mirror of
https://github.com/romanz/amodem.git
synced 2026-04-21 05:36:42 +08:00
add linear filter utility function.
This commit is contained in:
@@ -26,12 +26,10 @@ def test_linreg():
|
||||
|
||||
|
||||
def test_filter():
|
||||
f = sigproc.Filter(b=[1], a=[1])
|
||||
x = range(10)
|
||||
y = list(f(x))
|
||||
assert [float(i) for i in x] == y
|
||||
y = sigproc.lfilter(b=[1], a=[1], x=x)
|
||||
assert (np.array(x) == y).all()
|
||||
|
||||
f = sigproc.Filter(b=[0.5], a=[1, -0.5])
|
||||
x = [1] + [0] * 10
|
||||
y = list(f(x))
|
||||
assert y == [0.5 ** (i+1) for i in range(len(x))]
|
||||
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))]
|
||||
|
||||
Reference in New Issue
Block a user