raytools.utility¶
progress bar
- class raytools.utility.TStqdm(*_, **__)[source]¶
Bases:
tqdm
- raytools.utility.pool_call(func, args, *fixed_args, cap=None, expandarg=True, desc='processing', workers=True, pbar=True, **kwargs)[source]¶
calls func for a sequence of arguments using a ProcessPool executor and a progress bar. result is equivalent to:
result = [] for arg in args: result.append(func(*args, *fixed_args, **kwargs)) return result
- Parameters:
func (callable) – the function to execute in parallel
args (Sequence[Sequence]) – list of arguments (each item is expanded with ‘*’ unless expandarg is false). first N args of func
fixed_args (Sequence) – arguments passed to func that are the same for all calls (next N arguments after args)
cap (int, optional) – execution cap for ProcessPool
expandarg (bool, optional) – expand args with ‘*’ when calling func
desc (str, optional) – label for progress bar
workers (Union[bool, str], optional) – return threadpool (‘t’, ‘threads’, ‘thread’) or processpool (True)
pbar (bool, optional) – display progress bar while executing
kwargs – additional keyword arguments passed to func
- Return type:
sequence of results from func (order preserved)