-
Notifications
You must be signed in to change notification settings - Fork 16
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
Changes from 3 commits
992412b
1dcb9e6
9d1a6bc
eba9b25
3cf11df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
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. Notably, read-only numpy disallows |
||
def test_xp(self, xp: ModuleType): | ||
xp_assert_close( | ||
cov(xp.asarray([[0.0, 2.0], [1.0, 1.0], [2.0, 0.0]]).T, xp=xp), | ||
|
@@ -366,6 +367,7 @@ def test_device(self, xp: ModuleType, device: Device): | |
x2 = xp.asarray([2, 3, 4], device=device) | ||
assert get_device(setdiff1d(x1, x2)) == device | ||
|
||
@pytest.mark.skip_xp_backend(Backend.NUMPY_READONLY) | ||
def test_xp(self, xp: ModuleType): | ||
x1 = xp.asarray([3, 8, 20]) | ||
x2 = xp.asarray([2, 3, 4]) | ||
|
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]) | ||
|
Uh oh!
There was an error while loading. Please reload this page.