Skip to content

Commit b1c705b

Browse files
Merge pull request #915 from AayushSabharwal/as/nothing-remake
fix: handle `:var => nothing` provided to `remake`
2 parents 4a5a252 + 6e8e1a5 commit b1c705b

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/remake.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,7 @@ function fill_vars(
986986
end
987987
for (k, v) in varmap
988988
haskey(sym_to_idx, k) && continue
989+
v === nothing && continue
989990
newvals[k] = v
990991
end
991992
return newvals

test/downstream/modelingtoolkit_remake.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,3 +397,12 @@ end
397397
# old value retained
398398
@test prob2.ps[Gamma] 3.0
399399
end
400+
401+
@testset "`nothing` value for variable specified as `Symbol`" begin
402+
@variables x(t) [guess = 1.0] y(t) [guess = 1.0]
403+
@parameters p [guess = 1.0] q [guess = 1.0]
404+
@mtkbuild sys = ODESystem(
405+
[D(x) ~ p * x + q * y, y ~ 2x], t; parameter_dependencies = [q ~ 2p])
406+
prob = ODEProblem(sys, [:x => 1.0], (0.0, 1.0), [p => 1.0])
407+
@test_nowarn remake(prob; u0 = [:y => 1.0, :x => nothing])
408+
end

0 commit comments

Comments
 (0)