StaticArrays.jl icon indicating copy to clipboard operation
StaticArrays.jl copied to clipboard

`FieldArray` could display better

Open danielwe opened this issue 2 years ago • 1 comments

A FieldArray displays as an array, values only. It would be great if it showed the field names too---named fields are presumably the reason to use a FieldArray in the first place.

julia> using StaticArrays

julia> Base.@kwdef struct Foo <: FieldVector{2,Float64}
           bar::Float64
           baz::Float64
       end
Foo

julia> Foo(bar=3.0, baz=5.0)
2-element Foo with indices SOneTo(2):
 3.0
 5.0

Compare LabelledArrays.jl:

julia> using LabelledArrays

julia> SLVector(bar=3.0, baz=5.0)
2-element SLArray{Tuple{2}, Float64, 1, 2, (:bar, :baz)} with indices SOneTo(2):
 :bar => 3.0
 :baz => 5.0

danielwe avatar Dec 05 '23 19:12 danielwe

I would vote for something closer to NamedTuple display, i.e. display as something like:

julia> Foo(bar=3.0, baz=5.0)
2-element Foo with indices SOneTo(2):
 bar = 3.0
 baz = 5.0

stevengj avatar Dec 05 '23 19:12 stevengj