Skip to content

Commit

Permalink
fix FIR zero filter for short length coefficients (#3881)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnitz authored Nov 29, 2021
1 parent a13c18e commit c0e2064
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pycbc/filter/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ def lfilter(coefficients, timeseries):
# If there aren't many points just use the default scipy method
if len(timeseries) < 2**7:
series = scipy.signal.lfilter(coefficients, 1.0, timeseries)
return series
return TimeSeries(series,
epoch=timeseries.start_time,
delta_t=timeseries.delta_t)
elif (len(timeseries) < fillen * 10) or (len(timeseries) < 2**18):
cseries = (Array(coefficients[::-1] * 1)).astype(timeseries.dtype)
cseries.resize(len(timeseries))
Expand Down
2 changes: 1 addition & 1 deletion test/test_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def test_lfilter(self):
test = test[len(c):]

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

self.assertTrue(isinstance(test, TimeSeries))
self.assertTrue(maxreldiff < 1e-7)

suite = unittest.TestSuite()
Expand Down

0 comments on commit c0e2064

Please sign in to comment.