Skip to content

TST: Cleanup tests from numeric_only / nuisance deprecation #50133

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
rhshadrach opened this issue Dec 8, 2022 · 7 comments
Open

TST: Cleanup tests from numeric_only / nuisance deprecation #50133

rhshadrach opened this issue Dec 8, 2022 · 7 comments
Assignees
Labels
Clean Nuisance Columns Identifying/Dropping nuisance columns in reductions, groupby.add, DataFrame.apply Testing pandas testing functions or related to the test suite

Comments

@rhshadrach
Copy link
Member

In enforcing the numeric_only / silent dropping of nuisance columns deprecations for 2.0, many of our tests now have the following pattern:

df = pd.DataFrame({'a': [1, 2, 3], 'b': ['x', 'y', 'z']})
with pytest.raises(TypeError, match=...):
   df.mean()
result = df.mean(numeric_only=True)
expected = ...
tm.assert_series_equal(result, expected)

I think it would be better to consolidate these into a small group of tests, something like test_op_raises_on_invalid_type, and remove the invalid types from the remainder of the tests.

cc @mroeschke

@rhshadrach rhshadrach added Testing pandas testing functions or related to the test suite Clean Nuisance Columns Identifying/Dropping nuisance columns in reductions, groupby.add, DataFrame.apply labels Dec 8, 2022
@albuzenet
Copy link
Contributor

take

@albuzenet
Copy link
Contributor

Hello rhshadrach, this will be my first contribution to pandas. Do you have any example of test/file I can start with ? Maybe the work can be split if there is a lot to be done ?

@rhshadrach
Copy link
Member Author

@AlexBuzenet - you can find examples by searching the tests for numeric_only=True; while not all of these will be examples, a good amount will. It's only an example when it fits the pattern described above. Here is one such example:

with pytest.raises(TypeError, match="does not support"):
df.groupby("A").sum().columns
result = df.groupby("A").sum(numeric_only=True).columns

I'd recommend naming the files test_invalid_op.py (the name may be workshopped) that will go in various subdirectories - e.g. frame and groupby - within the tests directory. In working on this issue, we want to make sure we don't lose test coverage. So for any removed test we need to point at a similar test in the new location.

I'll plan to do one example PR in the next day or two in groupby.

As for splitting this up, I think that's a good idea but it would require a list of tests. I don't have that at the moment, and it would take some time to create.

@albuzenet
Copy link
Contributor

@rhshadrach I just opened a PR extending your work in groupby. Let me know if it is what is expected. Should we continue with frame after groupby ?

@jbrockmendel
Copy link
Member

a lot of these exist in tests.groupby.test_raises

@luke396
Copy link
Contributor

luke396 commented Jul 26, 2023

This issue has been silent for a while, I can continue to finish it.

@rhshadrach
Copy link
Member Author

@luke396 - that's be great. I've lost track of where things stand here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Nuisance Columns Identifying/Dropping nuisance columns in reductions, groupby.add, DataFrame.apply Testing pandas testing functions or related to the test suite
Projects
None yet
Development

No branches or pull requests

4 participants