Skip to content

Commit

Permalink
v0.1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Abbott committed Nov 28, 2020
1 parent 26ecdbe commit e991b7b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 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.7"
version = "0.1.8"

[deps]
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
Expand Down
10 changes: 5 additions & 5 deletions src/names.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ If there are duplicate names or unnamed axes, an error is thrown.
```jldoctest
julia> using AxisKeys
julia> arr = KeyedArray([1 2], x=[1], y=[2,3]);
julia> arr = KeyedArray(rand(1,3), x=[1], y=[2,3,4]);
julia> named_axiskeys(arr)
(x = [1], y = [2, 3])
(x = [1], y = [2, 3, 4])
```
"""
function named_axiskeys(arr)::NamedTuple
NT = NamedTuple{dimnames(arr)}
return NT(axiskeys(arr))
function named_axiskeys(A::AbstractArray)
NT = NamedTuple{dimnames(A)}
NT(axiskeys(A))
end
27 changes: 13 additions & 14 deletions test/_basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,7 @@ using Test, AxisKeys
@test_throws Exception wrapdims(rand(5), ['a','b','c'])
@test_throws Exception KeyedArray(rand(5), ['a','b','c'])

@testset "named_axiskeys" begin
arr = KeyedArray(randn(2,3), a=1:2, b=1:3)
@inferred named_axiskeys(arr)
@test named_axiskeys(arr) === (a=1:2, b=1:3)
@test Tuple(named_axiskeys(arr)) === axiskeys(arr)

nonames = KeyedArray(randn(2,3), (1:2, 1:3))
@test_throws ErrorException named_axiskeys(nonames)

v = KeyedArray(randn(3), x=1:3)
dupnames = v .+ v'
@test_throws ErrorException named_axiskeys(dupnames)
end
end

@testset "selectors" begin

V = wrapdims(rand(Int8, 11), 0:0.1:1)
Expand Down Expand Up @@ -182,6 +168,19 @@ end
@test_throws Exception N(obs='z') # ideally BoundsError
end

@testset "named_axiskeys" begin
arr = wrapdims(randn(2,3), a=1:2, b='a':'c')
@inferred named_axiskeys(arr)
@test named_axiskeys(arr) === (a=1:2, b='a':'c')
@test Tuple(named_axiskeys(arr)) === axiskeys(arr)

nonames = KeyedArray(randn(2,3), (1:2, 'a':'c'))
@test_throws ErrorException named_axiskeys(nonames)

v = wrapdims(randn(3), x=1:3)
@test_throws ErrorException named_axiskeys(v .+ v') # duplicate names
end

end
@testset "broadcasting" begin
using Base: OneTo
Expand Down

2 comments on commit e991b7b

@mcabbott
Copy link
Owner

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/25450

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.8 -m "<description of version>" e991b7bd40c92024a033ae46261e8c1ccbeb2ab8
git push origin v0.1.8

Please sign in to comment.