This commit is contained in:
Wim Pomp
2021-05-25 10:51:14 +02:00
parent 6c9c18746b
commit 9caeb06c2b
2 changed files with 4 additions and 2 deletions

View File

@@ -127,12 +127,14 @@ class chunks():
""" """
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
N = min(*[len(a) for a in args]) if len(args) > 1 else len(args[0])
if 's' in kwargs and 'n' in kwargs: if 's' in kwargs and 'n' in kwargs:
N = min(*[len(a) for a in args]) if len(args) > 1 else len(args[0])
n = kwargs['n'] if N < kwargs['s'] * kwargs['n'] else round(N / kwargs['s']) n = kwargs['n'] if N < kwargs['s'] * kwargs['n'] else round(N / kwargs['s'])
elif 's' in kwargs: # size of chunks elif 's' in kwargs: # size of chunks
N = min(*[len(a) for a in args]) if len(args) > 1 else len(args[0])
n = round(N / kwargs['s']) n = round(N / kwargs['s'])
elif 'n' in kwargs: # number of chunks elif 'n' in kwargs: # number of chunks
N = min(*[len(a) for a in args]) if len(args) > 1 else len(args[0])
n = kwargs['n'] n = kwargs['n']
else: # size of chunks in 1st argument else: # size of chunks in 1st argument
s, *args = args s, *args = args

View File

@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
setuptools.setup( setuptools.setup(
name="parfor", name="parfor",
version="2021.5.1", version="2021.5.2",
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.",