Skip to content

Commit 908b636

Browse files
authored
Merge pull request #141 from dolfin-adjoint/dolci/progressbar_issues
Dolci/progressbar issues
2 parents 4616f3f + 6bc1d7f commit 908b636

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

pyadjoint/checkpointing.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,7 @@ def evaluate_adj(self, last_block, markings):
214214
if self.mode not in (Mode.EVALUATED, Mode.FINISHED_RECORDING):
215215
raise CheckpointError("Evaluate Functional before calling gradient.")
216216

217-
with self.tape.progress_bar("Evaluating Adjoint",
218-
max=self.timesteps) as bar:
217+
with self.tape.progress_bar("Evaluating Adjoint", max=self.timesteps) as bar:
219218
if self.adjoint_evaluated:
220219
reverse_iterator = iter(self.reverse_schedule)
221220
while not isinstance(self._current_action, EndReverse):
@@ -257,7 +256,8 @@ def process_operation(self, cp_action, bar, **kwargs):
257256
def _(self, cp_action, bar, functional=None, **kwargs):
258257
for step in cp_action:
259258
if self.mode == Mode.RECOMPUTE:
260-
bar.next()
259+
if bar:
260+
bar.next()
261261
# Get the blocks of the current step.
262262
current_step = self.tape.timesteps[step]
263263
for block in current_step:
@@ -290,7 +290,8 @@ def _(self, cp_action, bar, functional=None, **kwargs):
290290
@process_operation.register(Reverse)
291291
def _(self, cp_action, bar, markings, functional=None, **kwargs):
292292
for step in cp_action:
293-
bar.next()
293+
if bar:
294+
bar.next()
294295
# Get the blocks of the current step.
295296
current_step = self.tape.timesteps[step]
296297
for block in reversed(current_step):

pyadjoint/tape.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ def __init__(self, *args, **kwargs):
703703
def __enter__(self):
704704
pass
705705

706-
def __exit__(self):
706+
def __exit__(self, *args, **kwargs):
707707
pass
708708

709709
def iter(self, iterator):

0 commit comments

Comments
 (0)