From 8728b715152e7bbbdec2abccf525f4f6e4749204 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 3 Nov 2023 05:58:46 -0400 Subject: [PATCH] Test nested AD Works now. Fixes https://github.com/SciML/Integrals.jl/issues/164 Fixes https://github.com/SciML/Integrals.jl/issues/67 Fixes https://github.com/SciML/Integrals.jl/issues/76 --- test/nested_ad_tests.jl | 13 +++++++++++++ test/runtests.jl | 27 +++++++-------------------- 2 files changed, 20 insertions(+), 20 deletions(-) create mode 100644 test/nested_ad_tests.jl diff --git a/test/nested_ad_tests.jl b/test/nested_ad_tests.jl new file mode 100644 index 00000000..435abdbd --- /dev/null +++ b/test/nested_ad_tests.jl @@ -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] diff --git a/test/runtests.jl b/test/runtests.jl index 00a11307..3db4af75 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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") \ No newline at end of file