def _intersect_1d(breaks):
 start = 0
 last_end = 0
 old_idx = 0
 ret = []
 ret_next = []
 for idx in range(1, len(breaks)):
  (label, br) = breaks[idx]
  (last_label, last_br) = breaks[(idx - 1)]
  if (last_label == 'n'):
   if ret_next:
    ret.append(ret_next)
    ret_next = []
  if (last_label == 'o'):
   start = 0
  else:
   start = last_end
  end = ((br - last_br) + start)
  last_end = end
  if (br == last_br):
   continue
  ret_next.append((old_idx, slice(start, end)))
  if (label == 'o'):
   old_idx += 1
   start = 0
 if ret_next:
  ret.append(ret_next)
 return ret

def _intersect_1d ( breaks ) : start = 0 last_end = 0 old_idx = 0 ret = [ ] ret_next = [ ] for idx in range ( 1 , len ( breaks ) ) : ( label , br ) = breaks [ idx ] ( last_label , last_br ) = breaks [ ( idx - 1 ) ] if ( last_label == 'n' ) : if ret_next : ret . append ( ret_next ) ret_next = [ ] if ( last_label == 'o' ) : start = 0 else : start = last_end end = ( ( br - last_br ) + start ) last_end = end if ( br == last_br ) : continue ret_next . append ( ( old_idx , slice ( start , end ) ) ) if ( label == 'o' ) : old_idx += 1 start = 0 if ret_next : ret . append ( ret_next ) return ret
internal utility to intersect chunks for 1d after preprocessing .