Skip to content

Commit

Permalink
move if-else clause autside of update op
Browse files Browse the repository at this point in the history
  • Loading branch information
rasbt committed Nov 7, 2017
1 parent 5402431 commit b79487b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions mlxtend/utils/counter.py
Expand Up @@ -64,6 +64,12 @@ def __init__(self, stderr=False, start_newline=True, precision=0,
else:
self.precision = '%d'
self.name = name

if self.name is None:
self._print_name = ''
else:
self._print_name = '%s: ' % self.name

self.start_time = time.time()
self.curr_iter = 0
if start_newline:
Expand All @@ -78,8 +84,6 @@ def update(self):
out = '%d iter | %s sec' % (self.curr_iter,
self.precision % (self.end_time
- self.start_time))
if self.name is None:
self.stream.write('\r%s' % out)
else:
self.stream.write('\r %s: %s' % (self.name, out))

self.stream.write('\r%s%s' % (self._print_name, out))
self.stream.flush()

0 comments on commit b79487b

Please sign in to comment.