input: unscaled sections.
  returns: sections scaled to [0, 255]
508395
def scale_sections(sections, scaling_scope):
  '''
  
  '''
  new_sections = []

  if scaling_scope == 'layer':
    for section in sections:
      new_sections.append(scale_image_for_display(section))

  elif scaling_scope == 'network':
    global_min, global_max = global_extrema(sections)

    for section in sections:
      new_sections.append(scale_image_for_display(section,
                                                  global_min,
                                                  global_max))
  return new_sections
612284
def unmarshall(self, cls):
        
        for k, v in self.all_settings().items():
            setattr(cls, k, v)

        return cls
678859
def _scaled_int(s):
    """
    s = bytearray(s)  # For Python 2

    # Get leftmost bit (sign) as 1 (if 0) or -1 (if 1)
    sign = 1 - ((s[0] & 0x80) >> 6)

    # Combine remaining bits
    int_val = (((s[0] & 0x7f) << 16) | (s[1] << 8) | s[2])
    log.debug('Source: %s Int: %x Sign: %d', ' '.join(hex(c) for c in s), int_val, sign)

    # Return scaled and with proper sign
    return (sign * int_val) / 10000.
607392
def section(self, section, skip=['type', 'order']):
        
        return [(key, val) for key, val in self.parser.items(section)
                if key not in skip]
779385
def unmapped(sam, mates):
    
    for read in sam:
        if read.startswith('@') is True:
            continue
        read = read.strip().split()
        if read[2] == '*' and read[6] == '*':
                yield read
        elif mates is True:
            if read[2] == '*' or read[6] == '*':
                yield read
            for i in read:
                if i == 'YT:Z:UP':
                    yield read
1231409
def chunked(data, chunksize):
    
    if chunksize < 1:
        raise ValueError("Chunksize must be at least 1!")
    if int(chunksize) != chunksize:
        raise ValueError("Chunksize needs to be an integer")
    res = []
    cur = []
    for e in data:
        cur.append(e)
        if len(cur) >= chunksize:
            res.append(cur)
            cur = []
    if cur:
        res.append(cur)
    return res
873538
def _sections_to_variance_sections(self, sections_over_time):
    '''
    '''
    variance_sections = []

    for i in range(len(sections_over_time[0])):
      time_sections = [sections[i] for sections in sections_over_time]
      variance = np.var(time_sections, axis=0)
      variance_sections.append(variance)

    return variance_sections
194199
def get_truncatable_str(str_to_convert):
    
    truncated, truncated_byte_count = check_str_length(
        str_to_convert, MAX_LENGTH)

    result = {
        'value': truncated,
        'truncated_byte_count': truncated_byte_count,
    }
    return result
336735
def unfolding(tens, i):
    """"""
    return reshape(tens.full(), (np.prod(tens.n[0:(i+1)]), -1))
533421
def get_sections(self):
        
        try:
            obj_list = self.__dict__['sections']
            return [Section(i) for i in obj_list]
        except KeyError:
            self._lazy_load()
            obj_list = self.__dict__['sections']
            return [Section(i) for i in obj_list]
196485
def _split_section_and_key(key):
    """"""
    parts = key.split('.')
    if len(parts) > 1:
        return 'renku "{0}"'.format(parts[0]), '.'.join(parts[1:])
    return 'renku', key
1033131
def autoscale(self):
        
        # requires matplotlib >= 0.98.0
        (vmin, vmax) = self.axis.get_data_interval()

        locs = self._get_default_locs(vmin, vmax)
        (vmin, vmax) = locs[[0, -1]]
        if vmin == vmax:
            vmin -= 1
            vmax += 1
        return nonsingular(vmin, vmax)
283720
def GetUnscannedSubNode(self):
    
    if not self.sub_nodes and not self.scanned:
      return self

    for sub_node in self.sub_nodes:
      result = sub_node.GetUnscannedSubNode()
      if result:
        return result

    return None
42448
def top_sections(self):
        

        top_line = self.text.split('\n')[0]
        sections = len(top_line.split('+')) - 2

        return sections
368294
def _block_width(self):
        
        section = self.sections[-1]
        return Emu(
            section.page_width - section.left_margin - section.right_margin
        )
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
688076
def sections(self):
    """"""
    if not self._is_parsed:
      self._Parse()
      self._is_parsed = True

    return self._sections