Skip to content

Commit ffb28ab

Browse files
Merge pull request #786 from SciML/more_depwarn
Depwarns 2: Resurrection
2 parents 61d9156 + 7748ef5 commit ffb28ab

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/systems/diffeqs/abstractodesystem.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function calculate_tgrad(sys::AbstractODESystem;
22
simplify=false)
3-
isempty(sys.tgrad[]) || return sys.tgrad[] # use cached tgrad, if possible
3+
isempty(get_tgrad(sys)[]) || return get_tgrad(sys)[] # use cached tgrad, if possible
44

55
# We need to remove explicit time dependence on the state because when we
66
# have `u(t) * t` we want to have the tgrad to be `u(t)` instead of `u'(t) *
@@ -13,13 +13,13 @@ function calculate_tgrad(sys::AbstractODESystem;
1313
tgrad = [expand_derivatives(ModelingToolkit.Differential(iv)(r), simplify) for r in rhs]
1414
reverse_rule = Dict(map((x, xt) -> x=>xt, detime_dvs.(xs), xs))
1515
tgrad = Num.(substitute.(tgrad, Ref(reverse_rule)))
16-
sys.tgrad[] = tgrad
16+
get_tgrad(sys)[] = tgrad
1717
return tgrad
1818
end
1919

2020
function calculate_jacobian(sys::AbstractODESystem;
2121
sparse=false, simplify=false)
22-
isempty(sys.jac[]) || return sys.jac[] # use cached Jacobian, if possible
22+
isempty(get_jac(sys)[]) || return get_jac(sys)[] # use cached Jacobian, if possible
2323
rhs = [eq.rhs for eq equations(sys)]
2424

2525
iv = get_iv(sys)
@@ -31,7 +31,7 @@ function calculate_jacobian(sys::AbstractODESystem;
3131
jac = jacobian(rhs, dvs, simplify=simplify)
3232
end
3333

34-
sys.jac[] = jac # cache Jacobian
34+
get_jac(sys)[] = jac # cache Jacobian
3535
return jac
3636
end
3737

@@ -162,7 +162,7 @@ function DiffEqBase.ODEFunction{iip}(sys::AbstractODESystem, dvs = states(sys),
162162
jac = _jac === nothing ? nothing : _jac,
163163
tgrad = _tgrad === nothing ? nothing : _tgrad,
164164
mass_matrix = _M,
165-
jac_prototype = sparse ? similar(sys.jac[],Float64) : nothing,
165+
jac_prototype = sparse ? similar(get_jac(sys)[],Float64) : nothing,
166166
syms = Symbol.(states(sys)),
167167
indepsym = Symbol(independent_variable(sys)),
168168
)
@@ -214,7 +214,7 @@ function ODEFunctionExpr{iip}(sys::AbstractODESystem, dvs = states(sys),
214214

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

217-
jp_expr = sparse ? :(similar($(sys.jac[]),Float64)) : :nothing
217+
jp_expr = sparse ? :(similar($(get_jac(sys)[]),Float64)) : :nothing
218218

219219
ex = quote
220220
f = $f

test/odesystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,6 @@ eqs = [
250250
0 ~ x1 - x2,
251251
]
252252
sys = ODESystem(eqs, t)
253-
@test isequal(sys.iv, t)
253+
@test isequal(get_iv(sys), t)
254254
@test isequal(states(sys), [x1, x2])
255255
@test isempty(parameters(sys))

0 commit comments

Comments
 (0)