Skip to content

Commit 75ece2b

Browse files
authored
Merge pull request #859 from SciML/renam_reactionparams
Rename `reactionparams` and similar functions
2 parents 5b3063d + dce6cf4 commit 75ece2b

File tree

8 files changed

+8
-59
lines changed

8 files changed

+8
-59
lines changed

HISTORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Catalyst unreleased (master branch)
44

55
## Catalyst 14.0
6+
- The `reactionparams`, `numreactionparams`, and `reactionparamsmap` functions have been removed.
67
- To be more consistent with ModelingToolkit's immutability requirement for systems, we have removed API functions that mutate `ReactionSystem`s such as `addparam!`, `addreaction!`, `addspecies`, `@add_reactions`, and `merge!`. Please use `ModelingToolkit.extend` and `ModelingToolkit.compose` to generate new merged and/or composed `ReactionSystem`s from multiple component systems.
78
- Added CatalystStructuralIdentifiabilityExtension, which permits StructuralIdentifiability.jl function to be applied directly to Catalyst systems. E.g. use
89
```julia

docs/src/api.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,6 @@ can call:
128128
the system and any sub-systems that are also `ReactionSystems`.
129129
* `ModelingToolkit.parameters(rn)` returns all parameters across the
130130
system, *all sub-systems*, and all constraint systems.
131-
* [`reactionparams(rn)`](@ref) is a vector of all the parameters within the
132-
system and any sub-systems that are also `ReactionSystem`s. These include all
133-
parameters that appear within some `Reaction`.
134131
* `ModelingToolkit.equations(rn)` returns all [`Reaction`](@ref)s and all
135132
`Symbolics.Equations` defined across the system, *all sub-systems*, and all
136133
constraint systems. `Reaction`s are ordered ahead of `Equation`s with the
@@ -155,16 +152,16 @@ accessor functions.
155152
```@docs
156153
species
157154
nonspecies
158-
reactionparams
155+
reactionsystemparams
159156
reactions
160157
nonreactions
161158
numspecies
162159
numparams
163160
numreactions
164-
numreactionparams
161+
numreactionsystemparams
165162
speciesmap
166163
paramsmap
167-
reactionparamsmap
164+
reactionsystemparamsmap
168165
isspecies
169166
Catalyst.isconstant
170167
Catalyst.isbc

src/Catalyst.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ export get_noise_scaling, has_noise_scaling
9898
# The `ReactionSystem` structure and its functions.
9999
include("reactionsystem.jl")
100100
export ReactionSystem, isspatial
101-
export species, nonspecies, reactionparams, reactions, nonreactions, speciesmap, paramsmap
102-
export numspecies, numreactions, numreactionparams, setdefaults!
103-
export make_empty_network, reactionparamsmap
101+
export species, nonspecies, reactions, nonreactions, speciesmap, paramsmap
102+
export numspecies, numreactions, setdefaults!
103+
export make_empty_network
104104
export dependants, dependents, substoichmat, prodstoichmat, netstoichmat
105105
export reactionrates
106106
export isequivalent

src/reactionsystem.jl

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -723,24 +723,6 @@ function get_indep_sts(rs::ReactionSystem, remove_conserved = false)
723723
indepsts, filter(isspecies, indepsts)
724724
end
725725

