Skip to content

Commit 544896d

Browse files
hersleChrisRackauckas
authored andcommitted
Just error if an equation only contains parameters (and no variables)
1 parent be2f38d commit 544896d

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/utils.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,12 @@ function check_equations(eqs, iv)
201201
isequal(single_iv, iv) ||
202202
throw(ArgumentError("Differential w.r.t. variable ($single_iv) other than the independent variable ($iv) are not allowed."))
203203
end
204+
205+
for eq in eqs
206+
vars, pars = collect_vars(eq, iv)
207+
isempty(vars) && !isempty(pars) &&
208+
throw(ArgumentError("Equation $eq contains only parameters, but relationships between parameters should be specified with defaults or parameter_dependencies."))
209+
end
204210
end
205211
"""
206212
Get all the independent variables with respect to which differentials are taken.

test/odesystem.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,6 @@ eqs = [
427427
@parameters p q
428428
@test_throws ArgumentError ODESystem([p ~ q], t; name = :foo)
429429
@test_throws ArgumentError ODESystem([p ~ 1], t; name = :foo)
430-
@test_throws ArgumentError ODESystem([1 ~ 2], t; name = :foo)
431430

432431
@variables x(t)
433432
@parameters M b k

0 commit comments

Comments
 (0)