[Numpy-discussion] How to get the shape of an array slice without doing it

Keith Goodman kwgoodman at gmail.com
Fri Jan 29 13:03:19 EST 2010


On Fri, Jan 29, 2010 at 9:53 AM,  <josef.pktd at gmail.com> wrote:
> I forgot about ellipsis, since I never use them,
> replace ellipsis by [slice(None)]*ndim or something like this
>
> I don't know how to access an ellipsis directly, is it even possible
> to construct an index list that contains an ellipsis?
> There is an object for it but I never looked at it.

I haven't been following the discussion and I don't understand your
question and in a moment I will accidentally hit send...

>> class eli(object):
   ...:
   ...:         def __init__(self):
   ...:             pass
   ...:
   ...:     def __getitem__(self, index):
   ...:             print index
   ...:

>> x[...]
Ellipsis
>> x[...,1]
(Ellipsis, 1)

Ellipsis is a python class. Built in, no need to import.



More information about the NumPy-Discussion mailing list