fix typo in tests.

This commit is contained in:
Roman Zeyde
2014-08-15 10:39:53 +03:00
parent 65200d1038
commit 7971a1c8d3

View File

@@ -30,6 +30,7 @@ def quantize(q, s):
expected = q.symbols[index]
assert r == expected
def test_overflow():
q = sigproc.QAM(config.symbols)
r = np.random.RandomState(seed=0)
@@ -37,6 +38,7 @@ def test_overflow():
s = 10*(r.normal() + 1j * r.normal())
quantize(q, s)
def test_linreg():
x = np.array([1, 3, 2, 8, 4, 6, 9, 7, 0, 5])
a, b = 12.3, 4.56
@@ -55,22 +57,32 @@ def test_filter():
y = sigproc.lfilter(b=[0.5], a=[1, -0.5], x=x)
assert list(y) == [0.5 ** (i+1) for i in range(len(x))]
def test_estimate():
r = np.random.RandomState(seed=0)
x = r.uniform(-1, 1, [1000])
x[:10] = 0
x[len(x)-10:] = 0
c = 1.23
y = c * x
c_, = sigproc.estimate(x=x, y=y, order=1)
assert abs(c - c_) < 1e-12
h = [1, 1]
y = sigproc.lfilter(b=h, a=[1], x=x)
h_ = sigproc.estimate(x=x, y=y, order=len(h))
assert norm(h - h_) < 1e-12
h = [0.1, 0.6, 0.9, 0.7, -0.2]
L = len(h) / 2
L = len(h) // 2
y = sigproc.lfilter(b=h, a=[1], x=x)
h_ = sigproc.estimate(
x=x[:len(x)-L], y=y[L:],
order=len(h), lookahead=L
)
y_ = sigproc.lfilter(b=h_, a=[1], x=x)
assert norm(y - y_) < 1e-12
assert norm(h - h_) < 1e-12
y_ = sigproc.lfilter(b=h_, a=[1], x=x)
assert norm(y - y_) < 1e-12