[Numpy-discussion] Question about indexing
Keith Goodman
kwgoodman@gmail....
Thu May 29 23:14:15 CDT 2008
On Thu, May 29, 2008 at 8:50 PM, Alan G Isaac <aisaac@american.edu> wrote:
> Is ``a[[0,1]]`` completely equivalent to ``a[[0,1],...]``
> and ``a[[0,1],:]``?
They look, smell, and taste the same. But I can't read array's
__getitem__ since it is in C instead of python.
>> np.index_exp[[0,1]]
([0, 1],)
>> np.index_exp[[0,1],:]
([0, 1], slice(None, None, None))
>> np.index_exp[[0,1],...]
([0, 1], Ellipsis)
>> a[[0,1]].flags
C_CONTIGUOUS : True
F_CONTIGUOUS : False
OWNDATA : True
WRITEABLE : True
ALIGNED : True
UPDATEIFCOPY : False
>>
>> a[[0,1],:].flags
C_CONTIGUOUS : True
F_CONTIGUOUS : False
OWNDATA : True
WRITEABLE : True
ALIGNED : True
UPDATEIFCOPY : False
>>
>> a[[0,1],...].flags
C_CONTIGUOUS : True
F_CONTIGUOUS : False
OWNDATA : True
WRITEABLE : True
ALIGNED : True
UPDATEIFCOPY : False
Now, pop quiz, what does this mean:
>> a[[[[[[[[[[[[[[[[0,1]]]]]]]]]]]]]]]]
array([[[[[[[[[[[[[[[0, 1, 2],
[3, 4, 5]]]]]]]]]]]]]]])
?
More information about the Numpy-discussion
mailing list