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/python/gnuradio/eng_notation.py | |
parent | e426b9ad20dbbf41326c103b31a7418a80362b06 (diff) |
runtime: pep8 formatting
Signed-off-by: Josh Morman <jmorman@gnuradio.org>
Diffstat (limited to 'gnuradio-runtime/python/gnuradio/eng_notation.py')
-rw-r--r-- | gnuradio-runtime/python/gnuradio/eng_notation.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/gnuradio-runtime/python/gnuradio/eng_notation.py b/gnuradio-runtime/python/gnuradio/eng_notation.py index adf6e9572c..c4c95e3cc9 100644 --- a/gnuradio-runtime/python/gnuradio/eng_notation.py +++ b/gnuradio-runtime/python/gnuradio/eng_notation.py @@ -24,7 +24,8 @@ scale_factor['p'] = 1e-12 scale_factor['f'] = 1e-15 scale_factor['a'] = 1e-18 -def num_to_str (n, precision=6): + +def num_to_str(n, precision=6): '''Convert a number to a string in engineering notation. E.g., 5e-9 -> 5n''' m = abs(n) format_spec = '%.' + repr(int(precision)) + 'g' @@ -50,7 +51,7 @@ def num_to_str (n, precision=6): return '%s' % float(format_spec % (n)) -def str_to_num (value): +def str_to_num(value): '''Convert a string in engineering notation to a number. E.g., '15m' -> 15e-3''' try: if not isinstance(value, str): @@ -58,8 +59,8 @@ def str_to_num (value): scale = 1.0 suffix = value[-1] if suffix in scale_factor: - return float (value[0:-1]) * scale_factor[suffix] - return float (value) + return float(value[0:-1]) * scale_factor[suffix] + return float(value) except (TypeError, KeyError, ValueError): - raise ValueError ( + raise ValueError( "Invalid engineering notation value: %r" % (value,)) |