@@ -420,34 +420,36 @@ end
420420 @test isequal (StructArrays. fieldarrays (t)[1 ], [1 , missing , 3 ])
421421end
422422
423+ pair_structarray ((first, last)) = StructArray {Pair{eltype(first), eltype(last)}} ((first, last))
424+
423425@testset " collectpairs" begin
424426 v = (i=> i+ 1 for i in 1 : 3 )
425- @test collect_structarray_rec (v) == StructArray {Pair{Int, Int}} (( [1 ,2 ,3 ], [2 ,3 ,4 ]) )
427+ @test collect_structarray_rec (v) == pair_structarray ( [1 ,2 ,3 ] => [2 ,3 ,4 ])
426428 @test eltype (collect_structarray_rec (v)) == Pair{Int, Int}
427429
428430 v = (i == 1 ? (1.2 => i+ 1 ) : (i => i+ 1 ) for i in 1 : 3 )
429- @test collect_structarray_rec (v) == StructArray {Pair{Real, Int}} (( [1.2 ,2 ,3 ], [2 ,3 ,4 ]) )
431+ @test collect_structarray_rec (v) == pair_structarray ( [1.2 ,2 ,3 ] => [2 ,3 ,4 ])
430432 @test eltype (collect_structarray_rec (v)) == Pair{Real, Int}
431433
432434 v = ((a= i,) => (b= " a$i " ,) for i in 1 : 3 )
433- @test collect_structarray_rec (v) == StructArray (StructArray ((a = [1 ,2 ,3 ],)) => StructArray ((b = [" a1" ," a2" ," a3" ],)))
435+ @test collect_structarray_rec (v) == pair_structarray (StructArray ((a = [1 ,2 ,3 ],)) => StructArray ((b = [" a1" ," a2" ," a3" ],)))
434436 @test eltype (collect_structarray_rec (v)) == Pair{NamedTuple{(:a ,), Tuple{Int64}}, NamedTuple{(:b ,), Tuple{String}}}
435437
436438 v = (i == 1 ? (a= " 1" ,) => (b= " a$i " ,) : (a= i,) => (b= " a$i " ,) for i in 1 : 3 )
437- @test collect_structarray_rec (v) == StructArray (StructArray ((a = [" 1" ,2 ,3 ],)) => StructArray ((b = [" a1" ," a2" ," a3" ],)))
439+ @test collect_structarray_rec (v) == pair_structarray (StructArray ((a = [" 1" ,2 ,3 ],)) => StructArray ((b = [" a1" ," a2" ," a3" ],)))
438440 @test eltype (collect_structarray_rec (v)) == Pair{NamedTuple{(:a ,), Tuple{Any}}, NamedTuple{(:b ,), Tuple{String}}}
439441
440442 # empty
441443 v = ((a= i,) => (b= " a$i " ,) for i in 0 : - 1 )
442- @test collect_structarray_rec (v) == StructArray (StructArray ((a = Int[],)) => StructArray ((b = String[],)))
444+ @test collect_structarray_rec (v) == pair_structarray (StructArray ((a = Int[],)) => StructArray ((b = String[],)))
443445 @test eltype (collect_structarray_rec (v)) == Pair{NamedTuple{(:a ,), Tuple{Int}}, NamedTuple{(:b ,), Tuple{String}}}
444446
445447 v = Iterators. filter (t -> t. first. a == 4 , ((a= i,) => (b= " a$i " ,) for i in 1 : 3 ))
446- @test collect_structarray_rec (v) == StructArray (StructArray ((a = Int[],)) => StructArray ((b = String[],)))
448+ @test collect_structarray_rec (v) == pair_structarray (StructArray ((a = Int[],)) => StructArray ((b = String[],)))
447449 @test eltype (collect_structarray_rec (v)) == Pair{NamedTuple{(:a ,), Tuple{Int}}, NamedTuple{(:b ,), Tuple{String}}}
448450
449451 t = collect_structarray_rec ((b = 1 ,) => (a = i,) for i in (2 , missing , 3 ))
450- s = StructArray (StructArray (b = [1 ,1 ,1 ]) => StructArray (a = [2 , missing , 3 ]))
452+ s = pair_structarray (StructArray (b = [1 ,1 ,1 ]) => StructArray (a = [2 , missing , 3 ]))
451453 @test s[1 ] == t[1 ]
452454 @test ismissing (t[2 ]. second. a)
453455 @test s[3 ] == t[3 ]
0 commit comments