Skip to content

fix: failing tests #580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/CI_BracketingNonlinearSolve.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: CI (BracketingNonlinearSolve)

on:
pull_request:
branches:
- master
paths:
- "lib/BracketingNonlinearSolve/**"
- ".github/workflows/CI_BracketingNonlinearSolve.yml"
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/CI_NonlinearSolve.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: CI (NonlinearSolve)

on:
pull_request:
branches:
- master
paths:
- "src/**"
- "ext/**"
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/CI_NonlinearSolveBase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: CI (NonlinearSolveBase)

on:
pull_request:
branches:
- master
paths:
- "lib/NonlinearSolveBase/**"
- ".github/workflows/CI_NonlinearSolveBase.yml"
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/CI_NonlinearSolveFirstOrder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: CI (NonlinearSolveFirstOrder)

on:
pull_request:
branches:
- master
paths:
- "lib/NonlinearSolveFirstOrder/**"
- ".github/workflows/CI_NonlinearSolveFirstOrder.yml"
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/CI_NonlinearSolveHomotopyContinuation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: CI (NonlinearSolveHomotopyContinuation)

on:
pull_request:
branches:
- master
paths:
- "lib/NonlinearSolveHomotopyContinuation/**"
- ".github/workflows/CI_NonlinearSolveHomotopyContinuation.yml"
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/CI_NonlinearSolveQuasiNewton.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: CI (NonlinearSolveQuasiNewton)

on:
pull_request:
branches:
- master
paths:
- "lib/NonlinearSolveQuasiNewton/**"
- ".github/workflows/CI_NonlinearSolveQuasiNewton.yml"
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/CI_NonlinearSolveSpectralMethods.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: CI (NonlinearSolveSpectralMethods)

on:
pull_request:
branches:
- master
paths:
- "lib/NonlinearSolveSpectralMethods/**"
- ".github/workflows/CI_NonlinearSolveSpectralMethods.yml"
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/CI_SCCNonlinearSolve.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: CI (SCCNonlinearSolve)

on:
pull_request:
branches:
- master
paths:
- "lib/SCCNonlinearSolve/**"
- ".github/workflows/CI_SCCNonlinearSolve.yml"
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/CI_SciMLJacobianOperators.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: CI (SciMLJacobianOperators)

on:
pull_request:
branches:
- master
paths:
- "lib/SciMLJacobianOperators/**"
- ".github/workflows/CI_SciMLJacobianOperators.yml"
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/CI_SimpleNonlinearSolve.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: CI (SimpleNonlinearSolve)

