Skip to content

Commit b1db413

Browse files
committed
Python 3.x fixes: xrange -> range
Replaced all xranges with ranges, as Python 3 doesn't use xrange any more.
1 parent c88bf47 commit b1db413

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

commpy/channelcoding/turbo.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ def _backward_recursion(trellis, msg_length, noise_variance,
8787
output_table = trellis.output_table
8888

8989
# Backward recursion
90-
for reverse_time_index in reversed(xrange(1, msg_length+1)):
90+
for reverse_time_index in reversed(range(1, msg_length+1)):
9191

92-
for current_state in xrange(number_states):
93-
for current_input in xrange(number_inputs):
92+
for current_state in range(number_states):
93+
for current_input in range(number_inputs):
9494
next_state = next_state_table[current_state, current_input]
9595
code_symbol = output_table[current_state, current_input]
9696
codeword_array = dec2bitarray(code_symbol, n)
@@ -124,11 +124,11 @@ def _forward_recursion_decoding(trellis, mode, msg_length, noise_variance,
124124
output_table = trellis.output_table
125125

126126
# Forward Recursion
127-
for time_index in xrange(1, msg_length+1):
127+
for time_index in range(1, msg_length+1):
128128

129129
app[:] = 0
130-
for current_state in xrange(number_states):
131-
for current_input in xrange(number_inputs):
130+
for current_state in range(number_states):
131+
for current_input in range(number_inputs):
132132
next_state = next_state_table[current_state, current_input]
133133
branch_prob = branch_probs[current_input, current_state, time_index-1]
134134
# Compute the forward state metrics
@@ -308,7 +308,7 @@ def turbo_decode(sys_symbols, non_sys_symbols_1, non_sys_symbols_2, trellis,
308308
# Interleave systematic symbols for input to second decoder
309309
sys_symbols_i = interleaver.interlv(sys_symbols)
310310

311-
for iteration_count in xrange(number_iterations):
311+
for iteration_count in range(number_iterations):
312312

313313
# MAP Decoder - 1
314314
[L_ext_1, decoded_bits] = map_decode(sys_symbols, non_sys_symbols_1,

commpy/channels.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def awgn(input_signal, snr_dB, rate=1.0):
162162
# g_var = 0.5
163163
# gain_process = zeros([len(path_gains), block_length], dtype=complex)
164164
# delay_process = zeros([n2+1-n1, len(path_delays)])
165-
# for k in xrange(len(path_gains)):
165+
# for k in range(len(path_gains)):
166166
# g = (g_var**0.5) * (randn(channel_length) + 1j*randn(channel_length))
167167
# g_filt = convolve(g, h_jakes, mode='same')
168168
# g_filt_interp = resample(g_filt, block_length)

commpy/modulation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def demodulate(self, input_symbols, demod_type, noise_var = 0):
7272
"""
7373
if demod_type == 'hard':
7474
index_list = map(lambda i: argmin(abs(input_symbols[i] - self.constellation)), \
75-
xrange(0, len(input_symbols)))
75+
range(0, len(input_symbols)))
7676
demod_bits = hstack(map(lambda i: dec2bitarray(i, self.num_bits_symbol),
7777
index_list))
7878
elif demod_type == 'soft':
@@ -147,7 +147,7 @@ def ofdm_tx(x, nfft, nsc, cp_length):
147147
cp_length = float(cp_length)
148148
ofdm_tx_signal = array([])
149149

150-
for i in xrange(0, shape(x)[1]):
150+
for i in range(0, shape(x)[1]):
151151
symbols = x[:,i]
152152
ofdm_sym_freq = zeros(nfft, dtype=complex)
153153
ofdm_sym_freq[1:(nsc/2)+1] = symbols[nsc/2:]
@@ -164,7 +164,7 @@ def ofdm_rx(y, nfft, nsc, cp_length):
164164
num_ofdm_symbols = int(len(y)/(nfft + cp_length))
165165
x_hat = zeros([nsc, num_ofdm_symbols], dtype=complex)
166166

167-
for i in xrange(0, num_ofdm_symbols):
167+
for i in range(0, num_ofdm_symbols):
168168
ofdm_symbol = y[i*nfft + (i+1)*cp_length:(i+1)*(nfft + cp_length)]
169169
symbols_freq = fft(ofdm_symbol)
170170
x_hat[:,i] = concatenate((symbols_freq[-nsc/2:], symbols_freq[1:(nsc/2)+1]))

commpy/sequences.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ def pnsequence(pn_order, pn_seed, pn_mask, seq_length):
4949
pnseq = zeros(seq_length)
5050

5151
# Initialize shift register with the pn_seed
52-
sr = array(map(lambda i: int(pn_seed[i]), xrange(0, len(pn_seed))))
52+
sr = array(map(lambda i: int(pn_seed[i]), range(0, len(pn_seed))))
5353

54-
for i in xrange(seq_length):
54+
for i in range(seq_length):
5555
new_bit = 0
56-
for j in xrange(pn_order):
56+
for j in range(pn_order):
5757
if int(pn_mask[j]) == 1:
5858
new_bit = new_bit ^ sr[j]
5959
pnseq[i] = sr[pn_order-1]

doc/sphinxext/plot_directive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ def makefig(code, code_path, output_dir, output_base, config):
520520
all_exists = True
521521
for i, code_piece in enumerate(code_pieces):
522522
images = []
523-
for j in xrange(1000):
523+
for j in range(1000):
524524
img = ImageFile('%s_%02d_%02d' % (output_base, i, j), output_dir)
525525
for format, dpi in formats:
526526
if out_of_date(code_path, img.filename(format)):

0 commit comments

Comments
 (0)