sequence
stringlengths
546
16.2k
code
stringlengths
108
19.3k
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:is_prime; 3, parameters; 3, 4; 3, 5; 4, identifier:n; 5, default_parameter; 5, 6; 5, 7; 6, identifier:k; 7, integer:64; 8, block; 8, 9; 8, 11; 8, 18; 8, 31; 8, 49; 8, 53; 8, 59; 8, 86; 8, 116; 9, expression_statement; 9, 10; 10, comment; 11, if...
def is_prime(n, k=64): """ Test whether n is prime probabilisticly. This uses the Miller-Rabin primality test. If n is composite, then this test will declare it to be probably prime with a probability of at most 4**-k. To be on the safe side, a value of k=64 for integers up to 3072 bits is...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:iterrows; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:workbook; 7, None; 8, block; 8, 9; 8, 11; 8, 15; 8, 19; 8, 23; 8, 24; 8, 30; 8, 149; 8, 181; 8, 182; 8, 196; 8, 254; 8, 324; 9, expression_...
def iterrows(self, workbook=None): """ Yield rows as lists of data. The data is exactly as it is in the source pandas DataFrames and any formulas are not resolved. """ resolved_tables = [] max_height = 0 max_width = 0 # while yielding rows __form...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:format_listfield_nodes; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:field_name; 5, identifier:field; 6, identifier:field_id; 7, identifier:state; 8, identifier:lineno; 9, block; 9, 10; 9, 12; 9, 13; 9, 21; 9, 32; 9, 40; 9, 53; 9,...
def format_listfield_nodes(field_name, field, field_id, state, lineno): """Create a section node that documents a ListField config field. Parameters ---------- field_name : `str` Name of the configuration field (the attribute name of on the config class). field : ``lsst.pex.config.L...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:format_choicefield_nodes; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:field_name; 5, identifier:field; 6, identifier:field_id; 7, identifier:state; 8, identifier:lineno; 9, block; 9, 10; 9, 12; 9, 13; 9, 21; 9, 100; 9, 108; 9, 12...
def format_choicefield_nodes(field_name, field, field_id, state, lineno): """Create a section node that documents a ChoiceField config field. Parameters ---------- field_name : `str` Name of the configuration field (the attribute name of on the config class). field : ``lsst.pex.conf...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:format_configchoicefield_nodes; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:field_name; 5, identifier:field; 6, identifier:field_id; 7, identifier:state; 8, identifier:lineno; 9, block; 9, 10; 9, 12; 9, 13; 9, 21; 9, 122; 9, 130;...
def format_configchoicefield_nodes(field_name, field, field_id, state, lineno): """Create a section node that documents a ConfigChoiceField config field. Parameters ---------- field_name : `str` Name of the configuration field (the attribute name of on the config class). field : ``l...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:format_registryfield_nodes; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:field_name; 5, identifier:field; 6, identifier:field_id; 7, identifier:state; 8, identifier:lineno; 9, block; 9, 10; 9, 12; 9, 20; 9, 21; 9, 22; 9, 23; 9, 31...
def format_registryfield_nodes(field_name, field, field_id, state, lineno): """Create a section node that documents a RegistryField config field. Parameters ---------- field_name : `str` Name of the configuration field (the attribute name of on the config class). field : ``lsst.pex....
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:translate_argv; 3, parameters; 3, 4; 4, identifier:raw_args; 5, block; 5, 6; 5, 8; 5, 12; 5, 59; 5, 66; 5, 88; 5, 95; 5, 149; 5, 156; 5, 167; 5, 174; 5, 185; 5, 192; 5, 206; 5, 213; 5, 227; 6, expression_statement; 6, 7; 7, comment; 8, expressi...
def translate_argv(raw_args): """Enables conversion from system arguments. Parameters ---------- raw_args : list Arguments taken raw from the system input. Returns ------- kwargs : dict The input arguments formatted as a kwargs dict. To use as input, simply use `KQM...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:run; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 16; 5, 39; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:document; 11, attribute; 11, 12; 11, 15; 12,...
def run(self): """Run the ``remote-code-block`` directive. """ document = self.state.document if not document.settings.file_insertion_enabled: return [document.reporter.warning('File insertion disabled', line=self.lineno)] ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:aggregate_duplicates; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:X; 5, identifier:Y; 6, default_parameter; 6, 7; 6, 8; 7, identifier:aggregator; 8, string:"mean"; 9, default_parameter; 9, 10; 9, 11; 10, identifier:precision; 11, iden...
def aggregate_duplicates(X, Y, aggregator="mean", precision=precision): """ A function that will attempt to collapse duplicates in domain space, X, by aggregating values over the range space, Y. @ In, X, an m-by-n array of values specifying m n-dimensional samples...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:install; 3, parameters; 3, 4; 3, 5; 4, identifier:application; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 10; 7, 29; 7, 48; 7, 67; 7, 86; 7, 97; 8, expression_statement; 8, 9; 9, comment; 10, if_statement; 10, 1...
def install(application, **kwargs): """Call this to install StatsD for the Tornado application. :param tornado.web.Application application: the application to install the collector into. :param kwargs: keyword parameters to pass to the :class:`StatsDCollector` initializer. :returns: :da...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:sign; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:user_id; 5, default_parameter; 5, 6; 5, 7; 6, identifier:user_type; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:today; 10, None; 11, default_parameter; 11, 12; 11, 13; 1...
def sign(user_id, user_type=None, today=None, session=None): """Check user id for validity, then sign user in if they are signed out, or out if they are signed in. :param user_id: The ID of the user to sign in or out. :param user_type: (optional) Specify whether user is signing in as a `'student'` or `...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:display; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:obj; 5, default_parameter; 5, 6; 5, 7; 6, identifier:skiphidden; 7, True; 8, dictionary_splat_pattern; 8, 9; 9, identifier:printargs; 10, block; 10, 11; 10, 13; 10, 20; 10, 21; 10, 22; 10...
def display(obj, skiphidden=True, **printargs): """Print a view of obj, where obj is either a ctypes-derived class or an instance of such a class. Any additional keyword arguments are passed directly to the print function. This is mostly useful to introspect structures from an interactive session....
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 1, 11; 2, function_name:assemble; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 8; 4, identifier:self; 5, identifier:module; 6, list_splat_pattern; 6, 7; 7, identifier:modules; 8, dictionary_splat_pattern; 8, 9; 9, identifier:kwargs; 10, comment; 11, block; 11, 12; 11, ...
def assemble(self, module, *modules, **kwargs): # type: (AbstractModule, *AbstractModule, **Any) -> SeqRecord """Assemble the provided modules into the vector. Arguments: module (`~moclo.base.modules.AbstractModule`): a module to insert in the vector. mod...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:getback; 3, parameters; 3, 4; 3, 5; 4, identifier:config; 5, default_parameter; 5, 6; 5, 7; 6, identifier:force; 7, False; 8, block; 8, 9; 8, 11; 8, 17; 8, 23; 8, 35; 8, 73; 8, 79; 8, 88; 8, 98; 8, 102; 8, 106; 8, 125; 8, 139; 8, 140; 8, 150; 8...
def getback(config, force=False): """Goes back to the master branch, deletes the current branch locally and remotely.""" repo = config.repo active_branch = repo.active_branch if active_branch.name == "master": error_out("You're already on the master branch.") if repo.is_dirty(): ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:untldict_normalizer; 3, parameters; 3, 4; 3, 5; 4, identifier:untl_dict; 5, identifier:normalizations; 6, block; 6, 7; 6, 9; 6, 10; 6, 110; 7, expression_statement; 7, 8; 8, comment; 9, comment; 10, for_statement; 10, 11; 10, 14; 10, 19; 10, 20...
def untldict_normalizer(untl_dict, normalizations): """Normalize UNTL elements by their qualifier. Takes a UNTL descriptive metadata dictionary and a dictionary of the elements and the qualifiers for normalization: {'element1': ['qualifier1', 'qualifier2'], 'element2': ['qualifier3']} and norm...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:start; 3, parameters; 3, 4; 3, 5; 4, identifier:config; 5, default_parameter; 5, 6; 5, 7; 6, identifier:bugnumber; 7, string:""; 8, block; 8, 9; 8, 11; 8, 17; 8, 41; 8, 75; 8, 79; 8, 114; 8, 200; 8, 207; 8, 216; 8, 217; 8, 231; 8, 248; 8, 257; ...
def start(config, bugnumber=""): """Create a new topic branch.""" repo = config.repo if bugnumber: summary, bugnumber, url = get_summary(config, bugnumber) else: url = None summary = None if summary: summary = input('Summary ["{}"]: '.format(summary)).strip() or sum...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 1, 12; 2, function_name:getPortSideView; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:side; 6, type; 6, 7; 7, generic_type; 7, 8; 7, 9; 8, identifier:List; 9, type_parameter; 9, 10; 10, type; 10, 11; 11, string:"LPort"; 12, block; 12, 13; 12, 15...
def getPortSideView(self, side) -> List["LPort"]: """ Returns a sublist view for all ports of given side. :attention: Use this only after port sides are fixed! This is currently the case after running the {@link org.eclipse.elk.alg.layered.intermediate.PortListSorter}. Non-stru...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:command_line_config; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 18; 5, 22; 5, 26; 5, 30; 5, 110; 5, 210; 5, 243; 5, 244; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 1...
def command_line_config(self): """ settings.py is the basis if wants to change them by command line arguments, the existing option will be transformed to the value type in settings.py the unexisting option will be treated as string by default, and transform to certain ty...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:create_form_data; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 10; 7, 11; 7, 21; 7, 31; 7, 41; 7, 51; 7, 52; 7, 60; 7, 61; 7, 211; 7, 215; 7, 216; 7, 279; 7, 280; 7, ...
def create_form_data(self, **kwargs): """Create groupings of form elements.""" # Get the specified keyword arguments. children = kwargs.get('children', []) sort_order = kwargs.get('sort_order', None) solr_response = kwargs.get('solr_response', None) superuser = kwargs.get...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_untl; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:sort_structure; 6, block; 6, 7; 6, 9; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, call; 10, 11; 10, 16; 11, attribute; 11, 12; 11, 15; 12...
def sort_untl(self, sort_structure): """Sort the UNTL Python object by the index of a sort structure pre-ordered list. """ self.children.sort(key=lambda obj: sort_structure.index(obj.tag))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:top; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:sort_by; 6, block; 6, 7; 6, 9; 6, 21; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:sort; 12, call; 12...
def top(self, sort_by): """Get the best results according to your custom sort method.""" sort = sorted(self.results, key=sort_by) return sort
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:portTryReduce; 3, parameters; 3, 4; 3, 8; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:root; 6, type; 6, 7; 7, identifier:LNode; 8, typed_parameter; 8, 9; 8, 10; 9, identifier:port; 10, type; 10, 11; 11, identifier:LPort; 12, block; 12, 13; 1...
def portTryReduce(root: LNode, port: LPort): """ Check if majority of children is connected to same port if it is the case reduce children and connect this port instead children :note: use reduceUselessAssignments, extractSplits, flattenTrees before this function to maximize it's effect """...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 1, 14; 2, function_name:countDirectlyConnected; 3, parameters; 3, 4; 3, 8; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:port; 6, type; 6, 7; 7, identifier:LPort; 8, typed_parameter; 8, 9; 8, 10; 9, identifier:result; 10, type; 10, 11; 11, identifier:dict; 12,...
def countDirectlyConnected(port: LPort, result: dict) -> int: """ Count how many ports are directly connected to other nodes :return: cumulative sum of port counts """ inEdges = port.incomingEdges outEdges = port.outgoingEdges if port.children: ch_cnt = 0 # try: # ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:untlxml2py; 3, parameters; 3, 4; 4, identifier:untl_filename; 5, block; 5, 6; 5, 8; 5, 9; 5, 13; 5, 14; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:parent...
def untlxml2py(untl_filename): """Parse a UNTL XML file object into a pyuntl element tree. You can also pass this a string as file input like so: import StringIO untlxml2py(StringIO.StringIO(untl_string)) """ # Create a stack to hold parents. parent_stack = [] # Use iterparse to open th...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:post2pydict; 3, parameters; 3, 4; 3, 5; 4, identifier:post; 5, identifier:ignore_list; 6, block; 6, 7; 6, 9; 6, 17; 6, 21; 6, 22; 6, 23; 6, 34; 6, 35; 6, 85; 6, 401; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10,...
def post2pydict(post, ignore_list): """Convert the UNTL posted data to a Python dictionary.""" root_element = PYUNTL_DISPATCH['metadata']() untl_form_dict = {} # Turn the posted data into usable data # (otherwise the value lists get messed up). form_post = dict(post.copy()) # Loop through al...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:untlpy2dcpy; 3, parameters; 3, 4; 3, 5; 4, identifier:untl_elements; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 10; 7, 14; 7, 18; 7, 28; 7, 38; 7, 48; 7, 58; 7, 68; 7, 78; 7, 79; 7, 107; 7, 108; 7, 116; 7, 248; ...
def untlpy2dcpy(untl_elements, **kwargs): """Convert the UNTL elements structure into a DC structure. kwargs can be passed to the function for certain effects: ark: Takes an ark string and creates an identifier element out of it. domain_name: Takes a domain string and creates an ark URL from it (a...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:untlpy2highwirepy; 3, parameters; 3, 4; 3, 5; 4, identifier:untl_elements; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 10; 7, 14; 7, 18; 7, 22; 7, 26; 7, 36; 7, 189; 7, 199; 8, expression_statement; 8, 9; 9, comm...
def untlpy2highwirepy(untl_elements, **kwargs): """Convert a UNTL Python object to a highwire Python object.""" highwire_list = [] title = None publisher = None creation = None escape = kwargs.get('escape', False) for element in untl_elements.children: # If the UNTL element should be...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:untlpy2etd_ms; 3, parameters; 3, 4; 3, 5; 4, identifier:untl_elements; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 10; 7, 14; 7, 18; 7, 22; 7, 23; 7, 31; 7, 306; 7, 307; 7, 365; 8, expression_statement; 8, 9; 9, ...
def untlpy2etd_ms(untl_elements, **kwargs): """Convert the UNTL elements structure into an ETD_MS structure. kwargs can be passed to the function for certain effects. """ degree_children = {} date_exists = False seen_creation = False # Make the root element. etd_ms_root = ETD_MS_CONVERS...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:global_request; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:kind; 6, default_parameter; 6, 7; 6, 8; 7, identifier:data; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:wait; 11, True; 12, block; 12, 13;...
def global_request(self, kind, data=None, wait=True): """ Make a global request to the remote host. These are normally extensions to the SSH2 protocol. :param str kind: name of the request. :param tuple data: an optional tuple containing additional data to attach to...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_by_range; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:model_cls; 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, 21; 9, 30; 9, 48; 9, 68; 9, 69; 9, 70; ...
def get_by_range(model_cls, *args, **kwargs): """ Get ordered list of models for the specified time range. The timestamp on the earliest model will likely occur before start_timestamp. This is to ensure that we return the models for the entire range. :param model_cls: the class of the model to retu...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:add_data; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:data; 6, default_parameter; 6, 7; 6, 8; 7, identifier:metadata; 8, None; 9, block; 9, 10; 9, 12; 9, 21; 9, 22; 9, 63; 9, 64; 9, 72; 9, 113; 9, 130; 9, 134; 9, 175; 10,...
def add_data(self, data, metadata=None): """Add data to the parameter set Parameters ---------- data: numpy.ndarray one or more parameter sets. It must either be 1D or 2D, with the first dimension the number of parameter sets (K), and the second the n...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:linked_model_for_class; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:cls; 6, default_parameter; 6, 7; 6, 8; 7, identifier:make_constants_variable; 8, False; 9, dictionary_splat_pattern; 9, 10; 10, identifier:kwargs;...
def linked_model_for_class(self, cls, make_constants_variable=False, **kwargs): """ Create a PriorModel wrapping the specified class with attributes from this instance. Priors can be overridden using keyword arguments. Any constructor arguments of the new class for which there is no attribute as...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:load_categories; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:max_pages; 7, integer:30; 8, block; 8, 9; 8, 11; 8, 18; 8, 19; 8, 41; 8, 52; 8, 59; 8, 63; 8, 73; 8, 92; 9, expression_statement; 9,...
def load_categories(self, max_pages=30): """ Load all WordPress categories from the given site. :param max_pages: kill counter to avoid infinite looping :return: None """ logger.info("loading categories") # clear them all out so we don't get dupes if requested ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:load_tags; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:max_pages; 7, integer:30; 8, block; 8, 9; 8, 11; 8, 18; 8, 19; 8, 41; 8, 52; 8, 59; 8, 63; 8, 73; 8, 92; 9, expression_statement; 9, 10; 1...
def load_tags(self, max_pages=30): """ Load all WordPress tags from the given site. :param max_pages: kill counter to avoid infinite looping :return: None """ logger.info("loading tags") # clear them all out so we don't get dupes if requested if self.pur...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:load_authors; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:max_pages; 7, integer:10; 8, block; 8, 9; 8, 11; 8, 18; 8, 19; 8, 41; 8, 52; 8, 59; 8, 63; 8, 73; 8, 92; 9, expression_statement; 9, 10...
def load_authors(self, max_pages=10): """ Load all WordPress authors from the given site. :param max_pages: kill counter to avoid infinite looping :return: None """ logger.info("loading authors") # clear them all out so we don't get dupes if requested if...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:load_media; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:max_pages; 7, integer:150; 8, block; 8, 9; 8, 11; 8, 18; 8, 19; 8, 51; 8, 62; 8, 69; 8, 76; 8, 80; 8, 90; 8, 109; 9, expression_statement...
def load_media(self, max_pages=150): """ Load all WordPress media from the given site. :param max_pages: kill counter to avoid infinite looping :return: None """ logger.info("loading media") # clear them all out so we don't get dupes if self.purge_first:...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:load_wp_post; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:self; 5, identifier:api_post; 6, default_parameter; 6, 7; 6, 8; 7, identifier:bulk_mode; 8, True; 9, default_parameter; 9, 10; 9, 11; 10, identifier:post_c...
def load_wp_post(self, api_post, bulk_mode=True, post_categories=None, post_tags=None, post_media_attachments=None, posts=None): """ Load a single post from API data. :param api_post: the API data for the post :param bulk_mode: If True, minimize db operations by bulk creating post objec...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sync_deleted_attachments; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:api_post; 6, block; 6, 7; 6, 9; 6, 48; 6, 49; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, ...
def sync_deleted_attachments(self, api_post): """ Remove Posts with post_type=attachment that have been removed from the given Post on the WordPress side. Logic: - get the list of Posts with post_type = attachment whose parent_id = this post_id - get the corresponding list from ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 25; 2, function_name:http_request; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 4, identifier:self; 5, identifier:verb; 6, identifier:uri; 7, default_parameter; 7, 8; 7, 9; 8, identifier:data; 9, None; 10, default_parameter; 10, 11; 10...
def http_request(self, verb, uri, data=None, headers=None, files=None, response_format=None, is_rdf = True, stream = False ): ''' Primary route for all HTTP requests to repository. Ability to set most parameters for requests library, with some additional convenience parameters as well....
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:create; 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:specify_uri; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ignore_tombstone; 10, False; 11, default_...
def create(self, specify_uri=False, ignore_tombstone=False, serialization_format=None, stream=False, auto_refresh=None): ''' Primary method to create resources. Args: specify_uri (bool): If True, uses PUT verb and sets the URI during creation. If False, uses POST and gets repository minted URI ignore_tom...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:refresh; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:refresh_binary; 7, True; 8, block; 8, 9; 8, 11; 8, 24; 8, 25; 8, 51; 9, expression_statement; 9, 10; 10, string:''' Performs GET request a...
def refresh(self, refresh_binary=True): ''' Performs GET request and refreshes RDF information for resource. Args: None Returns: None ''' updated_self = self.repo.get_resource(self.uri) # if resource type of updated_self != self, raise exception if not isinstance(self, type(updated_self)): ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:update; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sparql_query_only; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:auto_refresh; 10, None; 11, default_parameter; 11...
def update(self, sparql_query_only=False, auto_refresh=None, update_binary=True): ''' Method to update resources in repository. Firing this method computes the difference in the local modified graph and the original one, creates an instance of SparqlUpdate and builds a sparql query that represents these differe...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:update_gunicorns; 3, parameters; 4, block; 4, 5; 4, 7; 4, 9; 4, 13; 4, 24; 4, 28; 4, 47; 4, 68; 4, 81; 4, 90; 4, 99; 4, 243; 4, 244; 4, 268; 4, 269; 4, 288; 5, expression_statement; 5, 6; 6, comment; 7, global_statement; 7, 8; 8, identifier:tic...
def update_gunicorns(): """ Updates the dict of gunicorn processes. Run the ps command and parse its output for processes named after gunicorn, building up a dict of gunicorn processes. When new gunicorns are discovered, run the netstat command to determine the ports they're serving on. """ ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:handle_keypress; 3, parameters; 3, 4; 4, identifier:screen; 5, block; 5, 6; 5, 8; 5, 10; 5, 27; 6, expression_statement; 6, 7; 7, comment; 8, global_statement; 8, 9; 9, identifier:selected_pid; 10, try_statement; 10, 11; 10, 24; 11, block; 11, ...
def handle_keypress(screen): """ Check for a key being pressed and handle it if applicable. """ global selected_pid try: key = screen.getkey().upper() except: return if key in ("KEY_DOWN", "J"): move_selection() elif key in ("KEY_UP", "K"): move_selection(...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:renderContent; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 14; 5, 20; 5, 21; 5, 22; 5, 44; 5, 75; 5, 76; 5, 82; 5, 152; 5, 172; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10...
def renderContent(self): """ Walk from outputs to inputs for each public signal register port of wrap node if required lazy load all operator and statement nodes for signals """ stm = self.stm portCtx = self.portCtx # for each inputs and outputs render exp...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:generate; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:project; 6, block; 6, 7; 6, 9; 6, 32; 6, 33; 6, 34; 6, 35; 6, 36; 6, 37; 6, 38; 6, 39; 6, 43; 6, 62; 6, 104; 6, 123; 6, 142; 6, 161; 6, 180; 6, 199; 6, 218; 6, 228; 6, 236; ...
def generate(self, project): """ Package name construction is based on provider, not on prefix. Prefix does not have to equal provider_prefix. """ for assignment in self.s2n_mapping: if assignment["ipprefix"] == project: self._name = assignment["package"] return self # # github.com -> github ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_read_elem_nodes; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:fid; 6, block; 6, 7; 6, 9; 6, 13; 6, 14; 6, 15; 6, 16; 6, 17; 6, 35; 6, 78; 6, 79; 6, 80; 6, 104; 6, 105; 6, 106; 6, 107; 6, 151; 6, 152; 6, 301; 6, 302; 6, 308; 6, ...
def _read_elem_nodes(self, fid): """ Read the nodes from an opened elem.dat file. Correct for CutMcK transformations. We store three typed of nodes in the dict 'nodes': * "raw" : as read from the elem.dat file * "presort" : pre-sorted so we can directly read node number...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:errorhandle; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:resp; 6, block; 6, 7; 6, 9; 6, 204; 7, expression_statement; 7, 8; 8, comment; 9, if_statement; 9, 10; 9, 15; 9, 144; 9, 193; 10, comparison_operator:==; 10, 11; 10, 14; ...
def errorhandle(self, resp): """Parse API error responses and raise appropriate exceptions.""" if self.format == 'json': parsed = xmltodict.parse(resp) errors = parsed[self.RESPONSE_TOKEN][self.ERROR_TOKEN] # Create list of errors if more than one error re...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:cleanup; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:config; 5, identifier:searchstring; 6, default_parameter; 6, 7; 6, 8; 7, identifier:force; 8, False; 9, block; 9, 10; 9, 12; 9, 18; 9, 29; 9, 70; 9, 77; 9, 85; 9, 91; 9, 103; 9, 104; 9, 10...
def cleanup(config, searchstring, force=False): """Deletes a found branch locally and remotely.""" repo = config.repo branches_ = list(find(repo, searchstring)) if not branches_: error_out("No branches found") elif len(branches_) > 1: error_out( "More than one branch fou...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:construct; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:data; 6, block; 6, 7; 6, 9; 6, 13; 6, 17; 6, 18; 6, 97; 6, 103; 6, 104; 6, 147; 6, 153; 6, 154; 6, 176; 6, 177; 6, 190; 6, 191; 6, 195; 6, 199; 6, 243; 6, 252; 6, 261; 6, 2...
def construct(self, data): """Construct info about a project from artefact :param data: golang-project-packages artefact :type data: json/dict """ occurrences = {} main_occurrences = {} # occurrences of devel packages for pkg in data["data"]["dependencies"]: package = pkg["package"] for item in...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:td_is_finished; 3, parameters; 3, 4; 4, identifier:tomodir; 5, block; 5, 6; 5, 8; 5, 20; 5, 21; 5, 22; 5, 23; 5, 125; 5, 126; 5, 127; 5, 128; 5, 301; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 14; 9, not_operator; 9, 1...
def td_is_finished(tomodir): """Return the state of modeling and inversion for a given tomodir. The result does not take into account sensitivities or potentials, as optionally generated by CRMod. Parameters ---------- tomodir: string Directory to check Returns ------- crmo...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sipdir_is_finished; 3, parameters; 3, 4; 4, identifier:sipdir; 5, block; 5, 6; 5, 8; 5, 20; 5, 44; 5, 61; 5, 65; 5, 69; 5, 98; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 14; 9, not_operator; 9, 10; 10, call; 10, 11; 10...
def sipdir_is_finished(sipdir): """Return the state of modeling and inversion for a given SIP dir. The result does not take into account sensitivities or potentials, as optionally generated by CRMod. Parameters ---------- sipdir: string Directory to check Returns ------- cr...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 38; 2, function_name:list; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 3, 35; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:source_ids; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sen...
def list(self, source_ids=None, seniority="all", stage=None, date_start="1494539999", date_end=TIMESTAMP_NOW, filter_id=None, page=1, limit=30, sort_by='ranking', filter_reference=None, order_by=None): """ Retreive all profiles that match the query param. Args: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:iterdupes; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:compare; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:filt; 10, None; 11, block; 11, 12; 11, 14; 11, 24; 11, 28; 11, 2...
def iterdupes(self, compare=None, filt=None): ''' streaming item iterator with low overhead duplicate file detection Parameters: - compare compare function between files (defaults to md5sum) ''' if not compare: compare = self.md5sum seen_siz = {} ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 1, 10; 2, function_name:objects_to_root; 3, parameters; 3, 4; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:objects; 6, type; 6, 7; 7, identifier:List; 8, type; 8, 9; 9, identifier:Root; 10, block; 10, 11; 10, 13; 10, 124; 10, 200; 10, 207; 11, expression_state...
def objects_to_root(objects: List) -> Root: """ Convert a list of s3 ObjectSummaries into a directory tree. :param objects: The list of objects, e.g. the result of calling `.objects.all()` on a bucket. :return: The tree structure, contained within a root node. """ def _to_t...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:parse; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:xml_file; 6, block; 6, 7; 6, 9; 6, 13; 6, 34; 6, 337; 7, expression_statement; 7, 8; 8, string:"Get a list of parsed recipes from BeerXML input"; 9, expression_statement; 9, 10...
def parse(self, xml_file): "Get a list of parsed recipes from BeerXML input" recipes = [] with open(xml_file, "rt") as f: tree = ElementTree.parse(f) for recipeNode in tree.iter(): if self.to_lower(recipeNode.tag) != "recipe": continue ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_parse_extra; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:fp; 6, block; 6, 7; 6, 9; 6, 13; 6, 17; 6, 24; 6, 158; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, ide...
def _parse_extra(self, fp): """ Parse and store the config comments and create maps for dot notion lookup """ comment = '' section = '' fp.seek(0) for line in fp: line = line.rstrip() if not line: if comment: comment ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 43; 1, 47; 2, function_name:_sample_action_fluent; 3, parameters; 3, 4; 3, 5; 3, 9; 3, 15; 3, 23; 3, 33; 3, 39; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:name; 7, type; 7, 8; 8, identifier:str; 9, typed_parameter; 9, 10; 9, 11; 10, identifi...
def _sample_action_fluent(self, name: str, dtype: tf.DType, size: Sequence[int], constraints: Dict[str, Constraints], default_value: tf.Tensor, prob: float) -> tf.Tensor: '''Samples the action fluent with given `name`, `dtype`, and `size`. ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 29; 1, 31; 2, function_name:UnitToLNode; 3, parameters; 3, 4; 3, 8; 3, 17; 3, 26; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:u; 6, type; 6, 7; 7, identifier:Unit; 8, typed_default_parameter; 8, 9; 8, 10; 8, 16; 9, identifier:node; 10, type; 10, 11; 11, generic_...
def UnitToLNode(u: Unit, node: Optional[LNode]=None, toL: Optional[dict]=None, optimizations=[]) -> LNode: """ Build LNode instance from Unit instance :attention: unit has to be synthesized """ if toL is None: toL = {} if node is None: root = LNod...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_hypergeometric_stats; 3, parameters; 3, 4; 3, 5; 4, identifier:N; 5, identifier:indices; 6, block; 6, 7; 6, 9; 6, 19; 6, 40; 6, 46; 6, 62; 6, 78; 6, 84; 6, 90; 6, 94; 6, 98; 6, 102; 6, 229; 7, expression_statement; 7, 8; 8, comment; 9, asse...
def get_hypergeometric_stats(N, indices): """Calculates hypergeom. p-values and fold enrichments for all cutoffs. Parameters ---------- N: int The length of the list indices: `numpy.ndarray` with ``dtype=np.uint16`` The (sorted) indices of the "1's" in the list. """ assert ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:purge_existing_ovb; 3, parameters; 3, 4; 3, 5; 4, identifier:nova_api; 5, identifier:neutron; 6, block; 6, 7; 6, 9; 6, 16; 6, 57; 6, 139; 6, 231; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, call; 10, 11; 10, 1...
def purge_existing_ovb(nova_api, neutron): """Purge any trace of an existing OVB deployment. """ LOG.info('Cleaning up OVB environment from the tenant.') for server in nova_api.servers.list(): if server.name in ('bmc', 'undercloud'): server.delete() if server.name.startswith(...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:reduceUselessAssignments; 3, parameters; 3, 4; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:root; 6, type; 6, 7; 7, identifier:LNode; 8, block; 8, 9; 8, 11; 8, 27; 8, 31; 8, 225; 9, expression_statement; 9, 10; 10, comment; 11, for_statement; ...
def reduceUselessAssignments(root: LNode): """ Remove assignments if it is only a direct connection and can be replaced with direct link """ for n in root.children: if n.children: reduceUselessAssignments(n) do_update = False for n in root.children: if isinstance(n.o...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:determine_completeness; 3, parameters; 3, 4; 4, identifier:py_untl; 5, block; 5, 6; 5, 8; 5, 9; 5, 94; 5, 110; 5, 114; 5, 115; 5, 116; 5, 208; 5, 209; 5, 233; 5, 234; 5, 240; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, expression_...
def determine_completeness(py_untl): """Take a Python untl and calculate the completeness. Completeness is based on this: metadata_quality.rst documentation. Returns a float 0.0 - 1.0. """ # Default values for the completeness dictionary. completeness_dict = { 'title': {'present': False...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:read_char_lengths; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:filename; 6, identifier:electrode_filename; 7, block; 7, 8; 7, 10; 7, 147; 7, 164; 7, 170; 8, expression_statement; 8, 9; 9, comment; 10, if_statement; 10, 11...
def read_char_lengths(self, filename, electrode_filename): """Read characteristic lengths from the given file. The file is expected to have either 1 or 4 entries/lines with characteristic lengths > 0 (floats). If only one value is encountered, it is used for all four entities. If four v...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:parse_atom_tag_data; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:name; 6, identifier:tag_content; 7, block; 7, 8; 7, 10; 7, 16; 8, expression_statement; 8, 9; 9, string:'''Parse the atom tag data.'''; 10, expression_state...
def parse_atom_tag_data(self, name, tag_content): '''Parse the atom tag data.''' current_atom_site = self.current_atom_site if current_atom_site.IsHETATM: # Early out - do not parse HETATM records return elif name == 'PDBx:atom_site': # We have to han...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:link; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 3, 16; 4, default_parameter; 4, 5; 4, 6; 5, identifier:origin; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:rel; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifier:value; 1...
def link(origin=None, rel=None, value=None, attributes=None, source=None): ''' Action function generator to create a link based on the context's current link, or on provided parameters :param origin: IRI/string, or list of same; origins for the created relationships. If None, the action context provide...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:foreach; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 4, default_parameter; 4, 5; 4, 6; 5, identifier:origin; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:rel; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifier:target; 12, ...
def foreach(origin=None, rel=None, target=None, attributes=None): ''' Action function generator to compute a combination of links :return: Versa action function to do the actual work ''' def _foreach(ctx): ''' Versa action function utility to compute a list of values from a list of ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_method_documentation; 3, parameters; 3, 4; 4, identifier:method; 5, block; 5, 6; 5, 8; 5, 13; 5, 45; 5, 52; 5, 56; 5, 179; 5, 190; 5, 205; 5, 345; 5, 356; 6, expression_statement; 6, 7; 7, comment; 8, import_from_statement; 8, 9; 8, 11; 9, ...
def get_method_documentation(method): """ This function uses "inspect" to retrieve information about a method. Also, if you place comment on the method, method can be docummented with "reStructured Text". :param method: method to describe :returns: { 'name' : <stri...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_dictionary_list; 3, parameters; 3, 4; 3, 5; 4, identifier:dict_list; 5, identifier:sort_key; 6, block; 6, 7; 6, 9; 6, 22; 6, 34; 7, expression_statement; 7, 8; 8, comment; 9, if_statement; 9, 10; 9, 19; 10, boolean_operator:or; 10, 11; 10,...
def sort_dictionary_list(dict_list, sort_key): """ sorts a list of dictionaries based on the value of the sort_key dict_list - a list of dictionaries sort_key - a string that identifies the key to sort the dictionaries with. Test sorting a list of dictionaries: >>> sort_dictionary_list([{...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:_push; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:self; 5, identifier:title; 6, identifier:view; 7, identifier:class_name; 8, identifier:is_class; 9, dictionary_splat_pattern; 9, 10; 10, identifier:kwargs; 11, block; 11, ...
def _push(self, title, view, class_name, is_class, **kwargs): """ Push nav data stack """ # Set the page title set_view_attr(view, "title", title, cls_name=class_name) module_name = view.__module__ method_name = view.__name__ _endpoint = build_endpoint_route_name(view,...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:render; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 12; 5, 16; 5, 218; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:menu_list; 11, list:[]; 12, expre...
def render(self): """ Render the menu into a sorted by order multi dict """ menu_list = [] menu_index = 0 for _, menu in copy.deepcopy(self.MENU).items(): subnav = [] menu["kwargs"]["_id"] = str(menu_index) menu["kwargs"]["active"] = False ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:add_item; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:self; 5, identifier:url; 6, default_parameter; 6, 7; 6, 8; 7, identifier:title; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:selection; 11, None...
def add_item(self, url, title=None, selection=None, jsonp=None, redirect=None, response_info=False): """ Method to add a new item to a instapaper account Parameters: url -> URL to add title -> optional title for the URL Returns: (status as int, s...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_determine_representative_chains; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 9; 5, 13; 5, 19; 5, 152; 5, 173; 5, 179; 6, expression_statement; 6, 7; 7, string:''' Quotient the chains to get equivalence classes of chains. ...
def _determine_representative_chains(self): ''' Quotient the chains to get equivalence classes of chains. These will be used for the actual mapping.''' # todo: This logic should be moved into the FASTA class or a more general module (maybe a fast exists which uses a C/C++ library?) but at present it is ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:_align_with_substrings; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:chains_to_skip; 7, call; 7, 8; 7, 9; 8, identifier:set; 9, argument_list; 10, block; 10, 11; 10, 13; 10, 189; 10, 190; 10, 1...
def _align_with_substrings(self, chains_to_skip = set()): '''Simple substring-based matching''' for c in self.representative_chains: # Skip specified chains if c not in chains_to_skip: #colortext.pcyan(c) #colortext.warning(self.fasta[c]) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_chain_mutations; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:pdb_id_1; 6, identifier:chain_1; 7, identifier:pdb_id_2; 8, identifier:chain_2; 9, block; 9, 10; 9, 12; 9, 13; 9, 22; 9, 31; 9, 43; 9, 55; 9, 56...
def get_chain_mutations(self, pdb_id_1, chain_1, pdb_id_2, chain_2): '''Returns a list of tuples each containing a SEQRES Mutation object and an ATOM Mutation object representing the mutations from pdb_id_1, chain_1 to pdb_id_2, chain_2. SequenceMaps are constructed in this function betwe...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:make; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:apps; 6, block; 6, 7; 6, 9; 6, 370; 6, 371; 7, expression_statement; 7, 8; 8, comment; 9, for_statement; 9, 10; 9, 13; 9, 35; 10, tuple_pattern; 10, 11; 10, 12; 11, identifier:a...
def make(self, apps): """ Make subreport items from results. """ for (appname, app) in sorted(apps.items(), key=lambda x: (x[1].priority, x[0])): logger.info('Getting report results from %r', appname) for report_data in app.report_data: if report_...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:get_report_parts; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:apps; 6, identifier:formats; 7, block; 7, 8; 7, 10; 7, 43; 7, 50; 7, 141; 7, 145; 7, 181; 7, 214; 7, 223; 7, 227; 7, 302; 8, expression_statement; 8, 9; 9, com...
def get_report_parts(self, apps, formats): """ Make report item texts in a specified format. """ for fmt in formats: width = 100 if fmt is not None else tui.get_terminal_size()[0] for sr in self.subreports: sr.make_format(fmt, width) logge...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_convert; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:chain_id; 6, identifier:residue_id; 7, identifier:from_scheme; 8, identifier:to_scheme; 9, block; 9, 10; 9, 12; 9, 13; 9, 51; 9, 106; 9, 161; 9, 199; 10, e...
def _convert(self, chain_id, residue_id, from_scheme, to_scheme): '''The actual 'private' conversion function.''' # There are 12 valid combinations but rather than write them all out explicitly, we will use recursion, sacrificing speed for brevity if from_scheme == 'rosetta': atom_i...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_create_sequences; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 9; 5, 41; 5, 42; 5, 73; 5, 88; 5, 98; 5, 108; 5, 151; 5, 152; 5, 156; 5, 263; 5, 340; 5, 341; 6, expression_statement; 6, 7; 7, string:'''Get all of the Sequen...
def _create_sequences(self): '''Get all of the Sequences - Rosetta, ATOM, SEQRES, FASTA, UniParc.''' # Create the Rosetta sequences and the maps from the Rosetta sequences to the ATOM sequences try: self.pdb.construct_pdb_to_rosetta_residue_map(self.rosetta_scripts_path, rosetta_dat...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:search_update_index; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 19; 5, 37; 5, 45; 5, 106; 5, 264; 5, 276; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifi...
def search_update_index(self): """ Updates the search index for this instance. This happens automatically on put. """ doc_id = self.search_get_document_id(self.key) fields = [search.AtomField('class_name', name) for name in self.search_get_class_names()] index ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:index_siblings; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:pid; 5, default_parameter; 5, 6; 5, 7; 6, identifier:include_pid; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:children; 10, None; 11, default_pa...
def index_siblings(pid, include_pid=False, children=None, neighbors_eager=False, eager=False, with_deposits=True): """Send sibling records of the passed pid for indexing. Note: By default does not index the 'pid' itself, only zero or more siblings. :param pid: PID (recid) of w...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:iter_paths; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:pathnames; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:mapfunc; 10, None; 11, block; 11, 12; 11, 14; 11, 22; 11, 42;...
def iter_paths(self, pathnames=None, mapfunc=None): """ Special iteration on paths. Yields couples of path and items. If a expanded path doesn't match with any files a couple with path and `None` is returned. :param pathnames: Iterable with a set of pathnames. If is `None` uses the all ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:process; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:source; 5, identifier:target; 6, identifier:rdfsonly; 7, default_parameter; 7, 8; 7, 9; 8, identifier:base; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifier:log...
def process(source, target, rdfsonly, base=None, logger=logging): ''' Prepare a statement into a triple ready for rdflib graph ''' for link in source.match(): s, p, o = link[:3] #SKip docheader statements if s == (base or '') + '@docheader': continue if p in RESOURCE_MAP...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:show_more; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 3, 14; 4, identifier:request; 5, identifier:post_process_fun; 6, identifier:get_fun; 7, identifier:object_class; 8, default_parameter; 8, 9; 8, 10; 9, identifier:should_cache; 10, ...
def show_more(request, post_process_fun, get_fun, object_class, should_cache=True, template='common_json.html', to_json_kwargs=None): """ Return list of objects of the given type. GET parameters: limit: number of returned objects (default 10, maximum 100) page: current page numb...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 28; 2, function_name:cache_control; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 3, 25; 4, default_parameter; 4, 5; 4, 6; 5, identifier:max_age; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:private; 9, False; 10, default_parameter; 10,...
def cache_control(max_age=None, private=False, public=False, s_maxage=None, must_revalidate=False, proxy_revalidate=False, no_cache=False, no_store=False): """Generate the value for a Cache-Control header. Example: >>> from rhino.http import cache_control as cc >>> from datetim...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:plot_places; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 15; 5, 25; 5, 29; 5, 33; 5, 90; 5, 133; 5, 149; 5, 159; 5, 169; 5, 212; 6, expression_statement; 6, 7; 7, string:'''Plot places where the agent has been and generate...
def plot_places(self): '''Plot places where the agent has been and generated a spirograph. ''' from matplotlib import pyplot as plt fig, ax = plt.subplots() x = [] y = [] if len(self.arg_history) > 1: xs = [] ys = [] for p in s...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:df; 3, parameters; 3, 4; 4, default_parameter; 4, 5; 4, 6; 5, identifier:unit; 6, string:'GB'; 7, block; 7, 8; 7, 10; 7, 14; 7, 25; 7, 32; 7, 38; 7, 56; 7, 57; 7, 67; 7, 76; 7, 102; 7, 113; 7, 131; 7, 322; 8, expression_statement; 8, 9; 9, stri...
def df(unit = 'GB'): '''A wrapper for the df shell command.''' details = {} headers = ['Filesystem', 'Type', 'Size', 'Used', 'Available', 'Capacity', 'MountedOn'] n = len(headers) unit = df_conversions[unit] p = subprocess.Popen(args = ['df', '-TP'], stdout = subprocess.PIPE) # -P prevents line...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:vote_mean; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:candidates; 5, identifier:votes; 6, identifier:n_winners; 7, block; 7, 8; 7, 10; 7, 23; 7, 47; 7, 69; 7, 80; 7, 97; 7, 112; 7, 116; 7, 145; 8, expression_statement; 8, 9; 9, comment; 10,...
def vote_mean(candidates, votes, n_winners): """Perform mean voting based on votes. Mean voting computes the mean preference for each of the artifact candidates from the votes and sorts the candidates in the mean preference order. Ties are resolved randomly. :param candidates: All candidates ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:vote; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:candidates; 6, block; 6, 7; 6, 9; 6, 26; 6, 43; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:ranks; ...
def vote(self, candidates): """Rank artifact candidates. The voting is needed for the agents living in societies using social decision making. The function should return a sorted list of (candidate, evaluation)-tuples. Depending on the social choice function used, the evaluation...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:gather_votes; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:candidates; 6, block; 6, 7; 6, 9; 6, 13; 6, 40; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier...
def gather_votes(self, candidates): """Gather votes for the given candidates from the agents in the environment. Returned votes are anonymous, i.e. they cannot be tracked to any individual agent afterwards. :returns: A list of votes. Each vote is a list of ``(artifa...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:install_dependencies; 3, parameters; 3, 4; 4, default_parameter; 4, 5; 4, 6; 5, identifier:feature; 6, None; 7, block; 7, 8; 7, 10; 7, 13; 7, 21; 7, 31; 7, 51; 7, 52; 7, 109; 7, 110; 7, 120; 7, 132; 7, 133; 7, 164; 7, 173; 7, 181; 7, 196; 7, 19...
def install_dependencies(feature=None): """ Install dependencies for a feature """ import subprocess echo(green('\nInstall dependencies:')) echo(green('-' * 40)) req_path = os.path.realpath(os.path.dirname(__file__) + '/../_requirements') # list all features if no feature name if not feat...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:resolve_handler; 3, parameters; 3, 4; 3, 5; 4, identifier:request; 5, identifier:view_handlers; 6, block; 6, 7; 6, 9; 6, 13; 6, 53; 6, 60; 6, 66; 6, 72; 6, 138; 6, 144; 6, 150; 6, 179; 6, 202; 6, 208; 6, 225; 6, 236; 6, 253; 7, expression_state...
def resolve_handler(request, view_handlers): """Select a suitable handler to handle the request. Returns a (handler, vary) tuple, where handler is a handler_metadata tuple and vary is a set containing header names that were used during content negotiation and that should be included in the 'Vary' heade...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:url_for; 3, parameters; 3, 4; 3, 6; 4, list_splat_pattern; 4, 5; 5, identifier:args; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kw; 8, block; 8, 9; 8, 11; 8, 12; 8, 33; 8, 43; 8, 53; 8, 65; 8, 112; 9, expression_statement; 9, 10; 10, comm...
def url_for(*args, **kw): """Build the URL for a target route. The target is the first positional argument, and can be any valid target for `Mapper.path`, which will be looked up on the current mapper object and used to build the URL for that route. Additionally, it can be one o...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 35; 2, function_name:execute; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 4, identifier:command; 5, default_parameter; 5, 6; 5, 7; 6, identifier:return_output; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:l...
def execute(command, return_output=True, log_file=None, log_settings=None, error_logfile=None, timeout=None, line_function=None, poll_timing = 0.01, logger=None, working_folder=None, env=None): """ Execute a program and logs standard output into a file. :param return_output: returns the STDOUT...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:add_backbone_atoms_linearly_from_loop_filepaths; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:loop_json_filepath; 6, identifier:fasta_filepath; 7, identifier:residue_ids; 8, block; 8, 9; 8, 11; 8, 12; 8, 24; 8, 34; 8...
def add_backbone_atoms_linearly_from_loop_filepaths(self, loop_json_filepath, fasta_filepath, residue_ids): '''A utility wrapper around add_backbone_atoms_linearly. Adds backbone atoms in a straight line from the first to the last residue of residue_ids. loop_json_filepath is a path to a ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:add_atoms_linearly; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:start_atom; 6, identifier:end_atom; 7, identifier:new_atoms; 8, default_parameter; 8, 9; 8, 10; 9, identifier:jitterbug; 10, float:0.2; 11, bloc...
def add_atoms_linearly(self, start_atom, end_atom, new_atoms, jitterbug = 0.2): '''A low-level function which adds new_atoms between start_atom and end_atom. This function does not validate the input i.e. the calling functions are responsible for ensuring that the insertion makes sense. R...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:dispatch_request; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 20; 5, 21; 5, 30; 5, 40; 5, 65; 5, 66; 5, 75; 5, 100; 5, 101; 5, 212; 5, 213; 5, 222; 5, 231; 5, 240; 5, 249; 5, 250; 5, 261; 5, 278; 5, 279; 5, 357; 5, 358; 5,...
def dispatch_request(self): """ Handle redirect back from provider """ if current_user.is_authenticated: return redirect(self.next) # clear previous! if 'social_data' in session: del session['social_data'] res = self.app.authorized_response() if ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:get_duration_measures; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:source_file_path; 5, default_parameter; 5, 6; 5, 7; 6, identifier:output_path; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:phonemic...
def get_duration_measures(source_file_path, output_path=None, phonemic=False, semantic=False, quiet=False, similarity_file = None, threshold = None): """Parses ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:tokenize; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 18; 5, 19; 5, 23; 5, 56; 5, 60; 5, 64; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 13; 9, not_operator; 9, 10; 10, attribute; 10, 11; 10, 12; 1...
def tokenize(self): """Tokenizes all multiword names in the list of Units. Modifies: - (indirectly) self.unit_list, by combining words into compound words. This is done because many names may be composed of multiple words, e.g., 'grizzly bear'. In order to count the number ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:clean; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 26; 5, 36; 5, 37; 5, 41; 5, 142; 5, 143; 5, 147; 5, 151; 5, 211; 5, 212; 5, 280; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 13; 9, not_operator; ...
def clean(self): """ Removes any Units that are not applicable given the current semantic or phonetic category. Modifies: - self.unit_list: Removes Units from this list that do not fit into the clustering category. it does by by either combining units to make compound words,...