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

Error passing significant digits and two numpy array containing strings #345

Closed
SimonRubenDrauz opened this issue Aug 31, 2022 · 1 comment

Comments

@SimonRubenDrauz
Copy link

Describe the bug
I have two objects I want to compare with each other. In order to do so I use your package deepdiff. So imagine you have object A and object B. In order to check, if both objects are equal, I did the following:

DeepDiff(self._dict_, other._dict_, ignore_nan_inequality=True, significant_digits=6, math_epsilon=1e-6,
ignore_private_variables=False).

Doing this in case of a list of strings in _dict_, I get the following error:

File "C:...\lib\site-packages\numpy\testing_private\utils.py", line 1039, in compare z = abs(x - y)
TypeError: unsupported operand type(s) for -: 'str' and 'str'.

A quickfix that worked for me in self._diff_numy_array:
grafik
If you agree on that quickfix, I can do a PR, if you want to.

To Reproduce

a = np.array(['a', 'b'], dtype=object)
b = np.array(['a', 'b'], dtype=object)
DeepDiff(a, b, significant_digits=6)

Expected behavior
I would expect that passing a dictionary where significant_digits apply to only few entries, in case of the other entries it is just skipped.

OS, DeepDiff version and Python version (please complete the following information):

  • OS: Windows
  • Version: 10 Enterprise
  • Python Version: 3.8.5
  • DeepDiff Version: 6.1.0

Additional context
The numpy version I use is 1.22.4

@seperman
Copy link
Owner

Hi @SimonRubenDrauz
Thank you for reporting this issue and providing the solution too. Sorry it took more than a year to take a look at this ticket.
I copy pasted your solution and pushed it to the dev branch. I will keep you posted once it is released.

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

No branches or pull requests

2 participants