@@ -123,25 +123,33 @@ def _process_radius(self, radius):
123123 return _radius
124124
125125 def contains (self , mouseevent , radius = None ):
126- """Test whether the mouse event occurred in the patch.
126+ """
127+ Test whether the mouse event occurred in the patch.
127128
128- Returns T/F, {}
129+ Returns
130+ -------
131+ (bool, empty dict)
129132 """
130133 if self ._contains is not None :
131134 return self ._contains (self , mouseevent )
132135 radius = self ._process_radius (radius )
133136 codes = self .get_path ().codes
134- vertices = self .get_path ().vertices
135- # if the current path is concatenated by multiple sub paths.
136- # get the indexes of the starting code(MOVETO) of all sub paths
137- idxs , = np .where (codes == Path .MOVETO )
138- # Don't split before the first MOVETO.
139- idxs = idxs [1 :]
140- return any (
137+ if codes is not None :
138+ vertices = self .get_path ().vertices
139+ # if the current path is concatenated by multiple sub paths.
140+ # get the indexes of the starting code(MOVETO) of all sub paths
141+ idxs , = np .where (codes == Path .MOVETO )
142+ # Don't split before the first MOVETO.
143+ idxs = idxs [1 :]
144+ subpaths = map (
145+ Path , np .split (vertices , idxs ), np .split (codes , idxs ))
146+ else :
147+ subpaths = [self .get_path ()]
148+ inside = any (
141149 subpath .contains_point (
142150 (mouseevent .x , mouseevent .y ), self .get_transform (), radius )
143- for subpath in map (
144- Path , np . split ( vertices , idxs ), np . split ( codes , idxs ))) , {}
151+ for subpath in subpaths )
152+ return inside , {}
145153
146154 def contains_point (self , point , radius = None ):
147155 """
0 commit comments