I am testing some edge cases of my program and observed a strange fact. When I create a scalar numpy array, it has size==1
and ndim==0
.
>>> A=np.array(1.0)
>>> A.ndim # returns 0
>>> A.size # returns 1
But when I create empty array with no element, then it has size==0
but ndim==1
.
>>> A=np.array([])
>>> A.ndim # returns 1
>>> A.size # returns 0
Why is that? I would expect the ndim
to be also 0
. Or is there another way of creation of 'really' empty array with size
and ndim
equal to 0
?
UPDATE: even A=np.empty(shape=None)
does not create dimensionless array of size 0...