-
Notifications
You must be signed in to change notification settings - Fork 949
Add num and round parameters to Float sliders #2719
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
base: main
Are you sure you want to change the base?
Conversation
Default value of |
d308b53
to
f42e8c6
Compare
f42e8c6
to
fd221a4
Compare
Hey @davidbrochart so the way this was supposed to work is, in an example like this:
The slider should go all the way to 70? |
No, this PR introduces a new |
Ah! I see, so it works for me :) |
Good point, maybe yes. And also |
Your changes also work rebasing on the big PR. |
I don't think we should add a |
889d9f3
to
9bc4742
Compare
Given this perhaps the way interact generates sliders should also be changed? That is a far more disruptive change unfortunately. But if |
I'm not sure to follow you. What I meant is that if you pass |
Sorry for the delay @davidbrochart. All works as expected for me :) |
Yeah I'm not sure about the RTD issue, it doesn't seem to be related to this PR. |
If you rebase that error will be fixed. See #3098
Sorry, all I meant was that with this the the default behavior will be slightly divergegent for these two different ways of creating sliders. For direct creation |
9bc4742
to
e94ebd9
Compare
Ah yes you're right, |
I realized the |
Putting this as 8.1 since it is additive and not backwards incompatible. If this is finished before the 8.0 beta, then it can certainly go in! |
@jasongrout this is ready to go in. |
Added a
num
parameter toFloatSlider
andFloatRangeSlider
, which specifies the number of values in the[min, max]
interval, and infersstep
. It can be more intuitive than specifyingstep
.The
num
parameter takes precedence over thestep
parameter.See the
step
API as the equivalent ofnumpy.arange
, and thenum
API as the equivalent ofnumpy.linspace
.Fixes #2287 and such issues where one specifies a
max
value which is not included althoughmax = min + n * step
. With thenum
API,max
is always included.Added a
round
parameter toFloatSlider
, which ifTrue
rounds the value set from Python to the closest value in the set of possible values (according tostep
ornum
), and ifFalse
raises an exception if the specified value is not in the set of possible values (default value isTrue
).