예제 #1
0
    def test_001_ii(self):
	src_data = (1, 2, 3, 4, 5, 6)
	dst_data = (6, 15)
	src = blocks.vector_source_i(src_data)
	itg = blocks.integrate_ii(3)
	dst = blocks.vector_sink_i()
	self.tb.connect(src, itg, dst)
	self.tb.run()
	self.assertEqual(dst_data, dst.data())
예제 #2
0
 def test_float_to_int_identity(self):
     src_data = (1.0, 2.0, 3.0, 4.0, 5.0)
     expected_data = (1, 2, 3, 4, 5)
     src = blocks.vector_source_f(src_data)
     op = blocks.float_to_int()
     dst = blocks.vector_sink_i()
     self.tb.connect(src, op, dst)
     self.tb.run()
     self.assertEqual(expected_data, dst.data())
예제 #3
0
 def help_ii(self, src_data, exp_data, op):
     for s in zip(range(len(src_data)), src_data):
         src = blocks.vector_source_i(s[1])
         self.tb.connect(src, (op, s[0]))
     dst = blocks.vector_sink_i()
     self.tb.connect(op, dst)
     self.tb.run()
     result_data = dst.data()
     self.assertEqual(exp_data, result_data)
예제 #4
0
 def test_and_const_ii(self):
     src_data = (1, 2, 3, 0x5004, 0x1150)
     expected_result = (0, 2, 2, 0x5000, 0x1100)
     src = blocks.vector_source_i(src_data)
     op = blocks.and_const_ii(0x55AA)
     dst = blocks.vector_sink_i()
     self.tb.connect(src, op, dst)
     self.tb.run()
     self.assertEqual(dst.data(), expected_result)
예제 #5
0
 def help_ii (self, src_data, exp_data, op):
     for s in zip (range (len (src_data)), src_data):
         src = blocks.vector_source_i (s[1])
         self.tb.connect (src, (op, s[0]))
     dst = blocks.vector_sink_i ()
     self.tb.connect (op, dst)
     self.tb.run ()
     result_data = dst.data ()
     self.assertEqual (exp_data, result_data)
예제 #6
0
 def test_and_const_ii (self):
     src_data =        (1,  2,  3,  0x5004,   0x1150)
     expected_result = (0,  2,  2,  0x5000,   0x1100)
     src = blocks.vector_source_i(src_data)
     op = blocks.and_const_ii (0x55AA)
     dst = blocks.vector_sink_i()
     self.tb.connect(src, op, dst)
     self.tb.run()
     self.assertEqual(dst.data(), expected_result)
예제 #7
0
 def test_float_to_int_identity(self):
     src_data = (1.0, 2.0, 3.0, 4.0, 5.0)
     expected_data = (1, 2, 3, 4, 5)
     src = blocks.vector_source_f(src_data)
     op = blocks.float_to_int()
     dst = blocks.vector_sink_i()
     self.tb.connect(src, op, dst)
     self.tb.run()
     self.assertEqual(expected_data, dst.data())
예제 #8
0
    def help_const_ii(self, src_data, exp_data, op):
	src = blocks.vector_source_i(src_data)
	srcv = blocks.stream_to_vector(gr.sizeof_int, len(src_data))
	rhs = blocks.vector_to_stream(gr.sizeof_int, len(src_data))
        dst = blocks.vector_sink_i()
        self.tb.connect(src, srcv, op, rhs, dst)
        self.tb.run()
        result_data = dst.data()
        self.assertEqual(exp_data, result_data)
예제 #9
0
 def test_float_to_int_scale(self):
     src_data = (1.0, 2.0, 3.0, 4.0, 5.0)
     expected_data = (5, 10, 15, 20, 25)
     src = blocks.vector_source_f(src_data)
     op = blocks.float_to_int(1, 5)
     dst = blocks.vector_sink_i()
     self.tb.connect(src, op, dst)
     self.tb.run()
     self.assertEqual(expected_data, dst.data())
