sequence
stringlengths
546
16.2k
code
stringlengths
108
19.3k
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:gather_categories; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:imap; 5, identifier:header; 6, default_parameter; 6, 7; 6, 8; 7, identifier:categories; 8, None; 9, block; 9, 10; 9, 12; 9, 13; 9, 34; 9, 55; 9, 61; 9, 68; 9, 127; 9, 128; 9, 151...
def gather_categories(imap, header, categories=None): """ Find the user specified categories in the map and create a dictionary to contain the relevant data for each type within the categories. Multiple categories will have their types combined such that each possible combination will have its own entry...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:color_mapping; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:sample_map; 5, identifier:header; 6, identifier:group_column; 7, default_parameter; 7, 8; 7, 9; 8, identifier:color_column; 9, None; 10, block; 10, 11; 10, 13; 10, 19; 10, 29;...
def color_mapping(sample_map, header, group_column, color_column=None): """ Determine color-category mapping. If color_column was specified, then map the category names to color values. Otherwise, use the palettable colors to automatically generate a set of colors for the group values. :type sample...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 29; 2, function_name:shuffle_genome; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 12; 3, 15; 3, 16; 3, 19; 3, 22; 3, 23; 3, 26; 4, identifier:genome; 5, identifier:cat; 6, default_parameter; 6, 7; 6, 8; 7, identifier:fraction; 8, call; 8, 9; 8, 10; 9, identifier:float; 10,...
def shuffle_genome(genome, cat, fraction = float(100), plot = True, \ alpha = 0.1, beta = 100000, \ min_length = 1000, max_length = 200000): """ randomly shuffle genome """ header = '>randomized_%s' % (genome.name) sequence = list(''.join([i[1] for i in parse_fasta(genome)])) len...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:sam2fastq; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:sam; 5, default_parameter; 5, 6; 5, 7; 6, identifier:singles; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:force; 10, False; 11, block; 11, 12; 11, 14; 11, 22; 12, express...
def sam2fastq(sam, singles = False, force = False): """ convert sam to fastq """ L, R = None, None for line in sam: if line.startswith('@') is True: continue line = line.strip().split() bit = [True if i == '1' else False \ for i in bin(int(line[1])...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_sam; 3, parameters; 3, 4; 3, 5; 4, identifier:sam; 5, identifier:sort; 6, block; 6, 7; 6, 9; 6, 31; 6, 143; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:tempdir; ...
def sort_sam(sam, sort): """ sort sam file """ tempdir = '%s/' % (os.path.abspath(sam).rsplit('/', 1)[0]) if sort is True: mapping = '%s.sorted.sam' % (sam.rsplit('.', 1)[0]) if sam != '-': if os.path.exists(mapping) is False: os.system("\ ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:crossmap; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 4, identifier:fas; 5, identifier:reads; 6, identifier:options; 7, identifier:no_shrink; 8, identifier:keepDB; 9, identifier:threads; 10, identifier:cluster; 11, identif...
def crossmap(fas, reads, options, no_shrink, keepDB, threads, cluster, nodes): """ map all read sets against all fasta files """ if cluster is True: threads = '48' btc = [] for fa in fas: btd = bowtiedb(fa, keepDB) F, R, U = reads if F is not False: if...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:bit_by_bit; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:in_data; 6, block; 6, 7; 6, 9; 6, 10; 6, 28; 6, 34; 6, 100; 6, 138; 6, 155; 7, expression_statement; 7, 8; 8, comment; 9, comment; 10, if_statement; 10, 11; 10, 16; 11, ca...
def bit_by_bit(self, in_data): """ Classic simple and slow CRC implementation. This function iterates bit by bit over the augmented input message and returns the calculated CRC value at the end. """ # If the input data is a string, convert to bytes. if isinstance...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:parse_ggKbase_tables; 3, parameters; 3, 4; 3, 5; 4, identifier:tables; 5, identifier:id_type; 6, block; 6, 7; 6, 9; 6, 13; 6, 282; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, id...
def parse_ggKbase_tables(tables, id_type): """ convert ggKbase genome info tables to dictionary """ g2info = {} for table in tables: for line in open(table): line = line.strip().split('\t') if line[0].startswith('name'): header = line h...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:top_hits; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:hits; 5, identifier:num; 6, identifier:column; 7, identifier:reverse; 8, block; 8, 9; 8, 11; 8, 26; 9, expression_statement; 9, 10; 10, comment; 11, expression_statement; 11, 12; 12...
def top_hits(hits, num, column, reverse): """ get top hits after sorting by column number """ hits.sort(key = itemgetter(column), reverse = reverse) for hit in hits[0:num]: yield hit
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:numBlast_sort; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:blast; 5, identifier:numHits; 6, identifier:evalueT; 7, identifier:bitT; 8, block; 8, 9; 8, 11; 8, 27; 8, 30; 8, 40; 8, 140; 8, 149; 9, expression_statement; 9, 10; 10, comment...
def numBlast_sort(blast, numHits, evalueT, bitT): """ parse b6 output with sorting """ header = ['#query', 'target', 'pident', 'alen', 'mismatch', 'gapopen', 'qstart', 'qend', 'tstart', 'tend', 'evalue', 'bitscore'] yield header hmm = {h:[] for h in header} for line in blast: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:numDomtblout; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:domtblout; 5, identifier:numHits; 6, identifier:evalueT; 7, identifier:bitT; 8, identifier:sort; 9, block; 9, 10; 9, 12; 9, 31; 9, 58; 9, 61; 9, 69; 9, 280; 10, expression...
def numDomtblout(domtblout, numHits, evalueT, bitT, sort): """ parse hmm domain table output this version is faster but does not work unless the table is sorted """ if sort is True: for hit in numDomtblout_sort(domtblout, numHits, evalueT, bitT): yield hit return head...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:compare_clades; 3, parameters; 3, 4; 4, identifier:pw; 5, block; 5, 6; 5, 8; 5, 22; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:names; 11, call; 11, 12; 11, 13; 12, ident...
def compare_clades(pw): """ print min. pident within each clade and then matrix of between-clade max. """ names = sorted(set([i for i in pw])) for i in range(0, 4): wi, bt = {}, {} for a in names: for b in pw[a]: if ';' not in a or ';' not in b: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:searchAccession; 3, parameters; 3, 4; 4, identifier:acc; 5, block; 5, 6; 5, 8; 5, 9; 5, 10; 5, 20; 5, 95; 5, 96; 5, 106; 5, 181; 5, 182; 5, 192; 5, 267; 5, 298; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, comment; 10, expression_s...
def searchAccession(acc): """ attempt to use NCBI Entrez to get BioSample ID """ # try genbank file # genome database out, error = entrez('genome', acc) for line in out.splitlines(): line = line.decode('ascii').strip() if 'Assembly_Accession' in line or 'BioSample' in lin...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:_configure_logger; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 4, identifier:fmt; 5, identifier:quiet; 6, identifier:level; 7, identifier:fpath; 8, identifier:pre_hooks; 9, identifier:post_hooks; 10, identifier:metric_grouping_in...
def _configure_logger(fmt, quiet, level, fpath, pre_hooks, post_hooks, metric_grouping_interval): """ configures a logger when required write to stderr or a file """ # NOTE not thread safe. Multiple BaseScripts cannot be instantiated concurrently. level = getattr(logging, level.upper()) gl...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:combine_modifiers; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:graphemes; 6, block; 6, 7; 6, 9; 6, 13; 6, 17; 6, 24; 6, 210; 6, 211; 6, 221; 6, 225; 6, 229; 6, 287; 7, expression_statement; 7, 8; 8, comment; 9, expression_state...
def combine_modifiers(self, graphemes): """ Given a string that is space-delimited on Unicode grapheme clusters, group Unicode modifier letters with their preceding base characters, deal with tie bars, etc. Parameters ---------- string : str A Unicode...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:check_mismatches; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:read; 5, identifier:pair; 6, identifier:mismatches; 7, identifier:mm_option; 8, identifier:req_map; 9, block; 9, 10; 9, 12; 9, 13; 9, 48; 9, 49; 9, 56; 9, 63; 9, 64; 9...
def check_mismatches(read, pair, mismatches, mm_option, req_map): """ - check to see if the read maps with <= threshold number of mismatches - mm_option = 'one' or 'both' depending on whether or not one or both reads in a pair need to pass the mismatch threshold - pair can be False if read does n...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:get_steam; 3, parameters; 4, block; 4, 5; 4, 7; 4, 8; 4, 9; 4, 10; 4, 30; 4, 31; 4, 32; 4, 40; 4, 54; 4, 68; 4, 69; 4, 70; 4, 71; 4, 72; 4, 97; 4, 98; 4, 99; 4, 100; 4, 101; 5, expression_statement; 5, 6; 6, comment; 7, comment; 8, comment; 9, ...
def get_steam(): """ Returns a Steam object representing the current Steam installation on the users computer. If the user doesn't have Steam installed, returns None. """ # Helper function which checks if the potential userdata directory exists # and returns a new Steam instance with that userdata directory...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:generate_barcodes; 3, parameters; 3, 4; 3, 5; 4, identifier:nIds; 5, default_parameter; 5, 6; 5, 7; 6, identifier:codeLen; 7, integer:12; 8, block; 8, 9; 8, 11; 8, 41; 8, 56; 8, 77; 8, 78; 8, 90; 8, 115; 8, 119; 8, 195; 9, expression_statement;...
def generate_barcodes(nIds, codeLen=12): """ Given a list of sample IDs generate unique n-base barcodes for each. Note that only 4^n unique barcodes are possible. """ def next_code(b, c, i): return c[:i] + b + (c[i+1:] if i < -1 else '') def rand_base(): return random.choice(['A...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:parse_fasta_annotations; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:fastas; 5, identifier:annot_tables; 6, identifier:trans_table; 7, block; 7, 8; 7, 10; 7, 58; 8, expression_statement; 8, 9; 9, comment; 10, if_statement; 10, 11; 10, 14; 11...
def parse_fasta_annotations(fastas, annot_tables, trans_table): """ parse gene call information from Prodigal fasta output """ if annot_tables is not False: annots = {} for table in annot_tables: for cds in open(table): ID, start, end, strand = cds.strip().spl...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:find_consensus; 3, parameters; 3, 4; 4, identifier:bases; 5, block; 5, 6; 5, 8; 5, 17; 5, 34; 5, 35; 5, 78; 5, 96; 5, 126; 5, 186; 5, 192; 5, 198; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9...
def find_consensus(bases): """ find consensus base based on nucleotide frequencies """ nucs = ['A', 'T', 'G', 'C', 'N'] total = sum([bases[nuc] for nuc in nucs if nuc in bases]) # save most common base as consensus (random nuc if there is a tie) try: top = max([bases[nuc] for nuc...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:print_consensus; 3, parameters; 3, 4; 4, identifier:genomes; 5, block; 5, 6; 5, 8; 5, 9; 5, 13; 5, 14; 5, 132; 5, 133; 5, 209; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12...
def print_consensus(genomes): """ print consensensus sequences for each genome and sample """ # generate consensus sequences cons = {} # cons[genome][sample][contig] = consensus for genome, contigs in list(genomes.items()): cons[genome] = {} for contig, samples in list(contigs.it...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:parse_cov; 3, parameters; 3, 4; 3, 5; 4, identifier:cov_table; 5, identifier:scaffold2genome; 6, block; 6, 7; 6, 9; 6, 13; 6, 14; 6, 18; 6, 19; 6, 20; 6, 190; 6, 191; 6, 207; 6, 267; 7, expression_statement; 7, 8; 8, comment; 9, expression_stat...
def parse_cov(cov_table, scaffold2genome): """ calculate genome coverage from scaffold coverage table """ size = {} # size[genome] = genome size mapped = {} # mapped[genome][sample] = mapped bases # parse coverage files for line in open(cov_table): line = line.strip().split('\t') ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:print_genome_matrix; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:hits; 5, identifier:fastas; 6, identifier:id2desc; 7, identifier:file_name; 8, block; 8, 9; 8, 11; 8, 19; 8, 26; 8, 34; 8, 50; 8, 122; 8, 130; 8, 138; 8, 154; 9, expressi...
def print_genome_matrix(hits, fastas, id2desc, file_name): """ optimize later? slow ... should combine with calculate_threshold module """ out = open(file_name, 'w') fastas = sorted(fastas) print('## percent identity between genomes', file=out) print('# - \t %s' % ('\t'.join(fastas)), fi...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:calc_thresholds; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 13; 4, identifier:rbh; 5, identifier:file_name; 6, default_parameter; 6, 7; 6, 8; 7, identifier:thresholds; 8, list:[False, False, False, False]; 8, 9; 8, 10; 8, 11; 8, 12; 9, False; 10, Fal...
def calc_thresholds(rbh, file_name, thresholds = [False, False, False, False], stdevs = 2): """ if thresholds are not specififed, calculate based on the distribution of normalized bit scores """ calc_threshold = thresholds[-1] norm_threshold = {} for pair in itertools.permutations([i for i in rb...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_update_property; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:tree_to_update; 5, identifier:xpath_root; 6, identifier:xpaths; 7, identifier:values; 8, block; 8, 9; 8, 11; 8, 12; 8, 240; 8, 241; 8, 248; 8, 255; 9, expression_statement; ...
def _update_property(tree_to_update, xpath_root, xpaths, values): """ Default update operation for a single parser property. If xpaths contains one xpath, then one element per value will be inserted at that location in the tree_to_update; otherwise, the number of values must match the number of xpaths. ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:validate_complex_list; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:prop; 5, identifier:value; 6, default_parameter; 6, 7; 6, 8; 7, identifier:xpath_map; 8, None; 9, block; 9, 10; 9, 12; 10, expression_statement; 10, 11; 11, comment; 12, if_s...
def validate_complex_list(prop, value, xpath_map=None): """ Default validation for Attribute Details data structure """ if value is not None: validate_type(prop, value, (dict, list)) if prop in _complex_definitions: complex_keys = _complex_definitions[prop] else: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:validate_dates; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:prop; 5, identifier:value; 6, default_parameter; 6, 7; 6, 8; 7, identifier:xpath_map; 8, None; 9, block; 9, 10; 9, 12; 10, expression_statement; 10, 11; 11, comment; 12, if_statemen...
def validate_dates(prop, value, xpath_map=None): """ Default validation for Date Types data structure """ if value is not None: validate_type(prop, value, dict) date_keys = set(value) if date_keys: if DATE_TYPE not in date_keys or DATE_VALUES not in date_keys: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:getCharacterSet; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 12; 5, 16; 5, 20; 5, 24; 5, 245; 6, expression_statement; 6, 7; 7, string:'''Get a character set with individual members or ranges. Current index is on ...
def getCharacterSet(self): '''Get a character set with individual members or ranges. Current index is on '[', the start of the character set. ''' chars = u'' c = None cnt = 1 start = 0 while True: escaped_slash = False c...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:getSequence; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:level; 7, integer:0; 8, block; 8, 9; 8, 11; 8, 15; 8, 19; 8, 23; 8, 27; 8, 31; 8, 348; 8, 349; 8, 361; 8, 377; 9, expression_statement; ...
def getSequence(self, level=0): '''Get a sequence of nodes.''' seq = [] op = '' left_operand = None right_operand = None sequence_closed = False while True: c = self.next() if not c: break if c and c not in self...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:process; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:data; 6, identifier:type; 7, identifier:history; 8, block; 8, 9; 8, 11; 8, 17; 8, 25; 8, 32; 8, 40; 8, 44; 8, 131; 8, 140; 8, 149; 9, expression_statement; 9, 10;...
def process(self, data, type, history): """ process the specified type then process its children """ if type in history: return if type.enum(): return history.append(type) resolved = type.resolve() value = None if type.multi_occurrence(): ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_process_tz; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:dt; 6, identifier:naive; 7, identifier:tz; 8, block; 8, 9; 8, 11; 8, 101; 8, 108; 8, 115; 8, 152; 8, 158; 8, 207; 9, expression_statement; 9, 10; 10, comment;...
def _process_tz(self, dt, naive, tz): """Process timezone casting and conversion.""" def _tz(t): if t in (None, 'naive'): return t if t == 'local': if __debug__ and not localtz: raise ValueError("Requested conversion to local timezone, but `localtz` not installed.") t = localtz ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:__dfs; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:v; 6, identifier:index; 7, identifier:layers; 8, block; 8, 9; 8, 11; 8, 60; 8, 155; 9, expression_statement; 9, 10; 10, comment; 11, if_statement; 11, 12; 11, 15; 1...
def __dfs(self, v, index, layers): """ we recursively run dfs on each vertices in free_vertex, :param v: vertices in free_vertex :return: True if P is not empty (i.e., the maximal set of vertex-disjoint alternating path of length k) and false otherwise. """ if in...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:login; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:username; 6, identifier:password; 7, default_parameter; 7, 8; 7, 9; 8, identifier:login_token; 9, None; 10, block; 10, 11; 10, 13; 10, 45; 10, 68; 10, 105; 11, exp...
def login(self, username, password, login_token=None): """ Authenticate with the given credentials. If authentication is successful, all further requests sent will be signed the authenticated user. Note that passwords are sent as plaintext. This is a limitation of the M...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:cut_levels; 3, parameters; 3, 4; 3, 5; 4, identifier:nodes; 5, identifier:start_level; 6, block; 6, 7; 6, 9; 6, 13; 6, 17; 6, 152; 6, 168; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12...
def cut_levels(nodes, start_level): """ cutting nodes away from menus """ final = [] removed = [] for node in nodes: if not hasattr(node, 'level'): # remove and ignore nodes that don't have level information remove(node, removed) continue if no...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:S; 3, parameters; 3, 4; 3, 5; 4, identifier:Document; 5, list_splat_pattern; 5, 6; 6, identifier:fields; 7, block; 7, 8; 7, 10; 7, 14; 7, 118; 8, expression_statement; 8, 9; 9, comment; 10, expression_statement; 10, 11; 11, assignment; 11, 12; ...
def S(Document, *fields): """Generate a MongoDB sort order list using the Django ORM style.""" result = [] for field in fields: if isinstance(field, tuple): # Unpack existing tuple. field, direction = field result.append((field, direction)) continue direction = ASCENDING if not field.starts...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:valid; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:cnpj; 6, block; 6, 7; 6, 9; 6, 19; 6, 23; 6, 31; 6, 39; 6, 43; 6, 49; 6, 89; 6, 105; 6, 117; 6, 123; 6, 131; 6, 135; 6, 141; 6, 181; 6, 197; 6, 209; 7, expression_statement; 7,...
def valid(self, cnpj): """Check if a CNPJ is valid. We should avoid sending invalid CNPJ to the web service as we know it is going to be a waste of bandwidth. Assumes CNPJ is a string. """ if len(cnpj) != 14: return False tam = 12 nums = cnpj[:tam] ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:arrayuniqify; 3, parameters; 3, 4; 3, 5; 4, identifier:X; 5, default_parameter; 5, 6; 5, 7; 6, identifier:retainorder; 7, False; 8, block; 8, 9; 8, 11; 8, 19; 8, 25; 8, 47; 9, expression_statement; 9, 10; 10, comment; 11, expression_statement; ...
def arrayuniqify(X, retainorder=False): """ Very fast uniqify routine for numpy arrays. **Parameters** **X** : numpy array Determine the unique elements of this numpy array. **retainorder** : Boolean, optional Whether or not to return in...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:equalspairs; 3, parameters; 3, 4; 3, 5; 4, identifier:X; 5, identifier:Y; 6, block; 6, 7; 6, 9; 6, 17; 6, 39; 6, 60; 6, 77; 6, 86; 6, 102; 6, 118; 6, 129; 6, 145; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, as...
def equalspairs(X, Y): """ Indices of elements in a sorted numpy array equal to those in another. Given numpy array `X` and sorted numpy array `Y`, determine the indices in Y equal to indices in X. Returns `[A,B]` where `A` and `B` are numpy arrays of indices in `X` such that:: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 22; 2, function_name:loadSV; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:fname; 5, default_parameter; 5, 6; 5, 7; 6, identifier:shape; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:titles; 10, None; 11, default_parameter;...
def loadSV(fname, shape=None, titles=None, aligned=False, byteorder=None, renamer=None, **kwargs): """ Load a delimited text file to a numpy record array. Basically, this function calls loadSVcols and combines columns returned by that function into a numpy ndarray with stuctured dtype. A...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 22; 2, function_name:loadSVrecs; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:fname; 5, default_parameter; 5, 6; 5, 7; 6, identifier:uselines; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:skiprows; 10, integer:0; 11, defa...
def loadSVrecs(fname, uselines=None, skiprows=0, linefixer=None, delimiter_regex=None, verbosity=DEFAULT_VERBOSITY, **metadata): """ Load a separated value text file to a list of lists of strings of records. Takes a tabular text file with a specified delimeter and end-of-line character...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 1, 13; 2, function_name:dflt_interval; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:cd_id; 7, type; 7, 8; 8, identifier:str; 9, type; 9, 10; 10, tuple; 10, 11; 10, 12; 11, identifier:int; 12, identifier:int; 13, b...
def dflt_interval(self, cd_id: str) -> (int, int): """ Return default non-revocation interval from latest 'to' times on delta frames of revocation cache entries on indices stemming from input cred def id. Compute the 'from'/'to' values as the earliest/latest 'to' values of all c...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 1, 15; 2, function_name:parse; 3, parameters; 3, 4; 3, 8; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:base_dir; 6, type; 6, 7; 7, identifier:str; 8, typed_default_parameter; 8, 9; 8, 10; 8, 12; 9, identifier:timestamp; 10, type; 10, 11; 11, identifier:int; 1...
def parse(base_dir: str, timestamp: int = None) -> int: """ Parse and update from archived cache files. Only accept new content; do not overwrite any existing cache content. :param base_dir: archive base directory :param timestamp: epoch time of cache serving as subdirectory, de...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_convert_hbf_meta_val_for_xml; 3, parameters; 3, 4; 3, 5; 4, identifier:key; 5, identifier:val; 6, block; 6, 7; 6, 9; 6, 26; 6, 30; 6, 34; 6, 91; 6, 155; 7, expression_statement; 7, 8; 8, comment; 9, if_statement; 9, 10; 9, 15; 10, call; 10, 11...
def _convert_hbf_meta_val_for_xml(key, val): """Convert to a BadgerFish-style dict for addition to a dict suitable for addition to XML tree or for v1.0 to v0.0 conversion.""" if isinstance(val, list): return [_convert_hbf_meta_val_for_xml(key, i) for i in val] is_literal = True content = Non...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:validate_params_match; 3, parameters; 3, 4; 3, 5; 4, identifier:method; 5, identifier:parameters; 6, block; 6, 7; 6, 9; 6, 18; 6, 19; 6, 35; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, ...
def validate_params_match(method, parameters): """Validates that the given parameters are exactly the method's declared parameters. :param method: The method to be called :type method: function :param parameters: The parameters to use in the call :type parameters: dict[str, object] | list[object] ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:addcols; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:X; 5, identifier:cols; 6, default_parameter; 6, 7; 6, 8; 7, identifier:names; 8, None; 9, block; 9, 10; 9, 12; 9, 36; 9, 190; 9, 210; 9, 240; 10, expression_statement; 10, 11; 11, comment;...
def addcols(X, cols, names=None): """ Add one or more columns to a numpy ndarray. Technical dependency of :func:`tabular.spreadsheet.aggregate_in`. Implemented by the tabarray method :func:`tabular.tab.tabarray.addcols`. **Parameters** **X** : numpy ndarray with structured dtyp...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:replace; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 4, identifier:X; 5, identifier:old; 6, identifier:new; 7, default_parameter; 7, 8; 7, 9; 8, identifier:strict; 9, True; 10, default_parameter; 10, 11; 10, 12; 11, identifier:cols; 1...
def replace(X, old, new, strict=True, cols=None, rows=None): """ Replace value `old` with `new` everywhere it appears in-place. Implemented by the tabarray method :func:`tabular.tab.tabarray.replace`. **Parameters** **X** : numpy ndarray with structured dtype Nu...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:rowstack; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:seq; 5, default_parameter; 5, 6; 5, 7; 6, identifier:mode; 7, string:'nulls'; 8, default_parameter; 8, 9; 8, 10; 9, identifier:nullvals; 10, None; 11, block; 11, 12; 11, 14; 11, 25; 11, ...
def rowstack(seq, mode='nulls', nullvals=None): ''' Vertically stack a sequence of numpy ndarrays with structured dtype Analog of numpy.vstack Implemented by the tabarray method :func:`tabular.tab.tabarray.rowstack` which uses :func:`tabular.tabarray.tab_rowstack`. **Parameters** ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:colstack; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:seq; 5, default_parameter; 5, 6; 5, 7; 6, identifier:mode; 7, string:'abort'; 8, default_parameter; 8, 9; 8, 10; 9, identifier:returnnaming; 10, False; 11, block; 11, 12; 11, 14; 11, 23;...
def colstack(seq, mode='abort',returnnaming=False): """ Horizontally stack a sequence of numpy ndarrays with structured dtypes Analog of numpy.hstack for recarrays. Implemented by the tabarray method :func:`tabular.tab.tabarray.colstack` which uses :func:`tabular.tabarray.tab_colstack`. ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:getjp2image; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:date; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sourceId; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:observatory; 10, None; 11, default_param...
def getjp2image(date, sourceId=None, observatory=None, instrument=None, detector=None, measurement=None): ''' Helioviewer.org and JHelioviewer operate off of JPEG2000 formatted image data generated from science-quality FITS files. U...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 1, 26; 2, function_name:loads_loader; 3, parameters; 3, 4; 3, 10; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:load_module; 6, type; 6, 7; 7, attribute; 7, 8; 7, 9; 8, identifier:types; 9, identifier:ModuleType; 10, typed_parameter; 10, 11; 10, 12; 11, identi...
def loads_loader(load_module: types.ModuleType, pairs: Dict[str, str]) -> Optional[JSGValidateable]: """json loader objecthook :param load_module: Module that contains the various types :param pairs: key/value tuples (In our case, they are str/str) :return: """ cntxt = load_module._CONTEXT ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 1, 11; 2, function_name:get_cred_def; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:cd_id; 7, type; 7, 8; 8, identifier:str; 9, type; 9, 10; 10, identifier:str; 11, block; 11, 12; 11, 14; 11, 22; 11, 31; 11, 194; 1...
async def get_cred_def(self, cd_id: str) -> str: """ Get credential definition from ledger by its identifier. Raise AbsentCredDef for no such credential definition, logging any error condition and raising BadLedgerTxn on bad request. Raise ClosedPool if cred def not in cache and pool is...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:convert_nexson_format; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:blob; 5, identifier:out_nexson_format; 6, default_parameter; 6, 7; 6, 8; 7, identifier:current_format; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, i...
def convert_nexson_format(blob, out_nexson_format, current_format=None, remove_old_structs=True, pristine_if_invalid=False, sort_arbitrary=False): """Take a dict form of NexSON and conve...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_inplace_sort_by_id; 3, parameters; 3, 4; 4, identifier:unsorted_list; 5, block; 5, 6; 5, 8; 5, 17; 5, 32; 5, 38; 5, 43; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 15; 9, not_operator; 9, 10; 10, call; 10, 11; 10, 12; ...
def _inplace_sort_by_id(unsorted_list): """Takes a list of dicts each of which has an '@id' key, sorts the elements in the list by the value of the @id key. Assumes that @id is unique or the dicts have a meaningul < operator """ if not isinstance(unsorted_list, list): return sorted_list ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:cull_nonmatching_trees; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:nexson; 5, identifier:tree_id; 6, default_parameter; 6, 7; 6, 8; 7, identifier:curr_version; 8, None; 9, block; 9, 10; 9, 12; 9, 24; 9, 39; 9, 46; 9, 52; 9, 56; 9, 119; 9, 1...
def cull_nonmatching_trees(nexson, tree_id, curr_version=None): """Modifies `nexson` and returns it in version 1.2.1 with any tree that does not match the ID removed. Note that this does not search through the NexSON for every node, edge, tree that was deleted. So the resulting NexSON may have brok...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 1, 30; 2, function_name:_validate; 3, parameters; 3, 4; 3, 5; 3, 9; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:val; 7, type; 7, 8; 8, identifier:list; 9, typed_default_parameter; 9, 10; 9, 11; 9, 17; 10, identifier:log; 11, type; 11, 12;...
def _validate(self, val: list, log: Optional[Logger] = None) -> Tuple[bool, List[str]]: """ Determine whether val is a valid instance of this array :returns: Success indicator and error list """ errors = [] if not isinstance(val, list): errors.append(f"{self._variable_name}:...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 1, 16; 2, function_name:_sync_revoc; 3, parameters; 3, 4; 3, 5; 3, 9; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:rr_id; 7, type; 7, 8; 8, identifier:str; 9, typed_default_parameter; 9, 10; 9, 11; 9, 13; 10, identifier:rr_size; 11, type; ...
async def _sync_revoc(self, rr_id: str, rr_size: int = None) -> None: """ Create revoc registry if need be for input revocation registry identifier; open and cache tails file reader. :param rr_id: revocation registry identifier :param rr_size: if new revocation registry necessar...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:add_namespace_uri; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:ns_uri; 6, default_parameter; 6, 7; 6, 8; 7, identifier:prefix; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:schema_location; 11, None; ...
def add_namespace_uri(self, ns_uri, prefix=None, schema_location=None): """Adds a new namespace to this set, optionally with a prefix and schema location URI. If the namespace already exists, the given prefix and schema location are merged with the existing entry: * If non-N...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:get_schemaloc_string; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ns_uris; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sort; 10, False; 11, default_parameter; 11, 12...
def get_schemaloc_string(self, ns_uris=None, sort=False, delim="\n"): """Constructs and returns a schemalocation attribute. If no namespaces in this set have any schema locations defined, returns an empty string. Args: ns_uris (iterable): The namespaces to include in the co...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:tab_join; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:ToMerge; 5, default_parameter; 5, 6; 5, 7; 6, identifier:keycols; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:nullvals; 10, None; 11, default_parameter...
def tab_join(ToMerge, keycols=None, nullvals=None, renamer=None, returnrenaming=False, Names=None): ''' Database-join for tabular arrays. Wrapper for :func:`tabular.spreadsheet.join` that deals with the coloring and returns the result as a tabarray. Method calls:: data ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 26; 2, function_name:aggregate; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:On; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:AggFuncDict; 10, None; 11, default...
def aggregate(self, On=None, AggFuncDict=None, AggFunc=None, AggList = None, returnsort=False,KeepOthers=True, keyfuncdict=None): """ Aggregate a tabarray on columns for given functions. Method wraps:: tabular.spreadsheet.aggregate(self, On, AggFuncDict, AggFu...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:argsort; 3, parameters; 3, 4; 3, 5; 3, 9; 3, 12; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:axis; 7, unary_operator:-; 7, 8; 8, integer:1; 9, default_parameter; 9, 10; 9, 11; 10, identifier:kind; 11, string:'quicksort'...
def argsort(self, axis=-1, kind='quicksort', order=None): """ Returns the indices that would sort an array. .. note:: This method wraps `numpy.argsort`. This documentation is modified from that of `numpy.argsort`. Perform an indirect sort along the gi...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_finalize_namespaces; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ns_dict; 7, None; 8, block; 8, 9; 8, 11; 8, 36; 8, 37; 8, 59; 8, 60; 8, 61; 8, 67; 8, 68; 8, 91; 8, 92; 8, 103; 8, 104; 8, 105;...
def _finalize_namespaces(self, ns_dict=None): """Returns a dictionary of namespaces to be exported with an XML document. This loops over all the namespaces that were discovered and built during the execution of ``collect()`` and ``_parse_collected_classes()`` and attempts to mer...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:update_empty_fields; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 10; 7, 28; 7, 46; 7, 64; 7, 95; 7, 113; 7, 129; 7, 146; 7, 164; 8, expression_statement; 8, 9; 9, co...
def update_empty_fields(self, **kwargs): """Updates the field of info about an OTU that might not be filled in by a match_names or taxon call.""" if self._is_deprecated is None: self._is_deprecated = kwargs.get('is_deprecated') if self._is_dubious is None: self._is_dubiou...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 1, 25; 2, function_name:get_creds; 3, parameters; 3, 4; 3, 5; 3, 9; 3, 14; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:proof_req_json; 7, type; 7, 8; 8, identifier:str; 9, typed_default_parameter; 9, 10; 9, 11; 9, 13; 10, identifier:filt;...
async def get_creds(self, proof_req_json: str, filt: dict = None, filt_dflt_incl: bool = False) -> (Set[str], str): """ Get credentials from HolderProver wallet corresponding to proof request and filter criteria; return credential identifiers from wallet and credentials json. Return empt...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:summary; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:processors; 5, identifier:metrics; 6, identifier:context; 7, block; 7, 8; 7, 10; 7, 11; 7, 47; 7, 83; 7, 123; 7, 127; 7, 209; 7, 216; 7, 253; 7, 258; 7, 265; 7, 274; 7, 306; 7, 315; 8, exp...
def summary(processors, metrics, context): """Print the summary""" # display aggregated metric values on language level def display_header(processors, before='', after=''): """Display the header for the summary results.""" print(before, end=' ') for processor in processors: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:run_experiment; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:experiment; 5, identifier:roleouts; 6, identifier:episodes; 7, default_parameter; 7, 8; 7, 9; 8, identifier:in_cloud; 9, False; 10, default_parameter; 10, 11; 10, 12; ...
def run_experiment(experiment, roleouts, episodes, in_cloud=False, dynProfile=None): """ Runs the given experiment and returns the results. """ def run(): if dynProfile is None: maxsteps = len(experiment.profile) # episode length else: maxsteps = dy...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:total_cost; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:p; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:p_cost; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, i...
def total_cost(self, p=None, p_cost=None, pcost_model=None): """ Computes total cost for the generator at the given output level. """ p = self.p if p is None else p p_cost = self.p_cost if p_cost is None else p_cost pcost_model = self.pcost_model if pcost_model is None else pcost...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:offers_to_pwl; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:offers; 6, block; 6, 7; 6, 9; 6, 14; 6, 15; 6, 29; 6, 30; 6, 48; 6, 49; 6, 62; 6, 75; 6, 87; 6, 166; 6, 201; 6, 231; 7, expression_statement; 7, 8; 8, comment; 9, asser...
def offers_to_pwl(self, offers): """ Updates the piece-wise linear total cost function using the given offer blocks. Based on off2case.m from MATPOWER by Ray Zimmerman, developed at PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more info. """ assert no...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:bids_to_pwl; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:bids; 6, block; 6, 7; 6, 9; 6, 13; 6, 14; 6, 28; 6, 29; 6, 47; 6, 48; 6, 61; 6, 74; 6, 86; 6, 154; 6, 208; 6, 209; 6, 210; 7, expression_statement; 7, 8; 8, comment; 9, a...
def bids_to_pwl(self, bids): """ Updates the piece-wise linear total cost function using the given bid blocks. Based on off2case.m from MATPOWER by Ray Zimmerman, developed at PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more info. """ assert self.is_...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:DoxyfileParse; 3, parameters; 3, 4; 4, identifier:file_contents; 5, block; 5, 6; 5, 8; 5, 12; 5, 15; 5, 29; 5, 35; 5, 49; 5, 55; 5, 61; 5, 69; 5, 73; 5, 74; 5, 78; 5, 82; 5, 86; 5, 90; 5, 130; 5, 277; 5, 278; 5, 330; 6, expression_statement; 6,...
def DoxyfileParse(file_contents): """ Parse a Doxygen source file and return a dictionary of all the values. Values will be strings and lists of strings. """ data = {} import shlex lex = shlex.shlex(instream = file_contents, posix = True) lex.wordchars += "*+./-:" lex.whitespace = lex.whites...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:DoxySourceScan; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:node; 5, identifier:env; 6, identifier:path; 7, block; 7, 8; 7, 10; 7, 39; 7, 44; 7, 48; 7, 59; 7, 80; 7, 90; 7, 100; 7, 101; 7, 102; 7, 103; 7, 104; 7, 118; 7, 288; 7, 289; 7, 340;...
def DoxySourceScan(node, env, path): """ Doxygen Doxyfile source scanner. This should scan the Doxygen file and add any files used to generate docs to the list of source files. """ default_file_patterns = [ '*.c', '*.cc', '*.cxx', '*.cpp', '*.c++', '*.java', '*.ii', '*.ixx', '*.ipp', '*.i++'...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_quadratic_costs; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:generators; 6, identifier:ipol; 7, identifier:nxyz; 8, identifier:base_mva; 9, block; 9, 10; 9, 12; 9, 19; 9, 26; 9, 40; 9, 63; 9, 91; 9, 119; 9, 1...
def _quadratic_costs(self, generators, ipol, nxyz, base_mva): """ Returns the quadratic cost components of the objective function. """ npol = len(ipol) rnpol = range(npol) gpol = [g for g in generators if g.pcost_model == POLYNOMIAL] if [g for g in gpol if len(g.p_cost) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_gh; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:x; 6, block; 6, 7; 6, 9; 6, 28; 6, 29; 6, 48; 6, 49; 6, 86; 6, 87; 6, 102; 6, 121; 6, 140; 6, 151; 6, 152; 6, 167; 6, 168; 6, 180; 6, 181; 6, 182; 6, 183; 6, 205; 6, 206; 6, 226;...
def _gh(self, x): """ Evaluates the constraint function values. """ Pgen = x[self._Pg.i1:self._Pg.iN + 1] # Active generation in p.u. Qgen = x[self._Qg.i1:self._Qg.iN + 1] # Reactive generation in p.u. for i, gen in enumerate(self._gn): gen.p = Pgen[i] * self._base_m...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:performAction; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:action; 6, block; 6, 7; 6, 9; 6, 29; 6, 39; 6, 51; 6, 52; 6, 69; 6, 70; 6, 84; 6, 85; 6, 86; 6, 108; 6, 109; 6, 170; 6, 176; 7, expression_statement; 7, 8; 8, comment; ...
def performAction(self, action): """ Perform an action on the world that changes it's internal state. """ gs = [g for g in self.case.online_generators if g.bus.type !=REFERENCE] assert len(action) == len(gs) logger.info("Action: %s" % list(action)) # Set the output of ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 1, 28; 2, function_name:blt; 3, parameters; 3, 4; 3, 12; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:f; 6, type; 6, 7; 7, generic_type; 7, 8; 7, 9; 8, identifier:List; 9, type_parameter; 9, 10; 10, type; 10, 11; 11, identifier:SYM; 12, typed_parameter; 12, 1...
def blt(f: List[SYM], x: List[SYM]) -> Dict[str, Any]: """ Sort equations by dependence """ J = ca.jacobian(f, x) nblock, rowperm, colperm, rowblock, colblock, coarserow, coarsecol = J.sparsity().btf() return { 'J': J, 'nblock': nblock, 'rowperm': rowperm, 'colper...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_generators; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, call; 9, 10; 9, 15; 10, attribute; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, i...
def sort_generators(self): """ Reorders the list of generators according to bus index. """ self.generators.sort(key=lambda gn: gn.bus._i)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:create; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:dotdata; 6, default_parameter; 6, 7; 6, 8; 7, identifier:prog; 8, string:"dot"; 9, default_parameter; 9, 10; 9, 11; 10, identifier:format; 11, string:"xdot"; 12, ...
def create(self, dotdata, prog="dot", format="xdot"): """ Creates and returns a representation of the graph using the Graphviz layout program given by 'prog', according to the given format. Writes the graph to a temporary dot file and processes it with the program given by 'prog' (which...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:format; 3, parameters; 3, 4; 3, 5; 4, identifier:file_metrics; 5, identifier:build_metrics; 6, block; 6, 7; 6, 9; 6, 134; 6, 143; 6, 144; 6, 153; 6, 160; 6, 229; 6, 230; 6, 250; 6, 255; 6, 281; 7, expression_statement; 7, 8; 8, comment; 9, func...
def format(file_metrics, build_metrics): """compute output in XML format.""" def indent(elem, level=0): i = "\n" + level*" " if len(elem): if not elem.text or not elem.text.strip(): elem.text = i + " " if not elem.tail or not elem.tail.strip(): ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:governor; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:Xgov; 6, identifier:Pgov; 7, identifier:Vgov; 8, block; 8, 9; 8, 11; 8, 17; 8, 27; 8, 36; 8, 54; 8, 72; 8, 73; 8, 80; 8, 81; 8, 88; 8, 95; 8, 102; 8, 109; 8, 116...
def governor(self, Xgov, Pgov, Vgov): """ Governor model. Based on Governor.m from MatDyn by Stijn Cole, developed at Katholieke Universiteit Leuven. See U{http://www.esat.kuleuven.be/electa/teaching/ matdyn/} for more information. """ governors = self.governors ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:generator; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:Xgen; 6, identifier:Xexc; 7, identifier:Xgov; 8, identifier:Vgen; 9, block; 9, 10; 9, 12; 9, 18; 9, 28; 9, 37; 9, 53; 9, 69; 9, 70; 9, 77; 9, 84; 9, 99; 9...
def generator(self, Xgen, Xexc, Xgov, Vgen): """ Generator model. Based on Generator.m from MatDyn by Stijn Cole, developed at Katholieke Universiteit Leuven. See U{http://www.esat.kuleuven.be/electa/teaching/ matdyn/} for more information. """ generators = self.dyn_gene...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_const_pf_constraints; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:gn; 6, identifier:base_mva; 7, block; 7, 8; 7, 10; 7, 43; 7, 53; 7, 60; 7, 67; 7, 82; 7, 97; 7, 112; 7, 127; 7, 142; 7, 143; 7, 169; 7, 170; 7, 171; 7, 17...
def _const_pf_constraints(self, gn, base_mva): """ Returns a linear constraint enforcing constant power factor for dispatchable loads. The power factor is derived from the original value of Pmin and either Qmin (for inductive loads) or Qmax (for capacitive loads). If both Qmin a...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_voltage_angle_diff_limit; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:buses; 6, identifier:branches; 7, block; 7, 8; 7, 10; 7, 17; 7, 309; 8, expression_statement; 8, 9; 9, comment; 10, expression_statement; 10, 11; 11, ...
def _voltage_angle_diff_limit(self, buses, branches): """ Returns the constraint on the branch voltage angle differences. """ nb = len(buses) if not self.ignore_ang_lim: iang = [i for i, b in enumerate(branches) if (b.ang_min and (b.ang_min > -360.0)) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_clipPrices; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 9; 5, 41; 5, 42; 5, 74; 5, 75; 5, 112; 5, 113; 5, 150; 5, 151; 5, 152; 5, 153; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, if_statement; 9, 10; 9, 13; ...
def _clipPrices(self): """ Clip cleared prices according to guarantees and limits. """ # Guarantee that cleared offer prices are >= offers. if self.guaranteeOfferPrice: for offer in self.offers: if offer.accepted and offer.clearedPrice < offer.price: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:gpu_iuwt_decomposition; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:in1; 5, identifier:scale_count; 6, identifier:scale_adjust; 7, identifier:store_smoothed; 8, identifier:store_on_gpu; 9, block; 9, 10; 9, 12; 9, 13; 9, 20; 9, 44...
def gpu_iuwt_decomposition(in1, scale_count, scale_adjust, store_smoothed, store_on_gpu): """ This function calls the a trous algorithm code to decompose the input into its wavelet coefficients. This is the isotropic undecimated wavelet transform implemented for a GPU. INPUTS: in1 (...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:gpu_iuwt_recomposition; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:in1; 5, identifier:scale_adjust; 6, identifier:store_on_gpu; 7, identifier:smoothed_array; 8, block; 8, 9; 8, 11; 8, 35; 8, 36; 8, 45; 8, 46; 8, 47; 8, 57; 8, 102; 8, ...
def gpu_iuwt_recomposition(in1, scale_adjust, store_on_gpu, smoothed_array): """ This function calls the a trous algorithm code to recompose the input into a single array. This is the implementation of the isotropic undecimated wavelet transform recomposition for a GPU. INPUTS: in1 (no ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:from_config; 3, parameters; 3, 4; 4, identifier:config; 5, block; 5, 6; 5, 8; 5, 12; 5, 20; 5, 174; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:matrix; 11, dictionary; 12...
def from_config(config): """ Generate a matrix from a configuration dictionary. """ matrix = {} variables = config.keys() for entries in product(*config.values()): combination = dict(zip(variables, entries)) include = True for value in combination.values(): fo...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 71; 2, function_name:moresane_by_scale; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 3, 35; 3, 38; 3, 41; 3, 44; 3, 47; 3, 50; 3, 53; 3, 56; 3, 59; 3, 62; 3, 65; 3, 68; 4, identifier:self; 5, default_parameter; 5, 6; 5, ...
def moresane_by_scale(self, start_scale=1, stop_scale=20, subregion=None, sigma_level=4, loop_gain=0.1, tolerance=0.75, accuracy=1e-6, major_loop_miter=100, minor_loop_miter=30, all_on_gpu=False, decom_mode="ser", core_count=1, conv_device='cpu', conv_mode='linear', e...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:load_or_create; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:cls; 5, default_parameter; 5, 6; 5, 7; 6, identifier:filename; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:no_input; 10, False; 11, default_parameter; 1...
def load_or_create(cls, filename=None, no_input=False, create_new=False, **kwargs): """ Load system from a dump, if dump file exists, or create a new system if it does not exist. """ parser = argparse.ArgumentParser() parser.add_argument('--no_input', action='store_true') ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:cleanup; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 14; 5, 26; 5, 47; 5, 56; 5, 68; 5, 77; 5, 99; 5, 108; 5, 125; 5, 134; 5, 156; 5, 165; 5, 192; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9...
def cleanup(self): """ Clean up before quitting """ self.pre_exit_trigger = True self.logger.info("Shutting down %s, please wait a moment.", self.name) for t in threading.enumerate(): if isinstance(t, TimerClass): t.cancel() self....
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:write_puml; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:filename; 7, string:''; 8, block; 8, 9; 8, 11; 8, 44; 8, 65; 8, 72; 8, 79; 8, 105; 8, 112; 8, 335; 8, 342; 9, expression_statement; 9, 10...
def write_puml(self, filename=''): """ Writes PUML from the system. If filename is given, stores result in the file. Otherwise returns result as a string. """ def get_type(o): type = 'program' if isinstance(o, AbstractSensor): type ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:fit; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:X; 6, default_parameter; 6, 7; 6, 8; 7, identifier:y; 8, None; 9, block; 9, 10; 9, 12; 9, 20; 9, 34; 9, 46; 9, 54; 9, 65; 9, 66; 9, 92; 9, 109; 9, 121; 9, 122; 9, 174; 9, 1...
def fit(self, X, y=None): """ Fit the inlier model given training data. This function attempts to choose reasonable defaults for parameters sigma and rho if none are specified, which could then be adjusted to improve performance. Parameters ---------- X ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:predict_sequence; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:X; 6, identifier:A; 7, identifier:pi; 8, default_parameter; 8, 9; 8, 10; 9, identifier:inference; 10, string:'smoothing'; 11, block; 11, 12; 11, 1...
def predict_sequence(self, X, A, pi, inference='smoothing'): """ Calculate class probabilities for a sequence of data. Parameters ---------- X : array Test data, of dimension N times d (rows are time frames, columns are data dimensions) A : class ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:add_bgcolor; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:colname; 6, default_parameter; 6, 7; 6, 8; 7, identifier:cmap; 8, string:'copper'; 9, default_parameter; 9, 10; 9, 11; 10, identifier:mode; 11, string...
def add_bgcolor(self, colname, cmap='copper', mode='absmax', threshold=2): """Change column content into HTML paragraph with background color :param colname: :param cmap: a colormap (matplotlib) or created using colormap package (from pypi). :param mode: type of ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 1, 21; 2, function_name:list; 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:filter; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:type; 10, None; 11, default_parameter; 11,...
def list(self, filter=None, type=None, sort=None, limit=None, page=None): # pylint: disable=redefined-builtin """Get a list of configs. :param filter: (optional) Filters to apply as a string list. :param type: (optional) `union` or `inter` as string. :param sort: (optional) Sort fields ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:signup_handler; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:remote; 5, list_splat_pattern; 5, 6; 6, identifier:args; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 12; 9, 13; 9, 23; 9, 24; 9, 31; 9, 40; 9, 49; 9...
def signup_handler(remote, *args, **kwargs): """Handle extra signup information. :param remote: The remote application. :returns: Redirect response or the template rendered. """ # User already authenticated so move on if current_user.is_authenticated: return redirect('/') # Retriev...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 1, 21; 2, function_name:list_csv; 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:filter; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:type; 10, None; 11, default_parameter;...
def list_csv(self, filter=None, type=None, sort=None, limit=None, page=None): # pylint: disable=redefined-builtin """Get a list of results as CSV. :param filter: (optional) Filters to apply as a string list. :param type: (optional) `union` or `inter` as string. :param sort: (optional) S...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 1, 13; 2, function_name:list_logdir; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:id; 6, default_parameter; 6, 7; 6, 8; 7, identifier:filter; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:sort; 11, None; 12, comment; 1...
def list_logdir(self, id, filter=None, sort=None): # pylint: disable=invalid-name,redefined-builtin """Get a list of logdir files. :param id: Result ID as an int. :param filter: Filter to apply as string. :param sort: Sort field to apply as string. :return: :class:`results.LogDi...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_init_report; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 14; 5, 20; 5, 21; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifi...
def _init_report(self): """create the report directory and return the directory name""" self.sections = [] self.section_names = [] # if the directory already exists, print a warning try: if os.path.isdir(self.directory) is False: if self.verbose: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:check_instance; 3, parameters; 3, 4; 4, identifier:function; 5, block; 5, 6; 5, 8; 5, 283; 6, expression_statement; 6, 7; 7, comment; 8, function_definition; 8, 9; 8, 10; 8, 16; 9, function_name:wrapper; 10, parameters; 10, 11; 10, 12; 10, 14; ...
def check_instance(function): """ Wrapper that tests the type of _session. Purpose: This decorator function is used by all functions within | the Jaide class that interact with a device to ensure the | proper session type is in use. If it is not, it will | atte...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:commit; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:commands; 7, string:""; 8, default_parameter; 8, 9; 8, 10; 9, identifier:confirmed; 10, None; 11, default_...
def commit(self, commands="", confirmed=None, comment=None, at_time=None, synchronize=False, req_format='text'): """ Perform a commit operation. Purpose: Executes a commit operation. All parameters are optional. | commit confirm and commit at are mutually exclusive. All ...