Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Deprecate setting pickradius via set_picker #16154

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 10, 2020

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Jan 8, 2020

There's set_pickradius just for that purpose; moreover
set_picker(True) would previously accidentally also set the pickradius
to 1 (because True == 1...).

Also don't set self._contains in Line2D.set_picker -- this is consistent
with all other artist classes.

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 force-pushed the line2dpickpickradius branch from dd78991 to addd0ca Compare January 8, 2020 01:30
@timhoffm timhoffm changed the title Deprecate setting Line2D's pickradius via set_picker. Deprecate setting pickradius via set_picker Jan 8, 2020
lib/matplotlib/artist.py Outdated Show resolved Hide resolved
examples/event_handling/legend_picking.py Outdated Show resolved Hide resolved
examples/event_handling/legend_picking.py Show resolved Hide resolved
@anntzer anntzer force-pushed the line2dpickpickradius branch from addd0ca to 429ae03 Compare January 9, 2020 00:16
@anntzer anntzer added this to the v3.3.0 milestone Jan 9, 2020
@anntzer anntzer force-pushed the line2dpickpickradius branch from 429ae03 to 0105b67 Compare January 9, 2020 16:56
Setting `.Line2D`\'s pickradius via `.Line2D.set_picker`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Setting a `.Line2D`\'s pickradius (i.e. the tolerance for pick events and
containment checks) is deprecated. Use `.Line2D.set_pickradius` instead.
Copy link
Member

Choose a reason for hiding this comment

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

This sentence reads funny. Suggest "Setting a .Line2D's pickradius via .Line2D.set_picker." Yes, I know it says that the previous line , but if you don't want to repeat, don't repeat any of it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nah, that was just a plain typo, edited to yours.

@@ -543,6 +535,10 @@ def set_picker(self, picker):
artist, return *hit=True* and props is a dictionary of
properties you want added to the PickEvent attributes.

- *deprecated*: For `.Line2D` only, *picker* can also be a float
that sets the tolerance for checking whether an event occurred
Copy link
Member

Choose a reason for hiding this comment

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

Hmmm, you can see how this ended up here, given that we can also pass a function at this point.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But at least functions are not misinterpretable as numbers...

Copy link
Member

Choose a reason for hiding this comment

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

Is the other solution to only set the pick radius if picker is not a bool?

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, you can do that (but what about np.bool_(True)?). But e.g. LineCollections also have a pickradius which is not settable with set_picker, and noone ever requested to change that, so...

Copy link
Member

Choose a reason for hiding this comment

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

Well, I guess you can deprecate it and see if anyone notices... I do think there is some advantage to having the pick logic all in one place, rather than here and in set_pickradius, but don't feel strongly about it

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 have some further cleanups too, but as always and as you say, if people show up with pitchforks, we can always revert the change...

Copy link
Member

Choose a reason for hiding this comment

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

I do think there is some advantage to having the pick logic all in one place

I was thinking about t his as well, but it occurred to me that set_picker(5) is not quite readable.
We can later always try and find something even better, cleaning this up now and aligning withwith other parts of the API is a reasonable step.

There's set_pickradius just for that purpose; moreover
`set_picker(True)` would previously accidentally also set the pickradius
to 1 (because True == 1...).

Also don't set self._contains in Line2D.set_picker -- this is consistent
with all other artist classes.
@anntzer anntzer force-pushed the line2dpickpickradius branch from 0105b67 to a2de5bb Compare January 9, 2020 21:43
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.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.