Skip to content

Commit 06d15fd

Browse files
authored
Merge pull request #646 from isaacsas/fix-plots-names
Fix names in plot legends
2 parents 31aadff + 0ea5fd2 commit 06d15fd

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

src/systems/diffeqs/abstractodesystem.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,13 @@ 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)
161162
ODEFunction{iip}(f,
162163
jac = _jac === nothing ? nothing : _jac,
163164
tgrad = _tgrad === nothing ? nothing : _tgrad,
164165
mass_matrix = _M,
165166
jac_prototype = sparse ? similar(sys.jac[],Float64) : nothing,
166-
syms = Symbol.(states(sys)))
167+
syms = tosymbol.(sts, states=sts, escape=false))
167168
end
168169

169170
"""
@@ -214,18 +215,18 @@ function ODEFunctionExpr{iip}(sys::AbstractODESystem, dvs = states(sys),
214215

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

218+
sts = states(sys)
217219
ex = quote
218220
f = $f
219221
tgrad = $_tgrad
220222
jac = $_jac
221223
M = $_M
222-
223224
ODEFunction{$iip}(f,
224225
jac = jac,
225226
tgrad = tgrad,
226227
mass_matrix = M,
227228
jac_prototype = $jp_expr,
228-
syms = $(Symbol.(states(sys))))
229+
syms = $(tosymbol.(sts, states=sts, escape=false)))
229230
end
230231
!linenumbers ? striplines(ex) : ex
231232
end

src/systems/diffeqs/sdesystem.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,14 @@ function DiffEqBase.SDEFunction{iip}(sys::SDESystem, dvs = sys.states, ps = sys.
190190
M = calculate_massmatrix(sys)
191191
_M = (u0 === nothing || M == I) ? M : ArrayInterface.restructure(u0 .* u0',M)
192192

193+
sts = states(sys)
193194
SDEFunction{iip}(f,g,
194195
jac = _jac === nothing ? nothing : _jac,
195196
tgrad = _tgrad === nothing ? nothing : _tgrad,
196197
Wfact = _Wfact === nothing ? nothing : _Wfact,
197198
Wfact_t = _Wfact_t === nothing ? nothing : _Wfact_t,
198199
mass_matrix = _M,
199-
syms = Symbol.(sys.states))
200+
syms = tosymbol.(sts, states=sts, escape=false))
200201
end
201202

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

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

258+
sts = states(sys)
257259
ex = quote
258260
f = $f
259261
g = $g
@@ -262,14 +264,13 @@ function SDEFunctionExpr{iip}(sys::SDESystem, dvs = states(sys),
262264
Wfact = $_Wfact
263265
Wfact_t = $_Wfact_t
264266
M = $_M
265-
266267
SDEFunction{$iip}(f,g,
267268
jac = jac,
268269
tgrad = tgrad,
269270
Wfact = Wfact,
270271
Wfact_t = Wfact_t,
271272
mass_matrix = M,
272-
syms = $(Symbol.(states(sys))),kwargs...)
273+
syms = $(tosymbol.(sts, states=sts, escape=false)),kwargs...)
273274
end
274275
!linenumbers ? striplines(ex) : ex
275276
end

src/systems/jumps/jumpsystem.jl

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

@@ -225,12 +226,13 @@ function DiscreteProblemExpr(sys::JumpSystem, u0map, tspan::Tuple,
225226
u0 = varmap_to_vars(u0map, states(sys))
226227
p = varmap_to_vars(parammap, parameters(sys))
227228
# identity function to make syms works
229+
sts = states(sys)
228230
quote
229231
f = DiffEqBase.DISCRETE_INPLACE_DEFAULT
230232
u0 = $u0
231233
p = $p
232234
tspan = $tspan
233-
df = DiscreteFunction(f, syms=$(Symbol.(states(sys))))
235+
df = DiscreteFunction{true,true}(f, syms=$(tosymbol.(sts, states=sts, escape=false)))
234236
DiscreteProblem(df, u0, tspan, p; kwargs...)
235237
end
236238
end

0 commit comments

Comments
 (0)