Skip to content

Commit 0993d78

Browse files
committed
iteratorsize for partition iterator
1 parent dcde84d commit 0993d78

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

base/iterator.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,9 @@ type PartitionIterator{T}
490490
end
491491

492492
eltype{T}(::Type{PartitionIterator{T}}) = Vector{eltype(T)}
493+
partition_iteratorsize(::HasShape) = HasLength()
494+
partition_iteratorsize{T}(isz::T) = isz
495+
iteratorsize{T}(P::Type{PartitionIterator{T}}) = partition_iteratorsize(iteratorsize(T))
493496

494497
function length(itr::PartitionIterator)
495498
l = length(itr.c)

test/functional.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,10 @@ let v = collect(Base.partition([1,2,3,4,5], 1))
264264
@test all(i->v[i][1] == i, v)
265265
end
266266

267-
let v = collect(Base.partition([1,2,3,4,5], 2))
268-
@test v[1] == [1,2]
269-
@test v[2] == [3,4]
270-
@test v[3] == [5]
267+
let v1 = collect(Base.partition([1,2,3,4,5], 2)), v2 = collect(Base.partition(Base.flatten([1,2,3,4,5]), 2))
268+
@test v1[1] == v1[1] == [1,2]
269+
@test v1[2] == v2[2] == [3,4]
270+
@test v1[3] == v2[3] == [5]
271271
end
272272

273273
let v = collect(Base.partition(enumerate([1,2,3,4,5]), 3))

0 commit comments

Comments
 (0)