[Numpy-svn] r4064 - trunk/numpy
Thu Sep 20 16:12:44 CDT 2007
Date: 2007-09-20 16:12:04 -0500 (Thu, 20 Sep 2007)
New Revision: 4064
Update documentation for `where`.
--- trunk/numpy/add_newdocs.py 2007-09-20 19:30:24 UTC (rev 4063)
+++ trunk/numpy/add_newdocs.py 2007-09-20 21:12:04 UTC (rev 4064)
@@ -339,19 +339,31 @@
- """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
+ condition : array of bool
+ When True, yield x, otherwise yield y.
+ x,y : 1-dimensional arrays
+ Values from which to choose.
+ This is equivalent to
- instead. This always results in a 2d array, with a row of indices for
- each element that satisfies the condition.
+ [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.
+ In the special case, where only `condition` is given, the
+ tuple condition.nonzero() is returned, instead.
+ >>> where([True,False,True],[1,2,3],[4,5,6])
+ array([1, 5, 3])
More information about the Numpy-svn