From c16a619ec2bdf2227e5247466b69cd9e25e36358 Mon Sep 17 00:00:00 2001 From: xamm <39380924+xamm@users.noreply.github.com> Date: Fri, 16 Apr 2021 11:24:05 +0200 Subject: DOC: add note for clip() special case a_min > a_max See #18782 --- numpy/core/fromnumeric.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'numpy/core/fromnumeric.py') 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]) -- cgit v1.2.1 From c5e9e140e57774262cf5ac4762d19a9da5c9477d Mon Sep 17 00:00:00 2001 From: xamm <39380924+xamm@users.noreply.github.com> Date: Fri, 16 Apr 2021 11:49:26 +0200 Subject: MAINT: change argument type in numpy.clip documentation example from keyword to positional as suggested by reviewer --- numpy/core/fromnumeric.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'numpy/core/fromnumeric.py') diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index c8ab0ae25..7c43cd313 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -2099,7 +2099,7 @@ def clip(a, a_min, a_max, out=None, **kwargs): 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) + >>> np.clip(a, 8, 1) 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]) -- cgit v1.2.1 From 379ffd443c12ef45f178a30605a237198689f29b Mon Sep 17 00:00:00 2001 From: Patrick <39380924+xamm@users.noreply.github.com> Date: Sat, 17 Apr 2021 10:37:33 +0200 Subject: MAINT: Remove unnecessary dash for the dividing line Co-authored-by: Matthias Bussonnier --- numpy/core/fromnumeric.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'numpy/core/fromnumeric.py') diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index 7c43cd313..5c7b3372b 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -2087,7 +2087,7 @@ 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. -- cgit v1.2.1