Print current iteration even if target is unknown
* Print current iteration even if target is unknown
* Compact string formatting in a single step
...to address comments.
* Remove redundant computation of %width for self.target
@@ -302,8 +302,8 @@ class Progbar(object):
if self.target is not -1:
numdigits = int(np.floor(np.log10(self.target))) + 1
- barstr = '%%%dd/%%%dd [' % (numdigits, numdigits)
- bar = barstr % (current, self.target)
+ barstr = '%%%dd/%d [' % (numdigits, self.target)
+ bar = barstr % current
prog = float(current) / self.target
prog_width = int(self.width * prog)
if prog_width > 0:
@@ -314,6 +314,9 @@ class Progbar(object):
bar += '='
bar += ('.' * (self.width - prog_width))
bar += ']'
+ else:
+ bar = '%7d/Unknown' % current
+
sys.stdout.write(bar)
self.total_width = len(bar)
