Skip to content

Commit 95e9738

Browse files
committed
simplify dynamic_rule to not directly access nested function f
1 parent c496552 commit 95e9738

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

src/core_systems/continuous_time_ode.jl

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,7 @@ function SciMLBase.reinit!(ds::ContinuousTimeDynamicalSystem, u::AbstractArray =
150150
end
151151

152152
# `DEIntegrator` stuff
153-
function dynamic_rule(integ::DEIntegrator)
154-
# with remake it can happen that we have nested SDEFunctions
155-
# sciml integrator deals with this internally well
156-
f = integ.f
157-
while hasfield(typeof(f), :f)
158-
f = f.f
159-
end
160-
return f
161-
end
153+
dynamic_rule(integ::DEIntegrator) = integ.f.f
162154
current_parameters(integ::DEIntegrator) = integ.p
163155
initial_state(integ::DEIntegrator) = integ.sol.prob.u0
164156
current_state(ds::CoupledODEs) = current_state(ds.integ)

test/stochastic.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ end
8181

8282
# CoupledODEs creation
8383
ds = CoupledODEs(lorenz_oop)
84-
@test dynamic_rule(ds) == lorenz_rule
84+
@test dynamic_rule(ds).f == lorenz_rule
8585
@test ds.integ.alg isa Tsit5
8686
test_dynamical_system(ds, u0, p0; idt = false, iip = false)
8787
# and back
8888
sde = CoupledSDEs(ds, p0)
89-
@test dynamic_rule(sde) == lorenz_rule
89+
@test dynamic_rule(sde).f.f == lorenz_rule
9090
@test sde.integ.alg isa SOSRA
9191
end
9292

0 commit comments

Comments
 (0)