Skip to content

Commit 0588665

Browse files
author
Peter Combs
committed
Smarter, unified progress bar
1 parent 39ef1a6 commit 0588665

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

PlotUtils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,9 @@ def svg_heatmap(data, filename, row_labels=None, box_size=4,
294294
y_diff = 0
295295
if progress_bar:
296296
from progressbar import ProgressBar
297-
iterator = ProgressBar()(list(zip(data, cmap, data_names,
298-
norm_rows_by, spacers)))
297+
iterator = zip(data, cmap, data_names, norm_rows_by, spacers)
298+
pbar = ProgressBar(maxval=len(iterator)*rows).start()
299+
pbar_val = 0
299300
else:
300301
iterator = zip(data, cmap, data_names, norm_rows_by, spacers)
301302

@@ -354,6 +355,9 @@ def svg_heatmap(data, filename, row_labels=None, box_size=4,
354355
box_size = total_width / float(new_cols)
355356

356357
for i in range(rows):
358+
if progress_bar:
359+
pbar.update(pbar_val)
360+
pbar_val += 1
357361
prefix = col_labels[0][:col_labels[0].find(col_sep)]
358362
if cmap_by_prefix:
359363
c_cmap = cmap_by_prefix(prefix)
@@ -430,4 +434,5 @@ def svg_heatmap(data, filename, row_labels=None, box_size=4,
430434
for i in range(rows):
431435
dwg.add(dwg.text(row_labels[i],
432436
(x_start, y_start + i*box_height+box_height),))
437+
pbar.finish()
433438
dwg.saveas(filename)

0 commit comments

Comments
 (0)