Skip to content
Snippets Groups Projects
Commit b496973b authored by Oscar Gustafsson's avatar Oscar Gustafsson :bicyclist:
Browse files

Rename copy_component to copy

parent bcf36af7
No related branches found
No related tags found
1 merge request!261Replaceop
Pipeline #93192 passed
......@@ -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)
......
......@@ -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):
......
......@@ -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)
]
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment