reno.diagrams.ModelDiagram#
- class reno.diagrams.ModelDiagram(model, _model_map=None, _level=0, _parent=None)#
Bases:
objectA graph representation of a model, where nodes are the components and the edges represent the connections between them based on their equations.
Methods
__init__(model[, _model_map, _level, _parent])Create a new diagram for the specified model.
Return _all_ edges in the entire diagram.
Get a list of every node in this diagrams _greater_ context.
configure(config)Apply a passed configuration to all nodes/edges.
get_ref_node(ref)Get the DiagramNode associated with a reference.
Recurse upwards through parent models until we hit the "top" model.
to_graphviz([config])Generate the graphviz Digraph and return it.
Attributes
- Parameters:
model (reno.Model)
_model_map (dict[reno.Model, ModelDiagram])
_level (int)
_parent (ModelDiagram)
- __annotations__ = {'subgraph_colors': 'ClassVar[list[str]]'}#
- __dict__ = mappingproxy({'__module__': 'reno.diagrams', '__annotations__': {'subgraph_colors': 'ClassVar[list[str]]', 'submodels': 'list[ModelDiagram]', 'parent': 'ModelDiagram', 'digraph': 'Digraph', 'nodes': 'list[DiagramNode]', 'spark_traces': 'list[xr.Dataset]'}, '__doc__': 'A graph representation of a model, where nodes are the components and the edges\n represent the connections between them based on their equations.\n ', 'subgraph_colors': [{'light': '#BBDDFF', 'dark': '#334455'}, {'light': '#DDBBFF', 'dark': '#443355'}], '__init__': <function ModelDiagram.__init__>, '_build_nodes': <function ModelDiagram._build_nodes>, '_build_edges': <function ModelDiagram._build_edges>, '_fix_implicit_inflow_nodes': <function ModelDiagram._fix_implicit_inflow_nodes>, 'get_topmost_diagram': <function ModelDiagram.get_topmost_diagram>, 'all_nodes': <function ModelDiagram.all_nodes>, '_all_nodes': <function ModelDiagram._all_nodes>, 'all_edges': <function ModelDiagram.all_edges>, '_all_edges': <function ModelDiagram._all_edges>, 'configure': <function ModelDiagram.configure>, '_get_model_traces': <function ModelDiagram._get_model_traces>, '_reset_edge_render_state': <function ModelDiagram._reset_edge_render_state>, '_make_graph': <function ModelDiagram._make_graph>, 'to_graphviz': <function ModelDiagram.to_graphviz>, '_repr_png_': <function ModelDiagram._repr_png_>, 'get_ref_node': <function ModelDiagram.get_ref_node>, '__dict__': <attribute '__dict__' of 'ModelDiagram' objects>, '__weakref__': <attribute '__weakref__' of 'ModelDiagram' objects>})#
- __module__ = 'reno.diagrams'#
- __weakref__#
list of weak references to the object
- all_edges()#
Return _all_ edges in the entire diagram.
This requires navigating to the “top” parent model and recursively working down from there.
- Return type:
list[DiagramEdge]
- all_nodes()#
Get a list of every node in this diagrams _greater_ context.
Note that this returns all nodes from every diagram/sub-diagram involved, not just this one.
- Return type:
list[DiagramNode]
- configure(config)#
Apply a passed configuration to all nodes/edges.
- Parameters:
config (RenderConfig)
- Return type:
None
- get_ref_node(ref)#
Get the DiagramNode associated with a reference.
This is challenging because references don’t have any direct connection to nodes. This gets used for correctly constructing an edge, which requires a node on each side when you may only have a reference from seek_refs.
- Parameters:
ref (reno.Reference)
- Return type:
- get_topmost_diagram()#
Recurse upwards through parent models until we hit the “top” model.
- Return type:
- subgraph_colors: ClassVar[list[str]] = [{'dark': '#334455', 'light': '#BBDDFF'}, {'dark': '#443355', 'light': '#DDBBFF'}]#
- to_graphviz(config=None)#
Generate the graphviz Digraph and return it.
Output is also stored on
self.digraph.- Parameters:
config (RenderConfig)
- Return type:
Digraph