From 2b90137b81c177ead05bc405020c77b5ee63a364 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson <oscar.gustafsson@gmail.com> Date: Tue, 4 Apr 2023 17:28:47 +0200 Subject: [PATCH] Add test adding the output of two SFGs --- test/test_sfg.py | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/test/test_sfg.py b/test/test_sfg.py index 508782e1..cdb7d16c 100644 --- a/test/test_sfg.py +++ b/test/test_sfg.py @@ -11,15 +11,10 @@ import pytest from b_asic import SFG, Input, Output, Signal from b_asic.core_operations import ( - Absolute, Addition, Butterfly, - ComplexConjugate, Constant, ConstantMultiplication, - Division, - Max, - Min, Multiplication, SquareRoot, Subtraction, @@ -945,6 +940,31 @@ class TestConnectExternalSignalsToComponentsMultipleComp: assert test_sfg.evaluate(1, 2, 3, 4) == 16 assert not test_sfg.connect_external_signals_to_components() + def test_add_two_sfgs(self): + c1 = ConstantMultiplication(0.5) + c1_sfg = c1.to_sfg() + + c2 = ConstantMultiplication(0.5) + c2_sfg = c2.to_sfg() + + in1 = Input() + in2 = Input() + + output = Output(c1_sfg + c2_sfg) + c1_sfg << in1 + c2_sfg << in2 + + sfg = SFG([in1, in2], [output]) + assert not sfg.find_by_type_name(ConstantMultiplication.type_name()) + + c1_sfg.connect_external_signals_to_components() + sfg = SFG([in1, in2], [output]) + assert len(sfg.find_by_type_name(ConstantMultiplication.type_name())) == 1 + + c2_sfg.connect_external_signals_to_components() + sfg = SFG([in1, in2], [output]) + assert len(sfg.find_by_type_name(ConstantMultiplication.type_name())) == 2 + class TestTopologicalOrderOperations: def test_feedback_sfg(self, sfg_simple_filter): -- GitLab