pyphi.parallel.map_reduce#
- pyphi.parallel.map_reduce(fn, items, *more_items, reduce_func=<function _flatten>, reduce_kwargs=None, parallel=True, ordered=False, total=None, chunksize=None, sequential_threshold=1, shortcircuit_func=<function false>, shortcircuit_callback=None, shortcircuit_callback_args=None, progress=None, desc=None, map_kwargs=None, size_func=None, backend='auto')[source]#
Map
fnoveritems(zipped withmore_items) and reduce.Runs in parallel through the scheduler selected by
backend(orconfig.infrastructure.parallel_backend). Withparallel=Falseit runs serially in-process.reduce_funcdefaults to flattening the per-item results into a list.size_funcreturns a relative per-item cost estimate used to pack cost-balanced chunks (parent-side, so it must be cheap);Nonepacks equal-count chunks.When
shortcircuit_funcfires,shortcircuit_callback(if given) is invoked withshortcircuit_callback_args, or — when those are not given — with the list of results collected so far, ending with the triggering result. The payload is the same on every backend and dispatch path.- Raises:
ValueError – If
size_funcis given together withordered=True: cost balancing reorders items across chunks, so it cannot preserve input order.- Parameters:
- Return type: