-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Improved selection widget #3502
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
Improved selection widget #3502
Conversation
@tacaswell, @fariza, here we go... |
@blink1073 Just for future reference |
I removed |
@blink1073 This needs (at minimum) a re-base. |
8e94df1
to
a68d119
Compare
Rebase complete. |
@@ -0,0 +1,161 @@ | |||
from __future__ import (absolute_import, division, print_function, |
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.
GUI tests? madness!
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.
Ha, I had already written these tests for scikit-image, but yes, it was a pain...
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.
You need to white-list this file to be run in
matplotlib/lib/matplotlib/__init__.py
Line 1397 in c600130
default_test_modules = [ |
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.
Done.
Some tests are failing on Travis |
ae3a08e
to
bdc8800
Compare
I'm at a bit of a loss here. I tested on both Python 2.7 and 3.4 with Ubuntu 14.04 64bit. The build is not only failing two of my tests but some outside of the reach of this PR as well: |
assert ax._got_onselect | ||
|
||
|
||
def test_rectangle_selector(): |
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.
Add a @cleanup
(from matplotlib.testing.decorators
) to this. I suspect that the other failing tests are due the artists form this test leaking out.
I can reproduce the failures locally running the tests like they are run on travis:
I get (slightly different) failures if I run just the widget tests via nosetest:
|
Funny, now that I added the |
xdata = min(x1, xdata) | ||
ydata = max(y0, ydata) | ||
ydata = min(y1, ydata) | ||
event.xdata = xdata |
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.
This smells like something that is going to introduce race-condition/transient bugs if more than one callback is using the same event.
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.
Should events have a lock attribute perhaps? Then you could use with event.lock():
.
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 found the right solution: use a utility method to calculate the bounds as needed, and use a copy
of the events for the onselect
callback.
Passing all tests now. |
Catching |
Sure, but I have no idea what the error means or what to do about it... |
@blink1073 See PR against your branch. |
@tacaswell, I am offended and pleased by your GIF. |
Why offended? |
- strip white space - rearrange 'not's
Widgets assume that the canvas has been drawn atleast once before they are called (which is reasonable for interactive usage as the user needs to be able to _see_ the gui before they can interact with it). Ensure that the tests draw the canvas before trying to use the widgets. Doing this allows for removing some of the error handling logic from the widgets.
dfcb0b7
to
86f28fa
Compare
@tacaswell, assuming I didn't dork up the rebase, this should be good to go. |
@tacaswell, it looks like the build failed due to some unrelated network problems, do you want to restart it? |
ENH : selection widget refactor
What's next, the new RectangleSelector? |
If by new you mean moving over what you have in skimage, then yes! On Wed Nov 12 2014 at 8:08:47 PM Steven Silvester [email protected]
|
This is in preparation for enhancing the selection widgets as per #3486.
This expands the new
_Selector
class from #3376 and normalizes the API for the three current selection widgets:RectangleSelector
,LassoSelector
, andSpanSelector
.The only known API change is that the ignore criteria from the
RectangleSelector
are now used for all three, since they were the most complete and robust.This also adds tests for all three widgets.