@@ -103,12 +103,34 @@ end
103
103
@testset " getindex with additional inds" begin
104
104
A = reshape (1 : 12 , (3 , 4 ))
105
105
subA = view (A, :, :)
106
+ LA = LinearIndices (A)
107
+ CA = CartesianIndices (A)
106
108
@test @inferred (ArrayInterface. getindex (A, 1 , 1 , 1 )) == 1
107
109
@test @inferred (ArrayInterface. getindex (A, 1 , 1 , :)) == [1 ]
110
+ @test @inferred (ArrayInterface. getindex (A, 1 , 1 , 1 : 1 )) == [1 ]
108
111
@test @inferred (ArrayInterface. getindex (A, 1 , 1 , :, :)) == ones (1 , 1 )
112
+ @test @inferred (ArrayInterface. getindex (A, :, 1 , 1 )) == 1 : 3
113
+ @test @inferred (ArrayInterface. getindex (A, :, 1 , :)) == reshape (1 : 3 , 3 , 1 )
109
114
@test @inferred (ArrayInterface. getindex (subA, 1 , 1 , 1 )) == 1
110
115
@test @inferred (ArrayInterface. getindex (subA, 1 , 1 , :)) == [1 ]
116
+ @test @inferred (ArrayInterface. getindex (subA, 1 , 1 , 1 : 1 )) == [1 ]
111
117
@test @inferred (ArrayInterface. getindex (subA, 1 , 1 , :, :)) == ones (1 , 1 )
118
+ @test @inferred (ArrayInterface. getindex (subA, :, 1 , 1 )) == 1 : 3
119
+ @test @inferred (ArrayInterface. getindex (subA, :, 1 , :)) == reshape (1 : 3 , 3 , 1 )
120
+ @test @inferred (ArrayInterface. getindex (LA, 1 , 1 , 1 )) == 1
121
+ @test @inferred (ArrayInterface. getindex (LA, 1 , 1 , :)) == [1 ]
122
+ @test @inferred (ArrayInterface. getindex (LA, 1 , 1 , 1 : 1 )) == [1 ]
123
+ @test @inferred (ArrayInterface. getindex (LA, 1 , 1 , :, :)) == ones (1 , 1 )
124
+ @test @inferred (ArrayInterface. getindex (LA, :, 1 , 1 )) == 1 : 3
125
+ @test @inferred (ArrayInterface. getindex (LA, :, 1 , :)) == reshape (1 : 3 , 3 , 1 )
126
+ @test @inferred (ArrayInterface. getindex (CA, 1 , 1 , 1 )) == CartesianIndex (1 , 1 )
127
+ @test @inferred (ArrayInterface. getindex (CA, 1 , 1 , :)) == [CartesianIndex (1 , 1 )]
128
+ @test @inferred (ArrayInterface. getindex (CA, 1 , 1 , 1 : 1 )) == [CartesianIndex (1 , 1 )]
129
+ @test @inferred (ArrayInterface. getindex (CA, 1 , 1 , :, :)) == fill (CartesianIndex (1 , 1 ), 1 , 1 )
130
+ @test @inferred (ArrayInterface. getindex (CA, :, 1 , 1 )) ==
131
+ reshape (CartesianIndex (1 , 1 ): CartesianIndex (3 , 1 ), 3 )
132
+ @test @inferred (ArrayInterface. getindex (CA, :, 1 , :)) ==
133
+ reshape (CartesianIndex (1 , 1 ): CartesianIndex (3 , 1 ), 3 , 1 )
112
134
end
113
135
114
136
@testset " 0-dimensional" begin
0 commit comments