Skip to content

Commit adf5571

Browse files
committed
Fix test depwarns from putting the gridtype into the boundarycondition
1 parent 9f7bf16 commit adf5571

20 files changed

+124
-148
lines changed

test/b-splines/constant.jl

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,16 @@
77

88
for (constructor, copier) in ((interpolate, x->x), (interpolate!, copy))
99
isinplace = constructor == interpolate!
10-
itp1c = @inferred(constructor(copier(A1), BSpline(Constant()), OnCell()))
11-
itp1g = @inferred(constructor(copier(A1), BSpline(Constant()), OnGrid()))
12-
itp2c = @inferred(constructor(copier(A2), BSpline(Constant()), OnCell()))
13-
itp2g = @inferred(constructor(copier(A2), BSpline(Constant()), OnGrid()))
14-
itp3c = @inferred(constructor(copier(A3), BSpline(Constant()), OnCell()))
15-
itp3g = @inferred(constructor(copier(A3), BSpline(Constant()), OnGrid()))
10+
itp1 = @inferred(constructor(copier(A1), BSpline(Constant())))
11+
itp2 = @inferred(constructor(copier(A2), BSpline(Constant())))
12+
itp3 = @inferred(constructor(copier(A3), BSpline(Constant())))
1613

17-
@test parent(itp1c) === itp1c.coefs
18-
@test Interpolations.lbounds(itp1c) == (0.5,)
19-
@test Interpolations.lbounds(itp1g) == (1,)
20-
@test Interpolations.ubounds(itp1c) == (N1 + 0.5,)
21-
@test Interpolations.ubounds(itp1g) == (N1,)
14+
@test parent(itp1) === itp1.coefs
15+
@test Interpolations.lbounds(itp1) == (1,)
16+
@test Interpolations.ubounds(itp1) == (N1,)
2217

2318
# Evaluation on provided data points
24-
for (itp, A) in ((itp1c, A1), (itp1g, A1), (itp2c, A2), (itp2g, A2), (itp3c, A3), (itp3g, A3))
19+
for (itp, A) in ((itp1, A1), (itp2, A2), (itp3, A3))
2520
check_axes(itp, A, isinplace)
2621
check_inbounds_values(itp, A)
2722
check_oob(itp)
@@ -30,19 +25,15 @@
3025

3126
# Evaluation between data points (tests constancy)
3227
for i in 2:N1-1
33-
@test A1[i] == itp1c(i+.3) == itp1g(i+.3) == itp1c(i-.3) == itp1g(i-.3)
28+
@test A1[i] == itp1(i+.3) == itp1(i+.3) == itp1(i-.3) == itp1(i-.3)
3429
end
3530
# 2D
3631
for i in 2:N1-1, j in 2:N1-1
37-
@test A2[i,j] == itp2c(i+.4,j-.3) == itp2g(i+.4,j-.3)
32+
@test A2[i,j] == itp2(i+.4,j-.3) == itp2(i+.4,j-.3)
3833
end
3934
# 3D
4035
for i in 2:N1-1, j in 2:N1-1, k in 2:N1-1
41-
@test A3[i,j,k] == itp3c(i+.4,j-.3,k+.1) == itp3g(i+.4,j-.3,k+.2)
36+
@test A3[i,j,k] == itp3(i+.4,j-.3,k+.1) == itp3(i+.4,j-.3,k+.2)
4237
end
43-
44-
# Edge behavior
45-
@test A1[1] == itp1c(.7)
46-
@test A1[N1] == itp1c(N1+.3)
4738
end
4839
end

test/b-splines/cubic.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
for BC in (Line, Flat, Free, Periodic), GT in (OnGrid, OnCell)
1616
for (A, f) in ((A0, f0), (A1, f1))
17-
itp1 = @inferred(constructor(copier(A), BSpline(Cubic(BC())), GT()))
17+
itp1 = @inferred(constructor(copier(A), BSpline(Cubic(BC(GT())))))
1818
ax1 = axes(itp1)[1]
1919
@test Interpolations.lbounds(itp1) == (GT == OnGrid ? (first(ax1),) : (first(ax1) - 0.5,))
2020
@test Interpolations.ubounds(itp1) == (GT == OnGrid ? (last(ax1),) : (last(ax1) + 0.5,))
@@ -30,7 +30,7 @@
3030
end
3131
end
3232

