- 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
|
- Using dill instead of pickle: a lot more objects can be used when parallelizing
|
||||||
- Progress bars are built-in
|
- Progress bars are built-in
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
pip install parfor
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
Parfor decorates a functions and returns the result of that function evaluated in parallel for each iteration of
|
Parfor decorates a functions and returns the result of that function evaluated in parallel for each iteration of
|
||||||
an iterator.
|
an iterator.
|
||||||
|
|||||||
@@ -118,8 +118,8 @@ def chunks(n, *args):
|
|||||||
""" Yield successive n-sized chunks from lists. """
|
""" Yield successive n-sized chunks from lists. """
|
||||||
A = len(args)==1
|
A = len(args)==1
|
||||||
N = len(args[0])
|
N = len(args[0])
|
||||||
n = int(round(N/round(N/n)))
|
n = int(round(N/max(1, round(N/n))))
|
||||||
for i in range(0, N, n):
|
for i in range(0, N, n) if N else []:
|
||||||
if A:
|
if A:
|
||||||
yield args[0][i:i+n]
|
yield args[0][i:i+n]
|
||||||
else:
|
else:
|
||||||
|
|||||||
2
setup.py
2
setup.py
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
|
|||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name="parfor",
|
name="parfor",
|
||||||
version="2020.09.4",
|
version="2020.11.24",
|
||||||
author="Wim Pomp",
|
author="Wim Pomp",
|
||||||
author_email="wimpomp@gmail.com",
|
author_email="wimpomp@gmail.com",
|
||||||
description="A package to mimic the use of parfor as done in Matlab.",
|
description="A package to mimic the use of parfor as done in Matlab.",
|
||||||
|
|||||||
Reference in New Issue
Block a user