Skip to content

Conversation

@ev-br
Copy link
Member

@ev-br ev-br commented Jan 21, 2026

The spec only says that "If both min and max are None, the elements of the returned array must equal the respective elements in x"

Bare NumPy 2.x and CuPy 13.x return copes:

>>> x = np.arange(8); np.may_share_memory(x, np.clip(x))
False

Thus assume that all wrapped libraries should return a copy, too. Add a test to this effect.

Copilot AI review requested due to automatic review settings January 21, 2026 20:22
@ev-br
Copy link
Member Author

ev-br commented Jan 21, 2026

array-api-strict needs a fix --- data-apis/array-api-strict#180

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a test to verify that clip(x, None, None) returns a copy rather than a view, which aligns with the behavior of NumPy 2.x and CuPy 13.x. The specification doesn't explicitly require this behavior, but the test ensures consistency across wrapped libraries.

Changes:

  • Adds a new test test_clip_none that verifies clip returns a copy when both min and max are None

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

The spec only says that "If both min and max are None, the elements of
the returned array must equal the respective elements in x"

Bare NumPy 2.x and CuPy 13.x return copes:

>>> x = np.arange(8); np.may_share_memory(x, np.clip(x))
False

Thus assume that all wrapped libraries should return a copy, too.
Add a test to this effect.
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.

1 participant