Skip to content

Commit 21e028b

Browse files
authored
fix: failing tests (#580)
* fix: initial objective for termination conditions * test: needs NonlinearSolve * fix: halley's method for matrices * fix: return type inference * ci: run on indirect PRs * test: skip finitediff inference tests for now * fix: broken SciMLBase release
1 parent be6b9a5 commit 21e028b

24 files changed

+44
-41
lines changed

.github/workflows/CI_BracketingNonlinearSolve.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ name: CI (BracketingNonlinearSolve)
22

33
on:
44
pull_request:
5-
branches:
6-
- master
75
paths:
86
- "lib/BracketingNonlinearSolve/**"
97
- ".github/workflows/CI_BracketingNonlinearSolve.yml"

.github/workflows/CI_NonlinearSolve.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ name: CI (NonlinearSolve)
22

33
on:
44
pull_request:
5-
branches:
6-
- master
75
paths:
86
- "src/**"
97
- "ext/**"

.github/workflows/CI_NonlinearSolveBase.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ name: CI (NonlinearSolveBase)
22

33
on:
44
pull_request:
5-
branches:
6-
- master
75
paths:
86
- "lib/NonlinearSolveBase/**"
97
- ".github/workflows/CI_NonlinearSolveBase.yml"

.github/workflows/CI_NonlinearSolveFirstOrder.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ name: CI (NonlinearSolveFirstOrder)
22

33
on:
44
pull_request:
5-
branches:
6-
- master
75
paths:
86
- "lib/NonlinearSolveFirstOrder/**"
97
- ".github/workflows/CI_NonlinearSolveFirstOrder.yml"

.github/workflows/CI_NonlinearSolveHomotopyContinuation.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ name: CI (NonlinearSolveHomotopyContinuation)
22

33
on:
44
pull_request:
5-
branches:
6-
- master
75
paths:
86
- "lib/NonlinearSolveHomotopyContinuation/**"
97
- ".github/workflows/CI_NonlinearSolveHomotopyContinuation.yml"

.github/workflows/CI_NonlinearSolveQuasiNewton.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ name: CI (NonlinearSolveQuasiNewton)
22

33
on:
44
pull_request:
5-
branches:
6-
- master
75
paths:
86
- "lib/NonlinearSolveQuasiNewton/**"
97
- ".github/workflows/CI_NonlinearSolveQuasiNewton.yml"

.github/workflows/CI_NonlinearSolveSpectralMethods.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ name: CI (NonlinearSolveSpectralMethods)
22

33
on:
44
pull_request:
5-
branches:
6-
- master
75
paths:
86
- "lib/NonlinearSolveSpectralMethods/**"
97
- ".github/workflows/CI_NonlinearSolveSpectralMethods.yml"

.github/workflows/CI_SCCNonlinearSolve.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ name: CI (SCCNonlinearSolve)
22

33
on:
44
pull_request:
5-
branches:
6-
- master
75
paths:
86
- "lib/SCCNonlinearSolve/**"
97
- ".github/workflows/CI_SCCNonlinearSolve.yml"

.github/workflows/CI_SciMLJacobianOperators.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ name: CI (SciMLJacobianOperators)
22

33
on:
44
pull_request:
5-
branches:
6-
- master
75
paths:
86
- "lib/SciMLJacobianOperators/**"
97
- ".github/workflows/CI_SciMLJacobianOperators.yml"

.github/workflows/CI_SimpleNonlinearSolve.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ name: CI (SimpleNonlinearSolve)
22

33
on:
44
pull_request:
5-
branches:
6-
- master
75
paths:
86
- "lib/SimpleNonlinearSolve/**"
97
- ".github/workflows/CI_SimpleNonlinearSolve.yml"

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Random = "1.10"
111111
ReTestItems = "1.24"
112112
Reexport = "1.2"
113113
SIAMFANLEquations = "1.0.1"
114-
SciMLBase = "2.68.1"
114+
SciMLBase = "2.69"
115115
SimpleNonlinearSolve = "2.1"
116116
SparseArrays = "1.10"
117117
SparseConnectivityTracer = "0.6.5"

docs/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ OrdinaryDiffEqTsit5 = "1.1.0"
5454
PETSc = "0.3"
5555
Plots = "1"
5656
Random = "1.10"
57-
SciMLBase = "2.68.1"
57+
SciMLBase = "2.69"
5858
SciMLJacobianOperators = "0.1"
5959
SimpleNonlinearSolve = "2"
6060
SparseConnectivityTracer = "0.6.5"

lib/BracketingNonlinearSolve/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ InteractiveUtils = "<0.0.1, 1"
3030
NonlinearSolveBase = "1.1"
3131
PrecompileTools = "1.2"
3232
Reexport = "1.2"
33-
SciMLBase = "2.68.1"
33+
SciMLBase = "2.69"
3434
Test = "1.10"
3535
TestItemRunner = "1"
3636
julia = "1.10"

lib/NonlinearSolveBase/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ MaybeInplace = "0.1.4"
6868
Preferences = "1.4"
6969
Printf = "1.10"
7070
RecursiveArrayTools = "3"
71-
SciMLBase = "2.68.1"
71+
SciMLBase = "2.69"
7272
SciMLJacobianOperators = "0.1.1"
7373
SciMLOperators = "0.3.13"
7474
SparseArrays = "1.10"

lib/NonlinearSolveFirstOrder/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ PrecompileTools = "1.2"
5353
Random = "1.10"
5454
ReTestItems = "1.24"
5555
Reexport = "1"
56-
SciMLBase = "2.68.1"
56+
SciMLBase = "2.69"
5757
SciMLJacobianOperators = "0.1.0"
5858
Setfield = "1.1.1"
5959
SparseArrays = "1.10"

lib/NonlinearSolveQuasiNewton/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Pkg = "1.10"
5252
PrecompileTools = "1.2"
5353
ReTestItems = "1.24"
5454
Reexport = "1"
55-
SciMLBase = "2.68.1"
55+
SciMLBase = "2.69"
5656
SciMLOperators = "0.3.13"
5757
StableRNGs = "1"
5858
StaticArrays = "1.9.8"

lib/NonlinearSolveSpectralMethods/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Pkg = "1.10"
4141
PrecompileTools = "1.2"
4242
ReTestItems = "1.24"
4343
Reexport = "1"
44-
SciMLBase = "2.68.1"
44+
SciMLBase = "2.69"
4545
StableRNGs = "1"
4646
StaticArrays = "1.9.8"
4747
Test = "1.10"

lib/SCCNonlinearSolve/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Pkg = "1.10"
2424
PrecompileTools = "1.2"
2525
ReTestItems = "1.24"
2626
Reexport = "1"
27-
SciMLBase = "2.68.1"
27+
SciMLBase = "2.69"
2828
StableRNGs = "1"
2929
StaticArrays = "1.9.8"
3030
SymbolicIndexingInterface = "0.3.36"

lib/SciMLJacobianOperators/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ ForwardDiff = "0.10.36, 1"
2929
InteractiveUtils = "<0.0.1, 1"
3030
LinearAlgebra = "1.10"
3131
ReverseDiff = "1.15"
32-
SciMLBase = "2.68.1"
32+
SciMLBase = "2.69"
3333
SciMLOperators = "0.3.13"
3434
Test = "1.10"
3535
TestItemRunner = "1"

lib/SimpleNonlinearSolve/Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SimpleNonlinearSolve"
22
uuid = "727e6d20-b764-4bd8-a329-72de5adea6c7"
33
authors = ["SciML"]
4-
version = "2.2.1"
4+
version = "2.2.2"
55

66
[deps]
77
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
@@ -66,7 +66,7 @@ PrecompileTools = "1.2"
6666
Random = "1.10"
6767
Reexport = "1.2"
6868
ReverseDiff = "1.15"
69-
SciMLBase = "2.68.1"
69+
SciMLBase = "2.69"
7070
Setfield = "1.1.1"
7171
StaticArrays = "1.9"
7272
StaticArraysCore = "1.4.3"

lib/SimpleNonlinearSolve/src/halley.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ function SciMLBase.__solve(
7474
end
7575

7676
aᵢ = J_fact \ NLBUtils.safe_vec(fx)
77-
hvvp = Utils.compute_hvvp(prob, autodiff, fx_cache, x, aᵢ)
77+
hvvp = Utils.compute_hvvp(
78+
prob, autodiff, fx_cache, x, NLBUtils.restructure(x, aᵢ))
7879
bᵢ = J_fact \ NLBUtils.safe_vec(hvvp)
7980

8081
cᵢ_ = NLBUtils.safe_vec(cᵢ)

lib/SimpleNonlinearSolve/src/lbroyden.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,11 @@ end
6262

6363
# For scalar problems / if the threshold is larger than problem size just use Broyden
6464
if x isa Number || length(x) η
65-
return SciMLBase.__solve(
65+
sol = SciMLBase.__solve(
6666
prob, SimpleBroyden(; alg.linesearch), args...;
6767
abstol, reltol, maxiters, termination_condition, kwargs...
6868
)
69+
return Utils.nonlinear_solution_new_alg(sol, alg)
6970
end
7071

7172
fx = NLBUtils.evaluate_f(prob, x)

lib/SimpleNonlinearSolve/src/utils.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,16 @@ function compute_hvvp(prob, autodiff, fx, x, dir)
171171
else
172172
@closure (u, p) -> only(DI.pushforward(prob.f, autodiff, u, (dir,), Constant(p)))
173173
end
174-
only(DI.pushforward(jvp_fn, autodiff, x, (dir,), Constant(prob.p)))
174+
return only(DI.pushforward(jvp_fn, autodiff, x, (dir,), Constant(prob.p)))
175+
end
176+
177+
function nonlinear_solution_new_alg(
178+
sol::SciMLBase.NonlinearSolution{T, N, uType, R, P, A, O, uType2, S, Tr}, alg
179+
) where {T, N, uType, R, P, A, O, uType2, S, Tr}
180+
return SciMLBase.NonlinearSolution{T, N, uType, R, P, typeof(alg), O, uType2, S, Tr}(
181+
sol.u, sol.resid, sol.prob, alg, sol.retcode, sol.original, sol.left, sol.right,
182+
sol.stats, sol.trace
183+
)
175184
end
176185

177186
end

lib/SimpleNonlinearSolve/test/core/rootfind_tests.jl

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,22 @@
2727
AbsNormSafeBestTerminationMode(Base.Fix1(maximum, abs))
2828
]
2929

30-
function run_nlsolve_oop(f::F, u0, p = 2.0; solver) where {F}
31-
return @inferred solve(NonlinearProblem{false}(f, u0, p), solver; abstol = 1e-9)
30+
function run_nlsolve_oop(f::F, u0, p = 2.0; solver, broken_inferred = false) where {F}
31+
prob = NonlinearProblem{false}(f, u0, p)
32+
@test @inferred(solve(prob, solver; abstol = 1e-9)) isa
33+
SciMLBase.AbstractNonlinearSolution broken=broken_inferred
34+
return solve(prob, solver; abstol = 1e-9)
3235
end
33-
function run_nlsolve_iip(f!::F, u0, p = 2.0; solver) where {F}
34-
return @inferred solve(NonlinearProblem{true}(f!, u0, p), solver; abstol = 1e-9)
36+
function run_nlsolve_iip(f!::F, u0, p = 2.0; solver, broken_inferred = false) where {F}
37+
prob = NonlinearProblem{true}(f!, u0, p)
38+
@test @inferred(solve(prob, solver; abstol = 1e-9)) isa
39+
SciMLBase.AbstractNonlinearSolution broken=broken_inferred
40+
return solve(prob, solver; abstol = 1e-9)
3541
end
3642
end
3743

3844
@testitem "First Order Methods" setup=[RootfindTestSnippet] tags=[:core] begin
39-
for alg in (
45+
@testset for alg in (
4046
SimpleNewtonRaphson,
4147
SimpleTrustRegion,
4248
(; kwargs...) -> SimpleTrustRegion(; kwargs..., nlsolve_update_rule = Val(true))
@@ -50,7 +56,10 @@ end
5056
)
5157
@testset "[OOP] u0: $(typeof(u0))" for u0 in (
5258
[1.0, 1.0], @SVector[1.0, 1.0], 1.0)
53-
sol = run_nlsolve_oop(quadratic_f, u0; solver = alg(; autodiff))
59+
broken_inferred = u0 isa StaticArray && (autodiff isa AutoFiniteDiff ||
60+
(autodiff isa AutoReverseDiff && VERSION < v"1.11"))
61+
sol = run_nlsolve_oop(quadratic_f, u0; solver = alg(; autodiff),
62+
broken_inferred)
5463
@test SciMLBase.successful_retcode(sol)
5564
@test maximum(abs, quadratic_f(sol.u, 2.0)) < 1e-9
5665
end
@@ -85,7 +94,10 @@ end
8594
)
8695
@testset "[OOP] u0: $(typeof(u0))" for u0 in (
8796
[1.0, 1.0], @SVector[1.0, 1.0], 1.0)
88-
sol = run_nlsolve_oop(quadratic_f, u0; solver = alg(; autodiff))
97+
broken_inferred = u0 isa StaticArray && (autodiff isa AutoFiniteDiff ||
98+
(autodiff isa AutoReverseDiff && VERSION < v"1.11"))
99+
sol = run_nlsolve_oop(quadratic_f, u0; solver = alg(; autodiff),
100+
broken_inferred)
89101
@test SciMLBase.successful_retcode(sol)
90102
@test maximum(abs, quadratic_f(sol.u, 2.0)) < 1e-9
91103
end

0 commit comments

Comments
 (0)