Skip to content

Commit

Permalink
fix: interpolation using symbolic idxs for RODESolution
Browse files Browse the repository at this point in the history
  • Loading branch information
AayushSabharwal committed Jan 2, 2024
1 parent 98f357b commit 9ea5b75
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/solutions/rode_solutions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,22 @@ TruncatedStacktraces.@truncate_stacktrace RODESolution 1 2

function (sol::RODESolution)(t, ::Type{deriv} = Val{0}; idxs = nothing,
continuity = :left) where {deriv}
if idxs !== nothing
if !(idxs isa Union{<:AbstractArray, <:Tuple})
idxs = [idxs]

Check warning on line 68 in src/solutions/rode_solutions.jl

View check run for this annotation

Codecov / codecov/patch

src/solutions/rode_solutions.jl#L66-L68

Added lines #L66 - L68 were not covered by tests
end
idxs = map(idxs) do idx
if symbolic_type(idx) === NotSymbolic()
return idx
elseif symbolic_type(idx) === ScalarSymbolic()
return variable_index(sol, idx)

Check warning on line 74 in src/solutions/rode_solutions.jl

View check run for this annotation

Codecov / codecov/patch

src/solutions/rode_solutions.jl#L70-L74

Added lines #L70 - L74 were not covered by tests
else
return variable_index.((sol,), collect(idx))

Check warning on line 76 in src/solutions/rode_solutions.jl

View check run for this annotation

Codecov / codecov/patch

src/solutions/rode_solutions.jl#L76

Added line #L76 was not covered by tests
end
end
any(i === nothing for i in idxs) && error("All idxs must be variables")
idxs = reduce(vcat, idxs)

Check warning on line 80 in src/solutions/rode_solutions.jl

View check run for this annotation

Codecov / codecov/patch

src/solutions/rode_solutions.jl#L79-L80

Added lines #L79 - L80 were not covered by tests
end
sol.interp(t, idxs, deriv, sol.prob.p, continuity)
end
function (sol::RODESolution)(v, t, ::Type{deriv} = Val{0}; idxs = nothing,
Expand Down

0 comments on commit 9ea5b75

Please sign in to comment.