From ed6c5f6e80be80daf997fe962aab2ac5d6bf4203 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Thu, 28 Nov 2024 13:43:46 +0100 Subject: [PATCH] Improve resample "irrational ratio" test (#597) * Properly compute reference signal in "irrational ratio" test * Simplify criterion in "irrational ratio" test --- test/resample.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/resample.jl b/test/resample.jl index 78b174f4e..2c8cbb312 100644 --- a/test/resample.jl +++ b/test/resample.jl @@ -79,22 +79,22 @@ end x = sinpi.(2*tx) y = resample(x, ratio) yLen = length(y) - ty = range(0, stop=cycles, length=yLen) + ty = range(0, length=yLen, step=step(tx)/ratio) yy = sinpi.(2*ty) idxLower = round(Int, yLen/3) idxUpper = idxLower*2 yDelta = abs.(y[idxLower:idxUpper].-yy[idxLower:idxUpper]) - @test all(map(delta -> abs(delta) < 0.005, yDelta)) + @test maximum(yDelta) < 0.00025 # Test Float32 ratio (#302) f32_ratio = convert(Float32, ratio) f32_y = resample(x, f32_ratio) - ty = range(0, stop =cycles, length =yLen) + ty = range(0, length=yLen, step=step(tx)/f32_ratio) yy = sinpi.(2*ty) idxLower = round(Int, yLen/3) idxUpper = idxLower*2 yDelta = abs.(f32_y[idxLower:idxUpper].-yy[idxLower:idxUpper]) - @test all(map(delta -> abs(delta) < 0.005, yDelta)) + @test maximum(yDelta) < 0.00025 end @testset "arbitrary ratio" begin