Pandas version checks
Reproducible Example
import pandas as pd
left = pd.Series([2**60 + 1], dtype="int64")
right = pd.Series([float(2**60)], dtype="float64") # exactly 2**60, so the two values are 1 apart
pd.testing.assert_series_equal(
left, right, check_dtype=False, check_exact=False, rtol=0, atol=0.5
)
# no AssertionError, even though the values are 1 apart and atol is 0.5
Issue Description
With check_dtype=False and check_exact=False, comparing an integer Series against a float Series ignores atol and rtol completely.
assert_almost_equal short-circuits on array_equivalent before any tolerance logic runs. array_equivalent casts the two arrays to a common dtype, so 2**60 + 1 becomes float(2**60), the arrays compare equal, and the elementwise comparison that would apply rtol/atol is never reached.
The same thing happens with the nullable dtypes (Int64 vs Float64), and through assert_frame_equal and assert_index_equal.
This is the same symptom as #66400 but a different code path. #66400 was the double cast inside assert_almost_equal itself, which is fixed in #66696; this one happens earlier, before that code is reached, so it is not covered by that PR.
Worth noting that array_equivalent also backs Index.equals and DataFrame.equals, where casting to a common dtype is reasonable, so a fix likely needs to be scoped to the testing path rather than changing array_equivalent itself.
Expected Behavior
atol=0.5 should not accept two values that are 1 apart. The tolerance should be applied to the actual values.
Installed Versions
Details
Reproduced on main at commit 44ae066.
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
With
check_dtype=Falseandcheck_exact=False, comparing an integer Series against a float Series ignoresatolandrtolcompletely.assert_almost_equalshort-circuits onarray_equivalentbefore any tolerance logic runs.array_equivalentcasts the two arrays to a common dtype, so2**60 + 1becomesfloat(2**60), the arrays compare equal, and the elementwise comparison that would applyrtol/atolis never reached.The same thing happens with the nullable dtypes (
Int64vsFloat64), and throughassert_frame_equalandassert_index_equal.This is the same symptom as #66400 but a different code path. #66400 was the
doublecast insideassert_almost_equalitself, which is fixed in #66696; this one happens earlier, before that code is reached, so it is not covered by that PR.Worth noting that
array_equivalentalso backsIndex.equalsandDataFrame.equals, where casting to a common dtype is reasonable, so a fix likely needs to be scoped to the testing path rather than changingarray_equivalentitself.Expected Behavior
atol=0.5should not accept two values that are 1 apart. The tolerance should be applied to the actual values.Installed Versions
Details
Reproduced on main at commit 44ae066.