information : NUMBER INFORMATION_UNIT
494482
def p_information_constructor(self, p):
        ''
        logger.debug('information = number %s, information unit %s', p[1], p[2])
        p[0] = Information.from_quantity_unit(p[1], p[2])
1229322
def humanize(number):
    
    # units = ('bytes', 'KB', 'MB', 'GB', 'TB')
    # base = 1000
    units = ('bytes', 'KiB', 'MiB', 'GiB', 'TiB')
    base = 1024
    if number is None:
        return None
    pow = int(math.log(number, base)) if number > 0 else 0
    pow = min(pow, len(units) - 1)
    mantissa = number / (base ** pow)
    return "%.4g %s" % (mantissa, units[pow])
638110
def _parse_unit(unit, placement_str):
    
    if not unit:
        return None
    try:
        return int(unit)
    except (TypeError, ValueError):
        msg = 'unit in placement {} must be digit'.format(placement_str)
        raise ValueError(msg.encode('utf-8'))
909782
def info(self):
        

        info = ''

        if self._header is not None:
            if self._header_encoding is None:
                header = ''

                for b in bytearray(self.header):
                    if chr(b) in string.printable:
                        header += chr(b)
                    else:
                        header += '\\x{:02x}'.format(b)
            else:
                header = self.header

            info += 'Header:                  "{}"\n'.format(header)

        if self.execution_start_address is not None:
            info += 'Execution start address: 0x{:08x}\n'.format(
                self.execution_start_address)

        info += 'Data ranges:\n\n'

        for address, data in self._segments:
            minimum_address = address
            size = len(data)
            maximum_address = (minimum_address + size // self.word_size_bytes)
            info += 4 * ' '
            info += '0x{:08x} - 0x{:08x} ({})\n'.format(
                minimum_address,
                maximum_address,
                format_size(size, binary=True))

        return info
890722
def display_unit(self):
        
        if self._display_unit:
            return self._display_unit
        elif self._Q:
            config = Configuration.display.unit_systems
            default_system = Configuration.unit_system
            units = config.systems[default_system]

            self._display_unit = units.get(self._type, self._unit)

            if self._type == "temperature":
                from_unit = "deg" + self._unit.upper()
                to_unit = "deg" + self._display_unit.upper()
            else:
                from_unit = self._unit
                to_unit = self._display_unit

            #print("dv", from_unit, to_unit)
            self._q_unit = self._Q("1 " + from_unit)
            self._q_display = self._Q("1 " + to_unit)
            
            
        return self._display_unit
482458
def _unit(g):
    """"""
    nt_unit_rule = get_any_nt_unit_rule(g)
    while nt_unit_rule:
        g = _remove_unit_rule(g, nt_unit_rule)
        nt_unit_rule = get_any_nt_unit_rule(g)
    return g
548865
def information_content(self):
        
        ic = 0
        for row in self.pwm:
            ic += 2.0 + np.sum([row[x] * log(row[x])/log(2) for x in range(4) if row[x] > 0])
        return ic
40226
def units(cls, scale=1):
        '''
        

        '''
        return [cls(x=scale), cls(y=scale), cls(z=scale)]
660957
def parse_unit(item, group, slash):
    """"""
    surface = item.group(group).replace('.', '')
    power = re.findall(r'\-?[0-9%s]+' % r.SUPERSCRIPTS, surface)

    if power:
        power = [r.UNI_SUPER[i] if i in r.UNI_SUPER else i for i
                 in power]
        power = ''.join(power)
        new_power = (-1 * int(power) if slash else int(power))
        surface = re.sub(r'\^?\-?[0-9%s]+' % r.SUPERSCRIPTS, '', surface)

    elif re.findall(r'\bcubed\b', surface):
        new_power = (-3 if slash else 3)
        surface = re.sub(r'\bcubed\b', '', surface).strip()

    elif re.findall(r'\bsquared\b', surface):
        new_power = (-2 if slash else 2)
        surface = re.sub(r'\bsquared\b', '', surface).strip()

    else:
        new_power = (-1 if slash else 1)

    return surface, new_power
127541
function format(value, unitInfo) {
  const unit = unitInfo.unit;
  const precision = unitInfo.precision || 0;
  let v = 0;
  switch (unit) {
    case 'GB':
      v = value / GB;
      break;
    case 'MB':
      v = value / MB;
      break;
    default:
      v = value;
      break;
  }
  v = parseFloat(Number(v).toFixed(precision));
  return v;
}
959952
def get_unit(item, text):
    """"""
    group_units = [1, 4, 6, 8, 10]
    group_operators = [3, 5, 7, 9]

    item_units = [item.group(i) for i in group_units if item.group(i)]

    if len(item_units) == 0:
        unit = l.NAMES['dimensionless']
    else:
        dimensions, slash = [], False
        for group in sorted(group_units + group_operators):
            if not item.group(group):
                continue
            if group in group_units:
                surface, power = parse_unit(item, group, slash)
                if clf.USE_CLF:
                    base = clf.disambiguate_unit(surface, text).name
                else:
                    base = l.UNITS[surface][0].name
                dimensions += [{'base': base, 'power': power}]
            elif not slash:
                slash = any(i in item.group(group) for i in [u'/', u' per '])

        unit = get_unit_from_dimensions(dimensions, text)

    logging.debug(u'\tUnit: %s', unit)
    logging.debug(u'\tEntity: %s', unit.entity)

    return unit
407958
function getMemoryUsage(unitInfo) {
  const data = process.memoryUsage();
  const keys = Object.keys(data);
  const result = {};
  keys.forEach((key) => {
    result[key] = format(data[key], unitInfo);
  });
  return result;
}
983775
def getAnalogType(self,num):
        
        listidx = self.An.index(num)
        unit = self.uu[listidx]

        if unit == 'kV' or unit == 'V':
            return 'V'
        elif unit == 'A' or unit == 'kA':
            return 'I'
        else:
            print 'Unknown channel type'
            return 0
576546
def print_series_info(self, series_info, minimal_series_number=1):
        
        strinfo = ''
        if len(series_info) > minimal_series_number:
            for serie_number in series_info.keys():
                strl = get_one_serie_info(series_info, serie_number)
                strinfo = strinfo + strl + '\n'
                # rint strl

        return strinfo
1044488
def number(self) -> Optional[Union[str, Set[str]]]:
        """"""
        if "number" not in self.data.columns:
            return None
        if all(self.data.number.isna()):
            return None
        tmp = set(self.data.number)
        if len(tmp) == 1:
            return tmp.pop()
        logging.warn("Several numbers for one flight, consider splitting")
        return tmp
839083
def format_sizeof(num, suffix='bytes'):
    ''''''
    for unit in ['','K','M','G','T','P','E','Z']:
        if abs(num) < 1000.0:
            return "%3.1f%s%s" % (num, unit, suffix)
        num /= 1000.0
    return "%.1f%s%s" % (num, 'Y', suffix)
728265
def get_sn(unit):
    
    sn = 0
    match_re = re.findall(str(sentence_delimiters), unit)
    if match_re:
        string = ''.join(match_re)
        sn = len(string)
    return int(sn)