@@ -198,6 +198,26 @@ function test_vector_indexing{T}(::Type{T}, shape, ::Type{TestAbstractArray})
198
198
# Test with containers that aren't Int[]
199
199
@test B[[]] == A[[]] == []
200
200
@test B[convert (Array{Any}, idxs)] == A[convert (Array{Any}, idxs)] == idxs
201
+
202
+ # Test adding dimensions with matrices
203
+ idx1 = rand (1 : size (A, 1 ), 3 )
204
+ idx2 = rand (1 : Base. trailingsize (A, 2 ), 4 , 5 )
205
+ @test B[idx1, idx2] == A[idx1, idx2] == reshape (A[idx1, vec (idx2)], 3 , 4 , 5 ) == reshape (B[idx1, vec (idx2)], 3 , 4 , 5 )
206
+ @test B[1 , idx2] == A[1 , idx2] == reshape (A[1 , vec (idx2)], 4 , 5 ) == reshape (B[1 , vec (idx2)], 4 , 5 )
207
+
208
+ # test removing dimensions with 0-d arrays
209
+ idx0 = reshape ([rand (1 : size (A, 1 ))])
210
+ @test B[idx0, idx2] == A[idx0, idx2] == reshape (A[idx0[], vec (idx2)], 4 , 5 ) == reshape (B[idx0[], vec (idx2)], 4 , 5 )
211
+ @test B[reshape ([end ]), reshape ([end ])] == A[reshape ([end ]), reshape ([end ])] == reshape ([A[end ,end ]]) == reshape ([B[end ,end ]])
212
+
213
+ # test logical indexing
214
+ mask = bitrand (shape)
215
+ @test B[mask] == A[mask] == B[find (mask)] == A[find (mask)] == find (mask)
216
+ @test B[vec (mask)] == A[vec (mask)] == find (mask)
217
+ mask1 = bitrand (size (A, 1 ))
218
+ mask2 = bitrand (Base. trailingsize (A, 2 ))
219
+ @test B[mask1, mask2] == A[mask1, mask2] == B[find (mask1), find (mask2)]
220
+ @test B[mask1, 1 ] == A[mask1, 1 ] == find (mask1)
201
221
end
202
222
203
223
function test_primitives {T} (:: Type{T} , shape, :: Type{TestAbstractArray} )
0 commit comments