-
-
Notifications
You must be signed in to change notification settings - Fork 58
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
As of 7.1.0, output eltype is different when evaluating on vectors compared to just broadcasting the scalar path
julia> using DataInterpolations
julia> u = [2, 3];
julia> t = [0.0, 1.0];
julia> itp = ConstantInterpolation(u, t)
julia> itp(t)
2-element Vector{Float64}:
2.0
3.0
julia> itp.(t)
2-element Vector{Int64}:
2
3The culprit is in the following lines from https://github.com/SciML/DataInterpolations.jl/blob/master/src/DataInterpolations.jl#L29
function (interp::AbstractInterpolation)(t::AbstractVector)
u = get_u(interp.u, t)
interp(u, t)
end
function get_u(u::AbstractVector, t)
return similar(t, promote_type(eltype(u), eltype(t)))
endFor floats versus ints, a specialization can be defined for ConstantInterpolation (whose output is the one that actually preserves the eltype of u). But I wonder if the promotion would also generate issues with exotic output types. Would it be possible for get_u to use the inferred return type of interp itself or would that require usage of arcane Julia internals?
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working