Skip to content

Commit a0e9520

Browse files
authored
Merge pull request #385 from mkitti/master
Fix testing issues on Julia nightly (1.6)
2 parents 4913d3b + 5bf0b3a commit a0e9520

File tree

1 file changed

+46
-24
lines changed

1 file changed

+46
-24
lines changed

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)