brainstate.transform.debug_nan_if#
- brainstate.transform.debug_nan_if(has_nan, fn, *args, phase='')[source]#
Conditionally run fn with NaN / Inf detection.
Equivalent to:
if has_nan: debug_nan(fn, *args, phase=phase)
but JIT-compatible via
jax.lax.cond.- Parameters:
has_nan (
Array|ndarray|bool|number|bool|int|float|complex|Quantity) – Condition to trigger debugging. Batched arrays are collapsed withunvmap(..., op='any').fn (
Callable) – The function to debug.*args – Arguments to pass to the function.
phase (
str) – Label prepended to the error message.
- Return type:
See also
debug_nanUnconditional variant.