sequence
stringlengths
492
15.9k
code
stringlengths
75
8.58k
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: Na...
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): name = filename if filename else self.filename path = filepath if filepath else self.filepath name = self._ends_with(name, ".json") path = self._ends_with(path, os.path.sep) if not os.pat...
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, 24; 6, 37; 6, 48; 6, 52; 6, 63; 6, 73; 6, 84; 6, 186; 6, 246; 6, 252; 7, try_statement; 7, 8; 7, 19; 8, block; 8, 9; 9, express...
def _resolve_requirements(self, requirements): try: dut_count = requirements["duts"]["*"]["count"] except KeyError: return [] default_values = { "type": "hardware", "allowed_platforms": [], "nick": None, } default_values...
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, 30; 11, 74; 11,...
def flash(self, binary_location=None, forceflash=None): if not Flash: self.logger.error("Mbed-flasher not installed!") raise ImportError("Mbed-flasher not installed!") try: self.build = Build.init(binary_location) except NotImplementedError as error: ...
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, 18; 5, 46; 5, 64; 5, 82; 5, 197; 5, 251; 5, 264; 5, 282; 6, if_statement; 6, 7; 6, 12; 7, comparison_operator:is; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier...
def open_connection(self): if self.readthread is not None: raise DutConnectionError("Trying to open serial port which was already open") self.logger.info("Open Connection " "for '%s' using '%s' baudrate: %d" % (self.dut_name, ...
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, 12; 5, 23; 5, 27; 5, 31; 5, 49; 5, 71; 5, 188; 5, 222; 5, 231; 5, 240; 5, 247; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:table; 9, call; 9, 10...
def print_info(self): table = PrettyTable() start_string = "DutSerial {} \n".format(self.name) row = [] info_string = "" if self.config: info_string = info_string + "Configuration for this DUT:\n\n {} \n".format(self.config) if self.comport: table....
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, 19; 5, 31; 5, 53; 5, 61; 5, 73; 5, 93; 5, 130; 6, if_statement; 6, 7; 6, 13; 7, not_operator; 7, 8; 8, call; 8, 9; 8, 10; 9, identifier:isinstance; 10, argument_list; 10, 11; ...
def check(labels): if not isinstance(labels, list): raise IOError('labels are not in a list') if not len(labels): raise IOError('the labels list is empty') if not all([isinstance(l, np.ndarray) for l in labels]): raise IOError('all labels must be numpy arrays'...
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'): sparsity = sparsity if dformat == 'sparse' else None data = Data(items, times, features, properties=properties, sparsity=sparsity, check=True) Writer...
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): if to_item is None: to_item = self.items.data[-1] if from_item is None else from_item if from_item is None: from_item = self.items.data[0] if not self.items.is_valid_interval(from_ite...
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, 32; 5, 48; 5, 373; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:d; 9, call; 9, 10; 9, 11; 10, identifier:dict; 11, argument_list; 11, 12; 11, 15; 11, 18;...
def parse(s): d = dict(ninputs=None, noutputs=None, input_labels=None, output_labels=None, intype=None, cover=set()) lines = [line.strip() for line in s.splitlines()] for i, line in enumerate(lines, start=1): if not line or _COMMENT.match(line): continue ...
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, 16; 8, 51; 8, 60; 8, 90; 8, 145; 8, 194; 8, 223; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, ...
def var(name, index=None): tname = type(name) if tname is str: names = (name, ) elif tname is tuple: names = name else: fstr = "expected name to be a str or tuple, got {0.__name__}" raise TypeError(fstr.format(tname)) if not names: raise ValueError("expected a...
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, 21; 5, 35; 6, if_statement; 6, 7; 6, 15; 7, not_operator; 7, 8; 8, call; 8, 9; 8, 10; 9, identifier:isinstance; 10, argument_list; 10, 11; 10, 12; 11, identifier:objs; 12, at...
def _itemize(objs): 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: if ftype is None: if isin...
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, 23; 8, 30; 8, 36; 8, 52; 8, 61; 8, 67; 8, 341; 9, expression_statement; 9, 10; 10, assignment; 1...
def _filtdim(items, shape, dim, nsl): normshape = tuple(stop - start for start, stop in shape) nsl_type = type(nsl) newitems = list() num = reduce(operator.mul, normshape[:dim+1]) size = len(items) // num n = normshape[dim] if nsl_type is int: for i in range(num): if i % ...
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, 17; 10, 23; 10, 32; 10, 41; 10, 78; 10, 88; 10, 98; 10, 148;...
def parse(text: str) -> Docstring: ret = Docstring() if not text: return ret text = inspect.cleandoc(text) match = _titles_re.search(text) if match: desc_chunk = text[: match.start()] meta_chunk = text[match.start() :] else: desc_chunk = text meta_chunk = ...
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): tools = [] if not tool: logger.info("Workspace supports one tool for all projects within.") return -1 else: tools = [tool] result = 0 for export_tool in tools: tool_export = ToolsS...
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, 16; 6, 31; 6, 40; 6, 46; 6, 70; 6, 79; 6, 109; 6, 116; 6, 153; 6, 159; 6, 190; 6, 244; 6, 252; 6, 260; 6, 266; 6, 302; 7, expression_stateme...
def _send_request(self, request): headers = {"X-Experience-API-Version": self.version} if self.auth is not None: headers["Authorization"] = self.auth headers.update(request.headers) params = request.query_params params = {k: unicode(params[k]).encode('utf-8') for k in...
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, 11; 6, 24; 6, 85; 6, 97; 6, 103; 6, 112; 6, 130; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:params; 10, dicti...
def query_statements(self, query): params = {} param_keys = [ "registration", "since", "until", "limit", "ascending", "related_activities", "related_agents", "format", "attachments", ] ...
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): if not isinstance(activity, Activity): activity = Activity(activity) if not isinstance(agent, Agent): agent = Agent(agent) request = HTTPRequest( method="GET", resource="activi...
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, 235; 11, if_statement; 11, 12; 11...
def as_version(self, version=Version.latest): if not isinstance(self, list): result = {} for k, v in self.iteritems() if isinstance(self, dict) else vars(self).iteritems(): k = self._props_corrected.get(k, k) if isinstance(v, SerializableBase): ...
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): cmd = " ".join([command] + list(map(str, options)) ) def _print_info(msg): if msg is None: return if log: log.info(msg) else: print(msg) def _p...
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; 9, return_statement; 9, 10; 10, list_comprehension; 10, 11; 10, 21; 11, tuple; 11, 12; 11, 13; 12,...
def to_items(self, func=str): return [ (key, func(self.kwargs[key])) for key in sorted(self.kwargs.keys()) ]
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; 8, for_statement; 8, 9; 8, 12; 8, 17; 9, pattern_list; 9, 10; 9, 11; 10, identifier:path; 11, identifier:project...
def _apply_sub_frames(cls, documents, subs): for path, projection in subs.items(): sub = None expect_map = False if '$sub' in projection: sub = projection.pop('$sub') elif '$sub.' in projection: sub = projection.pop('$sub.') ...
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; 8, for_statement; 8, 9; 8, 12; 8, 17; 9, pattern_list; 9, 10; 9, 11; 10, identifier:path; 11, identifier:projec...
def _dereference(cls, documents, references): for path, projection in references.items(): if '$ref' not in projection: continue ids = set() for document in documents: value = cls._path_to_value(path, document) if not value: ...
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, 14; 7, 21; 7, 28; 7, 32; 7, 36; 7, 125; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:weight_...
def p(i, sample_size, weights): weight_i = weights[i] weights_sum = sum(weights) other_weights = list(weights) del other_weights[i] probability_of_i = 0 for picks in range(0, sample_size): permutations = list(itertools.permutations(other_weights, picks)) ...
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, 11; 6, 17; 6, 63; 6, 76; 6, 139; 6, 152; 6, 256; 6, 269; 6, 332; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:chan...
def diff_to_html(cls, details): changes = [] if not details: return '' def _frame(value): if isinstance(value, dict) and '_str' in value: return value['_str'] elif isinstance(value, list): return ', '.join([_frame(v) for v in va...
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, 11; 6, 54; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:sort; 10, list:[]; 11, for_statement; 11, 12; 11, 13; 11, 14; 12,...
def SortBy(*qs): 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, 9; 4, 51; 4, 65; 4, 72; 4, 141; 5, expression_statement; 5, 6; 6, assignment; 6, 7; 6, 8; 7, identifier:override_files; 8, list:[]; 9, for_statement; 9, 10; 9, 11; 9, 16; 10, identifier:stack; 11, call...
def refresh(): 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_FILE in override_files: del override_files[override_files.index(OVERRI...
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): global logs_are_structured logs_are_structured = structured if not isinstance(level, int): level = logging._nameToLevel[level] def ensure_utf8_stream(stream): if not isinstance(stream, io.StringIO) and hasattr(...
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, 39; 5, 148; 6, if_statement; 6, 7; 6, 16; 6, 28; 7, call; 7, 8; 7, 9; 8, identifier:isinstance; 9, argument_list; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifie...
def getMessage(self): if isinstance(self.msg, numpy.ndarray): msg = self.array2string(self.msg) else: msg = str(self.msg) if self.args: a2s = self.array2string if isinstance(self.args, Dict): args = {k: (a2s(v) if isinstance(v, nump...
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, 14; 6, 21; 6, 51; 6, 62; 6, 66; 6, 138; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:incoming; 10, call; 10, 11; 10,...
def toposorted(nodes, edges): incoming = defaultdict(set) outgoing = defaultdict(set) for edge in edges: incoming[edge.to_id].add(edge.from_id) outgoing[edge.from_id].add(edge.to_id) working_set = list(nodes.values()) results = [] while working_set: remaining = [] ...
0, ERROR; 0, 1; 0, 2; 0, 5; 0, 7; 0, 41; 0, 51; 0, 63; 0, 74; 0, 77; 0, 303; 0, 306; 0, 324; 0, 334; 0, 335; 1, identifier:proc; 2, parameters; 2, 3; 2, 4; 3, identifier:ctx; 4, identifier:files; 5, expression_statement; 5, 6; 6, string:'''Process calculated structures'''; 7, function_definition; 7, 8; 7, 9; 7, 12; 8, ...
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] if ...
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): if init_solution is not None: if not isinstance(init_solution, dimod.SampleSet): raise TypeError("'init_solution' should be a 'dimod.SampleSet' instance") if len(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): LOGGER.debug('mmi_to_raster requested.') if algorithm is None: algorithm = USE_ASCII if self.algorithm_name: tif_path = os.path.join( self.output_dir, '%s-%s.tif' % ( self....
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, 13; 6, 20; 6, 35; 6, 42; 6, 57; 6, 61; 6, 90; 6, 190; 6, 211; 6, 215; 6, 240; 6, 251; 6, 302; 6, 347; 6, 375; 6, 381; 6, 389; 6, 401...
def create_keyword_file(self, algorithm): keyword_io = KeywordIO() mmi_default_classes = default_classification_thresholds( earthquake_mmi_scale ) mmi_default_threshold = { earthquake_mmi_scale['key']: { 'active': True, 'classes': m...
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, 24; 8, 33; 8, 83; 8, 89; 8, 136; 8, 143; 8, 147; 8, 167; 8, 171; 8, 189; 8, 201; 8, ...
def _check_value_mapping(layer, exposure_key=None): index = layer.fields().lookupField(exposure_type_field['field_name']) unique_exposure = layer.uniqueValues(index) if layer.keywords['layer_purpose'] == layer_purpose_hazard['key']: if not exposure_key: message = tr('Hazard value mapping...
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, 10; 5, 86; 5, 110; 5, 124; 5, 128; 5, 180; 5, 191; 5, 195; 5, 238; 5, 244; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:fields; 9, lis...
def clean_inasafe_fields(layer): fields = [] if layer.keywords['layer_purpose'] == layer_purpose_exposure['key']: fields = get_fields( layer.keywords['layer_purpose'], layer.keywords['exposure']) elif layer.keywords['layer_purpose'] == layer_purpose_hazard['key']: fields = get_fi...
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, 17; 5, 23; 5, 33; 5, 40; 5, 53; 5, 61; 5, 71; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:exposure; 9, call; 9, 10; 9, 15; 10, attribute; ...
def _size_is_needed(layer): exposure = layer.keywords.get('exposure') if not exposure: return False indivisible_exposure_keys = [f['key'] for f in indivisible_exposure] if exposure in indivisible_exposure_keys: return False if layer.geometryType() == QgsWkbTypes.PointGeometry: ...
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, 14; 5, 25; 5, 33; 5, 41; 5, 52; 5, 65; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:layer_purpose; 9, subscript; 9, 10; 9, 13; 10, attribu...
def _remove_features(layer): layer_purpose = layer.keywords['layer_purpose'] layer_subcategory = layer.keywords.get(layer_purpose) compulsory_field = get_compulsory_fields(layer_purpose, layer_subcategory) inasafe_fields = layer.keywords['inasafe_fields'] field_names = inasafe_fields.get(compulsory_...
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, 69; 9, function_definition; 9, 10; 9, 11; 9, 14; 10, function_name:sort_by_locale; 11, paramete...
def get_profiles(self, overwrite=False): def sort_by_locale(unsorted_profiles, locale): if locale is None: return unsorted_profiles locale = '_%s' % locale[:2] profiles_our_locale = [] profiles_remaining = [] for profile_name in unsorte...
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, 29; 6, 35; 6, 62; 6, 82; 7, for_statement; 7, 8; 7, 11; 7, 19; 8, pattern_list; 8, 9; 8, 10; 9, identifier:key; 10, identifier:...
def sorted_keywords_by_order(keywords, order): for key, value in list(keywords.items()): if value is None: del keywords[key] ordered_keywords = OrderedDict() for key in order: if key in list(keywords.keys()): ordered_keywords[key] = keywords.get(key) for keyword i...
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, 15; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:layer_modes; 9, subscript; 9, 10; 9, 14; 10, call; 10, 11; 10, 12; 11, identifier:de...
def get_layer_modes(subcategory): layer_modes = definition(subcategory)['layer_modes'] return sorted(layer_modes, key=lambda k: k['key'])
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): if count_selected_features is not None: text += ' (' + tr('{count} selected features').format( count=count_selected_features) + ')' size = combo.count() for combo_index in range(0, size)...
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; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 15; 8, attribute; 8, 9; 8, 14; 9, call; 9, 10; 9, 11; 10, identifier:super; 11, argument_list; 11, 12; 11, 13; 12, identifier:JSSObj...
def sort(self): 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; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 15; 8, attribute; 8, 9; 8, 14; 9, call; 9, 10; 9, 11; 10, identifier:super; 11, argument_list; 11, 12; 11, 13; 12, identifie...
def sort_by_name(self): 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, 21; 7, 54; 7, 83; 7, 91; 7, 98; 7, 110; 7, 114; 7, 123; 7, 131; 7, 143; 8, expression_stateme...
def find_sorted_task_dependencies(task, task_name, task_id): log.info("find_sorted_task_dependencies {} {}".format(task_name, task_id)) cot_input_dependencies = [ _craft_dependency_tuple(task_name, task_type, task_id) for task_type, task_id in task['extra'].get('chainOfTrust', {}).get('inputs', ...
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, 11; 6, 76; 6, 100; 6, 122; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:all_artifact...
def get_all_artifacts_per_task_id(chain, upstream_artifacts): all_artifacts_per_task_id = {} for link in chain.links: if link.task_type in PARENT_TASK_TYPES: add_enumerable_item_to_dict( dict_=all_artifacts_per_task_id, key=link.task_id, item='public/task-graph.json' ...
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, 16; 5, 30; 5, 37; 5, 41; 5, 45; 5, 122; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:upstream_artifacts; 9,...
def get_upstream_artifacts_full_paths_per_task_id(context): upstream_artifacts = context.task['payload']['upstreamArtifacts'] task_ids_and_relative_paths = [ (artifact_definition['taskId'], artifact_definition['paths']) for artifact_definition in upstream_artifacts ] optional_artifacts_p...
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, 17; 8, 26; 8, 66; 8, 175; 9, if_statement; 9, 10; 9, 12; 10, not_operator; 10, 11; 11, identifi...
def _PreparedData(self, order_by=()): if not order_by: return self.__data sorted_data = self.__data[:] if isinstance(order_by, six.string_types) or ( isinstance(order_by, tuple) and len(order_by) == 2 and order_by[1].lower() in ["asc", "desc"]): order_by = (order_by,) for key...
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=()): encoder = DataTableJSONEncoder() if columns_order is None: columns_order = [col["id"] for col in self.__columns] col_dict = dict([(col["id"], col) for col in self.__columns]) jscode = "var %s = new google.visualization.DataTable();\n" % na...
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, 16; 11, 20; 11, 2...
def ToHtml(self, columns_order=None, order_by=()): table_template = "<html><body><table border=\"1\">%s</table></body></html>" columns_template = "<thead><tr>%s</tr></thead>" rows_template = "<tbody>%s</tbody>" row_template = "<tr>%s</tr>" header_cell_template = "<th>%s</th>" cell_template = "<t...
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=","): csv_buffer = six.StringIO() writer = csv.writer(csv_buffer, delimiter=separator) if columns_order is None: columns_order = [col["id"] for col in self.__columns] col_dict = dict([(col["id"], col) for col in self.__columns]) def en...
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, 29; 11, 46; 1...
def _ToJSonObj(self, columns_order=None, order_by=()): if columns_order is None: columns_order = [col["id"] for col in self.__columns] col_dict = dict([(col["id"], col) for col in self.__columns]) col_objs = [] for col_id in columns_order: col_obj = {"id": col_dict[col_id]["id"], ...
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, 29; 11, 44; 12, e...
def ToJSon(self, columns_order=None, order_by=()): encoded_response_str = DataTableJSONEncoder().encode(self._ToJSonObj(columns_order, order_by)) if not isinstance(encoded_response_str, str): return encoded_response_str.encode("utf-8") return encoded_response_str
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, 19; 8, 23; 8, 34; 8, 69; 8, 83; 9, if_statement; 9, 10; 9, 16; 10, comparison_operator:<=; 10, 11; 10, ...
def _radix_sort(L, i=0): 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 buckets ] return done_bucket + [ b for blist in b...
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, 13; 6, 29; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:allowed_values; 10, list:["T...
def fixed_legend_filter_sort(self, fixed_legend_filter_sort): allowed_values = ["TOP", "BOTTOM"] if fixed_legend_filter_sort not in allowed_values: raise ValueError( "Invalid value for `fixed_legend_filter_sort` ({0}), must be one of {1}" .format(fixed_legend_...
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, 64; 10, 81; 10, 95; 11, if_statem...
def print_table(title, headers, rows, sort_columns=None): if sort_columns is not None: if isinstance(sort_columns, int): rows = sorted(rows, key=itemgetter(sort_columns)) elif isinstance(sort_columns, (list, tuple)): rows = sorted(rows, key=itemgetter(*sort_columns)) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:formatted; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 96; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:ret; 9, string:"Statistics (times in seconds, lengths in Bytes):\n"; 10, if_statement; 10,...
def formatted(self): ret = "Statistics (times in seconds, lengths in Bytes):\n" if self.enabled: snapshot = sorted(self.snapshot(), key=lambda item: item[1].avg_time, reverse=True) include_svr = False for nam...
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 cl...
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]]): 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, 20; 9, 37; 9, 53; 9, 57; 9, 174; 10, expression_statement; 10...
def print_all_commands(self, *, no_pager=False): formatter = self.parent_parser._get_formatter() command_names = sorted(self.parent_parser.subparsers.choices.keys()) max_name_len = max([len(name) for name in command_names]) + 1 commands = "" for name in command_names: ...
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, 25; 10, expression_statement; 10, 11; 11, assignment; 11, 12; ...
def rank_dated_files(pattern, dir, descending=True): files = glob.glob(op.join(dir, pattern)) return sorted(files, reverse=descending)
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): outfile = '' if not outdir: outdir = '' if not outname and outdir: outname = uniprot_id if outname: outname = op.join(outdir, outname) outfile = '{}.json'.format(outname) ...
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): if not self.representative_sequence: log.error('{}: no representative sequence set, cannot use best structures API'.format(self.id)) return None uniprot_id = self.representative_sequence.uniprot ...
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): all_representative_uniprots = [] for g in self.genes_with_a_representative_sequence: uniprot_id = g.protein.representative_sequence.uniprot if uniprot_id: if '-' in uniprot_id: ...
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=""): if parent_path: parent_path += "." if isinstance(type, str): if type == "*": type = set(MAPPING_NAME_TYPE.keys()) - set(["nested", "multi_field", "multifield"]) else: ...
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, 42; 8, 52; 9, if_statement; 9, 10; 9, 15; 10, comparison_operator:in; 10, 11; 10, 12; 11, identif...
def insert(self, index, key, value): if key in self.keyOrder: n = self.keyOrder.index(key) del self.keyOrder[n] if n < index: index -= 1 self.keyOrder.insert(index, key) super(SortedDict, self).__setitem__(key, value)
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, 56; 12, express...
def sort_qualified_edges(graph) -> Iterable[EdgeTuple]: qualified_edges = ( (u, v, k, d) for u, v, k, d in graph.edges(keys=True, data=True) if graph.has_edge_citation(u, v, k) and graph.has_edge_evidence(u, v, k) ) return sorted(qualified_edges, key=_sort_qualified_edges_helper)
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; 11, return_statement; 11, 12; 12, call; 12, 13; 12, 16...
def _citation_sort_key(t: EdgeTuple) -> str: 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]: 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; 8, return_statement; 8, 9; 9, call; 9, 10; 9, 31; 10, attribute; 10, 11; 10, 30; 11, call; 11, 12; 11, 15; 12, attribute; 12, 13; 12, 14...
def hash_dump(data) -> str: return hashlib.sha512(json.dumps(data, sort_keys=True).encode('utf-8')).hexdigest()
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, 40; 7, function_definition; 7, 8; 7, 9; 7, 11; 8, function_name:decorate; 9, parameters; 9, 10; 10, identifier:fun; 11, block; 11...
def yield_sorted_by_type(*typelist): def decorate(fun): @wraps(fun) def decorated(*args, **kwds): return iterate_by_type(fun(*args, **kwds), typelist) return decorated return decorate
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: dates = feed.restrict_dates(dates) if not dates: return pd.DataFrame() t = pd.merge(feed.trips, feed.stop_times) t = t[t["route_id"] == route_id].copy() a = feed.compute_trip_activity(dates) fram...
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: if f.empty or g.empty: return f.equals(g) else: F = ( f.sort_index(axis=1) .sort_values(list(f.columns)) .reset_index(drop=True) ) G = ( g.sort_index(axis=1) .sort_va...
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: dates = feed.restrict_dates(dates) if not dates: return pd.DataFrame() t = pd.merge(feed.trips, feed.stop_times) t = t[t["stop_id"] == stop_id].copy() a = feed.compute_trip_activity(dates) frames =...
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 prope...
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 unit...
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, 35; 6, 49; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:fit; 10, generator_expression; 10, 11; 10, 24; 11, tuple; ...
def _find_best_fit(self, pbin): fit = ((pbin.fitness(r[0], r[1]), k) for k, r in self._sorted_rect.items()) fit = (f for f in fit if f[0] is not None) try: _, rect = min(fit, key=self.first_item) return rect except ValueError: return None
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 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, block; 7, 8; 7, 45; 8, for_statement; 8, 9; 8, 12; 8, 17; 9, pattern_list; 9, 10; 9, 11; 10, id...
def _item_attributes_match(crypto_config, plaintext_item, encrypted_item): for name, value in plaintext_item.items(): if crypto_config.attribute_actions.action(name) == CryptoAction.ENCRYPT_AND_SIGN: continue if encrypted_item.get(name) != value: return False return True
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, 12; 5, 16; 5, 25; 5, 36; 5, 45; 5, 181; 5, 187; 5, 231; 5, 253; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:icons; 9, call; 9, 10; 9, 11; 10, iden...
def load_css(self): icons = dict() common_prefix = None parser = tinycss.make_parser('page3') stylesheet = parser.parse_stylesheet_file(self.css_file) is_icon = re.compile("\.(.*):before,?") for rule in stylesheet.rules: selector = rule.selector.as_css() ...
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, 10; 5, 252; 5, 325; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:list_of_rules; 9, list:[]; 10, for_statement; 10, 11; 10, 12; 10, 15; 11, identifier:...
def rules(self): 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_row: for grant_row in rule_row['grants']: if 'group_id' ...
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, 13; 6, 39; 6, 84; 6, 109; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:nets; 10, subscript; 10, 11; 10, 12;...
def _select_mgmt_networks(self, conf): nets = conf['nets'] mgmts = sorted( [ name for name, net in nets.iteritems() if net.get('management') is True ] ) if len(mgmts) == 0: mgmt_name = sorted((nets.keys()))[0] ...
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, 12; 5, 45; 5, 54; 5, 107; 5, 122; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:wave; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11,...
def validate_wavetable(self): wave = self._wavetable if N.any(wave <= 0): wrong = N.where(wave <= 0)[0] raise exceptions.ZeroWavelength( 'Negative or Zero wavelength occurs in wavelength array', rows=wrong) sorted = N.sort(wave) if ...
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, 16; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:statecodes; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, ...
def getStateIndex(self,state): statecodes = self.getStateCode(state) return np.searchsorted(self.codes,statecodes).astype(int)
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, 20; 7, 55; 7, 71; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:paths; 11, call; 11, ...
def guess_chimera_path(search_all=False): paths = _search_chimera(CHIMERA_BINARY, CHIMERA_LOCATIONS, CHIMERA_PREFIX, search_all=search_all) if not paths and search_all: headless = '{0[0]}{1}{0[1]}'.format(os.path.split(CHIMERA_BINARY), '-headless') paths = _search_chi...
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, 13; 8, 19; 8, 23; 8, 64; 8, 97; 8, 154; 8, 179; 9, expression_statement; 9, 10; 10, assignment; 10, ...
def _topo_sort(self, forward=True): topo_list = [] queue = deque() indeg = {} if forward: get_edges = self.out_edges get_degree = self.inc_degree get_next = self.tail else: get_edges = self.inc_edges get_degree = self.ou...
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, 13; 6, 20; 6, 58; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:unmapped_combinations; 10, c...
def find_missing_projections(label_list, projections): unmapped_combinations = set() if WILDCARD_COMBINATION in projections: return [] for labeled_segment in label_list.ranges(): combination = tuple(sorted([label.value for label in labeled_segment[2]])) if combination not in projecti...
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, 10; 5, 61; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:projections; 9, dictionary; 10, for_statement; 10, 11; 10, 12; 10, 19; ...
def load_projections(projections_file): projections = {} for parts in textfile.read_separated_lines_generator(projections_file, '|'): combination = tuple(sorted([label.strip() for label in parts[0].split(' ')])) new_label = parts[1].strip() projections[combination] = new_label return...
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, 19; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:all_labels; 9, call; 9, 10; 9, 11; 10, identifier:set; 11, argument_list; 11, 12; 12, list_com...
def label_values(self): all_labels = set([l.value for l in self]) return sorted(all_labels)
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, 10; 5, 14; 5, 129; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:regions; 9, list:[]; 10, expression_statement; 10, 11; 11, assignment; 11, 1...
def get_utt_regions(self): regions = [] current_offset = 0 for utt_idx in sorted(self.utt_ids): offset = current_offset num_frames = [] refs = [] for cnt in self.containers: num_frames.append(cnt.get(utt_idx).shape[0]) ...
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): f = open(path, 'w', encoding='utf-8') if type(values) is dict: if sort_by_column in [0, 1]: items = sorted(values.items(), key=lambda t: t[sort_by_column]) else: items = values.items() for k...
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, 19; 5, 26; 5, 43; 6, if_statement; 6, 7; 6, 13; 7, not_operator; 7, 8; 8, call; 8, 9; 8, 10; 9, identifier:isinstance; 10, argument_list; 10, 11; 10, 12; 11, identifier:s; 12, i...
def sort_set(s): if not isinstance(s, Set): raise TypeError("sets only") s = frozenset(s) if s not in _sort_set_memo: _sort_set_memo[s] = sorted(s, key=_sort_set_key) return _sort_set_memo[s]
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, 12; 5, 19; 5, 23; 5, 27; 5, 31; 5, 38; 5, 163; 5, 185; 5, 195; 5, 201; 6, if_statement; 6, 7; 6, 9; 7, not_operator; 7, 8; 8, identifier:tagstring; 9, block; 9, 10; 10...
def parse_tags(tagstring): if not tagstring: return [] tagstring = force_text(tagstring) words = [] buffer = [] to_be_split = [] i = iter(tagstring) try: while True: c = six.next(i) if c == '"': if buffer: to_be_spli...
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, 26; 7, 51; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:unique...
def _sort_by_unique_fields(model, model_objs, unique_fields): unique_fields = [ field for field in model._meta.fields if field.attname in unique_fields ] def sort_key(model_obj): return tuple( field.get_db_prep_save(getattr(model_obj, field.attname), ...
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, 22; 6, 78; 7, if_statement; 7, 8; 7, 19; 8, boolean_operator:and; 8, 9; 8, 16; 9, call; 9, 10; 9, 11; 10, identifier:isinstance; 11, argument_list; 11,...
def find(self, datum): 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) if self.expressions else None) return [jsonpath_...
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, 11; 6, 15; 6, 19; 6, 68; 6, 77; 6, 86; 6, 95; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier...
def get_subset_riverid_index_list(self, river_id_list): netcdf_river_indices_list = [] valid_river_ids = [] missing_river_ids = [] for river_id in river_id_list: try: netcdf_river_indices_list \ .append(self.get_river_index(river_id)) ...
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, 23; 7, 33; 7, 37; 7, 41; 7, 118; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identi...
def get_child_type_choices(self, request, action): choices = super(ChildModelPluginPolymorphicParentModelAdmin, self) \ .get_child_type_choices(request, action) plugins = self.child_model_plugin_class.get_plugins() labels = {} sort_priorities = {} if plugins: ...