Skip to content

Commit

Permalink
throw error if early number
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas committed Apr 6, 2017
1 parent c848dd1 commit 4bbca8e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/dense/generic_dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ times ts (sorted), with values timeseries and derivatives ks
idx = sortperm(tvals,rev=tdir<0)
i = 2 # Start the search thinking it's between ts[1] and ts[2]
tvals[idx[end]] > ts[end] && error("Solution interpolation cannot extrapolate past the final timepoint. Either solve on a longer timespan or use the local extrapolation from the integrator interface.")
tvals[idx[1]] < 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 idxs == nothing
if (eltype(timeseries) <: AbstractArray) && !(eltype(timeseries) <: Array)
vals = Vector{Vector{eltype(first(timeseries))}}(length(tvals))
Expand Down Expand Up @@ -163,6 +164,7 @@ times ts (sorted), with values timeseries and derivatives ks
idx = sortperm(tvals,rev=tdir<0)
i = 2 # Start the search thinking it's between ts[1] and ts[2]
tvals[idx[end]] > ts[end] && error("Solution interpolation cannot extrapolate past the final timepoint. Either solve on a longer timespan or use the local extrapolation from the integrator interface.")
tvals[idx[1]] < ts[1] && error("Solution interpolation cannot extrapolate before the first timepoint. Either start solving earlier or use the local extrapolation from the integrator interface.")
@inbounds for j in idx
t = tvals[j]
i = searchsortedfirst(@view(ts[@view(notsaveat_idxs[i:end])]),t,rev=tdir<0)+i-1 # It's in the interval ts[i-1] to ts[i]
Expand Down Expand Up @@ -220,6 +222,7 @@ times ts (sorted), with values timeseries and derivatives ks
@inline function ode_interpolation(tval::Number,id,idxs,deriv)
@unpack ts,timeseries,ks,f,notsaveat_idxs,cache = id
tval > ts[end] && error("Solution interpolation cannot extrapolate past the final timepoint. Either solve on a longer timespan or use the local extrapolation from the integrator interface.")
tval < ts[1] && error("Solution interpolation cannot extrapolate before the first timepoint. Either start solving earlier or use the local extrapolation from the integrator interface.")
tdir = sign(ts[end]-ts[1])
@inbounds i = searchsortedfirst(@view(ts[notsaveat_idxs]),tval,rev=tdir<0) # It's in the interval ts[i-1] to ts[i]
@inbounds if ts[notsaveat_idxs[i]] == tval
Expand Down Expand Up @@ -264,6 +267,7 @@ times ts (sorted), with values timeseries and derivatives ks
@inline function ode_interpolation!(out,tval::Number,id,idxs,deriv)
@unpack ts,timeseries,ks,f,notsaveat_idxs,cache = id
tval > ts[end] && error("Solution interpolation cannot extrapolate past the final timepoint. Either solve on a longer timespan or use the local extrapolation from the integrator interface.")
tval < ts[1] && error("Solution interpolation cannot extrapolate before the first timepoint. Either start solving earlier or use the local extrapolation from the integrator interface.")
tdir = sign(ts[end]-ts[1])
@inbounds i = searchsortedfirst(@view(ts[notsaveat_idxs]),tval,rev=tdir<0) # It's in the interval ts[i-1] to ts[i]
@inbounds if ts[notsaveat_idxs[i]] == tval
Expand Down

0 comments on commit 4bbca8e

Please sign in to comment.