From bcf36af77e47bc155c93fc5f73f23df110cf921c Mon Sep 17 00:00:00 2001
From: Oscar Gustafsson <oscar.gustafsson@gmail.com>
Date: Mon, 3 Apr 2023 18:23:06 +0200
Subject: [PATCH] Rename replace_component to replace_operation

---
 b_asic/signal_flow_graph.py | 11 ++++++-----
 test/test_sfg.py            | 12 ++++++------
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/b_asic/signal_flow_graph.py b/b_asic/signal_flow_graph.py
index cf2d3a99..173106f9 100644
--- a/b_asic/signal_flow_graph.py
+++ b/b_asic/signal_flow_graph.py
@@ -594,17 +594,18 @@ class SFG(AbstractOperation):
                 keys.append(comp.key(output_index, comp.graph_id))
         return keys
 
-    def replace_component(self, component: Operation, graph_id: GraphID) -> "SFG":
+    def replace_operation(self, component: Operation, graph_id: GraphID) -> "SFG":
         """
-        Find and replace all components matching either on GraphID, Type or both.
-        Then return a new deepcopy of the sfg with the replaced component.
+        Find and replace an operation based on GraphID.
+
+        Then return a new deepcopy of the SFG with the replaced operation.
 
         Parameters
         ----------
         component : Operation
-            The new component(s), e.g. Multiplication
+            The new operation(s), e.g. Multiplication
         graph_id : GraphID
-            The GraphID to match the component to replace.
+            The GraphID to match the operation to replace.
         """
 
         sfg_copy = self()  # Copy to not mess with this SFG.
diff --git a/test/test_sfg.py b/test/test_sfg.py
index 516f4377..508782e1 100644
--- a/test/test_sfg.py
+++ b/test/test_sfg.py
@@ -296,12 +296,12 @@ class TestComponents:
         }
 
 
-class TestReplaceComponents:
+class TestReplaceOperation:
     def test_replace_addition_by_id(self, operation_tree):
         sfg = SFG(outputs=[Output(operation_tree)])
         component_id = "add1"
 
-        sfg = sfg.replace_component(Multiplication(name="Multi"), graph_id=component_id)
+        sfg = sfg.replace_operation(Multiplication(name="Multi"), graph_id=component_id)
         assert component_id not in sfg._components_by_id.keys()
         assert "Multi" in sfg._components_by_name.keys()
 
@@ -309,7 +309,7 @@ class TestReplaceComponents:
         sfg = SFG(outputs=[Output(large_operation_tree)])
         component_id = "add3"
 
-        sfg = sfg.replace_component(Multiplication(name="Multi"), graph_id=component_id)
+        sfg = sfg.replace_operation(Multiplication(name="Multi"), graph_id=component_id)
         assert "Multi" in sfg._components_by_name.keys()
         assert component_id not in sfg._components_by_id.keys()
 
@@ -318,7 +318,7 @@ class TestReplaceComponents:
         component_id = "c1"
         const_ = sfg.find_by_id(component_id)
 
-        sfg = sfg.replace_component(Constant(1), graph_id=component_id)
+        sfg = sfg.replace_operation(Constant(1), graph_id=component_id)
         assert const_ is not sfg.find_by_id(component_id)
 
     def test_no_match_on_replace(self, large_operation_tree):
@@ -328,7 +328,7 @@ class TestReplaceComponents:
         with pytest.raises(
             ValueError, match="No operation matching the criteria found"
         ):
-            sfg = sfg.replace_component(
+            sfg = sfg.replace_operation(
                 Multiplication(name="Multi"), graph_id=component_id
             )
 
@@ -340,7 +340,7 @@ class TestReplaceComponents:
             TypeError,
             match="The input count may not differ between the operations",
         ):
-            sfg = sfg.replace_component(
+            sfg = sfg.replace_operation(
                 Multiplication(name="Multi"), graph_id=component_id
             )
 
-- 
GitLab