dpnp.spacing

dpnp.spacing = <DPNPUnaryFunc 'spacing'>

Return the distance between x and the nearest adjacent number.

For full documentation refer to numpy.spacing.

Parameters:
x{dpnp.ndarray, usm_ndarray}

The array of values to find the spacing of, expected to have a real-valued floating-point data type.

out{None, dpnp.ndarray, usm_ndarray, tuple of ndarray}, optional

Output array to populate. Array must have the correct shape and the expected data type. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

Default: None.

order{None, "C", "F", "A", "K"}, optional

Memory layout of the newly output array, if parameter out is None.

Default: "K".

Returns:
outdpnp.ndarray

The spacing of values of x. The data type of the returned array is determined by the Type Promotion Rules.

Limitations

Parameters where and subok are supported with their default values. Keyword argument kwargs is currently unsupported. Otherwise NotImplementedError exception will be raised.

Notes

It can be considered as a generalization of EPS: dpnp.spacing(dpnp.float64(1)) == dpnp.finfo(dpnp.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.

Examples

>>> import dpnp as np
>>> a = np.array(1)
>>> b = np.spacing(a)
>>> b == np.finfo(b.dtype).eps
array(True)