sequence
stringlengths
1.19k
35k
code
stringlengths
75
8.58k
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_raw_counts'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
def get_raw_counts(self): words = [] labels = [] words_said = set() for unit in self.parsed_response: word = unit.text test = False if self.type == "PHONETIC": test = (word.startswith(self.letter) and "T_" not in...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'compute_similarity_score'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'childre...
def compute_similarity_score(self, unit1, unit2): if self.type == "PHONETIC": word1 = unit1.phonetic_representation word2 = unit2.phonetic_representation if self.current_similarity_measure == "phone": word1_length, word2_length = len(word1), len(word2) ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'compute_pairwise_similarity_score'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children...
def compute_pairwise_similarity_score(self): pairs = [] all_scores = [] for i, unit in enumerate(self.parsed_response): for j, other_unit in enumerate(self.parsed_response): if i != j: pair = (i, j) rev_pair = (j, i) ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'compute_between_collection_interval_duration'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identi...
def compute_between_collection_interval_duration(self, prefix): durations = [] for collection in self.collection_list: start = collection[0].start_time end = collection[-1].end_time durations.append((start, end)) interstices = [durations[i + 1][0] - durations[...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'compute_within_collection_vowel_duration'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'ident...
def compute_within_collection_vowel_duration(self, prefix, no_singletons=False): if no_singletons: min_size = 2 else: prefix += "no_singletons_" min_size = 1 durations = [] for cluster in self.collection_list: if len(cluster) >= min_size: ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'print_output'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self...
def print_output(self): if self.response_format == "csv": for key in self.measures: if "TIMING_" in key: self.measures[key] = "NA" if not self.quiet: print print self.type.upper() + " RESULTS:" keys = [e for e in self.me...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_by'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
def sort_by(self, fieldName, reverse=False): ''' sort_by - Return a copy of this collection, sorted by the given fieldName. The fieldName is accessed the same way as other filtering, so it supports custom properties, etc. @param fieldName <str> - The name of the field on ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_qtls_from_rqtl_data'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': []...
def get_qtls_from_rqtl_data(matrix, lod_threshold): t_matrix = list(zip(*matrix)) qtls = [['Trait', 'Linkage Group', 'Position', 'Exact marker', 'LOD']] for row in t_matrix[3:]: lgroup = None max_lod = None peak = None cnt = 1 while cnt < len(row): if lgro...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '19']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'response'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17']}; {'id': '4', 'type': 'identifier', 'chil...
def response(code, body='', etag=None, last_modified=None, expires=None, **kw): if etag is not None: if not (etag[0] == '"' and etag[-1] == '"'): etag = '"%s"' % etag kw['etag'] = etag if last_modified is not None: kw['last_modified'] = datetime_to_httpdate(last_modified) ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'plot_optimum_prediction_fraction_correct_cutoffs_over_range'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8'...
def plot_optimum_prediction_fraction_correct_cutoffs_over_range(self, analysis_set, min_stability_classication_x_cutoff, max_stability_classication_x_cutoff, suppress_plot = False, analysis_file_prefix = None, verbose = True): '''Plots the optimum cutoff for the predictions to maximize the fraction correct metr...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_chain_details_by_related_pdb_chains'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'i...
def get_chain_details_by_related_pdb_chains(self, pdb_id, chain_id, pfam_accs): ''' Returns a dict of SCOPe details using info This returns Pfam-level information for a PDB chain i.e. no details on the protein, species, or domain will be returned. If there are SCOPe entries for the assoc...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'recall_service'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
def recall_service(self, service): if not isinstance(service, Service): raise TypeError("service must be of type Service.") logger.warning("The deployment for {0} on {1} failed starting the rollback.".format(service.alias, self.url.geturl())) def anonymous(anonymous_service): ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sorted_items'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
def sorted_items(d, key=__identity, reverse=False): def pairkey_key(item): return key(item[0]) return sorted(d.items(), key=pairkey_key, reverse=reverse)
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '22']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_or_create_in_transaction'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13', '16', '19']}; {'id': '...
def get_or_create_in_transaction(tsession, model, values, missing_columns = [], variable_columns = [], updatable_columns = [], only_use_supplied_columns = False, read_only = False): ''' Uses the SQLAlchemy model to retrieve an existing record based on the supplied field values or, if there is no existing re...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'errors'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'...
def errors(self, instance): if isinstance(instance, dict): return self._validate(instance) elif isinstance(instance, forms.BaseForm): if instance.is_bound and instance.is_valid(): return self._validate(instance.cleaned_data) return self._validate(dict(...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'multimatch'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17']}; {'id': '4', 'type': 'identifier', 'ch...
def multimatch(self, origin=None, rel=None, target=None, attrs=None, include_ids=False): ''' Iterator over relationship IDs that match a pattern of components, with multiple options provided for each component origin - (optional) origin of the relationship (similar to an RDF subject), or set of ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_qtls_from_mapqtl_data'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'childr...
def get_qtls_from_mapqtl_data(matrix, threshold, inputfile): trait_name = inputfile.split(')_', 1)[1].split('.mqo')[0] qtls = [] qtl = None for entry in matrix[1:]: if qtl is None: qtl = entry if qtl[1] != entry[1]: if float(qtl[4]) > float(threshold): ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'merge_range_pairs'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
def merge_range_pairs(prs): '''Takes in a list of pairs specifying ranges and returns a sorted list of merged, sorted ranges.''' new_prs = [] sprs = [sorted(p) for p in prs] sprs = sorted(sprs) merged = False x = 0 while x < len(sprs): newx = x + 1 new_pair = list(sprs[x]) ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '29']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20', '23', '26']}; {'id': '4', 'type': 'id...
def create(self, agent_cls=None, n_agents=10, agent_kwargs={}, env_cls=Environment, env_kwargs={}, callback=None, conns=0, log_folder=None): if not issubclass(env_cls, Environment): raise TypeError("Environment class must be derived from ({}" ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'callproc'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier', 'children': ...
def callproc(self, procname, parameters=(), quiet=False, expect_return_value=False): self.procedures_run += 1 i = 0 errcode = 0 caughte = None out_param_indices = [] for j in range(len(parameters)): p = parameters[j] if type(p) == type('') and p[0]...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_insert_dict_string'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13']}; {'id': '4', 'type': 'id...
def create_insert_dict_string(self, tblname, d, PKfields=[], fields=None, check_existing = False): '''The main function of the insert_dict functions. This creates and returns the SQL query and parameters used by the other functions but does not insert any data into the database. Simple fun...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fixed_point'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children':...
def fixed_point(is_zero, plus, minus, f, x): @memo_Y def _fixed_point(fixed_point_fun): def __fixed_point(collected, new): diff = minus(new, collected) if is_zero(diff): return collected return fixed_point_fun(plus(collected, diff), f(diff)) re...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'connections_from_graph'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children'...
def connections_from_graph(env, G, edge_data=False): if not issubclass(G.__class__, (Graph, DiGraph)): raise TypeError("Graph structure must be derived from Networkx's " "Graph or DiGraph.") if not hasattr(env, 'get_agents'): raise TypeError("Parameter 'env' must have get...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'graph_from_connections'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [],...
def graph_from_connections(env, directed=False): G = DiGraph() if directed else Graph() conn_list = env.get_connections(data=True) for agent, conns in conn_list: G.add_node(agent) ebunch = [] for nb, data in conns.items(): ebunch.append((agent, nb, data)) if len(e...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'profile'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'requ...
def profile(request, status=200): if request.method == 'GET': if request.GET.get("username", False): try: user_profile = User.objects.get(username=request.GET.get("username"), userprofile__public=True).userprofile except...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_session_identifiers'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'childre...
def get_session_identifiers(cls, folder=None, inputfile=None): sessions = [] if inputfile and folder: raise MQ2Exception( 'You should specify either a folder or a file') if folder: if not os.path.isdir(folder): return sessions f...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'template2regex'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
def template2regex(template, ranges=None): if len(template) and -1 < template.find('|') < len(template) - 1: raise InvalidTemplateError("'|' may only appear at the end, found at position %d in %s" % (template.find('|'), template)) if ranges is None: ranges = DEFAULT_RANGES anchor = True ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'path'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
def path(self, target, args, kw): if type(target) in string_types: if ':' in target: prefix, rest = target.split(':', 1) route = self.named_routes[prefix] prefix_params = route._pop_params(args, kw) prefix_path = route.path([], prefix_p...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_children_graph'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'childr...
def get_children_graph(self, item_ids=None, language=None, forbidden_item_ids=None): if forbidden_item_ids is None: forbidden_item_ids = set() def _children(item_ids): if item_ids is None: items = Item.objects.filter(active=True).prefetch_related('children') ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_parents_graph'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [],...
def get_parents_graph(self, item_ids, language=None): def _parents(item_ids): if item_ids is None: items = Item.objects.filter(active=True).prefetch_related('parents') else: item_ids = [ii for iis in item_ids.values() for ii in iis] items =...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_graph'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
def get_graph(self, item_ids, language=None): def _related(item_ids): if item_ids is None: items = Item.objects.filter(active=True).prefetch_related('parents', 'children') else: item_ids = [ii for iis in item_ids.values() for ii in iis] ite...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'translate_item_ids'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'childre...
def translate_item_ids(self, item_ids, language, is_nested=None): if is_nested is None: def is_nested_fun(x): return True elif isinstance(is_nested, bool): def is_nested_fun(x): return is_nested else: is_nested_fun = is_nested ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_leaves'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [],...
def get_leaves(self, item_ids=None, language=None, forbidden_item_ids=None): forbidden_item_ids = set() if forbidden_item_ids is None else set(forbidden_item_ids) children = self.get_children_graph(item_ids, language=language, forbidden_item_ids=forbidden_item_ids) counts = self.get_children_cou...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_image'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17']}; {'id': '4', 'type': 'identifier', 'chi...
async def get_image(self, imgtype=None, tags=None, nsfw=None, hidden=None, filetype=None): if not imgtype and not tags: raise MissingTypeOrTags("'get_image' requires at least one of either type or tags.") if imgtype and not isinstance(imgtype, str): raise TypeError("type of 'imgt...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'query'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'logfil...
def query(logfile, jobID = None): joblist = logfile.readFromLogfile() if jobID and type(jobID) == type(1): command = ['qstat', '-j', str(jobID)] else: command = ['qstat'] processoutput = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() output = ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'build'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10']}; {'id': '4', 'type': 'identifier', 'children': [],...
def build(client, repository_tag, docker_file, tag=None, use_cache=False): if not isinstance(client, docker.Client): raise TypeError("client needs to be of type docker.Client.") if not isinstance(docker_file, six.string_types) or not os.path.exists(docker_file): raise Exception("...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_class'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'requ...
def create_class(request): if request.method == 'GET': return render(request, 'classes_create.html', {}, help_text=create_class.__doc__) if request.method == 'POST': if not request.user.is_authenticated() or not hasattr(request.user, "userprofile"): return render_json(request, { ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_student'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 're...
def create_student(request): if not get_config('proso_user', 'allow_create_students', default=False): return render_json(request, { 'error': _('Creation of new users is not allowed.'), 'error_type': 'student_creation_not_allowed' }, template='class_create_student.html', help_...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '80']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'lograptor'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20', '23', '26', '29', '32', '35', '38'...
def lograptor(files, patterns=None, matcher='ruled', cfgfiles=None, apps=None, hosts=None, filters=None, time_period=None, time_range=None, case=False, invert=False, word=False, files_with_match=None, count=False, quiet=False, max_count=0, only_matching=False, line_number=False...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sanitize_codon_list'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
def sanitize_codon_list(codon_list, forbidden_seqs=()): for codon in codon_list: if len(codon) != 3: raise ValueError("Codons must have exactly 3 bases: '{}'".format(codon)) bad_seqs = set() bad_seqs.union( restriction_sites.get(seq, seq) for seq in forbidden_seqs...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_node'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
def add_node(self, node): nodes = self.nodes() if len(nodes) <= self.m0: other_nodes = [n for n in nodes if n.id != node.id] for n in other_nodes: node.connect(direction="both", whom=n) else: for idx_newvector in xrange(self.m): ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_concepts_to_recalculate'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier',...
def get_concepts_to_recalculate(self, users, lang, concepts=None): only_one_user = False if not isinstance(users, list): only_one_user = True users = [users] mapping = self.get_item_concept_mapping(lang) current_user_stats = defaultdict(lambda: {}) user_st...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'recalculate_concepts'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': ...
def recalculate_concepts(self, concepts, lang=None): if len(concepts) == 0: return if lang is None: items = Concept.objects.get_concept_item_mapping(concepts=Concept.objects.filter(pk__in=set(flatten(concepts.values())))) else: items = Concept.objects.get_conc...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_user_stats'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15']}; {'id': '4', 'type': 'identifier', ...
def get_user_stats(self, users, lang=None, concepts=None, since=None, recalculate=True): only_one_user = False if not isinstance(users, list): users = [users] only_one_user = True if recalculate: if lang is None: raise ValueError('Recalculation...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '21']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'execute'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18']}; {'id': '4', 'type': 'identifier', '...
def execute(self, sql, parameters = None, cursorClass = DictCursor, quiet = False, locked = False, do_commit = True): i = 0 errcode = 0 caughte = None cursor = None if sql.find(";") != -1 or sql.find("\\G") != -1: raise Exception("The SQL command '%s' contains a semi-colon or \\G. This is a potential SQL i...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_tasks'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '8', '11']}; {'id': '4', 'type': 'identifier', 'childre...
def create_tasks(task_coro, addrs, *args, flatten=True, **kwargs): '''Create and schedule a set of asynchronous tasks. The function creates the tasks using a given list of agent addresses and wraps each of them in :func:`asyncio.ensure_future`. The ``*args`` and ``**kwargs`` are passed down to :func:`ta...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'ERROR', 'children': ['2', '204']}; {'id': '2', 'type': 'function_definition', 'children': ['3', '4', '21']}, {'id': '3', 'type': 'function_name', 'children': [], 'value': 'write'}; {'id': '4', 'type': 'parameters', 'children': ['5', '6', '9', '12', ...
def write(models, out=None, base=None, propertybase=None, shorteners=None, logger=logging): ''' models - input Versa models from which output is generated. Must be a sequence object, not an iterator ''' assert out is not None if not isinstance(models, list): models = [models] sho...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'register_extensions'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
def register_extensions(self): try: for extension, config in self.config['extensions'].items(): extension_bstr = '' extension_pieces = extension.split('.') if len(extension_pieces) > 1: extension_bstr = '.'.join(extension_pieces) ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '19']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'request'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13', '16']}; {'id': '4', 'type': 'identifier', '...
def request(self, method, path, query={}, headers={}, body={}, base_url=None): ''' Issues a request to Onshape Args: - method (str): HTTP method - path (str): Path e.g. /api/documents/:id - query (dict, default={}): Query params in key-value pairs ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fix_pdb'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {...
def fix_pdb(self): '''A function to fix fatal errors in PDB files when they can be automatically fixed. At present, this only runs if self.strict is False. We may want a separate property for this since we may want to keep strict mode but still allow PDBs to be fixed. The only f...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'stripForDDG'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14']}; {'id': '4', 'type': 'identifier', 'childre...
def stripForDDG(self, chains = True, keepHETATM = False, numberOfModels = None, raise_exception = True): '''Strips a PDB to ATOM lines. If keepHETATM is True then also retain HETATM lines. By default all PDB chains are kept. The chains parameter should be True or a list. In the latter case...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'neighbors2'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10']}; {'id': '4', 'type': 'identifier', 'children'...
def neighbors2(self, distance, chain_residue, atom = None, resid_list = None): '''this one is more precise since it uses the chain identifier also''' if atom == None: lines = [line for line in self.atomlines(resid_list) if line[17:20] in allowed_PDB_residues_types] else: ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '26']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_document'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '11', '14', '17', '20', '23']}; {'id': '4', '...
def add_document(self, item_uri, name, metadata, content=None, docurl=None, file=None, displaydoc=False, preferName=False, contrib_id=None): if not preferName and file is not None: docid = os.path.basename(file) else: ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_agents'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [],...
def get_agents(self, addr=True, agent_cls=None, include_manager=False): '''Get agents in the environment. :param bool addr: If ``True``, returns only addresses of the agents. :param agent_cls: Optional, if specified returns only agents belonging to that particular class. ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'tee'}, {'id': '3', 'type': 'parameters', 'children': ['4', '6']}; {'id': '4', 'type': 'list_splat_pattern', 'children': ['5']}, {'id':...
def tee(*popenargs, **kwargs): import subprocess, select, sys process = subprocess.Popen( stdout=subprocess.PIPE, stderr=subprocess.PIPE, *popenargs, **kwargs) stdout, stderr = '', '' def read_stream(input_callback, output_stream): read = input_callback() output_s...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dump_object'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
def dump_object(self, obj): if isinstance(obj, uuid.UUID): return str(obj) if hasattr(obj, 'isoformat'): return obj.isoformat() if isinstance(obj, (bytes, bytearray, memoryview)): return base64.b64encode(obj).decode('ASCII') raise TypeError('{!r} is no...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'normalize_datum'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
def normalize_datum(self, datum): if datum is None: return datum if isinstance(datum, self.PACKABLE_TYPES): return datum if isinstance(datum, uuid.UUID): datum = str(datum) if isinstance(datum, bytearray): datum = bytes(datum) if is...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'redirect'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'end...
def redirect(endpoint, **kw): _endpoint = None if isinstance(endpoint, six.string_types): _endpoint = endpoint if "/" in endpoint: return f_redirect(endpoint) else: for r in Mocha._app.url_map.iter_rules(): _endpoint = endpoint if '...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_search'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
def _search(self, query, search_term): criterias = mongoengine.Q() rel_criterias = mongoengine.Q() terms = shlex.split(search_term) if len(terms) == 1 and re.match(RE_OBJECTID, terms[0]): q = query.filter(id=bson.ObjectId(terms[0])) if q.count() == 1: ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'replace_seqres'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
def replace_seqres(self, pdb, update_atoms = True): newpdb = PDB() inserted_seqres = False entries_before_seqres = set(["HEADER", "OBSLTE", "TITLE", "CAVEAT", "COMPND", "SOURCE", "KEYWDS", "EXPDTA", "AUTHOR", "REVDAT", "SPRSDE", "JRNL", "R...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'enrich_json_objects_by_object_type'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'ch...
def enrich_json_objects_by_object_type(request, value): time_start_globally = time() if isinstance(value, list): json = [x.to_json() if hasattr(x, "to_json") else x for x in value] else: if isinstance(value, dict): json = value else: json = value.to_json() ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'change_parent'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
def change_parent(sender, instance, **kwargs): if instance.id is None: return if len({'term', 'term_id'} & set(instance.changed_fields)) != 0: diff = instance.diff parent = diff['term'][0] if 'term' in diff else diff['term_id'][0] child_id = instance.item_id if parent is ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'bin_atoms'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'},...
def bin_atoms(self): '''This function bins the Atoms into fixed-size sections of the protein space in 3D.''' low_point = numpy.array([self.min_x, self.min_y, self.min_z]) high_point = numpy.array([self.max_x, self.max_y, self.max_z]) atom_bin_dimensions = numpy.ceil((high_point - low_poi...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
def get(self, attr_name, *args): if not isinstance(attr_name, six.string_types): raise TypeError('attr_name must be a str.') if '-' in attr_name: attr_name = attr_name.replace('-', '_') parent_attr = self attr = getattr(parent_attr, attr_name, None) for ar...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_load_yml_config'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
def _load_yml_config(self, config_file): if not isinstance(config_file, six.string_types): raise TypeError('config_file must be a str.') try: def construct_yaml_int(self, node): obj = SafeConstructor.construct_yaml_int(self, node) data = ConfigInt...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_create_attr'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [],...
def _create_attr(self, property_key, data, ancestors): if not isinstance(property_key, six.string_types): raise TypeError("property_key must be a string. type: {0} was passed.".format(type(property_key))) if not isinstance(ancestors, OrderedDict): raise TypeError("ancestors must ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_collect_unrecognized_values'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier',...
def _collect_unrecognized_values(self, scheme, data, ancestors): if not isinstance(ancestors, OrderedDict): raise TypeError("ancestors must be an OrderedDict. type: {0} was passed.".format(type(ancestors))) if not isinstance(scheme, dict): raise TypeError('scheme must be a dict. ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_update_scheme'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
def _update_scheme(self, scheme, ancestors): if not isinstance(ancestors, OrderedDict): raise TypeError("ancestors must be an OrderedDict. type: {0} was passed.".format(type(ancestors))) if not isinstance(scheme, dict): raise TypeError('scheme must be a dict. type: {0} was passed...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_walk_tree'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13']}; {'id': '4', 'type': 'identifier', 'chi...
def _walk_tree(self, data, scheme, ancestors=None, property_name=None, prefix=None): if property_name is None: property_name = 'root' order = ['registries'] + [key for key in scheme.keys() if key not in ('registries',)] scheme = OrderedDict(sorted(scheme.items(), key=lambda x...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__execute_validations'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '12']}; {'id': '4', 'type': 'id...
def __execute_validations(self, validations, data, property_name, ancestors, negation=False, prefix=None): if not isinstance(ancestors, OrderedDict): raise TypeError("ancestors must be an OrderedDict. type: {0} was passed.".format(type(ancestors))) if not isinstance(validations, dict): ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'users_feature'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'app...
def users_feature(app): if not app.config.get('USER_JWT_SECRET', None): raise x.JwtSecretMissing('Please set USER_JWT_SECRET in config') app.session_interface = BoilerSessionInterface() user_service.init(app) login_manager.init_app(app) login_manager.login_view = 'user.login' login_manag...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'match'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}...
def match(self, other): ''' This is a noisy terminal-printing function at present since there is no need to make it a proper API function.''' colortext.message("FASTA Match") for frompdbID, fromchains in sorted(self.iteritems()): matched_pdbs = {} matched_chains = {} ...
{'id': '0', 'type': 'ERROR', 'children': ['1', '2', '7', '9', '15', '19', '26', '33', '36', '37', '40', '46', '48', '49', '50', '51', '54', '55', '56', '57', '60', '61', '62', '63', '69', '72', '82', '86', '91', '101', '116', '126', '131', '171', '179', '211', '214', '215', '219', '222', '223', '226', '227', '230', '23...
def generateSummaryHTMLTable(self, extraLapse = TYPICAL_LAPSE): '''Generates a summary in HTML of the status of the expected scripts broken based on the log. This summary is returned as a list of strings. ''' scriptsRun = self.scriptsRun html = [] html.append("<table style='text-align:center;border:1px so...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'apply_quality_control_checks'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14']}; {'id': '4', 'type': 'iden...
def apply_quality_control_checks( seq, check_gen9_seqs=True, check_short_length=True, check_local_gc_content=True, check_global_gc_content=True): seq = seq.upper() failure_reasons = [] if check_short_length: if len(seq) < min_gene_length: failure_r...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'oauth_connect'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
def oauth_connect(self, provider, action): valid_actions = ["connect", "authorized", "test"] _redirect = views.auth.Account.account_settings if is_authenticated() else self.login if action not in valid_actions \ or "oauth" not in __options__.get("registration_methods") \ ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'set_neighbors'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
async def set_neighbors(self): '''Set neighbors for multi-environments, their slave environments, and agents. ''' t = time.time() self.logger.debug("Settings grid neighbors for the multi-environments.") tasks = [] for i in range(len(self.grid)): for j ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'vectors'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
def vectors(self, direction="all", failed=False): if direction not in ["all", "incoming", "outgoing"]: raise ValueError( "{} is not a valid vector direction. " "Must be all, incoming or outgoing.".format(direction)) if failed not in ["all", False, True]: ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'transmissions'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': ...
def transmissions(self, direction="outgoing", status="all", failed=False): if direction not in ["incoming", "outgoing", "all"]: raise(ValueError("You cannot get transmissions of direction {}." .format(direction) + "Type can only be incoming, outgoing or...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'user_stats'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'reques...
def user_stats(request): timer('user_stats') response = {} data = None if request.method == "POST": data = json.loads(request.body.decode("utf-8"))["filters"] if "filters" in request.GET: data = load_query_json(request.GET, "filters") if data is None: return render_json(r...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_resource'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '11']}; {'id': '4', 'type': 'identifier', ...
def create_resource(output_model, rtype, unique, links, existing_ids=None, id_helper=None): ''' General-purpose routine to create a new resource in the output model, based on data provided output_model - Versa connection to model to be updated rtype - Type IRI for the new resource, set with...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'patterns'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, ...
def patterns(self): if not self.args.patterns and not self.args.pattern_files: try: self.args.patterns.append(self.args.files.pop(0)) except IndexError: raise LogRaptorArgumentError('PATTERN', 'no search pattern') patterns = set() if self.a...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'qualify'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
def qualify(qualification, value, worker): from boto.mturk.connection import MTurkConnection config = PsiturkConfig() config.load_config() aws_access_key_id = config.get('AWS Access', 'aws_access_key_id') aws_secret_access_key = config.get('AWS Access', 'aws_secret_access_key') conn = MTurkConne...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'setup_jobs'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
def setup_jobs(outpath, options, input_files): ''' This function sets up the jobs by creating the necessary input files as expected. - outpath is where the output is to be stored. - options is the optparse options object. - input_files is a list of paths to input files. ''' job...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_stdlib'}, {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '7', '12', '49', '74'...
def load_stdlib(): '''Scans sys.path for standard library modules. ''' if _stdlib: return _stdlib prefixes = tuple({os.path.abspath(p) for p in ( sys.prefix, getattr(sys, 'real_prefix', sys.prefix), getattr(sys, 'base_prefix', sys.prefix), )}) for sp in sys.path: ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'is_python_script'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
def is_python_script(filename): '''Checks a file to see if it's a python script of some sort. ''' if filename.lower().endswith('.py'): return True if not os.path.isfile(filename): return False try: with open(filename, 'rb') as fp: if fp.read(2) != b' ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fit'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14']}; {'id': '4', 'type': 'identifier', 'children': [], ...
def fit(dataset, alpha=1e-8, max_iterations=10, save_results=True, show=False): from disco.worker.pipeline.worker import Worker, Stage from disco.core import Job, result_iterator import numpy as np if dataset.params["y_map"] == []: raise Exception("Logistic regression requires a target label map...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'draw_image'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15']}; {'id': '4', 'type': 'identifier', 'chi...
def draw_image(self, image, xmin=0, ymin=0, xmax=None, ymax=None): if xmax is None: xmax = xmin + image.size[0] if ymax is None: ymax = ymin + image.size[1] self.bitmap_list.append({'image': image, 'xmin': xmin, ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_prepare_data'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
def _prepare_data(self): xmin, xmax = self.limits['xmin'], self.limits['xmax'] self.prepared_plot_series_list = [] for series in self.plot_series_list: prepared_series = series.copy() data = prepared_series['data'] x, _, _, _ = zip(*data) if sorted...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_departures'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'childre...
def get_departures(self, stop_id, route, destination, api_key): self.stop_id = stop_id self.route = route self.destination = destination self.api_key = api_key url = \ 'https://api.transport.nsw.gov.au/v1/tp/departure_mon?' \ 'outputFormat=rapidJSON&coordO...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pw'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10', '11', '12']}; {'id': '4', 'type': 'identifie...
def pw( ctx, key_pattern, user_pattern, mode, strict_flag, user_flag, file, edit_subcommand, gen_subcommand, ): def handle_sigint(*_): click.echo() ctx.exit(1) signal.signal(signal.SIGINT, handle_sigint) if gen_subcommand: length = int(key_pattern)...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'launch_editor'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
def launch_editor(ctx, file): editor = os.environ.get("PW_EDITOR") if not editor: click.echo("error: no editor set in PW_EDITOR environment variables") ctx.exit(1) if not os.path.exists(file): click.echo("error: password store not found at '%s'" % file, err=True) ctx.exit(1) ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fit'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sim...
def fit(sim_mat, D_len, cidx): min_energy = np.inf for j in range(3): inds = [np.argmin([sim_mat[idy].get(idx, 0) for idx in cidx]) for idy in range(D_len) if idy in sim_mat] cidx = [] energy = 0 for i in np.unique(inds): indsi = np.where(inds == i)[0] min...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'authenticate'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
def authenticate(self, request, remote_user=None): if not remote_user: remote_user = request if not remote_user: return None user = None username = self.clean_username(remote_user) try: if self.create_unknown_user: defaults = {}...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'bc2pg'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10', '11', '12']}; {'id': '4', 'type': 'identi...
def bc2pg(dataset, db_url, table, schema, query, append, pagesize, sortby, max_workers): src = bcdata.validate_name(dataset) src_schema, src_table = [i.lower() for i in src.split(".")] if not schema: schema = src_schema if not table: table = src_table conn = pgdata.connect(db_url) ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__parseFormat'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [...
def __parseFormat(self, fmt, content, fps = 25): '''Actual parser. Please note that time_to is not required to process as not all subtitles provide it.''' headerFound = False subSection = '' for lineNo, line in enumerate(content): line = self._initialLinePrepare(line,...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_json'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15']}; {'id': '4', 'type': 'identifier', 'chil...
def _get_json(self, model, space=None, rel_path=None, extra_params=None, get_all=None): if space is None and model not in (Space, Event): raise Exception( 'In general, `API._get_json` should always ' 'be called with a `space` argument.' ) if not ex...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_config'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
def load_config(app_name, *args, **kwargs): configure_logging() prefix = kwargs.get('prefix', 'etc') verbose = kwargs.get('verbose', False) location = kwargs.get('location', None) passphrase = kwargs.get('passphrase', os.getenv("%s_SETTINGS_CRYPT_KEY" % app_name.upper(), os.geten...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'predict'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
def predict(tree, x, y=[], dist=False): node_id = 1 while 1: nodes = tree[node_id] if nodes[0][5] == "c": if x[nodes[0][1]] <= nodes[0][2]: index, node_id = 0, nodes[0][0] else: index, node_id = 1, nodes[1][0] else: if x...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pay_with_account_credit_cards'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'childr...
def pay_with_account_credit_cards(invoice_id) -> Optional[Transaction]: logger.debug('invoice-payment-started', invoice_id=invoice_id) with transaction.atomic(): invoice = Invoice.objects.select_for_update().get(pk=invoice_id) if not invoice.in_payable_state: raise PreconditionError(...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'handle_django_settings'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
def handle_django_settings(filename): '''Attempts to load a Django project and get package dependencies from settings. Tested using Django 1.4 and 1.8. Not sure if some nuances are missed in the other versions. ''' old_sys_path = sys.path[:] dirpath = os.path.dirname(filename) project = ...