sequence
stringlengths
546
16.2k
code
stringlengths
108
19.3k
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, 12; 9, 24; 9, 31; 9, 38; 9, 47; 9, 56; 9, 57; 9,...
def _findRedundantProteins(protToPeps, pepToProts, proteins=None): """Returns a set of proteins with redundant peptide evidence. After removing the redundant proteins from the "protToPeps" and "pepToProts" mapping, all remaining proteins have at least one unique peptide. The remaining proteins are a "m...
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, 9; 6, 16; 6, 49; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12...
def _mergeProteinEntries(proteinLists, protToPeps): """Returns a new "protToPeps" dictionary with entries merged that are present in proteinLists. NOTE: The key of the merged entry is a tuple of the sorted protein keys. This behaviour might change in the future; the tuple might be replaced ...
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): """Do structured list output. Sorts the list by date, possibly reversed, filtered from 'since'. The returned list is: foldername, message key, message object """ folder = self.folder \ if foldername == ...
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; 5, 8; 6, expression_statement; 6, 7; 7, comment; 8, return_statement; 8, 9; 9, call; 9, 10; 9, 11; 10, identifier:sorted; 11, argument_list; 11, 12; 11, 15; 11, 20; 12, attr...
def sort_entries(self): """Get whether reverse is True or False. Return the sorted data.""" 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): """Returns a modification description of a certain label state of a peptide. :param peptide: Peptide sequence used to calculat the expected label state modifications :param labelStateInfo...
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, 9; 6, 31; 7, expression_statement; 7, 8; 8, comment; 9, if_statement; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, identifier...
def rank(self, member): """ Gets the ASC rank of @member from the sorted set, that is, lower scores have lower ranks """ if self.reversed: return self._client.zrevrank(self.key_prefix, self._dumps(member)) return self._client.zrank(self.key_prefix, self._dumps(mem...
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): """Prepares the ``siiContainer`` for the import of peptide spectrum matching results. Adds entries to ``siiContainer.container`` and to ``siiContainer.info``. :param si...
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]: """ This find_nearest function does NOT assume sorted input inputs: x: array (float, int, datetime, h5py.Dataset) within which to search for x0 x0: singleton or array of values to search for in x outputs: idx: index of flattened x nearest to x0 ...
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; 8, 11; 9, expression_statement; 9, 10; 10, comment; 11, for_statement; 11, 12; 11,...
def primary_mrna(entrystream, parenttype='gene'): """ Select a single mRNA as a representative for each protein-coding gene. The primary mRNA is the one with the longest translation product. In cases where multiple isoforms have the same translated length, the feature ID is used for sorting. T...
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, 11; 8, 30; 8, 42; 8, 56; 8, 71; 8, 131; 9, expression_statement; 9, 10; 10, comment; 11, expression_...
def notes(self, public_only=False): """ Retrieve a list of Note instances that should be shown for this release, grouped as either new features or known issues, and sorted first by sort_num highest to lowest and then by created date, which is applied to both groups, and t...
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'): """Find dispatches by certain criteria. Parameters ---------- author : str Name of the nation authoring the dispatch. category : str Dispatch's prima...
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, 13; 10, 14; 10, 20; 10, 21; 10, 49; 10, 50; 10, 57; 1...
def have_cycle(graph:dict) -> frozenset: """Perform a topologic sort to detect any cycle. Return the set of unsortable nodes. If at least one item, then there is cycle in given graph. """ # topological sort walked = set() # walked nodes nodes = frozenset(it.chain(it.chain.from_iterable(gr...
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, 57; 7, 58; 7, 69; 7, 70; 7, 74; 7, 78; 7, 206; 7, 207; 7, 208; 7, 215; 7, 222; 7, 232; 7, 233; ...
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 iterab...
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, 9; 6, 19; 6, 42; 6, 45; 6, 53; 6, 68; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10,...
def _get_sorted_iterator(self, iterator): """ Get the iterator over the sorted items. This function decides whether the items can be sorted in memory or on disk. :return: """ lines = list(next(iterator)) if len(lines) < self.max_lines: return iter(sor...
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, 10; 7, 14; 7, 77; 8, expression_statement; 8, 9; 9, comment; 10, expression_statement; 10, 11; 11, assignment; 11, 12...
def _split(self, iterator, tmp_dir): """ Splits the file into several chunks. If the original file is too big to fit in the allocated space, the sorting will be split into several chunks, then merged. :param tmp_dir: Where to put the intermediate sorted results. :param o...
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; 7, 10; 8, expression_statement; 8, 9; 9, comment; 10, with_statement; 10, 11; 10, 21; 11, with_clause; 11, 12; 12, with_item;...
def _write(self, lines, fname): """ Writes a intermediate temporary sorted file :param lines: The lines to write. :param fname: The name of the temporary file. :return: """ with open(fname, 'wb') as out_fhndl: for line in sorted(lines, key=self.key): ...
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, 10; 7, 21; 8, expression_statement; 8, 9; 9, comment; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 15; 1...
def add(self, interval, offset): """ The added interval must be overlapping or beyond the last stored interval ie. added in sorted order. :param interval: interval to add :param offset: full virtual offset to add :return: """ start, stop = self.get_start_stop(int...
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): """ This is a python generator that yields tweets stored in a mongodb collection. Tweet "created_at" field is assumed to have been stored in the format supported by MongoDB. Inputs: - client: A py...
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, 12; 9, 29; 9, 46; 10, expression_statement; 10, 11; 11, com...
def save(self, *args, **kwargs): """ Store a string representation of content_object as target and actor name for fast retrieval and sorting. """ if not self.target: self.target = str(self.content_object) if not self.actor_name: self.actor_name = s...
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, 8; 5, 58; 6, expression_statement; 6, 7; 7, comment; 8, function_definition; 8, 9; 8, 10; 8, 13; 9, function_name:compare; 10, parameters; 10, 11; 10, 12; 11, identifier...
def _sort_modules(mods): """ Always sort `index` or `README` as first filename in list. """ 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 ...
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, 9; 6, 13; 6, 17; 6, 81; 6, 85; 6, 111; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10...
def _sort_results(self, results): """ Order the results. :param results: The disordened results. :type results: array.bs4.element.Tag :return: The ordened results. :rtype: array.bs4.element.Tag """ parents = [] groups = [] for result in r...
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, 8; 5, 14; 5, 20; 5, 26; 5, 32; 5, 84; 5, 94; 5, 109; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identif...
def _update_sorting(self): """ Insert new entries into the merged iterator. :param sorted_tops: A SortedDict. :param tops: The most recent entry from each iterator. :param idxs: The indices to update. """ key = self.key sorted_tops = self.sorted_tops tops...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 1, 5; 2, function_name:domain_user_stats; 3, parameters; 4, comment; 5, block; 5, 6; 5, 8; 5, 27; 5, 45; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:fname; 11, call; 11, 12; 11, 17; 12, a...
def domain_user_stats(): # type: () -> pd.Series """ Get number of distinct email addresses in observed domains TODO: get up to date with new projects layout How to build email_domain_users.csv: from collections import defaultdict import logging from common import utils as common impor...
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, 8; 5, 12; 5, 22; 5, 35; 5, 78; 5, 79; 5, 96; 5, 97; 5, 113; 5, 160; 5, 182; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; ...
def _topological_sort(self): """ Kahn's algorithm for Topological Sorting - Finds cycles in graph - Computes dependency weight """ sorted_graph = [] node_map = self._graph.get_nodes() nodes = [NodeVisitor(node_map[node]) for node in node_map] def...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 1, 9; 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, comment; 9, block; 9, 10; 9, 12; 9, 19; 9, 30; 9, 42; 10, expression_statement; 10, 11; 11, string:''' Returns a ...
def plugins(group, spec=None): # TODO: share this documentation with `../doc/plugin.rst`... ''' 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 ...
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): """Attempts to match each string in strings in order. Will return the string that matches or an empty string if no match. If word arg >= 1 then only match if string is followed by a whitespace which is much higher performance. ...
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, 11; 8, 12; 8, 21; 8, 35; 8, ...
def decide_which_users_to_annotate(centrality_vector, number_to_annotate, already_annotated, node_to_id): """ Sorts a centrality vector and returns the Twitter user ids that are to be annotated. Inputs:...
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; 7, 10; 8, expression_statement; 8, 9; 9, comment; 10, expression_statement; 10, 11; 11, call; 11, 12; 11, 13; ...
def set_attribute_string(target, name, value): """ Sets an attribute to a string on a Dataset or Group. If the attribute `name` doesn't exist yet, it is created. If it already exists, it is overwritten if it differs from `value`. Notes ----- ``set_attributes_all`` is the fastest way to set and...
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, 8; 5, 14; 5, 18; 5, 40; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:graph; 11, s...
def __calculate_edge_weights(dfs_data): """Calculates the weight of each edge, for embedding-order sorting.""" 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 weight...
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, 8; 5, 12; 5, 18; 5, 24; 5, 30; 5, 126; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier...
def __sort_adjacency_lists(dfs_data): """Sorts the adjacency list representation by the edge weights.""" 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(...
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, 9; 6, 15; 6, 21; 6, 30; 6, 38; 6, 46; 6, 54; 6, 62; 6, 70; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10...
def __edge_weight(edge_id, dfs_data): """Calculates the edge weight used to sort edges.""" 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 =...
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, 13; 8, 24; 9, expression_statement; 9, 10; 10, comment; 11, glob...
def classify_segmented_recording(recording, result_format=None): """Use this function if you are sure you have a single symbol. Parameters ---------- recording : string The recording in JSON format Returns ------- list of dictionaries Each dictionary contains the keys 'symb...
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, 8; 5, 15; 5, 34; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:by_formula_id; 11, ca...
def sort_by_formula_id(raw_datasets): """ Sort a list of formulas by `id`, where `id` represents the accepted formula id. Parameters ---------- raw_datasets : list of dictionaries A list of raw datasets. Examples -------- The parameter `raw_datasets` has to be of the format...
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, 8; 5, 16; 5, 45; 5, 62; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:pointlist; 11, call;...
def get_sorted_pointlist(self): """ Make sure that the points and strokes are in order. Returns ------- list A list of all strokes in the recording. Each stroke is represented as a list of dicts {'time': 123, 'x': 45, 'y': 67} """ pointlis...
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, 11; 8, 26; 8, 43; 9, expression_statement; 9, 10; 10, comment; 11, if_statement; 11, 12; 11, 15; 11,...
def get_name(self, use_alias=True): """ Gets the name to reference the sorted field :return: the name to reference the sorted field :rtype: str """ if self.desc: direction = 'DESC' else: direction = 'ASC' if use_alias: ...
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): """ Adds an order by clause to the query by adding a ``Sorter`` instance to the query's sorters list :type field: str or dict or :class:`Field <querybuilder.fields.Field>` :param field: This can be a string of a field name,...
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; 6, 9; 7, expression_statement; 7, 8; 8, comment; 9, return_statement; 9, 10; 10, call; 10, 11; 10, 12; 11, identifier:AmpalContainer; 12, argument_li...
def sort_by_tag(self, tag): """Sorts the `AmpalContainer` by a tag on the component objects. Parameters ---------- tag : str Key of tag used for sorting. """ 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, 8; 5, 23; 5, 47; 5, 72; 5, 81; 5, 90; 5, 91; 5, 95; 5, 149; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, ...
def fit_heptad_register(crangles): """Attempts to fit a heptad repeat to a set of Crick angles. Parameters ---------- crangles: [float] A list of average Crick angles for the coiled coil. Returns ------- fit_data: [(float, float, float)] Sorted list of fits for each heptad ...
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, 8; 5, 9; 5, 10; 5, 17; 5, 18; 5, 32; 5, 33; 5, 34; 5, 44; 5, 45; 5, 53; 5, 54; 5, 55; 5, 56; 5, 64; 5, 65; 5, 78; 5, 79; 5, 80; 5, 84; 5, 102; 5, 114; 5, 115; 5, 143; 5, 144;...
def simplify(self): """ Return a new simplified expression in canonical form from this expression. For simplification of AND and OR fthe ollowing rules are used recursively bottom up: - Associativity (output does not contain same operations nested) - Annihilati...
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, 11; 8, 12; 8, 13; 8, 14; 8, 18; 8, 67; 8, 88; 8, 95; 8, 109; 9, expres...
def _recordAndPrintHeadline(self, test, error_class, artifact): """Record that an error-like thing occurred, and print a summary. Store ``artifact`` with the record. Return whether the test result is any sort of failure. """ # We duplicate the errorclass handling from super ra...
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.d...
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; 8, 11; 9, expression_statement; 9, 10; 10, comment; 11, if_statement; 11, 12; 11, 15; 11, 68; 12, comparison_op...
def sortBy(self, val=None): """ Sort the object's values by a criterion produced by an iterator. """ if val is not None: if _(val).isString(): return self._wrap(sorted(self.obj, key=lambda x, *args: x.get(val))) else: ...
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): """ Use a comparator function to figure out the smallest index at which an object should be inserted so as to maintain order. Uses binary search. """ array = self.obj value = iterator(obj) low = 0 h...
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, 14; 11, 22; 11, 28; 11, ...
def uniq(self, isSorted=False, iterator=None): """ Produce a duplicate-free version of the array. If the array has already been sorted, you have the option of using a faster algorithm. Aliased as `unique`. """ ns = self.Namespace() ns.results = [] ns.array...
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, 8; 5, 12; 5, 44; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:names; 11, list:[]; 12, for_statement;...
def functions(self): """ Return a sorted list of the function names available on the object. """ 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, 13; 9, 20; 9, 26; 9, 32; 9, 38; 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; 10, 13; 11, expres...
def append_responder(self, matcher, *args, **kwargs): """Add a responder of last resort. Like `.autoresponds`, but instead of adding a responder to the top of the stack, add it to the bottom. This responder will be called if no others match. """ return self._insert_respo...
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; 6, 9; 7, expression_statement; 7, 8; 8, comment; 9, return_statement; 9, 10; 10, call; 10, 11; 10, 12; 11, identifier:list; 12, argument_list;...
def unique_list_dicts(dlist, key): """Return a list of dictionaries which are sorted for only unique entries. :param dlist: :param key: :return list: """ 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, 9; 6, 10; 6, 22; 6, 32; 7, expression_statement; 7, 8; 8, comment; 9, comment; 10, if_statement; 10, 11; 10, 16; 11, comparison_operator:==; ...
def _get_bmu(self, activations): """Get indices of bmus, sorted by their distance from input.""" # If the neural gas is a recursive neural gas, we need reverse argsort. if self.argfunc == 'argmax': activations = -activations sort = np.argsort(activations, 1) return so...
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'.'): """Sort a list of version number strings. This function ensures that the package sorting based on number name is performed correctly when including alpha, dev rc1 etc... """ if versions == []: return [] digits = u'012345...
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, 12; 9, 17; 9, 26; 9, 35; 9, 44; 9, 53; 9, 62; 9, 76; 9, 84; 9, 9...
def make_qq_plot(kev, obs, mdl, unit, key_text): """Make a quantile-quantile plot comparing events and a model. *kev* A 1D, sorted array of event energy bins measured in keV. *obs* A 1D array giving the number or rate of events in each bin. *mdl* A 1D array giving the modeled number 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, 13; 10, 21; 10, 22; 10, 35; 10, 36; 10,...
def _qr_factor_full(a, dtype=np.float): """Compute the QR factorization of a matrix, with pivoting. Parameters: a - An n-by-m arraylike, m >= n. dtype - (optional) The data type to use for computations. Default is np.float. Returns: q - An m-by-m orthogonal matrix (q q^T = ident) r - An n-by-m u...
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): """Solve the equation A^T x = B, D x = 0. Parameters: a - an n-by-m array, m >= n b - an m-vector ddiag - an n-vector giving the diagonal of D. (The rest of D is 0.) Returns: x - n-vector solving the equation. s - the n-by-n supplementary matrix s. p...
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, 12; 9, 22; 9, 32; 9, 49; 9, 71; 9, 83; 9, 99; 9, 105; 9, 118; 9, 150; ...
def concat(invises, outvis, timesort=False): """Concatenate visibility measurement sets. invises (list of str) Paths to the input measurement sets outvis (str) Path to the output measurement set. timesort (boolean) If true, sort the output in time after concatenation. Example:: ...
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): """Returns a list of zones for the specified account. Arguments: account_name -- The name of the account. Keyword Arguments: q -- The search parameters, in a dict. Valid keys are: name - substring mat...
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, 13; 10, 17; 10, 25; 11, expression_stat...
def get_zones(self, q=None, **kwargs): """Returns a list of zones across all of the user's accounts. Keyword Arguments: q -- The search parameters, in a dict. Valid keys are: name - substring match of the zone name zone_type - one of: PRIMARY ...
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, 14; 1...
def get_rrsets(self, zone_name, q=None, **kwargs): """Returns the list of RRSets in the specified zone. Arguments: zone_name -- The name of the zone. Keyword Arguments: q -- The search parameters, in a dict. Valid keys are: ttl - must match the TTL for the rrset ...
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, 8; 5, 28; 5, 51; 5, 109; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 14; 9, call; 9, 10; 9, 11; 10, identifier:isinstance; 11, argument_list...
def nested_tuple(container): """Recursively transform a container structure to a nested tuple. The function understands container types inheriting from the selected abstract base classes in `collections.abc`, and performs the following replacements: `Mapping` `tuple` of key-value pair `tuple`s....
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, 9; 6, 15; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:idx; 12...
def _ranges_key(r, delta_indices): """Sorting key for ranges. When used with ``reverse=True``, this can be used to sort index ranges into the order we would prefer to eliminate them by evaluating KroneckerDeltas: First, eliminate primed indices, then indices names higher in the alphabet. """ id...
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): """ Plot the scaled ChIP-seq data. :param x: X-axis to use (e.g, for TSS +/- 1kb with 100 bins, this would be `np.linspace(-1000, 1000, 100)`) :param row_order: Array-like object containing row order -- typic...
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, 8; 5, 15; 5, 22; 5, 40; 5, 47; 5, 76; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:li...
def _restricted_growth_notation(l): """ The clustering returned by the hcluster module gives group membership without regard for numerical order This function preserves the group membership, but sorts the labelling into numerical order """ list_length = len(l) d = defaultdict(l...
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, 9; 6, 12; 6, 22; 7, expression_statement; 7, 8; 8, comment; 9, import_statement; 9, 10; 10, dotted_name; 10, 11; 11, identifier:bisect; 12, expr...
def insort_no_dup(lst, item): """ If item is not in lst, add item to list at its sorted position """ 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; 5, 8; 6, expression_statement; 6, 7; 7, comment; 8, return_statement; 8, 9; 9, list_comprehension; 9, 10; 9, 15; 10, subscript; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12,...
def records(self): """ Returns a list of records in SORT_KEY order """ 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; 9, 12; 10, expression_statement; 10, ...
def score(self, phone_number, account_lifecycle_event, **params): """ Score is an API that delivers reputation scoring based on phone number intelligence, traffic patterns, machine learning, and a global data consortium. See https://developer.telesign.com/docs/score-api for detailed API...
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, 8; 5, 16; 5, 28; 5, 59; 5, 86; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:members; 11, call; ...
def sorted_members(self): """ Iterate over sorted members of shape in the same order in which the members are declared except yielding the required members before any optional members. """ members = collections.OrderedDict() required_names = self.metadata.get("req...
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): """ Calculate the Brier scores of an ensemble for exceeding given thresholds. According to the threshold decomposition of CRPS, the resulting Brier scores can thus be summed along the last ...
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...
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, 10; 7, 11; 7, 12; 7, 23; 7, 24; 8, expression_statement; 8, 9; 9, comment; 10, comment; 11, comment; 12, expression...
def _get_samples(self, N, trace_sort): """Save N samples from ``self.proposal`` to ``self.samples`` This function does NOT calculate the weights. Return a reference to this run's samples in ``self.samples``. If ``trace_sort`` is True, additionally return an array indicating the ...
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, 12; 9, 21; 9, 45; 9, 56; 10, expression_statement; 10, 11; 11, comme...
def argsort_indices(a, axis=-1): """Like argsort, but returns an index suitable for sorting the the original array even if that array is multidimensional """ 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, 8; 5, 18; 5, 42; 5, 101; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 15; 9, comparison_operator:<; 9, 10; 9, 14; 10, call; 10, 11; 10, 12; 11, id...
def sorted(collection): """ sorting dict by key, schema-collection by schema-name operations by id """ if len(collection) < 1: return collection if isinstance(collection, dict): return sorted(collection.items(), key=lambda x: x[0]) ...
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, 14; 11, 34; 11, 52;...
def get_schemas(cls, schema_types=None, sort=True): """ Get schemas by type. If ``schema_type`` is None, return all schemas :param schema_types: list of schema types :type schema_types: list or None :param bool sort: sort by name :return: list of schemas :rtype: ...
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): """Write a list of Cartesians into a molden file. .. note:: Since it permamently writes a file, this function is strictly speaking **not sideeffect free**. The list to be writte...
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, 8; 5, 145; 5, 154; 5, 164; 5, 174; 5, 183; 5, 192; 6, expression_statement; 6, 7; 7, comment; 8, function_definition; 8, 9; 8, 10; 8, 12; 9, function_name:calculate_inerti...
def get_inertia(self): """Calculate the inertia tensor and transforms along rotation axes. This function calculates the inertia tensor and returns a 4-tuple. The unit is ``amu * length-unit-of-xyz-file**2`` Args: None Returns: dict: The...
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): """Write xyz-file Args: buf (str): StringIO-like, optional buffer to write to sort_index (bool): If sort_index is true, the ...
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, 8; 5, 9; 5, 26; 5, 27; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, if_statement; 9, 10; 9, 19; 10, comparison_operator:==; 10, 11; 10, 14; 11, attribute; 11, 12...
def priority(self): """ Get priority for this Schema. Used to sort mapping keys :rtype: int """ # Markers have priority set on the class if self.compiled_type == const.COMPILED_TYPE.MARKER: return self.compiled.priority # Other types have static pri...
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; 6, 9; 7, expression_statement; 7, 8; 8, comment; 9, return_statement; 9, 10; 10, call; 10, 11; 10, 12; 11, identifier:sorted; 12, argument_l...
def sort_schemas(cls, schemas_list): """ Sort the provided list of schemas according to their priority. This also supports markers, and markers of a single type are also sorted according to the priority of the wrapped schema. :type schemas_list: list[CompiledSchema] :rtype: list[Compil...
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): """ Adds batch_size, limit, sort parameters to a DB cursor """ 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) ...
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, 14; 10, 23; 11, expression_statement...
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. ''' # Ignore intervals of 0 or negative ...
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, 9; 6, 51; 6, 131; 7, expression_statement; 7, 8; 8, comment; 9, for_statement; 9, 10; 9, 11; 9, 16; 10, identifier:key; 11, call; 11, 12; 11, 15; 1...
def parse(cls, querydict): """ Parse querydict data. There are expected agruments: distinct, fields, filter, include, page, sort Parameters ---------- querydict : django.http.request.QueryDict MultiValueDict with query arguments. Returns ...
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, 9; 6, 17; 6, 18; 6, 49; 6, 50; 6, 77; 6, 86; 6, 95; 6, 96; 6, 110; 6, 119; 6, 123; 6, 124; 6, 138; 6, 139; 6, 179; 6, 180; 6, 189; ...
def _pcca_connected_isa(evec, n_clusters): """ PCCA+ spectral clustering method using the inner simplex algorithm. Clusters the first n_cluster eigenvectors of a transition matrix in order to cluster the states. This function assumes that the state space is fully connected, i.e. the transition matrix w...
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, 10; 7, 11; 7, 21; 7, 22; 7, 23; 7, 37; 7, 45; 7, 46; 7, 58; 7, 59; 7, 128; 7, 134; 7, 149; 7, 161; 7, 1...
def _opt_soft(eigvectors, rot_matrix, n_clusters): """ Optimizes the PCCA+ rotation matrix such that the memberships are exclusively nonnegative. Parameters ---------- eigenvectors : ndarray A matrix with the sorted eigenvectors in the columns. The stationary eigenvector should be f...
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, comment; 11, if_statement; 11, 12; 11, 16; 11, 32; 12, cal...
def connected_sets(C, directed=True): r"""Compute connected sets of microstates. Connected components for a directed graph with edge-weights given by the count matrix. Parameters ---------- C : scipy.sparse matrix Count matrix specifying edge weights. directed : bool, optional ...
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, 11; 8, 19; 8, 27; 9, expression_statement; 9, 10; 10, comment; 11, expression_statemen...
def zcount(self, name, score_start, score_end): """ Returns the number of elements in the sorted set at key ``name`` with a score between ``score_start`` and ``score_end``. Like **Redis.ZCOUNT** .. note:: The range is [``score_start``, ``score_end``] :param string name...
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, 11; 8, 21; 8, 25; 8, 47; 8, 56; 9, expression_statement; 9, 10; 10, co...
def reload_index(self, progress_cb=dummy_progress_cb): """ Read the index, and load the document list from it Arguments: callback --- called during the indexation (may be called *often*). step : DocSearch.INDEX_STEP_READING or DocSearch.INDEX_STEP...
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, 9; 6, 17; 6, 28; 7, expression_statement; 7, 8; 8, comment; 9, if_statement; 9, 10; 9, 13; 10, comparison_operator:is; 10, 11; 10, 12; 11, identif...
def __doc_cmp(self, other): """ Comparison function. Can be used to sort docs alphabetically. """ 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...
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, 9; 6, 17; 6, 30; 6, 43; 6, 62; 7, expression_statement; 7, 8; 8, comment; 9, if_statement; 9, 10; 9, 13; 10, comparison_operator:is; 10, 11; 10,...
def __label_cmp(self, other): """ Comparaison function. Can be used to sort labels alphabetically. """ 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:...
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; 5, 8; 6, expression_statement; 6, 7; 7, comment; 8, return_statement; 8, 9; 9, call; 9, 10; 9, 11; 10, identifier:sorted; 11, argument_list; 11, 12; 11, 17; 12, call; 12, 1...
def stop_sequence(self): """Return the sorted StopTimes for this trip.""" 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): """ The default will find at most 100 documents near the given coordinate. The returned list is sorted according to the distance, with the nearest document being first in the list. ...
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, 10; 7, 19; 7, 29; 7, 44; 7, 51; 7, 58; 7, 62; 7, 66; 7, 187; 7, 196; 7, 202; 7, 208; 7, 217; 8, e...
def rank_targets(sample_frame, ref_targets, ref_sample): """Uses the geNorm algorithm to determine the most stably expressed genes from amongst ref_targets in your sample. See Vandesompele et al.'s 2002 Genome Biology paper for information about the algorithm: http://dx.doi.org/10.1186/gb-2002-3-7-rese...
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; 5, 8; 6, expression_statement; 6, 7; 7, comment; 8, return_statement; 8, 9; 9, list_comprehension; 9, 10; 9, 21; 10, conditional_expression:if; 10, 11; 10, 15; 10, 20; 11, ...
def natural_sort_key(s): """ returns a key that can be used in sort functions. Example: >>> items = ['A99', 'a1', 'a2', 'a10', 'a24', 'a12', 'a100'] The normal sort function will ignore the natural order of the integers in the string: >>> print sorted(items) ['A99', 'a1', 'a10', 'a10...
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, 12; 9, 13; 9, 14; 9, 43; 10, expression_statement; 10, 11; 11, comment; 1...
def relabel_nodes(G, mapping, copy=True): """Relabel the nodes of the graph G. Parameters ---------- G : graph A NetworkX graph mapping : dictionary A dictionary with the old labels as keys and new labels as values. A partial mapping is allowed. copy : bool (optional, def...
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): """Return a copy of the graph G with the nodes relabeled with integers. Parameters ---------- G : graph A NetworkX graph first_label : int, optional (default=...
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, 8; 5, 24; 5, 33; 6, expression_statement; 6, 7; 7, comment; 8, function_definition; 8, 9; 8, 10; 8, 12; 9, function_name:tok2time; 10, parameters; 10, 11; 11, identifier...
def get_token_ids(tree): """ returns a list of all token IDs occuring the the given exmaralda file, sorted by their time stamp in ascending order. """ def tok2time(token_element): ''' extracts the time (float) of a <tli> element (i.e. the absol...
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, 12; 9, 40; 9, 44; 9, 64; 9, 107; 10, expression_statement; 10, 11; 11...
def get_span(docgraph, node_id, debug=False): """ returns all the tokens that are dominated or in a span relation with the given node. If debug is set to True, you'll get a warning if the graph is cyclic. Returns ------- span : list of str sorted list of token nodes (token node IDs)...
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, 8; 5, 14; 5, 20; 5, 56; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier...
def _get_terminals_and_nonterminals(sentence_graph): """ Given a TigerSentenceGraph, returns a sorted list of terminal node IDs, as well as a sorted list of nonterminal node IDs. Parameters ---------- sentence_graph : TigerSentenceGraph a directed graph representing one syntax annotated...
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; 8, 11; 9, expression_statement; 9, 10; 10, comment; 11, for_statement; 11, 12; 11, 15; 11...
def print_sorted_counter(counter, tab=1): """print all elements of a counter in descending order""" 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, 11; 8, 22; 8, 30; 8, 38; 8, 46; 8, 70; 9, expression_statement; 9, 10; 10, comment; 11, if_stateme...
def sorted_bfs_edges(G, source=None): """Produce edges in a breadth-first-search starting at source. Neighbors appear in the order a linguist would expect in a syntax tree. The result will only contain edges that express a dominance or spanning relation, i.e. edges expressing pointing or precedence rel...
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, 11; 8, 22; 8, 29; 8, 48; 9, expression_statement; 9, 10; 10, comment; 11, if_statement; 11, 1...
def sorted_bfs_successors(G, source=None): """Return dictionary of successors in breadth-first-search from source. Parameters ---------- G : DiscourseDocumentGraph graph source : node Specify starting node for breadth-first search and return edges in the component reachable from sour...