Skip to content

Commit 05e6b22

Browse files
committed
Update multiaxis_indices to not generate too few indices
The spec now requires that a multiaxis index either has an ellipsis or exactly as many indices as dimensions.
1 parent 0b41f77 commit 05e6b22

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

array_api_tests/hypothesis_helpers.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,15 @@ def multiaxis_indices(draw, shapes):
288288

289289
# Avoid using 'in', which might do == on an array.
290290
res_has_ellipsis = any(i is ... for i in res)
291-
if n_entries == len(shape) and not res_has_ellipsis:
292-
# note("Adding extra")
293-
extra = draw(lists(one_of(integer_indices(sizes), slices(sizes)), min_size=0, max_size=3))
294-
res += extra
291+
if not res_has_ellipsis:
292+
if n_entries < len(shape):
293+
# The spec requires either an ellipsis or exactly as many indices
294+
# as dimensions.
295+
assume(False)
296+
elif n_entries == len(shape):
297+
# note("Adding extra")
298+
extra = draw(lists(one_of(integer_indices(sizes), slices(sizes)), min_size=0, max_size=3))
299+
res += extra
295300
return tuple(res)
296301

297302

0 commit comments

Comments
 (0)