sequence
stringlengths
492
15.9k
code
stringlengths
75
8.58k
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:get_dummy_dynamic_run; 3, parameters; 3, 4; 3, 5; 4, identifier:nsamples; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 18; 7, 28; 7, 38; 7, 48; 7, 58; 7, 71; 7, 94; 7, 114; 7, 125; 7, 148; 7, 171; 7, 182; 7, 193; ...
def get_dummy_dynamic_run(nsamples, **kwargs): seed = kwargs.pop('seed', False) ndim = kwargs.pop('ndim', 2) nthread_init = kwargs.pop('nthread_init', 2) nthread_dyn = kwargs.pop('nthread_dyn', 3) logl_range = kwargs.pop('logl_range', 1) if kwargs: raise TypeError('Unexpected **kwargs: {...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_dates_for_project; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:project; 6, block; 6, 7; 6, 18; 6, 22; 6, 88; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:file_re; 10, call; 10, 11; 10, 14; 11, at...
def get_dates_for_project(self, project): file_re = re.compile(r'^%s_([0-9]{8})\.json$' % project) all_dates = [] for f in os.listdir(self.cache_path): if not os.path.isfile(os.path.join(self.cache_path, f)): continue m = file_re.match(f) if m ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:insort_event_right; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:event; 6, default_parameter; 6, 7; 6, 8; 7, identifier:lo; 8, integer:0; 9, default_parameter; 9, 10; 9, 11; 10, identifier:hi; 11, None; 12, block; 1...
def insort_event_right(self, event, lo=0, hi=None): if lo < 0: raise ValueError('lo must be non-negative') if hi is None: hi = len(self.queue) while lo < hi: mid = (lo + hi) // 2 if event[0] < self.queue[mid][0]: hi = mid else: lo = mid + 1 self.queue.insert...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:getMd5Checksum; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 27; 5, 44; 5, 57; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:references; 9, call; 9, 10; 9, 11; 10, identifier:sorted; 11, argument_list; 1...
def getMd5Checksum(self): references = sorted( self.getReferences(), key=lambda ref: ref.getMd5Checksum()) checksums = ''.join([ref.getMd5Checksum() for ref in references]) md5checksum = hashlib.md5(checksums).hexdigest() return md5checksum
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:knn_impute_few_observed; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:X; 5, identifier:missing_mask; 6, identifier:k; 7, default_parameter; 7, 8; 7, 9; 8, identifier:verbose; 9, False; 10, default_parameter; 10, 11; 10, 12; 11, ...
def knn_impute_few_observed( X, missing_mask, k, verbose=False, print_interval=100): start_t = time.time() n_rows, n_cols = X.shape missing_mask_column_major = np.asarray(missing_mask, order="F") observed_mask_column_major = ~missing_mask_column_major X_column_major = X.copy(order="F") X...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_sort_converters; 3, parameters; 3, 4; 3, 5; 4, identifier:cls; 5, default_parameter; 5, 6; 5, 7; 6, identifier:app_ready; 7, False; 8, block; 8, 9; 8, 11; 8, 21; 9, expression_statement; 9, 10; 10, string:'''Sorts the converter functions'''; 1...
def _sort_converters(cls, app_ready=False): '''Sorts the converter functions''' cls._sorting_enabled = cls._sorting_enabled or app_ready if cls._sorting_enabled: for converter in cls.converters: converter.prepare_sort_key() cls.converters.sort(key=attrgett...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:prepare_sort_key; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 80; 6, expression_statement; 6, 7; 7, string:''' Triggered by view_function._sort_converters when our sort key should be created. This can't be ...
def prepare_sort_key(self): ''' Triggered by view_function._sort_converters when our sort key should be created. This can't be called in the constructor because Django models might not be ready yet. ''' if isinstance(self.convert_type, str): try: app_n...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:sort_key_for_numeric_suffixes; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:path; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sep; 7, string:'.'; 8, default_parameter; 8, 9; 8, 10; 9, identifier:suffix_index; 10, unary_operator:-; 10, 11...
def sort_key_for_numeric_suffixes(path, sep='.', suffix_index=-2): chunks = path.split(sep) if chunks[suffix_index].isdigit(): return sep.join(chunks[:suffix_index] + chunks[suffix_index+1:]), int(chunks[suffix_index]) return path, 0
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_get_query; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:cursor; 6, block; 6, 7; 6, 9; 6, 27; 6, 45; 6, 56; 7, expression_statement; 7, 8; 8, string:''' Query tempalte for source Solr, sorts by id by default. '...
def _get_query(self, cursor): ''' Query tempalte for source Solr, sorts by id by default. ''' query = {'q':'*:*', 'sort':'id desc', 'rows':self._rows, 'cursorMark':cursor} if self._date_field: query['sort'] = "{...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:url_params; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:request; 5, default_parameter; 5, 6; 5, 7; 6, identifier:except_params; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:as_is; 10, False; 11, block; 11, 12; 11, 20; 11, 24; 1...
def url_params(request, except_params=None, as_is=False): if not request.GET: return '' params = [] for key, value in request.GET.items(): if except_params and key not in except_params: for v in request.GET.getlist(key): params.append('%s=%s' % (key, urlquote(v)))...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:compose; 3, parameters; 3, 4; 4, list_splat_pattern; 4, 5; 5, identifier:funcs; 6, block; 6, 7; 7, if_statement; 7, 8; 7, 14; 7, 38; 7, 73; 7, 86; 7, 98; 8, comparison_operator:==; 8, 9; 8, 13; 9, call; 9, 10; 9, 11; 10, identifier:len; 11, arg...
def compose(*funcs): if len(funcs) == 2: f0,f1=funcs; return lambda *a,**kw: f0(f1(*a,**kw)) elif len(funcs) == 3: f0,f1,f2=funcs; return lambda *a,**kw: f0(f1(f2(*a,**kw))) elif len(funcs) == 0: return lambda x:x elif len(funcs) == 1: return funcs[0] else: def composed(*args,**kwargs): ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_sort_lines; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:_valid_lines; 11, call; 11, 12; 11, 13; 12, identifie...
def _sort_lines(self): self._valid_lines = sorted( self._valid_lines, key=lambda line: line.accept_date, )
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_sort_and_trim; 3, parameters; 3, 4; 3, 5; 4, identifier:data; 5, default_parameter; 5, 6; 5, 7; 6, identifier:reverse; 7, False; 8, block; 8, 9; 8, 13; 8, 21; 8, 39; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifie...
def _sort_and_trim(data, reverse=False): threshold = 10 data_list = data.items() data_list = sorted( data_list, key=lambda data_info: data_info[1], reverse=reverse, ) return data_list[:threshold]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_queryset; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 20; 5, 29; 5, 38; 6, expression_statement; 6, 7; 7, string:'''Apply Datatables sort and search criterion to QuerySet'''; 8, expression_statement; 8, 9; 9, assignmen...
def get_queryset(self): '''Apply Datatables sort and search criterion to QuerySet''' qs = super(DatatablesView, self).get_queryset() qs = self.global_search(qs) qs = self.column_search(qs) return qs.order_by(*self.get_orders())
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:rangify; 3, parameters; 3, 4; 4, identifier:number_list; 5, block; 5, 6; 5, 12; 5, 16; 5, 24; 5, 57; 5, 66; 6, if_statement; 6, 7; 6, 9; 7, not_operator; 7, 8; 8, identifier:number_list; 9, block; 9, 10; 10, return_statement; 10, 11; 11, identi...
def rangify(number_list): if not number_list: return number_list ranges = [] range_start = prev_num = number_list[0] for num in number_list[1:]: if num != (prev_num + 1): ranges.append((range_start, prev_num)) range_start = num prev_num = num ranges.ap...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:get_solver; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:name; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:refresh; 10, False; 11, dictionary_splat_pattern; 11, 12; 1...
def get_solver(self, name=None, refresh=False, **filters): _LOGGER.debug("Requested a solver that best matches feature filters=%r", filters) if name is not None: filters.setdefault('name', name) if not filters and self.default_solver: filters = self.default_solver ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:find_germanet_xml_files; 3, parameters; 3, 4; 4, identifier:xml_path; 5, block; 5, 6; 5, 8; 5, 28; 5, 55; 5, 70; 5, 79; 5, 102; 5, 117; 5, 153; 5, 180; 5, 195; 5, 204; 5, 230; 5, 245; 5, 254; 5, 263; 6, expression_statement; 6, 7; 7, string:'''...
def find_germanet_xml_files(xml_path): ''' Globs the XML files contained in the given directory and sorts them into sections for import into the MongoDB database. Arguments: - `xml_path`: the path to the directory containing the GermaNet XML files ''' xml_files = sorted(glob.glob(os.pa...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 31; 2, function_name:iter_org_issues; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 3, 28; 4, identifier:self; 5, identifier:name; 6, default_parameter; 6, 7; 6, 8; 7, identifier:filter; 8, string:''; 9, default_parameter; 9, 10; 9, 11;...
def iter_org_issues(self, name, filter='', state='', labels='', sort='', direction='', since=None, number=-1, etag=None): url = self._build_url('orgs', name, 'issues') params = issue_params(filter, state, labels, sort, direction, since) return self._iter(int(number), url,...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:iter_repos; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 18; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:type; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sort; 10, None; 11, default_parameter; 11, 12...
def iter_repos(self, type=None, sort=None, direction=None, number=-1, etag=None): url = self._build_url('user', 'repos') params = {} if type in ('all', 'owner', 'public', 'private', 'member'): params.update(type=type) if sort in ('created', 'updated', 'push...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:iter_starred; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 18; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:login; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sort; 10, None; 11, default_parameter; 11,...
def iter_starred(self, login=None, sort=None, direction=None, number=-1, etag=None): if login: return self.user(login).iter_starred(sort, direction) params = {'sort': sort, 'direction': direction} self._remove_none(params) url = self._build_url('user', 's...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 25; 2, function_name:search_code; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 22; 4, identifier:self; 5, identifier:query; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sort; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:order; 1...
def search_code(self, query, sort=None, order=None, per_page=None, text_match=False, number=-1, etag=None): params = {'q': query} headers = {} if sort == 'indexed': params['sort'] = sort if sort and order in ('asc', 'desc'): params['order'] = o...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 25; 2, function_name:search_issues; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 22; 4, identifier:self; 5, identifier:query; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sort; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:order;...
def search_issues(self, query, sort=None, order=None, per_page=None, text_match=False, number=-1, etag=None): params = {'q': query} headers = {} if sort in ('comments', 'created', 'updated'): params['sort'] = sort if order in ('asc', 'desc'): ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 25; 2, function_name:search_users; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 22; 4, identifier:self; 5, identifier:query; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sort; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:order; ...
def search_users(self, query, sort=None, order=None, per_page=None, text_match=False, number=-1, etag=None): params = {'q': query} headers = {} if sort in ('followers', 'repositories', 'joined'): params['sort'] = sort if order in ('asc', 'desc'): ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:iter_starred; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 15; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:direction; 10, None; 11, default_parameter; 11, 12...
def iter_starred(self, sort=None, direction=None, number=-1, etag=None): from .repos import Repository params = {'sort': sort, 'direction': direction} self._remove_none(params) url = self.starred_urlt.expand(owner=None, repo=None) return self._iter(int(number), url, Repository, p...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:iter_forks; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 12; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort; 7, string:''; 8, default_parameter; 8, 9; 8, 10; 9, identifier:number; 10, unary_operator:-; 10, 11; 11, integer:1; 1...
def iter_forks(self, sort='', number=-1, etag=None): url = self._build_url('forks', base_url=self._api) params = {} if sort in ('newest', 'oldest', 'watchers'): params = {'sort': sort} return self._iter(int(number), url, Repository, params, etag)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 36; 2, function_name:iter_issues; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 33; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:milestone; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:stat...
def iter_issues(self, milestone=None, state=None, assignee=None, mentioned=None, labels=None, sort=None, direction=None, since=None, number=...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:iter_milestones; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 18; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:state; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sort; 10, None; 11, default_parameter; ...
def iter_milestones(self, state=None, sort=None, direction=None, number=-1, etag=None): url = self._build_url('milestones', base_url=self._api) accepted = {'state': ('open', 'closed'), 'sort': ('due_date', 'completeness'), 'direction': ('as...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 27; 2, function_name:iter_pulls; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 24; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:state; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:head; 10, None; 11, default_pa...
def iter_pulls(self, state=None, head=None, base=None, sort='created', direction='desc', number=-1, etag=None): url = self._build_url('pulls', base_url=self._api) params = {} if state and state.lower() in ('all', 'open', 'closed'): params['state'] = state.lower() ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:iter_user_repos; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 18; 4, identifier:login; 5, default_parameter; 5, 6; 5, 7; 6, identifier:type; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sort; 10, None; 11, default_parameter; ...
def iter_user_repos(login, type=None, sort=None, direction=None, number=-1, etag=None): if login: return gh.iter_user_repos(login, type, sort, direction, number, etag) return iter([])
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sort_descendants; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:attr; 7, string:"name"; 8, block; 8, 9; 8, 23; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:node2...
def sort_descendants(self, attr="name"): node2content = self.get_cached_content(store_attr=attr, container_type=list) for n in self.traverse(): if not n.is_leaf(): n.children.sort(key=lambda x: str(sorted(node2content[x])))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:collect_backups; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:location; 6, block; 6, 7; 6, 11; 6, 18; 6, 26; 6, 32; 6, 192; 6, 207; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:backups; 10, list:[]; 1...
def collect_backups(self, location): backups = [] location = coerce_location(location) logger.info("Scanning %s for backups ..", location) location.ensure_readable() for entry in natsort(location.context.list_entries(location.directory)): match = TIMESTAMP_PATTERN.sea...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:prepare_bam; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 4, identifier:job; 5, identifier:uuid; 6, identifier:url; 7, identifier:config; 8, default_parameter; 8, 9; 8, 10; 9, identifier:paired_url; 10, None; 11, default_parameter; 11, ...
def prepare_bam(job, uuid, url, config, paired_url=None, rg_line=None): if config.run_bwa: get_bam = job.wrapJobFn(setup_and_run_bwakit, uuid, url, rg_line, config, ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:alignment; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:job; 5, identifier:ids; 6, identifier:input_args; 7, identifier:sample; 8, block; 8, 9; 8, 15; 8, 25; 8, 31; 8, 37; 8, 45; 8, 59; 8, 78; 8, 92; 8, 137; 8, 168; 8, 202; 8, 236; 8, 2...
def alignment(job, ids, input_args, sample): uuid, urls = sample work_dir = job.fileStore.getLocalTempDir() output_dir = input_args['output_dir'] key_path = input_args['ssec'] cores = multiprocessing.cpu_count() return_input_paths(job, work_dir, ids, 'ref.fa', 'ref.fa.amb', 'ref.fa.ann', ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:bamsort_and_index; 3, parameters; 3, 4; 3, 5; 4, identifier:job; 5, identifier:job_vars; 6, block; 6, 7; 6, 13; 6, 23; 6, 29; 6, 39; 6, 51; 6, 64; 6, 73; 6, 89; 6, 105; 6, 118; 6, 139; 6, 156; 6, 173; 7, expression_statement; 7, 8; 8, assignmen...
def bamsort_and_index(job, job_vars): input_args, ids = job_vars work_dir = job.fileStore.getLocalTempDir() sudo = input_args['sudo'] rg_alignments = return_input_paths(job, work_dir, ids, 'rg_alignments.bam') output = os.path.join(work_dir, 'sorted.bam') cmd1 = ['sort', docker_path(rg_alignment...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_bam_by_reference; 3, parameters; 3, 4; 3, 5; 4, identifier:job; 5, identifier:job_vars; 6, block; 6, 7; 6, 13; 6, 23; 6, 36; 6, 48; 6, 52; 6, 72; 6, 113; 6, 119; 6, 177; 6, 195; 6, 205; 6, 212; 6, 225; 6, 245; 6, 262; 7, expression_stateme...
def sort_bam_by_reference(job, job_vars): input_args, ids = job_vars work_dir = job.fileStore.getLocalTempDir() sorted_bam, sorted_bai = return_input_paths(job, work_dir, ids, 'sorted.bam', 'sorted.bam.bai') output = os.path.join(work_dir, 'sort_by_ref.bam') ref_seqs = [] handle = subprocess.Pop...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:main; 3, parameters; 4, block; 4, 5; 4, 11; 4, 20; 4, 28; 4, 121; 5, expression_statement; 5, 6; 6, assignment; 6, 7; 6, 8; 7, identifier:parser; 8, call; 8, 9; 8, 10; 9, identifier:build_parser; 10, argument_list; 11, expression_statement; 11,...
def main(): parser = build_parser() Job.Runner.addToilOptions(parser) args = parser.parse_args() inputs = {'config': args.config, 'config_fastq': args.config_fastq, 'input': args.input, 'unc.bed': args.unc, 'hg19.transcripts.fa': args.fasta, ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:fourier_series; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:pars; 6, identifier:x; 7, identifier:order; 8, block; 8, 9; 8, 15; 8, 77; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:su...
def fourier_series(self, pars, x, order): sum = pars[0] for i in range(order): sum += pars[i * 2 + 1] * np.sin(2 * np.pi * (i + 1) * x) \ + pars[i * 2 + 2] * np.cos(2 * np.pi * (i + 1) * x) return sum
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:slope_percentile; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:date; 6, identifier:mag; 7, block; 7, 8; 7, 27; 7, 46; 7, 57; 7, 63; 7, 69; 7, 75; 7, 85; 7, 95; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10...
def slope_percentile(self, date, mag): date_diff = date[1:] - date[:len(date) - 1] mag_diff = mag[1:] - mag[:len(mag) - 1] index = np.where(mag_diff != 0.) date_diff = date_diff[index] mag_diff = mag_diff[index] slope = date_diff / mag_diff percentile_10 = np.perc...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:number_aware_alphabetical_cmp; 3, parameters; 3, 4; 3, 5; 4, identifier:str1; 5, identifier:str2; 6, block; 6, 7; 6, 55; 6, 65; 6, 75; 6, 89; 6, 93; 6, 125; 6, 152; 7, function_definition; 7, 8; 7, 9; 7, 11; 8, function_name:flatten_tokens; 9, ...
def number_aware_alphabetical_cmp(str1, str2): def flatten_tokens(tokens): l = [] for token in tokens: if isinstance(token, str): for char in token: l.append(char) else: assert isinstance(token, float) l.appe...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_members; 3, parameters; 3, 4; 3, 5; 4, identifier:tup; 5, identifier:names; 6, block; 6, 7; 6, 30; 6, 53; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 12; 9, pattern_list; 9, 10; 9, 11; 10, identifier:scalars; 11, identifier:tupl...
def sort_members(tup, names): scalars, tuples = partition(lambda x: not is_tuple_node(tup.member[x].value), names) unbound, bound = partition(lambda x: tup.member[x].value.is_unbound(), scalars) return usorted(unbound) + usorted(bound), usorted(tuples)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_schemas; 3, parameters; 3, 4; 4, identifier:schemas; 5, block; 5, 6; 5, 60; 6, function_definition; 6, 7; 6, 8; 6, 10; 7, function_name:keyfun; 8, parameters; 8, 9; 9, identifier:v; 10, block; 10, 11; 10, 24; 11, expression_statement; 11, ...
def sort_schemas(schemas): def keyfun(v): x = SQL_SCHEMA_REGEXP.match(v).groups() return (int(x[0]), x[1], int(x[2]) if x[2] else None, x[3] if x[3] else 'zzz', int(x[4])) return sorted(schemas, key=keyfun)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_nodes; 3, parameters; 3, 4; 3, 5; 4, identifier:dom; 5, identifier:cmp_func; 6, block; 6, 7; 6, 13; 7, expression_statement; 7, 8; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:dom; 11, identifier:normalize; 12, argument...
def sort_nodes(dom, cmp_func): dom.normalize() for node in list(walk_dom(dom, elements_only=True)): prev_sib = node.previousSibling while prev_sib and cmp_func(prev_sib, node) == 1: node.parentNode.insertBefore(node, prev_sib) prev_sib = node.previousSibling
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 7; 2, function_name:currentdir; 3, parameters; 3, 4; 4, identifier:self; 5, type; 5, 6; 6, identifier:str; 7, block; 7, 8; 7, 99; 8, if_statement; 8, 9; 8, 14; 9, comparison_operator:is; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, i...
def currentdir(self) -> str: if self._currentdir is None: directories = self.availabledirs.folders if len(directories) == 1: self.currentdir = directories[0] elif self.DEFAULTDIR in directories: self.currentdir = self.DEFAULTDIR els...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 7; 2, function_name:zip_currentdir; 3, parameters; 3, 4; 4, identifier:self; 5, type; 5, 6; 6, None; 7, block; 7, 8; 7, 48; 8, with_statement; 8, 9; 8, 21; 9, with_clause; 9, 10; 10, with_item; 10, 11; 11, as_pattern; 11, 12; 11, 19; 12, call; 12, 13; 12, 16...
def zip_currentdir(self) -> None: with zipfile.ZipFile(f'{self.currentpath}.zip', 'w') as zipfile_: for filepath, filename in zip(self.filepaths, self.filenames): zipfile_.write(filename=filepath, arcname=filename) del self.currentdir
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 11; 2, function_name:keywords; 3, parameters; 3, 4; 4, identifier:self; 5, type; 5, 6; 6, generic_type; 6, 7; 6, 8; 7, identifier:Set; 8, type_parameter; 8, 9; 9, type; 9, 10; 10, identifier:str; 11, block; 11, 12; 12, return_statement; 12, 13; 13, call; 13,...
def keywords(self) -> Set[str]: return set(keyword for device in self for keyword in device.keywords if keyword not in self._shadowed_keywords)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 11; 2, function_name:variables; 3, parameters; 3, 4; 4, identifier:self; 5, type; 5, 6; 6, generic_type; 6, 7; 6, 8; 7, identifier:Set; 8, type_parameter; 8, 9; 9, type; 9, 10; 10, identifier:str; 11, block; 11, 12; 11, 24; 11, 39; 12, expression_statement; ...
def variables(self) -> Set[str]: variables: Set[str] = set() for connection in self.__connections: variables.update(connection.variables) return variables
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 23; 2, function_name:model2subs2seqs; 3, parameters; 3, 4; 4, identifier:self; 5, type; 5, 6; 6, generic_type; 6, 7; 6, 8; 7, identifier:Dict; 8, type_parameter; 8, 9; 8, 11; 9, type; 9, 10; 10, identifier:str; 11, type; 11, 12; 12, generic_type; 12, 13; 12,...
def model2subs2seqs(self) -> Dict[str, Dict[str, List[str]]]: model2subs2seqs = collections.defaultdict( lambda: collections.defaultdict(list)) for model in self.find('sequences'): model_name = strip(model.tag) if model_name == 'node': continue ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 17; 2, function_name:subs2seqs; 3, parameters; 3, 4; 4, identifier:self; 5, type; 5, 6; 6, generic_type; 6, 7; 6, 8; 7, identifier:Dict; 8, type_parameter; 8, 9; 8, 11; 9, type; 9, 10; 10, identifier:str; 11, type; 11, 12; 12, generic_type; 12, 13; 12, 14; 1...
def subs2seqs(self) -> Dict[str, List[str]]: subs2seqs = collections.defaultdict(list) nodes = find(self.find('sequences'), 'node') if nodes is not None: for seq in nodes: subs2seqs['node'].append(strip(seq.tag)) return subs2seqs
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 1, 10; 2, function_name:get_modelnames; 3, parameters; 4, type; 4, 5; 5, generic_type; 5, 6; 5, 7; 6, identifier:List; 7, type_parameter; 7, 8; 8, type; 8, 9; 9, identifier:str; 10, block; 10, 11; 11, return_statement; 11, 12; 12, call; 12, 13; 12, 14; 13, iden...
def get_modelnames() -> List[str]: return sorted(str(fn.split('.')[0]) for fn in os.listdir(models.__path__[0]) if (fn.endswith('.py') and (fn != '__init__.py')))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 15; 2, function_name:toys; 3, parameters; 3, 4; 4, identifier:self; 5, type; 5, 6; 6, generic_type; 6, 7; 6, 8; 7, identifier:Tuple; 8, type_parameter; 8, 9; 8, 13; 9, type; 9, 10; 10, attribute; 10, 11; 10, 12; 11, identifier:timetools; 12, identifier:TOY; ...
def toys(self) -> Tuple[timetools.TOY, ...]: return tuple(toy for (toy, _) in self)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 1, 8; 2, function_name:collect_variables; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:selections; 6, type; 6, 7; 7, None; 8, block; 8, 9; 9, expression_statement; 9, 10; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:se...
def collect_variables(self, selections) -> None: self.insert_variables(self.device2target, self.targetspecs, selections)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 1, 8; 2, function_name:collect_variables; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:selections; 6, type; 6, 7; 7, None; 8, block; 8, 9; 8, 18; 9, expression_statement; 9, 10; 10, call; 10, 11; 10, 16; 11, attribute; 11, 12; 11, 15; 12, call; ...
def collect_variables(self, selections) -> None: super().collect_variables(selections) self.insert_variables(self.device2base, self.basespecs, selections)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:save_controls; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:parameterstep; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:simulationstep; 10, None; 11, default_parameter...
def save_controls(self, parameterstep=None, simulationstep=None, auxfiler=None): self.elements.save_controls(parameterstep=parameterstep, simulationstep=simulationstep, auxfiler=auxfiler)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:variables; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 13; 5, 28; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:variables; 9, call; 9, 10; 9, 11; 10, identifier:set; 11, argument_list; 11, 12; 12, list:...
def variables(self): variables = set([]) for node in self.nodes: variables.add(node.variable) return sorted(variables)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 1, 15; 2, function_name:sort_timeplaceentries; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:timeentry; 6, identifier:placeentry; 7, type; 7, 8; 8, generic_type; 8, 9; 8, 10; 9, identifier:Tuple; 10, type_parameter; 10, 11; 10, 13; 11, type...
def sort_timeplaceentries(self, timeentry, placeentry) -> Tuple[Any, Any]: if self._timeaxis: return placeentry, timeentry return timeentry, placeentry
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 1, 16; 2, function_name:prepare_io_example_1; 3, parameters; 4, type; 4, 5; 5, generic_type; 5, 6; 5, 7; 6, identifier:Tuple; 7, type_parameter; 7, 8; 7, 12; 8, type; 8, 9; 9, attribute; 9, 10; 9, 11; 10, identifier:devicetools; 11, identifier:Nodes; 12, type; ...
def prepare_io_example_1() -> Tuple[devicetools.Nodes, devicetools.Elements]: from hydpy import TestIO TestIO.clear() from hydpy.core.filetools import SequenceManager hydpy.pub.sequencemanager = SequenceManager() with TestIO(): hydpy.pub.sequencemanager.inputdirpath = 'inputpath' hyd...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 29; 2, function_name:comparison_table; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:caption; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:label; 10, stri...
def comparison_table(self, caption=None, label="tab:model_comp", hlines=True, aic=True, bic=True, dic=True, sort="bic", descending=True): if sort == "bic": assert bic, "You cannot sort by BIC if you turn it off" if sort == "aic": assert aic, "You cannot s...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_initDevClasses; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 12; 5, 18; 5, 24; 5, 28; 5, 32; 5, 45; 5, 153; 5, 165; 5, 177; 5, 181; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identif...
def _initDevClasses(self): self._devClassTree = {} self._partitionTree = {} self._mapDevType = {} basedevs = [] otherdevs = [] if self._mapMajorDevclass is None: self._initBlockMajorMap() for dev in self._diskStats: stats = self._diskStats[...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:zdiffstore; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:dest; 6, identifier:keys; 7, default_parameter; 7, 8; 7, 9; 8, identifier:withscores; 9, False; 10, block; 10, 11; 10, 13; 10, 23; 10, 30; 11, expression_stat...
def zdiffstore(self, dest, keys, withscores=False): '''Compute the difference of multiple sorted. The difference of sets specified by ``keys`` into a new sorted set in ``dest``. ''' keys = (dest,) + tuple(keys) wscores = 'withscores' if withscores else '' r...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:places_within_radius; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:place; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:latitude; 10, None; 11, default_pa...
def places_within_radius( self, place=None, latitude=None, longitude=None, radius=0, **kwargs ): kwargs['withdist'] = True kwargs['withcoord'] = True kwargs['withhash'] = False kwargs.setdefault('sort', 'ASC') unit = kwargs.setdefault('unit', 'km') if place is...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:naturalize_person; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:string; 6, block; 6, 7; 6, 20; 6, 34; 6, 44; 6, 48; 6, 52; 6, 56; 6, 60; 6, 69; 6, 103; 6, 165; 6, 178; 6, 187; 7, expression_statement; 7, 8; 8, assignment; 8, 9; ...
def naturalize_person(self, string): suffixes = [ 'Jr', 'Jr.', 'Sr', 'Sr.', 'I', 'II', 'III', 'IV', 'V', ] suffixes = suffixes + [s.lower() for s in suffixes] particles = [ 'Le', 'La', 'Von', 'Van...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_countries; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 36; 5, 40; 5, 66; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:qs; 9, call; 9, 10; 9, 34; 10, attribute; 10, 11; 10, 32; 10, 33; 11, call; 11,...
def get_countries(self): qs = Venue.objects.values('country') \ .exclude(country='') \ .distinct() \ .order_by('country') countries = [] for c in qs: countries.append({ ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:fit; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:self; 5, identifier:t; 6, identifier:y; 7, default_parameter; 7, 8; 7, 9; 8, identifier:dy; 9, integer:1; 10, default_parameter; 10, 11; 10, 12; 11, identifier:presorted; 12, Fal...
def fit(self, t, y, dy=1, presorted=False): self.t, self.y, self.dy = self._validate_inputs(t, y, dy, presorted) self._fit(self.t, self.y, self.dy) return self
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:validate_inputs; 3, parameters; 3, 4; 3, 6; 4, list_splat_pattern; 4, 5; 5, identifier:arrays; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 19; 8, 29; 8, 46; 8, 60; 8, 103; 9, expression_statement; 9, 10; 10, assi...
def validate_inputs(*arrays, **kwargs): arrays = np.broadcast_arrays(*arrays) sort_by = kwargs.pop('sort_by', None) if kwargs: raise ValueError("unrecognized arguments: {0}".format(kwargs.keys())) if arrays[0].ndim != 1: raise ValueError("Input arrays should be one-dimensional.") if ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:multinterp; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:x; 5, identifier:y; 6, identifier:xquery; 7, default_parameter; 7, 8; 7, 9; 8, identifier:slow; 9, False; 10, block; 10, 11; 10, 27; 10, 33; 10, 39; 10, 51; 10, 70; 11, expressio...
def multinterp(x, y, xquery, slow=False): x, y, xquery = map(np.asarray, (x, y, xquery)) assert x.ndim == 1 assert xquery.ndim == 1 assert y.shape == x.shape + xquery.shape xquery = np.clip(xquery, x.min(), x.max()) if slow: from scipy.interpolate import interp1d return np.array(...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:check_valid_time_and_sort; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:df; 5, identifier:timescol; 6, default_parameter; 6, 7; 6, 8; 7, identifier:days; 8, integer:5; 9, default_parameter; 9, 10; 9, 11; 10, identifier:warning; 11, Tru...
def check_valid_time_and_sort(df, timescol, days=5, warning=True): timediff = (df[timescol].max() - df[timescol].min()).days if timediff < days: return df.sort_values(timescol).reset_index(drop=True).reset_index() else: if warning: sys.stderr.write( "\nWarning: da...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:list_anime_series; 3, parameters; 3, 4; 3, 5; 3, 10; 3, 15; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort; 7, attribute; 7, 8; 7, 9; 8, identifier:META; 9, identifier:SORT_ALPHA; 10, default_parameter; 10, 11; 10, 12...
def list_anime_series(self, sort=META.SORT_ALPHA, limit=META.MAX_SERIES, offset=0): result = self._android_api.list_series( media_type=ANDROID.MEDIA_TYPE_ANIME, filter=sort, limit=limit, offset=offset) return result
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:list_drama_series; 3, parameters; 3, 4; 3, 5; 3, 10; 3, 15; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort; 7, attribute; 7, 8; 7, 9; 8, identifier:META; 9, identifier:SORT_ALPHA; 10, default_parameter; 10, 11; 10, 12...
def list_drama_series(self, sort=META.SORT_ALPHA, limit=META.MAX_SERIES, offset=0): result = self._android_api.list_series( media_type=ANDROID.MEDIA_TYPE_DRAMA, filter=sort, limit=limit, offset=offset) return result
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:list_media; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 11; 3, 16; 4, identifier:self; 5, identifier:series; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sort; 8, attribute; 8, 9; 8, 10; 9, identifier:META; 10, identifier:SORT_DESC; 11, default_par...
def list_media(self, series, sort=META.SORT_DESC, limit=META.MAX_MEDIA, offset=0): params = { 'sort': sort, 'offset': offset, 'limit': limit, } params.update(self._get_series_query_dict(series)) result = self._android_api.list_media(**params) r...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:solve_sort; 3, parameters; 3, 4; 3, 5; 4, identifier:expr; 5, identifier:vars; 6, block; 6, 7; 6, 24; 6, 30; 6, 50; 6, 62; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:lhs_values; 10, call; 10, 11; 10, 14; 11, attrib...
def solve_sort(expr, vars): lhs_values = repeated.getvalues(__solve_for_repeated(expr.lhs, vars)[0]) sort_expression = expr.rhs def _key_func(x): return solve(sort_expression, __nest_scope(expr.lhs, vars, x)).value results = ordered.ordered(lhs_values, key_func=_key_func) return Result(repea...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:expression; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:previous_precedence; 7, integer:0; 8, block; 8, 9; 8, 17; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:...
def expression(self, previous_precedence=0): lhs = self.atom() return self.operator(lhs, previous_precedence)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:application; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:func; 6, block; 6, 7; 6, 17; 6, 53; 6, 62; 6, 85; 6, 96; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:start; 10, attribute; 10, 11; 10, 16; 11...
def application(self, func): start = self.tokens.matched.start if self.tokens.accept(common_grammar.rparen): return ast.Apply(func, start=start, end=self.tokens.matched.end, source=self.original) arguments = [self.expression()] while self.tokens.a...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:value_eq; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:other; 6, block; 6, 7; 6, 20; 6, 34; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:self_sorted; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 1...
def value_eq(self, other): self_sorted = ordered.ordered(self.getvalues()) other_sorted = ordered.ordered(repeated.getvalues(other)) return self_sorted == other_sorted
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:merge; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:a_intervals; 5, identifier:b_intervals; 6, identifier:op; 7, block; 7, 8; 7, 20; 7, 32; 7, 48; 7, 53; 7, 58; 7, 62; 7, 66; 7, 70; 7, 82; 7, 177; 8, expression_statement; 8, 9; 9, assignment;...
def merge(a_intervals, b_intervals, op): a_endpoints = a_intervals.flatten().tolist() b_endpoints = b_intervals.flatten().tolist() sentinel = max(a_endpoints[-1], b_endpoints[-1]) + 1 a_endpoints += [sentinel] b_endpoints += [sentinel] a_index = 0 b_index = 0 ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:check_bam; 3, parameters; 3, 4; 3, 5; 4, identifier:bam; 5, default_parameter; 5, 6; 5, 7; 6, identifier:samtype; 7, string:"bam"; 8, block; 8, 9; 8, 16; 8, 26; 8, 58; 8, 89; 8, 143; 9, expression_statement; 9, 10; 10, call; 10, 11; 10, 14; 11,...
def check_bam(bam, samtype="bam"): ut.check_existance(bam) samfile = pysam.AlignmentFile(bam, "rb") if not samfile.has_index(): pysam.index(bam) samfile = pysam.AlignmentFile(bam, "rb") logging.info("Nanoget: No index for bam file could be found, created index.") if not samfile.h...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:get_input; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:source; 5, identifier:files; 6, default_parameter; 6, 7; 6, 8; 7, identifier:threads; 8, integer:4; 9, default_parameter; 9, 10; 9, 11; 10, identifier:readtyp...
def get_input(source, files, threads=4, readtype="1D", combine="simple", names=None, barcoded=False): proc_functions = { 'fastq': ex.process_fastq_plain, 'fasta': ex.process_fasta, 'bam': ex.process_bam, 'summary': ex.process_summary, 'fastq_rich': ex.process_fa...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:validate_wavelengths; 3, parameters; 3, 4; 4, identifier:wavelengths; 5, block; 5, 6; 5, 36; 5, 49; 5, 58; 5, 87; 5, 96; 5, 145; 6, if_statement; 6, 7; 6, 14; 6, 30; 7, call; 7, 8; 7, 9; 8, identifier:isinstance; 9, argument_list; 9, 10; 9, 11;...
def validate_wavelengths(wavelengths): if isinstance(wavelengths, u.Quantity): units.validate_wave_unit(wavelengths.unit) wave = wavelengths.value else: wave = wavelengths if np.isscalar(wave): wave = [wave] wave = np.asarray(wave) if np.any(wave <= 0): raise ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:heapify; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:key; 7, identifier:__marker; 8, block; 8, 9; 9, if_statement; 9, 10; 9, 15; 9, 44; 10, comparison_operator:is; 10, 11; 10, 12; 11, identifie...
def heapify(self, key=__marker): if key is self.__marker: n = len(self._heap) for pos in reversed(range(n//2)): self._sink(pos) else: try: pos = self._position[key] except KeyError: raise KeyError(key) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 29; 1, 31; 2, function_name:__update_display_items_model; 3, parameters; 3, 4; 3, 5; 3, 11; 3, 21; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:display_items_model; 7, type; 7, 8; 8, attribute; 8, 9; 8, 10; 9, identifier:ListModel; 10, identif...
def __update_display_items_model(self, display_items_model: ListModel.FilteredListModel, data_group: typing.Optional[DataGroup.DataGroup], filter_id: typing.Optional[str]) -> None: with display_items_model.changes(): if data_group is not None: display_items_model.container = data_gro...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_by_date_key; 3, parameters; 3, 4; 4, identifier:data_item; 5, block; 5, 6; 6, return_statement; 6, 7; 7, expression_list; 7, 8; 7, 25; 7, 28; 8, conditional_expression:if; 8, 9; 8, 19; 8, 22; 9, binary_operator:+; 9, 10; 9, 13; 10, attribu...
def sort_by_date_key(data_item): return data_item.title + str(data_item.uuid) if data_item.is_live else str(), data_item.date_for_sorting, str(data_item.uuid)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:open_mfbpchdataset; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:paths; 5, default_parameter; 5, 6; 5, 7; 6, identifier:concat_dim; 7, string:'time'; 8, default_parameter; 8, 9; 8, 10; 9, identifier:compat; 10, string:'n...
def open_mfbpchdataset(paths, concat_dim='time', compat='no_conflicts', preprocess=None, lock=None, **kwargs): from xarray.backends.api import _MultiFileCloser dask = kwargs.pop('dask', False) if not dask: raise ValueError("Reading multiple files without dask is not supported"...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_get_archive_filelist; 3, parameters; 3, 4; 4, identifier:filename; 5, block; 5, 6; 5, 10; 5, 88; 5, 100; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:names; 9, list:[]; 10, if_statement; 10, 11; 10, 17; 10, 42; 10, 7...
def _get_archive_filelist(filename): names = [] if tarfile.is_tarfile(filename): with tarfile.open(filename) as tar_file: names = sorted(tar_file.getnames()) elif zipfile.is_zipfile(filename): with zipfile.ZipFile(filename) as zip_file: names = sorted(zip_file.namelis...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:pbar_strings; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:files; 5, default_parameter; 5, 6; 5, 7; 6, identifier:desc; 7, string:''; 8, dictionary_splat_pattern; 8, 9; 9, identifier:kwargs; 10, block; 10, 11; 11, return_statement; 11, 12; 1...
def pbar_strings(files, desc='', **kwargs): return tqdm( sorted(files, key=lambda s: s.lower()), desc=('<' + str(datetime.now().strftime("%Y-%m-%d %H:%M:%S")) + '> ' + desc), dynamic_ncols=True, **kwargs)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_func; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:key; 6, block; 6, 7; 6, 18; 6, 29; 6, 40; 7, if_statement; 7, 8; 7, 15; 8, comparison_operator:==; 8, 9; 8, 10; 9, identifier:key; 10, attribute; 10, 11; 10, 14; 11, attrib...
def sort_func(self, key): if key == self._KEYS.TIME: return 'aaa' if key == self._KEYS.DATA: return 'zzy' if key == self._KEYS.SOURCE: return 'zzz' return key
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_func; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:key; 6, block; 6, 7; 6, 18; 6, 29; 7, if_statement; 7, 8; 7, 15; 8, comparison_operator:==; 8, 9; 8, 10; 9, identifier:key; 10, attribute; 10, 11; 10, 14; 11, attribute; 11...
def sort_func(self, key): if key == self._KEYS.VALUE: return 'aaa' if key == self._KEYS.SOURCE: return 'zzz' return key
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_func; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:key; 6, block; 6, 7; 6, 18; 6, 29; 6, 40; 6, 51; 6, 62; 6, 73; 6, 84; 7, if_statement; 7, 8; 7, 15; 8, comparison_operator:==; 8, 9; 8, 10; 9, identifier:key; 10, attribute...
def sort_func(self, key): if key == self._KEYS.SCHEMA: return 'aaa' if key == self._KEYS.NAME: return 'aab' if key == self._KEYS.SOURCES: return 'aac' if key == self._KEYS.ALIAS: return 'aad' if key == self._KEYS.MODELS: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_func; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:key; 6, block; 6, 7; 6, 18; 6, 29; 6, 40; 7, if_statement; 7, 8; 7, 15; 8, comparison_operator:==; 8, 9; 8, 10; 9, identifier:key; 10, attribute; 10, 11; 10, 14; 11, attrib...
def sort_func(self, key): if key == self._KEYS.TIME: return 'aaa' if key == self._KEYS.MODEL: return 'zzy' if key == self._KEYS.SOURCE: return 'zzz' return key
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:TypeFactory; 3, parameters; 3, 4; 4, identifier:type_; 5, block; 5, 6; 5, 21; 5, 40; 6, if_statement; 6, 7; 6, 18; 7, boolean_operator:and; 7, 8; 7, 13; 8, call; 8, 9; 8, 10; 9, identifier:isinstance; 10, argument_list; 10, 11; 10, 12; 11, iden...
def TypeFactory(type_): if isinstance(type_, type) and issubclass(type_, Type): return type_ for x in __types__: if x.represents(type_): return x.get(type_) raise UnknownType(type_)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_sorted_dependencies; 3, parameters; 3, 4; 4, identifier:service_model; 5, block; 5, 6; 5, 21; 5, 33; 5, 60; 5, 77; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:app_models; 9, call; 9, 10; 9, 11; 10, identifier:lis...
def get_sorted_dependencies(service_model): app_models = list(service_model._meta.app_config.get_models()) dependencies = {model: set() for model in app_models} relations = ( relation for model in app_models for relation in model._meta.related_objects if relation.on_delete in...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:format_time_and_value_to_segment_list; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:time_and_value_list; 5, identifier:segments_count; 6, identifier:start_timestamp; 7, identifier:end_timestamp; 8, default_parameter; 8, 9; 8, 10;...
def format_time_and_value_to_segment_list(time_and_value_list, segments_count, start_timestamp, end_timestamp, average=False): segment_list = [] time_step = (end_timestamp - start_timestamp) / segments_count for i in range(segments_count): segment_start_time...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_api_root_view; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:api_urls; 7, None; 8, block; 8, 9; 8, 15; 8, 25; 8, 47; 8, 154; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11...
def get_api_root_view(self, api_urls=None): api_root_dict = OrderedDict() list_name = self.routes[0].name for prefix, viewset, basename in self.registry: api_root_dict[prefix] = list_name.format(basename=basename) class APIRootView(views.APIView): _ignore_model_pe...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_default_base_name; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:viewset; 6, block; 6, 7; 6, 16; 6, 41; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:queryset; 10, call; 10, 11; 10, 12; 11, identifi...
def get_default_base_name(self, viewset): queryset = getattr(viewset, 'queryset', None) if queryset is not None: get_url_name = getattr(queryset.model, 'get_url_name', None) if get_url_name is not None: return get_url_name() return super(SortedDefaultRoute...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sort_dict; 3, parameters; 3, 4; 3, 5; 4, identifier:d; 5, default_parameter; 5, 6; 5, 7; 6, identifier:desc; 7, True; 8, block; 8, 9; 8, 31; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:sort; 12, call; 12, 13; ...
def sort_dict(d, desc=True): sort = sorted(d.items(), key=lambda x: x[1], reverse=desc) return OrderedDict(sort)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:_tupleCompare; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 17; 3, 20; 4, identifier:tuple1; 5, identifier:ineq; 6, identifier:tuple2; 7, default_parameter; 7, 8; 7, 9; 8, identifier:eq; 9, lambda; 9, 10; 9, 13; 10, lambda_parameters; 10, 11; 10,...
def _tupleCompare(tuple1, ineq, tuple2, eq=lambda a,b: (a==b), ander=AND, orer=OR): orholder = [] for limit in range(len(tuple1)): eqconstraint = [ eq(elem1, elem2) for elem1, elem2 in zip(tuple1, tuple2)[:limit]] ineqconstraint = in...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:get_datasets; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:query; 7, string:'*:*'; 8, dictionary_splat_pattern; 8, 9; 9, identifier:kwargs; 10, block; 10, 11; 11, return_statement; 11, 12...
def get_datasets(self, query='*:*', **kwargs): return hdx.data.dataset.Dataset.search_in_hdx(query=query, configuration=self.configuration, fq='organization:%s' % self.data['name'], **kwargs)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_all_organization_names; 3, parameters; 3, 4; 3, 7; 4, default_parameter; 4, 5; 4, 6; 5, identifier:configuration; 6, None; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 19; 9, 25; 10, expression_statement; 10,...
def get_all_organization_names(configuration=None, **kwargs): organization = Organization(configuration=configuration) organization['id'] = 'all organizations' return organization._write_to_hdx('list', kwargs, 'id')
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:search_in_hdx; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:cls; 5, default_parameter; 5, 6; 5, 7; 6, identifier:query; 7, string:'*:*'; 8, default_parameter; 8, 9; 8, 10; 9, identifier:configuration; 10, None; 11, default_para...
def search_in_hdx(cls, query='*:*', configuration=None, page_size=1000, **kwargs): dataset = Dataset(configuration=configuration) total_rows = kwargs.get('rows', cls.max_int) start = kwargs.get('start', 0) all_datasets = None attempts = 0 while attempts < cls.max_attempts...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 1, 22; 2, function_name:sort_dict; 3, parameters; 3, 4; 3, 8; 3, 13; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:d; 6, type; 6, 7; 7, identifier:dict; 8, typed_default_parameter; 8, 9; 8, 10; 8, 12; 9, identifier:by; 10, type; 10, 11; 11, identifier:str; 12,...
def sort_dict(d: dict, by: str = 'key', allow_duplicates: bool = True) -> collections.OrderedDict: if by == 'key': i = 0 elif by == 'value': values = list(d.values()) if len(values) != len(set(values)) and not allow_duplicates: duplicates = find_duplicates(value...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_all_users; 3, parameters; 3, 4; 3, 7; 4, default_parameter; 4, 5; 4, 6; 5, identifier:configuration; 6, None; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 19; 9, 25; 9, 36; 9, 42; 9, 75; 10, expression_statem...
def get_all_users(configuration=None, **kwargs): user = User(configuration=configuration) user['id'] = 'all users' result = user._write_to_hdx('list', kwargs, 'id') users = list() if result: for userdict in result: user = User(userdict, configuration=c...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:fromkeys; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:cls; 5, identifier:iterable; 6, default_parameter; 6, 7; 6, 8; 7, identifier:value; 8, None; 9, block; 9, 10; 9, 28; 10, if_statement; 10, 11; 10, 16; 11, not_operator; 11, 12; 12, call; ...
def fromkeys(cls, iterable, value=None): if not callable(value): return cls(dict.fromkeys(iterable, value)) return cls((key, value(key)) for key in iterable)