Create a new task with the values substituted This is like dask.core.subs, but takes a dict of many substitutions to perform simultaneously. It is not as concerned with micro performance.
(task, substitution)
| 194 | |
| 195 | |
| 196 | def subs(task, substitution): |
| 197 | """Create a new task with the values substituted |
| 198 | |
| 199 | This is like dask.core.subs, but takes a dict of many substitutions to |
| 200 | perform simultaneously. It is not as concerned with micro performance. |
| 201 | """ |
| 202 | if isinstance(task, dict): |
| 203 | return {k: subs(v, substitution) for k, v in task.items()} |
| 204 | if type(task) in (tuple, list, set): |
| 205 | return type(task)([subs(x, substitution) for x in task]) |
| 206 | try: |
| 207 | return substitution[task] |
| 208 | except (KeyError, TypeError): |
| 209 | return task |
| 210 | |
| 211 | |
| 212 | def index_subs(ind, substitution): |