Skip to content

Commit

Permalink
add unittest for the hand written lfilter
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnitz committed Mar 28, 2016
1 parent c026b8c commit c7ff1bf
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/test_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
from pycbc.filter import *
from pycbc.scheme import *
from utils import parse_args_all_schemes, simple_exit
from numpy.random import uniform
import scipy.signal
from pycbc.filter.resample import lfilter

_scheme, _context = parse_args_all_schemes("Resampling")

Expand Down Expand Up @@ -65,6 +68,23 @@ def test_resample_errors(self):
with self.context:
self.assertRaises(TypeError, resample_to_delta_t, self.a, self.target_delta_t)

def test_lfilter(self):
"Check our hand written lfilter"
c = uniform(-10, 10, size=1024)
ts = uniform(-1, 1, size=4323)

ref = scipy.signal.lfilter(c, 1.0, ts)
test = lfilter(c, ts)

# These only agree where there is no fft wraparound
# so excluded corrupted region from test
ref = ref[len(c):]
test = test[len(c):]

maxreldiff = ((ref - test) / ref).max()

self.assertTrue(maxreldiff < 1e-7)

suite = unittest.TestSuite()
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestUtils))

Expand Down

0 comments on commit c7ff1bf

Please sign in to comment.