687687 _pmap = merge (pmap, Dict (p => 1.0 ))
688688 prob = Problem (sys, u0map, (0.0 , 1.0 ), _pmap)
689689 @test prob. ps[p] ≈ 1.0
690- @test prob. f. initialization_data === nothing
690+ initsys = prob. f. initialization_data. initializeprob. f. sys
691+ @test is_parameter (initsys, p)
691692
692693 # Non-floating point
693694 @parameters r:: Int s:: Int
696697 prob = Problem (sys, u0map, (0.0 , 1.0 ), [r => 1 ])
697698 @test prob. ps[r] == 1
698699 @test prob. ps[s] == 2
699- @test prob. f. initialization_data === nothing
700+ initsys = prob. f. initialization_data. initializeprob. f. sys
701+ @test is_parameter (initsys, r)
702+ @test is_parameter (initsys, s)
700703
701704 @mtkbuild sys = System (
702705 [D (x) ~ x + rhss[1 ], p ~ x + y + rhss[2 ]], t; guesses = [p => 0.0 ])
@@ -1180,21 +1183,28 @@ end
11801183 @test integ2. ps[q] ≈ 2 cbrt (3 / 28 )
11811184end
11821185
1186+ function test_dummy_initialization_equation (prob, var)
1187+ initsys = prob. f. initialization_data. initializeprob. f. sys
1188+ @test isempty (equations (initsys))
1189+ idx = findfirst (eq -> isequal (var, eq. lhs), observed (initsys))
1190+ @test idx != = nothing && is_parameter (initsys, observed (initsys)[idx]. rhs)
1191+ end
1192+
11831193@testset " Remake problem with no initializeprob" begin
11841194 @variables x (t) [guess = 1.0 ] y (t) [guess = 1.0 ]
11851195 @parameters p [guess = 1.0 ] q [guess = 1.0 ]
11861196 @mtkbuild sys = ODESystem (
11871197 [D (x) ~ p * x + q * y, y ~ 2 x], t; parameter_dependencies = [q ~ 2 p])
11881198 prob = ODEProblem (sys, [x => 1.0 ], (0.0 , 1.0 ), [p => 1.0 ])
1189- @test prob. f . initialization_data === nothing
1199+ test_dummy_initialization_equation ( prob, x)
11901200 prob2 = remake (prob; u0 = [x => 2.0 ])
11911201 @test prob2[x] == 2.0
1192- @test prob2. f . initialization_data === nothing
1202+ test_dummy_initialization_equation ( prob2, x)
11931203 prob3 = remake (prob; u0 = [y => 2.0 ])
11941204 @test prob3. f. initialization_data != = nothing
11951205 @test init (prob3)[x] ≈ 1.0
11961206 prob4 = remake (prob; p = [p => 1.0 ])
1197- @test prob4. f . initialization_data === nothing
1207+ test_dummy_initialization_equation ( prob4, x)
11981208 prob5 = remake (prob; p = [p => missing , q => 2.0 ])
11991209 @test prob5. f. initialization_data != = nothing
12001210 @test init (prob5). ps[p] ≈ 1.0
@@ -1206,12 +1216,12 @@ end
12061216 @mtkbuild sys = ODESystem (
12071217 [D (x) ~ p * x + q * y, y ~ 2 x], t; parameter_dependencies = [q ~ 2 p])
12081218 prob = ODEProblem (sys, [:x => 1.0 ], (0.0 , 1.0 ), [p => 1.0 ])
1209- @test prob. f . initialization_data === nothing
1219+ test_dummy_initialization_equation ( prob, x)
12101220 prob2 = remake (prob; u0 = [:x => 2.0 ])
1211- @test prob2. f. initialization_data === nothing
1212- prob3 = remake (prob; u0 = [:y => 1.0 ])
1213- @test prob3. f. initialization_data != = nothing
1221+ test_dummy_initialization_equation (prob2, x)
1222+ prob3 = remake (prob; u0 = [:y => 1.0 , :x => nothing ])
12141223 @test init (prob3)[x] ≈ 0.5
1224+ @test SciMLBase. successful_retcode (solve (prob3))
12151225end
12161226
12171227@testset " Issue#3246: type promotion with parameter dependent initialization_eqs" begin
0 commit comments