apply_along_axis
Apply a function to 1-D slices of an array along the given axis. The function is called once for each slice, and the results are assembled into an output array. Supports arrays of any dimensionality. For ND arrays, the function iterates over all combinations of indices on dimensions other thanaxis.
| Parameter | Type | Default | Description |
|---|---|---|---|
func1d | (arr: NDArray) => number | NDArray | — | Function that operates on a 1-D array and returns a scalar or 1-D array. |
axis | number | — | Axis along which to apply func1d. |
arr | ArrayLike | — | Input array. |
NDArray — The result of applying func1d along the specified axis.
apply_over_axes
Apply a function repeatedly over multiple axes. After each application, the result is kept with the reduced axis preserved as a size-1 dimension, so subsequent axes remain valid.| Parameter | Type | Default | Description |
|---|---|---|---|
func | (a: NDArray, axis: number) => NDArray | — | Function that takes an array and an axis, returning an array with that axis reduced to size 1. |
a | ArrayLike | — | Input array. |
axes | number[] | — | Axes over which to apply func, in order. |
NDArray — The result of applying func over all specified axes.
shares_memory
Determine whether two arrays share the same underlying data buffer. Returnstrue only when the arrays definitely reference overlapping memory.
| Parameter | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | — | First input array. |
b | ArrayLike | — | Second input array. |
boolean — true if both arrays share memory.
may_share_memory
Determine whether two arrays might share memory. This is a less strict check thanshares_memory — it may return true even when the arrays do not actually overlap, but it never returns false when they do.
| Parameter | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | — | First input array. |
b | ArrayLike | — | Second input array. |
boolean — true if the arrays might share memory.
ndim
Return the number of dimensions of an array.| Parameter | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | — | Input array or array-like. |
number — The number of dimensions (axes).
shape
Return the shape of an array as a number array.| Parameter | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | — | Input array or array-like. |
number[] — The dimensions of the array.
size
Return the total number of elements in an array.| Parameter | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | — | Input array or array-like. |
number — The total number of elements (product of shape dimensions).
geterr
Get the current error handling settings for floating-point operations.object — An object with keys divide, over, under, and invalid, each set to one of 'warn', 'raise', 'ignore', or 'print'.
seterr
Set how floating-point errors are handled. Returns the previous settings so you can restore them later.| Parameter | Type | Default | Description |
|---|---|---|---|
all | ErrorMode | undefined | Default mode applied to all error categories unless overridden by specific args. |
divide | ErrorMode | undefined | Division-by-zero handling mode. |
over | ErrorMode | undefined | Overflow handling mode. |
under | ErrorMode | undefined | Underflow handling mode. |
invalid | ErrorMode | undefined | Invalid operation handling mode. |
FloatErrorState — The previous error handling settings.