cubed icon indicating copy to clipboard operation
cubed copied to clipboard

Support negative step size in indexing

Open tomwhite opened this issue 10 months ago • 1 comments

From @dcherian in https://github.com/cubed-dev/cubed/pull/636#discussion_r1869951520

https://github.com/pydata/xarray/blob/99ee8c6ca54057a9b994d7685f36236f2d5a69d9/xarray/core/indexing.py#L1084 and friends. We rewrite the query to normal slice with +ve stride, then reverse in-memory after read :)

This is one of Xarray's magic tricks that very few people know about. We guarantee consistent indexing API over any array for the most part.

In https://github.com/pydata/xarray/issues/8667, I suggested reusing this machinery for cubed.

EDIT: actually my comment is here: https://github.com/pydata/xarray/issues/8834#issuecomment-2124943965

tomwhite avatar Dec 04 '24 17:12 tomwhite