From ff6c9968e8b7ce3ab79fd4f8342edf2c521bff9f Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Mon, 13 Aug 2018 16:04:06 +0300 Subject: [PATCH] Don't inherit from object on modern Python 3 --- amodem/__main__.py | 6 +++--- amodem/alsa.py | 6 +++--- amodem/async_reader.py | 2 +- amodem/audio.py | 4 ++-- amodem/common.py | 2 +- amodem/config.py | 2 +- amodem/detect.py | 2 +- amodem/dsp.py | 6 +++--- amodem/equalizer.py | 2 +- amodem/framing.py | 6 +++--- amodem/recv.py | 2 +- amodem/sampling.py | 4 ++-- amodem/send.py | 2 +- amodem/stream.py | 4 ++-- amodem/tests/test_calib.py | 2 +- amodem/tests/utils.py | 2 +- 16 files changed, 27 insertions(+), 27 deletions(-) diff --git a/amodem/__main__.py b/amodem/__main__.py index 4dd00b2..4d3ac8d 100644 --- a/amodem/__main__.py +++ b/amodem/__main__.py @@ -31,7 +31,7 @@ bitrate = os.environ.get('BITRATE', 1) config = bitrates.get(int(bitrate)) -class Compressor(object): +class Compressor: def __init__(self, stream): self.obj = zlib.compressobj() log.info('Using zlib compressor') @@ -52,7 +52,7 @@ class Compressor(object): return result -class Decompressor(object): +class Decompressor: def __init__(self, stream): self.obj = zlib.decompressobj() log.info('Using zlib decompressor') @@ -185,7 +185,7 @@ def create_parser(description, interface_factory): return p -class _Dummy(object): +class _Dummy: def __enter__(self): return self diff --git a/amodem/alsa.py b/amodem/alsa.py index a22a561..af3c63f 100644 --- a/amodem/alsa.py +++ b/amodem/alsa.py @@ -9,7 +9,7 @@ import logging log = logging.getLogger(__name__) -class Interface(object): +class Interface: RECORDER = 'arecord' PLAYER = 'aplay' @@ -50,7 +50,7 @@ class Interface(object): return Player(self) -class Recorder(object): +class Recorder: def __init__(self, lib): self.p = lib.launch(args=lib.record_cmd, stdout=subprocess.PIPE) self.read = self.p.stdout.read @@ -60,7 +60,7 @@ class Recorder(object): self.p.kill() -class Player(object): +class Player: def __init__(self, lib): self.p = lib.launch(args=lib.play_cmd, stdin=subprocess.PIPE) self.write = self.p.stdin.write diff --git a/amodem/async_reader.py b/amodem/async_reader.py index d344fec..706e2bb 100644 --- a/amodem/async_reader.py +++ b/amodem/async_reader.py @@ -8,7 +8,7 @@ import six # since `Queue` module was renamed to `queue` (in Python 3) log = logging.getLogger() -class AsyncReader(object): +class AsyncReader: def __init__(self, stream, bufsize): self.stream = stream self.queue = six.moves.queue.Queue() diff --git a/amodem/audio.py b/amodem/audio.py index 64cfd91..dabe275 100644 --- a/amodem/audio.py +++ b/amodem/audio.py @@ -7,7 +7,7 @@ import time log = logging.getLogger(__name__) -class Interface(object): +class Interface: def __init__(self, config, debug=False): self.debug = bool(debug) self.config = config @@ -53,7 +53,7 @@ class Interface(object): return Stream(self, config=self.config, write=True) -class Stream(object): +class Stream: timer = time.time diff --git a/amodem/common.py b/amodem/common.py index 62d2758..afdc622 100644 --- a/amodem/common.py +++ b/amodem/common.py @@ -81,7 +81,7 @@ def izip(iterables): yield tuple([next(iterable) for iterable in iterables]) -class Dummy(object): +class Dummy: """ Dummy placeholder object for testing and mocking. """ def __getattr__(self, name): diff --git a/amodem/config.py b/amodem/config.py index 90c99de..e2b5c3d 100644 --- a/amodem/config.py +++ b/amodem/config.py @@ -3,7 +3,7 @@ import numpy as np -class Configuration(object): +class Configuration: Fs = 32000.0 # sampling frequency [Hz] Tsym = 0.001 # symbol duration [seconds] Npoints = 64 diff --git a/amodem/detect.py b/amodem/detect.py index 66c9c19..7677e90 100644 --- a/amodem/detect.py +++ b/amodem/detect.py @@ -13,7 +13,7 @@ from . import common log = logging.getLogger(__name__) -class Detector(object): +class Detector: COHERENCE_THRESHOLD = 0.9 diff --git a/amodem/dsp.py b/amodem/dsp.py index 458afca..425b737 100644 --- a/amodem/dsp.py +++ b/amodem/dsp.py @@ -5,7 +5,7 @@ import numpy as np from . import common -class FIR(object): +class FIR: def __init__(self, h): self.h = np.array(h) self.x_state = [0] * len(self.h) @@ -19,7 +19,7 @@ class FIR(object): self.x_state = x_ -class Demux(object): +class Demux: def __init__(self, sampler, omegas, Nsym): self.Nsym = Nsym self.filters = [exp_iwt(-w, Nsym) / (0.5*self.Nsym) for w in omegas] @@ -73,7 +73,7 @@ def linear_regression(x, y): return a, b -class MODEM(object): +class MODEM: def __init__(self, symbols): self.encode_map = {} diff --git a/amodem/equalizer.py b/amodem/equalizer.py index 998801b..51f2227 100644 --- a/amodem/equalizer.py +++ b/amodem/equalizer.py @@ -9,7 +9,7 @@ from . import sampling from . import levinson -class Equalizer(object): +class Equalizer: def __init__(self, config): self.carriers = config.carriers diff --git a/amodem/framing.py b/amodem/framing.py index f7e72c8..ff4d53c 100644 --- a/amodem/framing.py +++ b/amodem/framing.py @@ -14,7 +14,7 @@ def _checksum_func(x): return binascii.crc32(bytes(x)) & 0xFFFFFFFF -class Checksum(object): +class Checksum: fmt = '>L' # unsigned longs (32-bit) size = struct.calcsize(fmt) @@ -34,7 +34,7 @@ class Checksum(object): return payload -class Framer(object): +class Framer: block_size = 250 prefix_fmt = '>B' prefix_len = struct.calcsize(prefix_fmt) @@ -88,7 +88,7 @@ def chain_wrapper(func): return wrapped -class BitPacker(object): +class BitPacker: byte_size = 8 def __init__(self): diff --git a/amodem/recv.py b/amodem/recv.py index fb6404d..0b1259d 100644 --- a/amodem/recv.py +++ b/amodem/recv.py @@ -13,7 +13,7 @@ from . import equalizer log = logging.getLogger(__name__) -class Receiver(object): +class Receiver: def __init__(self, config, pylab=None): self.stats = {} diff --git a/amodem/sampling.py b/amodem/sampling.py index b369746..8bcfdd9 100644 --- a/amodem/sampling.py +++ b/amodem/sampling.py @@ -5,7 +5,7 @@ import numpy as np from . import common -class Interpolator(object): +class Interpolator: def __init__(self, resolution=1024, width=128): @@ -33,7 +33,7 @@ class Interpolator(object): defaultInterpolator = Interpolator() -class Sampler(object): +class Sampler: def __init__(self, src, interp=None, freq=1.0): self.freq = freq self.equalizer = lambda x: x # LTI equalization filter diff --git a/amodem/send.py b/amodem/send.py index 26778e1..37de2db 100644 --- a/amodem/send.py +++ b/amodem/send.py @@ -10,7 +10,7 @@ from . import dsp log = logging.getLogger(__name__) -class Sender(object): +class Sender: def __init__(self, fd, config, gain=1.0): self.gain = gain self.offset = 0 diff --git a/amodem/stream.py b/amodem/stream.py index 7cfb401..2ca7a2b 100644 --- a/amodem/stream.py +++ b/amodem/stream.py @@ -1,7 +1,7 @@ import time -class Reader(object): +class Reader: wait = 0.2 timeout = 2.0 @@ -45,7 +45,7 @@ class Reader(object): __next__ = next -class Dumper(object): +class Dumper: def __init__(self, src, dst): self.src = src self.dst = dst diff --git a/amodem/tests/test_calib.py b/amodem/tests/test_calib.py index 25c921a..8da5b4e 100644 --- a/amodem/tests/test_calib.py +++ b/amodem/tests/test_calib.py @@ -12,7 +12,7 @@ import mock config = config.fastest() -class ProcessMock(object): +class ProcessMock: def __init__(self): self.buf = BytesIO() self.stdin = self diff --git a/amodem/tests/utils.py b/amodem/tests/utils.py index 8853dc0..9dbfeec 100644 --- a/amodem/tests/utils.py +++ b/amodem/tests/utils.py @@ -1,7 +1,7 @@ import numpy as np -class IIR(object): +class IIR: def __init__(self, b, a): self.b = np.array(b) / a[0] self.a = np.array(a[1:]) / a[0]