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

Function test_annotations_blockwise_unpack

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

Source from the content-addressed store, hash-verified

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