summaryrefslogtreecommitdiff
path: root/gr-trellis/python
diff options
context:
space:
mode:
authormormj <mormjb@gmail.com>2020-10-30 10:59:50 -0400
committerMarcus Müller <marcus@hostalia.de>2020-10-30 17:52:53 +0100
commit7a0948ba85758fba1cc3858ef99bfa600dcc7416 (patch)
tree610d7f9d773a193562def6df2d4b50f1bb3b3f86 /gr-trellis/python
parent12192ee7d58de95ddca35a3e93bfc172bdb5c820 (diff)
qa: run autopep8 formatting on qa python files
find ./ -iname qa*.py | xargs autopep8 --in-place -a -a mostly formats whitespace and gets rid of trailing semicolons
Diffstat (limited to 'gr-trellis/python')
-rw-r--r--gr-trellis/python/trellis/qa_trellis.py52
1 files changed, 31 insertions, 21 deletions
diff --git a/gr-trellis/python/trellis/qa_trellis.py b/gr-trellis/python/trellis/qa_trellis.py
index fcd2f2d871..d020d1a86e 100644
--- a/gr-trellis/python/trellis/qa_trellis.py
+++ b/gr-trellis/python/trellis/qa_trellis.py
@@ -17,7 +17,7 @@ from gnuradio import gr, gr_unittest, trellis, digital, analog, blocks
fsm_args = {"awgn1o2_4": [2, 4, 4,
[0, 2, 0, 2, 1, 3, 1, 3],
[0, 3, 3, 0, 1, 2, 2, 1],
- ],
+ ],
"rep2": [2, 1, 4, [0, 0], [0, 3]],
"nothing": [2, 1, 2, [0, 0], [0, 1]],
}
@@ -26,21 +26,25 @@ constells = {2: digital.constellation_bpsk(),
4: digital.constellation_qpsk(),
}
+
class test_trellis (gr_unittest.TestCase):
- def test_001_fsm (self):
+ def test_001_fsm(self):
f = trellis.fsm(*fsm_args["awgn1o2_4"])
- self.assertEqual(fsm_args["awgn1o2_4"],[f.I(),f.S(),f.O(),f.NS(),f.OS()])
+ self.assertEqual(
+ fsm_args["awgn1o2_4"], [
+ f.I(), f.S(), f.O(), f.NS(), f.OS()])
- def test_002_fsm (self):
+ def test_002_fsm(self):
f = trellis.fsm(*fsm_args["awgn1o2_4"])
g = trellis.fsm(f)
- self.assertEqual((g.I(),g.S(),g.O(),g.NS(),g.OS()),(f.I(),f.S(),f.O(),f.NS(),f.OS()))
+ self.assertEqual((g.I(), g.S(), g.O(), g.NS(), g.OS()),
+ (f.I(), f.S(), f.O(), f.NS(), f.OS()))
- def test_003_fsm (self):
+ def test_003_fsm(self):
# FIXME: no file "awgn1o2_4.fsm"
#f = trellis.fsm("awgn1o2_4.fsm")
- #self.assertEqual(fsm_args["awgn1o2_4"],(f.I(),f.S(),f.O(),f.NS(),f.OS()))
+ # self.assertEqual(fsm_args["awgn1o2_4"],(f.I(),f.S(),f.O(),f.NS(),f.OS()))
pass
def test_004_fsm(self):
@@ -48,12 +52,12 @@ class test_trellis (gr_unittest.TestCase):
# Just checking that it initializes properly.
f = trellis.fsm(*fsm_args["rep2"])
- def test_001_interleaver (self):
+ def test_001_interleaver(self):
K = 5
- IN = [1,2,3,4,0]
- DIN = [4,0,1,2,3]
- i = trellis.interleaver(K,IN)
- self.assertEqual((K,IN,DIN),(i.K(),i.INTER(),i.DEINTER()))
+ IN = [1, 2, 3, 4, 0]
+ DIN = [4, 0, 1, 2, 3]
+ i = trellis.interleaver(K, IN)
+ self.assertEqual((K, IN, DIN), (i.K(), i.INTER(), i.DEINTER()))
def test_001_viterbi(self):
"""
@@ -74,6 +78,7 @@ class trellis_tb(gr.top_block):
"""
A simple top block for use testing gr-trellis.
"""
+
def __init__(self, constellation, f, N0=0.25, seed=-666):
"""
constellation - a constellation object used for modulation.
@@ -82,10 +87,12 @@ class trellis_tb(gr.top_block):
seed - random seed
"""
super(trellis_tb, self).__init__()
- # packet size in bits (make it multiple of 16 so it can be packed in a short)
- packet_size = 1024*16
+ # packet size in bits (make it multiple of 16 so it can be packed in a
+ # short)
+ packet_size = 1024 * 16
+ # bits per FSM input symbol
# bits per FSM input symbol
- bitspersymbol = int(round(math.log(f.I()) / math.log(2))) # bits per FSM input symbol
+ bitspersymbol = int(round(math.log(f.I()) / math.log(2)))
# packet size in trellis steps
K = packet_size // bitspersymbol
@@ -101,11 +108,14 @@ class trellis_tb(gr.top_block):
# CHANNEL
add = blocks.add_cc()
- noise = analog.noise_source_c(analog.GR_GAUSSIAN,math.sqrt(N0 / 2),seed)
+ noise = analog.noise_source_c(
+ analog.GR_GAUSSIAN, math.sqrt(
+ N0 / 2), seed)
# RX
# data preprocessing to generate metrics for Viterbi
- metrics = trellis.constellation_metrics_cf(constellation.base(), digital.TRELLIS_EUCLIDEAN)
+ metrics = trellis.constellation_metrics_cf(
+ constellation.base(), digital.TRELLIS_EUCLIDEAN)
# Put -1 if the Initial/Final states are not set.
va = trellis.viterbi_s(f, K, 0, -1)
# pack FSM input symbols to shorts
@@ -113,10 +123,10 @@ class trellis_tb(gr.top_block):
# check the output
self.dst = blocks.check_lfsr_32k_s()
- self.connect (src, src_head, s2fsmi, enc, mod)
- self.connect (mod, (add, 0))
- self.connect (noise, (add, 1))
- self.connect (add, metrics, va, fsmi2s, self.dst)
+ self.connect(src, src_head, s2fsmi, enc, mod)
+ self.connect(mod, (add, 0))
+ self.connect(noise, (add, 1))
+ self.connect(add, metrics, va, fsmi2s, self.dst)
if __name__ == '__main__':