8000 Fix OffsetBox custom picker by QuLogic · Pull Request #30096 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Fix OffsetBox custom picker #30096

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

QuLogic
Copy link
Member
@QuLogic QuLogic commented May 22, 2025

PR summary

As with the custom picker, Artist.contains returns a boolean and a dictionary in a tuple. This non-empty tuple is always true, so the custom picker would always return True for any non-scroll event. It would also lose the related dictionary.

This broke mplcursors tests.

PR checklist

@QuLogic QuLogic added this to the v3.10.4 milestone May 22, 2025
@greglucas
Copy link
Contributor

Are you able to bring one of the tests from mplcursors over to get coverage of the new line?

@QuLogic
Copy link
Member Author
QuLogic commented May 23, 2025

Possibly, but they all use mplcursors objects too.

Copy link
Contributor
@anntzer anntzer left a comment

Choose a reason for hiding this comment

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

Looks correct, and definitely fixes mplcursors' test suite. A test would be nice indeed.

Also the logic looks a bit inverted, I'd write this as if mouseevent.name == "scroll_event": return False, {} else: return artist.contains(mouseevent), not that it really matters.

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.

Optionally, take suggestions by @anntzer

As with the custom picker, `Artist.contains` returns a boolean and a
dictionary in a tuple. This non-empty tuple is always true, so the
custom picker would always return True for any non-scroll event. It
would also lose the related dictionary.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0