Skip to content

Commit d61d9ed

Browse files
committed
test: move tests for QuasiNewton solvers
1 parent c73690e commit d61d9ed

File tree

8 files changed

+372
-242
lines changed

8 files changed

+372
-242
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: CI (NonlinearSolveQuasiNewton)
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
paths:
8+
- "lib/NonlinearSolveQuasiNewton/**"
9+
- ".github/workflows/CI_NonlinearSolveQuasiNewton.yml"
10+
- "lib/NonlinearSolveBase/**"
11+
- "lib/SciMLJacobianOperators/**"
12+
push:
13+
branches:
14+
- master
15+
16+
concurrency:
17+
# Skip intermediate builds: always.
18+
# Cancel intermediate builds: only if it is a pull request build.
19+
group: ${{ github.workflow }}-${{ github.ref }}
20+
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
21+
22+
jobs:
23+
test:
24+
runs-on: ${{ matrix.os }}
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
version:
29+
- "lts"
30+
- "1"
31+
os:
32+
- ubuntu-latest
33+
- macos-latest
34+
- windows-latest
35+
steps:
36+
- uses: actions/checkout@v4
37+
- uses: julia-actions/setup-julia@v2
38+
with:
39+
version: ${{ matrix.version }}
40+
- uses: actions/cache@v4
41+
env:
42+
cache-name: cache-artifacts
43+
with:
44+
path: ~/.julia/artifacts
45+
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
46+
restore-keys: |
47+
${{ runner.os }}-test-${{ env.cache-name }}-
48+
${{ runner.os }}-test-
49+
${{ runner.os }}-
50+
- name: "Install Dependencies and Run Tests"
51+
run: |
52+
import Pkg
53+
Pkg.Registry.update()
54+
# Install packages present in subdirectories
55+
dev_pks = Pkg.PackageSpec[]
56+
for path in ("lib/SciMLJacobianOperators", "lib/NonlinearSolveBase")
57+
push!(dev_pks, Pkg.PackageSpec(; path))
58+
end
59+
Pkg.develop(dev_pks)
60+
Pkg.instantiate()
61+
Pkg.test(; coverage="user")
62+
shell: julia --color=yes --code-coverage=user --depwarn=yes --project=lib/NonlinearSolveQuasiNewton {0}
63+
- uses: julia-actions/julia-processcoverage@v1
64+
with:
65+
directories: lib/NonlinearSolveQuasiNewton/src,lib/NonlinearSolveBase/src,lib/NonlinearSolveBase/ext,lib/SciMLJacobianOperators/src
66+
- uses: codecov/codecov-action@v4
67+
with:
68+
file: lcov.info
69+
token: ${{ secrets.CODECOV_TOKEN }}
70+
verbose: true
71+
fail_ci_if_error: true

lib/NonlinearSolveQuasiNewton/Project.toml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
88
CommonSolve = "38540f10-b2f7-11e9-35d8-d573e4eb0ff2"
99
ConcreteStructs = "2569d6c7-a4a2-43d3-a901-331e8e4be471"
1010
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
11-
LineSearch = "87fe0de2-c867-4266-b59a-2f0a94fc965b"
1211
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1312
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
1413
MaybeInplace = "bb5d69b7-63fc-4a16-80bd-7e42200c7bdb"
@@ -20,15 +19,21 @@ SciMLOperators = "c0aeaf25-5076-4817-a8d5-81caf7dfa961"
2019
StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
2120

2221
[compat]
22+
ADTypes = "1.9.0"
2323
Aqua = "0.8"
2424
ArrayInterface = "7.16.0"
25+
BenchmarkTools = "1.5.0"
2526
CommonSolve = "0.2.4"
2627
ConcreteStructs = "0.2.3"
2728
DiffEqBase = "6.155.3"
29+
Enzyme = "0.13.12"
2830
ExplicitImports = "1.5"
31+
FiniteDiff = "2.26.0"
32+
ForwardDiff = "0.10.36"
2933
Hwloc = "3"
3034
InteractiveUtils = "<0.0.1, 1"
3135
LineSearch = "0.1.4"
36+
LineSearches = "7.3.0"
3237
LinearAlgebra = "1.11.0"
3338
LinearSolve = "2.36.1"
3439
MaybeInplace = "0.1.4"
@@ -41,20 +46,31 @@ Reexport = "1"
4146
SciMLBase = "2.54"
4247
SciMLOperators = "0.3.11"
4348
StableRNGs = "1"
49+
StaticArrays = "1.9.8"
4450
StaticArraysCore = "1.4.3"
4551
Test = "1.10"
52+
Zygote = "0.6.72"
4653
julia = "1.10"
4754

