-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In-place broadcasting into non-broadcastable things #36105
Comments
Both packages snagged by this agreed they had an incomplete specification and have already fixed it themselves. I think the gain in functionality is worth this very minor change, and I would advocate for no additional changes here. |
I suppose 1.4-like behavior is still possible by overloading (Of course, opening up |
Yes, that would work, but the better way (and the way both those packages pursued) is simply to "finish" implementing the broadcastable interface or avoid this idiom entirely. |
Yeah, I agree that's the right move, e.g., for the packages you listed in the OP. I was thinking about extending the semantics of broadcasting where |
I agree that the awkward-array style operations are good target. For nested things @tkf I wonder if we could using nested dot-getindices operations to detangle it on the LHS, as it seems (to me) you might need to do anyway on the RHS? A.[2:4].[end] .= B.[1:3].[begin] (I'm not sure if that particular example makes sense, but something like that) |
(Just a quick response, but maybe #30845 is the best place to continue the discussion?) |
Yes, and I think this issue can be closed. |
So we have the syntax
A .= x
, broadcastingx
intoA
's shape and mutatingA
to those new values. I've always thought of this syntax only supporting broadcastable LHSes, but prior to #35620 this wasn't actually necessary... the default broadcast machinery seamlessly transformed this into a call tocopyto!(A, x)
without requiring much ofA
at all.Version 1.4
Version 1.5-beta.1
This snagged several packages:
WeightedNorm
that wraps a vector but isn't itself a vector or even iterable. It does, however, supportcopyto!
andsize
, and its tests use.=
to simply change the wrapped vector. It is currently not possible to use a WeightedNorm in any other broadcast expression.So the question is: are we ok with this change? I'm inclined to say that the existing usages are incomplete specifications.
The text was updated successfully, but these errors were encountered: