using StructArrays
test1 = StructArray{NamedTuple{(:a, :b), NTuple{2, Float32}}}((a=[0f0,0f0,1f0,1f0,2f0,2f0,2f0],b=[0f0,0f0,0f0,0f0,0f0,0f0,0f0]))
7-element StructArray(::Vector{Float32}, ::Vector{Float32}) with eltype NamedTuple{(:a, :b), Tuple{Float32, Float32}}:
(a = 0.0, b = 0.0)
(a = 0.0, b = 0.0)
(a = 1.0, b = 0.0)
(a = 1.0, b = 0.0)
(a = 2.0, b = 0.0)
(a = 2.0, b = 0.0)
(a = 2.0, b = 0.0)
test2 = StructArray{NamedTuple{(:a, :b), NTuple{2, Float32}}}((a=[0,0,1,1,2,2,2],b=[0,0,0,0,0,0,0]))
7-element StructArray(::Vector{Int64}, ::Vector{Int64}) with eltype NamedTuple{(:a, :b), Tuple{Float32, Float32}}:
(a = 0.0, b = 0.0)
(a = 0.0, b = 0.0)
(a = 1.0, b = 0.0)
(a = 1.0, b = 0.0)
(a = 2.0, b = 0.0)
(a = 2.0, b = 0.0)
(a = 2.0, b = 0.0)
typeof(test1)
StructVector{NamedTuple{(:a, :b), Tuple{Float32, Float32}}, NamedTuple{(:a, :b), Tuple{Vector{Float32}, Vector{Float32}}}, Int64} (alias for StructArray{NamedTuple{(:a, :b), Tuple{Float32, Float32}}, 1, NamedTuple{(:a, :b), Tuple{Array{Float32, 1}, Array{Float32, 1}}}, Int64})
typeof(test2)
StructVector{NamedTuple{(:a, :b), Tuple{Float32, Float32}}, NamedTuple{(:a, :b), Tuple{Vector{Int64}, Vector{Int64}}}, Int64} (alias for StructArray{NamedTuple{(:a, :b), Tuple{Float32, Float32}}, 1, NamedTuple{(:a, :b), Tuple{Array{Int64, 1}, Array{Int64, 1}}}, Int64})
I thought that for both the element type is given explicitly, so why is the type of ttt1 and ttt2 different? That seems weird, I would either expect the elements of test2.a and test2.b to be interpreted as Float32 OR giving an error upon construction of test2. Any hints? Thanks.