From 69b3ccc16207e3b8302c8a7b70016dd5a27910e1 Mon Sep 17 00:00:00 2001 From: liamhuber Date: Mon, 15 May 2023 15:03:49 -0700 Subject: [PATCH] Deprecate the (semi)old flow control nodes --- ironflow/nodes/deprecated/flow_control.py | 73 +++++++++++++++++++++++ ironflow/nodes/standard.py | 68 --------------------- 2 files changed, 73 insertions(+), 68 deletions(-) create mode 100644 ironflow/nodes/deprecated/flow_control.py diff --git a/ironflow/nodes/deprecated/flow_control.py b/ironflow/nodes/deprecated/flow_control.py new file mode 100644 index 00000000..27acbf54 --- /dev/null +++ b/ironflow/nodes/deprecated/flow_control.py @@ -0,0 +1,73 @@ +from __future__ import annotations + +from ironflow.model import dtypes +from ironflow.model.node import Node +from ironflow.model.port import NodeInputBP, NodeOutputBP +from ironflow.node_tools import main_widgets +from ironflow.nodes.deprecated.special_nodes import DualNodeBase + + +class ForEach_Node(Node): + title = "ForEach" + version = "v0.1" + init_inputs = [ + NodeInputBP(type_="exec", label="start"), + NodeInputBP(type_="exec", label="reset"), + NodeInputBP(dtype=dtypes.List(), label="elements"), + ] + init_outputs = [ + NodeOutputBP(label="loop", type_="exec"), + NodeOutputBP(label="e", type_="data"), + NodeOutputBP(label="finished", type_="exec"), + ] + color = "#b33a27" + + _count = 0 + + def update_event(self, inp=-1): + if inp == 0: + self._count += 1 + if len(self.inputs.values.elements) > self._count: + e = self.inputs.values.elements[self._count] + self.set_output_val(1, e) + self.exec_output(0) + else: + self.exec_output(2) + elif inp > 0: + self._count = 0 + self.val = self._count + + +class ExecCounter_Node(DualNodeBase): + title = "ExecCounter" + version = "v0.1" + init_inputs = [ + NodeInputBP(type_="exec"), + ] + init_outputs = [ + NodeOutputBP(type_="exec"), + ] + color = "#5d95de" + + def __init__(self, params): + super().__init__(params, active=True) + self._count = 0 + + def update_event(self, inp=-1): + if self.active and inp == 0: + self._count += 1 + self.val = self._count + elif not self.active: + self.val = self.input(0) + + +class Click_Node(Node): + title = "Click" + version = "v0.1" + main_widget_class = main_widgets.ButtonNodeWidget + init_inputs = [] + init_outputs = [NodeOutputBP(type_="exec")] + color = "#99dd55" + + def update_event(self, inp=-1): + self.exec_output(0) diff --git a/ironflow/nodes/standard.py b/ironflow/nodes/standard.py index c70ae316..1d185f23 100644 --- a/ironflow/nodes/standard.py +++ b/ironflow/nodes/standard.py @@ -13,8 +13,6 @@ from ironflow.model import dtypes from ironflow.model.node import DataNode, Node from ironflow.model.port import NodeInputBP, NodeOutputBP -from ironflow.node_tools import main_widgets -from ironflow.nodes.deprecated.special_nodes import DualNodeBase from pyiron_atomistics import Atoms @@ -384,72 +382,6 @@ def node_function(self, x, **kwargs) -> dict: return {"sin": np.sin(x)} -class ForEach_Node(Node): - title = "ForEach" - version = "v0.1" - init_inputs = [ - NodeInputBP(type_="exec", label="start"), - NodeInputBP(type_="exec", label="reset"), - NodeInputBP(dtype=dtypes.List(), label="elements"), - ] - init_outputs = [ - NodeOutputBP(label="loop", type_="exec"), - NodeOutputBP(label="e", type_="data"), - NodeOutputBP(label="finished", type_="exec"), - ] - color = "#b33a27" - - _count = 0 - - def update_event(self, inp=-1): - if inp == 0: - self._count += 1 - if len(self.inputs.values.elements) > self._count: - e = self.inputs.values.elements[self._count] - self.set_output_val(1, e) - self.exec_output(0) - else: - self.exec_output(2) - elif inp > 0: - self._count = 0 - self.val = self._count - - -class ExecCounter_Node(DualNodeBase): - title = "ExecCounter" - version = "v0.1" - init_inputs = [ - NodeInputBP(type_="exec"), - ] - init_outputs = [ - NodeOutputBP(type_="exec"), - ] - color = "#5d95de" - - def __init__(self, params): - super().__init__(params, active=True) - self._count = 0 - - def update_event(self, inp=-1): - if self.active and inp == 0: - self._count += 1 - self.val = self._count - elif not self.active: - self.val = self.input(0) - - -class Click_Node(Node): - title = "Click" - version = "v0.1" - main_widget_class = main_widgets.ButtonNodeWidget - init_inputs = [] - init_outputs = [NodeOutputBP(type_="exec")] - color = "#99dd55" - - def update_event(self, inp=-1): - self.exec_output(0) - - class Input_Node(DataNode): """ Give data as a string and cast it to a specific type.