Skip to content

Commit fcca2f7

Browse files
committed
test: bring over more tests
1 parent a753186 commit fcca2f7

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

.github/workflows/CI_SimpleNonlinearSolve.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ jobs:
3232
- ubuntu-latest
3333
- macos-latest
3434
- windows-latest
35+
group:
36+
- core
37+
- adjoint
3538
steps:
3639
- uses: actions/checkout@v4
3740
- uses: julia-actions/setup-julia@v2
@@ -60,6 +63,8 @@ jobs:
6063
Pkg.instantiate()
6164
Pkg.test(; coverage=true)
6265
shell: julia --color=yes --code-coverage=user --depwarn=yes --project=lib/SimpleNonlinearSolve {0}
66+
env:
67+
GROUP: ${{ matrix.group }}
6368
- uses: julia-actions/julia-processcoverage@v1
6469
with:
6570
directories: lib/SimpleNonlinearSolve/src,lib/SimpleNonlinearSolve/ext
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
@itesitem "Allocation Tests" tags=[:core] begin
2+
using SimpleNonlinearSolve, StaticArrays, AllocCheck
3+
4+
quadratic_f(u, p) = u .* u .- p
5+
quadratic_f!(du, u, p) = (du .= u .* u .- p)
6+
7+
@testset "$(nameof(typeof(alg)))" for alg in (
8+
SimpleNewtonRaphson(),
9+
SimpleTrustRegion(),
10+
SimpleTrustRegion(; nlsolve_update_rule = Val(true)),
11+
SimpleBroyden(),
12+
SimpleLimitedMemoryBroyden(),
13+
SimpleKlement(),
14+
SimpleHalley(),
15+
SimpleBroyden(; linesearch = Val(true)),
16+
SimpleLimitedMemoryBroyden(; linesearch = Val(true))
17+
)
18+
@check_allocs nlsolve(prob, alg) = SciMLBase.solve(prob, alg; abstol = 1e-9)
19+
20+
nlprob_scalar = NonlinearProblem{false}(quadratic_f, 1.0, 2.0)
21+
nlprob_sa = NonlinearProblem{false}(quadratic_f, @SVector[1.0, 1.0], 2.0)
22+
23+
try
24+
nlsolve(nlprob_scalar, alg)
25+
@test true
26+
catch e
27+
@error e
28+
@test false
29+
end
30+
31+
# ForwardDiff allocates for hessian since we don't propagate the chunksize
32+
try
33+
nlsolve(nlprob_sa, alg)
34+
@test true
35+
catch e
36+
@error e
37+
@test false broken = (alg isa SimpleHalley)
38+
end
39+
end
40+
end
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@testitem "Matrix Resizing" tags=[:core] begin
2+
ff(u, p) = u .* u .- p
3+
u0 = ones(2, 3)
4+
p = 2.0
5+
vecprob = NonlinearProblem(ff, vec(u0), p)
6+
prob = NonlinearProblem(ff, u0, p)
7+
8+
@testset "$(nameof(typeof(alg)))" for alg in (
9+
SimpleKlement(),
10+
SimpleBroyden(),
11+
SimpleNewtonRaphson(),
12+
SimpleDFSane(),
13+
SimpleLimitedMemoryBroyden(; threshold = Val(2)),
14+
SimpleTrustRegion(),
15+
SimpleTrustRegion(; nlsolve_update_rule = Val(true))
16+
)
17+
@test vec(solve(prob, alg).u) solve(vecprob, alg).u
18+
end
19+
end

0 commit comments

Comments
 (0)