Skip to content

Commit e780a31

Browse files
committed
Add more nonlinear tests
1 parent 2f5ced4 commit e780a31

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/analysis/ipoincidence.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ function apply_linear_incidence(𝕃, ret::Incidence, caller::Union{CallerMappin
109109
end
110110
# We'll only be state-dependent if variables from the callee
111111
# map to at least one other variable than `j`.
112-
state_dependent |= length(used_caller_variables) - did_use_time > 1
112+
if j == 1 # time
113+
state_dependent |= length(used_caller_variables) > 1
114+
else # state
115+
state_dependent |= length(used_caller_variables) - did_use_time > 1
116+
end
113117
# If another state may contain time, we may be time-dependent too.
114118
time_dependent |= did_use_time
115119
end

test/incidence.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,26 @@ dependencies(row) = sort(rowvals(row) .=> nonzeros(row), by = first)
272272
incidence = @infer_incidence _muladd2(u₁, u₂, u₁, u₃)
273273
@test dependencies(incidence.row) == [2 => nonlinear, 3 => linear_state_dependent, 4 => linear_state_dependent]
274274
@test incidence == incidence"f(u₁, ∝ₛu₂, ∝ₛu₃)"
275+
276+
incidence = @infer_incidence exp(u₁)
277+
@test dependencies(incidence.row) == [2 => nonlinear]
278+
@test incidence == incidence"a + f(u₁)"
279+
280+
incidence = @infer_incidence t * exp(u₁)
281+
@test dependencies(incidence.row) == [1 => linear_state_dependent, 2 => nonlinear]
282+
@test incidence == incidence"a + f(∝ₛt, u₁)"
283+
284+
incidence = @infer_incidence u₁ * exp(t)
285+
@test dependencies(incidence.row) == [1 => nonlinear, 2 => linear_time_dependent]
286+
@test incidence == incidence"a + f(t, ∝ₜu₁)"
287+
288+
incidence = @infer_incidence u₁ * exp(t + u₂)
289+
@test dependencies(incidence.row) == [1 => nonlinear, 2 => linear_time_and_state_dependent, 3 => nonlinear]
290+
@test incidence == incidence"a + f(t, ∝ₜₛu₁, u₂)"
291+
292+
incidence = @infer_incidence atan(u₁, u₂)
293+
@test dependencies(incidence.row) == [2 => nonlinear, 3 => nonlinear]
294+
@test incidence == incidence"a + f(u₁, u₂)"
275295
end;
276296

277297
end

0 commit comments

Comments
 (0)