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 rayleigh(random_state, scale=1.0, size=None, chunk_size=None, gpu=None, dtype=None):
r"""
Draw samples from a Rayleigh distribution.
The :math:`\chi` and Weibull distributions are generalizations of the
Rayleigh.
Parameters
----------
scale : float or array_like of floats, optional
... |
Draw samples from a Rayleigh distribution.
The :math:`\chi` and Weibull distributions are generalizations of the
Rayleigh.
Parameters
----------
scale : float or array_like of floats, optional
Scale, also equals the mode. Should be >= 0. Default is 1.
size : int or tuple of ints, ... | rayleigh | python | mars-project/mars | mars/tensor/random/rayleigh.py | https://github.com/mars-project/mars/blob/master/mars/tensor/random/rayleigh.py | Apache-2.0 |
def shuffle(random_state, x, axis=0):
r"""
Modify a sequence in-place by shuffling its contents.
The order of sub-arrays is changed but their contents remains the same.
Parameters
----------
x : array_like
The array or list to be shuffled.
axis : int, optional
The axis which... |
Modify a sequence in-place by shuffling its contents.
The order of sub-arrays is changed but their contents remains the same.
Parameters
----------
x : array_like
The array or list to be shuffled.
axis : int, optional
The axis which `x` is shuffled along. Default is 0.
Ret... | shuffle | python | mars-project/mars | mars/tensor/random/shuffle.py | https://github.com/mars-project/mars/blob/master/mars/tensor/random/shuffle.py | Apache-2.0 |
def standard_cauchy(random_state, size=None, chunk_size=None, gpu=None, dtype=None):
r"""
Draw samples from a standard Cauchy distribution with mode = 0.
Also known as the Lorentz distribution.
Parameters
----------
size : int or tuple of ints, optional
Output shape. If the given shap... |
Draw samples from a standard Cauchy distribution with mode = 0.
Also known as the Lorentz distribution.
Parameters
----------
size : int or tuple of ints, optional
Output shape. If the given shape is, e.g., ``(m, n, k)``, then
``m * n * k`` samples are drawn. Default is None, in... | standard_cauchy | python | mars-project/mars | mars/tensor/random/standard_cauchy.py | https://github.com/mars-project/mars/blob/master/mars/tensor/random/standard_cauchy.py | Apache-2.0 |
def standard_exponential(
random_state, size=None, chunk_size=None, gpu=None, dtype=None
):
"""
Draw samples from the standard exponential distribution.
`standard_exponential` is identical to the exponential distribution
with a scale parameter of 1.
Parameters
----------
size : int or ... |
Draw samples from the standard exponential distribution.
`standard_exponential` is identical to the exponential distribution
with a scale parameter of 1.
Parameters
----------
size : int or tuple of ints, optional
Output shape. If the given shape is, e.g., ``(m, n, k)``, then
... | standard_exponential | python | mars-project/mars | mars/tensor/random/standard_exponential.py | https://github.com/mars-project/mars/blob/master/mars/tensor/random/standard_exponential.py | Apache-2.0 |
def standard_gamma(
random_state, shape, size=None, chunk_size=None, gpu=None, dtype=None
):
r"""
Draw samples from a standard Gamma distribution.
Samples are drawn from a Gamma distribution with specified parameters,
shape (sometimes designated "k") and scale=1.
Parameters
----------
... |
Draw samples from a standard Gamma distribution.
Samples are drawn from a Gamma distribution with specified parameters,
shape (sometimes designated "k") and scale=1.
Parameters
----------
shape : float or array_like of floats
Parameter, should be > 0.
size : int or tuple of ints, ... | standard_gamma | python | mars-project/mars | mars/tensor/random/standard_gamma.py | https://github.com/mars-project/mars/blob/master/mars/tensor/random/standard_gamma.py | Apache-2.0 |
def standard_normal(random_state, size=None, chunk_size=None, gpu=None, dtype=None):
"""
Draw samples from a standard Normal distribution (mean=0, stdev=1).
Parameters
----------
size : int or tuple of ints, optional
Output shape. If the given shape is, e.g., ``(m, n, k)``, then
``... |
Draw samples from a standard Normal distribution (mean=0, stdev=1).
Parameters
----------
size : int or tuple of ints, optional
Output shape. If the given shape is, e.g., ``(m, n, k)``, then
``m * n * k`` samples are drawn. Default is None, in which case a
single value is ret... | standard_normal | python | mars-project/mars | mars/tensor/random/standard_normal.py | https://github.com/mars-project/mars/blob/master/mars/tensor/random/standard_normal.py | Apache-2.0 |
def standard_t(random_state, df, size=None, chunk_size=None, gpu=None, dtype=None):
r"""
Draw samples from a standard Student's t distribution with `df` degrees
of freedom.
A special case of the hyperbolic distribution. As `df` gets
large, the result resembles that of the standard normal
distr... |
Draw samples from a standard Student's t distribution with `df` degrees
of freedom.
A special case of the hyperbolic distribution. As `df` gets
large, the result resembles that of the standard normal
distribution (`standard_normal`).
Parameters
----------
df : float or array_like of ... | standard_t | python | mars-project/mars | mars/tensor/random/standard_t.py | https://github.com/mars-project/mars/blob/master/mars/tensor/random/standard_t.py | Apache-2.0 |
def uniform(
random_state, low=0.0, high=1.0, size=None, chunk_size=None, gpu=None, dtype=None
):
r"""
Draw samples from a uniform distribution.
Samples are uniformly distributed over the half-open interval
``[low, high)`` (includes low, but excludes high). In other words,
any value within the... |
Draw samples from a uniform distribution.
Samples are uniformly distributed over the half-open interval
``[low, high)`` (includes low, but excludes high). In other words,
any value within the given interval is equally likely to be drawn
by `uniform`.
Parameters
----------
low : float... | uniform | python | mars-project/mars | mars/tensor/random/uniform.py | https://github.com/mars-project/mars/blob/master/mars/tensor/random/uniform.py | Apache-2.0 |
def vonmises(random_state, mu, kappa, size=None, chunk_size=None, gpu=None, dtype=None):
r"""
Draw samples from a von Mises distribution.
Samples are drawn from a von Mises distribution with specified mode
(mu) and dispersion (kappa), on the interval [-pi, pi].
The von Mises distribution (also kno... |
Draw samples from a von Mises distribution.
Samples are drawn from a von Mises distribution with specified mode
(mu) and dispersion (kappa), on the interval [-pi, pi].
The von Mises distribution (also known as the circular normal
distribution) is a continuous probability distribution on the unit
... | vonmises | python | mars-project/mars | mars/tensor/random/vonmises.py | https://github.com/mars-project/mars/blob/master/mars/tensor/random/vonmises.py | Apache-2.0 |
def wald(random_state, mean, scale, size=None, chunk_size=None, gpu=None, dtype=None):
r"""
Draw samples from a Wald, or inverse Gaussian, distribution.
As the scale approaches infinity, the distribution becomes more like a
Gaussian. Some references claim that the Wald is an inverse Gaussian
with m... |
Draw samples from a Wald, or inverse Gaussian, distribution.
As the scale approaches infinity, the distribution becomes more like a
Gaussian. Some references claim that the Wald is an inverse Gaussian
with mean equal to 1, but this is by no means universal.
The inverse Gaussian distribution was f... | wald | python | mars-project/mars | mars/tensor/random/wald.py | https://github.com/mars-project/mars/blob/master/mars/tensor/random/wald.py | Apache-2.0 |
def weibull(random_state, a, size=None, chunk_size=None, gpu=None, dtype=None):
r"""
Draw samples from a Weibull distribution.
Draw samples from a 1-parameter Weibull distribution with the given
shape parameter `a`.
.. math:: X = (-ln(U))^{1/a}
Here, U is drawn from the uniform distribution o... |
Draw samples from a Weibull distribution.
Draw samples from a 1-parameter Weibull distribution with the given
shape parameter `a`.
.. math:: X = (-ln(U))^{1/a}
Here, U is drawn from the uniform distribution over (0,1].
The more common 2-parameter Weibull, including a scale parameter
:ma... | weibull | python | mars-project/mars | mars/tensor/random/weibull.py | https://github.com/mars-project/mars/blob/master/mars/tensor/random/weibull.py | Apache-2.0 |
def zipf(random_state, a, size=None, chunk_size=None, gpu=None, dtype=None):
r"""
Draw samples from a Zipf distribution.
Samples are drawn from a Zipf distribution with specified parameter
`a` > 1.
The Zipf distribution (also known as the zeta distribution) is a
continuous probability distribu... |
Draw samples from a Zipf distribution.
Samples are drawn from a Zipf distribution with specified parameter
`a` > 1.
The Zipf distribution (also known as the zeta distribution) is a
continuous probability distribution that satisfies Zipf's law: the
frequency of an item is inversely proportiona... | zipf | python | mars-project/mars | mars/tensor/random/zipf.py | https://github.com/mars-project/mars/blob/master/mars/tensor/random/zipf.py | Apache-2.0 |
def all(a, axis=None, out=None, keepdims=None, combine_size=None):
"""
Test whether all array elements along a given axis evaluate to True.
Parameters
----------
a : array_like
Input tensor or object that can be converted to a tensor.
axis : None or int or tuple of ints, optional
... |
Test whether all array elements along a given axis evaluate to True.
Parameters
----------
a : array_like
Input tensor or object that can be converted to a tensor.
axis : None or int or tuple of ints, optional
Axis or axes along which a logical AND reduction is performed.
T... | all | python | mars-project/mars | mars/tensor/reduction/all.py | https://github.com/mars-project/mars/blob/master/mars/tensor/reduction/all.py | Apache-2.0 |
def allclose(a, b, rtol=1e-05, atol=1e-08, equal_nan=False):
"""
Returns True if 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... |
Returns True if 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
between `a` and `b`.... | allclose | python | mars-project/mars | mars/tensor/reduction/allclose.py | https://github.com/mars-project/mars/blob/master/mars/tensor/reduction/allclose.py | Apache-2.0 |
def any(a, axis=None, out=None, keepdims=None, combine_size=None):
"""
Test whether any tensor element along a given axis evaluates to True.
Returns single boolean unless `axis` is not ``None``
Parameters
----------
a : array_like
Input tensor or object that can be converted to an arra... |
Test whether any tensor element along a given axis evaluates to True.
Returns single boolean unless `axis` is not ``None``
Parameters
----------
a : array_like
Input tensor or object that can be converted to an array.
axis : None or int or tuple of ints, optional
Axis or axes ... | any | python | mars-project/mars | mars/tensor/reduction/any.py | https://github.com/mars-project/mars/blob/master/mars/tensor/reduction/any.py | Apache-2.0 |
def argmax(a, axis=None, out=None, combine_size=None):
"""
Returns the indices of the maximum values along an axis.
Parameters
----------
a : array_like
Input tensor.
axis : int, optional
By default, the index is into the flattened tensor, otherwise
along the specified a... |
Returns the indices of the maximum values along an axis.
Parameters
----------
a : array_like
Input tensor.
axis : int, optional
By default, the index is into the flattened tensor, otherwise
along the specified axis.
out : Tensor, optional
If provided, the resul... | argmax | python | mars-project/mars | mars/tensor/reduction/argmax.py | https://github.com/mars-project/mars/blob/master/mars/tensor/reduction/argmax.py | Apache-2.0 |
def argmin(a, axis=None, out=None, combine_size=None):
"""
Returns the indices of the minimum values along an axis.
Parameters
----------
a : array_like
Input tensor.
axis : int, optional
By default, the index is into the flattened tensor, otherwise
along the specified a... |
Returns the indices of the minimum values along an axis.
Parameters
----------
a : array_like
Input tensor.
axis : int, optional
By default, the index is into the flattened tensor, otherwise
along the specified axis.
out : Tensor, optional
If provided, the resul... | argmin | python | mars-project/mars | mars/tensor/reduction/argmin.py | https://github.com/mars-project/mars/blob/master/mars/tensor/reduction/argmin.py | Apache-2.0 |
def array_equal(a1, a2):
"""
True if two tensors have the same shape and elements, False otherwise.
Parameters
----------
a1, a2 : array_like
Input arrays.
Returns
-------
b : bool
Returns True if the tensors are equal.
See Also
--------
allclose: Returns T... |
True if two tensors have the same shape and elements, False otherwise.
Parameters
----------
a1, a2 : array_like
Input arrays.
Returns
-------
b : bool
Returns True if the tensors are equal.
See Also
--------
allclose: Returns True if two tensors are element-w... | array_equal | python | mars-project/mars | mars/tensor/reduction/array_equal.py | https://github.com/mars-project/mars/blob/master/mars/tensor/reduction/array_equal.py | Apache-2.0 |
def count_nonzero(a, axis=None, combine_size=None):
"""
Counts the number of non-zero values in the tensor ``a``.
The word "non-zero" is in reference to the Python 2.x
built-in method ``__nonzero__()`` (renamed ``__bool__()``
in Python 3.x) of Python objects that tests an object's
"truthfulness... |
Counts the number of non-zero values in the tensor ``a``.
The word "non-zero" is in reference to the Python 2.x
built-in method ``__nonzero__()`` (renamed ``__bool__()``
in Python 3.x) of Python objects that tests an object's
"truthfulness". For example, any number is considered
truthful if it... | count_nonzero | python | mars-project/mars | mars/tensor/reduction/count_nonzero.py | https://github.com/mars-project/mars/blob/master/mars/tensor/reduction/count_nonzero.py | Apache-2.0 |
def cumprod(a, axis=None, dtype=None, out=None):
"""
Return the cumulative product of elements along a given axis.
Parameters
----------
a : array_like
Input tensor.
axis : int, optional
Axis along which the cumulative product is computed. By default
the input is flatte... |
Return the cumulative product of elements along a given axis.
Parameters
----------
a : array_like
Input tensor.
axis : int, optional
Axis along which the cumulative product is computed. By default
the input is flattened.
dtype : dtype, optional
Type of the ret... | cumprod | python | mars-project/mars | mars/tensor/reduction/cumprod.py | https://github.com/mars-project/mars/blob/master/mars/tensor/reduction/cumprod.py | Apache-2.0 |
def cumsum(a, axis=None, dtype=None, out=None):
"""
Return the cumulative sum of the elements along a given axis.
Parameters
----------
a : array_like
Input tensor.
axis : int, optional
Axis along which the cumulative sum is computed. The default
(None) is to compute the... |
Return the cumulative sum of the elements along a given axis.
Parameters
----------
a : array_like
Input tensor.
axis : int, optional
Axis along which the cumulative sum is computed. The default
(None) is to compute the cumsum over the flattened tensor.
dtype : dtype, o... | cumsum | python | mars-project/mars | mars/tensor/reduction/cumsum.py | https://github.com/mars-project/mars/blob/master/mars/tensor/reduction/cumsum.py | Apache-2.0 |
def max(a, axis=None, out=None, keepdims=None, combine_size=None):
"""
Return the maximum of an array or maximum along an axis.
Parameters
----------
a : array_like
Input data.
axis : None or int or tuple of ints, optional
Axis or axes along which to operate. By default, flatte... |
Return the maximum of an array or maximum along an axis.
Parameters
----------
a : array_like
Input data.
axis : None or int or tuple of ints, optional
Axis or axes along which to operate. By default, flattened input is
used.
If this is a tuple of ints, the maximu... | max | python | mars-project/mars | mars/tensor/reduction/max.py | https://github.com/mars-project/mars/blob/master/mars/tensor/reduction/max.py | Apache-2.0 |
def mean(a, axis=None, dtype=None, out=None, keepdims=None, combine_size=None):
"""
Compute the arithmetic mean along the specified axis.
Returns the average of the array elements. The average is taken over
the flattened tensor by default, otherwise over the specified axis.
`float64` intermediate ... |
Compute the arithmetic mean along the specified axis.
Returns the average of the array elements. The average is taken over
the flattened tensor by default, otherwise over the specified axis.
`float64` intermediate and return values are used for integer inputs.
Parameters
----------
a : a... | mean | python | mars-project/mars | mars/tensor/reduction/mean.py | https://github.com/mars-project/mars/blob/master/mars/tensor/reduction/mean.py | Apache-2.0 |
def min(a, axis=None, out=None, keepdims=None, combine_size=None):
"""
Return the minimum of a tensor or minimum along an axis.
Parameters
----------
a : array_like
Input data.
axis : None or int or tuple of ints, optional
Axis or axes along which to operate. By default, flatte... |
Return the minimum of a tensor or minimum along an axis.
Parameters
----------
a : array_like
Input data.
axis : None or int or tuple of ints, optional
Axis or axes along which to operate. By default, flattened input is
used.
If this is a tuple of ints, the minimu... | min | python | mars-project/mars | mars/tensor/reduction/min.py | https://github.com/mars-project/mars/blob/master/mars/tensor/reduction/min.py | Apache-2.0 |
def nanargmax(a, axis=None, out=None, combine_size=None):
"""
Return the indices of the maximum values in the specified axis ignoring
NaNs. For all-NaN slices ``ValueError`` is raised. Warning: the
results cannot be trusted if a slice contains only NaNs and -Infs.
Parameters
----------
a :... |
Return the indices of the maximum values in the specified axis ignoring
NaNs. For all-NaN slices ``ValueError`` is raised. Warning: the
results cannot be trusted if a slice contains only NaNs and -Infs.
Parameters
----------
a : array_like
Input data.
axis : int, optional
... | nanargmax | python | mars-project/mars | mars/tensor/reduction/nanargmax.py | https://github.com/mars-project/mars/blob/master/mars/tensor/reduction/nanargmax.py | Apache-2.0 |
def nanargmin(a, axis=None, out=None, combine_size=None):
"""
Return the indices of the minimum values in the specified axis ignoring
NaNs. For all-NaN slices ``ValueError`` is raised. Warning: the results
cannot be trusted if a slice contains only NaNs and Infs.
Parameters
----------
a : a... |
Return the indices of the minimum values in the specified axis ignoring
NaNs. For all-NaN slices ``ValueError`` is raised. Warning: the results
cannot be trusted if a slice contains only NaNs and Infs.
Parameters
----------
a : array_like
Input data.
axis : int, optional
Ax... | nanargmin | python | mars-project/mars | mars/tensor/reduction/nanargmin.py | https://github.com/mars-project/mars/blob/master/mars/tensor/reduction/nanargmin.py | Apache-2.0 |
def nancumprod(a, axis=None, dtype=None, out=None):
"""
Return the cumulative product of tensor elements over a given axis treating Not a
Numbers (NaNs) as one. The cumulative product does not change when NaNs are
encountered and leading NaNs are replaced by ones.
Ones are returned for slices that... |
Return the cumulative product of tensor elements over a given axis treating Not a
Numbers (NaNs) as one. The cumulative product does not change when NaNs are
encountered and leading NaNs are replaced by ones.
Ones are returned for slices that are all-NaN or empty.
Parameters
----------
a... | nancumprod | python | mars-project/mars | mars/tensor/reduction/nancumprod.py | https://github.com/mars-project/mars/blob/master/mars/tensor/reduction/nancumprod.py | Apache-2.0 |
def nancumsum(a, axis=None, dtype=None, out=None):
"""
Return the cumulative sum of tensor elements over a given axis treating Not a
Numbers (NaNs) as zero. The cumulative sum does not change when NaNs are
encountered and leading NaNs are replaced by zeros.
Zeros are returned for slices that are a... |
Return the cumulative sum of tensor elements over a given axis treating Not a
Numbers (NaNs) as zero. The cumulative sum does not change when NaNs are
encountered and leading NaNs are replaced by zeros.
Zeros are returned for slices that are all-NaN or empty.
Parameters
----------
a : ar... | nancumsum | python | mars-project/mars | mars/tensor/reduction/nancumsum.py | https://github.com/mars-project/mars/blob/master/mars/tensor/reduction/nancumsum.py | Apache-2.0 |
def nanmax(a, axis=None, out=None, keepdims=None, combine_size=None):
"""
Return the maximum of an array or maximum along an axis, ignoring any
NaNs. When all-NaN slices are encountered a ``RuntimeWarning`` is
raised and NaN is returned for that slice.
Parameters
----------
a : array_like
... |
Return the maximum of an array or maximum along an axis, ignoring any
NaNs. When all-NaN slices are encountered a ``RuntimeWarning`` is
raised and NaN is returned for that slice.
Parameters
----------
a : array_like
Tensor containing numbers whose maximum is desired. If `a` is not a
... | nanmax | python | mars-project/mars | mars/tensor/reduction/nanmax.py | https://github.com/mars-project/mars/blob/master/mars/tensor/reduction/nanmax.py | Apache-2.0 |
def nanmean(a, axis=None, dtype=None, out=None, keepdims=None, combine_size=None):
"""
Compute the arithmetic mean along the specified axis, ignoring NaNs.
Returns the average of the tensor elements. The average is taken over
the flattened tensor by default, otherwise over the specified axis.
`flo... |
Compute the arithmetic mean along the specified axis, ignoring NaNs.
Returns the average of the tensor elements. The average is taken over
the flattened tensor by default, otherwise over the specified axis.
`float64` intermediate and return values are used for integer inputs.
For all-NaN slices,... | nanmean | python | mars-project/mars | mars/tensor/reduction/nanmean.py | https://github.com/mars-project/mars/blob/master/mars/tensor/reduction/nanmean.py | Apache-2.0 |
def nanmin(a, axis=None, out=None, keepdims=None, combine_size=None):
"""
Return minimum of a tensor or minimum along an axis, ignoring any NaNs.
When all-NaN slices are encountered a ``RuntimeWarning`` is raised and
Nan is returned for that slice.
Parameters
----------
a : array_like
... |
Return minimum of a tensor or minimum along an axis, ignoring any NaNs.
When all-NaN slices are encountered a ``RuntimeWarning`` is raised and
Nan is returned for that slice.
Parameters
----------
a : array_like
Tensor containing numbers whose minimum is desired. If `a` is not an
... | nanmin | python | mars-project/mars | mars/tensor/reduction/nanmin.py | https://github.com/mars-project/mars/blob/master/mars/tensor/reduction/nanmin.py | Apache-2.0 |
def nanprod(a, axis=None, dtype=None, out=None, keepdims=None, combine_size=None):
"""
Return the product of array elements over a given axis treating Not a
Numbers (NaNs) as ones.
One is returned for slices that are all-NaN or empty.
Parameters
----------
a : array_like
Tensor con... |
Return the product of array elements over a given axis treating Not a
Numbers (NaNs) as ones.
One is returned for slices that are all-NaN or empty.
Parameters
----------
a : array_like
Tensor containing numbers whose product is desired. If `a` is not an
tensor, a conversion is... | nanprod | python | mars-project/mars | mars/tensor/reduction/nanprod.py | https://github.com/mars-project/mars/blob/master/mars/tensor/reduction/nanprod.py | Apache-2.0 |
def nanstd(
a, axis=None, dtype=None, out=None, ddof=0, keepdims=None, combine_size=None
):
"""
Compute the standard deviation along the specified axis, while
ignoring NaNs.
Returns the standard deviation, a measure of the spread of a
distribution, of the non-NaN tensor elements. The standard d... |
Compute the standard deviation along the specified axis, while
ignoring NaNs.
Returns the standard deviation, a measure of the spread of a
distribution, of the non-NaN tensor elements. The standard deviation is
computed for the flattened tensor by default, otherwise over the
specified axis.
... | nanstd | python | mars-project/mars | mars/tensor/reduction/nanstd.py | https://github.com/mars-project/mars/blob/master/mars/tensor/reduction/nanstd.py | Apache-2.0 |
def nansum(a, axis=None, dtype=None, out=None, keepdims=None, combine_size=None):
"""
Return the sum of array elements over a given axis treating Not a
Numbers (NaNs) as zero.
Zero is returned for slices that are all-NaN or
empty.
Parameters
----------
a : array_like
Tensor con... |
Return the sum of array elements over a given axis treating Not a
Numbers (NaNs) as zero.
Zero is returned for slices that are all-NaN or
empty.
Parameters
----------
a : array_like
Tensor containing numbers whose sum is desired. If `a` is not an
tensor, a conversion is at... | nansum | python | mars-project/mars | mars/tensor/reduction/nansum.py | https://github.com/mars-project/mars/blob/master/mars/tensor/reduction/nansum.py | Apache-2.0 |
def nanvar(
a, axis=None, dtype=None, out=None, ddof=0, keepdims=None, combine_size=None
):
"""
Compute the variance along the specified axis, while ignoring NaNs.
Returns the variance of the tensor elements, a measure of the spread of
a distribution. The variance is computed for the flattened ten... |
Compute the variance along the specified axis, while ignoring NaNs.
Returns the variance of the tensor elements, a measure of the spread of
a distribution. The variance is computed for the flattened tensor by
default, otherwise over the specified axis.
For all-NaN slices or slices with zero degr... | nanvar | python | mars-project/mars | mars/tensor/reduction/nanvar.py | https://github.com/mars-project/mars/blob/master/mars/tensor/reduction/nanvar.py | Apache-2.0 |
def prod(a, axis=None, dtype=None, out=None, keepdims=None, combine_size=None):
"""
Return the product of tensor elements over a given axis.
Parameters
----------
a : array_like
Input data.
axis : None or int or tuple of ints, optional
Axis or axes along which a product is perfo... |
Return the product of tensor elements over a given axis.
Parameters
----------
a : array_like
Input data.
axis : None or int or tuple of ints, optional
Axis or axes along which a product is performed. The default,
axis=None, will calculate the product of all the elements i... | prod | python | mars-project/mars | mars/tensor/reduction/prod.py | https://github.com/mars-project/mars/blob/master/mars/tensor/reduction/prod.py | Apache-2.0 |
def std(a, axis=None, dtype=None, out=None, ddof=0, keepdims=None, combine_size=None):
"""
Compute the standard deviation along the specified axis.
Returns the standard deviation, a measure of the spread of a distribution,
of the tensor elements. The standard deviation is computed for the
flattened... |
Compute the standard deviation along the specified axis.
Returns the standard deviation, a measure of the spread of a distribution,
of the tensor elements. The standard deviation is computed for the
flattened tensor by default, otherwise over the specified axis.
Parameters
----------
a : ... | std | python | mars-project/mars | mars/tensor/reduction/std.py | https://github.com/mars-project/mars/blob/master/mars/tensor/reduction/std.py | Apache-2.0 |
def sum(a, axis=None, dtype=None, out=None, keepdims=None, combine_size=None):
"""
Sum of tensor elements over a given axis.
Parameters
----------
a : array_like
Elements to sum.
axis : None or int or tuple of ints, optional
Axis or axes along which a sum is performed. The defa... |
Sum of tensor elements over a given axis.
Parameters
----------
a : array_like
Elements to sum.
axis : None or int or tuple of ints, optional
Axis or axes along which a sum is performed. The default,
axis=None, will sum all of the elements of the input tensor. If
... | sum | python | mars-project/mars | mars/tensor/reduction/sum.py | https://github.com/mars-project/mars/blob/master/mars/tensor/reduction/sum.py | Apache-2.0 |
def var(a, axis=None, dtype=None, out=None, ddof=0, keepdims=None, combine_size=None):
"""
Compute the variance along the specified axis.
Returns the variance of the tensor elements, a measure of the spread of a
distribution. The variance is computed for the flattened tensor by
default, otherwise ... |
Compute the variance along the specified axis.
Returns the variance of the tensor elements, a measure of the spread of a
distribution. The variance is computed for the flattened tensor by
default, otherwise over the specified axis.
Parameters
----------
a : array_like
Tensor cont... | var | python | mars-project/mars | mars/tensor/reduction/var.py | https://github.com/mars-project/mars/blob/master/mars/tensor/reduction/var.py | Apache-2.0 |
def reshape(a, newshape, order="C"):
"""
Gives a new shape to a tensor without changing its data.
Parameters
----------
a : array_like
Tensor to be reshaped.
newshape : int or tuple of ints
The new shape should be compatible with the original shape. If
an integer, then t... |
Gives a new shape to a tensor without changing its data.
Parameters
----------
a : array_like
Tensor to be reshaped.
newshape : int or tuple of ints
The new shape should be compatible with the original shape. If
an integer, then the result will be a 1-D tensor of that lengt... | reshape | python | mars-project/mars | mars/tensor/reshape/reshape.py | https://github.com/mars-project/mars/blob/master/mars/tensor/reshape/reshape.py | Apache-2.0 |
def cdist(XA, XB, metric="euclidean", **kwargs):
"""
Compute distance between each pair of the two collections of inputs.
See Notes for common calling conventions.
Parameters
----------
XA : Tensor
An :math:`m_A` by :math:`n` tensor of :math:`m_A`
original observations in an :m... |
Compute distance between each pair of the two collections of inputs.
See Notes for common calling conventions.
Parameters
----------
XA : Tensor
An :math:`m_A` by :math:`n` tensor of :math:`m_A`
original observations in an :math:`n`-dimensional space.
Inputs are converted ... | cdist | python | mars-project/mars | mars/tensor/spatial/distance/cdist.py | https://github.com/mars-project/mars/blob/master/mars/tensor/spatial/distance/cdist.py | Apache-2.0 |
def pdist(X, metric="euclidean", **kwargs):
"""
Pairwise distances between observations in n-dimensional space.
See Notes for common calling conventions.
Parameters
----------
X : Tensor
An m by n tensor of m original observations in an
n-dimensional space.
metric : str or ... |
Pairwise distances between observations in n-dimensional space.
See Notes for common calling conventions.
Parameters
----------
X : Tensor
An m by n tensor of m original observations in an
n-dimensional space.
metric : str or function, optional
The distance metric to u... | pdist | python | mars-project/mars | mars/tensor/spatial/distance/pdist.py | https://github.com/mars-project/mars/blob/master/mars/tensor/spatial/distance/pdist.py | Apache-2.0 |
def squareform(X, force="no", checks=True, chunk_size=None):
"""
Convert a vector-form distance vector to a square-form distance
matrix, and vice-versa.
Parameters
----------
X : Tensor
Either a condensed or redundant distance matrix.
force : str, optional
As with MATLAB(TM)... |
Convert a vector-form distance vector to a square-form distance
matrix, and vice-versa.
Parameters
----------
X : Tensor
Either a condensed or redundant distance matrix.
force : str, optional
As with MATLAB(TM), if force is equal to ``'tovector'`` or
``'tomatrix'``, the... | squareform | python | mars-project/mars | mars/tensor/spatial/distance/squareform.py | https://github.com/mars-project/mars/blob/master/mars/tensor/spatial/distance/squareform.py | Apache-2.0 |
def gammaln(x, out=None, where=None, **kwargs):
"""
Logarithm of the absolute value of the Gamma function.
Parameters
----------
x : array-like
Values on the real line at which to compute ``gammaln``
out : Tensor, None, or tuple of Tensor and None, optional
A location into which... |
Logarithm of the absolute value of the Gamma function.
Parameters
----------
x : array-like
Values on the real line at which to compute ``gammaln``
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is stored. If provided, it must have
... | gammaln | python | mars-project/mars | mars/tensor/special/gamma_funcs.py | https://github.com/mars-project/mars/blob/master/mars/tensor/special/gamma_funcs.py | Apache-2.0 |
def entr(x, out=None, where=None, **kwargs):
r"""
Elementwise function for computing entropy.
.. math:: \text{entr}(x) = \begin{cases} - x \log(x) & x > 0 \\ 0 & x = 0 \\ -\infty & \text{otherwise} \end{cases}
Parameters
----------
x : Tensor
Input tensor.
Returns
-------
... |
Elementwise function for computing entropy.
.. math:: \text{entr}(x) = \begin{cases} - x \log(x) & x > 0 \\ 0 & x = 0 \\ -\infty & \text{otherwise} \end{cases}
Parameters
----------
x : Tensor
Input tensor.
Returns
-------
res : Tensor
The value of the elementwise en... | entr | python | mars-project/mars | mars/tensor/special/info_theory.py | https://github.com/mars-project/mars/blob/master/mars/tensor/special/info_theory.py | Apache-2.0 |
def rel_entr(x, y, out=None, where=None, **kwargs):
r"""
Elementwise function for computing relative entropy.
.. math::
\mathrm{rel\_entr}(x, y) =
\begin{cases}
x \log(x / y) & x > 0, y > 0 \\
0 & x = 0, y \ge 0 \\
\infty & \text{otherwis... |
Elementwise function for computing relative entropy.
.. math::
\mathrm{rel\_entr}(x, y) =
\begin{cases}
x \log(x / y) & x > 0, y > 0 \\
0 & x = 0, y \ge 0 \\
\infty & \text{otherwise}
\end{cases}
Parameters
----------
... | rel_entr | python | mars-project/mars | mars/tensor/special/info_theory.py | https://github.com/mars-project/mars/blob/master/mars/tensor/special/info_theory.py | Apache-2.0 |
def kl_div(x, y, out=None, where=None, **kwargs):
r"""
Elementwise function for computing relative entropy.
.. math::
\mathrm{rel\_entr}(x, y) =
\begin{cases}
x \log(x / y) & x > 0, y > 0 \\
0 & x = 0, y \ge 0 \\
\infty & \text{otherwise}... |
Elementwise function for computing relative entropy.
.. math::
\mathrm{rel\_entr}(x, y) =
\begin{cases}
x \log(x / y) & x > 0, y > 0 \\
0 & x = 0, y \ge 0 \\
\infty & \text{otherwise}
\end{cases}
Parameters
----------
... | kl_div | python | mars-project/mars | mars/tensor/special/info_theory.py | https://github.com/mars-project/mars/blob/master/mars/tensor/special/info_theory.py | Apache-2.0 |
def average(a, axis=None, weights=None, returned=False):
"""
Compute the weighted average along the specified axis.
Parameters
----------
a : array_like
Tensor containing data to be averaged. If `a` is not a tensor, a
conversion is attempted.
axis : None or int or tuple of ints,... |
Compute the weighted average along the specified axis.
Parameters
----------
a : array_like
Tensor containing data to be averaged. If `a` is not a tensor, a
conversion is attempted.
axis : None or int or tuple of ints, optional
Axis or axes along which to average `a`. The ... | average | python | mars-project/mars | mars/tensor/statistics/average.py | https://github.com/mars-project/mars/blob/master/mars/tensor/statistics/average.py | Apache-2.0 |
def bincount(x, weights=None, minlength=0, chunk_size_limit=None):
"""
Count number of occurrences of each value in array of non-negative ints.
The number of bins (of size 1) is one larger than the largest value in
`x`. If `minlength` is specified, there will be at least this number
of bins in the ... |
Count number of occurrences of each value in array of non-negative ints.
The number of bins (of size 1) is one larger than the largest value in
`x`. If `minlength` is specified, there will be at least this number
of bins in the output array (though it will be longer if necessary,
depending on the ... | bincount | python | mars-project/mars | mars/tensor/statistics/bincount.py | https://github.com/mars-project/mars/blob/master/mars/tensor/statistics/bincount.py | Apache-2.0 |
def _ureduce(a, func, **kwargs):
"""
Internal Function.
Call `func` with `a` as first argument swapping the axes to use extended
axis on functions that don't support it natively.
Returns result and a.shape with axis dims set to 1.
Parameters
----------
a : array_like
Input tens... |
Internal Function.
Call `func` with `a` as first argument swapping the axes to use extended
axis on functions that don't support it natively.
Returns result and a.shape with axis dims set to 1.
Parameters
----------
a : array_like
Input tensor or object that can be converted to a ... | _ureduce | python | mars-project/mars | mars/tensor/statistics/core.py | https://github.com/mars-project/mars/blob/master/mars/tensor/statistics/core.py | Apache-2.0 |
def cov(m, y=None, rowvar=True, bias=False, ddof=None, fweights=None, aweights=None):
"""
Estimate a covariance matrix, given data and weights.
Covariance indicates the level to which two variables vary together.
If we examine N-dimensional samples, :math:`X = [x_1, x_2, ... x_N]^T`,
then the covar... |
Estimate a covariance matrix, given data and weights.
Covariance indicates the level to which two variables vary together.
If we examine N-dimensional samples, :math:`X = [x_1, x_2, ... x_N]^T`,
then the covariance matrix element :math:`C_{ij}` is the covariance of
:math:`x_i` and :math:`x_j`. The... | cov | python | mars-project/mars | mars/tensor/statistics/cov.py | https://github.com/mars-project/mars/blob/master/mars/tensor/statistics/cov.py | Apache-2.0 |
def digitize(x, bins, right=False):
"""
Return the indices of the bins to which each value in input tensor belongs.
Each index ``i`` returned is such that ``bins[i-1] <= x < bins[i]`` if
`bins` is monotonically increasing, or ``bins[i-1] > x >= bins[i]`` if
`bins` is monotonically decreasing. If va... |
Return the indices of the bins to which each value in input tensor belongs.
Each index ``i`` returned is such that ``bins[i-1] <= x < bins[i]`` if
`bins` is monotonically increasing, or ``bins[i-1] > x >= bins[i]`` if
`bins` is monotonically decreasing. If values in `x` are beyond the
bounds of `b... | digitize | python | mars-project/mars | mars/tensor/statistics/digitize.py | https://github.com/mars-project/mars/blob/master/mars/tensor/statistics/digitize.py | Apache-2.0 |
def _ravel_and_check_weights(a, weights):
"""Check a and weights have matching shapes, and ravel both"""
a = astensor(a)
# Ensure that the array is a "subtractable" dtype
if a.dtype == np.bool_:
warnings.warn(
f"Converting input from {a.dtype} to {np.uint8} for compatibility.",
... | Check a and weights have matching shapes, and ravel both | _ravel_and_check_weights | python | mars-project/mars | mars/tensor/statistics/histogram.py | https://github.com/mars-project/mars/blob/master/mars/tensor/statistics/histogram.py | Apache-2.0 |
def _get_outer_edges(a, range):
"""
Determine the outer bin edges to use, from either the data or the range
argument
"""
if range is not None:
first_edge, last_edge = _check_range(range)
else:
assert a.size == 0
# handle empty arrays. Can't determine range, so use 0-1.
... |
Determine the outer bin edges to use, from either the data or the range
argument
| _get_outer_edges | python | mars-project/mars | mars/tensor/statistics/histogram.py | https://github.com/mars-project/mars/blob/master/mars/tensor/statistics/histogram.py | Apache-2.0 |
def _unsigned_subtract(a, b):
"""
Subtract two values where a >= b, and produce an unsigned result
This is needed when finding the difference between the upper and lower
bound of an int16 histogram
"""
# coerce to a single type
signed_to_unsigned = {
np.byte: np.ubyte,
np.sh... |
Subtract two values where a >= b, and produce an unsigned result
This is needed when finding the difference between the upper and lower
bound of an int16 histogram
| _unsigned_subtract | python | mars-project/mars | mars/tensor/statistics/histogram.py | https://github.com/mars-project/mars/blob/master/mars/tensor/statistics/histogram.py | Apache-2.0 |
def histogram_bin_edges(a, bins=10, range=None, weights=None):
r"""
Function to calculate only the edges of the bins used by the `histogram`
function.
Parameters
----------
a : array_like
Input data. The histogram is computed over the flattened tensor.
bins : int or sequence of scal... |
Function to calculate only the edges of the bins used by the `histogram`
function.
Parameters
----------
a : array_like
Input data. The histogram is computed over the flattened tensor.
bins : int or sequence of scalars or str, optional
If `bins` is an int, it defines the number... | histogram_bin_edges | python | mars-project/mars | mars/tensor/statistics/histogram.py | https://github.com/mars-project/mars/blob/master/mars/tensor/statistics/histogram.py | Apache-2.0 |
def histogram(a, bins=10, range=None, weights=None, density=None):
r"""
Compute the histogram of a set of data.
Parameters
----------
a : array_like
Input data. The histogram is computed over the flattened tensor.
bins : int or sequence of scalars or str, optional
If `bins` is a... |
Compute the histogram of a set of data.
Parameters
----------
a : array_like
Input data. The histogram is computed over the flattened tensor.
bins : int or sequence of scalars or str, optional
If `bins` is an int, it defines the number of equal-width
bins in the given range... | histogram | python | mars-project/mars | mars/tensor/statistics/histogram.py | https://github.com/mars-project/mars/blob/master/mars/tensor/statistics/histogram.py | Apache-2.0 |
def median(a, axis=None, out=None, overwrite_input=False, keepdims=False):
"""
Compute the median along the specified axis.
Returns the median of the tensor elements.
Parameters
----------
a : array_like
Input tensor or object that can be converted to a tensor.
axis : {int, sequenc... |
Compute the median along the specified axis.
Returns the median of the tensor elements.
Parameters
----------
a : array_like
Input tensor or object that can be converted to a tensor.
axis : {int, sequence of int, None}, optional
Axis or axes along which the medians are compute... | median | python | mars-project/mars | mars/tensor/statistics/median.py | https://github.com/mars-project/mars/blob/master/mars/tensor/statistics/median.py | Apache-2.0 |
def percentile(
a,
q,
axis=None,
out=None,
overwrite_input=False,
interpolation="linear",
keepdims=False,
):
"""
Compute the q-th percentile of the data along the specified axis.
Returns the q-th percentile(s) of the array elements.
Parameters
----------
a : array_l... |
Compute the q-th percentile of the data along the specified axis.
Returns the q-th percentile(s) of the array elements.
Parameters
----------
a : array_like
Input tensor or object that can be converted to a tensor.
q : array_like of float
Percentile or sequence of percentiles ... | percentile | python | mars-project/mars | mars/tensor/statistics/percentile.py | https://github.com/mars-project/mars/blob/master/mars/tensor/statistics/percentile.py | Apache-2.0 |
def ptp(a, axis=None, out=None, keepdims=None):
"""
Range of values (maximum - minimum) along an axis.
The name of the function comes from the acronym for 'peak to peak'.
Parameters
----------
a : array_like
Input values.
axis : int, optional
Axis along which to find the pe... |
Range of values (maximum - minimum) along an axis.
The name of the function comes from the acronym for 'peak to peak'.
Parameters
----------
a : array_like
Input values.
axis : int, optional
Axis along which to find the peaks. By default, flatten the
array.
out : ... | ptp | python | mars-project/mars | mars/tensor/statistics/ptp.py | https://github.com/mars-project/mars/blob/master/mars/tensor/statistics/ptp.py | Apache-2.0 |
def quantile(
a,
q,
axis=None,
out=None,
overwrite_input=False,
interpolation="linear",
keepdims=False,
**kw,
):
"""
Compute the q-th quantile of the data along the specified axis.
Parameters
----------
a : array_like
Input tensor or object that can be conver... |
Compute the q-th quantile of the data along the specified axis.
Parameters
----------
a : array_like
Input tensor or object that can be converted to a tensor.
q : array_like of float
Quantile or sequence of quantiles to compute, which must be between
0 and 1 inclusive.
... | quantile | python | mars-project/mars | mars/tensor/statistics/quantile.py | https://github.com/mars-project/mars/blob/master/mars/tensor/statistics/quantile.py | Apache-2.0 |
def _compute_prob_inside_method(m, n, g, h): # pragma: no cover
"""
Count the proportion of paths that stay strictly inside two diagonal lines.
Parameters
----------
m : integer
m > 0
n : integer
n > 0
g : integer
g is greatest common divisor of m and n
h : inte... |
Count the proportion of paths that stay strictly inside two diagonal lines.
Parameters
----------
m : integer
m > 0
n : integer
n > 0
g : integer
g is greatest common divisor of m and n
h : integer
0 <= h <= lcm(m,n)
Returns
-------
p : float
... | _compute_prob_inside_method | python | mars-project/mars | mars/tensor/stats/ks.py | https://github.com/mars-project/mars/blob/master/mars/tensor/stats/ks.py | Apache-2.0 |
def _compute_prob_outside_square(n, h): # pragma: no cover
"""
Compute the proportion of paths that pass outside the two diagonal lines.
Parameters
----------
n : integer
n > 0
h : integer
0 <= h <= n
Returns
-------
p : float
The proportion of paths that p... |
Compute the proportion of paths that pass outside the two diagonal lines.
Parameters
----------
n : integer
n > 0
h : integer
0 <= h <= n
Returns
-------
p : float
The proportion of paths that pass outside the lines x-y = +/-h.
| _compute_prob_outside_square | python | mars-project/mars | mars/tensor/stats/ks.py | https://github.com/mars-project/mars/blob/master/mars/tensor/stats/ks.py | Apache-2.0 |
def _count_paths_outside_method(m, n, g, h): # pragma: no cover
"""
Count the number of paths that pass outside the specified diagonal.
Parameters
----------
m : integer
m > 0
n : integer
n > 0
g : integer
g is greatest common divisor of m and n
h : integer
... |
Count the number of paths that pass outside the specified diagonal.
Parameters
----------
m : integer
m > 0
n : integer
n > 0
g : integer
g is greatest common divisor of m and n
h : integer
0 <= h <= lcm(m,n)
Returns
-------
p : float
Th... | _count_paths_outside_method | python | mars-project/mars | mars/tensor/stats/ks.py | https://github.com/mars-project/mars/blob/master/mars/tensor/stats/ks.py | Apache-2.0 |
def _attempt_exact_2kssamp(n1, n2, g, d, alternative): # pragma: no cover
"""Attempts to compute the exact 2sample probability.
n1, n2 are the sample sizes
g is the gcd(n1, n2)
d is the computed max difference in ECDFs
Returns (success, d, probability)
"""
lcm = (n1 // g) * n2
h = int... | Attempts to compute the exact 2sample probability.
n1, n2 are the sample sizes
g is the gcd(n1, n2)
d is the computed max difference in ECDFs
Returns (success, d, probability)
| _attempt_exact_2kssamp | python | mars-project/mars | mars/tensor/stats/ks.py | https://github.com/mars-project/mars/blob/master/mars/tensor/stats/ks.py | Apache-2.0 |
def ks_1samp(
x: Union[np.ndarray, list, TileableType],
cdf: Callable,
args: Tuple = (),
alternative: str = "two-sided",
mode: str = "auto",
):
"""
Performs the one-sample Kolmogorov-Smirnov test for goodness of fit.
This test compares the underlying distribution F(x) of a sample
ag... |
Performs the one-sample Kolmogorov-Smirnov test for goodness of fit.
This test compares the underlying distribution F(x) of a sample
against a given continuous distribution G(x). See Notes for a description
of the available null and alternative hypotheses.
Parameters
----------
x : array_... | ks_1samp | python | mars-project/mars | mars/tensor/stats/ks.py | https://github.com/mars-project/mars/blob/master/mars/tensor/stats/ks.py | Apache-2.0 |
def ks_2samp(
data1: Union[np.ndarray, list, TileableType],
data2: Union[np.ndarray, list, TileableType],
alternative: str = "two-sided",
mode: str = "auto",
):
"""
Compute the Kolmogorov-Smirnov statistic on 2 samples.
This is a two-sided test for the null hypothesis that 2 independent sam... |
Compute the Kolmogorov-Smirnov statistic on 2 samples.
This is a two-sided test for the null hypothesis that 2 independent samples
are drawn from the same continuous distribution. The alternative hypothesis
can be either 'two-sided' (default), 'less' or 'greater'.
Parameters
----------
d... | ks_2samp | python | mars-project/mars | mars/tensor/stats/ks.py | https://github.com/mars-project/mars/blob/master/mars/tensor/stats/ks.py | Apache-2.0 |
def power_divergence(f_obs, f_exp=None, ddof=0, axis=0, lambda_=None):
"""
Cressie-Read power divergence statistic and goodness of fit test.
This function tests the null hypothesis that the categorical data
has the given frequencies, using the Cressie-Read power divergence
statistic.
Parameter... |
Cressie-Read power divergence statistic and goodness of fit test.
This function tests the null hypothesis that the categorical data
has the given frequencies, using the Cressie-Read power divergence
statistic.
Parameters
----------
f_obs : array_like
Observed frequencies in each c... | power_divergence | python | mars-project/mars | mars/tensor/stats/power_divergence.py | https://github.com/mars-project/mars/blob/master/mars/tensor/stats/power_divergence.py | Apache-2.0 |
def rankdata(a, method="average", *, axis=None):
"""Assign ranks to data, dealing with ties appropriately.
By default (``axis=None``), the data array is first flattened, and a flat
array of ranks is returned. Separately reshape the rank array to the
shape of the data array if desired (see Examples).
... | Assign ranks to data, dealing with ties appropriately.
By default (``axis=None``), the data array is first flattened, and a flat
array of ranks is returned. Separately reshape the rank array to the
shape of the data array if desired (see Examples).
Ranks begin at 1. The `method` argument controls how r... | rankdata | python | mars-project/mars | mars/tensor/stats/rankdata.py | https://github.com/mars-project/mars/blob/master/mars/tensor/stats/rankdata.py | Apache-2.0 |
def _ttest_finish(df, t, alternative):
"""Common code between all 3 t-test functions."""
if alternative != "two-sided" and parse_version(sp_version) < parse_version(
"1.6.0"
): # pragma: no cover
raise ValueError("alternative must be 'two-sided' with scipy prior to 1.6.0")
if alternati... | Common code between all 3 t-test functions. | _ttest_finish | python | mars-project/mars | mars/tensor/stats/ttest.py | https://github.com/mars-project/mars/blob/master/mars/tensor/stats/ttest.py | Apache-2.0 |
async def wait_for_condition(
condition_predictor, timeout=10, retry_interval_ms=100, **kwargs
): # pragma: no cover
"""Wait until a condition is met or time out with an exception.
Args:
condition_predictor: A function that predicts the condition.
timeout: Maximum timeout in seconds.
... | Wait until a condition is met or time out with an exception.
Args:
condition_predictor: A function that predicts the condition.
timeout: Maximum timeout in seconds.
retry_interval_ms: Retry interval in milliseconds.
Raises:
RuntimeError: If the condition is not met before the t... | wait_for_condition | python | mars-project/mars | mars/tests/core.py | https://github.com/mars-project/mars/blob/master/mars/tests/core.py | Apache-2.0 |
def glibc_version_string():
"Returns glibc version string, or None if not using glibc."
# ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen
# manpage says, "If filename is NULL, then the returned handle is for the
# main program". This way we can let the linker do the work to figure ou... | Returns glibc version string, or None if not using glibc. | glibc_version_string | python | plasticityai/magnitude | glibc.py | https://github.com/plasticityai/magnitude/blob/master/glibc.py | MIT |
def libc_ver():
"""Try to determine the glibc version
Returns a tuple of strings (lib, version) which default to empty strings
in case the lookup fails.
"""
glibc_version = glibc_version_string()
if glibc_version is None:
return ("", "")
else:
return ("glibc", glibc_version) | Try to determine the glibc version
Returns a tuple of strings (lib, version) which default to empty strings
in case the lookup fails.
| libc_ver | python | plasticityai/magnitude | glibc.py | https://github.com/plasticityai/magnitude/blob/master/glibc.py | MIT |
def get_impl_version_info():
"""Return sys.version_info-like tuple for use in decrementing the minor
version."""
if get_abbr_impl() == 'pp':
# as per https://github.com/pypa/pip/issues/2882
return (sys.version_info[0], sys.pypy_version_info.major,
sys.pypy_version_info.minor)... | Return sys.version_info-like tuple for use in decrementing the minor
version. | get_impl_version_info | python | plasticityai/magnitude | pep425tags.py | https://github.com/plasticityai/magnitude/blob/master/pep425tags.py | MIT |
def get_flag(var, fallback, expected=True, warn=True):
"""Use a fallback method for determining SOABI flags if the needed config
var is unset or unavailable."""
val = get_config_var(var)
if val is None:
if warn:
log.debug("Config variable '%s' is unset, Python ABI tag may "
... | Use a fallback method for determining SOABI flags if the needed config
var is unset or unavailable. | get_flag | python | plasticityai/magnitude | pep425tags.py | https://github.com/plasticityai/magnitude/blob/master/pep425tags.py | MIT |
def get_abi_tag():
"""Return the ABI tag based on SOABI (if available) or emulate SOABI
(CPython 2, PyPy)."""
soabi = get_config_var('SOABI')
impl = get_abbr_impl()
if not soabi and impl in {'cp', 'pp'} and hasattr(sys, 'maxunicode'):
d = ''
m = ''
u = ''
if get_flag(... | Return the ABI tag based on SOABI (if available) or emulate SOABI
(CPython 2, PyPy). | get_abi_tag | python | plasticityai/magnitude | pep425tags.py | https://github.com/plasticityai/magnitude/blob/master/pep425tags.py | MIT |
def get_darwin_arches(major, minor, machine):
"""Return a list of supported arches (including group arches) for
the given major, minor and machine architecture of an macOS machine.
"""
arches = []
def _supports_arch(major, minor, arch):
# Looking at the application support for macOS version... | Return a list of supported arches (including group arches) for
the given major, minor and machine architecture of an macOS machine.
| get_darwin_arches | python | plasticityai/magnitude | pep425tags.py | https://github.com/plasticityai/magnitude/blob/master/pep425tags.py | MIT |
def get_supported(versions=None, noarch=False, platform=None,
impl=None, abi=None):
"""Return a list of supported tags for each version specified in
`versions`.
:param versions: a list of string versions, of the form ["33", "32"],
or None. The first version will be assumed to supp... | Return a list of supported tags for each version specified in
`versions`.
:param versions: a list of string versions, of the form ["33", "32"],
or None. The first version will be assumed to support our ABI.
:param platform: specify the exact platform you want valid
tags for, or None. If Non... | get_supported | python | plasticityai/magnitude | pep425tags.py | https://github.com/plasticityai/magnitude/blob/master/pep425tags.py | MIT |
def download_and_install_wheel():
"""Downloads and installs pre-compiled remote wheels"""
if skip_wheel():
return False
if installed_wheel():
return True
if tried_downloading_wheel():
return False
print("Downloading and installing wheel (if it exists)...")
tmpwhl_dir = te... | Downloads and installs pre-compiled remote wheels | download_and_install_wheel | python | plasticityai/magnitude | setup.py | https://github.com/plasticityai/magnitude/blob/master/setup.py | MIT |
def parse_requirements(filename):
""" load requirements from a pip requirements file """
lineiter = (line.strip() for line in open(filename))
return [line for line in lineiter if line and not line.startswith("#")] | load requirements from a pip requirements file | parse_requirements | python | plasticityai/magnitude | setup.py | https://github.com/plasticityai/magnitude/blob/master/setup.py | MIT |
def copy_custom_compile():
"""Copy the third party folders into site-packages under
PACKAGE_NAME/third_party/internal/ and
./build/lib/PACKAGE_NAME/third_party/internal/
for good measure"""
from distutils.dir_util import copy_tree
try:
import site
cp_from = INTERNAL + '/'
... | Copy the third party folders into site-packages under
PACKAGE_NAME/third_party/internal/ and
./build/lib/PACKAGE_NAME/third_party/internal/
for good measure | copy_custom_compile | python | plasticityai/magnitude | setup.py | https://github.com/plasticityai/magnitude/blob/master/setup.py | MIT |
def _sqlite_try_max_variable_number(num):
""" Tests whether SQLite can handle num variables """
db = sqlite3.connect(':memory:')
try:
db.cursor().execute(
"SELECT 1 IN (" + ",".join(["?"] * num) + ")",
([0] * num)
).fetchall()
return num
except BaseExcepti... | Tests whether SQLite can handle num variables | _sqlite_try_max_variable_number | python | plasticityai/magnitude | pymagnitude/__init__.py | https://github.com/plasticityai/magnitude/blob/master/pymagnitude/__init__.py | MIT |
def __new__(cls, *args, **kwargs):
""" Returns a concatenated magnitude object, if Magnitude parameters """
if len(args) > 0 and isinstance(args[0], Magnitude):
obj = object.__new__(ConcatenatedMagnitude, *args, **kwargs)
obj.__init__(*args, **kwargs)
else:
ob... | Returns a concatenated magnitude object, if Magnitude parameters | __new__ | python | plasticityai/magnitude | pymagnitude/__init__.py | https://github.com/plasticityai/magnitude/blob/master/pymagnitude/__init__.py | MIT |
def _db(self, force_new=False, downloader=False):
"""Returns a cursor to the database. Each thread gets its
own cursor.
"""
identifier = threading.current_thread().ident
conn_exists = identifier in self._cursors
if not conn_exists or force_new:
if self.fd:
... | Returns a cursor to the database. Each thread gets its
own cursor.
| _db | python | plasticityai/magnitude | pymagnitude/__init__.py | https://github.com/plasticityai/magnitude/blob/master/pymagnitude/__init__.py | MIT |
def _key_t(self, key):
"""Transforms a key to lower case depending on case
sensitivity.
"""
if self.case_insensitive and (isinstance(key, str) or
isinstance(key, unicode)):
return key.lower()
return key | Transforms a key to lower case depending on case
sensitivity.
| _key_t | python | plasticityai/magnitude | pymagnitude/__init__.py | https://github.com/plasticityai/magnitude/blob/master/pymagnitude/__init__.py | MIT |
def _oov_key_t(self, key):
"""Transforms a key for out-of-vocabulary lookup.
"""
is_str = isinstance(key, str) or isinstance(key, unicode)
if is_str:
key = Magnitude.BOW + self._key_t(key) + Magnitude.EOW
return is_str, self._key_shrunk_2(key)
return is_st... | Transforms a key for out-of-vocabulary lookup.
| _oov_key_t | python | plasticityai/magnitude | pymagnitude/__init__.py | https://github.com/plasticityai/magnitude/blob/master/pymagnitude/__init__.py | MIT |
def _oov_english_stem_english_ixes(self, key):
"""Strips away common English prefixes and suffixes."""
key_lower = key.lower()
start_idx = 0
end_idx = 0
for p in Magnitude.ENGLISH_PREFIXES:
if key_lower[:len(p)] == p:
start_idx = len(p)
... | Strips away common English prefixes and suffixes. | _oov_english_stem_english_ixes | python | plasticityai/magnitude | pymagnitude/__init__.py | https://github.com/plasticityai/magnitude/blob/master/pymagnitude/__init__.py | MIT |
def _oov_stem(self, key):
"""Strips away common prefixes and suffixes."""
if len(key) <= Magnitude.MAX_KEY_LENGTH_FOR_STEM:
if self.language == 'en':
return self._oov_english_stem_english_ixes(key)
return key | Strips away common prefixes and suffixes. | _oov_stem | python | plasticityai/magnitude | pymagnitude/__init__.py | https://github.com/plasticityai/magnitude/blob/master/pymagnitude/__init__.py | MIT |
def _db_query_similar_keys_vector(
self, key, orig_key, topn=3, normalized=None):
"""Finds similar keys in the database and gets the mean vector."""
normalized = normalized if normalized is not None else self.normalized
def _sql_escape_single(s):
return s.replace("'", "'... | Finds similar keys in the database and gets the mean vector. | _db_query_similar_keys_vector | python | plasticityai/magnitude | pymagnitude/__init__.py | https://github.com/plasticityai/magnitude/blob/master/pymagnitude/__init__.py | MIT |
def _seed(self, val):
"""Returns a unique seed for val and the (optional) namespace."""
if self._namespace:
return xxhash.xxh32(
self._namespace.encode('utf-8') +
Magnitude.RARE_CHAR +
val.encode('utf-8')).intdigest()
else:
... | Returns a unique seed for val and the (optional) namespace. | _seed | python | plasticityai/magnitude | pymagnitude/__init__.py | https://github.com/plasticityai/magnitude/blob/master/pymagnitude/__init__.py | MIT |
def _process_lm_output(self, q, normalized):
"""Process the output from a language model"""
zero_d = not(isinstance(q, list))
one_d = not(zero_d) and (len(q) == 0 or not(isinstance(q[0], list)))
if self.elmo:
if zero_d:
r_val = np.concatenate(self.get_elmo_emb... | Process the output from a language model | _process_lm_output | python | plasticityai/magnitude | pymagnitude/__init__.py | https://github.com/plasticityai/magnitude/blob/master/pymagnitude/__init__.py | MIT |
def _out_of_vocab_vector(self, key, normalized=None, force=False):
"""Generates a random vector based on the hash of the key."""
normalized = normalized if normalized is not None else self.normalized
orig_key = key
is_str, key = self._oov_key_t(key)
if self._is_lm() and is_str an... | Generates a random vector based on the hash of the key. | _out_of_vocab_vector | python | plasticityai/magnitude | pymagnitude/__init__.py | https://github.com/plasticityai/magnitude/blob/master/pymagnitude/__init__.py | MIT |
def _db_batch_generator(self, params):
""" Generates batches of paramaters that respect
SQLite's MAX_VARIABLE_NUMBER """
if len(params) <= Magnitude.SQLITE_MAX_VARIABLE_NUMBER:
yield params
else:
it = iter(params)
for batch in \
ite... | Generates batches of paramaters that respect
SQLite's MAX_VARIABLE_NUMBER | _db_batch_generator | python | plasticityai/magnitude | pymagnitude/__init__.py | https://github.com/plasticityai/magnitude/blob/master/pymagnitude/__init__.py | MIT |
def _db_full_result_to_vec(self, result, put_cache=True, normalized=None):
"""Converts a full database result to a vector."""
normalized = normalized if normalized is not None else self.normalized
result_key = result[0]
vec = self._db_result_to_vec(result[1:], normalized)
if put_... | Converts a full database result to a vector. | _db_full_result_to_vec | python | plasticityai/magnitude | pymagnitude/__init__.py | https://github.com/plasticityai/magnitude/blob/master/pymagnitude/__init__.py | MIT |
def _vector_for_key(self, key, normalized=None):
"""Queries the database for a single key."""
normalized = normalized if normalized is not None else self.normalized
result = self._db().execute(
"""
SELECT *
FROM `magnitude`
WHERE key = ... | Queries the database for a single key. | _vector_for_key | python | plasticityai/magnitude | pymagnitude/__init__.py | https://github.com/plasticityai/magnitude/blob/master/pymagnitude/__init__.py | MIT |
def _vectors_for_keys_cached(self, keys, normalized=None, force=False):
"""Queries the database for multiple keys."""
normalized = normalized if normalized is not None else self.normalized
if self._is_lm() and not force:
keys = [self._key_t(key) for key in keys]
return se... | Queries the database for multiple keys. | _vectors_for_keys_cached | python | plasticityai/magnitude | pymagnitude/__init__.py | https://github.com/plasticityai/magnitude/blob/master/pymagnitude/__init__.py | MIT |
def _key_for_index(self, index, return_vector=True):
"""Queries the database the key at a single index."""
columns = "key"
if return_vector:
columns = "*"
result = self._db().execute(
"""
SELECT """ + columns + """
FROM `magnitude`
... | Queries the database the key at a single index. | _key_for_index | python | plasticityai/magnitude | pymagnitude/__init__.py | https://github.com/plasticityai/magnitude/blob/master/pymagnitude/__init__.py | MIT |
def _keys_for_indices(self, indices, return_vector=True):
"""Queries the database for the keys of multiple indices."""
unseen_indices = tuple(int(index + 1) for index in indices
if self._key_for_index_cached._cache.get(((index,), # noqa
... | Queries the database for the keys of multiple indices. | _keys_for_indices | python | plasticityai/magnitude | pymagnitude/__init__.py | https://github.com/plasticityai/magnitude/blob/master/pymagnitude/__init__.py | MIT |
def query(self, q, pad_to_length=None,
pad_left=None, truncate_left=None,
normalized=None):
"""Handles a query of keys which could be a single key, a
1-D list of keys, or a 2-D list of keys.
"""
normalized = normalized if normalized is not None else self.norma... | Handles a query of keys which could be a single key, a
1-D list of keys, or a 2-D list of keys.
| query | python | plasticityai/magnitude | pymagnitude/__init__.py | https://github.com/plasticityai/magnitude/blob/master/pymagnitude/__init__.py | MIT |
def unroll(self, v):
""" Unrolls a vector if it was concatenated from its base model
form. """
if self.elmo and isinstance(v, np.ndarray):
return unroll_elmo(v, self.placeholders)
else:
return v | Unrolls a vector if it was concatenated from its base model
form. | unroll | python | plasticityai/magnitude | pymagnitude/__init__.py | https://github.com/plasticityai/magnitude/blob/master/pymagnitude/__init__.py | MIT |
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.