Up to date

This page is up to date for NumDot v0.12. If you still find outdated information, please open an issue.

nd

Inherits: Object

Contains NumDot functions returning tensors.

Description

The base namespace for NumDot functions.

All mathematical functions in this namespace return tensors. For reduction results further used in scalar computation, consider using ndb, ndf and ndi instead.

Methods

NDArray

abs(a: Variant) static

NDArray

acos(a: Variant) static

NDArray

acosh(a: Variant) static

NDArray

add(a: Variant, b: Variant) static

NDArray

all(a: Variant, axes: Variant = null) static

NDArray

angle(v: Variant) static

NDArray

any(a: Variant, axes: Variant = null) static

NDArray

arange(start_or_stop: Variant, stop: Variant = null, step: Variant = 1, dtype: DType = 13) static

NDArray

argmax(a: Variant, axis: Variant = null) static

NDArray

argmin(a: Variant, axis: Variant = null) static

NDArray

array(array: Variant, dtype: DType = 13) static

NDArray

as_array(array: Variant, dtype: DType = 13) static

NDArray

asin(a: Variant) static

NDArray

asinh(a: Variant) static

NDArray

atan(a: Variant) static

NDArray

atan2(x1: Variant, x2: Variant) static

NDArray

atanh(a: Variant) static

StringName

axis_all() static

NDArray

bitwise_and(a: Variant, b: Variant) static

NDArray

bitwise_left_shift(a: Variant, b: Variant) static

NDArray

bitwise_not(a: Variant) static

NDArray

bitwise_or(a: Variant, b: Variant) static

NDArray

bitwise_right_shift(a: Variant, b: Variant) static

NDArray

bitwise_xor(a: Variant, b: Variant) static

NDArray

bool_(array: Variant) static

NDArray

broadcast_to(v: Variant, shape: Variant) static

NDArray

ceil(a: Variant) static

NDArray

clip(a: Variant, min: Variant, max: Variant) static

NDArray

complex64(array: Variant) static

NDArray

complex128(array: Variant) static

NDArray

complex_as_vector(v: Variant) static

NDArray

concatenate(v: Variant, axis: Variant = 0, dtype: DType = 13) static

NDArray

conjugate(v: Variant) static

NDArray

convolve(array: Variant, kernel: Variant) static

NDArray

copy(array: Variant) static

NDArray

copysign(a: Variant, b: Variant) static

NDArray

cos(a: Variant) static

NDArray

cosh(a: Variant) static

NDArray

count_nonzero(a: Variant, axes: Variant = null) static

NDArray

cross(a: Variant, b: Variant, axisa: int = -1, axisb: int = -1, axisc: int = -1) static

NDArray

cumprod(a: Variant, axis: Variant = null) static

NDArray

cumsum(a: Variant, axis: Variant = null) static

NDRandomGenerator

default_rng(seed: Variant = null) static

NDArray

deg2rad(a: Variant) static

NDArray

diag(v: Variant, offset: int = 0) static

NDArray

diagonal(v: Variant, offset: int = 0, axis1: int = 0, axis2: int = 1) static

NDArray

diff(a: Variant, n: int = 1, axis: int = -1) static

NDArray

divide(a: Variant, b: Variant) static

NDArray

dot(a: Variant, b: Variant) static

PackedByteArray

dumpb(array: Variant) static

float

e() static

StringName

ellipsis() static

NDArray

empty(shape: Variant, dtype: DType = 2) static

NDArray

empty_like(model: Variant, dtype: DType = 13, shape: Variant = null) static

NDArray

equal(a: Variant, b: Variant) static

float

euler_gamma() static

NDArray

exp(a: Variant) static

NDArray

expand_dims(v: Variant, axis: int) static

NDArray

expm1(a: Variant) static

NDArray

eye(shape: Variant, k: int = 0, dtype: DType = 2) static

NDArray

fft(v: Variant, axis: int = -1) static

NDArray

fft_freq(n: int, d: float = 1) static

NDArray

flip(v: Variant, axis: int) static

NDArray

float32(array: Variant) static

NDArray

float64(array: Variant) static

NDArray

floor(a: Variant) static

NDArray

floor_divide(a: Variant, b: Variant) static

Vector4i

from(start: int) static

NDArray

full(shape: Variant, fill_value: Variant, dtype: DType = 2) static

NDArray

full_like(model: Variant, fill_value: Variant, dtype: DType = 13, shape: Variant = null) static

NDArray

greater(a: Variant, b: Variant) static

NDArray

greater_equal(a: Variant, b: Variant) static

Array[NDArray]

hsplit(v: Variant, indices_or_sections: Variant) static

NDArray

hstack(v: Variant, dtype: DType = 13) static

NDArray

hypot(a: Variant, b: Variant) static

NDArray

imag(v: Variant) static

float

inf() static

NDArray

inner(a: Variant, b: Variant) static

NDArray

int8(array: Variant) static

NDArray

int16(array: Variant) static

NDArray

int32(array: Variant) static

NDArray

int64(array: Variant) static

NDArray

is_close(a: Variant, b: Variant, rtol: float = 1e-05, atol: float = 1e-08, equal_nan: bool = false) static

NDArray

is_finite(a: Variant) static

NDArray

is_inf(a: Variant) static

NDArray

is_nan(a: Variant) static

NDArray

less(a: Variant, b: Variant) static

NDArray

less_equal(a: Variant, b: Variant) static

NDArray

linspace(start: Variant, stop: Variant, num: int = 50, endpoint: bool = true, dtype: DType = 13) static

NDArray

load(file_or_buffer: Variant) static

NDArray

log(a: Variant) static

NDArray

log1p(a: Variant) static

NDArray

log2(a: Variant) static

