parallel iterator split

This commit is contained in:
Roman Zeyde
2014-07-07 16:42:00 +03:00
committed by Roman Zeyde
parent 000e96b40d
commit 9981f280f4
2 changed files with 41 additions and 1 deletions

View File

@@ -16,3 +16,16 @@ def test_iterate():
assert iterlist(range(N), 2, offset=5) == [(i, [i, i+1]) for i in range(5, N-1)]
assert iterlist(range(N), 1, func=lambda b: -b) == [(i, [-i]) for i in range(N)]
def test_split():
L = [(i*2, i*2+1) for i in range(10)]
iters = common.split(L, n=2)
assert zip(*iters) == L
for i in [0, 1]:
iters = common.split(L, n=2)
iters[i].next()
try:
iters[i].next()
assert False
except IndexError as e:
assert e.args == (i,)