mirror of
https://github.com/robmcmullen/atrcopy.git
synced 2024-11-29 11:51:14 +00:00
Added bool_to_ranges to convert numpy boolean result to list of ranges
This commit is contained in:
parent
7549140abe
commit
44341691f0
@ -100,7 +100,11 @@ class DefaultSegment(object):
|
|||||||
|
|
||||||
def get_style_ranges(self, **kwargs):
|
def get_style_ranges(self, **kwargs):
|
||||||
style_bits = self.get_style_bits(**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
|
# split into groups with consecutive numbers
|
||||||
groups = np.split(w, np.where(np.diff(w) != 1)[0] + 1)
|
groups = np.split(w, np.where(np.diff(w) != 1)[0] + 1)
|
||||||
ranges = []
|
ranges = []
|
||||||
|
Loading…
Reference in New Issue
Block a user