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

EnhancedTextProgressBar not coherent with docstring of BaseProgressBar #2148

Closed
NathalyaaHikari opened this issue Apr 3, 2023 · 1 comment

Comments

@NathalyaaHikari
Copy link

Bug Description

When initializing an EnhancedTextProgressBar object the __init__ method is calling the start method of it's super class instead of it's own. When then using update (without calling start manually again) there will be an AttributeError because width is not getting initialized by __init__

Code to Reproduce the Bug

from qutip.ui.progressbar import *

n = 10
a = EnhancedTextProgressBar(n)
# a.start(n)
for i in range(n):
    a.update(i)
a.finished()

Code Output

Traceback (most recent call last):
  File "C:\Users\Name\Desktop\qutip_bug.py", line 6, in <module>
    a.update(i)
  File "C:\Users\Name\AppData\Local\Programs\Python\Python311\Lib\site-packages\qutip\ui\progressbar.py", line 96, in update
    all_full = self.width - 2
               ^^^^^^^^^^
AttributeError: 'EnhancedTextProgressBar' object has no attribute 'width'

Expected Behaviour

Proper initialization of the width attribute by EnhancedTextProgressBar.__init__

Your Environment

QuTiP Version:      4.7.1
Numpy Version:      1.24.2
Scipy Version:      1.10.1
Cython Version:     0.29.33
Matplotlib Version: 3.7.1
Python Version:     3.11.0
Number of CPUs:     8
BLAS Info:          OPENBLAS
OPENMP Installed:   False
INTEL MKL Ext:      False
Platform Info:      Windows (AMD64)

Additional Context

Currently in master the __init__ for both TextProgressBar and EnhancedTextProgressBar have been commented out and made to just pass. See

def __init__(self, iterations=0, chunk_size=10):
and
def __init__(self, iterations=0, chunk_size=10):

I would suggest making them both call their own start method to omit an additional call of start by the user right after initialization. This would also make both classes be in line with the usage suggested by the docstring of BaseProgressBar. Otherwise I would suggest to include the call to start in said docstring.

As I'm pretty new to github and git in general I would like to try and create a PR myself once you give me approval for the suggested change here.

@Ericgig
Copy link
Member

Ericgig commented Mar 31, 2024

Fixed in v5

@Ericgig Ericgig closed this as completed Mar 31, 2024
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

2 participants