array-api icon indicating copy to clipboard operation
array-api copied to clipboard

Specify multi-indexing behaviour?

Open jni opened this issue 2 years ago • 2 comments

As far as I can tell, the array API doesn't specify how multi-indexing (e.g. arr[[1, 8, 9]]) works, either for single axis or multiple axes. I presume this is because different libraries have settled on different behaviour here, and it is hard to find community consensus on whether vectorised indexing (NumPy style) or orthogonal indexing (I think xarray? Maybe others?) should be used. My personal view is that we should all just use vector indexing by default but, failing that, it would still be very useful to settle on .vindex and .oindex properties for the API. I think these are either available or already do the "obviously" right thing on different array implementations.

Having a consistent API for vector indexing is extremely high value for napari, where we want to be compatible with any array input and need to write into arrays using fancy indexing (e.g. to annotate with a circular brush). Other libraries like scikit-image would certainly also benefit.

jni avatar Mar 26 '22 01:03 jni

If you mean integer array indexing, that is being discussed in #177. So far it's been omitted because not all libraries implement it.

If you just mean indexing with a tuple, like arr[1, 8, 9], that should be specified pretty well right now, so you'd need to clarify exactly what is missing.

asmeurer avatar Mar 26 '22 01:03 asmeurer

Bumping this thread as vindex & oindex came up in a recent meeting.

Also as it came up in the context of Zarr recently, which implements both the advanced indexing and vindex & oindex.

Should add Dask implements vindex (with some caveats), but not oindex currently.

jakirkham avatar May 17 '22 20:05 jakirkham

I'm going to close this issue in favor of https://github.com/data-apis/array-api/issues/669, where we are also discussing integer array indexing.

kgryte avatar Apr 04 '24 07:04 kgryte