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 :class: |
| RETURNS | DESCRIPTION |
|---|---|
Spec
|
The schema as the file declares it, |
| RAISES | DESCRIPTION |
|---|---|
LanguageError
|
Anything the language does not accept, a text that is not a mapping of sections included. |
FileNotFoundError
|
A |
Source code in src/math_spec/validation.py
validate_expressions(schema)
#
Validate and resolve every expression and where string in schema, once for every reader.
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.
A piecewise: block's links are resolved here too, and its frame
checked, so the typesetter reads the curve a file states without expanding
it and the expansion reads the typed links.
| RETURNS | DESCRIPTION |
|---|---|
Resolved
|
Every declaration's typed tree — what the dim rules, lowering and the |
Resolved
|
typesetter read instead of resolving the text again. |
| RAISES | DESCRIPTION |
|---|---|
SchemaError
|
Listing every problem found, one per line. |
DimensionError
|
The first dim rule a declaration breaks, once every name resolves. |
Source code in src/math_spec/validation.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |