diff --git a/src/chunks.jl b/src/chunks.jl index 6bd4a7f..6e2d102 100644 --- a/src/chunks.jl +++ b/src/chunks.jl @@ -78,8 +78,7 @@ Base.@propagate_inbounds function Base.getindex(r::RegularChunks, i::Int) @boundscheck checkbounds(r, i) return max((i - 1) * r.chunksize + 1 - r.offset, 1):min(i * r.chunksize - r.offset, r.arraysize) end -Base.size(r::RegularChunks, _) = div(r.arraysize + r.offset - 1, r.chunksize) + 1 -Base.size(r::RegularChunks) = (size(r, 1),) +Base.size(r::RegularChunks) = (div(r.arraysize + r.offset - 1, r.chunksize) + 1,) function Base.:(==)(r1::RegularChunks, r2::RegularChunks) # The axis sizes must always match r1.arraysize == r2.arraysize || return false diff --git a/test/runtests.jl b/test/runtests.jl index b14036b..477b889 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -231,6 +231,7 @@ end @test a1[3] == 9:10 @test length(a1) == 3 @test size(a1) == (3,) + @test size(a1, 2) == 1 @test subsetchunks(a1, 1:10) === a1 @test subsetchunks(a1, 4:9) === RegularChunks(5, 0, 6) @test subsetchunks(a1, Int[]) === RegularChunks(1, 0, 0)