index_to_mask
¶
Converts indices to a mask representation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
array
|
Array of indices where the mask will be True. |
required |
size
|
Optional[int]
|
Length of the returned mask array. By default, the size is set to the maximum index in the indices + 1. |
None
|
Returns:
| Type | Description |
|---|---|
array
|
A boolean array of length |
array
|
|
Example:
>>> index = mx.array([1, 2, 3])
>>> index_to_mask(index, size=5)
array([False, True, True, True, False], dtype=bool)
Source code in mlx_graphs/utils/array_ops.py
from mlx_graphs.utils.array_ops import index_to_mask · mlx_graphs/utils/array_ops.py