Skip to content

Commit 17001c1

Browse files
committed
significant digits and two numpy array containing strings - fixes #345
1 parent 58e6ac9 commit 17001c1

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

deepdiff/diff.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1410,9 +1410,12 @@ def _diff_numpy_array(self, level, parents_ids=frozenset(), local_tree=None):
14101410
else:
14111411
try:
14121412
np.testing.assert_almost_equal(level.t1, level.t2, decimal=self.significant_digits)
1413-
return # all good
1413+
except TypeError:
1414+
np.array_equal(level.t1, level.t2, equal_nan=self.ignore_nan_inequality)
14141415
except AssertionError:
14151416
pass # do detailed checking below
1417+
else:
1418+
return # all good
14161419

14171420
# compare array meta-data
14181421
_original_type = level.t1.dtype

tests/test_diff_numpy.py

+6
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@
119119
'deepdiff_kwargs': {'significant_digits': 3},
120120
'expected_result': {},
121121
},
122+
'numpy_almost_equal2': {
123+
't1': np.array(['a', 'b'], dtype=object),
124+
't2': np.array(['a', 'b'], dtype=object),
125+
'deepdiff_kwargs': {'significant_digits': 6},
126+
'expected_result': {},
127+
},
122128
'numpy_different_shape': {
123129
't1': np.array([[1, 1], [2, 3]]),
124130
't2': np.array([1]),

0 commit comments

Comments
 (0)