Skip to content

TST: Run all tests on read-only numpy arrays #92

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 5 commits into from
Jan 15, 2025

Conversation

crusaderky
Copy link
Contributor

No description provided.

@lucascolley lucascolley self-requested a review January 15, 2025 13:34
@@ -136,6 +136,7 @@ def test_device(self, xp: ModuleType, device: Device):
x = xp.asarray([1, 2, 3], device=device)
assert get_device(cov(x)) == device

@pytest.mark.skip_xp_backend(Backend.NUMPY_READONLY)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Notably, read-only numpy disallows __iadd__ etc., whereas jax and sparse simply don't define these methods, which causes them to fall back to a = a.__add__(b)

x1 = xp.asarray([3, 8, 20])
x2 = xp.asarray(x2)
x2 = xp.arange(n)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

NumPyReadOnly.asarray(x2, copy=None) was tainting the globally defined x2, ruining it for the following iterations of the test.

Copy link
Member

@lucascolley lucascolley left a comment

Choose a reason for hiding this comment

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

seems good, thanks!

@lucascolley lucascolley merged commit 5f4fa99 into data-apis:main Jan 15, 2025
10 checks passed
@crusaderky crusaderky deleted the numpy_ro branch January 15, 2025 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants