8000 Dedupe implementation of axes grid switching in toolmanager. by anntzer · Pull Request #16823 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Dedupe implementation of axes grid switching in toolmanager. #16823

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

Merged
merged 1 commit into from
Mar 30, 2020

Conversation

anntzer
Copy link
Contributor
@anntzer anntzer commented Mar 18, 2020

... by making it forward to the "classic" toolbar implementation.

(I have the vague feeling we need to decide what we really want to do with toolmanager, at some point...)

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@anntzer anntzer added this to the v3.3.0 milestone Mar 18, 2020
Copy link
Member
@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, this looks like a great simplification. 👍


class ToolMinorGrid(_ToolGridBase):
def trigger(self, sender, event, data=None):
sentinel = str(uuid.uuid4()) # Prevent triggering the wrong handler.
Copy link
Member
@timhoffm timhoffm Mar 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add a comment to explain on a higher level what we're doing here, e.g.

# Trigger grid switching by temporarily setting rcParams['keymap.grid']
# to a unique key and sending an appropriate event.

Also, is it safe to modify the event here? Now knowing about the implementation, I could imagine e.g. that events are divided in separate subclasses like MouseEvent, KeyPressEvent and that key_press_handler() will ignore MouseEvents. But for some reason this is triggered via a MouseEvent.

I may be overly cautious here. From the little I know about the event system, I have the impression that it's rather loosely defined. I'm afraid that this could break if we do refinements on the event system.

Speaking of which, is it possible to test this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added your clarifying comment.
The event is completely restored immediately after the event is processed, so we should be fine.
There's no tests for now, but helping setting up testing is actually a good reason for this dedupe -- that means less stuff to test twice (between the classic toolbar and the toolmanager).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, actually I wanted to test this injection logic, which means you'd need to write a test around toolmanager. Independently, one may want a test for the classic trigger as well. 👼

Anyway, I'm half-way approving without a test, but want to think about it for a bit.

... by making it forward to the "classic" toolbar implementation.
Copy link
Member
@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though a test would be a strong plus, in a way not testing the new code is not worse than not testing the old code.

@anntzer
Copy link
Contributor Author
anntzer commented Mar 29, 2020

Actually once #16933 goes in it should be easy to test this.

@tacaswell
Copy link
Member

This is very clever.

@tacaswell tacaswell merged commit 1bf9ea5 into matplotlib:master Mar 30, 2020
@anntzer anntzer deleted the toolgrid branch March 30, 2020 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0