Skip to content

Commit fc7039f

Browse files
committed
also check normalize_indexer
1 parent 2bfd28f commit fc7039f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

xarray/tests/test_indexing.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,24 @@ def test_read_only_view(self) -> None:
275275

276276

277277
class TestLazyArray:
278+
@pytest.mark.parametrize(
279+
["indexer", "size", "expected"],
280+
(
281+
(4, 5, 4),
282+
(-1, 3, 2),
283+
(slice(None), 4, slice(0, 4, 1)),
284+
(slice(1, -3), 7, slice(1, 4, 1)),
285+
(np.array([-1, 3, -2]), 5, np.array([4, 3, 3])),
286+
),
287+
)
288+
def normalize_indexer(self, indexer, size, expected):
289+
actual = indexing.normalize_indexer(indexer, size)
290+
291+
if isinstance(expected, np.ndarray):
292+
np.testing.assert_equal(actual, expected)
293+
else:
294+
assert actual == expected
295+
278296
def test_slice_slice(self) -> None:
279297
arr = ReturnItem()
280298
for size in [100, 99]:

0 commit comments

Comments
 (0)