[Numpy-discussion] Fancy-indexing reorders output in corner cases?
Stéfan van der Walt
stefan at sun.ac.za
Tue May 15 14:08:05 EDT 2012
On Mon, May 14, 2012 at 9:03 PM, Travis Oliphant <travis at continuum.io> wrote:
> What happens, though when you have
> a[:, in1 :, in2]?
> To "resolve" this ambiguity, the code sends the (3,4) sub-space to the front of the "dimensions" and returns (3,4,10,8). In retro-spect, the code should raise an error as I doubt anyone actually relies on this behavior, and then we could have "done the right" thing for situations like in1 being an integer which actually makes some sense and should not have been confused with the "general case"
You're right, the behavior is deterministic but counter-intuitive, and
at least warning in the case when dimensions get flipped around would
be helpful. Raising an error may break some code, though, so for that
we'll have to bump the API.
More information about the NumPy-Discussion