diff --git a/src/diskarray.jl b/src/diskarray.jl index d985d30..2f48b43 100644 --- a/src/diskarray.jl +++ b/src/diskarray.jl @@ -129,7 +129,7 @@ function process_index(i::AbstractUnitRange{<:Integer}, cs, ::NoBatch) DiskIndex((length(i),), (length(i),), (Colon(),), (Colon(),), (i,)), Base.tail(cs) end function process_index(i::AbstractArray{<:Integer}, cs, ::NoBatch) - indmin, indmax = extrema(i) + indmin, indmax = isempty(i) ? (1,0) : extrema(i) DiskIndex(size(i), ((indmax - indmin + 1),), map(_->Colon(),size(i)), ((i .- (indmin - 1)),), (indmin:indmax,)), Base.tail(cs) end function process_index(i::AbstractArray{Bool,N}, cs, ::NoBatch) where {N} diff --git a/test/runtests.jl b/test/runtests.jl index 4f211ac..440cd1e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -496,6 +496,13 @@ end a = AccessCountDiskArray(reshape(1:20, 4, 5, 1); chunksize=(4, 1, 1)) @test a[:, [1, 4], 1] == trueparent(a)[:, [1, 4], 1] @test getindex_count(a) == 1 + + #Test with empty vectors + @test a[Int[]] == Int[] + @test a[:,Int[],:] == zeros(Int,4,0,1) + @test a[Int[],:,:] == zeros(Int,0,5,1) + @test getindex_count(a) == 4 + coords = CartesianIndex.([(1, 1, 1), (3, 1, 1), (2, 4, 1), (4, 4, 1)]) @test a[coords] == trueparent(a)[coords] @test_broken getindex_count(a) == 4