Skip to content

Commit b908b0a

Browse files
Fix findall with empty MtlArray of Bool (#601)
1 parent 9149006 commit b908b0a

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/indexing.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function Base.findall(bools::WrappedMtlArray{Bool})
2828
indices = MtlVector{Int64, Metal.SharedStorage}(undef, boolslen)
2929
cumsum!(indices, reshape(bools, boolslen))
3030

31-
n = indices[end]
31+
n = isempty(indices) ? 0 : indices[end]
3232
ys = similar(bools, I, n)
3333

3434
if n > 0

test/array.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,9 @@ end
533533
end
534534

535535
# ND
536+
let x = rand(Bool, 0, 0)
537+
@test findall(x) == Array(findall(MtlArray(x)))
538+
end
536539
let x = rand(Bool, 1000, 1000)
537540
@test findall(x) == Array(findall(MtlArray(x)))
538541
end

0 commit comments

Comments
 (0)