sequence
stringlengths
492
15.9k
code
stringlengths
75
8.58k
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sortby; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:ntd; 6, block; 6, 7; 7, if_statement; 7, 8; 7, 19; 7, 34; 8, comparison_operator:in; 8, 9; 8, 10; 9, string:'reldepth'; 10, subscript; 10, 11; 10, 18; 11, attribute; 11, 12; 1...
def sortby(self, ntd): if 'reldepth' in self.grprobj.gosubdag.prt_attr['flds']: return [ntd.NS, -1*ntd.dcnt, ntd.reldepth] else: return [ntd.NS, -1*ntd.dcnt, ntd.depth]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_nts_sorted; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:hdrgo_prt; 6, identifier:hdrgos; 7, identifier:hdrgo_sort; 8, block; 8, 9; 8, 13; 8, 23; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11...
def get_nts_sorted(self, hdrgo_prt, hdrgos, hdrgo_sort): nts_flat = [] self.get_sorted_hdrgo2usrgos(hdrgos, nts_flat, hdrgo_prt, hdrgo_sort) return nts_flat
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:get_sorted_hdrgo2usrgos; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:hdrgos; 6, default_parameter; 6, 7; 6, 8; 7, identifier:flat_list; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:hdrgo_prt; ...
def get_sorted_hdrgo2usrgos(self, hdrgos, flat_list=None, hdrgo_prt=True, hdrgo_sort=True): sorted_hdrgos_usrgos = [] h2u_get = self.grprobj.hdrgo2usrgos.get hdr_go2nt = self._get_go2nt(hdrgos) if hdrgo_sort is True: hdr_go2nt = sorted(hdr_go2nt.items(), key=lambda t: self.hd...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_init_hdrgo_sortby; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:hdrgo_sortby; 6, identifier:sortby; 7, block; 7, 8; 7, 15; 7, 22; 8, if_statement; 8, 9; 8, 12; 9, comparison_operator:is; 9, 10; 9, 11; 10, identifier:hdrgo...
def _init_hdrgo_sortby(self, hdrgo_sortby, sortby): if hdrgo_sortby is not None: return hdrgo_sortby if sortby is not None: return sortby return self.sortby
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_get_sortgo; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 23; 6, if_statement; 6, 7; 6, 14; 7, comparison_operator:in; 7, 8; 7, 9; 8, string:'sortgo'; 9, attribute; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self...
def _get_sortgo(self): if 'sortgo' in self.datobj.kws: return self.datobj.kws['sortgo'] return self.datobj.grprdflt.gosubdag.prt_attr['sort'] + "\n"
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_get_sorted_section; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:nts_section; 6, block; 6, 7; 6, 32; 6, 47; 7, if_statement; 7, 8; 7, 13; 8, comparison_operator:is; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:self; ...
def _get_sorted_section(self, nts_section): if self.section_sortby is True: return sorted(nts_section, key=lambda nt: self.sortgos.usrgo_sortby(nt)) if self.section_sortby is False or self.section_sortby is None: return nts_section return sorted(nts_section, key=lambda nt...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_sections_2dnt; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:sec2d_go; 6, block; 6, 7; 7, return_statement; 7, 8; 8, list_comprehension; 8, 9; 8, 17; 9, tuple; 9, 10; 9, 11; 10, identifier:nm; 11, call; 11, 12; 11, 15; 12, at...
def get_sections_2dnt(self, sec2d_go): return [(nm, self.get_ntgos_sorted(gos)) for nm, gos in sec2d_go]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_ntgos_sorted; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:hdrgos; 6, block; 6, 7; 6, 15; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:go2nt; 10, attribute; 10, 11; 10, 14; 11, attribute; 11, 12; ...
def get_ntgos_sorted(self, hdrgos): go2nt = self.grprobj.go2nt return sorted([go2nt[go] for go in hdrgos if go in go2nt], key=self.fncsortnt)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_sortobj; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:goea_results; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kws; 8, block; 8, 9; 8, 22; 8, 34; 8, 46; 8, 65; 8, 74; 8, 93; 9, expression_statement; 9, 10; 10, as...
def get_sortobj(self, goea_results, **kws): nts_goea = MgrNtGOEAs(goea_results).get_goea_nts_prt(**kws) goids = set(nt.GO for nt in nts_goea) go2nt = {nt.GO:nt for nt in nts_goea} grprobj = Grouper("GOEA", goids, self.hdrobj, self.grprdflt.gosubdag, go2nt=go2nt) grprobj.prt_summa...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_get_sorted_relationships; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:goterm; 6, block; 6, 7; 6, 17; 6, 28; 6, 43; 7, if_statement; 7, 8; 7, 15; 8, comparison_operator:in; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifie...
def _get_sorted_relationships(self, goterm): if goterm.id in self.goids_seen: return self.goids_seen.add(goterm.id) for goterm_upper in goterm.get_goterms_upper(): self._get_sorted_relationships(goterm_upper) self.goterms_sorted.append(goterm)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:write_dag; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:out; 7, attribute; 7, 8; 7, 9; 8, identifier:sys; 9, identifier:stdout; 10, block; 10, 11; 11, for_statement; 11, 12; 11, 13; 11, 21; 12,...
def write_dag(self, out=sys.stdout): for rec in sorted(self.values()): print(rec, file=out)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:sort_nts; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:nt_list; 6, identifier:codekey; 7, block; 7, 8; 7, 28; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:sortby; 11, lambda; 11, 12; 11, 14; 1...
def sort_nts(self, nt_list, codekey): sortby = lambda nt: self.ev2idx.get(getattr(nt, codekey), -1) return sorted(nt_list, key=sortby)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:prt_gos; 3, parameters; 3, 4; 3, 5; 3, 10; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:prt; 7, attribute; 7, 8; 7, 9; 8, identifier:sys; 9, identifier:stdout; 10, dictionary_splat_pattern; 10, 11; 11, identifier:kws_usr...
def prt_gos(self, prt=sys.stdout, **kws_usr): desc2nts = self.get_desc2nts(**kws_usr) self.prt_nts(desc2nts, prt, kws_usr.get('prtfmt')) return desc2nts
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:get_nts_flat; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:hdrgo_prt; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:use_sections; 10, True; 11, block; 11, 12; 11, 43; 11, 59; ...
def get_nts_flat(self, hdrgo_prt=True, use_sections=True): if self.sectobj is None or not use_sections: return self.sortgos.get_nts_sorted( hdrgo_prt, hdrgos=self.grprobj.get_hdrgos(), hdrgo_sort=True) if not use_sections: return se...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_adjust_prt_flds; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:kws_xlsx; 6, identifier:desc2nts; 7, identifier:shade_hdrgos; 8, block; 8, 9; 8, 18; 8, 28; 8, 32; 8, 43; 8, 78; 9, if_statement; 9, 10; 9, 13; 10, compa...
def _adjust_prt_flds(self, kws_xlsx, desc2nts, shade_hdrgos): if "prt_flds" in kws_xlsx: return kws_xlsx["prt_flds"] dont_print = set(['hdr_idx', 'is_hdrgo', 'is_usrgo']) prt_flds_adjusted = [] nt_flds = self.sortobj.get_fields(desc2nts) for nt_fld in nt_flds: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_get_shade_hdrgos; 3, parameters; 3, 4; 4, dictionary_splat_pattern; 4, 5; 5, identifier:kws; 6, block; 6, 7; 6, 16; 6, 25; 6, 36; 6, 51; 7, if_statement; 7, 8; 7, 11; 8, comparison_operator:in; 8, 9; 8, 10; 9, string:'shade_hdrgos'; 10, identi...
def _get_shade_hdrgos(**kws): if 'shade_hdrgos' in kws: return kws['shade_hdrgos'] if 'hdrgo_prt' in kws: return kws['hdrgo_prt'] if 'section_sortby' in kws and kws['section_sortby']: return False if 'top_n' in kws and isinstance(kws['top_n'], int): ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:dflt_sortby_objgoea; 3, parameters; 3, 4; 4, identifier:goea_res; 5, block; 5, 6; 6, return_statement; 6, 7; 7, list:[getattr(goea_res, 'enrichment'), getattr(goea_res, 'namespace'), getattr(goea_res, 'p_uncorrec...
def dflt_sortby_objgoea(goea_res): return [getattr(goea_res, 'enrichment'), getattr(goea_res, 'namespace'), getattr(goea_res, 'p_uncorrected'), getattr(goea_res, 'depth'), getattr(goea_res, 'GO')]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:dflt_sortby_ntgoea; 3, parameters; 3, 4; 4, identifier:ntgoea; 5, block; 5, 6; 6, return_statement; 6, 7; 7, list:[ntgoea.enrichment, ntgoea.namespace, ntgoea.p_uncorrected, ntgoea.depth, ...
def dflt_sortby_ntgoea(ntgoea): return [ntgoea.enrichment, ntgoea.namespace, ntgoea.p_uncorrected, ntgoea.depth, ntgoea.GO]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:sort; 3, parameters; 3, 4; 3, 5; 3, 9; 3, 12; 3, 15; 4, identifier:x; 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:reverse; 11, False; 12, def...
def sort(x, axis=-1, reverse=False, with_index=False, only_index=False): from .function_bases import sort as sort_base n_outputs = 2 if with_index and not only_index else 1 return sort_base(x, axis, reverse, with_index, only_index, n_outputs)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:optimize; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 27; 6, with_statement; 6, 7; 6, 17; 7, with_clause; 7, 8; 8, with_item; 8, 9; 9, as_pattern; 9, 10; 9, 15; 10, call; 10, 11; 10, 12; 11, identifier:open; 12, argument_list; 1...
def optimize(self): with open(LIBRARIES_FILE, 'r') as f: libs_data = json.load(f) for alg, libs_names in libs_data.items(): libs = self.get_libs(alg) if not libs: continue self.libs[alg] = [lib for lib in libs if [lib.module_name, lib.func_...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:sort_common_members; 3, parameters; 4, block; 4, 5; 4, 11; 4, 15; 4, 22; 4, 26; 4, 43; 4, 50; 4, 75; 4, 89; 5, expression_statement; 5, 6; 6, assignment; 6, 7; 6, 8; 7, identifier:filename; 8, binary_operator:+; 8, 9; 8, 10; 9, identifier:PREFI...
def sort_common_members(): filename = PREFIX + '/common_members.json' sorted_json_data = {} json_data = read_json(filename) all_keys = [] for key, value in json_data.items(): all_keys.append(key) sorted_keys = sorted(all_keys) for key in sorted_keys: if len(json_data[key]) > ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_ConstructPartitions; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:collection_links; 6, identifier:partitions_per_node; 7, block; 7, 8; 7, 15; 7, 33; 7, 37; 7, 92; 7, 98; 8, expression_statement; 8, 9; 9, assignment; 9, 10...
def _ConstructPartitions(self, collection_links, partitions_per_node): collections_node_count = len(collection_links) partitions = [partition._Partition() for _ in xrange(0, partitions_per_node * collections_node_count)] index = 0 for collection_node in collection_links: hash...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:parse_leap_seconds; 3, parameters; 3, 4; 4, identifier:fileobj; 5, block; 5, 6; 5, 13; 5, 29; 5, 38; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:lines; 9, call; 9, 10; 9, 11; 10, identifier:iter; 11, argument_list; 1...
def parse_leap_seconds(fileobj): lines = iter(fileobj) for line in lines: if line.startswith(b' break else: raise ValueError('Leap_Second.dat is missing its expiration date') line = line.decode('ascii') with _lock: original_locale = locale.setlocale(locale.LC_ALL)...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:build_delta_t_table; 3, parameters; 3, 4; 4, identifier:delta_t_recent; 5, block; 5, 6; 5, 13; 5, 20; 5, 27; 5, 37; 5, 55; 5, 62; 5, 72; 5, 80; 5, 100; 5, 104; 5, 113; 5, 126; 5, 136; 5, 150; 6, expression_statement; 6, 7; 7, assignment; 7, 8; ...
def build_delta_t_table(delta_t_recent): ancient = load_bundled_npy('morrison_stephenson_deltat.npy') historic = load_bundled_npy('historic_deltat.npy') historic_start_time = historic[0,0] i = searchsorted(ancient[0], historic_start_time) bundled = concatenate([ancient[:,:i], historic], axis=1) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 55; 2, function_name:plot_confusion_matrix_with_cv; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 3, 25; 3, 28; 3, 31; 3, 34; 3, 37; 3, 40; 3, 43; 3, 46; 3, 49; 3, 52; 4, identifier:clf; 5, identifier:X; 6, identifier:y; 7, default_para...
def plot_confusion_matrix_with_cv(clf, X, y, labels=None, true_labels=None, pred_labels=None, title=None, normalize=False, hide_zeros=False, x_tick_rotation=0, do_cv=True, cv=None, shu...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 42; 2, function_name:plot_confusion_matrix; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 3, 27; 3, 30; 3, 33; 3, 36; 3, 39; 4, identifier:y_true; 5, identifier:y_pred; 6, default_parameter; 6, 7; 6, 8; 7, identifier:labels; 8, None; 9,...
def plot_confusion_matrix(y_true, y_pred, labels=None, true_labels=None, pred_labels=None, title=None, normalize=False, hide_zeros=False, x_tick_rotation=0, ax=None, figsize=None, cmap='Blues', title_fontsize="large", ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sorting; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 124; 6, if_statement; 6, 7; 6, 15; 7, call; 7, 8; 7, 13; 8, attribute; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, identifier:qs; 12, identifier:get; 13,...
def sorting(self): if self.qs.get('sort'): sorting_results = [] for sort_field in self.qs['sort'].split(','): field = sort_field.replace('-', '') if field not in self.schema._declared_fields: raise InvalidSort("{} has no attribute {}".f...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:filter_query; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:query; 6, identifier:filter_info; 7, identifier:model; 8, block; 8, 9; 8, 33; 9, if_statement; 9, 10; 9, 11; 10, identifier:filter_info; 11, block; 11, 12; 1...
def filter_query(self, query, filter_info, model): if filter_info: filters = create_filters(model, filter_info, self.resource) query = query.filter(*filters) return query
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:sort_query; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:query; 6, identifier:sort_info; 7, block; 7, 8; 7, 66; 8, for_statement; 8, 9; 8, 10; 8, 11; 9, identifier:sort_opt; 10, identifier:sort_info; 11, block; 11, 12; 11,...
def sort_query(self, query, sort_info): for sort_opt in sort_info: field = sort_opt['field'] if not hasattr(self.model, field): raise InvalidSort("{} has no attribute {}".format(self.model.__name__, field)) query = query.order_by(getattr(getattr(self.model, fi...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 25; 2, function_name:_get_log_entries; 3, parameters; 3, 4; 4, identifier:self; 5, type; 5, 6; 6, generic_type; 6, 7; 6, 8; 7, identifier:List; 8, type_parameter; 8, 9; 9, type; 9, 10; 10, generic_type; 10, 11; 10, 12; 11, identifier:Tuple; 12, type_paramete...
def _get_log_entries(self) -> List[Tuple[int, bytes, List[int], bytes]]: if self.is_error: return [] else: return sorted(itertools.chain( self._log_entries, *(child._get_log_entries() for child in self.children) ))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:sort_by_size; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:group_limit; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:discard_others; 10, False; 11, default_parameter; ...
def sort_by_size(self, group_limit=None, discard_others=False, others_label='others'): self.groups = OrderedDict(sorted(six.iteritems(self.groups), key=lambda x: len(x[1]), reverse=True)) if group_limi...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_comments; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:resource; 6, default_parameter; 6, 7; 6, 8; 7, identifier:before; 8, None; 9, block; 9, 10; 9, 27; 9, 67; 10, expression_statement; 10, 11; 11, assignment; 11, 12;...
def get_comments(self, resource, before=None): params = dict(apikey=self.api_key, resource=resource, before=before) try: response = requests.get(self.base + 'comments/get', params=params, proxies=self.proxies) except requests.RequestException as e: return dict(error=e.mes...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:clean_fail; 3, parameters; 3, 4; 4, identifier:func; 5, block; 5, 6; 5, 8; 5, 56; 6, expression_statement; 6, 7; 7, string:''' A decorator to cleanly exit on a failed call to AWS. catch a `botocore.exceptions.ClientError` raised from an...
def clean_fail(func): ''' A decorator to cleanly exit on a failed call to AWS. catch a `botocore.exceptions.ClientError` raised from an action. This sort of error is raised if you are targeting a region that isn't set up (see, `credstash setup`. ''' def func_wrapper(*args, **kwargs): ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:parse_header; 3, parameters; 3, 4; 3, 5; 4, identifier:cls; 5, default_parameter; 5, 6; 5, 7; 6, identifier:value; 7, string:'*/*'; 8, block; 8, 9; 9, expression_statement; 9, 10; 10, yield; 10, 11; 11, call; 11, 12; 11, 13; 12, identifier:sort...
def parse_header(cls, value='*/*'): yield from sorted(( cls.from_string(token.strip()) for token in value.split(',') if token.strip() ), reverse=True)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_canonical; 3, parameters; 3, 4; 3, 5; 4, identifier:keyword; 5, identifier:stmts; 6, block; 6, 7; 6, 22; 6, 26; 6, 39; 6, 105; 6, 120; 7, try_statement; 7, 8; 7, 17; 8, block; 8, 9; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 1...
def sort_canonical(keyword, stmts): try: (_arg_type, subspec) = stmt_map[keyword] except KeyError: return stmts res = [] keep = [s[0] for s in data_def_stmts] + ['case'] for (kw, _spec) in flatten_spec(subspec): comments = [] for s in stmts: if s.keyword =...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 30; 2, function_name:sort; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 3, 27; 4, identifier:self; 5, identifier:key; 6, default_parameter; 6, 7; 6, 8; 7, identifier:start; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:nu...
def sort(self, key, start=None, num=None, by=None, get=None, desc=False, alpha=False, store=None, groups=False): '''Sort and return the list, set or sorted set at ``key``. ``start`` and ``num`` allow for paging through the sorted data ``by`` allows using an external key to weight an...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_url_filemeta; 3, parameters; 3, 4; 4, identifier:url; 5, block; 5, 6; 5, 13; 5, 20; 5, 35; 5, 43; 5, 127; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:parsed_url; 9, call; 9, 10; 9, 11; 10, identifier:try_parse_ur...
def get_url_filemeta(url): parsed_url = try_parse_url(url) if parsed_url is None: return None if parsed_url.scheme.startswith('ftp'): return get_ftp_filemeta(parsed_url) url = parsed_url.geturl() try: r = requests.get(url, stream=True, allow_redirects=True, timeout=5) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 59; 2, function_name:offline_plotly_scatter_bubble; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 32; 3, 35; 3, 38; 3, 50; 3, 56; 4, identifier:df; 5, default_parameter; 5, 6; 5, 7; 6, identifier:x; 7, string:'x'; 8, default_paramet...
def offline_plotly_scatter_bubble(df, x='x', y='y', size_col='size', text_col='text', category_col='category', possible_categories=None, filename=None, config={'displaylogo': False}, x...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:get_acronyms; 3, parameters; 3, 4; 4, default_parameter; 4, 5; 4, 6; 5, identifier:manuscript; 6, call; 6, 7; 6, 12; 7, attribute; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:os; 10, identifier:path; 11, identifier:expanduser; 12, ar...
def get_acronyms(manuscript=os.path.expanduser('~/code/nlpia/lane/manuscript')): acronyms = [] for f, lines in get_lines(manuscript): for line in lines: matches = CRE_ACRONYM.finditer(line) if matches: for m in matches: if m.group('a2'): ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_find; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:rpcmethod; 6, block; 6, 7; 6, 23; 6, 29; 6, 51; 6, 63; 6, 67; 6, 104; 6, 112; 7, expression_statement; 7, 8; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:lo...
async def _find(self, rpcmethod): log.info("crawling network with nearest: %s", str(tuple(self.nearest))) count = self.alpha if self.nearest.get_ids() == self.last_ids_crawled: count = len(self.nearest) self.last_ids_crawled = self.nearest.get_ids() dicts = {} ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 21; 2, function_name:match_key; 3, parameters; 3, 4; 4, identifier:self; 5, type; 5, 6; 6, generic_type; 6, 7; 6, 8; 7, identifier:Tuple; 8, type_parameter; 8, 9; 8, 11; 8, 13; 8, 15; 9, type; 9, 10; 10, identifier:bool; 11, type; 11, 12; 12, identifier:bool...
def match_key(self) -> Tuple[bool, bool, int, List[WeightedPart]]: if self.map is None: raise RuntimeError(f"{self!r} is not bound to a Map") complex_rule = any(weight.converter for weight in self._weights) return (not bool(self.defaults), complex_rule, -len(self._weights), self._wei...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 13; 2, function_name:build_key; 3, parameters; 3, 4; 4, identifier:self; 5, type; 5, 6; 6, generic_type; 6, 7; 6, 8; 7, identifier:Tuple; 8, type_parameter; 8, 9; 8, 11; 9, type; 9, 10; 10, identifier:bool; 11, type; 11, 12; 12, identifier:int; 13, block; 13...
def build_key(self) -> Tuple[bool, int]: if self.map is None: raise RuntimeError(f"{self!r} is not bound to a Map") return (not bool(self.defaults), -sum(1 for weight in self._weights if weight.converter))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:load_ui_file; 3, parameters; 3, 4; 4, identifier:name; 5, block; 5, 6; 5, 14; 5, 31; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:ui; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:gtk; 12, ident...
def load_ui_file(name): ui = gtk.Builder() ui.add_from_file(os.path.join(runtime.data_dir, name)) return ui
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:__remove_category; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:id; 6, block; 6, 7; 6, 26; 6, 30; 6, 39; 6, 48; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:affected_query; 10, assignment; 10, 11; 10,...
def __remove_category(self, id): affected_query = affected_ids = [res[0] for res in self.fetchall(affected_query, (id,))] update = "update activities set category_id = -1 where category_id = ?" self.execute(update, (id, )) self.execute("delete from categories where id = ?", (id, ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_sort; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 13; 8, subscript; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, identifier:__dict__; 12, string:'_z_order...
def _sort(self): self.__dict__['_z_ordered_sprites'] = sorted(self.sprites, key=lambda sprite:sprite.z_order)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_get_mouse_cursor; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, if_statement; 6, 7; 6, 12; 6, 17; 6, 32; 7, comparison_operator:is; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:mouse_cursor; 11, None...
def _get_mouse_cursor(self): if self.mouse_cursor is not None: return self.mouse_cursor elif self.interactive and self.draggable: return gdk.CursorType.FLEUR elif self.interactive: return gdk.CursorType.HAND2
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:entries; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 13; 5, 31; 5, 48; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:log; 11, argument_list; 11, 12; 12, string...
def entries(self): self.log(u"Getting entries") if not self.exists(): self.log_exc(u"This container does not exist. Wrong path?", None, True, TypeError) if self.actual_container is None: self.log_exc(u"The actual container object has not been set", None, True, TypeError) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 19; 5, 26; 5, 37; 5, 44; 5, 51; 5, 132; 5, 139; 6, if_statement; 6, 7; 6, 10; 7, attribute; 7, 8; 7, 9; 8, identifier:self; 9, identifier:is_guaranteed_sorted; 10, block; 10, 11;...
def sort(self): if self.is_guaranteed_sorted: self.log(u"Already sorted, returning") return self.log(u"Sorting...") self.__fragments = sorted(self.__fragments) self.log(u"Sorting... done") self.log(u"Checking relative positions...") for i in range(...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 12; 5, 168; 5, 182; 6, if_statement; 6, 7; 6, 10; 7, attribute; 7, 8; 7, 9; 8, identifier:self; 9, identifier:sorted; 10, block; 10, 11; 11, return_statement; 12, function_defini...
def sort(self): if self.sorted: return def key(variant): requested_key = [] names = set() for i, request in enumerate(self.solver.request_list): if not request.conflict: req = variant.requires_list.get(request.name) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_versions; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 12; 5, 79; 5, 101; 5, 107; 6, if_statement; 6, 7; 6, 10; 7, attribute; 7, 8; 7, 9; 8, identifier:self; 9, identifier:sorted; 10, block; 10, 11; 11, return_statement; 12,...
def sort_versions(self): if self.sorted: return for orderer in (self.solver.package_orderers or []): entries = orderer.reorder(self.entries, key=lambda x: x.package) if entries is not None: self.entries = entries self.sorted = True ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_reset; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:load; 6, block; 6, 7; 6, 18; 6, 24; 6, 30; 6, 38; 6, 46; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:values; 10, call; 10, 11; 10, 12; 11, identif...
def _reset(self, load): values = reduce(iadd, self._lists, []) self._clear() self._load = load self._half = load >> 1 self._dual = load << 1 self._update(values)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_build_index; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 19; 5, 43; 5, 50; 5, 57; 5, 72; 5, 90; 5, 116; 5, 137; 5, 153; 5, 159; 5, 209; 5, 221; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:row0; 9, ca...
def _build_index(self): row0 = list(map(len, self._lists)) if len(row0) == 1: self._index[:] = row0 self._offset = 0 return head = iter(row0) tail = iter(head) row1 = list(starmap(add, zip(head, tail))) if len(row0) & 1: row...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_fromset; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:cls; 5, identifier:values; 6, default_parameter; 6, 7; 6, 8; 7, identifier:key; 8, None; 9, block; 9, 10; 9, 19; 9, 25; 9, 34; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11...
def _fromset(cls, values, key=None): sorted_set = object.__new__(cls) sorted_set._set = values sorted_set.__init__(key=key) return sorted_set
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_argsort_and_resolve_ties; 3, parameters; 3, 4; 3, 5; 4, identifier:time; 5, identifier:random_state; 6, block; 6, 7; 6, 14; 6, 26; 6, 30; 6, 87; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:n_samples; 10, call; 10, ...
def _argsort_and_resolve_ties(time, random_state): n_samples = len(time) order = numpy.argsort(time, kind="mergesort") i = 0 while i < n_samples - 1: inext = i + 1 while inext < n_samples and time[order[i]] == time[order[inext]]: inext += 1 ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:toposort_classes; 3, parameters; 3, 4; 4, identifier:classes; 5, block; 5, 6; 5, 131; 5, 143; 5, 149; 5, 153; 5, 176; 6, function_definition; 6, 7; 6, 8; 6, 13; 7, function_name:get_class_topolist; 8, parameters; 8, 9; 8, 10; 8, 11; 8, 12; 9, i...
def toposort_classes(classes): def get_class_topolist(class_name, name_to_class, processed_classes, current_trace): if class_name in processed_classes: return [] if class_name in current_trace: raise AssertionError( 'Encountered self-reference in dependency ch...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_init_steps; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 12; 5, 20; 5, 27; 5, 31; 5, 58; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:_check_old_yaml_format; ...
def _init_steps(self,): self._check_old_yaml_format() config_steps = self.flow_config.steps self._check_infinite_flows(config_steps) steps = [] for number, step_config in config_steps.items(): specs = self._visit_step(number, step_config) steps.extend(spec...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:ranker; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:X; 6, identifier:meta; 7, block; 7, 8; 7, 23; 7, 37; 7, 45; 7, 55; 7, 65; 7, 71; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:total_score; ...
def ranker(self, X, meta): total_score = X.sum(axis=1).transpose() total_score = np.squeeze(np.asarray(total_score)) ranks = total_score.argsort() ranks = ranks[::-1] sorted_meta = [meta[r] for r in ranks] sorted_X = X[ranks] return (sorted_X, sorted_meta)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:create_pickled_data; 3, parameters; 3, 4; 3, 5; 4, identifier:idevice; 5, identifier:filename; 6, block; 6, 7; 6, 11; 6, 27; 6, 31; 6, 39; 6, 52; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:data; 10, dictionary; 11,...
def create_pickled_data(idevice, filename): data = {} for x in idevice.content: data[x] = idevice.content[x] location = filename pickle_file = open(location, 'wb') pickle.dump(data, pickle_file, protocol=pickle.HIGHEST_PROTOCOL) pickle_file.close()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:get_html_string; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 17; 7, 42; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:options; 11, call;...
def get_html_string(self, **kwargs): options = self._get_options(kwargs) if options["format"]: string = self._get_formatted_html_string(options) else: string = self._get_simple_html_string(options) return string
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_last_update_time; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 28; 6, expression_statement; 6, 7; 7, string:''' Gets the time at which each ledger was updated. Can be called at any time to get this infor...
def get_last_update_time(self): ''' Gets the time at which each ledger was updated. Can be called at any time to get this information. :return: an ordered dict of outdated ledgers sorted by last update time (from old to new) and then by ledger ID (in case of equal update time) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_listChunks; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 42; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:chunks; 9, list:[]; 10, for_statement; 10, 11; 10, 12; 10, 20; 11, identifier:fileName; ...
def _listChunks(self): chunks = [] for fileName in os.listdir(self.dataDir): index = ChunkedFileStore._fileNameToChunkIndex(fileName) if index is not None: chunks.append(index) return sorted(chunks)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:mostCommonElement; 3, parameters; 3, 4; 3, 12; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:elements; 6, type; 6, 7; 7, generic_type; 7, 8; 7, 9; 8, identifier:Iterable; 9, type_parameter; 9, 10; 10, type; 10, 11; 11, identifier:T; 12, typed_...
def mostCommonElement(elements: Iterable[T], to_hashable_f: Callable=None): class _Hashable(collections.abc.Hashable): def __init__(self, orig): self.orig = orig if isinstance(orig, collections.Hashable): self.hashable = orig elif to_hashable_f is not None...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:minute_index_to_session_labels; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:index; 6, block; 6, 7; 6, 18; 6, 39; 6, 58; 6, 65; 6, 156; 7, if_statement; 7, 8; 7, 12; 8, not_operator; 8, 9; 9, attribute; 9, 10; 9, 11; 10, identif...
def minute_index_to_session_labels(self, index): if not index.is_monotonic_increasing: raise ValueError( "Non-ordered index passed to minute_index_to_session_labels." ) prev_opens = ( self._opens.values.searchsorted(index.values, side='right') - 1 ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:aggregate_repeated_calls; 3, parameters; 3, 4; 3, 5; 4, identifier:frame; 5, identifier:options; 6, block; 6, 7; 6, 9; 6, 16; 6, 20; 6, 79; 6, 93; 6, 110; 7, expression_statement; 7, 8; 8, string:''' Converts a timeline into a time-aggregat...
def aggregate_repeated_calls(frame, options): ''' Converts a timeline into a time-aggregate summary. Adds together calls along the same call stack, so that repeated calls appear as the same frame. Removes time-linearity - frames are sorted according to total time spent. Useful for outputs that displ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:get_all_tags_names_as_list; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:admin; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:language; 10, string:"en"; 11, block; 11, 12; 11...
def get_all_tags_names_as_list(self, admin=False, language="en"): if admin: if self._all_tags_cache_list_admin != {} and language in self._all_tags_cache_list_admin: return self._all_tags_cache_list_admin[language] else: if self._all_tags_cache_list != {} and lang...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_users; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:course; 6, block; 6, 7; 6, 55; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:users; 10, call; 10, 11; 10, 12; 11, identifier:OrderedDict; 12, arg...
def get_users(self, course): users = OrderedDict(sorted(list(self.user_manager.get_users_info(self.user_manager.get_course_registered_users(course)).items()), key=lambda k: k[1][0] if k[1] is not None else "")) return users
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:radius_cmp; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:a; 5, identifier:b; 6, identifier:offsets; 7, block; 7, 8; 7, 10; 7, 24; 7, 31; 7, 39; 8, expression_statement; 8, 9; 9, string:'''return +1 or -1 for for sorting'''; 10, expression_sta...
def radius_cmp(a, b, offsets): '''return +1 or -1 for for sorting''' diff = radius(a, offsets) - radius(b, offsets) if diff > 0: return 1 if diff < 0: return -1 return 0
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:generate_enums_info; 3, parameters; 3, 4; 3, 5; 4, identifier:enums; 5, identifier:msgs; 6, block; 6, 7; 6, 230; 7, for_statement; 7, 8; 7, 9; 7, 10; 8, identifier:enum; 9, identifier:enums; 10, block; 10, 11; 10, 22; 10, 32; 10, 38; 10, 70; 10...
def generate_enums_info(enums, msgs): for enum in enums: enum.swift_name = camel_case_from_underscores(enum.name) enum.raw_value_type = get_enum_raw_type(enum, msgs) enum.formatted_description = "" if enum.description: enum.description = " ".join(enum.description.split())...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:compare_report_print; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:sorted_list; 5, identifier:scores; 6, identifier:best_name; 7, block; 7, 8; 7, 16; 7, 42; 7, 98; 7, 102; 7, 113; 7, 140; 7, 144; 7, 219; 7, 230; 8, expression_statement; 8, 9;...
def compare_report_print(sorted_list, scores, best_name): title_items = ["Rank", "Name", "Class-Score", "Overall-Score"] class_scores_len = map(lambda x: len( str(x["class"])), list(scores.values())) shifts = ["%-" + str(len(sorted_list) + 4) + "s", "%-"...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:replace_cells; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:key; 6, identifier:sorted_row_idxs; 7, block; 7, 8; 7, 15; 7, 19; 7, 23; 7, 35; 7, 106; 7, 121; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 14; 10, pa...
def replace_cells(self, key, sorted_row_idxs): row, col, tab = key new_keys = {} del_keys = [] selection = self.grid.actions.get_selection() for __row, __col, __tab in self.grid.code_array: if __tab == tab and \ (not selection or (__row, __col) in selec...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:OnSortAscending; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:event; 6, block; 6, 7; 6, 62; 7, try_statement; 7, 8; 7, 46; 8, block; 8, 9; 8, 39; 9, with_statement; 9, 10; 9, 21; 10, with_clause; 10, 11; 11, with_item; 11, 12; 1...
def OnSortAscending(self, event): try: with undo.group(_("Sort ascending")): self.grid.actions.sort_ascending(self.grid.actions.cursor) statustext = _(u"Sorting complete.") except Exception, err: statustext = _(u"Sorting failed: {}").format(err) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:get_font_list; 3, parameters; 4, block; 4, 5; 4, 13; 4, 29; 4, 35; 5, expression_statement; 5, 6; 6, assignment; 6, 7; 6, 8; 7, identifier:font_map; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:pangocairo; 11, identifier:cai...
def get_font_list(): font_map = pangocairo.cairo_font_map_get_default() font_list = [f.get_name() for f in font_map.list_families()] font_list.sort() return font_list
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:_sorted_keys; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:keys; 6, identifier:startkey; 7, default_parameter; 7, 8; 7, 9; 8, identifier:reverse; 9, False; 10, block; 10, 11; 10, 24; 10, 71; 10, 84; 10, 98; 10, 112;...
def _sorted_keys(self, keys, startkey, reverse=False): tuple_key = lambda t: t[::-1] if reverse: tuple_cmp = lambda t: t[::-1] > startkey[::-1] else: tuple_cmp = lambda t: t[::-1] < startkey[::-1] searchkeys = sorted(keys, key=tuple_key, reverse=reverse) s...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:stratify; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 28; 5, 36; 5, 72; 5, 88; 5, 108; 5, 127; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 12; 8, pattern_list; 8, 9; 8, 10; 8, 11; 9, identifier:Y; 10, identifier:D; 11...
def stratify(self): Y, D, X = self.raw_data['Y'], self.raw_data['D'], self.raw_data['X'] pscore = self.raw_data['pscore'] if isinstance(self.blocks, int): blocks = split_equal_bins(pscore, self.blocks) else: blocks = self.blocks[:] blocks[0] = 0 def subset(p_low, p_high): return (p_low < pscore) &...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 43; 2, function_name:list_current_orders; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 25; 3, 28; 3, 31; 3, 34; 3, 37; 3, 40; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:bet_ids; 7, None; 8, default_parameter; 8, 9; 8, 10...
def list_current_orders(self, bet_ids=None, market_ids=None, order_projection=None, customer_order_refs=None, customer_strategy_refs=None, date_range=time_range(), order_by=None, sort_dir=None, from_record=None, record_count=None, session=None, lightweight=None): ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:visit_Module; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:node; 6, block; 6, 7; 6, 13; 6, 19; 6, 50; 6, 92; 6, 103; 6, 111; 6, 117; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:newbody; 10, call; 10,...
def visit_Module(self, node): newbody = list() olddef = list() for stmt in node.body: if isinstance(stmt, ast.FunctionDef): olddef.append(stmt) else: newbody.append(stmt) try: newdef = topological_sort( s...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:qzordered; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:A; 5, identifier:B; 6, default_parameter; 6, 7; 6, 8; 7, identifier:crit; 8, float:1.0; 9, block; 9, 10; 9, 12; 9, 16; 9, 32; 9, 52; 9, 71; 10, expression_statement; 10, 11; 11, string:"...
def qzordered(A,B,crit=1.0): "Eigenvalues bigger than crit are sorted in the top-left." TOL = 1e-10 def select(alpha, beta): return alpha**2>crit*beta**2 [S,T,alpha,beta,U,V] = ordqz(A,B,output='real',sort=select) eigval = abs(numpy.diag(S)/numpy.diag(T)) return [S,T,U,V,eigval]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:ordqz; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:A; 5, identifier:B; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sort; 8, string:'lhp'; 9, default_parameter; 9, 10; 9, 11; 10, identifier:output; 11, string:'...
def ordqz(A, B, sort='lhp', output='real', overwrite_a=False, overwrite_b=False, check_finite=True): import warnings import numpy as np from numpy import asarray_chkfinite from scipy.linalg.misc import LinAlgError, _datacopied from scipy.linalg.lapack import get_lapack_funcs from scipy...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:inverse_cdf; 3, parameters; 3, 4; 3, 5; 4, identifier:su; 5, identifier:W; 6, block; 6, 7; 6, 11; 6, 17; 6, 25; 6, 35; 6, 65; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:j; 10, integer:0; 11, expression_statement; 1...
def inverse_cdf(su, W): j = 0 s = W[0] M = su.shape[0] A = np.empty(M, 'int') for n in range(M): while su[n] > s: j += 1 s += W[j] A[n] = j return A
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:sort_items; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:items; 6, default_parameter; 6, 7; 6, 8; 7, identifier:args; 8, False; 9, block; 9, 10; 9, 24; 9, 33; 9, 109; 9, 125; 9, 254; 9, 270; 10, if_statement; 10, 11; 10, 2...
def sort_items(self,items,args=False): if self.settings['sort'].lower() == 'src': return def alpha(i): return i.name def permission(i): if args: if i.intent == 'in': return 'b' if i.intent == 'inout': return 'c' if i.intent == 'out': return 'd' ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 23; 5, 38; 5, 53; 5, 68; 5, 83; 5, 98; 5, 113; 5, 128; 5, 143; 5, 158; 5, 173; 5, 188; 5, 203; 5, 218; 6, expression_statement; 6, 7; 7, string:''' Sorts components...
def sort(self): ''' Sorts components of the object. ''' if hasattr(self,'variables'): sort_items(self,self.variables) if hasattr(self,'modules'): sort_items(self,self.modules) if hasattr(self,'submodules'): sort_items(self,self.submodul...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_catalogue_chronologically; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 16; 5, 25; 5, 48; 6, expression_statement; 6, 7; 7, string:''' Sorts the catalogue into chronological order '''; 8, expression_sta...
def sort_catalogue_chronologically(self): ''' Sorts the catalogue into chronological order ''' dec_time = self.get_decimal_time() idx = np.argsort(dec_time) if np.all((idx[1:] - idx[:-1]) > 0.): return self.select_catalogue_events(idx)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:cmp_mat; 3, parameters; 3, 4; 3, 5; 4, identifier:a; 5, identifier:b; 6, block; 6, 7; 6, 11; 6, 46; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:c; 10, integer:0; 11, for_statement; 11, 12; 11, 15; 11, 24; 12, patter...
def cmp_mat(a, b): c = 0 for x, y in zip(a.flat, b.flat): c = cmp(abs(x), abs(y)) if c != 0: return c return c
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_dicoms; 3, parameters; 3, 4; 4, identifier:dicoms; 5, block; 5, 6; 5, 24; 5, 42; 5, 60; 5, 82; 5, 104; 5, 126; 5, 137; 5, 148; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:dicom_input_sorted_x; 9, call; 9, 10; 9,...
def sort_dicoms(dicoms): dicom_input_sorted_x = sorted(dicoms, key=lambda x: (x.ImagePositionPatient[0])) dicom_input_sorted_y = sorted(dicoms, key=lambda x: (x.ImagePositionPatient[1])) dicom_input_sorted_z = sorted(dicoms, key=lambda x: (x.ImagePositionPatient[2])) diff_x = abs(dicom_input_sorted_x[-1...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_get_sorted_mosaics; 3, parameters; 3, 4; 4, identifier:dicom_input; 5, block; 5, 6; 5, 21; 5, 54; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:sorted_mosaics; 9, call; 9, 10; 9, 11; 10, identifier:sorted; 11, argumen...
def _get_sorted_mosaics(dicom_input): sorted_mosaics = sorted(dicom_input, key=lambda x: x.AcquisitionNumber) for index in range(0, len(sorted_mosaics) - 1): if sorted_mosaics[index].AcquisitionNumber >= sorted_mosaics[index + 1].AcquisitionNumber: raise ConversionValidationError("INCONSISTE...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:relate_obs_ids_to_chosen_alts; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:obs_id_array; 5, identifier:alt_id_array; 6, identifier:choice_array; 7, block; 7, 8; 7, 12; 7, 63; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, id...
def relate_obs_ids_to_chosen_alts(obs_id_array, alt_id_array, choice_array): chosen_alts_to_obs_ids = {} for alt_id in np.sort(np.unique(alt_id_array)): selection_condition =\ np.where((alt_id_array == alt_id) & (choice_arra...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:create_estimation_obj; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:model_obj; 5, identifier:init_vals; 6, default_parameter; 6, 7; 6, 8; 7, identifier:mappings; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier...
def create_estimation_obj(model_obj, init_vals, mappings=None, ridge=None, constrained_pos=None, weights=None): mapping_matrices =\ model_obj.get_mappings_for_fit() if mappings i...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sequence; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 110; 6, expression_statement; 6, 7; 7, string:''' sort the points in the line with given option '''; 8, if_statement; 8, 9; 8, 20; 9, parenthesized_expr...
def sequence(self): ''' sort the points in the line with given option ''' if (len(self.Points[0]) == 2): if (self.Sort == 'X' or self.Sort == 'x'): self.Points.sort(key=lambda x: x[0]) self.order(self.Points) elif (self.Sort == 'Y' ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_get_pos; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:key; 6, block; 6, 7; 6, 24; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:p; 10, call; 10, 11; 10, 12; 11, identifier:bisect; 12, argument_list; 1...
def _get_pos(self, key): p = bisect(self.runtime._keys, self.hashi(key)) if p == len(self.runtime._keys): return 0 else: return p
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:lapmod; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 3, 14; 4, identifier:n; 5, identifier:cc; 6, identifier:ii; 7, identifier:kk; 8, default_parameter; 8, 9; 8, 10; 9, identifier:fast; 10, True; 11, default_parameter; 11, 12; 11, 13; 1...
def lapmod(n, cc, ii, kk, fast=True, return_cost=True, fp_version=FP_DYNAMIC): check_cost(n, cc, ii, kk) if fast is True: x, y = _lapmod(n, cc, ii, kk, fp_version=fp_version) else: cc = np.ascontiguousarray(cc, dtype=np.float64) ii = np.ascontiguousarray(ii, dtype=np.int32...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_items; 3, parameters; 3, 4; 4, identifier:items; 5, block; 5, 6; 5, 10; 5, 48; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:sorted_items; 9, dictionary; 10, for_statement; 10, 11; 10, 12; 10, 13; 11, identifier:i...
def sort_items(items): sorted_items = {} for item in items: category = lookup(item, 'itemCategory', 'categoryCode') if sorted_items.get(category) is None: sorted_items[category] = [] sorted_items[category].append(item) return sorted_items
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_user_permissions; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:user_id; 6, block; 6, 7; 6, 20; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:permissions; 10, call; 10, 11; 10, 16; 11, attribute; 11...
def get_user_permissions(self, user_id): permissions = self.user_service.getPermissions(id=user_id) return sorted(permissions, key=itemgetter('keyName'))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:transformChildrenToNative; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, for_statement; 6, 7; 6, 8; 6, 21; 7, identifier:childArray; 8, generator_expression; 8, 9; 8, 14; 9, subscript; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; ...
def transformChildrenToNative(self): for childArray in (self.contents[k] for k in self.sortChildKeys()): for child in childArray: child = child.transformToNative() child.transformChildrenToNative()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_candidate_pairs; 3, parameters; 3, 4; 3, 5; 4, identifier:pairs; 5, identifier:ice_controlling; 6, block; 6, 7; 6, 24; 7, function_definition; 7, 8; 7, 9; 7, 11; 8, function_name:pair_priority; 9, parameters; 9, 10; 10, identifier:pair; 11...
def sort_candidate_pairs(pairs, ice_controlling): def pair_priority(pair): return -candidate_pair_priority(pair.local_candidate, pair.remote_candidate, ice_controlling) pairs.sort(key=pair_priority)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:order_by_refs; 3, parameters; 3, 4; 4, identifier:envs; 5, block; 5, 6; 5, 23; 5, 35; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:topology; 9, dictionary_comprehension; 9, 10; 9, 20; 10, pair; 10, 11; 10, 14; 11, sub...
def order_by_refs(envs): topology = { env['name']: set(env['refs']) for env in envs } by_name = { env['name']: env for env in envs } return [ by_name[name] for name in toposort_flatten(topology) ]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:merged_packages; 3, parameters; 3, 4; 3, 5; 4, identifier:env_packages; 5, identifier:names; 6, block; 6, 7; 6, 30; 6, 34; 6, 40; 6, 78; 6, 111; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:combined_packages; 10, cal...
def merged_packages(env_packages, names): combined_packages = sorted(itertools.chain.from_iterable( env_packages[name].items() for name in names )) result = {} errors = set() for name, version in combined_packages: if name in result: if result[name] != version: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:recursive_refs; 3, parameters; 3, 4; 3, 5; 4, identifier:envs; 5, identifier:name; 6, block; 6, 7; 6, 24; 6, 30; 6, 63; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:refs_by_name; 10, dictionary_comprehension; 10, 11;...
def recursive_refs(envs, name): refs_by_name = { env['name']: set(env['refs']) for env in envs } refs = refs_by_name[name] if refs: indirect_refs = set(itertools.chain.from_iterable([ recursive_refs(envs, ref) for ref in refs ])) else: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:reference_cluster; 3, parameters; 3, 4; 3, 5; 4, identifier:envs; 5, identifier:name; 6, block; 6, 7; 6, 27; 6, 41; 6, 83; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:edges; 10, list_comprehension; 10, 11; 10, 19; 1...
def reference_cluster(envs, name): edges = [ set([env['name'], ref]) for env in envs for ref in env['refs'] ] prev, cluster = set(), set([name]) while prev != cluster: prev = set(cluster) to_visit = [] for edge in edges: if cluster & edge: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:search; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, identifier:text; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sort; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:offset; 11, integer:100; 12,...
def search(self, text, sort=None, offset=100, page=1, aquarius_url=None): assert page >= 1, f'Invalid page value {page}. Required page >= 1.' logger.info(f'Searching asset containing: {text}') return [DDO(dictionary=ddo_dict) for ddo_dict in self._get_aquarius(aquarius_url).text_...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:query; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, identifier:query; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sort; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:offset; 11, integer:100; 12,...
def query(self, query, sort=None, offset=100, page=1, aquarius_url=None): logger.info(f'Searching asset query: {query}') aquarius = self._get_aquarius(aquarius_url) return [DDO(dictionary=ddo_dict) for ddo_dict in aquarius.query_search(query, sort, offset, page)['results']]