scipp.nan_to_num#

scipp.nan_to_num(x, *, nan=None, posinf=None, neginf=None, out=None)#

Element-wise special value replacement.

All elements in the output are identical to input except in the presence of a NaN, Inf or -Inf. The function allows replacements to be separately specified for NaN, Inf or -Inf values. You can choose to replace a subset of those special values by providing just the required keyword arguments.

Parameters:
  • x (Variable) – Input data.

  • nan (Optional[Variable], default: None) – Replacement values for NaN in the input.

  • posinf (Optional[Variable], default: None) – Replacement values for Inf in the input.

  • neginf (Optional[Variable], default: None) – Replacement values for -Inf in the input.

  • out (Optional[Variable], default: None) – Optional output buffer.

Raises:

scipp.DTypeError – If the types of input and replacement do not match.

Returns:

Variable – Input with specified substitutions.