numpy 1.22.4 Pypi GitHub Homepage
Other Docs
NotesParametersRaisesReturnsBackRef
assert_array_almost_equal_nulp(x, y, nulp=1)

This is a relatively robust method to compare two arrays whose amplitude is variable.

Notes

An assertion is raised if the following condition is not met:

abs(x - y) <= nulps * spacing(maximum(abs(x), abs(y)))

Parameters

x, y : array_like

Input arrays.

nulp : int, optional

The maximum number of unit in the last place for tolerance (see Notes). Default is 1.

Raises

AssertionError

If the spacing between x and y for one or more elements is larger than :None:None:`nulp`.

Returns

None

Compare two arrays relatively to their spacing.

See Also

assert_array_max_ulp

Check that all items of arrays differ in at most N Units in the Last Place.

spacing

Return the distance between x and the nearest adjacent number.

Examples

This example is valid syntax, but we were not able to check execution
>>> x = np.array([1., 1e-10, 1e-20])
... eps = np.finfo(x.dtype).eps
... np.testing.assert_array_almost_equal_nulp(x, x*eps/2 + x)
This example is valid syntax, but we were not able to check execution
>>> np.testing.assert_array_almost_equal_nulp(x, x*eps + x)
Traceback (most recent call last):
  ...
AssertionError: X and Y are not equal to 1 ULP (max is 2)
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

numpy.testing._private.utils.assert_array_almost_equal numpy.testing._private.utils.assert_almost_equal numpy.testing._private.utils.assert_array_equal numpy.testing._private.utils.assert_allclose numpy.testing._private.utils.assert_approx_equal numpy.testing._private.utils.assert_array_max_ulp

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /numpy/testing/_private/utils.py#1534
type: <class 'function'>
Commit: