Last active
October 4, 2024 17:16
-
-
Save mh0w/b4ca64be820138ac356d486f2c82757a to your computer and use it in GitHub Desktop.
tqdm and trange
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tqdm import tqdm, trange | |
import time # used in this example to delay progress | |
# Initiate 0-100 progress bar, start at 15, with format shown below | |
# One bar will be shown and updated | |
# Will display one 0-100 progress bar, showing just percentage and the bar | |
pbar = tqdm(total=100, initial=15, bar_format='Loading: {percentage:3.0f}%|{bar:10}') | |
# Loading: 15%|█▌ | |
time.sleep(2) | |
pbar.update(35) | |
# Loading: 50%|█████ | |
time.sleep(2) | |
pbar.update(35) | |
# Loading: 85%|████████▌ | |
time.sleep(2) | |
pbar.update(15) | |
# Loading: 100%|██████████ | |
pbar.close() | |
# Loading: 100%|██████████ | |
########## | |
# trange # | |
########## | |
# 100.000%|██████████| 100000000/100000000 [00:14<00:00] | |
for i in trange(int(1e8), bar_format = "{desc}: {percentage:.3f}%|{bar}| {n_fmt}/{total_fmt} [{elapsed}<{remaining}]"): | |
pass | |
# | |
# 100000000/100000000|██████████| [00:15 elapsed, 00:00 remaining] | |
for i in trange(int(1e8), bar_format = "{desc}: {n_fmt}/{total_fmt}|{bar}| [{elapsed} elapsed, {remaining} remaining]"): | |
pass | |
# Completed 100000000/100000000|██████████| [00:15 elapsed, 00:00 remaining] | |
for i in trange(int(1e8), bar_format = "Completed {desc}: {n_fmt}/{total_fmt}|{bar}| [{elapsed} elapsed, {remaining} remaining]"): | |
pass | |
# SEO terms: progress bar, progression, %, percent, percentage, percentages, s, seconds, m, | |
# min, mins, minute, minutes, eta, complete, duration |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment