sequence stringlengths 546 16.2k | code stringlengths 108 19.3k |
|---|---|
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 1, 16; 2, function_name:select_segment; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:segs; 6, identifier:segs_tips; 7, identifier:segs_undecided; 8, type; 8, 9; 9, generic_type; 9, 10; 9, 11; 10, identifier:Tuple; 11, type_parameter;... | def select_segment(self, segs, segs_tips, segs_undecided) -> Tuple[int, int]:
"""Out of a list of line segments, choose segment that has the most
distant second data point.
Assume the distance matrix Ddiff is sorted according to seg_idcs.
Compute all the distances.
Returns
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:unique_categories; 3, parameters; 3, 4; 4, identifier:categories; 5, block; 5, 6; 5, 8; 5, 17; 5, 34; 5, 56; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:categories; 11, c... | def unique_categories(categories):
"""Pass array-like categories, return sorted cleaned unique categories."""
categories = np.unique(categories)
categories = np.setdiff1d(categories, np.array(settings.categories_to_ignore))
categories = np.array(natsorted(categories, key=lambda v: v.upper()))
return... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:find_one_and_delete; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, identifier:filter; 6, default_parameter; 6, 7; 6, 8; 7, identifier:projection; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:sort; 1... | def find_one_and_delete(self, filter,
projection=None, sort=None, session=None, **kwargs):
"""Finds a single document and deletes it, returning the document.
>>> db.test.count_documents({'x': 1})
2
>>> db.test.find_one_and_delete({'x': 1})
{u'... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 6; 2, function_name:sort; 3, parameters; 3, 4; 4, identifier:lines; 5, comment; 6, block; 6, 7; 6, 9; 6, 10; 6, 17; 6, 27; 6, 57; 7, expression_statement; 7, 8; 8, comment; 9, comment; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 12, ide... | def sort(lines): # type: (List[str]) -> List[str]
"""Sort a YAML file in alphabetical order, keeping blocks together.
:param lines: array of strings (without newlines)
:return: sorted array of strings
"""
# make a copy of lines since we will clobber it
lines = list(lines)
new_lines = parse... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 6; 2, function_name:first_key; 3, parameters; 3, 4; 4, identifier:lines; 5, comment; 6, block; 6, 7; 6, 9; 7, expression_statement; 7, 8; 8, comment; 9, for_statement; 9, 10; 9, 11; 9, 12; 9, 44; 10, identifier:line; 11, identifier:lines; 12, block; 12, 13; ... | def first_key(lines): # type: (List[str]) -> str
"""Returns a string representing the sort key of a block.
The sort key is the first YAML key we encounter, ignoring comments, and
stripping leading quotes.
>>> print(test)
# some comment
'foo': true
>>> first_key(test)
'foo'
"""
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:geoadd; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 11; 4, identifier:self; 5, identifier:key; 6, identifier:longitude; 7, identifier:latitude; 8, identifier:member; 9, list_splat_pattern; 9, 10; 10, identifier:args; 11, dictionary_s... | def geoadd(self, key, longitude, latitude, member, *args, **kwargs):
"""Add one or more geospatial items in the geospatial index represented
using a sorted set.
:rtype: int
"""
return self.execute(
b'GEOADD', key, longitude, latitude, member, *args, **kwargs
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 31; 2, function_name:georadius; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 12; 3, 13; 3, 16; 3, 19; 3, 22; 3, 25; 3, 28; 4, identifier:self; 5, identifier:key; 6, identifier:longitude; 7, identifier:latitude; 8, identifier:radius; 9, default_parameter; ... | def georadius(self, key, longitude, latitude, radius, unit='m', *,
with_dist=False, with_hash=False, with_coord=False,
count=None, sort=None, encoding=_NOTSET):
"""Query a sorted set representing a geospatial index to fetch members
matching a given maximum distance fr... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 30; 2, function_name:georadiusbymember; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 3, 27; 4, identifier:self; 5, identifier:key; 6, identifier:member; 7, identifier:radius; 8, default_parameter; 8, 9; 8, 10; 9, identifie... | def georadiusbymember(self, key, member, radius, unit='m', *,
with_dist=False, with_hash=False, with_coord=False,
count=None, sort=None, encoding=_NOTSET):
"""Query a sorted set representing a geospatial index to fetch members
matching a given maximum ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 26; 2, function_name:sort; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 4, identifier:self; 5, identifier:key; 6, list_splat_pattern; 6, 7; 7, identifier:get_patterns; 8, default_parameter; 8, 9; 8, 10; 9, identifier:by; 10, None; 11, ... | def sort(self, key, *get_patterns,
by=None, offset=None, count=None,
asc=None, alpha=False, store=None):
"""Sort the elements in a list, set or sorted set."""
args = []
if by is not None:
args += [b'BY', by]
if offset is not None and count is not Non... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:zadd; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 10; 4, identifier:self; 5, identifier:key; 6, identifier:score; 7, identifier:member; 8, list_splat_pattern; 8, 9; 9, identifier:pairs; 10, default_parameter; 10, 11; 10, 12; 11, identifier... | def zadd(self, key, score, member, *pairs, exist=None):
"""Add one or more members to a sorted set or update its score.
:raises TypeError: score not int or float
:raises TypeError: length of pairs is not even number
"""
if not isinstance(score, (int, float)):
raise T... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 22; 2, function_name:zcount; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 12; 3, 18; 3, 19; 4, identifier:self; 5, identifier:key; 6, default_parameter; 6, 7; 6, 8; 7, identifier:min; 8, call; 8, 9; 8, 10; 9, identifier:float; 10, argument_list; 10, 11; 11, string:'-inf'; ... | def zcount(self, key, min=float('-inf'), max=float('inf'),
*, exclude=None):
"""Count the members in a sorted set with scores
within the given values.
:raises TypeError: min or max is not float or int
:raises ValueError: if min greater than max
"""
if not ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:zincrby; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:key; 6, identifier:increment; 7, identifier:member; 8, block; 8, 9; 8, 11; 8, 26; 8, 38; 9, expression_statement; 9, 10; 10, comment; 11, if_statement; 11, 12; 11... | def zincrby(self, key, increment, member):
"""Increment the score of a member in a sorted set.
:raises TypeError: increment is not float or int
"""
if not isinstance(increment, (int, float)):
raise TypeError("increment argument must be int or float")
fut = self.execu... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:zrem; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:key; 6, identifier:member; 7, list_splat_pattern; 7, 8; 8, identifier:members; 9, block; 9, 10; 9, 12; 10, expression_statement; 10, 11; 11, comment; 12, return_stat... | def zrem(self, key, member, *members):
"""Remove one or more members from a sorted set."""
return self.execute(b'ZREM', key, member, *members) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:zremrangebylex; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, identifier:key; 6, default_parameter; 6, 7; 6, 8; 7, identifier:min; 8, string:b'-'; 9, default_parameter; 9, 10; 9, 11; 10, identifier:max; 11, string... | def zremrangebylex(self, key, min=b'-', max=b'+',
include_min=True, include_max=True):
"""Remove all members in a sorted set between the given
lexicographical range.
:raises TypeError: if min is not bytes
:raises TypeError: if max is not bytes
"""
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:zremrangebyrank; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:key; 6, identifier:start; 7, identifier:stop; 8, block; 8, 9; 8, 11; 8, 24; 8, 37; 9, expression_statement; 9, 10; 10, comment; 11, if_statement; 11, 12; ... | def zremrangebyrank(self, key, start, stop):
"""Remove all members in a sorted set within the given indexes.
:raises TypeError: if start is not int
:raises TypeError: if stop is not int
"""
if not isinstance(start, int):
raise TypeError("start argument must be int")
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 22; 2, function_name:zremrangebyscore; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 12; 3, 18; 3, 19; 4, identifier:self; 5, identifier:key; 6, default_parameter; 6, 7; 6, 8; 7, identifier:min; 8, call; 8, 9; 8, 10; 9, identifier:float; 10, argument_list; 10, 11; 11, strin... | def zremrangebyscore(self, key, min=float('-inf'), max=float('inf'),
*, exclude=None):
"""Remove all members in a sorted set within the given scores.
:raises TypeError: if min or max is not int or float
"""
if not isinstance(min, (int, float)):
raise... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:zrevrange; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 4, identifier:self; 5, identifier:key; 6, identifier:start; 7, identifier:stop; 8, default_parameter; 8, 9; 8, 10; 9, identifier:withscores; 10, False; 11, default_parameter; 11, 1... | def zrevrange(self, key, start, stop, withscores=False, encoding=_NOTSET):
"""Return a range of members in a sorted set, by index,
with scores ordered from high to low.
:raises TypeError: if start or stop is not int
"""
if not isinstance(start, int):
raise TypeError(... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 34; 2, function_name:zrevrangebyscore; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 12; 3, 18; 3, 19; 3, 22; 3, 25; 3, 28; 3, 31; 4, identifier:self; 5, identifier:key; 6, default_parameter; 6, 7; 6, 8; 7, identifier:max; 8, call; 8, 9; 8, 10; 9, identifier:float; 10, argu... | def zrevrangebyscore(self, key, max=float('inf'), min=float('-inf'),
*, exclude=None, withscores=False,
offset=None, count=None, encoding=_NOTSET):
"""Return a range of members in a sorted set, by score,
with scores ordered from high to low.
:ra... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:zscore; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:key; 6, identifier:member; 7, block; 7, 8; 7, 10; 7, 21; 8, expression_statement; 8, 9; 9, comment; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 12,... | def zscore(self, key, member):
"""Get the score associated with the given member in a sorted set."""
fut = self.execute(b'ZSCORE', key, member)
return wait_convert(fut, optional_int_or_float) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:zunionstore; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 9; 3, 12; 4, identifier:self; 5, identifier:destkey; 6, identifier:key; 7, list_splat_pattern; 7, 8; 8, identifier:keys; 9, default_parameter; 9, 10; 9, 11; 10, identifier:with_weights; 11... | def zunionstore(self, destkey, key, *keys,
with_weights=False, aggregate=None):
"""Add multiple sorted sets and store result in a new key."""
keys = (key,) + keys
numkeys = len(keys)
args = []
if with_weights:
assert all(isinstance(val, (list, tupl... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:zscan; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:key; 6, default_parameter; 6, 7; 6, 8; 7, identifier:cursor; 8, integer:0; 9, default_parameter; 9, 10; 9, 11; 10, identifier:match; 11, None; 12, default_p... | def zscan(self, key, cursor=0, match=None, count=None):
"""Incrementally iterate sorted sets elements and associated scores."""
args = []
if match is not None:
args += [b'MATCH', match]
if count is not None:
args += [b'COUNT', count]
fut = self.execute(b'Z... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:zpopmin; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 10; 4, identifier:self; 5, identifier:key; 6, default_parameter; 6, 7; 6, 8; 7, identifier:count; 8, None; 9, keyword_separator; 10, default_parameter; 10, 11; 10, 12; 11, identifier:encoding;... | def zpopmin(self, key, count=None, *, encoding=_NOTSET):
"""Removes and returns up to count members with the lowest scores
in the sorted set stored at key.
:raises TypeError: if count is not int
"""
if count is not None and not isinstance(count, int):
raise TypeError... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:zpopmax; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 10; 4, identifier:self; 5, identifier:key; 6, default_parameter; 6, 7; 6, 8; 7, identifier:count; 8, None; 9, keyword_separator; 10, default_parameter; 10, 11; 10, 12; 11, identifier:encoding;... | def zpopmax(self, key, count=None, *, encoding=_NOTSET):
"""Removes and returns up to count members with the highest scores
in the sorted set stored at key.
:raises TypeError: if count is not int
"""
if count is not None and not isinstance(count, int):
raise TypeErro... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:uniq; 3, parameters; 3, 4; 4, identifier:container; 5, block; 5, 6; 5, 8; 5, 109; 6, expression_statement; 6, 7; 7, comment; 8, try_statement; 8, 9; 8, 29; 9, block; 9, 10; 10, return_statement; 10, 11; 11, comparison_operator:==; 11, 12; 11, 2... | def uniq(container):
"""
Check if all of a container's elements are unique.
Successively tries first to rely that the elements are hashable, then
falls back on them being sortable, and finally falls back on brute
force.
"""
try:
return len(set(unbool(i) for i in container)) == len... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:split_traversal; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:traversal; 5, identifier:edges; 6, default_parameter; 6, 7; 6, 8; 7, identifier:edges_hash; 8, None; 9, block; 9, 10; 9, 12; 9, 26; 9, 27; 9, 49; 9, 50; 9, 70; 9, 71; 9, 88; 9, 89;... | def split_traversal(traversal,
edges,
edges_hash=None):
"""
Given a traversal as a list of nodes, split the traversal
if a sequential index pair is not in the given edges.
Parameters
--------------
edges : (n, 2) int
Graph edge indexes
traversa... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:fill_traversals; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:traversals; 5, identifier:edges; 6, default_parameter; 6, 7; 6, 8; 7, identifier:edges_hash; 8, None; 9, block; 9, 10; 9, 12; 9, 13; 9, 27; 9, 28; 9, 37; 9, 38; 9, 52; 9, 53; 9, 67... | def fill_traversals(traversals, edges, edges_hash=None):
"""
Convert a traversal of a list of edges into a sequence of
traversals where every pair of consecutive node indexes
is an edge in a passed edge list
Parameters
-------------
traversals : sequence of (m,) int
Node indexes of t... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:hashable_rows; 3, parameters; 3, 4; 3, 5; 4, identifier:data; 5, default_parameter; 5, 6; 5, 7; 6, identifier:digits; 7, None; 8, block; 8, 9; 8, 11; 8, 12; 8, 27; 8, 28; 8, 38; 8, 39; 8, 51; 8, 52; 8, 53; 8, 168; 8, 169; 8, 192; 8, 193; 8, 213... | def hashable_rows(data, digits=None):
"""
We turn our array into integers based on the precision
given by digits and then put them in a hashable format.
Parameters
---------
data : (n, m) array
Input data
digits : int or None
How many digits to add to hash if data is floating po... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:interpolate_nans_1d; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:x; 5, identifier:y; 6, default_parameter; 6, 7; 6, 8; 7, identifier:kind; 8, string:'linear'; 9, block; 9, 10; 9, 12; 9, 21; 9, 27; 9, 33; 9, 42; 9, 119; 10, expression_stateme... | def interpolate_nans_1d(x, y, kind='linear'):
"""Interpolate NaN values in y.
Interpolate NaN values in the y dimension. Works with unsorted x values.
Parameters
----------
x : array-like
1-dimensional array of numeric x-values
y : array-like
1-dimensional array of numeric y-va... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:interpolate_1d; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 8; 4, identifier:x; 5, identifier:xp; 6, list_splat_pattern; 6, 7; 7, identifier:args; 8, dictionary_splat_pattern; 8, 9; 9, identifier:kwargs; 10, block; 10, 11; 10, 13; 10, 14; 10, 26; 10, ... | def interpolate_1d(x, xp, *args, **kwargs):
r"""Interpolates data with any shape over a specified axis.
Interpolation over a specified axis for arrays of any shape.
Parameters
----------
x : array-like
1-D array of desired interpolated values.
xp : array-like
The x-coordinates... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:log_interpolate_1d; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 8; 4, identifier:x; 5, identifier:xp; 6, list_splat_pattern; 6, 7; 7, identifier:args; 8, dictionary_splat_pattern; 8, 9; 9, identifier:kwargs; 10, block; 10, 11; 10, 13; 10, 14; 10, 26; ... | def log_interpolate_1d(x, xp, *args, **kwargs):
r"""Interpolates data with logarithmic x-scale over a specified axis.
Interpolation on a logarithmic x-scale for interpolation values in pressure coordintates.
Parameters
----------
x : array-like
1-D array of desired interpolated values.
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_find_append_zero_crossings; 3, parameters; 3, 4; 3, 5; 4, identifier:x; 5, identifier:y; 6, block; 6, 7; 6, 9; 6, 10; 6, 40; 6, 51; 6, 62; 6, 63; 6, 72; 6, 78; 6, 84; 6, 85; 6, 100; 6, 106; 6, 112; 7, expression_statement; 7, 8; 8, comment; 9,... | def _find_append_zero_crossings(x, y):
r"""
Find and interpolate zero crossings.
Estimate the zero crossings of an x,y series and add estimated crossings to series,
returning a sorted array with no duplicate values.
Parameters
----------
x : `pint.Quantity`
x values of data
y :... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:sort_ordered_objects; 3, parameters; 3, 4; 3, 5; 4, identifier:items; 5, default_parameter; 5, 6; 5, 7; 6, identifier:getter; 7, lambda; 7, 8; 7, 10; 8, lambda_parameters; 8, 9; 9, identifier:x; 10, identifier:x; 11, block; 11, 12; 11, 14; 12,... | def sort_ordered_objects(items, getter=lambda x: x):
"""Sort an iterable of OrderedBase instances.
Args:
items (iterable): the objects to sort
getter (callable or None): a function to extract the OrderedBase instance from an object.
Examples:
>>> sort_ordered_objects([x, y, z])
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:remove_fewwords_paragraphs; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 25; 5, 31; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:all_nodes; 11, call; ... | def remove_fewwords_paragraphs(self):
"""\
remove paragraphs that have less than x number of words,
would indicate that it's some sort of link
"""
all_nodes = self.parser.getElementsByTags(self.get_top_node(), ['*'])
all_nodes.reverse()
for el in all_nodes:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:compare_baselines; 3, parameters; 3, 4; 3, 5; 4, identifier:old_baseline_filename; 5, identifier:new_baseline_filename; 6, block; 6, 7; 6, 9; 6, 16; 6, 23; 6, 30; 6, 35; 6, 40; 6, 41; 6, 49; 6, 56; 6, 60; 6, 67; 7, expression_statement; 7, 8; 8... | def compare_baselines(old_baseline_filename, new_baseline_filename):
"""
This function enables developers to more easily configure plugin
settings, by comparing two generated baselines and highlighting
their differences.
For effective use, a few assumptions are made:
1. Baselines are sorted... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_GetEventIdentifiers; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:event; 6, block; 6, 7; 6, 9; 6, 13; 6, 24; 6, 31; 6, 153; 6, 154; 6, 155; 6, 193; 6, 203; 6, 212; 7, expression_statement; 7, 8; 8, comment; 9, expression_statem... | def _GetEventIdentifiers(self, event):
"""Retrieves different identifiers of the event.
Every event contains event data, which consists of attributes and values.
These attributes and values can be represented as a string and used for
sorting and uniquely identifying events. This function determines mul... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:PopEvents; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 16; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:event; 11, call; 11, 12; 11, 15; 12, attribut... | def PopEvents(self):
"""Pops events from the heap.
Yields:
EventObject: event.
"""
event = self.PopEvent()
while event:
yield event
event = self.PopEvent() |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_CheckStatusAnalysisProcess; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:pid; 6, block; 6, 7; 6, 9; 6, 10; 6, 11; 6, 18; 6, 268; 6, 277; 7, expression_statement; 7, 8; 8, comment; 9, comment; 10, comment; 11, expression_stateme... | def _CheckStatusAnalysisProcess(self, pid):
"""Checks the status of an analysis process.
Args:
pid (int): process ID (PID) of a registered analysis process.
Raises:
KeyError: if the process is not registered with the engine.
"""
# TODO: Refactor this method, simplify and separate conce... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:_ExportEvent; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:output_module; 6, identifier:event; 7, default_parameter; 7, 8; 7, 9; 8, identifier:deduplicate_events; 9, True; 10, block; 10, 11; 10, 13; 10, 40; 11, expr... | def _ExportEvent(self, output_module, event, deduplicate_events=True):
"""Exports an event using an output module.
Args:
output_module (OutputModule): output module.
event (EventObject): event.
deduplicate_events (Optional[bool]): True if events should be
deduplicated.
"""
i... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_FlushExportBuffer; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:output_module; 6, default_parameter; 6, 7; 6, 8; 7, identifier:deduplicate_events; 8, True; 9, block; 9, 10; 9, 12; 9, 16; 9, 20; 9, 24; 9, 34; 9, 131; 10, e... | def _FlushExportBuffer(self, output_module, deduplicate_events=True):
"""Flushes buffered events and writes them to the output module.
Args:
output_module (OutputModule): output module.
deduplicate_events (Optional[bool]): True if events should be
deduplicated.
"""
last_macb_group... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_MergeEventTag; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:storage_writer; 6, identifier:attribute_container; 7, block; 7, 8; 7, 10; 7, 18; 7, 26; 7, 31; 7, 32; 7, 33; 7, 45; 7, 66; 8, expression_statement; 8, 9; 9, comm... | def _MergeEventTag(self, storage_writer, attribute_container):
"""Merges an event tag with the last stored event tag.
If there is an existing event the provided event tag is updated with
the contents of the existing one. After which the event tag index is
updated.
Args:
storage_writer (Stora... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_StartAnalysisProcesses; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:storage_writer; 6, identifier:analysis_plugins; 7, block; 7, 8; 7, 10; 7, 17; 7, 65; 8, expression_statement; 8, 9; 9, comment; 10, expression_statement... | def _StartAnalysisProcesses(self, storage_writer, analysis_plugins):
"""Starts the analysis processes.
Args:
storage_writer (StorageWriter): storage writer.
analysis_plugins (dict[str, AnalysisPlugin]): analysis plugins that
should be run and their names.
"""
logger.info('Starting... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_StopAnalysisProcesses; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:abort; 7, False; 8, block; 8, 9; 8, 11; 8, 18; 8, 24; 8, 25; 8, 26; 8, 27; 8, 37; 8, 66; 8, 67; 8, 68; 8, 92; 8, 93; 8, 104; ... | def _StopAnalysisProcesses(self, abort=False):
"""Stops the analysis processes.
Args:
abort (bool): True to indicated the stop is issued on abort.
"""
logger.debug('Stopping analysis processes.')
self._StopMonitoringProcesses()
# Note that multiprocessing.Queue is very sensitive regardin... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_UpdateForemanProcessStatus; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 20; 5, 31; 5, 80; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:used_memory; ... | def _UpdateForemanProcessStatus(self):
"""Update the foreman process status."""
used_memory = self._process_information.GetUsedMemory() or 0
display_name = getattr(self._merge_task, 'identifier', '')
self._processing_status.UpdateForemanStatus(
self._name, self._status, self._pid, used_memory,... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:workers_status; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 6, expression_statement; 6, 7; 7, comment; 8, return_statement; 8, 9; 9, list_comprehension; 9, 10; 9, 15; 10, subscript; 10, 11; 10, 14; 11, attribute; 11, 12; 11, ... | def workers_status(self):
"""The worker status objects sorted by identifier."""
return [self._workers_status[identifier]
for identifier in sorted(self._workers_status.keys())] |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:ProcessStorage; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 17; 5, 28; 5, 39; 5, 50; 5, 70; 5, 83; 5, 102; 5, 113; 5, 119; 5, 127; 5, 135; 5, 145; 5, 155; 5, 165; 5, 169; 5, 267; 5, 339; 5, 345; 5, 354; 5, 417; 5, 430; 6, ... | def ProcessStorage(self):
"""Processes a plaso storage file.
Raises:
BadConfigOption: when a configuration parameter fails validation.
RuntimeError: if a non-recoverable situation is encountered.
"""
self._CheckStorageFile(self._storage_file_path)
self._status_view.SetMode(self._status... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:sort_state; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:best_hyp_indices; 7, type; 7, 8; 8, attribute; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:mx; 11, identifier:nd; 12, identifi... | def sort_state(self, best_hyp_indices: mx.nd.NDArray):
"""
Sorts states according to k-best order from last step in beam search.
"""
self.states = [mx.nd.take(ds, best_hyp_indices) for ds in self.states] |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 1, 27; 2, function_name:rerank; 3, parameters; 3, 4; 3, 5; 3, 15; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:hypotheses; 7, type; 7, 8; 8, generic_type; 8, 9; 8, 10; 9, identifier:Dict; 10, type_parameter; 10, 11; 10, 13; 11, type; 11, 1... | def rerank(self, hypotheses: Dict[str, Any], reference: str) -> Dict[str, Any]:
"""
Reranks a set of hypotheses that belong to one single reference
translation. Uses stable sorting.
:param hypotheses: Nbest translations.
:param reference: A single string with the actual referenc... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:load; 3, parameters; 3, 4; 3, 5; 3, 9; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:path; 7, type; 7, 8; 8, identifier:str; 9, typed_default_parameter; 9, 10; 9, 11; 9, 17; 10, identifier:k; 11, type; 11, 12; 12, generic_t... | def load(self, path: str, k: Optional[int] = None):
"""
Load lexicon from Numpy array file. The top-k target ids will be sorted by increasing target id.
:param path: Path to Numpy array file.
:param k: Optionally load less items than stored in path.
"""
load_time_start =... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 1, 15; 2, function_name:get_trg_ids; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:src_ids; 7, type; 7, 8; 8, attribute; 8, 9; 8, 10; 9, identifier:np; 10, identifier:ndarray; 11, type; 11, 12; 12, attribute; 12, ... | def get_trg_ids(self, src_ids: np.ndarray) -> np.ndarray:
"""
Lookup possible target ids for input sequence of source ids.
:param src_ids: Sequence(s) of source ids (any shape).
:return: Possible target ids for source (unique sorted, always includes special symbols).
"""
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:choice; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:obj; 6, block; 6, 7; 6, 9; 6, 26; 6, 43; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:tree_id; 12,... | def choice(self, obj):
"""
Overloads the choice method to add the position
of the object in the tree for future sorting.
"""
tree_id = getattr(obj, self.queryset.model._mptt_meta.tree_id_attr, 0)
left = getattr(obj, self.queryset.model._mptt_meta.left_attr, 0)
ret... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_best_dataset_key; 3, parameters; 3, 4; 3, 5; 4, identifier:key; 5, identifier:choices; 6, block; 6, 7; 6, 9; 6, 10; 6, 66; 6, 115; 6, 170; 6, 217; 6, 264; 7, expression_statement; 7, 8; 8, comment; 9, comment; 10, if_statement; 10, 11; 10, ... | def get_best_dataset_key(key, choices):
"""Choose the "best" `DatasetID` from `choices` based on `key`.
The best key is chosen based on the follow criteria:
1. Central wavelength is nearest to the `key` wavelength if
specified.
2. Least modified dataset if `modifiers` is `None` in `... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 27; 2, function_name:get_key; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 4, identifier:key; 5, identifier:key_container; 6, default_parameter; 6, 7; 6, 8; 7, identifier:num_results; 8, integer:1; 9, default_parameter; 9, 10; 9, 11; 1... | def get_key(key, key_container, num_results=1, best=True,
resolution=None, calibration=None, polarization=None,
level=None, modifiers=None):
"""Get the fully-specified key best matching the provided key.
Only the best match is returned if `best` is `True` (default). See
`get_best_da... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:group_files; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:files_to_sort; 5, default_parameter; 5, 6; 5, 7; 6, identifier:reader; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:time_threshold; 10, integer:10; 1... | def group_files(files_to_sort, reader=None, time_threshold=10,
group_keys=None, ppp_config_dir=None, reader_kwargs=None):
"""Group series of files by file pattern information.
By default this will group files by their filename ``start_time``
assuming it exists in the pattern. By passing the... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sorted_filetype_items; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 12; 5, 27; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:processed_types; 11, list:... | def sorted_filetype_items(self):
"""Sort the instance's filetypes in using order."""
processed_types = []
file_type_items = deque(self.config['file_types'].items())
while len(file_type_items):
filetype, filetype_info = file_type_items.popleft()
requirements = fil... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:combine_hashes; 3, parameters; 3, 4; 4, identifier:hashes; 5, block; 5, 6; 5, 8; 5, 14; 5, 35; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:hasher; 11, call; 11, 12; 11, 1... | def combine_hashes(hashes):
"""A simple helper function to combine other hashes. Sorts the hashes before rolling them in."""
hasher = sha1()
for h in sorted(hashes):
h = ensure_binary(h)
hasher.update(h)
return hasher.hexdigest() if PY3 else hasher.hexdigest().decode('utf-8') |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 31; 2, function_name:register_jvm_tool; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 3, 25; 3, 28; 4, identifier:cls; 5, identifier:register; 6, identifier:key; 7, default_parameter; 7, 8; 7, 9; 8, identifier:classpath_spec; 9, None; 1... | def register_jvm_tool(cls,
register,
key,
classpath_spec=None,
main=None,
custom_rules=None,
fingerprint=True,
classpath=None,
h... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_available_urls; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:urls; 6, block; 6, 7; 6, 9; 6, 24; 6, 42; 6, 43; 6, 72; 6, 87; 6, 105; 6, 119; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assig... | def get_available_urls(self, urls):
"""Return reachable urls sorted by their ping times."""
baseurl_to_urls = {self._baseurl(url): url for url in urls}
pingtimes = self._pinger.pings(list(baseurl_to_urls.keys())) # List of pairs (host, time in ms).
self._log.debug('Artifact cache server ping times: {}'... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:iterate; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:scopes; 6, block; 6, 7; 6, 9; 6, 26; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:scope_infos; 12... | def iterate(self, scopes):
"""Yields ScopeInfo instances for the specified scopes, plus relevant related scopes.
Relevant scopes are:
- All tasks in a requested goal.
- All subsystems tied to a request scope.
Yields in a sensible order: Sorted by scope, but with subsystems tied to a request sc... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_expand_tasks; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:scopes; 6, block; 6, 7; 6, 9; 6, 16; 6, 69; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:ex... | def _expand_tasks(self, scopes):
"""Add all tasks in any requested goals.
Returns the requested scopes, plus the added tasks, sorted by scope name.
"""
expanded_scopes = set(scopes)
for scope, info in self._scope_to_info.items():
if info.category == ScopeInfo.TASK:
outer = enclosing_s... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_all; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 6, expression_statement; 6, 7; 7, comment; 8, return_statement; 8, 9; 9, list_comprehension; 9, 10; 9, 30; 10, dictionary; 10, 11; 10, 16; 10, 21; 11, pair; 11, 12; 11, 13;... | def get_all(self):
"""Returns all the timings, sorted in decreasing order.
Each value is a dict: { path: <path>, timing: <timing in seconds> }
"""
return [{'label': x[0], 'timing': x[1], 'is_tool': x[0] in self._tool_labels}
for x in sorted(self._timings_by_path.items(), key=lambda x: x[1],... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:all; 3, parameters; 4, block; 4, 5; 4, 7; 5, expression_statement; 5, 6; 6, comment; 7, return_statement; 7, 8; 8, list_comprehension; 8, 9; 8, 10; 8, 24; 9, identifier:goal; 10, for_in_clause; 10, 11; 10, 14; 11, pattern_list; 11, 12; 11, 13; ... | def all():
"""Returns all active registered goals, sorted alphabetically by name.
:API: public
"""
return [goal for _, goal in sorted(Goal._goal_by_name.items()) if goal.active] |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:select_best_url; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 16; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:best_url; 11, subscript; 11, 12; 11, 15... | def select_best_url(self):
"""Select `best` url.
Since urls are pre-sorted w.r.t. their ping times, we simply return the first element
from the list. And we always return the same url unless we observe greater than max
allowed number of consecutive failures. In this case, we would return the next `best... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_topological_sort; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:targets; 6, block; 6, 7; 6, 9; 6, 16; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:targ... | def _topological_sort(self, targets):
"""Topologically order a list of targets"""
target_set = set(targets)
return [t for t in reversed(sort_targets(targets)) if t in target_set] |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sortmerna_detailed_barplot; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 9; 5, 15; 5, 21; 5, 56; 5, 75; 5, 76; 5, 89; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10... | def sortmerna_detailed_barplot (self):
""" Make the HighCharts HTML to plot the sortmerna rates """
# Specify the order of the different possible categories
keys = OrderedDict()
metrics = set()
for sample in self.sortmerna:
for key in self.sortmerna[sample]:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_short_chrom; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:chrom; 6, block; 6, 7; 6, 9; 6, 17; 6, 35; 6, 45; 6, 70; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, i... | def _short_chrom(self, chrom):
"""Plot standard chromosomes + X, sorted numerically.
Allows specification from a list of chromosomes via config
for non-standard genomes.
"""
default_allowed = set(["X"])
allowed_chroms = set(getattr(config, "goleft_indexcov_config", {}).g... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:deepvalues; 3, parameters; 3, 4; 4, identifier:mapping; 5, block; 5, 6; 5, 8; 5, 15; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:values; 11, call; 11, 12; 11, 13; 12, ide... | def deepvalues(mapping):
"""Iterates over nested mapping, depth-first, in sorted order by key."""
values = vals_sorted_by_key(mapping)
for obj in values:
mapping = False
try:
obj.items
except AttributeError:
pass
else:
mapping = True
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:values; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 6, expression_statement; 6, 7; 7, comment; 8, return_statement; 8, 9; 9, list_comprehension; 9, 10; 9, 19; 10, call; 10, 11; 10, 16; 11, attribute; 11, 12; 11, 15; 12, attri... | def values(self):
"""Return a list of all the message's header values.
These will be sorted in the order they appeared in the original
message, or were added to the message, and may contain duplicates.
Any fields deleted and re-inserted are always appended to the header
list.
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:items; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 6, expression_statement; 6, 7; 7, comment; 8, return_statement; 8, 9; 9, list_comprehension; 9, 10; 9, 21; 10, tuple; 10, 11; 10, 12; 11, identifier:k; 12, call; 12, 13; 12, ... | def items(self):
"""Get all the message's header fields and values.
These will be sorted in the order they appeared in the original
message, or were added to the message, and may contain duplicates.
Any fields deleted and re-inserted are always appended to the header
list.
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_all; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:name; 6, default_parameter; 6, 7; 6, 8; 7, identifier:failobj; 8, None; 9, block; 9, 10; 9, 12; 9, 16; 9, 24; 9, 56; 9, 62; 10, expression_statement; 10, 11; 11, commen... | def get_all(self, name, failobj=None):
"""Return a list of all the values for the named field.
These will be sorted in the order they appeared in the original
message, and may contain duplicates. Any fields deleted and
re-inserted are always appended to the header list.
If no ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:setup; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:job; 5, identifier:input_file_id; 6, identifier:n; 7, identifier:down_checkpoints; 8, block; 8, 9; 8, 11; 8, 12; 8, 21; 9, expression_statement; 9, 10; 10, comment; 11, comment; 12, ex... | def setup(job, input_file_id, n, down_checkpoints):
"""Sets up the sort.
Returns the FileID of the sorted file
"""
# Write the input file to the file store
job.fileStore.logToMaster("Starting the merge sort")
return job.addChildJobFn(down,
input_file_id, n,
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:down; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:job; 5, identifier:input_file_id; 6, identifier:n; 7, identifier:down_checkpoints; 8, block; 8, 9; 8, 11; 8, 12; 8, 26; 8, 37; 9, expression_statement; 9, 10; 10, comment; 11, comment; ... | def down(job, input_file_id, n, down_checkpoints):
"""Input is a file and a range into that file to sort and an output location in which
to write the sorted file.
If the range is larger than a threshold N the range is divided recursively and
a follow on job is then created which merges back the results.... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort; 3, parameters; 3, 4; 3, 5; 4, identifier:in_file; 5, identifier:out_file; 6, block; 6, 7; 6, 9; 6, 17; 6, 25; 6, 31; 6, 37; 6, 45; 6, 56; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 1... | def sort(in_file, out_file):
"""Sorts the given file.
"""
filehandle = open(in_file, 'r')
lines = filehandle.readlines()
filehandle.close()
lines.sort()
filehandle = open(out_file, 'w')
for line in lines:
filehandle.write(line)
filehandle.close() |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:merge; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:filehandle_1; 5, identifier:filehandle_2; 6, identifier:output_filehandle; 7, block; 7, 8; 7, 10; 7, 18; 7, 57; 8, expression_statement; 8, 9; 9, comment; 10, expression_statement; 10, 11; 1... | def merge(filehandle_1, filehandle_2, output_filehandle):
"""Merges together two files maintaining sorted order.
"""
line2 = filehandle_2.readline()
for line1 in filehandle_1.readlines():
while line2 != '' and line2 <= line1:
output_filehandle.write(line2)
line2 = filehan... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:decorateSubHeader; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:title; 5, identifier:columnWidths; 6, identifier:options; 7, block; 7, 8; 7, 10; 7, 18; 8, expression_statement; 8, 9; 9, comment; 10, expression_statement; 10, 11; 11, assignmen... | def decorateSubHeader(title, columnWidths, options):
""" Add a marker to the correct field if the TITLE is sorted on.
"""
title = title.lower()
if title != options.sortCategory:
s = "| %*s%*s%*s%*s%*s " % (
columnWidths.getWidth(title, "min"), "min",
columnWidths.getWidth... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sortJobs; 3, parameters; 3, 4; 3, 5; 4, identifier:jobTypes; 5, identifier:options; 6, block; 6, 7; 6, 9; 6, 28; 6, 36; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:lo... | def sortJobs(jobTypes, options):
""" Return a jobTypes all sorted.
"""
longforms = {"med": "median",
"ave": "average",
"min": "min",
"total": "total",
"max": "max",}
sortField = longforms[options.sortField]
if (options.sortCategory ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_sort_tau_by_y; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:y; 6, block; 6, 7; 6, 9; 6, 10; 6, 20; 6, 28; 6, 41; 6, 56; 6, 64; 6, 75; 6, 87; 6, 107; 7, expression_statement; 7, 8; 8, comment; 9, comment; 10, expression_statemen... | def _sort_tau_by_y(self, y):
"""Sort tau matrix by dependece with variable y.
Args:
:param y: index of variable of intrest
:type y: int
"""
# first column is the variable of interest
tau_y = self.tau_matrix[:, y]
tau_y[y] = np.NaN
temp = ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_edge; 3, parameters; 3, 4; 4, identifier:edges; 5, block; 5, 6; 5, 8; 6, expression_statement; 6, 7; 7, comment; 8, return_statement; 8, 9; 9, call; 9, 10; 9, 11; 10, identifier:sorted; 11, argument_list; 11, 12; 11, 13; 12, identifier:edg... | def sort_edge(edges):
"""Sort iterable of edges first by left node indices then right.
Args:
edges(list[Edge]): List of edges to be sorted.
Returns:
list[Edge]: Sorted list by left and right node indices.
"""
return sorted(edges, key=lambda x: (x.L, x.R)... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 25; 2, function_name:stanc; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 4, default_parameter; 4, 5; 4, 6; 5, identifier:file; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:charset; 9, string:'utf-8'; 10, default_parameter; 10, 11; 10, ... | def stanc(file=None, charset='utf-8', model_code=None, model_name="anon_model",
include_paths=None, verbose=False, obfuscate_model_name=True):
"""Translate Stan model specification into C++ code.
Parameters
----------
file : {string, file}, optional
If filename, the string passed as a... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:suggestion_list; 3, parameters; 3, 4; 3, 8; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:input_; 6, type; 6, 7; 7, identifier:str; 8, typed_parameter; 8, 9; 8, 10; 9, identifier:options; 10, type; 10, 11; 11, generic_type; 11, 12; 11, 13; 12,... | def suggestion_list(input_: str, options: Collection[str]):
"""Get list with suggestions for a given input.
Given an invalid input string and list of valid options, returns a filtered list
of valid options sorted based on their similarity with the input.
"""
options_by_distance = {}
input_thres... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 1, 14; 2, function_name:lexical_distance; 3, parameters; 3, 4; 3, 8; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:a_str; 6, type; 6, 7; 7, identifier:str; 8, typed_parameter; 8, 9; 8, 10; 9, identifier:b_str; 10, type; 10, 11; 11, identifier:str; 12, type; 12... | def lexical_distance(a_str: str, b_str: str) -> int:
"""Computes the lexical distance between strings A and B.
The "distance" between two strings is given by counting the minimum number of edits
needed to transform string A into string B. An edit can be an insertion, deletion,
or substitution of a sing... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 1, 22; 2, function_name:get_suggested_type_names; 3, parameters; 3, 4; 3, 8; 3, 12; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:schema; 6, type; 6, 7; 7, identifier:GraphQLSchema; 8, typed_parameter; 8, 9; 8, 10; 9, identifier:type_; 10, type; 10, 11; 11, id... | def get_suggested_type_names(
schema: GraphQLSchema, type_: GraphQLOutputType, field_name: str
) -> List[str]:
"""
Get a list of suggested type names.
Go through all of the implementations of type, as well as the interfaces
that they implement. If any of those types include the provided field,
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:instances_get; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:opts; 5, identifier:plugins; 6, identifier:url_file_input; 7, identifier:out; 8, block; 8, 9; 8, 11; 8, 17; 8, 24; 8, 59; 8, 90; 9, expression_statement; 9, 10; 10, comment; 11... | def instances_get(opts, plugins, url_file_input, out):
"""
Creates and returns an ordered dictionary containing instances for all available
scanning plugins, sort of ordered by popularity.
@param opts: options as returned by self._options.
@param plugins: plugins as returned by plugins_util.plugins_... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_signed_headers; 3, parameters; 3, 4; 4, identifier:headers; 5, block; 5, 6; 5, 8; 5, 12; 5, 31; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:signed_headers; 11, list:[... | def get_signed_headers(headers):
"""
Get signed headers.
:param headers: input dictionary to be sorted.
"""
signed_headers = []
for header in headers:
signed_headers.append(header.lower().strip())
return sorted(signed_headers) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:add_from_names_to_locals; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:node; 6, block; 6, 7; 6, 9; 6, 18; 6, 32; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, iden... | def add_from_names_to_locals(self, node):
"""Store imported names to the locals
Resort the locals if coming from a delayed node
"""
_key_func = lambda node: node.fromlineno
def sort_locals(my_list):
my_list.sort(key=_key_func)
for (name, asname) in node.nam... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:nearest; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:nodes; 6, block; 6, 7; 6, 9; 6, 17; 6, 23; 6, 29; 6, 74; 6, 75; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11,... | def nearest(self, nodes):
"""Get the node closest to this one from the given list of nodes.
:param nodes: The list of nodes to search. All of these nodes must
belong to the same module as this one. The list should be
sorted by the line number of the nodes, smallest first.
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:object_type; 3, parameters; 3, 4; 3, 5; 4, identifier:node; 5, default_parameter; 5, 6; 5, 7; 6, identifier:context; 7, None; 8, block; 8, 9; 8, 11; 8, 33; 8, 48; 9, expression_statement; 9, 10; 10, comment; 11, try_statement; 11, 12; 11, 24; 1... | def object_type(node, context=None):
"""Obtain the type of the given node
This is used to implement the ``type`` builtin, which means that it's
used for inferring type calls, as well as used in a couple of other places
in the inference.
The node will be inferred first, so this function can support ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_deffacts; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 6, expression_statement; 6, 7; 7, comment; 8, return_statement; 8, 9; 9, call; 9, 10; 9, 11; 10, identifier:sorted; 11, argument_list; 11, 12; 11, 18; 12, call; 12, 13... | def get_deffacts(self):
"""Return the existing deffacts sorted by the internal order"""
return sorted(self._get_by_type(DefFacts), key=lambda d: d.order) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:json_dumps; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:data; 6, block; 6, 7; 6, 9; 7, expression_statement; 7, 8; 8, comment; 9, return_statement; 9, 10; 10, call; 10, 11; 10, 35; 11, attribute; 11, 12; 11, 34; 12, call; 12, 1... | def json_dumps(self, data):
"""
Standardized json.dumps function with separators and sorted keys set
Args:
data (dict or list): data to be dumped
Returns:
string: json
"""
return json.dumps(
data,
separators=(',', ':'),
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:create_waveform_generator; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:variable_params; 5, identifier:data; 6, default_parameter; 6, 7; 6, 8; 7, identifier:recalibration; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identif... | def create_waveform_generator(variable_params, data,
recalibration=None, gates=None,
**static_params):
"""Creates a waveform generator for use with a model.
Parameters
----------
variable_params : list of str
The names of the parameter... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:rst_dict_table; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:dict_; 5, default_parameter; 5, 6; 5, 7; 6, identifier:key_format; 7, identifier:str; 8, default_parameter; 8, 9; 8, 10; 9, identifier:val_format; 10, identifier:str;... | def rst_dict_table(dict_, key_format=str, val_format=str, header=None,
sort=True):
"""Returns an RST-formatted table of keys and values from a `dict`
Parameters
----------
dict_ : dict
data to display in table
key_format : callable
callable function with which to ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:read_transforms_from_config; 3, parameters; 3, 4; 3, 5; 4, identifier:cp; 5, default_parameter; 5, 6; 5, 7; 6, identifier:section; 7, string:"transforms"; 8, block; 8, 9; 8, 11; 8, 15; 8, 55; 9, expression_statement; 9, 10; 10, comment; 11, exp... | def read_transforms_from_config(cp, section="transforms"):
"""Returns a list of PyCBC transform instances for a section in the
given configuration file.
If the transforms are nested (i.e., the output of one transform is the
input of another), the returned list will be sorted by the order of the
nes... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:samples_from_cli; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:opts; 6, default_parameter; 6, 7; 6, 8; 7, identifier:parameters; 8, None; 9, dictionary_splat_pattern; 9, 10; 10, identifier:kwargs; 11, block; 11, 12;... | def samples_from_cli(self, opts, parameters=None, **kwargs):
"""Reads samples from the given command-line options.
Parameters
----------
opts : argparse Namespace
The options with the settings to use for loading samples (the sort
of thing returned by ``ArgumentPa... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:data_from_cli; 3, parameters; 3, 4; 4, identifier:opts; 5, block; 5, 6; 5, 8; 5, 9; 5, 16; 5, 23; 5, 24; 5, 37; 5, 48; 5, 49; 5, 63; 5, 64; 5, 65; 5, 150; 5, 151; 5, 152; 5, 156; 5, 160; 5, 164; 5, 171; 5, 208; 5, 209; 5, 226; 5, 227; 5, 279; 6... | def data_from_cli(opts):
"""Loads the data needed for a model from the given
command-line options. Gates specifed on the command line are also applied.
Parameters
----------
opts : ArgumentParser parsed args
Argument options parsed from a command line string (the sort of thing
retur... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:sort; 3, parameters; 3, 4; 3, 5; 3, 9; 3, 12; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:axis; 7, unary_operator:-; 7, 8; 8, integer:1; 9, default_parameter; 9, 10; 9, 11; 10, identifier:kind; 11, string:'quicksort'; 1... | def sort(self, axis=-1, kind='quicksort', order=None):
"""Sort an array, in-place.
This function extends the standard numpy record array in-place sort
to allow the basic use of Field array virtual fields. Only a single
field is currently supported when referencing a virtual field.
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:emit_containers; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:containers; 6, default_parameter; 6, 7; 6, 8; 7, identifier:verbose; 8, True; 9, block; 9, 10; 9, 12; 9, 30; 9, 49; 10, expression_statement; 10, 11; 11, commen... | def emit_containers(self, containers, verbose=True):
"""
Emits the task definition and sorts containers by name
:param containers: List of the container definitions
:type containers: list of dict
:param verbose: Print out newlines and indented JSON
:type verbose: bool
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_completions; 3, parameters; 3, 4; 4, identifier:completions_gen; 5, block; 5, 6; 5, 8; 5, 14; 5, 50; 6, expression_statement; 6, 7; 7, comment; 8, import_from_statement; 8, 9; 8, 12; 9, dotted_name; 9, 10; 9, 11; 10, identifier:knack; 11, ... | def sort_completions(completions_gen):
""" sorts the completions """
from knack.help import REQUIRED_TAG
def _get_weight(val):
""" weights the completions with required things first the lexicographically"""
priority = ''
if val.display_meta and val.display_meta.startswith(REQUIRED_T... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:attr_list; 3, parameters; 3, 4; 3, 7; 3, 10; 4, default_parameter; 4, 5; 4, 6; 5, identifier:label; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:kwargs; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifier:attributes; 12,... | def attr_list(label=None, kwargs=None, attributes=None):
"""Return assembled DOT attribute list string.
Sorts ``kwargs`` and ``attributes`` if they are plain dicts (to avoid
unpredictable order from hash randomization in Python 3 versions).
>>> attr_list()
''
>>> attr_list('spam spam', kwargs... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:mapping_items; 3, parameters; 3, 4; 3, 5; 4, identifier:mapping; 5, default_parameter; 5, 6; 5, 7; 6, identifier:_iteritems; 7, attribute; 7, 8; 7, 9; 8, identifier:_compat; 9, identifier:iteritems; 10, block; 10, 11; 10, 13; 10, 32; 11, expre... | def mapping_items(mapping, _iteritems=_compat.iteritems):
"""Return an iterator over the ``mapping`` items, sort if it's a plain dict.
>>> list(mapping_items({'spam': 0, 'ham': 1, 'eggs': 2}))
[('eggs', 2), ('ham', 1), ('spam', 0)]
>>> from collections import OrderedDict
>>> list(mapping_items(Ord... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:convert_tensor_to_probability_map; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:scope; 5, identifier:operator; 6, identifier:container; 7, block; 7, 8; 7, 10; 7, 22; 7, 33; 7, 200; 7, 212; 7, 338; 8, expression_statement; 8, 9; 9, string:'''
... | def convert_tensor_to_probability_map(scope, operator, container):
'''
This converter tries to convert a special operator 'TensorToProbabilityMap' into a sequence of some ONNX operators.
Those operators are used to create a dictionary in which keys are class labels and values are the associated
probabil... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:group_and_sort_nodes; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 17; 8, 145; 8, 191; 9, boolean_operator:and; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; ... | def group_and_sort_nodes(self):
"""
Groups and then sorts the nodes according to the criteria passed into
the Plot constructor.
"""
if self.node_grouping and not self.node_order:
if self.group_order == "alphabetically":
self.nodes = [
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.