Skip to content

Commit

Permalink
Test local tracers
Browse files Browse the repository at this point in the history
  • Loading branch information
adrhill committed Aug 22, 2024
1 parent 1e73da1 commit c0076fa
Showing 1 changed file with 38 additions and 46 deletions.
84 changes: 38 additions & 46 deletions test/ext/test_DataInterpolations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,62 +18,54 @@ interpolations_s = (
u = [1.0, 2.0, 5.0]
t = [0.0, 1.0, 3.0]

@testset "Jacobian Global" begin
method = TracerSparsityDetector()
J(f, x) = jacobian_sparsity(f, x, method)
@testset "Jacobian" begin
@testset "$M" for M in (TracerSparsityDetector, TracerLocalSparsityDetector)
method = M()
J(f, x) = jacobian_sparsity(f, x, method)

@testset "Non-differentiable" begin
@testset "$T" for T in interpolations_z
interp = T(u, t)
@test J(interp, 2.0) [0;;]
@testset "Non-differentiable" begin
@testset "$T" for T in interpolations_z
interp = T(u, t)
@test J(interp, 2.0) [0;;]
end
end
end
@testset "First-order differentiable" begin
@testset "$T" for T in interpolations_f
interp = T(u, t)
@test J(interp, 2.0) [1;;]
@testset "First-order differentiable" begin
@testset "$T" for T in interpolations_f
interp = T(u, t)
@test J(interp, 2.0) [1;;]
end
end
end
@testset "Second-order differentiable" begin
@testset "$T" for T in interpolations_s
interp = T(u, t)
@test J(interp, 2.0) [1;;]
@testset "Second-order differentiable" begin
@testset "$T" for T in interpolations_s
interp = T(u, t)
@test J(interp, 2.0) [1;;]
end
end
end
end

# TODO: add tests
# @testset "Jacobian Local" begin
# method = TracerLocalSparsityDetector()
# J(f, x) = jacobian_sparsity(f, x, method)
# end

@testset "Global Hessian" begin
method = TracerSparsityDetector()
H(f, x) = hessian_sparsity(f, x, method)
@testset "Hessian" begin
@testset "$M" for M in (TracerSparsityDetector, TracerLocalSparsityDetector)
method = M()
H(f, x) = hessian_sparsity(f, x, method)

@testset "Non-differentiable" begin
@testset "$T" for T in interpolations_z
interp = T(u, t)
@test H(interp, 2.0) [0;;]
@testset "Non-differentiable" begin
@testset "$T" for T in interpolations_z
interp = T(u, t)
@test H(interp, 2.0) [0;;]
end
end
end
@testset "First-order differentiable" begin
@testset "$T" for T in interpolations_f
interp = T(u, t)
@test H(interp, 2.0) [0;;]
@testset "First-order differentiable" begin
@testset "$T" for T in interpolations_f
interp = T(u, t)
@test H(interp, 2.0) [0;;]
end
end
end
@testset "Second-order differentiable" begin
@testset "$T" for T in interpolations_s
interp = T(u, t)
@test H(interp, 2.0) [1;;]
@testset "Second-order differentiable" begin
@testset "$T" for T in interpolations_s
interp = T(u, t)
@test H(interp, 2.0) [1;;]
end
end
end
end

# TODO: add tests
# @testset "Local Hessian" begin
# method = TracerLocalSparsityDetector()
# H(f, x) = hessian_sparsity(f, x, method)
# end

0 comments on commit c0076fa

Please sign in to comment.