mars.tensor.spacing¶

mars.tensor.spacing(x, out=None, where=None, **kwargs)[source]

Return the distance between x and the nearest adjacent number.

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 the inputs broadcast to. If not provided or None, a freshly-allocated tensor is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
where : array_like, optional
Values of True indicate to calculate the ufunc at that position, values of False indicate to leave the value in the output alone.

**kwargs

out : array_like
The spacing of values of x1.

It can be considered as a generalization of EPS: spacing(mt.float64(1)) == mt.finfo(mt.float64).eps, and there should not be any representable number between x + spacing(x) and x for any finite x.

Spacing of +- inf and NaN is NaN.

>>> import mars.tensor as mt

>>> (mt.spacing(1) == mt.finfo(mt.float64).eps).execute()
True