-
-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve save_idxs #180
Improve save_idxs #180
Conversation
Codecov Report
@@ Coverage Diff @@
## master #180 +/- ##
==========================================
+ Coverage 71.75% 71.83% +0.08%
==========================================
Files 61 61
Lines 21165 21230 +65
==========================================
+ Hits 15187 15251 +64
- Misses 5978 5979 +1
Continue to review full report at Codecov.
|
@@ -107,8 +107,8 @@ function ode_interpolation(tvals,id,idxs,deriv) | |||
tdir*tvals[idx[1]] < tdir*ts[1] && error("Solution interpolation cannot extrapolate before the first timepoint. Either start solving earlier or use the local extrapolation from the integrator interface.") | |||
if typeof(idxs) <: Number | |||
vals = Vector{eltype(first(timeseries))}(length(tvals)) | |||
elseif typeof(idxs) <: AbstractVector | |||
vals = Vector{Vector{eltype(first(timeseries))}}(length(tvals)) | |||
elseif typeof(idxs) <: AbstractArray |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...! Thanks. For some reason I couldn't find out how to do this before haha
Thanks. I actually just couldn't find out how to do this before. Would you mind making similar changes to StochasticDiffEq.jl? It should be incorrect in the same ways since the code is so similar. |
When I wrote a notebook of benchmarks for DelayDiffEq, I discovered that
save_idxs
does not seem to work completely correct. First I thought this is a problem in DelayDiffEq (and there might still be issues there), but it is at least partly also a problem in OrdinaryDiffEq: Usingsave_idxs
such thattypeof(u[save_idxs]) != typeof(u)
does not work. So e.g. it is not possible to extract single components of the state vector with scalars, and maybe even worse it is not possible to extract a vector or vectorized component of a matrix. When I had fixed this issue and finally could extract arbitrary components I noticed another issue: it is not possible to plot solutions retrieved by scalar indexing since the interpolation of exactly that case is broken. Hence this PR additionally includes an improved interpolation that covers this case. Use cases and examples are given in the added test file.