예제 #10
0
 def test_float_to_int_scale(self):
     src_data = (1.0, 2.0, 3.0, 4.0, 5.0)
     expected_data = (5, 10, 15, 20, 25)
     src = blocks.vector_source_f(src_data)
     op = blocks.float_to_int(1, 5)
     dst = blocks.vector_sink_i()
     self.tb.connect(src, op, dst)
     self.tb.run()
     self.assertEqual(expected_data, dst.data())
예제 #11
0
 def test_skip_all(self):
     skip_cnt = len(self.src_data)
     expected_result = tuple(self.src_data[skip_cnt:])
     src1 = blocks.vector_source_i(self.src_data)
     op = blocks.skiphead(gr.sizeof_int, skip_cnt)
     dst1 = blocks.vector_sink_i()
     self.tb.connect(src1, op, dst1)
     self.tb.run()
     dst_data = dst1.data()
     self.assertEqual(expected_result, dst_data)
예제 #12
0
 def test_skip_all(self):
     skip_cnt = len(self.src_data)
     expected_result = tuple(self.src_data[skip_cnt:])
     src1 = blocks.vector_source_i(self.src_data)
     op = blocks.skiphead(gr.sizeof_int, skip_cnt)
     dst1 = blocks.vector_sink_i()
     self.tb.connect(src1, op, dst1)
     self.tb.run()
     dst_data = dst1.data()
     self.assertEqual(expected_result, dst_data)
예제 #13
0
 def test_head(self):
     src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
     expected_result = (1, 2, 3, 4)
     src1 = blocks.vector_source_i(src_data)
     op = blocks.head(gr.sizeof_int, 4)
     dst1 = blocks.vector_sink_i()
     self.tb.connect(src1, op)
     self.tb.connect(op, dst1)
     self.tb.run()
     dst_data = dst1.data()
     self.assertEqual(expected_result, dst_data)
예제 #14
0
 def test_const_i(self):
     tb = self.tb
     expected_result = (1, 1, 1, 1)
     src1 = analog.sig_source_i(1e6, analog.GR_CONST_WAVE, 0, 1)
     op = blocks.head(gr.sizeof_int, 4)
     dst1 = blocks.vector_sink_i()
     tb.connect(src1, op)
     tb.connect(op, dst1)
     tb.run()
     dst_data = dst1.data()
     self.assertEqual(expected_result, dst_data)
예제 #15
0
 def test_head(self):
     src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
     expected_result = (1, 2, 3, 4)
     src1 = blocks.vector_source_i(src_data)
     op = blocks.head(gr.sizeof_int, 4)
     dst1 = blocks.vector_sink_i()
     self.tb.connect(src1, op)
     self.tb.connect(op, dst1)
     self.tb.run()
     dst_data = dst1.data()
     self.assertEqual(expected_result, dst_data)
예제 #16
0
    def help_ii(self, size, src_data, exp_data, op):
        for s in zip(range (len (src_data)), src_data):
            src = blocks.vector_source_i(s[1])
	    srcv = blocks.stream_to_vector(gr.sizeof_int, size)
	    self.tb.connect(src, srcv)
            self.tb.connect(srcv, (op, s[0]))
	rhs = blocks.vector_to_stream(gr.sizeof_int, size)
        dst = blocks.vector_sink_i()
        self.tb.connect(op, rhs, dst)
        self.tb.run()
        result_data = dst.data()
        self.assertEqual(exp_data, result_data)
예제 #17
0
    def test_002(self):

        src_data = [1,2,3,4]
        expected_result = [16777216, 33554432, 50331648, 67108864];

        src = blocks.vector_source_i(src_data)
        op = blocks.endian_swap(4)
        dst = blocks.vector_sink_i()

        self.tb.connect(src, op, dst)
        self.tb.run()
        result_data = list(dst.data())
    
        self.assertEqual(expected_result, result_data)
