aquakin.check_finite_gradient#

aquakin.check_finite_gradient(value, *, what, remedy)[source]#

Raise a friendly RuntimeError if value is non-finite.

The silent-NaN footgun of differentiating a stiff solve: the gradient comes back NaN/Inf and nothing says why. Call this on a freshly computed gradient/Jacobian to convert that into an actionable error.

Parameters:
  • value (array-like) – The gradient or Jacobian to check.

  • what (str) – Short noun for the message (e.g. "calibration gradient").

  • remedy (str) – The concrete fix to suggest.

Return type:

None