From 9cd8883d224da2ed24112cd5ad7c00fd2e034155 Mon Sep 17 00:00:00 2001 From: Evgeni Burovski Date: Sat, 22 Nov 2025 16:29:04 +0100 Subject: [PATCH 1/2] ENH: test take_along_axis with indices < 0 --- array_api_tests/test_indexing_functions.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/array_api_tests/test_indexing_functions.py b/array_api_tests/test_indexing_functions.py index 7b8c8763..6cea0a66 100644 --- a/array_api_tests/test_indexing_functions.py +++ b/array_api_tests/test_indexing_functions.py @@ -77,7 +77,6 @@ def test_take(x, data): ) def test_take_along_axis(x, data): # TODO - # 2. negative indices # 3. different dtypes for indices # 4. "broadcast-compatible" indices axis = data.draw( @@ -97,7 +96,7 @@ def test_take_along_axis(x, data): hh.arrays( shape=idx_shape, dtype=dh.default_int, - elements={"min_value": 0, "max_value": x.shape[n_axis]-1} + elements={"min_value": -x.shape[n_axis], "max_value": x.shape[n_axis]-1} ), label="indices" ) From 27845161d97f3c93e5c3e009370bae2f9f7d19a2 Mon Sep 17 00:00:00 2001 From: Evgeni Burovski Date: Sat, 22 Nov 2025 17:18:28 +0100 Subject: [PATCH 2/2] ENH: test take with negative indices --- array_api_tests/test_indexing_functions.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/array_api_tests/test_indexing_functions.py b/array_api_tests/test_indexing_functions.py index 6cea0a66..b3510e60 100644 --- a/array_api_tests/test_indexing_functions.py +++ b/array_api_tests/test_indexing_functions.py @@ -17,7 +17,6 @@ ) def test_take(x, data): # TODO: - # * negative indices # * different dtypes for indices # axis is optional but only if x.ndim == 1 @@ -28,7 +27,7 @@ def test_take(x, data): kw = {"axis": data.draw(_axis_st)} axis = kw.get("axis", 0) _indices = data.draw( - st.lists(st.integers(0, x.shape[axis] - 1), min_size=1, unique=True), + st.lists(st.integers(-x.shape[axis], x.shape[axis] - 1), min_size=1, unique=True), label="_indices", ) n_axis = axis if axis>=0 else x.ndim + axis