mirror of
https://github.com/romanz/amodem.git
synced 2026-03-24 19:31:02 +08:00
pylint fixes
This commit is contained in:
6
loop.py
6
loop.py
@@ -1,10 +1,10 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
import itertools
|
import itertools
|
||||||
|
|
||||||
import recv
|
|
||||||
import sampling
|
import sampling
|
||||||
import sigproc
|
import sigproc
|
||||||
|
|
||||||
|
|
||||||
class Filter(object):
|
class Filter(object):
|
||||||
def __init__(self, b, a=()):
|
def __init__(self, b, a=()):
|
||||||
self.b = b
|
self.b = b
|
||||||
@@ -20,6 +20,7 @@ class Filter(object):
|
|||||||
self.y = [y] + self.y
|
self.y = [y] + self.y
|
||||||
return y
|
return y
|
||||||
|
|
||||||
|
|
||||||
class FreqLoop(object):
|
class FreqLoop(object):
|
||||||
def __init__(self, x, freqs, prefix=0.0):
|
def __init__(self, x, freqs, prefix=0.0):
|
||||||
interp = sampling.Interpolator()
|
interp = sampling.Interpolator()
|
||||||
@@ -34,7 +35,8 @@ class FreqLoop(object):
|
|||||||
|
|
||||||
samplers = itertools.tee(self.sampler, len(freqs))
|
samplers = itertools.tee(self.sampler, len(freqs))
|
||||||
for freq, generator in zip(freqs, samplers):
|
for freq, generator in zip(freqs, samplers):
|
||||||
self.gens.append( sigproc.extract_symbols(generator, freq) )
|
gen = sigproc.extract_symbols(generator, freq)
|
||||||
|
self.gens.append(gen)
|
||||||
|
|
||||||
Kp, Ki = 0.2, 0.01
|
Kp, Ki = 0.2, 0.01
|
||||||
b = np.array([1, -1])*Kp + np.array([0.5, 0.5])*Ki
|
b = np.array([1, -1])*Kp + np.array([0.5, 0.5])*Ki
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import logging
|
|||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Interpolator(object):
|
class Interpolator(object):
|
||||||
def __init__(self, resolution=10000, width=128):
|
def __init__(self, resolution=10000, width=128):
|
||||||
self.width = width
|
self.width = width
|
||||||
@@ -28,6 +29,7 @@ class Interpolator(object):
|
|||||||
coeffs = self.filt[j]
|
coeffs = self.filt[j]
|
||||||
return coeffs, k - self.width
|
return coeffs, k - self.width
|
||||||
|
|
||||||
|
|
||||||
class Sampler(object):
|
class Sampler(object):
|
||||||
def __init__(self, src, interp=None):
|
def __init__(self, src, interp=None):
|
||||||
self.src = iter(src)
|
self.src = iter(src)
|
||||||
@@ -70,6 +72,6 @@ if __name__ == '__main__':
|
|||||||
_, x = common.load(sys.stdin)
|
_, x = common.load(sys.stdin)
|
||||||
sampler = Sampler(x, Interpolator())
|
sampler = Sampler(x, Interpolator())
|
||||||
sampler.freq += df
|
sampler.freq += df
|
||||||
y = np.array(list(sampler), )
|
y = np.array(list(sampler))
|
||||||
sys.stdout.write( common.dumps(y*1j) )
|
y = common.dumps(y*1j)
|
||||||
|
sys.stdout.write(y)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import sampling
|
import sampling
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pylab
|
|
||||||
|
|
||||||
def test_resample():
|
def test_resample():
|
||||||
x = np.arange(300)
|
x = np.arange(300)
|
||||||
@@ -12,7 +12,8 @@ def test_resample():
|
|||||||
err = x - y
|
err = x - y
|
||||||
assert np.max(np.abs(err)) < 1e-10
|
assert np.max(np.abs(err)) < 1e-10
|
||||||
|
|
||||||
|
|
||||||
def test_coeffs():
|
def test_coeffs():
|
||||||
I = sampling.Interpolator(width=4, resolution=16)
|
I = sampling.Interpolator(width=4, resolution=16)
|
||||||
err = I.filt[0] - [0,0,0,1,0,0,0,0]
|
err = I.filt[0] - [0, 0, 0, 1, 0, 0, 0, 0]
|
||||||
assert np.max(np.abs(err)) < 1e-10
|
assert np.max(np.abs(err)) < 1e-10
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import common
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
|
||||||
def test_qam():
|
def test_qam():
|
||||||
q = sigproc.QAM(sigproc._symbols)
|
q = sigproc.QAM(sigproc._symbols)
|
||||||
r = random.Random(0)
|
r = random.Random(0)
|
||||||
@@ -13,6 +14,7 @@ def test_qam():
|
|||||||
decoded = list(q.decode(list(S)))
|
decoded = list(q.decode(list(S)))
|
||||||
assert decoded == bits
|
assert decoded == bits
|
||||||
|
|
||||||
|
|
||||||
def test_drift():
|
def test_drift():
|
||||||
fc = 10e3
|
fc = 10e3
|
||||||
df = 1.23
|
df = 1.23
|
||||||
|
|||||||
Reference in New Issue
Block a user