take
Take elements from an array along an axis.| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | — | Source array. |
indices | ArrayLike | — | Indices of the values to extract. |
axis | number | undefined | Axis along which to select values. When undefined, the input array is flattened before indexing. |
NDArray — Array of values taken from a at the specified indices.
put
Replace specified elements of an array with given values.| Name | Type | Default | Description |
|---|---|---|---|
a | NDArray | — | Target array. Modified in-place. |
indices | number[] | — | Flat indices of elements to replace. |
values | ArrayLike | — | Values to place at the target indices. If shorter than indices, values are repeated cyclically. |
void — The array a is modified in-place.
choose
Construct an array from an index array and a list of arrays to choose from.| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | — | Index array. Each value selects which array in choices to take the corresponding element from. |
choices | ArrayLike[] | — | List of arrays to choose from. All must be broadcastable to the same shape. |
NDArray — Array formed by picking elements from choices according to a.
compress
Return selected slices of an array along a given axis.| Name | Type | Default | Description |
|---|---|---|---|
condition | ArrayLike | — | Boolean array selecting which entries to keep. Its length must match the size of a along the given axis. |
a | ArrayLike | — | Array from which to extract. |
axis | number | undefined | Axis along which to operate. When undefined, the array is flattened first. |
NDArray — Array containing only the slices of a where condition is true.
select
Return an array drawn from elements inchoicelist depending on conditions.
| Name | Type | Default | Description |
|---|---|---|---|
condlist | ArrayLike[] | — | List of boolean arrays. The first condition that is true determines which choice is used. |
choicelist | ArrayLike[] | — | List of arrays from which output elements are taken. Must be the same length as condlist. |
defaultVal | number | 0 | Value used when no condition is satisfied. |
NDArray — Array where element i is taken from choicelist[j][i] for the first j where condlist[j][i] is true, or default_ if no condition is true.
place
Change elements of an array based on a boolean mask and replacement values.| Name | Type | Default | Description |
|---|---|---|---|
a | NDArray | — | Array to modify in-place. |
mask | ArrayLike | — | Boolean mask. Must be broadcastable to a. |
vals | ArrayLike | — | Values to place into a where mask is true. Cycled if shorter than the number of true values. |
void — The array arr is modified in-place.
putmask
Change elements of an array based on a boolean mask.| Name | Type | Default | Description |
|---|---|---|---|
a | NDArray | — | Target array. Modified in-place. |
mask | ArrayLike | — | Boolean mask. Where true, a is replaced by the corresponding element from values. |
values | ArrayLike | — | Replacement values. Cycled if shorter than the number of true entries in mask. |
void — The array a is modified in-place.
take_along_axis
Take values from an array by matching indices along an axis.| Name | Type | Default | Description |
|---|---|---|---|
arr | ArrayLike | — | Source array. |
indices | ArrayLike | — | Indices to take along each slice of arr. Must have the same number of dimensions as arr. |
axis | number | — | The axis to take along. |
NDArray — Array of values gathered from arr at the given indices along axis.
put_along_axis
Put values into an array by matching indices along an axis.| Name | Type | Default | Description |
|---|---|---|---|
arr | NDArray | — | Destination array. Modified in-place. |
indices | ArrayLike | — | Indices along axis where values are placed. |
values | ArrayLike | — | Values to insert. Must be broadcastable to indices. |
axis | number | — | The axis along which to put values. |
void — The array arr is modified in-place.
copyto
Copy values from one array to another.| Name | Type | Default | Description |
|---|---|---|---|
dst | NDArray | — | Destination array. Modified in-place. |
src | ArrayLike | number | bigint | — | Source array or scalar. Must be broadcastable to dst. |
void — The array dst is modified in-place.
broadcast_to
Broadcast an array to a new shape without copying data.| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | — | The array to broadcast. |
shape | number[] | — | Target shape. Must be compatible with the input shape under NumPy broadcasting rules. |
NDArray — A read-only view of the original array with the given shape.
broadcast_arrays
Broadcast any number of arrays against each other.| Name | Type | Default | Description |
|---|---|---|---|
...arrays | ArrayLike[] | — | Arrays to broadcast. |
NDArray[] — List of arrays with the same shape, broadcast from the inputs.
broadcast_shapes
Compute the shape resulting from broadcasting the given shapes together.| Name | Type | Default | Description |
|---|---|---|---|
...shapes | number[][] | — | Array shapes to broadcast together. |
number[] — The broadcast shape.
Throws: Error if the shapes are not compatible for broadcasting.