8000 Merge pull request #18786 from xamm/clip-doc-add-note · numpy/numpy@f048051 · GitHub
[go: up one dir, main page]

Skip to content

Commit f048051

Browse files
authored
Merge pull request #18786 from xamm/clip-doc-add-note
DOC: add note for clip() special case a_min > a_max See #18782
2 parents 2a2dc51 + 379ffd4 commit f048051

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

numpy/core/fromnumeric.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2086,15 +2086,25 @@ def clip(a, a_min, a_max, out=None, **kwargs):
20862086
--------
20872087
:ref:`ufuncs-output-type`
20882088
2089+
Notes
2090+
-----
2091+
When `a_min` is greater than `a_max`, `clip` returns an
2092+
array in which all values are equal to `a_max`,
2093+
as shown in the second example.
2094+
20892095
Examples
20902096
--------
20912097
>>> a = np.arange(10)
2092-
>>> np.clip(a, 1, 8)
2093-
array([1, 1, 2, 3, 4, 5, 6, 7, 8, 8])
20942098
>>> a
20952099
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
2100+
>>> np.clip(a, 1, 8)
2101+
array([1, 1, 2, 3, 4, 5, 6, 7, 8, 8])
2102+
>>> np.clip(a, 8, 1)
2103+
array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
20962104
>>> np.clip(a, 3, 6, out=a)
20972105
array([3, 3, 3, 3, 4, 5, 6, 6, 6, 6])
2106+
>>> a
2107+
array([3, 3, 3, 3, 4, 5, 6, 6, 6, 6])
20982108
>>> a = np.arange(10)
20992109
>>> a
21002110
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])

0 commit comments

Comments
 (0)
0