From ab383886fce684d80af2c576e547d3bc06c9d6fd Mon Sep 17 00:00:00 2001 From: Serwan Asaad Date: Tue, 19 Nov 2024 09:53:46 +0100 Subject: [PATCH] add test for filters --- .../ports/test_lf_fem_analog_ports.py | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/tests/components/ports/test_lf_fem_analog_ports.py b/tests/components/ports/test_lf_fem_analog_ports.py index b76a07b8..6c621f8e 100644 --- a/tests/components/ports/test_lf_fem_analog_ports.py +++ b/tests/components/ports/test_lf_fem_analog_ports.py @@ -83,6 +83,52 @@ def test_lf_fem_analog_output_port(): } +def test_fem_analog_output_port_filter(): + port = LFFEMAnalogOutputPort("con1", 1, 2) + port.feedforward_filter = None + port.feedback_filter = None + + assert port.get_port_properties() == { + "delay": 0, + "shareable": False, + "output_mode": "direct", + "sampling_rate": 1e9, + "upsampling_mode": "mw", + } + + port.feedforward_filter = [0.7, 0.2, 0.1] + + assert port.get_port_properties() == { + "delay": 0, + "shareable": False, + "output_mode": "direct", + "sampling_rate": 1e9, + "upsampling_mode": "mw", + "filter": {"feedforward": [0.7, 0.2, 0.1]}, + } + + port.feedback_filter = [0.3, 0.4, 0.5] + + assert port.get_port_properties() == { + "delay": 0, + "shareable": False, + "output_mode": "direct", + "sampling_rate": 1e9, + "upsampling_mode": "mw", + "filter": {"feedforward": [0.7, 0.2, 0.1], "feedback": [0.3, 0.4, 0.5]}, + } + + port.feedforward_filter = None + assert port.get_port_properties() == { + "delay": 0, + "shareable": False, + "output_mode": "direct", + "sampling_rate": 1e9, + "upsampling_mode": "mw", + "filter": {"feedback": [0.3, 0.4, 0.5]}, + } + + def test_lf_fem_analog_input_port(): with pytest.raises(TypeError): LFFEMAnalogInputPort()