Hello community, here is the log from the commit of package python-tqdm for openSUSE:Factory checked in at 2020-01-30 09:33:59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-tqdm (Old) and /work/SRC/openSUSE:Factory/.python-tqdm.new.26092 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-tqdm" Thu Jan 30 09:33:59 2020 rev:30 rq:767565 version:4.42.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-tqdm/python-tqdm.changes 2020-01-07 23:51:09.959963181 +0100 +++ /work/SRC/openSUSE:Factory/.python-tqdm.new.26092/python-tqdm.changes 2020-01-30 09:34:42.277275095 +0100 @@ -1,0 +2,21 @@ +Sun Jan 26 21:21:59 UTC 2020 - Arun Persaud <[email protected]> + +- update to version 4.42.0: + * notebook: update disable=None behaviour (#880) + * tqdm.keras: support tensorflow.keras as well as keras (#885) + * add contrib (#882) + + tenumerate (#840 <- #480, #402) + + tzip <= zip + + tmap <= map + + add concurrent module + o thread_map <= concurrent.futures.ThreadPoolExecutor.map + o process_map <= concurrent.futures.ProcessPoolExecutor.map + + add itertools module (#225) stub + o product + * add & update tests + * add & update documentation + + README + + examples/ + * update CI framework + +------------------------------------------------------------------- Old: ---- tqdm-4.41.1.tar.gz New: ---- tqdm-4.42.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-tqdm.spec ++++++ --- /var/tmp/diff_new_pack.xweQDz/_old 2020-01-30 09:34:47.949278131 +0100 +++ /var/tmp/diff_new_pack.xweQDz/_new 2020-01-30 09:34:47.949278131 +0100 @@ -28,7 +28,7 @@ %bcond_with test %endif Name: python-tqdm%{pkg_suffix} -Version: 4.41.1 +Version: 4.42.0 Release: 0 Summary: An extensible progress meter License: MPL-2.0 AND MIT ++++++ tqdm-4.41.1.tar.gz -> tqdm-4.42.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tqdm-4.41.1/Makefile new/tqdm-4.42.0/Makefile --- old/tqdm-4.41.1/Makefile 2020-01-01 19:30:30.000000000 +0100 +++ new/tqdm-4.42.0/Makefile 2020-01-25 01:09:22.000000000 +0100 @@ -84,7 +84,7 @@ asv publish asv preview -tqdm/tqdm.1: .meta/.tqdm.1.md tqdm/_main.py tqdm/_tqdm.py +tqdm/tqdm.1: .meta/.tqdm.1.md tqdm/cli.py tqdm/std.py # TODO: add to mkdocs.py python -m tqdm --help | tail -n+5 |\ sed -r -e 's/\\/\\\\/g' \ @@ -93,7 +93,7 @@ cat "$<" - |\ pandoc -o "$@" -s -t man -README.rst: .meta/.readme.rst tqdm/_tqdm.py tqdm/_main.py +README.rst: .meta/.readme.rst tqdm/std.py tqdm/cli.py @python .meta/mkdocs.py snapcraft.yaml: .meta/.snapcraft.yml @@ -118,10 +118,12 @@ coverclean: @+python -c "import os; os.remove('.coverage') if os.path.exists('.coverage') else None" @+python -c "import shutil; shutil.rmtree('tqdm/__pycache__', True)" + @+python -c "import shutil; shutil.rmtree('tqdm/contrib/__pycache__', True)" @+python -c "import shutil; shutil.rmtree('tqdm/tests/__pycache__', True)" clean: @+python -c "import os, glob; [os.remove(i) for i in glob.glob('*.py[co]')]" @+python -c "import os, glob; [os.remove(i) for i in glob.glob('tqdm/*.py[co]')]" + @+python -c "import os, glob; [os.remove(i) for i in glob.glob('tqdm/contrib/*.py[co]')]" @+python -c "import os, glob; [os.remove(i) for i in glob.glob('tqdm/tests/*.py[co]')]" @+python -c "import os, glob; [os.remove(i) for i in glob.glob('tqdm/examples/*.py[co]')]" toxclean: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tqdm-4.41.1/PKG-INFO new/tqdm-4.42.0/PKG-INFO --- old/tqdm-4.41.1/PKG-INFO 2020-01-01 19:30:45.000000000 +0100 +++ new/tqdm-4.42.0/PKG-INFO 2020-01-25 01:09:37.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: tqdm -Version: 4.41.1 +Version: 4.42.0 Summary: Fast, Extensible Progress Meter Home-page: https://github.com/tqdm/tqdm Maintainer: tqdm developers @@ -288,13 +288,18 @@ either normal-width unicode characters being incorrectly displayed as "wide", or some unicode characters not rendering. - - Wrapping enumerated iterables: use ``enumerate(tqdm(...))`` instead of - ``tqdm(enumerate(...))``. The same applies to ``numpy.ndenumerate``. - This is because enumerate functions tend to hide the length of iterables. - ``tqdm`` does not. - - Wrapping zipped iterables has similar issues due to internal optimisations. - ``tqdm(zip(a, b))`` should be replaced with ``zip(tqdm(a), b)`` or even - ``zip(tqdm(a), tqdm(b))``. + - Wrapping generators: + + * Generator wrapper functions tend to hide the length of iterables. + ``tqdm`` does not. + * Replace ``tqdm(enumerate(...))`` with ``enumerate(tqdm(...))`` or + ``tqdm(enumerate(x), total=len(x), ...)``. + The same applies to ``numpy.ndenumerate``. + * Replace ``tqdm(zip(a, b))`` with ``zip(tqdm(a), b)`` or even + ``zip(tqdm(a), tqdm(b))``. + * The same applies to ``itertools``. + * Some useful convenience functions can be found under ``tqdm.contrib``. + - `Hanging pipes in python2 <https://github.com/tqdm/tqdm/issues/359>`__: when using ``tqdm`` on the CLI, you may need to use Python 3.5+ for correct buffering. @@ -571,6 +576,21 @@ class tqdm.keras.TqdmCallback(keras.callbacks.Callback): """`keras` callback for epoch and batch progress""" + def tqdm.contrib.tenumerate(iterable, start=0, total=None, + tqdm_class=tqdm.auto.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`.""" + + The ``tqdm.contrib`` package also contains experimental modules: + + - ``tqdm.contrib.itertools``: Thin wrappers around ``itertools`` + - ``tqdm.contrib.concurrent``: Thin wrappers around ``concurrent.futures`` + Examples and Advanced Usage --------------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tqdm-4.41.1/README.rst new/tqdm-4.42.0/README.rst --- old/tqdm-4.41.1/README.rst 2020-01-01 19:30:44.000000000 +0100 +++ new/tqdm-4.42.0/README.rst 2020-01-25 01:09:36.000000000 +0100 @@ -280,13 +280,18 @@ either normal-width unicode characters being incorrectly displayed as "wide", or some unicode characters not rendering. -- Wrapping enumerated iterables: use ``enumerate(tqdm(...))`` instead of - ``tqdm(enumerate(...))``. The same applies to ``numpy.ndenumerate``. - This is because enumerate functions tend to hide the length of iterables. - ``tqdm`` does not. -- Wrapping zipped iterables has similar issues due to internal optimisations. - ``tqdm(zip(a, b))`` should be replaced with ``zip(tqdm(a), b)`` or even - ``zip(tqdm(a), tqdm(b))``. +- Wrapping generators: + + * Generator wrapper functions tend to hide the length of iterables. + ``tqdm`` does not. + * Replace ``tqdm(enumerate(...))`` with ``enumerate(tqdm(...))`` or + ``tqdm(enumerate(x), total=len(x), ...)``. + The same applies to ``numpy.ndenumerate``. + * Replace ``tqdm(zip(a, b))`` with ``zip(tqdm(a), b)`` or even + ``zip(tqdm(a), tqdm(b))``. + * The same applies to ``itertools``. + * Some useful convenience functions can be found under ``tqdm.contrib``. + - `Hanging pipes in python2 <https://github.com/tqdm/tqdm/issues/359>`__: when using ``tqdm`` on the CLI, you may need to use Python 3.5+ for correct buffering. @@ -563,6 +568,21 @@ class tqdm.keras.TqdmCallback(keras.callbacks.Callback): """`keras` callback for epoch and batch progress""" + def tqdm.contrib.tenumerate(iterable, start=0, total=None, + tqdm_class=tqdm.auto.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`.""" + +The ``tqdm.contrib`` package also contains experimental modules: + +- ``tqdm.contrib.itertools``: Thin wrappers around ``itertools`` +- ``tqdm.contrib.concurrent``: Thin wrappers around ``concurrent.futures`` + Examples and Advanced Usage --------------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tqdm-4.41.1/examples/include_no_requirements.py new/tqdm-4.42.0/examples/include_no_requirements.py --- old/tqdm-4.41.1/examples/include_no_requirements.py 2020-01-01 19:30:30.000000000 +0100 +++ new/tqdm-4.42.0/examples/include_no_requirements.py 2020-01-25 01:09:22.000000000 +0100 @@ -1,6 +1,6 @@ -# How to import tqdm without enforcing it as a dependency +# How to import tqdm in any frontend without enforcing it as a dependency try: - from tqdm import tqdm + from tqdm.auto import tqdm except ImportError: def tqdm(*args, **kwargs): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tqdm-4.41.1/examples/pandas_progress_apply.py new/tqdm-4.42.0/examples/pandas_progress_apply.py --- old/tqdm-4.41.1/examples/pandas_progress_apply.py 2020-01-01 19:30:30.000000000 +0100 +++ new/tqdm-4.42.0/examples/pandas_progress_apply.py 2020-01-25 01:09:22.000000000 +0100 @@ -1,6 +1,6 @@ import pandas as pd import numpy as np -from tqdm import tqdm +from tqdm.auto import tqdm df = pd.DataFrame(np.random.randint(0, 100, (100000, 6))) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tqdm-4.41.1/examples/parallel_bars.py new/tqdm-4.42.0/examples/parallel_bars.py --- old/tqdm-4.41.1/examples/parallel_bars.py 2020-01-01 19:30:30.000000000 +0100 +++ new/tqdm-4.42.0/examples/parallel_bars.py 2020-01-25 01:09:22.000000000 +0100 @@ -1,6 +1,7 @@ from __future__ import print_function from time import sleep -from tqdm import tqdm, trange +from tqdm.auto import tqdm, trange +from tqdm.contrib.concurrent import process_map, thread_map from random import random from multiprocessing import Pool, freeze_support from concurrent.futures import ThreadPoolExecutor @@ -12,11 +13,12 @@ PY2 = sys.version_info[:1] <= (2,) -def progresser(n, auto_position=True, write_safe=False, blocking=True): +def progresser(n, auto_position=True, write_safe=False, blocking=True, + progress=False): interval = random() * 0.002 / (NUM_SUBITERS - n + 2) total = 5000 text = "#{}, est. {:<04.2}s".format(n, interval * total) - for _ in trange(total, desc=text, + for _ in trange(total, desc=text, disable=not progress, lock_args=None if blocking else (False,), position=None if auto_position else n): sleep(interval) @@ -26,12 +28,19 @@ # we think we know about other bars (currently only py3 threading) if n == 6: tqdm.write("n == 6 completed") + return n + 1 if __name__ == '__main__': freeze_support() # for Windows support L = list(range(NUM_SUBITERS))[::-1] + print("Simple thread mapping") + thread_map(partial(progresser, write_safe=not PY2), L, max_workers=4) + + print("Simple process mapping") + process_map(partial(progresser), L, max_workers=4) + print("Manual nesting") for i in trange(16, desc="1"): for _ in trange(16, desc="2 @ %d" % i, leave=i % 2): @@ -39,7 +48,7 @@ print("Multi-processing") p = Pool(initializer=tqdm.set_lock, initargs=(tqdm.get_lock(),)) - p.map(progresser, L) + p.map(partial(progresser, progress=True), L) # unfortunately need ncols # to print spaces over leftover multi-processing bars (#796) @@ -50,6 +59,5 @@ # explicitly set just threading lock for nonblocking progress tqdm.set_lock(RLock()) with ThreadPoolExecutor() as p: - progresser_thread = partial( - progresser, write_safe=not PY2, blocking=False) - p.map(progresser_thread, L) + p.map(partial(progresser, progress=True, write_safe=not PY2, + blocking=False), L) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tqdm-4.41.1/examples/tqdm_wget.py new/tqdm-4.42.0/examples/tqdm_wget.py --- old/tqdm-4.41.1/examples/tqdm_wget.py 2020-01-01 19:30:30.000000000 +0100 +++ new/tqdm-4.42.0/examples/tqdm_wget.py 2020-01-25 01:09:22.000000000 +0100 @@ -21,7 +21,7 @@ import urllib from os import devnull -from tqdm import tqdm +from tqdm.auto import tqdm from docopt import docopt diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tqdm-4.41.1/examples/wrapping_generators.py new/tqdm-4.42.0/examples/wrapping_generators.py --- old/tqdm-4.41.1/examples/wrapping_generators.py 1970-01-01 01:00:00.000000000 +0100 +++ new/tqdm-4.42.0/examples/wrapping_generators.py 2020-01-25 01:09:22.000000000 +0100 @@ -0,0 +1,14 @@ +from tqdm.contrib import tenumerate, tzip, tmap +import numpy as np + +for _ in tenumerate(range(int(1e6)), desc="builtin enumerate"): + pass + +for _ in tenumerate(np.random.random((999, 999)), desc="numpy.ndenumerate"): + pass + +for _ in tzip(np.arange(1e6), np.arange(1e6) + 1, desc="builtin zip"): + pass + +mapped = tmap(lambda x: x + 1, np.arange(1e6), desc="builtin map") +assert (np.arange(1e6) + 1 == list(mapped)).all() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tqdm-4.41.1/tox.ini new/tqdm-4.42.0/tox.ini --- old/tqdm-4.41.1/tox.ini 2020-01-01 19:30:30.000000000 +0100 +++ new/tqdm-4.42.0/tox.ini 2020-01-25 01:09:22.000000000 +0100 @@ -5,7 +5,7 @@ [tox] # deprecation warning: py{26,32,33,34} -envlist = py{26,27,33,34,35,36,37,py,py3}, flake8, setup.py, perf +envlist = py{26,27,33,34,35,36,37,py,py3}, tf-no-keras, perf, flake8, setup.py [coverage] deps = @@ -69,6 +69,13 @@ deps = {[extra]deps} commands = {[extra]commands} +[testenv:tf-no-keras] +deps = + {[extra]deps} + tensorflow +commands = + nosetests --with-timer tqdm/tests/tests_keras.py -d -v + [testenv:perf] deps = nose diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tqdm-4.41.1/tqdm/_version.py new/tqdm-4.42.0/tqdm/_version.py --- old/tqdm-4.41.1/tqdm/_version.py 2020-01-01 19:30:30.000000000 +0100 +++ new/tqdm-4.42.0/tqdm/_version.py 2020-01-25 01:09:22.000000000 +0100 @@ -5,7 +5,7 @@ __all__ = ["__version__"] # major, minor, patch, -extra -version_info = 4, 41, 1 +version_info = 4, 42, 0 # Nice string for the version __version__ = '.'.join(map(str, version_info)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tqdm-4.41.1/tqdm/contrib/__init__.py new/tqdm-4.42.0/tqdm/contrib/__init__.py --- old/tqdm-4.41.1/tqdm/contrib/__init__.py 2020-01-01 19:30:30.000000000 +0100 +++ new/tqdm-4.42.0/tqdm/contrib/__init__.py 2020-01-25 01:09:22.000000000 +0100 @@ -1,5 +1,16 @@ +""" +Thin wrappers around common functions. + +Subpackages contain potentially unstable extensions. +""" from tqdm import tqdm +from tqdm.auto import tqdm as tqdm_auto from tqdm.utils import ObjectWrapper +from copy import deepcopy +import functools +import sys +__author__ = {"github.com/": ["casperdcl"]} +__all__ = ['tenumerate', 'tzip', 'tmap'] class DummyTqdmFile(ObjectWrapper): @@ -8,3 +19,62 @@ # Avoid print() second call (useless \n) if len(x.rstrip()) > 0: tqdm.write(x, file=self._wrapped, nolock=nolock) + + +def tenumerate(iterable, start=0, total=None, tqdm_class=tqdm_auto, + **tqdm_kwargs): + """ + Equivalent of `numpy.ndenumerate` or builtin `enumerate`. + + Parameters + ---------- + tqdm_class : [default: tqdm.auto.tqdm]. + """ + try: + import numpy as np + except ImportError: + pass + else: + if isinstance(iterable, np.ndarray): + return tqdm_class(np.ndenumerate(iterable), + total=total or iterable.size, **tqdm_kwargs) + return enumerate(tqdm_class(iterable, **tqdm_kwargs), start) + + +def _tzip(iter1, *iter2plus, **tqdm_kwargs): + """ + Equivalent of builtin `zip`. + + Parameters + ---------- + tqdm_class : [default: tqdm.auto.tqdm]. + """ + kwargs = deepcopy(tqdm_kwargs) + tqdm_class = kwargs.pop("tqdm_class", tqdm_auto) + for i in zip(tqdm_class(iter1, **tqdm_kwargs), *iter2plus): + yield i + + +def _tmap(function, *sequences, **tqdm_kwargs): + """ + Equivalent of builtin `map`. + + Parameters + ---------- + tqdm_class : [default: tqdm.auto.tqdm]. + """ + for i in _tzip(*sequences, **tqdm_kwargs): + yield function(*i) + + +if sys.version_info[:1] < (3,): + @functools.wraps(_tzip) + def tzip(*args, **kwargs): + return list(_tzip(*args, **kwargs)) + + @functools.wraps(_tmap) + def tmap(*args, **kwargs): + return list(_tmap(*args, **kwargs)) +else: + tzip = _tzip + tmap = _tmap diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tqdm-4.41.1/tqdm/contrib/concurrent.py new/tqdm-4.42.0/tqdm/contrib/concurrent.py --- old/tqdm-4.41.1/tqdm/contrib/concurrent.py 1970-01-01 01:00:00.000000000 +0100 +++ new/tqdm-4.42.0/tqdm/contrib/concurrent.py 2020-01-25 01:09:22.000000000 +0100 @@ -0,0 +1,64 @@ +""" +Thin wrappers around `concurrent.futures`. +""" +from __future__ import absolute_import +from tqdm.auto import tqdm as tqdm_auto +from copy import deepcopy +try: + from os import cpu_count +except ImportError: + try: + from multiprocessing import cpu_count + except ImportError: + def cpu_count(): + return 4 +import sys +__author__ = {"github.com/": ["casperdcl"]} +__all__ = ['thread_map', 'process_map'] + + +def _executor_map(PoolExecutor, fn, *iterables, **tqdm_kwargs): + """ + Implementation of `thread_map` and `process_map`. + + Parameters + ---------- + tqdm_class : [default: tqdm.auto.tqdm]. + """ + kwargs = deepcopy(tqdm_kwargs) + kwargs.setdefault("total", len(iterables[0])) + tqdm_class = kwargs.pop("tqdm_class", tqdm_auto) + max_workers = kwargs.pop("max_workers", min(32, cpu_count() + 4)) + pool_kwargs = dict(max_workers=max_workers) + if sys.version_info[:2] >= (3, 7): + # share lock in case workers are already using `tqdm` + pool_kwargs.update( + initializer=tqdm_class.set_lock, initargs=(tqdm_class.get_lock(),)) + with PoolExecutor(**pool_kwargs) as ex: + return list(tqdm_class(ex.map(fn, *iterables), **kwargs)) + + +def thread_map(fn, *iterables, **tqdm_kwargs): + """ + Equivalent of `list(map(fn, *iterables))` + driven by `concurrent.futures.ThreadPoolExecutor`. + + Parameters + ---------- + tqdm_class : [default: tqdm.auto.tqdm]. + """ + from concurrent.futures import ThreadPoolExecutor + return _executor_map(ThreadPoolExecutor, fn, *iterables, **tqdm_kwargs) + + +def process_map(fn, *iterables, **tqdm_kwargs): + """ + Equivalent of `list(map(fn, *iterables))` + driven by `concurrent.futures.ProcessPoolExecutor`. + + Parameters + ---------- + tqdm_class : [default: tqdm.auto.tqdm]. + """ + from concurrent.futures import ProcessPoolExecutor + return _executor_map(ProcessPoolExecutor, fn, *iterables, **tqdm_kwargs) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tqdm-4.41.1/tqdm/contrib/itertools.py new/tqdm-4.42.0/tqdm/contrib/itertools.py --- old/tqdm-4.41.1/tqdm/contrib/itertools.py 1970-01-01 01:00:00.000000000 +0100 +++ new/tqdm-4.42.0/tqdm/contrib/itertools.py 2020-01-25 01:09:22.000000000 +0100 @@ -0,0 +1,34 @@ +""" +Thin wrappers around `itertools`. +""" +from __future__ import absolute_import +from tqdm.auto import tqdm as tqdm_auto +from copy import deepcopy +import itertools +__author__ = {"github.com/": ["casperdcl"]} +__all__ = ['product'] + + +def product(*iterables, **tqdm_kwargs): + """ + Equivalent of `itertools.product`. + + Parameters + ---------- + tqdm_class : [default: tqdm.auto.tqdm]. + """ + kwargs = deepcopy(tqdm_kwargs) + tqdm_class = kwargs.pop("tqdm_class", tqdm_auto) + try: + lens = list(map(len, iterables)) + except TypeError: + total = None + else: + total = 1 + for i in lens: + total *= i + kwargs.setdefault("total", total) + with tqdm_class(**kwargs) as t: + for i in itertools.product(*iterables): + yield i + t.update() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tqdm-4.41.1/tqdm/keras.py new/tqdm-4.42.0/tqdm/keras.py --- old/tqdm-4.41.1/tqdm/keras.py 2020-01-01 19:30:30.000000000 +0100 +++ new/tqdm-4.42.0/tqdm/keras.py 2020-01-25 01:09:22.000000000 +0100 @@ -1,10 +1,18 @@ from __future__ import absolute_import, division from .auto import tqdm as tqdm_auto from copy import deepcopy -from keras.callbacks import Callback +try: + import keras +except ImportError as e: + try: + from tensorflow import keras + except ImportError: + raise e +__author__ = {"github.com/": ["casperdcl"]} +__all__ = ['TqdmCallback'] -class TqdmCallback(Callback): +class TqdmCallback(keras.callbacks.Callback): """`keras` callback for epoch and batch progress""" @staticmethod def bar2callback(bar, pop=None, delta=(lambda logs: 1)): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tqdm-4.41.1/tqdm/notebook.py new/tqdm-4.42.0/tqdm/notebook.py --- old/tqdm-4.41.1/tqdm/notebook.py 2020-01-01 19:30:30.000000000 +0100 +++ new/tqdm-4.42.0/tqdm/notebook.py 2020-01-25 01:09:22.000000000 +0100 @@ -192,6 +192,8 @@ kwargs['gui'] = True kwargs.setdefault('bar_format', '{l_bar}{bar}{r_bar}') kwargs['bar_format'] = kwargs['bar_format'].replace('{bar}', '<bar/>') + # convert disable = None to False + kwargs['disable'] = bool(kwargs.get('disable', False)) super(tqdm_notebook, self).__init__(*args, **kwargs) if self.disable or not kwargs['gui']: return diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tqdm-4.41.1/tqdm/tests/tests_concurrent.py new/tqdm-4.42.0/tqdm/tests/tests_concurrent.py --- old/tqdm-4.41.1/tqdm/tests/tests_concurrent.py 1970-01-01 01:00:00.000000000 +0100 +++ new/tqdm-4.42.0/tqdm/tests/tests_concurrent.py 2020-01-25 01:09:22.000000000 +0100 @@ -0,0 +1,36 @@ +""" +Tests for `tqdm.contrib.concurrent`. +""" +from tqdm.contrib.concurrent import thread_map, process_map +from tests_tqdm import with_setup, pretest, posttest, SkipTest, StringIO, \ + closing + + +def incr(x): + """Dummy function""" + return x + 1 + + +@with_setup(pretest, posttest) +def test_thread_map(): + """Test contrib.concurrent.thread_map""" + with closing(StringIO()) as our_file: + a = range(9) + b = [i + 1 for i in a] + try: + assert thread_map(lambda x: x + 1, a, file=our_file) == b + except ImportError: + raise SkipTest + assert thread_map(incr, a, file=our_file) == b + + +@with_setup(pretest, posttest) +def test_process_map(): + """Test contrib.concurrent.process_map""" + with closing(StringIO()) as our_file: + a = range(9) + b = [i + 1 for i in a] + try: + assert process_map(incr, a, file=our_file) == b + except ImportError: + raise SkipTest diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tqdm-4.41.1/tqdm/tests/tests_contrib.py new/tqdm-4.42.0/tqdm/tests/tests_contrib.py --- old/tqdm-4.41.1/tqdm/tests/tests_contrib.py 1970-01-01 01:00:00.000000000 +0100 +++ new/tqdm-4.42.0/tqdm/tests/tests_contrib.py 2020-01-25 01:09:22.000000000 +0100 @@ -0,0 +1,61 @@ +""" +Tests for `tqdm.contrib`. +""" +import sys +from tqdm.contrib import tenumerate, tzip, tmap +from tests_tqdm import with_setup, pretest, posttest, SkipTest, StringIO, \ + closing + + +def incr(x): + """Dummy function""" + return x + 1 + + +@with_setup(pretest, posttest) +def test_enumerate(): + """Test contrib.tenumerate""" + with closing(StringIO()) as our_file: + a = range(9) + assert list(tenumerate(a, file=our_file)) == list(enumerate(a)) + assert list(tenumerate(a, 42, file=our_file)) == list(enumerate(a, 42)) + + +@with_setup(pretest, posttest) +def test_enumerate_numpy(): + """Test contrib.tenumerate(numpy.ndarray)""" + try: + import numpy as np + except ImportError: + raise SkipTest + with closing(StringIO()) as our_file: + a = np.random.random((42, 1337)) + assert list(tenumerate(a, file=our_file)) == list(np.ndenumerate(a)) + + +@with_setup(pretest, posttest) +def test_zip(): + """Test contrib.tzip""" + with closing(StringIO()) as our_file: + a = range(9) + b = [i + 1 for i in a] + if sys.version_info[:1] < (3,): + assert tzip(a, b, file=our_file) == zip(a, b) + else: + gen = tzip(a, b, file=our_file) + assert gen != list(zip(a, b)) + assert list(gen) == list(zip(a, b)) + + +@with_setup(pretest, posttest) +def test_map(): + """Test contrib.tmap""" + with closing(StringIO()) as our_file: + a = range(9) + b = [i + 1 for i in a] + if sys.version_info[:1] < (3,): + assert tmap(lambda x: x + 1, a, file=our_file) == map(incr, a) + else: + gen = tmap(lambda x: x + 1, a, file=our_file) + assert gen != b + assert list(gen) == b diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tqdm-4.41.1/tqdm/tests/tests_itertools.py new/tqdm-4.42.0/tqdm/tests/tests_itertools.py --- old/tqdm-4.41.1/tqdm/tests/tests_itertools.py 1970-01-01 01:00:00.000000000 +0100 +++ new/tqdm-4.42.0/tqdm/tests/tests_itertools.py 2020-01-25 01:09:22.000000000 +0100 @@ -0,0 +1,27 @@ +""" +Tests for `tqdm.contrib.itertools`. +""" +from tqdm.contrib.itertools import product +from tests_tqdm import with_setup, pretest, posttest, StringIO, closing +import itertools + + +class NoLenIter(object): + def __init__(self, iterable): + self._it = iterable + + def __iter__(self): + for i in self._it: + yield i + + +@with_setup(pretest, posttest) +def test_product(): + """Test contrib.itertools.product""" + with closing(StringIO()) as our_file: + a = range(9) + assert list(product(a, a[::-1], file=our_file)) == \ + list(itertools.product(a, a[::-1])) + + assert list(product(a, NoLenIter(a), file=our_file)) == \ + list(itertools.product(a, NoLenIter(a))) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tqdm-4.41.1/tqdm/tests/tests_keras.py new/tqdm-4.42.0/tqdm/tests/tests_keras.py --- old/tqdm-4.41.1/tqdm/tests/tests_keras.py 2020-01-01 19:30:30.000000000 +0100 +++ new/tqdm-4.42.0/tqdm/tests/tests_keras.py 2020-01-25 01:09:22.000000000 +0100 @@ -10,7 +10,10 @@ try: from tqdm.keras import TqdmCallback import numpy as np - import keras as K + try: + import keras as K + except ImportError: + from tensorflow import keras as K except ImportError: raise SkipTest diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tqdm-4.41.1/tqdm/tqdm.1 new/tqdm-4.42.0/tqdm/tqdm.1 --- old/tqdm-4.41.1/tqdm/tqdm.1 2020-01-01 19:30:30.000000000 +0100 +++ new/tqdm-4.42.0/tqdm/tqdm.1 2020-01-25 01:09:22.000000000 +0100 @@ -52,14 +52,14 @@ .RE .TP .B \-\-total=\f[I]total\f[] -int, optional. +int or float, optional. The number of expected iterations. If unspecified, len(iterable) is used if possible. If float("inf") or as a last resort, only basic progress statistics are displayed (no ETA, no progressbar). If \f[C]gui\f[] is True and this parameter needs subsequent updating, -specify an initial arbitrary large positive integer, e.g. -int(9e9). +specify an initial arbitrary large positive number, e.g. +9e9. .RS .RE .TP @@ -99,7 +99,7 @@ .RE .TP .B \-\-miniters=\f[I]miniters\f[] -int, optional. +int or float, optional. Minimum progress display update interval, in iterations. If 0 and \f[C]dynamic_miniters\f[], will automatically adjust to equal \f[C]mininterval\f[] (more CPU efficient, good for tight loops). @@ -173,9 +173,11 @@ .RE .TP .B \-\-initial=\f[I]initial\f[] -int, optional. +int or float, optional. The initial counter value. Useful when restarting a progress bar [default: 0]. +If using float, consider specifying \f[C]{n:.3f}\f[] or similar in +\f[C]bar_format\f[], or specifying \f[C]unit_scale\f[]. .RS .RE .TP diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tqdm-4.41.1/tqdm.egg-info/PKG-INFO new/tqdm-4.42.0/tqdm.egg-info/PKG-INFO --- old/tqdm-4.41.1/tqdm.egg-info/PKG-INFO 2020-01-01 19:30:45.000000000 +0100 +++ new/tqdm-4.42.0/tqdm.egg-info/PKG-INFO 2020-01-25 01:09:37.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: tqdm -Version: 4.41.1 +Version: 4.42.0 Summary: Fast, Extensible Progress Meter Home-page: https://github.com/tqdm/tqdm Maintainer: tqdm developers @@ -288,13 +288,18 @@ either normal-width unicode characters being incorrectly displayed as "wide", or some unicode characters not rendering. - - Wrapping enumerated iterables: use ``enumerate(tqdm(...))`` instead of - ``tqdm(enumerate(...))``. The same applies to ``numpy.ndenumerate``. - This is because enumerate functions tend to hide the length of iterables. - ``tqdm`` does not. - - Wrapping zipped iterables has similar issues due to internal optimisations. - ``tqdm(zip(a, b))`` should be replaced with ``zip(tqdm(a), b)`` or even - ``zip(tqdm(a), tqdm(b))``. + - Wrapping generators: + + * Generator wrapper functions tend to hide the length of iterables. + ``tqdm`` does not. + * Replace ``tqdm(enumerate(...))`` with ``enumerate(tqdm(...))`` or + ``tqdm(enumerate(x), total=len(x), ...)``. + The same applies to ``numpy.ndenumerate``. + * Replace ``tqdm(zip(a, b))`` with ``zip(tqdm(a), b)`` or even + ``zip(tqdm(a), tqdm(b))``. + * The same applies to ``itertools``. + * Some useful convenience functions can be found under ``tqdm.contrib``. + - `Hanging pipes in python2 <https://github.com/tqdm/tqdm/issues/359>`__: when using ``tqdm`` on the CLI, you may need to use Python 3.5+ for correct buffering. @@ -571,6 +576,21 @@ class tqdm.keras.TqdmCallback(keras.callbacks.Callback): """`keras` callback for epoch and batch progress""" + def tqdm.contrib.tenumerate(iterable, start=0, total=None, + tqdm_class=tqdm.auto.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`.""" + + The ``tqdm.contrib`` package also contains experimental modules: + + - ``tqdm.contrib.itertools``: Thin wrappers around ``itertools`` + - ``tqdm.contrib.concurrent``: Thin wrappers around ``concurrent.futures`` + Examples and Advanced Usage --------------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tqdm-4.41.1/tqdm.egg-info/SOURCES.txt new/tqdm-4.42.0/tqdm.egg-info/SOURCES.txt --- old/tqdm-4.41.1/tqdm.egg-info/SOURCES.txt 2020-01-01 19:30:45.000000000 +0100 +++ new/tqdm-4.42.0/tqdm.egg-info/SOURCES.txt 2020-01-25 01:09:37.000000000 +0100 @@ -17,6 +17,7 @@ examples/redirect_print.py examples/simple_examples.py examples/tqdm_wget.py +examples/wrapping_generators.py tqdm/__init__.py tqdm/__main__.py tqdm/_main.py @@ -43,6 +44,11 @@ tqdm.egg-info/requires.txt tqdm.egg-info/top_level.txt tqdm/contrib/__init__.py +tqdm/contrib/concurrent.py +tqdm/contrib/itertools.py +tqdm/tests/tests_concurrent.py +tqdm/tests/tests_contrib.py +tqdm/tests/tests_itertools.py tqdm/tests/tests_keras.py tqdm/tests/tests_main.py tqdm/tests/tests_pandas.py
