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

Function test_array_delayed_complex_optimization

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

Source from the content-addressed store, hash-verified

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