kbarbary / Dierckx.jl

Julia package for 1-d and 2-d splines
Other
157 stars 30 forks source link

Default k adapt to data length #90

Open RibeiroAndre opened 2 years ago

RibeiroAndre commented 2 years ago

Hello, Currently this:

a=Spline1D([1,2,3],[2,4,8])

fails because k is 3 by default. I propose that if the data length is 2, k=1, if it's 3, k=2, otherwise, k=3. So the code change would likely be:

function Spline1D(x::AbstractVector, y::AbstractVector,
                  ...,
                  k::Int=min(length(x)-1,3), ...