Source code for pybnf.transcription.errors
"""Constrained-transcription exceptions (#563).
A single dependency-free home for the layer's exception, mirroring
:mod:`pybnf.gradient.errors`: the layout, the equality interface, and the outer loop
all raise it, and a consumer catches it without importing any of them.
"""
from ..printing import PybnfError
[docs]
class StageSkipped(Exception):
"""A homotopy stage that cannot be built faithfully at the point it is seeded from.
Not an error of the run: :func:`~pybnf.transcription.homotopy.run_homotopy` records the
stage as skipped, with :attr:`reason`, and goes on to the next one from the same point. A
stage that cannot transcribe the fit at one parameter point (a multiple-shooting knot that
cannot hold a state the trajectory reaches there) is a property of that point, and the
last stage of a ladder is the ordinary problem, which needs no such transcription.
"""
def __init__(self, stage, reason):
super().__init__('%s: %s' % (stage, reason))
self.stage = str(stage)
self.reason = str(reason)
[docs]
class TranscriptionError(PybnfError):
"""A constrained transcription could not be built, stepped, or reconciled.
Raised for the *structural* faults of the layer -- a variable block whose name
collides with a reported free parameter, a Jacobian block outside its declared
shape, a non-positive constraint scale, a penalty schedule that cannot start.
These are consumer wiring errors, not bad points to be stepped over: an
augmented layout that does not describe what the residual assembly is about to
write into is silently wrong in a way no fit result would reveal.
It is a :class:`~pybnf.printing.PybnfError` so the message reaches the user
intact when a fit is driven from a configuration rather than from a test.
"""