From b2a3a68907c2cabded98ccdd40dcc07c4d2b4018 Mon Sep 17 00:00:00 2001 From: ChrisRackauckas-Claude Date: Sun, 14 Jun 2026 20:31:52 -0400 Subject: [PATCH] Migrate off ReTestItems to SciMLTesting v1.2 Replace the ReTestItems-based test/runtests.jl (GROUP -> tag dispatch over @testitem blocks) with the SciMLTesting v1.2 folder-discovery model: * test/runtests.jl is now `using SciMLTesting; run_tests()`. * @testitem blocks become plain self-contained @testset files placed by group: Core lane stays at top-level test/*.jl (native line search custom-optimizer + Newton-Raphson + Strong Wolfe edge cases), the LineSearchesJL lane moves to test/linesearchesjl/, and the QA (ExplicitImports) lane moves to test/qa/ with its own sub-env Project.toml. * The @testsetup modules (CustomOptimizer / RootFinding) are inlined into each file that uses them so every file runs self-contained in its own @safetestset. * test_groups.toml keeps the same CI matrix cells (Core, LineSearchesJL, QA); QA gets in_all = false for clarity. * Root Project.toml drops ReTestItems/Hwloc/InteractiveUtils and the unused NonlinearProblemLibrary, moves ExplicitImports into the qa sub-env, and adds SciMLTesting + SafeTestsets to [extras]/[compat]/ [targets].test. The separate Enzyme CI job (test/enzyme/, run directly via its own Project.toml, outside the GROUP mechanism) is unchanged. Verified locally on Julia 1.11: GROUP=Core (144+85), GROUP=LineSearchesJL (96+80), and GROUP=QA (2) all pass. Co-Authored-By: Chris Rackauckas Co-Authored-By: Claude Opus 4.8 (1M context) --- Project.toml | 16 +- test/custom_optimizer_tests.jl | 118 ++++---------- test/linesearchesjl/custom_optimizer_tests.jl | 107 ++++++++++++ test/linesearchesjl/root_finding_tests.jl | 130 +++++++++++++++ test/qa/Project.toml | 15 ++ test/{ => qa}/explicit_imports_test.jl | 4 +- test/root_finding_tests.jl | 154 ++++++------------ test/runtests.jl | 40 +---- test/test_groups.toml | 1 + 9 files changed, 350 insertions(+), 235 deletions(-) create mode 100644 test/linesearchesjl/custom_optimizer_tests.jl create mode 100644 test/linesearchesjl/root_finding_tests.jl create mode 100644 test/qa/Project.toml rename test/{ => qa}/explicit_imports_test.jl (60%) diff --git a/Project.toml b/Project.toml index 872fb63..ab3d3cd 100644 --- a/Project.toml +++ b/Project.toml @@ -26,21 +26,18 @@ ADTypes = "1.9" CommonSolve = "0.2.4" ConcreteStructs = "0.2.3" DifferentiationInterface = "0.6.2, 0.7" -ExplicitImports = "1.14.0" FastClosures = "0.3.2" FiniteDiff = "2.24.0" ForwardDiff = "0.10.36, 1" -Hwloc = "3" -InteractiveUtils = "<0.0.1, 1" LineSearches = "7.3.0" LinearAlgebra = "1.10" MaybeInplace = "0.1.4" -NonlinearProblemLibrary = "0.1.2" PrecompileTools = "1.2.0" -ReTestItems = "1.28.0" ReverseDiff = "1.15.3" +SafeTestsets = "0.1, 1" SciMLBase = "2.54.0, 3.0" SciMLJacobianOperators = "0.1" +SciMLTesting = "1" StaticArraysCore = "1.4" Test = "1.10" Tracker = "0.2.35" @@ -49,18 +46,15 @@ julia = "1.10" [extras] DifferentiationInterface = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63" -ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7" FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41" ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" -Hwloc = "0e44f5e4-bd66-52a0-8798-143a42290a1d" -InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" LineSearches = "d3d80556-e9d4-5f37-9878-2ab0fcc64255" -NonlinearProblemLibrary = "b7050fa9-e91f-4b37-bcee-a89a063da141" -ReTestItems = "817f1d60-ba6b-4fd5-9520-3cf149f6a823" ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" +SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" +SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" [targets] -test = ["DifferentiationInterface", "ExplicitImports", "FiniteDiff", "ForwardDiff", "Hwloc", "InteractiveUtils", "LineSearches", "NonlinearProblemLibrary", "ReTestItems", "ReverseDiff", "Test", "Tracker", "Zygote"] +test = ["DifferentiationInterface", "FiniteDiff", "ForwardDiff", "LineSearches", "ReverseDiff", "SafeTestsets", "SciMLTesting", "Test", "Tracker", "Zygote"] diff --git a/test/custom_optimizer_tests.jl b/test/custom_optimizer_tests.jl index c9e2f2a..24d7738 100644 --- a/test/custom_optimizer_tests.jl +++ b/test/custom_optimizer_tests.jl @@ -1,36 +1,14 @@ # Test based on https://julianlsolvers.github.io/LineSearches.jl/stable/examples/generated/customoptimizer.html -# Note: Enzyme tests are in a separate test group (test/enzyme/) -@testsetup module CustomOptimizer -using LinearAlgebra, SciMLBase, LineSearch, SciMLJacobianOperators - -function gradient_descent( - prob, alg; g_atol::Real = 1.0e-5, maxiters::Int = 10000, autodiff = nothing - ) - u = copy(prob.u0) - if SciMLBase.isinplace(prob) - fu = similar(u) - prob.f(fu, u, prob.p) - else - fu = prob.f(u, prob.p) - end - - ls_cache = init(prob, alg, fu, u) - vjp_op = VecJacOperator(prob, fu, u; autodiff) - - alphas = Float64[] - iter = 0 - for _ in 1:maxiters - iter += 1 - svjp_op = StatefulJacobianOperator(vjp_op, u, prob.p) - gs = svjp_op * fu .* 2 - δu = -gs +# Note: Enzyme tests are in a separate test group (test/enzyme/), LineSearches.jl tests in test/linesearchesjl/ +using LineSearch, Test - ls_sol = solve!(ls_cache, u, δu) - - push!(alphas, ls_sol.step_size) - @. u = u + ls_sol.step_size * δu - gnorm = norm(gs) +module CustomOptimizer + using LinearAlgebra, SciMLBase, LineSearch, SciMLJacobianOperators + function gradient_descent( + prob, alg; g_atol::Real = 1.0e-5, maxiters::Int = 10000, autodiff = nothing + ) + u = copy(prob.u0) if SciMLBase.isinplace(prob) fu = similar(u) prob.f(fu, u, prob.p) @@ -38,71 +16,45 @@ function gradient_descent( fu = prob.f(u, prob.p) end - LineSearch.callback_into_cache!(ls_cache, fu) + ls_cache = init(prob, alg, fu, u) + vjp_op = VecJacOperator(prob, fu, u; autodiff) - gnorm < g_atol && break - end + alphas = Float64[] + iter = 0 + for _ in 1:maxiters + iter += 1 + svjp_op = StatefulJacobianOperator(vjp_op, u, prob.p) + gs = svjp_op * fu .* 2 + δu = -gs - return fu, u, iter, alphas -end + ls_sol = solve!(ls_cache, u, δu) -export gradient_descent + push!(alphas, ls_sol.step_size) + @. u = u + ls_sol.step_size * δu + gnorm = norm(gs) -end + if SciMLBase.isinplace(prob) + fu = similar(u) + prob.f(fu, u, prob.p) + else + fu = prob.f(u, prob.p) + end -@testitem "LineSearches.jl: Custom Optimizer" tags = [:linesearchesjl] setup = [CustomOptimizer] begin - using LineSearches, SciMLBase - using ADTypes, Tracker, ForwardDiff, Zygote, ReverseDiff, FiniteDiff + LineSearch.callback_into_cache!(ls_cache, fu) - @testset "OOP Problem" begin - nlf(x, p) = [p[1] - x[1], 10.0 * (x[2] - x[1]^2)] - nlp = NonlinearProblem(nlf, [-1.0, 1.0], [1.0]) - - @testset for autodiff in ( - AutoTracker(), AutoForwardDiff(), AutoZygote(), - AutoReverseDiff(), AutoFiniteDiff(), - ) - @testset "method: $(nameof(typeof(method)))" for method in ( - LineSearches.BackTracking(; order = 3), - StrongWolfe(), - HagerZhang(), - MoreThuente(), - ) - linesearch = LineSearchesJL(; method, autodiff) - fu, u, iter, alphas = gradient_descent(nlp, linesearch; autodiff) - - @test fu ≈ [0.0, 0.0] atol = 1.0e-2 - @test u ≈ [1.0, 1.0] atol = 1.0e-2 - @test !all(isone, alphas) - end + gnorm < g_atol && break end - end - @testset "In-Place Problem" begin - nlf(dx, x, p) = (dx .= [p[1] - x[1], 10.0 * (x[2] - x[1]^2)]) - nlp = NonlinearProblem(nlf, [-1.0, 1.0], [1.0]) + return fu, u, iter, alphas + end - @testset for autodiff in ( - AutoForwardDiff(), AutoReverseDiff(), AutoFiniteDiff(), - ) - @testset "method: $(nameof(typeof(method)))" for method in ( - LineSearches.BackTracking(; order = 3), - StrongWolfe(), - HagerZhang(), - MoreThuente(), - ) - linesearch = LineSearchesJL(; method, autodiff) - fu, u, iter, alphas = gradient_descent(nlp, linesearch; autodiff) + export gradient_descent - @test fu ≈ [0.0, 0.0] atol = 1.0e-2 - @test u ≈ [1.0, 1.0] atol = 1.0e-2 - @test !all(isone, alphas) - end - end - end end -@testitem "Native Line Search: Custom Optimizer" tags = [:core] setup = [CustomOptimizer] begin +using .CustomOptimizer + +@testset "Native Line Search: Custom Optimizer" begin using SciMLBase using ADTypes, Tracker, ForwardDiff, Zygote, ReverseDiff, FiniteDiff diff --git a/test/linesearchesjl/custom_optimizer_tests.jl b/test/linesearchesjl/custom_optimizer_tests.jl new file mode 100644 index 0000000..91ae080 --- /dev/null +++ b/test/linesearchesjl/custom_optimizer_tests.jl @@ -0,0 +1,107 @@ +# LineSearches.jl extension: custom optimizer tests +# Based on https://julianlsolvers.github.io/LineSearches.jl/stable/examples/generated/customoptimizer.html +using LineSearch, Test + +module CustomOptimizer + using LinearAlgebra, SciMLBase, LineSearch, SciMLJacobianOperators + + function gradient_descent( + prob, alg; g_atol::Real = 1.0e-5, maxiters::Int = 10000, autodiff = nothing + ) + u = copy(prob.u0) + if SciMLBase.isinplace(prob) + fu = similar(u) + prob.f(fu, u, prob.p) + else + fu = prob.f(u, prob.p) + end + + ls_cache = init(prob, alg, fu, u) + vjp_op = VecJacOperator(prob, fu, u; autodiff) + + alphas = Float64[] + iter = 0 + for _ in 1:maxiters + iter += 1 + svjp_op = StatefulJacobianOperator(vjp_op, u, prob.p) + gs = svjp_op * fu .* 2 + δu = -gs + + ls_sol = solve!(ls_cache, u, δu) + + push!(alphas, ls_sol.step_size) + @. u = u + ls_sol.step_size * δu + gnorm = norm(gs) + + if SciMLBase.isinplace(prob) + fu = similar(u) + prob.f(fu, u, prob.p) + else + fu = prob.f(u, prob.p) + end + + LineSearch.callback_into_cache!(ls_cache, fu) + + gnorm < g_atol && break + end + + return fu, u, iter, alphas + end + + export gradient_descent + +end + +using .CustomOptimizer + +@testset "LineSearches.jl: Custom Optimizer" begin + using LineSearches, SciMLBase + using ADTypes, Tracker, ForwardDiff, Zygote, ReverseDiff, FiniteDiff + + @testset "OOP Problem" begin + nlf(x, p) = [p[1] - x[1], 10.0 * (x[2] - x[1]^2)] + nlp = NonlinearProblem(nlf, [-1.0, 1.0], [1.0]) + + @testset for autodiff in ( + AutoTracker(), AutoForwardDiff(), AutoZygote(), + AutoReverseDiff(), AutoFiniteDiff(), + ) + @testset "method: $(nameof(typeof(method)))" for method in ( + LineSearches.BackTracking(; order = 3), + StrongWolfe(), + HagerZhang(), + MoreThuente(), + ) + linesearch = LineSearchesJL(; method, autodiff) + fu, u, iter, alphas = gradient_descent(nlp, linesearch; autodiff) + + @test fu ≈ [0.0, 0.0] atol = 1.0e-2 + @test u ≈ [1.0, 1.0] atol = 1.0e-2 + @test !all(isone, alphas) + end + end + end + + @testset "In-Place Problem" begin + nlf(dx, x, p) = (dx .= [p[1] - x[1], 10.0 * (x[2] - x[1]^2)]) + nlp = NonlinearProblem(nlf, [-1.0, 1.0], [1.0]) + + @testset for autodiff in ( + AutoForwardDiff(), AutoReverseDiff(), AutoFiniteDiff(), + ) + @testset "method: $(nameof(typeof(method)))" for method in ( + LineSearches.BackTracking(; order = 3), + StrongWolfe(), + HagerZhang(), + MoreThuente(), + ) + linesearch = LineSearchesJL(; method, autodiff) + fu, u, iter, alphas = gradient_descent(nlp, linesearch; autodiff) + + @test fu ≈ [0.0, 0.0] atol = 1.0e-2 + @test u ≈ [1.0, 1.0] atol = 1.0e-2 + @test !all(isone, alphas) + end + end + end +end diff --git a/test/linesearchesjl/root_finding_tests.jl b/test/linesearchesjl/root_finding_tests.jl new file mode 100644 index 0000000..1f15670 --- /dev/null +++ b/test/linesearchesjl/root_finding_tests.jl @@ -0,0 +1,130 @@ +# LineSearches.jl extension: Newton Raphson root-finding tests +using LineSearch, Test + +module RootFinding + + using SciMLBase, DifferentiationInterface, ForwardDiff + using SciMLBase: AbstractNonlinearProblem + const DI = DifferentiationInterface + + function newton_raphson(prob::AbstractNonlinearProblem, ls) + if SciMLBase.isinplace(prob) + return newton_raphson_iip(prob, ls) + else + return newton_raphson_oop(prob, ls) + end + end + + function newton_raphson_oop(prob::AbstractNonlinearProblem, ls) + u = copy(prob.u0) + fu = prob.f(u, prob.p) + + ls_cache = init(prob, ls, fu, u) + + alphas = Float64[] + iter = 0 + for _ in 1:100 + iter += 1 + + maximum(abs, fu) < 1.0e-8 && return true, fu, u, iter, alphas + + J = DI.jacobian(prob.f, AutoForwardDiff(), u, Constant(prob.p)) + δu = -J \ fu + + ls_sol = solve!(ls_cache, u, δu) + + push!(alphas, ls_sol.step_size) + @. u = u + ls_sol.step_size * δu + + fu = prob.f(u, prob.p) + end + + return false, fu, u, iter, alphas + end + + function newton_raphson_iip(prob::AbstractNonlinearProblem, ls) + u = copy(prob.u0) + fu = similar(u) + fu2 = similar(u) + prob.f(fu, u, prob.p) + + ls_cache = init(prob, ls, fu, u) + + alphas = Float64[] + iter = 0 + for _ in 1:100 + iter += 1 + + maximum(abs, fu) < 1.0e-8 && return true, fu, u, iter, alphas + + J = DI.jacobian(prob.f, fu2, AutoForwardDiff(), u, Constant(prob.p)) + δu = -J \ fu + + ls_sol = solve!(ls_cache, u, δu) + + push!(alphas, ls_sol.step_size) + @. u = u + ls_sol.step_size * δu + + prob.f(fu, u, prob.p) + end + + return false, fu, u, iter, alphas + end + + export newton_raphson + +end + +using .RootFinding + +@testset "LineSearches.jl: Newton Raphson" begin + using LineSearches, SciMLBase + using ADTypes, Tracker, ForwardDiff, Zygote, ReverseDiff, FiniteDiff + + @testset "OOP Problem" begin + nlf(x, p) = x .^ 2 .- p + nlp = NonlinearProblem(nlf, [-1.0, 1.0], [3.0]) + + @testset for autodiff in ( + AutoTracker(), AutoForwardDiff(), AutoZygote(), + AutoReverseDiff(), AutoFiniteDiff(), + ) + @testset "method: $(nameof(typeof(method)))" for method in ( + LineSearches.BackTracking(; order = 3), + StrongWolfe(), + HagerZhang(), + MoreThuente(), + Static(), + ) + linesearch = LineSearchesJL(; method, autodiff) + converged, fu, u, iter, alphas = newton_raphson(nlp, linesearch) + + @test fu ≈ [0.0, 0.0] atol = 1.0e-3 + @test abs.(u) ≈ sqrt.([3.0, 3.0]) atol = 1.0e-3 + end + end + end + + @testset "In-Place Problem" begin + nlf(dx, x, p) = (dx .= x .^ 2 .- p) + nlp = NonlinearProblem(nlf, [-1.0, 1.0], [3.0]) + + @testset for autodiff in ( + AutoForwardDiff(), AutoReverseDiff(), AutoFiniteDiff(), + ) + @testset "method: $(nameof(typeof(method)))" for method in ( + LineSearches.BackTracking(; order = 3), + StrongWolfe(), + HagerZhang(), + MoreThuente(), + Static(), + ) + linesearch = LineSearchesJL(; method, autodiff) + converged, fu, u, iter, alphas = newton_raphson(nlp, linesearch) + + @test fu ≈ [0.0, 0.0] atol = 1.0e-3 + @test abs.(u) ≈ sqrt.([3.0, 3.0]) atol = 1.0e-3 + end + end + end +end diff --git a/test/qa/Project.toml b/test/qa/Project.toml new file mode 100644 index 0000000..6615219 --- /dev/null +++ b/test/qa/Project.toml @@ -0,0 +1,15 @@ +[deps] +ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7" +LineSearch = "87fe0de2-c867-4266-b59a-2f0a94fc965b" +SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" +SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[sources] +LineSearch = {path = "../.."} + +[compat] +ExplicitImports = "1.14.0" +SafeTestsets = "0.1, 1" +SciMLTesting = "1" +Test = "1.10" diff --git a/test/explicit_imports_test.jl b/test/qa/explicit_imports_test.jl similarity index 60% rename from test/explicit_imports_test.jl rename to test/qa/explicit_imports_test.jl index 3022a3d..0e261e4 100644 --- a/test/explicit_imports_test.jl +++ b/test/qa/explicit_imports_test.jl @@ -1,6 +1,6 @@ -@testitem "Explicit Imports" tags = [:qa] begin - using ExplicitImports, LineSearch +using ExplicitImports, LineSearch, Test +@testset "Explicit Imports" begin @test check_no_implicit_imports(LineSearch) === nothing @test check_no_stale_explicit_imports(LineSearch) === nothing end diff --git a/test/root_finding_tests.jl b/test/root_finding_tests.jl index 692bb21..d13dc3d 100644 --- a/test/root_finding_tests.jl +++ b/test/root_finding_tests.jl @@ -1,133 +1,85 @@ # Here we write out Newton Raphson and test integration with LineSearch.jl. Main tests are # over at NonlinearSolve.jl and SimpleNonlinearSolve.jl -# Note: Enzyme tests are in a separate test group (test/enzyme/) -@testsetup module RootFinding - -using SciMLBase, DifferentiationInterface, ForwardDiff -using SciMLBase: AbstractNonlinearProblem -const DI = DifferentiationInterface - -function newton_raphson(prob::AbstractNonlinearProblem, ls) - if SciMLBase.isinplace(prob) - return newton_raphson_iip(prob, ls) - else - return newton_raphson_oop(prob, ls) - end -end - -function newton_raphson_oop(prob::AbstractNonlinearProblem, ls) - u = copy(prob.u0) - fu = prob.f(u, prob.p) - - ls_cache = init(prob, ls, fu, u) - - alphas = Float64[] - iter = 0 - for _ in 1:100 - iter += 1 - - maximum(abs, fu) < 1.0e-8 && return true, fu, u, iter, alphas +# Note: Enzyme tests are in a separate test group (test/enzyme/), LineSearches.jl tests in test/linesearchesjl/ +using LineSearch, Test - J = DI.jacobian(prob.f, AutoForwardDiff(), u, Constant(prob.p)) - δu = -J \ fu +module RootFinding - ls_sol = solve!(ls_cache, u, δu) + using SciMLBase, DifferentiationInterface, ForwardDiff + using SciMLBase: AbstractNonlinearProblem + const DI = DifferentiationInterface - push!(alphas, ls_sol.step_size) - @. u = u + ls_sol.step_size * δu + function newton_raphson(prob::AbstractNonlinearProblem, ls) + if SciMLBase.isinplace(prob) + return newton_raphson_iip(prob, ls) + else + return newton_raphson_oop(prob, ls) + end + end + function newton_raphson_oop(prob::AbstractNonlinearProblem, ls) + u = copy(prob.u0) fu = prob.f(u, prob.p) - end - return false, fu, u, iter, alphas -end + ls_cache = init(prob, ls, fu, u) -function newton_raphson_iip(prob::AbstractNonlinearProblem, ls) - u = copy(prob.u0) - fu = similar(u) - fu2 = similar(u) - prob.f(fu, u, prob.p) + alphas = Float64[] + iter = 0 + for _ in 1:100 + iter += 1 - ls_cache = init(prob, ls, fu, u) + maximum(abs, fu) < 1.0e-8 && return true, fu, u, iter, alphas - alphas = Float64[] - iter = 0 - for _ in 1:100 - iter += 1 + J = DI.jacobian(prob.f, AutoForwardDiff(), u, Constant(prob.p)) + δu = -J \ fu - maximum(abs, fu) < 1.0e-8 && return true, fu, u, iter, alphas + ls_sol = solve!(ls_cache, u, δu) - J = DI.jacobian(prob.f, fu2, AutoForwardDiff(), u, Constant(prob.p)) - δu = -J \ fu + push!(alphas, ls_sol.step_size) + @. u = u + ls_sol.step_size * δu - ls_sol = solve!(ls_cache, u, δu) + fu = prob.f(u, prob.p) + end - push!(alphas, ls_sol.step_size) - @. u = u + ls_sol.step_size * δu + return false, fu, u, iter, alphas + end + function newton_raphson_iip(prob::AbstractNonlinearProblem, ls) + u = copy(prob.u0) + fu = similar(u) + fu2 = similar(u) prob.f(fu, u, prob.p) - end - return false, fu, u, iter, alphas -end + ls_cache = init(prob, ls, fu, u) -export newton_raphson + alphas = Float64[] + iter = 0 + for _ in 1:100 + iter += 1 -end + maximum(abs, fu) < 1.0e-8 && return true, fu, u, iter, alphas -@testitem "LineSearches.jl: Newton Raphson" tags = [:linesearchesjl] setup = [RootFinding] begin - using LineSearches, SciMLBase - using ADTypes, Tracker, ForwardDiff, Zygote, ReverseDiff, FiniteDiff + J = DI.jacobian(prob.f, fu2, AutoForwardDiff(), u, Constant(prob.p)) + δu = -J \ fu - @testset "OOP Problem" begin - nlf(x, p) = x .^ 2 .- p - nlp = NonlinearProblem(nlf, [-1.0, 1.0], [3.0]) + ls_sol = solve!(ls_cache, u, δu) - @testset for autodiff in ( - AutoTracker(), AutoForwardDiff(), AutoZygote(), - AutoReverseDiff(), AutoFiniteDiff(), - ) - @testset "method: $(nameof(typeof(method)))" for method in ( - LineSearches.BackTracking(; order = 3), - StrongWolfe(), - HagerZhang(), - MoreThuente(), - Static(), - ) - linesearch = LineSearchesJL(; method, autodiff) - converged, fu, u, iter, alphas = newton_raphson(nlp, linesearch) + push!(alphas, ls_sol.step_size) + @. u = u + ls_sol.step_size * δu - @test fu ≈ [0.0, 0.0] atol = 1.0e-3 - @test abs.(u) ≈ sqrt.([3.0, 3.0]) atol = 1.0e-3 - end + prob.f(fu, u, prob.p) end - end - @testset "In-Place Problem" begin - nlf(dx, x, p) = (dx .= x .^ 2 .- p) - nlp = NonlinearProblem(nlf, [-1.0, 1.0], [3.0]) + return false, fu, u, iter, alphas + end - @testset for autodiff in ( - AutoForwardDiff(), AutoReverseDiff(), AutoFiniteDiff(), - ) - @testset "method: $(nameof(typeof(method)))" for method in ( - LineSearches.BackTracking(; order = 3), - StrongWolfe(), - HagerZhang(), - MoreThuente(), - Static(), - ) - linesearch = LineSearchesJL(; method, autodiff) - converged, fu, u, iter, alphas = newton_raphson(nlp, linesearch) + export newton_raphson - @test fu ≈ [0.0, 0.0] atol = 1.0e-3 - @test abs.(u) ≈ sqrt.([3.0, 3.0]) atol = 1.0e-3 - end - end - end end -@testitem "Native Line Search: Newton Raphson" tags = [:core] setup = [RootFinding] begin +using .RootFinding + +@testset "Native Line Search: Newton Raphson" begin using SciMLBase using ADTypes, Tracker, ForwardDiff, Zygote, ReverseDiff, FiniteDiff @@ -201,7 +153,7 @@ end end end -@testitem "Native Strong Wolfe edge cases" tags = [:core] begin +@testset "Native Strong Wolfe edge cases" begin quadratic_eval(α) = (0.5 * (α - 1.0)^2, α - 1.0) @testset "initial convergence" begin diff --git a/test/runtests.jl b/test/runtests.jl index c60f2d1..a18a7cc 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,38 +1,2 @@ -using ReTestItems, LineSearch, Hwloc, InteractiveUtils - -@info sprint(InteractiveUtils.versioninfo) - -const GROUP = get(ENV, "GROUP", "All") - -const RETESTITEMS_NWORKERS = parse( - Int, get(ENV, "RETESTITEMS_NWORKERS", string(min(Hwloc.num_physical_cores(), 4))) -) -const RETESTITEMS_NWORKER_THREADS = parse( - Int, - get( - ENV, "RETESTITEMS_NWORKER_THREADS", - string(max(Hwloc.num_virtual_cores() ÷ RETESTITEMS_NWORKERS, 1)) - ) -) - -# Map GROUP to testitem tags -const GROUP_TAGS = Dict( - "All" => nothing, # Run all tests - "Core" => [:core], # Native line search tests - "LineSearchesJL" => [:linesearchesjl], # LineSearches.jl extension tests - "QA" => [:qa] # Quality assurance tests (ExplicitImports) -) - -if !haskey(GROUP_TAGS, GROUP) - error("Unknown test group: $(GROUP). Valid groups: $(join(keys(GROUP_TAGS), ", "))") -end - -const TAGS = GROUP_TAGS[GROUP] - -@info "Running tests for group: $(GROUP) with $(RETESTITEMS_NWORKERS) workers" - -ReTestItems.runtests( - LineSearch; tags = TAGS, - nworkers = RETESTITEMS_NWORKERS, nworker_threads = RETESTITEMS_NWORKER_THREADS, - testitem_timeout = 3600 -) +using SciMLTesting +run_tests() diff --git a/test/test_groups.toml b/test/test_groups.toml index 8f01bd4..b84e060 100644 --- a/test/test_groups.toml +++ b/test/test_groups.toml @@ -6,3 +6,4 @@ versions = ["1", "lts"] [QA] versions = ["1"] +in_all = false