Skip to content

Commit c7c54fc

Browse files
fixup! test: test parameters as initialization unknowns
1 parent 59e4fe7 commit c7c54fc

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

test/initializationsystem.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -490,19 +490,21 @@ end
490490
@testset "Initialization of parameters" begin
491491
function test_parameter(prob, sym, val, initialval = zero(val))
492492
@test prob.ps[sym] initialval
493-
@test init(prob).ps[sym] val
494-
@test solve(prob).ps[sym] val
493+
@test init(prob, Tsit5()).ps[sym] val
494+
@test solve(prob, Tsit5()).ps[sym] val
495495
end
496496
@variables x(t) y(t)
497497
@parameters p
498498
_p = ModelingToolkit.setdefault(p, missing)
499+
_p = ModelingToolkit.setguess(_p, 0.0)
499500
@mtkbuild sys = ODESystem([D(x) ~ x, _p ~ x + y], t)
500501
prob = ODEProblem(sys, [x => 1.0, y => 1.0], (0.0, 1.0))
501502
test_parameter(prob, _p, 2.0)
502-
@mtkbuild sys = ODESystem([D(x) ~ x, p ~ x + y], t; defaults = [p => missing])
503+
@mtkbuild sys = ODESystem(
504+
[D(x) ~ x, p ~ x + y], t; defaults = [p => missing], guesses = [p => 0.0])
503505
prob = ODEProblem(sys, [x => 1.0, y => 1.0], (0.0, 1.0))
504506
test_parameter(prob, p, 2.0)
505-
@mtkbuild sys = ODESystem([D(x) ~ x, p ~ x + y], t)
507+
@mtkbuild sys = ODESystem([D(x) ~ x, p ~ x + y], t; guesses = [p => 0.0])
506508
prob = ODEProblem(sys, [x => 1.0, y => 1.0], (0.0, 1.0), [p => missing])
507509
test_parameter(prob, p, 2.0)
508510

@@ -516,7 +518,7 @@ end
516518
@testset "Null system" begin
517519
@variables x(t) y(t) s(t)
518520
@parameters x0 y0
519-
@mtkbuild sys = ODESystem([x ~ x0, y ~ y0, s ~ x + y], t)
521+
@mtkbuild sys = ODESystem([x ~ x0, y ~ y0, s ~ x + y], t; guesses = [y0 => 0.0])
520522
prob = ODEProblem(sys, [s => 1.0], (0.0, 1.0), [x0 => 0.3, y0 => missing])
521523
test_parameter(prob, y0, 0.7)
522524
end

0 commit comments

Comments
 (0)