math_spec.dimensions
Static dim-set checking — a type system whose type is a set of dim names.
Parameter dims are declared, variable foreach is declared, and operator
dimension arguments are name-checked, so every node's dim set is computable
before any data is bound. That is the whole basis of this pass: it runs at
load time, on the resolved core AST, so every consumer gets the same answer by
construction. The per-node rules are the "Dim algebra" table in
docs/reference/language/expressions.md; at the declaration level::
constraint -> the dims of both sides together must *equal* foreach
where -> the predicate's dims must not exceed the frame
bounds -> the bound parameter's dims must not exceed foreach
The direction that matters most is the stray dim: one the frame does not declare broadcasts silently at build time, so the same YAML quietly builds a bigger model than it reads as. The missing direction is checked too, a foreach dim the equation never uses just repeating one row across it — nearly always a typo.
check_schema(schema)
#
Check every declaration's dim rules.
| RAISES | DESCRIPTION |
|---|---|
DimensionError
|
On the first declaration that breaks one. |
Source code in src/math_spec/dimensions.py
dims_of(node, schema, context)
#
The dim set of a resolved expression, checking every rule on the way.
| RAISES | DESCRIPTION |
|---|---|
DimensionError
|
On the first rule broken. |