Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Clean up RectangleSelector move code#21921
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Uh oh!
There was an error while loading.Please reload this page.
lib/matplotlib/widgets.py Outdated
resize = self._active_handle and not move | ||
if resize: | ||
# If resizing, use xy/xy_press in a de-rotated frame |
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.
#If resizing,use xy/xy_press in a de-rotated frame | |
# use xy/xy_press in a de-rotated frame |
Optional: The code above aleady says it.
lib/matplotlib/widgets.py Outdated
- Re-size | ||
- Contine the creation of a new shape | ||
""" | ||
xy = np.array([event.xdata, event.ydata]) |
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.
xy=np.array([event.xdata,event.ydata]) | |
xy=np.array([event.xdata,event.ydata]) |
Side note: I'm wondering if a small internal class_Point
would make sense for such cases, basically namedtuple-like with arithmetics. So that we can do.
p = _Point(x, y)2*pp + (1, 2)p.x
Arithmetics should still be faster than the numpy overhead.
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 am +-0 on this change, because even if it does make slightly more compact, I am not convinced that it makes the code more readable. To me this is a matter of taste and it doesn't really matter: I don't see it as an improvement or a regression!
Typically, for a matplotlib developerevent.xdata
orevent.x
has a meaning, while in case ofxy
orxy_press
, this is a redirection and one need to look up what it is.
An alternative would be to add some convenience properties (xy
,xydata
) to theEvent
class. These properties could also support basic arithmetic, as suggested by@timhoffm inits comments.
A good point - I've dropped the commit that changes the variable names - hopefully what remains is definitely an improvement? |
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.
Yes, sorry, I have missed these other improvements!
PR Summary
I am working towards improving
RectangleSelector
to allow rotation past +/- 45 degrees. This PR cleans up some of the movement code to:xy
andxy_press
variables to make the code more readablePR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).