nodes
stringlengths
501
22.4k
edges
stringlengths
138
5.07k
code
stringlengths
108
19.3k
0, module; 1, function_definition; 2, function_name:get; 3, parameters; 4, block; 5, identifier:self; 6, identifier:slug; 7, expression_statement; 8, expression_statement; 9, comment:# check if is accessible from api; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement...
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; 10, 22; 11, 23; 12, 24; 13, 25; 14, 26; 15, 27; 16, 28; 17, 29; 18, 30; 19, 31; 21, 32; 21, 33; 22, 34; 22, 35; 23, 36; 23, 37; 24, 38; 24, 39; 25, 40; 25, 41; 26, 42; 26, 43; 27, 44...
def get(self, slug): """Get list of mappings. Url parameters: - from: filter "mappings from" - to: filter "mappings to" - page - per_page - match_type: s=substring, e=exact, sw=startswith - sortby: 'from' or 'to' """ ...
0, module; 1, function_definition; 2, function_name:pretty; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, for_statement; 9, return_statement; 10, string:"sort values and format output for viewing and comparing in test scenarios"; 11, assignment; 12, pattern_list; 13, ...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 6, 10; 7, 11; 8, 12; 8, 13; 8, 14; 9, 15; 11, 16; 11, 17; 12, 18; 12, 19; 13, 20; 13, 21; 14, 22; 17, 23; 17, 24; 21, 25; 22, 26; 22, 27; 22, 28; 22, 29; 22, 30; 22, 31; 25, 32; 25, 33; 26, 34; 26, 35; 27, 36; 28, 37; 28, 38; 29, 39; 29, 40; 30, 41; 30, 42; 31, 43; ...
def pretty(self): "sort values and format output for viewing and comparing in test scenarios" pretty_obj = OrderedDict() for key, value in sorted(iteritems(self.__dict__)): if value is None: pretty_obj[key] = None elif is_str_or_unicode(value): ...
0, module; 1, function_definition; 2, function_name:import_directory; 3, parameters; 4, type; 5, block; 6, typed_parameter; 7, typed_parameter; 8, default_parameter; 9, None; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15, for_stateme...
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; 5, 15; 6, 16; 6, 17; 7, 18; 7, 19; 8, 20; 8, 21; 10, 22; 11, 23; 12, 24; 13, 25; 14, 26; 15, 27; 15, 28; 15, 29; 17, 30; 19, 31; 22, 32; 23, 33; 23, 34; 24, 35; 24, 36; 25, 37; 25, 38; 26, 39; 26, 40; 28, 41; 28, 42; 29, 43; 33, 44...
def import_directory(module_basename: str, directory: str, sort_key = None) -> None: '''Load all python modules in directory and directory's children. Parameters ---------- :``module_basename``: module name prefix for loaded modules :``directory``: directory to load python modules from :...
0, module; 1, function_definition; 2, function_name:read; 3, parameters; 4, block; 5, identifier:self; 6, identifier:given_file; 7, expression_statement; 8, if_statement; 9, expression_statement; 10, expression_statement; 11, with_statement; 12, if_statement; 13, expression_statement; 14, return_statement; 15, comment:...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 7, 15; 8, 16; 8, 17; 9, 18; 10, 19; 11, 20; 11, 21; 12, 22; 12, 23; 13, 24; 14, 25; 16, 26; 16, 27; 17, 28; 18, 29; 18, 30; 19, 31; 19, 32; 20, 33; 21, 34; 22, 35; 22, 36; 23, 37; 24, 38; 24, 39; 26, 40; 26, 41; 27, 42; 27, 43; 28,...
def read(self, given_file): """ Read given_file to self.contents Will ignoring duplicate lines if self.unique is True Will sort self.contents after reading file if self.sorted is True """ if self.unique is not False and self.unique is not True: raise Attribute...
0, module; 1, function_definition; 2, function_name:force_clear_lock; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, return_statement; 8, string; 9, call; 10, string_content:Kick out whoever currently owns the namespace global lock. This is intended as purely a last-resort tool. If a...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 6, 8; 7, 9; 8, 10; 9, 11; 9, 12; 11, 13; 11, 14; 12, 15; 13, 16; 13, 17; 15, 18; 15, 19; 16, 20; 16, 21; 17, 22; 22, 23; 22, 24; 24, 25; 24, 26
def force_clear_lock(self): '''Kick out whoever currently owns the namespace global lock. This is intended as purely a last-resort tool. If another process has managed to get the global lock for a very long time, or if it requested the lock with a long expiration and then crash...
0, module; 1, function_definition; 2, function_name:prettyprint; 3, parameters; 4, block; 5, identifier:d; 6, expression_statement; 7, expression_statement; 8, comment:"""Print dicttree in Json-like format. keys are sorted """; 9, call; 10, identifier:print; 11, argument_list; 12, call; 13, attribute; 14, argum...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 6, 8; 7, 9; 9, 10; 9, 11; 11, 12; 12, 13; 12, 14; 13, 15; 13, 16; 14, 17; 14, 18; 14, 19; 14, 20; 18, 21; 18, 22; 19, 23; 19, 24; 20, 25; 20, 26; 26, 27; 26, 28
def prettyprint(d): """Print dicttree in Json-like format. keys are sorted """ print(json.dumps(d, sort_keys=True, indent=4, separators=("," , ": ")))
0, module; 1, function_definition; 2, function_name:_is_iterable; 3, parameters; 4, block; 5, identifier:val; 6, expression_statement; 7, try_statement; 8, comment:"""Ensure that a value is iterable and not some sort of string"""; 9, block; 10, except_clause; 11, else_clause; 12, expression_statement; 13, tuple; 14, bl...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 6, 8; 7, 9; 7, 10; 7, 11; 9, 12; 10, 13; 10, 14; 11, 15; 12, 16; 13, 17; 13, 18; 14, 19; 15, 20; 16, 21; 16, 22; 19, 23; 20, 24; 22, 25; 24, 26; 26, 27; 26, 28; 28, 29; 28, 30
def _is_iterable(val): """Ensure that a value is iterable and not some sort of string""" try: iter(val) except (ValueError, TypeError): return False else: return not isinstance(val, basestring)
0, module; 1, function_definition; 2, function_name:square_off; 3, parameters; 4, block; 5, identifier:series; 6, default_parameter; 7, default_parameter; 8, expression_statement; 9, if_statement; 10, return_statement; 11, identifier:time_delta; 12, None; 13, identifier:transition_seconds; 14, integer:1; 15, comment:""...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 6, 11; 6, 12; 7, 13; 7, 14; 8, 15; 9, 16; 9, 17; 9, 18; 9, 19; 10, 20; 18, 21; 18, 22; 19, 23; 20, 24; 20, 25; 21, 26; 21, 27; 22, 28; 23, 29; 23, 30; 23, 31; 23, 32; 24, 33; 24, 34; 26, 35; 26, 36; 27, 37; 28, 38; 28, 39; 29, 40; 30, 41; 31, 42; 32, 43; 33, ...
def square_off(series, time_delta=None, transition_seconds=1): """Insert samples in regularly sampled data to produce stairsteps from ramps when plotted. New samples are 1 second (1e9 ns) before each existing samples, to facilitate plotting and sorting >>> square_off(pd.Series(range(3), index=pd.date_rang...
0, module; 1, function_definition; 2, function_name:sortframe; 3, parameters; 4, block; 5, identifier:frame; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, return_statement; 12, string; 13, assignment; 14, assignment; 15, assignment; 16,...
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; 10, 16; 11, 17; 12, 18; 13, 19; 13, 20; 14, 21; 14, 22; 15, 23; 15, 24; 16, 25; 16, 26; 20, 27; 20, 28; 22, 29; 22, 30; 24, 31; 24, 32; 25, 33; 25, 34; 28, 35; 29, 36; 29, 37; 30, 38; 34, 39; 38, 40; 38, 41; 38, 42; 40, 43; ...
def sortframe(frame): ''' sorts particles for a frame ''' d = frame['data']; sortedargs = np.lexsort([d['xi'],d['yi'],d['zi']]) d = d[sortedargs]; frame['data']=d; return frame;
0, module; 1, function_definition; 2, function_name:get_release_id; 3, parameters; 4, block; 5, default_parameter; 6, expression_statement; 7, comment:# pylint: disable=invalid-name; 8, expression_statement; 9, if_statement; 10, return_statement; 11, identifier:version; 12, None; 13, comment:"""Get a unique, time-based...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 5, 11; 5, 12; 6, 13; 8, 14; 9, 15; 9, 16; 10, 17; 14, 18; 14, 19; 15, 20; 15, 21; 16, 22; 17, 23; 17, 24; 19, 25; 19, 26; 22, 27; 23, 28; 23, 29; 24, 30; 24, 31; 25, 32; 25, 33; 26, 34; 28, 35; 32, 36; 32, 37; 36, 38; 36, 39
def get_release_id(version=None): """Get a unique, time-based identifier for a deployment that optionally, also includes some sort of version number or release. If a version is supplied, the release ID will be of the form '$timestamp-$version'. For example: >>> get_release_id(version='1.4.1') ...
0, module; 1, function_definition; 2, function_name:group_objects_by; 3, parameters; 4, block; 5, identifier:self; 6, identifier:list; 7, identifier:attr; 8, default_parameter; 9, default_parameter; 10, expression_statement; 11, expression_statement; 12, for_statement; 13, return_statement; 14, identifier:valueLabel; 1...
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; 8, 14; 8, 15; 9, 16; 9, 17; 10, 18; 11, 19; 12, 20; 12, 21; 12, 22; 13, 23; 19, 24; 19, 25; 22, 26; 22, 27; 22, 28; 22, 29; 22, 30; 22, 31; 26, 32; 27, 33; 27, 34; 28, 35; 29, 36; 30, 37; 30, 38; 30, 39; 31, 40; 31, 41; 32, 42; 32, 43; 33...
def group_objects_by(self, list, attr, valueLabel="value", childrenLabel="children"): """ Generates a group object based on the attribute value on of the given attr value that is passed in. :param list list: A list of dictionary objects :param str attr: The attribute that the dictionari...
0, module; 1, function_definition; 2, function_name:sorts_query; 3, parameters; 4, block; 5, identifier:sortables; 6, expression_statement; 7, expression_statement; 8, for_statement; 9, return_statement; 10, comment:""" Turn the Sortables into a SQL ORDER BY query """; 11, assignment; 12, identifier:sortable; 13, ident...
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; 15, 19; 15, 20; 18, 21; 18, 22; 18, 23; 19, 24; 19, 25; 20, 26; 21, 27; 21, 28; 22, 29; 23, 30; 24, 31; 26, 32; 26, 33; 29, 34; 30, 35; 32, 36; 32, 37; 33, 38; 34, 39; 34, 40; 35, 41; 36, 42; 39, 43; ...
def sorts_query(sortables): """ Turn the Sortables into a SQL ORDER BY query """ stmts = [] for sortable in sortables: if sortable.desc: stmts.append('{} DESC'.format(sortable.field)) else: stmts.append('{} ASC'.format(sortable.field)) ...
0, module; 1, function_definition; 2, function_name:search; 3, parameters; 4, block; 5, identifier:self; 6, identifier:rtype; 7, dictionary_splat_pattern; 8, expression_statement; 9, expression_statement; 10, expression_statement; 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; 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; 7, 30; 8, 31; 9, 32; 10, 33; 11, 34; 12, 35; 13, 36; 14, 37; 15, 38; 16, 39; 17, 40; 17, 41; 18, 42; 19, 43; 19, 44; 19, 45; 2...
def search(self, rtype, **kwargs): """ Search for the model by assorted criteria Quite a bit needs to happen for a search processing! The breakdown is we need to apply the query parameters where applicable. These include pagination, sorting, & filtering. Additionally, ...
0, module; 1, function_definition; 2, function_name:force_seek; 3, parameters; 4, block; 5, identifier:fd; 6, identifier:offset; 7, default_parameter; 8, expression_statement; 9, try_statement; 10, identifier:chunk; 11, identifier:CHUNK; 12, comment:""" Force adjustment of read cursort to specified offset This fun...
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; 9, 14; 13, 15; 14, 16; 14, 17; 14, 18; 15, 19; 16, 20; 16, 21; 18, 22; 19, 23; 19, 24; 21, 25; 21, 26; 22, 27; 23, 28; 23, 29; 24, 30; 27, 31; 27, 32; 32, 33; 32, 34; 32, 35
def force_seek(fd, offset, chunk=CHUNK): """ Force adjustment of read cursort to specified offset This function takes a file descriptor ``fd`` and tries to seek to position specified by ``offset`` argument. If the descriptor does not support the ``seek()`` method, it will fall back to ``emulate_seek()`...
0, module; 1, function_definition; 2, function_name:append; 3, parameters; 4, block; 5, identifier:self; 6, identifier:hcont; 7, identifier:value; 8, default_parameter; 9, expression_statement; 10, assert_statement; 11, if_statement; 12, expression_statement; 13, identifier:score; 14, None; 15, comment:""" If sort_fiel...
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; 11, 17; 11, 18; 12, 19; 16, 20; 16, 21; 17, 22; 17, 23; 18, 24; 19, 25; 19, 26; 20, 27; 21, 28; 24, 29; 25, 30; 25, 31; 26, 32; 26, 33; 26, 34; 26, 35; 27, 36; 27, 37; 28, 38; 28, 39; 29, 40; 29, 41; 38, 42; 38, 43; ...
def append(self, hcont, value, score = None): """ If sort_field is specified, score must be None. If sort_field is not specified, score is mandatory. """ assert (score is None) != (self.field.sort_field is None) if score is None: score = getattr(value, self.field.sort_fie...
0, module; 1, function_definition; 2, function_name:raise_errors_on_nested_writes; 3, parameters; 4, block; 5, identifier:method_name; 6, identifier:serializer; 7, identifier:validated_data; 8, expression_statement; 9, comment:# Ensure we don't have a writable nested field. For example:; 10, comment:#; 11, comment:# cl...
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; 8, 21; 14, 22; 14, 23; 20, 24; 20, 25; 22, 26; 23, 27; 24, 28; 25, 29; 26, 30; 26, 31; 27, 32; 27, 33; 28, 34; 28, 35; 29, 36; 29, 37; 31, 38; 31, 39; 32, 40; 32, 41; 33, 42; 33, 43; 33, 44...
def raise_errors_on_nested_writes(method_name, serializer, validated_data): """ Give explicit errors when users attempt to pass writable nested data. If we don't do this explicitly they'd get a less helpful error when calling `.save()` on the serializer. We don't *automatically* support these sort...
0, module; 1, function_definition; 2, function_name:threenum; 3, parameters; 4, block; 5, identifier:h5file; 6, identifier:var; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, expression_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; 7, 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; 25, 41; 25, 42; 26, 43; 26, 44; 27...
def threenum(h5file, var, post_col='mult'): """ Calculates the three number summary for a variable. The three number summary is the minimum, maximum and the mean of the data. Traditionally one would summerise data with the five number summary: max, min, 1st, 2nd (median), 3rd quartile. But quantile...
0, module; 1, function_definition; 2, function_name:_filter_keys; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, function_definition; 11, return_statement; 12, identifier:content_id; 13, None; 14, identifier:prefix; 15, None; 1...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 6, 12; 6, 13; 7, 14; 7, 15; 8, 16; 8, 17; 9, 18; 10, 19; 10, 20; 10, 21; 11, 22; 18, 23; 20, 24; 21, 25; 21, 26; 21, 27; 21, 28; 21, 29; 21, 30; 21, 31; 21, 32; 21, 33; 21, 34; 21, 35; 21, 36; 21, 37; 21, 38; 21, 39; 25, 40; 28, 41; 29, 42; 29, 43; 29,...
def _filter_keys(self, content_id=None, prefix=None, subtopic_id=None): '''Filter out-of-order labels by key tuple. :class:`Label` always sorts by `(cid1,cid2,sid1,sid2)`, but for efficient lookups on `cid2` this class also stores in order `(cid2,cid1,sid2,sid1)`. Filter out things tha...
0, module; 1, function_definition; 2, function_name:topological_sorting; 3, parameters; 4, block; 5, identifier:nodes; 6, identifier:relations; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, while_statement; 14...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 7, 16; 8, 17; 9, 18; 10, 19; 11, 20; 12, 21; 13, 22; 13, 23; 14, 24; 14, 25; 15, 26; 16, 27; 17, 28; 17, 29; 18, 30; 18, 31; 19, 32; 19, 33; 20, 34; 20, 35; 21, 36; 21, 37; 23, 38; 23, 39; 23, 40; 23, 41; 24, 42; 25, 43; 31,...
def topological_sorting(nodes, relations): '''An implementation of Kahn's algorithm. ''' ret = [] nodes = set(nodes) | _nodes(relations) inc = _incoming(relations) out = _outgoing(relations) free = _free_nodes(nodes, inc) while free: n = free.pop() ret.append(n) ...
0, module; 1, function_definition; 2, function_name:solve_resource; 3, parameters; 4, block; 5, identifier:self; 6, identifier:value; 7, identifier:resource; 8, expression_statement; 9, for_statement; 10, raise_statement; 11, comment:"""Solve the given resource for the given value. The solving is done by the f...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 8, 11; 9, 12; 9, 13; 9, 14; 10, 15; 13, 16; 13, 17; 14, 18; 15, 19; 15, 20; 16, 21; 16, 22; 17, 23; 18, 24; 18, 25; 20, 26; 20, 27; 20, 28; 24, 29; 25, 30; 25, 31; 29, 32; 31, 33; 32, 34; 32, 35; 34, 36; 34, 37; 35, 38; 35, 39
def solve_resource(self, value, resource): """Solve the given resource for the given value. The solving is done by the first resource solver class that returns ``True`` when calling its ``can_solve`` method for the given resource, and that doesn't raise a ``CannotSolve`` exception. ...
0, module; 1, function_definition; 2, function_name:incrementName; 3, parameters; 4, block; 5, identifier:nameList; 6, identifier:name; 7, expression_statement; 8, if_statement; 9, expression_statement; 10, for_statement; 11, return_statement; 12, comment:""" return a name that is unique in a given nameList through...
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; 18, 28; 18, 29; 22, 30; 24, 31; 24, 32; 26, 33; 26, 34; 27, 35; 28, 36; 28, 37; 28, 38; 29, 39; 29, 40; 32, 41; 32, 42; 34, 43; ...
def incrementName(nameList, name): """ return a name that is unique in a given nameList through attaching a number to it >>> l = [] now we will add 3xfoo 2xbar and one klaus to our list: >>> l.append( incrementName(l,'foo') ) >>> l.append( incrementName(l,'bar') ) >>> l.append( increm...
0, module; 1, function_definition; 2, function_name:sort; 3, parameters; 4, block; 5, identifier:polylines; 6, expression_statement; 7, for_statement; 8, comment:""" sort points within polyline p0-p1-p2... """; 9, pattern_list; 10, call; 11, block; 12, identifier:n; 13, identifier:c; 14, identifier:enumerat...
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; 11, 17; 15, 18; 16, 19; 17, 20; 17, 21; 17, 22; 17, 23; 19, 24; 19, 25; 20, 26; 20, 27; 23, 28; 23, 29; 23, 30; 23, 31; 23, 32; 23, 33; 23, 34; 23, 35; 23, 36; 23, 37; 23, 38; 25, 39; 25, 40; 28, 41; 29, 42; 30, 43...
def sort(polylines): """ sort points within polyline p0-p1-p2... """ for n, c in enumerate(polylines): l = len(c) if l > 2: # DEFINE FIRST AND LAST INDEX A THOSE TWO POINTS THAT # HAVE THE BIGGEST DIFFERENCE FROM A MIDDLE: mid = c.mean(axis=0) ...
0, module; 1, function_definition; 2, function_name:get_queryset; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, return_statement; 11, comment:"""Query for the most voted messages sorting by the sum of voted an...
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; 21, 26; 21, 27; 22, 28; 22, 29; 23, 30; 23, 31; 24, 32; 24, 33; 26, 34; 26, 35; 27, 36; 30, 37; 31, 38; 32, 39; 32, 40; 36, 41; 36, 42; 40, 43;...
def get_queryset(self): """Query for the most voted messages sorting by the sum of voted and after by date.""" queryset = super(MostVotedManager, self).get_queryset() sql = """ SELECT count(sav.id) FROM colab_superarchives_vote AS...
0, module; 1, function_definition; 2, function_name:deleteByOrigIndex; 3, parameters; 4, block; 5, identifier:self; 6, identifier:index; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, for_statement; 11, expression_statement; 12, expression_statement; 13, return_statement; 14, comment:"""...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 7, 14; 8, 15; 9, 16; 10, 17; 10, 18; 10, 19; 11, 20; 12, 21; 13, 22; 15, 23; 15, 24; 16, 25; 16, 26; 17, 27; 17, 28; 18, 29; 18, 30; 19, 31; 20, 32; 20, 33; 21, 34; 21, 35; 30, 36; 31, 37; 31, 38; 32, 39; 32, 40; 34, 41; 34, 42; 36, 43; 3...
def deleteByOrigIndex(self, index): """Removes a single entry from the list given the index reference. The index, in this instance, is a reference to the *original* list indexing as seen when the list was first inserted into PLOD. An example: >>> test = [ ... {"name...
0, module; 1, function_definition; 2, function_name:deleteByOrigIndexList; 3, parameters; 4, block; 5, identifier:self; 6, identifier:indexList; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, for_statement; 12, expression_statement; 13, expression_statement; 14,...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 7, 15; 8, 16; 9, 17; 10, 18; 11, 19; 11, 20; 11, 21; 12, 22; 13, 23; 14, 24; 16, 25; 16, 26; 17, 27; 17, 28; 18, 29; 18, 30; 20, 31; 20, 32; 21, 33; 21, 34; 22, 35; 22, 36; 23, 37; 23, 38; 33, 39; 33, 40; 34, 41; 35, 42; 35, 43; 37...
def deleteByOrigIndexList(self, indexList): """Remove entries from the list given the index references. The index, in this instance, is a reference to the *original* list indexing as seen when the list was first inserted into PLOD. An example: >>> test = [ ... {"nam...
0, module; 1, function_definition; 2, function_name:sort; 3, parameters; 4, block; 5, identifier:self; 6, identifier:key; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, for_statement; 11, return_statement; 12, identifier:reverse; 13, False; 14, identifier:none_greater; 15, False; 16, string:''...
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; 10, 17; 10, 18; 10, 19; 11, 20; 18, 21; 18, 22; 19, 23; 19, 24; 19, 25; 22, 26; 22, 27; 23, 28; 24, 29; 24, 30; 24, 31; 25, 32; 25, 33; 27, 34; 27, 35; 28, 36; 28, 37; 30, 38; 30, 39; 31, 40; 32, 41; 32, 42; 33, 43; 3...
def sort(self, key, reverse=False, none_greater=False): '''Sort the list in the order of the dictionary key. Example of use: >>> test = [ ... {"name": "Jim", "age": 18, "income": 93000, "wigs": 68 }, ... {"name": "Larry", "age": 18, "wigs": [3, 2,...
0, module; 1, function_definition; 2, function_name:returnIndexList; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, expression_statement; 8, if_statement; 9, expression_statement; 10, for_statement; 11, return_statement; 12, identifier:limit; 13, False; 14, string:'''Return a list of integers tha...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 6, 12; 6, 13; 7, 14; 8, 15; 8, 16; 9, 17; 10, 18; 10, 19; 10, 20; 11, 21; 15, 22; 15, 23; 16, 24; 17, 25; 17, 26; 19, 27; 19, 28; 20, 29; 24, 30; 28, 31; 29, 32; 29, 33; 30, 34; 30, 35; 32, 36; 32, 37; 33, 38; 36, 39; 36, 40; 38, 41; 40, 42; 41, 43; 41...
def returnIndexList(self, limit=False): '''Return a list of integers that are list-index references to the original list of dictionaries." Example of use: >>> test = [ ... {"name": "Jim", "age": 18, "income": 93000, "order": 2}, ... {"name": "Larry", "age": 18, ...
0, module; 1, function_definition; 2, function_name:returnValue; 3, parameters; 4, block; 5, identifier:self; 6, identifier:key; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, if_statement; 11, expression_statement; 12, return_statement; 13, identifier:last; 14, False; 15, string:'''Return ...
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; 12, 20; 16, 21; 16, 22; 17, 23; 18, 24; 19, 25; 19, 26; 20, 27; 20, 28; 22, 29; 22, 30; 24, 31; 26, 32; 26, 33; 27, 34; 27, 35; 28, 36; 28, 37; 29, 38; 29, 39; 30, 40; 32, 41; 32, 42; 33, 43; 4...
def returnValue(self, key, last=False): '''Return the key's value for the first entry in the current list. If 'last=True', then the last entry is referenced." Returns None is the list is empty or the key is missing. Example of use: >>> test = [ ... {"name": "Jim", ...
0, module; 1, function_definition; 2, function_name:returnValueList; 3, parameters; 4, block; 5, identifier:self; 6, identifier:key_list; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, if_statement; 12, expression_statement; 13, for_statement; 14, return_statement;...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 7, 15; 7, 16; 8, 17; 9, 18; 10, 19; 11, 20; 11, 21; 12, 22; 13, 23; 13, 24; 13, 25; 14, 26; 18, 27; 18, 28; 19, 29; 19, 30; 20, 31; 21, 32; 22, 33; 22, 34; 25, 35; 30, 36; 30, 37; 32, 38; 34, 39; 34, 40; 35, 41; 36, 42; 36, 43; 37,...
def returnValueList(self, key_list, last=False): '''Return a list of key values for the first entry in the current list. If 'last=True', then the last entry is referenced." Returns None is the list is empty. If a key is missing, then that entry in the list is None. Example of u...
0, module; 1, function_definition; 2, function_name:sort_seq_records; 3, parameters; 4, block; 5, identifier:self; 6, identifier:seq_records; 7, expression_statement; 8, for_statement; 9, expression_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; 7, 18; 8, 19; 8, 20; 8, 21; 9, 22; 10, 23; 11, 24; 12, 25; 13, 26; 14, 27; 15, 28; 16, 29; 16, 30; 16, 31; 17, 32; 21, 33; 22, 34; 22, 35; 23, 36; 23, 37; 24, 38; 24, 39; 25, 40; 25, 41; 26, 42; 26, 43; 27, 44;...
def sort_seq_records(self, seq_records): """Checks that SeqExpandedRecords are sorted by gene_code and then by voucher code. The dashes in taxon names need to be converted to underscores so the dataset will be accepted by Biopython to do format conversions. """ for seq_record i...
0, module; 1, function_definition; 2, function_name:extractFromSQLFile; 3, parameters; 4, block; 5, identifier:self; 6, identifier:filePointer; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, comment:# reading file and splitting it into lines; 11, expression_statement; 12, expression_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; 4, 15; 4, 16; 4, 17; 4, 18; 7, 19; 7, 20; 8, 21; 9, 22; 11, 23; 12, 24; 13, 25; 13, 26; 13, 27; 15, 28; 16, 29; 17, 30; 17, 31; 17, 32; 17, 33; 18, 34; 22, 35; 22, 36; 23, 37; 23, 38; 24, 39; 24, 40; 27, 41; 27, 42; 28, 43; 28, 44;...
def extractFromSQLFile(self, filePointer, delimiter=";"): """ Process an SQL file and extract all the queries sorted. :param filePointer: <io.TextIOWrapper> file pointer to SQL file :return: <list> list of queries """ data = filePointer.read() # reading file and...
0, module; 1, function_definition; 2, function_name:sort_data; 3, parameters; 4, block; 5, identifier:self; 6, identifier:data; 7, identifier:sort_key; 8, default_parameter; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, for_statement; 13, return_statement; 14, identifier:reverse; 15, ...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 8, 14; 8, 15; 9, 16; 10, 17; 11, 18; 12, 19; 12, 20; 12, 21; 13, 22; 17, 23; 17, 24; 18, 25; 18, 26; 21, 27; 26, 28; 26, 29; 27, 30; 29, 31; 29, 32; 29, 33; 30, 34; 30, 35; 32, 36; 32, 37; 33, 38; 33, 39; 34, 40; 34, 41; 35, 42; 37, 43; 3...
async def sort_data(self, data, sort_key, reverse=False): """Sort dataset.""" sorted_data = [] lines = sorted(data, key=lambda k: k[sort_key], reverse=reverse) for line in lines: sorted_data.append(line) return sorted_data
0, module; 1, function_definition; 2, function_name:get_ceiling; 3, parameters; 4, type; 5, comment:# type: ignore; 6, block; 7, typed_parameter; 8, identifier:Cloud; 9, expression_statement; 10, for_statement; 11, return_statement; 12, identifier:clouds; 13, type; 14, comment:""" Returns ceiling layer from Cloud-L...
0, 1; 1, 2; 1, 3; 1, 4; 1, 5; 1, 6; 3, 7; 4, 8; 6, 9; 6, 10; 6, 11; 7, 12; 7, 13; 9, 14; 10, 15; 10, 16; 10, 17; 11, 18; 13, 19; 17, 20; 19, 21; 20, 22; 20, 23; 22, 24; 22, 25; 23, 26; 24, 27; 24, 28; 25, 29; 25, 30; 26, 31; 29, 32; 29, 33; 30, 34; 30, 35; 30, 36; 34, 37; 35, 38; 36, 39
def get_ceiling(clouds: [Cloud]) -> Cloud: # type: ignore """ Returns ceiling layer from Cloud-List or None if none found Assumes that the clouds are already sorted lowest to highest Only 'Broken', 'Overcast', and 'Vertical Visibility' are considdered ceilings Prevents errors due to lack of clou...
0, module; 1, function_definition; 2, function_name:_finish_filter; 3, parameters; 4, block; 5, identifier:self; 6, identifier:lst; 7, identifier:key; 8, identifier:include_self; 9, identifier:exclusive; 10, identifier:biggest_first; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, if_s...
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; 11, 22; 12, 23; 13, 24; 14, 25; 14, 26; 15, 27; 16, 28; 18, 29; 18, 30; 18, 31; 20, 32; 20, 33; 21, 34; 23, 35; 23, 36; 24, 37; 24, 38; 25, 39; 25, 40; 26, 41; 27, 42; 27, 43; 28, 44...
def _finish_filter(self, lst, key, include_self, exclusive, biggest_first): """Finish filtering a GIS operation. Can optionally exclude the input key, sort results, and exclude overlapping results. Internal function, not normally called directly.""" key = self._actual_key(key) locations = [x[0] ...
0, module; 1, function_definition; 2, function_name:intersects; 3, parameters; 4, block; 5, identifier:self; 6, identifier:key; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, expression_statement; 12, expression_statement; 13, if_statement; 14, expression_statement; 15, exp...
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; 7, 17; 7, 18; 8, 19; 8, 20; 9, 21; 9, 22; 10, 23; 10, 24; 11, 25; 12, 26; 13, 27; 13, 28; 14, 29; 15, 30; 16, 31; 26, 32; 26, 33; 27, 34; 27, 35; 28, 36; 29, 37; 29, 38; 30, 39; 30, 40; 31, 41; 31, 42; 33, 43; 33, 44;...
def intersects(self, key, include_self=False, exclusive=False, biggest_first=True, only=None): """Get all locations that intersect this location. Note that sorting is done by first by number of faces intersecting ``key``; the total number of faces in the intersected region is only used to break sorting...
0, module; 1, function_definition; 2, function_name:group_by_key_func; 3, parameters; 4, block; 5, identifier:iterable; 6, identifier:key_func; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, return_statement; 11, comment:""" Create a dictionary from an iterable such that the keys are the re...
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; 18, 20; 18, 21; 19, 22; 21, 23; 22, 24; 22, 25; 24, 26; 24, 27; 25, 28; 26, 29; 26, 30; 30, 31; 30, 32; 32, 33
def group_by_key_func(iterable, key_func): """ Create a dictionary from an iterable such that the keys are the result of evaluating a key function on elements of the iterable and the values are lists of elements all of which correspond to the key. >>> def si(d): return sorted(d.items()) >>> si(grou...
0, module; 1, function_definition; 2, function_name:sort; 3, parameters; 4, block; 5, identifier:line; 6, expression_statement; 7, expression_statement; 8, comment:# if (x0**2+y0**2)**0.5 < (x1**2+y1**2)**0.5:; 9, comment:# return (x1,y1,x0,y0); 10, comment:# return line; 11, comment:#; 12, comment:# ...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 6, 19; 7, 20; 15, 21; 16, 22; 16, 23; 16, 24; 17, 25; 17, 26; 18, 27; 20, 28; 20, 29; 21, 30; 21, 31; 22, 32; 22, 33; 23, 34; 24, 35; 24, 36; 26, 37; 26, 38; 28, 39; 28, 40; 28, 41; 28, 42; 32, 43; 32, 4...
def sort(line): """ change point position if x1,y0 < x0,y0 """ x0, y0, x1, y1 = line # if (x0**2+y0**2)**0.5 < (x1**2+y1**2)**0.5: # return (x1,y1,x0,y0) # return line # # if x1 < x0: # return (x1,y1,x0,y0) # return line turn = False ...
0, module; 1, function_definition; 2, function_name:vectorizable_features; 3, parameters; 4, block; 5, identifier:fcs; 6, expression_statement; 7, expression_statement; 8, return_statement; 9, string; 10, assignment; 11, call; 12, string_content:Discovers the ordered set of vectorizable features in ``fcs``. Return...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 6, 9; 7, 10; 8, 11; 9, 12; 10, 13; 10, 14; 11, 15; 11, 16; 14, 17; 14, 18; 16, 19; 17, 20; 18, 21; 18, 22; 19, 23; 19, 24; 22, 25; 22, 26; 24, 27; 26, 28; 26, 29; 27, 30; 27, 31; 27, 32; 27, 33; 31, 34; 31, 35; 32, 36; 32, 37; 33, 38; 38, 39; 38, 40; 40, 41; 41, 42; 41, 4...
def vectorizable_features(fcs): '''Discovers the ordered set of vectorizable features in ``fcs``. Returns a list of feature names, sorted lexicographically. Feature names are only included if the corresponding features are vectorizable (i.e., they are an instance of :class:`collections.Mapping`). ...
0, module; 1, function_definition; 2, function_name:extension_sort_key; 3, parameters; 4, block; 5, identifier:extension; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, return_statement; 10, comment:"""Returns the sorting key for an extension. The sorting key can be used to sort a li...
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; 13, 18; 13, 19; 13, 20; 15, 21; 15, 22; 17, 23; 17, 24; 18, 25; 18, 26; 19, 27; 19, 28; 20, 29; 20, 30; 23, 31; 23, 32; 28, 33; 28, 34; 28, 35; 31, 36; 31, 37; 32, 38; 32, 39; 33, 40; 34, 41; 35, 42; 38, 43
def extension_sort_key(extension): """Returns the sorting key for an extension. The sorting key can be used to sort a list of extensions into the order that is used in the Khronos C OpenGL headers. :param Extension extension: Extension to produce sort key for :returns: A sorting key """ nam...
0, module; 1, function_definition; 2, function_name:estimate; 3, parameters; 4, block; 5, identifier:self; 6, identifier:upgrades; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, return_statement; 11, comment:"""Estimate the time needed to apply upgrades. If an upgrades does not specify...
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; 19, 20; 20, 21; 20, 22; 22, 23; 22, 24; 23, 25; 23, 26
def estimate(self, upgrades): """Estimate the time needed to apply upgrades. If an upgrades does not specify and estimate it is assumed to be in the order of 1 second. :param upgrades: List of upgrades sorted in topological order. """ val = 0 for u in upgrades: ...
0, module; 1, function_definition; 2, function_name:human_estimate; 3, parameters; 4, block; 5, identifier:self; 6, identifier:upgrades; 7, expression_statement; 8, expression_statement; 9, if_statement; 10, comment:"""Make a human readable estimated time to completion string. :param upgrades: List of upgrades...
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; 9, 15; 9, 16; 9, 17; 9, 18; 9, 19; 9, 20; 9, 21; 9, 22; 11, 23; 11, 24; 12, 25; 12, 26; 13, 27; 14, 28; 14, 29; 15, 30; 15, 31; 16, 32; 16, 33; 17, 34; 17, 35; 18, 36; 18, 37; 19, 38; 19, 39; 20, 40; 20, 41; 21, 42; 21, 43; 22, 44;...
def human_estimate(self, upgrades): """Make a human readable estimated time to completion string. :param upgrades: List of upgrades sorted in topological order. """ val = self.estimate(upgrades) if val < 60: return "less than 1 minute" elif val < 300: ...
0, module; 1, function_definition; 2, function_name:pre_upgrade_checks; 3, parameters; 4, block; 5, identifier:self; 6, identifier:upgrades; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, for_statement; 11, expression_statement; 12, expression_statement; 13, comment:"""Run upgrade pre-checks pr...
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; 10, 18; 10, 19; 10, 20; 11, 21; 12, 22; 14, 23; 14, 24; 16, 25; 16, 26; 17, 27; 17, 28; 20, 29; 20, 30; 21, 31; 21, 32; 22, 33; 22, 34; 27, 35; 28, 36; 28, 37; 29, 38; 30, 39; 30, 40; 31, 41; 31, 42; 33, 43; 33...
def pre_upgrade_checks(self, upgrades): """Run upgrade pre-checks prior to applying upgrades. Pre-checks should in general be fast to execute. Pre-checks may the use the wait_for_user function, to query the user for confirmation, but should respect the --yes-i-know option to run...
0, module; 1, function_definition; 2, function_name:post_upgrade_checks; 3, parameters; 4, block; 5, identifier:self; 6, identifier:upgrades; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, for_statement; 11, expression_statement; 12, expression_statement; 13, comment:"""Run post-upgrade checks ...
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; 10, 18; 10, 19; 10, 20; 11, 21; 12, 22; 14, 23; 14, 24; 17, 25; 17, 26; 19, 27; 19, 28; 20, 29; 20, 30; 21, 31; 21, 32; 22, 33; 22, 34; 25, 35; 26, 36; 26, 37; 29, 38; 30, 39; 30, 40; 31, 41; 31, 42; 33, 43; 33...
def post_upgrade_checks(self, upgrades): """Run post-upgrade checks after applying all pending upgrades. Post checks may be used to emit warnings encountered when applying an upgrade, but post-checks can also be used to advice the user to run re-indexing or similar long running processe...
0, module; 1, function_definition; 2, function_name:order_upgrades; 3, parameters; 4, block; 5, identifier:self; 6, identifier:upgrades; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, comment:# Removed already applied upgrades (assumes all dependencies prior to; 12...
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; 7, 22; 7, 23; 8, 24; 9, 25; 10, 26; 13, 27; 13, 28; 13, 29; 15, 30; 15, 31; 15, 32; 17, 33; 18, 34; 19, 35; 19, 36; 19, 37; 20, 38; 20, 39; 20, 40; 21, 41; 25, 42; 25, 43; 26, 44; 26...
def order_upgrades(self, upgrades, history=None): """Order upgrades according to their dependencies. (topological sort using Kahn's algorithm - http://en.wikipedia.org/wiki/Topological_sorting). :param upgrades: Dict of upgrades :param history: Dict of applied upgrades ...
0, module; 1, function_definition; 2, function_name:_validate_field; 3, parameters; 4, block; 5, identifier:param; 6, identifier:fields; 7, expression_statement; 8, if_statement; 9, comment:""" Ensure the sortable field exists on the model """; 10, comparison_operator:param.field not in fields; 11, block; 12, attribute...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 7, 9; 8, 10; 8, 11; 10, 12; 10, 13; 11, 14; 12, 15; 12, 16; 14, 17; 17, 18; 17, 19; 19, 20; 20, 21; 21, 22; 21, 23; 21, 24; 22, 25; 22, 26; 23, 27; 23, 28; 24, 29; 24, 30; 25, 31; 26, 32; 26, 33; 27, 34; 29, 35; 32, 36; 32, 37; 32, 38; 33, 39; 33, 40; 37, 41; 38, 42
def _validate_field(param, fields): """ Ensure the sortable field exists on the model """ if param.field not in fields: raise InvalidQueryParams(**{ 'detail': 'The sort query param value of "%s" is ' 'invalid. That field does not exist on the ' 'r...
0, module; 1, function_definition; 2, function_name:_validate_no_rels; 3, parameters; 4, block; 5, identifier:param; 6, identifier:rels; 7, expression_statement; 8, if_statement; 9, comment:""" Ensure the sortable field is not on a relationship """; 10, comparison_operator:param.field in rels; 11, block; 12, attribute;...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 7, 9; 8, 10; 8, 11; 10, 12; 10, 13; 11, 14; 12, 15; 12, 16; 14, 17; 17, 18; 17, 19; 19, 20; 20, 21; 21, 22; 21, 23; 21, 24; 22, 25; 22, 26; 23, 27; 23, 28; 24, 29; 24, 30; 25, 31; 26, 32; 26, 33; 27, 34; 29, 35; 32, 36; 32, 37; 32, 38; 33, 39; 33, 40; 37, 41; 38, 42
def _validate_no_rels(param, rels): """ Ensure the sortable field is not on a relationship """ if param.field in rels: raise InvalidQueryParams(**{ 'detail': 'The sort query param value of "%s" is not ' 'supported. Sorting on relationships is not ' ...
0, module; 1, function_definition; 2, function_name:init; 3, parameters; 4, block; 5, identifier:req; 6, identifier:model; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, for_statement; 13, return_statement; 14, comment:""" Determine the...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 7, 14; 8, 15; 9, 16; 10, 17; 11, 18; 12, 19; 12, 20; 12, 21; 13, 22; 15, 23; 15, 24; 16, 25; 16, 26; 17, 27; 17, 28; 18, 29; 18, 30; 21, 31; 21, 32; 24, 33; 24, 34; 26, 35; 26, 36; 28, 37; 28, 38; 30, 39; 30, 40; 31, 41; 32, 42; 37, 43; 3...
def init(req, model): """ Determine the sorting preference by query parameter Return an array of Sortable objects. """ rels = model.relationships fields = model.all_fields params = req.get_param_as_list('sort') or [goldman.config.SORT] params = [Sortable(param.lower()) for param in params...
0, module; 1, function_definition; 2, function_name:get_allposts; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, try_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, for_statement; 13, expression_statement; 14, return_statemen...
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; 8, 18; 9, 19; 10, 20; 11, 21; 12, 22; 12, 23; 12, 24; 13, 25; 14, 26; 15, 27; 16, 28; 16, 29; 17, 30; 18, 31; 19, 32; 19, 33; 20, 34; 20, 35; 21, 36; 21, 37; 23, 38; 23, 39; 24, 40; 24, 41; 24, 42; 24, 43; 24, ...
def get_allposts(self): ''' Return all posts in blog sorted by date ''' result = self.client.posts(self.blog, offset = 0, limit = 1) try: total_posts = result['total_posts'] except: raise phasetumblr_errors.TumblrBlogException(result['meta']['msg']) delta = (total_posts / 10) + 1 all_posts = [] ...
0, module; 1, function_definition; 2, function_name:sort_dict_by_key; 3, parameters; 4, block; 5, identifier:obj; 6, expression_statement; 7, expression_statement; 8, return_statement; 9, comment:""" Sort dict by its keys >>> sort_dict_by_key(dict(c=1, b=2, a=3, d=4)) OrderedDict([('a', 3), ('b', 2), ('c',...
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; 15, 18; 16, 19; 17, 20; 17, 21; 18, 22; 18, 23; 23, 24; 23, 25; 24, 26; 24, 27; 25, 28; 25, 29; 26, 30; 26, 31
def sort_dict_by_key(obj): """ Sort dict by its keys >>> sort_dict_by_key(dict(c=1, b=2, a=3, d=4)) OrderedDict([('a', 3), ('b', 2), ('c', 1), ('d', 4)]) """ sort_func = lambda x: x[0] return OrderedDict(sorted(obj.items(), key=sort_func))
0, module; 1, function_definition; 2, function_name:sortBy; 3, parameters; 4, block; 5, identifier:self; 6, list_splat_pattern; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, return_statement; 11, identifier:args; 12, string; 13, assignment; 14, identifier:k; 15, identifier:args; 16, block; 17,...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 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; 13, 19; 13, 20; 16, 21; 20, 22; 20, 23; 21, 24; 21, 25; 22, 26; 23, 27; 24, 28; 24, 29; 25, 30; 30, 31; 31, 32; 31, 33; 32, 34; 32, 35; 33, 36; 33, 37; 37, 38; 37, 39; 37, 40; 38, 41; 38, 42; 39, 43; 3...
def sortBy(self, *args): '''sort results by given criteria''' criteria = ['seeds', 'size'] for k in args: if k in criteria: self.results = sorted( self.results, key=attrgetter(k), reverse=True) return self
0, module; 1, function_definition; 2, function_name:rate_limited; 3, parameters; 4, block; 5, identifier:max_per_second; 6, expression_statement; 7, import_statement; 8, expression_statement; 9, expression_statement; 10, function_definition; 11, return_statement; 12, comment:""" Sort of based off of an answer about ...
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; 10, 16; 10, 17; 10, 18; 11, 19; 13, 20; 14, 21; 14, 22; 15, 23; 15, 24; 17, 25; 18, 26; 18, 27; 22, 28; 22, 29; 24, 30; 26, 31; 26, 32; 26, 33; 27, 34; 28, 35; 28, 36; 29, 37; 32, 38; 32, 39; 33, 40; 33, 41; 33, 42; 33, 43; ...
def rate_limited(max_per_second): """ Sort of based off of an answer about rate limiting on Stack Overflow. Definitely **not** thread safe, so don't even think about it, buddy. """ import datetime min_request_time = datetime.timedelta(seconds=max_per_second) last_time_called...
0, module; 1, function_definition; 2, function_name:monotony; 3, parameters; 4, block; 5, identifier:seq; 6, expression_statement; 7, if_statement; 8, comment:"""Determine the monotony of a sequence :param seq: a sequence :returns: 1 if the sequence is sorted (increasing) :returns: 0 if it is not sorted ...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 6, 8; 7, 9; 7, 10; 7, 11; 7, 12; 9, 13; 9, 14; 10, 15; 11, 16; 11, 17; 12, 18; 14, 19; 14, 20; 15, 21; 16, 22; 16, 23; 17, 24; 18, 25; 20, 26; 23, 27; 23, 28; 24, 29; 25, 30; 28, 31; 29, 32; 31, 33; 31, 34; 34, 35; 35, 36; 35, 37; 37, 38
def monotony(seq): """Determine the monotony of a sequence :param seq: a sequence :returns: 1 if the sequence is sorted (increasing) :returns: 0 if it is not sorted :returns: -1 if it is sorted in reverse order (decreasing) >>> monotony([1, 2, 3]) 1 >>> monotony([1, 3, 2]) 0 >...
0, module; 1, function_definition; 2, function_name:variables; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, return_statement; 9, comment:""" Returns all documented module level variables in the module sorted alphabetically as a list of `pydoc.Variable...
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; 15, 18; 16, 19; 17, 20; 17, 21; 18, 22; 18, 23; 20, 24; 20, 25; 21, 26; 21, 27; 23, 28; 23, 29; 25, 30; 25, 31; 26, 32; 26, 33; 27, 34; 29, 35; 29, 36; 35, 37; 35, 38; 37, 39; 37, 40
def variables(self): """ Returns all documented module level variables in the module sorted alphabetically as a list of `pydoc.Variable`. """ p = lambda o: isinstance(o, Variable) and self._docfilter(o) return sorted(filter(p, self.doc.values()))
0, module; 1, function_definition; 2, function_name:classes; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, return_statement; 9, comment:""" Returns all documented module level classes in the module sorted alphabetically as a list of `pydoc.Class`. ...
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; 15, 18; 16, 19; 17, 20; 17, 21; 18, 22; 18, 23; 20, 24; 20, 25; 21, 26; 21, 27; 23, 28; 23, 29; 25, 30; 25, 31; 26, 32; 26, 33; 27, 34; 29, 35; 29, 36; 35, 37; 35, 38; 37, 39; 37, 40
def classes(self): """ Returns all documented module level classes in the module sorted alphabetically as a list of `pydoc.Class`. """ p = lambda o: isinstance(o, Class) and self._docfilter(o) return sorted(filter(p, self.doc.values()))
0, module; 1, function_definition; 2, function_name:functions; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, return_statement; 9, comment:""" Returns all documented module level functions in the module sorted alphabetically as a list of `pydoc.Function...
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; 15, 18; 16, 19; 17, 20; 17, 21; 18, 22; 18, 23; 20, 24; 20, 25; 21, 26; 21, 27; 23, 28; 23, 29; 25, 30; 25, 31; 26, 32; 26, 33; 27, 34; 29, 35; 29, 36; 35, 37; 35, 38; 37, 39; 37, 40
def functions(self): """ Returns all documented module level functions in the module sorted alphabetically as a list of `pydoc.Function`. """ p = lambda o: isinstance(o, Function) and self._docfilter(o) return sorted(filter(p, self.doc.values()))
0, module; 1, function_definition; 2, function_name:submodules; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, return_statement; 9, comment:""" Returns all documented sub-modules in the module sorted alphabetically as a list of `pydoc.Module`. "...
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; 15, 18; 16, 19; 17, 20; 17, 21; 18, 22; 18, 23; 20, 24; 20, 25; 21, 26; 21, 27; 23, 28; 23, 29; 25, 30; 25, 31; 26, 32; 26, 33; 27, 34; 29, 35; 29, 36; 35, 37; 35, 38; 37, 39; 37, 40
def submodules(self): """ Returns all documented sub-modules in the module sorted alphabetically as a list of `pydoc.Module`. """ p = lambda o: isinstance(o, Module) and self._docfilter(o) return sorted(filter(p, self.doc.values()))
0, module; 1, function_definition; 2, function_name:class_variables; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, return_statement; 9, comment:""" Returns all documented class variables in the class, sorted alphabetically as a list of `pydoc.Variable`...
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; 15, 18; 15, 19; 16, 20; 17, 21; 17, 22; 19, 23; 19, 24; 21, 25; 21, 26; 22, 27; 22, 28; 23, 29; 23, 30; 26, 31; 26, 32; 27, 33; 27, 34; 28, 35; 29, 36; 29, 37; 33, 38; 33, 39
def class_variables(self): """ Returns all documented class variables in the class, sorted alphabetically as a list of `pydoc.Variable`. """ p = lambda o: isinstance(o, Variable) and self.module._docfilter(o) return filter(p, self.doc.values())
0, module; 1, function_definition; 2, function_name:BEDIterator; 3, parameters; 4, block; 5, identifier:filehandle; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, if_statement; 14, if_statement; 15...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 6, 16; 6, 17; 7, 18; 7, 19; 8, 20; 8, 21; 9, 22; 9, 23; 10, 24; 11, 25; 12, 26; 13, 27; 13, 28; 14, 29; 14, 30; 15, 31; 15, 32; 15, 33; 25, 34; 25, 35; 26, 36; 26, 37; 27, 38; 27, 39; 28, 40; 30, 41; 33, 42; 33, 43; 33, 44; ...
def BEDIterator(filehandle, sortedby=None, verbose=False, scoreType=int, dropAfter=None): """ Get an iterator for a BED file :param filehandle: this can be either a string, or a stream-like object. In the former case, it is treated as a filename. The format ...
0, module; 1, function_definition; 2, function_name:compress_and_sort_index; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, try_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, comment:# Include UTF-8 BOM in header.; 13, expre...
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; 6, 23; 7, 24; 8, 25; 8, 26; 9, 27; 10, 28; 11, 29; 13, 30; 14, 31; 15, 32; 16, 33; 17, 34; 17, 35; 17, 36; 18, 37; 19, 38; 20, 39; 20, 40; 21, 41; 22, 42; 24, 43; 24, 44; 25, ...
def compress_and_sort_index(self): """Sort index, add header, and compress. :rtype: bool :returns: True """ idx_fname = '{name}.{date}.mbox.csv'.format(**self.__dict__) try: reader = csv.reader(open(idx_fname), dialect='excel-tab') except IOError: ...
0, module; 1, function_definition; 2, function_name:_sort; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, comment:""" Sort versions by their version number """; 9, assignment; 10, attribute; 11, call; 12, identifier:self; 13, identifier:versions; 14, id...
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(self): """ Sort versions by their version number """ self.versions = OrderedDict(sorted(self.versions.items(), key=lambda v: v[0]))
0, module; 1, function_definition; 2, function_name:get_workspace_activities; 3, parameters; 4, block; 5, identifier:brain; 6, default_parameter; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, return_statement; 11, identifier:limit; 12, integer:1; 13, comment:""" Return the workspace act...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 6, 11; 6, 12; 7, 13; 8, 14; 9, 15; 10, 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; 21, 29; 21, 30; 22, 31; 22, 32; 24, 33; 25, 34; 25, 35; 26, 36; 26, 37; 27, 38; 27, 39; 28, 40; 28, 41; 29, 42; 29, 43; ...
def get_workspace_activities(brain, limit=1): """ Return the workspace activities sorted by reverse chronological order Regarding the time value: - the datetime value contains the time in international format (machine readable) - the title value contains the absolute date and time of the p...
0, module; 1, function_definition; 2, function_name:sort_by; 3, parameters; 4, block; 5, identifier:items; 6, identifier:attr; 7, expression_statement; 8, function_definition; 9, return_statement; 10, comment:""" General sort filter - sorts by either attribute or key. """; 11, function_name:key_func; 12, parame...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 7, 10; 8, 11; 8, 12; 8, 13; 9, 14; 12, 15; 13, 16; 14, 17; 14, 18; 16, 19; 16, 20; 18, 21; 18, 22; 19, 23; 20, 24; 20, 25; 22, 26; 22, 27; 23, 28; 25, 29; 28, 30; 28, 31; 29, 32; 29, 33; 31, 34; 31, 35; 32, 36; 33, 37; 33, 38; 36, 39; 38, 40; 38, 41; 39, 42; 39, 43;...
def sort_by(items, attr): """ General sort filter - sorts by either attribute or key. """ def key_func(item): try: return getattr(item, attr) except AttributeError: try: return item[attr] except TypeError: getattr(item, ...
0, module; 1, function_definition; 2, function_name:sorted_migrations; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, if_statement; 8, return_statement; 9, comment:""" Sort migrations if necessary and store in self._sorted_migrations """; 10, not_operator; 11, block; 12, attrib...
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; 11, 14; 12, 15; 12, 16; 13, 17; 13, 18; 14, 19; 19, 20; 19, 21; 20, 22; 20, 23; 21, 24; 21, 25; 25, 26; 25, 27; 25, 28; 26, 29; 26, 30; 28, 31; 28, 32; 29, 33; 29, 34; 32, 35; 32, 36; 33, 37; 33, 38; 35, 39; 36, 40; 36, 41
def sorted_migrations(self): """ Sort migrations if necessary and store in self._sorted_migrations """ if not self._sorted_migrations: self._sorted_migrations = sorted( self.migration_registry.items(), # sort on the key... the migration number ...
0, module; 1, function_definition; 2, function_name:_sorter; 3, parameters; 4, block; 5, identifier:generated; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, return_statement; 10, comment:"""Return a list of paths sorted by dirname & basename."""; 11, assignment; 12, call; 13, list_compre...
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; 13, 18; 13, 19; 15, 20; 15, 21; 16, 22; 16, 23; 18, 24; 18, 25; 19, 26; 19, 27; 20, 28; 20, 29; 21, 30; 21, 31; 24, 32; 24, 33; 25, 34; 25, 35; 28, 36; 28, 37; 29, 38; 29, 39; 31, 40; 31, 41; 32, 42; 32, 43...
def _sorter(generated): """Return a list of paths sorted by dirname & basename.""" pairs = [(os.path.dirname(f), os.path.basename(f)) for f in set(list(generated))] pairs.sort() return [os.path.join(pair[0], pair[1]) for pair in pairs]
0, module; 1, function_definition; 2, function_name:regionsIntersection; 3, parameters; 4, block; 5, identifier:s1; 6, identifier:s2; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, comment:# we don't need to explicitly check for sorting because sorted order is; 11, comment:# a post-conditio...
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; 7, 19; 7, 20; 8, 21; 9, 22; 12, 23; 13, 24; 14, 25; 14, 26; 15, 27; 16, 28; 17, 29; 17, 30; 17, 31; 18, 32; 22, 33; 22, 34; 23, 35; 23, 36; 24, 37; 24, 38; 25, 39; 25, 40; 26, 41; 27, 42; 27, 43; 28, 44;...
def regionsIntersection(s1, s2, collapse=True): """ given two lists of genomic regions with chromosome, start and end coordinates, return a new list of regions which is the intersection of those two sets. Lists must be sorted by chromosome and start index :return: new list that represents the intersection of...
0, module; 1, function_definition; 2, function_name:bucketIterator; 3, parameters; 4, block; 5, identifier:elements; 6, identifier:buckets; 7, expression_statement; 8, function_definition; 9, function_definition; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, for_statement; 14, commen...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 7, 14; 8, 15; 8, 16; 8, 17; 9, 18; 9, 19; 9, 20; 10, 21; 11, 22; 12, 23; 13, 24; 13, 25; 13, 26; 13, 27; 16, 28; 16, 29; 17, 30; 19, 31; 19, 32; 19, 33; 19, 34; 19, 35; 20, 36; 20, 37; 20, 38; 20, 39; 20, 40; 20, 41; 20, 42; 20, 43; 20, 4...
def bucketIterator(elements, buckets): """ For each bucket in buckets, yield it and any elements that overlap it. :param elements: the genomic intervals to place into the buckets. Must be sorted by chromosome and start index. This could be a list, or an iterator. :param bu...
0, module; 1, function_definition; 2, function_name:_ordered; 3, parameters; 4, block; 5, identifier:generator; 6, list_splat_pattern; 7, dictionary_splat_pattern; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, for_statement; 13, return_statement; 14, identifie...
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; 10, 18; 11, 19; 12, 20; 12, 21; 12, 22; 13, 23; 17, 24; 17, 25; 18, 26; 18, 27; 19, 28; 19, 29; 22, 30; 25, 31; 25, 32; 27, 33; 27, 34; 29, 35; 29, 36; 30, 37; 31, 38; 31, 39; 32, 40; 32, 41; 34, 42; 37, 43; 37...
def _ordered(generator, *args, **kwargs): """Sort keys of unordered_dict and store in OrderedDict.""" unordered_dict = {k: v for k, v in generator(*args, **kwargs)} keys = sorted(list(dict(unordered_dict).keys())) result = OrderedDict() for key in keys: result[key] = unordered_dict[key] ...
0, module; 1, function_definition; 2, function_name:str2dict_keys; 3, parameters; 4, block; 5, identifier:str_in; 6, expression_statement; 7, expression_statement; 8, if_statement; 9, return_statement; 10, string; 11, assignment; 12, comparison_operator:tmp_dict is None; 13, block; 14, call; 15, string_content:Extracts...
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; 10, 15; 11, 16; 11, 17; 12, 18; 12, 19; 13, 20; 14, 21; 14, 22; 17, 23; 17, 24; 20, 25; 22, 26; 24, 27; 26, 28; 26, 29; 29, 30; 29, 31
def str2dict_keys(str_in): ''' Extracts the keys from a string that represents a dict and returns them sorted by key. Args: str_in (string) that contains python dict Returns: (list) with keys or None if no valid dict was found Raises: - ''' tmp_dict = str2dict(st...
0, module; 1, function_definition; 2, function_name:str2dict_values; 3, parameters; 4, block; 5, identifier:str_in; 6, expression_statement; 7, expression_statement; 8, if_statement; 9, return_statement; 10, string; 11, assignment; 12, comparison_operator:tmp_dict is None; 13, block; 14, list_comprehension; 15, string_...
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; 10, 15; 11, 16; 11, 17; 12, 18; 12, 19; 13, 20; 14, 21; 14, 22; 17, 23; 17, 24; 20, 25; 21, 26; 21, 27; 22, 28; 22, 29; 24, 30; 29, 31; 29, 32; 32, 33; 32, 34; 34, 35; 34, 36
def str2dict_values(str_in): ''' Extracts the values from a string that represents a dict and returns them sorted by key. Args: str_in (string) that contains python dict Returns: (list) with values or None if no valid dict was found Raises: - ''' tmp_dict = str2d...
0, module; 1, function_definition; 2, function_name:to_json; 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, return_statement; 13, identifier:include_keys; 14, None; 15, identifier:e...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 4, 11; 4, 12; 7, 13; 7, 14; 8, 15; 8, 16; 9, 17; 9, 18; 10, 19; 10, 20; 11, 21; 12, 22; 22, 23; 22, 24; 24, 25; 24, 26; 25, 27; 25, 28; 26, 29; 26, 30; 27, 31; 27, 32; 28, 33; 28, 34; 28, 35; 33, 36; 33, 37; 34, 38; 34, 39; 35, 40; 35, 41
def to_json(self, *, include_keys=None, exclude_keys=None, use_default_excludes=True, pretty=False): """Converts the response from to_dict to a JSON string. If pretty is True then newlines, indentation and key sorting are used. """ return to_json( self.to_dict( include_keys=i...
0, module; 1, function_definition; 2, function_name:get_annotations; 3, parameters; 4, block; 5, identifier:cls; 6, identifier:target; 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, ...
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; 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; 13, 33; 14, 34; 14, 35; 15, 36; 16, 37; 17, 38; 17, 39; 18, 40; 18, 41; 19, 42; 25, 43; 25, 44; 37...
def get_annotations( cls, target, exclude=None, ctx=None, select=lambda *p: True, mindepth=0, maxdepth=0, followannotated=True, public=True, _history=None ): """Returns all input target annotations of cls type sorted by definition order. :para...
0, module; 1, function_definition; 2, function_name:get_filenames; 3, parameters; 4, block; 5, identifier:dirname; 6, expression_statement; 7, expression_statement; 8, return_statement; 9, comment:"""Return all model output filenames inside a model output directory, sorted by iteration number. Parameters -...
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; 15, 18; 15, 19; 16, 20; 16, 21; 17, 22; 19, 23; 19, 24; 22, 25; 22, 26; 25, 27; 25, 28; 26, 29; 27, 30
def get_filenames(dirname): """Return all model output filenames inside a model output directory, sorted by iteration number. Parameters ---------- dirname: str A path to a directory. Returns ------- filenames: list[str] Paths to all output files inside `dirname`, sorte...
0, module; 1, function_definition; 2, function_name:sort_states; 3, parameters; 4, block; 5, identifier:states; 6, identifier:sort_list; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, return_statement; 11, comment:""" Returns a list of sorted states, original states list remains unsorted ...
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; 18, 22; 18, 23; 20, 24; 21, 25; 21, 26; 21, 27; 22, 28; 22, 29; 24, 30; 24, 31; 25, 32; 25, 33; 26, 34; 27, 35; 27, 36; 31, 37; 32, 38; 32, 39; 33, 40; 33, 41; 33, 42; 34, 43; ...
def sort_states(states, sort_list): """ Returns a list of sorted states, original states list remains unsorted The sort list is a list of state field: field key pairs For example (as YAML): - data: position - meta: created_at The field_key part can be a list to simplify ...
0, module; 1, function_definition; 2, function_name:search; 3, parameters; 4, block; 5, identifier:self; 6, identifier:terms; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, 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; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 4, 23; 7, 24; 7, 25; 8, 26; 8, 27; 9, 28; 9, 29; 10, 30; 10, 31; 11, 32; 12, 33; 13, 34; 14, 35; 18, 36; 19, 37; 19, 38; 19, 39; 20, 40; 21, 41; 22, 42; 22, 43; 22, 44; 23, 45...
def search(self, terms, category=Category.all_categories, page=1, sort_key=SearchSortKey.date, order_key=SearchOrderKey.descending): """Get a list of torrents that match the given search term :param terms: the `str` needle :param category: the desired :class:`Categ...
0, module; 1, function_definition; 2, function_name:partition; 3, parameters; 4, block; 5, identifier:self; 6, identifier:mapped_values; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, return_statement; 11, comment:"""Organize the mapped values by their key. Returns an unsorted sequence ...
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; 15, 21; 16, 22; 16, 23; 18, 24; 18, 25; 21, 26; 22, 27; 22, 28; 24, 29; 24, 30; 25, 31; 26, 32; 26, 33; 32, 34; 32, 35; 33, 36; 34, 37; 34, 38
def partition(self, mapped_values): """Organize the mapped values by their key. Returns an unsorted sequence of tuples with a key and a sequence of values. """ partitioned_data = collections.defaultdict(list) for key, value in mapped_values: partitioned_data[key].appe...
0, module; 1, function_definition; 2, function_name:cond_int; 3, parameters; 4, block; 5, identifier:self; 6, identifier:conkey; 7, expression_statement; 8, expression_statement; 9, if_statement; 10, return_statement; 11, comment:"""Return the trailing number from cond if any, as an int. If no trailing number, ...
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; 14, 19; 15, 20; 15, 21; 17, 22; 17, 23; 19, 24; 21, 25; 22, 26; 22, 27; 23, 28; 23, 29; 25, 30; 25, 31; 28, 32; 28, 33; 30, 34; 30, 35; 31, 36
def cond_int(self, conkey): """Return the trailing number from cond if any, as an int. If no trailing number, return the string conkey as is. This is used for sorting the conditions properly even when passing the number 10. The name of this function could be improved since it mi...
0, module; 1, function_definition; 2, function_name:sorted_conkeys; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, expression_statement; 8, comment:# Make for defined and sorted output:; 9, expression_statement; 10, for_statement; 11, if_statement; 12, return_statement; 13, identifier:prefix; 14,...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 6, 13; 6, 14; 7, 15; 9, 16; 10, 17; 10, 18; 10, 19; 11, 20; 11, 21; 12, 22; 16, 23; 16, 24; 19, 25; 20, 26; 21, 27; 22, 28; 22, 29; 22, 30; 25, 31; 27, 32; 29, 33; 29, 34; 30, 35; 31, 36; 31, 37; 35, 38; 35, 39; 37, 40; 37, 41; 38, 42; 38, 43; 3...
def sorted_conkeys(self, prefix=None): """Return all condition keys in self.conditions as a list sorted suitable for print or write to a file. If prefix is given return only the ones prefixed with prefix.""" # Make for defined and sorted output: conkeys = [] for cond in ...
0, module; 1, function_definition; 2, function_name:isordinal; 3, parameters; 4, block; 5, identifier:x; 6, expression_statement; 7, import_statement; 8, if_statement; 9, if_statement; 10, return_statement; 11, comment:"""Checks if a list or array contains ordinal data. Warning: -------- This is not a reli...
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; 9, 15; 9, 16; 10, 17; 12, 18; 12, 19; 13, 20; 13, 21; 14, 22; 15, 23; 16, 24; 17, 25; 17, 26; 18, 27; 20, 28; 20, 29; 21, 30; 21, 31; 22, 32; 23, 33; 23, 34; 24, 35; 24, 36; 29, 37; 31, 38; 32, 39; 32, 40; 34, 41; 34, 42; 35, 43; 3...
def isordinal(x): """Checks if a list or array contains ordinal data. Warning: -------- This is not a reliable check for a variable being ordinal. The following criteria are used - There are more observations than unique values. Why? Ordinal means discrete or countable and ...
0, module; 1, function_definition; 2, function_name:sort; 3, parameters; 4, block; 5, identifier:self; 6, list_splat_pattern; 7, expression_statement; 8, expression_statement; 9, return_statement; 10, identifier:sort; 11, comment:""" Sort the results. Define how the results should be sorted. The arguments shou...
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; 12, 14; 12, 15; 14, 16; 14, 17; 15, 18; 15, 19; 18, 20; 19, 21; 19, 22; 21, 23; 21, 24; 22, 25; 25, 26; 25, 27; 26, 28; 26, 29; 27, 30; 27, 31; 28, 32; 28, 33; 29, 34
def sort(self, *sort): """ Sort the results. Define how the results should be sorted. The arguments should be tuples of string defining the key and direction to sort by. For example `('name', 'asc')` and `('version', 'desc')`. The first sorte rule is considered first by the API....
0, module; 1, function_definition; 2, function_name:to_json; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, expression_statement; 11, return_statement; 12, identifier:drop_null; 13, True; 14, identifier:camel; 15, False; 16, ident...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, 10; 4, 11; 6, 12; 6, 13; 7, 14; 7, 15; 8, 16; 8, 17; 9, 18; 9, 19; 10, 20; 11, 21; 21, 22; 21, 23; 22, 24; 22, 25; 23, 26; 23, 27; 23, 28; 26, 29; 26, 30; 27, 31; 27, 32; 28, 33; 28, 34; 29, 35; 29, 36; 30, 37; 30, 38
def to_json(self, drop_null=True, camel=False, indent=None, sort_keys=False): """Serialize self as JSON Args: drop_null: bool, default True. Remove 'empty' attributes. See to_dict. camel: bool, default True. Convert keys to camelCase. indent: int, def...
0, module; 1, function_definition; 2, function_name:sort_by_name; 3, parameters; 4, block; 5, identifier:names; 6, expression_statement; 7, function_definition; 8, return_statement; 9, comment:"""Sort by last name, uniquely."""; 10, function_name:last_name_key; 11, parameters; 12, block; 13, call; 14, identifier:full_n...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 6, 9; 7, 10; 7, 11; 7, 12; 8, 13; 11, 14; 12, 15; 12, 16; 12, 17; 12, 18; 13, 19; 13, 20; 15, 21; 16, 22; 16, 23; 17, 24; 18, 25; 20, 26; 20, 27; 21, 28; 21, 29; 22, 30; 22, 31; 23, 32; 24, 33; 24, 34; 25, 35; 25, 36; 26, 37; 26, 38; 27, 39; 27, 40; 29, 41; 29, 42; 30, 43...
def sort_by_name(names): """Sort by last name, uniquely.""" def last_name_key(full_name): parts = full_name.split(' ') if len(parts) == 1: return full_name.upper() last_first = parts[-1] + ' ' + ' '.join(parts[:-1]) return last_first.upper() return sorted(set(na...
0, module; 1, function_definition; 2, function_name:sort; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, comment:# First sort commits by author email; 8, expression_statement; 9, comment:# Group commits by author email, so they can be merged; 10, for_statement; 11, comment:# Finally sort by th...
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; 8, 15; 10, 16; 10, 17; 10, 18; 12, 19; 13, 20; 15, 21; 15, 22; 16, 23; 16, 24; 17, 25; 17, 26; 18, 27; 19, 28; 19, 29; 20, 30; 20, 31; 25, 32; 25, 33; 26, 34; 26, 35; 27, 36; 27, 37; 28, 38; 28, 39; 29, 40; 29, 41; 34, 42; 34, 43; ...
def sort(self): """Sort by commit size, per author.""" # First sort commits by author email users = [] # Group commits by author email, so they can be merged for _, group in itertools.groupby(sorted(self.commits), operator.attrgetter('aut...
0, module; 1, function_definition; 2, function_name:sort; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, if_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, for_statement; 13, comment:# Take care of last commit; 14, expression...
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; 6, 17; 7, 18; 8, 19; 8, 20; 9, 21; 10, 22; 11, 23; 12, 24; 12, 25; 12, 26; 14, 27; 15, 28; 16, 29; 18, 30; 18, 31; 19, 32; 20, 33; 21, 34; 21, 35; 22, 36; 22, 37; 23, 38; 23, 39; 25, 40; 25, 41; 26, 42; 26, 43; 26, 44...
def sort(self): """Consolidate adjacent lines, if same commit ID. Will modify line number to be a range, when two or more lines with the same commit ID. """ self.sorted_commits = [] if not self.commits: return self.sorted_commits prev_commit = self.co...
0, module; 1, function_definition; 2, function_name:truncate_most_common; 3, parameters; 4, block; 5, identifier:self; 6, identifier:truncation_length; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, string; 11, assignment; 12, identifier:key; 13, call; 14, block; 15, string_content:Sorts the co...
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; 10, 15; 11, 16; 11, 17; 13, 18; 13, 19; 14, 20; 17, 21; 17, 22; 18, 23; 18, 24; 20, 25; 20, 26; 22, 27; 22, 28; 25, 29; 25, 30; 26, 31; 27, 32; 27, 33; 28, 34; 28, 35; 31, 36; 35, 37; 35, 38; 36, 39; 36, 40; 37, 41; 37, 42; 38, 43;...
def truncate_most_common(self, truncation_length): ''' Sorts the counter and keeps only the most common items up to ``truncation_length`` in place. :type truncation_length: int ''' keep_keys = set(v[0] for v in self.most_common(truncation_length)) for key in self...
0, module; 1, function_definition; 2, function_name:get_ordered_values; 3, parameters; 4, block; 5, identifier:self; 6, identifier:keypath; 7, identifier:distance_from; 8, default_parameter; 9, expression_statement; 10, expression_statement; 11, if_statement; 12, for_statement; 13, if_statement; 14, expression_statemen...
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; 4, 23; 8, 24; 8, 25; 9, 26; 10, 27; 11, 28; 11, 29; 11, 30; 11, 31; 12, 32; 12, 33; 12, 34; 13, 35; 13, 36; 14, 37; 15, 38; 16, 39; 17, 40; 17, 41; 18, 42; 18, 43; 19, 44; 20,...
def get_ordered_values(self, keypath, distance_from, open_interval=True): """ Retrieves the referents's values sorted by their distance from the min, max, or mid value. """ values = [] if keypath[0] == 'target': # instances start with 'target' prefix, but ...
0, module; 1, function_definition; 2, function_name:gp_datdir; 3, parameters; 4, block; 5, identifier:initial; 6, identifier:topN; 7, expression_statement; 8, comment:# prepare input/output directories; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, if_statement; 13, comment:# prepare ...
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; 7, 26; 9, 27; 10, 28; 11, 29; 12, 30; 12, 31; 12, 32; 14, 33; 15, 34; 15, 35; 15, 36; 16, 37; 19, 38; 21, 39; 23, 40; 24, 41; 25, 42; 27, 43; 27, 44; 28, ...
def gp_datdir(initial, topN): """example for plotting from a text file via numpy.loadtxt 1. prepare input/output directories 2. load the data into an OrderedDict() [adjust axes units] 3. sort countries from highest to lowest population 4. select the <topN> most populated countries 5. call ccsgp.make_plot w...
0, module; 1, function_definition; 2, function_name:rankingEval; 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, expression_statement; 13, comment:# Compute the selection probabilit...
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; 7, 21; 8, 22; 9, 23; 9, 24; 9, 25; 10, 26; 11, 27; 11, 28; 11, 29; 12, 30; 14, 31; 15, 32; 16, 33; 16, 34; 16, 35; 17, 36; 18, 37; 19, 38; 20, 39; 21, 40; 21, 41; 22, 42; 22, 43; 24, 44; 24...
def rankingEval(self): ''' Sorting the pop. base on the fitnessEval result ''' fitnessAll = numpy.zeros(self.length) fitnessNorm = numpy.zeros(self.length) for i in range(self.length): self.Ind[i].fitnessEval() fitnessAll[i] = self.Ind[i].fitness maxFitness = fitnessAll.max() for i in range(self...
0, module; 1, function_definition; 2, function_name:sortedbyAge; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, for_statement; 9, expression_statement; 10, return_statement; 11, string; 12, assignment; 13, identifier:i; 14, call; 15, block; 16, assignment; 17, subscrip...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 6, 11; 7, 12; 8, 13; 8, 14; 8, 15; 9, 16; 10, 17; 11, 18; 12, 19; 12, 20; 14, 21; 14, 22; 15, 23; 16, 24; 16, 25; 17, 26; 17, 27; 20, 28; 20, 29; 22, 30; 23, 31; 25, 32; 25, 33; 27, 34; 28, 35; 28, 36; 29, 37; 30, 38; 30, 39; 31, 40; 31, 41; 32, 42; 32, 43; 3...
def sortedbyAge(self): ''' Sorting the pop. base of the age ''' ageAll = numpy.zeros(self.length) for i in range(self.length): ageAll[i] = self.Ind[i].age ageSorted = ageAll.argsort() return ageSorted[::-1]
0, module; 1, function_definition; 2, function_name:upcoming_releases; 3, parameters; 4, block; 5, identifier:self; 6, identifier:product; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 7, 15; 8, 16; 9, 17; 10, 18; 11, 19; 12, 20; 13, 21; 14, 22; 16, 23; 16, 24; 17, 25; 17, 26; 18, 27; 18, 28; 19, 29; 19, 30; 20, 31; 20, 32; 21, 33; 21, 34; 22, 35; 22, 36; 24, 37; 26, 38; 26, 39; 28, 40; 28, 41; 30, 42; 30, 43; 32...
def upcoming_releases(self, product): """ Get upcoming releases for this product. Specifically we search for releases with a GA date greater-than or equal to today's date. :param product: str, eg. "ceph" :returns: deferred that when fired returns a list of Munch (dict-l...
0, module; 1, function_definition; 2, function_name:es_field_sort; 3, parameters; 4, block; 5, identifier:fld_name; 6, expression_statement; 7, expression_statement; 8, if_statement; 9, return_statement; 10, comment:""" Used with lambda to sort fields """; 11, assignment; 12, comparison_operator:"_" not in parts[-1]; 1...
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; 16, 22; 16, 23; 18, 24; 18, 25; 19, 26; 20, 27; 20, 28; 21, 29; 22, 30; 22, 31; 23, 32; 25, 33; 26, 34; 26, 35; 34, 36; 34, 37; 35, 38; 35, 39; 37, 40; 39, 41; 39, 42; 42, 43
def es_field_sort(fld_name): """ Used with lambda to sort fields """ parts = fld_name.split(".") if "_" not in parts[-1]: parts[-1] = "_" + parts[-1] return ".".join(parts)
0, module; 1, function_definition; 2, function_name:_get_vars; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, if_statement; 8, if_statement; 9, expression_statement; 10, comment:# translate a list of vars into a dict; 11, if_statement; 12, if_statement; 13, if_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; 6, 17; 7, 18; 7, 19; 8, 20; 8, 21; 9, 22; 11, 23; 11, 24; 11, 25; 12, 26; 12, 27; 13, 28; 13, 29; 13, 30; 13, 31; 14, 32; 15, 33; 16, 34; 17, 35; 18, 36; 18, 37; 19, 38; 20, 39; 20, 40; 21, 41; 22, 42; 22, 43; 23, 44;...
def _get_vars(self): ''' load the vars section from a play, accounting for all sorts of variable features including loading from yaml files, prompting, and conditional includes of the first file found in a list. ''' if self.vars is None: self.vars = {} if type(self....
0, module; 1, function_definition; 2, function_name:list_refs; 3, parameters; 4, block; 5, identifier:profile; 6, default_parameter; 7, expression_statement; 8, expression_statement; 9, if_statement; 10, expression_statement; 11, expression_statement; 12, return_statement; 13, identifier:ref_type; 14, None; 15, comment...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 6, 13; 6, 14; 7, 15; 8, 16; 9, 17; 9, 18; 10, 19; 11, 20; 12, 21; 16, 22; 16, 23; 18, 24; 19, 25; 19, 26; 20, 27; 20, 28; 24, 29; 26, 30; 26, 31; 28, 32; 28, 33; 29, 34; 29, 35; 30, 36; 30, 37; 31, 38; 31, 39; 32, 40; 32, 41; 33, 42; 33, 43; 35,...
def list_refs(profile, ref_type=None): """List all refs. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with. ref_type ...
0, module; 1, function_definition; 2, function_name:sort; 3, parameters; 4, block; 5, identifier:self; 6, identifier:fieldname; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, expression_statement; 11, try_statement; 12, expression_statement; 13, expression_statement; 14, for_statement; 15, commen...
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; 7, 18; 7, 19; 8, 20; 8, 21; 9, 22; 9, 23; 10, 24; 11, 25; 11, 26; 12, 27; 13, 28; 14, 29; 14, 30; 14, 31; 17, 32; 19, 33; 19, 34; 25, 35; 26, 36; 26, 37; 27, 38; 27, 39; 28, 40; 28, 41; 29, 42; 29, 43; 30, 44; ...
def sort(self, fieldname, key=lambda x: x, desc=False, inplace=False): """ This matches Python's built-in sorting signature closely. By default, a new DataTable will be returned and the original will not be mutated. If preferred, specify `inplace=True` in order to mutate the ori...
0, module; 1, function_definition; 2, function_name:intersectingIntervalIterator; 3, parameters; 4, block; 5, identifier:self; 6, identifier:start; 7, identifier:end; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, for_statement; 12, comment:""" Get an iterator which will iterate ove...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 8, 12; 9, 13; 10, 14; 11, 15; 11, 16; 11, 17; 13, 18; 13, 19; 14, 20; 14, 21; 17, 22; 19, 23; 19, 24; 20, 25; 20, 26; 21, 27; 22, 28; 23, 29; 23, 30; 24, 31; 24, 32; 27, 33; 27, 34; 28, 35; 34, 36; 34, 37; 36, 38; 37, 39; 37, 40
def intersectingIntervalIterator(self, start, end): """ Get an iterator which will iterate over those objects in the tree which intersect the given interval - sorted in order of start index :param start: find intervals in the tree that intersect an interval with with this start index ...
0, module; 1, function_definition; 2, function_name:_sanitize_usecols; 3, parameters; 4, block; 5, identifier:usecols; 6, expression_statement; 7, if_statement; 8, try_statement; 9, expression_statement; 10, for_statement; 11, comment:# Remove duplicates:; 12, expression_statement; 13, expression_statement; 14, return_...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 6, 15; 7, 16; 7, 17; 8, 18; 8, 19; 9, 20; 10, 21; 10, 22; 10, 23; 12, 24; 13, 25; 14, 26; 16, 27; 16, 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; 26, 41; 26, 42; 29, 43; 30, 4...
def _sanitize_usecols(usecols): """Make a tuple of sorted integers and return it. Return None if usecols is None""" if usecols is None: return None try: pats = usecols.split(',') pats = [p.strip() for p in pats if p] except AttributeError: usecols = [int(c) for c in...
0, module; 1, function_definition; 2, function_name:binary_search; 3, parameters; 4, block; 5, identifier:data; 6, identifier:target; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, if_statement; 13, if_statement; 14, identifier:lo; 15, intege...
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; 7, 15; 8, 16; 8, 17; 9, 18; 10, 19; 11, 20; 12, 21; 12, 22; 13, 23; 13, 24; 13, 25; 13, 26; 19, 27; 19, 28; 20, 29; 20, 30; 21, 31; 21, 32; 22, 33; 23, 34; 23, 35; 24, 36; 25, 37; 25, 38; 26, 39; 26, 40; 28, 41; 28, 42; 28, 43; 30,...
def binary_search(data, target, lo=0, hi=None): """ Perform binary search on sorted list data for target. Returns int representing position of target in data. """ hi = hi if hi is not None else len(data) mid = (lo + hi) // 2 if hi < 2 or hi > len(data) or target > data[-1] or target < data[0...
0, module; 1, function_definition; 2, function_name:repr_feature; 3, parameters; 4, block; 5, identifier:feature; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, if_statement; 11, if_statement; 12, assert_statement; 13, identifier:max_keys; 14, integer:100; 15, identifier:...
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 4, 12; 6, 13; 6, 14; 7, 15; 7, 16; 8, 17; 8, 18; 9, 19; 10, 20; 10, 21; 11, 22; 11, 23; 11, 24; 11, 25; 12, 26; 12, 27; 19, 28; 20, 29; 20, 30; 21, 31; 22, 32; 22, 33; 23, 34; 24, 35; 24, 36; 25, 37; 27, 38; 30, 39; 30, 40; 31, 41; 31, 42; 33, 43; 33, ...
def repr_feature(feature, max_keys=100, indent=8, lexigraphic=False): ''' generate a pretty-printed string for a feature Currently implemented: * StringCounter @max_keys: truncate long counters @indent: indent multi-line displays by this many spaces @lexigraphic: instead of sorting cou...
0, module; 1, function_definition; 2, function_name:_getkey; 3, parameters; 4, block; 5, identifier:self; 6, identifier:args; 7, identifier:kwargs; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, for_statement; 12, expression_statement; 13, return_statement; 14, comment:"""Get hash key f...
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; 11, 18; 11, 19; 12, 20; 13, 21; 15, 22; 15, 23; 16, 24; 16, 25; 19, 26; 20, 27; 20, 28; 23, 29; 23, 30; 25, 31; 25, 32; 26, 33; 28, 34; 28, 35; 30, 36; 32, 37; 33, 38; 33, 39; 35, 40; 37, 41; 37, 42; 38, 43; ...
def _getkey(self, args, kwargs): """Get hash key from args and kwargs. args and kwargs must be hashable. :param tuple args: called vargs. :param dict kwargs: called keywords. :return: hash(tuple(args) + tuple((key, val) for key in sorted(kwargs)). :rtype: int.""" ...
0, module; 1, function_definition; 2, function_name:iterator; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, if_statement; 9, return_statement; 10, comment:""" If search has occurred and no ordering has occurred, decorate each result with the number of ...
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; 13, 20; 13, 21; 16, 22; 16, 23; 17, 24; 17, 25; 18, 26; 19, 27; 20, 28; 20, 29; 20, 30; 21, 31; 22, 32; 22, 33; 26, 34; 26, 35; 27, 36; 27, 37; 28, 38; 28, 39; 29, 40; 29, 41; 30, 42; 30, 43;...
def iterator(self): """ If search has occurred and no ordering has occurred, decorate each result with the number of search terms so that it can be sorted by the number of occurrence of terms. In the case of search fields that span model relationships, we cannot accurate...
0, module; 1, function_definition; 2, function_name:save_as_json; 3, parameters; 4, block; 5, typed_parameter; 6, default_parameter; 7, typed_default_parameter; 8, default_parameter; 9, default_parameter; 10, expression_statement; 11, if_statement; 12, if_statement; 13, expression_statement; 14, expression_statement; 1...
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; 5, 15; 5, 16; 6, 17; 6, 18; 7, 19; 7, 20; 7, 21; 8, 22; 8, 23; 9, 24; 9, 25; 10, 26; 11, 27; 11, 28; 12, 29; 12, 30; 13, 31; 14, 32; 16, 33; 18, 34; 20, 35; 25, 36; 28, 37; 28, 38; 30, 39; 31, 40; 31, 41; 32, 42; 32, 43; 37, 44; 38...
def save_as_json(total: list, name='data.json', sort_by: str = None, no_duplicate=False, order='asc'): """Save what you crawled as a json file. Args: total (list): Total of data you crawled. name (str, optional): Defaults to 'd...