diff --git a/b_asic/graph_component.py b/b_asic/graph_component.py index 46d26a80e94c21f56766ca2cdd4070a979844dd2..a91b84f95c1b8bbae4717789d2447ec073cf8266 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 4af199a4a472d2ff4e2172e9b550845f19e792da..acbd7bd0245e056bb19d6110b7def77235105052 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 173106f90168ef26f93767b1611326405e015460..035555d9196176358a21c40062ca0256b4533e3f 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 b08e39071c6c8aa1745daa5d30aa54924d07a53e..41cc64a34ec706077606d1c49d0ee6c686c36a5a 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