Skip to content

Commit 64a20d7

Browse files
committed
refactored partitions.
1 parent f03c031 commit 64a20d7

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

python_toolbox/sequence_tools.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,12 @@ def partitions(sequence, partition_size=None, n_partitions=None,
135135

136136
enlarged_length = partition_size * n_partitions
137137

138-
filler = []
139-
if fillvalue != NoFillValue:
140-
filler = itertools.repeat(fillvalue, enlarged_length - sequence_length)
141-
142138
blocks = [sequence[i : i + partition_size] for i in
143139
xrange(0, enlarged_length, partition_size)]
144-
blocks[-1].extend(filler)
140+
141+
if fillvalue != NoFillValue:
142+
filler = itertools.repeat(fillvalue, enlarged_length - sequence_length)
143+
blocks[-1].extend(filler)
145144

146145
return blocks
147146

0 commit comments

Comments
 (0)