tqdm's "total" parameter bug
Due to something in the Sage 8.7 kernel (currently running in CoCalc), the tqdm progress bar crashes when I try to specify its total parameter. According to the documentation, my syntax should be correct. Specifically,
from tqdm import tqdm_notebook as tqdm
for i in tqdm(range(50),total=75):
print(i)
yields
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-1-e4e61f3c450b> in <module>()
1 from tqdm import tqdm_notebook as tqdm
----> 2 for i in tqdm(range(Integer(50)),total=Integer(75)):
3 print(i)
/ext/sage/sage-8.7_1804/local/lib/python2.7/site-packages/tqdm/__init__.pyc in tqdm_notebook(*args, **kwargs)
23 """See tqdm._tqdm_notebook.tqdm_notebook for full documentation"""
24 from ._tqdm_notebook import tqdm_notebook as _tqdm_notebook
---> 25 return _tqdm_notebook(*args, **kwargs)
26
27
/ext/sage/sage-8.7_1804/local/lib/python2.7/site-packages/tqdm/_tqdm_notebook.pyc in __init__(self, *args, **kwargs)
215 # Print initial bar state
216 if not self.disable:
--> 217 self.sp(self.__repr__()) # same as self.refresh without clearing
218
219 def __iter__(self, *args, **kwargs):
/ext/sage/sage-8.7_1804/local/lib/python2.7/site-packages/tqdm/_tqdm.pyc in __repr__(self)
982
983 def __repr__(self):
--> 984 return self.format_meter(**self.format_dict)
985
986 @property
/ext/sage/sage-8.7_1804/local/lib/python2.7/site-packages/tqdm/_tqdm.pyc in format_meter(n, total, elapsed, ncols, prefix, ascii, unit, unit_scale, rate, bar_format, postfix, unit_divisor, **extra_kwargs)
395 percentage = frac * 100
396
--> 397 l_bar += '{0:3.0f}%|'.format(percentage)
398
399 if ncols == 0:
ValueError: Unknown format code 'f' for object of type 'str'
Especially since a similar implementation of tqdm does work in a python 3 sheet, this feels like a minor bug to me. Or am I making some silly mistake?
-- edit: replaced example with a more straightforward one
Try with "10" instead of str(10)
Thanks for your answer, but the "10" isn't the problem; graphs.nauty_geng takes a string argument and returns an Iterable. The issue is related to the other number, which somehow becomes a string in tqdm.
I have replaced my example in response to your suggestion, to make the question more clear.