Skip to content

Commit

Permalink
Improve resample "irrational ratio" test (#597)
Browse files Browse the repository at this point in the history
* Properly compute reference signal in "irrational ratio" test

* Simplify criterion in "irrational ratio" test
  • Loading branch information
martinholters authored Nov 28, 2024
1 parent d6f8c6c commit ed6c5f6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/resample.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ed6c5f6

Please # to comment.