Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix that tqdm_class cannot be passed to tmap and tzip #1148

Merged
merged 2 commits into from Apr 5, 2021

Conversation

grst
Copy link
Contributor

@grst grst commented Mar 16, 2021

There's currently the issue that tqdm_class cannot be passed to tmap and tzip. This PR fixes the issue and adds tests for it.

Here's a repex of the problem:

from tqdm.contrib import tmap
from tqdm import tqdm       
list(tmap(print, range(10), tqdm_class=tqdm))
---------------------------------------------------------------------------
TqdmKeyError                              Traceback (most recent call last)
<ipython-input-4-62e01f8ad3b6> in <module>
----> 1 list(tmap(print, range(10), tqdm_class=tqdm))

~/anaconda3/lib/python3.7/site-packages/tqdm/contrib/__init__.py in _tmap(function, *sequences, **tqdm_kwargs)
     64     tqdm_class  : [default: tqdm.auto.tqdm].
     65     """
---> 66     for i in _tzip(*sequences, **tqdm_kwargs):
     67         yield function(*i)
     68 

~/anaconda3/lib/python3.7/site-packages/tqdm/contrib/__init__.py in _tzip(iter1, *iter2plus, **tqdm_kwargs)
     52     kwargs = deepcopy(tqdm_kwargs)
     53     tqdm_class = kwargs.pop("tqdm_class", tqdm_auto)
---> 54     for i in zip(tqdm_class(iter1, **tqdm_kwargs), *iter2plus):
     55         yield i
     56 

~/anaconda3/lib/python3.7/site-packages/tqdm/std.py in __init__(self, iterable, desc, total, leave, file, ncols, mininterval, maxinterval, miniters, ascii, disable, unit, unit_scale, dynamic_ncols, smoothing, bar_format, initial, position, postfix, unit_divisor, write_bytes, lock_args, nrows, gui, **kwargs)
    961                     fp_write=getattr(file, 'write', sys.stderr.write))
    962                 if "nested" in kwargs else
--> 963                 TqdmKeyError("Unknown argument(s): " + str(kwargs)))
    964 
    965         # Preprocess the arguments

TqdmKeyError: "Unknown argument(s): {'tqdm_class': <class 'tqdm.std.tqdm'>}"

@grst grst requested a review from casperdcl as a code owner March 16, 2021 17:54
@codecov
Copy link

codecov bot commented Mar 16, 2021

Codecov Report

Merging #1148 (c633fc5) into master (bcce20f) will decrease coverage by 0.18%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #1148      +/-   ##
==========================================
- Coverage   84.73%   84.55%   -0.19%     
==========================================
  Files          25       25              
  Lines        1651     1651              
  Branches      273      273              
==========================================
- Hits         1399     1396       -3     
- Misses        213      216       +3     
  Partials       39       39              

@casperdcl casperdcl self-assigned this Mar 16, 2021
@casperdcl casperdcl added c1-quick 🕐 Complexity low p0-bug-critical ☢ Exception rasing submodule ⊂ Periphery/subclasses to-merge ↰ Imminent labels Mar 16, 2021
@casperdcl casperdcl added this to the Non-breaking milestone Mar 16, 2021
@casperdcl casperdcl added this to Next Release in Casper Mar 16, 2021
Comment on lines -83 to +84
for i in zip(tqdm_class(iter1, **tqdm_kwargs), *iter2plus):
for i in zip(tqdm_class(iter1, **kwargs), *iter2plus):
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woops; nice catch.

@casperdcl casperdcl changed the base branch from master to devel April 5, 2021 19:05
@casperdcl casperdcl merged commit 9fb0f23 into tqdm:devel Apr 5, 2021
Casper automation moved this from Next Release to Done Apr 5, 2021
@casperdcl casperdcl mentioned this pull request Apr 5, 2021
bdice added a commit to glotzerlab/signac-flow that referenced this pull request Feb 27, 2022
bdice added a commit to glotzerlab/signac-flow that referenced this pull request Mar 1, 2022
* Fix: tqdm.auto requires ipywidgets for notebook support.

* Update changelog.

* Use tqdm_class to avoid bug in automatic detection.

* Bump tqdm requirement to 4.60.0 for tqdm/tqdm#1148.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c1-quick 🕐 Complexity low p0-bug-critical ☢ Exception rasing submodule ⊂ Periphery/subclasses to-merge ↰ Imminent
Projects
Casper
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants