Skip to content

Unify broadcasting behavior of materialize!!#35

Merged
MasonProtter merged 1 commit intoJuliaFolds2:masterfrom
sfalmo:dot-update
Oct 16, 2025
Merged

Unify broadcasting behavior of materialize!!#35
MasonProtter merged 1 commit intoJuliaFolds2:masterfrom
sfalmo:dot-update

Conversation

@sfalmo
Copy link
Contributor

@sfalmo sfalmo commented Oct 15, 2025

Addresses #34

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.

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 whatever x was.
Now, materialize!!(::SVector{N,T}, ::T) is still a SVector{N,T} and materialize!!(::SVector, ::Vector) is a SizedVector, i.e. information about the type and size are retained.

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.
Copy link
Member

@MasonProtter MasonProtter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to me, thanks for finding this!

@MasonProtter MasonProtter merged commit f054f46 into JuliaFolds2:master Oct 16, 2025
13 checks passed
@sfalmo
Copy link
Contributor Author

sfalmo commented Oct 16, 2025

Thanks for merging!

@sfalmo sfalmo deleted the dot-update branch October 16, 2025 12:58
@MasonProtter
Copy link
Member

Registering a new version with your two PRs now

@sfalmo
Copy link
Contributor Author

sfalmo commented Oct 16, 2025

There is one last pending pull request I'm working on right now, which fixes a minor quirk with the @! macro. Maybe wait with the release until this one is finished, unless it's already too late.

@MasonProtter
Copy link
Member

Ah yeah, it's too late but no problem we can just make more releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants