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:filter_sorted_apps; 3, parameters; 3, 4; 3, 5; 4, identifier:admin_apps; 5, identifier:request; 6, block; 6, 7; 6, 11; 6, 53; 6, 57; 6, 67; 6, 75; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:sorted_apps; 10, list:[]...
def filter_sorted_apps(admin_apps, request): sorted_apps = [] for orig_app_spec in appsettings.DASHBOARD_SORTED_APPS: app_spec = orig_app_spec.copy() app_spec['models'] = _build_app_models( request, admin_apps, app_spec['models'], ensure_all_models=True ) if app_spec[...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:render_stats; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:stats; 5, identifier:sort; 6, identifier:format; 7, block; 7, 8; 7, 14; 7, 29; 7, 37; 7, 45; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:output; 11, cal...
def render_stats(stats, sort, format): output = StdoutWrapper() if hasattr(stats, "stream"): stats.stream = output.stream stats.sort_stats(*sort) getattr(stats, format)() return output.stream
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:render_queries; 3, parameters; 3, 4; 3, 5; 4, identifier:queries; 5, identifier:sort; 6, block; 6, 7; 6, 13; 6, 40; 6, 99; 6, 103; 6, 107; 6, 156; 6, 173; 6, 196; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:output; ...
def render_queries(queries, sort): output = StringIO() if sort == 'order': print >>output, " time query" for query in queries: print >>output, " %8s %s" % (query["time"], query["sql"]) return output if sort == 'time': def sorter(x, y): return cmp(x...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:process_request; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:request; 6, block; 6, 7; 6, 50; 6, 83; 7, function_definition; 7, 8; 7, 9; 7, 11; 8, function_name:unpickle; 9, parameters; 9, 10; 10, identifier:params; 11, block; 1...
def process_request(self, request): def unpickle(params): stats = unpickle_stats(b64decode(params.get('stats', ''))) queries = cPickle.loads(b64decode(params.get('queries', ''))) return stats, queries if request.method != 'GET' and \ not (request.META.get( ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:dedupe_and_sort; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:sequence; 5, default_parameter; 5, 6; 5, 7; 6, identifier:first; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:last; 10, None; 11, block; 11, 12; 11, 18; 11, 24; 11, 3...
def dedupe_and_sort(sequence, first=None, last=None): first = first or [] last = last or [] new_sequence = [i for i in first if i in sequence] for item in sequence: if item not in new_sequence and item not in last: new_sequence.append(item) new_sequence.extend([i for i in last if...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sortedSemver; 3, parameters; 3, 4; 3, 5; 4, identifier:versions; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort; 7, string:"asc"; 8, block; 8, 9; 9, if_statement; 9, 10; 9, 19; 9, 77; 10, boolean_operator:and; 10, 11; 10, 12; 11, identifi...
def sortedSemver(versions, sort="asc"): if versions and isinstance(versions, (list, tuple)): if PY2: return sorted(versions, cmp=semver.compare, reverse=True if sort.upper() == "DESC" else False) else: from functools import cmp_to_key return sorted(versions, key=c...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 1, 12; 2, function_name:unique; 3, parameters; 3, 4; 3, 5; 4, identifier:arr; 5, default_parameter; 5, 6; 5, 7; 6, identifier:tolerance; 7, float:1e-6; 8, type; 8, 9; 9, attribute; 9, 10; 9, 11; 10, identifier:np; 11, identifier:ndarray; 12, block; 12, 13; 12, ...
def unique(arr, tolerance=1e-6) -> np.ndarray: arr = sorted(arr.flatten()) unique = [] while len(arr) > 0: current = arr[0] lis = [xi for xi in arr if np.abs(current - xi) < tolerance] arr = [xi for xi in arr if not np.abs(lis[0] - xi) < tolerance] xi_lis_average = sum(lis) /...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_get_cache_key; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 19; 5, 25; 5, 31; 5, 58; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:keys; 9, call; 9, 10; 9, 11; 10, identifier:list; 11, argument_list; 11...
def _get_cache_key(self): keys = list(self.params.keys()) keys.sort() cache_key = str() for key in keys: if key != "api_sig" and key != "api_key" and key != "sk": cache_key += key + self.params[key] return hashlib.sha1(cache_key.encode("utf-8")).hexdig...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 25; 2, function_name:fast_float; 3, parameters; 3, 4; 3, 5; 3, 11; 3, 14; 3, 19; 3, 22; 4, identifier:x; 5, default_parameter; 5, 6; 5, 7; 6, identifier:key; 7, lambda; 7, 8; 7, 10; 8, lambda_parameters; 8, 9; 9, identifier:x; 10, identifier:x; 11, default_paramet...
def fast_float( x, key=lambda x: x, nan=None, _uni=unicodedata.numeric, _nan_inf=NAN_INF, _first_char=POTENTIAL_FIRST_CHAR, ): if x[0] in _first_char or x.lstrip()[:3] in _nan_inf: try: x = float(x) return nan if nan is not None and x != x else x excep...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:fast_int; 3, parameters; 3, 4; 3, 5; 3, 11; 3, 16; 4, identifier:x; 5, default_parameter; 5, 6; 5, 7; 6, identifier:key; 7, lambda; 7, 8; 7, 10; 8, lambda_parameters; 8, 9; 9, identifier:x; 10, identifier:x; 11, default_parameter; 11, 12; 11, ...
def fast_int( x, key=lambda x: x, _uni=unicodedata.digit, _first_char=POTENTIAL_FIRST_CHAR, ): if x[0] in _first_char: try: return long(x) except ValueError: try: return _uni(x, key(x)) if len(x) == 1 else key(x) except TypeError: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_and_print_entries; 3, parameters; 3, 4; 3, 5; 4, identifier:entries; 5, identifier:args; 6, block; 6, 7; 6, 19; 6, 33; 6, 84; 6, 98; 6, 270; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:is_float; 10, comparison_...
def sort_and_print_entries(entries, args): is_float = args.number_type in ("float", "real", "f", "r") signed = args.signed or args.number_type in ("real", "r") alg = ( natsort.ns.FLOAT * is_float | natsort.ns.SIGNED * signed | natsort.ns.NOEXP * (not args.exp) | natsort.ns.PA...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:natsort_key; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:val; 5, identifier:key; 6, identifier:string_func; 7, identifier:bytes_func; 8, identifier:num_func; 9, block; 9, 10; 9, 22; 10, if_statement; 10, 11; 10, 14; 11, compariso...
def natsort_key(val, key, string_func, bytes_func, num_func): if key is not None: val = key(val) try: return string_func(val) except (TypeError, AttributeError): if type(val) in (bytes,): return bytes_func(val) try: return tuple( natsor...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:parse_number_factory; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:alg; 5, identifier:sep; 6, identifier:pre_sep; 7, block; 7, 8; 7, 25; 7, 45; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:nan_replace; 11, condit...
def parse_number_factory(alg, sep, pre_sep): nan_replace = float("+inf") if alg & ns.NANLAST else float("-inf") def func(val, _nan_replace=nan_replace, _sep=sep): return _sep, _nan_replace if val != val else val if alg & ns.PATH and alg & ns.UNGROUPLETTERS and alg & ns.LOCALEALPHA: return la...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:natsort_keygen; 3, parameters; 3, 4; 3, 7; 4, default_parameter; 4, 5; 4, 6; 5, identifier:key; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:alg; 9, attribute; 9, 10; 9, 11; 10, identifier:ns; 11, identifier:DEFAULT; 12, block; 12,...
def natsort_keygen(key=None, alg=ns.DEFAULT): try: ns.DEFAULT | alg except TypeError: msg = "natsort_keygen: 'alg' argument must be from the enum 'ns'" raise ValueError(msg + ", got {}".format(py23_str(alg))) if alg & ns.LOCALEALPHA and natsort.compat.locale.dumb_sort(): alg ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:natsorted; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:seq; 5, default_parameter; 5, 6; 5, 7; 6, identifier:key; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:reverse; 10, False; 11, default_parameter; 11, 12; 11, 13; 12,...
def natsorted(seq, key=None, reverse=False, alg=ns.DEFAULT): key = natsort_keygen(key, alg) return sorted(seq, reverse=reverse, key=key)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:humansorted; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:seq; 5, default_parameter; 5, 6; 5, 7; 6, identifier:key; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:reverse; 10, False; 11, default_parameter; 11, 12; 11, 13; 1...
def humansorted(seq, key=None, reverse=False, alg=ns.DEFAULT): return natsorted(seq, key, reverse, alg | ns.LOCALE)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:realsorted; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:seq; 5, default_parameter; 5, 6; 5, 7; 6, identifier:key; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:reverse; 10, False; 11, default_parameter; 11, 12; 11, 13; 12...
def realsorted(seq, key=None, reverse=False, alg=ns.DEFAULT): return natsorted(seq, key, reverse, alg | ns.REAL)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:index_natsorted; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:seq; 5, default_parameter; 5, 6; 5, 7; 6, identifier:key; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:reverse; 10, False; 11, default_parameter; 11, 12; 11, 1...
def index_natsorted(seq, key=None, reverse=False, alg=ns.DEFAULT): if key is None: newkey = itemgetter(1) else: def newkey(x): return key(itemgetter(1)(x)) index_seq_pair = [[x, y] for x, y in enumerate(seq)] index_seq_pair.sort(reverse=reverse, key=natsort_keygen(newkey, alg...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:order_by_index; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:seq; 5, identifier:index; 6, default_parameter; 6, 7; 6, 8; 7, identifier:iter; 8, False; 9, block; 9, 10; 10, return_statement; 10, 11; 11, conditional_expression:if; 11, 12; 11, 1...
def order_by_index(seq, index, iter=False): return (seq[i] for i in index) if iter else [seq[i] for i in index]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:find_records; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:self; 5, identifier:collection_name; 6, default_parameter; 6, 7; 6, 8; 7, identifier:query; 8, dictionary; 9, default_parameter; 9, 10; 9, 11; 10, identifi...
def find_records(self, collection_name, query={}, sort_by=None, sort_direction=None, start=0, limit=None): cursor = self._get_collection(collection_name).find(query) if sort_by is not None: cursor = self._apply_sort(cursor, sort_by, sort_direction) cursor = curso...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_apply_sort; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:cursor; 5, identifier:sort_by; 6, identifier:sort_direction; 7, block; 7, 8; 7, 35; 8, if_statement; 8, 9; 8, 20; 8, 27; 9, boolean_operator:and; 9, 10; 9, 13; 10, comparison_operator:...
def _apply_sort(cursor, sort_by, sort_direction): if sort_direction is not None and sort_direction.lower() == "desc": sort = pymongo.DESCENDING else: sort = pymongo.ASCENDING return cursor.sort(sort_by, sort)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 26; 2, function_name:get_runs; 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:sort_by; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sort_direction; 10, None; 11, default_parame...
def get_runs(self, sort_by=None, sort_direction=None, start=0, limit=None, query={"type": "and", "filters": []}): all_run_ids = os.listdir(self.directory) def run_iterator(): blacklist = set(["_sources"]) for id in all_run_ids: if id in blacklist: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:get_runs; 3, parameters; 4, block; 4, 5; 4, 13; 4, 21; 4, 29; 4, 38; 4, 47; 4, 58; 4, 69; 4, 75; 4, 106; 4, 133; 4, 141; 4, 149; 5, expression_statement; 5, 6; 6, assignment; 6, 7; 6, 8; 7, identifier:data; 8, subscript; 8, 9; 8, 12; 9, attribu...
def get_runs(): data = current_app.config["data"] draw = parse_int_arg("draw", 1) start = parse_int_arg("start", 0) length = parse_int_arg("length", -1) length = length if length >= 0 else None order_column = request.args.get("order[0][column]") order_dir = request.args.get("order[0][dir]") ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:generate_querystring; 3, parameters; 3, 4; 4, identifier:params; 5, block; 5, 6; 5, 12; 5, 16; 5, 92; 6, if_statement; 6, 7; 6, 9; 7, not_operator; 7, 8; 8, identifier:params; 9, block; 9, 10; 10, return_statement; 10, 11; 11, None; 12, express...
def generate_querystring(params): if not params: return None parts = [] for param, value in sorted(params.items()): if not isinstance(value, dict): parts.append(urlencode({param: value})) else: for key, sub_value in sorted(value.items()): compo...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:filter_catalog; 3, parameters; 3, 4; 3, 5; 4, identifier:catalog; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 18; 7, 28; 7, 38; 7, 48; 7, 54; 7, 61; 7, 70; 7, 79; 7, 92; 7, 101; 7, 111; 8, expression_statement; 8...
def filter_catalog(catalog, **kwargs): bright_limit = kwargs.get('bright_limit', 1.00) max_bright = kwargs.get('max_bright', None) min_bright = kwargs.get('min_bright', 20) colname = kwargs.get('colname', 'vegamag') phot_column = catalog[colname] num_sources = len(phot_column) sort_indx = np...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sort_timeseries; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ascending; 7, True; 8, block; 8, 9; 8, 17; 8, 21; 8, 36; 8, 54; 8, 60; 9, if_statement; 9, 10; 9, 15; 10, boolean_operator:and; 10, ...
def sort_timeseries(self, ascending=True): if ascending and self._sorted: return sortorder = 1 if not ascending: sortorder = -1 self._predefinedSorted = False self._timeseriesData.sort(key=lambda i: sortorder * i[0]) self._sorted = ascending ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sorted_timeseries; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ascending; 7, True; 8, block; 8, 9; 8, 13; 8, 22; 8, 41; 8, 50; 8, 62; 8, 68; 9, expression_statement; 9, 10; 10, assignment; 10, ...
def sorted_timeseries(self, ascending=True): sortorder = 1 if not ascending: sortorder = -1 data = sorted(self._timeseriesData, key=lambda i: sortorder * i[0]) newTS = TimeSeries(self._normalized) for entry in data: newTS.add_entry(*entry) newTS._s...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_calculate_values_to_forecast; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:timeSeries; 6, block; 6, 7; 6, 15; 6, 28; 6, 41; 6, 57; 6, 70; 7, if_statement; 7, 8; 7, 13; 8, comparison_operator:is; 8, 9; 8, 12; 9, attribute; 9, 10...
def _calculate_values_to_forecast(self, timeSeries): if self._forecastUntil is None: return if not timeSeries.is_sorted(): raise ValueError("timeSeries has to be sorted.") if not timeSeries.is_normalized(): raise ValueError("timeSeries has to be normalized.") ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:get_bucket; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:bucket; 6, default_parameter; 6, 7; 6, 8; 7, identifier:marker; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:max_keys; 11, None; 12, def...
def get_bucket(self, bucket, marker=None, max_keys=None, prefix=None): args = [] if marker is not None: args.append(("marker", marker)) if max_keys is not None: args.append(("max-keys", "%d" % (max_keys,))) if prefix is not None: args.append(("prefix",...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:findunique; 3, parameters; 3, 4; 3, 5; 4, identifier:lst; 5, identifier:key; 6, block; 6, 7; 7, return_statement; 7, 8; 8, call; 8, 9; 8, 10; 9, identifier:sorted; 10, argument_list; 10, 11; 11, call; 11, 12; 11, 13; 12, identifier:set; 13, arg...
def findunique(lst, key): return sorted(set([item[key.lower()] for item in lst]))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:make_input_dataframe_by_entity; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:tax_benefit_system; 5, identifier:nb_persons; 6, identifier:nb_groups; 7, block; 7, 8; 7, 14; 7, 30; 7, 39; 7, 45; 7, 65; 7, 76; 7, 98; 7, 110; 7, 122; 7, 127; 7, 17...
def make_input_dataframe_by_entity(tax_benefit_system, nb_persons, nb_groups): input_dataframe_by_entity = dict() person_entity = [entity for entity in tax_benefit_system.entities if entity.is_person][0] person_id = np.arange(nb_persons) input_dataframe_by_entity = dict() input_dataframe_by_entity[p...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:multi_sort; 3, parameters; 3, 4; 3, 5; 4, identifier:remotes; 5, identifier:sort; 6, block; 6, 7; 6, 13; 6, 19; 6, 74; 6, 91; 6, 97; 6, 168; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:exploded_alpha; 10, call; 10, ...
def multi_sort(remotes, sort): exploded_alpha = list() exploded_semver = list() if 'alpha' in sort: alpha_max_len = max(len(r['name']) for r in remotes) for name in (r['name'] for r in remotes): exploded_alpha.append([ord(i) for i in name] + [0] * (alpha_max_len - len(name))) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_params; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:ctx; 6, block; 6, 7; 6, 20; 7, expression_statement; 7, 8; 8, call; 8, 9; 8, 14; 9, attribute; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, identi...
def get_params(self, ctx): self.params.sort(key=self.custom_sort) return super(ClickGroup, self).get_params(ctx)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:configure_switch_entries; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:switch_ip; 6, identifier:port_bindings; 7, block; 7, 8; 7, 13; 7, 18; 7, 22; 7, 26; 7, 34; 7, 55; 7, 68; 7, 74; 7, 80; 7, 84; 7, 88; 7, 92; 7, 294; 7, ...
def configure_switch_entries(self, switch_ip, port_bindings): prev_vlan = -1 prev_vni = -1 prev_port = None prev_native_vlan = 0 starttime = time.time() port_bindings.sort(key=lambda x: (x.port_id, x.vlan_id, x.vni)) self.driver.capture_and_print_timeshot( ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_sort_resources_per_hosting_device; 3, parameters; 3, 4; 4, identifier:resources; 5, block; 5, 6; 5, 10; 5, 71; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:hosting_devices; 9, dictionary; 10, for_statement; 10, 11; 1...
def _sort_resources_per_hosting_device(resources): hosting_devices = {} for key in resources.keys(): for r in resources.get(key) or []: if r.get('hosting_device') is None: continue hd_id = r['hosting_device']['id'] hosting_d...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:compute; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:self; 5, identifier:t; 6, default_parameter; 6, 7; 6, 8; 7, identifier:yerr; 8, float:1.123e-12; 9, default_parameter; 9, 10; 9, 11; 10, identifier:check_sorted...
def compute(self, t, yerr=1.123e-12, check_sorted=True, A=None, U=None, V=None): t = np.atleast_1d(t) if check_sorted and np.any(np.diff(t) < 0.0): raise ValueError("the input coordinates must be sorted") if check_sorted and len(t.shape) > 1: raise ValueEr...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:group_dict; 3, parameters; 3, 4; 3, 5; 4, identifier:items; 5, identifier:keyfunc; 6, block; 6, 7; 6, 16; 6, 36; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:result; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 1...
def group_dict(items, keyfunc): result = collections.defaultdict(list) for i in items: key = keyfunc(i) result[key].append(i) return result
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_split_dict; 3, parameters; 3, 4; 4, identifier:dic; 5, block; 5, 6; 5, 8; 5, 19; 6, expression_statement; 6, 7; 7, string:'''Split dict into sorted keys and values >>> _split_dict({'b': 2, 'a': 1}) (['a', 'b'], [1, 2]) '''; 8, expr...
def _split_dict(dic): '''Split dict into sorted keys and values >>> _split_dict({'b': 2, 'a': 1}) (['a', 'b'], [1, 2]) ''' keys = sorted(dic.keys()) return keys, [dic[k] for k in keys]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:monitor; 3, parameters; 3, 4; 4, identifier:args; 5, block; 5, 6; 5, 8; 5, 22; 5, 30; 5, 52; 5, 70; 5, 82; 5, 124; 6, expression_statement; 6, 7; 7, string:''' Retrieve status of jobs submitted from a given workspace, as a list of TSV l...
def monitor(args): ''' Retrieve status of jobs submitted from a given workspace, as a list of TSV lines sorted by descending order of job submission date''' r = fapi.list_submissions(args.project, args.workspace) fapi._check_response_code(r, 200) statuses = sorted(r.json(), key=lambda k: k['subm...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:tcsort; 3, parameters; 3, 4; 4, identifier:item; 5, block; 5, 6; 6, return_statement; 6, 7; 7, binary_operator:+; 7, 8; 7, 14; 8, call; 8, 9; 8, 10; 9, identifier:len; 10, argument_list; 10, 11; 11, subscript; 11, 12; 11, 13; 12, identifier:ite...
def tcsort(item): return len(item[1]) + sum(tcsort(kv) for kv in item[1].items())
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sortProperties; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:properties; 6, block; 6, 7; 6, 28; 7, for_statement; 7, 8; 7, 11; 7, 16; 8, pattern_list; 8, 9; 8, 10; 9, identifier:prop; 10, identifier:objects; 11, call; 11, 12; 11...
def sortProperties(self, properties): for prop, objects in properties.items(): objects.sort(key=self._globalSortKey) return sorted(properties, key=lambda p: self.predicate_rank[p])
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:getSubOrder; 3, parameters; 3, 4; 4, identifier:existing; 5, block; 5, 6; 5, 46; 5, 50; 5, 106; 5, 115; 5, 127; 5, 136; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:alpha; 9, subscript; 9, 10; 9, 45; 10, call; 10, 11;...
def getSubOrder(existing): alpha = list(zip(*sorted(((k, v['rec']['label']) for k, v in existing.items()), key=lambda a: a[1])))[0] depths = {} def getDepth(id_): if id_ in depths: return depths[id_] else: if id_ in existing: names_above = getDepth(exi...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:insert_sort; 3, parameters; 3, 4; 3, 5; 4, identifier:node; 5, identifier:target; 6, block; 6, 7; 6, 13; 6, 19; 6, 36; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:sort; 10, attribute; 10, 11; 10, 12; 11, identifier:...
def insert_sort(node, target): sort = target.sort lang = target.lang collator = Collator.createInstance(Locale(lang) if lang else Locale()) for child in target.tree: if collator.compare(sort(child) or '', sort(node) or '') > 0: child.addprevious(node) break else: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:do_sort_by; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:element; 6, identifier:decl; 7, identifier:pseudo; 8, block; 8, 9; 8, 40; 8, 64; 8, 76; 8, 84; 8, 90; 8, 100; 8, 106; 8, 112; 9, if_statement; 9, 10; 9, 15; 9,...
def do_sort_by(self, element, decl, pseudo): if ',' in decl.value: css, flags = split(decl.value, ',') else: css = decl.value flags = None sort = css_to_func(serialize(css), serialize(flags or ''), self.css_namespaces, self.state['la...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:keys; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 12; 5, 45; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:keys; 9, call; 9, 10; 9, 11; 10, identifier:list; 11, argument_list; 12, for_statement; 12, 13;...
def keys(self): keys = list() for n in range(len(self)): key = self.get_value() if not key in ['', None]: keys.append(key) return keys
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:set_item; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:key; 6, identifier:value; 7, block; 7, 8; 7, 19; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:keys; 11, call; 11, 12; 11, 13; 12, identif...
def set_item(self, key, value): keys = list(self.keys()) if key in keys: self.set_value(1,keys.index(key),str(value)) else: self.set_value(0,len(self), str(key)) self.set_value(1,len(self)-1, str(value))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:insert_ordered; 3, parameters; 3, 4; 3, 5; 4, identifier:value; 5, identifier:array; 6, block; 6, 7; 6, 11; 6, 35; 6, 43; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:index; 10, integer:0; 11, for_statement; 11, 12; ...
def insert_ordered(value, array): index = 0 for n in range(0,len(array)): if value >= array[n]: index = n+1 array.insert(index, value) return index
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:remove_dataset; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:dataset; 7, None; 8, dictionary_splat_pattern; 8, 9; 9, identifier:kwargs; 10, block; 10, 11; 10, 18; 10, 38; 10, 48; 10, 100;...
def remove_dataset(self, dataset=None, **kwargs): self._kwargs_checks(kwargs) if dataset is None and not len(kwargs.items()): raise ValueError("must provide some value to filter for datasets") kind = kwargs.get('kind', None) if kind is not None: if isinstance(kind...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:calls_sorted; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 73; 5, 79; 5, 95; 5, 103; 6, function_definition; 6, 7; 6, 8; 6, 10; 7, function_name:_z; 8, parameters; 8, 9; 9, identifier:call; 10, block; 10, 11; 11, if_statement; 11...
def calls_sorted(self): def _z(call): if isinstance(call.z.value, np.ndarray): return np.mean(call.z.value.flatten()) elif isinstance(call.z.value, float) or isinstance(call.z.value, int): return call.z.value else: return -np.in...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_filter_library_state; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:items; 6, block; 6, 7; 6, 13; 6, 19; 6, 32; 6, 40; 6, 46; 7, if_statement; 7, 8; 7, 10; 8, not_operator; 8, 9; 9, identifier:items; 10, block; 10, 11; 11, retur...
def _filter_library_state(self, items): if not items: return items top_most_item = items[0] top_most_state_v = top_most_item if isinstance(top_most_item, StateView) else top_most_item.parent state = top_most_state_v.model.state global_gui_config = gui_helper_state_mac...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_filter_hovered_items; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:items; 6, identifier:event; 7, block; 7, 8; 7, 17; 7, 23; 7, 29; 7, 43; 7, 63; 7, 76; 7, 222; 7, 258; 8, expression_statement; 8, 9; 9, assignment; 9, 10;...
def _filter_hovered_items(self, items, event): items = self._filter_library_state(items) if not items: return items top_most_item = items[0] second_top_most_item = items[1] if len(items) > 1 else None first_state_v = next(filter(lambda item: isinstance(item, (NameView...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:compare_variables; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:tree_model; 5, identifier:iter1; 6, identifier:iter2; 7, default_parameter; 7, 8; 7, 9; 8, identifier:user_data; 9, None; 10, block; 10, 11; 10, 22; 10, 33; 10, 41; 10, 49...
def compare_variables(tree_model, iter1, iter2, user_data=None): path1 = tree_model.get_path(iter1)[0] path2 = tree_model.get_path(iter2)[0] name1 = tree_model[path1][0] name2 = tree_model[path2][0] name1_as_bits = ' '.join(format(ord(x), 'b') for x in name1) name2_as_bit...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:load_hook_files; 3, parameters; 3, 4; 4, identifier:pathname; 5, block; 5, 6; 5, 8; 5, 54; 6, global_statement; 6, 7; 7, identifier:hooks; 8, if_statement; 8, 9; 8, 24; 8, 40; 9, boolean_operator:and; 9, 10; 9, 17; 10, comparison_operator:>; 10...
def load_hook_files(pathname): global hooks if sys.version_info[0] > 2 and sys.version_info[1] > 4: fsglob = sorted(glob.iglob(pathname, recursive=True)) else: fsglob = sorted(glob.iglob(pathname)) for path in fsglob: real_path = os.path.realpath(path) if os.path.dirname(...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:sort; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:imports; 5, default_parameter; 5, 6; 5, 7; 6, identifier:separate; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:import_before_from; 10, True; 11, dictionary_splat_pattern...
def sort(imports, separate=True, import_before_from=True, **classify_kwargs): if separate: def classify_func(obj): return classify_import( obj.import_statement.module, **classify_kwargs ) types = ImportType.__all__ else: def classify_func(obj): ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_recursive; 3, parameters; 3, 4; 4, identifier:data; 5, block; 5, 6; 5, 10; 5, 53; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:newdict; 9, dictionary; 10, for_statement; 10, 11; 10, 12; 10, 17; 11, identifier:i; ...
def sort_recursive(data): newdict = {} for i in data.items(): if type(i[1]) is dict: newdict[i[0]] = sort_recursive(i[1]) else: newdict[i[0]] = i[1] return OrderedDict(sorted(newdict.items(), key=lambda item: (compare_type(type(item[1])), item[0])))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:names_to_abbreviations; 3, parameters; 3, 4; 4, identifier:reporters; 5, block; 5, 6; 5, 10; 5, 70; 5, 92; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:names; 9, dictionary; 10, for_statement; 10, 11; 10, 14; 10, 19; ...
def names_to_abbreviations(reporters): names = {} for reporter_key, data_list in reporters.items(): for data in data_list: abbrevs = data['editions'].keys() sort_func = lambda x: str(data['editions'][x]['start']) + x abbrevs = sorted(abbrevs, key=sort_func) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:flatten; 3, parameters; 3, 4; 4, identifier:weights; 5, block; 5, 6; 5, 126; 6, if_statement; 6, 7; 6, 14; 6, 37; 6, 119; 7, call; 7, 8; 7, 9; 8, identifier:isinstance; 9, argument_list; 9, 10; 9, 11; 10, identifier:weights; 11, attribute; 11, ...
def flatten(weights): if isinstance(weights, pd.DataFrame): wts = weights.stack().reset_index() wts.columns = ["date", "contract", "generic", "weight"] elif isinstance(weights, dict): wts = [] for key in sorted(weights.keys()): wt = weights[key].stack().reset_index() ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:calc_trades; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:current_contracts; 5, identifier:desired_holdings; 6, identifier:trade_weights; 7, identifier:prices; 8, identifier:multipliers; 9, dictionary_splat_pattern; 9, 10; ...
def calc_trades(current_contracts, desired_holdings, trade_weights, prices, multipliers, **kwargs): if not isinstance(trade_weights, dict): trade_weights = {"": trade_weights} generics = [] for key in trade_weights: generics.extend(trade_weights[key].columns) if not set(d...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_multiplier; 3, parameters; 3, 4; 3, 5; 4, identifier:weights; 5, identifier:root_generic_multiplier; 6, block; 6, 7; 6, 29; 6, 33; 6, 37; 6, 93; 6, 103; 6, 111; 7, if_statement; 7, 8; 7, 21; 8, boolean_operator:and; 8, 9; 8, 15; 9, comparis...
def get_multiplier(weights, root_generic_multiplier): if len(root_generic_multiplier) > 1 and not isinstance(weights, dict): raise ValueError("For multiple generic instruments weights must be a " "dictionary") mults = [] intrs = [] for ast, multiplier in root_generic_mul...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:roller; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:timestamps; 5, identifier:contract_dates; 6, identifier:get_weights; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 17; 9, 25; 9, 30; 9, 34; 9, 38; 9, 44...
def roller(timestamps, contract_dates, get_weights, **kwargs): timestamps = sorted(timestamps) contract_dates = contract_dates.sort_values() _check_contract_dates(contract_dates) weights = [] validate_inputs = True ts = timestamps[0] weights.extend(get_weights(ts, contract_dates, ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:strictly_monotonic; 3, parameters; 3, 4; 4, identifier:bb; 5, block; 5, 6; 5, 8; 5, 21; 5, 27; 5, 42; 5, 53; 5, 65; 6, expression_statement; 6, 7; 7, string:''' bb is an index array which may have numerous double or triple occurrences o...
def strictly_monotonic(bb): ''' bb is an index array which may have numerous double or triple occurrences of indices, such as for example the decay_index_pointer. This method removes all entries <= -, then all dublicates and finally returns a sorted list of indices. ''' cc=bb[np.where(bb>=0)...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_sort_shared_logical_disks; 3, parameters; 3, 4; 4, identifier:logical_disks; 5, block; 5, 6; 5, 24; 5, 45; 5, 49; 5, 53; 5, 75; 5, 79; 5, 83; 5, 106; 5, 119; 5, 123; 5, 203; 5, 212; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, ...
def _sort_shared_logical_disks(logical_disks): is_shared = (lambda x: True if ('share_physical_disks' in x and x['share_physical_disks']) else False) num_of_disks = (lambda x: x['number_of_physical_disks'] if 'number_of_physical_disks' in x else ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:get_versions; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:cls; 5, identifier:bucket; 6, identifier:key; 7, default_parameter; 7, 8; 7, 9; 8, identifier:desc; 9, True; 10, block; 10, 11; 10, 28; 10, 47; 11, expression_statement; 11, 12...
def get_versions(cls, bucket, key, desc=True): filters = [ cls.bucket_id == as_bucket_id(bucket), cls.key == key, ] order = cls.created.desc() if desc else cls.created.asc() return cls.query.filter(*filters).order_by(cls.key, order)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:sort_by; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:ids; 7, block; 7, 8; 7, 25; 7, 58; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:files; 11, dictionary_comprehension...
def sort_by(self, *ids): files = {str(f_.file_id): f_.key for f_ in self} self.filesmap = OrderedDict([ (files.get(id_, id_), self[files.get(id_, id_)].dumps()) for id_ in ids ]) self.flush()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sorted_files_from_bucket; 3, parameters; 3, 4; 3, 5; 4, identifier:bucket; 5, default_parameter; 5, 6; 5, 7; 6, identifier:keys; 7, None; 8, block; 8, 9; 8, 15; 8, 22; 8, 36; 8, 49; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12...
def sorted_files_from_bucket(bucket, keys=None): keys = keys or [] total = len(keys) sortby = dict(zip(keys, range(total))) values = ObjectVersion.get_by_bucket(bucket).all() return sorted(values, key=lambda x: sortby.get(x.key, total))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_data; 3, parameters; 3, 4; 3, 5; 4, identifier:x; 5, identifier:y; 6, block; 6, 7; 6, 18; 6, 28; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:xy; 10, call; 10, 11; 10, 12; 11, identifier:sorted; 12, argument_lis...
def sort_data(x, y): xy = sorted(zip(x, y)) x, y = zip(*xy) return x, y
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:unsort_vector; 3, parameters; 3, 4; 3, 5; 4, identifier:data; 5, identifier:indices_of_increasing; 6, block; 6, 7; 7, return_statement; 7, 8; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:numpy; 11, identifier:array; 12, argu...
def unsort_vector(data, indices_of_increasing): return numpy.array([data[indices_of_increasing.index(i)] for i in range(len(data))])
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_compute_sorted_indices; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 55; 5, 63; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:sorted_indices; 9, list:[]; 10, for_statement; 10, 11; 10, 12; 10, 20...
def _compute_sorted_indices(self): sorted_indices = [] for to_sort in [self.y] + self.x: data_w_indices = [(val, i) for (i, val) in enumerate(to_sort)] data_w_indices.sort() sorted_indices.append([i for val, i in data_w_indices]) self._yi_sorted = sorted_indic...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:specify_data_set; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:x_input; 6, identifier:y_input; 7, default_parameter; 7, 8; 7, 9; 8, identifier:sort_data; 9, False; 10, block; 10, 11; 10, 88; 10, 94; 11, if_statement...
def specify_data_set(self, x_input, y_input, sort_data=False): if sort_data: xy = sorted(zip(x_input, y_input)) x, y = zip(*xy) x_input_list = list(x_input) self._original_index_of_xvalue = [x_input_list.index(xi) for xi in x] if len(set(self._original...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:_aggregate; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:data; 5, default_parameter; 5, 6; 5, 7; 6, identifier:norm; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sort_by; 10, string:'value'; 11, default_parameter; 11, 12;...
def _aggregate(data, norm=True, sort_by='value', keys=None): ''' Counts the number of occurances of each item in 'data'. Inputs data: a list of values. norm: normalize the resulting counts (as percent) sort_by: how to sort the retured data. Options are 'value' and 'count'. Output a non-r...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:list_files; 3, parameters; 3, 4; 3, 5; 4, identifier:d; 5, default_parameter; 5, 6; 5, 7; 6, identifier:extension; 7, None; 8, block; 8, 9; 8, 11; 8, 53; 8, 125; 9, expression_statement; 9, 10; 10, string:''' Lists files in a given director...
def list_files(d, extension=None): ''' Lists files in a given directory. Args: d (str): Path to a directory. extension (str): If supplied, only files that contain the specificied extension will be returned. Default is ``False``, which returns all files in ``d``. R...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:get_collections; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:db; 5, default_parameter; 5, 6; 5, 7; 6, identifier:collection; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:prefix; 10, None; 11, default_parameter; 11, 12; 1...
def get_collections(db, collection=None, prefix=None, suffix=None): ''' Returns a sorted list of collection names found in ``db``. Arguments: db (Database): A pymongo Database object. Can be obtained with ``get_db``. collection (str): Name of a collection. If the collection is ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:leaf_nodes; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 23; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:deps; 9, set_comprehension; 9, 10; 9, 11; 9, 20; 10, identifier:item; 11, for_in_clause; 11, 12;...
def leaf_nodes(self): deps = {item for sublist in self.edges.values() for item in sublist} return self.nodes - deps
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, while_statement; 6, 7; 6, 10; 7, attribute; 7, 8; 7, 9; 8, identifier:self; 9, identifier:nodes; 10, block; 10, 11; 10, 15; 10, 37; 11, expression_statement; 11, 12; 12, assignme...
def sort(self): while self.nodes: iterated = False for node in self.leaf_nodes(): iterated = True self.prune_node(node) yield node if not iterated: raise CyclicGraphError("Sorting has found a cyclic graph.")
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:cycles; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 54; 5, 75; 5, 81; 5, 119; 6, function_definition; 6, 7; 6, 8; 6, 11; 7, function_name:walk_node; 8, parameters; 8, 9; 8, 10; 9, identifier:node; 10, identifier:seen; 11, block;...
def cycles(self): def walk_node(node, seen): if node in seen: yield (node,) return seen.add(node) for edge in self.edges[node]: for cycle in walk_node(edge, set(seen)): yield (node,) + cycle cycles = ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_prepare_imports; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:dicts; 6, block; 6, 7; 6, 13; 6, 17; 6, 33; 6, 70; 6, 83; 6, 146; 6, 152; 6, 158; 6, 162; 6, 211; 6, 237; 6, 254; 7, expression_statement; 7, 8; 8, assignment; 8, 9;...
def _prepare_imports(self, dicts): pseudo_ids = set() pseudo_matches = {} prepared = dict(super(OrganizationImporter, self)._prepare_imports(dicts)) for _, data in prepared.items(): parent_id = data.get('parent_id', None) or '' if parent_id.startswith('~'): ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:initial; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 8; 4, identifier:self; 5, identifier:request; 6, list_splat_pattern; 6, 7; 7, identifier:args; 8, dictionary_splat_pattern; 8, 9; 9, identifier:kwargs; 10, block; 10, 11; 10, 26; 10, 47; 10, 69; 11,...
def initial(self, request, *args, **kwargs): super(FlatMultipleModelMixin, self).initial(request, *args, **kwargs) assert not (self.sorting_field and self.sorting_fields), \ '{} should either define ``sorting_field`` or ``sorting_fields`` property, not both.' \ .format(self.__cla...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:prepare_sorting_fields; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 47; 6, if_statement; 6, 7; 6, 16; 7, comparison_operator:in; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:sorting_parameter_name; ...
def prepare_sorting_fields(self): if self.sorting_parameter_name in self.request.query_params: self._sorting_fields = [ _.strip() for _ in self.request.query_params.get(self.sorting_parameter_name).split(',') ] if self._sorting_fields: self._sorting_fi...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:JSONList; 3, parameters; 3, 4; 3, 6; 4, list_splat_pattern; 4, 5; 5, identifier:args; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 13; 8, 31; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, ide...
def JSONList(*args, **kwargs): type_ = JSON try: if kwargs.pop("unique_sorted"): type_ = JSONUniqueListType except KeyError: pass return MutationList.as_mutable(type_(*args, **kwargs))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:setup_coords; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 4, default_parameter; 4, 5; 4, 6; 5, identifier:arr_names; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:sort; 9, list:[]; 10, default_parameter; 10, 11; 10, 12; 11, identifier:...
def setup_coords(arr_names=None, sort=[], dims={}, **kwargs): try: return OrderedDict(arr_names) except (ValueError, TypeError): pass if arr_names is None: arr_names = repeat('arr{0}') elif isstring(arr_names): arr_names = repeat(arr_names) dims = OrderedDict(dims) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_tdata; 3, parameters; 3, 4; 3, 5; 4, identifier:t_format; 5, identifier:files; 6, block; 6, 7; 6, 33; 6, 36; 6, 41; 6, 45; 6, 65; 6, 74; 6, 87; 6, 138; 6, 147; 6, 158; 6, 169; 7, function_definition; 7, 8; 7, 9; 7, 11; 8, function_name:medi...
def get_tdata(t_format, files): def median(arr): return arr.min() + (arr.max() - arr.min())/2 import re from pandas import Index t_pattern = t_format for fmt, patt in t_patterns.items(): t_pattern = t_pattern.replace(fmt, patt) t_pattern = re.compile(t_pattern) time = list(ra...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_set_and_filter; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 16; 5, 38; 5, 217; 5, 227; 5, 239; 5, 245; 5, 253; 5, 261; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:fmtos; 9, list:[]; 10, expres...
def _set_and_filter(self): fmtos = [] seen = set() for key in self._force: self._registered_updates.setdefault(key, getattr(self, key).value) for key, value in chain( six.iteritems(self._registered_updates), six.iteritems( {...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_sorted_by_priority; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:fmtos; 6, default_parameter; 6, 7; 6, 8; 7, identifier:changed; 8, None; 9, block; 9, 10; 9, 35; 9, 112; 9, 129; 9, 139; 9, 150; 9, 160; 10, function_defini...
def _sorted_by_priority(self, fmtos, changed=None): def pop_fmto(key): idx = fmtos_keys.index(key) del fmtos_keys[idx] return fmtos.pop(idx) def get_children(fmto, parents_keys): all_fmtos = fmtos_keys + parents_keys for key in fmto.children + ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:sort_kwargs; 3, parameters; 3, 4; 3, 5; 4, identifier:kwargs; 5, list_splat_pattern; 5, 6; 6, identifier:param_lists; 7, block; 7, 8; 8, return_statement; 8, 9; 9, call; 9, 10; 9, 11; 10, identifier:chain; 11, argument_list; 11, 12; 11, 37; 12,...
def sort_kwargs(kwargs, *param_lists): return chain( ({key: kwargs.pop(key) for key in params.intersection(kwargs)} for params in map(set, param_lists)), [kwargs])
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:iterkeys; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 12; 5, 18; 5, 24; 5, 83; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:patterns; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, identifier:pat...
def iterkeys(self): patterns = self.patterns replace = self.replace seen = set() for key in six.iterkeys(self.base): for pattern in patterns: m = pattern.match(key) if m: ret = m.group('key') if replace else m.group() ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:keys; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 18; 5, 24; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:k; 9, call; 9, 10; 9, 11; 10, identifier:list; 11, argument_list; 11, 12; 12, call; 12, 13; 12,...
def keys(self): k = list(dict.keys(self)) k.sort() return k
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:get_reports_page; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:is_enclave; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:enclave_ids; 10, None; 11,...
def get_reports_page(self, is_enclave=None, enclave_ids=None, tag=None, excluded_tags=None, from_time=None, to_time=None): distribution_type = None if is_enclave: distribution_type = DistributionType.ENCLAVE elif not is_enclave: distribution_type ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 1, 11; 2, function_name:hashify_targets; 3, parameters; 3, 4; 3, 8; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:targets; 6, type; 6, 7; 7, identifier:list; 8, identifier:build_context; 9, type; 9, 10; 10, identifier:list; 11, block; 11, 12; 12, return_stateme...
def hashify_targets(targets: list, build_context) -> list: return sorted(build_context.targets[target_name].hash(build_context) for target_name in listify(targets))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:stable_reverse_topological_sort; 3, parameters; 3, 4; 4, identifier:graph; 5, block; 5, 6; 5, 21; 5, 27; 5, 33; 6, if_statement; 6, 7; 6, 13; 7, not_operator; 7, 8; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:graph; 11, ide...
def stable_reverse_topological_sort(graph): if not graph.is_directed(): raise networkx.NetworkXError( 'Topological sort not defined on undirected graphs.') seen = set() explored = set() for v in sorted(graph.nodes()): if v in explored: continue fringe = [v...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:walk_target_deps_topological_order; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:target; 7, type; 7, 8; 8, identifier:Target; 9, block; 9, 10; 9, 22; 10, expression_statement; 10, 11; 11, assignme...
def walk_target_deps_topological_order(self, target: Target): all_deps = get_descendants(self.target_graph, target.name) for dep_name in topological_sort(self.target_graph): if dep_name in all_deps: yield self.targets[dep_name]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:_print_message; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:prefix; 6, identifier:message; 7, default_parameter; 7, 8; 7, 9; 8, identifier:verbose; 9, True; 10, block; 10, 11; 10, 13; 10, 22; 10, 273; 11, expressio...
def _print_message(self, prefix, message, verbose=True): 'Prints a message and takes care of all sorts of nasty code' output = ['\n', prefix, message['message']] if verbose: verbose_output = [] if message['description']: verbose_output.append( ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:finish; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:items; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sort_methods; 10, None; 11, default_param...
def finish(self, items=None, sort_methods=None, succeeded=True, update_listing=False, cache_to_disc=True, view_mode=None): '''Adds the provided items to the XBMC interface. :param items: an iterable of items where each item is either a dictionary with keys/values suitable for ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:followingPrefix; 3, parameters; 3, 4; 4, identifier:prefix; 5, block; 5, 6; 5, 14; 5, 23; 5, 41; 5, 49; 5, 64; 5, 74; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:prefixBytes; 9, call; 9, 10; 9, 11; 10, identifier:arr...
def followingPrefix(prefix): prefixBytes = array('B', prefix) changeIndex = len(prefixBytes) - 1 while (changeIndex >= 0 and prefixBytes[changeIndex] == 0xff ): changeIndex = changeIndex - 1; if(changeIndex < 0): return None newBytes = array('B', prefix[0:...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sorted_maybe_numeric; 3, parameters; 3, 4; 4, identifier:x; 5, block; 5, 6; 5, 19; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:all_numeric; 9, call; 9, 10; 9, 11; 10, identifier:all; 11, argument_list; 11, 12; 12, ca...
def sorted_maybe_numeric(x): all_numeric = all(map(str.isdigit, x)) if all_numeric: return sorted(x, key=int) else: return sorted(x)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_by; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:sf; 6, block; 6, 7; 6, 20; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:params; 10, call; 10, 11; 10, 12; 11, identifier:join_params; 12, argument...
def sort_by(self, sf): params = join_params(self.parameters, {"sf": sf}) return self.__class__(**params)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_contributor_sort_value; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:obj; 6, block; 6, 7; 6, 13; 6, 38; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:user; 10, attribute; 10, 11; 10, 12; 11, identi...
def get_contributor_sort_value(self, obj): user = obj.contributor if user.first_name or user.last_name: contributor = user.get_full_name() else: contributor = user.username return contributor.strip().lower()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_gen_cache_key_for_slice; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:url_dict; 5, identifier:start_int; 6, identifier:total_int; 7, identifier:authn_subj_list; 8, block; 8, 9; 8, 18; 8, 28; 8, 38; 8, 61; 8, 73; 9, expression_statement...
def _gen_cache_key_for_slice(url_dict, start_int, total_int, authn_subj_list): key_url_dict = copy.deepcopy(url_dict) key_url_dict['query'].pop('start', None) key_url_dict['query'].pop('count', None) key_json = d1_common.util.serialize_to_normalized_compact_json( { 'url_dict': key_ur...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:normalize; 3, parameters; 3, 4; 4, identifier:rp_pyxb; 5, block; 5, 6; 5, 25; 5, 47; 5, 53; 6, function_definition; 6, 7; 6, 8; 6, 11; 7, function_name:sort; 8, parameters; 8, 9; 8, 10; 9, identifier:r; 10, identifier:a; 11, block; 11, 12; 12, ...
def normalize(rp_pyxb): def sort(r, a): d1_common.xml.sort_value_list_pyxb(_get_attr_or_list(r, a)) rp_pyxb.preferredMemberNode = set(_get_attr_or_list(rp_pyxb, 'pref')) - set( _get_attr_or_list(rp_pyxb, 'block') ) sort(rp_pyxb, 'block') sort(rp_pyxb, 'pref')
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:normalize; 3, parameters; 3, 4; 4, identifier:body_part_tup; 5, block; 5, 6; 6, return_statement; 6, 7; 7, call; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, string:'\n\n'; 10, identifier:join; 11, argument_list; 11, 12; 12, list_comprehension; 1...
def normalize(body_part_tup,): return '\n\n'.join( [ '{}\n\n{}'.format( str(p.headers[b'Content-Disposition'], p.encoding), p.text ) for p in sorted( body_part_tup, key=lambda p: p.headers[b'Content-Disposition'] ) ] ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:save_json; 3, parameters; 3, 4; 3, 5; 4, identifier:py_obj; 5, identifier:json_path; 6, block; 6, 7; 7, with_statement; 7, 8; 7, 21; 8, with_clause; 8, 9; 9, with_item; 9, 10; 10, as_pattern; 10, 11; 10, 19; 11, call; 11, 12; 11, 13; 12, identi...
def save_json(py_obj, json_path): with open(json_path, 'w', encoding='utf-8') as f: f.write(serialize_to_normalized_pretty_json(py_obj))