Skip to content

Commit d1a9899

Browse files
committed
fixes
1 parent 85b7bd4 commit d1a9899

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

src/cached.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ function _readblock_cached!(A::CachedDiskArray{T,N}, data, I...) where {T,N}
4141
if haskey(A.cache, c)
4242
A.cache[c]
4343
else
44-
chunk_data = Array{T,N}(undef, length.(I)...)
45-
A.cache[c] = readblock!(parent(A), chunk_data, I...)
44+
chunk_data = Array{T,N}(undef, length.(c)...)
45+
A.cache[c] = readblock!(parent(A), chunk_data, c...)
4646
end
4747
end
4848
out = ConcatDiskArray(chunk_arrays)

test/runtests.jl

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -709,22 +709,24 @@ end
709709
end
710710

711711
@testset "Cached arrays" begin
712-
A = (1:300) * (1:1200)'
713-
ch = ChunkedDiskArray((1:3000) * (1:1200)', (128, 128))
712+
M = (1:300) * (1:1200)'
713+
A = cat(M, M, M, M; dims=3)
714+
ch = ChunkedDiskArray(A, (128, 128, 2))
714715
ca = DiskArrays.CachedDiskArray(ch; maxsize=5)
715716
# Read the original
716717
@test sum(ca) == sum(ca)
717-
# Read from the cache
718-
@test ca[:, :] == ch
719718
length(ca.cache)
720719

721720
ca = DiskArrays.cache(ch; maxsize=5)
722721
@test sum(ca) == sum(ca)
723722

724-
@test ca[:, :] == ch[:, :]
725-
@test ca[:, 1] == ch[:, 1]
726-
@test ca[:, 2] == ch[:, 2]
727-
@test ca[:, 3] == ch[:, 3]
728-
@test ca[:, 200] == ch[:, 200]
729-
@test ca[200, :] == ch[200, :]
723+
@test ca[:, :, 1] == A[:, :, 1]
724+
@test ca[:, :, 2] == A[:, :, 2]
725+
@test ca[:, :, 2] == A[:, :, 3]
726+
@test ca[:, :, 2] == A[:, :, 4]
727+
@test ca[:, 1, 1] == ch[:, 1, 1]
728+
@test ca[:, 2, 1] == ch[:, 2, 1]
729+
@test ca[:, 3, 1] == ch[:, 3, 1]
730+
@test ca[:, 200, 1] == ch[:, 200, 1]
731+
@test ca[200, :, 1] == ch[200, :, 1]
730732
end

0 commit comments

Comments
 (0)