Skip to content

Commit e991b7b

Browse files
author
Michael Abbott
committed
v0.1.8
1 parent 26ecdbe commit e991b7b

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "AxisKeys"
22
uuid = "94b1ba4f-4ee9-5380-92f1-94cde586c3c5"
33
license = "MIT"
4-
version = "0.1.7"
4+
version = "0.1.8"
55

66
[deps]
77
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"

src/names.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,13 @@ If there are duplicate names or unnamed axes, an error is thrown.
140140
```jldoctest
141141
julia> using AxisKeys
142142
143-
julia> arr = KeyedArray([1 2], x=[1], y=[2,3]);
143+
julia> arr = KeyedArray(rand(1,3), x=[1], y=[2,3,4]);
144144
145145
julia> named_axiskeys(arr)
146-
(x = [1], y = [2, 3])
146+
(x = [1], y = [2, 3, 4])
147147
```
148148
"""
149-
function named_axiskeys(arr)::NamedTuple
150-
NT = NamedTuple{dimnames(arr)}
151-
return NT(axiskeys(arr))
149+
function named_axiskeys(A::AbstractArray)
150+
NT = NamedTuple{dimnames(A)}
151+
NT(axiskeys(A))
152152
end

test/_basic.jl

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,7 @@ using Test, AxisKeys
6363
@test_throws Exception wrapdims(rand(5), ['a','b','c'])
6464
@test_throws Exception KeyedArray(rand(5), ['a','b','c'])
6565

66-
@testset "named_axiskeys" begin
67-
arr = KeyedArray(randn(2,3), a=1:2, b=1:3)
68-
@inferred named_axiskeys(arr)
69-
@test named_axiskeys(arr) === (a=1:2, b=1:3)
70-
@test Tuple(named_axiskeys(arr)) === axiskeys(arr)
71-
72-
nonames = KeyedArray(randn(2,3), (1:2, 1:3))
73-
@test_throws ErrorException named_axiskeys(nonames)
74-
75-
v = KeyedArray(randn(3), x=1:3)
76-
dupnames = v .+ v'
77-
@test_throws ErrorException named_axiskeys(dupnames)
78-
end
7966
end
80-
8167
@testset "selectors" begin
8268

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

171+
@testset "named_axiskeys" begin
172+
arr = wrapdims(randn(2,3), a=1:2, b='a':'c')
173+
@inferred named_axiskeys(arr)
174+
@test named_axiskeys(arr) === (a=1:2, b='a':'c')
175+
@test Tuple(named_axiskeys(arr)) === axiskeys(arr)
176+
177+
nonames = KeyedArray(randn(2,3), (1:2, 'a':'c'))
178+
@test_throws ErrorException named_axiskeys(nonames)
179+
180+
v = wrapdims(randn(3), x=1:3)
181+
@test_throws ErrorException named_axiskeys(v .+ v') # duplicate names
182+
end
183+
185184
end
186185
@testset "broadcasting" begin
187186
using Base: OneTo

0 commit comments

Comments
 (0)