726-
"""
727-
reactionparams(network)
728-
729-
Given a [`ReactionSystem`](@ref), return a vector of all parameters defined
730-
within the system and any subsystems that are of type `ReactionSystem`. To get
731-
the parameters in the system and all subsystems, including non-`ReactionSystem`
732-
subsystems, use `parameters(network)`.
733-
734-
Notes:
735-
- Allocates and has to calculate these dynamically by comparison for each reaction.
736-
"""
737-
function reactionparams(network)
738-
ps = get_ps(network)
739-
systems = filter_nonrxsys(network)
740-
isempty(systems) && return ps
741-
unique([ps; reduce(vcat, map(sys -> species(sys, reactionparams(sys)), systems))])
742-
end
743-
744726
"""
745727
numparams(network)
746728
@@ -765,16 +747,6 @@ function paramsmap(network)
765747
Dict(p => i for (i, p) in enumerate(parameters(network)))
766748
end
767749

768-
"""
769-
reactionparamsmap(network)
770-
771-
Given a [`ReactionSystem`](@ref), return a Dictionary mapping from parameters that
772-
appear within `Reaction`s to their index within [`reactionparams(network)`](@ref).
773-
"""
774-
function reactionparamsmap(network)
775-
Dict(p => i for (i, p) in enumerate(reactionparams(network)))
776-
end
777-
778750
# used in the next function (`reactions(network)`).
779751
function namespace_reactions(network::ReactionSystem)
780752
rxs = reactions(network)
@@ -824,21 +796,6 @@ function nonreactions(network)
824796
equations(network)[(numreactions(network) + 1):end]
825797
end
826798

827-
"""
828-
numreactionparams(network)
829-
830-
Return the total number of parameters within the given [`ReactionSystem`](@ref)
831-
and subsystems that are `ReactionSystem`s.
832-
833-
Notes
834-
- If there are no subsystems this will be fast.
835-
- As this calls [`reactionparams`](@ref), it can be slow and will allocate if
836-
there are any subsystems.
837-
"""
838-
function numreactionparams(network)
839-
length(reactionparams(network))
840-
end
841-
842799
"""
843800
reactionrates(network)
844801

test/compositional_modelling/component_based_model_creation.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ let
297297
# Test API functions for composed model.
298298
@test issetequal(species(rs), [A, B, C])
299299
@test issetequal(unknowns(rs), [A, B, C, ns.D])
300-
@test issetequal(reactionparams(rs), [r₊, r₋])
301300
@test issetequal(parameters(rs), [r₊, r₋, ns.β])
302301
@test issetequal(reactions(rs), union(rxs1, rxs2))
303302
@test issetequal(filter(eq -> eq isa Reaction, equations(rs)), union(rxs1, rxs2))
@@ -340,7 +339,6 @@ let
340339
@test issetequal(unknowns(rs1), [A1, rs2.A2a, ns2.A2b, rs2.rs3.A3a, rs2.ns3.A3b])
341340
@test issetequal(species(rs1), [A1, rs2.A2a, rs2.rs3.A3a])
342341
@test issetequal(parameters(rs1), [p1, rs2.p2a, rs2.p2b, rs2.rs3.p3a, rs2.ns3.p3b])
343-
@test issetequal(reactionparams(rs1), [p1, rs2.p2a, rs2.p2b, rs2.rs3.p3a])
344342
@test issetequal(rxs, reactions(rs1))
345343
@test issetequal(eqs, equations(rs1))
346344
@test Catalyst.combinatoric_ratelaws(rs1)

test/dsl/dsl_advanced_model_construction.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ let
3535
@test ModelingToolkit.nameof(rn) == name
3636
@test numreactions(rn) == 0
3737
@test numspecies(rn) == 0
38-
@test numreactionparams(rn) == 0
3938
end
4039

4140
rn = @reaction_network name begin

test/miscellaneous_tests/api.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,13 @@ let
8383
@test pmat == prodstoichmat(rnmat) == Matrix(prodstoichmat(rnmat, sparse = true))
8484
end
8585

86-
# Tests `reactionparamsmap`, `reactionrates`, and `symmap_to_varmap` getters.
86+
# Tests `reactionrates`, and `symmap_to_varmap` getters.
8787
let
8888
rn = @reaction_network begin
8989
(p,d), 0 <--> X
9090
(kB,kD), 2X <--> X
9191
end
9292
@unpack p, d, kB, kD = rn
93-
isequal(reactionparamsmap(rn), Dict([p => 1, d => 2, kB => 3, kD => 4]))
9493
issetequal(reactionrates(rn), [p, d, kB, kD])
9594
isequal(symmap_to_varmap(rn, [:p => 1.0, :kB => 3.0]), [p => 1.0, kB => 3.0])
9695
end

test/reactionsystem_core/coupled_equation_crn_systems.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,7 @@ let
251251

252252
# Check parameters-related accessors.
253253
@test issetequal(parameters(coupled_rs), [p, d, v])
254-
@test issetequal(reactionparams(coupled_rs), [p, d, v])
255254
@test numparams(coupled_rs) == 3
256-
@test numreactionparams(coupled_rs) == 3
257255

258256
# Check other accessors.
259257
@test !isspatial(coupled_rs)

0 commit comments

Comments
 (0)