sequence
stringlengths
492
15.9k
code
stringlengths
75
8.58k
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_findRedundantProteins; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:protToPeps; 5, identifier:pepToProts; 6, default_parameter; 6, 7; 6, 8; 7, identifier:proteins; 8, None; 9, block; 9, 10; 9, 22; 9, 29; 9, 36; 9, 45; 9, 54; 9, 60; 9, 91; 9,...
def _findRedundantProteins(protToPeps, pepToProts, proteins=None): if proteins is None: proteins = viewkeys(protToPeps) pepFrequency = _getValueCounts(pepToProts) protPepCounts = _getValueCounts(protToPeps) getCount = operator.itemgetter(1) getProt = operator.itemgetter(0) proteinTuples ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_mergeProteinEntries; 3, parameters; 3, 4; 3, 5; 4, identifier:proteinLists; 5, identifier:protToPeps; 6, block; 6, 7; 6, 14; 6, 47; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:mergedProtToPeps; 10, call; 10, 11; 10...
def _mergeProteinEntries(proteinLists, protToPeps): mergedProtToPeps = dict(protToPeps) for proteins in proteinLists: for protein in proteins: peptides = mergedProtToPeps.pop(protein) mergedProtein = tuple(sorted(proteins)) mergedProtToPeps[mergedProtein] = peptides retur...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:_list; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:foldername; 7, string:"INBOX"; 8, default_parameter; 8, 9; 8, 10; 9, identifier:reverse; 10, False; 11, default_parameter; 11, 1...
def _list(self, foldername="INBOX", reverse=False, since=None): folder = self.folder \ if foldername == "INBOX" \ else self._getfolder(foldername) def sortcmp(d): try: return d[1].date except: return -1 lst = folder....
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_entries; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, return_statement; 6, 7; 7, call; 7, 8; 7, 9; 8, identifier:sorted; 9, argument_list; 9, 10; 9, 13; 9, 18; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, identifi...
def sort_entries(self): return sorted(self.data, key=self.sort_func, reverse=self.get_reverse())
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:expectedLabelPosition; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:peptide; 5, identifier:labelStateInfo; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sequence; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:modPositio...
def expectedLabelPosition(peptide, labelStateInfo, sequence=None, modPositions=None): if modPositions is None: modPositions = maspy.peptidemethods.returnModPositions(peptide, indexStart=0 ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:rank; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:member; 6, block; 6, 7; 6, 29; 7, if_statement; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:reversed; 11, block; 11, 12; 12, return_statement; 12,...
def rank(self, member): if self.reversed: return self._client.zrevrank(self.key_prefix, self._dumps(member)) return self._client.zrank(self.key_prefix, self._dumps(member))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:prepareSiiImport; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 4, identifier:siiContainer; 5, identifier:specfile; 6, identifier:path; 7, identifier:qcAttr; 8, identifier:qcLargerBetter; 9, identifier:qcCutoff; 10, identifi...
def prepareSiiImport(siiContainer, specfile, path, qcAttr, qcLargerBetter, qcCutoff, rankAttr, rankLargerBetter): if specfile not in siiContainer.info: siiContainer.addSpecfile(specfile, path) else: raise Exception('...') siiContainer.info[specfile]['qcAttr'] = qcAttr ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 1, 14; 2, function_name:find_nearest; 3, parameters; 3, 4; 3, 5; 4, identifier:x; 5, identifier:x0; 6, type; 6, 7; 7, generic_type; 7, 8; 7, 9; 8, identifier:Tuple; 9, type_parameter; 9, 10; 9, 12; 10, type; 10, 11; 11, identifier:int; 12, type; 12, 13; 13, ide...
def find_nearest(x, x0) -> Tuple[int, Any]: x = np.asanyarray(x) x0 = np.atleast_1d(x0) if x.size == 0 or x0.size == 0: raise ValueError('empty input(s)') if x0.ndim not in (0, 1): raise ValueError('2-D x0 not handled yet') ind = np.empty_like(x0, dtype=int) for i, xi in enumerat...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:primary_mrna; 3, parameters; 3, 4; 3, 5; 4, identifier:entrystream; 5, default_parameter; 5, 6; 5, 7; 6, identifier:parenttype; 7, string:'gene'; 8, block; 8, 9; 9, for_statement; 9, 10; 9, 11; 9, 12; 10, identifier:entry; 11, identifier:entrys...
def primary_mrna(entrystream, parenttype='gene'): for entry in entrystream: if not isinstance(entry, tag.Feature): yield entry continue for parent in tag.select.features(entry, parenttype, traverse=True): mrnas = [f for f in parent.children if f.type == 'mRNA'] ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:notes; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:public_only; 7, False; 8, block; 8, 9; 8, 28; 8, 40; 8, 54; 8, 69; 8, 129; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11,...
def notes(self, public_only=False): tag_index = dict((tag, i) for i, tag in enumerate(Note.TAGS)) notes = self.note_set.order_by('-sort_num', 'created') if public_only: notes = notes.filter(is_public=True) known_issues = [n for n in notes if n.is_known_issue_for(self)] ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:dispatchlist; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, keyword_separator; 6, default_parameter; 6, 7; 6, 8; 7, identifier:author; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:category; 11, None...
def dispatchlist(self, *, author=None, category=None, subcategory=None, sort='new'): params = {'sort': sort} if author: params['dispatchauthor'] = author if category and subcategory: if (category not in dispatch_categories or subca...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 1, 10; 2, function_name:have_cycle; 3, parameters; 3, 4; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:graph; 6, type; 6, 7; 7, identifier:dict; 8, type; 8, 9; 9, identifier:frozenset; 10, block; 10, 11; 10, 17; 10, 45; 10, 52; 10, 57; 10, 103; 11, expression_s...
def have_cycle(graph:dict) -> frozenset: walked = set() nodes = frozenset(it.chain(it.chain.from_iterable(graph.values()), graph.keys())) preds = reversed_graph(graph) last_walked_len = -1 while last_walked_len != len(walked): last_walked_len = len(walked) for node in nodes - walked:...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:time_pipeline; 3, parameters; 3, 4; 3, 5; 4, identifier:iterable; 5, list_splat_pattern; 5, 6; 6, identifier:steps; 7, block; 7, 8; 7, 10; 7, 56; 7, 67; 7, 71; 7, 75; 7, 197; 7, 204; 7, 211; 7, 221; 8, expression_statement; 8, 9; 9, string:''' ...
def time_pipeline(iterable, *steps): ''' This times the steps in a pipeline. Give it an iterable to test against followed by the steps of the pipeline seperated in individual functions. Example Usage: ``` from random import choice, randint l = [randint(0,50) for i in range(100)] step1 = lambda iterable:...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_matches; 3, parameters; 3, 4; 4, identifier:matches; 5, block; 5, 6; 5, 8; 5, 30; 5, 54; 6, expression_statement; 6, 7; 7, string:'''Sorts a ``list`` of matches best to worst'''; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; ...
def sort_matches(matches): '''Sorts a ``list`` of matches best to worst''' multipliers = {'exact':10**5,'fname':10**4,'fuzzy':10**2,'fuzzy_fragment':1} matches = [(multipliers[x.type]*(x.amount if x.amount else 1),x) for x in matches] return [x[1] for x in sorted(matches,reverse=True)]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_get_sorted_iterator; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:iterator; 6, block; 6, 7; 6, 17; 6, 40; 6, 43; 6, 51; 6, 66; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:lines; 10, call; 10, 11; 10...
def _get_sorted_iterator(self, iterator): lines = list(next(iterator)) if len(lines) < self.max_lines: return iter(sorted(lines, key=self.key)) import tempfile tmp_dir = tempfile.mkdtemp() fnames = self._split(chain([lines], iterator), tmp_dir) return SortedIt...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_split; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:iterator; 6, identifier:tmp_dir; 7, block; 7, 8; 7, 12; 7, 75; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:fnames; 11, list:[]; 12, for_st...
def _split(self, iterator, tmp_dir): fnames = [] for i, lines in enumerate(iterator): lines = list(lines) out_fname = os.path.join(tmp_dir, self.TMP_FNAME.format(i + 1)) self._write(lines, out_fname) fnames.append(out_fname) if len(lines) < sel...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_write; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:lines; 6, identifier:fname; 7, block; 7, 8; 8, with_statement; 8, 9; 8, 19; 9, with_clause; 9, 10; 10, with_item; 10, 11; 11, as_pattern; 11, 12; 11, 17; 12, call; 12, 1...
def _write(self, lines, fname): with open(fname, 'wb') as out_fhndl: for line in sorted(lines, key=self.key): pickle.dump(line, out_fhndl)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:add; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:interval; 6, identifier:offset; 7, block; 7, 8; 7, 19; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 13; 10, pattern_list; 10, 11; 10, 12; 11, identifier:start; 1...
def add(self, interval, offset): start, stop = self.get_start_stop(interval) if len(self.starts) > 0: if start < self.starts[-1] or offset <= self.offsets[-1][1]: raise ValueError('intervals and offsets must be added in-order') self.offsets[-1][1] = offset ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:get_collection_documents_generator; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:client; 5, identifier:database_name; 6, identifier:collection_name; 7, identifier:spec; 8, identifier:latest_n; 9, identifier:sort_key; 10, bl...
def get_collection_documents_generator(client, database_name, collection_name, spec, latest_n, sort_key): mongo_database = client[database_name] collection = mongo_database[collection_name] collection.create_index(sort_key) if latest_n is not None: skip_n = collection.count() - latest_n ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:save; 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, 27; 9, 44; 10, if_statement; 10, 11; 10, 15; 11, not_operat...
def save(self, *args, **kwargs): if not self.target: self.target = str(self.content_object) if not self.actor_name: self.actor_name = str(self.actor) super(Activity, self).save()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_sort_modules; 3, parameters; 3, 4; 4, identifier:mods; 5, block; 5, 6; 5, 56; 6, function_definition; 6, 7; 6, 8; 6, 11; 7, function_name:compare; 8, parameters; 8, 9; 8, 10; 9, identifier:x; 10, identifier:y; 11, block; 11, 12; 11, 18; 11, 24...
def _sort_modules(mods): def compare(x, y): x = x[1] y = y[1] if x == y: return 0 if y.stem == "__init__.py": return 1 if x.stem == "__init__.py" or x < y: return -1 return 1 return sorted(mods, key=cmp_to_key(compare))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_sort_results; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:results; 6, block; 6, 7; 6, 11; 6, 15; 6, 79; 6, 83; 6, 109; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:parents; 10, list:[]; 11, expressi...
def _sort_results(self, results): parents = [] groups = [] for result in results: if not self._in_list(parents, result.parent): parents.append(result.parent) groups.append([]) groups[len(groups) - 1].append(result) else: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_update_sorting; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 12; 5, 18; 5, 24; 5, 30; 5, 82; 5, 92; 5, 107; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:key; 9, attribute; 9, 10; 9, 11; 10, identifier:...
def _update_sorting(self): key = self.key sorted_tops = self.sorted_tops tops = self.tops iterators = self.iterators for idx in self.idxs: try: tops[idx] = next(iterators[idx]) top_key = key(tops[idx]) if top_key not in ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:domain_user_stats; 3, parameters; 4, block; 4, 5; 4, 24; 4, 42; 5, expression_statement; 5, 6; 6, assignment; 6, 7; 6, 8; 7, identifier:fname; 8, call; 8, 9; 8, 14; 9, attribute; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:os; 1...
def domain_user_stats(): fname = os.path.join(os.path.dirname(__file__), "email_domain_users.csv") stats = pd.read_csv(fname, header=0, squeeze=True, index_col=0) return stats[pd.notnull(stats.index)]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_topological_sort; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 20; 5, 33; 5, 76; 5, 93; 5, 109; 5, 156; 5, 178; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:sorted_graph; 9, list:[]; 10, express...
def _topological_sort(self): sorted_graph = [] node_map = self._graph.get_nodes() nodes = [NodeVisitor(node_map[node]) for node in node_map] def get_pointers_for_edge_nodes(visitor_decorated_node): edges = [] edge_ids = visitor_decorated_node.get_node().get_edges(...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:plugins; 3, parameters; 3, 4; 3, 5; 4, identifier:group; 5, default_parameter; 5, 6; 5, 7; 6, identifier:spec; 7, None; 8, block; 8, 9; 8, 11; 8, 18; 8, 29; 8, 41; 9, expression_statement; 9, 10; 10, string:''' Returns a `PluginSet` object fo...
def plugins(group, spec=None): ''' Returns a `PluginSet` object for the specified setuptools-style entrypoint `group`. This is just a wrapper around `pkg_resources.iter_entry_points` that allows the plugins to sort and override themselves. The optional `spec` parameter controls how and what plugins are lo...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:match_any_string; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:strings; 6, default_parameter; 6, 7; 6, 8; 7, identifier:word; 8, integer:0; 9, default_parameter; 9, 10; 9, 11; 10, identifier:offset; 11, integer:0; 1...
def match_any_string(self, strings, word=0, offset=0): if word: current = self.get_string(offset) return current if current in strings else '' current = '' currentlength = 0 length = 0 for string in strings: length = len(string) if ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:decide_which_users_to_annotate; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:centrality_vector; 5, identifier:number_to_annotate; 6, identifier:already_annotated; 7, identifier:node_to_id; 8, block; 8, 9; 8, 18; 8, 32; 8, 66; 8, 72; 8, ...
def decide_which_users_to_annotate(centrality_vector, number_to_annotate, already_annotated, node_to_id): centrality_vector = np.asarray(centrality_vector) ind = np.argsort(np.squeeze(centrality_vector)) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 27; 2, function_name:search; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 24; 4, identifier:self; 5, identifier:query; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sort_map; 8, dictionary; 8, 9; 8, 12; 8, 15; 8, 18; 8, 21; 9, pair; 9, 10; 9, 11; 10, string:'BoxSet'; 11,...
async def search(self, query, sort_map = {'BoxSet':0,'Series':1,'Movie':2,'Audio':3,'Person':4}, strict_sort = False): '''Sends a search request to emby, returns results |coro| Parameters ---------- query : str the search string to send to emby sort_map : dict ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:set_attribute_string; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:target; 5, identifier:name; 6, identifier:value; 7, block; 7, 8; 8, expression_statement; 8, 9; 9, call; 9, 10; 9, 11; 10, identifier:set_attribute; 11, argument_list; 11, 12;...
def set_attribute_string(target, name, value): set_attribute(target, name, np.bytes_(value))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:__calculate_edge_weights; 3, parameters; 3, 4; 4, identifier:dfs_data; 5, block; 5, 6; 5, 12; 5, 16; 5, 38; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:graph; 9, subscript; 9, 10; 9, 11; 10, identifier:dfs_data; 11, ...
def __calculate_edge_weights(dfs_data): graph = dfs_data['graph'] weights = {} for edge_id in graph.get_all_edge_ids(): edge_weight = __edge_weight(edge_id, dfs_data) weights[edge_id] = edge_weight return weights
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:__sort_adjacency_lists; 3, parameters; 3, 4; 4, identifier:dfs_data; 5, block; 5, 6; 5, 10; 5, 16; 5, 22; 5, 28; 5, 121; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:new_adjacency_lists; 9, dictionary; 10, expression_...
def __sort_adjacency_lists(dfs_data): new_adjacency_lists = {} adjacency_lists = dfs_data['adj'] edge_weights = dfs_data['edge_weights'] edge_lookup = dfs_data['edge_lookup'] for node_id, adj_list in list(adjacency_lists.items()): node_weight_lookup = {} frond_lookup = {} for...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:__edge_weight; 3, parameters; 3, 4; 3, 5; 4, identifier:edge_id; 5, identifier:dfs_data; 6, block; 6, 7; 6, 13; 6, 19; 6, 28; 6, 36; 6, 44; 6, 52; 6, 60; 6, 68; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:graph; 10,...
def __edge_weight(edge_id, dfs_data): graph = dfs_data['graph'] edge_lookup = dfs_data['edge_lookup'] edge = graph.get_edge(edge_id) u, v = edge['vertices'] d_u = D(u, dfs_data) d_v = D(v, dfs_data) lp_1 = L1(v, dfs_data) d_lp_1 = D(lp_1, dfs_data) if edge_lookup[edge_id] == 'backedg...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:classify_segmented_recording; 3, parameters; 3, 4; 3, 5; 4, identifier:recording; 5, default_parameter; 5, 6; 5, 7; 6, identifier:result_format; 7, None; 8, block; 8, 9; 8, 11; 8, 22; 9, global_statement; 9, 10; 10, identifier:single_symbol_cla...
def classify_segmented_recording(recording, result_format=None): global single_symbol_classifier if single_symbol_classifier is None: single_symbol_classifier = SingleClassificer() return single_symbol_classifier.predict(recording, result_format)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_by_formula_id; 3, parameters; 3, 4; 4, identifier:raw_datasets; 5, block; 5, 6; 5, 13; 5, 32; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:by_formula_id; 9, call; 9, 10; 9, 11; 10, identifier:defaultdict; 11, arg...
def sort_by_formula_id(raw_datasets): by_formula_id = defaultdict(list) for el in raw_datasets: by_formula_id[el['handwriting'].formula_id].append(el['handwriting']) return by_formula_id
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_sorted_pointlist; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 43; 5, 60; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:pointlist; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, ide...
def get_sorted_pointlist(self): pointlist = self.get_pointlist() for i in range(len(pointlist)): pointlist[i] = sorted(pointlist[i], key=lambda p: p['time']) pointlist = sorted(pointlist, key=lambda stroke: stroke[0]['time']) return pointlist
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_name; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:use_alias; 7, True; 8, block; 8, 9; 8, 24; 8, 41; 9, if_statement; 9, 10; 9, 13; 9, 18; 10, attribute; 10, 11; 10, 12; 11, identifier:self;...
def get_name(self, use_alias=True): if self.desc: direction = 'DESC' else: direction = 'ASC' if use_alias: return '{0} {1}'.format(self.field.get_identifier(), direction) return '{0} {1}'.format(self.field.get_select_sql(), direction)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:order_by; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:field; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:table; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, ...
def order_by(self, field=None, table=None, desc=False): self.sorters.append(Sorter( field=field, table=table, desc=desc )) return self
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_by_tag; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:tag; 6, block; 6, 7; 7, return_statement; 7, 8; 8, call; 8, 9; 8, 10; 9, identifier:AmpalContainer; 10, argument_list; 10, 11; 11, call; 11, 12; 11, 13; 12, identifier:so...
def sort_by_tag(self, tag): return AmpalContainer(sorted(self, key=lambda x: x.tags[tag]))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:fit_heptad_register; 3, parameters; 3, 4; 4, identifier:crangles; 5, block; 5, 6; 5, 21; 5, 45; 5, 70; 5, 79; 5, 88; 5, 92; 5, 146; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:crangles; 9, list_comprehension; 9, 10; ...
def fit_heptad_register(crangles): crangles = [x if x > 0 else 360 + x for x in crangles] hept_p = [x * (360.0 / 7.0) + ((360.0 / 7.0) / 2.0) for x in range(7)] ideal_crangs = [ hept_p[0], hept_p[2], hept_p[4], hept_p[6], hept_p[1], hept_p[3], hept_p[5...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:simplify; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 13; 5, 27; 5, 37; 5, 45; 5, 53; 5, 66; 5, 70; 5, 88; 5, 100; 5, 128; 5, 146; 5, 150; 5, 376; 5, 385; 5, 397; 5, 403; 5, 413; 5, 419; 6, if_statement; 6, 7; 6, 10; 7, attribut...
def simplify(self): if self.iscanonical: return self args = [arg.simplify() for arg in self.args] expr = self.__class__(*args) expr = expr.literalize() expr = expr.flatten() if self.annihilator in expr.args: return self.annihilator args = [...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_recordAndPrintHeadline; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:test; 6, identifier:error_class; 7, identifier:artifact; 8, block; 8, 9; 8, 13; 8, 62; 8, 83; 8, 90; 8, 104; 9, expression_statement; 9, 10; 10, a...
def _recordAndPrintHeadline(self, test, error_class, artifact): is_error_class = False for cls, (storage, label, is_failure) in self.errorClasses.items(): if isclass(error_class) and issubclass(error_class, cls): if is_failure: test.passed = False ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_decode_filename_to_unicode; 3, parameters; 3, 4; 4, identifier:f; 5, block; 5, 6; 5, 8; 5, 19; 5, 28; 6, expression_statement; 6, 7; 7, string:'''Get bytestring filename and return unicode. First, try to decode from default file system enc...
def _decode_filename_to_unicode(f): '''Get bytestring filename and return unicode. First, try to decode from default file system encoding If that fails, use ``chardet`` module to guess encoding. As a last resort, try to decode as utf-8. If the argument already is unicode, return as is''' log.deb...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sortBy; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:val; 7, None; 8, block; 8, 9; 9, if_statement; 9, 10; 9, 13; 9, 66; 10, comparison_operator:is; 10, 11; 10, 12; 11, identifier:val; 12, None;...
def sortBy(self, val=None): if val is not None: if _(val).isString(): return self._wrap(sorted(self.obj, key=lambda x, *args: x.get(val))) else: return self._wrap(sorted(self.obj, key=val)) else: return...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:sortedIndex; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:obj; 6, default_parameter; 6, 7; 6, 8; 7, identifier:iterator; 8, lambda; 8, 9; 8, 11; 9, lambda_parameters; 9, 10; 10, identifier:x; 11, identifier:x; 12, block; ...
def sortedIndex(self, obj, iterator=lambda x: x): array = self.obj value = iterator(obj) low = 0 high = len(array) while low < high: mid = (low + high) >> 1 if iterator(array[mid]) < value: low = mid + 1 else: hi...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:uniq; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:isSorted; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:iterator; 10, None; 11, block; 11, 12; 11, 20; 11, 26; 11, 34; 11, ...
def uniq(self, isSorted=False, iterator=None): ns = self.Namespace() ns.results = [] ns.array = self.obj initial = self.obj if iterator is not None: initial = _(ns.array).map(iterator) def by(memo, value, index): if ((_.last(memo) != value or ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:functions; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 42; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:names; 9, list:[]; 10, for_statement; 10, 11; 10, 14; 10, 20; 11, pattern_list; 11, 12; 11...
def functions(self): names = [] for i, k in enumerate(self.obj): if _(self.obj[k]).isCallable(): names.append(k) return self._wrap(sorted(names))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:createMSBWTFromBam; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:bamFNs; 5, identifier:outputDir; 6, identifier:numProcs; 7, identifier:areUniform; 8, identifier:logger; 9, block; 9, 10; 9, 12; 9, 19; 9, 25; 9, 31; 9, 37; 9, 43; 9...
def createMSBWTFromBam(bamFNs, outputDir, numProcs, areUniform, logger): ''' This function takes a fasta filename and creates the BWT using the technique from Cox and Bauer @param bamFNs - a list of BAM filenames to extract sequences from, READS MUST BE SORTED BY NAME @param outputDir - the directory fo...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:append_responder; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 8; 4, identifier:self; 5, identifier:matcher; 6, list_splat_pattern; 6, 7; 7, identifier:args; 8, dictionary_splat_pattern; 8, 9; 9, identifier:kwargs; 10, block; 10, 11; 11, return_stateme...
def append_responder(self, matcher, *args, **kwargs): return self._insert_responder("bottom", matcher, *args, **kwargs)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:unique_list_dicts; 3, parameters; 3, 4; 3, 5; 4, identifier:dlist; 5, identifier:key; 6, block; 6, 7; 7, return_statement; 7, 8; 8, call; 8, 9; 8, 10; 9, identifier:list; 10, argument_list; 10, 11; 11, call; 11, 12; 11, 25; 12, attribute; 12, 1...
def unique_list_dicts(dlist, key): return list(dict((val[key], val) for val in dlist).values())
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_get_bmu; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:activations; 6, block; 6, 7; 6, 19; 6, 29; 7, if_statement; 7, 8; 7, 13; 8, comparison_operator:==; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, identif...
def _get_bmu(self, activations): if self.argfunc == 'argmax': activations = -activations sort = np.argsort(activations, 1) return sort.argsort()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:sort_versions; 3, parameters; 3, 4; 3, 7; 3, 10; 4, default_parameter; 4, 5; 4, 6; 5, identifier:versions; 6, tuple; 7, default_parameter; 7, 8; 7, 9; 8, identifier:reverse; 9, False; 10, default_parameter; 10, 11; 10, 12; 11, identifier:sep; ...
def sort_versions(versions=(), reverse=False, sep=u'.'): if versions == []: return [] digits = u'0123456789' def toint(x): try: n = int(x) except: n = x return n versions = list(versions) new_versions, alpha, sizes = [], set(), set()...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:make_qq_plot; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:kev; 5, identifier:obs; 6, identifier:mdl; 7, identifier:unit; 8, identifier:key_text; 9, block; 9, 10; 9, 15; 9, 24; 9, 33; 9, 42; 9, 51; 9, 60; 9, 74; 9, 82; 9, 95; 9, 1...
def make_qq_plot(kev, obs, mdl, unit, key_text): import omega as om kev = np.asarray(kev) obs = np.asarray(obs) mdl = np.asarray(mdl) c_obs = np.cumsum(obs) c_mdl = np.cumsum(mdl) mx = max(c_obs[-1], c_mdl[-1]) p = om.RectPlot() p.addXY([0, mx], [0, mx], '1:1') p.addXY(c_mdl, c_o...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:_qr_factor_full; 3, parameters; 3, 4; 3, 5; 4, identifier:a; 5, default_parameter; 5, 6; 5, 7; 6, identifier:dtype; 7, attribute; 7, 8; 7, 9; 8, identifier:np; 9, identifier:float; 10, block; 10, 11; 10, 19; 10, 32; 10, 43; 10, 73; 10, 82; 10,...
def _qr_factor_full(a, dtype=np.float): n, m = a.shape packed, pmut, rdiag, acnorm = \ _manual_qr_factor_packed(a, dtype) r = np.zeros((n, m)) for i in range(n): r[i,:i] = packed[i,:i] r[i,i] = rdiag[i] q = np.eye(m) v = np.empty(m) for i in range(n): v[:] = p...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:_qrd_solve_full; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:a; 5, identifier:b; 6, identifier:ddiag; 7, default_parameter; 7, 8; 7, 9; 8, identifier:dtype; 9, attribute; 9, 10; 9, 11; 10, identifier:np; 11, identifier:float; 12, bloc...
def _qrd_solve_full(a, b, ddiag, dtype=np.float): a = np.asarray(a, dtype) b = np.asarray(b, dtype) ddiag = np.asarray(ddiag, dtype) n, m = a.shape assert m >= n assert b.shape == (m, ) assert ddiag.shape == (n, ) q, r, pmut = _qr_factor_full(a) bqt = np.dot(b, q.T) x, s = _manua...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:concat; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:invises; 5, identifier:outvis; 6, default_parameter; 6, 7; 6, 8; 7, identifier:timesort; 8, False; 9, block; 9, 10; 9, 20; 9, 30; 9, 47; 9, 69; 9, 81; 9, 97; 9, 103; 9, 116; 9, 148; 9, 160;...
def concat(invises, outvis, timesort=False): tb = util.tools.table() ms = util.tools.ms() if os.path.exists(outvis): raise RuntimeError('output "%s" already exists' % outvis) for invis in invises: if not os.path.isdir(invis): raise RuntimeError('input "%s" does not exist' % i...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:get_zones_of_account; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:account_name; 6, default_parameter; 6, 7; 6, 8; 7, identifier:q; 8, None; 9, dictionary_splat_pattern; 9, 10; 10, identifier:kwargs; 11, block; 11, ...
def get_zones_of_account(self, account_name, q=None, **kwargs): uri = "/v1/accounts/" + account_name + "/zones" params = build_params(q, kwargs) return self.rest_api_connection.get(uri, params)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:get_zones; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:q; 7, None; 8, dictionary_splat_pattern; 8, 9; 9, identifier:kwargs; 10, block; 10, 11; 10, 15; 10, 23; 11, expression_statement; 1...
def get_zones(self, q=None, **kwargs): uri = "/v1/zones" params = build_params(q, kwargs) return self.rest_api_connection.get(uri, params)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:get_rrsets; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:zone_name; 6, default_parameter; 6, 7; 6, 8; 7, identifier:q; 8, None; 9, dictionary_splat_pattern; 9, 10; 10, identifier:kwargs; 11, block; 11, 12; 11, 20; 1...
def get_rrsets(self, zone_name, q=None, **kwargs): uri = "/v1/zones/" + zone_name + "/rrsets" params = build_params(q, kwargs) return self.rest_api_connection.get(uri, params)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:nested_tuple; 3, parameters; 3, 4; 4, identifier:container; 5, block; 5, 6; 5, 26; 5, 49; 5, 107; 6, if_statement; 6, 7; 6, 12; 7, call; 7, 8; 7, 9; 8, identifier:isinstance; 9, argument_list; 9, 10; 9, 11; 10, identifier:container; 11, identif...
def nested_tuple(container): if isinstance(container, OrderedDict): return tuple(map(nested_tuple, container.items())) if isinstance(container, Mapping): return tuple(sorted_if_possible(map(nested_tuple, container.items()))) if not isinstance(container, (str, bytes)): if isinstance(c...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_ranges_key; 3, parameters; 3, 4; 3, 5; 4, identifier:r; 5, identifier:delta_indices; 6, block; 6, 7; 6, 13; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:idx; 10, attribute; 10, 11; 10, 12; 11, identifier:r; 12, iden...
def _ranges_key(r, delta_indices): idx = r.index_symbol if idx in delta_indices: return (r.index_symbol.primed, r.index_symbol.name) else: return (0, ' ')
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:plot; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:x; 6, default_parameter; 6, 7; 6, 8; 7, identifier:row_order; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:imshow_kwargs; 11, None; 12, defaul...
def plot(self, x, row_order=None, imshow_kwargs=None, strip=True): nrows = self.diffed_array.shape[0] if row_order is None: row_order = np.arange(nrows) extent = (min(x), max(x), 0, nrows) axes_info = metaseq.plotutils.matrix_and_line_shell(strip=strip) fig, matrix_ax...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_restricted_growth_notation; 3, parameters; 3, 4; 4, identifier:l; 5, block; 5, 6; 5, 13; 5, 20; 5, 38; 5, 45; 5, 74; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:list_length; 9, call; 9, 10; 9, 11; 10, identifier:len...
def _restricted_growth_notation(l): list_length = len(l) d = defaultdict(list) for (i, element) in enumerate(l): d[element].append(i) l2 = [None] * list_length for (name, index_list) in enumerate(sorted(d.values(), key=min)): for index in index_list: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:insort_no_dup; 3, parameters; 3, 4; 3, 5; 4, identifier:lst; 5, identifier:item; 6, block; 6, 7; 6, 10; 6, 20; 7, import_statement; 7, 8; 8, dotted_name; 8, 9; 9, identifier:bisect; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, ...
def insort_no_dup(lst, item): import bisect ix = bisect.bisect_left(lst, item) if lst[ix] != item: lst[ix:ix] = [item]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:records; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, return_statement; 6, 7; 7, list_comprehension; 7, 8; 7, 13; 8, subscript; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, identifier:_records; 12, identifier...
def records(self): return [self._records[i] for i in range(len(self._records))]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:score; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:phone_number; 6, identifier:account_lifecycle_event; 7, dictionary_splat_pattern; 7, 8; 8, identifier:params; 9, block; 9, 10; 10, return_statement; 10, 11; 11, cal...
def score(self, phone_number, account_lifecycle_event, **params): return self.post(SCORE_RESOURCE.format(phone_number=phone_number), account_lifecycle_event=account_lifecycle_event, **params)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sorted_members; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 26; 5, 57; 5, 83; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:members; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, iden...
def sorted_members(self): members = collections.OrderedDict() required_names = self.metadata.get("required", ()) for name, shape in self.members.items(): members[name] = AbShapeMember(name=name, shape=shape, is_required=name in required_names) if self.is_output_shape: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:threshold_brier_score; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:observations; 5, identifier:forecasts; 6, identifier:threshold; 7, default_parameter; 7, 8; 7, 9; 8, identifier:issorted; 9, False; 10, default_parameter; 10, 1...
def threshold_brier_score(observations, forecasts, threshold, issorted=False, axis=-1): observations = np.asarray(observations) threshold = np.asarray(threshold) forecasts = np.asarray(forecasts) if axis != -1: forecasts = move_axis_to_end(forecasts, axis) if foreca...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:run; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:N; 7, integer:1; 8, default_parameter; 8, 9; 8, 10; 9, identifier:trace_sort; 10, False; 11, block; 11, 12; 11, 14; 11, 21; 12, expressio...
def run(self, N=1, trace_sort=False): '''Run the sampler, store the history of visited points into the member variable ``self.samples`` and the importance weights into ``self.weights``. .. seealso:: :py:class:`pypmc.tools.History` :param N: Integer; the nu...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_get_samples; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:N; 6, identifier:trace_sort; 7, block; 7, 8; 7, 19; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:this_run; 11, call; 11, 12; 11, 17; ...
def _get_samples(self, N, trace_sort): this_run = self.samples.append(N) if trace_sort: this_run[:], origin = self.proposal.propose(N, self.rng, trace=True, shuffle=False) return this_run, origin else: this_run[:] = self.proposal.propose(N, self.rng) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:argsort_indices; 3, parameters; 3, 4; 3, 5; 4, identifier:a; 5, default_parameter; 5, 6; 5, 7; 6, identifier:axis; 7, unary_operator:-; 7, 8; 8, integer:1; 9, block; 9, 10; 9, 19; 9, 43; 9, 54; 10, expression_statement; 10, 11; 11, assignment; ...
def argsort_indices(a, axis=-1): a = np.asarray(a) ind = list(np.ix_(*[np.arange(d) for d in a.shape])) ind[axis] = a.argsort(axis) return tuple(ind)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sorted; 3, parameters; 3, 4; 4, identifier:collection; 5, block; 5, 6; 5, 16; 5, 40; 5, 99; 6, if_statement; 6, 7; 6, 13; 7, comparison_operator:<; 7, 8; 7, 12; 8, call; 8, 9; 8, 10; 9, identifier:len; 10, argument_list; 10, 11; 11, identifier:...
def sorted(collection): if len(collection) < 1: return collection if isinstance(collection, dict): return sorted(collection.items(), key=lambda x: x[0]) if isinstance(list(collection)[0], Operation): key = lambda x: x.operation_id elif isinstance(list(...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:get_schemas; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:cls; 5, default_parameter; 5, 6; 5, 7; 6, identifier:schema_types; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sort; 10, True; 11, block; 11, 12; 11, 32; 11, 50; 11, 66;...
def get_schemas(cls, schema_types=None, sort=True): result = filter(lambda x: not x.is_inline_array, cls._schemas.values()) if schema_types: result = filter(lambda x: x.schema_type in schema_types, result) if sort: result = sorted(result, key=attrgetter('name')) r...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:to_molden; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:cartesian_list; 5, default_parameter; 5, 6; 5, 7; 6, identifier:buf; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sort_index; 10, True; 11, default_parameter;...
def to_molden(cartesian_list, buf=None, sort_index=True, overwrite=True, float_format='{:.6f}'.format): if sort_index: cartesian_list = [molecule.sort_index() for molecule in cartesian_list] give_header = ("[MOLDEN FORMAT]\n" + "[N_GEO]\n" + str(len(ca...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_inertia; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 143; 5, 152; 5, 162; 5, 172; 5, 181; 5, 190; 6, function_definition; 6, 7; 6, 8; 6, 10; 7, function_name:calculate_inertia_tensor; 8, parameters; 8, 9; 9, identifier:molec...
def get_inertia(self): def calculate_inertia_tensor(molecule): masses = molecule.loc[:, 'mass'].values pos = molecule.loc[:, ['x', 'y', 'z']].values inertia = np.sum( masses[:, None, None] * ((pos**2).sum(axis=1)[:, None, None] ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 25; 2, function_name:to_xyz; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 22; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:buf; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sort_index; 10, True; 11, default_parameter...
def to_xyz(self, buf=None, sort_index=True, index=False, header=False, float_format='{:.6f}'.format, overwrite=True): if sort_index: molecule_string = self.sort_index().to_string( header=header, index=index, float_format=float_format) else: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:priority; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 23; 6, if_statement; 6, 7; 6, 16; 7, comparison_operator:==; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:compiled_type; 11, attribute; 11, 12; ...
def priority(self): if self.compiled_type == const.COMPILED_TYPE.MARKER: return self.compiled.priority return const.compiled_type_priorities[self.compiled_type]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_schemas; 3, parameters; 3, 4; 3, 5; 4, identifier:cls; 5, identifier:schemas_list; 6, block; 6, 7; 7, return_statement; 7, 8; 8, call; 8, 9; 8, 10; 9, identifier:sorted; 10, argument_list; 10, 11; 10, 12; 10, 39; 11, identifier:schemas_lis...
def sort_schemas(cls, schemas_list): return sorted(schemas_list, key=lambda x: ( x.priority, x.compiled.key_schema.priority if x.compiled_type == const.COMPILED_TYPE.MARKER else 0 ), reverse=True)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:patch_cursor; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:cursor; 5, default_parameter; 5, 6; 5, 7; 6, identifier:batch_size; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:limit; 10, None; 11, default_parame...
def patch_cursor(cursor, batch_size=None, limit=None, skip=None, sort=None, **kwargs): if type(batch_size) == int: cursor.batch_size(batch_size) if limit is not None: cursor.limit(limit) if sort is not None: cursor.sort(sort) if skip is not None: cursor.skip(skip)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:add_interval; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:start; 6, identifier:end; 7, default_parameter; 7, 8; 7, 9; 8, identifier:data; 9, None; 10, block; 10, 11; 10, 13; 10, 22; 11, expression_statement; 11, 12...
def add_interval(self, start, end, data=None): ''' Inserts an interval to the tree. Note that when inserting we do not maintain appropriate sorting of the "mid" data structure. This should be done after all intervals are inserted. ''' if (end - start) <= 0: r...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:parse; 3, parameters; 3, 4; 3, 5; 4, identifier:cls; 5, identifier:querydict; 6, block; 6, 7; 6, 49; 6, 129; 7, for_statement; 7, 8; 7, 9; 7, 14; 8, identifier:key; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:querydict;...
def parse(cls, querydict): for key in querydict.keys(): if not any((key in JSONAPIQueryDict._fields, cls.RE_FIELDS.match(key))): msg = "Query parameter {} is not known".format(key) raise ValueError(msg) result = JSONAPIQueryDict( ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_pcca_connected_isa; 3, parameters; 3, 4; 3, 5; 4, identifier:evec; 5, identifier:n_clusters; 6, block; 6, 7; 6, 15; 6, 46; 6, 73; 6, 82; 6, 91; 6, 105; 6, 114; 6, 118; 6, 132; 6, 172; 6, 181; 6, 290; 6, 303; 6, 313; 7, expression_statement; 7,...
def _pcca_connected_isa(evec, n_clusters): (n, m) = evec.shape if n_clusters > m: raise ValueError("Cannot cluster the (" + str(n) + " x " + str(m) + " eigenvector matrix to " + str(n_clusters) + " clusters.") diffs = np.abs(np.max(evec, axis=0) - np.min(evec, axis=0)) a...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_opt_soft; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:eigvectors; 5, identifier:rot_matrix; 6, identifier:n_clusters; 7, block; 7, 8; 7, 18; 7, 32; 7, 40; 7, 52; 7, 119; 7, 125; 7, 140; 7, 152; 7, 160; 8, expression_statement; 8, 9; 9, assi...
def _opt_soft(eigvectors, rot_matrix, n_clusters): eigvectors = eigvectors[:, :n_clusters] rot_crop_matrix = rot_matrix[1:][:, 1:] (x, y) = rot_crop_matrix.shape rot_crop_vec = np.reshape(rot_crop_matrix, x * y) def susanna_func(rot_crop_vec, eigvectors): rot_crop_matrix = np.reshape(rot_cro...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:connected_sets; 3, parameters; 3, 4; 3, 5; 4, identifier:C; 5, default_parameter; 5, 6; 5, 7; 6, identifier:directed; 7, True; 8, block; 8, 9; 8, 11; 9, expression_statement; 9, 10; 10, identifier:r; 11, if_statement; 11, 12; 11, 16; 11, 32; 12...
def connected_sets(C, directed=True): r if isdense(C): return sparse.connectivity.connected_sets(csr_matrix(C), directed=directed) else: return sparse.connectivity.connected_sets(C, directed=directed)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:zcount; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:name; 6, identifier:score_start; 7, identifier:score_end; 8, block; 8, 9; 8, 17; 8, 25; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identif...
def zcount(self, name, score_start, score_end): score_start = get_integer_or_emptystring('score_start', score_start) score_end = get_integer_or_emptystring('score_end', score_end) return self.execute_command('zcount', name, score_start, score_end)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:reload_index; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:progress_cb; 7, identifier:dummy_progress_cb; 8, block; 8, 9; 8, 19; 8, 23; 8, 45; 8, 54; 9, expression_statement; 9, 10; 10, assignmen...
def reload_index(self, progress_cb=dummy_progress_cb): nb_results = self.index.start_reload_index() progress = 0 while self.index.continue_reload_index(): progress_cb(progress, nb_results, self.INDEX_STEP_LOADING) progress += 1 progress_cb(1, 1, self.INDEX_STEP_LO...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:__doc_cmp; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:other; 6, block; 6, 7; 6, 15; 6, 26; 7, if_statement; 7, 8; 7, 11; 8, comparison_operator:is; 8, 9; 8, 10; 9, identifier:other; 10, None; 11, block; 11, 12; 12, return_stat...
def __doc_cmp(self, other): if other is None: return -1 if self.is_new and other.is_new: return 0 if self.__docid < other.__docid: return -1 elif self.__docid == other.__docid: return 0 else: return 1
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:__label_cmp; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:other; 6, block; 6, 7; 6, 15; 6, 28; 6, 41; 6, 60; 7, if_statement; 7, 8; 7, 11; 8, comparison_operator:is; 8, 9; 8, 10; 9, identifier:other; 10, None; 11, block; 11, 12;...
def __label_cmp(self, other): if other is None: return -1 label_name = strip_accents(self.name).lower() other_name = strip_accents(other.name).lower() if label_name < other_name: return -1 elif label_name == other_name: return 0 else: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:stop_sequence; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, return_statement; 6, 7; 7, call; 7, 8; 7, 9; 8, identifier:sorted; 9, argument_list; 9, 10; 9, 15; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifie...
def stop_sequence(self): return sorted( self.stop_times(), key=lambda x:int(x.get('stop_sequence')) )
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:near; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 12; 3, 15; 4, identifier:cls; 5, identifier:collection; 6, identifier:latitude; 7, identifier:longitude; 8, identifier:index_id; 9, default_parameter; 9, 10; 9, 11; 10, identifier:dis...
def near(cls, collection, latitude, longitude, index_id, distance=None, skip=None, limit=None): kwargs = { 'geo': index_id, 'latitude': latitude, 'longitude': longitude, 'distance': distance, 'skip': skip, 'limit': limit, } ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:rank_targets; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:sample_frame; 5, identifier:ref_targets; 6, identifier:ref_sample; 7, block; 7, 8; 7, 17; 7, 27; 7, 42; 7, 49; 7, 56; 7, 60; 7, 64; 7, 185; 7, 194; 7, 200; 7, 206; 7, 215; 8, expressi...
def rank_targets(sample_frame, ref_targets, ref_sample): table = collect_expression(sample_frame, ref_targets, ref_sample) all_samples = sample_frame['Sample'].unique() t = table.groupby(['Sample', 'Target']).mean() logt = log2(t) ref_targets = set(ref_targets) worst = [] worst_m = [] wh...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:natural_sort_key; 3, parameters; 3, 4; 4, identifier:s; 5, block; 5, 6; 6, return_statement; 6, 7; 7, list_comprehension; 7, 8; 7, 19; 8, conditional_expression:if; 8, 9; 8, 13; 8, 18; 9, call; 9, 10; 9, 11; 10, identifier:int; 11, argument_lis...
def natural_sort_key(s): return [int(text) if text.isdigit() else text for text in re.split(INTEGER_RE, str(s))]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:relabel_nodes; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:G; 5, identifier:mapping; 6, default_parameter; 6, 7; 6, 8; 7, identifier:copy; 8, True; 9, block; 9, 10; 9, 39; 10, if_statement; 10, 11; 10, 17; 10, 33; 11, not_operator; 11, 12; 1...
def relabel_nodes(G, mapping, copy=True): if not hasattr(mapping, "__getitem__"): m = dict((n, mapping(n)) for n in G) else: m = mapping if copy: return _relabel_copy(G, m) else: return _relabel_inplace(G, m)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:convert_node_labels_to_integers; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:G; 5, default_parameter; 5, 6; 5, 7; 6, identifier:first_label; 7, integer:0; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ordering; 10, string:"default...
def convert_node_labels_to_integers(G, first_label=0, ordering="default", label_attribute=None): N = G.number_of_nodes() + first_label if ordering == "default": mapping = dict(zip(G.nodes(), range(first_label, N))) elif ordering == "sorted": nlist = G.node...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_token_ids; 3, parameters; 3, 4; 4, identifier:tree; 5, block; 5, 6; 5, 22; 5, 31; 6, function_definition; 6, 7; 6, 8; 6, 10; 7, function_name:tok2time; 8, parameters; 8, 9; 9, identifier:token_element; 10, block; 10, 11; 10, 13; 11, express...
def get_token_ids(tree): def tok2time(token_element): ''' extracts the time (float) of a <tli> element (i.e. the absolute position of a token in the document) ''' return float(token_element.attrib['time']) timeline = tree.find('//common-timelin...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_span; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:docgraph; 5, identifier:node_id; 6, default_parameter; 6, 7; 6, 8; 7, identifier:debug; 8, False; 9, block; 9, 10; 9, 38; 9, 42; 9, 62; 9, 103; 10, if_statement; 10, 11; 10, 21; 11, boole...
def get_span(docgraph, node_id, debug=False): if debug is True and is_directed_acyclic_graph(docgraph) is False: warnings.warn( ("Can't reliably extract span '{0}' from cyclical graph'{1}'." "Maximum recursion depth may be exceeded.").format(node_id, ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_get_terminals_and_nonterminals; 3, parameters; 3, 4; 4, identifier:sentence_graph; 5, block; 5, 6; 5, 12; 5, 18; 5, 52; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:terminals; 9, call; 9, 10; 9, 11; 10, identifier:se...
def _get_terminals_and_nonterminals(sentence_graph): terminals = set() nonterminals = set() for node_id in sentence_graph.nodes_iter(): if sentence_graph.out_degree(node_id) > 0: nonterminals.add(node_id) else: terminals.add(node_id) return sorted(list(terminals),...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:print_sorted_counter; 3, parameters; 3, 4; 3, 5; 4, identifier:counter; 5, default_parameter; 5, 6; 5, 7; 6, identifier:tab; 7, integer:1; 8, block; 8, 9; 9, for_statement; 9, 10; 9, 13; 9, 30; 10, pattern_list; 10, 11; 10, 12; 11, identifier:k...
def print_sorted_counter(counter, tab=1): for key, count in sorted(counter.items(), key=itemgetter(1), reverse=True): print "{0}{1} - {2}".format('\t'*tab, key, count)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sorted_bfs_edges; 3, parameters; 3, 4; 3, 5; 4, identifier:G; 5, default_parameter; 5, 6; 5, 7; 6, identifier:source; 7, None; 8, block; 8, 9; 8, 20; 8, 28; 8, 36; 8, 44; 8, 68; 9, if_statement; 9, 10; 9, 13; 10, comparison_operator:is; 10, 11;...
def sorted_bfs_edges(G, source=None): if source is None: source = G.root xpos = horizontal_positions(G, source) visited = set([source]) source_children = get_child_nodes(G, source) queue = deque([(source, iter(sorted(source_children, key=lambda x: xpos...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sorted_bfs_successors; 3, parameters; 3, 4; 3, 5; 4, identifier:G; 5, default_parameter; 5, 6; 5, 7; 6, identifier:source; 7, None; 8, block; 8, 9; 8, 20; 8, 27; 8, 46; 9, if_statement; 9, 10; 9, 13; 10, comparison_operator:is; 10, 11; 10, 12; ...
def sorted_bfs_successors(G, source=None): if source is None: source = G.root successors = defaultdict(list) for src, target in sorted_bfs_edges(G, source): successors[src].append(target) return dict(successors)