Skip to content

Commit 8b83094

Browse files
test: test remake without initializeprob and Symbol values
1 parent 2c8d016 commit 8b83094

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test/initializationsystem.jl

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,3 +970,35 @@ end
970970
@test integ2.ps[p] == 1.0
971971
@test integ2.ps[q] 2cbrt(3 / 28)
972972
end
973+
974+
@testset "Remake problem with no initializeprob" begin
975+
@variables x(t) [guess = 1.0] y(t) [guess = 1.0]
976+
@parameters p [guess = 1.0] q [guess = 1.0]
977+
@mtkbuild sys = ODESystem([D(x) ~ p * x + q * y, y ~ 2x], t; parameter_dependencies = [q ~ 2p])
978+
prob = ODEProblem(sys, [x => 1.0], (0.0, 1.0), [p => 1.0])
979+
@test prob.f.initialization_data === nothing
980+
prob2 = remake(prob; u0 = [x => 2.0])
981+
@test prob2[x] == 2.0
982+
@test prob2.f.initialization_data === nothing
983+
prob3 = remake(prob; u0 = [y => 2.0])
984+
@test prob3.f.initialization_data !== nothing
985+
@test init(prob3)[x] 1.0
986+
prob4 = remake(prob; p = [p => 1.0])
987+
@test prob4.f.initialization_data === nothing
988+
prob5 = remake(prob; p = [p => missing, q => 2.0])
989+
@test prob5.f.initialization_data !== nothing
990+
@test init(prob5).ps[p] 1.0
991+
end
992+
993+
@testset "Variables provided as symbols" begin
994+
@variables x(t) [guess = 1.0] y(t) [guess = 1.0]
995+
@parameters p [guess = 1.0] q [guess = 1.0]
996+
@mtkbuild sys = ODESystem([D(x) ~ p * x + q * y, y ~ 2x], t; parameter_dependencies = [q ~ 2p])
997+
prob = ODEProblem(sys, [:x => 1.0], (0.0, 1.0), [p => 1.0])
998+
@test prob.f.initialization_data === nothing
999+
prob2 = remake(prob; u0 = [:x => 2.0])
1000+
@test prob2.f.initialization_data === nothing
1001+
prob3 = remake(prob; u0 = [:y => 1.0])
1002+
@test prob3.f.initialization_data !== nothing
1003+
@test init(prob3)[x] 0.5
1004+
end

0 commit comments

Comments
 (0)