Skip to content

Commit

Permalink
Merge pull request #141 from dolfin-adjoint/dolci/progressbar_issues
Browse files Browse the repository at this point in the history
Dolci/progressbar issues
  • Loading branch information
dham committed Mar 20, 2024
2 parents 4616f3f + 6bc1d7f commit 908b636
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 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,7 +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:
bar.next()
if bar:
bar.next()
# Get the blocks of the current step.
current_step = self.tape.timesteps[step]
for block in current_step:
Expand Down Expand Up @@ -290,7 +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:
bar.next()
if bar:
bar.next()
# 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 908b636

Please sign in to comment.