|
| 1 | +# Copyright (c) DataLab Platform Developers, BSD 3-Clause license, see LICENSE file. |
| 2 | + |
| 3 | +""" |
| 4 | +Frequential filtering application test. |
| 5 | +""" |
| 6 | + |
| 7 | +# pylint: disable=invalid-name # Allows short reference names like x, y, ... |
| 8 | +# guitest: show |
| 9 | + |
| 10 | +import sigima.params |
| 11 | +from sigima.objects import create_signal_from_param |
| 12 | +from sigima.tests.helpers import check_array_result |
| 13 | +from sigima.tests.signal.pulse.pulse_unit_test import create_test_square_params |
| 14 | + |
| 15 | +from datalab.tests import datalab_test_app_context |
| 16 | + |
| 17 | + |
| 18 | +def test_signal_freq_filter_app(): |
| 19 | + """Signal frequency filtering application test.""" |
| 20 | + with datalab_test_app_context(console=False) as win: |
| 21 | + panel = win.signalpanel |
| 22 | + s1 = create_signal_from_param(create_test_square_params()) |
| 23 | + panel.add_object(s1) |
| 24 | + for feature, paramclass in ( |
| 25 | + ("lowpass", sigima.params.LowPassFilterParam), |
| 26 | + ("highpass", sigima.params.HighPassFilterParam), |
| 27 | + ("bandstop", sigima.params.BandStopFilterParam), |
| 28 | + ): |
| 29 | + for zero_padding in (True, False): |
| 30 | + panel.objview.select_objects([1]) # Select the first signal |
| 31 | + param = paramclass.create(method="brickwall", zero_padding=zero_padding) |
| 32 | + param.update_from_obj(s1) |
| 33 | + panel.processor.run_feature(feature, param) |
| 34 | + |
| 35 | + s2 = panel.objview.get_sel_objects()[0] |
| 36 | + check_array_result( |
| 37 | + f"{feature} filter output X data (zero_padding={zero_padding})", |
| 38 | + s2.x, |
| 39 | + s1.x, |
| 40 | + ) |
| 41 | + |
| 42 | + |
| 43 | +if __name__ == "__main__": |
| 44 | + test_signal_freq_filter_app() |
0 commit comments