MCPcopy
hub / github.com/dask/dask / test_array_delayed

Function test_array_delayed

dask/tests/test_delayed.py:550–568  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

548
549@pytest.mark.filterwarnings("ignore:The dask.delayed:UserWarning")
550def test_array_delayed():
551 np = pytest.importorskip("numpy")
552 da = pytest.importorskip("dask.array")
553
554 arr = np.arange(100).reshape((10, 10))
555 darr = da.from_array(arr, chunks=(5, 5))
556 val = delayed(sum)([arr, darr, 1])
557 assert isinstance(val, Delayed)
558 assert np.allclose(val.compute(), arr + arr + 1)
559 assert val.sum().compute() == (arr + arr + 1).sum()
560 assert val[0, 0].compute() == (arr + arr + 1)[0, 0]
561
562 task, dsk = to_task_dask(darr)
563 assert not darr.dask.keys() - dsk.keys()
564 diff = dsk.keys() - darr.dask.keys()
565 assert len(diff) == 1
566
567 delayed_arr = delayed(darr)
568 assert (delayed_arr.compute() == arr).all()
569
570
571def test_array_delayed_complex_optimization():

Callers

nothing calls this directly

Calls 8

delayedFunction · 0.90
to_task_daskFunction · 0.90
reshapeMethod · 0.80
arangeMethod · 0.45
computeMethod · 0.45
sumMethod · 0.45
keysMethod · 0.45
allMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…