math_spec.validation
Load-time validation: the front door, and the pass that decides every expression.
to_spec(model)
#
Load and validate a model definition — the language's front door.
Everything decidable without data is decided here: schema shape, every expression and where string, every macro template, and every declaration a formulation emits.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
A YAML path, a mapping, or a loaded :class: |
| RETURNS | DESCRIPTION |
|---|---|
Spec
|
The schema as the file declares it, |
| RAISES | DESCRIPTION |
|---|---|
LanguageError
|
Anything the language does not accept. |
Source code in src/math_spec/validation.py
validate_expressions(schema)
#
Validate and resolve every expression and where string in schema.
What is checked:
- the expression parses, and constraints hold exactly one comparison where objectives hold none;
- every referenced name resolves, and every operator is a built-in whose dimension arguments name declared dimensions;
- where strings parse and resolve — an unknown name there is an error, not a silently-empty mask;
- macro formals may shadow model names but not a declared dimension, since
over=snapshotunder a formalsnapshotcannot say which it means; - every dim rule (
dimensions.check_schema), once names resolve.
| RAISES | DESCRIPTION |
|---|---|
SchemaError
|
Listing every problem found, one per line. |