Skip to content

Inconsistent errors when setting NaN range on different sliders #298

@qaz10102030

Description

@qaz10102030

Describe the bug
When calling setRange(np.nan, np.nan) on different superqt slider widgets, the errors vary inconsistently depending on the slider type. While I understand that using NaN is not valid input, I can avoid setting NaN in practice, but I thought this might be a design bug, so I wanted to report it just in case.

Some sliders crash with a RecursionError/OverflowError, some raise a ValueError, and others accept the values silently but become non-functional.

To Reproduce
Run the following code snippet, and replace the slider type on line 9 to test various sliders.

import numpy as np
from qtpy.QtCore import Qt
from qtpy.QtWidgets import QApplication
from superqt.sliders import *

app = QApplication([])

# Change this line to test other sliders
slider = QLabeledDoubleRangeSlider()

slider.setOrientation(Qt.Orientation.Horizontal)
slider.setRange(np.nan, np.nan)
slider.show()
app.exec_()

Behavior summary for different sliders

Slider Behavior/Error Traceback
QRangeSlider() Image
QDoubleSlider() Accept the values silently but become non-functional.
Image
QDoubleRangeSlider() Accept the values silently but become non-functional.
Image
QLabeledSlider() Image
QLabeledRangeSlider() Image
QLabeledDoubleSlider() Accept the values silently but become non-functional.
Image
QLabeledDoubleRangeSlider() Image

Expected behavior

  • Maybe a clear and early error (like ValueError) when passing NaN.
  • I think there shouldn't be infinite recursion or crashes deep in enum or label handling.

Desktop (please complete the following information):

  • OS: Win10
  • Qt Backend: Pyside6==6.8.2.1,Superqt==0.7.3
  • Python version: 3.11.9 64-bits

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions