Skip to content

Commit

Permalink
bump version, Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl committed Oct 8, 2017
2 parents a8e586f + 6aece54 commit 63b1cfc
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 39 deletions.
2 changes: 2 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
- [ ] I have visited the [source website], and in particular
read the [known issues]
- [ ] I have searched through the [issue tracker] for duplicates
- [ ] I have mentioned version numbers, operating system and
environment, where applicable

[source website]: https://github.com/tqdm/tqdm/
[known issues]: https://github.com/tqdm/tqdm/#faq-and-known-issues
Expand Down
4 changes: 3 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
- [ ] I have visited the [source website], and in particular
read the [known issues]
- [ ] I have searched through the [issue tracker] for duplicates
- [ ] If applicable, I have mentioned the relevant/related issue(s) in this PR
- [ ] I have mentioned version numbers, operating system and
environment, where applicable
- [ ] If applicable, I have mentioned the relevant/related issue(s)

[source website]: https://github.com/tqdm/tqdm/
[known issues]: https://github.com/tqdm/tqdm/#faq-and-known-issues
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ all:
@+make build

flake8:
@+flake8 --max-line-length=80 --count --statistics --exit-zero -j 8 --exclude .asv .
@+flake8 --max-line-length=80 --count --statistics --exit-zero -j 8 --exclude .asv,.tox .

test:
tox --skip-missing-interpreters
Expand Down
32 changes: 16 additions & 16 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,10 @@ Parameters
[default: '{l_bar}{bar}{r_bar}'], where
l_bar='{desc}: {percentage:3.0f}%|' and
r_bar='| {n_fmt}/{total_fmt} [{elapsed}<{remaining}, '
'{rate_fmt}{postfix}]'
'{rate_fmt}{postfix}]'
Possible vars: l_bar, bar, r_bar, n, n_fmt, total, total_fmt,
percentage, rate, rate_fmt, rate_noinv, rate_noinv_fmt,
rate_inv, rate_inv_fmt, elapsed, remaining, desc, postfix.
percentage, rate, rate_fmt, rate_noinv, rate_noinv_fmt,
rate_inv, rate_inv_fmt, elapsed, remaining, desc, postfix.
Note that a trailing ": " is automatically removed after {desc}
if the latter is empty.
* initial : int, optional
Expand Down Expand Up @@ -732,25 +732,25 @@ Monitoring thread, intervals and miniters

``tqdm`` implements a few tricks to to increase efficiency and reduce overhead.

1. Avoid unnecessary frequent bar refreshing: ``mininterval`` defines how long
to wait between each refresh. ``tqdm`` always gets updated in the background,
but it will diplay only every ``mininterval``.
2. Reduce number of calls to check system clock/time.
3. ``mininterval`` is more intuitive to configure than ``miniters``.
A clever adjustment system ``dynamic_miniters`` will automatically adjust
``miniters`` to the amount of iterations that fit into time ``mininterval``.
Essentially, ``tqdm`` will check if it's time to print without actually
checking time. This behavior can be still be bypassed by manually setting
``miniters``.
- Avoid unnecessary frequent bar refreshing: ``mininterval`` defines how long
to wait between each refresh. ``tqdm`` always gets updated in the background,
but it will diplay only every ``mininterval``.
- Reduce number of calls to check system clock/time.
- ``mininterval`` is more intuitive to configure than ``miniters``.
A clever adjustment system ``dynamic_miniters`` will automatically adjust
``miniters`` to the amount of iterations that fit into time ``mininterval``.
Essentially, ``tqdm`` will check if it's time to print without actually
checking time. This behavior can be still be bypassed by manually setting
``miniters``.

However, consider a case with a combination of fast and slow iterations.
After a few fast iterations, ``dynamic_miniters`` will set ``miniters`` to a
large number. When interation rate subsequently slows, ``miniters`` will
remain large and thus reduce display update frequency. To address this:

4. ``maxinterval`` defines the maximum time between display refreshes.
A concurrent monitoring thread checks for overdue updates and forces one
where necessary.
- ``maxinterval`` defines the maximum time between display refreshes.
A concurrent monitoring thread checks for overdue updates and forces one
where necessary.

