[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 01/03: simplify application of staticmethod
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 01/03: simplify application of staticmethod in .py |
Date: |
Tue, 28 Jun 2016 18:53:43 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit 2013f22b4e2203f88f482ff545aaafee35c72494
Author: Jiří Pinkava <address@hidden>
Date: Tue Jun 28 13:14:38 2016 +0200
simplify application of staticmethod in .py
---
gr-digital/examples/narrowband/receive_path.py | 8 ++------
gr-digital/examples/narrowband/transmit_path.py | 4 +---
gr-digital/examples/narrowband/uhd_interface.py | 10 +++-------
gr-digital/examples/ofdm/receive_path.py | 8 ++------
gr-digital/examples/ofdm/transmit_path.py | 6 ++----
gr-digital/examples/ofdm/uhd_interface.py | 10 +++-------
gr-digital/python/digital/cpm.py | 6 ++----
gr-digital/python/digital/generic_mod_demod.py | 6 +++---
gr-digital/python/digital/gfsk.py | 17 ++++++-----------
gr-digital/python/digital/gmsk.py | 17 ++++++-----------
gr-digital/python/digital/ofdm.py | 6 ++----
gr-uhd/apps/hf_radio/input.py | 2 +-
12 files changed, 33 insertions(+), 67 deletions(-)
diff --git a/gr-digital/examples/narrowband/receive_path.py
b/gr-digital/examples/narrowband/receive_path.py
index dc155e1..8bbfe92 100644
--- a/gr-digital/examples/narrowband/receive_path.py
+++ b/gr-digital/examples/narrowband/receive_path.py
@@ -124,8 +124,8 @@ class receive_path(gr.hier_block2):
threshold_in_db: set detection threshold (float (dB))
"""
self.probe.set_threshold(threshold_in_db)
-
-
+
+ @staticmethod
def add_options(normal, expert):
"""
Adds receiver-specific options to the Options Parser
@@ -141,10 +141,6 @@ class receive_path(gr.hier_block2):
expert.add_option("", "--chbw-factor", type="float", default=1.0,
help="Channel bandwidth = chbw_factor x signal
bandwidth [defaut=%default]")
- # Make a static method to call before instantiation
- add_options = staticmethod(add_options)
-
-
def _print_verbage(self):
"""
Prints information about the receive path
diff --git a/gr-digital/examples/narrowband/transmit_path.py
b/gr-digital/examples/narrowband/transmit_path.py
index 43a9605..70b4044 100644
--- a/gr-digital/examples/narrowband/transmit_path.py
+++ b/gr-digital/examples/narrowband/transmit_path.py
@@ -94,6 +94,7 @@ class transmit_path(gr.hier_block2):
def differential(self):
return self.modulator._differential
+ @staticmethod
def add_options(normal, expert):
"""
Adds transmitter-specific options to the Options Parser
@@ -115,9 +116,6 @@ class transmit_path(gr.hier_block2):
default=False,
help="Log all parts of flow graph to file (CAUTION:
lots of data)")
- # Make a static method to call before instantiation
- add_options = staticmethod(add_options)
-
def _print_verbage(self):
"""
Prints information about the transmit path
diff --git a/gr-digital/examples/narrowband/uhd_interface.py
b/gr-digital/examples/narrowband/uhd_interface.py
index 474e96f..e7c7fe3 100644
--- a/gr-digital/examples/narrowband/uhd_interface.py
+++ b/gr-digital/examples/narrowband/uhd_interface.py
@@ -145,7 +145,8 @@ class uhd_transmitter(uhd_interface, gr.hier_block2):
if(verbose):
self._print_verbage()
-
+
+ @staticmethod
def add_options(parser):
add_freq_option(parser)
parser.add_option("-a", "--args", type="string", default="",
@@ -165,9 +166,6 @@ class uhd_transmitter(uhd_interface, gr.hier_block2):
help="select clock source (e.g. 'external')
[default=%default]")
parser.add_option("-v", "--verbose", action="store_true",
default=False)
- # Make a static method to call before instantiation
- add_options = staticmethod(add_options)
-
def _print_verbage(self):
"""
Prints information about the UHD transmitter
@@ -203,6 +201,7 @@ class uhd_receiver(uhd_interface, gr.hier_block2):
if(verbose):
self._print_verbage()
+ @staticmethod
def add_options(parser):
add_freq_option(parser)
parser.add_option("-a", "--args", type="string", default="",
@@ -223,9 +222,6 @@ class uhd_receiver(uhd_interface, gr.hier_block2):
if not parser.has_option("--verbose"):
parser.add_option("-v", "--verbose", action="store_true",
default=False)
- # Make a static method to call before instantiation
- add_options = staticmethod(add_options)
-
def _print_verbage(self):
"""
Prints information about the UHD transmitter
diff --git a/gr-digital/examples/ofdm/receive_path.py
b/gr-digital/examples/ofdm/receive_path.py
index 2a6813f..0cb4479 100644
--- a/gr-digital/examples/ofdm/receive_path.py
+++ b/gr-digital/examples/ofdm/receive_path.py
@@ -82,8 +82,8 @@ class receive_path(gr.hier_block2):
threshold_in_db: set detection threshold (float (dB))
"""
self.probe.set_threshold(threshold_in_db)
-
-
+
+ @staticmethod
def add_options(normal, expert):
"""
Adds receiver-specific options to the Options Parser
@@ -95,10 +95,6 @@ class receive_path(gr.hier_block2):
expert.add_option("", "--log", action="store_true", default=False,
help="Log all parts of flow graph to files (CAUTION:
lots of data)")
- # Make a static method to call before instantiation
- add_options = staticmethod(add_options)
-
-
def _print_verbage(self):
"""
Prints information about the receive path
diff --git a/gr-digital/examples/ofdm/transmit_path.py
b/gr-digital/examples/ofdm/transmit_path.py
index aa146ce..98a81f3 100644
--- a/gr-digital/examples/ofdm/transmit_path.py
+++ b/gr-digital/examples/ofdm/transmit_path.py
@@ -75,7 +75,8 @@ class transmit_path(gr.hier_block2):
Calls the transmitter method to send a packet
"""
return self.ofdm_tx.send_pkt(payload, eof)
-
+
+ @staticmethod
def add_options(normal, expert):
"""
Adds transmitter-specific options to the Options Parser
@@ -92,9 +93,6 @@ class transmit_path(gr.hier_block2):
default=False,
help="Log all parts of flow graph to file (CAUTION:
lots of data)")
- # Make a static method to call before instantiation
- add_options = staticmethod(add_options)
-
def _print_verbage(self):
"""
Prints information about the transmit path
diff --git a/gr-digital/examples/ofdm/uhd_interface.py
b/gr-digital/examples/ofdm/uhd_interface.py
index 5b4d707..ac34d95 100644
--- a/gr-digital/examples/ofdm/uhd_interface.py
+++ b/gr-digital/examples/ofdm/uhd_interface.py
@@ -126,7 +126,8 @@ class uhd_transmitter(uhd_interface, gr.hier_block2):
if(verbose):
self._print_verbage()
-
+
+ @staticmethod
def add_options(parser):
add_freq_option(parser)
parser.add_option("-a", "--args", type="string", default="",
@@ -146,9 +147,6 @@ class uhd_transmitter(uhd_interface, gr.hier_block2):
help="select clock source (e.g. 'external')
[default=%default]")
parser.add_option("-v", "--verbose", action="store_true",
default=False)
- # Make a static method to call before instantiation
- add_options = staticmethod(add_options)
-
def _print_verbage(self):
"""
Prints information about the UHD transmitter
@@ -186,6 +184,7 @@ class uhd_receiver(uhd_interface, gr.hier_block2):
if(verbose):
self._print_verbage()
+ @staticmethod
def add_options(parser):
add_freq_option(parser)
parser.add_option("-a", "--args", type="string", default="",
@@ -206,9 +205,6 @@ class uhd_receiver(uhd_interface, gr.hier_block2):
if not parser.has_option("--verbose"):
parser.add_option("-v", "--verbose", action="store_true",
default=False)
- # Make a static method to call before instantiation
- add_options = staticmethod(add_options)
-
def _print_verbage(self):
"""
Prints information about the UHD transmitter
diff --git a/gr-digital/python/digital/cpm.py b/gr-digital/python/digital/cpm.py
index b27fb09..322c3f0 100644
--- a/gr-digital/python/digital/cpm.py
+++ b/gr-digital/python/digital/cpm.py
@@ -204,23 +204,21 @@ class cpm_mod(gr.hier_block2):
self.connect(self.fmmod,
blocks.file_sink(gr.sizeof_gr_complex, "fmmod.dat"))
-
+ @staticmethod
def add_options(parser):
"""
Adds CPM modulation-specific options to the standard parser
"""
parser.add_option("", "--bt", type="float", default=_def_bt,
help="set bandwidth-time product [default=%default]
(GMSK)")
- add_options=staticmethod(add_options)
-
+ @staticmethod
def extract_kwargs_from_options(options):
"""
Given command line options, create dictionary suitable for passing to
__init__
"""
return modulation_utils.extract_kwargs_from_options(cpm_mod.__init__,
('self',),
options)
- extract_kwargs_from_options=staticmethod(extract_kwargs_from_options)
diff --git a/gr-digital/python/digital/generic_mod_demod.py
b/gr-digital/python/digital/generic_mod_demod.py
index f34994f..1b8e114 100644
--- a/gr-digital/python/digital/generic_mod_demod.py
+++ b/gr-digital/python/digital/generic_mod_demod.py
@@ -175,12 +175,12 @@ class generic_mod(gr.hier_block2):
def bits_per_symbol(self): # static method that's also callable on an
instance
return self._constellation.bits_per_symbol()
+ @staticmethod
def add_options(parser):
"""
Adds generic modulation options to the standard parser
"""
add_common_options(parser)
- add_options=staticmethod(add_options)
def extract_kwargs_from_options(cls, options):
"""
@@ -324,7 +324,7 @@ class generic_demod(gr.hier_block2):
def samples_per_symbol(self):
return self._samples_per_symbol
- def bits_per_symbol(self): # staticmethod that's also callable on an
instance
+ def bits_per_symbol(self):
return self._constellation.bits_per_symbol()
def _print_verbage(self):
@@ -372,6 +372,7 @@ class generic_demod(gr.hier_block2):
self.connect(self.unpack,
blocks.file_sink(gr.sizeof_char, "rx_unpack.8b"))
+ @staticmethod
def add_options(parser):
"""
Adds generic demodulation options to the standard parser
@@ -385,7 +386,6 @@ class generic_demod(gr.hier_block2):
help="set phase tracking loop lock-in bandwidth
[default=%default]")
parser.add_option("", "--timing-bw", type="float",
default=_def_timing_bw,
help="set timing symbol sync loop gain lock-in
bandwidth [default=%default]")
- add_options=staticmethod(add_options)
def extract_kwargs_from_options(cls, options):
"""
diff --git a/gr-digital/python/digital/gfsk.py
b/gr-digital/python/digital/gfsk.py
index 6ba007c..3569ffe 100644
--- a/gr-digital/python/digital/gfsk.py
+++ b/gr-digital/python/digital/gfsk.py
@@ -133,10 +133,9 @@ class gfsk_mod(gr.hier_block2):
def samples_per_symbol(self):
return self._samples_per_symbol
+ @staticmethod
def bits_per_symbol(self=None): # staticmethod that's also callable on
an instance
return 1
- bits_per_symbol = staticmethod(bits_per_symbol) # make it a static
method.
-
def _print_verbage(self):
print "bits per symbol = %d" % self.bits_per_symbol()
@@ -152,24 +151,21 @@ class gfsk_mod(gr.hier_block2):
self.connect(self.fmmod,
blocks.file_sink(gr.sizeof_gr_complex, "fmmod.dat"))
-
+ @staticmethod
def add_options(parser):
"""
Adds GFSK modulation-specific options to the standard parser
"""
parser.add_option("", "--bt", type="float", default=_def_bt,
help="set bandwidth-time product [default=%default]
(GFSK)")
- add_options=staticmethod(add_options)
-
+ @staticmethod
def extract_kwargs_from_options(options):
"""
Given command line options, create dictionary suitable for passing to
__init__
"""
return modulation_utils.extract_kwargs_from_options(gfsk_mod.__init__,
('self',), options)
- extract_kwargs_from_options=staticmethod(extract_kwargs_from_options)
-
# /////////////////////////////////////////////////////////////////////////////
@@ -255,10 +251,9 @@ class gfsk_demod(gr.hier_block2):
def samples_per_symbol(self):
return self._samples_per_symbol
+ @staticmethod
def bits_per_symbol(self=None): # staticmethod that's also callable on
an instance
return 1
- bits_per_symbol = staticmethod(bits_per_symbol) # make it a static
method.
-
def _print_verbage(self):
print "bits per symbol = %d" % self.bits_per_symbol()
@@ -278,6 +273,7 @@ class gfsk_demod(gr.hier_block2):
self.connect(self.slicer,
blocks.file_sink(gr.sizeof_char, "slicer.dat"))
+ @staticmethod
def add_options(parser):
"""
Adds GFSK demodulation-specific options to the standard parser
@@ -290,15 +286,14 @@ class gfsk_demod(gr.hier_block2):
help="M&M clock recovery omega relative limit
[default=%default] (GFSK/PSK)")
parser.add_option("", "--freq-error", type="float",
default=_def_freq_error,
help="M&M clock recovery frequency error
[default=%default] (GFSK)")
- add_options=staticmethod(add_options)
+ @staticmethod
def extract_kwargs_from_options(options):
"""
Given command line options, create dictionary suitable for passing to
__init__
"""
return
modulation_utils.extract_kwargs_from_options(gfsk_demod.__init__,
('self',), options)
- extract_kwargs_from_options=staticmethod(extract_kwargs_from_options)
#
diff --git a/gr-digital/python/digital/gmsk.py
b/gr-digital/python/digital/gmsk.py
index 284f85f..e7a92a9 100644
--- a/gr-digital/python/digital/gmsk.py
+++ b/gr-digital/python/digital/gmsk.py
@@ -123,10 +123,9 @@ class gmsk_mod(gr.hier_block2):
def samples_per_symbol(self):
return self._samples_per_symbol
+ @staticmethod
def bits_per_symbol(self=None): # staticmethod that's also callable on
an instance
return 1
- bits_per_symbol = staticmethod(bits_per_symbol) # make it a static
method.
-
def _print_verbage(self):
print "bits per symbol = %d" % self.bits_per_symbol()
@@ -142,24 +141,21 @@ class gmsk_mod(gr.hier_block2):
self.connect(self.fmmod,
blocks.file_sink(gr.sizeof_gr_complex, "fmmod.dat"))
-
+ @staticmethod
def add_options(parser):
"""
Adds GMSK modulation-specific options to the standard parser
"""
parser.add_option("", "--bt", type="float", default=_def_bt,
help="set bandwidth-time product [default=%default]
(GMSK)")
- add_options=staticmethod(add_options)
-
+ @staticmethod
def extract_kwargs_from_options(options):
"""
Given command line options, create dictionary suitable for passing to
__init__
"""
return modulation_utils.extract_kwargs_from_options(gmsk_mod.__init__,
('self',), options)
- extract_kwargs_from_options=staticmethod(extract_kwargs_from_options)
-
# /////////////////////////////////////////////////////////////////////////////
@@ -239,10 +235,9 @@ class gmsk_demod(gr.hier_block2):
def samples_per_symbol(self):
return self._samples_per_symbol
+ @staticmethod
def bits_per_symbol(self=None): # staticmethod that's also callable on
an instance
return 1
- bits_per_symbol = staticmethod(bits_per_symbol) # make it a static
method.
-
def _print_verbage(self):
print "bits per symbol = %d" % self.bits_per_symbol()
@@ -262,6 +257,7 @@ class gmsk_demod(gr.hier_block2):
self.connect(self.slicer,
blocks.file_sink(gr.sizeof_char, "slicer.dat"))
+ @staticmethod
def add_options(parser):
"""
Adds GMSK demodulation-specific options to the standard parser
@@ -274,15 +270,14 @@ class gmsk_demod(gr.hier_block2):
help="M&M clock recovery omega relative limit
[default=%default] (GMSK/PSK)")
parser.add_option("", "--freq-error", type="float",
default=_def_freq_error,
help="M&M clock recovery frequency error
[default=%default] (GMSK)")
- add_options=staticmethod(add_options)
+ @staticmethod
def extract_kwargs_from_options(options):
"""
Given command line options, create dictionary suitable for passing to
__init__
"""
return
modulation_utils.extract_kwargs_from_options(gmsk_demod.__init__,
('self',), options)
- extract_kwargs_from_options=staticmethod(extract_kwargs_from_options)
#
diff --git a/gr-digital/python/digital/ofdm.py
b/gr-digital/python/digital/ofdm.py
index fdb2370..563b70a 100644
--- a/gr-digital/python/digital/ofdm.py
+++ b/gr-digital/python/digital/ofdm.py
@@ -146,6 +146,7 @@ class ofdm_mod(gr.hier_block2):
msg = gr.message_from_string(pkt)
self._pkt_input.msgq().insert_tail(msg)
+ @staticmethod
def add_options(normal, expert):
"""
Adds OFDM-specific options to the Options Parser
@@ -158,8 +159,6 @@ class ofdm_mod(gr.hier_block2):
help="set the number of occupied FFT bins
[default=%default]")
expert.add_option("", "--cp-length", type="intx", default=128,
help="set the number of bits in the cyclic prefix
[default=%default]")
- # Make a static method to call before instantiation
- add_options = staticmethod(add_options)
def _print_verbage(self):
"""
@@ -267,6 +266,7 @@ class ofdm_demod(gr.hier_block2):
self._watcher = _queue_watcher_thread(self._rcvd_pktq, callback)
+ @staticmethod
def add_options(normal, expert):
"""
Adds OFDM-specific options to the Options Parser
@@ -281,8 +281,6 @@ class ofdm_demod(gr.hier_block2):
help="set the number of bits in the cyclic prefix
[default=%default]")
expert.add_option("", "--snr", type="float", default=30.0,
help="SNR estimate [default=%default]")
- # Make a static method to call before instantiation
- add_options = staticmethod(add_options)
def _print_verbage(self):
"""
diff --git a/gr-uhd/apps/hf_radio/input.py b/gr-uhd/apps/hf_radio/input.py
index fd2ac47..49df347 100644
--- a/gr-uhd/apps/hf_radio/input.py
+++ b/gr-uhd/apps/hf_radio/input.py
@@ -65,6 +65,7 @@ class uhd_input(gr.hier_block2):
self.gain = gain
self.src.set_gain(gain, 0)
+ @staticmethod
def add_options(parser):
parser.add_option("-a", "--address", type="string",
default="addr=192.168.10.2",
@@ -75,4 +76,3 @@ class uhd_input(gr.hier_block2):
help="set frequency to FREQ", metavar="FREQ")
parser.add_option("-g", "--gain", type="eng_float", default=None,
help="set gain in dB (default is midpoint)")
- add_options = staticmethod(add_options)