Skip to content
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

Introduce mapped/Mapped #4

Merged
merged 3 commits into from
Dec 25, 2024
Merged

Introduce mapped/Mapped #4

merged 3 commits into from
Dec 25, 2024

Conversation

mtfishman
Copy link
Member

@mtfishman mtfishman commented Dec 25, 2024

Introduce mapped/Mapped, which are analogous to Base.Broadcast.broadcasted/Base.Broadcast.Broadcasted for representing lazy maps.

The new preferred API for the package for converting from a broadcast expression to a map expression is:

using Base.Broadcast: broadcasted
using BroadcastMapConversion: Mapped

bc = broadcasted(*, 2, randn(2, 2))
m = Mapped(bc)
# Evaluate the map expression in multiple ways:
map(m.f, m.args...) == copy(bc)
copy(mapped(m.f, m.args...)) == copy(bc)
copy(m) == copy(bc)

Mapped is meant to support that same functionality as Broadcasted. I plan to deprecate the previous interface map_function(bc::Broadcasted) and map_args(bc::Broadcasted) in favor of the API above.

We might consider changing the package name to something like MapExpressions.jl, since converting to and from broadcast expressions can now be seen more as just one feature of the package and not necessarily the primary purpose. Also note the similarity to MappedArrays.jl, which provides a similar lazy map object, but that object is an AbstractArray while this one is a Base.AbstractBroadcasted so it serves a slightly different purpose and has a different interface.

Copy link

codecov bot commented Dec 25, 2024

Codecov Report

Attention: Patch coverage is 76.47059% with 4 lines in your changes missing coverage. Please review.

Project coverage is 88.37%. Comparing base (33096dc) to head (33f0363).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/BroadcastMapConversion.jl 76.47% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            main       #4       +/-   ##
==========================================
+ Coverage   0.00%   88.37%   +88.37%     
==========================================
  Files          1        1               
  Lines         24       43       +19     
==========================================
+ Hits           0       38       +38     
+ Misses        24        5       -19     
Flag Coverage Δ
docs 88.37% <76.47%> (+88.37%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mtfishman mtfishman merged commit 3e63462 into main Dec 25, 2024
12 checks passed
@mtfishman mtfishman deleted the mapped branch December 25, 2024 16:38
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.

1 participant