JuliaMath / Interpolations.jl

Fast, continuous interpolation of discrete datasets in Julia
http://juliamath.github.io/Interpolations.jl/
Other
523 stars 110 forks source link

Bounds is not working on 2d linear interpolator #537

Open rkube opened 1 year ago

rkube commented 1 year ago

Hi, calling Interpolations.bound fails on a 2d interpolator:

ulia> x_rg = 1:10
1:10

julia> y_rg = 1:10
1:10

julia> ip = linear_interpolation((x_rg, y_rg), vals)
10×10 extrapolate(scale(interpolate(::Matrix{Float64}, BSpline(Linear())), (1:10, 1:10)), Throw()) with element type Float64:
 1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0

julia> Interpolations.bounds(ip)
ERROR: MethodError: no method matching lbounds(::Interpolations.Extrapolation{Float64, 2, ScaledInterpolation{Float64, 2, Interpolations.BSplineInterpolation{Float64, 2, Matrix{Float64}, BSpline{Linear{Throw{OnGrid}}}, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}, BSpline{Linear{Throw{OnGrid}}}, Tuple{UnitRange{Int64}, UnitRange{Int64}}}, BSpline{Linear{Throw{OnGrid}}}, Throw{Nothing}})
Closest candidates are:
  lbounds(::Interpolations.BSplineInterpolation) at ~/.julia/packages/Interpolations/nDwIa/src/b-splines/b-splines.jl:138
  lbounds(::Interpolations.GriddedInterpolation) at ~/.julia/packages/Interpolations/nDwIa/src/gridded/gridded.jl:175
  lbounds(::Interpolations.MonotonicInterpolation) at ~/.julia/packages/Interpolations/nDwIa/src/monotonic/monotonic.jl:423
  ...
Stacktrace:
 [1] bounds(itp::Interpolations.Extrapolation{Float64, 2, ScaledInterpolation{Float64, 2, Interpolations.BSplineInterpolation{Float64, 2, Matrix{Float64}, BSpline{Linear{Throw{OnGrid}}}, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}, BSpline{Linear{Throw{OnGrid}}}, Tuple{UnitRange{Int64}, UnitRange{Int64}}}, BSpline{Linear{Throw{OnGrid}}}, Throw{Nothing}})
   @ Interpolations ~/.julia/packages/Interpolations/nDwIa/src/Interpolations.jl:147
 [2] top-level scope
   @ REPL[13]:1