Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warning fixes #755

Merged
merged 1 commit into from
Dec 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ plot(bif_dia; xguide="k1", yguide="X")
- Updated Bifurcation documentation with respect to this new feature.

## Catalyst 13.5
- Added a CatalystHomotopyContinuationExtension extension, which exports the `hc_steady_state` function if HomotopyContinuation is exported. `hc_steady_state` finds the steady states of a reaction system using the homotopy continuation method. This feature is only available for julia versions 1.9+. Example:
- Added a CatalystHomotopyContinuationExtension extension, which exports the `hc_steady_state` function if HomotopyContinuation is exported. `hc_steady_state` finds the steady states of a reaction system using the homotopy continuation method. This feature is only available for julia versions 1.9+. Example:
```julia
wilhelm_2009_model = @reaction_network begin
k1, Y --> 2X
Expand Down Expand Up @@ -792,7 +792,7 @@ rn = @reaction_network Reversible_Reaction begin
k1, A --> B
k2, B --> A
end k1 k2
nameof(rn) == :Reversible_Reaction
ModelingToolkit.nameof(rn) == :Reversible_Reaction
```
Note, empty networks can no longer be created with parameters, i.e. only
```julia
Expand Down
2 changes: 1 addition & 1 deletion docs/src/catalyst_functionality/dsl_description.md
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ We can now simulate the network without providing any initial conditions:
```@example tut2
u0 = []
tspan = (0.0, 10.0)
p = [:p => 2.0, :d => .1, :X0 => 1.0]
p = [:p => 2.0, :d => .1, :X0 => 1.0]
oprob = ODEProblem(rn, u0, tspan, p)
sol = solve(oprob)
plot(sol)
Expand Down
2 changes: 1 addition & 1 deletion docs/unpublished/pdes.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ parameters in (Kim et al., J. Chem. Phys., 146, 2017).
First we load the packages we'll use
```julia
using Catalyst, MethodOfLines, DomainSets, OrdinaryDiffEq, Plots, Random, Distributions
using ModelingToolkit: scalarize, unwrap, operation, nameof, defaults
using ModelingToolkit: scalarize, unwrap, operation, defaults
```

Next let's specify our default parameter values
Expand Down
10 changes: 5 additions & 5 deletions ext/CatalystBifurcationKitExtension/bifurcation_kit_extension.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
### Dispatch for BifurcationKit BifurcationProblems ###

# Creates a BifurcationProblem, using a ReactionSystem as an input.
function BK.BifurcationProblem(rs::ReactionSystem, u0_bif, ps, bif_par, args...;
plot_var=nothing, record_from_solution=BK.record_sol_default, jac=true, u0=[], kwargs...)
function BK.BifurcationProblem(rs::ReactionSystem, u0_bif, ps, bif_par, args...;
plot_var=nothing, record_from_solution=BK.record_sol_default, jac=true, u0=[], kwargs...)

