def test_explain(self): # this test was written before __run checke everything; kept around for just another example f = MultistageChannelFilter(input_rate=10000, output_rate=1000, cutoff_freq=500, transition_width=100) self.assertEqual(f.explain(), textwrap.dedent("""\ 2 stages from 10000 to 1000 freq xlate and decimate by 5 using 43 taps (86000) in freq_xlating_fir_filter_ccc_sptr final filter and decimate by 2 using 49 taps (49000) in fft_filter_ccc_sptr No final resampler stage."""))
def test_explain(self): # this test was written before __run checke everything; kept around for just another example f = MultistageChannelFilter(input_rate=10000, output_rate=1000, cutoff_freq=500, transition_width=100) self.assertEqual(f.explain(), textwrap.dedent("""\ 2 stages from 10000 to 1000 freq xlate and decimate by 5 using 43 taps (86000) in freq_xlating_fir_filter_ccc_sptr final filter and decimate by 2 using 49 taps (49000) in fft_filter_ccc_sptr No final resampler stage."""))
def test_one_filter(**kwargs): print '------ %s -------' % (kwargs, ) f = MultistageChannelFilter(**kwargs) size = 10000000 top = gr.top_block() top.connect(blocks.vector_source_c([5] * size), f, blocks.null_sink(gr.sizeof_gr_complex)) print f.explain() t0 = time.clock() top.start() top.wait() top.stop() t1 = time.clock() print size, 'samples processed in', t1 - t0, 'CPU-seconds'
def test_one_filter(**kwargs): print '------ %s -------' % (kwargs,) f = MultistageChannelFilter(**kwargs) size = 10000000 top = gr.top_block() top.connect( blocks.vector_source_c([5] * size), f, blocks.null_sink(gr.sizeof_gr_complex)) print f.explain() t0 = time.clock() top.start() top.wait() top.stop() t1 = time.clock() print size, 'samples processed in', t1 - t0, 'CPU-seconds'
def test_setters(self): # TODO: Test filter functionality; this only tests that the operations work filt = MultistageChannelFilter(input_rate=32000000, output_rate=16000, cutoff_freq=3000, transition_width=1200) filt.set_cutoff_freq(2900) filt.set_transition_width(1000) filt.set_center_freq(10000) self.assertEqual(2900, filt.get_cutoff_freq()) self.assertEqual(1000, filt.get_transition_width()) self.assertEqual(10000, filt.get_center_freq()) self.assertEqual(filt.explain(), textwrap.dedent("""\ 7 stages from 32000000 to 16000 freq xlate and decimate by 5 using 25 taps (160000000) in freq_xlating_fir_filter_ccc_sptr decimate by 5 using 25 taps (32000000) in fft_filter_ccc_sptr decimate by 5 using 25 taps (6400000) in fft_filter_ccc_sptr decimate by 2 using 11 taps (1408000) in fft_filter_ccc_sptr decimate by 2 using 11 taps (704000) in fft_filter_ccc_sptr decimate by 2 using 11 taps (352000) in fft_filter_ccc_sptr final filter and decimate by 2 using 77 taps (1232000) in fft_filter_ccc_sptr No final resampler stage."""))
def test_setters(self): # TODO: Test filter functionality; this only tests that the operations work filt = MultistageChannelFilter(input_rate=32000000, output_rate=16000, cutoff_freq=3000, transition_width=1200) filt.set_cutoff_freq(2900) filt.set_transition_width(1000) filt.set_center_freq(10000) self.assertEqual(2900, filt.get_cutoff_freq()) self.assertEqual(1000, filt.get_transition_width()) self.assertEqual(10000, filt.get_center_freq()) self.assertEqual(filt.explain(), textwrap.dedent("""\ 7 stages from 32000000 to 16000 freq xlate and decimate by 5 using 25 taps (160000000) in freq_xlating_fir_filter_ccc_sptr decimate by 5 using 25 taps (32000000) in fft_filter_ccc_sptr decimate by 5 using 25 taps (6400000) in fft_filter_ccc_sptr decimate by 2 using 11 taps (1408000) in fft_filter_ccc_sptr decimate by 2 using 11 taps (704000) in fft_filter_ccc_sptr decimate by 2 using 11 taps (352000) in fft_filter_ccc_sptr final filter and decimate by 2 using 77 taps (1232000) in fft_filter_ccc_sptr No final resampler stage."""))