JuliaMath / Interpolations.jl

Fast, continuous interpolation of discrete datasets in Julia
http://juliamath.github.io/Interpolations.jl/
Other
523 stars 110 forks source link

Docs for scaled BSpline contradicts Base documentation #517

Closed jmsull closed 2 years ago

jmsull commented 2 years ago

In the Base documentation for StepRange, it is stated that the types involved in StepRange should never be floats.

However, for scaled BSplines, the Interpolations.jl documentation gives as an example exactly the thing Base says not to do.

Unless I am missing something, the Interpolations.jl examples should be updated? e.g. to use range(...)?

mkitti commented 2 years ago

In the Base documentation for StepRange, it is stated that the types involved in StepRange should never be floats.

I believe you may be confusing the StepRange type with the colon syntax. The colon syntax can produce many types of AbstractRanges other than StepRange.

julia> typeof(1:30)
UnitRange{Int64}

julia> typeof(1:2:40)
StepRange{Int64, Int64}

julia> typeof(1:2.:40)
StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}

When we use floating point numbers with the colon syntax, we get a StepRangeLen.

range also can produce several types of AbstractRange depending on the types provided as arguments.

julia> range(2,5) |> typeof
UnitRange{Int64}

julia> range(2,5, length=3) |> typeof
StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}

julia> range(2,5, step=0.1) |> typeof
StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}
jmsull commented 2 years ago

Thanks for the pointer about colon syntax.