Skip to content

Commit 5b2de94

Browse files
authored
Use Cubed version of array assertion functions in tests (#802)
1 parent 167a5b3 commit 5b2de94

17 files changed

+23
-23
lines changed

cubed/tests/array/test_nan_functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import numpy as np
22
import pytest
3-
from numpy.testing import assert_array_equal
43

54
import cubed
65
import cubed.array_api as xp
6+
from cubed._testing import assert_array_equal
77

88

99
@pytest.fixture

cubed/tests/array/test_overlap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import numpy as np
2-
from numpy.testing import assert_array_equal
32

43
import cubed
54
import cubed.array_api as xp
5+
from cubed._testing import assert_array_equal
66

77

88
def test_map_overlap_1d():

cubed/tests/array/test_pad.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import numpy as np
22
import pytest
3-
from numpy.testing import assert_array_equal
43

54
import cubed
65
import cubed.array_api as xp
6+
from cubed._testing import assert_array_equal
77

88

99
@pytest.fixture

cubed/tests/primitive/test_blockwise.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import numpy as np
22
import pytest
3-
from numpy.testing import assert_array_equal
43

4+
from cubed._testing import assert_array_equal
55
from cubed.backend_array_api import namespace as nxp
66
from cubed.primitive.blockwise import (
77
blockwise,

cubed/tests/primitive/test_rechunk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import numpy as np
22
import pytest
33
import zarr
4-
from numpy.testing import assert_array_equal
54

5+
from cubed._testing import assert_array_equal
66
from cubed.primitive.rechunk import rechunk
77
from cubed.runtime.executors.local import SingleThreadedExecutor
88
from cubed.storage.backend import open_backend_array

cubed/tests/test_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
import dill
66
import numpy as np
77
import pytest
8-
from numpy.testing import assert_array_equal
98

109
import cubed
1110
import cubed.array_api as xp
1211
import cubed.random
12+
from cubed._testing import assert_array_equal
1313
from cubed.array_api.dtypes import _floating_dtypes
1414
from cubed.backend_array_api import namespace as nxp
1515
from cubed.core.ops import general_blockwise, merge_chunks, partial_reduce, tree_reduce

cubed/tests/test_executor_features.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
import numpy as np
66
import psutil
77
import pytest
8-
from numpy.testing import assert_array_equal
98

109
import cubed
1110
import cubed.array_api as xp
1211
import cubed.random
12+
from cubed._testing import assert_array_equal
1313
from cubed.diagnostics import ProgressBar
1414
from cubed.diagnostics.history import HistoryCallback
1515
from cubed.diagnostics.mem_usage import MemoryVisualizationCallback

cubed/tests/test_groupby.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import numpy as np
22
import numpy_groupies as npg
33
import pytest
4-
from numpy.testing import assert_array_equal
54

65
import cubed.array_api as xp
6+
from cubed._testing import assert_array_equal
77
from cubed.backend_array_api import namespace as nxp
88
from cubed.core.groupby import (
99
_get_chunks_for_groups,

cubed/tests/test_gufunc.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import numpy as np
22
import pytest
3-
from numpy.testing import assert_allclose, assert_equal
43

54
import cubed
65
import cubed.array_api as xp
76
from cubed import apply_gufunc
7+
from cubed._testing import assert_allclose, assert_array_equal
88
from cubed.backend_array_api import namespace as nxp
99

1010

@@ -35,7 +35,7 @@ def add(x, y):
3535
a = cubed.from_array(np.array([1, 2, 3]), chunks=2, spec=spec)
3636
b = cubed.from_array(np.array([1, 2, 3]), chunks=2, spec=spec)
3737
z = apply_gufunc(add, "(),()->()", a, b, output_dtypes=a.dtype)
38-
assert_equal(z, np.array([2, 4, 6]))
38+
assert_array_equal(z, np.array([2, 4, 6]))
3939

4040

4141
def test_apply_gufunc_elemwise_01_non_cubed_input(spec):
@@ -45,7 +45,7 @@ def add(x, y):
4545
a = cubed.from_array(np.array([1, 2, 3]), chunks=3, spec=spec)
4646
b = np.array([1, 2, 3])
4747
z = apply_gufunc(add, "(),()->()", a, b, output_dtypes=a.dtype)
48-
assert_equal(z, np.array([2, 4, 6]))
48+
assert_array_equal(z, np.array([2, 4, 6]))
4949

5050

5151
def test_apply_gufunc_elemwise_loop(spec):
@@ -56,7 +56,7 @@ def foo(x):
5656
a = cubed.from_array(np.array([1, 2, 3]), chunks=2, spec=spec)
5757
z = apply_gufunc(foo, "()->()", a, output_dtypes=int)
5858
assert z.chunks == ((2, 1),)
59-
assert_equal(z, np.array([2, 4, 6]))
59+
assert_array_equal(z, np.array([2, 4, 6]))
6060

6161

6262
def test_apply_gufunc_elemwise_core(spec):
@@ -67,7 +67,7 @@ def foo(x):
6767
a = cubed.from_array(np.array([1, 2, 3]), chunks=3, spec=spec)
6868
z = apply_gufunc(foo, "(i)->(i)", a, output_dtypes=int)
6969
assert z.chunks == ((3,),)
70-
assert_equal(z, np.array([2, 4, 6]))
70+
assert_array_equal(z, np.array([2, 4, 6]))
7171

7272

7373
def test_gufunc_two_inputs(spec):
@@ -77,7 +77,7 @@ def foo(x, y):
7777
a = xp.ones((2, 3), chunks=100, dtype=int, spec=spec)
7878
b = xp.ones((3, 4), chunks=100, dtype=int, spec=spec)
7979
x = apply_gufunc(foo, "(i,j),(j,k)->(i,k)", a, b, output_dtypes=int)
80-
assert_equal(x, 3 * np.ones((2, 4), dtype=int))
80+
assert_array_equal(x, 3 * np.ones((2, 4), dtype=int))
8181

8282

8383
def test_apply_gufunc_axes_two_kept_coredims(spec):
@@ -101,7 +101,7 @@ def foo(x):
101101
a = cubed.from_array(np.array([1, 2, 3, 4, 5], dtype=int), spec=spec)
102102
x = apply_gufunc(foo, "()->(i_0)", a, output_dtypes=int, output_sizes={"i_0": 3})
103103
assert x.chunks == ((5,), (3,))
104-
assert_equal(
104+
assert_array_equal(
105105
x,
106106
np.array(
107107
[

cubed/tests/test_icechunk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
import numpy as np
44
import pytest
55
import zarr
6-
from numpy.testing import assert_array_equal
76

87
import cubed
98
import cubed.array_api as xp
109
import cubed.random
10+
from cubed._testing import assert_array_equal
1111
from cubed.tests.utils import MAIN_EXECUTORS
1212

1313
icechunk = pytest.importorskip("icechunk")

0 commit comments

Comments
 (0)