Skip to content

Commit b47e667

Browse files
committed
Make the meta-tests work with any array API compliant library
1 parent db9beae commit b47e667

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
from ..array_helpers import exactly_equal, notequal, int_to_dtype
22
from ..hypothesis_helpers import integer_dtypes
33
from ..test_type_promotion import dtype_nbits, dtype_signed
4+
from .._array_module import asarray, nan, equal, all
45

56
from hypothesis import given, assume
67
from hypothesis.strategies import integers
7-
import numpy as np
88

99
# TODO: These meta-tests currently only work with NumPy
1010

1111
def test_exactly_equal():
12-
a = np.array([0, 0., -0., -0., np.nan, np.nan, 1, 1])
13-
b = np.array([0, -1, -0., 0., np.nan, 1, 1, 2])
12+
a = asarray([0, 0., -0., -0., nan, nan, 1, 1])
13+
b = asarray([0, -1, -0., 0., nan, 1, 1, 2])
1414

15-
res = np.array([True, False, True, False, True, False, True, False])
16-
np.testing.assert_equal(exactly_equal(a, b), res)
15+
res = asarray([True, False, True, False, True, False, True, False])
16+
assert all(equal(exactly_equal(a, b), res))
1717

1818
def test_notequal():
19-
a = np.array([0, 0., -0., -0., np.nan, np.nan, 1, 1])
20-
b = np.array([0, -1, -0., 0., np.nan, 1, 1, 2])
19+
a = asarray([0, 0., -0., -0., nan, nan, 1, 1])
20+
b = asarray([0, -1, -0., 0., nan, 1, 1, 2])
2121

22-
res = np.array([False, True, False, False, False, True, False, True])
23-
np.testing.assert_equal(notequal(a, b), res)
22+
res = asarray([False, True, False, False, False, True, False, True])
23+
assert all(equal(notequal(a, b), res))
2424

2525
@given(integers(), integer_dtypes)
2626
def test_int_to_dtype(x, dtype):
2727
n = dtype_nbits(dtype)
2828
signed = dtype_signed(dtype)
2929
try:
30-
d = dtype(x)
30+
d = asarray(x, dtype=dtype)
3131
except OverflowError:
3232
assume(False)
3333
assert int_to_dtype(x, n, signed) == d

0 commit comments

Comments
 (0)