Skip to content

Commit 79efd5a

Browse files
Merge pull request #907 from SciML/kwargshandle_error
Change default kwargs handle from warn to error
2 parents 456cb3d + 6ce1a8f commit 79efd5a

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

src/solve.jl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const allowedkeywords = (:dense,
8888
:linsolve_kwargs)
8989

9090
const KWARGWARN_MESSAGE = """
91-
Unrecognized keyword arguments found. Future versions will error.
91+
Unrecognized keyword arguments found.
9292
The only allowed keyword arguments to `solve` are:
9393
$allowedkeywords
9494
@@ -450,8 +450,12 @@ function Base.showerror(io::IO, e::IncompatibleMassMatrixError)
450450
println(io, TruncatedStacktraces.VERBOSE_MSG)
451451
end
452452

453-
function init_call(_prob, args...; merge_callbacks = true, kwargshandle = KeywordArgWarn,
453+
function init_call(_prob, args...; merge_callbacks = true, kwargshandle = nothing,
454454
kwargs...)
455+
456+
kwargshandle = kwargshandle === nothing ? KeywordArgError : kwargshandle
457+
kwargshandle = has_kwargs(_prob) && haskey(_prob.kwargs, :kwargshandle) ? _prob.kwargs[:kwargshandle] : kwargshandle
458+
455459
if has_kwargs(_prob)
456460
if merge_callbacks && haskey(_prob.kwargs, :callback) && haskey(kwargs, :callback)
457461
kwargs_temp = NamedTuple{
@@ -526,8 +530,12 @@ function init_up(prob::DEProblem, sensealg, u0, p, args...; kwargs...)
526530
end
527531
end
528532

529-
function solve_call(_prob, args...; merge_callbacks = true, kwargshandle = KeywordArgWarn,
533+
function solve_call(_prob, args...; merge_callbacks = true, kwargshandle = nothing,
530534
kwargs...)
535+
536+
kwargshandle = kwargshandle === nothing ? KeywordArgError : kwargshandle
537+
kwargshandle = has_kwargs(_prob) && haskey(_prob.kwargs, :kwargshandle) ? _prob.kwargs[:kwargshandle] : kwargshandle
538+
531539
if has_kwargs(_prob)
532540
if merge_callbacks && haskey(_prob.kwargs, :callback) && haskey(kwargs, :callback)
533541
kwargs_temp = NamedTuple{

test/downstream/kwarg_warn.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ u0 = [1.0; 0.0; 0.0]
88
tspan = (0.0, 100.0)
99
prob = ODEProblem(lorenz, u0, tspan)
1010
@test_nowarn sol = solve(prob, Tsit5(), reltol = 1e-6)
11-
sol = solve(prob, Tsit5(), rel_tol = 1e-6)
12-
@test_logs (:warn, DiffEqBase.KWARGWARN_MESSAGE) sol=solve(prob, Tsit5(), rel_tol = 1e-6)
13-
@test_throws DiffEqBase.CommonKwargError sol=solve(prob, Tsit5(), rel_tol = 1e-6,
14-
kwargshandle = DiffEqBase.KeywordArgError)
11+
sol = solve(prob, Tsit5(), rel_tol = 1e-6, kwargshandle = DiffEqBase.KeywordArgWarn)
12+
@test_logs (:warn, DiffEqBase.KWARGWARN_MESSAGE) sol=solve(prob, Tsit5(), rel_tol = 1e-6, kwargshandle = DiffEqBase.KeywordArgWarn)
13+
@test_throws DiffEqBase.CommonKwargError sol=solve(prob, Tsit5(), rel_tol = 1e-6)
1514

16-
prob = ODEProblem(lorenz, u0, tspan, test = 2.0)
15+
prob = ODEProblem(lorenz, u0, tspan, test = 2.0, kwargshandle = DiffEqBase.KeywordArgWarn)
1716
@test_logs (:warn, DiffEqBase.KWARGWARN_MESSAGE) sol=solve(prob, Tsit5(), reltol = 1e-6)

0 commit comments

Comments
 (0)