A replacement for tqdm
Project description
What is this?
I wanted a light, clean, configurable alternative to tqdm. So I made one, complete with animations.
How do I use this?
pip install informative_iterator
from informative_iterator import ProgressBar
import time
#
# example 1
#
for progress, each_element in ProgressBar([ 1, 2, 3, "any iterable thing" ]):
time.sleep(0.002)
# example output:
# [>..................................] 0.00% | 0/1000 | started: 13:18:32 | eta: ________ | remaining: ________ |
# example output:
# [==============>....................] 42.50% | 425/1000 | started: 13:18:32 | eta: 13:18:44 | remaining: 0:07sec |
# example output:
# [================================>..] 93.10% | 931/1000 | started: 13:18:32 | eta: 13:18:44 | remaining: 0:01sec |
# example output:
# Done in 0:12sec at 13:18:44
#
# example 2
#
import random
def custom_iterable():
while True:
yield random.random()
for progress, each in ProgressBar(custom_iterable(), iterations=10000):
time.sleep(0.002)
#
# example 3
#
for progress, each in ProgressBar(10000):
time.sleep(0.002)
# index, just like using enumerate()
print('progress.index = ', progress.index)
# percent with two decimal places. ex: 99.5
print('progress.percent = ', progress.percent)
# the output of time.time() for this iteration (seconds since unix epoch)
print('progress.time = ', progress.time)
# boolean (updates dont always get printed every iteration)
print('progress.updated = ', progress.updated)
# int, doesn't change with each iteration: its the size of the iterator
print('progress.total_iterations = ', progress.total_iterations)
#
# example 4
#
# update ~30 times a second for smooth looking progress
for progress, each in ProgressBar(10000, seconds_per_print=0.03):
time.sleep(0.002)
#
# example 5
#
# have all progress bars default to trying to update update ~30 times a second
ProgressBar.configure(
seconds_per_print=0.03,
)
for progress, each in ProgressBar(10000):
time.sleep(0.002)
#
# example 6
#
ProgressBar.configure(
# all the options (these exist as arguments for ProgressBar as well)
layout=[ 'title', 'bar', 'percent', 'spacer', 'fraction', 'spacer', 'start_time', 'spacer', 'end_time', 'spacer', 'remaining_time', 'spacer', ],
spacer=" | ",
minmal=False, # False => defaults to normal layout
minimal_layout=[ 'title', 'bar', 'spacer', 'end_time', 'spacer', ],
inline=True,
disable_logging=False, # turn off all the output
progress_bar_size=35, # 35 characters
seconds_per_print=1, # print every second
percent_per_print=10, # And print every 10% of progress
)
for progress, each in ProgressBar(10000):
time.sleep(0.002)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for informative_iterator-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5cb41fb7bc6534e33ed60c5011541fc4e7f0123e9b24cbc0f16d88a684eee8e |
|
MD5 | df693982a98c6b358f0bd3fe4babee3f |
|
BLAKE2b-256 | e8508f62bd7ab2611df50eb171924869f01b785a4f1c8624fd9e92e9d2dd2d98 |
Close
Hashes for informative_iterator-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a1e79bc173c944e0220e520de858189b04ff4be26b9496d4c2000f0313b8833 |
|
MD5 | 1faea7bc725641472df3bcbf777d8c8c |
|
BLAKE2b-256 | a1b6ca7c30eb1f9d46521158b071e55e4d672a4f2950c5fd0932582d1efa97db |