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

Method _layer

dask/_expr.py:263–297  ·  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

261 )
262
263 def _layer(self) -> dict:
264 """The graph layer added by this expression.
265
266 Simple expressions that apply one task per partition can choose to only
267 implement `Expr._task` instead.
268
269 Examples
270 --------
271 >>> class Add(Expr):
272 ... def _layer(self):
273 ... return {
274 ... name: Task(
275 ... name,
276 ... operator.add,
277 ... TaskRef((self.left._name, i)),
278 ... TaskRef((self.right._name, i))
279 ... )
280 ... for i, name in enumerate(self.__dask_keys__())
281 ... }
282
283 Returns
284 -------
285 layer: dict
286 The Dask task graph added by this expression
287
288 See Also
289 --------
290 Expr._task
291 Expr.__dask_graph__
292 """
293
294 return {
295 (self._name, i): self._task((self._name, i), i)
296 for i in range(self.npartitions)
297 }
298
299 def rewrite(self, kind: str, rewritten):
300 """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