Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: julia
sudo: false
julia:
- 0.4
- 0.5
- nightly
matrix:
Expand Down
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
julia 0.4
julia 0.5

WoodburyMatrices 0.1.5
Ratios
Expand Down
2 changes: 1 addition & 1 deletion src/Interpolations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export
using Compat
using WoodburyMatrices, Ratios, AxisAlgorithms

import Base: convert, size, getindex, gradient, promote_rule, ndims, eltype
import Base: convert, size, getindex, gradient, promote_rule, ndims, eltype, checkbounds

# Julia v0.5 compatibility
if isdefined(:scaling) import Base.scaling end
Expand Down
4 changes: 3 additions & 1 deletion src/extrapolation/extrapolation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ function getindex_impl{T,N,ITPT,IT,GT,ET}(etp::Type{Extrapolation{T,N,ITPT,IT,GT
end
end

@generated function getindex{T,N,ITPT,IT,GT,ET}(etp::Extrapolation{T,N,ITPT,IT,GT,ET}, xs...)
@generated function getindex{T,N,ITPT,IT,GT,ET}(etp::Extrapolation{T,N,ITPT,IT,GT,ET}, xs::Number...)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should change this now to xs::Vararg{Number,N} (insist that N xs are provided).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I'd take that back. By putting on the Vararg constraint, you'd suddenly allow trailing 1s and indexing with fewer indices than dimensions (Base machinery will adjust the inputs to produce N outputs). So by not constraining to N, you ensure that this method "intercepts" the call.

getindex_impl(etp, xs...)
end

checkbounds(::AbstractExtrapolation,I...) = nothing


function gradient!_impl{T,N,ITPT,IT,GT,ET}(g, etp::Type{Extrapolation{T,N,ITPT,IT,GT,ET}}, xs...)
coords = [Symbol("xs_", d) for d in 1:N]
Expand Down
7 changes: 7 additions & 0 deletions test/extrapolation/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ 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


# check all extrapolations work with vectorized indexing
for E in [0,Flat(),Linear(),Periodic(),Reflect()]
@test (@inferred(getindex(extrapolate(interpolate([0,0],BSpline(Linear()),OnGrid()),E),[1.2, 1.8, 3.1]))) == [0,0,0]
end

end

include("type-stability.jl")