Skip to content

Commit 3403d67

Browse files
committed
extend tosymbol
1 parent e3d9875 commit 3403d67

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

src/systems/diffeqs/abstractodesystem.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ function DiffEqBase.ODEFunction{iip}(sys::AbstractODESystem, dvs = states(sys),
163163
tgrad = _tgrad === nothing ? nothing : _tgrad,
164164
mass_matrix = _M,
165165
jac_prototype = sparse ? similar(sys.jac[],Float64) : nothing,
166-
syms = nameof.(operation.(states(sys))))
166+
syms = tosymbol.(states(sys)))
167167
end
168168

169169
"""
@@ -225,7 +225,7 @@ function ODEFunctionExpr{iip}(sys::AbstractODESystem, dvs = states(sys),
225225
tgrad = tgrad,
226226
mass_matrix = M,
227227
jac_prototype = $jp_expr,
228-
syms = $(nameof.(operation.(states(sys)))))
228+
syms = $(tosymbol.(states(sys))))
229229
end
230230
!linenumbers ? striplines(ex) : ex
231231
end

src/systems/diffeqs/sdesystem.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ function DiffEqBase.SDEFunction{iip}(sys::SDESystem, dvs = sys.states, ps = sys.
196196
Wfact = _Wfact === nothing ? nothing : _Wfact,
197197
Wfact_t = _Wfact_t === nothing ? nothing : _Wfact_t,
198198
mass_matrix = _M,
199-
syms = nameof.(operation.(states(sys))))
199+
syms = tosymbol.(states(sys)))
200200
end
201201

202202
function DiffEqBase.SDEFunction(sys::SDESystem, args...; kwargs...)
@@ -269,7 +269,7 @@ function SDEFunctionExpr{iip}(sys::SDESystem, dvs = states(sys),
269269
Wfact = Wfact,
270270
Wfact_t = Wfact_t,
271271
mass_matrix = M,
272-
syms = $(nameof.(operation.(states(sys)))),kwargs...)
272+
syms = $(tosymbol.(states(sys))),kwargs...)
273273
end
274274
!linenumbers ? striplines(ex) : ex
275275
end

src/systems/jumps/jumpsystem.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ function DiffEqBase.DiscreteProblem(sys::JumpSystem, u0map, tspan::Tuple,
197197
p = parammap
198198
end
199199
f = DiffEqBase.DISCRETE_INPLACE_DEFAULT
200-
df = DiscreteFunction{true,true}(f, syms=nameof.(operation.(states(sys))))
200+
df = DiscreteFunction{true,true}(f, syms=tosymbol.(states(sys)))
201201
DiscreteProblem(df, u0, tspan, p; kwargs...)
202202
end
203203

@@ -230,7 +230,7 @@ function DiscreteProblemExpr(sys::JumpSystem, u0map, tspan::Tuple,
230230
u0 = $u0
231231
p = $p
232232
tspan = $tspan
233-
df = DiscreteFunction{true,true}(f, syms=$(nameof.(operation.(states(sys)))))
233+
df = DiscreteFunction{true,true}(f, syms=$(tosymbol.(states(sys))))
234234
DiscreteProblem(df, u0, tspan, p; kwargs...)
235235
end
236236
end

src/utils.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ tovar(s::Sym) = s
159159
Base.Symbol(x::Union{Num,Symbolic}) = tosymbol(x)
160160
tosymbol(x; kwargs...) = x
161161
tosymbol(x::Sym; kwargs...) = nameof(x)
162+
tosymbol(x::Term; kwargs...) = nameof(operation(x))
162163
tosymbol(t::Num; kwargs...) = tosymbol(value(t); kwargs...)
163164

164165
"""

0 commit comments

Comments
 (0)