Struggling to update deprecated Interpolations function

I have a small function in my package that interpolates values and I’ve noted that the function I’d been using, LinearInterpolation(Node, Node, extrapolation_bc=0), has been deprecated.

I’m struggling to understand what the proper structure looks like to use the current functionality in Interpolations.

My nodes are both Vector{Float64} types, which,

Interpolations.linear_interpolation(Rc[:, 1], Rc[:, 2], extrapolation_bc=0)

does not accept.

For reference, here’s the current version that I’d written that works in the whole of the functionality. Epicrop.jl/Epicrop.jl at 7724ba1e6bb099099c139d8236348286d47e7b89 · adamhsparks/Epicrop.jl · GitHub It’s a very simple way of determining a value between days that is completely linear.

Sorry if I’m unclear, but I’m still mainly learning Julia as a researcher who programs (in R) and am trying to understand what’s going on here.

I think you might need something like this:

julia> interp = linear_interpolation([.3,.5,.6], [.4,.7,.9]; extrapolation_bc=Line())
3-element extrapolate(interpolate((::Vector{Float64},), ::Vector{Float64}, Gridded(Linear())), Line()) with element type Float64:
 0.4
 0.7
 0.9

julia> interp(.4)
0.55

From what I can tell, extrapolation_bc determines how to extrapolate values outside the range of the input values. Setting extrapolation_bc = 0 is not valid.

1 Like

Thank you. Yes, indeed this was what I needed.

I had another bug that was throwing me off of this solution when I first investigated it.