pass extra kwargs to tqdm

This commit is contained in:
Mike Clark
2019-11-27 12:40:34 +00:00
committed by GitHub
parent 542416388f
commit d25977e3c7
+4 -1
View File
@@ -32,6 +32,7 @@ def _parallel(ordered, function, *arrays, **kwargs):
num_iter(int): If only non-list variables are passed, the
function will be performed num_iter times on
these variables. Default: 1.
**kwargs: extra arguments will be passes to tqdm
Returns:
An iterator which will apply the function
@@ -45,6 +46,8 @@ def _parallel(ordered, function, *arrays, **kwargs):
# Extract kwargs
num_cpus = kwargs.get('num_cpus', None)
num_iter = kwargs.get('num_iter', 1)
kwargs['num_cpus']=None
kwargs['num_iter']=None
# Determine num_cpus
if num_cpus is None:
@@ -67,7 +70,7 @@ def _parallel(ordered, function, *arrays, **kwargs):
# Create parallel iterator
map_type = 'imap' if ordered else 'uimap'
iterator = tqdm(getattr(Pool(num_cpus), map_type)(function, *arrays),
total=num_iter)
total=num_iter, **kwargs)
return iterator