From 24bbb8ede27ae9efc30d51eb1fe503011ed7c436 Mon Sep 17 00:00:00 2001 From: Fabian Gans Date: Fri, 23 Feb 2024 17:16:55 +0100 Subject: [PATCH] Fix 155 (#156) --- src/diskarray.jl | 1 + test/runtests.jl | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/diskarray.jl b/src/diskarray.jl index e203f7e..1ea4f34 100644 --- a/src/diskarray.jl +++ b/src/diskarray.jl @@ -153,6 +153,7 @@ splitcs(::Tuple{}, csnow, csrem) = (csnow, csrem) function getindex_disk(a, i::Union{Integer,CartesianIndex}...) checkscalar(i) + checkbounds(a,i...) outputarray = Array{eltype(a)}(undef, map(_ -> 1, size(a))...) i = Base.to_indices(a, i) j = map(1:ndims(a)) do d diff --git a/test/runtests.jl b/test/runtests.jl index 51d8ef2..8578b4f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -28,6 +28,12 @@ end @test DiskArrays.can_scalar() == true @test DiskArrays.checkscalar(Bool, 1, 2, 3) == true @test DiskArrays.checkscalar(Bool, :, 2:5, 3) == true + a = AccessCountDiskArray(reshape(1:24,2,3,4),chunksize=(2,2,2)) + @test a[1,2,3] == 15 + @test a[1,2,3,1] == 15 + @test_throws BoundsError a[1,2] + @test a[CartesianIndex(1,2),3] == 15 + @test a[CartesianIndex(1,2,3)] == 15 end function test_getindex(a)