diff --git a/src/sisl/nodes/node.py b/src/sisl/nodes/node.py index 98887926bd..894eecbbfa 100644 --- a/src/sisl/nodes/node.py +++ b/src/sisl/nodes/node.py @@ -677,6 +677,10 @@ def _maybe_autoupdate(self): if not self.context["lazy"]: self.get() + def get_diagram_label(self): + """Returns the label to be used in diagrams when displaying this node.""" + return None + class DummyInputValue(Node): """A dummy node that can be used as a placeholder for input values.""" diff --git a/src/sisl/nodes/syntax_nodes.py b/src/sisl/nodes/syntax_nodes.py index 9885e2c123..b94df1f256 100644 --- a/src/sisl/nodes/syntax_nodes.py +++ b/src/sisl/nodes/syntax_nodes.py @@ -111,8 +111,26 @@ def _receive_outdated(self): def function(test, true, false): return true if test else false + def get_diagram_label(self): + """Returns the label to be used in diagrams when displaying this node.""" + return "if/else" + class CompareSyntaxNode(SyntaxNode): + _op_to_symbol = { + "eq": "==", + "ne": "!=", + "gt": ">", + "lt": "<", + "ge": ">=", + "le": "<=", + None: "compare", + } + @staticmethod def function(left, op: str, right): return getattr(operator, op)(left, right) + + def get_diagram_label(self): + """Returns the label to be used in diagrams when displaying this node.""" + return self._op_to_symbol.get(self._prev_evaluated_inputs.get("op")) diff --git a/src/sisl/nodes/workflow.py b/src/sisl/nodes/workflow.py index 67e36bf17e..c96ba1f357 100644 --- a/src/sisl/nodes/workflow.py +++ b/src/sisl/nodes/workflow.py @@ -343,8 +343,9 @@ def rgb2gray(rgb): for node in nodes: graph_node = graph.nodes[node] + node_obj = self._workflow.dryrun_nodes.get(node) + if node_help: - node_obj = self._workflow.dryrun_nodes.get(node) title = ( _get_node_inputs_str(node_obj) if node_obj is not None else "" ) @@ -359,6 +360,7 @@ def rgb2gray(rgb): "level": level, "title": title, "font": font, + "label": node_obj.get_diagram_label(), **node_props, } )