Skip to content

Commit

Permalink
update/fix all submodule inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl committed Dec 25, 2020
1 parent ff70447 commit acbe648
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 17 deletions.
3 changes: 1 addition & 2 deletions .meta/.readme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -925,8 +925,7 @@ For further customisation,
Consider overloading ``display()`` to use e.g.
``self.frontend(**self.format_dict)`` instead of ``self.sp(repr(self))``.

Some submodule examples of inheritance which don't (yet) strictly conform to the
above recommendation:
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>`__
Expand Down
3 changes: 1 addition & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1142,8 +1142,7 @@ For further customisation,
Consider overloading ``display()`` to use e.g.
``self.frontend(**self.format_dict)`` instead of ``self.sp(repr(self))``.

Some submodule examples of inheritance which don't (yet) strictly conform to the
above recommendation:
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>`__
Expand Down
17 changes: 9 additions & 8 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ dependencies:
- flake8
- coverage
# extras
- matplotlib
- numpy
- matplotlib # gui
- numpy # pandas, keras, contrib.tenumerate
- pandas
- tensorflow
- twine # pymake pypi
- argopt # cd wiki && pymake
- wheel # setup.py bdist_wheel
- tensorflow # keras
- requests # contrib.telegram
- twine # `pymake pypi`
- argopt # `cd wiki && pymake`
- wheel # `setup.py bdist_wheel`
- pip:
- py-make >=0.1.0 # setup.py make/pymake
- pydoc-markdown # cd docs && pymake
- py-make >=0.1.0 # `setup.py make/pymake`
- pydoc-markdown # `cd docs && pymake`
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ include_package_data = True
packages = find:
[options.extras_require]
dev=py-make>=0.1.0; twine; wheel
telegram=requests
[options.entry_points]
console_scripts =
tqdm = tqdm.cli:main
Expand Down
6 changes: 5 additions & 1 deletion tqdm/contrib/discord.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self, token, channel_id):
def write(self, s):
"""Replaces internal `message`'s text with `s`."""
if not s:
return
s = "..."
s = s.replace('\r', '').strip()
if s == self.text:
return # skip duplicate message
Expand Down Expand Up @@ -101,6 +101,10 @@ def display(self, **kwargs):
fmt['bar_format'] = '{l_bar}{bar:10u}{r_bar}'
self.dio.write(self.format_meter(**fmt))

def clear(self, *args, **kwargs):
super(tqdm_discord, self).clear(*args, **kwargs)
self.dio.write("")


def tdrange(*args, **kwargs):
"""
Expand Down
6 changes: 5 additions & 1 deletion tqdm/contrib/telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self, token, chat_id):
def write(self, s):
"""Replaces internal `message_id`'s text with `s`."""
if not s:
return
s = "..."
s = s.replace('\r', '').strip()
if s == self.text:
return # avoid duplicate message Bot error
Expand Down Expand Up @@ -103,6 +103,10 @@ def display(self, **kwargs):
fmt['bar_format'] = '{l_bar}{bar:10u}{r_bar}'
self.tgio.write(self.format_meter(**fmt))

def clear(self, *args, **kwargs):
super(tqdm_telegram, self).clear(*args, **kwargs)
self.tgio.write("")


def ttgrange(*args, **kwargs):
"""
Expand Down
3 changes: 3 additions & 0 deletions tqdm/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ def close(self):
else:
self.plt.close(self.fig)

def clear(self, *_, **__):
pass

def display(self):
n = self.n
cur_t = self._time()
Expand Down
5 changes: 2 additions & 3 deletions tqdm/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,8 @@ def close(self, *args, **kwargs):
else:
self.disp(close=True)

def moveto(self, *_, **__):
# void -> avoid extraneous `\n` in IPython output cell
return
def clear(self, *_, **__):
pass

def reset(self, total=None):
"""
Expand Down

0 comments on commit acbe648

Please sign in to comment.