| 465 | |
| 466 | |
| 467 | def 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 | |
| 498 | def test_blockwise_diamond_fusion(): |