Skip to main content

A progress bar implementation for numba functions using tqdm

Project description

Numba-progress

A progress bar implementation for numba functions using tqdm. The module provides the class ProgressBar that works as a wrapper around the tqdm.tqdm progress bar.

It works by spawning a separate thread that updates the tqdm progress bar based on an atomic counter which can be accessed within a numba nopython function.

The progress bar works with parallel as well as sequential numba functions.

Installation

Using pip

pip install numba-progress

From source

git clone https://github.com/mortacious/numba-progress.git
cd numba-progress
python setup.py install

Usage

from numba import njit
from numba_progress import ProgressBar

num_iterations = 100

@njit(nogil=True)
def numba_function(num_iterations, progress_proxy):
    for i in range(num_iterations):
        #<DO CUSTOM WORK HERE>
        progress_proxy.update(1)

with ProgressBar(total=num_iterations) as progress:
    numba_function(num_iterations, progress)

The ProgressBar also works within parallel functions out of the box.

from numba import njit, prange
from numba_progress import ProgressBar

num_iterations = 100

@njit(nogil=True, parallel=True)
def numba_function(num_iterations, progress_proxy):
    for i in prange(num_iterations):
        #<DO CUSTOM WORK HERE>
        progress_proxy.update(1)

with ProgressBar(total=num_iterations) as progress:
    numba_function(num_iterations, progress)

See also the examples folder for more usage examples.

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

numba-progress-1.1.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

numba_progress-1.1.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file numba-progress-1.1.0.tar.gz.

File metadata

  • Download URL: numba-progress-1.1.0.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.17

File hashes

Hashes for numba-progress-1.1.0.tar.gz
Algorithm Hash digest
SHA256 f2a0da4840997eac2db47ef026c90f440169007d21c42f16551a3ead0e81fd4d
MD5 09afc820b081c0b2de0a589ec0b90a8a
BLAKE2b-256 8f6724936b5ddcf2b26a193132e66441a5f3c42102a68d0d3ea58b8ed506c1c1

See more details on using hashes here.

File details

Details for the file numba_progress-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for numba_progress-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a93561612b6c70480ee734b1265729f9517e872fd79eecf7a2a27e4e64ec728d
MD5 f14d4da2966b79213b8b1a6d0c37d7a0
BLAKE2b-256 4f5c5f2c4eee2481488ccfbf9a0a0bb94b7ad2fefafcfcbe59bde2bd2c4622d3

See more details on using hashes here.

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