Skip to content

Commit c40c0f3

Browse files
committed
python: Py3k compat
1 parent 5e07e65 commit c40c0f3

File tree

9 files changed

+17
-17
lines changed

9 files changed

+17
-17
lines changed

gr-blocks/python/blocks/qa_socket_pdu.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def test_004 (self):
105105
# Test that the TCP server can stream PDUs <= the MTU size.
106106
port = str(random.Random().randint(0, 30000) + 10000)
107107
mtu = 10000
108-
srcdata = tuple([x % 256 for x in xrange(mtu)])
108+
srcdata = tuple(x % 256 for x in range(mtu))
109109
data = pmt.init_u8vector(srcdata.__len__(), srcdata)
110110
pdu_msg = pmt.cons(pmt.PMT_NIL, data)
111111

@@ -125,7 +125,7 @@ def test_004 (self):
125125
received = self.pdu_sink.get_message(0)
126126
received_data = pmt.cdr(received)
127127
msg_data = []
128-
for i in xrange(mtu):
128+
for i in range(mtu):
129129
msg_data.append(pmt.u8vector_ref(received_data, i))
130130
self.assertEqual(srcdata, tuple(msg_data))
131131

gr-digital/python/digital/qa_scrambler.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def additive_scramble_lfsr(mask, seed, reglen, bpb, data):
3030
out = []
3131
for d in data:
3232
scramble_word = 0
33-
for i in xrange(0,bpb):
33+
for i in range(0,bpb):
3434
scramble_word ^= l.next_bit() << i
3535
out.append(d ^ scramble_word)
3636
return tuple(out)
@@ -122,7 +122,7 @@ def test_additive_scrambler_tags_oneway(self):
122122
reset_tag3 = gr.tag_t()
123123
reset_tag3.key = pmt.string_to_symbol(reset_tag_key)
124124
reset_tag3.offset = 20
125-
src = blocks.vector_source_b(src_data * 3, False, 1, (reset_tag1, reset_tag2, reset_tag3))
125+
src = blocks.vector_source_b([s * 3 for s in src_data], False, 1, (reset_tag1, reset_tag2, reset_tag3))
126126
scrambler = digital.additive_scrambler_bb(0x8a, 0x7f, 7, 0, 8, reset_tag_key)
127127
dst = blocks.vector_sink_b()
128128
self.tb.connect(src, scrambler, dst)

gr-qtgui/apps/gr_constellation_plot

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def main():
168168
tb = my_top_block(filelist, args.start, nsamples, max_nsamples);
169169

170170
main_box = plot_constellation_form(tb, 'GNU Radio Constellation Plot', 10000.0)
171-
for n in xrange(tb._nsigs):
171+
for n in range(tb._nsigs):
172172
main_box._style_edit[n].setCurrentIndex(0)
173173
main_box.show()
174174

gr-uhd/apps/uhd_fft

+4-4
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ class uhd_fft(gr.top_block, Qt.QWidget, UHDApp):
218218
self.qtgui_waterfall_sink_x_0.enable_grid(False)
219219
self.qtgui_waterfall_sink_x_0.disable_legend()
220220
alpha = 10.**(len(self.channels)-1)
221-
for i in xrange(len(self.channels)):
221+
for i in range(len(self.channels)):
222222
self.qtgui_waterfall_sink_x_0.set_line_label(i, "Channel {0}".format(i))
223223
self.qtgui_waterfall_sink_x_0.set_color_map(i, 0)
224224
self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alpha)
@@ -240,7 +240,7 @@ class uhd_fft(gr.top_block, Qt.QWidget, UHDApp):
240240
self.qtgui_time_sink_x_0.enable_grid(False)
241241
self.qtgui_time_sink_x_0.enable_control_panel(True)
242242
self.qtgui_time_sink_x_0.disable_legend()
243-
for i in xrange(2*len(self.channels)):
243+
for i in range(2*len(self.channels)):
244244
if(i % 2 == 0):
245245
self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Channel {0}}}".format(i/2))
246246
else:
@@ -268,7 +268,7 @@ class uhd_fft(gr.top_block, Qt.QWidget, UHDApp):
268268
self.qtgui_freq_sink_x_0.set_fft_average(self.fft_average)
269269
self.qtgui_freq_sink_x_0.enable_control_panel(True)
270270
self.qtgui_freq_sink_x_0.disable_legend()
271-
for i in xrange(len(self.channels)):
271+
for i in range(len(self.channels)):
272272
self.qtgui_freq_sink_x_0.set_line_label(i, "Channel {0}".format(i))
273273
self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
274274
self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
@@ -305,7 +305,7 @@ class uhd_fft(gr.top_block, Qt.QWidget, UHDApp):
305305
self.qtgui_phase_plot.enable_grid(True)
306306
self.qtgui_phase_plot.enable_control_panel(True)
307307
self.qtgui_phase_plot.disable_legend()
308-
for i in xrange(len(self.channels) - 1):
308+
for i in range(len(self.channels) - 1):
309309
self.qtgui_phase_plot.set_line_label(i, "Phase Delta Channels {0}/{1}".format(i, i+1))
310310
self.qtgui_phase_plot.set_line_width(i, widths[i])
311311
self.qtgui_phase_plot.set_line_color(i, colors[i])

