Skip to content

Commit

Permalink
remove fuse_selections
Browse files Browse the repository at this point in the history
  • Loading branch information
mrocklin committed Oct 10, 2019
1 parent cbba42b commit b1dca7d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 60 deletions.
47 changes: 0 additions & 47 deletions dask/optimization.py
Expand Up @@ -376,53 +376,6 @@ def functions_of(task):
return funcs


def fuse_selections(dsk, head1, head2, merge):
"""Fuse selections with lower operation.
Handles graphs of the form:
``{key1: (head1, key2, ...), key2: (head2, ...)}``
Parameters
----------
dsk : dict
dask graph
head1 : function
The first element of task1
head2 : function
The first element of task2
merge : function
Takes ``task1`` and ``task2`` and returns a merged task to
replace ``task1``.
Examples
--------
>>> def load(store, partition, columns):
... pass
>>> dsk = {'x': (load, 'store', 'part', ['a', 'b']),
... 'y': (getitem, 'x', 'a')}
>>> merge = lambda t1, t2: (load, t2[1], t2[2], t1[2])
>>> dsk2 = fuse_selections(dsk, getitem, load, merge)
>>> cull(dsk2, 'y')[0]
{'y': (<function load at ...>, 'store', 'part', 'a')}
"""
dsk2 = dict()
for k, v in dsk.items():
try:
if (
istask(v)
and v[0] == head1
and v[1] in dsk
and istask(dsk[v[1]])
and dsk[v[1]][0] == head2
):
dsk2[k] = merge(v, dsk[v[1]])
else:
dsk2[k] = v
except TypeError:
dsk2[k] = v
return dsk2


def default_fused_keys_renamer(keys):
"""Create new keys for ``fuse`` tasks"""
it = reversed(keys)
Expand Down
13 changes: 0 additions & 13 deletions dask/tests/test_optimization.py
@@ -1,6 +1,5 @@
import itertools
import pickle
from operator import getitem
from functools import partial

import pytest
Expand All @@ -14,7 +13,6 @@
inline,
inline_functions,
functions_of,
fuse_selections,
fuse_linear,
SubgraphCallable,
)
Expand Down Expand Up @@ -306,17 +304,6 @@ def test_functions_of():
assert functions_of((a,)) == set([a])


def test_fuse_selections():
def load(*args):
pass

dsk = {"x": (load, "store", "part", ["a", "b"]), "y": (getitem, "x", "a")}
merge = lambda t1, t2: (load, t2[1], t2[2], t1[2])
dsk2 = fuse_selections(dsk, getitem, load, merge)
dsk2, dependencies = cull(dsk2, "y")
assert dsk2 == {"y": (load, "store", "part", "a")}


def test_inline_cull_dependencies():
d = {"a": 1, "b": "a", "c": "b", "d": ["a", "b", "c"], "e": (add, (len, "d"), "a")}

Expand Down

0 comments on commit b1dca7d

Please sign in to comment.