Skip to content

Commit adb2d29

Browse files
committed
up
1 parent b42bb62 commit adb2d29

File tree

10 files changed

+653
-448
lines changed

10 files changed

+653
-448
lines changed

src/reaction_network.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,6 @@ function make_reaction_system(ex::Expr; name = :(gensym(:ReactionSystem)))
361361
default_reaction_metadata = :([])
362362
check_default_noise_scaling!(default_reaction_metadata, options)
363363
compound_expr, compound_species = read_compound_options(options)
364-
check_default_noise_scaling!(default_reaction_metadata, options)
365364

366365
# Parses reactions, species, and parameters.
367366
reactions = get_reactions(reaction_lines)

src/reactionsystem.jl

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,15 +1503,14 @@ function Base.convert(::Type{<:ODESystem}, rs::ReactionSystem; name = nameof(rs)
15031503
include_zero_odes)
15041504
eqs, sts, ps, obs, defs = addconstraints!(eqs, fullrs, ists, ispcs; remove_conserved)
15051505

1506-
osys = ODESystem(eqs, get_iv(fullrs), sts, ps;
1506+
ODESystem(eqs, get_iv(fullrs), sts, ps;
15071507
observed = obs,
15081508
name,
15091509
defaults = _merge(defaults,defs),
15101510
checks,
15111511
continuous_events = MT.get_continuous_events(fullrs),
15121512
discrete_events = MT.get_discrete_events(fullrs),
15131513
kwargs...)
1514-
return osys
15151514
end
15161515

15171516
"""
@@ -1546,13 +1545,12 @@ function Base.convert(::Type{<:NonlinearSystem}, rs::ReactionSystem; name = name
15461545
error_if_constraint_odes(NonlinearSystem, fullrs)
15471546
eqs, sts, ps, obs, defs = addconstraints!(eqs, fullrs, ists, ispcs; remove_conserved)
15481547

1549-
nlsys = NonlinearSystem(eqs, sts, ps;
1548+
NonlinearSystem(eqs, sts, ps;
15501549
name,
15511550
observed = obs,
15521551
defaults = _merge(defaults,defs),
15531552
checks,
15541553
kwargs...)
1555-
return nlsys
15561554
end
15571555

15581556
"""
@@ -1596,15 +1594,14 @@ function Base.convert(::Type{<:SDESystem}, rs::ReactionSystem;
15961594
@info "Boundary condition species detected. As constraint equations are not currently supported when converting to SDESystems, the resulting system will be undetermined. Consider using constant species instead."
15971595
end
15981596

1599-
ssys = SDESystem(eqs, noiseeqs, get_iv(flatrs), sts, ps;
1597+
SDESystem(eqs, noiseeqs, get_iv(flatrs), sts, ps;
16001598
observed = obs,
16011599
name,
16021600
defaults = defs,
16031601
checks,
16041602
continuous_events = MT.get_continuous_events(flatrs),
16051603
discrete_events = MT.get_discrete_events(flatrs),
16061604
kwargs...)
1607-
return ssys
16081605
end
16091606

16101607
"""
@@ -1630,7 +1627,7 @@ function Base.convert(::Type{<:JumpSystem}, rs::ReactionSystem; name = nameof(rs
16301627
remove_conserved = nothing, checks = false,
16311628
default_u0 = Dict(), default_p = Dict(), defaults = _merge(Dict(default_u0), Dict(default_p)),
16321629
kwargs...)
1633-
iscomplete(rs) || error(COMPLETENESS_ERROR)
1630+
iscomplete(rs) || error(COMPLETENESS_ERROR)
16341631
spatial_convert_err(rs::ReactionSystem, JumpSystem)
16351632

16361633
(remove_conserved !== nothing) &&
@@ -1649,14 +1646,13 @@ function Base.convert(::Type{<:JumpSystem}, rs::ReactionSystem; name = nameof(rs
16491646
any(isbc, get_unknowns(flatrs)) && (sts = vcat(sts, filter(isbc, get_unknowns(flatrs))))
16501647
ps = get_ps(flatrs)
16511648

1652-
jsys = JumpSystem(eqs, get_iv(flatrs), sts, ps;
1649+
JumpSystem(eqs, get_iv(flatrs), sts, ps;
16531650
observed = MT.observed(flatrs),
16541651
name,
16551652
defaults = _merge(defaults,MT.defaults(flatrs)),
16561653
checks,
16571654
discrete_events = MT.discrete_events(flatrs),
16581655
kwargs...)
1659-
return jsys
16601656
end
16611657

16621658
### Converts a reaction system to ODE or SDE problems ###
@@ -1821,7 +1817,7 @@ function MT.flatten(rs::ReactionSystem; name = nameof(rs))
18211817
balanced_bc_check = false,
18221818
spatial_ivs = get_sivs(rs),
18231819
continuous_events = MT.continuous_events(rs),
1824-
discrete_events = MT.continuous_events(rs))
1820+
discrete_events = MT.discrete_events(rs))
18251821
end
18261822

18271823
"""

test/dsl/dsl_model_construction.jl

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
### Fetch Packages and Reaction Networks ###
1+
### Prepares Tests ###
22

33
# Fetch packages.
44
using DiffEqBase, Catalyst, Random, Test
@@ -203,7 +203,7 @@ let
203203
end
204204
end
205205

206-
# Compares networks to networks written without parameters
206+
# Compares networks to networks written without parameters.
207207
let
208208
identical_networks_3 = Vector{Pair}()
209209
parameter_sets = []
@@ -421,3 +421,15 @@ let
421421
@test_throws LoadError @eval @reaction k, 0 --> im
422422
@test_throws LoadError @eval @reaction k, 0 --> nothing
423423
end
424+
425+
426+
### Other Tests ###
427+
428+
# Test names work.
429+
let
430+
rn = @reaction_network SIR1 begin
431+
k1, S + I --> 2I
432+
k2, I --> R
433+
end
434+
@test nameof(rn) == :SIR1
435+
end

0 commit comments

Comments
 (0)