mirror of https://github.com/tqdm/tqdm.git
Fix overlap of nested progressbar
The problem is exhibitable with the modified examples/parallel_bars.py, the fix is simple check pos is not None rather otherwise will fall into the trap of 0.
This commit is contained in:
parent
f66d9923d1
commit
74e6eba4ef
|
@ -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))
|
||||
|
|
|
@ -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')
|
||||
|
|
Loading…
Reference in New Issue