-
-
Notifications
You must be signed in to change notification settings - Fork 58
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug 🐞
CubicSpline interpolations error with a LinearAlgebra.SingularException when a time point is repeated.
Expected behavior
Perhaps a fallback to some default behavior, but probably a more descriptive error stating that time points are repeated, like happens if the time points are not sorted. I am not sure what a cubic spline's behavior "should" be for a repeated time point, so probably an error is best.
Minimal Reproducible Example 👇
This fails:
using DataInterpolations
u = [1.0, 2.0, 3.0]
t = [1.0, 1.0, 2.0]
CubicSpline(u, t)This works:
u = [1.0, 2.0, 3.0]
t = [1.0, 1.0+eps(Float64), 2.0]
CubicSpline(u, t)This also fails:
u = [1.0, 2.0, 3.0]
t = [1.0, 1.0+eps(Float64)/2, 2.0]
CubicSpline(u, t)Error & Stacktrace
ERROR: LinearAlgebra.SingularException(1)
Stacktrace:
[1] checknonsingular
@ C:\Program Files\julia-1.11.1\share\julia\stdlib\v1.11\LinearAlgebra\src\factorization.jl:69 [inlined]
[2] _check_lu_success
@ C:\Program Files\julia-1.11.1\share\julia\stdlib\v1.11\LinearAlgebra\src\lu.jl:84 [inlined]
[3] _lu_tridiag!
@ C:\Program Files\julia-1.11.1\share\julia\stdlib\v1.11\LinearAlgebra\src\lu.jl:652 [inlined]
[4] lu!(A::LinearAlgebra.Tridiagonal{Float64, Vector{…}}, pivot::LinearAlgebra.RowMaximum; check::Bool, allowsingular::Bool)
@ LinearAlgebra C:\Program Files\julia-1.11.1\share\julia\stdlib\v1.11\LinearAlgebra\src\lu.jl:578
[5] lu! (repeats 2 times)
@ C:\Program Files\julia-1.11.1\share\julia\stdlib\v1.11\LinearAlgebra\src\lu.jl:569 [inlined]
[6] _lu
@ C:\Program Files\julia-1.11.1\share\julia\stdlib\v1.11\LinearAlgebra\src\lu.jl:347 [inlined]
[7] lu
@ C:\Program Files\julia-1.11.1\share\julia\stdlib\v1.11\LinearAlgebra\src\lu.jl:341 [inlined]
[8] \(A::LinearAlgebra.Tridiagonal{Float64, Vector{Float64}}, B::Vector{Float64})
@ LinearAlgebra C:\Program Files\julia-1.11.1\share\julia\stdlib\v1.11\LinearAlgebra\src\generic.jl:1132
[9] CubicSpline(u::StepRangeLen{…}, t::Vector{…}; extrapolation::DataInterpolations.ExtrapolationType.T, extrapolation_left::DataInterpolations.ExtrapolationType.T, extrapolation_right::DataInterpolations.ExtrapolationType.T, cache_parameters::Bool, assume_linear_t::Float64)
@ DataInterpolations C:\Users\iwheeler\.julia\packages\DataInterpolations\6jW9q\src\interpolation_caches.jl:649
[10] CubicSpline(u::StepRangeLen{Float64, Base.TwicePrecision{…}, Base.TwicePrecision{…}, Int64}, t::Vector{Float64})
@ DataInterpolations C:\Users\iwheeler\.julia\packages\DataInterpolations\6jW9q\src\interpolation_caches.jl:625
[11] top-level scope
@ REPL[32]:1For reference, out-of-order time points
u = [1.0, 2.0, 3.0]
t = [1.0, 1.0-eps(Float64), 2.0]
CubicSpline(u, t)yield the following stacktrace:
ERROR: ArgumentError: The second argument (`t`), which is used for the interpolation domain, is not sorted.
It looks like the arguments `u` and `t` were inversed, make sure you used the arguments in the correct order.
Stacktrace:
[1] munge_data(u::StepRangeLen{…}, t::Vector{…}; check_sorted::Vector{…}, sorted_arg_name::Tuple{…})
@ DataInterpolations C:\Users\iwheeler\.julia\packages\DataInterpolations\6jW9q\src\interpolation_utils.jl:109
[2] munge_data
@ C:\Users\iwheeler\.julia\packages\DataInterpolations\6jW9q\src\interpolation_utils.jl:94 [inlined]
[3] CubicSpline(u::StepRangeLen{…}, t::Vector{…}; extrapolation::DataInterpolations.ExtrapolationType.T, extrapolation_left::DataInterpolations.ExtrapolationType.T, extrapolation_right::DataInterpolations.ExtrapolationType.T, cache_parameters::Bool, assume_linear_t::Float64)
@ DataInterpolations C:\Users\iwheeler\.julia\packages\DataInterpolations\6jW9q\src\interpolation_caches.jl:633
[4] CubicSpline(u::StepRangeLen{Float64, Base.TwicePrecision{…}, Base.TwicePrecision{…}, Int64}, t::Vector{Float64})
@ DataInterpolations C:\Users\iwheeler\.julia\packages\DataInterpolations\6jW9q\src\interpolation_caches.jl:625
[5] top-level scope
@ REPL[34]:1Environment (please complete the following information):
- Output of
using Pkg; Pkg.status()
[82cc6244] DataInterpolations v8.6.1Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working