-
Notifications
You must be signed in to change notification settings - Fork 947
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
Why are IntSlider and FloatSlider completely independent? #721
Comments
It looks like at least the views are shared: https://github.com/ipython/ipywidgets/blob/master/jupyter-js-widgets/src/widget_float.ts#L69 I thought there was more code sharing than apparently there actually is. It sounds like a good idea to refactor common functionality to a base class. |
Part of the reason is surely because of |
Do you think that there is a need for a |
There should probably be something like a number meta-trait type, say But I don't know anything about traitlets to be honest... |
Wow, we haven't gotten into meta trait types yet (like c++ templates )! 😄 That would be cool though. I was more thinking of a trait like Any that validate anything that is an instance of |
Well, you have |
@minrk what do you think of a |
Not quite, I meant parameterized trait types :) - although we have Instance, but it is an identity, not some computation based on types. |
That would be useful, but it would just be You could consider just changing |
Changing Float to Number(float) would probably work... |
A |
Yeah, I was thinking of matching the |
I don't see how that would work, since those are abstract types. I don't see the point of making a difference between You need concrete types for this because you want to control the type of |
That is exactly what I had in mind. Just that complex is not an option :) |
But that's not at all "matching the numbers hierarchy", so I'm confused now... |
I meant creating traittypes for the different levels of the numbers hierarchy. |
You mean concrete trait types like Like I said before, I would really prefer to determine the concrete type of |
The former. |
But that wouldn't solve my problem... |
My proposal is
the latter would be a better match with the js frontend which does not have a notion of int. |
I don't know the internal implementation, but why would the js frontend even need to know the value of the widget? I would prefer if the js widget would be as basic as possible: it should only know "this is a slider with 100 marks and the current value is mark 39". |
As an example, our jslink/jsdlink widgets let you hook widget values up on the browser side, so you'd need to know the value there. |
It seems that the
IntSlider
andFloatSlider
widgets are implemented completely independently, even though they do essentially the same thing for a different type. I would have expected that both classes would be specializations of, say,NumericSlider
or even that there would be just one class which could handle bothint
andfloat
.I am asking this question because maybe I want sliders for other kind of numbers (e.g. numpy or SageMath numbers or fractions).
CC @SylvainCorlay
The text was updated successfully, but these errors were encountered: