From 17c4cdbcdec0b9835616858a9f5ab5a7ef8f0c92 Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Mon, 5 Aug 2024 19:31:02 -0500
Subject: [PATCH] Switch to __array_ufunc__ in tests as a way to avoid numpy
 broadcasting

---
 test/test_arraycontext.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/test/test_arraycontext.py b/test/test_arraycontext.py
index 868790f..ae65a3d 100644
--- a/test/test_arraycontext.py
+++ b/test/test_arraycontext.py
@@ -133,7 +133,8 @@ class DOFArray:
         self.array_context = actx
         self.data = data
 
-    __array_priority__ = 10
+    # prevent numpy broadcasting
+    __array_ufunc__ = None
 
     def __bool__(self):
         if len(self) == 1 and self.data[0].size == 1:
@@ -219,6 +220,8 @@ class MyContainer:
     momentum: np.ndarray
     enthalpy: Union[DOFArray, np.ndarray]
 
+    __array_ufunc__ = None
+
     @property
     def array_context(self):
         if isinstance(self.mass, np.ndarray):
@@ -1364,7 +1367,8 @@ def test_container_equality(actx_factory):
 class Foo:
     u: DOFArray
 
-    __array_priority__ = 1  # disallow numpy arithmetic to take precedence
+    # prevent numpy arithmetic from taking precedence
+    __array_ufunc__ = None
 
     @property
     def array_context(self):
-- 
GitLab