Skip to content

Make hardwired tolerances configurable via a tol parameter (in units of eps) #268

Open

Description

@petercorke

Summary

Any function that applies a hardwired numerical tolerance should expose it as a tol parameter, expressed in units of machine epsilon (eps), so that callers can tighten or loosen it for their application.

Convention

The base module already follows this pattern in places, for example unitvec, iszero, iszerovec, isunitvec and angvec2r: tol is a multiple of eps (default 20), and a quantity is treated as zero when abs(x) < tol * eps. This issue is to apply it consistently.

Scope

  • Audit the package for literal tolerances (e.g. 1e-6, 1e-12), and for calls that rely on the default tolerance of a lower-level function.
  • Where a tolerance affects the result, add a tol parameter in units of eps, with a default that preserves current behaviour, and document it in the docstring.
  • Where the tolerance is used deep inside a base function, pass tol through every intermediate function, so a caller of a high-level method such as an SO3 or UnitQuaternion constructor can still control it. This may require adding the parameter to several functions in a call chain.

Example

UnitQuaternion.AngVec (see #266) now tests the angle with smb.iszero(theta), which uses the default tolerance. A caller cannot change it. It should accept tol and pass it to iszero, and the same applies to SO3.AngleAxis, SE3.AngleAxis and angvec2tr, which call angvec2r (which already has tol, see #267) but do not expose it.

Notes

  • Keep defaults unchanged so there is no behaviour change for existing code.
  • Add a test per changed function showing that tol takes effect.

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions