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

Commita1a62b4

Browse files
authored
Merge pull request#13497 from meeseeksmachine/auto-backport-of-pr-13057-on-v3.1.x
Backport PR#13057 on branch v3.1.x (Simplify callable(self._contains) checks)
2 parentsbc7b7a6 +bc07a8e commita1a62b4

File tree

9 files changed

+14
-12
lines changed

9 files changed

+14
-12
lines changed

‎lib/matplotlib/artist.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ def contains(self, mouseevent):
386386
--------
387387
set_contains, get_contains
388388
"""
389-
ifcallable(self._contains):
389+
ifself._containsisnotNone:
390390
returnself._contains(self,mouseevent)
391391
_log.warning("%r needs 'contains' method",self.__class__.__name__)
392392
returnFalse, {}
@@ -414,6 +414,8 @@ def contains(artist: Artist, event: MouseEvent) -> bool, dict
414414
implementation of the respective artist, but may provide
415415
additional information.
416416
"""
417+
ifnotcallable(picker):
418+
raiseTypeError("picker is not a callable")
417419
self._contains=picker
418420

419421
defget_contains(self):

‎lib/matplotlib/axes/_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4222,7 +4222,7 @@ def get_children(self):
42224222

42234223
defcontains(self,mouseevent):
42244224
# docstring inherited.
4225-
ifcallable(self._contains):
4225+
ifself._containsisnotNone:
42264226
returnself._contains(self,mouseevent)
42274227
returnself.patch.contains(mouseevent)
42284228

‎lib/matplotlib/axis.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def contains(self, mouseevent):
243243
This function always returns false. It is more useful to test if the
244244
axis as a whole contains the mouse rather than the set of tick marks.
245245
"""
246-
ifcallable(self._contains):
246+
ifself._containsisnotNone:
247247
returnself._contains(self,mouseevent)
248248
returnFalse, {}
249249

@@ -1846,7 +1846,7 @@ class XAxis(Axis):
18461846
defcontains(self,mouseevent):
18471847
"""Test whether the mouse event occurred in the x axis.
18481848
"""
1849-
ifcallable(self._contains):
1849+
ifself._containsisnotNone:
18501850
returnself._contains(self,mouseevent)
18511851

18521852
x,y=mouseevent.x,mouseevent.y
@@ -2155,7 +2155,7 @@ def contains(self, mouseevent):
21552155
21562156
Returns *True* | *False*
21572157
"""
2158-
ifcallable(self._contains):
2158+
ifself._containsisnotNone:
21592159
returnself._contains(self,mouseevent)
21602160

21612161
x,y=mouseevent.x,mouseevent.y

‎lib/matplotlib/collections.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ def contains(self, mouseevent):
353353
Returns ``bool, dict(ind=itemlist)``, where every item in itemlist
354354
contains the event.
355355
"""
356-
ifcallable(self._contains):
356+
ifself._containsisnotNone:
357357
returnself._contains(self,mouseevent)
358358

359359
ifnotself.get_visible():

‎lib/matplotlib/figure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ def contains(self, mouseevent):
656656
-------
657657
bool, {}
658658
"""
659-
ifcallable(self._contains):
659+
ifself._containsisnotNone:
660660
returnself._contains(self,mouseevent)
661661
inside=self.bbox.contains(mouseevent.x,mouseevent.y)
662662
returninside, {}

‎lib/matplotlib/image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ def contains(self, mouseevent):
613613
"""
614614
Test whether the mouse event occurred within the image.
615615
"""
616-
ifcallable(self._contains):
616+
ifself._containsisnotNone:
617617
returnself._contains(self,mouseevent)
618618
# TODO: make sure this is consistent with patch and patch
619619
# collection on nonlinear transformed coordinates.
@@ -1302,7 +1302,7 @@ def get_window_extent(self, renderer=None):
13021302

13031303
defcontains(self,mouseevent):
13041304
"""Test whether the mouse event occurred within the image."""
1305-
ifcallable(self._contains):
1305+
ifself._containsisnotNone:
13061306
returnself._contains(self,mouseevent)
13071307

13081308
ifnotself.get_visible():# or self.get_figure()._renderer is None:

‎lib/matplotlib/patches.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def contains(self, mouseevent, radius=None):
128128
129129
Returns T/F, {}
130130
"""
131-
ifcallable(self._contains):
131+
ifself._containsisnotNone:
132132
returnself._contains(self,mouseevent)
133133
radius=self._process_radius(radius)
134134
inside=self.get_path().contains_point(

‎lib/matplotlib/table.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ def _get_grid_bbox(self, renderer):
438438

439439
defcontains(self,mouseevent):
440440
# docstring inherited
441-
ifcallable(self._contains):
441+
ifself._containsisnotNone:
442442
returnself._contains(self,mouseevent)
443443

444444
# TODO: Return index of the cell containing the cursor so that the user

‎lib/matplotlib/text.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def contains(self, mouseevent):
194194
-------
195195
bool : bool
196196
"""
197-
ifcallable(self._contains):
197+
ifself._containsisnotNone:
198198
returnself._contains(self,mouseevent)
199199

200200
ifnotself.get_visible()orself._rendererisNone:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp