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

Projects
None yet
4 participants
@TomAugspurger
Copy link
Contributor

commented Dec 19, 2018

xref #24227

@TomAugspurger TomAugspurger added this to the 0.24.0 milestone Dec 19, 2018

@pep8speaks

This comment has been minimized.

Copy link

commented Dec 19, 2018

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()

This comment has been minimized.

Copy link
@TomAugspurger

TomAugspurger Dec 19, 2018

Author Contributor

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

@codecov

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

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)

This comment has been minimized.

Copy link
@jreback

jreback Dec 19, 2018

Contributor

can we make this more generic? IOW have nv.validate_statu_func dispatch based on fname?

This comment has been minimized.

Copy link
@TomAugspurger

TomAugspurger Dec 20, 2018

Author Contributor

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.

This comment has been minimized.

Copy link
@jreback

jreback Dec 21, 2018

Contributor

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

This comment has been minimized.

Copy link
@gfyoung

gfyoung Dec 20, 2018

Member

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.

This comment has been minimized.

Copy link
@jreback

jreback Dec 21, 2018

Contributor

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

@TomAugspurger

This comment has been minimized.

Copy link
Contributor Author

commented Dec 20, 2018

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

@TomAugspurger TomAugspurger referenced this pull request Dec 20, 2018

Merged

NumPyBackedExtensionArray #24227

0 of 3 tasks complete

@jreback jreback merged commit bab279a into pandas-dev:master Dec 21, 2018

3 checks passed

ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
pandas-dev.pandas Build #20181219.48 succeeded
Details
@jreback

This comment has been minimized.

Copy link
Contributor

commented Dec 21, 2018

@TomAugspurger TomAugspurger deleted the TomAugspurger:validate-keepdims branch Jan 2, 2019

Pingviinituutti added a commit to Pingviinituutti/pandas that referenced this pull request Feb 28, 2019

Pingviinituutti added 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
You can’t perform that action at this time.