-
Notifications
You must be signed in to change notification settings - Fork 948
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 sometimes approximates the max and does show the desired range #1889
Comments
Thanks for the clear and concise bug report (with an example!). I've confirmed the problem in widgets 7.1.0. I'm looking into it... |
This happens because of a floating point number issue, and I think the jqueryui slider we are using handles it incorrectly. When a slider's max is set, it's modified by this function: https://github.com/jquery/jquery-ui/blob/89af4c292eaa5fc1c83437ca71085264dcbef34a/ui/widgets/slider.js#L551 In that function, jqueryui tries to address roundoff error from the step by calculating what the max should be if we take the given number of steps from the min (let's call this the stepmax). However, it subtracts a whole step if the stepmax is more than the max. I think what it should do is realize that the last step may not be a full step, and set the max to what was explicitly set. For now, a workaround is to set max to something like Perhaps this is another reason for us to move off of the jqueryui slider: #630. |
The fundamental problem we are dealing with here is that |
Reference my comment at jquery/jquery-ui#1664 (comment) - which is where the current logic is put into place. |
I filed a bug on their bugtracker: https://bugs.jqueryui.com/ticket/15262 |
Another thing we could do is to specifically work around the jqueryui bug by automatically setting the slider max (and min?) to something slightly different. So in this example, our code would run the same test that jqueryui runs in its code to subtract a step value, and would then (if needed) adjust the jqueryui slider max option to something slightly more than
I think that wouldn't be too hard to implement, though it's still unfortunate that we need to do it. I'll set this to 'good first issue' since making such a workaround is a nicely-scoped several-line solution. |
I have confirmed (on Binder) that the new slider package on master (slated for 8.0 release) does not have this issue. Closing as fixed. |
I use ipywidgets 7.0.5 (py35_0)
Running the following code I get a widget in the range [0.2, 0.5] instead of [0.2,0.6]:
w = widgets.FloatSlider(value = 0.5, min = 0.2, max = 0.6, step = 0.1, description = "w")
The text was updated successfully, but these errors were encountered: