PlasmaCalcs.tools.multiprocessing.IdentityTask
- class PlasmaCalcs.tools.multiprocessing.IdentityTask(x, i=None)
Bases:
Tasktask which returns its (single) input. Useful for TaskArray, etc.- __init__(x, i=None)
Methods
__init__(x[, i])apply_async(pool, *[, kw])get_kw([kw])implied(task_info, *[, force_kw])new_with([f, args, kw, i])- apply_async(pool, *, kw={})
- perform the task asynchronously, i.e. pool.apply_async(…)Equivalent to pool.apply_async(self.f, args=self.args, kwds=self.kw)
- kw: dict
- kwargs for task will be task.kw, but updated with kw.E.g. if task.kw = {‘x’: 1}, and kw = {‘y’: 2}, –> task called with x=1, y=2.
- get_kw(kw={})
- gets self.kw, but updated with values from kw. (doesn’t alter self.kw)[EFF] if kw is empty, return self.kw instead of making a copy.
- classmethod implied(task_info, *, force_kw=True, **kw_init)
- return the Task implied from task_info.
- task_info: Task, iterable, or callable.
- Task –> return task_info, unchanged (unless force_kw and len(kw_init)>0).if task_info is not an instance of cls but it is a Task, raise TypeError.iterable –> return Task(*task_info).callable –> return Task(task_info).
- force_kw: bool
- applies if kw_init provided and task_info is a Task…True –> return task_info.new_with(**kw_init)False –> return task_info, unchanged.
kw_init: pass to Task(…, **kw_init) if task_info is not already a Task.
- new_with(f=UNSET, args=UNSET, kw=UNSET, i=UNSET)
- return a new Task, with the given inputs. Use value from self for UNSET inputs.E.g. Task(f, [5,6]).new_with(f=g, kw=dict(y=7)) –> Task(g, [5,6], dict(y=7))