From 3de0c77ed91e417c0b54972a78ffbad62f4bbb87 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Tue, 26 Jun 2012 19:43:01 -0700 Subject: blocks: added gr::blocks::float_to_int --- gr-blocks/python/qa_type_conversions.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'gr-blocks/python') diff --git a/gr-blocks/python/qa_type_conversions.py b/gr-blocks/python/qa_type_conversions.py index a97203566..354cf9392 100755 --- a/gr-blocks/python/qa_type_conversions.py +++ b/gr-blocks/python/qa_type_conversions.py @@ -241,6 +241,26 @@ class test_type_conversions(gr_unittest.TestCase): self.tb.run() self.assertEqual(expected_data, dst.data()) + def test_int_to_float_identity(self): + src_data = (1, 2, 3, 4, 5) + expected_data = (1.0, 2.0, 3.0, 4.0, 5.0) + src = gr.vector_source_i(src_data) + op = blocks_swig.int_to_float() + dst = gr.vector_sink_f() + self.tb.connect(src, op, dst) + self.tb.run() + self.assertFloatTuplesAlmostEqual(expected_data, dst.data()) + + def test_int_to_float_scale(self): + src_data = (1, 2, 3, 4, 5) + expected_data = (0.2, 0.4, 0.6, 0.8, 1.0) + src = gr.vector_source_i(src_data) + op = blocks_swig.int_to_float(1, 5) + dst = gr.vector_sink_f() + self.tb.connect(src, op, dst) + self.tb.run() + self.assertFloatTuplesAlmostEqual(expected_data, dst.data()) + if __name__ == '__main__': gr_unittest.run(test_type_conversions, "test_type_conversions.xml") -- cgit