Skip to content

Commit

Permalink
bump verions, merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl committed Aug 18, 2019
2 parents dc095e6 + 96cb8e1 commit 5b090fd
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 53 deletions.
4 changes: 2 additions & 2 deletions .meta/.readme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ file for more information.

Developers who have made significant contributions, ranked by *LoC*
(surviving lines of code,
`git fame <https://github.com/casperdcl/git-fame>`__ ``-wMC --excl '\.(png|gif|enc)$'``),
`git fame <https://github.com/casperdcl/git-fame>`__ ``-wMC``),
are:

==================== ================================================== ==== ================================
Expand Down Expand Up @@ -879,7 +879,7 @@ Citation information: |DOI| (publication), |DOI-code| (code)
.. |OpenHub-Status| image:: https://www.openhub.net/p/tqdm/widgets/project_thin_badge?format=gif
:target: https://www.openhub.net/p/tqdm?ref=Thin+badge
.. |awesome-python| image:: https://awesome.re/mentioned-badge.svg
:target: https://github.com/vinta/awesome-python)
:target: https://github.com/vinta/awesome-python
.. |LICENCE| image:: https://img.shields.io/pypi/l/tqdm.svg
:target: https://raw.githubusercontent.com/tqdm/tqdm/master/LICENCE
.. |DOI| image:: https://img.shields.io/badge/DOI-10.21105/joss.01277-green.svg
Expand Down
13 changes: 10 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ matrix:
- |
if [[ -n "$TRAVIS_TAG" ]]; then
docker tag tqdm/tqdm:latest tqdm/tqdm:${TRAVIS_TAG#v}
docker tag tqdm/tqdm:latest docker.pkg.github.com/tqdm/tqdm/tqdm:${TRAVIS_TAG#v}
; fi
docker tag tqdm/tqdm:latest docker.pkg.github.com/tqdm/tqdm/tqdm:${TRAVIS_TAG#v} ; fi
- docker tag tqdm/tqdm:latest tqdm/tqdm:devel
- docker tag tqdm/tqdm:latest docker.pkg.github.com/tqdm/tqdm/tqdm:latest
- docker tag tqdm/tqdm:latest docker.pkg.github.com/tqdm/tqdm/tqdm:devel
- pip install .[dev]
- make build
#- make submodules
Expand Down Expand Up @@ -56,15 +57,21 @@ matrix:
on:
tags: true
- provider: script
script: docker push docker.pkg.github.com/tqdm/tqdm/tqdm:${TRAVIS_TAG#v}
script: 'docker push docker.pkg.github.com/tqdm/tqdm/tqdm:${TRAVIS_TAG#v} || :'
on:
tags: true
- provider: script
script: docker push tqdm/tqdm:latest
- provider: script
script: 'docker push docker.pkg.github.com/tqdm/tqdm/tqdm:latest || :'
- provider: script
script: docker push tqdm/tqdm:devel
on:
branch: devel
- provider: script
script: 'docker push docker.pkg.github.com/tqdm/tqdm/tqdm:devel || :'
on:
branch: devel
- python: pypy2.7-5.10.0
env: TOXENV=pypy
- python: pypy3.5-5.10.0
Expand Down
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ all:
@+make build

flake8:
@+flake8 --max-line-length=80 --exclude .asv,.tox,.ipynb_checkpoints,build \
--ignore=W503,W504 -j 8 --count --statistics --exit-zero .
@+flake8 -j 8 --count --statistics --exit-zero .

test:
tox --skip-missing-interpreters
Expand All @@ -55,7 +54,7 @@ testnose:
testsetup:
@make README.rst
@make tqdm/tqdm.1
python setup.py check --restructuredtext --strict
python setup.py check --metadata --restructuredtext --strict
python setup.py make none

testcoverage:
Expand Down
5 changes: 3 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ Parameters
* leave : bool, optional
If [default: True], keeps all traces of the progressbar
upon termination of iteration.
If ``None``, will leave only if ``position`` is ``0``.
* file : ``io.TextIOWrapper`` or ``io.StringIO``, optional
Specifies where to output the progress messages
(default: sys.stderr). Uses ``file.write(str)`` and ``file.flush()``
Expand Down Expand Up @@ -962,7 +963,7 @@ file for more information.

Developers who have made significant contributions, ranked by *LoC*
(surviving lines of code,
`git fame <https://github.com/casperdcl/git-fame>`__ ``-wMC --excl '\.(png|gif|enc)$'``),
`git fame <https://github.com/casperdcl/git-fame>`__ ``-wMC``),
are:

==================== ================================================== ==== ================================
Expand Down Expand Up @@ -1043,7 +1044,7 @@ Citation information: |DOI| (publication), |DOI-code| (code)
.. |OpenHub-Status| image:: https://www.openhub.net/p/tqdm/widgets/project_thin_badge?format=gif
:target: https://www.openhub.net/p/tqdm?ref=Thin+badge
.. |awesome-python| image:: https://awesome.re/mentioned-badge.svg
:target: https://github.com/vinta/awesome-python)
:target: https://github.com/vinta/awesome-python
.. |LICENCE| image:: https://img.shields.io/pypi/l/tqdm.svg
:target: https://raw.githubusercontent.com/tqdm/tqdm/master/LICENCE
.. |DOI| image:: https://img.shields.io/badge/DOI-10.21105/joss.01277-green.svg
Expand Down
5 changes: 5 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
[bdist_wheel]
universal = 1

[flake8]
ignore = W503,W504
max_line_length = 80
exclude = .asv,.tox,.ipynb_checkpoints,build,dist,.git,__pycache__
3 changes: 1 addition & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ commands =
[testenv:flake8]
deps = flake8
commands =
flake8 --max-line-length=80 --exclude .asv,.tox,.ipynb_checkpoints,build \
--ignore=W503,W504 -j 8 --count --statistics --exit-zero .
flake8 -j 8 --count --statistics --exit-zero .

[testenv:setup.py]
deps =
Expand Down
11 changes: 8 additions & 3 deletions tqdm/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def posix_pipe(fin, fout, delim='\n', buf_size=256,
# ((opt, type), ... )
RE_OPTS = re.compile(r'\n {8}(\S+)\s{2,}:\s*([^,]+)')
# better split method assuming no positional args
RE_SHLEX = re.compile(r'\s*(?<!\S)--?([^\s=]+)(?:\s*|=|$)')
RE_SHLEX = re.compile(r'\s*(?<!\S)--?([^\s=]+)(\s+|=|$)')

# TODO: add custom support for some of the following?
UNSUPPORTED_OPTS = ('iterable', 'gui', 'out', 'file')
Expand Down Expand Up @@ -128,7 +128,12 @@ def main(fp=sys.stderr, argv=None):
try:
log = argv.index('--log')
except ValueError:
logLevel = 'INFO'
for i in argv:
if i.startswith('--log='):
logLevel = i[len('--log='):]
break
else:
logLevel = 'INFO'
else:
# argv.pop(log)
# logLevel = argv.pop(log)
Expand Down Expand Up @@ -172,7 +177,7 @@ def main(fp=sys.stderr, argv=None):
sys.exit(0)

argv = RE_SHLEX.split(' '.join(["tqdm"] + argv))
opts = dict(zip(argv[1::2], argv[2::2]))
opts = dict(zip(argv[1::3], argv[3::3]))

log.debug(opts)
opts.pop('log', True)
Expand Down
18 changes: 9 additions & 9 deletions tqdm/_tqdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ def _decr_instances(cls, instance):
for inst in cls._instances:
# negative `pos` means fixed
if hasattr(inst, "pos") and inst.pos > abs(instance.pos):
inst.clear(nolock=True)
inst.pos -= 1
# TODO: check this doesn't overwrite another fixed bar
# Kill monitor if no instances are left
Expand Down Expand Up @@ -743,6 +744,7 @@ def __init__(self, iterable=None, desc=None, total=None, leave=True,
leave : bool, optional
If [default: True], keeps all traces of the progressbar
upon termination of iteration.
If `None`, will leave only if `position` is `0`.
file : `io.TextIOWrapper` or `io.StringIO`, optional
Specifies where to output the progress messages
(default: sys.stderr). Uses `file.write(str)` and `file.flush()`
Expand Down Expand Up @@ -1188,16 +1190,14 @@ def fp_write(s):
return
raise # pragma: no cover

leave = pos == 0 if self.leave is None else self.leave

with self._lock:
if self.leave:
if self.last_print_n < self.n:
# stats for overall rate (no weighted average)
self.avg_time = None
self.display(pos=pos)
if not max([abs(getattr(i, "pos", 0))
for i in self._instances] + [pos]):
# only if not nested (#477)
fp_write('\n')
if leave:
# stats for overall rate (no weighted average)
self.avg_time = None
self.display(pos=0)
fp_write('\n')
else:
self.display(msg='', pos=pos)
if not pos:
Expand Down
2 changes: 1 addition & 1 deletion tqdm/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__all__ = ["__version__"]

# major, minor, patch, -extra
version_info = 4, 33, 0
version_info = 4, 34, 0

# Nice string for the version
__version__ = '.'.join(map(str, version_info))
Expand Down
2 changes: 1 addition & 1 deletion tqdm/tests/tests_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_main():
IN_DATA = '\0'.join(IN_DATA_LIST)
sys.stdin.write(IN_DATA)
sys.stdin.seek(0)
sys.argv = ['', '--ascii', '--bytes', '--unit_scale', 'False']
sys.argv = ['', '--ascii', '--bytes=True', '--unit_scale', 'False']
with closing(UnicodeIO()) as fp:
main(fp=fp)
assert str(len(IN_DATA)) in fp.getvalue()
Expand Down
7 changes: 4 additions & 3 deletions tqdm/tests/tests_perf.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def test_iter_overhead_simplebar_hard():

# Compute relative overhead of tqdm against native range()
try:
assert time_tqdm() < 3 * time_bench()
assert time_tqdm() < 3.5 * time_bench()
except AssertionError:
raise AssertionError('trange(%g): %f, simple_progress(%g): %f' %
(total, time_tqdm(), total, time_bench()))
Expand All @@ -321,7 +321,8 @@ def test_manual_overhead_simplebar_hard():
t.update(10)

simplebar_update = simple_progress(
total=total, file=our_file, leave=True, miniters=1, mininterval=0)
total=total * 10, file=our_file, leave=True, miniters=1,
mininterval=0)
a = 0
with relative_timer() as time_bench:
for i in _range(total):
Expand All @@ -330,7 +331,7 @@ def test_manual_overhead_simplebar_hard():

# Compute relative overhead of tqdm against native range()
try:
assert time_tqdm() < 3 * time_bench()
assert time_tqdm() < 3.5 * time_bench()
except AssertionError:
raise AssertionError('tqdm(%g): %f, simple_progress(%g): %f' %
(total, time_tqdm(), total, time_bench()))
68 changes: 44 additions & 24 deletions tqdm/tests/tests_tqdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,26 @@ def pos_line_diff(res_list, expected_list, raise_nonempty=True):
Return differences between two bar output lists.
To be used with `RE_pos`
"""
ln = len(res_list)
if ln < len(expected_list):
res = [(None, e) for e in expected_list[ln:]]
elif ln > len(expected_list):
res = [(r, None) for r in res_list[ln:]]
res = [(r, e) for r, e in zip(res_list, expected_list)
for pos in [len(e) - len(e.lstrip('\n'))] # bar position
if r != e # simple comparison
if not r.startswith(e) # start matches
or not (r.endswith('\x1b[A' * pos) # move up at end
or r == '\n') # final bar
or r[(-1 - pos) * len('\x1b[A'):] == '\x1b[A'] # extra move up
if res and raise_nonempty:
or not (
# move up at end (maybe less due to closing bars)
any(r.endswith(end + i * '\x1b[A') for i in range(pos + 1)
for end in [
']', # bar
' ']) # cleared
or '100%' in r # completed bar
or r == '\n') # final bar
or r[(-1 - pos) * len('\x1b[A'):] == '\x1b[A'] # too many moves up
if raise_nonempty and (res or len(res_list) != len(expected_list)):
if len(res_list) < len(expected_list):
res.extend([(None, e) for e in expected_list[len(res_list):]])
elif len(res_list) > len(expected_list):
res.extend([(r, None) for r in res_list[len(expected_list):]])
raise AssertionError(
"Got => Expected\n" + '\n'.join('"%r" => "%r"' % i for i in res))
"Got => Expected\n" + '\n'.join('%r => %r' % i for i in res))
return res


Expand Down Expand Up @@ -932,13 +938,17 @@ def test_close():
progressbar.update(3)
res = our_file.getvalue()
assert '| 3/3 ' in res # Should be blank
assert '\n' not in res
# close() called
assert len(tqdm._instances) == 0

exres = res + '\n'
if exres != our_file.getvalue():
raise AssertionError("\nExpected:\n{0}\nGot:{1}\n".format(
exres, our_file.getvalue()))
exres = res.rsplit(', ', 1)[0]
res = our_file.getvalue()
assert res[-1] == '\n'
if not res.startswith(exres):
raise AssertionError(
"\n<<< Expected:\n{0}\n>>> Got:\n{1}\n===".format(
exres + ', ...it/s]\n', our_file.getvalue()))

# Closing after the output stream has closed
with closing(StringIO()) as our_file:
Expand Down Expand Up @@ -1176,21 +1186,28 @@ def test_position():
'\n\n\rpos2 bar: 0%',
'\n\n\rpos2 bar: 50%',
'\n\n\rpos2 bar: 100%',
'\n\rpos1 bar: 50%',
'\rpos2 bar: 100%',
'\n\n\rpos1 bar: 50%',
'\n\n\rpos2 bar: 0%',
'\n\n\rpos2 bar: 50%',
'\n\n\rpos2 bar: 100%',
'\n\rpos1 bar: 100%',
'\rpos0 bar: 50%',
'\rpos2 bar: 100%',
'\n\n\rpos1 bar: 100%',
'\rpos1 bar: 100%',
'\n\rpos0 bar: 50%',
'\n\rpos1 bar: 0%',
'\n\n\rpos2 bar: 0%',
'\n\n\rpos2 bar: 50%',
'\n\n\rpos2 bar: 100%',
'\n\rpos1 bar: 50%',
'\rpos2 bar: 100%',
'\n\n\rpos1 bar: 50%',
'\n\n\rpos2 bar: 0%',
'\n\n\rpos2 bar: 50%',
'\n\n\rpos2 bar: 100%',
'\n\rpos1 bar: 100%',
'\rpos2 bar: 100%',
'\n\n\rpos1 bar: 100%',
'\rpos1 bar: 100%',
'\n\rpos0 bar: 100%',
'\rpos0 bar: 100%',
'\n']
pos_line_diff(res, exres)
Expand Down Expand Up @@ -1243,7 +1260,10 @@ def test_position():
exres = ['\rpos0 bar: 0%',
'\n\rpos1 bar: 0%',
'\n\n\rpos2 bar: 0%',
'\n\n\rpos3 bar: 0%',
'\n\n\r ',
'\r\x1b[A\x1b[A',
'\rpos1 bar: 0%',
'\n\n\n\rpos3 bar: 0%',
'\rpos0 bar: 10%',
'\n\rpos2 bar: 10%',
'\n\n\rpos3 bar: 10%']
Expand Down Expand Up @@ -1489,10 +1509,10 @@ def test_write():
assert before_err == '\rpos0 bar: 0%|\rpos0 bar: 10%|'
assert before_out == ''
after_err_res = [m[0] for m in RE_pos.findall(after_err)]
exres = [u'\rpos0 bar: 0%',
u'\rpos0 bar: 10%',
u'\r ',
u'\r\rpos0 bar: 10%']
exres = ['\rpos0 bar: 0%|',
'\rpos0 bar: 10%|',
'\r ',
'\r\rpos0 bar: 10%|']
pos_line_diff(after_err_res, exres)
assert after_out == s + '\n'
# Restore stdout and stderr
Expand Down
1 change: 1 addition & 0 deletions tqdm/tqdm.1
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ int(9e9).
bool, optional.
If [default: True], keeps all traces of the progressbar upon termination
of iteration.
If \f[C]None\f[], will leave only if \f[C]position\f[] is \f[C]0\f[].
.RS
.RE
.TP
Expand Down

0 comments on commit 5b090fd

Please sign in to comment.