sequence
stringlengths
492
15.9k
code
stringlengths
75
8.58k
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:sort; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:cmp; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:key; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifi...
def sort(self, cmp=None, key=None, reverse=False): if not key and self._keys: key = self.KeyValue super(CliTable, self).sort(cmp=cmp, key=key, reverse=reverse)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:sort; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:cmp; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:key; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifi...
def sort(self, cmp=None, key=None, reverse=False): def _DefaultKey(value): result = [] for key in self.header: try: result.append(float(value[key])) except ValueError: result.append(value[key]) return res...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:find_order; 3, parameters; 3, 4; 4, identifier:graph; 5, block; 5, 6; 5, 8; 6, expression_statement; 6, 7; 7, string:''' Do a topological sort on the dependency graph dict. '''; 8, while_statement; 8, 9; 8, 10; 9, identifier:graph; 10, ...
def find_order(graph): ''' Do a topological sort on the dependency graph dict. ''' while graph: leftmost = [l for l, s in graph.items() if not s] if not leftmost: raise ValueError('Dependency cycle detected! %s' % graph) leftmost.sort() for result in leftmost:...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:do_sort; 3, parameters; 3, 4; 3, 5; 4, identifier:value; 5, default_parameter; 5, 6; 5, 7; 6, identifier:case_sensitive; 7, False; 8, block; 8, 9; 8, 41; 9, if_statement; 9, 10; 9, 12; 9, 35; 10, not_operator; 10, 11; 11, identifier:case_sensit...
def do_sort(value, case_sensitive=False): if not case_sensitive: def sort_func(item): if isinstance(item, basestring): item = item.lower() return item else: sort_func = None return sorted(seq, key=sort_func)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:dedupe; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:contains_dupes; 5, default_parameter; 5, 6; 5, 7; 6, identifier:threshold; 7, integer:70; 8, default_parameter; 8, 9; 8, 10; 9, identifier:scorer; 10, attribute; 10, 11; 10, 12; 11, identi...
def dedupe(contains_dupes, threshold=70, scorer=fuzz.token_set_ratio): extractor = [] for item in contains_dupes: matches = extract(item, contains_dupes, limit=None, scorer=scorer) filtered = [x for x in matches if x[1] > threshold] if len(filtered) == 1: extractor.append(fil...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_process_and_sort; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:s; 5, identifier:force_ascii; 6, default_parameter; 6, 7; 6, 8; 7, identifier:full_process; 8, True; 9, block; 9, 10; 9, 25; 9, 33; 9, 45; 10, expression_statement; 10, 11; 11, a...
def _process_and_sort(s, force_ascii, full_process=True): ts = utils.full_process(s, force_ascii=force_ascii) if full_process else s tokens = ts.split() sorted_string = u" ".join(sorted(tokens)) return sorted_string.strip()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:token_sort_ratio; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:s1; 5, identifier:s2; 6, default_parameter; 6, 7; 6, 8; 7, identifier:force_ascii; 8, True; 9, default_parameter; 9, 10; 9, 11; 10, identifier:full_process; 11, True; 12, b...
def token_sort_ratio(s1, s2, force_ascii=True, full_process=True): return _token_sort(s1, s2, partial=False, force_ascii=force_ascii, full_process=full_process)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:partial_token_sort_ratio; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:s1; 5, identifier:s2; 6, default_parameter; 6, 7; 6, 8; 7, identifier:force_ascii; 8, True; 9, default_parameter; 9, 10; 9, 11; 10, identifier:full_process; 11, Tru...
def partial_token_sort_ratio(s1, s2, force_ascii=True, full_process=True): return _token_sort(s1, s2, partial=True, force_ascii=force_ascii, full_process=full_process)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:WRatio; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:s1; 5, identifier:s2; 6, default_parameter; 6, 7; 6, 8; 7, identifier:force_ascii; 8, True; 9, default_parameter; 9, 10; 9, 11; 10, identifier:full_process; 11, True; 12, block; 12, ...
def WRatio(s1, s2, force_ascii=True, full_process=True): if full_process: p1 = utils.full_process(s1, force_ascii=force_ascii) p2 = utils.full_process(s2, force_ascii=force_ascii) else: p1 = s1 p2 = s2 if not utils.validate_string(p1): return 0 if not utils.valida...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sort_depth; 3, parameters; 3, 4; 3, 5; 4, identifier:vals; 5, default_parameter; 5, 6; 5, 7; 6, identifier:reverse; 7, False; 8, block; 8, 9; 8, 28; 8, 44; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:lst; 12, ...
def sort_depth(vals, reverse=False): lst = [[float(price), quantity] for price, quantity in vals.items()] lst = sorted(lst, key=itemgetter(0), reverse=reverse) return lst
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:_get_fields; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:attrs; 5, identifier:field_class; 6, default_parameter; 6, 7; 6, 8; 7, identifier:pop; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:ordered; 11, False; 12, block...
def _get_fields(attrs, field_class, pop=False, ordered=False): fields = [ (field_name, field_value) for field_name, field_value in iteritems(attrs) if is_instance_or_subclass(field_value, field_class) ] if pop: for field_name, _ in fields: del attrs[field_name] ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 66; 2, function_name:extract_features; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 28; 3, 33; 3, 38; 3, 43; 3, 48; 3, 53; 3, 58; 3, 63; 4, identifier:timeseries_container; 5, default_parameter; 5, 6; 5, 7; 6, identifier:default_fc_parame...
def extract_features(timeseries_container, default_fc_parameters=None, kind_to_fc_parameters=None, column_id=None, column_sort=None, column_kind=None, column_value=None, chunksize=defaults.CHUNKSIZE, n_jobs=defaults.N_PROCESSES, show_wa...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:convert_to_output_format; 3, parameters; 3, 4; 4, identifier:param; 5, block; 5, 6; 5, 34; 6, function_definition; 6, 7; 6, 8; 6, 10; 7, function_name:add_parenthesis_if_string_value; 8, parameters; 8, 9; 9, identifier:x; 10, block; 10, 11; 11,...
def convert_to_output_format(param): def add_parenthesis_if_string_value(x): if isinstance(x, string_types): return '"' + str(x) + '"' else: return str(x) return "__".join(str(key) + "_" + add_parenthesis_if_string_value(param[key]) for key in sorted(param.keys()))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:end_profiling; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:profiler; 5, identifier:filename; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sorting; 8, None; 9, block; 9, 10; 9, 16; 9, 24; 9, 41; 9, 47; 10, expression_statement; 10, 11; 11,...
def end_profiling(profiler, filename, sorting=None): profiler.disable() s = six.StringIO() ps = pstats.Stats(profiler, stream=s).sort_stats(sorting) ps.print_stats() with open(filename, "w+") as f: _logger.info("[calculate_ts_features] Finished profiling of time series feature extraction") ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 95; 2, function_name:extract_relevant_features; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 3, 27; 3, 32; 3, 37; 3, 42; 3, 47; 3, 52; 3, 57; 3, 62; 3, 67; 3, 72; 3, 77; 3, 82; 3, 87; 3, 92; 4, identifier:timeseries_container; 5, ident...
def extract_relevant_features(timeseries_container, y, X=None, default_fc_parameters=None, kind_to_fc_parameters=None, column_id=None, column_sort=None, column_kind=None, column_value=None, show_warni...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:user_agents; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, return_statement; 6, 7; 7, parenthesized_expression; 7, 8; 8, call; 8, 9; 8, 58; 9, attribute; 9, 10; 9, 57; 10, call; 10, 11; 10, 44; 11, attribute; 11, 12; 11, 43; 12, c...
def user_agents(self): return (self.get_query() .select( PageView.headers['User-Agent'], fn.Count(PageView.id)) .group_by(PageView.headers['User-Agent']) .order_by(fn.Count(PageView.id).desc()) .tuples())
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:languages; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 31; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:language; 9, subscript; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:PageVi...
def languages(self): language = PageView.headers['Accept-Language'] first_language = fn.SubStr( language, 1, fn.StrPos(language, ';')) return (self.get_query() .select(first_language, fn.Count(PageView.id)) .group_by(first_langu...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:error_router; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:original_handler; 6, identifier:e; 7, block; 7, 8; 7, 28; 8, if_statement; 8, 9; 8, 14; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; ...
def error_router(self, original_handler, e): if self._has_fr_route(): try: return self.handle_error(e) except Exception: pass return original_handler(e)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:smooth_knn_dist; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:distances; 5, identifier:k; 6, default_parameter; 6, 7; 6, 8; 7, identifier:n_iter; 8, integer:64; 9, default_parameter; 9, 10; 9, 11; 10, identifier:local_connectivi...
def smooth_knn_dist(distances, k, n_iter=64, local_connectivity=1.0, bandwidth=1.0): target = np.log2(k) * bandwidth rho = np.zeros(distances.shape[0]) result = np.zeros(distances.shape[0]) for i in range(distances.shape[0]): lo = 0.0 hi = NPY_INFINITY mid = 1.0 ith_dista...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_visible_units; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, for_statement; 6, 7; 6, 8; 6, 43; 7, identifier:u; 8, call; 8, 9; 8, 10; 9, identifier:sorted; 10, argument_list; 10, 11; 10, 20; 11, attribute; 11, 12; 11, 19; 12, att...
def _visible_units(self): for u in sorted(self._obs.observation.raw_data.units, key=lambda u: (u.pos.z, u.owner != 16, -u.radius, u.tag)): yield u, point.Point.build(u.pos)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:interp; 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:coords; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:method; 10, string:'linear'; 11, default_parame...
def interp(self, coords=None, method='linear', assume_sorted=False, kwargs={}, **coords_kwargs): if self.dtype.kind not in 'uifc': raise TypeError('interp only works for a numeric type array. ' 'Given {}.'.format(self.dtype)) ds = self._to_temp_data...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:interp_like; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:other; 6, default_parameter; 6, 7; 6, 8; 7, identifier:method; 8, string:'linear'; 9, default_parameter; 9, 10; 9, 11; 10, identifier:assume_sorted; 1...
def interp_like(self, other, method='linear', assume_sorted=False, kwargs={}): if self.dtype.kind not in 'uifc': raise TypeError('interp only works for a numeric type array. ' 'Given {}.'.format(self.dtype)) ds = self._to_temp_dataset().interp_...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 1, 9; 2, function_name:is_uniform_spaced; 3, parameters; 3, 4; 3, 5; 4, identifier:arr; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, type; 7, 8; 8, identifier:bool; 9, block; 9, 10; 9, 22; 9, 31; 10, expression_statement; 10, 11; 11, assignment; ...
def is_uniform_spaced(arr, **kwargs) -> bool: arr = np.array(arr, dtype=float) diffs = np.diff(arr) return bool(np.isclose(diffs.min(), diffs.max(), **kwargs))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:broadcast_variables; 3, parameters; 3, 4; 4, list_splat_pattern; 4, 5; 5, identifier:variables; 6, block; 6, 7; 6, 14; 6, 21; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:dims_map; 10, call; 10, 11; 10, 12; 11, ident...
def broadcast_variables(*variables): dims_map = _unified_dims(variables) dims_tuple = tuple(dims_map) return tuple(var.set_dims(dims_map) if var.dims != dims_tuple else var for var in variables)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:interp; 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:coords; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:method; 10, string:'linear'; 11, default_parame...
def interp(self, coords=None, method='linear', assume_sorted=False, kwargs={}, **coords_kwargs): from . import missing coords = either_dict_or_kwargs(coords, coords_kwargs, 'interp') indexers = OrderedDict(self._validate_indexers(coords)) obj = self if assume_sorted else s...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:interp_like; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:other; 6, default_parameter; 6, 7; 6, 8; 7, identifier:method; 8, string:'linear'; 9, default_parameter; 9, 10; 9, 11; 10, identifier:assume_sorted; 1...
def interp_like(self, other, method='linear', assume_sorted=False, kwargs={}): coords = alignment.reindex_like_indexers(self, other) numeric_coords = OrderedDict() object_coords = OrderedDict() for k, v in coords.items(): if v.dtype.kind in 'uifcMm': ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:transpose; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:dims; 7, block; 7, 8; 7, 40; 7, 48; 7, 90; 8, if_statement; 8, 9; 8, 10; 9, identifier:dims; 10, block; 10, 11; 11, if_statement; 11, 12; 11, 2...
def transpose(self, *dims): if dims: if set(dims) ^ set(self.dims): raise ValueError('arguments to transpose (%s) must be ' 'permuted dataset dimensions (%s)' % (dims, tuple(self.dims))) ds = self.copy() ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:to_dask_dataframe; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:dim_order; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:set_index; 10, False; 11, block; 11, 12; 11, 18; 11, 2...
def to_dask_dataframe(self, dim_order=None, set_index=False): import dask.array as da import dask.dataframe as dd if dim_order is None: dim_order = list(self.dims) elif set(dim_order) != set(self.dims): raise ValueError( 'dim_order {} does not matc...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:interp; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:var; 5, identifier:indexes_coords; 6, identifier:method; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 20; 9, 37; 9, 49; 9, 56; 9, 72; 9, 80; 9, 94; 9, ...
def interp(var, indexes_coords, method, **kwargs): if not indexes_coords: return var.copy() if method in ['linear', 'nearest']: var, indexes_coords = _localize(var, indexes_coords) kwargs['bounds_error'] = kwargs.get('bounds_error', False) dims = list(indexes_coords) x, new_x = zip(*...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:coerce_pandas_values; 3, parameters; 3, 4; 4, identifier:objects; 5, block; 5, 6; 5, 13; 5, 20; 5, 24; 5, 102; 6, import_from_statement; 6, 7; 6, 11; 7, relative_import; 7, 8; 7, 9; 8, import_prefix; 9, dotted_name; 9, 10; 10, identifier:datase...
def coerce_pandas_values(objects): from .dataset import Dataset from .dataarray import DataArray out = [] for obj in objects: if isinstance(obj, Dataset): variables = obj else: variables = OrderedDict() if isinstance(obj, PANDAS_TYPES): ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:unique_value_groups; 3, parameters; 3, 4; 3, 5; 4, identifier:ar; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort; 7, True; 8, block; 8, 9; 8, 23; 8, 37; 8, 60; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 14; 11, pattern_li...
def unique_value_groups(ar, sort=True): inverse, values = pd.factorize(ar, sort=sort) groups = [[] for _ in range(len(values))] for n, g in enumerate(inverse): if g >= 0: groups[g].append(n) return values, groups
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:order; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 46; 6, if_statement; 6, 7; 6, 10; 6, 36; 7, attribute; 7, 8; 7, 9; 8, identifier:self; 9, identifier:stage; 10, block; 10, 11; 11, for_statement; 11, 12; 11, 13; 11, 14; 12, ide...
def order(self): if self.stage: for st in STAGES: if st in self.stage: stage = (STAGES.index(st), self.stage) break else: stage = (len(STAGES),) return (int(self.major), int(self.minor), int(self.patch)) + stage
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:zadd; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 4, identifier:self; 5, identifier:name; 6, identifier:mapping; 7, default_parameter; 7, 8; 7, 9; 8, identifier:nx; 9, False; 10, default_parameter; 10, 11; 10, 12; 11, identifie...
def zadd(self, name, mapping, nx=False, xx=False, ch=False, incr=False): if not mapping: raise DataError("ZADD requires at least one element/score pair") if nx and xx: raise DataError("ZADD allows either 'nx' or 'xx', not both") if incr and len(mapping) != 1: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:zincrby; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:name; 6, identifier:amount; 7, identifier:value; 8, block; 8, 9; 8, 11; 9, expression_statement; 9, 10; 10, string:"Increment the score of ``value`` in sorted set...
def zincrby(self, name, amount, value): "Increment the score of ``value`` in sorted set ``name`` by ``amount``" return self.execute_command('ZINCRBY', name, amount, value)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:zinterstore; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:dest; 6, identifier:keys; 7, default_parameter; 7, 8; 7, 9; 8, identifier:aggregate; 9, None; 10, block; 10, 11; 11, return_statement; 11, 12; 12, call; 12, ...
def zinterstore(self, dest, keys, aggregate=None): return self._zaggregate('ZINTERSTORE', dest, keys, aggregate)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:zlexcount; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:name; 6, identifier:min; 7, identifier:max; 8, block; 8, 9; 9, return_statement; 9, 10; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:...
def zlexcount(self, name, min, max): return self.execute_command('ZLEXCOUNT', name, min, max)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:zpopmax; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:name; 6, default_parameter; 6, 7; 6, 8; 7, identifier:count; 8, None; 9, block; 9, 10; 9, 22; 9, 29; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 1...
def zpopmax(self, name, count=None): args = (count is not None) and [count] or [] options = { 'withscores': True } return self.execute_command('ZPOPMAX', name, *args, **options)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:zpopmin; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:name; 6, default_parameter; 6, 7; 6, 8; 7, identifier:count; 8, None; 9, block; 9, 10; 9, 22; 9, 29; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 1...
def zpopmin(self, name, count=None): args = (count is not None) and [count] or [] options = { 'withscores': True } return self.execute_command('ZPOPMIN', name, *args, **options)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:bzpopmax; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:keys; 6, default_parameter; 6, 7; 6, 8; 7, identifier:timeout; 8, integer:0; 9, block; 9, 10; 9, 19; 9, 27; 9, 34; 10, if_statement; 10, 11; 10, 14; 11, comparison_ope...
def bzpopmax(self, keys, timeout=0): if timeout is None: timeout = 0 keys = list_or_args(keys, None) keys.append(timeout) return self.execute_command('BZPOPMAX', *keys)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:bzpopmin; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:keys; 6, default_parameter; 6, 7; 6, 8; 7, identifier:timeout; 8, integer:0; 9, block; 9, 10; 9, 19; 9, 27; 9, 34; 10, if_statement; 10, 11; 10, 14; 11, comparison_ope...
def bzpopmin(self, keys, timeout=0): if timeout is None: timeout = 0 keys = list_or_args(keys, None) keys.append(timeout) return self.execute_command('BZPOPMIN', *keys)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:zremrangebylex; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:name; 6, identifier:min; 7, identifier:max; 8, block; 8, 9; 9, return_statement; 9, 10; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identi...
def zremrangebylex(self, name, min, max): return self.execute_command('ZREMRANGEBYLEX', name, min, max)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:zremrangebyrank; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:name; 6, identifier:min; 7, identifier:max; 8, block; 8, 9; 9, return_statement; 9, 10; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, ident...
def zremrangebyrank(self, name, min, max): return self.execute_command('ZREMRANGEBYRANK', name, min, max)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:argsort_k_smallest; 3, parameters; 3, 4; 3, 5; 4, identifier:x; 5, identifier:k; 6, block; 6, 7; 6, 24; 6, 43; 6, 57; 6, 63; 7, if_statement; 7, 8; 7, 11; 8, comparison_operator:==; 8, 9; 8, 10; 9, identifier:k; 10, integer:0; 11, block; 11, 12...
def argsort_k_smallest(x, k): if k == 0: return np.array([], dtype=np.intp) if k is None or k >= len(x): return np.argsort(x) indices = np.argpartition(x, k)[:k] values = x[indices] return indices[np.argsort(values)]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:lookup; 3, parameters; 3, 4; 3, 8; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:source_id; 6, type; 6, 7; 7, identifier:str; 8, typed_parameter; 8, 9; 8, 10; 9, identifier:schema_id; 10, type; 10, 11; 11, identifier:str; 12, block; 12, 13; 13...
async def lookup(source_id: str, schema_id: str): try: schema = Schema(source_id, '', '', []) if not hasattr(Schema.lookup, "cb"): schema.logger.debug("vcx_schema_get_attributes: Creating callback") Schema.lookup.cb = create_cb(CFUNCTYPE(None, c_uint32, c_...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:interleave_keys; 3, parameters; 3, 4; 3, 5; 4, identifier:a; 5, identifier:b; 6, block; 6, 7; 6, 30; 7, function_definition; 7, 8; 7, 9; 7, 11; 8, function_name:interleave; 9, parameters; 9, 10; 10, identifier:args; 11, block; 11, 12; 12, retur...
def interleave_keys(a, b): def interleave(args): return ''.join([x for t in zip(*args) for x in t]) return int(''.join(interleave(format(x, '016b') for x in (a, b))), base=2)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 24; 2, function_name:pool; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 15; 3, 18; 3, 21; 4, identifier:data; 5, identifier:batch_size; 6, identifier:key; 7, default_parameter; 7, 8; 7, 9; 8, identifier:batch_size_fn; 9, lambda; 9, 10; 9, 14; 10, lambda_parameters; 1...
def pool(data, batch_size, key, batch_size_fn=lambda new, count, sofar: count, random_shuffler=None, shuffle=False, sort_within_batch=False): if random_shuffler is None: random_shuffler = random.shuffle for p in batch(data, batch_size * 100, batch_size_fn): p_batch = batch(sorted(p, key...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:data; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 63; 6, if_statement; 6, 7; 6, 10; 6, 25; 6, 55; 7, attribute; 7, 8; 7, 9; 8, identifier:self; 9, identifier:sort; 10, block; 10, 11; 11, expression_statement; 11, 12; 12, assignm...
def data(self): if self.sort: xs = sorted(self.dataset, key=self.sort_key) elif self.shuffle: xs = [self.dataset[i] for i in self.random_shuffler(range(len(self.dataset)))] else: xs = self.dataset return xs
0, module; 0, 1; 0, 302; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:color_table; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:color; 5, default_parameter; 5, 6; 5, 7; 6, identifier:N; 7, integer:1; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sort; 10, False; 11, default_para...
def color_table(color, N=1, sort=False, sort_values=False, inline=False, as_html=False): if isinstance(color, list): c_ = '' rgb_tup = [normalize(c) for c in color] if sort: rgb_tup.sort() elif isinstance(color, dict): c_ = '' items = [(k, normalize(v), hex_to...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_nearest_edge; 3, parameters; 3, 4; 3, 5; 4, identifier:G; 5, identifier:point; 6, block; 6, 7; 6, 15; 6, 28; 6, 43; 6, 69; 6, 84; 6, 92; 6, 99; 6, 119; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:start_time; 10,...
def get_nearest_edge(G, point): start_time = time.time() gdf = graph_to_gdfs(G, nodes=False, fill_edge_geometry=True) graph_edges = gdf[["geometry", "u", "v"]].values.tolist() edges_with_distances = [ ( graph_edge, Point(tuple(reversed(point))).distance(graph_edge[0]) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:get_http_headers; 3, parameters; 3, 4; 3, 7; 3, 10; 4, default_parameter; 4, 5; 4, 6; 5, identifier:user_agent; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:referer; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifier:ac...
def get_http_headers(user_agent=None, referer=None, accept_language=None): if user_agent is None: user_agent = settings.default_user_agent if referer is None: referer = settings.default_referer if accept_language is None: accept_language = settings.default_accept_language headers...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_has_sorted_sa_indices; 3, parameters; 3, 4; 3, 5; 4, identifier:s_indices; 5, identifier:a_indices; 6, block; 6, 7; 6, 14; 6, 60; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:L; 10, call; 10, 11; 10, 12; 11, identif...
def _has_sorted_sa_indices(s_indices, a_indices): L = len(s_indices) for i in range(L-1): if s_indices[i] > s_indices[i+1]: return False if s_indices[i] == s_indices[i+1]: if a_indices[i] >= a_indices[i+1]: return False return True
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_generate_a_indptr; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:num_states; 5, identifier:s_indices; 6, identifier:out; 7, block; 7, 8; 7, 12; 7, 18; 7, 47; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:idx; 11, ...
def _generate_a_indptr(num_states, s_indices, out): idx = 0 out[0] = 0 for s in range(num_states-1): while(s_indices[idx] == s): idx += 1 out[s+1] = idx out[num_states] = len(s_indices)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_topologically; 3, parameters; 3, 4; 4, identifier:dag; 5, block; 5, 6; 5, 15; 5, 19; 5, 29; 5, 86; 5, 106; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:dag; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 1...
def sort_topologically(dag): dag = copy.deepcopy(dag) sorted_nodes = [] independent_nodes = deque(get_independent_nodes(dag)) while independent_nodes: node = independent_nodes.popleft() sorted_nodes.append(node) downstream_nodes = dag[node] while downstream_nodes: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:set_topological_dag_upstreams; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:dag; 5, identifier:ops; 6, identifier:op_runs; 7, identifier:runs_by_ops; 8, block; 8, 9; 8, 20; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12;...
def set_topological_dag_upstreams(dag, ops, op_runs, runs_by_ops): sorted_ops = dags.sort_topologically(dag=dag) for op_id in sorted_ops: op_run_id = runs_by_ops[op_id] op_run = op_runs[op_run_id] set_op_upstreams(op_run=op_run, op=ops[op_id])
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:generate_from_text; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:text; 6, block; 6, 7; 6, 16; 6, 23; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:words; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12...
def generate_from_text(self, text): words = self.process_text(text) self.generate_from_frequencies(words) return self
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_update_pods_metrics; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:instance; 6, identifier:pods; 7, block; 7, 8; 7, 15; 7, 101; 7, 111; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:tags_map; 1...
def _update_pods_metrics(self, instance, pods): tags_map = defaultdict(int) for pod in pods['items']: pod_meta = pod.get('metadata', {}) pod_tags = self.kubeutil.get_pod_creator_tags(pod_meta, legacy_rep_controller_tag=True) services = self.kubeutil.match_services_for...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_agent_tags; 3, parameters; 3, 4; 3, 5; 4, identifier:since; 5, identifier:to; 6, block; 6, 7; 6, 23; 6, 42; 6, 49; 6, 62; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:agent_tags; 10, call; 10, 11; 10, 12; 11, ide...
def get_agent_tags(since, to): agent_tags = sorted(parse_version_info(t) for t in git_tag_list(r'^\d+\.\d+\.\d+$')) if to: to = parse_version_info(to) else: to = agent_tags[-1] since = parse_version_info(since) agent_tags = [t for t in agent_tags if since <= t <= to] return [str(...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:sort; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:key_or_list; 6, default_parameter; 6, 7; 6, 8; 7, identifier:direction; 8, None; 9, block; 9, 10; 9, 16; 9, 26; 9, 37; 10, expression_statement; 10, 11; 11, call; 11, 12; ...
def sort(self, key_or_list, direction=None): self.__check_okay_to_chain() keys = helpers._index_list(key_or_list, direction) self.__ordering = helpers._index_document(keys) return self
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:find_one_and_replace; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 3, 21; 4, identifier:self; 5, identifier:filter; 6, identifier:replacement; 7, default_parameter; 7, 8; 7, 9; 8, identifier:projection; 9, None; 10, default_para...
def find_one_and_replace(self, filter, replacement, projection=None, sort=None, upsert=False, return_document=ReturnDocument.BEFORE, **kwargs): common.validate_ok_for_replace(replacement) kwargs['update'] = replacement return self.__find_...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:find_one_and_update; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 3, 21; 4, identifier:self; 5, identifier:filter; 6, identifier:update; 7, default_parameter; 7, 8; 7, 9; 8, identifier:projection; 9, None; 10, default_parameter;...
def find_one_and_update(self, filter, update, projection=None, sort=None, upsert=False, return_document=ReturnDocument.BEFORE, **kwargs): common.validate_ok_for_update(update) kwargs['update'] = update return self.__find_and_modify(filter, ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 26; 2, function_name:feature_correlation; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 4, identifier:X; 5, identifier:y; 6, default_parameter; 6, 7; 6, 8; 7, identifier:ax; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:me...
def feature_correlation(X, y, ax=None, method='pearson', labels=None, sort=False, feature_index=None, feature_names=None, **kwargs): viz = FeatureCorrelation(ax, method, labels, sort, feature_index, feature_names, **kwargs) viz.fit(X, ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 29; 2, function_name:dispersion; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 3, 27; 4, identifier:words; 5, identifier:corpus; 6, default_parameter; 6, 7; 6, 8; 7, identifier:y; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identif...
def dispersion(words, corpus, y=None, ax=None, colors=None, colormap=None, labels=None, annotate_docs=False, ignore_case=False, **kwargs): visualizer = DispersionPlot( words, ax=ax, colors=colors, colormap=colormap, ignore_case=ignore_case, labels=labels, annotate_docs=annotat...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sorted_product_set; 3, parameters; 3, 4; 3, 5; 4, identifier:array_a; 5, identifier:array_b; 6, block; 6, 7; 7, return_statement; 7, 8; 8, subscript; 8, 9; 8, 37; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:np; 12, iden...
def sorted_product_set(array_a, array_b): return np.sort( np.concatenate( [array_a[i] * array_b for i in xrange(len(array_a))], axis=0) )[::-1]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_get_sorted_inputs; 3, parameters; 3, 4; 4, identifier:filename; 5, block; 5, 6; 5, 59; 5, 81; 5, 99; 5, 103; 5, 107; 5, 133; 6, with_statement; 6, 7; 6, 20; 7, with_clause; 7, 8; 8, with_item; 8, 9; 9, as_pattern; 9, 10; 9, 18; 10, call; 10, 1...
def _get_sorted_inputs(filename): with tf.gfile.Open(filename) as f: records = f.read().split("\n") inputs = [record.strip() for record in records] if not inputs[-1]: inputs.pop() input_lens = [(i, len(line.split())) for i, line in enumerate(inputs)] sorted_input_lens = sorted(input_lens, key=la...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:games_by_time; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:start_game; 6, identifier:end_game; 7, block; 7, 8; 7, 12; 7, 44; 7, 88; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:move_count; 11...
def games_by_time(self, start_game, end_game): move_count = b'move_count' rows = self.bt_table.read_rows( ROWCOUNT_PREFIX.format(start_game), ROWCOUNT_PREFIX.format(end_game), filter_=bigtable_row_filters.ColumnRangeFilter( METADATA, move_count, move_c...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:bleakest_moves; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:start_game; 6, identifier:end_game; 7, block; 7, 8; 7, 12; 7, 44; 7, 98; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:bleak; 11, st...
def bleakest_moves(self, start_game, end_game): bleak = b'bleakest_q' rows = self.bt_table.read_rows( ROW_PREFIX.format(start_game), ROW_PREFIX.format(end_game), filter_=bigtable_row_filters.ColumnRangeFilter( METADATA, bleak, bleak)) def parse...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:_generate_subtokens; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:token_counts; 5, identifier:alphabet; 6, identifier:min_count; 7, default_parameter; 7, 8; 7, 9; 8, identifier:num_iterations; 9, integer:4; 10, default_parameter...
def _generate_subtokens( token_counts, alphabet, min_count, num_iterations=4, reserved_tokens=None): if reserved_tokens is None: reserved_tokens = RESERVED_TOKENS subtoken_list = reserved_tokens + list(alphabet) max_subtoken_length = 1 for i in xrange(num_iterations): tf.logging.info("\tGenerati...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:sparse_svd; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:sparse_matrix; 5, identifier:num_values; 6, identifier:max_iter; 7, block; 7, 8; 7, 20; 7, 36; 7, 55; 7, 76; 8, if_statement; 8, 9; 8, 12; 9, comparison_operator:<=; 9, 10; 9, 11; 10, i...
def sparse_svd(sparse_matrix, num_values, max_iter): if num_values <= 0: raise ValueError("num_values should be > 0 but instead is %d." % num_values) if max_iter is not None and max_iter < 0: raise ValueError("max_iter should be >= 0 but instead is %d." % max_iter) if max_iter is None: max_iter = FLAG...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:build_collate_fn; 3, parameters; 3, 4; 3, 7; 3, 10; 4, default_parameter; 4, 5; 4, 6; 5, identifier:batch_first; 6, False; 7, default_parameter; 7, 8; 7, 9; 8, identifier:parallel; 9, True; 10, default_parameter; 10, 11; 10, 12; 11, identifier...
def build_collate_fn(batch_first=False, parallel=True, sort=False): def collate_seq(seq): lengths = [len(s) for s in seq] batch_length = max(lengths) shape = (batch_length, len(seq)) seq_tensor = torch.full(shape, config.PAD, dtype=torch.int64) for i, s in enumerate(seq): ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:get_golden_chunk_records; 3, parameters; 4, block; 4, 5; 4, 21; 5, expression_statement; 5, 6; 6, assignment; 6, 7; 6, 8; 7, identifier:pattern; 8, call; 8, 9; 8, 14; 9, attribute; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:os;...
def get_golden_chunk_records(): pattern = os.path.join(fsdb.golden_chunk_dir(), '*.zz') return sorted(tf.gfile.Glob(pattern), reverse=True)[:FLAGS.window_size]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_sorted_results; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:results_dicts; 6, block; 6, 7; 6, 13; 6, 28; 6, 32; 6, 45; 7, expression_statement; 7, 8; 8, call; 8, 9; 8, 10; 9, identifier:print; 10, argument_list; 10, 11; 10, 12...
def _sorted_results(self, results_dicts): print('results dicts:', results_dicts) sorted_dict = sorted(results_dicts, key=lambda k: k['start_time']) results = [] for entry in sorted_dict: results.append(entry['dt']) return results
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:get_models; 3, parameters; 4, block; 4, 5; 4, 24; 4, 39; 4, 62; 5, expression_statement; 5, 6; 6, assignment; 6, 7; 6, 8; 7, identifier:all_models; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:gfile; 11, identifier:Glob; 12,...
def get_models(): all_models = gfile.Glob(os.path.join(models_dir(), '*.meta')) model_filenames = [os.path.basename(m) for m in all_models] model_numbers_names = sorted([ (shipname.detect_model_num(m), shipname.detect_model_name(m)) for m in model_filenames]) return model_numbers_names
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 1, 19; 2, function_name:sorted_by; 3, parameters; 3, 4; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:key; 6, type; 6, 7; 7, generic_type; 7, 8; 7, 9; 8, identifier:Callable; 9, type_parameter; 9, 10; 9, 15; 10, type; 10, 11; 11, list:[raw_types.Qid]; 11, 12; ...
def sorted_by(key: Callable[[raw_types.Qid], Any]) -> 'QubitOrder': return QubitOrder(lambda qubits: tuple(sorted(qubits, key=key)))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 32; 1, 36; 2, function_name:diagonalize_real_symmetric_and_sorted_diagonal_matrices; 3, parameters; 3, 4; 3, 10; 3, 16; 3, 17; 3, 22; 3, 27; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:symmetric_matrix; 6, type; 6, 7; 7, attribute; 7, 8; 7, 9; 8, identifier:np; ...
def diagonalize_real_symmetric_and_sorted_diagonal_matrices( symmetric_matrix: np.ndarray, diagonal_matrix: np.ndarray, *, rtol: float = 1e-5, atol: float = 1e-8, check_preconditions: bool = True) -> np.ndarray: if check_preconditions: if (np.any(np.imag(symme...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 34; 1, 48; 2, function_name:findall_operations_between; 3, parameters; 3, 4; 3, 5; 3, 17; 3, 29; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:start_frontier; 7, type; 7, 8; 8, generic_type; 8, 9; 8, 10; 9, identifier:Dict; 10, type_parameter; ...
def findall_operations_between(self, start_frontier: Dict[ops.Qid, int], end_frontier: Dict[ops.Qid, int], omit_crossing_operations: bool = False ) -> List[Tuple[int, ops.Operation...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_GetUnsortedNotifications; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:queue_shard; 6, default_parameter; 6, 7; 6, 8; 7, identifier:notifications_by_session_id; 8, None; 9, block; 9, 10; 9, 19; 9, 33; 9, 121; 10, if_state...
def _GetUnsortedNotifications(self, queue_shard, notifications_by_session_id=None): if notifications_by_session_id is None: notifications_by_session_id = {} end_time = self.frozen_timestamp or rdfvalue.RDFDatetime.Now() for notification i...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:Dump; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:obj; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort_keys; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:encoder; 10, None; 11, block; 11, 12; 11, 36; 11, 56; 12, expressio...
def Dump(obj, sort_keys = False, encoder = None): text = json.dumps( obj, indent=2, sort_keys=sort_keys, ensure_ascii=False, cls=encoder, separators=_SEPARATORS) if compatibility.PY2 and isinstance(text, bytes): text = text.decode("utf-8") return text
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:NamedPlaceholders; 3, parameters; 3, 4; 4, identifier:iterable; 5, block; 5, 6; 5, 26; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:placeholders; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, string:", "; ...
def NamedPlaceholders(iterable): placeholders = ", ".join("%({})s".format(key) for key in sorted(iterable)) return "({})".format(placeholders)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:Columns; 3, parameters; 3, 4; 4, identifier:iterable; 5, block; 5, 6; 5, 13; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:columns; 9, call; 9, 10; 9, 11; 10, identifier:sorted; 11, argument_list; 11, 12; 12, identifie...
def Columns(iterable): columns = sorted(iterable) return "({})".format(", ".join("`{}`".format(col) for col in columns))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:GetArtifactsForCollection; 3, parameters; 3, 4; 3, 5; 4, identifier:os_name; 5, identifier:artifact_list; 6, block; 6, 7; 6, 15; 6, 23; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:artifact_arranger; 10, call; 10, 11...
def GetArtifactsForCollection(os_name, artifact_list): artifact_arranger = ArtifactArranger(os_name, artifact_list) artifact_names = artifact_arranger.GetArtifactsInProperOrder() return artifact_names
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_FilterOutPathInfoDuplicates; 3, parameters; 3, 4; 4, identifier:path_infos; 5, block; 5, 6; 5, 10; 5, 39; 5, 66; 5, 94; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:pi_dict; 9, dictionary; 10, for_statement; 10, 11; ...
def _FilterOutPathInfoDuplicates(path_infos): pi_dict = {} for pi in path_infos: path_key = (pi.path_type, pi.GetPathID()) pi_dict.setdefault(path_key, []).append(pi) def _SortKey(pi): return ( pi.stat_entry.st_ctime, pi.stat_entry.st_mtime, pi.stat_entry.st_atime, pi.s...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:DrainTaskSchedulerQueueForClient; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:client; 6, default_parameter; 6, 7; 6, 8; 7, identifier:max_count; 8, None; 9, block; 9, 10; 9, 21; 9, 28; 9, 37; 9, 45; 9, 230; 9, 245; 9, 267...
def DrainTaskSchedulerQueueForClient(self, client, max_count=None): if max_count is None: max_count = self.max_queue_size if max_count <= 0: return [] client = rdf_client.ClientURN(client) start_time = time.time() if data_store.RelationalDBEnabled(): action_requests = data_store.RE...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 71; 2, function_name:federated_query; 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; 3, 42; 3, 45; 3, 48; 3, 51; 3, 54; 3, 57; 3, 60; 3, 63; 3, 66; 3, 69; 4, identifier:self; 5, identifier:environment_i...
def federated_query(self, environment_id, filter=None, query=None, natural_language_query=None, passages=None, aggregation=None, count=None, ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 27; 2, function_name:query_relations; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 3, 25; 4, identifier:self; 5, identifier:environment_id; 6, identifier:collection_id; 7, default_parameter; 7, 8; 7, 9; 8, identifier:entities; 9, None;...
def query_relations(self, environment_id, collection_id, entities=None, context=None, sort=None, filter=None, count=None, eviden...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 22; 2, function_name:query_log; 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:filter; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:query; 10, None; 11, default_paramete...
def query_log(self, filter=None, query=None, count=None, offset=None, sort=None, **kwargs): headers = {} if 'headers' in kwargs: headers.update(kwargs.get('headers')) sdk_heade...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 22; 2, function_name:list_workspaces; 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:page_limit; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:include_count; 10, None; 11...
def list_workspaces(self, page_limit=None, include_count=None, sort=None, cursor=None, include_audit=None, **kwargs): headers = {} if 'headers' in kwargs: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 55; 2, function_name:list_feedback; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 3, 35; 3, 38; 3, 41; 3, 44; 3, 47; 3, 50; 3, 53; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:feedback_type; 7, None...
def list_feedback(self, feedback_type=None, before=None, after=None, document_title=None, model_id=None, model_version=None, category_removed=None, ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:multi_index_insert_row; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:df; 5, identifier:index_row; 6, identifier:values_row; 7, block; 7, 8; 7, 32; 7, 49; 7, 60; 7, 88; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier...
def multi_index_insert_row(df, index_row, values_row): row_index = pd.MultiIndex(levels=[[i] for i in index_row], labels=[[0] for i in index_row]) row = pd.DataFrame(values_row, index=row_index, columns=df.columns) df = pd.concat((df, row)) if df.index.lexsort_depth == len(...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:substring_search; 3, parameters; 3, 4; 3, 5; 4, identifier:word; 5, identifier:collection; 6, block; 6, 7; 7, return_statement; 7, 8; 8, list_comprehension; 8, 9; 8, 10; 8, 16; 9, identifier:item; 10, for_in_clause; 10, 11; 10, 12; 11, identifi...
def substring_search(word, collection): return [item for item in sorted(collection) if item.startswith(word)]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_nodes; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, return_statement; 6, 7; 7, call; 7, 8; 7, 9; 8, identifier:list; 9, argument_list; 9, 10; 10, call; 10, 11; 10, 12; 11, identifier:set; 12, argument_list; 12, 13; 13, list_comp...
def _nodes(self): return list(set([node for node, timeslice in super(DynamicBayesianNetwork, self).nodes()]))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:add_edge; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:start; 6, identifier:end; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 144; 9, 211; 9, 225; 10, try_statement; 10, 11; 10, 136; 1...
def add_edge(self, start, end, **kwargs): try: if len(start) != 2 or len(end) != 2: raise ValueError('Nodes must be of type (node, time_slice).') elif not isinstance(start[1], int) or not isinstance(end[1], int): raise ValueError('Nodes must be of type (no...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:estimate; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:start; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:tabu_length; 10, integer:0; 11, default_parameter; 11, 12; 1...
def estimate(self, start=None, tabu_length=0, max_indegree=None): epsilon = 1e-8 nodes = self.state_names.keys() if start is None: start = DAG() start.add_nodes_from(nodes) elif not isinstance(start, DAG) or not set(start.nodes()) == set(nodes): raise ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:add_node; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:node; 6, default_parameter; 6, 7; 6, 8; 7, identifier:weight; 8, None; 9, block; 9, 10; 9, 64; 10, if_statement; 10, 11; 10, 31; 10, 55; 11, boolean_operator:and; 11, ...
def add_node(self, node, weight=None): if isinstance(node, tuple) and len(node) == 2 and isinstance(node[1], dict): node, attrs = node if attrs.get('weight', None) is not None: attrs['weight'] = weight else: attrs = {'weight': weight} super(DAG...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:add_nodes_from; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:nodes; 6, default_parameter; 6, 7; 6, 8; 7, identifier:weights; 8, None; 9, block; 9, 10; 9, 17; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13...
def add_nodes_from(self, nodes, weights=None): nodes = list(nodes) if weights: if len(nodes) != len(weights): raise ValueError("The number of elements in nodes and weights" "should be equal.") for index in range(len(nodes)): ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:rank_items; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:userid; 6, identifier:user_items; 7, identifier:selected_items; 8, default_parameter; 8, 9; 8, 10; 9, identifier:recalculate_user; 10, False; 11, block;...
def rank_items(self, userid, user_items, selected_items, recalculate_user=False): if max(selected_items) >= user_items.shape[1] or min(selected_items) < 0: raise IndexError("Some of selected itemids are not in the model") liked_vector = user_items[userid] recommendations = liked_vect...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:get_sorted_structure; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 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, block; 11, 12; 11, 25; 12, expres...
def get_sorted_structure(self, key=None, reverse=False): sites = sorted(self, key=key, reverse=reverse) return self.__class__.from_sites(sites, charge=self._charge)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:from_str; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 4, identifier:cls; 5, identifier:input_string; 6, identifier:fmt; 7, default_parameter; 7, 8; 7, 9; 8, identifier:primitive; 9, False; 10, default_parameter; 10, 11; 10, 12; 11, id...
def from_str(cls, input_string, fmt, primitive=False, sort=False, merge_tol=0.0): from pymatgen.io.cif import CifParser from pymatgen.io.vasp import Poscar from pymatgen.io.cssr import Cssr from pymatgen.io.xcrysden import XSF from pymatgen.io.atat import Mcsqs ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_transition_chempots; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:element; 6, block; 6, 7; 6, 21; 6, 25; 6, 49; 6, 53; 6, 99; 6, 105; 7, if_statement; 7, 8; 7, 13; 8, comparison_operator:not; 8, 9; 8, 10; 9, identifier:eleme...
def get_transition_chempots(self, element): if element not in self.elements: raise ValueError("get_transition_chempots can only be called with " "elements in the phase diagram.") critical_chempots = [] for facet in self.facets: chempots = self...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:from_dir; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:cls; 5, identifier:top; 6, default_parameter; 6, 7; 6, 8; 7, identifier:exts; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:exclude_dirs; 11, string:"_*"; 12, block; ...
def from_dir(cls, top, exts=None, exclude_dirs="_*"): pseudos = [] if exts == "all_files": for f in [os.path.join(top, fn) for fn in os.listdir(top)]: if os.path.isfile(f): try: p = Pseudo.from_file(f) if p: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:sorted; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:attrname; 6, default_parameter; 6, 7; 6, 8; 7, identifier:reverse; 8, False; 9, block; 9, 10; 9, 14; 9, 48; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11,...
def sorted(self, attrname, reverse=False): attrs = [] for i, pseudo in self: try: a = getattr(pseudo, attrname) except AttributeError: a = np.inf attrs.append((i, a)) return self.__class__([self[a[0]] for a in sorted(attrs, key=...