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

Method _layer

dask/_expr.py:273–307  ·  view source on GitHub ↗

The graph layer added by this expression. Simple expressions that apply one task per partition can choose to only implement `Expr._task` instead. Examples -------- >>> class Add(Expr): ... def _layer(self): ... return { ..

(self)

Source from the content-addressed store, hash-verified

271 )
272
273 def _layer(self) -> dict:
274 """The graph layer added by this expression.
275
276 Simple expressions that apply one task per partition can choose to only
277 implement `Expr._task` instead.
278
279 Examples
280 --------
281 >>> class Add(Expr):
282 ... def _layer(self):
283 ... return {
284 ... name: Task(
285 ... name,
286 ... operator.add,
287 ... TaskRef((self.left._name, i)),
288 ... TaskRef((self.right._name, i))
289 ... )
290 ... for i, name in enumerate(self.__dask_keys__())
291 ... }
292
293 Returns
294 -------
295 layer: dict
296 The Dask task graph added by this expression
297
298 See Also
299 --------
300 Expr._task
301 Expr.__dask_graph__
302 """
303
304 return {
305 (self._name, i): self._task((self._name, i), i)
306 for i in range(self.npartitions)
307 }
308
309 def rewrite(self, kind: str, rewritten):
310 """Rewrite an expression

Callers 3

__dask_graph__Method · 0.45
_layerMethod · 0.45
__dask_graph__Method · 0.45

Calls 1

_taskMethod · 0.95

Tested by

no test coverage detected