-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
ENH: __array_function__
support for np.lib
, part 1/2
#12116
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
Conversation
np.lib.arraypad through np.lib.nanfunctions
be2b64f
to
4141e24
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here about repeated signatures, otherwise all good.
I see that you've omitted a lot of None
checks for this PR and I realise it will never dispatch to those, but it might be nice to make it explicit. I'll leave the decision up to you though.
@@ -36,6 +37,11 @@ | |||
] | |||
|
|||
|
|||
def _ediff1d_dispatcher(ary, to_end=None, to_begin=None): | |||
return (ary, to_end, to_begin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a is not None
check.
@@ -3294,6 +3405,12 @@ def _ureduce(a, func, **kwargs): | |||
return r, keepdim | |||
|
|||
|
|||
def _median_dispatcher( | |||
a, axis=None, out=None, overwrite_input=None, keepdims=None): | |||
return (a, out) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a None
check for out
.
@@ -3583,6 +3706,12 @@ def percentile(a, q, axis=None, out=None, | |||
a, q, axis, out, overwrite_input, interpolation, keepdims) | |||
|
|||
|
|||
def _quantile_dispatcher(a, q, axis=None, out=None, overwrite_input=None, | |||
interpolation=None, keepdims=None): | |||
return (a, q, out) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs None
check for out.
I opted against this style mostly because it can make the dispatchers significantly longer, e.g., def _ediff1d_dispatcher(ary, to_end=None, to_begin=None):
return (ary, to_end, to_begin) vs def _ediff1d_dispatcher(ary, to_end=None, to_begin=None):
yield ary
if to_end is not None:
yield to_end
if to_begin is not None:
yield to_begin If this actually made a difference in speed I would go for it, but I suspect they will actually be quite similar in performance. |
Thanks Stephan. |
__array_function__
support for np.lib
, part 1/2
xref #12028
np.lib.arraypad through np.lib.nanfunctions