rafaqz / DimensionalData.jl

Named dimensions and indexing for julia arrays and other data
https://rafaqz.github.io/DimensionalData.jl/stable/
MIT License
262 stars 38 forks source link

add title to DimArray #692

Open lazarusA opened 2 months ago

lazarusA commented 2 months ago

Add a title to the DimArray would be nice.

A = DimArray(rand(4,5), (a=1:4, b=1:5)) ╭─────────────────────────╮ │ 4×5 DimArray{Float64,2} │ >>It should be outset this box>TITLE FOR ARRAY/ DATASET-> Default A, but with a karg. ├─────────────────────────┴─────────────────────── dims ┐ ↓ a Sampled{Int64} 1:4 ForwardOrdered Regular Points, → b Sampled{Int64} 1:5 ForwardOrdered Regular Points └───────────────────────────────────────────────────────┘ ↓ → 1 2 3 4 5 1 0.424074 0.593846 0.940429 0.322598 0.889187 2 0.697233 0.213045 0.164312 0.269279 0.44907 3 0.601732 0.267198 0.967271 0.882953 0.97872 4 0.407274 0.0280848 0.619313 0.14258 0.886049

rafaqz commented 2 months ago

By title do you mean name(A) like we have now?

julia> A = DimArray(rand(4,5), (a=1:4, b=1:5); name=:title)
╭───────────────────────────────╮
│ 4×5 DimArray{Float64,2} title │
├───────────────────────────────┴───────────────── dims ┐
  ↓ a Sampled{Int64} 1:4 ForwardOrdered Regular Points,
  → b Sampled{Int64} 1:5 ForwardOrdered Regular Points
└───────────────────────────────────────────────────────┘
 ↓ →  1         2         3          4         5
 1    0.661617  0.770108  0.575509   0.868416  0.521379
 2    0.812634  0.667707  0.417909   0.623842  0.0260108
 3    0.200963  0.785179  0.0195309  0.250583  0.255492
 4    0.823116  0.112858  0.097574   0.029063  0.403353

But yes it could be in a better spot. One issue is sometimes if the eltype is huge the box goes to the full width of the screen and the line joins with the edge of the dims box.

But I think this looks good:

julia> A = DimArray(rand(4,5), (a=1:4, b=1:5); name=:title)
╭──────────────────────────╮
│ 4×5 DimArray{Float64,2}  │ title
├──────────────────────────┴────────────────────── dims ┐
  ↓ a Sampled{Int64} 1:4 ForwardOrdered Regular Points,
  → b Sampled{Int64} 1:5 ForwardOrdered Regular Points
└───────────────────────────────────────────────────────┘
 ↓ →  1         2         3          4         5
 1    0.661617  0.770108  0.575509   0.868416  0.521379
 2    0.812634  0.667707  0.417909   0.623842  0.0260108
 3    0.200963  0.785179  0.0195309  0.250583  0.255492
 4    0.823116  0.112858  0.097574   0.029063  0.403353

This not so much:

julia> A = DimArray(rand(4,5), (a=1:4, b=1:5); name=:title)
╭──────────────────────────╮
│ 4×5 DimArray{Float64,2}  │ 
│ title                    │ 
├──────────────────────────┴────────────────────── dims ┐
  ↓ a Sampled{Int64} 1:4 ForwardOrdered Regular Points,
  → b Sampled{Int64} 1:5 ForwardOrdered Regular Points
└───────────────────────────────────────────────────────┘
 ↓ →  1         2         3          4         5
 1    0.661617  0.770108  0.575509   0.868416  0.521379
 2    0.812634  0.667707  0.417909   0.623842  0.0260108
 3    0.200963  0.785179  0.0195309  0.250583  0.255492
 4    0.823116  0.112858  0.097574   0.029063  0.403353

Also its green in the REPL so stands out a bit more.

lazarusA commented 2 months ago

this positioning, I do like:

julia> A = DimArray(rand(4,5), (a=1:4, b=1:5); name=:title)
╭──────────────────────────╮
│ 4×5 DimArray{Float64,2}  │ title
├──────────────────────────┴────────────────────── dims ┐
  ↓ a Sampled{Int64} 1:4 ForwardOrdered Regular Points,
  → b Sampled{Int64} 1:5 ForwardOrdered Regular Points
└───────────────────────────────────────────────────────┘
 ↓ →  1         2         3          4         5
 1    0.661617  0.770108  0.575509   0.868416  0.521379
 2    0.812634  0.667707  0.417909   0.623842  0.0260108
 3    0.200963  0.785179  0.0195309  0.250583  0.255492
 4    0.823116  0.112858  0.097574   0.029063  0.403353
rafaqz commented 2 months ago

Yeah its more obviously a separate thing