summaryrefslogtreecommitdiff
path: root/numpy/core/fromnumeric.py
diff options
context:
space:
mode:
authorxamm <39380924+xamm@users.noreply.github.com>2021-04-16 11:24:05 +0200
committerxamm <39380924+xamm@users.noreply.github.com>2021-04-16 11:24:05 +0200
commitc16a619ec2bdf2227e5247466b69cd9e25e36358 (patch)
tree4ba052bec952045161e1afcb6148705524e4ac25 /numpy/core/fromnumeric.py
parent181f273a59744d58f90f45d953a3285484c72cba (diff)
downloadnumpy-c16a619ec2bdf2227e5247466b69cd9e25e36358.tar.gz
DOC: add note for clip() special case a_min > a_max See #18782
Diffstat (limited to 'numpy/core/fromnumeric.py')
-rw-r--r--numpy/core/fromnumeric.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py
index 3646b39b0..c8ab0ae25 100644
--- a/numpy/core/fromnumeric.py
+++ b/numpy/core/fromnumeric.py
@@ -2086,15 +2086,25 @@ def clip(a, a_min, a_max, out=None, **kwargs):
--------
:ref:`ufuncs-output-type`
+ Notes
+ --------
+ When `a_min` is greater than `a_max`, `clip` returns an
+ array in which all values are equal to `a_max`,
+ as shown in the second example.
+
Examples
--------
>>> a = np.arange(10)
- >>> np.clip(a, 1, 8)
- array([1, 1, 2, 3, 4, 5, 6, 7, 8, 8])
>>> a
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+ >>> np.clip(a, 1, 8)
+ array([1, 1, 2, 3, 4, 5, 6, 7, 8, 8])
+ >>> np.clip(a, a_max = 1, a_min = 8)
+ array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
>>> np.clip(a, 3, 6, out=a)
array([3, 3, 3, 3, 4, 5, 6, 6, 6, 6])
+ >>> a
+ array([3, 3, 3, 3, 4, 5, 6, 6, 6, 6])
>>> a = np.arange(10)
>>> a
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])