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

'FloatSlider' widget crash when setting up a minimum value #505

Closed
lorenzocerrone opened this issue Nov 15, 2022 · 5 comments · Fixed by #511
Closed

'FloatSlider' widget crash when setting up a minimum value #505

lorenzocerrone opened this issue Nov 15, 2022 · 5 comments · Fixed by #511
Labels
bug Something isn't working

Comments

@lorenzocerrone
Copy link

Describe the bug
In magicgui 0.6.0 setting up a min value different from 0. for the FloatSlider causes two bugs in the widget.

  1. The default value shown is wrong. (100000, for default=1, and min=0.1)
  2. When moving the slider the widget crash
Traceback (most recent call last):
  File ".../python3.10/site-packages/magicgui/backends/_qtpy/widgets.py", line 640, in _on_readout_change
    self._qwidget.setValue(self._pre_set_hook(self._readout_widget.value()))
OverflowError: argument 1 overflowed: value must be in the range -2147483648 to 2147483647
[1]    12542 IOT instruction (core dumped)  python test.py

Some more details:

  • The error does not affect the function call. If I run the widget in the example below, I get the correct value 1.
  • if I set min=0. the widget works normally.
  • Typing a new value next to the slider causes the same Traceback as above.

To Reproduce

from magicgui import magicgui

@magicgui(call_button='Run',
          sigma={'label': 'Sigma',
                 'widget_type': 'FloatSlider',
                 'max': 5.0,
                 'min': 0.1})
def widget_test(sigma: float = 1.0) -> None:
    print(sigma)

widget_test.show(run=True)

Screenshots
Screenshot from 2022-11-15 10-29-43

Environment (please complete the following information):

  • OS: linux, fedora 35
  • backend: Qt: 5.12.9, PyQt5: 5.12.3
  • magicgui version 0.6.0
  • python: 3.10
@lorenzocerrone lorenzocerrone added the bug Something isn't working label Nov 15, 2022
@tlambert03
Copy link
Member

tlambert03 commented Nov 16, 2022

Hi @lorenzocerrone, can you also tell me what version of superqt you have installed? (and, perhaps try updating it with pip install -U superqt?)

I am able to reproduce the problem with setting the min and max (and seeing a weird range)... but haven't been able to get the crash yet

@tlambert03
Copy link
Member

ah nevermind... took another look at the code, I thought we were using superqt's DoubleSlider here, but it looks like not. Will try to get this fixed soon, thanks for reporting

@brisvag
Copy link
Contributor

brisvag commented Nov 18, 2022

Just encountered the same (probably) issue, but with slightly different error [EDIT: looks like it's exactly the same, my bad :P]:

from magicgui import magicgui

@magicgui(auto_call=True, f=dict(widget_type='FloatSlider', min=0.5))
def a(f: float = 1):
    print(f)

a.show()

The slider works fine, and the printed values are in the correct range. However, the label is the problem:

image

And if I try to edit it, this error appears:

File ~/git/magicgui/src/magicgui/backends/_qtpy/widgets.py:650, in Slider._on_readout_change(self)
    649 def _on_readout_change(self):
--> 650     self._qwidget.setValue(self._pre_set_hook(self._readout_widget.value()))                      

OverflowError: argument 1 overflowed: value must be in the range -2147483648 to 2147483647

@tlambert03
Copy link
Member

thanks @brisvag

git bisect says the change occurred in #455 ... so it must be in the _init_range method that was added there

@tlambert03
Copy link
Member

Fixed in 0.6.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants