@@ -43,6 +43,7 @@ using Test
43
43
@test isassigned (A, 2 )
44
44
@test ! isassigned (A, 1 )
45
45
@test length .(axes (A)) == (2 ,)
46
+ @test_throws KeyError A[" 2" ]
46
47
47
48
correct_answer = DenseAxisArray ([2.0 , 3.0 ], 2 : 3 )
48
49
@test sprint (show, correct_answer) == """
@@ -93,6 +94,14 @@ And data, a 2-element $(Vector{Float64}):
93
94
@test 1 .+ A == correct_answer
94
95
end
95
96
97
+ @testset " String index set" begin
98
+ A = @inferred DenseAxisArray ([1.0 , 2.0 ], [" a" , " b" ])
99
+ @test (@inferred A[" a" ]) == (@inferred A[GenericString (" a" )]) == 1.0
100
+ @test (@inferred A[[" a" , " b" ]]) ==
101
+ (@inferred A[[GenericString (" a" ), GenericString (" b" )]]) ==
102
+ A
103
+ end
104
+
96
105
@testset " Mixed range/symbol index sets" begin
97
106
A = @inferred DenseAxisArray ([1 2 ; 3 4 ], 2 : 3 , [:a , :b ])
98
107
@test size (A) == (2 , 2 )
@@ -248,6 +257,11 @@ And data, a 0-dimensional $(Array{Int,0}):
248
257
@test (@inferred C[2 : 3 , [:a , :b ]]) == C
249
258
@test (@inferred C[2 , [:a , :b ]]) == DenseAxisArray ([5.0 , 6.0 ], [:a , :b ])
250
259
@test (@inferred C[2 : 3 , :b ]) == DenseAxisArray ([6.0 , 8.0 ], 2 : 3 )
260
+
261
+ D = DenseAxisArray ([5.0 6.0 ; 7.0 8.0 ], 2 : 3 , [" a" , " b" ])
262
+ @test (@inferred D[2 , GenericString (" b" )]) == 6.0
263
+ @test (@inferred D[2 , [GenericString (" a" ), GenericString (" b" )]]) ==
264
+ DenseAxisArray ([5.0 , 6.0 ], [" a" , " b" ])
251
265
end
252
266
@testset " BitArray" begin
253
267
x = DenseAxisArray ([0 1 ; 1 0 ], [:a , :b ], 1 : 2 )
0 commit comments