10000 TST: Add a few tests for paths that are for now limited to 32 dims · numpy/numpy@0a6dbd1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0a6dbd1

Browse files
committed
TST: Add a few tests for paths that are for now limited to 32 dims
1 parent 70cdd23 commit 0a6dbd1

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

numpy/_core/tests/test_multiarray.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5828,6 +5828,15 @@ def test_index_getset(self):
58285828
# If the type was incorrect, this would show up on big-endian machines
58295829
assert it.index == it.base.size
58305830

5831+
def test_maxdims(self):
5832+
# The flat iterator and thus attribute is currently unfortunately
5833+
# limited to only 32 dimensions (after bumping it to 64 for 2.0)
5834+
a = np.ones((1,) * 64)
5835+
5836+
with pytest.raises(RuntimeError,
5837+
match=".*32 dimensions but the array has 64"):
5838+
a.flat
5839+
58315840

58325841
class TestResize:
58335842

@@ -7406,6 +7415,22 @@ def test_output_dtype(self, ops):
74067415
expected_dt = np.result_type(*ops)
74077416
assert(np.choose([0], ops).dtype == expected_dt)
74087417

7418+
def test_dimension_and_args_limit(self):
7419+
# Maxdims for the legacy iterator is 32, but the maximum number
7420+
# of arguments is actually larger (a itself also counts here)
7421+
a = np.ones((1,) * 32, dtype=np.intp)
7422+
res = a.choose([0, a] + [2] * 61)
7423+
with pytest.raises(ValueError,
7424+
match="Need at least 0 and at most 64 array objects"):
7425+
a.choose([0, a] + [2] * 62)
7426+
7427+
assert_array_equal(res, a)
7428+
# Choose is unfortunately limited to 32 dims as of NumPy 2.0
7429+
a = np.ones((1,) * 60, dtype=np.intp)
7430+
with pytest.raises(RuntimeError,
7431+
match=".*32 dimensions but the array has 60"):
7432+
a.choose([a, a])
7433+
74097434

74107435
class TestRepeat:
74117436
def setup_method(self):

0 commit comments

Comments
 (0)
0