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 `name` keyword to various `DimArray` constructors #750

Open haakon-e opened 1 week ago

haakon-e commented 1 week ago

Currently, you can do

a = zeros(X(1:3), Y(1:2), name="hi")
# prints
╭────────────────────────────╮
│ 3×2 DimArray{Float64,2} hi │
├────────────────────────────┴──────────────────── dims ┐
  ↓ X Sampled{Int64} 1:3 ForwardOrdered Regular Points,
  → Y Sampled{Int64} 1:2 ForwardOrdered Regular Points
└───────────────────────────────────────────────────────┘
 ↓ →  1    2
 1    0.0  0.0
 2    0.0  0.0
 3    0.0  0.0

but not

similar(a, name="hello")

maybe there's other instances too that I can track down and patch. I'll try and add a PR if this seems reasonable.

rafaqz commented 1 week ago

Ah maybe similar missed out on keywords back then, most other constructor methods e.g. rand/fill got them.

Feel free to add them.