예제 #18
0
    def test_201b(self):
        random.seed(0)
        src_data = []
        for i in xrange(100):
            src_data.append((random.randint(-2**31, 2**31 - 1)))
        src_data = tuple(src_data)
        expected_results = src_data
        src = blocks.vector_source_i(tuple(src_data), False)
        op1 = blocks.packed_to_unpacked_ii(8, gr.GR_LSB_FIRST)
        op2 = blocks.unpacked_to_packed_ii(8, gr.GR_LSB_FIRST)
        dst = blocks.vector_sink_i()

        self.tb.connect(src, op1, op2)
        self.tb.connect(op2, dst)
        self.tb.run()

        self.assertEqual(expected_results, dst.data())
예제 #19
0
    def test_201b(self):
        random.seed(0)
        src_data = []
        for i in xrange(100):
            src_data.append((random.randint(-2**31,2**31-1)))
        src_data = tuple(src_data)
        expected_results = src_data
        src = blocks.vector_source_i(tuple(src_data), False)
        op1 = blocks.packed_to_unpacked_ii(8, gr.GR_LSB_FIRST)
        op2 = blocks.unpacked_to_packed_ii(8, gr.GR_LSB_FIRST)
        dst = blocks.vector_sink_i()

        self.tb.connect(src, op1, op2)
        self.tb.connect(op2, dst)
        self.tb.run()

        self.assertEqual(expected_results, dst.data())
예제 #20
0
    def test_002(self):

        # Test streams_to_stream (using stream_to_streams).

        n = 8
        src_len = n * 8
        src_data = tuple(range(src_len))
        expected_results = src_data

        src = blocks.vector_source_i(src_data)
        op1 = blocks.stream_to_streams(gr.sizeof_int, n)
        op2 = blocks.streams_to_stream(gr.sizeof_int, n)
        dst = blocks.vector_sink_i()

        self.tb.connect(src, op1)
        for i in range(n):
            self.tb.connect((op1, i), (op2, i))
        self.tb.connect(op2, dst)

        self.tb.run()
        self.assertEqual(expected_results, dst.data())
예제 #21
0
    def test_002(self):

        # Test streams_to_stream (using stream_to_streams).

        n = 8
        src_len = n * 8
        src_data = tuple(range(src_len))
        expected_results = src_data

        src = blocks.vector_source_i(src_data)
        op1 = blocks.stream_to_streams(gr.sizeof_int, n)
        op2 = blocks.streams_to_stream(gr.sizeof_int, n)
        dst = blocks.vector_sink_i()

        self.tb.connect(src, op1)
        for i in range(n):
            self.tb.connect((op1, i), (op2, i))
        self.tb.connect(op2, dst)

        self.tb.run()
        self.assertEqual(expected_results, dst.data())
예제 #22
0
    def test_001(self):
        """
        Test stream_to_streams.
        """
        n = 8
        src_len = n * 8
        src_data = range(src_len)

        expected_results = calc_expected_result(src_data, n)
        #print "expected results: ", expected_results
        src = blocks.vector_source_i(src_data)
        op = blocks.stream_to_streams(gr.sizeof_int, n)
        self.tb.connect(src, op)

        dsts = []
        for i in range(n):
            dst = blocks.vector_sink_i()
            self.tb.connect((op, i), (dst, 0))
            dsts.append(dst)

        self.tb.run()

        for d in range(n):
            self.assertEqual(expected_results[d], dsts[d].data())
예제 #23
0
    def test_001(self):
        """
        Test stream_to_streams.
        """
        n = 8
        src_len = n * 8
        src_data = range(src_len)

        expected_results = calc_expected_result(src_data, n)
        #print "expected results: ", expected_results
        src = blocks.vector_source_i(src_data)
        op = blocks.stream_to_streams(gr.sizeof_int, n)
        self.tb.connect(src, op)

        dsts = []
        for i in range(n):
            dst = blocks.vector_sink_i()
            self.tb.connect((op, i), (dst, 0))
            dsts.append(dst)

        self.tb.run()

        for d in range(n):
            self.assertEqual(expected_results[d], dsts[d].data())