Skip to content

Commit 1010353

Browse files
authored
Update to SciMLLogging 2.0 (#927)
* move linear verbosity t o specifiers * update to SciMLLogging 2.0 * CI * AbstractMessageLevel => MessageLevel * fix projects, fix up tests * fix verbosity setting in downstream test * format verbosity.jl * bump patch versions
1 parent d637062 commit 1010353

7 files changed

Lines changed: 53 additions & 52 deletions

File tree

Project.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "NonlinearSolve"
22
uuid = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
3-
version = "4.19.0"
3+
version = "4.19.1"
44
authors = ["SciML"]
55

66
[deps]
@@ -25,7 +25,6 @@ Preferences = "21216c6a-2e73-6563-6e65-726566657250"
2525
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
2626
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
2727
Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
28-
SciMLLogging = "a6db7da4-7206-11f0-1eab-35f2a5dbe1d1"
2928
SimpleNonlinearSolve = "727e6d20-b764-4bd8-a329-72de5adea6c7"
3029
StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
3130
SymbolicIndexingInterface = "2efcf032-c050-4f8e-a9bb-153293bab1f5"
@@ -120,7 +119,7 @@ ReverseDiff = "1.15"
120119
SIAMFANLEquations = "1.0.1"
121120
SciMLBase = "2.154, 3"
122121
Setfield = "1.1.2"
123-
SciMLLogging = "1.7"
122+
SciMLLogging = "1.10.1, 2"
124123
SimpleNonlinearSolve = "2.10"
125124
SparseArrays = "1.10"
126125
SparseConnectivityTracer = "1"

lib/NonlinearSolveBase/Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "NonlinearSolveBase"
22
uuid = "be0214bd-f91f-a760-ac4e-3421ce2b2da0"
3-
version = "2.25.0"
3+
version = "2.25.1"
44
authors = ["Avik Pal <avikpal@mit.edu> and contributors"]
55

66
[deps]
@@ -94,7 +94,7 @@ RecursiveArrayTools = "3, 4"
9494
ReverseDiff = "1.15"
9595
SciMLBase = "2.153, 3"
9696
SciMLJacobianOperators = "0.1.1"
97-
SciMLLogging = "1.7"
97+
SciMLLogging = "1.10.1, 2"
9898
SciMLOperators = "1.7"
9999
SciMLStructures = "1.5"
100100
Setfield = "1.1.2"

lib/NonlinearSolveBase/src/NonlinearSolveBase.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import SciMLBase: solve, init, __init, __solve, wrap_sol, get_root_indp, isinpla
3131
using SciMLJacobianOperators: JacobianOperator, StatefulJacobianOperator
3232
using SciMLOperators: AbstractSciMLOperator, IdentityOperator
3333
using SciMLLogging: SciMLLogging, @SciMLMessage, @verbosity_specifier,
34-
AbstractVerbositySpecifier, AbstractVerbosityPreset, AbstractMessageLevel,
34+
AbstractVerbositySpecifier, AbstractVerbosityPreset, MessageLevel,
3535
None, Minimal, Standard, Detailed, All, Silent, InfoLevel, WarnLevel
3636

3737
using PreallocationTools: FixedSizeDiffCache, get_tmp

lib/NonlinearSolveBase/src/verbosity.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ verbose = NonlinearVerbosity(
6565
NonlinearVerbosity
6666

6767
@verbosity_specifier NonlinearVerbosity begin
68+
sub_specifiers = (:linear_verbosity,)
6869
toggles = (
69-
:linear_verbosity, :non_enclosing_interval, :alias_u0_immutable,
70+
:non_enclosing_interval, :alias_u0_immutable,
7071
:linsolve_failed_noncurrent, :termination_condition, :threshold_state, :forcing,
7172
:sensitivity_vjp_choice,
7273
)

lib/NonlinearSolveBase/test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ using InteractiveUtils, Test
2525
# Ignore SciMLLogging types used by @verbosity_specifier macro (ExplicitImports can't track macro usage)
2626
@test check_no_stale_explicit_imports(
2727
NonlinearSolveBase;
28-
ignore = (:AbstractMessageLevel, :AbstractVerbositySpecifier, :All, :Detailed, :Minimal, :None, :Standard, :SciMLLogging)
28+
ignore = (:MessageLevel, :AbstractVerbositySpecifier, :All, :Detailed, :Minimal, :None, :Standard, :SciMLLogging)
2929
) === nothing
3030
@test check_all_qualified_accesses_via_owners(NonlinearSolveBase) === nothing
3131
end

test/core_tests.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ end
255255
# Trust region methods also don't work with complex numbers (they use extrema internally).
256256
@testitem "Complex Valued Problems: Single-Shooting" tags = [:downstream] begin
257257
using OrdinaryDiffEqTsit5
258+
using SciMLLogging: SciMLLogging
258259

259260
function ode_func!(du, u, p, t)
260261
du[1] = u[2]
@@ -265,7 +266,7 @@ end
265266
function objective_function!(resid, u0, p)
266267
odeprob = ODEProblem{true}(ode_func!, u0, (0.0, 100.0), p)
267268
sol = solve(
268-
odeprob, Tsit5(), abstol = 1.0e-9, reltol = 1.0e-9, verbose = false
269+
odeprob, Tsit5(), abstol = 1.0e-9, reltol = 1.0e-9, verbose = SciMLLogging.None()
269270
)
270271
resid[1] = sol(0.0)[1]
271272
resid[2] = sol(100.0)[1] - 1.0

test/verbosity_tests.jl

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -13,44 +13,44 @@
1313
v_standard = NonlinearVerbosity(SciMLLogging.Standard())
1414
v_detailed = NonlinearVerbosity(SciMLLogging.Detailed())
1515

16-
@test v_none.non_enclosing_interval isa SciMLLogging.Silent
17-
@test v_none.threshold_state isa SciMLLogging.Silent
18-
@test v_none.alias_u0_immutable isa SciMLLogging.Silent
19-
@test v_none.sensitivity_vjp_choice isa SciMLLogging.Silent
20-
21-
@test v_minimal.non_enclosing_interval isa SciMLLogging.WarnLevel
22-
@test v_minimal.alias_u0_immutable isa SciMLLogging.Silent
23-
@test v_minimal.termination_condition isa SciMLLogging.Silent
24-
@test v_minimal.sensitivity_vjp_choice isa SciMLLogging.Silent
25-
26-
@test v_standard.non_enclosing_interval isa SciMLLogging.WarnLevel
27-
@test v_standard.threshold_state isa SciMLLogging.WarnLevel
28-
@test v_standard.sensitivity_vjp_choice isa SciMLLogging.WarnLevel
29-
30-
@test v_detailed.alias_u0_immutable isa SciMLLogging.WarnLevel
31-
@test v_detailed.termination_condition isa SciMLLogging.WarnLevel
32-
@test v_detailed.sensitivity_vjp_choice isa SciMLLogging.WarnLevel
33-
34-
@test v_all.linsolve_failed_noncurrent isa SciMLLogging.WarnLevel
35-
@test v_all.threshold_state isa SciMLLogging.InfoLevel
36-
@test v_all.sensitivity_vjp_choice isa SciMLLogging.WarnLevel
16+
@test v_none.non_enclosing_interval == SciMLLogging.Silent()
17+
@test v_none.threshold_state == SciMLLogging.Silent()
18+
@test v_none.alias_u0_immutable == SciMLLogging.Silent()
19+
@test v_none.sensitivity_vjp_choice == SciMLLogging.Silent()
20+
21+
@test v_minimal.non_enclosing_interval == SciMLLogging.WarnLevel()
22+
@test v_minimal.alias_u0_immutable == SciMLLogging.Silent()
23+
@test v_minimal.termination_condition == SciMLLogging.Silent()
24+
@test v_minimal.sensitivity_vjp_choice == SciMLLogging.Silent()
25+
26+
@test v_standard.non_enclosing_interval == SciMLLogging.WarnLevel()
27+
@test v_standard.threshold_state == SciMLLogging.WarnLevel()
28+
@test v_standard.sensitivity_vjp_choice == SciMLLogging.WarnLevel()
29+
30+
@test v_detailed.alias_u0_immutable == SciMLLogging.WarnLevel()
31+
@test v_detailed.termination_condition == SciMLLogging.WarnLevel()
32+
@test v_detailed.sensitivity_vjp_choice == SciMLLogging.WarnLevel()
33+
34+
@test v_all.linsolve_failed_noncurrent == SciMLLogging.WarnLevel()
35+
@test v_all.threshold_state == SciMLLogging.InfoLevel()
36+
@test v_all.sensitivity_vjp_choice == SciMLLogging.WarnLevel()
3737
end
3838

3939
@testset "Group-level keyword constructors" begin
4040
v_error = NonlinearVerbosity(error_control = SciMLLogging.ErrorLevel())
41-
@test v_error.alias_u0_immutable isa SciMLLogging.ErrorLevel
42-
@test v_error.non_enclosing_interval isa SciMLLogging.ErrorLevel
43-
@test v_error.termination_condition isa SciMLLogging.ErrorLevel
44-
@test v_error.linsolve_failed_noncurrent isa SciMLLogging.ErrorLevel
41+
@test v_error.alias_u0_immutable == SciMLLogging.ErrorLevel()
42+
@test v_error.non_enclosing_interval == SciMLLogging.ErrorLevel()
43+
@test v_error.termination_condition == SciMLLogging.ErrorLevel()
44+
@test v_error.linsolve_failed_noncurrent == SciMLLogging.ErrorLevel()
4545

4646
v_numerical = NonlinearVerbosity(numerical = SciMLLogging.Silent())
47-
@test v_numerical.threshold_state isa SciMLLogging.Silent
47+
@test v_numerical.threshold_state == SciMLLogging.Silent()
4848

4949
v_sensitivity = NonlinearVerbosity(sensitivity = SciMLLogging.Silent())
50-
@test v_sensitivity.sensitivity_vjp_choice isa SciMLLogging.Silent
50+
@test v_sensitivity.sensitivity_vjp_choice == SciMLLogging.Silent()
5151

5252
v_sensitivity2 = NonlinearVerbosity(sensitivity = SciMLLogging.InfoLevel())
53-
@test v_sensitivity2.sensitivity_vjp_choice isa SciMLLogging.InfoLevel
53+
@test v_sensitivity2.sensitivity_vjp_choice == SciMLLogging.InfoLevel()
5454
end
5555

5656
@testset "Mixed group and individual settings" begin
@@ -60,10 +60,10 @@
6060
error_control = SciMLLogging.InfoLevel()
6161
)
6262
# Individual override should take precedence
63-
@test v_mixed.threshold_state isa SciMLLogging.WarnLevel
63+
@test v_mixed.threshold_state == SciMLLogging.WarnLevel()
6464
# Error control group setting should apply
65-
@test v_mixed.alias_u0_immutable isa SciMLLogging.InfoLevel
66-
@test v_mixed.linsolve_failed_noncurrent isa SciMLLogging.InfoLevel
65+
@test v_mixed.alias_u0_immutable == SciMLLogging.InfoLevel()
66+
@test v_mixed.linsolve_failed_noncurrent == SciMLLogging.InfoLevel()
6767
end
6868

6969
@testset "Individual keyword arguments" begin
@@ -72,12 +72,12 @@
7272
threshold_state = SciMLLogging.InfoLevel(),
7373
termination_condition = SciMLLogging.Silent()
7474
)
75-
@test v_individual.alias_u0_immutable isa SciMLLogging.ErrorLevel
76-
@test v_individual.threshold_state isa SciMLLogging.InfoLevel
77-
@test v_individual.termination_condition isa SciMLLogging.Silent
75+
@test v_individual.alias_u0_immutable == SciMLLogging.ErrorLevel()
76+
@test v_individual.threshold_state == SciMLLogging.InfoLevel()
77+
@test v_individual.termination_condition == SciMLLogging.Silent()
7878
# Unspecified options should use defaults
79-
@test v_individual.non_enclosing_interval isa SciMLLogging.WarnLevel
80-
@test v_individual.linsolve_failed_noncurrent isa SciMLLogging.WarnLevel
79+
@test v_individual.non_enclosing_interval == SciMLLogging.WarnLevel()
80+
@test v_individual.linsolve_failed_noncurrent == SciMLLogging.WarnLevel()
8181
end
8282

8383
g(u, p) = u^2 - 4
@@ -192,8 +192,8 @@
192192
# Test verbose = false converts to NonlinearVerbosity(None())
193193
cache2 = init(prob, verbose = false)
194194
@test cache2.verbose isa NonlinearVerbosity
195-
@test cache2.verbose.threshold_state isa SciMLLogging.Silent
196-
@test cache2.verbose.non_enclosing_interval isa SciMLLogging.Silent
195+
@test cache2.verbose.threshold_state == SciMLLogging.Silent()
196+
@test cache2.verbose.non_enclosing_interval == SciMLLogging.Silent()
197197
end
198198

199199
@testset "init with Preset verbose" begin
@@ -205,12 +205,12 @@
205205
# Test verbose = SciMLLogging.None() converts to NonlinearVerbosity(None())
206206
cache2 = init(prob, verbose = SciMLLogging.None())
207207
@test cache2.verbose isa NonlinearVerbosity
208-
@test cache2.verbose.threshold_state isa SciMLLogging.Silent
208+
@test cache2.verbose.threshold_state == SciMLLogging.Silent()
209209

210210
# Test verbose = SciMLLogging.Detailed()
211211
cache3 = init(prob, verbose = SciMLLogging.Detailed())
212212
@test cache3.verbose isa NonlinearVerbosity
213-
@test cache3.verbose.linear_verbosity isa SciMLLogging.Detailed
213+
@test cache3.verbose.linear_verbosity == SciMLLogging.Detailed()
214214

215215
# Test verbose = SciMLLogging.All()
216216
cache4 = init(prob, verbose = SciMLLogging.All())
@@ -220,7 +220,7 @@
220220
# Test verbose = SciMLLogging.Minimal()
221221
cache5 = init(prob, verbose = SciMLLogging.Minimal())
222222
@test cache5.verbose isa NonlinearVerbosity
223-
@test cache5.verbose.alias_u0_immutable isa SciMLLogging.Silent
223+
@test cache5.verbose.alias_u0_immutable == SciMLLogging.Silent()
224224
end
225225

226226
@testset "init then solve with converted verbose" begin
@@ -231,9 +231,9 @@
231231

232232
@testset "NonlinearVerbosity with keyword message levels (issue #796)" begin
233233
# Regression test: constructing NonlinearVerbosity with keyword arguments
234-
# that are AbstractMessageLevel subtypes should not throw UndefVarError
234+
# that are MessageLevel subtypes should not throw UndefVarError
235235
verb = NonlinearVerbosity(non_enclosing_interval = SciMLLogging.ErrorLevel())
236-
@test verb.non_enclosing_interval isa SciMLLogging.ErrorLevel
236+
@test verb.non_enclosing_interval == SciMLLogging.ErrorLevel()
237237

238238
# Test with the full solve pipeline from the issue MWE
239239
f_interval(x, p) = x^2 - p

0 commit comments

Comments
 (0)