Skip to content

Commit

Permalink
Merge pull request #52 from oxinabox/ox/rname
Browse files Browse the repository at this point in the history
Add rename
  • Loading branch information
mcabbott authored Mar 3, 2021
2 parents fac28cb + c01c6c8 commit 7caa53a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
3 changes: 2 additions & 1 deletion src/AxisKeys.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/names.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions test/_basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

2 comments on commit 7caa53a

@mcabbott
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/31201

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.13 -m "<description of version>" 7caa53a984bb4d06200859a4b47b1373c49cc006
git push origin v0.1.13

Please sign in to comment.