sequence stringlengths 492 15.9k | code stringlengths 75 8.58k |
|---|---|
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:register; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:func; 6, identifier:order; 7, block; 7, 8; 7, 16; 7, 28; 7, 44; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:token; 11, call; 11, 12; 11,... | def register(self, func, order):
token = self.Token()
self._filter_order.append((order, token, func))
self._filter_order.sort(key=lambda x: x[0])
return token |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_features; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:jid; 6, block; 6, 7; 6, 19; 6, 25; 6, 49; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:response; 10, yield; 10, 11; 11, call; 11, 12; 11, 17;... | def get_features(self, jid):
response = yield from self._disco.query_info(jid)
result = set()
for feature in response.features:
try:
result.add(pubsub_xso.Feature(feature))
except ValueError:
continue
return result |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:intersect; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:other; 6, block; 6, 7; 6, 19; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:loc; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, ide... | def intersect(self, other):
loc = self.locate_keys(other, strict=False)
return self.compress(loc, axis=0) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:locate_intersection_ranges; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:starts; 6, identifier:stops; 7, block; 7, 8; 7, 16; 7, 24; 7, 30; 7, 40; 7, 53; 7, 59; 7, 75; 7, 98; 8, expression_statement; 8, 9; 9, assignment; 9,... | def locate_intersection_ranges(self, starts, stops):
starts = asarray_ndim(starts, 1)
stops = asarray_ndim(stops, 1)
check_dim0_aligned(starts, stops)
start_indices = np.searchsorted(self, starts)
stop_indices = np.searchsorted(self, stops, side='right')
loc_ranges = star... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:locate_ranges; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:starts; 6, identifier:stops; 7, default_parameter; 7, 8; 7, 9; 8, identifier:strict; 9, True; 10, block; 10, 11; 10, 23; 10, 46; 11, expression_statement; ... | def locate_ranges(self, starts, stops, strict=True):
loc, found = self.locate_intersection_ranges(starts, stops)
if strict and np.any(~found):
raise KeyError(starts[~found], stops[~found])
return loc |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:intersect_ranges; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:starts; 6, identifier:stops; 7, block; 7, 8; 7, 21; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:loc; 11, call; 11, 12; 11, 15; 1... | def intersect_ranges(self, starts, stops):
loc = self.locate_ranges(starts, stops, strict=False)
return self.compress(loc, axis=0) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 25; 2, function_name:from_gff3; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 15; 3, 19; 3, 22; 4, identifier:path; 5, default_parameter; 5, 6; 5, 7; 6, identifier:attributes; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:region; 10, None; 11, default_par... | def from_gff3(path, attributes=None, region=None, score_fill=-1, phase_fill=-1,
attributes_fill='.', dtype=None):
a = gff3_to_recarray(path, attributes=attributes, region=region,
score_fill=score_fill, phase_fill=phase_fill,
attributes_... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 25; 2, function_name:iter_gff3; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 15; 3, 19; 3, 22; 4, identifier:path; 5, default_parameter; 5, 6; 5, 7; 6, identifier:attributes; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:region; 10, None; 11, default_par... | def iter_gff3(path, attributes=None, region=None, score_fill=-1,
phase_fill=-1, attributes_fill='.', tabix='tabix'):
if attributes is not None:
attributes = list(attributes)
if isinstance(attributes_fill, (list, tuple)):
if len(attributes) != len(attributes_fill):
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 28; 2, function_name:gff3_to_recarray; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 15; 3, 19; 3, 22; 3, 25; 4, identifier:path; 5, default_parameter; 5, 6; 5, 7; 6, identifier:attributes; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:region; 10, None; 1... | def gff3_to_recarray(path, attributes=None, region=None, score_fill=-1,
phase_fill=-1, attributes_fill='.', tabix='tabix', dtype=None):
recs = list(iter_gff3(path, attributes=attributes, region=region,
score_fill=score_fill, phase_fill=phase_fill,
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 27; 2, function_name:gff3_to_dataframe; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 15; 3, 19; 3, 22; 3, 25; 4, identifier:path; 5, default_parameter; 5, 6; 5, 7; 6, identifier:attributes; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:region; 10, None; ... | def gff3_to_dataframe(path, attributes=None, region=None, score_fill=-1,
phase_fill=-1, attributes_fill='.', tabix='tabix', **kwargs):
import pandas
recs = list(iter_gff3(path, attributes=attributes, region=region,
score_fill=score_fill, phase_fill=phase_fill,
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:voight_painting; 3, parameters; 3, 4; 4, identifier:h; 5, block; 5, 6; 5, 21; 5, 35; 5, 49; 5, 57; 5, 70; 5, 85; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:h; 9, call; 9, 10; 9, 11; 10, identifier:HaplotypeArray; 11... | def voight_painting(h):
h = HaplotypeArray(np.asarray(h), copy=False)
if h.max() > 1:
raise NotImplementedError('only biallelic variants are supported')
if h.min() < 0:
raise NotImplementedError('missing calls are not supported')
indices = h.prefix_argsort()
h = np.take(h, indices, a... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_model_perms; 3, parameters; 3, 4; 4, identifier:model; 5, block; 5, 6; 5, 14; 5, 22; 5, 34; 5, 50; 5, 68; 6, import_from_statement; 6, 7; 6, 12; 7, dotted_name; 7, 8; 7, 9; 7, 10; 7, 11; 8, identifier:django; 9, identifier:contrib; 10, iden... | def get_model_perms(model):
from django.contrib.auth.models import Permission
app_label = model._meta.app_label
model_name = model._meta.object_name.lower()
qs = Permission.objects.filter(content_type__app_label=app_label,
content_type__model=model_name)
perms = ('... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:sort_trigger_set; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:triggers; 5, default_parameter; 5, 6; 5, 7; 6, identifier:exclude_previous; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:say; 10, None; 11, block; 11, 12; 11, 24; 11... | def sort_trigger_set(triggers, exclude_previous=True, say=None):
if say is None:
say = lambda x: x
trigger_object_list = []
for index, trig in enumerate(triggers):
if exclude_previous and trig[1]["previous"]:
continue
pattern = trig[0]
match, weight = re.search(RE... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_list; 3, parameters; 3, 4; 4, identifier:items; 5, block; 5, 6; 5, 10; 5, 26; 5, 62; 5, 66; 5, 102; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:track; 9, dictionary; 10, function_definition; 10, 11; 10, 12; 10, ... | def sort_list(items):
track = {}
def by_length(word1, word2):
return len(word2) - len(word1)
for item in items:
cword = utils.word_count(item, all=True)
if cword not in track:
track[cword] = []
track[cword].append(item)
output = []
for count in sorted(trac... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sort_replies; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:thats; 7, False; 8, block; 8, 9; 8, 17; 8, 25; 8, 32; 8, 111; 8, 127; 8, 148; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 1... | def sort_replies(self, thats=False):
self._sorted["topics"] = {}
self._sorted["thats"] = {}
self._say("Sorting triggers...")
for topic in self._topics.keys():
self._say("Analyzing topic " + topic)
alltrig = inherit_utils.get_topic_triggers(self, topic, False)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:all; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:page; 7, integer:1; 8, default_parameter; 8, 9; 8, 10; 9, identifier:per_page; 10, integer:10; 11, default_parameter; 11, 12; 11, ... | def all(self, page=1, per_page=10, order_by="latest"):
return self._all("/photos", page=page, per_page=per_page, order_by=order_by) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:photos; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:username; 6, default_parameter; 6, 7; 6, 8; 7, identifier:page; 8, integer:1; 9, default_parameter; 9, 10; 9, 11; 10, identifier:per_page; 11, integer:10; ... | def photos(self, username, page=1, per_page=10, order_by="latest"):
url = "/users/{username}/photos".format(username=username)
result = self._photos(url, username, page=page, per_page=per_page, order_by=order_by)
return PhotoModel.parse_list(result) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:callable; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:nans; 7, False; 8, block; 8, 9; 8, 23; 8, 123; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:jitfunc; 12, ... | def callable(self, nans=False):
jitfunc = nb.njit(self.func, nogil=True)
def _loop(sortidx, group_idx, a, ret):
size = len(ret)
group_idx_srt = group_idx[sortidx]
a_srt = a[sortidx]
indices = step_indices(group_idx_srt)
for i in range(len(indic... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:scores2recos; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:scores; 6, identifier:candidates; 7, default_parameter; 7, 8; 7, 9; 8, identifier:rev; 9, False; 10, block; 10, 11; 10, 20; 10, 33; 11, expression_statement... | def scores2recos(self, scores, candidates, rev=False):
sorted_indices = np.argsort(scores)
if rev:
sorted_indices = sorted_indices[::-1]
return candidates[sorted_indices], scores[sorted_indices] |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 1, 28; 2, function_name:commutative_sequence_variable_partition_iter; 3, parameters; 3, 4; 3, 8; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:values; 6, type; 6, 7; 7, identifier:Multiset; 8, typed_parameter; 8, 9; 8, 10; 9, identifier:variables; 10, type; 10... | def commutative_sequence_variable_partition_iter(values: Multiset, variables: List[VariableWithCount]
) -> Iterator[Dict[str, Multiset]]:
if len(variables) == 1:
yield from _commutative_single_variable_partiton_iter(values, variables[0])
return
gen... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:iter_cookie_browse_sorting; 3, parameters; 3, 4; 4, identifier:cookies; 5, block; 5, 6; 5, 8; 6, expression_statement; 6, 7; 7, string:'''
Get sorting-cookie from cookies dictionary.
:yields: tuple of path and sorting property
:ytyp... | def iter_cookie_browse_sorting(cookies):
'''
Get sorting-cookie from cookies dictionary.
:yields: tuple of path and sorting property
:ytype: 2-tuple of strings
'''
try:
data = cookies.get('browse-sorting', 'e30=').encode('ascii')
for path, prop in json.loads(base64.b64decode(data... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_cookie_browse_sorting; 3, parameters; 3, 4; 3, 5; 4, identifier:path; 5, identifier:default; 6, block; 6, 7; 6, 9; 6, 30; 7, expression_statement; 7, 8; 8, string:'''
Get sorting-cookie data for path of current request.
:returns: so... | def get_cookie_browse_sorting(path, default):
'''
Get sorting-cookie data for path of current request.
:returns: sorting property
:rtype: string
'''
if request:
for cpath, cprop in iter_cookie_browse_sorting(request.cookies):
if path == cpath:
return cprop
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:integral; 3, parameters; 3, 4; 3, 5; 4, identifier:requestContext; 5, identifier:seriesList; 6, block; 6, 7; 6, 11; 6, 90; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:results; 10, list:[]; 11, for_statement; 11, 12;... | def integral(requestContext, seriesList):
results = []
for series in seriesList:
newValues = []
current = 0.0
for val in series:
if val is None:
newValues.append(None)
else:
current += val
newValues.append(current)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:map_metabolite2kegg; 3, parameters; 3, 4; 4, identifier:metabolite; 5, block; 5, 6; 5, 16; 5, 27; 5, 43; 5, 78; 5, 88; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:logger; 10, identifier:debug; 1... | def map_metabolite2kegg(metabolite):
logger.debug("Looking for KEGG compound identifier for %s.", metabolite.id)
kegg_annotation = metabolite.annotation.get("kegg.compound")
if kegg_annotation is None:
logger.warning("No kegg.compound annotation for metabolite %s.",
metabolite... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:preProcessForComparison; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:results; 5, identifier:target_size; 6, identifier:size_tolerance_prct; 7, block; 7, 8; 7, 12; 7, 53; 7, 71; 7, 75; 7, 136; 7, 148; 7, 172; 7, 377; 8, expression_statement; ... | async def preProcessForComparison(results, target_size, size_tolerance_prct):
reference = None
for result in results:
if result.source_quality is CoverSourceQuality.REFERENCE:
if ((reference is None) or
(CoverSourceResult.compare(result,
reference... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sort; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:order; 7, string:"asc"; 8, block; 8, 9; 8, 15; 8, 56; 9, expression_statement; 9, 10; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; ... | def sort(self, order="asc"):
self.__prepare()
if isinstance(self._json_data, list):
if order == "asc":
self._json_data = sorted(self._json_data)
else:
self._json_data = sorted(self._json_data, reverse=True)
return self |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:sort_by; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:property; 6, default_parameter; 6, 7; 6, 8; 7, identifier:order; 8, string:"asc"; 9, block; 9, 10; 9, 16; 9, 79; 10, expression_statement; 10, 11; 11, call; 11, 12; 11,... | def sort_by(self, property, order="asc"):
self.__prepare()
if isinstance(self._json_data, list):
if order == "asc":
self._json_data = sorted(
self._json_data,
key=lambda x: x.get(property)
)
else:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:get; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:dic; 5, identifier:path; 6, default_parameter; 6, 7; 6, 8; 7, identifier:seps; 8, identifier:PATH_SEPS; 9, default_parameter; 9, 10; 9, 11; 10, identifier:idx_reg; 11, identifier:_JSNP_... | def get(dic, path, seps=PATH_SEPS, idx_reg=_JSNP_GET_ARRAY_IDX_REG):
items = [_jsnp_unescape(p) for p in _split_path(path, seps)]
if not items:
return (dic, '')
try:
if len(items) == 1:
return (dic[items[0]], '')
prnt = functools.reduce(operator.getitem, items[:-1], dic)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:groupby; 3, parameters; 3, 4; 3, 5; 4, identifier:itr; 5, default_parameter; 5, 6; 5, 7; 6, identifier:key_fn; 7, None; 8, block; 8, 9; 9, return_statement; 9, 10; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:itertool... | def groupby(itr, key_fn=None):
return itertools.groupby(sorted(itr, key=key_fn), key=key_fn) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:open; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:path; 5, default_parameter; 5, 6; 5, 7; 6, identifier:mode; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ac_parser; 10, None; 11, dictionary_splat_pattern; 11, 12; 12, id... | def open(path, mode=None, ac_parser=None, **options):
psr = find(path, forced_type=ac_parser)
if mode is not None and mode.startswith('w'):
return psr.wopen(path, **options)
return psr.ropen(path, **options) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:single_load; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:input_; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ac_parser; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ac_template; 10, False; 11, default_paramete... | def single_load(input_, ac_parser=None, ac_template=False,
ac_context=None, **options):
r
cnf = _single_load(input_, ac_parser=ac_parser, ac_template=ac_template,
ac_context=ac_context, **options)
schema = _maybe_schema(ac_template=ac_template, ac_context=ac_context,
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:multi_load; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:inputs; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ac_parser; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ac_template; 10, False; 11, default_parameter... | def multi_load(inputs, ac_parser=None, ac_template=False, ac_context=None,
**options):
r
marker = options.setdefault("ac_marker", options.get("marker", '*'))
schema = _maybe_schema(ac_template=ac_template, ac_context=ac_context,
**options)
options["ac_schema"] =... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:load; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:path_specs; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ac_parser; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ac_dict; 10, None; 11, default_parameter... | def load(path_specs, ac_parser=None, ac_dict=None, ac_template=False,
ac_context=None, **options):
r
marker = options.setdefault("ac_marker", options.get("marker", '*'))
if anyconfig.utils.is_path_like_object(path_specs, marker):
return single_load(path_specs, ac_parser=ac_parser, ac_dict=a... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:dump; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:data; 5, identifier:out; 6, default_parameter; 6, 7; 6, 8; 7, identifier:ac_parser; 8, None; 9, dictionary_splat_pattern; 9, 10; 10, identifier:options; 11, block; 11, 12; 11, 23; 11, ... | def dump(data, out, ac_parser=None, **options):
ioi = anyconfig.ioinfo.make(out)
psr = find(ioi, forced_type=ac_parser)
LOGGER.info("Dumping: %s", ioi.path)
psr.dump(data, ioi, **options) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:dumps; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:data; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ac_parser; 7, None; 8, dictionary_splat_pattern; 8, 9; 9, identifier:options; 10, block; 10, 11; 10, 21; 11, expression_statement; 11, ... | def dumps(data, ac_parser=None, **options):
psr = find(None, forced_type=ac_parser)
return psr.dumps(data, **options) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 1, 16; 2, function_name:sort_response; 3, parameters; 3, 4; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:response; 6, type; 6, 7; 7, generic_type; 7, 8; 7, 9; 8, identifier:Dict; 9, type_parameter; 9, 10; 9, 12; 10, type; 10, 11; 11, identifier:str; 12, type;... | def sort_response(response: Dict[str, Any]) -> OrderedDict:
root_order = ["jsonrpc", "result", "error", "id"]
error_order = ["code", "message", "data"]
req = OrderedDict(sorted(response.items(), key=lambda k: root_order.index(k[0])))
if "error" in response:
req["error"] = OrderedDict(
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 1, 16; 2, function_name:sort_request; 3, parameters; 3, 4; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:request; 6, type; 6, 7; 7, generic_type; 7, 8; 7, 9; 8, identifier:Dict; 9, type_parameter; 9, 10; 9, 12; 10, type; 10, 11; 11, identifier:str; 12, type; 1... | def sort_request(request: Dict[str, Any]) -> OrderedDict:
sort_order = ["jsonrpc", "method", "params", "id"]
return OrderedDict(sorted(request.items(), key=lambda k: sort_order.index(k[0]))) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:dump; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:obj; 5, identifier:fp; 6, default_parameter; 6, 7; 6, 8; 7, identifier:container_count; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:sort_keys; 11, False;... | def dump(obj, fp, container_count=False, sort_keys=False, no_float32=True, default=None):
if not callable(fp.write):
raise TypeError('fp.write not callable')
fp_write = fp.write
__encode_value(fp_write, obj, {}, container_count, sort_keys, no_float32, default) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:torrents; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, dictionary_splat_pattern; 5, 6; 6, identifier:filters; 7, block; 7, 8; 7, 12; 7, 37; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:params; 11, dictionary; ... | def torrents(self, **filters):
params = {}
for name, value in filters.items():
name = 'filter' if name == 'status' else name
params[name] = value
return self._get('query/torrents', params=params) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_get_global_color_table; 3, parameters; 3, 4; 4, identifier:colors; 5, block; 5, 6; 5, 24; 5, 43; 5, 55; 5, 69; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:global_color_table; 9, call; 9, 10; 9, 13; 10, attribute; 10... | def _get_global_color_table(colors):
global_color_table = b''.join(c[0] for c in colors.most_common())
full_table_size = 2**(1+int(get_color_table_size(len(colors)), 2))
repeats = 3 * (full_table_size - len(colors))
zeros = struct.pack('<{}x'.format(repeats))
return global_color_table + zeros |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:good_sequences_to_track; 3, parameters; 3, 4; 3, 5; 4, identifier:flow; 5, default_parameter; 5, 6; 5, 7; 6, identifier:motion_threshold; 7, float:1.0; 8, block; 8, 9; 8, 13; 8, 17; 8, 64; 8, 95; 8, 135; 8, 166; 8, 170; 8, 174; 8, 295; 9, expre... | def good_sequences_to_track(flow, motion_threshold=1.0):
endpoints = []
in_low = False
for i, val in enumerate(flow):
if val < motion_threshold:
if not in_low:
endpoints.append(i)
in_low = True
else:
if in_low:
endpoints... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_generate_comparator; 3, parameters; 3, 4; 3, 5; 4, identifier:cls; 5, identifier:field_names; 6, block; 6, 7; 6, 14; 6, 24; 6, 57; 6, 71; 6, 153; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:field_names; 10, call; 1... | def _generate_comparator(cls, field_names):
field_names = list(field_names)
reverses = [1] * len(field_names)
for i, field_name in enumerate(field_names):
if field_name[0] == '-':
reverses[i] = -1
field_names[i] = field_name[1:]
field_names = [... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_segment_points; 3, parameters; 3, 4; 3, 5; 4, identifier:Aps; 5, identifier:Bps; 6, block; 6, 7; 6, 11; 6, 15; 6, 24; 6, 148; 6, 168; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:mid; 10, list:[]; 11, expression... | def sort_segment_points(Aps, Bps):
mid = []
j = 0
mid.append(Aps[0])
for i in range(len(Aps)-1):
dist = distance_tt_point(Aps[i], Aps[i+1])
for m in range(j, len(Bps)):
distm = distance_tt_point(Aps[i], Bps[m])
if dist > distm:
direction = dot(norm... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 43; 2, function_name:works; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 3, 35; 3, 38; 3, 41; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ids; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identi... | def works(self, ids = None, query = None, filter = None, offset = None,
limit = None, sample = None, sort = None,
order = None, facet = None, select = None, cursor = None,
cursor_max = 5000, **kwargs):
'''
Search Crossref works
:param ids: [Array] DOIs (... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 43; 2, function_name:prefixes; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 3, 35; 3, 38; 3, 41; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ids; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, ide... | def prefixes(self, ids = None, filter = None, offset = None,
limit = None, sample = None, sort = None,
order = None, facet = None, works = False, select = None,
cursor = None, cursor_max = 5000, **kwargs):
'''
Search Crossref prefixes
:param ids: [Array]... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 46; 2, function_name:types; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 3, 35; 3, 38; 3, 41; 3, 44; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ids; 7, None; 8, default_parameter; 8, 9; 8, 10; 9,... | def types(self, ids = None, query = None, filter = None, offset = None,
limit = None, sample = None, sort = None,
order = None, facet = None, works = False, select = None,
cursor = None, cursor_max = 5000, **kwargs):
'''
Search Crossref types
:param ids:... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 28; 2, function_name:licenses; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:query; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:offset; 10, None; 11, def... | def licenses(self, query = None, offset = None,
limit = None, sample = None, sort = None,
order = None, facet = None, **kwargs):
'''
Search Crossref licenses
:param query: [String] A query string
:param offset: [Fixnum] Number of record to start at, from 1 to ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_graph_component; 3, parameters; 3, 4; 4, identifier:graph; 5, block; 5, 6; 5, 20; 5, 30; 5, 40; 5, 55; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:components; 9, call; 9, 10; 9, 11; 10, identifier:map; 11, argume... | def get_graph_component(graph):
components = map(partial(_visit, graph=graph), graph)
node_component = dict(_gen_node_component(components))
graph_component = {component: [] for component in components}
graph_component.update(
dict(_gen_graph_component(graph, node_component, _gen_graph_value)))
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:pipe_fetchdata; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 4, default_parameter; 4, 5; 4, 6; 5, identifier:context; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:_INPUT; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifier:c... | def pipe_fetchdata(context=None, _INPUT=None, conf=None, **kwargs):
funcs = get_splits(None, conf, **cdicts(opts, kwargs))
parsed = get_parsed(_INPUT, funcs[0])
results = starmap(parse_result, parsed)
items = imap(utils.gen_items, results)
_OUTPUT = utils.multiplex(items)
return _OUTPUT |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:pipe_sort; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 4, default_parameter; 4, 5; 4, 6; 5, identifier:context; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:_INPUT; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifier:conf; ... | def pipe_sort(context=None, _INPUT=None, conf=None, **kwargs):
test = kwargs.pop('pass_if', None)
_pass = utils.get_pass(test=test)
key_defs = imap(DotDict, utils.listize(conf['KEY']))
get_value = partial(utils.get_value, **kwargs)
parse_conf = partial(utils.parse_conf, parse_func=get_value, **kwarg... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:asyncPipeStringtokenizer; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 4, default_parameter; 4, 5; 4, 6; 5, identifier:context; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:_INPUT; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, id... | def asyncPipeStringtokenizer(context=None, _INPUT=None, conf=None, **kwargs):
conf['delimiter'] = conf.pop('to-str', dict.get(conf, 'delimiter'))
splits = yield asyncGetSplits(_INPUT, conf, **cdicts(opts, kwargs))
parsed = yield asyncDispatch(splits, *get_async_dispatch_funcs())
items = yield asyncStarM... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 24; 2, function_name:alphabeta; 3, parameters; 3, 4; 3, 5; 3, 17; 4, identifier:game; 5, default_parameter; 5, 6; 5, 7; 6, identifier:alpha_beta; 7, tuple; 7, 8; 7, 13; 8, unary_operator:-; 8, 9; 9, call; 9, 10; 9, 11; 10, identifier:float; 11, argument_list; 11, ... | def alphabeta(game, alpha_beta=(-float('inf'), float('inf')),
player=dominoes.players.identity):
'''
Runs minimax search with alpha-beta pruning on the provided game.
:param Game game: game to search
:param tuple alpha_beta: a tuple of two floats that indicate
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:csv; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:cls; 5, identifier:d; 6, default_parameter; 6, 7; 6, 8; 7, identifier:order; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:header; 11, None; 12, default_parameter; ... | def csv(cls,
d,
order=None,
header=None,
sort_keys=True):
first_element = list(d)[0]
def _keys():
return list(d[first_element])
def _get(element, key):
try:
tmp = str(d[element][key])
except:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:deauthorize_application; 3, parameters; 3, 4; 4, identifier:request; 5, block; 5, 6; 6, if_statement; 6, 7; 6, 10; 6, 48; 7, attribute; 7, 8; 7, 9; 8, identifier:request; 9, identifier:facebook; 10, block; 10, 11; 10, 32; 10, 38; 10, 44; 11, ex... | def deauthorize_application(request):
if request.facebook:
user = User.objects.get(
facebook_id = request.facebook.signed_request.user.id
)
user.authorized = False
user.save()
return HttpResponse()
else:
return HttpResponse(status=400) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_handle_send_response; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:result; 6, identifier:payloadsByTopicPart; 7, identifier:deferredsByTopicPart; 8, block; 8, 9; 8, 50; 8, 98; 8, 122; 8, 267; 8, 271; 8, 412; 8, 471;... | def _handle_send_response(self, result, payloadsByTopicPart,
deferredsByTopicPart):
def _deliver_result(d_list, result=None):
for d in d_list:
if not isinstance(d, Deferred):
_deliver_result(d, result)
else:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:ordering_url; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:field_name; 6, block; 6, 7; 6, 15; 6, 19; 6, 31; 6, 50; 6, 59; 6, 71; 6, 78; 6, 117; 6, 121; 6, 192; 6, 203; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9... | def ordering_url(self, field_name):
path = self.request.path
direction = ""
query_params = self.request.GET.copy()
ordering = self.request.GET.get("order", "").split(",")
field = self._get_ordering_field_lookup(field_name)
if not ordering:
ordering = self.get_... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:load_maf; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:path; 5, default_parameter; 5, 6; 5, 7; 6, identifier:optional_cols; 7, list:[]; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sort_key; 10, identifier:variant_as... | def load_maf(
path,
optional_cols=[],
sort_key=variant_ascending_position_sort_key,
distinct=True,
raise_on_error=True,
encoding=None):
maf_df = load_maf_dataframe(path, raise_on_error=raise_on_error, encoding=encoding)
if len(maf_df) == 0 and raise_on_error:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 34; 2, function_name:load_vcf; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 25; 3, 28; 3, 31; 4, identifier:path; 5, default_parameter; 5, 6; 5, 7; 6, identifier:genome; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:reference_vcf_key... | def load_vcf(
path,
genome=None,
reference_vcf_key="reference",
only_passing=True,
allow_extended_nucleotides=False,
include_info=True,
chunk_size=10 ** 5,
max_variants=None,
sort_key=variant_ascending_position_sort_key,
distinct=True):
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:top_expression_effect; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:expression_levels; 6, block; 6, 7; 6, 16; 6, 26; 6, 44; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:effect_expression_dict; 10, cal... | def top_expression_effect(self, expression_levels):
effect_expression_dict = self.effect_expression(expression_levels)
if len(effect_expression_dict) == 0:
return None
def key_fn(effect_fpkm_pair):
(effect, fpkm) = effect_fpkm_pair
return (fpkm, multi_gene_eff... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sort; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:callback; 7, None; 8, block; 8, 9; 8, 15; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:items; 12, attribute; ... | def sort(self, callback=None):
items = self.items
if callback:
return self.__class__(sorted(items, key=callback))
else:
return self.__class__(sorted(items)) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:scan_for_spec; 3, parameters; 3, 4; 4, identifier:keyword; 5, block; 5, 6; 5, 20; 5, 29; 5, 44; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:keyword; 9, call; 9, 10; 9, 18; 10, attribute; 10, 11; 10, 17; 11, call; 11,... | def scan_for_spec(keyword):
keyword = keyword.lstrip('(').rstrip(')')
matches = release_line_re.findall(keyword)
if matches:
return Spec(">={}".format(matches[0]))
try:
return Spec(keyword)
except ValueError:
return None |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 26; 2, function_name:get_students; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:gradebook_id; 7, string:''; 8, default_parameter; 8, 9; 8, 10; 9, identifier:simple; 10, Fals... | def get_students(
self,
gradebook_id='',
simple=False,
section_name='',
include_photo=False,
include_grade_info=False,
include_grade_history=False,
include_makeup_grades=False
):
params = dict(
includ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_staff; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:gradebook_id; 6, default_parameter; 6, 7; 6, 8; 7, identifier:simple; 8, False; 9, block; 9, 10; 9, 33; 9, 81; 10, expression_statement; 10, 11; 11, assignment; 11, 1... | def get_staff(self, gradebook_id, simple=False):
staff_data = self.get(
'staff/{gradebookId}'.format(
gradebookId=gradebook_id or self.gradebook_id
),
params=None,
)
if simple:
simple_list = []
unraveled_list = self.unra... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_course_guide_staff; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:course_id; 7, string:''; 8, block; 8, 9; 8, 32; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifie... | def get_course_guide_staff(self, course_id=''):
staff_data = self.get(
'courseguide/course/{courseId}/staff'.format(
courseId=course_id or self.course_id
),
params=None
)
return staff_data['response']['docs'] |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 30; 2, function_name:optimize; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 15; 3, 18; 3, 21; 3, 24; 3, 27; 4, identifier:self; 5, identifier:problem; 6, default_parameter; 6, 7; 6, 8; 7, identifier:max_iterations; 8, integer:100; 9, default_parameter; 9, 10; 9, 11; ... | def optimize(self, problem, max_iterations=100, max_seconds=float('inf'),
cache_encoded=True, cache_solution=False, clear_cache=True,
logging_func=_print_fitnesses,
n_processes=0):
if not isinstance(problem, Problem):
raise TypeError('problem must b... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:inspect; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 16; 5, 23; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:inspector; 9, call; 9, 10; 9, 15; 10, attribute; 10, 11; 10, 14; 11, attribute; 11, 12; 11, ... | def inspect(self):
inspector = stix2patterns.inspector.InspectionListener()
self.walk(inspector)
return inspector.pattern_data() |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 22; 2, function_name:best_kmers; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 4, identifier:dt; 5, identifier:response; 6, identifier:sequence; 7, default_parameter; 7, 8; 7, 9; 8, identifier:k; 9, integer:6; 10, default_parameter; 10, 11; 10... | def best_kmers(dt, response, sequence, k=6, consider_shift=True, n_cores=1,
seq_align="start", trim_seq_len=None):
y = dt[response]
seq = dt[sequence]
if trim_seq_len is not None:
seq = pad_sequences(seq, align=seq_align, maxlen=trim_seq_len)
seq = [s.replace("N", "") for s in... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_custom_rdd_reduce; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:reduce_func; 6, block; 6, 7; 6, 47; 6, 62; 7, function_definition; 7, 8; 7, 9; 7, 11; 8, function_name:accumulating_iter; 9, parameters; 9, 10; 10, identifier:iter... | def _custom_rdd_reduce(self, reduce_func):
def accumulating_iter(iterator):
acc = None
for obj in iterator:
if acc is None:
acc = obj
else:
acc = reduce_func(acc, obj)
if acc is not None:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:__sort_analyses; 3, parameters; 3, 4; 4, identifier:sentence; 5, block; 5, 6; 5, 8; 5, 64; 6, expression_statement; 6, 7; 7, string:''' Sorts analysis of all the words in the sentence.
This is required for consistency, because by defau... | def __sort_analyses(sentence):
''' Sorts analysis of all the words in the sentence.
This is required for consistency, because by default, analyses are
listed in arbitrary order; '''
for word in sentence:
if ANALYSIS not in word:
raise Exception( '(!) Error: no analysis foun... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:tag; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:text; 6, block; 6, 7; 6, 43; 6, 52; 6, 82; 7, if_statement; 7, 8; 7, 13; 7, 25; 8, comparison_operator:==; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, ident... | def tag(self, text):
if self.search_method == 'ahocorasick':
events = self._find_keywords_ahocorasick(text.text)
elif self.search_method == 'naive':
events = self._find_keywords_naive(text.text)
events = self._resolve_conflicts(events)
if self.mapping:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:search; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:cls; 5, identifier:term; 6, default_parameter; 6, 7; 6, 8; 7, identifier:fields; 8, tuple; 9, block; 9, 10; 9, 31; 9, 43; 9, 51; 9, 62; 9, 74; 9, 78; 9, 82; 9, 147; 9, 162; 9, 172; 10, if_s... | def search(cls, term, fields=()):
if not any((cls._meta.search_fields, fields)):
raise AttributeError(
"A list of searchable fields must be provided in the class's "
"search_fields or provided to this function in the `fields` "
"kwarg."
)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:dependency_sort; 3, parameters; 3, 4; 4, identifier:dependency_tree; 5, block; 5, 6; 5, 10; 5, 16; 5, 35; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:sorted; 9, list:[]; 10, expression_statement; 10, 11; 11, assignme... | def dependency_sort(dependency_tree):
sorted = []
processed = set()
for key, deps in dependency_tree.iteritems():
_sort_r(sorted, processed, key, deps, dependency_tree)
return sorted |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_sort_r; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:sorted; 5, identifier:processed; 6, identifier:key; 7, identifier:deps; 8, identifier:dependency_tree; 9, block; 9, 10; 9, 16; 9, 23; 9, 62; 10, if_statement; 10, 11; 10, 14; 1... | def _sort_r(sorted, processed, key, deps, dependency_tree):
if key in processed:
return
processed.add(key)
for dep_key in deps:
dep_deps = dependency_tree.get(dep_key)
if dep_deps is None:
log.debug('"%s" not found, skipped', Repr(dep_key))
continue
_s... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:list; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:count; 7, integer:30; 8, default_parameter; 8, 9; 8, 10; 9, identifier:order; 10, string:'user_ptime'; 11, default_... | def list(self, count=30, order='user_ptime', asc=False, show_dir=True,
natsort=True):
if self.cid is None:
return False
self.reload()
kwargs = {}
kwargs['cid'] = self.cid
kwargs['asc'] = 1 if asc is True else 0
kwargs['show_dir'] = 1 if show_dir i... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:list_items; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort_key; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:reverse; 10, False; 11, block; 11, 12; 11, 25; 11, 40; 12, exp... | def list_items(self, sort_key=None, reverse=False):
items = list(self.items.values())
if sort_key:
items.sort(key=sort_key, reverse=reverse)
return items |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_prepare_axes; 3, parameters; 3, 4; 3, 5; 4, identifier:node; 5, identifier:sort_key; 6, block; 6, 7; 6, 13; 6, 19; 6, 36; 6, 40; 6, 121; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:links; 10, attribute; 10, 11; 10,... | def _prepare_axes(node, sort_key):
links = node.links
o_links = node._overlapping_links
overlap = {ax2 for ax in links for ax2 in o_links.get(ax, [])}
axes = []
for axis in sorted(links.keys(), key=sort_key):
if axis in overlap: continue
tgt = links[axis]
if axis in o_links:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_vid_split; 3, parameters; 3, 4; 4, identifier:vs; 5, block; 5, 6; 5, 15; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:match; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:var_re; 12, identi... | def sort_vid_split(vs):
match = var_re.match(vs)
if match is None:
raise ValueError('Invalid variable string: {}'.format(str(vs)))
else:
return match.groups() |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:properties; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 15; 5, 24; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:d; 9, call; 9, 10; 9, 11; 10, identifier:dict; 11, argument_list; 11, 12; 12, attribute; ... | def properties(self):
d = dict(self.sortinfo)
if CVARSORT in d:
del d[CVARSORT]
return d |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:build_messages_modules; 3, parameters; 3, 4; 4, identifier:messages; 5, block; 5, 6; 5, 15; 5, 54; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:data; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifie... | def build_messages_modules(messages):
data = collections.defaultdict(list)
for line in messages:
module_name = line.get('module')
module_path = line.get('path')
module_info = ModuleInfo(
module_name,
module_path,
)
data[module_info].append(line)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:write; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:nml; 5, identifier:nml_path; 6, default_parameter; 6, 7; 6, 8; 7, identifier:force; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:sort; 11, False; 12, block; 12, 13; 12... | def write(nml, nml_path, force=False, sort=False):
if not isinstance(nml, Namelist) and isinstance(nml, dict):
nml_in = Namelist(nml)
else:
nml_in = nml
nml_in.write(nml_path, force=force, sort=sort) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:date_key; 3, parameters; 3, 4; 3, 5; 4, identifier:cls; 5, identifier:month_string; 6, block; 6, 7; 6, 18; 6, 26; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 12; 9, pattern_list; 9, 10; 9, 11; 10, identifier:month; 11, identifier:yea... | def date_key(cls, month_string):
month, year = month_string.split(',')
month_ord = cls.month_ordinal[month]
return year, month_ord |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:SynchronizedClassMethod; 3, parameters; 3, 4; 3, 6; 4, list_splat_pattern; 4, 5; 5, identifier:locks_attr_names; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 19; 8, 28; 8, 50; 8, 176; 9, expression_statement; 9, 1... | def SynchronizedClassMethod(*locks_attr_names, **kwargs):
locks_attr_names = [
lock_name for lock_name in locks_attr_names if lock_name
]
if not locks_attr_names:
raise ValueError("The lock names list can't be empty")
if "sorted" not in kwargs or kwargs["sorted"]:
locks_attr_name... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:__sort_registry; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:svc_ref; 6, block; 6, 7; 7, with_statement; 7, 8; 7, 13; 8, with_clause; 8, 9; 9, with_item; 9, 10; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, identifier... | def __sort_registry(self, svc_ref):
with self.__svc_lock:
if svc_ref not in self.__svc_registry:
raise BundleException("Unknown service: {0}".format(svc_ref))
for spec in svc_ref.get_property(OBJECTCLASS):
spec_refs = self.__svc_specs[spec]
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:sorted_timezones; 3, parameters; 4, block; 4, 5; 4, 59; 4, 67; 4, 71; 4, 91; 4, 138; 4, 220; 4, 226; 5, function_definition; 5, 6; 5, 7; 5, 9; 6, function_name:hourmin; 7, parameters; 7, 8; 8, identifier:delta; 9, block; 9, 10; 9, 45; 9, 55; 10... | def sorted_timezones():
def hourmin(delta):
if delta.days < 0:
hours, remaining = divmod(86400 - delta.seconds, 3600)
else:
hours, remaining = divmod(delta.seconds, 3600)
minutes, remaining = divmod(remaining, 60)
return hours, minutes
now = datetime.utcno... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:alphanum_order; 3, parameters; 3, 4; 4, identifier:triples; 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:triples; 11, keyword_argument; 11, 12; 11, 13; 12, ... | def alphanum_order(triples):
return sorted(
triples,
key=lambda t: [
int(t) if t.isdigit() else t
for t in re.split(r'([0-9]+)', t.relation or '')
]
) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_encode_penman; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:g; 6, default_parameter; 6, 7; 6, 8; 7, identifier:top; 8, None; 9, block; 9, 10; 9, 21; 9, 32; 9, 40; 9, 50; 9, 131; 9, 138; 9, 143; 9, 211; 9, 263; 9, 268; 9, ... | def _encode_penman(self, g, top=None):
if top is None:
top = g.top
remaining = set(g.triples())
variables = g.variables()
store = defaultdict(lambda: ([], []))
for t in g.triples():
if t.inverted:
store[t.target][0].append(t)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:copy; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, return_statement; 6, 7; 7, call; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:__class__; 11, argument_list; 11, 12; 11, 13; 11, 18; 12, identifier:s... | def copy(self):
return self.__class__(self, key=self._key, load=self._load) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:copy; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, return_statement; 6, 7; 7, call; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:__class__; 11, argument_list; 11, 12; 11, 15; 11, 18; 12, attribute; 1... | def copy(self):
return self.__class__(self._key, self._load, self._iteritems()) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sort_group; 3, parameters; 3, 4; 3, 5; 4, identifier:d; 5, default_parameter; 5, 6; 5, 7; 6, identifier:return_only_first; 7, False; 8, block; 8, 9; 8, 11; 8, 18; 8, 25; 8, 44; 9, expression_statement; 9, 10; 10, string:''' Sort a dictionary of... | def sort_group(d, return_only_first=False):
''' Sort a dictionary of relative paths and cluster equal paths together at the same time '''
d_sort = sort_dict_of_paths(d)
base_elt = (-1, None)
while (base_elt[1] is None and d_sort):
base_elt = d_sort.pop(0)
if base_elt[1] is None:
retu... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:group_files_by_size_fast; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:fileslist; 5, identifier:nbgroups; 6, default_parameter; 6, 7; 6, 8; 7, identifier:mode; 8, integer:1; 9, block; 9, 10; 9, 12; 9, 18; 9, 22; 9, 26; 9, 45; 9, 50; 9, 302; 1... | def group_files_by_size_fast(fileslist, nbgroups, mode=1):
'''Given a files list with sizes, output a list where the files are grouped in nbgroups per cluster.
Pseudo-code for algorithm in O(n log(g)) (thank's to insertion sort or binary search trees)
See for more infos: http://cs.stackexchange.com/question... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:print_; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:rows; 5, default_parameter; 5, 6; 5, 7; 6, identifier:limit; 7, integer:15; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sort; 10, string:'size'; 11, default_parameter; 11, 12; ... | def print_(rows, limit=15, sort='size', order='descending'):
localrows = []
for row in rows:
localrows.append(list(row))
sortby = ['type', '
if sort not in sortby:
raise ValueError("invalid sort, should be one of" + str(sortby))
orders = ['ascending', 'descending']
if order not i... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:split_and_sort; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 17; 5, 35; 5, 50; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:graphs; 9, call; 9, 10; 9, 11; 10, identifier:list; 11, argument_list; 11, 12;... | def split_and_sort(self):
graphs = list(self.split())
graphs.sort(key=lambda x: -len(x.metadata))
for index, graph in enumerate(graphs):
graph.index = index
return graphs |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 31; 2, function_name:profile; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 3, 25; 4, default_parameter; 4, 5; 4, 6; 5, identifier:fn; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:skip; 9, integer:0; 10, default_parameter; 10, 11; 10, 1... | def profile(fn=None, skip=0, filename=None, immediate=False, dirs=False,
sort=None, entries=40,
profiler=('cProfile', 'profile', 'hotshot')):
if fn is None:
def decorator(fn):
return profile(fn, skip=skip, filename=filename,
immediate=immediate,... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_get_kernel_arguments; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 36; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:declarations; 9, list:[]; 10, for_statement; 10, 11; 10, 14; 10, 21; 11, patte... | def _get_kernel_arguments(self):
declarations = []
for name, data in self._kernel_data.items():
declarations.extend(data.get_kernel_parameters('_' + name))
return declarations |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:topological_sort; 3, parameters; 3, 4; 4, identifier:data; 5, block; 5, 6; 5, 36; 5, 58; 5, 87; 5, 114; 5, 215; 5, 220; 5, 229; 5, 236; 5, 241; 5, 245; 5, 278; 6, function_definition; 6, 7; 6, 8; 6, 10; 7, function_name:check_self_dependencies;... | def topological_sort(data):
def check_self_dependencies(input_data):
for k, v in input_data.items():
if k in v:
raise ValueError('Self-dependency, {} depends on itself.'.format(k))
def prepare_input_data(input_data):
return {k: set(v) for k, v in input_data.items()}
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:get_posts; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:include_draft; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:filter_functions; 10, None; 11, block; 11, 12; 11, 136; 1... | def get_posts(self, include_draft=False, filter_functions=None):
def posts_generator(path):
if os.path.isdir(path):
for file in os.listdir(path):
filename, ext = os.path.splitext(file)
format_name = get_standard_format_name(ext[1:])
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:arbitrary_object_to_string; 3, parameters; 3, 4; 4, identifier:a_thing; 5, block; 5, 6; 5, 13; 5, 24; 5, 50; 5, 65; 5, 81; 5, 93; 5, 159; 5, 169; 6, if_statement; 6, 7; 6, 10; 7, comparison_operator:is; 7, 8; 7, 9; 8, identifier:a_thing; 9, Non... | def arbitrary_object_to_string(a_thing):
if a_thing is None:
return ''
if isinstance(a_thing, six.string_types):
return a_thing
if six.PY3 and isinstance(a_thing, six.binary_type):
try:
return a_thing.decode('utf-8')
except UnicodeDecodeError:
pass
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:add_parser; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:args; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 16; 9, 24; 9, 32; 9, 38; 9, 50; 9, 66; 9, 84; 10, exp... | def add_parser(self, *args, **kwargs):
command_name = args[0]
new_kwargs = kwargs.copy()
new_kwargs['configman_subparsers_option'] = self._configman_option
new_kwargs['subparser_name'] = command_name
subparsers = self._configman_option.foreign_data.argparse.subparsers
a_s... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_parse_and_sort_accept_header; 3, parameters; 3, 4; 4, identifier:accept_header; 5, block; 5, 6; 6, return_statement; 6, 7; 7, call; 7, 8; 7, 9; 8, identifier:sorted; 9, argument_list; 9, 10; 9, 23; 9, 31; 10, list_comprehension; 10, 11; 10, 15... | def _parse_and_sort_accept_header(accept_header):
return sorted([_split_into_mimetype_and_priority(x) for x in accept_header.split(',')],
key=lambda x: x[1], reverse=True) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_name; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 23; 6, if_statement; 6, 7; 6, 16; 7, boolean_operator:and; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:_record; 11, attribute; 11, 12; 11, 15;... | def sort_name(self):
if self._record and self._record.sort_name:
return self._record.sort_name
return self.name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.