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
Using the early validation hook for IntSlider and FloatSlider #8142
Conversation
e1061c0
to
1e63456
Compare
Can you verify that passing conflicting values on init still fails by adding a few tests? slider = IntSlider(min=1, max=0, value=-1) |
Currently, validation does not occur on init. We cannot use cross validation functions like |
Okay, then I think this one should wait until you add delayed validation to the hold_notifications context (or however it makes the most sense to implement that) |
612af5d
to
9e8b1f4
Compare
@minrk Here is a version of the context manager holding validation. Let me know what you think. |
I think it looks sensible, but it would appear to not be working just yet. Lots of test failures that look like trait values aren't being set. |
9e8b1f4
to
b7a08c6
Compare
8dab755
to
cb87820
Compare
This is ready for further review. |
cb87820
to
cd5834f
Compare
@@ -215,7 +215,7 @@ def excepthook(self, etype, evalue, tb): | |||
return crashhandler.crash_handler_lite(etype, evalue, tb) | |||
|
|||
def _ipython_dir_changed(self, name, old, new): | |||
if old is not None: | |||
if old is not None and old is not Undefined: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can old be Undefined, now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In traitlets.py Line 449, I changed the value of old
from None
to Undefined
in case of key error.
The reason for that change, is that to roll back in case of bulk rejection, I need to distinguish between unset attributes and attributes set to None.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, makes sense. There may be other cases affected by this. We'll have to keep an eye out.
Added a test. |
Using the early validation hook for IntSlider and FloatSlider
@jdfreder @minrk @jasongrout indeed, during initial setting I must prevent the cross validation.