[Numpy-discussion] Matching 0-d arrays and NumPy scalars

Anne Archibald peridot.faceted at gmail.com
Thu Feb 21 18:43:49 EST 2008


On 21/02/2008, Stefan van der Walt <stefan at sun.ac.za> wrote:

>  Could I ask that we also consider implementing len() for 0-d arrays?
>  numpy.asarray returns those as-is, and I would like to be able to
>  handle them just as I do any other 1-dimensional array.  I don't know
>  if a length of 1 would be valid, given a shape of (), but there must
>  be some consistent way of handling them.

Well, if the length of an array is the product of all its sizes, the
product of no things is customarily defined to be one... whether that
is actually a useful value is another question.

Anne



More information about the NumPy-Discussion mailing list