From 1348ab3ba2e78767e1bd7df699260baf13654f73 Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Tue, 19 Aug 2014 17:53:20 +0300 Subject: [PATCH] sampling: fix off-by-one padding error --- amodem/sampling.py | 2 +- tests/test_sampling.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/amodem/sampling.py b/amodem/sampling.py index a46165c..2f52459 100644 --- a/amodem/sampling.py +++ b/amodem/sampling.py @@ -34,7 +34,7 @@ class Sampler(object): self.width = self.interp.width # TODO: explain indices arithmetic - padding = [0.0] * (self.interp.width - 1) + padding = [0.0] * self.interp.width self.src = itertools.chain(padding, src) self.offset = self.interp.width + 1 self.buff = np.zeros(self.interp.coeff_len) diff --git a/tests/test_sampling.py b/tests/test_sampling.py index 416ccbd..161cd8b 100644 --- a/tests/test_sampling.py +++ b/tests/test_sampling.py @@ -11,7 +11,7 @@ def test_resample(): dst = BytesIO() sampling.resample(src=src, dst=dst, df=0.0) y = common.loads(dst.getvalue()) - err = x[1:len(y)+1] - y + err = x[:len(y)] - y assert np.max(np.abs(err)) < 1e-4 dst = BytesIO()