Skip to content

Commit

Permalink
Merge pull request #46 from tillahoffmann/apply
Browse files Browse the repository at this point in the history
Clarify inplace modification of context (fixes #43).
  • Loading branch information
tillahoffmann committed Oct 29, 2019
2 parents 2e71d70 + 61d8bc8 commit bf9ce55
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
8 changes: 8 additions & 0 deletions pythonflow/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ def normalize_context(self, context, **kwargs):
"""
Normalize a context by replacing all operation names with operation instances.
.. note::
This function modifies the context in place. Use :code:`context=context.copy()` to avoid
the context being modified.
Parameters
----------
context : dict[Operation or str, object]
Expand Down Expand Up @@ -127,6 +131,10 @@ def apply(self, fetches, context=None, *, callback=None, **kwargs):
"""
Evaluate one or more operations given a context.
.. note::
This function modifies the context in place. Use :code:`context=context.copy()` to avoid
the context being modified.
Parameters
----------
fetches : list[str or Operation] or str or Operation
Expand Down
8 changes: 5 additions & 3 deletions pythonflow/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ class conditional(Operation): # pylint: disable=C0103,W0223
"""
Return `x` if `predicate` is `True` and `y` otherwise.
Note that the conditional operation will only execute one branch of the computation graph
depending on `predicate`.
.. note::
The conditional operation will only execute one branch of the computation graph depending on
`predicate`.
"""
def __init__(self, predicate, x, y=None, *, length=None, name=None, dependencies=None): # pylint: disable=W0235
super(conditional, self).__init__(predicate, x, y,
Expand All @@ -67,7 +68,8 @@ class try_(Operation): # pylint: disable=C0103,W0223
Try to evaluate `operation`, fall back to alternative operations in `except_`, and ensure that
`finally_` is evaluated.
Note that the alternative operations will only be executed if the target operation fails.
.. note::
The alternative operations will only be executed if the target operation fails.
Parameters
----------
Expand Down

0 comments on commit bf9ce55

Please sign in to comment.