Unify broadcasting behavior of materialize!!#35
Merged
MasonProtter merged 1 commit intoJuliaFolds2:masterfrom Oct 16, 2025
Merged
Unify broadcasting behavior of materialize!!#35MasonProtter merged 1 commit intoJuliaFolds2:masterfrom
materialize!!#35MasonProtter merged 1 commit intoJuliaFolds2:masterfrom
Conversation
The broadcasting behavior of `materialize!!(dest, x)` is made consistent for mutable and immutable destinations `dest`. Previously, the shape and type of immutable `dest` was not considered. This commit changes NoBang.materialize to also let the `dest` participate in the broadcast, thereby propagating information about its shape and type.
MasonProtter
approved these changes
Oct 16, 2025
Member
MasonProtter
left a comment
There was a problem hiding this comment.
This makes sense to me, thanks for finding this!
Contributor
Author
|
Thanks for merging! |
Member
|
Registering a new version with your two PRs now |
Contributor
Author
|
There is one last pending pull request I'm working on right now, which fixes a minor quirk with the |
Member
|
Ah yeah, it's too late but no problem we can just make more releases. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses #34
The broadcasting behavior of
materialize!!(dest, x)is made consistent for mutable and immutable destinationsdest. Previously, the shape and type of immutabledestwas not considered. This commit changes NoBang.materialize to also let thedestparticipate in the broadcast, thereby propagating information about its shape and type.Not sure if
broadcasted(first ∘ tuple, x, dest))is the most idiomatic way to do this, but it seems to work.Note that this also narrows down the type of the result:
Previously,
materialize!!(::SVector, x)would yield whateverxwas.Now,
materialize!!(::SVector{N,T}, ::T)is still aSVector{N,T}andmaterialize!!(::SVector, ::Vector)is aSizedVector, i.e. information about the type and size are retained.