diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2021-04-21 17:17:14 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-21 17:17:14 -0600 |
commit | f048051926bdc1f145b4e6a9516b0ee55b5d1e8e (patch) | |
tree | d386a02c700799079596dd74e8f3ee4b4ffe7100 | |
parent | 2a2dc51aacab13eb2ebe3ca97cf1bc674ba7f39f (diff) | |
parent | 379ffd443c12ef45f178a30605a237198689f29b (diff) | |
download | numpy-f048051926bdc1f145b4e6a9516b0ee55b5d1e8e.tar.gz |
Merge pull request #18786 from xamm/clip-doc-add-note
DOC: add note for clip() special case a_min > a_max See #18782
-rw-r--r-- | numpy/core/fromnumeric.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index 3646b39b0..5c7b3372b 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, 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]) + >>> 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]) |