Skip to content

Commit 4f70d0a

Browse files
fix a bunch of depwarns
1 parent b12c854 commit 4f70d0a

File tree

3 files changed

+29
-27
lines changed

3 files changed

+29
-27
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ModelingToolkit"
22
uuid = "961ee093-0014-501f-94e3-6117800e7a78"
33
authors = ["Chris Rackauckas <[email protected]>"]
4-
version = "5.6.0"
4+
version = "5.6.1"
55

66
[deps]
77
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"

src/systems/diffeqs/abstractodesystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function generate_function(sys::AbstractODESystem, dvs = states(sys), ps = param
6161
return build_function(rhss,
6262
map(x->time_varying_as_func(value(x), sys), dvs),
6363
map(x->time_varying_as_func(value(x), sys), ps),
64-
sys.iv; kwargs...)
64+
get_iv(sys); kwargs...)
6565
end
6666

6767
function time_varying_as_func(x, sys)

src/systems/reaction/reactionsystem.jl

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,11 @@ function oderatelaw(rx; combinatoric_ratelaw=true)
187187
end
188188

189189
function assemble_oderhs(rs; combinatoric_ratelaws=true)
190-
species_to_idx = Dict((x => i for (i,x) in enumerate(rs.states)))
191-
rhsvec = Any[0 for i in eachindex(rs.states)]
190+
sts = states(rs)
191+
species_to_idx = Dict((x => i for (i,x) in enumerate(sts)))
192+
rhsvec = Any[0 for i in eachindex(sts)]
192193

193-
for rx in rs.eqs
194+
for rx in equations(rs)
194195
rl = oderatelaw(rx; combinatoric_ratelaw=combinatoric_ratelaws)
195196
for (spec,stoich) in rx.netstoich
196197
i = species_to_idx[spec]
@@ -210,20 +211,21 @@ end
210211
function assemble_drift(rs; combinatoric_ratelaws=true, as_odes=true)
211212
rhsvec = assemble_oderhs(rs; combinatoric_ratelaws=combinatoric_ratelaws)
212213
if as_odes
213-
D = Differential(rs.iv)
214-
eqs = [Equation(D(x),rhs) for (x,rhs) in zip(rs.states,rhsvec)]
214+
D = Differential(get_iv(rs))
215+
eqs = [Equation(D(x),rhs) for (x,rhs) in zip(states(rs),rhsvec)]
215216
else
216217
eqs = [Equation(0,rhs) for rhs in rhsvec]
217218
end
218219
eqs
219220
end
220221

221222
function assemble_diffusion(rs, noise_scaling; combinatoric_ratelaws=true)
222-
eqs = Matrix{Any}(undef, length(rs.states), length(rs.eqs))
223+
sts = states(rs)
224+
eqs = Matrix{Any}(undef, length(sts), length(equations(rs)))
223225
eqs .= 0
224-
species_to_idx = Dict((x => i for (i,x) in enumerate(rs.states)))
226+
species_to_idx = Dict((x => i for (i,x) in enumerate(sts)))
225227

226-
for (j,rx) in enumerate(rs.eqs)
228+
for (j,rx) in enumerate(equations(rs))
227229
rlsqrt = sqrt(abs(oderatelaw(rx; combinatoric_ratelaw=combinatoric_ratelaws)))
228230
(noise_scaling!==nothing) && (rlsqrt *= noise_scaling[j])
229231
for (spec,stoich) in rx.netstoich
@@ -283,7 +285,7 @@ end
283285
"""
284286
```julia
285287
ismassaction(rx, rs; rxvars = get_variables(rx.rate),
286-
haveivdep = any(var -> isequal(rs.iv,var), rxvars),
288+
haveivdep = any(var -> isequal(get_iv(rs),var), rxvars),
287289
stateset = Set(states(rs)))
288290
```
289291
@@ -299,7 +301,7 @@ explicitly on the independent variable (usually time).
299301
- Optional: `stateset`, set of states which if the rxvars are within mean rx is non-mass action.
300302
"""
301303
function ismassaction(rx, rs; rxvars = get_variables(rx.rate),
302-
haveivdep = any(var -> isequal(rs.iv,var), rxvars),
304+
haveivdep = any(var -> isequal(get_iv(rs),var), rxvars),
303305
stateset = Set(states(rs)))
304306
# if no dependencies must be zero order
305307
(length(rxvars)==0) && return true
@@ -332,15 +334,15 @@ function assemble_jumps(rs; combinatoric_ratelaws=true)
332334
stateset = Set(states(rs))
333335
#rates = []; rstoich = []; nstoich = []
334336
rxvars = []
335-
ivname = rs.iv.name
337+
ivname = nameof(get_iv(rs))
336338

