Skip to content

Validate Line2D pickradius when setting it, not when reading it. #16134

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
Jan 8, 2020

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Jan 7, 2020

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

@@ -507,7 +504,11 @@ def set_pickradius(self, d):
d : float
Pick radius, in points.
"""
self.pickradius = d
if not isinstance(d, Number):
raise ValueError("pick radius should be a distance")
Copy link
Member

Choose a reason for hiding this comment

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

Great to move this. But should it also be a positive number?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure.

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.

Please state your opinion on pickradius 0. May self-merge after this.

@@ -507,7 +504,11 @@ def set_pickradius(self, d):
d : float
Pick radius, in points.
"""
self.pickradius = d
if not isinstance(d, Number) or d < 0:
Copy link
Member

Choose a reason for hiding this comment

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

Does a pick radius of 0 make sense? It would trigger only if you hit that pixel. Likely set_pickradius(0) might be misunderstood as deactivating picking. Anyway, let's not be overly restrictive. -> ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think zero makes more or less sense than 0.001, for example (especially given that GUI toolkits will typically only report events with a precision of 1px anyways), so I wouldn't overly worry about that.

@anntzer anntzer merged commit 60cb031 into matplotlib:master Jan 8, 2020
@anntzer anntzer deleted the line2dpickradius branch January 8, 2020 00:15
@QuLogic QuLogic added this to the v3.3.0 milestone Mar 24, 2020
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.

4 participants