NDArray

log10(a: Variant) static

NDArray

logaddexp(a: Variant, b: Variant) static

NDArray

logical_and(a: Variant, b: Variant) static

NDArray

logical_not(a: Variant) static

NDArray

logical_or(a: Variant, b: Variant) static

NDArray

logical_xor(a: Variant, b: Variant) static

NDArray

matmul(a: Variant, b: Variant) static

NDArray

max(a: Variant, axes: Variant = null) static

NDArray

maximum(a: Variant, b: Variant) static

NDArray

mean(a: Variant, axes: Variant = null) static

NDArray

median(a: Variant, axes: Variant = null) static

Array[NDArray]

meshgrid(arrays: Variant, indexing: StringName = &"xy") static

NDArray

min(a: Variant, axes: Variant = null) static

NDArray

minimum(a: Variant, b: Variant) static

NDArray

moveaxis(v: Variant, src: Variant, dst: Variant) static

NDArray

multiply(a: Variant, b: Variant) static

float

nan() static

NDArray

negative(a: Variant) static

StringName

newaxis() static

Array[NDArray]

nonzero(a: Variant) static

NDArray

norm(a: Variant, ord: Variant = 2, axes: Variant = null) static

NDArray

not_equal(a: Variant, b: Variant) static

NDArray

ones(shape: Variant, dtype: DType = 2) static

NDArray

ones_like(model: Variant, dtype: DType = 13, shape: Variant = null) static

NDArray

outer(a: Variant, b: Variant) static

NDArray

pad(v: Variant, pad_width: Variant, pad_mode: PadMode = 0, pad_value: Variant = 0) static

float

pi() static

NDArray

positive(a: Variant) static

NDArray

pow(a: Variant, b: Variant) static

NDArray

prod(a: Variant, axes: Variant = null) static

NDArray

rad2deg(a: Variant) static

Vector4i

range(start_or_stop: Variant, stop: Variant = &"no_value", step: Variant = null) static

NDArray

real(v: Variant) static

NDArray

remainder(a: Variant, b: Variant) static

NDArray

repeat(v: Variant, repeats: Variant, axis: Variant = null) static

NDArray

reshape(a: Variant, shape: Variant) static

NDArray

rint(a: Variant) static

NDArray

roll(v: Variant, shift: Variant, axis: Variant = null) static

NDArray

round(a: Variant) static

NDArray

sign(a: Variant) static

NDArray

signbit(a: Variant) static

NDArray

sin(a: Variant) static

NDArray

sinh(a: Variant) static

int

size_of_dtype_in_bytes(dtype: DType) static

NDArray

sliding_window_view(array: Variant, window_shape: Variant) static

Array[NDArray]

split(v: Variant, indices_or_sections: Variant, axis: int = 0) static

NDArray

sqrt(a: Variant) static

NDArray

square(a: Variant) static

NDArray

squeeze(v: Variant, axes: Variant = null) static

NDArray

stack(v: Variant, axis: int = 0) static

NDArray

std(a: Variant, axes: Variant = null) static

NDArray

subtract(a: Variant, b: Variant) static

NDArray

sum(a: Variant, axes: Variant = null) static

NDArray

sum_product(a: Variant, b: Variant, axes: Variant = null) static

NDArray

swapaxes(v: Variant, a: int, b: int) static

NDArray

tan(a: Variant) static

NDArray

tanh(a: Variant) static

NDArray

tile(v: Variant, reps: Variant, inner: bool = false) static

Vector4i

to(stop: int) static

NDArray

trace(v: Variant, offset: int = 0, axis1: int = 0, axis2: int = 1) static

NDArray

transpose(a: Variant, permutation: Variant = null) static

NDArray

trunc(a: Variant) static

NDArray

uint8(array: Variant) static

NDArray

uint16(array: Variant) static

NDArray

uint32(array: Variant) static

NDArray

uint64(array: Variant) static

NDArray

unstack(v: Variant, axis: int = 0) static

NDArray

var(a: Variant, axes: Variant = null) static

NDArray

vector_as_complex(v: Variant, keepdims: bool = false, dtype: DType = 13) static

Array[NDArray]

vsplit(v: Variant, indices_or_sections: Variant) static

NDArray

vstack(v: Variant, dtype: DType = 13) static

NDArray

where(condition: Variant, x: Variant, y: Variant) static

NDArray

zeros(shape: Variant, dtype: DType = 2) static

NDArray

zeros_like(model: Variant, dtype: DType = 13, shape: Variant = null) static


Enumerations

enum DType: 🔗

DType Bool = 0

Boolean type (true or false), stored as a byte.

DType Float32 = 1

Single-precision (32 bit) floating-point number type.

DType Float64 = 2

Double-precision (64 bit) floating-point number type.

DType Complex64 = 3

Complex number type composed of two single-precision floating-point numbers.

DType Complex128 = 4

Complex number type composed of two double-precision floating-point numbers.

DType Int8 = 5

Signed integer type with 8 bits.

DType Int16 = 6

Signed integer type with 16 bits.

DType Int32 = 7

Signed integer type with 32 bits.

DType Int64 = 8

Signed integer type with 64 bits.

DType UInt8 = 9

Unsigned integer type with 8 bits. This dtype cannot express negative values.

DType UInt16 = 10

Unsigned integer type with 16 bits. This dtype cannot express negative values.

DType UInt32 = 11

Unsigned integer type with 32 bits. This dtype cannot express negative values.

DType UInt64 = 12

Unsigned integer type with 64 bits. This dtype cannot express negative values.

DType DTypeMax = 13

There is currently no description for this enum. Please help us by contributing one!


enum PadMode: 🔗

PadMode Constant = 0

