Skip to content

Commit 70de90a

Browse files
authored
Stop allowing set_working_tape to be used as a function decorator (#242)
The previous functionality did not work as expected because the __init__ method was evaluated eagerly at import, instead of per function invocation.
1 parent 40b8eeb commit 70de90a

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

pyadjoint/tape.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,12 @@ def continue_annotation():
3030
return _annotation_enabled
3131

3232

33-
class set_working_tape(ContextDecorator):
33+
class set_working_tape:
3434
"""Set a new tape as the working tape.
3535
3636
This class can be used in three ways:
3737
1) as a free function to replace the working tape,
3838
2) as a context manager within which a new tape is set as the working tape,
39-
3) as a function decorator so that the new tape is set only inside the function.
4039
4140
Example usage:
4241
@@ -55,22 +54,6 @@ class set_working_tape(ContextDecorator):
5554
with set_working_tape() as tape:
5655
...
5756
58-
3) Set the local tape inside a decorated function.
59-
The two functions below are equivalent:
60-
61-
.. highlight:: python
62-
.. code-block:: python
63-
64-
@set_working_tape()
65-
def decorated_function(*args, **kwargs):
66-
# do something here
67-
return ReducedFunctional(functional, control)
68-
69-
def context_function(*args, **kwargs):
70-
with set_working_tape():
71-
# do something here
72-
return ReducedFunctional(functional, control)
73-
7457
"""
7558

7659
def __init__(self, tape=None, **tape_kwargs):

0 commit comments

Comments
 (0)