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

tqdm_pandas() causes multiple lines to be printed in IDLE (Ubuntu 14.04, python2.7) #191

Closed
ofir-reich opened this issue Jul 1, 2016 · 5 comments
Labels
invalid ⛔ Not-an-issue or upstream (not-our-issue)

Comments

@ofir-reich
Copy link

>>> from tqdm import *
>>> import time
>>> # good
>>> for i in trange(10):
    time.sleep(0.2)


100%|██████████| 10/10 [00:02<00:00,  4.92it/s]
>>> # this will break things:
>>> tqdm_pandas(tqdm())
0it [00:00, ?it/s]
>>> for i in trange(10):
    time.sleep(0.2)



  0%|          | 0/10 [00:00<?, ?it/s]�[A
 10%|█         | 1/10 [00:00<00:01,  4.97it/s]�[A
 20%|██        | 2/10 [00:00<00:01,  4.90it/s]�[A
 30%|███       | 3/10 [00:00<00:01,  4.85it/s]�[A
 40%|████      | 4/10 [00:00<00:01,  4.84it/s]�[A
 50%|█████     | 5/10 [00:01<00:01,  4.84it/s]�[A
 60%|██████    | 6/10 [00:01<00:00,  4.83it/s]�[A
 70%|███████   | 7/10 [00:01<00:00,  4.82it/s]�[A
 80%|████████  | 8/10 [00:01<00:00,  4.83it/s]�[A
 90%|█████████ | 9/10 [00:01<00:00,  4.84it/s]�[A
100%|██████████| 10/10 [00:02<00:00,  4.84it/s]�[A
�[A

After running tqdm_pandas(tqdm()).
Some strange characters are printed instead of the carriage return action.
Running tqdm_pandas(tqdm()) again creates more of these strange characters and new lines:

>>> tqdm_pandas(tqdm())


0it [00:00, ?it/s]�[A�[A
>>> for i in trange(10):
    time.sleep(0.2)





  0%|          | 0/10 [00:00<?, ?it/s]�[A�[A�[A


 10%|█         | 1/10 [00:00<00:01,  4.98it/s]�[A�[A�[A


 20%|██        | 2/10 [00:00<00:01,  4.93it/s]�[A�[A�[A


 30%|███       | 3/10 [00:00<00:01,  4.89it/s]�[A�[A�[A


 40%|████      | 4/10 [00:00<00:01,  4.87it/s]�[A�[A�[A


 50%|█████     | 5/10 [00:01<00:01,  4.84it/s]�[A�[A�[A


 60%|██████    | 6/10 [00:01<00:00,  4.83it/s]�[A�[A�[A


 70%|███████   | 7/10 [00:01<00:00,  4.83it/s]�[A�[A�[A


 80%|████████  | 8/10 [00:01<00:00,  4.78it/s]�[A�[A�[A


 90%|█████████ | 9/10 [00:01<00:00,  4.75it/s]�[A�[A�[A


100%|██████████| 10/10 [00:02<00:00,  4.78it/s]�[A�[A�[A


�[A�[A�[A

This only happens in IDLE. When I try the python in Shell it behaves fine (except that it stays there after the loop is over).

Thanks for the amazing project!

@casperdcl
Copy link
Sponsor Member

this implies IDLE

  1. does not support nested bars
  2. does not garbage collect aggressively enough so is not closing old bars
    and thus attempting to nest them

Do you experience the same issue if just doing a normal trange twice?
On 1 Jul 2016 4:55 a.m., "Ofir Reich" notifications@github.com wrote:

from tqdm import *
import time

good

for i in trange(10):
time.sleep(0.2)

100%|██████████| 10/10 [00:02<00:00, 4.92it/s]

this will break things:

tqdm_pandas(tqdm())
0it [00:00, ?it/s]
for i in trange(10):
time.sleep(0.2)

0%| | 0/10 [00:00<?, ?it/s]�[A
10%|█ | 1/10 [00:00<00:01, 4.97it/s]�[A
20%|██ | 2/10 [00:00<00:01, 4.90it/s]�[A
30%|███ | 3/10 [00:00<00:01, 4.85it/s]�[A
40%|████ | 4/10 [00:00<00:01, 4.84it/s]�[A
50%|█████ | 5/10 [00:01<00:01, 4.84it/s]�[A
60%|██████ | 6/10 [00:01<00:00, 4.83it/s]�[A
70%|███████ | 7/10 [00:01<00:00, 4.82it/s]�[A
80%|████████ | 8/10 [00:01<00:00, 4.83it/s]�[A
90%|█████████ | 9/10 [00:01<00:00, 4.84it/s]�[A
100%|██████████| 10/10 [00:02<00:00, 4.84it/s]�[A
�[A

After running tqdm_pandas(tqdm()).
Some strange characters are printed instead of the carriage return action.
Running tqdm_pandas(tqdm()) again creates more of these strange characters
and new lines:

tqdm_pandas(tqdm())

0it [00:00, ?it/s]�[A�[A

for i in trange(10):
time.sleep(0.2)

0%| | 0/10 [00:00<?, ?it/s]�[A�[A�[A

10%|█ | 1/10 [00:00<00:01, 4.98it/s]�[A�[A�[A

20%|██ | 2/10 [00:00<00:01, 4.93it/s]�[A�[A�[A

30%|███ | 3/10 [00:00<00:01, 4.89it/s]�[A�[A�[A

40%|████ | 4/10 [00:00<00:01, 4.87it/s]�[A�[A�[A

50%|█████ | 5/10 [00:01<00:01, 4.84it/s]�[A�[A�[A

60%|██████ | 6/10 [00:01<00:00, 4.83it/s]�[A�[A�[A

70%|███████ | 7/10 [00:01<00:00, 4.83it/s]�[A�[A�[A

80%|████████ | 8/10 [00:01<00:00, 4.78it/s]�[A�[A�[A

90%|█████████ | 9/10 [00:01<00:00, 4.75it/s]�[A�[A�[A

100%|██████████| 10/10 [00:02<00:00, 4.78it/s]�[A�[A�[A

�[A�[A�[A

This only happens in IDLE. When I try the python in Shell it behaves fine
(except that it stays there after the loop is over).

Thanks for the amazing project!


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#191, or mute the thread
https://github.com/notifications/unsubscribe/AKR9m9xG_8UqmxhG6kNzow176uInaEVHks5qRI-ygaJpZM4JCzEE
.

@ofir-reich
Copy link
Author

Correct.

>>> for i in trange(10):
    for j in trange(3):
        time.sleep(0.2)


  0%|          | 0/10 [00:00<?, ?it/s]
  0%|          | 0/3 [00:00<?, ?it/s]�[A
 33%|███▎      | 1/3 [00:00<00:00,  4.99it/s]�[A
 67%|██████▋   | 2/3 [00:00<00:00,  3.96it/s]�[A
100%|██████████| 3/3 [00:00<00:00,  4.18it/s]�[A
 10%|█         | 1/10 [00:00<00:07,  1.25it/s]
  0%|          | 0/3 [00:00<?, ?it/s]�[A
 33%|███▎      | 1/3 [00:00<00:00,  4.97it/s]�[A
 67%|██████▋   | 2/3 [00:00<00:00,  4.92it/s]�[A
100%|██████████| 3/3 [00:00<00:00,  4.88it/s]�[A
 20%|██        | 2/10 [00:01<00:05,  1.34it/s]
  0%|          | 0/3 [00:00<?, ?it/s]�[A
 33%|███▎      | 1/3 [00:00<00:00,  4.98it/s]�[A
 67%|██████▋   | 2/3 [00:00<00:00,  4.96it/s]�[A
...

Multiple bars work in python run from Shell.

@lrq3000
Copy link
Member

lrq3000 commented Jul 3, 2016

Yes this is a well-known issue with IDLE, all progress bars are affected. IDLE can support only \t and \n control characters, but not any other. The main dev stated this was on purpose as it can ease debugging:

The tk Text widget used by IDLE only interprets \t and \n, but not other control characters. To some of us, this seems appropriate for a development environment, where erasing characters is less appropriate than in a production environment.

http://stackoverflow.com/a/35900117/1121352

@alfredoxyanez
Copy link

Is there a way for tqdm to run only on the shell and not when you run from IDLE directly ?

@casperdcl
Copy link
Sponsor Member

@ayanez17 I think you're referring to something like #443

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid ⛔ Not-an-issue or upstream (not-our-issue)
Projects
None yet
Development

No branches or pull requests

4 participants