ml_switcheroo.core.tikz¶
TikZ Concrete Syntax Tree (CST) Data Structures.
This package provides a pure Python representation of TikZ/PGF code designed to represent neural network graphs with high fidelity. It supports: - Nodes with HTML-like label tables for layer metadata. - Edges representing data flow. - Trivia preservation (comments/whitespace) for round-trip stability.
Submodules¶
Classes¶
Abstract base class for all TikZ CST nodes. |
|
Represents non-semantic textual elements (whitespace, newlines). |
|
Represents a LaTeX comment (e.g. |
|
Represents a TikZ option like |
|
Represents an HTML-like table structure used inside TikZ Node labels. |
|
Represents a |
|
Represents a |
|
The root container representing the |
Package Contents¶
- class ml_switcheroo.core.tikz.TikzBaseNode[source]¶
Bases:
abc.ABCAbstract base class for all TikZ CST nodes.
- class ml_switcheroo.core.tikz.TriviaNode[source]¶
Bases:
TikzBaseNodeRepresents non-semantic textual elements (whitespace, newlines).
- content: str¶
The raw whitespace content.
- class ml_switcheroo.core.tikz.TikzComment[source]¶
Bases:
TikzBaseNodeRepresents a LaTeX comment (e.g.
% My Comment). Includes the percent sign in the content or adds it during export.- text: str¶
The comment text.
- trailing_newline: bool = True¶
Whether to append a newline after the comment.
- class ml_switcheroo.core.tikz.TikzOption[source]¶
Bases:
TikzBaseNodeRepresents a TikZ option like
[draw=black]or[circle].- key: str¶
Option key.
- value: str | None = None¶
Optional value for key-value pairs.
- class ml_switcheroo.core.tikz.TikzTable[source]¶
Bases:
TikzBaseNodeRepresents an HTML-like table structure used inside TikZ Node labels. Uses LaTeX tabular environment syntax.
Example:
\begin{tabular}{c} \textbf{LayerName} \\ param: val \end{tabular}
- rows: List[List[str]] = []¶
List of rows, where each row is a list of cell strings.
- align: str = 'c'¶
Column alignment (c=center, l=left, r=right).
- class ml_switcheroo.core.tikz.TikzNode[source]¶
Bases:
TikzBaseNodeRepresents a
\nodecommand.Structure:
\node [options] (id) at (x, y) {label_content};
- node_id: str¶
Unique identifier for the node (used for edges).
- x: float¶
X Coordinate.
- y: float¶
Y Coordinate.
- options: List[TikzOption] = []¶
List of TikZ options.
- leading_trivia: List[TriviaNode] = []¶
Whitespace/Comments before the node command.
- class ml_switcheroo.core.tikz.TikzEdge[source]¶
Bases:
TikzBaseNodeRepresents a
\drawcommand connecting two nodes.Structure:
\draw [options] (src) -- (tgt);
- source_id: str¶
Source node ID.
- target_id: str¶
Target node ID.
- options: List[TikzOption] = []¶
List of styling options.
- connector: str = '--'¶
Connector style (e.g.
--or->).
- leading_trivia: List[TriviaNode] = []¶
Whitespace before the draw command.
- class ml_switcheroo.core.tikz.TikzGraph[source]¶
Bases:
TikzBaseNodeThe root container representing the
tikzpictureenvironment.Structure:
\begin{tikzpicture} ... children ... \end{tikzpicture}
- children: List[TikzBaseNode] = []¶
List of nodes, edges, comments, and trivia.
- options: List[TikzOption] = []¶
Global environment options.