diff --git a/lib/matplotlib/artist.py b/lib/matplotlib/artist.py index a38914dcb38a..08f95d6a2a39 100644 --- a/lib/matplotlib/artist.py +++ b/lib/matplotlib/artist.py @@ -386,7 +386,7 @@ def contains(self, mouseevent): -------- set_contains, get_contains """ - if callable(self._contains): + if self._contains is not None: return self._contains(self, mouseevent) _log.warning("%r needs 'contains' method", self.__class__.__name__) return False, {} @@ -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): diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index c2b48b9d9e1b..441fc822ce09 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -4222,7 +4222,7 @@ def get_children(self): def contains(self, mouseevent): # docstring inherited. - if callable(self._contains): + if self._contains is not None: return self._contains(self, mouseevent) return self.patch.contains(mouseevent) diff --git a/lib/matplotlib/axis.py b/lib/matplotlib/axis.py index fd3ee314dad0..e15be513ab3c 100644 --- a/lib/matplotlib/axis.py +++ b/lib/matplotlib/axis.py @@ -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. """ - if callable(self._contains): + if self._contains is not None: return self._contains(self, mouseevent) return False, {} @@ -1846,7 +1846,7 @@ class XAxis(Axis): def contains(self, mouseevent): """Test whether the mouse event occurred in the x axis. """ - if callable(self._contains): + if self._contains is not None: return self._contains(self, mouseevent) x, y = mouseevent.x, mouseevent.y @@ -2155,7 +2155,7 @@ def contains(self, mouseevent): Returns *True* | *False* """ - if callable(self._contains): + if self._contains is not None: return self._contains(self, mouseevent) x, y = mouseevent.x, mouseevent.y diff --git a/lib/matplotlib/collections.py b/lib/matplotlib/collections.py index 3a460efd878b..53df43a41a45 100644 --- a/lib/matplotlib/collections.py +++ b/lib/matplotlib/collections.py @@ -353,7 +353,7 @@ def contains(self, mouseevent): Returns ``bool, dict(ind=itemlist)``, where every item in itemlist contains the event. """ - if callable(self._contains): + if self._contains is not None: return self._contains(self, mouseevent) if not self.get_visible(): diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index a1ffa1a86e66..6919dbf1c4f5 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -656,7 +656,7 @@ def contains(self, mouseevent): ------- bool, {} """ - if callable(self._contains): + if self._contains is not None: return self._contains(self, mouseevent) inside = self.bbox.contains(mouseevent.x, mouseevent.y) return inside, {} diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index 0643d9f9aff2..28aefa96447f 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -613,7 +613,7 @@ def contains(self, mouseevent): """ Test whether the mouse event occurred within the image. """ - if callable(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. @@ -1302,7 +1302,7 @@ def get_window_extent(self, renderer=None): def contains(self, mouseevent): """Test whether the mouse event occurred within the image.""" - if callable(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: diff --git a/lib/matplotlib/patches.py b/lib/matplotlib/patches.py index 565e7baae2c6..91cfa2cc2f63 100644 --- a/lib/matplotlib/patches.py +++ b/lib/matplotlib/patches.py @@ -128,7 +128,7 @@ def contains(self, mouseevent, radius=None): Returns T/F, {} """ - if callable(self._contains): + if self._contains is not None: return self._contains(self, mouseevent) radius = self._process_radius(radius) inside = self.get_path().contains_point( diff --git a/lib/matplotlib/table.py b/lib/matplotlib/table.py index 33827fc726fe..55eadc51b0c1 100644 --- a/lib/matplotlib/table.py +++ b/lib/matplotlib/table.py @@ -438,7 +438,7 @@ def _get_grid_bbox(self, renderer): def contains(self, mouseevent): # docstring inherited - if callable(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 diff --git a/lib/matplotlib/text.py b/lib/matplotlib/text.py index 650689cdb629..3ceffaf3777a 100644 --- a/lib/matplotlib/text.py +++ b/lib/matplotlib/text.py @@ -194,7 +194,7 @@ def contains(self, mouseevent): ------- bool : bool """ - if callable(self._contains): + if self._contains is not None: return self._contains(self, mouseevent) if not self.get_visible() or self._renderer is None: pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy