Skip to content

Commit f84e571

Browse files
test: test passing nothing to u0 for all system types
1 parent bbc8bf7 commit f84e571

File tree

5 files changed

+31
-1
lines changed

5 files changed

+31
-1
lines changed

test/discrete_system.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,3 +271,11 @@ end
271271
k = ShiftIndex(t)
272272
@named sys = DiscreteSystem([x ~ x^2 + y^2, y ~ x(k - 1) + y(k - 1)], t)
273273
@test_throws ["algebraic equations", "not yet supported"] structural_simplify(sys)
274+
275+
@testset "Passing `nothing` to `u0`" begin
276+
@variables x(t) = 1
277+
k = ShiftIndex()
278+
@mtkbuild sys = DiscreteSystem([x(k) ~ x(k - 1) + 1], t)
279+
prob = @test_nowarn DiscreteProblem(sys, nothing, (0.0, 1.0))
280+
@test_nowarn solve(prob, FunctionMap())
281+
end

test/nonlinearsystem.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,3 +318,10 @@ sys = structural_simplify(ns; conservative = true)
318318
sol = solve(prob, NewtonRaphson())
319319
@test sol[x] sol[y] sol[z] -3
320320
end
321+
322+
@testset "Passing `nothing` to `u0`" begin
323+
@variables x = 1
324+
@mtkbuild sys = NonlinearSystem([0 ~ x^2 - x^3 + 3])
325+
prob = @test_nowarn NonlinearProblem(sys, nothing)
326+
@test_nowarn solve(prob)
327+
end

test/odesystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1390,7 +1390,7 @@ end
13901390

13911391
@testset "Passing `nothing` to `u0`" begin
13921392
@variables x(t) = 1
1393-
@mtkbuild sys = ODEProblem(D(x) ~ t, t)
1393+
@mtkbuild sys = ODESystem(D(x) ~ t, t)
13941394
prob = @test_nowarn ODEProblem(sys, nothing, (0.0, 1.0))
13951395
@test_nowarn solve(prob)
13961396
end

test/optimizationsystem.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,3 +340,10 @@ end
340340
prob.f.cons_h(H3, [1.0, 1.0], [1.0, 100.0])
341341
@test prob.f.cons_h([1.0, 1.0], [1.0, 100.0]) == H3
342342
end
343+
344+
@testset "Passing `nothing` to `u0`" begin
345+
@variables x = 1.0
346+
@mtkbuild sys = OptimizationSystem((x - 3)^2, [x], [])
347+
prob = @test_nowarn OptimizationProblem(sys, nothing)
348+
@test_nowarn solve(prob, NelderMead())
349+
end

test/sdesystem.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,3 +776,11 @@ end
776776
prob = SDEProblem(de, u0map, (0.0, 100.0), parammap)
777777
@test solve(prob, SOSRI()).retcode == ReturnCode.Success
778778
end
779+
780+
@testset "Passing `nothing` to `u0`" begin
781+
@variables x(t) = 1
782+
@brownian b
783+
@mtkbuild sys = System([D(x) ~ x + b], t)
784+
prob = @test_nowarn SDEProblem(sys, nothing, (0.0, 1.0))
785+
@test_nowarn solve(prob, ImplicitEM())
786+
end

0 commit comments

Comments
 (0)