diff options
author | Andrej Rode <mail@andrejro.de> | 2018-06-23 23:41:42 +0200 |
---|---|---|
committer | Andrej Rode <mail@andrejro.de> | 2018-06-24 00:03:35 +0200 |
commit | 167a6152bad060fc53dd29e0fa79ef83eff1be5b (patch) | |
tree | a01049672d9d7d1bf3d295ed96698a323941f8e8 /gr-digital/python/digital/utils | |
parent | 3c8e6008b092287246234001db7cf1a4038300da (diff) | |
parent | fcd002b6ac82e1e0c1224e24506410ff0833e1aa (diff) |
Merge branch 'python3_fix' into next
Manual merge conflict resolution has been applied to following
conflicts:
* Typos:
* gnuradio-runtime/python/gnuradio/ctrlport/GrDataPlotter.py
* gr-blocks/python/blocks/qa_wavfile.py
* gr-filter/examples/gr_filtdes_api.py
* grc/blocks/parameter.xml
* gr-uhd/python/uhd/__init__.py
* ValueError -> RuntimeError:
* gr-blocks/python/blocks/qa_hier_block2.py
* relative Imports & other Py3k:
* gr-digital/python/digital/psk_constellations.py
* gr-digital/python/digital/qam_constellations.py
* gr-digital/python/digital/test_soft_decisions.py
* gr-digital/python/digital/gfsk.py
* SequenceCompleter:
* gr-utils/python/modtool/modtool_add.py
* gr-utils/python/modtool/modtool_rename.py
* gr-utils/python/modtool/modtool_rm.py
* Updated API on next:
* gr-blocks/grc/blocks_file_source.xml
* gr-blocks/python/blocks/qa_file_source_sink.py
* gr-qtgui/grc/qtgui_time_sink_x.xml
* GRC Py3k Updates:
* grc/core/Block.py
* grc/core/Constants.py
* grc/core/Platform.py
* grc/core/utils/odict.py
* grc/gui/Actions.py
* grc/gui/Block.py
* grc/gui/Executor.py
* grc/gui/Port.py
Diffstat (limited to 'gr-digital/python/digital/utils')
-rw-r--r-- | gr-digital/python/digital/utils/alignment.py | 12 | ||||
-rw-r--r-- | gr-digital/python/digital/utils/gray_code.py | 16 | ||||
-rw-r--r-- | gr-digital/python/digital/utils/mod_codes.py | 1 | ||||
-rw-r--r-- | gr-digital/python/digital/utils/tagged_streams.py | 23 |
4 files changed, 30 insertions, 22 deletions
diff --git a/gr-digital/python/digital/utils/alignment.py b/gr-digital/python/digital/utils/alignment.py index f3ad3781e2..e9292a4bcc 100644 --- a/gr-digital/python/digital/utils/alignment.py +++ b/gr-digital/python/digital/utils/alignment.py @@ -41,6 +41,8 @@ This module contains functions for aligning sequences. (100, -20) """ +from __future__ import division +from __future__ import unicode_literals import random @@ -63,7 +65,7 @@ def compare_sequences(d1, d2, offset, sample_indices=None): """ max_index = min(len(d1), len(d2)+offset) if sample_indices is None: - sample_indices = range(0, max_index) + sample_indices = list(range(0, max_index)) correct = 0 total = 0 for i in sample_indices: @@ -84,8 +86,8 @@ def random_sample(size, num_samples=def_num_samples, seed=None): if num_samples > size: indices = set(range(0, size)) else: - if num_samples > size/2: - num_samples = num_samples/2 + if num_samples > size / 2: + num_samples = num_samples / 2 indices = set([]) while len(indices) < num_samples: index = rndm.randint(0, size-1) @@ -119,8 +121,8 @@ def align_sequences(d1, d2, best_offset = None best_compared = None best_correct = None - pos_range = range(0, min(len(d1), max_offset)) - neg_range = range(-1, -min(len(d2), max_offset), -1) + pos_range = list(range(0, min(len(d1), max_offset))) + neg_range = list(range(-1, -min(len(d2), max_offset), -1)) # Interleave the positive and negative offsets. int_range = [item for items in zip(pos_range, neg_range) for item in items] for offset in int_range: diff --git a/gr-digital/python/digital/utils/gray_code.py b/gr-digital/python/digital/utils/gray_code.py index 926a1ded10..ad88274087 100644 --- a/gr-digital/python/digital/utils/gray_code.py +++ b/gr-digital/python/digital/utils/gray_code.py @@ -1,25 +1,27 @@ #!/usr/bin/env python # # Copyright 2011 Free Software Foundation, Inc. -# +# # This file is part of GNU Radio -# +# # GNU Radio 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. -# +# # GNU Radio 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 GNU Radio; see the file COPYING. If not, write to # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. -# +# +from __future__ import division +from __future__ import unicode_literals class GrayCodeGenerator(object): """ Generates and caches gray codes. @@ -41,7 +43,7 @@ class GrayCodeGenerator(object): if len(self.gcs) < length: self.generate_new_gray_code(length) return self.gcs[:length] - + def generate_new_gray_code(self, length): """ Generates new gray code and places into cache. @@ -49,7 +51,7 @@ class GrayCodeGenerator(object): while len(self.gcs) < length: if self.i == self.lp2: # if i is a power of two then gray number is of form 1100000... - result = self.i + self.i/2 + result = self.i + self.i // 2 else: # if not we take advantage of the symmetry of all but the last bit # around a power of two. diff --git a/gr-digital/python/digital/utils/mod_codes.py b/gr-digital/python/digital/utils/mod_codes.py index f55fe41b8b..586ab1999a 100644 --- a/gr-digital/python/digital/utils/mod_codes.py +++ b/gr-digital/python/digital/utils/mod_codes.py @@ -21,6 +21,7 @@ # # Constants used to represent what coding to use. +from __future__ import unicode_literals GRAY_CODE = 'gray' SET_PARTITION_CODE = 'set-partition' NO_CODE = 'none' diff --git a/gr-digital/python/digital/utils/tagged_streams.py b/gr-digital/python/digital/utils/tagged_streams.py index 4b393bfc20..68267a293e 100644 --- a/gr-digital/python/digital/utils/tagged_streams.py +++ b/gr-digital/python/digital/utils/tagged_streams.py @@ -1,27 +1,30 @@ #!/usr/bin/env python # # Copyright 2013 Free Software Foundation, Inc. -# +# # This file is part of GNU Radio -# +# # GNU Radio 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. -# +# # GNU Radio 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 GNU Radio; see the file COPYING. If not, write to # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. -# +# # DEPRECATED -- Marked for removal in 3.8 +from __future__ import print_function +from __future__ import division +from __future__ import unicode_literals from gnuradio import gr import pmt @@ -30,9 +33,9 @@ def make_lengthtags(lengths, offsets, tagname='length', vlen=1): assert(len(offsets) == len(lengths)) for offset, length in zip(offsets, lengths): tag = gr.tag_t() - tag.offset = offset/vlen + tag.offset = offset / vlen tag.key = pmt.string_to_symbol(tagname) - tag.value = pmt.from_long(length/vlen) + tag.value = pmt.from_long(length / vlen) tags.append(tag) return tags @@ -75,7 +78,7 @@ def count_bursts(data, tags, lengthtagname, vlen=1): if pos in lengths: if in_packet: print("Got tag at pos {0} current packet_pos is {1}".format(pos, packet_pos)) - raise StandardError("Received packet tag while in packet.") + raise Exception("Received packet tag while in packet.") packet_pos = -1 packet_length = lengths[pos] in_packet = True @@ -127,9 +130,9 @@ def packets_to_vectors(packets, lengthtagname, vlen=1): for packet in packets: data.extend(packet) tag = gr.tag_t() - tag.offset = offset/vlen + tag.offset = offset // vlen tag.key = pmt.string_to_symbol(lengthtagname) - tag.value = pmt.from_long(len(packet)/vlen) + tag.value = pmt.from_long(len(packet) // vlen) tags.append(tag) offset = offset + len(packet) return data, tags |