Skip to content

Commit 9683970

Browse files
Backport PR #45565: REGR: check_flags not respected in assert_frame_equal (#45671)
Co-authored-by: Patrick Hoefler <[email protected]>
1 parent 1d017f2 commit 9683970

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

doc/source/whatsnew/v1.4.1.rst

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ including other versions of pandas.
1515
Fixed regressions
1616
~~~~~~~~~~~~~~~~~
1717
- Regression in :meth:`Series.mask` with ``inplace=True`` and ``PeriodDtype`` and an incompatible ``other`` coercing to a common dtype instead of raising (:issue:`45546`)
18+
- Regression in :func:`.assert_frame_equal` not respecting ``check_flags=False`` (:issue:`45554`)
1819
- Regression in :meth:`Series.fillna` with ``downcast=False`` incorrectly downcasting ``object`` dtype (:issue:`45603`)
1920
- Regression in :meth:`DataFrame.loc.__setitem__` losing :class:`Index` name if :class:`DataFrame` was empty before (:issue:`45621`)
2021
-

pandas/_testing/asserters.py

+1
Original file line numberDiff line numberDiff line change
@@ -1344,6 +1344,7 @@ def assert_frame_equal(
13441344
rtol=rtol,
13451345
atol=atol,
13461346
check_index=False,
1347+
check_flags=False,
13471348
)
13481349

13491350

pandas/tests/util/test_assert_frame_equal.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,22 @@ def test_frame_equal_mixed_dtypes(frame_or_series, any_numeric_ea_dtype, indexer
323323
tm.assert_equal(obj1, obj2, check_exact=True, check_dtype=False)
324324

325325

326-
def test_assert_series_equal_check_like_different_indexes():
326+
def test_assert_frame_equal_check_like_different_indexes():
327327
# GH#39739
328328
df1 = DataFrame(index=pd.Index([], dtype="object"))
329329
df2 = DataFrame(index=pd.RangeIndex(start=0, stop=0, step=1))
330330
with pytest.raises(AssertionError, match="DataFrame.index are different"):
331331
tm.assert_frame_equal(df1, df2, check_like=True)
332+
333+
334+
def test_assert_frame_equal_checking_allow_dups_flag():
335+
# GH#45554
336+
left = DataFrame([[1, 2], [3, 4]])
337+
left.flags.allows_duplicate_labels = False
338+
339+
right = DataFrame([[1, 2], [3, 4]])
340+
right.flags.allows_duplicate_labels = True
341+
tm.assert_frame_equal(left, right, check_flags=False)
342+
343+
with pytest.raises(AssertionError, match="allows_duplicate_labels"):
344+
tm.assert_frame_equal(left, right, check_flags=True)

0 commit comments

Comments
 (0)