Skip to content

Commit 7621398

Browse files
committed
Fix pandas-dev#25068 using the same constant as in numpy for decimal_almost_equal
1 parent f75a220 commit 7621398

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pandas/_libs/testing.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ cdef bint decimal_almost_equal(double desired, double actual, int decimal):
4343
# Code from
4444
# http://docs.scipy.org/doc/numpy/reference/generated
4545
# /numpy.testing.assert_almost_equal.html
46-
return abs(desired - actual) < (0.5 * 10.0 ** -decimal)
46+
return abs(desired - actual) < (1.5 * 10.0 ** -decimal)
4747

4848

4949
cpdef assert_dict_equal(a, b, bint compare_keys=True):

pandas/tests/util/test_assert_frame_equal.py

+8
Original file line numberDiff line numberDiff line change
@@ -207,3 +207,11 @@ def test_frame_equal_unicode(df1, df2, msg, by_blocks):
207207
# when comparing DataFrames containing differing unicode objects.
208208
with pytest.raises(AssertionError, match=msg):
209209
assert_frame_equal(df1, df2, by_blocks=by_blocks)
210+
211+
212+
def test_frame_equal_precision():
213+
# see gh-25068
214+
df1 = DataFrame([0.00016, -0.154526, -0.20580199999999998])
215+
df2 = DataFrame(
216+
[0.00015981824253685772, -0.15452557802200317, -0.20580188930034637])
217+
_assert_frame_equal_both(df1, df2, check_exact=False, check_less_precise=3)

0 commit comments

Comments
 (0)