MCPcopy
hub / github.com/dask/dask / _layer

Method _layer

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

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