nodes
stringlengths
501
22.4k
edges
stringlengths
138
5.07k
code
stringlengths
108
19.3k
0, module; 1, function_definition; 2, function_name:serialize_to_normalized_pretty_json; 3, parameters; 4, block; 5, identifier:py_obj; 6, expression_statement; 7, return_statement; 8, comment:"""Serialize a native object to normalized, pretty printed JSON. The JSON string is normalized by sorting any dictionary k...
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; 11, 16; 11, 17; 15, 18; 15, 19; 16, 20; 16, 21; 17, 22; 17, 23
def serialize_to_normalized_pretty_json(py_obj): """Serialize a native object to normalized, pretty printed JSON. The JSON string is normalized by sorting any dictionary keys. Args: py_obj: object Any object that can be represented in JSON. Some types, such as datetimes are automatic...
0, module; 1, function_definition; 2, function_name:serialize_to_normalized_compact_json; 3, parameters; 4, block; 5, identifier:py_obj; 6, expression_statement; 7, return_statement; 8, comment:"""Serialize a native object to normalized, compact JSON. The JSON string is normalized by sorting any dictionary keys. I...
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; 11, 16; 11, 17; 15, 18; 15, 19; 16, 20; 16, 21; 17, 22; 17, 23; 21, 24; 21, 25; 24, 26; 25, 27
def serialize_to_normalized_compact_json(py_obj): """Serialize a native object to normalized, compact JSON. The JSON string is normalized by sorting any dictionary keys. It will be on a single line without whitespace between elements. Args: py_obj: object Any object that can be represent...
0, module; 1, function_definition; 2, function_name:topological_sort; 3, parameters; 4, block; 5, identifier:unsorted_dict; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, while_statement; 12, return_statement; 13, comment:"""Sort objects...
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; 12, 20; 14, 21; 14, 22; 15, 23; 15, 24; 16, 25; 16, 26; 17, 27; 17, 28; 19, 29; 19, 30; 20, 31; 20, 32; 24, 33; 24, 34; 28, 35; 28, 36; 29, 37; 30, 38; 30, 39; 30, 40; 35, 41; 35, 42; 37, 43; 3...
def topological_sort(unsorted_dict): """Sort objects by dependency. Sort a dict of obsoleting PID to obsoleted PID to a list of PIDs in order of obsolescence. Args: unsorted_dict : dict Dict that holds obsolescence information. Each ``key/value`` pair establishes that the PID in ...
0, module; 1, function_definition; 2, function_name:sort_elements_by_child_values; 3, parameters; 4, block; 5, identifier:obj_pyxb; 6, identifier:child_name_list; 7, expression_statement; 8, expression_statement; 9, comment:"""In-place sort simple or complex elements in a PyXB object by values they contain in child...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 7, 9; 8, 10; 10, 11; 10, 12; 11, 13; 11, 14; 12, 15; 15, 16; 15, 17; 17, 18; 17, 19; 18, 20; 19, 21; 19, 22; 21, 23; 21, 24; 22, 25; 22, 26; 24, 27; 27, 28; 27, 29; 29, 30; 29, 31
def sort_elements_by_child_values(obj_pyxb, child_name_list): """In-place sort simple or complex elements in a PyXB object by values they contain in child elements. Args: obj_pyxb: PyXB object child_name_list: list of str List of element names that are direct children of the PyXB objec...
0, module; 1, function_definition; 2, function_name:get_field_values; 3, parameters; 4, block; 5, identifier:self; 6, identifier:name; 7, default_parameter; 8, default_parameter; 9, dictionary_splat_pattern; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, expr...
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; 7, 17; 7, 18; 8, 19; 8, 20; 9, 21; 10, 22; 11, 23; 12, 24; 13, 25; 14, 26; 15, 27; 16, 28; 18, 29; 23, 30; 23, 31; 24, 32; 24, 33; 25, 34; 25, 35; 26, 36; 26, 37; 27, 38; 27, 39; 31, 40; 31, 41; 32, 42; 32, 43; 33, 44...
def get_field_values(self, name, maxvalues=-1, sort=True, **query_dict): """Retrieve the unique values for a field, along with their usage counts. :param name: Name of field for which to retrieve values :type name: string :param sort: Sort the result :param maxvalues: Maximum ...
0, module; 1, function_definition; 2, function_name:bin; 3, parameters; 4, block; 5, identifier:x; 6, identifier:bins; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, if_statement; 11, if_statement; 12, if_statement; 13, comment:# digitize works on 1d array but not nd arrays.; 14, comment:# So ...
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; 11, 24; 12, 25; 12, 26; 15, 27; 20, 28; 21, 29; 21, 30; 22, 31; 23, 32; 23, 33; 24, 34; 25, 35; 26, 36; 27, 37; 27, 38; 31, 39; 34, 40; 35, 41; 35, 42; 36, 43; 37, 4...
def bin(x, bins, maxX=None, minX=None): ''' bin signal x using 'binsN' bin. If minX, maxX are None, they default to the full range of the signal. If they are not None, everything above maxX gets assigned to binsN-1 and everything below minX gets assigned to 0, this is effectively the same as clippin...
0, module; 1, function_definition; 2, function_name:update_item; 3, parameters; 4, block; 5, identifier:self; 6, identifier:table_name; 7, identifier:key_dict; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, default_parameter; 13, default_parameter; 14, default_parameter; 1...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 3, 13; 3, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 4, 23; 8, 24; 8, 25; 9, 26; 9, 27; 10, 28; 10, 29; 11, 30; 11, 31; 12, 32; 12, 33; 13, 34; 13, 35; 14, 36; 14, 37; 15, 38; 16, 39; 17, 40; 17, 41; 18, 42; 18, 43; 19, 44; 19, ...
def update_item(self, table_name, key_dict, condition_expression=None, update_expression=None, expression_attribute_names=None, expression_attribute_values=None, return_consumed_capacity=None, return_...
0, module; 1, function_definition; 2, function_name:query; 3, parameters; 4, block; 5, identifier:self; 6, identifier:table_name; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, default_parameter; 13, default_parameter; 14, default_parameter; 15, defau...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 3, 13; 3, 14; 3, 15; 3, 16; 3, 17; 3, 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; 7, 33; 7, 34; 8, 35; 8, 36; 9, 37; 9, 38; 10, 39; 10, 40; 11, 41; 11, 42; 12, 43; 12, 44; 13, 45; 13, 46;...
def query(self, table_name, index_name=None, consistent_read=None, key_condition_expression=None, filter_expression=None, expression_attribute_names=None, expression_attribute_values=None, projection_expression=None, ...
0, module; 1, function_definition; 2, function_name:get_gae_versions; 3, parameters; 4, block; 5, expression_statement; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, comment:# We only care about the Python releases, which all are in the format; 10, comment:# "featured/google_appengine_{v...
0, 1; 1, 2; 1, 3; 1, 4; 4, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 5, 16; 6, 17; 7, 18; 8, 19; 13, 20; 14, 21; 14, 22; 14, 23; 15, 24; 17, 25; 17, 26; 18, 27; 18, 28; 19, 29; 19, 30; 20, 31; 20, 32; 23, 33; 23, 34; 23, 35; 24, 36; 24, 37; 26, 38; 26, 39; 27, 40; 27, 41; 30, 42; 30, 43; 33, ...
def get_gae_versions(): """Gets a list of all of the available Python SDK versions, sorted with the newest last.""" r = requests.get(SDK_RELEASES_URL) r.raise_for_status() releases = r.json().get('items', {}) # We only care about the Python releases, which all are in the format # "featured...
0, module; 1, function_definition; 2, function_name:_parse_options; 3, parameters; 4, type; 5, block; 6, typed_parameter; 7, generic_type; 8, expression_statement; 9, try_statement; 10, identifier:options; 11, type; 12, identifier:Dict; 13, type_parameter; 14, comment:""" Parse repeatable CLI options >>> opts = _p...
0, 1; 1, 2; 1, 3; 1, 4; 1, 5; 3, 6; 4, 7; 5, 8; 5, 9; 6, 10; 6, 11; 7, 12; 7, 13; 8, 14; 9, 15; 9, 16; 11, 17; 13, 18; 13, 19; 15, 20; 16, 21; 16, 22; 17, 23; 17, 24; 18, 25; 19, 26; 20, 27; 22, 28; 24, 29; 27, 30; 27, 31; 28, 32; 29, 33; 31, 34; 31, 35; 32, 36; 32, 37; 34, 38; 34, 39; 35, 40; 35, 41; 37, 42; 38, 43; 3...
def _parse_options(options: List[str]) -> Dict[str, str]: """ Parse repeatable CLI options >>> opts = _parse_options(['cluster.name=foo', 'CRATE_JAVA_OPTS="-Dxy=foo"']) >>> print(json.dumps(opts, sort_keys=True)) {"CRATE_JAVA_OPTS": "\\"-Dxy=foo\\"", "cluster.name": "foo"} """ try: retu...
0, module; 1, function_definition; 2, function_name:collapse; 3, parameters; 4, block; 5, identifier:l; 6, identifier:raw; 7, expression_statement; 8, expression_statement; 9, comment:# LiPD data (in progress), sorted dataset name; 10, expression_statement; 11, expression_statement; 12, try_statement; 13, expression_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; 7, 15; 8, 16; 10, 17; 11, 18; 12, 19; 12, 20; 12, 21; 13, 22; 14, 23; 16, 24; 16, 25; 17, 26; 17, 27; 18, 28; 18, 29; 20, 30; 20, 31; 20, 32; 20, 33; 20, 34; 21, 35; 21, 36; 22, 37; 22, 38; 24, 39; 24, 40; 25, 41; 30, 42; 32, 43; 3...
def collapse(l, raw): """ LiPD Version 1.3 Main function to initiate time series to LiPD conversion Each object has a: "paleoNumber" or "chronNumber" "tableNumber" "modelNumber" "time_id" "mode" - chronData or paleoData "tableType" - "meas" "ens" "summ" :param list l: Time ...
0, module; 1, function_definition; 2, function_name:collapseTs; 3, parameters; 4, block; 5, default_parameter; 6, expression_statement; 7, comment:# Retrieve the associated raw data according to the "time_id" found in each object. Match it in _timeseries_data; 8, global_statement; 9, expression_statement; 10, if_statem...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 5, 12; 5, 13; 6, 14; 8, 15; 9, 16; 10, 17; 10, 18; 10, 19; 11, 20; 16, 21; 16, 22; 17, 23; 18, 24; 19, 25; 19, 26; 24, 27; 26, 28; 27, 29; 27, 30; 28, 31; 28, 32; 30, 33; 31, 34; 31, 35; 31, 36; 31, 37; 32, 38; 32, 39; 34, 40; 35, 41; 36, 42; 37, 43; 3...
def collapseTs(ts=None): """ Collapse a time series back into LiPD record form. | Example | 1. D = lipd.readLipd() | 2. ts = lipd.extractTs(D) | 3. New_D = lipd.collapseTs(ts) _timeseries_data is sorted by time_id, and then by dataSetName _timeseries_data[10103341]["ODP1098B"] = {data}...
0, module; 1, function_definition; 2, function_name:display_results; 3, parameters; 4, block; 5, identifier:results; 6, default_parameter; 7, expression_statement; 8, comment:# print("\nVALIDATOR RESULTS"); 9, comment:# print("======================\n"); 10, if_statement; 11, for_statement; 12, return_statement; 13, id...
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; 10, 16; 10, 17; 11, 18; 11, 19; 11, 20; 16, 21; 17, 22; 20, 23; 22, 24; 23, 25; 23, 26; 24, 27; 24, 28; 25, 29; 26, 30; 26, 31; 28, 32; 29, 33; 29, 34; 29, 35; 30, 36; 30, 37; 31, 38; 31, 39; 32, 40; 34, 41; 34, 42; 35, 43; ...
def display_results(results, detailed=False): """ Display the results from the validator in a brief or detailed output :param list results: API results, sorted by dataset name (multiple) :param bool detailed: Detailed results on or off :return none: """ # print("\nVALIDATOR RESULTS") # ...
0, module; 1, function_definition; 2, function_name:call_validator_api; 3, parameters; 4, block; 5, identifier:dsn; 6, identifier:api_data; 7, expression_statement; 8, expression_statement; 9, try_statement; 10, if_statement; 11, expression_statement; 12, return_statement; 13, comment:""" Single call to the lipd.ne...
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; 9, 15; 9, 16; 9, 17; 9, 18; 9, 19; 9, 20; 10, 21; 10, 22; 11, 23; 12, 24; 14, 25; 14, 26; 17, 27; 17, 28; 17, 29; 17, 30; 17, 31; 17, 32; 17, 33; 17, 34; 18, 35; 18, 36; 19, 37; 19, 38; 20, 39; 20, 40; 21, 41; 22, 42; 23, 43; 23, 4...
def call_validator_api(dsn, api_data): """ Single call to the lipd.net validator API 'api_data' format: [ {"type": "csv", "filenameFull": /path/to/filename.csv, "data": "", ...}, {"type": "json", "filenameFull": /path/to/metadata.jsonld, "data": "", ...}, ... ] Result f...
0, module; 1, function_definition; 2, function_name:create_back_links; 3, parameters; 4, block; 5, identifier:env; 6, expression_statement; 7, if_statement; 8, expression_statement; 9, for_statement; 10, expression_statement; 11, comment:""" Create back-links in all found needs. But do this only once, as all ne...
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; 9, 15; 9, 16; 9, 17; 10, 18; 12, 19; 12, 20; 13, 21; 14, 22; 14, 23; 15, 24; 15, 25; 16, 26; 16, 27; 17, 28; 18, 29; 18, 30; 19, 31; 19, 32; 20, 33; 23, 34; 23, 35; 26, 36; 26, 37; 28, 38; 28, 39; 28, 40; 29, 41; 29, 42; 39, 43; 39...
def create_back_links(env): """ Create back-links in all found needs. But do this only once, as all needs are already collected and this sorting is for all needs and not only for the ones of the current document. :param env: sphinx enviroment :return: None """ if env.needs_workflow['bac...
0, module; 1, function_definition; 2, function_name:CaseGroups; 3, parameters; 4, block; 5, default_parameter; 6, expression_statement; 7, comment:# Dict mapping lowercase code point to fold-equivalent group.; 8, expression_statement; 9, function_definition; 10, expression_statement; 11, expression_statement; 12, for_s...
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; 5, 15; 5, 16; 6, 17; 8, 18; 9, 19; 9, 20; 9, 21; 10, 22; 11, 23; 12, 24; 12, 25; 12, 26; 13, 27; 14, 28; 18, 29; 18, 30; 20, 31; 20, 32; 21, 33; 21, 34; 21, 35; 21, 36; 21, 37; 22, 38; 22, 39; 23, 40; 23, 41; 26, 42; 27, 43; 27, 44...
def CaseGroups(unicode_dir=_UNICODE_DIR): """Returns list of Unicode code groups equivalent under case folding. Each group is a sorted list of code points, and the list of groups is sorted by first code point in the group. Args: unicode_dir: Unicode data directory Returns: list of Unicode code gr...
0, module; 1, function_definition; 2, function_name:naturalsortkey; 3, parameters; 4, block; 5, identifier:s; 6, expression_statement; 7, return_statement; 8, comment:"""Natural sort order"""; 9, list_comprehension; 10, conditional_expression:int(part) if part.isdigit() else part; 11, for_in_clause; 12, call; 13, call;...
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; 28, 30
def naturalsortkey(s): """Natural sort order""" return [int(part) if part.isdigit() else part for part in re.split('([0-9]+)', s)]
0, module; 1, function_definition; 2, function_name:max_variance_genes; 3, parameters; 4, block; 5, identifier:data; 6, default_parameter; 7, default_parameter; 8, expression_statement; 9, comment:# TODO: profile, make more efficient for large matrices; 10, comment:# 8000 cells: 0.325 seconds; 11, comment:# top time: s...
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; 4, 24; 6, 25; 6, 26; 7, 27; 7, 28; 8, 29; 18, 30; 19, 31; 19, 32; 19, 33; 20, 34; 21, 35; 22, 36; 23, 37; 23, 38; 23, 39; 24, 40; 30, 41; 30, 42; 31, 43; 31, 44; 32, 45...
def max_variance_genes(data, nbins=5, frac=0.2): """ This function identifies the genes that have the max variance across a number of bins sorted by mean. Args: data (array): genes x cells nbins (int): number of bins to sort genes by mean expression level. Default: 10. frac (flo...
0, module; 1, function_definition; 2, function_name:unique; 3, parameters; 4, block; 5, identifier:ar; 6, expression_statement; 7, import_statement; 8, if_statement; 9, return_statement; 10, comment:r"""Find the unique elements of an array. It uses ``dask.array.unique`` if necessary. Args: ar (array_l...
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; 11, 15; 11, 16; 12, 17; 12, 18; 13, 19; 14, 20; 14, 21; 15, 22; 15, 23; 18, 24; 18, 25; 19, 26; 21, 27; 25, 28; 25, 29; 26, 30; 26, 31; 28, 32; 28, 33; 30, 34; 30, 35; 31, 36
def unique(ar): r"""Find the unique elements of an array. It uses ``dask.array.unique`` if necessary. Args: ar (array_like): Input array. Returns: array_like: the sorted unique elements. """ import dask.array as da if isinstance(ar, da.core.Array): return da.uniq...
0, module; 1, function_definition; 2, function_name:polls_get; 3, parameters; 4, block; 5, identifier:self; 6, dictionary_splat_pattern; 7, expression_statement; 8, expression_statement; 9, if_statement; 10, identifier:kwargs; 11, comment:""" Polls A Poll on Pollster is a collection of questions and res...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 6, 10; 7, 11; 8, 12; 9, 13; 9, 14; 9, 15; 12, 16; 12, 17; 13, 18; 13, 19; 14, 20; 15, 21; 16, 22; 16, 23; 18, 24; 18, 25; 19, 26; 20, 27; 21, 28; 21, 29; 23, 30; 26, 31; 27, 32; 27, 33; 28, 34; 29, 35; 32, 36; 32, 37; 33, 38; 34, 39; 34, 40; 38, 41; 39, 42; 40, 43; ...
def polls_get(self, **kwargs): """ Polls A Poll on Pollster is a collection of questions and responses published by a reputable survey house. This endpoint provides raw data from the survey house, plus Pollster-provided metadata about each question. Pollster editors don't include every question...
0, module; 1, function_definition; 2, function_name:_sorted_actions; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, for_statement; 8, for_statement; 9, for_statement; 10, comment:""" Generate the sorted list of actions based on the "last" attribute. """; 11, identifier:a; 12, c...
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; 8, 15; 8, 16; 9, 17; 9, 18; 9, 19; 12, 20; 12, 21; 13, 22; 15, 23; 15, 24; 16, 25; 18, 26; 18, 27; 19, 28; 21, 29; 21, 30; 22, 31; 24, 32; 24, 33; 25, 34; 27, 35; 27, 36; 28, 37; 29, 38; 29, 39; 30, 40; 30, 41; 31, 42; 32, 43; 32, ...
def _sorted_actions(self): """ Generate the sorted list of actions based on the "last" attribute. """ for a in filter(lambda _: not _.last and \ not self.is_action(_, 'parsers'), self._actions): yield a for a in filter(lambda _: _.last and \ ...
0, module; 1, function_definition; 2, function_name:eigendecomp; 3, parameters; 4, block; 5, identifier:G; 6, identifier:d; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, comment:# test decomposition of G.; 11, comment:#G_hat = np.dot(np.dot(u, np.diag(lamda)), u.T); 12, comment:#assert ...
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; 7, 23; 8, 24; 9, 25; 14, 26; 15, 27; 16, 28; 17, 29; 17, 30; 18, 31; 19, 32; 20, 33; 21, 34; 22, 35; 24, 36; 24, 37; 25, 38; 25, 39; 26, 40; 26, 41; 27, 42; 27, 43; 28, 44; 28...
def eigendecomp(G, d): """ Computes sorted eigendecomposition of G. :param G: Matrix :param d: rank :return factor: vector of square root d of eigenvalues (biggest to smallest). :return u: matrix with colums equal to the normalized eigenvectors corresponding to sorted eigenvalues. """ ...
0, module; 1, function_definition; 2, function_name:get_astrom; 3, parameters; 4, block; 5, default_parameter; 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:offic...
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; 5, 14; 5, 15; 6, 16; 6, 17; 7, 18; 8, 19; 9, 20; 10, 21; 10, 22; 10, 23; 11, 24; 12, 25; 13, 26; 15, 27; 17, 28; 19, 29; 19, 30; 20, 31; 20, 32; 21, 33; 22, 34; 23, 35; 24, 36; 24, 37; 25, 38; 25, 39; 26, 40; 26, 41; 34, 42; 35, 43; 37, 4...
def get_astrom(official='%',provisional='%'): """Query the measure table for all measurements of a particular object. Default is to return all the astrometry in the measure table, sorted by mjdate""" sql= "SELECT m.* FROM measure m " sql+="LEFT JOIN object o ON m.provisional LIKE o.provisional " ...
0, module; 1, function_definition; 2, function_name:sorted_by_field; 3, parameters; 4, block; 5, identifier:issues; 6, default_parameter; 7, default_parameter; 8, expression_statement; 9, return_statement; 10, identifier:field; 11, string; 12, identifier:reverse; 13, False; 14, comment:"""Return a list of issues sorted...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 6, 10; 6, 11; 7, 12; 7, 13; 8, 14; 9, 15; 11, 16; 15, 17; 15, 18; 18, 19; 18, 20; 18, 21; 20, 22; 20, 23; 21, 24; 21, 25; 23, 26; 23, 27; 26, 28; 27, 29; 27, 30
def sorted_by_field(issues, field='closed_at', reverse=False): """Return a list of issues sorted by closing date date.""" return sorted(issues, key = lambda i:i[field], reverse=reverse)
0, module; 1, function_definition; 2, function_name:order_by; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, expression_statement; 8, if_statement; 9, if_statement; 10, return_statement; 11, identifier:key_selector; 12, identifier:identity; 13, string; 14, call; 15, block; 16, not_operator; 17, b...
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; 9, 16; 9, 17; 10, 18; 13, 19; 14, 20; 14, 21; 15, 22; 16, 23; 17, 24; 18, 25; 18, 26; 20, 27; 20, 28; 22, 29; 23, 30; 23, 31; 24, 32; 25, 33; 25, 34; 26, 35; 26, 36; 26, 37; 29, 38; 29, 39; 31, 40; 32, 41; 32, 42; 35, 43; 35...
def order_by(self, key_selector=identity): '''Sorts by a key in ascending order. Introduces a primary sorting order to the sequence. Additional sort criteria should be specified by subsequent calls to then_by() and then_by_descending(). Calling order_by() or order_by_descending() on ...
0, module; 1, function_definition; 2, function_name:then_by; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, expression_statement; 8, if_statement; 9, if_statement; 10, expression_statement; 11, return_statement; 12, identifier:key_selector; 13, identifier:identity; 14, string; 15, call; 16, block...
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; 9, 18; 10, 19; 11, 20; 14, 21; 15, 22; 15, 23; 16, 24; 17, 25; 18, 26; 19, 27; 19, 28; 22, 29; 22, 30; 24, 31; 25, 32; 25, 33; 26, 34; 27, 35; 27, 36; 28, 37; 31, 38; 31, 39; 33, 40; 34, 41; 34, 42; 35, 43; 35,...
def then_by(self, key_selector=identity): '''Introduce subsequent ordering to the sequence with an optional key. The returned sequence will be sorted in ascending order by the selected key. Note: This method uses deferred execution. Args: key_selector: A unary func...
0, module; 1, function_definition; 2, function_name:sort; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, comment:"""Sorts all results rows. Sorts by: size (descending), n-gram, count (descending), label, text name, siglum. """; 9, call; 10, at...
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; 11, 16; 12, 17; 12, 18; 14, 19; 14, 20; 15, 21; 15, 22; 16, 23; 16, 24; 20, 25; 20, 26; 20, 27; 20, 28; 20, 29; 20, 30; 22, 31; 22, 32; 22, 33; 22, 34; 22, 35; 22, 36; 25, 37; 25, 38; 26, 39; 26, 40; 27, 41; 27, 42; 28, ...
def sort(self): """Sorts all results rows. Sorts by: size (descending), n-gram, count (descending), label, text name, siglum. """ self._matches.sort_values( by=[constants.SIZE_FIELDNAME, constants.NGRAM_FIELDNAME, constants.COUNT_FIELDNAME, constants...
0, module; 1, function_definition; 2, function_name:_set_labels; 3, parameters; 4, block; 5, identifier:self; 6, identifier:catalogue; 7, expression_statement; 8, with_statement; 9, return_statement; 10, comment:"""Returns a dictionary of the unique labels in `catalogue` and the count of all tokens associated w...
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; 12, 15; 12, 16; 12, 17; 14, 18; 15, 19; 16, 20; 17, 21; 17, 22; 17, 23; 18, 24; 18, 25; 19, 26; 19, 27; 20, 28; 20, 29; 21, 30; 21, 31; 22, 32; 22, 33; 23, 34; 23, 35; 23, 36; 23, 37; 26, 38; 26, 39; 27, 40; 27, 41; 32, 42; 32, 43...
def _set_labels(self, catalogue): """Returns a dictionary of the unique labels in `catalogue` and the count of all tokens associated with each, and sets the record of each Text to its corresponding label. Texts that do not have a label specified are set to the empty string. ...
0, module; 1, function_definition; 2, function_name:get_fn_args; 3, parameters; 4, block; 5, identifier:fn; 6, typed_parameter; 7, typed_default_parameter; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, if_statement; 14, return_stateme...
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; 6, 15; 6, 16; 7, 17; 7, 18; 7, 19; 8, 20; 9, 21; 10, 22; 11, 23; 12, 24; 13, 25; 13, 26; 14, 27; 16, 28; 18, 29; 21, 30; 21, 31; 22, 32; 22, 33; 23, 34; 23, 35; 24, 36; 24, 37; 26, 38; 31, 39; 31, 40; 33, 41; 33, 42; 35, 43; 35, 44...
def get_fn_args(fn, kwargs: dict, prefix: str = None): """ Given function and a dict of kwargs return a dict containing only the args used by the function. If prefix is specified, also search for args that begin with '{prefix}__'. Removes prefix in returned dict. Raises ValueError if a require...
0, module; 1, function_definition; 2, function_name:pick_kwargs; 3, parameters; 4, block; 5, typed_parameter; 6, typed_parameter; 7, typed_default_parameter; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, if_statement; 12, expression_statement; 13, if_statement; 14, return_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; 5, 15; 5, 16; 6, 17; 6, 18; 7, 19; 7, 20; 7, 21; 8, 22; 9, 23; 10, 24; 11, 25; 11, 26; 12, 27; 13, 28; 13, 29; 14, 30; 16, 31; 18, 32; 20, 33; 23, 34; 23, 35; 24, 36; 24, 37; 26, 38; 26, 39; 27, 40; 27, 41; 29, 42; 30, 43; 30, 44; ...
def pick_kwargs(kwargs: dict, required_args: list, prefix: str = None): """ Given a dict of kwargs and a list of required_args, return a dict containing only the args in required_args. If prefix is specified, also search for args that begin with '{prefix}__'. Removes prefix in returned dict. R...
0, module; 1, function_definition; 2, function_name:search; 3, parameters; 4, block; 5, identifier:query; 6, default_parameter; 7, expression_statement; 8, comment:# Build the SQL statement.; 9, expression_statement; 10, comment:# Execute the SQL.; 11, if_statement; 12, with_statement; 13, comment:# Wrap the SQL result...
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; 6, 15; 6, 16; 7, 17; 9, 18; 11, 19; 11, 20; 12, 21; 12, 22; 14, 23; 18, 24; 18, 25; 19, 26; 19, 27; 20, 28; 21, 29; 22, 30; 23, 31; 23, 32; 24, 33; 24, 34; 25, 35; 25, 36; 26, 37; 26, 38; 27, 39; 27, 40; 28, 41; 29, 42; 30, 43; 30,...
def search(query, query_type=DEFAULT_QUERY_TYPE): """Search database using parsed query. Executes a database search query from the given ``query`` (a ``Query`` object) and optionally accepts a list of search weights. By default, the search results are ordered by weight. :param query: containing te...
0, module; 1, function_definition; 2, function_name:get_tdms_files; 3, parameters; 4, block; 5, identifier:directory; 6, expression_statement; 7, expression_statement; 8, comment:# get all tdms files; 9, expression_statement; 10, comment:# exclude traces files; 11, expression_statement; 12, return_statement; 13, commen...
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; 9, 15; 11, 16; 12, 17; 14, 18; 14, 19; 15, 20; 15, 21; 16, 22; 16, 23; 17, 24; 17, 25; 19, 26; 19, 27; 21, 28; 21, 29; 21, 30; 23, 31; 23, 32; 23, 33; 25, 34; 26, 35; 26, 36; 29, 37; 29, 38; 30, 39; 32, 40; 32, 41; 33, 42; 35, 43; ...
def get_tdms_files(directory): """Recursively find projects based on '.tdms' file endings Searches the `directory` recursively and return a sorted list of all found '.tdms' project files, except fluorescence data trace files which end with `_traces.tdms`. """ path = pathlib.Path(directory).reso...
0, module; 1, function_definition; 2, function_name:footrule_dist; 3, parameters; 4, block; 5, identifier:params1; 6, default_parameter; 7, expression_statement; 8, assert_statement; 9, expression_statement; 10, if_statement; 11, return_statement; 12, identifier:params2; 13, None; 14, comment:r"""Compute Spearman's foo...
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; 10, 18; 10, 19; 11, 20; 15, 21; 15, 22; 16, 23; 16, 24; 17, 25; 17, 26; 18, 27; 19, 28; 20, 29; 20, 30; 21, 31; 21, 32; 22, 33; 22, 34; 24, 35; 24, 36; 27, 37; 28, 38; 29, 39; 29, 40; 30, 41; 33, 42; 33, 43; 3...
def footrule_dist(params1, params2=None): r"""Compute Spearman's footrule distance between two models. This function computes Spearman's footrule distance between the rankings induced by two parameter vectors. Let :math:`\sigma_i` be the rank of item ``i`` in the model described by ``params1``, and :ma...
0, module; 1, function_definition; 2, function_name:kendalltau_dist; 3, parameters; 4, block; 5, identifier:params1; 6, default_parameter; 7, expression_statement; 8, assert_statement; 9, expression_statement; 10, if_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, return_sta...
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; 6, 15; 6, 16; 7, 17; 8, 18; 9, 19; 10, 20; 10, 21; 10, 22; 11, 23; 12, 24; 13, 25; 14, 26; 18, 27; 18, 28; 19, 29; 19, 30; 20, 31; 20, 32; 21, 33; 22, 34; 23, 35; 23, 36; 24, 37; 24, 38; 25, 39; 25, 40; 26, 41; 26, 42; 27, 43; 27, ...
def kendalltau_dist(params1, params2=None): r"""Compute the Kendall tau distance between two models. This function computes the Kendall tau distance between the rankings induced by two parameter vectors. Let :math:`\sigma_i` be the rank of item ``i`` in the model described by ``params1``, and :math:`\t...
0, module; 1, function_definition; 2, function_name:parse_sort_string; 3, parameters; 4, block; 5, identifier:sort; 6, expression_statement; 7, if_statement; 8, expression_statement; 9, expression_statement; 10, for_statement; 11, expression_statement; 12, return_statement; 13, comment:""" Parse a sort string for u...
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; 7, 15; 8, 16; 9, 17; 10, 18; 10, 19; 10, 20; 11, 21; 12, 22; 14, 23; 14, 24; 15, 25; 16, 26; 16, 27; 17, 28; 17, 29; 20, 30; 20, 31; 20, 32; 20, 33; 20, 34; 21, 35; 21, 36; 25, 37; 27, 38; 27, 39; 30, 40; 31, 41; 32, 42; 33, 43; 34...
def parse_sort_string(sort): """ Parse a sort string for use with elasticsearch :param: sort: the sort string """ if sort is None: return ['_score'] l = sort.rsplit(',') sortlist = [] for se in l: se = se.strip() order = 'desc' if se[0:1] == '-' else 'asc' ...
0, module; 1, function_definition; 2, function_name:get_config_dir; 3, parameters; 4, block; 5, identifier:path; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, expressi...
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; 12, 26; 13, 27; 14, 28; 15, 29; 15, 30; 15, 31; 16, 32; 24, 33; 24, 34; 25, 35; 25, 36; 26, 37; 26, 38; 27, 39; 27, 40; 28, 41; 28, 42; 31, 43; 31, 44; ...
def get_config_dir(path, pattern="*.config", configspec=None, allow_errors=False): """ Load an entire directory of configuration files, merging them into one. This function will load multiple configuration files matching the given pattern, in the given path, and merge them. The found files are first sorted alphabe...
0, module; 1, function_definition; 2, function_name:is_first_instance_aws; 3, parameters; 4, block; 5, expression_statement; 6, try_statement; 7, try_statement; 8, try_statement; 9, return_statement; 10, comment:""" Returns True if the current instance is the first instance in the ASG group, sorted by instance_...
0, 1; 1, 2; 1, 3; 1, 4; 4, 5; 4, 6; 4, 7; 4, 8; 4, 9; 5, 10; 6, 11; 6, 12; 6, 13; 7, 14; 7, 15; 7, 16; 7, 17; 8, 18; 8, 19; 8, 20; 8, 21; 9, 22; 12, 23; 12, 24; 12, 25; 13, 26; 13, 27; 15, 28; 15, 29; 15, 30; 15, 31; 16, 32; 16, 33; 17, 34; 17, 35; 20, 36; 20, 37; 20, 38; 21, 39; 21, 40; 22, 41; 22, 42; 23, 43; 24, 44;...
def is_first_instance_aws(): """ Returns True if the current instance is the first instance in the ASG group, sorted by instance_id. """ try: # get instance id and aws region instance_details = requests.get('http://169.254.169.254/latest/dynamic/instance-identity/document', ...
0, module; 1, function_definition; 2, function_name:creation_ordered; 3, parameters; 4, block; 5, identifier:class_to_decorate; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, decorated_definition; 10, expression_statement; 11, comment:# noinspection PyProtectedMember; 12, function_definit...
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; 9, 20; 10, 21; 12, 22; 12, 23; 12, 24; 13, 25; 14, 26; 15, 27; 17, 28; 17, 29; 18, 30; 18, 31; 19, 32; 20, 33; 20, 34; 20, 35; 21, 36; 21, 37; 23, 38; 23, 39; 24, 40; 24, 41; 25, 42; 25, 43; 26, 4...
def creation_ordered(class_to_decorate): """ Class decorator that ensures that instances will be ordered after creation order when sorted. :type class_to_decorate: class :rtype: class """ next_index = functools.partial(next, itertools.count()) __init__orig = class_to_decorate....
0, module; 1, function_definition; 2, function_name:get_members; 3, parameters; 4, block; 5, identifier:cls; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, expression_statement; 11, if_statement; 12, expression_statement; 13, for_statement; 14, function_definition; 15, expre...
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; 6, 18; 6, 19; 7, 20; 7, 21; 8, 22; 8, 23; 9, 24; 9, 25; 10, 26; 11, 27; 11, 28; 12, 29; 13, 30; 13, 31; 13, 32; 14, 33; 14, 34; 14, 35; 15, 36; 16, 37; 16, 38; 16, 39; 17, 40; 27, 41; 27, 42; 28, 43; 29, 44; 29...
def get_members(cls, member_class=None, is_member=None, sort_key=None, _parameter=None): """ Collect all class level attributes matching the given criteria. :param class member_class: Class(es) to collect :param is_member: Function to determine if an object should be collected :para...
0, module; 1, function_definition; 2, function_name:sort_field; 3, parameters; 4, block; 5, identifier:self; 6, identifier:field_name; 7, identifier:direction; 8, default_parameter; 9, expression_statement; 10, expression_statement; 11, if_statement; 12, expression_statement; 13, return_statement; 14, identifier:field_...
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; 8, 14; 8, 15; 9, 16; 10, 17; 11, 18; 11, 19; 11, 20; 11, 21; 12, 22; 13, 23; 17, 24; 17, 25; 18, 26; 18, 27; 19, 28; 20, 29; 20, 30; 21, 31; 22, 32; 22, 33; 25, 34; 25, 35; 28, 36; 29, 37; 29, 38; 30, 39; 31, 40; 32, 41; 32, 42; 33, 43; 3...
def sort_field(self, field_name, direction, field_vals=None): """ sort this query by field_name in directrion field_name -- string -- the field to sort on direction -- integer -- negative for DESC, positive for ASC field_vals -- list -- the order the rows should be returned in ...
0, module; 1, function_definition; 2, function_name:check_photometry_categorize; 3, parameters; 4, block; 5, identifier:x; 6, identifier:y; 7, identifier:levels; 8, default_parameter; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, com...
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; 4, 22; 8, 23; 8, 24; 9, 25; 10, 26; 11, 27; 12, 28; 13, 29; 15, 30; 16, 31; 17, 32; 18, 33; 19, 34; 20, 35; 20, 36; 21, 37; 21, 38; 21, 39; 21, 40; 22, 41; 25, 42; 26, 43; 26, 44; 27...
def check_photometry_categorize(x, y, levels, tags=None): '''Put every point in its category. levels must be sorted.''' x = numpy.asarray(x) y = numpy.asarray(y) ys = y.copy() ys.sort() # Mean of the upper half m = ys[len(ys) // 2:].mean() y /= m m = 1.0 s = ys[len(ys) // 2:...
0, module; 1, function_definition; 2, function_name:_normalize_sort_SQL; 3, parameters; 4, block; 5, identifier:self; 6, identifier:field_name; 7, identifier:field_vals; 8, identifier:sort_dir_str; 9, expression_statement; 10, expression_statement; 11, if_statement; 12, expression_statement; 13, expression_statement; 1...
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; 9, 18; 10, 19; 11, 20; 11, 21; 11, 22; 12, 23; 13, 24; 14, 25; 14, 26; 14, 27; 15, 28; 16, 29; 17, 30; 19, 31; 19, 32; 20, 33; 20, 34; 21, 35; 22, 36; 23, 37; 23, 38; 24, 39; 24, 40; 25, 41; 25, 42; 27, 43; 27,...
def _normalize_sort_SQL(self, field_name, field_vals, sort_dir_str): """ allow sorting by a set of values http://stackoverflow.com/questions/3303851/sqlite-and-custom-order-by """ fvi = None if sort_dir_str == 'ASC': fvi = (t for t in enumerate(field_vals)) ...
0, module; 1, function_definition; 2, function_name:_process; 3, parameters; 4, block; 5, identifier:self; 6, identifier:segments; 7, expression_statement; 8, comment:# sort_f= lambda r: max_line_width*(r[1]/max_line_height)+r[0]; 9, comment:# segments= sorted(segments, key=sort_f); 10, comment:# segments= segments_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; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 7, 18; 12, 19; 13, 20; 15, 21; 16, 22; 17, 23; 19, 24; 19, 25; 20, 26; 20, 27; 21, 28; 21, 29; 22, 30; 22, 31; 23, 32; 23, 33; 24, 34; 24, 35; 25, 36; 25, 37; 27, 38; 27, 39; 29, 40; 29, 41; 31, 42; 31, 43; 36,...
def _process(self, segments): """sort segments in read order - left to right, up to down""" # sort_f= lambda r: max_line_width*(r[1]/max_line_height)+r[0] # segments= sorted(segments, key=sort_f) # segments= segments_to_numpy( segments ) # return segments mlh, mlw = self....
0, module; 1, function_definition; 2, function_name:flatten; 3, parameters; 4, block; 5, identifier:rho; 6, identifier:pval; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, if_statement; 14, return_statement; 15, i...
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; 13, 24; 14, 25; 18, 26; 18, 27; 19, 28; 19, 29; 20, 30; 20, 31; 21, 32; 21, 33; 22, 34; 22, 35; 23, 36; 23, 37; 24, 38; 24, 39; 25, 40; 25, 41; 27, 42; 27, 43; 29,...
def flatten(rho, pval, sortby="cor"): """Flatten correlation and p-value matrix Parameters: ----------- rho : ndarray Correlation Matrix pval : ndarray Matrix with p-values sortby : str sort the output table by - "cor" the highest absolute correlation coeffici...
0, module; 1, function_definition; 2, function_name:has_code; 3, parameters; 4, block; 5, identifier:state; 6, identifier:text; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, expression_statement; 11, comment:# either simple text matching or regex test; 12, expression_statement; 13, if_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; 7, 15; 7, 16; 8, 17; 8, 18; 9, 19; 10, 20; 12, 21; 13, 22; 13, 23; 14, 24; 20, 25; 20, 26; 21, 27; 21, 28; 22, 29; 23, 30; 23, 31; 26, 32; 26, 33; 28, 34; 28, 35; 28, 36; 30, 37; 31, 38; 34, 39; 34, 40; 36, 41; 36, 42; 37, 43; 37, ...
def has_code(state, text, incorrect_msg="The checker expected to find `{{text}}` in your command.", fixed=False): """Check whether the student code contains text. This function is a simpler override of the `has_code` function in protowhat, because ``ast_node._get_text()`` is not implemented in the OSH pars...
0, module; 1, function_definition; 2, function_name:topports; 3, parameters; 4, block; 5, default_parameter; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, expression_statement; 11, if_statement; 12, return_statement; 13, identifier:sort_by; 14, string; 15, identifier:lim...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 4, 12; 5, 13; 5, 14; 6, 15; 6, 16; 7, 17; 7, 18; 8, 19; 8, 20; 9, 21; 10, 22; 11, 23; 11, 24; 12, 25; 14, 26; 22, 27; 22, 28; 24, 29; 25, 30; 25, 31; 28, 32; 28, 33; 29, 34; 29, 35; 31, 36; 31, 37; 32, 38; 32, 39; 33, 40; 34, 41; 35, 42; 35, 43; 38, 44...
def topports(sort_by='records', limit=10, date=None, return_format=None): """Information about top ports for a particular date with return limit. :param sort_by: one of 'records', 'targets', 'sources' :param limit: number of records to be returned :param date: an optional string in 'Y-M-D' format or da...
0, module; 1, function_definition; 2, function_name:all_nodes_that_receive; 3, parameters; 4, block; 5, identifier:service; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, assert_statement; 11, if_statement; 12, expression_statement; 13, expression_statement; 14, if_statem...
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; 12, 27; 13, 28; 14, 29; 14, 30; 15, 31; 15, 32; 15, 33; 15, 34; 16, 35; 24, 36; 25, 37; 25, 38; 26, 39; 27, 40; 27, 41; 28, 42; 28, 43; 29, 44; ...
def all_nodes_that_receive(service, service_configuration=None, run_only=False, deploy_to_only=False): """If run_only, returns only the services that are in the runs_on list. If deploy_to_only, returns only the services in the deployed_to list. If neither, both are returned, duplicates stripped. Results...
0, module; 1, function_definition; 2, function_name:_cuthill_mckee; 3, parameters; 4, block; 5, identifier:vertices; 6, identifier:vertices_neighbours; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, while_state...
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; 7, 15; 8, 16; 9, 17; 10, 18; 11, 19; 12, 20; 13, 21; 13, 22; 14, 23; 16, 24; 16, 25; 17, 26; 17, 27; 18, 28; 18, 29; 19, 30; 19, 31; 20, 32; 20, 33; 21, 34; 21, 35; 22, 36; 22, 37; 22, 38; 22, 39; 22, 40; 22, 41; 25, 42; 25, 43; 27...
def _cuthill_mckee(vertices, vertices_neighbours): """Yield the Cuthill-McKee order for a connected, undirected graph. `Wikipedia <https://en.wikipedia.org/wiki/Cuthill%E2%80%93McKee_algorithm>`_ provides a good introduction to the Cuthill-McKee algorithm. The RCM algorithm attempts to order vertic...
0, module; 1, function_definition; 2, function_name:write_csv; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, expression_statement; 8, comment:# Sort the Sections; 9, expression_statement; 10, comment:# Sort Terms in the root section; 11, comment:# Re-wrap the description and abstract; 12, if_sta...
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; 6, 18; 6, 19; 7, 20; 9, 21; 12, 22; 12, 23; 13, 24; 13, 25; 14, 26; 15, 27; 16, 28; 17, 29; 21, 30; 21, 31; 22, 32; 22, 33; 23, 34; 24, 35; 24, 36; 25, 37; 26, 38; 26, 39; 27, 40; 27, 41; 28, 42; 28, 43; 29, 44...
def write_csv(self, path=None): """Write CSV file. Sorts the sections before calling the superclass write_csv""" # Sort the Sections self.sort_sections(['Root', 'Contacts', 'Documentation', 'References', 'Resources', 'Citations', 'Schema']) # Sort Terms in the root section # ...
0, module; 1, function_definition; 2, function_name:validate_functions; 3, parameters; 4, block; 5, typed_parameter; 6, identifier:bo; 7, expression_statement; 8, if_statement; 9, comment:# Recursively process every NSArg by processing BELAst and Functions; 10, if_statement; 11, return_statement; 12, identifier:ast; 13...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 5, 12; 5, 13; 7, 14; 8, 15; 8, 16; 10, 17; 10, 18; 11, 19; 13, 20; 15, 21; 15, 22; 16, 23; 16, 24; 16, 25; 16, 26; 16, 27; 17, 28; 17, 29; 18, 30; 22, 31; 22, 32; 23, 33; 24, 34; 25, 35; 26, 36; 27, 37; 27, 38; 29, 39; 29, 40; 30, 41; 30, 42; 30, 43; 3...
def validate_functions(ast: BELAst, bo): """Recursively validate function signatures Determine if function matches one of the available signatures. Also, 1. Add entity types to AST NSArg, e.g. Abundance, ... 2. Add optional to AST Arg (optional means it is not a fixed, required argument and n...
0, module; 1, function_definition; 2, function_name:hash_nanopub; 3, parameters; 4, type; 5, block; 6, typed_parameter; 7, identifier:str; 8, expression_statement; 9, expression_statement; 10, comment:# Type; 11, expression_statement; 12, expression_statement; 13, comment:# Citation; 14, if_statement; 15, comment:# Ass...
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; 5, 19; 5, 20; 5, 21; 5, 22; 5, 23; 5, 24; 5, 25; 5, 26; 6, 27; 6, 28; 8, 29; 9, 30; 11, 31; 12, 32; 14, 33; 14, 34; 14, 35; 14, 36; 16, 37; 17, 38; 17, 39; 17, 40; 18, 41; 19, 42; 21, 43; 22, 44; 22, 45;...
def hash_nanopub(nanopub: Mapping[str, Any]) -> str: """Create CityHash64 from nanopub for duplicate check TODO - check that this hash value is consistent between C# and Python running on laptop and server Build string to hash Collect flat array of (all values.strip()): nanopub.type.name ...
0, module; 1, function_definition; 2, function_name:build_listing; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, function_definition; 8, expression_statement; 9, return_statement; 10, comment:""" Builds a listing of all functions sorted A-Z, with their names and descriptions "...
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; 12, 17; 13, 18; 13, 19; 13, 20; 13, 21; 13, 22; 13, 23; 14, 24; 14, 25; 15, 26; 15, 27; 18, 28; 20, 29; 22, 30; 22, 31; 23, 32; 25, 33; 25, 34; 27, 35; 27, 36; 28, 37; 28, 38; 29, 39; 29, 40; 31, 41; 32, 42; 32, 43; ...
def build_listing(self): """ Builds a listing of all functions sorted A-Z, with their names and descriptions """ def func_entry(name, func): args, varargs, defaults = self._get_arg_spec(func) # add regular arguments params = [{'name': str(a), 'optiona...
0, module; 1, function_definition; 2, function_name:sort_url_qsl; 3, parameters; 4, block; 5, identifier:cls; 6, identifier:raw_url; 7, dictionary_splat_pattern; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, return_statement; 12, identifier:kwargs; 13, comment:"""Do nothing but sort th...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 7, 12; 8, 13; 9, 14; 10, 15; 11, 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; 24, 31; 26, 32; 30, 33; 30, 34; 32, 35; 32, 36; 34, 37; 34, 38; 38, 39
def sort_url_qsl(cls, raw_url, **kwargs): """Do nothing but sort the params of url. raw_url: the raw url to be sorted; kwargs: (optional) same kwargs for ``sorted``. """ parsed_url = urlparse(raw_url) qsl = parse_qsl(parsed_url.query) return cls._join_ur...
0, module; 1, function_definition; 2, function_name:get_sorted_series_files; 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, expression_statement; 14, comment:...
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; 4, 20; 4, 21; 4, 22; 4, 23; 4, 24; 4, 25; 6, 26; 6, 27; 7, 28; 7, 29; 8, 30; 8, 31; 9, 32; 9, 33; 10, 34; 10, 35; 11, 36; 11, 37; 12, 38; 13, 39; 15, 40; 15, 41; 16, 42; 17, 43; 18, 44; 18, 45; 19...
def get_sorted_series_files(self, startpath="", series_number=None, return_files_with_info=False, sort_keys="SliceLocation", return_files=True, remove_doubled_slice_locations=True): """ Function returns sorted list of dicom files. File paths are organized by Serie...
0, module; 1, function_definition; 2, function_name:guess_interval; 3, parameters; 4, block; 5, identifier:nums; 6, default_parameter; 7, expression_statement; 8, if_statement; 9, expression_statement; 10, if_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, expression_stateme...
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; 6, 16; 6, 17; 7, 18; 8, 19; 8, 20; 9, 21; 10, 22; 10, 23; 11, 24; 12, 25; 13, 26; 14, 27; 15, 28; 19, 29; 20, 30; 21, 31; 21, 32; 22, 33; 22, 34; 23, 35; 24, 36; 24, 37; 25, 38; 25, 39; 26, 40; 26, 41; 27, 42; 27, 43; 30, 44...
def guess_interval(nums, accuracy=0): """Given a seq of number, return the median, only calculate interval >= accuracy. :: from torequests.utils import guess_interval import random seq = [random.randint(1, 100) for i in range(20)] print(guess_interval(seq, 5)) # sorted...
0, module; 1, function_definition; 2, function_name:sort_list_of_dicts; 3, parameters; 4, block; 5, identifier:lst_of_dct; 6, identifier:keys; 7, default_parameter; 8, dictionary_splat_pattern; 9, expression_statement; 10, if_statement; 11, comment:# dcmdir = lst_of_dct[:]; 12, comment:# lst_of_dct.sort(key=lambda x: [...
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; 7, 15; 7, 16; 8, 17; 9, 18; 10, 19; 10, 20; 13, 21; 14, 22; 19, 23; 19, 24; 20, 25; 21, 26; 21, 27; 23, 28; 23, 29; 25, 30; 26, 31; 26, 32; 27, 33; 27, 34; 27, 35; 29, 36; 30, 37; 30, 38; 33, 39; 33, 40; 34, 41; 34, 42; 35, 43; 38,...
def sort_list_of_dicts(lst_of_dct, keys, reverse=False, **sort_args): """ Sort list of dicts by one or multiple keys. If the key is not available, sort these to the end. :param lst_of_dct: input structure. List of dicts. :param keys: one or more keys in list :param reverse: :param sort_arg...
0, module; 1, function_definition; 2, function_name:parallel_deblur; 3, parameters; 4, block; 5, identifier:inputs; 6, identifier:params; 7, identifier:pos_ref_db_fp; 8, identifier:neg_ref_dp_fp; 9, default_parameter; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, comment:# remove the...
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; 9, 28; 9, 29; 10, 30; 11, 31; 12, 32; 14, 33; 15, 34; 16, 35; 17, 36; 17, 37; 17, 38; 20, 39; 20, 40; 21, 41; 21, 42; 22, 43; 23, 44; 24, 45...
def parallel_deblur(inputs, params, pos_ref_db_fp, neg_ref_dp_fp, jobs_to_start=1): """Dispatch execution over a pool of processors This code was adopted from the American Gut project: https://github.com/biocore/American-Gut/blob/master/americangut/parallel.py Parameters ------...
0, module; 1, function_definition; 2, function_name:build_index_sortmerna; 3, parameters; 4, block; 5, identifier:ref_fp; 6, identifier:working_dir; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, for_statement; 12, return_statement; 13, comment:"""Build a SortMe...
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; 9, 15; 10, 16; 11, 17; 11, 18; 11, 19; 12, 20; 14, 21; 14, 22; 15, 23; 15, 24; 16, 25; 16, 26; 19, 27; 19, 28; 19, 29; 19, 30; 19, 31; 19, 32; 19, 33; 19, 34; 19, 35; 22, 36; 22, 37; 23, 38; 23, 39; 24, 40; 27, 41; 28, 42; 29, 43; ...
def build_index_sortmerna(ref_fp, working_dir): """Build a SortMeRNA index for all reference databases. Parameters ---------- ref_fp: tuple filepaths to FASTA reference databases working_dir: string working directory path where to store the indexed database Returns ------- ...
0, module; 1, function_definition; 2, function_name:remove_artifacts_from_biom_table; 3, parameters; 4, block; 5, identifier:table_filename; 6, identifier:fasta_filename; 7, identifier:ref_fp; 8, identifier:biom_table_dir; 9, identifier:ref_db_fp; 10, default_parameter; 11, default_parameter; 12, default_parameter; 13,...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 3, 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; 4, 45; 4, 46; 4, 47; ...
def remove_artifacts_from_biom_table(table_filename, fasta_filename, ref_fp, biom_table_dir, ref_db_fp, threads=1, ...
0, module; 1, function_definition; 2, function_name:remove_artifacts_seqs; 3, parameters; 4, block; 5, identifier:seqs_fp; 6, identifier:ref_fp; 7, identifier:working_dir; 8, identifier:ref_db_fp; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, default_parameter; 13, default_parameter; 14, expre...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 3, 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; 9, 35; 9, 36; 10, 37; 10, 38; 11, 39; 11, 40; 12, 41; 12, 42; 13, 43; 13, 44; 14, 45; 15, 4...
def remove_artifacts_seqs(seqs_fp, ref_fp, working_dir, ref_db_fp, negate=False, threads=1, verbose=False, sim_thresh=None, ...
0, module; 1, function_definition; 2, function_name:launch_workflow; 3, parameters; 4, block; 5, identifier:seqs_fp; 6, identifier:working_dir; 7, identifier:mean_error; 8, identifier:error_dist; 9, identifier:indel_prob; 10, identifier:indel_max; 11, identifier:trim_length; 12, identifier:left_trim_length; 13, identif...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 3, 13; 3, 14; 3, 15; 3, 16; 3, 17; 3, 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; 16, 41; 16, 42; 17, 43; 17, 44; 18, 45; 18, 46; 1...
def launch_workflow(seqs_fp, working_dir, mean_error, error_dist, indel_prob, indel_max, trim_length, left_trim_length, min_size, ref_fp, ref_db_fp, threads_per_sample=1, sim_thresh=None, coverage_thresh=None): """Launch full deblur workflow for a single p...
0, module; 1, function_definition; 2, function_name:logs; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, if_statement; 8, expression_statement; 9, expression_statement; 10, return_statement; 11, comment:"""Find the log directory and return all the logs sorted."""; 12, not_operator; 13, block; ...
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; 9, 15; 10, 16; 12, 17; 13, 18; 14, 19; 14, 20; 15, 21; 15, 22; 17, 23; 17, 24; 18, 25; 20, 26; 20, 27; 21, 28; 21, 29; 22, 30; 23, 31; 23, 32; 25, 33; 25, 34; 26, 35; 26, 36; 30, 37; 30, 38; 33, 39; 33, 40; 35, 41; 35, 42; 38, 43; ...
def logs(self): """Find the log directory and return all the logs sorted.""" if not self.parent.loaded: self.parent.load() logs = self.parent.p.logs_dir.flat_directories logs.sort(key=lambda x: x.mod_time) return logs
0, module; 1, function_definition; 2, function_name:sort_string_by_pairs; 3, parameters; 4, block; 5, identifier:strings; 6, expression_statement; 7, assert_statement; 8, expression_statement; 9, expression_statement; 10, comment:# This shallow copies the list; 11, while_statement; 12, return_statement; 13, 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; 6, 13; 7, 14; 8, 15; 9, 16; 11, 17; 11, 18; 12, 19; 14, 20; 14, 21; 15, 22; 15, 23; 16, 24; 16, 25; 18, 26; 18, 27; 20, 28; 20, 29; 25, 30; 25, 31; 26, 32; 27, 33; 27, 34; 27, 35; 28, 36; 28, 37; 31, 38; 32, 39; 32, 40; 33, 41; 33, 42; 34, 43; 3...
def sort_string_by_pairs(strings): """Group a list of strings by pairs, by matching those with only one character difference between each other together.""" assert len(strings) % 2 == 0 pairs = [] strings = list(strings) # This shallow copies the list while strings: template = strings.po...
0, module; 1, function_definition; 2, function_name:natural_sort; 3, parameters; 4, block; 5, identifier:item; 6, expression_statement; 7, expression_statement; 8, return_statement; 9, comment:""" Sort strings that contain numbers correctly. Works in Python 2 and 3. >>> l = ['v1.3.12', 'v1.3.3', 'v1.2.5', 'v1....
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 6, 9; 7, 10; 8, 11; 10, 12; 10, 13; 11, 14; 11, 15; 13, 16; 13, 17; 14, 18; 14, 19; 14, 20; 15, 21; 15, 22; 16, 23; 16, 24; 17, 25; 18, 26; 18, 27; 19, 28; 19, 29; 20, 30; 20, 31; 22, 32; 22, 33; 25, 34; 27, 35; 28, 36; 28, 37; 30, 38; 30, 39; 32, 40; 32, 41; 33, 42; 33, ...
def natural_sort(item): """ Sort strings that contain numbers correctly. Works in Python 2 and 3. >>> l = ['v1.3.12', 'v1.3.3', 'v1.2.5', 'v1.2.15', 'v1.2.3', 'v1.2.1'] >>> l.sort(key=natural_sort) >>> l.__repr__() "['v1.2.1', 'v1.2.3', 'v1.2.5', 'v1.2.15', 'v1.3.3', 'v1.3.12']" """ dre...
0, module; 1, function_definition; 2, function_name:get_elementary_intervals; 3, parameters; 4, block; 5, identifier:self; 6, identifier:features; 7, expression_statement; 8, expression_statement; 9, try_statement; 10, expression_statement; 11, expression_statement; 12, return_statement; 13, comment:"""Generates a sort...
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; 9, 15; 9, 16; 10, 17; 11, 18; 12, 19; 14, 20; 14, 21; 15, 22; 16, 23; 16, 24; 17, 25; 17, 26; 18, 27; 18, 28; 22, 29; 22, 30; 22, 31; 24, 32; 26, 33; 26, 34; 27, 35; 27, 36; 31, 37; 31, 38; 32, 39; 34, 40; 37, 41; 37, 42; 38, 43; 3...
def get_elementary_intervals(self, features): """Generates a sorted list of elementary intervals""" coords = [] try: for interval in features: if len(interval) != 3: raise SyntaxError('Interval malformed %s. Allways specify start and end position f...
0, module; 1, function_definition; 2, function_name:convtable2dict; 3, parameters; 4, block; 5, identifier:convtable; 6, identifier:locale; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, for_statement; 11, return_statement; 12, identifier:update; 13, None; 14, comment:""" Convert a list...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 7, 12; 7, 13; 8, 14; 9, 15; 10, 16; 10, 17; 10, 18; 11, 19; 15, 20; 15, 21; 18, 22; 21, 23; 21, 24; 21, 25; 22, 26; 22, 27; 22, 28; 22, 29; 23, 30; 23, 31; 26, 32; 26, 33; 27, 34; 28, 35; 28, 36; 29, 37; 30, 38; 30, 39; 32, 40; 34, 41; 34, 42; 35, 43; ...
def convtable2dict(convtable, locale, update=None): """ Convert a list of conversion dict to a dict for a certain locale. >>> sorted(convtable2dict([{'zh-hk': '列斯', 'zh-hans': '利兹', 'zh': '利兹', 'zh-tw': '里茲'}, {':uni': '巨集', 'zh-cn': '宏'}], 'zh-cn').items()) [('列斯', '利兹'), ('利兹', '利兹'), ('巨集', '宏'), ('...
0, module; 1, function_definition; 2, function_name:re_sort; 3, parameters; 4, block; 5, identifier:data; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, return_statement; 11, comment:""" A data with keys that are not enumerated sequentially will be re sorted and...
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; 14, 22; 14, 23; 15, 24; 15, 25; 16, 26; 19, 27; 19, 28; 25, 29; 26, 30; 28, 31; 30, 32; 30, 33; 31, 34; 31, 35; 32, 36; 32, 37; 33, 38; 33, 39; 34, 40; 34, 41
def re_sort(data): """ A data with keys that are not enumerated sequentially will be re sorted and sequentially ordered. For example:: >>> data = {16: ('1', 'b'), 3: ('1', 'a')} >>> re_sort(data) >>> {0: ('1', 'a'), 1: ('1', 'b')} """ keys = sorted(data.keys()) new_...
0, module; 1, function_definition; 2, function_name:natural_sorted; 3, parameters; 4, block; 5, identifier:iterable; 6, expression_statement; 7, function_definition; 8, expression_statement; 9, return_statement; 10, comment:"""Return human sorted list of strings. E.g. for sorting file names. >>> natural_sorte...
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; 14, 18; 14, 19; 15, 20; 15, 21; 17, 22; 19, 23; 19, 24; 21, 25; 21, 26; 22, 27; 22, 28; 23, 29; 23, 30; 24, 31; 26, 32; 26, 33; 27, 34; 28, 35; 28, 36; 31, 37; 34, 38; 34, 39; 34, 40; 36, 41; 36, 42; 38, 43; ...
def natural_sorted(iterable): """Return human sorted list of strings. E.g. for sorting file names. >>> natural_sorted(['f1', 'f2', 'f10']) ['f1', 'f2', 'f10'] """ def sortkey(x): return [(int(c) if c.isdigit() else c) for c in re.split(numbers, x)] numbers = re.compile(r'(\d+)') ...
0, module; 1, function_definition; 2, function_name:sort_keys; 3, parameters; 4, block; 5, identifier:self; 6, identifier:keys; 7, default_parameter; 8, expression_statement; 9, comment:# to do: check that all reverse index values are unambiguous; 10, expression_statement; 11, expression_statement; 12, 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; 7, 14; 7, 15; 8, 16; 10, 17; 11, 18; 12, 19; 13, 20; 13, 21; 13, 22; 13, 23; 15, 24; 15, 25; 17, 26; 17, 27; 18, 28; 18, 29; 19, 30; 19, 31; 20, 32; 20, 33; 21, 34; 22, 35; 22, 36; 23, 37; 27, 38; 27, 39; 27, 40; 29, 41; 29, 42; 29, 43; 3...
def sort_keys(self, keys, order=QuerySet.ASCENDING): """Sort keys. Keys are sorted based on the value they are indexing. :param keys: Keys to be sorted :type keys: list(str) :param order: Order criteri (asending or descending) :type order: int :return: Sorted ke...
0, module; 1, function_definition; 2, function_name:options; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, for_statement; 11, comment:""" Returns an iterable of sorted option names in order to loop thr...
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; 10, 15; 10, 16; 10, 17; 12, 18; 12, 19; 13, 20; 13, 21; 14, 22; 14, 23; 17, 24; 17, 25; 19, 26; 19, 27; 20, 28; 20, 29; 21, 30; 23, 31; 23, 32; 24, 33; 25, 34; 25, 35; 26, 36; 26, 37; 30, 38; 30, 39; 32, 40; 33, 41; 33, 42; 34, 43;...
def options(self): """ Returns an iterable of sorted option names in order to loop through all the configuration directives specified in the class. """ keys = self.__class__.__dict__.copy() keys.update(self.__dict__) keys = sorted(keys.keys()) for opt in ...
0, module; 1, function_definition; 2, function_name:_tidy; 3, parameters; 4, type; 5, block; 6, identifier:self; 7, None; 8, expression_statement; 9, if_statement; 10, comment:""" Removes overlaps, etc., and sorts. """; 11, attribute; 12, block; 13, else_clause; 14, identifier:self; 15, identifier:no_ov...
0, 1; 1, 2; 1, 3; 1, 4; 1, 5; 3, 6; 4, 7; 5, 8; 5, 9; 8, 10; 9, 11; 9, 12; 9, 13; 11, 14; 11, 15; 12, 16; 12, 17; 13, 18; 16, 19; 18, 20; 19, 21; 19, 22; 20, 23; 21, 24; 21, 25; 22, 26; 23, 27; 23, 28; 26, 29; 26, 30; 27, 31; 27, 32
def _tidy(self) -> None: """ Removes overlaps, etc., and sorts. """ if self.no_overlap: self.remove_overlap(self.no_contiguous) # will sort else: self._sort()
0, module; 1, function_definition; 2, function_name:index_list_for_sort_order; 3, parameters; 4, type; 5, block; 6, typed_parameter; 7, typed_default_parameter; 8, typed_default_parameter; 9, generic_type; 10, expression_statement; 11, function_definition; 12, if_statement; 13, expression_statement; 14, return_statemen...
0, 1; 1, 2; 1, 3; 1, 4; 1, 5; 3, 6; 3, 7; 3, 8; 4, 9; 5, 10; 5, 11; 5, 12; 5, 13; 5, 14; 6, 15; 6, 16; 7, 17; 7, 18; 7, 19; 8, 20; 8, 21; 8, 22; 9, 23; 9, 24; 10, 25; 11, 26; 11, 27; 11, 28; 12, 29; 12, 30; 12, 31; 13, 32; 14, 33; 16, 34; 18, 35; 21, 36; 24, 37; 27, 38; 28, 39; 30, 40; 30, 41; 31, 42; 32, 43; 32, 44; 3...
def index_list_for_sort_order(x: List[Any], key: Callable[[Any], Any] = None, reverse: bool = False) -> List[int]: """ Returns a list of indexes of ``x``, IF ``x`` WERE TO BE SORTED. Args: x: data key: function to be applied to the data to generate a sort key; ...
0, module; 1, function_definition; 2, function_name:sort_list_by_index_list; 3, parameters; 4, type; 5, block; 6, typed_parameter; 7, typed_parameter; 8, None; 9, expression_statement; 10, expression_statement; 11, identifier:x; 12, type; 13, identifier:indexes; 14, type; 15, comment:""" Re-orders ``x`` by the list...
0, 1; 1, 2; 1, 3; 1, 4; 1, 5; 3, 6; 3, 7; 4, 8; 5, 9; 5, 10; 6, 11; 6, 12; 7, 13; 7, 14; 9, 15; 10, 16; 12, 17; 14, 18; 16, 19; 16, 20; 17, 21; 17, 22; 18, 23; 18, 24; 19, 25; 19, 26; 20, 27; 20, 28; 22, 29; 24, 30; 27, 31; 27, 32; 28, 33; 28, 34; 29, 35; 30, 36
def sort_list_by_index_list(x: List[Any], indexes: List[int]) -> None: """ Re-orders ``x`` by the list of ``indexes`` of ``x``, in place. Example: .. code-block:: python from cardinal_pythonlib.lists import sort_list_by_index_list z = ["a", "b", "c", "d", "e"] sort_list_by_in...
0, module; 1, function_definition; 2, function_name:fetch_all_first_values; 3, parameters; 4, type; 5, block; 6, typed_parameter; 7, typed_parameter; 8, generic_type; 9, expression_statement; 10, expression_statement; 11, comment:# type: ResultProxy; 12, try_statement; 13, identifier:session; 14, type; 15, identifier:s...
0, 1; 1, 2; 1, 3; 1, 4; 1, 5; 3, 6; 3, 7; 4, 8; 5, 9; 5, 10; 5, 11; 5, 12; 6, 13; 6, 14; 7, 15; 7, 16; 8, 17; 8, 18; 9, 19; 10, 20; 12, 21; 12, 22; 14, 23; 16, 24; 18, 25; 20, 26; 20, 27; 21, 28; 22, 29; 22, 30; 25, 31; 27, 32; 27, 33; 28, 34; 29, 35; 29, 36; 30, 37; 32, 38; 32, 39; 33, 40; 34, 41; 34, 42; 36, 43; 37, ...
def fetch_all_first_values(session: Session, select_statement: Select) -> List[Any]: """ Returns a list of the first values in each row returned by a ``SELECT`` query. A Core version of this sort of thing: http://xion.io/post/code/sqlalchemy-query-values.html Args: ...
0, module; 1, function_definition; 2, function_name:atoi; 3, parameters; 4, type; 5, block; 6, typed_parameter; 7, generic_type; 8, expression_statement; 9, return_statement; 10, identifier:text; 11, type; 12, identifier:Union; 13, type_parameter; 14, comment:""" Converts strings to integers if they're composed of ...
0, 1; 1, 2; 1, 3; 1, 4; 1, 5; 3, 6; 4, 7; 5, 8; 5, 9; 6, 10; 6, 11; 7, 12; 7, 13; 8, 14; 9, 15; 11, 16; 13, 17; 13, 18; 15, 19; 15, 20; 15, 21; 17, 22; 18, 23; 19, 24; 19, 25; 20, 26; 20, 27; 25, 28; 26, 29; 26, 30
def atoi(text: str) -> Union[int, str]: """ Converts strings to integers if they're composed of digits; otherwise returns the strings unchanged. One way of sorting strings with numbers; it will mean that ``"11"`` is more than ``"2"``. """ return int(text) if text.isdigit() else text
0, module; 1, function_definition; 2, function_name:reducer_metro; 3, parameters; 4, block; 5, identifier:self; 6, identifier:metro; 7, identifier:values; 8, expression_statement; 9, expression_statement; 10, for_statement; 11, comment:""" Output tags of POI locations nearby tweet locations Values will...
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; 15, 22; 15, 23; 17, 24; 17, 25; 21, 26; 22, 27; 23, 28; 23, 29; 23, 30; 23, 31; 25, 32; 27, 33; 27, 34; 28, 35; 28, 36; 30, 37; 31, 38; 31, 39; 32, 40; 32, 41; 33, 42; 33, 4...
def reducer_metro(self, metro, values): """ Output tags of POI locations nearby tweet locations Values will be sorted coming into reducer. First element in each value tuple will be either 1 (osm POI) or 2 (geotweet). Build a spatial index with POI records. For each tweet...
0, module; 1, function_definition; 2, function_name:list_file_extensions; 3, parameters; 4, type; 5, block; 6, typed_parameter; 7, typed_default_parameter; 8, generic_type; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, for_statement; 13, return_statement; 14, identifier:path; 15, type...
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; 6, 14; 6, 15; 7, 16; 7, 17; 7, 18; 8, 19; 8, 20; 9, 21; 10, 22; 11, 23; 12, 24; 12, 25; 12, 26; 13, 27; 15, 28; 17, 29; 20, 30; 22, 31; 22, 32; 23, 33; 23, 34; 24, 35; 24, 36; 24, 37; 25, 38; 25, 39; 26, 40; 26, 41; 26, 42; 27, 43; 27, 44...
def list_file_extensions(path: str, reportevery: int = 1) -> List[str]: """ Returns a sorted list of every file extension found in a directory and its subdirectories. Args: path: path to scan reportevery: report directory progress after every *n* steps Returns: sorted list ...
0, module; 1, function_definition; 2, function_name:sort_by_dependencies; 3, parameters; 4, block; 5, identifier:exts; 6, default_parameter; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, while_statement; 12, return_statement; 13, identifier:retry; 14, None; 15,...
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; 11, 19; 11, 20; 12, 21; 16, 22; 16, 23; 17, 24; 17, 25; 18, 26; 18, 27; 20, 28; 20, 29; 20, 30; 20, 31; 21, 32; 21, 33; 22, 34; 22, 35; 23, 36; 23, 37; 25, 38; 25, 39; 27, 40; 27, 41; 27, 42; 28, 43; 29...
def sort_by_dependencies(exts, retry=None): """Calculate the Feature Extractor Resolution Order. """ sorted_ext, features_from_sorted = [], set() pending = [(e, 0) for e in exts] retry = len(exts) * 100 if retry is None else retry while pending: ext, cnt = pending.pop(0) if not...
0, module; 1, function_definition; 2, function_name:_sort_layers; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, comment:"""Sort the layers by depth."""; 9, assignment; 10, attribute; 11, call; 12, identifier:self; 13, identifier:_layers; 14, identifier:OrderedDict; 15...
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; 15, 16; 16, 17; 16, 18; 18, 19; 18, 20; 19, 21; 19, 22; 20, 23; 20, 24; 21, 25; 21, 26; 24, 27; 24, 28; 25, 29; 25, 30; 27, 31; 28, 32; 28, 33
def _sort_layers(self): """Sort the layers by depth.""" self._layers = OrderedDict(sorted(self._layers.items(), key=lambda t: t[0]))
0, module; 1, function_definition; 2, function_name:sort_sections; 3, parameters; 4, block; 5, identifier:self; 6, identifier:order; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, assert_statement; 12, expression_statement; 13, comment:""" Sort sections ...
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; 9, 15; 10, 16; 11, 17; 12, 18; 14, 19; 14, 20; 15, 21; 15, 22; 16, 23; 16, 24; 17, 25; 17, 26; 18, 27; 18, 28; 20, 29; 20, 30; 22, 31; 22, 32; 23, 33; 23, 34; 24, 35; 24, 36; 24, 37; 25, 38; 25, 39; 26, 40; 26, 41; 27, 42; 27, 43; ...
def sort_sections(self, order): """ Sort sections according to the section names in the order list. All remaining sections are added to the end in their original order :param order: Iterable of section names :return: """ order_lc = [e.lower() for e in order] ...
0, module; 1, function_definition; 2, function_name:split_iterable_as_iterable; 3, parameters; 4, block; 5, identifier:self; 6, identifier:values; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, function_definition; 11, expression_statement; 12, for_statement; 13, comment:"""Group iterabl...
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; 9, 15; 10, 16; 10, 17; 10, 18; 11, 19; 12, 20; 12, 21; 12, 22; 14, 23; 14, 24; 15, 25; 15, 26; 17, 27; 18, 28; 19, 29; 19, 30; 21, 31; 21, 32; 22, 33; 24, 34; 24, 35; 26, 36; 26, 37; 28, 38; 28, 39; 30, 40; 30, 41; 33, 42; 35, 43; ...
def split_iterable_as_iterable(self, values): """Group iterable into iterables, in the order of the keys Parameters ---------- values : iterable of length equal to keys iterable of values to be grouped Yields ------ iterable of items in values ...
0, module; 1, function_definition; 2, function_name:as_index; 3, parameters; 4, block; 5, identifier:keys; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, expression_statement; 11, if_statement; 12, if_statement; 13, try_statement; 14, if_statement; 15, if_statement; 16, iden...
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; 6, 16; 6, 17; 7, 18; 7, 19; 8, 20; 8, 21; 9, 22; 9, 23; 10, 24; 11, 25; 11, 26; 12, 27; 12, 28; 13, 29; 13, 30; 14, 31; 14, 32; 15, 33; 15, 34; 15, 35; 17, 36; 17, 37; 25, 38; 25, 39; 26, 40; 27, 41; 27, 42; 28, 43; 29, 44; ...
def as_index(keys, axis=semantics.axis_default, base=False, stable=True, lex_as_struct=False): """ casting rules for a keys object to an index object the preferred semantics is that keys is a sequence of key objects, except when keys is an instance of tuple, in which case the zipped elements of the...
0, module; 1, function_definition; 2, function_name:axis_as_object; 3, parameters; 4, block; 5, identifier:arr; 6, default_parameter; 7, expression_statement; 8, expression_statement; 9, comment:# make axis to be viewed as a void object as contiguous items; 10, expression_statement; 11, comment:# number of bytes in eac...
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; 6, 17; 6, 18; 7, 19; 8, 20; 10, 21; 12, 22; 14, 23; 16, 24; 18, 25; 20, 26; 20, 27; 21, 28; 21, 29; 22, 30; 22, 31; 23, 32; 23, 33; 24, 34; 24, 35; 27, 36; 27, 37; 29, 38; 29, 39; 31, 40; 31, 41; 33, 42; 33, 43; 34, 4...
def axis_as_object(arr, axis=-1): """cast the given axis of an array to a void object if the axis to be cast is contiguous, a view is returned, otherwise a copy is made this is useful for efficiently sorting by the content of an axis, for instance Parameters ---------- arr : ndarray arr...
0, module; 1, function_definition; 2, function_name:rank; 3, parameters; 4, block; 5, identifier:keys; 6, default_parameter; 7, expression_statement; 8, expression_statement; 9, return_statement; 10, identifier:axis; 11, attribute; 12, comment:"""where each item is in the pecking order. Parameters ---------- ...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 6, 10; 6, 11; 7, 12; 8, 13; 9, 14; 11, 15; 11, 16; 13, 17; 13, 18; 14, 19; 14, 20; 18, 21; 18, 22; 22, 23; 22, 24
def rank(keys, axis=semantics.axis_default): """where each item is in the pecking order. Parameters ---------- keys : indexable object Returns ------- ndarray, [keys.size], int unique integers, ranking the sorting order Notes ----- we should have that index.sorted[inde...
0, module; 1, function_definition; 2, function_name:sort_by; 3, parameters; 4, block; 5, identifier:function; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, return_statement; 10, comment:""" Sorts an incoming sequence by using the given `function` as key. >>> range(10) > sort_by(...
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; 11, 14; 11, 15; 12, 16; 12, 17; 15, 18; 15, 19; 16, 20; 16, 21; 17, 22; 19, 23; 19, 24; 22, 25; 22, 26; 24, 27; 24, 28; 25, 29; 26, 30; 26, 31; 31, 32
def sort_by(function): """ Sorts an incoming sequence by using the given `function` as key. >>> range(10) > sort_by(-X) [9, 8, 7, 6, 5, 4, 3, 2, 1, 0] Supports automatic data-structure creation:: users > sort_by([X.last_name, X.first_name]) There is also a shortcut for ``sort_by(X)``...
0, module; 1, function_definition; 2, function_name:in_sorted; 3, parameters; 4, block; 5, identifier:values; 6, identifier:value; 7, expression_statement; 8, expression_statement; 9, if_statement; 10, return_statement; 11, comment:"""Checks if a value is in a sorted list. Uses the :mod:`bisect` builtin to find th...
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; 10, 15; 12, 16; 12, 17; 13, 18; 13, 19; 14, 20; 15, 21; 15, 22; 17, 23; 17, 24; 19, 25; 19, 26; 20, 27; 21, 28; 21, 29; 23, 30; 23, 31; 24, 32; 24, 33; 26, 34
def in_sorted(values, value): """Checks if a value is in a sorted list. Uses the :mod:`bisect` builtin to find the insertion point for ``value``. Args: values (List[int]): Integers sorted in ascending order. value (int): Value to check if contained in ``values``. Returns: ...
0, module; 1, function_definition; 2, function_name:handle_keypress; 3, parameters; 4, block; 5, identifier:self; 6, identifier:k; 7, expression_statement; 8, if_statement; 9, comment:"""Last resort for keypresses."""; 10, comparison_operator:k == "esc"; 11, block; 12, elif_clause; 13, elif_clause; 14, elif_clause; 15,...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 7, 9; 8, 10; 8, 11; 8, 12; 8, 13; 8, 14; 10, 15; 10, 16; 11, 17; 11, 18; 12, 19; 12, 20; 12, 21; 13, 22; 13, 23; 13, 24; 14, 25; 14, 26; 14, 27; 17, 28; 18, 29; 19, 30; 19, 31; 21, 32; 22, 33; 22, 34; 24, 35; 25, 36; 25, 37; 27, 38; 27, 39; 27, 40; 27, 41; 28, 42; 28, 43;...
def handle_keypress(self, k): """Last resort for keypresses.""" if k == "esc": self.save_file() raise urwid.ExitMainLoop() elif k == "delete": # delete at end of line self.walker.combine_focus_with_next() elif k == "backspace": ...
0, module; 1, function_definition; 2, function_name:sorted; 3, parameters; 4, block; 5, identifier:self; 6, identifier:fsort; 7, expression_statement; 8, if_statement; 9, expression_statement; 10, return_statement; 11, string; 12, not_operator; 13, block; 14, assignment; 15, identifier:self; 16, string_content:Allows t...
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; 10, 15; 11, 16; 12, 17; 13, 18; 14, 19; 14, 20; 17, 21; 17, 22; 18, 23; 19, 24; 19, 25; 23, 26; 23, 27; 24, 28; 24, 29; 25, 30; 26, 31; 26, 32; 27, 33; 27, 34
def sorted(self, fsort): ''' Allows to add one or more sort on specific fields. Each sort can be reversed as well. The sort is defined on a per field level, with special field name for _score to sort by score. ''' if not self.params: self.params = dict() self.params['...
0, module; 1, function_definition; 2, function_name:_filter_sources; 3, parameters; 4, block; 5, identifier:self; 6, identifier:sources; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, return_statement; 11, comment:"""Remove sources with errors and return ordered by host success. :param...
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; 16, 22; 16, 23; 17, 24; 17, 25; 18, 26; 18, 27; 19, 28; 19, 29; 20, 30; 21, 31; 23, 32; 23, 33; 28, 34; 28, 35; 29, 36; 30, 37; 30, 38; 31, 39; 31, 40; 33, 41; 33, 42; 34, 43; ...
def _filter_sources(self, sources): """Remove sources with errors and return ordered by host success. :param sources: List of potential sources to connect to. :type sources: list :returns: Sorted list of potential sources without errors. :rtype: list """ filtered...
0, module; 1, function_definition; 2, function_name:get_cantons; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, return_statement; 8, comment:""" Return the list of unique cantons, sorted by name. """; 9, call; 10, identifier:sorted; 11, argument_list; 12, call; 13, identifier:l...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 6, 8; 7, 9; 9, 10; 9, 11; 11, 12; 12, 13; 12, 14; 14, 15; 15, 16; 15, 17; 17, 18; 18, 19; 18, 20; 19, 21; 19, 22; 20, 23; 20, 24; 24, 25; 24, 26; 25, 27; 25, 28; 27, 29; 27, 30; 29, 31; 29, 32
def get_cantons(self): """ Return the list of unique cantons, sorted by name. """ return sorted(list(set([ location.canton for location in self.get_locations().values() ])))
0, module; 1, function_definition; 2, function_name:get_municipalities; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, return_statement; 8, comment:""" Return the list of unique municipalities, sorted by name. """; 9, call; 10, identifier:sorted; 11, argument_list; 12, call; 13...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 6, 8; 7, 9; 9, 10; 9, 11; 11, 12; 12, 13; 12, 14; 14, 15; 15, 16; 15, 17; 17, 18; 18, 19; 18, 20; 19, 21; 19, 22; 20, 23; 20, 24; 24, 25; 24, 26; 25, 27; 25, 28; 27, 29; 27, 30; 29, 31; 29, 32
def get_municipalities(self): """ Return the list of unique municipalities, sorted by name. """ return sorted(list(set([ location.municipality for location in self.get_locations().values() ])))
0, module; 1, function_definition; 2, function_name:execute; 3, parameters; 4, block; 5, identifier:self; 6, identifier:sql; 7, list_splat_pattern; 8, dictionary_splat_pattern; 9, expression_statement; 10, try_statement; 11, expression_statement; 12, expression_statement; 13, if_statement; 14, identifier:args; 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; 4, 13; 7, 14; 8, 15; 9, 16; 10, 17; 10, 18; 11, 19; 12, 20; 13, 21; 13, 22; 13, 23; 16, 24; 17, 25; 18, 26; 18, 27; 18, 28; 19, 29; 19, 30; 20, 31; 20, 32; 21, 33; 21, 34; 22, 35; 23, 36; 25, 37; 26, 38; 26, 39; 28, 40; 30, 41; 30, 42; 31, 43; 3...
def execute(self, sql, *args, **kwargs): ''' Run raw SQL on the database, and receive relaxing output. This is sort of the foundational method that most of the others build on. ''' try: self.cursor.execute(sql, *args) except self.sqlite3.InterfaceError, msg: raise self.sqlite3.In...
0, module; 1, function_definition; 2, function_name:check_message; 3, parameters; 4, block; 5, identifier:message; 6, dictionary_splat_pattern; 7, expression_statement; 8, if_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, f...
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; 6, 16; 7, 17; 8, 18; 8, 19; 9, 20; 10, 21; 11, 22; 12, 23; 13, 24; 14, 25; 14, 26; 14, 27; 15, 28; 18, 29; 18, 30; 19, 31; 20, 32; 20, 33; 21, 34; 21, 35; 22, 36; 22, 37; 23, 38; 23, 39; 24, 40; 24, 41; 26, 42; 26, 43; 26, 4...
def check_message(message, **kwargs): """Check the message format. Rules: - the first line must start by a component name - and a short description (52 chars), - then bullet points are expected - and finally signatures. :param components: compontents, e.g. ``('auth', 'utils', 'misc')`` ...
0, module; 1, function_definition; 2, function_name:_getArrays; 3, parameters; 4, block; 5, identifier:items; 6, identifier:attr; 7, identifier:defaultValue; 8, expression_statement; 9, expression_statement; 10, for_statement; 11, for_statement; 12, return_statement; 13, comment:"""Return arrays with equal size of item...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 8, 13; 9, 14; 10, 15; 10, 16; 10, 17; 11, 18; 11, 19; 11, 20; 12, 21; 14, 22; 14, 23; 17, 24; 19, 25; 19, 26; 20, 27; 23, 28; 23, 29; 24, 30; 24, 31; 24, 32; 26, 33; 26, 34; 27, 35; 29, 36; 32, 37; 34, 38; 34, 39; 35, 40; 35, 41; 36, 42; 36, 43;...
def _getArrays(items, attr, defaultValue): """Return arrays with equal size of item attributes from a list of sorted "items" for fast and convenient data processing. :param attr: list of item attributes that should be added to the returned array. :param defaultValue: if an item is missing an at...
0, module; 1, function_definition; 2, function_name:_log_board_ports; 3, parameters; 4, block; 5, identifier:self; 6, identifier:ports; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, comment:""" A board with no ports is allowed. In the logfile, ports must be sorted ...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 7, 10; 8, 11; 9, 12; 11, 13; 11, 14; 12, 15; 12, 16; 14, 17; 14, 18; 15, 19; 15, 20; 16, 21; 18, 22; 18, 23; 21, 24; 21, 25; 23, 26; 23, 27; 24, 28; 24, 29; 25, 30; 27, 31; 27, 32; 28, 33; 30, 34; 30, 35; 31, 36; 32, 37; 32, 38; 34, 39; 34, 40; 35, 41; 35, 42; 37, 4...
def _log_board_ports(self, ports): """ A board with no ports is allowed. In the logfile, ports must be sorted - ascending by tile identifier (primary) - alphabetical by edge direction (secondary) :param ports: list of catan.board.Port objects """ ports =...
0, module; 1, function_definition; 2, function_name:sort; 3, parameters; 4, block; 5, identifier:self; 6, identifier:attr; 7, expression_statement; 8, expression_statement; 9, return_statement; 10, comment:"""Sort the ratings based on an attribute"""; 11, assignment; 12, identifier:self; 13, attribute; 14, call; 15, id...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 7, 10; 8, 11; 9, 12; 11, 13; 11, 14; 13, 15; 13, 16; 14, 17; 14, 18; 17, 19; 17, 20; 19, 21; 19, 22; 22, 23; 22, 24; 22, 25; 23, 26; 23, 27; 24, 28; 24, 29
def sort(self, attr): """Sort the ratings based on an attribute""" self.entries = Sorter(self.entries, self.category, attr).sort_entries() return self
0, module; 1, function_definition; 2, function_name:_visit; 3, parameters; 4, block; 5, identifier:self; 6, identifier:L; 7, identifier:marked; 8, identifier:tempmarked; 9, expression_statement; 10, assert_statement; 11, if_statement; 12, if_statement; 13, comment:""" Sort features topologically. This ...
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; 11, 16; 12, 17; 12, 18; 14, 19; 15, 20; 15, 21; 16, 22; 17, 23; 17, 24; 18, 25; 18, 26; 18, 27; 18, 28; 18, 29; 18, 30; 18, 31; 18, 32; 19, 33; 19, 34; 22, 35; 25, 36; 26, 37; 27, 38; 27, 39; 28, 40; 28, 41; 29, 42; 29, 43...
def _visit(self, L, marked, tempmarked): """ Sort features topologically. This recursive function uses depth-first search to find an ordering of the features in the feature graph that is sorted both topologically and with respect to genome coordinates. Implementation ba...
0, module; 1, function_definition; 2, function_name:pseudoify; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, assert_statement; 8, assert_statement; 9, assert_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, expression_state...
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; 6, 22; 7, 23; 8, 24; 9, 25; 10, 26; 11, 27; 12, 28; 13, 29; 14, 30; 15, 31; 16, 32; 17, 33; 18, 34; 18, 35; 18, 36; 19, 37; 20, 38; 21, 39; 23, 40; 23, 41; 24, 42; 24, 43; 25, 44; 25...
def pseudoify(self): """ Derive a pseudo-feature parent from the given multi-feature. The provided multi-feature does not need to be the representative. The newly created pseudo-feature has the same seqid as the provided multi- feature, and spans its entire range. Otherwise, the...
0, module; 1, function_definition; 2, function_name:attribute_crawl; 3, parameters; 4, block; 5, identifier:self; 6, identifier:key; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, return_statement; 11, comment:""" Grab all attribute values associated with the given feature. Tra...
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; 18, 21; 18, 22; 19, 23; 20, 24; 20, 25; 23, 26; 23, 27; 24, 28; 24, 29; 25, 30; 27, 31; 27, 32; 30, 33; 31, 34; 31, 35; 32, 36; 32, 37; 33, 38; 33, 39; 37, 40; 37, 41; 38, 42; 38, 43; ...
def attribute_crawl(self, key): """ Grab all attribute values associated with the given feature. Traverse the given feature (and all of its descendants) to find all values associated with the given attribute key. >>> import tag >>> reader = tag.GFF3Reader(tag.pkgdata('o...
0, module; 1, function_definition; 2, function_name:_findSamesetProteins; 3, parameters; 4, block; 5, identifier:protToPeps; 6, default_parameter; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, for_statement; 11, expression_statement; 12, for_statement; 13, return_statement; 14, identifi...
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; 10, 21; 11, 22; 12, 23; 12, 24; 12, 25; 13, 26; 17, 27; 17, 28; 18, 29; 18, 30; 21, 31; 21, 32; 22, 33; 22, 34; 24, 35; 24, 36; 25, 37; 28, 38; 28, 39; 28, 40; 30, 41; 30, 42; 31, 43; 32,...
def _findSamesetProteins(protToPeps, proteins=None): """Find proteins that are mapped to an identical set of peptides. :param protToPeps: dict, for each protein (=key) contains a set of associated peptides (=value). For Example {protein: {peptide, ...}, ...} :param proteins: iterable, proteins that...