Skip to content

Commit

Permalink
merge_strict revert
Browse files Browse the repository at this point in the history
  • Loading branch information
ivborissov committed Jul 11, 2023
1 parent 4ec17e4 commit be7da1c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
# check keys in y before merge
function merge_strict(x::NamedTuple, y::NamedTuple)
#=
kx = keys(x)
ky = keys(y)
for k in ky
@assert k in kx "Can't merge elements in strict mode. Key $k not found in $kx."
end
=#
y_indexes = indexin([keys(y)...], [keys(x)...])
y_lost = isnothing.(y_indexes)
@assert !any(y_lost) "Cannot merge elements with keys $(keys(y)[y_lost]) in strict mode."

merge(x, y)
end

Expand Down

0 comments on commit be7da1c

Please sign in to comment.