NumPy Functions

Workflows provides equivalents to many NumPy functions through the workflows.numpy module, for use on the Workflows Array type. Supported functions are listed here. For more information, see the Workflows guide.

Generally, you should use these functions from the Workflows submodule, like:

import descarteslabs.workflows as wf
from descarteslabs.workflows import numpy as wnp

wf_array = wf.Image.from_id("foo:bar").ndarray
arr_t = wnp.transpose(wf_array, [1, 2, 0])

But for convenience, you can also use NumPy versions of these functions directly on Workflows Array:

import numpy as np
same_arr_t = np.transpose(wf_array, [1, 2, 0])

Use of these docstrings is subject to the NumPy license.

Top Level Functions

absolute(x)

Calculate the absolute value element-wise.

add(x1, x2)

Add arguments element-wise.

all(a[, axis])

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

allclose(a, b[, rtol, atol, equal_nan])

Returns True if two arrays are element-wise equal within a tolerance.

angle(z[, deg])

Return the angle of the complex argument.

any(a[, axis])

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

arange([start, stop, step])

Return evenly spaced values within a given interval.

arccos(x)

Trigonometric inverse cosine, element-wise.

arccosh(x)

Inverse hyperbolic cosine, element-wise.

arcsin(x)

Inverse sine, element-wise.

arcsinh(x)

Inverse hyperbolic sine element-wise.

arctan(x)

Trigonometric inverse tangent, element-wise.

arctan2(x1, x2)

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

arctanh(x)

Inverse hyperbolic tangent element-wise.

argmax(a[, axis])

Returns the indices of the maximum values along an axis.

argmin(a[, axis])

Returns the indices of the minimum values along an axis.

argwhere(a)

Find the indices of array elements that are non-zero, grouped by element.

around(a[, decimals])

Evenly round to the given number of decimals.

array

alias of descarteslabs.workflows.types.array.array_.Array

atleast_1d(*arys)

Convert inputs to arrays with at least one dimension.

atleast_2d(*arys)

View inputs as arrays with at least two dimensions.

atleast_3d(*arys)

View inputs as arrays with at least three dimensions.

average(a[, axis, weights])

Compute the weighted average along the specified axis.

bincount(x[, weights, minlength])

Count number of occurrences of each value in array of non-negative ints.

bitwise_and(x1, x2)

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

bitwise_or(x1, x2)

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

bitwise_xor(x1, x2)

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

bitwise_not(x)

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

broadcast_arrays(*args)

Broadcast any number of arrays against each other.

broadcast_to(array, shape)

Broadcast an array to a new shape.

cbrt(x)

Return the cube-root of an array, element-wise.

ceil(x)

Return the ceiling of the input, element-wise.

clip(a, a_min, a_max)

Clip (limit) the values in an array.

compress(condition, a[, axis])

Return selected slices of an array along given axis.

concatenate(arrays[, axis])

Join a sequence of arrays along an existing axis.

conj(x)

Return the complex conjugate, element-wise.

conjugate(x)

Return the complex conjugate, element-wise.

copysign(x1, x2)

Change the sign of x1 to that of x2, element-wise.

corrcoef(x[, y, rowvar])

Return Pearson product-moment correlation coefficients.

cos(x)

Cosine element-wise.

cosh(x)

Hyperbolic cosine, element-wise.

count_nonzero(a[, axis])

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

cov(m[, y, rowvar, bias, ddof, fweights, …])

Estimate a covariance matrix, given data and weights.

cumprod(a[, axis, dtype])

Return the cumulative product of elements along a given axis.

cumsum(a[, axis, dtype])

Return the cumulative sum of the elements along a given axis.

deg2rad(x)

Convert angles from degrees to radians.

degrees(x)

Convert angles from radians to degrees.

diag(v)

Extract a diagonal or construct a diagonal array.

diagonal(a[, offset, axis1, axis2])

Return specified diagonals.

diff(a[, n, axis])

Calculate the n-th discrete difference along the given axis.

digitize(x, bins[, right])

Return the indices of the bins to which each value in input array belongs.

divide(x1, x2)

Returns a true division of the inputs, element-wise.

dot(a, b)

Dot product of two arrays.

dstack(arrays)

Stack arrays in sequence depth wise (along third axis).

ediff1d(ary[, to_end, to_begin])

The differences between consecutive elements of an array.

einsum(subscripts, *operands[, dtype, …])

Evaluates the Einstein summation convention on the operands.

equal(x1, x2)

Return (x1 == x2) element-wise.

exp(x)

Calculate the exponential of all elements in the input array.

exp2(x)

Calculate 2**p for all p in the input array.

expm1(x)

Calculate exp(x) - 1 for all elements in the array.

eye(N[, M, k, dtype])

Return a 2-D array with ones on the diagonal and zeros elsewhere.

fabs(x)

Compute the absolute values element-wise.

fix(x)

Round to nearest integer towards zero.

flatnonzero(a)

Return indices that are non-zero in the flattened version of a.

float_power(x1, x2)

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

floor(x)

Return the floor of the input, element-wise.

floor_divide(x1, x2)

Return the largest integer smaller or equal to the division of the inputs.

fmax(x1, x2)

Element-wise maximum of array elements.

fmin(x1, x2)

Element-wise minimum of array elements.

fmod(x1, x2)

Return the element-wise remainder of division.

full(shape, fill_value[, dtype])

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

full_like(a, fill_value[, dtype])

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

gradient(f, *varargs[, edge_order, axis])

Return the gradient of an N-dimensional array.

greater(x1, x2)

Return the truth value of (x1 > x2) element-wise.

greater_equal(x1, x2)

Return the truth value of (x1 >= x2) element-wise.

histogram(a[, bins, range, weights, density])

Compute the histogram of a set of data.

hstack(arrays)

Stack arrays in sequence horizontally (column wise).

hypot(x1, x2)

Given the “legs” of a right triangle, return its hypotenuse.

imag(val)

Return the imaginary part of the complex argument.

indices(dimensions[, dtype])

Return an array representing the indices of a grid.

insert(arr, obj, values, axis)

Insert values along the given axis before the given indices.

isclose(a, b[, rtol, atol, equal_nan])

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

isfinite(x)

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

isin(element, test_elements[, …])

Calculates element in test_elements, broadcasting over element only.

isinf(x)

Test element-wise for positive or negative infinity.

isnan(x)

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

isneginf(x)

Test element-wise for negative infinity, return result as bool array.

isposinf(x)

Test element-wise for positive infinity, return result as bool array.

isreal(x)

Returns a bool array, where True if input element is real.

ldexp(x1, x2)

Returns x1 * 2**x2, element-wise.

less(x1, x2)

Return the truth value of (x1 < x2) element-wise.

less_equal(x1, x2)

Return the truth value of (x1 =< x2) element-wise.

linspace(start, stop[, num, endpoint, …])

Return evenly spaced numbers over a specified interval.

log(x)

Natural logarithm, element-wise.

log10(x)

Return the base 10 logarithm of the input array, element-wise.

log1p(x)

Return the natural logarithm of one plus the input array, element-wise.

log2(x)

Base-2 logarithm of x.

logaddexp(x1, x2)

Logarithm of the sum of exponentiations of the inputs.

logaddexp2(x1, x2)

Logarithm of the sum of exponentiations of the inputs in base-2.

logical_and(x1, x2)

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

logical_not(x)

Compute the truth value of NOT x element-wise.

logical_or(x1, x2)

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

logical_xor(x1, x2)

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

max(a[, axis])

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

maximum(x1, x2)

Element-wise maximum of array elements.

mean(a[, axis])

Compute the arithmetic mean along the specified axis.

meshgrid(*xi[, indexing, sparse])

Return coordinate matrices from coordinate vectors.

min(a[, axis])

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

minimum(x1, x2)

Element-wise minimum of array elements.

mod(x1, x2)

Return element-wise remainder of division.

moveaxis(a, source, destination)

Move axes of an array to new positions.

multiply(x1, x2)

Multiply arguments element-wise.

nan_to_num(x)

Replace NaN with zero and infinity with large finite numbers (default behaviour) or with the numbers defined by the user using the nan, posinf and/or neginf keywords.

nanargmax(a[, axis])

Return the indices of the maximum values in the specified axis ignoring NaNs.

nanargmin(a[, axis])

Return the indices of the minimum values in the specified axis ignoring NaNs.

nancumprod(a[, axis, dtype])

Return the cumulative product of array elements over a given axis treating Not a Numbers (NaNs) as one.

nancumsum(a[, axis, dtype])

Return the cumulative sum of array elements over a given axis treating Not a Numbers (NaNs) as zero.

nanmax(a[, axis])

Return the maximum of an array or maximum along an axis, ignoring any NaNs.

nanmean(a[, axis])

Compute the arithmetic mean along the specified axis, ignoring NaNs.

nanmin(a[, axis])

Return minimum of an array or minimum along an axis, ignoring any NaNs.

nanprod(a[, axis])

Return the product of array elements over a given axis treating Not a Numbers (NaNs) as ones.

nanstd(a[, axis])

Compute the standard deviation along the specified axis, while ignoring NaNs.

nansum(a[, axis])

Return the sum of array elements over a given axis treating Not a Numbers (NaNs) as zero.

nanvar(a[, axis, ddof])

Compute the variance along the specified axis, while ignoring NaNs.

negative(x)

Numerical negative, element-wise.

nextafter(x1, x2)

Return the next floating-point value after x1 towards x2, element-wise.

nonzero(a)

Return the indices of the elements that are non-zero.

not_equal(x1, x2)

Return (x1 != x2) element-wise.

ones(shape[, dtype])

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

ones_like(a[, dtype])

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

outer(a, b)

Compute the outer product of two vectors.

pad(array, pad_width[, mode])

Pad an array.

percentile(a, q[, interpolation])

Compute the q-th percentile of the data along the specified axis.

power(x1, x2)

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

prod(a[, axis])

Return the product of array elements over a given axis.

ptp(a[, axis])

Range of values (maximum - minimum) along an axis.

rad2deg(x)

Convert angles from radians to degrees.

radians(x)

Convert angles from degrees to radians.

ravel(a)

Return a contiguous flattened array.

real(val)

Return the real part of the complex argument.

reciprocal(x)

Return the reciprocal of the argument, element-wise.

remainder(x1, x2)

Return element-wise remainder of division.

repeat(a, repeats[, axis])

Repeat elements of an array.

reshape(a, newshape)

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

rint(x)

Round elements of the array to the nearest integer.

roll(a, shift[, axis])

Roll array elements along a given axis.

rollaxis(a, axis[, start])

Roll the specified axis backwards, until it lies in a given position.

round(a[, decimals])

Round an array to the given number of decimals.

sign(x)

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

signbit(x)

Returns element-wise True where signbit is set (less than zero).

sin(x)

Trigonometric sine, element-wise.

sinh(x)

Hyperbolic sine, element-wise.

spacing(x)

Return the distance between x and the nearest adjacent number.

sqrt(x)

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

square(x)

Return the element-wise square of the input.

squeeze(a[, axis])

Remove single-dimensional entries from the shape of an array.

stack(arrays[, axis])

Join a sequence of arrays along a new axis.

std(a[, axis])

Compute the standard deviation along the specified axis.

subtract(x1, x2)

Subtract arguments, element-wise.

sum(a[, axis])

Sum of array elements over a given axis.

take(a, indices[, axis])

Take elements from an array along an axis.

tan(x)

Compute tangent element-wise.

tanh(x)

Compute hyperbolic tangent element-wise.

tensordot(a, b[, axes])

Compute tensor dot product along specified axes.

tile(A, reps)

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

trace(a[, offset, axis1, axis2])

Return the sum along diagonals of the array.

transpose(a[, axes])

Permute the dimensions of an array.

tril(m[, k])

Lower triangle of an array.

triu(m[, k])

Upper triangle of an array.

true_divide(x1, x2)

Returns a true division of the inputs, element-wise.

trunc(x)

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

unique(ar)

Find the unique elements of an array.

unravel_index(indices, shape)

Converts a flat index or array of flat indices into a tuple of coordinate arrays.

var(a[, axis, ddof])

Compute the variance along the specified axis.

vdot(a, b)

Return the dot product of two vectors.

vstack(arrays)

Stack arrays in sequence vertically (row wise).

where(condition, x, y)

Return elements chosen from x or y depending on condition.

zeros(shape[, dtype])

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

zeros_like(a)

Return an array of zeros with the same shape and type as a given array.

Linear Algebra

linalg.cholesky(a)

Cholesky decomposition.

linalg.inv(a)

Compute the (multiplicative) inverse of a matrix.

linalg.lstsq(a, b)

Return the least-squares solution to a linear matrix equation.

linalg.norm(x[, ord, axis])

Matrix or vector norm.

linalg.qr(a[, mode])

Compute the qr factorization of a matrix.

linalg.solve(a, b)

Solve a linear matrix equation, or system of linear scalar equations.

linalg.svd(a)

Singular Value Decomposition.

Masked Arrays

ma.average(a[, axis, weights])

Return the weighted average of array over the given axis.

ma.filled(a[, fill_value])

Return input as an array with masked data replaced by a fill value.

ma.fix_invalid(a, fill_value)

Return input with invalid data masked and replaced by a fill value.

ma.masked_array

alias of descarteslabs.workflows.types.array.masked_array.MaskedArray

ma.masked_equal(x, value)

Mask an array where equal to a given value.

ma.masked_greater(x, value)

Mask an array where greater than a given value.

ma.masked_greater_equal(x, value)

Mask an array where greater than or equal to a given value.

ma.masked_inside(x, v1, v2)

Mask an array inside a given interval.

ma.masked_invalid(a)

Mask an array where invalid values occur (NaNs or infs).

ma.masked_less(x, value)

Mask an array where less than a given value.

ma.masked_less_equal(x, value)

Mask an array where less than or equal to a given value.

ma.masked_not_equal(x, value)

Mask an array where not equal to a given value.

ma.masked_outside(x, v1, v2)

Mask an array outside a given interval.

ma.masked_values(x, value[, rtol, atol, shrink])

Mask using floating point equality.

ma.masked_where(condition, a)

Mask an array where a condition is met.

