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-0.0.2.tar.gz
(6.9 kB
view hashes)
Built Distribution
Close
Hashes for numba_progress-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c3ab348b707e93ea008330b533b65ab7c70e062874bc35622799086c81fcc15 |
|
MD5 | 601a3cc3f604bf764b0ab978886ea231 |
|
BLAKE2b-256 | 6632830e288652f50e1ece3bbf5c26e4ba9cbd6bf5fd77633c3862b7212e9c3d |