Skip to content

Commit

Permalink
Merge pull request #34 from tillahoffmann/args
Browse files Browse the repository at this point in the history
Add kwargs to placeholder.
  • Loading branch information
tillahoffmann committed Jun 29, 2018
2 parents ed28c8c + c760fe1 commit 2901619
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pythonflow/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class placeholder(Operation): # pylint: disable=C0103,R0903
"""
Placeholder that needs to be given in the context to be evaluated.
"""
def __init__(self, name=None):
super(placeholder, self).__init__(name=name)
def __init__(self, name=None, **kwargs):
super(placeholder, self).__init__(name=name, **kwargs)

def _evaluate(self): # pylint: disable=W0221
raise ValueError("missing value for placeholder '%s'" % self.name)
Expand Down
8 changes: 8 additions & 0 deletions tests/test_pythonflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,3 +527,11 @@ def test_stack_trace():
raise RuntimeError("did not raise ZeroDivisionError")
except ZeroDivisionError as ex:
assert isinstance(ex.__cause__, pf.EvaluationError)


def test_placeholder_with_kwargs():
with pf.Graph() as graph:
a = pf.placeholder(length=2)
b, c = a

assert graph([b, c], {a: [1, 2]}) == (1, 2)

0 comments on commit 2901619

Please sign in to comment.