isclose

Contents

isclose#

class saiunit.math.isclose(x, y, rtol=None, atol=None, equal_nan=False, **kwargs)#

Returns a boolean array where 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.

Parameters:
  • x (saiunit.Quantity | Array | ndarray | bool | number | bool | int | float | complex) – Input arrays to compare.

  • y (saiunit.Quantity | Array | ndarray | bool | number | bool | int | float | complex) – Input arrays to compare.

  • rtol (float | saiunit.Quantity) – The relative tolerance parameter (see Notes).

  • atol (float | saiunit.Quantity) – The absolute tolerance parameter (see Notes).

  • equal_nan (bool) – Whether to compare NaN’s as equal. If True, NaN’s in a will be considered equal to NaN’s in b in the output array.

Returns:

out – Boolean array where x and y are equal within tolerance.

Return type:

bool | Array

Examples

>>> import saiunit as u
>>> import jax.numpy as jnp
>>> u.math.isclose(jnp.array([1.0, 2.0]), jnp.array([1.0, 2.0001]))
Array([ True,  True], dtype=bool)