diff options
author | Josh Morman <jmorman@gnuradio.org> | 2021-11-24 12:53:58 -0500 |
---|---|---|
committer | mormj <34754695+mormj@users.noreply.github.com> | 2021-11-24 14:41:53 -0500 |
commit | 51ec89501552c35b2bd0721c0501302f224fe44d (patch) | |
tree | 442036c424c286ece0976dcd3c36891cddefcd25 /gnuradio-runtime/lib/math | |
parent | e426b9ad20dbbf41326c103b31a7418a80362b06 (diff) |
runtime: pep8 formatting
Signed-off-by: Josh Morman <jmorman@gnuradio.org>
Diffstat (limited to 'gnuradio-runtime/lib/math')
-rw-r--r-- | gnuradio-runtime/lib/math/gen_sine_table.py | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/gnuradio-runtime/lib/math/gen_sine_table.py b/gnuradio-runtime/lib/math/gen_sine_table.py index ae31b6b81a..b45cb52e7e 100644 --- a/gnuradio-runtime/lib/math/gen_sine_table.py +++ b/gnuradio-runtime/lib/math/gen_sine_table.py @@ -11,33 +11,36 @@ import math import sys -def gen_approx_table (f, nentries, min_x, max_x): + +def gen_approx_table(f, nentries, min_x, max_x): """return a list of nentries containing tuples of the form: (m, c). min_x and max_x specify the domain of the table. """ r = [] - incx = float (max_x - min_x) / nentries - for i in range (nentries): + incx = float(max_x - min_x) / nentries + for i in range(nentries): a = (i * incx) + min_x b = ((i + 1) * incx) + min_x - m = (f(b)-f(a)) / (b-a) + m = (f(b) - f(a)) / (b - a) c = f(a) - r.append ((m, c)) + r.append((m, c)) return r -def scaled_sine (x): - return math.sin (x * math.pi / 2**31) -def gen_sine_table (): +def scaled_sine(x): + return math.sin(x * math.pi / 2**31) + + +def gen_sine_table(): nbits = 10 nentries = 2**nbits # min_x = -2**31 # max_x = 2**31-1 min_x = 0 - max_x = 2**32-1 - t = gen_approx_table (scaled_sine, nentries, min_x, max_x) + max_x = 2**32 - 1 + t = gen_approx_table(scaled_sine, nentries, min_x, max_x) # sys.stdout.write ('static const int WORDBITS = 32;\n') # sys.stdout.write ('static const int NBITS = %d;\n' % (nbits,)) @@ -45,9 +48,10 @@ def gen_sine_table (): # sys.stdout.write ('static const double sine_table[%d][2] = {\n'% (nentries,)) for e in t: - sys.stdout.write (' { %22.15e, %22.15e },\n' % (e[0], e[1])) + sys.stdout.write(' { %22.15e, %22.15e },\n' % (e[0], e[1])) # sys.stdout.write ('};\n') + if __name__ == '__main__': - gen_sine_table () + gen_sine_table() |