Skip to content

Commit 4bab2ab

Browse files
fix: fix type stability of remake(::SDEProblem)
1 parent f5cb199 commit 4bab2ab

File tree

1 file changed

+6
-45
lines changed

1 file changed

+6
-45
lines changed

src/remake.jl

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -352,26 +352,8 @@ function remake(prob::SDEProblem;
352352
if seed === missing
353353
seed = prob.seed
354354
end
355-
356-
if f === missing && g === missing
357-
f = prob.f
358-
g = prob.g
359-
elseif f !== missing && g === missing
360-
g = prob.g
361-
elseif f === missing && g !== missing
362-
if prob.f isa SDEFunction
363-
f = remake(prob.f; g = g)
364-
else
365-
f = SDEFunction(prob.f, g; sys = prob.f.sys)
366-
end
367-
else
368-
if f isa SDEFunction
369-
f = remake(f; g = g)
370-
else
371-
f = SDEFunction(f, g; sys = prob.f.sys)
372-
end
373-
end
374-
f = remake(f; initialization_data)
355+
f = coalesce(f, prob.f)
356+
f = remake(prob.f; f, g, initialization_data)
375357
iip = isinplace(prob)
376358

377359
if kwargs === missing
@@ -444,12 +426,8 @@ function remake(prob::DDEProblem; f = missing, h = missing, u0 = missing,
444426
initialization_data = nothing
445427
end
446428

447-
if f === missing
448-
f = prob.f
449-
elseif !(f isa DDEFunction)
450-
f = remake(prob.f; f = f)
451-
end
452-
f = remake(f; initialization_data)
429+
f = coalesce(f, prob.f)
430+
f = remake(prob.f; f, initialization_data)
453431

454432
h = coalesce(h, prob.h)
455433
constant_lags = coalesce(constant_lags, prob.constant_lags)
@@ -546,25 +524,8 @@ function remake(prob::SDDEProblem;
546524
seed = prob.seed
547525
end
548526

549-
if f === missing && g === missing
550-
f = prob.f
551-
g = prob.g
552-
elseif f !== missing && g === missing
553-
g = prob.g
554-
elseif f === missing && g !== missing
555-
if prob.f isa SDEFunction
556-
f = remake(prob.f; g = g)
557-
else
558-
f = SDEFunction(prob.f, g; sys = prob.f.sys)
559-
end
560-
else
561-
if f isa SDEFunction
562-
f = remake(f; g = g)
563-
else
564-
f = SDEFunction(f, g; sys = prob.f.sys)
565-
end
566-
end
567-
f = remake(f; initialization_data)
527+
f = coalesce(f, prob.f)
528+
f = remake(prob.f; f, g, initialization_data)
568529
iip = isinplace(prob)
569530

570531
h = coalesce(h, prob.h)

0 commit comments

Comments
 (0)