Skip to content

Commit e9b99cf

Browse files
authored
Merge branch 'master' into master
2 parents e22ae1b + a0e9520 commit e9b99cf

File tree

4 files changed

+57
-38
lines changed

4 files changed

+57
-38
lines changed

README.md

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
11
# Interpolations
22

33
[![Build Status](https://travis-ci.org/JuliaMath/Interpolations.jl.svg?branch=master)](https://travis-ci.org/JuliaMath/Interpolations.jl)
4-
[![PkgEval Status](http://pkg.julialang.org/badges/Interpolations_0.4.svg)](http://pkg.julialang.org/?pkg=Interpolations)
5-
[![Interpolations](http://pkg.julialang.org/badges/Interpolations_0.5.svg)](http://pkg.julialang.org/?pkg=Interpolations)
6-
7-
Documentation:
84
[![](https://img.shields.io/badge/docs-latest-blue.svg)](http://juliamath.github.io/Interpolations.jl/latest)
95

6+
**NEWS** This package is currently under new maintainership. Please be patient while the new maintainer learns the new package. If you would like to volunteer, please mention this in an issue.
107

118
**NEWS** v0.9 was a breaking release. See the [news](NEWS.md) for details on how to update.
129

13-
**NEWS** This package is officially looking for a maintainer.
14-
The original authors are only fixing bugs that affect them personally.
15-
However, to facilitate transition to a long-term maintainer,
16-
for a period of time they will make a concerted attempt to review pull requests.
17-
Step forward soon to avoid the risk of not being able to take advantage of such offers of support.
18-
1910
This package implements a variety of interpolation schemes for the
2011
Julia language. It has the goals of ease-of-use, broad algorithmic
2112
support, and exceptional performance.
2213

2314
Currently this package's support is best
2415
for [B-splines](https://en.wikipedia.org/wiki/B-spline) and also
2516
supports irregular grids. However, the API has been designed with
26-
intent to support more options. Pull-requests are more than welcome!
17+
intent to support more options. Initial support for Lanczos
18+
interpolation was recently added. Pull-requests are more than welcome!
2719
It should be noted that the API may continue to evolve over time.
2820

2921
Other interpolation packages for Julia include:
@@ -122,6 +114,6 @@ Interpolations wins in every case, sometimes by a very large margin.
122114

123115
## Contributing
124116

125-
Work is very much in progress, but and help is always welcome. If you want to help out but don't know where to start, take a look at issue [#5 - our feature wishlist](https://github.com/JuliaMath/Interpolations.jl/issues/5) =) There is also some [developer documentation](doc/devdocs.md) that may help you understand how things work internally.
117+
Work is very much in progress, but and help is always welcome. If you want to help out but don't know where to start, take a look at issue [#5 - our feature wishlist](https://github.com/JuliaMath/Interpolations.jl/issues/5) =) There is also some [developer documentation](http://juliamath.github.io/Interpolations.jl/latest/devdocs/) that may help you understand how things work internally.
126118

127119
Contributions in any form are appreciated, but the best pull requests come with tests!

src/extrapolation/extrapolation.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ count_interp_dims(::Type{<:Extrapolation{T,N,ITPT}}, n) where {T,N,ITPT} = count
5353
end
5454
@inline function (etp::Extrapolation{T,N})(x::Vararg{Union{Number,AbstractVector},N}) where {T,N}
5555
itp = parent(etp)
56-
Tret = typeof(lispyprod(zero(T), x...))
57-
ret = zeros(Tret, shape(x...))
56+
ret = zeros(T, shape(x...))
5857
for (i, y) in zip(eachindex(ret), Iterators.product(x...))
5958
ret[i] = etp(y...)
6059
end

test/extrapolation/type-stability.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,10 @@ using Test, Interpolations, DualNumbers, Unitful
6969
@test @inferred(itp(2018)) === 2.0f0 * u
7070
@test @inferred(etp(2018)) === 2.0f0 * u
7171
@test @inferred(etp(2019)) === 1.0f0 * u
72+
73+
# Unitful vector knots
74+
t = [0.0, 1.0] * u"m"
75+
itp = LinearInterpolation(t, y)
76+
@test itp(0.5u"m") == 1.5f0 * u
77+
@test itp([0.5, 0.75]u"m") == [1.5f0, 1.75f0] * u
7278
end

test/io.jl

Lines changed: 46 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,47 @@ using Test
88
A = rand(8,20)
99

1010
itp = interpolate(A, BSpline(Constant()))
11-
@test summary(itp) == "8×20 interpolate(::Array{Float64,2}, BSpline(Constant())) with element type Float64"
11+
@test summary(itp) == "8×20 interpolate(::Matrix{Float64}, BSpline(Constant())) with element type Float64" ||
12+
summary(itp) == "8×20 interpolate(::Array{Float64,2}, BSpline(Constant())) with element type Float64"
1213

1314
itp = interpolate(A, BSpline(Constant()))
14-
@test summary(itp) == "8×20 interpolate(::Array{Float64,2}, BSpline(Constant())) with element type Float64"
15+
@test summary(itp) == "8×20 interpolate(::Matrix{Float64}, BSpline(Constant())) with element type Float64" ||
16+
summary(itp) == "8×20 interpolate(::Array{Float64,2}, BSpline(Constant())) with element type Float64"
1517

1618
itp = interpolate(A, BSpline(Linear()))
17-
@test summary(itp) == "8×20 interpolate(::Array{Float64,2}, BSpline(Linear())) with element type Float64"
19+
@test summary(itp) == "8×20 interpolate(::Matrix{Float64}, BSpline(Linear())) with element type Float64" ||
20+
summary(itp) == "8×20 interpolate(::Array{Float64,2}, BSpline(Linear())) with element type Float64"
1821

1922
itp = interpolate(A, BSpline(Quadratic(Reflect(OnCell()))))
20-
@test summary(itp) == "8×20 interpolate(OffsetArray(::Array{Float64,2}, 0:9, 0:21), BSpline(Quadratic(Reflect(OnCell())))) with element type Float64"
23+
@test summary(itp) == "8×20 interpolate(OffsetArray(::Matrix{Float64}, 0:9, 0:21), BSpline(Quadratic(Reflect(OnCell())))) with element type Float64" ||
24+
summary(itp) == "8×20 interpolate(OffsetArray(::Array{Float64,2}, 0:9, 0:21), BSpline(Quadratic(Reflect(OnCell())))) with element type Float64"
2125

2226
itp = interpolate(A, (BSpline(Linear()), NoInterp()))
23-
@test summary(itp) == "8×20 interpolate(::Array{Float64,2}, (BSpline(Linear()), NoInterp())) with element type Float64"
27+
@test summary(itp) == "8×20 interpolate(::Matrix{Float64}, (BSpline(Linear()), NoInterp())) with element type Float64" ||
28+
summary(itp) == "8×20 interpolate(::Array{Float64,2}, (BSpline(Linear()), NoInterp())) with element type Float64"
2429

2530
itp = interpolate!(copy(A), BSpline(Quadratic(InPlace(OnCell()))))
26-
@test summary(itp) == "8×20 interpolate(::Array{Float64,2}, BSpline(Quadratic(InPlace(OnCell())))) with element type Float64"
31+
@test summary(itp) == "8×20 interpolate(::Matrix{Float64}, BSpline(Quadratic(InPlace(OnCell())))) with element type Float64" ||
32+
summary(itp) == "8×20 interpolate(::Array{Float64,2}, BSpline(Quadratic(InPlace(OnCell())))) with element type Float64"
2733
end
2834

2935
@testset "Gridded" begin
3036
A = rand(20)
3137
A_x = collect(1.0:2.0:40.0)
3238
knots = (A_x,)
3339
itp = interpolate(knots, A, Gridded(Linear()))
34-
@test summary(itp) == "20-element interpolate((::Array{Float64,1},), ::Array{Float64,1}, Gridded(Linear())) with element type Float64"
40+
@test summary(itp) == "20-element interpolate((::Vector{Float64},), ::Vector{Float64}, Gridded(Linear())) with element type Float64" ||
41+
summary(itp) == "20-element interpolate((::Array{Float64,1},), ::Array{Float64,1}, Gridded(Linear())) with element type Float64"
3542

3643
A = rand(8,20)
3744
knots = ([x^2 for x = 1:8], [0.2y for y = 1:20])
3845
itp = interpolate(knots, A, Gridded(Linear()))
39-
@test summary(itp) == "8×20 interpolate((::Array{Int64,1},::Array{Float64,1}), ::Array{Float64,2}, Gridded(Linear())) with element type Float64"
46+
@test summary(itp) == "8×20 interpolate((::Vector{Int64},::Vector{Float64}), ::Matrix{Float64}, Gridded(Linear())) with element type Float64" ||
47+
summary(itp) == "8×20 interpolate((::Array{Int64,1},::Array{Float64,1}), ::Array{Float64,2}, Gridded(Linear())) with element type Float64"
4048

4149
itp = interpolate(knots, A, (Gridded(Linear()),Gridded(Constant())))
42-
@test summary(itp) == "8×20 interpolate((::Array{Int64,1},::Array{Float64,1}), ::Array{Float64,2}, (Gridded(Linear()), Gridded(Constant()))) with element type Float64"
50+
@test summary(itp) == "8×20 interpolate((::Vector{Int64},::Vector{Float64}), ::Matrix{Float64}, (Gridded(Linear()), Gridded(Constant()))) with element type Float64" ||
51+
summary(itp) == "8×20 interpolate((::Array{Int64,1},::Array{Float64,1}), ::Array{Float64,2}, (Gridded(Linear()), Gridded(Constant()))) with element type Float64"
4352

4453
# issue #260
4554
A = (1:4)/4
@@ -48,26 +57,33 @@ using Test
4857
show(io, MIME("text/plain"), itp)
4958
str1 = String(take!(io))
5059
str2 = "4-element interpolate((0.0:0.1:0.3,), ::Array{Float64,1}, Gridded(Linear())) with element type Float64:\n 0.25\n 0.5 \n 0.75\n 1.0"
51-
@test filter(!isspace, str1) == filter(!isspace, str2)
60+
str3 = "4-elementinterpolate((0.0:0.1:0.3,),::Vector{Float64},Gridded(Linear()))withelementtypeFloat64:\n 0.25 \n 0.5 \n 0.75\n 1.0"
61+
@test filter(!isspace, str1) == filter(!isspace, str3) ||
62+
filter(!isspace, str1) == filter(!isspace, str2)
5263
io2 = IOBuffer()
5364
show(io2, itp)
5465
str1 = String(take!(io2))
5566
str2 = "4-element interpolate((0.0:0.1:0.3,), ::Array{Float64,1}, Gridded(Linear())) with element type Float64:\n 0.25\n 0.5 \n 0.75\n 1.0"
56-
@test filter(!isspace, str1) == filter(!isspace, str2)
67+
str3 = "4-elementinterpolate((0.0:0.1:0.3,),::Vector{Float64},Gridded(Linear()))withelementtypeFloat64:\n 0.25\n 0.5\n 0.75\n 1.0"
68+
@test filter(!isspace, str1) == filter(!isspace, str3) ||
69+
filter(!isspace, str1) == filter(!isspace, str2)
5770
end
5871

5972
@testset "scaled" begin
6073
itp = interpolate(1:1.0:10, BSpline(Linear()))
6174
sitp = scale(itp, -3:.5:1.5)
62-
@test summary(sitp) == "10-element scale(interpolate(::Array{Float64,1}, BSpline(Linear())), (-3.0:0.5:1.5,)) with element type Float64"
75+
@test summary(sitp) == "10-element scale(interpolate(::Vector{Float64}, BSpline(Linear())), (-3.0:0.5:1.5,)) with element type Float64" ||
76+
summary(sitp) == "10-element scale(interpolate(::Array{Float64,1}, BSpline(Linear())), (-3.0:0.5:1.5,)) with element type Float64"
6377
io = IOBuffer()
6478
show(io, MIME("text/plain"), sitp)
6579
str = String(take!(io))
66-
@test str == "10-element scale(interpolate(::Array{Float64,1}, BSpline(Linear())), (-3.0:0.5:1.5,)) with element type Float64:\n 1.0\n 2.0\n 3.0\n 4.0\n 5.0\n 6.0\n 7.0\n 8.0\n 9.0\n 10.0"
80+
@test str == "10-element scale(interpolate(::Vector{Float64}, BSpline(Linear())), (-3.0:0.5:1.5,)) with element type Float64:\n 1.0\n 2.0\n 3.0\n 4.0\n 5.0\n 6.0\n 7.0\n 8.0\n 9.0\n 10.0" ||
81+
str == "10-element scale(interpolate(::Array{Float64,1}, BSpline(Linear())), (-3.0:0.5:1.5,)) with element type Float64:\n 1.0\n 2.0\n 3.0\n 4.0\n 5.0\n 6.0\n 7.0\n 8.0\n 9.0\n 10.0"
6782
io2 = IOBuffer()
6883
show(io2, sitp)
6984
str2 = String(take!(io2))
70-
@test str2 == "10-element scale(interpolate(::Array{Float64,1}, BSpline(Linear())), (-3.0:0.5:1.5,)) with element type Float64:\n 1.0\n 2.0\n 3.0\n 4.0\n 5.0\n 6.0\n 7.0\n 8.0\n 9.0\n 10.0"
85+
@test str2 == "10-element scale(interpolate(::Vector{Float64}, BSpline(Linear())), (-3.0:0.5:1.5,)) with element type Float64:\n 1.0\n 2.0\n 3.0\n 4.0\n 5.0\n 6.0\n 7.0\n 8.0\n 9.0\n 10.0" ||
86+
str2 == "10-element scale(interpolate(::Array{Float64,1}, BSpline(Linear())), (-3.0:0.5:1.5,)) with element type Float64:\n 1.0\n 2.0\n 3.0\n 4.0\n 5.0\n 6.0\n 7.0\n 8.0\n 9.0\n 10.0"
7187

7288
gauss(phi, mu, sigma) = exp(-(phi-mu)^2 / (2sigma)^2)
7389
testfunction(x,y) = gauss(x, 0.5, 4) * gauss(y, -.5, 2)
@@ -77,29 +93,32 @@ using Test
7793
itp2 = interpolate(zs, BSpline(Quadratic(Flat(OnGrid()))))
7894
sitp2 = scale(itp2, xs, ys)
7995
teststring = "21×41 scale(interpolate(OffsetArray(::Array{Float64,2}, 0:22, 0:42), BSpline(Quadratic(Flat(OnGrid())))), (-5.0:0.5:5.0,$SPACE-4.0:0.2:4.0)) with element type Float64"
80-
@test summary(sitp2) == teststring
96+
teststring2 = "21×41 scale(interpolate(OffsetArray(::Matrix{Float64}, 0:22, 0:42), BSpline(Quadratic(Flat(OnGrid())))), (-5.0:0.5:5.0,$SPACE-4.0:0.2:4.0)) with element type Float64"
97+
@test summary(sitp2) == teststring2 ||
98+
summary(sitp2) == teststring
8199
io3 = IOBuffer()
82100
show(io3, sitp2)
83101
str3 = String(take!(io3))
84-
@test occursin(teststring, str3)
102+
@test occursin(teststring2, str3) || occursin(teststring, str3)
85103
end
86104

87105
@testset "Monotonic" begin
88106
A_x = collect(1.0:2.0:40.0)
89107
A = map(x->x^2, A_x)
90108
itp = interpolate(A_x, A, FritschButlandMonotonicInterpolation())
91109
teststring = "20-element interpolate(::Array{Float64,1}, ::Array{Float64,1}, FritschButlandMonotonicInterpolation()) with element type Float64"
92-
@test summary(itp) == teststring
110+
teststring2 = "20-element interpolate(::Vector{Float64}, ::Vector{Float64}, FritschButlandMonotonicInterpolation()) with element type Float64"
111+
@test summary(itp) == teststring2 || summary(itp) == teststring
93112

94113
io = IOBuffer()
95114
show(io, itp)
96115
str = String(take!(io))
97-
@test occursin(teststring, str)
116+
@test occursin(teststring2, str) || occursin(teststring, str)
98117

99118
io2 = IOBuffer()
100119
show(io2, MIME("text/plain"), itp)
101120
str = String(take!(io2))
102-
@test occursin(teststring, str)
121+
@test occursin(teststring2, str) || occursin(teststring, str)
103122
end
104123

105124
@testset "Extrapolation" begin
@@ -108,19 +127,21 @@ using Test
108127
itpg = interpolate(A, BSpline(Linear()))
109128
etpg = extrapolate(itpg, Flat())
110129
teststring = "8×20 extrapolate(interpolate(::Array{Float64,2}, BSpline(Linear())), Flat()) with element type Float64"
111-
@test summary(etpg) == teststring
130+
teststring16 = "8×20 extrapolate(interpolate(::Matrix{Float64}, BSpline(Linear())), Flat()) with element type Float64"
131+
@test summary(etpg) == teststring16 || summary(etpg) == teststring
112132
io = IOBuffer()
113133
show(io, etpg)
114134
str = String(take!(io))
115-
@test occursin(teststring, str)
135+
@test occursin(teststring16, str) || occursin(teststring, str)
116136

117137
etpf = extrapolate(itpg, NaN)
118138
teststring2 = "8×20 extrapolate(interpolate(::Array{Float64,2}, BSpline(Linear())), NaN) with element type Float64"
119-
@test summary(etpf) == teststring2
139+
teststring16 = "8×20 extrapolate(interpolate(::Matrix{Float64}, BSpline(Linear())), NaN) with element type Float64"
140+
@test summary(etpf) == teststring16 || summary(etpf) == teststring2
120141
io2 = IOBuffer()
121142
show(io2, etpf)
122143
str2 = String(take!(io2))
123-
@test occursin(teststring2, str2)
144+
@test occursin(teststring16, str2) || occursin(teststring2, str2)
124145
end
125146

126147
@testset "Combinations" begin
@@ -138,6 +159,7 @@ using Test
138159
io = IOBuffer()
139160
show(io, MIME("text/plain"), itp)
140161
str = String(take!(io))
141-
@test str == "3×3×3 scale(interpolate(OffsetArray(::Array{Float64,3}, 0:4, 0:4, 0:4), BSpline(Cubic(Free(OnGrid())))), (2:4, 2:4, 2:4)) with element type Float64:\n[:, :, 1] =\n 0.0 0.0 0.0\n 0.0 0.0 0.0\n 0.0 0.0 0.0\n\n[:, :, 2] =\n 0.0 0.0 0.0\n 0.0 0.0 0.0\n 0.0 0.0 0.0\n\n[:, :, 3] =\n 0.0 0.0 0.0\n 0.0 0.0 0.0\n 0.0 0.0 0.0"
162+
@test str == "3×3×3 scale(interpolate(OffsetArray(::Array{Float64, 3}, 0:4, 0:4, 0:4), BSpline(Cubic(Free(OnGrid())))), (2:4, 2:4, 2:4)) with element type Float64:\n[:, :, 1] =\n 0.0 0.0 0.0\n 0.0 0.0 0.0\n 0.0 0.0 0.0\n\n[:, :, 2] =\n 0.0 0.0 0.0\n 0.0 0.0 0.0\n 0.0 0.0 0.0\n\n[:, :, 3] =\n 0.0 0.0 0.0\n 0.0 0.0 0.0\n 0.0 0.0 0.0" ||
163+
str == "3×3×3 scale(interpolate(OffsetArray(::Array{Float64,3}, 0:4, 0:4, 0:4), BSpline(Cubic(Free(OnGrid())))), (2:4, 2:4, 2:4)) with element type Float64:\n[:, :, 1] =\n 0.0 0.0 0.0\n 0.0 0.0 0.0\n 0.0 0.0 0.0\n\n[:, :, 2] =\n 0.0 0.0 0.0\n 0.0 0.0 0.0\n 0.0 0.0 0.0\n\n[:, :, 3] =\n 0.0 0.0 0.0\n 0.0 0.0 0.0\n 0.0 0.0 0.0"
142164
end
143165
end # testset

0 commit comments

Comments
 (0)