33-
itp2 = @inferred(constructor(copier(A2), BSpline(Cubic(BC())), GT()))
33+
itp2 = @inferred(constructor(copier(A2), BSpline(Cubic(BC(GT())))))
3434
@test_throws ArgumentError parent(itp2)
3535
check_axes(itp2, A2, isinplace)
3636
check_inbounds_values(itp2, A2)
@@ -54,18 +54,18 @@
5454

5555
for BC in (Line, Flat, Free, Periodic), GT in (OnGrid,OnCell)
5656

57-
itp = constructor(copier(A), BSpline(Cubic(BC())), GT())
57+
itp = constructor(copier(A), BSpline(Cubic(BC(GT()))))
5858
# test that inner region is close to data
5959
for x in range(ix[5], stop=ix[end-4], length=100)
6060
@test g(x) Interpolations.gradient1(itp,x) atol=cbrt(cbrt(eps(g(x))))
6161
end
6262
end
6363
end
64-
itp_flat_g = interpolate(A, BSpline(Cubic(Flat())), OnGrid())
64+
itp_flat_g = interpolate(A, BSpline(Cubic(Flat(OnGrid()))))
6565
@test Interpolations.gradient(itp_flat_g,1)[1] 0 atol=eps()
6666
@test Interpolations.gradient(itp_flat_g,ix[end])[1] 0 atol=eps()
6767

68-
itp_flat_c = interpolate(A, BSpline(Cubic(Flat())), OnCell())
68+
itp_flat_c = interpolate(A, BSpline(Cubic(Flat(OnCell()))))
6969
@test Interpolations.gradient(itp_flat_c,0.5)[1] 0 atol=eps()
7070
@test Interpolations.gradient(itp_flat_c,ix[end] + 0.5)[1] 0 atol=eps()
7171
end

test/b-splines/linear.jl

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,14 @@
1212

1313
for (constructor, copier) in ((interpolate, identity), (interpolate!, copy))
1414
isinplace = constructor == interpolate!
15-
itp1c = @inferred(constructor(copier(A1), BSpline(Linear()), OnCell()))
16-
itp1g = @inferred(constructor(copier(A1), BSpline(Linear()), OnGrid()))
17-
itp2c = @inferred(constructor(copier(A2), BSpline(Linear()), OnCell()))
18-
itp2g = @inferred(constructor(copier(A2), BSpline(Linear()), OnGrid()))
19-
20-
@test parent(itp1c) === itp1c.coefs
21-
@test Interpolations.lbounds(itp1c) == (0.5,)
22-
@test Interpolations.lbounds(itp1g) == (1,)
23-
@test Interpolations.ubounds(itp1c) == (xmax + 0.5,)
24-
@test Interpolations.ubounds(itp1g) == (xmax,)
25-
26-
for (itp, A) in ((itp1c, A1), (itp1g, A1), (itp2c, A2), (itp2g, A2))
15+
itp1 = @inferred(constructor(copier(A1), BSpline(Linear())))
16+
itp2 = @inferred(constructor(copier(A2), BSpline(Linear())))
17+
18+
@test parent(itp1) === itp1.coefs
19+
@test Interpolations.lbounds(itp1) == (1,)
20+
@test Interpolations.ubounds(itp1) == (xmax,)
21+
22+
for (itp, A) in ((itp1, A1), (itp2, A2))
2723
check_axes(itp, A, isinplace)
2824
check_inbounds_values(itp, A)
2925
check_oob(itp)
@@ -34,19 +30,17 @@
3430

3531
# Just interpolation
3632
for x in 1:.2:xmax
37-
@test f(x) itp1c(x) atol=abs(0.1 * f(x))
33+
@test f(x) itp1(x) atol=abs(0.1 * f(x))
3834
end
3935

4036
# 2D
41-
for itp2 in (itp2c, itp2g)
42-
for x in 2.1:.2:xmax-1, y in 1.9:.2:ymax-.9
43-
@test (f(x,y),itp2(x,y),atol=abs(0.25 * f(x,y)))
44-
end
37+
for x in 2.1:.2:xmax-1, y in 1.9:.2:ymax-.9
38+
@test (f(x,y),itp2(x,y),atol=abs(0.25 * f(x,y)))
4539
end
4640

