[Numpy-discussion] np.where: x and y need to have the same shape as condition ?
Tue Jan 29 05:16:43 CST 2013
the doc for `where` says "x and y need to have the same shape as condition"
"where is equivalent to:
[xv if c else yv for (c,xv,yv) in zip(condition,x,y)]"
holds as long as len(condition) == len(x) == len(y) ?
And `condition` can be broadcast ?
n = 3
all01 = np.array([ t for t in np.ndindex( n * (2,) )]) # 000 001 ...
x = np.zeros(n)
y = np.ones(n)
w = np.where( all01, y, x ) # 2^n x n
Can anyone please help me understand `where`
/ extend "where is equivalent to ..." ?
More information about the NumPy-Discussion