summaryrefslogtreecommitdiff
path: root/gr-blocks/python
diff options
context:
space:
mode:
authorJohnathan Corgan2012-06-23 09:06:19 -0700
committerJohnathan Corgan2012-06-23 09:18:27 -0700
commit48ba99044710dc69c0ebdd3fbe97798622713a9f (patch)
tree1a329d1a7f4352d1fd973fe1b8023dd48f806318 /gr-blocks/python
parented0dffa3c1a84a4b8f3201969896f61af39b86a3 (diff)
downloadgnuradio-48ba99044710dc69c0ebdd3fbe97798622713a9f.tar.gz
gnuradio-48ba99044710dc69c0ebdd3fbe97798622713a9f.tar.bz2
gnuradio-48ba99044710dc69c0ebdd3fbe97798622713a9f.zip
blocks: added gr::blocks::complex_to_mag
Diffstat (limited to 'gr-blocks/python')
-rwxr-xr-xgr-blocks/python/qa_type_conversions.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/gr-blocks/python/qa_type_conversions.py b/gr-blocks/python/qa_type_conversions.py
index 1faf83ad8..92590feac 100755
--- a/gr-blocks/python/qa_type_conversions.py
+++ b/gr-blocks/python/qa_type_conversions.py
@@ -22,6 +22,7 @@
from gnuradio import gr, gr_unittest
import blocks_swig
+import math
class test_type_conversions(gr_unittest.TestCase):
@@ -116,6 +117,16 @@ class test_type_conversions(gr_unittest.TestCase):
self.tb.run()
self.assertFloatTuplesAlmostEqual(expected_data, dst.data())
+ def test_complex_to_mag(self):
+ src_data = (1+2j, 3-4j, 5+6j, 7-8j, -9+10j)
+ expected_data = (math.sqrt(5), math.sqrt(25), math.sqrt(61), math.sqrt(113), math.sqrt(181))
+ src = gr.vector_source_c(src_data)
+ op = blocks_swig.complex_to_mag()
+ dst = gr.vector_sink_f()
+ self.tb.connect(src, op, dst)
+ self.tb.run()
+ self.assertFloatTuplesAlmostEqual(expected_data, dst.data(), 5)
+
if __name__ == '__main__':
gr_unittest.run(test_type_conversions, "test_type_conversions.xml")