-
Notifications
You must be signed in to change notification settings - Fork 5
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
Use mergewith
for merging dicts of sets
#35
Comments
To keep everything in one place, the proposition in the comment is for a function julia> d1 = Dict(1 => Set([1, 2, 3]), 2 => Set([3, 4, 5]))
Dict{Symbol, Set{Int64}} with 2 entries:
1 => Set([2, 3, 1])
2 => Set([5, 4, 3])
julia> d2 = Dict(2 => Set([5, 6, 7]), 3 => Set([8, 9, 10]))
Dict{Symbol, Set{Int64}} with 2 entries:
2 => Set([5, 6, 7])
3 => Set([10, 9, 8])
julia> mergewith(union, d1, d2)
Dict{Symbol, Set{Int64}} with 3 entries:
1 => Set([2, 3, 1])
2 => Set([5, 4, 6, 7, 3])
3 => Set([10, 9, 8])
The proposed julia> d1 = Dict(UInt(1) => Set([1, 2, 3]), UInt(2) => Set([3, 4, 5]))
Dict{UInt64, Set{Int64}} with 2 entries:
0x0000000000000002 => Set([5, 4, 3])
0x0000000000000001 => Set([2, 3, 1])
julia> d2 = Dict(UInt(2) => Set([5, 6, 7]), UInt(3) => Set([8, 9, 10]))
Dict{UInt64, Set{Int64}} with 2 entries:
0x0000000000000002 => Set([5, 6, 7])
0x0000000000000003 => Set([10, 9, 8])
julia> SparseConnectivityTracer.additive_merge(HessianTracer(d1), HessianTracer(d2))
HessianTracer{Set{Int64}}(
2 => (5, 4, 6, 7, 3),
3 => (10, 9, 8),
1 => (2, 3, 1),
) |
Closing this for now, but PRs increasing the performance of The two functions are named after their analogous operations on polynomials. In the given example, The implementation of this is closely related to #34. |
I'm not proposing a new function, I'm pointing out it's part of help?> mergewith
search: mergewith mergewith!
mergewith(combine, d::AbstractDict, others::AbstractDict...)
mergewith(combine)
merge(combine, d::AbstractDict, others::AbstractDict...)
Construct a merged collection from the given collections. If necessary, the
types of the resulting collection will be promoted to accommodate the types
of the merged collections. Values with the same key will be combined using
the combiner function. The curried form mergewith(combine) returns the
function (args...) -> mergewith(combine, args...). |
TIL! Could this be used for |
idk |
Linking to #33 (comment) so that we may close the PR first and get rid of
union!
afterwardsThe text was updated successfully, but these errors were encountered: