| 118 | |
| 119 | |
| 120 | class ExprTuple(DaskMethodsMixin): |
| 121 | __dask_scheduler__ = staticmethod(dask.threaded.get) |
| 122 | __dask_optimize__ = None |
| 123 | |
| 124 | def __init__(self, *children): |
| 125 | self.children = tuple(children) |
| 126 | |
| 127 | def __dask_exprs__(self): |
| 128 | return tuple(child.expr for child in self.children) |
| 129 | |
| 130 | def __dask_rebuild_from_exprs__(self, exprs): |
| 131 | return ExprTuple(*(ExprScalar(expr) for expr in exprs)) |
| 132 | |
| 133 | def __dask_graph__(self): |
| 134 | return merge(*(child.__dask_graph__() for child in self.children)) |
| 135 | |
| 136 | def __dask_keys__(self): |
| 137 | return [child.__dask_keys__() for child in self.children] |
| 138 | |
| 139 | def __dask_layers__(self): |
| 140 | return tuple(child.expr._name for child in self.children) |
| 141 | |
| 142 | def __dask_tokenize__(self): |
| 143 | return self.children |
| 144 | |
| 145 | def __dask_postcompute__(self): |
| 146 | return _finalize_expr_tuple, () |
| 147 | |
| 148 | def __dask_postpersist__(self): |
| 149 | return ExprTuple._rebuild, (self.children,) |
| 150 | |
| 151 | @staticmethod |
| 152 | def _rebuild(dsk, children): |
| 153 | return ExprTuple(*(ExprScalar._rebuild(dsk, child.expr) for child in children)) |
| 154 | |
| 155 | |
| 156 | def test_collections_to_expr_uses_composite_protocol(): |
no outgoing calls