262
262
@test d == c == StructArray (a= [1 ,10 ,2 ,3 ], b= [2 ,20 ,3 ,4 ], c= [" a" ," A" ," b" ," c" ])
263
263
d = deleteat! (c, 2 )
264
264
@test d == c == StructArray (a= [1 ,2 ,3 ], b= [2 ,3 ,4 ], c= [" a" ," b" ," c" ])
265
- if Base. VERSION >= v " 1.7.0"
266
- d = keepat! (c, 2 )
267
- @test d == c == StructArray (a= [2 ], b= [3 ], c= [" b" ])
268
- end
265
+ d = keepat! (c, 2 )
266
+ @test d == c == StructArray (a= [2 ], b= [3 ], c= [" b" ])
269
267
270
268
c = StructArray (a= [1 ], b= [2 ], c= [" a" ])
271
269
d = [(a= 10 , b= 20 , c= " A" )]
302
300
@test d == c == StructArray {C} (a= [1 ,10 ,2 ,3 ], b= [2 ,20 ,3 ,4 ], c= [" a" ," A" ," b" ," c" ])
303
301
d = deleteat! (c, 2 )
304
302
@test d == c == StructArray {C} (a= [1 ,2 ,3 ], b= [2 ,3 ,4 ], c= [" a" ," b" ," c" ])
305
- if Base. VERSION >= v " 1.7.0"
306
- d = keepat! (c, 2 )
307
- @test d == c == StructArray {C} (a= [2 ], b= [3 ], c= [" b" ])
308
- end
303
+ d = keepat! (c, 2 )
304
+ @test d == c == StructArray {C} (a= [2 ], b= [3 ], c= [" b" ])
309
305
310
306
c = StructArray {C} (a= [1 ], b= [2 ], c= [" a" ])
311
307
d = [C (10 , 20 , " A" )]
@@ -495,14 +491,12 @@ end
495
491
end
496
492
497
493
@testset " constructor from slices" begin
498
- if VERSION >= v " 1.1"
499
- X = [1.0 2.0 ; 3.0 4.0 ]
500
- @test StructArray {Complex{Float64}} (X; dims= 1 ) == [Complex (1.0 ,3.0 ), Complex (2.0 ,4.0 )]
501
- @test StructArray {Complex{Float64}} (X; dims= 2 ) == [Complex (1.0 ,2.0 ), Complex (3.0 ,4.0 )]
494
+ X = [1.0 2.0 ; 3.0 4.0 ]
495
+ @test StructArray {Complex{Float64}} (X; dims= 1 ) == [Complex (1.0 ,3.0 ), Complex (2.0 ,4.0 )]
496
+ @test StructArray {Complex{Float64}} (X; dims= 2 ) == [Complex (1.0 ,2.0 ), Complex (3.0 ,4.0 )]
502
497
503
- X = [1.0 2.0 ; 3.0 4.0 ; 5.0 6.0 ]
504
- @test StructArray {Tuple{Float64,Complex{Float64}}} (X; dims= 1 ) == [(1.0 ,Complex (3.0 ,5.0 )), (2.0 , Complex (4.0 ,6.0 ))]
505
- end
498
+ X = [1.0 2.0 ; 3.0 4.0 ; 5.0 6.0 ]
499
+ @test StructArray {Tuple{Float64,Complex{Float64}}} (X; dims= 1 ) == [(1.0 ,Complex (3.0 ,5.0 )), (2.0 , Complex (4.0 ,6.0 ))]
506
500
end
507
501
508
502
struct A
@@ -1111,19 +1105,11 @@ end
1111
1105
io = IOBuffer ()
1112
1106
Base. showarg (io, rows, true )
1113
1107
str = String (take! (io))
1114
- if VERSION < v " 1.6-"
1115
- @test str == " LazyRows(::Array{Float64,2}, ::Array{Float64,2}) with eltype LazyRow{Complex{Float64}}"
1116
- else
1117
- @test str == " LazyRows(::Matrix{Float64}, ::Matrix{Float64}) with eltype LazyRow{ComplexF64}"
1118
- end
1108
+ @test str == " LazyRows(::Matrix{Float64}, ::Matrix{Float64}) with eltype LazyRow{ComplexF64}"
1119
1109
io = IOBuffer ()
1120
1110
Base. showarg (io, rows, false )
1121
1111
str = String (take! (io))
1122
- if VERSION < v " 1.6-"
1123
- @test str == " LazyRows(::Array{Float64,2}, ::Array{Float64,2})"
1124
- else
1125
- @test str == " LazyRows(::Matrix{Float64}, ::Matrix{Float64})"
1126
- end
1112
+ @test str == " LazyRows(::Matrix{Float64}, ::Matrix{Float64})"
1127
1113
s = StructArray ((rand (10 , 10 ), rand (10 , 10 )))
1128
1114
rows = LazyRows (s)
1129
1115
@test IndexStyle (rows) isa IndexLinear
@@ -1143,19 +1129,11 @@ end
1143
1129
io = IOBuffer ()
1144
1130
Base. showarg (io, rows, true )
1145
1131
str = String (take! (io))
1146
- if VERSION < v " 1.6-"
1147
- @test str == " LazyRows(::Array{Float64,2}, ::Array{Float64,2}) with eltype LazyRow{Tuple{Float64,Float64}}"
1148
- else
1149
- @test str == " LazyRows(::Matrix{Float64}, ::Matrix{Float64}) with eltype LazyRow{Tuple{Float64, Float64}}"
1150
- end
1132
+ @test str == " LazyRows(::Matrix{Float64}, ::Matrix{Float64}) with eltype LazyRow{Tuple{Float64, Float64}}"
1151
1133
io = IOBuffer ()
1152
1134
Base. showarg (io, rows, false )
1153
1135
str = String (take! (io))
1154
- if VERSION < v " 1.6-"
1155
- @test str == " LazyRows(::Array{Float64,2}, ::Array{Float64,2})"
1156
- else
1157
- @test str == " LazyRows(::Matrix{Float64}, ::Matrix{Float64})"
1158
- end
1136
+ @test str == " LazyRows(::Matrix{Float64}, ::Matrix{Float64})"
1159
1137
end
1160
1138
1161
1139
@testset " refarray" begin
@@ -1185,19 +1163,11 @@ end
1185
1163
io = IOBuffer ()
1186
1164
Base. showarg (io, s, true )
1187
1165
str = String (take! (io))
1188
- if VERSION < v " 1.6-"
1189
- @test str == " StructArray(::Array{Int64,1}, ::Array{Int64,1}) with eltype Complex{Int64}"
1190
- else
1191
- @test str == " StructArray(::Vector{Int64}, ::Vector{Int64}) with eltype Complex{Int64}"
1192
- end
1166
+ @test str == " StructArray(::Vector{Int64}, ::Vector{Int64}) with eltype Complex{Int64}"
1193
1167
io = IOBuffer ()
1194
1168
Base. showarg (io, s, false )
1195
1169
str = String (take! (io))
1196
- if VERSION < v " 1.6-"
1197
- @test str == " StructArray(::Array{Int64,1}, ::Array{Int64,1})"
1198
- else
1199
- @test str == " StructArray(::Vector{Int64}, ::Vector{Int64})"
1200
- end
1170
+ @test str == " StructArray(::Vector{Int64}, ::Vector{Int64})"
1201
1171
end
1202
1172
1203
1173
@testset " append!!" begin
@@ -1474,7 +1444,7 @@ end
1474
1444
t = map (x -> (a= rand ([" " , 1 , nothing ]),), StructVector (a= 1 : 10 )):: StructVector
1475
1445
@test eltype (t) <: NamedTuple{(:a,)}
1476
1446
1477
- t = VERSION >= v " 1.7 " ? @inferred ( map (x -> (a = x . a, b = 2 ), s)) : map (x -> (a= x. a, b= 2 ), s)
1447
+ t = @inferred map (x -> (a= x. a, b= 2 ), s)
1478
1448
@test t isa StructArray
1479
1449
@test map (x -> (a= x. a, b= 2 ), s) == [(a= 1 , b= 2 ), (a= 2 , b= 2 ), (a= 3 , b= 2 )]
1480
1450
0 commit comments