math_spec.typesetting.walk
The walk: program → typeset lines. Written once, for every format.
Everything here is a decision about the math — where a bracket changes the reading, which dimension a reduction binds, that a mask belongs on the ∀ rather than in the equation, that a translation shows at the leaf it re-indexes. None of it is about syntax, so none is duplicated per format.
AlignedComparison = ParameterComparison | ExpressionComparison | CountComparison | DimensionComparison | DimensionPosition | RelationComparison | RelationPairComparison
module-attribute
#
Walk(program, symbols, fmt, *, inline_expressions=False)
#
Walks a program, emitting :class:Lines in one format.
:meth:equations prints every section; what those sections use, the
legend reads off the program (:func:~math_spec.typesetting.legend.notice).
Source code in src/math_spec/typesetting/walk.py
format = fmt
instance-attribute
#
inline_expressions = inline_expressions
instance-attribute
#
program = program
instance-attribute
#
symbols = symbols
instance-attribute
#
defined()
#
The named expressions that print under their own symbol: every one, or only the unsubstitutable when inlining.
Inlining leaves a name standing only where substitution cannot reach
it — a cases block, and an entry the objective and constraints
never read, which is a quantity reported back rather than solved for.
Source code in src/math_spec/typesetting/walk.py
definition(name)
#
The line defining one named expression, symbol = body over its frame.
Source code in src/math_spec/typesetting/walk.py
equations()
#
Every titled section of equations.
Source code in src/math_spec/typesetting/walk.py
line(name)
#
The one line name prints as: a named expression, a constraint, an assumption, a curve, or a variable's domain.
An assumption is looked up where the document prints it from, so a condition a curve's method states is a line a reader can ask for before the curve is written out.
| RAISES | DESCRIPTION |
|---|---|
SchemaError
|
name is declared as none of the five, or as two — a constraint may share a variable's name, and one line prints one of them. |
Source code in src/math_spec/typesetting/walk.py
sides(node, ctx)
#
One comparison as its two sides, the relation symbol leading the right.
Split so that a line whose whole predicate is one comparison aligns on the relation, as a constraint does.