Skip to content

Deprecate Locator.refresh and associated helpers. #16963

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
Apr 14, 2020

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Mar 30, 2020

Locator.refresh() was called at certain places to let locators update
their internal state, typically based on the axis limits. Instead, they
can just always consult the axis limits when called, if needed. (This
should be more robust -- otherwise, a call to a locator basically always
needs to be preceded to a call to refresh() to ensure getting
up-to-date results.)

The deprecation is made slightly complex by the fact that we need to
check whether the user is using a third-party locator which overrides
refresh(), and warn in that case.

The associated helper methods NavigationToolbar2.draw() and
ToolViewsPositions.refresh_locators() (which called refresh() and
then canvas.draw_idle() are deprecated, and should be replaced by
calls to draw_idle() on the corresponding canvas once the deprecation
period ends.

Followup to #15606.

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 30, 2020
Copy link
Member

@efiring efiring left a comment

Choose a reason for hiding this comment

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

Fairly cursory review, but looks good apart from one minor question.

self._draw()

# Can be removed once Locator.refresh() is removed, and replaced by an
# inline call to self.figure.canvas.draw_idle().
Copy link
Member

Choose a reason for hiding this comment

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

Here and above, wouldn't it be self.canvas.draw_idle()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, thanks for noticing.

`Locator.refresh()` was called at certain places to let locators update
their internal state, typically based on the axis limits.  Instead, they
can just always consult the axis limits when called, if needed.  (This
should be more robust -- otherwise, a call to a locator basically always
needs to be preceded to a call to `refresh()` to ensure getting
up-to-date results.)

The deprecation is made slightly complex by the fact that we need to
check whether the user is using a third-party locator which overrides
`refresh()`, and warn in that case.

The associated helper methods `NavigationToolbar2.draw()` and
`ToolViewsPositions.refresh_locators()` (which called `refresh()` and
then `canvas.draw_idle()` are deprecated, and should be replaced by
calls to `draw_idle()` on the corresponding canvas once the deprecation
period ends.
@anntzer
Copy link
Contributor Author

anntzer commented Apr 14, 2020

rebased

@efiring efiring merged commit 2f32371 into matplotlib:master Apr 14, 2020
@anntzer anntzer deleted the unfresh branch April 14, 2020 17:43
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