Skip to content

Commit e268bf1

Browse files
committed
Switch to __array_ufunc__ in tests as a way to avoid numpy broadcasting
1 parent c724cb1 commit e268bf1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Diff for: test/test_arraycontext.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ def __init__(self, actx, data):
136136
self.array_context = actx
137137
self.data = data
138138

139-
__array_priority__ = 10
139+
# prevent numpy broadcasting
140+
__array_ufunc__ = None
140141

141142
def __bool__(self):
142143
if len(self) == 1 and self.data[0].size == 1:
@@ -222,6 +223,8 @@ class MyContainer:
222223
momentum: np.ndarray
223224
enthalpy: Union[DOFArray, np.ndarray]
224225

226+
__array_ufunc__ = None
227+
225228
@property
226229
def array_context(self):
227230
if isinstance(self.mass, np.ndarray):
@@ -1367,7 +1370,8 @@ def test_container_equality(actx_factory):
13671370
class Foo:
13681371
u: DOFArray
13691372

1370-
__array_priority__ = 1 # disallow numpy arithmetic to take precedence
1373+
# prevent numpy arithmetic from taking precedence
1374+
__array_ufunc__ = None
13711375

13721376
@property
13731377
def array_context(self):

0 commit comments

Comments
 (0)