Skip to content

Commit

Permalink
Merge pull request #179 from JuliaMath/teh/fix_178
Browse files Browse the repository at this point in the history
Fix computation of element type (fixes #178)
  • Loading branch information
timholy authored Sep 19, 2017
2 parents 1201501 + b10a8c8 commit 62dd04b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
4 changes: 0 additions & 4 deletions src/b-splines/indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@ function getindex_return_type(::Type{BSplineInterpolation{T,N,TCoefs,IT,GT,Pad}}
_promote_mul(eltype(TCoefs), I)
end

@noinline function getindex_return_type(::Type{Tel}, ::Type{BSplineInterpolation{T,N,TCoefs,IT,GT,Pad}}, argtypes::Tuple) where {Tel,T,N,TCoefs,IT<:DimSpec{BSpline},GT<:DimSpec{GridType},Pad}
reduce(_promote_mul, eltype(TCoefs), (Tel, argtypes...))
end

@generated function gradient!(g::AbstractVector, itp::BSplineInterpolation{T,N}, xs::Number...) where {T,N}
length(xs) == N || error("Can only be called with $N indexes")
gradient_impl(itp)
Expand Down
2 changes: 1 addition & 1 deletion src/extrapolation/filled.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function getindex_impl(fitp::Type{FilledExtrapolation{T,N,ITP,IT,GT,FT}}, args)
n = length(args)
n == N || return error("Must index $(N)-dimensional interpolation objects with $(nindexes(N))")

Tret = FT<:Number ? getindex_return_type(T, ITP, args) : FT
Tret = FT<:Number ? getindex_return_type(ITP, (T, args...)) : FT
meta = Expr(:meta, :inline)
quote
$meta
Expand Down
5 changes: 4 additions & 1 deletion test/extrapolation/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ etp100g = extrapolate(interpolate(([10;20],),[100;110], Gridded(Linear())), Flat
@test @inferred(getindex(etp100g, 5)) == 100
@test @inferred(getindex(etp100g, 15)) == 105
@test @inferred(getindex(etp100g, 25)) == 110

# issue #178
a = randn(10,10) + im*rand(10,10)
etp = @inferred(extrapolate(interpolate((1:10, 1:10), a, Gridded(Linear())), 0.0))
@test @inferred(etp[-1,0]) === 0.0+0.0im

# check all extrapolations work with vectorized indexing
for E in [0,Flat(),Linear(),Periodic(),Reflect()]
Expand Down

0 comments on commit 62dd04b

Please sign in to comment.