Skip to content

BUG: Prevent abuse of kwargs in stat functions #12318

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

Conversation

gfyoung
Copy link
Member

@gfyoung gfyoung commented Feb 13, 2016

Addresses issue #12301 by filtering kwargs argument in stat functions to prevent the passage of clearly invalid arguments while at the same time maintaining compatibility with analogous numpy functions.

@gfyoung
Copy link
Member Author

gfyoung commented Feb 13, 2016

Suggestions on where I could place tests to make sure such an issue doesn't crop up again? Tried finding a place, but no one place really stood out to me.

@jreback
Copy link
Contributor

jreback commented Feb 13, 2016

tests/frame/test_analytics.py

@jreback
Copy link
Contributor

jreback commented Feb 13, 2016

or maybe better in test_generic.py (if you place it in Generic then it will be run for each of the structures)

compat_args = ['out', 'dtype']
list(map(kwargs.__delitem__, filter(
kwargs.__contains__, compat_args)))
if kwargs:
Copy link
Contributor

Choose a reason for hiding this comment

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

can you put this in a helper function (you can pass kwargs and parameterize the compat_args if you want)

maybe _assert_valid_kwargs or something

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@jreback jreback added API Design Error Reporting Incorrect or improved errors from pandas labels Feb 13, 2016
@gfyoung
Copy link
Member Author

gfyoung commented Feb 13, 2016

@jreback : Off topic, but I noticed that there's a MASSIVE queue on Travis right now. There seem to be a ton of duplicate builds that could be cancelled.

@jreback
Copy link
Contributor

jreback commented Feb 13, 2016

its actually progressing, travis was down most of today.

@jreback
Copy link
Contributor

jreback commented Feb 13, 2016

your builds occur independently of pandas FYI

@gfyoung
Copy link
Member Author

gfyoung commented Feb 13, 2016

Ah, I see. Also, I like the suggestion for test_generic.py. I'll go with that one.

@jreback jreback added this to the 0.18.0 milestone Feb 13, 2016
@jreback
Copy link
Contributor

jreback commented Feb 13, 2016

lgtm. ping when green.

@jreback
Copy link
Contributor

jreback commented Feb 13, 2016

pls add a whatsnew entry (you can put in API changes)

@gfyoung gfyoung force-pushed the kwarg_remover branch 2 times, most recently from c63b936 to 1fc24a1 Compare February 14, 2016 08:40
Filters kwargs argument in stat functions to
prevent the passage of clearly invalid arguments
while at the same time maintaining compatibility
with analogous numpy functions.

Closes pandas-devgh-12301.
@gfyoung
Copy link
Member Author

gfyoung commented Feb 14, 2016

@jreback : Travis is happy again. Good to merge if there's nothing else.

@jreback jreback closed this in 3d2f115 Feb 14, 2016
@gfyoung gfyoung deleted the kwarg_remover branch February 14, 2016 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Error Reporting Incorrect or improved errors from pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants