Skip to content

Commit

Permalink
Display container only in notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
atharva-2001 committed Jul 29, 2021
1 parent 69556f2 commit 7d2d6ae
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions tardis/montecarlo/montecarlo_numba/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
dynamic_ncols=True,
bar_format="{bar}{percentage:3.0f}% of packets propagated, iteration 0/?",
)
packet_pbar.container.close()
if type(packet_pbar).__name__ == "tqdm_notebook":
packet_pbar.container.close()


def update_packet_pbar(i, current_iteration, total_iterations, total_packets):
Expand All @@ -64,13 +65,14 @@ def update_packet_pbar(i, current_iteration, total_iterations, total_packets):
# set bar total when first called
if packet_pbar.total == None:
packet_pbar.ncols = "100%"
packet_pbar.container = packet_pbar.status_printer(
packet_pbar.fp,
packet_pbar.total,
packet_pbar.desc,
packet_pbar.ncols,
)
display(packet_pbar.container)
if type(packet_pbar).__name__ == "tqdm_notebook":
packet_pbar.container = packet_pbar.status_printer(
packet_pbar.fp,
packet_pbar.total,
packet_pbar.desc,
packet_pbar.ncols,
)
display(packet_pbar.container)
packet_pbar.reset(total=total_packets)
packet_pbar.display()

Expand All @@ -84,7 +86,7 @@ def update_packet_pbar(i, current_iteration, total_iterations, total_packets):
+ str(total_iterations)
)

if type(packet_pbar) != tqdm.tqdm:
if type(packet_pbar).__name__ == "tqdm_notebook":
# stop displaying last container
packet_pbar.container.close()

Expand Down

0 comments on commit 7d2d6ae

Please sign in to comment.