Skip to content

Commit

Permalink
Cover slice edge cases
Browse files Browse the repository at this point in the history
- slice(0)
- slice(start, start)
- slice(start, start, y)
  • Loading branch information
gonzaponte committed Feb 15, 2024
1 parent 868235c commit 9f11c12
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions invisible_cities/dataflow/dataflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,11 @@ def slice(*args, close_all=False):
if step is None: step = 1
if stop is None: stopper = it.count()
else : stopper = range((stop - start + step - 1) // step)

@coroutine
def slice_loop(target):
with closing(target):
if start >= stop : yield
for _ in range(start) : yield
for _ in stopper:
target.send((yield))
Expand Down

0 comments on commit 9f11c12

Please sign in to comment.