Safe get multiple indices, translate keys for
        datelike to underlying repr.
170661
def _get_indices(self, names):
        

        def get_converter(s):
            # possibly convert to the actual key types
            # in the indices, could be a Timestamp or a np.datetime64
            if isinstance(s, (Timestamp, datetime.datetime)):
                return lambda key: Timestamp(key)
            elif isinstance(s, np.datetime64):
                return lambda key: Timestamp(key).asm8
            else:
                return lambda key: key

        if len(names) == 0:
            return []

        if len(self.indices) > 0:
            index_sample = next(iter(self.indices))
        else:
            index_sample = None     # Dummy sample

        name_sample = names[0]
        if isinstance(index_sample, tuple):
            if not isinstance(name_sample, tuple):
                msg = ("must supply a tuple to get_group with multiple"
                       " grouping keys")
                raise ValueError(msg)
            if not len(name_sample) == len(index_sample):
                try:
                    # If the original grouper was a tuple
                    return [self.indices[name] for name in names]
                except KeyError:
                    # turns out it wasn't a tuple
                    msg = ("must supply a same-length tuple to get_group"
                           " with multiple grouping keys")
                    raise ValueError(msg)

            converters = [get_converter(s) for s in index_sample]
            names = (tuple(f(n) for f, n in zip(converters, name))
                     for name in names)

        else:
            converter = get_converter(index_sample)
            names = (converter(name) for name in names)

        return [self.indices.get(name, []) for name in names]
248179
def get_keys_from_value(self, value):
        

        return [key for key, data in self.iteritems() if data == value]
729563
def _try_pydatetime(x):
    
    try:
        # for datetimeindex
        x = [y.isoformat() for y in x.to_pydatetime()]
    except AttributeError:
        pass
    try:
        # for generic series
        x = [y.isoformat() for y in x.dt.to_pydatetime()]
    except AttributeError:
        pass
    return x
1202678
def extract_exdates(component):
    
    dates = []

    exd_prop = component.get('exdate')
    if exd_prop:
        if isinstance(exd_prop, list): # In case there is more than one exdate property
            for exd_list in exd_prop:
                dates.extend(normalize(exd.dt) for exd in exd_list.dts)
        elif isinstance(exd_prop, vDDDLists):
            dates.extend(normalize(exd.dt) for exd in exd_prop.dts)

    return dates
180425
def _convert_key(self, key, is_setter=False):
        

        # allow arbitrary setting
        if is_setter:
            return list(key)

        for ax, i in zip(self.obj.axes, key):
            if ax.is_integer():
                if not is_integer(i):
                    raise ValueError("At based indexing on an integer index "
                                     "can only have integer indexers")
            else:
                if is_integer(i) and not ax.holds_integer():
                    raise ValueError("At based indexing on an non-integer "
                                     "index can only have non-integer "
                                     "indexers")
        return key
800708
def extractDate(self, inp):
        """"""
        dates = self.extractDates(inp)
        for date in dates:
            return date
        return None
950201
def de_rep(fastas, append_index, return_original = False):
    
    ids = []
    for fasta in fastas:
        for seq in parse_fasta(fasta):
            header = seq[0].split('>')[1].split()
            id = header[0]
            if id not in ids:
                ids.append(id)
                if return_original is True:
                    yield [header, seq]
                else:
                    yield seq
            elif append_index == True:
                new, ids = append_index_id(id, ids) 
                if return_original is True:
                    yield [header, ['>%s %s' % (new, ' '.join(header[1::])), seq[1]]]
                else:
                    yield ['>%s %s' % (new, ' '.join(header[1::])), seq[1]]
674298
def [] *key
      return slice(*key) if key.size != 1
      key = key[0]
      case key
      when Numeric
        key
      when DateTime
        Helper.find_index_of_date(@data, key)
      when Range
        # FIXME: get_by_range is suspiciously close to just #slice,
        #   but one of specs fails when replacing it with just slice
        get_by_range(key.first, key.last)
      else
        raise ArgumentError, "Key #{key} is out of bounds" if
          Helper.key_out_of_bounds?(key, @data)

        slice(*Helper.find_date_string_bounds(key))
      end
    end
1364584
def reprsig(fun, name=None, method=False):
    """"""
    args, varargs, keywords, defs, kwargs = [], [], None, [], {}
    argspec = fun
    if callable(fun):
        name = fun.__name__ if name is None else name
        argspec = getargspec(fun)
    try:
        args = argspec[0]
        varargs = argspec[1]
        keywords = argspec[2]
        defs = argspec[3]
    except IndexError:
        pass
    if defs:
        args, kwkeys = args[:-len(defs)], args[-len(defs):]
        kwargs = dict(zip(kwkeys, defs))
    if varargs:
        args.append('*' + varargs)
    if method:
        args.insert(0, 'self')
    return reprcall(name, map(str, args), kwargs, keywords,
                    argfilter=str)
1233611
def getyrdoy(date):
    """"""

    try:
        doy = date.toordinal()-datetime(date.year,1,1).toordinal()+1
    except AttributeError:
        raise AttributeError("Must supply a pandas datetime object or " +
                             "equivalent")
    else:
        return date.year, doy
902536
def extract_keypairs(lines, regexer):
    """"""
    updates = {}
    for line in lines:
        # for consistency we must match the replacer and strip whitespace / newlines
        match = regexer.match(line.strip())
        if not match:
            continue
        k_v = match.groupdict()
        updates[k_v[Constants.KEY_GROUP]] = k_v[Constants.VALUE_GROUP]
    return updates
385046
def _keys_via_value_nonrecur(d,v):
    '''
        
    '''
    rslt = []
    for key in d:
        if(d[key] == v):
            rslt.append(key)
    return(rslt)
456237
def proper_repr(value: Any) -> str:
    """"""

    if isinstance(value, sympy.Basic):
        result = sympy.srepr(value)

        # HACK: work around https://github.com/sympy/sympy/issues/16074
        # (only handles a few cases)
        fixed_tokens = [
            'Symbol', 'pi', 'Mul', 'Add', 'Mod', 'Integer', 'Float', 'Rational'
        ]
        for token in fixed_tokens:
            result = result.replace(token, 'sympy.' + token)

        return result

    if isinstance(value, np.ndarray):
        return 'np.array({!r})'.format(value.tolist())
    return repr(value)
682945
def keys(self, namespace, prefix=None, limit=None, offset=None):
        """"""
        params = [namespace]
        query = 'SELECT key FROM gauged_keys WHERE namespace = %s'
        if prefix is not None:
            query += ' AND key LIKE %s'
            params.append(prefix + '%')
        if limit is not None:
            query += ' LIMIT %s'
            params.append(limit)
        if offset is not None:
            query += ' OFFSET %s'
            params.append(offset)
        cursor = self.cursor
        cursor.execute(query, params)
        return [key for key, in cursor]
874838
private Set<Comparable> prepareKeys(OIndex<?> index, Object keys) {
    final Class<?> targetType = index.getKeyTypes()[0].getDefaultJavaType();

    return convertResult(keys, targetType);
  }
553494
def safe_repr(source, max_length=0):
    """"""
    try:
        return ellipsis(repr(source), max_length)
    except Exception as e:
        return ellipsis("<n/a: repr(...) raised %s>" % e, max_length)
1067604
def _to_desired_dates(self, arr):
        """"""
        times = utils.times.extract_months(
            arr[internal_names.TIME_STR], self.months
        )
        return arr.sel(time=times)