Skip to content

Commit

Permalink
Use mergewith in additive_merge (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrhill authored May 3, 2024
1 parent 8bc5c4e commit 0b7fc7d
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions src/tracers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,7 @@ end

# Merge first- and second-order terms in an "additive" fashion
function additive_merge(a::HessianTracer, b::HessianTracer)
da = deepcopy(a.inputs)
db = b.inputs
for k in keys(db)
if haskey(da, k)
union!(da[k], db[k])
else
push!(da, k => db[k])
end
end
return HessianTracer(da)
return HessianTracer(mergewith(union, a.inputs, b.inputs))
end

# Merge first- and second-order terms in a "distributive" fashion
Expand Down

0 comments on commit 0b7fc7d

Please sign in to comment.