JuliaMath / JuliaMath/Interpolations.jl
Constant(Previous) doesn't work (incorrect documentation?)
- Dominant language
- Julia
- Stars
- 575
- Forks
- 117
- PR merge metrics
- No merged PRs in 30d
Description
Looking at some examples at https://juliamath.github.io/Interpolations.jl/stable/control/
i see
```julia
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
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?
https://github.com/JuliaMath/Interpolations.jl/blob/33409a657cacabf877681439605f16431f4bc8f4/docs/src/control.md?plain=1#L18
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.