Skip to content
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

Fix isapprox for dictionaries in testing (and highlight existing errors) #12

Merged
merged 1 commit into from
Aug 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ function Base.isapprox(seq1::AbstractDict, seq2::AbstractDict)
for (k1,v1) in seq1
k1 ∈ keys(seq2) || (println("key $k1 missing from seq2"); return false)
if v1 isa AbstractDict
return isapprox(v1, seq2[k1])
Copy link
Member

@jameskermode jameskermode Aug 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with this change we no longer recursively check sub-dictionaries. Isn't that a problem for arrays and info too? It should probably be something like isapprox(v1, seq2[k1]) || return false

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think and isapprox are equivalent, so the new line is still recursively calling this function. I just changed the syntax to be more consistent with the rest of the function.

elseif v1 isa Array{AbstractFloat} || v1 isa AbstractFloat
v1 ≈ seq2[k1] || (println("key $k1: $v1 !≈ $(seq2[k1])"); return false)
elseif v1 isa Array{<:AbstractFloat} || v1 isa AbstractFloat
v1 ≈ seq2[k1] || (println("key $k1: $v1 !≈ $(seq2[k1])"); return false)
else
v1 == seq2[k1] || (println("key $k1: $v1 != $(seq2[k1])"); return false)
Expand Down