Skip to content

Commit

Permalink
fix setindex! for DimStack with integer index (#869)
Browse files Browse the repository at this point in the history
* add missing `kw...`

* add a test
  • Loading branch information
tiemvanderdeure authored Nov 28, 2024
1 parent 51e94b1 commit 3b3c817
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/stack/indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ end
map((A, x) -> setindex!(A, x, I...; kw...), layers(s), xs)
end

_map_setindex!(s, xs, i) = map((A, x) -> setindex!(A, x, i...; kw...), layers(s), xs)
_map_setindex!(s, xs, i; kw...) = map((A, x) -> setindex!(A, x, i...; kw...), layers(s), xs)

_setindex_mixed!(s::AbstractDimStack, x, i::AbstractArray) =
map(A -> setindex!(A, x, DimIndices(dims(s))[i]), layers(s))
Expand Down
2 changes: 2 additions & 0 deletions test/indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,8 @@ end

@testset "setindex!" begin
s_set = deepcopy(s)
s_set[1] = (one=4, two=5, three=6)
@test s_set[1, 1] === (one=4.0, two=5.0f0, three=6)
s_set[1, 1] = (one=9, two=10, three=11)
@test s_set[1, 1] === (one=9.0, two=10.0f0, three=11)
s_set[X=At(:b), Y=At(10.0)] = (one=7, two=11, three=13)
Expand Down

0 comments on commit 3b3c817

Please sign in to comment.