gds_viz¶
Public API — all visualization functions.
Visualization utilities for GDS specifications.
spec_to_mermaid(spec, *, group_by=None, show_entities=True, show_wires=True, theme=None)
¶
Generate a Mermaid flowchart from a GDSSpec.
Renders an architecture-level view with blocks grouped by role or tag, entity cylinders, and dependency wires.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
GDSSpec
|
The GDS specification to visualize. |
required |
group_by
|
str | None
|
Tag key to group blocks by. None groups by GDS role. |
None
|
show_entities
|
bool
|
If True, render entity cylinders with state variables. |
True
|
show_wires
|
bool
|
If True, render dependency edges from wirings. |
True
|
theme
|
MermaidTheme | None
|
Mermaid theme — one of 'default', 'neutral', 'dark', 'forest', 'base'. None uses the default ('neutral'). |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Mermaid flowchart diagram as a string. |
Source code in packages/gds-viz/gds_viz/architecture.py
canonical_to_mermaid(canonical, *, show_updates=True, show_parameters=True, theme=None)
¶
Generate a Mermaid flowchart from a CanonicalGDS projection.
Renders the formal GDS decomposition: X_t -> U -> g -> f -> X_{t+1} with optional parameter space (Theta) and update map labels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
canonical
|
CanonicalGDS
|
The canonical GDS projection to visualize. |
required |
show_updates
|
bool
|
If True, label mechanism->X edges with entity.variable. |
True
|
show_parameters
|
bool
|
If True, show the Theta node when parameters exist. |
True
|
theme
|
MermaidTheme | None
|
Mermaid theme — one of 'default', 'neutral', 'dark', 'forest', 'base'. None uses the default ('neutral'). |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Mermaid flowchart diagram as a string. |
Source code in packages/gds-viz/gds_viz/canonical.py
block_to_mermaid(block, *, theme=None)
¶
Generate a Mermaid flowchart from a Block composition tree.
This is a convenience wrapper that flattens the block and creates a minimal diagram showing the composition structure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
block
|
Block
|
The root block (atomic or composite). |
required |
theme
|
MermaidTheme | None
|
Mermaid theme — one of 'default', 'neutral', 'dark', 'forest', 'base'. None uses the default ('neutral'). |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Mermaid flowchart diagram as a string. |
Example
from gds.blocks.roles import BoundaryAction, Policy, Mechanism
from gds.types.interface import Interface, port
from gds_viz import block_to_mermaid
observe = BoundaryAction(
name="Observe",
interface=Interface(forward_out=(port("Signal"),))
)
decide = Policy(
name="Decide",
interface=Interface(
forward_in=(port("Signal"),),
forward_out=(port("Action"),)
)
)
update = Mechanism(
name="Update",
interface=Interface(forward_in=(port("Action"),)),
updates=[("Entity", "state")]
)
pipeline = observe >> decide >> update
print(block_to_mermaid(pipeline))
Source code in packages/gds-viz/gds_viz/mermaid.py
system_to_mermaid(system, show_hierarchy=False, *, theme=None)
¶
Generate a Mermaid flowchart from a SystemIR.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system
|
SystemIR
|
The compiled system to visualize. |
required |
show_hierarchy
|
bool
|
If True, uses the hierarchy tree to organize subgraphs. If False, renders a flat graph of all blocks. |
False
|
theme
|
MermaidTheme | None
|
Mermaid theme — one of 'default', 'neutral', 'dark', 'forest', 'base'. None uses the default ('neutral'). |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Mermaid flowchart diagram as a string. |
Example
Source code in packages/gds-viz/gds_viz/mermaid.py
params_to_mermaid(spec, *, theme=None)
¶
Generate a parameter influence diagram from a GDSSpec.
Shows Θ parameters → blocks that use them → entities they update. Only includes blocks that reference at least one parameter, and entities reachable from those blocks via the update map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
GDSSpec
|
The GDS specification. |
required |
theme
|
MermaidTheme | None
|
Mermaid theme — one of 'default', 'neutral', 'dark', 'forest', 'base'. None uses the default ('neutral'). |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Mermaid flowchart diagram as a string. |
Source code in packages/gds-viz/gds_viz/traceability.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
trace_to_mermaid(spec, entity, variable, *, theme=None)
¶
Generate a traceability diagram for a single entity variable.
Shows every block that can transitively affect the variable, the parameters feeding those blocks, and the causal chain.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
GDSSpec
|
The GDS specification. |
required |
entity
|
str
|
Entity name (e.g. "Susceptible"). |
required |
variable
|
str
|
Variable name (e.g. "count"). |
required |
theme
|
MermaidTheme | None
|
Mermaid theme — one of 'default', 'neutral', 'dark', 'forest', 'base'. None uses the default ('neutral'). |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Mermaid flowchart diagram as a string. |
Source code in packages/gds-viz/gds_viz/traceability.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |