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

Nathaniel Smith njs at pobox.com
Wed May 16 10:03:43 EDT 2012


On Tue, May 15, 2012 at 5:03 AM, Travis Oliphant <travis at continuum.io> wrote:
> So, the behavior is actually quite predictable, it's just that in some common cases it doesn't do what you would expect --- especially if you think that [0,1] is "the same" as :2.   When I wrote this code to begin with I should have raised an error and then worked in the cases that make sense.    This is a good example of making the mistake of thinking that it's better to provide something very general rather than just raise an error when an obvious and clear solution is not available.
>
> There is the possibility that we could now raise an error in NumPy when this situation is encountered because I strongly doubt anyone is actually relying on the current behavior.    I would like to do this, actually, as soon as possible.  Comments?

+1 from me.

It'd probably be a good idea to check for and deprecate any similarly
bizarre cases of mixed boolean indexing/slicing, mixed boolean/integer
indexing, etc.

- N



More information about the NumPy-Discussion mailing list