Return an array drawn from elements in choicelist, depending on conditions.
Parameters: | condlist : list of N boolean arrays of length M
choicelist : list of N arrays of length M
|
---|---|
Returns: | output : 1-dimensional array of length M
|
Notes
Equivalent to:
output = []
for m in range(M):
output += [V[m] for V,C in zip(values,cond) if C[m]]
or [default]
Examples
>>> t = np.arange(10)
>>> s = np.arange(10)*100
>>> condlist = [t == 4, t > 5]
>>> choicelist = [s, t]
>>> np.select(condlist, choicelist)
array([ 0, 0, 0, 0, 400, 0, 6, 7, 8, 9])