diff options
author | Johannes Demel <ufcsy@student.kit.edu> | 2015-07-20 11:35:35 +0200 |
---|---|---|
committer | Johannes Demel <ufcsy@student.kit.edu> | 2015-07-20 11:35:35 +0200 |
commit | ac11b4db0094b865eac75be5b5f61e4856466cee (patch) | |
tree | 1fb4994125e17648cf69c3c91c6991f6e6a9a54e /gr-fec/python | |
parent | b781fe746fb258af6ebc49499a76369665272f9d (diff) |
fec: code clean-up for block 'ber_bf'.
Diffstat (limited to 'gr-fec/python')
-rw-r--r-- | gr-fec/python/fec/qa_ber_bf.py | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/gr-fec/python/fec/qa_ber_bf.py b/gr-fec/python/fec/qa_ber_bf.py index 3e7919e054..5d1734de0c 100644 --- a/gr-fec/python/fec/qa_ber_bf.py +++ b/gr-fec/python/fec/qa_ber_bf.py @@ -54,7 +54,7 @@ class test_ber_bf(gr_unittest.TestCase): self.tb.run() data = dst.data() - expected_result = [numpy.log10(1.0 / (8.0 * N)), ] + expected_result = self.log_ber(1., N) # [numpy.log10(1.0 / (8.0 * N)), ] self.assertFloatTuplesAlmostEqual(expected_result, data, 5) @@ -79,7 +79,7 @@ class test_ber_bf(gr_unittest.TestCase): self.tb.run() data = dst.data() - expected_result = [numpy.log10(1.0 / (8.0 * N)), ] + expected_result = self.log_ber(1., N) self.assertFloatTuplesAlmostEqual(expected_result, data, 5) @@ -104,7 +104,7 @@ class test_ber_bf(gr_unittest.TestCase): self.tb.run() data = dst.data() - expected_result = [numpy.log10(8.0 / (8.0 * N)), ] + expected_result = self.log_ber(8., N) self.assertFloatTuplesAlmostEqual(expected_result, data, 5) @@ -137,6 +137,36 @@ class test_ber_bf(gr_unittest.TestCase): self.assertFloatTuplesAlmostEqual(expected_result, data, 5) + def test_004(self): + # Cause 16 consecutive bit errors out of 8*N bits + # make sure bytes are only read once. + # using streaming mode + + mode = False + N = 10000 + data0 = numpy.random.randint(0, 256, N).tolist() + data1 = copy.deepcopy(data0) + data1[0] ^= 0xFF + data1[1] ^= 0xFF + + src0 = blocks.vector_source_b(data0) + src1 = blocks.vector_source_b(data1) + op = fec.ber_bf(mode) + dst = blocks.vector_sink_f() + + self.tb.connect(src0, (op, 0)) + self.tb.connect(src1, (op, 1)) + self.tb.connect(op, dst) + self.tb.run() + + data = dst.data() + expected_result = self.log_ber(16, N) + + self.assertFloatTuplesAlmostEqual(expected_result, data, 5) + + def log_ber(self, n_errors, N): + return numpy.log10(1. * n_errors / (8.0 * N)), + if __name__ == '__main__': gr_unittest.run(test_ber_bf, "test_ber_bf.xml") |