Skip to content

Commit 3383bce

Browse files
test: test remake without initializeprob and Symbol values
1 parent 2698015 commit 3383bce

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

test/initializationsystem.jl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,3 +998,37 @@ end
998998
@test integ2.ps[p] == 1.0
999999
@test integ2.ps[q] 2cbrt(3 / 28)
10001000
end
1001+
1002+
@testset "Remake problem with no initializeprob" begin
1003+
@variables x(t) [guess = 1.0] y(t) [guess = 1.0]
1004+
@parameters p [guess = 1.0] q [guess = 1.0]
1005+
@mtkbuild sys = ODESystem(
1006+
[D(x) ~ p * x + q * y, y ~ 2x], t; parameter_dependencies = [q ~ 2p])
1007+
prob = ODEProblem(sys, [x => 1.0], (0.0, 1.0), [p => 1.0])
1008+
@test prob.f.initialization_data === nothing
1009+
prob2 = remake(prob; u0 = [x => 2.0])
1010+
@test prob2[x] == 2.0
1011+
@test prob2.f.initialization_data === nothing
1012+
prob3 = remake(prob; u0 = [y => 2.0])
1013+
@test prob3.f.initialization_data !== nothing
1014+
@test init(prob3)[x] 1.0
1015+
prob4 = remake(prob; p = [p => 1.0])
1016+
@test prob4.f.initialization_data === nothing
1017+
prob5 = remake(prob; p = [p => missing, q => 2.0])
1018+
@test prob5.f.initialization_data !== nothing
1019+
@test init(prob5).ps[p] 1.0
1020+
end
1021+
1022+
@testset "Variables provided as symbols" begin
1023+
@variables x(t) [guess = 1.0] y(t) [guess = 1.0]
1024+
@parameters p [guess = 1.0] q [guess = 1.0]
1025+
@mtkbuild sys = ODESystem(
1026+
[D(x) ~ p * x + q * y, y ~ 2x], t; parameter_dependencies = [q ~ 2p])
1027+
prob = ODEProblem(sys, [:x => 1.0], (0.0, 1.0), [p => 1.0])
1028+
@test prob.f.initialization_data === nothing
1029+
prob2 = remake(prob; u0 = [:x => 2.0])
1030+
@test prob2.f.initialization_data === nothing
1031+
prob3 = remake(prob; u0 = [:y => 1.0])
1032+
@test prob3.f.initialization_data !== nothing
1033+
@test init(prob3)[x] 0.5
1034+
end

0 commit comments

Comments
 (0)