[Numpy-discussion] Response to PEP suggestions

Timo Korvola tkorvola at welho.com
Fri Feb 18 11:03:18 EST 2005

Robert Kern <rkern at ucsd.edu> writes:
> I'm not averse to len(x) returning 0 when given a rank-0 array. I see
> it as giving up one consistency (that scalar-like objects don't have
> lengths) for another (arrays having a common set of operations that
> one can expect regardless of rank or shape).

That would be akin to making 0/0 return 0.  It is possible to create
arrays of length zero, e.g, by indexing with an empty slice, and these
should not be confused with rank zero arrays.

> Might our PEP efforts be better spent locating and fixing the places
> in core Python where rank-0 arrays won't be accepted as core ints and
> floats?

Sounds useful.

> List/tuple indexing is one.

Rank 0 arrays should also be kept in mind when defining array indexing
in the PEP.

	Timo Korvola		<URL:http://www.iki.fi/tkorvola>

More information about the NumPy-Discussion mailing list