Fixes issue where the key deep_distance is not returned when both compared items are equal#510
Merged
seperman merged 1 commit intoseperman:devfrom Dec 14, 2024
Merged
Conversation
Owner
|
Hi @sherjeelshabih |
Merged
Owner
|
Hi @sherjeelshabih |
Contributor
Author
Hi, @seperman. I do not have a public example yet. We use deepdiff in our code to have a rough estimate whenever we don't have to compare something specific. It works really well for us. Thank you for such a nice project! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi, Sep. I use your library for some evals code and I realized DeepDiff doesn't send back the key "deep_distance" when comparing exact matches. I read the docs and there is no explicit mention that it shouldn't. I expect a deep_distance=0 returned at least when I ask for it using get_deep_distance=True.
I had some checks in my code on top of this. But then I wanted to make sure and when down debugging your code.
I found two issues.
One is if deep_distance is 0, remove_empty_keys treats it as empty. I added a very simple check. If the item is an instance of int, then it should have some value. Thus it's not empty.
Second, the
__len__function only expects to deal with SetOrdered instances so I just added an int there.I hope this fits with your design goals. Let me know if I misunderstood the docs. Otherwise, feel free to make edits as you please before merging.