Upstream Suor/funcy state of the touched files before c0960e614e
This commit is contained in:
1 parent
67695a8058
commit
f15f2b80fb
2 files changed
+2
-18
No files matched your search
+2
-6
@@ -363,12 +363,8 @@ def _cut_iter(drop_tail, n, step, seq):
|
|||||||
if len(pool) < n:
|
if len(pool) < n:
|
||||||
break
|
break
|
||||||
yield pool
|
yield pool
|
||||||
if step < n:
|
pool = pool[step:]
|
||||||
pool = pool[step:]
|
pool.extend(islice(it, step))
|
||||||
pool.extend(islice(it, step))
|
|
||||||
else:
|
|
||||||
take(step - n, it) # discard the gap between parts
|
|
||||||
pool = take(n, it)
|
|
||||||
if not drop_tail:
|
if not drop_tail:
|
||||||
for item in _cut_seq(drop_tail, n, step, pool):
|
for item in _cut_seq(drop_tail, n, step, pool):
|
||||||
yield item
|
yield item
|
||||||
|
|||||||
@@ -170,18 +170,6 @@ def test_chunks():
|
|||||||
assert lchunks(2, 1, [0, 1, 2, 3]) == [[0, 1], [1, 2], [2, 3], [3]]
|
assert lchunks(2, 1, [0, 1, 2, 3]) == [[0, 1], [1, 2], [2, 3], [3]]
|
||||||
assert lchunks(3, 1, iter(range(3))) == [[0, 1, 2], [1, 2], [2]]
|
assert lchunks(3, 1, iter(range(3))) == [[0, 1, 2], [1, 2], [2]]
|
||||||
|
|
||||||
def test_partition_step_gt_n():
|
|
||||||
# The iterator path must skip step - n items between parts, like the
|
|
||||||
# Sequence path, when step > n.
|
|
||||||
assert lpartition(2, 3, iter(range(10))) == lpartition(2, 3, list(range(10)))
|
|
||||||
assert lpartition(2, 3, iter(range(10))) == [[0, 1], [3, 4], [6, 7]]
|
|
||||||
|
|
||||||
def test_chunks_step_gt_n():
|
|
||||||
# The iterator path must skip step - n items between parts, like the
|
|
||||||
# Sequence path, when step > n.
|
|
||||||
assert lchunks(2, 3, iter(range(10))) == lchunks(2, 3, list(range(10)))
|
|
||||||
assert lchunks(2, 3, iter(range(10))) == [[0, 1], [3, 4], [6, 7], [9]]
|
|
||||||
|
|
||||||
def test_partition_by():
|
def test_partition_by():
|
||||||
assert lpartition_by(lambda x: x == 3, [1,2,3,4,5]) == [[1,2], [3], [4,5]]
|
assert lpartition_by(lambda x: x == 3, [1,2,3,4,5]) == [[1,2], [3], [4,5]]
|
||||||
assert lpartition_by('x', 'abxcd') == [['a', 'b'], ['x'], ['c', 'd']]
|
assert lpartition_by('x', 'abxcd') == [['a', 'b'], ['x'], ['c', 'd']]
|
||||||
|
|||||||
Reference in new issue
Block a user