Skip to content

Commit a60406e

Browse files
committed
Remove mixed int/slice indexing test case
1 parent 0b84419 commit a60406e

1 file changed

Lines changed: 1 addition & 26 deletions

File tree

tests/test_indexing.py

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#!/usr/bin/env python3
22
"""Property tests comparing RasterIndex with PandasIndex for indexing operations."""
33

4-
from collections.abc import Hashable
5-
64
import numpy as np
75
import pytest
86
import xarray as xr
@@ -23,27 +21,6 @@
2321
)
2422

2523

26-
def is_mixed_scalar_slice_indexer(indexers: dict[Hashable, int | slice]) -> bool:
27-
# TODO: Fix bug in RasterIndex with mixed scalar/slice indexing across dimensions
28-
# When you have scalar indexing on one dimension (e.g., y=0) and slice indexing
29-
# on another (e.g., x=slice(None, 1)), RasterIndex.isel() returns None for the
30-
# scalar dimension, dropping that index. This causes xarray to incorrectly handle
31-
# the coordinate variables - the sliced dimension's coordinate (x) maintains
32-
# dims ('x',) even though the data has been reduced by the scalar indexing.
33-
# This results in: "ValueError: dimensions ('x',) must have the same length as
34-
# the number of data dimensions, ndim=0"
35-
#
36-
# Example failing case: raster_da.isel(y=0, x=slice(None, 1))
37-
# - y=0 causes RasterIndex to return None for y dimension
38-
# - x=slice(None, 1) preserves RasterIndex for x dimension
39-
# - Result: coordinate variable x has wrong dimensionality
40-
#
41-
# For now, filter out these cases using hypothesis.assume()
42-
has_scalar = any(isinstance(v, int | np.integer) for v in indexers.values())
43-
has_slice = any(isinstance(v, slice) for v in indexers.values())
44-
return has_scalar and has_slice and len(indexers) > 1
45-
46-
4724
@pytest.fixture
4825
def raster_da():
4926
"""Create a DataArray with RasterIndex coordinates."""
@@ -92,9 +69,7 @@ def pandas_da(raster_da):
9269
def test_isel_basic_indexing_equivalence(data, raster_da, pandas_da):
9370
"""Test that isel produces identical results for RasterIndex and PandasIndex."""
9471
sizes = dict(raster_da.sizes)
95-
indexers = data.draw(
96-
basic_indexers(sizes=sizes).filter(lambda idxr: not is_mixed_scalar_slice_indexer(idxr))
97-
)
72+
indexers = data.draw(basic_indexers(sizes=sizes))
9873
result_raster = raster_da.isel(indexers)
9974
result_pandas = pandas_da.isel(indexers)
10075
xr.testing.assert_identical(result_raster, result_pandas)

0 commit comments

Comments
 (0)