-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
Description
What happened?
With xarray==2025.12.0, the rioxarray tests started to fail:
https://github.com/corteva/rioxarray/actions/runs/19997389961/job/57347087949
The issue was traced back to this change #10948.
What did you expect to happen?
No error.
Minimal Complete Verifiable Example
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "xarray[complete]@git+https://github.com/pydata/xarray.git@main",
# ]
# ///
#
# This script automatically imports the development branch of xarray to check for issues.
# Please delete this header if you have _not_ tested this script with `uv run`!
import xarray as xr
xr.show_versions()
from xarray.core.indexing import normalize_indexer, _decompose_slice
print(_decompose_slice(slice(-1, None, -1), 8))
# (slice(0, 8, 1), slice(None, None, -1))
print(_decompose_slice(normalize_indexer(slice(-1, None, -1), 8), 8))
# Traceback (most recent call last):
# File "<stdin>", line 1, in <module>
# _decompose_slice(normalize_indexer(slice(-1, None, -1), 8), 8)
# ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# File ".../lib/python3.14/site-packages/xarray/core/indexing.py", # line 1217, in _decompose_slice
# exact_stop = range(start, stop, step)[-1]
# ~~~~~~~~~~~~~~~~~~~~~~~~^^^^
# IndexError: range object index out of rangeSteps to reproduce
No response
MVCE confirmation
- Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
- Complete example — the example is self-contained, including all data and the text of any traceback.
- Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
- New issue — a search of GitHub Issues suggests this is not a duplicate.
- Recent environment — the issue occurs with the latest version of xarray and its dependencies.
Relevant log output
=================================== FAILURES ===================================
________________________________ test_indexing _________________________________
def test_indexing():
...
# minus-stepped slice
ind = {"band": numpy.array([2, 1, 0]), "x": slice(-1, None, -1), "y": 0}
> assert_allclose(expected.isel(**ind), actual.isel(**ind))
...
testenv/lib/python3.12/site-packages/xarray/core/indexing.py:1415: in _decompose_outer_indexer
bk_slice, np_slice = _decompose_slice(k, s)
^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
key = slice(7, -1, -1), size = 8
def _decompose_slice(key: slice, size: int) -> tuple[slice, slice]:
# determine stop precisely for step > 1 case
# Use the range object to do the calculation
# e.g. [98:2:-2] -> [98:3:-2]
> exact_stop = range(start, stop, step)[-1]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E IndexError: range object index out of rangeAnything else we need to know?
No response
Environment
Details
https://github.com/corteva/rioxarray/actions/runs/19997389961/job/57347087949xarray-2025.12.0
cftime-1.6.5
cloudpickle-3.1.2
dask-2025.11.0
fsspec-2025.12.0
netcdf4-1.7.3