where#

rbc.stdlib.searching_functions.where(condition, x1, x2)#

Returns elements chosen from x1 or x2 depending on condition.

Examples

>>> from rbc.stdlib import array_api
>>> @heavydb('int32[](int32[])')
... def rbc_where(a):
...     return array_api.where(a < 2, a, -1)
>>> a = np.arange(5, dtype=np.int32)
>>> rbc_where(a).execute()
array([ 0,  1, -1, -1, -1], dtype=int32)
>>> @heavydb('int32[](int32[])')
... def rbc_where(a):
...     return array_api.where([True, False], 2, a)
>>> a = np.asarray([111, 222], dtype=np.int32)
>>> rbc_where(a).execute()
array([  2, 222], dtype=int32)

Array-API ‘where’ doc