8000 API: bump MAXDIMS/MAXARGS to 64 introduce NPY_AXIS_RAVEL by seberg · Pull Request #25149 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

API: bump MAXDIMS/MAXARGS to 64 introduce NPY_AXIS_RAVEL #25149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Nov 28, 2023
Prev Previous commit
Next Next commit
TST: Add a few tests for paths that are for now limited to 32 dims
  • Loading branch information
seberg committed Nov 17, 2023
commit bbc40836309c8ec49bce25582ac23214b7e733ff
25 changes: 25 additions & 0 deletions numpy/_core/tests/test_multiarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -5828,6 +5828,15 @@ def test_index_getset(self):
# If the type was incorrect, this would show up on big-endian machines
assert it.index == it.base.size

def test_maxdims(self):
# The flat iterator and thus attribute is currently unfortunately
# limited to only 32 dimensions (after bumping it to 64 for 2.0)
a = np.ones((1,) * 64)

with pytest.raises(RuntimeError,
match=".*32 dimensions but the array has 64"):
a.flat


class TestResize:

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

def test_dimension_and_args_limit(self):
# Maxdims for the legacy iterator is 32, but the maximum number
# of arguments is actually larger (a itself also counts here)
a = np.ones((1,) * 32, dtype=np.intp)
res = a.choose([0, a] + [2] * 61)
with pytest.raises(ValueError,
match="Need at least 0 and at most 64 array objects"):
a.choose([0, a] + [2] * 62)

assert_array_equal(res, a)
# Choose is unfortunately limited to 32 dims as of NumPy 2.0
a = np.ones((1,) * 60, dtype=np.intp)
with pytest.raises(RuntimeError,
match=".*32 dimensions but the array has 60"):
a.choose([a, a])


class TestRepeat:
def setup_method(self):
Expand Down
0