Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Backport PR #13057 on branch v3.1.x (Simplify callable(self._contains) checks)#13497

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall 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
4 changes: 3 additions & 1 deletionlib/matplotlib/artist.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -386,7 +386,7 @@ def contains(self, mouseevent):
--------
set_contains, get_contains
"""
ifcallable(self._contains):
if self._contains is not None:
return self._contains(self, mouseevent)
_log.warning("%r needs 'contains' method", self.__class__.__name__)
return False, {}
Expand DownExpand Up@@ -414,6 +414,8 @@ def contains(artist: Artist, event: MouseEvent) -> bool, dict
implementation of the respective artist, but may provide
additional information.
"""
if not callable(picker):
raise TypeError("picker is not a callable")
self._contains = picker

def get_contains(self):
Expand Down
2 changes: 1 addition & 1 deletionlib/matplotlib/axes/_base.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4222,7 +4222,7 @@ def get_children(self):

def contains(self, mouseevent):
# docstring inherited.
ifcallable(self._contains):
if self._contains is not None:
return self._contains(self, mouseevent)
return self.patch.contains(mouseevent)

Expand Down
6 changes: 3 additions & 3 deletionslib/matplotlib/axis.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -243,7 +243,7 @@ def contains(self, mouseevent):
This function always returns false. It is more useful to test if the
axis as a whole contains the mouse rather than the set of tick marks.
"""
ifcallable(self._contains):
if self._contains is not None:
return self._contains(self, mouseevent)
return False, {}

Expand DownExpand Up@@ -1846,7 +1846,7 @@ class XAxis(Axis):
def contains(self, mouseevent):
"""Test whether the mouse event occurred in the x axis.
"""
ifcallable(self._contains):
if self._contains is not None:
return self._contains(self, mouseevent)

x, y = mouseevent.x, mouseevent.y
Expand DownExpand Up@@ -2155,7 +2155,7 @@ def contains(self, mouseevent):

Returns *True* | *False*
"""
ifcallable(self._contains):
if self._contains is not None:
return self._contains(self, mouseevent)

x, y = mouseevent.x, mouseevent.y
Expand Down
2 changes: 1 addition & 1 deletionlib/matplotlib/collections.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -353,7 +353,7 @@ def contains(self, mouseevent):
Returns ``bool, dict(ind=itemlist)``, where every item in itemlist
contains the event.
"""
ifcallable(self._contains):
if self._contains is not None:
return self._contains(self, mouseevent)

if not self.get_visible():
Expand Down
2 changes: 1 addition & 1 deletionlib/matplotlib/figure.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -656,7 +656,7 @@ def contains(self, mouseevent):
-------
bool, {}
"""
ifcallable(self._contains):
if self._contains is not None:
return self._contains(self, mouseevent)
inside = self.bbox.contains(mouseevent.x, mouseevent.y)
return inside, {}
Expand Down
4 changes: 2 additions & 2 deletionslib/matplotlib/image.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -613,7 +613,7 @@ def contains(self, mouseevent):
"""
Test whether the mouse event occurred within the image.
"""
ifcallable(self._contains):
if self._contains is not None:
return self._contains(self, mouseevent)
# TODO: make sure this is consistent with patch and patch
# collection on nonlinear transformed coordinates.
Expand DownExpand Up@@ -1302,7 +1302,7 @@ def get_window_extent(self, renderer=None):

def contains(self, mouseevent):
"""Test whether the mouse event occurred within the image."""
ifcallable(self._contains):
if self._contains is not None:
return self._contains(self, mouseevent)

if not self.get_visible(): # or self.get_figure()._renderer is None:
Expand Down
2 changes: 1 addition & 1 deletionlib/matplotlib/patches.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -128,7 +128,7 @@ def contains(self, mouseevent, radius=None):

Returns T/F, {}
"""
ifcallable(self._contains):
if self._contains is not None:
return self._contains(self, mouseevent)
radius = self._process_radius(radius)
inside = self.get_path().contains_point(
Expand Down
2 changes: 1 addition & 1 deletionlib/matplotlib/table.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -438,7 +438,7 @@ def _get_grid_bbox(self, renderer):

def contains(self, mouseevent):
# docstring inherited
ifcallable(self._contains):
if self._contains is not None:
return self._contains(self, mouseevent)

# TODO: Return index of the cell containing the cursor so that the user
Expand Down
2 changes: 1 addition & 1 deletionlib/matplotlib/text.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -194,7 +194,7 @@ def contains(self, mouseevent):
-------
bool : bool
"""
ifcallable(self._contains):
if self._contains is not None:
return self._contains(self, mouseevent)

if not self.get_visible() or self._renderer is None:
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp