Open hexaeder opened 5 months ago
I think this could be solved by replacing map
with broadcast
here:
Underlying issue being that mapping over multiple collections only loops through the shortest list. I think broadcast behaviour is what you'd expect here
julia> map((a,b)->a*repr(b), ["foo", "bar"], 1)
1-element Vector{String}:
"foo1"
julia> map((a,b)->a*repr(b), ["foo", "bar"], [1,2])
2-element Vector{String}:
"foo1"
"bar2"
julia> map((a,b)->a*repr(b), ["foo", "bar"], [1,2,3])
2-element Vector{String}:
"foo1"
"bar2"
julia> broadcast((a,b)->a*repr(b), ["foo", "bar"], 1)
2-element Vector{String}:
"foo1"
"bar1"
julia> broadcast((a,b)->a*repr(b), ["foo", "bar"], [1,2])
2-element Vector{String}:
"foo1"
"bar2"
julia> broadcast((a,b)->a*repr(b), ["foo", "bar"], [1,2,3])
ERROR: DimensionMismatch: arrays could not be broadcast to a common size: a has axes Base.OneTo(2) and b has axes
Describe the bug 🐞
setu
does not perform sizecheck between the new values and the number of indexed elements.Expected behavior
I would expect it to either error or implicitly broadcast, but it only overwrites a single value. The expectation comes especially when using the
setindex!
interface, because then it feels like array indexingMinimal Reproducible Example 👇