diff options
author | Martin Braun <martin@gnuradio.org> | 2020-12-18 11:42:24 +0100 |
---|---|---|
committer | Marcus Müller <marcus@hostalia.de> | 2020-12-19 01:01:11 +0100 |
commit | 7e112bfd12731073ac2970aa97f789abeb6f7e88 (patch) | |
tree | bfb884f40111d4ddb4735d1c2f15d3dcb672f2f2 /gr-digital/python/digital | |
parent | 76f05e7585e23541eaab0890b8dc90296903795b (diff) |
digital: ofdm: Fix whitespace in OFDM chanest block
Both the C++ and Python files have really weird whitespace issues,
making them hard to read. This makes the whitespace usage for consistent
with usual formatting, and fixes some Doxygen issues.
Signed-off-by: Martin Braun <martin@gnuradio.org>
Diffstat (limited to 'gr-digital/python/digital')
-rw-r--r-- | gr-digital/python/digital/bindings/ofdm_chanest_vcvc_python.cc | 4 | ||||
-rw-r--r-- | gr-digital/python/digital/qa_ofdm_chanest_vcvc.py | 48 |
2 files changed, 17 insertions, 35 deletions
diff --git a/gr-digital/python/digital/bindings/ofdm_chanest_vcvc_python.cc b/gr-digital/python/digital/bindings/ofdm_chanest_vcvc_python.cc index bf77ebd0ae..009d6b2e66 100644 --- a/gr-digital/python/digital/bindings/ofdm_chanest_vcvc_python.cc +++ b/gr-digital/python/digital/bindings/ofdm_chanest_vcvc_python.cc @@ -13,8 +13,8 @@ /* If manual edits are made, the following tags should be modified accordingly. */ /* BINDTOOL_GEN_AUTOMATIC(0) */ /* BINDTOOL_USE_PYGCCXML(0) */ -/* BINDTOOL_HEADER_FILE(ofdm_chanest_vcvc.h) */ -/* BINDTOOL_HEADER_FILE_HASH(82caca03752b79f24d3d33c573cf570b) */ +/* BINDTOOL_HEADER_FILE(ofdm_chanest_vcvc.h) */ +/* BINDTOOL_HEADER_FILE_HASH(a4f2516ae6c6cc38e9cf81673542ef76) */ /***********************************************************************************/ #include <pybind11/complex.h> diff --git a/gr-digital/python/digital/qa_ofdm_chanest_vcvc.py b/gr-digital/python/digital/qa_ofdm_chanest_vcvc.py index c69d2af984..f51aca8fc7 100644 --- a/gr-digital/python/digital/qa_ofdm_chanest_vcvc.py +++ b/gr-digital/python/digital/qa_ofdm_chanest_vcvc.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2012-2014 Free Software Foundation, Inc. # # This file is part of GNU Radio @@ -7,9 +7,6 @@ # # - -import sys -import numpy import random import numpy @@ -21,9 +18,9 @@ def shift_tuple(vec, N): """ Shifts a vector by N elements. Fills up with zeros. """ if N > 0: return (0,) * N + tuple(vec[0:-N]) - else: - N = -N - return tuple(vec[N:]) + (0,) * N + # else: + N = -N + return tuple(vec[N:]) + (0,) * N def rand_range(min_val, max_val): @@ -103,7 +100,7 @@ class qa_ofdm_chanest_vcvc (gr_unittest.TestCase): for tag in tags: if pmt.symbol_to_string(tag.key) == 'ofdm_sync_carr_offset': carr_offset_hat = pmt.to_long(tag.value) - self.assertEqual(pmt.to_long(tag.value), carr_offset) + self.assertEqual(carr_offset_hat, carr_offset) def test_003_channel_no_carroffset(self): """ Add a channel, check if it's correctly estimated """ @@ -215,12 +212,7 @@ class qa_ofdm_chanest_vcvc (gr_unittest.TestCase): self.assertEqual(chan_est, chanest_exp) self.assertEqual( sink.data(), - list( - numpy.multiply( - shift_tuple( - data_symbol, - carr_offset), - channel))) + list(numpy.multiply(shift_tuple(data_symbol, carr_offset), channel))) def test_999_all_at_once(self): """docstring for test_999_all_at_once""" @@ -306,15 +298,9 @@ class qa_ofdm_chanest_vcvc (gr_unittest.TestCase): shift_tuple(sync_sym2, carr_offset) + \ shift_tuple(data_sym, carr_offset) channel = [ - rand_range( - min_chan_ampl, - max_chan_ampl) * - numpy.exp( - 1j * - rand_range( - 0, - 2 * - numpy.pi)) for x in range(fft_len)] + rand_range(min_chan_ampl, max_chan_ampl) * + numpy.exp(1j * rand_range(0, 2 * numpy.pi)) + for x in range(fft_len)] src = blocks.vector_source_c(tx_data, False, fft_len) chan = blocks.multiply_const_vcc(channel) noise = analog.noise_source_c(analog.GR_GAUSSIAN, wgn_amplitude) @@ -323,8 +309,8 @@ class qa_ofdm_chanest_vcvc (gr_unittest.TestCase): sink = blocks.vector_sink_c(fft_len) top_block.connect(src, chan, (add, 0), chanest, sink) top_block.connect( - noise, blocks.stream_to_vector( - gr.sizeof_gr_complex, fft_len), (add, 1)) + noise, + blocks.stream_to_vector(gr.sizeof_gr_complex, fft_len), (add, 1)) top_block.run() channel_est = None carr_offset_hat = 0 @@ -341,15 +327,11 @@ class qa_ofdm_chanest_vcvc (gr_unittest.TestCase): shifted_carrier_mask = shift_tuple(carrier_mask, carr_offset) for i in range(fft_len): if shifted_carrier_mask[i] and channel_est[i]: - self.assertAlmostEqual( - channel[i], channel_est[i], places=0) + self.assertAlmostEqual(channel[i], channel_est[i], places=0) rx_sym_est[i] = (sink.data()[i] / channel_est[i]).real - return ( - carr_offset, list( - shift_tuple( - rx_sym_est, -carr_offset_hat))) + return carr_offset, list(shift_tuple(rx_sym_est, -carr_offset_hat)) bit_errors = 0 - for k in range(n_iter): + for _ in range(n_iter): sync_sym = [(random.randint(0, 1) * 2 - 1) * syncsym_mask[i] for i in range(fft_len)] ref_sym = [(random.randint(0, 1) * 2 - 1) * carrier_mask[i] @@ -357,7 +339,7 @@ class qa_ofdm_chanest_vcvc (gr_unittest.TestCase): data_sym = [(random.randint(0, 1) * 2 - 1) * carrier_mask[i] for i in range(fft_len)] data_sym[26] = 1 - (carr_offset, rx_sym) = run_flow_graph(sync_sym, ref_sym, data_sym) + (_, rx_sym) = run_flow_graph(sync_sym, ref_sym, data_sym) rx_sym_est = [0, ] * fft_len for i in range(fft_len): if carrier_mask[i] == 0: |