Pads with a constant value, given by pad_value.

PadMode Symmetric = 1

Pads with the reflection of the vector mirrored along the edge of the array.

PadMode Reflect = 2

Pads with the reflection of the vector mirrored on the first and last values of the vector along each axis.

PadMode Wrap = 3

Pads with the wrap of the vector along the axis. The first values are used to pad the end and the end values are used to pad the beginning.

PadMode Edge = 4

Pads with the edge values of array.


Method Descriptions

NDArray abs(a: Variant) static 🔗

Calculate the absolute value element-wise.


NDArray acos(a: Variant) static 🔗

Trigonometric inverse cosine, element-wise.

The inverse of cos so that, if y = cos(x), then x = arccos(y).


NDArray acosh(a: Variant) static 🔗

Inverse hyperbolic cosine, element-wise.


NDArray add(a: Variant, b: Variant) static 🔗

Add arguments element-wise.


NDArray all(a: Variant, axes: Variant = null) static 🔗

Test whether all array elements along a given axis evaluate to True.

Returns a 0-dimension boolean if axes is null. In that case, ndb.all() is preferred.


NDArray angle(v: Variant) static 🔗

Return the angle of the complex argument.

This is equivalent to nd.atan2(nd.imag(x), nd.real(x)).


NDArray any(a: Variant, axes: Variant = null) static 🔗

Test whether any array element along a given axis evaluates to True.

Returns a 0-dimension boolean if axes is null. In that case, ndb.any() is preferred.


NDArray arange(start_or_stop: Variant, stop: Variant = null, step: Variant = 1, dtype: DType = 13) static 🔗

Return evenly spaced values within a given interval.


NDArray argmax(a: Variant, axis: Variant = null) static 🔗

Index of the maximum value along axis, as int64. With axis null, the input is flattened and a 0-D scalar index into the flat data is returned. Errors on complex dtypes (no total order).


NDArray argmin(a: Variant, axis: Variant = null) static 🔗

Index of the minimum value along axis, as int64. With axis null, the input is flattened and a 0-D scalar index into the flat data is returned. Errors on complex dtypes (no total order).


NDArray array(array: Variant, dtype: DType = 13) static 🔗

Create a new NDArray of the given DType from the given data.

If the input is an NDArray, it will be copied.


NDArray as_array(array: Variant, dtype: DType = 13) static 🔗

Convert the input to an array, but avoid copying data if possible.


NDArray asin(a: Variant) static 🔗

Inverse sine, element-wise.

The inverse of sine, so that if y = sin(x) then x = arcsin(y).


NDArray asinh(a: Variant) static 🔗

Inverse hyperbolic sine element-wise.


NDArray atan(a: Variant) static 🔗

Trigonometric inverse tangent, element-wise.

The inverse of tan, so that if y = tan(x) then x = arctan(y).


NDArray atan2(x1: Variant, x2: Variant) static 🔗

Element-wise arc tangent of x1/x2 choosing the quadrant correctly.

The quadrant (i.e., branch) is chosen so that arctan2(x1, x2) is the signed angle in radians between the ray ending at the origin and passing through the point (1,0), and the ray ending at the origin and passing through the point (x2, x1). (Note the role reversal: the “y-coordinate” is the first function parameter, the “x-coordinate” is the second.) By IEEE convention, this function is defined for x2 = +/-0 and for either or both of x1 and x2 = +/-inf.


NDArray atanh(a: Variant) static 🔗

Inverse hyperbolic tangent element-wise.


StringName axis_all() static 🔗

There is currently no description for this method. Please help us by contributing one!


NDArray bitwise_and(a: Variant, b: Variant) static 🔗

Compute the bit-wise AND of two arrays element-wise.


NDArray bitwise_left_shift(a: Variant, b: Variant) static 🔗

Shift the bits of an integer to the left.


NDArray bitwise_not(a: Variant) static 🔗

Compute bit-wise inversion, or bit-wise NOT, element-wise.


NDArray bitwise_or(a: Variant, b: Variant) static 🔗

Compute the bit-wise OR of two arrays element-wise.


NDArray bitwise_right_shift(a: Variant, b: Variant) static 🔗

Shift the bits of an integer to the right.


NDArray bitwise_xor(a: Variant, b: Variant) static 🔗

Compute the bit-wise XOR of two arrays element-wise.


NDArray bool_(array: Variant) static 🔗

Convert to a bool dtype tensor.

Equivalent to nd.as_array(array, nd.DType.Bool).


NDArray broadcast_to(v: Variant, shape: Variant) static 🔗

Return a view of v stretched to shape. Front-padded axes and any input axes of length 1 are broadcast (zero-stride); the rest must match the target dimension or the call errors. The result shares memory with v — writing through it is not supported.


NDArray ceil(a: Variant) static 🔗

Return the ceiling of the input, element-wise.

The ceil of the scalar x is the smallest integer i, such that i >= x.


NDArray clip(a: Variant, min: Variant, max: Variant) static 🔗

Clip (limit) the values in an array.

Given an interval, values outside the interval are clipped to the interval edges. For example, if an interval of [0, 1] is specified, values smaller than 0 become 0, and values larger than 1 become 1.

Equivalent to but faster than nd.minimum(a_max, nd.maximum(a, a_min)).

No check is performed to ensure a_min < a_max.


NDArray complex64(array: Variant) static 🔗

Convert to a complex64 dtype tensor.

Equivalent to nd.as_array(array, nd.DType.Complex64).


NDArray complex128(array: Variant) static 🔗

Convert to a complex128 dtype tensor.

Equivalent to nd.as_array(array, nd.DType.Complex128).


NDArray complex_as_vector(v: Variant) static 🔗

