Added bool_to_ranges to convert numpy boolean result to list of ranges

This commit is contained in:
Rob McMullen 2016-03-06 21:38:59 -08:00
parent 7549140abe
commit 44341691f0

View File

@ -100,7 +100,11 @@ class DefaultSegment(object):
def get_style_ranges(self, **kwargs):
style_bits = self.get_style_bits(**kwargs)
w = np.where(self.style & style_bits)[0]
matches = (self.style & style_bits) > 0
return self.bool_to_ranges(matches)
def bool_to_ranges(self, matches):
w = np.where(matches == True)[0]
# split into groups with consecutive numbers
groups = np.split(w, np.where(np.diff(w) != 1)[0] + 1)
ranges = []