Skip to content

Constant(Previous) doesn't work (incorrect documentation?) #527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Micket opened this issue Oct 22, 2022 · 0 comments
Open

Constant(Previous) doesn't work (incorrect documentation?) #527

Micket opened this issue Oct 22, 2022 · 0 comments

Comments

@Micket
Copy link

Micket commented Oct 22, 2022

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?

itp = interpolate(a, BSpline(Constant(Previous)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant