From b496973b03669cc5c8479c99a538543daecf370f Mon Sep 17 00:00:00 2001
From: Oscar Gustafsson <oscar.gustafsson@gmail.com>
Date: Mon, 3 Apr 2023 18:27:00 +0200
Subject: [PATCH] Rename copy_component to copy

---
 b_asic/graph_component.py   | 4 ++--
 b_asic/operation.py         | 8 +++-----
 b_asic/signal_flow_graph.py | 8 ++++----
 test/test_operation.py      | 4 ++--
 4 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/b_asic/graph_component.py b/b_asic/graph_component.py
index 46d26a80..a91b84f9 100644
--- a/b_asic/graph_component.py
+++ b/b_asic/graph_component.py
@@ -83,7 +83,7 @@ class GraphComponent(ABC):
         raise NotImplementedError
 
     @abstractmethod
-    def copy_component(self, *args, **kwargs) -> "GraphComponent":
+    def copy(self, *args, **kwargs) -> "GraphComponent":
         """
         Get a new instance of this graph component type with the same name, id and
         parameters.
@@ -160,7 +160,7 @@ class AbstractGraphComponent(GraphComponent):
     def set_param(self, name: str, value: Any) -> None:
         self._parameters[name] = value
 
-    def copy_component(self, *args, **kwargs) -> GraphComponent:
+    def copy(self, *args, **kwargs) -> GraphComponent:
         new_component = self.__class__(*args, **kwargs)
         new_component.name = copy(self.name)
         new_component.graph_id = copy(self.graph_id)
diff --git a/b_asic/operation.py b/b_asic/operation.py
index 4af199a4..acbd7bd0 100644
--- a/b_asic/operation.py
+++ b/b_asic/operation.py
@@ -853,7 +853,7 @@ class AbstractOperation(Operation, AbstractGraphComponent):
                 last_operations = [last_operations]
             outputs = [Output(o) for o in last_operations]
         except TypeError:
-            operation_copy: Operation = cast(Operation, self.copy_component())
+            operation_copy: Operation = cast(Operation, self.copy())
             inputs = []
             for i in range(self.input_count):
                 input_ = Input()
@@ -864,10 +864,8 @@ class AbstractOperation(Operation, AbstractGraphComponent):
 
         return SFG(inputs=inputs, outputs=outputs)
 
-    def copy_component(self, *args, **kwargs) -> GraphComponent:
-        new_component: Operation = cast(
-            Operation, super().copy_component(*args, **kwargs)
-        )
+    def copy(self, *args, **kwargs) -> GraphComponent:
+        new_component: Operation = cast(Operation, super().copy(*args, **kwargs))
         for i, _input in enumerate(self.inputs):
             new_component.input(i).latency_offset = _input.latency_offset
         for i, output in enumerate(self.outputs):
diff --git a/b_asic/signal_flow_graph.py b/b_asic/signal_flow_graph.py
index 173106f9..035555d9 100644
--- a/b_asic/signal_flow_graph.py
+++ b/b_asic/signal_flow_graph.py
@@ -505,8 +505,8 @@ class SFG(AbstractOperation):
 
         return input_indexes_required
 
-    def copy_component(self, *args, **kwargs) -> GraphComponent:
-        return super().copy_component(
+    def copy(self, *args, **kwargs) -> GraphComponent:
+        return super().copy(
             *args,
             **kwargs,
             inputs=self._input_operations,
@@ -1030,7 +1030,7 @@ class SFG(AbstractOperation):
     ) -> GraphComponent:
         if original_component in self._original_components_to_new:
             raise ValueError("Tried to add duplicate SFG component")
-        new_component = original_component.copy_component()
+        new_component = original_component.copy()
         self._original_components_to_new[original_component] = new_component
         if not new_component.graph_id or new_component.graph_id in self._used_ids:
             new_id = self._graph_id_generator.next_id(
@@ -1397,7 +1397,7 @@ class SFG(AbstractOperation):
 
         # Make `factor` copies of the sfg
         new_ops = [
-            [cast(Operation, op.copy_component()) for op in self.operations]
+            [cast(Operation, op.copy()) for op in self.operations]
             for _ in range(factor)
         ]
 
diff --git a/test/test_operation.py b/test/test_operation.py
index b08e3907..41cc64a3 100644
--- a/test/test_operation.py
+++ b/test/test_operation.py
@@ -229,7 +229,7 @@ class TestCopyOperation:
     def test_copy_butterfly_latency_offsets(self):
         bfly = Butterfly(latency_offsets={"in0": 4, "in1": 2, "out0": 10, "out1": 9})
 
-        bfly_copy = bfly.copy_component()
+        bfly_copy = bfly.copy()
 
         assert bfly_copy.latency_offsets == {
             "in0": 4,
@@ -242,7 +242,7 @@ class TestCopyOperation:
         add = Addition()
         add.execution_time = 2
 
-        add_copy = add.copy_component()
+        add_copy = add.copy()
 
         assert add_copy.execution_time == 2
 
-- 
GitLab