4741
# Rational element types
4842
A1R = Rational{Int}[fr(x) for x in 1:10]
49-
itp1r = @inferred(constructor(copier(A1R), BSpline(Linear()), OnGrid()))
43+
itp1r = @inferred(constructor(copier(A1R), BSpline(Linear())))
5044
@test @inferred(size(itp1r)) == size(A1R)
5145
@test itp1r(23 // 10) fr(23 // 10) atol=abs(0.1 * fr(23 // 10))
5246
@test typeof(itp1r(23//10)) == Rational{Int}
@@ -55,7 +49,7 @@
5549

5650
# Issue #183
5751
x = rand(3,3,3)
58-
itp = interpolate(x, BSpline(Linear()), OnGrid())
52+
itp = interpolate(x, BSpline(Linear()))
5953
@test itp(1.5, CartesianIndex((2, 3))) === itp(1.5, 2, 3)
6054
@test itp(CartesianIndex((1, 2)), 1.5) === itp(1, 2, 1.5)
6155
end

test/b-splines/mixed.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
for (constructor, copier) in ((interpolate, x->x), (interpolate!, copy))
55
A2 = rand(Float64, N, N) * 100
66
for BC in (Flat,Line,Free,Periodic,Reflect,Natural), GT in (OnGrid, OnCell)
7-
itp_a = @inferred(constructor(copier(A2), (BSpline(Linear()), BSpline(Quadratic(BC()))), GT()))
8-
itp_b = @inferred(constructor(copier(A2), (BSpline(Quadratic(BC())), BSpline(Linear())), GT()))
7+
itp_a = @inferred(constructor(copier(A2), (BSpline(Linear()), BSpline(Quadratic(BC(GT()))))))
8+
itp_b = @inferred(constructor(copier(A2), (BSpline(Quadratic(BC(GT()))), BSpline(Linear()))))
99
isfullsize = constructor == interpolate || BC==Periodic
1010
if isfullsize
1111
@test @inferred(size(itp_a)) == size(A2)
@@ -49,8 +49,8 @@
4949
A2[i] *= 100
5050
end
5151
for BC in (Flat,Line,Free,Periodic,Reflect,Natural), GT in (OnGrid, OnCell)
52-
itp_a = @inferred(constructor(copier(A2), (BSpline(Linear()), BSpline(Quadratic(BC()))), GT()))
53-
itp_b = @inferred(constructor(copier(A2), (BSpline(Quadratic(BC())), BSpline(Linear())), GT()))
52+
itp_a = @inferred(constructor(copier(A2), (BSpline(Linear()), BSpline(Quadratic(BC(GT()))))))
53+
itp_b = @inferred(constructor(copier(A2), (BSpline(Quadratic(BC(GT()))), BSpline(Linear()))))
5454
if constructor == interpolate!
5555
@test isa(itp_a.coefs, SharedArray)
5656
@test isa(itp_b.coefs, SharedArray)

test/b-splines/multivalued.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@
44
A = reinterpret(MyPair{Float64}, A0)
55
a1, a2 = A0[1:2:end], A0[2:2:end]
66
@test length(A) == 10
7-
itp = interpolate(A, BSpline(Constant()), OnGrid())
7+
itp = interpolate(A, BSpline(Constant()))
88
@test itp(3.2) MyPair(A0[5],A0[6])
9-
itp = interpolate(A, BSpline(Linear()), OnGrid())
9+
itp = interpolate(A, BSpline(Linear()))
1010
@test itp(3.2) 0.8*MyPair(A0[5],A0[6]) + 0.2*MyPair(A0[7],A0[8])
11-
it, gt = BSpline(Quadratic(Flat())), OnGrid()
12-
itp = interpolate(A, it, gt)
13-
@test itp(3.2) MyPair(interpolate(a1, it, gt)(3.2), interpolate(a2, it, gt)(3.2))
11+
it = BSpline(Quadratic(Flat(OnGrid())))
12+
itp = interpolate(A, it)
13+
@test itp(3.2) MyPair(interpolate(a1, it)(3.2), interpolate(a2, it)(3.2))
1414

1515
# 2d
1616
A0 = rand(100)
1717
A = reshape(reinterpret(MyPair{Float64}, A0), (10,5))
1818
a1, a2 = reshape(A0[1:2:end], (10,5)), reshape(A0[2:2:end], (10,5))
19-
for (it, gt) in ((BSpline(Constant()), OnGrid()),
20-
(BSpline(Linear()), OnGrid()),
21-
(BSpline(Quadratic(Flat())), OnGrid()))
22-
itp = interpolate(A, it, gt)
23-
@test itp(3.2,1.8) MyPair(interpolate(a1, it, gt)(3.2,1.8), interpolate(a2, it, gt)(3.2,1.8))
19+
for it in (BSpline(Constant()),
20+
BSpline(Linear()),
21+
BSpline(Quadratic(Flat(OnGrid()))))
22+
itp = interpolate(A, it)
23+
@test itp(3.2,1.8) MyPair(interpolate(a1, it)(3.2,1.8), interpolate(a2, it)(3.2,1.8))
2424
end
2525
end

test/b-splines/non1.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,42 +21,42 @@ using AxisAlgorithms, OffsetArrays
2121
xinds, yinds = -2:28,0:9
2222
A2 = OffsetArray(Float64[f2(x,y) for x in xinds, y in yinds], xinds, yinds)
2323

24-
for GT in (OnGrid, OnCell), O in (Constant, Linear)
25-
itp1 = @inferred(constructor(copier(A1), BSpline(O()), GT()))
24+
for O in (Constant, Linear)
25+
itp1 = @inferred(constructor(copier(A1), BSpline(O())))
2626
check_axes(itp1, A1, isinplace)
2727
check_inbounds_values(itp1, A1)
2828
check_oob(itp1)
2929
can_eval_near_boundaries(itp1)
3030

31-
itp2 = @inferred(constructor(copier(A2), BSpline(O()), GT()))
31+
itp2 = @inferred(constructor(copier(A2), BSpline(O())))
3232
check_axes(itp2, A2, isinplace)
3333
check_inbounds_values(itp2, A2)
3434
check_oob(itp2)
3535
can_eval_near_boundaries(itp2)
3636
end
3737

3838
for BC in (Flat,Line,Free,Periodic,Reflect,Natural), GT in (OnGrid, OnCell)
39-
itp1 = @inferred(constructor(copier(A1), BSpline(Quadratic(BC())), GT()))
39+
itp1 = @inferred(constructor(copier(A1), BSpline(Quadratic(BC(GT())))))
4040
check_axes(itp1, A1, isinplace)
4141
check_inbounds_values(itp1, A1)
4242
check_oob(itp1)
4343
can_eval_near_boundaries(itp1)
4444

45-
itp2 = @inferred(constructor(copier(A2), BSpline(Quadratic(BC())), GT()))
45+
itp2 = @inferred(constructor(copier(A2), BSpline(Quadratic(BC(GT())))))
4646
check_axes(itp2, A2, isinplace)
4747
check_inbounds_values(itp2, A2)
4848
check_oob(itp2)
4949
can_eval_near_boundaries(itp2)
5050
end
5151

5252
for BC in (Flat,Line,Free,Periodic), GT in (OnGrid, OnCell)
53-
itp1 = @inferred(constructor(copier(A1), BSpline(Cubic(BC())), GT()))
53+
itp1 = @inferred(constructor(copier(A1), BSpline(Cubic(BC(GT())))))
5454
check_axes(itp1, A1, isinplace)
5555
check_inbounds_values(itp1, A1)
5656
check_oob(itp1)
5757
can_eval_near_boundaries(itp1)
5858

59-
itp2 = @inferred(constructor(copier(A2), BSpline(Cubic(BC())), GT()))
59+
itp2 = @inferred(constructor(copier(A2), BSpline(Cubic(BC(GT())))))
6060
check_axes(itp2, A2, isinplace)
6161
check_inbounds_values(itp2, A2)
6262
check_oob(itp2)
@@ -68,7 +68,7 @@ using AxisAlgorithms, OffsetArrays
6868
f(x) = sin((x-3)*2pi/9 - 1)
6969
inds = -7:2
7070
A = OffsetArray(Float64[f(x) for x in inds], inds)
71-
itp1 = interpolate!(copy(A), BSpline(Quadratic(InPlace())), OnCell())
71+
itp1 = interpolate!(copy(A), BSpline(Quadratic(InPlace(OnCell()))))
7272
check_axes(itp1, A)
7373
check_inbounds_values(itp1, A)
7474
check_oob(itp1)
@@ -77,7 +77,7 @@ using AxisAlgorithms, OffsetArrays
7777
f(x,y) = sin(x/10)*cos(y/6) + 0.1
7878
xinds, yinds = -2:28,0:9
7979
A2 = OffsetArray(Float64[f(x,y) for x in xinds, y in yinds], xinds, yinds)
80-
itp2 = interpolate!(copy(A2), BSpline(Quadratic(InPlace())), OnCell())
80+
itp2 = interpolate!(copy(A2), BSpline(Quadratic(InPlace(OnCell()))))
8181
check_axes(itp2, A2)
8282
check_inbounds_values(itp2, A2)
8383
check_oob(itp2)

test/b-splines/quadratic.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
xmax = 10
66
A = Float64[f(x) for x in 1:xmax]
77
for BC in (Flat,Line,Free,Periodic,Reflect,Natural), GT in (OnGrid, OnCell)
8-
itp1 = @inferred(constructor(copier(A), BSpline(Quadratic(BC())), GT()))
8+
itp1 = @inferred(constructor(copier(A), BSpline(Quadratic(BC(GT())))))
99
ax1 = axes(itp1)[1]
1010
@test Interpolations.lbounds(itp1) == (GT == OnGrid ? (first(ax1),) : (first(ax1) - 0.5,))
1111
@test Interpolations.ubounds(itp1) == (GT == OnGrid ? (last(ax1),) : (last(ax1) + 0.5,))
@@ -27,7 +27,7 @@
2727

2828
# test that inner region is close to data
2929
for BC in (Flat,Line,Free,Periodic,Reflect,Natural), GT in (OnGrid, OnCell)
30-
itp2 = @inferred(constructor(copier(A), BSpline(Quadratic(BC())), GT()))
30+
itp2 = @inferred(constructor(copier(A), BSpline(Quadratic(BC(GT())))))
3131
check_axes(itp2, A, isinplace)
3232
check_inbounds_values(itp2, A)
3333
check_oob(itp2)
@@ -44,14 +44,14 @@
4444
f(x) = sin((x-3)*2pi/9 - 1)
4545
xmax = 10
4646
A = Float64[f(x) for x in 1:xmax]
47-
itp1 = interpolate!(copy(A), BSpline(Quadratic(InPlace())), OnCell())
47+
itp1 = interpolate!(copy(A), BSpline(Quadratic(InPlace(OnCell()))))
4848
@test axes(itp1) == axes(A)
4949
check_inbounds_values(itp1, A)
5050

5151
f(x,y) = sin(x/10)*cos(y/6)
5252
xmax, ymax = 30,10
5353
A = Float64[f(x,y) for x in 1:xmax, y in 1:ymax]
54-
itp2 = interpolate!(copy(A), BSpline(Quadratic(InPlace())), OnCell())
54+
itp2 = interpolate!(copy(A), BSpline(Quadratic(InPlace(OnCell()))))
5555
@test axes(itp2) == axes(A)
5656
check_inbounds_values(itp2, A)
5757
end

test/extrapolation/non1.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ using Test, Interpolations, OffsetArrays
55
f(x) = sin((x-3)*2pi/9 - 1)
66
xinds = -3:6
77
A = OffsetArray(Float64[f(x) for x in xinds], xinds)
8-
itpg = interpolate(A, BSpline(Linear()), OnGrid())
8+
itpg = interpolate(A, BSpline(Linear()))
99

1010
schemes = (
1111
Flat,
12-
Linear,
12+
Line,
1313
Reflect,
1414
Periodic
1515
)
@@ -22,7 +22,7 @@ end
2222
g(y) = (y/100)^3
2323
yinds = 2:5
2424
A = OffsetArray(Float64[f(x)*g(y) for x in xinds, y in yinds], xinds, yinds)
25-
itp2 = interpolate(A, BSpline(Linear()), OnGrid())
25+
itp2 = interpolate(A, BSpline(Linear()))
2626

2727
for (etp2,E) in map(E -> (extrapolate(itp2, E()), E), schemes)
2828
@test parent(etp2) === itp2

0 commit comments

Comments
 (0)