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

Sasha ndarray at mac.com
Wed Jan 11 12:18:45 EST 2006


On 1/11/06, Travis Oliphant <oliphant.travis at ieee.org> wrote:
> ...
> I made just a couple of changes to the new checkin:  now only 1 ellipsis
> is allowed.  In the n-d case multiple ellipsis always treats elipsis
> after the first as ':' (full slice objects).  But 0-d arrays can't use
> the ':' object and so multiple ellipses should not be allowed.

As I mentioned on the Wiki page, I did not see any reason to allow multiple
Ellipses and only added them for consistency with the N-d case, so I like what
you did.  However, N-d arrays do allow a mix of multiple Ellipses and newaxes:

>>> from numpy import *
>>> x = array([[1,2,3],[4,5,6]])
>>> x.shape
(2, 3)
>>> x[newaxis,...,newaxis,...].shape
(1, 2, 1, 3)
>>> import numpy; numpy.__version__
'0.9.3.1831'

I think this should be disallowed in favor of more explicit
>>> x[newaxis,:,newaxis,...].shape
(1, 2, 1, 3)


-- sasha




More information about the SciPy-Dev mailing list