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

Stephan Hoyer shoyer at gmail.com
Tue Jun 26 21:22:24 EDT 2018

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

> We can expose some of the internals
> These could be expressed as methods on the internal indexing objects I
> proposed in the first reply to this thread, which has seen no responses.
> I think Hameer Abbasi is looking for something like OrthogonalIndexer(...).to_vindex()
> -> VectorizedIndexer such that arr.oindex[ind] selects the same elements
> as arr.vindex[OrthogonalIndexer(ind).to_vindex()]
> Eric

It is probably worth noting that xarray already uses very similar classes
internally for keeping track of indexing operations. See BasicIndexer,
OuterIndexer and VectorizedIndexer:

This turns out to be pretty convenient model even when not using
subclassing. In xarray, we use them internally in various "partial duck
array" classes that do some lazy computation upon indexing with
__getitem__. It's nice to simply be able to forward on Indexer objects
rather than implement separate vindex/oindex methods.

We also have utility functions for converting between different forms,
e.g., from OuterIndexer to VectorizedIndexer:

I guess this is a case for using such classes internally in NumPy, and
possibly for exposing them publicly as well.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20180626/819c5c79/attachment.html>

More information about the NumPy-Discussion mailing list