sequence
stringlengths
546
16.2k
code
stringlengths
108
19.3k
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:write_file; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, identifier:content; 6, default_parameter; 6, 7; 6, 8; 7, identifier:filepath; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:filename; 11, Non...
def write_file(self, content, filepath=None, filename=None, indent=None, keys_to_write=None): ''' Write a Python dictionary as JSON to a file. :param content: Dictionary of key-value pairs to save to a file :param filepath: Path where the file is to be created :param filename: N...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:write_values; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, identifier:data; 6, default_parameter; 6, 7; 6, 8; 7, identifier:filepath; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:filename; 11, None...
def write_values(self, data, filepath=None, filename=None, indent=None, keys_to_write=None): """ Tries to write extra content to a JSON file. Creates filename.temp with updated content, removes the old file and finally renames the .temp to match the old file. This is in effort t...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_resolve_requirements; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:requirements; 6, block; 6, 7; 6, 9; 6, 26; 6, 39; 6, 50; 6, 54; 6, 65; 6, 75; 6, 86; 6, 87; 6, 189; 6, 249; 6, 255; 7, expression_statement; 7, 8; 8, comment; 9...
def _resolve_requirements(self, requirements): """ Internal method for resolving requirements into resource configurations. :param requirements: Resource requirements from test case configuration as dictionary. :return: Empty list if dut_count cannot be resolved, or nothing """ ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:flash; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:binary_location; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:forceflash; 10, None; 11, block; 11, 12; 11, 14; 11, 32; 11,...
def flash(self, binary_location=None, forceflash=None): """ Flash a binary to the target device using mbed-flasher. :param binary_location: Binary to flash to device. :param forceflash: Not used. :return: False if an unknown error was encountered during flashing. True if...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:open_connection; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 20; 5, 48; 5, 66; 5, 84; 5, 199; 5, 253; 5, 266; 5, 267; 5, 285; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 14; 9, comparison_operator:...
def open_connection(self): """ Open serial port connection. :return: Nothing :raises: DutConnectionError if serial port was already open or a SerialException occurs. ValueError if EnhancedSerial __init__ or value setters raise ValueError """ if self.readthread is...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:print_info; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 14; 5, 25; 5, 29; 5, 33; 5, 51; 5, 73; 5, 190; 5, 224; 5, 233; 5, 242; 5, 249; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment...
def print_info(self): """ Prints Dut information nicely formatted into a table. """ table = PrettyTable() start_string = "DutSerial {} \n".format(self.name) row = [] info_string = "" if self.config: info_string = info_string + "Configuration fo...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:check; 3, parameters; 3, 4; 4, identifier:labels; 5, block; 5, 6; 5, 8; 5, 9; 5, 22; 5, 34; 5, 56; 5, 57; 5, 65; 5, 77; 5, 97; 5, 134; 5, 135; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, if_statement; 9, 10; 9, 16; 10, not_operato...
def check(labels): """Raise IOError if labels are not correct `labels` must be a list of sorted numpy arrays of equal dimensions (must be 1D or 2D). In the case of 2D labels, the second axis must have the same shape for all labels. """ # type checking ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 24; 2, function_name:write; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 4, identifier:filename; 5, identifier:groupname; 6, identifier:items; 7, identifier:times; 8, identifier:features; 9, default_parameter; 9, 10; 9, 11; 10, id...
def write(filename, groupname, items, times, features, properties=None, dformat='dense', chunk_size='auto', sparsity=0.1, mode='a'): """Write h5features data in a HDF5 file. This function is a wrapper to the Writer class. It has three purposes: * Check parameters for errors (see details below), ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:read; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:from_item; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:to_item; 10, None; 11, default_parameter; 11, 12; 11,...
def read(self, from_item=None, to_item=None, from_time=None, to_time=None): """Retrieve requested data coordinates from the h5features index. :param str from_item: Optional. Read the data starting from this item. (defaults to the first stored item) :param str to_item: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:parse; 3, parameters; 3, 4; 4, identifier:s; 5, block; 5, 6; 5, 8; 5, 34; 5, 50; 5, 384; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:d; 11, call; 11, 12; 11, 13; 12, iden...
def parse(s): """ Parse an input string in PLA format, and return an intermediate representation dict. Parameters ---------- s : str String containing a PLA. Returns ------- A dict with all PLA information: =============== ============ ===========================...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:var; 3, parameters; 3, 4; 3, 5; 4, identifier:name; 5, default_parameter; 5, 6; 5, 7; 6, identifier:index; 7, None; 8, block; 8, 9; 8, 11; 8, 18; 8, 53; 8, 62; 8, 92; 8, 147; 8, 196; 8, 225; 9, expression_statement; 9, 10; 10, comment; 11, expr...
def var(name, index=None): """Return a unique Variable instance. .. note:: Do **NOT** call this function directly. Instead, use one of the concrete implementations: * :func:`pyeda.boolalg.bdd.bddvar` * :func:`pyeda.boolalg.expr.exprvar`, * :func:`pyeda.boolalg.table.ttvar`. ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_itemize; 3, parameters; 3, 4; 4, identifier:objs; 5, block; 5, 6; 5, 8; 5, 23; 5, 37; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 17; 9, not_operator; 9, 10; 10, call; 10, 11; 10, 12; 11, identifier:isinstance; 12, arg...
def _itemize(objs): """Recursive helper function for farray.""" if not isinstance(objs, collections.Sequence): raise TypeError("expected a sequence of Function") isseq = [isinstance(obj, collections.Sequence) for obj in objs] if not any(isseq): ftype = None for obj in objs: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_filtdim; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:items; 5, identifier:shape; 6, identifier:dim; 7, identifier:nsl; 8, block; 8, 9; 8, 11; 8, 25; 8, 32; 8, 38; 8, 39; 8, 55; 8, 56; 8, 65; 8, 66; 8, 72; 8, 350; 9, expression_stateme...
def _filtdim(items, shape, dim, nsl): """Return items, shape filtered by a dimension slice.""" normshape = tuple(stop - start for start, stop in shape) nsl_type = type(nsl) newitems = list() # Number of groups num = reduce(operator.mul, normshape[:dim+1]) # Size of each group size = len(...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 1, 10; 2, function_name:parse; 3, parameters; 3, 4; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:text; 6, type; 6, 7; 7, identifier:str; 8, type; 8, 9; 9, identifier:Docstring; 10, block; 10, 11; 10, 13; 10, 19; 10, 25; 10, 26; 10, 35; 10, 36; 10, 45; 10, 82; ...
def parse(text: str) -> Docstring: """ Parse the Google-style docstring into its components. :returns: parsed docstring """ ret = Docstring() if not text: return ret # Clean according to PEP-0257 text = inspect.cleandoc(text) # Find first title and split on its position ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:generate; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:tool; 6, default_parameter; 6, 7; 6, 8; 7, identifier:copied; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:copy; 11, False; 12, block; 12, 13; 1...
def generate(self, tool, copied=False, copy=False): """ Generates a workspace """ # copied - already done by external script, copy - do actual copy tools = [] if not tool: logger.info("Workspace supports one tool for all projects within.") return -1 else...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_send_request; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:request; 6, block; 6, 7; 6, 9; 6, 18; 6, 33; 6, 42; 6, 48; 6, 72; 6, 81; 6, 111; 6, 118; 6, 155; 6, 161; 6, 192; 6, 246; 6, 254; 6, 262; 6, 268; 6, 304; 7, expression_s...
def _send_request(self, request): """Establishes connection and returns http response based off of request. :param request: HTTPRequest object :type request: :class:`tincan.http_request.HTTPRequest` :returns: LRS Response object :rtype: :class:`tincan.lrs_response.LRSResponse` ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:query_statements; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:query; 6, block; 6, 7; 6, 9; 6, 13; 6, 26; 6, 87; 6, 99; 6, 105; 6, 114; 6, 132; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assig...
def query_statements(self, query): """Query the LRS for statements with specified parameters :param query: Dictionary of query parameters and their values :type query: dict :return: LRS Response object with the returned StatementsResult object as content :rtype: :class:`tincan.l...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:retrieve_state; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:activity; 6, identifier:agent; 7, identifier:state_id; 8, default_parameter; 8, 9; 8, 10; 9, identifier:registration; 10, None; 11, block; 11, 12; 1...
def retrieve_state(self, activity, agent, state_id, registration=None): """Retrieve state from LRS with the provided parameters :param activity: Activity object of desired state :type activity: :class:`tincan.activity.Activity` :param agent: Agent object of desired state :type a...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:as_version; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:version; 7, attribute; 7, 8; 7, 9; 8, identifier:Version; 9, identifier:latest; 10, block; 10, 11; 10, 13; 10, 237; 11, expression_state...
def as_version(self, version=Version.latest): """Returns a dict that has been modified based on versioning in order to be represented in JSON properly A class should overload as_version(self, version) implementation in order to tailor a more specific representation :param versi...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 22; 2, function_name:xrun; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 19; 4, identifier:command; 5, identifier:options; 6, default_parameter; 6, 7; 6, 8; 7, identifier:log; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:_log_container_as_...
def xrun(command, options, log=None, _log_container_as_started=False, logfile=None, timeout=-1, kill_callback=None): """ Run something on command line. Example: _run("ls", ["-lrt", "../"]) """ cmd = " ".join([command] + list(map(str, options)) ) def _print_info(msg): if ms...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:to_items; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:func; 7, identifier:str; 8, block; 8, 9; 8, 11; 9, expression_statement; 9, 10; 10, comment; 11, return_statement; 11, 12; 12, list_compreh...
def to_items(self, func=str): """ Contruct a list of dictionary items. The items are normalized using: - A sort function by key (for consistent results) - A transformation function for values The transformation function will default to `str`, which is a good choic...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_apply_sub_frames; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:cls; 5, identifier:documents; 6, identifier:subs; 7, block; 7, 8; 7, 10; 7, 11; 8, expression_statement; 8, 9; 9, comment; 10, comment; 11, for_statement; 11, 12; 11, 15; 11, 20;...
def _apply_sub_frames(cls, documents, subs): """Convert embedded documents to sub-frames for one or more documents""" # Dereference each reference for path, projection in subs.items(): # Get the SubFrame class we'll use to wrap the embedded document sub = None ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_dereference; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:cls; 5, identifier:documents; 6, identifier:references; 7, block; 7, 8; 7, 10; 7, 11; 8, expression_statement; 8, 9; 9, comment; 10, comment; 11, for_statement; 11, 12; 11, 15; 11, 20...
def _dereference(cls, documents, references): """Dereference one or more documents""" # Dereference each reference for path, projection in references.items(): # Check there is a $ref in the projection, else skip it if '$ref' not in projection: continue ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:p; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:i; 5, identifier:sample_size; 6, identifier:weights; 7, block; 7, 8; 7, 10; 7, 11; 7, 17; 7, 24; 7, 25; 7, 26; 7, 33; 7, 37; 7, 38; 7, 42; 7, 139; 8, expression_statement; 8, 9; 9, comment; 10, ...
def p(i, sample_size, weights): """ Given a weighted set and sample size return the probabilty that the weight `i` will be present in the sample. Created to test the output of the `SomeOf` maker class. The math was provided by Andy Blackshaw - thank you dad :) """ ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:diff_to_html; 3, parameters; 3, 4; 3, 5; 4, identifier:cls; 5, identifier:details; 6, block; 6, 7; 6, 9; 6, 13; 6, 14; 6, 20; 6, 68; 6, 69; 6, 82; 6, 145; 6, 146; 6, 159; 6, 263; 6, 264; 6, 277; 6, 340; 7, expression_statement; 7, 8; 8, comment...
def diff_to_html(cls, details): """Return an entry's details in HTML format""" changes = [] # Check that there are details to convert to HMTL if not details: return '' def _frame(value): """ Handle converted `Frame` references where the human...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:SortBy; 3, parameters; 3, 4; 4, list_splat_pattern; 4, 5; 5, identifier:qs; 6, block; 6, 7; 6, 9; 6, 13; 6, 56; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:sort; 12, ...
def SortBy(*qs): """Convert a list of Q objects into list of sort instructions""" sort = [] for q in qs: if q._path.endswith('.desc'): sort.append((q._path[:-5], DESCENDING)) else: sort.append((q._path, ASCENDING)) return sort
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:refresh; 3, parameters; 4, block; 4, 5; 4, 7; 4, 11; 4, 53; 4, 67; 4, 74; 4, 143; 5, expression_statement; 5, 6; 6, comment; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:override_files; 10, list:[]; 11, for_statement...
def refresh(): """Scan over all the involved directories and load configs from them.""" override_files = [] for stack in traceback.extract_stack(): f = os.path.join(os.path.dirname(stack[0]), OVERRIDE_FILE) if f not in override_files: override_files.insert(0, f) if OVERRIDE_F...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:setup; 3, parameters; 3, 4; 3, 14; 3, 18; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:level; 6, type; 6, 7; 7, generic_type; 7, 8; 7, 9; 8, identifier:Union; 9, type_parameter; 9, 10; 9, 12; 10, type; 10, 11; 11, identifier:str; 12, type; 12...
def setup(level: Union[str, int], structured: bool, config_path: str = None): """ Make stdout and stderr unicode friendly in case of misconfigured \ environments, initializes the logging, structured logging and \ enables colored logs if it is appropriate. :param level: The global logging level. ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:getMessage; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 41; 5, 150; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 18; 8, 30; 9, call; 9, 10; 9, 11; 10, identifier:isinstance; 11, argument_list; 11, 1...
def getMessage(self): """ Return the message for this LogRecord. Return the message for this LogRecord after merging any user-supplied \ arguments with the message. """ if isinstance(self.msg, numpy.ndarray): msg = self.array2string(self.msg) else: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:toposorted; 3, parameters; 3, 4; 3, 5; 4, identifier:nodes; 5, identifier:edges; 6, block; 6, 7; 6, 9; 6, 16; 6, 23; 6, 53; 6, 64; 6, 68; 6, 141; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11;...
def toposorted(nodes, edges): """ Perform a topological sort on the input resources. The topological sort uses Kahn's algorithm, which is a stable sort and will preserve this ordering; note that a DFS will produce a worst case ordering from the perspective of batching. """ incoming = defaultdi...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:proc; 3, parameters; 3, 4; 3, 5; 4, identifier:ctx; 5, identifier:files; 6, block; 6, 7; 6, 9; 6, 43; 6, 53; 6, 65; 6, 76; 7, expression_statement; 7, 8; 8, string:'''Process calculated structures'''; 9, function_definition; 9, 10; 9, 11; 9, 14...
def proc(ctx, files): '''Process calculated structures''' def calc_reader(fn, verb): if verb: echo('Reading: {:<60s}\r'.format(fn), nl=False, err=True) return ase.io.read(fn) action = ctx.parent.params['action'] systems = [calc_reader(calc, verbose) for calc in files] i...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:sample; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:self; 5, identifier:bqm; 6, default_parameter; 6, 7; 6, 8; 7, identifier:init_solution; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:tenure; 11, N...
def sample(self, bqm, init_solution=None, tenure=None, scale_factor=1, timeout=20, num_reads=1): """Run a tabu search on a given binary quadratic model. Args: bqm (:obj:`~dimod.BinaryQuadraticModel`): The binary quadratic model (BQM) to be sampled. init_solution ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:mmi_to_raster; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:force_flag; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:algorithm; 10, identifier:USE_ASCII; 11, block; 11, 12; ...
def mmi_to_raster(self, force_flag=False, algorithm=USE_ASCII): """Convert the grid.xml's mmi column to a raster using gdal_grid. A geotiff file will be created. Unfortunately no python bindings exist for doing this so we are going to do it using a shell call. .. see also:: ht...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:create_keyword_file; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:algorithm; 6, block; 6, 7; 6, 9; 6, 15; 6, 16; 6, 23; 6, 38; 6, 45; 6, 60; 6, 64; 6, 94; 6, 194; 6, 215; 6, 216; 6, 220; 6, 245; 6, 256; 6, 307; 6, 352; 6, 353; 6...
def create_keyword_file(self, algorithm): """Create keyword file for the raster file created. Basically copy a template from keyword file in converter data and add extra keyword (usually a title) :param algorithm: Which re-sampling algorithm to use. valid options are 'neare...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_check_value_mapping; 3, parameters; 3, 4; 3, 5; 4, identifier:layer; 5, default_parameter; 5, 6; 5, 7; 6, identifier:exposure_key; 7, None; 8, block; 8, 9; 8, 11; 8, 26; 8, 35; 8, 85; 8, 92; 8, 139; 8, 146; 8, 150; 8, 170; 8, 174; 8, 192; 8, 2...
def _check_value_mapping(layer, exposure_key=None): """Loop over the exposure type field and check if the value map is correct. :param layer: The layer :type layer: QgsVectorLayer :param exposure_key: The exposure key. :type exposure_key: str """ index = layer.fields().lookupField(exposure...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:clean_inasafe_fields; 3, parameters; 3, 4; 4, identifier:layer; 5, block; 5, 6; 5, 8; 5, 12; 5, 13; 5, 91; 5, 92; 5, 93; 5, 94; 5, 118; 5, 132; 5, 133; 5, 137; 5, 189; 5, 190; 5, 201; 5, 205; 5, 206; 5, 249; 5, 255; 6, expression_statement; 6, ...
def clean_inasafe_fields(layer): """Clean inasafe_fields based on keywords. 1. Must use standard field names. 2. Sum up list of fields' value and put in the standard field name. 3. Remove un-used fields. :param layer: The layer :type layer: QgsVectorLayer """ fields = [] # Exposure...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_size_is_needed; 3, parameters; 3, 4; 4, identifier:layer; 5, block; 5, 6; 5, 8; 5, 19; 5, 26; 5, 36; 5, 44; 5, 58; 5, 59; 5, 60; 5, 68; 5, 78; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 1...
def _size_is_needed(layer): """Checker if we need the size field. :param layer: The layer to test. :type layer: QgsVectorLayer :return: If we need the size field. :rtype: bool """ exposure = layer.keywords.get('exposure') if not exposure: # The layer is not an exposure. ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_remove_features; 3, parameters; 3, 4; 4, identifier:layer; 5, block; 5, 6; 5, 8; 5, 9; 5, 17; 5, 28; 5, 36; 5, 44; 5, 45; 5, 46; 5, 57; 5, 70; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, expression_statement; 9, 10; 10, assignmen...
def _remove_features(layer): """Remove features which do not have information for InaSAFE or an invalid geometry. :param layer: The vector layer. :type layer: QgsVectorLayer """ # Get the layer purpose of the layer. layer_purpose = layer.keywords['layer_purpose'] layer_subcategory = lay...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_profiles; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:overwrite; 7, False; 8, block; 8, 9; 8, 11; 8, 73; 8, 74; 8, 75; 9, expression_statement; 9, 10; 10, comment; 11, function_definition; ...
def get_profiles(self, overwrite=False): """Get all the minimum needs profiles. :returns: The minimum needs by name. :rtype: list """ def sort_by_locale(unsorted_profiles, locale): """Sort the profiles by language settings. The profiles that are in the s...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sorted_keywords_by_order; 3, parameters; 3, 4; 3, 5; 4, identifier:keywords; 5, identifier:order; 6, block; 6, 7; 6, 9; 6, 10; 6, 32; 6, 38; 6, 65; 6, 85; 7, expression_statement; 7, 8; 8, comment; 9, comment; 10, for_statement; 10, 11; 10, 14;...
def sorted_keywords_by_order(keywords, order): """Sort keywords based on defined order. :param keywords: Keyword to be sorted. :type keywords: dict :param order: Ordered list of key. :type order: list :return: Ordered dictionary based on order list. :rtype: OrderedDict """ # we n...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_layer_modes; 3, parameters; 3, 4; 4, identifier:subcategory; 5, block; 5, 6; 5, 8; 5, 17; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:layer_modes; 11, subscript; 11, ...
def get_layer_modes(subcategory): """Return all sorted layer modes from exposure or hazard. :param subcategory: Hazard or Exposure key. :type subcategory: str :returns: List of layer modes definition. :rtype: list """ layer_modes = definition(subcategory)['layer_modes'] return sorted(l...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:add_ordered_combo_item; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:combo; 5, identifier:text; 6, default_parameter; 6, 7; 6, 8; 7, identifier:data; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:count_selected_fea...
def add_ordered_combo_item( combo, text, data=None, count_selected_features=None, icon=None): """Add a combo item ensuring that all items are listed alphabetically. Although QComboBox allows you to set an InsertAlphabetically enum this only has effect when a user interactively adds combo items to ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, call; 9, 10; 9, 17; 10, attribute; 10, 11; 10, 16; 11, call; 11, 12; 11, 13; 12, identifier:super;...
def sort(self): """Sort list elements by ID.""" super(JSSObjectList, self).sort(key=lambda k: k.id)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_by_name; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, call; 9, 10; 9, 17; 10, attribute; 10, 11; 10, 16; 11, call; 11, 12; 11, 13; 12, identifie...
def sort_by_name(self): """Sort list elements by name.""" super(JSSObjectList, self).sort(key=lambda k: k.name)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:find_sorted_task_dependencies; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:task; 5, identifier:task_name; 6, identifier:task_id; 7, block; 7, 8; 7, 10; 7, 23; 7, 56; 7, 85; 7, 93; 7, 100; 7, 112; 7, 116; 7, 117; 7, 118; 7, 127; 7, 135; 7, 14...
def find_sorted_task_dependencies(task, task_name, task_id): """Find the taskIds of the chain of trust dependencies of a given task. Args: task (dict): the task definition to inspect. task_name (str): the name of the task, for logging and naming children. task_id (str): the taskId of th...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_all_artifacts_per_task_id; 3, parameters; 3, 4; 3, 5; 4, identifier:chain; 5, identifier:upstream_artifacts; 6, block; 6, 7; 6, 9; 6, 13; 6, 80; 6, 104; 6, 105; 6, 127; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, ...
def get_all_artifacts_per_task_id(chain, upstream_artifacts): """Return every artifact to download, including the Chain Of Trust Artifacts. Args: chain (ChainOfTrust): the chain of trust object upstream_artifacts: the list of upstream artifact definitions Returns: dict: sorted list...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_upstream_artifacts_full_paths_per_task_id; 3, parameters; 3, 4; 4, identifier:context; 5, block; 5, 6; 5, 8; 5, 18; 5, 32; 5, 39; 5, 43; 5, 47; 5, 124; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment;...
def get_upstream_artifacts_full_paths_per_task_id(context): """List the downloaded upstream artifacts. Args: context (scriptworker.context.Context): the scriptworker context. Returns: dict, dict: lists of the paths to upstream artifacts, sorted by task_id. First dict represents...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_PreparedData; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:order_by; 7, tuple; 8, block; 8, 9; 8, 11; 8, 19; 8, 28; 8, 68; 8, 177; 9, expression_statement; 9, 10; 10, comment; 11, if_statement;...
def _PreparedData(self, order_by=()): """Prepares the data for enumeration - sorting it by order_by. Args: order_by: Optional. Specifies the name of the column(s) to sort by, and (optionally) which direction to sort in. Default sort direction is asc. Following formats are ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:ToJSCode; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:name; 6, default_parameter; 6, 7; 6, 8; 7, identifier:columns_order; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:order_by; 11, tuple; 12, block;...
def ToJSCode(self, name, columns_order=None, order_by=()): """Writes the data table as a JS code string. This method writes a string of JS code that can be run to generate a DataTable with the specified data. Typically used for debugging only. Args: name: The name of the table. The name woul...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:ToHtml; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:columns_order; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:order_by; 10, tuple; 11, block; 11, 12; 11, 14; 11, 18; 11, 2...
def ToHtml(self, columns_order=None, order_by=()): """Writes the data table as an HTML table code string. Args: columns_order: Optional. Specifies the order of columns in the output table. Specify a list of all column IDs in the order in which you want the table ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:ToCsv; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:columns_order; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:order_by; 10, tuple; 11, default_parameter; 11, 12; 11,...
def ToCsv(self, columns_order=None, order_by=(), separator=","): """Writes the data table as a CSV string. Output is encoded in UTF-8 because the Python "csv" module can't handle Unicode properly according to its documentation. Args: columns_order: Optional. Specifies the order of columns in the...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:_ToJSonObj; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:columns_order; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:order_by; 10, tuple; 11, block; 11, 12; 11, 14; 11, 31; 1...
def _ToJSonObj(self, columns_order=None, order_by=()): """Returns an object suitable to be converted to JSON. Args: columns_order: Optional. A list of all column IDs in the order in which you want them created in the output table. If specified, all column IDs mus...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:ToJSon; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:columns_order; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:order_by; 10, tuple; 11, block; 11, 12; 11, 14; 11, 31; 11, 4...
def ToJSon(self, columns_order=None, order_by=()): """Returns a string that can be used in a JS DataTable constructor. This method writes a JSON string that can be passed directly into a Google Visualization API DataTable constructor. Use this output if you are hosting the visualization HTML on your si...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_radix_sort; 3, parameters; 3, 4; 3, 5; 4, identifier:L; 5, default_parameter; 5, 6; 5, 7; 6, identifier:i; 7, integer:0; 8, block; 8, 9; 8, 11; 8, 21; 8, 25; 8, 36; 8, 71; 8, 85; 9, expression_statement; 9, 10; 10, comment; 11, if_statement; 1...
def _radix_sort(L, i=0): """ Most significant char radix sort """ if len(L) <= 1: return L done_bucket = [] buckets = [ [] for x in range(255) ] for s in L: if i >= len(s): done_bucket.append(s) else: buckets[ ord(s[i]) ].append(s) buckets = [ _radix_sort(b, i + 1) for b in buck...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:fixed_legend_filter_sort; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:fixed_legend_filter_sort; 6, block; 6, 7; 6, 9; 6, 15; 6, 16; 6, 33; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignmen...
def fixed_legend_filter_sort(self, fixed_legend_filter_sort): """Sets the fixed_legend_filter_sort of this ChartSettings. Whether to display \"Top\"- or \"Bottom\"-ranked series in the fixed legend # noqa: E501 :param fixed_legend_filter_sort: The fixed_legend_filter_sort of this ChartSetting...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:print_table; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:title; 5, identifier:headers; 6, identifier:rows; 7, default_parameter; 7, 8; 7, 9; 8, identifier:sort_columns; 9, None; 10, block; 10, 11; 10, 13; 10, 66; 10, 83; 10, 97; 11, e...
def print_table(title, headers, rows, sort_columns=None): """ Print a table of rows with headers using tabulate. Parameters: title (:term: string): String that will be output before the Table. headers (list or tuple): List of strings that defines the header for each ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 6; 2, function_name:formatted; 3, parameters; 3, 4; 4, identifier:self; 5, comment; 6, block; 6, 7; 6, 9; 6, 10; 6, 11; 6, 15; 6, 106; 7, expression_statement; 7, 8; 8, comment; 9, comment; 10, comment; 11, expression_statement; 11, 12; 12, assignment; 12, 1...
def formatted(self): # pylint: disable=line-too-long """ Return a human readable string with the statistics for this container. The operations are sorted by decreasing average time. The three columns for `ServerTime` are included only if the WBEM server has returned WBEM...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_clusters; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:platform; 6, identifier:retry_contexts; 7, identifier:all_clusters; 8, block; 8, 9; 8, 11; 8, 15; 8, 27; 8, 120; 8, 141; 8, 156; 9, expression_statement; 9, ...
def get_clusters(self, platform, retry_contexts, all_clusters): ''' return clusters sorted by load. ''' possible_cluster_info = {} candidates = set(copy.copy(all_clusters)) while candidates and not possible_cluster_info: wait_for_any_cluster(retry_contexts) for ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 1, 20; 2, function_name:get_profile_names_and_default; 3, parameters; 4, type; 4, 5; 5, parenthesized_expression; 5, 6; 6, subscript; 6, 7; 6, 10; 6, 15; 7, attribute; 7, 8; 7, 9; 8, identifier:typing; 9, identifier:Tuple; 10, subscript; 10, 11; 10, 14; 11, att...
def get_profile_names_and_default() -> ( typing.Tuple[typing.Sequence[str], typing.Optional[Profile]]): """Return the list of profile names and the default profile object. The list of names is sorted. """ with ProfileStore.open() as config: return sorted(config), config.default
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:print_all_commands; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, keyword_separator; 6, default_parameter; 6, 7; 6, 8; 7, identifier:no_pager; 8, False; 9, block; 9, 10; 9, 12; 9, 22; 9, 39; 9, 55; 9, 59; 9, 176; 10, expression_statem...
def print_all_commands(self, *, no_pager=False): """Print help for all commands. Commands are sorted in alphabetical order and wrapping is done based on the width of the terminal. """ formatter = self.parent_parser._get_formatter() command_names = sorted(self.parent_pars...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:rank_dated_files; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:pattern; 5, identifier:dir; 6, default_parameter; 6, 7; 6, 8; 7, identifier:descending; 8, True; 9, block; 9, 10; 9, 12; 9, 27; 10, expression_statement; 10, 11; 11, comment; 12, ...
def rank_dated_files(pattern, dir, descending=True): """Search a directory for files that match a pattern. Return an ordered list of these files by filename. Args: pattern: The glob pattern to search for. dir: Path to directory where the files will be searched for. descending: Default T...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:best_structures; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:uniprot_id; 5, default_parameter; 5, 6; 5, 7; 6, identifier:outname; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:outdir; 10, None; 11, default_paramete...
def best_structures(uniprot_id, outname=None, outdir=None, seq_ident_cutoff=0.0, force_rerun=False): """Use the PDBe REST service to query for the best PDB structures for a UniProt ID. More information found here: https://www.ebi.ac.uk/pdbe/api/doc/sifts.html Link used to retrieve results: https://www.ebi....
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:map_uniprot_to_pdb; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:seq_ident_cutoff; 7, float:0.0; 8, default_parameter; 8, 9; 8, 10; 9, identifier:outdir; 10, None; 11, default_para...
def map_uniprot_to_pdb(self, seq_ident_cutoff=0.0, outdir=None, force_rerun=False): """Map the representative sequence's UniProt ID to PDB IDs using the PDBe "Best Structures" API. Will save a JSON file of the results to the protein sequences folder. The "Best structures" API is available at ht...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:map_uniprot_to_pdb; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:seq_ident_cutoff; 7, float:0.0; 8, default_parameter; 8, 9; 8, 10; 9, identifier:outdir; 10, None; 11, default_para...
def map_uniprot_to_pdb(self, seq_ident_cutoff=0.0, outdir=None, force_rerun=False): """Map all representative sequences' UniProt ID to PDB IDs using the PDBe "Best Structures" API. Will save a JSON file of the results to each protein's ``sequences`` folder. The "Best structures" API is availabl...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:get_properties_by_type; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:type; 6, default_parameter; 6, 7; 6, 8; 7, identifier:recursive; 8, True; 9, default_parameter; 9, 10; 9, 11; 10, identifier:parent_path; 11, stri...
def get_properties_by_type(self, type, recursive=True, parent_path=""): """ Returns a sorted list of fields that match the type. :param type the type of the field "string","integer" or a list of types :param recursive recurse to sub object :returns a sorted list of fields the ma...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:insert; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:index; 6, identifier:key; 7, identifier:value; 8, block; 8, 9; 8, 11; 8, 44; 8, 54; 9, expression_statement; 9, 10; 10, comment; 11, if_statement; 11, 12; 11, 17; ...
def insert(self, index, key, value): """Inserts the key, value pair before the item with the given index.""" if key in self.keyOrder: n = self.keyOrder.index(key) del self.keyOrder[n] if n < index: index -= 1 self.keyOrder.insert(index, key) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 11; 2, function_name:sort_qualified_edges; 3, parameters; 3, 4; 4, identifier:graph; 5, type; 5, 6; 6, generic_type; 6, 7; 6, 8; 7, identifier:Iterable; 8, type_parameter; 8, 9; 9, type; 9, 10; 10, identifier:EdgeTuple; 11, block; 11, 12; 11, 14; 11, 58; 12,...
def sort_qualified_edges(graph) -> Iterable[EdgeTuple]: """Return the qualified edges, sorted first by citation, then by evidence, then by annotations. :param BELGraph graph: A BEL graph """ qualified_edges = ( (u, v, k, d) for u, v, k, d in graph.edges(keys=True, data=True) if ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 1, 10; 2, function_name:_citation_sort_key; 3, parameters; 3, 4; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:t; 6, type; 6, 7; 7, identifier:EdgeTuple; 8, type; 8, 9; 9, identifier:str; 10, block; 10, 11; 10, 13; 11, expression_statement; 11, 12; 12, comment;...
def _citation_sort_key(t: EdgeTuple) -> str: """Make a confusing 4 tuple sortable by citation.""" return '"{}", "{}"'.format(t[3][CITATION][CITATION_TYPE], t[3][CITATION][CITATION_REFERENCE])
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 1, 18; 2, function_name:clean_pubmed_identifiers; 3, parameters; 3, 4; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:pmids; 6, type; 6, 7; 7, generic_type; 7, 8; 7, 9; 8, identifier:Iterable; 9, type_parameter; 9, 10; 10, type; 10, 11; 11, identifier:str; 12, ...
def clean_pubmed_identifiers(pmids: Iterable[str]) -> List[str]: """Clean a list of PubMed identifiers with string strips, deduplicates, and sorting.""" return sorted({str(pmid).strip() for pmid in pmids})
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 7; 2, function_name:hash_dump; 3, parameters; 3, 4; 4, identifier:data; 5, type; 5, 6; 6, identifier:str; 7, block; 7, 8; 7, 10; 8, expression_statement; 8, 9; 9, comment; 10, return_statement; 10, 11; 11, call; 11, 12; 11, 33; 12, attribute; 12, 13; 12, 32;...
def hash_dump(data) -> str: """Hash an arbitrary JSON dictionary by dumping it in sorted order, encoding it in UTF-8, then hashing the bytes. :param data: An arbitrary JSON-serializable object :type data: dict or list or tuple """ return hashlib.sha512(json.dumps(data, sort_keys=True).encode('utf-8...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:yield_sorted_by_type; 3, parameters; 3, 4; 4, list_splat_pattern; 4, 5; 5, identifier:typelist; 6, block; 6, 7; 6, 9; 6, 42; 7, expression_statement; 7, 8; 8, comment; 9, function_definition; 9, 10; 9, 11; 9, 13; 10, function_name:decorate; 11,...
def yield_sorted_by_type(*typelist): """ a useful decorator for the collect_impl method of SuperChange subclasses. Caches the yielded changes, and re-emits them collected by their type. The order of the types can be specified by listing the types as arguments to this decorator. Unlisted types wi...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 1, 22; 2, function_name:build_route_timetable; 3, parameters; 3, 4; 3, 8; 3, 12; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:feed; 6, type; 6, 7; 7, string:"Feed"; 8, typed_parameter; 8, 9; 8, 10; 9, identifier:route_id; 10, type; 10, 11; 11, identifier:str;...
def build_route_timetable( feed: "Feed", route_id: str, dates: List[str] ) -> DataFrame: """ Return a timetable for the given route and dates. Parameters ---------- feed : Feed route_id : string ID of a route in ``feed.routes`` dates : string or list A YYYYMMDD date stri...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 1, 14; 2, function_name:almost_equal; 3, parameters; 3, 4; 3, 8; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:f; 6, type; 6, 7; 7, identifier:DataFrame; 8, typed_parameter; 8, 9; 8, 10; 9, identifier:g; 10, type; 10, 11; 11, identifier:DataFrame; 12, type; 12...
def almost_equal(f: DataFrame, g: DataFrame) -> bool: """ Return ``True`` if and only if the given DataFrames are equal after sorting their columns names, sorting their values, and reseting their indices. """ if f.empty or g.empty: return f.equals(g) else: # Put in canonical ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 1, 22; 2, function_name:build_stop_timetable; 3, parameters; 3, 4; 3, 8; 3, 12; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:feed; 6, type; 6, 7; 7, string:"Feed"; 8, typed_parameter; 8, 9; 8, 10; 9, identifier:stop_id; 10, type; 10, 11; 11, identifier:str; 1...
def build_stop_timetable( feed: "Feed", stop_id: str, dates: List[str] ) -> DataFrame: """ Return a DataFrame containing the timetable for the given stop ID and dates. Parameters ---------- feed : Feed stop_id : string ID of the stop for which to build the timetable dates : ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_unit_property_names; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:unit_id; 7, None; 8, block; 8, 9; 8, 11; 8, 63; 9, expression_statement; 9, 10; 10, string:'''Get a list of property names f...
def get_unit_property_names(self, unit_id=None): '''Get a list of property names for a given unit, or for all units if unit_id is None Parameters ---------- unit_id: int The unit id for which the property names will be returned If None (default), will return prop...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:copy_unit_properties; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:sorting; 6, default_parameter; 6, 7; 6, 8; 7, identifier:unit_ids; 8, None; 9, block; 9, 10; 9, 12; 9, 25; 10, expression_statement; 10, 11; 11, string:'''...
def copy_unit_properties(self, sorting, unit_ids=None): '''Copy unit properties from another sorting extractor to the current sorting extractor. Parameters ---------- sorting: SortingExtractor The sorting extractor from which the properties will be copied uni...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:copy_unit_spike_features; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:sorting; 6, default_parameter; 6, 7; 6, 8; 7, identifier:unit_ids; 8, None; 9, block; 9, 10; 9, 12; 9, 25; 10, expression_statement; 10, 11; 11, string...
def copy_unit_spike_features(self, sorting, unit_ids=None): '''Copy unit spike features from another sorting extractor to the current sorting extractor. Parameters ---------- sorting: SortingExtractor The sorting extractor from which the spike features will be copied...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:merge_units; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:unit_ids; 6, block; 6, 7; 6, 9; 6, 13; 6, 42; 6, 46; 7, expression_statement; 7, 8; 8, string:'''This function merges two roots from the curation tree according to the gi...
def merge_units(self, unit_ids): '''This function merges two roots from the curation tree according to the given unit_ids. It creates a new unit_id and root that has the merged roots as children. Parameters ---------- unit_ids: list The unit ids to be merged ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:split_unit; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:unit_id; 6, identifier:indices; 7, block; 7, 8; 7, 10; 7, 14; 7, 43; 8, expression_statement; 8, 9; 9, string:'''This function splits a root from the curation tree a...
def split_unit(self, unit_id, indices): '''This function splits a root from the curation tree according to the given unit_id and indices. It creates two new unit_ids and roots that have the split root as a child. This function splits the spike train of the root by the given indices. Parameters ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_find_best_fit; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:pbin; 6, block; 6, 7; 6, 9; 6, 37; 6, 51; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:fit...
def _find_best_fit(self, pbin): """ Return best fitness rectangle from rectangles packing _sorted_rect list Arguments: pbin (PackingAlgorithm): Packing bin Returns: key of the rectangle with best fitness """ fit = ((pbin.fitness(r[0], r[1]), k) f...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 1, 8; 2, function_name:_item_attributes_match; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:crypto_config; 5, identifier:plaintext_item; 6, identifier:encrypted_item; 7, comment; 8, block; 8, 9; 8, 11; 8, 48; 9, expression_statement; 9, 10; 10, comment; 11, f...
def _item_attributes_match(crypto_config, plaintext_item, encrypted_item): # type: (CryptoConfig, Dict, Dict) -> Bool """Determines whether the unencrypted values in the plaintext items attributes are the same as those in the encrypted item. Essentially this uses brute force to cover when we don't know the ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:load_css; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 14; 5, 18; 5, 27; 5, 38; 5, 47; 5, 186; 5, 192; 5, 193; 5, 237; 5, 259; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; ...
def load_css(self): """ Creates a dict of all icons available in CSS file, and finds out what's their common prefix. :returns sorted icons dict, common icon prefix """ icons = dict() common_prefix = None parser = tinycss.make_parser('page3') style...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:rules; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 12; 5, 256; 5, 257; 5, 330; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:list_of_rules; 11, list:[...
def rules(self): """ Returns a sorted list of firewall rules. Returns: list """ list_of_rules = [] for main_row in self.dict_rules: if 'rules' in main_row: for rule_row in main_row['rules']: if 'grants' in rule...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_select_mgmt_networks; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:conf; 6, block; 6, 7; 6, 9; 6, 15; 6, 41; 6, 86; 6, 111; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, ...
def _select_mgmt_networks(self, conf): """ Select management networks. If no management network is found, it will mark the first network found by sorted the network lists. Also adding default DNS domain, if none is set. Args: conf(spec): spec """ ne...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:validate_wavetable; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 9; 5, 15; 5, 48; 5, 49; 5, 58; 5, 112; 5, 113; 5, 128; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, expression_statement; 9, 10; 10, assignment; ...
def validate_wavetable(self): """Enforce monotonic, ascending wavelength array with no zero or negative values. Raises ------ pysynphot.exceptions.DuplicateWavelength Wavelength array contains duplicate entries. pysynphot.exceptions.UnsortedWavelength ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:getStateIndex; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:state; 6, block; 6, 7; 6, 9; 6, 18; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:statecodes...
def getStateIndex(self,state): """ Returns the index of a state by calculating the state code and searching for this code a sorted list. Can be called on multiple states at once. """ statecodes = self.getStateCode(state) return np.searchsorted(self.codes,statecodes).astyp...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:guess_chimera_path; 3, parameters; 3, 4; 4, default_parameter; 4, 5; 4, 6; 5, identifier:search_all; 6, False; 7, block; 7, 8; 7, 10; 7, 22; 7, 58; 7, 74; 8, expression_statement; 8, 9; 9, comment; 10, expression_statement; 10, 11; 11, assignme...
def guess_chimera_path(search_all=False): """ Try to guess Chimera installation path. Parameters ---------- search_all : bool, optional, default=False If no CHIMERADIR env var is set, collect all posible locations of Chimera installations. Returns ------- paths: list of...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_topo_sort; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:forward; 7, True; 8, block; 8, 9; 8, 11; 8, 15; 8, 21; 8, 25; 8, 26; 8, 67; 8, 100; 8, 157; 8, 183; 9, expression_statement; 9, 10; 10, c...
def _topo_sort(self, forward=True): """ Topological sort. Returns a list of nodes where the successors (based on outgoing and incoming edges selected by the forward parameter) of any given node appear in the sequence after that node. """ topo_list = [] qu...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 34; 2, function_name:execute_sql; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 3, 25; 3, 28; 3, 31; 4, identifier:server_context; 5, identifier:schema_name; 6, identifier:sql; 7, default_parameter; 7, 8; 7, 9; 8, identifier:container_p...
def execute_sql(server_context, schema_name, sql, container_path=None, max_rows=None, sort=None, offset=None, container_filter=None, save_in_session=None, parameters=None, required_version=None, ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:find_missing_projections; 3, parameters; 3, 4; 3, 5; 4, identifier:label_list; 5, identifier:projections; 6, block; 6, 7; 6, 9; 6, 15; 6, 22; 6, 60; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, ...
def find_missing_projections(label_list, projections): """ Finds all combinations of labels in `label_list` that are not covered by an entry in the dictionary of `projections`. Returns a list containing tuples of uncovered label combinations or en empty list if there are none. All uncovered label combin...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:load_projections; 3, parameters; 3, 4; 4, identifier:projections_file; 5, block; 5, 6; 5, 8; 5, 12; 5, 63; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:projections; 11, di...
def load_projections(projections_file): """ Loads projections defined in the given `projections_file`. The `projections_file` is expected to be in the following format:: old_label_1 | new_label_1 old_label_1 old_label_2 | new_label_2 old_label_3 | You can define one projection...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:label_values; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 21; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:all_labels; 11, call; 11, 12; 11, 13; 12, ...
def label_values(self): """ Return a list of all occuring label values. Returns: list: Lexicographically sorted list (str) of label values. Example: >>> ll = LabelList(labels=[ >>> Label('a', 3.2, 4.5), >>> Label('b', 5.1, 8.9), ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_utt_regions; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 12; 5, 16; 5, 132; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:regions; 11, list:[]; 12...
def get_utt_regions(self): """ Return the regions of all utterances, assuming all utterances are concatenated. It is assumed that the utterances are sorted in ascending order for concatenation. A region is defined by offset (in chunks), length (num-chunks) and a list of referenc...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:write_separated_lines; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:path; 5, identifier:values; 6, default_parameter; 6, 7; 6, 8; 7, identifier:separator; 8, string:' '; 9, default_parameter; 9, 10; 9, 11; 10, identifier:sort_by_column...
def write_separated_lines(path, values, separator=' ', sort_by_column=0): """ Writes list or dict to file line by line. Dict can have list as value then they written separated on the line. Parameters: path (str): Path to write file to. values (dict, list): A dictionary or a list to writ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_set; 3, parameters; 3, 4; 4, identifier:s; 5, block; 5, 6; 5, 8; 5, 21; 5, 28; 5, 45; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 15; 9, not_operator; 9, 10; 10, call; 10, 11; 10, 12; 11, identifier:isinstance; 12,...
def sort_set(s): """Return a sorted list of the contents of a set This is intended to be used to iterate over world state, where you just need keys to be in some deterministic order, but the sort order should be obvious from the key. Non-strings come before strings and then tuples. Tuples compare elem...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:parse_tags; 3, parameters; 3, 4; 4, identifier:tagstring; 5, block; 5, 6; 5, 8; 5, 14; 5, 21; 5, 25; 5, 29; 5, 30; 5, 31; 5, 35; 5, 42; 5, 169; 5, 191; 5, 201; 5, 207; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 11; 9, ...
def parse_tags(tagstring): """ Parses tag input, with multiple word input being activated and delineated by commas and double quotes. Quotes take precedence, so they may contain commas. Returns a sorted list of unique tag names. Adapted from Taggit, modified to not split strings on spaces. ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_sort_by_unique_fields; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:model; 5, identifier:model_objs; 6, identifier:unique_fields; 7, block; 7, 8; 7, 10; 7, 28; 7, 53; 8, expression_statement; 8, 9; 9, comment; 10, expression_statement; 10, 1...
def _sort_by_unique_fields(model, model_objs, unique_fields): """ Sort a list of models by their unique fields. Sorting models in an upsert greatly reduces the chances of deadlock when doing concurrent upserts """ unique_fields = [ field for field in model._meta.fields if field....
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:find; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:datum; 6, block; 6, 7; 6, 9; 6, 24; 6, 80; 7, expression_statement; 7, 8; 8, comment; 9, if_statement; 9, 10; 9, 21; 10, boolean_operator:and; 10, 11; 10, 18; 11, call; 11, 12; ...
def find(self, datum): """Return sorted value of This if list or dict.""" if isinstance(datum.value, dict) and self.expressions: return datum if isinstance(datum.value, dict) or isinstance(datum.value, list): key = (functools.cmp_to_key(self._compare) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_subset_riverid_index_list; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:river_id_list; 6, block; 6, 7; 6, 9; 6, 13; 6, 17; 6, 21; 6, 71; 6, 80; 6, 89; 6, 98; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement...
def get_subset_riverid_index_list(self, river_id_list): """ Gets the subset riverid_list from the netcdf file Optional returns include the list of valid river ids in the dataset as well as a list of missing rive rids Parameters ---------- river_id_list: list or :...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:get_child_type_choices; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:request; 6, identifier:action; 7, block; 7, 8; 7, 10; 7, 11; 7, 26; 7, 27; 7, 37; 7, 41; 7, 45; 7, 122; 8, expression_statement; 8, 9; 9, comment; 10, co...
def get_child_type_choices(self, request, action): """ Override choice labels with ``verbose_name`` from plugins and sort. """ # Get choices from the super class to check permissions. choices = super(ChildModelPluginPolymorphicParentModelAdmin, self) \ .get_child_type...