The monitoring thread should not have a noticeable overhead, and guarantees
updates at least every 10 seconds by default.
Expand Down
3 changes: 2 additions & 1 deletion examples/redirect_print.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ def some_fun(i):
# tqdm needs the original stdout
# and dynamic_ncols=True to autodetect console width
for i in tqdm(range(3), file=orig_stdout, dynamic_ncols=True):
sleep(.5)
# order of the following two lines should not matter
some_fun(i)
sleep(.5)

# After the `with`, printing is restored
print("Done!")
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ def execute_makefile_commands(commands, alias, verbose=False):
platforms=['any'],
packages=['tqdm'],
entry_points={'console_scripts': ['tqdm=tqdm._main:main'], },
data_files = [('man/man1', ['tqdm.1'])],
package_data = {'': ['CONTRIBUTING.md', 'LICENCE', 'examples/*.py']},
data_files=[('man/man1', ['tqdm.1'])],
package_data={'': ['CONTRIBUTING.md', 'LICENCE', 'examples/*.py']},
long_description=README_rst,
classifiers=[
# Trove classifiers
Expand Down
23 changes: 8 additions & 15 deletions tqdm/_tqdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,10 @@ def format_meter(n, total, elapsed, ncols=None, prefix='', ascii=False,
[default: '{l_bar}{bar}{r_bar}'], where
l_bar='{desc}: {percentage:3.0f}%|' and
r_bar='| {n_fmt}/{total_fmt} [{elapsed}<{remaining}, '
'{rate_fmt}{postfix}]'
'{rate_fmt}{postfix}]'
Possible vars: l_bar, bar, r_bar, n, n_fmt, total, total_fmt,
percentage, rate, rate_fmt, rate_noinv, rate_noinv_fmt,
rate_inv, rate_inv_fmt, elapsed, remaining, desc, postfix.
percentage, rate, rate_fmt, rate_noinv, rate_noinv_fmt,
rate_inv, rate_inv_fmt, elapsed, remaining, desc, postfix.
Note that a trailing ": " is automatically removed after {desc}
if the latter is empty.
postfix : str, optional
Expand Down Expand Up @@ -1212,7 +1212,7 @@ def set_postfix_str(self, s='', refresh=True):
def moveto(self, n):
self.fp.write(_unicode('\n' * n + _term_move_up() * -n))

def clear(self, nomove=False, nolock=False):
def clear(self, nolock=False):
"""
Clear current bar display
"""
Expand All @@ -1221,14 +1221,10 @@ def clear(self, nomove=False, nolock=False):

if not nolock:
self._lock.acquire()
if not nomove:
self.moveto(self.pos)
# clear up the bar (can't rely on sp(''))
self.fp.write('\r')
self.fp.write(' ' * (self.ncols if self.ncols else 10))
self.moveto(self.pos)
self.sp('')
self.fp.write('\r') # place cursor back at the beginning of line
if not nomove:
self.moveto(-self.pos)
self.moveto(-self.pos)
if not nolock:
self._lock.release()

Expand All @@ -1242,10 +1238,7 @@ def refresh(self, nolock=False):
if not nolock:
self._lock.acquire()
self.moveto(self.pos)
# clear up this line's content (whatever there was)
self.clear(nomove=True, nolock=True)
# Print current/last bar state
self.fp.write(self.__repr__())
self.sp(self.__repr__())
self.moveto(-self.pos)
if not nolock:
self._lock.release()
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, 19, 1
version_info = 4, 19, 2

# Nice string for the version
__version__ = '.'.join(map(str, version_info))
Expand Down
3 changes: 1 addition & 2 deletions tqdm/tests/tests_tqdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1362,8 +1362,7 @@ def test_write():
assert after_err_res == [u'\rpos0 bar: 0%',
u'\rpos0 bar: 10%',
u'\r ',
u'\r\r ',
u'\rpos0 bar: 10%']
u'\r\rpos0 bar: 10%']
assert after_out == s + '\n'
# Restore stdout and stderr
sys.stderr = stde
Expand Down

0 comments on commit 63b1cfc

Please sign in to comment.