Skip to content

Commit

Permalink
Test nested AD
Browse files Browse the repository at this point in the history
Works now. Fixes #164

Fixes #67

Fixes #76
  • Loading branch information
ChrisRackauckas committed Nov 3, 2023
1 parent 91bdca9 commit 8728b71
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
13 changes: 13 additions & 0 deletions test/nested_ad_tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Integrals, ForwardDiff, Cubature, Test

my_parameters = [1.0, 2.0]
my_function(x, p) = x^2 + p[1]^3 * x + p[2]^2
function my_integration(p)
my_problem = IntegralProblem(my_function, -1.0, 1.0, p)
# return solve(my_problem, HCubatureJL(), reltol=1e-3, abstol=1e-3) # Works
return solve(my_problem, CubatureJLh(), reltol=1e-3, abstol=1e-3) # Errors
end
my_solution = my_integration(my_parameters)
@test ForwardDiff.jacobian(my_integration, my_parameters) == [0.0 8.0]
@test ForwardDiff.jacobian(x->ForwardDiff.jacobian(my_integration, x), my_parameters) == [0.0 0.0
0.0 4.0]
27 changes: 7 additions & 20 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,10 @@ using Pkg
using SafeTestsets
using Test

@time @safetestset "Interface Tests" begin
include("interface_tests.jl")
end
@time @safetestset "Derivative Tests" begin
include("derivative_tests.jl")
end
@time @safetestset "Infinite Integral Tests" begin
include("inf_integral_tests.jl")
end
@time @safetestset "Gaussian Quadrature Tests" begin
include("gaussian_quadrature_tests.jl")
end

@time @safetestset "Sampled Integration Tests" begin
include("sampled_tests.jl")
end

@time @safetestset "QuadratureFunction Tests" begin
include("quadrule_tests.jl")
end
@time @safetestset "Interface Tests" include("interface_tests.jl")
@time @safetestset "Derivative Tests" include("derivative_tests.jl")
@time @safetestset "Infinite Integral Tests" include("inf_integral_tests.jl")
@time @safetestset "Gaussian Quadrature Tests" include("gaussian_quadrature_tests.jl")
@time @safetestset "Sampled Integration Tests" include("sampled_tests.jl")
@time @safetestset "QuadratureFunction Tests" include("quadrule_tests.jl")
@time @safetestset "Nested AD Tests" include("nested_ad_tests.jl")

0 comments on commit 8728b71

Please sign in to comment.