-
Notifications
You must be signed in to change notification settings - Fork 10
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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
992412b
TST: Run all tests on read-only numpy arrays
crusaderky 1dcb9e6
Merge branch 'main' into numpy_ro
crusaderky 9d1a6bc
simplify Backend
crusaderky eba9b25
clarify docs
crusaderky 3cf11df
Remove unnecessary recursion guard
crusaderky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
from types import ModuleType | ||
|
||
import numpy as np | ||
import pytest | ||
|
||
from array_api_extra._lib import Backend | ||
from array_api_extra._lib._testing import xp_assert_equal | ||
from array_api_extra._lib._utils._compat import device as get_device | ||
from array_api_extra._lib._utils._helpers import in1d | ||
from array_api_extra._lib._utils._typing import Array, Device | ||
from array_api_extra._lib._utils._typing import Device | ||
|
||
# mypy: disable-error-code=no-untyped-usage | ||
|
||
|
@@ -16,10 +15,10 @@ class TestIn1D: | |
@pytest.mark.skip_xp_backend(Backend.DASK_ARRAY, reason="no argsort") | ||
@pytest.mark.skip_xp_backend(Backend.SPARSE, reason="no unique_inverse, no device") | ||
# cover both code paths | ||
@pytest.mark.parametrize("x2", [np.arange(9), np.arange(15)]) | ||
def test_no_invert_assume_unique(self, xp: ModuleType, x2: Array): | ||
@pytest.mark.parametrize("n", [9, 15]) | ||
def test_no_invert_assume_unique(self, xp: ModuleType, n: int): | ||
x1 = xp.asarray([3, 8, 20]) | ||
x2 = xp.asarray(x2) | ||
x2 = xp.arange(n) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
expected = xp.asarray([True, True, False]) | ||
actual = in1d(x1, x2) | ||
xp_assert_equal(actual, expected) | ||
|
@@ -30,6 +29,7 @@ def test_device(self, xp: ModuleType, device: Device): | |
x2 = xp.asarray([2, 3, 4], device=device) | ||
assert get_device(in1d(x1, x2)) == device | ||
|
||
@pytest.mark.skip_xp_backend(Backend.NUMPY_READONLY) | ||
@pytest.mark.skip_xp_backend(Backend.SPARSE, reason="no arange, no device") | ||
def test_xp(self, xp: ModuleType): | ||
x1 = xp.asarray([1, 6]) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 toa = a.__add__(b)