diff options
author | Douglas Anderson <danderson@ntia.doc.gov> | 2017-02-12 15:52:19 -0800 |
---|---|---|
committer | Johnathan Corgan <johnathan@corganlabs.com> | 2017-02-26 18:21:22 -0800 |
commit | 9e625c4821f4c63421b3d3747c0c4f358fef6c5f (patch) | |
tree | 41dedbe053417be7314cdce15d64fbbb89db4d8d /gr-digital/python/digital/utils/alignment.py | |
parent | e5aabcc6a4a9335f3ef8abf5f89104b626e9364d (diff) |
python3: update non-GRC components to use python2 or python3
Diffstat (limited to 'gr-digital/python/digital/utils/alignment.py')
-rw-r--r-- | gr-digital/python/digital/utils/alignment.py | 12 |
1 files changed, 7 insertions, 5 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: |