Skip to content

Commit 0b95c58

Browse files
committed
test for adaptive=true on non-adaptive alg
1 parent 873f440 commit 0b95c58

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/OrdinaryDiffEqCore/src/solve.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ function DiffEqBase.__init(
112112
if only_diagonal_mass_matrix(alg) &&
113113
prob.f.mass_matrix isa AbstractMatrix &&
114114
!isdiag(prob.f.mass_matrix)
115-
error("$(typeof(alg).name.name) only works with diagonal mass matrices. Please choose a solver suitable for your problem (e.g. Rodas5P)")
115+
throw(ArgumentError("$(typeof(alg).name.name) only works with diagonal mass matrices. Please choose a solver suitable for your problem (e.g. Rodas5P)"))
116116
end
117117

118118
if !isempty(saveat) && dense
@@ -131,7 +131,10 @@ function DiffEqBase.__init(
131131
!(alg isa OrdinaryDiffEqCompositeAlgorithm) &&
132132
!(alg isa DAEAlgorithm)) || !adaptive || !isadaptive(alg)) &&
133133
dt == tType(0) && isempty(tstops)) && dt_required(alg)
134-
error("Fixed timestep methods require a choice of dt or choosing the tstops")
134+
throw(ArgumentError("Fixed timestep methods require a choice of dt or choosing the tstops"))
135+
end
136+
if !isadaptive(alg) && adaptive
137+
throw(ArgumentError("Fixed timestep methods can not be run with adaptive=true"))
135138
end
136139

137140
isdae = alg isa DAEAlgorithm || (!(prob isa DiscreteProblem) &&

test/integrators/check_error.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,6 @@ end
5656
@test sol.stats.naccept + sol.stats.nreject <= 30
5757
@test_broken sol.retcode = ReturnCode.Success
5858
end
59+
60+
@test_throws ArgumentError solve(prob, Euler(), dt=0.1 adaptive=true)
61+
@test_throws ArgumentError solve(prob, Euler())

0 commit comments

Comments
 (0)