sequence stringlengths 492 15.9k | code stringlengths 75 8.58k |
|---|---|
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:interev_mag; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 11; 4, identifier:times; 5, identifier:mags; 6, default_parameter; 6, 7; 6, 8; 7, identifier:size; 8, tuple; 8, 9; 8, 10; 9, float:10.5; 10, float:7.5; 11, dictionary_splat_pattern; 11, 12; 12, ... | def interev_mag(times, mags, size=(10.5, 7.5), **kwargs):
import matplotlib.pyplot as plt
info = [(times[i], mags[i]) for i in range(len(times))]
info.sort(key=lambda tup: tup[0])
times = [x[0] for x in info]
mags = [x[1] for x in info]
fig, axes = plt.subplots(1, 2, sharey=True, figsize=size)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:pprint_blockers; 3, parameters; 3, 4; 4, identifier:blockers; 5, block; 5, 6; 5, 10; 5, 86; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:pprinted; 9, list:[]; 10, for_statement; 10, 11; 10, 12; 10, 28; 11, identifier:... | def pprint_blockers(blockers):
pprinted = []
for blocker in sorted(blockers, key=lambda x: tuple(reversed(x))):
buf = [blocker[0]]
if len(blocker) > 1:
buf.append(' (which is blocking ')
buf.append(', which is blocking '.join(blocker[1:]))
buf.append(')')
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:get_document_summary; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:N; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:cite_sort; 10, True; 11, default_parameter; 11, 12; ... | def get_document_summary(self, N=None, cite_sort=True, refresh=True):
abstracts = self.get_abstracts(refresh=refresh)
if cite_sort:
counts = [(a, int(a.citedby_count)) for a in abstracts]
counts.sort(reverse=True, key=itemgetter(1))
abstracts = [a[0] for a in counts]
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_match_version_string; 3, parameters; 3, 4; 4, identifier:version; 5, block; 5, 6; 5, 15; 5, 23; 5, 39; 5, 74; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:matched; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12... | def _match_version_string(version):
matched = _VERSION_STRING_REGEX.match(version)
g = matched.groups()
major, minor, micro = g[0], g[2], g[4]
if major and minor and micro:
major, minor, micro = int(major), int(minor), int(micro)
else:
raise GnuPGVersionError("Could not parse GnuPG v... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:generate_help; 3, parameters; 4, block; 4, 5; 4, 9; 4, 19; 4, 57; 5, expression_statement; 5, 6; 6, assignment; 6, 7; 6, 8; 7, identifier:help_text; 8, string:'\nAvailable recipes:\n\n'; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 1... | def generate_help():
help_text = '\nAvailable recipes:\n\n'
recipes = config.Config.get_registered_recipes()
for contents, _, _ in sorted(recipes, key=lambda k: k[0]['name']):
help_text += ' {0:<35s}{1:s}\n'.format(
contents['name'], contents.get('short_description', 'No description'))
return help_t... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 22; 2, function_name:write_to_csv; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:filename; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:extension; 10, string:'.dat'; 11... | def write_to_csv(self, filename=None, extension='.dat', overwrite=False,
stride=1, chunksize=None, **kw):
import os
if not filename:
assert hasattr(self, 'filenames')
filenames = []
for f in self.filenames:
base, _ = os.path.splite... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:add_distances; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:indices; 6, default_parameter; 6, 7; 6, 8; 7, identifier:periodic; 8, True; 9, default_parameter; 9, 10; 9, 11; 10, identifier:indices2; 11, None; 12, bloc... | def add_distances(self, indices, periodic=True, indices2=None):
r
from .distances import DistanceFeature
atom_pairs = _parse_pairwise_input(
indices, indices2, self.logger, fname='add_distances()')
atom_pairs = self._check_indices(atom_pairs)
f = DistanceFeature(self.... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:add_inverse_distances; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:indices; 6, default_parameter; 6, 7; 6, 8; 7, identifier:periodic; 8, True; 9, default_parameter; 9, 10; 9, 11; 10, identifier:indices2; 11, None; ... | def add_inverse_distances(self, indices, periodic=True, indices2=None):
from .distances import InverseDistanceFeature
atom_pairs = _parse_pairwise_input(
indices, indices2, self.logger, fname='add_inverse_distances()')
atom_pairs = self._check_indices(atom_pairs)
f = InverseD... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:add_contacts; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, identifier:indices; 6, default_parameter; 6, 7; 6, 8; 7, identifier:indices2; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:threshold; 11, ... | def add_contacts(self, indices, indices2=None, threshold=0.3, periodic=True, count_contacts=False):
r
from .distances import ContactFeature
atom_pairs = _parse_pairwise_input(
indices, indices2, self.logger, fname='add_contacts()')
atom_pairs = self._check_indices(atom_pairs)... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:spd_eig; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:W; 5, default_parameter; 5, 6; 5, 7; 6, identifier:epsilon; 7, float:1e-10; 8, default_parameter; 8, 9; 8, 10; 9, identifier:method; 10, string:'QR'; 11, default_parameter; 11, 12;... | def spd_eig(W, epsilon=1e-10, method='QR', canonical_signs=False):
assert _np.allclose(W.T, W), 'W is not a symmetric matrix'
if method.lower() == 'qr':
from .eig_qr.eig_qr import eig_qr
s, V = eig_qr(W)
elif method.lower() == 'schur':
from scipy.linalg import schur
S, V = sc... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:eig_corr; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:C0; 5, identifier:Ct; 6, default_parameter; 6, 7; 6, 8; 7, identifier:epsilon; 8, float:1e-10; 9, default_parameter; 9, 10; 9, 11; 10, identifier:method; 11, string:'QR'; 12... | def eig_corr(C0, Ct, epsilon=1e-10, method='QR', sign_maxelement=False):
r
L = spd_inv_split(C0, epsilon=epsilon, method=method, canonical_signs=True)
Ct_trans = _np.dot(_np.dot(L.T, Ct), L)
if _np.allclose(Ct.T, Ct):
from scipy.linalg import eigh
l, R_trans = eigh(Ct_trans)
else:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:sortino_ratio; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:threshold; 7, float:0.0; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ddof; 10, integer:0; 11, default_parameter; 11... | def sortino_ratio(self, threshold=0.0, ddof=0, freq=None):
stdev = self.semi_stdev(threshold=threshold, ddof=ddof, freq=freq)
return (self.anlzd_ret() - threshold) / stdev |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:sort; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:columnId; 6, default_parameter; 6, 7; 6, 8; 7, identifier:order; 8, attribute; 8, 9; 8, 10; 9, identifier:Qt; 10, identifier:AscendingOrder; 11, block; 11, 12; 11, 20; 11... | def sort(self, columnId, order=Qt.AscendingOrder):
self.layoutAboutToBeChanged.emit()
self.sortingAboutToStart.emit()
column = self._dataFrame.columns[columnId]
self._dataFrame.sort_values(column, ascending=not bool(order), inplace=True)
self.layoutChanged.emit()
self.sor... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:run; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:clf; 6, block; 6, 7; 6, 17; 6, 29; 6, 44; 6, 60; 6, 72; 6, 83; 6, 91; 6, 95; 6, 151; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:rank; 10, call; 10, ... | def run(self, clf):
rank = MPI.COMM_WORLD.Get_rank()
if rank == 0:
logger.info(
'running activity-based voxel selection via Searchlight'
)
self.sl.distribute([self.data], self.mask)
self.sl.broadcast((self.labels, self.num_folds, clf))
if r... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:run; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:clf; 6, block; 6, 7; 6, 17; 6, 62; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:rank; 10, call; 10, 11; 10, 16; 11, attribute; 11, 12; 11, 15; 12, att... | def run(self, clf):
rank = MPI.COMM_WORLD.Get_rank()
if rank == self.master_rank:
results = self._master()
results.sort(key=lambda tup: tup[1], reverse=True)
else:
self._worker(clf)
results = []
return results |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:sort; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:column_or_label; 6, default_parameter; 6, 7; 6, 8; 7, identifier:descending; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:distinct; 11, False; 12, b... | def sort(self, column_or_label, descending=False, distinct=False):
column = self._get_column(column_or_label)
if distinct:
_, row_numbers = np.unique(column, return_index=True)
else:
row_numbers = np.argsort(column, axis=0, kind='mergesort')
assert (row_numbers < ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_sub_expand; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:tags; 6, block; 6, 7; 6, 11; 6, 20; 6, 89; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:entities; 10, dictionary; 11, expression_statement; 11... | def _sub_expand(self, tags):
entities = {}
graph = self._build_graph(tags)
for tag in tags:
for entity_index in xrange(len(tag.get('entities'))):
node_name = graph_key_from_tag(tag, entity_index)
if not node_name in entities:
entiti... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 1, 22; 2, function_name:_rank_results; 3, parameters; 3, 4; 3, 12; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:results; 6, type; 6, 7; 7, generic_type; 7, 8; 7, 9; 8, identifier:List; 9, type_parameter; 9, 10; 10, type; 10, 11; 11, identifier:Dict; 12, typed... | def _rank_results(results: List[Dict], method: SimAlgorithm) -> List[Dict]:
sorted_results = sorted(
results, reverse=True, key=lambda k: k[OwlSim2Api.method2key[method]]
)
if len(sorted_results) > 0:
rank = 1
previous_score = sorted_results[0][OwlSim2Api.meth... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sorted_source_files; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 11; 5, 15; 5, 52; 6, assert_statement; 6, 7; 6, 10; 7, attribute; 7, 8; 7, 9; 8, identifier:self; 9, identifier:final; 10, string:'Call build() before using the gr... | def sorted_source_files(self):
assert self.final, 'Call build() before using the graph.'
out = []
for node in nx.topological_sort(self.graph):
if isinstance(node, NodeSet):
out.append(node.nodes)
else:
out.append([node])
return list... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:expand_source_files; 3, parameters; 3, 4; 3, 5; 4, identifier:filenames; 5, default_parameter; 5, 6; 5, 7; 6, identifier:cwd; 7, None; 8, block; 8, 9; 8, 13; 8, 56; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:... | def expand_source_files(filenames, cwd=None):
out = []
for f in expand_paths(filenames, cwd):
if os.path.isdir(f):
out += collect_files(f, ".py")
else:
if f.endswith(".py"):
out.append(f)
return sorted(set(out)) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:run; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 12; 5, 33; 5, 39; 5, 45; 5, 51; 5, 58; 5, 78; 5, 99; 5, 119; 5, 133; 5, 162; 5, 181; 5, 199; 5, 224; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:query;... | def run(self):
query = self.query
self.cardinality = query.add_columns(self.columns[0].sqla_expr).count()
self._set_column_filter_expressions()
self._set_global_filter_expression()
self._set_sort_expressions()
self._set_yadcf_data(query)
query = query.filter(
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:poll_events; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, while_statement; 6, 7; 6, 10; 7, attribute; 7, 8; 7, 9; 8, identifier:self; 9, identifier:started; 10, block; 10, 11; 10, 15; 10, 19; 10, 54; 10, 83; 10, 98; 11, expressio... | def poll_events(self):
while self.started:
event_obj = None
event_name = None
try:
event_obj = self._sl4a.eventWait(50000)
except:
if self.started:
print("Exception happened during polling.")
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:pop_events; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:regex_pattern; 6, identifier:timeout; 7, block; 7, 8; 7, 19; 7, 29; 7, 65; 7, 86; 8, if_statement; 8, 9; 8, 13; 9, not_operator; 9, 10; 10, attribute; 10, 11; 10, 12... | def pop_events(self, regex_pattern, timeout):
if not self.started:
raise IllegalStateError(
"Dispatcher needs to be started before popping.")
deadline = time.time() + timeout
while True:
results = self._match_and_pop(regex_pattern)
if len(resul... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:children; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, return_statement; 6, 7; 7, call; 7, 8; 7, 9; 8, identifier:pvector; 9, argument_list; 9, 10; 10, call; 10, 11; 10, 12; 11, identifier:sorted; 12, argument_list; 12, 13; 12, 2... | def children(self):
return pvector(
sorted(self._children.values(), key=lambda m: m.task_level)) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_get_last_child_with_lineno; 3, parameters; 3, 4; 4, identifier:node; 5, block; 5, 6; 5, 17; 5, 23; 5, 41; 5, 93; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:ignored_fields; 9, call; 9, 10; 9, 11; 10, identifier:set;... | def _get_last_child_with_lineno(node):
ignored_fields = set(['ctx', 'decorator_list', 'names', 'returns'])
fields = node._fields
if isinstance(node, ast.Call):
fields = ('func', 'args', 'starargs', 'keywords', 'kwargs')
for name in reversed(fields):
if name in ignored_fields:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_patched_ast; 3, parameters; 3, 4; 3, 5; 4, identifier:source; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sorted_children; 7, False; 8, block; 8, 9; 9, return_statement; 9, 10; 10, call; 10, 11; 10, 12; 11, identifier:patch_ast; 12, arg... | def get_patched_ast(source, sorted_children=False):
return patch_ast(ast.parse(source), source, sorted_children) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:patch_ast; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:node; 5, identifier:source; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sorted_children; 8, False; 9, block; 9, 10; 9, 19; 9, 29; 9, 37; 10, if_statement; 10, 11; 10, 16; 11, call; 1... | def patch_ast(node, source, sorted_children=False):
if hasattr(node, 'region'):
return node
walker = _PatchingASTWalker(source, children=sorted_children)
ast.call_for_nodes(node, walker)
return node |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:write_ast; 3, parameters; 3, 4; 4, identifier:patched_ast_node; 5, block; 5, 6; 5, 10; 5, 44; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:result; 9, list:[]; 10, for_statement; 10, 11; 10, 12; 10, 15; 11, identifier:... | def write_ast(patched_ast_node):
result = []
for child in patched_ast_node.sorted_children:
if isinstance(child, ast.AST):
result.append(write_ast(child))
else:
result.append(child)
return ''.join(result) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:sorted_proposals; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:proposals; 5, default_parameter; 5, 6; 5, 7; 6, identifier:scopepref; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:typepref; 10, None; 11, block; 11, 12; 11, 21; 12,... | def sorted_proposals(proposals, scopepref=None, typepref=None):
sorter = _ProposalSorter(proposals, scopepref, typepref)
return sorter.get_sorted_proposal_list() |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_sorted_proposal_list; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 31; 5, 35; 5, 85; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:proposals; 9, dictionary; 10, for_statement; 10, 11; 10, 12; ... | def get_sorted_proposal_list(self):
proposals = {}
for proposal in self.proposals:
proposals.setdefault(proposal.scope, []).append(proposal)
result = []
for scope in self.scopepref:
scope_proposals = proposals.get(scope, [])
scope_proposals = [proposal... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:get_rank; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:entity; 6, identifier:criteria; 7, default_parameter; 7, 8; 7, 9; 8, identifier:condition; 9, True; 10, block; 10, 11; 10, 25; 10, 31; 10, 42; 10, 55; 10, 61; 1... | def get_rank(self, entity, criteria, condition = True):
entity = entity if not isinstance(entity, Projector) else entity.reference_entity
positions = entity.members_position
biggest_entity_size = np.max(positions) + 1
filtered_criteria = np.where(condition, criteria, np.inf)
ids ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:value_nth_person; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:n; 6, identifier:array; 7, default_parameter; 7, 8; 7, 9; 8, identifier:default; 9, integer:0; 10, block; 10, 11; 10, 20; 10, 26; 10, 34; 10, 40; 10, 54... | def value_nth_person(self, n, array, default = 0):
self.members.check_array_compatible_with_entity(array)
positions = self.members_position
nb_persons_per_entity = self.nb_persons()
members_map = self.ordered_members_map
result = self.filled_array(default, dtype = array.dtype)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:create_query_index; 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:design_document_id; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:index_name; 10, None; 1... | def create_query_index(
self,
design_document_id=None,
index_name=None,
index_type='json',
partitioned=False,
**kwargs
):
if index_type == JSON_INDEX_TYPE:
index = Index(self, design_document_id, index_name,
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_search_result; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:ddoc_id; 6, identifier:index_name; 7, dictionary_splat_pattern; 7, 8; 8, identifier:query_params; 9, block; 9, 10; 9, 18; 10, expression_statement; 10, ... | def get_search_result(self, ddoc_id, index_name, **query_params):
ddoc = DesignDocument(self, ddoc_id)
return self._get_search_result(
'/'.join((ddoc.document_url, '_search', index_name)),
**query_params
) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:predict_log_proba; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:X; 6, block; 6, 7; 6, 16; 6, 26; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:jll; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, ... | def predict_log_proba(self, X):
jll = self._joint_log_likelihood(X)
log_prob_x = logsumexp(jll, axis=1)
return jll - np.atleast_2d(log_prob_x).T |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_get_sorting_key_values; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:array1; 6, identifier:array2; 7, block; 7, 8; 7, 19; 7, 28; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:concat_arrays; 11... | def _get_sorting_key_values(self, array1, array2):
concat_arrays = numpy.concatenate([array1, array2])
unique_values = numpy.unique(concat_arrays)
return numpy.sort(unique_values) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:sortedneighbourhood; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:args; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 20; 9, 27; 10, expression_statement; 10, 11;... | def sortedneighbourhood(self, *args, **kwargs):
indexer = SortedNeighbourhood(*args, **kwargs)
self.add(indexer)
return self |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_build_bst_from_sorted_values; 3, parameters; 3, 4; 4, identifier:sorted_values; 5, block; 5, 6; 5, 16; 5, 25; 5, 34; 5, 47; 5, 62; 6, if_statement; 6, 7; 6, 13; 7, comparison_operator:==; 7, 8; 7, 12; 8, call; 8, 9; 8, 10; 9, identifier:len; 1... | def _build_bst_from_sorted_values(sorted_values):
if len(sorted_values) == 0:
return None
mid_index = len(sorted_values) // 2
root = Node(sorted_values[mid_index])
root.left = _build_bst_from_sorted_values(sorted_values[:mid_index])
root.right = _build_bst_from_sorted_values(sorted_values[mi... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:holm; 3, parameters; 3, 4; 3, 5; 4, identifier:pvals; 5, default_parameter; 5, 6; 5, 7; 6, identifier:alpha; 7, float:.05; 8, block; 8, 9; 8, 18; 8, 24; 8, 32; 8, 45; 8, 54; 8, 60; 8, 68; 8, 76; 8, 98; 8, 109; 8, 120; 8, 138; 8, 149; 8, 171; 9,... | def holm(pvals, alpha=.05):
pvals = np.asarray(pvals)
shape_init = pvals.shape
pvals = pvals.ravel()
num_nan = np.isnan(pvals).sum()
pvals_sortind = np.argsort(pvals)
pvals_sorted = pvals[pvals_sortind]
sortrevind = pvals_sortind.argsort()
ntests = pvals.size - num_nan
pvals_corr = n... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_reverse_chronologically; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 13; 8, attribute; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, identifier:measurements;... | def sort_reverse_chronologically(self):
self.measurements.sort(key=lambda m: m.timestamp, reverse=True) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sorted_dependencies; 3, parameters; 3, 4; 3, 5; 4, identifier:dist; 5, default_parameter; 5, 6; 5, 7; 6, identifier:reverse; 7, False; 8, block; 8, 9; 8, 14; 8, 19; 8, 24; 8, 28; 8, 33; 8, 107; 8, 113; 8, 119; 8, 191; 8, 205; 8, 219; 9, import_... | def sorted_dependencies(dist, reverse=False):
from .. import baseclass
collection = [dist]
nodes = [dist]
edges = []
pool = [dist]
while pool:
dist = pool.pop()
for key in sorted(dist.prm):
value = dist.prm[key]
if not isinstance(value, baseclass.Dist):
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:orth_ttr; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:order; 5, identifier:dist; 6, default_parameter; 6, 7; 6, 8; 7, identifier:normed; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:sort; 11, strin... | def orth_ttr(
order, dist, normed=False, sort="GR", retall=False,
cross_truncation=1., **kws):
polynomials, norms, _, _ = chaospy.quad.generate_stieltjes(
dist=dist, order=numpy.max(order), retall=True, **kws)
if normed:
for idx, poly in enumerate(polynomials):
polyno... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:orth_chol; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:order; 5, identifier:dist; 6, default_parameter; 6, 7; 6, 8; 7, identifier:normed; 8, True; 9, default_parameter; 9, 10; 9, 11; 10, identifier:sort; 11, string:"GR";... | def orth_chol(order, dist, normed=True, sort="GR", cross_truncation=1., **kws):
dim = len(dist)
basis = chaospy.poly.basis(
start=1, stop=order, dim=dim, sort=sort,
cross_truncation=cross_truncation,
)
length = len(basis)
cholmat = chaospy.chol.gill_king(chaospy.descriptives.Cov(basi... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_key; 3, parameters; 3, 4; 4, identifier:val; 5, block; 5, 6; 6, return_statement; 6, 7; 7, call; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:numpy; 10, identifier:sum; 11, argument_list; 11, 12; 12, binary_operator:*; 12, 13; 12,... | def sort_key(val):
return numpy.sum((max(val)+1)**numpy.arange(len(val)-1, -1, -1)*val) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:orth_gs; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:order; 5, identifier:dist; 6, default_parameter; 6, 7; 6, 8; 7, identifier:normed; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:sort; 11, string:"GR"; ... | def orth_gs(order, dist, normed=False, sort="GR", cross_truncation=1., **kws):
logger = logging.getLogger(__name__)
dim = len(dist)
if isinstance(order, int):
if order == 0:
return chaospy.poly.Poly(1, dim=dim)
basis = chaospy.poly.basis(
0, order, dim, sort, cross_tr... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:basis; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:start; 5, default_parameter; 5, 6; 5, 7; 6, identifier:stop; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:dim; 10, integer:1; 11, default_parameter; 11, 12; 11, 1... | def basis(start, stop=None, dim=1, sort="G", cross_truncation=1.):
if stop is None:
start, stop = numpy.array(0), start
start = numpy.array(start, dtype=int)
stop = numpy.array(stop, dtype=int)
dim = max(start.size, stop.size, dim)
indices = numpy.array(chaospy.bertran.bindex(
numpy.... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:sorted; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:key; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:reverse; 10, False; 11, block; 11, 12; 12, return_statement; 12, 13; 13... | def sorted(self, key=None, reverse=False):
return self._transform(transformations.sorted_t(key=key, reverse=reverse)) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:GetCredentials; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 4, identifier:package_name; 5, identifier:scopes; 6, identifier:client_id; 7, identifier:client_secret; 8, identifier:user_agent; 9, default_paramet... | def GetCredentials(package_name, scopes, client_id, client_secret, user_agent,
credentials_filename=None,
api_key=None,
client=None,
oauth2client_args=None,
**kwds):
scopes = util.NormalizeScopes(scopes)
client_info =... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:get_sorted_graph; 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:start; 7, integer:0; 8, default_parameter; 8, 9; 8, 10; 9, identifier:stop; 10, integer:100; 11, defaul... | def get_sorted_graph(
self,
start=0,
stop=100,
slices=100,
include_inf=False,
exact=False):
if not self.is_sorted:
raise Exception("Not a sorted queue")
with context.connections.redis.pipeline(transaction=exact) as pipe:... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:get_threads; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:querystring; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sort; 8, string:'newest_first'; 9, default_parameter; 9, 10; 9, 11; 10, identifier:exclude_tags;... | def get_threads(self, querystring, sort='newest_first', exclude_tags=None):
assert sort in self._sort_orders
q = self.query(querystring)
q.set_sort(self._sort_orders[sort])
if exclude_tags:
for tag in exclude_tags:
q.exclude_tag(tag)
return self.async_... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:nd_sort_samples; 3, parameters; 3, 4; 4, identifier:samples; 5, block; 5, 6; 5, 15; 5, 22; 5, 41; 6, assert_statement; 6, 7; 7, comparison_operator:==; 7, 8; 7, 14; 8, call; 8, 9; 8, 10; 9, identifier:len; 10, argument_list; 10, 11; 11, attribu... | def nd_sort_samples(samples):
assert len(samples.shape) == 2
tree = cKDTree(samples)
d, i = tree.query(samples[0], k=len(samples))
return i |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:GetVolumeIdentifiers; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:volume_system; 6, block; 6, 7; 6, 11; 6, 36; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:volume_identifiers; 10, list:[]; 11, for_st... | def GetVolumeIdentifiers(self, volume_system):
volume_identifiers = []
for volume in volume_system.volumes:
volume_identifier = getattr(volume, 'identifier', None)
if volume_identifier:
volume_identifiers.append(volume_identifier)
return sorted(volume_identifiers) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:topological_order_dfs; 3, parameters; 3, 4; 4, identifier:graph; 5, block; 5, 6; 5, 13; 5, 17; 5, 25; 5, 127; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:n; 9, call; 9, 10; 9, 11; 10, identifier:len; 11, argument_lis... | def topological_order_dfs(graph):
n = len(graph)
order = []
times_seen = [-1] * n
for start in range(n):
if times_seen[start] == -1:
times_seen[start] = 0
to_visit = [start]
while to_visit:
node = to_visit[-1]
children = graph[n... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:topological_order; 3, parameters; 3, 4; 4, identifier:graph; 5, block; 5, 6; 5, 16; 5, 24; 5, 40; 5, 54; 5, 58; 5, 102; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:V; 9, call; 9, 10; 9, 11; 10, identifier:range; 11, ... | def topological_order(graph):
V = range(len(graph))
indeg = [0 for _ in V]
for node in V:
for neighbor in graph[node]:
indeg[neighbor] += 1
Q = [node for node in V if indeg[node] == 0]
order = []
while Q:
node = Q.pop()
order.append(node)
for neighbor ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:interval_tree; 3, parameters; 3, 4; 4, identifier:intervals; 5, block; 5, 6; 5, 13; 5, 26; 5, 30; 5, 34; 5, 38; 5, 79; 5, 93; 5, 107; 5, 114; 5, 121; 6, if_statement; 6, 7; 6, 10; 7, comparison_operator:==; 7, 8; 7, 9; 8, identifier:intervals; ... | def interval_tree(intervals):
if intervals == []:
return None
center = intervals[len(intervals) // 2][0]
L = []
R = []
C = []
for I in intervals:
if I[1] <= center:
L.append(I)
elif center < I[0]:
R.append(I)
else:
C.append(I)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_type; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:name; 6, block; 6, 7; 6, 18; 7, if_statement; 7, 8; 7, 15; 8, comparison_operator:==; 8, 9; 8, 14; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:name;... | def get_type(self, name):
if name.lower() == 'hiddenservices':
return FilesystemOnionService
return type(self.parsers[name]) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 25; 2, function_name:schwarz; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 4, identifier:A; 5, identifier:x; 6, identifier:b; 7, default_parameter; 7, 8; 7, 9; 8, identifier:iterations; 9, integer:1; 10, default_parameter; 10, 11; 10, ... | def schwarz(A, x, b, iterations=1, subdomain=None, subdomain_ptr=None,
inv_subblock=None, inv_subblock_ptr=None, sweep='forward'):
A, x, b = make_system(A, x, b, formats=['csr'])
A.sort_indices()
if subdomain is None and inv_subblock is not None:
raise ValueError("inv_subblock must be No... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:get_stdlib_path; 3, parameters; 4, block; 4, 5; 5, if_statement; 5, 6; 5, 13; 5, 25; 6, comparison_operator:>=; 6, 7; 6, 10; 7, attribute; 7, 8; 7, 9; 8, identifier:sys; 9, identifier:version_info; 10, tuple; 10, 11; 10, 12; 11, integer:2; 12, ... | def get_stdlib_path():
if sys.version_info >= (2, 7):
import sysconfig
return sysconfig.get_paths()['stdlib']
else:
return os.path.join(sys.prefix, 'lib') |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:exists_case_sensitive; 3, parameters; 3, 4; 4, identifier:path; 5, block; 5, 6; 5, 17; 5, 53; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:result; 9, call; 9, 10; 9, 15; 10, attribute; 10, 11; 10, 14; 11, attribute; 1... | def exists_case_sensitive(path):
result = os.path.exists(path)
if sys.platform.startswith('win') and result:
directory, basename = os.path.split(path)
result = basename in os.listdir(directory)
return result |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 1, 14; 2, function_name:_add_comments; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:comments; 6, default_parameter; 6, 7; 6, 8; 7, identifier:original_string; 8, string:""; 9, ERROR; 9, 10; 10, return_statement; 10, 11; 11, boolean_operato... | def _add_comments(self, comments, original_string=""):
return comments and "{0}
"; ".join(comments)) or original_string |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_priority_key; 3, parameters; 3, 4; 4, identifier:pep8_result; 5, block; 5, 6; 5, 16; 5, 20; 5, 25; 5, 35; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:priority; 9, list:[
'e701',
'e702',
'e225... | def _priority_key(pep8_result):
priority = [
'e701',
'e702',
'e225', 'e231',
'e201',
'e262'
]
middle_index = 10000
lowest_priority = [
'e501'
]
key = pep8_result['id'].lower()
try:
return priority.index(key)
except ValueError:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:git_hook; 3, parameters; 3, 4; 4, default_parameter; 4, 5; 4, 6; 5, identifier:strict; 6, False; 7, block; 7, 8; 7, 12; 7, 19; 7, 23; 7, 76; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:diff_cmd; 11, string:"git di... | def git_hook(strict=False):
diff_cmd = "git diff-index --cached --name-only --diff-filter=ACMRTUXB HEAD"
files_modified = get_lines(diff_cmd)
errors = 0
for filename in files_modified:
if filename.endswith('.py'):
staged_cmd = "git show :%s" % filename
staged_contents = g... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_all_fix_names; 3, parameters; 3, 4; 3, 5; 4, identifier:fixer_pkg; 5, default_parameter; 5, 6; 5, 7; 6, identifier:remove_prefix; 7, True; 8, block; 8, 9; 8, 20; 8, 33; 8, 37; 8, 87; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 1... | def get_all_fix_names(fixer_pkg, remove_prefix=True):
pkg = __import__(fixer_pkg, [], [], ["*"])
fixer_dir = os.path.dirname(pkg.__file__)
fix_names = []
for name in sorted(os.listdir(fixer_dir)):
if name.startswith("fix_") and name.endswith(".py"):
if remove_prefix:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:check; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, for_statement; 6, 7; 6, 8; 6, 40; 7, identifier:unsorted; 8, call; 8, 9; 8, 10; 9, identifier:iter; 10, generator_expression; 10, 11; 10, 14; 10, 25; 11, subscript; 11, 12; 11, ... | def check(self):
for unsorted in iter(self[i] for i in range(len(self) - 2) if not operator.le(self[i], self[i + 1])):
self.resort(unsorted) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:sort_by_list_order; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:sortlist; 5, identifier:reflist; 6, default_parameter; 6, 7; 6, 8; 7, identifier:reverse; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:fltr; 11, Fa... | def sort_by_list_order(sortlist, reflist, reverse=False, fltr=False,
slemap=None):
def keyfunc(entry):
if slemap is not None:
rle = slemap(entry)
if rle in reflist:
return reflist.index(rle)
else:
return sortlist.index(entry) + len(r... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:strategy; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:names; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 71; 10, function_definition; 10, 11; 10, 12; 10, 14; 1... | def strategy(self, *names, **kwargs):
def decorator(func):
keep_name = kwargs.pop("keep_name", False)
if kwargs:
key = next(iter(kwargs))
raise TypeError("Unknown keyword argument '{}'".format(key))
if not keep_name:
func.__name__ = str(names[0])
self[names] = func
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:humansort; 3, parameters; 3, 4; 4, identifier:l; 5, block; 5, 6; 5, 9; 5, 48; 5, 57; 6, import_statement; 6, 7; 7, dotted_name; 7, 8; 8, identifier:re; 9, function_definition; 9, 10; 9, 11; 9, 13; 10, function_name:alphanum_key; 11, parameters;... | def humansort(l):
import re
def alphanum_key(s):
def tryint(s):
if s.isdigit():
return int(s)
return s
return [tryint(c) for c in re.split("([0-9]+)", s)]
l.sort(key=alphanum_key)
return None |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 27; 2, function_name:add; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 25; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:name; 7, string:''; 8, default_parameter; 8, 9; 8, 10; 9, identifier:type; 10, string:''; 11, d... | def add(self, name='', type='', agent='', scanner='', location='', language='en', *args, **kwargs):
part = '/library/sections?name=%s&type=%s&agent=%s&scanner=%s&language=%s&location=%s' % (
quote_plus(name), type, agent, quote_plus(scanner), language, quote_plus(location))
if kwargs:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:all; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort; 7, None; 8, dictionary_splat_pattern; 8, 9; 9, identifier:kwargs; 10, block; 10, 11; 10, 15; 10, 26; 10, 36; 11, expression_stateme... | def all(self, sort=None, **kwargs):
sortStr = ''
if sort is not None:
sortStr = '?sort=' + sort
key = '/library/sections/%s/all%s' % (self.key, sortStr)
return self.fetchItems(key, **kwargs) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:as_sorted_list; 3, parameters; 3, 4; 4, identifier:options; 5, block; 5, 6; 5, 29; 6, if_statement; 6, 7; 6, 13; 7, comparison_operator:>; 7, 8; 7, 12; 8, call; 8, 9; 8, 10; 9, identifier:len; 10, argument_list; 10, 11; 11, identifier:options; ... | def as_sorted_list(options):
if len(options) > 0:
options = sorted(options, key=lambda o: o.number)
return options |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:df_all; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:phot; 6, block; 6, 7; 6, 30; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:df; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifi... | def df_all(self, phot):
df = pd.concat([self.to_df(f) for f in self.get_filenames(phot)])
return df |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:searchsorted; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:arr; 5, identifier:N; 6, identifier:x; 7, block; 7, 8; 7, 12; 7, 18; 7, 22; 7, 31; 7, 90; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:L; 11, integer:0; ... | def searchsorted(arr, N, x):
L = 0
R = N-1
done = False
m = (L+R)//2
while not done:
if arr[m] < x:
L = m + 1
elif arr[m] > x:
R = m - 1
elif arr[m] == x:
done = True
m = (L+R)//2
if L>R:
done = True
return L |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_plot_spectrogram; 3, parameters; 3, 4; 3, 5; 4, identifier:G; 5, identifier:node_idx; 6, block; 6, 7; 6, 9; 6, 14; 6, 23; 6, 38; 6, 48; 6, 65; 6, 74; 6, 90; 6, 104; 6, 133; 6, 147; 6, 157; 6, 174; 6, 182; 6, 201; 6, 218; 6, 235; 6, 241; 6, 302... | def _plot_spectrogram(G, node_idx):
r
from pygsp import features
qtg, _, _ = _import_qtg()
if not hasattr(G, 'spectr'):
features.compute_spectrogram(G)
M = G.spectr.shape[1]
spectr = G.spectr[node_idx, :] if node_idx is not None else G.spectr
spectr = np.ravel(spectr)
min_spec, m... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:write_omega_scan_config; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:channellist; 5, identifier:fobj; 6, default_parameter; 6, 7; 6, 8; 7, identifier:header; 8, True; 9, block; 9, 10; 9, 35; 10, if_statement; 10, 11; 10, 16; 10, 21; 11, call... | def write_omega_scan_config(channellist, fobj, header=True):
if isinstance(fobj, FILE_LIKE):
close = False
else:
fobj = open(fobj, 'w')
close = True
try:
if header:
print('
print('
group = None
for channel in channellist:
if... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:coalesce; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 22; 5, 28; 5, 35; 5, 153; 5, 159; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:sort; 11, argument_list; ... | def coalesce(self):
self.sort(key=lambda ts: ts.t0.value)
i = j = 0
N = len(self)
while j < N:
this = self[j]
j += 1
if j < N and this.is_contiguous(self[j]) == 1:
while j < N and this.is_contiguous(self[j]):
try:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:read_cache; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:cachefile; 5, default_parameter; 5, 6; 5, 7; 6, identifier:coltype; 7, identifier:LIGOTimeGPS; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sort; 10, None; 11, default_param... | def read_cache(cachefile, coltype=LIGOTimeGPS, sort=None, segment=None):
if not isinstance(cachefile, FILE_LIKE):
with open(file_path(cachefile), 'r') as fobj:
return read_cache(fobj, coltype=coltype, sort=sort,
segment=segment)
cache = [x.path for x in _iter_ca... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_learned_skills; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:lang; 6, block; 6, 7; 6, 23; 6, 30; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:skills; 10, list_comprehension; 10, 11; 10, 12; 11, id... | def get_learned_skills(self, lang):
skills = [skill for skill in
self.user_data.language_data[lang]['skills']]
self._compute_dependency_order(skills)
return [skill for skill in
sorted(skills, key=lambda skill: skill['dependency_order'])
if skill[... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:combine_adjacent_lines; 3, parameters; 3, 4; 4, identifier:line_numbers; 5, block; 5, 6; 5, 10; 5, 14; 5, 21; 5, 27; 5, 31; 5, 92; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:combine_template; 9, string:"{0}-{1}"; 10... | def combine_adjacent_lines(line_numbers):
combine_template = "{0}-{1}"
combined_list = []
line_numbers.append(None)
start = line_numbers[0]
end = None
for line_number in line_numbers[1:]:
if (end if end else start) + 1 == line_number:
end = lin... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_menus; 3, parameters; 3, 4; 4, identifier:c; 5, block; 5, 6; 6, for_statement; 6, 7; 6, 8; 6, 11; 7, identifier:name; 8, attribute; 8, 9; 8, 10; 9, identifier:c; 10, identifier:items; 11, block; 11, 12; 12, if_statement; 12, 13; 12, 19; 13... | def sort_menus(c):
for name in c.items:
if not c.sorted[name]:
c.items[name].sort(key=lambda x: x.weight)
c.sorted[name] = True |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_frequency_order_transform; 3, parameters; 3, 4; 4, identifier:sets; 5, block; 5, 6; 5, 13; 5, 33; 5, 52; 5, 71; 5, 78; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:logging; 10, identifier:debug;... | def _frequency_order_transform(sets):
logging.debug("Applying frequency order transform on tokens...")
counts = reversed(Counter(token for s in sets for token in s).most_common())
order = dict((token, i) for i, (token, _) in enumerate(counts))
sets = [np.sort([order[token] for token in s]) for s in sets... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:to_numpy_vectors; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 13; 3, 18; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:variable_order; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:dtype; 10, attribute; 10, 11; 10, 12... | def to_numpy_vectors(self, variable_order=None, dtype=np.float, index_dtype=np.int64, sort_indices=False):
linear = self.linear
quadratic = self.quadratic
num_variables = len(linear)
num_interactions = len(quadratic)
irow = np.empty(num_interactions, dtype=index_dtype)
ic... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:from_samples_bqm; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:cls; 5, identifier:samples_like; 6, identifier:bqm; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 17; 9, 26; 10, expression_statement; 10, 11;... | def from_samples_bqm(cls, samples_like, bqm, **kwargs):
samples_like = as_samples(samples_like)
energies = bqm.energies(samples_like)
return cls.from_samples(samples_like, energy=energies, vartype=bqm.vartype, **kwargs) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:samples; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:n; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sorted_by; 10, string:'energy'; 11, block; 11, 12; 11, 30; 11, 68; 12, i... | def samples(self, n=None, sorted_by='energy'):
if n is not None:
return self.samples(sorted_by=sorted_by)[:n]
if sorted_by is None:
samples = self.record.sample
else:
order = np.argsort(self.record[sorted_by])
samples = self.record.sample[order]
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:append_variables; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:samples_like; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sort_labels; 8, True; 9, block; 9, 10; 9, 19; 9, 26; 9, 75; 9, 81; 9, 101; 9, 110; 9, 125; 10, ex... | def append_variables(self, samples_like, sort_labels=True):
samples, labels = as_samples(samples_like)
num_samples = len(self)
if samples.shape[0] == num_samples:
pass
elif samples.shape[0] == 1 and num_samples:
samples = np.repeat(samples, num_samples, axis=0)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:slice; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:slice_args; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 20; 9, 41; 9, 61; 9, 99; 10, expression_statement; 1... | def slice(self, *slice_args, **kwargs):
sorted_by = kwargs.pop('sorted_by', 'energy')
if kwargs:
raise TypeError('slice got an unexpected '
'keyword argument {!r}'.format(kwargs.popitem()[0]))
if slice_args:
selector = slice(*slice_args)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:describe_features; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:traj; 6, block; 6, 7; 6, 20; 6, 58; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:n_f; 10, subscript; 10, 11; 10, 19; 11, attribute; 11, ... | def describe_features(self, traj):
n_f = self.partial_transform(traj).shape[1]
zippy=zip(itertools.repeat("N/A", n_f),
itertools.repeat("N/A", n_f),
itertools.repeat("N/A", n_f),
itertools.repeat(("N/A","N/A","N/A","N/A"), n_f))
return dict_m... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_mapped_populations; 3, parameters; 3, 4; 3, 5; 4, identifier:mdl1; 5, identifier:mdl2; 6, block; 6, 7; 6, 18; 6, 64; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:return_vect; 10, call; 10, 11; 10, 14; 11, attribute;... | def _mapped_populations(mdl1, mdl2):
return_vect = np.zeros(mdl1.n_states_)
for i in range(mdl1.n_states_):
try:
mdl1_unmapped = mdl1.inverse_transform([i])[0][0]
mdl2_mapped = mdl2.mapping_[mdl1_unmapped]
return_vect[i] = mdl2.populations_[mdl2_mapped]
excep... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:query; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:x; 6, default_parameter; 6, 7; 6, 8; 7, identifier:k; 8, integer:1; 9, default_parameter; 9, 10; 9, 11; 10, identifier:p; 11, integer:2; 12, default_paramet... | def query(self, x, k=1, p=2, distance_upper_bound=np.inf):
cdists, cinds = self._kdtree.query(x, k, p, distance_upper_bound)
return cdists, self._split_indices(cinds) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_fn_list; 3, parameters; 3, 4; 4, identifier:fn_list; 5, block; 5, 6; 5, 13; 5, 30; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:dt_list; 9, call; 9, 10; 9, 11; 10, identifier:get_dt_list; 11, argument_list; 11, 1... | def sort_fn_list(fn_list):
dt_list = get_dt_list(fn_list)
fn_list_sort = [fn for (dt,fn) in sorted(zip(dt_list,fn_list))]
return fn_list_sort |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort; 3, parameters; 3, 4; 4, identifier:iterable; 5, block; 5, 6; 5, 19; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:ips; 9, call; 9, 10; 9, 11; 10, identifier:sorted; 11, generator_expression; 11, 12; 11, 16; 12, c... | def sort(iterable):
ips = sorted(normalize_ip(ip) for ip in iterable)
return [clean_ip(ip) for ip in ips] |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:glob; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 25; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:file_glob; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:glob; 12, identifier:g... | def glob(self):
file_glob = glob.glob(BASE_NAME.format('*', self.num, '*', '.*'))
return sorted(file_glob, key=lambda f: os.path.splitext(f)) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:event; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:interface_id; 6, identifier:address; 7, identifier:value_key; 8, identifier:value; 9, block; 9, 10; 9, 30; 9, 57; 9, 84; 10, expression_statement; 10, 11; 11,... | def event(self, interface_id, address, value_key, value):
LOG.debug("RPCFunctions.event: interface_id = %s, address = %s, value_key = %s, value = %s" % (
interface_id, address, value_key.upper(), str(value)))
self.devices_all[interface_id.split(
'-')[-1]][address].event(interface... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:get_isolated_cpus; 3, parameters; 4, block; 4, 5; 4, 12; 4, 19; 4, 27; 4, 37; 4, 67; 5, expression_statement; 5, 6; 6, assignment; 6, 7; 6, 8; 7, identifier:path; 8, call; 8, 9; 8, 10; 9, identifier:sysfs_path; 10, argument_list; 10, 11; 11, st... | def get_isolated_cpus():
path = sysfs_path('devices/system/cpu/isolated')
isolated = read_first_line(path)
if isolated:
return parse_cpu_list(isolated)
cmdline = read_first_line(proc_path('cmdline'))
if cmdline:
match = re.search(r'\bisolcpus=([^ ]+)', cmdline)
if match:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:framesToFrameRange; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:frames; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:zfill; 10, integer:0; 11, default_parameter; 11, ... | def framesToFrameRange(frames, sort=True, zfill=0, compress=False):
if compress:
frames = unique(set(), frames)
frames = list(frames)
if not frames:
return ''
if len(frames) == 1:
return pad(frames[0], zfill)
if sort:
frames.sort()
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_normalize_request_parameters; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:oauth_params; 6, identifier:req_kwargs; 7, block; 7, 8; 7, 10; 7, 14; 7, 24; 7, 34; 7, 44; 7, 66; 7, 95; 7, 99; 7, 138; 7, 163; 7, 169; 8, express... | def _normalize_request_parameters(self, oauth_params, req_kwargs):
'''
This process normalizes the request parameters as detailed in the OAuth
1.0 spec.
Additionally we apply a `Content-Type` header to the request of the
`FORM_URLENCODE` type if the `Content-Type` was previously ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:do_summary; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:params; 6, block; 6, 7; 6, 33; 6, 49; 6, 130; 6, 148; 7, expression_statement; 7, 8; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, identifier:... | def do_summary(self, params):
self.show_output("%s%s%s%s",
"Created".ljust(32),
"Last modified".ljust(32),
"Owner".ljust(23),
"Name")
results = sorted(self._zk.stat_map(params.path))
if params.top... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:do_json_count_values; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:params; 6, block; 6, 7; 6, 37; 6, 49; 6, 56; 6, 130; 6, 154; 6, 170; 6, 251; 6, 272; 6, 297; 7, try_statement; 7, 8; 7, 18; 8, block; 8, 9; 9, expression_stateme... | def do_json_count_values(self, params):
try:
Keys.validate(params.keys)
except Keys.Bad as ex:
self.show_output(str(ex))
return
path_map = PathMap(self._zk, params.path)
values = defaultdict(int)
for path, data in path_map.get():
tr... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:do_json_dupes_for_keys; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:params; 6, block; 6, 7; 6, 37; 6, 49; 6, 60; 6, 160; 6, 164; 6, 233; 6, 244; 7, try_statement; 7, 8; 7, 18; 8, block; 8, 9; 9, expression_statement; 9, 10; 10,... | def do_json_dupes_for_keys(self, params):
try:
Keys.validate(params.keys)
except Keys.Bad as ex:
self.show_output(str(ex))
return
path_map = PathMap(self._zk, params.path)
dupes_by_path = defaultdict(lambda: defaultdict(list))
for path, data in... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:add_property_orders; 3, parameters; 3, 4; 3, 5; 4, identifier:query_proto; 5, list_splat_pattern; 5, 6; 6, identifier:orders; 7, block; 7, 8; 8, for_statement; 8, 9; 8, 10; 8, 11; 9, identifier:order; 10, identifier:orders; 11, block; 11, 12; 1... | def add_property_orders(query_proto, *orders):
for order in orders:
proto = query_proto.order.add()
if order[0] == '-':
order = order[1:]
proto.direction = query_pb2.PropertyOrder.DESCENDING
else:
proto.direction = query_pb2.PropertyOrder.ASCENDING
proto.property.name = order |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:check_levels; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:imls; 5, identifier:imt; 6, default_parameter; 6, 7; 6, 8; 7, identifier:min_iml; 8, float:1E-10; 9, block; 9, 10; 10, if_statement; 10, 11; 10, 17; 10, 27; 10, 44; 10, 67; 10, 92; 11... | def check_levels(imls, imt, min_iml=1E-10):
if len(imls) < 1:
raise ValueError('No imls for %s: %s' % (imt, imls))
elif imls != sorted(imls):
raise ValueError('The imls for %s are not sorted: %s' % (imt, imls))
elif len(distinct(imls)) < len(imls):
raise ValueError("Found duplicated ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.