You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The return value of derivative is inferred as Any (i.e., it is type-unstable). This seems like a bug?
Furthermore, it allocates a Vector{Float64} for its return value. Since the dimensionality is known from the ParametricSpline type, couldn't we use SVector{2,Float64} instead? StaticArrays.jl is pretty widely used these days, so it is not crazy to add a dependency on it. (Alternatively, you could add an API that returns a tuple.)
julia>using Dierckx, Test
julia> spl =ParametricSpline(1:10, rand(2, 10))
ParametricSpline(knots=[1.0,3.0…8.0,10.0] (8 elements), k=3, extrapolation="nearest", residual=0.0)
julia>derivative(spl, 5.1) # allocates2-element Vector{Float64}:-0.67563942202007240.1203327362940756
julia>@inferredderivative(spl, 5.1) # type-unstable
ERROR:return type Vector{Float64} does not match inferred return type Any
The text was updated successfully, but these errors were encountered:
Looks like the type-instability comes from the dims=[2] pattern that is used in the source, which is type-unstable because the length of the dims array is not known until runtime.
The fix should be simple: use dims=2 instead of dims=[2]. (Or if there are multiple dims, use a tuple.)
The return value of
derivative
is inferred asAny
(i.e., it is type-unstable). This seems like a bug?Furthermore, it allocates a
Vector{Float64}
for its return value. Since the dimensionality is known from theParametricSpline
type, couldn't we useSVector{2,Float64}
instead? StaticArrays.jl is pretty widely used these days, so it is not crazy to add a dependency on it. (Alternatively, you could add an API that returns a tuple.)The text was updated successfully, but these errors were encountered: