Skip to content

Commit 8bca0e9

Browse files
Merge pull request #335 from AayushSabharwal/as/bool-view
fix: fix views with boolean mask
2 parents a64ff30 + c44a776 commit 8bca0e9

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/vector_of_array.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,13 +528,13 @@ function Base.view(A::AbstractVectorOfArray{T,N,<:AbstractVector{T}}, I::Vararg{
528528
J = map(i->Base.unalias(A,i), to_indices(A, Base.tail(I)))
529529
end
530530
@boundscheck checkbounds(A, J...)
531-
SubArray(IndexStyle(A), A, J, Base.index_dimsum(J...))
531+
SubArray(A, J)
532532
end
533533
function Base.view(A::AbstractVectorOfArray, I::Vararg{Any,M}) where {M}
534534
@inline
535535
J = map(i->Base.unalias(A,i), to_indices(A, I))
536536
@boundscheck checkbounds(A, J...)
537-
SubArray(IndexStyle(A), A, J, Base.index_dimsum(J...))
537+
SubArray(A, J)
538538
end
539539
function Base.SubArray(parent::AbstractVectorOfArray, indices::Tuple)
540540
@inline

test/interface_tests.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ arrvb = Array(testvb)
8484
# view
8585
testvc = VectorOfArray([rand(1:10, 3, 3) for _ in 1:3])
8686
arrvc = Array(testvc)
87-
for idxs in [(2, 2, :), (2, :, 2), (:, 2, 2), (:, :, 2), (:, 2, :), (2, : ,:), (:, :, :)]
87+
for idxs in [(2, 2, :), (2, :, 2), (:, 2, 2), (:, :, 2), (:, 2, :), (2, : ,:), (:, :, :), (1:2, 1:2, Bool[1, 0, 1]), (1:2, Bool[1, 0, 1], 1:2), (Bool[1, 0, 1], 1:2, 1:2)]
8888
arr_view = view(arrvc, idxs...)
8989
voa_view = view(testvc, idxs...)
9090
@test size(arr_view) == size(voa_view)
@@ -93,11 +93,13 @@ end
9393

9494
testvc = VectorOfArray(collect(1:10))
9595
arrvc = Array(testvc)
96+
bool_idx = rand(Bool, 10)
9697
for (voaidx, arridx) in [
9798
((:,), (:,)),
9899
((3:5,), (3:5,)),
99100
((:, 3:5), (3:5,)),
100101
((1, 3:5), (3:5,)),
102+
((:, bool_idx), (bool_idx,))
101103
]
102104
arr_view = view(arrvc, arridx...)
103105
voa_view = view(testvc, voaidx...)

0 commit comments

Comments
 (0)