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 /gnuradio-runtime/examples | |
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 'gnuradio-runtime/examples')
15 files changed, 63 insertions, 39 deletions
diff --git a/gnuradio-runtime/examples/mp-sched/affinity_set.py b/gnuradio-runtime/examples/mp-sched/affinity_set.py index e6637b44bf..a253c8081c 100755..100644 --- a/gnuradio-runtime/examples/mp-sched/affinity_set.py +++ b/gnuradio-runtime/examples/mp-sched/affinity_set.py @@ -4,6 +4,8 @@ # Title: Affinity Set Test ################################################## +from __future__ import print_function +from __future__ import unicode_literals from gnuradio import eng_notation from gnuradio import gr from gnuradio import blocks @@ -57,7 +59,7 @@ if __name__ == '__main__': tb.start() while(1): - ret = raw_input('Enter a new Core # or Press Enter to quit: ') + ret = input('Enter a new Core # or Press Enter to quit: ') if(len(ret) == 0): tb.stop() sys.exit(0) @@ -67,6 +69,6 @@ if __name__ == '__main__': try: n = int(ret) except ValueError: - print "Invalid number" + print("Invalid number") else: tb.filter_filt_0.set_processor_affinity([n,]) diff --git a/gnuradio-runtime/examples/mp-sched/plot_flops.py b/gnuradio-runtime/examples/mp-sched/plot_flops.py index 9bd2ff12bb..e71770aee3 100755..100644 --- a/gnuradio-runtime/examples/mp-sched/plot_flops.py +++ b/gnuradio-runtime/examples/mp-sched/plot_flops.py @@ -23,6 +23,7 @@ Reads output from run_synthetic.py and runs gnuplot showing GFLOPS as f(npipes, nstages) """ +from __future__ import unicode_literals import re import sys diff --git a/gnuradio-runtime/examples/mp-sched/run_synthetic.py b/gnuradio-runtime/examples/mp-sched/run_synthetic.py index 802fb9fd34..684f95bd87 100755..100644 --- a/gnuradio-runtime/examples/mp-sched/run_synthetic.py +++ b/gnuradio-runtime/examples/mp-sched/run_synthetic.py @@ -22,6 +22,8 @@ """ Run synthetic.py for npipes in [1,16], nstages in [1,16] """ +from __future__ import division +from __future__ import unicode_literals import re import sys @@ -49,7 +51,7 @@ def write_shell_script(f, data_filename, description, ncores, gflops, max_pipes_ # We'd like each run of synthetic to take ~10 seconds desired_time_per_run = 10 est_gflops_avail = min(nstages * npipes, ncores) * gflops - nsamples = (est_gflops_avail * desired_time_per_run)/(512.0 * nstages * npipes) + nsamples = (est_gflops_avail * desired_time_per_run) / (512.0 * nstages * npipes) nsamples = int(nsamples * 1e9) cmd = "./synthetic.py -m -s %d -p %d -N %d\n" % (nstages, npipes, nsamples) diff --git a/gnuradio-runtime/examples/mp-sched/synthetic.py b/gnuradio-runtime/examples/mp-sched/synthetic.py index 16e39734ae..0f0b7b37cc 100755..100644 --- a/gnuradio-runtime/examples/mp-sched/synthetic.py +++ b/gnuradio-runtime/examples/mp-sched/synthetic.py @@ -19,6 +19,9 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # +from __future__ import print_function +from __future__ import division +from __future__ import unicode_literals from gnuradio import gr, eng_notation from gnuradio import blocks, filter from gnuradio.eng_arg import eng_float, intx @@ -35,7 +38,7 @@ class pipeline(gr.hier_block2): gr.hier_block2.__init__(self, "pipeline", gr.io_signature(1, 1, gr.sizeof_float), gr.io_signature(0, 0, 0)) - taps = ntaps*[1.0/ntaps] + taps = ntaps*[1.0 / ntaps] upstream = self for i in range(nstages): op = filter.fir_filter_fff(1, taps) @@ -85,23 +88,23 @@ def time_it(tb): start = os.times() tb.run() stop = os.times() - delta = map((lambda a, b: a-b), stop, start) + delta = list(map((lambda a, b: a-b), stop, start)) user, sys, childrens_user, childrens_sys, real = delta total_user = user + childrens_user total_sys = sys + childrens_sys if tb.machine_readable: - print "%3d %3d %.3e %7.3f %7.3f %7.3f %7.3f %.6e %.3e" % ( - tb.npipes, tb.nstages, tb.nsamples, real, total_user, total_sys, (total_user+total_sys)/real, tb.flop, tb.flop/real) + print("%3d %3d %.3e %7.3f %7.3f %7.3f %7.3f %.6e %.3e" % ( + tb.npipes, tb.nstages, tb.nsamples, real, total_user, total_sys, (total_user+total_sys) / real, tb.flop, tb.flop / real)) else: - print "npipes %7d" % (tb.npipes,) - print "nstages %7d" % (tb.nstages,) - print "nsamples %s" % (eng_notation.num_to_str(tb.nsamples),) - print "real %7.3f" % (real,) - print "user %7.3f" % (total_user,) - print "sys %7.3f" % (total_sys,) - print "(user+sys)/real %7.3f" % ((total_user + total_sys)/real,) - print "pseudo_flop %s" % (eng_notation.num_to_str(tb.flop),) - print "pseudo_flop/real %s" % (eng_notation.num_to_str(tb.flop/real),) + print("npipes %7d" % (tb.npipes,)) + print("nstages %7d" % (tb.nstages,)) + print("nsamples %s" % (eng_notation.num_to_str(tb.nsamples),)) + print("real %7.3f" % (real,)) + print("user %7.3f" % (total_user,)) + print("sys %7.3f" % (total_sys,)) + print("(user+sys)/real %7.3f" % ((total_user + total_sys) / real,)) + print("pseudo_flop %s" % (eng_notation.num_to_str(tb.flop),)) + print("pseudo_flop/real %s" % (eng_notation.num_to_str(tb.flop / real),)) if __name__ == "__main__": @@ -109,7 +112,7 @@ if __name__ == "__main__": tb = top() time_it(tb) except KeyboardInterrupt: - raise SystemExit, 128 + raise SystemExit(128) diff --git a/gnuradio-runtime/examples/mp-sched/wfm_rcv_pll_to_wav.py b/gnuradio-runtime/examples/mp-sched/wfm_rcv_pll_to_wav.py index bb3296d428..93f26c6637 100755..100644 --- a/gnuradio-runtime/examples/mp-sched/wfm_rcv_pll_to_wav.py +++ b/gnuradio-runtime/examples/mp-sched/wfm_rcv_pll_to_wav.py @@ -20,6 +20,8 @@ # Boston, MA 02110-1301, USA. # +from __future__ import division +from __future__ import unicode_literals from gnuradio import gr, gru, eng_notation, filter from gnuradio import audio from gnuradio import analog @@ -94,7 +96,7 @@ class wfm_rx_block (gr.top_block): if args.volume is None: g = self.volume_range() - args.volume = float(g[0]+g[1])/2 + args.volume = float(g[0]+g[1]) / 2 # set initial values @@ -109,8 +111,8 @@ class wfm_rx_block (gr.top_block): def set_vol (self, vol): g = self.volume_range() self.vol = max(g[0], min(g[1], vol)) - self.volume_control_l.set_k(10**(self.vol/10)) - self.volume_control_r.set_k(10**(self.vol/10)) + self.volume_control_l.set_k(10**(self.vol / 10)) + self.volume_control_r.set_k(10**(self.vol / 10)) def volume_range(self): return (-20.0, 0.0, 0.5) diff --git a/gnuradio-runtime/examples/network/audio_sink.py b/gnuradio-runtime/examples/network/audio_sink.py index 9b91db5d1e..9ebe8a4c80 100755..100644 --- a/gnuradio-runtime/examples/network/audio_sink.py +++ b/gnuradio-runtime/examples/network/audio_sink.py @@ -20,6 +20,7 @@ # Boston, MA 02110-1301, USA. # +from __future__ import unicode_literals from gnuradio import gr from gnuradio import blocks from argparse import ArgumentParser diff --git a/gnuradio-runtime/examples/network/audio_source.py b/gnuradio-runtime/examples/network/audio_source.py index 6a464a8f28..cc4a34c63f 100755..100644 --- a/gnuradio-runtime/examples/network/audio_source.py +++ b/gnuradio-runtime/examples/network/audio_source.py @@ -20,6 +20,7 @@ # Boston, MA 02110-1301, USA. # +from __future__ import unicode_literals from gnuradio import gr from gnuradio import blocks from argparse import ArgumentParser diff --git a/gnuradio-runtime/examples/network/dial_tone_sink.py b/gnuradio-runtime/examples/network/dial_tone_sink.py index 4b1db98649..e6acbb08d4 100755..100644 --- a/gnuradio-runtime/examples/network/dial_tone_sink.py +++ b/gnuradio-runtime/examples/network/dial_tone_sink.py @@ -20,6 +20,7 @@ # Boston, MA 02110-1301, USA. # +from __future__ import unicode_literals from gnuradio import gr, audio from gnuradio import blocks from argparse import ArgumentParser diff --git a/gnuradio-runtime/examples/network/dial_tone_source.py b/gnuradio-runtime/examples/network/dial_tone_source.py index ee2bc9529b..aa3ab9954f 100755..100644 --- a/gnuradio-runtime/examples/network/dial_tone_source.py +++ b/gnuradio-runtime/examples/network/dial_tone_source.py @@ -20,6 +20,7 @@ # Boston, MA 02110-1301, USA. # +from __future__ import unicode_literals from gnuradio import gr from argparse import ArgumentParser import sys diff --git a/gnuradio-runtime/examples/network/vector_sink.py b/gnuradio-runtime/examples/network/vector_sink.py index 362f631380..a8850d8a01 100755..100644 --- a/gnuradio-runtime/examples/network/vector_sink.py +++ b/gnuradio-runtime/examples/network/vector_sink.py @@ -20,6 +20,7 @@ # Boston, MA 02110-1301, USA. # +from __future__ import unicode_literals from gnuradio import gr from gnuradio import blocks from gnuradio.eng_arg import eng_float, intx diff --git a/gnuradio-runtime/examples/network/vector_source.py b/gnuradio-runtime/examples/network/vector_source.py index be40134bc0..cf8d0000c2 100755..100644 --- a/gnuradio-runtime/examples/network/vector_source.py +++ b/gnuradio-runtime/examples/network/vector_source.py @@ -20,6 +20,7 @@ # Boston, MA 02110-1301, USA. # +from __future__ import unicode_literals from gnuradio import gr from gnuradio import blocks from argparse import ArgumentParser diff --git a/gnuradio-runtime/examples/volk_benchmark/volk_math.py b/gnuradio-runtime/examples/volk_benchmark/volk_math.py index 753257c237..6fc6cfa78d 100755..100644 --- a/gnuradio-runtime/examples/volk_benchmark/volk_math.py +++ b/gnuradio-runtime/examples/volk_benchmark/volk_math.py @@ -1,5 +1,7 @@ #!/usr/bin/env python +from __future__ import print_function +from __future__ import unicode_literals from gnuradio import gr from gnuradio import blocks import argparse @@ -87,7 +89,7 @@ def run_tests(func, N, iters): res = format_results(func.__name__, t) return res except AttributeError: - print "\tCould not run test. Skipping." + print("\tCould not run test. Skipping.") return None def main(): @@ -119,7 +121,7 @@ def main(): default=20, help='Number of iterations [default: %(default)s]') parser.add_argument('--tests', type=int, nargs='*', - choices=xrange(len(avail_tests)), + choices=list(range(len(avail_tests))), help='A list of tests to run; can be a single test or a \ space-separated list.') parser.add_argument('--list', action='store_true', @@ -129,8 +131,8 @@ def main(): args = parser.parse_args() if(args.list): - print "Available Tests to Run:" - print "\n".join(["\t{0}: {1}".format(i,f.__name__) for i,f in enumerate(avail_tests)]) + print("Available Tests to Run:") + print("\n".join(["\t{0}: {1}".format(i,f.__name__) for i,f in enumerate(avail_tests)])) sys.exit(0) N = int(args.nitems) @@ -141,7 +143,7 @@ def main(): new_table(conn, label) if args.all: - tests = xrange(len(avail_tests)) + tests = list(range(len(avail_tests))) else: tests = args.tests diff --git a/gnuradio-runtime/examples/volk_benchmark/volk_plot.py b/gnuradio-runtime/examples/volk_benchmark/volk_plot.py index 48f9922054..2e02773e05 100755..100644 --- a/gnuradio-runtime/examples/volk_benchmark/volk_plot.py +++ b/gnuradio-runtime/examples/volk_benchmark/volk_plot.py @@ -1,5 +1,7 @@ #!/usr/bin/env python +from __future__ import division +from __future__ import unicode_literals import sys, math import argparse from volk_test_funcs import * @@ -100,7 +102,7 @@ def main(): # Plot the results - x0 = xrange(len(name_reg)) + x0 = list(range(len(name_reg))) i = 0 for t in (table_data): ydata = [] @@ -119,7 +121,7 @@ def main(): if(args.percent != t): # makes x values for this data set placement # width of bars depends on number of comparisons - wdth = 0.80/(M-1) + wdth = 0.80 / (M-1) x1 = [x + i*wdth for x in x0] i += 1 @@ -130,7 +132,7 @@ def main(): else: # makes x values for this data set placement # width of bars depends on number of comparisons - wdth = 0.80/M + wdth = 0.80 / M x1 = [x + i*wdth for x in x0] i += 1 diff --git a/gnuradio-runtime/examples/volk_benchmark/volk_test_funcs.py b/gnuradio-runtime/examples/volk_benchmark/volk_test_funcs.py index a7dd7b705c..603c2ae5c3 100644 --- a/gnuradio-runtime/examples/volk_benchmark/volk_test_funcs.py +++ b/gnuradio-runtime/examples/volk_benchmark/volk_test_funcs.py @@ -1,5 +1,7 @@ #!/usr/bin/env python +from __future__ import print_function +from __future__ import unicode_literals from gnuradio import gr from gnuradio import blocks import math, sys, os, time @@ -122,18 +124,18 @@ class helper(gr.top_block): self.snks = [] self.head = blocks.head(isizeof, N) - for n in xrange(nsrcs): + for n in range(nsrcs): self.srcs.append(blocks.null_source(isizeof)) - for n in xrange(nsnks): + for n in range(nsnks): self.snks.append(blocks.null_sink(osizeof)) self.connect(self.srcs[0], self.head, (self.op,0)) - for n in xrange(1, nsrcs): + for n in range(1, nsrcs): self.connect(self.srcs[n], (self.op,n)) - for n in xrange(nsnks): + for n in range(nsnks): self.connect((self.op,n), self.snks[n]) def timeit(tb, iterations): @@ -143,10 +145,10 @@ def timeit(tb, iterations): ''' r = gr.enable_realtime_scheduling() if r != gr.RT_OK: - print "Warning: failed to enable realtime scheduling" + print("Warning: failed to enable realtime scheduling") times = [] - for i in xrange(iterations): + for i in range(iterations): start_time = time.time() tb.run() end_time = time.time() diff --git a/gnuradio-runtime/examples/volk_benchmark/volk_types.py b/gnuradio-runtime/examples/volk_benchmark/volk_types.py index 546e9629c0..697ec213c1 100755..100644 --- a/gnuradio-runtime/examples/volk_benchmark/volk_types.py +++ b/gnuradio-runtime/examples/volk_benchmark/volk_types.py @@ -1,5 +1,7 @@ #!/usr/bin/env python +from __future__ import print_function +from __future__ import unicode_literals from gnuradio import gr from gnuradio import blocks import argparse @@ -105,7 +107,7 @@ def run_tests(func, N, iters): res = format_results(func.__name__, t) return res except AttributeError: - print "\tCould not run test. Skipping." + print("\tCould not run test. Skipping.") return None def main(): @@ -143,7 +145,7 @@ def main(): default=20, help='Number of iterations [default: %(default)s]') parser.add_argument('--tests', type=int, nargs='*', - choices=xrange(len(avail_tests)), + choices=list(range(len(avail_tests))), help='A list of tests to run; can be a single test or a \ space-separated list.') parser.add_argument('--list', action='store_true', @@ -153,8 +155,8 @@ def main(): args = parser.parse_args() if(args.list): - print "Available Tests to Run:" - print "\n".join(["\t{0}: {1}".format(i,f.__name__) for i,f in enumerate(avail_tests)]) + print("Available Tests to Run:") + print("\n".join(["\t{0}: {1}".format(i,f.__name__) for i,f in enumerate(avail_tests)])) sys.exit(0) N = int(args.nitems) @@ -165,7 +167,7 @@ def main(): new_table(conn, label) if args.all: - tests = xrange(len(avail_tests)) + tests = list(range(len(avail_tests))) else: tests = args.tests |