Skip to content

Commit 2bcc921

Browse files
committed
Switch to __array_ufunc__ in tests as a way to avoid numpy broadcasting
1 parent 955820f commit 2bcc921

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

test/test_arraycontext.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ def __init__(self, actx, data):
133133
self.array_context = actx
134134
self.data = data
135135

136-
__array_priority__ = 10
136+
# prevent numpy broadcasting
137+
__array_ufunc__ = None
137138

138139
def __bool__(self):
139140
if len(self) == 1 and self.data[0].size == 1:
@@ -219,6 +220,8 @@ class MyContainer:
219220
momentum: np.ndarray
220221
enthalpy: Union[DOFArray, np.ndarray]
221222

223+
__array_ufunc__ = None
224+
222225
@property
223226
def array_context(self):
224227
if isinstance(self.mass, np.ndarray):
@@ -1364,7 +1367,8 @@ def test_container_equality(actx_factory):
13641367
class Foo:
13651368
u: DOFArray
13661369

1367-
__array_priority__ = 1 # disallow numpy arithmetic to take precedence
1370+
# prevent numpy arithmetic from taking precedence
1371+
__array_ufunc__ = None
13681372

13691373
@property
13701374
def array_context(self):

0 commit comments

Comments
 (0)