where

where(condition: array, x1: array, x2: array, /) array

Returns elements chosen from x1 or x2 depending on condition.

Parameters:
  • condition (array) – when True, yield x1_i; otherwise, yield x2_i. Must be compatible with x1 and x2 (see Broadcasting).

  • x1 (array) – first input array. Must be compatible with condition and x2 (see Broadcasting).

  • x2 (array) – second input array. Must be compatible with condition and x1 (see Broadcasting).

Returns:

out (array) – an array with elements from x1 where condition is True, and elements from x2 elsewhere. The returned array must have a data type determined by Type Promotion Rules rules with the arrays x1 and x2.