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

Function test_optimize_blockwise_custom_annotations

dask/array/tests/test_atop.py:467–495  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

465
466
467def test_optimize_blockwise_custom_annotations():
468 a = da.ones(10, chunks=(5,))
469 b = a + 1
470
471 with dask.annotate(qux="foo"):
472 c = b + 2
473 d = c + 3
474
475 with dask.annotate(qux="baz"):
476 e = d + 4
477 f = e + 5
478
479 g = f + 6
480
481 dsk = da.optimization.optimize_blockwise(g.dask)
482
483 annotations = (
484 layer.annotations
485 for layer in dsk.layers.values()
486 if isinstance(layer, Blockwise)
487 )
488 annotations = collections.Counter(
489 tuple(a.items()) if type(a) is dict else a for a in annotations
490 )
491
492 assert len(annotations) == 3
493 assert annotations[None] == 2
494 assert annotations[(("qux", "baz"),)] == 1
495 assert annotations[(("qux", "foo"),)] == 1
496
497
498def test_blockwise_diamond_fusion():

Callers

nothing calls this directly

Calls 3

onesMethod · 0.45
valuesMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected