3 # Copyright 2006 Free Software Foundation, Inc.
5 # This file is part of GNU Radio
7 # GNU Radio is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3, or (at your option)
12 # GNU Radio is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Radio; see the file COPYING. If not, write to
19 # the Free Software Foundation, Inc., 51 Franklin Street,
20 # Boston, MA 02110-1301, USA.
23 from gnuradio import gr, gr_unittest
25 class my_add2_dd(gr.feval_dd):
29 class my_add2_ll(gr.feval_ll):
33 class my_add2_cc(gr.feval_cc):
38 class test_feval(gr_unittest.TestCase):
42 src_data = (0.0, 1.0, 2.0, 3.0, 4.0)
43 expected_result = (2.0, 3.0, 4.0, 5.0, 6.0)
44 # this is all in python...
45 actual_result = tuple([f.eval(x) for x in src_data])
46 self.assertEqual(expected_result, actual_result)
50 src_data = (0.0, 1.0, 2.0, 3.0, 4.0)
51 expected_result = (2.0, 3.0, 4.0, 5.0, 6.0)
52 # this is python -> C++ -> python and back again...
53 actual_result = tuple([gr.feval_dd_example(f, x) for x in src_data])
54 self.assertEqual(expected_result, actual_result)
59 src_data = (0, 1, 2, 3, 4)
60 expected_result = (2, 3, 4, 5, 6)
61 # this is all in python...
62 actual_result = tuple([f.eval(x) for x in src_data])
63 self.assertEqual(expected_result, actual_result)
67 src_data = (0, 1, 2, 3, 4)
68 expected_result = (2, 3, 4, 5, 6)
69 # this is python -> C++ -> python and back again...
70 actual_result = tuple([gr.feval_ll_example(f, x) for x in src_data])
71 self.assertEqual(expected_result, actual_result)
76 src_data = (0+1j, 2+3j, 4+5j, 6+7j)
77 expected_result = (2-1j, 4+1j, 6+3j, 8+5j)
78 # this is all in python...
79 actual_result = tuple([f.eval(x) for x in src_data])
80 self.assertEqual(expected_result, actual_result)
84 src_data = (0+1j, 2+3j, 4+5j, 6+7j)
85 expected_result = (2-1j, 4+1j, 6+3j, 8+5j)
86 # this is python -> C++ -> python and back again...
87 actual_result = tuple([gr.feval_cc_example(f, x) for x in src_data])
88 self.assertEqual(expected_result, actual_result)
91 if __name__ == '__main__':