cottax.consumers.visualization.xdsm_layout module

The XDSM’s layout: where each step, coupling and ring of a struct stands, in cells and in px.

SEP = ', '

What separates two variable names sharing one line of a data box.

VAR_FONT_SIZE = 12.0

The size a variable name, an i/o label and the key are set at, at the base font size.

class Setting(size: float, vsize: float, ssize: float, k: float, bold: bool, measure: Measure | None)[source]

Bases: NamedTuple

How the text is set: the sizes, the scale k every distance is a multiple of, and how a label is measured.

size: float

Alias for field number 0

vsize: float

Alias for field number 1

ssize: float

Alias for field number 2

k: float

Alias for field number 3

bold: bool

Alias for field number 4

measure: Measure | None

Alias for field number 5

property chip_h: float
property line_h: float
spanl(s: str)[source]
Return type:

tuple[float, float]

twl(s: str)[source]
Return type:

float

twv(s: str)[source]
Return type:

float

twd(s: str)[source]
Return type:

float

setting(font_size: float | None, bold: bool, measure: Measure | None)[source]

The text set at font_size, bold where a name is, measured by measure.

Return type:

Setting

class Grid(steps: list[str], idx: dict[str, int], slots: list[list], span: list[int], head_col: list[int], n_in: int, n_ext_col: int, n_out: int, out_col: int, out_row: int, nrows: int, ncols: int, nodes: dict[tuple[int, int], list[str]])[source]

Bases: NamedTuple

Where each step and each coupling box stands, in rows and columns.

steps: list[str]

Alias for field number 0

idx: dict[str, int]

Alias for field number 1

slots: list[list]

Alias for field number 2

span: list[int]

Alias for field number 3

head_col: list[int]

Alias for field number 4

n_in: int

Alias for field number 5

n_ext_col: int

Alias for field number 6

n_out: int

Alias for field number 7

out_col: int

Alias for field number 8

out_row: int

Alias for field number 9

nrows: int

Alias for field number 10

ncols: int

Alias for field number 11

nodes: dict[tuple[int, int], list[str]]

Alias for field number 12

property n: int
row_of(s: str)[source]
Return type:

int

col_of(s: str)[source]
Return type:

int

diag_col(r: int)[source]

The column of the box that sources row r: a step’s own, or the Coor block.

Return type:

int

diag_row(c: int)[source]

The row of the box column c feeds into: a step’s, or for the results column the results box at its foot.

Return type:

int | None

grid(struct: dict, *, condition_slots: bool | str, stack_inputs: bool, collapse_names: bool)[source]

Every step’s columns and row, and the coupling boxes between them.

Return type:

Grid

line_width(line: Sequence[Shown], t: Setting)[source]

What one drawn line measures: the base names, plus the separators.

Return type:

float

class Layout(grid: Grid, setting: Setting, gap: float, gap_y: float, box_floor: float, labels: dict[int, str], lines: dict[tuple[int, int], list[list[Shown]]], box_size: dict[tuple[int, int], tuple[float, float]], inputs_label: str, outputs_label: str, col_w: list[float], row_h: list[float], col_x: list[float], row_y: list[float], ring_at: dict[tuple[str, int, str, int], float], ext_w: float, out_w: float, in_target: int | None, out_arrow: int | None, m_top: float, m_left: float, m_bottom: float, key_h: float, key_w: float, key_g: float, width: float, height: float)[source]

Bases: NamedTuple

Where everything stands, in px: every column’s and row’s size and start, every ring’s edges, the two boundary boxes, the margins, the key’s strip and the canvas.

grid: Grid

Alias for field number 0

setting: Setting

Alias for field number 1

gap: float

Alias for field number 2

gap_y: float

Alias for field number 3

box_floor: float

Alias for field number 4

labels: dict[int, str]

Alias for field number 5

lines: dict[tuple[int, int], list[list[Shown]]]

Alias for field number 6

box_size: dict[tuple[int, int], tuple[float, float]]

Alias for field number 7

inputs_label: str

Alias for field number 8

outputs_label: str

Alias for field number 9

col_w: list[float]

Alias for field number 10

row_h: list[float]

Alias for field number 11

col_x: list[float]

Alias for field number 12

row_y: list[float]

Alias for field number 13

ring_at: dict[tuple[str, int, str, int], float]

Alias for field number 14

ext_w: float

Alias for field number 15

out_w: float

Alias for field number 16

in_target: int | None

Alias for field number 17

out_arrow: int | None

Alias for field number 18

m_top: float

Alias for field number 19

m_left: float

Alias for field number 20

m_bottom: float

Alias for field number 21

key_h: float

Alias for field number 22

key_w: float

Alias for field number 23

key_g: float

Alias for field number 24

width: float

Alias for field number 25

height: float

Alias for field number 26

cx(c: int)[source]
Return type:

float

cy(r: int)[source]
Return type:

float

bw_of(c: int)[source]

The box in column c: its column, less the gap to the next one.

Return type:

float

bh_of(r: int)[source]

… and the same down the rows, less the vertical gap.

Return type:

float

layout(struct: dict, sty: Style, keys: list[dict], *, formatter: Formatter, font_size: float | None, measure: Measure | None, condition_slots: bool | str, stack_inputs: bool, collapse_names: bool, inline_names: bool, square_names: bool, input_label: str | None, output_label: str | None, edges: bool, box_scale: float, var_box_scale: float, gap: float | None, gap_y: float | None, ring_gap: float | None, nest_gap: float | None, head_gap: float | None, cell: tuple[float, float] | None)[source]

struct laid out, under every argument of render_xdsm_svg that moves anything.

Return type:

Layout