MCPcopy
hub / github.com/dask/dask / test_array_delayed_complex_optimization

Function test_array_delayed_complex_optimization

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

Source from the content-addressed store, hash-verified

569
570
571def test_array_delayed_complex_optimization():
572 # Ensure that when multiple collections are passed to a Delayed function,
573 # they are optimized together
574 np = pytest.importorskip("numpy")
575 pytest.importorskip("dask.array")
576 from dask.array.core import from_func
577 from dask.array.utils import assert_eq
578
579 called = False
580
581 def only_once():
582 nonlocal called
583 if called:
584 raise RuntimeError("Already executed")
585
586 called = True
587 return np.arange(100).reshape((10, 10))
588
589 darr = from_func(only_once, shape=(10, 10), dtype=int)
590 a = darr + 1
591 b = darr + 2
592 val = delayed(sum)([a, b, 1])
593 assert isinstance(val, Delayed)
594 np_arr = np.arange(100).reshape((10, 10))
595 assert_eq(val.compute(), (np_arr + 1) + (np_arr + 2) + 1)
596
597
598def test_array_delayed_complex_optimization_kwargs():

Callers

nothing calls this directly

Calls 6

from_funcFunction · 0.90
delayedFunction · 0.90
assert_eqFunction · 0.90
reshapeMethod · 0.80
arangeMethod · 0.45
computeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…