summaryrefslogtreecommitdiff
path: root/gr-blocks/python
diff options
context:
space:
mode:
authorJohnathan Corgan2012-06-23 08:12:30 -0700
committerJohnathan Corgan2012-06-23 08:26:31 -0700
commit6eb1447df04883af78ed78eb8449378e67d67bf6 (patch)
treeb4db3c2d85a27d1cfe7704a4ce3cfa5248b6066b /gr-blocks/python
parentc16e6eba638ebe3bdf5ee4770ce409481c8e1c7a (diff)
downloadgnuradio-6eb1447df04883af78ed78eb8449378e67d67bf6.tar.gz
gnuradio-6eb1447df04883af78ed78eb8449378e67d67bf6.tar.bz2
gnuradio-6eb1447df04883af78ed78eb8449378e67d67bf6.zip
blocks: added gr::blocks::complex_to_float
Diffstat (limited to 'gr-blocks/python')
-rwxr-xr-xgr-blocks/python/qa_type_conversions.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/gr-blocks/python/qa_type_conversions.py b/gr-blocks/python/qa_type_conversions.py
index b03103bfe..5d477eef1 100755
--- a/gr-blocks/python/qa_type_conversions.py
+++ b/gr-blocks/python/qa_type_conversions.py
@@ -71,5 +71,31 @@ class test_type_conversions(gr_unittest.TestCase):
self.tb.run()
self.assertEqual(expected_data, dst.data())
+ def test_complex_to_float_1(self):
+ src_data = (1+2j, 3+4j, 5+6j, 7+8j, 9+10j)
+ expected_data = (1.0, 3.0, 5.0, 7.0, 9.0)
+ src = gr.vector_source_c(src_data)
+ op = blocks_swig.complex_to_float()
+ dst = gr.vector_sink_f()
+ self.tb.connect(src, op, dst)
+ self.tb.run()
+ self.assertFloatTuplesAlmostEqual(expected_data, dst.data())
+
+ def test_complex_to_float_2(self):
+ src_data = (1+2j, 3+4j, 5+6j, 7+8j, 9+10j)
+ expected_data1 = (1.0, 3.0, 5.0, 7.0, 9.0)
+ expected_data2 = (2.0, 4.0, 6.0, 8.0, 10.0)
+ src = gr.vector_source_c(src_data)
+ op = blocks_swig.complex_to_float()
+ dst1 = gr.vector_sink_f()
+ dst2 = gr.vector_sink_f()
+ self.tb.connect(src, op)
+ self.tb.connect((op, 0), dst1)
+ self.tb.connect((op, 1), dst2)
+ self.tb.run()
+ self.assertFloatTuplesAlmostEqual(expected_data1, dst1.data())
+ self.assertFloatTuplesAlmostEqual(expected_data2, dst2.data())
+
+
if __name__ == '__main__':
gr_unittest.run(test_type_conversions, "test_type_conversions.xml")