Skip to content

Commit 6f87f70

Browse files
committed
Add tests for too many axes
1 parent 609bad2 commit 6f87f70

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

test/core.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
A = @inferred(AxisArray(reshape(1:24, 2,3,4), .1:.1:.2, .1:.1:.3, .1:.1:.4))
22
@test_throws ArgumentError AxisArray(reshape(1:24, 2,3,4), .1:.1:.1, .1:.1:.3, .1:.1:.4)
33
@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)
45
@test parent(A) === reshape(1:24, 2,3,4)
56
# Test iteration
67
for (a,b) in zip(A, A.data)
@@ -129,17 +130,22 @@ B = AxisArray([1 4; 2 5; 3 6], (:x, :y), (0.2, 100), (-3,14))
129130
@test AxisArrays.HasAxes(A) == AxisArrays.HasAxes{true}()
130131
@test AxisArrays.HasAxes([1]) == AxisArrays.HasAxes{false}()
131132

132-
# Test axisdim
133133
@test_throws ArgumentError AxisArray(reshape(1:24, 2,3,4),
134134
Axis{1}(.1:.1:.2),
135135
Axis{2}(1//10:1//10:3//10),
136136
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
137142

138143
A = @inferred(AxisArray(reshape(1:24, 2,3,4),
139144
Axis{:x}(.1:.1:.2),
140145
Axis{:y}(1//10:1//10:3//10),
141146
Axis{:z}(["a", "b", "c", "d"])))
142147

148+
# Test axisdim
143149
@test axisdim(A, Axis{:x}) == axisdim(A, Axis{:x}()) == 1
144150
@test axisdim(A, Axis{:y}) == axisdim(A, Axis{:y}()) == 2
145151
@test axisdim(A, Axis{:z}) == axisdim(A, Axis{:z}()) == 3

0 commit comments

Comments
 (0)