From 8a416eb679662e7c1a8550749b611aa947fc8ba9 Mon Sep 17 00:00:00 2001 From: Sathvik Bhagavan Date: Thu, 28 Sep 2023 06:52:27 +0000 Subject: [PATCH] test: update tests for extrapolation --- test/derivative_tests.jl | 4 +--- test/interpolation_tests.jl | 6 ++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/test/derivative_tests.jl b/test/derivative_tests.jl index 3b3a1518..7501d096 100644 --- a/test/derivative_tests.jl +++ b/test/derivative_tests.jl @@ -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) diff --git a/test/interpolation_tests.jl b/test/interpolation_tests.jl index 6ce3fefb..28ccdce4 100644 --- a/test/interpolation_tests.jl +++ b/test/interpolation_tests.jl @@ -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)