summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/python
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-core/src/python')
-rw-r--r--gnuradio-core/src/python/gnuradio/gr/Makefile.am4
-rwxr-xr-xgnuradio-core/src/python/gnuradio/gr/qa_add_and_friends.py34
-rwxr-xr-xgnuradio-core/src/python/gnuradio/gr/qa_complex_to_xxx.py2
-rw-r--r--gnuradio-core/src/python/gnuradio/gr/qa_conjugate.py53
-rwxr-xr-xgnuradio-core/src/python/gnuradio/gr/qa_delay.py2
-rwxr-xr-xgnuradio-core/src/python/gnuradio/gr/qa_fft.py54
-rwxr-xr-xgnuradio-core/src/python/gnuradio/gr/qa_fft_filter.py86
-rwxr-xr-xgnuradio-core/src/python/gnuradio/gr/qa_float_to_char.py82
-rwxr-xr-x[-rw-r--r--]gnuradio-core/src/python/gnuradio/gr/qa_float_to_int.py22
-rwxr-xr-xgnuradio-core/src/python/gnuradio/gr/qa_float_to_short.py86
-rwxr-xr-xgnuradio-core/src/python/gnuradio/gr/qa_float_to_uchar.py64
-rwxr-xr-xgnuradio-core/src/python/gnuradio/gr/qa_int_to_float.py20
-rw-r--r--gnuradio-core/src/python/gnuradio/gr/qa_multiply_conjugate.py57
-rwxr-xr-xgnuradio-core/src/python/gnuradio/gr/qa_short_to_char.py69
-rwxr-xr-xgnuradio-core/src/python/gnuradio/gr/qa_short_to_float.py70
15 files changed, 699 insertions, 6 deletions
diff --git a/gnuradio-core/src/python/gnuradio/gr/Makefile.am b/gnuradio-core/src/python/gnuradio/gr/Makefile.am
index f5af80c78..9853766f9 100644
--- a/gnuradio-core/src/python/gnuradio/gr/Makefile.am
+++ b/gnuradio-core/src/python/gnuradio/gr/Makefile.am
@@ -50,6 +50,7 @@ noinst_PYTHON = \
qa_bin_statistics.py \
qa_classify.py \
qa_complex_to_xxx.py \
+ qa_conjugate.py \
qa_copy.py \
qa_delay.py \
qa_dc_blocker.py \
@@ -60,7 +61,9 @@ noinst_PYTHON = \
qa_fft.py \
qa_fft_filter.py \
qa_filter_delay_fc.py \
+ qa_float_to_char.py \
qa_float_to_int.py \
+ qa_float_to_short.py \
qa_fractional_interpolator.py \
qa_frequency_modulator.py \
qa_fsk_stuff.py \
@@ -77,6 +80,7 @@ noinst_PYTHON = \
qa_kludged_imports.py \
qa_max.py \
qa_message.py \
+ qa_multiply_conjugate.py \
qa_mute.py \
qa_nlog10.py \
qa_noise.py \
diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_add_and_friends.py b/gnuradio-core/src/python/gnuradio/gr/qa_add_and_friends.py
index 8fb70fb3f..e3b20c3c3 100755
--- a/gnuradio-core/src/python/gnuradio/gr/qa_add_and_friends.py
+++ b/gnuradio-core/src/python/gnuradio/gr/qa_add_and_friends.py
@@ -78,6 +78,24 @@ class test_add_and_friends (gr_unittest.TestCase):
op = gr.multiply_const_ii (5)
self.help_ii ((src_data,), expected_result, op)
+ def test_mult_const_ff (self):
+ src_data = (-1, 0, 1, 2, 3)
+ expected_result = (-5, 0, 5, 10, 15)
+ op = gr.multiply_const_cc (5)
+ self.help_cc ((src_data,), expected_result, op)
+
+ def test_mult_const_cc (self):
+ src_data = (-1-1j, 0+0j, 1+1j, 2+2j, 3+3j)
+ expected_result = (-5-5j, 0+0j, 5+5j, 10+10j, 15+15j)
+ op = gr.multiply_const_cc (5)
+ self.help_cc ((src_data,), expected_result, op)
+
+ def test_mult_const_cc2 (self):
+ src_data = (-1-1j, 0+0j, 1+1j, 2+2j, 3+3j)
+ expected_result = (-3-7j, 0+0j, 3+7j, 6+14j, 9+21j)
+ op = gr.multiply_const_cc (5+2j)
+ self.help_cc ((src_data,), expected_result, op)
+
def test_add_ii (self):
src1_data = (1, 2, 3, 4, 5)
src2_data = (8, -3, 4, 8, 2)
@@ -94,6 +112,22 @@ class test_add_and_friends (gr_unittest.TestCase):
self.help_ii ((src1_data, src2_data),
expected_result, op)
+ def test_mult_ff (self):
+ src1_data = (1, 2, 3, 4, 5)
+ src2_data = (8, -3, 4, 8, 2)
+ expected_result = (8, -6, 12, 32, 10)
+ op = gr.multiply_ff ()
+ self.help_ff ((src1_data, src2_data),
+ expected_result, op)
+
+ def test_mult_cc (self):
+ src1_data = (1+1j, 2+2j, 3+3j, 4+4j, 5+5j)
+ src2_data = (8, -3, 4, 8, 2)
+ expected_result = (8+8j, -6-6j, 12+12j, 32+32j, 10+10j)
+ op = gr.multiply_cc ()
+ self.help_cc ((src1_data, src2_data),
+ expected_result, op)
+
def test_sub_ii_1 (self):
src1_data = (1, 2, 3, 4, 5)
expected_result = (-1, -2, -3, -4, -5)
diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_complex_to_xxx.py b/gnuradio-core/src/python/gnuradio/gr/qa_complex_to_xxx.py
index 76627247b..01679dc05 100755
--- a/gnuradio-core/src/python/gnuradio/gr/qa_complex_to_xxx.py
+++ b/gnuradio-core/src/python/gnuradio/gr/qa_complex_to_xxx.py
@@ -134,7 +134,7 @@ class test_complex_ops (gr_unittest.TestCase):
self.tb.run ()
actual_result = dst.data ()
- self.assertFloatTuplesAlmostEqual (expected_result, actual_result, 5)
+ self.assertFloatTuplesAlmostEqual (expected_result, actual_result, 3)
if __name__ == '__main__':
diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_conjugate.py b/gnuradio-core/src/python/gnuradio/gr/qa_conjugate.py
new file mode 100644
index 000000000..c07902a5a
--- /dev/null
+++ b/gnuradio-core/src/python/gnuradio/gr/qa_conjugate.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+#
+# Copyright 2012 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_conjugate (gr_unittest.TestCase):
+
+ def setUp (self):
+ self.tb = gr.top_block ()
+
+ def tearDown (self):
+ self.tb = None
+
+ def test_000 (self):
+ src_data = (-2-2j, -1-1j, -2+2j, -1+1j,
+ 2-2j, 1-1j, 2+2j, 1+1j,
+ 0+0j)
+
+ exp_data = (-2+2j, -1+1j, -2-2j, -1-1j,
+ 2+2j, 1+1j, 2-2j, 1-1j,
+ 0-0j)
+
+ src = gr.vector_source_c(src_data)
+ op = gr.conjugate_cc ()
+ dst = gr.vector_sink_c ()
+
+ self.tb.connect(src, op)
+ self.tb.connect(op, dst)
+ self.tb.run()
+ result_data = dst.data ()
+ self.assertEqual (exp_data, result_data)
+
+if __name__ == '__main__':
+ gr_unittest.run(test_conjugate, "test_conjugate.xml")
diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_delay.py b/gnuradio-core/src/python/gnuradio/gr/qa_delay.py
index 7cad0ae72..114e50108 100755
--- a/gnuradio-core/src/python/gnuradio/gr/qa_delay.py
+++ b/gnuradio-core/src/python/gnuradio/gr/qa_delay.py
@@ -50,7 +50,7 @@ class test_delay (gr_unittest.TestCase):
delta_t = 10
tb = self.tb
src_data = [float(x) for x in range(0, 100)]
- expected_result = tuple(delta_t*[0.0] + src_data[0:-delta_t])
+ expected_result = tuple(delta_t*[0.0] + src_data)
src = gr.vector_source_f(src_data)
op = gr.delay(gr.sizeof_float, delta_t)
diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_fft.py b/gnuradio-core/src/python/gnuradio/gr/qa_fft.py
index 98d80fbb0..e90eb2e7f 100755
--- a/gnuradio-core/src/python/gnuradio/gr/qa_fft.py
+++ b/gnuradio-core/src/python/gnuradio/gr/qa_fft.py
@@ -152,6 +152,60 @@ class test_fft(gr_unittest.TestCase):
#self.assertComplexTuplesAlmostEqual (expected_result, result_data, 5)
self.assert_fft_ok2(expected_result, result_data)
+ def test_003(self):
+ # Same test as above, only use 2 threads
+
+ tb = gr.top_block()
+ fft_size = 32
+
+ tmp_data = ((4377+4516j),
+ (-1706.1268310546875+1638.4256591796875j),
+ (-915.2083740234375+660.69427490234375j),
+ (-660.370361328125+381.59600830078125j),
+ (-499.96044921875+238.41630554199219j),
+ (-462.26748657226562+152.88948059082031j),
+ (-377.98440551757812+77.5928955078125j),
+ (-346.85821533203125+47.152004241943359j),
+ (-295+20j),
+ (-286.33609008789062-22.257017135620117j),
+ (-271.52999877929688-33.081821441650391j),
+ (-224.6358642578125-67.019538879394531j),
+ (-244.24473571777344-91.524826049804688j),
+ (-203.09068298339844-108.54627227783203j),
+ (-198.45195007324219-115.90768432617188j),
+ (-182.97744750976562-128.12318420410156j),
+ (-167-180j),
+ (-130.33688354492188-173.83778381347656j),
+ (-141.19784545898438-190.28807067871094j),
+ (-111.09677124023438-214.48896789550781j),
+ (-70.039543151855469-242.41630554199219j),
+ (-68.960540771484375-228.30015563964844j),
+ (-53.049201965332031-291.47097778320312j),
+ (-28.695289611816406-317.64553833007812j),
+ (57-300j),
+ (45.301143646240234-335.69509887695312j),
+ (91.936195373535156-373.32437133789062j),
+ (172.09465026855469-439.275146484375j),
+ (242.24473571777344-504.47515869140625j),
+ (387.81732177734375-666.6788330078125j),
+ (689.48553466796875-918.2142333984375j),
+ (1646.539306640625-1694.1956787109375j))
+
+ src_data = tuple([x/fft_size for x in tmp_data])
+
+ expected_result = tuple([complex(primes[2*i], primes[2*i+1]) for i in range(fft_size)])
+
+ nthreads = 2
+
+ src = gr.vector_source_c(src_data)
+ s2v = gr.stream_to_vector(gr.sizeof_gr_complex, fft_size)
+ fft = gr.fft_vcc(fft_size, False, [], False, nthreads)
+ v2s = gr.vector_to_stream(gr.sizeof_gr_complex, fft_size)
+ dst = gr.vector_sink_c()
+ tb.connect(src, s2v, fft, v2s, dst)
+ tb.run()
+ result_data = dst.data()
+ self.assert_fft_ok2(expected_result, result_data)
if __name__ == '__main__':
gr_unittest.run(test_fft, "test_fft.xml")
diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_fft_filter.py b/gnuradio-core/src/python/gnuradio/gr/qa_fft_filter.py
index 325495c1d..1e9fdb6a8 100755
--- a/gnuradio-core/src/python/gnuradio/gr/qa_fft_filter.py
+++ b/gnuradio-core/src/python/gnuradio/gr/qa_fft_filter.py
@@ -110,6 +110,23 @@ class test_fft_filter(gr_unittest.TestCase):
def test_ccc_002(self):
+ # Test nthreads
+ tb = gr.top_block()
+ src_data = (0,1,2,3,4,5,6,7)
+ taps = (2,)
+ nthreads = 2
+ expected_result = tuple([2 * complex(x) for x in (0,1,2,3,4,5,6,7)])
+ src = gr.vector_source_c(src_data)
+ op = gr.fft_filter_ccc(1, taps, nthreads)
+ dst = gr.vector_sink_c()
+ tb.connect(src, op, dst)
+ tb.run()
+ result_data = dst.data()
+ #print 'expected:', expected_result
+ #print 'results: ', result_data
+ self.assertComplexTuplesAlmostEqual (expected_result, result_data, 5)
+
+ def test_ccc_003(self):
tb = gr.top_block()
src_data = (0,1,2,3,4,5,6,7)
taps = (2,)
@@ -124,6 +141,7 @@ class test_fft_filter(gr_unittest.TestCase):
#print 'results: ', result_data
self.assertComplexTuplesAlmostEqual (expected_result, result_data, 5)
+
def test_ccc_004(self):
random.seed(0)
for i in xrange(25):
@@ -167,6 +185,30 @@ class test_fft_filter(gr_unittest.TestCase):
self.assert_fft_ok2(expected_result, result_data)
+ def test_ccc_006(self):
+ # Test decimating with nthreads=2
+ random.seed(0)
+ nthreads = 2
+ for i in xrange(25):
+ # sys.stderr.write("\n>>> Loop = %d\n" % (i,))
+ dec = i + 1
+ src_len = 4*1024
+ src_data = make_random_complex_tuple(src_len)
+ ntaps = int(random.uniform(2, 100))
+ taps = make_random_complex_tuple(ntaps)
+ expected_result = reference_filter_ccc(dec, taps, src_data)
+
+ src = gr.vector_source_c(src_data)
+ op = gr.fft_filter_ccc(dec, taps, nthreads)
+ dst = gr.vector_sink_c()
+ tb = gr.top_block()
+ tb.connect(src, op, dst)
+ tb.run()
+ del tb
+ result_data = dst.data()
+
+ self.assert_fft_ok2(expected_result, result_data)
+
# ----------------------------------------------------------------
# test _fff version
# ----------------------------------------------------------------
@@ -202,7 +244,22 @@ class test_fft_filter(gr_unittest.TestCase):
#print 'results: ', result_data
self.assertFloatTuplesAlmostEqual (expected_result, result_data, 5)
- def xtest_fff_003(self):
+ def test_fff_003(self):
+ # Test 02 with nthreads
+ tb = gr.top_block()
+ src_data = (0,1,2,3,4,5,6,7)
+ taps = (2,)
+ nthreads = 2
+ expected_result = tuple([2 * float(x) for x in (0,1,2,3,4,5,6,7)])
+ src = gr.vector_source_f(src_data)
+ op = gr.fft_filter_fff(1, taps, nthreads)
+ dst = gr.vector_sink_f()
+ tb.connect(src, op, dst)
+ tb.run()
+ result_data = dst.data()
+ self.assertFloatTuplesAlmostEqual (expected_result, result_data, 5)
+
+ def xtest_fff_004(self):
random.seed(0)
for i in xrange(25):
sys.stderr.write("\n>>> Loop = %d\n" % (i,))
@@ -232,7 +289,7 @@ class test_fft_filter(gr_unittest.TestCase):
actual.write(`x` + '\n')
raise
- def xtest_fff_004(self):
+ def xtest_fff_005(self):
random.seed(0)
for i in xrange(25):
sys.stderr.write("\n>>> Loop = %d\n" % (i,))
@@ -252,7 +309,7 @@ class test_fft_filter(gr_unittest.TestCase):
self.assert_fft_float_ok2(expected_result, result_data, abs_eps=2.0)
- def xtest_fff_005(self):
+ def xtest_fff_006(self):
random.seed(0)
for i in xrange(25):
sys.stderr.write("\n>>> Loop = %d\n" % (i,))
@@ -273,6 +330,29 @@ class test_fft_filter(gr_unittest.TestCase):
self.assert_fft_float_ok2(expected_result, result_data)
+ def xtest_fff_007(self):
+ # test decimation with nthreads
+ random.seed(0)
+ nthreads = 2
+ for i in xrange(25):
+ sys.stderr.write("\n>>> Loop = %d\n" % (i,))
+ dec = i + 1
+ src_len = 4*1024
+ src_data = make_random_float_tuple(src_len)
+ ntaps = int(random.uniform(2, 100))
+ taps = make_random_float_tuple(ntaps)
+ expected_result = reference_filter_fff(dec, taps, src_data)
+
+ src = gr.vector_source_f(src_data)
+ op = gr.fft_filter_fff(dec, taps, nthreads)
+ dst = gr.vector_sink_f()
+ tb = gr.top_block()
+ tb.connect(src, op, dst)
+ tb.run()
+ result_data = dst.data()
+
+ self.assert_fft_float_ok2(expected_result, result_data)
+
def test_fff_get0(self):
random.seed(0)
for i in xrange(25):
diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_float_to_char.py b/gnuradio-core/src/python/gnuradio/gr/qa_float_to_char.py
new file mode 100755
index 000000000..ecdd36228
--- /dev/null
+++ b/gnuradio-core/src/python/gnuradio/gr/qa_float_to_char.py
@@ -0,0 +1,82 @@
+#!/usr/bin/env python
+#
+# Copyright 2011,2012 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_char (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)
+ expected_result = [0, 1, 2, 3, 4, 5, 255, 254, 253]
+ src = gr.vector_source_f(src_data)
+ op = gr.float_to_char()
+ dst = gr.vector_sink_b()
+
+ self.tb.connect(src, op, dst)
+ self.tb.run()
+ result_data = list(dst.data())
+
+ self.assertEqual(expected_result, result_data)
+
+ def test_002(self):
+
+ src_data = ( 126.0, 127.0, 128.0)
+ expected_result = [ 126, 127, 127 ]
+
+ src = gr.vector_source_f(src_data)
+ op = gr.float_to_char()
+ # Note: vector_sink_b returns uchar
+ dst = gr.vector_sink_b()
+
+ self.tb.connect(src, op, dst)
+ self.tb.run()
+ result_data = list(dst.data())
+
+ self.assertEqual(expected_result, result_data)
+
+ def test_003(self):
+
+ scale = 2
+ vlen = 3
+ src_data = (0.0, 1.1, 2.2, 3.3, 4.4, 5.5, -1.1, -2.2, -3.3)
+ expected_result = [0, 2, 4, 6, 8, 11, 254, 252, 250]
+ src = gr.vector_source_f(src_data)
+ s2v = gr.stream_to_vector(gr.sizeof_float, vlen)
+ op = gr.float_to_char(vlen, scale)
+ v2s = gr.vector_to_stream(gr.sizeof_char, vlen)
+ dst = gr.vector_sink_b()
+
+ self.tb.connect(src, s2v, op, v2s, dst)
+ self.tb.run()
+ result_data = list(dst.data())
+
+ self.assertEqual(expected_result, result_data)
+
+if __name__ == '__main__':
+ gr_unittest.run(test_float_to_char, "test_float_to_char.xml")
+
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
index 3e0b847a2..977a8518d 100644..100755
--- a/gnuradio-core/src/python/gnuradio/gr/qa_float_to_int.py
+++ b/gnuradio-core/src/python/gnuradio/gr/qa_float_to_int.py
@@ -33,7 +33,8 @@ class test_float_to_int (gr_unittest.TestCase):
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]
+ expected_result = [0, 1, 2, 3, 4, 6, -1, -2, -3, -4, -6]
+
src = gr.vector_source_f(src_data)
op = gr.float_to_int()
dst = gr.vector_sink_i()
@@ -60,6 +61,25 @@ class test_float_to_int (gr_unittest.TestCase):
self.assertEqual(expected_result, result_data)
+
+ def test_003(self):
+
+ scale = 2
+ vlen = 3
+ src_data = (0.0, 1.1, 2.2, 3.3, 4.4, 5.5, -1.1, -2.2, -3.3)
+ expected_result = [0, 2, 4, 7, 9, 11, -2, -4, -7,]
+ src = gr.vector_source_f(src_data)
+ s2v = gr.stream_to_vector(gr.sizeof_float, vlen)
+ op = gr.float_to_int(vlen, scale)
+ v2s = gr.vector_to_stream(gr.sizeof_int, vlen)
+ dst = gr.vector_sink_i()
+
+ self.tb.connect(src, s2v, op, v2s, 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")
diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_float_to_short.py b/gnuradio-core/src/python/gnuradio/gr/qa_float_to_short.py
new file mode 100755
index 000000000..0d89a149c
--- /dev/null
+++ b/gnuradio-core/src/python/gnuradio/gr/qa_float_to_short.py
@@ -0,0 +1,86 @@
+#!/usr/bin/env python
+#
+# Copyright 2011,2012 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
+import ctypes
+
+class test_float_to_short (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 = [0, 1, 2, 3, 4, 6, -1, -2, -3, -4, -6]
+
+ src = gr.vector_source_f(src_data)
+ op = gr.float_to_short()
+ dst = gr.vector_sink_s()
+
+ self.tb.connect(src, op, dst)
+ self.tb.run()
+ result_data = list(dst.data())
+
+ self.assertEqual(expected_result, result_data)
+
+ def test_002(self):
+
+ src_data = ( 32766, 32767, 32768,
+ -32767, -32768, -32769)
+ expected_result = [ 32766, 32767, 32767,
+ -32767, -32768, -32768 ]
+
+ src = gr.vector_source_f(src_data)
+ op = gr.float_to_short()
+ dst = gr.vector_sink_s()
+
+ self.tb.connect(src, op, dst)
+ self.tb.run()
+ result_data = list(dst.data())
+
+ self.assertEqual(expected_result, result_data)
+
+ def test_003(self):
+
+ scale = 2
+ vlen = 3
+ src_data = (0.0, 1.1, 2.2, 3.3, 4.4, 5.5, -1.1, -2.2, -3.3)
+ expected_result = [0, 2, 4, 7, 9, 11, -2, -4, -7]
+ src = gr.vector_source_f(src_data)
+ s2v = gr.stream_to_vector(gr.sizeof_float, vlen)
+ op = gr.float_to_short(vlen, scale)
+ v2s = gr.vector_to_stream(gr.sizeof_short, vlen)
+ dst = gr.vector_sink_s()
+
+ self.tb.connect(src, s2v, op, v2s, dst)
+ self.tb.run()
+ result_data = list(dst.data())
+
+ self.assertEqual(expected_result, result_data)
+
+if __name__ == '__main__':
+ gr_unittest.run(test_float_to_short, "test_float_to_short.xml")
+
diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_float_to_uchar.py b/gnuradio-core/src/python/gnuradio/gr/qa_float_to_uchar.py
new file mode 100755
index 000000000..0d54f45f3
--- /dev/null
+++ b/gnuradio-core/src/python/gnuradio/gr/qa_float_to_uchar.py
@@ -0,0 +1,64 @@
+#!/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
+import ctypes
+
+class test_float_to_uchar (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 = [0, 1, 2, 3, 4, 6, 0, 0, 0, 0, 0]
+ src = gr.vector_source_f(src_data)
+ op = gr.float_to_uchar()
+ dst = gr.vector_sink_b()
+
+ self.tb.connect(src, op, dst)
+ self.tb.run()
+ result_data = list(dst.data())
+
+ self.assertEqual(expected_result, result_data)
+
+ def test_002(self):
+
+ src_data = ( 254.0, 255.0, 256.0)
+ expected_result = [ 254, 255, 255 ]
+ src = gr.vector_source_f(src_data)
+ op = gr.float_to_uchar()
+ dst = gr.vector_sink_b()
+
+ 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_uchar, "test_float_to_uchar.xml")
+
diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_int_to_float.py b/gnuradio-core/src/python/gnuradio/gr/qa_int_to_float.py
index edfc26409..530b2a5cc 100755
--- a/gnuradio-core/src/python/gnuradio/gr/qa_int_to_float.py
+++ b/gnuradio-core/src/python/gnuradio/gr/qa_int_to_float.py
@@ -44,6 +44,26 @@ class test_int_to_float (gr_unittest.TestCase):
self.assertFloatTuplesAlmostEqual(expected_result, result_data)
+ def test_002(self):
+
+ vlen = 3
+ src_data = ( 65000, 65001, 65002, 65003, 65004, 65005,
+ -65001, -65002, -65003)
+ expected_result = [ 65000.0, 65001.0, 65002.0,
+ 65003.0, 65004.0, 65005.0,
+ -65001.0, -65002.0, -65003.0]
+ src = gr.vector_source_i(src_data)
+ s2v = gr.stream_to_vector(gr.sizeof_int, vlen)
+ op = gr.int_to_float(vlen)
+ v2s = gr.vector_to_stream(gr.sizeof_float, vlen)
+ dst = gr.vector_sink_f()
+
+ self.tb.connect(src, s2v, op, v2s, dst)
+ self.tb.run()
+ result_data = list(dst.data())
+
+ self.assertEqual(expected_result, result_data)
+
if __name__ == '__main__':
gr_unittest.run(test_int_to_float, "test_int_to_float.xml")
diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_multiply_conjugate.py b/gnuradio-core/src/python/gnuradio/gr/qa_multiply_conjugate.py
new file mode 100644
index 000000000..aaf3cc125
--- /dev/null
+++ b/gnuradio-core/src/python/gnuradio/gr/qa_multiply_conjugate.py
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+#
+# Copyright 2012 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_multiply_conjugate (gr_unittest.TestCase):
+
+ def setUp (self):
+ self.tb = gr.top_block ()
+
+ def tearDown (self):
+ self.tb = None
+
+ def test_000 (self):
+ src_data0 = (-2-2j, -1-1j, -2+2j, -1+1j,
+ 2-2j, 1-1j, 2+2j, 1+1j,
+ 0+0j)
+ src_data1 = (-3-3j, -4-4j, -3+3j, -4+4j,
+ 3-3j, 4-4j, 3+3j, 4+4j,
+ 0+0j)
+
+ exp_data = (12+0j, 8+0j, 12+0j, 8+0j,
+ 12+0j, 8+0j, 12+0j, 8+0j,
+ 0+0j)
+ src0 = gr.vector_source_c(src_data0)
+ src1 = gr.vector_source_c(src_data1)
+ op = gr.multiply_conjugate_cc ()
+ dst = gr.vector_sink_c ()
+
+ self.tb.connect(src0, (op,0))
+ self.tb.connect(src1, (op,1))
+ self.tb.connect(op, dst)
+ self.tb.run()
+ result_data = dst.data ()
+ self.assertEqual (exp_data, result_data)
+
+if __name__ == '__main__':
+ gr_unittest.run(test_multiply_conjugate, "test_multiply_conjugate.xml")
diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_short_to_char.py b/gnuradio-core/src/python/gnuradio/gr/qa_short_to_char.py
new file mode 100755
index 000000000..6a95fa01d
--- /dev/null
+++ b/gnuradio-core/src/python/gnuradio/gr/qa_short_to_char.py
@@ -0,0 +1,69 @@
+#!/usr/bin/env python
+#
+# Copyright 2011,2012 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
+import ctypes
+
+class test_short_to_char (gr_unittest.TestCase):
+
+ def setUp (self):
+ self.tb = gr.top_block ()
+
+ def tearDown (self):
+ self.tb = None
+
+ def test_001(self):
+
+ src_data = range(0, 32767, 32767/127)
+ src_data = [int(s) for s in src_data]
+ expected_result = range(0, 128)
+ src = gr.vector_source_s(src_data)
+ op = gr.short_to_char()
+ dst = gr.vector_sink_b()
+
+ self.tb.connect(src, op, dst)
+ self.tb.run()
+ result_data = list(dst.data())
+
+ self.assertEqual(expected_result, result_data)
+
+ def test_002(self):
+
+ vlen = 3
+ src_data = range(0, 32400, 32767/127)
+ src_data = [int(s) for s in src_data]
+ expected_result = range(0, 126)
+ src = gr.vector_source_s(src_data)
+ s2v = gr.stream_to_vector(gr.sizeof_short, vlen)
+ op = gr.short_to_char(vlen)
+ v2s = gr.vector_to_stream(gr.sizeof_char, vlen)
+ dst = gr.vector_sink_b()
+
+ self.tb.connect(src, s2v, op, v2s, dst)
+ self.tb.run()
+ result_data = list(dst.data())
+
+ self.assertEqual(expected_result, result_data)
+
+if __name__ == '__main__':
+ gr_unittest.run(test_short_to_char, "test_short_to_char.xml")
+
diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_short_to_float.py b/gnuradio-core/src/python/gnuradio/gr/qa_short_to_float.py
new file mode 100755
index 000000000..8f331b495
--- /dev/null
+++ b/gnuradio-core/src/python/gnuradio/gr/qa_short_to_float.py
@@ -0,0 +1,70 @@
+#!/usr/bin/env python
+#
+# Copyright 2011,2012 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
+import ctypes
+
+class test_short_to_float (gr_unittest.TestCase):
+
+ def setUp (self):
+ self.tb = gr.top_block ()
+
+ def tearDown (self):
+ self.tb = None
+
+ def test_001(self):
+
+ src_data = (0, 1, 2, 3, 4, 5, -1, -2, -3, -4, -5)
+ expected_result = [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0,
+ -1.0, -2.0, -3.0, -4.0, -5.0]
+
+ src = gr.vector_source_s(src_data)
+ op = gr.short_to_float()
+ dst = gr.vector_sink_f()
+
+ self.tb.connect(src, op, dst)
+ self.tb.run()
+ result_data = list(dst.data())
+
+ self.assertEqual(expected_result, result_data)
+
+ def test_002(self):
+
+ vlen = 3
+ src_data = (0, 1, 2, 3, 4, 5, -1, -2, -3)
+ expected_result = [0.0, 1.0, 2.0, 3.0, 4.0,
+ 5.0, -1.0, -2.0, -3.0]
+ src = gr.vector_source_s(src_data)
+ s2v = gr.stream_to_vector(gr.sizeof_short, vlen)
+ op = gr.short_to_float(vlen)
+ v2s = gr.vector_to_stream(gr.sizeof_float, vlen)
+ dst = gr.vector_sink_f()
+
+ self.tb.connect(src, s2v, op, v2s, dst)
+ self.tb.run()
+ result_data = list(dst.data())
+
+ self.assertEqual(expected_result, result_data)
+
+if __name__ == '__main__':
+ gr_unittest.run(test_short_to_float, "test_short_to_float.xml")
+