1
1
import numpy as np
2
2
import pytest
3
- from numpy .testing import assert_allclose , assert_equal
4
3
5
4
import cubed
6
5
import cubed .array_api as xp
7
6
from cubed import apply_gufunc
7
+ from cubed ._testing import assert_allclose , assert_array_equal
8
8
from cubed .backend_array_api import namespace as nxp
9
9
10
10
@@ -35,7 +35,7 @@ def add(x, y):
35
35
a = cubed .from_array (np .array ([1 , 2 , 3 ]), chunks = 2 , spec = spec )
36
36
b = cubed .from_array (np .array ([1 , 2 , 3 ]), chunks = 2 , spec = spec )
37
37
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 ]))
39
39
40
40
41
41
def test_apply_gufunc_elemwise_01_non_cubed_input (spec ):
@@ -45,7 +45,7 @@ def add(x, y):
45
45
a = cubed .from_array (np .array ([1 , 2 , 3 ]), chunks = 3 , spec = spec )
46
46
b = np .array ([1 , 2 , 3 ])
47
47
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 ]))
49
49
50
50
51
51
def test_apply_gufunc_elemwise_loop (spec ):
@@ -56,7 +56,7 @@ def foo(x):
56
56
a = cubed .from_array (np .array ([1 , 2 , 3 ]), chunks = 2 , spec = spec )
57
57
z = apply_gufunc (foo , "()->()" , a , output_dtypes = int )
58
58
assert z .chunks == ((2 , 1 ),)
59
- assert_equal (z , np .array ([2 , 4 , 6 ]))
59
+ assert_array_equal (z , np .array ([2 , 4 , 6 ]))
60
60
61
61
62
62
def test_apply_gufunc_elemwise_core (spec ):
@@ -67,7 +67,7 @@ def foo(x):
67
67
a = cubed .from_array (np .array ([1 , 2 , 3 ]), chunks = 3 , spec = spec )
68
68
z = apply_gufunc (foo , "(i)->(i)" , a , output_dtypes = int )
69
69
assert z .chunks == ((3 ,),)
70
- assert_equal (z , np .array ([2 , 4 , 6 ]))
70
+ assert_array_equal (z , np .array ([2 , 4 , 6 ]))
71
71
72
72
73
73
def test_gufunc_two_inputs (spec ):
@@ -77,7 +77,7 @@ def foo(x, y):
77
77
a = xp .ones ((2 , 3 ), chunks = 100 , dtype = int , spec = spec )
78
78
b = xp .ones ((3 , 4 ), chunks = 100 , dtype = int , spec = spec )
79
79
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 ))
81
81
82
82
83
83
def test_apply_gufunc_axes_two_kept_coredims (spec ):
@@ -101,7 +101,7 @@ def foo(x):
101
101
a = cubed .from_array (np .array ([1 , 2 , 3 , 4 , 5 ], dtype = int ), spec = spec )
102
102
x = apply_gufunc (foo , "()->(i_0)" , a , output_dtypes = int , output_sizes = {"i_0" : 3 })
103
103
assert x .chunks == ((5 ,), (3 ,))
104
- assert_equal (
104
+ assert_array_equal (
105
105
x ,
106
106
np .array (
107
107
[
0 commit comments