[Numpy-discussion] NEP 21: Simplified and explicit advanced indexing

Robert Kern robert.kern at gmail.com
Tue Jun 26 03:46:02 EDT 2018


On Tue, Jun 26, 2018 at 12:13 AM Eric Wieser <wieser.eric+numpy at gmail.com>
wrote:

> > I don't think it should be relegated to the "officially discouraged"
> ghetto of `.legacy_index`
>
> The way I read it, the new spelling lof that would be the explicit but not
> discouraged `image.vindex[rr, cc]`.
>

Okay, I missed that the first time through. I think having more
self-contained descriptions of the semantics of each of these would be a
good idea. The current description of `.vindex` spends more time talking
about what it doesn't do, compared to the other methods, than what it does.

Some more typical, less-exotic examples would be a good idea.

> I would reserve warnings for the cases where the current behavior is
> something no one really wants, like mixing slices and integer arrays.
>
> These are the cases that would only be available under `legacy_index`.
>

I'm still leaning towards not warning on current, unproblematic common
uses. It's unnecessary churn for currently working, understandable code. I
would still reserve warnings and deprecation for the cases where the
current behavior gives us something that no one wants. Those are the real
traps that people need to be warned away from.

If someone is mixing slices and integer indices, that's a really good sign
that they thought indexing behaved in a different way (e.g. orthogonal
indexing).

If someone is just using multiple index arrays that would currently not
give an error, that's actually a really good sign that they are using it
correctly and are getting the semantics that they desired. If they wanted
orthogonal indexing, it is *really* likely that their index arrays would
*not* broadcast together. And even if they did, the wrong shape of the
result is one of the more easily noticed things. These are not silent
errors that would motivate adding a new warning.

-- 
Robert Kern
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20180626/569afde2/attachment.html>


More information about the NumPy-Discussion mailing list