cottax.consumers.visualization.xdsm module¶
A graph as an XDSM (Lambe & Martins, 2012) in SVG: the stylesheet and the painting in order.
- xdsm_css(sty: Style, levels: int = RING_LEVELS)[source]¶
sty as the XDSM’s stylesheet, colours only: BASE_CSS states the structure. The class names are render_xdsm_svg’s – .diag a model, .data a coupling, .ext a boundary box, .group a solve ring’s band (.group-l<d> its depth, .group-nested below the top), .group-ff a block run in order. A problem’s hexagon and a solve ring’s contour are coloured on the shape, not here.
- Return type:
str
- LINE_WEIGHTS = {'.data': 1.0, '.deco': 1.1, '.diag,.ext': 1.4, '.edge': 2.0, '.group': 1.7, '.group-ff': 1.3, '.io': 1.4}¶
.diag,.ext a model box and the boundary boxes, .data a coupling box, .deco a minted name’s caret, .group a solve’s ring, .group-ff a block run in order, .edge a coupling line, .io an external arrow. line_weights overrides one, line_scale multiplies all.
- Type:
Every line weight in px, by class
- RING_THICK = 4.0¶
A ring’s weight under thick_blocks=True, in px.
- stylesheet(sty: Style, *, follow_system: bool, css: str, font: str | None, font_size: float | None, size: float, vsize: float, weights: Mapping[str, float], line_scale: float, line_weights: Mapping[str, float] | None, thick_blocks: bool | float)[source]¶
The whole of one drawing’s <style>: BASE_CSS, sty’s colours, and every setting of render_xdsm_svg that is said in CSS.
- Return type:
str
- render_xdsm_svg(graph: NestingGraph | ExecutableGraph | Plan | dict, *, blocks: bool | ExecutableGraph = False, file_name: str = 'xdsm', outdir: str = '.', style: Style | str = TERRACOTTA, follow_system: bool = False, css: str = '', input_label: str | None = None, output_label: str | None = None, write: bool = False, legend: bool = True, font: str | None = None, font_size: float | None = None, names: bool = True, edges: bool = False, thick_blocks: bool | float = False, line_scale: float = 1.0, line_weights: Mapping[str, float] | None = None, box_scale: float = 1.0, var_box_scale: float = 1.0, condition_slots: bool | str = False, problem_first: bool = True, stack_inputs: bool = False, collapse_names: bool = False, inline_names: bool = False, square_names: bool = False, gap: float | None = None, gap_y: float | None = None, ring_gap: float | None = None, nest_gap: float | None = None, head_gap: float | None = None, cell: tuple[float, float] | None = None, canvas: tuple[float, float] | None = None, align: str = 'center', formatter: Formatter = PlainFormat(), measure: Measure | None = None)[source]¶
graph as a self-contained XDSM in SVG: the steps on the diagonal, a coupling’s box at (producer’s row, consumer’s column), a free input entering from the top-left box and a result leaving to the bottom-right one. Returns an SvgDoc, whose .cell is the widest step column and tallest row used and .size the drawing’s (width, height).
graph: a NestingGraph, a Plan (its graph), a proof (its graph, ringed as proved) or an xdsm_struct already built. blocks: ring every solve, and order the diagonal to run order (an ExecutableGraph: ring as that proof has it); otherwise the diagonal is binding order. file_name, outdir, write: with write=True, also write <outdir>/<file_name>.svg (.path). style: a Style or a name in STYLES. follow_system: add DARK under the viewer’s prefers-color-scheme (the default style only); a hexagon and a ring’s contour keep the light ground’s colours. css: appended to the stylesheet. input_label, output_label: the boundary boxes’ text (None: ‘Coor’, ‘Out’). legend: draw the key beneath the matrix. font: the face, a CSS family list (None: the style’s). font_size: a step label’s size in px; every other size and distance follows it. names: draw the text; off, the boxes keep the size of the names they would hold. edges: also draw the line from producer through a coupling box to its consumer, and with no boundary variable the labelled arrows in and out. thick_blocks: rings at RING_THICK px and solid, or at the number given. line_scale: multiplies every line weight. line_weights: merged over LINE_WEIGHTS before line_scale, per class. box_scale: the air around a step’s label and its row’s floor, times this. var_box_scale: the air around a coupling box’s names, times this. condition_slots: a condition node’s reads in a column per kind (min, = 0, ≤ 0, = û, ≤ u, g ≤ g_max); True for optimise and feasibility problems and every requirement (what it requires), ‘all’ for every condition node. problem_first: a problem at the head of the block it drives; off keeps the graph’s order within a block. stack_inputs: the free inputs on one row, not one row each. collapse_names: a coupling box shows a count, N vars, its names in its <title>. inline_names: a coupling box’s names on one line. square_names: a coupling box’s names in the fewest lines keeping it about square. gap: px between neighbouring boxes, both ways (CELL_GAP); gap_y: the vertical one alone. ring_gap: px from a ring to the boxes and rings beside it (gap / 2). nest_gap, head_gap: px from a ring to a ring nested in it and to its problem’s hexagon (ring_gap). cell: (w, h) in px, every step column and every row at this pitch (another drawing’s .cell), so two drawings share a grid. canvas: (w, h) in px to pad the drawing to (another’s .size), so two share a scale; a smaller canvas is ignored. align: where the drawing sits in canvas: ‘center’, ‘top-left’, ‘top’, ‘left’. formatter: how a name is written; markup (MARKUP) is measured as it is set. measure: (label, size, bold) -> (ink_left, ink_width) in px, replacing the width estimate (latex.xdsm.CairoMeasure).
- Return type: