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 --- doc/release/upcoming_changes/18782.change.rst | 5 +++++ numpy/core/fromnumeric.py | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 doc/release/upcoming_changes/18782.change.rst diff --git a/doc/release/upcoming_changes/18782.change.rst b/doc/release/upcoming_changes/18782.change.rst new file mode 100644 index 000000000..c401b6733 --- /dev/null +++ b/doc/release/upcoming_changes/18782.change.rst @@ -0,0 +1,5 @@ +Added `numpy.clip` note and example for special case `a_min` greater than `a_max` to the documentation +------------------------------------------------------------------------------------------------------ +The documentation of `numpy.clip` has been changed to include an example and a note +for the special case where `a_min` is set to a value greater than `a_max`, +which causes `numpy.clip` to return an array in which all values are equal to `a_max`. \ No newline at end of file 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 1d2efc4140b2b1f819db181259d9cca6553d126c Mon Sep 17 00:00:00 2001 From: xamm <39380924+xamm@users.noreply.github.com> Date: Fri, 16 Apr 2021 11:30:25 +0200 Subject: MAINT: changing news fragment filename to correct pull request --- doc/release/upcoming_changes/18782.change.rst | 5 ----- doc/release/upcoming_changes/18786.change.rst | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) delete mode 100644 doc/release/upcoming_changes/18782.change.rst create mode 100644 doc/release/upcoming_changes/18786.change.rst diff --git a/doc/release/upcoming_changes/18782.change.rst b/doc/release/upcoming_changes/18782.change.rst deleted file mode 100644 index c401b6733..000000000 --- a/doc/release/upcoming_changes/18782.change.rst +++ /dev/null @@ -1,5 +0,0 @@ -Added `numpy.clip` note and example for special case `a_min` greater than `a_max` to the documentation ------------------------------------------------------------------------------------------------------- -The documentation of `numpy.clip` has been changed to include an example and a note -for the special case where `a_min` is set to a value greater than `a_max`, -which causes `numpy.clip` to return an array in which all values are equal to `a_max`. \ No newline at end of file diff --git a/doc/release/upcoming_changes/18786.change.rst b/doc/release/upcoming_changes/18786.change.rst new file mode 100644 index 000000000..c401b6733 --- /dev/null +++ b/doc/release/upcoming_changes/18786.change.rst @@ -0,0 +1,5 @@ +Added `numpy.clip` note and example for special case `a_min` greater than `a_max` to the documentation +------------------------------------------------------------------------------------------------------ +The documentation of `numpy.clip` has been changed to include an example and a note +for the special case where `a_min` is set to a value greater than `a_max`, +which causes `numpy.clip` to return an array in which all values are equal to `a_max`. \ No newline at end of file -- cgit v1.2.1 From 71115524c292a7f4ac7e5a8e6b89e8cf41d1ab72 Mon Sep 17 00:00:00 2001 From: xamm <39380924+xamm@users.noreply.github.com> Date: Fri, 16 Apr 2021 11:45:16 +0200 Subject: MAINT: removing news fragments documentation changes are usually not added to release notes --- doc/release/upcoming_changes/18786.change.rst | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 doc/release/upcoming_changes/18786.change.rst diff --git a/doc/release/upcoming_changes/18786.change.rst b/doc/release/upcoming_changes/18786.change.rst deleted file mode 100644 index c401b6733..000000000 --- a/doc/release/upcoming_changes/18786.change.rst +++ /dev/null @@ -1,5 +0,0 @@ -Added `numpy.clip` note and example for special case `a_min` greater than `a_max` to the documentation ------------------------------------------------------------------------------------------------------- -The documentation of `numpy.clip` has been changed to include an example and a note -for the special case where `a_min` is set to a value greater than `a_max`, -which causes `numpy.clip` to return an array in which all values are equal to `a_max`. \ No newline at end of file -- 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(-) 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(-) 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