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

Add `rekey` method

Open rofinn opened this issue 4 years ago • 1 comments

It's kind of annoying needing to reconstruct a KeyedArray every time you want to replace the keys in an array. I was thinking that we could do something similar to rename:

rekey(ka, (key1, key2, ...))
rekey(ka, dim1 => key1)

Maybe also:

rekey(ka, dim1 => (newdim, key1))

To do a rename and rekey in one operation?

NOTE: We're already doing a version of this in AxisSets.jl, but it'd be nice if we could just extend a method here.

rofinn avatar Apr 21 '21 18:04 rofinn

Sounds good. Unlike rename, there's no confusion which way the arrow goes, so rekey(ka; dim1=kv1) would also be OK.

mcabbott avatar Apr 21 '21 21:04 mcabbott