Skip to content

Commit

Permalink
Remove ComponentArrays dep, cleanup handling of skip_checks
Browse files Browse the repository at this point in the history
  • Loading branch information
BenChung committed Sep 24, 2024
1 parent bac568c commit e6bdd12
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
1 change: 0 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
ConstructionBase = "187b0558-2788-49d3-abe0-74a17ed4e7c9"
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
Expand Down
29 changes: 15 additions & 14 deletions src/systems/callbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1024,26 +1024,27 @@ function compile_user_affect(affect::MutatingFunctionalAffect, cb, sys, dvs, ps;
end

obs_exprs = observed(affect)
for oexpr in obs_exprs
invalid_vars = invalid_variables(sys, oexpr)
if length(invalid_vars) > 0 && !affect.skip_checks
error("Observed equation $(oexpr) in affect refers to missing variable(s) $(invalid_vars); the variables may not have been added (e.g. if a component is missing).")
if !affect.skip_checks
for oexpr in obs_exprs
invalid_vars = invalid_variables(sys, oexpr)
if length(invalid_vars) > 0
error("Observed equation $(oexpr) in affect refers to missing variable(s) $(invalid_vars); the variables may not have been added (e.g. if a component is missing).")
end
end
end
obs_syms = observed_syms(affect)
obs_syms, obs_exprs = check_dups(obs_syms, obs_exprs)

mod_exprs = modified(affect)
for mexpr in mod_exprs
if affect.skip_checks
continue
end
if !is_variable(sys, mexpr) && parameter_index(sys, mexpr) === nothing && !affect.skip_checks
@warn ("Expression $mexpr cannot be assigned to; currently only unknowns and parameters may be updated by an affect.")
end
invalid_vars = unassignable_variables(sys, mexpr)
if length(invalid_vars) > 0 && !affect.skip_checks
error("Modified equation $(mexpr) in affect refers to missing variable(s) $(invalid_vars); the variables may not have been added (e.g. if a component is missing) or they may have been reduced away.")
if !affect.skip_checks
for mexpr in mod_exprs
if !is_variable(sys, mexpr) && parameter_index(sys, mexpr) === nothing
@warn ("Expression $mexpr cannot be assigned to; currently only unknowns and parameters may be updated by an affect.")
end
invalid_vars = unassignable_variables(sys, mexpr)
if length(invalid_vars) > 0
error("Modified equation $(mexpr) in affect refers to missing variable(s) $(invalid_vars); the variables may not have been added (e.g. if a component is missing) or they may have been reduced away.")
end
end
end
mod_syms = modified_syms(affect)
Expand Down

0 comments on commit e6bdd12

Please sign in to comment.