Skip to content

Commit 27c923c

Browse files
committed
fix more
1 parent 828d461 commit 27c923c

File tree

4 files changed

+19
-17
lines changed

4 files changed

+19
-17
lines changed

src/systems/abstractsystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ end
196196
function namespace_expr(O,name,ivname) where {T}
197197
if istree(O)
198198
if operation(O) isa Sym
199-
Term{T}(rename(operation(O),renamespace(name,operation(O).name)),namespace_expr.(arguments(O),name,ivname))
199+
Term{symtype(O)}(rename(operation(O),renamespace(name,operation(O).name)),namespace_expr.(arguments(O),name,ivname))
200200
else
201201
similarterm(O,operation(O),namespace_expr.(arguments(O),name,ivname))
202202
end

src/systems/jumps/jumpsystem.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ end
127127
function numericrstoich(mtrs::Vector{Pair{V,W}}, statetoid) where {V,W}
128128
rs = Vector{Pair{Int,W}}()
129129
for (spec,stoich) in mtrs
130-
if !(spec isa Term) && _iszero(spec)
130+
if !istree(spec) && _iszero(spec)
131131
push!(rs, 0 => stoich)
132132
else
133133
push!(rs, statetoid[value(spec)] => stoich)
@@ -140,7 +140,7 @@ end
140140
function numericnstoich(mtrs::Vector{Pair{V,W}}, statetoid) where {V,W}
141141
ns = Vector{Pair{Int,W}}()
142142
for (spec,stoich) in mtrs
143-
!(spec isa Term) && _iszero(spec) && error("Net stoichiometry can not have a species labelled 0.")
143+
!istree(spec) && _iszero(spec) && error("Net stoichiometry can not have a species labelled 0.")
144144
push!(ns, statetoid[spec] => stoich)
145145
end
146146
sort!(ns)

src/systems/reduction.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ isvar(s::Any) = false
3838
function get_α_x(αx)
3939
if isvar(αx)
4040
return 1, αx
41-
elseif αx isa Term && operation(αx) === (*)
41+
elseif istree(αx) && operation(αx) === (*)
4242
args = arguments(αx)
4343
nums = []
4444
syms = []

src/utils.jl

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,25 @@ function flatten_expr!(x)
3131
x
3232
end
3333

34-
function detime_dvs(op::Term)
35-
if operation(op) isa Sym
36-
Sym{Real}(nameof(operation(op)))
37-
else
38-
Term{Real}(operation(op),detime_dvs.(arguments(op)))
39-
end
34+
function detime_dvs(op)
35+
if !istree(op)
36+
op
37+
elseif operation(op) isa Sym
38+
Sym{Real}(nameof(operation(op)))
39+
else
40+
similarterm(op, operation(op),detime_dvs.(arguments(op)))
41+
end
4042
end
41-
detime_dvs(op) = op
4243

4344
function retime_dvs(op::Sym,dvs,iv)
4445
Sym{FnType{Tuple{symtype(iv)}, Real}}(nameof(op))(iv)
4546
end
4647

47-
function retime_dvs(op::Term, dvs, iv)
48-
similarterm(op, operation(op), retime_dvs.(arguments(op),(dvs,),(iv,)))
48+
function retime_dvs(op, dvs, iv)
49+
istree(op) ?
50+
similarterm(op, operation(op), retime_dvs.(arguments(op),(dvs,),(iv,))) :
51+
op
4952
end
50-
retime_dvs(op,dvs,iv) = op
5153

5254
is_derivative(O::Term) = isa(operation(O), Differential)
5355
is_derivative(::Any) = false
@@ -131,8 +133,8 @@ julia> substitute(ex, Dict([x => z, sin(z) => z^2]))
131133
"""
132134
substitute(expr::Num, s::Union{Pair, Vector, Dict}; kw...) = Num(substituter(s)(value(expr); kw...))
133135
# TODO: move this to SymbolicUtils
134-
substitute(expr::Term, s::Pair; kw...) = substituter([s[1] => s[2]])(expr; kw...)
135-
substitute(expr::Term, s::Vector; kw...) = substituter(s)(expr; kw...)
136+
substitute(expr, s::Pair; kw...) = substituter([s[1] => s[2]])(expr; kw...)
137+
substitute(expr, s::Vector; kw...) = substituter(s)(expr; kw...)
136138

137139
substituter(pair::Pair) = substituter((pair,))
138140
function substituter(pairs)
@@ -157,7 +159,7 @@ function states_to_sym(states::Set)
157159
function _states_to_sym(O)
158160
if O isa Equation
159161
Expr(:(=), _states_to_sym(O.lhs), _states_to_sym(O.rhs))
160-
elseif O isa Term
162+
elseif istree(O)
161163
if isa(operation(O), Sym)
162164
O in states && return tosymbol(O)
163165
# dependent variables

0 commit comments

Comments
 (0)