Is it possible to add a property to a StructArray?
The following code fails:
julia> using KiteUtils, StructArrays
julia> syslog=demo_syslog(7)
julia> function Base.getproperty(st::StructArray{SysState}, sym::Symbol)
if sym == :x
last.getfield(st, :X)
elseif sym == :y
last.getfield(st, :Y)
elseif sym == :z
last.getfield(st, :Z) # last.(st.Z)
else
getfield(st, sym)
end
end
julia> syslog.z
ERROR: type NamedTuple has no field z
Stacktrace:
[1] component
@ ~/.julia/packages/StructArrays/MdA9B/src/structarray.jl:307 [inlined]
[2] getproperty(s::StructArrays.StructVector{SysState{7}, NamedTuple{(:time, :orient, :elevation, :azimuth, :l_tether, :v_reelout, :force, :depower, :v_app, :X, :Y, :Z), Tuple{Vector{Float64}, Vector{StaticArrays.MVector{4, Float32}}, Vector{Float64}, Vector{Float32}, Vector{Float32}, Vector{Float32}, Vector{Float32}, Vector{Float32}, Vector{Float32}, Vector{StaticArrays.MVector{7, Float32}}, Vector{StaticArrays.MVector{7, Float32}}, Vector{StaticArrays.MVector{7, Float32}}}}, Int64}, key::Symbol)
@ StructArrays ~/.julia/packages/StructArrays/MdA9B/src/structarray.jl:309
[3] top-level scope
@ REPL[6]:1
Additional info:
julia> typeof(syslog)
StructVector{SysState{7}, NamedTuple{(:time, :orient, :elevation, :azimuth, :l_tether, :v_reelout, :force, :depower, :v_app, :X, :Y, :Z), Tuple{Vector{Float64}, Vector{MVector{4, Float32}}, Vector{Float64}, Vector{Float32}, Vector{Float32}, Vector{Float32}, Vector{Float32}, Vector{Float32}, Vector{Float32}, Vector{MVector{7, Float32}}, Vector{MVector{7, Float32}}, Vector{MVector{7, Float32}}}}, Int64} (alias for StructArrays.StructArray{SysState{7}, 1, NamedTuple{(:time, :orient, :elevation, :azimuth, :l_tether, :v_reelout, :force, :depower, :v_app, :X, :Y, :Z), Tuple{Array{Float64, 1}, Array{StaticArrays.MArray{Tuple{4}, Float32, 1, 4}, 1}, Array{Float64, 1}, Array{Float32, 1}, Array{Float32, 1}, Array{Float32, 1}, Array{Float32, 1}, Array{Float32, 1}, Array{Float32, 1}, Array{StaticArrays.MArray{Tuple{7}, Float32, 1, 7}, 1}, Array{StaticArrays.MArray{Tuple{7}, Float32, 1, 7}, 1}, Array{StaticArrays.MArray{Tuple{7}, Float32, 1, 7}, 1}}}, Int64})
Any idea?