Skip to content

Commit

Permalink
revert lattice reaction system changes
Browse files Browse the repository at this point in the history
  • Loading branch information
TorkelE committed Mar 31, 2024
1 parent 3ef3931 commit 9d793ac
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src/spatial_reaction_systems/lattice_reaction_systems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ struct LatticeReactionSystem{S,T} # <: MT.AbstractTimeDependentSystem
All parameters related to the lattice reaction system
(both with spatial and non-spatial effects).
"""
parameters::Vector{Any}
parameters::Vector{BasicSymbolic{Real}}
"""
Parameters which values are tied to vertexes (adjacencies),
e.g. (possibly) have an unique value at each vertex of the system.
"""
vertex_parameters::Vector{Any}
vertex_parameters::Vector{BasicSymbolic{Real}}
"""
Parameters which values are tied to edges (adjacencies),
e.g. (possibly) have an unique value at each edge of the system.
"""
edge_parameters::Vector{Any}
edge_parameters::Vector{BasicSymbolic{Real}}

function LatticeReactionSystem(rs::ReactionSystem{S}, spatial_reactions::Vector{T},
lattice::DiGraph; init_digraph = true) where {S, T}
Expand All @@ -52,7 +52,7 @@ struct LatticeReactionSystem{S,T} # <: MT.AbstractTimeDependentSystem
num_species = length(unique([species(rs); spat_species]))
rs_edge_parameters = filter(isedgeparameter, parameters(rs))
if isempty(spatial_reactions)
srs_edge_parameters = Vector{Any}[]
srs_edge_parameters = Vector{BasicSymbolic{Real}}[]
else
srs_edge_parameters = setdiff(reduce(vcat, [parameters(sr) for sr in spatial_reactions]), parameters(rs))
end
Expand Down
20 changes: 18 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@ using SafeTestsets
### Run the tests ###
@time begin

### Tests the properties of ReactionSystems. ###
@time @safetestset "Reactions" begin include("reactionsystem_structure/reactions.jl") end
@time @safetestset "ReactionSystem" begin include("reactionsystem_structure/reactionsystem.jl") end
@time @safetestset "Higher Order Reactions" begin include("reactionsystem_structure/higher_order_reactions.jl") end

### Tests model creation via the @reaction_network DSL. ###
@time @safetestset "Basic DSL" begin include("dsl/dsl_basics.jl") end
@time @safetestset "DSL Model Construction" begin include("dsl/dsl_model_construction.jl") end
@time @safetestset "Custom CRN Functions" begin include("dsl/custom_functions.jl") end
@time @safetestset "DSL Options" begin include("dsl/dsl_options.jl") end

### Non-DSL model creation and modification. ###
@time @safetestset "ReactionSystem Components Based Creation" begin include("programmatic_model_creation/component_based_model_creation.jl") end
@time @safetestset "Programmatic Model Expansion" begin include("programmatic_model_creation/programmatic_model_expansion.jl") end

# Runs various miscellaneous tests.
@time @safetestset "API" begin include("miscellaneous_tests/api.jl") end
@time @safetestset "Symbolic Stoichiometry" begin include("miscellaneous_tests/symbolic_stoichiometry.jl") end
@time @safetestset "NonlinearProblems and Steady State Solving" begin include("miscellaneous_tests/nonlinear_solve.jl") end
@time @safetestset "Events" begin include("miscellaneous_tests/events.jl") end
Expand All @@ -25,8 +42,7 @@ using SafeTestsets
### Tests Spatial Network Simulations. ###
@time @safetestset "PDE Systems Simulations" begin include("spatial_reaction_systems/simulate_PDEs.jl") end
@time @safetestset "Lattice Reaction Systems" begin include("spatial_reaction_systems/lattice_reaction_systems.jl") end
# Requires internal rework due to permitting non-default parameter types. However, rework have already been carried out in a separate branch.
# @time @safetestset "ODE Lattice Systems Simulations" begin include("spatial_reaction_systems/lattice_reaction_systems_ODEs.jl") end
@time @safetestset "ODE Lattice Systems Simulations" begin include("spatial_reaction_systems/lattice_reaction_systems_ODEs.jl") end

### Tests network visualization. ###
@time @safetestset "Latexify" begin include("visualization/latexify.jl") end
Expand Down
23 changes: 13 additions & 10 deletions test/spatial_reaction_systems/lattice_reaction_systems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,12 @@ let
@test_throws ErrorException LatticeReactionSystem(rs, [tr], grid)
end


### Test Designation of Parameter Types ###
# Currently not supported. Won't be until the LatticeReactionSystem internal update is merged.

# Checks that parameter types designated in the non-spatial `ReactionSystem` is handled correctly.
let
@test_broken let
# Declares LatticeReactionSystem with designated parameter types.
rs = @reaction_network begin
@parameters begin
Expand Down Expand Up @@ -326,7 +328,7 @@ end

# Checks that programmatically declared parameters (with types) can be used in `TransportReaction`s.
# Checks that LatticeReactionSystem with non-default parameter types can be simulated.
let
@test_broken let
rs = @reaction_network begin
@parameters p::Float32
(p,d), 0 <--> X
Expand Down Expand Up @@ -354,11 +356,12 @@ end

# Tests that LatticeReactionSystem cannot be generated where transport reactions depend on parameters
# that have a type designated in the non-spatial `ReactionSystem`.
let
rs = @reaction_network begin
@parameters D::Int64
(p,d), 0 <--> X
end
tr = @transport_reaction D X
@test_throws Exception LatticeReactionSystem(rs, tr, grid)
end
@test_broken false
# let
# rs = @reaction_network begin
# @parameters D::Int64
# (p,d), 0 <--> X
# end
# tr = @transport_reaction D X
# @test_throws Exception LatticeReactionSystem(rs, tr, grid)
# end

0 comments on commit 9d793ac

Please sign in to comment.