diff --git a/examples/parallel_bars.py b/examples/parallel_bars.py index 98eb06e0..7efccd0c 100644 --- a/examples/parallel_bars.py +++ b/examples/parallel_bars.py @@ -8,7 +8,7 @@ L = list(range(9)) def progresser(n): - interval = 0.001 / (n + 2) + interval = 0.001 / (len(L) - n + 2) total = 5000 text = "#{}, est. {:<04.2}s".format(n, interval * total) for _ in tqdm(range(total), desc=text, position=n): @@ -21,9 +21,9 @@ if __name__ == '__main__': initializer=tqdm.set_lock, initargs=(RLock(),)) p.map(progresser, L) - print("\n" * (len(L) - 2)) + print("\n" * len(L)) # alternatively, on UNIX, just use the default internal lock p = Pool(len(L)) p.map(progresser, L) - print("\n" * (len(L) - 2)) + print("\n" * len(L)) diff --git a/tqdm/_tqdm.py b/tqdm/_tqdm.py index b8cf7e9e..2fb31bdc 100755 --- a/tqdm/_tqdm.py +++ b/tqdm/_tqdm.py @@ -1107,13 +1107,13 @@ Please use `tqdm_gui(...)` instead of `tqdm(..., gui=True)` # stats for overall rate (no weighted average) self.avg_time = None self.sp(self.__repr__()) - if pos: + if pos is not None: self.moveto(-pos) else: fp_write('\n') else: self.sp('') # clear up last bar - if pos: + if pos is not None: self.moveto(-pos) else: fp_write('\r')