newton.math.safe_div#

newton.math.safe_div(x, y, eps=EPSILON)[source]#

Safe division that returns x / y, falling back to x / eps when y is zero.

Parameters:
  • x (Any) – Numerator.

  • y (Any) – Denominator.

  • eps (float) – Small positive fallback used in place of y when y == 0.

Returns:

The quotient x / y, or x / eps if y is zero.

Return type:

Any