Skip to content

TST: Add test for rolling window, see GH 34605 #34705

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 1 commit into from
Jun 15, 2020

Conversation

gglanzani
Copy link
Contributor

@gglanzani gglanzani commented Jun 10, 2020

Dear maintainers,

I'm opening this PR to address issue #34605.

I've made the test conditional to Python 3.8 as I'm using the positional only syntax as strong check. If this is not desired, let me know and I will change the function to explicitly check for the length of *args.

Edit: maybe the usage of parametrize is a bit exaggerated here.
Edit2: Using Python 3.8 only features does not pleases the tests. Updating.

@pep8speaks
Copy link

pep8speaks commented Jun 10, 2020

Hello @gglanzani! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2020-06-15 06:54:55 UTC

@gglanzani gglanzani changed the title TST Add test for rolling window, see GH 34605 TST: Add test for rolling window, see GH 34605 Jun 10, 2020
df.rolling(1).apply(scaled_sum, raw=True, args=(2,))

for grouping in groupings:
df.groupby(**grouping).rolling(1).apply(scaled_sum, raw=True, args=(2,))
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 we can parameterize over raw; this doesn't need to be fixed.

I think we have a raw pytest fixture you can use.


df = DataFrame(data={"X": range(5)}, index=[0, 0, 1, 1, 1])

df.rolling(1).apply(scaled_sum, raw=True, args=(2,))
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 this case is already tested (so you can remove)


df.rolling(1).apply(scaled_sum, raw=True, args=(2,))

for grouping in groupings:
Copy link
Member

Choose a reason for hiding this comment

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

We'll want to test the output of this operation

result = df.groupby(**grouping)...
expected = pd.DataFrame(...)
tm.assert_frame_equal(result, expected

Copy link
Member

Choose a reason for hiding this comment

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

Also just simplify the parametrize to:

@pytest.mark.parametrize("groupings", [{"level": 0}, {"by": "X"}]

so we can remove the for loop here

@gglanzani
Copy link
Contributor Author

@mroeschke Thanks for the review Matthew, I think I've addressed all your points.

@mroeschke
Copy link
Member

Looks good. I think our CI is having issues currently, so we can probably merge this once that is fixed.

@jreback jreback added Testing pandas testing functions or related to the test suite Window rolling, ewma, expanding labels Jun 10, 2020
@jreback jreback added this to the 1.1 milestone Jun 10, 2020
@jreback
Copy link
Contributor

jreback commented Jun 10, 2020

lgtm. yep can merge once CI is good.

@WillAyd
Copy link
Member

WillAyd commented Jun 12, 2020

@gglanzani can you merge master?

@gglanzani
Copy link
Contributor Author

@WillAyd Done

@jreback jreback merged commit 718bc9f into pandas-dev:master Jun 15, 2020
@jreback
Copy link
Contributor

jreback commented Jun 15, 2020

thanks @gglanzani

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Testing pandas testing functions or related to the test suite Window rolling, ewma, expanding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Positional Arguments Passed as a Keyword Argument in Custom Rolling Aggregation
5 participants