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

Include a smoother unicode progress bar #38

Closed
BertrandBordage opened this issue Oct 12, 2015 · 7 comments
Closed

Include a smoother unicode progress bar #38

BertrandBordage opened this issue Oct 12, 2015 · 7 comments

Comments

@BertrandBordage
Copy link

(First of all, thanks for reviving this nice project :D )

A progress bar similar to the new one in pip could be nice, using these characters:
https://github.com/pypa/pip/blob/develop/pip/_vendor/progress/bar.py#L63
Pip detects if this smoother progress bar can be used, and otherwise falls back to the regular one (see pypa/pip#2231).

@kmike
Copy link
Contributor

kmike commented Oct 12, 2015

isn't it already implemented?

@lrq3000
Copy link
Member

lrq3000 commented Oct 12, 2015

Yes it's the ascii=False option IIRC. But I don't know if it's implemented in a similar fashion (ie: if it's as smooth as the pip progress bar).

@lrq3000
Copy link
Member

lrq3000 commented Oct 12, 2015

I just checked, it's indeed the ascii=False option to force use the smooth unicode bar, but normally the default option ascii=None should automatically use the smooth unicode bar if available, and else the ascii bar if not available. So I suppose the OP did try in his terminal which didn't support unicode (eg, on Windows?). The unicode bar can always be used inside IPython/Jupyter so it's a better environment to test this feature.

However, the provided links can be interesting to compare the implementation, and see if we can "steal" something maybe to enhance the smooth progress bar.

@lrq3000
Copy link
Member

lrq3000 commented Oct 12, 2015

The relevant lines for smooth bar management in tqdm:
https://github.com/tqdm/tqdm/blob/master/tqdm/_tqdm.py#L149-L157

Lol look at pip's FillingSquaresBar, FillingCirclesBar and ShadyBar! Genius :D

@BertrandBordage
Copy link
Author

Ah, sorry for the fuss, it’s an invalid issue.
I didn’t use a long enough time resolution in the following example:

from time import sleep
from tqdm import trange

for i in trange(1000):
    sleep(0.01)

Because of the default refresh rate of tqdm, (and being mislead by the current gif that’s from the previous version), I wrote this issue a bit too fast :\

Well done to all of the team, everything is better in that new tqdm! All the annoying issues are gone! (mostly: printing after an end of tqdm, the narrow width, this issue)

@casperdcl
Copy link
Sponsor Member

My first flurry of contributions to this project included a smooth unicode progress bar and radical speed increases.

My implementation (see above comment) was rather neater and faster than pip's version (which did however inspire me). It also doesn't require the hateful coding: utf-8 directive.

To force Unicode in your terminal (I have to do this in my cross-compiled debian distribution on my phone

PYTHONIOENCODING=utf-8 python -c 'import tqdm; i=[j for j in tqdm.trange(int(1e8), leave=True)]'

Still, thanks @BertrandBordage for using tqdm and suggesting improvements! You seemed to imply some things are still not fixed... Do create a new issue for anything else you can think of.

@lrq3000
Copy link
Member

lrq3000 commented Oct 12, 2015

@casperdcl yes that's also what I thought about the speed, surely pip's version is a hella lot slower since it uses class inheritance. Great job on this one :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants