Skip to content

Commit 6523dfd

Browse files
committed
adds test_leaf_array_type_broadcasting
1 parent a83a075 commit 6523dfd

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/test_arraycontext.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,32 @@ def test_norm_ord_none(actx_factory, ndim):
765765
np.testing.assert_allclose(actx.to_numpy(norm_a), norm_a_ref)
766766

767767

768+
@with_container_arithmetic(
769+
bcast_obj_array=True,
770+
bcast_numpy_array=True,
771+
rel_comparison=True,
772+
_cls_has_array_context_attr=True)
773+
@dataclass_array_container
774+
@dataclass(frozen=True)
775+
class Foo:
776+
u: DOFArray
777+
778+
@property
779+
def array_context(self):
780+
return self.u.array_context
781+
782+
783+
def test_leaf_array_type_broadcasting(actx_factory):
784+
actx = actx_factory()
785+
786+
foo = Foo(DOFArray(actx, (actx.zeros(3, dtype=np.float64) + 41, )))
787+
bar = foo + 4
788+
baz = foo + actx.from_numpy(4*np.ones((3, )))
789+
790+
np.testing.assert_allclose(bar.u[0].get(),
791+
baz.u[0].get())
792+
793+
768794
if __name__ == "__main__":
769795
import sys
770796
if len(sys.argv) > 1:

0 commit comments

Comments
 (0)