- Fix chunks for when length of input is smaller than chunk size.
This commit is contained in:
@@ -11,6 +11,9 @@ Tested on linux on python 2.7 and 3.8 and on Windows and OSX on python 3.8.
|
||||
- Using dill instead of pickle: a lot more objects can be used when parallelizing
|
||||
- Progress bars are built-in
|
||||
|
||||
## Installation
|
||||
pip install parfor
|
||||
|
||||
## Usage
|
||||
Parfor decorates a functions and returns the result of that function evaluated in parallel for each iteration of
|
||||
an iterator.
|
||||
|
||||
@@ -118,8 +118,8 @@ def chunks(n, *args):
|
||||
""" Yield successive n-sized chunks from lists. """
|
||||
A = len(args)==1
|
||||
N = len(args[0])
|
||||
n = int(round(N/round(N/n)))
|
||||
for i in range(0, N, n):
|
||||
n = int(round(N/max(1, round(N/n))))
|
||||
for i in range(0, N, n) if N else []:
|
||||
if A:
|
||||
yield args[0][i:i+n]
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user