Return a list of 2-tuples consisting of key/score.
498208
def as_items(self, decode=False):
        
        items = self.database.zrange(self.key, 0, -1, withscores=True)
        if decode:
            items = [(_decode(k), score) for k, score in items]
        return items
405847
def recursive_asdict(d):
    """"""
    out = {}
    for k, v in asdict(d).iteritems():
        if hasattr(v, '__keylist__'):
            out[k] = recursive_asdict(v)
        elif isinstance(v, list):
            out[k] = []
            for item in v:
                if hasattr(item, '__keylist__'):
                    out[k].append(recursive_asdict(item))
                else:
                    out[k].append(item)
        else:
            out[k] = v
    return out
175500
def C_dict2array(C):
    """"""
    return np.hstack([np.asarray(C[k]).ravel() for k in C_keys])
1110358
def _dict_subset(keys, master_dict):
    '''
    
    '''
    return dict([(k, v) for k, v in six.iteritems(master_dict) if k in keys])
358616
def items(self):
        """"""
        return list(zip((self.scalars + self.sections), list(self.values())))
166016
def keys(self):
        """"""
        result = []
        if self.fresh_index is not None:
            result += self.fresh_index.keys()
        if self.opt_index is not None:
            result += self.opt_index.keys()
        return result
1366462
def group_by_key_impl(sequence):
    
    result = {}
    for element in sequence:
        if result.get(element[0]):
            result.get(element[0]).append(element[1])
        else:
            result[element[0]] = [element[1]]
    return six.viewitems(result)
934502
def keys(self):
		
		if hasattr(self._nodes, 'iterkeys'):
			return self._nodes.keys()
		else:
			return tuple(self._nodes.keys())
364562
def combined_dict(*dicts):
  """"""
  return {k: v for d in dicts for k, v in d.items()}
1032936
def filter(self, scored_list):
        '''
        

        '''
        top_n_key = -1 * self.top_n
        top_n_list = sorted(scored_list, key=lambda x: x[1])[top_n_key:]
        result_list = sorted(top_n_list, key=lambda x: x[0])
        return result_list
197255
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self, 'min') and self.min is not None:
            _dict['min'] = self.min
        if hasattr(self, 'max') and self.max is not None:
            _dict['max'] = self.max
        if hasattr(self, 'score') and self.score is not None:
            _dict['score'] = self.score
        return _dict
1029756
def list2dict(list_of_options):
    """"""
    d = {}
    for key, value in list_of_options:
        d[key] = value
    return d
242351
def args_as_tuple(self):
        """"""
        result = ("currentdate", )
        result += (
            ":zone",
            self.extra_arguments["zone"].strip('"'),
            self.arguments["match-type"],
        )
        if self.arguments["match-type"] in [":count", ":value"]:
            result += (self.extra_arguments["match-type"].strip('"'), )
        result += (self.arguments["date-part"].strip('"'), )
        value = self.arguments["key-list"]
        if isinstance(value, list):
            # FIXME
            value = "[{}]".format(
                ",".join('"{}"'.format(item) for item in value))
        if value.startswith("["):
            result = result + tuple(tools.to_list(value))
        else:
            result = result + (value.strip('"'),)
        return result
651891
def zset_score_pairs(response, **options):
    
    if not response or not options.get('withscores'):
        return response
    score_cast_func = options.get('score_cast_func', float)
    it = iter(response)
    return list(izip(it, imap(score_cast_func, it)))
659519
def iteritems(self):
        ''''''
        for x in range(len(self.keys)):
            yield (self.keys[x], self.values[x])
261613
def nearest_keys(self, key):
        """"""
        if not isinstance(key, tuple):
            _key = (key,)
        if self.__stale:
            self.generate_tree()
        d, idx = self.__tree.query(
            _key, self.k_neighbors, distance_upper_bound=self.distance_upper_bound)

        try:
            return [self.__keys[id][0] for id in idx if id < len(self.__keys)]
        except TypeError:
            # if k_neighbors = 1 query is not returnng arrays
            return self.__keys[idx]
444755
def _aggregrate_scores(its,tss,num_sentences):
    """"""
    final = []
    for i,el in enumerate(its):
        for j, le in enumerate(tss):
            if el[2] == le[2]:
                assert el[1] == le[1]
                final.append((el[1],i+j,el[2]))
    _final = sorted(final, key = lambda tup: tup[1])[:num_sentences]
    return sorted(_final, key = lambda tup: tup[0])