Skip to content

Commit faf3fdd

Browse files
committed
Fix 'rtol' and 'atol' for numeric extension types
1 parent 700be61 commit faf3fdd

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

pandas/_testing/asserters.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,8 @@ def assert_series_equal(
10681068
assert_extension_array_equal(
10691069
left._values,
10701070
right._values,
1071+
rtol=rtol,
1072+
atol=atol,
10711073
check_dtype=check_dtype,
10721074
index_values=np.asarray(left.index),
10731075
)

pandas/tests/util/test_assert_series_equal.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
DataFrame,
77
Series,
88
)
9+
from pandas.core.dtypes.common import is_extension_array_dtype
910
import pandas._testing as tm
1011

1112

@@ -105,7 +106,7 @@ def test_series_not_equal_metadata_mismatch(kwargs):
105106

106107

107108
@pytest.mark.parametrize("data1,data2", [(0.12345, 0.12346), (0.1235, 0.1236)])
108-
@pytest.mark.parametrize("dtype", ["float32", "float64"])
109+
@pytest.mark.parametrize("dtype", ["float32", "float64", "Float32"])
109110
@pytest.mark.parametrize("decimals", [0, 1, 2, 3, 5, 10])
110111
def test_less_precise(data1, data2, dtype, decimals):
111112
rtol = 10 ** -decimals
@@ -115,7 +116,10 @@ def test_less_precise(data1, data2, dtype, decimals):
115116
if (decimals == 5 or decimals == 10) or (
116117
decimals >= 3 and abs(data1 - data2) >= 0.0005
117118
):
118-
msg = "Series values are different"
119+
if is_extension_array_dtype(dtype):
120+
msg = "ExtensionArray are different"
121+
else:
122+
msg = "Series values are different"
119123
with pytest.raises(AssertionError, match=msg):
120124
tm.assert_series_equal(s1, s2, rtol=rtol)
121125
else:

0 commit comments

Comments
 (0)