Skip to content

Commit 5780d91

Browse files
committed
Print detected transformation equations when there is not exactly one
1 parent 2d5aa12 commit 5780d91

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/systems/diffeqs/basic_transformations.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ function change_independent_variable(sys::AbstractODESystem, iv, eqs = []; dummi
137137
eqs = [eqs; get_eqs(sys)] # all equations (system-defined + user-provided) we may use
138138
idxs = findall(eq -> isequal(eq.lhs, D1(iv2_of_iv1)), eqs)
139139
if length(idxs) != 1
140-
error("Exactly one equation for $D1($iv2_of_iv1) was not specified!")
140+
error("Exactly one equation for $D1($iv2_of_iv1) was not specified! Got $(length(idxs)) equations:\n", join(eqs[idxs], '\n'))
141141
end
142142
div2_of_iv1_eq = popat!(eqs, only(idxs)) # get and remove e.g. du/dt = ... (may be added back later as a dummy)
143143
div2_of_iv1 = chain_rule(div2_of_iv1_eq.rhs)

test/basic_transformations.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,10 @@ end
148148
M = complete(M)
149149
@test_throws "singular" change_independent_variable(M, M.x)
150150
@test_throws "structurally simplified" change_independent_variable(structural_simplify(M), y)
151-
@test_throws "not specified" change_independent_variable(M, w)
152-
@test_throws "not specified" change_independent_variable(M, v)
151+
@test_throws "Got 0 equations:" change_independent_variable(M, w)
152+
@test_throws "Got 0 equations:" change_independent_variable(M, v)
153+
M = ODESystem([D(x) ~ 1, v ~ 1], t; name = :M) |> complete
154+
@test_throws "Got 2 equations:" change_independent_variable(M, M.x, [D(x) ~ 2])
153155
@test_throws "not a function of the independent variable" change_independent_variable(M, y)
154156
@test_throws "not a function of the independent variable" change_independent_variable(M, z)
155157
M = ODESystem([D(x) ~ 0, v ~ x], t; name = :M)

0 commit comments

Comments
 (0)