Skip to content

MethodError bounds for CubicSplineInterpolation #427

@hendri54

Description

@hendri54

Calling bounds on a CubicSplineInterpolation throws a MethodError:

julia> xV = LinRange(-20.0, 10.0, 50);
julia> yV = LinRange(-10.0, 30.0, 40);
julia> zM = xV .+ xV .* yV';
julia> cubic1 = CubicSplineInterpolation((xV, yV), zM);
julia> bounds(cubic1)
ERROR: MethodError: no method matching lbounds(::Interpolations.Extrapolation{Float64, 2, ScaledInterpolation{Float64, 2, Interpolations.BSplineInterpolation{Float64, 2, OffsetArrays.OffsetMatrix{Float64, Matrix{Float64}}, BSpline{Cubic{Line{OnGrid}}}, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}, BSpline{Cubic{Line{OnGrid}}}, Tuple{LinRange{Float64}, LinRange{Float64}}}, BSpline{Cubic{Line{OnGrid}}}, Throw{Nothing}})
Closest candidates are:
  lbounds(::Interpolations.BSplineInterpolation) at /Users/lutz/.julia/packages/Interpolations/GIn2o/src/b-splines/b-splines.jl:133
  lbounds(::Interpolations.GriddedInterpolation) at /Users/lutz/.julia/packages/Interpolations/GIn2o/src/gridded/gridded.jl:92
  lbounds(::Interpolations.MonotonicInterpolation) at /Users/lutz/.julia/packages/Interpolations/GIn2o/src/monotonic/monotonic.jl:387
  ...
Stacktrace:
 [1] bounds(itp::Interpolations.Extrapolation{Float64, 2, ScaledInterpolation{Float64, 2, Interpolations.BSplineInterpolation{Float64, 2, OffsetArrays.OffsetMatrix{Float64, Matrix{Float64}}, BSpline{Cubic{Line{OnGrid}}}, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}, BSpline{Cubic{Line{OnGrid}}}, Tuple{LinRange{Float64}, LinRange{Float64}}}, BSpline{Cubic{Line{OnGrid}}}, Throw{Nothing}})
   @ Interpolations ~/.julia/packages/Interpolations/GIn2o/src/Interpolations.jl:146
 [2] top-level scope

Constructing what appears to be the same interpolation the long way round does not throw a MethodError:

julia> cubic2 = interpolate(zM, BSpline(Cubic(Line(OnGrid()))));
julia> cubic2 = scale(cubic2, xV, yV);
julia> cubic1(-10.5, 7.5)
-89.25
julia> cubic2(-10.5, 7.5)
-89.25
julia> bounds(cubic2)
((-20.0, 10.0), (-10.0, 30.0))

I thought both ways of constructing the CubicSplineInterpolation were the same. What am I missing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions