-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Validation on the python side #7602
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
Conversation
|
Thanks @SylvainCorlay . I see you opened #7603 too, I still think this should get merged regardless, for 3.0 . |
|
Yes I think too. I doubt the other logic will replace this one for IPython 3.0. |
|
@SylvainCorlay I've checked out this branch and I'm testing it now. The code looks a-okay to me. |
|
@SylvainCorlay this does fix the problem @ssunkara1 reported, but I did find another problem. I haven't checked if it exists in master too or if it's a result of this fix. a.min = 20
a.value = 50print(a.value)50 %%javascript
element.log(a.get('value'));50 print(a.value)20 %%javascript
element.log(a.get('value'));50 The Javascript value is out of sync with the Python value. It should log 20... |
|
My IPython logging convenience function: %%javascript
/**
* Log to a notebook cell for easy reading.
*
* Usage:
* %%javascript
* element.log('hello world!');
*/
element.constructor.prototype.log = function() {
for (var i = 0; i < arguments.length; i++) {
this.append($('<div/>').text(String(arguments[i])));
}
}; |
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 not use the _max_changed name instead of defining the method and registering it manually?
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.
I was simply replicating the logic from _BoundedInt in _BoundedFloat. I can change that.
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.
Now using _max_changed, _min_changed and _value_changed.
|
Thanks @SylvainCorlay ! |
|
It looks like there's a legitimate test failure. |
|
I think now that you're using the _X_changed syntax, validation is occurring earlier and that's causing the failure. Strange, the default values should pass validation... |
|
I can reset to the previous commit if it is fine with you. It is possible that the validation happens even before all the default values are set, which would explain the failure. |
|
It seems that may be a better idea than using a lock to prevent validation until after initialization. I'm going to take a quick look... |
|
@SylvainCorlay ah it was just a typo: SylvainCorlay#1 |
|
If there's a good reason for it to not use the |
|
Test failures look real. |
|
Sorry for the trouble @SylvainCorlay , I thought those typos were the problem. At this point I think it's best to revert back to 200775b because I think my original evaluation of the problem was right (validation is occurring too early now). |
160f369 to
2368f9a
Compare
|
ok, let me do that - and rebase. |
|
@SylvainCorlay looks like the commit got credited to me even though I haven't done anything :P . Do you want to fix that before we Travis&merge? |
|
@jdfreder I rebased the whole thing to 2 commits:
|
|
It is funny how an old inline comment on an outdated diff is displayed again. |
|
@jdfreder green button? |
Validation on the python side
|
🍏 |
This is a simple fix for #6814. In general, whenever a widget model may be modified by both the backend and the frontend, if there is a validation stage that transform the set values, the logic should be implemented on both sides.
On this regard, but outside of the scope of this small PR: