SciML / SciML/ComponentArrays.jl
Make `map` output consistent with the rest of broadcasting
Open
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 375
- Forks
- 42
- Avg merge
- 7h 25m
- Merged PRs (30d)
- 17
Description
From https://github.com/avik-pal/Lux.jl/pull/109#issuecomment-1198724214
julia> ca = ComponentArray(a=1, b=2)
julia> map((x,y) -> x+y, ca, 1:2) # returns a Vector
2-element Vector{Int64}:
2
4
julia> ca .+ (1:2) # returns a ComponentVector
ComponentVector{Int64}(a = 2, b = 4)
This can probably be fixed with an overload of Base.promote_shape for CombinedAxis.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the Julia examples comparing map((x,y) -> x+y, ca, 1:2) with ca .+ (1:2). Start by inspecting CombinedAxis and Base.promote_shape behavior, then verify that map preserves the ComponentVector structure like broadcasting does. Done means the map call returns a ComponentVector with the expected values and existing behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100