While calling altaipony.flarelc.sample_flare_recovery progressbar.ProgressBar raises error notification
Closed this issue · 3 comments
What needs to be created or improved?
While calling sample_flare_recovery() the implemented Class ProgressBar from the package progress bar raises an error notification. Likely this bug only occurs while using jupyter notebook.
####Code Example:
`import altaipony
from altaipony.lcio import from_mast
Fetch a light curve from MAST
flc = from_mast("KIC 9726699", c=9, mode="LC", mission="Kepler")
De-trend with a Sav-Gol filter
flc = flc.detrend("savgol")
Do the injection-recovery
flc, fake_flc = flc.sample_flare_recovery(inject_before_detrending=False, iterations=10, fakefreq=.001, ampl=[1e-4, 0.5],dur=[.001/6., 0.1/6.])`
``
As the function gets called it will produce the following notification:
TypeError Traceback (most recent call last)
in
1 flcd, fakeflc = flcd.sample_flare_recovery(inject_before_detrending=True, mode="savgol",
2 iterations=50, fakefreq=1, ampl=[1e-4, 0.5],
----> 3 dur=[.001/6., 0.1/6.])
4 #unexpexted keyword argument 'max value' this is why I excluded iterations in flarls.py, I checked in progressbar
5 #and could not find the problem
~/Internship_stellarflares/altaipony/flarelc.py in sample_flare_recovery(self, iterations, inject_before_detrending, mode, func, save_lc_to_file, folder, fakefreq, save, path, **kwargs)
438
439 widgets = [progressbar.Percentage(), progressbar.Bar()]
--> 440 bar = progressbar.ProgressBar(widgets=widgets, max_value = iterations).start() #maxval = max_value
441 for i in range(iterations):
442 fake_lc = copy.deepcopy(lc)
TypeError: init() got an unexpected keyword argument 'max_value'
How can you fix this?
In flarelc.py go to line 440 and change max_value to maxval. As can be seen in the source code of progressbar.ProgressBar in init maxval gets pulled if max_value is none.
def __init__(self, min_value=0, max_value=None, widgets=None, left_justify=True, initial_value=0, poll_interval=None, widget_kwargs=None, custom_len=utils.len_color, max_error=True, prefix=None, suffix=None, variables=None, min_poll_interval=None, **kwargs): ''' Initializes a progress bar with sane defaults ''' StdRedirectMixin.__init__(self, **kwargs) ResizableMixin.__init__(self, **kwargs) ProgressBarBase.__init__(self, **kwargs) if not max_value and kwargs.get('maxval') is not None: warnings.warn('The usage of
maxval is deprecated, please use ' '
max_value instead', DeprecationWarning) **max_value = kwargs.get('maxval')
**
The version of python and jupyter, I was using:
Python 3.7.3
jupyter core : 4.6.1
jupyter-notebook : 6.0.0
qtconsole : not installed
ipython : 7.10.1
ipykernel : 5.1.3
jupyter client : 5.3.3
jupyter lab : 1.2.1
nbconvert : 5.6.1
ipywidgets : 7.5.1
nbformat : 4.4.0
traitlets : 4.3.3
Cheers
Implemented in the latest commit, thanks!
I think I'll change that back - I'm using progressbar2-3.51.4 and there, maxval
is deprecated and throws a warning that I should use max_value
instead. @aaronmaas maybe you nee to update the version progressbar on your machine. Let me know if that helps.
/home/ekaterina/Documents/000_envs/forallpurposes/lib/python3.6/site-packages/progressbar/bar.py:296: DeprecationWarning: The usage of
maxval
is deprecated, please usemax_value
instead
'max_value
instead', DeprecationWarning)
I added a version requirement to setup.py and requirements.txt for progressbar2 now. It should be >=3.51.4 - I am closing this issue unless the error comes back with new installations.