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 fix(x, out=None, **kwargs):
"""
Round to nearest integer towards zero.
Round a tensor of floats element-wise to nearest integer towards zero.
The rounded values are returned as floats.
Parameters
----------
x : array_like
An tensor of floats to be rounded
out : Tensor, op... |
Round to nearest integer towards zero.
Round a tensor of floats element-wise to nearest integer towards zero.
The rounded values are returned as floats.
Parameters
----------
x : array_like
An tensor of floats to be rounded
out : Tensor, optional
Output tensor
Retur... | fix | python | mars-project/mars | mars/tensor/arithmetic/fix.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/fix.py | Apache-2.0 |
def float_power(x1, x2, out=None, where=None, **kwargs):
"""
First tensor elements raised to powers from second array, element-wise.
Raise each base in `x1` to the positionally-corresponding power in `x2`.
`x1` and `x2` must be broadcastable to the same shape. This differs from
the power function i... |
First tensor elements raised to powers from second array, element-wise.
Raise each base in `x1` to the positionally-corresponding 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
float... | float_power | python | mars-project/mars | mars/tensor/arithmetic/float_power.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/float_power.py | Apache-2.0 |
def floor(x, out=None, where=None, **kwargs):
r"""
Return the floor of the input, element-wise.
The floor of the scalar `x` is the largest integer `i`, such that
`i <= x`. It is often denoted as :math:`\lfloor x \rfloor`.
Parameters
----------
x : array_like
Input data.
out : ... |
Return the floor of the input, element-wise.
The floor of the scalar `x` is the largest integer `i`, such that
`i <= x`. It is often denoted as :math:`\lfloor x \rfloor`.
Parameters
----------
x : array_like
Input data.
out : Tensor, None, or tuple of Tensor and None, optional
... | floor | python | mars-project/mars | mars/tensor/arithmetic/floor.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/floor.py | Apache-2.0 |
def floordiv(x1, x2, out=None, where=None, **kwargs):
"""
Return the largest integer smaller or equal to the division of the inputs.
It is equivalent to the Python ``//`` operator and pairs with the
Python ``%`` (`remainder`), function so that ``b = a % b + b * (a // b)``
up to roundoff.
Parame... |
Return the largest integer smaller or equal to the division of the inputs.
It is equivalent to the Python ``//`` operator and pairs with the
Python ``%`` (`remainder`), function so that ``b = a % b + b * (a // b)``
up to roundoff.
Parameters
----------
x1 : array_like
Numerator.
... | floordiv | python | mars-project/mars | mars/tensor/arithmetic/floordiv.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/floordiv.py | Apache-2.0 |
def fmax(x1, x2, out=None, where=None, **kwargs):
"""
Element-wise maximum of array elements.
Compare two tensors and returns a new tensor containing the element-wise
maxima. If one of the elements being compared is a NaN, then the
non-nan element is returned. If both elements are NaNs then the fir... |
Element-wise maximum of array elements.
Compare two tensors and returns a new tensor containing the element-wise
maxima. If one of the elements being compared is a NaN, then the
non-nan element is returned. If both elements are NaNs then the first
is returned. The latter distinction is important ... | fmax | python | mars-project/mars | mars/tensor/arithmetic/fmax.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/fmax.py | Apache-2.0 |
def fmin(x1, x2, out=None, where=None, **kwargs):
"""
Element-wise minimum of array elements.
Compare two tensors and returns a new tensor containing the element-wise
minima. If one of the elements being compared is a NaN, then the
non-nan element is returned. If both elements are NaNs then the fir... |
Element-wise minimum of array elements.
Compare two tensors and returns a new tensor containing the element-wise
minima. If one of the elements being compared is a NaN, then the
non-nan element is returned. If both elements are NaNs then the first
is returned. The latter distinction is important ... | fmin | python | mars-project/mars | mars/tensor/arithmetic/fmin.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/fmin.py | Apache-2.0 |
def fmod(x1, x2, out=None, where=None, **kwargs):
"""
Return the element-wise 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 ... |
Return the element-wise 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 operator ``x1 % x2``.
Pa... | fmod | python | mars-project/mars | mars/tensor/arithmetic/fmod.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/fmod.py | Apache-2.0 |
def frexp(x, out1=None, out2=None, out=None, where=None, **kwargs):
"""
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.
... |
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
Tensor of numbers... | frexp | python | mars-project/mars | mars/tensor/arithmetic/frexp.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/frexp.py | Apache-2.0 |
def greater(x1, x2, out=None, where=None, **kwargs):
"""
Return the truth value of (x1 > x2) element-wise.
Parameters
----------
x1, x2 : array_like
Input tensors. If ``x1.shape != x2.shape``, they must be
broadcastable to a common shape (which may be the shape of one or
th... |
Return the truth value of (x1 > x2) element-wise.
Parameters
----------
x1, x2 : array_like
Input tensors. If ``x1.shape != x2.shape``, they must be
broadcastable to a common shape (which may be the shape of one or
the other).
out : Tensor, None, or tuple of Tensor and Non... | greater | python | mars-project/mars | mars/tensor/arithmetic/greater.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/greater.py | Apache-2.0 |
def greater_equal(x1, x2, out=None, where=None, **kwargs):
"""
Return the truth value of (x1 >= x2) element-wise.
Parameters
----------
x1, x2 : array_like
Input tensors. If ``x1.shape != x2.shape``, they must be
broadcastable to a common shape (which may be the shape of one or
... |
Return the truth value of (x1 >= x2) element-wise.
Parameters
----------
x1, x2 : array_like
Input tensors. If ``x1.shape != x2.shape``, they must be
broadcastable to a common shape (which may be the shape of one or
the other).
out : Tensor, None, or tuple of Tensor and No... | greater_equal | python | mars-project/mars | mars/tensor/arithmetic/greater_equal.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/greater_equal.py | Apache-2.0 |
def hypot(x1, x2, out=None, where=None, **kwargs):
"""
Given the "legs" of a right triangle, return its hypotenuse.
Equivalent to ``sqrt(x1**2 + x2**2)``, element-wise. If `x1` or
`x2` is scalar_like (i.e., unambiguously cast-able to a scalar type),
it is broadcast for use with each element of the... |
Given the "legs" of a right triangle, return its hypotenuse.
Equivalent to ``sqrt(x1**2 + x2**2)``, element-wise. If `x1` or
`x2` is scalar_like (i.e., unambiguously cast-able to a scalar type),
it is broadcast for use with each element of the other argument.
(See Examples)
Parameters
--... | hypot | python | mars-project/mars | mars/tensor/arithmetic/hypot.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/hypot.py | Apache-2.0 |
def invert(x, out=None, where=None, **kwargs):
"""
Compute bit-wise inversion, or bit-wise NOT, element-wise.
Computes the bit-wise NOT of the underlying binary representation of
the integers in the input tensors. This ufunc implements the C/Python
operator ``~``.
For signed integer inputs, th... |
Compute bit-wise inversion, or bit-wise NOT, element-wise.
Computes the bit-wise NOT of the underlying binary representation of
the integers in the input tensors. This ufunc implements the C/Python
operator ``~``.
For signed integer inputs, the two's complement is returned. In a
two's-comple... | invert | python | mars-project/mars | mars/tensor/arithmetic/invert.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/invert.py | Apache-2.0 |
def isclose(a, b, rtol=1e-05, atol=1e-08, equal_nan=False):
"""
Returns a boolean tensor where two tensors are element-wise equal within a
tolerance.
The tolerance values are positive, typically very small numbers. The
relative difference (`rtol` * abs(`b`)) and the absolute difference
`atol` ... |
Returns a boolean tensor where two tensors are element-wise equal within a
tolerance.
The tolerance values are positive, typically very small numbers. The
relative difference (`rtol` * abs(`b`)) and the absolute difference
`atol` are added together to compare against the absolute difference
b... | isclose | python | mars-project/mars | mars/tensor/arithmetic/isclose.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/isclose.py | Apache-2.0 |
def isfinite(x, out=None, where=None, **kwargs):
"""
Test element-wise for finiteness (not infinity or not Not a Number).
The result is returned as a boolean tensor.
Parameters
----------
x : array_like
Input values.
out : Tensor, None, or tuple of Tensor and None, optional
... |
Test element-wise for finiteness (not infinity or not Not a Number).
The result is returned as a boolean tensor.
Parameters
----------
x : array_like
Input values.
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is stored. If provided... | isfinite | python | mars-project/mars | mars/tensor/arithmetic/isfinite.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/isfinite.py | Apache-2.0 |
def isinf(x, out=None, where=None, **kwargs):
"""
Test element-wise 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 : Tensor, None, or tuple o... |
Test element-wise 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 : Tensor, None, or tuple of Tensor and None, optional
A location into w... | isinf | python | mars-project/mars | mars/tensor/arithmetic/isinf.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/isinf.py | Apache-2.0 |
def isnan(x, out=None, where=None, **kwargs):
"""
Test element-wise for NaN and return result as a boolean tensor.
Parameters
----------
x : array_like
Input tensor.
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is stored. If provided... |
Test element-wise for NaN and return result as a boolean tensor.
Parameters
----------
x : array_like
Input tensor.
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is stored. If provided, it must have
a shape that the inputs broadc... | isnan | python | mars-project/mars | mars/tensor/arithmetic/isnan.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/isnan.py | Apache-2.0 |
def ldexp(x1, x2, out=None, where=None, **kwargs):
"""
Returns x1 * 2**x2, element-wise.
The mantissas `x1` and twos exponents `x2` are used to construct
floating point numbers ``x1 * 2**x2``.
Parameters
----------
x1 : array_like
Tensor of multipliers.
x2 : array_like, int
... |
Returns x1 * 2**x2, element-wise.
The mantissas `x1` and twos exponents `x2` are used to construct
floating point numbers ``x1 * 2**x2``.
Parameters
----------
x1 : array_like
Tensor of multipliers.
x2 : array_like, int
Tensor of twos exponents.
out : Tensor, None, or ... | ldexp | python | mars-project/mars | mars/tensor/arithmetic/ldexp.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/ldexp.py | Apache-2.0 |
def less(x1, x2, out=None, where=None, **kwargs):
"""
Return the truth value of (x1 < x2) element-wise.
Parameters
----------
x1, x2 : array_like
Input tensors. If ``x1.shape != x2.shape``, they must be
broadcastable to a common shape (which may be the shape of one or
the o... |
Return the truth value of (x1 < x2) element-wise.
Parameters
----------
x1, x2 : array_like
Input tensors. If ``x1.shape != x2.shape``, they must be
broadcastable to a common shape (which may be the shape of one or
the other).
out : Tensor, None, or tuple of Tensor and Non... | less | python | mars-project/mars | mars/tensor/arithmetic/less.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/less.py | Apache-2.0 |
def less_equal(x1, x2, out=None, where=None, **kwargs):
"""
Return the truth value of (x1 =< x2) element-wise.
Parameters
----------
x1, x2 : array_like
Input tensors. If ``x1.shape != x2.shape``, they must be
broadcastable to a common shape (which may be the shape of one or
... |
Return the truth value of (x1 =< x2) element-wise.
Parameters
----------
x1, x2 : array_like
Input tensors. If ``x1.shape != x2.shape``, they must be
broadcastable to a common shape (which may be the shape of one or
the other).
out : Tensor, None, or tuple of Tensor and No... | less_equal | python | mars-project/mars | mars/tensor/arithmetic/less_equal.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/less_equal.py | Apache-2.0 |
def log(x, out=None, where=None, **kwargs):
"""
Natural logarithm, element-wise.
The natural logarithm `log` is the inverse of the exponential function,
so that `log(exp(x)) = x`. The natural logarithm is logarithm in base
`e`.
Parameters
----------
x : array_like
Input value.
... |
Natural logarithm, element-wise.
The natural logarithm `log` is the inverse of the exponential function,
so that `log(exp(x)) = x`. The natural logarithm is logarithm in base
`e`.
Parameters
----------
x : array_like
Input value.
out : Tensor, None, or tuple of tensor and None... | log | python | mars-project/mars | mars/tensor/arithmetic/log.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/log.py | Apache-2.0 |
def log10(x, out=None, where=None, **kwargs):
"""
Return the base 10 logarithm of the input tensor, element-wise.
Parameters
----------
x : array_like
Input values.
out : Tensor, None, or tuple of tensor and None, optional
A location into which the result is stored. If provided,... |
Return the base 10 logarithm of the input tensor, element-wise.
Parameters
----------
x : array_like
Input values.
out : Tensor, None, or tuple of tensor and None, optional
A location into which the result is stored. If provided, it must have
a shape that the inputs broadca... | log10 | python | mars-project/mars | mars/tensor/arithmetic/log10.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/log10.py | Apache-2.0 |
def log1p(x, out=None, where=None, **kwargs):
"""
Return the natural logarithm of one plus the input tensor, element-wise.
Calculates ``log(1 + x)``.
Parameters
----------
x : array_like
Input values.
out : Tensor, None, or tuple of Tensor and None, optional
A location into... |
Return the natural logarithm of one plus the input tensor, element-wise.
Calculates ``log(1 + x)``.
Parameters
----------
x : array_like
Input values.
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is stored. If provided, it must hav... | log1p | python | mars-project/mars | mars/tensor/arithmetic/log1p.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/log1p.py | Apache-2.0 |
def log2(x, out=None, where=None, **kwargs):
"""
Base-2 logarithm of `x`.
Parameters
----------
x : array_like
Input values.
out : Tensor, None, or tuple of tensor and None, optional
A location into which the result is stored. If provided, it must have
a shape that the i... |
Base-2 logarithm of `x`.
Parameters
----------
x : array_like
Input values.
out : Tensor, None, or tuple of tensor 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`,
... | log2 | python | mars-project/mars | mars/tensor/arithmetic/log2.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/log2.py | Apache-2.0 |
def logaddexp(x1, x2, out=None, where=None, **kwargs):
"""
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... |
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 p... | logaddexp | python | mars-project/mars | mars/tensor/arithmetic/logaddexp.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/logaddexp.py | Apache-2.0 |
def logaddexp2(x1, x2, out=None, where=None, **kwargs):
"""
Logarithm of the sum of exponentiations of the inputs in base-2.
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 f... |
Logarithm of the sum of exponentiations of the inputs in base-2.
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 base-2 logarithm ... | logaddexp2 | python | mars-project/mars | mars/tensor/arithmetic/logaddexp2.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/logaddexp2.py | Apache-2.0 |
def logical_and(x1, x2, out=None, where=None, **kwargs):
"""
Compute the truth value of x1 AND x2 element-wise.
Parameters
----------
x1, x2 : array_like
Input tensors. `x1` and `x2` must be of the same shape.
out : Tensor, None, or tuple of Tensor and None, optional
A location ... |
Compute the truth value of x1 AND x2 element-wise.
Parameters
----------
x1, x2 : array_like
Input tensors. `x1` and `x2` must be of the same shape.
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is stored. If provided, it must have
... | logical_and | python | mars-project/mars | mars/tensor/arithmetic/logical_and.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/logical_and.py | Apache-2.0 |
def logical_not(x, out=None, where=None, **kwargs):
"""
Compute the truth value of NOT x element-wise.
Parameters
----------
x : array_like
Logical NOT is applied to the elements of `x`.
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result i... |
Compute the truth value of NOT x element-wise.
Parameters
----------
x : array_like
Logical NOT is applied to the elements of `x`.
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is stored. If provided, it must have
a shape that th... | logical_not | python | mars-project/mars | mars/tensor/arithmetic/logical_not.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/logical_not.py | Apache-2.0 |
def logical_or(x1, x2, out=None, where=None, **kwargs):
"""
Compute the truth value of x1 OR x2 element-wise.
Parameters
----------
x1, x2 : array_like
Logical OR is applied to the elements of `x1` and `x2`.
They have to be of the same shape.
out : Tensor, None, or tuple of Tens... |
Compute the truth value of x1 OR x2 element-wise.
Parameters
----------
x1, x2 : array_like
Logical OR is applied to the elements of `x1` and `x2`.
They have to be of the same shape.
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result ... | logical_or | python | mars-project/mars | mars/tensor/arithmetic/logical_or.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/logical_or.py | Apache-2.0 |
def logical_xor(x1, x2, out=None, where=None, **kwargs):
"""
Compute the truth value of x1 XOR x2, element-wise.
Parameters
----------
x1, x2 : array_like
Logical XOR is applied to the elements of `x1` and `x2`. They must
be broadcastable to the same shape.
out : Tensor, None, ... |
Compute the truth value of x1 XOR x2, element-wise.
Parameters
----------
x1, x2 : array_like
Logical XOR is applied to the elements of `x1` and `x2`. They must
be broadcastable to the same shape.
out : Tensor, None, or tuple of Tensor and None, optional
A location into wh... | logical_xor | python | mars-project/mars | mars/tensor/arithmetic/logical_xor.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/logical_xor.py | Apache-2.0 |
def lshift(x1, x2, out=None, where=None, **kwargs):
"""
Shift the bits of an integer to the left.
Bits are shifted to the left by appending `x2` 0s at the right of `x1`.
Since the internal representation of numbers is in binary format, this
operation is equivalent to multiplying `x1` by ``2**x2``.
... |
Shift the bits of an integer to the left.
Bits are shifted to the left by appending `x2` 0s at the right of `x1`.
Since the internal representation of numbers is in binary format, this
operation is equivalent to multiplying `x1` by ``2**x2``.
Parameters
----------
x1 : array_like of integ... | lshift | python | mars-project/mars | mars/tensor/arithmetic/lshift.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/lshift.py | Apache-2.0 |
def maximum(x1, x2, out=None, where=None, **kwargs):
"""
Element-wise maximum of tensor elements.
Compare two tensors and returns a new array containing the element-wise
maxima. If one of the elements being compared is a NaN, then that
element is returned. If both elements are NaNs then the first i... |
Element-wise maximum of tensor elements.
Compare two tensors and returns a new array containing the element-wise
maxima. If one of the elements being compared is a NaN, then that
element is returned. If both elements are NaNs then the first is
returned. The latter distinction is important for comp... | maximum | python | mars-project/mars | mars/tensor/arithmetic/maximum.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/maximum.py | Apache-2.0 |
def minimum(x1, x2, out=None, where=None, **kwargs):
"""
Element-wise minimum of tensor elements.
Compare two tensors and returns a new tensor containing the element-wise
minima. If one of the elements being compared is a NaN, then that
element is returned. If both elements are NaNs then the first ... |
Element-wise minimum of tensor elements.
Compare two tensors and returns a new tensor containing the element-wise
minima. If one of the elements being compared is a NaN, then that
element is returned. If both elements are NaNs then the first is
returned. The latter distinction is important for com... | minimum | python | mars-project/mars | mars/tensor/arithmetic/minimum.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/minimum.py | Apache-2.0 |
def mod(x1, x2, out=None, where=None, **kwargs):
"""
Return element-wise remainder of division.
Computes the remainder complementary to the `floor_divide` function. It is
equivalent to the Python modulus operator``x1 % x2`` and has the same sign
as the divisor `x2`. The MATLAB function equivalent ... |
Return element-wise remainder of division.
Computes the remainder complementary to the `floor_divide` function. It is
equivalent to the Python modulus operator``x1 % x2`` and has the same sign
as the divisor `x2`. The MATLAB function equivalent to ``np.remainder``
is ``mod``.
.. warning::
... | mod | python | mars-project/mars | mars/tensor/arithmetic/mod.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/mod.py | Apache-2.0 |
def modf(x, out1=None, out2=None, out=None, where=None, **kwargs):
"""
Return the fractional and integral parts of a tensor, element-wise.
The fractional and integral parts are negative if the given number is
negative.
Parameters
----------
x : array_like
Input tensor.
out : Te... |
Return the fractional and integral parts of a tensor, element-wise.
The fractional and integral parts are negative if the given number is
negative.
Parameters
----------
x : array_like
Input tensor.
out : Tensor, None, or tuple of Tensor and None, optional
A location into ... | modf | python | mars-project/mars | mars/tensor/arithmetic/modf.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/modf.py | Apache-2.0 |
def multiply(x1, x2, out=None, where=None, **kwargs):
"""
Multiply arguments element-wise.
Parameters
----------
x1, x2 : array_like
Input arrays to be multiplied.
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is stored. If provided, ... |
Multiply arguments element-wise.
Parameters
----------
x1, x2 : array_like
Input arrays to be multiplied.
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is stored. If provided, it must have
a shape that the inputs broadcast to. If... | multiply | python | mars-project/mars | mars/tensor/arithmetic/multiply.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/multiply.py | Apache-2.0 |
def nan_to_num(x, copy=True, **kwargs):
"""
Replace nan with zero and inf with large finite numbers.
If `x` is inexact, NaN is replaced by zero, and infinity and -infinity
replaced by the respectively largest and most negative finite floating
point values representable by ``x.dtype``.
For comp... |
Replace nan with zero and inf with large finite numbers.
If `x` is inexact, NaN is replaced by zero, and infinity and -infinity
replaced by the respectively largest and most negative finite floating
point values representable by ``x.dtype``.
For complex dtypes, the above is applied to each of the... | nan_to_num | python | mars-project/mars | mars/tensor/arithmetic/nan_to_num.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/nan_to_num.py | Apache-2.0 |
def negative(x, out=None, where=None, **kwargs):
"""
Numerical negative, element-wise.
Parameters
----------
x : array_like or scalar
Input tensor.
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is stored. If provided, it must have
... |
Numerical negative, element-wise.
Parameters
----------
x : array_like or scalar
Input tensor.
out : Tensor, None, or tuple of Tensor 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 provid... | negative | python | mars-project/mars | mars/tensor/arithmetic/negative.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/negative.py | Apache-2.0 |
def nextafter(x1, x2, out=None, where=None, **kwargs):
"""
Return the next floating-point value after x1 towards x2, element-wise.
Parameters
----------
x1 : array_like
Values to find the next representable value of.
x2 : array_like
The direction where to look for the next repre... |
Return the next floating-point value after x1 towards x2, element-wise.
Parameters
----------
x1 : array_like
Values to find the next representable value of.
x2 : array_like
The direction where to look for the next representable value of `x1`.
out : Tensor, None, or tuple of Te... | nextafter | python | mars-project/mars | mars/tensor/arithmetic/nextafter.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/nextafter.py | Apache-2.0 |
def not_equal(x1, x2, out=None, where=None, **kwargs):
"""
Return (x1 != x2) element-wise.
Parameters
----------
x1, x2 : array_like
Input tensors.
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is stored. If provided, it must have
... |
Return (x1 != x2) element-wise.
Parameters
----------
x1, x2 : array_like
Input tensors.
out : Tensor, None, or tuple of Tensor 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 `N... | not_equal | python | mars-project/mars | mars/tensor/arithmetic/not_equal.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/not_equal.py | Apache-2.0 |
def positive(x, out=None, where=None, **kwargs):
"""
Numerical positive, element-wise.
Parameters
----------
x : array_like or scalar
Input tensor.
Returns
-------
y : Tensor or scalar
Returned array or scalar: `y = +x`.
"""
op = TensorPositive(**kwargs)
ret... |
Numerical positive, element-wise.
Parameters
----------
x : array_like or scalar
Input tensor.
Returns
-------
y : Tensor or scalar
Returned array or scalar: `y = +x`.
| positive | python | mars-project/mars | mars/tensor/arithmetic/positive.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/positive.py | Apache-2.0 |
def power(x1, x2, out=None, where=None, **kwargs):
r"""
First tensor elements raised to powers from second tensor, element-wise.
Raise each base in `x1` to the positionally-corresponding power in
`x2`. `x1` and `x2` must be broadcastable to the same shape. Note that an
integer type raised to a neg... |
First tensor elements raised to powers from second tensor, element-wise.
Raise each base in `x1` to the positionally-corresponding power in
`x2`. `x1` and `x2` must be broadcastable to the same shape. Note that an
integer type raised to a negative integer power will raise a ValueError.
Parameter... | power | python | mars-project/mars | mars/tensor/arithmetic/power.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/power.py | Apache-2.0 |
def rad2deg(x, out=None, where=None, **kwargs):
"""
Convert angles from radians to degrees.
Parameters
----------
x : array_like
Angle in radians.
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is stored. If provided, it must have
... |
Convert angles from radians to degrees.
Parameters
----------
x : array_like
Angle in radians.
out : Tensor, None, or tuple of Tensor 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 provid... | rad2deg | python | mars-project/mars | mars/tensor/arithmetic/rad2deg.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/rad2deg.py | Apache-2.0 |
def radians(x, out=None, where=None, **kwargs):
"""
Convert angles from degrees to radians.
Parameters
----------
x : array_like
Input tensor in degrees.
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is stored. If provided, it must ha... |
Convert angles from degrees to radians.
Parameters
----------
x : array_like
Input tensor in degrees.
out : Tensor, None, or tuple of Tensor 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... | radians | python | mars-project/mars | mars/tensor/arithmetic/radians.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/radians.py | Apache-2.0 |
def reciprocal(x, out=None, where=None, **kwargs):
"""
Return the reciprocal of the argument, element-wise.
Calculates ``1/x``.
Parameters
----------
x : array_like
Input tensor.
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is s... |
Return the reciprocal of the argument, element-wise.
Calculates ``1/x``.
Parameters
----------
x : array_like
Input tensor.
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is stored. If provided, it must have
a shape that the ... | reciprocal | python | mars-project/mars | mars/tensor/arithmetic/reciprocal.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/reciprocal.py | Apache-2.0 |
def rint(x, out=None, where=None, **kwargs):
"""
Round elements of the tensor to the nearest integer.
Parameters
----------
x : array_like
Input tensor.
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is stored. If provided, it must hav... |
Round elements of the tensor to the nearest integer.
Parameters
----------
x : array_like
Input tensor.
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is stored. If provided, it must have
a shape that the inputs broadcast to. If n... | rint | python | mars-project/mars | mars/tensor/arithmetic/rint.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/rint.py | Apache-2.0 |
def rshift(x1, x2, out=None, where=None, **kwargs):
"""
Shift the bits of an integer to the right.
Bits are shifted to the right `x2`. Because the internal
representation of numbers is in binary format, this operation is
equivalent to dividing `x1` by ``2**x2``.
Parameters
----------
... |
Shift the bits of an integer to the right.
Bits are shifted to the right `x2`. Because the internal
representation of numbers is in binary format, this operation is
equivalent to dividing `x1` by ``2**x2``.
Parameters
----------
x1 : array_like, int
Input values.
x2 : array_l... | rshift | python | mars-project/mars | mars/tensor/arithmetic/rshift.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/rshift.py | Apache-2.0 |
def sign(x, out=None, where=None, **kwargs):
r"""
Returns an element-wise indication of the sign of a number.
The `sign` function returns ``-1 if x < 0, 0 if x==0, 1 if x > 0``. nan
is returned for nan inputs.
For complex inputs, the `sign` function returns
``sign(x.real) + 0j if x.real != 0 ... |
Returns an element-wise indication of the sign of a number.
The `sign` function returns ``-1 if x < 0, 0 if x==0, 1 if x > 0``. nan
is returned for nan inputs.
For complex inputs, the `sign` function returns
``sign(x.real) + 0j if x.real != 0 else sign(x.imag) + 0j``.
complex(nan, 0) is ret... | sign | python | mars-project/mars | mars/tensor/arithmetic/sign.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/sign.py | Apache-2.0 |
def signbit(x, out=None, where=None, **kwargs):
"""
Returns element-wise True where signbit is set (less than zero).
Parameters
----------
x : array_like
The input value(s).
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is stored. If ... |
Returns element-wise True where signbit is set (less than zero).
Parameters
----------
x : array_like
The input value(s).
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is stored. If provided, it must have
a shape that the inputs ... | signbit | python | mars-project/mars | mars/tensor/arithmetic/signbit.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/signbit.py | Apache-2.0 |
def sin(x, out=None, where=None, **kwargs):
r"""
Trigonometric sine, element-wise.
Parameters
----------
x : array_like
Angle, in radians (:math:`2 \pi` rad equals 360 degrees).
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is stored.... |
Trigonometric sine, element-wise.
Parameters
----------
x : array_like
Angle, in radians (:math:`2 \pi` rad equals 360 degrees).
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is stored. If provided, it must have
a shape that the ... | sin | python | mars-project/mars | mars/tensor/arithmetic/sin.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/sin.py | Apache-2.0 |
def sinh(x, out=None, where=None, **kwargs):
"""
Hyperbolic sine, element-wise.
Equivalent to ``1/2 * (mt.exp(x) - mt.exp(-x))`` or
``-1j * mt.sin(1j*x)``.
Parameters
----------
x : array_like
Input tensor.
out : Tensor, None, or tuple of Tensor and None, optional
A loc... |
Hyperbolic sine, element-wise.
Equivalent to ``1/2 * (mt.exp(x) - mt.exp(-x))`` or
``-1j * mt.sin(1j*x)``.
Parameters
----------
x : array_like
Input tensor.
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is stored. If provided, ... | sinh | python | mars-project/mars | mars/tensor/arithmetic/sinh.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/sinh.py | Apache-2.0 |
def spacing(x, out=None, where=None, **kwargs):
"""
Return the distance between x and the nearest adjacent number.
Parameters
----------
x : array_like
Values to find the spacing of.
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is st... |
Return the distance between x and the nearest adjacent number.
Parameters
----------
x : array_like
Values to find the spacing of.
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is stored. If provided, it must have
a shape that th... | spacing | python | mars-project/mars | mars/tensor/arithmetic/spacing.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/spacing.py | Apache-2.0 |
def sqrt(x, out=None, where=None, **kwargs):
"""
Return the positive square-root of an tensor, element-wise.
Parameters
----------
x : array_like
The values whose square-roots are required.
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the resul... |
Return the positive square-root of an tensor, element-wise.
Parameters
----------
x : array_like
The values whose square-roots are required.
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is stored. If provided, it must have
a sha... | sqrt | python | mars-project/mars | mars/tensor/arithmetic/sqrt.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/sqrt.py | Apache-2.0 |
def square(x, out=None, where=None, **kwargs):
"""
Return the element-wise square of the input.
Parameters
----------
x : array_like
Input data.
out : Tensor, None, or tuple of tensor and None, optional
A location into which the result is stored. If provided, it must have
... |
Return the element-wise square of the input.
Parameters
----------
x : array_like
Input data.
out : Tensor, None, or tuple of tensor 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 provide... | square | python | mars-project/mars | mars/tensor/arithmetic/square.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/square.py | Apache-2.0 |
def subtract(x1, x2, out=None, where=None, **kwargs):
"""
Subtract arguments, element-wise.
Parameters
----------
x1, x2 : array_like
The tensors to be subtracted from each other.
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is store... |
Subtract arguments, element-wise.
Parameters
----------
x1, x2 : array_like
The tensors to be subtracted from each other.
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is stored. If provided, it must have
a shape that the inputs ... | subtract | python | mars-project/mars | mars/tensor/arithmetic/subtract.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/subtract.py | Apache-2.0 |
def tan(x, out=None, where=None, **kwargs):
"""
Compute tangent element-wise.
Equivalent to ``mt.sin(x)/mt.cos(x)`` element-wise.
Parameters
----------
x : array_like
Input tensor.
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is s... |
Compute tangent element-wise.
Equivalent to ``mt.sin(x)/mt.cos(x)`` element-wise.
Parameters
----------
x : array_like
Input tensor.
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is stored. If provided, it must have
a shape th... | tan | python | mars-project/mars | mars/tensor/arithmetic/tan.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/tan.py | Apache-2.0 |
def tanh(x, out=None, where=None, **kwargs):
"""
Compute hyperbolic tangent element-wise.
Equivalent to ``mt.sinh(x)/np.cosh(x)`` or ``-1j * mt.tan(1j*x)``.
Parameters
----------
x : array_like
Input tensor.
out : Tensor, None, or tuple of Tensor and None, optional
A locati... |
Compute hyperbolic tangent element-wise.
Equivalent to ``mt.sinh(x)/np.cosh(x)`` or ``-1j * mt.tan(1j*x)``.
Parameters
----------
x : array_like
Input tensor.
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is stored. If provided, it ... | tanh | python | mars-project/mars | mars/tensor/arithmetic/tanh.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/tanh.py | Apache-2.0 |
def truediv(x1, x2, out=None, where=None, **kwargs):
"""
Returns a true division of the inputs, element-wise.
Instead of the Python traditional 'floor division', this returns a true
division. True division adjusts the output type to present the best
answer, regardless of input types.
Paramete... |
Returns a true division of the inputs, element-wise.
Instead of the Python traditional 'floor division', this returns a true
division. True division adjusts the output type to present the best
answer, regardless of input types.
Parameters
----------
x1 : array_like
Dividend tenso... | truediv | python | mars-project/mars | mars/tensor/arithmetic/truediv.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/truediv.py | Apache-2.0 |
def trunc(x, out=None, where=None, **kwargs):
"""
Return the truncated value of the input, element-wise.
The truncated value of the scalar `x` is the nearest integer `i` which
is closer to zero than `x` is. In short, the fractional part of the
signed number `x` is discarded.
Parameters
---... |
Return the truncated value of the input, element-wise.
The truncated value of the scalar `x` is the nearest integer `i` which
is closer to zero than `x` is. In short, the fractional part of the
signed number `x` is discarded.
Parameters
----------
x : array_like
Input data.
ou... | trunc | python | mars-project/mars | mars/tensor/arithmetic/trunc.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/trunc.py | Apache-2.0 |
def chunk_tree_add(dtype, chunks, idx, shape, sparse=False, combine_size=None):
"""
Generate tree add plan.
Assume combine size as 4, given a input chunks with size 8,
we will generate tree add plan like:
op op op op op op op op
| | | |
-------- --------
... |
Generate tree add plan.
Assume combine size as 4, given a input chunks with size 8,
we will generate tree add plan like:
op op op op op op op op
| | | |
-------- --------
tree_add tree_add
| |
-------------
... | chunk_tree_add | python | mars-project/mars | mars/tensor/arithmetic/utils.py | https://github.com/mars-project/mars/blob/master/mars/tensor/arithmetic/utils.py | Apache-2.0 |
def argpartition(a, kth, axis=-1, kind="introselect", order=None, **kw):
"""
Perform an indirect partition along the given axis using the
algorithm specified by the `kind` keyword. It returns an array of
indices of the same shape as `a` that index data along the given
axis in partitioned order.
... |
Perform an indirect partition along the given axis using the
algorithm specified by the `kind` keyword. It returns an array of
indices of the same shape as `a` that index data along the given
axis in partitioned order.
.. versionadded:: 1.8.0
Parameters
----------
a : array_like
... | argpartition | python | mars-project/mars | mars/tensor/base/argpartition.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/argpartition.py | Apache-2.0 |
def argsort(a, axis=-1, kind=None, parallel_kind=None, psrs_kinds=None, order=None):
"""
Returns the indices that would sort a tensor.
Perform an indirect sort along the given axis using the algorithm specified
by the `kind` keyword. It returns a tensor of indices of the same shape as
`a` that inde... |
Returns the indices that would sort a tensor.
Perform an indirect sort along the given axis using the algorithm specified
by the `kind` keyword. It returns a tensor of indices of the same shape as
`a` that index data along the given axis in sorted order.
Parameters
----------
a : array_li... | argsort | python | mars-project/mars | mars/tensor/base/argsort.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/argsort.py | Apache-2.0 |
def argwhere(a):
"""
Find the indices of tensor elements that are non-zero, grouped by element.
Parameters
----------
a : array_like
Input data.
Returns
-------
index_tensor : Tensor
Indices of elements that are non-zero. Indices are grouped by element.
See Also
... |
Find the indices of tensor elements that are non-zero, grouped by element.
Parameters
----------
a : array_like
Input data.
Returns
-------
index_tensor : Tensor
Indices of elements that are non-zero. Indices are grouped by element.
See Also
--------
where, no... | argwhere | python | mars-project/mars | mars/tensor/base/argwhere.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/argwhere.py | Apache-2.0 |
def _astype(tensor, dtype, order="K", casting="unsafe", copy=True):
"""
Copy of the tensor, cast to a specified type.
Parameters
----------
dtype : str or dtype
Typecode or data-type to which the array is cast.
casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional
C... |
Copy of the tensor, cast to a specified type.
Parameters
----------
dtype : str or dtype
Typecode or data-type to which the array is cast.
casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional
Controls what kind of data casting may occur. Defaults to 'unsafe'
f... | _astype | python | mars-project/mars | mars/tensor/base/astype.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/astype.py | Apache-2.0 |
def atleast_1d(*tensors):
"""
Convert inputs to tensors with at least one dimension.
Scalar inputs are converted to 1-dimensional tensors, whilst
higher-dimensional inputs are preserved.
Parameters
----------
tensors1, tensors2, ... : array_like
One or more input tensors.
Retu... |
Convert inputs to tensors with at least one dimension.
Scalar inputs are converted to 1-dimensional tensors, whilst
higher-dimensional inputs are preserved.
Parameters
----------
tensors1, tensors2, ... : array_like
One or more input tensors.
Returns
-------
ret : Tensor
... | atleast_1d | python | mars-project/mars | mars/tensor/base/atleast_1d.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/atleast_1d.py | Apache-2.0 |
def atleast_2d(*tensors):
"""
View inputs as tensors with at least two dimensions.
Parameters
----------
tensors1, tensors2, ... : array_like
One or more array-like sequences. Non-tensor inputs are converted
to tensors. Tensors that already have two or more dimensions are
... |
View inputs as tensors with at least two dimensions.
Parameters
----------
tensors1, tensors2, ... : array_like
One or more array-like sequences. Non-tensor inputs are converted
to tensors. Tensors that already have two or more dimensions are
preserved.
Returns
-----... | atleast_2d | python | mars-project/mars | mars/tensor/base/atleast_2d.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/atleast_2d.py | Apache-2.0 |
def atleast_3d(*tensors):
"""
View inputs as tensors with at least three dimensions.
Parameters
----------
tensors1, tensors2, ... : array_like
One or more tensor-like sequences. Non-tensor inputs are converted to
tensors. Tensors that already have three or more dimensions are
... |
View inputs as tensors with at least three dimensions.
Parameters
----------
tensors1, tensors2, ... : array_like
One or more tensor-like sequences. Non-tensor inputs are converted to
tensors. Tensors that already have three or more dimensions are
preserved.
Returns
... | atleast_3d | python | mars-project/mars | mars/tensor/base/atleast_3d.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/atleast_3d.py | Apache-2.0 |
def broadcast_arrays(*args, **kwargs):
"""
Broadcast any number of arrays against each other.
Parameters
----------
`*args` : array_likes
The tensors to broadcast.
Returns
-------
broadcasted : list of tensors
Examples
--------
>>> import mars.tensor as mt
>>>... |
Broadcast any number of arrays against each other.
Parameters
----------
`*args` : array_likes
The tensors to broadcast.
Returns
-------
broadcasted : list of tensors
Examples
--------
>>> import mars.tensor as mt
>>> x = mt.array([[1,2,3]])
>>> y = mt.array(... | broadcast_arrays | python | mars-project/mars | mars/tensor/base/broadcast_arrays.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/broadcast_arrays.py | Apache-2.0 |
def broadcast_to(tensor, shape):
"""Broadcast an tensor to a new shape.
Parameters
----------
tensor : array_like
The tensor to broadcast.
shape : tuple
The shape of the desired array.
Returns
-------
broadcast : Tensor
Raises
------
ValueError
If t... | Broadcast an tensor to a new shape.
Parameters
----------
tensor : array_like
The tensor to broadcast.
shape : tuple
The shape of the desired array.
Returns
-------
broadcast : Tensor
Raises
------
ValueError
If the tensor is not compatible with the new... | broadcast_to | python | mars-project/mars | mars/tensor/base/broadcast_to.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/broadcast_to.py | Apache-2.0 |
def copy(a, order="K"):
"""
Return a tensor copy of the given object.
Parameters
----------
a : array_like
Input data.
order : {'C', 'F', 'A', 'K'}, optional
Controls the memory layout of the copy. 'C' means C-order,
'F' means F-order, 'A' means 'F' if `a` is Fortran con... |
Return a tensor copy of the given object.
Parameters
----------
a : array_like
Input data.
order : {'C', 'F', 'A', 'K'}, optional
Controls the memory layout of the copy. 'C' means C-order,
'F' means F-order, 'A' means 'F' if `a` is Fortran contiguous,
'C' otherwise.... | copy | python | mars-project/mars | mars/tensor/base/copy.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/copy.py | Apache-2.0 |
def copyto(dst, src, casting="same_kind", where=True):
"""
Copies values from one array to another, broadcasting as necessary.
Raises a TypeError if the `casting` rule is violated, and if
`where` is provided, it selects which elements to copy.
Parameters
----------
dst : Tensor
The... |
Copies values from one array to another, broadcasting as necessary.
Raises a TypeError if the `casting` rule is violated, and if
`where` is provided, it selects which elements to copy.
Parameters
----------
dst : Tensor
The tensor into which values are copied.
src : array_like
... | copyto | python | mars-project/mars | mars/tensor/base/copyto.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/copyto.py | Apache-2.0 |
def delete(arr, obj, axis=None):
"""
Return a new array with sub-arrays along an axis deleted. For a one
dimensional array, this returns those entries not returned by
`arr[obj]`.
Parameters
----------
arr : array_like
Input array.
obj : slice, int or array of ints
Indica... |
Return a new array with sub-arrays along an axis deleted. For a one
dimensional array, this returns those entries not returned by
`arr[obj]`.
Parameters
----------
arr : array_like
Input array.
obj : slice, int or array of ints
Indicate indices of sub-arrays to remove along... | delete | python | mars-project/mars | mars/tensor/base/delete.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/delete.py | Apache-2.0 |
def diff(a, n=1, axis=-1):
"""
Calculate the n-th discrete difference along the given axis.
The first difference is given by ``out[n] = a[n+1] - a[n]`` along
the given axis, higher differences are calculated by using `diff`
recursively.
Parameters
----------
a : array_like
Inpu... |
Calculate the n-th discrete difference along the given axis.
The first difference is given by ``out[n] = a[n+1] - a[n]`` along
the given axis, higher differences are calculated by using `diff`
recursively.
Parameters
----------
a : array_like
Input tensor
n : int, optional
... | diff | python | mars-project/mars | mars/tensor/base/diff.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/diff.py | Apache-2.0 |
def dsplit(a, indices_or_sections):
"""
Split tensor into multiple sub-tensors along the 3rd axis (depth).
Please refer to the `split` documentation. `dsplit` is equivalent
to `split` with ``axis=2``, the array is always split along the third
axis provided the tensor dimension is greater than or e... |
Split tensor into multiple sub-tensors along the 3rd axis (depth).
Please refer to the `split` documentation. `dsplit` is equivalent
to `split` with ``axis=2``, the array is always split along the third
axis provided the tensor dimension is greater than or equal to 3.
See Also
--------
s... | dsplit | python | mars-project/mars | mars/tensor/base/dsplit.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/dsplit.py | Apache-2.0 |
def ediff1d(a, to_end=None, to_begin=None):
"""
The differences between consecutive elements of a tensor.
Parameters
----------
a : 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 re... |
The differences between consecutive elements of a tensor.
Parameters
----------
a : 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, opti... | ediff1d | python | mars-project/mars | mars/tensor/base/ediff1d.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/ediff1d.py | Apache-2.0 |
def expand_dims(a, axis):
"""
Expand the shape of a tensor.
Insert a new axis that will appear at the `axis` position in the expanded
array shape.
Parameters
----------
a : array_like
Input tensor.
axis : int
Position in the expanded axes where the new axis is placed.
... |
Expand the shape of a tensor.
Insert a new axis that will appear at the `axis` position in the expanded
array shape.
Parameters
----------
a : array_like
Input tensor.
axis : int
Position in the expanded axes where the new axis is placed.
Returns
-------
res :... | expand_dims | python | mars-project/mars | mars/tensor/base/expand_dims.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/expand_dims.py | Apache-2.0 |
def flatten(a, order="C"):
"""
Return a copy of the tensor collapsed into one dimension.
Parameters
----------
order : {'C', 'F', 'A', 'K'}, optional
'C' means to flatten in row-major (C-style) order.
'F' means to flatten in column-major (Fortran-
style) order. 'A' means to ... |
Return a copy of the tensor collapsed into one dimension.
Parameters
----------
order : {'C', 'F', 'A', 'K'}, optional
'C' means to flatten in row-major (C-style) order.
'F' means to flatten in column-major (Fortran-
style) order. 'A' means to flatten in column-major
or... | flatten | python | mars-project/mars | mars/tensor/base/flatten.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/flatten.py | Apache-2.0 |
def flip(m, axis):
"""
Reverse the order of elements in a tensor along the given axis.
The shape of the array is preserved, but the elements are reordered.
Parameters
----------
m : array_like
Input tensor.
axis : integer
Axis in tensor, which entries are reversed.
Re... |
Reverse the order of elements in a tensor along the given axis.
The shape of the array is preserved, but the elements are reordered.
Parameters
----------
m : array_like
Input tensor.
axis : integer
Axis in tensor, which entries are reversed.
Returns
-------
out ... | flip | python | mars-project/mars | mars/tensor/base/flip.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/flip.py | Apache-2.0 |
def hsplit(a, indices_or_sections):
"""
Split a tensor into multiple sub-tensors horizontally (column-wise).
Please refer to the `split` documentation. `hsplit` is equivalent
to `split` with ``axis=1``, the tensor is always split along the second
axis regardless of the tensor dimension.
See A... |
Split a tensor into multiple sub-tensors horizontally (column-wise).
Please refer to the `split` documentation. `hsplit` is equivalent
to `split` with ``axis=1``, the tensor is always split along the second
axis regardless of the tensor dimension.
See Also
--------
split : Split an array... | hsplit | python | mars-project/mars | mars/tensor/base/hsplit.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/hsplit.py | Apache-2.0 |
def in1d(
ar1: Union[TileableType, np.ndarray],
ar2: Union[TileableType, np.ndarray, list],
assume_unique: bool = False,
invert: bool = False,
):
"""
Test whether each element of a 1-D tensor is also present in a second tensor.
Returns a boolean tensor the same length as `ar1` that is True
... |
Test whether each element of a 1-D tensor is also present in a second tensor.
Returns a boolean tensor the same length as `ar1` that is True
where an element of `ar1` is in `ar2` and False otherwise.
We recommend using :func:`isin` instead of `in1d` for new code.
Parameters
----------
ar... | in1d | python | mars-project/mars | mars/tensor/base/in1d.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/in1d.py | Apache-2.0 |
def insert(arr, obj, values, axis=None):
"""
Insert values along the given axis before the given indices.
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.
... |
Insert values along the given axis before the given indices.
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.
values : array_like
Values to insert... | insert | python | mars-project/mars | mars/tensor/base/insert.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/insert.py | Apache-2.0 |
def isin(
element: Union[TileableType, np.ndarray],
test_elements: Union[TileableType, np.ndarray, list],
assume_unique: bool = False,
invert: bool = False,
):
"""
Calculates `element in test_elements`, broadcasting over `element` only.
Returns a boolean array of the same shape as `element` ... |
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 tensor.
test_elemen... | isin | python | mars-project/mars | mars/tensor/base/isin.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/isin.py | Apache-2.0 |
def map_chunk(t, func, args=(), **kwargs):
"""
Apply function to each chunk.
Parameters
----------
func : function
Function to apply to each chunk.
args : tuple
Positional arguments to pass to func in addition to the array.
**kwargs
Additional keyword arguments to pa... |
Apply function to each chunk.
Parameters
----------
func : function
Function to apply to each chunk.
args : tuple
Positional arguments to pass to func in addition to the array.
**kwargs
Additional keyword arguments to pass as keywords arguments to func.
Returns
... | map_chunk | python | mars-project/mars | mars/tensor/base/map_chunk.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/map_chunk.py | Apache-2.0 |
def moveaxis(a, source, destination):
"""
Move axes of a tensor to new positions.
Other axes remain in their original order.
Parameters
----------
a : Tensor
The tensor whose axes should be reordered.
source : int or sequence of int
Original positions of the axes to move. T... |
Move axes of a tensor to new positions.
Other axes remain in their original order.
Parameters
----------
a : Tensor
The tensor whose axes should be reordered.
source : int or sequence of int
Original positions of the axes to move. These must be unique.
destination : int or... | moveaxis | python | mars-project/mars | mars/tensor/base/moveaxis.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/moveaxis.py | Apache-2.0 |
def ndim(a):
"""
Return the number of dimensions of a tensor.
Parameters
----------
a : array_like
Input tebsir. If it is not already a tensor, a conversion is
attempted.
Returns
-------
number_of_dimensions : int
The number of dimensions in `a`. Scalars are z... |
Return the number of dimensions of a tensor.
Parameters
----------
a : array_like
Input tebsir. If it is not already a tensor, a conversion is
attempted.
Returns
-------
number_of_dimensions : int
The number of dimensions in `a`. Scalars are zero-dimensional.
... | ndim | python | mars-project/mars | mars/tensor/base/ndim.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/ndim.py | Apache-2.0 |
def _tile_psrs(cls, op, kth):
"""
Approach here would be almost like PSRSSorter, but there are definitely some differences
Main processes are listed below:
Stage 1, local sort and regular samples collected
State 2, gather and merge samples, choose and broadcast p-1 pivots
... |
Approach here would be almost like PSRSSorter, but there are definitely some differences
Main processes are listed below:
Stage 1, local sort and regular samples collected
State 2, gather and merge samples, choose and broadcast p-1 pivots
Stage 3, Local data is partitioned
... | _tile_psrs | python | mars-project/mars | mars/tensor/base/partition.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/partition.py | Apache-2.0 |
def partition(a, kth, axis=-1, kind="introselect", order=None, **kw):
r"""
Return a partitioned copy of a tensor.
Creates a copy of the tensor with its elements rearranged in such a
way that the value of the element in k-th position is in the
position it would be in a sorted tensor. All elements sm... |
Return a partitioned copy of a tensor.
Creates a copy of the tensor with its elements rearranged in such a
way that the value of the element in k-th position is in the
position it would be in a sorted tensor. All elements smaller than
the k-th element are moved before this element and all equal or... | partition | python | mars-project/mars | mars/tensor/base/partition.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/partition.py | Apache-2.0 |
def ravel(a, order="C"):
"""Return a contiguous flattened tensor.
A 1-D tensor, containing the elements of the input, is returned. A copy is
made only if needed.
Parameters
----------
a : array_like
Input tensor. The elements in `a` are packed as a 1-D tensor.
order : {'C','F', '... | Return a contiguous flattened tensor.
A 1-D tensor, containing the elements of the input, is returned. A copy is
made only if needed.
Parameters
----------
a : array_like
Input tensor. The elements in `a` are packed as a 1-D tensor.
order : {'C','F', 'A', 'K'}, optional
The ... | ravel | python | mars-project/mars | mars/tensor/base/ravel.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/ravel.py | Apache-2.0 |
def rebalance(tensor, factor=None, axis=0, num_partitions=None, reassign_worker=True):
"""
Make Data more balanced across entire cluster.
Parameters
----------
factor : float
Specified so that number of chunks after balance is
total CPU count of cluster * factor.
axis : int
... |
Make Data more balanced across entire cluster.
Parameters
----------
factor : float
Specified so that number of chunks after balance is
total CPU count of cluster * factor.
axis : int
The axis to rebalance.
num_partitions : int
Specified so the number of chunks ... | rebalance | python | mars-project/mars | mars/tensor/base/rebalance.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/rebalance.py | Apache-2.0 |
def repeat(a, repeats, axis=None):
"""
Repeat elements of a tensor.
Parameters
----------
a : array_like
Input tensor.
repeats : int or tensor of ints
The number of repetitions for each element. `repeats` is broadcasted
to fit the shape of the given axis.
axis : int... |
Repeat elements of a tensor.
Parameters
----------
a : array_like
Input tensor.
repeats : int or tensor of ints
The number of repetitions for each element. `repeats` is broadcasted
to fit the shape of the given axis.
axis : int, optional
The axis along which to... | repeat | python | mars-project/mars | mars/tensor/base/repeat.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/repeat.py | Apache-2.0 |
def result_type(*tensors_and_dtypes):
"""
Returns the type that results from applying the NumPy
type promotion rules to the arguments.
Type promotion in Mars works similarly to the rules in languages
like C++, with some slight differences. When both scalars and
arrays are used, the array's typ... |
Returns the type that results from applying the NumPy
type promotion rules to the arguments.
Type promotion in Mars works similarly to the rules in languages
like C++, with some slight differences. When both scalars and
arrays are used, the array's type takes precedence and the actual value
o... | result_type | python | mars-project/mars | mars/tensor/base/result_type.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/result_type.py | Apache-2.0 |
def roll(a, shift, axis=None):
"""
Roll tensor elements along a given axis.
Elements that roll beyond the last position are re-introduced at
the first.
Parameters
----------
a : array_like
Input tensor.
shift : int or tuple of ints
The number of places by which elements... |
Roll tensor elements along a given axis.
Elements that roll beyond the last position are re-introduced at
the first.
Parameters
----------
a : array_like
Input tensor.
shift : int or tuple of ints
The number of places by which elements are shifted. If a tuple,
the... | roll | python | mars-project/mars | mars/tensor/base/roll.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/roll.py | Apache-2.0 |
def rollaxis(tensor, axis, start=0):
"""
Roll the specified axis backwards, until it lies in a given position.
This function continues to be supported for backward compatibility, but you
should prefer `moveaxis`.
Parameters
----------
a : Tensor
Input tensor.
axis : int
... |
Roll the specified axis backwards, until it lies in a given position.
This function continues to be supported for backward compatibility, but you
should prefer `moveaxis`.
Parameters
----------
a : Tensor
Input tensor.
axis : int
The axis to roll backwards. The positions ... | rollaxis | python | mars-project/mars | mars/tensor/base/rollaxis.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/rollaxis.py | Apache-2.0 |
def searchsorted(a, v, side="left", sorter=None, combine_size=None):
"""
Find indices where elements should be inserted to maintain order.
Find the indices into a sorted tensor `a` such that, if the
corresponding elements in `v` were inserted before the indices, the
order of `a` would be preserved.... |
Find indices where elements should be inserted to maintain order.
Find the indices into a sorted tensor `a` such that, if the
corresponding elements in `v` were inserted before the indices, the
order of `a` would be preserved.
Assuming that `a` is sorted:
====== ============================... | searchsorted | python | mars-project/mars | mars/tensor/base/searchsorted.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/searchsorted.py | Apache-2.0 |
def setdiff1d(ar1, ar2, assume_unique=False):
"""
Find the set difference of two tensors.
Return the unique values in `ar1` that are not in `ar2`.
Parameters
----------
ar1 : array_like
Input tensor.
ar2 : array_like
Input comparison tensor.
assume_unique : bool
... |
Find the set difference of two tensors.
Return the unique values in `ar1` that are not in `ar2`.
Parameters
----------
ar1 : array_like
Input tensor.
ar2 : array_like
Input comparison tensor.
assume_unique : bool
If True, the input tensors are both assumed to be un... | setdiff1d | python | mars-project/mars | mars/tensor/base/setdiff1d.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/setdiff1d.py | Apache-2.0 |
def shape(a):
"""
Return the shape of a tensor.
Parameters
----------
a : array_like
Input tensor.
Returns
-------
shape : ExecutableTuple of tensors
The elements of the shape tuple give the lengths of the
corresponding array dimensions.
Examples
------... |
Return the shape of a tensor.
Parameters
----------
a : array_like
Input tensor.
Returns
-------
shape : ExecutableTuple of tensors
The elements of the shape tuple give the lengths of the
corresponding array dimensions.
Examples
--------
>>> import mar... | shape | python | mars-project/mars | mars/tensor/base/shape.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/shape.py | Apache-2.0 |
def _tile_psrs(cls, op):
"""
Refer to http://csweb.cs.wfu.edu/bigiron/LittleFE-PSRS/build/html/PSRSalgorithm.html
to see explanation of parallel sorting by regular sampling
"""
out_tensor = op.outputs[0]
in_tensor, axis_chunk_shape, out_idxes, need_align = yield from cls.... |
Refer to http://csweb.cs.wfu.edu/bigiron/LittleFE-PSRS/build/html/PSRSalgorithm.html
to see explanation of parallel sorting by regular sampling
| _tile_psrs | python | mars-project/mars | mars/tensor/base/sort.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/sort.py | Apache-2.0 |
def squeeze(a, axis=None):
"""
Remove single-dimensional entries from the shape of a tensor.
Parameters
----------
a : array_like
Input data.
axis : None or int or tuple of ints, optional
Selects a subset of the single-dimensional entries in the
shape. If an axis is sele... |
Remove single-dimensional entries from the shape of a tensor.
Parameters
----------
a : array_like
Input data.
axis : None or int or tuple of ints, optional
Selects a subset of the single-dimensional entries in the
shape. If an axis is selected with shape entry greater than... | squeeze | python | mars-project/mars | mars/tensor/base/squeeze.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/squeeze.py | Apache-2.0 |
def swapaxes(a, axis1, axis2):
"""
Interchange two axes of a tensor.
Parameters
----------
a : array_like
Input tensor.
axis1 : int
First axis.
axis2 : int
Second axis.
Returns
-------
a_swapped : Tensor
If `a` is a Tensor, then a view of `a` is
... |
Interchange two axes of a tensor.
Parameters
----------
a : array_like
Input tensor.
axis1 : int
First axis.
axis2 : int
Second axis.
Returns
-------
a_swapped : Tensor
If `a` is a Tensor, then a view of `a` is
returned; otherwise a new tens... | swapaxes | python | mars-project/mars | mars/tensor/base/swapaxes.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/swapaxes.py | Apache-2.0 |
def tile(A, reps):
"""
Construct a tensor by repeating A the number of times given by reps.
If `reps` has length ``d``, the result will have dimension of
``max(d, A.ndim)``.
If ``A.ndim < d``, `A` is promoted to be d-dimensional by prepending new
axes. So a shape (3,) array is promoted to (1, ... |
Construct a tensor by repeating A the number of times given by reps.
If `reps` has length ``d``, the result will have dimension of
``max(d, A.ndim)``.
If ``A.ndim < d``, `A` is promoted to be d-dimensional by prepending new
axes. So a shape (3,) array is promoted to (1, 3) for 2-D replication,
... | tile | python | mars-project/mars | mars/tensor/base/tile.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/tile.py | Apache-2.0 |
def transpose(a, axes=None):
"""
Permute the dimensions of a tensor.
Parameters
----------
a : array_like
Input tensor.
axes : list of ints, optional
By default, reverse the dimensions, otherwise permute the axes
according to the values given.
Returns
-------
... |
Permute the dimensions of a tensor.
Parameters
----------
a : array_like
Input tensor.
axes : list of ints, optional
By default, reverse the dimensions, otherwise permute the axes
according to the values given.
Returns
-------
p : Tensor
`a` with its ax... | transpose | python | mars-project/mars | mars/tensor/base/transpose.py | https://github.com/mars-project/mars/blob/master/mars/tensor/base/transpose.py | Apache-2.0 |
Subsets and Splits
Django Code with Docstrings
Filters Python code examples from Django repository that contain Django-related code, helping identify relevant code snippets for understanding Django framework usage patterns.
SQL Console for Shuu12121/python-treesitter-filtered-datasetsV2
Retrieves specific code examples from the Flask repository but doesn't provide meaningful analysis or patterns beyond basic data retrieval.
HTTPX Repo Code and Docstrings
Retrieves specific code examples from the httpx repository, which is useful for understanding how particular libraries are used but doesn't provide broader analytical insights about the dataset.
Requests Repo Docstrings & Code
Retrieves code examples with their docstrings and file paths from the requests repository, providing basic filtering but limited analytical value beyond finding specific code samples.
Quart Repo Docstrings & Code
Retrieves code examples with their docstrings from the Quart repository, providing basic code samples but offering limited analytical value for understanding broader patterns or relationships in the dataset.