Skip to content

Interpolation error for monotonically decreasing t #427

@bclyons12

Description

@bclyons12

Describe the bug 🐞

In v8.0.1, creating an interpolation now checks if the t array is sorted, but it uses the issorted function which, by default, make sure that the values are monotonically increasing. For monotonically decreasing t, this throws an error.

Expected behavior

DataInterpolations should work properly for monotonically decreasing t, as it did before v8.0.1.

Minimal Reproducible Example 👇

using DataInterpolations
N = 11
x = range(1, 0, N)
y = rand(N)
DataInterpolations.LinearInterpolation(y, x)

Error & Stacktrace ⚠️

ArgumentError: The second argument (`t`), which is used for the interpolation domain, is not sorted.

Stacktrace:
 [1] munge_data(u::Vector{Float64}, t::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}; check_sorted::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, sorted_arg_name::Tuple{String, String})
   @ DataInterpolations [~/.julia/packages/DataInterpolations/CuJMO/src/interpolation_utils.jl:106](http://localhost:8888/lab/tree/FUSE/playground/~/.julia/packages/DataInterpolations/CuJMO/src/interpolation_utils.jl#line=105)
 [2] munge_data
   @ [~/.julia/packages/DataInterpolations/CuJMO/src/interpolation_utils.jl:94](http://localhost:8888/lab/tree/FUSE/playground/~/.julia/packages/DataInterpolations/CuJMO/src/interpolation_utils.jl#line=93) [inlined]
 [3] LinearInterpolation(u::Vector{Float64}, t::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}; extrapolation::DataInterpolations.ExtrapolationType.T, extrapolation_left::DataInterpolations.ExtrapolationType.T, extrapolation_right::DataInterpolations.ExtrapolationType.T, cache_parameters::Bool, assume_linear_t::Float64)
   @ DataInterpolations [~/.julia/packages/DataInterpolations/CuJMO/src/interpolation_caches.jl:55](http://localhost:8888/lab/tree/FUSE/playground/~/.julia/packages/DataInterpolations/CuJMO/src/interpolation_caches.jl#line=54)
 [4] LinearInterpolation(u::Vector{Float64}, t::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64})
   @ DataInterpolations [~/.julia/packages/DataInterpolations/CuJMO/src/interpolation_caches.jl:49](http://localhost:8888/lab/tree/FUSE/playground/~/.julia/packages/DataInterpolations/CuJMO/src/interpolation_caches.jl#line=48)
 [5] top-level scope
   @ In[8]:5

Environment (please complete the following information):

  • Output of using Pkg; Pkg.status()
Status `/private/var/folders/nt/ct_lf2n94_1c21908mmbx55w0000gq/T/jl_fUWBJg/Project.toml`
  [82cc6244] DataInterpolations v8.0.1
  • Output of using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
Status `/private/var/folders/nt/ct_lf2n94_1c21908mmbx55w0000gq/T/jl_fUWBJg/Manifest.toml`
  [bbf7d656] CommonSubexpressions v0.3.1
  [a8cc5b0e] Crayons v4.1.1
  [9a962f9c] DataAPI v1.16.0
  [82cc6244] DataInterpolations v8.0.1
  [e2d170a0] DataValueInterfaces v1.0.0
  [163ba53b] DiffResults v1.1.0
  [b552c78f] DiffRules v1.15.1
  [ffbed154] DocStringExtensions v0.9.4
  [4e289a0a] EnumX v1.0.5
  [64ca27bc] FindFirstFunctions v1.4.1
⌅ [f6369f11] ForwardDiff v0.10.38
  [92d709cd] IrrationalConstants v0.2.4
  [82899510] IteratorInterfaceExtensions v1.0.0
  [692b3bcd] JLLWrappers v1.7.0
  [b964fa9f] LaTeXStrings v1.4.0
  [2ab3a3ac] LogExpFunctions v0.3.29
  [1914dd2f] MacroTools v0.5.16
  [77ba4419] NaNMath v1.1.3
  [bac558e1] OrderedCollections v1.8.0
⌅ [aea7be01] PrecompileTools v1.2.1
  [21216c6a] Preferences v1.4.3
  [08abe8d2] PrettyTables v2.4.0
  [3cdcf5f2] RecipesBase v1.3.4
  [189a3867] Reexport v1.2.2
  [276daf66] SpecialFunctions v2.5.1
  [1e83bf80] StaticArraysCore v1.4.3
  [892a3eda] StringManipulation v0.4.1
  [3783bdb8] TableTraits v1.0.1
  [bd369af6] Tables v1.12.0
  [efe28fd5] OpenSpecFun_jll v0.5.6+0
  [56f22d72] Artifacts v1.11.0
  [2a0f44e3] Base64 v1.11.0
  [ade2ca70] Dates v1.11.0
  [8f399da3] Libdl v1.11.0
  [37e2e46d] LinearAlgebra v1.11.0
  [d6f4376e] Markdown v1.11.0
  [de0858da] Printf v1.11.0
  [9a3f8284] Random v1.11.0
  [ea8e919c] SHA v0.7.0
  [fa267f1f] TOML v1.0.3
  [4ec0a83e] Unicode v1.11.0
  [e66e0078] CompilerSupportLibraries_jll v1.1.1+0
  [4536629a] OpenBLAS_jll v0.3.27+1
  [05823500] OpenLibm_jll v0.8.5+0
  [8e850b90] libblastrampoline_jll v5.11.0+0
Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use `status --outdated -m`
  • Output of versioninfo()
Julia Version 1.11.5
Commit 760b2e5b739 (2025-04-14 06:53 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin24.0.0)
  CPU: 12 × Apple M4 Pro
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, apple-m1)
Threads: 10 default, 0 interactive, 5 GC (on 8 virtual cores)
Environment:
  JULIA_NUM_THREADS = 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions