sequence
stringlengths
546
16.2k
code
stringlengths
108
19.3k
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_raw_counts; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 9; 5, 13; 5, 17; 5, 23; 5, 24; 5, 25; 5, 361; 5, 388; 5, 415; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, expression_statement; 9, 10; 10, assignmen...
def get_raw_counts(self): """Determines counts for unique words, repetitions, etc using the raw text response. Adds the following measures to the self.measures dictionary: - COUNT_total_words: count of words (i.e. utterances with semantic content) spoken by the subject. Fill...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:compute_similarity_score; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:unit1; 6, identifier:unit2; 7, block; 7, 8; 7, 10; 7, 390; 8, expression_statement; 8, 9; 9, comment; 10, if_statement; 10, 11; 10, 16; 10, 227; 11, co...
def compute_similarity_score(self, unit1, unit2): """ Returns the similarity score between two words. The type of similarity scoring method used depends on the currently active method and clustering type. :param unit1: Unit object corresponding to the first word. :type unit1:...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:compute_pairwise_similarity_score; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 12; 5, 16; 5, 95; 5, 96; 5, 110; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, ide...
def compute_pairwise_similarity_score(self): """Computes the average pairwise similarity score between all pairs of Units. The pairwise similarity is calculated as the sum of similarity scores for all pairwise word pairs in a response -- except any pair composed of a word and itself -- ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:compute_between_collection_interval_duration; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:prefix; 6, block; 6, 7; 6, 9; 6, 13; 6, 14; 6, 48; 6, 49; 6, 79; 6, 80; 6, 81; 6, 103; 6, 125; 7, expression_statement; 7, 8; 8, comment;...
def compute_between_collection_interval_duration(self, prefix): """Calculates BETWEEN-collection intervals for the current collection and measure type and takes their mean. :param str prefix: Prefix for the key entry in self.measures. Negative intervals (for overlapping clusters) a...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:compute_within_collection_vowel_duration; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:prefix; 6, default_parameter; 6, 7; 6, 8; 7, identifier:no_singletons; 8, False; 9, block; 9, 10; 9, 12; 9, 29; 9, 33; 9, 89; 9, 111; 1...
def compute_within_collection_vowel_duration(self, prefix, no_singletons=False): """ Computes the mean duration of vowels from Units within clusters. :param str prefix: Prefix for the key entry in self.measures :param bool no_singletons: If False, excludes collections of length 1 from calculati...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:print_output; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 34; 5, 183; 5, 184; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 14; 9, comparison_operator:==; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12;...
def print_output(self): """ Outputs final list of measures to screen a csv file. The .csv file created has the same name as the input file, with "vfclust_TYPE_CATEGORY" appended to the filename, where TYPE indicates the type of task performed done (SEMANTIC or PHONETIC) and CATEGORY ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:sort_by; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:fieldName; 6, default_parameter; 6, 7; 6, 8; 7, identifier:reverse; 8, False; 9, block; 9, 10; 9, 12; 10, expression_statement; 10, 11; 11, string:''' sort_...
def sort_by(self, fieldName, reverse=False): ''' sort_by - Return a copy of this collection, sorted by the given fieldName. The fieldName is accessed the same way as other filtering, so it supports custom properties, etc. @param fieldName <str> - The name of the field o...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_qtls_from_rqtl_data; 3, parameters; 3, 4; 3, 5; 4, identifier:matrix; 5, identifier:lod_threshold; 6, block; 6, 7; 6, 9; 6, 20; 6, 30; 6, 31; 6, 32; 6, 33; 6, 199; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 1...
def get_qtls_from_rqtl_data(matrix, lod_threshold): """ Retrieve the list of significants QTLs for the given input matrix and using the specified LOD threshold. This assumes one QTL per linkage group. :arg matrix, the MapQTL file read in memory :arg threshold, threshold used to determine if a given...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:response; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:code; 5, default_parameter; 5, 6; 5, 7; 6, identifier:body; 7, string:''; 8, default_parameter; 8, 9; 8, 10; 9, identifier:etag; 10, None; 11, default_parameter; 11,...
def response(code, body='', etag=None, last_modified=None, expires=None, **kw): """Helper to build an HTTP response. Parameters: code : An integer status code. body : The response body. See `Response.__init__` for details. etag : A value for the ETag header. Double quotes will be...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:plot_optimum_prediction_fraction_correct_cutoffs_over_range; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 3, 14; 4, identifier:self; 5, identifier:analysis_set; 6, identifier:min_stability_classication_x_cutoff; 7, identifier:max_stabil...
def plot_optimum_prediction_fraction_correct_cutoffs_over_range(self, analysis_set, min_stability_classication_x_cutoff, max_stability_classication_x_cutoff, suppress_plot = False, analysis_file_prefix = None, verbose = True): '''Plots the optimum cutoff for the predictions to maximize the fraction correct metr...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_chain_details_by_related_pdb_chains; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:pdb_id; 6, identifier:chain_id; 7, identifier:pfam_accs; 8, block; 8, 9; 8, 11; 8, 17; 8, 23; 8, 31; 8, 49; 8, 53; 8, 54; 8, 58; 8...
def get_chain_details_by_related_pdb_chains(self, pdb_id, chain_id, pfam_accs): ''' Returns a dict of SCOPe details using info This returns Pfam-level information for a PDB chain i.e. no details on the protein, species, or domain will be returned. If there are SCOPe entries for the assoc...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:recall_service; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:service; 6, block; 6, 7; 6, 9; 6, 22; 6, 43; 6, 214; 7, expression_statement; 7, 8; 8, comment; 9, if_statement; 9, 10; 9, 16; 10, not_operator; 10, 11; 11, call; 11, ...
def recall_service(self, service): """ This method assumes that its a roll back during a deployment. If not used during a deployment session This method should be extended later to be more useful. """ if not isinstance(service, Service): raise TypeError("service mus...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:sorted_items; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:d; 5, default_parameter; 5, 6; 5, 7; 6, identifier:key; 7, identifier:__identity; 8, default_parameter; 8, 9; 8, 10; 9, identifier:reverse; 10, False; 11, block; 11, 12; 11, 14; 11, ...
def sorted_items(d, key=__identity, reverse=False): """ Return the items of the dictionary sorted by the keys >>> sample = dict(foo=20, bar=42, baz=10) >>> tuple(sorted_items(sample)) (('bar', 42), ('baz', 10), ('foo', 20)) >>> reverse_string = lambda s: ''.join(reversed(s)) >>> tuple(sorted_items(sample, key=...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 22; 2, function_name:get_or_create_in_transaction; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 4, identifier:tsession; 5, identifier:model; 6, identifier:values; 7, default_parameter; 7, 8; 7, 9; 8, identifier:missing_columns; 9, list:[]; 10...
def get_or_create_in_transaction(tsession, model, values, missing_columns = [], variable_columns = [], updatable_columns = [], only_use_supplied_columns = False, read_only = False): ''' Uses the SQLAlchemy model to retrieve an existing record based on the supplied field values or, if there is no existing re...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:errors; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:instance; 6, block; 6, 7; 6, 9; 7, expression_statement; 7, 8; 8, comment; 9, if_statement; 9, 10; 9, 15; 9, 23; 9, 84; 9, 183; 10, call; 10, 11; 10, 12; 11, identifier:isinst...
def errors(self, instance): """Run all field validators and return a dict of errors. The keys of the resulting dict coorespond to field names. instance can be a dict (ie, form.cleaned_data), a form, a formset, or a model instance. If instance is a form, full_clean() will be cal...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:multimatch; 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:origin; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:rel; 10, None; 11, default_parameter; 11, 1...
def multimatch(self, origin=None, rel=None, target=None, attrs=None, include_ids=False): ''' Iterator over relationship IDs that match a pattern of components, with multiple options provided for each component origin - (optional) origin of the relationship (similar to an RDF subject), or set of...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:get_qtls_from_mapqtl_data; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:matrix; 5, identifier:threshold; 6, identifier:inputfile; 7, block; 7, 8; 7, 10; 7, 29; 7, 33; 7, 37; 7, 140; 7, 171; 8, expression_statement; 8, 9; 9, comment; 10, expre...
def get_qtls_from_mapqtl_data(matrix, threshold, inputfile): """Extract the QTLs found by MapQTL reading its file. This assume that there is only one QTL per linkage group. :arg matrix, the MapQTL file read in memory :arg threshold, threshold used to determine if a given LOD value is reflective...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:merge_range_pairs; 3, parameters; 3, 4; 4, identifier:prs; 5, block; 5, 6; 5, 8; 5, 12; 5, 23; 5, 30; 5, 34; 5, 38; 5, 144; 6, expression_statement; 6, 7; 7, string:'''Takes in a list of pairs specifying ranges and returns a sorted list of merg...
def merge_range_pairs(prs): '''Takes in a list of pairs specifying ranges and returns a sorted list of merged, sorted ranges.''' new_prs = [] sprs = [sorted(p) for p in prs] sprs = sorted(sprs) merged = False x = 0 while x < len(sprs): newx = x + 1 new_pair = list(sprs[x]) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 29; 2, function_name:create; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:agent_cls; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:n_agents; 10, integer:1...
def create(self, agent_cls=None, n_agents=10, agent_kwargs={}, env_cls=Environment, env_kwargs={}, callback=None, conns=0, log_folder=None): """A convenience function to create simple simulations. Method first creates environment, then instantiates agents into it w...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:callproc; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:procname; 6, default_parameter; 6, 7; 6, 8; 7, identifier:parameters; 8, tuple; 9, default_parameter; 9, 10; 9, 11; 10, identifier:quiet; 11, False; 12, ...
def callproc(self, procname, parameters=(), quiet=False, expect_return_value=False): """Calls a MySQL stored procedure procname and returns the return values. This uses DictCursor. To get return values back out of a stored procedure, prefix the parameter with a @ character. """ self....
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:create_insert_dict_string; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 4, identifier:self; 5, identifier:tblname; 6, identifier:d; 7, default_parameter; 7, 8; 7, 9; 8, identifier:PKfields; 9, list:[]; 10, default_parameter; 10, 11; 10...
def create_insert_dict_string(self, tblname, d, PKfields=[], fields=None, check_existing = False): '''The main function of the insert_dict functions. This creates and returns the SQL query and parameters used by the other functions but does not insert any data into the database. Simple fu...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:fixed_point; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:is_zero; 5, identifier:plus; 6, identifier:minus; 7, identifier:f; 8, identifier:x; 9, block; 9, 10; 9, 12; 9, 57; 10, expression_statement; 10, 11; 11, comment; 12, decora...
def fixed_point(is_zero, plus, minus, f, x): """ Get the least fixed point when it can be computed piecewise. .. testsetup:: from proso.func import fixed_point .. doctest:: >>> sorted(fixed_point( ... is_zero=lambda xs: len(xs) == 0, ... plus=lambda xs, ys: xs +...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:connections_from_graph; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:env; 5, identifier:G; 6, default_parameter; 6, 7; 6, 8; 7, identifier:edge_data; 8, False; 9, block; 9, 10; 9, 12; 9, 31; 9, 44; 9, 55; 9, 86; 9, 87; 9, 94; 9, 100; 9, 108; ...
def connections_from_graph(env, G, edge_data=False): """Create connections for agents in the given environment from the given NetworkX graph structure. :param env: Environment where the agents live. The environment should be derived from :class:`~creamas.core.environment.Environment`, ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:graph_from_connections; 3, parameters; 3, 4; 3, 5; 4, identifier:env; 5, default_parameter; 5, 6; 5, 7; 6, identifier:directed; 7, False; 8, block; 8, 9; 8, 11; 8, 22; 8, 33; 8, 85; 9, expression_statement; 9, 10; 10, comment; 11, expression_st...
def graph_from_connections(env, directed=False): """Create NetworkX graph from agent connections in a given environment. :param env: Environment where the agents live. The environment must be derived from :class:`~creamas.core.environment.Environment`, :class:`~creamas.mp.MultiEnvironme...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:profile; 3, parameters; 3, 4; 3, 5; 4, identifier:request; 5, default_parameter; 5, 6; 5, 7; 6, identifier:status; 7, integer:200; 8, block; 8, 9; 8, 11; 9, expression_statement; 9, 10; 10, comment; 11, if_statement; 11, 12; 11, 17; 11, 151; 11...
def profile(request, status=200): """ Get the user's profile. If the user has no assigned profile, the HTTP 404 is returned. Make a POST request to modify the user's profile. GET parameters: html turn on the HTML version of the API username: username of user (onl...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:get_session_identifiers; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:cls; 5, default_parameter; 5, 6; 5, 7; 6, identifier:folder; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:inputfile; 10, None; 11, block; 11, 12; 11, 14; 11, ...
def get_session_identifiers(cls, folder=None, inputfile=None): """ Retrieve the list of session identifiers contained in the data on the folder or the inputfile. For this plugin, it returns the list of excel sheet available. :kwarg folder: the path to the folder containing the files to ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:template2regex; 3, parameters; 3, 4; 3, 5; 4, identifier:template; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ranges; 7, None; 8, block; 8, 9; 8, 11; 8, 47; 8, 56; 8, 60; 8, 64; 8, 81; 8, 85; 8, 89; 8, 94; 8, 98; 8, 102; 8, 106; 8, 312; 8,...
def template2regex(template, ranges=None): """Convert a URL template to a regular expression. Converts a template, such as /{name}/ to a regular expression, e.g. /(?P<name>[^/]+)/ and a list of the named parameters found in the template (e.g. ['name']). Ranges are given after a colon in a template name...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:path; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:target; 6, identifier:args; 7, identifier:kw; 8, block; 8, 9; 8, 11; 9, expression_statement; 9, 10; 10, comment; 11, if_statement; 11, 12; 11, 18; 11, 97; 11, 137; ...
def path(self, target, args, kw): """Build a URL path fragment for a resource or route. Possible values for `target`: A string that does not start with a '.' and does not contain ':'. : Looks up the route of the same name on this mapper and returns it's path. A s...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:get_children_graph; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:item_ids; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:language; 10, None; 11, default_parameter; 11, ...
def get_children_graph(self, item_ids=None, language=None, forbidden_item_ids=None): """ Get a subgraph of items reachable from the given set of items through the 'child' relation. Args: item_ids (list): items which are taken as roots for the reachability languag...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_parents_graph; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:item_ids; 6, default_parameter; 6, 7; 6, 8; 7, identifier:language; 8, None; 9, block; 9, 10; 9, 12; 9, 103; 9, 114; 10, expression_statement; 10, 11; 11, com...
def get_parents_graph(self, item_ids, language=None): """ Get a subgraph of items reachable from the given set of items through the 'parent' relation. Args: item_ids (list): items which are taken as roots for the reachability language (str): if specified, filter ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_graph; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:item_ids; 6, default_parameter; 6, 7; 6, 8; 7, identifier:language; 8, None; 9, block; 9, 10; 9, 12; 9, 116; 10, expression_statement; 10, 11; 11, comment; 12, functi...
def get_graph(self, item_ids, language=None): """ Get a subgraph of items reachable from the given set of items through any relation. Args: item_ids (list): items which are taken as roots for the reachability language (str): if specified, filter out items which a...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:translate_item_ids; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:item_ids; 6, identifier:language; 7, default_parameter; 7, 8; 7, 9; 8, identifier:is_nested; 9, None; 10, block; 10, 11; 10, 13; 10, 45; 10, 55; 10, 7...
def translate_item_ids(self, item_ids, language, is_nested=None): """ Translate a list of item ids to JSON objects which reference them. Args: item_ids (list[int]): item ids language (str): language used for further filtering (some objects for different l...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:get_leaves; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:item_ids; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:language; 10, None; 11, default_parameter; 11, 12; 11, ...
def get_leaves(self, item_ids=None, language=None, forbidden_item_ids=None): """ Get mapping of items to their reachable leaves. Leaves having inactive relations to other items are omitted. Args: item_ids (list): items which are taken as roots for the reachability ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:get_image; 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:imgtype; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:tags; 10, None; 11, default_parameter; 11, ...
async def get_image(self, imgtype=None, tags=None, nsfw=None, hidden=None, filetype=None): """Request an image from weeb.sh. This function is a coroutine. Parameters: imgtype: str - the type of image to get. (If not specified, needs at least one tag) tags: list - the ta...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:query; 3, parameters; 3, 4; 3, 5; 4, identifier:logfile; 5, default_parameter; 5, 6; 5, 7; 6, identifier:jobID; 7, None; 8, block; 8, 9; 8, 11; 8, 19; 8, 49; 8, 72; 8, 78; 8, 84; 8, 85; 8, 89; 8, 117; 8, 132; 8, 145; 9, expression_statement; 9,...
def query(logfile, jobID = None): """If jobID is an integer then return False if the job has finished and True if it is still running. Otherwise, returns a table of jobs run by the user.""" joblist = logfile.readFromLogfile() if jobID and type(jobID) == type(1): command = ['qstat', '-j',...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:build; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:client; 5, identifier:repository_tag; 6, identifier:docker_file; 7, default_parameter; 7, 8; 7, 9; 8, identifier:tag; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identi...
def build(client, repository_tag, docker_file, tag=None, use_cache=False): """ Build a docker image """ if not isinstance(client, docker.Client): raise TypeError("client needs to be of type docker.Client.") if not isinstance(docker_file, six.string_types) or not os.p...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:create_class; 3, parameters; 3, 4; 4, identifier:request; 5, block; 5, 6; 5, 8; 5, 27; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 14; 9, comparison_operator:==; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifi...
def create_class(request): """Create new class POST parameters (JSON): name: Human readable name of class code (optional): unique code of class used for joining to class """ if request.method == 'GET': return render(request, 'classes_create.html', {}, he...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:create_student; 3, parameters; 3, 4; 4, identifier:request; 5, block; 5, 6; 5, 8; 5, 45; 5, 64; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 18; 9, not_operator; 9, 10; 10, call; 10, 11; 10, 12; 11, identifier:get_config...
def create_student(request): """ Create new user in class POST parameters (JSON): class: id of the class username (optional): username of student, if not provided username is create based on name password (optional): password of student first_...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 80; 2, function_name:lograptor; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 3, 35; 3, 38; 3, 41; 3, 44; 3, 47; 3, 50; 3, 53; 3, 56; 3, 59; 3, 62; 3, 65; 3, 68; 3, 71; 3, 74; 3, 77; 4, identifier:files; 5, default_parame...
def lograptor(files, patterns=None, matcher='ruled', cfgfiles=None, apps=None, hosts=None, filters=None, time_period=None, time_range=None, case=False, invert=False, word=False, files_with_match=None, count=False, quiet=False, max_count=0, only_matching=False, line_number=False...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sanitize_codon_list; 3, parameters; 3, 4; 3, 5; 4, identifier:codon_list; 5, default_parameter; 5, 6; 5, 7; 6, identifier:forbidden_seqs; 7, tuple; 8, block; 8, 9; 8, 11; 8, 12; 8, 13; 8, 35; 8, 36; 8, 37; 8, 38; 8, 44; 8, 60; 8, 75; 8, 96; 8, ...
def sanitize_codon_list(codon_list, forbidden_seqs=()): """ Make silent mutations to the given codon lists to remove any undesirable sequences that are present within it. Undesirable sequences include restriction sites, which may be optionally specified as a second argument, and homopolymers abo...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:add_node; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:node; 6, block; 6, 7; 6, 9; 6, 17; 6, 18; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:nodes; 12...
def add_node(self, node): """Add newcomers one by one, using linear preferential attachment.""" nodes = self.nodes() # Start with a core of m0 fully-connected agents... if len(nodes) <= self.m0: other_nodes = [n for n in nodes if n.id != node.id] for n in other_n...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:get_concepts_to_recalculate; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:users; 6, identifier:lang; 7, default_parameter; 7, 8; 7, 9; 8, identifier:concepts; 9, None; 10, block; 10, 11; 10, 13; 10, 17; 10, 34; 10, ...
def get_concepts_to_recalculate(self, users, lang, concepts=None): """ Get concept which have same changes and have to be recalculated Args: users (list of users or user): users whose user stats we are interesting in lang (str): language of used concepts conc...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:recalculate_concepts; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:concepts; 6, default_parameter; 6, 7; 6, 8; 7, identifier:lang; 8, None; 9, block; 9, 10; 9, 12; 9, 21; 9, 73; 9, 79; 9, 85; 10, expression_statement; 10, ...
def recalculate_concepts(self, concepts, lang=None): """ Recalculated given concepts for given users Args: concepts (dict): user id (int -> set of concepts to recalculate) lang(Optional[str]): language used to get items in all concepts (cached). Defaults ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:get_user_stats; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, identifier:users; 6, default_parameter; 6, 7; 6, 8; 7, identifier:lang; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:concepts; 11, None;...
def get_user_stats(self, users, lang=None, concepts=None, since=None, recalculate=True): """ Finds all UserStats of given concepts and users. Recompute UserStats if necessary Args: users (Optional[list of users] or [user]): list of primary keys of user or users ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:execute; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:self; 5, identifier:sql; 6, default_parameter; 6, 7; 6, 8; 7, identifier:parameters; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:cursorClass; 11...
def execute(self, sql, parameters = None, cursorClass = DictCursor, quiet = False, locked = False, do_commit = True): """Execute SQL query. This uses DictCursor by default.""" i = 0 errcode = 0 caughte = None cursor = None if sql.find(";") != -1 or sql.find("\\G") != -1: # Catches some injections rais...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:create_tasks; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 8; 3, 11; 4, identifier:task_coro; 5, identifier:addrs; 6, list_splat_pattern; 6, 7; 7, identifier:args; 8, default_parameter; 8, 9; 8, 10; 9, identifier:flatten; 10, True; 11, dictionary_splat...
def create_tasks(task_coro, addrs, *args, flatten=True, **kwargs): '''Create and schedule a set of asynchronous tasks. The function creates the tasks using a given list of agent addresses and wraps each of them in :func:`asyncio.ensure_future`. The ``*args`` and ``**kwargs`` are passed down to :func:`t...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:write; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:models; 5, default_parameter; 5, 6; 5, 7; 6, identifier:out; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:base; 10, None; 11, default_parameter; 11, 12; 11...
def write(models, out=None, base=None, propertybase=None, shorteners=None, logger=logging): ''' models - input Versa models from which output is generated. Must be a sequence object, not an iterator ''' assert out is not None #Output stream required if not isinstance(models, list): m...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:register_extensions; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 6, expression_statement; 6, 7; 7, comment; 8, try_statement; 8, 9; 8, 164; 9, block; 9, 10; 10, for_statement; 10, 11; 10, 14; 10, 23; 11, pattern_list; 11, 12;...
def register_extensions(self): """ Function registers extensions given extensions list Args ---- extensions (list) : the extensions dict on app.config.<env> Raises ------ Exception: Raises exception when extension can't be loaded properly...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:request; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 4, identifier:self; 5, identifier:method; 6, identifier:path; 7, default_parameter; 7, 8; 7, 9; 8, identifier:query; 9, dictionary; 10, default_parameter; 10, 11; 10, 12; 11,...
def request(self, method, path, query={}, headers={}, body={}, base_url=None): ''' Issues a request to Onshape Args: - method (str): HTTP method - path (str): Path e.g. /api/documents/:id - query (dict, default={}): Query params in key-value pairs ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:fix_pdb; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 14; 5, 15; 5, 21; 5, 51; 5, 52; 6, expression_statement; 6, 7; 7, string:'''A function to fix fatal errors in PDB files when they can be automatically fixed. At present,...
def fix_pdb(self): '''A function to fix fatal errors in PDB files when they can be automatically fixed. At present, this only runs if self.strict is False. We may want a separate property for this since we may want to keep strict mode but still allow PDBs to be fixed. The only ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:stripForDDG; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:chains; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:keepHETATM; 10, False; 11, default_parameter; 11,...
def stripForDDG(self, chains = True, keepHETATM = False, numberOfModels = None, raise_exception = True): '''Strips a PDB to ATOM lines. If keepHETATM is True then also retain HETATM lines. By default all PDB chains are kept. The chains parameter should be True or a list. In the latter case...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 1, 14; 2, function_name:neighbors2; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:self; 5, identifier:distance; 6, identifier:chain_residue; 7, default_parameter; 7, 8; 7, 9; 8, identifier:atom; 9, None; 10, default_parameter; 10, 11; 10, 12; 11,...
def neighbors2(self, distance, chain_residue, atom = None, resid_list = None): #atom = " CA " '''this one is more precise since it uses the chain identifier also''' if atom == None: # consider all atoms lines = [line for line in self.atomlines(resid_list) if line[17:20] in allo...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 26; 2, function_name:add_document; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 4, identifier:self; 5, identifier:item_uri; 6, identifier:name; 7, identifier:metadata; 8, default_parameter; 8, 9; 8, 10; 9, identifier:content; 10,...
def add_document(self, item_uri, name, metadata, content=None, docurl=None, file=None, displaydoc=False, preferName=False, contrib_id=None): """Add a document to an existing item :param item_uri: the URI that references the item :ty...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:get_agents; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:addr; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:agent_cls; 10, None; 11, default_parameter; 11, 12; 11, 13;...
def get_agents(self, addr=True, agent_cls=None, include_manager=False): '''Get agents in the environment. :param bool addr: If ``True``, returns only addresses of the agents. :param agent_cls: Optional, if specified returns only agents belonging to that particular class....
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:tee; 3, parameters; 3, 4; 3, 6; 4, list_splat_pattern; 4, 5; 5, identifier:popenargs; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 11; 8, 18; 8, 40; 8, 48; 8, 76; 8, 170; 8, 184; 8, 198; 9, expression_statement; 9...
def tee(*popenargs, **kwargs): """ Run a command as if it were piped though tee. Output generated by the command is displayed in real time to the terminal. It is also captured in strings and returned once the process terminated. This function is very useful for logging output from cluster runs....
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:dump_object; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:obj; 6, block; 6, 7; 6, 9; 6, 23; 6, 36; 6, 58; 7, expression_statement; 7, 8; 8, comment; 9, if_statement; 9, 10; 9, 17; 10, call; 10, 11; 10, 12; 11, identifier:isinsta...
def dump_object(self, obj): """ Called to encode unrecognized object. :param object obj: the object to encode :return: the encoded object :raises TypeError: when `obj` cannot be encoded This method is passed as the ``default`` keyword parameter to :func:`json.du...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:normalize_datum; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:datum; 6, block; 6, 7; 6, 9; 6, 16; 6, 27; 6, 43; 6, 57; 6, 72; 6, 87; 6, 98; 6, 122; 6, 158; 7, expression_statement; 7, 8; 8, comment; 9, if_statement; 9, 10; 9, 13...
def normalize_datum(self, datum): """ Convert `datum` into something that umsgpack likes. :param datum: something that we want to process with umsgpack :return: a packable version of `datum` :raises TypeError: if `datum` cannot be packed This message is called by :meth:...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:redirect; 3, parameters; 3, 4; 3, 5; 4, identifier:endpoint; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kw; 7, block; 7, 8; 7, 10; 7, 14; 7, 133; 8, expression_statement; 8, 9; 9, comment; 10, expression_statement; 10, 11; 11, assignment;...
def redirect(endpoint, **kw): """ Redirect allow to redirect dynamically using the classes methods without knowing the right endpoint. Expecting all endpoint have GET as method, it will try to pick the first match, based on the endpoint provided or the based on the Rule map_url An endpoint can ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_search; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:query; 6, identifier:search_term; 7, block; 7, 8; 7, 10; 7, 18; 7, 26; 7, 35; 7, 36; 7, 84; 7, 336; 7, 337; 7, 338; 7, 339; 8, expression_statement; 8, 9; 9, comment; 1...
def _search(self, query, search_term): """ Improved search between words. The original _search for MongoEngine dates back to November 12th, 2013 [1]_. In this ref it's stated that there is a bug with complex Q queries preventing multi-word searches. During this time, the MongoEn...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:replace_seqres; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:pdb; 6, default_parameter; 6, 7; 6, 8; 7, identifier:update_atoms; 8, True; 9, block; 9, 10; 9, 12; 9, 18; 9, 22; 9, 44; 9, 48; 9, 145; 9, 263; 9, 277; 10, expre...
def replace_seqres(self, pdb, update_atoms = True): """Replace SEQRES lines with a new sequence, optionally removing mutated sidechains""" newpdb = PDB() inserted_seqres = False entries_before_seqres = set(["HEADER", "OBSLTE", "TITLE", "CAVEAT", "COMPND", "SOURCE", ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:enrich_json_objects_by_object_type; 3, parameters; 3, 4; 3, 5; 4, identifier:request; 5, identifier:value; 6, block; 6, 7; 6, 9; 6, 15; 6, 64; 6, 76; 6, 216; 6, 232; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10,...
def enrich_json_objects_by_object_type(request, value): """ Take the given value and start enrichment by object_type. The va Args: request (django.http.request.HttpRequest): request which is currently processed value (dict|list|django.db.models.Model): in case of django.db.model...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:change_parent; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:sender; 5, identifier:instance; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 11; 8, 19; 8, 133; 8, 260; 9, expression_statement; 9, 10; 10, comment; 11...
def change_parent(sender, instance, **kwargs): """ When the given flashcard has changed. Look at term and context and change the corresponding item relation. """ if instance.id is None: return if len({'term', 'term_id'} & set(instance.changed_fields)) != 0: diff = instance.diff ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:bin_atoms; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 9; 5, 27; 5, 45; 5, 61; 5, 91; 5, 95; 5, 163; 5, 164; 5, 233; 5, 234; 5, 302; 5, 303; 5, 307; 5, 363; 6, expression_statement; 6, 7; 7, string:'''This function bins th...
def bin_atoms(self): '''This function bins the Atoms into fixed-size sections of the protein space in 3D.''' # Create the atom bins low_point = numpy.array([self.min_x, self.min_y, self.min_z]) high_point = numpy.array([self.max_x, self.max_y, self.max_z]) atom_bin_dimensions = ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:attr_name; 6, list_splat_pattern; 6, 7; 7, identifier:args; 8, block; 8, 9; 8, 11; 8, 26; 8, 27; 8, 42; 8, 46; 8, 55; 8, 112; 9, expression_statement; 9, 10; 10, comment; 1...
def get(self, attr_name, *args): """ Get the most retrieval attribute in the configuration file. This method will recursively look through the configuration file for the attribute specified and return the last found value or None. The values can be referenced by the key name provided in...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_load_yml_config; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:config_file; 6, block; 6, 7; 6, 9; 6, 24; 7, expression_statement; 7, 8; 8, comment; 9, if_statement; 9, 10; 9, 18; 10, not_operator; 10, 11; 11, call; 11, 12; 11, 1...
def _load_yml_config(self, config_file): """ loads a yaml str, creates a few constructs for pyaml, serializes and normalized the config data. Then assigns the config data to self._data. :param config_file: A :string: loaded from a yaml file. """ if not isinstance(config_file, s...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_create_attr; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:property_key; 6, identifier:data; 7, identifier:ancestors; 8, block; 8, 9; 8, 11; 8, 34; 8, 55; 8, 59; 8, 72; 8, 76; 8, 77; 8, 162; 9, expression_statement; ...
def _create_attr(self, property_key, data, ancestors): """ Dynamically Creates attributes on for a Config. Also adds name and alias to each Config object. :param property_key: A :string: configuration property name. :param data: The adds the user supplied for this specific property. :p...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_collect_unrecognized_values; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:scheme; 6, identifier:data; 7, identifier:ancestors; 8, block; 8, 9; 8, 11; 8, 32; 8, 53; 8, 57; 8, 187; 9, expression_statement; 9, 10; 10, ...
def _collect_unrecognized_values(self, scheme, data, ancestors): """ Looks for values that aren't defined in the scheme and returns a dict with any unrecognized values found. :param scheme: A :dict:, The scheme defining the validations. :param data: A :dict: user supplied for this specific prop...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_update_scheme; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:scheme; 6, identifier:ancestors; 7, block; 7, 8; 7, 10; 7, 31; 7, 52; 7, 53; 7, 62; 7, 77; 7, 81; 7, 224; 7, 231; 8, expression_statement; 8, 9; 9, comment; 10, ...
def _update_scheme(self, scheme, ancestors): """ Updates the current scheme based off special pre-defined keys and retruns a new updated scheme. :param scheme: A :dict:, The scheme defining the validations. :param ancestors: A :OrderedDict: that provides a history of its ancestors. :rty...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:_walk_tree; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 4, identifier:self; 5, identifier:data; 6, identifier:scheme; 7, default_parameter; 7, 8; 7, 9; 8, identifier:ancestors; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, ident...
def _walk_tree(self, data, scheme, ancestors=None, property_name=None, prefix=None): """ This function takes configuration data and a validation scheme then walk the configuration tree validating the configuraton data agenst the scheme provided. Will raise error on failure otherwise return None....
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:__execute_validations; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 12; 4, identifier:self; 5, identifier:validations; 6, identifier:data; 7, identifier:property_name; 8, identifier:ancestors; 9, default_parameter; 9, 10; 9, 11; 10, i...
def __execute_validations(self, validations, data, property_name, ancestors, negation=False, prefix=None): """ Validate the data for a specific configuration value. This method will look up all of the validations provided and dynamically call any validation methods. If a validation fails a error will be...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:users_feature; 3, parameters; 3, 4; 4, identifier:app; 5, block; 5, 6; 5, 8; 5, 9; 5, 28; 5, 29; 5, 37; 5, 38; 5, 45; 5, 46; 5, 53; 5, 59; 5, 65; 5, 82; 5, 83; 5, 90; 5, 97; 5, 105; 5, 143; 5, 144; 5, 151; 5, 192; 6, expression_statement; 6, 7;...
def users_feature(app): """ Add users feature Allows to register users and assign groups, instantiates flask login, flask principal and oauth integration """ # check we have jwt secret configures if not app.config.get('USER_JWT_SECRET', None): raise x.JwtSecretMissing('Please set US...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:match; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:other; 6, block; 6, 7; 6, 9; 6, 16; 7, expression_statement; 7, 8; 8, string:''' This is a noisy terminal-printing function at present since there is no need to make it a prope...
def match(self, other): ''' This is a noisy terminal-printing function at present since there is no need to make it a proper API function.''' colortext.message("FASTA Match") for frompdbID, fromchains in sorted(self.iteritems()): matched_pdbs = {} matched_chains = {} ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:generateSummaryHTMLTable; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:extraLapse; 7, identifier:TYPICAL_LAPSE; 8, block; 8, 9; 8, 11; 8, 17; 8, 21; 8, 28; 8, 29; 8, 36; 8, 43; 8, 44; 8, 50; 8, ...
def generateSummaryHTMLTable(self, extraLapse = TYPICAL_LAPSE): '''Generates a summary in HTML of the status of the expected scripts broken based on the log. This summary is returned as a list of strings. ''' scriptsRun = self.scriptsRun html = [] html.append("<table style='text-align:center;border:1px...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:apply_quality_control_checks; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:seq; 5, default_parameter; 5, 6; 5, 7; 6, identifier:check_gen9_seqs; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:check_short_length; 10, ...
def apply_quality_control_checks( seq, check_gen9_seqs=True, check_short_length=True, check_local_gc_content=True, check_global_gc_content=True): """ Raise a ValueError if the given sequence doesn't pass all of the Gen9 quality control design guidelines. Certain che...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:oauth_connect; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:provider; 6, identifier:action; 7, block; 7, 8; 7, 10; 7, 17; 7, 34; 7, 71; 7, 79; 7, 85; 7, 94; 7, 103; 7, 107; 7, 111; 7, 115; 7, 154; 7, 261; 7, 393; 7, 404; 8...
def oauth_connect(self, provider, action): """ This endpoint doesn't check if user is logged in, because it has two functions 1. If the user is not logged in, it will try to signup the user - if the social info exist, it will login - not, it will create a new account and...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:set_neighbors; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 16; 5, 25; 5, 29; 5, 186; 5, 195; 5, 206; 5, 210; 5, 237; 5, 246; 5, 266; 5, 284; 5, 298; 6, expression_statement; 6, 7; 7, string:'''Set neighbors for multi-envir...
async def set_neighbors(self): '''Set neighbors for multi-environments, their slave environments, and agents. ''' t = time.time() self.logger.debug("Settings grid neighbors for the multi-environments.") tasks = [] for i in range(len(self.grid)): for j ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:vectors; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:direction; 7, string:"all"; 8, default_parameter; 8, 9; 8, 10; 9, identifier:failed; 10, False; 11, block; 11, 12; 11, 14; 11, 15; 11...
def vectors(self, direction="all", failed=False): """Get vectors that connect at this node. Direction can be "incoming", "outgoing" or "all" (default). Failed can be True, False or all """ # check direction if direction not in ["all", "incoming", "outgoing"]: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:transmissions; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:direction; 7, string:"outgoing"; 8, default_parameter; 8, 9; 8, 10; 9, identifier:status; 10, string:"all"; 11, default_...
def transmissions(self, direction="outgoing", status="all", failed=False): """Get transmissions sent to or from this node. Direction can be "all", "incoming" or "outgoing" (default). Status can be "all" (default), "pending", or "received". failed can be True, False or "all" """ ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:user_stats; 3, parameters; 3, 4; 4, identifier:request; 5, block; 5, 6; 5, 8; 5, 13; 5, 17; 5, 21; 5, 46; 5, 63; 5, 82; 5, 88; 5, 104; 5, 111; 5, 118; 5, 138; 5, 150; 5, 166; 5, 176; 5, 186; 5, 252; 5, 364; 6, expression_statement; 6, 7; 7, com...
def user_stats(request): """ Get user statistics for selected groups of items time: time in format '%Y-%m-%d_%H:%M:%S' used for practicing user: identifier of the user (only for stuff users) username: username of user (only for users with public profile) filters: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:create_resource; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 4, identifier:output_model; 5, identifier:rtype; 6, identifier:unique; 7, identifier:links; 8, default_parameter; 8, 9; 8, 10; 9, identifier:existing_ids; 10, None; 11, defau...
def create_resource(output_model, rtype, unique, links, existing_ids=None, id_helper=None): ''' General-purpose routine to create a new resource in the output model, based on data provided output_model - Versa connection to model to be updated rtype - Type IRI for the new resource, set wit...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:patterns; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 9; 5, 55; 5, 56; 5, 62; 5, 94; 5, 105; 5, 113; 5, 114; 5, 130; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, if_statement; 9, 10; 9, 23; 10, boolean_operato...
def patterns(self): """ A tuple with re.RegexObject objects created from regex pattern arguments. """ # No explicit argument for patterns ==> consider the first source argument as pattern. if not self.args.patterns and not self.args.pattern_files: try: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:qualify; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:qualification; 5, identifier:value; 6, identifier:worker; 7, block; 7, 8; 7, 10; 7, 11; 7, 18; 7, 24; 7, 30; 7, 40; 7, 50; 7, 58; 7, 126; 7, 133; 7, 143; 7, 144; 7, 158; 7, 187; 7, 197; 7,...
def qualify(qualification, value, worker): """Assign a qualification to a worker.""" # create connection to AWS from boto.mturk.connection import MTurkConnection config = PsiturkConfig() config.load_config() aws_access_key_id = config.get('AWS Access', 'aws_access_key_id') aws_secret_access_...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:setup_jobs; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:outpath; 5, identifier:options; 6, identifier:input_files; 7, block; 7, 8; 7, 10; 7, 14; 7, 18; 7, 22; 7, 23; 7, 24; 7, 25; 7, 26; 7, 27; 7, 28; 7, 149; 7, 150; 7, 161; 7, 169; 7, 177; ...
def setup_jobs(outpath, options, input_files): ''' This function sets up the jobs by creating the necessary input files as expected. - outpath is where the output is to be stored. - options is the optparse options object. - input_files is a list of paths to input files. ''' jo...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:load_stdlib; 3, parameters; 4, block; 4, 5; 4, 7; 4, 12; 4, 49; 4, 74; 4, 96; 4, 105; 4, 192; 5, expression_statement; 5, 6; 6, string:'''Scans sys.path for standard library modules. '''; 7, if_statement; 7, 8; 7, 9; 8, identifier:_stdlib; ...
def load_stdlib(): '''Scans sys.path for standard library modules. ''' if _stdlib: return _stdlib prefixes = tuple({os.path.abspath(p) for p in ( sys.prefix, getattr(sys, 'real_prefix', sys.prefix), getattr(sys, 'base_prefix', sys.prefix), )}) for sp in sys.path...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:is_python_script; 3, parameters; 3, 4; 4, identifier:filename; 5, block; 5, 6; 5, 8; 5, 22; 5, 35; 5, 80; 6, expression_statement; 6, 7; 7, string:'''Checks a file to see if it's a python script of some sort. '''; 8, if_statement; 8, 9; 8, ...
def is_python_script(filename): '''Checks a file to see if it's a python script of some sort. ''' if filename.lower().endswith('.py'): return True if not os.path.isfile(filename): return False try: with open(filename, 'rb') as fp: if fp.read(2) != b'#!': ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:fit; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:dataset; 5, default_parameter; 5, 6; 5, 7; 6, identifier:alpha; 7, float:1e-8; 8, default_parameter; 8, 9; 8, 10; 9, identifier:max_iterations; 10, integer:10; 11, default_param...
def fit(dataset, alpha=1e-8, max_iterations=10, save_results=True, show=False): """ Function starts a job for calculation of theta parameters Parameters ---------- input - dataset object with input urls and other parameters alpha - convergence value max_iterations - define maximum number of...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:draw_image; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, identifier:image; 6, default_parameter; 6, 7; 6, 8; 7, identifier:xmin; 8, integer:0; 9, default_parameter; 9, 10; 9, 11; 10, identifier:ymin; 11, integer:...
def draw_image(self, image, xmin=0, ymin=0, xmax=None, ymax=None): """Draw an image. Do not forget to use :meth:`set_axis_equal` to preserve the aspect ratio of the image, or change the aspect ratio of the plot to the aspect ratio of the image. :param image: Pillow Image object...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_prepare_data; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 24; 5, 30; 5, 154; 5, 160; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 13; 10, pattern_list; 10, 11; 10, 12;...
def _prepare_data(self): """Prepare data before rendering When plotting very large datasets, we don't want to include data points which are outside the x-axis limits. LaTeX is very slow and consumes a lot of memory otherwise. Limiting the data points is only (easily) possible wh...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_departures; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:stop_id; 6, identifier:route; 7, identifier:destination; 8, identifier:api_key; 9, block; 9, 10; 9, 12; 9, 18; 9, 24; 9, 30; 9, 36; 9, 37; 9, 52; 9, ...
def get_departures(self, stop_id, route, destination, api_key): """Get the latest data from Transport NSW.""" self.stop_id = stop_id self.route = route self.destination = destination self.api_key = api_key # Build the URL including the STOP_ID and the API key url...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:pw; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 4, identifier:ctx; 5, identifier:key_pattern; 6, identifier:user_pattern; 7, identifier:mode; 8, identifier:strict_flag; 9, identifier:user_flag; 10, identifier:file; ...
def pw( ctx, key_pattern, user_pattern, mode, strict_flag, user_flag, file, edit_subcommand, gen_subcommand, ): """Search for USER and KEY in GPG-encrypted password file.""" # install silent Ctrl-C handler def handle_sigint(*_): click.echo() ctx.exit(1) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:launch_editor; 3, parameters; 3, 4; 3, 5; 4, identifier:ctx; 5, identifier:file; 6, block; 6, 7; 6, 9; 6, 10; 6, 21; 6, 39; 6, 40; 6, 70; 6, 71; 6, 80; 6, 106; 6, 107; 6, 139; 6, 140; 6, 149; 6, 172; 6, 185; 6, 194; 6, 195; 6, 219; 6, 220; 7, e...
def launch_editor(ctx, file): """launch editor with decrypted password database""" # do not use EDITOR environment variable (rather force user to make a concious choice) editor = os.environ.get("PW_EDITOR") if not editor: click.echo("error: no editor set in PW_EDITOR environment variables") ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:fit; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:sim_mat; 5, identifier:D_len; 6, identifier:cidx; 7, block; 7, 8; 7, 10; 7, 16; 7, 173; 8, expression_statement; 8, 9; 9, comment; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11,...
def fit(sim_mat, D_len, cidx): """ Algorithm maximizes energy between clusters, which is distinction in this algorithm. Distance matrix contains mostly 0, which are overlooked due to search of maximal distances. Algorithm does not try to retain k clusters. D: numpy array - Symmetric distance matrix k: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 1, 10; 1, 11; 2, function_name:authenticate; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:request; 6, default_parameter; 6, 7; 6, 8; 7, identifier:remote_user; 8, None; 9, comment; 10, comment; 11, block; 11, 12; 11, 14; 11, 22; 11, 28; 11...
def authenticate(self, request, remote_user=None): #pylint:disable=arguments-differ # Django <=1.8 and >=1.9 have different signatures. """ The ``username`` passed here is considered trusted. This method simply returns the ``User`` object with the given username. In ord...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:bc2pg; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 4, identifier:dataset; 5, identifier:db_url; 6, identifier:table; 7, identifier:schema; 8, identifier:query; 9, identifier:append; 10, identifier:pagesize; 11, iden...
def bc2pg(dataset, db_url, table, schema, query, append, pagesize, sortby, max_workers): """Download a DataBC WFS layer to postgres - an ogr2ogr wrapper. \b $ bcdata bc2pg bc-airports --db_url postgresql://postgres:postgres@localhost:5432/postgis The default target database can be specified by sett...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:__parseFormat; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:fmt; 6, identifier:content; 7, default_parameter; 7, 8; 7, 9; 8, identifier:fps; 9, integer:25; 10, block; 10, 11; 10, 13; 10, 17; 10, 21; 11, expression_s...
def __parseFormat(self, fmt, content, fps = 25): '''Actual parser. Please note that time_to is not required to process as not all subtitles provide it.''' headerFound = False subSection = '' for lineNo, line in enumerate(content): line = self._initialLinePrepare(line...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:_get_json; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, identifier:model; 6, default_parameter; 6, 7; 6, 8; 7, identifier:space; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:rel_path; 11, None; 12,...
def _get_json(self, model, space=None, rel_path=None, extra_params=None, get_all=None): """ Base level method for fetching data from the API """ # Only API.spaces and API.event should not provide # the `space argument if space is None and model not in (Space, Event): ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:load_config; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:app_name; 5, list_splat_pattern; 5, 6; 6, identifier:args; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 12; 9, 16; 9, 17; 9, 27; 9, 37; 9, 47; 9, 75; 9,...
def load_config(app_name, *args, **kwargs): """ Given a path to a file, parse its lines in ini-like format, and then set them in the current namespace. Quiet by default. Set verbose to True to see the absolute path to the config files printed on stderr. """ configure_logging() # compat...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:predict; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:tree; 5, identifier:x; 6, default_parameter; 6, 7; 6, 8; 7, identifier:y; 8, list:[]; 9, default_parameter; 9, 10; 9, 11; 10, identifier:dist; 11, False; 12, block; 12, 13; 12, 15; ...
def predict(tree, x, y=[], dist=False): """ Function makes a prediction of one sample with a tree model. If y label is defined it returns node identifier and margin. tree: dictionary - tree model x: numpy array - one sample from the dataset y: string, integer or float - sample label """ # ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 11; 2, function_name:pay_with_account_credit_cards; 3, parameters; 3, 4; 4, identifier:invoice_id; 5, type; 5, 6; 6, generic_type; 6, 7; 6, 8; 7, identifier:Optional; 8, type_parameter; 8, 9; 9, type; 9, 10; 10, identifier:Transaction; 11, block; 11, 12; 11,...
def pay_with_account_credit_cards(invoice_id) -> Optional[Transaction]: """ Get paid for the invoice, trying the valid credit cards on record for the account. If successful attaches the payment to the invoice and marks the invoice as paid. :param invoice_id: the id of the invoice to pay. :return: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:handle_django_settings; 3, parameters; 3, 4; 4, identifier:filename; 5, block; 5, 6; 5, 8; 5, 17; 5, 28; 5, 39; 5, 47; 5, 66; 5, 83; 5, 90; 5, 99; 5, 107; 5, 131; 5, 148; 5, 154; 5, 160; 5, 166; 5, 295; 5, 309; 5, 422; 5, 423; 5, 432; 5, 439; 5...
def handle_django_settings(filename): '''Attempts to load a Django project and get package dependencies from settings. Tested using Django 1.4 and 1.8. Not sure if some nuances are missed in the other versions. ''' old_sys_path = sys.path[:] dirpath = os.path.dirname(filename) project =...