8000 Validate Line2D pickradius when setting it, not when reading i… (#16134) · matplotlib/matplotlib@60cb031 · GitHub
[go: up one dir, main page]

Skip to content

Commit 60cb031

Browse files
authored
Validate Line2D pickradius when setting it, not when reading i… (#16134)
Validate Line2D pickradius when setting it, not when reading it.
2 parents a7f136e + 969a485 commit 60cb031

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/matplotlib/lines.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -444,9 +444,6 @@ def contains(self, mouseevent):
444444
if inside is not None:
445445
return inside, info
446446

447-
if not isinstance(self.pickradius, Number):
448-
raise ValueError("pick radius should be a distance")
449-
450447
# Make sure we have data to plot
451448
if self._invalidy or self._invalidx:
452449
self.recache()
@@ -495,7 +492,7 @@ def get_pickradius(self):
495492
496493
See `.contains` for more details.
497494
"""
498-
return self.pickradius
495+
return self._pickradius
499496

500497
def set_pickradius(self, d):
501498
"""Set the pick radius used for containment tests.
@@ -507,7 +504,11 @@ def set_pickradius(self, d):
507504
d : float
508505
Pick radius, in points.
509506
"""
510-
self.pickradius = d
507+
if not isinstance(d, Number) or d < 0:
508+
raise ValueError("pick radius should be a distance")
509+
self._pickradius = d
510+
511+
pickradius = property(get_pickradius, set_pickradius)
511512

512513
def get_fillstyle(self):
513514
"""

0 commit comments

Comments
 (0)
0