Skip to content

Commit

Permalink
Backport PR pandas-dev#57341: REGR: assert_series_equal defaulting to…
Browse files Browse the repository at this point in the history
… check_exact=True for Index
  • Loading branch information
phofl authored and meeseeksmachine committed Feb 12, 2024
1 parent 947f5ae commit 2fcbcb7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v2.2.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Fixed regressions
- Fixed performance regression in :meth:`Series.combine_first` (:issue:`55845`)
- Fixed regression in :func:`concat` changing long-standing behavior that always sorted the non-concatenation axis when the axis was a :class:`DatetimeIndex` (:issue:`57006`)
- Fixed regression in :func:`merge_ordered` raising ``TypeError`` for ``fill_method="ffill"`` and ``how="left"`` (:issue:`57010`)
- Fixed regression in :func:`pandas.testing.assert_series_equal` defaulting to ``check_exact=True`` when checking the :class:`Index` (:issue:`57067`)
- Fixed regression in :func:`wide_to_long` raising an ``AttributeError`` for string columns (:issue:`57066`)
- Fixed regression in :meth:`.DataFrameGroupBy.idxmin`, :meth:`.DataFrameGroupBy.idxmax`, :meth:`.SeriesGroupBy.idxmin`, :meth:`.SeriesGroupBy.idxmax` ignoring the ``skipna`` argument (:issue:`57040`)
- Fixed regression in :meth:`.DataFrameGroupBy.idxmin`, :meth:`.DataFrameGroupBy.idxmax`, :meth:`.SeriesGroupBy.idxmin`, :meth:`.SeriesGroupBy.idxmax` where values containing the minimum or maximum value for the dtype could produce incorrect results (:issue:`57040`)
Expand Down
3 changes: 2 additions & 1 deletion pandas/_testing/asserters.py
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,7 @@ def assert_series_equal(
>>> tm.assert_series_equal(a, b)
"""
__tracebackhide__ = True
check_exact_index = False if check_exact is lib.no_default else check_exact
if (
check_exact is lib.no_default
and rtol is lib.no_default
Expand Down Expand Up @@ -944,7 +945,7 @@ def assert_series_equal(
right.index,
exact=check_index_type,
check_names=check_names,
check_exact=check_exact,
check_exact=check_exact_index,
check_categorical=check_categorical,
check_order=not check_like,
rtol=rtol,
Expand Down
8 changes: 8 additions & 0 deletions pandas/tests/util/test_assert_series_equal.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,3 +474,11 @@ def test_assert_series_equal_int_tol():
tm.assert_extension_array_equal(
left.astype("Int64").values, right.astype("Int64").values, rtol=1.5
)


def test_assert_series_equal_index_exact_default():
# GH#57067
ser1 = Series(np.zeros(6, dtype=int), [0, 0.2, 0.4, 0.6, 0.8, 1])
ser2 = Series(np.zeros(6, dtype=int), np.linspace(0, 1, 6))
tm.assert_series_equal(ser1, ser2)
tm.assert_frame_equal(ser1.to_frame(), ser2.to_frame())

0 comments on commit 2fcbcb7

Please sign in to comment.