# Converts symbols to symbolics.
(bif_par isa Symbol) && (bif_par = rs.var_to_name[bif_par])
(plot_var isa Symbol) && (plot_var = rs.var_to_name[plot_var])
(bif_par isa Symbol) && (bif_par = ModelingToolkit.get_var_to_name(rs)[bif_par])
(plot_var isa Symbol) && (plot_var = ModelingToolkit.get_var_to_name(rs)[plot_var])
((u0_bif isa Vector{<:Pair{Symbol,<:Any}}) || (u0_bif isa Dict{Symbol, <:Any})) && (u0_bif = symmap_to_varmap(rs, u0_bif))
((ps isa Vector{<:Pair{Symbol,<:Any}}) || (ps isa Dict{Symbol, <:Any})) && (ps = symmap_to_varmap(rs, ps))
((u0 isa Vector{<:Pair{Symbol,<:Any}}) || (u0 isa Dict{Symbol, <:Any})) && (u0 = symmap_to_varmap(rs, u0))
Expand All @@ -16,6 +16,6 @@ function BK.BifurcationProblem(rs::ReactionSystem, u0_bif, ps, bif_par, args...;
nsys = convert(NonlinearSystem, rs; remove_conserved=true, defaults=Dict(u0))

# Makes BifurcationProblem (this call goes through the ModelingToolkit-based BifurcationKit extension).
return BK.BifurcationProblem(nsys, u0_bif, ps, bif_par, args...; plot_var=plot_var,
return BK.BifurcationProblem(nsys, u0_bif, ps, bif_par, args...; plot_var=plot_var,
record_from_solution=record_from_solution, jac=jac, kwargs...)
end
10 changes: 5 additions & 5 deletions src/graphs.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#######################################################################
# Contains code from Catlab.jl:
# https://raw.githubusercontent.com/AlgebraicJulia/Catlab.jl/master/src/graphics/Graphviz.jl
#
#
# That license for that code is:
#
# The MIT License
Expand Down Expand Up @@ -275,7 +275,7 @@
function edgify(δ, i, reverse::Bool)
attr = Attributes()
return map(δ) do p
val = String(p[1].f.name)
val = String(getname(p[1]))

Check warning on line 278 in src/graphs.jl

View check run for this annotation

Codecov / codecov/patch

src/graphs.jl#L278

Added line #L278 was not covered by tests
weight = "$(p[2])"
attr = Attributes(:label => weight, :labelfontsize => "6")
return Edge(reverse ? ["rx_$i", "$val"] :
Expand All @@ -289,7 +289,7 @@
for (i, rx) in enumerate(rxs)
deps = rx.rate isa Number ? Any[] : get_variables(rx.rate, specs)
for dep in deps
val = String(dep.f.name)
val = String(getname(dep))

Check warning on line 292 in src/graphs.jl

View check run for this annotation

Codecov / codecov/patch

src/graphs.jl#L292

Added line #L292 was not covered by tests
attr = Attributes(:color => "#d91111", :style => "dashed")
e = Edge(["$val", "rx_$i"], attr)
push!(es, e)
Expand Down Expand Up @@ -324,7 +324,7 @@
complexgraph(rn::ReactionSystem; complexdata=reactioncomplexes(rn))

Creates a Graphviz graph of the [`ReactionComplex`](@ref)s in `rn`. Reactions
correspond to arrows and reaction complexes to blue circles.
correspond to arrows and reaction complexes to blue circles.

Notes:
- Black arrows from complexes to complexes indicate reactions whose rate is a
Expand Down Expand Up @@ -389,7 +389,7 @@
function Graph(rn::ReactionSystem)
rxs = reactions(rn)
specs = species(rn)
statenodes = [Node(string(s.f.name),
statenodes = [Node(string(getname(s)),

Check warning on line 392 in src/graphs.jl

View check run for this annotation

Codecov / codecov/patch

src/graphs.jl#L392

Added line #L392 was not covered by tests
Attributes(:shape => "circle", :color => "#6C9AC3")) for s in specs]
transnodes = [Node(string("rx_$i"),
Attributes(:shape => "point", :color => "#E28F41", :width => ".1"))
Expand Down
2 changes: 1 addition & 1 deletion src/latexify_recipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
rxs = reactions(rn)
nonrxs = filter(eq -> eq isa Equation, equations(rn))
if isempty(rxs) && isempty(nonrxs)
latexstr = Latexify.LaTeXString("ReactionSystem $(nameof(rn)) has no reactions or equations.")
latexstr = Latexify.LaTeXString("ReactionSystem $(ModelingToolkit.nameof(rn)) has no reactions or equations.")

Check warning on line 121 in src/latexify_recipes.jl

View check run for this annotation

Codecov / codecov/patch

src/latexify_recipes.jl#L121

Added line #L121 was not covered by tests
Latexify.COPY_TO_CLIPBOARD && clipboard(latexstr)
return latexstr
end
Expand Down
2 changes: 1 addition & 1 deletion src/networkapi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,7 @@ conservedquantities(state, cons_laws) = cons_laws * state
function conservationlaw_errorcheck(rs, pre_varmap)
vars_with_vals = Set(p[1] for p in pre_varmap)
any(s -> s in vars_with_vals, species(rs)) && return
isempty(conservedequations(Catalyst.flatten(rs))) ||
isempty(conservedequations(Catalyst.flatten(rs))) ||
error("The system has conservation laws but initial conditions were not provided for some species.")
end

Expand Down
2 changes: 1 addition & 1 deletion src/reactionsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1438,7 +1438,7 @@ Notes:
"""
function Base.convert(::Type{<:JumpSystem}, rs::ReactionSystem; name = nameof(rs),
combinatoric_ratelaws = get_combinatoric_ratelaws(rs),
remove_conserved = nothing, checks = false,
remove_conserved = nothing, checks = false,
default_u0 = Dict(), default_p = Dict(), defaults = _merge(Dict(default_u0), Dict(default_p)),
kwargs...)
spatial_convert_err(rs::ReactionSystem, JumpSystem)
Expand Down
5 changes: 3 additions & 2 deletions src/registered_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ function expand_registered_functions(eq::Equation)
end
# If applied to a ReactionSystem, applied function to all Reactions and other Equations, and return updated system.
function expand_registered_functions(rs::ReactionSystem)
rs = @set rs.eqs = [Catalyst.expand_registered_functions(eq) for eq in rs.eqs]
return @set rs.rxs = [Catalyst.expand_registered_functions(rx) for rx in rs.rxs]
@set! rs.eqs = [Catalyst.expand_registered_functions(eq) for eq in get_eqs(rs)]
@set! rs.rxs = [Catalyst.expand_registered_functions(rx) for rx in get_rxs(rs)]
return rs
end
8 changes: 4 additions & 4 deletions test/dsl/dsl_basics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### Fetch Packages and Set Global Variables ###

using Catalyst
using Catalyst, ModelingToolkit
@variables t

### Naming Tests ###
Expand All @@ -12,14 +12,14 @@ let
@species A(t)
rx = Reaction(k, [A], nothing)
function rntest(rn, name)
@test nameof(rn) == name
@test ModelingToolkit.nameof(rn) == name
@test isequal(species(rn)[1], ModelingToolkit.unwrap(A))
@test isequal(parameters(rn)[1], ModelingToolkit.unwrap(k))
@test reactions(rn)[1] == rx
end

function emptyrntest(rn, name)
@test nameof(rn) == name
@test ModelingToolkit.nameof(rn) == name
@test numreactions(rn) == 0
@test numspecies(rn) == 0
@test numreactionparams(rn) == 0
Expand All @@ -42,7 +42,7 @@ let
@parameters k
k, A --> 0
end
rntest(rn, nameof(rn))
rntest(rn, ModelingToolkit.nameof(rn))

function makern(; name)
@reaction_network $name begin
Expand Down
2 changes: 1 addition & 1 deletion test/dsl/dsl_model_construction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Fetch packages.
using DiffEqBase, Catalyst, Random, Test
using ModelingToolkit: operation, istree, get_states, get_ps, get_eqs, get_systems,
get_iv
get_iv, nameof

# Sets rnd number.
using StableRNGs
Expand Down
52 changes: 26 additions & 26 deletions test/dsl/dsl_options.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,48 +49,48 @@ let
(k1, k2), A <--> B
end

n1 = @reaction_network name begin (k1, k2), A <--> B end
n2 = @reaction_network name begin
n1 = @reaction_network rnname begin (k1, k2), A <--> B end
n2 = @reaction_network rnname begin
@parameters k1 k2
(k1, k2), A <--> B
end
n3 = @reaction_network name begin
n3 = @reaction_network rnname begin
@species A(t) B(t)
(k1, k2), A <--> B
end
n4 = @reaction_network name begin
n4 = @reaction_network rnname begin
@parameters k1 k2
@species A(t) B(t)
(k1, k2), A <--> B
end
n5 = @reaction_network name begin
n5 = @reaction_network rnname begin
(k1, k2), A <--> B
@parameters k1 k2
end
n6 = @reaction_network name begin
n6 = @reaction_network rnname begin
(k1, k2), A <--> B
@species A(t) B(t)
end
n7 = @reaction_network name begin
n7 = @reaction_network rnname begin
(k1, k2), A <--> B
@parameters k1 k2
@species A(t) B(t)
end
n8 = @reaction_network name begin
n8 = @reaction_network rnname begin
@parameters begin
k1
k2
end
(k1, k2), A <--> B
end
n9 = @reaction_network name begin
n9 = @reaction_network rnname begin
@species begin
A(t)
B(t)
end
(k1, k2), A <--> B
end
n10 = @reaction_network name begin
n10 = @reaction_network rnname begin
@parameters begin
k1
k2
Expand All @@ -104,7 +104,7 @@ let
@test all(==(n1), (n2, n3, n4, n5, n6, n7, n8, n9, n10))
end

# Tests that when either @species or @parameters is given, the other is infered properly.
# Tests that when either @species or @parameters is given, the other is infered properly.
let
rn1 = @reaction_network begin
k*X, A + B --> 0
Expand Down Expand Up @@ -222,33 +222,33 @@ end

##Checks that some created networks are identical.
let
rn12 = @reaction_network name begin (k1, k2), A <--> B end
rn13 = @reaction_network name begin
rn12 = @reaction_network rnname begin (k1, k2), A <--> B end
rn13 = @reaction_network rnname begin
@parameters k1 k2
(k1, k2), A <--> B
end
rn14 = @reaction_network name begin
rn14 = @reaction_network rnname begin
@species A(t) B(t)
(k1, k2), A <--> B
end
rn15 = @reaction_network name begin
rn15 = @reaction_network rnname begin
@parameters k1 k2
@species A(t) B(t)
(k1, k2), A <--> B
end
@test all(==(rn12), (rn13, rn14, rn15))
end

# Checks that the rights things are put in vectors.
# Checks that the rights things are put in vectors.
let
rn18 = @reaction_network name begin
rn18 = @reaction_network rnname begin
@parameters p d1 d2
@species A(t) B(t)
p, 0 --> A
1, A --> B
(d1, d2), (A, B) --> 0
end
rn19 = @reaction_network name begin
rn19 = @reaction_network rnname begin
p, 0 --> A
1, A --> B
(d1, d2), (A, B) --> 0
Expand All @@ -263,21 +263,21 @@ let
@test isequal(species(rn18)[1], A)
@test isequal(species(rn18)[2], B)

rn20 = @reaction_network name begin
rn20 = @reaction_network rnname begin
@species X(t)
@parameters S
mm(X,v,K), 0 --> Y
(k1,k2), 2Y <--> Y2
d*Y, S*(Y2+Y) --> 0
end
rn21 = @reaction_network name begin
rn21 = @reaction_network rnname begin
@species X(t) Y(t) Y2(t)
@parameters v K k1 k2 d S
mm(X,v,K), 0 --> Y
(k1,k2), 2Y <--> Y2
d*Y, S*(Y2+Y) --> 0
end
rn22 = @reaction_network name begin
rn22 = @reaction_network rnname begin
@species X(t) Y2(t)
@parameters d k1
mm(X,v,K), 0 --> Y
Expand All @@ -291,17 +291,17 @@ let
@test issetequal(species(rn22), [X Y Y2])
end

# Tests that defaults work.
# Tests that defaults work.
let
rn26 = @reaction_network name begin
rn26 = @reaction_network rnname begin
@parameters p=1.0 d1 d2=5
@species A(t) B(t)=4
p, 0 --> A
1, A --> B
(d1, d2), (A, B) --> 0
end

rn27 = @reaction_network name begin
rn27 = @reaction_network rnname begin
@parameters p1=1.0 p2=2.0 k1=4.0 k2=5.0 v=8.0 K=9.0 n=3 d=10.0
@species X(t)=4.0 Y(t)=3.0 X2Y(t)=2.0 Z(t)=1.0
(p1,p2), 0 --> (X,Y)
Expand All @@ -312,7 +312,7 @@ let
u0_27 = []
p_27 = []

rn28 = @reaction_network name begin
rn28 = @reaction_network rnname begin
@parameters p1=1.0 p2 k1=4.0 k2 v=8.0 K n=3 d
@species X(t)=4.0 Y(t) X2Y(t) Z(t)=1.0
(p1,p2), 0 --> (X,Y)
Expand All @@ -324,7 +324,7 @@ let
p_28 = symmap_to_varmap(rn28, [:Y=>3.0, :X2Y=>2.0])
defs28 = Dict(Iterators.flatten((u0_28, p_28)))

rn29 = @reaction_network name begin
rn29 = @reaction_network rnname begin
@parameters p1 p2 k1 k2 v K n d
@species X(t) Y(t) X2Y(t) Z(t)
(p1,p2), 0 --> (X,Y)
Expand Down
2 changes: 1 addition & 1 deletion test/network_analysis/conservation_laws.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ let
cons_laws = conservationlaws(rn)
cons_eqs = conservedequations(rn)
cons_laws_constants = conservationlaw_constants(rn)
conserved_quantity = conservedquantities(cons_laws[1, :], rn.states[1])
conserved_quantity = conservedquantities(cons_laws[1, :], states(rn)[1])

@test sum(cons_laws) == 4
@test size(cons_laws) == (2, 4)
Expand Down
Loading
Loading