math_spec.lowering
Lower a validated model to a :class:~math_spec.program.Program.
One lowering, on the language side: it reads the typed AST and emits
declarations with names resolved and shapes fixed, and reaches no consumer. A
construct with no lowering raises :class:~math_spec.errors.LanguageError
naming its rewrite.
curve_left_as_written_message(blocks)
#
The refusal for a model lowered with its piecewise: blocks still to be written out.
Source code in src/math_spec/lowering.py
lower_program(expanded)
#
Compile a model whose curves are written out into a :class:~math_spec.program.Program.
A domain: binary variable lowers with fixed 0/1 bounds. A sos:
block lowers as itself — a program carries a set, and
:meth:~math_spec.model.Spec.expand is what states one as binaries
instead. A piecewise: block does not lower at all: it states rows, and
:meth:~math_spec.model.Spec.expand is what writes them, so a model still
carrying one is refused rather than written out on the caller's behalf.
| PARAMETER | DESCRIPTION |
|---|---|
expanded
|
A model with no
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
LanguageError
|
A construct outside the language, named with its
rewrite, or a |
Source code in src/math_spec/lowering.py
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 173 174 175 176 177 178 179 180 181 182 183 184 185 | |
to_program(spec)
#
spec as a :class:~math_spec.program.Program — the public door.
Takes whatever you have: a YAML path, the YAML itself, a mapping, a loaded
model, or a program already. Idempotent, so a caller that does not know
which it holds can call this and be sure. The model is lowered as it
arrived: nothing is written out here, so a piecewise: block still in
it is refused, naming :meth:~math_spec.model.Spec.expand.
| PARAMETER | DESCRIPTION |
|---|---|
spec
|
What to read the declarations from. |
| RETURNS | DESCRIPTION |
|---|---|
Program
|
Every declaration the file makes, with names resolved and shapes |
Program
|
fixed. |
| RAISES | DESCRIPTION |
|---|---|
SchemaError
|
The file is not a valid model. |
LanguageError
|
A construct outside the language, named with its
rewrite, or a |