Reinterprets elements in a complex-typed array as a 2-D vector.

The new dimension is added in the back.


NDArray concatenate(v: Variant, axis: Variant = 0, dtype: DType = 13) static 🔗

Join a sequence of arrays along an existing axis.

The arrays must match in dimension except in the axis.


NDArray conjugate(v: Variant) static 🔗

Return the complex conjugate, element-wise.

The complex conjugate of a complex number is obtained by changing the sign of its imaginary part.


NDArray convolve(array: Variant, kernel: Variant) static 🔗

Convolve two N-dimensional arrays. They are broadcasted against each other in the inner dimensions.

Currently, kernel must be smaller than array in all dimensions.


NDArray copy(array: Variant) static 🔗

Creates a copy of the given array.


NDArray copysign(a: Variant, b: Variant) static 🔗

Element-wise composition of |a| with the sign of b. Real dtypes only.


NDArray cos(a: Variant) static 🔗

Cosine element-wise.


NDArray cosh(a: Variant) static 🔗

Hyperbolic cosine, element-wise.

Equivalent to 0.5 * (nd.exp(x) + nd.exp(-x)).


NDArray count_nonzero(a: Variant, axes: Variant = null) static 🔗

Counts the number of non-zero values in the array a along the given axes.

Returns a 0-dimension scalar if axes is null. In that case, consider ndi.count_nonzero().


NDArray cross(a: Variant, b: Variant, axisa: int = -1, axisb: int = -1, axisc: int = -1) static 🔗

Return the cross product of two (arrays of) vectors.

The cross product of a and b in R3 is a vector perpendicular to both a and b. If a and b are arrays of vectors, the vectors are defined by the last axis of a and b by default, and these axes can have dimensions 2 or 3. Where the dimension of either a or b is 2, the third component of the input vector is assumed to be zero and the cross product calculated accordingly. In cases where both input vectors have dimension 2, the z-component of the cross product is returned.


NDArray cumprod(a: Variant, axis: Variant = null) static 🔗

Cumulative product of array elements along the given axis. The output preserves the input shape; element i along axis holds the product of all elements at positions 0..i.

If axis is null the input is flattened first and a 1-D result is returned.

Like prod(), the accumulator is widened to int64 / uint64 for narrow integer dtypes to avoid mid-pass overflow.


NDArray cumsum(a: Variant, axis: Variant = null) static 🔗

Cumulative sum of array elements along the given axis. The output preserves the input shape; element i along axis holds the sum of all elements at positions 0..i.

If axis is null the input is flattened first and a 1-D result is returned.

Like sum(), the accumulator is widened to int64 / uint64 for narrow integer dtypes to avoid mid-pass overflow.


NDRandomGenerator default_rng(seed: Variant = null) static 🔗

Creates a new random number generator (rng) with the default random engine (mt19937).

If no seed is provided, a fresh, unpredictable entropy will be pulled from the OS.


NDArray deg2rad(a: Variant) static 🔗

Convert angles from degrees to radians.


NDArray diag(v: Variant, offset: int = 0) static 🔗

This function does one of two things, depending on the dimension of the input array:

1-D: Constructs a square matrix from a k-th diagonal, with all other positions being 0.

2-D: Returns a view of the k-th diagonal, like diagonal().


NDArray diagonal(v: Variant, offset: int = 0, axis1: int = 0, axis2: int = 1) static 🔗

Return specified matrix diagonals. This is a view of the given array.

If the array has more than 2 dimensions, the given dimensions are removed, and the new dimension is inserted as the new last (innermost) dimension.


NDArray diff(a: Variant, n: int = 1, axis: int = -1) static 🔗

The n-th discrete difference of a along axis. Each pass replaces neighbours with their difference (out[i] = a[i+1] - a[i]); this repeats n times.

The output shape matches the input except along axis, where it shrinks by n. If n is larger than the axis length, the output is empty along that axis.

axis is a single dimension and may be negative to count from the end.


NDArray divide(a: Variant, b: Variant) static 🔗

Divide arguments element-wise.


NDArray dot(a: Variant, b: Variant) static 🔗

Dot product of two arrays. Specifically,

If either a or b is 0-D (scalar), it is equivalent to multiply, but using multiply() or a * b is preferred.

If both a and b are 2-D or less, but not 0-D, it is equal to matmul(), and using it is preferred.

Otherwise, it would be equivalent to tensordot, but currently fails.


PackedByteArray dumpb(array: Variant) static 🔗

Save an array to a buffer in NumPy .npy format.

See load() to load an array in the same format.


float e() static 🔗

Euler’s constant, base of natural logarithms, Napier’s constant.


StringName ellipsis() static 🔗

An alias for the StringName &"...". In a subscript, this will stand in for omitted dimensions, for example if you want to index the last dimension.


NDArray empty(shape: Variant, dtype: DType = 2) static 🔗

Return a new array of given shape and type, without initializing entries.


NDArray empty_like(model: Variant, dtype: DType = 13, shape: Variant = null) static 🔗

Return a new array with the same shape and type as a given array.

DType and shape will, if supplied, override the values inferred from the given array.


NDArray equal(a: Variant, b: Variant) static 🔗

Return (x1 == x2) element-wise.


float euler_gamma() static 🔗

Euler-Mascheroni constant.


NDArray exp(a: Variant) static 🔗

Calculate the exponential of all elements in the input array.


NDArray expand_dims(v: Variant, axis: int) static 🔗

Insert a length-1 dimension at the given axis of v. Returns a view sharing the input's data — no copy.

axis may be negative to count from the end. The valid range is [-ndim - 1, ndim]; values outside that range error.


NDArray expm1(a: Variant) static 🔗

Element-wise exp(a) - 1, computed accurately for |a| near zero.


NDArray eye(shape: Variant, k: int = 0, dtype: DType = 2) static 🔗

Return a tensor with ones on the diagonal, and 0 elsewhere. The shape depends on the first parameter:

If an int N is given, an NxN matrix is returned.

Otherwise, the first parameter is interpreted as a shape.

k is the index of the diagonal: 0 (the default) refers to the main diagonal, a positive value refers to an upper diagonal, and a negative value to a lower diagonal.


NDArray fft(v: Variant, axis: int = -1) static 🔗

Compute the one-dimensional discrete Fourier Transform.


NDArray fft_freq(n: int, d: float = 1) static 🔗

Return the Discrete Fourier Transform sample frequencies.

The returned float array f contains the frequency bin centers in cycles per unit of the sample spacing (with zero at the start). For instance, if the sample spacing is in seconds, then the frequency unit is cycles/second.

Given a window length n and a sample spacing d:

f = [0, 1, ...,   n/2-1,     -n/2, ..., -1] / (d*n)   if n is even

f = [0, 1, ..., (n-1)/2, -(n-1)/2, ..., -1] / (d*n)   if n is odd


NDArray flip(v: Variant, axis: int) static 🔗

Reverse the order of elements in an array along the given axis.

The shape of the array is preserved, but the elements are reordered.


NDArray float32(array: Variant) static 🔗

Convert to a float32 dtype tensor.

Equivalent to nd.as_array(array, nd.DType.Float32).


NDArray float64(array: Variant) static 🔗

Convert to a float64 dtype tensor.

Equivalent to nd.as_array(array, nd.DType.Float64).


NDArray floor(a: Variant) static 🔗

Return the floor of the input, element-wise.

The floor of the scalar x is the largest integer i, such that i <= x.


NDArray floor_divide(a: Variant, b: Variant) static 🔗

Element-wise floor of a / b — Python-style "//" rounding toward -infinity, including for integer inputs (so nd.floor_divide(-7, 2) == -4, not -3). Real dtypes only.


Vector4i from(start: int) static 🔗

Create a range that starts at the given index.


NDArray full(shape: Variant, fill_value: Variant, dtype: DType = 2) static 🔗

Return a new array of given shape and type, filled with fill_value.


NDArray full_like(model: Variant, fill_value: Variant, dtype: DType = 13, shape: Variant = null) static 🔗

Return a new array with the same shape and type as a given array, filled with the given value.

DType and shape will, if supplied, override the values inferred from the given array.


NDArray greater(a: Variant, b: Variant) static 🔗

Return (x1 > x2) element-wise.


NDArray greater_equal(a: Variant, b: Variant) static 🔗

Return (x1 >= x2) element-wise.


Array[NDArray] hsplit(v: Variant, indices_or_sections: Variant) static 🔗

Split an array into multiple sub-arrays horizontally (column-wise).

Please refer to split(). hsplit is equivalent to split() with axis=1, the array is always split along the second axis except for 1-D arrays, where it is split at axis=0.


NDArray hstack(v: Variant, dtype: DType = 13) static 🔗

Stack arrays in sequence horizontally (column wise).

This is equivalent to concatenation along the second axis, except for 1-D arrays where it concatenates along the first axis. Rebuilds arrays divided by hsplit.

This function makes most sense for arrays with up to 3 dimensions. For instance, for pixel-data with a height (first axis), width (second axis), and r/g/b channels (third axis). The functions concatenate, stack and block provide more general stacking and concatenation operations.


NDArray hypot(a: Variant, b: Variant) static 🔗

Element-wise sqrt(a * a + b * b), computed without intermediate overflow.


NDArray imag(v: Variant) static 🔗

Return the imaginary part of the complex argument.

If the argument is not complex, returns a non-writeable array.


float inf() static 🔗

IEEE 754 floating point representation of (positive) infinity.


NDArray inner(a: Variant, b: Variant) static 🔗

Inner product of two arrays.

Ordinary inner product of vectors for 1-D arrays (without complex conjugation), in higher dimensions a sum product over the last axes.


NDArray int8(array: Variant) static 🔗

Convert to an int8 dtype tensor.

Equivalent to nd.as_array(array, nd.DType.Int8).


NDArray int16(array: Variant) static 🔗

Convert to an int16 dtype tensor.

Equivalent to nd.as_array(array, nd.DType.Int16).


NDArray int32(array: Variant) static 🔗

Convert to an int32 dtype tensor.

Equivalent to nd.as_array(array, nd.DType.Int32).


NDArray int64(array: Variant) static 🔗

Convert to an int64 dtype tensor.

Equivalent to nd.as_array(array, nd.DType.Int64).


NDArray is_close(a: Variant, b: Variant, rtol: float = 1e-05, atol: float = 1e-08, equal_nan: bool = false) static 🔗

Returns a boolean array where two arrays are element-wise equal within a tolerance.

The tolerance values are positive, typically very small numbers. The relative difference (rtol * abs(b)) and the absolute difference atol are added together to compare against the absolute difference between a and b.


NDArray is_finite(a: Variant) static 🔗

Test element-wise for finiteness (not infinity and not Not a Number).

The result is returned as a boolean array.


NDArray is_inf(a: Variant) static 🔗

Test element-wise for positive or negative infinity.

Returns a boolean array of the same shape as x, True where x == +/-inf, otherwise False.


NDArray is_nan(a: Variant) static 🔗

Test element-wise for NaN and return result as a boolean array.


NDArray less(a: Variant, b: Variant) static 🔗

Return (x1 < x2) element-wise.


NDArray less_equal(a: Variant, b: Variant) static 🔗

Return (x1 <= x2) element-wise.


