Tag arxiv report numbers

    We handle arXiv in 2 ways:
    * starting with arXiv:1022.1111
    * this format exactly 9999.9999
    We also format the output to the standard arxiv notation:
    * arXiv:2007.12.1111
    * arXiv:2007.12.1111v2
774960
def tag_arxiv(line):
    
    def tagger(match):
        groups = match.groupdict()
        if match.group('suffix'):
            groups['suffix'] = ' ' + groups['suffix']
        else:
            groups['suffix'] = ''
        return u'<cds.REPORTNUMBER>arXiv:%(year)s'\
            u'%(month)s.%(num)s%(suffix)s' \
            u'</cds.REPORTNUMBER>' % groups

    line = re_arxiv_5digits.sub(tagger, line)
    line = re_arxiv.sub(tagger, line)
    line = re_new_arxiv_5digits.sub(tagger, line)
    line = re_new_arxiv.sub(tagger, line)
    return line
1370367
def to_h(num, suffix='B'):
    """"""
    if num is None:  # Show None when data is missing
        return "None"
    for unit in ['', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi']:
        if abs(num) < 1024.0:
            return "%3.1f%s%s" % (num, unit, suffix)
        num /= 1024.0
    return "%.1f%s%s" % (num, 'Yi', suffix)
635512
def _sane_version_list(version):
    
    v0 = str(version[0])
    if v0:
        # Test if the major is a number.
        try:
            v0 = v0.lstrip("v").lstrip("V")
            # Handle the common case where tags have v before major.
            v0 = int(v0)
        except ValueError:
            v0 = None

    if v0 is None:
        version = [0, 0] + version
    else:
        version[0] = v0

    try:
        # Test if the minor is a number.
        version[1] = int(version[1])
    except ValueError:
        # Insert Minor 0.
        version = [version[0], 0] + version[1:]

    return version
1012663
function formatNumber(value, options) {
    options = options || {};
    value += ''; // must be String Type

    // not a number !!
    if (!__isNumber(value)) {
        return false;
    }

    var valueArr = __splitValue(value),
        integer = valueArr[0],
        negative = integer < 0,
        absInteger = Math.abs(integer) + '',
        formattedValue;

    if (options.reduce) {
        if (absInteger >= 100000 && absInteger <= 999999) {
            options.prefix = 'k' + options.prefix;
            integer = integer.slice(0, -3);
        } else if (absInteger > 999999 && absInteger <= 9999999) {
            options.prefix = 'Mio ' + options.prefix;
            integer = negative ? '-' + absInteger[0] + ',' + absInteger[1] : absInteger[0] + ',' + absInteger[1];
        } else if (absInteger > 9999999 && absInteger <= 999999999) {
            options.prefix = 'Mio ' + options.prefix;
            integer = integer.slice(0, -6);
        } else if (absInteger > 999999999 && absInteger <= 9999999999) {
            options.prefix = 'Mrd ' + options.prefix;
            integer = integer.slice(0, -8);
            integer = negative ? '-' + absInteger[0] + ',' + absInteger[1] : absInteger[0] + ',' + absInteger[1];
        } else if (absInteger > 9999999999) {
            options.prefix = 'Mrd ' + options.prefix;
            integer = integer.slice(0, -9);
        }

        // add spaces
        formattedValue = __addSpacesSeparator(integer);
    } else {
        // add spaces
        valueArr[0] = __addSpacesSeparator(integer);
        formattedValue = valueArr.join(',');
    }

    if (options.prefix) {
        formattedValue += ' ' + options.prefix;
    }

    return formattedValue;
}
1205757
def t_NUMBER(t):
    '
    exponents = {
            'G' : 30, 'g' : 30,
            'M' : 20, 'm' : 20,
            'K' : 10, 'k' : 10,
            }
    if t.value[-1] in exponents:
        t.value = math.ldexp(int(t.value[:-1]), exponents[t.value[-1]])
    else:
        t.value = int(t.value)
    return t
1196857
def form_number(self):
		
		k1, o1, m2, s2 = (
			np.extract(self.model['constituent'] == c, self.model['amplitude'])
			for c in [constituent._K1, constituent._O1, constituent._M2, constituent._S2]
		)
		return (k1+o1)/(m2+s2)
330557
def format_version(epoch, version, release):
    '''
    
    '''
    full_version = '{0}:{1}'.format(epoch, version) if epoch else version
    if release:
        full_version += '-{0}'.format(release)
    return full_version
387688
def t_NUMBER(self, t):
        '
        if re.match(r'^(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?(kb|gb|mb|tb|pb|Kb|Gb|Mb|Tb|Pb)?$',t.value):
            multiplyer = 1
            try:
                suffix = (t.value[-2:]).lower()
                if suffix in ['kb']:
                    multiplyer = 1024
                elif suffix in ['mb']:
                    multiplyer = 1024*1024
                elif suffix in ['gb']:
                    multiplyer = 1024*1024*1024
                elif suffix in ['tb']:
                    multiplyer = 1024*1024*1024*1024
                elif suffix in ['pb']:
                    multiplyer = 1024*1024*1024*1024*1024
                
                if multiplyer > 1:
                    t.value = t.value[:-2]
            except:
                pass
            
            try:
                f = float(t.value)
                try:
                    e = int(t.value)
                except ValueError:
                    e = f
                    
                if (e == f):
                    t.value = multiplyer*e
                else:
                    t.value = multiplyer*f
            except ValueError:
                _LOGGER.error("el valor %s no es un numero valido" % t.value)
                t.value = 0
        else:
            t.type = 'STRING'
            
        return t
542614
def is_arxiv(obj):
    """"""
    arxiv_test = obj.split()
    if not arxiv_test:
        return False

    matched_arxiv = (RE_ARXIV_PRE_2007_CLASS.match(arxiv_test[0]) or
                     RE_ARXIV_POST_2007_CLASS.match(arxiv_test[0]))

    if not matched_arxiv:
        return False

    if not matched_arxiv.group('category'):
        return True

    valid_arxiv_categories_lower = [category.lower() for category in valid_arxiv_categories()]
    category = matched_arxiv.group('category').lower()
    return (category in valid_arxiv_categories_lower or
            category.replace('-', '.') in valid_arxiv_categories_lower)
402811
def prepare_num_formats #:nodoc:
      num_formats      = {}
      index            = 164
      num_format_count = 0

      (@xf_formats + @dxf_formats).each do |format|
        num_format = format.num_format

        # Check if num_format is an index to a built-in number format.
        # Also check for a string of zeros, which is a valid number format
        # string but would evaluate to zero.
        #
        if num_format.to_s =~ /^\d+$/ && num_format.to_s !~ /^0+\d/
          # Index to a built-in number format.
          format.num_format_index = num_format
          next
        end

        if num_formats[num_format]
          # Number format has already been used.
          format.num_format_index = num_formats[num_format]
        else
          # Add a new number format.
          num_formats[num_format] = index
          format.num_format_index = index
          index += 1

          # Only increase font count for XF formats (not for DXF formats).
          num_format_count += 1 if ptrue?(format.xf_index)
        end
      end

      @num_format_count = num_format_count
    end
495467
def _compare_versions(v1, v2):
    
    def normalize(v):
        # strip trailing .0 or .00 or .0.0 or ...
        v = re.sub(r'(\.0+)*$', '', v)
        result = []
        for part in v.split('.'):
            # just digits
            m = re.match(r'^(\d+)$', part)
            if m:
                result.append(int(m.group(1)))
                continue
            # digits letters
            m = re.match(r'^(\d+)([a-zA-Z]+)$', part)
            if m:
                result.append(int(m.group(1)))
                result.append(m.group(2))
                continue
            # digits letters digits
            m = re.match(r'^(\d+)([a-zA-Z]+)(\d+)$', part)
            if m:
                result.append(int(m.group(1)))
                result.append(m.group(2))
                result.append(int(m.group(3)))
                continue
        return tuple(result)

    n1 = normalize(v1)
    n2 = normalize(v2)

    return (n1 > n2) - (n1 < n2)
1123562
def prog_version():
    
    print("Version   : {0}\n"
          "Licence   : {1}\n"
          "Email     : {2}\n"
          "Maintainer: {3}".format(_meta_.__version__,
                                   _meta_.__license__,
                                   _meta_.__email__,
                                   _meta_.__maintainer__))
1027018
def _suffix(self):
        """"""
        _output_formats={'GCG':'.msf',
                        'GDE':'.gde',
                        'PHYLIP':'.phy',
                        'PIR':'.pir',
                        'NEXUS':'.nxs'}

        if self.Parameters['-output'].isOn():
            return _output_formats[self.Parameters['-output'].Value]
        else:
            return '.aln'
1088625
def number_to_dp(number: Optional[float],
                 dp: int,
                 default: Optional[str] = "",
                 en_dash_for_minus: bool = True) -> str:
    
    if number is None:
        return default
    if number == float("inf"):
        return u"∞"
    if number == float("-inf"):
        s = u"-∞"
    else:
        s = u"{:.{precision}f}".format(number, precision=dp)
    if en_dash_for_minus:
        s = s.replace("-", u"–")  # hyphen becomes en dash for minus sign
    return s
617980
def t_NUMBER(t):
    # This pattern must come AFTER t_HEXA and t_BIN
    '
    t.text = t.value
    t.value = float(t.value)

    if t.value == int(t.value) and is_label(t):
        t.value = int(t.value)
        t.type = 'LABEL'

    return t
989213
def numeric
      if latest?
        1_000_000_000_000_000_000_000_000_000
      elsif semantic?
        # This assumes each counter will never go > 1000
        if development?
          self =~ /v?(\d+).(\d+).(\d+).(dev|pre)(\d+)/
          (Regexp.last_match[1].to_i * 1000 * 1000 * 1000) +
            (Regexp.last_match[2].to_i * 1000 * 1000) +
            (Regexp.last_match[3].to_i * 1000) +
            Regexp.last_match[5].to_i
        else
          self =~ /v?(\d+).(\d+).(\d+)/
          (Regexp.last_match[1].to_i * 1000 * 1000 * 1000) +
            (Regexp.last_match[2].to_i * 1000 * 1000) +
            (Regexp.last_match[3].to_i * 1000)
        end
      elsif timestamp?
        to_time.to_i
      else
        validate!
      end
    end
1069859
def number(self, number):
        
        s = [ord(x) for x in str(number)] + [14]  # Bytes of string representation in bytes

        if number == int(number) and abs(number) < 65536:  # integer form?
            sign = 0xFF if number < 0 else 0
            b = [0, sign] + self.numberLH(number) + [0]
        else:  # Float form
            (C, ED, LH) = fp.immediate_float(number)
            C = C[:2]  # Remove 'h'
            ED = ED[:4]  # Remove 'h'
            LH = LH[:4]  # Remove 'h'

            b = [int(C, 16)]  # Convert to BASE 10
            b += [int(ED[:2], 16), int(ED[2:], 16)]
            b += [int(LH[:2], 16), int(LH[2:], 16)]

        return s + b