337339
isempty(equations(rs)) && error("Must give at least one reaction before constructing a JumpSystem.")
338340
for rx in equations(rs)
339341
empty!(rxvars)
340342
(rx.rate isa Symbolic) && get_variables!(rxvars, rx.rate)
341343
haveivdep = false
342344
@inbounds for i = 1:length(rxvars)
343-
if isequal(rxvars[i], rs.iv)
345+
if isequal(rxvars[i], get_iv(rs))
344346
haveivdep = true
345347
break
346348
end
@@ -378,8 +380,8 @@ ignored.
378380
"""
379381
function Base.convert(::Type{<:ODESystem}, rs::ReactionSystem; combinatoric_ratelaws=true)
380382
eqs = assemble_drift(rs; combinatoric_ratelaws=combinatoric_ratelaws)
381-
ODESystem(eqs,rs.iv,rs.states,rs.ps,name=rs.name,
382-
systems=convert.(ODESystem,rs.systems))
383+
ODESystem(eqs,get_iv(rs),states(rs),get_ps(rs),name=nameof(rs),
384+
systems=convert.(ODESystem,get_systems(rs)))
383385
end
384386

385387
"""
@@ -397,7 +399,7 @@ ignored.
397399
"""
398400
function Base.convert(::Type{<:NonlinearSystem},rs::ReactionSystem; combinatoric_ratelaws=true)
399401
eqs = assemble_drift(rs; combinatoric_ratelaws=combinatoric_ratelaws, as_odes=false)
400-
NonlinearSystem(eqs,rs.states,rs.ps,name=rs.name,systems=convert.(NonlinearSystem,rs.systems))
402+
NonlinearSystem(eqs,states(rs),get_ps(rs),name=nameof(rs),systems=convert.(NonlinearSystem,get_systems(rs)))
401403
end
402404

403405
"""
@@ -424,12 +426,12 @@ This input may contain repeat parameters.
424426
function Base.convert(::Type{<:SDESystem},rs::ReactionSystem, combinatoric_ratelaws=true; noise_scaling=nothing)
425427

426428
if noise_scaling isa Vector
427-
(length(noise_scaling)!=length(rs.eqs)) &&
429+
(length(noise_scaling)!=length(equations(rs))) &&
428430
error("The number of elements in 'noise_scaling' must be equal " *
429431
"to the number of reactions in the reaction system.")
430432
noise_scaling = value.(noise_scaling)
431433
elseif !isnothing(noise_scaling)
432-
noise_scaling = fill(value(noise_scaling),length(rs.eqs))
434+
noise_scaling = fill(value(noise_scaling),length(equations(rs)))
433435
end
434436

435437
eqs = assemble_drift(rs; combinatoric_ratelaws=combinatoric_ratelaws)
@@ -439,12 +441,12 @@ function Base.convert(::Type{<:SDESystem},rs::ReactionSystem, combinatoric_ratel
439441

440442
SDESystem(eqs,
441443
noiseeqs,
442-
rs.iv,
443-
rs.states,
444+
get_iv(iv),
445+
states(rs),
444446
(noise_scaling===nothing) ?
445-
rs.ps :
446-
union(rs.ps,toparam.(noise_scaling)),
447-
name=rs.name,systems=convert.(SDESystem,rs.systems))
447+
get_ps(rs) :
448+
union(get_ps(rs),toparam.(noise_scaling)),
449+
name=rs.name,systems=convert.(SDESystem,get_systems(rs)))
448450
end
449451

450452
"""
@@ -462,8 +464,8 @@ Notes:
462464
"""
463465
function Base.convert(::Type{<:JumpSystem},rs::ReactionSystem; combinatoric_ratelaws=true)
464466
eqs = assemble_jumps(rs; combinatoric_ratelaws=combinatoric_ratelaws)
465-
JumpSystem(eqs,rs.iv,rs.states,rs.ps,name=rs.name,
466-
systems=convert.(JumpSystem,rs.systems))
467+
JumpSystem(eqs,get_iv(rs),states(rs),get_ps(rs),name=nameof(rs),
468+
systems=convert.(JumpSystem,get_systems(rs)))
467469
end
468470

469471

@@ -484,7 +486,7 @@ end
484486
# SDEProblem from AbstractReactionNetwork
485487
function DiffEqBase.SDEProblem(rs::ReactionSystem, u0, tspan, p=DiffEqBase.NullParameters(), args...; noise_scaling=nothing, kwargs...)
486488
sde_sys = convert(SDESystem,rs,noise_scaling=noise_scaling)
487-
p_matrix = zeros(length(rs.states), length(rs.eqs))
489+
p_matrix = zeros(length(states(rs)), length(equations(rs)))
488490
return SDEProblem(sde_sys,u0,tspan,p,args...; noise_rate_prototype=p_matrix,kwargs...)
489491
end
490492

0 commit comments

Comments
 (0)