[Numpy-discussion] How to get the shape of an array slice without doing it
Fri Jan 29 12:27:24 CST 2010
On Fri, Jan 29, 2010 at 1:03 PM, Keith Goodman <firstname.lastname@example.org> wrote:
> On Fri, Jan 29, 2010 at 9:53 AM, <email@example.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
> (Ellipsis, 1)
> Ellipsis is a python class. Built in, no need to import.
thanks, this makes it possible to construct index lists with Ellipsis,
but it showed that my broadcast idea doesn't work this way
Travis explained last year how slices and broadcasting are used for
indexing, and it's quite a bit more complicated than this.
Sorry for jumping in too fast.
>>> indi= (slice(2,5),Ellipsis, np.arange(3)[:,None])
>>> ind2 = 
>>> for i in indi:
if not i is Ellipsis: ind2.append(i)
[slice(2, 5, None), slice(None, None, None), slice(None, None, None),
> NumPy-Discussion mailing list
More information about the NumPy-Discussion