nodes stringlengths 501 22.4k | edges stringlengths 138 5.07k | code stringlengths 108 19.3k |
|---|---|---|
0, module; 1, function_definition; 2, function_name:_findRedundantProteins; 3, parameters; 4, block; 5, identifier:protToPeps; 6, identifier:pepToProts; 7, default_parameter; 8, expression_statement; 9, if_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement;... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 4, 23; 7, 24; 7, 25; 8, 26; 9, 27; 9, 28; 10, 29; 11, 30; 12, 31; 13, 32; 16, 33; 17, 34; 17, 35; 17, 36; 18, 37; 19, 38; 19, 39; 19, 40; 20, 41; 21, 42; 22, 43; 22, 44; 22, 4... | 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; 1, function_definition; 2, function_name:_mergeProteinEntries; 3, parameters; 4, block; 5, identifier:proteinLists; 6, identifier:protToPeps; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, return_statement; 11, comment:"""Returns a new "protToPeps" dictionary with entries merged that... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 7, 11; 8, 12; 9, 13; 9, 14; 9, 15; 10, 16; 12, 17; 12, 18; 15, 19; 15, 20; 15, 21; 18, 22; 18, 23; 19, 24; 19, 25; 19, 26; 20, 27; 21, 28; 23, 29; 26, 30; 27, 31; 27, 32; 28, 33; 28, 34; 30, 35; 32, 36; 32, 37; 33, 38; 33, 39; 35, 40; 35, 41; 37, 42; 41, 43; ... | 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; 1, function_definition; 2, function_name:_list; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, expression_statement; 11, function_definition; 12, expression_statement; 13, expression_statement; 14, expression_stateme... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 6, 16; 6, 17; 7, 18; 7, 19; 8, 20; 8, 21; 9, 22; 10, 23; 11, 24; 11, 25; 11, 26; 12, 27; 13, 28; 14, 29; 15, 30; 23, 31; 23, 32; 25, 33; 26, 34; 27, 35; 27, 36; 28, 37; 28, 38; 29, 39; 29, 40; 32, 41; 32, 42; 32, 43; 32, 44;... | 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; 1, function_definition; 2, function_name:sort_entries; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, return_statement; 8, comment:"""Get whether reverse is True or False. Return the sorted data."""; 9, call; 10, identifier:sorted; 11, argument_list; 12, attribute; 13, keyword_argum... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 6, 8; 7, 9; 9, 10; 9, 11; 11, 12; 11, 13; 11, 14; 12, 15; 12, 16; 13, 17; 13, 18; 14, 19; 14, 20; 18, 21; 18, 22; 20, 23; 20, 24; 23, 25; 23, 26 | 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; 1, function_definition; 2, function_name:expectedLabelPosition; 3, parameters; 4, block; 5, identifier:peptide; 6, identifier:labelStateInfo; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, if_statement; 11, if_statement; 12, expression_statement; 13, for_statement; 14, if_statement;... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 7, 17; 7, 18; 8, 19; 8, 20; 9, 21; 10, 22; 10, 23; 11, 24; 11, 25; 12, 26; 13, 27; 13, 28; 13, 29; 14, 30; 14, 31; 15, 32; 15, 33; 15, 34; 16, 35; 22, 36; 22, 37; 23, 38; 24, 39; 24, 40; 25, 41; 26, 42; 26, 43; 27, 44... | 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; 1, function_definition; 2, function_name:rank; 3, parameters; 4, block; 5, identifier:self; 6, identifier:member; 7, expression_statement; 8, if_statement; 9, return_statement; 10, comment:""" Gets the ASC rank of @member from the sorted set, that is,
lower scores have lower ranks
"""; 11... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 7, 10; 8, 11; 8, 12; 9, 13; 11, 14; 11, 15; 12, 16; 13, 17; 13, 18; 16, 19; 17, 20; 17, 21; 18, 22; 18, 23; 19, 24; 19, 25; 20, 26; 20, 27; 22, 28; 22, 29; 23, 30; 23, 31; 24, 32; 24, 33; 25, 34; 25, 35; 30, 36; 30, 37; 31, 38; 32, 39; 32, 40; 34, 41; 34, 42; 35, 43... | 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; 1, function_definition; 2, function_name:prepareSiiImport; 3, parameters; 4, block; 5, identifier:siiContainer; 6, identifier:specfile; 7, identifier:path; 8, identifier:qcAttr; 9, identifier:qcLargerBetter; 10, identifier:qcCutoff; 11, identifier:rankAttr; 12, identifier:rankLargerBetter; 13, expression_sta... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 13, 20; 14, 21; 14, 22; 14, 23; 15, 24; 16, 25; 17, 26; 18, 27; 19, 28; 21, 29; 21, 30; 22, 31; 23, 32; 24, 33; 24, 34; 25, 35; 25, 36; 26, 37; 26, 38; 27, 39; 27, 40; 28, 41; 28, 42; 30, 43; 30, ... | 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; 1, function_definition; 2, function_name:find_nearest; 3, parameters; 4, type; 5, block; 6, identifier:x; 7, identifier:x0; 8, generic_type; 9, expression_statement; 10, expression_statement; 11, comment:# for indexing upon return; 12, expression_statement; 13, comment:# %%; 14, if_statement; 15, if_statemen... | 0, 1; 1, 2; 1, 3; 1, 4; 1, 5; 3, 6; 3, 7; 4, 8; 5, 9; 5, 10; 5, 11; 5, 12; 5, 13; 5, 14; 5, 15; 5, 16; 5, 17; 5, 18; 5, 19; 5, 20; 8, 21; 8, 22; 9, 23; 10, 24; 12, 25; 14, 26; 14, 27; 15, 28; 15, 29; 17, 30; 19, 31; 19, 32; 19, 33; 20, 34; 22, 35; 22, 36; 24, 37; 24, 38; 25, 39; 25, 40; 26, 41; 26, 42; 27, 43; 28, 44; ... | 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; 1, function_definition; 2, function_name:primary_mrna; 3, parameters; 4, block; 5, identifier:entrystream; 6, default_parameter; 7, expression_statement; 8, for_statement; 9, identifier:parenttype; 10, string; 11, comment:"""
Select a single mRNA as a representative for each protein-coding gene.
The... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 6, 9; 6, 10; 7, 11; 8, 12; 8, 13; 8, 14; 10, 15; 14, 16; 14, 17; 14, 18; 16, 19; 16, 20; 17, 21; 17, 22; 17, 23; 18, 24; 19, 25; 20, 26; 20, 27; 22, 28; 22, 29; 23, 30; 23, 31; 23, 32; 24, 33; 25, 34; 25, 35; 26, 36; 28, 37; 28, 38; 29, 39; 29, 40; 29, 41; 30, 42; 31, 43;... | 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; 1, function_definition; 2, function_name:notes; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, if_statement; 11, expression_statement; 12, expression_statement; 13, return_statement; 14, identifier:public_only;... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 6, 14; 6, 15; 7, 16; 8, 17; 9, 18; 10, 19; 10, 20; 11, 21; 12, 22; 13, 23; 17, 24; 17, 25; 18, 26; 18, 27; 20, 28; 21, 29; 21, 30; 22, 31; 22, 32; 23, 33; 23, 34; 25, 35; 25, 36; 27, 37; 27, 38; 28, 39; 30, 40; 30, 41; 30, 42; 32, 43; 32,... | 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; 1, function_definition; 2, function_name:dispatchlist; 3, parameters; 4, block; 5, identifier:self; 6, keyword_separator; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, expression_statement; 12, expression_statement; 13, if_statement; 14, comment:# Here we do nee... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 7, 20; 7, 21; 8, 22; 8, 23; 9, 24; 9, 25; 10, 26; 10, 27; 11, 28; 12, 29; 13, 30; 13, 31; 17, 32; 17, 33; 17, 34; 17, 35; 18, 36; 18, 37; 19, 38; 27, 39; 29, 40; 29, 41; 31, 42; 32, 43; 32, 44; 33... | 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; 1, function_definition; 2, function_name:have_cycle; 3, parameters; 4, type; 5, block; 6, typed_parameter; 7, identifier:frozenset; 8, expression_statement; 9, comment:# topological sort; 10, expression_statement; 11, comment:# walked nodes; 12, expression_statement; 13, comment:# all nodes of the graph; 14,... | 0, 1; 1, 2; 1, 3; 1, 4; 1, 5; 3, 6; 4, 7; 5, 8; 5, 9; 5, 10; 5, 11; 5, 12; 5, 13; 5, 14; 5, 15; 5, 16; 5, 17; 5, 18; 6, 19; 6, 20; 8, 21; 10, 22; 12, 23; 14, 24; 16, 25; 17, 26; 17, 27; 18, 28; 20, 29; 22, 30; 22, 31; 23, 32; 23, 33; 24, 34; 24, 35; 25, 36; 25, 37; 26, 38; 26, 39; 27, 40; 27, 41; 28, 42; 28, 43; 31, 44... | 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; 1, function_definition; 2, function_name:time_pipeline; 3, parameters; 4, block; 5, identifier:iterable; 6, list_splat_pattern; 7, expression_statement; 8, if_statement; 9, comment:# if iterable is not a function, load the whole thing; 10, comment:# into a list so it can be ran over multiple times; 11, if_st... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 6, 23; 7, 24; 8, 25; 8, 26; 8, 27; 11, 28; 11, 29; 13, 30; 14, 31; 15, 32; 15, 33; 15, 34; 18, 35; 19, 36; 20, 37; 22, 38; 22, 39; 22, 40; 24, 41; 25, 42; 25, 43; 26, 44; 27, ... | 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; 1, function_definition; 2, function_name:sort_matches; 3, parameters; 4, block; 5, identifier:matches; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, return_statement; 10, string; 11, assignment; 12, assignment; 13, list_comprehension; 14, string_content:Sorts a ``list`` of mat... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 6, 10; 7, 11; 8, 12; 9, 13; 10, 14; 11, 15; 11, 16; 12, 17; 12, 18; 13, 19; 13, 20; 16, 21; 16, 22; 16, 23; 16, 24; 18, 25; 18, 26; 19, 27; 19, 28; 20, 29; 20, 30; 21, 31; 21, 32; 22, 33; 22, 34; 23, 35; 23, 36; 24, 37; 24, 38; 25, 39; 25, 40; 26, 41; 26, 42; 30, 43... | 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; 1, function_definition; 2, function_name:_get_sorted_iterator; 3, parameters; 4, block; 5, identifier:self; 6, identifier:iterator; 7, expression_statement; 8, expression_statement; 9, if_statement; 10, import_statement; 11, expression_statement; 12, expression_statement; 13, return_statement; 14, comment:""... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 7, 14; 8, 15; 9, 16; 9, 17; 10, 18; 11, 19; 12, 20; 13, 21; 15, 22; 15, 23; 16, 24; 16, 25; 17, 26; 18, 27; 19, 28; 19, 29; 20, 30; 20, 31; 21, 32; 21, 33; 23, 34; 23, 35; 24, 36; 24, 37; 25, 38; 25, 39; 26, 40; 29, 41; 29, 42; 31, 43; 31... | 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; 1, function_definition; 2, function_name:_split; 3, parameters; 4, block; 5, identifier:self; 6, identifier:iterator; 7, identifier:tmp_dir; 8, expression_statement; 9, expression_statement; 10, for_statement; 11, return_statement; 12, comment:"""
Splits the file into several chunks.
If the ... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 8, 12; 9, 13; 10, 14; 10, 15; 10, 16; 11, 17; 13, 18; 13, 19; 14, 20; 14, 21; 15, 22; 15, 23; 16, 24; 16, 25; 16, 26; 16, 27; 16, 28; 23, 29; 24, 30; 25, 31; 26, 32; 27, 33; 28, 34; 28, 35; 30, 36; 30, 37; 31, 38; 31, 39; 32, 40; 32, 41; 33, 42; 33, 43... | 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; 1, function_definition; 2, function_name:_write; 3, parameters; 4, block; 5, identifier:self; 6, identifier:lines; 7, identifier:fname; 8, expression_statement; 9, with_statement; 10, comment:"""
Writes a intermediate temporary sorted file
:param lines: The lines to write.
:param fna... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 8, 10; 9, 11; 9, 12; 11, 13; 12, 14; 13, 15; 14, 16; 14, 17; 14, 18; 15, 19; 15, 20; 17, 21; 17, 22; 18, 23; 19, 24; 19, 25; 20, 26; 22, 27; 22, 28; 23, 29; 25, 30; 25, 31; 28, 32; 28, 33; 29, 34; 29, 35; 31, 36; 33, 37; 33, 38; 34, 39; 34, 40; 35, 41; 35, 42 | 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; 1, function_definition; 2, function_name:add; 3, parameters; 4, block; 5, identifier:self; 6, identifier:interval; 7, identifier:offset; 8, expression_statement; 9, expression_statement; 10, if_statement; 11, comment:"""
The added interval must be overlapping or beyond the last stored interval ie. ad... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 8, 11; 9, 12; 10, 13; 10, 14; 10, 15; 12, 16; 12, 17; 13, 18; 13, 19; 14, 20; 14, 21; 14, 22; 15, 23; 16, 24; 16, 25; 17, 26; 17, 27; 18, 28; 18, 29; 20, 30; 20, 31; 21, 32; 22, 33; 23, 34; 23, 35; 23, 36; 26, 37; 26, 38; 27, 39; 29, 40; 30, 41; 30, 42; 31, 4... | 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; 1, function_definition; 2, function_name:get_collection_documents_generator; 3, parameters; 4, block; 5, identifier:client; 6, identifier:database_name; 7, identifier:collection_name; 8, identifier:spec; 9, identifier:latest_n; 10, identifier:sort_key; 11, expression_statement; 12, expression_statement; 13, ... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 11, 17; 12, 18; 13, 19; 14, 20; 15, 21; 15, 22; 15, 23; 16, 24; 16, 25; 16, 26; 18, 27; 18, 28; 19, 29; 19, 30; 20, 31; 20, 32; 21, 33; 21, 34; 22, 35; 22, 36; 22, 37; 22, 38; 23, 39; 26, 40; 28, 41; 28, 42; 30, 43; 3... | 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; 1, function_definition; 2, function_name:save; 3, parameters; 4, block; 5, identifier:self; 6, list_splat_pattern; 7, dictionary_splat_pattern; 8, expression_statement; 9, if_statement; 10, if_statement; 11, expression_statement; 12, identifier:args; 13, identifier:kwargs; 14, comment:"""
Store a str... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 6, 12; 7, 13; 8, 14; 9, 15; 9, 16; 10, 17; 10, 18; 11, 19; 15, 20; 16, 21; 17, 22; 18, 23; 19, 24; 19, 25; 20, 26; 20, 27; 21, 28; 22, 29; 22, 30; 23, 31; 24, 32; 24, 33; 28, 34; 28, 35; 31, 36; 31, 37; 32, 38; 32, 39; 34, 40; 34, 41; 35, 42; 35, 43; 3... | 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; 1, function_definition; 2, function_name:_sort_modules; 3, parameters; 4, block; 5, identifier:mods; 6, expression_statement; 7, function_definition; 8, return_statement; 9, comment:""" Always sort `index` or `README` as first filename in list. """; 10, function_name:compare; 11, parameters; 12, block; 13, c... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 6, 9; 7, 10; 7, 11; 7, 12; 8, 13; 11, 14; 11, 15; 12, 16; 12, 17; 12, 18; 12, 19; 12, 20; 12, 21; 13, 22; 13, 23; 16, 24; 17, 25; 18, 26; 18, 27; 19, 28; 19, 29; 20, 30; 20, 31; 21, 32; 23, 33; 23, 34; 24, 35; 24, 36; 25, 37; 25, 38; 26, 39; 26, 40; 27, 41; 28, 42; 28, 43... | 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; 1, function_definition; 2, function_name:_sort_results; 3, parameters; 4, block; 5, identifier:self; 6, identifier:results; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, for_statement; 11, expression_statement; 12, for_statement; 13, return_statement; 14, comment:"""
... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 7, 14; 8, 15; 9, 16; 10, 17; 10, 18; 10, 19; 11, 20; 12, 21; 12, 22; 12, 23; 13, 24; 15, 25; 15, 26; 16, 27; 16, 28; 19, 29; 20, 30; 20, 31; 23, 32; 29, 33; 29, 34; 29, 35; 32, 36; 33, 37; 34, 38; 34, 39; 34, 40; 35, 41; 36, 42; 36, 43; 3... | 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; 1, function_definition; 2, function_name:_update_sorting; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, for_statement; 12, if_statement; 13, expression_statement; 14, expression_st... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 6, 15; 7, 16; 8, 17; 9, 18; 10, 19; 11, 20; 11, 21; 11, 22; 12, 23; 12, 24; 13, 25; 14, 26; 16, 27; 16, 28; 17, 29; 17, 30; 18, 31; 18, 32; 19, 33; 19, 34; 21, 35; 21, 36; 22, 37; 23, 38; 23, 39; 24, 40; 25, 41; 25, 42; 26, 43; 26,... | 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; 1, function_definition; 2, function_name:domain_user_stats; 3, parameters; 4, comment:# type: () -> pd.Series; 5, block; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, return_statement; 10, comment:""" Get number of distinct email addresses in observed domains
TODO: get up... | 0, 1; 1, 2; 1, 3; 1, 4; 1, 5; 5, 6; 5, 7; 5, 8; 5, 9; 6, 10; 7, 11; 8, 12; 9, 13; 11, 14; 11, 15; 12, 16; 12, 17; 13, 18; 13, 19; 15, 20; 15, 21; 17, 22; 17, 23; 19, 24; 19, 25; 20, 26; 20, 27; 21, 28; 21, 29; 22, 30; 22, 31; 23, 32; 23, 33; 23, 34; 23, 35; 24, 36; 24, 37; 25, 38; 26, 39; 26, 40; 28, 41; 28, 42; 33, 43... | 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; 1, function_definition; 2, function_name:_topological_sort; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, function_definition; 11, comment:# node is initially weighted with the number of immediate dependenc... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 6, 18; 7, 19; 8, 20; 9, 21; 10, 22; 10, 23; 10, 24; 12, 25; 12, 26; 12, 27; 14, 28; 15, 29; 15, 30; 16, 31; 17, 32; 19, 33; 19, 34; 20, 35; 20, 36; 21, 37; 21, 38; 23, 39; 24, 40; 24, 41; 24, 42; 24, 43; 27, 44... | 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; 1, function_definition; 2, function_name:plugins; 3, parameters; 4, comment:# TODO: share this documentation with `../doc/plugin.rst`...; 5, block; 6, identifier:group; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, return_state... | 0, 1; 1, 2; 1, 3; 1, 4; 1, 5; 3, 6; 3, 7; 5, 8; 5, 9; 5, 10; 5, 11; 5, 12; 7, 13; 7, 14; 8, 15; 9, 16; 10, 17; 11, 18; 12, 19; 16, 20; 16, 21; 17, 22; 17, 23; 18, 24; 18, 25; 19, 26; 19, 27; 21, 28; 21, 29; 23, 30; 23, 31; 25, 32; 25, 33; 27, 34; 27, 35; 27, 36; 29, 37; 31, 38; 33, 39; 36, 40; 36, 41; 38, 42; 38, 43; 3... | 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; 1, function_definition; 2, function_name:match_any_string; 3, parameters; 4, block; 5, identifier:self; 6, identifier:strings; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, if_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, for_statement... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 7, 16; 7, 17; 8, 18; 8, 19; 9, 20; 10, 21; 10, 22; 11, 23; 12, 24; 13, 25; 14, 26; 14, 27; 14, 28; 15, 29; 22, 30; 22, 31; 23, 32; 23, 33; 24, 34; 24, 35; 25, 36; 25, 37; 28, 38; 28, 39; 28, 40; 30, 41; 31, 42; 38, 43; 39, 4... | 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; 1, function_definition; 2, function_name:decide_which_users_to_annotate; 3, parameters; 4, block; 5, identifier:centrality_vector; 6, identifier:number_to_annotate; 7, identifier:already_annotated; 8, identifier:node_to_id; 9, expression_statement; 10, comment:# Sort the centrality vector according to decrea... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 9, 20; 11, 21; 12, 22; 13, 23; 13, 24; 13, 25; 15, 26; 16, 27; 17, 28; 18, 29; 18, 30; 18, 31; 19, 32; 21, 33; 21, 34; 22, 35; 22, 36; 23, 37; 23, 38; 24, 39; 25, 40; 26, 41; 26, 42; 27, 43; 27, 4... | 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; 1, function_definition; 2, function_name:search; 3, parameters; 4, block; 5, identifier:self; 6, identifier:query; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, expression_statement; 11, if_statement; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15,... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 7, 17; 7, 18; 8, 19; 8, 20; 9, 21; 10, 22; 11, 23; 11, 24; 12, 25; 13, 26; 14, 27; 15, 28; 16, 29; 18, 30; 18, 31; 18, 32; 18, 33; 18, 34; 21, 35; 22, 36; 22, 37; 24, 38; 25, 39; 25, 40; 26, 41; 26, 42; 27, 43; 27, 44... | 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; 1, function_definition; 2, function_name:set_attribute_string; 3, parameters; 4, block; 5, identifier:target; 6, identifier:name; 7, identifier:value; 8, expression_statement; 9, expression_statement; 10, comment:""" Sets an attribute to a string on a Dataset or Group.
If the attribute `name` doesn't ex... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 8, 10; 9, 11; 11, 12; 11, 13; 13, 14; 13, 15; 13, 16; 16, 17; 16, 18; 17, 19; 17, 20; 18, 21 | 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; 1, function_definition; 2, function_name:__calculate_edge_weights; 3, parameters; 4, block; 5, identifier:dfs_data; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, return_statement; 11, comment:"""Calculates the weight of each edge, for embedding-order sorting... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 6, 11; 7, 12; 8, 13; 9, 14; 9, 15; 9, 16; 10, 17; 12, 18; 12, 19; 13, 20; 13, 21; 15, 22; 15, 23; 16, 24; 16, 25; 19, 26; 19, 27; 22, 28; 22, 29; 24, 30; 25, 31; 27, 32; 30, 33; 30, 34; 31, 35; 31, 36; 34, 37; 34, 38; 35, 39; 35, 40; 38, 41; 38, 42 | 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; 1, function_definition; 2, function_name:__sort_adjacency_lists; 3, parameters; 4, block; 5, identifier:dfs_data; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, for_statement; 12, return_statement; 13, comment:"""Sorts the adj... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 6, 13; 7, 14; 8, 15; 9, 16; 10, 17; 11, 18; 11, 19; 11, 20; 12, 21; 14, 22; 14, 23; 15, 24; 15, 25; 16, 26; 16, 27; 17, 28; 17, 29; 18, 30; 18, 31; 19, 32; 19, 33; 20, 34; 20, 35; 20, 36; 20, 37; 20, 38; 20, 39; 20, 40; 20, 41; 20, 42; 25, 43; 2... | 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; 1, function_definition; 2, function_name:__edge_weight; 3, parameters; 4, block; 5, identifier:edge_id; 6, identifier:dfs_data; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 7, 17; 8, 18; 9, 19; 10, 20; 11, 21; 12, 22; 13, 23; 14, 24; 15, 25; 16, 26; 16, 27; 16, 28; 16, 29; 16, 30; 18, 31; 18, 32; 19, 33; 19, 34; 20, 35; 20, 36; 21, 37; 21, 38; 22, 39; 22, 40; 23, 41; 23, 42; 24, 43; 24, ... | 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; 1, function_definition; 2, function_name:classify_segmented_recording; 3, parameters; 4, block; 5, identifier:recording; 6, default_parameter; 7, expression_statement; 8, global_statement; 9, if_statement; 10, return_statement; 11, identifier:result_format; 12, None; 13, comment:"""Use this function if you a... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 6, 11; 6, 12; 7, 13; 8, 14; 9, 15; 9, 16; 10, 17; 15, 18; 15, 19; 16, 20; 17, 21; 17, 22; 20, 23; 21, 24; 21, 25; 22, 26; 22, 27; 23, 28; 23, 29; 29, 30; 29, 31 | 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; 1, function_definition; 2, function_name:sort_by_formula_id; 3, parameters; 4, block; 5, identifier:raw_datasets; 6, expression_statement; 7, expression_statement; 8, for_statement; 9, return_statement; 10, comment:"""
Sort a list of formulas by `id`, where `id` represents the accepted
formula id.
... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 6, 10; 7, 11; 8, 12; 8, 13; 8, 14; 9, 15; 11, 16; 11, 17; 14, 18; 17, 19; 17, 20; 18, 21; 20, 22; 21, 23; 21, 24; 23, 25; 23, 26; 24, 27; 25, 28; 25, 29; 27, 30; 27, 31; 29, 32; 29, 33; 31, 34; 32, 35; 32, 36; 36, 37 | 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; 1, function_definition; 2, function_name:get_sorted_pointlist; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, for_statement; 9, expression_statement; 10, return_statement; 11, comment:"""
Make sure that the points and strokes are in order.
R... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 6, 11; 7, 12; 8, 13; 8, 14; 8, 15; 9, 16; 10, 17; 12, 18; 12, 19; 14, 20; 14, 21; 15, 22; 16, 23; 16, 24; 19, 25; 19, 26; 21, 27; 22, 28; 24, 29; 24, 30; 25, 31; 25, 32; 27, 33; 27, 34; 28, 35; 28, 36; 30, 37; 30, 38; 34, 39; 35, 40; 35, 41; 36, 42; 36, 43; 3... | 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; 1, function_definition; 2, function_name:get_name; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, expression_statement; 8, if_statement; 9, if_statement; 10, return_statement; 11, identifier:use_alias; 12, True; 13, comment:"""
Gets the name to reference the sorted field
... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 6, 11; 6, 12; 7, 13; 8, 14; 8, 15; 8, 16; 9, 17; 9, 18; 10, 19; 14, 20; 14, 21; 15, 22; 16, 23; 18, 24; 19, 25; 19, 26; 22, 27; 23, 28; 24, 29; 25, 30; 25, 31; 26, 32; 26, 33; 27, 34; 27, 35; 28, 36; 29, 37; 29, 38; 30, 39; 32, 40; 32, 41; 35, 42; 36, 43; 36,... | 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; 1, function_definition; 2, function_name:order_by; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, expression_statement; 11, return_statement; 12, identifier:field; 13, None; 14, identifier:table; 15, None; 16, identi... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 6, 12; 6, 13; 7, 14; 7, 15; 8, 16; 8, 17; 9, 18; 10, 19; 11, 20; 19, 21; 19, 22; 21, 23; 21, 24; 22, 25; 23, 26; 23, 27; 25, 28; 25, 29; 29, 30; 29, 31; 29, 32; 30, 33; 30, 34; 31, 35; 31, 36; 32, 37; 32, 38 | 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; 1, function_definition; 2, function_name:sort_by_tag; 3, parameters; 4, block; 5, identifier:self; 6, identifier:tag; 7, expression_statement; 8, return_statement; 9, comment:"""Sorts the `AmpalContainer` by a tag on the component objects.
Parameters
----------
tag : str
... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 7, 9; 8, 10; 10, 11; 10, 12; 12, 13; 13, 14; 13, 15; 15, 16; 15, 17; 17, 18; 17, 19; 19, 20; 19, 21; 20, 22; 21, 23; 21, 24; 23, 25; 23, 26 | 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; 1, function_definition; 2, function_name:fit_heptad_register; 3, parameters; 4, block; 5, identifier:crangles; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, comment:# This is dirty, too long but trim... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 6, 16; 7, 17; 8, 18; 9, 19; 10, 20; 11, 21; 13, 22; 14, 23; 14, 24; 14, 25; 15, 26; 17, 27; 17, 28; 18, 29; 18, 30; 19, 31; 19, 32; 20, 33; 20, 34; 21, 35; 21, 36; 22, 37; 22, 38; 24, 39; 24, 40; 25, 41; 25, 42; 25, 43; 26, ... | 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; 1, function_definition; 2, function_name:simplify; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, comment:# TODO: Refactor DualBase.simplify into different "sub-evals".; 8, comment:# If self is already canonical do nothing.; 9, if_statement; 10, comment:# Otherwise bring arguments i... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 4, 23; 4, 24; 4, 25; 4, 26; 4, 27; 4, 28; 4, 29; 4, 30; 4, 31; 4, 32; 4, 33; 4, 34; 4, 35; 4, 36; 4, 37; 4, 38; 4, 39; 4, 40; 4, 41; 4, 42; 4, 43; 4, 44; 6, 45; 9, 46; 9, 47; ... | 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; 1, function_definition; 2, function_name:_recordAndPrintHeadline; 3, parameters; 4, block; 5, identifier:self; 6, identifier:test; 7, identifier:error_class; 8, identifier:artifact; 9, expression_statement; 10, comment:# We duplicate the errorclass handling from super rather than calling; 11, comment:# it an... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 9, 19; 13, 20; 14, 21; 14, 22; 14, 23; 15, 24; 15, 25; 16, 26; 17, 27; 18, 28; 20, 29; 20, 30; 21, 31; 21, 32; 22, 33; 22, 34; 23, 35; 24, 36; 25, 37; 25, 38; 26, 39; 26, 40; 27, 41; 27, 42; 32, 43; 32, ... | 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; 1, function_definition; 2, function_name:_decode_filename_to_unicode; 3, parameters; 4, block; 5, identifier:f; 6, expression_statement; 7, expression_statement; 8, if_statement; 9, try_statement; 10, string; 11, call; 12, call; 13, block; 14, block; 15, except_clause; 16, string_content:Get bytestring filen... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 6, 10; 7, 11; 8, 12; 8, 13; 9, 14; 9, 15; 10, 16; 11, 17; 11, 18; 12, 19; 12, 20; 13, 21; 14, 22; 15, 23; 15, 24; 17, 25; 17, 26; 18, 27; 18, 28; 20, 29; 20, 30; 21, 31; 22, 32; 24, 33; 24, 34; 24, 35; 24, 36; 24, 37; 24, 38; 24, 39; 24, 40; 27, 41; 28, 42; 28, 43; ... | 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; 1, function_definition; 2, function_name:sortBy; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, expression_statement; 8, if_statement; 9, identifier:val; 10, None; 11, comment:""" Sort the object's values by a criterion produced by an iterator.
"""; 12, comparison_operator:val ... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 6, 9; 6, 10; 7, 11; 8, 12; 8, 13; 8, 14; 12, 15; 12, 16; 13, 17; 14, 18; 17, 19; 17, 20; 17, 21; 18, 22; 19, 23; 19, 24; 20, 25; 21, 26; 22, 27; 23, 28; 23, 29; 25, 30; 26, 31; 27, 32; 27, 33; 28, 34; 28, 35; 30, 36; 30, 37; 31, 38; 32, 39; 32, 40; 33, 41; 35, 42; 36, 43;... | 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; 1, function_definition; 2, function_name:sortedIndex; 3, parameters; 4, block; 5, identifier:self; 6, identifier:obj; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, while_statement; 14, return_statement... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 7, 15; 7, 16; 8, 17; 9, 18; 10, 19; 11, 20; 12, 21; 13, 22; 13, 23; 14, 24; 16, 25; 16, 26; 18, 27; 18, 28; 19, 29; 19, 30; 20, 31; 20, 32; 21, 33; 21, 34; 22, 35; 22, 36; 23, 37; 23, 38; 24, 39; 24, 40; 25, 41; 28, 42; 28, 43; 30,... | 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; 1, function_definition; 2, function_name:uniq; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, if_statement; 14, function_definition; 15... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 6, 17; 6, 18; 7, 19; 7, 20; 8, 21; 9, 22; 10, 23; 11, 24; 12, 25; 13, 26; 13, 27; 14, 28; 14, 29; 14, 30; 15, 31; 16, 32; 22, 33; 22, 34; 23, 35; 23, 36; 24, 37; 24, 38; 25, 39; 25, 40; 26, 41; 26, 42; 27, 43; 29, 44;... | 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; 1, function_definition; 2, function_name:functions; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, for_statement; 9, return_statement; 10, comment:""" Return a sorted list of the function names available on the object.
"""; 11, assignment; 12, patter... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 6, 10; 7, 11; 8, 12; 8, 13; 8, 14; 9, 15; 11, 16; 11, 17; 12, 18; 12, 19; 13, 20; 13, 21; 14, 22; 15, 23; 15, 24; 21, 25; 22, 26; 22, 27; 23, 28; 23, 29; 24, 30; 25, 31; 25, 32; 26, 33; 26, 34; 27, 35; 30, 36; 30, 37; 33, 38; 33, 39; 35, 40; 37, 41; 38, 42; 38, 43; ... | 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; 1, function_definition; 2, function_name:createMSBWTFromBam; 3, parameters; 4, block; 5, identifier:bamFNs; 6, identifier:outputDir; 7, identifier:numProcs; 8, identifier:areUniform; 9, identifier:logger; 10, expression_statement; 11, comment:#generate the files we will reference and clear out the in memory ... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 10, 20; 12, 21; 13, 22; 14, 23; 15, 24; 16, 25; 17, 26; 18, 27; 19, 28; 20, 29; 21, 30; 21, 31; 22, 32; 22, 33; 23, 34; 23, 35; 24, 36; 24, 37; 25, 38; 25, 39; 26, 40; 26, 41; 27, 42; 27, 43; 28, ... | 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; 1, function_definition; 2, function_name:append_responder; 3, parameters; 4, block; 5, identifier:self; 6, identifier:matcher; 7, list_splat_pattern; 8, dictionary_splat_pattern; 9, expression_statement; 10, return_statement; 11, identifier:args; 12, identifier:kwargs; 13, comment:"""Add a responder of last ... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 7, 11; 8, 12; 9, 13; 10, 14; 14, 15; 14, 16; 15, 17; 15, 18; 16, 19; 16, 20; 16, 21; 16, 22; 21, 23; 22, 24 | 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; 1, function_definition; 2, function_name:unique_list_dicts; 3, parameters; 4, block; 5, identifier:dlist; 6, identifier:key; 7, expression_statement; 8, return_statement; 9, comment:"""Return a list of dictionaries which are sorted for only unique entries.
:param dlist:
:param key:
:return list:... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 7, 9; 8, 10; 10, 11; 10, 12; 12, 13; 13, 14; 13, 15; 14, 16; 14, 17; 16, 18; 16, 19; 19, 20; 19, 21; 20, 22; 20, 23; 21, 24; 21, 25; 22, 26; 22, 27 | 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; 1, function_definition; 2, function_name:_get_bmu; 3, parameters; 4, block; 5, identifier:self; 6, identifier:activations; 7, expression_statement; 8, comment:# If the neural gas is a recursive neural gas, we need reverse argsort.; 9, if_statement; 10, expression_statement; 11, return_statement; 12, comment:... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 7, 12; 9, 13; 9, 14; 10, 15; 11, 16; 13, 17; 13, 18; 14, 19; 15, 20; 15, 21; 16, 22; 16, 23; 17, 24; 17, 25; 18, 26; 19, 27; 21, 28; 21, 29; 22, 30; 22, 31; 27, 32; 27, 33; 28, 34; 28, 35; 29, 36; 29, 37; 33, 38 | 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; 1, function_definition; 2, function_name:sort_versions; 3, parameters; 4, block; 5, default_parameter; 6, default_parameter; 7, default_parameter; 8, expression_statement; 9, if_statement; 10, expression_statement; 11, function_definition; 12, expression_statement; 13, expression_statement; 14, for_statement... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 4, 23; 5, 24; 5, 25; 6, 26; 6, 27; 7, 28; 7, 29; 8, 30; 9, 31; 9, 32; 10, 33; 11, 34; 11, 35; 11, 36; 12, 37; 13, 38; 14, 39; 14, 40; 14, 41; 16, 42; 17, 43; 18, 44; 18, 45; 2... | 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; 1, function_definition; 2, function_name:make_qq_plot; 3, parameters; 4, block; 5, identifier:kev; 6, identifier:obs; 7, identifier:mdl; 8, identifier:unit; 9, identifier:key_text; 10, expression_statement; 11, import_statement; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 4, 23; 4, 24; 4, 25; 4, 26; 4, 27; 4, 28; 4, 29; 10, 30; 11, 31; 12, 32; 13, 33; 14, 34; 15, 35; 16, 36; 17, 37; 18, 38; 19, 39; 20, 40; 23, 41; 24, 42; 25, 43; 26, 44; 26, 45... | 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; 1, function_definition; 2, function_name:_qr_factor_full; 3, parameters; 4, block; 5, identifier:a; 6, default_parameter; 7, expression_statement; 8, expression_statement; 9, comment:# Compute the packed Q and R matrix information.; 10, expression_statement; 11, comment:# Now we unpack. Start with the R matr... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 4, 23; 4, 24; 6, 25; 6, 26; 7, 27; 8, 28; 10, 29; 14, 30; 15, 31; 15, 32; 15, 33; 21, 34; 22, 35; 23, 36; 23, 37; 23, 38; 24, 39; 26, 40; 26, 41; 28, 42; 28, 43; 29, 44; 29, 4... | 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; 1, function_definition; 2, function_name:_qrd_solve_full; 3, parameters; 4, block; 5, identifier:a; 6, identifier:b; 7, identifier:ddiag; 8, default_parameter; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, assert_statement... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 8, 22; 8, 23; 9, 24; 10, 25; 11, 26; 12, 27; 13, 28; 14, 29; 15, 30; 16, 31; 18, 32; 19, 33; 20, 34; 21, 35; 23, 36; 23, 37; 25, 38; 25, 39; 26, 40; 26, 41; 27, 42; 27, 43; 28, 44; 2... | 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; 1, function_definition; 2, function_name:concat; 3, parameters; 4, block; 5, identifier:invises; 6, identifier:outvis; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, if_statement; 12, for_statement; 13, expression_statement; 14, expression_statement; 15,... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 7, 23; 7, 24; 8, 25; 9, 26; 10, 27; 11, 28; 11, 29; 12, 30; 12, 31; 12, 32; 13, 33; 14, 34; 15, 35; 16, 36; 17, 37; 17, 38; 17, 39; 18, 40; 19, 41; 20, 42; 21, 43; 21, 44; 22,... | 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; 1, function_definition; 2, function_name:get_zones_of_account; 3, parameters; 4, block; 5, identifier:self; 6, identifier:account_name; 7, default_parameter; 8, dictionary_splat_pattern; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, return_statement; 13, identifier:q; 14, N... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 4, 12; 7, 13; 7, 14; 8, 15; 9, 16; 10, 17; 11, 18; 12, 19; 17, 20; 17, 21; 18, 22; 18, 23; 19, 24; 19, 25; 21, 26; 21, 27; 23, 28; 23, 29; 24, 30; 24, 31; 25, 32; 25, 33; 26, 34; 26, 35; 29, 36; 29, 37; 30, 38; 30, 39 | 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; 1, function_definition; 2, function_name:get_zones; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, dictionary_splat_pattern; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, return_statement; 12, identifier:q; 13, None; 14, identifier:kwargs; 15, comment:... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 6, 12; 6, 13; 7, 14; 8, 15; 9, 16; 10, 17; 11, 18; 16, 19; 16, 20; 17, 21; 17, 22; 18, 23; 18, 24; 22, 25; 22, 26; 23, 27; 23, 28; 24, 29; 24, 30; 26, 31; 26, 32; 27, 33; 27, 34 | 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; 1, function_definition; 2, function_name:get_rrsets; 3, parameters; 4, block; 5, identifier:self; 6, identifier:zone_name; 7, default_parameter; 8, dictionary_splat_pattern; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, return_statement; 13, identifier:q; 14, None; 15, iden... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 4, 12; 7, 13; 7, 14; 8, 15; 9, 16; 10, 17; 11, 18; 12, 19; 17, 20; 17, 21; 18, 22; 18, 23; 19, 24; 19, 25; 21, 26; 21, 27; 23, 28; 23, 29; 24, 30; 24, 31; 25, 32; 25, 33; 26, 34; 26, 35; 29, 36; 29, 37; 30, 38; 30, 39 | 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; 1, function_definition; 2, function_name:nested_tuple; 3, parameters; 4, block; 5, identifier:container; 6, expression_statement; 7, if_statement; 8, if_statement; 9, if_statement; 10, return_statement; 11, comment:"""Recursively transform a container structure to a nested tuple.
The function understand... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 6, 11; 7, 12; 7, 13; 8, 14; 8, 15; 9, 16; 9, 17; 10, 18; 12, 19; 12, 20; 13, 21; 14, 22; 14, 23; 15, 24; 16, 25; 17, 26; 17, 27; 20, 28; 20, 29; 21, 30; 23, 31; 23, 32; 24, 33; 25, 34; 25, 35; 26, 36; 26, 37; 27, 38; 27, 39; 30, 40; 30, 41; 33, 42; 33, 43; 35... | 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; 1, function_definition; 2, function_name:_ranges_key; 3, parameters; 4, block; 5, identifier:r; 6, identifier:delta_indices; 7, expression_statement; 8, expression_statement; 9, if_statement; 10, comment:"""Sorting key for ranges.
When used with ``reverse=True``, this can be used to sort index ranges in... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 7, 10; 8, 11; 9, 12; 9, 13; 9, 14; 11, 15; 11, 16; 12, 17; 12, 18; 13, 19; 14, 20; 14, 21; 14, 22; 16, 23; 16, 24; 19, 25; 22, 26; 25, 27; 25, 28; 26, 29; 27, 30; 27, 31; 28, 32; 28, 33; 29, 34; 29, 35; 30, 36; 30, 37; 32, 38; 32, 39; 35, 40 | 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; 1, function_definition; 2, function_name:plot; 3, parameters; 4, block; 5, identifier:self; 6, identifier:x; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, expression_statement; 11, expression_statement; 12, if_statement; 13, expression_statement; 14, expression_statement; 15, expressi... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 4, 23; 4, 24; 4, 25; 4, 26; 4, 27; 4, 28; 4, 29; 7, 30; 7, 31; 8, 32; 8, 33; 9, 34; 9, 35; 10, 36; 11, 37; 12, 38; 12, 39; 13, 40; 14, 41; 15, 42; 16, 43; 17, 44; 17, 45; 18, ... | 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; 1, function_definition; 2, function_name:_restricted_growth_notation; 3, parameters; 4, block; 5, identifier:l; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, expression_statement; 11, for_statement; 12, return_statement; 13, comment:""" The clustering return... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 6, 13; 7, 14; 8, 15; 9, 16; 9, 17; 9, 18; 10, 19; 11, 20; 11, 21; 11, 22; 12, 23; 14, 24; 14, 25; 15, 26; 15, 27; 16, 28; 16, 29; 17, 30; 17, 31; 18, 32; 19, 33; 19, 34; 20, 35; 20, 36; 21, 37; 21, 38; 22, 39; 23, 40; 23, 41; 25, 42; 25, 43; 27,... | 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; 1, function_definition; 2, function_name:insort_no_dup; 3, parameters; 4, block; 5, identifier:lst; 6, identifier:item; 7, expression_statement; 8, import_statement; 9, expression_statement; 10, if_statement; 11, comment:"""
If item is not in lst, add item to list at its sorted position
"""; 12, dott... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 7, 11; 8, 12; 9, 13; 10, 14; 10, 15; 12, 16; 13, 17; 13, 18; 14, 19; 14, 20; 15, 21; 18, 22; 18, 23; 19, 24; 19, 25; 21, 26; 22, 27; 22, 28; 23, 29; 23, 30; 26, 31; 26, 32; 31, 33; 31, 34; 32, 35; 34, 36; 34, 37 | 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; 1, function_definition; 2, function_name:records; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, return_statement; 8, comment:""" Returns a list of records in SORT_KEY order """; 9, list_comprehension; 10, subscript; 11, for_in_clause; 12, attribute; 13, identifier:i; 14, identifier... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 6, 8; 7, 9; 9, 10; 9, 11; 10, 12; 10, 13; 11, 14; 11, 15; 12, 16; 12, 17; 15, 18; 15, 19; 19, 20; 20, 21; 20, 22; 22, 23; 23, 24; 23, 25 | 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; 1, function_definition; 2, function_name:score; 3, parameters; 4, block; 5, identifier:self; 6, identifier:phone_number; 7, identifier:account_lifecycle_event; 8, dictionary_splat_pattern; 9, expression_statement; 10, return_statement; 11, identifier:params; 12, comment:"""
Score is an API that deliv... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 8, 11; 9, 12; 10, 13; 13, 14; 13, 15; 14, 16; 14, 17; 15, 18; 15, 19; 15, 20; 18, 21; 18, 22; 19, 23; 19, 24; 20, 25; 21, 26; 21, 27; 22, 28; 28, 29; 28, 30 | 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; 1, function_definition; 2, function_name:sorted_members; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, if_statement; 11, expression_statement; 12, comment:"""
Iterate over sorted members of shape in the sa... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 6, 12; 7, 13; 8, 14; 9, 15; 9, 16; 9, 17; 10, 18; 10, 19; 10, 20; 11, 21; 13, 22; 13, 23; 14, 24; 14, 25; 15, 26; 15, 27; 16, 28; 16, 29; 17, 30; 18, 31; 18, 32; 20, 33; 21, 34; 23, 35; 23, 36; 25, 37; 25, 38; 28, 39; 28, 40; 30, 41; 33, 42; 34, 43; 34... | 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; 1, function_definition; 2, function_name:threshold_brier_score; 3, parameters; 4, block; 5, identifier:observations; 6, identifier:forecasts; 7, identifier:threshold; 8, default_parameter; 9, default_parameter; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_state... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 4, 23; 4, 24; 8, 25; 8, 26; 9, 27; 9, 28; 10, 29; 11, 30; 12, 31; 13, 32; 14, 33; 14, 34; 15, 35; 15, 36; 16, 37; 16, 38; 17, 39; 18, 40; 18, 41; 19, 42; 19, 43; 20, 44; 21, 4... | 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; 1, function_definition; 2, function_name:run; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, expression_statement; 9, if_statement; 10, if_statement; 11, identifier:N; 12, integer:1; 13, identifier:trace_sort; 14, False; 15, string; 16, comparison_operator:N == 0;... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 6, 11; 6, 12; 7, 13; 7, 14; 8, 15; 9, 16; 9, 17; 10, 18; 10, 19; 10, 20; 15, 21; 16, 22; 16, 23; 17, 24; 19, 25; 19, 26; 19, 27; 20, 28; 24, 29; 25, 30; 26, 31; 27, 32; 28, 33; 28, 34; 30, 35; 30, 36; 31, 37; 31, 38; 33, 39; 34, 40; 35, 41; 35, 42; 36, 43; 36... | 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; 1, function_definition; 2, function_name:_get_samples; 3, parameters; 4, block; 5, identifier:self; 6, identifier:N; 7, identifier:trace_sort; 8, expression_statement; 9, comment:# allocate an empty numpy array to store the run and append accept count; 10, comment:# (importance sampling accepts all points); ... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 8, 14; 11, 15; 13, 16; 13, 17; 13, 18; 15, 19; 15, 20; 17, 21; 17, 22; 18, 23; 20, 24; 20, 25; 21, 26; 22, 27; 23, 28; 23, 29; 24, 30; 24, 31; 25, 32; 26, 33; 26, 34; 27, 35; 27, 36; 28, 37; 29, 38; 30, 39; 30, 40; 33, 41; 33, 42; 34, 43;... | 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; 1, function_definition; 2, function_name:argsort_indices; 3, parameters; 4, block; 5, identifier:a; 6, default_parameter; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, return_statement; 12, identifier:axis; 13, unary_operator; 14, comment:"""Like arg... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 6, 12; 6, 13; 7, 14; 8, 15; 9, 16; 10, 17; 11, 18; 13, 19; 15, 20; 15, 21; 16, 22; 16, 23; 17, 24; 17, 25; 18, 26; 18, 27; 21, 28; 21, 29; 23, 30; 23, 31; 24, 32; 24, 33; 25, 34; 25, 35; 27, 36; 28, 37; 28, 38; 29, 39; 31, 40; 34, 41; 34, 42; 35, 43; 4... | 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; 1, function_definition; 2, function_name:sorted; 3, parameters; 4, block; 5, identifier:collection; 6, expression_statement; 7, if_statement; 8, if_statement; 9, if_statement; 10, return_statement; 11, comment:"""
sorting dict by key,
schema-collection by schema-name
operations by id
... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 6, 11; 7, 12; 7, 13; 8, 14; 8, 15; 9, 16; 9, 17; 9, 18; 9, 19; 10, 20; 12, 21; 12, 22; 13, 23; 14, 24; 14, 25; 15, 26; 16, 27; 16, 28; 17, 29; 18, 30; 18, 31; 19, 32; 20, 33; 20, 34; 21, 35; 21, 36; 23, 37; 25, 38; 25, 39; 26, 40; 28, 41; 28, 42; 29, 43; 30, ... | 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; 1, function_definition; 2, function_name:get_schemas; 3, parameters; 4, block; 5, identifier:cls; 6, default_parameter; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, if_statement; 11, if_statement; 12, return_statement; 13, identifier:schema_types; 14, None; 15, identifier:sort;... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 6, 13; 6, 14; 7, 15; 7, 16; 8, 17; 9, 18; 10, 19; 10, 20; 11, 21; 11, 22; 12, 23; 18, 24; 18, 25; 20, 26; 22, 27; 25, 28; 25, 29; 26, 30; 27, 31; 29, 32; 29, 33; 30, 34; 30, 35; 31, 36; 31, 37; 32, 38; 32, 39; 33, 40; 33, 41; 35, 42; 35, 43; 37,... | 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; 1, function_definition; 2, function_name:to_molden; 3, parameters; 4, block; 5, identifier:cartesian_list; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, expression_statement; 11, if_statement; 12, expression_statement; 13, expression_statement; 14, expression_sta... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 6, 20; 6, 21; 7, 22; 7, 23; 8, 24; 8, 25; 9, 26; 9, 27; 10, 28; 11, 29; 11, 30; 12, 31; 13, 32; 14, 33; 15, 34; 16, 35; 17, 36; 18, 37; 19, 38; 19, 39; 19, 40; 27, 41; 27, 42; 30, 43; 31, 44; 31, ... | 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; 1, function_definition; 2, function_name:get_inertia; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, function_definition; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, return_statement; 14, comment... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 6, 14; 7, 15; 7, 16; 7, 17; 8, 18; 9, 19; 10, 20; 11, 21; 12, 22; 13, 23; 16, 24; 17, 25; 17, 26; 17, 27; 17, 28; 17, 29; 17, 30; 17, 31; 17, 32; 18, 33; 18, 34; 19, 35; 19, 36; 20, 37; 20, 38; 21, 39; 21, 40; 22, 41; 22, 42; 23, 43; 23, ... | 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; 1, function_definition; 2, function_name:to_xyz; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, expression_statement; 13, if_statement; 14, comment:# NOTE the following migh... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 6, 20; 6, 21; 7, 22; 7, 23; 8, 24; 8, 25; 9, 26; 9, 27; 10, 28; 10, 29; 11, 30; 11, 31; 12, 32; 13, 33; 13, 34; 13, 35; 17, 36; 18, 37; 19, 38; 19, 39; 19, 40; 29, 41; 29, 42; 34, 43; 35, 44; 36, ... | 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; 1, function_definition; 2, function_name:priority; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, comment:# Markers have priority set on the class; 8, if_statement; 9, comment:# Other types have static priority; 10, return_statement; 11, comment:""" Get priority for this Schema.
... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 6, 11; 8, 12; 8, 13; 10, 14; 12, 15; 12, 16; 13, 17; 14, 18; 14, 19; 15, 20; 15, 21; 16, 22; 16, 23; 17, 24; 18, 25; 18, 26; 19, 27; 19, 28; 22, 29; 22, 30; 24, 31; 24, 32; 31, 33; 31, 34 | 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; 1, function_definition; 2, function_name:sort_schemas; 3, parameters; 4, block; 5, identifier:cls; 6, identifier:schemas_list; 7, expression_statement; 8, return_statement; 9, comment:""" Sort the provided list of schemas according to their priority.
This also supports markers, and markers of a sing... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 7, 9; 8, 10; 10, 11; 10, 12; 12, 13; 12, 14; 12, 15; 14, 16; 14, 17; 15, 18; 15, 19; 17, 20; 17, 21; 20, 22; 21, 23; 21, 24; 21, 25; 21, 26; 21, 27; 21, 28; 25, 29; 25, 30; 28, 31; 28, 32; 28, 33; 31, 34; 31, 35; 32, 36; 32, 37; 34, 38; 34, 39; 36, 40; 36, 41; 37, 42; 37,... | 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; 1, function_definition; 2, function_name:patch_cursor; 3, parameters; 4, block; 5, identifier:cursor; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, dictionary_splat_pattern; 11, expression_statement; 12, if_statement; 13, if_statement; 14, if_statement; 15, if_st... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 6, 16; 6, 17; 7, 18; 7, 19; 8, 20; 8, 21; 9, 22; 9, 23; 10, 24; 11, 25; 12, 26; 12, 27; 13, 28; 13, 29; 14, 30; 14, 31; 15, 32; 15, 33; 26, 34; 26, 35; 27, 36; 28, 37; 28, 38; 29, 39; 30, 40; 30, 41; 31, 42; 32, 43; 32, 44; ... | 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; 1, function_definition; 2, function_name:add_interval; 3, parameters; 4, block; 5, identifier:self; 6, identifier:start; 7, identifier:end; 8, default_parameter; 9, expression_statement; 10, comment:# Ignore intervals of 0 or negative length; 11, if_statement; 12, if_statement; 13, identifier:data; 14, None;... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 4, 12; 8, 13; 8, 14; 9, 15; 11, 16; 11, 17; 12, 18; 12, 19; 12, 20; 12, 21; 12, 22; 16, 23; 16, 24; 17, 25; 18, 26; 18, 27; 20, 28; 21, 29; 21, 30; 21, 31; 22, 32; 22, 33; 23, 34; 26, 35; 26, 36; 28, 37; 29, 38; 29, 39; 31, 40; 33, 41; 33, 42; 33, 43; ... | 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; 1, function_definition; 2, function_name:parse; 3, parameters; 4, block; 5, identifier:cls; 6, identifier:querydict; 7, expression_statement; 8, for_statement; 9, expression_statement; 10, return_statement; 11, comment:""" Parse querydict data.
There are expected agruments:
distinct, fie... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 7, 11; 8, 12; 8, 13; 8, 14; 9, 15; 10, 16; 13, 17; 13, 18; 14, 19; 15, 20; 15, 21; 17, 22; 17, 23; 19, 24; 19, 25; 21, 26; 21, 27; 24, 28; 25, 29; 25, 30; 27, 31; 27, 32; 27, 33; 27, 34; 27, 35; 27, 36; 28, 37; 28, 38; 29, 39; 30, 40; 31, 41; 31, 42; 32, 43; ... | 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; 1, function_definition; 2, function_name:_pcca_connected_isa; 3, parameters; 4, block; 5, identifier:evec; 6, identifier:n_clusters; 7, expression_statement; 8, expression_statement; 9, comment:# do we have enough eigenvectors?; 10, if_statement; 11, comment:# check if the first, and only the first eigenvect... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 4, 23; 4, 24; 4, 25; 4, 26; 4, 27; 4, 28; 4, 29; 4, 30; 4, 31; 4, 32; 4, 33; 4, 34; 7, 35; 8, 36; 10, 37; 10, 38; 12, 39; 13, 40; 13, 41; 14, 42; 14, 43; 16, 44; 17, 45; 18, 4... | 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; 1, function_definition; 2, function_name:_opt_soft; 3, parameters; 4, block; 5, identifier:eigvectors; 6, identifier:rot_matrix; 7, identifier:n_clusters; 8, expression_statement; 9, comment:# only consider first n_clusters eigenvectors; 10, expression_statement; 11, comment:# crop first row and first column... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 4, 23; 8, 24; 10, 25; 13, 26; 14, 27; 16, 28; 18, 29; 18, 30; 18, 31; 18, 32; 19, 33; 19, 34; 20, 35; 21, 36; 22, 37; 23, 38; 25, 39; 25, 40; 26, 41; 26, 42; 27, 43; 27, 44; 2... | 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; 1, function_definition; 2, function_name:connected_sets; 3, parameters; 4, block; 5, identifier:C; 6, default_parameter; 7, expression_statement; 8, if_statement; 9, identifier:directed; 10, True; 11, comment:r"""Compute connected sets of microstates.
Connected components for a directed graph with edge-... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 6, 9; 6, 10; 7, 11; 8, 12; 8, 13; 8, 14; 12, 15; 12, 16; 13, 17; 14, 18; 16, 19; 17, 20; 18, 21; 20, 22; 20, 23; 21, 24; 22, 25; 22, 26; 23, 27; 23, 28; 24, 29; 24, 30; 25, 31; 25, 32; 27, 33; 27, 34; 28, 35; 28, 36; 29, 37; 29, 38; 30, 39; 30, 40; 34, 41; 37, 42; 37, 43;... | 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; 1, function_definition; 2, function_name:zcount; 3, parameters; 4, block; 5, identifier:self; 6, identifier:name; 7, identifier:score_start; 8, identifier:score_end; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, return_statement; 13, comment:"""
Returns the number o... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 4, 12; 9, 13; 10, 14; 11, 15; 12, 16; 14, 17; 14, 18; 15, 19; 15, 20; 16, 21; 16, 22; 18, 23; 18, 24; 20, 25; 20, 26; 21, 27; 21, 28; 22, 29; 22, 30; 22, 31; 22, 32; 24, 33; 24, 34; 26, 35; 26, 36; 29, 37; 33, 38; 35, 39 | 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; 1, function_definition; 2, function_name:reload_index; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, while_statement; 11, expression_statement; 12, expression_statement; 13, identifier:progress_cb; 14, identif... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 6, 13; 6, 14; 7, 15; 8, 16; 9, 17; 10, 18; 10, 19; 11, 20; 12, 21; 16, 22; 16, 23; 17, 24; 17, 25; 18, 26; 18, 27; 19, 28; 19, 29; 20, 30; 20, 31; 21, 32; 21, 33; 23, 34; 23, 35; 26, 36; 26, 37; 28, 38; 29, 39; 31, 40; 31, 41; 31, 42; 32, 43; 32... | 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; 1, function_definition; 2, function_name:__doc_cmp; 3, parameters; 4, block; 5, identifier:self; 6, identifier:other; 7, expression_statement; 8, if_statement; 9, if_statement; 10, if_statement; 11, comment:"""
Comparison function. Can be used to sort docs alphabetically.
"""; 12, comparison_... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 7, 11; 8, 12; 8, 13; 9, 14; 9, 15; 10, 16; 10, 17; 10, 18; 10, 19; 12, 20; 12, 21; 13, 22; 14, 23; 14, 24; 15, 25; 16, 26; 16, 27; 17, 28; 18, 29; 18, 30; 19, 31; 22, 32; 23, 33; 23, 34; 24, 35; 24, 36; 25, 37; 26, 38; 26, 39; 27, 40; 27, 41; 28, 42; 29, 43; ... | 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; 1, function_definition; 2, function_name:__label_cmp; 3, parameters; 4, block; 5, identifier:self; 6, identifier:other; 7, expression_statement; 8, if_statement; 9, expression_statement; 10, expression_statement; 11, if_statement; 12, if_statement; 13, comment:"""
Comparaison function. Can be used to... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 7, 13; 8, 14; 8, 15; 9, 16; 10, 17; 11, 18; 11, 19; 11, 20; 11, 21; 12, 22; 12, 23; 12, 24; 12, 25; 14, 26; 14, 27; 15, 28; 16, 29; 16, 30; 17, 31; 17, 32; 18, 33; 18, 34; 19, 35; 20, 36; 20, 37; 21, 38; 22, 39; 22, 40; 23, 41; 24, 42; 24, 43; 2... | 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; 1, function_definition; 2, function_name:stop_sequence; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, return_statement; 8, comment:"""Return the sorted StopTimes for this trip."""; 9, call; 10, identifier:sorted; 11, argument_list; 12, call; 13, keyword_argument; 14, attribute; 15,... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 6, 8; 7, 9; 9, 10; 9, 11; 11, 12; 11, 13; 12, 14; 12, 15; 13, 16; 13, 17; 14, 18; 14, 19; 17, 20; 17, 21; 20, 22; 21, 23; 21, 24; 24, 25; 25, 26; 25, 27; 26, 28; 26, 29; 27, 30; 30, 31 | 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; 1, function_definition; 2, function_name:near; 3, parameters; 4, block; 5, identifier:cls; 6, identifier:collection; 7, identifier:latitude; 8, identifier:longitude; 9, identifier:index_id; 10, default_parameter; 11, default_parameter; 12, default_parameter; 13, expression_statement; 14, expression_statement... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 4, 13; 4, 14; 4, 15; 10, 16; 10, 17; 11, 18; 11, 19; 12, 20; 12, 21; 13, 22; 14, 23; 15, 24; 23, 25; 23, 26; 24, 27; 24, 28; 26, 29; 26, 30; 26, 31; 26, 32; 26, 33; 26, 34; 27, 35; 27, 36; 28, 37; 28, 38; 28, 39; 28, 40; 29, 41; 29, 42; 30, 43; ... | 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; 1, function_definition; 2, function_name:rank_targets; 3, parameters; 4, block; 5, identifier:sample_frame; 6, identifier:ref_targets; 7, identifier:ref_sample; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_state... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 8, 22; 9, 23; 10, 24; 11, 25; 12, 26; 13, 27; 14, 28; 15, 29; 16, 30; 16, 31; 17, 32; 18, 33; 19, 34; 20, 35; 21, 36; 23, 37; 23, 38; 24, 39; 24, 40; 25, 41; 25, 42; 26, 43; 26, 44; ... | 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; 1, function_definition; 2, function_name:natural_sort_key; 3, parameters; 4, block; 5, identifier:s; 6, expression_statement; 7, return_statement; 8, comment:"""
returns a key that can be used in sort functions.
Example:
>>> items = ['A99', 'a1', 'a2', 'a10', 'a24', 'a12', 'a100']
The norm... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 6, 8; 7, 9; 9, 10; 9, 11; 10, 12; 10, 13; 10, 14; 11, 15; 11, 16; 12, 17; 12, 18; 13, 19; 13, 20; 16, 21; 16, 22; 18, 23; 19, 24; 19, 25; 21, 26; 21, 27; 22, 28; 22, 29; 29, 30; 29, 31; 31, 32 | 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; 1, function_definition; 2, function_name:relabel_nodes; 3, parameters; 4, block; 5, identifier:G; 6, identifier:mapping; 7, default_parameter; 8, expression_statement; 9, comment:# you can pass a function f(old_label)->new_label; 10, comment:# but we'll just make a dictionary here regardless; 11, if_statemen... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 7, 13; 7, 14; 8, 15; 11, 16; 11, 17; 11, 18; 12, 19; 12, 20; 12, 21; 16, 22; 17, 23; 18, 24; 20, 25; 21, 26; 22, 27; 22, 28; 23, 29; 24, 30; 25, 31; 26, 32; 28, 33; 28, 34; 29, 35; 29, 36; 30, 37; 31, 38; 31, 39; 32, 40; 36, 41; 36, 42; 37, 43; ... | 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; 1, function_definition; 2, function_name:convert_node_labels_to_integers; 3, parameters; 4, block; 5, identifier:G; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, expression_statement; 11, if_statement; 12, expression_statement; 13, expression_statement; 14, co... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 6, 17; 6, 18; 7, 19; 7, 20; 8, 21; 8, 22; 9, 23; 10, 24; 11, 25; 11, 26; 11, 27; 11, 28; 11, 29; 11, 30; 12, 31; 13, 32; 15, 33; 15, 34; 16, 35; 24, 36; 24, 37; 25, 38; 25, 39; 26, 40; 27, 41; 27, 42; 28, 43; 28, 44; ... | 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; 1, function_definition; 2, function_name:get_token_ids; 3, parameters; 4, block; 5, identifier:tree; 6, expression_statement; 7, function_definition; 8, expression_statement; 9, return_statement; 10, comment:"""
returns a list of all token IDs occuring the the given exmaralda file,
sorted by ... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 6, 10; 7, 11; 7, 12; 7, 13; 8, 14; 9, 15; 12, 16; 13, 17; 13, 18; 14, 19; 14, 20; 15, 21; 15, 22; 17, 23; 18, 24; 20, 25; 20, 26; 21, 27; 21, 28; 22, 29; 22, 30; 23, 31; 24, 32; 24, 33; 25, 34; 25, 35; 26, 36; 27, 37; 27, 38; 28, 39; 30, 40; 30, 41; 33, 42; 36, 43; ... | 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; 1, function_definition; 2, function_name:get_span; 3, parameters; 4, block; 5, identifier:docgraph; 6, identifier:node_id; 7, default_parameter; 8, expression_statement; 9, if_statement; 10, expression_statement; 11, if_statement; 12, for_statement; 13, return_statement; 14, identifier:debug; 15, False; 16, ... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 7, 14; 7, 15; 8, 16; 9, 17; 9, 18; 10, 19; 11, 20; 11, 21; 12, 22; 12, 23; 12, 24; 13, 25; 17, 26; 17, 27; 18, 28; 19, 29; 19, 30; 20, 31; 20, 32; 21, 33; 22, 34; 22, 35; 22, 36; 23, 37; 23, 38; 24, 39; 24, 40; 24, 41; 25, 42; 25, 43; 26,... | 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; 1, function_definition; 2, function_name:_get_terminals_and_nonterminals; 3, parameters; 4, block; 5, identifier:sentence_graph; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, return_statement; 11, comment:"""
Given a TigerSentenceGraph, returns a sorted ... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 6, 11; 7, 12; 8, 13; 9, 14; 9, 15; 9, 16; 10, 17; 12, 18; 12, 19; 13, 20; 13, 21; 15, 22; 15, 23; 16, 24; 17, 25; 17, 26; 17, 27; 19, 28; 19, 29; 21, 30; 21, 31; 22, 32; 22, 33; 24, 34; 24, 35; 24, 36; 24, 37; 25, 38; 25, 39; 27, 40; 27, 41; 34, 42; 34, 43; 3... | 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; 1, function_definition; 2, function_name:print_sorted_counter; 3, parameters; 4, block; 5, identifier:counter; 6, default_parameter; 7, expression_statement; 8, for_statement; 9, identifier:tab; 10, integer:1; 11, comment:"""print all elements of a counter in descending order"""; 12, pattern_list; 13, call; ... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 6, 9; 6, 10; 7, 11; 8, 12; 8, 13; 8, 14; 12, 15; 12, 16; 13, 17; 13, 18; 14, 19; 18, 20; 18, 21; 18, 22; 19, 23; 20, 24; 20, 25; 21, 26; 21, 27; 22, 28; 22, 29; 23, 30; 23, 31; 24, 32; 24, 33; 27, 34; 27, 35; 30, 36; 30, 37; 31, 38; 31, 39; 31, 40; 35, 41; 38, 42; 38, 43;... | 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; 1, function_definition; 2, function_name:sorted_bfs_edges; 3, parameters; 4, block; 5, identifier:G; 6, default_parameter; 7, expression_statement; 8, if_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, while_statement; 14, identifier:sourc... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 6, 14; 6, 15; 7, 16; 8, 17; 8, 18; 9, 19; 10, 20; 11, 21; 12, 22; 13, 23; 13, 24; 17, 25; 17, 26; 18, 27; 19, 28; 19, 29; 20, 30; 20, 31; 21, 32; 21, 33; 22, 34; 22, 35; 24, 36; 24, 37; 27, 38; 29, 39; 29, 40; 31, 41; 31, 42; 33, 43; 33, ... | 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; 1, function_definition; 2, function_name:sorted_bfs_successors; 3, parameters; 4, block; 5, identifier:G; 6, default_parameter; 7, expression_statement; 8, if_statement; 9, expression_statement; 10, for_statement; 11, return_statement; 12, identifier:source; 13, None; 14, comment:"""Return dictionary of succ... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 6, 12; 6, 13; 7, 14; 8, 15; 8, 16; 9, 17; 10, 18; 10, 19; 10, 20; 11, 21; 15, 22; 15, 23; 16, 24; 17, 25; 17, 26; 18, 27; 18, 28; 19, 29; 19, 30; 20, 31; 21, 32; 21, 33; 24, 34; 26, 35; 26, 36; 30, 37; 30, 38; 31, 39; 33, 40; 34, 41; 34, 42; 36, 43; 39... | 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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.