@@ -39,12 +39,25 @@ S = OffsetArray(view(A0, 1:2, 1:2), (-1,2)) # LinearSlow
39
39
@test_throws DimensionMismatch OffsetArray (A0, 0 : 1 , 2 : 4 )
40
40
41
41
# Scalar indexing
42
- @test A[0 ,3 ] == A[1 ] == S[0 ,3 ] == S[1 ] == 1
43
- @test A[1 ,3 ] == A[2 ] == S[1 ,3 ] == S[2 ] == 2
44
- @test A[0 ,4 ] == A[3 ] == S[0 ,4 ] == S[3 ] == 3
45
- @test A[1 ,4 ] == A[4 ] == S[1 ,4 ] == S[4 ] == 4
42
+ @test A[0 ,3 ] == A[0 ,3 ,1 ] == A[1 ] == S[0 ,3 ] == S[0 ,3 ,1 ] == S[1 ] == 1
43
+ @test A[1 ,3 ] == A[1 ,3 ,1 ] == A[2 ] == S[1 ,3 ] == S[1 ,3 ,1 ] == S[2 ] == 2
44
+ @test A[0 ,4 ] == A[0 ,4 ,1 ] == A[3 ] == S[0 ,4 ] == S[0 ,4 ,1 ] == S[3 ] == 3
45
+ @test A[1 ,4 ] == A[1 ,4 ,1 ] == A[4 ] == S[1 ,4 ] == S[1 ,4 ,1 ] == S[4 ] == 4
46
+ @test @unsafe (A[0 ,3 ]) == @unsafe (A[0 ,3 ,1 ]) == @unsafe (A[1 ]) == @unsafe (S[0 ,3 ]) == @unsafe (S[0 ,3 ,1 ]) == @unsafe (S[1 ]) == 1
47
+ @test @unsafe (A[1 ,3 ]) == @unsafe (A[1 ,3 ,1 ]) == @unsafe (A[2 ]) == @unsafe (S[1 ,3 ]) == @unsafe (S[1 ,3 ,1 ]) == @unsafe (S[2 ]) == 2
48
+ @test @unsafe (A[0 ,4 ]) == @unsafe (A[0 ,4 ,1 ]) == @unsafe (A[3 ]) == @unsafe (S[0 ,4 ]) == @unsafe (S[0 ,4 ,1 ]) == @unsafe (S[3 ]) == 3
49
+ @test @unsafe (A[1 ,4 ]) == @unsafe (A[1 ,4 ,1 ]) == @unsafe (A[4 ]) == @unsafe (S[1 ,4 ]) == @unsafe (S[1 ,4 ,1 ]) == @unsafe (S[4 ]) == 4
46
50
@test_throws BoundsError A[1 ,1 ]
47
51
@test_throws BoundsError S[1 ,1 ]
52
+ @test_throws BoundsError A[0 ,3 ,2 ]
53
+ @test_throws BoundsError A[0 ,3 ,0 ]
54
+ Ac = copy (A)
55
+ Ac[0 ,3 ] = 10
56
+ @test Ac[0 ,3 ] == 10
57
+ Ac[0 ,3 ,1 ] = 11
58
+ @test Ac[0 ,3 ] == 11
59
+ @unsafe Ac[0 ,3 ,1 ] = 12
60
+ @test Ac[0 ,3 ] == 12
48
61
49
62
# Vector indexing
50
63
@test A[:, 3 ] == S[:, 3 ] == OffsetArray ([1 ,2 ], (A. offsets[1 ],))
@@ -63,8 +76,15 @@ S = OffsetArray(view(A0, 1:2, 1:2), (-1,2)) # LinearSlow
63
76
64
77
# CartesianIndexing
65
78
@test A[CartesianIndex ((0 ,3 ))] == S[CartesianIndex ((0 ,3 ))] == 1
79
+ @test A[CartesianIndex ((0 ,3 )),1 ] == S[CartesianIndex ((0 ,3 )),1 ] == 1
80
+ @test @unsafe (A[CartesianIndex ((0 ,3 ))]) == @unsafe (S[CartesianIndex ((0 ,3 ))]) == 1
81
+ @test @unsafe (A[CartesianIndex ((0 ,3 )),1 ]) == @unsafe (S[CartesianIndex ((0 ,3 )),1 ]) == 1
66
82
@test_throws BoundsError A[CartesianIndex (1 ,1 )]
83
+ @test_throws BoundsError A[CartesianIndex (1 ,1 ),0 ]
84
+ @test_throws BoundsError A[CartesianIndex (1 ,1 ),2 ]
67
85
@test_throws BoundsError S[CartesianIndex (1 ,1 )]
86
+ @test_throws BoundsError S[CartesianIndex (1 ,1 ),0 ]
87
+ @test_throws BoundsError S[CartesianIndex (1 ,1 ),2 ]
68
88
@test eachindex (A) == 1 : 4
69
89
@test eachindex (S) == CartesianRange ((0 : 1 ,3 : 4 ))
70
90
0 commit comments