Skip to content

Commit 380b80c

Browse files
authored
Merge pull request #143 from marius311/MM/vecindex
make vector indexing work with all extrapolations
2 parents 6301e01 + ce431a1 commit 380b80c

File tree

5 files changed

+12
-4
lines changed

5 files changed

+12
-4
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
language: julia
22
sudo: false
33
julia:
4-
- 0.4
54
- 0.5
65
- nightly
76
matrix:

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
julia 0.4
1+
julia 0.5
22

33
WoodburyMatrices 0.1.5
44
Ratios

src/Interpolations.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export
3737
using Compat
3838
using WoodburyMatrices, Ratios, AxisAlgorithms
3939

40-
import Base: convert, size, getindex, gradient, promote_rule, ndims, eltype
40+
import Base: convert, size, getindex, gradient, promote_rule, ndims, eltype, checkbounds
4141

4242
# Julia v0.5 compatibility
4343
if isdefined(:scaling) import Base.scaling end

src/extrapolation/extrapolation.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,12 @@ function getindex_impl{T,N,ITPT,IT,GT,ET}(etp::Type{Extrapolation{T,N,ITPT,IT,GT
5454
end
5555
end
5656

57-
@generated function getindex{T,N,ITPT,IT,GT,ET}(etp::Extrapolation{T,N,ITPT,IT,GT,ET}, xs...)
57+
@generated function getindex{T,N,ITPT,IT,GT,ET}(etp::Extrapolation{T,N,ITPT,IT,GT,ET}, xs::Number...)
5858
getindex_impl(etp, xs...)
5959
end
6060

61+
checkbounds(::AbstractExtrapolation,I...) = nothing
62+
6163

6264
function gradient!_impl{T,N,ITPT,IT,GT,ET}(g, etp::Type{Extrapolation{T,N,ITPT,IT,GT,ET}}, xs...)
6365
coords = [Symbol("xs_", d) for d in 1:N]

test/extrapolation/runtests.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ etp100g = extrapolate(interpolate(([10;20],),[100;110], Gridded(Linear())), Flat
7979
@test @inferred(getindex(etp100g, 5)) == 100
8080
@test @inferred(getindex(etp100g, 15)) == 105
8181
@test @inferred(getindex(etp100g, 25)) == 110
82+
83+
84+
# check all extrapolations work with vectorized indexing
85+
for E in [0,Flat(),Linear(),Periodic(),Reflect()]
86+
@test (@inferred(getindex(extrapolate(interpolate([0,0],BSpline(Linear()),OnGrid()),E),[1.2, 1.8, 3.1]))) == [0,0,0]
87+
end
88+
8289
end
8390

8491
include("type-stability.jl")

0 commit comments

Comments
 (0)