NDArray linspace(start: Variant, stop: Variant, num: int = 50, endpoint: bool = true, dtype: DType = 13) static 🔗

Return evenly spaced numbers over a specified interval.

Returns num evenly spaced samples, calculated over the interval [start, stop].

The endpoint of the interval can optionally be excluded.


NDArray load(file_or_buffer: Variant) static 🔗

Load arrays in npy format.

Supports FileAccess, PackedByteArray and String path parameters.

See dumpb() to write an array to the same format.


NDArray log(a: Variant) static 🔗

Natural logarithm, element-wise.

The natural logarithm log is the inverse of the exponential function, so that log(exp(x)) = x. The natural logarithm is logarithm in base e.


NDArray log1p(a: Variant) static 🔗

Element-wise log(1 + a), computed accurately for |a| near zero.


NDArray log2(a: Variant) static 🔗

Base-2 logarithm, element-wise.


NDArray log10(a: Variant) static 🔗

Base-10 logarithm, element-wise.


NDArray logaddexp(a: Variant, b: Variant) static 🔗

Element-wise log(exp(a) + exp(b)), computed without intermediate overflow. Real dtypes only.


NDArray logical_and(a: Variant, b: Variant) static 🔗

Compute the truth value of x1 AND x2 element-wise.


NDArray logical_not(a: Variant) static 🔗

Compute the truth value of NOT x element-wise.


NDArray logical_or(a: Variant, b: Variant) static 🔗

Compute the truth value of x1 OR x2 element-wise.


NDArray logical_xor(a: Variant, b: Variant) static 🔗

Compute the truth value of x1 XOR x2 element-wise.

Similar to not_equal(), but converts all arguments to boolean before computation.


NDArray matmul(a: Variant, b: Variant) static 🔗

Matrix multiplication of two arrays.

The behavior depends on the arguments in the following way:

If either of the arguments is 0-D, the operation fails.

If both arguments are 2-D they are multiplied like conventional matrices.

If the first argument is 1-D, it is promoted to a matrix by prepending a 1 to its dimensions. After matrix multiplication the prepended 1 is removed.

If the second argument is 1-D, it is promoted to a matrix by appending a 1 to its dimensions. After matrix multiplication the appended 1 is removed.

If either argument is N-D, N > 2, it is treated as a stack of matrices residing in the last two indexes and broadcast accordingly.


NDArray max(a: Variant, axes: Variant = null) static 🔗

Return the maximum of an array or maximum along an axis.

Returns a 0-dimension scalar if axes is null. In that case, consider ndf.max() or ndi.max().


NDArray maximum(a: Variant, b: Variant) static 🔗

Element-wise maximum of array elements.

Compare two arrays and return a new array containing the element-wise maxima. If one of the elements being compared is a NaN, then that element is returned. If both elements are NaNs then the first is returned. The latter distinction is important for complex NaNs, which are defined as at least one of the real or imaginary parts being a NaN. The net effect is that NaNs are propagated.


NDArray mean(a: Variant, axes: Variant = null) static 🔗

Compute the arithmetic mean along the specified axis.

Returns a 0-dimension scalar if axes is null. In that case, consider ndf.mean().


NDArray median(a: Variant, axes: Variant = null) static 🔗

Compute the median along the specified axis. The median is the middle value when you sort the values.

Returns a 0-dimension scalar if axes is null. In that case, consider ndf.median() or ndi.median().


Array[NDArray] meshgrid(arrays: Variant, indexing: StringName = &"xy") static 🔗

Build coordinate grids from a list of 1-D arrays. Returns an array of N arrays, one per input, each of the same shape, with input i varying along its own axis.

With the default &"xy" indexing the first two output axes are swapped (matching the image-coordinate convention numpy uses), so for inputs x (length Nx) and y (length Ny) the outputs have shape (Ny, Nx). With &"ij" indexing they have shape (Nx, Ny). For three or more inputs only the first two dims are affected by the indexing choice.


NDArray min(a: Variant, axes: Variant = null) static 🔗

Return the minimum of an array or minimum along an axis.

Returns a 0-dimension scalar if axes is null. In that case, consider ndf.min() or ndi.min().


NDArray minimum(a: Variant, b: Variant) static 🔗

Element-wise minimum of array elements.

Compare two arrays and return a new array containing the element-wise minima. If one of the elements being compared is a NaN, then that element is returned. If both elements are NaNs then the first is returned. The latter distinction is important for complex NaNs, which are defined as at least one of the real or imaginary parts being a NaN. The net effect is that NaNs are propagated.


NDArray moveaxis(v: Variant, src: Variant, dst: Variant) static 🔗

Move axes of an array to new positions. Other axes remain in their original order.

src and dst are each an int or a list of ints (same length); negatives count from the end.


NDArray multiply(a: Variant, b: Variant) static 🔗

Multiply arguments element-wise.


float nan() static 🔗

IEEE 754 floating point representation of Not a Number (NaN).


NDArray negative(a: Variant) static 🔗

Returns the negative value of the number.

For unsigned types, returns MAX - value.

For non-number types, generates an error.


StringName newaxis() static 🔗

An alias for the StringName &"newaxis". In a subscript, this will add a dimension of size one.


Array[NDArray] nonzero(a: Variant) static 🔗

Indices of elements that are non-zero. Returns an array of N int64 1-D arrays (one per dimension); together they index the non-zero elements of a. Errors on 0-D inputs.


NDArray norm(a: Variant, ord: Variant = 2, axes: Variant = null) static 🔗

Vector norm.

This function is able to return one of 4 different vector norms, depending on the value of the ord parameter (L0, L1, L2 and LInf).

Returns a 0-dimension scalar if axes is null. In that case, consider ndf.norm() or ndi.norm().


