-
-
Notifications
You must be signed in to change notification settings - Fork 536
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
discreteslider crashes with only a single value #2395
Comments
Well I guess all sliders are like this, but maybe it'd be good to duplicate the first value or disable it if only one value? |
A minimum reproducible example would be import panel as pn
pn.extension(sizing_mode="stretch_width")
pn.widgets.DiscreteSlider(options=["something else"]).servable() ValueError: Slider 'start' and 'end' cannot be equal.
Traceback (most recent call last):
File "c:\repos\private\panel_docker\panel\.venv\lib\site-packages\bokeh\application\handlers\code_runner.py", line 197, in run
exec(self._code, module.__dict__)
File "C:\repos\private\panel_docker\panel\panel\test_example.py", line 4, in <module>
pn.widgets.DiscreteSlider(options=["something else"]).servable()
File "c:\repos\private\panel_docker\panel\panel\viewable.py", line 331, in servable
self.server_doc(title=title, location=location)
File "c:\repos\private\panel_docker\panel\panel\viewable.py", line 782, in server_doc
model = self.get_root(doc)
File "c:\repos\private\panel_docker\panel\panel\viewable.py", line 500, in get_root
root = self._get_model(doc, comm=comm)
File "c:\repos\private\panel_docker\panel\panel\widgets\base.py", line 173, in _get_model
model = self._composite._get_model(doc, root, parent, comm)
File "c:\repos\private\panel_docker\panel\panel\layout\base.py", line 113, in _get_model
objects = self._get_objects(model, [], doc, root, comm)
File "c:\repos\private\panel_docker\panel\panel\layout\base.py", line 103, in _get_objects
child = pane._get_model(doc, root, model, comm)
File "c:\repos\private\panel_docker\panel\panel\widgets\base.py", line 79, in _get_model
model = self._widget_type(**self._process_param_change(self._init_params()))
File "c:\repos\private\panel_docker\panel\.venv\lib\site-packages\bokeh\models\widgets\sliders.py", line 71, in __init__
raise ValueError("Slider 'start' and 'end' cannot be equal.")
ValueError: Slider 'start' and 'end' cannot be equal. |
|
I imagine:
The reason for this is if the options are dynamically generated and there is only one selectable option, it would crash the program. |
Agree that this is an issue, widgets can frequently be auto-generated so while it makes little sense to have a single valued slider (or any widget for that matter) it shouldn't error. The real problem we face here is that bokeh does not like it. Duplicating the option is a fix, not sure it is the cleanest. |
The text was updated successfully, but these errors were encountered: