sequence
stringlengths
1.19k
35k
code
stringlengths
75
8.58k
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'select_segment'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'childr...
def select_segment(self, segs, segs_tips, segs_undecided) -> Tuple[int, int]: scores_tips = np.zeros((len(segs), 4)) allindices = np.arange(self._adata.shape[0], dtype=int) for iseg, seg in enumerate(segs): if segs_tips[iseg][0] == -1: continue if not isinstance(self.dist...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'unique_categories'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
def unique_categories(categories): categories = np.unique(categories) categories = np.setdiff1d(categories, np.array(settings.categories_to_ignore)) categories = np.array(natsorted(categories, key=lambda v: v.upper())) return categories
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_one_and_delete'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15']}; {'id': '4', 'type': 'identifi...
def find_one_and_delete(self, filter, projection=None, sort=None, session=None, **kwargs): kwargs['remove'] = True return self.__find_and_modify(filter, projection, sort, session=session, **kwargs)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'lines'}, {'i...
def sort(lines): lines = list(lines) new_lines = parse_block(lines, header=True) for block in sorted(parse_blocks(lines), key=first_key): if new_lines: new_lines.append('') new_lines.extend(block) return new_lines
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'first_key'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'lines'}...
def first_key(lines): for line in lines: if line.startswith(' continue if any(line.startswith(quote) for quote in QUOTES): return line[1:] return line else: return ''
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'geoadd'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '11']}; {'id': '4', 'type': 'identifier', 'chi...
def geoadd(self, key, longitude, latitude, member, *args, **kwargs): return self.execute( b'GEOADD', key, longitude, latitude, member, *args, **kwargs )
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '31']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'georadius'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '12', '13', '16', '19', '22', '25', '28']};...
def georadius(self, key, longitude, latitude, radius, unit='m', *, with_dist=False, with_hash=False, with_coord=False, count=None, sort=None, encoding=_NOTSET): args = validate_georadius_options( radius, unit, with_dist, with_hash, with_coord, count, sort ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '30']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'georadiusbymember'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '11', '12', '15', '18', '21', '24', '27'...
def georadiusbymember(self, key, member, radius, unit='m', *, with_dist=False, with_hash=False, with_coord=False, count=None, sort=None, encoding=_NOTSET): args = validate_georadius_options( radius, unit, with_dist, with_hash, with_coord, count, so...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '26']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '8', '11', '14', '17', '20', '23']}; {'id': '4', 'type': 'ident...
def sort(self, key, *get_patterns, by=None, offset=None, count=None, asc=None, alpha=False, store=None): args = [] if by is not None: args += [b'BY', by] if offset is not None and count is not None: args += [b'LIMIT', offset, count] if ge...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zadd'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '10']}; {'id': '4', 'type': 'identifier', 'children':...
def zadd(self, key, score, member, *pairs, exist=None): if not isinstance(score, (int, float)): raise TypeError("score argument must be int or float") if len(pairs) % 2 != 0: raise TypeError("length of pairs must be even number") scores = (item for i, item in enumerate(pa...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '22']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zcount'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '12', '18', '19']}; {'id': '4', 'type': 'identifier', 'childr...
def zcount(self, key, min=float('-inf'), max=float('inf'), *, exclude=None): if not isinstance(min, (int, float)): raise TypeError("min argument must be int or float") if not isinstance(max, (int, float)): raise TypeError("max argument must be int or float") ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zincrby'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
def zincrby(self, key, increment, member): if not isinstance(increment, (int, float)): raise TypeError("increment argument must be int or float") fut = self.execute(b'ZINCRBY', key, increment, member) return wait_convert(fut, int_or_float)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zrem'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
def zrem(self, key, member, *members): return self.execute(b'ZREM', key, member, *members)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zremrangebylex'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15']}; {'id': '4', 'type': 'identifier', ...
def zremrangebylex(self, key, min=b'-', max=b'+', include_min=True, include_max=True): if not isinstance(min, bytes): raise TypeError("min argument must be bytes") if not isinstance(max, bytes): raise TypeError("max argument must be bytes") if not m...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zremrangebyrank'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': ...
def zremrangebyrank(self, key, start, stop): if not isinstance(start, int): raise TypeError("start argument must be int") if not isinstance(stop, int): raise TypeError("stop argument must be int") return self.execute(b'ZREMRANGEBYRANK', key, start, stop)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '22']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zremrangebyscore'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '12', '18', '19']}; {'id': '4', 'type': 'identifier...
def zremrangebyscore(self, key, min=float('-inf'), max=float('inf'), *, exclude=None): if not isinstance(min, (int, float)): raise TypeError("min argument must be int or float") if not isinstance(max, (int, float)): raise TypeError("max argument must be i...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zrevrange'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '11']}; {'id': '4', 'type': 'identifier', 'child...
def zrevrange(self, key, start, stop, withscores=False, encoding=_NOTSET): if not isinstance(start, int): raise TypeError("start argument must be int") if not isinstance(stop, int): raise TypeError("stop argument must be int") if withscores: args = [b'WITHSCOR...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '34']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zrevrangebyscore'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '12', '18', '19', '22', '25', '28', '31']}; {'id': ...
def zrevrangebyscore(self, key, max=float('inf'), min=float('-inf'), *, exclude=None, withscores=False, offset=None, count=None, encoding=_NOTSET): if not isinstance(min, (int, float)): raise TypeError("min argument must be int or float") if ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zscore'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
def zscore(self, key, member): fut = self.execute(b'ZSCORE', key, member) return wait_convert(fut, optional_int_or_float)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zunionstore'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '9', '12']}; {'id': '4', 'type': 'identifier', 'chi...
def zunionstore(self, destkey, key, *keys, with_weights=False, aggregate=None): keys = (key,) + keys numkeys = len(keys) args = [] if with_weights: assert all(isinstance(val, (list, tuple)) for val in keys), ( "All key arguments must be (ke...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zscan'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier', 'children': [],...
def zscan(self, key, cursor=0, match=None, count=None): args = [] if match is not None: args += [b'MATCH', match] if count is not None: args += [b'COUNT', count] fut = self.execute(b'ZSCAN', key, cursor, *args) def _converter(obj): return (int(...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zpopmin'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '10']}; {'id': '4', 'type': 'identifier', 'children': [...
def zpopmin(self, key, count=None, *, encoding=_NOTSET): if count is not None and not isinstance(count, int): raise TypeError("count argument must be int") args = [] if count is not None: args.extend([count]) fut = self.execute(b'ZPOPMIN', key, *args, encoding=enc...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zpopmax'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '10']}; {'id': '4', 'type': 'identifier', 'children': [...
def zpopmax(self, key, count=None, *, encoding=_NOTSET): if count is not None and not isinstance(count, int): raise TypeError("count argument must be int") args = [] if count is not None: args.extend([count]) fut = self.execute(b'ZPOPMAX', key, *args, encoding=enc...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'uniq'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'container'},...
def uniq(container): try: return len(set(unbool(i) for i in container)) == len(container) except TypeError: try: sort = sorted(unbool(i) for i in container) sliced = itertools.islice(sort, 1, None) for i, j in zip(sort, sliced): if i == j: ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'split_traversal'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], '...
def split_traversal(traversal, edges, edges_hash=None): traversal = np.asanyarray(traversal, dtype=np.int64) if edges_hash is None: edges_hash = grouping.hashable_rows( np.sort(edges, axis=1)) trav_edge = np.column_sta...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fill_traversals'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], '...
def fill_traversals(traversals, edges, edges_hash=None): edges = np.asanyarray(edges, dtype=np.int64) edges.sort(axis=1) if len(traversals) == 0: return edges.copy() if edges_hash is None: edges_hash = grouping.hashable_rows(edges) splits = [] for nodes in traversals: spl...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'hashable_rows'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
def hashable_rows(data, digits=None): if len(data) == 0: return np.array([]) as_int = float_to_int(data, digits=digits) if len(as_int.shape) == 1: return as_int if len(as_int.shape) == 2 and as_int.shape[1] <= 4: precision = int(np.floor(64 / as_int.shape[1])) if np.abs(a...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'interpolate_nans_1d'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [...
def interpolate_nans_1d(x, y, kind='linear'): x_sort_args = np.argsort(x) x = x[x_sort_args] y = y[x_sort_args] nans = np.isnan(y) if kind == 'linear': y[nans] = np.interp(x[nans], x[~nans], y[~nans]) elif kind == 'log': y[nans] = np.interp(np.log(x[nans]), np.log(x[~nans]), y[~n...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'interpolate_1d'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '8']}; {'id': '4', 'type': 'identifier', 'children': ...
def interpolate_1d(x, xp, *args, **kwargs): r fill_value = kwargs.pop('fill_value', np.nan) axis = kwargs.pop('axis', 0) x = np.asanyarray(x).reshape(-1) ndim = xp.ndim sort_args = np.argsort(xp, axis=axis) sort_x = np.argsort(x) sorter = broadcast_indices(xp, sort_args, ndim, axis) ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'log_interpolate_1d'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '8']}; {'id': '4', 'type': 'identifier', 'childre...
def log_interpolate_1d(x, xp, *args, **kwargs): r fill_value = kwargs.pop('fill_value', np.nan) axis = kwargs.pop('axis', 0) log_x = np.log(x) log_xp = np.log(xp) return interpolate_1d(log_x, log_xp, *args, axis=axis, fill_value=fill_value)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_find_append_zero_crossings'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children'...
def _find_append_zero_crossings(x, y): r crossings = find_intersections(x[1:], y[1:], np.zeros_like(y[1:]) * y.units) x = concatenate((x, crossings[0])) y = concatenate((y, crossings[1])) sort_idx = np.argsort(x) x = x[sort_idx] y = y[sort_idx] keep_idx = np.ediff1d(x, to_end=[1]) > 0 ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_ordered_objects'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], ...
def sort_ordered_objects(items, getter=lambda x: x): return sorted(items, key=lambda x: getattr(getter(x), OrderedBase.CREATION_COUNTER_FIELD, -1))
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove_fewwords_paragraphs'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], ...
def remove_fewwords_paragraphs(self): all_nodes = self.parser.getElementsByTags(self.get_top_node(), ['*']) all_nodes.reverse() for el in all_nodes: tag = self.parser.getTag(el) text = self.parser.getText(el) stop_words = self.stopwords_class(language=self.get...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'compare_baselines'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
def compare_baselines(old_baseline_filename, new_baseline_filename): if old_baseline_filename == new_baseline_filename: raise RedundantComparisonError old_baseline = _get_baseline_from_file(old_baseline_filename) new_baseline = _get_baseline_from_file(new_baseline_filename) _remove_nonexistent_f...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_GetEventIdentifiers'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], '...
def _GetEventIdentifiers(self, event): attributes = [] attribute_string = 'data_type: {0:s}'.format(event.data_type) attributes.append(attribute_string) for attribute_name, attribute_value in sorted(event.GetAttributes()): if attribute_name in self._IDENTIFIER_EXCLUDED_ATTRIBUTES: continue...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'PopEvents'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'},...
def PopEvents(self): event = self.PopEvent() while event: yield event event = self.PopEvent()
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_CheckStatusAnalysisProcess'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children'...
def _CheckStatusAnalysisProcess(self, pid): self._RaiseIfNotRegistered(pid) if pid in self._completed_analysis_processes: status_indicator = definitions.STATUS_INDICATOR_COMPLETED process_status = { 'processing_status': status_indicator} used_memory = 0 else: process = self...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_ExportEvent'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': []...
def _ExportEvent(self, output_module, event, deduplicate_events=True): if event.timestamp != self._export_event_timestamp: self._FlushExportBuffer( output_module, deduplicate_events=deduplicate_events) self._export_event_timestamp = event.timestamp self._export_event_heap.PushEvent(event)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_FlushExportBuffer'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': []...
def _FlushExportBuffer(self, output_module, deduplicate_events=True): last_macb_group_identifier = None last_content_identifier = None macb_group = [] generator = self._export_event_heap.PopEvents() for macb_group_identifier, content_identifier, event in generator: if deduplicate_events and la...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_MergeEventTag'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
def _MergeEventTag(self, storage_writer, attribute_container): if attribute_container.CONTAINER_TYPE != 'event_tag': return event_identifier = attribute_container.GetEventIdentifier() if not event_identifier: return stored_event_tag = self._event_tag_index.GetEventTagByIdentifier( st...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_StartAnalysisProcesses'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children...
def _StartAnalysisProcesses(self, storage_writer, analysis_plugins): logger.info('Starting analysis plugins.') for analysis_plugin in analysis_plugins.values(): self._analysis_plugins[analysis_plugin.NAME] = analysis_plugin process = self._StartWorkerProcess(analysis_plugin.NAME, storage_writer) ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_StopAnalysisProcesses'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [],...
def _StopAnalysisProcesses(self, abort=False): logger.debug('Stopping analysis processes.') self._StopMonitoringProcesses() if abort: self._AbortTerminate() if not self._use_zeromq: logger.debug('Emptying queues.') for event_queue in self._event_queues.values(): event_queue.Emp...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_UpdateForemanProcessStatus'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [],...
def _UpdateForemanProcessStatus(self): used_memory = self._process_information.GetUsedMemory() or 0 display_name = getattr(self._merge_task, 'identifier', '') self._processing_status.UpdateForemanStatus( self._name, self._status, self._pid, used_memory, display_name, self._number_of_consumed...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'workers_status'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
def workers_status(self): return [self._workers_status[identifier] for identifier in sorted(self._workers_status.keys())]
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ProcessStorage'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
def ProcessStorage(self): self._CheckStorageFile(self._storage_file_path) self._status_view.SetMode(self._status_view_mode) self._status_view.SetStorageFileInformation(self._storage_file_path) status_update_callback = ( self._status_view.GetAnalysisStatusUpdateCallback()) session = engine.Ba...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_state'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
def sort_state(self, best_hyp_indices: mx.nd.NDArray): self.states = [mx.nd.take(ds, best_hyp_indices) for ds in self.states]
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '19', '27']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'rerank'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '15']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
def rerank(self, hypotheses: Dict[str, Any], reference: str) -> Dict[str, Any]: scores = [self.scoring_function(hypothesis, reference) for hypothesis in hypotheses['translations']] ranking = list(np.argsort(scores, kind='mergesort')[::-1]) reranked_hypotheses = self._sort_by_ranking(hypotheses, ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's...
def load(self, path: str, k: Optional[int] = None): load_time_start = time.time() with open(path, 'rb') as inp: _lex = np.load(inp) loaded_k = _lex.shape[1] if k is not None: top_k = min(k, loaded_k) if k > loaded_k: logger.warning("Can...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_trg_ids'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
def get_trg_ids(self, src_ids: np.ndarray) -> np.ndarray: unique_src_ids = np.lib.arraysetops.unique(src_ids) trg_ids = np.lib.arraysetops.union1d(self.always_allow, self.lex[unique_src_ids, :].reshape(-1)) return trg_ids
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'choice'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'...
def choice(self, obj): tree_id = getattr(obj, self.queryset.model._mptt_meta.tree_id_attr, 0) left = getattr(obj, self.queryset.model._mptt_meta.left_attr, 0) return super(MPTTModelChoiceIterator, self).choice(obj) + ((tree_id, left),)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_best_dataset_key'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], '...
def get_best_dataset_key(key, choices): if key.wavelength is not None and choices: nearest_wl = min([_wl_dist(key.wavelength, x.wavelength) for x in choices if x.wavelength is not None]) choices = [c for c in choices if _wl_dist(key.wavelength, c.waveleng...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '27']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_key'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18', '21', '24']}; {'id': '4', 'type': 'id...
def get_key(key, key_container, num_results=1, best=True, resolution=None, calibration=None, polarization=None, level=None, modifiers=None): if isinstance(key, numbers.Number): key = DatasetID(wavelength=key, modifiers=None) elif isinstance(key, (str, six.text_type)): key...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'group_files'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17']}; {'id': '4', 'type': 'identifier', 'c...
def group_files(files_to_sort, reader=None, time_threshold=10, group_keys=None, ppp_config_dir=None, reader_kwargs=None): if reader is None: raise ValueError("'reader' keyword argument is required.") elif not isinstance(reader, (list, tuple)): reader = [reader] reader = reade...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sorted_filetype_items'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
def sorted_filetype_items(self): processed_types = [] file_type_items = deque(self.config['file_types'].items()) while len(file_type_items): filetype, filetype_info = file_type_items.popleft() requirements = filetype_info.get('requires') if requirements is not...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'combine_hashes'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ha...
def combine_hashes(hashes): hasher = sha1() for h in sorted(hashes): h = ensure_binary(h) hasher.update(h) return hasher.hexdigest() if PY3 else hasher.hexdigest().decode('utf-8')
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '31']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'register_jvm_tool'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13', '16', '19', '22', '25', '28']}; {...
def register_jvm_tool(cls, register, key, classpath_spec=None, main=None, custom_rules=None, fingerprint=True, classpath=None, h...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_available_urls'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
def get_available_urls(self, urls): baseurl_to_urls = {self._baseurl(url): url for url in urls} pingtimes = self._pinger.pings(list(baseurl_to_urls.keys())) self._log.debug('Artifact cache server ping times: {}' .format(', '.join(['{}: {:.6f} secs'.format(*p) for p in pingtimes]))) s...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'iterate'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self...
def iterate(self, scopes): scope_infos = [self._scope_to_info[s] for s in self._expand_tasks(scopes)] if scope_infos: for scope_info in self._expand_subsystems(scope_infos): yield scope_info
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_expand_tasks'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
def _expand_tasks(self, scopes): expanded_scopes = set(scopes) for scope, info in self._scope_to_info.items(): if info.category == ScopeInfo.TASK: outer = enclosing_scope(scope) while outer != GLOBAL_SCOPE: if outer in expanded_scopes: expanded_scopes.add(scope) ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_all'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {...
def get_all(self): return [{'label': x[0], 'timing': x[1], 'is_tool': x[0] in self._tool_labels} for x in sorted(self._timings_by_path.items(), key=lambda x: x[1], reverse=True)]
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'all'}, {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5']}, {'id': '5', 'type': 'return...
def all(): return [goal for _, goal in sorted(Goal._goal_by_name.items()) if goal.active]
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'select_best_url'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's...
def select_best_url(self): best_url = self.parsed_urls[0] try: yield best_url except Exception: self.unsuccessful_calls[best_url] += 1 if self.unsuccessful_calls[best_url] > self.max_failures: self.parsed_urls.rotate(-1) self.unsuccessful_calls[best_url] = 0 raise ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_topological_sort'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
def _topological_sort(self, targets): target_set = set(targets) return [t for t in reversed(sort_targets(targets)) if t in target_set]
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sortmerna_detailed_barplot'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], ...
def sortmerna_detailed_barplot (self): keys = OrderedDict() metrics = set() for sample in self.sortmerna: for key in self.sortmerna[sample]: if not key in ["total", "rRNA", "non_rRNA"] and not "_pct" in key: metrics.add(key) for key in metr...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_short_chrom'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
def _short_chrom(self, chrom): default_allowed = set(["X"]) allowed_chroms = set(getattr(config, "goleft_indexcov_config", {}).get("chromosomes", [])) chrom_clean = chrom.replace("chr", "") try: chrom_clean = int(chrom_clean) except ValueError: if chrom_cl...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'deepvalues'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'mappin...
def deepvalues(mapping): values = vals_sorted_by_key(mapping) for obj in values: mapping = False try: obj.items except AttributeError: pass else: mapping = True for subobj in deepvalues(obj): yield subobj if ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'values'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'...
def values(self): return [self.policy.header_fetch_parse(k, v) for k, v in self._headers]
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'items'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'i...
def items(self): return [(k, self.policy.header_fetch_parse(k, v)) for k, v in self._headers]
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_all'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
def get_all(self, name, failobj=None): values = [] name = name.lower() for k, v in self._headers: if k.lower() == name: values.append(self.policy.header_fetch_parse(k, v)) if not values: return failobj return values
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'setup'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
def setup(job, input_file_id, n, down_checkpoints): job.fileStore.logToMaster("Starting the merge sort") return job.addChildJobFn(down, input_file_id, n, down_checkpoints=down_checkpoints, memory='600M').rv()
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'down'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
def down(job, input_file_id, n, down_checkpoints): input_file = job.fileStore.readGlobalFile(input_file_id, cache=False) length = os.path.getsize(input_file) if length > n: job.fileStore.logToMaster("Splitting file: %s of size: %s" % (input_file_id, length), level=l...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'in_file...
def sort(in_file, out_file): filehandle = open(in_file, 'r') lines = filehandle.readlines() filehandle.close() lines.sort() filehandle = open(out_file, 'w') for line in lines: filehandle.write(line) filehandle.close()
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'merge'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'f...
def merge(filehandle_1, filehandle_2, output_filehandle): line2 = filehandle_2.readline() for line1 in filehandle_1.readlines(): while line2 != '' and line2 <= line1: output_filehandle.write(line2) line2 = filehandle_2.readline() output_filehandle.write(line1) while l...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'decorateSubHeader'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [],...
def decorateSubHeader(title, columnWidths, options): title = title.lower() if title != options.sortCategory: s = "| %*s%*s%*s%*s%*s " % ( columnWidths.getWidth(title, "min"), "min", columnWidths.getWidth(title, "med"), "med", columnWidths.getWidth(title, "ave"), "ave"...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sortJobs'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'job...
def sortJobs(jobTypes, options): longforms = {"med": "median", "ave": "average", "min": "min", "total": "total", "max": "max",} sortField = longforms[options.sortField] if (options.sortCategory == "time" or options.sortCategory == "...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_sort_tau_by_y'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
def _sort_tau_by_y(self, y): tau_y = self.tau_matrix[:, y] tau_y[y] = np.NaN temp = np.empty([self.n_nodes, 3]) temp[:, 0] = np.arange(self.n_nodes) temp[:, 1] = tau_y temp[:, 2] = abs(tau_y) temp[np.isnan(temp)] = -10 tau_sorted = temp[temp[:, 2].argsort(...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_edge'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'edges'}...
def sort_edge(edges): return sorted(edges, key=lambda x: (x.L, x.R))
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '25']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'stanc'}, {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10', '13', '16', '19', '22']}; {'id': '4', 'type': 'default_parame...
def stanc(file=None, charset='utf-8', model_code=None, model_name="anon_model", include_paths=None, verbose=False, obfuscate_model_name=True): if file and model_code: raise ValueError("Specify stan model with `file` or `model_code`, " "not both.") if file is None and m...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'suggestion_list'}, {'id': '3', 'type': 'parameters', 'children': ['4', '8']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5'...
def suggestion_list(input_: str, options: Collection[str]): options_by_distance = {} input_threshold = len(input_) // 2 for option in options: distance = lexical_distance(input_, option) threshold = max(input_threshold, len(option) // 2, 1) if distance <= threshold: optio...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'lexical_distance'}, {'id': '3', 'type': 'parameters', 'children': ['4', '8']}; {'id': '4', 'type': 'typed_parameter', 'children...
def lexical_distance(a_str: str, b_str: str) -> int: if a_str == b_str: return 0 a, b = a_str.lower(), b_str.lower() a_len, b_len = len(a), len(b) if a == b: return 1 d = [[j for j in range(0, b_len + 1)]] for i in range(1, a_len + 1): d.append([i] + [0] * b_len) for ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16', '22']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_suggested_type_names'}, {'id': '3', 'type': 'parameters', 'children': ['4', '8', '12']}; {'id': '4', 'type': 'typed_paramet...
def get_suggested_type_names( schema: GraphQLSchema, type_: GraphQLOutputType, field_name: str ) -> List[str]: if is_abstract_type(type_): type_ = cast(GraphQLAbstractType, type_) suggested_object_types = [] interface_usage_count: Dict[str, int] = defaultdict(int) for possible_ty...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'instances_get'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': []...
def instances_get(opts, plugins, url_file_input, out): instances = OrderedDict() preferred_order = ['wordpress', 'joomla', 'drupal'] for cms_name in preferred_order: for plugin in plugins: plugin_name = plugin.__name__.lower() if cms_name == plugin_name: insta...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_signed_headers'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
def get_signed_headers(headers): signed_headers = [] for header in headers: signed_headers.append(header.lower().strip()) return sorted(signed_headers)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_from_names_to_locals'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [...
def add_from_names_to_locals(self, node): _key_func = lambda node: node.fromlineno def sort_locals(my_list): my_list.sort(key=_key_func) for (name, asname) in node.names: if name == "*": try: imported = node.do_import_module() ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'nearest'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self...
def nearest(self, nodes): myroot = self.root() mylineno = self.fromlineno nearest = None, 0 for node in nodes: assert node.root() is myroot, ( "nodes %s and %s are not from the same module" % (self, node) ) lineno = node.fromlineno ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'object_type'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
def object_type(node, context=None): try: types = set(_object_type(node, context)) except exceptions.InferenceError: return util.Uninferable if len(types) > 1 or not types: return util.Uninferable return list(types)[0]
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_deffacts'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self...
def get_deffacts(self): return sorted(self._get_by_type(DefFacts), key=lambda d: d.order)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'json_dumps'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's...
def json_dumps(self, data): return json.dumps( data, separators=(',', ':'), sort_keys=True, cls=self.json_encoder, ensure_ascii=False ).encode('utf8')
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_waveform_generator'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifi...
def create_waveform_generator(variable_params, data, recalibration=None, gates=None, **static_params): try: approximant = static_params['approximant'] except KeyError: raise ValueError("no approximant provided in the static args") g...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'rst_dict_table'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14']}; {'id': '4', 'type': 'identifier', 'chil...
def rst_dict_table(dict_, key_format=str, val_format=str, header=None, sort=True): keys, values = zip(*dict_.items()) keys = map(key_format, keys) values = map(val_format, values) nckey = max(map(len, keys)) ncval = max(map(len, values)) if header: khead, vhead = heade...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read_transforms_from_config'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children'...
def read_transforms_from_config(cp, section="transforms"): trans = [] for subsection in cp.get_subsections(section): name = cp.get_opt_tag(section, "name", subsection) t = transforms[name].from_config(cp, section, subsection) trans.append(t) return order_transforms(trans)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'samples_from_cli'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children'...
def samples_from_cli(self, opts, parameters=None, **kwargs): if parameters is None and opts.parameters is None: parameters = self.variable_args elif parameters is None: parameters = opts.parameters _, extra_actions = self.extra_args_parser() extra_args = [act.dest...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'data_from_cli'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'opt...
def data_from_cli(opts): gates = gates_from_cli(opts) psd_gates = psd_gates_from_cli(opts) instruments = opts.instruments if opts.instruments is not None else [] strain_dict = strain_from_cli_multi_ifos(opts, instruments, precision="double") if not opts.g...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9', '12']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
def sort(self, axis=-1, kind='quicksort', order=None): try: numpy.recarray.sort(self, axis=axis, kind=kind, order=order) except ValueError: if isinstance(order, list): raise ValueError("Cannot process more than one order field") self[:] = self[numpy.ar...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'emit_containers'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], '...
def emit_containers(self, containers, verbose=True): containers = sorted(containers, key=lambda c: c.get('name')) task_definition = { 'family': self.family, 'containerDefinitions': containers, 'volumes': self.volumes or [] } if verbose: ret...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_completions'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
def sort_completions(completions_gen): from knack.help import REQUIRED_TAG def _get_weight(val): priority = '' if val.display_meta and val.display_meta.startswith(REQUIRED_TAG): priority = ' ' return priority + val.text return sorted(completions_gen, key=_get_weight)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'attr_list'}, {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10']}; {'id': '4', 'type': 'default_parameter', 'children': ['...
def attr_list(label=None, kwargs=None, attributes=None): content = a_list(label, kwargs, attributes) if not content: return '' return ' [%s]' % content
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'mapping_items'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
def mapping_items(mapping, _iteritems=_compat.iteritems): if type(mapping) is dict: return iter(sorted(_iteritems(mapping))) return _iteritems(mapping)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'convert_tensor_to_probability_map'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier',...
def convert_tensor_to_probability_map(scope, operator, container): ''' This converter tries to convert a special operator 'TensorToProbabilityMap' into a sequence of some ONNX operators. Those operators are used to create a dictionary in which keys are class labels and values are the associated probabil...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'group_and_sort_nodes'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
def group_and_sort_nodes(self): if self.node_grouping and not self.node_order: if self.group_order == "alphabetically": self.nodes = [ n for n, d in sorted( self.graph.nodes(data=True), key=lambda...