Skip to content

Inconsistent interpolation outcome on Float32 inputs #255

@cstjean

Description

@cstjean

When x::Vector{Int} and y::Vector{Float32}, I expect the outcome to be a Float32, but it's inconsistent:

julia> interp = Interpolations.interpolate(([1,2,3],), [1.0f0, 2.0f0, 1.0f0], Interpolations.Gridded(Interpolations.Linear()));

julia> interp(2)
2.0

julia> interp([2])
1-element Array{Float64,1}:
 2.0

julia> ex = Interpolations.extrapolate(interp, NaN32);

julia> ex(2)
2.0

julia> ex([2])
1-element Array{Float32,1}:
 2.0

If my inputs are Float32, then all is fine, but for my use case, x is the number of seconds since some reference time, and I am a bit worried about the loss of precision that comes from early Float32 conversion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions