0

Indexing a NumPy array with None increases its number of dimensions, adding an axis with length 1:

import numpy
array = numpy.arange(1, 10)
for i in range(4):
    print (array )
    array = array[None]

This form is usually found with None replaced by its alias newaxis.

But what is the rationale making indexing with None meaningful regarding changing the shape?

Or is it just a convention to use without rational?

mins
  • 6,478
  • 12
  • 56
  • 75
  • It's a unique value that doesn't have any other use in indexing. – hpaulj Dec 16 '20 at 16:42
  • 1
    The same question also asked [here](https://stackoverflow.com/questions/1408311/numpy-array-slice-using-none) – anurag Dec 17 '20 at 12:07
  • @anurag. Good find, however while the rationale question was asked, it was never answered :-) – mins Dec 17 '20 at 12:29

1 Answers1

0

Super late response but I figure it could help those searching.

Answer is also here:

The authors of numpy just decided to use 'none' as an alias to newaxis. There is no rational. no english semantic to make this make sense. It's just a word they decided to use.