Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Deprecate Artist.{set,get}_contains. #16200

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 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions doc/api/next_api_changes/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,13 @@ Setting a `.Line2D`\'s pickradius (i.e. the tolerance for pick events
and containment checks) via `.Line2D.set_picker` is deprecated. Use
`.Line2D.set_pickradius` instead.

`.Line2D.set_picker` no longer sets the artist's custom-contain() check. Use
``Line2D.set_contains`` instead.
`.Line2D.set_picker` no longer sets the artist's custom-contain() check.

``Artist.set_contains``, ``Artist.get_contains``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Setting a custom method overridding `.Artist.contains` is deprecated.
There is no replacement, but you may still customize pick events using
`.Artist.set_picker`.

`~matplotlib.colorbar.Colorbar` methods
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
13 changes: 6 additions & 7 deletions lib/matplotlib/artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ def _default_contains(self, mouseevent, figure=None):
"""
Base impl. for checking whether a mouseevent happened in an artist.

1. If the artist defines a custom checker, use it.
1. If the artist defines a custom checker, use it (deprecated).
2. If the artist figure is known and the event did not occur in that
figure (by checking its ``canvas`` attribute), reject it.
3. Otherwise, return `None, {}`, indicating that the subclass'
Expand All @@ -396,7 +396,7 @@ def _default_contains(self, mouseevent, figure=None):
return inside, info
# subclass-specific implementation follows

The `canvas` kwarg is provided for the implementation of
The *figure* kwarg is provided for the implementation of
`Figure.contains`.
"""
if callable(self._contains):
Expand All @@ -406,7 +406,8 @@ def _default_contains(self, mouseevent, figure=None):
return None, {}

def contains(self, mouseevent):
"""Test whether the artist contains the mouse event.
"""
Test whether the artist contains the mouse event.

Parameters
----------
Expand All @@ -420,17 +421,14 @@ def contains(self, mouseevent):
An artist-specific dictionary of details of the event context,
such as which points are contained in the pick radius. See the
individual Artist subclasses for details.

See Also
--------
set_contains, get_contains
"""
inside, info = self._default_contains(mouseevent)
if inside is not None:
return inside, info
_log.warning("%r needs 'contains' method", self.__class__.__name__)
return False, {}

@cbook.deprecated("3.3", alternative="set_picker")
def set_contains(self, picker):
"""
Define a custom contains test for the artist.
Expand Down Expand Up @@ -458,6 +456,7 @@ def contains(artist: Artist, event: MouseEvent) -> bool, dict
raise TypeError("picker is not a callable")
self._contains = picker

@cbook.deprecated("3.3", alternative="get_picker")
def get_contains(self):
"""
Return the custom contains function of the artist if set, or *None*.
Expand Down