mlx.core.where#

where(condition: scalar | array, x: scalar | array, y: scalar | array, /, *, stream: None | Stream | Device = None) array#

Select from x or y according to condition.

The condition and input arrays must be the same shape or broadcastable with each another.

Parameters:
  • condition (array) – The condition array.

  • x (array) – The input selected from where condition is True.

  • y (array) – The input selected from where condition is False.

Returns:

The output containing elements selected from x and y.

Return type:

result (array)