Skip to content

Commit ceef987

Browse files
Merge pull request #1175 from AayushSabharwal/as/fix-jet-opt
fix: fix type-instability of `_get_root_indp`
2 parents d878c48 + ac3e0bf commit ceef987

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

src/solve.jl

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -537,19 +537,6 @@ function get_updated_symbolic_problem(indp, prob; kw...)
537537
return prob
538538
end
539539

540-
"""
541-
$(TYPEDSIGNATURES)
542-
543-
Get the innermost index provider using `SII.symbolic_container`.
544-
"""
545-
function _get_root_indp(indp)
546-
if hasmethod(SII.symbolic_container, Tuple{typeof(indp)}) &&
547-
(sc = SII.symbolic_container(indp)) !== indp
548-
return _get_root_indp(sc)
549-
end
550-
return indp
551-
end
552-
553540
function init_call(_prob, args...; merge_callbacks = true, kwargshandle = nothing,
554541
kwargs...)
555542
kwargshandle = kwargshandle === nothing ? KeywordArgError : kwargshandle
@@ -1270,12 +1257,12 @@ function checkkwargs(kwargshandle; kwargs...)
12701257
end
12711258

12721259
function get_concrete_problem(prob::AbstractJumpProblem, isadapt; kwargs...)
1273-
get_updated_symbolic_problem(_get_root_indp(prob), prob; kwargs...)
1260+
get_updated_symbolic_problem(SciMLBase.get_root_indp(prob), prob; kwargs...)
12741261
end
12751262

12761263
function get_concrete_problem(prob::SteadyStateProblem, isadapt; kwargs...)
12771264
oldprob = prob
1278-
prob = get_updated_symbolic_problem(_get_root_indp(prob), prob; kwargs...)
1265+
prob = get_updated_symbolic_problem(SciMLBase.get_root_indp(prob), prob; kwargs...)
12791266
if prob !== oldprob
12801267
kwargs = (; kwargs..., u0 = SII.state_values(prob), p = SII.parameter_values(prob))
12811268
end
@@ -1287,7 +1274,7 @@ end
12871274

12881275
function get_concrete_problem(prob::NonlinearProblem, isadapt; kwargs...)
12891276
oldprob = prob
1290-
prob = get_updated_symbolic_problem(_get_root_indp(prob), prob; kwargs...)
1277+
prob = get_updated_symbolic_problem(SciMLBase.get_root_indp(prob), prob; kwargs...)
12911278
if prob !== oldprob
12921279
kwargs = (; kwargs..., u0 = SII.state_values(prob), p = SII.parameter_values(prob))
12931280
end
@@ -1299,7 +1286,7 @@ end
12991286

13001287
function get_concrete_problem(prob::NonlinearLeastSquaresProblem, isadapt; kwargs...)
13011288
oldprob = prob
1302-
prob = get_updated_symbolic_problem(_get_root_indp(prob), prob; kwargs...)
1289+
prob = get_updated_symbolic_problem(SciMLBase.get_root_indp(prob), prob; kwargs...)
13031290
if prob !== oldprob
13041291
kwargs = (; kwargs..., u0 = SII.state_values(prob), p = SII.parameter_values(prob))
13051292
end
@@ -1325,7 +1312,7 @@ end
13251312

13261313
function get_concrete_problem(prob, isadapt; kwargs...)
13271314
oldprob = prob
1328-
prob = get_updated_symbolic_problem(_get_root_indp(prob), prob; kwargs...)
1315+
prob = get_updated_symbolic_problem(SciMLBase.get_root_indp(prob), prob; kwargs...)
13291316
if prob !== oldprob
13301317
kwargs = (; kwargs..., u0 = SII.state_values(prob), p = SII.parameter_values(prob))
13311318
end
@@ -1348,7 +1335,7 @@ end
13481335

13491336
function get_concrete_problem(prob::DAEProblem, isadapt; kwargs...)
13501337
oldprob = prob
1351-
prob = get_updated_symbolic_problem(_get_root_indp(prob), prob; kwargs...)
1338+
prob = get_updated_symbolic_problem(SciMLBase.get_root_indp(prob), prob; kwargs...)
13521339
if prob !== oldprob
13531340
kwargs = (; kwargs..., u0 = SII.state_values(prob), p = SII.parameter_values(prob))
13541341
end
@@ -1376,7 +1363,7 @@ end
13761363

13771364
function get_concrete_problem(prob::DDEProblem, isadapt; kwargs...)
13781365
oldprob = prob
1379-
prob = get_updated_symbolic_problem(_get_root_indp(prob), prob; kwargs...)
1366+
prob = get_updated_symbolic_problem(SciMLBase.get_root_indp(prob), prob; kwargs...)
13801367
if prob !== oldprob
13811368
kwargs = (; kwargs..., u0 = SII.state_values(prob), p = SII.parameter_values(prob))
13821369
end

0 commit comments

Comments
 (0)