Skip to content

Commit

Permalink
Test on more types of interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
adrhill committed Aug 22, 2024
1 parent 4c659d0 commit 78052bd
Showing 1 changed file with 26 additions and 19 deletions.
45 changes: 26 additions & 19 deletions test/ext/test_DataInterpolations.jl
Original file line number Diff line number Diff line change
@@ -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]
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 78052bd

Please sign in to comment.