Skip to content
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

COMPAT: Add keepdims and friends to validation #24356

Merged
merged 5 commits into from
Dec 21, 2018

Conversation

TomAugspurger
Copy link
Contributor

xref #24227

@TomAugspurger TomAugspurger added the Compat pandas objects compatability with Numpy or Python functions label Dec 19, 2018
@TomAugspurger TomAugspurger added this to the 0.24.0 milestone Dec 19, 2018
@pep8speaks
Copy link

Hello @TomAugspurger! Thanks for submitting the PR.

@@ -225,16 +226,32 @@ def validate_cum_func_with_skipna(skipna, args, kwargs, name):
STAT_FUNC_DEFAULTS = OrderedDict()
STAT_FUNC_DEFAULTS['dtype'] = None
STAT_FUNC_DEFAULTS['out'] = None

PROD_DEFAULTS = SUM_DEFAULTS = STAT_FUNC_DEFAULTS.copy()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a bit complicated to get the order of the keywords correct.

@codecov
Copy link

codecov bot commented Dec 19, 2018

Codecov Report

Merging #24356 into master will decrease coverage by 49.28%.
The diff coverage is 81.81%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master   #24356       +/-   ##
===========================================
- Coverage   92.29%   43.01%   -49.29%     
===========================================
  Files         162      162               
  Lines       51808    51825       +17     
===========================================
- Hits        47817    22290    -25527     
- Misses       3991    29535    +25544
Flag Coverage Δ
#multiple ?
#single 43.01% <81.81%> (+0.01%) ⬆️
Impacted Files Coverage Δ
pandas/compat/numpy/function.py 57.14% <100%> (-30%) ⬇️
pandas/core/generic.py 39.62% <50%> (-57.04%) ⬇️
pandas/io/formats/latex.py 0% <0%> (-100%) ⬇️
pandas/core/categorical.py 0% <0%> (-100%) ⬇️
pandas/io/sas/sas_constants.py 0% <0%> (-100%) ⬇️
pandas/tseries/plotting.py 0% <0%> (-100%) ⬇️
pandas/tseries/converter.py 0% <0%> (-100%) ⬇️
pandas/io/formats/html.py 0% <0%> (-98.65%) ⬇️
pandas/core/groupby/categorical.py 0% <0%> (-95.46%) ⬇️
pandas/io/sas/sas7bdat.py 0% <0%> (-91.17%) ⬇️
... and 122 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 14c33b0...82ce910. Read the comment docs.

@codecov
Copy link

codecov bot commented Dec 19, 2018

Codecov Report

Merging #24356 into master will increase coverage by <.01%.
The diff coverage is 95.45%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #24356      +/-   ##
==========================================
+ Coverage   92.29%   92.29%   +<.01%     
==========================================
  Files         162      162              
  Lines       51808    51825      +17     
==========================================
+ Hits        47817    47833      +16     
- Misses       3991     3992       +1
Flag Coverage Δ
#multiple 90.7% <95.45%> (ø) ⬆️
#single 43.01% <81.81%> (+0.01%) ⬆️
Impacted Files Coverage Δ
pandas/compat/numpy/function.py 87.91% <100%> (+0.77%) ⬆️
pandas/core/generic.py 96.62% <87.5%> (-0.04%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 88aebed...ed5308f. Read the comment docs.

if name == 'sum':
nv.validate_sum(tuple(), kwargs)
elif name == 'prod':
nv.validate_prod(tuple(), 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 we make this more generic? IOW have nv.validate_statu_func dispatch based on fname?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that would make sense, but it isn't really written that way right now. Right now we just have instances of CompatValidator sitting in function.py, and we choose the right one to call.

It'd be nice to have a decorator that did it for us

@validate_numpy
def mean(self, ...):
    ...

then we don't have the duplication of the function name. But I think that's a decent sized refactor of how things are done now.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok but this seems very hacky to hardcore when we already know the name

Copy link
Member

Choose a reason for hiding this comment

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

But I think that's a decent sized refactor of how things are done now.

Agreed. At the time, I wrote it that way to keep things explicit, and it made it slightly easier to handle the details of each analogous numpy function.

That being said, I think refactoring to dispatching seems reasonable as well but would be best served for investigation and execution in a follow-up.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok for now. let's followup and see if can reduce need to specify names like this.

@TomAugspurger
Copy link
Contributor Author

Is this OK to go? It'll let me use our regular validators in #24227

@TomAugspurger TomAugspurger mentioned this pull request Dec 20, 2018
3 tasks
@jreback jreback merged commit bab279a into pandas-dev:master Dec 21, 2018
@jreback
Copy link
Contributor

jreback commented Dec 21, 2018

thanks @TomAugspurger

@TomAugspurger TomAugspurger deleted the validate-keepdims branch January 2, 2019 20:17
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this pull request Feb 28, 2019
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this pull request Feb 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants