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?