Constant(Previous) doesn't work (incorrect documentation?)
Micket opened this issue · comments
Mikael Öhman commented
Looking at some examples at https://juliamath.github.io/Interpolations.jl/stable/control/
i see
a = rand(10) # test data
# Nearest-neighbor interpolation
itp = interpolate(a, BSpline(Constant()))
v = itp(5.4) # returns a[5]
# Previous-neighbor interpolation
itp = interpolate(a, BSpline(Constant(Previous))) # this fails
because
julia> Constant(Previous)
ERROR: MethodError: no method matching (Constant{Nearest})(::Type{Previous})
Closest candidates are:
(Constant{T})() where T<:Interpolations.ConstantInterpType at ~/.julia/packages/Interpolations/Sxe87/src/b-splines/constant.jl:41
(Constant{T})(::Periodic{Nothing}) where T<:Interpolations.ConstantInterpType at ~/.julia/packages/Interpolations/Sxe87/src/b-splines/constant.jl:43
(Constant{T})(::BC) where {T<:Interpolations.ConstantInterpType, BC<:Interpolations.BoundaryCondition} at ~/.julia/packages/Interpolations/Sxe87/src/b-splines/constant.jl:42
Stacktrace:
[1] Constant(args::Type)
@ Interpolations ~/.julia/packages/Interpolations/Sxe87/src/b-splines/constant.jl:40
[2] top-level scope
@ REPL[16]:1
As far as I can tell, you are supposed to do
itp = interpolate(a, BSpline(Constant{Previous}()))
Tested on julia 1.8.0 and 1.7.3 with Interpolations v0.14.6
So i think just the documentation is wrong here?
Interpolations.jl/docs/src/control.md
Line 18 in 33409a6