Skip to content

Commit 22151e7

Browse files
fix: only promote tunables/initials in promote_u0_p if non-empty
1 parent 37f5320 commit 22151e7

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/systems/nonlinear/initializesystem.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -602,10 +602,14 @@ function promote_u0_p(u0, p::MTKParameters, t0)
602602
u0 = DiffEqBase.promote_u0(u0, p.tunable, t0)
603603
u0 = DiffEqBase.promote_u0(u0, p.initials, t0)
604604

605-
tunables = DiffEqBase.promote_u0(p.tunable, u0, t0)
606-
initials = DiffEqBase.promote_u0(p.initials, u0, t0)
607-
p = SciMLStructures.replace(SciMLStructures.Tunable(), p, tunables)
608-
p = SciMLStructures.replace(SciMLStructures.Initials(), p, initials)
605+
if !isempty(p.tunable)
606+
tunables = DiffEqBase.promote_u0(p.tunable, u0, t0)
607+
p = SciMLStructures.replace(SciMLStructures.Tunable(), p, tunables)
608+
end
609+
if !isempty(p.initials)
610+
initials = DiffEqBase.promote_u0(p.initials, u0, t0)
611+
p = SciMLStructures.replace(SciMLStructures.Initials(), p, initials)
612+
end
609613

610614
return u0, p
611615
end

0 commit comments

Comments
 (0)