zeros
Create an array filled with zeros.| Name | Type | Default | Description |
|---|---|---|---|
shape | number[] | - | Shape of the new array, e.g. [2, 3]. |
dtype | DType | 'float64' | Desired data type. |
NDArray — Array of zeros with the given shape.
ones
Create an array filled with ones.| Name | Type | Default | Description |
|---|---|---|---|
shape | number[] | - | Shape of the new array. |
dtype | DType | 'float64' | Desired data type. |
NDArray — Array of ones with the given shape.
empty
Create an uninitialized array. In JavaScript, this is equivalent tozeros since typed arrays are zero-initialized.
| Name | Type | Default | Description |
|---|---|---|---|
shape | number[] | - | Shape of the new array. |
dtype | DType | 'float64' | Desired data type. |
NDArray — Uninitialized array (zero-filled in practice).
full
Create an array filled with a constant value.| Name | Type | Default | Description |
|---|---|---|---|
shape | number[] | - | Shape of the new array. |
fill_value | number | bigint | boolean | - | Value to fill the array with. |
dtype | DType | inferred | Data type. Inferred from fill_value if omitted (int32 for integers, float64 for floats, bool for booleans, int64 for bigints). |
NDArray — Array filled with fill_value.
array
Create an array from nested JavaScript arrays, typed arrays, or existing arrays.| Name | Type | Default | Description |
|---|---|---|---|
data | NestedArray | TypedArray | - | Input data. Can be a nested JS array, a TypedArray, or an existing NDArray. |
dtype | DType | inferred | Data type. Inferred from data if omitted. |
NDArray — An ndarray constructed from the input data.
asarray
Convert the input to an array. If the input is already anNDArray with the correct dtype, it is returned without copying.
| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | - | Input data, in any form that can be converted to an array. |
dtype | DType | inferred | Data type. If specified and differs from the input, a cast is performed. |
NDArray — Array interpretation of a. No copy is made if a is already an ndarray of the matching dtype.
asanyarray
Convert input to an array, passing through subclasses. Behaves identically toasarray in numpy-ts.
| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | - | Input data. |
dtype | DType | inferred | Desired data type. |
NDArray — Array interpretation of a.
asarray_chkfinite
Convert input to an array, raising an error if the input containsInf or NaN.
| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | - | Input data. |
dtype | DType | inferred | Desired data type. |
NDArray — Array interpretation of a.
Throws: Error if the array contains Inf or NaN.
ascontiguousarray
Return a contiguous array (C order) in memory. In numpy-ts, this always returns a copy.| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | - | Input data. |
dtype | DType | inferred | Desired data type. |
NDArray — Contiguous array with C-order memory layout.
asfortranarray
Return an array laid out in Fortran order in memory. In numpy-ts, this returns a C-order copy (Fortran order is not natively supported).| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | - | Input data. |
dtype | DType | inferred | Desired data type. |
NDArray — Array copy (C-order in practice).
require
Return an array that satisfies requirements. In numpy-ts, requirements like'C', 'F', 'A', 'W', 'O', 'E' are mostly no-ops.
| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | - | Input array. |
dtype | DType | undefined | Desired data type. A cast is performed if needed. |
_requirements | string | string[] | undefined | Memory layout requirements (e.g., ['C']). Mostly no-ops in numpy-ts. |
NDArray — Array satisfying the given requirements.
copy
Return a deep copy of an array.| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | - | Input array to copy. |
NDArray — A copy of the input array. Modifications to the copy do not affect the original.
zeros_like
Return an array of zeros with the same shape and dtype as a given array.| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | - | Reference array. |
dtype | DType | a.dtype | Override data type. |
NDArray — Array of zeros matching the shape (and optionally dtype) of a.
ones_like
Return an array of ones with the same shape and dtype as a given array.| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | - | Reference array. |
dtype | DType | a.dtype | Override data type. |
NDArray — Array of ones matching the shape of a.
empty_like
Return an uninitialized array with the same shape and dtype as a given array.| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | - | Reference array. |
dtype | DType | a.dtype | Override data type. |
NDArray — Uninitialized array (zero-filled in practice) matching the shape of a.
full_like
Return a filled array with the same shape and dtype as a given array.| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | - | Reference array. |
fill_value | number | bigint | boolean | - | Fill value. |
dtype | DType | a.dtype | Override data type. |
NDArray — Array filled with fill_value, matching the shape of a.