On Tue, Jun 26, 2018 at 9:38 AM Eric Wieser <wieser.eric+nu...@gmail.com> wrote:
> 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: https://github.com/pydata/xarray/blob/v0.10.7/xarray/core/indexing.py#L295-L428 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: https://github.com/pydata/xarray/blob/v0.10.7/xarray/core/indexing.py#L654 I guess this is a case for using such classes internally in NumPy, and possibly for exposing them publicly as well.
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion