qudit_sim.parallel_map
- qudit_sim.parallel_map(target, args=None, kwarg_keys=None, kwarg_values=None, common_args=None, common_kwargs=None, arg_position=None, thread_based=False, log_level=logging.WARNING)
Call the target on a list of args in parallel processes.
The returned result is equivalent to
kwargs = list(dict(zip(kwarg_keys, values)) for values in kwarg_values) [target(*(a + common_args), **(k | common_kwargs)) for a, k in zip(args, kwargs)]
The order of the positional arguments can optionally be specified via the arg_position parameter. If this is given, the positional arguments to the target function is
positional[arg_position[i]] = args[][i]
with common_args filling in the unused positions in order.
- Parameters
target (
Callable) – Function to execute in parallel.args (
Optional[List[Any]]) – List of positional arguments.kwarg_keys (
Union[str,Tuple[str],None]) – Key(s) of mapped keyword arguments.kwarg_values (
Optional[List[Any]]) – List of values of keyword arguments.common_args (
Optional[tuple]) – Positional arguments common to all invocation of the function.common_kwargs (
Optional[dict]) – Keyword arguments common to all invocation of the function.arg_position (
Union[int,Sequence[int],None]) – Positions of each element of args in the function call.thread_based (
bool) – Use threads instead of processes.log_level (
int) – logger level.
- Return type
list- Returns
List of return values of the function.