Closed sdc50 closed 5 years ago
It appears that parambokeh does adapt the step based on the current value of the parameter. This is better, but it still produces some unwanted results.
The following example will produce a slider with a step size of 0.01:
class SmallNumber(param.Parameterized):
n = param.Number(default=0.01, bounds=(0, 1.01))
parambokeh.Widgets(SmallNumber)
But if the default value is changed to 1 then the step size will be 1. The slider will allow the user to set only three values: 0, 1, and 1.01. If the value is set to 1.01 and then the widget is re-rendered then the step size becomes 0.01.
But if the default value is changed to 1 then the step size will be 1.
That might be because the step size is integer when the default is integer? Is this true if you use 1.0 instead?
At any rate, integer stepping should be disabled when the bounds are clearly not integers themselves.
I think the behavior you are reporting is from Bokeh rather than ParamBokeh, and it may be possible to improve Bokeh's heuristics here so that it more reliably has an appropriate default stepsize. In any case, I agree that Param should allow a stepsize to be specified explicitly and that ParamBokeh should respect it.
I'm having the same issue with param.Range
even though the doc examples indicate that will interpret whether or not the input is integer or float. Both of these results in a range tool that uses an integer (1) step size.
integer_range = param.Range(default=(3,7),bounds=(0, 10))
float_range = param.Range(default=(0,1.57),bounds=(0, 3.145))
I think that's a bug, because even this one is forcing integer values, despite there being no integers anywhere:
float_range = param.Range(default=(0.01,1.57),bounds=(0.01, 3.145))
The only relevant code for ranges in ParamBokeh seems to be:
def RangeWidget(*args, **kw):
if not 'start' in kw and 'end' in kw:
kw['start'], kw['end'] = kw['value']
elif 'value' not in kw:
kw['value'] = (kw['start'], kw['end'])
# TODO: should use param definition of integer (when that is
# itself fixed...).
if isinstance(kw['start'], int) and isinstance(kw['end'], int):
kw['step'] = 1
return RangeSlider(*args, **kw)
I'm not sure what that TODO item means, as I don't see any problem noted in param.Integer, but in any case, it seems to be forcing a stepsize of 1 only in cases where the ranges are both ints. Something must not be right about it, though...
This was added in param and panel.
It appears that the default
step
for paramnb and parambokeh slider widgets is 0.1, but I can't see a way to change it. If I have a number with bounds that are smaller than 0.1 then I am unable to use the widget.For example the following produces an unusable widget:
It would be great to specify what the
step
should be, or at least have a default that is based on the bounds.