diff options
| author | Eric Wieser <wieser.eric@gmail.com> | 2018-12-09 01:08:33 -0800 |
|---|---|---|
| committer | Tyler Reddy <tyler.je.reddy@gmail.com> | 2019-05-14 13:52:35 -0700 |
| commit | dfe7b9db2350505903ba19867bf27dabda2bff71 (patch) | |
| tree | 60a4ab3db913c5b4276e060ffdd490e42380c25a /numpy/core/fromnumeric.py | |
| parent | 8970dc8e588776bbae45953b2809883c4b6f8ed0 (diff) | |
| download | numpy-dfe7b9db2350505903ba19867bf27dabda2bff71.tar.gz | |
ENH/DEP: Use a ufunc under the hood for ndarray.clip
This includes:
* The addition of 3-input PyObject inner loop
* The removal of `->f->fastclip` for builtin types, which now use ufuncs instead
* A deprecation in `PyArray_Clip` for third-party types that still use `->f->fastclip`
* A deprecation of the unusual casting behavior of `clip`
* A deprecation of the broken `nan`-behavior of `clip`, which was previously dependent on dimensionality and byte-order.
Diffstat (limited to 'numpy/core/fromnumeric.py')
| -rw-r--r-- | numpy/core/fromnumeric.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index 7024ac237..814ade64e 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -1961,12 +1961,12 @@ def compress(condition, a, axis=None, out=None): return _wrapfunc(a, 'compress', condition, axis=axis, out=out) -def _clip_dispatcher(a, a_min, a_max, out=None): +def _clip_dispatcher(a, a_min, a_max, out=None, **kwargs): return (a, a_min, a_max) @array_function_dispatch(_clip_dispatcher) -def clip(a, a_min, a_max, out=None): +def clip(a, a_min, a_max, out=None, **kwargs): """ Clip (limit) the values in an array. @@ -1992,6 +1992,11 @@ def clip(a, a_min, a_max, out=None): The results will be placed in this array. It may be the input array for in-place clipping. `out` must be of the right shape to hold the output. Its type is preserved. + **kwargs + For other keyword-only arguments, see the + :ref:`ufunc docs <ufuncs.kwargs>`. + + .. versionadded:: 1.17.0 Returns ------- @@ -2020,7 +2025,7 @@ def clip(a, a_min, a_max, out=None): array([3, 4, 2, 3, 4, 5, 6, 7, 8, 8]) """ - return _wrapfunc(a, 'clip', a_min, a_max, out=out) + return _wrapfunc(a, 'clip', a_min, a_max, out=out, **kwargs) def _sum_dispatcher(a, axis=None, dtype=None, out=None, keepdims=None, |