gr-uhd/apps/uhd_rx_cfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class rx_cfile_block(gr.top_block):
7979
)
8080
# Set the subdevice spec:
8181
if options.spec:
82-
for mb_idx in xrange(self._u.get_num_mboards()):
82+
for mb_idx in range(self._u.get_num_mboards()):
8383
self._u.set_subdev_spec(options.spec, mb_idx)
8484
# Set the antenna:
8585
if options.antenna is not None:
@@ -125,7 +125,7 @@ class rx_cfile_block(gr.top_block):
125125
self._u.set_time_unknown_pps(uhd.time_spec())
126126
cmd_time = self._u.get_time_now() + uhd.time_spec(COMMAND_DELAY)
127127
try:
128-
for mb_idx in xrange(self._u.get_num_mboards()):
128+
for mb_idx in range(self._u.get_num_mboards()):
129129
self._u.set_command_time(cmd_time, mb_idx)
130130
command_time_set = True
131131
except RuntimeError:
@@ -136,7 +136,7 @@ class rx_cfile_block(gr.top_block):
136136
sys.stderr.write('[UHD_RX] [ERROR] Failed to set center frequency on channel {chan}\n'.format(chan=chan))
137137
exit(1)
138138
if command_time_set:
139-
for mb_idx in xrange(self._u.get_num_mboards()):
139+
for mb_idx in range(self._u.get_num_mboards()):
140140
self._u.clear_command_time(mb_idx)
141141
print("[UHD_RX] Syncing channels...")
142142
time.sleep(COMMAND_DELAY)

gr-utils/python/utils/gr_plot_qt

+1-1
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ class gr_plot_qt(QtGui.QMainWindow):
338338

339339
tstep = 1.0 / self.sample_rate
340340
self.iq = iq
341-
self.time = [tstep*(self.position + i) for i in xrange(len(self.iq))]
341+
self.time = [tstep*(self.position + i) for i in range(len(self.iq))]
342342

343343
self.set_file_pos_box(start, end)
344344
except MemoryError:

gr-utils/python/utils/plot_fft_base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def get_data(self):
9393
self.iq_fft = self.dofft(self.iq)
9494

9595
tstep = 1.0 / self.sample_rate
96-
#self.time = scipy.array([tstep*(self.position + i) for i in xrange(len(self.iq))])
96+
#self.time = scipy.array([tstep*(self.position + i) for i in range(len(self.iq))])
9797
self.time = scipy.array([tstep*(i) for i in range(len(self.iq))])
9898

9999
self.freq = self.calc_freq(self.time, self.sample_rate)

gr-utils/python/utils/plot_psd_base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def get_data(self):
103103
# returns a zero-length array
104104
if(len(self.iq) > 0):
105105
tstep = 1.0 / self.sample_rate
106-
#self.time = scipy.array([tstep*(self.position + i) for i in xrange(len(self.iq))])
106+
#self.time = scipy.array([tstep*(self.position + i) for i in range(len(self.iq))])
107107
self.time = scipy.array([tstep*(i) for i in range(len(self.iq))])
108108

109109
self.iq_psd, self.freq = self.dopsd(self.iq)

gr-zeromq/python/zeromq/qa_zeromq_sub.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def tearDown (self):
4444

4545
def test_001 (self):
4646
vlen = 10
47-
src_data = numpy.array(range(vlen)*100, 'float32')
47+
src_data = numpy.array(range(vlen), 'float32')*100
4848
zeromq_sub_source = zeromq.sub_source(gr.sizeof_float, vlen, "tcp://127.0.0.1:5555")
4949
sink = blocks.vector_sink_f(vlen)
5050
self.tb.connect(zeromq_sub_source, sink)
@@ -60,7 +60,7 @@ def test_002 (self):
6060
vlen = 10
6161

6262
# Construct multipart source data to publish
63-
raw_data = [numpy.array(range(vlen)*100, 'float32'), numpy.array(range(vlen, 2*vlen)*100, 'float32')]
63+
raw_data = [numpy.array(range(vlen), 'float32')*100, numpy.array(range(vlen, 2*vlen), 'float32')*100]
6464
src_data = [a.tostring() for a in raw_data]
6565
zeromq_sub_source = zeromq.sub_source(gr.sizeof_float, vlen, "tcp://127.0.0.1:5555")
6666
sink = blocks.vector_sink_f(vlen)

0 commit comments

Comments
 (0)