[Numpy-discussion] Fancy-indexing reorders output in corner cases?
Zachary Pincus
zachary.pincus at yale.edu
Mon May 14 22:34:23 EDT 2012
> On Mon, May 14, 2012 at 4:33 PM, Zachary Pincus <zachary.pincus at yale.edu> wrote:
>> The below seems to be a bug, but perhaps it's unavoidably part of the indexing mechanism?
>>
>> It's easiest to show via example... note that using "[0,1]" to pull two columns out of the array gives the same shape as using ":2" in the simple case, but when there's additional slicing happening, the shapes get transposed or something.
>
> When fancy indexing and slicing is mixed, the resulting shape is
> essentially unpredictable.
Aah, right -- this does come up on the list not infrequently, doesn't it. I'd always thought it was more exotic usages that raised these issues. Good to know.
> The "correct" way to do it is to only use
> fancy indexing, i.e. generate the indices of the sliced dimension as
> well.
>
Excellent -- thanks!
> Stéfan
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
More information about the NumPy-Discussion
mailing list