This is a pre-release version (latest). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy latest / numpy / testing / _private / utils / nulp_diff

function

numpy.testing._private.utils:nulp_diff

source: build-install/usr/lib/python3.14/site-packages/numpy/testing/_private/utils.py :1888

Signature

def   nulp_diff ( x y dtype = None )

Summary

For each item in x and y, return the number of representable floating points between them.

Parameters

x : array_like

first input array

y : array_like

second input array

dtype : dtype, optional

Data-type to convert x and y to if given. Default is None.

Returns

nulp : array_like

number of representable floating point numbers between each item in x and y.

Notes

For computing the ULP difference, this API does not differentiate between various representations of NAN (ULP difference between 0x7fc00000 and 0xffc00000 is zero).

Examples

# By definition, epsilon is the smallest number such as 1 + eps != 1, so # there should be exactly one ULP between 1 and 1 + eps
nulp_diff(1, 1 + np.finfo(x.dtype).eps)

Aliases

  • numpy.testing._private.utils.nulp_diff