Skip to content

Commit 2d657f7

Browse files
authored
Merge pull request #679 from SciML/myb/name
Escape state names for `f.sym`
2 parents 02e9d0e + d63d28e commit 2d657f7

File tree

4 files changed

+7
-12
lines changed

4 files changed

+7
-12
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 = "4.0.8"
4+
version = "4.0.9"
55

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

src/systems/diffeqs/abstractodesystem.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,12 @@ function DiffEqBase.ODEFunction{iip}(sys::AbstractODESystem, dvs = states(sys),
158158

159159
_M = (u0 === nothing || M == I) ? M : ArrayInterface.restructure(u0 .* u0',M)
160160

161-
sts = states(sys)
162161
ODEFunction{iip}(f,
163162
jac = _jac === nothing ? nothing : _jac,
164163
tgrad = _tgrad === nothing ? nothing : _tgrad,
165164
mass_matrix = _M,
166165
jac_prototype = sparse ? similar(sys.jac[],Float64) : nothing,
167-
syms = tosymbol.(sts, states=sts, escape=false))
166+
syms = Symbol.(states(sys)))
168167
end
169168

170169
"""
@@ -215,7 +214,6 @@ function ODEFunctionExpr{iip}(sys::AbstractODESystem, dvs = states(sys),
215214

216215
jp_expr = sparse ? :(similar($(sys.jac[]),Float64)) : :nothing
217216

218-
sts = states(sys)
219217
ex = quote
220218
f = $f
221219
tgrad = $_tgrad
@@ -226,7 +224,7 @@ function ODEFunctionExpr{iip}(sys::AbstractODESystem, dvs = states(sys),
226224
tgrad = tgrad,
227225
mass_matrix = M,
228226
jac_prototype = $jp_expr,
229-
syms = $(tosymbol.(sts, states=sts, escape=false)))
227+
syms = $(Symbol.(states(sys))))
230228
end
231229
!linenumbers ? striplines(ex) : ex
232230
end

src/systems/diffeqs/sdesystem.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ function DiffEqBase.SDEFunction{iip}(sys::SDESystem, dvs = sys.states, ps = sys.
197197
Wfact = _Wfact === nothing ? nothing : _Wfact,
198198
Wfact_t = _Wfact_t === nothing ? nothing : _Wfact_t,
199199
mass_matrix = _M,
200-
syms = tosymbol.(sts, states=sts, escape=false))
200+
syms = Symbol.(sys.states))
201201
end
202202

203203
function DiffEqBase.SDEFunction(sys::SDESystem, args...; kwargs...)
@@ -255,7 +255,6 @@ function SDEFunctionExpr{iip}(sys::SDESystem, dvs = states(sys),
255255

256256
_M = (u0 === nothing || M == I) ? M : ArrayInterface.restructure(u0 .* u0',M)
257257

258-
sts = states(sys)
259258
ex = quote
260259
f = $f
261260
g = $g
@@ -270,7 +269,7 @@ function SDEFunctionExpr{iip}(sys::SDESystem, dvs = states(sys),
270269
Wfact = Wfact,
271270
Wfact_t = Wfact_t,
272271
mass_matrix = M,
273-
syms = $(tosymbol.(sts, states=sts, escape=false)),kwargs...)
272+
syms = $(Symbol.(states(sys))),kwargs...)
274273
end
275274
!linenumbers ? striplines(ex) : ex
276275
end

src/systems/jumps/jumpsystem.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,7 @@ function DiffEqBase.DiscreteProblem(sys::JumpSystem, u0map, tspan::Tuple,
197197
p = parammap
198198
end
199199
f = DiffEqBase.DISCRETE_INPLACE_DEFAULT
200-
sts = states(sys)
201-
df = DiscreteFunction{true,true}(f, syms=tosymbol.(sts, states=sts, escape=false))
200+
df = DiscreteFunction{true,true}(f, syms=Symbol.(states(sys)))
202201
DiscreteProblem(df, u0, tspan, p; kwargs...)
203202
end
204203

@@ -226,13 +225,12 @@ function DiscreteProblemExpr(sys::JumpSystem, u0map, tspan::Tuple,
226225
u0 = varmap_to_vars(u0map, states(sys))
227226
p = varmap_to_vars(parammap, parameters(sys))
228227
# identity function to make syms works
229-
sts = states(sys)
230228
quote
231229
f = DiffEqBase.DISCRETE_INPLACE_DEFAULT
232230
u0 = $u0
233231
p = $p
234232
tspan = $tspan
235-
df = DiscreteFunction{true,true}(f, syms=$(tosymbol.(sts, states=sts, escape=false)))
233+
df = DiscreteFunction{true,true}(f, syms=$(Symbol.(states(sys))))
236234
DiscreteProblem(df, u0, tspan, p; kwargs...)
237235
end
238236
end

0 commit comments

Comments
 (0)