API¶
Top level user functions:
add (x1, x2, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.add. 
all (a[, axis, keepdims, split_every, out]) 
Test whether all array elements along a given axis evaluate to True. 
allclose (arr1, arr2[, rtol, atol, equal_nan]) 
Returns True if two arrays are elementwise equal within a tolerance. 
angle (x[, deg]) 
Return the angle of the complex argument. 
any (a[, axis, keepdims, split_every, out]) 
Test whether any array element along a given axis evaluates to True. 
append (arr, values[, axis]) 
Append values to the end of an array. 
apply_along_axis (func1d, axis, arr, *args[, …]) 
Apply a function to 1D slices along the given axis. 
apply_over_axes (func, a, axes) 
Apply a function repeatedly over multiple axes. 
arange (*args, **kwargs) 
Return evenly spaced values from start to stop with step size step. 
arccos (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.arccos. 
arccosh (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.arccosh. 
arcsin (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.arcsin. 
arcsinh (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.arcsinh. 
arctan (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.arctan. 
arctan2 (x1, x2, /[, out, where, casting, …]) 
This docstring was copied from numpy.arctan2. 
arctanh (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.arctanh. 
argmax (x[, axis, split_every, out]) 
Return the maximum of an array or maximum along an axis. 
argmin (x[, axis, split_every, out]) 
Return the minimum of an array or minimum along an axis. 
argtopk (a, k[, axis, split_every]) 
Extract the indices of the k largest elements from a on the given axis, and return them sorted from largest to smallest. 
argwhere (a) 
Find the indices of array elements that are nonzero, grouped by element. 
around (x[, decimals]) 
Evenly round to the given number of decimals. 
array (object[, dtype, copy, order, subok, …]) 
This docstring was copied from numpy.array. 
asanyarray (a) 
Convert the input to a dask array. 
asarray (a, **kwargs) 
Convert the input to a dask 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, returned]) 
Compute the weighted average along the specified axis. 
bincount (x[, weights, minlength]) 
This docstring was copied from numpy.bincount. 
bitwise_and (x1, x2, /[, out, where, …]) 
This docstring was copied from numpy.bitwise_and. 
bitwise_not (x, /[, out, where, casting, …]) 
This docstring was copied from numpy.invert. 
bitwise_or (x1, x2, /[, out, where, casting, …]) 
This docstring was copied from numpy.bitwise_or. 
bitwise_xor (x1, x2, /[, out, where, …]) 
This docstring was copied from numpy.bitwise_xor. 
block (arrays[, allow_unknown_chunksizes]) 
Assemble an ndarray from nested lists of blocks. 
blockwise (func, out_ind, *args[, name, …]) 
Tensor operation: Generalized inner and outer products 
broadcast_arrays (*args, **kwargs) 
Broadcast any number of arrays against each other. 
broadcast_to (x, shape[, chunks, meta]) 
Broadcast an array to a new shape. 
cbrt (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.cbrt. 
coarsen (reduction, x, axes[, trim_excess]) 
Coarsen array by applying reduction to fixed size neighborhoods 
ceil (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.ceil. 
choose (a, choices) 
Construct an array from an index array and a set of arrays to choose from. 
clip (*args, **kwargs) 
Clip (limit) the values in an array. 
compress (condition, a[, axis]) 
Return selected slices of an array along given axis. 
concatenate (seq[, axis, …]) 
Concatenate arrays along an existing axis 
conj (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.conjugate. 
copysign (x1, x2, /[, out, where, casting, …]) 
This docstring was copied from numpy.copysign. 
corrcoef (x[, y, rowvar]) 
Return Pearson productmoment correlation coefficients. 
cos (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.cos. 
cosh (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.cosh. 
count_nonzero (a[, axis]) 
Counts the number of nonzero values in the array a . 
cov (m[, y, rowvar, bias, ddof]) 
Estimate a covariance matrix, given data and weights. 
cumprod (x[, axis, dtype, out, method]) 
Return the cumulative product of elements along a given axis. 
cumsum (x[, axis, dtype, out, method]) 
Return the cumulative sum of the elements along a given axis. 
deg2rad (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.deg2rad. 
degrees (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.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 nth discrete difference along the given axis. 
divmod (x1, x2[, out1, out2], / [[, out, …]) 
This docstring was copied from numpy.divmod. 
digitize (a, bins[, right]) 
Return the indices of the bins to which each value in input array belongs. 
dot (a, b[, out]) 
This docstring was copied from numpy.dot. 
dstack (tup[, allow_unknown_chunksizes]) 
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[, out, dtype, …]) 
This docstring was copied from numpy.einsum. 
empty (*args, **kwargs) 
Blocked variant of empty 
empty_like (a[, dtype, order, chunks, name, …]) 
Return a new array with the same shape and type as a given array. 
equal (x1, x2, /[, out, where, casting, …]) 
This docstring was copied from numpy.equal. 
exp (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.exp. 
exp2 (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.exp2. 
expm1 (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.expm1. 
eye (N[, chunks, M, k, dtype]) 
Return a 2D Array with ones on the diagonal and zeros elsewhere. 
fabs (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.fabs. 
fix (*args, **kwargs) 
Round to nearest integer towards zero. 
flatnonzero (a) 
Return indices that are nonzero in the flattened version of a. 
flip (m, axis) 
Reverse element order along axis. 
flipud (m) 
Flip array in the up/down direction. 
fliplr (m) 
Flip array in the left/right direction. 
float_power (x1, x2, /[, out, where, …]) 
This docstring was copied from numpy.float_power. 
floor (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.floor. 
floor_divide (x1, x2, /[, out, where, …]) 
This docstring was copied from numpy.floor_divide. 
fmax (x1, x2, /[, out, where, casting, …]) 
This docstring was copied from numpy.fmax. 
fmin (x1, x2, /[, out, where, casting, …]) 
This docstring was copied from numpy.fmin. 
fmod (x1, x2, /[, out, where, casting, …]) 
This docstring was copied from numpy.fmod. 
frexp (x[, out1, out2], / [[, out, where, …]) 
This docstring was copied from numpy.frexp. 
fromfunction (func[, chunks, shape, dtype]) 
Construct an array by executing a function over each coordinate. 
frompyfunc (func, nin, nout, *[, identity]) 
This docstring was copied from numpy.frompyfunc. 
full (shape, fill_value, *args, **kwargs) 
Blocked variant of full 
full_like (a, fill_value[, order, dtype, …]) 
Return a full array with the same shape and type as a given array. 
gradient (f, *varargs, **kwargs) 
Return the gradient of an Ndimensional array. 
greater (x1, x2, /[, out, where, casting, …]) 
This docstring was copied from numpy.greater. 
greater_equal (x1, x2, /[, out, where, …]) 
This docstring was copied from numpy.greater_equal. 
histogram (a[, bins, range, normed, weights, …]) 
Blocked variant of numpy.histogram() . 
histogramdd (sample, bins[, range, normed, …]) 
Blocked variant of numpy.histogramdd() . 
hstack (tup[, allow_unknown_chunksizes]) 
Stack arrays in sequence horizontally (column wise). 
hypot (x1, x2, /[, out, where, casting, …]) 
This docstring was copied from numpy.hypot. 
imag (*args, **kwargs) 
Return the imaginary part of the complex argument. 
indices (dimensions[, dtype, chunks]) 
Implements NumPy’s indices for Dask Arrays. 
insert (arr, obj, values, axis) 
Insert values along the given axis before the given indices. 
invert (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.invert. 
isclose (arr1, arr2[, rtol, atol, equal_nan]) 
Returns a boolean array where two arrays are elementwise equal within a tolerance. 
iscomplex (*args, **kwargs) 
Returns a bool array, where True if input element is complex. 
isfinite (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.isfinite. 
isin (element, test_elements[, …]) 
Calculates element in test_elements, broadcasting over element only. 
isinf (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.isinf. 
isneginf 
This docstring was copied from numpy.equal. 
isnan (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.isnan. 
isnull (values) 
pandas.isnull for dask arrays 
isposinf 
This docstring was copied from numpy.equal. 
isreal (*args, **kwargs) 
Returns a bool array, where True if input element is real. 
ldexp (x1, x2, /[, out, where, casting, …]) 
This docstring was copied from numpy.ldexp. 
less (x1, x2, /[, out, where, casting, …]) 
This docstring was copied from numpy.less. 
linspace (start, stop[, num, endpoint, …]) 
Return num evenly spaced values over the closed interval [start, stop]. 
log (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.log. 
log10 (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.log10. 
log1p (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.log1p. 
log2 (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.log2. 
logaddexp (x1, x2, /[, out, where, casting, …]) 
This docstring was copied from numpy.logaddexp. 
logaddexp2 (x1, x2, /[, out, where, casting, …]) 
This docstring was copied from numpy.logaddexp2. 
logical_and (x1, x2, /[, out, where, …]) 
This docstring was copied from numpy.logical_and. 
logical_not (x, /[, out, where, casting, …]) 
This docstring was copied from numpy.logical_not. 
logical_or (x1, x2, /[, out, where, casting, …]) 
This docstring was copied from numpy.logical_or. 
logical_xor (x1, x2, /[, out, where, …]) 
This docstring was copied from numpy.logical_xor. 
map_overlap (func, *args[, depth, boundary, …]) 
Map a function over blocks of arrays with some overlap 
map_blocks (func, *args[, name, token, …]) 
Map a function across all blocks of a dask array. 
matmul (x1, x2, /[, out, casting, order, …]) 
This docstring was copied from numpy.matmul. 
max (a[, axis, keepdims, split_every, out]) 
Return the maximum of an array or maximum along an axis. 
maximum (x1, x2, /[, out, where, casting, …]) 
This docstring was copied from numpy.maximum. 
mean (a[, axis, dtype, keepdims, …]) 
Compute the arithmetic mean along the specified axis. 
median (a[, axis, keepdims, out]) 
Compute the median along the specified axis. 
meshgrid (*xi, **kwargs) 
Return coordinate matrices from coordinate vectors. 
min (a[, axis, keepdims, split_every, out]) 
Return the minimum of an array or minimum along an axis. 
minimum (x1, x2, /[, out, where, casting, …]) 
This docstring was copied from numpy.minimum. 
mod (x1, x2, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.remainder. 
modf (x[, out1, out2], / [[, out, where, …]) 
This docstring was copied from numpy.modf. 
moment (a, order[, axis, dtype, keepdims, …]) 

moveaxis (a, source, destination) 
Move axes of an array to new positions. 
multiply (x1, x2, /[, out, where, casting, …]) 
This docstring was copied from numpy.multiply. 
nanargmax (x[, axis, split_every, out]) 
Return the maximum of an array or maximum along an axis, ignoring any NaNs. 
nanargmin (x[, axis, split_every, out]) 
Return minimum of an array or minimum along an axis, ignoring any NaNs. 
nancumprod (x, axis[, dtype, out, method]) 
Return the cumulative product of array elements over a given axis treating Not a Numbers (NaNs) as one. 
nancumsum (x, axis[, dtype, out, method]) 
Return the cumulative sum of array elements over a given axis treating Not a Numbers (NaNs) as zero. 
nanmax (a[, axis, keepdims, split_every, out]) 
Return the maximum of an array or maximum along an axis, ignoring any NaNs. 
nanmean (a[, axis, dtype, keepdims, …]) 
Compute the arithmetic mean along the specified axis, ignoring NaNs. 
nanmedian (a[, axis, keepdims, out]) 
Compute the median along the specified axis, while ignoring NaNs. 
nanmin (a[, axis, keepdims, split_every, out]) 
Return minimum of an array or minimum along an axis, ignoring any NaNs. 
nanprod (a[, axis, dtype, keepdims, …]) 
Return the product of array elements over a given axis treating Not a Numbers (NaNs) as ones. 
nanstd (a[, axis, dtype, keepdims, ddof, …]) 
Compute the standard deviation along the specified axis, while ignoring NaNs. 
nansum (a[, axis, dtype, keepdims, …]) 
Return the sum of array elements over a given axis treating Not a Numbers (NaNs) as zero. 
nanvar (a[, axis, dtype, keepdims, ddof, …]) 
Compute the variance along the specified axis, while ignoring NaNs. 
nan_to_num (*args, **kwargs) 
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. 
negative (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.negative. 
nextafter (x1, x2, /[, out, where, casting, …]) 
This docstring was copied from numpy.nextafter. 
nonzero (a) 
Return the indices of the elements that are nonzero. 
not_equal (x1, x2, /[, out, where, casting, …]) 
This docstring was copied from numpy.not_equal. 
notnull (values) 
pandas.notnull for dask arrays 
ones (*args, **kwargs) 
Blocked variant of ones 
ones_like (a[, dtype, order, chunks, name, shape]) 
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, method]) 
Approximate percentile of 1D array 
PerformanceWarning 
A warning given when bad chunking may cause poor performance 
piecewise (x, condlist, funclist, *args, **kw) 
Evaluate a piecewisedefined function. 
power (x1, x2, /[, out, where, casting, …]) 
This docstring was copied from numpy.power. 
prod (a[, axis, dtype, keepdims, …]) 
Return the product of array elements over a given axis. 
ptp (a[, axis]) 
Range of values (maximum  minimum) along an axis. 
rad2deg (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.rad2deg. 
radians (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.radians. 
ravel (array_like) 
Return a contiguous flattened array. 
real (*args, **kwargs) 
Return the real part of the complex argument. 
reciprocal (x, /[, out, where, casting, …]) 
This docstring was copied from numpy.reciprocal. 
rechunk (x[, chunks, threshold, …]) 
Convert blocks in dask array x for new chunks. 
reduction (x, chunk, aggregate[, axis, …]) 
General version of reductions 
register_chunk_type (type) 
Register the given type as a valid chunk and downcast array type 
remainder (x1, x2, /[, out, where, casting, …]) 
This docstring was copied from numpy.remainder. 
repeat (a, repeats[, axis]) 
Repeat elements of an array. 
reshape (x, shape[, merge_chunks]) 
Reshape array to new shape 
result_type (*arrays_and_dtypes) 
This docstring was copied from numpy.result_type. 
rint (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.rint. 
roll (array, shift[, axis]) 
Roll array elements along a given axis. 
rollaxis (a, axis[, start]) 

rot90 (m[, k, axes]) 
Rotate an array by 90 degrees in the plane specified by axes. 
round (a[, decimals]) 
Round an array to the given number of decimals. 
sign (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.sign. 
signbit (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.signbit. 
sin (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.sin. 
sinc (*args, **kwargs) 
Return the normalized sinc function. 
sinh (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.sinh. 
sqrt (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.sqrt. 
square (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.square. 
squeeze (a[, axis]) 
Remove axes of length one from a. 
stack (seq[, axis, allow_unknown_chunksizes]) 
Stack arrays along a new axis 
std (a[, axis, dtype, keepdims, ddof, …]) 
Compute the standard deviation along the specified axis. 
subtract (x1, x2, /[, out, where, casting, …]) 
This docstring was copied from numpy.subtract. 
sum (a[, axis, dtype, keepdims, split_every, out]) 
Sum of array elements over a given axis. 
take (a, indices[, axis]) 
Take elements from an array along an axis. 
tan (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.tan. 
tanh (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.tanh. 
tensordot (lhs, rhs[, axes]) 
Compute tensor dot product along specified axes. 
tile (A, reps) 
Construct an array by repeating A the number of times given by reps. 
topk (a, k[, axis, split_every]) 
Extract the k largest elements from a on the given axis, and return them sorted from largest to smallest. 
trace (a[, offset, axis1, axis2, dtype]) 
Return the sum along diagonals of the array. 
transpose (a[, axes]) 
Reverse or permute the axes of an array; returns the modified array. 
true_divide (x1, x2, /[, out, where, …]) 
This docstring was copied from numpy.true_divide. 
tril (m[, k]) 
Lower triangle of an array. 
triu (m[, k]) 
Upper triangle of an array. 
trunc (x, /[, out, where, casting, order, …]) 
This docstring was copied from numpy.trunc. 
unify_chunks (*args, **kwargs) 
Unify chunks across a sequence of arrays 
unique (ar[, return_index, return_inverse, …]) 
Find the unique elements of an array. 
unravel_index (indices, shape[, order]) 
This docstring was copied from numpy.unravel_index. 
var (a[, axis, dtype, keepdims, ddof, …]) 
Compute the variance along the specified axis. 
vdot (a, b) 
This docstring was copied from numpy.vdot. 
vstack (tup[, allow_unknown_chunksizes]) 
Stack arrays in sequence vertically (row wise). 
where (condition, [x, y]) 
This docstring was copied from numpy.where. 
zeros (*args, **kwargs) 
Blocked variant of zeros 
zeros_like (a[, dtype, order, chunks, name, …]) 
Return an array of zeros with the same shape and type as a given array. 
Fast Fourier Transforms¶
fft.fft_wrap (fft_func[, kind, dtype]) 
Wrap 1D, 2D, and ND real and complex FFT functions 
fft.fft (a[, n, axis]) 
Wrapping of numpy.fft.fft 
fft.fft2 (a[, s, axes]) 
Wrapping of numpy.fft.fft2 
fft.fftn (a[, s, axes]) 
Wrapping of numpy.fft.fftn 
fft.ifft (a[, n, axis]) 
Wrapping of numpy.fft.ifft 
fft.ifft2 (a[, s, axes]) 
Wrapping of numpy.fft.ifft2 
fft.ifftn (a[, s, axes]) 
Wrapping of numpy.fft.ifftn 
fft.rfft (a[, n, axis]) 
Wrapping of numpy.fft.rfft 
fft.rfft2 (a[, s, axes]) 
Wrapping of numpy.fft.rfft2 
fft.rfftn (a[, s, axes]) 
Wrapping of numpy.fft.rfftn 
fft.irfft (a[, n, axis]) 
Wrapping of numpy.fft.irfft 
fft.irfft2 (a[, s, axes]) 
Wrapping of numpy.fft.irfft2 
fft.irfftn (a[, s, axes]) 
Wrapping of numpy.fft.irfftn 
fft.hfft (a[, n, axis]) 
Wrapping of numpy.fft.hfft 
fft.ihfft (a[, n, axis]) 
Wrapping of numpy.fft.ihfft 
fft.fftfreq (n[, d, chunks]) 
Return the Discrete Fourier Transform sample frequencies. 
fft.rfftfreq (n[, d, chunks]) 
Return the Discrete Fourier Transform sample frequencies (for usage with rfft, irfft). 
fft.fftshift (x[, axes]) 
Shift the zerofrequency component to the center of the spectrum. 
fft.ifftshift (x[, axes]) 
The inverse of fftshift. 
Linear Algebra¶
linalg.cholesky (a[, lower]) 
Returns the Cholesky decomposition, \(A = L L^*\) or \(A = U^* U\) of a Hermitian positivedefinite matrix A. 
linalg.inv (a) 
Compute the inverse of a matrix with LU decomposition and forward / backward substitutions. 
linalg.lstsq (a, b) 
Return the leastsquares solution to a linear matrix equation using QR decomposition. 
linalg.lu (a) 
Compute the lu decomposition of a matrix. 
linalg.norm (x[, ord, axis, keepdims]) 
Matrix or vector norm. 
linalg.qr (a) 
Compute the qr factorization of a matrix. 
linalg.solve (a, b[, sym_pos]) 
Solve the equation a x = b for x . 
linalg.solve_triangular (a, b[, lower]) 
Solve the equation a x = b for x, assuming a is a triangular matrix. 
linalg.svd (a[, coerce_signs]) 
Compute the singular value decomposition of a matrix. 
linalg.svd_compressed (a, k[, iterator, …]) 
Randomly compressed rankk thin Singular Value Decomposition. 
linalg.sfqr (data[, name]) 
Direct ShortandFat QR 
linalg.tsqr (data[, compute_svd, …]) 
Direct TallandSkinny QR algorithm 
Masked Arrays¶
ma.average (a[, axis, weights, returned]) 
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.getdata (a) 
Return the data of a masked array as an ndarray. 
ma.getmaskarray (a) 
Return the mask of a masked array, or full boolean array of False. 
ma.masked_array (data[, mask, fill_value]) 
An array class with possibly masked values. 
ma.masked_equal (a, value) 
Mask an array where equal to a given value. 
ma.masked_greater (x, value[, copy]) 
Mask an array where greater than a given value. 
ma.masked_greater_equal (x, value[, copy]) 
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[, copy]) 
Mask an array where less than a given value. 
ma.masked_less_equal (x, value[, copy]) 
Mask an array where less than or equal to a given value. 
ma.masked_not_equal (x, value[, copy]) 
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. 
ma.set_fill_value (a, fill_value) 
Set the filling value of a, if a is a masked array. 
Random¶
random.beta 
Draw samples from a Beta distribution. 
random.binomial 
Draw samples from a binomial distribution. 
random.chisquare 
Draw samples from a chisquare distribution. 
random.choice 
Generates a random sample from a given 1D array 
random.exponential 
Draw samples from an exponential distribution. 
random.f 
Draw samples from an F distribution. 
random.gamma 
Draw samples from a Gamma distribution. 
random.geometric 
Draw samples from the geometric distribution. 
random.gumbel 
Draw samples from a Gumbel distribution. 
random.hypergeometric 
Draw samples from a Hypergeometric distribution. 
random.laplace 
Draw samples from the Laplace or double exponential distribution with specified location (or mean) and scale (decay). 
random.logistic 
Draw samples from a logistic distribution. 
random.lognormal 
Draw samples from a lognormal distribution. 
random.logseries 
Draw samples from a logarithmic series distribution. 
random.negative_binomial 
Draw samples from a negative binomial distribution. 
random.noncentral_chisquare 
Draw samples from a noncentral chisquare distribution. 
random.noncentral_f 
Draw samples from the noncentral F distribution. 
random.normal 
Draw random samples from a normal (Gaussian) distribution. 
random.pareto 
Draw samples from a Pareto II or Lomax distribution with specified shape. 
random.permutation 
Randomly permute a sequence, or return a permuted range. 
random.poisson 
Draw samples from a Poisson distribution. 
random.power 
Draws samples in [0, 1] from a power distribution with positive exponent a  1. 
random.randint 
Return random integers from low (inclusive) to high (exclusive). 
random.random 
Return random floats in the halfopen interval [0.0, 1.0). 
random.random_sample 
Return random floats in the halfopen interval [0.0, 1.0). 
random.rayleigh 
Draw samples from a Rayleigh distribution. 
random.standard_cauchy 
Draw samples from a standard Cauchy distribution with mode = 0. 
random.standard_exponential 
Draw samples from the standard exponential distribution. 
random.standard_gamma 
Draw samples from a standard Gamma distribution. 
random.standard_normal 
Draw samples from a standard Normal distribution (mean=0, stdev=1). 
random.standard_t 
Draw samples from a standard Student’s t distribution with df degrees of freedom. 
random.triangular 
Draw samples from the triangular distribution over the interval [left, right] . 
random.uniform 
Draw samples from a uniform distribution. 
random.vonmises 
Draw samples from a von Mises distribution. 
random.wald 
Draw samples from a Wald, or inverse Gaussian, distribution. 
random.weibull 
Draw samples from a Weibull distribution. 
random.zipf 
Standard distributions 
Stats¶
stats.ttest_ind (a, b[, axis, equal_var]) 
Calculate the Ttest for the means of two independent samples of scores. 
stats.ttest_1samp (a, popmean[, axis, nan_policy]) 
Calculate the Ttest for the mean of ONE group of scores. 
stats.ttest_rel (a, b[, axis, nan_policy]) 
Calculate the ttest on TWO RELATED samples of scores, a and b. 
stats.chisquare (f_obs[, f_exp, ddof, axis]) 
Calculate a oneway chisquare test. 
stats.power_divergence (f_obs[, f_exp, ddof, …]) 
CressieRead power divergence statistic and goodness of fit test. 
stats.skew (a[, axis, bias, nan_policy]) 
Compute the sample skewness of a data set. 
stats.skewtest (a[, axis, nan_policy]) 
Test whether the skew is different from the normal distribution. 
stats.kurtosis (a[, axis, fisher, bias, …]) 
Compute the kurtosis (Fisher or Pearson) of a dataset. 
stats.kurtosistest (a[, axis, nan_policy]) 
Test whether a dataset has normal kurtosis. 
stats.normaltest (a[, axis, nan_policy]) 
Test whether a sample differs from a normal distribution. 
stats.f_oneway (*args) 
Perform oneway ANOVA. 
stats.moment (a[, moment, axis, nan_policy]) 
Calculate the nth moment about the mean for a sample. 
Image Support¶
image.imread (filename[, imread, preprocess]) 
Read a stack of images into a dask array 
Slightly Overlapping Computations¶
overlap.overlap (x, depth, boundary) 
Share boundaries between neighboring blocks 
overlap.map_overlap (func, *args[, depth, …]) 
Map a function over blocks of arrays with some overlap 
lib.stride_tricks.sliding_window_view (x, …) 
Create a sliding window view into the array with the given window shape. 
overlap.trim_internal (x, axes[, boundary]) 
Trim sides from each block 
overlap.trim_overlap (x, depth[, boundary]) 
Trim sides from each block. 
Create and Store Arrays¶
from_array (x[, chunks, name, lock, asarray, …]) 
Create dask array from something that looks like an array. 
from_delayed (value, shape[, dtype, meta, name]) 
Create a dask array from a dask delayed value 
from_npy_stack (dirname[, mmap_mode]) 
Load dask array from stack of npy files 
from_zarr (url[, component, storage_options, …]) 
Load array from the zarr storage format 
from_tiledb (uri[, attribute, chunks, …]) 
Load array from the TileDB storage format 
store (sources, targets[, lock, regions, …]) 
Store dask arrays in arraylike objects, overwrite data in target 
to_hdf5 (filename, *args, **kwargs) 
Store arrays in HDF5 file 
to_zarr (arr, url[, component, …]) 
Save array to the zarr storage format 
to_npy_stack (dirname, x[, axis]) 
Write dask array to a stack of .npy files 
to_tiledb (darray, uri[, compute, …]) 
Save array to the TileDB storage format 
Generalized Ufuncs¶
apply_gufunc (func, signature, *args, **kwargs) 
Apply a generalized ufunc or similar python function to arrays. 
as_gufunc ([signature]) 
Decorator for dask.array.gufunc . 
gufunc (pyfunc, **kwargs) 
Binds pyfunc into dask.array.apply_gufunc when called. 
Internal functions¶
blockwise (func, out_ind, *args[, name, …]) 
Tensor operation: Generalized inner and outer products 
normalize_chunks (chunks[, shape, limit, …]) 
Normalize chunks to tuple of tuples 
Other functions¶

dask.array.
add
(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.add.
Some inconsistencies with the Dask version may exist.
Add arguments elementwise.
Parameters:  x1, x2 : array_like
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). out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  add : ndarray or scalar
The sum of x1 and x2, elementwise. This is a scalar if both x1 and x2 are scalars.
Notes
Equivalent to x1 + x2 in terms of array broadcasting.
Examples
>>> np.add(1.0, 4.0) # doctest: +SKIP 5.0 >>> x1 = np.arange(9.0).reshape((3, 3)) # doctest: +SKIP >>> x2 = np.arange(3.0) # doctest: +SKIP >>> np.add(x1, x2) # doctest: +SKIP array([[ 0., 2., 4.], [ 3., 5., 7.], [ 6., 8., 10.]])
The
+
operator can be used as a shorthand fornp.add
on ndarrays.>>> x1 = np.arange(9.0).reshape((3, 3)) # doctest: +SKIP >>> x2 = np.arange(3.0) # doctest: +SKIP >>> x1 + x2 # doctest: +SKIP array([[ 0., 2., 4.], [ 3., 5., 7.], [ 6., 8., 10.]])

dask.array.
all
(a, axis=None, keepdims=False, split_every=None, out=None)[source]¶ Test whether all array elements along a given axis evaluate to True.
This docstring was copied from numpy.all.
Some inconsistencies with the Dask 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 Output type determination 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 subclasses of ndarray, however any nondefault value will be. If the subclass’ method does not implement keepdims any exceptions will be raised.
 where : array_like of bool, optional (Not supported in Dask)
Elements to include in checking for all True values. See ~numpy.ufunc.reduce for details.
New in version 1.20.0.
Returns:  all : ndarray, bool
A new boolean or array is returned unless out is specified, in which case a reference to out is returned.
See also
ndarray.all
 equivalent method
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.
Examples
>>> np.all([[True,False],[True,True]]) # doctest: +SKIP False
>>> np.all([[True,False],[True,True]], axis=0) # doctest: +SKIP array([ True, False])
>>> np.all([1, 4, 5]) # doctest: +SKIP True
>>> np.all([1.0, np.nan]) # doctest: +SKIP True
>>> np.all([[True, True], [False, True]], where=[[True], [False]]) # doctest: +SKIP True
>>> o=np.array(False) # doctest: +SKIP >>> z=np.all([1, 4, 5], out=o) # doctest: +SKIP >>> id(z), id(o), z # doctest: +SKIP (28293632, 28293632, array(True)) # may vary

dask.array.
allclose
(arr1, arr2, rtol=1e05, atol=1e08, equal_nan=False)[source]¶ Returns True if two arrays are elementwise equal within a tolerance.
This docstring was copied from numpy.allclose.
Some inconsistencies with the Dask 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:  a, b : array_like
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 : bool
Returns True if the two arrays are equal within the given tolerance; False otherwise.
Notes
If the following equation is elementwise 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 fromallclose(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.allclose is not defined for nonnumeric data types.
Examples
>>> np.allclose([1e10,1e7], [1.00001e10,1e8]) # doctest: +SKIP False >>> np.allclose([1e10,1e8], [1.00001e10,1e9]) # doctest: +SKIP True >>> np.allclose([1e10,1e8], [1.0001e10,1e9]) # doctest: +SKIP False >>> np.allclose([1.0, np.nan], [1.0, np.nan]) # doctest: +SKIP False >>> np.allclose([1.0, np.nan], [1.0, np.nan], equal_nan=True) # doctest: +SKIP True

dask.array.
angle
(x, deg=0)[source]¶ Return the angle of the complex argument.
This docstring was copied from numpy.angle.
Some inconsistencies with the Dask version may exist.
Parameters:  z : array_like (Not supported in Dask)
A complex number or sequence of complex numbers.
 deg : bool, optional
Return angle in degrees if True, radians if False (default).
Returns:  angle : ndarray or scalar
The counterclockwise angle from the positive real axis on the complex plane in the range
(pi, pi]
, with dtype as numpy.float64.Changed in version 1.16.0: This function works on subclasses of ndarray like ma.array.
See also
arctan2
absolute
Notes
Although the angle of the complex number 0 is undefined,
numpy.angle(0)
returns the value 0.Examples
>>> np.angle([1.0, 1.0j, 1+1j]) # in radians # doctest: +SKIP array([ 0. , 1.57079633, 0.78539816]) # may vary >>> np.angle(1+1j, deg=True) # in degrees # doctest: +SKIP 45.0

dask.array.
any
(a, axis=None, keepdims=False, split_every=None, out=None)[source]¶ Test whether any array element along a given axis evaluates to True.
This docstring was copied from numpy.any.
Some inconsistencies with the Dask 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 Output type determination 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 subclasses of ndarray, however any nondefault value will be. If the subclass’ method does not implement keepdims any exceptions will be raised.
 where : array_like of bool, optional (Not supported in Dask)
Elements to include in checking for any True values. See ~numpy.ufunc.reduce for details.
New in version 1.20.0.
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.
See also
ndarray.any
 equivalent method
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.
Examples
>>> np.any([[True, False], [True, True]]) # doctest: +SKIP True
>>> np.any([[True, False], [False, False]], axis=0) # doctest: +SKIP array([ True, False])
>>> np.any([1, 0, 5]) # doctest: +SKIP True
>>> np.any(np.nan) # doctest: +SKIP True
>>> np.any([[True, False], [False, False]], where=[[False], [True]]) # doctest: +SKIP False
>>> o=np.array(False) # doctest: +SKIP >>> z=np.any([1, 4, 5], out=o) # doctest: +SKIP >>> z, o # doctest: +SKIP (array(True), array(True)) >>> # Check now that z is a reference to o >>> z is o # doctest: +SKIP True >>> id(z), id(o) # identity of z and o # doctest: +SKIP (191614240, 191614240)

dask.array.
append
(arr, values, axis=None)[source]¶ Append values to the end of an array.
This docstring was copied from numpy.append.
Some inconsistencies with the Dask version may exist.
Parameters:  arr : array_like
Values are appended to a copy of this array.
 values : array_like
These values are appended to a copy of arr. It must be of the correct shape (the same shape as arr, excluding axis). If axis is not specified, values can be any shape and will be flattened before use.
 axis : int, optional
The axis along which values are appended. If axis is not given, both arr and values are flattened before use.
Returns:  append : ndarray
A copy of arr with values appended to axis. Note that append does not occur inplace: a new array is allocated and filled. If axis is None, out is a flattened array.
See also
insert
 Insert elements into an array.
delete
 Delete elements from an array.
Examples
>>> np.append([1, 2, 3], [[4, 5, 6], [7, 8, 9]]) # doctest: +SKIP array([1, 2, 3, ..., 7, 8, 9])
When axis is specified, values must have the correct shape.
>>> np.append([[1, 2, 3], [4, 5, 6]], [[7, 8, 9]], axis=0) # doctest: +SKIP array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) >>> np.append([[1, 2, 3], [4, 5, 6]], [7, 8, 9], axis=0) # doctest: +SKIP Traceback (most recent call last): ... ValueError: all the input arrays must have same number of dimensions, but the array at index 0 has 2 dimension(s) and the array at index 1 has 1 dimension(s)

dask.array.
apply_along_axis
(func1d, axis, arr, *args, dtype=None, shape=None, **kwargs)[source]¶ Apply a function to 1D slices along the given axis.
This docstring was copied from numpy.apply_along_axis.
Some inconsistencies with the Dask version may exist.
This is a blocked variant of
numpy.apply_along_axis()
implemented viadask.array.map_blocks()
Parameters:  func1d : function (M,) > (Nj…)
This function should accept 1D arrays. It is applied to 1D slices of arr along the specified axis.
 axis : integer
Axis along which arr is sliced.
 arr : ndarray (Ni…, M, Nk…)
Input array.
 args : any
Additional arguments to func1d.
 kwargs : any
Additional named arguments to func1d.
New in version 1.9.0.
Returns:  out : ndarray (Ni…, Nj…, Nk…)
The output array. The shape of out is identical to the shape of arr, except along the axis dimension. This axis is removed, and replaced with new dimensions equal to the shape of the return value of func1d. So if func1d returns a scalar out will have one fewer dimensions than arr.
See also
apply_over_axes
 Apply a function repeatedly over multiple axes.
Notes
If either of dtype or shape are not provided, Dask attempts to determine them by calling func1d on a dummy array. This may produce incorrect values for dtype or shape, so we recommend providing them.
Execute func1d(a, *args, **kwargs) where func1d operates on 1D arrays and a is a 1D slice of arr along axis.
This is equivalent to (but faster than) the following use of ndindex and s_, which sets each of
ii
,jj
, andkk
to a tuple of indices:Ni, Nk = a.shape[:axis], a.shape[axis+1:] for ii in ndindex(Ni): for kk in ndindex(Nk): f = func1d(arr[ii + s_[:,] + kk]) Nj = f.shape for jj in ndindex(Nj): out[ii + jj + kk] = f[jj]
Equivalently, eliminating the inner loop, this can be expressed as:
Ni, Nk = a.shape[:axis], a.shape[axis+1:] for ii in ndindex(Ni): for kk in ndindex(Nk): out[ii + s_[...,] + kk] = func1d(arr[ii + s_[:,] + kk])
Examples
>>> def my_func(a): # doctest: +SKIP ... """Average first and last element of a 1D array""" ... return (a[0] + a[1]) * 0.5 >>> b = np.array([[1,2,3], [4,5,6], [7,8,9]]) # doctest: +SKIP >>> np.apply_along_axis(my_func, 0, b) # doctest: +SKIP array([4., 5., 6.]) >>> np.apply_along_axis(my_func, 1, b) # doctest: +SKIP array([2., 5., 8.])
For a function that returns a 1D array, the number of dimensions in outarr is the same as arr.
>>> b = np.array([[8,1,7], [4,3,9], [5,2,6]]) # doctest: +SKIP >>> np.apply_along_axis(sorted, 1, b) # doctest: +SKIP array([[1, 7, 8], [3, 4, 9], [2, 5, 6]])
For a function that returns a higher dimensional array, those dimensions are inserted in place of the axis dimension.
>>> b = np.array([[1,2,3], [4,5,6], [7,8,9]]) # doctest: +SKIP >>> np.apply_along_axis(np.diag, 1, b) # doctest: +SKIP array([[[1, 0, 0], [0, 2, 0], [0, 0, 3]], [[4, 0, 0], [0, 5, 0], [0, 0, 6]], [[7, 0, 0], [0, 8, 0], [0, 0, 9]]])

dask.array.
apply_over_axes
(func, a, axes)[source]¶ Apply a function repeatedly over multiple axes.
This docstring was copied from numpy.apply_over_axes.
Some inconsistencies with the Dask version may exist.
func is called as res = func(a, axis), where axis is the first element of axes. The result res of the function call must have either the same dimensions as a or one less dimension. If res has one less dimension than a, a dimension is inserted before axis. The call to func is then repeated for each axis in axes, with res as the first argument.
Parameters:  func : function
This function must take two arguments, func(a, axis).
 a : array_like
Input array.
 axes : array_like
Axes over which func is applied; the elements must be integers.
Returns:  apply_over_axis : ndarray
The output array. The number of dimensions is the same as a, but the shape can be different. This depends on whether func changes the shape of its output with respect to its input.
See also
apply_along_axis
 Apply a function to 1D slices of an array along the given axis.
Notes
This function is equivalent to tuple axis arguments to reorderable ufuncs with keepdims=True. Tuple axis arguments to ufuncs have been available since version 1.7.0.
Examples
>>> a = np.arange(24).reshape(2,3,4) # doctest: +SKIP >>> a # doctest: +SKIP array([[[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11]], [[12, 13, 14, 15], [16, 17, 18, 19], [20, 21, 22, 23]]])
Sum over axes 0 and 2. The result has same number of dimensions as the original array:
>>> np.apply_over_axes(np.sum, a, [0,2]) # doctest: +SKIP array([[[ 60], [ 92], [124]]])
Tuple axis arguments to ufuncs are equivalent:
>>> np.sum(a, axis=(0,2), keepdims=True) # doctest: +SKIP array([[[ 60], [ 92], [124]]])

dask.array.
arange
(*args, **kwargs)[source]¶ Return evenly spaced values from start to stop with step size step.
The values are halfopen [start, stop), so including start and excluding stop. This is basically the same as python’s range function but for dask arrays.
When using a noninteger step, such as 0.1, the results will often not be consistent. It is better to use linspace for these cases.
Parameters:  start : int, optional
The starting value of the sequence. The default is 0.
 stop : int
The end of the interval, this value is excluded from the interval.
 step : int, optional
The spacing between the values. The default is 1 when not specified. The last value of the sequence.
 chunks : int
The number of samples on each block. Note that the last block will have fewer samples if
len(array) % chunks != 0
. dtype : numpy.dtype
Output dtype. Omit to infer it from start, stop, step
Returns:  samples : dask array
See also

dask.array.
arccos
(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.arccos.
Some inconsistencies with the Dask version may exist.
Trigonometric inverse cosine, elementwise.
The inverse of cos so that, if
y = cos(x)
, thenx = arccos(y)
.Parameters:  x : array_like
xcoordinate on the unit circle. For real arguments, the domain is [1, 1].
 out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  angle : ndarray
The angle of the ray intersecting the unit circle at the given xcoordinate in radians [0, pi]. This is a scalar if x is a scalar.
Notes
arccos is a multivalued function: for each x there are infinitely many numbers z such that cos(z) = x. The convention is to return the angle z whose real part lies in [0, pi].
For realvalued input data types, arccos always returns real output. For each value that cannot be expressed as a real number or infinity, it yields
nan
and sets the invalid floating point error flag.For complexvalued input, arccos is a complex analytic function that has branch cuts [inf, 1] and [1, inf] and is continuous from above on the former and from below on the latter.
The inverse cos is also known as acos or cos^1.
References
M. Abramowitz and I.A. Stegun, “Handbook of Mathematical Functions”, 10th printing, 1964, pp. 79. http://www.math.sfu.ca/~cbm/aands/
Examples
We expect the arccos of 1 to be 0, and of 1 to be pi:
>>> np.arccos([1, 1]) # doctest: +SKIP array([ 0. , 3.14159265])
Plot arccos:
>>> import matplotlib.pyplot as plt # doctest: +SKIP >>> x = np.linspace(1, 1, num=100) # doctest: +SKIP >>> plt.plot(x, np.arccos(x)) # doctest: +SKIP >>> plt.axis('tight') # doctest: +SKIP >>> plt.show() # doctest: +SKIP

dask.array.
arccosh
(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.arccosh.
Some inconsistencies with the Dask version may exist.
Inverse hyperbolic cosine, elementwise.
Parameters:  x : array_like
Input array.
 out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  arccosh : ndarray
Array of the same shape as x. This is a scalar if x is a scalar.
Notes
arccosh is a multivalued function: for each x there are infinitely many numbers z such that cosh(z) = x. The convention is to return the z whose imaginary part lies in [pi, pi] and the real part in
[0, inf]
.For realvalued input data types, arccosh always returns real output. For each value that cannot be expressed as a real number or infinity, it yields
nan
and sets the invalid floating point error flag.For complexvalued input, arccosh is a complex analytical function that has a branch cut [inf, 1] and is continuous from above on it.
References
[1] M. Abramowitz and I.A. Stegun, “Handbook of Mathematical Functions”, 10th printing, 1964, pp. 86. http://www.math.sfu.ca/~cbm/aands/ [2] Wikipedia, “Inverse hyperbolic function”, https://en.wikipedia.org/wiki/Arccosh Examples
>>> np.arccosh([np.e, 10.0]) # doctest: +SKIP array([ 1.65745445, 2.99322285]) >>> np.arccosh(1) # doctest: +SKIP 0.0

dask.array.
arcsin
(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.arcsin.
Some inconsistencies with the Dask version may exist.
Inverse sine, elementwise.
Parameters:  x : array_like
ycoordinate on the unit circle.
 out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  angle : ndarray
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.
Notes
arcsin is a multivalued function: for each x there are infinitely many numbers z such that \(sin(z) = x\). The convention is to return the angle z whose real part lies in [pi/2, pi/2].
For realvalued input data types, arcsin always returns real output. For each value that cannot be expressed as a real number or infinity, it yields
nan
and sets the invalid floating point error flag.For complexvalued input, arcsin is a complex analytic function that has, by convention, the branch cuts [inf, 1] and [1, inf] and is continuous from above on the former and from below on the latter.
The inverse sine is also known as asin or sin^{1}.
References
Abramowitz, M. and Stegun, I. A., Handbook of Mathematical Functions, 10th printing, New York: Dover, 1964, pp. 79ff. http://www.math.sfu.ca/~cbm/aands/
Examples
>>> np.arcsin(1) # pi/2 # doctest: +SKIP 1.5707963267948966 >>> np.arcsin(1) # pi/2 # doctest: +SKIP 1.5707963267948966 >>> np.arcsin(0) # doctest: +SKIP 0.0

dask.array.
arcsinh
(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.arcsinh.
Some inconsistencies with the Dask version may exist.
Inverse hyperbolic sine elementwise.
Parameters:  x : array_like
Input array.
 out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  out : ndarray or scalar
Array of the same shape as x. This is a scalar if x is a scalar.
Notes
arcsinh is a multivalued function: for each x there are infinitely many numbers z such that sinh(z) = x. The convention is to return the z whose imaginary part lies in [pi/2, pi/2].
For realvalued input data types, arcsinh always returns real output. For each value that cannot be expressed as a real number or infinity, it returns
nan
and sets the invalid floating point error flag.For complexvalued input, arccos is a complex analytical function that has branch cuts [1j, infj] and [1j, infj] and is continuous from the right on the former and from the left on the latter.
The inverse hyperbolic sine is also known as asinh or
sinh^1
.References
[1] M. Abramowitz and I.A. Stegun, “Handbook of Mathematical Functions”, 10th printing, 1964, pp. 86. http://www.math.sfu.ca/~cbm/aands/ [2] Wikipedia, “Inverse hyperbolic function”, https://en.wikipedia.org/wiki/Arcsinh Examples
>>> np.arcsinh(np.array([np.e, 10.0])) # doctest: +SKIP array([ 1.72538256, 2.99822295])

dask.array.
arctan
(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.arctan.
Some inconsistencies with the Dask version may exist.
Trigonometric inverse tangent, elementwise.
The inverse of tan, so that if
y = tan(x)
thenx = arctan(y)
.Parameters:  x : array_like
 out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  out : ndarray or scalar
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.
See also
Notes
arctan is a multivalued function: for each x there are infinitely many numbers z such that tan(z) = x. The convention is to return the angle z whose real part lies in [pi/2, pi/2].
For realvalued input data types, arctan always returns real output. For each value that cannot be expressed as a real number or infinity, it yields
nan
and sets the invalid floating point error flag.For complexvalued input, arctan is a complex analytic function that has [1j, infj] and [1j, infj] as branch cuts, and is continuous from the left on the former and from the right on the latter.
The inverse tangent is also known as atan or tan^{1}.
References
Abramowitz, M. and Stegun, I. A., Handbook of Mathematical Functions, 10th printing, New York: Dover, 1964, pp. 79. http://www.math.sfu.ca/~cbm/aands/
Examples
We expect the arctan of 0 to be 0, and of 1 to be pi/4:
>>> np.arctan([0, 1]) # doctest: +SKIP array([ 0. , 0.78539816])
>>> np.pi/4 # doctest: +SKIP 0.78539816339744828
Plot arctan:
>>> import matplotlib.pyplot as plt # doctest: +SKIP >>> x = np.linspace(10, 10) # doctest: +SKIP >>> plt.plot(x, np.arctan(x)) # doctest: +SKIP >>> plt.axis('tight') # doctest: +SKIP >>> plt.show() # doctest: +SKIP

dask.array.
arctan2
(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.arctan2.
Some inconsistencies with the Dask version may exist.
Elementwise arc tangent of
x1/x2
choosing the quadrant correctly.The quadrant (i.e., branch) is chosen so that
arctan2(x1, x2)
is the signed angle in radians between the ray ending at the origin and passing through the point (1,0), and the ray ending at the origin and passing through the point (x2, x1). (Note the role reversal: the “ycoordinate” is the first function parameter, the “xcoordinate” is the second.) By IEEE convention, this function is defined for x2 = +/0 and for either or both of x1 and x2 = +/inf (see Notes for specific values).This function is not defined for complexvalued arguments; for the socalled argument of complex values, use angle.
Parameters:  x1 : array_like, realvalued
ycoordinates.
 x2 : array_like, realvalued
xcoordinates. If
x1.shape != x2.shape
, they must be broadcastable to a common shape (which becomes the shape of the output). out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  angle : ndarray
Array of angles in radians, in the range
[pi, pi]
. This is a scalar if both x1 and x2 are scalars.
Notes
arctan2 is identical to the atan2 function of the underlying C library. The following special values are defined in the C standard: [1]
x1 x2 arctan2(x1,x2) +/ 0 +0 +/ 0 +/ 0 0 +/ pi > 0 +/inf +0 / +pi < 0 +/inf 0 / pi +/inf +inf +/ (pi/4) +/inf inf +/ (3*pi/4) Note that +0 and 0 are distinct floating point numbers, as are +inf and inf.
References
[1] ISO/IEC standard 9899:1999, “Programming language C.” Examples
Consider four points in different quadrants:
>>> x = np.array([1, +1, +1, 1]) # doctest: +SKIP >>> y = np.array([1, 1, +1, +1]) # doctest: +SKIP >>> np.arctan2(y, x) * 180 / np.pi # doctest: +SKIP array([135., 45., 45., 135.])
Note the order of the parameters. arctan2 is defined also when x2 = 0 and at several other special points, obtaining values in the range
[pi, pi]
:>>> np.arctan2([1., 1.], [0., 0.]) # doctest: +SKIP array([ 1.57079633, 1.57079633]) >>> np.arctan2([0., 0., np.inf], [+0., 0., np.inf]) # doctest: +SKIP array([ 0. , 3.14159265, 0.78539816])

dask.array.
arctanh
(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.arctanh.
Some inconsistencies with the Dask version may exist.
Inverse hyperbolic tangent elementwise.
Parameters:  x : array_like
Input array.
 out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  out : ndarray or scalar
Array of the same shape as x. This is a scalar if x is a scalar.
See also
emath.arctanh
Notes
arctanh is a multivalued function: for each x there are infinitely many numbers z such that tanh(z) = x. The convention is to return the z whose imaginary part lies in [pi/2, pi/2].
For realvalued input data types, arctanh always returns real output. For each value that cannot be expressed as a real number or infinity, it yields
nan
and sets the invalid floating point error flag.For complexvalued input, arctanh is a complex analytical function that has branch cuts [1, inf] and [1, inf] and is continuous from above on the former and from below on the latter.
The inverse hyperbolic tangent is also known as atanh or
tanh^1
.References
[1] M. Abramowitz and I.A. Stegun, “Handbook of Mathematical Functions”, 10th printing, 1964, pp. 86. http://www.math.sfu.ca/~cbm/aands/ [2] Wikipedia, “Inverse hyperbolic function”, https://en.wikipedia.org/wiki/Arctanh Examples
>>> np.arctanh([0, 0.5]) # doctest: +SKIP array([ 0. , 0.54930614])

dask.array.
argmax
(x, axis=None, split_every=None, out=None)¶ Return the maximum of an array or maximum along an axis.
This docstring was copied from numpy.amax.
Some inconsistencies with the Dask version may exist.
Parameters:  a : array_like (Not supported in Dask)
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 Output type determination for more details.
 keepdims : bool, optional (Not supported in Dask)
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 subclasses of ndarray, however any nondefault value will be. If the subclass’ method does not implement keepdims any exceptions will be raised.
 initial : scalar, optional (Not supported in Dask)
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 (Not supported in Dask)
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
.
See also
amin
 The minimum value of an array along a given axis, propagating any NaNs.
nanmax
 The maximum value of an array along a given axis, ignoring any NaNs.
maximum
 Elementwise maximum of two arrays, propagating any NaNs.
fmax
 Elementwise maximum of two arrays, ignoring any NaNs.
argmax
 Return the indices of the maximum values.
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 elementwise comparison of 2 arrays; when
a.shape[0]
is 2,maximum(a[0], a[1])
is faster thanamax(a, axis=0)
.Examples
>>> a = np.arange(4).reshape((2,2)) # doctest: +SKIP >>> a # doctest: +SKIP array([[0, 1], [2, 3]]) >>> np.amax(a) # Maximum of the flattened array # doctest: +SKIP 3 >>> np.amax(a, axis=0) # Maxima along the first axis # doctest: +SKIP array([2, 3]) >>> np.amax(a, axis=1) # Maxima along the second axis # doctest: +SKIP array([1, 3]) >>> np.amax(a, where=[False, True], initial=1, axis=0) # doctest: +SKIP array([1, 3]) >>> b = np.arange(5, dtype=float) # doctest: +SKIP >>> b[2] = np.NaN # doctest: +SKIP >>> np.amax(b) # doctest: +SKIP nan >>> np.amax(b, where=~np.isnan(b), initial=1) # doctest: +SKIP 4.0 >>> np.nanmax(b) # doctest: +SKIP 4.0
You can use an initial value to compute the maximum of an empty slice, or to initialize it to a different value:
>>> np.max([[50], [10]], axis=1, initial=0) # doctest: +SKIP array([ 0, 10])
Notice that the initial value is used as one of the elements for which the maximum is determined, unlike for the default argument Python’s max function, which is only used for empty iterables.
>>> np.max([5], initial=6) # doctest: +SKIP 6 >>> max([5], default=6) # doctest: +SKIP 5

dask.array.
argmin
(x, axis=None, split_every=None, out=None)¶ Return the minimum of an array or minimum along an axis.
This docstring was copied from numpy.amin.
Some inconsistencies with the Dask version may exist.
Parameters:  a : array_like (Not supported in Dask)
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 Output type determination for more details.
 keepdims : bool, optional (Not supported in Dask)
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 subclasses of ndarray, however any nondefault value will be. If the subclass’ method does not implement keepdims any exceptions will be raised.
 initial : scalar, optional (Not supported in Dask)
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 (Not supported in Dask)
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
.
See also
amax
 The maximum value of an array along a given axis, propagating any NaNs.
nanmin
 The minimum value of an array along a given axis, ignoring any NaNs.
minimum
 Elementwise minimum of two arrays, propagating any NaNs.
fmin
 Elementwise minimum of two arrays, ignoring any NaNs.
argmin
 Return the indices of the minimum values.
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 elementwise comparison of 2 arrays; when
a.shape[0]
is 2,minimum(a[0], a[1])
is faster thanamin(a, axis=0)
.Examples
>>> a = np.arange(4).reshape((2,2)) # doctest: +SKIP >>> a # doctest: +SKIP array([[0, 1], [2, 3]]) >>> np.amin(a) # Minimum of the flattened array # doctest: +SKIP 0 >>> np.amin(a, axis=0) # Minima along the first axis # doctest: +SKIP array([0, 1]) >>> np.amin(a, axis=1) # Minima along the second axis # doctest: +SKIP array([0, 2]) >>> np.amin(a, where=[False, True], initial=10, axis=0) # doctest: +SKIP array([10, 1])
>>> b = np.arange(5, dtype=float) # doctest: +SKIP >>> b[2] = np.NaN # doctest: +SKIP >>> np.amin(b) # doctest: +SKIP nan >>> np.amin(b, where=~np.isnan(b), initial=10) # doctest: +SKIP 0.0 >>> np.nanmin(b) # doctest: +SKIP 0.0
>>> np.min([[50], [10]], axis=1, initial=0) # doctest: +SKIP array([50, 0])
Notice that the initial value is used as one of the elements for which the minimum is determined, unlike for the default argument Python’s max function, which is only used for empty iterables.
Notice that this isn’t the same as Python’s
default
argument.>>> np.min([6], initial=5) # doctest: +SKIP 5 >>> min([6], default=5) # doctest: +SKIP 6

dask.array.
argtopk
(a, k, axis=1, split_every=None)[source]¶ Extract the indices of the k largest elements from a on the given axis, and return them sorted from largest to smallest. If k is negative, extract the indices of the k smallest elements instead, and return them sorted from smallest to largest.
This performs best when
k
is much smaller than the chunk size. All results will be returned in a single chunk along the given axis.Parameters:  x: Array
Data being sorted
 k: int
 axis: int, optional
 split_every: int >=2, optional
See
topk()
. The performance considerations for topk also apply here.
Returns:  Selection of np.intp indices of x with size abs(k) along the given axis.
Examples
>>> import dask.array as da >>> x = np.array([5, 1, 3, 6]) >>> d = da.from_array(x, chunks=2) >>> d.argtopk(2).compute() array([3, 0]) >>> d.argtopk(2).compute() array([1, 2])

dask.array.
argwhere
(a)[source]¶ Find the indices of array elements that are nonzero, grouped by element.
This docstring was copied from numpy.argwhere.
Some inconsistencies with the Dask version may exist.
Parameters:  a : array_like
Input data.
Returns:  index_array : (N, a.ndim) ndarray
Indices of elements that are nonzero. Indices are grouped by element. This array will have shape
(N, a.ndim)
whereN
is the number of nonzero items.
Notes
np.argwhere(a)
is almost the same asnp.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 usenonzero(a)
instead.Examples
>>> x = np.arange(6).reshape(2,3) # doctest: +SKIP >>> x # doctest: +SKIP array([[0, 1, 2], [3, 4, 5]]) >>> np.argwhere(x>1) # doctest: +SKIP array([[0, 2], [1, 0], [1, 1], [1, 2]])

dask.array.
around
(x, decimals=0)[source]¶ Evenly round to the given number of decimals.
This docstring was copied from numpy.around.
Some inconsistencies with the Dask version may exist.
Parameters:  a : array_like (Not supported in Dask)
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 (Not supported in Dask)
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 Output type determination 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.
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 floatingpoint datatypes. For positive decimals it is equivalent tonp.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 [1] and errors introduced when scaling by powers of ten. For instance, note the extra “1” in the following:>>> np.round(56294995342131.5, 3) # doctest: +SKIP 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) # doctest: +SKIP '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 64bit floating point values:
>>> round(56294995342131.5, 3) # doctest: +SKIP 56294995342131.5 >>> np.round(16.055, 2), round(16.055, 2) # equals 16.0549999999999997 # doctest: +SKIP (16.06, 16.05)
References
[1] “Lecture Notes on the Status of IEEE 754”, William Kahan, https://people.eecs.berkeley.edu/~wkahan/ieee754status/IEEE754.PDF [2] “How Futile are Mindless Assessments of Roundoff in FloatingPoint Computation?”, William Kahan, https://people.eecs.berkeley.edu/~wkahan/Mindless.pdf Examples
>>> np.around([0.37, 1.64]) # doctest: +SKIP array([0., 2.]) >>> np.around([0.37, 1.64], decimals=1) # doctest: +SKIP array([0.4, 1.6]) >>> np.around([.5, 1.5, 2.5, 3.5, 4.5]) # rounds to nearest even value # doctest: +SKIP array([0., 2., 2., 4., 4.]) >>> np.around([1,2,3,11], decimals=1) # ndarray of ints is returned # doctest: +SKIP array([ 1, 2, 3, 11]) >>> np.around([1,2,3,11], decimals=1) # doctest: +SKIP array([ 0, 0, 0, 10])

dask.array.
array
(object, dtype=None, *, copy=True, order='K', subok=False, ndmin=0, like=None)[source]¶ This docstring was copied from numpy.array.
Some inconsistencies with the Dask version may exist.
Create an array.
Parameters:  object : array_like
An array, any object exposing the array interface, an object whose __array__ method returns an array, or any (nested) sequence.
 dtype : datatype, optional
The desired datatype for the array. If not given, then the type will be determined as the minimum type required to hold the objects in the sequence.
 copy : bool, optional
If true (default), then the object is copied. Otherwise, a copy will only be made if __array__ returns a copy, if obj is a nested sequence, or if a copy is needed to satisfy any of the other requirements (dtype, order, etc.).
 order : {‘K’, ‘A’, ‘C’, ‘F’}, optional
Specify the memory layout of the array. If object is not an array, the newly created array will be in C order (row major) unless ‘F’ is specified, in which case it will be in Fortran order (column major). If object is an array the following holds.
order no copy copy=True ‘K’ unchanged F & C order preserved, otherwise most similar order ‘A’ unchanged F order if input is F and not C, otherwise C order ‘C’ C order C order ‘F’ F order F order When
copy=False
and a copy is made for other reasons, the result is the same as ifcopy=True
, with some exceptions for A, see the Notes section. The default order is ‘K’. subok : bool, optional
If True, then subclasses will be passedthrough, otherwise the returned array will be forced to be a baseclass array (default).
 ndmin : int, optional
Specifies the minimum number of dimensions that the resulting array should have. Ones will be prepended to the shape as needed to meet this requirement.
 like : array_like
Reference object to allow the creation of arrays which are not NumPy arrays. If an arraylike passed in as
like
supports the__array_function__
protocol, the result will be defined by it. In this case, it ensures the creation of an array object compatible with that passed in via this argument.Note
The
like
keyword is an experimental feature pending on acceptance of NEP 35.New in version 1.20.0.
Returns:  out : ndarray
An array object satisfying the specified requirements.
See also
empty_like
 Return an empty array with shape and type of input.
ones_like
 Return an array of ones with shape and type of input.
zeros_like
 Return an array of zeros with shape and type of input.
full_like
 Return a new array with shape of input filled with value.
empty
 Return a new uninitialized array.
ones
 Return a new array setting values to one.
zeros
 Return a new array setting values to zero.
full
 Return a new array of given shape filled with value.
Notes
When order is ‘A’ and object is an array in neither ‘C’ nor ‘F’ order, and a copy is forced by a change in dtype, then the order of the result is not necessarily ‘C’ as expected. This is likely a bug.
Examples
>>> np.array([1, 2, 3]) # doctest: +SKIP array([1, 2, 3])
Upcasting:
>>> np.array([1, 2, 3.0]) # doctest: +SKIP array([ 1., 2., 3.])
More than one dimension:
>>> np.array([[1, 2], [3, 4]]) # doctest: +SKIP array([[1, 2], [3, 4]])
Minimum dimensions 2:
>>> np.array([1, 2, 3], ndmin=2) # doctest: +SKIP array([[1, 2, 3]])
Type provided:
>>> np.array([1, 2, 3], dtype=complex) # doctest: +SKIP array([ 1.+0.j, 2.+0.j, 3.+0.j])
Datatype consisting of more than one element:
>>> x = np.array([(1,2),(3,4)],dtype=[('a','<i4'),('b','<i4')]) # doctest: +SKIP >>> x['a'] # doctest: +SKIP array([1, 3])
Creating an array from subclasses:
>>> np.array(np.mat('1 2; 3 4')) # doctest: +SKIP array([[1, 2], [3, 4]])
>>> np.array(np.mat('1 2; 3 4'), subok=True) # doctest: +SKIP matrix([[1, 2], [3, 4]])

dask.array.
asanyarray
(a)[source]¶ Convert the input to a dask array.
Subclasses of
np.ndarray
will be passed through as chunks unchanged.Parameters:  a : arraylike
Input data, in any form that can be converted to a dask array.
Returns:  out : dask array
Dask array interpretation of a.
Examples
>>> import dask.array as da >>> import numpy as np >>> x = np.arange(3) >>> da.asanyarray(x) dask.array<array, shape=(3,), dtype=int64, chunksize=(3,), chunktype=numpy.ndarray>
>>> y = [[1, 2, 3], [4, 5, 6]] >>> da.asanyarray(y) dask.array<array, shape=(2, 3), dtype=int64, chunksize=(2, 3), chunktype=numpy.ndarray>

dask.array.
asarray
(a, **kwargs)[source]¶ Convert the input to a dask array.
Parameters:  a : arraylike
Input data, in any form that can be converted to a dask array.
Returns:  out : dask array
Dask array interpretation of a.
Examples
>>> import dask.array as da >>> import numpy as np >>> x = np.arange(3) >>> da.asarray(x) dask.array<array, shape=(3,), dtype=int64, chunksize=(3,), chunktype=numpy.ndarray>
>>> y = [[1, 2, 3], [4, 5, 6]] >>> da.asarray(y) dask.array<array, shape=(2, 3), dtype=int64, chunksize=(2, 3), chunktype=numpy.ndarray>

dask.array.
atleast_1d
(*arys)[source]¶ Convert inputs to arrays with at least one dimension.
This docstring was copied from numpy.atleast_1d.
Some inconsistencies with the Dask version may exist.
Scalar inputs are converted to 1dimensional arrays, whilst higherdimensional inputs are preserved.
Parameters:  arys1, arys2, … : array_like
One or more input arrays.
Returns:  ret : ndarray
An array, or list of arrays, each with
a.ndim >= 1
. Copies are made only if necessary.
See also
Examples
>>> np.atleast_1d(1.0) # doctest: +SKIP array([1.])
>>> x = np.arange(9.0).reshape(3,3) # doctest: +SKIP >>> np.atleast_1d(x) # doctest: +SKIP array([[0., 1., 2.], [3., 4., 5.], [6., 7., 8.]]) >>> np.atleast_1d(x) is x # doctest: +SKIP True
>>> np.atleast_1d(1, [3, 4]) # doctest: +SKIP [array([1]), array([3, 4])]

dask.array.
atleast_2d
(*arys)[source]¶ View inputs as arrays with at least two dimensions.
This docstring was copied from numpy.atleast_2d.
Some inconsistencies with the Dask version may exist.
Parameters:  arys1, arys2, … : array_like
One or more arraylike sequences. Nonarray inputs are converted to arrays. Arrays that already have two or more dimensions are preserved.
Returns:  res, res2, … : ndarray
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.
See also
Examples
>>> np.atleast_2d(3.0) # doctest: +SKIP array([[3.]])
>>> x = np.arange(3.0) # doctest: +SKIP >>> np.atleast_2d(x) # doctest: +SKIP array([[0., 1., 2.]]) >>> np.atleast_2d(x).base is x # doctest: +SKIP True
>>> np.atleast_2d(1, [1, 2], [[1, 2]]) # doctest: +SKIP [array([[1]]), array([[1, 2]]), array([[1, 2]])]

dask.array.
atleast_3d
(*arys)[source]¶ View inputs as arrays with at least three dimensions.
This docstring was copied from numpy.atleast_3d.
Some inconsistencies with the Dask version may exist.
Parameters:  arys1, arys2, … : array_like
One or more arraylike sequences. Nonarray inputs are converted to arrays. Arrays that already have three or more dimensions are preserved.
Returns:  res1, res2, … : ndarray
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 1D array of shape(N,)
becomes a view of shape(1, N, 1)
, and a 2D array of shape(M, N)
becomes a view of shape(M, N, 1)
.
See also
Examples
>>> np.atleast_3d(3.0) # doctest: +SKIP array([[[3.]]])
>>> x = np.arange(3.0) # doctest: +SKIP >>> np.atleast_3d(x).shape # doctest: +SKIP (1, 3, 1)
>>> x = np.arange(12.0).reshape(4,3) # doctest: +SKIP >>> np.atleast_3d(x).shape # doctest: +SKIP (4, 3, 1) >>> np.atleast_3d(x).base is x.base # x is a reshape, so not base itself # doctest: +SKIP True
>>> for arr in np.atleast_3d([1, 2], [[1, 2]], [[[1, 2]]]): # doctest: +SKIP ... print(arr, arr.shape) # doctest: +SKIP ... [[[1] [2]]] (1, 2, 1) [[[1] [2]]] (1, 2, 1) [[[1 2]]] (1, 1, 2)

dask.array.
average
(a, axis=None, weights=None, returned=False)[source]¶ Compute the weighted average along the specified axis.
This docstring was copied from numpy.average.
Some inconsistencies with the Dask 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 1D (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 1D 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 befloat64
.
Raises:  ZeroDivisionError
When all weights along axis are zero. See numpy.ma.average for a version robust to this type of error.
 TypeError
When the length of 1D weights is not the same as the shape of a along axis.
See also
mean
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.
Examples
>>> data = np.arange(1, 5) # doctest: +SKIP >>> data # doctest: +SKIP array([1, 2, 3, 4]) >>> np.average(data) # doctest: +SKIP 2.5 >>> np.average(np.arange(1, 11), weights=np.arange(10, 0, 1)) # doctest: +SKIP 4.0
>>> data = np.arange(6).reshape((3,2)) # doctest: +SKIP >>> data # doctest: +SKIP array([[0, 1], [2, 3], [4, 5]]) >>> np.average(data, axis=1, weights=[1./4, 3./4]) # doctest: +SKIP array([0.75, 2.75, 4.75]) >>> np.average(data, weights=[1./4, 3./4]) # doctest: +SKIP Traceback (most recent call last): ... TypeError: Axis must be specified when shapes of a and weights differ.
>>> a = np.ones(5, dtype=np.float128) # doctest: +SKIP >>> w = np.ones(5, dtype=np.complex64) # doctest: +SKIP >>> avg = np.average(a, weights=w) # doctest: +SKIP >>> print(avg.dtype) # doctest: +SKIP complex256

dask.array.
bincount
(x, weights=None, minlength=0)[source]¶ This docstring was copied from numpy.bincount.
Some inconsistencies with the Dask version may exist.
Count number of occurrences of each value in array of nonnegative ints.
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 positioni
,out[n] += weight[i]
instead ofout[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 : ndarray of ints
The result of binning the input array. The length of out is equal to
np.amax(x)+1
.
Raises:  ValueError
If the input is not 1dimensional, or contains elements with negative values, or if minlength is negative.
 TypeError
If the type of the input is float or complex.
Examples
>>> np.bincount(np.arange(5)) # doctest: +SKIP array([1, 1, 1, 1, 1]) >>> np.bincount(np.array([0, 1, 1, 3, 2, 1, 7])) # doctest: +SKIP array([1, 3, 1, 1, 0, 0, 0, 1])
>>> x = np.array([0, 1, 1, 3, 2, 1, 7, 23]) # doctest: +SKIP >>> np.bincount(x).size == np.amax(x)+1 # doctest: +SKIP True
The input array needs to be of integer dtype, otherwise a TypeError is raised:
>>> np.bincount(np.arange(5, dtype=float)) # doctest: +SKIP Traceback (most recent call last): ... TypeError: Cannot cast array data from dtype('float64') to dtype('int64') according to the rule 'safe'
A possible use of
bincount
is to perform sums over variablesize chunks of an array, using theweights
keyword.>>> w = np.array([0.3, 0.5, 0.2, 0.7, 1., 0.6]) # weights # doctest: +SKIP >>> x = np.array([0, 1, 1, 2, 2, 2]) # doctest: +SKIP >>> np.bincount(x, weights=w) # doctest: +SKIP array([ 0.3, 0.7, 1.1])

dask.array.
bitwise_and
(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.bitwise_and.
Some inconsistencies with the Dask version may exist.
Compute the bitwise AND of two arrays elementwise.
Computes the bitwise AND of the underlying binary representation of the integers in the input arrays. This ufunc implements the C/Python operator
&
.Parameters:  x1, x2 : array_like
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). out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  out : ndarray or scalar
Result. This is a scalar if both x1 and x2 are scalars.
See also
logical_and
bitwise_or
bitwise_xor
binary_repr
 Return the binary representation of the input number as a string.
Examples
The number 13 is represented by
00001101
. Likewise, 17 is represented by00010001
. The bitwise AND of 13 and 17 is therefore000000001
, or 1:>>> np.bitwise_and(13, 17) # doctest: +SKIP 1
>>> np.bitwise_and(14, 13) # doctest: +SKIP 12 >>> np.binary_repr(12) # doctest: +SKIP '1100' >>> np.bitwise_and([14,3], 13) # doctest: +SKIP array([12, 1])
>>> np.bitwise_and([11,7], [4,25]) # doctest: +SKIP array([0, 1]) >>> np.bitwise_and(np.array([2,5,255]), np.array([3,14,16])) # doctest: +SKIP array([ 2, 4, 16]) >>> np.bitwise_and([True, True], [False, True]) # doctest: +SKIP array([False, True])
The
&
operator can be used as a shorthand fornp.bitwise_and
on ndarrays.>>> x1 = np.array([2, 5, 255]) # doctest: +SKIP >>> x2 = np.array([3, 14, 16]) # doctest: +SKIP >>> x1 & x2 # doctest: +SKIP array([ 2, 4, 16])

dask.array.
bitwise_not
(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.invert.
Some inconsistencies with the Dask version may exist.
Compute bitwise inversion, or bitwise NOT, elementwise.
Computes the bitwise NOT of the underlying binary representation of the integers in the input arrays. This ufunc implements the C/Python operator
~
.For signed integer inputs, the two’s complement is returned. In a two’scomplement system negative numbers are represented by the two’s complement of the absolute value. This is the most common method of representing signed integers on computers [1]. A Nbit two’scomplement system can represent every integer in the range \(2^{N1}\) to \(+2^{N1}1\).
Parameters:  x : array_like
Only integer and boolean types are handled.
 out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  out : ndarray or scalar
Result. This is a scalar if x is a scalar.
See also
bitwise_and
,bitwise_or
,bitwise_xor
logical_not
binary_repr
 Return the binary representation of the input number as a string.
Notes
bitwise_not is an alias for invert:
>>> np.bitwise_not is np.invert # doctest: +SKIP True
References
[1] Wikipedia, “Two’s complement”, https://en.wikipedia.org/wiki/Two’s_complement Examples
We’ve seen that 13 is represented by
00001101
. The invert or bitwise NOT of 13 is then:>>> x = np.invert(np.array(13, dtype=np.uint8)) # doctest: +SKIP >>> x # doctest: +SKIP 242 >>> np.binary_repr(x, width=8) # doctest: +SKIP '11110010'
The result depends on the bitwidth:
>>> x = np.invert(np.array(13, dtype=np.uint16)) # doctest: +SKIP >>> x # doctest: +SKIP 65522 >>> np.binary_repr(x, width=16) # doctest: +SKIP '1111111111110010'
When using signed integer types the result is the two’s complement of the result for the unsigned type:
>>> np.invert(np.array([13], dtype=np.int8)) # doctest: +SKIP array([14], dtype=int8) >>> np.binary_repr(14, width=8) # doctest: +SKIP '11110010'
Booleans are accepted as well:
>>> np.invert(np.array([True, False])) # doctest: +SKIP array([False, True])
The
~
operator can be used as a shorthand fornp.invert
on ndarrays.>>> x1 = np.array([True, False]) # doctest: +SKIP >>> ~x1 # doctest: +SKIP array([False, True])

dask.array.
bitwise_or
(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.bitwise_or.
Some inconsistencies with the Dask version may exist.
Compute the bitwise OR of two arrays elementwise.
Computes the bitwise OR of the underlying binary representation of the integers in the input arrays. This ufunc implements the C/Python operator

.Parameters:  x1, x2 : array_like
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). out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  out : ndarray or scalar
Result. This is a scalar if both x1 and x2 are scalars.
See also
logical_or
bitwise_and
bitwise_xor
binary_repr
 Return the binary representation of the input number as a string.
Examples
The number 13 has the binaray representation
00001101
. Likewise, 16 is represented by00010000
. The bitwise OR of 13 and 16 is then000111011
, or 29:>>> np.bitwise_or(13, 16) # doctest: +SKIP 29 >>> np.binary_repr(29) # doctest: +SKIP '11101'
>>> np.bitwise_or(32, 2) # doctest: +SKIP 34 >>> np.bitwise_or([33, 4], 1) # doctest: +SKIP array([33, 5]) >>> np.bitwise_or([33, 4], [1, 2]) # doctest: +SKIP array([33, 6])
>>> np.bitwise_or(np.array([2, 5, 255]), np.array([4, 4, 4])) # doctest: +SKIP array([ 6, 5, 255]) >>> np.array([2, 5, 255])  np.array([4, 4, 4]) # doctest: +SKIP array([ 6, 5, 255]) >>> np.bitwise_or(np.array([2, 5, 255, 2147483647], dtype=np.int32), # doctest: +SKIP ... np.array([4, 4, 4, 2147483647], dtype=np.int32)) array([ 6, 5, 255, 2147483647]) >>> np.bitwise_or([True, True], [False, True]) # doctest: +SKIP array([ True, True])
The

operator can be used as a shorthand fornp.bitwise_or
on ndarrays.>>> x1 = np.array([2, 5, 255]) # doctest: +SKIP >>> x2 = np.array([4, 4, 4]) # doctest: +SKIP >>> x1  x2 # doctest: +SKIP array([ 6, 5, 255])

dask.array.
bitwise_xor
(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.bitwise_xor.
Some inconsistencies with the Dask version may exist.
Compute the bitwise XOR of two arrays elementwise.
Computes the bitwise XOR of the underlying binary representation of the integers in the input arrays. This ufunc implements the C/Python operator
^
.Parameters:  x1, x2 : array_like
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). out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  out : ndarray or scalar
Result. This is a scalar if both x1 and x2 are scalars.
See also
logical_xor
bitwise_and
bitwise_or
binary_repr
 Return the binary representation of the input number as a string.
Examples
The number 13 is represented by
00001101
. Likewise, 17 is represented by00010001
. The bitwise XOR of 13 and 17 is therefore00011100
, or 28:>>> np.bitwise_xor(13, 17) # doctest: +SKIP 28 >>> np.binary_repr(28) # doctest: +SKIP '11100'
>>> np.bitwise_xor(31, 5) # doctest: +SKIP 26 >>> np.bitwise_xor([31,3], 5) # doctest: +SKIP array([26, 6])
>>> np.bitwise_xor([31,3], [5,6]) # doctest: +SKIP array([26, 5]) >>> np.bitwise_xor([True, True], [False, True]) # doctest: +SKIP array([ True, False])
The
^
operator can be used as a shorthand fornp.bitwise_xor
on ndarrays.>>> x1 = np.array([True, True]) # doctest: +SKIP >>> x2 = np.array([False, True]) # doctest: +SKIP >>> x1 ^ x2 # doctest: +SKIP array([ True, False])

dask.array.
block
(arrays, allow_unknown_chunksizes=False)[source]¶ Assemble an ndarray from nested lists of blocks.
Blocks in the innermost lists are concatenated along the last dimension (1), then these are concatenated along the secondlast dimension (2), and so on until the outermost list is reached
Blocks can be of any dimension, but will not be broadcasted using the normal rules. Instead, leading axes of size 1 are inserted, to make
block.ndim
the same for all blocks. This is primarily useful for working with scalars, and means that code likeblock([v, 1])
is valid, wherev.ndim == 1
.When the nested list is two levels deep, this allows block matrices to be constructed from their components.
Parameters:  arrays : nested list of array_like or scalars (but not tuples)
If passed a single ndarray or scalar (a nested list of depth 0), this is returned unmodified (and not copied).
Elements shapes must match along the appropriate axes (without broadcasting), but leading 1s will be prepended to the shape as necessary to make the dimensions match.
 allow_unknown_chunksizes: bool
Allow unknown chunksizes, such as come from converting from dask dataframes. Dask.array is unable to verify that chunks line up. If data comes from differently aligned sources then this can cause unexpected results.
Returns:  block_array : ndarray
The array assembled from the given blocks.
The dimensionality of the output is equal to the greatest of: * the dimensionality of all the inputs * the depth to which the input list is nested
Raises:  ValueError
 If list depths are mismatched  for instance,
[[a, b], c]
is illegal, and should be spelt[[a, b], [c]]
 If lists are empty  for instance,
[[a, b], []]
 If list depths are mismatched  for instance,
See also
concatenate
 Join a sequence of arrays together.
stack
 Stack arrays in sequence along a new dimension.
hstack
 Stack arrays in sequence horizontally (column wise).
vstack
 Stack arrays in sequence vertically (row wise).
dstack
 Stack arrays in sequence depth wise (along third dimension).
vsplit
 Split array into a list of multiple subarrays vertically.
Notes
When called with only scalars,
block
is equivalent to an ndarray call. Soblock([[1, 2], [3, 4]])
is equivalent toarray([[1, 2], [3, 4]])
.This function does not enforce that the blocks lie on a fixed grid.
block([[a, b], [c, d]])
is not restricted to arrays of the form:AAAbb AAAbb cccDD
But is also allowed to produce, for some
a, b, c, d
:AAAbb AAAbb cDDDD
Since concatenation happens along the last axis first, block is _not_ capable of producing the following directly:
AAAbb cccbb cccDD
Matlab’s “square bracket stacking”,
[A, B, ...; p, q, ...]
, is equivalent toblock([[A, B, ...], [p, q, ...]])
.

dask.array.
blockwise
(func, out_ind, *args, name=None, token=None, dtype=None, adjust_chunks=None, new_axes=None, align_arrays=True, concatenate=None, meta=None, **kwargs)[source]¶ Tensor operation: Generalized inner and outer products
A broad class of blocked algorithms and patterns can be specified with a concise multiindex notation. The
blockwise
function applies an inmemory function across multiple blocks of multiple inputs in a variety of ways. Many dask.array operations are special cases of blockwise including elementwise, broadcasting, reductions, tensordot, and transpose.Parameters:  func : callable
Function to apply to individual tuples of blocks
 out_ind : iterable
Block pattern of the output, something like ‘ijk’ or (1, 2, 3)
 *args : sequence of Array, index pairs
Sequence like (x, ‘ij’, y, ‘jk’, z, ‘i’)
 **kwargs : dict
Extra keyword arguments to pass to function
 dtype : np.dtype
Datatype of resulting array.
 concatenate : bool, keyword only
If true concatenate arrays along dummy indices, else provide lists
 adjust_chunks : dict
Dictionary mapping index to function to be applied to chunk sizes
 new_axes : dict, keyword only
New indexes and their dimension lengths
Examples
2D embarrassingly parallel operation from two arrays, x, and y.
>>> import operator, numpy as np, dask.array as da >>> x = da.from_array([[1, 2], ... [3, 4]], chunks=(1, 2)) >>> y = da.from_array([[10, 20], ... [0, 0]]) >>> z = blockwise(operator.add, 'ij', x, 'ij', y, 'ij', dtype='f8') >>> z.compute() array([[11, 22], [ 3, 4]])
Outer product multiplying a by b, two 1d vectors
>>> a = da.from_array([0, 1, 2], chunks=1) >>> b = da.from_array([10, 50, 100], chunks=1) >>> z = blockwise(np.outer, 'ij', a, 'i', b, 'j', dtype='f8') >>> z.compute() array([[ 0, 0, 0], [ 10, 50, 100], [ 20, 100, 200]])
z = x.T
>>> z = blockwise(np.transpose, 'ji', x, 'ij', dtype=x.dtype) >>> z.compute() array([[1, 3], [2, 4]])
The transpose case above is illustrative because it does transposition both on each inmemory block by calling
np.transpose
and on the order of the blocks themselves, by switching the order of the indexij > ji
.We can compose these same patterns with more variables and more complex inmemory functions
z = X + Y.T
>>> z = blockwise(lambda x, y: x + y.T, 'ij', x, 'ij', y, 'ji', dtype='f8') >>> z.compute() array([[11, 2], [23, 4]])
Any index, like
i
missing from the output index is interpreted as a contraction (note that this differs from Einstein convention; repeated indices do not imply contraction.) In the case of a contraction the passed function should expect an iterable of blocks on any array that holds that index. To receive arrays concatenated along contracted dimensions instead passconcatenate=True
.Inner product multiplying a by b, two 1d vectors
>>> def sequence_dot(a_blocks, b_blocks): ... result = 0 ... for a, b in zip(a_blocks, b_blocks): ... result += a.dot(b) ... return result
>>> z = blockwise(sequence_dot, '', a, 'i', b, 'i', dtype='f8') >>> z.compute() 250
Add new singlechunk dimensions with the
new_axes=
keyword, including the length of the new dimension. New dimensions will always be in a single chunk.>>> def f(a): ... return a[:, None] * np.ones((1, 5))
>>> z = blockwise(f, 'az', a, 'a', new_axes={'z': 5}, dtype=a.dtype)
New dimensions can also be multichunk by specifying a tuple of chunk sizes. This has limited utility as is (because the chunks are all the same), but the resulting graph can be modified to achieve more useful results (see
da.map_blocks
).>>> z = blockwise(f, 'az', a, 'a', new_axes={'z': (5, 5)}, dtype=x.dtype) >>> z.chunks ((1, 1, 1), (5, 5))
If the applied function changes the size of each chunk you can specify this with a
adjust_chunks={...}
dictionary holding a function for each index that modifies the dimension size in that index.>>> def double(x): ... return np.concatenate([x, x])
>>> y = blockwise(double, 'ij', x, 'ij', ... adjust_chunks={'i': lambda n: 2 * n}, dtype=x.dtype) >>> y.chunks ((2, 2), (2,))
Include literals by indexing with None
>>> z = blockwise(operator.add, 'ij', x, 'ij', 1234, None, dtype=x.dtype) >>> z.compute() array([[1235, 1236], [1237, 1238]])

dask.array.
broadcast_arrays
(*args, **kwargs)[source]¶ Broadcast any number of arrays against each other.
This docstring was copied from numpy.broadcast_arrays.
Some inconsistencies with the Dask version may exist.
Parameters:  `*args` : array_likes
The arrays to broadcast.
 subok : bool, optional (Not supported in Dask)
If True, then subclasses will be passedthrough, otherwise the returned arrays will be forced to be a baseclass array (default).
Returns:  broadcasted : list of arrays
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.
See also
broadcast
broadcast_to
broadcast_shapes
Examples
>>> x = np.array([[1,2,3]]) # doctest: +SKIP >>> y = np.array([[4],[5]]) # doctest: +SKIP >>> np.broadcast_arrays(x, y) # doctest: +SKIP [array([[1, 2, 3], [1, 2, 3]]), array([[4, 4, 4], [5, 5, 5]])]
Here is a useful idiom for getting contiguous copies instead of noncontiguous views.
>>> [np.array(a) for a in np.broadcast_arrays(x, y)] # doctest: +SKIP [array([[1, 2, 3], [1, 2, 3]]), array([[4, 4, 4], [5, 5, 5]])]

dask.array.
broadcast_to
(x, shape, chunks=None, meta=None)[source]¶ Broadcast an array to a new shape.
Parameters:  x : array_like
The array to broadcast.
 shape : tuple
The shape of the desired array.
 chunks : tuple, optional
If provided, then the result will use these chunks instead of the same chunks as the source array. Setting chunks explicitly as part of broadcast_to is more efficient than rechunking afterwards. Chunks are only allowed to differ from the original shape along dimensions that are new on the result or have size 1 the input array.
 meta : empty ndarray
empty ndarray created with same NumPy backend, ndim and dtype as the Dask Array being created (overrides dtype)
Returns:  broadcast : dask array
See also

dask.array.
cbrt
(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.cbrt.
Some inconsistencies with the Dask version may exist.
Return the cuberoot of an array, elementwise.
New in version 1.10.0.
Parameters:  x : array_like
The values whose cuberoots are required.
 out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  y : ndarray
An array of the same shape as x, containing the cube cuberoot of each element in x. If out was provided, y is a reference to it. This is a scalar if x is a scalar.
Examples
>>> np.cbrt([1,8,27]) # doctest: +SKIP array([ 1., 2., 3.])

dask.array.
coarsen
(reduction, x, axes, trim_excess=False, **kwargs)[source]¶ Coarsen array by applying reduction to fixed size neighborhoods
Parameters:  reduction: function
Function like np.sum, np.mean, etc…
 x: np.ndarray
Array to be coarsened
 axes: dict
Mapping of axis to coarsening factor
Examples
>>> x = np.array([1, 2, 3, 4, 5, 6]) >>> coarsen(np.sum, x, {0: 2}) #doctest: +SKIP array([ 3, 7, 11]) >>> coarsen(np.max, x, {0: 3}) #doctest: +SKIP array([3, 6])
Provide dictionary of scale per dimension
>>> x = np.arange(24).reshape((4, 6)) >>> x array([[ 0, 1, 2, 3, 4, 5], [ 6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17], [18, 19, 20, 21, 22, 23]])
>>> coarsen(np.min, x, {0: 2, 1: 3}) #doctest: +SKIP array([[ 0, 3], [12, 15]])
You must avoid excess elements explicitly
>>> x = np.array([1, 2, 3, 4, 5, 6, 7, 8]) >>> coarsen(np.min, x, {0: 3}, trim_excess=True) #doctest: +SKIP array([1, 4])

dask.array.
ceil
(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.ceil.
Some inconsistencies with the Dask version may exist.
Return the ceiling of the input, elementwise.
The ceil of the scalar x is the smallest integer i, such that i >= x. It is often denoted as \(\lceil x \rceil\).
Parameters:  x : array_like
Input data.
 out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  y : ndarray or scalar
The ceiling of each element in x, with float dtype. This is a scalar if x is a scalar.
Examples
>>> a = np.array([1.7, 1.5, 0.2, 0.2, 1.5, 1.7, 2.0]) # doctest: +SKIP >>> np.ceil(a) # doctest: +SKIP array([1., 1., 0., 1., 2., 2., 2.])

dask.array.
choose
(a, choices)[source]¶ Construct an array from an index array and a set of arrays to choose from.
This docstring was copied from numpy.choose.
Some inconsistencies with the Dask version may exist.
First of all, if confused or uncertain, definitely look at the Examples  in its full generality, this function is less simple than it might seem from the following code description (below ndi = numpy.lib.index_tricks):
np.choose(a,c) == np.array([c[a[I]][I] for I in ndi.ndindex(a.shape)])
.But this omits some subtleties. Here is a fully general summary:
Given an “index” array (a) of integers and a sequence of n arrays (choices), a and each choice array are first broadcast, as necessary, to arrays of a common shape; calling these Ba and Bchoices[i], i = 0,…,n1 we have that, necessarily,
Ba.shape == Bchoices[i].shape
for each i. Then, a new array with shapeBa.shape
is created as follows: if
mode=raise
(the default), then, first of all, each element of a (and thus Ba) must be in the range [0, n1]; now, suppose that i (in that range) is the value at the (j0, j1, …, jm) position in Ba  then the value at the same position in the new array is the value in Bchoices[i] at that same position;  if
mode=wrap
, values in a (and thus Ba) may be any (signed) integer; modular arithmetic is used to map integers outside the range [0, n1] back into that range; and then the new array is constructed as above;  if
mode=clip
, values in a (and thus Ba) may be any (signed) integer; negative integers are mapped to 0; values greater than n1 are mapped to n1; and then the new array is constructed as above.
Parameters:  a : int array
This array must contain integers in [0, n1], where n is the number of choices, unless
mode=wrap
ormode=clip
, in which cases any integers are permissible. choices : sequence of arrays
Choice arrays. a and all of the choices must be broadcastable to the same shape. If choices is itself an array (not recommended), then its outermost dimension (i.e., the one corresponding to
choices.shape[0]
) is taken as defining the “sequence”. out : array, optional (Not supported in Dask)
If provided, the result will be inserted into 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’ (default), ‘wrap’, ‘clip’}, optional (Not supported in Dask)
Specifies how indices outside [0, n1] will be treated:
 ‘raise’ : an exception is raised
 ‘wrap’ : value becomes value mod n
 ‘clip’ : values < 0 are mapped to 0, values > n1 are mapped to n1
Returns:  merged_array : array
The merged result.
Raises:  ValueError: shape mismatch
If a and each choice array are not all broadcastable to the same shape.
See also
ndarray.choose
 equivalent method
numpy.take_along_axis
 Preferable if choices is an array
Notes
To reduce the chance of misinterpretation, even though the following “abuse” is nominally supported, choices should neither be, nor be thought of as, a single array, i.e., the outermost sequencelike container should be either a list or a tuple.
Examples
>>> choices = [[0, 1, 2, 3], [10, 11, 12, 13], # doctest: +SKIP ... [20, 21, 22, 23], [30, 31, 32, 33]] >>> np.choose([2, 3, 1, 0], choices # doctest: +SKIP ... # the first element of the result will be the first element of the ... # third (2+1) "array" in choices, namely, 20; the second element ... # will be the second element of the fourth (3+1) choice array, i.e., ... # 31, etc. ... ) array([20, 31, 12, 3]) >>> np.choose([2, 4, 1, 0], choices, mode='clip') # 4 goes to 3 (41) # doctest: +SKIP array([20, 31, 12, 3]) >>> # because there are 4 choice arrays >>> np.choose([2, 4, 1, 0], choices, mode='wrap') # 4 goes to (4 mod 4) # doctest: +SKIP array([20, 1, 12, 3]) >>> # i.e., 0
A couple examples illustrating how choose broadcasts:
>>> a = [[1, 0, 1], [0, 1, 0], [1, 0, 1]] # doctest: +SKIP >>> choices = [10, 10] # doctest: +SKIP >>> np.choose(a, choices) # doctest: +SKIP array([[ 10, 10, 10], [10, 10, 10], [ 10, 10, 10]])
>>> # With thanks to Anne Archibald >>> a = np.array([0, 1]).reshape((2,1,1)) # doctest: +SKIP >>> c1 = np.array([1, 2, 3]).reshape((1,3,1)) # doctest: +SKIP >>> c2 = np.array([1, 2, 3, 4, 5]).reshape((1,1,5)) # doctest: +SKIP >>> np.choose(a, (c1, c2)) # result is 2x3x5, res[0,:,:]=c1, res[1,:,:]=c2 # doctest: +SKIP array([[[ 1, 1, 1, 1, 1], [ 2, 2, 2, 2, 2], [ 3, 3, 3, 3, 3]], [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]])
 if

dask.array.
clip
(*args, **kwargs)¶ Clip (limit) the values in an array.
This docstring was copied from numpy.clip.
Some inconsistencies with the Dask 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.minimum(a_max, np.maximum(a, a_min))
.No check is performed to ensure
a_min < a_max
.Parameters:  a : array_like (Not supported in Dask)
Array containing elements to clip.
 a_min, a_max : array_like or None
Minimum and maximum value. If
None
, clipping is not performed on the corresponding edge. Only one of a_min and a_max may beNone
. Both are broadcast against a. out : ndarray, optional (Not supported in Dask)
The results will be placed in this array. It may be the input array for inplace clipping. out must be of the right shape to hold the output. Its type is preserved.
 **kwargs
For other keywordonly arguments, see the ufunc docs.
New in version 1.17.0.
Returns:  clipped_array : ndarray
An array with the elements of a, but where values < a_min are replaced with a_min, and those > a_max with a_max.
See also
Examples
>>> a = np.arange(10) # doctest: +SKIP >>> np.clip(a, 1, 8) # doctest: +SKIP array([1, 1, 2, 3, 4, 5, 6, 7, 8, 8]) >>> a # doctest: +SKIP array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) >>> np.clip(a, 3, 6, out=a) # doctest: +SKIP array([3, 3, 3, 3, 4, 5, 6, 6, 6, 6]) >>> a = np.arange(10) # doctest: +SKIP >>> a # doctest: +SKIP array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) >>> np.clip(a, [3, 4, 1, 1, 1, 4, 4, 4, 4, 4], 8) # doctest: +SKIP array([3, 4, 2, 3, 4, 5, 6, 7, 8, 8])

dask.array.
compress
(condition, a, axis=None)[source]¶ Return selected slices of an array along given axis.
This docstring was copied from numpy.compress.
Some inconsistencies with the Dask 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 1D array, compress is equivalent to extract.
Parameters:  condition : 1D 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 (Not supported in Dask)
Output array. Its type is preserved and it must be of the right shape to hold the output.
Returns:  compressed_array : ndarray
A copy of a without the slices along axis for which condition is false.
See also
take
,choose
,diag
,diagonal
,select
ndarray.compress
 Equivalent method in ndarray
extract
 Equivalent method when working on 1D arrays
 Output type determination
Examples
>>> a = np.array([[1, 2], [3, 4], [5, 6]]) # doctest: +SKIP >>> a # doctest: +SKIP array([[1, 2], [3, 4], [5, 6]]) >>> np.compress([0, 1], a, axis=0) # doctest: +SKIP array([[3, 4]]) >>> np.compress([False, True, True], a, axis=0) # doctest: +SKIP array([[3, 4], [5, 6]]) >>> np.compress([False, True], a, axis=1) # doctest: +SKIP array([[2], [4], [6]])
Working on the flattened array does not return slices along an axis but selects elements.
>>> np.compress([False, True], a) # doctest: +SKIP array([2])

dask.array.
concatenate
(seq, axis=0, allow_unknown_chunksizes=False)[source]¶ Concatenate arrays along an existing axis
Given a sequence of dask Arrays form a new dask Array by stacking them along an existing dimension (axis=0 by default)
Parameters:  seq: list of dask.arrays
 axis: int
Dimension along which to align all of the arrays
 allow_unknown_chunksizes: bool
Allow unknown chunksizes, such as come from converting from dask dataframes. Dask.array is unable to verify that chunks line up. If data comes from differently aligned sources then this can cause unexpected results.
See also
Examples
Create slices
>>> import dask.array as da >>> import numpy as np
>>> data = [da.from_array(np.ones((4, 4)), chunks=(2, 2)) ... for i in range(3)]
>>> x = da.concatenate(data, axis=0) >>> x.shape (12, 4)
>>> da.concatenate(data, axis=1).shape (4, 12)
Result is a new dask Array

dask.array.
conj
(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.conjugate.
Some inconsistencies with the Dask version may exist.
Return the complex conjugate, elementwise.
The complex conjugate of a complex number is obtained by changing the sign of its imaginary part.
Parameters:  x : array_like
Input value.
 out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  y : ndarray
The complex conjugate of x, with same dtype as y. This is a scalar if x is a scalar.
Notes
conj is an alias for conjugate:
>>> np.conj is np.conjugate # doctest: +SKIP True
Examples
>>> np.conjugate(1+2j) # doctest: +SKIP (12j)
>>> x = np.eye(2) + 1j * np.eye(2) # doctest: +SKIP >>> np.conjugate(x) # doctest: +SKIP array([[ 1.1.j, 0.0.j], [ 0.0.j, 1.1.j]])

dask.array.
copysign
(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.copysign.
Some inconsistencies with the Dask version may exist.
Change the sign of x1 to that of x2, elementwise.
If x2 is a scalar, its sign will be copied to all elements of x1.
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). out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  out : ndarray or scalar
The values of x1 with the sign of x2. This is a scalar if both x1 and x2 are scalars.
Examples
>>> np.copysign(1.3, 1) # doctest: +SKIP 1.3 >>> 1/np.copysign(0, 1) # doctest: +SKIP inf >>> 1/np.copysign(0, 1) # doctest: +SKIP inf
>>> np.copysign([1, 0, 1], 1.1) # doctest: +SKIP array([1., 0., 1.]) >>> np.copysign([1, 0, 1], np.arange(3)1) # doctest: +SKIP array([1., 0., 1.])

dask.array.
corrcoef
(x, y=None, rowvar=1)[source]¶ Return Pearson productmoment correlation coefficients.
This docstring was copied from numpy.corrcoef.
Some inconsistencies with the Dask 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 1D or 2D 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 (Not supported in Dask)
Has no effect, do not use.
Deprecated since version 1.10.0.
 ddof : _NoValue, optional (Not supported in Dask)
Has no effect, do not use.
Deprecated since version 1.10.0.
 dtype : datatype, optional (Not supported in Dask)
Datatype of the result. By default, the return datatype will have at least numpy.float64 precision.
New in version 1.20.
Returns:  R : ndarray
The correlation coefficient matrix of the variables.
See also
cov
 Covariance matrix
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.
Examples
In this example we generate two random arrays,
xarr
andyarr
, and compute the rowwise and columnwise Pearson correlation coefficients,R
. Sincerowvar
is true by default, we first find the rowwise Pearson correlation coefficients between the variables ofxarr
.>>> import numpy as np # doctest: +SKIP >>> rng = np.random.default_rng(seed=42) # doctest: +SKIP >>> xarr = rng.random((3, 3)) # doctest: +SKIP >>> xarr # doctest: +SKIP array([[0.77395605, 0.43887844, 0.85859792], [0.69736803, 0.09417735, 0.97562235], [0.7611397 , 0.78606431, 0.12811363]]) >>> R1 = np.corrcoef(xarr) # doctest: +SKIP >>> R1 # doctest: +SKIP array([[ 1. , 0.99256089, 0.68080986], [ 0.99256089, 1. , 0.76492172], [0.68080986, 0.76492172, 1. ]])
If we add another set of variables and observations
yarr
, we can compute the rowwise Pearson correlation coefficients between the variables inxarr
andyarr
.>>> yarr = rng.random((3, 3)) # doctest: +SKIP >>> yarr # doctest: +SKIP array([[0.45038594, 0.37079802, 0.92676499], [0.64386512, 0.82276161, 0.4434142 ], [0.22723872, 0.55458479, 0.06381726]]) >>> R2 = np.corrcoef(xarr, yarr) # doctest: +SKIP >>> R2 # doctest: +SKIP array([[ 1. , 0.99256089, 0.68080986, 0.75008178, 0.934284 , 0.99004057], [ 0.99256089, 1. , 0.76492172, 0.82502011, 0.97074098, 0.99981569], [0.68080986, 0.76492172, 1. , 0.99507202, 0.89721355, 0.77714685], [ 0.75008178, 0.82502011, 0.99507202, 1. , 0.93657855, 0.83571711], [0.934284 , 0.97074098, 0.89721355, 0.93657855, 1. , 0.97517215], [0.99004057, 0.99981569, 0.77714685, 0.83571711, 0.97517215, 1. ]])
Finally if we use the option
rowvar=False
, the columns are now being treated as the variables and we will find the columnwise Pearson correlation coefficients between variables inxarr
andyarr
.>>> R3 = np.corrcoef(xarr, yarr, rowvar=False) # doctest: +SKIP >>> R3 # doctest: +SKIP array([[ 1. , 0.77598074, 0.47458546, 0.75078643, 0.9665554 , 0.22423734], [ 0.77598074, 1. , 0.92346708, 0.99923895, 0.58826587, 0.44069024], [0.47458546, 0.92346708, 1. , 0.93773029, 0.23297648, 0.75137473], [0.75078643, 0.99923895, 0.93773029, 1. , 0.55627469, 0.47536961], [0.9665554 , 0.58826587, 0.23297648, 0.55627469, 1. , 0.46666491], [ 0.22423734, 0.44069024, 0.75137473, 0.47536961, 0.46666491, 1. ]])

dask.array.
cos
(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.cos.
Some inconsistencies with the Dask version may exist.
Cosine elementwise.
Parameters:  x : array_like
Input array in radians.
 out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  y : ndarray
The corresponding cosine values. This is a scalar if x is a scalar.
Notes
If out is provided, the function writes the result into it, and returns a reference to out. (See Examples)
References
M. Abramowitz and I. A. Stegun, Handbook of Mathematical Functions. New York, NY: Dover, 1972.
Examples
>>> np.cos(np.array([0, np.pi/2, np.pi])) # doctest: +SKIP array([ 1.00000000e+00, 6.12303177e17, 1.00000000e+00]) >>> >>> # Example of providing the optional output parameter >>> out1 = np.array([0], dtype='d') # doctest: +SKIP >>> out2 = np.cos([0.1], out1) # doctest: +SKIP >>> out2 is out1 # doctest: +SKIP True >>> >>> # Example of ValueError due to provision of shape mismatched `out` >>> np.cos(np.zeros((3,3)),np.zeros((2,2))) # doctest: +SKIP Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: operands could not be broadcast together with shapes (3,3) (2,2)

dask.array.
cosh
(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.cosh.
Some inconsistencies with the Dask version may exist.
Hyperbolic cosine, elementwise.
Equivalent to
1/2 * (np.exp(x) + np.exp(x))
andnp.cos(1j*x)
.Parameters:  x : array_like
Input array.
 out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  out : ndarray or scalar
Output array of same shape as x. This is a scalar if x is a scalar.
Examples
>>> np.cosh(0) # doctest: +SKIP 1.0
The hyperbolic cosine describes the shape of a hanging cable:
>>> import matplotlib.pyplot as plt # doctest: +SKIP >>> x = np.linspace(4, 4, 1000) # doctest: +SKIP >>> plt.plot(x, np.cosh(x)) # doctest: +SKIP >>> plt.show() # doctest: +SKIP

dask.array.
count_nonzero
(a, axis=None)[source]¶ Counts the number of nonzero values in the array
a
.This docstring was copied from numpy.count_nonzero.
Some inconsistencies with the Dask version may exist.
The word “nonzero” is in reference to the Python 2.x builtin 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 ina
(and in subarrays thereof) have their__nonzero__()
or__bool__()
method evaluated toTrue
.Parameters:  a : array_like
The array for which to count nonzeros.
 axis : int or tuple, optional
Axis or tuple of axes along which to count nonzeros. Default is None, meaning that nonzeros will be counted along a flattened version of
a
.New in version 1.12.0.
 keepdims : bool, optional (Not supported in Dask)
If this is set to True, the axes that are counted are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.
New in version 1.19.0.
Returns:  count : int or array of int
Number of nonzero values in the array along a given axis. Otherwise, the total number of nonzero values in the array is returned.
See also
nonzero
 Return the coordinates of all the nonzero values.
Examples
>>> np.count_nonzero(np.eye(4)) # doctest: +SKIP 4 >>> a = np.array([[0, 1, 7, 0], # doctest: +SKIP ... [3, 0, 2, 19]]) >>> np.count_nonzero(a) # doctest: +SKIP 5 >>> np.count_nonzero(a, axis=0) # doctest: +SKIP array([1, 1, 2, 1]) >>> np.count_nonzero(a, axis=1) # doctest: +SKIP array([2, 3]) >>> np.count_nonzero(a, axis=1, keepdims=True) # doctest: +SKIP array([[2], [3]])

dask.array.
cov
(m, y=None, rowvar=1, bias=0, ddof=None)[source]¶ Estimate a covariance matrix, given data and weights.
This docstring was copied from numpy.cov.
Some inconsistencies with the Dask version may exist.
Covariance indicates the level to which two variables vary together. If we examine Ndimensional 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 1D or 2D 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)
, whereN
is the number of observations given (unbiased estimate). If bias is True, then normalization is byN
. These values can be overridden by using the keywordddof
in numpy versions >= 1.5. ddof : int, optional
If not
None
the default value implied by bias is overridden. Note thatddof=1
will return the unbiased estimate, even if both fweights and aweights are specified, andddof=0
will return the simple average. See the notes for the details. The default value isNone
.New in version 1.5.
 fweights : array_like, int, optional (Not supported in Dask)
1D array of integer frequency weights; the number of times each observation vector should be repeated.
New in version 1.10.
 aweights : array_like, optional (Not supported in Dask)
1D 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.
 dtype : datatype, optional (Not supported in Dask)
Datatype of the result. By default, the return datatype will have at least numpy.float64 precision.
New in version 1.20.
Returns:  out : ndarray
The covariance matrix of the variables.
See also
corrcoef
 Normalized covariance matrix
Notes
Assume that the observations are in the columns of the observation array m and let
f = fweights
anda = 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 factorv1 / (v1**2  ddof * v2)
goes over to1 / (np.sum(f)  ddof)
as it should.Examples
Consider two variables, \(x_0\) and \(x_1\), which correlate perfectly, but in opposite directions:
>>> x = np.array([[0, 2], [1, 1], [2, 0]]).T # doctest: +SKIP >>> x # doctest: +SKIP array([[0, 1, 2], [2, 1, 0]])
Note how \(x_0\) increases while \(x_1\) decreases. The covariance matrix shows this clearly:
>>> np.cov(x) # doctest: +SKIP array([[ 1., 1.], [1., 1.]])
Note that element \(C_{0,1}\), which shows the correlation between \(x_0\) and \(x_1\), is negative.
Further, note how x and y are combined:
>>> x = [2.1, 1, 4.3] # doctest: +SKIP >>> y = [3, 1.1, 0.12] # doctest: +SKIP >>> X = np.stack((x, y), axis=0) # doctest: +SKIP >>> np.cov(X) # doctest: +SKIP array([[11.71 , 4.286 ], # may vary [4.286 , 2.144133]]) >>> np.cov(x, y) # doctest: +SKIP array([[11.71 , 4.286 ], # may vary [4.286 , 2.144133]]) >>> np.cov(x) # doctest: +SKIP array(11.71)

dask.array.
cumprod
(x, axis=None, dtype=None, out=None, method='sequential')[source]¶ Return the cumulative product of elements along a given axis.
This docstring was copied from numpy.cumprod.
Some inconsistencies with the Dask version may exist.
Dask added an additional keywordonly argument
method
. method : {‘sequential’, ‘blelloch’}, optional
Choose which method to use to perform the cumprod. Default is ‘sequential’.
 ‘sequential’ performs the cumprod of each prior block before the current block.
 ‘blelloch’ is a workefficient parallel cumprod. It exposes parallelism by first taking the product of each block and combines the products via a binary tree. This method may be faster or more memory efficient depending on workload, scheduler, and hardware. More benchmarking is necessary.
Parameters:  a : array_like (Not supported in Dask)
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 : ndarray
A new array holding the result is returned unless out is specified, in which case a reference to out is returned.
See also
Notes
Arithmetic is modular when using integer types, and no error is raised on overflow.
Examples
>>> a = np.array([1,2,3]) # doctest: +SKIP >>> np.cumprod(a) # intermediate results 1, 1*2 # doctest: +SKIP ... # total product 1*2*3 = 6 array([1, 2, 6]) >>> a = np.array([[1, 2, 3], [4, 5, 6]]) # doctest: +SKIP >>> np.cumprod(a, dtype=float) # specify type of output # doctest: +SKIP array([ 1., 2., 6., 24., 120., 720.])
The cumulative product for each column (i.e., over the rows) of a:
>>> np.cumprod(a, axis=0) # doctest: +SKIP array([[ 1, 2, 3], [ 4, 10, 18]])
The cumulative product for each row (i.e. over the columns) of a:
>>> np.cumprod(a,axis=1) # doctest: +SKIP array([[ 1, 2, 6], [ 4, 20, 120]])

dask.array.
cumsum
(x, axis=None, dtype=None, out=None, method='sequential')[source]¶ Return the cumulative sum of the elements along a given axis.
This docstring was copied from numpy.cumsum.
Some inconsistencies with the Dask version may exist.
Dask added an additional keywordonly argument
method
. method : {‘sequential’, ‘blelloch’}, optional
Choose which method to use to perform the cumsum. Default is ‘sequential’.
 ‘sequential’ performs the cumsum of each prior block before the current block.
 ‘blelloch’ is a workefficient parallel cumsum. It exposes parallelism by first taking the sum of each block and combines the sums via a binary tree. This method may be faster or more memory efficient depending on workload, scheduler, and hardware. More benchmarking is necessary.
Parameters:  a : array_like (Not supported in Dask)
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 Output type determination 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 1d array.
See also
Notes
Arithmetic is modular when using integer types, and no error is raised on overflow.
Examples
>>> a = np.array([[1,2,3], [4,5,6]]) # doctest: +SKIP >>> a # doctest: +SKIP array([[1, 2, 3], [4, 5, 6]]) >>> np.cumsum(a) # doctest: +SKIP array([ 1, 3, 6, 10, 15, 21]) >>> np.cumsum(a, dtype=float) # specifies type of output value(s) # doctest: +SKIP array([ 1., 3., 6., 10., 15., 21.])
>>> np.cumsum(a,axis=0) # sum over rows for each of the 3 columns # doctest: +SKIP array([[1, 2, 3], [5, 7, 9]]) >>> np.cumsum(a,axis=1) # sum over columns for each of the 2 rows # doctest: +SKIP array([[ 1, 3, 6], [ 4, 9, 15]])

dask.array.
deg2rad
(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.deg2rad.
Some inconsistencies with the Dask version may exist.
Convert angles from degrees to radians.
Parameters:  x : array_like
Angles in degrees.
 out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  y : ndarray
The corresponding angle in radians. This is a scalar if x is a scalar.
See also
rad2deg
 Convert angles from radians to degrees.
unwrap
 Remove large jumps in angle by wrapping.
Notes
New in version 1.3.0.
deg2rad(x)
isx * pi / 180
.Examples
>>> np.deg2rad(180) # doctest: +SKIP 3.1415926535897931

dask.array.
degrees
(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.degrees.
Some inconsistencies with the Dask version may exist.
Convert angles from radians to degrees.
Parameters:  x : array_like
Input array in radians.
 out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  y : ndarray of floats
The corresponding degree values; if out was supplied this is a reference to it. This is a scalar if x is a scalar.
See also
rad2deg
 equivalent function
Examples
Convert a radian array to degrees
>>> rad = np.arange(12.)*np.pi/6 # doctest: +SKIP >>> np.degrees(rad) # doctest: +SKIP array([ 0., 30., 60., 90., 120., 150., 180., 210., 240., 270., 300., 330.])
>>> out = np.zeros((rad.shape)) # doctest: +SKIP >>> r = np.degrees(rad, out) # doctest: +SKIP >>> np.all(r == out) # doctest: +SKIP True

dask.array.
diag
(v)[source]¶ Extract a diagonal or construct a diagonal array.
This docstring was copied from numpy.diag.
Some inconsistencies with the Dask 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 2D array, return a copy of its kth diagonal. If v is a 1D array, return a 2D array with v on the kth diagonal.
 k : int, optional (Not supported in Dask)
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 : ndarray
The extracted diagonal or constructed diagonal array.
See also
Examples
>>> x = np.arange(9).reshape((3,3)) # doctest: +SKIP >>> x # doctest: +SKIP array([[0, 1, 2], [3, 4, 5], [6, 7, 8]])
>>> np.diag(x) # doctest: +SKIP array([0, 4, 8]) >>> np.diag(x, k=1) # doctest: +SKIP array([1, 5]) >>> np.diag(x, k=1) # doctest: +SKIP array([3, 7])
>>> np.diag(np.diag(x)) # doctest: +SKIP array([[0, 0, 0], [0, 4, 0], [0, 0, 8]])

dask.array.
diagonal
(a, offset=0, axis1=0, axis2=1)[source]¶ Return specified diagonals.
This docstring was copied from numpy.diagonal.
Some inconsistencies with the Dask version may exist.
If a is 2D, 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 2D subarray 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 readonly 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 justnp.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 2D subarrays 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 2D subarrays from which the diagonals should be taken. Defaults to second axis (1).
Returns:  array_of_diagonals : ndarray
If a is 2D, then a 1D array containing the diagonal and of the same type as a is returned unless a is a matrix, in which case a 1D array rather than a (2D) 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.
Raises:  ValueError
If the dimension of a is less than 2.
See also
diag
 MATLAB workalike for 1D and 2D arrays.
diagflat
 Create diagonal arrays.
trace
 Sum along diagonals.
Examples
>>> a = np.arange(4).reshape(2,2) # doctest: +SKIP >>> a # doctest: +SKIP array([[0, 1], [2, 3]]) >>> a.diagonal() # doctest: +SKIP array([0, 3]) >>> a.diagonal(1) # doctest: +SKIP array([1])
A 3D example:
>>> a = np.arange(8).reshape(2,2,2); a # doctest: +SKIP array([[[0, 1], [2, 3]], [[4, 5], [6, 7]]]) >>> a.diagonal(0, # Main diagonals of two arrays created by skipping # doctest: +SKIP ... 0, # across the outer(left)most axis last and ... 1) # the "middle" (row) axis first. array([[0, 6], [1, 7]])
The subarrays whose main diagonals we just obtained; note that each corresponds to fixing the rightmost (column) axis, and that the diagonals are “packed” in rows.
>>> a[:,:,0] # main diagonal is [0 6] # doctest: +SKIP array([[0, 2], [4, 6]]) >>> a[:,:,1] # main diagonal is [1 7] # doctest: +SKIP array([[1, 3], [5, 7]])
The antidiagonal can be obtained by reversing the order of elements using either numpy.flipud or numpy.fliplr.
>>> a = np.arange(9).reshape(3, 3) # doctest: +SKIP >>> a # doctest: +SKIP array([[0, 1, 2], [3, 4, 5], [6, 7, 8]]) >>> np.fliplr(a).diagonal() # Horizontal flip # doctest: +SKIP array([2, 4, 6]) >>> np.flipud(a).diagonal() # Vertical flip # doctest: +SKIP array([6, 4, 2])
Note that the order in which the diagonal is retrieved varies depending on the flip function.

dask.array.
diff
(a, n=1, axis=1)[source]¶ Calculate the nth discrete difference along the given axis.
This docstring was copied from numpy.diff.
Some inconsistencies with the Dask 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 asis.
 axis : int, optional
The axis along which the difference is taken, default is the last axis.
 prepend, append : array_like, optional
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 : ndarray
The nth 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.
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) # doctest: +SKIP >>> np.diff(u8_arr) # doctest: +SKIP array([255], dtype=uint8) >>> u8_arr[1,...]  u8_arr[0,...] # doctest: +SKIP 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) # doctest: +SKIP >>> np.diff(i16_arr) # doctest: +SKIP array([1], dtype=int16)
Examples
>>> x = np.array([1, 2, 4, 7, 0]) # doctest: +SKIP >>> np.diff(x) # doctest: +SKIP array([ 1, 2, 3, 7]) >>> np.diff(x, n=2) # doctest: +SKIP array([ 1, 1, 10])
>>> x = np.array([[1, 3, 6, 10], [0, 5, 6, 8]]) # doctest: +SKIP >>> np.diff(x) # doctest: +SKIP array([[2, 3, 4], [5, 1, 2]]) >>> np.diff(x, axis=0) # doctest: +SKIP array([[1, 2, 0, 2]])
>>> x = np.arange('10661013', '10661016', dtype=np.datetime64) # doctest: +SKIP >>> np.diff(x) # doctest: +SKIP array([1, 1], dtype='timedelta64[D]')

dask.array.
digitize
(a, bins, right=False)[source]¶ 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 Dask version may exist.
right order of bins returned index i satisfies False
increasing bins[i1] <= x < bins[i]
True
increasing bins[i1] < x <= bins[i]
False
decreasing bins[i1] > x >= bins[i]
True
decreasing bins[i1] >= 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 (Not supported in Dask)
Input array to be binned. Prior to NumPy 1.10.0, this array had to be 1dimensional, but can now have any shape.
 bins : array_like
Array of bins. It has to be 1dimensional 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[i1] <= x < bins[i] is the default behavior for monotonically increasing bins.
Returns:  indices : ndarray of ints
Output array of indices, of same shape as x.
Raises:  ValueError
If bins is not monotonic.
 TypeError
If the type of the input is complex.
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 1dimensional.
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.
Examples
>>> x = np.array([0.2, 6.4, 3.0, 1.6]) # doctest: +SKIP >>> bins = np.array([0.0, 1.0, 2.5, 4.0, 10.0]) # doctest: +SKIP >>> inds = np.digitize(x, bins) # doctest: +SKIP >>> inds # doctest: +SKIP array([1, 4, 3, 2]) >>> for n in range(x.size): # doctest: +SKIP ... print(bins[inds[n]1], "<=", x[n], "<", bins[inds[n]]) ... 0.0 <= 0.2 < 1.0 4.0 <= 6.4 < 10.0 2.5 <= 3.0 < 4.0 1.0 <= 1.6 < 2.5
>>> x = np.array([1.2, 10.0, 12.4, 15.5, 20.]) # doctest: +SKIP >>> bins = np.array([0, 5, 10, 15, 20]) # doctest: +SKIP >>> np.digitize(x,bins,right=True) # doctest: +SKIP array([1, 2, 3, 4, 4]) >>> np.digitize(x,bins,right=False) # doctest: +SKIP array([1, 3, 3, 4, 5])

dask.array.
dot
(a, b, out=None)[source]¶ This docstring was copied from numpy.dot.
Some inconsistencies with the Dask version may exist.
Dot product of two arrays. Specifically,
If both a and b are 1D arrays, it is inner product of vectors (without complex conjugation).
If both a and b are 2D arrays, it is matrix multiplication, but using
matmul()
ora @ b
is preferred.If either a or b is 0D (scalar), it is equivalent to
multiply()
and usingnumpy.multiply(a, b)
ora * b
is preferred.If a is an ND array and b is a 1D array, it is a sum product over the last axis of a and b.
If a is an ND array and b is an MD array (where
M>=2
), it is a sum product over the last axis of a and the secondtolast 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 Ccontiguous, 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 : ndarray
Returns the dot product of a and b. If a and b are both scalars or both 1D arrays then a scalar is returned; otherwise an array is returned. If out is given, then it is returned.
Raises:  ValueError
If the last dimension of a is not the same size as the secondtolast dimension of b.
See also
Examples
>>> np.dot(3, 4) # doctest: +SKIP 12
Neither argument is complexconjugated:
>>> np.dot([2j, 3j], [2j, 3j]) # doctest: +SKIP (13+0j)
For 2D arrays it is the matrix product:
>>> a = [[1, 0], [0, 1]] # doctest: +SKIP >>> b = [[4, 1], [2, 2]] # doctest: +SKIP >>> np.dot(a, b) # doctest: +SKIP array([[4, 1], [2, 2]])
>>> a = np.arange(3*4*5*6).reshape((3,4,5,6)) # doctest: +SKIP >>> b = np.arange(3*4*5*6)[::1].reshape((5,4,6,3)) # doctest: +SKIP >>> np.dot(a, b)[2,3,2,1,2,2] # doctest: +SKIP 499128 >>> sum(a[2,3,2,:] * b[1,2,:,2]) # doctest: +SKIP 499128

dask.array.
dstack
(tup, allow_unknown_chunksizes=False)[source]¶ Stack arrays in sequence depth wise (along third axis).
This docstring was copied from numpy.dstack.
Some inconsistencies with the Dask version may exist.
This is equivalent to concatenation along the third axis after 2D arrays of shape (M,N) have been reshaped to (M,N,1) and 1D 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 pixeldata 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. 1D or 2D arrays must have the same shape.
Returns:  stacked : ndarray
The array formed by stacking the given arrays, will be at least 3D.
See also
concatenate
 Join a sequence of arrays along an existing axis.
stack
 Join a sequence of arrays along a new axis.
block
 Assemble an ndarray from nested lists of blocks.
vstack
 Stack arrays in sequence vertically (row wise).
hstack
 Stack arrays in sequence horizontally (column wise).
column_stack
 Stack 1D arrays as columns into a 2D array.
dsplit
 Split array along third axis.
Examples
>>> a = np.array((1,2,3)) # doctest: +SKIP >>> b = np.array((2,3,4)) # doctest: +SKIP >>> np.dstack((a,b)) # doctest: +SKIP array([[[1, 2], [2, 3], [3, 4]]])
>>> a = np.array([[1],[2],[3]]) # doctest: +SKIP >>> b = np.array([[2],[3],[4]]) # doctest: +SKIP >>> np.dstack((a,b)) # doctest: +SKIP array([[[1, 2]], [[2, 3]], [[3, 4]]])

dask.array.
ediff1d
(ary, to_end=None, to_begin=None)[source]¶ The differences between consecutive elements of an array.
This docstring was copied from numpy.ediff1d.
Some inconsistencies with the Dask 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 : ndarray
The differences. Loosely, this is
ary.flat[1:]  ary.flat[:1]
.
Notes
When applied to masked arrays, this function drops the mask information if the to_begin and/or to_end parameters are used.
Examples
>>> x = np.array([1, 2, 4, 7, 0]) # doctest: +SKIP >>> np.ediff1d(x) # doctest: +SKIP array([ 1, 2, 3, 7])
>>> np.ediff1d(x, to_begin=99, to_end=np.array([88, 99])) # doctest: +SKIP array([99, 1, 2, ..., 7, 88, 99])
The returned array is always 1D.
>>> y = [[1, 2, 4], [1, 6, 24]] # doctest: +SKIP >>> np.ediff1d(y) # doctest: +SKIP array([ 1, 2, 3, 5, 18])

dask.array.
empty
(*args, **kwargs)¶ Blocked variant of empty
Follows the signature of empty exactly except that it also features optional keyword arguments
chunks: int, tuple, or dict
andname: str
.Original signature follows below.
Return
np.empty_like(a, shape=shape, **kwargs)
if the shape argument is supported (requires NumPy >= 1.17), otherwise falls back to using the old behavior, returningnp.empty(shape, **kwargs)
.

dask.array.
empty_like
(a, dtype=None, order='C', chunks=None, name=None, shape=None)[source]¶ Return a new array with the same shape and type as a given array.
Parameters:  a : array_like
The shape and datatype of a define these same attributes of the returned array.
 dtype : datatype, optional
Overrides the data type of the result.
 order : {‘C’, ‘F’}, optional
Whether to store multidimensional data in C or Fortrancontiguous (row or columnwise) order in memory.
 chunks : sequence of ints
The number of samples on each block. Note that the last block will have fewer samples if
len(array) % chunks != 0
. name : str, optional
An optional keyname for the array. Defaults to hashing the input keyword arguments.
 shape : int or sequence of ints, optional.
Overrides the shape of the result.
Returns:  out : ndarray
Array of uninitialized (arbitrary) data with the same shape and type as a.
See also
ones_like
 Return an array of ones with shape and type of input.
zeros_like
 Return an array of zeros with shape and type of input.
empty
 Return a new uninitialized array.
ones
 Return a new array setting values to one.
zeros
 Return a new array setting values to zero.
Notes
This function does not initialize the returned array; to do that use zeros_like or ones_like instead. It may be marginally faster than the functions that do set the array values.

dask.array.
equal
(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.equal.
Some inconsistencies with the Dask version may exist.
Return (x1 == x2) elementwise.
Parameters:  x1, x2 : array_like
Input arrays. If
x1.shape != x2.shape
, they must be broadcastable to a common shape (which becomes the shape of the output). out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  out : ndarray or scalar
Output array, elementwise 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.
See also
not_equal
,greater_equal
,less_equal
,greater
,less
Examples
>>> np.equal([0, 1, 3], np.arange(3)) # doctest: +SKIP array([ True, True, False])
What is compared are values, not types. So an int (1) and an array of length one can evaluate as True:
>>> np.equal(1, np.ones(1)) # doctest: +SKIP array([ True])
The
==
operator can be used as a shorthand fornp.equal
on ndarrays.>>> a = np.array([2, 4, 6]) # doctest: +SKIP >>> b = np.array([2, 4, 2]) # doctest: +SKIP >>> a == b # doctest: +SKIP array([ True, True, False])

dask.array.
einsum
(subscripts, *operands, out=None, dtype=None, order='K', casting='safe', optimize=False)[source]¶ This docstring was copied from numpy.einsum.
Some inconsistencies with the Dask version may exist.
Evaluates the Einstein summation convention on the operands.
Using the Einstein summation convention, many common multidimensional, 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 (Not supported in Dask)
If provided, the calculation is done into this array.
 dtype : {datatype, 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 byteorder 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 (Not supported in Dask)
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. Seenp.einsum_path
for more details. Defaults to False.
Returns:  output : ndarray
The calculation based on the Einstein summation convention.
See also
einsum_path
,dot
,inner
,outer
,tensordot
,linalg.multi_dot
einops
 similar verbose interface is provided by einops package to cover additional operations: transpose, reshape/flatten, repeat/tile, squeeze/unsqueeze and reductions.
opt_einsum
 opt_einsum optimizes contraction order for einsumlike expressions in backendagnostic manner.
Notes
New in version 1.6.0.
The Einstein summation convention can be used to compute many multidimensional, linear algebraic array operations. einsum provides a succinct way of representing these.
A nonexhaustive 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, elementwise and scalar multiplication,
numpy.multiply()
.  Tensor contractions,
numpy.tensordot()
.  Chained array operations, in efficient calculation order,
numpy.einsum_path()
.
The subscripts string is a commaseparated 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 tonp.inner(a,b)
. If a label appears only once, it is not summed, sonp.einsum('i', a)
produces a view ofa
with no changes. A further examplenp.einsum('ij,jk', a, b)
describes traditional matrix multiplication and is equivalent tonp.matmul(a,b)
. Repeated subscript labels in one operand take the diagonal. For example,np.einsum('ii', a)
is equivalent tonp.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, whilenp.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 likenp.sum(a, axis=1)
, andnp.einsum('ii>i', a)
is likenp.diag(a)
. The difference is that einsum does not allow broadcasting by default. Additionallynp.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 NumPystyle 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 donp.einsum('i...i', a)
, or to do a matrixmatrix product with the leftmost indices instead of rightmost, one can donp.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 asnp.swapaxes(a, 0, 2)
andnp.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.Examples
>>> a = np.arange(25).reshape(5,5) # doctest: +SKIP >>> b = np.arange(5) # doctest: +SKIP >>> c = np.arange(6).reshape(2,3) # doctest: +SKIP
Trace of a matrix:
>>> np.einsum('ii', a) # doctest: +SKIP 60 >>> np.einsum(a, [0,0]) # doctest: +SKIP 60 >>> np.trace(a) # doctest: +SKIP 60
Extract the diagonal (requires explicit form):
>>> np.einsum('ii>i', a) # doctest: +SKIP array([ 0, 6, 12, 18, 24]) >>> np.einsum(a, [0,0], [0]) # doctest: +SKIP array([ 0, 6, 12, 18, 24]) >>> np.diag(a) # doctest: +SKIP array([ 0, 6, 12, 18, 24])
Sum over an axis (requires explicit form):
>>> np.einsum('ij>i', a) # doctest: +SKIP array([ 10, 35, 60, 85, 110]) >>> np.einsum(a, [0,1], [0]) # doctest: +SKIP array([ 10, 35, 60, 85, 110]) >>> np.sum(a, axis=1) # doctest: +SKIP array([ 10, 35, 60, 85, 110])
For higher dimensional arrays summing a single axis can be done with ellipsis:
>>> np.einsum('...j>...', a) # doctest: +SKIP array([ 10, 35, 60, 85, 110]) >>> np.einsum(a, [Ellipsis,1], [Ellipsis]) # doctest: +SKIP array([ 10, 35, 60, 85, 110])
Compute a matrix transpose, or reorder any number of axes:
>>> np.einsum('ji', c) # doctest: +SKIP array([[0, 3], [1, 4], [2, 5]]) >>> np.einsum('ij>ji', c) # doctest: +SKIP array([[0, 3], [1, 4], [2, 5]]) >>> np.einsum(c, [1,0]) # doctest: +SKIP array([[0, 3], [1, 4], [2, 5]]) >>> np.transpose(c) # doctest: +SKIP array([[0, 3], [1, 4], [2, 5]])
Vector inner products:
>>> np.einsum('i,i', b, b) # doctest: +SKIP 30 >>> np.einsum(b, [0], b, [0]) # doctest: +SKIP 30 >>> np.inner(b,b) # doctest: +SKIP 30
Matrix vector multiplication:
>>> np.einsum('ij,j', a, b) # doctest: +SKIP array([ 30, 80, 130, 180, 230]) >>> np.einsum(a, [0,1], b, [1]) # doctest: +SKIP array([ 30, 80, 130, 180, 230]) >>> np.dot(a, b) # doctest: +SKIP array([ 30, 80, 130, 180, 230]) >>> np.einsum('...j,j', a, b) # doctest: +SKIP array([ 30, 80, 130, 180, 230])
Broadcasting and scalar multiplication:
>>> np.einsum('..., ...', 3, c) # doctest: +SKIP array([[ 0, 3, 6], [ 9, 12, 15]]) >>> np.einsum(',ij', 3, c) # doctest: +SKIP array([[ 0, 3, 6], [ 9, 12, 15]]) >>> np.einsum(3, [Ellipsis], c, [Ellipsis]) # doctest: +SKIP array([[ 0, 3, 6], [ 9, 12, 15]]) >>> np.multiply(3, c) # doctest: +SKIP array([[ 0, 3, 6], [ 9, 12, 15]])
Vector outer product:
>>> np.einsum('i,j', np.arange(2)+1, b) # doctest: +SKIP array([[0, 1, 2, 3, 4], [0, 2, 4, 6, 8]]) >>> np.einsum(np.arange(2)+1, [0], b, [1]) # doctest: +SKIP array([[0, 1, 2, 3, 4], [0, 2, 4, 6, 8]]) >>> np.outer(np.arange(2)+1, b) # doctest: +SKIP array([[0, 1, 2, 3, 4], [0, 2, 4, 6, 8]])
Tensor contraction:
>>> a = np.arange(60.).reshape(3,4,5) # doctest: +SKIP >>> b = np.arange(24.).reshape(4,3,2) # doctest: +SKIP >>> np.einsum('ijk,jil>kl', a, b) # doctest: +SKIP array([[4400., 4730.], [4532., 4874.], [4664., 5018.], [4796., 5162.], [4928., 5306.]]) >>> np.einsum(a, [0,1,2], b, [1,0,3], [2,3]) # doctest: +SKIP array([[4400., 4730.], [4532., 4874.], [4664., 5018.], [4796., 5162.], [4928., 5306.]]) >>> np.tensordot(a,b, axes=([1,0],[0,1])) # doctest: +SKIP array([[4400., 4730.], [4532., 4874.], [4664., 5018.], [4796., 5162.], [4928., 5306.]])
Writeable returned arrays (since version 1.10.0):
>>> a = np.zeros((3, 3)) # doctest: +SKIP >>> np.einsum('ii>i', a)[:] = 1 # doctest: +SKIP >>> a # doctest: +SKIP array([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]])
Example of ellipsis use:
>>> a = np.arange(6).reshape((3,2)) # doctest: +SKIP >>> b = np.arange(12).reshape((4,3)) # doctest: +SKIP >>> np.einsum('ki,jk>ij', a, b) # doctest: +SKIP array([[10, 28, 46, 64], [13, 40, 67, 94]]) >>> np.einsum('ki,...k>i...', a, b) # doctest: +SKIP array([[10, 28, 46, 64], [13, 40, 67, 94]]) >>> np.einsum('k...,jk', a, b) # doctest: +SKIP array([[10, 28, 46, 64], [13, 40, 67, 94]])
Chained array operations. For more complicated contractions, speed ups might be achieved by repeatedly computing a ‘greedy’ path or precomputing the ‘optimal’ path and repeatedly applying it, using an einsum_path insertion (since version 1.12.0). Performance improvements can be particularly significant with larger arrays:
>>> a = np.ones(64).reshape(2,4,8) # doctest: +SKIP
Basic einsum: ~1520ms (benchmarked on 3.1GHz Intel i5.)
>>> for iteration in range(500): # doctest: +SKIP ... _ = np.einsum('ijk,ilm,njm,nlk,abc>',a,a,a,a,a)
Suboptimal einsum (due to repeated path calculation time): ~330ms
>>> for iteration in range(500): # doctest: +SKIP ... _ = np.einsum('ijk,ilm,njm,nlk,abc>',a,a,a,a,a, optimize='optimal')
Greedy einsum (faster optimal path approximation): ~160ms
>>> for iteration in range(500): # doctest: +SKIP ... _ = np.einsum('ijk,ilm,njm,nlk,abc>',a,a,a,a,a, optimize='greedy')
Optimal einsum (best usage pattern in some use cases): ~110ms
>>> path = np.einsum_path('ijk,ilm,njm,nlk,abc>',a,a,a,a,a, optimize='optimal')[0] # doctest: +SKIP >>> for iteration in range(500): # doctest: +SKIP ... _ = np.einsum('ijk,ilm,njm,nlk,abc>',a,a,a,a,a, optimize=path)

dask.array.
exp
(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.exp.
Some inconsistencies with the Dask version may exist.
Calculate the exponential of all elements in the input array.
Parameters:  x : array_like
Input values.
 out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  out : ndarray or scalar
Output array, elementwise exponential of x. This is a scalar if x is a scalar.
See also
Notes
The irrational number
e
is also known as Euler’s number. It is approximately 2.718281, and is the base of the natural logarithm,ln
(this means that, if \(x = \ln y = \log_e y\), then \(e^x = y\). For real input,exp(x)
is always positive.For complex arguments,
x = a + ib
, we can write \(e^x = e^a e^{ib}\). The first term, \(e^a\), is already known (it is the real argument, described above). The second term, \(e^{ib}\), is \(\cos b + i \sin b\), a function with magnitude 1 and a periodic phase.References
[1] Wikipedia, “Exponential function”, https://en.wikipedia.org/wiki/Exponential_function [2] M. Abramovitz and I. A. Stegun, “Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables,” Dover, 1964, p. 69, http://www.math.sfu.ca/~cbm/aands/page_69.htm Examples
Plot the magnitude and phase of
exp(x)
in the complex plane:>>> import matplotlib.pyplot as plt # doctest: +SKIP
>>> x = np.linspace(2*np.pi, 2*np.pi, 100) # doctest: +SKIP >>> xx = x + 1j * x[:, np.newaxis] # a + ib over complex plane # doctest: +SKIP >>> out = np.exp(xx) # doctest: +SKIP
>>> plt.subplot(121) # doctest: +SKIP >>> plt.imshow(np.abs(out), # doctest: +SKIP ... extent=[2*np.pi, 2*np.pi, 2*np.pi, 2*np.pi], cmap='gray') >>> plt.title('Magnitude of exp(x)') # doctest: +SKIP
>>> plt.subplot(122) # doctest: +SKIP >>> plt.imshow(np.angle(out), # doctest: +SKIP ... extent=[2*np.pi, 2*np.pi, 2*np.pi, 2*np.pi], cmap='hsv') >>> plt.title('Phase (angle) of exp(x)') # doctest: +SKIP >>> plt.show() # doctest: +SKIP

dask.array.
exp2
(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.exp2.
Some inconsistencies with the Dask version may exist.
Calculate 2**p for all p in the input array.
Parameters:  x : array_like
Input values.
 out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  out : ndarray or scalar
Elementwise 2 to the power x. This is a scalar if x is a scalar.
See also
Notes
New in version 1.3.0.
Examples
>>> np.exp2([2, 3]) # doctest: +SKIP array([ 4., 8.])

dask.array.
expm1
(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.expm1.
Some inconsistencies with the Dask version may exist.
Calculate
exp(x)  1
for all elements in the array.Parameters:  x : array_like
Input values.
 out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  out : ndarray or scalar
Elementwise exponential minus one:
out = exp(x)  1
. This is a scalar if x is a scalar.
See also
log1p
log(1 + x)
, the inverse of expm1.
Notes
This function provides greater precision than
exp(x)  1
for small values ofx
.Examples
The true value of
exp(1e10)  1
is1.00000000005e10
to about 32 significant digits. This example shows the superiority of expm1 in this case.>>> np.expm1(1e10) # doctest: +SKIP 1.00000000005e10 >>> np.exp(1e10)  1 # doctest: +SKIP 1.000000082740371e10

dask.array.
eye
(N, chunks='auto', M=None, k=0, dtype=<class 'float'>)[source]¶ Return a 2D Array with ones on the diagonal and zeros elsewhere.
Parameters:  N : int
Number of rows in the output.
 chunks : int, str
How to chunk the array. Must be one of the following forms:
 A blocksize like 1000.
 A size in bytes, like “100 MiB” which will choose a uniform blocklike shape
 The word “auto” which acts like the above, but uses a configuration
value
array.chunksize
for the chunk size
 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 : datatype, optional
Datatype of the returned array.
Returns:  I : Array of shape (N,M)
An array where all elements are equal to zero, except for the kth diagonal, whose values are equal to one.

dask.array.
fabs
(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.fabs.
Some inconsistencies with the Dask version may exist.
Compute the absolute values elementwise.
This function returns the absolute values (positive magnitude) of the data in x. Complex values are not handled, use absolute to find the absolute values of complex data.
Parameters:  x : array_like
The array of numbers for which the absolute values are required. If x is a scalar, the result y will also be a scalar.
 out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  y : ndarray or scalar
The absolute values of x, the returned values are always floats. This is a scalar if x is a scalar.
See also
absolute
 Absolute values including complex types.
Examples
>>> np.fabs(1) # doctest: +SKIP 1.0 >>> np.fabs([1.2, 1.2]) # doctest: +SKIP array([ 1.2, 1.2])

dask.array.
fix
(*args, **kwargs)¶ Round to nearest integer towards zero.
This docstring was copied from numpy.fix.
Some inconsistencies with the Dask version may exist.
Round an array of floats elementwise to nearest integer towards zero. The rounded values are returned as floats.
Parameters:  x : array_like (Not supported in Dask)
An array of floats to be rounded
 out : ndarray, optional
A location into which the result is stored. If provided, it must have a shape that the input broadcasts to. If not provided or None, a freshlyallocated array is returned.
Returns:  out : ndarray of floats
A float array with the same dimensions as the input. If second argument is not supplied then a float array is returned with the rounded values.
If a second argument is supplied the result is stored there. The return value out is then a reference to that array.
Examples
>>> np.fix(3.14) # doctest: +SKIP 3.0 >>> np.fix(3) # doctest: +SKIP 3.0 >>> np.fix([2.1, 2.9, 2.1, 2.9]) # doctest: +SKIP array([ 2., 2., 2., 2.])

dask.array.
flatnonzero
(a)[source]¶ Return indices that are nonzero in the flattened version of a.
This docstring was copied from numpy.flatnonzero.
Some inconsistencies with the Dask version may exist.
This is equivalent to np.nonzero(np.ravel(a))[0].
Parameters:  a : array_like
Input data.
Returns:  res : ndarray
Output array, containing the indices of the elements of a.ravel() that are nonzero.
See also
Examples
>>> x = np.arange(2, 3) # doctest: +SKIP >>> x # doctest: +SKIP array([2, 1, 0, 1, 2]) >>> np.flatnonzero(x) # doctest: +SKIP array([0, 1, 3, 4])
Use the indices of the nonzero elements as an index array to extract these elements:
>>> x.ravel()[np.flatnonzero(x)] # doctest: +SKIP array([2, 1, 1, 2])

dask.array.
flip
(m, axis)[source]¶ Reverse element order along axis.
Parameters:  axis : int
Axis to reverse element order of.
Returns:  reversed array : ndarray

dask.array.
flipud
(m)[source]¶ Flip array in the up/down direction.
This docstring was copied from numpy.flipud.
Some inconsistencies with the Dask version may exist.
Flip the entries in each column in the up/down direction. Rows are preserved, but appear in a different order than before.
Parameters:  m : array_like
Input array.
Returns:  out : array_like
A view of m with the rows reversed. Since a view is returned, this operation is \(\mathcal O(1)\).
Notes
Equivalent to
m[::1,...]
. Does not require the array to be twodimensional.Examples
>>> A = np.diag([1.0, 2, 3]) # doctest: +SKIP >>> A # doctest: +SKIP array([[1., 0., 0.], [0., 2., 0.], [0., 0., 3.]]) >>> np.flipud(A) # doctest: +SKIP array([[0., 0., 3.], [0., 2., 0.], [1., 0., 0.]])
>>> A = np.random.randn(2,3,5) # doctest: +SKIP >>> np.all(np.flipud(A) == A[::1,...]) # doctest: +SKIP True
>>> np.flipud([1,2]) # doctest: +SKIP array([2, 1])

dask.array.
fliplr
(m)[source]¶ Flip array in the left/right direction.
This docstring was copied from numpy.fliplr.
Some inconsistencies with the Dask version may exist.
Flip the entries in each row in the left/right direction. Columns are preserved, but appear in a different order than before.
Parameters:  m : array_like
Input array, must be at least 2D.
Returns:  f : ndarray
A view of m with the columns reversed. Since a view is returned, this operation is \(\mathcal O(1)\).
Notes
Equivalent to m[:,::1]. Requires the array to be at least 2D.
Examples
>>> A = np.diag([1.,2.,3.]) # doctest: +SKIP >>> A # doctest: +SKIP array([[1., 0., 0.], [0., 2., 0.], [0., 0., 3.]]) >>> np.fliplr(A) # doctest: +SKIP array([[0., 0., 1.], [0., 2., 0.], [3., 0., 0.]])
>>> A = np.random.randn(2,3,5) # doctest: +SKIP >>> np.all(np.fliplr(A) == A[:,::1,...]) # doctest: +SKIP True

dask.array.
float_power
(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.float_power.
Some inconsistencies with the Dask version may exist.
First array elements raised to powers from second array, elementwise.
Raise each base in x1 to the positionallycorresponding power in x2. x1 and x2 must be broadcastable to the same shape. This differs from the power function in that integers, float16, and float32 are promoted to floats with a minimum precision of float64 so that the result is always inexact. The intent is that the function will return a usable result for negative powers and seldom overflow for positive powers.
New in version 1.12.0.
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). out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  y : ndarray
The bases in x1 raised to the exponents in x2. This is a scalar if both x1 and x2 are scalars.
See also
power
 power function that preserves type
Examples
Cube each element in a list.
>>> x1 = range(6) # doctest: +SKIP >>> x1 # doctest: +SKIP [0, 1, 2, 3, 4, 5] >>> np.float_power(x1, 3) # doctest: +SKIP array([ 0., 1., 8., 27., 64., 125.])
Raise the bases to different exponents.
>>> x2 = [1.0, 2.0, 3.0, 3.0, 2.0, 1.0] # doctest: +SKIP >>> np.float_power(x1, x2) # doctest: +SKIP array([ 0., 1., 8., 27., 16., 5.])
The effect of broadcasting.
>>> x2 = np.array([[1, 2, 3, 3, 2, 1], [1, 2, 3, 3, 2, 1]]) # doctest: +SKIP >>> x2 # doctest: +SKIP array([[1, 2, 3, 3, 2, 1], [1, 2, 3, 3, 2, 1]]) >>> np.float_power(x1, x2) # doctest: +SKIP array([[ 0., 1., 8., 27., 16., 5.], [ 0., 1., 8., 27., 16., 5.]])

dask.array.
floor
(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.floor.
Some inconsistencies with the Dask version may exist.
Return the floor of the input, elementwise.
The floor of the scalar x is the largest integer i, such that i <= x. It is often denoted as \(\lfloor x \rfloor\).
Parameters:  x : array_like
Input data.
 out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  y : ndarray or scalar
The floor of each element in x. This is a scalar if x is a scalar.
Notes
Some spreadsheet programs calculate the “floortowardszero”, in other words
floor(2.5) == 2
. NumPy instead uses the definition of floor where floor(2.5) == 3.Examples
>>> a = np.array([1.7, 1.5, 0.2, 0.2, 1.5, 1.7, 2.0]) # doctest: +SKIP >>> np.floor(a) # doctest: +SKIP array([2., 2., 1., 0., 1., 1., 2.])

dask.array.
floor_divide
(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.floor_divide.
Some inconsistencies with the Dask version may exist.
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 thata = a % b + b * (a // b)
up to roundoff.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). out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  y : ndarray
y = floor(x1/x2) This is a scalar if both x1 and x2 are scalars.
See also
Examples
>>> np.floor_divide(7,3) # doctest: +SKIP 2 >>> np.floor_divide([1., 2., 3., 4.], 2.5) # doctest: +SKIP array([ 0., 0., 1., 1.])
The
//
operator can be used as a shorthand fornp.floor_divide
on ndarrays.>>> x1 = np.array([1., 2., 3., 4.]) # doctest: +SKIP >>> x1 // 2.5 # doctest: +SKIP array([0., 0., 1., 1.])

dask.array.
fmax
(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.fmax.
Some inconsistencies with the Dask version may exist.
Elementwise maximum of array elements.
Compare two arrays and returns a new array containing the elementwise maxima. If one of the elements being compared is a NaN, then the nonnan element is returned. If both elements are NaNs then the first is returned. The latter distinction is important for complex NaNs, which are defined as at least one of the real or imaginary parts being a NaN. The net effect is that NaNs are ignored when possible.
Parameters:  x1, x2 : array_like
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). out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  y : ndarray or scalar
The maximum of x1 and x2, elementwise. This is a scalar if both x1 and x2 are scalars.
See also
Notes
New in version 1.3.0.
The fmax is equivalent to
np.where(x1 >= x2, x1, x2)
when neither x1 nor x2 are NaNs, but it is faster and does proper broadcasting.Examples
>>> np.fmax([2, 3, 4], [1, 5, 2]) # doctest: +SKIP array([ 2., 5., 4.])
>>> np.fmax(np.eye(2), [0.5, 2]) # doctest: +SKIP array([[ 1. , 2. ], [ 0.5, 2. ]])
>>> np.fmax([np.nan, 0, np.nan],[0, np.nan, np.nan]) # doctest: +SKIP array([ 0., 0., nan])

dask.array.
fmin
(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.fmin.
Some inconsistencies with the Dask version may exist.
Elementwise minimum of array elements.
Compare two arrays and returns a new array containing the elementwise minima. If one of the elements being compared is a NaN, then the nonnan element is returned. If both elements are NaNs then the first is returned. The latter distinction is important for complex NaNs, which are defined as at least one of the real or imaginary parts being a NaN. The net effect is that NaNs are ignored when possible.
Parameters:  x1, x2 : array_like
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). out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  y : ndarray or scalar
The minimum of x1 and x2, elementwise. This is a scalar if both x1 and x2 are scalars.
See also
Notes
New in version 1.3.0.
The fmin is equivalent to
np.where(x1 <= x2, x1, x2)
when neither x1 nor x2 are NaNs, but it is faster and does proper broadcasting.Examples
>>> np.fmin([2, 3, 4], [1, 5, 2]) # doctest: +SKIP array([1, 3, 2])
>>> np.fmin(np.eye(2), [0.5, 2]) # doctest: +SKIP array([[ 0.5, 0. ], [ 0. , 1. ]])
>>> np.fmin([np.nan, 0, np.nan],[0, np.nan, np.nan]) # doctest: +SKIP array([ 0., 0., nan])

dask.array.
fmod
(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.fmod.
Some inconsistencies with the Dask version may exist.
Return the elementwise remainder of division.
This is the NumPy implementation of the C library function fmod, the remainder has the same sign as the dividend x1. It is equivalent to the Matlab(TM)
rem
function and should not be confused with the Python modulus operatorx1 % x2
.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). out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  y : array_like
The remainder of the division of x1 by x2. This is a scalar if both x1 and x2 are scalars.
See also
remainder
 Equivalent to the Python
%
operator. divide
Notes
The result of the modulo operation for negative dividend and divisors is bound by conventions. For fmod, the sign of result is the sign of the dividend, while for remainder the sign of the result is the sign of the divisor. The fmod function is equivalent to the Matlab(TM)
rem
function.Examples
>>> np.fmod([3, 2, 1, 1, 2, 3], 2) # doctest: +SKIP array([1, 0, 1, 1, 0, 1]) >>> np.remainder([3, 2, 1, 1, 2, 3], 2) # doctest: +SKIP array([1, 0, 1, 1, 0, 1])
>>> np.fmod([5, 3], [2, 2.]) # doctest: +SKIP array([ 1., 1.]) >>> a = np.arange(3, 3).reshape(3, 2) # doctest: +SKIP >>> a # doctest: +SKIP array([[3, 2], [1, 0], [ 1, 2]]) >>> np.fmod(a, [2,2]) # doctest: +SKIP array([[1, 0], [1, 0], [ 1, 0]])

dask.array.
frexp
(x, [out1, out2, ]/, [out=(None, None), ]*, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])[source]¶ This docstring was copied from numpy.frexp.
Some inconsistencies with the Dask version may exist.
Decompose the elements of x into mantissa and twos exponent.
Returns (mantissa, exponent), where x = mantissa * 2**exponent`. The mantissa is lies in the open interval(1, 1), while the twos exponent is a signed integer.
Parameters:  x : array_like
Array of numbers to be decomposed.
 out1 : ndarray, optional
Output array for the mantissa. Must have the same shape as x.
 out2 : ndarray, optional
Output array for the exponent. Must have the same shape as x.
 out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  mantissa : ndarray
Floating values between 1 and 1. This is a scalar if x is a scalar.
 exponent : ndarray
Integer exponents of 2. This is a scalar if x is a scalar.
See also
ldexp
 Compute
y = x1 * 2**x2
, the inverse of frexp.
Notes
Complex dtypes are not supported, they will raise a TypeError.
Examples
>>> x = np.arange(9) # doctest: +SKIP >>> y1, y2 = np.frexp(x) # doctest: +SKIP >>> y1 # doctest: +SKIP array([ 0. , 0.5 , 0.5 , 0.75 , 0.5 , 0.625, 0.75 , 0.875, 0.5 ]) >>> y2 # doctest: +SKIP array([0, 1, 2, 2, 3, 3, 3, 3, 4]) >>> y1 * 2**y2 # doctest: +SKIP array([ 0., 1., 2., 3., 4., 5., 6., 7., 8.])

dask.array.
fromfunction
(func, chunks='auto', shape=None, dtype=None, **kwargs)[source]¶ Construct an array by executing a function over each coordinate.
This docstring was copied from numpy.fromfunction.
Some inconsistencies with the Dask version may exist.
The resulting array therefore has a value
fn(x, y, z)
at coordinate(x, y, z)
.Parameters:  function : callable (Not supported in Dask)
The function is called with N parameters, where N is the rank of shape. Each parameter represents the coordinates of the array varying along a specific axis. For example, if shape were
(2, 2)
, then the parameters would bearray([[0, 0], [1, 1]])
andarray([[0, 1], [0, 1]])
 shape : (N,) tuple of ints
Shape of the output array, which also determines the shape of the coordinate arrays passed to function.
 dtype : datatype, optional
Datatype of the coordinate arrays passed to function. By default, dtype is float.
 like : array_like (Not supported in Dask)
Reference object to allow the creation of arrays which are not NumPy arrays. If an arraylike passed in as
like
supports the__array_function__
protocol, the result will be defined by it. In this case, it ensures the creation of an array object compatible with that passed in via this argument.Note
The
like
keyword is an experimental feature pending on acceptance of NEP 35.New in version 1.20.0.
Returns:  fromfunction : any
The result of the call to function is passed back directly. Therefore the shape of fromfunction is completely determined by function. If function returns a scalar value, the shape of fromfunction would not match the shape parameter.
Notes
Keywords other than dtype are passed to function.
Examples
>>> np.fromfunction(lambda i, j: i == j, (3, 3), dtype=int) # doctest: +SKIP array([[ True, False, False], [False, True, False], [False, False, True]])
>>> np.fromfunction(lambda i, j: i + j, (3, 3), dtype=int) # doctest: +SKIP array([[0, 1, 2], [1, 2, 3], [2, 3, 4]])

dask.array.
frompyfunc
(func, nin, nout, *[, identity])[source]¶ This docstring was copied from numpy.frompyfunc.
Some inconsistencies with the Dask version may exist.
Takes an arbitrary Python function and returns a NumPy ufunc.
Can be used, for example, to add broadcasting to a builtin Python function (see Examples section).
Parameters:  func : Python function object
An arbitrary Python function.
 nin : int
The number of input arguments.
 nout : int
The number of objects returned by func.
 identity : object, optional
The value to use for the ~numpy.ufunc.identity attribute of the resulting object. If specified, this is equivalent to setting the underlying C
identity
field toPyUFunc_IdentityValue
. If omitted, the identity is set toPyUFunc_None
. Note that this is _not_ equivalent to setting the identity toNone
, which implies the operation is reorderable.
Returns:  out : ufunc
Returns a NumPy universal function (
ufunc
) object.
See also
vectorize
 Evaluates pyfunc over input arrays using broadcasting rules of numpy.
Notes
The returned ufunc always returns PyObject arrays.
Examples
Use frompyfunc to add broadcasting to the Python function
oct
:>>> oct_array = np.frompyfunc(oct, 1, 1) # doctest: +SKIP >>> oct_array(np.array((10, 30, 100))) # doctest: +SKIP array(['0o12', '0o36', '0o144'], dtype=object) >>> np.array((oct(10), oct(30), oct(100))) # for comparison # doctest: +SKIP array(['0o12', '0o36', '0o144'], dtype='<U5')

dask.array.
full
(shape, fill_value, *args, **kwargs)[source]¶ Blocked variant of full
Follows the signature of full exactly except that it also features optional keyword arguments
chunks: int, tuple, or dict
andname: str
.Original signature follows below.
Return
np.full_like(a, fill_value, shape=shape, **kwargs)
if the shape argument is supported (requires NumPy >= 1.17), otherwise falls back to using the old behavior, returningnp.full(shape, fill_value, **kwargs)
.

dask.array.
full_like
(a, fill_value, order='C', dtype=None, chunks=None, name=None, shape=None)[source]¶ Return a full array with the same shape and type as a given array.
Parameters:  a : array_like
The shape and datatype of a define these same attributes of the returned array.
 fill_value : scalar
Fill value.
 dtype : datatype, optional
Overrides the data type of the result.
 order : {‘C’, ‘F’}, optional
Whether to store multidimensional data in C or Fortrancontiguous (row or columnwise) order in memory.
 chunks : sequence of ints
The number of samples on each block. Note that the last block will have fewer samples if
len(array) % chunks != 0
. name : str, optional
An optional keyname for the array. Defaults to hashing the input keyword arguments.
 shape : int or sequence of ints, optional.
Overrides the shape of the result.
Returns:  out : ndarray
Array of fill_value with the same shape and type as a.
See also
zeros_like
 Return an array of zeros with shape and type of input.
ones_like
 Return an array of ones with shape and type of input.
empty_like
 Return an empty array with shape and type of input.
zeros
 Return a new array setting values to zero.
ones
 Return a new array setting values to one.
empty
 Return a new uninitialized array.
full
 Fill a new array.

dask.array.
gradient
(f, *varargs, **kwargs)[source]¶ Return the gradient of an Ndimensional array.
This docstring was copied from numpy.gradient.
Some inconsistencies with the Dask version may exist.
The gradient is computed using second order accurate central differences in the interior points and either first or second order accurate onesides (forward or backwards) differences at the boundaries. The returned gradient hence has the same shape as the input array.
Parameters:  f : array_like
An Ndimensional 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:
 single scalar to specify a sample distance for all dimensions.
 N scalars to specify a constant sample distance for each dimension. i.e. dx, dy, dz, …
 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
 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 (Not supported in Dask)
Gradient is calculated using Nth order accurate differences at the boundaries. Default: 1.
New in version 1.9.1.
 axis : None or int or tuple of ints, optional (Not supported in Dask)
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 : ndarray or list of ndarray
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.
Notes
Assuming that \(f\in C^{3}\) (i.e., \(f\) has at least 3 continuous derivatives) and let \(h_{*}\) be a nonhomogeneous stepsize, we minimize the “consistency error” \(\eta_{i}\) between the true gradient and its estimate from a linear combination of the neighboring gridpoints:
\[\eta_{i} = f_{i}^{\left(1\right)}  \left[ \alpha f\left(x_{i}\right) + \beta f\left(x_{i} + h_{d}\right) + \gamma f\left(x_{i}h_{s}\right) \right]\]By substituting \(f(x_{i} + h_{d})\) and \(f(x_{i}  h_{s})\) with their Taylor series expansion, this translates into solving the following the linear system:
\[\begin{split}\left\{ \begin{array}{r} \alpha+\beta+\gamma=0 \\ \beta h_{d}\gamma h_{s}=1 \\ \beta h_{d}^{2}+\gamma h_{s}^{2}=0 \end{array} \right.\end{split}\]The resulting approximation of \(f_{i}^{(1)}\) is the following:
\[\hat f_{i}^{(1)} = \frac{ h_{s}^{2}f\left(x_{i} + h_{d}\right) + \left(h_{d}^{2}  h_{s}^{2}\right)f\left(x_{i}\right)  h_{d}^{2}f\left(x_{i}h_{s}\right)} { h_{s}h_{d}\left(h_{d} + h_{s}\right)} + \mathcal{O}\left(\frac{h_{d}h_{s}^{2} + h_{s}h_{d}^{2}}{h_{d} + h_{s}}\right)\]It is worth noting that if \(h_{s}=h_{d}\) (i.e., data are evenly spaced) we find the standard second order approximation:
\[\hat f_{i}^{(1)}= \frac{f\left(x_{i+1}\right)  f\left(x_{i1}\right)}{2h} + \mathcal{O}\left(h^{2}\right)\]With a similar procedure the forward/backward approximations used for boundaries can be derived.
References
[1] Quarteroni A., Sacco R., Saleri F. (2007) Numerical Mathematics (Texts in Applied Mathematics). New York: Springer. [2] Durran D. R. (1999) Numerical Methods for Wave Equations in Geophysical Fluid Dynamics. New York: Springer. [3] Fornberg B. (1988) Generation of Finite Difference Formulas on Arbitrarily Spaced Grids, Mathematics of Computation 51, no. 184 : 699706. PDF. Examples
>>> f = np.array([1, 2, 4, 7, 11, 16], dtype=float) # doctest: +SKIP >>> np.gradient(f) # doctest: +SKIP array([1. , 1.5, 2.5, 3.5, 4.5, 5. ]) >>> np.gradient(f, 2) # doctest: +SKIP array([0.5 , 0.75, 1.25, 1.75, 2.25, 2.5 ])
Spacing can be also specified with an array that represents the coordinates of the values F along the dimensions. For instance a uniform spacing:
>>> x = np.arange(f.size) # doctest: +SKIP >>> np.gradient(f, x) # doctest: +SKIP array([1. , 1.5, 2.5, 3.5, 4.5, 5. ])
Or a non uniform one:
>>> x = np.array([0., 1., 1.5, 3.5, 4., 6.], dtype=float) # doctest: +SKIP >>> np.gradient(f, x) # doctest: +SKIP array([1. , 3. , 3.5, 6.7, 6.9, 2.5])
For two dimensional arrays, the return will be two arrays ordered by axis. In this example the first array stands for the gradient in rows and the second one in columns direction:
>>> np.gradient(np.array([[1, 2, 6], [3, 4, 5]], dtype=float)) # doctest: +SKIP [array([[ 2., 2., 1.], [ 2., 2., 1.]]), array([[1. , 2.5, 4. ], [1. , 1. , 1. ]])]
In this example the spacing is also specified: uniform for axis=0 and non uniform for axis=1
>>> dx = 2. # doctest: +SKIP >>> y = [1., 1.5, 3.5] # doctest: +SKIP >>> np.gradient(np.array([[1, 2, 6], [3, 4, 5]], dtype=float), dx, y) # doctest: +SKIP [array([[ 1. , 1. , 0.5], [ 1. , 1. , 0.5]]), array([[2. , 2. , 2. ], [2. , 1.7, 0.5]])]
It is possible to specify how boundaries are treated using edge_order
>>> x = np.array([0, 1, 2, 3, 4]) # doctest: +SKIP >>> f = x**2 # doctest: +SKIP >>> np.gradient(f, edge_order=1) # doctest: +SKIP array([1., 2., 4., 6., 7.]) >>> np.gradient(f, edge_order=2) # doctest: +SKIP array([0., 2., 4., 6., 8.])
The axis keyword can be used to specify a subset of axes of which the gradient is calculated
>>> np.gradient(np.array([[1, 2, 6], [3, 4, 5]], dtype=float), axis=0) # doctest: +SKIP array([[ 2., 2., 1.], [ 2., 2., 1.]])

dask.array.
greater
(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.greater.
Some inconsistencies with the Dask version may exist.
Return the truth value of (x1 > x2) elementwise.
Parameters:  x1, x2 : array_like
Input arrays. If
x1.shape != x2.shape
, they must be broadcastable to a common shape (which becomes the shape of the output). out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  out : ndarray or scalar
Output array, elementwise 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.
See also
greater_equal
,less
,less_equal
,equal
,not_equal
Examples
>>> np.greater([4,2],[2,2]) # doctest: +SKIP array([ True, False])
The
>
operator can be used as a shorthand fornp.greater
on ndarrays.>>> a = np.array([4, 2]) # doctest: +SKIP >>> b = np.array([2, 2]) # doctest: +SKIP >>> a > b # doctest: +SKIP array([ True, False])

dask.array.
greater_equal
(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.greater_equal.
Some inconsistencies with the Dask version may exist.
Return the truth value of (x1 >= x2) elementwise.
Parameters:  x1, x2 : array_like
Input arrays. If
x1.shape != x2.shape
, they must be broadcastable to a common shape (which becomes the shape of the output). out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  out : bool or ndarray of bool
Output array, elementwise 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.
Examples
>>> np.greater_equal([4, 2, 1], [2, 2, 2]) # doctest: +SKIP array([ True, True, False])
The
>=
operator can be used as a shorthand fornp.greater_equal
on ndarrays.>>> a = np.array([4, 2, 1]) # doctest: +SKIP >>> b = np.array([2, 2, 2]) # doctest: +SKIP >>> a >= b # doctest: +SKIP array([ True, True, False])

dask.array.
histogram
(a, bins=None, range=None, normed=False, weights=None, density=None)[source]¶ Blocked variant of
numpy.histogram()
.Parameters:  a : dask.array.Array
Input data; the histogram is computed over the flattened array. If the
weights
argument is used, the chunks ofa
are accessed to check chunking compatibility betweena
andweights
. Ifweights
isNone
, adask.dataframe.Series
object can be passed as input data. bins : int or sequence of scalars, optional
Either an iterable specifying the
bins
or the number ofbins
and arange
argument is required as computingmin
andmax
over blocked arrays is an expensive operation that must be performed explicitly. If bins is an int, it defines the number of equalwidth 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 nonuniform bin widths. 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
This is equivalent to the
density
argument, but produces incorrect results for unequal bin widths. It should not be used. weights : dask.array.Array, optional
A dask.array.Array of weights, of the same block structure as
a
. Each value ina
only contributes its associated weight towards the bin count (instead of 1). Ifdensity
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. IfTrue
, 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 thenormed
keyword if given. Ifdensity
is True,bins
cannot be a singlenumber delayed value. It must be a concrete number, or a (possiblydelayed) array/sequence of the bin edges.
Returns:  hist : dask Array
The values of the histogram. See density and weights for a description of the possible semantics.
 bin_edges : dask Array of dtype float
Return the bin edges
(length(hist)+1)
.
Examples
Using number of bins and range:
>>> import dask.array as da >>> import numpy as np >>> x = da.from_array(np.arange(10000), chunks=10) >>> h, bins = da.histogram(x, bins=10, range=[0, 10000]) >>> bins array([ 0., 1000., 2000., 3000., 4000., 5000., 6000., 7000., 8000., 9000., 10000.]) >>> h.compute() array([1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000])
Explicitly specifying the bins:
>>> h, bins = da.histogram(x, bins=np.array([0, 5000, 10000])) >>> bins array([ 0, 5000, 10000]) >>> h.compute() array([5000, 5000])

dask.array.
histogramdd
(sample, bins, range=None, normed=None, weights=None, density=None)[source]¶ Blocked variant of
numpy.histogramdd()
.Chunking of the input data (
sample
) is only allowed along the 0th (row) axis (the axis corresponding to the total number of samples). Data chunked along the 1st axis (column) axis is not compatible with this function. If weights are used, they must be chunked along the 0th axis identically to the input sample.A proper example setup for a three dimensional histogram, where the sample shape is
(8, 3)
and weights are shape(8,)
, sample chunks would be((4, 4), (3,))
and the weights chunks would be((4, 4),)
a table of the structure:sample (8 x 3) weights chunk row x y z row w 0 0 5 6 6 0 0.5 1 8 9 2 1 0.8 2 3 3 1 2 0.3 3 2 5 6 3 0.7 1 4 3 1 1 4 0.3 5 3 2 9 5 1.3 6 8 1 5 6 0.8 7 3 5 3 7 0.7 If the sample 0th dimension and weight 0th (row) dimension are chunked differently, a
ValueError
will be raised. If coordinate groupings ((x, y, z) trios) are separated by a chunk boundry, then aValueError
will be raised. We suggest that you rechunk your data if it is of that form.The chunks property of the data (and optional weights) are used to check for compatibility with the blocked algorithm (as described above); therefore, you must call to_dask_array on a collection from
dask.dataframe
, i.e.dask.dataframe.Series
ordask.dataframe.DataFrame
.Parameters:  sample : dask.array.Array (N, D) or sequence of dask.array.Array
Multidimensional data to be histogrammed.
Note the unusual interpretation of a sample when it is a sequence of dask Arrays:
 When a (N, D) dask Array, each row is an entry in the sample (coordinate in D dimensional space).
 When a sequence of dask Arrays, each element in the sequence is the array of values for a single coordinate. This type of input will be automatically rechunked along the column axis if necessary. This may induce a runtime increase.
 bins : sequence of arrays describing bin edges, int, or sequence of ints
The bin specification.
The possible binning configurations are:
 A sequence of arrays describing the monotonically increasing bin edges along each dimension.
 A single int describing the total number of bins that will
be used in each dimension (this requires the
range
argument to be defined).  A sequence of ints describing the total number of bins to be
used in each dimension (this requires the
range
argument to be defined).
When bins are described by arrays, the rightmost edge is included. Bins described by arrays also allows for nonuniform bin widths.
 range : sequence of pairs, optional
A sequence of length D, each a (min, max) tuple giving the outer bin edges to be used if the edges are not given explicitly in
bins
. If defined, this argument is required to have an entry for each dimension. Unlikenumpy.histogramdd()
, if bins does not define bin edges, this argument is required (this function will not automatically use the min and max of of the value in a given dimension because the input data may be lazy in dask). normed : bool, optional
An alias for the density argument that behaves identically. To avoid confusion with the broken argument to histogram, density should be preferred.
 weights : dask.array.Array, optional
An array of values weighing each sample in the input data. The chunks of the weights must be identical to the chunking along the 0th (row) axis of the data sample.
 density : bool, optional
If
False
(default), the returned array represents the number of samples in each bin. IfTrue
, the returned array represents the probability density function at each bin.
See also
Examples
Computing the histogram in 5 blocks using different bin edges along each dimension:
>>> import dask.array as da >>> x = da.random.uniform(0, 1, size=(1000, 3), chunks=(200, 3)) >>> edges = [ ... np.linspace(0, 1, 5), # 4 bins in 1st dim ... np.linspace(0, 1, 6), # 5 in the 2nd ... np.linspace(0, 1, 4), # 3 in the 3rd ... ] >>> h, edges = da.histogramdd(x, bins=edges) >>> result = h.compute() >>> result.shape (4, 5, 3)
Defining the bins by total number and their ranges, along with using weights:
>>> bins = (4, 5, 3) >>> ranges = ((0, 1),) * 3 # expands to ((0, 1), (0, 1), (0, 1)) >>> w = da.random.uniform(0, 1, size=(1000,), chunks=x.chunksize[0]) >>> h, edges = da.histogramdd(x, bins=bins, range=ranges, weights=w) >>> np.isclose(h.sum().compute(), w.sum().compute()) True

dask.array.
hstack
(tup, allow_unknown_chunksizes=False)[source]¶ Stack arrays in sequence horizontally (column wise).
This docstring was copied from numpy.hstack.
Some inconsistencies with the Dask version may exist.
This is equivalent to concatenation along the second axis, except for 1D 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 pixeldata 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 1D arrays which can be any length.
Returns:  stacked : ndarray
The array formed by stacking the given arrays.
See also
concatenate
 Join a sequence of arrays along an existing axis.
stack
 Join a sequence of arrays along a new axis.
block
 Assemble an ndarray from nested lists of blocks.
vstack
 Stack arrays in sequence vertically (row wise).
dstack
 Stack arrays in sequence depth wise (along third axis).
column_stack
 Stack 1D arrays as columns into a 2D array.
hsplit
 Split an array into multiple subarrays horizontally (columnwise).
Examples
>>> a = np.array((1,2,3)) # doctest: +SKIP >>> b = np.array((2,3,4)) # doctest: +SKIP >>> np.hstack((a,b)) # doctest: +SKIP array([1, 2, 3, 2, 3, 4]) >>> a = np.array([[1],[2],[3]]) # doctest: +SKIP >>> b = np.array([[2],[3],[4]]) # doctest: +SKIP >>> np.hstack((a,b)) # doctest: +SKIP array([[1, 2], [2, 3], [3, 4]])

dask.array.
hypot
(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.hypot.
Some inconsistencies with the Dask version may exist.
Given the “legs” of a right triangle, return its hypotenuse.
Equivalent to
sqrt(x1**2 + x2**2)
, elementwise. If x1 or x2 is scalar_like (i.e., unambiguously castable to a scalar type), it is broadcast for use with each element of the other argument. (See Examples)Parameters:  x1, x2 : array_like
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). out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  z : ndarray
The hypotenuse of the triangle(s). This is a scalar if both x1 and x2 are scalars.
Examples
>>> np.hypot(3*np.ones((3, 3)), 4*np.ones((3, 3))) # doctest: +SKIP array([[ 5., 5., 5.], [ 5., 5., 5.], [ 5., 5., 5.]])
Example showing broadcast of scalar_like argument:
>>> np.hypot(3*np.ones((3, 3)), [4]) # doctest: +SKIP array([[ 5., 5., 5.], [ 5., 5., 5.], [ 5., 5., 5.]])

dask.array.
imag
(*args, **kwargs)¶ Return the imaginary part of the complex argument.
This docstring was copied from numpy.imag.
Some inconsistencies with the Dask version may exist.
Parameters:  val : array_like (Not supported in Dask)
Input array.
Returns:  out : ndarray or scalar
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.
Examples
>>> a = np.array([1+2j, 3+4j, 5+6j]) # doctest: +SKIP >>> a.imag # doctest: +SKIP array([2., 4., 6.]) >>> a.imag = np.array([8, 10, 12]) # doctest: +SKIP >>> a # doctest: +SKIP array([1. +8.j, 3.+10.j, 5.+12.j]) >>> np.imag(1 + 1j) # doctest: +SKIP 1.0

dask.array.
indices
(dimensions, dtype=<class 'int'>, chunks='auto')[source]¶ Implements NumPy’s
indices
for Dask Arrays.Generates a grid of indices covering the dimensions provided.
The final array has the shape
(len(dimensions), *dimensions)
. The chunks are used to specify the chunking for axis 1 up tolen(dimensions)
. The 0th axis always has chunks of length 1.Parameters:  dimensions : sequence of ints
The shape of the index grid.
 dtype : dtype, optional
Type to use for the array. Default is
int
. chunks : sequence of ints, str
The size of each block. Must be one of the following forms:
 A blocksize like (500, 1000)
 A size in bytes, like “100 MiB” which will choose a uniform blocklike shape
 The word “auto” which acts like the above, but uses a configuration
value
array.chunksize
for the chunk size
Note that the last block will have fewer samples if
len(array) % chunks != 0
.
Returns:  grid : dask array

dask.array.
insert
(arr, obj, values, axis)[source]¶ Insert values along the given axis before the given indices.
This docstring was copied from numpy.insert.
Some inconsistencies with the Dask 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 : ndarray
A copy of arr with values inserted. Note that insert does not occur inplace: a new array is returned. If axis is None, out is a flattened array.
See also
append
 Append elements at the end of an array.
concatenate
 Join a sequence of arrays along an existing axis.
delete
 Delete elements from an array.
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.
Examples
>>> a = np.array([[1, 1], [2, 2], [3, 3]]) # doctest: +SKIP >>> a # doctest: +SKIP array([[1, 1], [2, 2], [3, 3]]) >>> np.insert(a, 1, 5) # doctest: +SKIP array([1, 5, 1, ..., 2, 3, 3]) >>> np.insert(a, 1, 5, axis=1) # doctest: +SKIP array([[1, 5, 1], [2, 5, 2], [3, 5, 3]])
Difference between sequence and scalars:
>>> np.insert(a, [1], [[1],[2],[3]], axis=1) # doctest: +SKIP array([[1, 1, 1], [2, 2, 2], [3, 3, 3]]) >>> np.array_equal(np.insert(a, 1, [1, 2, 3], axis=1), # doctest: +SKIP ... np.insert(a, [1], [[1],[2],[3]], axis=1)) True
>>> b = a.flatten() # doctest: +SKIP >>> b # doctest: +SKIP array([1, 1, 2, 2, 3, 3]) >>> np.insert(b, [2, 2], [5, 6]) # doctest: +SKIP array([1, 1, 5, ..., 2, 3, 3])
>>> np.insert(b, slice(2, 4), [5, 6]) # doctest: +SKIP array([1, 1, 5, ..., 2, 3, 3])
>>> np.insert(b, [2, 2], [7.13, False]) # type casting # doctest: +SKIP array([1, 1, 7, ..., 2, 3, 3])
>>> x = np.arange(8).reshape(2, 4) # doctest: +SKIP >>> idx = (1, 3) # doctest: +SKIP >>> np.insert(x, idx, 999, axis=1) # doctest: +SKIP array([[ 0, 999, 1, 2, 999, 3], [ 4, 999, 5, 6, 999, 7]])

dask.array.
invert
(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.invert.
Some inconsistencies with the Dask version may exist.
Compute bitwise inversion, or bitwise NOT, elementwise.
Computes the bitwise NOT of the underlying binary representation of the integers in the input arrays. This ufunc implements the C/Python operator
~
.For signed integer inputs, the two’s complement is returned. In a two’scomplement system negative numbers are represented by the two’s complement of the absolute value. This is the most common method of representing signed integers on computers [1]. A Nbit two’scomplement system can represent every integer in the range \(2^{N1}\) to \(+2^{N1}1\).
Parameters:  x : array_like
Only integer and boolean types are handled.
 out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  out : ndarray or scalar
Result. This is a scalar if x is a scalar.
See also
bitwise_and
,bitwise_or
,bitwise_xor
logical_not
binary_repr
 Return the binary representation of the input number as a string.
Notes
bitwise_not is an alias for invert:
>>> np.bitwise_not is np.invert # doctest: +SKIP True
References
[1] Wikipedia, “Two’s complement”, https://en.wikipedia.org/wiki/Two’s_complement Examples
We’ve seen that 13 is represented by
00001101
. The invert or bitwise NOT of 13 is then:>>> x = np.invert(np.array(13, dtype=np.uint8)) # doctest: +SKIP >>> x # doctest: +SKIP 242 >>> np.binary_repr(x, width=8) # doctest: +SKIP '11110010'
The result depends on the bitwidth:
>>> x = np.invert(np.array(13, dtype=np.uint16)) # doctest: +SKIP >>> x # doctest: +SKIP 65522 >>> np.binary_repr(x, width=16) # doctest: +SKIP '1111111111110010'
When using signed integer types the result is the two’s complement of the result for the unsigned type:
>>> np.invert(np.array([13], dtype=np.int8)) # doctest: +SKIP array([14], dtype=int8) >>> np.binary_repr(14, width=8) # doctest: +SKIP '11110010'
Booleans are accepted as well:
>>> np.invert(np.array([True, False])) # doctest: +SKIP array([False, True])
The
~
operator can be used as a shorthand fornp.invert
on ndarrays.>>> x1 = np.array([True, False]) # doctest: +SKIP >>> ~x1 # doctest: +SKIP array([False, True])

dask.array.
isclose
(arr1, arr2, rtol=1e05, atol=1e08, equal_nan=False)[source]¶ Returns a boolean array where two arrays are elementwise equal within a tolerance.
This docstring was copied from numpy.isclose.
Some inconsistencies with the Dask 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:  a, b : array_like
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 : array_like
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.
See also
allclose
math.isclose
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 builtin 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.
isclose is not defined for nonnumeric data types.
Examples
>>> np.isclose([1e10,1e7], [1.00001e10,1e8]) # doctest: +SKIP array([ True, False]) >>> np.isclose([1e10,1e8], [1.00001e10,1e9]) # doctest: +SKIP array([ True, True]) >>> np.isclose([1e10,1e8], [1.0001e10,1e9]) # doctest: +SKIP array([False, True]) >>> np.isclose([1.0, np.nan], [1.0, np.nan]) # doctest: +SKIP array([ True, False]) >>> np.isclose([1.0, np.nan], [1.0, np.nan], equal_nan=True) # doctest: +SKIP array([ True, True]) >>> np.isclose([1e8, 1e7], [0.0, 0.0]) # doctest: +SKIP array([ True, False]) >>> np.isclose([1e100, 1e7], [0.0, 0.0], atol=0.0) # doctest: +SKIP array([False, False]) >>> np.isclose([1e10, 1e10], [1e20, 0.0]) # doctest: +SKIP array([ True, True]) >>> np.isclose([1e10, 1e10], [1e20, 0.999999e10], atol=0.0) # doctest: +SKIP array([False, True])

dask.array.
iscomplex
(*args, **kwargs)¶ Returns a bool array, where True if input element is complex.
This docstring was copied from numpy.iscomplex.
Some inconsistencies with the Dask version may exist.
What is tested is whether the input has a nonzero imaginary part, not if the input type is complex.
Parameters:  x : array_like (Not supported in Dask)
Input array.
Returns:  out : ndarray of bools
Output array.
See also
isreal
iscomplexobj
 Return True if x is a complex type or an array of complex numbers.
Examples
>>> np.iscomplex([1+1j, 1+0j, 4.5, 3, 2, 2j]) # doctest: +SKIP array([ True, False, False, False, False, True])

dask.array.
isfinite
(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.isfinite.
Some inconsistencies with the Dask version may exist.
Test elementwise for finiteness (not infinity or not Not a Number).
The result is returned as a boolean array.
Parameters:  x : array_like
Input values.
 out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  y : ndarray, bool
True where
x
is not positive infinity, negative infinity, or NaN; false otherwise. This is a scalar if x is a scalar.
Notes
Not a Number, positive infinity and negative infinity are considered to be nonfinite.
NumPy uses the IEEE Standard for Binary FloatingPoint for Arithmetic (IEEE 754). This means that Not a Number is not equivalent to infinity. Also that positive infinity is not equivalent to negative infinity. But infinity is equivalent to positive infinity. Errors result if the second argument is also supplied when x is a scalar input, or if first and second arguments have different shapes.
Examples
>>> np.isfinite(1) # doctest: +SKIP True >>> np.isfinite(0) # doctest: +SKIP True >>> np.isfinite(np.nan) # doctest: +SKIP False >>> np.isfinite(np.inf) # doctest: +SKIP False >>> np.isfinite(np.NINF) # doctest: +SKIP False >>> np.isfinite([np.log(1.),1.,np.log(0)]) # doctest: +SKIP array([False, True, False])
>>> x = np.array([np.inf, 0., np.inf]) # doctest: +SKIP >>> y = np.array([2, 2, 2]) # doctest: +SKIP >>> np.isfinite(x, y) # doctest: +SKIP array([0, 1, 0]) >>> y # doctest: +SKIP array([0, 1, 0])

dask.array.
isin
(element, test_elements, assume_unique=False, invert=False)¶ 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.
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 nonarraylike 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 : ndarray, bool
Has the same shape as element. The values element[isin] are in test_elements.
See also
in1d
 Flattened version of this function.
numpy.lib.arraysetops
 Module with a number of other functions for performing set operations on arrays.
Notes
isin is an elementwise function version of the python keyword in.
isin(a, b)
is roughly equivalent tonp.array([item in b for item in a])
if a and b are 1D sequences.element and test_elements are converted to arrays if they are not already. If test_elements is a set (or other nonsequence 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 nonsequence collections. Converting the set to a list usually gives the desired behavior.
New in version 1.13.0.
Examples
>>> element = 2*np.arange(4).reshape((2, 2)) >>> element array([[0, 2], [4, 6]]) >>> test_elements = [1, 2, 4, 8] >>> mask = np.isin(element, test_elements) >>> mask array([[False, True], [ True, False]]) >>> element[mask] array([2, 4])
The indices of the matched values can be obtained with nonzero:
>>> np.nonzero(mask) (array([0, 1]), array([1, 0]))
The test can also be inverted:
>>> mask = np.isin(element, test_elements, invert=True) >>> mask array([[ True, False], [False, True]]) >>> element[mask] array([0, 6])
Because of how array handles sets, the following does not work as expected:
>>> test_set = {1, 2, 4, 8} >>> np.isin(element, test_set) array([[False, False], [False, False]])
Casting the set to a list gives the expected result:
>>> np.isin(element, list(test_set)) array([[False, True], [ True, False]])

dask.array.
isinf
(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.isinf.
Some inconsistencies with the Dask version may exist.
Test elementwise for positive or negative infinity.
Returns a boolean array of the same shape as x, True where
x == +/inf
, otherwise False.Parameters:  x : array_like
Input values
 out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  y : bool (scalar) or boolean ndarray
True where
x
is positive or negative infinity, false otherwise. This is a scalar if x is a scalar.
Notes
NumPy uses the IEEE Standard for Binary FloatingPoint for Arithmetic (IEEE 754).
Errors result if the second argument is supplied when the first argument is a scalar, or if the first and second arguments have different shapes.
Examples
>>> np.isinf(np.inf) # doctest: +SKIP True >>> np.isinf(np.nan) # doctest: +SKIP False >>> np.isinf(np.NINF) # doctest: +SKIP True >>> np.isinf([np.inf, np.inf, 1.0, np.nan]) # doctest: +SKIP array([ True, True, False, False])
>>> x = np.array([np.inf, 0., np.inf]) # doctest: +SKIP >>> y = np.array([2, 2, 2]) # doctest: +SKIP >>> np.isinf(x, y) # doctest: +SKIP array([1, 0, 1]) >>> y # doctest: +SKIP array([1, 0, 1])

dask.array.
isneginf
(*args, **kwargs)¶ This docstring was copied from numpy.equal.
Some inconsistencies with the Dask version may exist.
Return (x1 == x2) elementwise.
Parameters:  x1, x2 : array_like
Input arrays. If
x1.shape != x2.shape
, they must be broadcastable to a common shape (which becomes the shape of the output). out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  out : ndarray or scalar
Output array, elementwise 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.
See also
not_equal
,greater_equal
,less_equal
,greater
,less
Examples
>>> np.equal([0, 1, 3], np.arange(3)) # doctest: +SKIP array([ True, True, False])
What is compared are values, not types. So an int (1) and an array of length one can evaluate as True:
>>> np.equal(1, np.ones(1)) # doctest: +SKIP array([ True])
The
==
operator can be used as a shorthand fornp.equal
on ndarrays.>>> a = np.array([2, 4, 6]) # doctest: +SKIP >>> b = np.array([2, 4, 2]) # doctest: +SKIP >>> a == b # doctest: +SKIP array([ True, True, False])

dask.array.
isnan
(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.isnan.
Some inconsistencies with the Dask version may exist.
Test elementwise for NaN and return result as a boolean array.
Parameters:  x : array_like
Input array.
 out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  y : ndarray or bool
True where
x
is NaN, false otherwise. This is a scalar if x is a scalar.
Notes
NumPy uses the IEEE Standard for Binary FloatingPoint for Arithmetic (IEEE 754). This means that Not a Number is not equivalent to infinity.
Examples
>>> np.isnan(np.nan) # doctest: +SKIP True >>> np.isnan(np.inf) # doctest: +SKIP False >>> np.isnan([np.log(1.),1.,np.log(0)]) # doctest: +SKIP array([ True, False, False])

dask.array.
isposinf
(*args, **kwargs)¶ This docstring was copied from numpy.equal.
Some inconsistencies with the Dask version may exist.
Return (x1 == x2) elementwise.
Parameters:  x1, x2 : array_like
Input arrays. If
x1.shape != x2.shape
, they must be broadcastable to a common shape (which becomes the shape of the output). out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  out : ndarray or scalar
Output array, elementwise 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.
See also
not_equal
,greater_equal
,less_equal
,greater
,less
Examples
>>> np.equal([0, 1, 3], np.arange(3)) # doctest: +SKIP array([ True, True, False])
What is compared are values, not types. So an int (1) and an array of length one can evaluate as True:
>>> np.equal(1, np.ones(1)) # doctest: +SKIP array([ True])
The
==
operator can be used as a shorthand fornp.equal
on ndarrays.>>> a = np.array([2, 4, 6]) # doctest: +SKIP >>> b = np.array([2, 4, 2]) # doctest: +SKIP >>> a == b # doctest: +SKIP array([ True, True, False])

dask.array.
isreal
(*args, **kwargs)¶ Returns a bool array, where True if input element is real.
This docstring was copied from numpy.isreal.
Some inconsistencies with the Dask version may exist.
If element has complex type with zero complex part, the return value for that element is True.
Parameters:  x : array_like (Not supported in Dask)
Input array.
Returns:  out : ndarray, bool
Boolean array of same shape as x.
See also
iscomplex
isrealobj
 Return True if x is not a complex type.
Examples
>>> np.isreal([1+1j, 1+0j, 4.5, 3, 2, 2j]) # doctest: +SKIP array([False, True, True, True, True, False])

dask.array.
ldexp
(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.ldexp.
Some inconsistencies with the Dask version may exist.
Returns x1 * 2**x2, elementwise.
The mantissas x1 and twos exponents x2 are used to construct floating point numbers
x1 * 2**x2
.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). out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  y : ndarray or scalar
The result of
x1 * 2**x2
. This is a scalar if both x1 and x2 are scalars.
See also
frexp
 Return (y1, y2) from
x = y1 * 2**y2
, inverse to ldexp.
Notes
Complex dtypes are not supported, they will raise a TypeError.
ldexp is useful as the inverse of frexp, if used by itself it is more clear to simply use the expression
x1 * 2**x2
.Examples
>>> np.ldexp(5, np.arange(4)) # doctest: +SKIP array([ 5., 10., 20., 40.], dtype=float16)
>>> x = np.arange(6) # doctest: +SKIP >>> np.ldexp(*np.frexp(x)) # doctest: +SKIP array([ 0., 1., 2., 3., 4., 5.])

dask.array.
less
(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.less.
Some inconsistencies with the Dask version may exist.
Return the truth value of (x1 < x2) elementwise.
Parameters:  x1, x2 : array_like
Input arrays. If
x1.shape != x2.shape
, they must be broadcastable to a common shape (which becomes the shape of the output). out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  out : ndarray or scalar
Output array, elementwise 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.
See also
greater
,less_equal
,greater_equal
,equal
,not_equal
Examples
>>> np.less([1, 2], [2, 2]) # doctest: +SKIP array([ True, False])
The
<
operator can be used as a shorthand fornp.less
on ndarrays.>>> a = np.array([1, 2]) # doctest: +SKIP >>> b = np.array([2, 2]) # doctest: +SKIP >>> a < b # doctest: +SKIP array([ True, False])

dask.array.
linspace
(start, stop, num=50, endpoint=True, retstep=False, chunks='auto', dtype=None)[source]¶ Return num evenly spaced values over the closed interval [start, stop].
Parameters:  start : scalar
The starting value of the sequence.
 stop : scalar
The last value of the sequence.
 num : int, optional
Number of samples to include in the returned dask array, including the endpoints. Default is 50.
 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. Default is False.
 chunks : int
The number of samples on each block. Note that the last block will have fewer samples if num % blocksize != 0
 dtype : dtype, optional
The type of the output array.
Returns:  samples : dask array
 step : float, optional
Only returned if
retstep
is True. Size of spacing between samples.
See also

dask.array.
log
(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.log.
Some inconsistencies with the Dask version may exist.
Natural logarithm, elementwise.
The natural logarithm log is the inverse of the exponential function, so that log(exp(x)) = x. The natural logarithm is logarithm in base e.
Parameters:  x : array_like
Input value.
 out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  y : ndarray
The natural logarithm of x, elementwise. This is a scalar if x is a scalar.
Notes
Logarithm is a multivalued function: for each x there is an infinite number of z such that exp(z) = x. The convention is to return the z whose imaginary part lies in [pi, pi].
For realvalued input data types, log always returns real output. For each value that cannot be expressed as a real number or infinity, it yields
nan
and sets the invalid floating point error flag.For complexvalued input, log is a complex analytical function that has a branch cut [inf, 0] and is continuous from above on it. log handles the floatingpoint negative zero as an infinitesimal negative number, conforming to the C99 standard.
References
[1] M. Abramowitz and I.A. Stegun, “Handbook of Mathematical Functions”, 10th printing, 1964, pp. 67. http://www.math.sfu.ca/~cbm/aands/ [2] Wikipedia, “Logarithm”. https://en.wikipedia.org/wiki/Logarithm Examples
>>> np.log([1, np.e, np.e**2, 0]) # doctest: +SKIP array([ 0., 1., 2., Inf])

dask.array.
log10
(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.log10.
Some inconsistencies with the Dask version may exist.
Return the base 10 logarithm of the input array, elementwise.
Parameters:  x : array_like
Input values.
 out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  y : ndarray
The logarithm to the base 10 of x, elementwise. NaNs are returned where x is negative. This is a scalar if x is a scalar.
See also
emath.log10
Notes
Logarithm is a multivalued function: for each x there is an infinite number of z such that 10**z = x. The convention is to return the z whose imaginary part lies in [pi, pi].
For realvalued input data types, log10 always returns real output. For each value that cannot be expressed as a real number or infinity, it yields
nan
and sets the invalid floating point error flag.For complexvalued input, log10 is a complex analytical function that has a branch cut [inf, 0] and is continuous from above on it. log10 handles the floatingpoint negative zero as an infinitesimal negative number, conforming to the C99 standard.
References
[1] M. Abramowitz and I.A. Stegun, “Handbook of Mathematical Functions”, 10th printing, 1964, pp. 67. http://www.math.sfu.ca/~cbm/aands/ [2] Wikipedia, “Logarithm”. https://en.wikipedia.org/wiki/Logarithm Examples
>>> np.log10([1e15, 3.]) # doctest: +SKIP array([15., nan])

dask.array.
log1p
(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.log1p.
Some inconsistencies with the Dask version may exist.
Return the natural logarithm of one plus the input array, elementwise.
Calculates
log(1 + x)
.Parameters:  x : array_like
Input values.
 out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  y : ndarray
Natural logarithm of 1 + x, elementwise. This is a scalar if x is a scalar.
See also
expm1
exp(x)  1
, the inverse of log1p.
Notes
For realvalued input, log1p is accurate also for x so small that 1 + x == 1 in floatingpoint accuracy.
Logarithm is a multivalued function: for each x there is an infinite number of z such that exp(z) = 1 + x. The convention is to return the z whose imaginary part lies in [pi, pi].
For realvalued input data types, log1p always returns real output. For each value that cannot be expressed as a real number or infinity, it yields
nan
and sets the invalid floating point error flag.For complexvalued input, log1p is a complex analytical function that has a branch cut [inf, 1] and is continuous from above on it. log1p handles the floatingpoint negative zero as an infinitesimal negative number, conforming to the C99 standard.
References
[1] M. Abramowitz and I.A. Stegun, “Handbook of Mathematical Functions”, 10th printing, 1964, pp. 67. http://www.math.sfu.ca/~cbm/aands/ [2] Wikipedia, “Logarithm”. https://en.wikipedia.org/wiki/Logarithm Examples
>>> np.log1p(1e99) # doctest: +SKIP 1e99 >>> np.log(1 + 1e99) # doctest: +SKIP 0.0

dask.array.
log2
(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.log2.
Some inconsistencies with the Dask version may exist.
Base2 logarithm of x.
Parameters:  x : array_like
Input values.
 out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  y : ndarray
Base2 logarithm of x. This is a scalar if x is a scalar.
Notes
New in version 1.3.0.
Logarithm is a multivalued function: for each x there is an infinite number of z such that 2**z = x. The convention is to return the z whose imaginary part lies in [pi, pi].
For realvalued input data types, log2 always returns real output. For each value that cannot be expressed as a real number or infinity, it yields
nan
and sets the invalid floating point error flag.For complexvalued input, log2 is a complex analytical function that has a branch cut [inf, 0] and is continuous from above on it. log2 handles the floatingpoint negative zero as an infinitesimal negative number, conforming to the C99 standard.
Examples
>>> x = np.array([0, 1, 2, 2**4]) # doctest: +SKIP >>> np.log2(x) # doctest: +SKIP array([Inf, 0., 1., 4.])
>>> xi = np.array([0+1.j, 1, 2+0.j, 4.j]) # doctest: +SKIP >>> np.log2(xi) # doctest: +SKIP array([ 0.+2.26618007j, 0.+0.j , 1.+0.j , 2.+2.26618007j])

dask.array.
logaddexp
(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.logaddexp.
Some inconsistencies with the Dask version may exist.
Logarithm of the sum of exponentiations of the inputs.
Calculates
log(exp(x1) + exp(x2))
. This function is useful in statistics where the calculated probabilities of events may be so small as to exceed the range of normal floating point numbers. In such cases the logarithm of the calculated probability is stored. This function allows adding probabilities stored in such a fashion.Parameters:  x1, x2 : array_like
Input values. If
x1.shape != x2.shape
, they must be broadcastable to a common shape (which becomes the shape of the output). out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  result : ndarray
Logarithm of
exp(x1) + exp(x2)
. This is a scalar if both x1 and x2 are scalars.
See also
logaddexp2
 Logarithm of the sum of exponentiations of inputs in base 2.
Notes
New in version 1.3.0.
Examples
>>> prob1 = np.log(1e50) # doctest: +SKIP >>> prob2 = np.log(2.5e50) # doctest: +SKIP >>> prob12 = np.logaddexp(prob1, prob2) # doctest: +SKIP >>> prob12 # doctest: +SKIP 113.87649168120691 >>> np.exp(prob12) # doctest: +SKIP 3.5000000000000057e50

dask.array.
logaddexp2
(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.logaddexp2.
Some inconsistencies with the Dask version may exist.
Logarithm of the sum of exponentiations of the inputs in base2.
Calculates
log2(2**x1 + 2**x2)
. This function is useful in machine learning when the calculated probabilities of events may be so small as to exceed the range of normal floating point numbers. In such cases the base2 logarithm of the calculated probability can be used instead. This function allows adding probabilities stored in such a fashion.Parameters:  x1, x2 : array_like
Input values. If
x1.shape != x2.shape
, they must be broadcastable to a common shape (which becomes the shape of the output). out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  result : ndarray
Base2 logarithm of
2**x1 + 2**x2
. This is a scalar if both x1 and x2 are scalars.
See also
logaddexp
 Logarithm of the sum of exponentiations of the inputs.
Notes
New in version 1.3.0.
Examples
>>> prob1 = np.log2(1e50) # doctest: +SKIP >>> prob2 = np.log2(2.5e50) # doctest: +SKIP >>> prob12 = np.logaddexp2(prob1, prob2) # doctest: +SKIP >>> prob1, prob2, prob12 # doctest: +SKIP (166.09640474436813, 164.77447664948076, 164.28904982231052) >>> 2**prob12 # doctest: +SKIP 3.4999999999999914e50

dask.array.
logical_and
(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.logical_and.
Some inconsistencies with the Dask version may exist.
Compute the truth value of x1 AND x2 elementwise.
Parameters:  x1, x2 : array_like
Input arrays. If
x1.shape != x2.shape
, they must be broadcastable to a common shape (which becomes the shape of the output). out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  y : ndarray or bool
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.
See also
Examples
>>> np.logical_and(True, False) # doctest: +SKIP False >>> np.logical_and([True, False], [False, False]) # doctest: +SKIP array([False, False])
>>> x = np.arange(5) # doctest: +SKIP >>> np.logical_and(x>1, x<4) # doctest: +SKIP array([False, False, True, True, False])
The
&
operator can be used as a shorthand fornp.logical_and
on boolean ndarrays.>>> a = np.array([True, False]) # doctest: +SKIP >>> b = np.array([False, False]) # doctest: +SKIP >>> a & b # doctest: +SKIP array([False, False])

dask.array.
logical_not
(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.logical_not.
Some inconsistencies with the Dask version may exist.
Compute the truth value of NOT x elementwise.
Parameters:  x : array_like
Logical NOT is applied to the elements of x.
 out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  y : bool or ndarray of bool
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.
See also
Examples
>>> np.logical_not(3) # doctest: +SKIP False >>> np.logical_not([True, False, 0, 1]) # doctest: +SKIP array([False, True, True, False])
>>> x = np.arange(5) # doctest: +SKIP >>> np.logical_not(x<3) # doctest: +SKIP array([False, False, False, True, True])

dask.array.
logical_or
(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.logical_or.
Some inconsistencies with the Dask version may exist.
Compute the truth value of x1 OR x2 elementwise.
Parameters:  x1, x2 : array_like
Logical OR 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). out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  y : ndarray or bool
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.
See also
Examples
>>> np.logical_or(True, False) # doctest: +SKIP True >>> np.logical_or([True, False], [False, False]) # doctest: +SKIP array([ True, False])
>>> x = np.arange(5) # doctest: +SKIP >>> np.logical_or(x < 1, x > 3) # doctest: +SKIP array([ True, False, False, False, True])
The

operator can be used as a shorthand fornp.logical_or
on boolean ndarrays.>>> a = np.array([True, False]) # doctest: +SKIP >>> b = np.array([False, False]) # doctest: +SKIP >>> a  b # doctest: +SKIP array([ True, False])

dask.array.
logical_xor
(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])¶ This docstring was copied from numpy.logical_xor.
Some inconsistencies with the Dask version may exist.
Compute the truth value of x1 XOR x2, elementwise.
Parameters:  x1, x2 : array_like
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). out : ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
 where : array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default
out=None
, locations within it where the condition is False will remain uninitialized. **kwargs
For other keywordonly arguments, see the ufunc docs.
Returns:  y : bool or ndarray of bool
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.
See also
Examples
>>> np.logical_xor(True, False) # doctest: +SKIP True >>> np.logical_xor([True, True, False, False], [True, False, True, False]) # doctest: +SKIP array([False, True, True, False])
>>> x = np.arange(5) # doctest: +SKIP >>> np.logical_xor(x < 1, x > 3) # doctest: +SKIP array([ True, False, False, False, True])
Simple example showing support of broadcasting
>>> np.logical_xor(0, np.eye(2)) # doctest: +SKIP array([[ True, False], [False, True]])

dask.array.
map_blocks
(func, *args, name=None, token=None, dtype=None, chunks=None, drop_axis=[], new_axis=None, meta=None, **kwargs)[source]¶ Map a function across all blocks of a dask array.
Note that
map_blocks
will attempt to automatically determine the output array type by callingfunc
on 0d versions of the inputs. Please refer to themeta
keyword argument below if you expect that the function will not succeed when operating on 0d arrays.Parameters:  func : callable
Function to apply to every block in the array.
 args : dask arrays or other objects
 dtype : np.dtype, optional
The
dtype
of the output array. It is recommended to provide this. If not provided, will be inferred by applying the function to a small set of fake data. chunks : tuple, optional
Chunk shape of resulting blocks if the function does not preserve shape. If not provided, the resulting array is assumed to have the same block structure as the first input array.
 drop_axis : number or iterable, optional
Dimensions lost by the function.
 new_axis : number or iterable, optional
New dimensions created by the function. Note that these are applied after
drop_axis
(if present). token : string, optional
The key prefix to use for the output array. If not provided, will be determined from the function name.
 name : string, optional
The key name to use for the output array. Note that this fully specifies the output key name, and must be unique. If not provided, will be determined by a hash of the arguments.
 meta : arraylike, optional
The
meta
of the output array, when specified is expected to be an array of the same type and dtype of that returned when calling.compute()
on the array returned by this function. When not provided,meta
will be inferred by applying the function to a small set of fake data, usually a 0d array. It’s important to ensure thatfunc
can successfully complete computation without raising exceptions when 0d is passed to it, providingmeta
will be required otherwise. If the output type is known beforehand (e.g.,np.ndarray
,cupy.ndarray
), an empty array of such type dtype can be passed, for example:meta=np.array((), dtype=np.int32)
. **kwargs :
Other keyword arguments to pass to function. Values must be constants (not dask.arrays)
See also
dask.array.blockwise
 Generalized operation with control over block alignment.
Examples
>>> import dask.array as da >>> x = da.arange(6, chunks=3)
>>> x.map_blocks(lambda x: x * 2).compute() array([ 0, 2, 4, 6, 8, 10])
The
da.map_blocks
function can also accept multiple arrays.>>> d = da.arange(5, chunks=2) >>> e = da.arange(5, chunks=2)
>>> f = da.map_blocks(lambda a, b: a + b**2, d, e) >>> f.compute() array([ 0, 2, 6, 12, 20])
If the function changes shape of the blocks then you must provide chunks explicitly.
>>> y = x.map_blocks(lambda x: x[::2], chunks=((2, 2),))
You have a bit of freedom in specifying chunks. If all of the output chunk sizes are the same, you can provide just that chunk size as a single tuple.
>>> a = da.arange(18, chunks=(6,)) >>> b = a.map_blocks(lambda x: x[:3], chunks=(3,))
If the function changes the dimension of the blocks you must specify the created or destroyed dimensions.
>>> b = a.map_blocks(lambda x: x[None, :, None], chunks=(1, 6, 1), ... new_axis=[0, 2])
If
chunks
is specified butnew_axis
is not, then it is inferred to add the necessary number of axes on the left.Map_blocks aligns blocks by block positions without regard to shape. In the following example we have two arrays with the same number of blocks but with different shape and chunk sizes.
>>> x = da.arange(1000, chunks=(100,)) >>> y = da.arange(100, chunks=(10,))
The relevant attribute to match is numblocks.
>>> x.numblocks (10,) >>> y.numblocks (10,)
If these match (up to broadcasting rules) then we can map arbitrary functions across blocks
>>> def func(a, b): ... return np.array([a.max(), b.max()])
>>> da.map_blocks(func, x, y, chunks=(2,), dtype='i8') dask.array<func, shape=(20,), dtype=int64, chunksize=(2,), chunktype=numpy.ndarray>
>>> _.compute() array([ 99, 9, 199, 19, 299, 29, 399, 39, 499, 49, 599, 59, 699, 69, 799, 79, 899, 89, 999, 99])
Your block function get information about where it is in the array by accepting a special
block_info
orblock_id
keyword argument.>>> def func(block_info=None): ... pass
This will receive the following information:
>>> block_info # doctest: +SKIP {0: {'shape': (1000,), 'numchunks': (10,), 'chunklocation': (4,), 'arraylocation': [(400, 500)]}, None: {'shape': (1000,), 'numchunks': (10,), 'chunklocation': (4,), 'arraylocation': [(400, 500)], 'chunkshape': (100,), 'dtype': dtype('float64')}}
For each argument and keyword arguments that are dask arrays (the positions of which are the first index), you will receive the shape of the full array, the number of chunks of the full array in each dimension, the chunk location (for example the fourth chunk over in the first dimension), and the array location (for example the slice corresponding to
40:50
). The same information is provided for the output, with the keyNone
, plus the shape and dtype that should be returned.These features can be combined to synthesize an array from scratch, for example:
>>> def func(block_info=None): ... loc = block_info[None]['arraylocation'][0] ... return np.arange(loc[0], loc[1])
>>> da.map_blocks(func, chunks=((4, 4),), dtype=np.float_) dask.array<func, shape=(8,), dtype=float64, chunksize=(4,), chunktype=numpy.ndarray>
>>> _.compute() array([0, 1, 2, 3, 4, 5, 6, 7])
block_id
is similar toblock_info
but contains only thechunk_location
:>>> def func(block_id=None): ... pass
This will receive the following information:
>>> block_id # doctest: +SKIP (4, 3)
You may specify the key name prefix of the resulting task in the graph with the optional
token
keyword argument.>>> x.map_blocks(lambda x: x + 1, name='increment') # doctest: +SKIP dask.array<increment, shape=(100,), dtype=int64, chunksize=(10,), chunktype=numpy.ndarray>
For functions that may not handle 0d arrays, it’s also possible to specify
meta
with an empty array matching the type of the expected result. In the example below,func
will result in anIndexError
when computingmeta
:>>> da.map_blocks(lambda x: x[2], da.random.random(5), meta=np.array(())) dask.array<lambda, shape=(5,), dtype=float64, chunksize=(5,), chunktype=numpy.ndarray>
Similarly, it’s possible to specify a nonNumPy array to
meta
, and provide adtype
:>>> import cupy # doctest: +SKIP >>> rs = da.random.RandomState(RandomState=cupy.random.RandomState) # doctest: +SKIP >>> dt = np.float32 >>> da.map_blocks(lambda x: x[2], rs.random(5, dtype=dt), meta=cupy.array((), dtype=dt)) # doctest: +SKIP dask.array<lambda, shape=(5,), dtype=float32, chunksize=(5,), chunktype=cupy.ndarray>

dask.array.
matmul
(x1, x2, /, out=None, *, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])[source]¶ This docstring was copied from numpy.matmul.
Some inconsistencies with the Dask version may exist.
Matrix product of two arrays.
Parameters:  x1, x2 : array_like
Input arrays, scalars not allowed.
 out : ndarray, optional
A location into which the result is stored. If provided, it must have a shape that matches the signature (n,k),(k,m)>(n,m). If not provided or None, a freshlyallocated array is returned.
 **kwargs
For other keywordonly arguments, see the ufunc docs.
New in version 1.16: Now handles ufunc kwargs
Returns:  y : ndarray
The matrix product of the inputs. This is a scalar only when both x1, x2 are 1d vectors.
Raises:  ValueError
If the last dimension of x1 is not the same size as the secondtolast dimension of x2.
If a scalar value is passed in.
See also
Notes
The behavior depends on the arguments in the following way.
 If both arguments are 2D they are multiplied like conventional matrices.
 If either argument is ND, N > 2, it is treated as a stack of matrices residing in the last two indexes and broadcast accordingly.
 If the first argument is 1D, it is promoted to a matrix by prepending a 1 to its dimensions. After matrix multiplication the prepended 1 is removed.
 If the second argument is 1D, it is promoted to a matrix by appending a 1 to its dimensions. After matrix multiplication the appended 1 is removed.
matmul
differs fromdot
in two important ways:Multiplication by scalars is not allowed, use
*
instead.Stacks of matrices are broadcast together as if the matrices were elements, respecting the signature
(n,k),(k,m)>(n,m)
:>>> a = np.ones([9, 5, 7, 4]) # doctest: +SKIP >>> c = np.ones([9, 5, 4, 3]) # doctest: +SKIP >>> np.dot(a, c).shape # d