Skip to content

Commit 56b3e59

Browse files
authored
Fix 'rtol' and 'atol' for numeric extension types (#44488)
1 parent 00f4417 commit 56b3e59

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

pandas/_testing/asserters.py

+2
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

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import pytest
22

3+
from pandas.core.dtypes.common import is_extension_array_dtype
4+
35
import pandas as pd
46
from pandas import (
57
Categorical,
@@ -105,7 +107,7 @@ def test_series_not_equal_metadata_mismatch(kwargs):
105107

106108

107109
@pytest.mark.parametrize("data1,data2", [(0.12345, 0.12346), (0.1235, 0.1236)])
108-
@pytest.mark.parametrize("dtype", ["float32", "float64"])
110+
@pytest.mark.parametrize("dtype", ["float32", "float64", "Float32"])
109111
@pytest.mark.parametrize("decimals", [0, 1, 2, 3, 5, 10])
110112
def test_less_precise(data1, data2, dtype, decimals):
111113
rtol = 10 ** -decimals
@@ -115,7 +117,10 @@ def test_less_precise(data1, data2, dtype, decimals):
115117
if (decimals == 5 or decimals == 10) or (
116118
decimals >= 3 and abs(data1 - data2) >= 0.0005
117119
):
118-
msg = "Series values are different"
120+
if is_extension_array_dtype(dtype):
121+
msg = "ExtensionArray are different"
122+
else:
123+
msg = "Series values are different"
119124
with pytest.raises(AssertionError, match=msg):
120125
tm.assert_series_equal(s1, s2, rtol=rtol)
121126
else:

0 commit comments

Comments
 (0)