convert #RRGGBB to an (R, G, B) tuple
187067
def html_to_rgb(colorstring):
    
    colorstring = colorstring.strip()
    if colorstring[0] == '#':
        colorstring = colorstring[1:]

    if len(colorstring) != 6:
        raise ValueError("input #%s is not in #RRGGBB format" % colorstring)

    r, g, b = colorstring[:2], colorstring[2:4], colorstring[4:]
    r, g, b = [int(n, 16) for n in (r, g, b)]

    return (r, g, b, 255)
994112
def colorRGB(r, g, b):
        
        return (float(r / 255), float(g / 255), float(b / 255))
410819
def ver_to_tuple(value):
    
    return tuple(int(_f) for _f in re.split(r'\D+', value) if _f)
242243
def _bin(g):
    """"""
    new_rules = []
    for rule in g.rules:
        if len(rule.rhs) > 2:
            new_rules += _split(rule)
        else:
            new_rules.append(rule)
    return Grammar(new_rules)
341016
def matchiter(r, s, flags=0):
    
    if isinstance(r, basestring):
        r = re.compile(r, flags)
    i = 0
    while s:
        m = r.match(s)
        g = m and m.group(0)
        if not m or not g:
            raise ValueError("{}: {!r}".format(i, s[:50]))
        i += len(g)
        s = s[len(g):]
        yield m
621081
function rstr2binb(input) {
    var i, l = input.length * 8,
      output = Array(input.length >> 2),
      lo = output.length;
    for (i = 0; i < lo; i += 1) {
      output[i] = 0;
    }
    for (i = 0; i < l; i += 8) {
      output[i >> 5] |= (input.charCodeAt(i / 8) & 0xFF) << (24 - i % 32);
    }
    return output;
  }
242898
def parse_vtrgb(path='/etc/vtrgb'):
    '''  '''
    palette = ()
    table = []
    try:
        with open(path) as infile:
            for i, line in enumerate(infile):
                row = tuple(int(val) for val in line.split(','))
                table.append(row)
                if i == 2:  # failsafe
                    break

        palette = tuple(zip(*table))  # swap rows to columns

    except IOError as err:
        palette = color_tables.vga_palette4

    return palette
856325
public static final String toBrowserRGB(final int r, final int g, final int b)
    {
        return "rgb(" + fixRGB(r) + "," + fixRGB(g) + "," + fixRGB(b) + ")";
    }
1043452
def try_rgb(s, default=None):
    
    if not s:
        return default
    try:
        r, g, b = (int(x.strip()) for x in s.split(','))
    except ValueError:
        raise InvalidRgb(s)
    if not all(in_range(x, 0, 255) for x in (r, g, b)):
        raise InvalidRgb(s)

    return r, g, b
1176765
def value2rgba(x:float, cmap:Callable=cm.RdYlGn, alpha_mult:float=1.0)->Tuple:
    ""
    c = cmap(x)
    rgb = (np.array(c[:-1]) * 255).astype(int)
    a = c[-1] * alpha_mult
    return tuple(rgb.tolist() + [a])
277183
def rs_generator_poly_all(max_nsym, fcr=0, generator=2):
    ''''''
    g_all = {}
    g_all[0] = g_all[1] = [1]
    for nsym in xrange(max_nsym):
        g_all[nsym] = rs_generator_poly(nsym, fcr, generator)
    return g_all
708813
def rmap(fn, coll, is_iterable=None):
    
    result = []
    for x in coll:
        if is_iterable is None:
            is_iterable = isiterable

        if is_iterable(x):
            y = rmap(fn, x)
        else:
            y = fn(x)
        result.append(y)
    return result
713502
public static Vector4f fromIntRGBA(int r, int g, int b, int a) {
        return new Vector4f((r & 0xff) / 255f, (g & 0xff) / 255f, (b & 0xff) / 255f, (a & 0xff) / 255f);
    }
940582
def HTMLColorToRGB(colorstring):
    
    colorstring = colorstring.strip()
    if colorstring[0] == '#':
        colorstring = colorstring[1:]
    if len(colorstring) != 6:
        raise ValueError(
            "input #{0} is not in #RRGGBB format".format(colorstring))
    r, g, b = colorstring[:2], colorstring[2:4], colorstring[4:]
    r, g, b = [int(n, 16) for n in (r, g, b)]
    return (r, g, b)
357787
def _conv_general_shape_tuple(self, lhs_shape, rhs_shape, window_strides,
                                padding, dimension_numbers):
    """"""
    lhs_perm, rhs_perm, out_perm = self._conv_general_permutations(
        dimension_numbers)
    lhs_trans = onp.take(lhs_shape, lhs_perm)
    rhs_trans = onp.take(rhs_shape, rhs_perm)
    out_trans = self._conv_shape_tuple(
        lhs_trans, rhs_trans, window_strides, padding)
    return tuple(onp.take(out_trans, onp.argsort(out_perm)))
159794
def from_string(cls, rgb_hex_str):
        
        r = int(rgb_hex_str[:2], 16)
        g = int(rgb_hex_str[2:4], 16)
        b = int(rgb_hex_str[4:], 16)
        return cls(r, g, b)
1034959
def set_bg(self, r, g, b):
        
        self.img_bg = (r, g, b)
        self.redraw(whence=0)