dpnp.allclose

dpnp.allclose(a, b, rtol=1e-05, atol=1e-08, **kwargs)[source]

Returns True if two arrays are element-wise equal within a tolerance.

The tolerance values are positive, typically very small numbers. The relative difference (rtol * abs(b)) and the absolute difference atol are added together to compare against the absolute difference between a and b.

If either array contains one or more NaNs, False is returned. Infs are treated as equal if they are in the same place and of the same sign in both arrays.

For full documentation refer to numpy.allclose.

Returns:

out -- A 0-dim array with True value if the two arrays are equal within the given tolerance; with False otherwise.

Return type:

dpnp.ndarray

Limitations

Parameters a and b are supported either as dpnp.ndarray, dpctl.tensor.usm_ndarray or scalars, but both a and b can not be scalars at the same time. Keyword argument kwargs is currently unsupported. Otherwise the functions will be executed sequentially on CPU. Parameters rtol and atol are supported as scalars. Otherwise TypeError exception will be raised. Input array data types are limited by supported integer and floating DPNP Available array data types.

See also

dpnp.isclose

Test whether two arrays are element-wise equal.

dpnp.all

Test whether all elements evaluate to True.

dpnp.any

Test whether any element evaluates to True.

dpnp.equal

Return (x1 == x2) element-wise.

Examples

>>> import dpnp as np
>>> a = np.array([1e10, 1e-7])
>>> b = np.array([1.00001e10, 1e-8])
>>> np.allclose(a, b)
array([False])
>>> a = np.array([1.0, np.nan])
>>> b = np.array([1.0, np.nan])
>>> np.allclose(a, b)
array([False])
>>> a = np.array([1.0, np.inf])
>>> b = np.array([1.0, np.inf])
>>> np.allclose(a, b)
array([ True])