You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As discussed from CS meeting earlier, I am getting a DeprecationWarning when dividing a DOFArray by an arraycontext scalar:
/Users/nnytko2/Git/ceesd-nonlinear-solve/code/actx_issue.py:17: DeprecationWarning: Broadcasting <class 'meshmode.dof_array.DOFArray'> over array context array type <class 'arraycontext.impl.pyopencl.taggable_cl_array.TaggableCLArray'> is deprecated and will no longer work in 2025. There is no replacement as of right now. See the discussion in https://github.com/inducer/arraycontext/pull/190.
y = x / flat_norm(x) # Warning occurs here
Thanks for writing this up! This is an informative corner case. We started issuing a warning for this type of code because finding the array types associated with an array context (to allow broadcasting specifically for them) has a number of problems:
it's sometimes contradictory, in that numpy arrays can be array context arrays, and they have their own broadcasting behavior.
it requires us to find the array context first. This is a slow and failure-prone operation, and I would prefer to continue to avoid it.
At the same time, broadcasting device scalars is (IMO) eminently reasonable, and I feel that the above code should probably be allowed.
So this comes down to the question of whether we should create a loophole for "scalars". A dumb-and-perhaps-not-too-expensive way to detect them would be getattr(ary, "shape", None) == (). But this feels loosey-goosey in a not-so-healthy way. I'd be grateful for alternate proposals/ideas.
I don't really have any new useful ideas :( At least at the time this warning was introduced, what I mostly had in mind was written here: #190 (comment).
In general, it seems like the hard part is ContainerTypeA + ContainerTypeB, where we don't know who's supposed to broadcast into who. Making ContainerTypeA + ArrayOrScalar work should be doable with some hackery (like you mentioned)..
As discussed from CS meeting earlier, I am getting a
DeprecationWarning
when dividing a DOFArray by an arraycontext scalar:And minimal reproducing example:
The text was updated successfully, but these errors were encountered: