We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9be87aa commit 8197e2bCopy full SHA for 8197e2b
lib/matplotlib/mlab.py
@@ -3884,14 +3884,14 @@ def contiguous_regions(mask):
3884
idx, = np.nonzero(mask[:-1] != mask[1:])
3885
idx += 1
3886
3887
+ # List operations are faster for moderately sized arrays
3888
+ idx = idx.tolist()
3889
+
3890
# Add first and/or last index if needed
- if mask[0] or mask[-1]:
- idx = (idx,)
- if mask[0]:
3891
- idx = ([0],) + idx
3892
- if mask[-1]:
3893
- idx = idx + ([len(mask)],)
3894
- idx = np.concatenate(idx)
+ if mask[0]:
+ idx = [0] + idx
+ if mask[-1]:
+ idx.append(len(mask))
3895
3896
return list(zip(idx[::2], idx[1::2]))
3897
0 commit comments