sequence
stringlengths
492
15.9k
code
stringlengths
75
8.58k
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:get_sh_ids; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:identity; 6, identifier:backend_name; 7, block; 7, 8; 7, 19; 7, 29; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:identity_tuple; 11, ca...
def get_sh_ids(self, identity, backend_name): identity_tuple = tuple(identity.items()) sh_ids = self.__get_sh_ids_cache(identity_tuple, backend_name) return sh_ids
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_sh_identity; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:item; 6, default_parameter; 6, 7; 6, 8; 7, identifier:identity_field; 8, None; 9, block; 9, 10; 9, 60; 9, 64; 9, 77; 9, 81; 9, 101; 9, 109; 10, function_definit...
def get_sh_identity(self, item, identity_field=None): def fill_list_identity(identity, user_list_data): identity['username'] = user_list_data[0]['__text__'] if '@' in identity['username']: identity['email'] = identity['username'] if 'name' in user_list_data[0]...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:feed; 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:from_date; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:from_offset; 10, None; 11, default_para...
def feed(self, from_date=None, from_offset=None, category=None, latest_items=None, arthur_items=None, filter_classified=None): if self.fetch_archive: items = self.perceval_backend.fetch_from_archive() self.feed_items(items) return elif arthur_items: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_identities; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:item; 6, block; 6, 7; 6, 156; 6, 164; 6, 270; 6, 376; 7, function_definition; 7, 8; 7, 9; 7, 13; 8, function_name:add_sh_github_identity; 9, parameters; 9, 10; 9, 11; ...
def get_identities(self, item): def add_sh_github_identity(user, user_field, rol): github_repo = None if GITHUB in item['origin']: github_repo = item['origin'].replace(GITHUB, '') github_repo = re.sub('.git$', '', github_repo) if not github_rep...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:areas_of_code; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:git_enrich; 5, identifier:in_conn; 6, identifier:out_conn; 7, default_parameter; 7, 8; 7, 9; 8, identifier:block_size; 9, integer:100; 10, block; 10, 11; 10, 29; 10, 37; 11, e...
def areas_of_code(git_enrich, in_conn, out_conn, block_size=100): aoc = AreasOfCode(in_connector=in_conn, out_connector=out_conn, block_size=block_size, git_enrich=git_enrich) ndocs = aoc.analyze() return ndocs
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_make_serializer; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:meas; 5, identifier:schema; 6, identifier:rm_none; 7, identifier:extra_tags; 8, identifier:placeholder; 9, block; 9, 10; 9, 16; 9, 20; 9, 24; 9, 28; 9, 32; 9, 177; 9, ...
def _make_serializer(meas, schema, rm_none, extra_tags, placeholder): _validate_schema(schema, placeholder) tags = [] fields = [] ts = None meas = meas for k, t in schema.items(): if t is MEASUREMENT: meas = f"{{i.{k}}}" elif t is TIMEINT: ts = f"{{i.{k}}}...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 1, 23; 2, function_name:iterpoints; 3, parameters; 3, 4; 3, 8; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:resp; 6, type; 6, 7; 7, identifier:dict; 8, typed_default_parameter; 8, 9; 8, 10; 8, 16; 9, identifier:parser; 10, type; 10, 11; 11, generic_type; 11, ...
def iterpoints(resp: dict, parser: Optional[Callable] = None) -> Iterator[Any]: for statement in resp['results']: if 'series' not in statement: continue for series in statement['series']: if parser is None: return (x for x in series['values']) elif...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 1, 13; 2, function_name:serialize; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:df; 5, identifier:measurement; 6, default_parameter; 6, 7; 6, 8; 7, identifier:tag_columns; 8, None; 9, dictionary_splat_pattern; 9, 10; 10, identifier:extra_tags; 11, type...
def serialize(df, measurement, tag_columns=None, **extra_tags) -> bytes: if measurement is None: raise ValueError("Missing 'measurement'") if not isinstance(df.index, pd.DatetimeIndex): raise ValueError('DataFrame index is not DatetimeIndex') tag_columns = set(tag_columns or []) isnull =...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:get_my_feed; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:limit; 7, integer:150; 8, default_parameter; 8, 9; 8, 10; 9, identifier:offset; 10, integer:20; 11, default_paramet...
def get_my_feed(self, limit=150, offset=20, sort="updated", nid=None): r = self.request( method="network.get_my_feed", nid=nid, data=dict( limit=limit, offset=offset, sort=sort ) ) return self._handle...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:filter_feed; 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:updated; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:following; 10, False; 11, default...
def filter_feed(self, updated=False, following=False, folder=False, filter_folder="", sort="updated", nid=None): assert sum([updated, following, folder]) == 1 if folder: assert filter_folder if updated: filter_type = dict(updated=1) elif follow...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_dataset; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:dataset; 6, block; 6, 7; 6, 11; 6, 19; 6, 216; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:success; 10, True; 11, expression_statement; 11, 1...
def get_dataset(self, dataset): success = True dataset_path = self.base_dataset_path + dataset if not isdir(dataset_path): was_error = False for iteration in range(5): if iteration == 0 or was_error is True: zip_path = dataset_path + "....
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 32; 2, function_name:install; 3, parameters; 3, 4; 3, 7; 3, 27; 3, 30; 4, default_parameter; 4, 5; 4, 6; 5, identifier:verbose; 6, True; 7, default_parameter; 7, 8; 7, 9; 8, identifier:verbose_destination; 9, conditional_expression:if; 9, 10; 9, 17; 9, 24; 10, cal...
def install(verbose=True, verbose_destination=sys.__stderr__.fileno() if hasattr(sys.__stderr__, 'fileno') else sys.__stderr__, strict=True, **kwargs): global _MANHOLE with _LOCK: if _MANHOLE is None: _MANHOLE = Manhole() else: if stric...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 37; 2, function_name:update; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 3, 25; 3, 28; 3, 31; 3, 34; 4, identifier:self; 5, identifier:alert_condition_nrql_id; 6, identifier:policy_id; 7, default_parameter; 7, 8; 7, 9; 8, identifier:n...
def update( self, alert_condition_nrql_id, policy_id, name=None, threshold_type=None, query=None, since_value=None, terms=None, expected_groups=None, value_function=None, runbook_url=None, ignore_overlap=None, enabled=True): conditions_nrql_dict = self.list(policy_id) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 26; 2, function_name:create; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 4, identifier:self; 5, identifier:policy_id; 6, identifier:name; 7, identifier:threshold_type; 8, identifier:query; 9, identifier:since_value;...
def create( self, policy_id, name, threshold_type, query, since_value, terms, expected_groups=None, value_function=None, runbook_url=None, ignore_overlap=None, enabled=True): data = { 'nrql_condition': { 'type': threshold_type, 'nam...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 34; 2, function_name:update; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 3, 25; 3, 28; 3, 31; 4, identifier:self; 5, identifier:alert_condition_id; 6, identifier:policy_id; 7, default_parameter; 7, 8; 7, 9; 8, identifier:type; 9, None...
def update( self, alert_condition_id, policy_id, type=None, condition_scope=None, name=None, entities=None, metric=None, runbook_url=None, terms=None, user_defined=None, enabled=None): conditi...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:operatorPrecedence; 3, parameters; 3, 4; 3, 5; 4, identifier:base; 5, identifier:operators; 6, block; 6, 7; 6, 13; 6, 29; 6, 49; 6, 214; 6, 218; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:expression; 10, call; 10, ...
def operatorPrecedence(base, operators): expression = Forward() last = base | Suppress('(') + expression + Suppress(')') def parse_operator(expr, arity, association, action=None, extra=None): return expr, arity, association, action, extra for op in operators: expr, arity, association, ac...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:readGraph; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:edgeList; 5, default_parameter; 5, 6; 5, 7; 6, identifier:nodeList; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:directed; 10, False; 11, default_param...
def readGraph(edgeList, nodeList = None, directed = False, idKey = 'ID', eSource = 'From', eDest = 'To'): progArgs = (0, "Starting to reading graphs") if metaknowledge.VERBOSE_MODE: progKwargs = {'dummy' : False} else: progKwargs = {'dummy' : True} with _ProgressBar(*progArgs, **progKwar...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:writeGraph; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:grph; 5, identifier:name; 6, default_parameter; 6, 7; 6, 8; 7, identifier:edgeInfo; 8, True; 9, default_parameter; 9, 10; 9, 11; 10, identifier:typing; 11, F...
def writeGraph(grph, name, edgeInfo = True, typing = False, suffix = 'csv', overwrite = True, allSameAttribute = False): progArgs = (0, "Writing the graph to files starting with: {}".format(name)) if metaknowledge.VERBOSE_MODE: progKwargs = {'dummy' : False} else: progKwargs = {'dummy' : Tru...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:mergeGraphs; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:targetGraph; 5, identifier:addedGraph; 6, default_parameter; 6, 7; 6, 8; 7, identifier:incrementedNodeVal; 8, string:'count'; 9, default_parameter; 9, 10; 9, 11; 10, identifier:...
def mergeGraphs(targetGraph, addedGraph, incrementedNodeVal = 'count', incrementedEdgeVal = 'weight'): for addedNode, attribs in addedGraph.nodes(data = True): if incrementedNodeVal: try: targetGraph.node[addedNode][incrementedNodeVal] += attribs[incrementedNodeVal] e...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:writeRecord; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:f; 6, block; 6, 7; 7, if_statement; 7, 8; 7, 11; 7, 27; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:bad; 11, block; 11, 12; 12, raise_statement; 12, 13;...
def writeRecord(self, f): if self.bad: raise BadPubmedRecord("This record cannot be converted to a file as the input was malformed.\nThe original line number (if any) is: {} and the original file is: '{}'".format(self._sourceLine, self._sourceFile)) else: authTags = {} ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 32; 2, function_name:graphDensityContourPlot; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 4, identifier:G; 5, default_parameter; 5, 6; 5, 7; 6, identifier:iters; 7, integer:50; 8, default_parameter; 8, 9; 8, 10; 9, identifier:...
def graphDensityContourPlot(G, iters = 50, layout = None, layoutScaleFactor = 1, overlay = False, nodeSize = 10, axisSamples = 100, blurringFactor = .1, contours = 15, graphType = 'coloured'): from mpl_toolkits.mplot3d import Axes3D if not isinstance(G, nx.classes.digraph.DiGraph) and not isinstance(G, nx.class...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:makeNodeTuple; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 3, 13; 4, identifier:citation; 5, identifier:idVal; 6, identifier:nodeInfo; 7, identifier:fullInfo; 8, identifier:nodeType; 9, identifier:count; 10, identif...
def makeNodeTuple(citation, idVal, nodeInfo, fullInfo, nodeType, count, coreCitesDict, coreValues, detailedValues, addCR): d = {} if nodeInfo: if nodeType == 'full': if coreValues: if citation in coreCitesDict: R = coreCitesDict[citation] ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:expandRecs; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:G; 5, identifier:RecCollect; 6, identifier:nodeType; 7, identifier:weighted; 8, block; 8, 9; 9, for_statement; 9, 10; 9, 11; 9, 12; 10, identifier:Rec; 11, identifier:RecCollect; ...
def expandRecs(G, RecCollect, nodeType, weighted): for Rec in RecCollect: fullCiteList = [makeID(c, nodeType) for c in Rec.createCitation(multiCite = True)] if len(fullCiteList) > 1: for i, citeID1 in enumerate(fullCiteList): if citeID1 in G: for citeI...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:writeBib; 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:fname; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:maxStringLength; 10, integer:1000; 11, default...
def writeBib(self, fname = None, maxStringLength = 1000, wosMode = False, reducedOutput = False, niceIDs = True): if fname: f = open(fname, mode = 'w', encoding = 'utf-8') else: f = open(self.name[:200] + '.bib', mode = 'w', encoding = 'utf-8') f.write("%This file was gen...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:makeDict; 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:onlyTheseTags; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:longNames; 10, False; 11, default_para...
def makeDict(self, onlyTheseTags = None, longNames = False, raw = False, numAuthors = True, genderCounts = True): if onlyTheseTags: for i in range(len(onlyTheseTags)): if onlyTheseTags[i] in fullToTagDict: onlyTheseTags[i] = fullToTagDict[onlyTheseTags[i]] ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 44; 2, function_name:networkCoCitation; 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; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:dropAnon; 7, True; 8, default_parameter; 8, 9;...
def networkCoCitation(self, dropAnon = True, nodeType = "full", nodeInfo = True, fullInfo = False, weighted = True, dropNonJournals = False, count = True, keyWords = None, detailedCore = True, detailedCoreAttributes = False, coreOnly = False, expandedCore = False, addCR = False): allowedTypes = ["full", "origin...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:networkBibCoupling; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:weighted; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:fullInfo; 10, False; 11, default_parameter; 11,...
def networkBibCoupling(self, weighted = True, fullInfo = False, addCR = False): progArgs = (0, "Make a citation network for coupling") if metaknowledge.VERBOSE_MODE: progKwargs = {'dummy' : False} else: progKwargs = {'dummy' : True} with _ProgressBar(*progArgs, **...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:localCiteStats; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:pandasFriendly; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:keyType; 10, string:"citation"; 11, block; 11, 12; ...
def localCiteStats(self, pandasFriendly = False, keyType = "citation"): count = 0 recCount = len(self) progArgs = (0, "Starting to get the local stats on {}s.".format(keyType)) if metaknowledge.VERBOSE_MODE: progKwargs = {'dummy' : False} else: progKwargs ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:citeFilter; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:keyString; 7, string:''; 8, default_parameter; 8, 9; 8, 10; 9, identifier:field; 10, string:'all'; 11, default_param...
def citeFilter(self, keyString = '', field = 'all', reverse = False, caseSensitive = False): retRecs = [] keyString = str(keyString) for R in self: try: if field == 'all': for cite in R.get('citations'): if caseSensitive: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 24; 2, function_name:rankedSeries; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 4, identifier:self; 5, identifier:tag; 6, default_parameter; 6, 7; 6, 8; 7, identifier:outputFile; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:giv...
def rankedSeries(self, tag, outputFile = None, giveCounts = True, giveRanks = False, greatestFirst = True, pandasMode = True, limitTo = None): if giveRanks and giveCounts: raise mkException("rankedSeries cannot return counts and ranks only one of giveRanks or giveCounts can be True.") series...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:timeSeries; 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:tag; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:outputFile; 10, None; 11, default_param...
def timeSeries(self, tag = None, outputFile = None, giveYears = True, greatestFirst = True, limitTo = False, pandasMode = True): seriesDict = {} for R in self: try: year = R['year'] except KeyError: continue if tag is None: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:cooccurrenceCounts; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:keyTag; 6, list_splat_pattern; 6, 7; 7, identifier:countedTags; 8, block; 8, 9; 8, 27; 8, 40; 8, 62; 8, 66; 8, 83; 8, 104; 8, 267; 9, if_statement; 9, 10; 9,...
def cooccurrenceCounts(self, keyTag, *countedTags): if not isinstance(keyTag, str): raise TagError("'{}' is not a string it cannot be used as a tag.".format(keyTag)) if len(countedTags) < 1: TagError("You need to provide atleast one tag") for tag in countedTags: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:getCitations; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:field; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:values; 10, None; 11, default_parameter; 11, 12; 11, 13;...
def getCitations(self, field = None, values = None, pandasFriendly = True): retCites = [] if values is not None: if isinstance(values, (str, int, float)) or not isinstance(values, collections.abc.Container): values = [values] if field is not None: for cite...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:proQuestParser; 3, parameters; 3, 4; 4, identifier:proFile; 5, block; 5, 6; 5, 10; 5, 16; 5, 20; 5, 24; 5, 301; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:nameDict; 9, dictionary; 10, expression_statement; 10, 11; 1...
def proQuestParser(proFile): nameDict = {} recSet = set() error = None lineNum = 0 try: with open(proFile, 'r', encoding = 'utf-8') as openfile: f = enumerate(openfile, start = 1) for i in range(12): lineNum, line = next(f) while True: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:minus; 3, parameters; 3, 4; 3, 5; 4, identifier:repo_list_a; 5, identifier:repo_list_b; 6, block; 6, 7; 6, 15; 6, 27; 6, 33; 6, 60; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:included; 10, call; 10, 11; 10, 12; 11,...
def minus(repo_list_a, repo_list_b): included = defaultdict(lambda: False) for repo in repo_list_b: included[repo.full_name] = True a_minus_b = list() for repo in repo_list_a: if not included[repo.full_name]: included[repo.full_name] = True ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:__clean_and_tokenize; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:doc_list; 6, block; 6, 7; 6, 29; 6, 35; 6, 42; 6, 50; 6, 58; 6, 122; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:doc_list; 10, call;...
def __clean_and_tokenize(self, doc_list): doc_list = filter( lambda x: x is not None and len(x) <= GitSuggest.MAX_DESC_LEN, doc_list, ) cleaned_doc_list = list() tokenizer = RegexpTokenizer(r"[a-zA-Z]+") stopwords = self.__get_words_to_ignore() dic...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:__get_search_results; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:self; 5, identifier:url; 6, identifier:limit; 7, identifier:order_by; 8, identifier:sort_order; 9, identifier:filter; 10, block; 10, 11; 10, 27; 10, 59; 10,...
def __get_search_results(self, url, limit, order_by, sort_order, filter): order_by_options = ['search_rank', 'series_id', 'title', 'units', 'frequency', 'seasonal_adjustment', 'realtime_start', 'realtime_end', 'last_updated', 'observation_start', 'observat...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:search; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, identifier:text; 6, default_parameter; 6, 7; 6, 8; 7, identifier:limit; 8, integer:1000; 9, default_parameter; 9, 10; 9, 11; 10, identifier:order_by; 11, None;...
def search(self, text, limit=1000, order_by=None, sort_order=None, filter=None): url = "%s/series/search?search_text=%s&" % (self.root_url, quote_plus(text)) info = self.__get_search_results(url, limit, order_by, sort_order, filter) return info
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:search_by_release; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, identifier:release_id; 6, default_parameter; 6, 7; 6, 8; 7, identifier:limit; 8, integer:0; 9, default_parameter; 9, 10; 9, 11; 10, identifier:order...
def search_by_release(self, release_id, limit=0, order_by=None, sort_order=None, filter=None): url = "%s/release/series?release_id=%d" % (self.root_url, release_id) info = self.__get_search_results(url, limit, order_by, sort_order, filter) if info is None: raise ValueError('No series...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:search_by_category; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, identifier:category_id; 6, default_parameter; 6, 7; 6, 8; 7, identifier:limit; 8, integer:0; 9, default_parameter; 9, 10; 9, 11; 10, identifier:ord...
def search_by_category(self, category_id, limit=0, order_by=None, sort_order=None, filter=None): url = "%s/category/series?category_id=%d&" % (self.root_url, category_id) info = self.__get_search_results(url, limit, order_by, sort_order, filter) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:format_name; 3, parameters; 3, 4; 4, identifier:subject; 5, block; 5, 6; 5, 31; 6, if_statement; 6, 7; 6, 14; 7, call; 7, 8; 7, 9; 8, identifier:isinstance; 9, argument_list; 9, 10; 9, 11; 10, identifier:subject; 11, attribute; 11, 12; 11, 13; ...
def format_name(subject): if isinstance(subject, x509.Name): subject = [(OID_NAME_MAPPINGS[s.oid], s.value) for s in subject] return '/%s' % ('/'.join(['%s=%s' % (force_text(k), force_text(v)) for k, v in subject]))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:parse_name; 3, parameters; 3, 4; 4, identifier:name; 5, block; 5, 6; 5, 14; 5, 20; 5, 67; 5, 105; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:name; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier...
def parse_name(name): name = name.strip() if not name: return [] try: items = [(NAME_CASE_MAPPINGS[t[0].upper()], force_text(t[2])) for t in NAME_RE.findall(name)] except KeyError as e: raise ValueError('Unknown x509 name field: %s' % e.args[0]) for key, oid in NAME_OID_MAPPI...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:parse_general_name; 3, parameters; 3, 4; 4, identifier:name; 5, block; 5, 6; 5, 13; 5, 17; 5, 26; 5, 49; 5, 205; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:name; 9, call; 9, 10; 9, 11; 10, identifier:force_text; 11,...
def parse_general_name(name): name = force_text(name) typ = None match = GENERAL_NAME_RE.match(name) if match is not None: typ, name = match.groups() typ = typ.lower() if typ is None: if re.match('[a-z0-9]{2,}://', name): try: return x509.UniformRe...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:render; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:args; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 20; 9, 35; 9, 59; 9, 75; 9, 88; 9, 94; 9, 132; 9, 147; 9,...
def render(self, *args, **kwargs): pretty = kwargs.pop("pretty", False) if pretty and self._stable != "pretty": self._stable = False for arg in args: self._stable = False if isinstance(arg, dict): self.inject(arg) if kwargs: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:_insert; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:dom_group; 6, default_parameter; 6, 7; 6, 8; 7, identifier:idx; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:prepend; 11, False; 12, defaul...
def _insert(self, dom_group, idx=None, prepend=False, name=None): if idx and idx < 0: idx = 0 if prepend: idx = 0 else: idx = idx if idx is not None else len(self.childs) if dom_group is not None: if not isinstance(dom_group, Iterable) or i...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:check_label; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:labels; 5, identifier:required; 6, identifier:value_regex; 7, identifier:target_labels; 8, block; 8, 9; 8, 29; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11,...
def check_label(labels, required, value_regex, target_labels): present = target_labels is not None and not set(labels).isdisjoint(set(target_labels)) if present: if required and not value_regex: return True elif value_regex: pattern = re.compile(value_regex) p...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:receive_fmf_metadata; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:name; 5, identifier:path; 6, default_parameter; 6, 7; 6, 8; 7, identifier:object_list; 8, False; 9, block; 9, 10; 9, 14; 9, 21; 9, 30; 9, 59; 9, 64; 9, 121; 10, expression_sta...
def receive_fmf_metadata(name, path, object_list=False): output = {} fmf_tree = ExtendedTree(path) logger.debug("get FMF metadata for test (path:%s name=%s)", path, name) items = [x for x in fmf_tree.climb() if x.name.endswith("/" + name) and "@" not in x.name] if object_list: return items ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:prune_overridden; 3, parameters; 3, 4; 4, identifier:ansi_string; 5, block; 5, 6; 5, 27; 5, 138; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:multi_seqs; 9, call; 9, 10; 9, 11; 10, identifier:set; 11, generator_expres...
def prune_overridden(ansi_string): multi_seqs = set(p for p in RE_ANSI.findall(ansi_string) if ';' in p[1]) for escape, codes in multi_seqs: r_codes = list(reversed(codes.split(';'))) try: r_codes = r_codes[:r_codes.index('0') + 1] except ValueError: pass ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:parse_input; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:tagged_string; 5, identifier:disable_colors; 6, identifier:keep_tags; 7, block; 7, 8; 7, 15; 7, 24; 7, 67; 7, 77; 7, 84; 7, 107; 7, 114; 7, 118; 7, 124; 7, 172; 7, 181; 8, expression_s...
def parse_input(tagged_string, disable_colors, keep_tags): codes = ANSICodeMapping(tagged_string) output_colors = getattr(tagged_string, 'value_colors', tagged_string) if not keep_tags: for tag, replacement in (('{' + k + '}', '' if v is None else '\033[%dm' % v) for k, v in codes.items()): ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:memoize; 3, parameters; 3, 4; 4, identifier:method; 5, block; 5, 6; 5, 18; 5, 24; 5, 30; 5, 175; 5, 181; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:cache; 9, assignment; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; ...
def memoize(method): cache = method.cache = collections.OrderedDict() _get = cache.get _popitem = cache.popitem @functools.wraps(method) def memoizer(instance, x, *args, **kwargs): if not _WITH_MEMOIZATION or isinstance(x, u.Quantity): return method(instance, x, *args, **kwargs) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_set_value; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:new_value; 6, block; 6, 7; 6, 36; 6, 65; 6, 99; 6, 123; 7, if_statement; 7, 8; 7, 19; 8, boolean_operator:and; 8, 9; 8, 14; 9, comparison_operator:is; 9, 10; 9, 13; 10, at...
def _set_value(self, new_value): if self.min_value is not None and new_value < self.min_value: raise SettingOutOfBounds( "Trying to set parameter {0} = {1}, which is less than the minimum allowed {2}".format( self.name, new_value, self.min_value)) if self....
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:set_uninformative_prior; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:prior_class; 6, block; 6, 7; 6, 13; 6, 59; 6, 105; 6, 121; 6, 137; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:prior_instance; 10...
def set_uninformative_prior(self, prior_class): prior_instance = prior_class() if self.min_value is None: raise ParameterMustHaveBounds("Parameter %s does not have a defined minimum. Set one first, then re-run " "set_uninformative_prior" % self.path)...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:find_library; 3, parameters; 3, 4; 3, 5; 4, identifier:library_root; 5, default_parameter; 5, 6; 5, 7; 6, identifier:additional_places; 7, None; 8, block; 8, 9; 8, 20; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifi...
def find_library(library_root, additional_places=None): first_guess = ctypes.util.find_library(library_root) if first_guess is not None: if sys.platform.lower().find("linux") >= 0: return sanitize_lib_name(first_guess), None elif sys.platform.lower().find("darwin") >= 0: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:LDA_discriminants; 3, parameters; 3, 4; 3, 5; 4, identifier:x; 5, identifier:labels; 6, block; 6, 7; 6, 25; 6, 35; 7, try_statement; 7, 8; 7, 18; 8, block; 8, 9; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:x; ...
def LDA_discriminants(x, labels): try: x = np.array(x) except: raise ValueError('Impossible to convert x to a numpy array.') eigen_values, eigen_vectors = LDA_base(x, labels) return eigen_values[(-eigen_values).argsort()]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:train; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:self; 5, identifier:x; 6, identifier:d; 7, default_parameter; 7, 8; 7, 9; 8, identifier:epochs; 9, integer:10; 10, default_parameter; 10, 11; 10, 12; 11, identifier:shuffle; 12...
def train(self, x, d, epochs=10, shuffle=False): N = len(x) if not len(d) == N: raise ValueError('The length of vector d and matrix x must agree.') if not len(x[0]) == self.n_input: raise ValueError('The number of network inputs is not correct.') if self.outputs...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:PCA_components; 3, parameters; 3, 4; 4, identifier:x; 5, block; 5, 6; 5, 24; 5, 44; 5, 58; 6, try_statement; 6, 7; 6, 17; 7, block; 7, 8; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:x; 11, call; 11, 12; 11, 15; 12...
def PCA_components(x): try: x = np.array(x) except: raise ValueError('Impossible to convert x to a numpy array.') eigen_values, eigen_vectors = np.linalg.eig(np.cov(x.T)) eigen_order = eigen_vectors.T[(-eigen_values).argsort()] return eigen_values[(-eigen_values).argsort()]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:add_mpl_colorbar; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:dfr; 5, identifier:fig; 6, identifier:dend; 7, identifier:params; 8, default_parameter; 8, 9; 8, 10; 9, identifier:orientation; 10, string:"row"; 11, block; 11, 12; 1...
def add_mpl_colorbar(dfr, fig, dend, params, orientation="row"): for name in dfr.index[dend["dendrogram"]["leaves"]]: if name not in params.classes: params.classes[name] = name classdict = {cls: idx for (idx, cls) in enumerate(params.classes.values())} cblist = [] for name in dfr.ind...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:calculate_anim; 3, parameters; 3, 4; 3, 5; 4, identifier:infiles; 5, identifier:org_lengths; 6, block; 6, 7; 6, 14; 6, 21; 6, 37; 6, 45; 6, 226; 6, 233; 6, 246; 6, 317; 6, 336; 7, expression_statement; 7, 8; 8, call; 8, 9; 8, 12; 9, attribute; ...
def calculate_anim(infiles, org_lengths): logger.info("Running ANIm") logger.info("Generating NUCmer command-lines") deltadir = os.path.join(args.outdirname, ALIGNDIR["ANIm"]) logger.info("Writing nucmer output to %s", deltadir) if not args.skip_nucmer: joblist = anim.generate_nucmer_jobs( ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:unified_anib; 3, parameters; 3, 4; 3, 5; 4, identifier:infiles; 5, identifier:org_lengths; 6, block; 6, 7; 6, 17; 6, 35; 6, 43; 6, 290; 6, 300; 6, 370; 6, 389; 7, expression_statement; 7, 8; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10,...
def unified_anib(infiles, org_lengths): logger.info("Running %s", args.method) blastdir = os.path.join(args.outdirname, ALIGNDIR[args.method]) logger.info("Writing BLAST output to %s", blastdir) if not args.skip_blastn: logger.info("Fragmenting input files, and writing to %s", args.outdirname) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:process_deltadir; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:delta_dir; 5, identifier:org_lengths; 6, default_parameter; 6, 7; 6, 8; 7, identifier:logger; 8, None; 9, block; 9, 10; 9, 20; 9, 35; 9, 58; 9, 267; 10, expression_statement; 10, ...
def process_deltadir(delta_dir, org_lengths, logger=None): deltafiles = pyani_files.get_input_files(delta_dir, ".filter") results = ANIResults(list(org_lengths.keys()), "ANIm") for org, length in list(org_lengths.items()): results.alignment_lengths[org][org] = length for deltafile in deltafiles:...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:write_contigs; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:asm_uid; 5, identifier:contig_uids; 6, default_parameter; 6, 7; 6, 8; 7, identifier:batchsize; 8, integer:10000; 9, block; 9, 10; 9, 18; 9, 44; 9, 56; 9, 83; 9, 107; 9, 119; 9, 140; ...
def write_contigs(asm_uid, contig_uids, batchsize=10000): logger.info("Collecting contig data for %s", asm_uid) asm_record = Entrez.read( entrez_retry( Entrez.esummary, db='assembly', id=asm_uid, rettype='text'), validate=False) asm_organism = asm_record['DocumentSummarySet']['Do...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:calculate_tetra_zscore; 3, parameters; 3, 4; 4, identifier:filename; 5, block; 5, 6; 5, 34; 5, 258; 5, 262; 5, 315; 5, 319; 5, 323; 5, 442; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:counts; 9, tuple; 9, 10; 9, 16; ...
def calculate_tetra_zscore(filename): counts = (collections.defaultdict(int), collections.defaultdict(int), collections.defaultdict(int), collections.defaultdict(int)) for rec in SeqIO.parse(filename, 'fasta'): for seq in [str(rec.seq).upper(), str(rec.seq.reverse_compl...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:calculate_correlations; 3, parameters; 3, 4; 4, identifier:tetra_z; 5, block; 5, 6; 5, 17; 5, 39; 5, 253; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:orgs; 9, call; 9, 10; 9, 11; 10, identifier:sorted; 11, argument_l...
def calculate_correlations(tetra_z): orgs = sorted(tetra_z.keys()) correlations = pd.DataFrame(index=orgs, columns=orgs, dtype=float).fillna(1.0) for idx, org1 in enumerate(orgs[:-1]): for org2 in orgs[idx+1:]: assert sorted(tetra_z[org1].keys()) == sorted...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:process_blast; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:blast_dir; 5, identifier:org_lengths; 6, default_parameter; 6, 7; 6, 8; 7, identifier:fraglengths; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identi...
def process_blast( blast_dir, org_lengths, fraglengths=None, mode="ANIb", identity=0.3, coverage=0.7, logger=None, ): blastfiles = pyani_files.get_input_files(blast_dir, ".blast_tab") results = ANIResults(list(org_lengths.keys()), mode) for org, length in list(org_lengths.items()...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:run_dependency_graph; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:jobgraph; 5, default_parameter; 5, 6; 5, 7; 6, identifier:logger; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:jgprefix; 10, string:"ANIm_SGE_JG"; ...
def run_dependency_graph(jobgraph, logger=None, jgprefix="ANIm_SGE_JG", sgegroupsize=10000, sgeargs=None): joblist = build_joblist(jobgraph) dep_count = 0 if logger: logger.info("Jobs to run with scheduler") for job in joblist: logger.info("{0}: {1}".form...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:outputpairedstats; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 3, 13; 3, 14; 3, 15; 3, 16; 3, 17; 3, 18; 3, 19; 3, 20; 4, identifier:fname; 5, identifier:writemode; 6, identifier:name1; 7, identifier:n1; 8, identifi...
def outputpairedstats(fname,writemode,name1,n1,m1,se1,min1,max1,name2,n2,m2,se2,min2,max2,statname,stat,prob): suffix = '' try: x = prob.shape prob = prob[0] except: pass if prob < 0.001: suffix = ' ***' elif prob < 0.01: suffix = ' **' elif prob < 0.05: suffix = ' ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:GeneReader; 3, parameters; 3, 4; 3, 5; 4, identifier:fh; 5, default_parameter; 5, 6; 5, 7; 6, identifier:format; 7, string:'gff'; 8, block; 8, 9; 8, 16; 8, 45; 8, 208; 8, 212; 8, 216; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, ...
def GeneReader( fh, format='gff' ): known_formats = ( 'gff', 'gtf', 'bed') if format not in known_formats: print('%s format not in %s' % (format, ",".join( known_formats )), file=sys.stderr) raise Exception('?') if format == 'bed': for line in fh: f = line.strip().sp...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:read_next_maf; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:file; 5, default_parameter; 5, 6; 5, 7; 6, identifier:species_to_lengths; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:parse_e_rows; 10, False; 11, block; 11, 12; 11, 2...
def read_next_maf( file, species_to_lengths=None, parse_e_rows=False ): alignment = Alignment(species_to_lengths=species_to_lengths) line = readline( file, skip_blank=True ) if not line: return None fields = line.split() if fields[0] != 'a': raise Exception("Expected 'a ...' line") alignment.at...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:parse_record; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:lines; 6, block; 6, 7; 6, 11; 6, 52; 6, 56; 6, 62; 6, 66; 6, 429; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:temp_lines; 10, list:[]; 11, f...
def parse_record( self, lines ): temp_lines = [] for line in lines: fields = line.rstrip( "\r\n" ).split( None, 1 ) if len( fields ) == 1: fields.append( "" ) temp_lines.append( fields ) lines = temp_lines motif = TransfacMotif() ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:tile_interval; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:sources; 5, identifier:index; 6, identifier:ref_src; 7, identifier:start; 8, identifier:end; 9, default_parameter; 9, 10; 9, 11; 10, identifier:seq_db; 11, None; 1...
def tile_interval( sources, index, ref_src, start, end, seq_db=None ): assert sources[0].split('.')[0] == ref_src.split('.')[0], \ "%s != %s" % ( sources[0].split('.')[0], ref_src.split('.')[0] ) base_len = end - start blocks = index.get( ref_src, start, end ) blocks.sort(key=lambda t: t.score) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:binned_bitsets_proximity; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:f; 5, default_parameter; 5, 6; 5, 7; 6, identifier:chrom_col; 7, integer:0; 8, default_parameter; 8, 9; 8, 10; 9, identifier:start_col; 10, in...
def binned_bitsets_proximity( f, chrom_col=0, start_col=1, end_col=2, strand_col=5, upstream=0, downstream=0 ): last_chrom = None last_bitset = None bitsets = dict() for line in f: if line.startswith(" fields = line.split() strand = "+" if len(fields) >= strand_col + 1: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:to_file; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:Class; 5, identifier:dict; 6, identifier:file; 7, default_parameter; 7, 8; 7, 9; 8, identifier:is_little_endian; 9, True; 10, block; 10, 11; 10, 21; 10, 29; 10, 41; 10, 52; 10, 124;...
def to_file( Class, dict, file, is_little_endian=True ): io = BinaryFileWriter( file, is_little_endian=is_little_endian ) start_offset = io.tell() io.seek( start_offset + ( 8 * 256 ) ) subtables = [ [] for i in range(256) ] for key, value in dict.items(): pair_offset ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:transform; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:elem; 5, identifier:chain_CT_CQ; 6, identifier:max_gap; 7, block; 7, 8; 7, 15; 7, 47; 7, 78; 7, 84; 7, 90; 7, 109; 7, 129; 7, 136; 7, 208; 7, 215; 7, 222; 7, 240; 7, 258; 7, 316; 7, 351;...
def transform(elem, chain_CT_CQ, max_gap): (chain, CT, CQ) = chain_CT_CQ start, end = max(elem['start'], chain.tStart) - chain.tStart, min(elem['end'], chain.tEnd) - chain.tStart assert np.all( (CT[:,1] - CT[:,0]) == (CQ[:,1] - CQ[:,0]) ) to_chrom = chain.qName to_gab_start = chain.qStart start_...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:visit_Method; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:method; 6, block; 6, 7; 6, 15; 6, 59; 6, 86; 6, 109; 6, 133; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:resolved_method; 10, attribute; 10,...
def visit_Method(self, method): resolved_method = method.resolved.type def get_params(method, extra_bindings): result = [] for param in method.params: resolved_param = texpr(param.resolved.type, param.resolved.bindings, extra_bindings) result.appen...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:file_search; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:query; 6, default_parameter; 6, 7; 6, 8; 7, identifier:offset; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:timeout; 11, None; 12, block; 12, ...
def file_search(self, query, offset=None, timeout=None): params = dict(apikey=self.api_key, query=query, offset=offset) try: response = requests.get(self.base + 'file/search', params=params, proxies=self.proxies, timeout=timeout) except requests.RequestException as e: ret...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_handle_retry; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:resp; 6, block; 6, 7; 6, 18; 6, 28; 6, 48; 6, 67; 6, 117; 6, 152; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 13; 9, pattern_list; 9, 10; 9, 11; 9, 12; 10, i...
def _handle_retry(self, resp): exc_t, exc_v, exc_tb = sys.exc_info() if exc_t is None: raise TypeError('Must be called in except block.') retry_on_exc = tuple( (x for x in self._retry_on if inspect.isclass(x))) retry_on_codes = tuple( (x for x in self....
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_event_triggers; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 14; 5, 18; 5, 26; 5, 105; 5, 114; 5, 349; 5, 366; 5, 379; 5, 387; 5, 395; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:events; 9, ...
def get_event_triggers(self): events = {} nvrflag = False event_xml = [] url = '%s/ISAPI/Event/triggers' % self.root_url try: response = self.hik_request.get(url, timeout=CONNECT_TIMEOUT) if response.status_code == requests.codes.not_found: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_device_info; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 18; 5, 22; 5, 202; 5, 222; 5, 242; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:device_info; 9, dictionary; 10, expression_statement;...
def get_device_info(self): device_info = {} url = '%s/ISAPI/System/deviceInfo' % self.root_url using_digest = False try: response = self.hik_request.get(url, timeout=CONNECT_TIMEOUT) if response.status_code == requests.codes.unauthorized: _LOGGING....
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:alert_stream; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:reset_event; 6, identifier:kill_event; 7, block; 7, 8; 7, 21; 7, 25; 7, 29; 7, 33; 7, 41; 8, expression_statement; 8, 9; 9, call; 9, 10; 9, 13; 10, attribute; 10, ...
def alert_stream(self, reset_event, kill_event): _LOGGING.debug('Stream Thread Started: %s, %s', self.name, self.cam_id) start_event = False parse_string = "" fail_count = 0 url = '%s/ISAPI/Event/notification/alertStream' % self.root_url while True: try: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:construct_request; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:ticker; 5, default_parameter; 5, 6; 5, 7; 6, identifier:fields; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:date; 10, None; 11, default_parame...
def construct_request(ticker, fields=None, date=None, date_from=None, date_to=None, freq=None): if isinstance(ticker, basestring): request = ticker elif hasattr(ticker, '__len__'): request = ','.join(ticker) else: raise ValueError('ti...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:set; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:name; 6, identifier:value; 7, default_parameter; 7, 8; 7, 9; 8, identifier:index; 9, unary_operator:-; 9, 10; 10, integer:1; 11, block; 11, 12; 11, 29; 11, 37; 11, 5...
def set(self, name, value, index=-1): if isinstance(value, ElementProxy): value = value[0].to_er7() name = name.upper() reference = None if name is None else self.element.find_child_reference(name) child_ref, child_name = (None, None) if reference is None else (reference['ref...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:init_app; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:app; 6, default_parameter; 6, 7; 6, 8; 7, identifier:config_prefix; 8, None; 9, block; 9, 10; 9, 25; 9, 35; 9, 54; 9, 61; 9, 80; 9, 93; 9, 108; 9, 122; 9, 136; 9, 241;...
def init_app(self, app, config_prefix=None): if 'redis' not in app.extensions: app.extensions['redis'] = {} self.config_prefix = config_prefix = config_prefix or 'REDIS' if config_prefix in app.extensions['redis']: raise ValueError('Already registered config prefix {0!r}....
0, module; 0, 1; 1, ERROR; 1, 2; 1, 348; 2, function_definition; 2, 3; 2, 4; 2, 6; 3, function_name:__setup_native_run; 4, parameters; 4, 5; 5, identifier:self; 6, block; 6, 7; 6, 14; 6, 29; 6, 59; 6, 72; 6, 84; 6, 97; 6, 121; 6, 150; 6, 163; 6, 165; 6, 217; 6, 229; 6, 235; 6, 301; 7, expression_statement; 7, 8; 8, ass...
def __setup_native_run(self): self.vol_opts = ['z'] self.add_env('SCUBAINIT_UMASK', '{:04o}'.format(get_umask())) if not self.as_root: self.add_env('SCUBAINIT_UID', os.getuid()) self.add_env('SCUBAINIT_GID', os.getgid()) if self.verbose: self.add_env('...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 1, 18; 2, function_name:sort; 3, parameters; 3, 4; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:records; 6, type; 6, 7; 7, generic_type; 7, 8; 7, 9; 8, identifier:Sequence; 9, type_parameter; 9, 10; 10, type; 10, 11; 11, identifier:Record; 12, type; 12, 13; 1...
def sort(records: Sequence[Record]) -> List[Record]: "Sort records into a canonical order, suitable for comparison." return sorted(records, key=_record_key)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:_issubclass_Mapping_covariant; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 4, identifier:subclass; 5, identifier:superclass; 6, identifier:bound_Generic; 7, identifier:bound_typevars; 8, identifier:bound_typevars_readonly; 9, ide...
def _issubclass_Mapping_covariant(subclass, superclass, bound_Generic, bound_typevars, bound_typevars_readonly, follow_fwd_refs, _recursion_check): if is_Generic(subclass): if subclass.__origin__ is None or not issubclass(subclass.__origin__, Mapping): return _issubclass_Generic(subc...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:_isinstance; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:obj; 5, identifier:cls; 6, default_parameter; 6, 7; 6, 8; 7, identifier:bound_Generic; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:bound_typ...
def _isinstance(obj, cls, bound_Generic=None, bound_typevars=None, bound_typevars_readonly=False, follow_fwd_refs=True, _recursion_check=None): if bound_typevars is None: bound_typevars = {} if is_Generic(cls) and cls.__origin__ is typing.Iterable: if not is_iterable(obj): ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:typelogged_module; 3, parameters; 3, 4; 4, identifier:md; 5, block; 5, 6; 5, 14; 5, 67; 5, 73; 5, 99; 5, 105; 5, 128; 5, 138; 5, 193; 5, 218; 6, if_statement; 6, 7; 6, 11; 7, not_operator; 7, 8; 8, attribute; 8, 9; 8, 10; 9, identifier:pytypes;...
def typelogged_module(md): if not pytypes.typelogging_enabled: return md if isinstance(md, str): if md in sys.modules: md = sys.modules[md] if md is None: return md elif md in pytypes.typechecker._pending_modules: pytypes.typechecker._p...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:import_process_elements; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:document; 5, identifier:diagram_graph; 6, identifier:sequence_flows; 7, identifier:process_elements_dict; 8, identifier:plane_element; 9, block; 9, 10; 10, for_...
def import_process_elements(document, diagram_graph, sequence_flows, process_elements_dict, plane_element): for process_element in document.getElementsByTagNameNS("*", consts.Consts.process): BpmnDiagramGraphImport.import_process_element(process_elements_dict, process_element) process_id...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:generate_nodes_clasification; 3, parameters; 3, 4; 4, identifier:bpmn_diagram; 5, block; 5, 6; 5, 10; 5, 14; 5, 18; 5, 22; 5, 35; 5, 53; 5, 66; 5, 84; 5, 97; 5, 115; 5, 128; 5, 146; 5, 159; 5, 177; 5, 190; 5, 208; 5, 221; 5, 239; 5, 252; 5, 271...
def generate_nodes_clasification(bpmn_diagram): nodes_classification = {} classification_element = "Element" classification_start_event = "Start Event" classification_end_event = "End Event" task_list = bpmn_diagram.get_nodes(consts.Consts.task) for element in task_list: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:hclust_linearize; 3, parameters; 3, 4; 4, identifier:U; 5, block; 5, 6; 5, 12; 5, 21; 6, import_from_statement; 6, 7; 6, 10; 7, dotted_name; 7, 8; 7, 9; 8, identifier:scipy; 9, identifier:cluster; 10, dotted_name; 10, 11; 11, identifier:hierarc...
def hclust_linearize(U): from scipy.cluster import hierarchy Z = hierarchy.ward(U) return hierarchy.leaves_list(hierarchy.optimal_leaf_ordering(Z, U))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:kruskal_align; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:U; 5, identifier:V; 6, default_parameter; 6, 7; 6, 8; 7, identifier:permute_U; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:permute_V; 11, False; 12, block; 12...
def kruskal_align(U, V, permute_U=False, permute_V=False): unrm = [f / np.linalg.norm(f, axis=0) for f in U.factors] vnrm = [f / np.linalg.norm(f, axis=0) for f in V.factors] sim_matrices = [np.dot(u.T, v) for u, v in zip(unrm, vnrm)] cost = 1 - np.mean(np.abs(sim_matrices), axis=0) indices = Munkre...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:randn_ktensor; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:shape; 5, identifier:rank; 6, default_parameter; 6, 7; 6, 8; 7, identifier:norm; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:random_state; 11, None; 12, block;...
def randn_ktensor(shape, rank, norm=None, random_state=None): rns = _check_random_state(random_state) factors = KTensor([rns.standard_normal((i, rank)) for i in shape]) return _rescale_tensor(factors, norm)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:fit; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:self; 5, identifier:X; 6, identifier:ranks; 7, default_parameter; 7, 8; 7, 9; 8, identifier:replicates; 9, integer:1; 10, default_parameter; 10, 11; 10, 12; 11, identifier:verbos...
def fit(self, X, ranks, replicates=1, verbose=True): if not isinstance(ranks, collections.Iterable): ranks = (ranks,) for r in ranks: if r not in self.results: self.results[r] = [] if verbose: itr = trange(replicates, ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_create_model_class; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:model; 6, block; 6, 7; 6, 17; 6, 42; 6, 60; 6, 72; 6, 111; 6, 155; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:cls_name; 10, call; 10...
def _create_model_class(self, model): cls_name = model.replace('.', '_') if sys.version_info[0] < 3: if isinstance(cls_name, unicode): cls_name = cls_name.encode('utf-8') attrs = { '_env': self, '_odoo': self._odoo, '_name': model, ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_init_values; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:context; 7, None; 8, block; 8, 9; 8, 22; 8, 26; 8, 56; 9, if_statement; 9, 10; 9, 13; 10, comparison_operator:is; 10, 11; 10, 12; 11, i...
def _init_values(self, context=None): if context is None: context = self.env.context basic_fields = [] for field_name in self._columns: field = self._columns[field_name] if not getattr(field, 'relation', False): basic_fields.append(field_name) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:parse_resource_id; 3, parameters; 3, 4; 4, identifier:rid; 5, block; 5, 6; 5, 12; 5, 21; 5, 121; 6, if_statement; 6, 7; 6, 9; 7, not_operator; 7, 8; 8, identifier:rid; 9, block; 9, 10; 10, return_statement; 10, 11; 11, dictionary; 12, expressio...
def parse_resource_id(rid): if not rid: return {} match = _ARMID_RE.match(rid) if match: result = match.groupdict() children = _CHILDREN_RE.finditer(result['children'] or '') count = None for count, child in enumerate(children): result.update({ ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 26; 2, function_name:lookup_instance; 3, parameters; 3, 4; 3, 8; 3, 13; 3, 18; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:name; 6, type; 6, 7; 7, identifier:str; 8, typed_default_parameter; 8, 9; 8, 10; 8, 12; 9, identifier:instance_type; 10, type; 10, 11; 11, ...
def lookup_instance(name: str, instance_type: str = '', image_name: str = '', states: tuple = ('running', 'stopped', 'initializing')): ec2 = get_ec2_resource() instances = ec2.instances.filter( Filters=[{'Name': 'instance-state-name', 'Values': states}]) prefix = get_prefix() username = ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:extract_attr_for_match; 3, parameters; 3, 4; 3, 5; 4, identifier:items; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 12; 7, 37; 7, 41; 7, 52; 7, 126; 7, 141; 7, 148; 8, expression_statement; 8, 9; 9, assignment; 9...
def extract_attr_for_match(items, **kwargs): query_arg = None for arg, value in kwargs.items(): if value == -1: assert query_arg is None, "Only single query arg (-1 valued) is allowed" query_arg = arg result = [] filterset = set(kwargs.keys()) for item in items: match = True assert fil...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_maybe_create_resources; 3, parameters; 3, 4; 4, typed_default_parameter; 4, 5; 4, 6; 4, 8; 5, identifier:logging_task; 6, type; 6, 7; 7, identifier:Task; 8, None; 9, block; 9, 10; 9, 37; 9, 118; 10, function_definition; 10, 11; 10, 12; 10, 15;...
def _maybe_create_resources(logging_task: Task = None): def log(*args): if logging_task: logging_task.log(*args) else: util.log(*args) def should_create_resources(): prefix = u.get_prefix() if u.get_keypair_name() not in u.get_keypair_dict(): log(f"Missing {u.get_keypair_name()} ke...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_set_aws_environment; 3, parameters; 3, 4; 4, typed_default_parameter; 4, 5; 4, 6; 4, 8; 5, identifier:task; 6, type; 6, 7; 7, identifier:Task; 8, None; 9, block; 9, 10; 9, 22; 9, 34; 9, 61; 9, 86; 9, 109; 9, 144; 10, expression_statement; 10, ...
def _set_aws_environment(task: Task = None): current_zone = os.environ.get('NCLUSTER_ZONE', '') current_region = os.environ.get('AWS_DEFAULT_REGION', '') def log(*args): if task: task.log(*args) else: util.log(*args) if current_region and current_zone: assert current_zone.startswith( ...