From 78052bda2e36a6a9f04618869640298b80b21608 Mon Sep 17 00:00:00 2001 From: adrhill Date: Thu, 22 Aug 2024 19:06:04 +0200 Subject: [PATCH] Test on more types of interpolation --- test/ext/test_DataInterpolations.jl | 45 +++++++++++++++++------------ 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/test/ext/test_DataInterpolations.jl b/test/ext/test_DataInterpolations.jl index 3e2d04a..c53722b 100644 --- a/test/ext/test_DataInterpolations.jl +++ b/test/ext/test_DataInterpolations.jl @@ -1,12 +1,19 @@ using SparseConnectivityTracer using DataInterpolations +using DataInterpolations: AbstractInterpolation using Test # Categorize Interpolations by type of differentiability interpolations_z = (ConstantInterpolation,) interpolations_f = (LinearInterpolation,) -interpolations_s = (QuadraticInterpolation,) +interpolations_s = ( + QuadraticInterpolation, + LagrangeInterpolation, + AkimaInterpolation, + QuadraticSpline, + CubicSpline, +) u = [1.0, 2.0, 5.0] t = [0.0, 1.0, 3.0] @@ -16,21 +23,21 @@ t = [0.0, 1.0, 3.0] J(f, x) = jacobian_sparsity(f, x, method) @testset "Non-differentiable" begin - @testset "$TI" for TI in interpolations_z - interpolant = TI(u, t) - @test J(interpolant, 2.0) ≈ [0;;] + @testset "$T" for T in interpolations_z + interp = construct_interpolator(T, u, t) + @test J(interp, 2.0) ≈ [0;;] end end @testset "First-order differentiable" begin - @testset "$TI" for TI in interpolations_f - interpolant = TI(u, t) - @test J(interpolant, 2.0) ≈ [1;;] + @testset "$T" for T in interpolations_f + interp = construct_interpolator(T, u, t) + @test J(interp, 2.0) ≈ [1;;] end end @testset "Second-order differentiable" begin - @testset "$TI" for TI in interpolations_s - interpolant = TI(u, t) - @test J(interpolant, 2.0) ≈ [1;;] + @testset "$T" for T in interpolations_s + interp = construct_interpolator(T, u, t) + @test J(interp, 2.0) ≈ [1;;] end end end @@ -46,21 +53,21 @@ end H(f, x) = hessian_sparsity(f, x, method) @testset "Non-differentiable" begin - @testset "$TI" for TI in interpolations_z - interpolant = TI(u, t) - @test H(interpolant, 2.0) ≈ [0;;] + @testset "$T" for T in interpolations_z + interp = T(u, t) + @test H(interp, 2.0) ≈ [0;;] end end @testset "First-order differentiable" begin - @testset "$TI" for TI in interpolations_f - interpolant = TI(u, t) - @test H(interpolant, 2.0) ≈ [0;;] + @testset "$T" for T in interpolations_f + interp = T(u, t) + @test H(interp, 2.0) ≈ [0;;] end end @testset "Second-order differentiable" begin - @testset "$TI" for TI in interpolations_s - interpolant = TI(u, t) - @test H(interpolant, 2.0) ≈ [1;;] + @testset "$T" for T in interpolations_s + interp = T(u, t) + @test H(interp, 2.0) ≈ [1;;] end end end