sequence
stringlengths
1.25k
34.6k
code
stringlengths
75
8.58k
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_paren_group'},{'id': '3', 'type': 'parameters', 'children': ['4']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 'par...
def parse_paren_group(paren_string): def max_depth(s): depth = 0 max_depth = 0 for c in s: if c == '(': depth += 1 max_depth = max(max_depth, depth) elif c == ')': depth -= 1 return max_depth return [max_dep...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'gather_categories'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']},{'id': '4', 'type': 'identifier', 'children': [], 'va...
def gather_categories(imap, header, categories=None): if categories is None: return {"default": DataCategory(set(imap.keys()), {})} cat_ids = [header.index(cat) for cat in categories if cat in header and "=" not in cat] table = OrderedDict() conditions = defaultdict(set) for i...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'color_mapping'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']},{'id': '4', 'type': 'identifier', 'children': [], '...
def color_mapping(sample_map, header, group_column, color_column=None): group_colors = OrderedDict() group_gather = gather_categories(sample_map, header, [group_column]) if color_column is not None: color_gather = gather_categories(sample_map, header, [color_column]) for group in group_gathe...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '29']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'shuffle_genome'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '12', '15', '16', '19', '22', '23', '26']},{'id': '4', '...
def shuffle_genome(genome, cat, fraction = float(100), plot = True, \ alpha = 0.1, beta = 100000, \ min_length = 1000, max_length = 200000): header = '>randomized_%s' % (genome.name) sequence = list(''.join([i[1] for i in parse_fasta(genome)])) length = len(sequence) shuffled = [] wh...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'sam2fastq'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']},{'id': '4', 'type': 'identifier', 'children': [], 'value': '...
def sam2fastq(sam, singles = False, force = False): 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])).split('b')[1][::-1]] while len(...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_sam'},{'id': '3', 'type': 'parameters', 'children': ['4', '5']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 'sam'},{...
def sort_sam(sam, sort): 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("\ sort -k1 --buffer-size=%sG -T ...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'crossmap'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10', '11']},{'id': '4', 'type': 'identifier', ...
def crossmap(fas, reads, options, no_shrink, keepDB, threads, cluster, nodes): 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 U is False: u = False for i, f in...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'bit_by_bit'},{'id': '3', 'type': 'parameters', 'children': ['4', '5']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'...
def bit_by_bit(self, in_data): if isinstance(in_data, str): in_data = [ord(c) for c in in_data] register = self.NonDirectInit for octet in in_data: if self.ReflectIn: octet = self.reflect(octet, 8) for i in range(8): topbit = re...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_ggKbase_tables'},{'id': '3', 'type': 'parameters', 'children': ['4', '5']},{'id': '4', 'type': 'identifier', 'children': [], 'valu...
def parse_ggKbase_tables(tables, id_type): g2info = {} for table in tables: for line in open(table): line = line.strip().split('\t') if line[0].startswith('name'): header = line header[4] = 'genome size (bp)' header[12] = ' ...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'top_hits'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']},{'id': '4', 'type': 'identifier', 'children': [], 'value'...
def top_hits(hits, num, column, reverse): hits.sort(key = itemgetter(column), reverse = reverse) for hit in hits[0:num]: yield hit
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'numBlast_sort'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']},{'id': '4', 'type': 'identifier', 'children': [], 'v...
def numBlast_sort(blast, numHits, evalueT, bitT): header = [' 'qstart', 'qend', 'tstart', 'tend', 'evalue', 'bitscore'] yield header hmm = {h:[] for h in header} for line in blast: if line.startswith(' continue line = line.strip().split('\t') line[10], l...
{'id': '0', 'type': 'module', 'children': ['1', '64', '67', '75', '267']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9', '47']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'numDomtblout'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']},{'id': '4', 'type...
def numDomtblout(domtblout, numHits, evalueT, bitT, sort): if sort is True: for hit in numDomtblout_sort(domtblout, numHits, evalueT, bitT): yield hit return header = [' 'query name', 'query accession', 'qlen', 'full E-value', 'full score', 'full bias', ...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'compare_clades'},{'id': '3', 'type': 'parameters', 'children': ['4']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 'pw'},{...
def compare_clades(pw): 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: continue pident = pw[a][b] cA, cB = a.split(';')[i],...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'searchAccession'},{'id': '3', 'type': 'parameters', 'children': ['4']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 'acc'}...
def searchAccession(acc): out, error = entrez('genome', acc) for line in out.splitlines(): line = line.decode('ascii').strip() if 'Assembly_Accession' in line or 'BioSample' in line: newAcc = line.split('>')[1].split('<')[0].split('.')[0].split(',')[0] if len(newAcc) > 0:...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']},{'id': '2', 'type': 'function_name', 'children': [], 'value': '_configure_logger'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10']},{'id': '4', 'type': 'identifier...
def _configure_logger(fmt, quiet, level, fpath, pre_hooks, post_hooks, metric_grouping_interval): level = getattr(logging, level.upper()) global _GLOBAL_LOG_CONFIGURED if _GLOBAL_LOG_CONFIGURED: return def wrap_hook(fn): @wraps(fn) def processor(logger, method_name, event_dic...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'combine_modifiers'},{'id': '3', 'type': 'parameters', 'children': ['4', '5']},{'id': '4', 'type': 'identifier', 'children': [], 'value':...
def combine_modifiers(self, graphemes): result = [] temp = "" count = len(graphemes) for grapheme in reversed(graphemes): count -= 1 if len(grapheme) == 1 and unicodedata.category(grapheme) == "Lm" \ and not ord(grapheme) in [712, 716]: ...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_mismatches'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']},{'id': '4', 'type': 'identifier', 'children'...
def check_mismatches(read, pair, mismatches, mm_option, req_map): if pair is False: mm = count_mismatches(read) if mm is False: return False if mismatches is False: return True if mm <= mismatches: return True r_mm = count_mismatches(read) ...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_steam'},{'id': '3', 'type': 'parameters', 'children': []},{'id': '4', 'type': 'block', 'children': ['5', '25', '33', '47', '61', '84...
def get_steam(): helper = lambda udd: Steam(udd) if os.path.exists(udd) else None plat = platform.system() if plat == 'Darwin': return helper(paths.default_osx_userdata_path()) if plat == 'Linux': return helper(paths.default_linux_userdata_path()) if plat == 'Windows': possible_dir = winutils.find...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'generate_barcodes'},{'id': '3', 'type': 'parameters', 'children': ['4', '5']},{'id': '4', 'type': 'identifier', 'children': [], 'value':...
def generate_barcodes(nIds, codeLen=12): def next_code(b, c, i): return c[:i] + b + (c[i+1:] if i < -1 else '') def rand_base(): return random.choice(['A', 'T', 'C', 'G']) def rand_seq(n): return ''.join([rand_base() for _ in range(n)]) hpf = re.compile('aaaa|cccc|gggg|tttt', re....
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'ERROR', 'children': ['2']},{'id': '2', 'type': 'function_definition', 'children': ['3', '4', '8']},{'id': '3', 'type': 'function_name', 'children': [], 'value': 'parse_fasta_annotations'},{'id': '4', 'type': 'parameters', 'children': ['5', '6', '7']}...
def parse_fasta_annotations(fastas, annot_tables, trans_table): if annot_tables is not False: annots = {} for table in annot_tables: for cds in open(table): ID, start, end, strand = cds.strip().split() annots[ID] = [start, end, int(strand)] for fasta i...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_consensus'},{'id': '3', 'type': 'parameters', 'children': ['4']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 'bases'...
def find_consensus(bases): nucs = ['A', 'T', 'G', 'C', 'N'] total = sum([bases[nuc] for nuc in nucs if nuc in bases]) try: top = max([bases[nuc] for nuc in nucs if nuc in bases]) except: bases['consensus'] = ('N', 'n/a') bases['consensus frequency'] = 'n/a' bases['referen...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'print_consensus'},{'id': '3', 'type': 'parameters', 'children': ['4']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 'genom...
def print_consensus(genomes): cons = {} for genome, contigs in list(genomes.items()): cons[genome] = {} for contig, samples in list(contigs.items()): for sample, stats in list(samples.items()): if sample not in cons[genome]: cons[genome][sample] = ...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_cov'},{'id': '3', 'type': 'parameters', 'children': ['4', '5']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 'cov_ta...
def parse_cov(cov_table, scaffold2genome): size = {} mapped = {} for line in open(cov_table): line = line.strip().split('\t') if line[0].startswith(' samples = line[1:] samples = [i.rsplit('/', 1)[-1].split('.', 1)[0] for i in samples] continue s...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'print_genome_matrix'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']},{'id': '4', 'type': 'identifier', 'children': ...
def print_genome_matrix(hits, fastas, id2desc, file_name): out = open(file_name, 'w') fastas = sorted(fastas) print(' print(' for fasta in fastas: line = [fasta] for other in fastas: if other == fasta: average = '-' else: averag...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'ERROR', 'children': ['2', '298', '304']},{'id': '2', 'type': 'function_definition', 'children': ['3', '4', '17']},{'id': '3', 'type': 'function_name', 'children': [], 'value': 'calc_thresholds'},{'id': '4', 'type': 'parameters', 'children': ['5', '6'...
def calc_thresholds(rbh, file_name, thresholds = [False, False, False, False], stdevs = 2): calc_threshold = thresholds[-1] norm_threshold = {} for pair in itertools.permutations([i for i in rbh], 2): if pair[0] not in norm_threshold: norm_threshold[pair[0]] = {} norm_threshold[p...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']},{'id': '2', 'type': 'function_name', 'children': [], 'value': '_update_property'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']},{'id': '4', 'type': 'identifier', 'children': [],...
def _update_property(tree_to_update, xpath_root, xpaths, values): def update_element(elem, idx, root, path, vals): has_root = bool(root and len(path) > len(root) and path.startswith(root)) path, attr = get_xpath_tuple(path) if attr: removed = [get_element(elem, path)] ...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'validate_complex_list'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']},{'id': '4', 'type': 'identifier', 'children': [],...
def validate_complex_list(prop, value, xpath_map=None): if value is not None: validate_type(prop, value, (dict, list)) if prop in _complex_definitions: complex_keys = _complex_definitions[prop] else: complex_keys = {} if xpath_map is None else xpath_map for id...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'validate_dates'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']},{'id': '4', 'type': 'identifier', 'children': [], 'value...
def validate_dates(prop, value, xpath_map=None): 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: if prop in _complex_definitions: complex...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'getCharacterSet'},{'id': '3', 'type': 'parameters', 'children': ['4']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'...
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 = self.next...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'getSequence'},{'id': '3', 'type': 'parameters', 'children': ['4', '5']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 'self...
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....
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'process'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']},{'id': '4', 'type': 'identifier', 'children': [], 'value':...
def process(self, data, type, history): if type in history: return if type.enum(): return history.append(type) resolved = type.resolve() value = None if type.multi_occurrence(): value = [] else: if len(resolved) > 0:...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']},{'id': '2', 'type': 'function_name', 'children': [], 'value': '_process_tz'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']},{'id': '4', 'type': 'identifier', 'children': [], 'val...
def _process_tz(self, dt, naive, tz): 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 if not isinstance(t, tzinfo): if __debug__ and not local...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']},{'id': '2', 'type': 'function_name', 'children': [], 'value': '__dfs'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']},{'id': '4', 'type': 'identifier', 'children': [], 'value': '...
def __dfs(self, v, index, layers): if index == 0: path = [v] while self._dfs_parent[v] != v: path.append(self._dfs_parent[v]) v = self._dfs_parent[v] self._dfs_paths.append(path) return True for neighbour in self._graph[v]: ...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'login'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']},{'id': '4', 'type': 'identifier', 'children': [], 'value': ...
def login(self, username, password, login_token=None): if login_token is None: token_doc = self.post(action='query', meta='tokens', type='login') login_token = token_doc['query']['tokens']['logintoken'] login_doc = self.post( action="clientlogin", username=username, p...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'cut_levels'},{'id': '3', 'type': 'parameters', 'children': ['4', '5']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 'nodes...
def cut_levels(nodes, start_level): final = [] removed = [] for node in nodes: if not hasattr(node, 'level'): remove(node, removed) continue if node.attr.get('soft_root', False): remove(node, removed) continue if node.level == start_lev...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'S'},{'id': '3', 'type': 'parameters', 'children': ['4', '5']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 'Document'},{'i...
def S(Document, *fields): result = [] for field in fields: if isinstance(field, tuple): field, direction = field result.append((field, direction)) continue direction = ASCENDING if not field.startswith('__'): field = field.replace('__', '.') if field[0] == '-': direction = DESCENDING if field...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'valid'},{'id': '3', 'type': 'parameters', 'children': ['4', '5']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'},{'i...
def valid(self, cnpj): if len(cnpj) != 14: return False tam = 12 nums = cnpj[:tam] digs = cnpj[tam:] tot = 0 pos = tam-7 for i in range(tam, 0, -1): tot = tot + int(nums[tam-i])*pos pos = pos - 1 if pos < 2: ...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'arrayuniqify'},{'id': '3', 'type': 'parameters', 'children': ['4', '5']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 'X'}...
def arrayuniqify(X, retainorder=False): s = X.argsort() X = X[s] D = np.append([True],X[1:] != X[:-1]) if retainorder: DD = np.append(D.nonzero()[0],len(X)) ind = [min(s[x:DD[i+1]]) for (i,x) in enumerate(DD[:-1])] ind.sort() return ind else: return [D,s]
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'equalspairs'},{'id': '3', 'type': 'parameters', 'children': ['4', '5']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 'X'},...
def equalspairs(X, Y): T = Y.copy() R = (T[1:] != T[:-1]).nonzero()[0] R = np.append(R,np.array([len(T)-1])) M = R[R.searchsorted(range(len(T)))] D = T.searchsorted(X) T = np.append(T,np.array([0])) M = np.append(M,np.array([0])) A = (T[D] == X) * D B = (T[D] == X) * (M[D] + 1) r...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '22']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'loadSV'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20']},{'id': '4', 'type': 'identifier', 'chil...
def loadSV(fname, shape=None, titles=None, aligned=False, byteorder=None, renamer=None, **kwargs): [columns, metadata] = loadSVcols(fname, **kwargs) if 'names' in metadata.keys(): names = metadata['names'] else: names = None if 'formats' in metadata.keys(): formats =...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '22']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'loadSVrecs'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20']},{'id': '4', 'type': 'identifier', '...
def loadSVrecs(fname, uselines=None, skiprows=0, linefixer=None, delimiter_regex=None, verbosity=DEFAULT_VERBOSITY, **metadata): if delimiter_regex and isinstance(delimiter_regex, types.StringType): import re delimiter_regex = re.compile(delimiter_regex) [metadata, inferedlines,...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9', '13']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'dflt_interval'},{'id': '3', 'type': 'parameters', 'children': ['4', '5']},{'id': '4', 'type': 'identifier', 'children': [], 'value...
def dflt_interval(self, cd_id: str) -> (int, int): LOGGER.debug('RevocationCache.dflt_interval >>>') fro = None to = None for rr_id in self: if cd_id != rev_reg_id2cred_def_id(rr_id): continue entry = self[rr_id] if entry.rr_delta_frame...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13', '15']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse'},{'id': '3', 'type': 'parameters', 'children': ['4', '8']},{'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']},...
def parse(base_dir: str, timestamp: int = None) -> int: LOGGER.debug('parse >>> base_dir: %s, timestamp: %s', base_dir, timestamp) if not isdir(base_dir): LOGGER.info('No cache archives available: not feeding cache') LOGGER.debug('parse <<< None') return None ...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']},{'id': '2', 'type': 'function_name', 'children': [], 'value': '_convert_hbf_meta_val_for_xml'},{'id': '3', 'type': 'parameters', 'children': ['4', '5']},{'id': '4', 'type': 'identifier', 'children': ...
def _convert_hbf_meta_val_for_xml(key, val): if isinstance(val, list): return [_convert_hbf_meta_val_for_xml(key, i) for i in val] is_literal = True content = None if isinstance(val, dict): ret = val if '@href' in val: is_literal = False else: cont...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'validate_params_match'},{'id': '3', 'type': 'parameters', 'children': ['4', '5']},{'id': '4', 'type': 'identifier', 'children': [], 'val...
def validate_params_match(method, parameters): argspec = inspect.getargspec(method) default_length = len(argspec.defaults) if argspec.defaults is not None else 0 if isinstance(parameters, list): if len(parameters) > len(argspec.args) and argspec.varargs is None: raise InvalidParamsError(...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'addcols'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 'X'}...
def addcols(X, cols, names=None): if isinstance(names,str): names = [n.strip() for n in names.split(',')] if isinstance(cols, list): if any([isinstance(x,np.ndarray) or isinstance(x,list) or \ isinstance(x,tuple) for x in cols]): assert all([len(x...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'replace'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13']},{'id': '4', 'type': 'identifier', 'children':...
def replace(X, old, new, strict=True, cols=None, rows=None): if cols == None: cols = X.dtype.names elif isinstance(cols, str): cols = cols.split(',') if rows == None: rows = np.ones((len(X),), bool) if strict: new = np.array(new) for a in cols: if X.dt...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'rowstack'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 's...
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** ...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'colstack'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 's...
def colstack(seq, mode='abort',returnnaming=False): assert mode in ['first','drop','abort','rename'], \ 'mode argument must take on value "first","drop", "rename", or "abort".' AllNames = utils.uniqify(utils.listunion( [list(l.dtype.names) for l in seq])) Na...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'getjp2image'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17']},{'id': '4', 'type': 'identifier', 'child...
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...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20', '26']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'loads_loader'},{'id': '3', 'type': 'parameters', 'children': ['4', '10']},{'id': '4', 'type': 'typed_parameter', 'children': ['5'...
def loads_loader(load_module: types.ModuleType, pairs: Dict[str, str]) -> Optional[JSGValidateable]: cntxt = load_module._CONTEXT possible_type = pairs[cntxt.TYPE] if cntxt.TYPE in pairs else None target_class = getattr(load_module, possible_type, None) if isinstance(possible_type, str) else None if tar...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9', '11']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_cred_def'},{'id': '3', 'type': 'parameters', 'children': ['4', '5']},{'id': '4', 'type': 'identifier', 'children': [], 'value'...
async def get_cred_def(self, cd_id: str) -> str: LOGGER.debug('_BaseAgent.get_cred_def >>> cd_id: %s', cd_id) rv_json = json.dumps({}) with CRED_DEF_CACHE.lock: if cd_id in CRED_DEF_CACHE: LOGGER.info('_BaseAgent.get_cred_def: got cred def for %s from cache', cd_id) ...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'convert_nexson_format'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15']},{'id': '4', 'type': 'identifier...
def convert_nexson_format(blob, out_nexson_format, current_format=None, remove_old_structs=True, pristine_if_invalid=False, sort_arbitrary=False): if not current_format: current_...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']},{'id': '2', 'type': 'function_name', 'children': [], 'value': '_inplace_sort_by_id'},{'id': '3', 'type': 'parameters', 'children': ['4']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 'u...
def _inplace_sort_by_id(unsorted_list): if not isinstance(unsorted_list, list): return sorted_list = [(i.get('@id'), i) for i in unsorted_list] sorted_list.sort() del unsorted_list[:] unsorted_list.extend([i[1] for i in sorted_list])
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'cull_nonmatching_trees'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']},{'id': '4', 'type': 'identifier', 'children': []...
def cull_nonmatching_trees(nexson, tree_id, curr_version=None): if curr_version is None: curr_version = detect_nexson_version(nexson) if not _is_by_id_hbf(curr_version): nexson = convert_nexson_format(nexson, BY_ID_HONEY_BADGERFISH) nexml_el = get_nexml_el(nexson) tree_groups = nexml_el[...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18', '30']},{'id': '2', 'type': 'function_name', 'children': [], 'value': '_validate'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '9']},{'id': '4', 'type': 'identifier', 'children': [], 'val...
def _validate(self, val: list, log: Optional[Logger] = None) -> Tuple[bool, List[str]]: errors = [] if not isinstance(val, list): errors.append(f"{self._variable_name}: {repr(val)} is not an array") else: for i in range(0, len(val)): v = val[i] ...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14', '16']},{'id': '2', 'type': 'function_name', 'children': [], 'value': '_sync_revoc'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '9']},{'id': '4', 'type': 'identifier', 'children': [], 'v...
async def _sync_revoc(self, rr_id: str, rr_size: int = None) -> None: LOGGER.debug('Issuer._sync_revoc >>> rr_id: %s, rr_size: %s', rr_id, rr_size) (cd_id, tag) = rev_reg_id2cred_def_id__tag(rr_id) try: await self.get_cred_def(cd_id) except AbsentCredDef: LOGGER.d...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_namespace_uri'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']},{'id': '4', 'type': 'identifier', 'children': [...
def add_namespace_uri(self, ns_uri, prefix=None, schema_location=None): assert ns_uri if ns_uri in self.__ns_uri_map: ni = self.__lookup_uri(ns_uri) new_ni = copy.deepcopy(ni) if prefix: self.__check_prefix_conflict(ni, prefix) new_ni.p...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_schemaloc_string'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']},{'id': '4', 'type': 'identifier', 'children...
def get_schemaloc_string(self, ns_uris=None, sort=False, delim="\n"): if not ns_uris: ns_uris = six.iterkeys(self.__ns_uri_map) if sort: ns_uris = sorted(ns_uris) schemalocs = [] for ns_uri in ns_uris: ni = self.__lookup_uri(ns_uri) if ni.s...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'tab_join'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17']},{'id': '4', 'type': 'identifier', 'children...
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 = t...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '26']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'aggregate'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20', '23']},{'id': '4', 'type': 'identifie...
def aggregate(self, On=None, AggFuncDict=None, AggFunc=None, AggList = None, returnsort=False,KeepOthers=True, keyfuncdict=None): if returnsort: [data, s] = spreadsheet.aggregate(X=self, On=On, AggFuncDict=AggFuncDict, ...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'argsort'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '9', '12']},{'id': '4', 'type': 'identifier', 'children': [], 'value...
def argsort(self, axis=-1, kind='quicksort', order=None): index_array = np.core.fromnumeric._wrapit(self, 'argsort', axis, kind, order) index_array = index_array.view(np.ndarray) return index_array
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']},{'id': '2', 'type': 'function_name', 'children': [], 'value': '_finalize_namespaces'},{'id': '3', 'type': 'parameters', 'children': ['4', '5']},{'id': '4', 'type': 'identifier', 'children': [], 'valu...
def _finalize_namespaces(self, ns_dict=None): if ns_dict: for ns, alias in six.iteritems(ns_dict): self._collected_namespaces.add_namespace_uri(ns, alias) self._collected_namespaces.add_namespace_uri( ns_uri=idgen.get_id_namespace(), prefix=idgen.get_i...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_empty_fields'},{'id': '3', 'type': 'parameters', 'children': ['4', '5']},{'id': '4', 'type': 'identifier', 'children': [], 'value...
def update_empty_fields(self, **kwargs): if self._is_deprecated is None: self._is_deprecated = kwargs.get('is_deprecated') if self._is_dubious is None: self._is_dubious = kwargs.get('is_dubious') if self._is_synonym is None: self._is_synonym = kwargs.get('is_s...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '19', '25']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_creds'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '9', '14']},{'id': '4', 'type': 'identifier', 'children': []...
async def get_creds(self, proof_req_json: str, filt: dict = None, filt_dflt_incl: bool = False) -> (Set[str], str): LOGGER.debug('HolderProver.get_creds >>> proof_req_json: %s, filt: %s', proof_req_json, filt) if filt is None: filt = {} rv = None creds_json = await anoncreds....
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'summary'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 'pro...
def summary(processors, metrics, context): def display_header(processors, before='', after=''): print(before, end=' ') for processor in processors: processor.display_header() print(after) def display_separator(processors, before='', after=''): print(before, end=' ') ...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'run_experiment'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10']},{'id': '4', 'type': 'identifier', 'children'...
def run_experiment(experiment, roleouts, episodes, in_cloud=False, dynProfile=None): def run(): if dynProfile is None: maxsteps = len(experiment.profile) else: maxsteps = dynProfile.shape[1] na = len(experiment.agents) ni = roleouts * episod...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'total_cost'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']},{'id': '4', 'type': 'identifier', 'children': [], 'va...
def total_cost(self, p=None, p_cost=None, pcost_model=None): 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_model p = 0.0 if not self.online else p if pcost_model == PW_LINEAR: ...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'offers_to_pwl'},{'id': '3', 'type': 'parameters', 'children': ['4', '5']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
def offers_to_pwl(self, offers): assert not self.is_load g_offers = [offer for offer in offers if offer.generator == self] gt_zero = [offr for offr in g_offers if round(offr.quantity, 4) > 0.0] valid = [offer for offer in gt_zero if not offer.withheld] p_offers = [v for v in vali...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'bids_to_pwl'},{'id': '3', 'type': 'parameters', 'children': ['4', '5']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 'self...
def bids_to_pwl(self, bids): assert self.is_load vl_bids = [bid for bid in bids if bid.vLoad == self] gt_zero = [bid for bid in vl_bids if round(bid.quantity, 4) > 0.0] valid_bids = [bid for bid in gt_zero if not bid.withheld] p_bids = [v for v in valid_bids if not v.reactive] ...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'DoxyfileParse'},{'id': '3', 'type': 'parameters', 'children': ['4']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 'file_co...
def DoxyfileParse(file_contents): data = {} import shlex lex = shlex.shlex(instream = file_contents, posix = True) lex.wordchars += "*+./-:" lex.whitespace = lex.whitespace.replace("\n", "") lex.escape = "" lineno = lex.lineno token = lex.get_token() key = token last_token = "" key_toke...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'DoxySourceScan'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']},{'id': '4', 'type': 'identifier', 'children': [], 'value...
def DoxySourceScan(node, env, path): default_file_patterns = [ '*.c', '*.cc', '*.cxx', '*.cpp', '*.c++', '*.java', '*.ii', '*.ixx', '*.ipp', '*.i++', '*.inl', '*.h', '*.hh ', '*.hxx', '*.hpp', '*.h++', '*.idl', '*.odl', '*.cs', '*.php', '*.php3', '*.inc', '*.m', '*.mm', '*.py', ] defaul...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']},{'id': '2', 'type': 'function_name', 'children': [], 'value': '_quadratic_costs'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']},{'id': '4', 'type': 'identifier', 'children'...
def _quadratic_costs(self, generators, ipol, nxyz, base_mva): 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) > 3]: logger.error("Order of polynomial cost greater than quadratic.") ...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']},{'id': '2', 'type': 'function_name', 'children': [], 'value': '_gh'},{'id': '3', 'type': 'parameters', 'children': ['4', '5']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'},{'id'...
def _gh(self, x): Pgen = x[self._Pg.i1:self._Pg.iN + 1] Qgen = x[self._Qg.i1:self._Qg.iN + 1] for i, gen in enumerate(self._gn): gen.p = Pgen[i] * self._base_mva gen.q = Qgen[i] * self._base_mva Sbus = self.om.case.getSbus(self._bs) Vang = x[self._Va.i1:se...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'performAction'},{'id': '3', 'type': 'parameters', 'children': ['4', '5']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
def performAction(self, action): 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)) for i, g in enumerate(gs): g.p = action[i] NewtonPF(self.case, verbose=False).solve() ...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20', '28']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'blt'},{'id': '3', 'type': 'parameters', 'children': ['4', '12']},{'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']},{...
def blt(f: List[SYM], x: List[SYM]) -> Dict[str, Any]: J = ca.jacobian(f, x) nblock, rowperm, colperm, rowblock, colblock, coarserow, coarsecol = J.sparsity().btf() return { 'J': J, 'nblock': nblock, 'rowperm': rowperm, 'colperm': colperm, 'rowblock': rowblock, ...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_generators'},{'id': '3', 'type': 'parameters', 'children': ['4']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'...
def sort_generators(self): self.generators.sort(key=lambda gn: gn.bus._i)
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'create'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']},{'id': '4', 'type': 'identifier', 'children': [], 'value':...
def create(self, dotdata, prog="dot", format="xdot"): import os, tempfile from dot2tex.dotparsing import find_graphviz progs = find_graphviz() if progs is None: logger.warning("GraphViz executables not found.") return None if not progs.has_key(prog): ...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'format'},{'id': '3', 'type': 'parameters', 'children': ['4', '5']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 'file_metr...
def format(file_metrics, build_metrics): 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(): elem.tail = i for ele...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'governor'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']},{'id': '4', 'type': 'identifier', 'children': [], 'value'...
def governor(self, Xgov, Pgov, Vgov): governors = self.governors omegas = 2 * pi * self.freq F = zeros(Xgov.shape) typ1 = [g.generator._i for g in governors if g.model == CONST_POWER] typ2 = [g.generator._i for g in governors if g.model == GENERAL_IEEE] F[typ1, 0] = 0 ...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'generator'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']},{'id': '4', 'type': 'identifier', 'children': [], '...
def generator(self, Xgen, Xexc, Xgov, Vgen): generators = self.dyn_generators omegas = 2 * pi * self.freq F = zeros(Xgen.shape) typ1 = [g._i for g in generators if g.model == CLASSICAL] typ2 = [g._i for g in generators if g.model == FOURTH_ORDER] omega = Xgen[typ1, 1] ...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']},{'id': '2', 'type': 'function_name', 'children': [], 'value': '_const_pf_constraints'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']},{'id': '4', 'type': 'identifier', 'children': [],...
def _const_pf_constraints(self, gn, base_mva): ivl = array([i for i, g in enumerate(gn) if g.is_load and (g.q_min != 0.0 or g.q_max != 0.0)]) vl = [gn[i] for i in ivl] nvl = len(vl) ng = len(gn) Pg = array([g.p for g in vl]) / base_mva Qg = array([g.q...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']},{'id': '2', 'type': 'function_name', 'children': [], 'value': '_voltage_angle_diff_limit'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']},{'id': '4', 'type': 'identifier', 'children':...
def _voltage_angle_diff_limit(self, buses, branches): 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)) or (b.ang_max and (b.ang_max < 360.0))] iangl = array([i for...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']},{'id': '2', 'type': 'function_name', 'children': [], 'value': '_clipPrices'},{'id': '3', 'type': 'parameters', 'children': ['4']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'},{'...
def _clipPrices(self): if self.guaranteeOfferPrice: for offer in self.offers: if offer.accepted and offer.clearedPrice < offer.price: offer.clearedPrice = offer.price if self.guaranteeBidPrice: for bid in self.bids: if bid.accep...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'gpu_iuwt_decomposition'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']},{'id': '4', 'type': 'identifier', 'chi...
def gpu_iuwt_decomposition(in1, scale_count, scale_adjust, store_smoothed, store_on_gpu): ker = SourceModule( ) wavelet_filter = (1./16)*np.array([1,4,6,4,1], dtype=np.float32) wavelet_filter = gpuarray.to_gpu_async(wavelet_filter) detail_coeffs = gpuarray.empty([scale_count-scale_adjust, in1.shape[0], ...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'gpu_iuwt_recomposition'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']},{'id': '4', 'type': 'identifier', 'children...
def gpu_iuwt_recomposition(in1, scale_adjust, store_on_gpu, smoothed_array): wavelet_filter = (1./16)*np.array([1,4,6,4,1], dtype=np.float32) wavelet_filter = gpuarray.to_gpu_async(wavelet_filter) max_scale = in1.shape[0] + scale_adjust if smoothed_array is None: recomposition = gpuarray.zeros([...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_config'},{'id': '3', 'type': 'parameters', 'children': ['4']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 'config'},...
def from_config(config): matrix = {} variables = config.keys() for entries in product(*config.values()): combination = dict(zip(variables, entries)) include = True for value in combination.values(): for reducer in value.reducers: if reducer.pattern == '-':...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '71']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'moresane_by_scale'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20', '23', '26', '29', '32', '35',...
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...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_or_create'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14']},{'id': '4', 'type': 'identifier', 'children...
def load_or_create(cls, filename=None, no_input=False, create_new=False, **kwargs): parser = argparse.ArgumentParser() parser.add_argument('--no_input', action='store_true') parser.add_argument('--create_new', action='store_true') args = parser.parse_args() if args.no_input: ...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'cleanup'},{'id': '3', 'type': 'parameters', 'children': ['4']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'},{'id':...
def cleanup(self): 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.logger.debug('Timers cancelled') for i in self.objects:...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'write_puml'},{'id': '3', 'type': 'parameters', 'children': ['4', '5']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'...
def write_puml(self, filename=''): def get_type(o): type = 'program' if isinstance(o, AbstractSensor): type = 'sensor' elif isinstance(o, AbstractActuator): type = 'actuator' return type if filename: s = open(fil...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'fit'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'},...
def fit(self, X, y=None): N = X.shape[0] if y is None: y = np.zeros(N) self.classes = list(set(y)) self.classes.sort() self.n_classes = len(self.classes) if not self.sigma: self.sigma = median_kneighbour_distance(X) self.gamma = self.si...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'predict_sequence'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']},{'id': '4', 'type': 'identifier', 'children...
def predict_sequence(self, X, A, pi, inference='smoothing'): obsll = self.predict_proba(X) T, S = obsll.shape alpha = np.zeros((T, S)) alpha[0, :] = pi for t in range(1, T): alpha[t, :] = np.dot(alpha[t-1, :], A) for s in range(S): alpha[t,...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_bgcolor'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']},{'id': '4', 'type': 'identifier', 'children': [...
def add_bgcolor(self, colname, cmap='copper', mode='absmax', threshold=2): try: cmap = cmap_builder(cmap) except: pass data = self.df[colname].values if len(data) == 0: return if mode == 'clip': data = [min(x, threshold)...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'list'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17']},{'id': '4', 'type': 'identifier', 'children': [...
def list(self, filter=None, type=None, sort=None, limit=None, page=None): schema = self.LIST_SCHEMA resp = self.service.list(self.base, filter, type, sort, limit, page) cs, l = self.service.decode(schema, resp, many=True, links=True) return Page(cs, l)
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'signup_handler'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']},{'id': '4', 'type': 'identifier', 'children': [], 'value...
def signup_handler(remote, *args, **kwargs): if current_user.is_authenticated: return redirect('/') oauth_token = token_getter(remote) if not oauth_token: return redirect('/') session_prefix = token_session_key(remote.name) if not session.get(session_prefix + '_autoregister', False):...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'list_csv'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17']},{'id': '4', 'type': 'identifier', 'children...
def list_csv(self, filter=None, type=None, sort=None, limit=None, page=None): return self.service.list(self.base, filter, type, sort, limit, page, format='csv').text
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'list_logdir'},{'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']},{'id': '4', 'type': 'identifier', 'children': [], 'va...
def list_logdir(self, id, filter=None, sort=None): schema = LogDirFileSchema() resp = self.service.list(self.base+str(id)+'/logdir/', filter, sort) return self.service.decode(schema, resp, many=True)
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']},{'id': '2', 'type': 'function_name', 'children': [], 'value': '_init_report'},{'id': '3', 'type': 'parameters', 'children': ['4']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'},{...
def _init_report(self): self.sections = [] self.section_names = [] try: if os.path.isdir(self.directory) is False: if self.verbose: print("Created directory {}".format(self.directory)) os.mkdir(self.directory) for this i...
{'id': '0', 'type': 'module', 'children': ['1']},{'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']},{'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_instance'},{'id': '3', 'type': 'parameters', 'children': ['4']},{'id': '4', 'type': 'identifier', 'children': [], 'value': 'functi...
def check_instance(function): def wrapper(self, *args, **kwargs): func_trans = { "commit": manager.Manager, "compare_config": manager.Manager, "commit_check": manager.Manager, "device_info": manager.Manager, "diff_config...