Skip to content

Commit 022dd7d

Browse files
committed
Added minimal test for resample with irrational resampling rate
1 parent 4865ded commit 022dd7d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/resample.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,24 @@ y4_ml = vec(readdlm(joinpath(dirname(@__FILE__), "data", "resample_y_2_3.txt"),'
4444
y4_jl = resample(x_ml, rate, h4_ml)
4545
@test_approx_eq y4_jl y4_ml
4646

47+
#
48+
# Test resample with a rational factor
49+
#
50+
51+
ratio = 3.141592653589793
52+
cycles = 2
53+
tx = linspace(0, cycles, 1000)
54+
x = sinpi(2*tx)
55+
y = resample(x, ratio, 32)
56+
yLen = length(y)
57+
ty = linspace(0, cycles, yLen)
58+
yy = sinpi(2*ty)
59+
idxLower = round(Int, yLen/3)
60+
idxUpper = idxLower*2
61+
yDelta = abs(y[idxLower:idxUpper].-yy[idxLower:idxUpper])
62+
@test all(map(delta -> abs(delta) < 0.005, yDelta))
63+
64+
4765
#
4866
# Test response of resample_filter
4967
#

0 commit comments

Comments
 (0)