sequence stringlengths 492 15.9k | code stringlengths 75 8.58k |
|---|---|
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]:
scores_tips = np.zeros((len(segs), 4))
allindices = np.arange(self._adata.shape[0], dtype=int)
for iseg, seg in enumerate(segs):
if segs_tips[iseg][0] == -1: continue
if not isinstance(self.dist... |
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, 15; 5, 32; 5, 54; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:categories; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11,... | def unique_categories(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 categories |
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):
kwargs['remove'] = True
return self.__find_and_modify(filter, projection, sort,
session=session, **kwargs) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort; 3, parameters; 3, 4; 4, identifier:lines; 5, block; 5, 6; 5, 13; 5, 23; 5, 53; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:lines; 9, call; 9, 10; 9, 11; 10, identifier:list; 11, argument_list; 11, 12; 12, ident... | def sort(lines):
lines = list(lines)
new_lines = parse_block(lines, header=True)
for block in sorted(parse_blocks(lines), key=first_key):
if new_lines:
new_lines.append('')
new_lines.extend(block)
return new_lines |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:first_key; 3, parameters; 3, 4; 4, identifier:lines; 5, block; 5, 6; 6, for_statement; 6, 7; 6, 8; 6, 9; 6, 38; 7, identifier:line; 8, identifier:lines; 9, block; 9, 10; 9, 36; 10, if_statement; 10, 11; 10, 14; 10, 29; 11, attribute; 11, 12; 11... | def first_key(lines):
for line in lines:
if line.startswith('
continue
if any(line.startswith(quote) for quote in QUOTES):
return line[1:]
return line
else:
return '' |
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):
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):
args = validate_georadius_options(
radius, unit, with_dist, with_hash, with_coord, count, sort
... |
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):
args = validate_georadius_options(
radius, unit, with_dist, with_hash, with_coord, count, so... |
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):
args = []
if by is not None:
args += [b'BY', by]
if offset is not None and count is not None:
args += [b'LIMIT', offset, count]
if ge... |
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):
if not isinstance(score, (int, float)):
raise TypeError("score argument must be int or float")
if len(pairs) % 2 != 0:
raise TypeError("length of pairs must be even number")
scores = (item for i, item in enumerate(pa... |
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):
if not isinstance(min, (int, float)):
raise TypeError("min argument must be int or float")
if not isinstance(max, (int, float)):
raise TypeError("max argument must be int or float")
... |
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, 24; 8, 36; 9, if_statement; 9, 10; 9, 18; 10, not_operator; 10, 11; 11, call; 11, 12; 11, 1... | def zincrby(self, key, increment, member):
if not isinstance(increment, (int, float)):
raise TypeError("increment argument must be int or float")
fut = self.execute(b'ZINCRBY', key, increment, member)
return wait_convert(fut, int_or_float) |
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; 10, return_statement; 10, 11; 11, call; 11, 12; 11, 15; 12, attribute... | def zrem(self, key, member, *members):
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):
if not isinstance(min, bytes):
raise TypeError("min argument must be bytes")
if not isinstance(max, bytes):
raise TypeError("max argument must be bytes")
if not m... |
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, 22; 8, 35; 9, if_statement; 9, 10; 9, 16; 10, not_operator; 10, 11; 11, call; 11, 12; 11,... | def zremrangebyrank(self, key, start, stop):
if not isinstance(start, int):
raise TypeError("start argument must be int")
if not isinstance(stop, int):
raise TypeError("stop argument must be int")
return self.execute(b'ZREMRANGEBYRANK', key, start, stop) |
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):
if not isinstance(min, (int, float)):
raise TypeError("min argument must be int or float")
if not isinstance(max, (int, float)):
raise TypeError("max argument must be i... |
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):
if not isinstance(start, int):
raise TypeError("start argument must be int")
if not isinstance(stop, int):
raise TypeError("stop argument must be int")
if withscores:
args = [b'WITHSCOR... |
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):
if not isinstance(min, (int, float)):
raise TypeError("min argument must be int or float")
if ... |
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, 19; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:fut; 11, call; 11, 12; 11, 15; 12, attribute... | def zscore(self, key, member):
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):
keys = (key,) + keys
numkeys = len(keys)
args = []
if with_weights:
assert all(isinstance(val, (list, tuple)) for val in keys), (
"All key arguments must be (ke... |
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):
args = []
if match is not None:
args += [b'MATCH', match]
if count is not None:
args += [b'COUNT', count]
fut = self.execute(b'ZSCAN', key, cursor, *args)
def _converter(obj):
return (int(... |
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):
if count is not None and not isinstance(count, int):
raise TypeError("count argument must be int")
args = []
if count is not None:
args.extend([count])
fut = self.execute(b'ZPOPMIN', key, *args, encoding=enc... |
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):
if count is not None and not isinstance(count, int):
raise TypeError("count argument must be int")
args = []
if count is not None:
args.extend([count])
fut = self.execute(b'ZPOPMAX', key, *args, encoding=enc... |
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, 107; 6, try_statement; 6, 7; 6, 27; 7, block; 7, 8; 8, return_statement; 8, 9; 9, comparison_operator:==; 9, 10; 9, 23; 10, call; 10, 11; 10, 12; 11, identifier:len; 12, arg... | def uniq(container):
try:
return len(set(unbool(i) for i in container)) == len(container)
except TypeError:
try:
sort = sorted(unbool(i) for i in container)
sliced = itertools.islice(sort, 1, None)
for i, j in zip(sort, sliced):
if i == j:
... |
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, 24; 9, 46; 9, 66; 9, 83; 9, 93; 9, 149; 9, 255; 9, 264; 10,... | def split_traversal(traversal,
edges,
edges_hash=None):
traversal = np.asanyarray(traversal,
dtype=np.int64)
if edges_hash is None:
edges_hash = grouping.hashable_rows(
np.sort(edges, axis=1))
trav_edge = np.column_sta... |
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, 24; 9, 33; 9, 47; 9, 61; 9, 65; 9, 87; 9, 116; 9, 161; 10,... | def fill_traversals(traversals, edges, edges_hash=None):
edges = np.asanyarray(edges, dtype=np.int64)
edges.sort(axis=1)
if len(traversals) == 0:
return edges.copy()
if edges_hash is None:
edges_hash = grouping.hashable_rows(edges)
splits = []
for nodes in traversals:
spl... |
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, 24; 8, 34; 8, 46; 8, 154; 8, 177; 8, 197; 9, if_statement; 9, 10; 9, 16; 10, comparison_operator:=... | def hashable_rows(data, digits=None):
if len(data) == 0:
return np.array([])
as_int = float_to_int(data, digits=digits)
if len(as_int.shape) == 1:
return as_int
if len(as_int.shape) == 2 and as_int.shape[1] <= 4:
precision = int(np.floor(64 / as_int.shape[1]))
if np.abs(a... |
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, 19; 9, 25; 9, 31; 9, 40; 9, 117; 10, expression_statement; 10,... | def interpolate_nans_1d(x, y, kind='linear'):
x_sort_args = np.argsort(x)
x = x[x_sort_args]
y = y[x_sort_args]
nans = np.isnan(y)
if kind == 'linear':
y[nans] = np.interp(x[nans], x[~nans], y[~nans])
elif kind == 'log':
y[nans] = np.interp(np.log(x[nans]), np.log(x[~nans]), y[~n... |
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, 25; 10, 35; 10, ... | def interpolate_1d(x, xp, *args, **kwargs):
r
fill_value = kwargs.pop('fill_value', np.nan)
axis = kwargs.pop('axis', 0)
x = np.asanyarray(x).reshape(-1)
ndim = xp.ndim
sort_args = np.argsort(xp, axis=axis)
sort_x = np.argsort(x)
sorter = broadcast_indices(xp, sort_args, ndim, axis)
... |
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, 25; 10, 35; ... | def log_interpolate_1d(x, xp, *args, **kwargs):
r
fill_value = kwargs.pop('fill_value', np.nan)
axis = kwargs.pop('axis', 0)
log_x = np.log(x)
log_xp = np.log(xp)
return interpolate_1d(log_x, log_xp, *args, axis=axis, fill_value=fill_value) |
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, 39; 6, 50; 6, 61; 6, 70; 6, 76; 6, 82; 6, 97; 6, 103; 6, 109; 7, expression_statement; 7, 8; 8, identifier:r; 9, expression_state... | def _find_append_zero_crossings(x, y):
r
crossings = find_intersections(x[1:], y[1:], np.zeros_like(y[1:]) * y.units)
x = concatenate((x, crossings[0]))
y = concatenate((y, crossings[1]))
sort_idx = np.argsort(x)
x = x[sort_idx]
y = y[sort_idx]
keep_idx = np.ediff1d(x, to_end=[1]) > 0
... |
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; 12, return_... | def sort_ordered_objects(items, getter=lambda x: x):
return sorted(items, key=lambda x: getattr(getter(x), OrderedBase.CREATION_COUNTER_FIELD, -1)) |
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, 23; 5, 29; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:all_nodes; 9, call; 9, 10; 9, 15; 10, attribute; 10, 11; 10, 14; 11, attr... | def remove_fewwords_paragraphs(self):
all_nodes = self.parser.getElementsByTags(self.get_top_node(), ['*'])
all_nodes.reverse()
for el in all_nodes:
tag = self.parser.getTag(el)
text = self.parser.getText(el)
stop_words = self.stopwords_class(language=self.get... |
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, 14; 6, 21; 6, 28; 6, 33; 6, 38; 6, 46; 6, 53; 6, 57; 6, 64; 7, if_statement; 7, 8; 7, 11; 8, comparison_o... | def compare_baselines(old_baseline_filename, new_baseline_filename):
if old_baseline_filename == new_baseline_filename:
raise RedundantComparisonError
old_baseline = _get_baseline_from_file(old_baseline_filename)
new_baseline = _get_baseline_from_file(new_baseline_filename)
_remove_nonexistent_f... |
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, 11; 6, 22; 6, 29; 6, 151; 6, 189; 6, 199; 6, 208; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:attributes; ... | def _GetEventIdentifiers(self, event):
attributes = []
attribute_string = 'data_type: {0:s}'.format(event.data_type)
attributes.append(attribute_string)
for attribute_name, attribute_value in sorted(event.GetAttributes()):
if attribute_name in self._IDENTIFIER_EXCLUDED_ATTRIBUTES:
continue... |
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, 14; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:event; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, identifier:... | def PopEvents(self):
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, 14; 6, 264; 6, 273; 7, expression_statement; 7, 8; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, iden... | def _CheckStatusAnalysisProcess(self, pid):
self._RaiseIfNotRegistered(pid)
if pid in self._completed_analysis_processes:
status_indicator = definitions.STATUS_INDICATOR_COMPLETED
process_status = {
'processing_status': status_indicator}
used_memory = 0
else:
process = self... |
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, 38; 11, if_statement... | def _ExportEvent(self, output_module, event, deduplicate_events=True):
if event.timestamp != self._export_event_timestamp:
self._FlushExportBuffer(
output_module, deduplicate_events=deduplicate_events)
self._export_event_timestamp = event.timestamp
self._export_event_heap.PushEvent(event) |
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, 14; 9, 18; 9, 22; 9, 32; 9, 129; 10, expressi... | def _FlushExportBuffer(self, output_module, deduplicate_events=True):
last_macb_group_identifier = None
last_content_identifier = None
macb_group = []
generator = self._export_event_heap.PopEvents()
for macb_group_identifier, content_identifier, event in generator:
if deduplicate_events and la... |
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, 16; 7, 24; 7, 29; 7, 41; 7, 62; 8, if_statement; 8, 9; 8, 14; 9, comparison_operator:!=; 9,... | def _MergeEventTag(self, storage_writer, attribute_container):
if attribute_container.CONTAINER_TYPE != 'event_tag':
return
event_identifier = attribute_container.GetEventIdentifier()
if not event_identifier:
return
stored_event_tag = self._event_tag_index.GetEventTagByIdentifier(
st... |
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, 15; 7, 63; 8, expression_statement; 8, 9; 9, call; 9, 10; 9, 13; 10, attribute; 10, 1... | def _StartAnalysisProcesses(self, storage_writer, analysis_plugins):
logger.info('Starting analysis plugins.')
for analysis_plugin in analysis_plugins.values():
self._analysis_plugins[analysis_plugin.NAME] = analysis_plugin
process = self._StartWorkerProcess(analysis_plugin.NAME, storage_writer)
... |
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, 16; 8, 22; 8, 31; 8, 60; 8, 84; 8, 95; 8, 114; 9, expression_statement; 9, 10; 10, call; ... | def _StopAnalysisProcesses(self, abort=False):
logger.debug('Stopping analysis processes.')
self._StopMonitoringProcesses()
if abort:
self._AbortTerminate()
if not self._use_zeromq:
logger.debug('Emptying queues.')
for event_queue in self._event_queues.values():
event_queue.Emp... |
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, 18; 5, 29; 5, 78; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:used_memory; 9, boolean_operator:or; 9, 10; 9, 17; 10, call; 10, ... | def _UpdateForemanProcessStatus(self):
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, display_name,
self._number_of_consumed... |
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; 6, return_statement; 6, 7; 7, list_comprehension; 7, 8; 7, 13; 8, subscript; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, identifier:_workers_status; ... | def workers_status(self):
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, 15; 5, 26; 5, 37; 5, 48; 5, 68; 5, 81; 5, 100; 5, 111; 5, 117; 5, 125; 5, 133; 5, 143; 5, 153; 5, 163; 5, 167; 5, 264; 5, 335; 5, 341; 5, 350; 5, 413; 5, 426; 6, expres... | def ProcessStorage(self):
self._CheckStorageFile(self._storage_file_path)
self._status_view.SetMode(self._status_view_mode)
self._status_view.SetStorageFileInformation(self._storage_file_path)
status_update_callback = (
self._status_view.GetAnalysisStatusUpdateCallback())
session = engine.Ba... |
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):
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]:
scores = [self.scoring_function(hypothesis, reference) for hypothesis in hypotheses['translations']]
ranking = list(np.argsort(scores, kind='mergesort')[::-1])
reranked_hypotheses = self._sort_by_ranking(hypotheses, ... |
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_time_start = time.time()
with open(path, 'rb') as inp:
_lex = np.load(inp)
loaded_k = _lex.shape[1]
if k is not None:
top_k = min(k, loaded_k)
if k > loaded_k:
logger.warning("Can... |
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:
unique_src_ids = np.lib.arraysetops.unique(src_ids)
trg_ids = np.lib.arraysetops.union1d(self.always_allow, self.lex[unique_src_ids, :].reshape(-1))
return trg_ids |
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, 24; 6, 41; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:tree_id; 10, call; 10, 11; 10, 12; 11, identifier:getattr; 12, argu... | def choice(self, obj):
tree_id = getattr(obj, self.queryset.model._mptt_meta.tree_id_attr, 0)
left = getattr(obj, self.queryset.model._mptt_meta.left_attr, 0)
return super(MPTTModelChoiceIterator,
self).choice(obj) + ((tree_id, left),) |
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, 61; 6, 110; 6, 165; 6, 212; 6, 259; 7, if_statement; 7, 8; 7, 15; 8, boolean_operator:and; 8, 9; 8, 14; 9, comparison_operator:is; 9, ... | def get_best_dataset_key(key, choices):
if key.wavelength is not None and choices:
nearest_wl = min([_wl_dist(key.wavelength, x.wavelength)
for x in choices if x.wavelength is not None])
choices = [c for c in choices
if _wl_dist(key.wavelength, c.waveleng... |
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):
if isinstance(key, numbers.Number):
key = DatasetID(wavelength=key, modifiers=None)
elif isinstance(key, (str, six.text_type)):
key... |
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):
if reader is None:
raise ValueError("'reader' keyword argument is required.")
elif not isinstance(reader, (list, tuple)):
reader = [reader]
reader = reade... |
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, 10; 5, 25; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:processed_types; 9, list:[]; 10, expression_statement; 10, 11; 11, assignment;... | def sorted_filetype_items(self):
processed_types = []
file_type_items = deque(self.config['file_types'].items())
while len(file_type_items):
filetype, filetype_info = file_type_items.popleft()
requirements = filetype_info.get('requires')
if requirements is not... |
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, 12; 5, 33; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:hasher; 9, call; 9, 10; 9, 11; 10, identifier:sha1; 11, argument_list; 12, for_stat... | def combine_hashes(hashes):
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, 22; 6, 40; 6, 69; 6, 84; 6, 102; 6, 116; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:baseurl_to_urls; 10, dic... | def get_available_urls(self, urls):
baseurl_to_urls = {self._baseurl(url): url for url in urls}
pingtimes = self._pinger.pings(list(baseurl_to_urls.keys()))
self._log.debug('Artifact cache server ping times: {}'
.format(', '.join(['{}: {:.6f} secs'.format(*p) for p in pingtimes])))
s... |
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, 24; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:scope_infos; 10, list_comprehension; 10, 11; 10, 16; 11, subscript; 11... | def iterate(self, scopes):
scope_infos = [self._scope_to_info[s] for s in self._expand_tasks(scopes)]
if scope_infos:
for scope_info in self._expand_subsystems(scope_infos):
yield scope_info |
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, 14; 6, 67; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:expanded_scopes; 10, call; 10, 11; 10, 12; 11, identifier... | def _expand_tasks(self, scopes):
expanded_scopes = set(scopes)
for scope, info in self._scope_to_info.items():
if info.category == ScopeInfo.TASK:
outer = enclosing_scope(scope)
while outer != GLOBAL_SCOPE:
if outer in expanded_scopes:
expanded_scopes.add(scope)
... |
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; 6, return_statement; 6, 7; 7, list_comprehension; 7, 8; 7, 28; 8, dictionary; 8, 9; 8, 14; 8, 19; 9, pair; 9, 10; 9, 11; 10, string:'label'; 11, subscript; 11, 12; 11, 13; 12, id... | def get_all(self):
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], reverse=True)] |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:all; 3, parameters; 4, block; 4, 5; 5, return_statement; 5, 6; 6, list_comprehension; 6, 7; 6, 8; 6, 22; 7, identifier:goal; 8, for_in_clause; 8, 9; 8, 12; 9, pattern_list; 9, 10; 9, 11; 10, identifier:_; 11, identifier:goal; 12, call; 12, 13; ... | def all():
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, 14; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:best_url; 9, subscript; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 1... | def select_best_url(self):
best_url = self.parsed_urls[0]
try:
yield best_url
except Exception:
self.unsuccessful_calls[best_url] += 1
if self.unsuccessful_calls[best_url] > self.max_failures:
self.parsed_urls.rotate(-1)
self.unsuccessful_calls[best_url] = 0
raise
... |
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, 14; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:target_set; 10, call; 10, 11; 10, 12; 11, identifier:set; 1... | def _topological_sort(self, 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, 12; 5, 18; 5, 53; 5, 72; 5, 85; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:keys; 9, call; 9, 10; 9, 11; 10, identifier:OrderedD... | def sortmerna_detailed_barplot (self):
keys = OrderedDict()
metrics = set()
for sample in self.sortmerna:
for key in self.sortmerna[sample]:
if not key in ["total", "rRNA", "non_rRNA"] and not "_pct" in key:
metrics.add(key)
for key in metr... |
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, 15; 6, 33; 6, 43; 6, 68; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:default_allowed; 10, call; 10, 11; 10, 12; 11... | def _short_chrom(self, chrom):
default_allowed = set(["X"])
allowed_chroms = set(getattr(config, "goleft_indexcov_config", {}).get("chromosomes", []))
chrom_clean = chrom.replace("chr", "")
try:
chrom_clean = int(chrom_clean)
except ValueError:
if chrom_cl... |
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, 13; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:values; 9, call; 9, 10; 9, 11; 10, identifier:vals_sorted_by_key; 11, argument_list; 11, 12; ... | def deepvalues(mapping):
values = vals_sorted_by_key(mapping)
for obj in values:
mapping = False
try:
obj.items
except AttributeError:
pass
else:
mapping = True
for subobj in deepvalues(obj):
yield subobj
if ... |
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; 6, return_statement; 6, 7; 7, list_comprehension; 7, 8; 7, 17; 8, call; 8, 9; 8, 14; 9, attribute; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, identifier... | def values(self):
return [self.policy.header_fetch_parse(k, v)
for k, v in self._headers] |
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; 6, return_statement; 6, 7; 7, list_comprehension; 7, 8; 7, 19; 8, tuple; 8, 9; 8, 10; 9, identifier:k; 10, call; 10, 11; 10, 16; 11, attribute; 11, 12; 11, 15; 12, attribute; 12, 1... | def items(self):
return [(k, self.policy.header_fetch_parse(k, v))
for k, v in self._headers] |
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, 14; 9, 22; 9, 54; 9, 60; 10, expression_statement; 10, 11; 11, assignment; 1... | def get_all(self, name, failobj=None):
values = []
name = name.lower()
for k, v in self._headers:
if k.lower() == name:
values.append(self.policy.header_fetch_parse(k, v))
if not values:
return failobj
return values |
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, 18; 9, expression_statement; 9, 10; 10, call; 10, 11; 10, 16; 11, attribute; 11, 1... | def setup(job, input_file_id, n, down_checkpoints):
job.fileStore.logToMaster("Starting the merge sort")
return job.addChildJobFn(down,
input_file_id, n,
down_checkpoints=down_checkpoints,
memory='600M').rv() |
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, 23; 8, 34; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, iden... | def down(job, input_file_id, n, down_checkpoints):
input_file = job.fileStore.readGlobalFile(input_file_id, cache=False)
length = os.path.getsize(input_file)
if length > n:
job.fileStore.logToMaster("Splitting file: %s of size: %s"
% (input_file_id, length), level=l... |
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, 15; 6, 23; 6, 29; 6, 35; 6, 43; 6, 54; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:filehandle; 10, call; 10, 11; 10,... | def sort(in_file, out_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, 16; 7, 55; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:line2; 11,... | def merge(filehandle_1, filehandle_2, output_filehandle):
line2 = filehandle_2.readline()
for line1 in filehandle_1.readlines():
while line2 != '' and line2 <= line1:
output_filehandle.write(line2)
line2 = filehandle_2.readline()
output_filehandle.write(line1)
while l... |
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, 16; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:title; 11, call; 11, 1... | def decorateSubHeader(title, columnWidths, options):
title = title.lower()
if title != options.sortCategory:
s = "| %*s%*s%*s%*s%*s " % (
columnWidths.getWidth(title, "min"), "min",
columnWidths.getWidth(title, "med"), "med",
columnWidths.getWidth(title, "ave"), "ave"... |
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, 26; 6, 34; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:longforms; 10, dictionary; 10, 11; 10, 14; 10, 17; 10, 20... | def sortJobs(jobTypes, options):
longforms = {"med": "median",
"ave": "average",
"min": "min",
"total": "total",
"max": "max",}
sortField = longforms[options.sortField]
if (options.sortCategory == "time" or
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, 17; 6, 25; 6, 38; 6, 53; 6, 61; 6, 72; 6, 84; 6, 104; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:tau_y; 10, subscri... | def _sort_tau_by_y(self, y):
tau_y = self.tau_matrix[:, y]
tau_y[y] = np.NaN
temp = np.empty([self.n_nodes, 3])
temp[:, 0] = np.arange(self.n_nodes)
temp[:, 1] = tau_y
temp[:, 2] = abs(tau_y)
temp[np.isnan(temp)] = -10
tau_sorted = temp[temp[:, 2].argsort(... |
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; 6, return_statement; 6, 7; 7, call; 7, 8; 7, 9; 8, identifier:sorted; 9, argument_list; 9, 10; 9, 11; 10, identifier:edges; 11, keyword_argument; 11, 12; 11, 13; 12, identifie... | def sort_edge(edges):
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):
if file and model_code:
raise ValueError("Specify stan model with `file` or `model_code`, "
"not both.")
if file is None and m... |
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]):
options_by_distance = {}
input_threshold = len(input_) // 2
for option in options:
distance = lexical_distance(input_, option)
threshold = max(input_threshold, len(option) // 2, 1)
if distance <= threshold:
optio... |
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:
if a_str == b_str:
return 0
a, b = a_str.lower(), b_str.lower()
a_len, b_len = len(a), len(b)
if a == b:
return 1
d = [[j for j in range(0, b_len + 1)]]
for i in range(1, a_len + 1):
d.append([i] + [0] * b_len)
for ... |
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]:
if is_abstract_type(type_):
type_ = cast(GraphQLAbstractType, type_)
suggested_object_types = []
interface_usage_count: Dict[str, int] = defaultdict(int)
for possible_ty... |
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, 15; 8, 22; 8, 57; 8, 88; 9, expression_statement; 9, 10; 10, assignment; 10, 11... | def instances_get(opts, plugins, url_file_input, out):
instances = OrderedDict()
preferred_order = ['wordpress', 'joomla', 'drupal']
for cms_name in preferred_order:
for plugin in plugins:
plugin_name = plugin.__name__.lower()
if cms_name == plugin_name:
insta... |
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, 10; 5, 29; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:signed_headers; 9, list:[]; 10, for_statement; 10, 11; 10, 12; 10, 13; 11, ide... | def get_signed_headers(headers):
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, 16; 6, 30; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:_key_func; 10, lambda; 10, 11; 10, 13; 11, lambd... | def add_from_names_to_locals(self, node):
_key_func = lambda node: node.fromlineno
def sort_locals(my_list):
my_list.sort(key=_key_func)
for (name, asname) in node.names:
if name == "*":
try:
imported = node.do_import_module()
... |
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, 15; 6, 21; 6, 27; 6, 72; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:myroot; 10, call; 10, 11; 10, 14; 11, attribute; 1... | def nearest(self, nodes):
myroot = self.root()
mylineno = self.fromlineno
nearest = None, 0
for node in nodes:
assert node.root() is myroot, (
"nodes %s and %s are not from the same module" % (self, node)
)
lineno = node.fromlineno
... |
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, 31; 8, 46; 9, try_statement; 9, 10; 9, 22; 10, block; 10, 11; 11, expression_statement; 11, 12; 12,... | def object_type(node, context=None):
try:
types = set(_object_type(node, context))
except exceptions.InferenceError:
return util.Uninferable
if len(types) > 1 or not types:
return util.Uninferable
return list(types)[0] |
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; 6, return_statement; 6, 7; 7, call; 7, 8; 7, 9; 8, identifier:sorted; 9, argument_list; 9, 10; 9, 16; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier... | def get_deffacts(self):
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; 7, return_statement; 7, 8; 8, call; 8, 9; 8, 33; 9, attribute; 9, 10; 9, 32; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:... | def json_dumps(self, data):
return json.dumps(
data,
separators=(',', ':'),
sort_keys=True,
cls=self.json_encoder,
ensure_ascii=False
).encode('utf8') |
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):
try:
approximant = static_params['approximant']
except KeyError:
raise ValueError("no approximant provided in the static args")
g... |
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):
keys, values = zip(*dict_.items())
keys = map(key_format, keys)
values = map(val_format, values)
nckey = max(map(len, keys))
ncval = max(map(len, values))
if header:
khead, vhead = heade... |
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, 13; 8, 53; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10,... | def read_transforms_from_config(cp, section="transforms"):
trans = []
for subsection in cp.get_subsections(section):
name = cp.get_opt_tag(section, "name", subsection)
t = transforms[name].from_config(cp, section, subsection)
trans.append(t)
return order_transforms(trans) |
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):
if parameters is None and opts.parameters is None:
parameters = self.variable_args
elif parameters is None:
parameters = opts.parameters
_, extra_actions = self.extra_args_parser()
extra_args = [act.dest... |
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, 13; 5, 20; 5, 33; 5, 44; 5, 58; 5, 142; 5, 146; 5, 150; 5, 154; 5, 161; 5, 198; 5, 215; 5, 265; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:g... | def data_from_cli(opts):
gates = gates_from_cli(opts)
psd_gates = psd_gates_from_cli(opts)
instruments = opts.instruments if opts.instruments is not None else []
strain_dict = strain_from_cli_multi_ifos(opts, instruments,
precision="double")
if not opts.g... |
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):
try:
numpy.recarray.sort(self, axis=axis, kind=kind, order=order)
except ValueError:
if isinstance(order, list):
raise ValueError("Cannot process more than one order field")
self[:] = self[numpy.ar... |
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, 28; 9, 47; 10, expression_statement; 10, 11; 11, assignment; 1... | def emit_containers(self, containers, verbose=True):
containers = sorted(containers, key=lambda c: c.get('name'))
task_definition = {
'family': self.family,
'containerDefinitions': containers,
'volumes': self.volumes or []
}
if verbose:
ret... |
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, 12; 5, 45; 6, import_from_statement; 6, 7; 6, 10; 7, dotted_name; 7, 8; 7, 9; 8, identifier:knack; 9, identifier:help; 10, dotted_name; 10, 11; 11, identif... | def sort_completions(completions_gen):
from knack.help import REQUIRED_TAG
def _get_weight(val):
priority = ''
if val.display_meta and val.display_meta.startswith(REQUIRED_TAG):
priority = ' '
return priority + val.text
return sorted(completions_gen, key=_get_weight) |
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):
content = a_list(label, kwargs, attributes)
if not content:
return ''
return ' [%s]' % content |
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, 30; 11, if_statement;... | def mapping_items(mapping, _iteritems=_compat.iteritems):
if type(mapping) is dict:
return iter(sorted(_iteritems(mapping)))
return _iteritems(mapping) |
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, 333; 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; 6, if_statement; 6, 7; 6, 15; 6, 143; 6, 189; 7, boolean_operator:and; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:node_grouping; 11, ... | def group_and_sort_nodes(self):
if self.node_grouping and not self.node_order:
if self.group_order == "alphabetically":
self.nodes = [
n
for n, d in sorted(
self.graph.nodes(data=True),
key=lambda... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.