4855
[extras]
56+
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
4957
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
58+
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
59+
Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
5060
ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7"
61+
FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41"
62+
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
5163
Hwloc = "0e44f5e4-bd66-52a0-8798-143a42290a1d"
5264
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
65+
LineSearch = "87fe0de2-c867-4266-b59a-2f0a94fc965b"
66+
LineSearches = "d3d80556-e9d4-5f37-9878-2ab0fcc64255"
5367
NonlinearProblemLibrary = "b7050fa9-e91f-4b37-bcee-a89a063da141"
5468
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
5569
ReTestItems = "817f1d60-ba6b-4fd5-9520-3cf149f6a823"
5670
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
71+
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
5772
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
73+
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
5874

5975
[targets]
60-
test = ["Aqua", "ExplicitImports", "Hwloc", "InteractiveUtils", "NonlinearProblemLibrary", "Pkg", "ReTestItems", "StableRNGs", "Test"]
76+
test = ["ADTypes", "Aqua", "BenchmarkTools", "Enzyme", "ExplicitImports", "FiniteDiff", "ForwardDiff", "Hwloc", "InteractiveUtils", "LineSearch", "LineSearches", "NonlinearProblemLibrary", "Pkg", "ReTestItems", "StableRNGs", "StaticArrays", "Test", "Zygote"]

lib/NonlinearSolveQuasiNewton/src/solve.jl

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -95,34 +95,31 @@ end
9595
kwargs
9696
end
9797

98-
# XXX: Implement
99-
# function __reinit_internal!(cache::QuasiNewtonCache{INV, GB, iip},
100-
# args...; p = cache.p, u0 = cache.u, alias_u0::Bool = false,
101-
# maxiters = 1000, maxtime = nothing, kwargs...) where {INV, GB, iip}
102-
# if iip
103-
# recursivecopy!(cache.u, u0)
104-
# cache.prob.f(cache.fu, cache.u, p)
105-
# else
106-
# cache.u = __maybe_unaliased(u0, alias_u0)
107-
# set_fu!(cache, cache.prob.f(cache.u, p))
108-
# end
109-
# cache.p = p
110-
111-
# __reinit_internal!(cache.stats)
112-
# cache.nsteps = 0
113-
# cache.nresets = 0
114-
# cache.steps_since_last_reset = 0
115-
# cache.maxiters = maxiters
116-
# cache.maxtime = maxtime
117-
# cache.total_time = 0.0
118-
# cache.force_stop = false
119-
# cache.force_reinit = false
120-
# cache.retcode = ReturnCode.Default
121-
122-
# reset!(cache.trace)
123-
# reinit!(cache.termination_cache, get_fu(cache), get_u(cache); kwargs...)
124-
# reset_timer!(cache.timer)
125-
# end
98+
function InternalAPI.reinit_self!(
99+
cache::QuasiNewtonCache, args...; p = cache.p, u0 = cache.u,
100+
alias_u0::Bool = false, maxiters = 1000, maxtime = nothing, kwargs...
101+
)
102+
Utils.reinit_common!(cache, u0, p, alias_u0)
103+
104+
InternalAPI.reinit!(cache.stats)
105+
cache.nsteps = 0
106+
cache.nresets = 0
107+
cache.steps_since_last_reset = 0
108+
cache.maxiters = maxiters
109+
cache.maxtime = maxtime
110+
cache.total_time = 0.0
111+
cache.force_stop = false
112+
cache.force_reinit = false
113+
cache.retcode = ReturnCode.Default
114+
115+
NonlinearSolveBase.reset!(cache.trace)
116+
SciMLBase.reinit!(
117+
cache.termination_cache, NonlinearSolveBase.get_fu(cache),
118+
NonlinearSolveBase.get_u(cache); kwargs...
119+
)
120+
NonlinearSolveBase.reset_timer!(cache.timer)
121+
return
122+
end
126123

127124
NonlinearSolveBase.@internal_caches(QuasiNewtonCache,
128125
:initialization_cache, :descent_cache, :linesearch_cache, :trustregion_cache,

0 commit comments

Comments
 (0)