Consider this script:
actx=_acf()
@with_container_arithmetic(bcast_obj_array=True,bcast_numpy_array=True,rel_comparison=True,_cls_has_array_context_attr=True)@dataclass_array_container@dataclass(frozen=True)classFoo:
u: DOFArrayfoo=Foo(DOFArray(actx, (actx.zeros(3, dtype=np.float64) +41, )))
print(foo) # prints: Foo(u=DOFArray((cl.Array([41., 41., 41.]),)))print(foo+1) # prints: Foo(u=DOFArray((cl.Array([42., 42., 42.]),)))print(foo+actx.from_numpy(np.ones(()))) # ERROR! 😲
I don't see a good reason why we don't support this.
I think we should also go a step ahead and make sure that we broadcast every cl.Array to be added (if legal) with all the leaf arrays of the array container. One way I could see this working is if every ArrayContext comes with a ARRAY_TYPE static, frozen attribute which gives us a hint to broadcast to all successive arrays.
Consider this script:
I don't see a good reason why we don't support this.
I think we should also go a step ahead and make sure that we broadcast every cl.Array to be added (if legal) with all the leaf arrays of the array container. One way I could see this working is if every
ArrayContextcomes with aARRAY_TYPEstatic, frozen attribute which gives us a hint to broadcast to all successive arrays.