Skip to content

TST: Move groupby tests out of test_function #55967

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 2 commits into from
Nov 16, 2023

Conversation

rhshadrach
Copy link
Member

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

The tests that remain are tests that go across reductions, transformations, and filters. The bulk of these are tests for numeric_only

@rhshadrach rhshadrach added Testing pandas testing functions or related to the test suite Groupby Clean labels Nov 15, 2023


@pytest.mark.parametrize("f", [max, min, sum])
@pytest.mark.parametrize("keys", ["jim", ["jim", "joe"]]) # Single key # Multi-key
Copy link
Member

Choose a reason for hiding this comment

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

the comment might be clearer if instead of being a comment it was encoded in ids=["single_key", "multi_key"]

result = df.groupby("A", as_index=False).cumsum()
tm.assert_frame_equal(result, expected)

# GH 13994
Copy link
Member

Choose a reason for hiding this comment

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

NBD (in part bc it will be removed in a few months) but probably should be split out into a separate test

df_out.set_index("a", inplace=True)

grpd = df.groupby("a")
t = getattr(grpd, method)(*data["args"])
Copy link
Member

Choose a reason for hiding this comment

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

nitpick can we avoid 1-letter variable names while we're here

Copy link
Member

Choose a reason for hiding this comment

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

(i like "result" and "expected" to make clear which one is which, particularly in places where neither is constructed explicitly)

@jbrockmendel
Copy link
Member

tests arent changed, just cut/paste?

@rhshadrach
Copy link
Member Author

tests arent changed, just cut/paste?

Yea - that's right. Just a move here. Once test_functions is no more and test_groupby only has tests for the GroupBy instances themselves, I'm going to start trying to improve the quality of individual tests.

@mroeschke mroeschke added this to the 2.2 milestone Nov 16, 2023
@@ -219,3 +219,73 @@ def test_describe_duplicate_columns():
)
expected.index.names = [1]
tm.assert_frame_equal(result, expected)


class TestGroupByNonCythonPaths:
Copy link
Member

Choose a reason for hiding this comment

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

Note for a follow up, would be good to collapse this class into just the testing function and fixtures

@mroeschke mroeschke merged commit 4c359a3 into pandas-dev:main Nov 16, 2023
@mroeschke
Copy link
Member

Thanks @rhshadrach

@rhshadrach rhshadrach deleted the clean_gb_tests_6 branch November 16, 2023 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Groupby Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants