jax.numpy.isnan#

jax.numpy.isnan(x, /)[source]#

Returns a boolean array indicating whether each element of input is NaN.

JAX implementation of numpy.isnan.

Parameters:

x (ArrayLike) – input array or scalar.

Returns:

A boolean array of same shape as x containing True where x is not a number (i.e. NaN) and False otherwise.

Return type:

Array

See also

  • jax.numpy.isfinite(): Returns a boolean array indicating whether each element of input is finite.

  • jax.numpy.isinf(): Returns a boolean array indicating whether each element of input is either positive or negative infinity.

  • jax.numpy.isposinf(): Returns a boolean array indicating whether each element of input is positive infinity.

  • jax.numpy.isneginf(): Returns a boolean array indicating whether each element of input is negative infinity.

Examples

>>> jnp.isnan(6)
Array(False, dtype=bool, weak_type=True)
>>> x = jnp.array([2, 1+4j, jnp.inf, jnp.nan])
>>> jnp.isnan(x)
Array([False, False, False,  True], dtype=bool)