@@ -137,23 +137,17 @@ def contains(self, mouseevent, radius=None):
137
137
"""
138
138
if callable (self ._contains ):
139
139
return self ._contains (self , mouseevent )
140
- inside = False
141
- start = 0
142
140
radius = self ._process_radius (radius )
143
141
codes = self .get_path ().codes
144
142
vertices = self .get_path ().vertices
145
- for i in range (1 , len (codes )+ 1 ):
146
- # fix bug (#8384)
147
- # if current path is concatenated by multiple pathes
148
- # check if any subpath contains the point.
149
- if (i == len (codes )) or (codes [i ] == 1 ):
150
- path = Path (np .concatenate ([vertices [start : i ]]),
151
- np .concatenate ([codes [start : i ]]))
152
- inside = inside or path .contains_point (
153
- (mouseevent .x , mouseevent .y ), self .get_transform (), radius
154
- )
155
- start = i
156
- return inside , {}
143
+ idxs , = np .nonzero (codes == 1 )
144
+ # Don't split before the first MOVETO.
145
+ idxs = idxs [1 :]
146
+ return any (
147
+ subpath .contains_point (
148
+ (mouseevent .x , mouseevent .y ), self .get_transform (), radius )
149
+ for subpath in map (
150
+ Path , np .split (vertices , idxs ), np .split (codes , idxs ))), {}
157
151
158
152
def contains_point (self , point , radius = None ):
159
153
"""
0 commit comments