Skip to content

TST:: Fixing pytest warning #50186

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pandas/tests/frame/indexing/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1449,6 +1449,8 @@ def test_loc_bool_multiindex(self, dtype, indexer):
names=["a", "b"],
)
df = DataFrame({"c": [1, 2, 3, 4]}, index=midx)
df.sort_index()
Copy link
Member

Choose a reason for hiding this comment

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

This has no effect. What are you trying to do?

Copy link
Contributor Author

@theoniko theoniko Dec 11, 2022

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

sort_index returns a new object, as long as you ignore the new object, you will just continue operating on the unsorted object. In general, we don't want to call anything in tests that is not strictly necessary.

You have to understand where the warning is from. Then you can catch the warning or re-write the test so that the warning vanishes altogether. I guess that this is not possible here, but not sure.


result = df.loc[indexer]
expected = DataFrame(
{"c": [1, 2]}, index=Index([True, False], name="b", dtype=dtype)
Expand Down