mirror of
https://github.com/romanz/amodem.git
synced 2026-03-23 19:01:00 +08:00
parallel iterator split
This commit is contained in:
@@ -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,)
|
||||
|
||||
Reference in New Issue
Block a user