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

Problem with comparing lists, with an boolean as element #166

Closed
fi-do opened this issue Jan 8, 2020 · 3 comments
Closed

Problem with comparing lists, with an boolean as element #166

fi-do opened this issue Jan 8, 2020 · 3 comments
Assignees
Labels

Comments

@fi-do
Copy link

fi-do commented Jan 8, 2020

Hey guys,

thanks for this usefull library.
I got some problems when I compare two list. Each of them has one boolean as element. Using DeepDiff with ignore_order=False works like a charm. But forced with ignore_order=True doesn't work anymore.

Code to reproduce:

from deepdiff import DeepDiff

a = [True]
b = [False]

print(DeepDiff(a, b, ignore_order=True))

Expected results:

{'values_changed': {'root[0]': {'new_value': False, 'old_value': True}}}

Real results:

Can not produce a hash for root.Not counting this object.
 'True is not one of the hashed items.'
Can not produce a hash for root.Not counting this object.
 'False is not one of the hashed items.'
{}

I need the ignore_order to be true, for other objects.
deepdiff 4.0.7, Python 3.6.9, Ubuntu 18.04

@fi-do
Copy link
Author

fi-do commented Jan 13, 2020

 item_hash = hashes_all[item]
except Exception as e:  # pragma: no cover
  logger.error("Can not produce a hash for %s."
                       "Not counting this object.\n %s" %
                      (level.path(), e))

After some little trial and error, I got some findings in context with the problem. Interesting part is in file diff.py, line 479. The value of "item" is an element(type bool) of the list. But the dictionary hashes_all contains "only" an object of type "BoolObj".
With a different kind of types(e.g strings), these two objetcs "matches". It looks like the object needs to be converted from the "BoolObj" type back to the "bool" type.
I'm still relatively new to programming. But I try to stay tuned to the understanding of the program.

@seperman
Copy link
Owner

Hi @fi-do
Thanks for reporting this bug. I'm working on a patch.

@seperman seperman self-assigned this Jan 17, 2020
@seperman seperman added the bug label Jan 17, 2020
@seperman
Copy link
Owner

This issue is addressed in #173
DeepDiff 4.2.0

@seperman seperman mentioned this issue Jan 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants