Compare two arrays relatively to their spacing.
This is a relatively robust method to compare two arrays whose amplitude is variable.
Parameters: | x, y : array_like
nulp : int, optional
|
---|---|
Returns: | None : |
Raises: | AssertionError :
|
See also
Notes
An assertion is raised if the following condition is not met:
abs(x - y) <= nulps * spacing(max(abs(x), abs(y)))
Examples
>>> 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)