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

Fixes issue where the key deep_distance is not returned when both compared items are equal #510

Merged
merged 1 commit into from
Dec 14, 2024

Conversation

sherjeelshabih
Copy link
Contributor

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.

@seperman
Copy link
Owner

Hi @sherjeelshabih
Thanks for making the PR. Interesting, what is an example of how you use DeepDiff for evals code?

@seperman seperman merged commit 743c901 into seperman:dev Dec 14, 2024
@seperman seperman mentioned this pull request Dec 14, 2024
@seperman
Copy link
Owner

Hi @sherjeelshabih
Thanks for contributing to DeepDiff. DeepDiff 8.1.0 is released and includes your code!

@sherjeelshabih
Copy link
Contributor Author

Hi @sherjeelshabih Thanks for making the PR. Interesting, what is an example of how you use DeepDiff for evals code?

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants