math_spec.errors
The errors the language raises.
:class:LanguageError is the file saying something the language does not
accept — decidable at load time, with no data bound. :class:MathSpecError
is the root a consumer's own errors may derive from, so one except covers
the package.
DimensionError
#
Bases: LanguageError
A dim-set rule was violated. Raised at load time, before any data.
LanguageError
#
Bases: MathSpecError
The model is not sayable in the language, or does not obey its rules.
MathSpecError
#
Bases: ValueError
Base class for every error this package raises on purpose.
PiecewiseExpansionError
#
Bases: LanguageError
A piecewise block references something that doesn't exist or collides.
SchemaError
#
Bases: LanguageError
The declarations themselves are wrong, before any expression is read.
An unknown key, a bad dtype, a duplicate YAML key, a
version this reader does not know — as against a bare
:class:LanguageError, which is sound declarations saying something the
language rejects (an undeclared name, a dim rule, degree 2).
did_you_mean(name, known, *, label='Declared')
#
The repair clause for an unrecognised name: the near miss, or the set.
Only the clause is shared — an unknown declaration, an unknown YAML key and an unknown symbol-table entry each frame it with a sentence of their own.
Source code in src/math_spec/errors.py
schema_error(exc)
#
A pydantic ValidationError as one of ours, keeping the class.
Pydantic wraps whatever a validator raises, so our own class cannot reach
the caller from inside the model — but the original survives under
ctx['error'], so a :class:DimensionError comes back one. Anything
else, including several errors at once, is a :class:SchemaError.