Skip to content

TST: Testing for mixed int/str Index #61349

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

Open
wants to merge 77 commits into
base: main
Choose a base branch
from
Open

Conversation

xaris96
Copy link

@xaris96 xaris96 commented Apr 24, 2025

pelagiavlas and others added 26 commits March 26, 2025 22:58
@datapythonista
Copy link
Member

@xaris96 Can you fix the broken tests and remove all your debug files from this PR please?

@datapythonista datapythonista added Testing pandas testing functions or related to the test suite Index Related to the Index class or subclasses labels May 3, 2025
@datapythonista datapythonista changed the title Issue tm TST: Testing for mixed int/str Index May 3, 2025
xaris96 and others added 5 commits May 22, 2025 19:30
Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>
Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>
Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>
Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>
@xaris96 xaris96 requested a review from mroeschke May 23, 2025 07:30
Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

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

Please review the diff and consistently use these following conventions

  1. Use inferred_type to check for the new mixed-int-string case you added
  2. If a test fails, do not astype or pytest.skip. Add an pytest.mark.xfail to the test instead

Comment on lines +158 to +160
has_str = any(isinstance(x, str) for x in index)
has_int = any(isinstance(x, int) for x in index)
if has_str and has_int:
Copy link
Member

Choose a reason for hiding this comment

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

Please check .inferred_type.

Copy link
Author

Choose a reason for hiding this comment

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

I tried using .inferred_type, but it causes unrelated tests to fail (not just the mixed int/str ones). Let me know if you'd like more details.

Comment on lines +66 to +69
@pytest.mark.parametrize(
"index_or_series_obj", [[1, 2, 3], ["a", "b", "c"], [0, "a", 1, "b", 2, "c"]]
)
@pytest.mark.parametrize("sort", [True, False])
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@pytest.mark.parametrize(
"index_or_series_obj", [[1, 2, 3], ["a", "b", "c"], [0, "a", 1, "b", 2, "c"]]
)
@pytest.mark.parametrize("sort", [True, False])

This overrides the original fixtures being used here


for idx in [index1, index2]:
for lvl in range(idx.nlevels):
if has_mixed_types(idx.get_level_values(lvl)):
Copy link
Member

Choose a reason for hiding this comment

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

Please check inferred_type

Comment on lines +939 to +942
pytest.skip(
f"Mixed types in MultiIndex level {lvl} are not orderable"
)
Copy link
Member

Choose a reason for hiding this comment

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

Please add an xfail marker instead

@xaris96 xaris96 force-pushed the issue-TM branch 6 times, most recently from 92e9e10 to a1eed56 Compare May 30, 2025 15:40
@xaris96 xaris96 requested a review from Dr-Irv as a code owner May 30, 2025 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Index Related to the Index class or subclasses Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TST: mixed_int_string Index
5 participants