[Numpy-discussion] Fancy-indexing reorders output in corner cases?

Stéfan van der Walt stefan at sun.ac.za
Mon May 14 20:07:04 EDT 2012

Hi Zach

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.  The "correct" way to do it is to only use
fancy indexing, i.e. generate the indices of the sliced dimension as


More information about the NumPy-Discussion mailing list