Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- # Copyright 2014 <+YOU OR YOUR COMPANY+>.
- #
- # This 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.
- #
- # This software 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 this software; 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
- from gnuradio import blocks
- import alamouti_swig as alamouti
- import sys,random
- class qa_al_enc (gr_unittest.TestCase):
- def setUp (self):
- self.tb = gr.top_block ()
- def tearDown (self):
- self.tb = None
- def test_001_t (self):
- # set up fg
- n=2048
- lst1 = [random.randint(1, 10) for x in range (n)]
- lst2= [random.randint(1, 10) for x in range (n)]
- numb=list()
- for i in range (n):
- numb.append(complex(lst1[i],lst2[i]))
- def negconj(x):
- return -(x.conjugate())
- Tx1=list()
- Tx2=list()
- i=0
- while i<n:
- Tx1.append(numb[i])
- Tx1.append(negconj(numb[i+1]))
- Tx2.append(numb[i+1])
- Tx2.append(numb[i].conjugate())
- i+=2
- expected_result1 = Tx1
- expected_result2 = Tx2
- src = blocks.vector_source_c(numb)
- opr = alamouti.al_enc(n)
- dst1 = blocks.vector_sink_c()
- dst2 = blocks.vector_sink_c()
- self.tb.connect(src,opr)
- self.tb.connect((opr,0),dst1)
- self.tb.connect((opr,1),dst2)
- self.tb.run ()
- # check data
- #print "numb"
- #print numb
- #print "dst"
- #print dst1.data()
- #print dst2.data()
- result_data1 = dst1.data()
- result_data2 = dst2.data()
- self.assertFloatTuplesAlmostEqual(expected_result1, result_data1)
- self.assertFloatTuplesAlmostEqual(expected_result2, result_data2)
- if __name__ == '__main__':
- gr_unittest.run(qa_al_enc, "qa_al_enc.xml")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement