Skip to content

Commit fca13bd

Browse files
Route solver warnings through DEVerbosity instead of verbose !== false
DiffEqBase v7 passes `verbose` as a `DEVerbosity` object. Even silent modes like `DEVerbosity(None())` are not `===false`, so the prior `verbose !== false` guard always admitted warnings and ignored the caller's silence request. - Route every compat warning (unsupported kwargs, explicit t-gradient / Jacobian on stiff solvers, compat-chart link) through `@SciMLMessage`. `@SciMLMessage` handles both `Bool` (true→WarnLevel, false→Silent) and `AbstractVerbositySpecifier` (reads the named toggle), so v6 callers and v7 callers are both honored. - Use the `:mismatched_input_output_type` toggle from `DEVerbosity`, which is the right bucket for "input the GeometricIntegrators solver cannot honor" messages. - Inline the `check_keywords` loop since the SciMLBase helper always `@warn`s and can't be parameterized by verbosity. - Add `SciMLLogging` as a direct dep for `@SciMLMessage`. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
1 parent 3e13835 commit fca13bd

3 files changed

Lines changed: 43 additions & 17 deletions

File tree

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
88
GeometricIntegrators = "dcce2d33-59f6-5b8d-9047-0defad88ae06"
99
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
1010
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
11+
SciMLLogging = "a6db7da4-7206-11f0-1eab-35f2a5dbe1d1"
1112

1213
[compat]
1314
DiffEqBase = "6.62, 7"
1415
ExplicitImports = "1.14.0"
1516
GeometricIntegrators = "0.15, 0.16"
1617
Reexport = "0.2, 1"
1718
SciMLBase = "2, 3"
19+
SciMLLogging = "1"
1820
julia = "1.10"
1921

2022
[extras]

src/GeometricIntegratorsDiffEq.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ module GeometricIntegratorsDiffEq
22

33
using Reexport: Reexport, @reexport
44
@reexport using DiffEqBase: DiffEqBase
5-
using SciMLBase: SciMLBase, ReturnCode, check_keywords, warn_compat
5+
using SciMLBase: SciMLBase, ReturnCode
6+
using SciMLLogging: @SciMLMessage
67

78
using GeometricIntegrators: GeometricIntegrators, CrankNicolson, Crouzeix,
89
ExplicitEuler, ExplicitMidpoint, Gauss, Heun2, Heun3, ImplicitEuler,

src/solve.jl

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,53 @@ function DiffEqBase.__solve(
1515
error("dt required for fixed timestep methods.")
1616
end
1717

18-
# DiffEqBase v7 passes `verbose` as a `DEVerbosity` object instead of a Bool.
19-
# Treat anything that is not literally `false` as "show warnings".
20-
verbose_bool = verbose !== false
21-
2218
isstiff = !(
2319
alg isa Union{
2420
GIImplicitEuler, GIImplicitMidpoint,
2521
GISRK3, GIGLRK, GIRadauIA, GIRadauIIA,
2622
}
2723
)
2824

29-
if verbose_bool
30-
warned = !isempty(kwargs) && check_keywords(alg, kwargs, warnlist)
31-
if !(prob.f isa DiffEqBase.AbstractParameterizedFunction) && isstiff
32-
if DiffEqBase.has_tgrad(prob.f)
33-
@warn "Explicit t-gradient given to this stiff solver is ignored."
34-
warned = true
35-
end
36-
if DiffEqBase.has_jac(prob.f)
37-
@warn "Explicit Jacobian given to this stiff solver is ignored."
38-
warned = true
39-
end
25+
# `verbose` may be a `Bool` (DiffEqBase v6) or a `DEVerbosity` / other
26+
# `AbstractVerbositySpecifier` (DiffEqBase v7+). Route each warning through
27+
# `@SciMLMessage` so a silent spec (e.g. `DEVerbosity(None())`) actually
28+
# suppresses it — a `verbose !== false` guard can't, since a silent
29+
# `DEVerbosity` is not `false`. The `:mismatched_input_output_type` toggle
30+
# is the right DEVerbosity bucket for these: every message here reports an
31+
# input the GeometricIntegrators solver cannot honor. For `Bool` verbose,
32+
# `@SciMLMessage` ignores the toggle name and just maps true→WarnLevel,
33+
# false→Silent.
34+
warned = false
35+
for (kw, val) in kwargs
36+
if kw in warnlist && val !== nothing
37+
@SciMLMessage(
38+
string("The ", kw, " argument is ignored by ", alg, "."),
39+
verbose, :mismatched_input_output_type
40+
)
41+
warned = true
42+
end
43+
end
44+
if !(prob.f isa DiffEqBase.AbstractParameterizedFunction) && isstiff
45+
if DiffEqBase.has_tgrad(prob.f)
46+
@SciMLMessage(
47+
"Explicit t-gradient given to this stiff solver is ignored.",
48+
verbose, :mismatched_input_output_type
49+
)
50+
warned = true
4051
end
41-
warned && warn_compat()
52+
if DiffEqBase.has_jac(prob.f)
53+
@SciMLMessage(
54+
"Explicit Jacobian given to this stiff solver is ignored.",
55+
verbose, :mismatched_input_output_type
56+
)
57+
warned = true
58+
end
59+
end
60+
if warned
61+
@SciMLMessage(
62+
"https://docs.sciml.ai/DiffEqDocs/stable/basics/compatibility_chart/",
63+
verbose, :mismatched_input_output_type
64+
)
4265
end
4366

4467
if callback !== nothing

0 commit comments

Comments
 (0)