paroto.viz.utils#
Utility functions for visualization module.
Functions#
|
Extract simplified label from dotted variable name. |
|
Extract subsystem name from dotted variable name. |
|
Convert value to string, handling arrays. |
|
Deduplicate nodes with same label, preferring primary params. |
|
Deduplicate edges using canonical node mapping. |
Module Contents#
- paroto.viz.utils.get_simple_label(full_name)#
Extract simplified label from dotted variable name.
- Parameters:
full_name (
str) – Full variable name (e.g., “vedef.breakdown.voltage”)- Returns:
Simplified label (e.g., “voltage”)
- Return type:
Examples
>>> get_simple_label("vedef.breakdown.voltage") 'voltage' >>> get_simple_label("simple_var") 'simple_var'
- paroto.viz.utils.get_subsystem_name(full_name)#
Extract subsystem name from dotted variable name.
- Parameters:
full_name (
str) – Full variable name (e.g., “vedef.breakdown.voltage”)- Returns:
Subsystem name (e.g., “vedef.breakdown”) or ‘root’ if no subsystem
- Return type:
Examples
>>> get_subsystem_name("vedef.breakdown.voltage") 'vedef.breakdown' >>> get_subsystem_name("simple_var") 'root'
- paroto.viz.utils.serialize_value(value)#
Convert value to string, handling arrays.
- Parameters:
value (
Any) – Value to serialize- Returns:
String representation of value
- Return type:
- paroto.viz.utils.deduplicate_nodes_by_label(nodes, levels, max_level=None)#
Deduplicate nodes with same label, preferring primary params.
When multiple nodes have the same simplified label (e.g., multiple “gap_distance” nodes from different subsystems), keeps only one canonical representative.
- Parameters:
- Returns:
(deduplicated_nodes, node_to_canonical, deduplicated_by_level) - deduplicated_nodes: dict of canonical nodes - node_to_canonical: mapping from any node to its canonical version - deduplicated_by_level: dict of level -> list of canonical node_ids
- Return type:
- paroto.viz.utils.deduplicate_edges(edges, node_to_canonical, displayed_nodes)#
Deduplicate edges using canonical node mapping.