IdentityTask
- class PlasmaCalcs.tools.multiprocessing.IdentityTask(x, i=None)
Bases:
Tasktask which returns its (single) input. Useful for TaskArray, etc.
Methods
__call__(**kw)perform the task, i.e. return f(*args, **kw).
apply_async(pool, *[, kw])perform the task asynchronously, i.e. pool.apply_async(...).
get_kw([kw])gets self.kw, but updated with values from kw.
implied(task_info, *[, force_kw])return the Task implied from task_info.
new_with([f, args, kw, i])return a new Task, with the given inputs.
- __call__(**kw)
perform the task, i.e. return f(*args, **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.
- 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: dictkwargs 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: boolapplies 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))