value_is_nan#

ivy.value_is_nan(x, /, *, include_infs=True)[source]#

Determine whether the single valued array or scalar is of nan type.

Parameters:
  • x (Union[Array, NativeArray, Number]) – The input to check Input array.

  • include_infs (bool, default: True) – Whether to include infs and -infs in the check. Default is True.

Return type:

bool

Returns:

ret – Boolean as to whether the input value is a nan or not.

Examples

>>> x = ivy.array([451])
>>> y = ivy.value_is_nan(x)
>>> print(y)
False
>>> x = ivy.array([float('inf')])
>>> y = ivy.value_is_nan(x)
>>> print(y)
True
>>> x = ivy.array([float('inf')])
>>> y = ivy.value_is_nan(x, include_infs=False)
>>> print(y)
False
>>> x = ivy.array([float('nan')])
>>> y = ivy.value_is_nan(x, include_infs=False)
>>> print(y)
True
>>> x = ivy.array([0])
>>> y = ivy.value_is_nan(x)
>>> print(y)
False
Array.value_is_nan(self, /, *, include_infs=True)[source]#

ivy.Array instance method variant of ivy.value_is_nan. This method simply wraps the function, and so the docstring for ivy.value_is_nan also applies to this method with minimal changes.

Parameters:
  • self (Array) – input array

  • include_infs (bool, default: True) – Whether to include infs and -infs in the check. Default is True.

Return type:

bool

Returns:

ret – Boolean as to whether the input value is a nan or not.

Examples

With one ivy.Array instance method:

>>> x = ivy.array([92])
>>> y = x.value_is_nan()
>>> print(y)
False
>>> x = ivy.array([float('inf')])
>>> y = x.value_is_nan()
>>> print(y)
True
>>> x = ivy.array([float('nan')])
>>> y = x.value_is_nan()
>>> print(y)
True
>>> x = ivy.array([float('inf')])
>>> y = x.value_is_nan(include_infs=False)
>>> print(y)
False
Container.value_is_nan(self, /, *, include_infs=True, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

ivy.Container instance method variant of ivy.value_is_nan. This method simply wraps the function, and so the docstring for ivy.value_is_nan also applies to this method with minimal changes.

Parameters:
  • self (Container) – input container.

  • include_infs (Union[bool, Container], default: True) – Whether to include infs and -infs in the check. Default is True.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The key-chains to apply or not apply the method to. Default is None.

  • to_apply (Union[bool, Container], default: True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is True.

  • prune_unapplied (Union[bool, Container], default: False) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (Union[bool, Container], default: False) – Whether to also map method to sequences (lists, tuples). Default is False.

Return type:

Container

Returns:

ret – Boolean as to whether the input value is a nan or not.

Examples

>>> x = ivy.Container(a=ivy.array([425]), b=ivy.array([float('nan')]))
>>> y = x.value_is_nan()
>>> print(y)
{
    a: False,
    b: True
}
>>> x = ivy.Container(a=ivy.array([float('inf')]), b=ivy.array([0]))
>>> y = x.value_is_nan()
>>> print(y)
{
    a: True,
    b: False
}
>>> x = ivy.Container(a=ivy.array([float('inf')]), b=ivy.array([22]))
>>> y = x.value_is_nan(include_infs=False)
>>> print(y)
{
    a: False,
    b: False
}