NDArray not_equal(a: Variant, b: Variant) static 🔗

Return (x1 != x2) element-wise.


NDArray ones(shape: Variant, dtype: DType = 2) static 🔗

Return a new array of given shape and type, filled with ones.


NDArray ones_like(model: Variant, dtype: DType = 13, shape: Variant = null) static 🔗

Return a new array of ones with the same shape and type as a given array.

DType and shape will, if supplied, override the values inferred from the given array.


NDArray outer(a: Variant, b: Variant) static 🔗

Compute the outer product of two vectors.

Both vectors are flattened before the operation.


NDArray pad(v: Variant, pad_width: Variant, pad_mode: PadMode = 0, pad_value: Variant = 0) static 🔗

Pad an array.

pad_width can be one of the following:

  1. number, shortcut for [number, number].

  2. [before, after], pads all axes equally.

  3. [[before_0, after_0], [before_1, after_1], ...], pads axes in order.


float pi() static 🔗

The PI constant, that is the ratio of a circle's circumference to its diameter.


NDArray positive(a: Variant) static 🔗

For number types, returns a copy of the array.

For non-number types, generates an error.


NDArray pow(a: Variant, b: Variant) static 🔗

First array elements raised to powers from second array, element-wise.


NDArray prod(a: Variant, axes: Variant = null) static 🔗

Return the product of array elements over a given axis.

Returns a 0-dimension scalar if axes is null. In that case, consider ndf.prod() or ndi.prod().


NDArray rad2deg(a: Variant) static 🔗

Convert angles from radians to degrees.


Vector4i range(start_or_stop: Variant, stop: Variant = &"no_value", step: Variant = null) static 🔗

Create a range. arange can be called with a varying number of positional arguments:

arange(stop): Values are generated within the half-open interval [0, stop) (in other words, the interval including start but excluding stop).

arange(start, stop): Values are generated within the half-open interval [start, stop).

arange(start, stop, step) Values are generated within the half-open interval [start, stop), with spacing between values given by step.

Note that ranges are represented as Vector4i(mask, start, stop, step).


NDArray real(v: Variant) static 🔗

Return the real part of the complex argument.

If the argument is not complex, returns the argument.


NDArray remainder(a: Variant, b: Variant) static 🔗

Returns the element-wise remainder of division.

Computes the remainder complementary to the floor_divide function. It is equivalent to the modulus operator x1 % x2 and has the same sign as the divisor x2.


NDArray repeat(v: Variant, repeats: Variant, axis: Variant = null) static 🔗

Repeat each element of v along axis. The output has the same shape as the input except along axis, whose length becomes the sum of the repeat counts.

If axis is null, the input is flattened first and the result is 1-D.

repeats is either an int (every element repeated that many times) or an array. A length-1 array is treated as the scalar; otherwise it must have the same length as the axis being repeated and assigns one count per element.


NDArray reshape(a: Variant, shape: Variant) static 🔗

Gives a new shape to an array without changing its data.

Up to one element in the new shape can be -1 to infer its size.


NDArray rint(a: Variant) static 🔗

Round elements of the array to the nearest integer.


NDArray roll(v: Variant, shift: Variant, axis: Variant = null) static 🔗

Cyclically shift elements of v along axis. Elements that fall off one end re-enter at the other.

If axis is null, the input is treated as a flat row-major sequence and shifted by shift (an int), then reshaped back to its original shape.

If axis is an int, shift is an int and elements are shifted along that single axis.

If both are arrays of the same length, each axis is shifted by the corresponding amount in sequence.

Negative shifts and shifts larger than the axis length are normalized.


NDArray round(a: Variant) static 🔗

Round elements of the array to the nearest integer.


NDArray sign(a: Variant) static 🔗

Returns an element-wise indication of the sign of a number.

The sign function returns -1 if x < 0, 0 if x==0, 1 if x > 0. nan is returned for nan inputs.


NDArray signbit(a: Variant) static 🔗

Element-wise test for whether the IEEE-754 sign bit is set. Returns true for negative finite values, -0.0, and -infinity. Real dtypes only.


NDArray sin(a: Variant) static 🔗

Trigonometric sine, element-wise.


NDArray sinh(a: Variant) static 🔗

Hyperbolic sine, element-wise.

Equivalent to 0.5 * (nd.exp(x) - nd.exp(-x)).


int size_of_dtype_in_bytes(dtype: DType) static 🔗

Size of a single element of an array using the dtype.


NDArray sliding_window_view(array: Variant, window_shape: Variant) static 🔗

Create a sliding window view into the array with the given window shape.

Also known as rolling or moving window, the window slides across all dimensions of the array and extracts subsets of the array at all window positions.


Array[NDArray] split(v: Variant, indices_or_sections: Variant, axis: int = 0) static 🔗

Split an array into multiple sub-arrays as views into v.

This can be regarded as the opposite of concatenate().

indices_or_sections must be either:

An integer N — the array is divided into N equal sub-arrays along axis. The axis length must be divisible by N.

A list of sorted indices marking where along axis the array is split.


NDArray sqrt(a: Variant) static 🔗

Return the non-negative square-root of an array, element-wise.


NDArray square(a: Variant) static 🔗

Return the element-wise square of the input.


NDArray squeeze(v: Variant, axes: Variant = null) static 🔗

Remove length-1 axes from v. If axes is null (default), drops every length-1 axis; otherwise drops only the listed axes (int or list of ints, negatives count from the end). Errors if any requested axis is not size 1.


NDArray stack(v: Variant, axis: int = 0) static 🔗

Join a sequence of arrays along a new axis.

The axis parameter specifies the index of the new axis in the dimensions of the result. For example, if axis=0 it will be the first dimension and if axis=-1 it will be the last dimension.

