[Numpy-discussion] Re: [SciPy-dev] How to handle a[...] in numpy?

Sasha ndarray at mac.com
Mon Jan 9 10:20:02 CST 2006


On 1/9/06, Francesc Altet <faltet at carabos.com> wrote:
> ...
> I'd propose the next behaviour for 0-rank arrays:
>
> In [65]: type(numpy.array(0)[...])
> Out[65]: <type 'numpy.ndarray'>
>
> In [66]: type(numpy.array(0)[()])   # Indexing a la numarray
> Out[66]: <type 'int32_arrtype'>
>

I like the idea of supporting [()] on zero rank ndarrays, but I think
it should be equivalent to [...].  I view [...] as [(slice(None),) *
rank], and thus for rank=0, [...] is the same as [()].

Furthermore, I don't see any use for [...] that always returns the
same array.  As far as I remember in some old version of Numeric,
[...] was a way to make a contiguous copy, but in numpy this is not
the case (one needs to use copy method for that).

>>> x[::2][...].flags
{'WRITEABLE': True, 'UPDATEIFCOPY': False, 'CONTIGUOUS': False,
'FORTRAN': False, 'ALIGNED': True, 'OWNDATA': False}

-- sasha




More information about the Numpy-discussion mailing list