tolerancing.registry#

Tolerance Registry Module

This module contains the base class for tolerance types and the registry that maps tolerance type names, as used by Tolerancing.add_tolerance, to their classes. Register a ToleranceType subclass to add a new kind of tolerance without changing core code.

Kramer Harrison, 2026

Classes

ToleranceRegistry()

Registry of tolerance types, keyed by name.

ToleranceType(optic, **kwargs)

Applies a signed deviation from nominal to one property of an optic.

class ToleranceRegistry[source]#

Registry of tolerance types, keyed by name.

get(name: str) → type[ToleranceType][source]#

Return the class registered under name.

Raises:

ValueError – If name is not registered.

names() → list[str][source]#

Return the registered names, sorted.

register(name: str, tolerance_cls: type[ToleranceType], overwrite: bool = False) → None[source]#

Register a tolerance type.

Parameters:
  • name – The name used in Tolerancing.add_tolerance.

  • tolerance_cls – A ToleranceType subclass.

  • overwrite – Replace an existing registration with the same name.

Raises:
  • TypeError – If tolerance_cls is not a ToleranceType subclass.

  • ValueError – If name is already registered and overwrite is False.

class ToleranceType(optic: Optic, **kwargs)[source]#

Applies a signed deviation from nominal to one property of an optic.

Subclasses read the nominal state in __init__ and must restore it exactly in reset.

Parameters:
  • optic – The optic the tolerance applies to.

  • **kwargs – Type-specific arguments, such as surface_number.

Variables:
  • phase (optiland.tolerancing.base.Phase) – The phase in which the deviation is applied.

  • units (str) – Units of the deviation, shown in docs and result tables.

abstractmethod apply(delta: float) → None[source]#

Apply a deviation from nominal.

Parameters:

delta – The signed deviation, in units.

abstract property label: str#

Return a short, human-readable name, e.g. "Radius S1".

phase: Phase = 0#
abstractmethod reset() → None[source]#

Restore the nominal state.

units: str = ''#