Skip to content

validate min/max axis #23206

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 3 commits into from
Oct 18, 2018
Merged

Conversation

jbrockmendel
Copy link
Member

Broken off from #23140.

@pep8speaks
Copy link

Hello @jbrockmendel! Thanks for submitting the PR.

@codecov
Copy link

codecov bot commented Oct 17, 2018

Codecov Report

Merging #23206 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #23206      +/-   ##
==========================================
+ Coverage   92.19%   92.19%   +<.01%     
==========================================
  Files         169      169              
  Lines       50954    50964      +10     
==========================================
+ Hits        46975    46985      +10     
  Misses       3979     3979
Flag Coverage Δ
#multiple 90.61% <100%> (ø) ⬆️
#single 42.26% <10%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/compat/numpy/function.py 87.13% <100%> (+0.46%) ⬆️
pandas/core/indexes/datetimelike.py 98.25% <100%> (+0.02%) ⬆️

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 9285820...b8302b3. Read the comment docs.

@TomAugspurger TomAugspurger added the Refactor Internal refactoring of code label Oct 18, 2018
@TomAugspurger TomAugspurger added this to the 0.24.0 milestone Oct 18, 2018
@TomAugspurger TomAugspurger merged commit 6bc79c9 into pandas-dev:master Oct 18, 2018
@jreback
Copy link
Contributor

jreback commented Oct 18, 2018

this is not correct - why did you merge??

@jreback
Copy link
Contributor

jreback commented Oct 18, 2018

this is very verbose code and needs to be incorporated to the validation rather than done in the DatetimeArray

@@ -479,6 +481,7 @@ def max(self, axis=None, *args, **kwargs):
numpy.ndarray.max
"""
nv.validate_max(args, kwargs)
nv.validate_minmax_axis(axis)
Copy link
Contributor

Choose a reason for hiding this comment

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

these need to be inside these functions

the is so smelly to have to call 2 functions here
pls fix

@TomAugspurger
Copy link
Contributor

Seems good to me. Shall we revert?

@jorisvandenbossche
Copy link
Member

The argument made on the previous PR is that those two validations are not really the same, so they don't necessarily need to live in the same function

@jreback
Copy link
Contributor

jreback commented Oct 18, 2018

i disagree

we have a well thought out pattern for handling these validations

this should be integral to the current framework rather than simply adding another function call

@jorisvandenbossche
Copy link
Member

I think the question is whether you see this as a "numpy compatibility" check, or rather a general keyword arg validation check (as we do in many places in pandas). In the first case you are right this should be integrated, in the second case I think separate is fine, and the function should actually be moved to _validators.py.
I think for that question we could go either way, but I personally lean more toward this being a general check.

@jreback
Copy link
Contributor

jreback commented Oct 18, 2018

this should be part of the existing check

the issue as written is that you have to remember to add this in addition. to _validate_min for example
whereas it should just be part of that

this is just cause for bugs laters on as written

@jbrockmendel
Copy link
Member Author

@jreback the new axis validation func assumes self.ndim==1, which nothing else in compat.numpy.functions does. Adding that assumption into a subset of that module's functions is much smellier than making an explicit function call in four place.s

If we were to combine the axis check into the existing functions, two possible approaches come to mind. The first is to wrap the extant functions and pin the new one to them. You disapproved of this when implemented in #23140.

The second approach is to modify the function-generating code and bake in this new check to everything in compat.functions.numpy. Besides not being clear that we want this check in all the other affected functions, these way these functions are generated is opaque to newcomers (yo!) and changing the generating code will end up much more verbose than the 4 lines of function calls in this implementation.

@jbrockmendel jbrockmendel deleted the argmin_validate branch October 23, 2018 03:28
tm9k1 pushed a commit to tm9k1/pandas that referenced this pull request Nov 19, 2018
* validate min/max axis closes pandas-dev#23081

* Fix copy/paste indentation mistake

* Fix merge mixup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactor Internal refactoring of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Datetime/Timedelta/Period Index min, argmin, max, argmax have axis kwarg
5 participants