[Numpy-discussion] numarray: shape of scalar

Todd Miller jmiller at stsci.edu
Tue Mar 9 10:29:21 CST 2004


On Tue, 2004-03-09 at 13:00, Sebastian Haase wrote:
> Hi,
> Is this intended:

Yes.

> >>> na.array([1,2,4]).shape
> (3,)
> >>> na.array([1,2]).shape
> (2,)
> >>> na.array([1]).shape
> (1,)
> >>> na.array(1).shape
> ()
> 
> Why is na.array([1]).shape not equal to na.array(1).shape ?

na.array(1) is how you say "make a rank-0 array with contents 1".  There
are places where it is natural and useful in the *implementation* of
numarray.

> Did I miss the respective section in the manual ?

rank-0 arrays are a dark corner of numarray which is mostly hidden.  I
don't think they're documented anywhere.


Regards,
Todd

-- 
Todd Miller <jmiller at stsci.edu>





More information about the Numpy-discussion mailing list