Skip to content

fix: fix remake(::JumpProblem) #3581

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/systems/nonlinear/initializesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,10 @@ function SciMLBase.remake_initialization_data(

oldinitdata = odefn.initialization_data

# We _always_ build initialization now. So if we didn't build it before, don't do
# it now
oldinitdata === nothing && return nothing

if !(eltype(u0) <: Pair) && !(eltype(p) <: Pair)
oldinitdata === nothing && return nothing

Expand Down
15 changes: 15 additions & 0 deletions test/jumpsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -551,3 +551,18 @@ end
sol = solve(jprob, SSAStepper())
@test eltype(sol[X]) === Int64
end

@testset "Issue#3571: `remake(::JumpProblem)`" begin
@variables X(t)
@parameters a b
eq = D(X) ~ a
rate = b * X
affect = [X ~ X - 1]
crj = ConstantRateJump(rate, affect)
@named jsys = JumpSystem([crj, eq], t, [X], [a, b])
jsys = complete(jsys)
oprob = ODEProblem(jsys, [:X => 1.0], (0.0, 10.0), [:a => 1.0, :b => 0.5])
jprob = JumpProblem(jsys, oprob)
jprob2 = remake(jprob; u0 = [:X => 10.0])
@test jprob2[X] ≈ 10.0
end
Loading