cottax.consumers.visualization.matrix module¶
A graph as an N2 matrix (a DSM) in SVG: a row and a column per node, a mark where the row’s node produces what the column’s reads (below the diagonal is feedback). Optional on top: groups (groups: a mapping of group to nodes, or a function of a node, by_namespace; a group is a tuple and nests, each level a band), the solves boxed at every depth, and the row names.
- by_namespace(depth: int | None = None)[source]¶
The grouping a graph’s own names declare (PlaceDrawing.namespace_of: its leading names without its own, a minted one read through its namespace), depth levels deep.
- Return type:
Callable[[Label],tuple[str,...]]
- grouped_struct(struct: dict)[source]¶
struct collapsed to its groups, in the order they first appear: a row per group, a cell counting the variables flowing from one to another (the diagonal, within one).
- Return type:
dict
- matrix_struct(graph, *, order: str | Sequence[Label] = 'structure', groups: Grouping | None = None, formatter: Formatter = PlainFormat(), style: Style | str = TERRACOTTA, colours: Mapping[str, str] | None = None)[source]¶
The plain data every matrix renderer draws: rows (name, group, colour, problem type, driven, minted, depth, reads, writes), cells (row, column, the variables, the source’s colour), bands (a contiguous run of one group, per nesting level of the groups), boxes (a solve contiguous in this order: rows, depth, the type answering it), legend (each group and its count), kinds (each category drawn, its name to its Kind, in row order), nodes (the order) and summary counts. A group’s hue is fixed by the graph’s binding order, so one graph is coloured alike in every order; colours pins an outermost group’s hue by name, for several graphs drawn alike.
- Return type:
dict
- render_matrix_svg(graph, *, order: str | Sequence[Label] = 'structure', groups: Grouping | None = None, grouped: bool = False, names: bool = True, colour: bool = True, legend: bool = True, bands: bool = True, name_column: float | None = None, cell: float | None = None, font_size: float = 9.0, problem_mark: float = 0.0, colours: Mapping[str, str] | None = None, font: str | None = None, style: Style | str = TERRACOTTA, formatter: Formatter = PlainFormat(), write: bool = False, file_name: str = 'matrix', outdir: str = '.')[source]¶
The N2 matrix of graph (a NestingGraph, an ExecutableGraph or a Plan) as a self-contained SVG; .size, .names_width and .struct (matrix_struct) beside it.
order: ‘structure’ (run order at every level, each solve contiguous and boxed), ‘binding’, ‘grouped’ (structure, regrouped so each group is contiguous) or a permutation of the nodes. groups: a mapping of group to nodes, or a function of a node (by_namespace). grouped: draw the groups themselves, a cell counting the variables between two. names, colour, legend: the row names, the group colours, the key. bands: the group bars beside and over the matrix. name_column: the names’ column width in px, flush left, so several matrices line up (default: their own width, flush right). cell: a row’s pitch in px (CELL_EM * font_size). font_size, font: the type (font default: the style’s). problem_mark: the least width of a problem’s hexagon in px, drawn over its neighbours. colours: an outermost group’s hue by name, to colour several graphs alike. style, formatter: as every picture’s. write, file_name, outdir: with write=True, also write <outdir>/<file_name>.svg.
- Return type: