summaryrefslogtreecommitdiff
path: root/gr-blocks/python
diff options
context:
space:
mode:
authorJohnathan Corgan2012-06-24 11:42:20 -0700
committerJohnathan Corgan2012-06-24 11:42:20 -0700
commit8c23d9f9ebfe04b60d59efc636c6d5b02baacc99 (patch)
tree772c33274d13715b0e7b807292765a42414c38c4 /gr-blocks/python
parentb48716fe0b666cf2be605c0c7d79111c6caf96c5 (diff)
downloadgnuradio-8c23d9f9ebfe04b60d59efc636c6d5b02baacc99.tar.gz
gnuradio-8c23d9f9ebfe04b60d59efc636c6d5b02baacc99.tar.bz2
gnuradio-8c23d9f9ebfe04b60d59efc636c6d5b02baacc99.zip
blocks: added gr::blocks::float_to_complex
Diffstat (limited to 'gr-blocks/python')
-rwxr-xr-xgr-blocks/python/qa_type_conversions.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/gr-blocks/python/qa_type_conversions.py b/gr-blocks/python/qa_type_conversions.py
index 2caa283d2..4daf5f602 100755
--- a/gr-blocks/python/qa_type_conversions.py
+++ b/gr-blocks/python/qa_type_conversions.py
@@ -167,5 +167,30 @@ class test_type_conversions(gr_unittest.TestCase):
self.tb.run()
self.assertEqual(expected_data, dst.data())
+ def test_float_to_complex_1(self):
+ src_data = (1.0, 3.0, 5.0, 7.0, 9.0)
+ expected_data = (1+0j, 3+0j, 5+0j, 7+0j, 9+0j)
+ src = gr.vector_source_f(src_data)
+ op = blocks_swig.float_to_complex()
+ dst = gr.vector_sink_c()
+ self.tb.connect(src, op, dst)
+ self.tb.run()
+ self.assertFloatTuplesAlmostEqual(expected_data, dst.data())
+
+ def test_float_to_complex_2(self):
+ src1_data = (1.0, 3.0, 5.0, 7.0, 9.0)
+ src2_data = (2.0, 4.0, 6.0, 8.0, 10.0)
+ expected_data = (1+2j, 3+4j, 5+6j, 7+8j, 9+10j)
+ src1 = gr.vector_source_f(src1_data)
+ src2 = gr.vector_source_f(src2_data)
+ op = blocks_swig.float_to_complex()
+ dst = gr.vector_sink_c()
+ self.tb.connect(src1, (op, 0))
+ self.tb.connect(src2, (op, 1))
+ self.tb.connect(op, dst)
+ self.tb.run()
+ self.assertFloatTuplesAlmostEqual(expected_data, dst.data())
+
+
if __name__ == '__main__':
gr_unittest.run(test_type_conversions, "test_type_conversions.xml")