diff options
author | Jonas Liechti <jonas.i.liechti@protonmail.ch> | 2021-10-05 00:46:41 +0200 |
---|---|---|
committer | Jonas Liechti <jonas.i.liechti@protonmail.ch> | 2021-10-05 00:46:41 +0200 |
commit | dd3dff57b097c375858f84ebf57d75ec50150e55 (patch) | |
tree | 12d6ddfd81308701c5cefeb1201222aae4ea8194 /numpy/lib/function_base.py | |
parent | 6000e438ea56e7eb622fe99ce28321eb81faec59 (diff) | |
download | numpy-dd3dff57b097c375858f84ebf57d75ec50150e55.tar.gz |
adding example: also highlight priority in multiple matches
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 0dee7784a..3c49c227a 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -660,8 +660,17 @@ def select(condlist, choicelist, default=0): >>> x = np.arange(6) >>> condlist = [x<3, x>3] >>> choicelist = [x, x**2] - >>> np.select(condlist, choicelist) - array([ 0, 1, 2, 0, 16, 25]) + >>> np.select(condlist, choicelist, 55) + array([ 0, 1, 2, 55, 16, 25]) + + Note that, when multiple conditions are satisfied, the element is drawn + from the first element in `choicelist` with a matching condition: + + >>> x = np.arange(6) + >>> condlist = [x<=4, x>3] + >>> choicelist = [x, x**2] + >>> np.select(condlist, choicelist, 55) + array([ 0, 1, 2, 3, 4, 25]) """ # Check the size of condlist and choicelist are the same, or abort. |