diff --git a/b_asic/operation.py b/b_asic/operation.py index f43abd242e05b4bcb335a955a22ef2673d7836c7..a1f3b7ca1ccd2f4f022afe4e46d80521f087ea41 100644 --- a/b_asic/operation.py +++ b/b_asic/operation.py @@ -61,14 +61,14 @@ class Operation(GraphComponent, SignalSourceProvider): @property @abstractmethod - def inputs(self) -> List[InputPort]: - """Get a list of all input ports.""" + def inputs(self) -> Sequence[InputPort]: + """Get all input ports.""" raise NotImplementedError @property @abstractmethod - def outputs(self) -> List[OutputPort]: - """Get a list of all output ports.""" + def outputs(self) -> Sequence[OutputPort]: + """Get all output ports.""" raise NotImplementedError @property @@ -233,11 +233,11 @@ class AbstractOperation(Operation, AbstractGraphComponent): return Division(self, src) @property - def inputs(self) -> List[InputPort]: + def inputs(self) -> Sequence[InputPort]: return self._input_ports.copy() @property - def outputs(self) -> List[OutputPort]: + def outputs(self) -> Sequence[OutputPort]: return self._output_ports.copy() @property diff --git a/b_asic/signal_flow_graph.py b/b_asic/signal_flow_graph.py index a30ca0c3bcebe733351c4ee997881fabee7003e4..78a037e2dbc5ff9fafe8bf146755e6405be1766b 100644 --- a/b_asic/signal_flow_graph.py +++ b/b_asic/signal_flow_graph.py @@ -215,9 +215,9 @@ class SFG(AbstractOperation): """ return self._components_by_id.get(graph_id, None) - def find_by_name(self, name: Name) -> List[GraphComponent]: + def find_by_name(self, name: Name) -> Sequence[GraphComponent]: """Find all graph components with the specified name. - Returns an empty list if no components were found. + Returns an empty sequence if no components were found. Keyword arguments: name: Name of the desired component(s) diff --git a/test/test_signal_flow_graph.py b/test/test_signal_flow_graph.py index 87fc5d9937505ad31f4880a4652629c5499c6ad3..51267cc44ece60c05e622c02c89b8ec1a5d5b17d 100644 --- a/test/test_signal_flow_graph.py +++ b/test/test_signal_flow_graph.py @@ -5,13 +5,14 @@ from b_asic import SFG, Signal, Input, Output, Constant, Addition, Multiplicatio class TestConstructor: def test_direct_input_to_output_sfg_construction(self): - inp = Input("INP1") - out = Output(None, "OUT1") - out.input(0).connect(inp, "S1") + in1 = Input("IN1") + out1 = Output(None, "OUT1") + out1.input(0).connect(in1, "S1") - sfg = SFG(inputs = [inp], outputs = [out]) + sfg = SFG(inputs = [in1], outputs = [out1]) # in1 ---s1---> out1 assert len(list(sfg.components)) == 3 + assert len(list(sfg.operations)) == 2 assert sfg.input_count == 1 assert sfg.output_count == 1 @@ -19,11 +20,12 @@ class TestConstructor: add1 = Addition(None, None, "ADD1") add2 = Addition(None, None, "ADD2") - sig1 = add2.input(0).connect(add1, "S1") + s1 = add2.input(0).connect(add1, "S1") - sfg = SFG(input_signals = [sig1], output_signals = [sig1]) + sfg = SFG(input_signals = [s1], output_signals = [s1]) # in1 ---s1---> out1 assert len(list(sfg.components)) == 3 + assert len(list(sfg.operations)) == 2 assert sfg.input_count == 1 assert sfg.output_count == 1 @@ -31,6 +33,7 @@ class TestConstructor: sfg = SFG(outputs = [Output(operation_tree)]) assert len(list(sfg.components)) == 7 + assert len(list(sfg.operations)) == 4 assert sfg.input_count == 0 assert sfg.output_count == 1 @@ -38,6 +41,7 @@ class TestConstructor: sfg = SFG(output_signals = [Signal(source = operation_tree.output(0))]) assert len(list(sfg.components)) == 7 + assert len(list(sfg.operations)) == 4 assert sfg.input_count == 0 assert sfg.output_count == 1