sequence
stringlengths
492
15.9k
code
stringlengths
75
8.58k
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_keys; 3, parameters; 3, 4; 3, 5; 4, identifier:data_list; 5, default_parameter; 5, 6; 5, 7; 6, identifier:leading_columns; 7, identifier:LEADING_COLUMNS; 8, block; 8, 9; 8, 32; 8, 36; 8, 60; 9, expression_statement; 9, 10; 10, assignment; 1...
def get_keys(data_list, leading_columns=LEADING_COLUMNS): all_keys = set().union(*(list(d.keys()) for d in data_list)) leading_keys = [] for key in leading_columns: if key not in all_keys: continue leading_keys.append(key) all_keys.remove(key) return leading_keys + so...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:to_file; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:f; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sorted; 8, True; 9, default_parameter; 9, 10; 9, 11; 10, identifier:relativize; 11, True; 12, default_p...
def to_file(self, f, sorted=True, relativize=True, nl=None): if sys.hexversion >= 0x02030000: str_type = basestring else: str_type = str if nl is None: opts = 'w' else: opts = 'wb' if isinstance(f, str_type): f = file(f,...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_sorted_keys; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:keys; 6, block; 6, 7; 6, 11; 6, 31; 6, 76; 6, 105; 6, 125; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:sorted_keys; 10, list:[]; 11, if_stat...
def _sorted_keys(self, keys): sorted_keys = [] if ('epoch' in keys) and ('epoch' not in self.keys_ignored_): sorted_keys.append('epoch') for key in sorted(keys): if not ( (key in ('epoch', 'dur')) or (key in self.keys_ignored_) or ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:sort_values; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:expr; 5, identifier:by; 6, default_parameter; 6, 7; 6, 8; 7, identifier:ascending; 8, True; 9, block; 9, 10; 9, 23; 9, 42; 10, if_statement; 10, 11; 10, 17; 11, not_operator; 11, 12; 1...
def sort_values(expr, by, ascending=True): if not isinstance(by, list): by = [by, ] by = [it(expr) if inspect.isfunction(it) else it for it in by] return SortedCollectionExpr(expr, _sorted_fields=by, _ascending=ascending, _schema=expr._schema)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:reshuffle; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:expr; 5, default_parameter; 5, 6; 5, 7; 6, identifier:by; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sort; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, ide...
def reshuffle(expr, by=None, sort=None, ascending=True): by = by or RandomScalar() grouped = expr.groupby(by) if sort: grouped = grouped.sort_values(sort, ascending=ascending) return ReshuffledCollectionExpr(_input=grouped, _schema=expr._schema)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:cumsum; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:expr; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ascending; 10, True; 11, default_parameter; 11, 1...
def cumsum(expr, sort=None, ascending=True, unique=False, preceding=None, following=None): if expr._data_type == types.boolean: output_type = types.int64 else: output_type = expr._data_type return _cumulative_op(expr, CumSum, sort=sort, ascending=ascending, ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:cummax; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:expr; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ascending; 10, True; 11, default_parameter; 11, 1...
def cummax(expr, sort=None, ascending=True, unique=False, preceding=None, following=None): return _cumulative_op(expr, CumMax, sort=sort, ascending=ascending, unique=unique, preceding=preceding, following=following)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:cummin; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:expr; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ascending; 10, True; 11, default_parameter; 11, 1...
def cummin(expr, sort=None, ascending=True, unique=False, preceding=None, following=None): return _cumulative_op(expr, CumMin, sort=sort, ascending=ascending, unique=unique, preceding=preceding, following=following)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:cummean; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:expr; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ascending; 10, True; 11, default_parameter; 11, ...
def cummean(expr, sort=None, ascending=True, unique=False, preceding=None, following=None): data_type = _stats_type(expr) return _cumulative_op(expr, CumMean, sort=sort, ascending=ascending, unique=unique, preceding=preceding, following=following, ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:cummedian; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:expr; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ascending; 10, True; 11, default_parameter; 11...
def cummedian(expr, sort=None, ascending=True, unique=False, preceding=None, following=None): data_type = _stats_type(expr) return _cumulative_op(expr, CumMedian, sort=sort, ascending=ascending, unique=unique, preceding=preceding, following=follo...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:cumcount; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:expr; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ascending; 10, True; 11, default_parameter; 11,...
def cumcount(expr, sort=None, ascending=True, unique=False, preceding=None, following=None): data_type = types.int64 return _cumulative_op(expr, CumCount, sort=sort, ascending=ascending, unique=unique, preceding=preceding, following=following, dat...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:cumstd; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:expr; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ascending; 10, True; 11, default_parameter; 11, 1...
def cumstd(expr, sort=None, ascending=True, unique=False, preceding=None, following=None): data_type = _stats_type(expr) return _cumulative_op(expr, CumStd, sort=sort, ascending=ascending, unique=unique, preceding=preceding, following=following, dat...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:nth_value; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:expr; 5, identifier:nth; 6, default_parameter; 6, 7; 6, 8; 7, identifier:skip_nulls; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:sort; 11, None; 12, defaul...
def nth_value(expr, nth, skip_nulls=False, sort=None, ascending=True): return _cumulative_op(expr, NthValue, data_type=expr._data_type, sort=sort, ascending=ascending, _nth=nth, _skip_nulls=skip_nulls)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:rank; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:expr; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ascending; 10, True; 11, block; 11, 12; 12, return_statement; 12, 13; 13...
def rank(expr, sort=None, ascending=True): return _rank_op(expr, Rank, types.int64, sort=sort, ascending=ascending)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:dense_rank; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:expr; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ascending; 10, True; 11, block; 11, 12; 12, return_statement; 12, ...
def dense_rank(expr, sort=None, ascending=True): return _rank_op(expr, DenseRank, types.int64, sort=sort, ascending=ascending)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:percent_rank; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:expr; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ascending; 10, True; 11, block; 11, 12; 12, return_statement; 12...
def percent_rank(expr, sort=None, ascending=True): return _rank_op(expr, PercentRank, types.float64, sort=sort, ascending=ascending)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:row_number; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:expr; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ascending; 10, True; 11, block; 11, 12; 12, return_statement; 12, ...
def row_number(expr, sort=None, ascending=True): return _rank_op(expr, RowNumber, types.int64, sort=sort, ascending=ascending)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:qcut; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:expr; 5, identifier:bins; 6, default_parameter; 6, 7; 6, 8; 7, identifier:labels; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:sort; 11, None; 12, default_parame...
def qcut(expr, bins, labels=False, sort=None, ascending=True): if labels is None or labels: raise NotImplementedError('Showing bins or customizing labels not supported') return _rank_op(expr, QCut, types.int64, sort=sort, ascending=ascending, _bins=bins)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:cume_dist; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:expr; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ascending; 10, True; 11, block; 11, 12; 12, return_statement; 12, 1...
def cume_dist(expr, sort=None, ascending=True): return _rank_op(expr, CumeDist, types.float64, sort=sort, ascending=ascending)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:lag; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:expr; 5, identifier:offset; 6, default_parameter; 6, 7; 6, 8; 7, identifier:default; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:sort; 11, None; 12, default_param...
def lag(expr, offset, default=None, sort=None, ascending=True): return _shift_op(expr, Lag, offset, default=default, sort=sort, ascending=ascending)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:lead; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:expr; 5, identifier:offset; 6, default_parameter; 6, 7; 6, 8; 7, identifier:default; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:sort; 11, None; 12, default_para...
def lead(expr, offset, default=None, sort=None, ascending=True): return _shift_op(expr, Lead, offset, default=default, sort=sort, ascending=ascending)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:value_counts; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:expr; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ascending; 10, False; 11, default_parameter; 11, 12; 11, ...
def value_counts(expr, sort=True, ascending=False, dropna=False): names = [expr.name, 'count'] typos = [expr.dtype, types.int64] return ValueCounts(_input=expr, _schema=Schema.from_lists(names, typos), _sort=sort, _ascending=ascending, _dropna=dropna)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:last; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:limit; 7, integer:1; 8, dictionary_splat_pattern; 8, 9; 9, identifier:kwargs; 10, block; 10, 11; 11, return_statement; 11, 12; 12, call;...
def last(self, limit=1, **kwargs): return self.collection_instance( self.db_adapter( db_name=kwargs.get('db'), role=kwargs.get('role', 'replica') ).select( where='created_at IS NOT NULL', order='created_at DESC',...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:_compile_itemsort; 3, parameters; 4, block; 4, 5; 4, 7; 4, 16; 4, 27; 4, 38; 4, 50; 4, 60; 4, 79; 4, 106; 5, expression_statement; 5, 6; 6, string:'''return sort function of mappings'''; 7, function_definition; 7, 8; 7, 9; 7, 11; 8, function_na...
def _compile_itemsort(): '''return sort function of mappings''' def is_extra(key_): return key_ is Extra def is_remove(key_): return isinstance(key_, Remove) def is_marker(key_): return isinstance(key_, Marker) def is_type(key_): return inspect.isclass(key_) def i...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_compile_dict; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:schema; 6, block; 6, 7; 6, 19; 6, 23; 6, 27; 6, 83; 6, 308; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:base_validate; 10, call; 10, 11; 10...
def _compile_dict(self, schema): base_validate = self._compile_mapping( schema, invalid_msg='dictionary value') groups_of_exclusion = {} groups_of_inclusion = {} for node in schema: if isinstance(node, Exclusive): g = groups_of_exclusion.setdefault...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:to_list; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:length; 6, block; 6, 7; 6, 37; 6, 57; 6, 72; 6, 115; 7, if_statement; 7, 8; 7, 11; 8, comparison_operator:is; 8, 9; 8, 10; 9, identifier:length; 10, None; 11, block; 11, 12; ...
def to_list(self, length): if length is not None: if not isinstance(length, int): raise TypeError('length must be an int, not %r' % length) elif length < 0: raise ValueError('length must be non-negative') if self._query_flags() & _QUERY_OPTIONS['ta...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:find; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:args; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 24; 9, 37; 10, expression_statement; 10, 11; 11, assignment...
def find(self, *args, **kwargs): cursor = self.delegate.find(*args, **kwargs) grid_out_cursor = create_class_with_framework( AgnosticGridOutCursor, self._framework, self.__module__) return grid_out_cursor(cursor, self.collection)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_serial_poller; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 199; 6, while_statement; 6, 7; 6, 8; 7, True; 8, block; 8, 9; 8, 23; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:_next; 12, call; 12,...
def _serial_poller(self): while True: _next = dict(self._poller.poll(POLLING_FREQUENCY_MS)) if self._halt_read_file.fileno() in _next: log.debug("Poller [{}]: halt".format(hash(self))) self._halt_read_file.read() break elif self...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:enqueue_at; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 9; 4, identifier:self; 5, identifier:scheduled_time; 6, identifier:func; 7, list_splat_pattern; 7, 8; 8, identifier:args; 9, dictionary_splat_pattern; 9, 10; 10, identifier:kwargs; 11, bloc...
def enqueue_at(self, scheduled_time, func, *args, **kwargs): timeout = kwargs.pop('timeout', None) job_id = kwargs.pop('job_id', None) job_ttl = kwargs.pop('job_ttl', None) job_result_ttl = kwargs.pop('job_result_ttl', None) job_description = kwargs.pop('job_description', None) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_getMostActiveCells; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 12; 5, 27; 5, 40; 5, 57; 5, 68; 5, 104; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:poolingActivation; 9, attribute; 9, 10; 9, 11; 10, ...
def _getMostActiveCells(self): poolingActivation = self._poolingActivation nonZeroCells = numpy.argwhere(poolingActivation > 0)[:,0] poolingActivationSubset = poolingActivation[nonZeroCells] + \ self._poolingActivation_tieBreaker[nonZeroCells] potentialUnionSDR = nonZeroCel...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:printNetwork; 3, parameters; 3, 4; 4, identifier:network; 5, block; 5, 6; 5, 19; 6, print_statement; 6, 7; 6, 8; 6, 18; 7, string:"The network has"; 8, call; 8, 9; 8, 10; 9, identifier:len; 10, argument_list; 10, 11; 11, call; 11, 12; 11, 17; 1...
def printNetwork(network): print "The network has",len(network.regions.values()),"regions" for p in range(network.getMaxPhase()): print "=== Phase",p for region in network.regions.values(): if network.getPhases(region.name)[0] == p: print " ",region.name
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:argmaxMulti; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:a; 5, identifier:groupKeys; 6, default_parameter; 6, 7; 6, 8; 7, identifier:assumeSorted; 8, False; 9, block; 9, 10; 9, 38; 9, 56; 9, 68; 9, 85; 9, 97; 10, if_statement; 10, 11; 10, 13...
def argmaxMulti(a, groupKeys, assumeSorted=False): if not assumeSorted: sorter = np.argsort(groupKeys, kind="mergesort") a = a[sorter] groupKeys = groupKeys[sorter] _, indices, lengths = np.unique(groupKeys, return_index=True, return_counts=True) maxValues = np.maximu...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:getAllCellsInColumns; 3, parameters; 3, 4; 3, 5; 4, identifier:columns; 5, identifier:cellsPerColumn; 6, block; 6, 7; 7, return_statement; 7, 8; 8, call; 8, 9; 8, 34; 9, attribute; 9, 10; 9, 33; 10, parenthesized_expression; 10, 11; 11, binary_...
def getAllCellsInColumns(columns, cellsPerColumn): return ((columns * cellsPerColumn).reshape((-1, 1)) + np.arange(cellsPerColumn, dtype="uint32")).flatten()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:shuffle_sparse_matrix_and_labels; 3, parameters; 3, 4; 3, 5; 4, identifier:matrix; 5, identifier:labels; 6, block; 6, 7; 6, 9; 6, 17; 6, 27; 6, 36; 6, 45; 6, 54; 6, 56; 7, print_statement; 7, 8; 8, string:"Shuffling data"; 9, expression_stateme...
def shuffle_sparse_matrix_and_labels(matrix, labels): print "Shuffling data" new_matrix = matrix.toDense() rng_state = numpy.random.get_state() numpy.random.shuffle(new_matrix) numpy.random.set_state(rng_state) numpy.random.shuffle(labels) print "Data shuffled" return SM32(new_matrix), numpy.asarray(lab...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:compute; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:sensorToBodyByColumn; 6, identifier:sensorToSpecificObjectByColumn; 7, block; 7, 8; 7, 22; 7, 28; 7, 103; 7, 121; 7, 135; 7, 150; 8, expression_statement; 8, 9; 9, assi...
def compute(self, sensorToBodyByColumn, sensorToSpecificObjectByColumn): votesByCell = np.zeros(self.cellCount, dtype="int") self.activeSegmentsByColumn = [] for (connections, activeSensorToBodyCells, activeSensorToSpecificObjectCells) in zip(self.connectionsByColumn, ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:metricCompute; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:sensorToBody; 6, identifier:bodyToSpecificObject; 7, block; 7, 8; 7, 25; 7, 40; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:overlap...
def metricCompute(self, sensorToBody, bodyToSpecificObject): overlaps = self.metricConnections.computeActivity({ "bodyToSpecificObject": bodyToSpecificObject, "sensorToBody": sensorToBody, }) self.activeMetricSegments = np.where(overlaps >= 2)[0] self.activeCells = np.unique( self.metr...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:compute; 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:feedforwardInput; 7, tuple; 8, default_parameter; 8, 9; 8, 10; 9, identifier:lateralInputs; 10, tuple; 11, defau...
def compute(self, feedforwardInput=(), lateralInputs=(), feedforwardGrowthCandidates=None, learn=True, predictedInput = None,): if feedforwardGrowthCandidates is None: feedforwardGrowthCandidates = feedforwardInput if not learn: self._computeInferenceMode(feedforwardInput...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:_learn; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 3, 13; 4, identifier:permanences; 5, identifier:rng; 6, identifier:activeCells; 7, identifier:activeInput; 8, identifier:growthCandidateInput; 9, identifier:sample...
def _learn( permanences, rng, activeCells, activeInput, growthCandidateInput, sampleSize, initialPermanence, permanenceIncrement, permanenceDecrement, connectedPermanence): permanences.incrementNonZerosOnOuter( activeCells, activeInput, permanenceIncrement) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:compute; 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:deltaLocation; 7, tuple; 8, default_parameter; 8, 9; 8, 10; 9, identifier:newLocation; 10, tuple; 11, default_pa...
def compute(self, deltaLocation=(), newLocation=(), featureLocationInput=(), featureLocationGrowthCandidates=(), learn=True): prevActiveCells = self.activeCells self.activeDeltaSegments = np.where( (self.internalConnections.computeActivity( prevActiveCells, self.connect...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:getmerge; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:self; 5, identifier:path; 6, identifier:dst; 7, default_parameter; 7, 8; 7, 9; 8, identifier:newline; 9, False; 10, default_parameter; 10, 11; 10, 12; 11, identifier:check_c...
def getmerge(self, path, dst, newline=False, check_crc=False): ''' Get all the files in the directories that match the source file pattern and merge and sort them to only one file on local fs. :param paths: Directory containing files that will be merged :type paths: string ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:countByValue; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, return_statement; 6, 7; 7, call; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:transform; 11, argument_list; 11, 12; 12, lambda; 12, 13; 12, ...
def countByValue(self): return self.transform( lambda rdd: self._context._context.parallelize( rdd.countByValue().items()))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_contiguous_offsets; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:offsets; 6, block; 6, 7; 6, 13; 6, 41; 7, expression_statement; 7, 8; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:offsets; 11, identifier:sor...
def _contiguous_offsets(self, offsets): offsets.sort() for i in range(len(offsets) - 1): assert offsets[i] + 1 == offsets[i + 1], \ "Offsets not contiguous: %s" % (offsets,) return offsets
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_collapse; 3, parameters; 3, 4; 4, identifier:intervals; 5, block; 5, 6; 5, 10; 5, 65; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:span; 9, None; 10, for_statement; 10, 11; 10, 14; 10, 15; 11, pattern_list; 11, 12; 1...
def _collapse(intervals): span = None for start, stop in intervals: if span is None: span = _Interval(start, stop) elif start <= span.stop < stop: span = _Interval(span.start, stop) elif start > span.stop: yield span span = _Interval(start,...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:remove; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:index; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:hash; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, ide...
def remove(self, index=None, hash=None, keepSorted=True): if index is not None: clibrebound.reb_remove(byref(self), index, keepSorted) if hash is not None: hash_types = c_uint32, c_uint, c_ulong PY3 = sys.version_info[0] == 3 if PY3: string...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:particles; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 18; 5, 41; 5, 47; 5, 76; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:sim; 9, attribute; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, i...
def particles(self): sim = self._sim.contents ps = [] if self.testparticle>=0: N = 1 else: N = sim.N-sim.N_var ParticleList = Particle*N ps = ParticleList.from_address(ctypes.addressof(sim._particles.contents)+self.index*ctypes.sizeof(Particle)) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:filter_queryset; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:request; 6, identifier:queryset; 7, identifier:view; 8, block; 8, 9; 8, 17; 8, 28; 8, 39; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 14; ...
def filter_queryset(self, request, queryset, view): self.ordering_param = view.SORT ordering = self.get_ordering(request, queryset, view) if ordering: return queryset.order_by(*ordering) return queryset
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_ordering; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:request; 6, identifier:queryset; 7, identifier:view; 8, block; 8, 9; 8, 20; 8, 62; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identi...
def get_ordering(self, request, queryset, view): params = view.get_request_feature(view.SORT) if params: fields = [param.strip() for param in params] valid_ordering, invalid_ordering = self.remove_invalid_fields( queryset, fields, view ) if...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:remove_invalid_fields; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:queryset; 6, identifier:fields; 7, identifier:view; 8, block; 8, 9; 8, 13; 8, 17; 8, 76; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10,...
def remove_invalid_fields(self, queryset, fields, view): valid_orderings = [] invalid_orderings = [] for term in fields: stripped_term = term.lstrip('-') reverse_sort_term = '' if len(stripped_term) is len(term) else '-' ordering = self.ordering_for(stripped_t...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 1, 17; 2, function_name:_format_dataframe; 3, parameters; 3, 4; 3, 10; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:df; 6, type; 6, 7; 7, attribute; 7, 8; 7, 9; 8, identifier:pd; 9, identifier:DataFrame; 10, default_parameter; 10, 11; 10, 12; 11, identifier:n...
def _format_dataframe( df: pd.DataFrame, nautical_units=True ) -> pd.DataFrame: if "callsign" in df.columns and df.callsign.dtype == object: df.callsign = df.callsign.str.strip() if nautical_units: df.altitude = df.altitude / 0.3048 if "geoaltitude" in df....
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:find_package_indexes_in_dir; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:simple_dir; 6, block; 6, 7; 6, 26; 6, 51; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:packages; 10, call; 10, 11; 10, 12; 11,...
def find_package_indexes_in_dir(self, simple_dir): packages = sorted( { canonicalize_name(x) for x in os.listdir(simple_dir) } ) packages = [x for x in packages if os.path.isdir(os.path.join(simple_dir, x))] return packages
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:factorize; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 11; 3, 14; 4, identifier:train; 5, identifier:test; 6, identifier:features; 7, default_parameter; 7, 8; 7, 9; 8, identifier:na_value; 9, unary_operator:-; 9, 10; 10, integer:9999; 11, defaul...
def factorize(train, test, features, na_value=-9999, full=False, sort=True): for column in features: if full: vs = pd.concat([train[column], test[column]]) labels, indexer = pd.factorize(vs, sort=sort) else: labels, indexer = pd.factorize(train[column], sort=sort)...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:preferred_ordinal; 3, parameters; 3, 4; 3, 5; 4, identifier:cls; 5, identifier:attr_name; 6, block; 6, 7; 6, 16; 6, 45; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:attr_name; 10, call; 10, 11; 10, 14; 11, attribute;...
def preferred_ordinal(cls, attr_name): attr_name = cls.map(attr_name) if attr_name in cls.preferred_order: ordinal = cls.preferred_order.index(attr_name) else: ordinal = len(cls.preferred_order) return (ordinal, attr_name)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:patience_sort; 3, parameters; 3, 4; 4, identifier:xs; 5, block; 5, 6; 5, 8; 5, 14; 6, expression_statement; 6, 7; 7, string:'''Patience sort an iterable, xs. This function generates a series of pairs (x, pile), where "pile" is the 0-bas...
def patience_sort(xs): '''Patience sort an iterable, xs. This function generates a series of pairs (x, pile), where "pile" is the 0-based index of the pile "x" should be placed on top of. Elements of "xs" must be less-than comparable. ''' pile_tops = list() for x in xs: pile = bisect...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort; 3, parameters; 3, 4; 4, identifier:args; 5, block; 5, 6; 5, 15; 5, 31; 5, 42; 5, 61; 5, 66; 5, 80; 5, 90; 5, 98; 5, 169; 5, 189; 5, 201; 5, 207; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:p; 9, call; 9, 10; 9,...
def sort(args): p = OptionParser(sort.__doc__) p.add_option("--sizes", default=False, action="store_true", help="Sort by decreasing size [default: %default]") opts, args = p.parse_args(args) if len(args) != 1: sys.exit(p.print_help()) fastafile, = args sortedfastafile = ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:posmap; 3, parameters; 3, 4; 4, identifier:args; 5, block; 5, 6; 5, 15; 5, 26; 5, 45; 5, 52; 5, 62; 5, 68; 5, 85; 5, 91; 5, 100; 5, 106; 5, 119; 5, 125; 5, 146; 5, 152; 5, 172; 5, 178; 5, 197; 5, 203; 5, 209; 5, 238; 5, 244; 6, expression_state...
def posmap(args): p = OptionParser(posmap.__doc__) opts, args = p.parse_args(args) if len(args) != 3: sys.exit(p.print_help()) frgscffile, fastafile, scf = args cmd = "faOneRecord {0} {1}".format(fastafile, scf) scffastafile = scf + ".fasta" if not op.exists(scffastafile): sh...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:shred; 3, parameters; 3, 4; 4, identifier:args; 5, block; 5, 6; 5, 15; 5, 26; 5, 46; 5, 51; 5, 58; 5, 64; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:p; 9, call; 9, 10; 9, 11; 10, identifier:OptionParser; 11, argumen...
def shred(args): p = OptionParser(shred.__doc__) opts, args = p.parse_args(args) if len(args) != 1: sys.exit(not p.print_help()) s, = args u = UnitigLayout(s) u.shred() u.print_to_file(inplace=True)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:index; 3, parameters; 3, 4; 4, identifier:args; 5, block; 5, 6; 5, 15; 5, 26; 5, 45; 5, 50; 5, 56; 5, 65; 5, 82; 5, 88; 5, 97; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:p; 9, call; 9, 10; 9, 11; 10, identifier:Opti...
def index(args): p = OptionParser(index.__doc__) opts, args = p.parse_args(args) if len(args) != 1: sys.exit(p.print_help()) frgscffile, = args gzfile = frgscffile + ".gz" cmd = "bgzip -c {0}".format(frgscffile) if not op.exists(gzfile): sh(cmd, outfile=gzfile) tbifile = ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort; 3, parameters; 3, 4; 4, identifier:args; 5, block; 5, 6; 5, 12; 5, 21; 5, 37; 5, 56; 5, 62; 5, 68; 5, 75; 5, 86; 5, 106; 5, 111; 5, 117; 5, 157; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:valid_sort_methods; 9...
def sort(args): valid_sort_methods = ("unix", "topo") p = OptionParser(sort.__doc__) p.add_option("--method", default="unix", choices=valid_sort_methods, help="Specify sort method [default: %default]") p.add_option("-i", dest="inplace", default=False, action="store_true", ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:sort_layout; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:thread; 5, identifier:listfile; 6, default_parameter; 6, 7; 6, 8; 7, identifier:column; 8, integer:0; 9, block; 9, 10; 9, 17; 9, 31; 9, 37; 9, 45; 9, 58; 9, 62; 9, 68; 9, 104; 9, 114; ...
def sort_layout(thread, listfile, column=0): from jcvi.formats.base import DictFile outfile = listfile.rsplit(".", 1)[0] + ".sorted.list" threadorder = thread.order fw = open(outfile, "w") lt = DictFile(listfile, keypos=column, valuepos=None) threaded = [] imported = set() for t in threa...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:fromgroups; 3, parameters; 3, 4; 4, identifier:args; 5, block; 5, 6; 5, 13; 5, 22; 5, 33; 5, 53; 5, 59; 5, 67; 5, 78; 5, 85; 5, 102; 6, import_from_statement; 6, 7; 6, 11; 7, dotted_name; 7, 8; 7, 9; 7, 10; 8, identifier:jcvi; 9, identifier:for...
def fromgroups(args): from jcvi.formats.bed import Bed p = OptionParser(fromgroups.__doc__) opts, args = p.parse_args(args) if len(args) < 2: sys.exit(not p.print_help()) groupsfile = args[0] bedfiles = args[1:] beds = [Bed(x) for x in bedfiles] fp = open(groupsfile) groups =...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:merge_paths; 3, parameters; 3, 4; 3, 5; 4, identifier:paths; 5, default_parameter; 5, 6; 5, 7; 6, identifier:weights; 7, None; 8, block; 8, 9; 8, 19; 8, 26; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:G; 12, c...
def merge_paths(paths, weights=None): G = make_paths(paths, weights=weights) G = reduce_paths(G) return G
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:build; 3, parameters; 3, 4; 4, identifier:args; 5, block; 5, 6; 5, 13; 5, 20; 5, 27; 5, 36; 5, 52; 5, 63; 5, 83; 5, 90; 5, 106; 5, 115; 5, 123; 5, 132; 5, 138; 5, 147; 5, 153; 5, 163; 5, 168; 5, 174; 6, import_from_statement; 6, 7; 6, 11; 7, do...
def build(args): from jcvi.apps.cdhit import deduplicate from jcvi.apps.vecscreen import mask from jcvi.formats.fasta import sort p = OptionParser(build.__doc__) p.add_option("--nodedup", default=False, action="store_true", help="Do not deduplicate [default: deduplicate]") opts,...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort; 3, parameters; 3, 4; 4, identifier:args; 5, block; 5, 6; 5, 11; 6, import_statement; 6, 7; 7, dotted_name; 7, 8; 7, 9; 7, 10; 8, identifier:jcvi; 9, identifier:formats; 10, identifier:blast; 11, return_statement; 11, 12; 12, call; 12, 13;...
def sort(args): import jcvi.formats.blast return jcvi.formats.blast.sort(args + ["--coords"])
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:coverage; 3, parameters; 3, 4; 4, identifier:args; 5, block; 5, 6; 5, 15; 5, 34; 5, 50; 5, 56; 5, 67; 5, 87; 5, 93; 5, 99; 5, 127; 5, 139; 5, 148; 5, 158; 5, 215; 5, 221; 5, 236; 5, 243; 5, 253; 5, 283; 6, expression_statement; 6, 7; 7, assignm...
def coverage(args): p = OptionParser(coverage.__doc__) p.add_option("--format", default="bigwig", choices=("bedgraph", "bigwig", "coverage"), help="Output format") p.add_option("--nosort", default=False, action="store_true", help="Do not sort BAM") p.se...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_number_finder; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:s; 5, identifier:regex; 6, identifier:numconv; 7, block; 7, 8; 7, 17; 7, 30; 7, 37; 7, 64; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:s; 11, call; 11...
def _number_finder(s, regex, numconv): s = regex.split(s) if len(s) == 1: return tuple(s) s = remove_empty(s) for i in range(len(s)): try: s[i] = numconv(s[i]) except ValueError: pass if not isinstance(s[0], six.string_types): return [''] + s ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:index_natsorted; 3, parameters; 3, 4; 3, 5; 3, 11; 3, 14; 3, 17; 4, identifier:seq; 5, default_parameter; 5, 6; 5, 7; 6, identifier:key; 7, lambda; 7, 8; 7, 10; 8, lambda_parameters; 8, 9; 9, identifier:x; 10, identifier:x; 11, default_paramet...
def index_natsorted(seq, key=lambda x: x, number_type=float, signed=True, exp=True): from operator import itemgetter item1 = itemgetter(1) index_seq_pair = [[x, key(y)] for x, y in zip(range(len(seq)), seq)] index_seq_pair.sort(key=lambda x: natsort_key(item1(x), ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort; 3, parameters; 3, 4; 4, identifier:args; 5, block; 5, 6; 5, 15; 5, 35; 5, 54; 5, 70; 5, 79; 5, 85; 5, 96; 5, 116; 5, 121; 5, 127; 5, 137; 5, 143; 5, 182; 5, 192; 5, 196; 5, 212; 5, 221; 5, 232; 5, 246; 6, expression_statement; 6, 7; 7, as...
def sort(args): p = OptionParser(sort.__doc__) p.add_option("-i", "--inplace", dest="inplace", default=False, action="store_true", help="Sort bed file in place [default: %default]") p.add_option("-u", dest="unique", default=False, action="store_true", help="Un...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:by_image_seq; 3, parameters; 3, 4; 3, 5; 4, identifier:blocks; 5, identifier:image_seq; 6, block; 6, 7; 7, return_statement; 7, 8; 8, call; 8, 9; 8, 10; 9, identifier:list; 10, argument_list; 10, 11; 11, call; 11, 12; 11, 13; 12, identifier:fil...
def by_image_seq(blocks, image_seq): return list(filter(lambda block: blocks[block].ec_hdr.image_seq == image_seq, blocks))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:by_vol_id; 3, parameters; 3, 4; 3, 5; 4, identifier:blocks; 5, default_parameter; 5, 6; 5, 7; 6, identifier:slist; 7, None; 8, block; 8, 9; 8, 13; 8, 76; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:vol_blocks;...
def by_vol_id(blocks, slist=None): vol_blocks = {} for i in blocks: if slist and i not in slist: continue elif not blocks[i].is_valid: continue if blocks[i].vid_hdr.vol_id not in vol_blocks: vol_blocks[blocks[i].vid_hdr.vol_id] = [] vol_blocks[...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:by_type; 3, parameters; 3, 4; 3, 5; 4, identifier:blocks; 5, default_parameter; 5, 6; 5, 7; 6, identifier:slist; 7, None; 8, block; 8, 9; 8, 13; 8, 17; 8, 21; 8, 25; 8, 100; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, id...
def by_type(blocks, slist=None): layout = [] data = [] int_vol = [] unknown = [] for i in blocks: if slist and i not in slist: continue if blocks[i].is_vtbl and blocks[i].is_valid: layout.append(i) elif blocks[i].is_internal_vol and blocks[i].is_valid:...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:group_pairs; 3, parameters; 3, 4; 3, 5; 4, identifier:blocks; 5, identifier:layout_blocks_list; 6, block; 6, 7; 6, 11; 6, 48; 6, 63; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:image_dict; 10, dictionary; 11, for_st...
def group_pairs(blocks, layout_blocks_list): image_dict={} for block_id in layout_blocks_list: image_seq=blocks[block_id].ec_hdr.image_seq if image_seq not in image_dict: image_dict[image_seq]=[block_id] else: image_dict[image_seq].append(block_id) log(group_p...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:read_cBpack; 3, parameters; 3, 4; 4, identifier:filename; 5, block; 5, 6; 5, 32; 5, 38; 5, 72; 6, with_statement; 6, 7; 6, 19; 7, with_clause; 7, 8; 8, with_item; 8, 9; 9, as_pattern; 9, 10; 9, 17; 10, call; 10, 11; 10, 14; 11, attribute; 11, 1...
def read_cBpack(filename): with gzip.open(filename, 'rb') as infile: data = msgpack.load(infile, raw=False) header = data[0] if ( not isinstance(header, dict) or header.get('format') != 'cB' or header.get('version') != 1 ): raise ValueError("Unexpected header: %r" % heade...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:addDiscreteOutcomeConstantMean; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:distribution; 5, identifier:x; 6, identifier:p; 7, default_parameter; 7, 8; 7, 9; 8, identifier:sort; 9, False; 10, block; 10, 11; 10, 13; 10, 37; 10, 54; 10,...
def addDiscreteOutcomeConstantMean(distribution, x, p, sort = False): ''' Adds a discrete outcome of x with probability p to an existing distribution, holding constant the relative probabilities of other outcomes and overall mean. Parameters ---------- distribution : [np.array] Two eleme...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:runStickyEregressionsInStata; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:infile_name; 5, identifier:interval_size; 6, identifier:meas_err; 7, identifier:sticky; 8, identifier:all_specs; 9, identifier:stata_exe; 10, block;...
def runStickyEregressionsInStata(infile_name,interval_size,meas_err,sticky,all_specs,stata_exe): ''' Runs regressions for the main tables of the StickyC paper in Stata and produces a LaTeX table with results for one "panel". Running in Stata allows production of the KP-statistic, for which there is curr...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:capability_functions; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:fn; 6, block; 6, 7; 6, 18; 6, 22; 6, 66; 6, 80; 6, 91; 7, if_statement; 7, 8; 7, 9; 8, identifier:_debug; 9, block; 9, 10; 10, expression_statement; 10, 11; 11, ...
def capability_functions(self, fn): if _debug: Collector._debug("capability_functions %r", fn) fns = [] for cls in self.capabilities: xfn = getattr(cls, fn, None) if _debug: Collector._debug(" - cls, xfn: %r, %r", cls, xfn) if xfn: fns.appen...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:add; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:items; 7, block; 7, 8; 7, 35; 8, for_statement; 8, 9; 8, 10; 8, 11; 9, identifier:item; 10, identifier:items; 11, block; 11, 12; 11, 21; 11, 27; 12, ...
def add(self, *items): for item in items: self.unsorted.append(item) key = item[0] self.index[key] = item return self
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 22; 5, 129; 5, 137; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:sorted; 11, call; 11, 12; 11, ...
def sort(self): self.sorted = list() self.pushed = set() for item in self.unsorted: popped = [] self.push(item) while len(self.stack): try: top = self.top() ref = next(top[1]) refd = s...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:push; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:item; 6, block; 6, 7; 6, 15; 6, 26; 6, 35; 7, if_statement; 7, 8; 7, 13; 8, comparison_operator:in; 8, 9; 8, 10; 9, identifier:item; 10, attribute; 10, 11; 10, 12; 11, identifie...
def push(self, item): if item in self.pushed: return frame = (item, iter(item[1])) self.stack.append(frame) self.pushed.add(item)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:content; 6, block; 6, 7; 6, 13; 6, 39; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:v; 10, attribute; 10, 11; 10, 12; 11, identifier:content; 12, ide...
def sort(self, content): v = content.value if isinstance(v, Object): md = v.__metadata__ md.ordering = self.ordering(content.real) return self
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:alerts; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:alert_level; 7, string:'High'; 8, block; 8, 9; 8, 21; 8, 29; 8, 65; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, ident...
def alerts(self, alert_level='High'): alerts = self.zap.core.alerts() alert_level_value = self.alert_levels[alert_level] alerts = sorted((a for a in alerts if self.alert_levels[a['risk']] >= alert_level_value), key=lambda k: self.alert_levels[k['risk']], reverse=True) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:assortativity_bin; 3, parameters; 3, 4; 3, 5; 4, identifier:CIJ; 5, default_parameter; 5, 6; 5, 7; 6, identifier:flag; 7, integer:0; 8, block; 8, 9; 8, 11; 8, 168; 8, 181; 8, 202; 8, 222; 8, 234; 9, expression_statement; 9, 10; 10, string:''' ...
def assortativity_bin(CIJ, flag=0): ''' The assortativity coefficient is a correlation coefficient between the degrees of all nodes on two opposite ends of a link. A positive assortativity coefficient indicates that nodes tend to link to other nodes with the same or similar degree. Parameters ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_coords; 3, parameters; 3, 4; 4, identifier:coord; 5, block; 5, 6; 5, 9; 5, 27; 5, 38; 6, import_statement; 6, 7; 7, dotted_name; 7, 8; 8, identifier:iris; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:order...
def sort_coords(coord): import iris order = {'T': -2, 'Z': -1, 'X': 1, 'Y': 2} axis = iris.util.guess_coord_axis(coord) return (order.get(axis, 0), coord and coord.name())
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:separate_groups; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:groups; 5, identifier:key; 6, identifier:total; 7, block; 7, 8; 7, 21; 7, 33; 7, 41; 7, 56; 7, 71; 7, 77; 7, 83; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 13; 10, pat...
def separate_groups(groups, key, total): optimum, extra = compute_optimum(len(groups), total) over_loaded, under_loaded, optimal = _smart_separate_groups(groups, key, total) if not extra: return over_loaded, under_loaded potential_under_loaded = [ group for group in optimal if ke...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:zrange; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 3, 14; 4, identifier:self; 5, identifier:name; 6, identifier:start; 7, identifier:end; 8, default_parameter; 8, 9; 8, 10; 9, identifier:desc; 10, False; 11, default_parameter; 11, 12;...
async def zrange(self, name, start, end, desc=False, withscores=False, score_cast_func=float): if desc: return await self.zrevrange(name, start, end, withscores, score_cast_func) pieces = ['ZRANGE', name, start, end] if wit...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:zremrangebyscore; 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, await; 10, 11; 11, call; 11, 12; 11, 15; 12, attribute; 12, 1...
async def zremrangebyscore(self, name, min, max): return await self.execute_command('ZREMRANGEBYSCORE', name, min, max)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 33; 2, function_name:georadius; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 3, 27; 3, 30; 4, identifier:self; 5, identifier:name; 6, identifier:longitude; 7, identifier:latitude; 8, identifier:radius; 9, default_parameter;...
async def georadius(self, name, longitude, latitude, radius, unit=None, withdist=False, withcoord=False, withhash=False, count=None, sort=None, store=None, store_dist=None): return await self._georadiusgeneric('GEORADIUS', ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 32; 2, function_name:georadiusbymember; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 4, identifier:self; 5, identifier:name; 6, identifier:member; 7, identifier:radius; 8, default_parameter; 8, 9; 8, 10; 9, identifi...
async def georadiusbymember(self, name, member, radius, unit=None, withdist=False, withcoord=False, withhash=False, count=None, sort=None, store=None, store_dist=None): return await self._georadiusgeneric('GEORADIUSBYMEMBER', ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 32; 2, function_name:search; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:page; 7, integer:0; 8, default_parameter; 8, 9; 8, 10; 9, identifier:per_page; 10, in...
def search(self, page=0, per_page=50, sort=None, q=None, include_totals=True, fields=None, from_param=None, take=None, include_fields=True): params = { 'per_page': per_page, 'page': page, 'include_totals': str(include_totals).lower(), ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 32; 2, function_name:list; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:page; 7, integer:0; 8, default_parameter; 8, 9; 8, 10; 9, identifier:per_page; 10, inte...
def list(self, page=0, per_page=25, sort=None, connection=None, q=None, search_engine=None, include_totals=True, fields=None, include_fields=True): params = { 'per_page': per_page, 'page': page, 'include_totals': str(include_totals).lower(), ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:get_log_events; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, identifier:user_id; 6, default_parameter; 6, 7; 6, 8; 7, identifier:page; 8, integer:0; 9, default_parameter; 9, 10; 9, 11; 10, identifier:per_page; 11...
def get_log_events(self, user_id, page=0, per_page=50, sort=None, include_totals=False): params = { 'per_page': per_page, 'page': page, 'include_totals': str(include_totals).lower(), 'sort': sort } url = self._url('{}/logs'.f...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:get_activities; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:before; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:after; 10, None; 11, default_parameter; 11, 12; 11, 1...
def get_activities(self, before=None, after=None, limit=None): if before: before = self._utc_datetime_to_epoch(before) if after: after = self._utc_datetime_to_epoch(after) params = dict(before=before, after=after) result_fetcher = functools.partial(self.protocol.g...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 33; 2, function_name:get_segment_leaderboard; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 3, 27; 3, 30; 4, identifier:self; 5, identifier:segment_id; 6, default_parameter; 6, 7; 6, 8; 7, identifier:gender; 8, None; 9, default_paramete...
def get_segment_leaderboard(self, segment_id, gender=None, age_group=None, weight_class=None, following=None, club_id=None, timeframe=None, top_results_limit=None, page=None, context_entries = None): params = {} if gender is not None: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:get_segment_efforts; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, identifier:segment_id; 6, default_parameter; 6, 7; 6, 8; 7, identifier:athlete_id; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:sta...
def get_segment_efforts(self, segment_id, athlete_id=None, start_date_local=None, end_date_local=None, limit=None): params = {"segment_id": segment_id} if athlete_id is not None: params['athlete_id'] = athlete_id if start_date_l...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:range; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 4, identifier:self; 5, identifier:low; 6, identifier:high; 7, default_parameter; 7, 8; 7, 9; 8, identifier:with_scores; 9, False; 10, default_parameter; 10, 11; 10, 12; 11, identifier...
def range(self, low, high, with_scores=False, desc=False, reverse=False): if reverse: return self.database.zrevrange(self.key, low, high, with_scores) else: return self.database.zrange(self.key, low, high, desc, with_scores)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sfiles_to_event; 3, parameters; 3, 4; 4, identifier:sfile_list; 5, block; 5, 6; 5, 10; 5, 29; 5, 43; 5, 53; 5, 59; 5, 87; 5, 92; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:event_list; 9, list:[]; 10, expression_stat...
def sfiles_to_event(sfile_list): event_list = [] sort_list = [(readheader(sfile).origins[0].time, sfile) for sfile in sfile_list] sort_list.sort(key=lambda tup: tup[0]) sfile_list = [sfile[1] for sfile in sort_list] catalog = Catalog() for i, sfile in enumerate(sfile_list): ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 24; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 13; 8, attribute; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, identifier:families; 12, identifier:sort;...
def sort(self): self.families.sort(key=lambda x: x.template.name) return self
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:decluster; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:trig_int; 6, default_parameter; 6, 7; 6, 8; 7, identifier:timing; 8, string:'detect'; 9, default_parameter; 9, 10; 9, 11; 10, identifier:metric; 11, string:'av...
def decluster(self, trig_int, timing='detect', metric='avg_cor'): all_detections = [] for fam in self.families: all_detections.extend(fam.detections) if timing == 'detect': if metric == 'avg_cor': detect_info = [(d.detect_time, d.detect_val / d.no_chans) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 25; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:detections; 11, call; 11, 12; 11, 13; 12, identifier:...
def sort(self): self.detections = sorted(self.detections, key=lambda d: d.detect_time) return self
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 25; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:templates; 11, call; 11, 12; 11, 13; 12, identifier:s...
def sort(self): self.templates = sorted(self.templates, key=lambda x: x.name) return self
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:filter_picks; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:catalog; 5, default_parameter; 5, 6; 5, 7; 6, identifier:stations; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:channels; 10, None; 11, defau...
def filter_picks(catalog, stations=None, channels=None, networks=None, locations=None, top_n_picks=None, evaluation_mode='all'): filtered_catalog = catalog.copy() if stations: for event in filtered_catalog: if len(event.picks) == 0: continue event...