@@ -252,19 +252,19 @@ collect_structarray_rec(t) = StructArrays.collect_structarray(t, initializer = i
252
252
253
253
v = [(a = 1 , b = 2 ), (a = 1.2 , b = 3 )]
254
254
@test collect_structarray_rec (v) == StructArray ((a = [1 , 1.2 ], b = Int[2 , 3 ]))
255
- @test typeof (collect_structarray_rec (v)) == typeof (StructArray ((a = [1 , 1.2 ], b = Int[2 , 3 ])))
255
+ @test typeof (collect_structarray_rec (v)) == typeof (StructArray ((a = Real [1 , 1.2 ], b = Int[2 , 3 ])))
256
256
257
257
s = StructArray (a = [1 , 2 ], b = [3 , 4 ])
258
258
@test StructArrays. collect_structarray (LazyRow (s, i) for i in eachindex (s)) == s
259
259
@test collect_structarray_rec (LazyRow (s, i) for i in eachindex (s)) == s
260
260
261
261
v = [(a = 1 , b = 2 ), (a = 1.2 , b = " 3" )]
262
262
@test collect_structarray_rec (v) == StructArray ((a = [1 , 1.2 ], b = Any[2 , " 3" ]))
263
- @test typeof (collect_structarray_rec (v)) == typeof (StructArray ((a = [1 , 1.2 ], b = Any[2 , " 3" ])))
263
+ @test typeof (collect_structarray_rec (v)) == typeof (StructArray ((a = Real [1 , 1.2 ], b = Any[2 , " 3" ])))
264
264
265
265
v = [(a = 1 , b = 2 ), (a = 1.2 , b = 2 ), (a = 1 , b = " 3" )]
266
- @test collect_structarray_rec (v) == StructArray ((a = [1 , 1.2 , 1 ], b = Any[2 , 2 , " 3" ]))
267
- @test typeof (collect_structarray_rec (v)) == typeof (StructArray ((a = [1 , 1.2 , 1 ], b = Any[2 , 2 , " 3" ])))
266
+ @test collect_structarray_rec (v) == StructArray ((a = Real [1 , 1.2 , 1 ], b = Any[2 , 2 , " 3" ]))
267
+ @test typeof (collect_structarray_rec (v)) == typeof (StructArray ((a = Real [1 , 1.2 , 1 ], b = Any[2 , 2 , " 3" ])))
268
268
269
269
# length unknown
270
270
itr = Iterators. filter (isodd, 1 : 8 )
@@ -292,21 +292,21 @@ end
292
292
@inferred StructArrays. collect_structarray (v)
293
293
294
294
v = [(1 , 2 ), (1.2 , 3 )]
295
- @test collect_structarray_rec (v) == StructArray (([1 , 1.2 ], Int[2 , 3 ]))
295
+ @test collect_structarray_rec (v) == StructArray ((Real [1 , 1.2 ], Int[2 , 3 ]))
296
296
297
297
v = [(1 , 2 ), (1.2 , " 3" )]
298
- @test collect_structarray_rec (v) == StructArray (([1 , 1.2 ], Any[2 , " 3" ]))
299
- @test typeof (collect_structarray_rec (v)) == typeof (StructArray (([1 , 1.2 ], Any[2 , " 3" ])))
298
+ @test collect_structarray_rec (v) == StructArray ((Real [1 , 1.2 ], Any[2 , " 3" ]))
299
+ @test typeof (collect_structarray_rec (v)) == typeof (StructArray ((Real [1 , 1.2 ], Any[2 , " 3" ])))
300
300
301
301
v = [(1 , 2 ), (1.2 , 2 ), (1 , " 3" )]
302
- @test collect_structarray_rec (v) == StructArray (([1 , 1.2 , 1 ], Any[2 , 2 , " 3" ]))
302
+ @test collect_structarray_rec (v) == StructArray ((Real [1 , 1.2 , 1 ], Any[2 , 2 , " 3" ]))
303
303
# length unknown
304
304
itr = Iterators. filter (isodd, 1 : 8 )
305
305
tuple_itr = ((i+ 1 , i- 1 ) for i in itr)
306
306
@test collect_structarray_rec (tuple_itr) == StructArray (([2 , 4 , 6 , 8 ], [0 , 2 , 4 , 6 ]))
307
307
tuple_itr_real = (i == 1 ? (1.2 , i- 1 ) : (i+ 1 , i- 1 ) for i in itr)
308
- @test collect_structarray_rec (tuple_itr_real) == StructArray (([1.2 , 4 , 6 , 8 ], [0 , 2 , 4 , 6 ]))
309
- @test typeof (collect_structarray_rec (tuple_itr_real)) == typeof (StructArray (([1.2 , 4 , 6 , 8 ], [0 , 2 , 4 , 6 ])))
308
+ @test collect_structarray_rec (tuple_itr_real) == StructArray ((Real [1.2 , 4 , 6 , 8 ], [0 , 2 , 4 , 6 ]))
309
+ @test typeof (collect_structarray_rec (tuple_itr_real)) == typeof (StructArray ((Real [1.2 , 4 , 6 , 8 ], [0 , 2 , 4 , 6 ])))
310
310
311
311
# empty
312
312
itr = Iterators. filter (t -> t > 10 , 1 : 8 )
330
330
@test collect_structarray_rec (itr) == collect (itr)
331
331
real_itr = (i == 1 ? 1.5 : i for i in itr)
332
332
@test collect_structarray_rec (real_itr) == collect (real_itr)
333
- @test eltype (collect_structarray_rec (real_itr)) == Float64
333
+ @test eltype (collect_structarray_rec (real_itr)) == Real
334
334
335
335
# empty
336
336
itr = Iterators. filter (t -> t > 10 , 1 : 8 )
352
352
@test eltype (collect_structarray_rec (v)) == Pair{Int, Int}
353
353
354
354
v = (i == 1 ? (1.2 => i+ 1 ) : (i => i+ 1 ) for i in 1 : 3 )
355
- @test collect_structarray_rec (v) == StructArray {Pair{Float64 , Int}} ([1.2 ,2 ,3 ], [2 ,3 ,4 ])
356
- @test eltype (collect_structarray_rec (v)) == Pair{Float64 , Int}
355
+ @test collect_structarray_rec (v) == StructArray {Pair{Real , Int}} ([1.2 ,2 ,3 ], [2 ,3 ,4 ])
356
+ @test eltype (collect_structarray_rec (v)) == Pair{Real , Int}
357
357
358
358
v = ((a= i,) => (b= " a$i " ,) for i in 1 : 3 )
359
359
@test collect_structarray_rec (v) == StructArray{Pair{NamedTuple{(:a ,),Tuple{Int64}},NamedTuple{(:b ,),Tuple{String}}}}(StructArray ((a = [1 ,2 ,3 ],)), StructArray ((b = [" a1" ," a2" ," a3" ],)))
0 commit comments