Skip to content

Fix NumPy clip with read-only integer bounds - #486

Merged
ev-br merged 1 commit into
data-apis:mainfrom
AryanRG:fix-numpy-clip-readonly-bounds
Nov 1, 2026
Merged

ev-br merged 1 commit into
data-apis:mainfrom
AryanRG:fix-numpy-clip-readonly-bounds

Conversation

@AryanRG

@AryanRG AryanRG commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

NumPy clip raises ValueError: assignment destination is read-only when an integer array is clipped with same-dtype bounds from broadcast_to or an array marked read-only.

Skip the range adjustment when a bound already has the input dtype, since its values are representable. Regression tests cover lower and upper bounds, broadcasted bounds, and out= without changing the bound or input.

Validated the NumPy tests on NumPy 1.26.4 and 2.5.4, plus the local suite with NumPy and Torch. Optional backends were skipped.

@ev-br

ev-br commented Oct 31, 2026

Copy link
Copy Markdown
Member

CI failures:

@ev-br

ev-br commented Nov 1, 2026

Copy link
Copy Markdown
Member

Apart from unrelated failures, the patch LGTM.

@ev-br
ev-br merged commit 0ab2046 into data-apis:main Nov 1, 2026
21 of 28 checks passed
@ev-br

ev-br commented Nov 1, 2026

Copy link
Copy Markdown
Member

Merged, thank you @AryanRG !

@antonwolfy

Copy link
Copy Markdown
Contributor

@ev-br

This comes from dpnp 0.21.0, released on Oct 28. It moved to the 2025.12 version.
dpnp's __array_namespace__ accepts only the version it implements, so api_version="2024.12" now raises ValueError: Only 2025.12 is supported.

I believe this is intended on the dpnp side. And so the fix is to add "2024.12" to the dpnp xfail list in tests/test_array_namespace.py. I'm happy to open a PR for it.

@ev-br

ev-br commented Nov 2, 2026

Copy link
Copy Markdown
Member

Happy to review a PR for skipping 2024.12!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants