Skip to main content

Python library for Data Science

Project description

ProgressBar

Let us consider a few examples explaining how to use the ProgressBar class from the module progress:

from deeppy.progress import ProgressBar
from time import sleep

bar = ProgressBar(max=20, width=50, elapsed=True)

for i in range(10):
    sleep(1)
    bar.next()

bar.finish()
print()

for i in range(15):
    sleep(1)
    bar.next()
Out:
Processing: [#########################                         ] 50% [elapsed: 10s; ETA: 10s]
Processing: [#####################################             ] 75% [elapsed: 15s; ETA: 5s]

The class supports the context management protocol and can be used with the with statement. Alternative bar formats are also available:

with ProgressBar("Charging", max=20, width=50) as bar:
    for i in range(10):
        sleep(1)
        bar.next()
print()

with ProgressBar("FillingSquares", max=20, width=50) as bar:
    for i in range(15):
        sleep(1)
        bar.next()
Out:
Processing: [█████████████████████████∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙] 50% [ETA: 10s]              
Processing: [▣▣▣▣▣▣▣▣▣▣▣▣▣▣▣▣▣▣▣▣▣▣▣▣▣▣▣▣▣▣▣▣▣▣▣▣▣▢▢▢▢▢▢▢▢▢▢▢▢▢] 75% [ETA: 5s]

Note that the next method can be replaced by the show method with index argument supplied:

with ProgressBar("FillingCircles", max=20, width=50, eta=False) as bar:
    for i in range(10):
        sleep(1)
        bar.show(i + 1)
Out:
Processing: [◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉◉◯◯◯◯◯◯◯◯◯◯◯◯◯◯◯◯◯◯◯◯◯◯◯◯◯] 50%

ProgressSpinner

The following examples explain how to use the ProgressSpinner class from the module progress:

from deeppy.progress import ProgressSpinner
from time import sleep, time

spinner = ProgressSpinner()

since = time()
while True:
    # Do some work
    sleep(0.2)
    spinner.next()
    if time() - since > 5:
        break

Alternative spinner formats are also available:

with ProgressSpinner("Pie") as spinner:
    since = time()
    while True:
        sleep(0.2)
        spinner.next()
        if time() - since > 5:
            break
print()

with ProgressSpinner("Moon") as spinner:
    since = time()
    while True:
        sleep(0.2)
        spinner.next()
        if time() - since > 5:
            break
print()

with ProgressSpinner("Pixel") as spinner:
    since = time()
    while True:
        sleep(0.2)
        spinner.next()
        if time() - since > 5:
            break
Out:
Processing: ◷
Processing: ◐
Processing: ⣷

Installation

Download from PyPI:

pip install deep-py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deep-py-0.0.4.tar.gz (2.8 kB view hashes)

Uploaded Source

Built Distribution

deep_py-0.0.4-py3-none-any.whl (3.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page