Skip to content

Commit 47f384b

Browse files
Fixed a blunder in test_usm_ndarray_operations
This prevented it from exercising methods of the namespace
1 parent 7e1bf48 commit 47f384b

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

dpctl/tests/test_usm_ndarray_operators.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,25 @@
2222

2323
class Dummy:
2424
@staticmethod
25-
def __abs__(a):
25+
def abs(a):
2626
return a
2727

2828
@staticmethod
29-
def __add__(a, b):
29+
def add(a, b):
3030
if isinstance(a, dpt.usm_ndarray):
3131
return a
3232
else:
3333
return b
3434

3535
@staticmethod
36-
def __sub__(a, b):
36+
def subtract(a, b):
3737
if isinstance(a, dpt.usm_ndarray):
3838
return a
3939
else:
4040
return b
4141

4242
@staticmethod
43-
def __mul__(a, b):
43+
def multiply(a, b):
4444
if isinstance(a, dpt.usm_ndarray):
4545
return a
4646
else:
@@ -51,6 +51,7 @@ def __mul__(a, b):
5151
def test_fp_ops(namespace):
5252
X = dpt.usm_ndarray(1, "d")
5353
X._set_namespace(namespace)
54+
assert X.__array_namespace__() is namespace
5455
X[0] = -2.5
5556
X.__abs__()
5657
X.__add__(1.0)
@@ -75,8 +76,10 @@ def test_fp_ops(namespace):
7576
X.__imul__(X)
7677
X.__itruediv__(1.0)
7778
X.__ifloordiv__(1.0)
79+
7880
X = dpt.usm_ndarray(1, "i4")
7981
X._set_namespace(namespace)
82+
assert X.__array_namespace__() is namespace
8083
X.__lshift__(2)
8184
X.__rshift__(2)
8285
X.__rlshift__(2)
@@ -99,8 +102,10 @@ def test_fp_ops(namespace):
99102
X.__pow__(2)
100103
X.__rpow__(2)
101104
X.__ipow__(2)
105+
102106
M = dpt.from_numpy(np.eye(3, 3, dtype="d"))
103107
X._set_namespace(namespace)
108+
assert X.__array_namespace__() is namespace
104109
M.__matmul__(M)
105110
M.__imatmul__(M)
106111
M.__rmatmul__(M)

0 commit comments

Comments
 (0)