mlx_graphs.utils.array_ops.index_to_mask

Contents

mlx_graphs.utils.array_ops.index_to_mask#

mlx_graphs.utils.array_ops.index_to_mask(index: mlx.core.array, size: int | None = None) mlx.core.array[source]#

Converts indices to a mask representation.

Parameters:
  • index (array) – Array of indices where the mask will be True.

  • size (Optional[int]) – Length of the returned mask array. By default, the size is set to the maximum index in the indices + 1.

Return type:

array

Returns:

A boolean array of length size, with True at the given index indices and False elsewhere.

Example:

>>> index = mx.array([1, 2, 3])
>>> index_to_mask(index, size=5)
array([False, True, True, True, False], dtype=bool)