absolute(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Union[Scalar, Int, Array, Bool, Float, MaskedArray]

Calculate the absolute value element-wise.

This docstring was copied from numpy.absolute

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Input array.

Returns

absolute – An ndarray containing the absolute value of each element in x. For complex input, a + ib, the absolute value is \(\sqrt{ a^2 + b^2 }\). This is a scalar if x is a scalar.

Return type

ndarray

add(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Union[Scalar, Int, Array, Bool, Float, MaskedArray]

Add arguments element-wise.

This docstring was copied from numpy.add

Some inconsistencies with the Workflows version may exist

Parameters

x2 (x1,) – The arrays to be added. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

add – The sum of x1 and x2, element-wise. This is a scalar if both x1 and x2 are scalars.

Return type

ndarray or scalar

all(a: Union[Array, MaskedArray], axis: Union[NoneType, List[Int], Int] = None) → Union[Scalar, Array, MaskedArray]

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

This docstring was copied from numpy.all

Some inconsistencies with the Workflows version may exist

Parameters
  • a (array_like) – Input array or object that can be converted to an array.

  • axis (None or int or tuple of ints, optional) –

    Axis or axes along which a logical AND reduction is performed. The default (axis=None) is to perform a logical AND over all the dimensions of the input array. axis may be negative, in which case it counts from the last to the first axis.

    New in version 1.7.0.

    If this is a tuple of ints, a reduction is performed on multiple axes, instead of a single axis or all the axes as before.

  • out (ndarray, optional) – Alternate output array in which to place the result. It must have the same shape as the expected output and its type is preserved (e.g., if dtype(out) is float, the result will consist of 0.0’s and 1.0’s). See ufuncs-output-type for more details.

  • keepdims (bool, optional) –

    If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.

    If the default value is passed, then keepdims will not be passed through to the all method of sub-classes of ndarray, however any non-default value will be. If the sub-class’ method does not implement keepdims any exceptions will be raised.

Returns

  • all (ndarray, bool) – A new boolean or array is returned unless out is specified, in which case a reference to out is returned.

  • any (Test whether any element along a given axis evaluates to True.)

Notes

Not a Number (NaN), positive infinity and negative infinity evaluate to True because these are not equal to zero.

allclose(a: Union[Array, Scalar, MaskedArray], b: Union[Array, Scalar, MaskedArray], rtol: Union[Float, Int] = 1e-05, atol: Union[Float, Int] = 1e-08, equal_nan: Bool = False) → Scalar

Returns True if two arrays are element-wise equal within a tolerance.

This docstring was copied from numpy.allclose

Some inconsistencies with the Workflows version may exist

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.

NaNs are treated as equal if they are in the same place and if equal_nan=True. Infs are treated as equal if they are in the same place and of the same sign in both arrays.

Parameters
  • b (a,) – Input arrays to compare.

  • rtol (float) – The relative tolerance parameter (see Notes).

  • atol (float) – The absolute tolerance parameter (see Notes).

  • equal_nan (bool) –

    Whether to compare NaN’s as equal. If True, NaN’s in a will be considered equal to NaN’s in b in the output array.

    New in version 1.10.0.

Returns

allclose – Returns True if the two arrays are equal within the given tolerance; False otherwise.

Return type

bool

Notes

If the following equation is element-wise True, then allclose returns True.

absolute(a - b) <= (atol + rtol * absolute(b))

The above equation is not symmetric in a and b, so that allclose(a, b) might be different from allclose(b, a) in some rare cases.

The comparison of a and b uses standard broadcasting, which means that a and b need not have the same shape in order for allclose(a, b) to evaluate to True. The same is true for equal but not array_equal.

angle(z: Union[Array, MaskedArray], deg: Bool = False) → Array

Return the angle of the complex argument.

This docstring was copied from numpy.angle

Some inconsistencies with the Workflows version may exist

Parameters
  • z (array_like) – A complex number or sequence of complex numbers.

  • deg (bool, optional) – Return angle in degrees if True, radians if False (default).

Returns

angle – The counterclockwise angle from the positive real axis on the complex plane in the range (-pi, pi], with dtype as numpy.float64.

..versionchanged:: 1.16.0

This function works on subclasses of ndarray like ma.array.

Return type

ndarray or scalar

any(a: Union[Array, MaskedArray], axis: Union[NoneType, List[Int], Int] = None) → Union[Scalar, Array, MaskedArray]

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

This docstring was copied from numpy.any

Some inconsistencies with the Workflows version may exist

Returns single boolean unless axis is not None

Parameters
  • a (array_like) – Input array or object that can be converted to an array.

  • axis (None or int or tuple of ints, optional) –

    Axis or axes along which a logical OR reduction is performed. The default (axis=None) is to perform a logical OR over all the dimensions of the input array. axis may be negative, in which case it counts from the last to the first axis.

    New in version 1.7.0.

    If this is a tuple of ints, a reduction is performed on multiple axes, instead of a single axis or all the axes as before.

  • out (ndarray, optional) – Alternate output array in which to place the result. It must have the same shape as the expected output and its type is preserved (e.g., if it is of type float, then it will remain so, returning 1.0 for True and 0.0 for False, regardless of the type of a). See ufuncs-output-type for more details.

  • keepdims (bool, optional) –

    If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.

    If the default value is passed, then keepdims will not be passed through to the any method of sub-classes of ndarray, however any non-default value will be. If the sub-class’ method does not implement keepdims any exceptions will be raised.

Returns

  • any (bool or ndarray) – A new boolean or ndarray is returned unless out is specified, in which case a reference to out is returned.

  • all (Test whether all elements along a given axis evaluate to True.)

Notes

Not a Number (NaN), positive infinity and negative infinity evaluate to True because these are not equal to zero.

arange(start: Union[Float, Scalar, Int] = 0, stop: Union[Float, Scalar, Int] = None, step: Union[Float, Scalar, Int] = 1) → Array

Return evenly spaced values within a given interval.

This docstring was copied from numpy.arange

Some inconsistencies with the Workflows version may exist

Values are generated within the half-open interval [start, stop) (in other words, the interval including start but excluding stop). For integer arguments the function is equivalent to the Python built-in range function, but returns an ndarray rather than a list.

When using a non-integer step, such as 0.1, the results will often not be consistent. It is better to use numpy.linspace for these cases.

Parameters
  • start (number, optional) – Start of interval. The interval includes this value. The default start value is 0.

  • stop (number) – End of interval. The interval does not include this value, except in some cases where step is not an integer and floating point round-off affects the length of out.

  • step (number, optional) – Spacing between values. For any output out, this is the distance between two adjacent values, out[i+1] - out[i]. The default step size is 1. If step is specified as a position argument, start must also be given.

  • dtype (dtype) – The type of the output array. If dtype is not given, infer the data type from the other input arguments.

Returns

arange – Array of evenly spaced values.

For floating point arguments, the length of the result is ceil((stop - start)/step). Because of floating point overflow, this rule may result in the last element of out being greater than stop.

Return type

ndarray

arccos(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

Trigonometric inverse cosine, element-wise.

This docstring was copied from numpy.arccos

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – x-coordinate on the unit circle.

Returns

angle – The angle of the ray intersecting the unit circle at the given x-coordinate in radians [0, pi]. This is a scalar if x is a scalar.

Return type

ndarray

arccosh(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

Inverse hyperbolic cosine, element-wise.

This docstring was copied from numpy.arccosh

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Input array.

Returns

arccosh – Array of the same shape as x. This is a scalar if x is a scalar.

Return type

ndarray

arcsin(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

Inverse sine, element-wise.

This docstring was copied from numpy.arcsin

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – y-coordinate on the unit circle.

Returns

angle – The inverse sine of each element in x, in radians and in the closed interval [-pi/2, pi/2]. This is a scalar if x is a scalar.

Return type

ndarray

arcsinh(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

Inverse hyperbolic sine element-wise.

This docstring was copied from numpy.arcsinh

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Input array.

Returns

out – Array of the same shape as x. This is a scalar if x is a scalar.

Return type

ndarray or scalar

arctan(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

Trigonometric inverse tangent, element-wise.

This docstring was copied from numpy.arctan

Some inconsistencies with the Workflows version may exist

Parameters
  • x (array_like) –

  • out (ndarray, None, or tuple of ndarray and None, optional) –

Returns

out – Out has the same shape as x. Its real part is in [-pi/2, pi/2] (arctan(+/-inf) returns +/-pi/2). This is a scalar if x is a scalar.

Return type

ndarray or scalar

arctan2(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

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

This docstring was copied from numpy.arctan2

Some inconsistencies with the Workflows version may exist

Parameters
  • x1 (array_like, real-valued) – y-coordinates.

  • x2 (array_like, real-valued) – x-coordinates. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

angle – Array of angles in radians, in the range [-pi, pi]. This is a scalar if both x1 and x2 are scalars.

Return type

ndarray

arctanh(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

Inverse hyperbolic tangent element-wise.

This docstring was copied from numpy.arctanh

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Input array.

Returns

out – Array of the same shape as x. This is a scalar if x is a scalar.

Return type

ndarray or scalar

argmax(a: Union[Array, MaskedArray], axis: Optional[Int] = None) → Union[Scalar, Array]

Returns the indices of the maximum values along an axis.

This docstring was copied from numpy.argmax

Some inconsistencies with the Workflows version may exist

Parameters
  • a (array_like) – Input array.

  • axis (int, optional) – By default, the index is into the flattened array, otherwise along the specified axis.

  • out (array, optional) – If provided, the result will be inserted into this array. It should be of the appropriate shape and dtype.

Returns

index_array – Array of indices into the array. It has the same shape as a.shape with the dimension along axis removed.

Return type

ndarray of ints

Notes

In case of multiple occurrences of the maximum values, the indices corresponding to the first occurrence are returned.

argmin(a: Union[Array, MaskedArray], axis: Optional[Int] = None) → Union[Scalar, Array]

Returns the indices of the minimum values along an axis.

This docstring was copied from numpy.argmin

Some inconsistencies with the Workflows version may exist

Parameters
  • a (array_like) – Input array.

  • axis (int, optional) – By default, the index is into the flattened array, otherwise along the specified axis.

  • out (array, optional) – If provided, the result will be inserted into this array. It should be of the appropriate shape and dtype.

Returns

index_array – Array of indices into the array. It has the same shape as a.shape with the dimension along axis removed.

Return type

ndarray of ints

Notes

In case of multiple occurrences of the minimum values, the indices corresponding to the first occurrence are returned.

argwhere(a: Union[Array, MaskedArray]) → Array

Find the indices of array elements that are non-zero, grouped by element.

This docstring was copied from numpy.argwhere

Some inconsistencies with the Workflows version may exist

Parameters

a (array_like) – Input data.

Returns

index_array – Indices of elements that are non-zero. Indices are grouped by element. This array will have shape (N, a.ndim) where N is the number of non-zero items.

Return type

(N, a.ndim) ndarray

Notes

np.argwhere(a) is almost the same as np.transpose(np.nonzero(a)), but produces a result of the correct shape for a 0D array.

The output of argwhere is not suitable for indexing arrays. For this purpose use nonzero(a) instead.

around(a: Union[Scalar, Array, MaskedArray], decimals: Int = 0) → Union[Scalar, Array, MaskedArray]

Evenly round to the given number of decimals.

This docstring was copied from numpy.around

Some inconsistencies with the Workflows version may exist

Parameters
  • a (array_like) – Input data.

  • decimals (int, optional) – Number of decimal places to round to (default: 0). If decimals is negative, it specifies the number of positions to the left of the decimal point.

  • out (ndarray, optional) – Alternative output array in which to place the result. It must have the same shape as the expected output, but the type of the output values will be cast if necessary. See ufuncs-output-type for more details.

Returns

  • rounded_array (ndarray) – An array of the same type as a, containing the rounded values. Unless out was specified, a new array is created. A reference to the result is returned.

    The real and imaginary parts of complex numbers are rounded separately. The result of rounding a float is a float.

  • ceil, fix, floor, rint, trunc

Notes

For values exactly halfway between rounded decimal values, NumPy rounds to the nearest even value. Thus 1.5 and 2.5 round to 2.0, -0.5 and 0.5 round to 0.0, etc.

np.around uses a fast but sometimes inexact algorithm to round floating-point datatypes. For positive decimals it is equivalent to np.true_divide(np.rint(a * 10**decimals), 10**decimals), which has error due to the inexact representation of decimal fractions in the IEEE floating point standard and errors introduced when scaling by powers of ten. For instance, note the extra “1” in the following:

>>> np.round(56294995342131.5, 3)
56294995342131.51

If your goal is to print such values with a fixed number of decimals, it is preferable to use numpy’s float printing routines to limit the number of printed decimals:

>>> np.format_float_positional(56294995342131.5, precision=3)
'56294995342131.5'

The float printing routines use an accurate but much more computationally demanding algorithm to compute the number of digits after the decimal point.

Alternatively, Python’s builtin round function uses a more accurate but slower algorithm for 64-bit floating point values:

>>> round(56294995342131.5, 3)
56294995342131.5
>>> np.round(16.055, 2), round(16.055, 2)  # equals 16.0549999999999997
(16.06, 16.05)
array(arr)

Proxy Array representing a multidimensional, homogenous array of fixed-size items.

Can be instantiated from a NumPy ndarray (via from_numpy), or a Python iterable. Currently, Arrays can only be constructed from small local arrays (< 10MB). Array follows the same syntax as NumPy arrays. It supports vectorized operations, broadcasting, and multidimensional indexing. There are some limitations including slicing with lists/arrays in multiple axes (x[[1, 2, 3], [3, 2, 1]]) and slicing with a multidimensional list/array of integers.

Note

Array is an experimental API. It may be changed in the future, will not necessarily be backwards compatible, and may have unexpected bugs. Please contact us with any feedback!

Examples

>>> import descarteslabs.workflows as wf
>>> # Create a 1-dimensional Array of Ints
>>> arr = wf.Array([1, 2, 3, 4, 5])
>>> arr
<descarteslabs.workflows.types.array.array_.Array object at 0x...>
>>> arr.compute(geoctx) 
array([1, 2, 3, 4, 5])
>>> import numpy as np
>>> import descarteslabs.workflows as wf
>>> ndarray = np.ones((3, 10, 10))
>>> # Create an Array from the 3-dimensional numpy array
>>> arr = wf.Array(ndarray)
>>> arr
<descarteslabs.workflows.types.array.array_.Array object at 0x...>
atleast_1d(*arys: Union[Array, Scalar, MaskedArray]) → Union[List[Array], List[MaskedArray], Array, MaskedArray]

Convert inputs to arrays with at least one dimension.

This docstring was copied from numpy.atleast_1d

Some inconsistencies with the Workflows version may exist

Scalar inputs are converted to 1-dimensional arrays, whilst higher-dimensional inputs are preserved.

Parameters

arys2, .. (arys1,) – One or more input arrays.

Returns

ret – An array, or list of arrays, each with a.ndim >= 1. Copies are made only if necessary.

Return type

ndarray

atleast_2d(*arys: Union[Array, Scalar, MaskedArray]) → Union[List[Array], List[MaskedArray], Array, MaskedArray]

View inputs as arrays with at least two dimensions.

This docstring was copied from numpy.atleast_2d

Some inconsistencies with the Workflows version may exist

Parameters

arys2, .. (arys1,) – One or more array-like sequences. Non-array inputs are converted to arrays. Arrays that already have two or more dimensions are preserved.

Returns

res, res2, … – An array, or list of arrays, each with a.ndim >= 2. Copies are avoided where possible, and views with two or more dimensions are returned.

Return type

ndarray

atleast_3d(*arys: Union[Array, Scalar, MaskedArray]) → Union[List[Array], List[MaskedArray], Array, MaskedArray]

View inputs as arrays with at least three dimensions.

This docstring was copied from numpy.atleast_3d

Some inconsistencies with the Workflows version may exist

Parameters

arys2, .. (arys1,) – One or more array-like sequences. Non-array inputs are converted to arrays. Arrays that already have three or more dimensions are preserved.

Returns

res1, res2, … – An array, or list of arrays, each with a.ndim >= 3. Copies are avoided where possible, and views with three or more dimensions are returned. For example, a 1-D array of shape (N,) becomes a view of shape (1, N, 1), and a 2-D array of shape (M, N) becomes a view of shape (M, N, 1).

Return type

ndarray

average(a: Union[Scalar, Array, MaskedArray], axis: Union[NoneType, List[Int], Int] = None, weights: Union[Scalar, Array, MaskedArray] = None) → Union[Scalar, Array, MaskedArray]

Compute the weighted average along the specified axis.

This docstring was copied from numpy.average

Some inconsistencies with the Workflows version may exist

Parameters
  • a (array_like) – Array containing data to be averaged. If a is not an array, a conversion is attempted.

  • axis (None or int or tuple of ints, optional) –

    Axis or axes along which to average a. The default, axis=None, will average over all of the elements of the input array. If axis is negative it counts from the last to the first axis.

    New in version 1.7.0.

    If axis is a tuple of ints, averaging is performed on all of the axes specified in the tuple instead of a single axis or all the axes as before.

  • weights (array_like, optional) –

    An array of weights associated with the values in a. Each value in a contributes to the average according to its associated weight. The weights array can either be 1-D (in which case its length must be the size of a along the given axis) or of the same shape as a. If weights=None, then all data in a are assumed to have a weight equal to one. The 1-D calculation is:

    avg = sum(a * weights) / sum(weights)
    

    The only constraint on weights is that sum(weights) must not be 0.

  • returned (bool, optional) – Default is False. If True, the tuple (average, sum_of_weights) is returned, otherwise only the average is returned. If weights=None, sum_of_weights is equivalent to the number of elements over which the average is taken.

Returns

  • retval, [sum_of_weights] (array_type or double) – Return the average along the specified axis. When returned is True, return a tuple with the average as the first element and the sum of the weights as the second element. sum_of_weights is of the same type as retval. The result dtype follows a genereal pattern. If weights is None, the result dtype will be that of a , or float64 if a is integral. Otherwise, if weights is not None and a is non- integral, the result type will be the type of lowest precision capable of representing values of both a and weights. If a happens to be integral, the previous rules still applies but the result dtype will at least be float64.

  • ma.average (average for masked arrays – useful if your data contains) – “missing” values

  • numpy.result_type (Returns the type that results from applying the) – numpy type promotion rules to the arguments.

bincount(x: Union[Array, MaskedArray], weights: Union[NoneType, Array, MaskedArray] = None, minlength: Int = 0) → Array

Count number of occurrences of each value in array of non-negative ints.

This docstring was copied from numpy.bincount

Some inconsistencies with the Workflows version may exist

The number of bins (of size 1) is one larger than the largest value in x. If minlength is specified, there will be at least this number of bins in the output array (though it will be longer if necessary, depending on the contents of x). Each bin gives the number of occurrences of its index value in x. If weights is specified the input array is weighted by it, i.e. if a value n is found at position i, out[n] += weight[i] instead of out[n] += 1.

Parameters
  • x (array_like, 1 dimension, nonnegative ints) – Input array.

  • weights (array_like, optional) – Weights, array of the same shape as x.

  • minlength (int, optional) –

    A minimum number of bins for the output array.

    New in version 1.6.0.

Returns

out – The result of binning the input array. The length of out is equal to np.amax(x)+1.

Return type

ndarray of ints

bitwise_and(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Union[Scalar, Int, Array, Bool, Float, MaskedArray]

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

This docstring was copied from numpy.bitwise_and

Some inconsistencies with the Workflows version may exist

Parameters

x2 (x1,) – Only integer and boolean types are handled. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

out – Result. This is a scalar if both x1 and x2 are scalars.

Return type

ndarray or scalar

bitwise_or(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Union[Scalar, Int, Array, Bool, Float, MaskedArray]

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

This docstring was copied from numpy.bitwise_or

Some inconsistencies with the Workflows version may exist

Parameters

x2 (x1,) – Only integer and boolean types are handled. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

out – Result. This is a scalar if both x1 and x2 are scalars.

Return type

ndarray or scalar

bitwise_xor(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Union[Scalar, Int, Array, Bool, Float, MaskedArray]

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

This docstring was copied from numpy.bitwise_xor

Some inconsistencies with the Workflows version may exist

Parameters

x2 (x1,) – Only integer and boolean types are handled. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

out – Result. This is a scalar if both x1 and x2 are scalars.

Return type

ndarray or scalar

bitwise_not(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Union[Scalar, Int, Array, Bool, Float, MaskedArray]

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

This docstring was copied from numpy.invert

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Only integer and boolean types are handled.

Returns

out – Result. This is a scalar if x is a scalar.

Return type

ndarray or scalar

broadcast_arrays(*args: Union[Array, MaskedArray]) → Union[List[Array], List[MaskedArray]]

Broadcast any number of arrays against each other.

This docstring was copied from numpy.broadcast_arrays

Some inconsistencies with the Workflows version may exist

Parameters
  • *args (array_likes) – The arrays to broadcast.

  • subok (bool, optional) – If True, then sub-classes will be passed-through, otherwise the returned arrays will be forced to be a base-class array (default).

Returns

broadcasted – These arrays are views on the original arrays. They are typically not contiguous. Furthermore, more than one element of a broadcasted array may refer to a single memory location. If you need to write to the arrays, make copies first. While you can set the writable flag True, writing to a single output value may end up changing more than one location in the output array.

Deprecated since version 1.17: The output is currently marked so that if written to, a deprecation warning will be emitted. A future version will set the writable flag False so writing to it will raise an error.

Return type

list of arrays

broadcast_to(array: Union[Array, MaskedArray], shape: List[Int]) → Union[Array, MaskedArray]

Broadcast an array to a new shape.

This docstring was copied from numpy.broadcast_to

Some inconsistencies with the Workflows version may exist

Parameters
  • array (array_like) – The array to broadcast.

  • shape (tuple) – The shape of the desired array.

  • subok (bool, optional) – If True, then sub-classes will be passed-through, otherwise the returned array will be forced to be a base-class array (default).

Returns

broadcast – A readonly view on the original array with the given shape. It is typically not contiguous. Furthermore, more than one element of a broadcasted array may refer to a single memory location.

Return type

array

Notes

New in version 1.10.0.

cbrt(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

Return the cube-root of an array, element-wise.

This docstring was copied from numpy.cbrt

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – The values whose cube-roots are required.

Returns

y – An array of the same shape as x, containing the cube cube-root of each element in x. If out was provided, y is a reference to it. This is a scalar if x is a scalar.

Return type

ndarray

ceil(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Union[Scalar, Int, Array, Bool, Float, MaskedArray]

Return the ceiling of the input, element-wise.

This docstring was copied from numpy.ceil

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Input data.

Returns

y – The ceiling of each element in x, with float dtype. This is a scalar if x is a scalar.

Return type

ndarray or scalar

clip(a: Union[Scalar, Array, MaskedArray], a_min: Union[Scalar, Int, Array, Float, MaskedArray], a_max: Union[Scalar, Int, Array, Float, MaskedArray]) → Union[Scalar, Array, MaskedArray]

Clip (limit) the values in an array.

This docstring was copied from numpy.clip

Some inconsistencies with the Workflows version may exist

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 np.maximum(a_min, np.minimum(a, a_max)). No check is performed to ensure a_min < a_max.

Parameters
  • a (array_like) – Array containing elements to clip.

  • a_min (scalar or array_like or None) – Minimum value. If None, clipping is not performed on lower interval edge. Not more than one of a_min and a_max may be None.

  • a_max (scalar or array_like or None) – Maximum value. If None, clipping is not performed on upper interval edge. Not more than one of a_min and a_max may be None. If a_min or a_max are array_like, then the three arrays will be broadcasted to match their shapes.

  • out (ndarray, optional) – The results will be placed in this array. It may be the input array for in-place clipping. out must be of the right shape to hold the output. Its type is preserved.

  • **kwargs

    For other keyword-only arguments, see the ufunc docs.

    New in version 1.17.0.

Returns

clipped_array – An array with the elements of a, but where values < a_min are replaced with a_min, and those > a_max with a_max.

Return type

ndarray

compress(condition: Union[Array, MaskedArray], a: Union[Array, MaskedArray], axis: Optional[Int] = None) → Union[Array, MaskedArray]

Return selected slices of an array along given axis.

This docstring was copied from numpy.compress

Some inconsistencies with the Workflows version may exist

When working along a given axis, a slice along that axis is returned in output for each index where condition evaluates to True. When working on a 1-D array, compress is equivalent to extract.

Parameters
  • condition (1-D array of bools) – Array that selects which entries to return. If len(condition) is less than the size of a along the given axis, then output is truncated to the length of the condition array.

  • a (array_like) – Array from which to extract a part.

  • axis (int, optional) – Axis along which to take slices. If None (default), work on the flattened array.

  • out (ndarray, optional) – Output array. Its type is preserved and it must be of the right shape to hold the output.

Returns

compressed_array – A copy of a without the slices along axis for which condition is false.

Return type

ndarray

concatenate(arrays: Union[List[Array], List[MaskedArray]], axis: Int = 0) → Union[Array, MaskedArray]

Join a sequence of arrays along an existing axis.

This docstring was copied from numpy.concatenate

Some inconsistencies with the Workflows version may exist

Parameters
  • a2, .. (a1,) – The arrays must have the same shape, except in the dimension corresponding to axis (the first, by default).

  • axis (int, optional) – The axis along which the arrays will be joined. If axis is None, arrays are flattened before use. Default is 0.

  • out (ndarray, optional) – If provided, the destination to place the result. The shape must be correct, matching that of what concatenate would have returned if no out argument were specified.

Returns

res – The concatenated array.

Return type

ndarray

Notes

When one or more of the arrays to be concatenated is a MaskedArray, this function will return a MaskedArray object instead of an ndarray, but the input masks are not preserved. In cases where a MaskedArray is expected as input, use the ma.concatenate function from the masked array module instead.

conj(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Union[Scalar, Int, Array, Bool, Float, MaskedArray]

Return the complex conjugate, element-wise.

This docstring was copied from numpy.conjugate

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Input value.

Returns

y – The complex conjugate of x, with same dtype as y. This is a scalar if x is a scalar.

Return type

ndarray

conjugate(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Union[Scalar, Int, Array, Bool, Float, MaskedArray]

Return the complex conjugate, element-wise.

This docstring was copied from numpy.conjugate

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Input value.

Returns

y – The complex conjugate of x, with same dtype as y. This is a scalar if x is a scalar.

Return type

ndarray

copysign(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

Change the sign of x1 to that of x2, element-wise.

This docstring was copied from numpy.copysign

Some inconsistencies with the Workflows version may exist

Parameters
  • x1 (array_like) – Values to change the sign of.

  • x2 (array_like) – The sign of x2 is copied to x1. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

out – The values of x1 with the sign of x2. This is a scalar if both x1 and x2 are scalars.

Return type

ndarray or scalar

corrcoef(x: Union[Array, MaskedArray], y: Union[NoneType, Array, MaskedArray] = None, rowvar: Bool = True) → Union[Array, MaskedArray]

Return Pearson product-moment correlation coefficients.

This docstring was copied from numpy.corrcoef

Some inconsistencies with the Workflows version may exist

Please refer to the documentation for cov for more detail. The relationship between the correlation coefficient matrix, R, and the covariance matrix, C, is

\[R_{ij} = \frac{ C_{ij} } { \sqrt{ C_{ii} * C_{jj} } }\]

The values of R are between -1 and 1, inclusive.

Parameters
  • x (array_like) – A 1-D or 2-D array containing multiple variables and observations. Each row of x represents a variable, and each column a single observation of all those variables. Also see rowvar below.

  • y (array_like, optional) – An additional set of variables and observations. y has the same shape as x.

  • rowvar (bool, optional) – If rowvar is True (default), then each row represents a variable, with observations in the columns. Otherwise, the relationship is transposed: each column represents a variable, while the rows contain observations.

  • bias (_NoValue, optional) –

    Has no effect, do not use.

    Deprecated since version 1.10.0.

  • ddof (_NoValue, optional) –

    Has no effect, do not use.

    Deprecated since version 1.10.0.

Returns

R – The correlation coefficient matrix of the variables.

Return type

ndarray

Notes

Due to floating point rounding the resulting array may not be Hermitian, the diagonal elements may not be 1, and the elements may not satisfy the inequality abs(a) <= 1. The real and imaginary parts are clipped to the interval [-1, 1] in an attempt to improve on that situation but is not much help in the complex case.

This function accepts but discards arguments bias and ddof. This is for backwards compatibility with previous versions of this function. These arguments had no effect on the return values of the function and can be safely ignored in this and previous versions of numpy.

cos(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

Cosine element-wise.

This docstring was copied from numpy.cos

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Input array in radians.

Returns

y – The corresponding cosine values. This is a scalar if x is a scalar.

Return type

ndarray

cosh(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

Hyperbolic cosine, element-wise.

This docstring was copied from numpy.cosh

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Input array.

Returns

out – Output array of same shape as x. This is a scalar if x is a scalar.

Return type

ndarray or scalar

count_nonzero(a: Union[Scalar, Array, MaskedArray], axis: Optional[Int] = None) → Union[Scalar, Array, MaskedArray]

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

This docstring was copied from numpy.count_nonzero

Some inconsistencies with the Workflows version may exist

The word “non-zero” is in reference to the Python 2.x built-in method __nonzero__() (renamed __bool__() in Python 3.x) of Python objects that tests an object’s “truthfulness”. For example, any number is considered truthful if it is nonzero, whereas any string is considered truthful if it is not the empty string. Thus, this function (recursively) counts how many elements in a (and in sub-arrays thereof) have their __nonzero__() or __bool__() method evaluated to True.

Parameters
  • a (array_like) – The array for which to count non-zeros.

  • axis (int or tuple, optional) –

    Axis or tuple of axes along which to count non-zeros. Default is None, meaning that non-zeros will be counted along a flattened version of a.

    New in version 1.12.0.

Returns

count – Number of non-zero values in the array along a given axis. Otherwise, the total number of non-zero values in the array is returned.

Return type

int or array of int

cov(m: Union[Array, MaskedArray], y: Union[NoneType, Array, MaskedArray] = None, rowvar: Bool = True, bias: Bool = False, ddof: Optional[Int] = None, fweights: Union[NoneType, Array, Int] = None, aweights: Optional[Array] = None) → Union[Array, MaskedArray]

Estimate a covariance matrix, given data and weights.

This docstring was copied from numpy.cov

Some inconsistencies with the Workflows version may exist

Covariance indicates the level to which two variables vary together. If we examine N-dimensional samples, \(X = [x_1, x_2, ... x_N]^T\), then the covariance matrix element \(C_{ij}\) is the covariance of \(x_i\) and \(x_j\). The element \(C_{ii}\) is the variance of \(x_i\).

See the notes for an outline of the algorithm.

Parameters
  • m (array_like) – A 1-D or 2-D array containing multiple variables and observations. Each row of m represents a variable, and each column a single observation of all those variables. Also see rowvar below.

  • y (array_like, optional) – An additional set of variables and observations. y has the same form as that of m.

  • rowvar (bool, optional) – If rowvar is True (default), then each row represents a variable, with observations in the columns. Otherwise, the relationship is transposed: each column represents a variable, while the rows contain observations.

  • bias (bool, optional) – Default normalization (False) is by (N - 1), where N is the number of observations given (unbiased estimate). If bias is True, then normalization is by N. These values can be overridden by using the keyword ddof in numpy versions >= 1.5.

  • ddof (int, optional) –

    If not None the default value implied by bias is overridden. Note that ddof=1 will return the unbiased estimate, even if both fweights and aweights are specified, and ddof=0 will return the simple average. See the notes for the details. The default value is None.

    New in version 1.5.

  • fweights (array_like, int, optional) –

    1-D array of integer frequency weights; the number of times each observation vector should be repeated.

    New in version 1.10.

  • aweights (array_like, optional) –

    1-D array of observation vector weights. These relative weights are typically large for observations considered “important” and smaller for observations considered less “important”. If ddof=0 the array of weights can be used to assign probabilities to observation vectors.

    New in version 1.10.

Returns

out – The covariance matrix of the variables.

Return type

ndarray

Notes

Assume that the observations are in the columns of the observation array m and let f = fweights and a = aweights for brevity. The steps to compute the weighted covariance are as follows:

>>> m = np.arange(10, dtype=np.float64)
>>> f = np.arange(10) * 2
>>> a = np.arange(10) ** 2.
>>> ddof = 1
>>> w = f * a
>>> v1 = np.sum(w)
>>> v2 = np.sum(w * a)
>>> m -= np.sum(m - w, axis=None, keepdims=True) / v1
>>> cov = np.dot(m - w, m.T) * v1 / (v1**2 - ddof * v2)

Note that when a == 1, the normalization factor v1 / (v1**2 - ddof * v2) goes over to 1 / (np.sum(f) - ddof) as it should.

cumprod(a: Union[Scalar, Array, MaskedArray], axis: Optional[Int] = None, dtype: Optional[DType] = None) → Union[Array, MaskedArray]

Return the cumulative product of elements along a given axis.

This docstring was copied from numpy.cumprod

Some inconsistencies with the Workflows version may exist

Parameters
  • a (array_like) – Input array.

  • axis (int, optional) – Axis along which the cumulative product is computed. By default the input is flattened.

  • dtype (dtype, optional) – Type of the returned array, as well as of the accumulator in which the elements are multiplied. If dtype is not specified, it defaults to the dtype of a, unless a has an integer dtype with a precision less than that of the default platform integer. In that case, the default platform integer is used instead.

  • out (ndarray, optional) – Alternative output array in which to place the result. It must have the same shape and buffer length as the expected output but the type of the resulting values will be cast if necessary.

Returns

cumprod – A new array holding the result is returned unless out is specified, in which case a reference to out is returned.

Return type

ndarray

Notes

Arithmetic is modular when using integer types, and no error is raised on overflow.

cumsum(a: Union[Scalar, Array, MaskedArray], axis: Optional[Int] = None, dtype: Optional[DType] = None) → Union[Array, MaskedArray]

Return the cumulative sum of the elements along a given axis.

This docstring was copied from numpy.cumsum

Some inconsistencies with the Workflows version may exist

Parameters
  • a (array_like) – Input array.

  • axis (int, optional) – Axis along which the cumulative sum is computed. The default (None) is to compute the cumsum over the flattened array.

  • dtype (dtype, optional) – Type of the returned array and of the accumulator in which the elements are summed. If dtype is not specified, it defaults to the dtype of a, unless a has an integer dtype with a precision less than that of the default platform integer. In that case, the default platform integer is used.

  • out (ndarray, optional) – Alternative output array in which to place the result. It must have the same shape and buffer length as the expected output but the type will be cast if necessary. See ufuncs-output-type for more details.

Returns

  • cumsum_along_axis (ndarray.) – A new array holding the result is returned unless out is specified, in which case a reference to out is returned. The result has the same size as a, and the same shape as a if axis is not None or a is a 1-d array.

  • trapz (Integration of array values using the composite trapezoidal rule.)

  • diff (Calculate the n-th discrete difference along given axis.)

Notes

Arithmetic is modular when using integer types, and no error is raised on overflow.

deg2rad(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

Convert angles from degrees to radians.

This docstring was copied from numpy.deg2rad

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Angles in degrees.

Returns

y – The corresponding angle in radians. This is a scalar if x is a scalar.

Return type

ndarray

degrees(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

Convert angles from radians to degrees.

This docstring was copied from numpy.degrees

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Input array in radians.

Returns

y – The corresponding degree values; if out was supplied this is a reference to it. This is a scalar if x is a scalar.

Return type

ndarray of floats

diag(v: Union[Array, MaskedArray]) → Array

Extract a diagonal or construct a diagonal array.

This docstring was copied from numpy.diag

Some inconsistencies with the Workflows version may exist

See the more detailed documentation for numpy.diagonal if you use this function to extract a diagonal and wish to write to the resulting array; whether it returns a copy or a view depends on what version of numpy you are using.

Parameters
  • v (array_like) – If v is a 2-D array, return a copy of its k-th diagonal. If v is a 1-D array, return a 2-D array with v on the k-th diagonal.

  • k (int, optional) – Diagonal in question. The default is 0. Use k>0 for diagonals above the main diagonal, and k<0 for diagonals below the main diagonal.

Returns

out – The extracted diagonal or constructed diagonal array.

Return type

ndarray

diagonal(a: Union[Array, MaskedArray], offset: Int = 0, axis1: Int = 0, axis2: Int = 1) → Union[Array, MaskedArray]

Return specified diagonals.

This docstring was copied from numpy.diagonal

Some inconsistencies with the Workflows version may exist

If a is 2-D, returns the diagonal of a with the given offset, i.e., the collection of elements of the form a[i, i+offset]. If a has more than two dimensions, then the axes specified by axis1 and axis2 are used to determine the 2-D sub-array whose diagonal is returned. The shape of the resulting array can be determined by removing axis1 and axis2 and appending an index to the right equal to the size of the resulting diagonals.

In versions of NumPy prior to 1.7, this function always returned a new, independent array containing a copy of the values in the diagonal.

In NumPy 1.7 and 1.8, it continues to return a copy of the diagonal, but depending on this fact is deprecated. Writing to the resulting array continues to work as it used to, but a FutureWarning is issued.

Starting in NumPy 1.9 it returns a read-only view on the original array. Attempting to write to the resulting array will produce an error.

In some future release, it will return a read/write view and writing to the returned array will alter your original array. The returned array will have the same type as the input array.

If you don’t write to the array returned by this function, then you can just ignore all of the above.

If you depend on the current behavior, then we suggest copying the returned array explicitly, i.e., use np.diagonal(a).copy() instead of just np.diagonal(a). This will work with both past and future versions of NumPy.

Parameters
  • a (array_like) – Array from which the diagonals are taken.

  • offset (int, optional) – Offset of the diagonal from the main diagonal. Can be positive or negative. Defaults to main diagonal (0).

  • axis1 (int, optional) – Axis to be used as the first axis of the 2-D sub-arrays from which the diagonals should be taken. Defaults to first axis (0).

  • axis2 (int, optional) – Axis to be used as the second axis of the 2-D sub-arrays from which the diagonals should be taken. Defaults to second axis (1).

Returns

array_of_diagonals – If a is 2-D, then a 1-D array containing the diagonal and of the same type as a is returned unless a is a matrix, in which case a 1-D array rather than a (2-D) matrix is returned in order to maintain backward compatibility.

If a.ndim > 2, then the dimensions specified by axis1 and axis2 are removed, and a new axis inserted at the end corresponding to the diagonal.

Return type

ndarray

diff(a: Union[Array, MaskedArray], n: Int = 1, axis: Int = -1) → Union[Array, MaskedArray]

Calculate the n-th discrete difference along the given axis.

This docstring was copied from numpy.diff

Some inconsistencies with the Workflows version may exist

The first difference is given by out[i] = a[i+1] - a[i] along the given axis, higher differences are calculated by using diff recursively.

Parameters
  • a (array_like) – Input array

  • n (int, optional) – The number of times values are differenced. If zero, the input is returned as-is.

  • axis (int, optional) – The axis along which the difference is taken, default is the last axis.

  • append (prepend,) –

    Values to prepend or append to a along axis prior to performing the difference. Scalar values are expanded to arrays with length 1 in the direction of axis and the shape of the input array in along all other axes. Otherwise the dimension and shape must match a except along axis.

    New in version 1.16.0.

Returns

diff – The n-th differences. The shape of the output is the same as a except along axis where the dimension is smaller by n. The type of the output is the same as the type of the difference between any two elements of a. This is the same as the type of a in most cases. A notable exception is datetime64, which results in a timedelta64 output array.

Return type

ndarray

Notes

Type is preserved for boolean arrays, so the result will contain False when consecutive elements are the same and True when they differ.

For unsigned integer arrays, the results will also be unsigned. This should not be surprising, as the result is consistent with calculating the difference directly:

>>> u8_arr = np.array([1, 0], dtype=np.uint8)
>>> np.diff(u8_arr)
array([255], dtype=uint8)
>>> u8_arr[1,...] - u8_arr[0,...]
255

If this is not desirable, then the array should be cast to a larger integer type first:

>>> i16_arr = u8_arr.astype(np.int16)
>>> np.diff(i16_arr)
array([-1], dtype=int16)
digitize(x: Union[Scalar, Array, MaskedArray], bins: Union[Array, MaskedArray], right: Bool = False) → Union[Scalar, Array]

Return the indices of the bins to which each value in input array belongs.

This docstring was copied from numpy.digitize

Some inconsistencies with the Workflows version may exist

right

order of bins

returned index i satisfies

False

increasing

bins[i-1] <= x < bins[i]

True

increasing

bins[i-1] < x <= bins[i]

False

decreasing

bins[i-1] > x >= bins[i]

True

decreasing

bins[i-1] >= x > bins[i]

If values in x are beyond the bounds of bins, 0 or len(bins) is returned as appropriate.

Parameters
  • x (array_like) – Input array to be binned. Prior to NumPy 1.10.0, this array had to be 1-dimensional, but can now have any shape.

  • bins (array_like) – Array of bins. It has to be 1-dimensional and monotonic.

  • right (bool, optional) – Indicating whether the intervals include the right or the left bin edge. Default behavior is (right==False) indicating that the interval does not include the right edge. The left bin end is open in this case, i.e., bins[i-1] <= x < bins[i] is the default behavior for monotonically increasing bins.

Returns

indices – Output array of indices, of same shape as x.

Return type

ndarray of ints

Notes

If values in x are such that they fall outside the bin range, attempting to index bins with the indices that digitize returns will result in an IndexError.

New in version 1.10.0.

np.digitize is implemented in terms of np.searchsorted. This means that a binary search is used to bin the values, which scales much better for larger number of bins than the previous linear search. It also removes the requirement for the input array to be 1-dimensional.

For monotonically _increasing_ bins, the following are equivalent:

np.digitize(x, bins, right=True)
np.searchsorted(bins, x, side='left')

Note that as the order of the arguments are reversed, the side must be too. The searchsorted call is marginally faster, as it does not do any monotonicity checks. Perhaps more importantly, it supports all dtypes.

divide(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Union[Scalar, Int, Array, Bool, Float, MaskedArray]

Returns a true division of the inputs, element-wise.

This docstring was copied from numpy.true_divide

Some inconsistencies with the Workflows version may exist

Parameters
  • x1 (array_like) – Dividend array.

  • x2 (array_like) – Divisor array. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

out – This is a scalar if both x1 and x2 are scalars.

Return type

ndarray or scalar

dot(a: Union[Scalar, Array, MaskedArray], b: Union[Scalar, Array, MaskedArray]) → Union[Scalar, Array, MaskedArray]

Dot product of two arrays. Specifically,

This docstring was copied from numpy.dot

Some inconsistencies with the Workflows version may exist

  • If both a and b are 1-D arrays, it is inner product of vectors (without complex conjugation).

  • If both a and b are 2-D arrays, it is matrix multiplication, but using matmul() or a @ b is preferred.

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

  • If a is an N-D array and b is a 1-D array, it is a sum product over the last axis of a and b.

  • If a is an N-D array and b is an M-D array (where M>=2), it is a sum product over the last axis of a and the second-to-last axis of b:

    dot(a, b)[i,j,k,m] = sum(a[i,j,:] * b[k,:,m])
    
Parameters
  • a (array_like) – First argument.

  • b (array_like) – Second argument.

  • out (ndarray, optional) – Output argument. This must have the exact kind that would be returned if it was not used. In particular, it must have the right type, must be C-contiguous, and its dtype must be the dtype that would be returned for dot(a,b). This is a performance feature. Therefore, if these conditions are not met, an exception is raised, instead of attempting to be flexible.

Returns

output – Returns the dot product of a and b. If a and b are both scalars or both 1-D arrays then a scalar is returned; otherwise an array is returned. If out is given, then it is returned.

Return type

ndarray

dstack(arrays: Union[List[Array], List[MaskedArray]]) → Union[Array, MaskedArray]

Stack arrays in sequence depth wise (along third axis).

This docstring was copied from numpy.dstack

Some inconsistencies with the Workflows version may exist

This is equivalent to concatenation along the third axis after 2-D arrays of shape (M,N) have been reshaped to (M,N,1) and 1-D arrays of shape (N,) have been reshaped to (1,N,1). Rebuilds arrays divided by dsplit.

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.

Parameters

tup (sequence of arrays) – The arrays must have the same shape along all but the third axis. 1-D or 2-D arrays must have the same shape.

Returns

stacked – The array formed by stacking the given arrays, will be at least 3-D.

Return type

ndarray

ediff1d(ary: Union[Scalar, Array, MaskedArray], to_end: Union[NoneType, Scalar, Array, MaskedArray] = None, to_begin: Union[NoneType, Scalar, Array, MaskedArray] = None) → Union[Array, MaskedArray]

The differences between consecutive elements of an array.

This docstring was copied from numpy.ediff1d

Some inconsistencies with the Workflows version may exist

Parameters
  • ary (array_like) – If necessary, will be flattened before the differences are taken.

  • to_end (array_like, optional) – Number(s) to append at the end of the returned differences.

  • to_begin (array_like, optional) – Number(s) to prepend at the beginning of the returned differences.

Returns

ediff1d – The differences. Loosely, this is ary.flat[1:] - ary.flat[:-1].

Return type

ndarray

Notes

When applied to masked arrays, this function drops the mask information if the to_begin and/or to_end parameters are used.

einsum(subscripts: Str, *operands: Array, dtype: Optional[DType] = None, casting: Str = 'safe', optimize: Union[Str, Bool] = False) → Array

Evaluates the Einstein summation convention on the operands.

This docstring was copied from numpy.einsum

Some inconsistencies with the Workflows version may exist

Using the Einstein summation convention, many common multi-dimensional, linear algebraic array operations can be represented in a simple fashion. In implicit mode einsum computes these values.

In explicit mode, einsum provides further flexibility to compute other array operations that might not be considered classical Einstein summation operations, by disabling, or forcing summation over specified subscript labels.

See the notes and examples for clarification.

Parameters
  • subscripts (str) – Specifies the subscripts for summation as comma separated list of subscript labels. An implicit (classical Einstein summation) calculation is performed unless the explicit indicator ‘->’ is included as well as subscript labels of the precise output form.

  • operands (list of array_like) – These are the arrays for the operation.

  • out (ndarray, optional) – If provided, the calculation is done into this array.

  • dtype ({data-type, None}, optional) – If provided, forces the calculation to use the data type specified. Note that you may have to also give a more liberal casting parameter to allow the conversions. Default is None.

  • order ({'C', 'F', 'A', 'K'}, optional) – Controls the memory layout of the output. ‘C’ means it should be C contiguous. ‘F’ means it should be Fortran contiguous, ‘A’ means it should be ‘F’ if the inputs are all ‘F’, ‘C’ otherwise. ‘K’ means it should be as close to the layout as the inputs as is possible, including arbitrarily permuted axes. Default is ‘K’.

  • casting ({'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional) –

    Controls what kind of data casting may occur. Setting this to ‘unsafe’ is not recommended, as it can adversely affect accumulations.

    • ’no’ means the data types should not be cast at all.

    • ’equiv’ means only byte-order changes are allowed.

    • ’safe’ means only casts which can preserve values are allowed.

    • ’same_kind’ means only safe casts or casts within a kind, like float64 to float32, are allowed.

    • ’unsafe’ means any data conversions may be done.

    Default is ‘safe’.

  • optimize ({False, True, 'greedy', 'optimal'}, optional) – Controls if intermediate optimization should occur. No optimization will occur if False and True will default to the ‘greedy’ algorithm. Also accepts an explicit contraction list from the np.einsum_path function. See np.einsum_path for more details. Defaults to False.

Returns

output – The calculation based on the Einstein summation convention.

Return type

ndarray

Notes

New in version 1.6.0.

The Einstein summation convention can be used to compute many multi-dimensional, linear algebraic array operations. einsum provides a succinct way of representing these.

A non-exhaustive list of these operations, which can be computed by einsum, is shown below along with examples:

  • Trace of an array, numpy.trace().

  • Return a diagonal, numpy.diag().

  • Array axis summations, numpy.sum().

  • Transpositions and permutations, numpy.transpose().

  • Matrix multiplication and dot product, numpy.matmul() numpy.dot().

  • Vector inner and outer products, numpy.inner() numpy.outer().

  • Broadcasting, element-wise and scalar multiplication, numpy.multiply().

  • Tensor contractions, numpy.tensordot().

  • Chained array operations, in efficient calculation order, numpy.einsum_path().

The subscripts string is a comma-separated list of subscript labels, where each label refers to a dimension of the corresponding operand. Whenever a label is repeated it is summed, so np.einsum('i,i', a, b) is equivalent to np.inner(a,b). If a label appears only once, it is not summed, so np.einsum('i', a) produces a view of a with no changes. A further example np.einsum('ij,jk', a, b) describes traditional matrix multiplication and is equivalent to np.matmul(a,b). Repeated subscript labels in one operand take the diagonal. For example, np.einsum('ii', a) is equivalent to np.trace(a).

In implicit mode, the chosen subscripts are important since the axes of the output are reordered alphabetically. This means that np.einsum('ij', a) doesn’t affect a 2D array, while np.einsum('ji', a) takes its transpose. Additionally, np.einsum('ij,jk', a, b) returns a matrix multiplication, while, np.einsum('ij,jh', a, b) returns the transpose of the multiplication since subscript ‘h’ precedes subscript ‘i’.

In explicit mode the output can be directly controlled by specifying output subscript labels. This requires the identifier ‘->’ as well as the list of output subscript labels. This feature increases the flexibility of the function since summing can be disabled or forced when required. The call np.einsum('i->', a) is like np.sum(a, axis=-1), and np.einsum('ii->i', a) is like np.diag(a). The difference is that einsum does not allow broadcasting by default. Additionally np.einsum('ij,jh->ih', a, b) directly specifies the order of the output subscript labels and therefore returns matrix multiplication, unlike the example above in implicit mode.

To enable and control broadcasting, use an ellipsis. Default NumPy-style broadcasting is done by adding an ellipsis to the left of each term, like np.einsum('...ii->...i', a). To take the trace along the first and last axes, you can do np.einsum('i...i', a), or to do a matrix-matrix product with the left-most indices instead of rightmost, one can do np.einsum('ij...,jk...->ik...', a, b).

When there is only one operand, no axes are summed, and no output parameter is provided, a view into the operand is returned instead of a new array. Thus, taking the diagonal as np.einsum('ii->i', a) produces a view (changed in version 1.10.0).

einsum also provides an alternative way to provide the subscripts and operands as einsum(op0, sublist0, op1, sublist1, ..., [sublistout]). If the output shape is not provided in this format einsum will be calculated in implicit mode, otherwise it will be performed explicitly. The examples below have corresponding einsum calls with the two parameter methods.

New in version 1.10.0.

Views returned from einsum are now writeable whenever the input array is writeable. For example, np.einsum('ijk...->kji...', a) will now have the same effect as np.swapaxes(a, 0, 2) and np.einsum('ii->i', a) will return a writeable view of the diagonal of a 2D array.

New in version 1.12.0.

Added the optimize argument which will optimize the contraction order of an einsum expression. For a contraction with three or more operands this can greatly increase the computational efficiency at the cost of a larger memory footprint during computation.

Typically a ‘greedy’ algorithm is applied which empirical tests have shown returns the optimal path in the majority of cases. In some cases ‘optimal’ will return the superlative path through a more expensive, exhaustive search. For iterative calculations it may be advisable to calculate the optimal path once and reuse that path by supplying it as an argument. An example is given below.

See numpy.einsum_path() for more details.

equal(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Bool

Return (x1 == x2) element-wise.

This docstring was copied from numpy.equal

Some inconsistencies with the Workflows version may exist

Parameters

x2 (x1,) – Input arrays. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

out – Output array, element-wise comparison of x1 and x2. Typically of type bool, unless dtype=object is passed. This is a scalar if both x1 and x2 are scalars.

Return type

ndarray or scalar

exp(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

Calculate the exponential of all elements in the input array.

This docstring was copied from numpy.exp

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Input values.

Returns

out – Output array, element-wise exponential of x. This is a scalar if x is a scalar.

Return type

ndarray or scalar

exp2(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

Calculate 2**p for all p in the input array.

This docstring was copied from numpy.exp2

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Input values.

Returns

out – Element-wise 2 to the power x. This is a scalar if x is a scalar.

Return type

ndarray or scalar

expm1(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

Calculate exp(x) - 1 for all elements in the array.

This docstring was copied from numpy.expm1

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Input values.

Returns

out – Element-wise exponential minus one: out = exp(x) - 1. This is a scalar if x is a scalar.

Return type

ndarray or scalar

eye(N: Int, M: Optional[Int] = None, k: Int = 0, dtype: DType = <descarteslabs.workflows.types.array.dtype.DType object>) → Array

Return a 2-D array with ones on the diagonal and zeros elsewhere.

This docstring was copied from numpy.eye

Some inconsistencies with the Workflows version may exist

Parameters
  • N (int) – Number of rows in the output.

  • M (int, optional) – Number of columns in the output. If None, defaults to N.

  • k (int, optional) – 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.

  • dtype (data-type, optional) – Data-type of the returned array.

  • order ({'C', 'F'}, optional) –

    Whether the output should be stored in row-major (C-style) or column-major (Fortran-style) order in memory.

    New in version 1.14.0.

Returns

I – An array where all elements are equal to zero, except for the k-th diagonal, whose values are equal to one.

Return type

ndarray of shape (N,M)

fabs(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

Compute the absolute values element-wise.

This docstring was copied from numpy.fabs

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – The array of numbers for which the absolute values are required. If

Returns

y – The absolute values of x, the returned values are always floats. This is a scalar if x is a scalar.

Return type

ndarray or scalar

fix(x: Union[Scalar, Array, MaskedArray]) → Union[Scalar, Array, MaskedArray]

Round to nearest integer towards zero.

This docstring was copied from numpy.fix

Some inconsistencies with the Workflows version may exist

Round an array of floats element-wise to nearest integer towards zero. The rounded values are returned as floats.

Parameters
  • x (array_like) – An array of floats to be rounded

  • y (ndarray, optional) – Output array

Returns

out – The array of rounded numbers

Return type

ndarray of floats

flatnonzero(a: Union[Array, Scalar, MaskedArray]) → Array

Return indices that are non-zero in the flattened version of a.

This docstring was copied from numpy.flatnonzero

Some inconsistencies with the Workflows version may exist

This is equivalent to np.nonzero(np.ravel(a))[0].

Parameters

a (array_like) – Input data.

Returns

res – Output array, containing the indices of the elements of a.ravel() that are non-zero.

Return type

ndarray

float_power(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

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

This docstring was copied from numpy.float_power

Some inconsistencies with the Workflows version may exist

Parameters
  • x1 (array_like) – The bases.

  • x2 (array_like) – The exponents. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

y – The bases in x1 raised to the exponents in x2. This is a scalar if both x1 and x2 are scalars.

Return type

ndarray

floor(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Union[Scalar, Int, Array, Bool, Float, MaskedArray]

Return the floor of the input, element-wise.

This docstring was copied from numpy.floor

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Input data.

Returns

y – The floor of each element in x. This is a scalar if x is a scalar.

Return type

ndarray or scalar

floor_divide(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Union[Scalar, Int, Array, Bool, Float, MaskedArray]

Return the largest integer smaller or equal to the division of the inputs. It is equivalent to the Python // operator and pairs with the Python % (remainder), function so that a = a % b + b * (a // b) up to roundoff.

This docstring was copied from numpy.floor_divide

Some inconsistencies with the Workflows version may exist

Parameters
  • x1 (array_like) – Numerator.

  • x2 (array_like) – Denominator. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

y – y = floor(x1/x2) This is a scalar if both x1 and x2 are scalars.

Return type

ndarray

fmax(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Union[Scalar, Int, Array, Bool, Float, MaskedArray]

Element-wise maximum of array elements.

This docstring was copied from numpy.fmax

Some inconsistencies with the Workflows version may exist

Parameters

x2 (x1,) – The arrays holding the elements to be compared. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

y – The maximum of x1 and x2, element-wise. This is a scalar if both x1 and x2 are scalars.

Return type

ndarray or scalar

fmin(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Union[Scalar, Int, Array, Bool, Float, MaskedArray]

Element-wise minimum of array elements.

This docstring was copied from numpy.fmin

Some inconsistencies with the Workflows version may exist

Parameters

x2 (x1,) – The arrays holding the elements to be compared. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

y – The minimum of x1 and x2, element-wise. This is a scalar if both x1 and x2 are scalars.

Return type

ndarray or scalar

fmod(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Union[Scalar, Int, Array, Bool, Float, MaskedArray]

Return the element-wise remainder of division.

This docstring was copied from numpy.fmod

Some inconsistencies with the Workflows version may exist

Parameters
  • x1 (array_like) – Dividend.

  • x2 (array_like) – Divisor. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

y – The remainder of the division of x1 by x2. This is a scalar if both x1 and x2 are scalars.

Return type

array_like

full(shape: Union[List[Int], Int], fill_value: Union[Scalar, Int, Array, Bool, Float, MaskedArray], dtype: Optional[DType] = None) → Array

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

This docstring was copied from numpy.full

Some inconsistencies with the Workflows version may exist

Parameters
  • shape (int or sequence of ints) – Shape of the new array, e.g., (2, 3) or 2.

  • fill_value (scalar) – Fill value.

  • dtype (data-type, optional) –

    The desired data-type for the array The default, None, means

    np.array(fill_value).dtype.

  • order ({'C', 'F'}, optional) – Whether to store multidimensional data in C- or Fortran-contiguous (row- or column-wise) order in memory.

Returns

out – Array of fill_value with the given shape, dtype, and order.

Return type

ndarray

full_like(a: Union[Array, Scalar, MaskedArray], fill_value: Union[Scalar, Int, Array, Bool, Float, MaskedArray], dtype: Optional[DType] = None) → Array

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

This docstring was copied from numpy.full_like

Some inconsistencies with the Workflows version may exist

Parameters
  • a (array_like) – The shape and data-type of a define these same attributes of the returned array.

  • fill_value (scalar) – Fill value.

  • dtype (data-type, optional) – Overrides the data type of the result.

  • order ({'C', 'F', 'A', or 'K'}, optional) – Overrides the memory layout of the result. ‘C’ means C-order, ‘F’ means F-order, ‘A’ means ‘F’ if a is Fortran contiguous, ‘C’ otherwise. ‘K’ means match the layout of a as closely as possible.

  • subok (bool, optional.) – If True, then the newly created array will use the sub-class type of ‘a’, otherwise it will be a base-class array. Defaults to True.

  • shape (int or sequence of ints, optional.) –

    Overrides the shape of the result. If order=’K’ and the number of dimensions is unchanged, will try to keep order, otherwise, order=’C’ is implied.

    New in version 1.17.0.

Returns

out – Array of fill_value with the same shape and type as a.

Return type

ndarray

gradient(f: Union[Array, MaskedArray], *varargs: Union[Array, List[Int], Int], edge_order: Int = 1, axis: Optional[Int] = None) → Union[List[Array], List[MaskedArray]]

Return the gradient of an N-dimensional array.

This docstring was copied from numpy.gradient

Some inconsistencies with the Workflows version may exist

The gradient is computed using second order accurate central differences in the interior points and either first or second order accurate one-sides (forward or backwards) differences at the boundaries. The returned gradient hence has the same shape as the input array.

Parameters
  • f (array_like) – An N-dimensional array containing samples of a scalar function.

  • varargs (list of scalar or array, optional) –

    Spacing between f values. Default unitary spacing for all dimensions. Spacing can be specified using:

    1. single scalar to specify a sample distance for all dimensions.

    2. N scalars to specify a constant sample distance for each dimension. i.e. dx, dy, dz, …

    3. N arrays to specify the coordinates of the values along each dimension of F. The length of the array must match the size of the corresponding dimension

    4. Any combination of N scalars/arrays with the meaning of 2. and 3.

    If axis is given, the number of varargs must equal the number of axes. Default: 1.

  • edge_order ({1, 2}, optional) –

    Gradient is calculated using N-th order accurate differences at the boundaries. Default: 1.

    New in version 1.9.1.

  • axis (None or int or tuple of ints, optional) –

    Gradient is calculated only along the given axis or axes The default (axis = None) is to calculate the gradient for all the axes of the input array. axis may be negative, in which case it counts from the last to the first axis.

    New in version 1.11.0.

Returns

gradient – A set of ndarrays (or a single ndarray if there is only one dimension) corresponding to the derivatives of f with respect to each dimension. Each derivative has the same shape as f.

Return type

ndarray or list of ndarray

greater(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Bool

Return the truth value of (x1 > x2) element-wise.

This docstring was copied from numpy.greater

Some inconsistencies with the Workflows version may exist

Parameters

x2 (x1,) – Input arrays. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

out – Output array, element-wise comparison of x1 and x2. Typically of type bool, unless dtype=object is passed. This is a scalar if both x1 and x2 are scalars.

Return type

ndarray or scalar

greater_equal(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Bool

Return the truth value of (x1 >= x2) element-wise.

This docstring was copied from numpy.greater_equal

Some inconsistencies with the Workflows version may exist

Parameters

x2 (x1,) – Input arrays. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

out – Output array, element-wise comparison of x1 and x2. Typically of type bool, unless dtype=object is passed. This is a scalar if both x1 and x2 are scalars.

Return type

bool or ndarray of bool

histogram(a: Array, bins: Union[List[Scalar], List[Int], List[Float], Int, Array] = 10, range: Union[Tuple[Int, Int], Tuple[Float, Float], Tuple[Float, Scalar], Tuple[Scalar, Scalar], Tuple[Scalar, Float], Tuple[Scalar, Int], Tuple[Int, Scalar], NoneType] = None, weights: Optional[Array] = None, density: Optional[Bool] = None) → Tuple[Array, Array]

Compute the histogram of a set of data.

This docstring was copied from numpy.histogram

Some inconsistencies with the Workflows version may exist

Parameters
  • a (array_like) – Input data. The histogram is computed over the flattened array.

  • bins (int or sequence of scalars or str, optional) –

    If bins is an int, it defines the number of equal-width bins in the given range (10, by default). If bins is a sequence, it defines a monotonically increasing array of bin edges, including the rightmost edge, allowing for non-uniform bin widths.

    New in version 1.11.0.

    If bins is a string, it defines the method used to calculate the optimal bin width, as defined by histogram_bin_edges.

  • range ((float, float), optional) – The lower and upper range of the bins. If not provided, range is simply (a.min(), a.max()). Values outside the range are ignored. The first element of the range must be less than or equal to the second. range affects the automatic bin computation as well. While bin width is computed to be optimal based on the actual data within range, the bin count will fill the entire range including portions containing no data.

  • normed (bool, optional) –

    Deprecated since version 1.6.0.

    This is equivalent to the density argument, but produces incorrect results for unequal bin widths. It should not be used.

    Changed in version 1.15.0: DeprecationWarnings are actually emitted.

  • weights (array_like, optional) – An array of weights, of the same shape as a. Each value in a only contributes its associated weight towards the bin count (instead of 1). If density is True, the weights are normalized, so that the integral of the density over the range remains 1.

  • density (bool, optional) –

    If False, the result will contain the number of samples in each bin. If True, the result is the value of the probability density function at the bin, normalized such that the integral over the range is 1. Note that the sum of the histogram values will not be equal to 1 unless bins of unity width are chosen; it is not a probability mass function.

    Overrides the normed keyword if given.

Returns

  • hist (array) – The values of the histogram. See density and weights for a description of the possible semantics.

  • bin_edges (array of dtype float) – Return the bin edges (length(hist)+1).

Notes

All but the last (righthand-most) bin is half-open. In other words, if bins is:

[1, 2, 3, 4]

then the first bin is [1, 2) (including 1, but excluding 2) and the second [2, 3). The last bin, however, is [3, 4], which includes 4.

hstack(arrays: Union[List[Array], List[MaskedArray]]) → Union[Array, MaskedArray]

Stack arrays in sequence horizontally (column wise).

This docstring was copied from numpy.hstack

Some inconsistencies with the Workflows version may exist

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.

Parameters

tup (sequence of ndarrays) – The arrays must have the same shape along all but the second axis, except 1-D arrays which can be any length.

Returns

stacked – The array formed by stacking the given arrays.

Return type

ndarray

hypot(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Union[Scalar, Int, Array, Bool, Float, MaskedArray]

Given the “legs” of a right triangle, return its hypotenuse.

This docstring was copied from numpy.hypot

Some inconsistencies with the Workflows version may exist

Parameters

x2 (x1,) – Leg of the triangle(s). If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

z – The hypotenuse of the triangle(s). This is a scalar if both x1 and x2 are scalars.

Return type

ndarray

imag(val: Union[Scalar, Array, MaskedArray]) → Union[Array, MaskedArray]

Return the imaginary part of the complex argument.

This docstring was copied from numpy.imag

Some inconsistencies with the Workflows version may exist

Parameters

val (array_like) – Input array.

Returns

out – The imaginary component of the complex argument. If val is real, the type of val is used for the output. If val has complex elements, the returned type is float.

Return type

ndarray or scalar

indices(dimensions: Union[List[Bool], List[Int], List[Float]], dtype: DType = <descarteslabs.workflows.types.array.dtype.DType object>) → Array

Return an array representing the indices of a grid.

This docstring was copied from numpy.indices

Some inconsistencies with the Workflows version may exist

Compute an array where the subarrays contain index values 0, 1, … varying only along the corresponding axis.

Parameters
  • dimensions (sequence of ints) – The shape of the grid.

  • dtype (dtype, optional) – Data type of the result.

  • sparse (boolean, optional) –

    Return a sparse representation of the grid instead of a dense representation. Default is False.

    New in version 1.17.

Returns

grid

If sparse is False:

Returns one array of grid indices, grid.shape = (len(dimensions),) + tuple(dimensions).

If sparse is True:

Returns a tuple of arrays, with grid[i].shape = (1, ..., 1, dimensions[i], 1, ..., 1) with dimensions[i] in the ith place

Return type

one ndarray or tuple of ndarrays

Notes

The output shape in the dense case is obtained by prepending the number of dimensions in front of the tuple of dimensions, i.e. if dimensions is a tuple (r0, ..., rN-1) of length N, the output shape is (N, r0, ..., rN-1).

The subarrays grid[k] contains the N-D array of indices along the k-th axis. Explicitly:

grid[k, i0, i1, ..., iN-1] = ik
insert(arr: Union[Array, MaskedArray], obj: Union[List[Int], Slice, Int], values: Union[Scalar, Array, MaskedArray], axis: Int) → Union[Array, MaskedArray]

Insert values along the given axis before the given indices.

This docstring was copied from numpy.insert

Some inconsistencies with the Workflows version may exist

Parameters
  • arr (array_like) – Input array.

  • obj (int, slice or sequence of ints) –

    Object that defines the index or indices before which values is inserted.

    New in version 1.8.0.

    Support for multiple insertions when obj is a single scalar or a sequence with one element (similar to calling insert multiple times).

  • values (array_like) – Values to insert into arr. If the type of values is different from that of arr, values is converted to the type of arr. values should be shaped so that arr[...,obj,...] = values is legal.

  • axis (int, optional) – Axis along which to insert values. If axis is None then arr is flattened first.

Returns

out – A copy of arr with values inserted. Note that insert does not occur in-place: a new array is returned. If axis is None, out is a flattened array.

Return type

ndarray

Notes

Note that for higher dimensional inserts obj=0 behaves very different from obj=[0] just like arr[:,0,:] = values is different from arr[:,[0],:] = values.

isclose(a: Union[Scalar, Array, MaskedArray], b: Union[Scalar, Array, MaskedArray], rtol: Union[Float, Int] = 1e-05, atol: Union[Float, Int] = 1e-08, equal_nan: Bool = False) → Union[Scalar, Array, MaskedArray]

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

This docstring was copied from numpy.isclose

Some inconsistencies with the Workflows version may exist

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.

Warning

The default atol is not appropriate for comparing numbers that are much smaller than one (see Notes).

Parameters
  • b (a,) – Input arrays to compare.

  • rtol (float) – The relative tolerance parameter (see Notes).

  • atol (float) – The absolute tolerance parameter (see Notes).

  • equal_nan (bool) – Whether to compare NaN’s as equal. If True, NaN’s in a will be considered equal to NaN’s in b in the output array.

Returns

y – Returns a boolean array of where a and b are equal within the given tolerance. If both a and b are scalars, returns a single boolean value.

Return type

array_like

Notes

New in version 1.7.0.

For finite values, isclose uses the following equation to test whether two floating point values are equivalent.

absolute(a - b) <= (atol + rtol * absolute(b))

Unlike the built-in math.isclose, the above equation is not symmetric in a and b – it assumes b is the reference value – so that isclose(a, b) might be different from isclose(b, a). Furthermore, the default value of atol is not zero, and is used to determine what small values should be considered close to zero. The default value is appropriate for expected values of order unity: if the expected values are significantly smaller than one, it can result in false positives. atol should be carefully selected for the use case at hand. A zero value for atol will result in False if either a or b is zero.

isfinite(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Bool

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

This docstring was copied from numpy.isfinite

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Input values.

Returns

y – True where x is not positive infinity, negative infinity, or NaN; false otherwise. This is a scalar if x is a scalar.

Return type

ndarray, bool

isin(element: Union[Scalar, Array, MaskedArray], test_elements: Union[Scalar, Array, MaskedArray], assume_unique: Bool = False, invert: Bool = False) → Union[Scalar, Array]

Calculates element in test_elements, broadcasting over element only. Returns a boolean array of the same shape as element that is True where an element of element is in test_elements and False otherwise.

This docstring was copied from numpy.isin

Some inconsistencies with the Workflows version may exist

Parameters
  • element (array_like) – Input array.

  • test_elements (array_like) – The values against which to test each value of element. This argument is flattened if it is an array or array_like. See notes for behavior with non-array-like parameters.

  • assume_unique (bool, optional) – If True, the input arrays are both assumed to be unique, which can speed up the calculation. Default is False.

  • invert (bool, optional) – If True, the values in the returned array are inverted, as if calculating element not in test_elements. Default is False. np.isin(a, b, invert=True) is equivalent to (but faster than) np.invert(np.isin(a, b)).

Returns

isin – Has the same shape as element. The values element[isin] are in test_elements.

Return type

ndarray, bool

Notes

isin is an element-wise function version of the python keyword in. isin(a, b) is roughly equivalent to np.array([item in b for item in a]) if a and b are 1-D sequences.

element and test_elements are converted to arrays if they are not already. If test_elements is a set (or other non-sequence collection) it will be converted to an object array with one element, rather than an array of the values contained in test_elements. This is a consequence of the array constructor’s way of handling non-sequence collections. Converting the set to a list usually gives the desired behavior.

New in version 1.13.0.

isinf(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Bool

Test element-wise for positive or negative infinity.

This docstring was copied from numpy.isinf

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Input values

Returns

y – True where x is positive or negative infinity, false otherwise. This is a scalar if x is a scalar.

Return type

bool (scalar) or boolean ndarray

isnan(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Bool

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

This docstring was copied from numpy.isnan

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Input array.

Returns

y – True where x is NaN, false otherwise. This is a scalar if x is a scalar.

Return type

ndarray or bool

isneginf(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Union[Array, MaskedArray, Bool]

Test element-wise for negative infinity, return result as bool array.

This docstring was copied from numpy.isneginf

Some inconsistencies with the Workflows version may exist

Parameters
  • x (array_like) – The input array.

  • out (array_like, optional) – A boolean array with the same shape and type as x to store the result.

Returns

out – A boolean array with the same dimensions as the input. If second argument is not supplied then a numpy boolean array is returned with values True where the corresponding element of the input is negative infinity and values False where the element of the input is not negative infinity.

If a second argument is supplied the result is stored there. If the type of that array is a numeric type the result is represented as zeros and ones, if the type is boolean then as False and True. The return value out is then a reference to that array.

Return type

ndarray

Notes

NumPy uses the IEEE Standard for Binary Floating-Point for Arithmetic (IEEE 754).

Errors result if the second argument is also supplied when x is a scalar input, if first and second arguments have different shapes, or if the first argument has complex values.

isposinf(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Union[Array, MaskedArray, Bool]

Test element-wise for positive infinity, return result as bool array.

This docstring was copied from numpy.isposinf

Some inconsistencies with the Workflows version may exist

Parameters
  • x (array_like) – The input array.

  • y (array_like, optional) – A boolean array with the same shape as x to store the result.

Returns

out – A boolean array with the same dimensions as the input. If second argument is not supplied then a boolean array is returned with values True where the corresponding element of the input is positive infinity and values False where the element of the input is not positive infinity.

If a second argument is supplied the result is stored there. If the type of that array is a numeric type the result is represented as zeros and ones, if the type is boolean then as False and True. The return value out is then a reference to that array.

Return type

ndarray

Notes

NumPy uses the IEEE Standard for Binary Floating-Point for Arithmetic (IEEE 754).

Errors result if the second argument is also supplied when x is a scalar input, if first and second arguments have different shapes, or if the first argument has complex values

isreal(x: Union[Scalar, Array, MaskedArray]) → Union[Scalar, Array, MaskedArray]

Returns a bool array, where True if input element is real.

This docstring was copied from numpy.isreal

Some inconsistencies with the Workflows version may exist

If element has complex type with zero complex part, the return value for that element is True.

Parameters

x (array_like) – Input array.

Returns

out – Boolean array of same shape as x.

Return type

ndarray, bool

ldexp(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Union[Scalar, Int, Array, Bool, Float, MaskedArray]

Returns x1 * 2**x2, element-wise.

This docstring was copied from numpy.ldexp

Some inconsistencies with the Workflows version may exist

Parameters
  • x1 (array_like) – Array of multipliers.

  • x2 (array_like, int) – Array of twos exponents. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

y – The result of x1 * 2**x2. This is a scalar if both x1 and x2 are scalars.

Return type

ndarray or scalar

less(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Bool

Return the truth value of (x1 < x2) element-wise.

This docstring was copied from numpy.less

Some inconsistencies with the Workflows version may exist

Parameters

x2 (x1,) – Input arrays. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

out – Output array, element-wise comparison of x1 and x2. Typically of type bool, unless dtype=object is passed. This is a scalar if both x1 and x2 are scalars.

Return type

ndarray or scalar

less_equal(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Bool

Return the truth value of (x1 =< x2) element-wise.

This docstring was copied from numpy.less_equal

Some inconsistencies with the Workflows version may exist

Parameters

x2 (x1,) – Input arrays. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

out – Output array, element-wise comparison of x1 and x2. Typically of type bool, unless dtype=object is passed. This is a scalar if both x1 and x2 are scalars.

Return type

ndarray or scalar

linspace(start: Union[Float, Int], stop: Union[Float, Int], num: Int = 50, endpoint: Bool = True, dtype: Optional[DType] = None, axis: Int = 0) → Array

Return evenly spaced numbers over a specified interval.

This docstring was copied from numpy.linspace

Some inconsistencies with the Workflows version may exist

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

The endpoint of the interval can optionally be excluded.

Changed in version 1.16.0: Non-scalar start and stop are now supported.

Parameters
  • start (array_like) – The starting value of the sequence.

  • stop (array_like) – The end value of the sequence, unless endpoint is set to False. In that case, the sequence consists of all but the last of num + 1 evenly spaced samples, so that stop is excluded. Note that the step size changes when endpoint is False.

  • num (int, optional) – Number of samples to generate. Default is 50. Must be non-negative.

  • endpoint (bool, optional) – If True, stop is the last sample. Otherwise, it is not included. Default is True.

  • retstep (bool, optional) – If True, return (samples, step), where step is the spacing between samples.

  • dtype (dtype, optional) –

    The type of the output array. If dtype is not given, infer the data type from the other input arguments.

    New in version 1.9.0.

  • axis (int, optional) –

    The axis in the result to store the samples. Relevant only if start or stop are array-like. By default (0), the samples will be along a new axis inserted at the beginning. Use -1 to get an axis at the end.

    New in version 1.16.0.

Returns

  • samples (ndarray) – There are num equally spaced samples in the closed interval [start, stop] or the half-open interval [start, stop) (depending on whether endpoint is True or False).

  • step (float, optional) – Only returned if retstep is True

    Size of spacing between samples.

log(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

Natural logarithm, element-wise.

This docstring was copied from numpy.log

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Input value.

Returns

y – The natural logarithm of x, element-wise. This is a scalar if x is a scalar.

Return type

ndarray

log10(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

Return the base 10 logarithm of the input array, element-wise.

This docstring was copied from numpy.log10

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Input values.

Returns

y – The logarithm to the base 10 of x, element-wise. NaNs are returned where x is negative. This is a scalar if x is a scalar.

Return type

ndarray

log1p(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

Return the natural logarithm of one plus the input array, element-wise.

This docstring was copied from numpy.log1p

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Input values.

Returns

y – Natural logarithm of 1 + x, element-wise. This is a scalar if x is a scalar.

Return type

ndarray

log2(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

Base-2 logarithm of x.

This docstring was copied from numpy.log2

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Input values.

Returns

y – Base-2 logarithm of x. This is a scalar if x is a scalar.

Return type

ndarray

logaddexp(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

Logarithm of the sum of exponentiations of the inputs.

This docstring was copied from numpy.logaddexp

Some inconsistencies with the Workflows version may exist

Parameters

x2 (x1,) – Input values. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

result – Logarithm of exp(x1) + exp(x2). This is a scalar if both x1 and x2 are scalars.

Return type

ndarray

logaddexp2(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

Logarithm of the sum of exponentiations of the inputs in base-2.

This docstring was copied from numpy.logaddexp2

Some inconsistencies with the Workflows version may exist

Parameters

x2 (x1,) – Input values. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

result – Base-2 logarithm of 2**x1 + 2**x2. This is a scalar if both x1 and x2 are scalars.

Return type

ndarray

logical_and(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Bool

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

This docstring was copied from numpy.logical_and

Some inconsistencies with the Workflows version may exist

Parameters

x2 (x1,) – Input arrays. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

y – Boolean result of the logical AND operation applied to the elements of x1 and x2; the shape is determined by broadcasting. This is a scalar if both x1 and x2 are scalars.

Return type

ndarray or bool

logical_not(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Bool

Compute the truth value of NOT x element-wise.

This docstring was copied from numpy.logical_not

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Logical NOT is applied to the elements of x.

Returns

y – Boolean result with the same shape as x of the NOT operation on elements of x. This is a scalar if x is a scalar.

Return type

bool or ndarray of bool

logical_or(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Bool

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

This docstring was copied from numpy.logical_or

Some inconsistencies with the Workflows version may exist

Parameters

x2 (x1,) – Logical OR is applied to the elements of x1 and x2.

Returns

y – Boolean result of the logical OR operation applied to the elements of x1 and x2; the shape is determined by broadcasting. This is a scalar if both x1 and x2 are scalars.

Return type

ndarray or bool

logical_xor(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Bool

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

This docstring was copied from numpy.logical_xor

Some inconsistencies with the Workflows version may exist

Parameters

x2 (x1,) – Logical XOR is applied to the elements of x1 and x2. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

y – Boolean result of the logical XOR operation applied to the elements of x1 and x2; the shape is determined by broadcasting. This is a scalar if both x1 and x2 are scalars.

Return type

bool or ndarray of bool

max(a: Union[Scalar, Array, MaskedArray], axis: Union[NoneType, List[Int], Int] = None) → Union[Scalar, Array, MaskedArray]

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

This docstring was copied from numpy.amax

Some inconsistencies with the Workflows version may exist

Parameters
  • a (array_like) – Input data.

  • axis (None or int or tuple of ints, optional) –

    Axis or axes along which to operate. By default, flattened input is used.

    New in version 1.7.0.

    If this is a tuple of ints, the maximum is selected over multiple axes, instead of a single axis or all the axes as before.

  • out (ndarray, optional) – Alternative output array in which to place the result. Must be of the same shape and buffer length as the expected output. See ufuncs-output-type for more details.

  • keepdims (bool, optional) –

    If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.

    If the default value is passed, then keepdims will not be passed through to the amax method of sub-classes of ndarray, however any non-default value will be. If the sub-class’ method does not implement keepdims any exceptions will be raised.

  • initial (scalar, optional) –

    The minimum value of an output element. Must be present to allow computation on empty slice. See ~numpy.ufunc.reduce for details.

    New in version 1.15.0.

  • where (array_like of bool, optional) –

    Elements to compare for the maximum. See ~numpy.ufunc.reduce for details.

    New in version 1.17.0.

Returns

  • amax (ndarray or scalar) – Maximum of a. If axis is None, the result is a scalar value. If axis is given, the result is an array of dimension a.ndim - 1.

  • nanmin, minimum, fmin

Notes

NaN values are propagated, that is if at least one item is NaN, the corresponding max value will be NaN as well. To ignore NaN values (MATLAB behavior), please use nanmax.

Don’t use amax for element-wise comparison of 2 arrays; when a.shape[0] is 2, maximum(a[0], a[1]) is faster than amax(a, axis=0).

maximum(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Union[Scalar, Int, Array, Bool, Float, MaskedArray]

Element-wise maximum of array elements.

This docstring was copied from numpy.maximum

Some inconsistencies with the Workflows version may exist

Parameters

x2 (x1,) – The arrays holding the elements to be compared. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

y – The maximum of x1 and x2, element-wise. This is a scalar if both x1 and x2 are scalars.

Return type

ndarray or scalar

mean(a: Union[Scalar, Array, MaskedArray], axis: Union[NoneType, List[Int], Int] = None) → Union[Scalar, Array, MaskedArray]

Compute the arithmetic mean along the specified axis.

This docstring was copied from numpy.mean

Some inconsistencies with the Workflows version may exist

Returns the average of the array elements. The average is taken over the flattened array by default, otherwise over the specified axis. float64 intermediate and return values are used for integer inputs.

Parameters
  • a (array_like) – Array containing numbers whose mean is desired. If a is not an array, a conversion is attempted.

  • axis (None or int or tuple of ints, optional) –

    Axis or axes along which the means are computed. The default is to compute the mean of the flattened array.

    New in version 1.7.0.

    If this is a tuple of ints, a mean is performed over multiple axes, instead of a single axis or all the axes as before.

  • dtype (data-type, optional) – Type to use in computing the mean. For integer inputs, the default is float64; for floating point inputs, it is the same as the input dtype.

  • out (ndarray, optional) – Alternate output array in which to place the result. The default is None; if provided, it must have the same shape as the expected output, but the type will be cast if necessary. See ufuncs-output-type for more details.

  • keepdims (bool, optional) –

    If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.

    If the default value is passed, then keepdims will not be passed through to the mean method of sub-classes of ndarray, however any non-default value will be. If the sub-class’ method does not implement keepdims any exceptions will be raised.

Returns

m – If out=None, returns a new array containing the mean values, otherwise a reference to the output array is returned.

Return type

ndarray, see dtype parameter above

Notes

The arithmetic mean is the sum of the elements along the axis divided by the number of elements.

Note that for floating-point input, the mean is computed using the same precision the input has. Depending on the input data, this can cause the results to be inaccurate, especially for float32 (see example below). Specifying a higher-precision accumulator using the dtype keyword can alleviate this issue.

By default, float16 results are computed using float32 intermediates for extra precision.

meshgrid(*xi: Union[Array, Scalar, MaskedArray], indexing: Str = 'xy', sparse: Bool = False) → List[Array]

Return coordinate matrices from coordinate vectors.

This docstring was copied from numpy.meshgrid

Some inconsistencies with the Workflows version may exist

Make N-D coordinate arrays for vectorized evaluations of N-D scalar/vector fields over N-D grids, given one-dimensional coordinate arrays x1, x2,…, xn.

Changed in version 1.9: 1-D and 0-D cases are allowed.

Parameters
  • x2,.., xn (x1,) – 1-D arrays representing the coordinates of a grid.

  • indexing ({'xy', 'ij'}, optional) –

    Cartesian (‘xy’, default) or matrix (‘ij’) indexing of output. See Notes for more details.

    New in version 1.7.0.

  • sparse (bool, optional) –

    If True a sparse grid is returned in order to conserve memory. Default is False.

    New in version 1.7.0.

  • copy (bool, optional) –

    If False, a view into the original arrays are returned in order to conserve memory. Default is True. Please note that sparse=False, copy=False will likely return non-contiguous arrays. Furthermore, more than one element of a broadcast array may refer to a single memory location. If you need to write to the arrays, make copies first.

    New in version 1.7.0.

Returns

X1, X2,…, XN – For vectors x1, x2,…, ‘xn’ with lengths Ni=len(xi) , return (N1, N2, N3,...Nn) shaped arrays if indexing=’ij’ or (N2, N1, N3,...Nn) shaped arrays if indexing=’xy’ with the elements of xi repeated to fill the matrix along the first dimension for x1, the second for x2 and so on.

Return type

ndarray

Notes

This function supports both indexing conventions through the indexing keyword argument. Giving the string ‘ij’ returns a meshgrid with matrix indexing, while ‘xy’ returns a meshgrid with Cartesian indexing. In the 2-D case with inputs of length M and N, the outputs are of shape (N, M) for ‘xy’ indexing and (M, N) for ‘ij’ indexing. In the 3-D case with inputs of length M, N and P, outputs are of shape (N, M, P) for ‘xy’ indexing and (M, N, P) for ‘ij’ indexing. The difference is illustrated by the following code snippet:

xv, yv = np.meshgrid(x, y, sparse=False, indexing='ij')
for i in range(nx):
    for j in range(ny):
        # treat xv[i,j], yv[i,j]

xv, yv = np.meshgrid(x, y, sparse=False, indexing='xy')
for i in range(nx):
    for j in range(ny):
        # treat xv[j,i], yv[j,i]

In the 1-D and 0-D case, the indexing and sparse keywords have no effect.

min(a: Union[Scalar, Array, MaskedArray], axis: Union[NoneType, List[Int], Int] = None) → Union[Scalar, Array, MaskedArray]

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

This docstring was copied from numpy.amin

Some inconsistencies with the Workflows version may exist

Parameters
  • a (array_like) – Input data.

  • axis (None or int or tuple of ints, optional) –

    Axis or axes along which to operate. By default, flattened input is used.

    New in version 1.7.0.

    If this is a tuple of ints, the minimum is selected over multiple axes, instead of a single axis or all the axes as before.

  • out (ndarray, optional) – Alternative output array in which to place the result. Must be of the same shape and buffer length as the expected output. See ufuncs-output-type for more details.

  • keepdims (bool, optional) –

    If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.

    If the default value is passed, then keepdims will not be passed through to the amin method of sub-classes of ndarray, however any non-default value will be. If the sub-class’ method does not implement keepdims any exceptions will be raised.

  • initial (scalar, optional) –

    The maximum value of an output element. Must be present to allow computation on empty slice. See ~numpy.ufunc.reduce for details.

    New in version 1.15.0.

  • where (array_like of bool, optional) –

    Elements to compare for the minimum. See ~numpy.ufunc.reduce for details.

    New in version 1.17.0.

Returns

  • amin (ndarray or scalar) – Minimum of a. If axis is None, the result is a scalar value. If axis is given, the result is an array of dimension a.ndim - 1.

  • nanmax, maximum, fmax

Notes

NaN values are propagated, that is if at least one item is NaN, the corresponding min value will be NaN as well. To ignore NaN values (MATLAB behavior), please use nanmin.

Don’t use amin for element-wise comparison of 2 arrays; when a.shape[0] is 2, minimum(a[0], a[1]) is faster than amin(a, axis=0).

minimum(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Union[Scalar, Int, Array, Bool, Float, MaskedArray]

Element-wise minimum of array elements.

This docstring was copied from numpy.minimum

Some inconsistencies with the Workflows version may exist

Parameters

x2 (x1,) – The arrays holding the elements to be compared. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

y – The minimum of x1 and x2, element-wise. This is a scalar if both x1 and x2 are scalars.

Return type

ndarray or scalar

mod(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Union[Scalar, Int, Array, Bool, Float, MaskedArray]

Return element-wise remainder of division.

This docstring was copied from numpy.remainder

Some inconsistencies with the Workflows version may exist

Parameters
  • x1 (array_like) – Dividend array.

  • x2 (array_like) – Divisor array. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

y – The element-wise remainder of the quotient floor_divide(x1, x2). This is a scalar if both x1 and x2 are scalars.

Return type

ndarray

moveaxis(a: Union[Array, MaskedArray], source: Union[List[Int], Int], destination: Union[List[Int], Int]) → Union[Array, MaskedArray]

Move axes of an array to new positions.

This docstring was copied from numpy.moveaxis

Some inconsistencies with the Workflows version may exist

Other axes remain in their original order.

New in version 1.11.0.

Parameters
  • a (np.ndarray) – The array whose axes should be reordered.

  • source (int or sequence of int) – Original positions of the axes to move. These must be unique.

  • destination (int or sequence of int) – Destination positions for each of the original axes. These must also be unique.

Returns

result – Array with moved axes. This array is a view of the input array.

Return type

np.ndarray

multiply(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Union[Scalar, Int, Array, Bool, Float, MaskedArray]

Multiply arguments element-wise.

This docstring was copied from numpy.multiply

Some inconsistencies with the Workflows version may exist

Parameters

x2 (x1,) – Input arrays to be multiplied. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

y – The product of x1 and x2, element-wise. This is a scalar if both x1 and x2 are scalars.

Return type

ndarray

nan_to_num(x: Union[Scalar, Array, MaskedArray]) → Union[Scalar, Array, MaskedArray]

Replace NaN with zero and infinity with large finite numbers (default behaviour) or with the numbers defined by the user using the nan, posinf and/or neginf keywords.

This docstring was copied from numpy.nan_to_num

Some inconsistencies with the Workflows version may exist

If x is inexact, NaN is replaced by zero or by the user defined value in nan keyword, infinity is replaced by the largest finite floating point values representable by x.dtype or by the user defined value in posinf keyword and -infinity is replaced by the most negative finite floating point values representable by x.dtype or by the user defined value in neginf keyword.

For complex dtypes, the above is applied to each of the real and imaginary components of x separately.

If x is not inexact, then no replacements are made.

Parameters
  • x (scalar or array_like) – Input data.

  • copy (bool, optional) –

    Whether to create a copy of x (True) or to replace values in-place (False). The in-place operation only occurs if casting to an array does not require a copy. Default is True.

    New in version 1.13.

  • nan (int, float, optional) –

    Value to be used to fill NaN values. If no value is passed then NaN values will be replaced with 0.0.

    New in version 1.17.

  • posinf (int, float, optional) –

    Value to be used to fill positive infinity values. If no value is passed then positive infinity values will be replaced with a very large number.

    New in version 1.17.

  • neginf (int, float, optional) –

    Value to be used to fill negative infinity values. If no value is passed then negative infinity values will be replaced with a very small (or negative) number.

    New in version 1.17.

Returns

outx, with the non-finite values replaced. If copy is False, this may be x itself.

Return type

ndarray

Notes

NumPy uses the IEEE Standard for Binary Floating-Point for Arithmetic (IEEE 754). This means that Not a Number is not equivalent to infinity.

nanargmax(a: Union[Array, MaskedArray], axis: Optional[Int] = None) → Union[Scalar, Array]

Return the indices of the maximum values in the specified axis ignoring NaNs. For all-NaN slices ValueError is raised. Warning: the results cannot be trusted if a slice contains only NaNs and -Infs.

This docstring was copied from numpy.nanargmax

Some inconsistencies with the Workflows version may exist

Parameters
  • a (array_like) – Input data.

  • axis (int, optional) – Axis along which to operate. By default flattened input is used.

Returns

index_array – An array of indices or a single index value.

Return type

ndarray

nanargmin(a: Union[Array, MaskedArray], axis: Optional[Int] = None) → Union[Scalar, Array]

Return the indices of the minimum values in the specified axis ignoring NaNs. For all-NaN slices ValueError is raised. Warning: the results cannot be trusted if a slice contains only NaNs and Infs.

This docstring was copied from numpy.nanargmin

Some inconsistencies with the Workflows version may exist

Parameters
  • a (array_like) – Input data.

  • axis (int, optional) – Axis along which to operate. By default flattened input is used.

Returns

index_array – An array of indices or a single index value.

Return type

ndarray

nancumprod(a: Union[Scalar, Array, MaskedArray], axis: Optional[Int] = None, dtype: Optional[DType] = None) → Union[Array, MaskedArray]

Return the cumulative product of array elements over a given axis treating Not a Numbers (NaNs) as one. The cumulative product does not change when NaNs are encountered and leading NaNs are replaced by ones.

This docstring was copied from numpy.nancumprod

Some inconsistencies with the Workflows version may exist

Ones are returned for slices that are all-NaN or empty.

New in version 1.12.0.

Parameters
  • a (array_like) – Input array.

  • axis (int, optional) – Axis along which the cumulative product is computed. By default the input is flattened.

  • dtype (dtype, optional) – Type of the returned array, as well as of the accumulator in which the elements are multiplied. If dtype is not specified, it defaults to the dtype of a, unless a has an integer dtype with a precision less than that of the default platform integer. In that case, the default platform integer is used instead.

  • out (ndarray, optional) – Alternative output array in which to place the result. It must have the same shape and buffer length as the expected output but the type of the resulting values will be cast if necessary.

Returns

nancumprod – A new array holding the result is returned unless out is specified, in which case it is returned.

Return type

ndarray

nancumsum(a: Union[Scalar, Array, MaskedArray], axis: Optional[Int] = None, dtype: Optional[DType] = None) → Union[Array, MaskedArray]

Return the cumulative sum of array elements over a given axis treating Not a Numbers (NaNs) as zero. The cumulative sum does not change when NaNs are encountered and leading NaNs are replaced by zeros.

This docstring was copied from numpy.nancumsum

Some inconsistencies with the Workflows version may exist

Zeros are returned for slices that are all-NaN or empty.

New in version 1.12.0.

Parameters
  • a (array_like) – Input array.

  • axis (int, optional) – Axis along which the cumulative sum is computed. The default (None) is to compute the cumsum over the flattened array.

  • dtype (dtype, optional) – Type of the returned array and of the accumulator in which the elements are summed. If dtype is not specified, it defaults to the dtype of a, unless a has an integer dtype with a precision less than that of the default platform integer. In that case, the default platform integer is used.

  • out (ndarray, optional) – Alternative output array in which to place the result. It must have the same shape and buffer length as the expected output but the type will be cast if necessary. See ufuncs-output-type for more details.

Returns

nancumsum – A new array holding the result is returned unless out is specified, in which it is returned. The result has the same size as a, and the same shape as a if axis is not None or a is a 1-d array.

Return type

ndarray.

nanmax(a: Union[Scalar, Array, MaskedArray], axis: Union[NoneType, List[Int], Int] = None) → Union[Scalar, Array, MaskedArray]

Return the maximum of an array or maximum along an axis, ignoring any NaNs. When all-NaN slices are encountered a RuntimeWarning is raised and NaN is returned for that slice.

This docstring was copied from numpy.nanmax

Some inconsistencies with the Workflows version may exist

Parameters
  • a (array_like) – Array containing numbers whose maximum is desired. If a is not an array, a conversion is attempted.

  • axis ({int, tuple of int, None}, optional) – Axis or axes along which the maximum is computed. The default is to compute the maximum of the flattened array.

  • out (ndarray, optional) –

    Alternate output array in which to place the result. The default is None; if provided, it must have the same shape as the expected output, but the type will be cast if necessary. See ufuncs-output-type for more details.

    New in version 1.8.0.

  • keepdims (bool, optional) –

    If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original a.

    If the value is anything but the default, then keepdims will be passed through to the max method of sub-classes of ndarray. If the sub-classes methods does not implement keepdims any exceptions will be raised.

    New in version 1.8.0.

Returns

  • nanmax (ndarray) – An array with the same shape as a, with the specified axis removed. If a is a 0-d array, or if axis is None, an ndarray scalar is returned. The same dtype as a is returned.

  • amin, fmin, minimum

Notes

NumPy uses the IEEE Standard for Binary Floating-Point for Arithmetic (IEEE 754). This means that Not a Number is not equivalent to infinity. Positive infinity is treated as a very large number and negative infinity is treated as a very small (i.e. negative) number.

If the input has a integer type the function is equivalent to np.max.

nanmean(a: Union[Scalar, Array, MaskedArray], axis: Union[NoneType, List[Int], Int] = None) → Union[Scalar, Array, MaskedArray]

Compute the arithmetic mean along the specified axis, ignoring NaNs.

This docstring was copied from numpy.nanmean

Some inconsistencies with the Workflows version may exist

Returns the average of the array elements. The average is taken over the flattened array by default, otherwise over the specified axis. float64 intermediate and return values are used for integer inputs.

For all-NaN slices, NaN is returned and a RuntimeWarning is raised.

New in version 1.8.0.

Parameters
  • a (array_like) – Array containing numbers whose mean is desired. If a is not an array, a conversion is attempted.

  • axis ({int, tuple of int, None}, optional) – Axis or axes along which the means are computed. The default is to compute the mean of the flattened array.

  • dtype (data-type, optional) – Type to use in computing the mean. For integer inputs, the default is float64; for inexact inputs, it is the same as the input dtype.

  • out (ndarray, optional) – Alternate output array in which to place the result. The default is None; if provided, it must have the same shape as the expected output, but the type will be cast if necessary. See ufuncs-output-type for more details.

  • keepdims (bool, optional) –

    If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original a.

    If the value is anything but the default, then keepdims will be passed through to the mean or sum methods of sub-classes of ndarray. If the sub-classes methods does not implement keepdims any exceptions will be raised.

Returns

m – If out=None, returns a new array containing the mean values, otherwise a reference to the output array is returned. Nan is returned for slices that contain only NaNs.

Return type

ndarray, see dtype parameter above

Notes

The arithmetic mean is the sum of the non-NaN elements along the axis divided by the number of non-NaN elements.

Note that for floating-point input, the mean is computed using the same precision the input has. Depending on the input data, this can cause the results to be inaccurate, especially for float32. Specifying a higher-precision accumulator using the dtype keyword can alleviate this issue.

nanmin(a: Union[Scalar, Array, MaskedArray], axis: Union[NoneType, List[Int], Int] = None) → Union[Scalar, Array, MaskedArray]

Return minimum of an array or minimum along an axis, ignoring any NaNs. When all-NaN slices are encountered a RuntimeWarning is raised and Nan is returned for that slice.

This docstring was copied from numpy.nanmin

Some inconsistencies with the Workflows version may exist

Parameters
  • a (array_like) – Array containing numbers whose minimum is desired. If a is not an array, a conversion is attempted.

  • axis ({int, tuple of int, None}, optional) – Axis or axes along which the minimum is computed. The default is to compute the minimum of the flattened array.

  • out (ndarray, optional) –

    Alternate output array in which to place the result. The default is None; if provided, it must have the same shape as the expected output, but the type will be cast if necessary. See ufuncs-output-type for more details.

    New in version 1.8.0.

  • keepdims (bool, optional) –

    If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original a.

    If the value is anything but the default, then keepdims will be passed through to the min method of sub-classes of ndarray. If the sub-classes methods does not implement keepdims any exceptions will be raised.

    New in version 1.8.0.

Returns

  • nanmin (ndarray) – An array with the same shape as a, with the specified axis removed. If a is a 0-d array, or if axis is None, an ndarray scalar is returned. The same dtype as a is returned.

  • amax, fmax, maximum

Notes

NumPy uses the IEEE Standard for Binary Floating-Point for Arithmetic (IEEE 754). This means that Not a Number is not equivalent to infinity. Positive infinity is treated as a very large number and negative infinity is treated as a very small (i.e. negative) number.

If the input has a integer type the function is equivalent to np.min.

nanprod(a: Union[Scalar, Array, MaskedArray], axis: Union[NoneType, List[Int], Int] = None) → Union[Scalar, Array, MaskedArray]

Return the product of array elements over a given axis treating Not a Numbers (NaNs) as ones.

This docstring was copied from numpy.nanprod

Some inconsistencies with the Workflows version may exist

One is returned for slices that are all-NaN or empty.

New in version 1.10.0.

Parameters
  • a (array_like) – Array containing numbers whose product is desired. If a is not an array, a conversion is attempted.

  • axis ({int, tuple of int, None}, optional) – Axis or axes along which the product is computed. The default is to compute the product of the flattened array.

  • dtype (data-type, optional) – The type of the returned array and of the accumulator in which the elements are summed. By default, the dtype of a is used. An exception is when a has an integer type with less precision than the platform (u)intp. In that case, the default will be either (u)int32 or (u)int64 depending on whether the platform is 32 or 64 bits. For inexact inputs, dtype must be inexact.

  • out (ndarray, optional) – Alternate output array in which to place the result. The default is None. If provided, it must have the same shape as the expected output, but the type will be cast if necessary. See ufuncs-output-type for more details. The casting of NaN to integer can yield unexpected results.

  • keepdims (bool, optional) – If True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original arr.

Returns

nanprod – A new array holding the result is returned unless out is specified, in which case it is returned.

Return type

ndarray

nanstd(a: Union[Scalar, Array, MaskedArray], axis: Union[NoneType, List[Int], Int] = None) → Union[Scalar, Array, MaskedArray]

Compute the standard deviation along the specified axis, while ignoring NaNs.

This docstring was copied from numpy.nanstd

Some inconsistencies with the Workflows version may exist

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

For all-NaN slices or slices with zero degrees of freedom, NaN is returned and a RuntimeWarning is raised.

New in version 1.8.0.

Parameters
  • a (array_like) – Calculate the standard deviation of the non-NaN values.

  • axis ({int, tuple of int, None}, optional) – Axis or axes along which the standard deviation is computed. The default is to compute the standard deviation of the flattened array.

  • dtype (dtype, optional) – Type to use in computing the standard deviation. For arrays of integer type the default is float64, for arrays of float types it is the same as the array type.

  • out (ndarray, optional) – Alternative output array in which to place the result. It must have the same shape as the expected output but the type (of the calculated values) will be cast if necessary.

  • ddof (int, optional) – Means Delta Degrees of Freedom. The divisor used in calculations is N - ddof, where N represents the number of non-NaN elements. By default ddof is zero.

  • keepdims (bool, optional) –

    If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original a.

    If this value is anything but the default it is passed through as-is to the relevant functions of the sub-classes. If these functions do not have a keepdims kwarg, a RuntimeError will be raised.

Returns

standard_deviation – If out is None, return a new array containing the standard deviation, otherwise return a reference to the output array. If ddof is >= the number of non-NaN elements in a slice or the slice contains only NaNs, then the result for that slice is NaN.

Return type

ndarray, see dtype parameter above.

Notes

The standard deviation is the square root of the average of the squared deviations from the mean: std = sqrt(mean(abs(x - x.mean())**2)).

The average squared deviation is normally calculated as x.sum() / N, where N = len(x). If, however, ddof is specified, the divisor N - ddof is used instead. In standard statistical practice, ddof=1 provides an unbiased estimator of the variance of the infinite population. ddof=0 provides a maximum likelihood estimate of the variance for normally distributed variables. The standard deviation computed in this function is the square root of the estimated variance, so even with ddof=1, it will not be an unbiased estimate of the standard deviation per se.

Note that, for complex numbers, std takes the absolute value before squaring, so that the result is always real and nonnegative.

For floating-point input, the std is computed using the same precision the input has. Depending on the input data, this can cause the results to be inaccurate, especially for float32 (see example below). Specifying a higher-accuracy accumulator using the dtype keyword can alleviate this issue.

nansum(a: Union[Scalar, Array, MaskedArray], axis: Union[NoneType, List[Int], Int] = None) → Union[Scalar, Array, MaskedArray]

Return the sum of array elements over a given axis treating Not a Numbers (NaNs) as zero.

This docstring was copied from numpy.nansum

Some inconsistencies with the Workflows version may exist

In NumPy versions <= 1.9.0 Nan is returned for slices that are all-NaN or empty. In later versions zero is returned.

Parameters
  • a (array_like) – Array containing numbers whose sum is desired. If a is not an array, a conversion is attempted.

  • axis ({int, tuple of int, None}, optional) – Axis or axes along which the sum is computed. The default is to compute the sum of the flattened array.

  • dtype (data-type, optional) –

    The type of the returned array and of the accumulator in which the elements are summed. By default, the dtype of a is used. An exception is when a has an integer type with less precision than the platform (u)intp. In that case, the default will be either (u)int32 or (u)int64 depending on whether the platform is 32 or 64 bits. For inexact inputs, dtype must be inexact.

    New in version 1.8.0.

  • out (ndarray, optional) –

    Alternate output array in which to place the result. The default is None. If provided, it must have the same shape as the expected output, but the type will be cast if necessary. See ufuncs-output-type for more details. The casting of NaN to integer can yield unexpected results.

    New in version 1.8.0.

  • keepdims – If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original a.

Returns

nansum – A new array holding the result is returned unless out is specified, in which it is returned. The result has the same size as a, and the same shape as a if axis is not None or a is a 1-d array.

Return type

ndarray.

Notes

If both positive and negative infinity are present, the sum will be Not A Number (NaN).

nanvar(a: Union[Array, MaskedArray], axis: Union[NoneType, List[Int], Int] = None, ddof: Int = 0) → Union[Scalar, Array]

Compute the variance along the specified axis, while ignoring NaNs.

This docstring was copied from numpy.nanvar

Some inconsistencies with the Workflows version may exist

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.

For all-NaN slices or slices with zero degrees of freedom, NaN is returned and a RuntimeWarning is raised.

New in version 1.8.0.

Parameters
  • a (array_like) – Array containing numbers whose variance is desired. If a is not an array, a conversion is attempted.

  • axis ({int, tuple of int, None}, optional) – Axis or axes along which the variance is computed. The default is to compute the variance of the flattened array.

  • dtype (data-type, optional) – Type to use in computing the variance. For arrays of integer type the default is float64; for arrays of float types it is the same as the array type.

  • out (ndarray, optional) – Alternate output array in which to place the result. It must have the same shape as the expected output, but the type is cast if necessary.

  • ddof (int, optional) – “Delta Degrees of Freedom”: the divisor used in the calculation is N - ddof, where N represents the number of non-NaN elements. By default ddof is zero.

  • keepdims (bool, optional) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original a.

Returns

variance – If out is None, return a new array containing the variance, otherwise return a reference to the output array. If ddof is >= the number of non-NaN elements in a slice or the slice contains only NaNs, then the result for that slice is NaN.

Return type

ndarray, see dtype parameter above

Notes

The variance is the average of the squared deviations from the mean, i.e., var = mean(abs(x - x.mean())**2).

The mean is normally calculated as x.sum() / N, where N = len(x). If, however, ddof is specified, the divisor N - ddof is used instead. In standard statistical practice, ddof=1 provides an unbiased estimator of the variance of a hypothetical infinite population. ddof=0 provides a maximum likelihood estimate of the variance for normally distributed variables.

Note that for complex numbers, the absolute value is taken before squaring, so that the result is always real and nonnegative.

For floating-point input, the variance is computed using the same precision the input has. Depending on the input data, this can cause the results to be inaccurate, especially for float32 (see example below). Specifying a higher-accuracy accumulator using the dtype keyword can alleviate this issue.

For this function to work on sub-classes of ndarray, they must define sum with the kwarg keepdims

negative(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Union[Scalar, Int, Array, Bool, Float, MaskedArray]

Numerical negative, element-wise.

This docstring was copied from numpy.negative

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like or scalar) – Input array.

Returns

y – Returned array or scalar: y = -x. This is a scalar if x is a scalar.

Return type

ndarray or scalar

nextafter(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

Return the next floating-point value after x1 towards x2, element-wise.

This docstring was copied from numpy.nextafter

Some inconsistencies with the Workflows version may exist

Parameters
  • x1 (array_like) – Values to find the next representable value of.

  • x2 (array_like) – The direction where to look for the next representable value of x1.

Returns

out – The next representable values of x1 in the direction of x2. This is a scalar if both x1 and x2 are scalars.

Return type

ndarray or scalar

nonzero(a: Union[Array, Scalar, MaskedArray]) → List[Array]

Return the indices of the elements that are non-zero.

This docstring was copied from numpy.nonzero

Some inconsistencies with the Workflows version may exist

Returns a tuple of arrays, one for each dimension of a, containing the indices of the non-zero elements in that dimension. The values in a are always tested and returned in row-major, C-style order.

To group the indices by element, rather than dimension, use argwhere, which returns a row for each non-zero element.

Note

When called on a zero-d array or scalar, nonzero(a) is treated as nonzero(atleast1d(a)).

Deprecated since version 1.17.0: Use atleast1d explicitly if this behavior is deliberate.

Parameters

a (array_like) – Input array.

Returns

tuple_of_arrays – Indices of elements that are non-zero.

Return type

tuple

Notes

While the nonzero values can be obtained with a[nonzero(a)], it is recommended to use x[x.astype(bool)] or x[x != 0] instead, which will correctly handle 0-d arrays.

not_equal(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Bool

Return (x1 != x2) element-wise.

This docstring was copied from numpy.not_equal

Some inconsistencies with the Workflows version may exist

Parameters

x2 (x1,) – Input arrays. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

out – Output array, element-wise comparison of x1 and x2. Typically of type bool, unless dtype=object is passed. This is a scalar if both x1 and x2 are scalars.

Return type

ndarray or scalar

ones(shape: Union[List[Int], Int], dtype: DType = <descarteslabs.workflows.types.array.dtype.DType object>) → Array

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

This docstring was copied from numpy.ones

Some inconsistencies with the Workflows version may exist

Parameters
  • shape (int or sequence of ints) – Shape of the new array, e.g., (2, 3) or 2.

  • dtype (data-type, optional) – The desired data-type for the array, e.g., numpy.int8. Default is numpy.float64.

  • order ({'C', 'F'}, optional, default: C) – Whether to store multi-dimensional data in row-major (C-style) or column-major (Fortran-style) order in memory.

Returns

out – Array of ones with the given shape, dtype, and order.

Return type

ndarray

ones_like(a: Union[Array, Scalar, MaskedArray], dtype: Optional[DType] = None) → Array

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

This docstring was copied from numpy.ones_like

Some inconsistencies with the Workflows version may exist

Parameters
  • a (array_like) – The shape and data-type of a define these same attributes of the returned array.

  • dtype (data-type, optional) –

    Overrides the data type of the result.

    New in version 1.6.0.

  • order ({'C', 'F', 'A', or 'K'}, optional) –

    Overrides the memory layout of the result. ‘C’ means C-order, ‘F’ means F-order, ‘A’ means ‘F’ if a is Fortran contiguous, ‘C’ otherwise. ‘K’ means match the layout of a as closely as possible.

    New in version 1.6.0.

  • subok (bool, optional.) – If True, then the newly created array will use the sub-class type of ‘a’, otherwise it will be a base-class array. Defaults to True.

  • shape (int or sequence of ints, optional.) –

    Overrides the shape of the result. If order=’K’ and the number of dimensions is unchanged, will try to keep order, otherwise, order=’C’ is implied.

    New in version 1.17.0.

Returns

out – Array of ones with the same shape and type as a.

Return type

ndarray

outer(a: Union[Array, Scalar, MaskedArray], b: Union[Array, Scalar, MaskedArray]) → Array

Compute the outer product of two vectors.

This docstring was copied from numpy.outer

Some inconsistencies with the Workflows version may exist

Given two vectors, a = [a0, a1, ..., aM] and b = [b0, b1, ..., bN], the outer product is:

[[a0*b0  a0*b1 ... a0*bN ]
 [a1*b0    .
 [ ...          .
 [aM*b0            aM*bN ]]
Parameters
  • a ((M,) array_like) – First input vector. Input is flattened if not already 1-dimensional.

  • b ((N,) array_like) – Second input vector. Input is flattened if not already 1-dimensional.

  • out ((M, N) ndarray, optional) –

    A location where the result is stored

    New in version 1.9.0.

Returns

outout[i, j] = a[i] * b[j]

Return type

(M, N) ndarray

See also

inner()

einsum()

einsum('i,j->ij', a.ravel(), b.ravel()) is the equivalent.

ufunc.outer()

A generalization to N dimensions and other operations. np.multiply.outer(a.ravel(), b.ravel()) is the equivalent.

pad(array: Union[Scalar, Array, MaskedArray], pad_width: Union[List[Int], Int], mode: Str = 'constant') → Union[Array, MaskedArray]

Pad an array.

This docstring was copied from numpy.pad

Some inconsistencies with the Workflows version may exist

Parameters
  • array (array_like of rank N) – The array to pad.

  • pad_width ({sequence, array_like, int}) – Number of values padded to the edges of each axis. ((before_1, after_1), … (before_N, after_N)) unique pad widths for each axis. ((before, after),) yields same before and after pad for each axis. (pad,) or int is a shortcut for before = after = pad width for all axes.

  • mode (str or function, optional) –

    One of the following string values or a user supplied function.

    ’constant’ (default)

    Pads with a constant value.

    ’edge’

    Pads with the edge values of array.

    ’linear_ramp’

    Pads with the linear ramp between end_value and the array edge value.

    ’maximum’

    Pads with the maximum value of all or part of the vector along each axis.

    ’mean’

    Pads with the mean value of all or part of the vector along each axis.

    ’median’

    Pads with the median value of all or part of the vector along each axis.

    ’minimum’

    Pads with the minimum value of all or part of the vector along each axis.

    ’reflect’

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

    ’symmetric’

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

    ’wrap’

    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.

    ’empty’

    Pads with undefined values.

    New in version 1.17.

    <function>

    Padding function, see Notes.

  • stat_length (sequence or int, optional) –

    Used in ‘maximum’, ‘mean’, ‘median’, and ‘minimum’. Number of values at edge of each axis used to calculate the statistic value.

    ((before_1, after_1), … (before_N, after_N)) unique statistic lengths for each axis.

    ((before, after),) yields same before and after statistic lengths for each axis.

    (stat_length,) or int is a shortcut for before = after = statistic length for all axes.

    Default is None, to use the entire axis.

  • constant_values (sequence or scalar, optional) –

    Used in ‘constant’. The values to set the padded values for each axis.

    ((before_1, after_1), ... (before_N, after_N)) unique pad constants for each axis.

    ((before, after),) yields same before and after constants for each axis.

    (constant,) or constant is a shortcut for before = after = constant for all axes.

    Default is 0.

  • end_values (sequence or scalar, optional) –

    Used in ‘linear_ramp’. The values used for the ending value of the linear_ramp and that will form the edge of the padded array.

    ((before_1, after_1), ... (before_N, after_N)) unique end values for each axis.

    ((before, after),) yields same before and after end values for each axis.

    (constant,) or constant is a shortcut for before = after = constant for all axes.

    Default is 0.

  • reflect_type ({'even', 'odd'}, optional) – Used in ‘reflect’, and ‘symmetric’. The ‘even’ style is the default with an unaltered reflection around the edge value. For the ‘odd’ style, the extended part of the array is created by subtracting the reflected values from two times the edge value.

Returns

pad – Padded array of rank equal to array with shape increased according to pad_width.

Return type

ndarray

Notes

New in version 1.7.0.

For an array with rank greater than 1, some of the padding of later axes is calculated from padding of previous axes. This is easiest to think about with a rank 2 array where the corners of the padded array are calculated by using padded values from the first axis.

The padding function, if used, should modify a rank 1 array in-place. It has the following signature:

padding_func(vector, iaxis_pad_width, iaxis, kwargs)

where

vectorndarray

A rank 1 array already padded with zeros. Padded values are vector[:iaxis_pad_width[0]] and vector[-iaxis_pad_width[1]:].

iaxis_pad_widthtuple

A 2-tuple of ints, iaxis_pad_width[0] represents the number of values padded at the beginning of vector where iaxis_pad_width[1] represents the number of values padded at the end of vector.

iaxisint

The axis currently being calculated.

kwargsdict

Any keyword arguments the function requires.

percentile(a: Union[Array, MaskedArray], q: Union[Array, MaskedArray], interpolation: Str = 'linear') → Array

Compute the q-th percentile of the data along the specified axis.

This docstring was copied from numpy.percentile

Some inconsistencies with the Workflows version may exist

Returns the q-th percentile(s) of the array elements.

Parameters
  • a (array_like) – Input array or object that can be converted to an array.

  • q (array_like of float) – Percentile or sequence of percentiles to compute, which must be between 0 and 100 inclusive.

  • axis ({int, tuple of int, None}, optional) –

    Axis or axes along which the percentiles are computed. The default is to compute the percentile(s) along a flattened version of the array.

    Changed in version 1.9.0: A tuple of axes is supported

  • out (ndarray, optional) – Alternative output array in which to place the result. It must have the same shape and buffer length as the expected output, but the type (of the output) will be cast if necessary.

  • overwrite_input (bool, optional) – If True, then allow the input array a to be modified by intermediate calculations, to save memory. In this case, the contents of the input a after this function completes is undefined.

  • interpolation ({'linear', 'lower', 'higher', 'midpoint', 'nearest'}) –

    This optional parameter specifies the interpolation method to use when the desired percentile lies between two data points i < j:

    • ’linear’: i + (j - i) * fraction, where fraction is the fractional part of the index surrounded by i and j.

    • ’lower’: i.

    • ’higher’: j.

    • ’nearest’: i or j, whichever is nearest.

    • ’midpoint’: (i + j) / 2.

    New in version 1.9.0.

  • keepdims (bool, optional) –

    If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original array a.

    New in version 1.9.0.

Returns

percentile – If q is a single percentile and axis=None, then the result is a scalar. If multiple percentiles are given, first axis of the result corresponds to the percentiles. The other axes are the axes that remain after the reduction of a. If the input contains integers or floats smaller than float64, the output data-type is float64. Otherwise, the output data-type is the same as that of the input. If out is specified, that array is returned instead.

Return type

scalar or ndarray

Notes

Given a vector V of length N, the q-th percentile of V is the value q/100 of the way from the minimum to the maximum in a sorted copy of V. The values and distances of the two nearest neighbors as well as the interpolation parameter will determine the percentile if the normalized ranking does not match the location of q exactly. This function is the same as the median if q=50, the same as the minimum if q=0 and the same as the maximum if q=100.

power(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Union[Scalar, Int, Array, Bool, Float, MaskedArray]

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

This docstring was copied from numpy.power

Some inconsistencies with the Workflows version may exist

Parameters
  • x1 (array_like) – The bases.

  • x2 (array_like) – The exponents. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

y – The bases in x1 raised to the exponents in x2. This is a scalar if both x1 and x2 are scalars.

Return type

ndarray

prod(a: Union[Scalar, Array, MaskedArray], axis: Union[NoneType, List[Int], Int] = None) → Union[Scalar, Array, MaskedArray]

Return the product of array elements over a given axis.

This docstring was copied from numpy.prod

Some inconsistencies with the Workflows version may exist

Parameters
  • a (array_like) – Input data.

  • axis (None or int or tuple of ints, optional) –

    Axis or axes along which a product is performed. The default, axis=None, will calculate the product of all the elements in the input array. If axis is negative it counts from the last to the first axis.

    New in version 1.7.0.

    If axis is a tuple of ints, a product is performed on all of the axes specified in the tuple instead of a single axis or all the axes as before.

  • dtype (dtype, optional) – The type of the returned array, as well as of the accumulator in which the elements are multiplied. The dtype of a is used by default unless a has an integer dtype of less precision than the default platform integer. In that case, if a is signed then the platform integer is used while if a is unsigned then an unsigned integer of the same precision as the platform integer is used.

  • out (ndarray, optional) – Alternative output array in which to place the result. It must have the same shape as the expected output, but the type of the output values will be cast if necessary.

  • keepdims (bool, optional) –

    If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.

    If the default value is passed, then keepdims will not be passed through to the prod method of sub-classes of ndarray, however any non-default value will be. If the sub-class’ method does not implement keepdims any exceptions will be raised.

  • initial (scalar, optional) –

    The starting value for this product. See ~numpy.ufunc.reduce for details.

    New in version 1.15.0.

  • where (array_like of bool, optional) –

    Elements to include in the product. See ~numpy.ufunc.reduce for details.

    New in version 1.17.0.

Returns

product_along_axis – An array shaped as a but with the specified axis removed. Returns a reference to out if specified.

Return type

ndarray, see dtype parameter above.

Notes

Arithmetic is modular when using integer types, and no error is raised on overflow. That means that, on a 32-bit platform:

>>> x = np.array([536870910, 536870910, 536870910, 536870910])
>>> np.prod(x)
16 # may vary

The product of an empty array is the neutral element 1:

>>> np.prod([])
1.0
ptp(a: Union[Scalar, Array, MaskedArray], axis: Union[NoneType, List[Int], Int] = None) → Union[Scalar, Array, MaskedArray]

Range of values (maximum - minimum) along an axis.

This docstring was copied from numpy.ptp

Some inconsistencies with the Workflows version may exist

The name of the function comes from the acronym for ‘peak to peak’.

Parameters
  • a (array_like) – Input values.

  • axis (None or int or tuple of ints, optional) –

    Axis along which to find the peaks. By default, flatten the array. axis may be negative, in which case it counts from the last to the first axis.

    New in version 1.15.0.

    If this is a tuple of ints, a reduction is performed on multiple axes, instead of a single axis or all the axes as before.

  • out (array_like) – Alternative output array in which to place the result. It must have the same shape and buffer length as the expected output, but the type of the output values will be cast if necessary.

  • keepdims (bool, optional) –

    If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.

    If the default value is passed, then keepdims will not be passed through to the ptp method of sub-classes of ndarray, however any non-default value will be. If the sub-class’ method does not implement keepdims any exceptions will be raised.

Returns

ptp – A new array holding the result, unless out was specified, in which case a reference to out is returned.

Return type

ndarray

rad2deg(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

Convert angles from radians to degrees.

This docstring was copied from numpy.rad2deg

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Angle in radians.

Returns

y – The corresponding angle in degrees. This is a scalar if x is a scalar.

Return type

ndarray

radians(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

Convert angles from degrees to radians.

This docstring was copied from numpy.radians

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Input array in degrees.

Returns

y – The corresponding radian values. This is a scalar if x is a scalar.

Return type

ndarray

ravel(a: Union[Scalar, Array, MaskedArray]) → Union[Scalar, Array, MaskedArray]

Return a contiguous flattened array.

This docstring was copied from numpy.ravel

Some inconsistencies with the Workflows version may exist

A 1-D array, containing the elements of the input, is returned. A copy is made only if needed.

As of NumPy 1.10, the returned array will have the same type as the input array. (for example, a masked array will be returned for a masked array input)

Parameters
  • a (array_like) – Input array. The elements in a are read in the order specified by order, and packed as a 1-D array.

  • order ({'C','F', 'A', 'K'}, optional) – The elements of a are read using this index order. ‘C’ means to index the elements in row-major, C-style order, with the last axis index changing fastest, back to the first axis index changing slowest. ‘F’ means to index the elements in column-major, Fortran-style order, with the first index changing fastest, and the last index changing slowest. Note that the ‘C’ and ‘F’ options take no account of the memory layout of the underlying array, and only refer to the order of axis indexing. ‘A’ means to read the elements in Fortran-like index order if a is Fortran contiguous in memory, C-like order otherwise. ‘K’ means to read the elements in the order they occur in memory, except for reversing the data when strides are negative. By default, ‘C’ index order is used.

Returns

y – y is an array of the same subtype as a, with shape (a.size,). Note that matrices are special cased for backward compatibility, if a is a matrix, then y is a 1-D ndarray.

Return type

array_like

Notes

In row-major, C-style order, in two dimensions, the row index varies the slowest, and the column index the quickest. This can be generalized to multiple dimensions, where row-major order implies that the index along the first axis varies slowest, and the index along the last quickest. The opposite holds for column-major, Fortran-style index ordering.

When a view is desired in as many cases as possible, arr.reshape(-1) may be preferable.

real(val: Union[Scalar, Array, MaskedArray]) → Union[Scalar, Array, MaskedArray]

Return the real part of the complex argument.

This docstring was copied from numpy.real

Some inconsistencies with the Workflows version may exist

Parameters

val (array_like) – Input array.

Returns

out – The real component of the complex argument. If val is real, the type of val is used for the output. If val has complex elements, the returned type is float.

Return type

ndarray or scalar

reciprocal(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Union[Scalar, Int, Array, Bool, Float, MaskedArray]

Return the reciprocal of the argument, element-wise.

This docstring was copied from numpy.reciprocal

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Input array.

Returns

y – Return array. This is a scalar if x is a scalar.

Return type

ndarray

remainder(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Union[Scalar, Int, Array, Bool, Float, MaskedArray]

Return element-wise remainder of division.

This docstring was copied from numpy.remainder

Some inconsistencies with the Workflows version may exist

Parameters
  • x1 (array_like) – Dividend array.

  • x2 (array_like) – Divisor array. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

y – The element-wise remainder of the quotient floor_divide(x1, x2). This is a scalar if both x1 and x2 are scalars.

Return type

ndarray

repeat(a: Union[Array, MaskedArray], repeats: Int, axis: Int = None) → Union[Array, MaskedArray]

Repeat elements of an array.

This docstring was copied from numpy.repeat

Some inconsistencies with the Workflows version may exist

Parameters
  • a (array_like) – Input array.

  • repeats (int or array of ints) – The number of repetitions for each element. repeats is broadcasted to fit the shape of the given axis.

  • axis (int, optional) – The axis along which to repeat values. By default, use the flattened input array, and return a flat output array.

Returns

repeated_array – Output array which has the same shape as a, except along the given axis.

Return type

ndarray

reshape(a: Union[Array, MaskedArray], newshape: List[Int]) → Union[Array, MaskedArray]

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

This docstring was copied from numpy.reshape

Some inconsistencies with the Workflows version may exist

Parameters
  • a (array_like) – Array to be reshaped.

  • newshape (int or tuple of ints) – The new shape should be compatible with the original shape. If an integer, then the result will be a 1-D array of that length. One shape dimension can be -1. In this case, the value is inferred from the length of the array and remaining dimensions.

  • order ({'C', 'F', 'A'}, optional) – Read the elements of a using this index order, and place the elements into the reshaped array using this index order. ‘C’ means to read / write the elements using C-like index order, with the last axis index changing fastest, back to the first axis index changing slowest. ‘F’ means to read / write the elements using Fortran-like index order, with the first index changing fastest, and the last index changing slowest. Note that the ‘C’ and ‘F’ options take no account of the memory layout of the underlying array, and only refer to the order of indexing. ‘A’ means to read / write the elements in Fortran-like index order if a is Fortran contiguous in memory, C-like order otherwise.

Returns

reshaped_array – This will be a new view object if possible; otherwise, it will be a copy. Note there is no guarantee of the memory layout (C- or Fortran- contiguous) of the returned array.

Return type

ndarray

Notes

It is not always possible to change the shape of an array without copying the data. If you want an error to be raised when the data is copied, you should assign the new shape to the shape attribute of the array:

>>> a = np.zeros((10, 2))

# A transpose makes the array non-contiguous
>>> b = a.T

# Taking a view makes it possible to modify the shape without modifying
# the initial object.
>>> c = b.view()
>>> c.shape = (20)
Traceback (most recent call last):
   ...
AttributeError: incompatible shape for a non-contiguous array

The order keyword gives the index ordering both for fetching the values from a, and then placing the values into the output array. For example, let’s say you have an array:

>>> a = np.arange(6).reshape((3, 2))
>>> a
array([[0, 1],
       [2, 3],
       [4, 5]])

You can think of reshaping as first raveling the array (using the given index order), then inserting the elements from the raveled array into the new array using the same kind of index ordering as was used for the raveling.

>>> np.reshape(a, (2, 3)) # C-like index ordering
array([[0, 1, 2],
       [3, 4, 5]])
>>> np.reshape(np.ravel(a), (2, 3)) # equivalent to C ravel then C reshape
array([[0, 1, 2],
       [3, 4, 5]])
>>> np.reshape(a, (2, 3), order='F') # Fortran-like index ordering
array([[0, 4, 3],
       [2, 1, 5]])
>>> np.reshape(np.ravel(a, order='F'), (2, 3), order='F')
array([[0, 4, 3],
       [2, 1, 5]])
rint(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

Round elements of the array to the nearest integer.

This docstring was copied from numpy.rint

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Input array.

Returns

out – Output array is same shape and type as x. This is a scalar if x is a scalar.

Return type

ndarray or scalar

roll(a: Union[Scalar, Array, MaskedArray], shift: Union[List[Int], Int], axis: Union[NoneType, List[Int], Int] = None) → Union[Scalar, Array, MaskedArray]

Roll array elements along a given axis.

This docstring was copied from numpy.roll

Some inconsistencies with the Workflows version may exist

Elements that roll beyond the last position are re-introduced at the first.

Parameters
  • a (array_like) – Input array.

  • shift (int or tuple of ints) – The number of places by which elements are shifted. If a tuple, then axis must be a tuple of the same size, and each of the given axes is shifted by the corresponding number. If an int while axis is a tuple of ints, then the same value is used for all given axes.

  • axis (int or tuple of ints, optional) – Axis or axes along which elements are shifted. By default, the array is flattened before shifting, after which the original shape is restored.

Returns

res – Output array, with the same shape as a.

Return type

ndarray

Notes

New in version 1.12.0.

Supports rolling over multiple dimensions simultaneously.

rollaxis(a: Union[Array, MaskedArray], axis: Int, start: Int = 0) → Union[Array, MaskedArray]

Roll the specified axis backwards, until it lies in a given position.

This docstring was copied from numpy.rollaxis

Some inconsistencies with the Workflows version may exist

This function continues to be supported for backward compatibility, but you should prefer moveaxis. The moveaxis function was added in NumPy 1.11.

Parameters
  • a (ndarray) – Input array.

  • axis (int) – The axis to roll backwards. The positions of the other axes do not change relative to one another.

  • start (int, optional) – The axis is rolled until it lies before this position. The default, 0, results in a “complete” roll.

Returns

res – For NumPy >= 1.10.0 a view of a is always returned. For earlier NumPy versions a view of a is returned only if the order of the axes is changed, otherwise the input array is returned.

Return type

ndarray

round(a: Union[Scalar, Array, MaskedArray], decimals: Int = 0) → Union[Scalar, Array, MaskedArray]

Round an array to the given number of decimals.

This docstring was copied from numpy.round_

Some inconsistencies with the Workflows version may exist

sign(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Union[Scalar, Int, Array, Bool, Float, MaskedArray]

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

This docstring was copied from numpy.sign

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Input values.

Returns

y – The sign of x. This is a scalar if x is a scalar.

Return type

ndarray

signbit(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Bool

Returns element-wise True where signbit is set (less than zero).

This docstring was copied from numpy.signbit

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – The input value(s).

Returns

result – Output array, or reference to out if that was supplied. This is a scalar if x is a scalar.

Return type

ndarray of bool

sin(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

Trigonometric sine, element-wise.

This docstring was copied from numpy.sin

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Angle, in radians (\(2 \pi\) rad equals 360 degrees).

Returns

y – The sine of each element of x. This is a scalar if x is a scalar.

Return type

array_like

sinh(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

Hyperbolic sine, element-wise.

This docstring was copied from numpy.sinh

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Input array.

Returns

y – The corresponding hyperbolic sine values. This is a scalar if x is a scalar.

Return type

ndarray

spacing(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

Return the distance between x and the nearest adjacent number.

This docstring was copied from numpy.spacing

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Values to find the spacing of.

Returns

out – The spacing of values of x. This is a scalar if x is a scalar.

Return type

ndarray or scalar

sqrt(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

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

This docstring was copied from numpy.sqrt

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – The values whose square-roots are required.

Returns

y – An array of the same shape as x, containing the positive square-root of each element in x. If any element in x is complex, a complex array is returned (and the square-roots of negative reals are calculated). If all of the elements in x are real, so is y, with negative elements returning nan. If out was provided, y is a reference to it. This is a scalar if x is a scalar.

Return type

ndarray

square(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Union[Scalar, Int, Array, Bool, Float, MaskedArray]

Return the element-wise square of the input.

This docstring was copied from numpy.square

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Input data.

Returns

out – Element-wise x*x, of the same shape and dtype as x. This is a scalar if x is a scalar.

Return type

ndarray or scalar

squeeze(a: Union[Scalar, Array, MaskedArray], axis: Union[NoneType, List[Int], Int] = None) → Union[Scalar, Array, MaskedArray]

Remove single-dimensional entries from the shape of an array.

This docstring was copied from numpy.squeeze

Some inconsistencies with the Workflows version may exist

Parameters
  • a (array_like) – Input data.

  • axis (None or int or tuple of ints, optional) –

    New in version 1.7.0.

    Selects a subset of the single-dimensional entries in the shape. If an axis is selected with shape entry greater than one, an error is raised.

Returns

squeezed – The input array, but with all or a subset of the dimensions of length 1 removed. This is always a itself or a view into a.

Return type

ndarray

stack(arrays: Union[List[Array], List[MaskedArray]], axis: Int = 0) → Union[Array, MaskedArray]

Join a sequence of arrays along a new axis.

This docstring was copied from numpy.stack

Some inconsistencies with the Workflows version may exist

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.

New in version 1.10.0.

Parameters
  • arrays (sequence of array_like) – Each array must have the same shape.

  • axis (int, optional) – The axis in the result array along which the input arrays are stacked.

  • out (ndarray, optional) – If provided, the destination to place the result. The shape must be correct, matching that of what stack would have returned if no out argument were specified.

Returns

stacked – The stacked array has one more dimension than the input arrays.

Return type

ndarray

std(a: Union[Scalar, Array, MaskedArray], axis: Union[NoneType, List[Int], Int] = None) → Union[Scalar, Array, MaskedArray]

Compute the standard deviation along the specified axis.

This docstring was copied from numpy.std

Some inconsistencies with the Workflows version may exist

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.

Parameters
  • a (array_like) – Calculate the standard deviation of these values.

  • axis (None or int or tuple of ints, optional) –

    Axis or axes along which the standard deviation is computed. The default is to compute the standard deviation of the flattened array.

    New in version 1.7.0.

    If this is a tuple of ints, a standard deviation is performed over multiple axes, instead of a single axis or all the axes as before.

  • dtype (dtype, optional) – Type to use in computing the standard deviation. For arrays of integer type the default is float64, for arrays of float types it is the same as the array type.

  • out (ndarray, optional) – Alternative output array in which to place the result. It must have the same shape as the expected output but the type (of the calculated values) will be cast if necessary.

  • ddof (int, optional) – Means Delta Degrees of Freedom. The divisor used in calculations is N - ddof, where N represents the number of elements. By default ddof is zero.

  • keepdims (bool, optional) –

    If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.

    If the default value is passed, then keepdims will not be passed through to the std method of sub-classes of ndarray, however any non-default value will be. If the sub-class’ method does not implement keepdims any exceptions will be raised.

Returns

standard_deviation – If out is None, return a new array containing the standard deviation, otherwise return a reference to the output array.

Return type

ndarray, see dtype parameter above.

Notes

The standard deviation is the square root of the average of the squared deviations from the mean, i.e., std = sqrt(mean(abs(x - x.mean())**2)).

The average squared deviation is normally calculated as x.sum() / N, where N = len(x). If, however, ddof is specified, the divisor N - ddof is used instead. In standard statistical practice, ddof=1 provides an unbiased estimator of the variance of the infinite population. ddof=0 provides a maximum likelihood estimate of the variance for normally distributed variables. The standard deviation computed in this function is the square root of the estimated variance, so even with ddof=1, it will not be an unbiased estimate of the standard deviation per se.

Note that, for complex numbers, std takes the absolute value before squaring, so that the result is always real and nonnegative.

For floating-point input, the std is computed using the same precision the input has. Depending on the input data, this can cause the results to be inaccurate, especially for float32 (see example below). Specifying a higher-accuracy accumulator using the dtype keyword can alleviate this issue.

subtract(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Union[Scalar, Int, Array, Bool, Float, MaskedArray]

Subtract arguments, element-wise.

This docstring was copied from numpy.subtract

Some inconsistencies with the Workflows version may exist

Parameters

x2 (x1,) – The arrays to be subtracted from each other. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

y – The difference of x1 and x2, element-wise. This is a scalar if both x1 and x2 are scalars.

Return type

ndarray

sum(a: Union[Scalar, Array, MaskedArray], axis: Union[NoneType, List[Int], Int] = None) → Union[Scalar, Array, MaskedArray]

Sum of array elements over a given axis.

This docstring was copied from numpy.sum

Some inconsistencies with the Workflows version may exist

Parameters
  • a (array_like) – Elements to sum.

  • axis (None or int or tuple of ints, optional) –

    Axis or axes along which a sum is performed. The default, axis=None, will sum all of the elements of the input array. If axis is negative it counts from the last to the first axis.

    New in version 1.7.0.

    If axis is a tuple of ints, a sum is performed on all of the axes specified in the tuple instead of a single axis or all the axes as before.

  • dtype (dtype, optional) – The type of the returned array and of the accumulator in which the elements are summed. The dtype of a is used by default unless a has an integer dtype of less precision than the default platform integer. In that case, if a is signed then the platform integer is used while if a is unsigned then an unsigned integer of the same precision as the platform integer is used.

  • out (ndarray, optional) – Alternative output array in which to place the result. It must have the same shape as the expected output, but the type of the output values will be cast if necessary.

  • keepdims (bool, optional) –

    If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.

    If the default value is passed, then keepdims will not be passed through to the sum method of sub-classes of ndarray, however any non-default value will be. If the sub-class’ method does not implement keepdims any exceptions will be raised.

  • initial (scalar, optional) –

    Starting value for the sum. See ~numpy.ufunc.reduce for details.

    New in version 1.15.0.

  • where (array_like of bool, optional) –

    Elements to include in the sum. See ~numpy.ufunc.reduce for details.

    New in version 1.17.0.

Returns

  • sum_along_axis (ndarray) – An array with the same shape as a, with the specified axis removed. If a is a 0-d array, or if axis is None, a scalar is returned. If an output array is specified, a reference to out is returned.

  • add.reduce (Equivalent functionality of add.)

  • cumsum (Cumulative sum of array elements.)

  • trapz (Integration of array values using the composite trapezoidal rule.)

  • mean, average

Notes

Arithmetic is modular when using integer types, and no error is raised on overflow.

The sum of an empty array is the neutral element 0:

>>> np.sum([])
0.0

For floating point numbers the numerical precision of sum (and np.add.reduce) is in general limited by directly adding each number individually to the result causing rounding errors in every step. However, often numpy will use a numerically better approach (partial pairwise summation) leading to improved precision in many use-cases. This improved precision is always provided when no axis is given. When axis is given, it will depend on which axis is summed. Technically, to provide the best speed possible, the improved precision is only used when the summation is along the fast axis in memory. Note that the exact precision may vary depending on other parameters. In contrast to NumPy, Python’s math.fsum function uses a slower but more precise approach to summation. Especially when summing a large number of lower precision floating point numbers, such as float32, numerical errors can become significant. In such cases it can be advisable to use dtype=”float64” to use a higher precision for the output.

take(a: Union[Array, MaskedArray], indices: Union[Array, List[Int], Int], axis: Int = None) → Union[Array, MaskedArray]

Take elements from an array along an axis.

This docstring was copied from numpy.take

Some inconsistencies with the Workflows version may exist

When axis is not None, this function does the same thing as “fancy” indexing (indexing arrays using arrays); however, it can be easier to use if you need elements along a given axis. A call such as np.take(arr, indices, axis=3) is equivalent to arr[:,:,:,indices,...].

Explained without fancy indexing, this is equivalent to the following use of ndindex, which sets each of ii, jj, and kk to a tuple of indices:

Ni, Nk = a.shape[:axis], a.shape[axis+1:]
Nj = indices.shape
for ii in ndindex(Ni):
    for jj in ndindex(Nj):
        for kk in ndindex(Nk):
            out[ii + jj + kk] = a[ii + (indices[jj],) + kk]
Parameters
  • a (array_like (Ni..., M, Nk...)) – The source array.

  • indices (array_like (Nj...)) –

    The indices of the values to extract.

    New in version 1.8.0.

    Also allow scalars for indices.

  • axis (int, optional) – The axis over which to select values. By default, the flattened input array is used.

  • out (ndarray, optional (Ni..., Nj..., Nk...)) – If provided, the result will be placed in this array. It should be of the appropriate shape and dtype. Note that out is always buffered if mode=’raise’; use other modes for better performance.

  • mode ({'raise', 'wrap', 'clip'}, optional) –

    Specifies how out-of-bounds indices will behave.

    • ’raise’ – raise an error (default)

    • ’wrap’ – wrap around

    • ’clip’ – clip to the range

    ’clip’ mode means that all indices that are too large are replaced by the index that addresses the last element along that axis. Note that this disables indexing with negative numbers.

Returns

out – The returned array has the same type as a.

Return type

ndarray (Ni…, Nj…, Nk…)

Notes

By eliminating the inner loop in the description above, and using s_ to build simple slice objects, take can be expressed in terms of applying fancy indexing to each 1-d slice:

Ni, Nk = a.shape[:axis], a.shape[axis+1:]
for ii in ndindex(Ni):
    for kk in ndindex(Nj):
        out[ii + s_[...,] + kk] = a[ii + s_[:,] + kk][indices]

For this reason, it is equivalent to (but faster than) the following use of apply_along_axis:

out = np.apply_along_axis(lambda a_1d: a_1d[indices], axis, a)
tan(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

Compute tangent element-wise.

This docstring was copied from numpy.tan

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Input array.

Returns

y – The corresponding tangent values. This is a scalar if x is a scalar.

Return type

ndarray

tanh(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

Compute hyperbolic tangent element-wise.

This docstring was copied from numpy.tanh

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Input array.

Returns

y – The corresponding hyperbolic tangent values. This is a scalar if x is a scalar.

Return type

ndarray

tensordot(a: Union[Array, MaskedArray], b: Union[Array, MaskedArray], axes: Int = 2) → Union[Array, MaskedArray]

Compute tensor dot product along specified axes.

This docstring was copied from numpy.tensordot

Some inconsistencies with the Workflows version may exist

Given two tensors, a and b, and an array_like object containing two array_like objects, (a_axes, b_axes), sum the products of a’s and b’s elements (components) over the axes specified by a_axes and b_axes. The third argument can be a single non-negative integer_like scalar, N; if it is such, then the last N dimensions of a and the first N dimensions of b are summed over.

Parameters
  • b (a,) – Tensors to “dot”.

  • axes (int or (2,) array_like) –

    • integer_like If an int N, sum over the last N axes of a and the first N axes of b in order. The sizes of the corresponding axes must match.

    • (2,) array_like Or, a list of axes to be summed over, first sequence applying to a, second to b. Both elements array_like must be of the same length.

Returns

output – The tensor dot product of the input.

Return type

ndarray

Notes

Three common use cases are:
  • axes = 0 : tensor product \(a\otimes b\)

  • axes = 1 : tensor dot product \(a\cdot b\)

  • axes = 2 : (default) tensor double contraction \(a:b\)

When axes is integer_like, the sequence for evaluation will be: first the -Nth axis in a and 0th axis in b, and the -1th axis in a and Nth axis in b last.

When there is more than one axis to sum over - and they are not the last (first) axes of a (b) - the argument axes should consist of two sequences of the same length, with the first axis to sum over given first in both sequences, the second axis second, and so forth.

The shape of the result consists of the non-contracted axes of the first tensor, followed by the non-contracted axes of the second.

tile(A: Union[Array, MaskedArray], reps: Union[Array, List[Int], MaskedArray, Int]) → Union[Array, MaskedArray]

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

This docstring was copied from numpy.tile

Some inconsistencies with the Workflows version may exist

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

If A.ndim < d, A is promoted to be d-dimensional by prepending new axes. So a shape (3,) array is promoted to (1, 3) for 2-D replication, or shape (1, 1, 3) for 3-D replication. If this is not the desired behavior, promote A to d-dimensions manually before calling this function.

If A.ndim > d, reps is promoted to A.ndim by pre-pending 1’s to it. Thus for an A of shape (2, 3, 4, 5), a reps of (2, 2) is treated as (1, 1, 2, 2).

Note : Although tile may be used for broadcasting, it is strongly recommended to use numpy’s broadcasting operations and functions.

Parameters
  • A (array_like) – The input array.

  • reps (array_like) – The number of repetitions of A along each axis.

Returns

c – The tiled output array.

Return type

ndarray

trace(a: Union[Array, MaskedArray], offset: Int = 0, axis1: Int = 0, axis2: Int = 1) → Union[Array, MaskedArray]

Return the sum along diagonals of the array.

This docstring was copied from numpy.trace

Some inconsistencies with the Workflows version may exist

If a is 2-D, the sum along its diagonal with the given offset is returned, i.e., the sum of elements a[i,i+offset] for all i.

If a has more than two dimensions, then the axes specified by axis1 and axis2 are used to determine the 2-D sub-arrays whose traces are returned. The shape of the resulting array is the same as that of a with axis1 and axis2 removed.

Parameters
  • a (array_like) – Input array, from which the diagonals are taken.

  • offset (int, optional) – Offset of the diagonal from the main diagonal. Can be both positive and negative. Defaults to 0.

  • axis2 (axis1,) – Axes to be used as the first and second axis of the 2-D sub-arrays from which the diagonals should be taken. Defaults are the first two axes of a.

  • dtype (dtype, optional) – Determines the data-type of the returned array and of the accumulator where the elements are summed. If dtype has the value None and a is of integer type of precision less than the default integer precision, then the default integer precision is used. Otherwise, the precision is the same as that of a.

  • out (ndarray, optional) – Array into which the output is placed. Its type is preserved and it must be of the right shape to hold the output.

Returns

sum_along_diagonals – If a is 2-D, the sum along the diagonal is returned. If a has larger dimensions, then an array of sums along diagonals is returned.

Return type

ndarray

transpose(a: Union[Array, MaskedArray], axes: Optional[List[Int]] = None) → Union[Array, MaskedArray]

Permute the dimensions of an array.

This docstring was copied from numpy.transpose

Some inconsistencies with the Workflows version may exist

Parameters
  • a (array_like) – Input array.

  • axes (list of ints, optional) – By default, reverse the dimensions, otherwise permute the axes according to the values given.

Returns

pa with its axes permuted. A view is returned whenever possible.

Return type

ndarray

Notes

Use transpose(a, argsort(axes)) to invert the transposition of tensors when using the axes keyword argument.

Transposing a 1-D array returns an unchanged view of the original array.

tril(m: Union[Array, MaskedArray], k: Int = 0) → Union[Array, MaskedArray]

Lower triangle of an array.

This docstring was copied from numpy.tril

Some inconsistencies with the Workflows version may exist

Return a copy of an array with elements above the k-th diagonal zeroed.

Parameters
  • m (array_like, shape (M, N)) – Input array.

  • k (int, optional) – Diagonal above which to zero elements. k = 0 (the default) is the main diagonal, k < 0 is below it and k > 0 is above.

Returns

tril – Lower triangle of m, of same shape and data-type as m.

Return type

ndarray, shape (M, N)

triu(m: Union[Array, MaskedArray], k: Int = 0) → Union[Array, MaskedArray]

Upper triangle of an array.

This docstring was copied from numpy.triu

Some inconsistencies with the Workflows version may exist

Return a copy of a matrix with the elements below the k-th diagonal zeroed.

Please refer to the documentation for tril for further details.

true_divide(x1: Union[Scalar, Int, Array, Bool, Float, MaskedArray], x2: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Float

Returns a true division of the inputs, element-wise.

This docstring was copied from numpy.true_divide

Some inconsistencies with the Workflows version may exist

Parameters
  • x1 (array_like) – Dividend array.

  • x2 (array_like) – Divisor array. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

out – This is a scalar if both x1 and x2 are scalars.

Return type

ndarray or scalar

trunc(x: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → Union[Scalar, Int, Array, Bool, Float, MaskedArray]

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

This docstring was copied from numpy.trunc

Some inconsistencies with the Workflows version may exist

Parameters

x (array_like) – Input data.

Returns

y – The truncated value of each element in x. This is a scalar if x is a scalar.

Return type

ndarray or scalar

unique(ar: Union[Array, MaskedArray]) → Array

Find the unique elements of an array.

This docstring was copied from numpy.unique

Some inconsistencies with the Workflows version may exist

Returns the sorted unique elements of an array. There are three optional outputs in addition to the unique elements:

  • the indices of the input array that give the unique values

  • the indices of the unique array that reconstruct the input array

  • the number of times each unique value comes up in the input array

Parameters
  • ar (array_like) – Input array. Unless axis is specified, this will be flattened if it is not already 1-D.

  • return_index (bool, optional) – If True, also return the indices of ar (along the specified axis, if provided, or in the flattened array) that result in the unique array.

  • return_inverse (bool, optional) – If True, also return the indices of the unique array (for the specified axis, if provided) that can be used to reconstruct ar.

  • return_counts (bool, optional) –

    If True, also return the number of times each unique item appears in ar.

    New in version 1.9.0.

  • axis (int or None, optional) –

    The axis to operate on. If None, ar will be flattened. If an integer, the subarrays indexed by the given axis will be flattened and treated as the elements of a 1-D array with the dimension of the given axis, see the notes for more details. Object arrays or structured arrays that contain objects are not supported if the axis kwarg is used. The default is None.

    New in version 1.13.0.

Returns

  • unique (ndarray) – The sorted unique values.

  • unique_indices (ndarray, optional) – The indices of the first occurrences of the unique values in the original array. Only provided if return_index is True.

  • unique_inverse (ndarray, optional) – The indices to reconstruct the original array from the unique array. Only provided if return_inverse is True.

  • unique_counts (ndarray, optional) – The number of times each of the unique values comes up in the original array. Only provided if return_counts is True.

    New in version 1.9.0.

Notes

When an axis is specified the subarrays indexed by the axis are sorted. This is done by making the specified axis the first dimension of the array (move the axis to the first dimension to keep the order of the other axes) and then flattening the subarrays in C order. The flattened subarrays are then viewed as a structured type with each element given a label, with the effect that we end up with a 1-D array of structured types that can be treated in the same way as any other 1-D array. The result is that the flattened subarrays are sorted in lexicographic order starting with the first element.

unravel_index(indices: Union[Scalar, Array, MaskedArray], shape: List[Int]) → Union[List[Array], List[Scalar]]

Converts a flat index or array of flat indices into a tuple of coordinate arrays.

This docstring was copied from numpy.unravel_index

Some inconsistencies with the Workflows version may exist

Parameters
  • indices (array_like) – An integer array whose elements are indices into the flattened version of an array of dimensions shape. Before version 1.6.0, this function accepted just one index value.

  • shape (tuple of ints) –

    The shape of the array to use for unraveling indices.

    Changed in version 1.16.0: Renamed from dims to shape.

  • order ({'C', 'F'}, optional) –

    Determines whether the indices should be viewed as indexing in row-major (C-style) or column-major (Fortran-style) order.

    New in version 1.6.0.

Returns

unraveled_coords – Each array in the tuple has the same shape as the indices array.

Return type

tuple of ndarray

var(a: Union[Array, MaskedArray], axis: Union[NoneType, List[Int], Int] = None, ddof: Int = 0) → Union[Scalar, Array]

Compute the variance along the specified axis.

This docstring was copied from numpy.var

Some inconsistencies with the Workflows version may exist

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.

Parameters
  • a (array_like) – Array containing numbers whose variance is desired. If a is not an array, a conversion is attempted.

  • axis (None or int or tuple of ints, optional) –

    Axis or axes along which the variance is computed. The default is to compute the variance of the flattened array.

    New in version 1.7.0.

    If this is a tuple of ints, a variance is performed over multiple axes, instead of a single axis or all the axes as before.

  • dtype (data-type, optional) – Type to use in computing the variance. For arrays of integer type the default is float64; for arrays of float types it is the same as the array type.

  • out (ndarray, optional) – Alternate output array in which to place the result. It must have the same shape as the expected output, but the type is cast if necessary.

  • ddof (int, optional) – “Delta Degrees of Freedom”: the divisor used in the calculation is N - ddof, where N represents the number of elements. By default ddof is zero.

  • keepdims (bool, optional) –

    If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.

    If the default value is passed, then keepdims will not be passed through to the var method of sub-classes of ndarray, however any non-default value will be. If the sub-class’ method does not implement keepdims any exceptions will be raised.

Returns

variance – If out=None, returns a new array containing the variance; otherwise, a reference to the output array is returned.

Return type

ndarray, see dtype parameter above

Notes

The variance is the average of the squared deviations from the mean, i.e., var = mean(abs(x - x.mean())**2).

The mean is normally calculated as x.sum() / N, where N = len(x). If, however, ddof is specified, the divisor N - ddof is used instead. In standard statistical practice, ddof=1 provides an unbiased estimator of the variance of a hypothetical infinite population. ddof=0 provides a maximum likelihood estimate of the variance for normally distributed variables.

Note that for complex numbers, the absolute value is taken before squaring, so that the result is always real and nonnegative.

For floating-point input, the variance is computed using the same precision the input has. Depending on the input data, this can cause the results to be inaccurate, especially for float32 (see example below). Specifying a higher-accuracy accumulator using the dtype keyword can alleviate this issue.

vdot(a: Union[Scalar, Array, MaskedArray], b: Union[Scalar, Array, MaskedArray]) → Array

Return the dot product of two vectors.

This docstring was copied from numpy.vdot

Some inconsistencies with the Workflows version may exist

The vdot(a, b) function handles complex numbers differently than dot(a, b). If the first argument is complex the complex conjugate of the first argument is used for the calculation of the dot product.

Note that vdot handles multidimensional arrays differently than dot: it does not perform a matrix product, but flattens input arguments to 1-D vectors first. Consequently, it should only be used for vectors.

Parameters
  • a (array_like) – If a is complex the complex conjugate is taken before calculation of the dot product.

  • b (array_like) – Second argument to the dot product.

Returns

output – Dot product of a and b. Can be an int, float, or complex depending on the types of a and b.

Return type

ndarray

vstack(arrays: Union[List[Array], List[MaskedArray]]) → Union[Array, MaskedArray]

Stack arrays in sequence vertically (row wise).

This docstring was copied from numpy.vstack

Some inconsistencies with the Workflows version may exist

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.

Parameters

tup (sequence of ndarrays) – The arrays must have the same shape along all but the first axis. 1-D arrays must have the same length.

Returns

stacked – The array formed by stacking the given arrays, will be at least 2-D.

Return type

ndarray

where(condition: Array, x: Union[Scalar, Array, MaskedArray], y: Union[Scalar, Array, MaskedArray]) → Array

Return elements chosen from x or y depending on condition.

This docstring was copied from numpy.where

Some inconsistencies with the Workflows version may exist

Note

When only condition is provided, this function is a shorthand for np.asarray(condition).nonzero(). Using nonzero directly should be preferred, as it behaves correctly for subclasses. The rest of this documentation covers only the case where all three arguments are provided.

Parameters
  • condition (array_like, bool) – Where True, yield x, otherwise yield y.

  • y (x,) – Values from which to choose. x, y and condition need to be broadcastable to some shape.

Returns

out – An array with elements from x where condition is True, and elements from y elsewhere.

Return type

ndarray

Notes

If all the arrays are 1-D, where is equivalent to:

[xv if c else yv
 for c, xv, yv in zip(condition, x, y)]
zeros(shape: Union[List[Int], Int], dtype: DType = <descarteslabs.workflows.types.array.dtype.DType object>) → Array

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

This docstring was copied from numpy.zeros

Some inconsistencies with the Workflows version may exist

Parameters
  • shape (int or tuple of ints) – Shape of the new array, e.g., (2, 3) or 2.

  • dtype (data-type, optional) – The desired data-type for the array, e.g., numpy.int8. Default is numpy.float64.

  • order ({'C', 'F'}, optional, default: 'C') – Whether to store multi-dimensional data in row-major (C-style) or column-major (Fortran-style) order in memory.

Returns

out – Array of zeros with the given shape, dtype, and order.

Return type

ndarray

zeros_like(a: Union[Scalar, Array, MaskedArray]) → Union[Scalar, Array]

Return an array of zeros with the same shape and type as a given array.

This docstring was copied from numpy.zeros_like

Some inconsistencies with the Workflows version may exist

Parameters
  • a (array_like) – The shape and data-type of a define these same attributes of the returned array.

  • dtype (data-type, optional) –

    Overrides the data type of the result.

    New in version 1.6.0.

  • order ({'C', 'F', 'A', or 'K'}, optional) –

    Overrides the memory layout of the result. ‘C’ means C-order, ‘F’ means F-order, ‘A’ means ‘F’ if a is Fortran contiguous, ‘C’ otherwise. ‘K’ means match the layout of a as closely as possible.

    New in version 1.6.0.

  • subok (bool, optional.) – If True, then the newly created array will use the sub-class type of ‘a’, otherwise it will be a base-class array. Defaults to True.

  • shape (int or sequence of ints, optional.) –

    Overrides the shape of the result. If order=’K’ and the number of dimensions is unchanged, will try to keep order, otherwise, order=’C’ is implied.

    New in version 1.17.0.

Returns

out – Array of zeros with the same shape and type as a.

Return type

ndarray

cholesky(a: Array) → Array

Cholesky decomposition.

This docstring was copied from numpy.cholesky

Some inconsistencies with the Workflows version may exist

Return the Cholesky decomposition, L * L.H, of the square matrix a, where L is lower-triangular and .H is the conjugate transpose operator (which is the ordinary transpose if a is real-valued). a must be Hermitian (symmetric if real-valued) and positive-definite. Only L is actually returned.

Parameters

a ((.., M, M) array_like) – Hermitian (symmetric if all elements are real), positive-definite input matrix.

Returns

L – Upper or lower-triangular Cholesky factor of a. Returns a matrix object if a is a matrix object.

Return type

(.., M, M) array_like

Notes

New in version 1.8.0.

Broadcasting rules apply, see the numpy.linalg documentation for details.

The Cholesky decomposition is often used as a fast way of solving

\[A \mathbf{x} = \mathbf{b}\]

(when A is both Hermitian/symmetric and positive-definite).

First, we solve for \(\mathbf{y}\) in

\[L \mathbf{y} = \mathbf{b},\]

and then for \(\mathbf{x}\) in

\[L.H \mathbf{x} = \mathbf{y}.\]
inv(a: Array) → Array

Compute the (multiplicative) inverse of a matrix.

This docstring was copied from numpy.inv

Some inconsistencies with the Workflows version may exist

Given a square matrix a, return the matrix ainv satisfying dot(a, ainv) = dot(ainv, a) = eye(a.shape[0]).

Parameters

a ((.., M, M) array_like) – Matrix to be inverted.

Returns

ainv – (Multiplicative) inverse of the matrix a.

Return type

(.., M, M) ndarray or matrix

Notes

New in version 1.8.0.

Broadcasting rules apply, see the numpy.linalg documentation for details.

lstsq(a: Array, b: Array) → Tuple[Array, Array, Array, Array]

Return the least-squares solution to a linear matrix equation.

This docstring was copied from numpy.lstsq

Some inconsistencies with the Workflows version may exist

Solves the equation \(a x = b\) by computing a vector x that minimizes the squared Euclidean 2-norm \(\| b - a x \|^2_2\). The equation may be under-, well-, or over-determined (i.e., the number of linearly independent rows of a can be less than, equal to, or greater than its number of linearly independent columns). If a is square and of full rank, then x (but for round-off error) is the “exact” solution of the equation.

Parameters
  • a ((M, N) array_like) – “Coefficient” matrix.

  • b ({(M,), (M, K)} array_like) – Ordinate or “dependent variable” values. If b is two-dimensional, the least-squares solution is calculated for each of the K columns of b.

  • rcond (float, optional) –

    Cut-off ratio for small singular values of a. For the purposes of rank determination, singular values are treated as zero if they are smaller than rcond times the largest singular value of a.

    Changed in version 1.14.0: If not set, a FutureWarning is given. The previous default of -1 will use the machine precision as rcond parameter, the new default will use the machine precision times max(M, N). To silence the warning and use the new default, use rcond=None, to keep using the old behavior, use rcond=-1.

Returns

  • x ({(N,), (N, K)} ndarray) – Least-squares solution. If b is two-dimensional, the solutions are in the K columns of x.

  • residuals ({(1,), (K,), (0,)} ndarray) – Sums of residuals; squared Euclidean 2-norm for each column in b - a*x. If the rank of a is < N or M <= N, this is an empty array. If b is 1-dimensional, this is a (1,) shape array. Otherwise the shape is (K,).

  • rank (int) – Rank of matrix a.

  • s ((min(M, N),) ndarray) – Singular values of a.

Notes

If b is a matrix, then all array results are returned as matrices.

norm(x: Array, ord: Optional[Int] = None, axis: Optional[Int] = None) → Union[Scalar, Array]

Matrix or vector norm.

This docstring was copied from numpy.norm

Some inconsistencies with the Workflows version may exist

This function is able to return one of eight different matrix norms, or one of an infinite number of vector norms (described below), depending on the value of the ord parameter.

Parameters
  • x (array_like) – Input array. If axis is None, x must be 1-D or 2-D, unless ord is None. If both axis and ord are None, the 2-norm of x.ravel will be returned.

  • ord ({non-zero int, inf, -inf, 'fro', 'nuc'}, optional) – Order of the norm (see table under Notes). inf means numpy’s inf object. The default is None.

  • axis ({None, int, 2-tuple of ints}, optional.) –

    If axis is an integer, it specifies the axis of x along which to compute the vector norms. If axis is a 2-tuple, it specifies the axes that hold 2-D matrices, and the matrix norms of these matrices are computed. If axis is None then either a vector norm (when x is 1-D) or a matrix norm (when x is 2-D) is returned. The default is None.

    New in version 1.8.0.

  • keepdims (bool, optional) –

    If this is set to True, the axes which are normed over are left in the result as dimensions with size one. With this option the result will broadcast correctly against the original x.

    New in version 1.10.0.

Returns

n – Norm of the matrix or vector(s).

Return type

float or ndarray

Notes

For values of ord <= 0, the result is, strictly speaking, not a mathematical ‘norm’, but it may still be useful for various numerical purposes.

The following norms can be calculated:

ord

norm for matrices

norm for vectors

None

Frobenius norm

2-norm

‘fro’

Frobenius norm

‘nuc’

nuclear norm

inf

max(sum(abs(x), axis=1))

max(abs(x))

-inf

min(sum(abs(x), axis=1))

min(abs(x))

0

sum(x != 0)

1

max(sum(abs(x), axis=0))

as below

-1

min(sum(abs(x), axis=0))

as below

2

2-norm (largest sing. value)

as below

-2

smallest singular value

as below

other

sum(abs(x)**ord)**(1./ord)

The Frobenius norm is given by :

\(||A||_F = [\sum_{i,j} abs(a_{i,j})^2]^{1/2}\)

The nuclear norm is the sum of the singular values.

qr(a: Array, mode: Str = 'reduced') → Tuple[Array, Array]

Compute the qr factorization of a matrix.

This docstring was copied from numpy.qr

Some inconsistencies with the Workflows version may exist

Factor the matrix a as qr, where q is orthonormal and r is upper-triangular.

Parameters
  • a (array_like, shape (M, N)) – Matrix to be factored.

  • mode ({'reduced', 'complete', 'r', 'raw'}, optional) –

    If K = min(M, N), then

    • ’reduced’ : returns q, r with dimensions (M, K), (K, N) (default)

    • ’complete’ : returns q, r with dimensions (M, M), (M, N)

    • ’r’ : returns r only with dimensions (K, N)

    • ’raw’ : returns h, tau with dimensions (N, M), (K,)

    The options ‘reduced’, ‘complete, and ‘raw’ are new in numpy 1.8, see the notes for more information. The default is ‘reduced’, and to maintain backward compatibility with earlier versions of numpy both it and the old default ‘full’ can be omitted. Note that array h returned in ‘raw’ mode is transposed for calling Fortran. The ‘economic’ mode is deprecated. The modes ‘full’ and ‘economic’ may be passed using only the first letter for backwards compatibility, but all others must be spelled out. See the Notes for more explanation.

Returns

  • q (ndarray of float or complex, optional) – A matrix with orthonormal columns. When mode = ‘complete’ the result is an orthogonal/unitary matrix depending on whether or not a is real/complex. The determinant may be either +/- 1 in that case.

  • r (ndarray of float or complex, optional) – The upper-triangular matrix.

  • (h, tau) (ndarrays of np.double or np.cdouble, optional) – The array h contains the Householder reflectors that generate q along with r. The tau array contains scaling factors for the reflectors. In the deprecated ‘economic’ mode only h is returned.

Notes

This is an interface to the LAPACK routines dgeqrf, zgeqrf, dorgqr, and zungqr.

For more information on the qr factorization, see for example: https://en.wikipedia.org/wiki/QR_factorization

Subclasses of ndarray are preserved except for the ‘raw’ mode. So if a is of type matrix, all the return values will be matrices too.

New ‘reduced’, ‘complete’, and ‘raw’ options for mode were added in NumPy 1.8.0 and the old option ‘full’ was made an alias of ‘reduced’. In addition the options ‘full’ and ‘economic’ were deprecated. Because ‘full’ was the previous default and ‘reduced’ is the new default, backward compatibility can be maintained by letting mode default. The ‘raw’ option was added so that LAPACK routines that can multiply arrays by q using the Householder reflectors can be used. Note that in this case the returned arrays are of type np.double or np.cdouble and the h array is transposed to be FORTRAN compatible. No routines using the ‘raw’ return are currently exposed by numpy, but some are available in lapack_lite and just await the necessary work.

solve(a: Array, b: Array) → Array

Solve a linear matrix equation, or system of linear scalar equations.

This docstring was copied from numpy.solve

Some inconsistencies with the Workflows version may exist

Computes the “exact” solution, x, of the well-determined, i.e., full rank, linear matrix equation ax = b.

Parameters
  • a ((.., M, M) array_like) – Coefficient matrix.

  • b ({(.., M,), (.., M, K)}, array_like) – Ordinate or “dependent variable” values.

Returns

x – Solution to the system a x = b. Returned shape is identical to b.

Return type

{(.., M,), (.., M, K)} ndarray

Notes

New in version 1.8.0.

Broadcasting rules apply, see the numpy.linalg documentation for details.

The solutions are computed using LAPACK routine _gesv.

a must be square and of full-rank, i.e., all rows (or, equivalently, columns) must be linearly independent; if either is not true, use lstsq for the least-squares best “solution” of the system/equation.

svd(a: Array) → Tuple[Array, Array, Array]

Singular Value Decomposition.

This docstring was copied from numpy.svd

Some inconsistencies with the Workflows version may exist

When a is a 2D array, it is factorized as u @ np.diag(s) @ vh = (u * s) @ vh, where u and vh are 2D unitary arrays and s is a 1D array of a’s singular values. When a is higher-dimensional, SVD is applied in stacked mode as explained below.

Parameters
  • a ((.., M, N) array_like) – A real or complex array with a.ndim >= 2.

  • full_matrices (bool, optional) – If True (default), u and vh have the shapes (..., M, M) and (..., N, N), respectively. Otherwise, the shapes are (..., M, K) and (..., K, N), respectively, where K = min(M, N).

  • compute_uv (bool, optional) – Whether or not to compute u and vh in addition to s. True by default.

  • hermitian (bool, optional) –

    If True, a is assumed to be Hermitian (symmetric if real-valued), enabling a more efficient method for finding singular values. Defaults to False.

    New in version 1.17.0.

Returns

  • u ({ (…, M, M), (…, M, K) } array) – Unitary array(s). The first a.ndim - 2 dimensions have the same size as those of the input a. The size of the last two dimensions depends on the value of full_matrices. Only returned when compute_uv is True.

  • s ((…, K) array) – Vector(s) with the singular values, within each vector sorted in descending order. The first a.ndim - 2 dimensions have the same size as those of the input a.

  • vh ({ (…, N, N), (…, K, N) } array) – Unitary array(s). The first a.ndim - 2 dimensions have the same size as those of the input a. The size of the last two dimensions depends on the value of full_matrices. Only returned when compute_uv is True.

Notes

Changed in version 1.8.0: Broadcasting rules apply, see the numpy.linalg documentation for details.

The decomposition is performed using LAPACK routine _gesdd.

SVD is usually described for the factorization of a 2D matrix \(A\). The higher-dimensional case will be discussed below. In the 2D case, SVD is written as \(A = U S V^H\), where \(A = a\), \(U= u\), \(S= \mathtt{np.diag}(s)\) and \(V^H = vh\). The 1D array s contains the singular values of a and u and vh are unitary. The rows of vh are the eigenvectors of \(A^H A\) and the columns of u are the eigenvectors of \(A A^H\). In both cases the corresponding (possibly non-zero) eigenvalues are given by s**2.

If a has more than two dimensions, then broadcasting rules apply, as explained in Linear algebra on several matrices at once.. This means that SVD is working in “stacked” mode: it iterates over all indices of the first a.ndim - 2 dimensions and for each combination SVD is applied to the last two indices. The matrix a can be reconstructed from the decomposition with either (u * s[..., None, :]) @ vh or u @ (s[..., None] * vh). (The @ operator can be replaced by the function np.matmul for python versions below 3.5.)

If a is a matrix object (as opposed to an ndarray), then so are all the return values.

average(a: MaskedArray, axis: Union[NoneType, List[Int], Int] = None, weights: Union[Scalar, Array, MaskedArray] = None) → Union[Scalar, MaskedArray]

Return the weighted average of array over the given axis.

This docstring was copied from numpy.average

Some inconsistencies with the Workflows version may exist

Parameters
  • a (array_like) – Data to be averaged. Masked entries are not taken into account in the computation.

  • axis (int, optional) – Axis along which to average a. If None, averaging is done over the flattened array.

  • weights (array_like, optional) –

    The importance that each element has in the computation of the average. The weights array can either be 1-D (in which case its length must be the size of a along the given axis) or of the same shape as a. If weights=None, then all data in a are assumed to have a weight equal to one. The 1-D calculation is:

    avg = sum(a * weights) / sum(weights)
    

    The only constraint on weights is that sum(weights) must not be 0.

  • returned (bool, optional) – Flag indicating whether a tuple (result, sum of weights) should be returned as output (True), or just the result (False). Default is False.

Returns

average, [sum_of_weights] – The average along the specified axis. When returned is True, return a tuple with the average as the first element and the sum of the weights as the second element. The return type is np.float64 if a is of integer type and floats smaller than float64, or the input data-type, otherwise. If returned, sum_of_weights is always float64.

Return type

(tuple of) scalar or MaskedArray

filled(a: MaskedArray, fill_value: Union[Scalar, Int, Array, Bool, Float, NoneType, MaskedArray] = None) → Array

Return input as an array with masked data replaced by a fill value.

This docstring was copied from numpy.filled

Some inconsistencies with the Workflows version may exist

If a is not a MaskedArray, a itself is returned. If a is a MaskedArray and fill_value is None, fill_value is set to a.fill_value.

Parameters
  • a (MaskedArray or array_like) – An input object.

  • fill_value (array_like, optional.) – Can be scalar or non-scalar. If non-scalar, the resulting filled array should be broadcastable over input array. Default is None.

Returns

a – The filled array.

Return type

ndarray

fix_invalid(a: Union[Array, MaskedArray], fill_value: Union[Scalar, Int, Array, Bool, Float, MaskedArray]) → MaskedArray

Return input with invalid data masked and replaced by a fill value.

This docstring was copied from numpy.fix_invalid

Some inconsistencies with the Workflows version may exist

Invalid data means values of nan, inf, etc.

Parameters
  • a (array_like) – Input array, a (subclass of) ndarray.

  • mask (sequence, optional) – Mask. Must be convertible to an array of booleans with the same shape as data. True indicates a masked (i.e. invalid) data.

  • copy (bool, optional) – Whether to use a copy of a (True) or to fix a in place (False). Default is True.

  • fill_value (scalar, optional) – Value used for fixing invalid data. Default is None, in which case the a.fill_value is used.

Returns

b – The input array with invalid entries fixed.

Return type

MaskedArray

Notes

A copy is performed by default.

masked_array(data, mask=False, fill_value=None)

Proxy MaskedArray representing a multidimensional, homogenous array of fixed-size items that may have missing or invalid entries. MaskedArray follows the same syntax as NumPy masked arrays. It supports vectorized operations, broadcasting, and multidimensional indexing. There are some limitations including slicing with lists/arrays in multiple axes (x[[1, 2, 3], [3, 2, 1]]) and slicing with a multidimensional list/array of integers.

Note

MaskedArray is an experimental API. It may be changed in the future, will not necessarily be backwards compatible, and may have unexpected bugs. Please contact us with any feedback!

Examples

>>> import descarteslabs.workflows as wf
>>> arr = wf.MaskedArray(data=[1, 2, 3, 4], mask=[True, False, False, True], fill_value=0)
>>> arr
<descarteslabs.workflows.types.array.masked_array.MaskedArray object at 0x...>
>>> arr.compute(geoctx) 
masked_array(data=[--, 2, 3, --],
             mask=[ True, False, False,  True],
       fill_value=0)
masked_equal(x: Union[Array, MaskedArray], value: Union[Bool, Float, Scalar, Int]) → MaskedArray

Mask an array where equal to a given value.

This docstring was copied from numpy.masked_equal

Some inconsistencies with the Workflows version may exist

This function is a shortcut to masked_where, with condition = (x == value). For floating point arrays, consider using masked_values(x, value).

masked_greater(x: Union[Array, MaskedArray], value: Union[Bool, Float, Scalar, Int]) → MaskedArray

Mask an array where greater than a given value.

This docstring was copied from numpy.masked_greater

Some inconsistencies with the Workflows version may exist

This function is a shortcut to masked_where, with condition = (x > value).

masked_greater_equal(x: Union[Array, MaskedArray], value: Union[Bool, Float, Scalar, Int]) → MaskedArray

Mask an array where greater than or equal to a given value.

This docstring was copied from numpy.masked_greater_equal

Some inconsistencies with the Workflows version may exist

This function is a shortcut to masked_where, with condition = (x >= value).

masked_inside(x: Union[Array, MaskedArray], v1: Union[Bool, Float, Scalar, Int], v2: Union[Bool, Float, Scalar, Int]) → MaskedArray

Mask an array inside a given interval.

This docstring was copied from numpy.masked_inside

Some inconsistencies with the Workflows version may exist

Shortcut to masked_where, where condition is True for x inside the interval [v1,v2] (v1 <= x <= v2). The boundaries v1 and v2 can be given in either order.

Notes

The array x is prefilled with its filling value.

masked_invalid(a: Union[Array, MaskedArray]) → MaskedArray

Mask an array where invalid values occur (NaNs or infs).

This docstring was copied from numpy.masked_invalid

Some inconsistencies with the Workflows version may exist

This function is a shortcut to masked_where, with condition = ~(np.isfinite(a)). Any pre-existing mask is conserved. Only applies to arrays with a dtype where NaNs or infs make sense (i.e. floating point types), but accepts any array_like object.

masked_less(x: Union[Array, MaskedArray], value: Union[Bool, Float, Scalar, Int]) → MaskedArray

Mask an array where less than a given value.

This docstring was copied from numpy.masked_less

Some inconsistencies with the Workflows version may exist

This function is a shortcut to masked_where, with condition = (x < value).

masked_less_equal(x: Union[Array, MaskedArray], value: Union[Bool, Float, Scalar, Int]) → MaskedArray

Mask an array where less than or equal to a given value.

This docstring was copied from numpy.masked_less_equal

Some inconsistencies with the Workflows version may exist

This function is a shortcut to masked_where, with condition = (x <= value).

masked_not_equal(x: Union[Array, MaskedArray], value: Union[Bool, Float, Scalar, Int]) → MaskedArray

Mask an array where not equal to a given value.

This docstring was copied from numpy.masked_not_equal

Some inconsistencies with the Workflows version may exist

This function is a shortcut to masked_where, with condition = (x != value).

masked_outside(x: Union[Array, MaskedArray], v1: Union[Bool, Float, Scalar, Int], v2: Union[Bool, Float, Scalar, Int]) → MaskedArray

Mask an array outside a given interval.

This docstring was copied from numpy.masked_outside

Some inconsistencies with the Workflows version may exist

Shortcut to masked_where, where condition is True for x outside the interval [v1,v2] (x < v1)|(x > v2). The boundaries v1 and v2 can be given in either order.

Notes

The array x is prefilled with its filling value.

masked_values(x: Union[Array, MaskedArray], value: Union[Bool, Float, Scalar, Int], rtol: Union[Float, Int] = 1e-05, atol: Union[Float, Int] = 1e-08, shrink: Bool = True) → MaskedArray

Mask using floating point equality.

This docstring was copied from numpy.masked_values

Some inconsistencies with the Workflows version may exist

Return a MaskedArray, masked where the data in array x are approximately equal to value, determined using isclose. The default tolerances for masked_values are the same as those for isclose.

For integer types, exact equality is used, in the same way as masked_equal.

The fill_value is set to value and the mask is set to nomask if possible.

Parameters
  • x (array_like) – Array to mask.

  • value (float) – Masking value.

  • atol (rtol,) – Tolerance parameters passed on to isclose

  • copy (bool, optional) – Whether to return a copy of x.

  • shrink (bool, optional) – Whether to collapse a mask full of False to nomask.

Returns

result – The result of masking x where approximately equal to value.

Return type

MaskedArray

masked_where(condition: Union[Scalar, Int, Array, Bool, Float, MaskedArray], a: Union[Array, MaskedArray]) → MaskedArray

Mask an array where a condition is met.

This docstring was copied from numpy.masked_where

Some inconsistencies with the Workflows version may exist

Return a as an array masked where condition is True. Any masked values of a or condition are also masked in the output.

Parameters
  • condition (array_like) – Masking condition. When condition tests floating point values for equality, consider using masked_values instead.

  • a (array_like) – Array to mask.

  • copy (bool) – If True (default) make a copy of a in the result. If False modify a in place and return a view.

Returns

result – The result of masking a where condition is True.

Return type

MaskedArray