Skip to content

Commit a52b61c

Browse files
Merge pull request #2695 from SciML/ChrisRackauckas-patch-2
Don't double recurse init with default algorithm
2 parents d227c90 + 8d0bbf7 commit a52b61c

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lib/OrdinaryDiffEqDefault/src/default_alg.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ function isdefaultalg(alg::CompositeAlgorithm{
4040
end
4141

4242
function DiffEqBase.__init(prob::ODEProblem, ::Nothing, args...; kwargs...)
43-
DiffEqBase.init(
43+
DiffEqBase.__init(
4444
prob, DefaultODEAlgorithm(autodiff = AutoFiniteDiff()),
4545
args...; wrap = Val(false), kwargs...)
4646
end
4747
function DiffEqBase.__solve(prob::ODEProblem, ::Nothing, args...; kwargs...)
48-
DiffEqBase.solve(
48+
DiffEqBase.__solve(
4949
prob, DefaultODEAlgorithm(autodiff = AutoFiniteDiff()),
5050
args...; wrap = Val(false), kwargs...)
5151
end

lib/OrdinaryDiffEqDefault/test/default_solver_tests.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,12 @@ schrod_eq(state, time, s) = -im * time * H(s) * state
124124
prob_complex = ODEProblem(schrod_eq, complex([1, -1] / sqrt(2)), (0, 1), 100)
125125
complex_sol = solve(prob_complex)
126126
@test complex_sol.retcode == ReturnCode.Success
127+
128+
# Make sure callback doesn't recurse init, which would cause iniitalize to be hit twice
129+
counter = Ref{Int}(0)
130+
cb = DiscreteCallback((u,t,integ)->false, (integ)->nothing;
131+
initialize = (c,u,t,integ)->counter[]+=1)
132+
133+
prob = ODEProblem((u,p,t)->[0.0], [0.0], (0.0,1.0))
134+
sol = solve(prob, callback=cb)
135+
@test counter[] == 1

0 commit comments

Comments
 (0)