Skip to content

Commit

Permalink
fix: handle :var => nothing provided to remake
Browse files Browse the repository at this point in the history
  • Loading branch information
AayushSabharwal committed Jan 21, 2025
1 parent 2461721 commit 6e8e1a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/remake.jl
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,7 @@ function fill_vars(
end
for (k, v) in varmap
haskey(sym_to_idx, k) && continue
v === nothing && continue
newvals[k] = v
end
return newvals
Expand Down
9 changes: 9 additions & 0 deletions test/downstream/modelingtoolkit_remake.jl
Original file line number Diff line number Diff line change
Expand Up @@ -397,3 +397,12 @@ end
# old value retained
@test prob2.ps[Gamma] 3.0
end

@testset "`nothing` value for variable specified as `Symbol`" begin
@variables x(t) [guess = 1.0] y(t) [guess = 1.0]
@parameters p [guess = 1.0] q [guess = 1.0]
@mtkbuild sys = ODESystem(
[D(x) ~ p * x + q * y, y ~ 2x], t; parameter_dependencies = [q ~ 2p])
prob = ODEProblem(sys, [:x => 1.0], (0.0, 1.0), [p => 1.0])
@test_nowarn remake(prob; u0 = [:y => 1.0, :x => nothing])
end

0 comments on commit 6e8e1a5

Please sign in to comment.