math_spec.typesetting.walk
The walk: resolved AST → 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.
PRIME = "'"
module-attribute
#
Walk(schema, namespace, symbols, fmt)
#
Walks a validated schema, emitting :class:Lines in one format.
Stateful only in what it has noticed — which edge policies appeared, whether a translation was counted inside a group, which positional forms printed, and which dimensions were compared against a coordinate that is a number; every one of them something the legend has to explain once the equations print it.
Source code in src/math_spec/typesetting/walk.py
format = fmt
instance-attribute
#
grouped = False
instance-attribute
#
namespace = namespace
instance-attribute
#
numeric_coordinates = set()
instance-attribute
#
policies = set()
instance-attribute
#
positions = set()
instance-attribute
#
schema = schema
instance-attribute
#
symbols = symbols
instance-attribute
#
arithmetic(node, ctx, *, need=0)
#
conjoined(ctx, *masks)
#
The mask on a quantifier, as one condition.
A mask every row passes arrives as None — resolution folds it,
so this prints what a program carries — and a quantifier with no
condition prints none.
Source code in src/math_spec/typesetting/walk.py
constraints()
#
Source code in src/math_spec/typesetting/walk.py
context(frame=())
#
convention_notes()
#
What the two faces mean, with the model's own symbols.
Only where the model has both, and quoting only derived symbols: a table is the author's to write, so a symbol it supplies is not one this note governs.
Source code in src/math_spec/typesetting/walk.py
definitions()
#
One line per cased expression, in declaration order, defining it.
Inlining the block where its name stood is what the AST does and the wrong thing to print: three arms are three rows tall, so whatever follows sits beside the middle one. So a use prints the symbol and the block prints here, as a paper states a quantity defined by region.
Every declared one prints, used or not — the rule a variable's domain follows, and what keeps this section independent of the others having run.
Source code in src/math_spec/typesetting/walk.py
glossaries()
#
Source code in src/math_spec/typesetting/walk.py
literal(value)
#
lookup(name, index)
#
membership(dim, index=None)
#
number(value)
#
Source code in src/math_spec/typesetting/walk.py
objective()
#
The objective's line.
The expression is scalar — every reduction in it is one the file wrote — so it renders like any other, and the line carries no label: the block has no name, and the section heading already says what it is.
Source code in src/math_spec/typesetting/walk.py
op(name)
#
ordinal(dimension, at, grouping)
#
The position compared against; a negative one counts back from the size of the set it is a position in — the group's where grouped.
Source code in src/math_spec/typesetting/walk.py
position(index, grouping)
#
position(dim) applied to the row, grouping as a subscript — as an argument it read as a second position.
Source code in src/math_spec/typesetting/walk.py
position_notes()
#
A sentence for each positional symbol the model actually printed.
The first is what the page cannot go without: a reader arrives from
papers where the index is the ordinal, so a page printing both
pos(t) = 0 and t >= 3 has to say once which is the position.
Source code in src/math_spec/typesetting/walk.py
quantifier(dims, condition)
#
Source code in src/math_spec/typesetting/walk.py
reduction_body(node, ctx)
#
What sits to the right of a sum, bracketed only where it must be.
A sum binds everything up to the next + or - at its own level,
so an additive body needs the bracket and nothing else does — including
a nested reduction, which is unambiguous. The precedence rule would
bracket that too, and a renderer that brackets everything is one nobody
trusts to bracket the thing that matters.
Source code in src/math_spec/typesetting/walk.py
translation(step)
#
The operator for one translation, its fill below and its group above.
Two subscripts is a TeX error rather than a rendering (#1165), and
comma-joined in one, 0,season_of(t) said nothing about which was
the fill and which the group. A named offset is always backward, since
offset=-p is refused at load.
Source code in src/math_spec/typesetting/walk.py
translation_notes()
#
A sentence for each translation symbol the model actually printed.
Only those: a legend explaining a symbol that is nowhere on the page is
a dead end, and plain t-k needs no note until something else stands
beside it.
Source code in src/math_spec/typesetting/walk.py
variables()
#
One line per variable, and one more for a set the variable carries.
A sos: block restricts the domain — which members of a family may
be nonzero at once — so it prints under this heading, beside the
variable it is a property of, rather than among the constraints, where
it would read as a row a solver holds.