summaryrefslogtreecommitdiff
path: root/numpy/add_newdocs.py
diff options
context:
space:
mode:
authorStefan van der Walt <stefan@sun.ac.za>2007-09-20 21:12:04 +0000
committerStefan van der Walt <stefan@sun.ac.za>2007-09-20 21:12:04 +0000
commit08488627b64df0275ba000cd8f24484639263a63 (patch)
tree40c3cfad7af06c6d55bdd78a629e3a17b320dd90 /numpy/add_newdocs.py
parent8ba0325c21e5c9ef4a3b70722cf77bc64abfbade (diff)
downloadnumpy-08488627b64df0275ba000cd8f24484639263a63.tar.gz
Update documentation for `where`.
Diffstat (limited to 'numpy/add_newdocs.py')
-rw-r--r--numpy/add_newdocs.py28
1 files changed, 20 insertions, 8 deletions
diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py
index 212915390..2acef6b69 100644
--- a/numpy/add_newdocs.py
+++ b/numpy/add_newdocs.py
@@ -339,18 +339,30 @@ add_newdoc('numpy.core.multiarray','set_numeric_ops',
""")
add_newdoc('numpy.core.multiarray','where',
- """where(condition, | x, y)
+ """where(condition, x, y) or where(condition)
- The result is shaped like condition and has elements of x and y where
- condition is respectively true or false. If x or y are not given,
- condition.nonzero() is returned.
+ Return elements from `x` or `y`, depending on `condition`.
- To group the indices by element, rather than dimension, use
+ *Parameters*:
+ condition : array of bool
+ When True, yield x, otherwise yield y.
+ x,y : 1-dimensional arrays
+ Values from which to choose.
+
+ *Notes*
+ This is equivalent to
+
+ [xv if c else yv for (c,xv,yv) in zip(condition,x,y)]
+
+ The result is shaped like `condition` and has elements of `x`
+ or `y` where `condition` is respectively True or False.
- transpose(where(condition))
+ In the special case, where only `condition` is given, the
+ tuple condition.nonzero() is returned, instead.
- instead. This always results in a 2d array, with a row of indices for
- each element that satisfies the condition.
+ *Examples*
+ >>> where([True,False,True],[1,2,3],[4,5,6])
+ array([1, 5, 3])
""")