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

Function test_array_delayed_complex_optimization_kwargs

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

Source from the content-addressed store, hash-verified

595
596
597def test_array_delayed_complex_optimization_kwargs():
598 # Ensure that collections that if multiple collections are passed to a
599 # Delayed function that they are optimized together
600 np = pytest.importorskip("numpy")
601 pytest.importorskip("dask.array")
602 from dask.array.core import from_func
603 from dask.array.utils import assert_eq
604
605 called = False
606
607 def only_once():
608 nonlocal called
609 if called:
610 raise RuntimeError("Already executed")
611
612 called = True
613 return np.arange(100).reshape((10, 10))
614
615 darr = from_func(only_once, shape=(10, 10), dtype=int)
616 a = darr + 1
617 b = darr + 2
618
619 def sum_kwargs_only(*, a, b, c):
620 return sum([a, b, c])
621
622 val = delayed(sum_kwargs_only)(a=a, b=b, c=1)
623 assert isinstance(val, Delayed)
624 np_arr = np.arange(100).reshape((10, 10))
625 assert_eq(val.compute(), (np_arr + 1) + (np_arr + 2) + 1)
626
627
628def test_array_bag_delayed():

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