Canonical rendering of einops patterns #
These functions serialize the existing syntax trees; there is no parallel pretty-printing AST. Rendering deliberately omits source spans and the source offset used to distinguish anonymous-axis occurrences. It preserves every syntactic choice that affects checking: axis order, parentheses, unit axes, ellipses, pack boundaries, and einsum operand boundaries.
Canonical output uses ASCII decimal notation for anonymous dimensions,
retains named axes exactly (including Unicode), and follows the spacing rules
of TokenKind.renderSequence.
Convert one elementary axis to its canonical lexer token.
Instances For
Render one elementary axis without source-location metadata.
Instances For
Canonical token sequence for one top-level or parenthesized axis.
Instances For
Render one top-level axis, retaining parentheses even for empty or unary groups because grouping is part of the parsed syntax.
Instances For
Canonical lexer tokens for an expression, in axis order.
Instances For
Render one expression with exactly one space between top-level axes.
Instances For
Render a rearrange, repeat, or reduce pattern in canonical form.
Instances For
Render the unique packed segment together with its fixed surrounding axes.
Instances For
Render all einsum operands and the requested output expression.