sequence stringlengths 492 15.9k | code stringlengths 75 8.58k |
|---|---|
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_raw_counts; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 14; 5, 20; 5, 351; 5, 378; 5, 405; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:words; 9, list:[]; 10, expression_statement; 10, 11; 1... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:compute_similarity_score; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:unit1; 6, identifier:unit2; 7, block; 7, 8; 7, 380; 8, if_statement; 8, 9; 8, 14; 8, 224; 9, comparison_operator:==; 9, 10; 9, 13; 10, attribute; 10, 1... | 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)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:compute_pairwise_similarity_score; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 14; 5, 93; 5, 107; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:pairs; 9, list:[]; 10, expression_statement; 10, 11... | 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)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:compute_between_collection_interval_duration; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:prefix; 6, block; 6, 7; 6, 11; 6, 43; 6, 73; 6, 95; 6, 117; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:dura... | 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[... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:compute_within_collection_vowel_duration; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:prefix; 6, default_parameter; 6, 7; 6, 8; 7, identifier:no_singletons; 8, False; 9, block; 9, 10; 9, 27; 9, 31; 9, 87; 9, 109; 10, if_s... | 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:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:print_output; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 32; 5, 181; 6, if_statement; 6, 7; 6, 12; 7, comparison_operator:==; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:response_format; 11, strin... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:sort_by; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:fieldName; 6, default_parameter; 6, 7; 6, 8; 7, identifier:reverse; 8, False; 9, block; 9, 10; 9, 12; 10, expression_statement; 10, 11; 11, string:'''
sort_... | 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 ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_qtls_from_rqtl_data; 3, parameters; 3, 4; 3, 5; 4, identifier:matrix; 5, identifier:lod_threshold; 6, block; 6, 7; 6, 18; 6, 28; 6, 189; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:t_matrix; 10, call; 10, 11; 10... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:response; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:code; 5, default_parameter; 5, 6; 5, 7; 6, identifier:body; 7, string:''; 8, default_parameter; 8, 9; 8, 10; 9, identifier:etag; 10, None; 11, default_parameter; 11,... | 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)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:plot_optimum_prediction_fraction_correct_cutoffs_over_range; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 3, 14; 4, identifier:self; 5, identifier:analysis_set; 6, identifier:min_stability_classication_x_cutoff; 7, identifier:max_stabil... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_chain_details_by_related_pdb_chains; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:pdb_id; 6, identifier:chain_id; 7, identifier:pfam_accs; 8, block; 8, 9; 8, 11; 8, 17; 8, 23; 8, 31; 8, 49; 8, 53; 8, 57; 8, 122; ... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:recall_service; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:service; 6, block; 6, 7; 6, 20; 6, 41; 6, 211; 7, if_statement; 7, 8; 7, 14; 8, not_operator; 8, 9; 9, call; 9, 10; 9, 11; 10, identifier:isinstance; 11, argument_list... | 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):
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:sorted_items; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:d; 5, default_parameter; 5, 6; 5, 7; 6, identifier:key; 7, identifier:__identity; 8, default_parameter; 8, 9; 8, 10; 9, identifier:reverse; 10, False; 11, block; 11, 12; 11, 24; 12, ... | 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) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 22; 2, function_name:get_or_create_in_transaction; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 4, identifier:tsession; 5, identifier:model; 6, identifier:values; 7, default_parameter; 7, 8; 7, 9; 8, identifier:missing_columns; 9, list:[]; 10... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:errors; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:instance; 6, block; 6, 7; 7, if_statement; 7, 8; 7, 13; 7, 21; 7, 82; 7, 181; 8, call; 8, 9; 8, 10; 9, identifier:isinstance; 10, argument_list; 10, 11; 10, 12; 11, identifier... | 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(... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:multimatch; 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:origin; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:rel; 10, None; 11, default_parameter; 11, 1... | 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 ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:get_qtls_from_mapqtl_data; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:matrix; 5, identifier:threshold; 6, identifier:inputfile; 7, block; 7, 8; 7, 27; 7, 31; 7, 35; 7, 136; 7, 167; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11;... | 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):
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:merge_range_pairs; 3, parameters; 3, 4; 4, identifier:prs; 5, block; 5, 6; 5, 8; 5, 12; 5, 23; 5, 30; 5, 34; 5, 38; 5, 144; 6, expression_statement; 6, 7; 7, string:'''Takes in a list of pairs specifying ranges and returns a sorted list of merg... | 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])
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 29; 2, function_name:create; 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:agent_cls; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:n_agents; 10, integer:1... | 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 ({}"
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:callproc; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:procname; 6, default_parameter; 6, 7; 6, 8; 7, identifier:parameters; 8, tuple; 9, default_parameter; 9, 10; 9, 11; 10, identifier:quiet; 11, False; 12, ... | 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]... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:create_insert_dict_string; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 4, identifier:self; 5, identifier:tblname; 6, identifier:d; 7, default_parameter; 7, 8; 7, 9; 8, identifier:PKfields; 9, list:[]; 10, default_parameter; 10, 11; 10... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:fixed_point; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:is_zero; 5, identifier:plus; 6, identifier:minus; 7, identifier:f; 8, identifier:x; 9, block; 9, 10; 9, 55; 10, decorated_definition; 10, 11; 10, 13; 11, decorator; 11, 12;... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:connections_from_graph; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:env; 5, identifier:G; 6, default_parameter; 6, 7; 6, 8; 7, identifier:edge_data; 8, False; 9, block; 9, 10; 9, 29; 9, 42; 9, 53; 9, 84; 9, 91; 9, 97; 9, 105; 10, if_statemen... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:graph_from_connections; 3, parameters; 3, 4; 3, 5; 4, identifier:env; 5, default_parameter; 5, 6; 5, 7; 6, identifier:directed; 7, False; 8, block; 8, 9; 8, 20; 8, 31; 8, 83; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, i... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:profile; 3, parameters; 3, 4; 3, 5; 4, identifier:request; 5, default_parameter; 5, 6; 5, 7; 6, identifier:status; 7, integer:200; 8, block; 8, 9; 9, if_statement; 9, 10; 9, 15; 9, 149; 9, 301; 10, comparison_operator:==; 10, 11; 10, 14; 11, at... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:get_session_identifiers; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:cls; 5, default_parameter; 5, 6; 5, 7; 6, identifier:folder; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:inputfile; 10, None; 11, block; 11, 12; 11, 16; 11, ... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:template2regex; 3, parameters; 3, 4; 3, 5; 4, identifier:template; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ranges; 7, None; 8, block; 8, 9; 8, 45; 8, 54; 8, 58; 8, 62; 8, 79; 8, 83; 8, 87; 8, 92; 8, 96; 8, 100; 8, 104; 8, 310; 8, 322; 8... | 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
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:path; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:target; 6, identifier:args; 7, identifier:kw; 8, block; 8, 9; 9, if_statement; 9, 10; 9, 16; 9, 93; 9, 132; 10, comparison_operator:in; 10, 11; 10, 15; 11, call; 11,... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:get_children_graph; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:item_ids; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:language; 10, None; 11, default_parameter; 11, ... | 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')
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_parents_graph; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:item_ids; 6, default_parameter; 6, 7; 6, 8; 7, identifier:language; 8, None; 9, block; 9, 10; 9, 101; 9, 112; 10, function_definition; 10, 11; 10, 12; 10, 14;... | 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 =... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_graph; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:item_ids; 6, default_parameter; 6, 7; 6, 8; 7, identifier:language; 8, None; 9, block; 9, 10; 9, 114; 10, function_definition; 10, 11; 10, 12; 10, 14; 11, function_na... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:translate_item_ids; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:item_ids; 6, identifier:language; 7, default_parameter; 7, 8; 7, 9; 8, identifier:is_nested; 9, None; 10, block; 10, 11; 10, 43; 10, 53; 10, 72; 10, 7... | 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
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:get_leaves; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:item_ids; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:language; 10, None; 11, default_parameter; 11, 12; 11, ... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:get_image; 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:imgtype; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:tags; 10, None; 11, default_parameter; 11, ... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:query; 3, parameters; 3, 4; 3, 5; 4, identifier:logfile; 5, default_parameter; 5, 6; 5, 7; 6, identifier:jobID; 7, None; 8, block; 8, 9; 8, 17; 8, 47; 8, 70; 8, 76; 8, 82; 8, 86; 8, 114; 8, 129; 8, 142; 9, expression_statement; 9, 10; 10, assig... | 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 = ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:build; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:client; 5, identifier:repository_tag; 6, identifier:docker_file; 7, default_parameter; 7, 8; 7, 9; 8, identifier:tag; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identi... | 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("... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:create_class; 3, parameters; 3, 4; 4, identifier:request; 5, block; 5, 6; 5, 25; 6, if_statement; 6, 7; 6, 12; 7, comparison_operator:==; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:request; 10, identifier:method; 11, string:'GET'; 12... | 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, {
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:create_student; 3, parameters; 3, 4; 4, identifier:request; 5, block; 5, 6; 5, 43; 5, 62; 6, if_statement; 6, 7; 6, 16; 7, not_operator; 7, 8; 8, call; 8, 9; 8, 10; 9, identifier:get_config; 10, argument_list; 10, 11; 10, 12; 10, 13; 11, string... | 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_... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 80; 2, function_name:lograptor; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 3, 35; 3, 38; 3, 41; 3, 44; 3, 47; 3, 50; 3, 53; 3, 56; 3, 59; 3, 62; 3, 65; 3, 68; 3, 71; 3, 74; 3, 77; 4, identifier:files; 5, default_parame... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sanitize_codon_list; 3, parameters; 3, 4; 3, 5; 4, identifier:codon_list; 5, default_parameter; 5, 6; 5, 7; 6, identifier:forbidden_seqs; 7, tuple; 8, block; 8, 9; 8, 31; 8, 37; 8, 53; 8, 68; 8, 89; 8, 102; 8, 106; 8, 122; 9, for_statement; 9, ... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:add_node; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:node; 6, block; 6, 7; 6, 15; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:nodes; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, ide... | 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):
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:get_concepts_to_recalculate; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:users; 6, identifier:lang; 7, default_parameter; 7, 8; 7, 9; 8, identifier:concepts; 9, None; 10, block; 10, 11; 10, 15; 10, 32; 10, 41; 10, ... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:recalculate_concepts; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:concepts; 6, default_parameter; 6, 7; 6, 8; 7, identifier:lang; 8, None; 9, block; 9, 10; 9, 19; 9, 71; 9, 77; 9, 83; 10, if_statement; 10, 11; 10, 17; 11,... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:get_user_stats; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, identifier:users; 6, default_parameter; 6, 7; 6, 8; 7, identifier:lang; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:concepts; 11, None;... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:execute; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:self; 5, identifier:sql; 6, default_parameter; 6, 7; 6, 8; 7, identifier:parameters; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:cursorClass; 11... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:create_tasks; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 8; 3, 11; 4, identifier:task_coro; 5, identifier:addrs; 6, list_splat_pattern; 6, 7; 7, identifier:args; 8, default_parameter; 8, 9; 8, 10; 9, identifier:flatten; 10, True; 11, dictionary_splat... | 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... |
0, module; 0, 1; 1, ERROR; 1, 2; 1, 204; 2, function_definition; 2, 3; 2, 4; 2, 21; 3, function_name:write; 4, parameters; 4, 5; 4, 6; 4, 9; 4, 12; 4, 15; 4, 18; 5, identifier:models; 6, default_parameter; 6, 7; 6, 8; 7, identifier:out; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:base; 11, None; 12, def... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:register_extensions; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, try_statement; 6, 7; 6, 159; 7, block; 7, 8; 8, for_statement; 8, 9; 8, 12; 8, 21; 9, pattern_list; 9, 10; 9, 11; 10, identifier:extension; 11, identifier:config; ... | 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)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:request; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 4, identifier:self; 5, identifier:method; 6, identifier:path; 7, default_parameter; 7, 8; 7, 9; 8, identifier:query; 9, dictionary; 10, default_parameter; 10, 11; 10, 12; 11,... | 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
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:fix_pdb; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 14; 5, 20; 5, 50; 6, expression_statement; 6, 7; 7, string:'''A function to fix fatal errors in PDB files when they can be automatically fixed. At present, this only run... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:stripForDDG; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:chains; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:keepHETATM; 10, False; 11, default_parameter; 11,... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:neighbors2; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:self; 5, identifier:distance; 6, identifier:chain_residue; 7, default_parameter; 7, 8; 7, 9; 8, identifier:atom; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identi... | 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:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 26; 2, function_name:add_document; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 4, identifier:self; 5, identifier:item_uri; 6, identifier:name; 7, identifier:metadata; 8, default_parameter; 8, 9; 8, 10; 9, identifier:content; 10,... | 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:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:get_agents; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:addr; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:agent_cls; 10, None; 11, default_parameter; 11, 12; 11, 13;... | 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.
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:tee; 3, parameters; 3, 4; 3, 6; 4, list_splat_pattern; 4, 5; 5, identifier:popenargs; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 16; 8, 38; 8, 46; 8, 73; 8, 167; 8, 181; 8, 195; 9, import_statement; 9, 10; 9, 12... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:dump_object; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:obj; 6, block; 6, 7; 6, 21; 6, 34; 6, 56; 7, if_statement; 7, 8; 7, 15; 8, call; 8, 9; 8, 10; 9, identifier:isinstance; 10, argument_list; 10, 11; 10, 12; 11, identifier:... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:normalize_datum; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:datum; 6, block; 6, 7; 6, 14; 6, 25; 6, 41; 6, 55; 6, 70; 6, 85; 6, 96; 6, 120; 6, 156; 7, if_statement; 7, 8; 7, 11; 8, comparison_operator:is; 8, 9; 8, 10; 9, ident... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:redirect; 3, parameters; 3, 4; 3, 5; 4, identifier:endpoint; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kw; 7, block; 7, 8; 7, 12; 7, 128; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:_endpoint; 11, None; 12,... | 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 '... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_search; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:query; 6, identifier:search_term; 7, block; 7, 8; 7, 16; 7, 24; 7, 33; 7, 80; 7, 329; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:criteri... | 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:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:replace_seqres; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:pdb; 6, default_parameter; 6, 7; 6, 8; 7, identifier:update_atoms; 8, True; 9, block; 9, 10; 9, 16; 9, 20; 9, 42; 9, 46; 9, 143; 9, 261; 9, 275; 10, expression_s... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:enrich_json_objects_by_object_type; 3, parameters; 3, 4; 3, 5; 4, identifier:request; 5, identifier:value; 6, block; 6, 7; 6, 13; 6, 62; 6, 74; 6, 212; 6, 228; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:time_start_... | 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()
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:change_parent; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:sender; 5, identifier:instance; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 17; 8, 131; 8, 258; 9, if_statement; 9, 10; 9, 15; 10, comparison_operator... | 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 ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:bin_atoms; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 26; 5, 44; 5, 60; 5, 90; 5, 94; 5, 162; 5, 231; 5, 299; 5, 303; 5, 359; 6, expression_statement; 6, 7; 7, string:'''This function bins the Atoms into fixed-size sectio... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:attr_name; 6, list_splat_pattern; 6, 7; 7, identifier:args; 8, block; 8, 9; 8, 24; 8, 39; 8, 43; 8, 52; 8, 109; 9, if_statement; 9, 10; 9, 18; 10, not_operator; 10, 11; 11,... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_load_yml_config; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:config_file; 6, block; 6, 7; 6, 22; 7, if_statement; 7, 8; 7, 16; 8, not_operator; 8, 9; 9, call; 9, 10; 9, 11; 10, identifier:isinstance; 11, argument_list; 11, 12;... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_create_attr; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:property_key; 6, identifier:data; 7, identifier:ancestors; 8, block; 8, 9; 8, 32; 8, 53; 8, 57; 8, 70; 8, 74; 8, 159; 9, if_statement; 9, 10; 9, 18; 10, not_... | 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 ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_collect_unrecognized_values; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:scheme; 6, identifier:data; 7, identifier:ancestors; 8, block; 8, 9; 8, 30; 8, 51; 8, 55; 8, 184; 9, if_statement; 9, 10; 9, 16; 10, not_oper... | 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. ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_update_scheme; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:scheme; 6, identifier:ancestors; 7, block; 7, 8; 7, 29; 7, 50; 7, 59; 7, 74; 7, 78; 7, 221; 7, 228; 8, if_statement; 8, 9; 8, 15; 9, not_operator; 9, 10; 10, cal... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:_walk_tree; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 4, identifier:self; 5, identifier:data; 6, identifier:scheme; 7, default_parameter; 7, 8; 7, 9; 8, identifier:ancestors; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, ident... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:__execute_validations; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 12; 4, identifier:self; 5, identifier:validations; 6, identifier:data; 7, identifier:property_name; 8, identifier:ancestors; 9, default_parameter; 9, 10; 9, 11; 10, i... | 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):
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:users_feature; 3, parameters; 3, 4; 4, identifier:app; 5, block; 5, 6; 5, 25; 5, 33; 5, 40; 5, 47; 5, 53; 5, 59; 5, 76; 5, 83; 5, 90; 5, 98; 5, 136; 5, 143; 5, 184; 6, if_statement; 6, 7; 6, 17; 7, not_operator; 7, 8; 8, call; 8, 9; 8, 14; 9, a... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:match; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:other; 6, block; 6, 7; 6, 9; 6, 16; 7, expression_statement; 7, 8; 8, string:''' This is a noisy terminal-printing function at present since there is no need to make it a prope... | 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 = {}
... |
0, ERROR; 0, 1; 0, 2; 0, 7; 0, 9; 0, 15; 0, 19; 0, 26; 0, 33; 0, 36; 0, 37; 0, 40; 0, 46; 0, 48; 0, 49; 0, 50; 0, 51; 0, 54; 0, 55; 0, 56; 0, 57; 0, 60; 0, 61; 0, 62; 0, 63; 0, 69; 0, 72; 0, 82; 0, 86; 0, 91; 0, 101; 0, 116; 0, 126; 0, 131; 0, 171; 0, 179; 0, 211; 0, 214; 0, 215; 0, 219; 0, 222; 0, 223; 0, 226; 0, 227;... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:apply_quality_control_checks; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:seq; 5, default_parameter; 5, 6; 5, 7; 6, identifier:check_gen9_seqs; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:check_short_length; 10, ... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:oauth_connect; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:provider; 6, identifier:action; 7, block; 7, 8; 7, 15; 7, 32; 7, 69; 7, 77; 7, 83; 7, 92; 7, 101; 7, 105; 7, 109; 7, 113; 7, 152; 7, 259; 7, 387; 7, 398; 8, expre... | 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") \
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:set_neighbors; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 16; 5, 25; 5, 29; 5, 186; 5, 195; 5, 206; 5, 210; 5, 237; 5, 246; 5, 266; 5, 284; 5, 298; 6, expression_statement; 6, 7; 7, string:'''Set neighbors for multi-envir... | 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 ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:vectors; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:direction; 7, string:"all"; 8, default_parameter; 8, 9; 8, 10; 9, identifier:failed; 10, False; 11, block; 11, 12; 11, 32; 11, 50; 12... | 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]:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:transmissions; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:direction; 7, string:"outgoing"; 8, default_parameter; 8, 9; 8, 10; 9, identifier:status; 10, string:"all"; 11, default_... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:user_stats; 3, parameters; 3, 4; 4, identifier:request; 5, block; 5, 6; 5, 11; 5, 15; 5, 19; 5, 44; 5, 61; 5, 80; 5, 86; 5, 102; 5, 109; 5, 116; 5, 136; 5, 148; 5, 164; 5, 174; 5, 184; 5, 250; 5, 362; 6, expression_statement; 6, 7; 7, call; 7, ... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:create_resource; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 4, identifier:output_model; 5, identifier:rtype; 6, identifier:unique; 7, identifier:links; 8, default_parameter; 8, 9; 8, 10; 9, identifier:existing_ids; 10, None; 11, defau... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:patterns; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 52; 5, 58; 5, 90; 5, 101; 5, 109; 5, 125; 6, if_statement; 6, 7; 6, 20; 7, boolean_operator:and; 7, 8; 7, 14; 8, not_operator; 8, 9; 9, attribute; 9, 10; 9, 13; 10, attribute... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:qualify; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:qualification; 5, identifier:value; 6, identifier:worker; 7, block; 7, 8; 7, 15; 7, 21; 7, 27; 7, 37; 7, 47; 7, 55; 7, 121; 7, 128; 7, 138; 7, 152; 7, 181; 7, 191; 7, 198; 7, 214; 7, 224; ... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:setup_jobs; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:outpath; 5, identifier:options; 6, identifier:input_files; 7, block; 7, 8; 7, 10; 7, 14; 7, 18; 7, 22; 7, 142; 7, 153; 7, 161; 7, 169; 7, 173; 7, 209; 7, 220; 7, 255; 7, 286; 7, 301; 7,... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:load_stdlib; 3, parameters; 4, block; 4, 5; 4, 7; 4, 12; 4, 49; 4, 74; 4, 96; 4, 105; 4, 192; 5, expression_statement; 5, 6; 6, string:'''Scans sys.path for standard library modules.
'''; 7, if_statement; 7, 8; 7, 9; 8, identifier:_stdlib; ... | 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:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:is_python_script; 3, parameters; 3, 4; 4, identifier:filename; 5, block; 5, 6; 5, 8; 5, 22; 5, 35; 5, 78; 6, expression_statement; 6, 7; 7, string:'''Checks a file to see if it's a python script of some sort.
'''; 8, if_statement; 8, 9; 8, ... | 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'
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:fit; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:dataset; 5, default_parameter; 5, 6; 5, 7; 6, identifier:alpha; 7, float:1e-8; 8, default_parameter; 8, 9; 8, 10; 9, identifier:max_iterations; 10, integer:10; 11, default_param... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:draw_image; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, identifier:image; 6, default_parameter; 6, 7; 6, 8; 7, identifier:xmin; 8, integer:0; 9, default_parameter; 9, 10; 9, 11; 10, identifier:ymin; 11, integer:... | 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,
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_prepare_data; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 22; 5, 28; 5, 151; 5, 157; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 11; 8, pattern_list; 8, 9; 8, 10; 9, identifier:xmin; 10, identifier:xmax; 11, expressi... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_departures; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:stop_id; 6, identifier:route; 7, identifier:destination; 8, identifier:api_key; 9, block; 9, 10; 9, 16; 9, 22; 9, 28; 9, 34; 9, 49; 9, 57; 9, 67; 9, ... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:pw; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 4, identifier:ctx; 5, identifier:key_pattern; 6, identifier:user_pattern; 7, identifier:mode; 8, identifier:strict_flag; 9, identifier:user_flag; 10, identifier:file; ... | 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)... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:launch_editor; 3, parameters; 3, 4; 3, 5; 4, identifier:ctx; 5, identifier:file; 6, block; 6, 7; 6, 18; 6, 36; 6, 66; 6, 75; 6, 101; 6, 133; 6, 142; 6, 165; 6, 178; 6, 187; 6, 211; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, i... | 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)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:fit; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:sim_mat; 5, identifier:D_len; 6, identifier:cidx; 7, block; 7, 8; 7, 14; 7, 166; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:min_energy; 11, attribute; 11, 12; 1... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:authenticate; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:request; 6, default_parameter; 6, 7; 6, 8; 7, identifier:remote_user; 8, None; 9, block; 9, 10; 9, 18; 9, 24; 9, 28; 9, 37; 9, 283; 10, if_statement; 10, 11; 10, 1... | 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 = {}... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:bc2pg; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 4, identifier:dataset; 5, identifier:db_url; 6, identifier:table; 7, identifier:schema; 8, identifier:query; 9, identifier:append; 10, identifier:pagesize; 11, iden... | 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)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:__parseFormat; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:fmt; 6, identifier:content; 7, default_parameter; 7, 8; 7, 9; 8, identifier:fps; 9, integer:25; 10, block; 10, 11; 10, 13; 10, 17; 10, 21; 11, expression_s... | 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,... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:_get_json; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, identifier:model; 6, default_parameter; 6, 7; 6, 8; 7, identifier:space; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:rel_path; 11, None; 12,... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:load_config; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:app_name; 5, list_splat_pattern; 5, 6; 6, identifier:args; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 14; 9, 24; 9, 34; 9, 44; 9, 72; 9, 76; 9, 96; 9,... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:predict; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:tree; 5, identifier:x; 6, default_parameter; 6, 7; 6, 8; 7, identifier:y; 8, list:[]; 9, default_parameter; 9, 10; 9, 11; 10, identifier:dist; 11, False; 12, block; 12, 13; 12, 17; ... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 11; 2, function_name:pay_with_account_credit_cards; 3, parameters; 3, 4; 4, identifier:invoice_id; 5, type; 5, 6; 6, generic_type; 6, 7; 6, 8; 7, identifier:Optional; 8, type_parameter; 8, 9; 9, type; 9, 10; 10, identifier:Transaction; 11, block; 11, 12; 11,... | 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(... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:handle_django_settings; 3, parameters; 3, 4; 4, identifier:filename; 5, block; 5, 6; 5, 8; 5, 17; 5, 28; 5, 39; 5, 47; 5, 66; 5, 83; 5, 90; 5, 99; 5, 107; 5, 130; 5, 147; 5, 153; 5, 159; 5, 165; 5, 291; 5, 305; 5, 416; 5, 425; 5, 432; 5, 454; 6... | 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 = ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.