summaryrefslogtreecommitdiff
path: root/gr-blocks/python
diff options
context:
space:
mode:
authorJohnathan Corgan2012-06-26 19:43:01 -0700
committerJohnathan Corgan2012-06-26 19:43:01 -0700
commit3de0c77ed91e417c0b54972a78ffbad62f4bbb87 (patch)
tree47e9e1742e6e877606b03704a26ce8cc3c67d14b /gr-blocks/python
parent0b7655a76e5c73b8f5a8310909cf038f12cbb869 (diff)
downloadgnuradio-3de0c77ed91e417c0b54972a78ffbad62f4bbb87.tar.gz
gnuradio-3de0c77ed91e417c0b54972a78ffbad62f4bbb87.tar.bz2
gnuradio-3de0c77ed91e417c0b54972a78ffbad62f4bbb87.zip
blocks: added gr::blocks::float_to_int
Diffstat (limited to 'gr-blocks/python')
-rwxr-xr-xgr-blocks/python/qa_type_conversions.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/gr-blocks/python/qa_type_conversions.py b/gr-blocks/python/qa_type_conversions.py
index a97203566..354cf9392 100755
--- a/gr-blocks/python/qa_type_conversions.py
+++ b/gr-blocks/python/qa_type_conversions.py
@@ -241,6 +241,26 @@ class test_type_conversions(gr_unittest.TestCase):
self.tb.run()
self.assertEqual(expected_data, dst.data())
+ def test_int_to_float_identity(self):
+ src_data = (1, 2, 3, 4, 5)
+ expected_data = (1.0, 2.0, 3.0, 4.0, 5.0)
+ src = gr.vector_source_i(src_data)
+ op = blocks_swig.int_to_float()
+ dst = gr.vector_sink_f()
+ self.tb.connect(src, op, dst)
+ self.tb.run()
+ self.assertFloatTuplesAlmostEqual(expected_data, dst.data())
+
+ def test_int_to_float_scale(self):
+ src_data = (1, 2, 3, 4, 5)
+ expected_data = (0.2, 0.4, 0.6, 0.8, 1.0)
+ src = gr.vector_source_i(src_data)
+ op = blocks_swig.int_to_float(1, 5)
+ dst = gr.vector_sink_f()
+ self.tb.connect(src, op, dst)
+ self.tb.run()
+ self.assertFloatTuplesAlmostEqual(expected_data, dst.data())
+
if __name__ == '__main__':
gr_unittest.run(test_type_conversions, "test_type_conversions.xml")