[Numpy-discussion] Fancy-indexing reorders output in corner cases?
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
Excellent -- thanks!
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
More information about the NumPy-Discussion