diff options
Diffstat (limited to 'gnuradio-core/src/python')
-rw-r--r-- | gnuradio-core/src/python/gnuradio/gr/Makefile.am | 2 | ||||
-rw-r--r-- | gnuradio-core/src/python/gnuradio/gr/qa_argmax.py | 77 | ||||
-rw-r--r-- | gnuradio-core/src/python/gnuradio/gr/qa_max.py | 56 |
3 files changed, 135 insertions, 0 deletions
diff --git a/gnuradio-core/src/python/gnuradio/gr/Makefile.am b/gnuradio-core/src/python/gnuradio/gr/Makefile.am index 175b36b60..557bf13f9 100644 --- a/gnuradio-core/src/python/gnuradio/gr/Makefile.am +++ b/gnuradio-core/src/python/gnuradio/gr/Makefile.am @@ -48,6 +48,7 @@ noinst_PYTHON = \ qa_add_and_friends.py \ qa_add_v_and_friends.py \ qa_agc.py \ + qa_argmax.py \ qa_basic_flow_graph.py \ qa_bin_statistics.py \ qa_cma_equalizer.py \ @@ -73,6 +74,7 @@ noinst_PYTHON = \ qa_interp_fir_filter.py \ qa_kludge_copy.py \ qa_kludged_imports.py \ + qa_max.py \ qa_message.py \ qa_mute.py \ qa_nlog10.py \ diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_argmax.py b/gnuradio-core/src/python/gnuradio/gr/qa_argmax.py new file mode 100644 index 000000000..767c27786 --- /dev/null +++ b/gnuradio-core/src/python/gnuradio/gr/qa_argmax.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python +# +# Copyright 2007 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +import math + + +class test_sig_source (gr_unittest.TestCase): + + def setUp (self): + self.fg = gr.flow_graph () + + + def tearDown (self): + self.fg = None + + + def test_001(self): + fg = self.fg + + src1_data = (0,0.2,-0.3,0,12,0) + src2_data = (0,0.0,3.0,0,10,0) + src3_data = (0,0.0,3.0,0,1,0) + + src1 = gr.vector_source_f (src1_data) + s2v1 = gr.stream_to_vector(gr.sizeof_float, len(src1_data)) + fg.connect( src1, s2v1 ) + + src2 = gr.vector_source_f (src2_data) + s2v2 = gr.stream_to_vector(gr.sizeof_float, len(src1_data)) + fg.connect( src2, s2v2 ) + + src3 = gr.vector_source_f (src3_data) + s2v3 = gr.stream_to_vector(gr.sizeof_float, len(src1_data)) + fg.connect( src3, s2v3 ) + + dst1 = gr.vector_sink_s () + dst2 = gr.vector_sink_s () + argmax = gr.argmax_fs (len(src1_data)) + + fg.connect (s2v1, (argmax, 0)) + fg.connect (s2v2, (argmax, 1)) + fg.connect (s2v3, (argmax, 2)) + + fg.connect ((argmax,0), dst1) + fg.connect ((argmax,1), dst2) + + fg.run () + index = dst1.data () + source = dst2.data () + self.assertEqual ( index, (4,)) + self.assertEqual ( source, (0,)) + + + +if __name__ == '__main__': + gr_unittest.main () + diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_max.py b/gnuradio-core/src/python/gnuradio/gr/qa_max.py new file mode 100644 index 000000000..b9807734a --- /dev/null +++ b/gnuradio-core/src/python/gnuradio/gr/qa_max.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python +# +# Copyright 2007 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +import math + + +class test_sig_source (gr_unittest.TestCase): + + def setUp (self): + self.fg = gr.flow_graph () + + + def tearDown (self): + self.fg = None + + + def test_001(self): + + src_data = (0,0.2,-0.3,0,12,0) + expected_result = (float(max(src_data)), ) + + src = gr.vector_source_f(src_data) + s2v = gr.stream_to_vector(gr.sizeof_float, len(src_data)) + op = gr.max_ff( len(src_data) ) + dst = gr.vector_sink_f() + + + self.fg.connect(src, s2v, op, dst) + self.fg.run() + result_data = dst.data() + self.assertEqual(expected_result, result_data) + + +if __name__ == '__main__': + gr_unittest.main () + |