Skip to content

Commit a3c9b83

Browse files
committed
up
1 parent 46af9a2 commit a3c9b83

File tree

3 files changed

+16
-22
lines changed

3 files changed

+16
-22
lines changed

src/reactionsystem.jl

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,11 @@ end
728728
# Special dispatch for equations, applied `findvars!` to left-hand and right-hand sides.
729729
function findvars!(ps, us, eq_to_search::Equation, ivs, vars)
730730
findvars!(ps, us, eq_to_search.lhs, ivs, vars)
731-
findvars!(ps, us, eq_to_search.lhs, ivs, vars)
731+
findvars!(ps, us, eq_to_search.rhs, ivs, vars)
732+
end
733+
# Special dispatch for Vectors (applies it to each vector element).
734+
function findvars!(ps, us, exprs_to_search::Vector, ivs, vars)
735+
foreach(exprtosearch -> findvars!(ps, us, exprtosearch, ivs, vars), exprs_to_search)
732736
end
733737

734738
# Called internally (whether DSL-based or programmtic model creation is used).
@@ -812,22 +816,12 @@ function find_event_vars!(ps, us, events::Vector, ivs, vars)
812816
foreach(event -> find_event_vars!(ps, us, event, ivs, vars), events)
813817
end
814818
# For a single event, adds quantitites from its condition and affect expression(s) to `ps` and `us`.
819+
# Applies `findvars!` to the event's condition (`event[1])` and affec (`event[2]`).
815820
function find_event_vars!(ps, us, event, ivs, vars)
816-
conds, affects = event
817-
# For discrete events, the condition can be a single value (for periodic events).
818-
# If not, it is a vector of conditions and we must check each.
819-
if conds isa Vector
820-
for cond in conds
821-
findvars!(ps, us, cond, ivs, vars)
822-
end
823-
else
824-
findvars!(ps, us, conds, ivs, vars)
825-
end
826-
# The affects is always a vector of equations. Here, we handle the lhs and rhs separately.
827-
for affect in affects
828-
findvars!(ps, us, cond, ivs, vars)
829-
end
821+
findvars!(ps, us, event[1], ivs, vars)
822+
findvars!(ps, us, event[2], ivs, vars)
830823
end
824+
831825
"""
832826
remake_ReactionSystem_internal(rs::ReactionSystem;
833827
default_reaction_metadata::Vector{Pair{Symbol, T}} = Vector{Pair{Symbol, Any}}()) where {T}

test/reactionsystem_structure/coupled_equation_reaction_systems.jl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,7 @@ let
455455
@equations D(D(V)) ~ 1.0 - V
456456
(p,d), 0 <--> X
457457
end
458-
@test_broken false # Had problem writing this test, need to fix.
459-
#@test_warn convert(NonlinearSystem, rs)
458+
@test_logs (:warn, r".*") convert(NonlinearSystem, rs)
460459
end
461460

462461
# Differential on the rhs, should yield a warning.
@@ -466,8 +465,7 @@ let
466465
@equations D(V) ~ 1.0 - V + D(U)
467466
(p,d), 0 <--> X
468467
end
469-
@test_broken false # Had problem writing this test, need to fix.
470-
#@test_warn convert(NonlinearSystem, rs)
468+
@test_logs (:warn, r".*") convert(NonlinearSystem, rs)
471469
end
472470

473471
# Non-differential term on the lhs, should yield a warning.
@@ -478,8 +476,7 @@ let
478476
@equations D(V) + V ~ 1.0 - V
479477
(p,d), 0 <--> X
480478
end
481-
@test_broken false # Had problem writing this test, need to fix.
482-
#@test_warn convert(NonlinearSystem, rs)
479+
@test_logs (:warn, r".*") convert(NonlinearSystem, rs)
483480
end
484481
end
485482
### Unusual Differentials Tests ###

test/reactionsystem_structure/designating_parameter_types.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ let
132132
@test unwrap(mtk_struct[X5]) == 0.5
133133
end
134134

135+
# This test started working now, probably due to a MTK fix. Need to look at where to put it
136+
# back into the test properly though.
137+
@test_broken false
135138
# Indexing currently broken for NonlinearSystem integrators (MTK intend to support this though).
136-
@test_broken unwrap(ninit.ps[p1]) isa Float64
139+
@test unwrap(ninit.ps[p1]) isa Float64
137140
end

0 commit comments

Comments
 (0)