[SciPy-dev] [Numpy-discussion] Re: How to handle a[...] in numpy?
ndarray at mac.com
Mon Jan 9 19:23:03 CST 2006
Attached patch implements indexing of zero rank arrays:
>>> x = array(42)
Ellipsis and empty tuple are the only two valid indices.
So far there was only one +1 vote for the feature (from Francesc
Altet, who also suggested that x[()] be allowed). Does anyone object
to this feature?
I have also proposed to support x[...,newaxis] (see comment by
sdementen at http://www.scipy.org/wikis/numdesign/). I will add this
feature if there is interest.
Finally, if we make x[...] valid for rank-0 arrays, should x[...] =
value be allowed as well? I think it should, applying the principle of
least surprized. An additional consideration is that rank-0 arrays
are unhashable, but there is no obvious way to change their values.
The following example show that rank-0 arrays are in fact mutable (in
a non-obvious way):
>>> x = array(1)
>>> x.shape=(1,); x = 42; x.shape=()
Please comment on the following proposals:
2. x[...] = value
3. x[..., newaxis]
More information about the Numpy-discussion