Skip to content

Commit 4d83a22

Browse files
fix: fix type-instability of get_root_indp
1 parent 3eb2288 commit 4d83a22

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

src/solutions/save_idxs.jl

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,30 @@ function as_diffeq_array(vt::Vector{VectorTemplate}, t)
4444
return DiffEqArray(typeof(TupleOfArraysWrapper(vt))[], t, (1, 1))
4545
end
4646

47-
function get_root_indp(indp)
48-
if hasmethod(symbolic_container, Tuple{typeof(indp)}) &&
49-
(sc = symbolic_container(indp)) !== indp
50-
return get_root_indp(sc)
47+
function get_root_indp(prob::AbstractSciMLProblem)
48+
get_root_indp(prob.f)
49+
end
50+
51+
function get_root_indp(f::T) where {T <: AbstractSciMLFunction}
52+
if hasfield(T, :sys)
53+
return f.sys
54+
elseif hasfield(T, :f) && f.f isa AbstractSciMLFunction
55+
return get_root_indp(f.f)
56+
else
57+
return nothing
5158
end
52-
return indp
59+
end
60+
61+
function get_root_indp(prob::LinearProblem)
62+
get_root_indp(prob.f)
63+
end
64+
65+
get_root_indp(prob::AbstractJumpProblem) = get_root_indp(prob.prob)
66+
67+
get_root_indp(x) = x
68+
69+
function get_root_indp(f::SymbolicLinearInterface)
70+
get_root_indp(f.sys)
5371
end
5472

5573
# Everything from this point on is public API

0 commit comments

Comments
 (0)