select
¶
select(
src: Union[array, list, tuple],
index_or_mask: Union[array, list],
axis: int = 0,
) -> Union[array, list]
Selects the entries of src along axis given by an index array or
by a boolean mask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src
|
Union[array, list, tuple]
|
An array, or a list/tuple (selected along its only axis). |
required |
index_or_mask
|
Union[array, list]
|
Indices of the entries to select, or a boolean mask of
shape |
required |
axis
|
int
|
The axis along which to select (must be |
0
|
Returns:
| Type | Description |
|---|---|
Union[array, list]
|
The selected entries, as an array if |
Union[array, list]
|
otherwise. |
Example:
src = mx.array([[1, 2], [3, 4], [5, 6]])
select(src, mx.array([True, False, True]))
# mx.array([[1, 2], [5, 6]])
select(["a", "b", "c"], mx.array([2, 0]))
# ["c", "a"]
Source code in mlx_graphs/utils/indexing.py
from mlx_graphs.utils import select · mlx_graphs/utils/indexing.py