Equivalent to nd.moveaxis(nd.array(v), 0, axis).


NDArray std(a: Variant, axes: Variant = null) static 🔗

Compute the standard deviation along the specified axis.

Returns the standard deviation, a measure of the spread of a distribution, of the array elements. The standard deviation is computed for the flattened array by default, otherwise over the specified axis.

Returns a 0-dimension scalar if axes is null. In that case, consider ndf.std().


NDArray subtract(a: Variant, b: Variant) static 🔗

Subtract arguments, element-wise.


NDArray sum(a: Variant, axes: Variant = null) static 🔗

Sum of array elements over a given axis.

Returns a 0-dimension scalar if axes is null. In that case, consider ndf.sum() or ndi.sum().


NDArray sum_product(a: Variant, b: Variant, axes: Variant = null) static 🔗

Dot product of two arrays along the given axes.

Equivalent to nd.sum(nd.multiply(a, b), axes).

Returns a 0-dimension scalar if axes is null. In that case, consider ndf.sum_product() or ndi.sum_product().


NDArray swapaxes(v: Variant, a: int, b: int) static 🔗

Interchange two axes of an array.


NDArray tan(a: Variant) static 🔗

Compute tangent element-wise.

Equivalent to nd.sin(x) / nd.cos(x) element-wise.


NDArray tanh(a: Variant) static 🔗

Compute hyperbolic tangent element-wise.

Equivalent to nd.sinh(x) / nd.cosh(x).


NDArray tile(v: Variant, reps: Variant, inner: bool = false) static 🔗

Construct an array by repeating v the number of times given by reps.

If reps has length d, the result will have dimension of max(d, v.ndim).

The repetitions will be applied from the innermost dimensions outwards.

If v.ndim > d, the outermost dimensions will remain unchanged.

If v.ndim < d, the array is broadcast with leading new axes.

When inner=true, elements will repeat individually rather than element groups repeating.


Vector4i to(stop: int) static 🔗

Create a range that starts at 0, and stops at the given index (exclusive).


NDArray trace(v: Variant, offset: int = 0, axis1: int = 0, axis2: int = 1) static 🔗

Return the sum of the k-th diagonal of a matrix.

The shape of the result will be the same as v, but with the two given axes removed.

Returns a 0-dimension scalar if v is 2-D. In that case, consider ndi.trace() and ndf.trace().


NDArray transpose(a: Variant, permutation: Variant = null) static 🔗

Returns an array with axes transposed.

If permutation is not given, reverses the order of the axes.


NDArray trunc(a: Variant) static 🔗

Return the truncated value of the input, element-wise.

The truncated value of the scalar x is the nearest integer i which is closer to zero than x is. In short, the fractional part of the signed number x is discarded.


NDArray uint8(array: Variant) static 🔗

Convert to a uint8 dtype tensor.

Equivalent to nd.as_array(array, nd.DType.UInt8).


NDArray uint16(array: Variant) static 🔗

Convert to a uint16 dtype tensor.

Equivalent to nd.as_array(array, nd.DType.UInt16).


NDArray uint32(array: Variant) static 🔗

Convert to a uint32 dtype tensor.

Equivalent to nd.as_array(array, nd.DType.UInt32).


NDArray uint64(array: Variant) static 🔗

Convert to a uint64 dtype tensor.

Equivalent to nd.as_array(array, nd.DType.UInt64).


NDArray unstack(v: Variant, axis: int = 0) static 🔗

Unpacks the given dimension of a rank-R tensor into a sequence of R-1 tensors. Opposite of stack().

Equivalent to nd.moveaxis(array, axis, 0).


NDArray var(a: Variant, axes: Variant = null) static 🔗

Compute the variance along the specified axis.

Returns the variance of the array elements, a measure of the spread of a distribution. The variance is computed for the flattened array by default, otherwise over the specified axis.

Returns a 0-dimension scalar if axes is null. In that case, consider ndf.var().


NDArray vector_as_complex(v: Variant, keepdims: bool = false, dtype: DType = 13) static 🔗

Reinterprets a real valued array with shape[-1] == 2 as a complex valued array.

If keepdims is false (default), the last dimension will be consumed. Otherwise, it will be 1.

This function will return a view if possible, but create a new array otherwise.


Array[NDArray] vsplit(v: Variant, indices_or_sections: Variant) static 🔗

Split an array into multiple sub-arrays vertically (row-wise).

Please refer to split(). vsplit is equivalent to split with axis=0 (default), the array is always split along the first axis regardless of the array dimension.


NDArray vstack(v: Variant, dtype: DType = 13) static 🔗

Stack arrays in sequence vertically (row wise).

This is equivalent to concatenation along the first axis after 1-D arrays of shape (N,) have been reshaped to (1,N). Rebuilds arrays divided by vsplit.

This function makes most sense for arrays with up to 3 dimensions. For instance, for pixel-data with a height (first axis), width (second axis), and r/g/b channels (third axis). The functions concatenate, stack and block provide more general stacking and concatenation operations.


NDArray where(condition: Variant, x: Variant, y: Variant) static 🔗

Element-wise selection. Returns elements from x where condition is true and from y otherwise.

condition must be a boolean tensor. All three operands broadcast against each other; the result dtype is the common type of x and y.


NDArray zeros(shape: Variant, dtype: DType = 2) static 🔗

Return a new array of given shape and type, filled with zeros.


NDArray zeros_like(model: Variant, dtype: DType = 13, shape: Variant = null) static 🔗

Return a new array of ones with the same shape and type as a given array.

DType and shape will, if supplied, override the values inferred from the given array.


User-contributed notes

Please read the User-contributed notes policy before submitting a comment.