diff options
author | Tom Rondeau | 2011-10-23 17:12:32 -0400 |
---|---|---|
committer | Tom Rondeau | 2011-10-23 17:12:32 -0400 |
commit | 7112e308a6b0b84387c73460c4c8d1e8ff9f3b5a (patch) | |
tree | e96b5804d26e221ab0de2c5bbeaffd7ab88159fd /gnuradio-core/src/python | |
parent | fea70a9c312ebf9cfcf8b5ddb60db3b6a3004248 (diff) | |
download | gnuradio-7112e308a6b0b84387c73460c4c8d1e8ff9f3b5a.tar.gz gnuradio-7112e308a6b0b84387c73460c4c8d1e8ff9f3b5a.tar.bz2 gnuradio-7112e308a6b0b84387c73460c4c8d1e8ff9f3b5a.zip |
core: Added type conversion int->float (issue #192). Added with a gri file and also added a gri file for float->int to perform function inside gr_float_to_int. Also added QA code for the new block.
Diffstat (limited to 'gnuradio-core/src/python')
-rw-r--r-- | gnuradio-core/src/python/gnuradio/gr/Makefile.am | 1 | ||||
-rw-r--r-- | gnuradio-core/src/python/gnuradio/gr/qa_float_to_int.py | 49 |
2 files changed, 50 insertions, 0 deletions
diff --git a/gnuradio-core/src/python/gnuradio/gr/Makefile.am b/gnuradio-core/src/python/gnuradio/gr/Makefile.am index 0960323dc..f5af80c78 100644 --- a/gnuradio-core/src/python/gnuradio/gr/Makefile.am +++ b/gnuradio-core/src/python/gnuradio/gr/Makefile.am @@ -60,6 +60,7 @@ noinst_PYTHON = \ qa_fft.py \ qa_fft_filter.py \ qa_filter_delay_fc.py \ + qa_float_to_int.py \ qa_fractional_interpolator.py \ qa_frequency_modulator.py \ qa_fsk_stuff.py \ diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_float_to_int.py b/gnuradio-core/src/python/gnuradio/gr/qa_float_to_int.py new file mode 100644 index 000000000..6eaf2e8f0 --- /dev/null +++ b/gnuradio-core/src/python/gnuradio/gr/qa_float_to_int.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python +# +# Copyright 2011 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 3, 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 + +class test_float_to_int (gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test_001(self): + + src_data = (0.0, 1.1, 2.2, 3.3, 4.4, 5.5, -1.1, -2.2, -3.3, -4.4, -5.5) + expected_result = [int(round(s)) for s in src_data] + src = gr.vector_source_f(src_data) + op = gr.float_to_int() + dst = gr.vector_sink_i() + + self.tb.connect(src, op, dst) + self.tb.run() + result_data = list(dst.data()) + + self.assertEqual(expected_result, result_data) + +if __name__ == '__main__': + gr_unittest.run(test_float_to_int, "test_float_to_int.xml") + |