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

Function test_annotations_blockwise_unpack

dask/tests/test_distributed.py:453–481  ·  view source on GitHub ↗
(c, s, a, b)

Source from the content-addressed store, hash-verified

451
452@gen_cluster(client=True)
453async def test_annotations_blockwise_unpack(c, s, a, b):
454 pytest.importorskip("numpy")
455 da = pytest.importorskip("dask.array")
456 np = pytest.importorskip("numpy")
457 from dask.array.utils import assert_eq
458
459 # A flaky doubling function -- need extra args because it is called before
460 # application to establish dtype/meta.
461 scale = varying([ZeroDivisionError("one"), ZeroDivisionError("two"), 2, 2])
462
463 def flaky_double(x):
464 return scale() * x
465
466 # A reliable double function.
467 def reliable_double(x):
468 return 2 * x
469
470 x = da.ones(10, chunks=(5,))
471
472 # The later annotations should not override the earlier annotations
473 with dask.annotate(retries=2):
474 y = x.map_blocks(flaky_double, meta=np.array((), dtype=np.float64))
475 with dask.annotate(retries=0):
476 z = y.map_blocks(reliable_double, meta=np.array((), dtype=np.float64))
477
478 with dask.config.set(optimization__fuse__active=False):
479 z = await c.compute(z)
480
481 assert_eq(z, np.ones(10) * 4.0)
482
483
484@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 5

assert_eqFunction · 0.90
setMethod · 0.80
onesMethod · 0.45
map_blocksMethod · 0.45
computeMethod · 0.45

Tested by

no test coverage detected