nodes stringlengths 501 22.4k | edges stringlengths 138 5.07k | code stringlengths 108 19.3k |
|---|---|---|
0, module; 1, function_definition; 2, function_name:find_nearest; 3, parameters; 4, block; 5, identifier:sorted_list; 6, identifier:x; 7, expression_statement; 8, if_statement; 9, comment:"""
Find the nearest item of x from sorted array.
:type array: list
:param array: an iterable object that support inex
... | 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; 10, 14; 10, 15; 11, 16; 12, 17; 12, 18; 13, 19; 15, 20; 15, 21; 16, 22; 17, 23; 17, 24; 18, 25; 19, 26; 19, 27; 19, 28; 22, 29; 22, 30; 24, 31; 24, 32; 25, 33; 26, 34; 27, 35; 28, 36; 28, 37; 28, 38; 32, 39; 33, 40; 33, 41; 34, 42; 34, 43... | def find_nearest(sorted_list, x):
"""
Find the nearest item of x from sorted array.
:type array: list
:param array: an iterable object that support inex
:param x: a comparable value
note: for finding the nearest item from a descending array, I recommend
find_nearest(sorted_list[::-1], x).... |
0, module; 1, function_definition; 2, function_name:_parse_dependencies; 3, parameters; 4, block; 5, identifier:string; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, for_statement; 13, expression_statement; 14,... | 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; 12, 21; 12, 22; 12, 23; 13, 24; 14, 25; 16, 26; 16, 27; 17, 28; 17, 29; 18, 30; 18, 31; 19, 32; 19, 33; 20, 34; 20, 35; 23, 36; 24, 37; 24, 38; 25, 39; 25, 40; 25, 41; 27, 42; 27, 43; 29,... | def _parse_dependencies(string):
"""
This function actually parses the dependencies are sorts them into
the buildable and given dependencies
"""
contents = _get_contents_between(string, '(', ')')
unsorted_dependencies = contents.split(',')
_check_parameters(unsorted_dependencies, ('?',))
... |
0, module; 1, function_definition; 2, function_name:assert_output; 3, parameters; 4, block; 5, identifier:output; 6, identifier:assert_equal; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, if_statement; 11, comment:"""
Check that two outputs have the same contents as one another, eve... | 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; 12, 17; 13, 18; 13, 19; 14, 20; 14, 21; 15, 22; 17, 23; 17, 24; 19, 25; 19, 26; 22, 27; 24, 28; 26, 29; 27, 30; 27, 31; 31, 32; 32, 33; 32, 34; 33, 35; 33, 36; 34, 37; 34, 38 | def assert_output(output, assert_equal):
"""
Check that two outputs have the same contents as one another, even if they
aren't sorted yet
"""
sorted_output = sorted(output)
sorted_assert = sorted(assert_equal)
if sorted_output != sorted_assert:
raise ValueError(ASSERT_ERROR.format(so... |
0, module; 1, function_definition; 2, function_name:sort; 3, parameters; 4, block; 5, identifier:self; 6, identifier:request; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, if_statement; 11, if_statement; 12, return_statement; 13, identifier:reverse; 14, False; 15, comment:"""Sort current c... | 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; 9, 16; 10, 17; 10, 18; 11, 19; 11, 20; 12, 21; 16, 22; 16, 23; 17, 24; 18, 25; 20, 26; 21, 27; 21, 28; 23, 29; 23, 30; 25, 31; 26, 32; 27, 33; 27, 34; 28, 35; 29, 36; 29, 37; 30, 38; 31, 39; 31, 40; 32, 41; 32, 42; 33, 43; 3... | def sort(self, request, reverse=False):
"""Sort current collection."""
field = self.model._meta.fields.get(self.columns_sort)
if not field:
return self.collection
if reverse:
field = field.desc()
return self.collection.order_by(field) |
0, module; 1, function_definition; 2, function_name:find_files; 3, parameters; 4, block; 5, default_parameter; 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, if_statement; 15, i... | 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; 5, 15; 5, 16; 6, 17; 6, 18; 7, 19; 7, 20; 8, 21; 8, 22; 9, 23; 9, 24; 10, 25; 10, 26; 11, 27; 11, 28; 12, 29; 13, 30; 14, 31; 14, 32; 14, 33; 14, 34; 30, 35; 30, 36; 31, 37; 31, 38; 32, 39; 33, 40; 33, 41; 34, 42; 36, 43; 36, 44; 3... | def find_files(path='', ext='', level=None, typ=list, dirs=False, files=True, verbosity=0):
""" Recursively find all files in the indicated directory
Filter by the indicated file name extension (ext)
Args:
path (str): Root/base path to search.
ext (str): File name extension. Only file paths... |
0, module; 1, function_definition; 2, function_name:sort; 3, parameters; 4, block; 5, identifier:self; 6, identifier:request; 7, default_parameter; 8, expression_statement; 9, return_statement; 10, identifier:reverse; 11, False; 12, comment:"""Sort collection."""; 13, call; 14, identifier:sorted; 15, argument_list; 16,... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 7, 10; 7, 11; 8, 12; 9, 13; 13, 14; 13, 15; 15, 16; 15, 17; 15, 18; 16, 19; 16, 20; 17, 21; 17, 22; 18, 23; 18, 24; 22, 25; 22, 26; 25, 27; 26, 28; 26, 29; 29, 30; 29, 31; 29, 32; 31, 33; 31, 34 | async def sort(self, request, reverse=False):
"""Sort collection."""
return sorted(
self.collection, key=lambda o: getattr(o, self.columns_sort, 0), reverse=reverse) |
0, module; 1, function_definition; 2, function_name:map_aliases_to_device_objects; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, for_statement; 9, return_statement; 10, comment:"""
A device object knows its rid, but not its alias.
A portal obje... | 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; 19, 22; 19, 23; 21, 24; 21, 25; 24, 26; 24, 27; 25, 28; 25, 29; 27, 30; 28, 31; 28, 32; 29, 33; 29, 34; 31, 35; 31, 36; 32, 37; 34, 38; 35, 39; 35, 40; 36, 41; 39, 42; 39, 43; ... | def map_aliases_to_device_objects(self):
"""
A device object knows its rid, but not its alias.
A portal object knows its device rids and aliases.
This function adds an 'portals_aliases' key to all of the
device objects so they can be sorted by alias.
"""... |
0, module; 1, function_definition; 2, function_name:print_sorted_device_list; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, if_statement; 12, expression_statement; 13, identifier:device_list; 14, N... | 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; 11, 20; 11, 21; 11, 22; 11, 23; 11, 24; 12, 25; 16, 26; 18, 27; 18, 28; 19, 29; 19, 30; 20, 31; 20, 32; 21, 33; 21, 34; 21, 35; 22, 36; 22, 37; 23, 38; 23, 39; 24, 40; 25, 41; 25, 42; 28, 43; 28,... | def print_sorted_device_list(self, device_list=None, sort_key='sn'):
"""
Takes in a sort key and prints the device list according to that sort.
Default sorts on serial number.
Current supported sort options are:
- name
- sn
- ... |
0, module; 1, function_definition; 2, function_name:compile_vocab; 3, parameters; 4, block; 5, identifier:docs; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, try_statement; 13, for_statement; 14, return_statement; 15, i... | 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; 6, 15; 6, 16; 7, 17; 7, 18; 8, 19; 8, 20; 9, 21; 10, 22; 11, 23; 12, 24; 12, 25; 13, 26; 13, 27; 13, 28; 13, 29; 13, 30; 14, 31; 20, 32; 20, 33; 22, 34; 22, 35; 23, 36; 23, 37; 24, 38; 24, 39; 25, 40; 25, 41; 26, 42; 26, 43; 27, 44... | def compile_vocab(docs, limit=1e6, verbose=0, tokenizer=Tokenizer(stem=None, lower=None, strip=None)):
"""Get the set of words used anywhere in a sequence of documents and assign an integer id
This vectorizer is much faster than the scikit-learn version (and only requires low/constant RAM ?).
>>> gen = ('... |
0, module; 1, function_definition; 2, function_name:find_point_in_section_list; 3, parameters; 4, block; 5, identifier:point; 6, identifier:section_list; 7, expression_statement; 8, if_statement; 9, if_statement; 10, try_statement; 11, comment:"""Returns the start of the section the given point belongs to.
The giv... | 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; 12, 18; 12, 19; 13, 20; 14, 21; 14, 22; 15, 23; 15, 24; 15, 25; 15, 26; 16, 27; 16, 28; 17, 29; 17, 30; 18, 31; 18, 32; 19, 33; 19, 34; 20, 35; 23, 36; 23, 37; 24, 38; 25, 39; 25, 40; 26, 41; 27, 42; 28, 43; ... | def find_point_in_section_list(point, section_list):
"""Returns the start of the section the given point belongs to.
The given list is assumed to contain start points of consecutive
sections, except for the final point, assumed to be the end point of the
last section. For example, the list [5, 8, 30, 3... |
0, module; 1, function_definition; 2, function_name:find_range_ix_in_section_list; 3, parameters; 4, block; 5, identifier:start; 6, identifier:end; 7, identifier:section_list; 8, expression_statement; 9, if_statement; 10, if_statement; 11, if_statement; 12, return_statement; 13, comment:"""Returns the index range all 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; 8, 13; 9, 14; 9, 15; 10, 16; 10, 17; 10, 18; 11, 19; 11, 20; 11, 21; 12, 22; 14, 23; 14, 24; 15, 25; 16, 26; 16, 27; 17, 28; 18, 29; 19, 30; 19, 31; 20, 32; 21, 33; 22, 34; 22, 35; 23, 36; 23, 37; 24, 38; 24, 39; 25, 40; 27, 41; 27, 42; 28, 43; ... | def find_range_ix_in_section_list(start, end, section_list):
"""Returns the index range all sections belonging to the given range.
The given list is assumed to contain start points of consecutive
sections, except for the final point, assumed to be the end point of the
last section. For example, the lis... |
0, module; 1, function_definition; 2, function_name:find_range_in_section_list; 3, parameters; 4, block; 5, identifier:start; 6, identifier:end; 7, identifier:section_list; 8, expression_statement; 9, expression_statement; 10, return_statement; 11, comment:"""Returns all sections belonging to the given range.
The ... | 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; 12, 14; 12, 15; 13, 16; 13, 17; 15, 18; 15, 19; 17, 20; 17, 21; 19, 22; 19, 23; 19, 24; 20, 25; 20, 26; 21, 27; 21, 28 | def find_range_in_section_list(start, end, section_list):
"""Returns all sections belonging to the given range.
The given list is assumed to contain start points of consecutive
sections, except for the final point, assumed to be the end point of the
last section. For example, the list [5, 8, 30, 31] is... |
0, module; 1, function_definition; 2, function_name:find_range_ix_in_point_list; 3, parameters; 4, block; 5, identifier:start; 6, identifier:end; 7, identifier:point_list; 8, expression_statement; 9, return_statement; 10, comment:"""Returns the index range all points inside the given range.
Parameters
--------... | 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; 12, 14; 12, 15; 13, 16; 13, 17; 14, 18; 14, 19; 15, 20; 16, 21; 16, 22; 17, 23 | def find_range_ix_in_point_list(start, end, point_list):
"""Returns the index range all points inside the given range.
Parameters
---------
start : float
The start of the desired range.
end : float
The end of the desired range.
point_list : sortedcontainers.SortedList
A ... |
0, module; 1, function_definition; 2, function_name:parse_int_string; 3, parameters; 4, type; 5, block; 6, typed_parameter; 7, generic_type; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, for_statement; 15, re... | 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; 6, 16; 6, 17; 7, 18; 7, 19; 8, 20; 9, 21; 10, 22; 11, 23; 12, 24; 13, 25; 14, 26; 14, 27; 14, 28; 15, 29; 17, 30; 19, 31; 21, 32; 21, 33; 22, 34; 22, 35; 23, 36; 23, 37; 24, 38; 24, 39; 25, 40; 25, 41; 25, 42; 28, 43; 29, 44... | def parse_int_string(int_string: str) -> List[int]:
"""
Given a string like "1 23 4-8 32 1", return a unique list of those integers in the string and
the integers in the ranges in the string.
Non-numbers ignored. Not necessarily sorted
"""
cleaned = " ".join(int_string.strip().split())
clean... |
0, module; 1, function_definition; 2, function_name:persistence2stats; 3, parameters; 4, block; 5, identifier:rev_docs; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, express... | 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; 6, 18; 6, 19; 7, 20; 7, 21; 8, 22; 8, 23; 9, 24; 9, 25; 10, 26; 10, 27; 11, 28; 12, 29; 13, 30; 14, 31; 15, 32; 16, 33; 17, 34; 17, 35; 17, 36; 29, 37; 29, 38; 30, 39; 30, 40; 31, 41; 31, 42; 32, 43; 32, 44; 33... | def persistence2stats(rev_docs, min_persisted=5, min_visible=1209600,
include=None, exclude=None, verbose=False):
"""
Processes a sorted and page-partitioned sequence of revision documents into
and adds statistics to the 'persistence' field each token "added" in the
revision persis... |
0, module; 1, function_definition; 2, function_name:diffs2persistence; 3, parameters; 4, block; 5, identifier:rev_docs; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 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; 4, 17; 6, 18; 6, 19; 7, 20; 7, 21; 8, 22; 8, 23; 9, 24; 9, 25; 10, 26; 11, 27; 12, 28; 13, 29; 14, 30; 16, 31; 17, 32; 17, 33; 17, 34; 27, 35; 27, 36; 28, 37; 28, 38; 29, 39; 29, 40; 30, 41; 30, 42; 31, 43; 31, 44; 32... | def diffs2persistence(rev_docs, window_size=50, revert_radius=15, sunset=None,
verbose=False):
"""
Processes a sorted and page-partitioned sequence of revision documents into
and adds a 'persistence' field to them containing statistics about how each
token "added" in the revision p... |
0, module; 1, function_definition; 2, function_name:_build_module_db; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, for_statement; 9, for_statement; 10, comment:"""
Build database of module callables sorted by line number.
The database is a dictionary... | 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; 9, 16; 9, 17; 11, 18; 11, 19; 12, 20; 12, 21; 13, 22; 13, 23; 14, 24; 14, 25; 14, 26; 16, 27; 16, 28; 17, 29; 19, 30; 19, 31; 22, 32; 22, 33; 24, 34; 25, 35; 26, 36; 27, 37; 27, 38; 29, 39; 30, 40; 30, 41; 31, 42; 32, 43; 32... | def _build_module_db(self):
"""
Build database of module callables sorted by line number.
The database is a dictionary whose keys are module file names and
whose values are lists of dictionaries containing name and line
number of callables in that module
"""
tdic... |
0, module; 1, function_definition; 2, function_name:_sorted_keys_items; 3, parameters; 4, block; 5, identifier:dobj; 6, expression_statement; 7, expression_statement; 8, for_statement; 9, comment:"""Return dictionary items sorted by key."""; 10, assignment; 11, identifier:key; 12, identifier:keys; 13, block; 14, identi... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 6, 9; 7, 10; 8, 11; 8, 12; 8, 13; 10, 14; 10, 15; 13, 16; 15, 17; 15, 18; 16, 19; 18, 20; 19, 21; 20, 22; 20, 23; 21, 24; 21, 25; 22, 26; 22, 27; 25, 28; 25, 29 | def _sorted_keys_items(dobj):
"""Return dictionary items sorted by key."""
keys = sorted(dobj.keys())
for key in keys:
yield key, dobj[key] |
0, module; 1, function_definition; 2, function_name:subdict_by_keys; 3, parameters; 4, block; 5, identifier:dict_obj; 6, identifier:keys; 7, expression_statement; 8, return_statement; 9, comment:"""Returns a sub-dict composed solely of the given keys.
Parameters
----------
dict_obj : dict
The dict ... | 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; 12, 16; 14, 17; 14, 18; 16, 19; 16, 20; 19, 21; 19, 22; 20, 23; 21, 24; 21, 25; 23, 26; 23, 27; 25, 28; 26, 29; 26, 30 | def subdict_by_keys(dict_obj, keys):
"""Returns a sub-dict composed solely of the given keys.
Parameters
----------
dict_obj : dict
The dict to create a sub-dict from.
keys : list of str
The keys to keep in the sub-dict. Keys not present in the given dict
will be ignored.
... |
0, module; 1, function_definition; 2, function_name:deep_merge_dict; 3, parameters; 4, block; 5, identifier:base; 6, identifier:priority; 7, expression_statement; 8, if_statement; 9, expression_statement; 10, for_statement; 11, return_statement; 12, comment:"""Recursively merges the two given dicts into a single dict.
... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 7, 12; 8, 13; 8, 14; 9, 15; 10, 16; 10, 17; 10, 18; 11, 19; 13, 20; 13, 21; 14, 22; 15, 23; 15, 24; 17, 25; 17, 26; 18, 27; 20, 28; 21, 29; 22, 30; 24, 31; 24, 32; 25, 33; 25, 34; 27, 35; 27, 36; 27, 37; 28, 38; 28, 39; 29, 40; 29, 41; 31, 42; 31, 43; ... | def deep_merge_dict(base, priority):
"""Recursively merges the two given dicts into a single dict.
Treating base as the the initial point of the resulting merged dict,
and considering the nested dictionaries as trees, they are merged os:
1. Every path to every leaf in priority would be represented in t... |
0, module; 1, function_definition; 2, function_name:norm_int_dict; 3, parameters; 4, block; 5, identifier:int_dict; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, return_statement; 11, comment:"""Normalizes values in the given dict with int values.
Parameters
-... | 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; 16, 22; 19, 23; 19, 24; 21, 25; 21, 26; 22, 27; 23, 28; 23, 29; 26, 30; 27, 31; 27, 32; 30, 33; 30, 34; 31, 35; 31, 36; 32, 37; 32, 38; 33, 39; 33, 40; 37, 41; 37, 42 | def norm_int_dict(int_dict):
"""Normalizes values in the given dict with int values.
Parameters
----------
int_dict : list
A dict object mapping each key to an int value.
Returns
-------
dict
A dict where each key is mapped to its relative part in the sum of
all dic... |
0, module; 1, function_definition; 2, function_name:sum_num_dicts; 3, parameters; 4, block; 5, identifier:dicts; 6, default_parameter; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, if_statement; 11, return_statement; 12, identifier:normalize; 13, False; 14, comment:"""Sums the given dicts into... | 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; 9, 17; 9, 18; 10, 19; 10, 20; 11, 21; 15, 22; 15, 23; 18, 24; 20, 25; 24, 26; 24, 27; 24, 28; 25, 29; 28, 30; 29, 31; 29, 32; 30, 33; 32, 34; 33, 35; 33, 36; 35, 37; 35, 38; 36, 39; 36, 40; 39, 41; 39, 42; 40, 43; 40,... | def sum_num_dicts(dicts, normalize=False):
"""Sums the given dicts into a single dict mapping each key to the sum
of its mappings in all given dicts.
Parameters
----------
dicts : list
A list of dict objects mapping each key to an numeric value.
normalize : bool, default False
I... |
0, module; 1, function_definition; 2, function_name:reverse_dict; 3, parameters; 4, block; 5, identifier:dict_obj; 6, expression_statement; 7, expression_statement; 8, for_statement; 9, for_statement; 10, return_statement; 11, comment:"""Reverse a dict, so each value in it maps to a sorted list of its keys.
Parame... | 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; 9, 17; 9, 18; 10, 19; 12, 20; 12, 21; 15, 22; 18, 23; 22, 24; 23, 25; 24, 26; 24, 27; 25, 28; 25, 29; 27, 30; 27, 31; 27, 32; 28, 33; 28, 34; 29, 35; 29, 36; 30, 37; 30, 38; 31, 39; 31, 40; 32, 41; 32, 42; 36, 43; 36,... | def reverse_dict(dict_obj):
"""Reverse a dict, so each value in it maps to a sorted list of its keys.
Parameters
----------
dict_obj : dict
A key-value dict.
Returns
-------
dict
A dict where each value maps to a sorted list of all the unique keys
that mapped to it.... |
0, module; 1, function_definition; 2, function_name:flatten_dict; 3, parameters; 4, block; 5, identifier:dict_obj; 6, default_parameter; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, function_definition; 12, function_definition; 13, expression_statement; 14, retur... | 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; 8, 19; 9, 20; 10, 21; 11, 22; 11, 23; 11, 24; 12, 25; 12, 26; 12, 27; 13, 28; 14, 29; 16, 30; 20, 31; 20, 32; 21, 33; 21, 34; 23, 35; 23, 36; 23, 37; 24, 38; 24, 39; 26, 40; 26, 41; 27, 42; 28, 43; 28, 4... | def flatten_dict(dict_obj, separator='.', flatten_lists=False):
"""Flattens the given dict into a single-level dict with flattend keys.
Parameters
----------
dict_obj : dict
A possibly nested dict.
separator : str, optional
The character to use as a separator between keys. Defaults ... |
0, module; 1, function_definition; 2, function_name:key_value_nested_generator; 3, parameters; 4, block; 5, identifier:dict_obj; 6, expression_statement; 7, for_statement; 8, comment:"""Recursively iterate over key-value pairs of nested dictionaries.
Parameters
----------
dict_obj : dict
The outer-... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 6, 8; 7, 9; 7, 10; 7, 11; 9, 12; 9, 13; 10, 14; 10, 15; 11, 16; 14, 17; 14, 18; 16, 19; 16, 20; 16, 21; 19, 22; 19, 23; 20, 24; 21, 25; 23, 26; 23, 27; 24, 28; 24, 29; 24, 30; 25, 31; 28, 32; 28, 33; 29, 34; 29, 35; 30, 36; 31, 37; 35, 38; 36, 39; 37, 40; 39, 41; 40, 42; 40, 43... | def key_value_nested_generator(dict_obj):
"""Recursively iterate over key-value pairs of nested dictionaries.
Parameters
----------
dict_obj : dict
The outer-most dict to iterate on.
Returns
-------
generator
A generator over key-value pairs in all nested dictionaries.
... |
0, module; 1, function_definition; 2, function_name:key_tuple_value_nested_generator; 3, parameters; 4, block; 5, identifier:dict_obj; 6, expression_statement; 7, for_statement; 8, comment:"""Recursively iterate over key-tuple-value pairs of nested dictionaries.
Parameters
----------
dict_obj : dict
... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 6, 8; 7, 9; 7, 10; 7, 11; 9, 12; 9, 13; 10, 14; 10, 15; 11, 16; 14, 17; 14, 18; 16, 19; 16, 20; 16, 21; 19, 22; 19, 23; 20, 24; 21, 25; 23, 26; 23, 27; 24, 28; 24, 29; 24, 30; 25, 31; 28, 32; 28, 33; 29, 34; 29, 35; 30, 36; 31, 37; 35, 38; 36, 39; 37, 40; 39, 41; 40, 42; 40, 43... | def key_tuple_value_nested_generator(dict_obj):
"""Recursively iterate over key-tuple-value pairs of nested dictionaries.
Parameters
----------
dict_obj : dict
The outer-most dict to iterate on.
Returns
-------
generator
A generator over key-tuple-value pairs in all nested ... |
0, module; 1, function_definition; 2, function_name:_sort_dd_skips; 3, parameters; 4, block; 5, identifier:configs; 6, identifier:dd_indices_all; 7, expression_statement; 8, expression_statement; 9, if_statement; 10, comment:# determine skips; 11, expression_statement; 12, expression_statement; 13, comment:# now determ... | 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; 9, 20; 11, 21; 12, 22; 14, 23; 15, 24; 15, 25; 15, 26; 16, 27; 18, 28; 18, 29; 19, 30; 19, 31; 20, 32; 21, 33; 21, 34; 22, 35; 22, 36; 23, 37; 23, 38; 26, 39; 26, 40; 29, 41; 29, 42; 30, 43; 30, 4... | def _sort_dd_skips(configs, dd_indices_all):
"""Given a set of dipole-dipole configurations, sort them according to
their current skip.
Parameters
----------
configs: Nx4 numpy.ndarray
Dipole-Dipole configurations
Returns
-------
dd_configs_sorted: dict
dictionary with ... |
0, module; 1, function_definition; 2, function_name:plot_pseudodepths; 3, parameters; 4, block; 5, identifier:configs; 6, identifier:nr_electrodes; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, dictionary_splat_pattern; 12, expression_statement; 13, comment:# for each conf... | 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; 7, 25; 7, 26; 8, 27; 8, 28; 9, 29; 9, 30; 10, 31; 10, 32; 11, 33; 12, 34; 15, 35; 16, 36; 18, 37; 19, 38; 21, 39; 22, 40; 23, 41; 23, 42; 23, 43; 24, 44; 24, 45;... | def plot_pseudodepths(configs, nr_electrodes, spacing=1, grid=None,
ctypes=None, dd_merge=False, **kwargs):
"""Plot pseudodepths for the measurements. If grid is given, then the
actual electrode positions are used, and the parameter 'spacing' is
ignored'
Parameters
----------
... |
0, module; 1, function_definition; 2, function_name:gen_reciprocals; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, expression_statement; 8, comment:# Switch AB and MN; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, comment:# # Sort by current dipoles; 13, expres... | 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; 9, 20; 10, 21; 11, 22; 13, 23; 14, 24; 15, 25; 15, 26; 16, 27; 20, 28; 20, 29; 21, 30; 21, 31; 22, 32; 22, 33; 23, 34; 23, 35; 24, 36; 24, 37; 26, 38; 29, 39; 29, 40; 29, 41; 30, 42; 30, 43; 30, 4... | def gen_reciprocals(self, append=False):
""" Generate reciprocal configurations, sort by AB, and optionally
append to configurations.
Parameters
----------
append : bool
Append reciprocals to configs (the default is False).
Examples
--------
... |
0, module; 1, function_definition; 2, function_name:load_seit_data; 3, parameters; 4, block; 5, identifier:directory; 6, default_parameter; 7, default_parameter; 8, dictionary_splat_pattern; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, comment:# check that the number of frequencies m... | 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; 6, 19; 6, 20; 7, 21; 7, 22; 8, 23; 9, 24; 10, 25; 11, 26; 13, 27; 13, 28; 15, 29; 16, 30; 16, 31; 16, 32; 17, 33; 18, 34; 20, 35; 22, 36; 25, 37; 25, 38; 26, 39; 26, 40; 27, 41; 27, 42; 28, 43; 29, 44; 2... | def load_seit_data(directory, frequency_file='frequencies.dat',
data_prefix='volt_', **kwargs):
"""Load sEIT data from data directory. This function loads data previously
exported from reda using reda.exporters.crtomo.write_files_to_directory
Parameters
----------
directory : str... |
0, module; 1, function_definition; 2, function_name:_query_attr_sort_fn; 3, parameters; 4, block; 5, identifier:self; 6, identifier:attr_val; 7, expression_statement; 8, expression_statement; 9, if_statement; 10, comment:"""Used to order where keys by most selective key first"""; 11, assignment; 12, comparison_operator... | 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; 13, 20; 14, 21; 15, 22; 15, 23; 18, 24; 18, 25; 19, 26; 20, 27; 20, 28; 20, 29; 21, 30; 26, 31; 26, 32; 27, 33; 27, 34; 28, 35; 29, 36; 30, 37; 32, 38; 32, 39; 35, 40; 36, 41; 38, 42; 38, 43;... | def _query_attr_sort_fn(self, attr_val):
"""Used to order where keys by most selective key first"""
attr, v = attr_val
if attr in self._indexes:
idx = self._indexes[attr]
if v in idx:
return len(idx[v])
else:
return 0
el... |
0, module; 1, function_definition; 2, function_name:sort; 3, parameters; 4, block; 5, identifier:self; 6, identifier:key; 7, default_parameter; 8, expression_statement; 9, if_statement; 10, return_statement; 11, identifier:reverse; 12, False; 13, comment:"""Sort Table in place, using given fields as sort key.
... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 7, 11; 7, 12; 8, 13; 9, 14; 9, 15; 9, 16; 10, 17; 14, 18; 14, 19; 15, 20; 15, 21; 15, 22; 15, 23; 16, 24; 16, 25; 19, 26; 19, 27; 20, 28; 20, 29; 20, 30; 21, 31; 23, 32; 23, 33; 23, 34; 23, 35; 25, 36; 25, 37; 27, 38; 27, 39; 27, 40; 28, 41; 28, 42; 29, 43; 2... | def sort(self, key, reverse=False):
"""Sort Table in place, using given fields as sort key.
@param key: if this is a string, it is a comma-separated list of field names,
optionally followed by 'desc' to indicate descending sort instead of the
default ascending sort; if a ... |
0, module; 1, function_definition; 2, function_name:sort_window_ids; 3, parameters; 4, block; 5, identifier:winid_list; 6, default_parameter; 7, expression_statement; 8, import_statement; 9, expression_statement; 10, expression_statement; 11, return_statement; 12, identifier:order; 13, string; 14, comment:"""
O... | 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; 20, 26; 23, 27; 23, 28; 25, 29; 25, 30; 27, 31; 27, 32; 28, 33; 29, 34; 29, 35; 30, 36; 30, 37 | def sort_window_ids(winid_list, order='mru'):
"""
Orders window ids by most recently used
"""
import utool as ut
winid_order = XCtrl.sorted_window_ids(order)
sorted_win_ids = ut.isect(winid_order, winid_list)
return sorted_win_ids |
0, module; 1, function_definition; 2, function_name:glob; 3, parameters; 4, block; 5, identifier:dpath; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, default_parameter; 13, dictionary_splat_pattern; 14, expression_statement; 15,... | 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; 6, 18; 6, 19; 7, 20; 7, 21; 8, 22; 8, 23; 9, 24; 9, 25; 10, 26; 10, 27; 11, 28; 11, 29; 12, 30; 12, 31; 13, 32; 14, 33; 15, 34; 16, 35; 17, 36; 34, 37; 34, 38; 35, 39; 35, 40; 38, 41; 38, 42; 40, 43; 40, 44; 42... | def glob(dpath, pattern=None, recursive=False, with_files=True, with_dirs=True,
maxdepth=None, exclude_dirs=[], fullpath=True, **kwargs):
r"""
Globs directory for pattern
DEPRICATED:
use pathlib.glob instead
Args:
dpath (str): directory path or pattern
pattern (str or ... |
0, module; 1, function_definition; 2, function_name:list_images; 3, parameters; 4, block; 5, identifier:img_dpath_; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, expression_statement; 12, comment:#if not QUIET:; 13, comment:# print(ignore_list); 14... | 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; 4, 20; 4, 21; 4, 22; 4, 23; 4, 24; 6, 25; 6, 26; 7, 27; 7, 28; 8, 29; 8, 30; 9, 31; 9, 32; 10, 33; 10, 34; 11, 35; 14, 36; 14, 37; 15, 38; 16, 39; 17, 40; 18, 41; 19, 42; 21, 43; 22, 44; 22, 45; 2... | def list_images(img_dpath_, ignore_list=[], recursive=False, fullpath=False,
full=None, sort=True):
r"""
Returns a list of images in a directory. By default returns relative paths.
TODO: rename to ls_images
TODO: Change all instances of fullpath to full
Args:
img_dpath_ (st... |
0, module; 1, function_definition; 2, function_name:isect; 3, parameters; 4, block; 5, identifier:list1; 6, identifier:list2; 7, expression_statement; 8, expression_statement; 9, return_statement; 10, comment:r"""
returns list1 elements that are also in list2. preserves order of list1
intersect_ordered
Ar... | 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; 12, 17; 14, 18; 14, 19; 16, 20; 16, 21; 17, 22; 19, 23; 22, 24; 22, 25 | def isect(list1, list2):
r"""
returns list1 elements that are also in list2. preserves order of list1
intersect_ordered
Args:
list1 (list):
list2 (list):
Returns:
list: new_list
Example:
>>> # DISABLE_DOCTEST
>>> from utool.util_list import * # NOQA
... |
0, module; 1, function_definition; 2, function_name:argsort; 3, parameters; 4, block; 5, list_splat_pattern; 6, dictionary_splat_pattern; 7, expression_statement; 8, if_statement; 9, identifier:args; 10, identifier:kwargs; 11, comment:"""
like np.argsort but for lists
Args:
*args: multiple lists to sor... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 5, 9; 6, 10; 7, 11; 8, 12; 8, 13; 8, 14; 12, 15; 12, 16; 13, 17; 13, 18; 13, 19; 13, 20; 14, 21; 15, 22; 15, 23; 16, 24; 16, 25; 17, 26; 18, 27; 19, 28; 20, 29; 21, 30; 21, 31; 22, 32; 22, 33; 25, 34; 25, 35; 26, 36; 26, 37; 27, 38; 27, 39; 28, 40; 28, 41; 29, 42; 29, 43;... | def argsort(*args, **kwargs):
"""
like np.argsort but for lists
Args:
*args: multiple lists to sort by
**kwargs:
reverse (bool): sort order is descending if True else acscending
CommandLine:
python -m utool.util_list argsort
Example:
>>> # DISABLE_DOCTE... |
0, module; 1, function_definition; 2, function_name:argsort2; 3, parameters; 4, block; 5, identifier:indexable; 6, default_parameter; 7, default_parameter; 8, expression_statement; 9, comment:# Create an iterator of value/key pairs; 10, if_statement; 11, comment:# Sort by values and extract the keys; 12, if_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; 6, 14; 6, 15; 7, 16; 7, 17; 8, 18; 10, 19; 10, 20; 10, 21; 12, 22; 12, 23; 12, 24; 13, 25; 19, 26; 19, 27; 20, 28; 21, 29; 22, 30; 22, 31; 23, 32; 24, 33; 27, 34; 27, 35; 28, 36; 29, 37; 32, 38; 33, 39; 36, 40; 36, 41; 37, 42; 38, 43; 38,... | def argsort2(indexable, key=None, reverse=False):
"""
Returns the indices that would sort a indexable object.
This is similar to np.argsort, but it is written in pure python and works
on both lists and dictionaries.
Args:
indexable (list or dict): indexable to sort by
Returns:
... |
0, module; 1, function_definition; 2, function_name:issorted; 3, parameters; 4, block; 5, identifier:list_; 6, default_parameter; 7, expression_statement; 8, return_statement; 9, identifier:op; 10, attribute; 11, comment:"""
Determines if a list is sorted
Args:
list_ (list):
op (func): sorted o... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 6, 9; 6, 10; 7, 11; 8, 12; 10, 13; 10, 14; 12, 15; 12, 16; 16, 17; 16, 18; 17, 19; 17, 20; 18, 21; 18, 22; 20, 23; 20, 24; 22, 25; 22, 26; 23, 27; 23, 28; 24, 29; 24, 30; 26, 31; 30, 32; 30, 33; 31, 34; 31, 35; 34, 36; 34, 37; 37, 38 | def issorted(list_, op=operator.le):
"""
Determines if a list is sorted
Args:
list_ (list):
op (func): sorted operation (default=operator.le)
Returns:
bool : True if the list is sorted
"""
return all(op(list_[ix], list_[ix + 1]) for ix in range(len(list_) - 1)) |
0, module; 1, function_definition; 2, function_name:list_alignment; 3, parameters; 4, block; 5, identifier:list1; 6, identifier:list2; 7, default_parameter; 8, expression_statement; 9, import_statement; 10, expression_statement; 11, if_statement; 12, return_statement; 13, identifier:missing; 14, False; 15, comment:"""
... | 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; 9, 16; 10, 17; 11, 18; 11, 19; 11, 20; 12, 21; 16, 22; 16, 23; 17, 24; 17, 25; 19, 26; 20, 27; 22, 28; 25, 29; 25, 30; 26, 31; 27, 32; 30, 33; 31, 34; 31, 35; 32, 36; 35, 37; 35, 38; 36, 39; 36, 40; 37, 41; 37, 42; 38, 43; 3... | def list_alignment(list1, list2, missing=False):
"""
Assumes list items are unique
Args:
list1 (list): a list of unique items to be aligned
list2 (list): a list of unique items in a desired ordering
missing (bool): True if list2 can contain items not in list1
Returns:
l... |
0, module; 1, function_definition; 2, function_name:hash_data; 3, parameters; 4, block; 5, identifier:data; 6, default_parameter; 7, default_parameter; 8, expression_statement; 9, if_statement; 10, if_statement; 11, if_statement; 12, identifier:hashlen; 13, None; 14, identifier:alphabet; 15, None; 16, comment:r"""
... | 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; 7, 15; 8, 16; 9, 17; 9, 18; 10, 19; 10, 20; 11, 21; 11, 22; 11, 23; 11, 24; 17, 25; 17, 26; 18, 27; 19, 28; 19, 29; 20, 30; 21, 31; 21, 32; 23, 33; 24, 34; 27, 35; 30, 36; 31, 37; 31, 38; 32, 39; 32, 40; 33, 41; 34, 42; 34, 43; 34,... | def hash_data(data, hashlen=None, alphabet=None):
r"""
Get a unique hash depending on the state of the data.
Args:
data (object): any sort of loosely organized data
hashlen (None): (default = None)
alphabet (None): (default = None)
Returns:
str: text - hash string
... |
0, module; 1, function_definition; 2, function_name:quick_search; 3, parameters; 4, block; 5, identifier:self; 6, identifier:name; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, expression_statement; 11, if_statement; 12, expression_statement; 13, if_statement; 14, expression_statement; 15, retur... | 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; 7, 16; 7, 17; 8, 18; 8, 19; 9, 20; 9, 21; 10, 22; 11, 23; 11, 24; 11, 25; 12, 26; 13, 27; 13, 28; 14, 29; 15, 30; 23, 31; 23, 32; 24, 33; 25, 34; 26, 35; 26, 36; 27, 37; 27, 38; 28, 39; 28, 40; 28, 41; 29, 42; 29, 43; 33, 44... | def quick_search(self, name, platform=None, sort_by=None, desc=True):
"""
Quick search method that allows you to search for a game using only the
title and the platform
:param name: string
:param platform: int
:param sort_by: string
:param desc: bool
:ret... |
0, module; 1, function_definition; 2, function_name:sort_protein_group; 3, parameters; 4, block; 5, identifier:pgroup; 6, identifier:sortfunctions; 7, identifier:sortfunc_index; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, for_statement; 13, 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; 8, 14; 9, 15; 10, 16; 11, 17; 12, 18; 12, 19; 12, 20; 13, 21; 15, 22; 15, 23; 16, 24; 16, 25; 17, 26; 17, 27; 20, 28; 25, 29; 25, 30; 28, 31; 28, 32; 28, 33; 29, 34; 29, 35; 30, 36; 31, 37; 31, 38; 32, 39; 33, 40; 37, 41; 37, 42; 38, 43; ... | def sort_protein_group(pgroup, sortfunctions, sortfunc_index):
"""Recursive function that sorts protein group by a number of sorting
functions."""
pgroup_out = []
subgroups = sortfunctions[sortfunc_index](pgroup)
sortfunc_index += 1
for subgroup in subgroups:
if len(subgroup) > 1 and sor... |
0, module; 1, function_definition; 2, function_name:sort_amounts; 3, parameters; 4, block; 5, identifier:proteins; 6, identifier:sort_index; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, return_statement; 11, comment:"""Generic function for sorting peptides and psms. Assumes a higher
numbe... | 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; 16, 21; 16, 22; 19, 23; 20, 24; 20, 25; 22, 26; 22, 27; 23, 28; 23, 29; 24, 30; 25, 31; 25, 32; 26, 33; 26, 34; 27, 35; 27, 36; 29, 37; 29, 38; 30, 39; 32, 40; 36, 41; 36, 42; 39, 43; ... | def sort_amounts(proteins, sort_index):
"""Generic function for sorting peptides and psms. Assumes a higher
number is better for what is passed at sort_index position in protein."""
amounts = {}
for protein in proteins:
amount_x_for_protein = protein[sort_index]
try:
amounts[... |
0, module; 1, function_definition; 2, function_name:greedy_max_inden_setcover; 3, parameters; 4, block; 5, identifier:candidate_sets_dict; 6, identifier:items; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, while_... | 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; 7, 17; 7, 18; 8, 19; 9, 20; 10, 21; 11, 22; 12, 23; 13, 24; 13, 25; 13, 26; 14, 27; 15, 28; 16, 29; 20, 30; 20, 31; 21, 32; 21, 33; 22, 34; 22, 35; 23, 36; 23, 37; 26, 38; 26, 39; 26, 40; 26, 41; 26, 42; 26, 43; 26, 4... | def greedy_max_inden_setcover(candidate_sets_dict, items, max_covers=None):
"""
greedy algorithm for maximum independent set cover
Covers items with sets from candidate sets. Could be made faster.
CommandLine:
python -m utool.util_alg --test-greedy_max_inden_setcover
Example0:
>>>... |
0, module; 1, function_definition; 2, function_name:setcover_greedy; 3, parameters; 4, block; 5, identifier:candidate_sets_dict; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, expression_statement; 11, import_statement; 12, expression_statement; 13, comment:# If candset_weig... | 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; 6, 22; 6, 23; 7, 24; 7, 25; 8, 26; 8, 27; 9, 28; 9, 29; 10, 30; 11, 31; 12, 32; 14, 33; 14, 34; 15, 35; 15, 36; 15, 37; 16, 38; 16, 39; 16, 40; 17, 41; 17, 42; 18, 43; 20, 44; 20, 45... | def setcover_greedy(candidate_sets_dict, items=None, set_weights=None, item_values=None, max_weight=None):
r"""
Greedy algorithm for various covering problems.
approximation gaurentees depending on specifications like set_weights and item values
Set Cover: log(len(items) + 1) approximation algorithm
... |
0, module; 1, function_definition; 2, function_name:knapsack_greedy; 3, parameters; 4, block; 5, identifier:items; 6, identifier:maxweight; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, for_statement; 12, return_statement; 13, comment:r"""
non-optimal greed... | 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; 20, 29; 20, 30; 27, 31; 28, 32; 28, 33; 28, 34; 31, 35; 31, 36; 32, 37; 32, 38; 33, 39; 34, 40; 35, 41; 35, 42; 36, 43; ... | def knapsack_greedy(items, maxweight):
r"""
non-optimal greedy version of knapsack algorithm
does not sort input. Sort the input by largest value
first if desired.
Args:
`items` (tuple): is a sequence of tuples `(value, weight, id_)`, where `value`
is a scalar and `weight` is a ... |
0, module; 1, function_definition; 2, function_name:factors; 3, parameters; 4, block; 5, identifier:n; 6, expression_statement; 7, return_statement; 8, comment:"""
Computes all the integer factors of the number `n`
Example:
>>> # ENABLE_DOCTEST
>>> from utool.util_alg import * # NOQA
>... | 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; 14, 16; 15, 17; 15, 18; 16, 19; 16, 20; 16, 21; 19, 22; 19, 23; 20, 24; 20, 25; 21, 26; 23, 27; 23, 28; 25, 29; 25, 30; 26, 31; 26, 32; 30, 33; 30, 34; 31, 35; 31, 36; 34, 37; 34, 38; 37, 39; 37, 40; 40, 41; 41, 42; 41, ... | def factors(n):
"""
Computes all the integer factors of the number `n`
Example:
>>> # ENABLE_DOCTEST
>>> from utool.util_alg import * # NOQA
>>> import utool as ut
>>> result = sorted(ut.factors(10))
>>> print(result)
[1, 2, 5, 10]
References:
h... |
0, module; 1, function_definition; 2, function_name:dict_stack; 3, parameters; 4, block; 5, identifier:dict_list; 6, default_parameter; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, expression_statement; 11, return_statement; 12, identifier:key_prefix; 13, string; 14, comment:r"""
stacks v... | 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; 9, 17; 9, 18; 10, 19; 11, 20; 15, 21; 15, 22; 18, 23; 19, 24; 19, 25; 22, 26; 22, 27; 23, 28; 23, 29; 23, 30; 25, 31; 25, 32; 27, 33; 28, 34; 28, 35; 29, 36; 29, 37; 30, 38; 32, 39; 36, 40; 36, 41; 37, 42; 38, 43; 43,... | def dict_stack(dict_list, key_prefix=''):
r"""
stacks values from two dicts into a new dict where the values are list of
the input values. the keys are the same.
DEPRICATE in favor of dict_stack2
Args:
dict_list (list): list of dicts with similar keys
Returns:
dict dict_stacke... |
0, module; 1, function_definition; 2, function_name:invert_dict; 3, parameters; 4, block; 5, identifier:dict_; 6, default_parameter; 7, expression_statement; 8, if_statement; 9, return_statement; 10, identifier:unique_vals; 11, True; 12, comment:"""
Reverses the keys and values in a dictionary. Set unique_vals to F... | 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; 8, 14; 8, 15; 9, 16; 14, 17; 14, 18; 15, 19; 17, 20; 18, 21; 19, 22; 20, 23; 20, 24; 21, 25; 21, 26; 22, 27; 24, 28; 24, 29; 26, 30; 26, 31; 27, 32; 27, 33; 28, 34; 28, 35; 29, 36; 29, 37; 30, 38; 30, 39; 31, 40; 33, 41; 33, 42; 36, 43; 3... | def invert_dict(dict_, unique_vals=True):
"""
Reverses the keys and values in a dictionary. Set unique_vals to False if
the values in the dict are not unique.
Args:
dict_ (dict_): dictionary
unique_vals (bool): if False, inverted keys are returned in a list.
Returns:
dict: ... |
0, module; 1, function_definition; 2, function_name:groupby_tags; 3, parameters; 4, block; 5, identifier:item_list; 6, identifier:tags_list; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, return_statement; 11, comment:r"""
case where an item can belong to multiple groups
Args:
... | 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; 13, 19; 13, 20; 14, 21; 14, 22; 15, 23; 18, 24; 18, 25; 22, 26; 22, 27; 23, 28; 23, 29; 23, 30; 25, 31; 30, 32; 32, 33; 33, 34; 33, 35; 34, 36; 34, 37; 35, 38; 36, 39; 36, 40 | def groupby_tags(item_list, tags_list):
r"""
case where an item can belong to multiple groups
Args:
item_list (list):
tags_list (list):
Returns:
dict: groupid_to_items
CommandLine:
python -m utool.util_dict --test-groupby_tags
Example:
>>> # ENABLE_DOC... |
0, module; 1, function_definition; 2, function_name:group_items; 3, parameters; 4, block; 5, identifier:items; 6, default_parameter; 7, default_parameter; 8, expression_statement; 9, if_statement; 10, comment:# Initialize a dict of lists; 11, expression_statement; 12, comment:# Insert each item into the correct group; ... | 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; 8, 19; 9, 20; 9, 21; 9, 22; 11, 23; 13, 24; 13, 25; 13, 26; 14, 27; 20, 28; 20, 29; 21, 30; 21, 31; 22, 32; 23, 33; 23, 34; 24, 35; 24, 36; 26, 37; 30, 38; 31, 39; 31, 40; 31, 41; 31, 42; 32, 43; 34, 44;... | def group_items(items, by=None, sorted_=True):
"""
Groups a list of items by group id.
Args:
items (list): a list of the values to be grouped.
if `by` is None, then each item is assumed to be a
(groupid, value) pair.
by (list): a corresponding list to group items by.... |
0, module; 1, function_definition; 2, function_name:hierarchical_map_vals; 3, parameters; 4, block; 5, identifier:func; 6, identifier:node; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, comment:#if not isinstance(node, dict):; 11, if_statement; 12, identifier:max_depth; 13, None; 14, identifi... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 7, 12; 7, 13; 8, 14; 8, 15; 9, 16; 11, 17; 11, 18; 11, 19; 11, 20; 17, 21; 18, 22; 19, 23; 19, 24; 19, 25; 20, 26; 20, 27; 20, 28; 20, 29; 21, 30; 21, 31; 22, 32; 23, 33; 23, 34; 25, 35; 25, 36; 29, 37; 29, 38; 31, 39; 31, 40; 32, 41; 32, 42; 33, 43; 3... | def hierarchical_map_vals(func, node, max_depth=None, depth=0):
"""
node is a dict tree like structure with leaves of type list
TODO: move to util_dict
CommandLine:
python -m utool.util_dict --exec-hierarchical_map_vals
Example:
>>> # ENABLE_DOCTEST
>>> from utool.util_dic... |
0, module; 1, function_definition; 2, function_name:sort_dict; 3, parameters; 4, block; 5, identifier:dict_; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, if_statement; 11, if_statement; 12, expression_statement; 13, expression_statement; 14, return_statement; 15, identi... | 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; 6, 15; 6, 16; 7, 17; 7, 18; 8, 19; 8, 20; 9, 21; 10, 22; 10, 23; 10, 24; 10, 25; 11, 26; 11, 27; 11, 28; 12, 29; 13, 30; 14, 31; 16, 32; 22, 33; 22, 34; 23, 35; 24, 36; 24, 37; 25, 38; 26, 39; 26, 40; 27, 41; 28, 42; 29, 43; 29, 44... | def sort_dict(dict_, part='keys', key=None, reverse=False):
"""
sorts a dictionary by its values or its keys
Args:
dict_ (dict_): a dictionary
part (str): specifies to sort by keys or values
key (Optional[func]): a function that takes specified part
and returns a sortab... |
0, module; 1, function_definition; 2, function_name:order_dict_by; 3, parameters; 4, block; 5, identifier:dict_; 6, identifier:key_order; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, return_statement; 13, comment:r"""
Reorders ite... | 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; 20, 27; 20, 28; 22, 29; 22, 30; 24, 31; 24, 32; 26, 33; 26, 34; 28, 35; 30, 36; 30, 37; 31, 38; 31, 39; 32, 40; 32, 41; 34, 42; 34, 43; ... | def order_dict_by(dict_, key_order):
r"""
Reorders items in a dictionary according to a custom key order
Args:
dict_ (dict_): a dictionary
key_order (list): custom key order
Returns:
OrderedDict: sorted_dict
CommandLine:
python -m utool.util_dict --exec-order_dict... |
0, module; 1, function_definition; 2, function_name:iteritems_sorted; 3, parameters; 4, block; 5, identifier:dict_; 6, expression_statement; 7, if_statement; 8, comment:""" change to iteritems ordered """; 9, call; 10, block; 11, else_clause; 12, identifier:isinstance; 13, argument_list; 14, return_statement; 15, block... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 6, 8; 7, 9; 7, 10; 7, 11; 9, 12; 9, 13; 10, 14; 11, 15; 13, 16; 13, 17; 14, 18; 15, 19; 18, 20; 18, 21; 19, 22; 20, 23; 20, 24; 21, 25; 22, 26; 22, 27; 27, 28; 28, 29; 28, 30; 30, 31; 31, 32; 31, 33; 32, 34; 32, 35; 33, 36 | def iteritems_sorted(dict_):
""" change to iteritems ordered """
if isinstance(dict_, OrderedDict):
return six.iteritems(dict_)
else:
return iter(sorted(six.iteritems(dict_))) |
0, module; 1, function_definition; 2, function_name:clean_line_profile_text; 3, parameters; 4, block; 5, identifier:text; 6, expression_statement; 7, comment:#; 8, expression_statement; 9, comment:#profile_block_list = fix_rawprofile_blocks(profile_block_list); 10, comment:#---; 11, comment:# FIXME can be written much ... | 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; 6, 24; 8, 25; 12, 26; 14, 27; 15, 28; 16, 29; 16, 30; 16, 31; 18, 32; 21, 33; 22, 34; 23, 35; 25, 36; 25, 37; 26, 38; 26, 39; 27, 40; 27, 41; 28, 42; 28, 43; 29, 44; 29... | def clean_line_profile_text(text):
"""
Sorts the output from line profile by execution time
Removes entries which were not run
"""
#
profile_block_list = parse_rawprofile_blocks(text)
#profile_block_list = fix_rawprofile_blocks(profile_block_list)
#---
# FIXME can be written much nic... |
0, module; 1, function_definition; 2, function_name:list_str; 3, parameters; 4, block; 5, identifier:list_; 6, dictionary_splat_pattern; 7, expression_statement; 8, import_statement; 9, expression_statement; 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; 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; 6, 31; 7, 32; 8, 33; 9, 34; 10, 35; 11, 36; 12, 37; 13, 38; 14, 39; 15, 40; 16, 41; 18, 42; 19, 43; 20, 44; 21, 45; 22,... | def list_str(list_, **listkw):
r"""
Makes a pretty list string
Args:
list_ (list): input list
**listkw: nl, newlines, packed, truncate, nobr, nobraces, itemsep,
trailing_sep, truncatekw, strvals, recursive,
indent_, precision, use_numpy, with_dtype, force... |
0, module; 1, function_definition; 2, function_name:generate_psms_quanted; 3, parameters; 4, block; 5, identifier:quantdb; 6, identifier:tsvfn; 7, identifier:isob_header; 8, identifier:oldheader; 9, default_parameter; 10, default_parameter; 11, expression_statement; 12, expression_statement; 13, expression_statement; 1... | 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; 9, 15; 9, 16; 10, 17; 10, 18; 11, 19; 12, 20; 13, 21; 14, 22; 14, 23; 14, 24; 20, 25; 20, 26; 21, 27; 21, 28; 22, 29; 22, 30; 23, 31; 23, 32; 24, 33; 24, 34; 24, 35; 24, 36; 25, 37; 25, 38; 26, 39; 26, 40; 28, 41; 28, 42; 32, 43; 3... | def generate_psms_quanted(quantdb, tsvfn, isob_header, oldheader,
isobaric=False, precursor=False):
"""Takes dbfn and connects, gets quants for each line in tsvfn, sorts
them in line by using keys in quantheader list."""
allquants, sqlfields = quantdb.select_all_psm_quants(isobaric... |
0, module; 1, function_definition; 2, function_name:nx_dag_node_rank; 3, parameters; 4, block; 5, identifier:graph; 6, default_parameter; 7, expression_statement; 8, import_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, if_statement; 13, identifier:nodes; 14, None; 15, comme... | 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; 12, 20; 12, 21; 12, 22; 16, 23; 16, 24; 17, 25; 17, 26; 18, 27; 18, 28; 19, 29; 19, 30; 20, 31; 20, 32; 21, 33; 22, 34; 23, 35; 26, 36; 26, 37; 28, 38; 28, 39; 30, 40; 30, 41; 33, 42; 34, 43; 34... | def nx_dag_node_rank(graph, nodes=None):
"""
Returns rank of nodes that define the "level" each node is on in a
topological sort. This is the same as the Graphviz dot rank.
Ignore:
simple_graph = ut.simplify_graph(exi_graph)
adj_dict = ut.nx_to_adj_dict(simple_graph)
import plot... |
0, module; 1, function_definition; 2, function_name:simplify_graph; 3, parameters; 4, block; 5, identifier:graph; 6, expression_statement; 7, import_statement; 8, expression_statement; 9, expression_statement; 10, if_statement; 11, expression_statement; 12, if_statement; 13, expression_statement; 14, expression_stateme... | 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; 11, 25; 12, 26; 12, 27; 12, 28; 13, 29; 14, 30; 15, 31; 16, 32; 17, 33; 19, 34; 19, 35; 20, 36; 20, 37; 21, 38; 21, 39; 22, 40; 22, 41; 23, 42; 24, 43; 25, 44... | def simplify_graph(graph):
"""
strips out everything but connectivity
Args:
graph (nx.Graph):
Returns:
nx.Graph: new_graph
CommandLine:
python3 -m utool.util_graph simplify_graph --show
python2 -m utool.util_graph simplify_graph --show
python2 -c "import n... |
0, module; 1, function_definition; 2, function_name:get_uniprot_evidence_level; 3, parameters; 4, block; 5, identifier:header; 6, expression_statement; 7, expression_statement; 8, for_statement; 9, return_statement; 10, comment:"""Returns uniprot protein existence evidence level for a fasta header.
Evidence levels ... | 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; 14, 19; 15, 20; 17, 21; 17, 22; 18, 23; 19, 24; 19, 25; 21, 26; 21, 27; 23, 28; 23, 29; 24, 30; 25, 31; 25, 32; 29, 33; 29, 34; 30, 35; 30, 36; 32, 37; 33, 38; 33, 39; 34, 40; 35, 41; 35, 42; 36, 43; ... | def get_uniprot_evidence_level(header):
"""Returns uniprot protein existence evidence level for a fasta header.
Evidence levels are 1-5, but we return 5 - x since sorting still demands
that higher is better."""
header = header.split()
for item in header:
item = item.split('=')
try:
... |
0, module; 1, function_definition; 2, function_name:sorted; 3, parameters; 4, block; 5, identifier:self; 6, identifier:by; 7, dictionary_splat_pattern; 8, expression_statement; 9, expression_statement; 10, return_statement; 11, identifier:kwargs; 12, comment:"""Sort array by a column.
Parameters
======... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 7, 11; 8, 12; 9, 13; 10, 14; 13, 15; 13, 16; 14, 17; 14, 18; 16, 19; 16, 20; 17, 21; 17, 22; 18, 23; 18, 24; 18, 25; 18, 26; 19, 27; 19, 28; 20, 29; 20, 30; 23, 31; 23, 32; 24, 33; 24, 34; 25, 35; 25, 36; 26, 37; 26, 38; 29, 39; 29, 40; 30, 41; 34, 42; 34, 43... | def sorted(self, by, **kwargs):
"""Sort array by a column.
Parameters
==========
by: str
Name of the columns to sort by(e.g. 'time').
"""
sort_idc = np.argsort(self[by], **kwargs)
return self.__class__(
self[sort_idc],
h5loc=se... |
0, module; 1, function_definition; 2, function_name:pmt_angles; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, if_statement; 8, return_statement; 9, comment:"""A list of PMT directions sorted by PMT channel, on DU-1, floor-1"""; 10, comparison_operator:self._pmt_angles == []; 11, block; 12, at... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 6, 9; 7, 10; 7, 11; 8, 12; 10, 13; 10, 14; 11, 15; 11, 16; 12, 17; 12, 18; 13, 19; 13, 20; 15, 21; 16, 22; 21, 23; 21, 24; 22, 25; 22, 26; 24, 27; 24, 28; 25, 29; 25, 30; 26, 31; 26, 32; 27, 33; 28, 34; 31, 35; 31, 36; 33, 37; 33, 38; 34, 39; 34, 40; 35, 41; 35, 42; 37, 4... | def pmt_angles(self):
"""A list of PMT directions sorted by PMT channel, on DU-1, floor-1"""
if self._pmt_angles == []:
mask = (self.pmts.du == 1) & (self.pmts.floor == 1)
self._pmt_angles = self.pmts.dir[mask]
return self._pmt_angles |
0, module; 1, function_definition; 2, function_name:_get_point; 3, parameters; 4, block; 5, identifier:self; 6, identifier:profile; 7, identifier:point; 8, expression_statement; 9, expression_statement; 10, try_statement; 11, comment:"""
Finds the given point in the profile, or adds it in sorted z order.
... | 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; 12, 15; 12, 16; 13, 17; 13, 18; 14, 19; 14, 20; 16, 21; 16, 22; 17, 23; 18, 24; 20, 25; 20, 26; 20, 27; 20, 28; 20, 29; 20, 30; 21, 31; 21, 32; 22, 33; 22, 34; 23, 35; 23, 36; 24, 37; 24, 38; 25, 39; 26, 40; 27, 41; 28, 42; 29, 4... | def _get_point(self, profile, point):
"""
Finds the given point in the profile, or adds it in sorted z order.
"""
cur_points_z = [p.location.z for p in profile.elements]
try:
cur_idx = cur_points_z.index(point.z)
return profile.elements[cur_idx]
ex... |
0, module; 1, function_definition; 2, function_name:metadata_sorter; 3, parameters; 4, block; 5, identifier:x; 6, identifier:y; 7, expression_statement; 8, if_statement; 9, if_statement; 10, comment:""" Sort metadata keys by priority.
"""; 11, comparison_operator:x == y; 12, block; 13, boolean_operator; 14, block; ... | 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; 9, 14; 9, 15; 9, 16; 9, 17; 11, 18; 11, 19; 12, 20; 13, 21; 13, 22; 14, 23; 15, 24; 15, 25; 16, 26; 16, 27; 17, 28; 20, 29; 21, 30; 21, 31; 22, 32; 22, 33; 23, 34; 24, 35; 24, 36; 25, 37; 26, 38; 26, 39; 27, 40; 28, 41; 34, 42; 34, 43; 34... | def metadata_sorter(x, y):
""" Sort metadata keys by priority.
"""
if x == y:
return 0
if x in METADATA_SORTER_FIRST and y in METADATA_SORTER_FIRST:
return -1 if METADATA_SORTER_FIRST.index(x) < METADATA_SORTER_FIRST.index(y) else 1
elif x in METADATA_SORTER_FIRST:
return -1
... |
0, module; 1, function_definition; 2, function_name:setRepayments; 3, parameters; 4, block; 5, identifier:self; 6, list_splat_pattern; 7, dictionary_splat_pattern; 8, expression_statement; 9, function_definition; 10, try_statement; 11, expression_statement; 12, expression_statement; 13, return_statement; 14, identifier... | 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; 6, 14; 7, 15; 8, 16; 9, 17; 9, 18; 9, 19; 10, 20; 10, 21; 11, 22; 12, 23; 13, 24; 18, 25; 19, 26; 19, 27; 20, 28; 21, 29; 21, 30; 22, 31; 22, 32; 23, 33; 23, 34; 26, 35; 27, 36; 27, 37; 28, 38; 29, 39; 29, 40; 30, 41; 30, 42; 30, 43; 31, ... | def setRepayments(self, *args, **kwargs):
"""Adds the repayments for this loan to a 'repayments' field.
Repayments are MambuRepayment objects.
Repayments get sorted by due date.
Returns the number of requests done to Mambu.
.. todo:: since pagination logic was added, is not always tr... |
0, module; 1, function_definition; 2, function_name:setTransactions; 3, parameters; 4, block; 5, identifier:self; 6, list_splat_pattern; 7, dictionary_splat_pattern; 8, expression_statement; 9, function_definition; 10, try_statement; 11, expression_statement; 12, expression_statement; 13, return_statement; 14, identifi... | 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; 6, 14; 7, 15; 8, 16; 9, 17; 9, 18; 9, 19; 10, 20; 10, 21; 11, 22; 12, 23; 13, 24; 18, 25; 19, 26; 19, 27; 20, 28; 21, 29; 21, 30; 22, 31; 22, 32; 23, 33; 23, 34; 26, 35; 27, 36; 27, 37; 28, 38; 29, 39; 29, 40; 30, 41; 30, 42; 30, 43; 31, ... | def setTransactions(self, *args, **kwargs):
"""Adds the transactions for this loan to a 'transactions' field.
Transactions are MambuTransaction objects.
Transactions get sorted by transaction id.
Returns the number of requests done to Mambu.
.. todo:: since pagination logic was added... |
0, module; 1, function_definition; 2, function_name:setActivities; 3, parameters; 4, block; 5, identifier:self; 6, list_splat_pattern; 7, dictionary_splat_pattern; 8, expression_statement; 9, function_definition; 10, try_statement; 11, expression_statement; 12, expression_statement; 13, return_statement; 14, identifier... | 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; 6, 14; 7, 15; 8, 16; 9, 17; 9, 18; 9, 19; 10, 20; 10, 21; 11, 22; 12, 23; 13, 24; 18, 25; 19, 26; 19, 27; 20, 28; 21, 29; 21, 30; 22, 31; 22, 32; 23, 33; 23, 34; 26, 35; 27, 36; 27, 37; 28, 38; 29, 39; 29, 40; 30, 41; 30, 42; 30, 43; 31, ... | def setActivities(self, *args, **kwargs):
"""Adds the activities for this group to a 'activities' field.
Activities are MambuActivity objects.
Activities get sorted by activity timestamp.
Returns the number of requests done to Mambu.
"""
def activityDate(activity):
... |
0, module; 1, function_definition; 2, function_name:compactor; 3, parameters; 4, block; 5, identifier:conf; 6, expression_statement; 7, comment:# Get the database handle; 8, expression_statement; 9, comment:# Get the limits container; 10, expression_statement; 11, comment:# Get the compactor configuration; 12, expressi... | 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; 6, 20; 8, 21; 10, 22; 12, 23; 14, 24; 14, 25; 14, 26; 14, 27; 16, 28; 17, 29; 19, 30; 19, 31; 19, 32; 21, 33; 21, 34; 22, 35; 22, 36; 23, 37; 23, 38; 24, 39; 24, 40; 27, 41; 28, 42; 28, 43; 29, 44... | def compactor(conf):
"""
The compactor daemon. This fuction watches the sorted set
containing bucket keys that need to be compacted, performing the
necessary compaction.
:param conf: A turnstile.config.Config instance containing the
configuration for the compactor daemon. Note th... |
0, module; 1, function_definition; 2, function_name:get; 3, parameters; 4, block; 5, identifier:self; 6, identifier:now; 7, expression_statement; 8, with_statement; 9, comment:"""
Get a bucket key to compact. If none are available, returns
None. This uses a configured lock to ensure that the bucket
... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 7, 9; 8, 10; 8, 11; 10, 12; 11, 13; 11, 14; 11, 15; 11, 16; 11, 17; 11, 18; 11, 19; 12, 20; 13, 21; 15, 22; 15, 23; 17, 24; 18, 25; 19, 26; 20, 27; 20, 28; 21, 29; 21, 30; 22, 31; 23, 32; 24, 33; 24, 34; 25, 35; 25, 36; 30, 37; 30, 38; 32, 39; 34, 40; 34, 41; 35, 42; 35, ... | def get(self, now):
"""
Get a bucket key to compact. If none are available, returns
None. This uses a configured lock to ensure that the bucket
key is popped off the sorted set in an atomic fashion.
:param now: The current time, as a float. Used to ensure the
... |
0, module; 1, function_definition; 2, function_name:get; 3, parameters; 4, block; 5, identifier:self; 6, identifier:now; 7, expression_statement; 8, expression_statement; 9, return_statement; 10, comment:"""
Get a bucket key to compact. If none are available, returns
None. This uses a Lua script to en... | 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; 12, 17; 14, 18; 14, 19; 15, 20; 15, 21; 18, 22; 18, 23; 19, 24; 19, 25; 24, 26; 24, 27; 25, 28; 25, 29; 27, 30; 29, 31; 30, 32; 30, 33; 31, 34; 31, 35; 35, 36; 35, 37 | def get(self, now):
"""
Get a bucket key to compact. If none are available, returns
None. This uses a Lua script to ensure that the bucket key is
popped off the sorted set in an atomic fashion.
:param now: The current time, as a float. Used to ensure the
b... |
0, module; 1, function_definition; 2, function_name:create; 3, parameters; 4, block; 5, identifier:self; 6, identifier:query; 7, keyword_separator; 8, default_parameter; 9, expression_statement; 10, if_statement; 11, expression_statement; 12, return_statement; 13, identifier:dc; 14, None; 15, comment:"""Creates a new p... | 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; 10, 16; 10, 17; 10, 18; 11, 19; 12, 20; 16, 21; 16, 22; 18, 23; 19, 24; 19, 25; 20, 26; 20, 27; 23, 28; 25, 29; 28, 30; 28, 31; 29, 32; 29, 33; 30, 34; 30, 35; 31, 36; 31, 37; 32, 38; 32, 39; 33, 40; 33, 41; 33, 42; 37, 43; ... | async def create(self, query, *, dc=None):
"""Creates a new prepared query
Parameters:
Query (Object): Query definition
dc (str): Specify datacenter that will be used.
Defaults to the agent's local datacenter.
Returns:
Object: New query ... |
0, module; 1, function_definition; 2, function_name:execute; 3, parameters; 4, block; 5, identifier:self; 6, identifier:query; 7, keyword_separator; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 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; 3, 10; 3, 11; 4, 12; 4, 13; 4, 14; 4, 15; 8, 16; 8, 17; 9, 18; 9, 19; 10, 20; 10, 21; 11, 22; 11, 23; 12, 24; 13, 25; 14, 26; 15, 27; 25, 28; 25, 29; 26, 30; 26, 31; 27, 32; 27, 33; 29, 34; 29, 35; 31, 36; 35, 37; 35, 38; 36, 39; 36, 40; 38, 41; 38, 42; 39, 43; 39, ... | async def execute(self, query, *,
dc=None, near=None, limit=None, consistency=None):
"""Executes a prepared query
Parameters:
query (ObjectID): Query ID
dc (str): Specify datacenter that will be used.
Defaults to the agent's local data... |
0, module; 1, function_definition; 2, function_name:headerSortAscending; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, comment:"""
Sorts the column at the current header index by ascending order.
"""; 10, call; 11, call; 12, ... | 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; 12, 16; 12, 17; 13, 18; 14, 19; 14, 20; 15, 21; 15, 22; 21, 23; 21, 24; 22, 25; 22, 26; 25, 27; 25, 28 | def headerSortAscending( self ):
"""
Sorts the column at the current header index by ascending order.
"""
self.setSortingEnabled(True)
self.sortByColumn(self._headerIndex, QtCore.Qt.AscendingOrder) |
0, module; 1, function_definition; 2, function_name:headerSortDescending; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, comment:"""
Sorts the column at the current header index by descending order.
"""; 10, call; 11, call; 12... | 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; 12, 16; 12, 17; 13, 18; 14, 19; 14, 20; 15, 21; 15, 22; 21, 23; 21, 24; 22, 25; 22, 26; 25, 27; 25, 28 | def headerSortDescending( self ):
"""
Sorts the column at the current header index by descending order.
"""
self.setSortingEnabled(True)
self.sortByColumn(self._headerIndex, QtCore.Qt.DescendingOrder) |
0, module; 1, function_definition; 2, function_name:nodes; 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, expression_statement; 14, return_statement; 15, i... | 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; 7, 15; 7, 16; 8, 17; 8, 18; 9, 19; 9, 20; 10, 21; 10, 22; 11, 23; 12, 24; 13, 25; 14, 26; 24, 27; 24, 28; 25, 29; 25, 30; 26, 31; 26, 32; 28, 33; 28, 34; 30, 35; 32, 36; 33, 37; 33, 38; 34, 39; 34, 40; 35, 41; 35, 42; 41, 43; 41, 4... | async def nodes(self, *,
dc=None, near=None, watch=None, consistency=None):
"""Lists nodes in a given DC
Parameters:
dc (str): Specify datacenter that will be used.
Defaults to the agent's local datacenter.
near (str): Sort the node list... |
0, module; 1, function_definition; 2, function_name:checks; 3, parameters; 4, block; 5, identifier:self; 6, identifier:service; 7, keyword_separator; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 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; 3, 10; 3, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 8, 17; 8, 18; 9, 19; 9, 20; 10, 21; 10, 22; 11, 23; 11, 24; 12, 25; 13, 26; 14, 27; 15, 28; 16, 29; 26, 30; 26, 31; 27, 32; 27, 33; 28, 34; 28, 35; 29, 36; 29, 37; 31, 38; 31, 39; 33, 40; 33, 41; 35, 42; 37, 43; 39, 4... | async def checks(self, service, *,
dc=None, near=None, watch=None, consistency=None):
"""Returns the checks of a service
Parameters:
dc (str): Specify datacenter that will be used.
Defaults to the agent's local datacenter.
near (str): W... |
0, module; 1, function_definition; 2, function_name:_get_alphabetical_members; 3, parameters; 4, block; 5, identifier:obj; 6, identifier:predicate; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, return_statement; 12, comment:"""Get members of an object, sorted a... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 7, 12; 8, 13; 9, 14; 10, 15; 11, 16; 13, 17; 13, 18; 14, 19; 14, 20; 15, 21; 15, 22; 16, 23; 16, 24; 18, 25; 18, 26; 20, 27; 20, 28; 21, 29; 21, 30; 23, 31; 23, 32; 24, 33; 24, 34; 26, 35; 28, 36; 32, 37; 32, 38; 35, 39; 35, 40; 36, 41; 36, 42; 39, 43;... | def _get_alphabetical_members(obj, predicate):
"""Get members of an object, sorted alphabetically.
Parameters
----------
obj
An object.
predicate : callable
Callable that takes an attribute and returns a bool of whether the
attribute should be returned or not.
Returns
... |
0, module; 1, function_definition; 2, function_name:_argsort; 3, parameters; 4, block; 5, identifier:y_score; 6, default_parameter; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, if_statement; 11, return_statement; 12, identifier:k; 13, None; 14, comment:"""
Returns the indexes in de... | 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; 11, 19; 15, 20; 15, 21; 16, 22; 16, 23; 17, 24; 17, 25; 18, 26; 21, 27; 21, 28; 23, 29; 23, 30; 26, 31; 27, 32; 27, 33; 30, 34; 31, 35; 31, 36; 34, 37; 36, 38; 36, 39; 39, 40; 39, 41 | def _argsort(y_score, k=None):
"""
Returns the indexes in descending order of the top k score
or all scores if k is None
"""
ranks = y_score.argsort()
argsort = ranks[::-1]
if k is not None:
argsort = argsort[0:k]
return argsort |
0, module; 1, function_definition; 2, function_name:assemble; 3, parameters; 4, comment:# type: (AbstractModule, *AbstractModule, **Any) -> SeqRecord; 5, block; 6, identifier:self; 7, identifier:module; 8, list_splat_pattern; 9, dictionary_splat_pattern; 10, expression_statement; 11, expression_statement; 12, return_st... | 0, 1; 1, 2; 1, 3; 1, 4; 1, 5; 3, 6; 3, 7; 3, 8; 3, 9; 5, 10; 5, 11; 5, 12; 8, 13; 9, 14; 10, 15; 11, 16; 12, 17; 16, 18; 16, 19; 17, 20; 17, 21; 19, 22; 19, 23; 20, 24; 20, 25; 23, 26; 23, 27; 23, 28; 23, 29; 26, 30; 26, 31; 27, 32; 27, 33; 28, 34; 28, 35; 29, 36; 29, 37; 33, 38; 33, 39; 35, 40; 35, 41; 37, 42; 37, 43;... | def assemble(self, module, *modules, **kwargs):
# type: (AbstractModule, *AbstractModule, **Any) -> SeqRecord
"""Assemble the provided modules into the vector.
Arguments:
module (`~moclo.base.modules.AbstractModule`): a module to insert
in the vector.
mod... |
0, module; 1, function_definition; 2, function_name:getPortSideView; 3, parameters; 4, type; 5, block; 6, identifier:self; 7, identifier:side; 8, generic_type; 9, expression_statement; 10, if_statement; 11, identifier:List; 12, type_parameter; 13, comment:"""
Returns a sublist view for all ports of given side.
... | 0, 1; 1, 2; 1, 3; 1, 4; 1, 5; 3, 6; 3, 7; 4, 8; 5, 9; 5, 10; 8, 11; 8, 12; 9, 13; 10, 14; 10, 15; 10, 16; 10, 17; 10, 18; 10, 19; 12, 20; 14, 21; 14, 22; 15, 23; 16, 24; 16, 25; 17, 26; 17, 27; 18, 28; 18, 29; 19, 30; 20, 31; 22, 32; 22, 33; 23, 34; 24, 35; 24, 36; 25, 37; 26, 38; 26, 39; 27, 40; 28, 41; 28, 42; 29, 43... | def getPortSideView(self, side) -> List["LPort"]:
"""
Returns a sublist view for all ports of given side.
:attention: Use this only after port sides are fixed!
This is currently the case after running the {@link org.eclipse.elk.alg.layered.intermediate.PortListSorter}.
Non-stru... |
0, module; 1, function_definition; 2, function_name:sort_untl; 3, parameters; 4, block; 5, identifier:self; 6, identifier:sort_structure; 7, expression_statement; 8, expression_statement; 9, comment:"""Sort the UNTL Python object by the index
of a sort structure pre-ordered list.
"""; 10, call; 11, attr... | 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; 13, 16; 13, 17; 15, 18; 15, 19; 19, 20; 19, 21; 20, 22; 21, 23; 21, 24; 23, 25; 23, 26; 24, 27; 27, 28; 27, 29 | def sort_untl(self, sort_structure):
"""Sort the UNTL Python object by the index
of a sort structure pre-ordered list.
"""
self.children.sort(key=lambda obj: sort_structure.index(obj.tag)) |
0, module; 1, function_definition; 2, function_name:top; 3, parameters; 4, block; 5, identifier:self; 6, identifier:sort_by; 7, expression_statement; 8, expression_statement; 9, return_statement; 10, comment:"""Get the best results according to your custom sort method."""; 11, assignment; 12, identifier:sort; 13, ident... | 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; 14, 15; 14, 16; 16, 17; 16, 18; 17, 19; 17, 20; 18, 21; 18, 22 | def top(self, sort_by):
"""Get the best results according to your custom sort method."""
sort = sorted(self.results, key=sort_by)
return sort |
0, module; 1, function_definition; 2, function_name:_read_elem_nodes; 3, parameters; 4, block; 5, identifier:self; 6, identifier:fid; 7, expression_statement; 8, expression_statement; 9, comment:# # prepare nodes; 10, comment:# nodes_sorted = np.zeros((number_of_nodes, 3), dtype=float); 11, comment:# nodes = np.z... | 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; 7, 29; 8, 30; 13, 31; 14, 32; 14, 33; 14, 34; 17, 35; 21, 36; 21, 37; 21, 38; 23, 39; 23, 40; 23, 41; 25, 42; 26, 43; 27, 44; 28, 45;... | def _read_elem_nodes(self, fid):
""" Read the nodes from an opened elem.dat file. Correct for CutMcK
transformations.
We store three typed of nodes in the dict 'nodes':
* "raw" : as read from the elem.dat file
* "presort" : pre-sorted so we can directly read node number... |
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, default_parameter; 10, default_parameter; 11, default_parameter; 12, default_parameter; 13, default_parameter; 14, default_parameter; 15, default_pa... | 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; 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; 6, 32; 6, 33; 7, 34; 7, 35; 8, 36; 8, 37; 9, 38; 9, 39; 10, 40; 10, 41; 11, 42; 11, 43; 12, 44; 12, 45; 13, 46; ... | def list(self, source_ids=None, seniority="all", stage=None,
date_start="1494539999", date_end=TIMESTAMP_NOW, filter_id=None,
page=1, limit=30, sort_by='ranking', filter_reference=None, order_by=None):
"""
Retreive all profiles that match the query param.
Args:
... |
0, module; 1, function_definition; 2, function_name:get_hypergeometric_stats; 3, parameters; 4, block; 5, identifier:N; 6, identifier:indices; 7, expression_statement; 8, assert_statement; 9, assert_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, ex... | 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; 7, 20; 8, 21; 9, 22; 10, 23; 11, 24; 12, 25; 13, 26; 14, 27; 15, 28; 16, 29; 17, 30; 18, 31; 18, 32; 19, 33; 21, 34; 21, 35; 22, 36; 22, 37; 22, 38; 23, 39; 23, 40; 24, 41; 24, 42; 25, 43; 25, 44;... | def get_hypergeometric_stats(N, indices):
"""Calculates hypergeom. p-values and fold enrichments for all cutoffs.
Parameters
----------
N: int
The length of the list
indices: `numpy.ndarray` with ``dtype=np.uint16``
The (sorted) indices of the "1's" in the list.
"""
assert ... |
0, module; 1, function_definition; 2, function_name:sort_dictionary_list; 3, parameters; 4, block; 5, identifier:dict_list; 6, identifier:sort_key; 7, expression_statement; 8, if_statement; 9, expression_statement; 10, return_statement; 11, comment:"""
sorts a list of dictionaries based on the value of the sort_key... | 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; 12, 16; 12, 17; 13, 18; 14, 19; 14, 20; 16, 21; 17, 22; 17, 23; 18, 24; 19, 25; 19, 26; 20, 27; 22, 28; 22, 29; 27, 30; 27, 31; 29, 32; 31, 33; 31, 34; 34, 35 | def sort_dictionary_list(dict_list, sort_key):
"""
sorts a list of dictionaries based on the value of the sort_key
dict_list - a list of dictionaries
sort_key - a string that identifies the key to sort the dictionaries with.
Test sorting a list of dictionaries:
>>> sort_dictionary_list([{... |
0, module; 1, function_definition; 2, function_name:render; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, return_statement; 11, comment:""" Render the menu into a sorted by order multi dict """; 12, assignment; 13, assignmen... | 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; 16, 27; 16, 28; 16, 29; 16, 30; 16, 31; 16, 32; 16, 33; 17, 34; 17, 35; 24, 36; 24, 37; 26, 38; 27, 39; 28, 40; 29, 41; 29, 42; 30, 43; 3... | def render(self):
""" Render the menu into a sorted by order multi dict """
menu_list = []
menu_index = 0
for _, menu in copy.deepcopy(self.MENU).items():
subnav = []
menu["kwargs"]["_id"] = str(menu_index)
menu["kwargs"]["active"] = False
... |
0, module; 1, function_definition; 2, function_name:vote_mean; 3, parameters; 4, block; 5, identifier:candidates; 6, identifier:votes; 7, identifier:n_winners; 8, expression_statement; 9, expression_statement; 10, for_statement; 11, for_statement; 12, expression_statement; 13, expression_statement; 14, 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; 8, 18; 9, 19; 10, 20; 10, 21; 10, 22; 11, 23; 11, 24; 11, 25; 12, 26; 13, 27; 14, 28; 15, 29; 16, 30; 16, 31; 16, 32; 17, 33; 19, 34; 19, 35; 22, 36; 25, 37; 26, 38; 26, 39; 27, 40; 27, 41; 28, 42; 28, 43; 29, ... | def vote_mean(candidates, votes, n_winners):
"""Perform mean voting based on votes.
Mean voting computes the mean preference for each of the artifact
candidates from the votes and sorts the candidates in the mean preference
order.
Ties are resolved randomly.
:param candidates: All candidates ... |
0, module; 1, function_definition; 2, function_name:vote; 3, parameters; 4, block; 5, identifier:self; 6, identifier:candidates; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, return_statement; 11, comment:"""Rank artifact candidates.
The voting is needed for the agents living i... | 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; 12, 15; 12, 16; 13, 17; 13, 18; 16, 19; 16, 20; 17, 21; 17, 22; 18, 23; 18, 24; 19, 25; 19, 26; 20, 27; 20, 28; 23, 29; 23, 30; 24, 31; 24, 32; 26, 33; 26, 34; 30, 35; 30, 36; 33, 37; 33, 38; 35, 39; 35, 40; 36, 41; 37, 42; 37, 43... | def vote(self, candidates):
"""Rank artifact candidates.
The voting is needed for the agents living in societies using
social decision making. The function should return a sorted list
of (candidate, evaluation)-tuples. Depending on the social choice
function used, the evaluation... |
0, module; 1, function_definition; 2, function_name:gather_votes; 3, parameters; 4, block; 5, identifier:self; 6, identifier:candidates; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, return_statement; 11, comment:"""Gather votes for the given candidates from the agents in the
environme... | 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; 14, 19; 14, 20; 15, 21; 15, 22; 19, 23; 19, 24; 20, 25; 21, 26; 22, 27; 25, 28; 25, 29; 26, 30; 26, 31; 27, 32; 27, 33; 31, 34; 31, 35; 32, 36; 32, 37; 33, 38; 34, 39; 34, 40; 35, 41 | def gather_votes(self, candidates):
"""Gather votes for the given candidates from the agents in the
environment.
Returned votes are anonymous, i.e. they cannot be tracked to any
individual agent afterwards.
:returns:
A list of votes. Each vote is a list of ``(artifa... |
0, module; 1, function_definition; 2, function_name:sort_by; 3, parameters; 4, block; 5, identifier:self; 6, identifier:fieldName; 7, default_parameter; 8, expression_statement; 9, return_statement; 10, identifier:reverse; 11, False; 12, string; 13, call; 14, string_content:sort_by - Return a copy of this collection, s... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 7, 10; 7, 11; 8, 12; 9, 13; 12, 14; 13, 15; 13, 16; 15, 17; 15, 18; 16, 19; 19, 20; 19, 21; 21, 22; 21, 23; 21, 24; 23, 25; 23, 26; 24, 27; 24, 28; 26, 29; 26, 30; 29, 31; 30, 32; 30, 33; 32, 34; 32, 35; 33, 36; 33, 37 | def sort_by(self, fieldName, reverse=False):
'''
sort_by - Return a copy of this collection, sorted by the given fieldName.
The fieldName is accessed the same way as other filtering, so it supports custom properties, etc.
@param fieldName <str> - The name of the field o... |
0, module; 1, function_definition; 2, function_name:sorted_items; 3, parameters; 4, block; 5, identifier:d; 6, default_parameter; 7, default_parameter; 8, expression_statement; 9, comment:# wrap the key func so it operates on the first element of each item; 10, function_definition; 11, return_statement; 12, identifier:... | 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; 7, 15; 8, 16; 10, 17; 10, 18; 10, 19; 11, 20; 18, 21; 19, 22; 20, 23; 20, 24; 22, 25; 24, 26; 24, 27; 24, 28; 25, 29; 25, 30; 26, 31; 26, 32; 27, 33; 27, 34; 28, 35; 28, 36; 30, 37; 31, 38; 31, 39; 37, 40; 37, 41 | def sorted_items(d, key=__identity, reverse=False):
"""
Return the items of the dictionary sorted by the keys
>>> sample = dict(foo=20, bar=42, baz=10)
>>> tuple(sorted_items(sample))
(('bar', 42), ('baz', 10), ('foo', 20))
>>> reverse_string = lambda s: ''.join(reversed(s))
>>> tuple(sorted_items(sample, key=... |
0, module; 1, function_definition; 2, function_name:merge_range_pairs; 3, parameters; 4, block; 5, identifier:prs; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, while_statement; 13, return_statement; 14, string... | 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; 8, 16; 9, 17; 10, 18; 11, 19; 12, 20; 12, 21; 13, 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; 21, 36; 21, 37; 21, 38; 21, 39; 21, 40; 27, 41; 27, 42; 29, 43; 29... | def merge_range_pairs(prs):
'''Takes in a list of pairs specifying ranges and returns a sorted list of merged, sorted ranges.'''
new_prs = []
sprs = [sorted(p) for p in prs]
sprs = sorted(sprs)
merged = False
x = 0
while x < len(sprs):
newx = x + 1
new_pair = list(sprs[x])
... |
0, module; 1, function_definition; 2, function_name:fixed_point; 3, parameters; 4, block; 5, identifier:is_zero; 6, identifier:plus; 7, identifier:minus; 8, identifier:f; 9, identifier:x; 10, expression_statement; 11, decorated_definition; 12, return_statement; 13, comment:"""
Get the least fixed point when it can ... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, 10; 4, 11; 4, 12; 10, 13; 11, 14; 11, 15; 12, 16; 14, 17; 15, 18; 15, 19; 15, 20; 16, 21; 16, 22; 19, 23; 20, 24; 20, 25; 22, 26; 22, 27; 24, 28; 24, 29; 24, 30; 25, 31; 27, 32; 27, 33; 29, 34; 29, 35; 30, 36; 30, 37; 30, 38; 33, 39; 36, 40; 37, 41; 37, 42; 38, 4... | def fixed_point(is_zero, plus, minus, f, x):
"""
Get the least fixed point when it can be computed piecewise.
.. testsetup::
from proso.func import fixed_point
.. doctest::
>>> sorted(fixed_point(
... is_zero=lambda xs: len(xs) == 0,
... plus=lambda xs, ys: xs +... |
0, module; 1, function_definition; 2, function_name:connections_from_graph; 3, parameters; 4, block; 5, identifier:env; 6, identifier:G; 7, default_parameter; 8, expression_statement; 9, if_statement; 10, if_statement; 11, expression_statement; 12, if_statement; 13, comment:# Sort agent addresses to the order they were... | 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; 7, 18; 7, 19; 8, 20; 9, 21; 9, 22; 10, 23; 10, 24; 11, 25; 12, 26; 12, 27; 14, 28; 15, 29; 16, 30; 17, 31; 21, 32; 22, 33; 23, 34; 24, 35; 25, 36; 25, 37; 26, 38; 26, 39; 27, 40; 28, 41; 28, 42; 29, 43; 29, 44;... | def connections_from_graph(env, G, edge_data=False):
"""Create connections for agents in the given environment from the given
NetworkX graph structure.
:param env:
Environment where the agents live. The environment should be derived
from :class:`~creamas.core.environment.Environment`,
... |
0, module; 1, function_definition; 2, function_name:is_python_script; 3, parameters; 4, block; 5, identifier:filename; 6, expression_statement; 7, if_statement; 8, if_statement; 9, try_statement; 10, return_statement; 11, string; 12, call; 13, block; 14, not_operator; 15, block; 16, block; 17, except_clause; 18, False;... | 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; 11, 19; 12, 20; 12, 21; 13, 22; 14, 23; 15, 24; 16, 25; 17, 26; 17, 27; 20, 28; 20, 29; 21, 30; 22, 31; 23, 32; 23, 33; 24, 34; 25, 35; 25, 36; 27, 37; 28, 38; 28, 39; 30, 40; 32, 41; 32, 42; 33, 43; 35... | def is_python_script(filename):
'''Checks a file to see if it's a python script of some sort.
'''
if filename.lower().endswith('.py'):
return True
if not os.path.isfile(filename):
return False
try:
with open(filename, 'rb') as fp:
if fp.read(2) != b'#!':
... |
0, module; 1, function_definition; 2, function_name:_prepare_data; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, expression_statement; 11, for_statement; 12, comment:"""Prepare data before rendering
When plotting ve... | 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; 11, 19; 11, 20; 11, 21; 13, 22; 13, 23; 14, 24; 14, 25; 16, 26; 16, 27; 17, 28; 17, 29; 17, 30; 17, 31; 17, 32; 17, 33; 18, 34; 18, 35; 20, 36; 20, 37; 21, 38; 21, 39; 21, 40; 21, 41; 21, 42; 21, 43; 22... | def _prepare_data(self):
"""Prepare data before rendering
When plotting very large datasets, we don't want to include data points
which are outside the x-axis limits. LaTeX is very slow and consumes a
lot of memory otherwise. Limiting the data points is only (easily)
possible wh... |
0, module; 1, function_definition; 2, function_name:by_user; 3, parameters; 4, block; 5, identifier:config; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, comment:"""Display LDAP group membership sorted by user."""; 12, assignment; 13, c... | 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; 12, 16; 12, 17; 13, 18; 13, 19; 14, 20; 14, 21; 15, 22; 15, 23; 17, 24; 17, 25; 18, 26; 18, 27; 21, 28; 21, 29; 22, 30; 22, 31; 23, 32; 23, 33; 29, 34; 32, 35; 33, 36; 33, 37; 36, 38; 36, 39 | def by_user(config):
"""Display LDAP group membership sorted by user."""
client = Client()
client.prepare_connection()
audit_api = API(client)
CLI.parse_membership('Groups by User', audit_api.by_user()) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.