diff options
-rwxr-xr-x | gr-filter/python/qa_fir_filter.py | 154 |
1 files changed, 140 insertions, 14 deletions
diff --git a/gr-filter/python/qa_fir_filter.py b/gr-filter/python/qa_fir_filter.py index 93974bb89..ac20286cc 100755 --- a/gr-filter/python/qa_fir_filter.py +++ b/gr-filter/python/qa_fir_filter.py @@ -31,10 +31,32 @@ class test_filter(gr_unittest.TestCase): self.tb = None def test_fir_filter_fff_001(self): - src_data = [1, 2, 3, 4] - expected_data = [0.5, 1.5, 2.5, 3.5] + src_data = 40*[1, 2, 3, 4] + expected_data = (0.5, 1.5, 3.0, 5.0, 5.5, 6.5, 8.0, 10.0, + 10.5, 11.5, 13.0, 15.0, 15.5, 16.5, 18.0, + 20.0, 20.5, 21.5, 23.0, 25.0, 25.5, 26.5, + 28.0, 30.0, 30.5, 31.5, 33.0, 35.0, 35.5, + 36.5, 38.0, 40.0, 40.5, 41.5, 43.0, 45.0, + 45.5, 46.5, 48.0, 50.0, 50.0, 50.0, 50.0, + 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, + 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, + 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, + 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, + 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, + 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, + 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, + 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, + 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, + 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, + 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, + 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, + 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, + 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, + 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, + 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, + 50.0, 50.0, 50.0, 50.0, 50.0) src = gr.vector_source_f(src_data) - op = filter.fir_filter_fff(1, [0.5, 0.5]) + op = filter.fir_filter_fff(1, 20*[0.5, 0.5]) dst = gr.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() @@ -42,23 +64,72 @@ class test_filter(gr_unittest.TestCase): self.assertFloatTuplesAlmostEqual(expected_data, result_data, 5) def test_fir_filter_fff_002(self): - src_data = 10*[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] - expected_data = [0.0,] + 4*[3.5, 7.5, 1.5, 5.5, 4.5,] + [3.5, 7.5, 1.5, 5.5] + src_data = 40*[1, 2, 3, 4] + expected_data = (0.5, 5.5, 10.5, 15.5, 20.5, 25.5, 30.5, 35.5, + 40.5, 45.5, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, + 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, + 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, + 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0) src = gr.vector_source_f(src_data) - op = filter.fir_filter_fff(4, [0.5, 0.5]) + op = filter.fir_filter_fff(4, 20*[0.5, 0.5]) dst = gr.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() - print result_data - print expected_data self.assertFloatTuplesAlmostEqual(expected_data, result_data, 5) def test_fir_filter_ccf_001(self): - src_data = [1+1j, 2+2j, 3+3j, 4+4j] - expected_data = [0.5+0.5j, 1.5+1.5j, 2.5+2.5j, 3.5+3.5j] + src_data = 40*[1+1j, 2+2j, 3+3j, 4+4j] + expected_data = ((0.5+0.5j), (1.5+1.5j), (3+3j), (5+5j), (5.5+5.5j), + (6.5+6.5j), (8+8j), (10+10j), (10.5+10.5j), (11.5+11.5j), + (13+13j), (15+15j), (15.5+15.5j), (16.5+16.5j), (18+18j), + (20+20j), (20.5+20.5j), (21.5+21.5j), (23+23j), (25+25j), + (25.5+25.5j), (26.5+26.5j), (28+28j), (30+30j), (30.5+30.5j), + (31.5+31.5j), (33+33j), (35+35j), (35.5+35.5j), (36.5+36.5j), + (38+38j), (40+40j), (40.5+40.5j), (41.5+41.5j), (43+43j), + (45+45j), (45.5+45.5j), (46.5+46.5j), (48+48j), (50+50j), + (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), + (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), + (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), + (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), + (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), + (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), + (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), + (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), + (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), + (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), + (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), + (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), + (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), + (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), + (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), + (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), + (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), + (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), + (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), + (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j)) + + src = gr.vector_source_c(src_data) + op = filter.fir_filter_ccf(1, 20*[0.5, 0.5]) + dst = gr.vector_sink_c() + self.tb.connect(src, op, dst) + self.tb.run() + result_data = dst.data() + self.assertComplexTuplesAlmostEqual(expected_data, result_data, 5) + + def test_fir_filter_ccf_002(self): + src_data = 40*[1+1j, 2+2j, 3+3j, 4+4j] + expected_data = ((0.5+0.5j), (5.5+5.5j), (10.5+10.5j), (15.5+15.5j), + (20.5+20.5j), (25.5+25.5j), (30.5+30.5j), (35.5+35.5j), + (40.5+40.5j), (45.5+45.5j), (50+50j), (50+50j), (50+50j), + (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), + (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), + (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), + (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), + (50+50j), (50+50j), (50+50j), (50+50j)) + src = gr.vector_source_c(src_data) - op = filter.fir_filter_ccf(1, [0.5, 0.5]) + op = filter.fir_filter_ccf(4, 20*[0.5, 0.5]) dst = gr.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() @@ -66,10 +137,43 @@ class test_filter(gr_unittest.TestCase): self.assertComplexTuplesAlmostEqual(expected_data, result_data, 5) def test_fir_filter_ccc_001(self): - src_data = [1+1j, 2+2j, 3+3j, 4+4j] - expected_data = [-0.5+1.5j, -1.5+4.5j, -2.5+7.5j, -3.5+10.5j] + src_data = 40*[1+1j, 2+2j, 3+3j, 4+4j] + expected_data = ((-0.5+1.5j), (-1.5+4.5j), (-3+9j), (-5+15j), + (-5.5+16.5j), (-6.5+19.5j), (-8+24j), (-10+30j), + (-10.5+31.5j), (-11.5+34.5j), (-13+39j), (-15+45j), + (-15.5+46.5j), (-16.5+49.5j), (-18+54j), (-20+60j), + (-20.5+61.5j), (-21.5+64.5j), (-23+69j), (-25+75j), + (-25.5+76.5j), (-26.5+79.5j), (-28+84j), (-30+90j), + (-30.5+91.5j), (-31.5+94.5j), (-33+99j), (-35+105j), + (-35.5+106.5j), (-36.5+109.5j), (-38+114j), (-40+120j), + (-40.5+121.5j), (-41.5+124.5j), (-43+129j), (-45+135j), + (-45.5+136.5j), (-46.5+139.5j), (-48+144j), (-50+150j), + (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), + (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), + (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), + (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), + (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), + (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), + (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), + (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), + (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), + (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), + (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), + (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), + (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), + (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), + (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), + (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), + (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), + (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), + (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), + (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), + (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), + (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), + (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), + (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j)) src = gr.vector_source_c(src_data) - op = filter.fir_filter_ccc(1, [0.5+1j, 0.5+1j]) + op = filter.fir_filter_ccc(1, 20*[0.5+1j, 0.5+1j]) dst = gr.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() @@ -92,6 +196,28 @@ class test_filter(gr_unittest.TestCase): result_data = dst.data() self.assertComplexTuplesAlmostEqual(expected_data, result_data, 5) + def test_fir_filter_ccc_003(self): + src_data = 40*[1+1j, 2+2j, 3+3j, 4+4j] + expected_data = ((-0.5+1.5j), (-5.5+16.5j), (-10.5+31.5j), + (-15.5+46.5j), (-20.5+61.5j), (-25.5+76.5j), + (-30.5+91.5j), (-35.5+106.5j), (-40.5+121.5j), + (-45.5+136.5j), (-50+150j), (-50+150j), (-50+150j), + (-50+150j), (-50+150j), (-50+150j), (-50+150j), + (-50+150j), (-50+150j), (-50+150j), (-50+150j), + (-50+150j), (-50+150j), (-50+150j), (-50+150j), + (-50+150j), (-50+150j), (-50+150j), (-50+150j), + (-50+150j), (-50+150j), (-50+150j), (-50+150j), + (-50+150j), (-50+150j), (-50+150j), (-50+150j), + (-50+150j), (-50+150j), (-50+150j)) + src = gr.vector_source_c(src_data) + op = filter.fir_filter_ccc(4, 20*[0.5+1j, 0.5+1j]) + dst = gr.vector_sink_c() + self.tb.connect(src, op, dst) + self.tb.run() + result_data = dst.data() + self.assertComplexTuplesAlmostEqual(expected_data, result_data, 5) + + if __name__ == '__main__': gr_unittest.run(test_filter, "test_filter.xml") |