| 1 |
Metadata-Version: 2.1 |
| 2 |
Name: tqdm |
| 3 |
Version: 4.66.3 |
| 4 |
Summary: Fast, Extensible Progress Meter |
| 5 |
Maintainer-email: tqdm developers <[email protected]> |
| 6 |
License: MPL-2.0 AND MIT |
| 7 |
Project-URL: homepage, https://tqdm.github.io |
| 8 |
Project-URL: repository, https://github.com/tqdm/tqdm |
| 9 |
Project-URL: changelog, https://tqdm.github.io/releases |
| 10 |
Project-URL: wiki, https://github.com/tqdm/tqdm/wiki |
| 11 |
Keywords: progressbar,progressmeter,progress,bar,meter,rate,eta,console,terminal,time |
| 12 |
Classifier: Development Status :: 5 - Production/Stable |
| 13 |
Classifier: Environment :: Console |
| 14 |
Classifier: Environment :: MacOS X |
| 15 |
Classifier: Environment :: Other Environment |
| 16 |
Classifier: Environment :: Win32 (MS Windows) |
| 17 |
Classifier: Environment :: X11 Applications |
| 18 |
Classifier: Framework :: IPython |
| 19 |
Classifier: Framework :: Jupyter |
| 20 |
Classifier: Intended Audience :: Developers |
| 21 |
Classifier: Intended Audience :: Education |
| 22 |
Classifier: Intended Audience :: End Users/Desktop |
| 23 |
Classifier: Intended Audience :: Other Audience |
| 24 |
Classifier: Intended Audience :: System Administrators |
| 25 |
Classifier: License :: OSI Approved :: MIT License |
| 26 |
Classifier: License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0) |
| 27 |
Classifier: Operating System :: MacOS |
| 28 |
Classifier: Operating System :: MacOS :: MacOS X |
| 29 |
Classifier: Operating System :: Microsoft |
| 30 |
Classifier: Operating System :: Microsoft :: MS-DOS |
| 31 |
Classifier: Operating System :: Microsoft :: Windows |
| 32 |
Classifier: Operating System :: POSIX |
| 33 |
Classifier: Operating System :: POSIX :: BSD |
| 34 |
Classifier: Operating System :: POSIX :: BSD :: FreeBSD |
| 35 |
Classifier: Operating System :: POSIX :: Linux |
| 36 |
Classifier: Operating System :: POSIX :: SunOS/Solaris |
| 37 |
Classifier: Operating System :: Unix |
| 38 |
Classifier: Programming Language :: Python |
| 39 |
Classifier: Programming Language :: Python :: 3 |
| 40 |
Classifier: Programming Language :: Python :: 3.7 |
| 41 |
Classifier: Programming Language :: Python :: 3.8 |
| 42 |
Classifier: Programming Language :: Python :: 3.9 |
| 43 |
Classifier: Programming Language :: Python :: 3.10 |
| 44 |
Classifier: Programming Language :: Python :: 3.11 |
| 45 |
Classifier: Programming Language :: Python :: 3 :: Only |
| 46 |
Classifier: Programming Language :: Python :: Implementation |
| 47 |
Classifier: Programming Language :: Python :: Implementation :: IronPython |
| 48 |
Classifier: Programming Language :: Python :: Implementation :: PyPy |
| 49 |
Classifier: Programming Language :: Unix Shell |
| 50 |
Classifier: Topic :: Desktop Environment |
| 51 |
Classifier: Topic :: Education :: Computer Aided Instruction (CAI) |
| 52 |
Classifier: Topic :: Education :: Testing |
| 53 |
Classifier: Topic :: Office/Business |
| 54 |
Classifier: Topic :: Other/Nonlisted Topic |
| 55 |
Classifier: Topic :: Software Development :: Build Tools |
| 56 |
Classifier: Topic :: Software Development :: Libraries |
| 57 |
Classifier: Topic :: Software Development :: Libraries :: Python Modules |
| 58 |
Classifier: Topic :: Software Development :: Pre-processors |
| 59 |
Classifier: Topic :: Software Development :: User Interfaces |
| 60 |
Classifier: Topic :: System :: Installation/Setup |
| 61 |
Classifier: Topic :: System :: Logging |
| 62 |
Classifier: Topic :: System :: Monitoring |
| 63 |
Classifier: Topic :: System :: Shells |
| 64 |
Classifier: Topic :: Terminals |
| 65 |
Classifier: Topic :: Utilities |
| 66 |
Requires-Python: >=3.7 |
| 67 |
Description-Content-Type: text/x-rst |
| 68 |
License-File: LICENCE |
| 69 |
Requires-Dist: colorama ; platform_system == "Windows" |
| 70 |
Provides-Extra: dev |
| 71 |
Requires-Dist: pytest >=6 ; extra == 'dev' |
| 72 |
Requires-Dist: pytest-cov ; extra == 'dev' |
| 73 |
Requires-Dist: pytest-timeout ; extra == 'dev' |
| 74 |
Requires-Dist: pytest-xdist ; extra == 'dev' |
| 75 |
Provides-Extra: notebook |
| 76 |
Requires-Dist: ipywidgets >=6 ; extra == 'notebook' |
| 77 |
Provides-Extra: slack |
| 78 |
Requires-Dist: slack-sdk ; extra == 'slack' |
| 79 |
Provides-Extra: telegram |
| 80 |
Requires-Dist: requests ; extra == 'telegram' |
| 81 |
|
| 82 |
|Logo| |
| 83 |
|
| 84 |
tqdm |
| 85 |
==== |
| 86 |
|
| 87 |
|Py-Versions| |Versions| |Conda-Forge-Status| |Docker| |Snapcraft| |
| 88 |
|
| 89 |
|Build-Status| |Coverage-Status| |Branch-Coverage-Status| |Codacy-Grade| |Libraries-Rank| |PyPI-Downloads| |
| 90 |
|
| 91 |
|LICENCE| |OpenHub-Status| |binder-demo| |awesome-python| |
| 92 |
|
| 93 |
``tqdm`` derives from the Arabic word *taqaddum* (تقدّم) which can mean "progress," |
| 94 |
and is an abbreviation for "I love you so much" in Spanish (*te quiero demasiado*). |
| 95 |
|
| 96 |
Instantly make your loops show a smart progress meter - just wrap any |
| 97 |
iterable with ``tqdm(iterable)``, and you're done! |
| 98 |
|
| 99 |
.. code:: python |
| 100 |
|
| 101 |
from tqdm import tqdm |
| 102 |
for i in tqdm(range(10000)): |
| 103 |
... |
| 104 |
|
| 105 |
``76%|████████████████████████ | 7568/10000 [00:33<00:10, 229.00it/s]`` |
| 106 |
|
| 107 |
``trange(N)`` can be also used as a convenient shortcut for |
| 108 |
``tqdm(range(N))``. |
| 109 |
|
| 110 |
|Screenshot| |
| 111 |
|Video| |Slides| |Merch| |
| 112 |
|
| 113 |
It can also be executed as a module with pipes: |
| 114 |
|
| 115 |
.. code:: sh |
| 116 |
|
| 117 |
$ seq 9999999 | tqdm --bytes | wc -l |
| 118 |
75.2MB [00:00, 217MB/s] |
| 119 |
9999999 |
| 120 |
|
| 121 |
$ tar -zcf - docs/ | tqdm --bytes --total `du -sb docs/ | cut -f1` \ |
| 122 |
> backup.tgz |
| 123 |
32%|██████████▍ | 8.89G/27.9G [00:42<01:31, 223MB/s] |
| 124 |
|
| 125 |
Overhead is low -- about 60ns per iteration (80ns with ``tqdm.gui``), and is |
| 126 |
unit tested against performance regression. |
| 127 |
By comparison, the well-established |
| 128 |
`ProgressBar <https://github.com/niltonvolpato/python-progressbar>`__ has |
| 129 |
an 800ns/iter overhead. |
| 130 |
|
| 131 |
In addition to its low overhead, ``tqdm`` uses smart algorithms to predict |
| 132 |
the remaining time and to skip unnecessary iteration displays, which allows |
| 133 |
for a negligible overhead in most cases. |
| 134 |
|
| 135 |
``tqdm`` works on any platform |
| 136 |
(Linux, Windows, Mac, FreeBSD, NetBSD, Solaris/SunOS), |
| 137 |
in any console or in a GUI, and is also friendly with IPython/Jupyter notebooks. |
| 138 |
|
| 139 |
``tqdm`` does not require any dependencies (not even ``curses``!), just |
| 140 |
Python and an environment supporting ``carriage return \r`` and |
| 141 |
``line feed \n`` control characters. |
| 142 |
|
| 143 |
------------------------------------------ |
| 144 |
|
| 145 |
.. contents:: Table of contents |
| 146 |
:backlinks: top |
| 147 |
:local: |
| 148 |
|
| 149 |
|
| 150 |
Installation |
| 151 |
------------ |
| 152 |
|
| 153 |
Latest PyPI stable release |
| 154 |
~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 155 |
|
| 156 |
|Versions| |PyPI-Downloads| |Libraries-Dependents| |
| 157 |
|
| 158 |
.. code:: sh |
| 159 |
|
| 160 |
pip install tqdm |
| 161 |
|
| 162 |
Latest development release on GitHub |
| 163 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 164 |
|
| 165 |
|GitHub-Status| |GitHub-Stars| |GitHub-Commits| |GitHub-Forks| |GitHub-Updated| |
| 166 |
|
| 167 |
Pull and install pre-release ``devel`` branch: |
| 168 |
|
| 169 |
.. code:: sh |
| 170 |
|
| 171 |
pip install "git+https://github.com/tqdm/tqdm.git@devel#egg=tqdm" |
| 172 |
|
| 173 |
Latest Conda release |
| 174 |
~~~~~~~~~~~~~~~~~~~~ |
| 175 |
|
| 176 |
|Conda-Forge-Status| |
| 177 |
|
| 178 |
.. code:: sh |
| 179 |
|
| 180 |
conda install -c conda-forge tqdm |
| 181 |
|
| 182 |
Latest Snapcraft release |
| 183 |
~~~~~~~~~~~~~~~~~~~~~~~~ |
| 184 |
|
| 185 |
|Snapcraft| |
| 186 |
|
| 187 |
There are 3 channels to choose from: |
| 188 |
|
| 189 |
.. code:: sh |
| 190 |
|
| 191 |
snap install tqdm # implies --stable, i.e. latest tagged release |
| 192 |
snap install tqdm --candidate # master branch |
| 193 |
snap install tqdm --edge # devel branch |
| 194 |
|
| 195 |
Note that ``snap`` binaries are purely for CLI use (not ``import``-able), and |
| 196 |
automatically set up ``bash`` tab-completion. |
| 197 |
|
| 198 |
Latest Docker release |
| 199 |
~~~~~~~~~~~~~~~~~~~~~ |
| 200 |
|
| 201 |
|Docker| |
| 202 |
|
| 203 |
.. code:: sh |
| 204 |
|
| 205 |
docker pull tqdm/tqdm |
| 206 |
docker run -i --rm tqdm/tqdm --help |
| 207 |
|
| 208 |
Other |
| 209 |
~~~~~ |
| 210 |
|
| 211 |
There are other (unofficial) places where ``tqdm`` may be downloaded, particularly for CLI use: |
| 212 |
|
| 213 |
|Repology| |
| 214 |
|
| 215 |
.. |Repology| image:: https://repology.org/badge/tiny-repos/python:tqdm.svg |
| 216 |
:target: https://repology.org/project/python:tqdm/versions |
| 217 |
|
| 218 |
Changelog |
| 219 |
--------- |
| 220 |
|
| 221 |
The list of all changes is available either on GitHub's Releases: |
| 222 |
|GitHub-Status|, on the |
| 223 |
`wiki <https://github.com/tqdm/tqdm/wiki/Releases>`__, or on the |
| 224 |
`website <https://tqdm.github.io/releases>`__. |
| 225 |
|
| 226 |
|
| 227 |
Usage |
| 228 |
----- |
| 229 |
|
| 230 |
``tqdm`` is very versatile and can be used in a number of ways. |
| 231 |
The three main ones are given below. |
| 232 |
|
| 233 |
Iterable-based |
| 234 |
~~~~~~~~~~~~~~ |
| 235 |
|
| 236 |
Wrap ``tqdm()`` around any iterable: |
| 237 |
|
| 238 |
.. code:: python |
| 239 |
|
| 240 |
from tqdm import tqdm |
| 241 |
from time import sleep |
| 242 |
|
| 243 |
text = "" |
| 244 |
for char in tqdm(["a", "b", "c", "d"]): |
| 245 |
sleep(0.25) |
| 246 |
text = text + char |
| 247 |
|
| 248 |
``trange(i)`` is a special optimised instance of ``tqdm(range(i))``: |
| 249 |
|
| 250 |
.. code:: python |
| 251 |
|
| 252 |
from tqdm import trange |
| 253 |
|
| 254 |
for i in trange(100): |
| 255 |
sleep(0.01) |
| 256 |
|
| 257 |
Instantiation outside of the loop allows for manual control over ``tqdm()``: |
| 258 |
|
| 259 |
.. code:: python |
| 260 |
|
| 261 |
pbar = tqdm(["a", "b", "c", "d"]) |
| 262 |
for char in pbar: |
| 263 |
sleep(0.25) |
| 264 |
pbar.set_description("Processing %s" % char) |
| 265 |
|
| 266 |
Manual |
| 267 |
~~~~~~ |
| 268 |
|
| 269 |
Manual control of ``tqdm()`` updates using a ``with`` statement: |
| 270 |
|
| 271 |
.. code:: python |
| 272 |
|
| 273 |
with tqdm(total=100) as pbar: |
| 274 |
for i in range(10): |
| 275 |
sleep(0.1) |
| 276 |
pbar.update(10) |
| 277 |
|
| 278 |
If the optional variable ``total`` (or an iterable with ``len()``) is |
| 279 |
provided, predictive stats are displayed. |
| 280 |
|
| 281 |
``with`` is also optional (you can just assign ``tqdm()`` to a variable, |
| 282 |
but in this case don't forget to ``del`` or ``close()`` at the end: |
| 283 |
|
| 284 |
.. code:: python |
| 285 |
|
| 286 |
pbar = tqdm(total=100) |
| 287 |
for i in range(10): |
| 288 |
sleep(0.1) |
| 289 |
pbar.update(10) |
| 290 |
pbar.close() |
| 291 |
|
| 292 |
Module |
| 293 |
~~~~~~ |
| 294 |
|
| 295 |
Perhaps the most wonderful use of ``tqdm`` is in a script or on the command |
| 296 |
line. Simply inserting ``tqdm`` (or ``python -m tqdm``) between pipes will pass |
| 297 |
through all ``stdin`` to ``stdout`` while printing progress to ``stderr``. |
| 298 |
|
| 299 |
The example below demonstrate counting the number of lines in all Python files |
| 300 |
in the current directory, with timing information included. |
| 301 |
|
| 302 |
.. code:: sh |
| 303 |
|
| 304 |
$ time find . -name '*.py' -type f -exec cat \{} \; | wc -l |
| 305 |
857365 |
| 306 |
|
| 307 |
real 0m3.458s |
| 308 |
user 0m0.274s |
| 309 |
sys 0m3.325s |
| 310 |
|
| 311 |
$ time find . -name '*.py' -type f -exec cat \{} \; | tqdm | wc -l |
| 312 |
857366it [00:03, 246471.31it/s] |
| 313 |
857365 |
| 314 |
|
| 315 |
real 0m3.585s |
| 316 |
user 0m0.862s |
| 317 |
sys 0m3.358s |
| 318 |
|
| 319 |
Note that the usual arguments for ``tqdm`` can also be specified. |
| 320 |
|
| 321 |
.. code:: sh |
| 322 |
|
| 323 |
$ find . -name '*.py' -type f -exec cat \{} \; | |
| 324 |
tqdm --unit loc --unit_scale --total 857366 >> /dev/null |
| 325 |
100%|█████████████████████████████████| 857K/857K [00:04<00:00, 246Kloc/s] |
| 326 |
|
| 327 |
Backing up a large directory? |
| 328 |
|
| 329 |
.. code:: sh |
| 330 |
|
| 331 |
$ tar -zcf - docs/ | tqdm --bytes --total `du -sb docs/ | cut -f1` \ |
| 332 |
> backup.tgz |
| 333 |
44%|██████████████▊ | 153M/352M [00:14<00:18, 11.0MB/s] |
| 334 |
|
| 335 |
This can be beautified further: |
| 336 |
|
| 337 |
.. code:: sh |
| 338 |
|
| 339 |
$ BYTES=$(du -sb docs/ | cut -f1) |
| 340 |
$ tar -cf - docs/ \ |
| 341 |
| tqdm --bytes --total "$BYTES" --desc Processing | gzip \ |
| 342 |
| tqdm --bytes --total "$BYTES" --desc Compressed --position 1 \ |
| 343 |
> ~/backup.tgz |
| 344 |
Processing: 100%|██████████████████████| 352M/352M [00:14<00:00, 30.2MB/s] |
| 345 |
Compressed: 42%|█████████▎ | 148M/352M [00:14<00:19, 10.9MB/s] |
| 346 |
|
| 347 |
Or done on a file level using 7-zip: |
| 348 |
|
| 349 |
.. code:: sh |
| 350 |
|
| 351 |
$ 7z a -bd -r backup.7z docs/ | grep Compressing \ |
| 352 |
| tqdm --total $(find docs/ -type f | wc -l) --unit files \ |
| 353 |
| grep -v Compressing |
| 354 |
100%|██████████████████████████▉| 15327/15327 [01:00<00:00, 712.96files/s] |
| 355 |
|
| 356 |
Pre-existing CLI programs already outputting basic progress information will |
| 357 |
benefit from ``tqdm``'s ``--update`` and ``--update_to`` flags: |
| 358 |
|
| 359 |
.. code:: sh |
| 360 |
|
| 361 |
$ seq 3 0.1 5 | tqdm --total 5 --update_to --null |
| 362 |
100%|████████████████████████████████████| 5.0/5 [00:00<00:00, 9673.21it/s] |
| 363 |
$ seq 10 | tqdm --update --null # 1 + 2 + ... + 10 = 55 iterations |
| 364 |
55it [00:00, 90006.52it/s] |
| 365 |
|
| 366 |
FAQ and Known Issues |
| 367 |
-------------------- |
| 368 |
|
| 369 |
|GitHub-Issues| |
| 370 |
|
| 371 |
The most common issues relate to excessive output on multiple lines, instead |
| 372 |
of a neat one-line progress bar. |
| 373 |
|
| 374 |
- Consoles in general: require support for carriage return (``CR``, ``\r``). |
| 375 |
|
| 376 |
* Some cloud logging consoles which don't support ``\r`` properly |
| 377 |
(`cloudwatch <https://github.com/tqdm/tqdm/issues/966>`__, |
| 378 |
`K8s <https://github.com/tqdm/tqdm/issues/1319>`__) may benefit from |
| 379 |
``export TQDM_POSITION=-1``. |
| 380 |
|
| 381 |
- Nested progress bars: |
| 382 |
|
| 383 |
* Consoles in general: require support for moving cursors up to the |
| 384 |
previous line. For example, |
| 385 |
`IDLE <https://github.com/tqdm/tqdm/issues/191#issuecomment-230168030>`__, |
| 386 |
`ConEmu <https://github.com/tqdm/tqdm/issues/254>`__ and |
| 387 |
`PyCharm <https://github.com/tqdm/tqdm/issues/203>`__ (also |
| 388 |
`here <https://github.com/tqdm/tqdm/issues/208>`__, |
| 389 |
`here <https://github.com/tqdm/tqdm/issues/307>`__, and |
| 390 |
`here <https://github.com/tqdm/tqdm/issues/454#issuecomment-335416815>`__) |
| 391 |
lack full support. |
| 392 |
* Windows: additionally may require the Python module ``colorama`` |
| 393 |
to ensure nested bars stay within their respective lines. |
| 394 |
|
| 395 |
- Unicode: |
| 396 |
|
| 397 |
* Environments which report that they support unicode will have solid smooth |
| 398 |
progressbars. The fallback is an ``ascii``-only bar. |
| 399 |
* Windows consoles often only partially support unicode and thus |
| 400 |
`often require explicit ascii=True <https://github.com/tqdm/tqdm/issues/454#issuecomment-335416815>`__ |
| 401 |
(also `here <https://github.com/tqdm/tqdm/issues/499>`__). This is due to |
| 402 |
either normal-width unicode characters being incorrectly displayed as |
| 403 |
"wide", or some unicode characters not rendering. |
| 404 |
|
| 405 |
- Wrapping generators: |
| 406 |
|
| 407 |
* Generator wrapper functions tend to hide the length of iterables. |
| 408 |
``tqdm`` does not. |
| 409 |
* Replace ``tqdm(enumerate(...))`` with ``enumerate(tqdm(...))`` or |
| 410 |
``tqdm(enumerate(x), total=len(x), ...)``. |
| 411 |
The same applies to ``numpy.ndenumerate``. |
| 412 |
* Replace ``tqdm(zip(a, b))`` with ``zip(tqdm(a), b)`` or even |
| 413 |
``zip(tqdm(a), tqdm(b))``. |
| 414 |
* The same applies to ``itertools``. |
| 415 |
* Some useful convenience functions can be found under ``tqdm.contrib``. |
| 416 |
|
| 417 |
- `No intermediate output in docker-compose <https://github.com/tqdm/tqdm/issues/771>`__: |
| 418 |
use ``docker-compose run`` instead of ``docker-compose up`` and ``tty: true``. |
| 419 |
|
| 420 |
- Overriding defaults via environment variables: |
| 421 |
e.g. in CI/cloud jobs, ``export TQDM_MININTERVAL=5`` to avoid log spam. |
| 422 |
This override logic is handled by the ``tqdm.utils.envwrap`` decorator |
| 423 |
(useful independent of ``tqdm``). |
| 424 |
|
| 425 |
If you come across any other difficulties, browse and file |GitHub-Issues|. |
| 426 |
|
| 427 |
Documentation |
| 428 |
------------- |
| 429 |
|
| 430 |
|Py-Versions| |README-Hits| (Since 19 May 2016) |
| 431 |
|
| 432 |
.. code:: python |
| 433 |
|
| 434 |
class tqdm(): |
| 435 |
""" |
| 436 |
Decorate an iterable object, returning an iterator which acts exactly |
| 437 |
like the original iterable, but prints a dynamically updating |
| 438 |
progressbar every time a value is requested. |
| 439 |
""" |
| 440 |
|
| 441 |
@envwrap("TQDM_") # override defaults via env vars |
| 442 |
def __init__(self, iterable=None, desc=None, total=None, leave=True, |
| 443 |
file=None, ncols=None, mininterval=0.1, |
| 444 |
maxinterval=10.0, miniters=None, ascii=None, disable=False, |
| 445 |
unit='it', unit_scale=False, dynamic_ncols=False, |
| 446 |
smoothing=0.3, bar_format=None, initial=0, position=None, |
| 447 |
postfix=None, unit_divisor=1000, write_bytes=False, |
| 448 |
lock_args=None, nrows=None, colour=None, delay=0): |
| 449 |
|
| 450 |
Parameters |
| 451 |
~~~~~~~~~~ |
| 452 |
|
| 453 |
* iterable : iterable, optional |
| 454 |
Iterable to decorate with a progressbar. |
| 455 |
Leave blank to manually manage the updates. |
| 456 |
* desc : str, optional |
| 457 |
Prefix for the progressbar. |
| 458 |
* total : int or float, optional |
| 459 |
The number of expected iterations. If unspecified, |
| 460 |
len(iterable) is used if possible. If float("inf") or as a last |
| 461 |
resort, only basic progress statistics are displayed |
| 462 |
(no ETA, no progressbar). |
| 463 |
If ``gui`` is True and this parameter needs subsequent updating, |
| 464 |
specify an initial arbitrary large positive number, |
| 465 |
e.g. 9e9. |
| 466 |
* leave : bool, optional |
| 467 |
If [default: True], keeps all traces of the progressbar |
| 468 |
upon termination of iteration. |
| 469 |
If ``None``, will leave only if ``position`` is ``0``. |
| 470 |
* file : ``io.TextIOWrapper`` or ``io.StringIO``, optional |
| 471 |
Specifies where to output the progress messages |
| 472 |
(default: sys.stderr). Uses ``file.write(str)`` and ``file.flush()`` |
| 473 |
methods. For encoding, see ``write_bytes``. |
| 474 |
* ncols : int, optional |
| 475 |
The width of the entire output message. If specified, |
| 476 |
dynamically resizes the progressbar to stay within this bound. |
| 477 |
If unspecified, attempts to use environment width. The |
| 478 |
fallback is a meter width of 10 and no limit for the counter and |
| 479 |
statistics. If 0, will not print any meter (only stats). |
| 480 |
* mininterval : float, optional |
| 481 |
Minimum progress display update interval [default: 0.1] seconds. |
| 482 |
* maxinterval : float, optional |
| 483 |
Maximum progress display update interval [default: 10] seconds. |
| 484 |
Automatically adjusts ``miniters`` to correspond to ``mininterval`` |
| 485 |
after long display update lag. Only works if ``dynamic_miniters`` |
| 486 |
or monitor thread is enabled. |
| 487 |
* miniters : int or float, optional |
| 488 |
Minimum progress display update interval, in iterations. |
| 489 |
If 0 and ``dynamic_miniters``, will automatically adjust to equal |
| 490 |
``mininterval`` (more CPU efficient, good for tight loops). |
| 491 |
If > 0, will skip display of specified number of iterations. |
| 492 |
Tweak this and ``mininterval`` to get very efficient loops. |
| 493 |
If your progress is erratic with both fast and slow iterations |
| 494 |
(network, skipping items, etc) you should set miniters=1. |
| 495 |
* ascii : bool or str, optional |
| 496 |
If unspecified or False, use unicode (smooth blocks) to fill |
| 497 |
the meter. The fallback is to use ASCII characters " 123456789#". |
| 498 |
* disable : bool, optional |
| 499 |
Whether to disable the entire progressbar wrapper |
| 500 |
[default: False]. If set to None, disable on non-TTY. |
| 501 |
* unit : str, optional |
| 502 |
String that will be used to define the unit of each iteration |
| 503 |
[default: it]. |
| 504 |
* unit_scale : bool or int or float, optional |
| 505 |
If 1 or True, the number of iterations will be reduced/scaled |
| 506 |
automatically and a metric prefix following the |
| 507 |
International System of Units standard will be added |
| 508 |
(kilo, mega, etc.) [default: False]. If any other non-zero |
| 509 |
number, will scale ``total`` and ``n``. |
| 510 |
* dynamic_ncols : bool, optional |
| 511 |
If set, constantly alters ``ncols`` and ``nrows`` to the |
| 512 |
environment (allowing for window resizes) [default: False]. |
| 513 |
* smoothing : float, optional |
| 514 |
Exponential moving average smoothing factor for speed estimates |
| 515 |
(ignored in GUI mode). Ranges from 0 (average speed) to 1 |
| 516 |
(current/instantaneous speed) [default: 0.3]. |
| 517 |
* bar_format : str, optional |
| 518 |
Specify a custom bar string formatting. May impact performance. |
| 519 |
[default: '{l_bar}{bar}{r_bar}'], where |
| 520 |
l_bar='{desc}: {percentage:3.0f}%|' and |
| 521 |
r_bar='| {n_fmt}/{total_fmt} [{elapsed}<{remaining}, ' |
| 522 |
'{rate_fmt}{postfix}]' |
| 523 |
Possible vars: l_bar, bar, r_bar, n, n_fmt, total, total_fmt, |
| 524 |
percentage, elapsed, elapsed_s, ncols, nrows, desc, unit, |
| 525 |
rate, rate_fmt, rate_noinv, rate_noinv_fmt, |
| 526 |
rate_inv, rate_inv_fmt, postfix, unit_divisor, |
| 527 |
remaining, remaining_s, eta. |
| 528 |
Note that a trailing ": " is automatically removed after {desc} |
| 529 |
if the latter is empty. |
| 530 |
* initial : int or float, optional |
| 531 |
The initial counter value. Useful when restarting a progress |
| 532 |
bar [default: 0]. If using float, consider specifying ``{n:.3f}`` |
| 533 |
or similar in ``bar_format``, or specifying ``unit_scale``. |
| 534 |
* position : int, optional |
| 535 |
Specify the line offset to print this bar (starting from 0) |
| 536 |
Automatic if unspecified. |
| 537 |
Useful to manage multiple bars at once (eg, from threads). |
| 538 |
* postfix : dict or ``*``, optional |
| 539 |
Specify additional stats to display at the end of the bar. |
| 540 |
Calls ``set_postfix(**postfix)`` if possible (dict). |
| 541 |
* unit_divisor : float, optional |
| 542 |
[default: 1000], ignored unless ``unit_scale`` is True. |
| 543 |
* write_bytes : bool, optional |
| 544 |
Whether to write bytes. If (default: False) will write unicode. |
| 545 |
* lock_args : tuple, optional |
| 546 |
Passed to ``refresh`` for intermediate output |
| 547 |
(initialisation, iterating, and updating). |
| 548 |
* nrows : int, optional |
| 549 |
The screen height. If specified, hides nested bars outside this |
| 550 |
bound. If unspecified, attempts to use environment height. |
| 551 |
The fallback is 20. |
| 552 |
* colour : str, optional |
| 553 |
Bar colour (e.g. 'green', '#00ff00'). |
| 554 |
* delay : float, optional |
| 555 |
Don't display until [default: 0] seconds have elapsed. |
| 556 |
|
| 557 |
Extra CLI Options |
| 558 |
~~~~~~~~~~~~~~~~~ |
| 559 |
|
| 560 |
* delim : chr, optional |
| 561 |
Delimiting character [default: '\n']. Use '\0' for null. |
| 562 |
N.B.: on Windows systems, Python converts '\n' to '\r\n'. |
| 563 |
* buf_size : int, optional |
| 564 |
String buffer size in bytes [default: 256] |
| 565 |
used when ``delim`` is specified. |
| 566 |
* bytes : bool, optional |
| 567 |
If true, will count bytes, ignore ``delim``, and default |
| 568 |
``unit_scale`` to True, ``unit_divisor`` to 1024, and ``unit`` to 'B'. |
| 569 |
* tee : bool, optional |
| 570 |
If true, passes ``stdin`` to both ``stderr`` and ``stdout``. |
| 571 |
* update : bool, optional |
| 572 |
If true, will treat input as newly elapsed iterations, |
| 573 |
i.e. numbers to pass to ``update()``. Note that this is slow |
| 574 |
(~2e5 it/s) since every input must be decoded as a number. |
| 575 |
* update_to : bool, optional |
| 576 |
If true, will treat input as total elapsed iterations, |
| 577 |
i.e. numbers to assign to ``self.n``. Note that this is slow |
| 578 |
(~2e5 it/s) since every input must be decoded as a number. |
| 579 |
* null : bool, optional |
| 580 |
If true, will discard input (no stdout). |
| 581 |
* manpath : str, optional |
| 582 |
Directory in which to install tqdm man pages. |
| 583 |
* comppath : str, optional |
| 584 |
Directory in which to place tqdm completion. |
| 585 |
* log : str, optional |
| 586 |
CRITICAL|FATAL|ERROR|WARN(ING)|[default: 'INFO']|DEBUG|NOTSET. |
| 587 |
|
| 588 |
Returns |
| 589 |
~~~~~~~ |
| 590 |
|
| 591 |
* out : decorated iterator. |
| 592 |
|
| 593 |
.. code:: python |
| 594 |
|
| 595 |
class tqdm(): |
| 596 |
def update(self, n=1): |
| 597 |
""" |
| 598 |
Manually update the progress bar, useful for streams |
| 599 |
such as reading files. |
| 600 |
E.g.: |
| 601 |
>>> t = tqdm(total=filesize) # Initialise |
| 602 |
>>> for current_buffer in stream: |
| 603 |
... ... |
| 604 |
... t.update(len(current_buffer)) |
| 605 |
>>> t.close() |
| 606 |
The last line is highly recommended, but possibly not necessary if |
| 607 |
``t.update()`` will be called in such a way that ``filesize`` will be |
| 608 |
exactly reached and printed. |
| 609 |
|
| 610 |
Parameters |
| 611 |
---------- |
| 612 |
n : int or float, optional |
| 613 |
Increment to add to the internal counter of iterations |
| 614 |
[default: 1]. If using float, consider specifying ``{n:.3f}`` |
| 615 |
or similar in ``bar_format``, or specifying ``unit_scale``. |
| 616 |
|
| 617 |
Returns |
| 618 |
------- |
| 619 |
out : bool or None |
| 620 |
True if a ``display()`` was triggered. |
| 621 |
""" |
| 622 |
|
| 623 |
def close(self): |
| 624 |
"""Cleanup and (if leave=False) close the progressbar.""" |
| 625 |
|
| 626 |
def clear(self, nomove=False): |
| 627 |
"""Clear current bar display.""" |
| 628 |
|
| 629 |
def refresh(self): |
| 630 |
""" |
| 631 |
Force refresh the display of this bar. |
| 632 |
|
| 633 |
Parameters |
| 634 |
---------- |
| 635 |
nolock : bool, optional |
| 636 |
If ``True``, does not lock. |
| 637 |
If [default: ``False``]: calls ``acquire()`` on internal lock. |
| 638 |
lock_args : tuple, optional |
| 639 |
Passed to internal lock's ``acquire()``. |
| 640 |
If specified, will only ``display()`` if ``acquire()`` returns ``True``. |
| 641 |
""" |
| 642 |
|
| 643 |
def unpause(self): |
| 644 |
"""Restart tqdm timer from last print time.""" |
| 645 |
|
| 646 |
def reset(self, total=None): |
| 647 |
""" |
| 648 |
Resets to 0 iterations for repeated use. |
| 649 |
|
| 650 |
Consider combining with ``leave=True``. |
| 651 |
|
| 652 |
Parameters |
| 653 |
---------- |
| 654 |
total : int or float, optional. Total to use for the new bar. |
| 655 |
""" |
| 656 |
|
| 657 |
def set_description(self, desc=None, refresh=True): |
| 658 |
""" |
| 659 |
Set/modify description of the progress bar. |
| 660 |
|
| 661 |
Parameters |
| 662 |
---------- |
| 663 |
desc : str, optional |
| 664 |
refresh : bool, optional |
| 665 |
Forces refresh [default: True]. |
| 666 |
""" |
| 667 |
|
| 668 |
def set_postfix(self, ordered_dict=None, refresh=True, **tqdm_kwargs): |
| 669 |
""" |
| 670 |
Set/modify postfix (additional stats) |
| 671 |
with automatic formatting based on datatype. |
| 672 |
|
| 673 |
Parameters |
| 674 |
---------- |
| 675 |
ordered_dict : dict or OrderedDict, optional |
| 676 |
refresh : bool, optional |
| 677 |
Forces refresh [default: True]. |
| 678 |
kwargs : dict, optional |
| 679 |
""" |
| 680 |
|
| 681 |
@classmethod |
| 682 |
def write(cls, s, file=sys.stdout, end="\n"): |
| 683 |
"""Print a message via tqdm (without overlap with bars).""" |
| 684 |
|
| 685 |
@property |
| 686 |
def format_dict(self): |
| 687 |
"""Public API for read-only member access.""" |
| 688 |
|
| 689 |
def display(self, msg=None, pos=None): |
| 690 |
""" |
| 691 |
Use ``self.sp`` to display ``msg`` in the specified ``pos``. |
| 692 |
|
| 693 |
Consider overloading this function when inheriting to use e.g.: |
| 694 |
``self.some_frontend(**self.format_dict)`` instead of ``self.sp``. |
| 695 |
|
| 696 |
Parameters |
| 697 |
---------- |
| 698 |
msg : str, optional. What to display (default: ``repr(self)``). |
| 699 |
pos : int, optional. Position to ``moveto`` |
| 700 |
(default: ``abs(self.pos)``). |
| 701 |
""" |
| 702 |
|
| 703 |
@classmethod |
| 704 |
@contextmanager |
| 705 |
def wrapattr(cls, stream, method, total=None, bytes=True, **tqdm_kwargs): |
| 706 |
""" |
| 707 |
stream : file-like object. |
| 708 |
method : str, "read" or "write". The result of ``read()`` and |
| 709 |
the first argument of ``write()`` should have a ``len()``. |
| 710 |
|
| 711 |
>>> with tqdm.wrapattr(file_obj, "read", total=file_obj.size) as fobj: |
| 712 |
... while True: |
| 713 |
... chunk = fobj.read(chunk_size) |
| 714 |
... if not chunk: |
| 715 |
... break |
| 716 |
""" |
| 717 |
|
| 718 |
@classmethod |
| 719 |
def pandas(cls, *targs, **tqdm_kwargs): |
| 720 |
"""Registers the current `tqdm` class with `pandas`.""" |
| 721 |
|
| 722 |
def trange(*args, **tqdm_kwargs): |
| 723 |
"""Shortcut for `tqdm(range(*args), **tqdm_kwargs)`.""" |
| 724 |
|
| 725 |
Convenience Functions |
| 726 |
~~~~~~~~~~~~~~~~~~~~~ |
| 727 |
|
| 728 |
.. code:: python |
| 729 |
|
| 730 |
def tqdm.contrib.tenumerate(iterable, start=0, total=None, |
| 731 |
tqdm_class=tqdm.auto.tqdm, **tqdm_kwargs): |
| 732 |
"""Equivalent of `numpy.ndenumerate` or builtin `enumerate`.""" |
| 733 |
|
| 734 |
def tqdm.contrib.tzip(iter1, *iter2plus, **tqdm_kwargs): |
| 735 |
"""Equivalent of builtin `zip`.""" |
| 736 |
|
| 737 |
def tqdm.contrib.tmap(function, *sequences, **tqdm_kwargs): |
| 738 |
"""Equivalent of builtin `map`.""" |
| 739 |
|
| 740 |
Submodules |
| 741 |
~~~~~~~~~~ |
| 742 |
|
| 743 |
.. code:: python |
| 744 |
|
| 745 |
class tqdm.notebook.tqdm(tqdm.tqdm): |
| 746 |
"""IPython/Jupyter Notebook widget.""" |
| 747 |
|
| 748 |
class tqdm.auto.tqdm(tqdm.tqdm): |
| 749 |
"""Automatically chooses beween `tqdm.notebook` and `tqdm.tqdm`.""" |
| 750 |
|
| 751 |
class tqdm.asyncio.tqdm(tqdm.tqdm): |
| 752 |
"""Asynchronous version.""" |
| 753 |
@classmethod |
| 754 |
def as_completed(cls, fs, *, loop=None, timeout=None, total=None, |
| 755 |
**tqdm_kwargs): |
| 756 |
"""Wrapper for `asyncio.as_completed`.""" |
| 757 |
|
| 758 |
class tqdm.gui.tqdm(tqdm.tqdm): |
| 759 |
"""Matplotlib GUI version.""" |
| 760 |
|
| 761 |
class tqdm.tk.tqdm(tqdm.tqdm): |
| 762 |
"""Tkinter GUI version.""" |
| 763 |
|
| 764 |
class tqdm.rich.tqdm(tqdm.tqdm): |
| 765 |
"""`rich.progress` version.""" |
| 766 |
|
| 767 |
class tqdm.keras.TqdmCallback(keras.callbacks.Callback): |
| 768 |
"""Keras callback for epoch and batch progress.""" |
| 769 |
|
| 770 |
class tqdm.dask.TqdmCallback(dask.callbacks.Callback): |
| 771 |
"""Dask callback for task progress.""" |
| 772 |
|
| 773 |
|
| 774 |
``contrib`` |
| 775 |
+++++++++++ |
| 776 |
|
| 777 |
The ``tqdm.contrib`` package also contains experimental modules: |
| 778 |
|
| 779 |
- ``tqdm.contrib.itertools``: Thin wrappers around ``itertools`` |
| 780 |
- ``tqdm.contrib.concurrent``: Thin wrappers around ``concurrent.futures`` |
| 781 |
- ``tqdm.contrib.slack``: Posts to `Slack <https://slack.com>`__ bots |
| 782 |
- ``tqdm.contrib.discord``: Posts to `Discord <https://discord.com>`__ bots |
| 783 |
- ``tqdm.contrib.telegram``: Posts to `Telegram <https://telegram.org>`__ bots |
| 784 |
- ``tqdm.contrib.bells``: Automagically enables all optional features |
| 785 |
|
| 786 |
* ``auto``, ``pandas``, ``slack``, ``discord``, ``telegram`` |
| 787 |
|
| 788 |
Examples and Advanced Usage |
| 789 |
--------------------------- |
| 790 |
|
| 791 |
- See the `examples <https://github.com/tqdm/tqdm/tree/master/examples>`__ |
| 792 |
folder; |
| 793 |
- import the module and run ``help()``; |
| 794 |
- consult the `wiki <https://github.com/tqdm/tqdm/wiki>`__; |
| 795 |
|
| 796 |
* this has an |
| 797 |
`excellent article <https://github.com/tqdm/tqdm/wiki/How-to-make-a-great-Progress-Bar>`__ |
| 798 |
on how to make a **great** progressbar; |
| 799 |
|
| 800 |
- check out the `slides from PyData London <https://tqdm.github.io/PyData2019/slides.html>`__, or |
| 801 |
- run the |binder-demo|. |
| 802 |
|
| 803 |
Description and additional stats |
| 804 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 805 |
|
| 806 |
Custom information can be displayed and updated dynamically on ``tqdm`` bars |
| 807 |
with the ``desc`` and ``postfix`` arguments: |
| 808 |
|
| 809 |
.. code:: python |
| 810 |
|
| 811 |
from tqdm import tqdm, trange |
| 812 |
from random import random, randint |
| 813 |
from time import sleep |
| 814 |
|
| 815 |
with trange(10) as t: |
| 816 |
for i in t: |
| 817 |
# Description will be displayed on the left |
| 818 |
t.set_description('GEN %i' % i) |
| 819 |
# Postfix will be displayed on the right, |
| 820 |
# formatted automatically based on argument's datatype |
| 821 |
t.set_postfix(loss=random(), gen=randint(1,999), str='h', |
| 822 |
lst=[1, 2]) |
| 823 |
sleep(0.1) |
| 824 |
|
| 825 |
with tqdm(total=10, bar_format="{postfix[0]} {postfix[1][value]:>8.2g}", |
| 826 |
postfix=["Batch", {"value": 0}]) as t: |
| 827 |
for i in range(10): |
| 828 |
sleep(0.1) |
| 829 |
t.postfix[1]["value"] = i / 2 |
| 830 |
t.update() |
| 831 |
|
| 832 |
Points to remember when using ``{postfix[...]}`` in the ``bar_format`` string: |
| 833 |
|
| 834 |
- ``postfix`` also needs to be passed as an initial argument in a compatible |
| 835 |
format, and |
| 836 |
- ``postfix`` will be auto-converted to a string if it is a ``dict``-like |
| 837 |
object. To prevent this behaviour, insert an extra item into the dictionary |
| 838 |
where the key is not a string. |
| 839 |
|
| 840 |
Additional ``bar_format`` parameters may also be defined by overriding |
| 841 |
``format_dict``, and the bar itself may be modified using ``ascii``: |
| 842 |
|
| 843 |
.. code:: python |
| 844 |
|
| 845 |
from tqdm import tqdm |
| 846 |
class TqdmExtraFormat(tqdm): |
| 847 |
"""Provides a `total_time` format parameter""" |
| 848 |
@property |
| 849 |
def format_dict(self): |
| 850 |
d = super(TqdmExtraFormat, self).format_dict |
| 851 |
total_time = d["elapsed"] * (d["total"] or 0) / max(d["n"], 1) |
| 852 |
d.update(total_time=self.format_interval(total_time) + " in total") |
| 853 |
return d |
| 854 |
|
| 855 |
for i in TqdmExtraFormat( |
| 856 |
range(9), ascii=" .oO0", |
| 857 |
bar_format="{total_time}: {percentage:.0f}%|{bar}{r_bar}"): |
| 858 |
if i == 4: |
| 859 |
break |
| 860 |
|
| 861 |
.. code:: |
| 862 |
|
| 863 |
00:00 in total: 44%|0000. | 4/9 [00:00<00:00, 962.93it/s] |
| 864 |
|
| 865 |
Note that ``{bar}`` also supports a format specifier ``[width][type]``. |
| 866 |
|
| 867 |
- ``width`` |
| 868 |
|
| 869 |
* unspecified (default): automatic to fill ``ncols`` |
| 870 |
* ``int >= 0``: fixed width overriding ``ncols`` logic |
| 871 |
* ``int < 0``: subtract from the automatic default |
| 872 |
|
| 873 |
- ``type`` |
| 874 |
|
| 875 |
* ``a``: ascii (``ascii=True`` override) |
| 876 |
* ``u``: unicode (``ascii=False`` override) |
| 877 |
* ``b``: blank (``ascii=" "`` override) |
| 878 |
|
| 879 |
This means a fixed bar with right-justified text may be created by using: |
| 880 |
``bar_format="{l_bar}{bar:10}|{bar:-10b}right-justified"`` |
| 881 |
|
| 882 |
Nested progress bars |
| 883 |
~~~~~~~~~~~~~~~~~~~~ |
| 884 |
|
| 885 |
``tqdm`` supports nested progress bars. Here's an example: |
| 886 |
|
| 887 |
.. code:: python |
| 888 |
|
| 889 |
from tqdm.auto import trange |
| 890 |
from time import sleep |
| 891 |
|
| 892 |
for i in trange(4, desc='1st loop'): |
| 893 |
for j in trange(5, desc='2nd loop'): |
| 894 |
for k in trange(50, desc='3rd loop', leave=False): |
| 895 |
sleep(0.01) |
| 896 |
|
| 897 |
For manual control over positioning (e.g. for multi-processing use), |
| 898 |
you may specify ``position=n`` where ``n=0`` for the outermost bar, |
| 899 |
``n=1`` for the next, and so on. |
| 900 |
However, it's best to check if ``tqdm`` can work without manual ``position`` |
| 901 |
first. |
| 902 |
|
| 903 |
.. code:: python |
| 904 |
|
| 905 |
from time import sleep |
| 906 |
from tqdm import trange, tqdm |
| 907 |
from multiprocessing import Pool, RLock, freeze_support |
| 908 |
|
| 909 |
L = list(range(9)) |
| 910 |
|
| 911 |
def progresser(n): |
| 912 |
interval = 0.001 / (n + 2) |
| 913 |
total = 5000 |
| 914 |
text = f"#{n}, est. {interval * total:<04.2}s" |
| 915 |
for _ in trange(total, desc=text, position=n): |
| 916 |
sleep(interval) |
| 917 |
|
| 918 |
if __name__ == '__main__': |
| 919 |
freeze_support() # for Windows support |
| 920 |
tqdm.set_lock(RLock()) # for managing output contention |
| 921 |
p = Pool(initializer=tqdm.set_lock, initargs=(tqdm.get_lock(),)) |
| 922 |
p.map(progresser, L) |
| 923 |
|
| 924 |
Note that in Python 3, ``tqdm.write`` is thread-safe: |
| 925 |
|
| 926 |
.. code:: python |
| 927 |
|
| 928 |
from time import sleep |
| 929 |
from tqdm import tqdm, trange |
| 930 |
from concurrent.futures import ThreadPoolExecutor |
| 931 |
|
| 932 |
L = list(range(9)) |
| 933 |
|
| 934 |
def progresser(n): |
| 935 |
interval = 0.001 / (n + 2) |
| 936 |
total = 5000 |
| 937 |
text = f"#{n}, est. {interval * total:<04.2}s" |
| 938 |
for _ in trange(total, desc=text): |
| 939 |
sleep(interval) |
| 940 |
if n == 6: |
| 941 |
tqdm.write("n == 6 completed.") |
| 942 |
tqdm.write("`tqdm.write()` is thread-safe in py3!") |
| 943 |
|
| 944 |
if __name__ == '__main__': |
| 945 |
with ThreadPoolExecutor() as p: |
| 946 |
p.map(progresser, L) |
| 947 |
|
| 948 |
Hooks and callbacks |
| 949 |
~~~~~~~~~~~~~~~~~~~ |
| 950 |
|
| 951 |
``tqdm`` can easily support callbacks/hooks and manual updates. |
| 952 |
Here's an example with ``urllib``: |
| 953 |
|
| 954 |
**``urllib.urlretrieve`` documentation** |
| 955 |
|
| 956 |
| [...] |
| 957 |
| If present, the hook function will be called once |
| 958 |
| on establishment of the network connection and once after each block read |
| 959 |
| thereafter. The hook will be passed three arguments; a count of blocks |
| 960 |
| transferred so far, a block size in bytes, and the total size of the file. |
| 961 |
| [...] |
| 962 |
|
| 963 |
.. code:: python |
| 964 |
|
| 965 |
import urllib, os |
| 966 |
from tqdm import tqdm |
| 967 |
urllib = getattr(urllib, 'request', urllib) |
| 968 |
|
| 969 |
class TqdmUpTo(tqdm): |
| 970 |
"""Provides `update_to(n)` which uses `tqdm.update(delta_n)`.""" |
| 971 |
def update_to(self, b=1, bsize=1, tsize=None): |
| 972 |
""" |
| 973 |
b : int, optional |
| 974 |
Number of blocks transferred so far [default: 1]. |
| 975 |
bsize : int, optional |
| 976 |
Size of each block (in tqdm units) [default: 1]. |
| 977 |
tsize : int, optional |
| 978 |
Total size (in tqdm units). If [default: None] remains unchanged. |
| 979 |
""" |
| 980 |
if tsize is not None: |
| 981 |
self.total = tsize |
| 982 |
return self.update(b * bsize - self.n) # also sets self.n = b * bsize |
| 983 |
|
| 984 |
eg_link = "https://caspersci.uk.to/matryoshka.zip" |
| 985 |
with TqdmUpTo(unit='B', unit_scale=True, unit_divisor=1024, miniters=1, |
| 986 |
desc=eg_link.split('/')[-1]) as t: # all optional kwargs |
| 987 |
urllib.urlretrieve(eg_link, filename=os.devnull, |
| 988 |
reporthook=t.update_to, data=None) |
| 989 |
t.total = t.n |
| 990 |
|
| 991 |
Inspired by `twine#242 <https://github.com/pypa/twine/pull/242>`__. |
| 992 |
Functional alternative in |
| 993 |
`examples/tqdm_wget.py <https://github.com/tqdm/tqdm/blob/master/examples/tqdm_wget.py>`__. |
| 994 |
|
| 995 |
It is recommend to use ``miniters=1`` whenever there is potentially |
| 996 |
large differences in iteration speed (e.g. downloading a file over |
| 997 |
a patchy connection). |
| 998 |
|
| 999 |
**Wrapping read/write methods** |
| 1000 |
|
| 1001 |
To measure throughput through a file-like object's ``read`` or ``write`` |
| 1002 |
methods, use ``CallbackIOWrapper``: |
| 1003 |
|
| 1004 |
.. code:: python |
| 1005 |
|
| 1006 |
from tqdm.auto import tqdm |
| 1007 |
from tqdm.utils import CallbackIOWrapper |
| 1008 |
|
| 1009 |
with tqdm(total=file_obj.size, |
| 1010 |
unit='B', unit_scale=True, unit_divisor=1024) as t: |
| 1011 |
fobj = CallbackIOWrapper(t.update, file_obj, "read") |
| 1012 |
while True: |
| 1013 |
chunk = fobj.read(chunk_size) |
| 1014 |
if not chunk: |
| 1015 |
break |
| 1016 |
t.reset() |
| 1017 |
# ... continue to use `t` for something else |
| 1018 |
|
| 1019 |
Alternatively, use the even simpler ``wrapattr`` convenience function, |
| 1020 |
which would condense both the ``urllib`` and ``CallbackIOWrapper`` examples |
| 1021 |
down to: |
| 1022 |
|
| 1023 |
.. code:: python |
| 1024 |
|
| 1025 |
import urllib, os |
| 1026 |
from tqdm import tqdm |
| 1027 |
|
| 1028 |
eg_link = "https://caspersci.uk.to/matryoshka.zip" |
| 1029 |
response = getattr(urllib, 'request', urllib).urlopen(eg_link) |
| 1030 |
with tqdm.wrapattr(open(os.devnull, "wb"), "write", |
| 1031 |
miniters=1, desc=eg_link.split('/')[-1], |
| 1032 |
total=getattr(response, 'length', None)) as fout: |
| 1033 |
for chunk in response: |
| 1034 |
fout.write(chunk) |
| 1035 |
|
| 1036 |
The ``requests`` equivalent is nearly identical: |
| 1037 |
|
| 1038 |
.. code:: python |
| 1039 |
|
| 1040 |
import requests, os |
| 1041 |
from tqdm import tqdm |
| 1042 |
|
| 1043 |
eg_link = "https://caspersci.uk.to/matryoshka.zip" |
| 1044 |
response = requests.get(eg_link, stream=True) |
| 1045 |
with tqdm.wrapattr(open(os.devnull, "wb"), "write", |
| 1046 |
miniters=1, desc=eg_link.split('/')[-1], |
| 1047 |
total=int(response.headers.get('content-length', 0))) as fout: |
| 1048 |
for chunk in response.iter_content(chunk_size=4096): |
| 1049 |
fout.write(chunk) |
| 1050 |
|
| 1051 |
**Custom callback** |
| 1052 |
|
| 1053 |
``tqdm`` is known for intelligently skipping unnecessary displays. To make a |
| 1054 |
custom callback take advantage of this, simply use the return value of |
| 1055 |
``update()``. This is set to ``True`` if a ``display()`` was triggered. |
| 1056 |
|
| 1057 |
.. code:: python |
| 1058 |
|
| 1059 |
from tqdm.auto import tqdm as std_tqdm |
| 1060 |
|
| 1061 |
def external_callback(*args, **kwargs): |
| 1062 |
... |
| 1063 |
|
| 1064 |
class TqdmExt(std_tqdm): |
| 1065 |
def update(self, n=1): |
| 1066 |
displayed = super(TqdmExt, self).update(n) |
| 1067 |
if displayed: |
| 1068 |
external_callback(**self.format_dict) |
| 1069 |
return displayed |
| 1070 |
|
| 1071 |
``asyncio`` |
| 1072 |
~~~~~~~~~~~ |
| 1073 |
|
| 1074 |
Note that ``break`` isn't currently caught by asynchronous iterators. |
| 1075 |
This means that ``tqdm`` cannot clean up after itself in this case: |
| 1076 |
|
| 1077 |
.. code:: python |
| 1078 |
|
| 1079 |
from tqdm.asyncio import tqdm |
| 1080 |
|
| 1081 |
async for i in tqdm(range(9)): |
| 1082 |
if i == 2: |
| 1083 |
break |
| 1084 |
|
| 1085 |
Instead, either call ``pbar.close()`` manually or use the context manager syntax: |
| 1086 |
|
| 1087 |
.. code:: python |
| 1088 |
|
| 1089 |
from tqdm.asyncio import tqdm |
| 1090 |
|
| 1091 |
with tqdm(range(9)) as pbar: |
| 1092 |
async for i in pbar: |
| 1093 |
if i == 2: |
| 1094 |
break |
| 1095 |
|
| 1096 |
Pandas Integration |
| 1097 |
~~~~~~~~~~~~~~~~~~ |
| 1098 |
|
| 1099 |
Due to popular demand we've added support for ``pandas`` -- here's an example |
| 1100 |
for ``DataFrame.progress_apply`` and ``DataFrameGroupBy.progress_apply``: |
| 1101 |
|
| 1102 |
.. code:: python |
| 1103 |
|
| 1104 |
import pandas as pd |
| 1105 |
import numpy as np |
| 1106 |
from tqdm import tqdm |
| 1107 |
|
| 1108 |
df = pd.DataFrame(np.random.randint(0, 100, (100000, 6))) |
| 1109 |
|
| 1110 |
# Register `pandas.progress_apply` and `pandas.Series.map_apply` with `tqdm` |
| 1111 |
# (can use `tqdm.gui.tqdm`, `tqdm.notebook.tqdm`, optional kwargs, etc.) |
| 1112 |
tqdm.pandas(desc="my bar!") |
| 1113 |
|
| 1114 |
# Now you can use `progress_apply` instead of `apply` |
| 1115 |
# and `progress_map` instead of `map` |
| 1116 |
df.progress_apply(lambda x: x**2) |
| 1117 |
# can also groupby: |
| 1118 |
# df.groupby(0).progress_apply(lambda x: x**2) |
| 1119 |
|
| 1120 |
In case you're interested in how this works (and how to modify it for your |
| 1121 |
own callbacks), see the |
| 1122 |
`examples <https://github.com/tqdm/tqdm/tree/master/examples>`__ |
| 1123 |
folder or import the module and run ``help()``. |
| 1124 |
|
| 1125 |
Keras Integration |
| 1126 |
~~~~~~~~~~~~~~~~~ |
| 1127 |
|
| 1128 |
A ``keras`` callback is also available: |
| 1129 |
|
| 1130 |
.. code:: python |
| 1131 |
|
| 1132 |
from tqdm.keras import TqdmCallback |
| 1133 |
|
| 1134 |
... |
| 1135 |
|
| 1136 |
model.fit(..., verbose=0, callbacks=[TqdmCallback()]) |
| 1137 |
|
| 1138 |
Dask Integration |
| 1139 |
~~~~~~~~~~~~~~~~ |
| 1140 |
|
| 1141 |
A ``dask`` callback is also available: |
| 1142 |
|
| 1143 |
.. code:: python |
| 1144 |
|
| 1145 |
from tqdm.dask import TqdmCallback |
| 1146 |
|
| 1147 |
with TqdmCallback(desc="compute"): |
| 1148 |
... |
| 1149 |
arr.compute() |
| 1150 |
|
| 1151 |
# or use callback globally |
| 1152 |
cb = TqdmCallback(desc="global") |
| 1153 |
cb.register() |
| 1154 |
arr.compute() |
| 1155 |
|
| 1156 |
IPython/Jupyter Integration |
| 1157 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 1158 |
|
| 1159 |
IPython/Jupyter is supported via the ``tqdm.notebook`` submodule: |
| 1160 |
|
| 1161 |
.. code:: python |
| 1162 |
|
| 1163 |
from tqdm.notebook import trange, tqdm |
| 1164 |
from time import sleep |
| 1165 |
|
| 1166 |
for i in trange(3, desc='1st loop'): |
| 1167 |
for j in tqdm(range(100), desc='2nd loop'): |
| 1168 |
sleep(0.01) |
| 1169 |
|
| 1170 |
In addition to ``tqdm`` features, the submodule provides a native Jupyter |
| 1171 |
widget (compatible with IPython v1-v4 and Jupyter), fully working nested bars |
| 1172 |
and colour hints (blue: normal, green: completed, red: error/interrupt, |
| 1173 |
light blue: no ETA); as demonstrated below. |
| 1174 |
|
| 1175 |
|Screenshot-Jupyter1| |
| 1176 |
|Screenshot-Jupyter2| |
| 1177 |
|Screenshot-Jupyter3| |
| 1178 |
|
| 1179 |
The ``notebook`` version supports percentage or pixels for overall width |
| 1180 |
(e.g.: ``ncols='100%'`` or ``ncols='480px'``). |
| 1181 |
|
| 1182 |
It is also possible to let ``tqdm`` automatically choose between |
| 1183 |
console or notebook versions by using the ``autonotebook`` submodule: |
| 1184 |
|
| 1185 |
.. code:: python |
| 1186 |
|
| 1187 |
from tqdm.autonotebook import tqdm |
| 1188 |
tqdm.pandas() |
| 1189 |
|
| 1190 |
Note that this will issue a ``TqdmExperimentalWarning`` if run in a notebook |
| 1191 |
since it is not meant to be possible to distinguish between ``jupyter notebook`` |
| 1192 |
and ``jupyter console``. Use ``auto`` instead of ``autonotebook`` to suppress |
| 1193 |
this warning. |
| 1194 |
|
| 1195 |
Note that notebooks will display the bar in the cell where it was created. |
| 1196 |
This may be a different cell from the one where it is used. |
| 1197 |
If this is not desired, either |
| 1198 |
|
| 1199 |
- delay the creation of the bar to the cell where it must be displayed, or |
| 1200 |
- create the bar with ``display=False``, and in a later cell call |
| 1201 |
``display(bar.container)``: |
| 1202 |
|
| 1203 |
.. code:: python |
| 1204 |
|
| 1205 |
from tqdm.notebook import tqdm |
| 1206 |
pbar = tqdm(..., display=False) |
| 1207 |
|
| 1208 |
.. code:: python |
| 1209 |
|
| 1210 |
# different cell |
| 1211 |
display(pbar.container) |
| 1212 |
|
| 1213 |
The ``keras`` callback has a ``display()`` method which can be used likewise: |
| 1214 |
|
| 1215 |
.. code:: python |
| 1216 |
|
| 1217 |
from tqdm.keras import TqdmCallback |
| 1218 |
cbk = TqdmCallback(display=False) |
| 1219 |
|
| 1220 |
.. code:: python |
| 1221 |
|
| 1222 |
# different cell |
| 1223 |
cbk.display() |
| 1224 |
model.fit(..., verbose=0, callbacks=[cbk]) |
| 1225 |
|
| 1226 |
Another possibility is to have a single bar (near the top of the notebook) |
| 1227 |
which is constantly re-used (using ``reset()`` rather than ``close()``). |
| 1228 |
For this reason, the notebook version (unlike the CLI version) does not |
| 1229 |
automatically call ``close()`` upon ``Exception``. |
| 1230 |
|
| 1231 |
.. code:: python |
| 1232 |
|
| 1233 |
from tqdm.notebook import tqdm |
| 1234 |
pbar = tqdm() |
| 1235 |
|
| 1236 |
.. code:: python |
| 1237 |
|
| 1238 |
# different cell |
| 1239 |
iterable = range(100) |
| 1240 |
pbar.reset(total=len(iterable)) # initialise with new `total` |
| 1241 |
for i in iterable: |
| 1242 |
pbar.update() |
| 1243 |
pbar.refresh() # force print final status but don't `close()` |
| 1244 |
|
| 1245 |
Custom Integration |
| 1246 |
~~~~~~~~~~~~~~~~~~ |
| 1247 |
|
| 1248 |
To change the default arguments (such as making ``dynamic_ncols=True``), |
| 1249 |
simply use built-in Python magic: |
| 1250 |
|
| 1251 |
.. code:: python |
| 1252 |
|
| 1253 |
from functools import partial |
| 1254 |
from tqdm import tqdm as std_tqdm |
| 1255 |
tqdm = partial(std_tqdm, dynamic_ncols=True) |
| 1256 |
|
| 1257 |
For further customisation, |
| 1258 |
``tqdm`` may be inherited from to create custom callbacks (as with the |
| 1259 |
``TqdmUpTo`` example `above <#hooks-and-callbacks>`__) or for custom frontends |
| 1260 |
(e.g. GUIs such as notebook or plotting packages). In the latter case: |
| 1261 |
|
| 1262 |
1. ``def __init__()`` to call ``super().__init__(..., gui=True)`` to disable |
| 1263 |
terminal ``status_printer`` creation. |
| 1264 |
2. Redefine: ``close()``, ``clear()``, ``display()``. |
| 1265 |
|
| 1266 |
Consider overloading ``display()`` to use e.g. |
| 1267 |
``self.frontend(**self.format_dict)`` instead of ``self.sp(repr(self))``. |
| 1268 |
|
| 1269 |
Some submodule examples of inheritance: |
| 1270 |
|
| 1271 |
- `tqdm/notebook.py <https://github.com/tqdm/tqdm/blob/master/tqdm/notebook.py>`__ |
| 1272 |
- `tqdm/gui.py <https://github.com/tqdm/tqdm/blob/master/tqdm/gui.py>`__ |
| 1273 |
- `tqdm/tk.py <https://github.com/tqdm/tqdm/blob/master/tqdm/tk.py>`__ |
| 1274 |
- `tqdm/contrib/slack.py <https://github.com/tqdm/tqdm/blob/master/tqdm/contrib/slack.py>`__ |
| 1275 |
- `tqdm/contrib/discord.py <https://github.com/tqdm/tqdm/blob/master/tqdm/contrib/discord.py>`__ |
| 1276 |
- `tqdm/contrib/telegram.py <https://github.com/tqdm/tqdm/blob/master/tqdm/contrib/telegram.py>`__ |
| 1277 |
|
| 1278 |
Dynamic Monitor/Meter |
| 1279 |
~~~~~~~~~~~~~~~~~~~~~ |
| 1280 |
|
| 1281 |
You can use a ``tqdm`` as a meter which is not monotonically increasing. |
| 1282 |
This could be because ``n`` decreases (e.g. a CPU usage monitor) or ``total`` |
| 1283 |
changes. |
| 1284 |
|
| 1285 |
One example would be recursively searching for files. The ``total`` is the |
| 1286 |
number of objects found so far, while ``n`` is the number of those objects which |
| 1287 |
are files (rather than folders): |
| 1288 |
|
| 1289 |
.. code:: python |
| 1290 |
|
| 1291 |
from tqdm import tqdm |
| 1292 |
import os.path |
| 1293 |
|
| 1294 |
def find_files_recursively(path, show_progress=True): |
| 1295 |
files = [] |
| 1296 |
# total=1 assumes `path` is a file |
| 1297 |
t = tqdm(total=1, unit="file", disable=not show_progress) |
| 1298 |
if not os.path.exists(path): |
| 1299 |
raise IOError("Cannot find:" + path) |
| 1300 |
|
| 1301 |
def append_found_file(f): |
| 1302 |
files.append(f) |
| 1303 |
t.update() |
| 1304 |
|
| 1305 |
def list_found_dir(path): |
| 1306 |
"""returns os.listdir(path) assuming os.path.isdir(path)""" |
| 1307 |
listing = os.listdir(path) |
| 1308 |
# subtract 1 since a "file" we found was actually this directory |
| 1309 |
t.total += len(listing) - 1 |
| 1310 |
# fancy way to give info without forcing a refresh |
| 1311 |
t.set_postfix(dir=path[-10:], refresh=False) |
| 1312 |
t.update(0) # may trigger a refresh |
| 1313 |
return listing |
| 1314 |
|
| 1315 |
def recursively_search(path): |
| 1316 |
if os.path.isdir(path): |
| 1317 |
for f in list_found_dir(path): |
| 1318 |
recursively_search(os.path.join(path, f)) |
| 1319 |
else: |
| 1320 |
append_found_file(path) |
| 1321 |
|
| 1322 |
recursively_search(path) |
| 1323 |
t.set_postfix(dir=path) |
| 1324 |
t.close() |
| 1325 |
return files |
| 1326 |
|
| 1327 |
Using ``update(0)`` is a handy way to let ``tqdm`` decide when to trigger a |
| 1328 |
display refresh to avoid console spamming. |
| 1329 |
|
| 1330 |
Writing messages |
| 1331 |
~~~~~~~~~~~~~~~~ |
| 1332 |
|
| 1333 |
This is a work in progress (see |
| 1334 |
`#737 <https://github.com/tqdm/tqdm/issues/737>`__). |
| 1335 |
|
| 1336 |
Since ``tqdm`` uses a simple printing mechanism to display progress bars, |
| 1337 |
you should not write any message in the terminal using ``print()`` while |
| 1338 |
a progressbar is open. |
| 1339 |
|
| 1340 |
To write messages in the terminal without any collision with ``tqdm`` bar |
| 1341 |
display, a ``.write()`` method is provided: |
| 1342 |
|
| 1343 |
.. code:: python |
| 1344 |
|
| 1345 |
from tqdm.auto import tqdm, trange |
| 1346 |
from time import sleep |
| 1347 |
|
| 1348 |
bar = trange(10) |
| 1349 |
for i in bar: |
| 1350 |
# Print using tqdm class method .write() |
| 1351 |
sleep(0.1) |
| 1352 |
if not (i % 3): |
| 1353 |
tqdm.write("Done task %i" % i) |
| 1354 |
# Can also use bar.write() |
| 1355 |
|
| 1356 |
By default, this will print to standard output ``sys.stdout``. but you can |
| 1357 |
specify any file-like object using the ``file`` argument. For example, this |
| 1358 |
can be used to redirect the messages writing to a log file or class. |
| 1359 |
|
| 1360 |
Redirecting writing |
| 1361 |
~~~~~~~~~~~~~~~~~~~ |
| 1362 |
|
| 1363 |
If using a library that can print messages to the console, editing the library |
| 1364 |
by replacing ``print()`` with ``tqdm.write()`` may not be desirable. |
| 1365 |
In that case, redirecting ``sys.stdout`` to ``tqdm.write()`` is an option. |
| 1366 |
|
| 1367 |
To redirect ``sys.stdout``, create a file-like class that will write |
| 1368 |
any input string to ``tqdm.write()``, and supply the arguments |
| 1369 |
``file=sys.stdout, dynamic_ncols=True``. |
| 1370 |
|
| 1371 |
A reusable canonical example is given below: |
| 1372 |
|
| 1373 |
.. code:: python |
| 1374 |
|
| 1375 |
from time import sleep |
| 1376 |
import contextlib |
| 1377 |
import sys |
| 1378 |
from tqdm import tqdm |
| 1379 |
from tqdm.contrib import DummyTqdmFile |
| 1380 |
|
| 1381 |
|
| 1382 |
@contextlib.contextmanager |
| 1383 |
def std_out_err_redirect_tqdm(): |
| 1384 |
orig_out_err = sys.stdout, sys.stderr |
| 1385 |
try: |
| 1386 |
sys.stdout, sys.stderr = map(DummyTqdmFile, orig_out_err) |
| 1387 |
yield orig_out_err[0] |
| 1388 |
# Relay exceptions |
| 1389 |
except Exception as exc: |
| 1390 |
raise exc |
| 1391 |
# Always restore sys.stdout/err if necessary |
| 1392 |
finally: |
| 1393 |
sys.stdout, sys.stderr = orig_out_err |
| 1394 |
|
| 1395 |
def some_fun(i): |
| 1396 |
print("Fee, fi, fo,".split()[i]) |
| 1397 |
|
| 1398 |
# Redirect stdout to tqdm.write() (don't forget the `as save_stdout`) |
| 1399 |
with std_out_err_redirect_tqdm() as orig_stdout: |
| 1400 |
# tqdm needs the original stdout |
| 1401 |
# and dynamic_ncols=True to autodetect console width |
| 1402 |
for i in tqdm(range(3), file=orig_stdout, dynamic_ncols=True): |
| 1403 |
sleep(.5) |
| 1404 |
some_fun(i) |
| 1405 |
|
| 1406 |
# After the `with`, printing is restored |
| 1407 |
print("Done!") |
| 1408 |
|
| 1409 |
Redirecting ``logging`` |
| 1410 |
~~~~~~~~~~~~~~~~~~~~~~~ |
| 1411 |
|
| 1412 |
Similar to ``sys.stdout``/``sys.stderr`` as detailed above, console ``logging`` |
| 1413 |
may also be redirected to ``tqdm.write()``. |
| 1414 |
|
| 1415 |
Warning: if also redirecting ``sys.stdout``/``sys.stderr``, make sure to |
| 1416 |
redirect ``logging`` first if needed. |
| 1417 |
|
| 1418 |
Helper methods are available in ``tqdm.contrib.logging``. For example: |
| 1419 |
|
| 1420 |
.. code:: python |
| 1421 |
|
| 1422 |
import logging |
| 1423 |
from tqdm import trange |
| 1424 |
from tqdm.contrib.logging import logging_redirect_tqdm |
| 1425 |
|
| 1426 |
LOG = logging.getLogger(__name__) |
| 1427 |
|
| 1428 |
if __name__ == '__main__': |
| 1429 |
logging.basicConfig(level=logging.INFO) |
| 1430 |
with logging_redirect_tqdm(): |
| 1431 |
for i in trange(9): |
| 1432 |
if i == 4: |
| 1433 |
LOG.info("console logging redirected to `tqdm.write()`") |
| 1434 |
# logging restored |
| 1435 |
|
| 1436 |
Monitoring thread, intervals and miniters |
| 1437 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 1438 |
|
| 1439 |
``tqdm`` implements a few tricks to increase efficiency and reduce overhead. |
| 1440 |
|
| 1441 |
- Avoid unnecessary frequent bar refreshing: ``mininterval`` defines how long |
| 1442 |
to wait between each refresh. ``tqdm`` always gets updated in the background, |
| 1443 |
but it will display only every ``mininterval``. |
| 1444 |
- Reduce number of calls to check system clock/time. |
| 1445 |
- ``mininterval`` is more intuitive to configure than ``miniters``. |
| 1446 |
A clever adjustment system ``dynamic_miniters`` will automatically adjust |
| 1447 |
``miniters`` to the amount of iterations that fit into time ``mininterval``. |
| 1448 |
Essentially, ``tqdm`` will check if it's time to print without actually |
| 1449 |
checking time. This behaviour can be still be bypassed by manually setting |
| 1450 |
``miniters``. |
| 1451 |
|
| 1452 |
However, consider a case with a combination of fast and slow iterations. |
| 1453 |
After a few fast iterations, ``dynamic_miniters`` will set ``miniters`` to a |
| 1454 |
large number. When iteration rate subsequently slows, ``miniters`` will |
| 1455 |
remain large and thus reduce display update frequency. To address this: |
| 1456 |
|
| 1457 |
- ``maxinterval`` defines the maximum time between display refreshes. |
| 1458 |
A concurrent monitoring thread checks for overdue updates and forces one |
| 1459 |
where necessary. |
| 1460 |
|
| 1461 |
The monitoring thread should not have a noticeable overhead, and guarantees |
| 1462 |
updates at least every 10 seconds by default. |
| 1463 |
This value can be directly changed by setting the ``monitor_interval`` of |
| 1464 |
any ``tqdm`` instance (i.e. ``t = tqdm.tqdm(...); t.monitor_interval = 2``). |
| 1465 |
The monitor thread may be disabled application-wide by setting |
| 1466 |
``tqdm.tqdm.monitor_interval = 0`` before instantiation of any ``tqdm`` bar. |
| 1467 |
|
| 1468 |
|
| 1469 |
Merch |
| 1470 |
----- |
| 1471 |
|
| 1472 |
You can buy `tqdm branded merch <https://tqdm.github.io/merch>`__ now! |
| 1473 |
|
| 1474 |
Contributions |
| 1475 |
------------- |
| 1476 |
|
| 1477 |
|GitHub-Commits| |GitHub-Issues| |GitHub-PRs| |OpenHub-Status| |GitHub-Contributions| |CII Best Practices| |
| 1478 |
|
| 1479 |
All source code is hosted on `GitHub <https://github.com/tqdm/tqdm>`__. |
| 1480 |
Contributions are welcome. |
| 1481 |
|
| 1482 |
See the |
| 1483 |
`CONTRIBUTING <https://github.com/tqdm/tqdm/blob/master/CONTRIBUTING.md>`__ |
| 1484 |
file for more information. |
| 1485 |
|
| 1486 |
Developers who have made significant contributions, ranked by *SLoC* |
| 1487 |
(surviving lines of code, |
| 1488 |
`git fame <https://github.com/casperdcl/git-fame>`__ ``-wMC --excl '\.(png|gif|jpg)$'``), |
| 1489 |
are: |
| 1490 |
|
| 1491 |
==================== ======================================================== ==== ================================ |
| 1492 |
Name ID SLoC Notes |
| 1493 |
==================== ======================================================== ==== ================================ |
| 1494 |
Casper da Costa-Luis `casperdcl <https://github.com/casperdcl>`__ ~80% primary maintainer |Gift-Casper| |
| 1495 |
Stephen Larroque `lrq3000 <https://github.com/lrq3000>`__ ~9% team member |
| 1496 |
Martin Zugnoni `martinzugnoni <https://github.com/martinzugnoni>`__ ~3% |
| 1497 |
Daniel Ecer `de-code <https://github.com/de-code>`__ ~2% |
| 1498 |
Richard Sheridan `richardsheridan <https://github.com/richardsheridan>`__ ~1% |
| 1499 |
Guangshuo Chen `chengs <https://github.com/chengs>`__ ~1% |
| 1500 |
Helio Machado `0x2b3bfa0 <https://github.com/0x2b3bfa0>`__ ~1% |
| 1501 |
Kyle Altendorf `altendky <https://github.com/altendky>`__ <1% |
| 1502 |
Noam Yorav-Raphael `noamraph <https://github.com/noamraph>`__ <1% original author |
| 1503 |
Matthew Stevens `mjstevens777 <https://github.com/mjstevens777>`__ <1% |
| 1504 |
Hadrien Mary `hadim <https://github.com/hadim>`__ <1% team member |
| 1505 |
Mikhail Korobov `kmike <https://github.com/kmike>`__ <1% team member |
| 1506 |
==================== ======================================================== ==== ================================ |
| 1507 |
|
| 1508 |
Ports to Other Languages |
| 1509 |
~~~~~~~~~~~~~~~~~~~~~~~~ |
| 1510 |
|
| 1511 |
A list is available on |
| 1512 |
`this wiki page <https://github.com/tqdm/tqdm/wiki/tqdm-ports>`__. |
| 1513 |
|
| 1514 |
|
| 1515 |
LICENCE |
| 1516 |
------- |
| 1517 |
|
| 1518 |
Open Source (OSI approved): |LICENCE| |
| 1519 |
|
| 1520 |
Citation information: |DOI| |
| 1521 |
|
| 1522 |
|README-Hits| (Since 19 May 2016) |
| 1523 |
|
| 1524 |
.. |Logo| image:: https://tqdm.github.io/img/logo.gif |
| 1525 |
.. |Screenshot| image:: https://tqdm.github.io/img/tqdm.gif |
| 1526 |
.. |Video| image:: https://tqdm.github.io/img/video.jpg |
| 1527 |
:target: https://tqdm.github.io/video |
| 1528 |
.. |Slides| image:: https://tqdm.github.io/img/slides.jpg |
| 1529 |
:target: https://tqdm.github.io/PyData2019/slides.html |
| 1530 |
.. |Merch| image:: https://tqdm.github.io/img/merch.jpg |
| 1531 |
:target: https://tqdm.github.io/merch |
| 1532 |
.. |Build-Status| image:: https://img.shields.io/github/actions/workflow/status/tqdm/tqdm/test.yml?branch=master&label=tqdm&logo=GitHub |
| 1533 |
:target: https://github.com/tqdm/tqdm/actions/workflows/test.yml |
| 1534 |
.. |Coverage-Status| image:: https://img.shields.io/coveralls/github/tqdm/tqdm/master?logo=coveralls |
| 1535 |
:target: https://coveralls.io/github/tqdm/tqdm |
| 1536 |
.. |Branch-Coverage-Status| image:: https://codecov.io/gh/tqdm/tqdm/branch/master/graph/badge.svg |
| 1537 |
:target: https://codecov.io/gh/tqdm/tqdm |
| 1538 |
.. |Codacy-Grade| image:: https://app.codacy.com/project/badge/Grade/3f965571598f44549c7818f29cdcf177 |
| 1539 |
:target: https://www.codacy.com/gh/tqdm/tqdm/dashboard |
| 1540 |
.. |CII Best Practices| image:: https://bestpractices.coreinfrastructure.org/projects/3264/badge |
| 1541 |
:target: https://bestpractices.coreinfrastructure.org/projects/3264 |
| 1542 |
.. |GitHub-Status| image:: https://img.shields.io/github/tag/tqdm/tqdm.svg?maxAge=86400&logo=github&logoColor=white |
| 1543 |
:target: https://github.com/tqdm/tqdm/releases |
| 1544 |
.. |GitHub-Forks| image:: https://img.shields.io/github/forks/tqdm/tqdm.svg?logo=github&logoColor=white |
| 1545 |
:target: https://github.com/tqdm/tqdm/network |
| 1546 |
.. |GitHub-Stars| image:: https://img.shields.io/github/stars/tqdm/tqdm.svg?logo=github&logoColor=white |
| 1547 |
:target: https://github.com/tqdm/tqdm/stargazers |
| 1548 |
.. |GitHub-Commits| image:: https://img.shields.io/github/commit-activity/y/tqdm/tqdm.svg?logo=git&logoColor=white |
| 1549 |
:target: https://github.com/tqdm/tqdm/graphs/commit-activity |
| 1550 |
.. |GitHub-Issues| image:: https://img.shields.io/github/issues-closed/tqdm/tqdm.svg?logo=github&logoColor=white |
| 1551 |
:target: https://github.com/tqdm/tqdm/issues?q= |
| 1552 |
.. |GitHub-PRs| image:: https://img.shields.io/github/issues-pr-closed/tqdm/tqdm.svg?logo=github&logoColor=white |
| 1553 |
:target: https://github.com/tqdm/tqdm/pulls |
| 1554 |
.. |GitHub-Contributions| image:: https://img.shields.io/github/contributors/tqdm/tqdm.svg?logo=github&logoColor=white |
| 1555 |
:target: https://github.com/tqdm/tqdm/graphs/contributors |
| 1556 |
.. |GitHub-Updated| image:: https://img.shields.io/github/last-commit/tqdm/tqdm/master.svg?logo=github&logoColor=white&label=pushed |
| 1557 |
:target: https://github.com/tqdm/tqdm/pulse |
| 1558 |
.. |Gift-Casper| image:: https://img.shields.io/badge/dynamic/json.svg?color=ff69b4&label=gifts%20received&prefix=%C2%A3&query=%24..sum&url=https%3A%2F%2Fcaspersci.uk.to%2Fgifts.json |
| 1559 |
:target: https://cdcl.ml/sponsor |
| 1560 |
.. |Versions| image:: https://img.shields.io/pypi/v/tqdm.svg |
| 1561 |
:target: https://tqdm.github.io/releases |
| 1562 |
.. |PyPI-Downloads| image:: https://img.shields.io/pypi/dm/tqdm.svg?label=pypi%20downloads&logo=PyPI&logoColor=white |
| 1563 |
:target: https://pepy.tech/project/tqdm |
| 1564 |
.. |Py-Versions| image:: https://img.shields.io/pypi/pyversions/tqdm.svg?logo=python&logoColor=white |
| 1565 |
:target: https://pypi.org/project/tqdm |
| 1566 |
.. |Conda-Forge-Status| image:: https://img.shields.io/conda/v/conda-forge/tqdm.svg?label=conda-forge&logo=conda-forge |
| 1567 |
:target: https://anaconda.org/conda-forge/tqdm |
| 1568 |
.. |Snapcraft| image:: https://img.shields.io/badge/snap-install-82BEA0.svg?logo=snapcraft |
| 1569 |
:target: https://snapcraft.io/tqdm |
| 1570 |
.. |Docker| image:: https://img.shields.io/badge/docker-pull-blue.svg?logo=docker&logoColor=white |
| 1571 |
:target: https://hub.docker.com/r/tqdm/tqdm |
| 1572 |
.. |Libraries-Rank| image:: https://img.shields.io/librariesio/sourcerank/pypi/tqdm.svg?logo=koding&logoColor=white |
| 1573 |
:target: https://libraries.io/pypi/tqdm |
| 1574 |
.. |Libraries-Dependents| image:: https://img.shields.io/librariesio/dependent-repos/pypi/tqdm.svg?logo=koding&logoColor=white |
| 1575 |
:target: https://github.com/tqdm/tqdm/network/dependents |
| 1576 |
.. |OpenHub-Status| image:: https://www.openhub.net/p/tqdm/widgets/project_thin_badge?format=gif |
| 1577 |
:target: https://www.openhub.net/p/tqdm?ref=Thin+badge |
| 1578 |
.. |awesome-python| image:: https://awesome.re/mentioned-badge.svg |
| 1579 |
:target: https://github.com/vinta/awesome-python |
| 1580 |
.. |LICENCE| image:: https://img.shields.io/pypi/l/tqdm.svg |
| 1581 |
:target: https://raw.githubusercontent.com/tqdm/tqdm/master/LICENCE |
| 1582 |
.. |DOI| image:: https://img.shields.io/badge/DOI-10.5281/zenodo.595120-blue.svg |
| 1583 |
:target: https://doi.org/10.5281/zenodo.595120 |
| 1584 |
.. |binder-demo| image:: https://mybinder.org/badge_logo.svg |
| 1585 |
:target: https://mybinder.org/v2/gh/tqdm/tqdm/master?filepath=DEMO.ipynb |
| 1586 |
.. |Screenshot-Jupyter1| image:: https://tqdm.github.io/img/jupyter-1.gif |
| 1587 |
.. |Screenshot-Jupyter2| image:: https://tqdm.github.io/img/jupyter-2.gif |
| 1588 |
.. |Screenshot-Jupyter3| image:: https://tqdm.github.io/img/jupyter-3.gif |
| 1589 |
.. |README-Hits| image:: https://caspersci.uk.to/cgi-bin/hits.cgi?q=tqdm&style=social&r=https://github.com/tqdm/tqdm&l=https://tqdm.github.io/img/favicon.png&f=https://tqdm.github.io/img/logo.gif |
| 1590 |
:target: https://caspersci.uk.to/cgi-bin/hits.cgi?q=tqdm&a=plot&r=https://github.com/tqdm/tqdm&l=https://tqdm.github.io/img/favicon.png&f=https://tqdm.github.io/img/logo.gif&style=social |