Skip to content

Commit

Permalink
Add numpy-style docstrings (#12)
Browse files Browse the repository at this point in the history
* Add numpy-style docstrings

* Update publisher.py

* Apply suggestions from code review

Co-authored-by: Cody Baker <[email protected]>

* Update publisher.py

* Remove display check

* Update publisher.py

* Update publisher.py

---------

Co-authored-by: Cody Baker <[email protected]>
  • Loading branch information
garrettmflynn and CodyCBakerPhD authored Jan 21, 2024
1 parent b117a3c commit 31a6d2a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/tqdm_publisher/publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from tqdm import tqdm as base_tqdm
from uuid import uuid4

from typing import Union

# This class is a subclass of tqdm that allows for an arbitary number of callbacks to be registered
class TQDMPublisher(base_tqdm):

Expand All @@ -11,12 +13,12 @@ def __init__(self, *args, **kwargs):


# Override the update method to call callbacks
def update(self, n=1):
def update(self, n: int=1) -> Union[bool, None]:
displayed = super().update(n)
for id in list(self.callbacks):
callback = self.callbacks.get(id)
if callback:
callback(self.format_dict)

for callback in self.callbacks.values():
callback(self.format_dict)

return displayed


Expand Down

0 comments on commit 31a6d2a

Please sign in to comment.