Convert [(section0, nts0), (section1, nts1), ... to [*nts0, *nts1, ...
173800
def get_sections_flattened(section_nts):
        """"""
        nt_flds = list(section_nts[0][1][0]._fields)
        # Flatten section_nts 2-D list
        if 'section' in nt_flds:
            return [nt for _, nts in section_nts for nt in nts]
        # Flatten section_nts 2-D list, and add sections to each namedtuple
        nt_flds.append('section')
        nts_flat = []
        ntobj = cx.namedtuple("Nt", " ".join(nt_flds))
        for section_name, nts in section_nts:
            for nt_go in nts:
                vals = list(nt_go) + [section_name]
                nts_flat.append(ntobj._make(vals))
        return nts_flat
989449
def _arrays_to_sections(self, arrays):
    '''
    
    '''
    sections = []
    sections_to_resize_later = {}
    show_all = self.config['show_all']
    image_width = self._determine_image_width(arrays, show_all)

    for array_number, array in enumerate(arrays):
      rank = len(array.shape)
      section_height = self._determine_section_height(array, show_all)

      if rank == 1:
        section = np.atleast_2d(array)
      elif rank == 2:
        section = array
      elif rank == 4:
        section = self._reshape_conv_array(array, section_height, image_width)
      else:
        section = self._reshape_irregular_array(array,
                                                section_height,
                                                image_width)
      # Only calculate variance for what we have to. In some cases (biases),
      # the section is larger than the array, so we don't want to calculate
      # variance for the same value over and over - better to resize later.
      # About a 6-7x speedup for a big network with a big variance window.
      section_size = section_height * image_width
      array_size = np.prod(array.shape)

      if section_size > array_size:
        sections.append(section)
        sections_to_resize_later[array_number] = section_height
      else:
        sections.append(im_util.resize(section, section_height, image_width))

    self.sections_over_time.append(sections)

    if self.config['mode'] == 'variance':
      sections = self._sections_to_variance_sections(self.sections_over_time)

    for array_number, height in sections_to_resize_later.items():
      sections[array_number] = im_util.resize(sections[array_number],
                                              height,
                                              image_width)
    return sections
269351
def to_ranges(lst):
    
    for a, b in itertools.groupby(enumerate(lst), lambda t: t[1] - t[0]):
        b = list(b)
        yield b[0][1], b[-1][1]
966894
def translate_section(data):
    
    sect_str = ""
    elements = data.get("Elements", [])
    for elem in elements:
            print("    Translating " + elem["Type"])
            sect_str += translate_map[elem["Type"]](elem)
    return sect_str
1096473
def _convertToElementList(elements_list):
    
    elements = []
    current_element = []
    for node_index in elements_list:
        if node_index == -1:
            elements.append(current_element)
            current_element = []
        else:
            current_element.append(node_index)

    return elements
642557
def per_section(it, is_delimiter=lambda x: x.isspace()):
    
    ret = []
    for line in it:
        if is_delimiter(line):
            if ret:
                yield ret  # OR  ''.join(ret)
                ret = []
        else:
            ret.append(line.rstrip())  # OR  ret.append(line)
    if ret:
        yield ret
663872
def split(self, indices_or_sections, axis=0):
        """"""
        if not isinstance(indices_or_sections, numbers.Integral):
            raise Error('splitting by array of indices is not yet implemented')
        n = indices_or_sections
        if self.shape[axis] % n != 0:
            raise ValueError("Array split doesn't result in an equal division")
        step = self.shape[axis] / n
        pieces = []
        start = 0
        while start < self.shape[axis]:
            stop = start + step
            ix = [slice(None)] * self.ndim
            ix[axis] = slice(start, stop)
            ix = tuple(ix)
            pieces.append(self[ix])
            start += step
        return pieces
293093
def chunk_list(l, n):
    """"""
    return [l[i:i + n] for i in range(0, len(l), n)]
62948
def parse_range_pairs(s, range_separator = '-', convert_to_tuple = True):
    ''' 
    '''
    result = map(sorted,
       map(lambda r:
            (int(r.split(range_separator)[0]), int(r.split(range_separator)[1])) if range_separator in r
            else (int(r), int(r)),
            s.split(',')))
    if convert_to_tuple:
        return tuple(map(tuple, result))
    return result
42391
def _to_seq(sc, cols, converter=None):
    
    if converter:
        cols = [converter(c) for c in cols]
    return sc._jvm.PythonUtils.toSeq(cols)
725817
def chop_sequence(sequence, limit_length):
        
        return [sequence[i:i + limit_length] for i in range(0, len(sequence), limit_length)]
776761
def get_nts_sections(self, sections, sortby=None):
        """"""
        goids = self.get_goids_sections(sections)
        gosubdag = GoSubDag(goids, self.go2obj)
        return [(sec, gosubdag.get_nts(gos, sortby)) for sec, gos in sections]
392802
def split_option(self, section, option):
		
		value = self[section][option].strip()
		if value == "":
			return []
		return [x.strip() for x in (value.split(","))]
567192
def _parse_section(token_iter):
    '''
    '''
    sexp = []
    for token in token_iter:
        if token == '(':
            new_sexp = _parse_section(token_iter)
            if not _match_section(new_sexp, UNWANTED_SECTIONS):
                sexp.append(new_sexp)
        elif token == ')':
            return sexp
        else:
            sexp.append(token)
    return sexp
659841
def chunk_list(list_, size):
    
    ll = len(list_)
    if ll <= size:
        return [list_]
    elif size == 0:
        return list_ # or None ??
    elif size == 1:
        return [[l] for l in list_]
    else:
        chunks = []
        for start, stop in zip(range(0, ll, size), range(size, ll, size)):
            chunks.append(list_[start:stop])
        chunks.append(list_[stop:])  # snag unaligned chunks from last stop
        return chunks
997634
def multi_split(s, split):
    # type: (S, Iterable[S]) -> List[S]
    """"""
    for r in split:
        s = s.replace(r, "|")
    return [i for i in s.split("|") if len(i) > 0]
356792
def _split_keys_v1(joined):
    
    left, _, right = joined.partition('::')
    return _decode_v1(left), _decode_v1(right)