Thanks to visit codestin.com Credit goes to github.com
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 3f384aa commit 9be87aaCopy full SHA for 9be87aa
lib/matplotlib/mlab.py
@@ -3880,9 +3880,18 @@ def contiguous_regions(mask):
3880
if not mask.size:
3881
return []
3882
3883
+ # Find the indices of region changes, and correct offset
3884
idx, = np.nonzero(mask[:-1] != mask[1:])
- idx = np.concatenate((([0],) if mask[0] else ()) + (idx + 1,) +
3885
- (([len(mask)],) if mask[-1] else ()))
+ idx += 1
3886
+
3887
+ # Add first and/or last index if needed
3888
+ if mask[0] or mask[-1]:
3889
+ idx = (idx,)
3890
+ if mask[0]:
3891
+ idx = ([0],) + idx
3892
+ if mask[-1]:
3893
+ idx = idx + ([len(mask)],)
3894
+ idx = np.concatenate(idx)
3895
3896
return list(zip(idx[::2], idx[1::2]))
3897
0 commit comments