Skip to content
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

REGR: Avoid regression warning with ea dtype and assert_index_equal order False #47325

Merged
merged 3 commits into from
Jun 15, 2022

Conversation

phofl
Copy link
Member

@phofl phofl commented Jun 13, 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 Jun 13, 2022
@phofl phofl added this to the 1.4.3 milestone Jun 13, 2022
left = Index(safe_sort(left))
right = Index(safe_sort(right))
left = Index(safe_sort(left), dtype=left.dtype)
right = Index(safe_sort(right), dtype=right.dtype)
Copy link
Member

Choose a reason for hiding this comment

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

maybe another issue, but the check_names check is later. It maybe that would need to resuse the code pattern you added in #47206. Not here, as this PR is targeted 1.4.3, just an observation.

Copy link
Member Author

@phofl phofl Jun 13, 2022

Choose a reason for hiding this comment

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

Good point, I am not using that myself, so I am a bit fuzzy on all the keywords :)

It is actually a bit more comlex, because These calls return regular indexes, even if a MultiIndex was given. I'll open an issue about it

Edit: Sorry misunderstood you. You are correct, we have to use exactly the same pattern

Copy link
Member

Choose a reason for hiding this comment

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

my thinking was that your fix in #47206 looked quite useful to robustly sort indexes. and maybe a safe_sort_index would be handy. (IIRC we cannot support pandas objects in safe_sort but would need to check this). I wonder can the fix in #47206 suffer from the rogue warning too without the dtype specified there?

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 completely right. Opened #47330 for 1.5

@@ -24,6 +24,7 @@ Fixed regressions
- Fixed regression in :func:`read_csv` with ``index_col=False`` identifying first row as index names when ``header=None`` (:issue:`46955`)
- Fixed regression in :meth:`.DataFrameGroupBy.agg` when used with list-likes or dict-likes and ``axis=1`` that would give incorrect results; now raises ``NotImplementedError`` (:issue:`46995`)
- Fixed regression in :meth:`DataFrame.resample` and :meth:`DataFrame.rolling` when used with list-likes or dict-likes and ``axis=1`` that would raise an unintuitive error message; now raises ``NotImplementedError`` (:issue:`46904`)
- Fixed regression in :func:`assert_index_equal` when ``check_order=False`` and :class:`Index` has extension dtype (:issue:`47207`)
Copy link
Member

Choose a reason for hiding this comment

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

I think I may have been wrong to add the regression label to #47207

Not strictly a regression since 1.3.5 did not have EA backed Indexes and the code sample created an object dtype Index. maybe this should be in the bugfix section. wdyt?

Copy link
Member Author

Choose a reason for hiding this comment

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

You are correct wrt ea back indexes, but you can also trigger this with

idx1 = pd.Index([1, 3], dtype="object")
idx2 = pd.Index([3, 1], dtype="object")
tm.assert_index_equal(idx1, idx2, check_order=False)

I'll add a test and will adjust the release note

Copy link
Member Author

Choose a reason for hiding this comment

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

Added both

tm.assert_index_equal(idx1, idx2, check_order=False)


def test_assert_index_equal_object_ints_order_false(any_numeric_ea_dtype):
Copy link
Member

Choose a reason for hiding this comment

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

don't need the fixture otherwise lgtm.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thx, good point. Removed.

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.

Thanks @phofl lgtm

@jreback jreback merged commit 7c6a76a into pandas-dev:main Jun 15, 2022
@jreback
Copy link
Contributor

jreback commented Jun 15, 2022

thanks @phofl

@jreback
Copy link
Contributor

jreback commented Jun 15, 2022

@meeseeksdev backport 1.4.x

@lumberbot-app
Copy link

lumberbot-app bot commented Jun 15, 2022

Could not push to auto-backport-of-pr-47325-on-1.4.x due to error, aborting.

@phofl phofl deleted the 47207 branch June 15, 2022 11:49
@@ -24,6 +24,7 @@ Fixed regressions
- Fixed regression in :func:`read_csv` with ``index_col=False`` identifying first row as index names when ``header=None`` (:issue:`46955`)
- Fixed regression in :meth:`.DataFrameGroupBy.agg` when used with list-likes or dict-likes and ``axis=1`` that would give incorrect results; now raises ``NotImplementedError`` (:issue:`46995`)
- Fixed regression in :meth:`DataFrame.resample` and :meth:`DataFrame.rolling` when used with list-likes or dict-likes and ``axis=1`` that would raise an unintuitive error message; now raises ``NotImplementedError`` (:issue:`46904`)
- Fixed regression in :func:`assert_index_equal` when ``check_order=False`` and :class:`Index` has extension or object dtype (:issue:`47207`)
Copy link
Member

Choose a reason for hiding this comment

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

@phofl FYI :func:`assert_index_equal` doesn't render. probably needs to be :func:`testing.assert_index_equal` .

no need to follow-up as can be done with other cleanups before release.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, will try to do correctly in the future

simonjayhawkins pushed a commit that referenced this pull request Jun 15, 2022
…th ea dtype and assert_index_equal order False) (#47366)

Backport PR #47325: REGR: Avoid regression warning with ea dtype and assert_index_equal order False

Co-authored-by: Patrick Hoefler <61934744+phofl@users.noreply.github.com>
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: assert_index_equal raises FutureWarning when comparing Index of Int64Dtype without checking order
3 participants