diff --git a/Project.toml b/Project.toml index e63d08b..d0d6242 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "AxisKeys" uuid = "94b1ba4f-4ee9-5380-92f1-94cde586c3c5" license = "MIT" -version = "0.1.12" +version = "0.1.13" [deps] AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c" diff --git a/src/AxisKeys.jl b/src/AxisKeys.jl index 5f4c45f..0120b2d 100644 --- a/src/AxisKeys.jl +++ b/src/AxisKeys.jl @@ -6,7 +6,8 @@ export KeyedArray, axiskeys include("lookup.jl") include("names.jl") -export NamedDimsArray, dimnames, named_axiskeys +export named_axiskeys +export NamedDimsArray, dimnames, rename # Reexport key NamedDimsArrays things include("wrap.jl") export wrapdims diff --git a/src/names.jl b/src/names.jl index df1789e..697915e 100644 --- a/src/names.jl +++ b/src/names.jl @@ -18,6 +18,8 @@ NamedDims.dim(A::KaNda{L}, name) where {L} = NamedDims.dim(L, name) Base.axes(A::KaNda{L}, s::Symbol) where {L} = axes(A, NamedDims.dim(L,s)) Base.size(A::KaNda{L,T,N}, s::Symbol) where {T,N,L} = size(A, NamedDims.dim(L,s)) +NamedDims.rename(A::KaNda, names...) = KeyedArray(rename(parent(A), names...), axiskeys(A)) + # Extra complication to make wrappers commutative: hasnames(A::KaNda) = true diff --git a/test/_basic.jl b/test/_basic.jl index a92da36..664718b 100644 --- a/test/_basic.jl +++ b/test/_basic.jl @@ -175,6 +175,9 @@ end @test named_axiskeys(arr) === (a=1:2, b='a':'c') @test Tuple(named_axiskeys(arr)) === axiskeys(arr) + @test named_axiskeys(rename(arr, :a=>:x)) == (x=1:2, b='a':'c') + @test named_axiskeys(rename(arr, (:y, :z))) == (y=1:2, z='a':'c') + nonames = KeyedArray(randn(2,3), (1:2, 'a':'c')) @test_throws ErrorException named_axiskeys(nonames)