Hi all, I’m currently using AxisArrays
to store array-like data, while giving some sense to the dimension names and with type parameters so that my type remains generic enough. This is super practical, but whenever I print data to the REPL, I get very long names due to the generic printing done by AxisArrays
.
I figured I could define my own show methods for my type, but it gets cumbersome very fast.
Here is a toy example
MyArray{T,M,VI} = AxisArrays.AxisMatrix{T,M,Tuple{AxisArrays.Axis{:x,VI},AxisArrays.Axis{:y,Vector{Symbol}}}} where {T<:Number,M<:AbstractMatrix{T},VI<:AbstractVector{<:Integer}}
I have as well secondary aliases as
MyArrayReal = MyArray{T,M,VI} where {T<:Real,M<:AbstractMatrix{T},VI<:AbstractVector{<:Integer}}
MyArrayComplex = MyArray{T,M,VI} where {T<:Complex,M<:AbstractMatrix{T},VI<:AbstractVector{<:Integer}}
To have this printed in the REPL in a shorter manner, I implemented a custom show
method with
show(io::IO, m::MIME"text/plain", ::Type{MyArray{T,M,VI}}) where {T<:Number,M<:AbstractMatrix{T},VI<:AbstractVector{<:Integer}} = println(io, "MyArray{$T,$M,$VI}")
but that fails easily one I used arrays of MyArray
…
What would be a better way to leverage AxisArrays
functionnality, while maintaining a light printing of the type ?