1
- A = AxisArray (reshape (1 : 24 , 2 ,3 ,4 ), .1 : .1 : .2 , .1 : .1 : .3 , .1 : .1 : .4 )
1
+ A = @inferred ( AxisArray (reshape (1 : 24 , 2 ,3 ,4 ), .1 : .1 : .2 , .1 : .1 : .3 , .1 : .1 : .4 ) )
2
2
@test_throws ArgumentError AxisArray (reshape (1 : 24 , 2 ,3 ,4 ), .1 : .1 : .1 , .1 : .1 : .3 , .1 : .1 : .4 )
3
3
@test_throws ArgumentError AxisArray (reshape (1 : 24 , 2 ,3 ,4 ), .1 : .1 : .1 , .1 : .1 : .3 )
4
+ @test_throws ArgumentError AxisArray (reshape (1 : 24 , 2 ,3 ,4 ), .1 : .1 : .2 , .1 : .1 : .3 , .1 : .1 : .4 , 1 : 1 )
4
5
@test parent (A) === reshape (1 : 24 , 2 ,3 ,4 )
5
6
# Test iteration
6
7
for (a,b) in zip (A, A. data)
@@ -40,7 +41,7 @@ for perm in ((:col, :row, :page), (:col, :page, :row),
40
41
end
41
42
@test axisnames (permutedims (A, (:col ,))) == (:col , :row , :page )
42
43
@test axisnames (permutedims (A, (:page ,))) == (:page , :row , :col )
43
- A2 = AxisArray (reshape (1 : 15 , 3 , 5 ))
44
+ A2 = @inferred ( AxisArray (reshape (1 : 15 , 3 , 5 ) ))
44
45
A1 = AxisArray (1 : 5 , :t )
45
46
for f in (transpose, ctranspose)
46
47
@test f (A2). data == f (A2. data)
@@ -100,12 +101,12 @@ A = AxisArray([1 3; 2 4], :a)
100
101
VERSION >= v " 0.5.0-dev" && @inferred (axisnames (A))
101
102
@test axisvalues (A) == (1 : 2 , 1 : 2 )
102
103
# Just axis values
103
- A = AxisArray (1 : 3 , .1 : .1 : .3 )
104
+ A = @inferred ( AxisArray (1 : 3 , .1 : .1 : .3 ) )
104
105
@test A. data == 1 : 3
105
106
@test axisnames (A) == (:row ,)
106
107
VERSION >= v " 0.5.0-dev" && @inferred (axisnames (A))
107
108
@test axisvalues (A) == (.1 : .1 : .3 ,)
108
- A = AxisArray (reshape (1 : 16 , 2 ,2 ,2 ,2 ), .5 : .5 : 1 )
109
+ A = @inferred ( AxisArray (reshape (1 : 16 , 2 ,2 ,2 ,2 ), .5 : .5 : 1 ) )
109
110
@test A. data == reshape (1 : 16 , 2 ,2 ,2 ,2 )
110
111
@test axisnames (A) == (:row ,:col ,:page ,:dim_4 )
111
112
VERSION >= v " 0.5.0-dev" && @inferred (axisnames (A))
@@ -129,17 +130,22 @@ B = AxisArray([1 4; 2 5; 3 6], (:x, :y), (0.2, 100), (-3,14))
129
130
@test AxisArrays. HasAxes (A) == AxisArrays. HasAxes {true} ()
130
131
@test AxisArrays. HasAxes ([1 ]) == AxisArrays. HasAxes {false} ()
131
132
132
- # Test axisdim
133
133
@test_throws ArgumentError AxisArray (reshape (1 : 24 , 2 ,3 ,4 ),
134
134
Axis {1} (.1 : .1 : .2 ),
135
135
Axis {2} (1 // 10 : 1 // 10 : 3 // 10 ),
136
136
Axis {3} ([" a" , " b" , " c" , " d" ])) # Axis need to be symbols
137
+ @test_throws ArgumentError AxisArray (reshape (1 : 24 , 2 ,3 ,4 ),
138
+ Axis {:x} (.1 : .1 : .2 ),
139
+ Axis {:y} (1 // 10 : 1 // 10 : 3 // 10 ),
140
+ Axis {:z} ([" a" , " b" , " c" , " d" ]),
141
+ Axis {:_} (1 : 1 )) # Too many Axes
137
142
138
- A = AxisArray (reshape (1 : 24 , 2 ,3 ,4 ),
143
+ A = @inferred ( AxisArray (reshape (1 : 24 , 2 ,3 ,4 ),
139
144
Axis {:x} (.1 : .1 : .2 ),
140
145
Axis {:y} (1 // 10 : 1 // 10 : 3 // 10 ),
141
- Axis {:z} ([" a" , " b" , " c" , " d" ]))
146
+ Axis {:z} ([" a" , " b" , " c" , " d" ])))
142
147
148
+ # Test axisdim
143
149
@test axisdim (A, Axis{:x }) == axisdim (A, Axis {:x} ()) == 1
144
150
@test axisdim (A, Axis{:y }) == axisdim (A, Axis {:y} ()) == 2
145
151
@test axisdim (A, Axis{:z }) == axisdim (A, Axis {:z} ()) == 3
@@ -176,7 +182,7 @@ T = A[AxisArrays.Axis{:x}]
176
182
177
183
# Test Timetype axis construction
178
184
dt, vals = DateTime (2010 , 1 , 2 , 3 , 40 ), randn (5 ,2 )
179
- A = AxisArray (vals, Axis {:Timestamp} (dt- Dates. Hour (2 ): Dates. Hour (1 ): dt+ Dates. Hour (2 )), Axis {:Cols} ([:A , :B ]))
185
+ A = @inferred ( AxisArray (vals, Axis {:Timestamp} (dt- Dates. Hour (2 ): Dates. Hour (1 ): dt+ Dates. Hour (2 )), Axis {:Cols} ([:A , :B ]) ))
180
186
@test A[:, :A ]. data == vals[:, 1 ]
181
187
@test A[dt, :]. data == vals[3 , :]
182
188
@@ -229,7 +235,7 @@ map!(*, A2, A, A)
229
235
230
236
# Reductions (issue #55)
231
237
A = AxisArray (collect (reshape (1 : 15 ,3 ,5 )), :y , :x )
232
- B = AxisArray (collect (reshape (1 : 15 ,3 ,5 )), Axis {:y} (0.1 : 0.1 : 0.3 ), Axis {:x} (10 : 10 : 50 ))
238
+ B = @inferred ( AxisArray (collect (reshape (1 : 15 ,3 ,5 )), Axis {:y} (0.1 : 0.1 : 0.3 ), Axis {:x} (10 : 10 : 50 ) ))
233
239
for C in (A, B)
234
240
for op in (sum, minimum) # together, cover both reduced_indices and reduced_indices0
235
241
axv = axisvalues (C)
0 commit comments