Skip to content

Commit

Permalink
Make the progress bar print optional.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ig-dolci committed Mar 18, 2024
1 parent 6ef3dae commit 6bc1d7f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
11 changes: 3 additions & 8 deletions pyadjoint/checkpointing.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,7 @@ def evaluate_adj(self, last_block, markings):
if self.mode not in (Mode.EVALUATED, Mode.FINISHED_RECORDING):
raise CheckpointError("Evaluate Functional before calling gradient.")

with self.tape.progress_bar("Evaluating Adjoint",
max=self.timesteps) as bar:
with self.tape.progress_bar("Evaluating Adjoint", max=self.timesteps) as bar:
if self.adjoint_evaluated:
reverse_iterator = iter(self.reverse_schedule)
while not isinstance(self._current_action, EndReverse):
Expand Down Expand Up @@ -257,10 +256,8 @@ def process_operation(self, cp_action, bar, **kwargs):
def _(self, cp_action, bar, functional=None, **kwargs):
for step in cp_action:
if self.mode == Mode.RECOMPUTE:
try:
if bar:
bar.next()
except AttributeError:
pass
# Get the blocks of the current step.
current_step = self.tape.timesteps[step]
for block in current_step:
Expand Down Expand Up @@ -293,10 +290,8 @@ def _(self, cp_action, bar, functional=None, **kwargs):
@process_operation.register(Reverse)
def _(self, cp_action, bar, markings, functional=None, **kwargs):
for step in cp_action:
try:
if bar:
bar.next()
except AttributeError:
pass
# Get the blocks of the current step.
current_step = self.tape.timesteps[step]
for block in reversed(current_step):
Expand Down
2 changes: 1 addition & 1 deletion pyadjoint/tape.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ def __init__(self, *args, **kwargs):
def __enter__(self):
pass

def __exit__(self):
def __exit__(self, *args, **kwargs):
pass

def iter(self, iterator):
Expand Down

0 comments on commit 6bc1d7f

Please sign in to comment.