Don't inherit from object on modern Python 3

This commit is contained in:
Roman Zeyde
2018-08-13 16:04:06 +03:00
parent 0bd691320e
commit ff6c9968e8
16 changed files with 27 additions and 27 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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()

View File

@@ -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

View File

@@ -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):

View File

@@ -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

View File

@@ -13,7 +13,7 @@ from . import common
log = logging.getLogger(__name__)
class Detector(object):
class Detector:
COHERENCE_THRESHOLD = 0.9

View File

@@ -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 = {}

View File

@@ -9,7 +9,7 @@ from . import sampling
from . import levinson
class Equalizer(object):
class Equalizer:
def __init__(self, config):
self.carriers = config.carriers

View File

@@ -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):

View File

@@ -13,7 +13,7 @@ from . import equalizer
log = logging.getLogger(__name__)
class Receiver(object):
class Receiver:
def __init__(self, config, pylab=None):
self.stats = {}

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -12,7 +12,7 @@ import mock
config = config.fastest()
class ProcessMock(object):
class ProcessMock:
def __init__(self):
self.buf = BytesIO()
self.stdin = self

View File

@@ -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]