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

Function test_to_task_dask

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

Source from the content-addressed store, hash-verified

46
47@pytest.mark.filterwarnings("ignore:The dask.delayed:UserWarning")
48def test_to_task_dask():
49 a = delayed(1, name="a")
50 b = delayed(2, name="b")
51 task, dask = to_task_dask([a, b, 3])
52 assert task == ["a", "b", 3]
53
54 task, dask = to_task_dask((a, b, 3))
55 assert task == (tuple, ["a", "b", 3])
56 assert dict(dask) == merge(a.dask, b.dask)
57
58 task, dask = to_task_dask({a: 1, b: 2})
59 assert task == (dict, [["b", 2], ["a", 1]]) or task == (dict, [["a", 1], ["b", 2]])
60 assert dict(dask) == merge(a.dask, b.dask)
61
62 f = namedtuple("f", ["a", "b", "c"])
63 x = f(a, b, 3)
64 task, dask = to_task_dask(x)
65 assert task == (f, "a", "b", 3)
66 assert dict(dask) == merge(a.dask, b.dask)
67
68 task, dask = to_task_dask(slice(a, b, 3))
69 assert task == (slice, "a", "b", 3)
70 assert dict(dask) == merge(a.dask, b.dask)
71
72 # Issue https://github.com/dask/dask/issues/2107
73 class MyClass(dict):
74 pass
75
76 task, dask = to_task_dask(MyClass())
77 assert type(task) is MyClass
78 assert dict(dask) == {}
79
80 # Custom dask objects
81 x = Tuple({"a": 1, "b": 2, "c": (add, "a", "b")}, ["a", "b", "c"])
82 task, dask = to_task_dask(x)
83 assert task in dask
84 f = dask.pop(task)
85 assert f.func == tuple
86 assert f.dependencies == {"a", "b", "c"}
87 assert dask == x._dask
88
89
90def test_delayed():

Callers

nothing calls this directly

Calls 7

delayedFunction · 0.90
to_task_daskFunction · 0.90
MyClassClass · 0.85
popMethod · 0.80
fFunction · 0.70
TupleClass · 0.70
mergeFunction · 0.50

Tested by

no test coverage detected