Skip to content

REGR: check_flags not respected in assert_frame_equal #45565

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 28, 2022

Conversation

phofl
Copy link
Member

@phofl phofl commented Jan 23, 2022

@phofl phofl added Testing pandas testing functions or related to the test suite Regression Functionality that used to work in a prior pandas version labels Jan 23, 2022
@phofl phofl added this to the 1.4.1 milestone Jan 23, 2022
left.flags.allows_duplicate_labels = False

right = DataFrame([[1, 2], [3, 4]])
right.flags.allows_duplicate_labels = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we also need to test for DataFrames with the same flags with check_flags=True/False. I find it odd (without investigation) that the reported issue was not picked up before. The flag is on the DataFrame so why not check that instead of on the Series?

@@ -15,7 +15,7 @@ including other versions of pandas.
Fixed regressions
~~~~~~~~~~~~~~~~~
- Regression in :meth:`Series.mask` with ``inplace=True`` and ``PeriodDtype`` and an incompatible ``other`` coercing to a common dtype instead of raising (:issue:`45546`)
-
- Regression in :func:`.assert_frame_equal` not respecting ``check_flags=False``(:issue:`45554`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again. I don't understand fully since have not investigated but this issue is not actually a regression if the flag was not propagated before? As with check_flags=True I assume it did not raise if the flags were different.

@@ -1344,6 +1344,7 @@ def assert_frame_equal(
rtol=rtol,
atol=atol,
check_index=False,
check_flags=check_flags,
Copy link
Member

@simonjayhawkins simonjayhawkins Jan 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right. I think I am starting to get my head round this. This should be check_flags=False to override the default checking in assert_series_equal and be consistent with check_index=False in the line above.

the flags check is already performed on the DataFrame.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep you are correct. Passing in False is the way to go here

@simonjayhawkins
Copy link
Member

Also, we should maybe consider #45092 a bug-fix for the flags propagation to the Series object and add some tests for that? I guess this is tested somewhere if the propagation of the flags to the Series when indexing a DataFrame is the right thing to do.

Copy link
Member

@simonjayhawkins simonjayhawkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blocking for now. The regression is from #45092 so that's the starting point. OK that the changes here may seem sensible but I think needs more discussion and merging this will close off the issue.

As #45092 appears to have made an unintentional change we should consider the implications. (is is the right thing to do, is it fully tested, should it have been communicated, do the docs need updating, is it a breaking change)

we may want to revert #45092 for now and re-introduce in 1.5

@phofl
Copy link
Member Author

phofl commented Jan 23, 2022

Hm in general I am fine with #45092, since the flags are now propagated because of the added finalize call. Which is what we should expect I think.

I don't think that we have many tests where we check for the flags (might be wrong here), because this is related to the finalize issue, where we check for metadata. If the metadata are propagated, the flag is propagated too.

@jreback
Copy link
Contributor

jreback commented Jan 23, 2022

Hm in general I am fine with #45092, since the flags are now propagated because of the added finalize call. Which is what we should expect I think.

I don't think that we have many tests where we check for the flags (might be wrong here), because this is related to the finalize issue, where we check for metadata. If the metadata are propagated, the flag is propagated too.

agree, yeah we should actcually turn this to true as a default if possible.

@@ -15,7 +15,7 @@ including other versions of pandas.
Fixed regressions
~~~~~~~~~~~~~~~~~
- Regression in :meth:`Series.mask` with ``inplace=True`` and ``PeriodDtype`` and an incompatible ``other`` coercing to a common dtype instead of raising (:issue:`45546`)
-
- Regression in :func:`.assert_frame_equal` not respecting ``check_flags=False`` (:issue:`45554`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this render?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Borrowed it from v1.3.0, worked there

@jreback jreback merged commit 49bddad into pandas-dev:main Jan 28, 2022
@jreback
Copy link
Contributor

jreback commented Jan 28, 2022

@meeseeksdev backport 1.4.x

@lumberbot-app
Copy link

lumberbot-app bot commented Jan 28, 2022

Something went wrong ... Please have a look at my logs.

@phofl phofl deleted the 45554 branch January 28, 2022 10:04
phofl added a commit that referenced this pull request Jan 28, 2022
yehoshuadimarsky pushed a commit to yehoshuadimarsky/pandas that referenced this pull request Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Regression Functionality that used to work in a prior pandas version Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Parameter check_flags is ignored in assert_frame_equal
3 participants