Skip to content

Commit

Permalink
test: update tests for extrapolation
Browse files Browse the repository at this point in the history
  • Loading branch information
sathvikbhagavan committed Sep 28, 2023
1 parent f28079d commit 8a416eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 1 addition & 3 deletions test/derivative_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ using FiniteDifferences
using DataInterpolations: derivative

function test_derivatives(func, tspan, name::String)
trange = range(minimum(tspan), maximum(tspan), length = 32)[2:(end - 1)]
trange = range(minimum(tspan) - 5.0, maximum(tspan) + 5.0, length = 32)
@testset "$name" begin
for t in trange
# Linearly spaced points might lead to evaluations outside
# trange
cdiff = central_fdm(5, 1; geom = true)(_t -> func(_t), t)
adiff = derivative(func, t)
@test isapprox(cdiff, adiff, atol = 1e-8)
Expand Down
6 changes: 6 additions & 0 deletions test/interpolation_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -476,21 +476,27 @@ u = [14.7, 11.51, 10.41, 14.95, 12.24, 11.22]

A = BSplineInterpolation(u, t, 2, :Uniform, :Uniform)

@test A(-1.0) == u[1]
@test [A(25.0), A(80.0)] == [13.454197730061425, 10.305633616059845]
@test [A(190.0), A(225.0)] == [14.07428439395079, 11.057784141519251]
@test [A(t[1]), A(t[end])] == [u[1], u[end]]
@test A(300.0) == u[end]

A = BSplineInterpolation(u, t, 2, :ArcLen, :Average)

@test A(-1.0) == u[1]
@test [A(25.0), A(80.0)] == [13.363814458968486, 10.685201117692609]
@test [A(190.0), A(225.0)] == [13.437481084762863, 11.367034741256463]
@test [A(t[1]), A(t[end])] == [u[1], u[end]]
@test A(300.0) == u[end]

A = BSplineApprox(u, t, 2, 4, :Uniform, :Uniform)

@test A(-1.0) == u[1]
@test [A(25.0), A(80.0)] [12.979802931218234, 10.914310609953178]
@test [A(190.0), A(225.0)] [13.851245975109263, 12.963685868886575]
@test [A(t[1]), A(t[end])] [u[1], u[end]]
@test A(300.0) == u[end]

# Curvefit Interpolation
rng = StableRNG(12345)
Expand Down

0 comments on commit 8a416eb

Please sign in to comment.