MCPcopy Create free account
hub / github.com/dask/dask / _ExprSequence

Class _ExprSequence

dask/_expr.py:1205–1287  ·  view source on GitHub ↗

A sequence of expressions This is used to be able to optimize multiple collections combined, e.g. when being computed simultaneously with ``dask.compute((Expr1, Expr2))``.

Source from the content-addressed store, hash-verified

1203
1204
1205class _ExprSequence(Expr):
1206 """A sequence of expressions
1207
1208 This is used to be able to optimize multiple collections combined, e.g. when
1209 being computed simultaneously with ``dask.compute((Expr1, Expr2))``.
1210 """
1211
1212 def __getitem__(self, other):
1213 return self.operands[other]
1214
1215 def _layer(self) -> dict:
1216 return toolz.merge(op._layer() for op in self.operands)
1217
1218 def __dask_keys__(self) -> list:
1219 all_keys = []
1220 for op in self.operands:
1221 all_keys.append(list(op.__dask_keys__()))
1222 return all_keys
1223
1224 def __repr__(self):
1225 return "ExprSequence(" + ", ".join(map(repr, self.operands)) + ")"
1226
1227 __str__ = __repr__
1228
1229 def finalize_compute(self):
1230 return _ExprSequence(
1231 *(op.finalize_compute() for op in self.operands),
1232 )
1233
1234 def __dask_annotations__(self):
1235 annotations_by_type = {}
1236 for op in self.operands:
1237 for k, v in op.__dask_annotations__().items():
1238 annotations_by_type.setdefault(k, {}).update(v)
1239 return annotations_by_type
1240
1241 def __len__(self):
1242 return len(self.operands)
1243
1244 def __iter__(self):
1245 return iter(self.operands)
1246
1247 def _simplify_down(self):
1248 from dask.highlevelgraph import HighLevelGraph
1249
1250 issue_warning = False
1251 hlgs = []
1252 if any(
1253 isinstance(op, (HLGExpr, HLGFinalizeCompute, dict)) for op in self.operands
1254 ):
1255 for op in self.operands:
1256 if isinstance(op, (HLGExpr, HLGFinalizeCompute)):
1257 hlgs.append(op)
1258 elif isinstance(op, dict):
1259 hlgs.append(
1260 HLGExpr(
1261 dsk=HighLevelGraph.from_collections(
1262 str(id(op)), op, dependencies=()

Calls

no outgoing calls