MCPcopy
hub / github.com/dask/dask / test_fuse

Function test_fuse

dask/tests/test_optimization.py:52–167  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

50
51
52def test_fuse():
53 fuse = fuse2 # tests both `fuse` and `fuse_linear`
54 d = {
55 "w": (inc, "x"),
56 "x": (inc, "y"),
57 "y": (inc, "z"),
58 "z": (add, "a", "b"),
59 "a": 1,
60 "b": 2,
61 }
62 assert fuse(d, rename_keys=False) == with_deps(
63 {"w": (inc, (inc, (inc, (add, "a", "b")))), "a": 1, "b": 2}
64 )
65 assert fuse(d, rename_keys=True) == with_deps(
66 {
67 "z-y-x-w": (inc, (inc, (inc, (add, "a", "b")))),
68 "a": 1,
69 "b": 2,
70 "w": "z-y-x-w",
71 }
72 )
73
74 d = {
75 "NEW": (inc, "y"),
76 "w": (inc, "x"),
77 "x": (inc, "y"),
78 "y": (inc, "z"),
79 "z": (add, "a", "b"),
80 "a": 1,
81 "b": 2,
82 }
83 assert fuse(d, rename_keys=False) == with_deps(
84 {
85 "NEW": (inc, "y"),
86 "w": (inc, (inc, "y")),
87 "y": (inc, (add, "a", "b")),
88 "a": 1,
89 "b": 2,
90 }
91 )
92 assert fuse(d, rename_keys=True) == with_deps(
93 {
94 "NEW": (inc, "z-y"),
95 "x-w": (inc, (inc, "z-y")),
96 "z-y": (inc, (add, "a", "b")),
97 "a": 1,
98 "b": 2,
99 "w": "x-w",
100 "y": "z-y",
101 }
102 )
103
104 d = {
105 "v": (inc, "y"),
106 "u": (inc, "w"),
107 "w": (inc, "x"),
108 "x": (inc, "y"),
109 "y": (inc, "z"),

Callers

nothing calls this directly

Calls 2

fuseFunction · 0.90
with_depsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…