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

Skip to content

Commit d158587

Browse files
authored
Merge pull request #6491 from anntzer/dont-warn-in-collections-picker
MNT: Don't warn in Collections.contains if picker is not numlike.
2 parents f16308a + c5ec5b3 commit d158587

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

lib/matplotlib/collections.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
except ImportError:
1919
# LPy workaround
2020
from fractions import gcd
21-
import warnings
2221

2322
import numpy as np
2423
import matplotlib as mpl
@@ -363,19 +362,11 @@ def contains(self, mouseevent):
363362
if not self.get_visible():
364363
return False, {}
365364

366-
if self._picker is True: # the Boolean constant, not just nonzero or 1
367-
pickradius = self._pickradius
368-
else:
369-
try:
370-
pickradius = float(self._picker)
371-
except TypeError:
372-
# This should not happen if "contains" is called via
373-
# pick, the normal route; the check is here in case
374-
# it is called through some unanticipated route.
375-
warnings.warn(
376-
"Collection picker %s could not be converted to float"
377-
% self._picker)
378-
pickradius = self._pickradius
365+
pickradius = (
366+
float(self._picker)
367+
if cbook.is_numlike(self._picker) and
368+
self._picker is not True # the bool, not just nonzero or 1
369+
else self._pickradius)
379370

380371
transform, transOffset, offsets, paths = self._prepare_points()
381372

0 commit comments

Comments
 (0)