Skip to content

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

Closed
@SimonRubenDrauz

Description

@SimonRubenDrauz

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions