Skip to content

Commit

Permalink
bump version, merge pull request tqdm#1112 from tqdm/devel
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl authored Jan 11, 2021
2 parents e697193 + daf3689 commit c58fc25
Show file tree
Hide file tree
Showing 11 changed files with 484 additions and 73 deletions.
49 changes: 32 additions & 17 deletions .meta/.readme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ Latest development release on GitHub

|GitHub-Status| |GitHub-Stars| |GitHub-Commits| |GitHub-Forks| |GitHub-Updated|

Pull and install in the current directory:
Pull and install pre-release ``devel`` branch:

.. code:: sh
pip install -e git+https://github.com/tqdm/tqdm.git@master#egg=tqdm
pip install "git+https://github.com/tqdm/tqdm.git@devel#egg=tqdm"
Latest Conda release
~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -417,11 +417,28 @@ Returns
On Python3+, `range` is used instead of `xrange`.
"""
class tqdm.notebook.tqdm(tqdm.tqdm):
"""Experimental IPython/Jupyter Notebook widget."""
Convenience Functions
~~~~~~~~~~~~~~~~~~~~~

.. code:: python
def tqdm.contrib.tenumerate(iterable, start=0, total=None,
tqdm_class=tqdm.auto.tqdm, **tqdm_kwargs):
"""Equivalent of `numpy.ndenumerate` or builtin `enumerate`."""
def tqdm.contrib.tzip(iter1, *iter2plus, **tqdm_kwargs):
"""Equivalent of builtin `zip`."""
def tqdm.contrib.tmap(function, *sequences, **tqdm_kwargs):
"""Equivalent of builtin `map`."""
Submodules
~~~~~~~~~~

.. code:: python
def tqdm.notebook.trange(*args, **tqdm_kwargs):
"""Experimental IPython/Jupyter Notebook widget version of `trange`."""
class tqdm.notebook.tqdm(tqdm.tqdm):
"""IPython/Jupyter Notebook widget."""
class tqdm.auto.tqdm(tqdm.tqdm):
"""Automatically chooses beween `tqdm.notebook` and `tqdm.tqdm`."""
Expand All @@ -434,23 +451,20 @@ Returns
"""Wrapper for `asyncio.as_completed`."""
class tqdm.gui.tqdm(tqdm.tqdm):
"""Experimental GUI version."""
"""Matplotlib GUI version."""
class tqdm.keras.TqdmCallback(keras.callbacks.Callback):
"""`keras` callback for epoch and batch progress."""
class tqdm.tk.tqdm(tqdm.tqdm):
"""Tkinter GUI version."""
def tqdm.contrib.tenumerate(iterable, start=0, total=None,
tqdm_class=tqdm.auto.tqdm, **tqdm_kwargs):
"""Equivalent of `numpy.ndenumerate` or builtin `enumerate`."""
class tqdm.rich.tqdm(tqdm.tqdm):
"""`rich.progress` version."""
def tqdm.contrib.tzip(iter1, *iter2plus, **tqdm_kwargs):
"""Equivalent of builtin `zip`."""
class tqdm.keras.TqdmCallback(keras.callbacks.Callback):
"""`keras` callback for epoch and batch progress."""
def tqdm.contrib.tmap(function, *sequences, **tqdm_kwargs):
"""Equivalent of builtin `map`."""
``contrib``
-----------
+++++++++++

The ``tqdm.contrib`` package also contains experimental modules:

Expand Down Expand Up @@ -929,6 +943,7 @@ Some submodule examples of inheritance:

- `tqdm/notebook.py <https://github.com/tqdm/tqdm/blob/master/tqdm/notebook.py>`__
- `tqdm/gui.py <https://github.com/tqdm/tqdm/blob/master/tqdm/gui.py>`__
- `tqdm/tk.py <https://github.com/tqdm/tqdm/blob/master/tqdm/tk.py>`__
- `tqdm/contrib/telegram.py <https://github.com/tqdm/tqdm/blob/master/tqdm/contrib/telegram.py>`__
- `tqdm/contrib/discord.py <https://github.com/tqdm/tqdm/blob/master/tqdm/contrib/discord.py>`__

Expand Down
49 changes: 32 additions & 17 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ Latest development release on GitHub

|GitHub-Status| |GitHub-Stars| |GitHub-Commits| |GitHub-Forks| |GitHub-Updated|

Pull and install in the current directory:
Pull and install pre-release ``devel`` branch:

.. code:: sh
pip install -e git+https://github.com/tqdm/tqdm.git@master#egg=tqdm
pip install "git+https://github.com/tqdm/tqdm.git@devel#egg=tqdm"
Latest Conda release
~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -634,11 +634,28 @@ Returns
On Python3+, `range` is used instead of `xrange`.
"""
class tqdm.notebook.tqdm(tqdm.tqdm):
"""Experimental IPython/Jupyter Notebook widget."""
Convenience Functions
~~~~~~~~~~~~~~~~~~~~~

.. code:: python
def tqdm.contrib.tenumerate(iterable, start=0, total=None,
tqdm_class=tqdm.auto.tqdm, **tqdm_kwargs):
"""Equivalent of `numpy.ndenumerate` or builtin `enumerate`."""
def tqdm.contrib.tzip(iter1, *iter2plus, **tqdm_kwargs):
"""Equivalent of builtin `zip`."""
def tqdm.contrib.tmap(function, *sequences, **tqdm_kwargs):
"""Equivalent of builtin `map`."""
Submodules
~~~~~~~~~~

.. code:: python
def tqdm.notebook.trange(*args, **tqdm_kwargs):
"""Experimental IPython/Jupyter Notebook widget version of `trange`."""
class tqdm.notebook.tqdm(tqdm.tqdm):
"""IPython/Jupyter Notebook widget."""
class tqdm.auto.tqdm(tqdm.tqdm):
"""Automatically chooses beween `tqdm.notebook` and `tqdm.tqdm`."""
Expand All @@ -651,23 +668,20 @@ Returns
"""Wrapper for `asyncio.as_completed`."""
class tqdm.gui.tqdm(tqdm.tqdm):
"""Experimental GUI version."""
"""Matplotlib GUI version."""
class tqdm.keras.TqdmCallback(keras.callbacks.Callback):
"""`keras` callback for epoch and batch progress."""
class tqdm.tk.tqdm(tqdm.tqdm):
"""Tkinter GUI version."""
def tqdm.contrib.tenumerate(iterable, start=0, total=None,
tqdm_class=tqdm.auto.tqdm, **tqdm_kwargs):
"""Equivalent of `numpy.ndenumerate` or builtin `enumerate`."""
class tqdm.rich.tqdm(tqdm.tqdm):
"""`rich.progress` version."""
def tqdm.contrib.tzip(iter1, *iter2plus, **tqdm_kwargs):
"""Equivalent of builtin `zip`."""
class tqdm.keras.TqdmCallback(keras.callbacks.Callback):
"""`keras` callback for epoch and batch progress."""
def tqdm.contrib.tmap(function, *sequences, **tqdm_kwargs):
"""Equivalent of builtin `map`."""
``contrib``
-----------
+++++++++++

The ``tqdm.contrib`` package also contains experimental modules:

Expand Down Expand Up @@ -1146,6 +1160,7 @@ Some submodule examples of inheritance:

- `tqdm/notebook.py <https://github.com/tqdm/tqdm/blob/master/tqdm/notebook.py>`__
- `tqdm/gui.py <https://github.com/tqdm/tqdm/blob/master/tqdm/gui.py>`__
- `tqdm/tk.py <https://github.com/tqdm/tqdm/blob/master/tqdm/tk.py>`__
- `tqdm/contrib/telegram.py <https://github.com/tqdm/tqdm/blob/master/tqdm/contrib/telegram.py>`__
- `tqdm/contrib/discord.py <https://github.com/tqdm/tqdm/blob/master/tqdm/contrib/discord.py>`__

Expand Down
3 changes: 2 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ dependencies:
- pandas
- tensorflow # keras
- requests # contrib.telegram
- twine # `pymake pypi`
- rich # rich
- argopt # `cd wiki && pymake`
- twine # `pymake pypi`
- wheel # `setup.py bdist_wheel`
- pip:
- py-make >=0.1.0 # `setup.py make/pymake`
Expand Down
7 changes: 7 additions & 0 deletions tests/tests_gui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""Test `tqdm.gui`."""
from .tests_tqdm import importorskip


def test_gui_import():
"""Test `tqdm.gui` import"""
importorskip('tqdm.gui')
10 changes: 10 additions & 0 deletions tests/tests_rich.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""Test `tqdm.rich`."""
import sys

from .tests_tqdm import importorskip, mark


@mark.skipif(sys.version_info[:3] < (3, 6, 1), reason="`rich` needs py>=3.6.1")
def test_rich_import():
"""Test `tqdm.rich` import"""
importorskip('tqdm.rich')
7 changes: 7 additions & 0 deletions tests/tests_tk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""Test `tqdm.tk`."""
from .tests_tqdm import importorskip


def test_tk_import():
"""Test `tqdm.tk` import"""
importorskip('tqdm.tk')
4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ passenv=CI TOXENV CODECOV_* COVERALLS_* CODACY_* HOME
deps=
{[extra]deps}
cython
matplotlib
numpy
pandas
tf: tensorflow
keras: keras
py{36,37,38,39}: rich
tf: tensorflow
commands={[extra]commands}
allowlist_externals={[extra]allowlist_externals}

Expand Down
34 changes: 18 additions & 16 deletions tqdm/gui.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""
GUI progressbar decorator for iterators.
Includes a default `range` iterator printing to `stderr`.
Matplotlib GUI progressbar decorator for iterators.
Usage:
>>> from tqdm.gui import trange, tqdm
Expand All @@ -11,6 +10,7 @@
# a result precise floating numbers (instead of truncated int)
from __future__ import absolute_import, division

import re
from warnings import warn

# to inherit from the tqdm class
Expand All @@ -25,7 +25,7 @@

class tqdm_gui(std_tqdm): # pragma: no cover
"""
Experimental GUI version of tqdm!
Experimental Matplotlib GUI version of tqdm!
"""

# TODO: @classmethod: write() on GUI?
Expand All @@ -40,11 +40,10 @@ def __init__(self, *args, **kwargs):
colour = kwargs.pop('colour', 'g')
super(tqdm_gui, self).__init__(*args, **kwargs)

# Initialize the GUI display
if self.disable or not kwargs['gui']:
if self.disable:
return

warn('GUI is experimental/alpha', TqdmExperimentalWarning, stacklevel=2)
warn("GUI is experimental/alpha", TqdmExperimentalWarning, stacklevel=2)
self.mpl = mpl
self.plt = plt

Expand All @@ -69,20 +68,20 @@ def __init__(self, *args, **kwargs):
ax.set_ylim(0, 0.001)
if total is not None:
ax.set_xlim(0, 100)
ax.set_xlabel('percent')
self.fig.legend((self.line1, self.line2), ('cur', 'est'),
ax.set_xlabel("percent")
self.fig.legend((self.line1, self.line2), ("cur", "est"),
loc='center right')
# progressbar
self.hspan = plt.axhspan(0, 0.001, xmin=0, xmax=0, color=colour)
else:
# ax.set_xlim(-60, 0)
ax.set_xlim(0, 60)
ax.invert_xaxis()
ax.set_xlabel('seconds')
ax.legend(('cur', 'est'), loc='lower left')
ax.set_xlabel("seconds")
ax.legend(("cur", "est"), loc='lower left')
ax.grid()
# ax.set_xlabel('seconds')
ax.set_ylabel((self.unit if self.unit else 'it') + '/s')
ax.set_ylabel((self.unit if self.unit else "it") + "/s")
if self.unit_scale:
plt.ticklabel_format(style='sci', axis='y', scilimits=(0, 0))
ax.yaxis.get_offset_text().set_x(-0.15)
Expand All @@ -93,8 +92,6 @@ def __init__(self, *args, **kwargs):
self.ax = ax

def close(self):
# if not self.gui:
# return super(tqdm_gui, self).close()
if self.disable:
return

Expand All @@ -116,7 +113,7 @@ def close(self):
def clear(self, *_, **__):
pass

def display(self):
def display(self, *_, **__):
n = self.n
cur_t = self._time()
elapsed = cur_t - self.start_t
Expand Down Expand Up @@ -175,8 +172,13 @@ def display(self):
line2.set_data(t_ago, zdata)

d = self.format_dict
d["ncols"] = 0
ax.set_title(self.format_meter(**d), fontname="DejaVu Sans Mono", fontsize=11)
# remove {bar}
d['bar_format'] = (d['bar_format'] or "{l_bar}<bar/>{r_bar}").replace(
"{bar}", "<bar/>")
msg = self.format_meter(**d)
if '<bar/>' in msg:
msg = "".join(re.split(r'\|?<bar/>\|?', msg, 1))
ax.set_title(msg, fontname="DejaVu Sans Mono", fontsize=11)
self.plt.pause(1e-9)


Expand Down
Loading

0 comments on commit c58fc25

Please sign in to comment.