assert_array_almost_equal_nulp(x, y, nulp=1)
This is a relatively robust method to compare two arrays whose amplitude is variable.
An assertion is raised if the following condition is not met:
abs(x - y) <= nulps * spacing(maximum(abs(x), abs(y)))
Input arrays.
The maximum number of unit in the last place for tolerance (see Notes). Default is 1.
If the spacing between x
and y
for one or more elements is larger than :None:None:`nulp`
.
Compare two arrays relatively to their spacing.
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.
>>> x = np.array([1., 1e-10, 1e-20])This example is valid syntax, but we were not able to check execution
... eps = np.finfo(x.dtype).eps
... np.testing.assert_array_almost_equal_nulp(x, x*eps/2 + x)
>>> 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 :
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
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