Skip to content

Commit

Permalink
fix mergewith workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
pablosanjose committed Jan 22, 2024
1 parent f188165 commit 65921a1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/slices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,12 @@ combine(d) = d

# TODO: when/if https://github.com/andyferris/Dictionaries.jl/pull/130 is merged
# this should become simply mergewith(combine_subcells, d1, d2, ds...)
combine(d1::D, d2::D, ds::D...) where {D<:CellIndicesDict} =
foldl(mergewith!(combine_subcells), (d2, ds...), init = copy(d1))
function combine(d1::D, d2::D, ds::D...) where {D<:CellIndicesDict}
# mergewith(combine_subcells, d1, d2, ds...)
out = similar(copy(keys(d1), keytype(D)), valtype(D))
copyto!(out, d1)
return foldl(mergewith!(combine_subcells), (d2, ds...), init = out)
end

combine_subcells(c::C, cs::C...) where {C<:CellSites} =
CellSites(cell(c), union(siteindices(c), siteindices.(cs)...))
Expand Down

0 comments on commit 65921a1

Please sign in to comment.