Skip to content

Commit ebd8392

Browse files
committed
make check explicit and add test
1 parent d2dba79 commit ebd8392

File tree

4 files changed

+5
-2
lines changed

4 files changed

+5
-2
lines changed

src/systems/diffeqs/abstractodesystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ function process_DEProblem(constructor, sys::AbstractODESystem,u0map,parammap;
304304
p = ps
305305
end
306306

307-
@assert length(dvs) == length(u0) "states and initial conditions are of different lengths"
307+
length(dvs) == length(u0) || throw(ArgumentError("States ($(length(dvs))) and initial conditions ($(length(u0))) are of different lengths."))
308308

309309
f = constructor(sys,dvs,ps,u0;tgrad=tgrad,jac=jac,checkbounds=checkbounds,
310310
linenumbers=linenumbers,parallel=parallel,simplify=simplify,

src/systems/nonlinear/nonlinearsystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ function process_NonlinearProblem(constructor, sys::NonlinearSystem,u0map,paramm
223223
p = ps
224224
end
225225

226-
@assert length(dvs) == length(u0) "states and initial conditions are of different lengths"
226+
length(dvs) == length(u0) || throw(ArgumentError("States ($(length(dvs))) and initial conditions ($(length(u0))) are of different lengths."))
227227

228228
f = constructor(sys,dvs,ps,u0;jac=jac,checkbounds=checkbounds,
229229
linenumbers=linenumbers,parallel=parallel,simplify=simplify,

test/nonlinearsystem.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ prob = NonlinearProblem(ns,ones(3),ones(3))
7575
sol = solve(prob,NewtonRaphson())
7676
@test sol.u[1] sol.u[2]
7777

78+
@test_throws ArgumentError NonlinearProblem(ns,ones(4),ones(3))
79+
7880
@variables u F s a
7981
eqs1 = [
8082
0 ~ σ*(y-x) + F,

test/odesystem.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ for (prob, atol) in [(prob1, 1e-12), (prob2, 1e-12), (prob3, 1e-12)]
230230
sol = solve(prob, Rodas5())
231231
@test all(x->(sum(x), 1.0, atol=atol), sol.u)
232232
end
233+
@test_throws ArgumentError ODEProblem(sys,zeros(5),tspan,p)
233234

234235
@test ModelingToolkit.construct_state(SArray{Tuple{3,3}}(rand(3,3)), [1,2]) == SVector{2}([1, 2])
235236

0 commit comments

Comments
 (0)