code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def trapz(y, x=None, dx=1.0, axis=-1): """ Integrate along the given axis using the composite trapezoidal rule. Integrate `y` (`x`) along given axis. Parameters ---------- y : array_like Input tensor to integrate. x : array_like, optional The sample points corresponding to ...
Integrate along the given axis using the composite trapezoidal rule. Integrate `y` (`x`) along given axis. Parameters ---------- y : array_like Input tensor to integrate. x : array_like, optional The sample points corresponding to the `y` values. If `x` is None, the sa...
trapz
python
mars-project/mars
mars/tensor/base/trapz.py
https://github.com/mars-project/mars/blob/master/mars/tensor/base/trapz.py
Apache-2.0
def unique( ar, return_index=False, return_inverse=False, return_counts=False, axis=None, aggregate_size=None, ): """ Find the unique elements of a tensor. Returns the sorted unique elements of a tensor. There are three optional outputs in addition to the unique elements: *...
Find the unique elements of a tensor. Returns the sorted unique elements of a tensor. There are three optional outputs in addition to the unique elements: * the indices of the input tensor that give the unique values * the indices of the unique tensor that reconstruct the input tensor * the n...
unique
python
mars-project/mars
mars/tensor/base/unique.py
https://github.com/mars-project/mars/blob/master/mars/tensor/base/unique.py
Apache-2.0
def vsplit(a, indices_or_sections): """ Split a tensor into multiple sub-tensors vertically (row-wise). Please refer to the ``split`` documentation. ``vsplit`` is equivalent to ``split`` with `axis=0` (default), the tensor is always split along the first axis regardless of the tensor dimension. ...
Split a tensor into multiple sub-tensors vertically (row-wise). Please refer to the ``split`` documentation. ``vsplit`` is equivalent to ``split`` with `axis=0` (default), the tensor is always split along the first axis regardless of the tensor dimension. See Also -------- split : Split ...
vsplit
python
mars-project/mars
mars/tensor/base/vsplit.py
https://github.com/mars-project/mars/blob/master/mars/tensor/base/vsplit.py
Apache-2.0
def where(condition, x=None, y=None): """ Return elements, either from `x` or `y`, depending on `condition`. If only `condition` is given, return ``condition.nonzero()``. Parameters ---------- condition : array_like, bool When True, yield `x`, otherwise yield `y`. x, y : array_like...
Return elements, either from `x` or `y`, depending on `condition`. If only `condition` is given, return ``condition.nonzero()``. Parameters ---------- condition : array_like, bool When True, yield `x`, otherwise yield `y`. x, y : array_like, optional Values from which to choos...
where
python
mars-project/mars
mars/tensor/base/where.py
https://github.com/mars-project/mars/blob/master/mars/tensor/base/where.py
Apache-2.0
def arange(*args, **kwargs): """ Return evenly spaced values within a given interval. Values are generated within the half-open interval ``[start, stop)`` (in other words, the interval including `start` but excluding `stop`). For integer arguments the function is equivalent to the Python built-in ...
Return evenly spaced values within a given interval. Values are generated within the half-open interval ``[start, stop)`` (in other words, the interval including `start` but excluding `stop`). For integer arguments the function is equivalent to the Python built-in `range <http://docs.python.org/li...
arange
python
mars-project/mars
mars/tensor/datasource/arange.py
https://github.com/mars-project/mars/blob/master/mars/tensor/datasource/arange.py
Apache-2.0
def array(x, dtype=None, copy=True, order="K", ndmin=None, chunk_size=None): """ Create a tensor. 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 : dat...
Create a tensor. 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 : data-type, optional The desired data-type for the array. If not given, then th...
array
python
mars-project/mars
mars/tensor/datasource/array.py
https://github.com/mars-project/mars/blob/master/mars/tensor/datasource/array.py
Apache-2.0
def diag(v, k=0, sparse=None, gpu=None, chunk_size=None): """ Extract a diagonal or construct a diagonal tensor. See the more detailed documentation for ``mt.diagonal`` if you use this function to extract a diagonal and wish to write to the resulting tensor Parameters ---------- v : array_...
Extract a diagonal or construct a diagonal tensor. See the more detailed documentation for ``mt.diagonal`` if you use this function to extract a diagonal and wish to write to the resulting tensor Parameters ---------- v : array_like If `v` is a 2-D tensor, return its `k`-th diagonal. ...
diag
python
mars-project/mars
mars/tensor/datasource/diag.py
https://github.com/mars-project/mars/blob/master/mars/tensor/datasource/diag.py
Apache-2.0
def diagflat(v, k=0, sparse=None, gpu=None, chunk_size=None): """ Create a two-dimensional tensor with the flattened input as a diagonal. Parameters ---------- v : array_like Input data, which is flattened and set as the `k`-th diagonal of the output. k : int, optional D...
Create a two-dimensional tensor with the flattened input as a diagonal. Parameters ---------- v : array_like Input data, which is flattened and set as the `k`-th diagonal of the output. k : int, optional Diagonal to set; 0, the default, corresponds to the "main" diagonal, ...
diagflat
python
mars-project/mars
mars/tensor/datasource/diagflat.py
https://github.com/mars-project/mars/blob/master/mars/tensor/datasource/diagflat.py
Apache-2.0
def empty(shape, dtype=None, chunk_size=None, gpu=None, order="C"): """ Return a new tensor of given shape and type, without initializing entries. Parameters ---------- shape : int or tuple of int Shape of the empty tensor dtype : data-type, optional Desired output data-type. ...
Return a new tensor of given shape and type, without initializing entries. Parameters ---------- shape : int or tuple of int Shape of the empty tensor dtype : data-type, optional Desired output data-type. chunk_size : int or tuple of int or tuple of ints, optional Desir...
empty
python
mars-project/mars
mars/tensor/datasource/empty.py
https://github.com/mars-project/mars/blob/master/mars/tensor/datasource/empty.py
Apache-2.0
def empty_like(a, dtype=None, gpu=None, order="K"): """ Return a new tensor with the same shape and type as a given tensor. Parameters ---------- a : array_like The shape and data-type of `a` define these same attributes of the returned tensor. dtype : data-type, optional ...
Return a new tensor with the same shape and type as a given tensor. Parameters ---------- a : array_like The shape and data-type of `a` define these same attributes of the returned tensor. dtype : data-type, optional Overrides the data type of the result. gpu : bool, op...
empty_like
python
mars-project/mars
mars/tensor/datasource/empty.py
https://github.com/mars-project/mars/blob/master/mars/tensor/datasource/empty.py
Apache-2.0
def eye(N, M=None, k=0, dtype=None, sparse=False, gpu=None, chunk_size=None, order="C"): """ Return a 2-D tensor with ones on the diagonal and zeros elsewhere. Parameters ---------- N : int Number of rows in the output. M : int, optional Number of columns in the output. If None, def...
Return a 2-D tensor with ones on the diagonal and zeros elsewhere. Parameters ---------- N : int Number of rows in the output. M : int, optional Number of columns in the output. If None, defaults to `N`. k : int, optional Index of the diagonal: 0 (the default) refers to the m...
eye
python
mars-project/mars
mars/tensor/datasource/eye.py
https://github.com/mars-project/mars/blob/master/mars/tensor/datasource/eye.py
Apache-2.0
def full(shape, fill_value, dtype=None, chunk_size=None, gpu=None, order="C"): """ Return a new tensor of given shape and type, filled with `fill_value`. Parameters ---------- shape : int or sequence of ints Shape of the new tensor, e.g., ``(2, 3)`` or ``2``. fill_value : scalar ...
Return a new tensor of given shape and type, filled with `fill_value`. Parameters ---------- shape : int or sequence of ints Shape of the new tensor, e.g., ``(2, 3)`` or ``2``. fill_value : scalar Fill value. dtype : data-type, optional The desired data-type for the ten...
full
python
mars-project/mars
mars/tensor/datasource/full.py
https://github.com/mars-project/mars/blob/master/mars/tensor/datasource/full.py
Apache-2.0
def full_like(a, fill_value, dtype=None, gpu=None, order="K"): """ Return a full tensor with the same shape and type as a given tensor. Parameters ---------- a : array_like The shape and data-type of `a` define these same attributes of the returned tensor. fill_value : scalar ...
Return a full tensor with the same shape and type as a given tensor. Parameters ---------- a : array_like The shape and data-type of `a` define these same attributes of the returned tensor. fill_value : scalar Fill value. dtype : data-type, optional Overrides th...
full_like
python
mars-project/mars
mars/tensor/datasource/full.py
https://github.com/mars-project/mars/blob/master/mars/tensor/datasource/full.py
Apache-2.0
def indices(dimensions, dtype=int, chunk_size=None): """ Return a tensor representing the indices of a grid. Compute a tensor where the subtensors contain index values 0,1,... varying only along the corresponding axis. Parameters ---------- dimensions : sequence of ints The shape o...
Return a tensor representing the indices of a grid. Compute a tensor where the subtensors contain index values 0,1,... varying only along the corresponding axis. Parameters ---------- dimensions : sequence of ints The shape of the grid. dtype : dtype, optional Data type of...
indices
python
mars-project/mars
mars/tensor/datasource/indices.py
https://github.com/mars-project/mars/blob/master/mars/tensor/datasource/indices.py
Apache-2.0
def linspace( start, stop, num=50, endpoint=True, retstep=False, dtype=None, gpu=None, chunk_size=None, ): """ Return evenly spaced numbers over a specified interval. Returns `num` evenly spaced samples, calculated over the interval [`start`, `stop`]. The endpoint o...
Return evenly spaced numbers over a specified interval. Returns `num` evenly spaced samples, calculated over the interval [`start`, `stop`]. The endpoint of the interval can optionally be excluded. Parameters ---------- start : scalar The starting value of the sequence. stop ...
linspace
python
mars-project/mars
mars/tensor/datasource/linspace.py
https://github.com/mars-project/mars/blob/master/mars/tensor/datasource/linspace.py
Apache-2.0
def meshgrid(*xi, **kwargs): """ Return coordinate matrices from coordinate vectors. Make N-D coordinate arrays for vectorized evaluations of N-D scalar/vector fields over N-D grids, given one-dimensional coordinate tensors x1, x2,..., xn. Parameters ---------- x1, x2,..., xn : array_l...
Return coordinate matrices from coordinate vectors. Make N-D coordinate arrays for vectorized evaluations of N-D scalar/vector fields over N-D grids, given one-dimensional coordinate tensors x1, x2,..., xn. Parameters ---------- x1, x2,..., xn : array_like 1-D arrays representing ...
meshgrid
python
mars-project/mars
mars/tensor/datasource/meshgrid.py
https://github.com/mars-project/mars/blob/master/mars/tensor/datasource/meshgrid.py
Apache-2.0
def ones(shape, dtype=None, chunk_size=None, gpu=None, order="C"): """ Return a new tensor of given shape and type, filled with ones. Parameters ---------- shape : int or sequence of ints Shape of the new tensor, e.g., ``(2, 3)`` or ``2``. dtype : data-type, optional The desired...
Return a new tensor of given shape and type, filled with ones. Parameters ---------- shape : int or sequence of ints Shape of the new tensor, e.g., ``(2, 3)`` or ``2``. dtype : data-type, optional The desired data-type for the tensor, e.g., `mt.int8`. Default is `mt.float6...
ones
python
mars-project/mars
mars/tensor/datasource/ones.py
https://github.com/mars-project/mars/blob/master/mars/tensor/datasource/ones.py
Apache-2.0
def ones_like(a, dtype=None, gpu=None, order="K"): """ Return a tensor of ones with the same shape and type as a given tensor. Parameters ---------- a : array_like The shape and data-type of `a` define these same attributes of the returned tensor. dtype : data-type, optional ...
Return a tensor of ones with the same shape and type as a given tensor. Parameters ---------- a : array_like The shape and data-type of `a` define these same attributes of the returned tensor. dtype : data-type, optional Overrides the data type of the result. gpu : bool...
ones_like
python
mars-project/mars
mars/tensor/datasource/ones.py
https://github.com/mars-project/mars/blob/master/mars/tensor/datasource/ones.py
Apache-2.0
def triu(m, k=0, gpu=None): """ Upper triangle of a tensor. Return a copy of a matrix with the elements below the `k`-th diagonal zeroed. Please refer to the documentation for `tril` for further details. See Also -------- tril : lower triangle of a tensor Examples -------- ...
Upper triangle of a tensor. Return a copy of a matrix with the elements below the `k`-th diagonal zeroed. Please refer to the documentation for `tril` for further details. See Also -------- tril : lower triangle of a tensor Examples -------- >>> import mars.tensor as mt ...
triu
python
mars-project/mars
mars/tensor/datasource/tri.py
https://github.com/mars-project/mars/blob/master/mars/tensor/datasource/tri.py
Apache-2.0
def tril(m, k=0, gpu=None): """ Lower triangle of a tensor. Return a copy of a tensor with elements above the `k`-th diagonal zeroed. Parameters ---------- m : array_like, shape (M, N) Input tensor. k : int, optional Diagonal above which to zero elements. `k = 0` (the defa...
Lower triangle of a tensor. Return a copy of a tensor with elements above the `k`-th diagonal zeroed. Parameters ---------- m : array_like, shape (M, N) Input tensor. k : int, optional Diagonal above which to zero elements. `k = 0` (the default) is the main diagonal, ...
tril
python
mars-project/mars
mars/tensor/datasource/tri.py
https://github.com/mars-project/mars/blob/master/mars/tensor/datasource/tri.py
Apache-2.0
def zeros(shape, dtype=None, chunk_size=None, gpu=None, sparse=False, order="C"): """ Return a new tensor of given shape and type, filled with zeros. Parameters ---------- shape : int or sequence of ints Shape of the new tensor, e.g., ``(2, 3)`` or ``2``. dtype : data-type, optional ...
Return a new tensor of given shape and type, filled with zeros. Parameters ---------- shape : int or sequence of ints Shape of the new tensor, e.g., ``(2, 3)`` or ``2``. dtype : data-type, optional The desired data-type for the array, e.g., `mt.int8`. Default is `mt.float6...
zeros
python
mars-project/mars
mars/tensor/datasource/zeros.py
https://github.com/mars-project/mars/blob/master/mars/tensor/datasource/zeros.py
Apache-2.0
def zeros_like(a, dtype=None, gpu=None, order="K"): """ Return a tensor of zeros with the same shape and type as a given tensor. Parameters ---------- a : array_like The shape and data-type of `a` define these same attributes of the returned array. dtype : data-type, optional ...
Return a tensor of zeros with the same shape and type as a given tensor. Parameters ---------- a : array_like The shape and data-type of `a` define these same attributes of the returned array. dtype : data-type, optional Overrides the data type of the result. gpu : bool...
zeros_like
python
mars-project/mars
mars/tensor/datasource/zeros.py
https://github.com/mars-project/mars/blob/master/mars/tensor/datasource/zeros.py
Apache-2.0
def einsum( subscripts, *operands, dtype=None, order="K", casting="safe", optimize=False ): """ Evaluates the Einstein summation convention on the operands. Using the Einstein summation convention, many common multi-dimensional, linear algebraic array operations can be represented in a simple fashi...
Evaluates the Einstein summation convention on the operands. Using the Einstein summation convention, many common multi-dimensional, linear algebraic array operations can be represented in a simple fashion. In *implicit* mode `einsum` computes these values. In *explicit* mode, `einsum` provides f...
einsum
python
mars-project/mars
mars/tensor/einsum/core.py
https://github.com/mars-project/mars/blob/master/mars/tensor/einsum/core.py
Apache-2.0
def _flop_count(idx_contraction, inner, num_terms, size_dictionary): """ Computes the number of FLOPS in the contraction. Parameters ---------- idx_contraction : iterable The indices involved in the contraction inner : bool Does this contraction require an inner product? num...
Computes the number of FLOPS in the contraction. Parameters ---------- idx_contraction : iterable The indices involved in the contraction inner : bool Does this contraction require an inner product? num_terms : int The number of terms in a contraction size_dictionar...
_flop_count
python
mars-project/mars
mars/tensor/einsum/einsumfunc.py
https://github.com/mars-project/mars/blob/master/mars/tensor/einsum/einsumfunc.py
Apache-2.0
def _compute_size_by_dict(indices, idx_dict): """ Computes the product of the elements in indices based on the dictionary idx_dict. Parameters ---------- indices : iterable Indices to base the product on. idx_dict : dictionary Dictionary of index sizes Returns -----...
Computes the product of the elements in indices based on the dictionary idx_dict. Parameters ---------- indices : iterable Indices to base the product on. idx_dict : dictionary Dictionary of index sizes Returns ------- ret : int The resulting product. ...
_compute_size_by_dict
python
mars-project/mars
mars/tensor/einsum/einsumfunc.py
https://github.com/mars-project/mars/blob/master/mars/tensor/einsum/einsumfunc.py
Apache-2.0
def _find_contraction(positions, input_sets, output_set): """ Finds the contraction for a given set of input and output sets. Parameters ---------- positions : iterable Integer positions of terms used in the contraction. input_sets : list List of sets that represent the lhs side...
Finds the contraction for a given set of input and output sets. Parameters ---------- positions : iterable Integer positions of terms used in the contraction. input_sets : list List of sets that represent the lhs side of the einsum subscript output_set : set Set that re...
_find_contraction
python
mars-project/mars
mars/tensor/einsum/einsumfunc.py
https://github.com/mars-project/mars/blob/master/mars/tensor/einsum/einsumfunc.py
Apache-2.0
def _update_other_results(results, best): """Update the positions and provisional input_sets of ``results`` based on performing the contraction result ``best``. Remove any involving the tensors contracted. Parameters ---------- results : list List of contraction results produced by ``_p...
Update the positions and provisional input_sets of ``results`` based on performing the contraction result ``best``. Remove any involving the tensors contracted. Parameters ---------- results : list List of contraction results produced by ``_parse_possible_contraction``. best : list ...
_update_other_results
python
mars-project/mars
mars/tensor/einsum/einsumfunc.py
https://github.com/mars-project/mars/blob/master/mars/tensor/einsum/einsumfunc.py
Apache-2.0
def _can_dot(inputs, result, idx_removed): """ Checks if we can use BLAS (np.tensordot) call and its beneficial to do so. Parameters ---------- inputs : list of str Specifies the subscripts for summation. result : str Resulting summation. idx_removed : set Indices th...
Checks if we can use BLAS (np.tensordot) call and its beneficial to do so. Parameters ---------- inputs : list of str Specifies the subscripts for summation. result : str Resulting summation. idx_removed : set Indices that are removed in the summation Returns ...
_can_dot
python
mars-project/mars
mars/tensor/einsum/einsumfunc.py
https://github.com/mars-project/mars/blob/master/mars/tensor/einsum/einsumfunc.py
Apache-2.0
def parse_einsum_input(operands): """ A reproduction of einsum c side einsum parsing in python. Returns ------- input_strings : str Parsed input strings output_string : str Parsed output string operands : list of array_like The operands to use in the numpy contractio...
A reproduction of einsum c side einsum parsing in python. Returns ------- input_strings : str Parsed input strings output_string : str Parsed output string operands : list of array_like The operands to use in the numpy contraction Examples -------- The oper...
parse_einsum_input
python
mars-project/mars
mars/tensor/einsum/einsumfunc.py
https://github.com/mars-project/mars/blob/master/mars/tensor/einsum/einsumfunc.py
Apache-2.0
def einsum_path(*operands, **kwargs): """ einsum_path(subscripts, *operands, optimize='greedy') Evaluates the lowest cost contraction order for an einsum expression by considering the creation of intermediate arrays. Parameters ---------- subscripts : str Specifies the subscripts f...
einsum_path(subscripts, *operands, optimize='greedy') Evaluates the lowest cost contraction order for an einsum expression by considering the creation of intermediate arrays. Parameters ---------- subscripts : str Specifies the subscripts for summation. *operands : list of array_l...
einsum_path
python
mars-project/mars
mars/tensor/einsum/einsumfunc.py
https://github.com/mars-project/mars/blob/master/mars/tensor/einsum/einsumfunc.py
Apache-2.0
def fft2(a, s=None, axes=(-2, -1), norm=None): """ Compute the 2-dimensional discrete Fourier Transform This function computes the *n*-dimensional discrete Fourier Transform over any axes in an *M*-dimensional array by means of the Fast Fourier Transform (FFT). By default, the transform is compute...
Compute the 2-dimensional discrete Fourier Transform This function computes the *n*-dimensional discrete Fourier Transform over any axes in an *M*-dimensional array by means of the Fast Fourier Transform (FFT). By default, the transform is computed over the last two axes of the input array, i.e.,...
fft2
python
mars-project/mars
mars/tensor/fft/fft2.py
https://github.com/mars-project/mars/blob/master/mars/tensor/fft/fft2.py
Apache-2.0
def fftfreq(n, d=1.0, gpu=None, chunk_size=None): """ Return the Discrete Fourier Transform sample frequencies. The returned float tensor `f` contains the frequency bin centers in cycles per unit of the sample spacing (with zero at the start). For instance, if the sample spacing is in seconds, the...
Return the Discrete Fourier Transform sample frequencies. The returned float tensor `f` contains the frequency bin centers in cycles per unit of the sample spacing (with zero at the start). For instance, if the sample spacing is in seconds, then the frequency unit is cycles/second. Given a windo...
fftfreq
python
mars-project/mars
mars/tensor/fft/fftfreq.py
https://github.com/mars-project/mars/blob/master/mars/tensor/fft/fftfreq.py
Apache-2.0
def fftn(a, s=None, axes=None, norm=None): """ Compute the N-dimensional discrete Fourier Transform. This function computes the *N*-dimensional discrete Fourier Transform over any number of axes in an *M*-dimensional tensor by means of the Fast Fourier Transform (FFT). Parameters ---------...
Compute the N-dimensional discrete Fourier Transform. This function computes the *N*-dimensional discrete Fourier Transform over any number of axes in an *M*-dimensional tensor by means of the Fast Fourier Transform (FFT). Parameters ---------- a : array_like Input tensor, can be ...
fftn
python
mars-project/mars
mars/tensor/fft/fftn.py
https://github.com/mars-project/mars/blob/master/mars/tensor/fft/fftn.py
Apache-2.0
def fftshift(x, axes=None): """ Shift the zero-frequency component to the center of the spectrum. This function swaps half-spaces for all axes listed (defaults to all). Note that ``y[0]`` is the Nyquist component only if ``len(x)`` is even. Parameters ---------- x : array_like Inpu...
Shift the zero-frequency component to the center of the spectrum. This function swaps half-spaces for all axes listed (defaults to all). Note that ``y[0]`` is the Nyquist component only if ``len(x)`` is even. Parameters ---------- x : array_like Input tensor. axes : int or shape t...
fftshift
python
mars-project/mars
mars/tensor/fft/fftshift.py
https://github.com/mars-project/mars/blob/master/mars/tensor/fft/fftshift.py
Apache-2.0
def ifft2(a, s=None, axes=(-2, -1), norm=None): """ Compute the 2-dimensional inverse discrete Fourier Transform. This function computes the inverse of the 2-dimensional discrete Fourier Transform over any number of axes in an M-dimensional array by means of the Fast Fourier Transform (FFT). In ot...
Compute the 2-dimensional inverse discrete Fourier Transform. This function computes the inverse of the 2-dimensional discrete Fourier Transform over any number of axes in an M-dimensional array by means of the Fast Fourier Transform (FFT). In other words, ``ifft2(fft2(a)) == a`` to within numeri...
ifft2
python
mars-project/mars
mars/tensor/fft/ifft2.py
https://github.com/mars-project/mars/blob/master/mars/tensor/fft/ifft2.py
Apache-2.0
def ifftshift(x, axes=None): """ The inverse of `fftshift`. Although identical for even-length `x`, the functions differ by one sample for odd-length `x`. Parameters ---------- x : array_like Input tensor. axes : int or shape tuple, optional Axes over which to calculate. De...
The inverse of `fftshift`. Although identical for even-length `x`, the functions differ by one sample for odd-length `x`. Parameters ---------- x : array_like Input tensor. axes : int or shape tuple, optional Axes over which to calculate. Defaults to None, which shifts all axe...
ifftshift
python
mars-project/mars
mars/tensor/fft/ifftshift.py
https://github.com/mars-project/mars/blob/master/mars/tensor/fft/ifftshift.py
Apache-2.0
def irfft2(a, s=None, axes=(-2, -1), norm=None): """ Compute the 2-dimensional inverse FFT of a real array. Parameters ---------- a : array_like The input tensor s : sequence of ints, optional Shape of the inverse FFT. axes : sequence of ints, optional The axes over ...
Compute the 2-dimensional inverse FFT of a real array. Parameters ---------- a : array_like The input tensor s : sequence of ints, optional Shape of the inverse FFT. axes : sequence of ints, optional The axes over which to compute the inverse fft. Default is the...
irfft2
python
mars-project/mars
mars/tensor/fft/irfft2.py
https://github.com/mars-project/mars/blob/master/mars/tensor/fft/irfft2.py
Apache-2.0
def irfftn(a, s=None, axes=None, norm=None): """ Compute the inverse of the N-dimensional FFT of real input. This function computes the inverse of the N-dimensional discrete Fourier Transform for real input over any number of axes in an M-dimensional tensor by means of the Fast Fourier Transform (F...
Compute the inverse of the N-dimensional FFT of real input. This function computes the inverse of the N-dimensional discrete Fourier Transform for real input over any number of axes in an M-dimensional tensor by means of the Fast Fourier Transform (FFT). In other words, ``irfftn(rfftn(a), a.shape...
irfftn
python
mars-project/mars
mars/tensor/fft/irfftn.py
https://github.com/mars-project/mars/blob/master/mars/tensor/fft/irfftn.py
Apache-2.0
def rfft2(a, s=None, axes=(-2, -1), norm=None): """ Compute the 2-dimensional FFT of a real tensor. Parameters ---------- a : array_like Input tensor, taken to be real. s : sequence of ints, optional Shape of the FFT. axes : sequence of ints, optional Axes over which...
Compute the 2-dimensional FFT of a real tensor. Parameters ---------- a : array_like Input tensor, taken to be real. s : sequence of ints, optional Shape of the FFT. axes : sequence of ints, optional Axes over which to compute the FFT. norm : {None, "ortho"}, option...
rfft2
python
mars-project/mars
mars/tensor/fft/rfft2.py
https://github.com/mars-project/mars/blob/master/mars/tensor/fft/rfft2.py
Apache-2.0
def rfftfreq(n, d=1.0, gpu=None, chunk_size=None): """ Return the Discrete Fourier Transform sample frequencies (for usage with rfft, irfft). The returned float tensor `f` contains the frequency bin centers in cycles per unit of the sample spacing (with zero at the start). For instance, if the...
Return the Discrete Fourier Transform sample frequencies (for usage with rfft, irfft). The returned float tensor `f` contains the frequency bin centers in cycles per unit of the sample spacing (with zero at the start). For instance, if the sample spacing is in seconds, then the frequency unit is ...
rfftfreq
python
mars-project/mars
mars/tensor/fft/rfftfreq.py
https://github.com/mars-project/mars/blob/master/mars/tensor/fft/rfftfreq.py
Apache-2.0
def rfftn(a, s=None, axes=None, norm=None): """ Compute the N-dimensional discrete Fourier Transform for real input. This function computes the N-dimensional discrete Fourier Transform over any number of axes in an M-dimensional real tensor by means of the Fast Fourier Transform (FFT). By default,...
Compute the N-dimensional discrete Fourier Transform for real input. This function computes the N-dimensional discrete Fourier Transform over any number of axes in an M-dimensional real tensor by means of the Fast Fourier Transform (FFT). By default, all axes are transformed, with the real transf...
rfftn
python
mars-project/mars
mars/tensor/fft/rfftn.py
https://github.com/mars-project/mars/blob/master/mars/tensor/fft/rfftn.py
Apache-2.0
def compress(condition, a, axis=None, out=None): """ Return selected slices of a tensor along given axis. When working along a given axis, a slice along that axis is returned in `output` for each index where `condition` evaluates to True. When working on a 1-D array, `compress` is equivalent to `ex...
Return selected slices of a tensor along given axis. When working along a given axis, a slice along that axis is returned in `output` for each index where `condition` evaluates to True. When working on a 1-D array, `compress` is equivalent to `extract`. Parameters ---------- condition : 1...
compress
python
mars-project/mars
mars/tensor/indexing/compress.py
https://github.com/mars-project/mars/blob/master/mars/tensor/indexing/compress.py
Apache-2.0
def _process_val(val, a, wrap): """ given the `val`, `a`, `wrap` which are the arguments in `fill_diagonal`, do some preprocess on `val` includes: 1. calculate the length to fill on diagonal, 2-d and n-d(n > 2) as well as that `wrap` is True and `a` is a tall matrix need to b...
given the `val`, `a`, `wrap` which are the arguments in `fill_diagonal`, do some preprocess on `val` includes: 1. calculate the length to fill on diagonal, 2-d and n-d(n > 2) as well as that `wrap` is True and `a` is a tall matrix need to be considered. 2. if val is a Tensor...
_process_val
python
mars-project/mars
mars/tensor/indexing/fill_diagonal.py
https://github.com/mars-project/mars/blob/master/mars/tensor/indexing/fill_diagonal.py
Apache-2.0
def _gen_val(val, diag_idx, cum_sizes): """ Given a tensor-level `val`, calculate the chunk-level `val`. Consider both the cases that `val` could be a tensor or ndarray. :param val: tensor-level `val` :diag_idx: chunk index on the diagonal direction :cum_sizes: accumulat...
Given a tensor-level `val`, calculate the chunk-level `val`. Consider both the cases that `val` could be a tensor or ndarray. :param val: tensor-level `val` :diag_idx: chunk index on the diagonal direction :cum_sizes: accumulative chunk sizes on the diagonal direction
_gen_val
python
mars-project/mars
mars/tensor/indexing/fill_diagonal.py
https://github.com/mars-project/mars/blob/master/mars/tensor/indexing/fill_diagonal.py
Apache-2.0
def fill_diagonal(a, val, wrap=False): """Fill the main diagonal of the given tensor of any dimensionality. For a tensor `a` with ``a.ndim >= 2``, the diagonal is the list of locations with indices ``a[i, ..., i]`` all identical. This function modifies the input tensor in-place, it does not return a va...
Fill the main diagonal of the given tensor of any dimensionality. For a tensor `a` with ``a.ndim >= 2``, the diagonal is the list of locations with indices ``a[i, ..., i]`` all identical. This function modifies the input tensor in-place, it does not return a value. Parameters ---------- a : Te...
fill_diagonal
python
mars-project/mars
mars/tensor/indexing/fill_diagonal.py
https://github.com/mars-project/mars/blob/master/mars/tensor/indexing/fill_diagonal.py
Apache-2.0
def nonzero(a): """ Return the indices of the elements that are non-zero. Returns a tuple of tensors, one for each dimension of `a`, containing the indices of the non-zero elements in that dimension. The values in `a` are always tested and returned. The corresponding non-zero values can be ...
Return the indices of the elements that are non-zero. Returns a tuple of tensors, one for each dimension of `a`, containing the indices of the non-zero elements in that dimension. The values in `a` are always tested and returned. The corresponding non-zero values can be obtained with:: ...
nonzero
python
mars-project/mars
mars/tensor/indexing/nonzero.py
https://github.com/mars-project/mars/blob/master/mars/tensor/indexing/nonzero.py
Apache-2.0
def take(a, indices, axis=None, out=None): """ Take elements from a tensor along an axis. When axis is not None, this function does the same thing as "fancy" indexing (indexing arrays using tensors); however, it can be easier to use if you need elements along a given axis. A call such as ``mt.t...
Take elements from a tensor along an axis. When axis is not None, this function does the same thing as "fancy" indexing (indexing arrays using tensors); however, it can be easier to use if you need elements along a given axis. A call such as ``mt.take(arr, indices, axis=3)`` is equivalent to `...
take
python
mars-project/mars
mars/tensor/indexing/take.py
https://github.com/mars-project/mars/blob/master/mars/tensor/indexing/take.py
Apache-2.0
def unravel_index(indices, dims, order="C"): """ Converts a flat index or tensor of flat indices into a tuple of coordinate tensors. Parameters ---------- indices : array_like An integer tensor whose elements are indices into the flattened version of a tensor of dimensions ``dim...
Converts a flat index or tensor of flat indices into a tuple of coordinate tensors. Parameters ---------- indices : array_like An integer tensor whose elements are indices into the flattened version of a tensor of dimensions ``dims``. dims : tuple of ints The shape of t...
unravel_index
python
mars-project/mars
mars/tensor/indexing/unravel_index.py
https://github.com/mars-project/mars/blob/master/mars/tensor/indexing/unravel_index.py
Apache-2.0
def dot(a, b, out=None, sparse=None): """ Dot product of two arrays. Specifically, - If both `a` and `b` are 1-D arrays, it is inner product of vectors (without complex conjugation). - If both `a` and `b` are 2-D arrays, it is matrix multiplication, but using :func:`matmul` or ``a @ b`` is...
Dot product of two arrays. Specifically, - If both `a` and `b` are 1-D arrays, it is inner product of vectors (without complex conjugation). - If both `a` and `b` are 2-D arrays, it is matrix multiplication, but using :func:`matmul` or ``a @ b`` is preferred. - If either `a` or `b` is 0-...
dot
python
mars-project/mars
mars/tensor/linalg/dot.py
https://github.com/mars-project/mars/blob/master/mars/tensor/linalg/dot.py
Apache-2.0
def inner(a, b, sparse=None): """ Returns the inner product of a and b for arrays of floating point types. Like the generic NumPy equivalent the product sum is over the last dimension of a and b. The first argument is not conjugated. """ a, b = astensor(a), astensor(b) if a.isscalar() and ...
Returns the inner product of a and b for arrays of floating point types. Like the generic NumPy equivalent the product sum is over the last dimension of a and b. The first argument is not conjugated.
inner
python
mars-project/mars
mars/tensor/linalg/inner.py
https://github.com/mars-project/mars/blob/master/mars/tensor/linalg/inner.py
Apache-2.0
def tile(cls, op): """ Use LU decomposition to compute inverse of matrix. Given a square matrix A: P, L, U = lu(A) b_eye is an identity matrix with the same shape as matrix A, then, (P * L * U) * A_inv = b_eye L * (U * A_inv) = P.T * b_eye use `solve_trian...
Use LU decomposition to compute inverse of matrix. Given a square matrix A: P, L, U = lu(A) b_eye is an identity matrix with the same shape as matrix A, then, (P * L * U) * A_inv = b_eye L * (U * A_inv) = P.T * b_eye use `solve_triangular` twice to compute the in...
tile
python
mars-project/mars
mars/tensor/linalg/inv.py
https://github.com/mars-project/mars/blob/master/mars/tensor/linalg/inv.py
Apache-2.0
def inv(a, sparse=None): """ Compute the (multiplicative) inverse of a matrix. Given a square matrix `a`, return the matrix `ainv` satisfying ``dot(a, ainv) = dot(ainv, a) = eye(a.shape[0])``. Parameters ---------- a : (..., M, M) array_like Matrix to be inverted. sparse: bool, ...
Compute the (multiplicative) inverse of a matrix. Given a square matrix `a`, return the matrix `ainv` satisfying ``dot(a, ainv) = dot(ainv, a) = eye(a.shape[0])``. Parameters ---------- a : (..., M, M) array_like Matrix to be inverted. sparse: bool, optional Return sparse v...
inv
python
mars-project/mars
mars/tensor/linalg/inv.py
https://github.com/mars-project/mars/blob/master/mars/tensor/linalg/inv.py
Apache-2.0
def matmul(a, b, sparse=None, out=None, **kw): """ Matrix product of two tensors. The behavior depends on the arguments in the following way. - If both arguments are 2-D they are multiplied like conventional matrices. - If either argument is N-D, N > 2, it is treated as a stack of matr...
Matrix product of two tensors. The behavior depends on the arguments in the following way. - If both arguments are 2-D they are multiplied like conventional matrices. - If either argument is N-D, N > 2, it is treated as a stack of matrices residing in the last two indexes and broadcast ac...
matmul
python
mars-project/mars
mars/tensor/linalg/matmul.py
https://github.com/mars-project/mars/blob/master/mars/tensor/linalg/matmul.py
Apache-2.0
def norm(x, ord=None, axis=None, keepdims=False): r""" Matrix or vector norm. This function is able to return one of eight different matrix norms, or one of an infinite number of vector norms (described below), depending on the value of the ``ord`` parameter. Parameters ---------- x : ...
Matrix or vector norm. This function is able to return one of eight different matrix norms, or one of an infinite number of vector norms (described below), depending on the value of the ``ord`` parameter. Parameters ---------- x : array_like Input tensor. If `axis` is None, `x` m...
norm
python
mars-project/mars
mars/tensor/linalg/norm.py
https://github.com/mars-project/mars/blob/master/mars/tensor/linalg/norm.py
Apache-2.0
def randomized_range_finder( A, size, n_iter, power_iteration_normalizer="auto", random_state=None ): r"""Computes an orthonormal matrix whose range approximates the range of A. .. versionadded:: 0.1.3 Parameters ---------- A : 2D tensor The input data tensor size : integer ...
Computes an orthonormal matrix whose range approximates the range of A. .. versionadded:: 0.1.3 Parameters ---------- A : 2D tensor The input data tensor size : integer Size of the return tensor n_iter : integer Number of power iterations used to stabilize the result ...
randomized_range_finder
python
mars-project/mars
mars/tensor/linalg/randomized_svd.py
https://github.com/mars-project/mars/blob/master/mars/tensor/linalg/randomized_svd.py
Apache-2.0
def randomized_svd( M, n_components, n_oversamples=10, n_iter="auto", power_iteration_normalizer="auto", transpose="auto", flip_sign=True, random_state=0, ): r""" Computes a truncated randomized SVD .. versionadded:: 0.1.4 Parameters ---------- M : Tensor ...
Computes a truncated randomized SVD .. versionadded:: 0.1.4 Parameters ---------- M : Tensor tensor to decompose n_components : int Number of singular values and vectors to extract. n_oversamples : int (default is 10) Additional number of random vectors to sample t...
randomized_svd
python
mars-project/mars
mars/tensor/linalg/randomized_svd.py
https://github.com/mars-project/mars/blob/master/mars/tensor/linalg/randomized_svd.py
Apache-2.0
def solve(a, b, sym_pos=False, sparse=None): """ Solve the equation ``a x = b`` for ``x``. Parameters ---------- a : (M, M) array_like A square matrix. b : (M,) or (M, N) array_like Right-hand side matrix in ``a x = b``. sym_pos : bool Assume `a` is symmetric and pos...
Solve the equation ``a x = b`` for ``x``. Parameters ---------- a : (M, M) array_like A square matrix. b : (M,) or (M, N) array_like Right-hand side matrix in ``a x = b``. sym_pos : bool Assume `a` is symmetric and positive definite. If ``True``, use Cholesky de...
solve
python
mars-project/mars
mars/tensor/linalg/solve.py
https://github.com/mars-project/mars/blob/master/mars/tensor/linalg/solve.py
Apache-2.0
def solve_triangular(a, b, lower=False, sparse=None): """ Solve the equation `a x = b` for `x`, assuming a is a triangular matrix. Parameters ---------- a : (M, M) array_like A triangular matrix b : (M,) or (M, N) array_like Right-hand side matrix in `a x = b` lower : bool, ...
Solve the equation `a x = b` for `x`, assuming a is a triangular matrix. Parameters ---------- a : (M, M) array_like A triangular matrix b : (M,) or (M, N) array_like Right-hand side matrix in `a x = b` lower : bool, optional Use only data contained in the lower triangl...
solve_triangular
python
mars-project/mars
mars/tensor/linalg/solve_triangular.py
https://github.com/mars-project/mars/blob/master/mars/tensor/linalg/solve_triangular.py
Apache-2.0
def tensordot(a, b, axes=2, sparse=None): """ Compute tensor dot product along specified axes for tensors >= 1-D. Given two tensors (arrays of dimension greater than or equal to one), `a` and `b`, and an array_like object containing two array_like objects, ``(a_axes, b_axes)``, sum the products of ...
Compute tensor dot product along specified axes for tensors >= 1-D. Given two tensors (arrays of dimension greater than or equal to one), `a` and `b`, and an array_like object containing two array_like objects, ``(a_axes, b_axes)``, sum the products of `a`'s and `b`'s elements (components) over th...
tensordot
python
mars-project/mars
mars/tensor/linalg/tensordot.py
https://github.com/mars-project/mars/blob/master/mars/tensor/linalg/tensordot.py
Apache-2.0
def calc_svd_shapes(a): """ Calculate output shapes of singular value decomposition. Follow the behavior of `numpy`: if a's shape is (6, 18), U's shape is (6, 6), s's shape is (6,), V's shape is (6, 18) if a's shape is (18, 6), U's shape is (18, 6), s's shape is (6,), V's shape is (6, 6) :param ...
Calculate output shapes of singular value decomposition. Follow the behavior of `numpy`: if a's shape is (6, 18), U's shape is (6, 6), s's shape is (6,), V's shape is (6, 18) if a's shape is (18, 6), U's shape is (18, 6), s's shape is (6,), V's shape is (6, 6) :param a: input tensor :return: (U...
calc_svd_shapes
python
mars-project/mars
mars/tensor/linalg/utils.py
https://github.com/mars-project/mars/blob/master/mars/tensor/linalg/utils.py
Apache-2.0
def svd_flip(u, v, u_based_decision=True): """ Sign correction to ensure deterministic output from SVD. Adjusts the columns of u and the rows of v such that the loadings in the columns in u that are largest in absolute value are always positive. Parameters ---------- u : Tensor u a...
Sign correction to ensure deterministic output from SVD. Adjusts the columns of u and the rows of v such that the loadings in the columns in u that are largest in absolute value are always positive. Parameters ---------- u : Tensor u and v are the output of `linalg.svd` or `ra...
svd_flip
python
mars-project/mars
mars/tensor/linalg/utils.py
https://github.com/mars-project/mars/blob/master/mars/tensor/linalg/utils.py
Apache-2.0
def vdot(a, b): """ Return the dot product of two vectors. The vdot(`a`, `b`) function handles complex numbers differently than dot(`a`, `b`). If the first argument is complex the complex conjugate of the first argument is used for the calculation of the dot product. Note that `vdot` handles ...
Return the dot product of two vectors. The vdot(`a`, `b`) function handles complex numbers differently than dot(`a`, `b`). If the first argument is complex the complex conjugate of the first argument is used for the calculation of the dot product. Note that `vdot` handles multidimensional tensor...
vdot
python
mars-project/mars
mars/tensor/linalg/vdot.py
https://github.com/mars-project/mars/blob/master/mars/tensor/linalg/vdot.py
Apache-2.0
def append(arr, values, axis=None): """ Append values to the end of an array. 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 ...
Append values to the end of an array. 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 ...
append
python
mars-project/mars
mars/tensor/merge/append.py
https://github.com/mars-project/mars/blob/master/mars/tensor/merge/append.py
Apache-2.0
def _block_format_index(index): """ Convert a list of indices ``[0, 1, 2]`` into ``"arrays[0][1][2]"``. """ idx_str = "".join("[{}]".format(i) for i in index if i is not None) return "arrays" + idx_str
Convert a list of indices ``[0, 1, 2]`` into ``"arrays[0][1][2]"``.
_block_format_index
python
mars-project/mars
mars/tensor/merge/block.py
https://github.com/mars-project/mars/blob/master/mars/tensor/merge/block.py
Apache-2.0
def _block_check_depths_match(arrays, parent_index=[]): """ Recursive function checking that the depths of nested lists in `arrays` all match. Mismatch raises a ValueError as described in the block docstring below. The entire index (rather than just the depth) needs to be calculated for each in...
Recursive function checking that the depths of nested lists in `arrays` all match. Mismatch raises a ValueError as described in the block docstring below. The entire index (rather than just the depth) needs to be calculated for each innermost list, in case an error needs to be raised, so that ...
_block_check_depths_match
python
mars-project/mars
mars/tensor/merge/block.py
https://github.com/mars-project/mars/blob/master/mars/tensor/merge/block.py
Apache-2.0
def _concatenate_shapes(shapes, axis): """Given array shapes, return the resulting shape and slices prefixes. These help in nested concatenation. Returns ------- shape: tuple of int This tuple satisfies: ``` shape, _ = _concatenate_shapes([arr.shape for shape in arrs], axis)...
Given array shapes, return the resulting shape and slices prefixes. These help in nested concatenation. Returns ------- shape: tuple of int This tuple satisfies: ``` shape, _ = _concatenate_shapes([arr.shape for shape in arrs], axis) shape == concatenate(arrs, axis).shap...
_concatenate_shapes
python
mars-project/mars
mars/tensor/merge/block.py
https://github.com/mars-project/mars/blob/master/mars/tensor/merge/block.py
Apache-2.0
def _block_info_recursion(arrays, max_depth, result_ndim, depth=0): """ Returns the shape of the final array, along with a list of slices and a list of arrays that can be used for assignment inside the new array Parameters ---------- arrays : nested list of arrays The arrays to chec...
Returns the shape of the final array, along with a list of slices and a list of arrays that can be used for assignment inside the new array Parameters ---------- arrays : nested list of arrays The arrays to check max_depth : list of int The number of nested lists result...
_block_info_recursion
python
mars-project/mars
mars/tensor/merge/block.py
https://github.com/mars-project/mars/blob/master/mars/tensor/merge/block.py
Apache-2.0
def _block(arrays, max_depth, result_ndim, depth=0): """ Internal implementation of block based on repeated concatenation. `arrays` is the argument passed to block. `max_depth` is the depth of nested lists within `arrays` and `result_ndim` is the greatest of the dimensions of the arrays in `arra...
Internal implementation of block based on repeated concatenation. `arrays` is the argument passed to block. `max_depth` is the depth of nested lists within `arrays` and `result_ndim` is the greatest of the dimensions of the arrays in `arrays` and the depth of the lists in `arrays` (see block docstr...
_block
python
mars-project/mars
mars/tensor/merge/block.py
https://github.com/mars-project/mars/blob/master/mars/tensor/merge/block.py
Apache-2.0
def block(arrays): """ Assemble an nd-array from nested lists of blocks. Blocks in the innermost lists are concatenated (see `concatenate`) along the last dimension (-1), then these are concatenated along the second-last dimension (-2), and so on until the outermost list is reached. Blocks can...
Assemble an nd-array from nested lists of blocks. Blocks in the innermost lists are concatenated (see `concatenate`) along the last dimension (-1), then these are concatenated along the second-last dimension (-2), and so on until the outermost list is reached. Blocks can be of any dimension, but ...
block
python
mars-project/mars
mars/tensor/merge/block.py
https://github.com/mars-project/mars/blob/master/mars/tensor/merge/block.py
Apache-2.0
def column_stack(tup): """ Stack 1-D tensors as columns into a 2-D tensor. Take a sequence of 1-D tensors and stack them as columns to make a single 2-D tensor. 2-D tensors are stacked as-is, just like with `hstack`. 1-D tensors are turned into 2-D columns first. Parameters ----------...
Stack 1-D tensors as columns into a 2-D tensor. Take a sequence of 1-D tensors and stack them as columns to make a single 2-D tensor. 2-D tensors are stacked as-is, just like with `hstack`. 1-D tensors are turned into 2-D columns first. Parameters ---------- tup : sequence of 1-D or ...
column_stack
python
mars-project/mars
mars/tensor/merge/column_stack.py
https://github.com/mars-project/mars/blob/master/mars/tensor/merge/column_stack.py
Apache-2.0
def concatenate(tensors, axis=0): """ Join a sequence of arrays along an existing axis. Parameters ---------- a1, a2, ... : sequence of array_like The tensors must have the same shape, except in the dimension corresponding to `axis` (the first, by default). axis : int, optional ...
Join a sequence of arrays along an existing axis. Parameters ---------- a1, a2, ... : sequence of array_like The tensors must have the same shape, except in the dimension corresponding to `axis` (the first, by default). axis : int, optional The axis along which the tensors ...
concatenate
python
mars-project/mars
mars/tensor/merge/concatenate.py
https://github.com/mars-project/mars/blob/master/mars/tensor/merge/concatenate.py
Apache-2.0
def hstack(tup): """ Stack tensors in sequence horizontally (column wise). This is equivalent to concatenation along the second axis, except for 1-D tensors where it concatenates along the first axis. Rebuilds tensors divided by `hsplit`. This function makes most sense for tensors with up to 3...
Stack tensors in sequence horizontally (column wise). This is equivalent to concatenation along the second axis, except for 1-D tensors where it concatenates along the first axis. Rebuilds tensors divided by `hsplit`. This function makes most sense for tensors with up to 3 dimensions. For ins...
hstack
python
mars-project/mars
mars/tensor/merge/hstack.py
https://github.com/mars-project/mars/blob/master/mars/tensor/merge/hstack.py
Apache-2.0
def stack(tensors, axis=0, out=None): """ Join a sequence of tensors along a new axis. The `axis` parameter specifies the index of the new axis in the dimensions of the result. For example, if ``axis=0`` it will be the first dimension and if ``axis=-1`` it will be the last dimension. Parameter...
Join a sequence of tensors along a new axis. The `axis` parameter specifies the index of the new axis in the dimensions of the result. For example, if ``axis=0`` it will be the first dimension and if ``axis=-1`` it will be the last dimension. Parameters ---------- tensors : sequence of ar...
stack
python
mars-project/mars
mars/tensor/merge/stack.py
https://github.com/mars-project/mars/blob/master/mars/tensor/merge/stack.py
Apache-2.0
def union1d(ar1, ar2, aggregate_size=None): """ Find the union of two tensors. Return the unique, sorted tensor of values that are in either of the two input tensors. Parameters ---------- ar1, ar2 : array_like Input tensors. They are flattened if they are not already 1D. Retu...
Find the union of two tensors. Return the unique, sorted tensor of values that are in either of the two input tensors. Parameters ---------- ar1, ar2 : array_like Input tensors. They are flattened if they are not already 1D. Returns ------- union1d : Tensor Unique...
union1d
python
mars-project/mars
mars/tensor/merge/union1d.py
https://github.com/mars-project/mars/blob/master/mars/tensor/merge/union1d.py
Apache-2.0
def beta(random_state, a, b, size=None, chunk_size=None, gpu=None, dtype=None): r""" Draw samples from a Beta distribution. The Beta distribution is a special case of the Dirichlet distribution, and is related to the Gamma distribution. It has the probability distribution function .. math:: f...
Draw samples from a Beta distribution. The Beta distribution is a special case of the Dirichlet distribution, and is related to the Gamma distribution. It has the probability distribution function .. math:: f(x; a,b) = \frac{1}{B(\alpha, \beta)} x^{\alpha - 1} ...
beta
python
mars-project/mars
mars/tensor/random/beta.py
https://github.com/mars-project/mars/blob/master/mars/tensor/random/beta.py
Apache-2.0
def binomial(random_state, n, p, size=None, chunk_size=None, gpu=None, dtype=None): r""" Draw samples from a binomial distribution. Samples are drawn from a binomial distribution with specified parameters, n trials and p probability of success where n an integer >= 0 and p is in the interval [0,1]....
Draw samples from a binomial distribution. Samples are drawn from a binomial distribution with specified parameters, n trials and p probability of success where n an integer >= 0 and p is in the interval [0,1]. (n may be input as a float, but it is truncated to an integer in use) Parameters ...
binomial
python
mars-project/mars
mars/tensor/random/binomial.py
https://github.com/mars-project/mars/blob/master/mars/tensor/random/binomial.py
Apache-2.0
def chisquare(random_state, df, size=None, chunk_size=None, gpu=None, dtype=None): r""" Draw samples from a chi-square distribution. When `df` independent random variables, each with standard normal distributions (mean 0, variance 1), are squared and summed, the resulting distribution is chi-square...
Draw samples from a chi-square distribution. When `df` independent random variables, each with standard normal distributions (mean 0, variance 1), are squared and summed, the resulting distribution is chi-square (see Notes). This distribution is often used in hypothesis testing. Parameters ...
chisquare
python
mars-project/mars
mars/tensor/random/chisquare.py
https://github.com/mars-project/mars/blob/master/mars/tensor/random/chisquare.py
Apache-2.0
def choice(random_state, a, size=None, replace=True, p=None, chunk_size=None, gpu=None): """ Generates a random sample from a given 1-D array Parameters ----------- a : 1-D array-like or int If a tensor, a random sample is generated from its elements. If an int, the random sample is...
Generates a random sample from a given 1-D array Parameters ----------- a : 1-D array-like or int If a tensor, a random sample is generated from its elements. If an int, the random sample is generated as if a were mt.arange(a) size : int or tuple of ints, optional Output sh...
choice
python
mars-project/mars
mars/tensor/random/choice.py
https://github.com/mars-project/mars/blob/master/mars/tensor/random/choice.py
Apache-2.0
def dirichlet(random_state, alpha, size=None, chunk_size=None, gpu=None, dtype=None): r""" Draw samples from the Dirichlet distribution. Draw `size` samples of dimension k from a Dirichlet distribution. A Dirichlet-distributed random variable can be seen as a multivariate generalization of a Beta d...
Draw samples from the Dirichlet distribution. Draw `size` samples of dimension k from a Dirichlet distribution. A Dirichlet-distributed random variable can be seen as a multivariate generalization of a Beta distribution. Dirichlet pdf is the conjugate prior of a multinomial in Bayesian inference. ...
dirichlet
python
mars-project/mars
mars/tensor/random/dirichlet.py
https://github.com/mars-project/mars/blob/master/mars/tensor/random/dirichlet.py
Apache-2.0
def exponential( random_state, scale=1.0, size=None, chunk_size=None, gpu=None, dtype=None ): r""" Draw samples from an exponential distribution. Its probability density function is .. math:: f(x; \frac{1}{\beta}) = \frac{1}{\beta} \exp(-\frac{x}{\beta}), for ``x > 0`` and 0 elsewhere. :math:...
Draw samples from an exponential distribution. Its probability density function is .. math:: f(x; \frac{1}{\beta}) = \frac{1}{\beta} \exp(-\frac{x}{\beta}), for ``x > 0`` and 0 elsewhere. :math:`\beta` is the scale parameter, which is the inverse of the rate parameter :math:`\lambda = 1/\beta`. ...
exponential
python
mars-project/mars
mars/tensor/random/exponential.py
https://github.com/mars-project/mars/blob/master/mars/tensor/random/exponential.py
Apache-2.0
def f(random_state, dfnum, dfden, size=None, chunk_size=None, gpu=None, dtype=None): """ Draw samples from an F distribution. Samples are drawn from an F distribution with specified parameters, `dfnum` (degrees of freedom in numerator) and `dfden` (degrees of freedom in denominator), where both par...
Draw samples from an F distribution. Samples are drawn from an F distribution with specified parameters, `dfnum` (degrees of freedom in numerator) and `dfden` (degrees of freedom in denominator), where both parameters should be greater than zero. The random variate of the F distribution (also...
f
python
mars-project/mars
mars/tensor/random/f.py
https://github.com/mars-project/mars/blob/master/mars/tensor/random/f.py
Apache-2.0
def gamma( random_state, shape, scale=1.0, size=None, chunk_size=None, gpu=None, dtype=None ): r""" Draw samples from a Gamma distribution. Samples are drawn from a Gamma distribution with specified parameters, `shape` (sometimes designated "k") and `scale` (sometimes designated "theta"), where...
Draw samples from a Gamma distribution. Samples are drawn from a Gamma distribution with specified parameters, `shape` (sometimes designated "k") and `scale` (sometimes designated "theta"), where both parameters are > 0. Parameters ---------- shape : float or array_like of floats ...
gamma
python
mars-project/mars
mars/tensor/random/gamma.py
https://github.com/mars-project/mars/blob/master/mars/tensor/random/gamma.py
Apache-2.0
def geometric(random_state, p, size=None, chunk_size=None, gpu=None, dtype=None): """ Draw samples from the geometric distribution. Bernoulli trials are experiments with one of two outcomes: success or failure (an example of such an experiment is flipping a coin). The geometric distribution models...
Draw samples from the geometric distribution. Bernoulli trials are experiments with one of two outcomes: success or failure (an example of such an experiment is flipping a coin). The geometric distribution models the number of trials that must be run in order to achieve success. It is therefore ...
geometric
python
mars-project/mars
mars/tensor/random/geometric.py
https://github.com/mars-project/mars/blob/master/mars/tensor/random/geometric.py
Apache-2.0
def gumbel( random_state, loc=0.0, scale=1.0, size=None, chunk_size=None, gpu=None, dtype=None ): r""" Draw samples from a Gumbel distribution. Draw samples from a Gumbel distribution with specified location and scale. For more information on the Gumbel distribution, see Notes and References b...
Draw samples from a Gumbel distribution. Draw samples from a Gumbel distribution with specified location and scale. For more information on the Gumbel distribution, see Notes and References below. Parameters ---------- loc : float or array_like of floats, optional The location of...
gumbel
python
mars-project/mars
mars/tensor/random/gumbel.py
https://github.com/mars-project/mars/blob/master/mars/tensor/random/gumbel.py
Apache-2.0
def hypergeometric( random_state, ngood, nbad, nsample, size=None, chunk_size=None, gpu=None, dtype=None ): r""" Draw samples from a Hypergeometric distribution. Samples are drawn from a hypergeometric distribution with specified parameters, ngood (ways to make a good selection), nbad (ways to make...
Draw samples from a Hypergeometric distribution. Samples are drawn from a hypergeometric distribution with specified parameters, ngood (ways to make a good selection), nbad (ways to make a bad selection), and nsample = number of items sampled, which is less than or equal to the sum ngood + nbad. ...
hypergeometric
python
mars-project/mars
mars/tensor/random/hypergeometric.py
https://github.com/mars-project/mars/blob/master/mars/tensor/random/hypergeometric.py
Apache-2.0
def laplace( random_state, loc=0.0, scale=1.0, size=None, chunk_size=None, gpu=None, dtype=None ): r""" Draw samples from the Laplace or double exponential distribution with specified location (or mean) and scale (decay). The Laplace distribution is similar to the Gaussian/normal distribution, ...
Draw samples from the Laplace or double exponential distribution with specified location (or mean) and scale (decay). The Laplace distribution is similar to the Gaussian/normal distribution, but is sharper at the peak and has fatter tails. It represents the difference between two independent, iden...
laplace
python
mars-project/mars
mars/tensor/random/laplace.py
https://github.com/mars-project/mars/blob/master/mars/tensor/random/laplace.py
Apache-2.0
def logistic( random_state, loc=0.0, scale=1.0, size=None, chunk_size=None, gpu=None, dtype=None ): r""" Draw samples from a logistic distribution. Samples are drawn from a logistic distribution with specified parameters, loc (location or mean, also median), and scale (>0). Parameters ----...
Draw samples from a logistic distribution. Samples are drawn from a logistic distribution with specified parameters, loc (location or mean, also median), and scale (>0). Parameters ---------- loc : float or array_like of floats, optional Parameter of the distribution. Default is 0. ...
logistic
python
mars-project/mars
mars/tensor/random/logistic.py
https://github.com/mars-project/mars/blob/master/mars/tensor/random/logistic.py
Apache-2.0
def lognormal( random_state, mean=0.0, sigma=1.0, size=None, chunk_size=None, gpu=None, dtype=None ): r""" Draw samples from a log-normal distribution. Draw samples from a log-normal distribution with specified mean, standard deviation, and array shape. Note that the mean and standard deviatio...
Draw samples from a log-normal distribution. Draw samples from a log-normal distribution with specified mean, standard deviation, and array shape. Note that the mean and standard deviation are not the values for the distribution itself, but of the underlying normal distribution it is derived from...
lognormal
python
mars-project/mars
mars/tensor/random/lognormal.py
https://github.com/mars-project/mars/blob/master/mars/tensor/random/lognormal.py
Apache-2.0
def logseries(random_state, p, size=None, chunk_size=None, gpu=None, dtype=None): r""" Draw samples from a logarithmic series distribution. Samples are drawn from a log series distribution with specified shape parameter, 0 < ``p`` < 1. Parameters ---------- p : float or array_like of float...
Draw samples from a logarithmic series distribution. Samples are drawn from a log series distribution with specified shape parameter, 0 < ``p`` < 1. Parameters ---------- p : float or array_like of floats Shape parameter for the distribution. Must be in the range (0, 1). size : i...
logseries
python
mars-project/mars
mars/tensor/random/logseries.py
https://github.com/mars-project/mars/blob/master/mars/tensor/random/logseries.py
Apache-2.0
def multinomial( random_state, n, pvals, size=None, chunk_size=None, gpu=None, dtype=None ): """ Draw samples from a multinomial distribution. The multinomial distribution is a multivariate generalisation of the binomial distribution. Take an experiment with one of ``p`` possible outcomes. An...
Draw samples from a multinomial distribution. The multinomial distribution is a multivariate generalisation of the binomial distribution. Take an experiment with one of ``p`` possible outcomes. An example of such an experiment is throwing a dice, where the outcome can be 1 through 6. Each sampl...
multinomial
python
mars-project/mars
mars/tensor/random/multinomial.py
https://github.com/mars-project/mars/blob/master/mars/tensor/random/multinomial.py
Apache-2.0
def multivariate_normal( random_state, mean, cov, size=None, check_valid=None, tol=None, chunk_size=None, gpu=None, dtype=None, ): """ Draw random samples from a multivariate normal distribution. The multivariate normal, multinormal or Gaussian distribution is a gene...
Draw random samples from a multivariate normal distribution. The multivariate normal, multinormal or Gaussian distribution is a generalization of the one-dimensional normal distribution to higher dimensions. Such a distribution is specified by its mean and covariance matrix. These parameters are...
multivariate_normal
python
mars-project/mars
mars/tensor/random/multivariate_normal.py
https://github.com/mars-project/mars/blob/master/mars/tensor/random/multivariate_normal.py
Apache-2.0
def negative_binomial( random_state, n, p, size=None, chunk_size=None, gpu=None, dtype=None ): r""" Draw samples from a negative binomial distribution. Samples are drawn from a negative binomial distribution with specified parameters, `n` trials and `p` probability of success where `n` is an in...
Draw samples from a negative binomial distribution. Samples are drawn from a negative binomial distribution with specified parameters, `n` trials and `p` probability of success where `n` is an integer > 0 and `p` is in the interval [0, 1]. Parameters ---------- n : int or array_like of in...
negative_binomial
python
mars-project/mars
mars/tensor/random/negative_binomial.py
https://github.com/mars-project/mars/blob/master/mars/tensor/random/negative_binomial.py
Apache-2.0
def noncentral_chisquare( random_state, df, nonc, size=None, chunk_size=None, gpu=None, dtype=None ): r""" Draw samples from a noncentral chi-square distribution. The noncentral :math:`\chi^2` distribution is a generalisation of the :math:`\chi^2` distribution. Parameters ---------- df...
Draw samples from a noncentral chi-square distribution. The noncentral :math:`\chi^2` distribution is a generalisation of the :math:`\chi^2` distribution. Parameters ---------- df : float or array_like of floats Degrees of freedom, should be > 0. nonc : float or array_like of floa...
noncentral_chisquare
python
mars-project/mars
mars/tensor/random/noncentral_chisquare.py
https://github.com/mars-project/mars/blob/master/mars/tensor/random/noncentral_chisquare.py
Apache-2.0
def noncentral_f( random_state, dfnum, dfden, nonc, size=None, chunk_size=None, gpu=None, dtype=None ): """ Draw samples from the noncentral F distribution. Samples are drawn from an F distribution with specified parameters, `dfnum` (degrees of freedom in numerator) and `dfden` (degrees of free...
Draw samples from the noncentral F distribution. Samples are drawn from an F distribution with specified parameters, `dfnum` (degrees of freedom in numerator) and `dfden` (degrees of freedom in denominator), where both parameters > 1. `nonc` is the non-centrality parameter. Parameters ---...
noncentral_f
python
mars-project/mars
mars/tensor/random/noncentral_f.py
https://github.com/mars-project/mars/blob/master/mars/tensor/random/noncentral_f.py
Apache-2.0
def pareto(random_state, a, size=None, chunk_size=None, gpu=None, dtype=None): r""" Draw samples from a Pareto II or Lomax distribution with specified shape. The Lomax or Pareto II distribution is a shifted Pareto distribution. The classical Pareto distribution can be obtained from the Lomax di...
Draw samples from a Pareto II or Lomax distribution with specified shape. The Lomax or Pareto II distribution is a shifted Pareto distribution. The classical Pareto distribution can be obtained from the Lomax distribution by adding 1 and multiplying by the scale parameter ``m`` (see Notes). T...
pareto
python
mars-project/mars
mars/tensor/random/pareto.py
https://github.com/mars-project/mars/blob/master/mars/tensor/random/pareto.py
Apache-2.0
def permutation(random_state, x, axis=0, chunk_size=None): r""" Randomly permute a sequence, or return a permuted range. Parameters ---------- x : int or array_like If `x` is an integer, randomly permute ``mt.arange(x)``. If `x` is an array, make a copy and shuffle the elements ...
Randomly permute a sequence, or return a permuted range. Parameters ---------- x : int or array_like If `x` is an integer, randomly permute ``mt.arange(x)``. If `x` is an array, make a copy and shuffle the elements randomly. axis : int, optional The axis which `x` i...
permutation
python
mars-project/mars
mars/tensor/random/permutation.py
https://github.com/mars-project/mars/blob/master/mars/tensor/random/permutation.py
Apache-2.0
def power(random_state, a, size=None, chunk_size=None, gpu=None, dtype=None): r""" Draws samples in [0, 1] from a power distribution with positive exponent a - 1. Also known as the power function distribution. Parameters ---------- a : float or array_like of floats Parameter of the...
Draws samples in [0, 1] from a power distribution with positive exponent a - 1. Also known as the power function distribution. Parameters ---------- a : float or array_like of floats Parameter of the distribution. Should be greater than zero. size : int or tuple of ints, optional ...
power
python
mars-project/mars
mars/tensor/random/power.py
https://github.com/mars-project/mars/blob/master/mars/tensor/random/power.py
Apache-2.0
def rand(random_state, *dn, **kw): """ Random values in a given shape. Create a tensor of the given shape and populate it with random samples from a uniform distributionc over ``[0, 1)``. Parameters ---------- d0, d1, ..., dn : int, optional The dimensions of the returned tenso...
Random values in a given shape. Create a tensor of the given shape and populate it with random samples from a uniform distributionc over ``[0, 1)``. Parameters ---------- d0, d1, ..., dn : int, optional The dimensions of the returned tensor, should all be positive. If no a...
rand
python
mars-project/mars
mars/tensor/random/rand.py
https://github.com/mars-project/mars/blob/master/mars/tensor/random/rand.py
Apache-2.0
def randn(random_state, *dn, **kw): r""" Return a sample (or samples) from the "standard normal" distribution. If positive, int_like or int-convertible arguments are provided, `randn` generates an array of shape ``(d0, d1, ..., dn)``, filled with random floats sampled from a univariate "normal" (Ga...
Return a sample (or samples) from the "standard normal" distribution. If positive, int_like or int-convertible arguments are provided, `randn` generates an array of shape ``(d0, d1, ..., dn)``, filled with random floats sampled from a univariate "normal" (Gaussian) distribution of mean 0 and varia...
randn
python
mars-project/mars
mars/tensor/random/randn.py
https://github.com/mars-project/mars/blob/master/mars/tensor/random/randn.py
Apache-2.0
def random_sample(random_state, size=None, chunk_size=None, gpu=None, dtype=None): """ Return random floats in the half-open interval [0.0, 1.0). Results are from the "continuous uniform" distribution over the stated interval. To sample :math:`Unif[a, b), b > a` multiply the output of `random_samp...
Return random floats in the half-open interval [0.0, 1.0). Results are from the "continuous uniform" distribution over the stated interval. To sample :math:`Unif[a, b), b > a` multiply the output of `random_sample` by `(b-a)` and add `a`:: (b - a) * random_sample() + a Parameters ----...
random_sample
python
mars-project/mars
mars/tensor/random/random_sample.py
https://github.com/mars-project/mars/blob/master/mars/tensor/random/random_sample.py
Apache-2.0