Skip to content

Commit 68e0605

Browse files
fix: update initials in remake with non-symbolic u0 and symbolic p
1 parent 5b81a11 commit 68e0605

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/systems/nonlinear/initializesystem.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,8 +655,10 @@ end
655655
function SciMLBase.late_binding_update_u0_p(
656656
prob, sys::AbstractSystem, u0, p, t0, newu0, newp)
657657
u0 === missing && return newu0, (p === missing ? copy(newp) : newp)
658+
# non-symbolic u0 updates initials...
658659
if !(eltype(u0) <: Pair)
659-
p === missing || return newu0, newp
660+
# if `p` is not provided or is symbolic
661+
p === missing || eltype(p) <: Pair || return newu0, newp
660662
newu0 === nothing && return newu0, newp
661663
newp = p === missing ? copy(newp) : newp
662664
initials, repack, alias = SciMLStructures.canonicalize(

test/initializationsystem.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,7 +1483,11 @@ end
14831483
@mtkbuild sys = ODESystem([D(x) ~ -c1 * x + c2 * y, D(y) ~ c1 * x - c2 * y], t)
14841484
prob1 = ODEProblem(sys, [1.0, 2.0], (0.0, 1.0), [c1 => 1.0, c2 => 2.0])
14851485
prob2 = remake(prob1, u0 = [2.0, 3.0])
1486+
prob3 = remake(prob1, u0 = [2.0, 3.0], p = [c1 => 2.0])
14861487
integ1 = init(prob1, Tsit5())
14871488
integ2 = init(prob2, Tsit5())
1489+
integ3 = init(prob3, Tsit5())
14881490
@test integ2.u [2.0, 3.0]
1491+
@test integ3.u [2.0, 3.0]
1492+
@test integ3.ps[c1] 2.0
14891493
end

0 commit comments

Comments
 (0)