cottax.consumers.visualization.page module

The interactive page around pictures rendered in Python, one view per picture: pan, Ctrl+scroll zoom and Fit; hover (a tooltip and the row and column lit, read off a picture’s data-i, data-r, data-c, data-v); CSS toggles; frames under a slider, the steps a frame changed haloed, a picture two frames share shipped once; the key a strip outside what pans.

TIP_VARS = 12

How many names one hover lists before it says how many are left.

class HtmlDoc[source]

Bases: str

HTML as a str, which a notebook also renders inline (_repr_html_). path is the .html file it was written to, or None. The string is the inline widget; the file is the same widget in a document of its own, filling the window.

path: str | None = None
FRAME_LABEL_CHARS = 80

How much of an op’s repr a frame’s label shows; the whole of it is the tooltip.

frame_label(op)[source]

An op as a frame names it: its own repr, shortened, and the whole for a tooltip.

Return type:

tuple[str, str]

prefixes(graph)[source]

(label, tip, graph) per frame: one for a graph, one per prefix of a Plan – its base, then each op applied, labelled by that op.

Return type:

list[tuple[str, str, object]]

changed(before, after)[source]

The nodes after defines that before did not define so: what an op changed.

Return type:

set

class Pictures[source]

Bases: object

The pictures a page ships, each once however many frames show it.

svgs: list[str]
add(svg: str)[source]
Return type:

int

page(svgs: Sequence[str], frames: Sequence[dict], *, style: Style, views: Sequence[str] = ('',), toggles: Sequence[tuple[str, str, bool, str]] = (), note: str = '', write: bool = False, file_name: str = 'page', outdir: str = '.')[source]

The page. svgs are the pictures, frames what the slider steps through, each {‘label’, ‘tip’, ‘views’} – one view per name in views (the XDSM and the N2 of one graph, say, swapped by a button), each {‘svg’: index, ‘rows’, ‘changed’, ‘legend’}: legend the key, drawn in a strip the pictures pan and zoom under, each entry {‘shape’: ‘hex’ | ‘band’ | ‘open’ | ‘square’, ‘fill’, ‘stroke’, ‘text’} and an optional title, what hovering it says; rows a list per step of {‘name’, ‘group’, ‘kind’, ‘driven’, ‘reads’, ‘nr’, ‘writes’, ‘nw’} in that picture’s order, changed the step indices to halo. toggles are (key, label, on, css): a button flipping data-no<key> on the host, and the rules drawn while it is off (written against :host([data-no<key>])). note is a line at the end of the bar.

Return type:

HtmlDoc