Skip to content

Commit 2e93e48

Browse files
authored
Merge pull request #44 from hyroai/allow-compose_unary-to-a-graph-destination
allow compose_unary to a graph destination
2 parents d86d7a0 + 41f6d46 commit 2e93e48

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

computation_graph/composers/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,9 @@ def _infer_composition_edges(
217217
gamla.unique,
218218
gamla.filter(
219219
gamla.compose_left(
220-
unbound_signature, lambda signature: key in signature.kwargs
220+
unbound_signature,
221+
lambda sig: key in sig.kwargs
222+
or (key is None and signature.is_unary(sig)),
221223
)
222224
),
223225
# Do not add edges to nodes from source that are already present in destination (cycle).

computation_graph/composers/composers_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
from computation_graph import composers, graph_runners
22

33

4+
def test_unary_composition_with_graph_destination():
5+
result = graph_runners.nullary_infer_sink(
6+
composers.compose_unary(
7+
composers.compose_left(lambda: 1, lambda a, b: a - b, key="a"), lambda: 2
8+
)
9+
)
10+
11+
assert result == -1
12+
13+
414
def test_ambiguity_does_not_blow_up():
515
counter = 0
616

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
setuptools.setup(
88
name="computation-graph",
99
python_requires=">=3",
10-
version="36",
10+
version="37",
1111
long_description=_LONG_DESCRIPTION,
1212
long_description_content_type="text/markdown",
1313
packages=setuptools.find_namespace_packages(),

0 commit comments

Comments
 (0)