sequence
stringlengths
492
15.9k
code
stringlengths
75
8.58k
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_get_paths_for_status; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:status; 6, block; 6, 7; 6, 16; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 13; 9, pattern_list; 9, 10; 9, 11; 9, 12; 10, identifier:added; 11, identi...
def _get_paths_for_status(self, status): added, modified, deleted = self._changes_cache return sorted({ 'added': list(added), 'modified': list(modified), 'deleted': list(deleted)}[status] )
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:sort; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:args; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 22; 10, expression_statement; 10, 11; 11, call; 11, 12; 11,...
def sort(self, *args, **kwargs): self._list.sort(*args, **kwargs) for index, value in enumerate(self._list): self._dict[value] = index
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:find; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:term; 6, default_parameter; 6, 7; 6, 8; 7, identifier:limit; 8, integer:0; 9, default_parameter; 9, 10; 9, 11; 10, identifier:sort; 11, False; 12, default_pa...
def find(self, term, limit=0, sort=False, ranks=None): ranks = ranks or self.ranks found_indices = [] count = 0 if not limit: for i, card in enumerate(self.cards): if check_term(card, term): found_indices.append(i) else: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:get_list; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:terms; 6, default_parameter; 6, 7; 6, 8; 7, identifier:limit; 8, integer:0; 9, default_parameter; 9, 10; 9, 11; 10, identifier:sort; 11, False; 12, defau...
def get_list(self, terms, limit=0, sort=False, ranks=None): ranks = ranks or self.ranks got_cards = [] try: indices = self.find_list(terms, limit=limit) got_cards = [self.cards[i] for i in indices if self.cards[i] not in got_cards] self.cards =...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:is_sorted; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ranks; 7, None; 8, block; 8, 9; 8, 17; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:ranks; 12, boolean_o...
def is_sorted(self, ranks=None): ranks = ranks or self.ranks return check_sorted(self, ranks)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sort; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ranks; 7, None; 8, block; 8, 9; 8, 17; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:ranks; 12, boolean_operat...
def sort(self, ranks=None): ranks = ranks or self.ranks self.cards = sort_cards(self.cards, ranks)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:canonical_headers; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:headers_to_sign; 6, block; 6, 7; 6, 33; 6, 39; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:l; 10, list_comprehension; 10, 11; 10, 30; 1...
def canonical_headers(self, headers_to_sign): l = ['%s:%s'%(n.lower().strip(), headers_to_sign[n].strip()) for n in headers_to_sign] l.sort() return '\n'.join(l)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:build_cards; 3, parameters; 3, 4; 3, 7; 4, default_parameter; 4, 5; 4, 6; 5, identifier:jokers; 6, False; 7, default_parameter; 7, 8; 7, 9; 8, identifier:num_jokers; 9, integer:0; 10, block; 10, 11; 10, 15; 10, 33; 10, 48; 11, expression_state...
def build_cards(jokers=False, num_jokers=0): new_deck = [] if jokers: new_deck += [Card("Joker", None) for i in xrange(num_jokers)] new_deck += [Card(value, suit) for value in VALUES for suit in SUITS] return new_deck
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:check_sorted; 3, parameters; 3, 4; 3, 5; 4, identifier:cards; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ranks; 7, None; 8, block; 8, 9; 8, 15; 8, 23; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:ranks; 12...
def check_sorted(cards, ranks=None): ranks = ranks or DEFAULT_RANKS sorted_cards = sort_cards(cards, ranks) if cards == sorted_cards or cards[::-1] == sorted_cards: return True else: return False
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:sort_card_indices; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:cards; 5, identifier:indices; 6, default_parameter; 6, 7; 6, 8; 7, identifier:ranks; 8, None; 9, block; 9, 10; 9, 16; 9, 54; 9, 83; 10, expression_statement; 10, 11; 11, assignme...
def sort_card_indices(cards, indices, ranks=None): ranks = ranks or DEFAULT_RANKS if ranks.get("suits"): indices = sorted( indices, key=lambda x: ranks["suits"][cards[x].suit] if cards[x].suit != None else 0 ) if ranks.get("values"): indices = ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sort_cards; 3, parameters; 3, 4; 3, 5; 4, identifier:cards; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ranks; 7, None; 8, block; 8, 9; 8, 15; 8, 49; 8, 76; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:rank...
def sort_cards(cards, ranks=None): ranks = ranks or DEFAULT_RANKS if ranks.get("suits"): cards = sorted( cards, key=lambda x: ranks["suits"][x.suit] if x.suit != None else 0 ) if ranks.get("values"): cards = sorted( cards, key=lambda x:...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:key; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:frame; 6, block; 6, 7; 6, 9; 6, 32; 6, 54; 6, 91; 6, 115; 7, expression_statement; 7, 8; 8, string:"Return the sort key for the given frame."; 9, function_definition; 9, 10; 9, 1...
def key(self, frame): "Return the sort key for the given frame." def keytuple(primary): if frame.frameno is None: return (primary, 1) return (primary, 0, frame.frameno) if type(frame) in self.frame_keys: return keytuple(self.frame_keys[type(fra...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:frames; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:key; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:orig_order; 10, False; 11, block; 11, 12; 11, 54; 11, 58; 11, 83; 11, 1...
def frames(self, key=None, orig_order=False): if key is not None: key = self._normalize_key(key) if len(self._frames[key]) == 0: raise KeyError("Key not found: " + repr(key)) return self._frames[key] frames = [] for frameid in self._frames.keys...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:detach; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:force; 7, False; 8, block; 8, 9; 8, 13; 8, 26; 8, 30; 8, 43; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:i...
def detach(self, force=False): instance_id = None if self.attach_data: instance_id = self.attach_data.instance_id device = None if self.attach_data: device = self.attach_data.device return self.connection.detach_volume(self.id, instance_id, device, force)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:make_node_dict; 3, parameters; 3, 4; 3, 5; 4, identifier:outer_list; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort; 7, string:"zone"; 8, block; 8, 9; 8, 13; 8, 17; 8, 35; 8, 115; 8, 119; 8, 123; 8, 143; 9, expression_statement; 9, 10; 10...
def make_node_dict(outer_list, sort="zone"): raw_dict = {} x = 1 for inner_list in outer_list: for node in inner_list: raw_dict[x] = node x += 1 if sort == "name": srt_dict = OrderedDict(sorted(raw_dict.items(), key=lambda k: (k[1].c...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:crack; 3, parameters; 3, 4; 3, 5; 3, 7; 3, 10; 4, identifier:ciphertext; 5, list_splat_pattern; 5, 6; 6, identifier:fitness_functions; 7, default_parameter; 7, 8; 7, 9; 8, identifier:ntrials; 9, integer:30; 10, default_parameter; 10, 11; 10, 1...
def crack(ciphertext, *fitness_functions, ntrials=30, nswaps=3000): if ntrials <= 0 or nswaps <= 0: raise ValueError("ntrials and nswaps must be positive integers") def next_node_inner_climb(node): a, b = random.sample(range(len(node)), 2) node[a], node[b] = node[b], node[a] plai...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:key_periods; 3, parameters; 3, 4; 3, 5; 4, identifier:ciphertext; 5, identifier:max_key_period; 6, block; 6, 7; 6, 17; 6, 21; 6, 64; 7, if_statement; 7, 8; 7, 11; 8, comparison_operator:<=; 8, 9; 8, 10; 9, identifier:max_key_period; 10, integer...
def key_periods(ciphertext, max_key_period): if max_key_period <= 0: raise ValueError("max_key_period must be a positive integer") key_scores = [] for period in range(1, min(max_key_period, len(ciphertext)) + 1): score = abs(ENGLISH_IC - index_of_coincidence(*split_columns(ciphertext, period...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:crack; 3, parameters; 3, 4; 3, 5; 3, 7; 3, 10; 3, 13; 4, identifier:ciphertext; 5, list_splat_pattern; 5, 6; 6, identifier:fitness_functions; 7, default_parameter; 7, 8; 7, 9; 8, identifier:min_key; 9, integer:0; 10, default_parameter; 10, 11;...
def crack(ciphertext, *fitness_functions, min_key=0, max_key=26, shift_function=shift_case_english): if min_key >= max_key: raise ValueError("min_key cannot exceed max_key") decryptions = [] for key in range(min_key, max_key): plaintext = decrypt(key, ciphertext, shift_function=shift_functio...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:get_sort_limit; 3, parameters; 4, block; 4, 5; 4, 20; 4, 30; 5, expression_statement; 5, 6; 6, assignment; 6, 7; 6, 8; 7, identifier:limit; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:_; 11, identifier:convert; 12, argument...
def get_sort_limit(): limit = _.convert(get("sort_limit"), _.to_int) if (limit < 1): limit = None return limit
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:get_sort_on; 3, parameters; 3, 4; 4, default_parameter; 4, 5; 4, 6; 5, identifier:allowed_indexes; 6, None; 7, block; 7, 8; 7, 15; 7, 36; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:sort_on; 11, call; 11, 12; 11, ...
def get_sort_on(allowed_indexes=None): sort_on = get("sort_on") if allowed_indexes and sort_on not in allowed_indexes: logger.warn("Index '{}' is not in allowed_indexes".format(sort_on)) return None return sort_on
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:to_list; 3, parameters; 3, 4; 4, identifier:thing; 5, block; 5, 6; 5, 13; 5, 25; 5, 49; 5, 65; 6, if_statement; 6, 7; 6, 10; 7, comparison_operator:is; 7, 8; 7, 9; 8, identifier:thing; 9, None; 10, block; 10, 11; 11, return_statement; 11, 12; 1...
def to_list(thing): if thing is None: return [] if isinstance(thing, set): return list(thing) if isinstance(thing, types.StringTypes): if thing.startswith("["): return ast.literal_eval(thing) if not (is_list(thing) or is_tuple(thing)): return [thing] retur...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_sort_spec; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 16; 5, 27; 5, 35; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:all_indexes; 9, call; 9, 10; 9, 15; 10, attribute; 10, 11; 10, 14; 11, attribut...
def get_sort_spec(self): all_indexes = self.catalog.get_indexes() si = req.get_sort_on(allowed_indexes=all_indexes) so = req.get_sort_order() return si, so
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:sort_dict; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:data; 6, identifier:key; 7, block; 7, 8; 7, 10; 8, expression_statement; 8, 9; 9, string:'''Sort a list of dictionaries by dictionary key'''; 10, return_statement; 10...
def sort_dict(self, data, key): '''Sort a list of dictionaries by dictionary key''' return sorted(data, key=itemgetter(key)) if data else []
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:load_drops; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:dropin; 6, block; 6, 7; 6, 14; 6, 51; 6, 64; 6, 79; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:obj; 10, call; 10, 11; 10, 12; 11, identifier:...
def load_drops(self, dropin): obj = load_object(dropin) try: drops = getattr(obj, self.drops_type) except AttributeError: try: drops = load_object('%s.%s' % (dropin, self.drops_type)) except ImportError: drops = None if ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:sort_by; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:attr_or_key; 6, default_parameter; 6, 7; 6, 8; 7, identifier:direction; 8, string:'asc'; 9, block; 9, 10; 9, 49; 9, 69; 9, 79; 10, if_statement; 10, 11; 10, 19; 10, 26;...
def sort_by(self, attr_or_key, direction='asc'): if direction in ('+', 'asc', gtk.SORT_ASCENDING): direction = gtk.SORT_ASCENDING elif direction in ('-', 'desc', gtk.SORT_DESCENDING): direction = gtk.SORT_DESCENDING else: raise AttributeError('unrecognised dir...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:load_file; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:filepath; 6, block; 6, 7; 6, 13; 6, 28; 6, 43; 6, 64; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, identi...
def load_file(self, filepath): self.file_path = filepath _, self.file_type = os.path.splitext(filepath) _, self.file_name = os.path.split(filepath) with open(filepath) as ffile: self.file_content = ffile.readlines() return (self._load_funcs[self.file_type]())
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 25; 2, function_name:find; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:limit; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:reverse; 10, False; 11, default_para...
def find(self, limit=None, reverse=False, sort=None, exclude=None, duplicates=True, pretty=False, **filters): if exclude is None: exclude = [] if 'href' not in filters: filters['href'] = True search = self._soup.findAll('a', **filters) if reverse: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:__draw_cmp; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:obj1; 6, identifier:obj2; 7, block; 7, 8; 8, if_statement; 8, 9; 8, 16; 8, 19; 8, 31; 9, comparison_operator:>; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, iden...
def __draw_cmp(self, obj1, obj2): if obj1.draw_order > obj2.draw_order: return 1 elif obj1.draw_order < obj2.draw_order: return -1 else: return 0
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:__up_cmp; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:obj1; 6, identifier:obj2; 7, block; 7, 8; 8, if_statement; 8, 9; 8, 16; 8, 19; 8, 31; 9, comparison_operator:>; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identi...
def __up_cmp(self, obj1, obj2): if obj1.update_order > obj2.update_order: return 1 elif obj1.update_order < obj2.update_order: return -1 else: return 0
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:discover; 3, parameters; 3, 4; 3, 7; 4, default_parameter; 4, 5; 4, 6; 5, identifier:timeout; 6, integer:1; 7, default_parameter; 7, 8; 7, 9; 8, identifier:retries; 9, integer:1; 10, block; 10, 11; 10, 15; 10, 21; 10, 25; 10, 51; 10, 58; 10, 1...
def discover(timeout=1, retries=1): locations = [] group = ('239.255.255.250', 1900) service = 'ssdp:urn:schemas-upnp-org:device:MediaRenderer:1' message = '\r\n'.join(['M-SEARCH * HTTP/1.1', 'HOST: {group[0]}:{group[1]}', 'MAN: "ssdp:discover"', ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:get_user_trades; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:limit; 7, integer:0; 8, default_parameter; 8, 9; 8, 10; 9, identifier:offset; 10, integer:0; 11, default_parameter; 11...
def get_user_trades(self, limit=0, offset=0, sort='desc'): self._log('get user trades') res = self._rest_client.post( endpoint='/user_transactions', payload={ 'book': self.name, 'limit': limit, 'offset': offset, 'sor...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:sort; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:col; 7, type; 7, 8; 8, identifier:str; 9, block; 9, 10; 10, try_statement; 10, 11; 10, 29; 11, block; 11, 12; 12, expression_statement; 12, 13; 1...
def sort(self, col: str): try: self.df = self.df.copy().sort_values(col) except Exception as e: self.err(e, "Can not sort the dataframe from column " + str(col))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 25; 2, function_name:iterate; 3, parameters; 3, 4; 3, 5; 3, 13; 3, 16; 3, 19; 3, 22; 4, identifier:MachineClass; 5, default_parameter; 5, 6; 5, 7; 6, identifier:stop_function; 7, lambda; 7, 8; 7, 10; 8, lambda_parameters; 8, 9; 9, identifier:iterations; 10, compar...
def iterate(MachineClass, stop_function=lambda iterations: iterations < 10000, machines=1000, survival_rate=0.05, mutation_rate=0.075, silent=False): def make_random(n): return MachineClass().randomize() def run_once(m): m.setUp() m.run() m.tearDown() return m ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:count_account; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:domain; 6, block; 6, 7; 6, 15; 6, 28; 6, 32; 6, 61; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:selector; 10, call; 10, 11; 10, 14; 11, att...
def count_account(self, domain): selector = domain.to_selector() cos_list = self.request_list('CountAccount', {'domain': selector}) ret = [] for i in cos_list: count = int(i['_content']) ret.append((zobjects.ClassOfService.from_dict(i), count)) return lis...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:search_directory; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 18; 7, 22; 7, 61; 7, 113; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:se...
def search_directory(self, **kwargs): search_response = self.request('SearchDirectory', kwargs) result = {} items = { "account": zobjects.Account.from_dict, "domain": zobjects.Domain.from_dict, "dl": zobjects.DistributionList.from_dict, "cos": zobj...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:search; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:query; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 13; 8, 22; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identif...
def search(self, query, **kwargs): content = kwargs content['query'] = {'_content': query} return self.request('Search', content)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:_call_zincrby; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 9; 4, identifier:self; 5, identifier:command; 6, identifier:value; 7, list_splat_pattern; 7, 8; 8, identifier:args; 9, dictionary_splat_pattern; 9, 10; 10, identifier:kwargs; 11, block; ...
def _call_zincrby(self, command, value, *args, **kwargs): if self.indexable: self.index([value]) return self._traverse_command(command, value, *args, **kwargs)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_extract_value_from_storage; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:string; 6, block; 6, 7; 6, 18; 6, 26; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:parts; 10, call; 10, 11; 10, 14; 11, attrib...
def _extract_value_from_storage(self, string): parts = string.split(self.separator) pk = parts.pop() return self.separator.join(parts), pk
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:get_boundaries; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:filter_type; 6, identifier:value; 7, block; 7, 8; 7, 14; 7, 18; 7, 22; 7, 26; 7, 143; 8, assert_statement; 8, 9; 9, comparison_operator:in; 9, 10; 9, 11; 10, ide...
def get_boundaries(self, filter_type, value): assert filter_type in self.handled_suffixes start = '-' end = '+' exclude = None if filter_type in (None, 'eq'): start = u'[%s%s' % (value, self.separator) end = start.encode('utf-8') + b'\xff' elif fil...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:get_boundaries; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:filter_type; 6, identifier:value; 7, block; 7, 8; 7, 14; 7, 18; 7, 22; 7, 26; 7, 79; 8, assert_statement; 8, 9; 9, comparison_operator:in; 9, 10; 9, 11; 10, iden...
def get_boundaries(self, filter_type, value): assert filter_type in self.handled_suffixes start = '-inf' end = '+inf' exclude = None if filter_type in (None, 'eq'): start = end = value elif filter_type == 'gt': start = '(%s' % value elif fi...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_combine_sets; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:sets; 6, identifier:final_set; 7, block; 7, 8; 7, 46; 8, if_statement; 8, 9; 8, 12; 8, 30; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, identifier:_has_so...
def _combine_sets(self, sets, final_set): if self._has_sortedsets: self.cls.get_connection().zinterstore(final_set, list(sets)) else: final_set = super(ExtendedCollectionManager, self)._combine_sets(sets, final_set) return final_set
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_final_redis_call; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:final_set; 6, identifier:sort_options; 7, block; 7, 8; 7, 18; 7, 37; 7, 84; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:conn; 1...
def _final_redis_call(self, final_set, sort_options): conn = self.cls.get_connection() if self._has_sortedsets and sort_options is None: return conn.zrange(final_set, 0, -1) if self.stored_key and not self._lazy_collection['sets']\ and len(self._lazy_collection['inter...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_collection_length; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:final_set; 6, block; 6, 7; 6, 17; 6, 60; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:conn; 10, call; 10, 11; 10, 16; 11, attribute; 11...
def _collection_length(self, final_set): conn = self.cls.get_connection() if self._has_sortedsets: return conn.zcard(final_set) elif self.stored_key and not self._lazy_collection['sets']\ and len(self._lazy_collection['intersects']) == 1: return conn.llen(...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_prepare_sort_by_score; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:values; 6, identifier:sort_options; 7, block; 7, 8; 7, 28; 7, 36; 7, 61; 7, 97; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 13; 10, pattern_l...
def _prepare_sort_by_score(self, values, sort_options): base_tmp_key, tmp_keys = self._zset_to_keys( key=self._sort_by_sortedset['by'], values=values, ) sort_options['by'] = '%s:*' % base_tmp_key ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_prepare_sort_options; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:has_pk; 6, block; 6, 7; 6, 20; 6, 45; 6, 112; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:sort_options; 10, call; 10, 11; 10, 18; 1...
def _prepare_sort_options(self, has_pk): sort_options = super(ExtendedCollectionManager, self)._prepare_sort_options(has_pk) if self._values: if not sort_options: sort_options = {} sort_options['get'] = self._values['fields']['keys'] if self._sort_by_sorte...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_get_final_set; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:sets; 6, identifier:pk; 7, identifier:sort_options; 8, block; 8, 9; 8, 64; 8, 81; 8, 119; 9, if_statement; 9, 10; 9, 15; 10, subscript; 10, 11; 10, 14; 11,...
def _get_final_set(self, sets, pk, sort_options): if self._lazy_collection['intersects']: sets = sets[::] sets.extend(self._lazy_collection['intersects']) if not self._lazy_collection['sets'] and not self.stored_key: sets.append(self.cls.get_field('pk').collec...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_prepare_sort_options; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:has_pk; 6, block; 6, 7; 6, 11; 6, 30; 6, 89; 6, 103; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:sort_options; 10, dictionary; 11, ...
def _prepare_sort_options(self, has_pk): sort_options = {} if self._sort is not None and not has_pk: sort_options.update(self._sort) if self._sort_limits is not None: if 'start' in self._sort_limits and 'num' not in self._sort_limits: self._sort_limits['nu...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_final_redis_call; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:final_set; 6, identifier:sort_options; 7, block; 7, 8; 7, 18; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:conn; 11, call; 11, 1...
def _final_redis_call(self, final_set, sort_options): conn = self.cls.get_connection() if sort_options is not None: return conn.sort(final_set, **sort_options) else: return conn.smembers(final_set)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 26; 2, function_name:query_mongo_sort_decend; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 20; 3, 23; 4, identifier:database_name; 5, identifier:collection_name; 6, default_parameter; 6, 7; 6, 8; 7, identifier:query; 8, dictionary; 9, default_parameter; 9, 10;...
def query_mongo_sort_decend( database_name, collection_name, query={}, skip=0, limit=getattr( settings, 'MONGO_LIMIT', 200), return_keys=(), sortkey=None): l = [] response_dict = {} try: mongodb_client_url = geta...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:build_sort; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 10; 7, 14; 7, 24; 7, 75; 8, expression_statement; 8, 9; 9, string:''' Break url parameters and turn into sort...
def build_sort(self, **kwargs): ''' Break url parameters and turn into sort arguments ''' sort = [] order = kwargs.get('order_by', None) if order: if type(order) is list: order = order[0] if order[:1] == '-': sort.append((order[1:],...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:load_remotes; 3, parameters; 3, 4; 3, 7; 4, default_parameter; 4, 5; 4, 6; 5, identifier:extra_path; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:load_user; 9, True; 10, block; 10, 11; 10, 17; 10, 39; 11, import_from_statement; 11,...
def load_remotes(extra_path=None, load_user=True): from os.path import getmtime try: remotes_file = find_config_file(REMOTES_FILE, extra_path=extra_path, load_user=load_user) except ConfigurationError: remotes_file = None if remotes_file is not None and os.path.exists(remotes_file): ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:find_previous; 3, parameters; 3, 4; 3, 5; 4, identifier:element; 5, identifier:l; 6, block; 6, 7; 6, 14; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:length; 10, call; 10, 11; 10, 12; 11, identifier:len; 12, argument...
def find_previous(element, l): length = len(l) for index, current in enumerate(l): if length - 1 == index: return current if index == 0: if element < current: return None if current <= element < l[index+1]: return current
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:tsort; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 30; 5, 38; 5, 42; 5, 102; 5, 110; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:task_dict; 9, dictionary; 10, for_statement; 10, 11; 10, 14; 10,...
def tsort(self): task_dict = {} for key, task in self.tasks.iteritems(): task_dict[task] = task.dependencies parts = task_dict.copy() result = [] while True: level = set([name for name, deps in parts.iteritems() if not deps]) if not level: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:getBounds; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:tzinfo; 7, None; 8, block; 8, 9; 8, 49; 9, if_statement; 9, 10; 9, 27; 9, 41; 10, boolean_operator:and; 10, 11; 10, 23; 10, 24; 11, compar...
def getBounds(self, tzinfo=None): if self.resolution >= datetime.timedelta(days=1) \ and tzinfo is not None: time = self._time.replace(tzinfo=tzinfo) else: time = self._time return ( min(self.fromDatetime(time), self.fromDatetime(self._time)), ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:_get_all_migrations; 3, parameters; 4, block; 4, 5; 4, 10; 4, 14; 4, 22; 4, 26; 4, 72; 4, 87; 5, import_from_statement; 5, 6; 5, 8; 6, relative_import; 6, 7; 7, import_prefix; 8, dotted_name; 8, 9; 9, identifier:migrations; 10, expression_state...
def _get_all_migrations(): from . import migrations package = migrations prefix = package.__name__ + '.' all_migrations = [] for importer, modname, ispkg in pkgutil.iter_modules(package.__path__, prefix): version = int(modname.split('.')[-1].split('_')[0]) all_migrations.append((vers...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:sort_genes; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:stable; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:inplace; 10, False; 11, default_parameter; 11, 12; 11, 13...
def sort_genes(self, stable=True, inplace=False, ascending=True): kind = 'quicksort' if stable: kind = 'mergesort' return self.sort_index(kind=kind, inplace=inplace, ascending=ascending)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:sort_samples; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:stable; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:inplace; 10, False; 11, default_parameter; 11, 12; 11, ...
def sort_samples(self, stable=True, inplace=False, ascending=True): kind = 'quicksort' if stable: kind = 'mergesort' return self.sort_index(axis=1, kind=kind, inplace=inplace, ascending=ascending)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:parseColors; 3, parameters; 3, 4; 3, 5; 4, identifier:colors; 5, identifier:defaultColor; 6, block; 6, 7; 6, 11; 6, 140; 6, 155; 6, 177; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:result; 10, list:[]; 11, if_statem...
def parseColors(colors, defaultColor): result = [] if colors: for colorInfo in colors: fields = colorInfo.split(maxsplit=1) if len(fields) == 2: threshold, color = fields try: threshold = float(threshold) except ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:bisect_index; 3, parameters; 3, 4; 3, 5; 4, identifier:a; 5, identifier:x; 6, block; 6, 7; 6, 17; 6, 33; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:i; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, id...
def bisect_index(a, x): i = bisect.bisect_left(a, x) if i != len(a) and a[i] == x: return i raise ValueError
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:writeSampleIndex; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:fp; 6, block; 6, 7; 7, expression_statement; 7, 8; 8, call; 8, 9; 8, 10; 9, identifier:print; 10, argument_list; 10, 11; 10, 42; 11, call; 11, 12; 11, 15; 12, attrib...
def writeSampleIndex(self, fp): print('\n'.join( '%d %s' % (index, name) for (index, name) in sorted((index, name) for (name, index) in self._samples.items()) ), file=fp)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:writePathogenIndex; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:fp; 6, block; 6, 7; 7, expression_statement; 7, 8; 8, call; 8, 9; 8, 10; 9, identifier:print; 10, argument_list; 10, 11; 10, 42; 11, call; 11, 12; 11, 15; 12, attr...
def writePathogenIndex(self, fp): print('\n'.join( '%d %s' % (index, name) for (index, name) in sorted((index, name) for (name, index) in self._pathogens.items()) ), file=fp)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_transform_chrom; 3, parameters; 3, 4; 4, identifier:chrom; 5, block; 5, 6; 6, try_statement; 6, 7; 6, 15; 6, 39; 7, block; 7, 8; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:c; 11, call; 11, 12; 11, 13; 12, identi...
def _transform_chrom(chrom): try: c = int(chrom) except: if chrom in ['X', 'Y']: return chrom elif chrom == 'MT': return '_MT' else: return '__' + chrom else: return '%02d' % c
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_show; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 23; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:p; 9, call; 9, 10; 9, 11; 10, identifier:_runshell; 11, argument_list; 11, 12; 11, 18; 12, list:[brct...
def _show(self): p = _runshell([brctlexe, 'show', self.name], "Could not show %s." % self.name) return p.stdout.read().split()[7:]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_assembly; 3, parameters; 3, 4; 4, identifier:name; 5, block; 5, 6; 5, 23; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:fn; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:pkg_resources; 12, id...
def get_assembly(name): fn = pkg_resources.resource_filename( __name__, _assy_path_fmt.format(name=name)) return json.load(gzip.open(fn, mode="rt", encoding="utf-8"))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:coverageInfo; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 13; 5, 59; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:result; 9, call; 9, 10; 9, 11; 10, identifier:defaultdict; 11, argument_list; 11, 12; 1...
def coverageInfo(self): result = defaultdict(list) for titleAlignment in self: for hsp in titleAlignment.hsps: score = hsp.score.score for (subjectOffset, base, _) in titleAlignment.read.walkHSP( hsp, includeWhiskers=False): ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 26; 2, function_name:filter; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:minMatchingReads; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:minMedianScore; 10, Non...
def filter(self, minMatchingReads=None, minMedianScore=None, withScoreBetterThan=None, minNewReads=None, minCoverage=None, maxTitles=None, sortOn='maxScore'): if minNewReads is None: readSetFilter = None else: if self.readSetFilter is None: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sortTitles; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:by; 6, block; 6, 7; 6, 17; 6, 40; 6, 65; 6, 95; 6, 120; 6, 127; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:titles; 10, call; 10, 11; 10, 12; ...
def sortTitles(self, by): titles = sorted(iter(self)) if by == 'length': return sorted( titles, reverse=True, key=lambda title: self[title].subjectLength) if by == 'maxScore': return sorted( titles, reverse=True, key=lambda ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:summary; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sortOn; 7, None; 8, block; 8, 9; 8, 23; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:titles; 12, condition...
def summary(self, sortOn=None): titles = self if sortOn is None else self.sortTitles(sortOn) for title in titles: yield self[title].summary()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:tabSeparatedSummary; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sortOn; 7, None; 8, block; 8, 9; 8, 13; 8, 43; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:re...
def tabSeparatedSummary(self, sortOn=None): result = [] for titleSummary in self.summary(sortOn): result.append('\t'.join([ '%(coverage)f', '%(medianScore)f', '%(bestScore)f', '%(readCount)d', '%(hspCount)d', ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:infer_namespaces; 3, parameters; 3, 4; 4, identifier:ac; 5, block; 5, 6; 6, return_statement; 6, 7; 7, list_comprehension; 7, 8; 7, 9; 7, 18; 8, identifier:v; 9, for_in_clause; 9, 10; 9, 13; 10, pattern_list; 10, 11; 10, 12; 11, identifier:k; 1...
def infer_namespaces(ac): return [v for k, v in ac_namespace_regexps.items() if k.match(ac)]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:to_digraph; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:args; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 18; 9, 171; 10, expression_statement; 10, 11; 11, ass...
def to_digraph(self, *args, **kwargs): digraph = _nx.DiGraph() for equation in self.equations: reactants, arrow, products = [value.strip() for value in _split_arrows(str(equation))] try: attr = equation.to_series("reactant...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:get_streams; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:game; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:channels; 10, None; 11, default_parameter; 11, 12; ...
def get_streams(self, game=None, channels=None, limit=25, offset=0): if isinstance(game, models.Game): game = game.name channelnames = [] cparam = None if channels: for c in channels: if isinstance(c, models.Channel): c = c.name...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:sort_queryset; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:queryset; 5, identifier:request; 6, default_parameter; 6, 7; 6, 8; 7, identifier:context; 8, None; 9, block; 9, 10; 9, 21; 9, 139; 10, expression_statement; 10, 11; 11, assignment; 1...
def sort_queryset(queryset, request, context=None): sort_by = request.GET.get('sort_by') if sort_by: if sort_by in [el.name for el in queryset.model._meta.fields]: queryset = queryset.order_by(sort_by) else: if sort_by in request.session: sort_by = request...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:percentile; 3, parameters; 3, 4; 3, 5; 4, identifier:data; 5, identifier:n; 6, block; 6, 7; 6, 14; 6, 25; 6, 45; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:size; 10, call; 10, 11; 10, 12; 11, identifier:len; 12, ar...
def percentile(data, n): size = len(data) idx = (n / 100.0) * size - 0.5 if idx < 0 or idx > size: raise StatisticsError("Too few data points ({}) for {}th percentile".format(size, n)) return data[int(idx)]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_histogram; 3, parameters; 3, 4; 4, identifier:data; 5, block; 5, 6; 5, 13; 5, 28; 5, 34; 5, 41; 5, 48; 5, 58; 5, 68; 5, 88; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:count; 9, call; 9, 10; 9, 11; 10, identifier...
def get_histogram(data): count = len(data) if count < 2: raise StatisticsError('Too few data points ({}) for get_histogram'.format(count)) min_ = data[0] max_ = data[-1] std = stdev(data) bins = get_histogram_bins(min_, max_, std, count) res = {x: 0 for x in bins} for value in da...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:make_geohash_tables; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:table; 5, identifier:listofprecisions; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 11; 8, 15; 8, 19; 8, 47; 8, 56; 8, 64; 8, 68; 8, 88; 8, 98; 8...
def make_geohash_tables(table,listofprecisions,**kwargs): ''' sort_by - field to sort by for each group return_squares - boolean arg if true returns a list of squares instead of writing out to table ''' return_squares = False sort_by = 'COUNT' for key,value in kwargs.iteritems(): if key == 'sort_by': sort_b...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:coercer; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:dataSets; 6, block; 6, 7; 6, 36; 6, 50; 6, 64; 6, 73; 6, 230; 6, 237; 7, function_definition; 7, 8; 7, 9; 7, 12; 8, function_name:makeSetter; 9, parameters; 9, 10; 9, 11; 10,...
def coercer(self, dataSets): def makeSetter(identifier, values): def setter(defaultObject): self._idsToObjects[identifier] = defaultObject self._lastValues[identifier] = values return setter created = self._coerceAll(self._extractCreations(dataSets...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:zcard; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:name; 6, block; 6, 7; 7, with_statement; 7, 8; 7, 16; 8, with_clause; 8, 9; 9, with_item; 9, 10; 10, as_pattern; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:s...
def zcard(self, name): with self.pipe as pipe: return pipe.zcard(self.redis_key(name))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:zscore; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:name; 6, identifier:value; 7, block; 7, 8; 8, with_statement; 8, 9; 8, 17; 9, with_clause; 9, 10; 10, with_item; 10, 11; 11, as_pattern; 11, 12; 11, 15; 12, attribute; 1...
def zscore(self, name, value): with self.pipe as pipe: return pipe.zscore(self.redis_key(name), self.valueparse.encode(value))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:zrank; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:name; 6, identifier:value; 7, block; 7, 8; 8, with_statement; 8, 9; 8, 17; 9, with_clause; 9, 10; 10, with_item; 10, 11; 11, as_pattern; 11, 12; 11, 15; 12, attribute; 12...
def zrank(self, name, value): with self.pipe as pipe: value = self.valueparse.encode(value) return pipe.zrank(self.redis_key(name), value)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:zlexcount; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:name; 6, identifier:min; 7, identifier:max; 8, block; 8, 9; 9, with_statement; 9, 10; 9, 18; 10, with_clause; 10, 11; 11, with_item; 11, 12; 12, as_pattern; 12,...
def zlexcount(self, name, min, max): with self.pipe as pipe: return pipe.zlexcount(self.redis_key(name), min, max)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:zrevrangebylex; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 4, identifier:self; 5, identifier:name; 6, identifier:max; 7, identifier:min; 8, default_parameter; 8, 9; 8, 10; 9, identifier:start; 10, None; 11, default_parameter; 11, 12; ...
def zrevrangebylex(self, name, max, min, start=None, num=None): with self.pipe as pipe: f = Future() res = pipe.zrevrangebylex(self.redis_key(name), max, min, start=start, num=num) def cb(): f.set([self.valueparse.decode(v...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:zremrangebylex; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:name; 6, identifier:min; 7, identifier:max; 8, block; 8, 9; 9, with_statement; 9, 10; 9, 18; 10, with_clause; 10, 11; 11, with_item; 11, 12; 12, as_pattern...
def zremrangebylex(self, name, min, max): with self.pipe as pipe: return pipe.zremrangebylex(self.redis_key(name), min, max)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:resort; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:attributeID; 6, default_parameter; 6, 7; 6, 8; 7, identifier:isAscending; 8, None; 9, block; 9, 10; 9, 21; 9, 29; 9, 46; 9, 83; 9, 89; 10, if_statement; 10, 11; 10, 14; ...
def resort(self, attributeID, isAscending=None): if isAscending is None: isAscending = self.defaultSortAscending newSortColumn = self.columns[attributeID] if newSortColumn.sortAttribute() is None: raise Unsortable('column %r has no sort attribute' % (attributeID,)) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_sortAttributeValue; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:offset; 6, block; 6, 7; 6, 42; 7, if_statement; 7, 8; 7, 11; 7, 36; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:_currentResults; 11, block; 11, ...
def _sortAttributeValue(self, offset): if self._currentResults: pageStart = (self._currentResults[offset][ self.currentSortColumn.attributeID], self._currentResults[offset][ '__item__'].storeID) else: pageStart = None ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:resort; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:columnName; 6, block; 6, 7; 6, 13; 6, 21; 6, 34; 6, 62; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:csc; 10, attribute; 10, 11; 10, 12; 11, identi...
def resort(self, columnName): csc = self.currentSortColumn newSortColumn = self.columns[columnName] if newSortColumn is None: raise Unsortable('column %r has no sort attribute' % (columnName,)) if csc is newSortColumn: self.isAscending = not self.isAscending ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:rowsAfterValue; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:value; 6, identifier:count; 7, block; 7, 8; 7, 58; 8, if_statement; 8, 9; 8, 12; 8, 24; 9, comparison_operator:is; 9, 10; 9, 11; 10, identifier:value; 11, None; ...
def rowsAfterValue(self, value, count): if value is None: query = self.inequalityQuery(None, count, True) else: pyvalue = self._toComparableValue(value) currentSortAttribute = self.currentSortColumn.sortAttribute() query = self.inequalityQuery(currentSortA...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:rowsBeforeValue; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:value; 6, identifier:count; 7, block; 7, 8; 7, 58; 8, if_statement; 8, 9; 8, 12; 8, 24; 9, comparison_operator:is; 9, 10; 9, 11; 10, identifier:value; 11, None;...
def rowsBeforeValue(self, value, count): if value is None: query = self.inequalityQuery(None, count, False) else: pyvalue = self._toComparableValue(value) currentSortAttribute = self.currentSortColumn.sortAttribute() query = self.inequalityQuery( ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:rowsBeforeItem; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:item; 6, identifier:count; 7, block; 7, 8; 7, 18; 7, 31; 7, 56; 7, 65; 7, 72; 7, 100; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:...
def rowsBeforeItem(self, item, count): currentSortAttribute = self.currentSortColumn.sortAttribute() value = currentSortAttribute.__get__(item, type(item)) firstQuery = self.inequalityQuery( AND(currentSortAttribute == value, self.itemType.storeID < item.storeID), ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:getTableMetadata; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 61; 5, 88; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:coltypes; 9, dictionary; 10, for_statement; 10, 11; 10, 14; 10, 21; 11, tupl...
def getTableMetadata(self): coltypes = {} for (colname, column) in self.columns.iteritems(): sortable = column.sortAttribute() is not None coltype = column.getType() if coltype is not None: coltype = unicode(coltype, 'ascii') coltypes[colna...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:getInitialArguments; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 15; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:ic; 9, call; 9, 10; 9, 11; 10, identifier:IColumn; 11, argument_list; 11, 12; 12, attri...
def getInitialArguments(self): ic = IColumn(self.currentSortColumn) return [ic.attributeID.decode('ascii'), self._getColumnList(), self.isAscending]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:build_database_sortmerna; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 18; 4, identifier:fasta_path; 5, default_parameter; 5, 6; 5, 7; 6, identifier:max_pos; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:output_dir; 10, None; 11, def...
def build_database_sortmerna(fasta_path, max_pos=None, output_dir=None, temp_dir=tempfile.gettempdir(), HALT_EXEC=False): if fasta_path is None: raise ValueError("Error: path to fasta referenc...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 37; 2, function_name:sortmerna_ref_cluster; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 3, 25; 3, 28; 3, 31; 3, 34; 4, default_parameter; 4, 5; 4, 6; 5, identifier:seq_path; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:sortmerna_db; 9...
def sortmerna_ref_cluster(seq_path=None, sortmerna_db=None, refseqs_fp=None, result_path=None, tabular=False, max_e_value=1, similarity=0.97, ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 35; 2, function_name:sortmerna_map; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 4, identifier:seq_path; 5, identifier:output_dir; 6, identifier:refseqs_fp; 7, identifier:sortmerna_db; 8, default_parameter; 8...
def sortmerna_map(seq_path, output_dir, refseqs_fp, sortmerna_db, e_value=1, threads=1, best=None, num_alignments=None, HALT_EXEC=False, output_sam=False, ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_dict_values_sorted_by_key; 3, parameters; 3, 4; 4, identifier:dictionary; 5, block; 5, 6; 6, for_statement; 6, 7; 6, 10; 6, 26; 7, pattern_list; 7, 8; 7, 9; 8, identifier:_; 9, identifier:value; 10, call; 10, 11; 10, 12; 11, identifier:sorted;...
def _dict_values_sorted_by_key(dictionary): for _, value in sorted(dictionary.iteritems(), key=operator.itemgetter(0)): yield value
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 52; 2, function_name:uclust_cluster_from_sorted_fasta_filepath; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 3, 35; 3, 38; 3, 41; 3, 44; 3, 49; 4, identifier:fasta_filepath; 5, default_parameter; 5, 6; 5, 7; 6, identifie...
def uclust_cluster_from_sorted_fasta_filepath( fasta_filepath, uc_save_filepath=None, percent_ID=0.97, max_accepts=1, max_rejects=8, stepwords=8, word_length=8, optimal=False, exact=False, suppress_sort=False, enable_rev_strand_matc...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 59; 2, function_name:get_clusters_from_fasta_filepath; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 3, 27; 3, 30; 3, 33; 3, 36; 3, 39; 3, 42; 3, 45; 3, 48; 3, 53; 3, 56; 4, identifier:fasta_filepath; 5, identifier:original_fasta_path; ...
def get_clusters_from_fasta_filepath( fasta_filepath, original_fasta_path, percent_ID=0.97, max_accepts=1, max_rejects=8, stepwords=8, word_length=8, optimal=False, exact=False, suppress_sort=False, output_dir=None, enable_r...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:ls; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:startswith; 7, None; 8, block; 8, 9; 8, 11; 8, 20; 8, 29; 8, 48; 9, expression_statement; 9, 10; 10, string:''' List all cubes available ...
def ls(self, startswith=None): ''' List all cubes available to the calling client. :param startswith: string to use in a simple "startswith" query filter :returns list: sorted list of cube names ''' logger.info('Listing cubes starting with "%s")' % startswith) sta...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 35; 2, function_name:usearch_sort_by_abundance; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 4, identifier:fasta_filepath; 5, default_parameter; 5, 6; 5, 7; 6, identifier:output_filepath; 7, None; 8, default_parameter; 8...
def usearch_sort_by_abundance( fasta_filepath, output_filepath=None, sizein=True, sizeout=True, minsize=0, log_name="abundance_sort.log", usersort=False, HALT_EXEC=False, save_intermediate_files=False, remove_usearch_logs=False, wor...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 47; 2, function_name:usearch_cluster_error_correction; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 3, 35; 3, 38; 3, 41; 3, 44; 4, identifier:fasta_filepath; 5, default_parameter; 5, 6; 5, 7; 6, identifier:output_filepat...
def usearch_cluster_error_correction( fasta_filepath, output_filepath=None, output_uc_filepath=None, percent_id_err=0.97, sizein=True, sizeout=True, w=64, slots=16769023, maxrejects=64, log_name="usearch_cluster_err_corrected.log", ...