on:
pull_request:
branches:
- master
paths:
- "lib/SimpleNonlinearSolve/**"
- ".github/workflows/CI_SimpleNonlinearSolve.yml"
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Random = "1.10"
ReTestItems = "1.24"
Reexport = "1.2"
SIAMFANLEquations = "1.0.1"
SciMLBase = "2.68.1"
SciMLBase = "2.69"
SimpleNonlinearSolve = "2.1"
SparseArrays = "1.10"
SparseConnectivityTracer = "0.6.5"
Expand Down
2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ OrdinaryDiffEqTsit5 = "1.1.0"
PETSc = "0.3"
Plots = "1"
Random = "1.10"
SciMLBase = "2.68.1"
SciMLBase = "2.69"
SciMLJacobianOperators = "0.1"
SimpleNonlinearSolve = "2"
SparseConnectivityTracer = "0.6.5"
Expand Down
2 changes: 1 addition & 1 deletion lib/BracketingNonlinearSolve/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ InteractiveUtils = "<0.0.1, 1"
NonlinearSolveBase = "1.1"
PrecompileTools = "1.2"
Reexport = "1.2"
SciMLBase = "2.68.1"
SciMLBase = "2.69"
Test = "1.10"
TestItemRunner = "1"
julia = "1.10"
Expand Down
2 changes: 1 addition & 1 deletion lib/NonlinearSolveBase/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ MaybeInplace = "0.1.4"
Preferences = "1.4"
Printf = "1.10"
RecursiveArrayTools = "3"
SciMLBase = "2.68.1"
SciMLBase = "2.69"
SciMLJacobianOperators = "0.1.1"
SciMLOperators = "0.3.13"
SparseArrays = "1.10"
Expand Down
2 changes: 1 addition & 1 deletion lib/NonlinearSolveFirstOrder/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ PrecompileTools = "1.2"
Random = "1.10"
ReTestItems = "1.24"
Reexport = "1"
SciMLBase = "2.68.1"
SciMLBase = "2.69"
SciMLJacobianOperators = "0.1.0"
Setfield = "1.1.1"
SparseArrays = "1.10"
Expand Down
2 changes: 1 addition & 1 deletion lib/NonlinearSolveQuasiNewton/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Pkg = "1.10"
PrecompileTools = "1.2"
ReTestItems = "1.24"
Reexport = "1"
SciMLBase = "2.68.1"
SciMLBase = "2.69"
SciMLOperators = "0.3.13"
StableRNGs = "1"
StaticArrays = "1.9.8"
Expand Down
2 changes: 1 addition & 1 deletion lib/NonlinearSolveSpectralMethods/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Pkg = "1.10"
PrecompileTools = "1.2"
ReTestItems = "1.24"
Reexport = "1"
SciMLBase = "2.68.1"
SciMLBase = "2.69"
StableRNGs = "1"
StaticArrays = "1.9.8"
Test = "1.10"
Expand Down
2 changes: 1 addition & 1 deletion lib/SCCNonlinearSolve/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Pkg = "1.10"
PrecompileTools = "1.2"
ReTestItems = "1.24"
Reexport = "1"
SciMLBase = "2.68.1"
SciMLBase = "2.69"
StableRNGs = "1"
StaticArrays = "1.9.8"
SymbolicIndexingInterface = "0.3.36"
Expand Down
2 changes: 1 addition & 1 deletion lib/SciMLJacobianOperators/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ForwardDiff = "0.10.36, 1"
InteractiveUtils = "<0.0.1, 1"
LinearAlgebra = "1.10"
ReverseDiff = "1.15"
SciMLBase = "2.68.1"
SciMLBase = "2.69"
SciMLOperators = "0.3.13"
Test = "1.10"
TestItemRunner = "1"
Expand Down
4 changes: 2 additions & 2 deletions lib/SimpleNonlinearSolve/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SimpleNonlinearSolve"
uuid = "727e6d20-b764-4bd8-a329-72de5adea6c7"
authors = ["SciML"]
version = "2.2.1"
version = "2.2.2"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down Expand Up @@ -66,7 +66,7 @@ PrecompileTools = "1.2"
Random = "1.10"
Reexport = "1.2"
ReverseDiff = "1.15"
SciMLBase = "2.68.1"
SciMLBase = "2.69"
Setfield = "1.1.1"
StaticArrays = "1.9"
StaticArraysCore = "1.4.3"
Expand Down
3 changes: 2 additions & 1 deletion lib/SimpleNonlinearSolve/src/halley.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ function SciMLBase.__solve(
end

aᵢ = J_fact \ NLBUtils.safe_vec(fx)
hvvp = Utils.compute_hvvp(prob, autodiff, fx_cache, x, aᵢ)
hvvp = Utils.compute_hvvp(
prob, autodiff, fx_cache, x, NLBUtils.restructure(x, aᵢ))
bᵢ = J_fact \ NLBUtils.safe_vec(hvvp)

cᵢ_ = NLBUtils.safe_vec(cᵢ)
Expand Down
3 changes: 2 additions & 1 deletion lib/SimpleNonlinearSolve/src/lbroyden.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@ end

# For scalar problems / if the threshold is larger than problem size just use Broyden
if x isa Number || length(x) ≤ η
return SciMLBase.__solve(
sol = SciMLBase.__solve(
prob, SimpleBroyden(; alg.linesearch), args...;
abstol, reltol, maxiters, termination_condition, kwargs...
)
return Utils.nonlinear_solution_new_alg(sol, alg)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

won't this lead to type stability issues?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no this will fix it. we need to use simplebroyden for the solve process. But we ensure all branches mark the returned alg as simplelbroyden

end

fx = NLBUtils.evaluate_f(prob, x)
Expand Down
11 changes: 10 additions & 1 deletion lib/SimpleNonlinearSolve/src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,16 @@ function compute_hvvp(prob, autodiff, fx, x, dir)
else
@closure (u, p) -> only(DI.pushforward(prob.f, autodiff, u, (dir,), Constant(p)))
end
only(DI.pushforward(jvp_fn, autodiff, x, (dir,), Constant(prob.p)))
return only(DI.pushforward(jvp_fn, autodiff, x, (dir,), Constant(prob.p)))
end

function nonlinear_solution_new_alg(
sol::SciMLBase.NonlinearSolution{T, N, uType, R, P, A, O, uType2, S, Tr}, alg
) where {T, N, uType, R, P, A, O, uType2, S, Tr}
return SciMLBase.NonlinearSolution{T, N, uType, R, P, typeof(alg), O, uType2, S, Tr}(
sol.u, sol.resid, sol.prob, alg, sol.retcode, sol.original, sol.left, sol.right,
sol.stats, sol.trace
)
end

end
26 changes: 19 additions & 7 deletions lib/SimpleNonlinearSolve/test/core/rootfind_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,22 @@
AbsNormSafeBestTerminationMode(Base.Fix1(maximum, abs))
]

function run_nlsolve_oop(f::F, u0, p = 2.0; solver) where {F}
return @inferred solve(NonlinearProblem{false}(f, u0, p), solver; abstol = 1e-9)
function run_nlsolve_oop(f::F, u0, p = 2.0; solver, broken_inferred = false) where {F}
prob = NonlinearProblem{false}(f, u0, p)
@test @inferred(solve(prob, solver; abstol = 1e-9)) isa
SciMLBase.AbstractNonlinearSolution broken=broken_inferred
return solve(prob, solver; abstol = 1e-9)
end
function run_nlsolve_iip(f!::F, u0, p = 2.0; solver) where {F}
return @inferred solve(NonlinearProblem{true}(f!, u0, p), solver; abstol = 1e-9)
function run_nlsolve_iip(f!::F, u0, p = 2.0; solver, broken_inferred = false) where {F}
prob = NonlinearProblem{true}(f!, u0, p)
@test @inferred(solve(prob, solver; abstol = 1e-9)) isa
SciMLBase.AbstractNonlinearSolution broken=broken_inferred
return solve(prob, solver; abstol = 1e-9)
end
end

@testitem "First Order Methods" setup=[RootfindTestSnippet] tags=[:core] begin
for alg in (
@testset for alg in (
SimpleNewtonRaphson,
SimpleTrustRegion,
(; kwargs...) -> SimpleTrustRegion(; kwargs..., nlsolve_update_rule = Val(true))
Expand All @@ -50,7 +56,10 @@ end
)
@testset "[OOP] u0: $(typeof(u0))" for u0 in (
[1.0, 1.0], @SVector[1.0, 1.0], 1.0)
sol = run_nlsolve_oop(quadratic_f, u0; solver = alg(; autodiff))
broken_inferred = u0 isa StaticArray && (autodiff isa AutoFiniteDiff ||
(autodiff isa AutoReverseDiff && VERSION < v"1.11"))
sol = run_nlsolve_oop(quadratic_f, u0; solver = alg(; autodiff),
broken_inferred)
@test SciMLBase.successful_retcode(sol)
@test maximum(abs, quadratic_f(sol.u, 2.0)) < 1e-9
end
Expand Down Expand Up @@ -85,7 +94,10 @@ end
)
@testset "[OOP] u0: $(typeof(u0))" for u0 in (
[1.0, 1.0], @SVector[1.0, 1.0], 1.0)
sol = run_nlsolve_oop(quadratic_f, u0; solver = alg(; autodiff))
broken_inferred = u0 isa StaticArray && (autodiff isa AutoFiniteDiff ||
(autodiff isa AutoReverseDiff && VERSION < v"1.11"))
sol = run_nlsolve_oop(quadratic_f, u0; solver = alg(; autodiff),
broken_inferred)
@test SciMLBase.successful_retcode(sol)
@test maximum(abs, quadratic_f(sol.u, 2.0)) < 1e-9
end
Expand Down
Loading