Skip to content

Commit 73fc486

Browse files
committed
Test nps.basic_indices() still generates flat indices
1 parent 7927a70 commit 73fc486

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

hypothesis-python/tests/numpy/test_gen_data.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,18 @@ def test_basic_indices_replaces_whole_axis_slices_with_ellipsis(idx):
11281128
assert slice(None) not in idx
11291129

11301130

1131+
def test_basic_indices_can_generate_indices_not_covering_all_dims():
1132+
# These "flat indices" are skippable in the underlying BasicIndexStrategy,
1133+
# so we ensure we're definitely generating them for nps.basic_indices().
1134+
find_any(
1135+
nps.basic_indices(shape=(3, 3, 3)),
1136+
lambda ix: (
1137+
(not isinstance(ix, tuple) and ix != Ellipsis)
1138+
or (isinstance(ix, tuple) and Ellipsis not in ix and len(ix) < 3)
1139+
),
1140+
)
1141+
1142+
11311143
@given(
11321144
shape=nps.array_shapes(min_dims=0, max_side=4)
11331145
| nps.array_shapes(min_dims=0, min_side=0, max_side=10),

0 commit comments

Comments
 (0)