|
1 | 1 | from ..array_helpers import exactly_equal, notequal, int_to_dtype
|
2 | 2 | from ..hypothesis_helpers import integer_dtypes
|
3 | 3 | from ..test_type_promotion import dtype_nbits, dtype_signed
|
| 4 | +from .._array_module import asarray, nan, equal, all |
4 | 5 |
|
5 | 6 | from hypothesis import given, assume
|
6 | 7 | from hypothesis.strategies import integers
|
7 |
| -import numpy as np |
8 | 8 |
|
9 | 9 | # TODO: These meta-tests currently only work with NumPy
|
10 | 10 |
|
11 | 11 | 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]) |
14 | 14 |
|
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)) |
17 | 17 |
|
18 | 18 | 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]) |
21 | 21 |
|
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)) |
24 | 24 |
|
25 | 25 | @given(integers(), integer_dtypes)
|
26 | 26 | def test_int_to_dtype(x, dtype):
|
27 | 27 | n = dtype_nbits(dtype)
|
28 | 28 | signed = dtype_signed(dtype)
|
29 | 29 | try:
|
30 |
| - d = dtype(x) |
| 30 | + d = asarray(x, dtype=dtype) |
31 | 31 | except OverflowError:
|
32 | 32 | assume(False)
|
33 | 33 | assert int_to_dtype(x, n, signed) == d
|
0 commit comments