sequence stringlengths 492 15.9k | code stringlengths 75 8.58k |
|---|---|
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:text_search; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:text; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sort; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:offset; 11, integer:100; 12, d... | def text_search(self, text, sort=None, offset=100, page=1):
assert page >= 1, f'Invalid page value {page}. Required page >= 1.'
payload = {"text": text, "sort": sort, "offset": offset, "page": page}
response = self.requests_session.get(
f'{self.url}/query',
params=payload... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:query_search; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:search_query; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sort; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:offset; 11, integer:1... | def query_search(self, search_query, sort=None, offset=100, page=1):
assert page >= 1, f'Invalid page value {page}. Required page >= 1.'
search_query['sort'] = sort
search_query['offset'] = offset
search_query['page'] = page
response = self.requests_session.post(
f'{s... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:trunk_angles; 3, parameters; 3, 4; 3, 5; 4, identifier:nrn; 5, default_parameter; 5, 6; 5, 7; 6, identifier:neurite_type; 7, attribute; 7, 8; 7, 9; 8, identifier:NeuriteType; 9, identifier:all; 10, block; 10, 11; 10, 13; 10, 23; 10, 31; 10, 74... | def trunk_angles(nrn, neurite_type=NeuriteType.all):
'''Calculates the angles between all the trunks of the neuron.
The angles are defined on the x-y plane and the trees
are sorted from the y axis and anticlock-wise.
'''
vectors = trunk_vectors(nrn, neurite_type=neurite_type)
if not vectors.size... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:resolve_symbols; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:tree; 6, identifier:database; 7, identifier:link_resolver; 8, block; 8, 9; 8, 19; 8, 25; 8, 51; 8, 82; 8, 108; 8, 138; 8, 150; 8, 161; 9, expression_state... | def resolve_symbols(self, tree, database, link_resolver):
self.typed_symbols = self.__get_empty_typed_symbols()
all_syms = OrderedSet()
for sym_name in self.symbol_names:
sym = database.get_symbol(sym_name)
self.__query_extra_symbols(
sym, all_syms, tree, ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_klass_parents; 3, parameters; 3, 4; 4, identifier:gi_name; 5, block; 5, 6; 5, 8; 5, 12; 5, 21; 5, 27; 5, 35; 6, expression_statement; 6, 7; 7, string:'''
Returns a sorted list of qualified symbols representing
the parents of the kla... | def get_klass_parents(gi_name):
'''
Returns a sorted list of qualified symbols representing
the parents of the klass-like symbol named gi_name
'''
res = []
parents = __HIERARCHY_GRAPH.predecessors(gi_name)
if not parents:
return []
__get_parent_link_recurse(parents[0], res)
r... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sorted_groupby; 3, parameters; 3, 4; 3, 5; 4, identifier:df; 5, identifier:groupby; 6, block; 6, 7; 6, 11; 6, 21; 6, 57; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:start; 10, integer:0; 11, expression_statement; 11... | def sorted_groupby(df, groupby):
start = 0
prev = df[groupby].iloc[start]
for i, x in enumerate(df[groupby]):
if x != prev:
yield prev, df.iloc[start:i]
prev = x
start = i
yield prev, df.iloc[start:] |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:add_note; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:note; 6, default_parameter; 6, 7; 6, 8; 7, identifier:octave; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:dynamics; 11, dictionary; 12, block; 1... | def add_note(self, note, octave=None, dynamics={}):
if type(note) == str:
if octave is not None:
note = Note(note, octave, dynamics)
elif len(self.notes) == 0:
note = Note(note, 4, dynamics)
else:
if Note(note, self.notes[-1].oc... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 1, 18; 2, function_name:_sort_row_col; 3, parameters; 3, 4; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:qubits; 6, type; 6, 7; 7, generic_type; 7, 8; 7, 9; 8, identifier:Iterator; 9, type_parameter; 9, 10; 10, type; 10, 11; 11, identifier:GridQubit; 12, type... | def _sort_row_col(qubits: Iterator[GridQubit]) -> List[GridQubit]:
return sorted(qubits, key=lambda x: (x.row, x.col)) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_cmp_bystrlen_reverse; 3, parameters; 3, 4; 3, 5; 4, identifier:a; 5, identifier:b; 6, block; 6, 7; 7, if_statement; 7, 8; 7, 17; 7, 21; 7, 34; 8, comparison_operator:>; 8, 9; 8, 13; 9, call; 9, 10; 9, 11; 10, identifier:len; 11, argument_list;... | def _cmp_bystrlen_reverse(a, b):
if len(a) > len(b):
return -1
elif len(a) < len(b):
return 1
else:
return 0 |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:prof_main; 3, parameters; 3, 4; 4, identifier:main; 5, block; 5, 6; 5, 179; 6, decorated_definition; 6, 7; 6, 12; 7, decorator; 7, 8; 8, call; 8, 9; 8, 10; 9, identifier:wraps; 10, argument_list; 10, 11; 11, identifier:main; 12, function_defini... | def prof_main(main):
@wraps(main)
def wrapper(*args, **kwargs):
import sys
try:
do_prof = sys.argv[1] == "prof"
if do_prof: sys.argv.pop(1)
except Exception:
do_prof = False
if not do_prof:
sys.exit(main())
else:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_least_constraining_values_sorter; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:problem; 5, identifier:assignment; 6, identifier:variable; 7, identifier:domains; 8, block; 8, 9; 8, 11; 8, 31; 8, 55; 9, expression_statement; 9, 10; 10, s... | def _least_constraining_values_sorter(problem, assignment, variable, domains):
'''
Sort values based on how many conflicts they generate if assigned.
'''
def update_assignment(value):
new_assignment = deepcopy(assignment)
new_assignment[variable] = value
return new_assignment
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:reading_order; 3, parameters; 3, 4; 3, 5; 4, identifier:e1; 5, identifier:e2; 6, block; 6, 7; 6, 13; 6, 19; 6, 58; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:b1; 10, attribute; 10, 11; 10, 12; 11, identifier:e1; 12... | def reading_order(e1, e2):
b1 = e1.bbox
b2 = e2.bbox
if round(b1[y0]) == round(b2[y0]) or round(b1[y1]) == round(b2[y1]):
return float_cmp(b1[x0], b2[x0])
return float_cmp(b1[y0], b2[y0]) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:xy_reading_order; 3, parameters; 3, 4; 3, 5; 4, identifier:e1; 5, identifier:e2; 6, block; 6, 7; 6, 13; 6, 19; 6, 44; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:b1; 10, attribute; 10, 11; 10, 12; 11, identifier:e1;... | def xy_reading_order(e1, e2):
b1 = e1.bbox
b2 = e2.bbox
if round(b1[x0]) == round(b2[x0]):
return float_cmp(b1[y0], b2[y0])
return float_cmp(b1[x0], b2[x0]) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:column_order; 3, parameters; 3, 4; 3, 5; 4, identifier:b1; 5, identifier:b2; 6, block; 6, 7; 6, 17; 6, 56; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 13; 9, tuple_pattern; 9, 10; 9, 11; 9, 12; 10, identifier:top; 11, identifier:left... | def column_order(b1, b2):
(top, left, bottom) = (1, 2, 3)
if round(b1[top]) == round(b2[top]) or round(b1[bottom]) == round(b2[bottom]):
return float_cmp(b1[left], b2[left])
return float_cmp(b1[top], b2[top]) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:merge_intervals; 3, parameters; 3, 4; 3, 5; 4, identifier:elems; 5, default_parameter; 5, 6; 5, 7; 6, identifier:overlap_thres; 7, float:2.0; 8, block; 8, 9; 8, 17; 8, 32; 8, 36; 8, 44; 8, 98; 8, 105; 9, expression_statement; 9, 10; 10, assignm... | def merge_intervals(elems, overlap_thres=2.0):
overlap_thres = max(0.0, overlap_thres)
ordered = sorted(elems, key=lambda e: e.x0)
intervals = []
cur = [-overlap_thres, -overlap_thres]
for e in ordered:
if e.x0 - cur[1] > overlap_thres:
if cur[1] > 0.0:
intervals.... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:predict; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:X; 6, default_parameter; 6, 7; 6, 8; 7, identifier:cost_mat; 8, None; 9, block; 9, 10; 9, 42; 10, if_statement; 10, 11; 10, 20; 11, comparison_operator:!=; 11, 12; 11, ... | def predict(self, X, cost_mat=None):
if self.n_features_ != X.shape[1]:
raise ValueError("Number of features of the model must "
"match the input. Model n_features is {0} and "
"input n_features is {1}."
"".format... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:predict_proba; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:X; 6, block; 6, 7; 6, 39; 6, 54; 6, 131; 6, 208; 7, if_statement; 7, 8; 7, 17; 8, comparison_operator:!=; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:self; ... | def predict_proba(self, X):
if self.n_features_ != X.shape[1]:
raise ValueError("Number of features of the model must "
"match the input. Model n_features is {0} and "
"input n_features is {1}."
"".format(self.n_f... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:to_param_dict; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 56; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:param_dict; 9, dictionary; 10, for_statement; 10, 11; 10, 14; 10, 20; 11, pattern_list... | def to_param_dict(self):
param_dict = {}
for index, dictionary in enumerate(self.value):
for key, value in dictionary.items():
param_name = '{param_name}[{index}][{key}]'.format(
param_name=self.param_name,
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:datetimes; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 19; 6, if_statement; 6, 7; 6, 12; 7, comparison_operator:is; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:_timestamps_data; 11, None; 12, block... | def datetimes(self):
if self._timestamps_data is None:
self._calculate_timestamps()
return tuple(DateTime.from_moy(moy, self.is_leap_year)
for moy in self._timestamps_data) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:hoys; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 19; 6, if_statement; 6, 7; 6, 12; 7, comparison_operator:is; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:_timestamps_data; 11, None; 12, block; 12,... | def hoys(self):
if self._timestamps_data is None:
self._calculate_timestamps()
return tuple(moy / 60.0 for moy in self._timestamps_data) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:hoys_int; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 19; 6, if_statement; 6, 7; 6, 12; 7, comparison_operator:is; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:_timestamps_data; 11, None; 12, block;... | def hoys_int(self):
if self._timestamps_data is None:
self._calculate_timestamps()
return tuple(int(moy / 60.0) for moy in self._timestamps_data) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:doys_int; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, if_statement; 6, 7; 6, 11; 6, 24; 7, not_operator; 7, 8; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:_is_reversed; 11, block; 11, 12; 12, return_statement; ... | def doys_int(self):
if not self._is_reversed:
return self._calc_daystamps(self.st_time, self.end_time)
else:
doys_st = self._calc_daystamps(self.st_time, DateTime.from_hoy(8759))
doys_end = self._calc_daystamps(DateTime.from_hoy(0), self.end_time)
return d... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:months_int; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, if_statement; 6, 7; 6, 11; 6, 31; 7, not_operator; 7, 8; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:_is_reversed; 11, block; 11, 12; 12, return_statement... | def months_int(self):
if not self._is_reversed:
return list(xrange(self.st_time.month, self.end_time.month + 1))
else:
months_st = list(xrange(self.st_time.month, 13))
months_end = list(xrange(1, self.end_time.month + 1))
return months_st + months_end |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:sorted; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:field_name; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ascending; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:fields; 10, None; 11, default_parameter; 11, 12; 11,... | def sorted(field_name, ascending=True, fields=None, count=5):
if field_name is None:
raise Exception('Sort field must be specified')
direction = '' if ascending else ' DESC'
projection = Sampling._create_projection(fields)
return lambda sql: 'SELECT %s FROM (%s) ORDER BY %s%s LIMIT %d' % (projecti... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:_auto; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:method; 5, identifier:fields; 6, identifier:count; 7, identifier:percent; 8, identifier:key_field; 9, identifier:ascending; 10, block; 10, 11; 11, if_statement; 11, 12; 11... | def _auto(method, fields, count, percent, key_field, ascending):
if method == 'limit':
return Sampling.default(fields=fields, count=count)
elif method == 'random':
return Sampling.random(fields=fields, percent=percent, count=count)
elif method == 'hashed':
return Sampling.hashed(fields=fie... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:pair_SAM_alignments; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:alignments; 5, default_parameter; 5, 6; 5, 7; 6, identifier:bundle; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:primary_only; 10, False; 11, block; 11, 12; 11, ... | def pair_SAM_alignments(
alignments,
bundle=False,
primary_only=False):
'''Iterate over SAM aligments, name-sorted paired-end
Args:
alignments (iterator of SAM/BAM alignments): the alignments to wrap
bundle (bool): if True, bundle all alignments from one read pair into a
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:pair_SAM_alignments_with_buffer; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:alignments; 5, default_parameter; 5, 6; 5, 7; 6, identifier:max_buffer_size; 7, integer:30000000; 8, default_parameter; 8, 9; 8, 10; 9, identifier:primary_only; 10... | def pair_SAM_alignments_with_buffer(
alignments,
max_buffer_size=30000000,
primary_only=False):
'''Iterate over SAM aligments with buffer, position-sorted paired-end
Args:
alignments (iterator of SAM/BAM alignments): the alignments to wrap
max_buffer_size (int): maxmal nu... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:local_maxima; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:vector; 5, default_parameter; 5, 6; 5, 7; 6, identifier:min_distance; 7, integer:4; 8, default_parameter; 8, 9; 8, 10; 9, identifier:brd_mode; 10, string:"wrap"; 11, block; 11, 12; 1... | def local_maxima(vector,min_distance = 4, brd_mode = "wrap"):
fits = gaussian_filter(numpy.asarray(vector,dtype=numpy.float32),1., mode=brd_mode)
for ii in range(len(fits)):
if fits[ii] == fits[ii-1]:
fits[ii-1] = 0.0
maxfits = maximum_filter(fits, size=min_distance, mode=brd_mode)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:local_minima; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:vector; 5, default_parameter; 5, 6; 5, 7; 6, identifier:min_distance; 7, integer:4; 8, default_parameter; 8, 9; 8, 10; 9, identifier:brd_mode; 10, string:"wrap"; 11, block; 11, 12; 1... | def local_minima(vector,min_distance = 4, brd_mode = "wrap"):
fits = gaussian_filter(numpy.asarray(vector,dtype=numpy.float32),1., mode=brd_mode)
for ii in range(len(fits)):
if fits[ii] == fits[ii-1]:
fits[ii-1] = numpy.pi/2.0
minfits = minimum_filter(fits, size=min_distance, mode=brd_mo... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:find_valley_range; 3, parameters; 3, 4; 3, 5; 4, identifier:vector; 5, default_parameter; 5, 6; 5, 7; 6, identifier:min_distance; 7, integer:4; 8, block; 8, 9; 8, 13; 8, 22; 8, 31; 8, 75; 8, 205; 9, expression_statement; 9, 10; 10, assignment; ... | def find_valley_range(vector, min_distance = 4):
mode = "wrap"
minima = local_minima(vector,min_distance,mode)
maxima = local_maxima(vector,min_distance,mode)
if len(maxima)>len(minima):
if vector[maxima[0]] >= vector[maxima[-1]]:
maxima=maxima[1:]
else:
maxima=ma... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_snps; 3, parameters; 3, 4; 4, identifier:snps; 5, block; 5, 6; 5, 22; 5, 41; 5, 60; 5, 81; 5, 92; 5, 105; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:sorted_list; 9, call; 9, 10; 9, 11; 10, identifier:sorted; 11... | def sort_snps(snps):
sorted_list = sorted(snps["chrom"].unique(), key=_natural_sort_key)
if "PAR" in sorted_list:
sorted_list.remove("PAR")
sorted_list.append("PAR")
if "MT" in sorted_list:
sorted_list.remove("MT")
sorted_list.append("MT")
snps["chrom"] = snps["chrom"].as... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_genetic_map_HapMapII_GRCh37; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 28; 6, if_statement; 6, 7; 6, 12; 7, comparison_operator:is; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:_genetic_map_Ha... | def get_genetic_map_HapMapII_GRCh37(self):
if self._genetic_map_HapMapII_GRCh37 is None:
self._genetic_map_HapMapII_GRCh37 = self._load_genetic_map(
self._get_path_genetic_map_HapMapII_GRCh37()
)
return self._genetic_map_HapMapII_GRCh37 |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:seperate_symbols; 3, parameters; 3, 4; 4, identifier:func; 5, block; 5, 6; 5, 10; 5, 14; 5, 84; 5, 123; 5, 137; 5, 151; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:params; 9, list:[]; 10, expression_statement; 10, 11... | def seperate_symbols(func):
params = []
vars = []
for symbol in func.free_symbols:
if not isidentifier(str(symbol)):
continue
if isinstance(symbol, Parameter):
params.append(symbol)
elif isinstance(symbol, Idx):
pass
elif isinstance(symbol,... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:name; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 27; 5, 50; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:base_str; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, string:'d{}{}_'; 12, identi... | def name(self):
base_str = 'd{}{}_'.format(self.derivative_count if
self.derivative_count > 1 else '', self.expr)
for var, count in self.variable_count:
base_str += 'd{}{}'.format(var, count if count > 1 else '')
return base_str |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_init_from_dict; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:model_dict; 6, block; 6, 7; 6, 16; 6, 43; 6, 55; 6, 70; 6, 88; 6, 107; 6, 129; 6, 145; 6, 187; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifie... | def _init_from_dict(self, model_dict):
sort_func = lambda symbol: symbol.name
self.model_dict = OrderedDict(sorted(model_dict.items(),
key=lambda i: sort_func(i[0])))
ordered = list(toposort(self.connectivity_mapping))
independent = sorted(ord... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:function_dict; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 12; 5, 45; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:func_dict; 9, call; 9, 10; 9, 11; 10, identifier:OrderedDict; 11, argument_list; 12, f... | def function_dict(self):
func_dict = OrderedDict()
for var, func in self.vars_as_functions.items():
expr = self.model_dict[var].xreplace(self.vars_as_functions)
func_dict[func] = expr
return func_dict |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:flatten_; 3, parameters; 3, 4; 4, identifier:structure; 5, block; 5, 6; 5, 47; 5, 76; 6, if_statement; 6, 7; 6, 12; 7, call; 7, 8; 7, 9; 8, identifier:isinstance; 9, argument_list; 9, 10; 9, 11; 10, identifier:structure; 11, identifier:dict; 12... | def flatten_(structure):
if isinstance(structure, dict):
if structure:
structure = zip(*sorted(structure.items(), key=lambda x: x[0]))[1]
else:
structure = ()
if isinstance(structure, (tuple, list)):
result = []
for element in structure:
result += flatten_(element)
return tuple... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:set_python; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:value; 6, block; 6, 7; 6, 28; 6, 34; 6, 40; 6, 59; 6, 68; 6, 86; 7, if_statement; 7, 8; 7, 12; 8, not_operator; 8, 9; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, ... | def set_python(self, value):
if not self.multiselect:
if value and not isinstance(value, list):
value = [value]
value = value or []
records = SortedDict()
for record in value:
self.validate_value(record)
records[record.id] = record
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:get_filetypes; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:filelist; 5, default_parameter; 5, 6; 5, 7; 6, identifier:path; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:size; 10, attribute; 10, 11; 10, 14; 11, attribute; 11, 12;... | def get_filetypes(filelist, path=None, size=os.path.getsize):
path = path or (lambda _: _)
histo = defaultdict(int)
for entry in filelist:
ext = os.path.splitext(path(entry))[1].lstrip('.').lower()
if ext and ext[0] == 'r' and ext[1:].isdigit():
ext = "rar"
elif ext == "j... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:validate_sort_fields; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 19; 5, 32; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:sort_fields; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, string:'... | def validate_sort_fields(self):
sort_fields = ','.join(self.options.sort_fields)
if sort_fields == '*':
sort_fields = self.get_output_fields()
return formatting.validate_sort_fields(sort_fields or config.sort_fields) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:validate_sort_fields; 3, parameters; 3, 4; 4, identifier:sort_fields; 5, block; 5, 6; 5, 12; 5, 44; 5, 54; 5, 80; 5, 95; 5, 169; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:descending; 9, call; 9, 10; 9, 11; 10, iden... | def validate_sort_fields(sort_fields):
descending = set()
def sort_order_filter(name):
"Helper to remove flag and memoize sort order"
if name.startswith('-'):
name = name[1:]
descending.add(name)
return name
sort_fields = validate_field_list(sort_fields, name_... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:load_data_source; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 12; 3, 17; 4, identifier:local_path; 5, identifier:remote_source_list; 6, identifier:open_method; 7, default_parameter; 7, 8; 7, 9; 8, identifier:open_method_kwargs; 9, call; 9, 10; 9... | def load_data_source(local_path,
remote_source_list,
open_method,
open_method_kwargs=dict(),
remote_kwargs=dict(),
verbose=True):
'''Flexible data retreiver to download and cache the data files locally.
Usage example (this makes a local ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:grouped_mean; 3, parameters; 3, 4; 3, 5; 4, identifier:arr; 5, identifier:spike_clusters; 6, block; 6, 7; 6, 16; 6, 25; 6, 31; 6, 42; 6, 49; 6, 57; 6, 66; 6, 76; 6, 88; 6, 99; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identi... | def grouped_mean(arr, spike_clusters):
arr = np.asarray(arr)
spike_clusters = np.asarray(spike_clusters)
assert arr.ndim == 1
assert arr.shape[0] == len(spike_clusters)
cluster_ids = _unique(spike_clusters)
spike_clusters_rel = _index_of(spike_clusters, cluster_ids)
spike_counts = np.bincoun... |
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:name; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sort_dir; 8, string:'asc'; 9, block; 9, 10; 9, 20; 10, expression_statement; 10, 11; 11, call; 11, 12; 11, 15; 12,... | def sort_by(self, name, sort_dir='asc'):
logger.log(5, "Sort by `%s` %s.", name, sort_dir)
self.eval_js('table.sortBy("{}", "{}");'.format(name, sort_dir)) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:find_column; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:search; 6, default_parameter; 6, 7; 6, 8; 7, identifier:data_type; 8, None; 9, block; 9, 10; 9, 22; 9, 26; 9, 96; 10, if_statement; 10, 11; 10, 16; 11, call; 11, 12... | def find_column(self, search, data_type=None):
if isinstance(data_type, str):
data_type = [data_type]
cols = []
for table in self.tables:
for col in vars(table):
if glob.fnmatch.fnmatch(col, search):
if data_type and isinstance(getattr(... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:to_linear; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:index; 7, None; 8, block; 8, 9; 8, 65; 8, 78; 9, if_statement; 9, 10; 9, 13; 10, comparison_operator:is; 10, 11; 10, 12; 11, identifier:in... | def to_linear(self, index=None):
if index is None:
n = len(self.index)-1
index = [self.index[i]*(1.-i/(n-1.))+self.index[i+1]*i/(n-1.) for
i in range(n)]
colors = [self.rgba_floats_tuple(x) for x in index]
return LinearColormap(colors, index=index,
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:regex_opt_inner; 3, parameters; 3, 4; 3, 5; 4, identifier:strings; 5, identifier:open_paren; 6, block; 6, 7; 6, 15; 6, 21; 6, 27; 6, 44; 6, 65; 6, 147; 6, 154; 6, 189; 6, 203; 6, 210; 6, 254; 7, expression_statement; 7, 8; 8, assignment; 8, 9; ... | def regex_opt_inner(strings, open_paren):
close_paren = open_paren and ')' or ''
if not strings:
return ''
first = strings[0]
if len(strings) == 1:
return open_paren + escape(first) + close_paren
if not first:
return open_paren + regex_opt_inner(strings[1:], '(?:') \
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_substitutions_from_config; 3, parameters; 3, 4; 4, identifier:config; 5, block; 5, 6; 5, 10; 5, 19; 5, 25; 5, 62; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:result; 9, list:[]; 10, expression_statement; 10, 11; ... | def get_substitutions_from_config(config):
result = []
pattern_names = config.options(SUBSTITUTION_SECTION)
pattern_names.sort()
for name in pattern_names:
pattern_val = config.get(SUBSTITUTION_SECTION, name)
list_rep = ast.literal_eval(pattern_val)
substitution = parse_substitut... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:next_sibling; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 102; 6, if_statement; 6, 7; 6, 10; 6, 46; 7, attribute; 7, 8; 7, 9; 8, identifier:self; 9, identifier:parent; 10, block; 10, 11; 10, 19; 10, 28; 11, expression_statement;... | def next_sibling(self):
if self.parent:
nodes = self.parent.children
index = nodes.index(self)
sibling = nodes[index + 1] if index < len(nodes) - 1 else None
else:
nodes = self.tree.nodes
index = nodes.index(self)
sibling = (
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:previous_sibling; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 93; 6, if_statement; 6, 7; 6, 10; 6, 41; 7, attribute; 7, 8; 7, 9; 8, identifier:self; 9, identifier:parent; 10, block; 10, 11; 10, 19; 10, 28; 11, expression_stateme... | def previous_sibling(self):
if self.parent:
nodes = self.parent.children
index = nodes.index(self)
sibling = nodes[index - 1] if index > 0 else None
else:
nodes = self.tree.nodes
index = nodes.index(self)
sibling = (
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:delay_or_run; 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, 18; 9, 26; 9, 67; 10, expression_statement; 10, 11;... | def delay_or_run(self, *args, **kwargs):
warnings.warn(
"delay_or_run is deprecated. Please use delay_or_eager",
DeprecationWarning,
)
possible_broker_errors = self._get_possible_broker_errors_tuple()
try:
result = self.apply_async(args=args, kwargs=kw... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:arrange; 3, parameters; 3, 4; 4, list_splat_pattern; 4, 5; 5, identifier:args; 6, block; 6, 7; 6, 17; 6, 56; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:names; 10, list_comprehension; 10, 11; 10, 14; 11, attribute; ... | def arrange(*args):
names = [column._name for column in args]
def f(df):
sortby_df = df >> mutate(*args)
index = sortby_df.sort_values([str(arg) for arg in args]).index
return df.loc[index]
return f |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:filenames; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:directory; 5, default_parameter; 5, 6; 5, 7; 6, identifier:tag; 7, string:''; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sorted; 10, False; 11, default_parameter; 11, 12; 1... | def filenames(directory, tag='', sorted=False, recursive=False):
if recursive:
f = [os.path.join(directory, f) for directory, _, filename in os.walk(directory) for f in filename if f.find(tag) > -1]
else:
f = [os.path.join(directory, f) for f in os.listdir(directory) if f.find(tag) > -1]
if... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_iterargs; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:item; 6, block; 6, 7; 6, 17; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:args; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, ... | def get_iterargs(self, item):
args = self._get_aggregate_args(item, 'mandatoryArgs')
return tuple(sorted([arg for arg in args if arg in self.iterargs])) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:merge_dict; 3, parameters; 3, 4; 3, 5; 4, identifier:a; 5, identifier:b; 6, block; 6, 7; 6, 17; 6, 24; 6, 106; 7, if_statement; 7, 8; 7, 14; 8, not_operator; 8, 9; 9, call; 9, 10; 9, 11; 10, identifier:isinstance; 11, argument_list; 11, 12; 11,... | def merge_dict(a, b):
if not isinstance(b, dict):
return b
result = deepcopy(a)
for key, val in six.iteritems(b):
if key in result and isinstance(result[key], dict):
result[key] = merge_dict(result[key], val)
elif key in result and isinstance(result[key], list):
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:posthoc_mannwhitney; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:a; 5, default_parameter; 5, 6; 5, 7; 6, identifier:val_col; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:group_col; 10, None; 11, defa... | def posthoc_mannwhitney(a, val_col=None, group_col=None, use_continuity=True, alternative='two-sided', p_adjust=None, sort=True):
'''Pairwise comparisons with Mann-Whitney rank test.
Parameters
----------
a : array_like or pandas DataFrame object
An array, any object exposing the array interface... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:posthoc_wilcoxon; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:a; 5, default_parameter; 5, 6; 5, 7; 6, identifier:val_col; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:group_col; 10, None; 11, default... | def posthoc_wilcoxon(a, val_col=None, group_col=None, zero_method='wilcox', correction=False, p_adjust=None, sort=False):
'''Pairwise comparisons with Wilcoxon signed-rank test. It is a non-parametric
version of the paired T-test for use with non-parametric ANOVA.
Parameters
----------
a : array_lik... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 28; 2, function_name:calendarplot; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 4, identifier:data; 5, default_parameter; 5, 6; 5, 7; 6, identifier:how; 7, string:'sum'; 8, default_parameter; 8, 9; 8, 10; 9, identifier:yearlabels; 10,... | def calendarplot(data, how='sum', yearlabels=True, yearascending=True, yearlabel_kws=None,
subplot_kws=None, gridspec_kws=None, fig_kws=None, **kwargs):
yearlabel_kws = yearlabel_kws or {}
subplot_kws = subplot_kws or {}
gridspec_kws = gridspec_kws or {}
fig_kws = fig_kws or {}
year... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 29; 2, function_name:tasks; 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:pattern; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:negate; 10, False; 11, def... | def tasks(self, pattern=None, negate=False, state=None, limit=None, reverse=True,
params=None, success=False, error=True):
request = clearly_pb2.FilterTasksRequest(
tasks_filter=clearly_pb2.PatternFilter(pattern=pattern or '.',
negate=... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:echo_headers; 3, parameters; 3, 4; 3, 5; 4, identifier:headers; 5, default_parameter; 5, 6; 5, 7; 6, identifier:file; 7, None; 8, block; 8, 9; 8, 42; 9, for_statement; 9, 10; 9, 13; 9, 21; 10, pattern_list; 10, 11; 10, 12; 11, identifier:k; 12,... | def echo_headers(headers, file=None):
for k, v in sorted(headers.items()):
click.echo("{0}: {1}".format(k.title(), v), file=file)
click.echo(file=file) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:by_own_time_per_call; 3, parameters; 3, 4; 4, identifier:stat; 5, block; 5, 6; 6, return_statement; 6, 7; 7, tuple; 7, 8; 7, 20; 8, conditional_expression:if; 8, 9; 8, 13; 8, 16; 9, unary_operator:-; 9, 10; 10, attribute; 10, 11; 10, 12; 11, id... | def by_own_time_per_call(stat):
return (-stat.own_time_per_call if stat.own_hits else -stat.own_time,
by_deep_time_per_call(stat)) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:missing_labels; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, return_statement; 6, 7; 7, call; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:np; 10, identifier:array; 11, argument_list; 11, 12; 12, call; 12, 13; 12, 14; 13... | def missing_labels(self):
return np.array(sorted(set(range(0, self.max_label + 1)).
difference(np.insert(self.labels, 0, 0)))) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 47; 2, function_name:fit_image; 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; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sma0; 7, None; 8, default_parameter; 8, 9; 8, 1... | def fit_image(self, sma0=None, minsma=0., maxsma=None, step=0.1,
conver=DEFAULT_CONVERGENCE, minit=DEFAULT_MINIT,
maxit=DEFAULT_MAXIT, fflag=DEFAULT_FFLAG,
maxgerr=DEFAULT_MAXGERR, sclip=3., nclip=0,
integrmode=BILINEAR, linear=False, maxrit=None):... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:values; 6, block; 6, 7; 7, for_statement; 7, 8; 7, 9; 7, 10; 8, identifier:level; 9, identifier:self; 10, block; 10, 11; 11, for_statement; 11, 12; 11, 15; 11, 16; 12, pattern_l... | def sort(self, values):
for level in self:
for wire1, wire2 in level:
if values[wire1] > values[wire2]:
values[wire1], values[wire2] = values[wire2], values[wire1] |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:getWorkersName; 3, parameters; 3, 4; 4, identifier:data; 5, block; 5, 6; 5, 18; 5, 24; 5, 37; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:names; 9, list_comprehension; 9, 10; 9, 11; 10, identifier:fichier; 11, for_in... | def getWorkersName(data):
names = [fichier for fichier in data.keys()]
names.sort()
try:
names.remove("broker")
except ValueError:
pass
return names |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 1, 32; 2, function_name:parse_commit_message; 3, parameters; 3, 4; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:message; 6, type; 6, 7; 7, identifier:str; 8, type; 8, 9; 9, generic_type; 9, 10; 9, 11; 10, identifier:Tuple; 11, type_parameter; 11, 12; 11, 14; 1... | def parse_commit_message(message: str) -> Tuple[int, str, Optional[str], Tuple[str, str, str]]:
parsed = re_parser.match(message)
if not parsed:
raise UnknownCommitMessageStyleError(
'Unable to parse the given commit message: {0}'.format(message)
)
subject = parsed.group('subject... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:todos; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 23; 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; 11, 12; 11, 13; 12, iden... | def todos(self):
result = self._sorter.sort(self.todolist.todos())
return self._apply_filters(result) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:group; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:p_todos; 6, block; 6, 7; 6, 17; 6, 27; 6, 131; 6, 152; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:p_todos; 10, call; 10, 11; 10, 12; 11, identifie... | def group(self, p_todos):
p_todos = _apply_sort_functions(p_todos, self.pregroupfunctions)
result = OrderedDict([((), p_todos)])
for (function, label), _ in self.groupfunctions:
oldresult = result
result = OrderedDict()
for oldkey, oldgroup in oldresult.items(... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:process_other_set; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:hdf5_file; 5, identifier:which_set; 6, identifier:image_archive; 7, identifier:patch_archive; 8, identifier:groundtruth; 9, identifier:offset; 10, block; 10, 1... | def process_other_set(hdf5_file, which_set, image_archive, patch_archive,
groundtruth, offset):
producer = partial(other_set_producer, image_archive=image_archive,
patch_archive=patch_archive,
groundtruth=groundtruth, which_set=which_set)
consu... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sorted_fancy_indexing; 3, parameters; 3, 4; 3, 5; 4, identifier:indexable; 5, identifier:request; 6, block; 6, 7; 6, 76; 7, if_statement; 7, 8; 7, 14; 7, 68; 8, comparison_operator:>; 8, 9; 8, 13; 9, call; 9, 10; 9, 11; 10, identifier:len; 11, ... | def sorted_fancy_indexing(indexable, request):
if len(request) > 1:
indices = numpy.argsort(request)
data = numpy.empty(shape=(len(request),) + indexable.shape[1:],
dtype=indexable.dtype)
data[indices] = indexable[numpy.array(request)[indices], ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:index_within_subset; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:indexable; 6, identifier:subset_request; 7, default_parameter; 7, 8; 7, 9; 8, identifier:sort_indices; 9, False; 10, block; 10, 11; 10, 36; 10, 55; 1... | def index_within_subset(self, indexable, subset_request,
sort_indices=False):
if isinstance(subset_request, numbers.Integral):
request, = self[[subset_request]]
else:
request = self[subset_request]
if isinstance(request, numbers.Integral) or ha... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 24; 2, function_name:degree_circle; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 15; 3, 18; 3, 21; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:EdgeAttribute; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:network; 10, None; ... | def degree_circle(self,EdgeAttribute=None,network=None,NodeAttribute=None,\
nodeList=None,singlePartition=None,verbose=None):
network=check_network(self,network,verbose=verbose)
PARAMS=set_param(['EdgeAttribute','network','NodeAttribute','nodeList',\
'singlePartition'],[EdgeAttribute,network,NodeAttribute,nodeL... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 66; 2, function_name:import_url; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 9; 3, 12; 3, 15; 3, 16; 3, 19; 3, 22; 3, 23; 3, 26; 3, 29; 3, 32; 3, 33; 3, 36; 3, 39; 3, 40; 3, 43; 3, 46; 3, 49; 3, 50; 3, 53; 3, 56; 3, 59; 3, 60; 3, 63; 4, identifier:self; 5, default_paramet... | def import_url(self,caseSensitiveNetworkCollectionKeys=None,\
caseSensitiveNetworkKeys=None,dataTypeList=None,\
DataTypeTargetForNetworkCollection=None,DataTypeTargetForNetworkList=None,\
delimiters=None,delimitersForDataList=None,firstRowAsColumnNames=None,\
KeyColumnForMapping=None,Key... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 35; 2, function_name:fromtif; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 4, identifier:path; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ext; 7, string:'tif'; 8, default_parameter; 8, 9; 8, 10; 9, identifier:start;... | def fromtif(path, ext='tif', start=None, stop=None, recursive=False, nplanes=None, npartitions=None, labels=None, engine=None, credentials=None, discard_extra=False):
from tifffile import TiffFile
if nplanes is not None and nplanes <= 0:
raise ValueError('nplanes must be positive if passed, got %d' % np... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 29; 2, function_name:frompng; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 4, identifier:path; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ext; 7, string:'png'; 8, default_parameter; 8, 9; 8, 10; 9, identifier:start; 10, None; 11,... | def frompng(path, ext='png', start=None, stop=None, recursive=False, npartitions=None, labels=None, engine=None, credentials=None):
from scipy.misc import imread
def getarray(idx_buffer_filename):
idx, buf, _ = idx_buffer_filename
fbuf = BytesIO(buf)
yield (idx,), imread(fbuf)
return... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:list; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:path; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ext; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:start; 10, None; 11, default_parameter; 11, 12; 11, 13; 12,... | def list(path, ext=None, start=None, stop=None, recursive=False):
files = listflat(path, ext) if not recursive else listrecursive(path, ext)
if len(files) < 1:
raise FileNotFoundError('Cannot find files of type "%s" in %s'
% (ext if ext else '*', path))
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:list; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:path; 5, default_parameter; 5, 6; 5, 7; 6, identifier:filename; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:start; 10, None; 11, default_parameter; 11, 12;... | def list(path, filename=None, start=None, stop=None, recursive=False, directories=False):
path = uri_to_path(path)
if not filename and recursive:
return listrecursive(path)
if filename:
if os.path.isdir(path):
path = os.path.join(path, filename)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:list; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:self; 5, identifier:path; 6, default_parameter; 6, 7; 6, 8; 7, identifier:filename; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:start; 11, None; 12... | def list(self, path, filename=None, start=None, stop=None, recursive=False, directories=False):
storageScheme, keys = self.getkeys(
path, filename=filename, directories=directories, recursive=recursive)
keys = [storageScheme + ":///" + key.bucket.name + "/" + key.name for key in keys]
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:validate_v3_svc_catalog_endpoint_data; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:expected; 6, identifier:actual; 7, block; 7, 8; 7, 17; 7, 34; 7, 167; 8, expression_statement; 8, 9; 9, call; 9, 10; 9, 15; 10, attribute;... | def validate_v3_svc_catalog_endpoint_data(self, expected, actual):
self.log.debug('Validating v3 service catalog endpoint data...')
self.log.debug('actual: {}'.format(repr(actual)))
for k, v in six.iteritems(expected):
if k in actual:
l_expected = sorted(v, key=lambda... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:ordered; 3, parameters; 3, 4; 4, identifier:orderme; 5, block; 5, 6; 5, 19; 5, 25; 5, 71; 6, if_statement; 6, 7; 6, 13; 7, not_operator; 7, 8; 8, call; 8, 9; 8, 10; 9, identifier:isinstance; 10, argument_list; 10, 11; 10, 12; 11, identifier:ord... | def ordered(orderme):
if not isinstance(orderme, dict):
raise ValueError('argument must be a dict type')
result = OrderedDict()
for k, v in sorted(six.iteritems(orderme), key=lambda x: x[0]):
if isinstance(v, dict):
result[k] = ordered(v)
else:
result[k] = v
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:search; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, identifier:q; 6, default_parameter; 6, 7; 6, 8; 7, identifier:start; 8, integer:1; 9, default_parameter; 9, 10; 9, 11; 10, identifier:num; 11, integer:10; 12, ... | def search(self,
q,
start=1,
num=10,
sortField="username",
sortOrder="asc"):
params = {
"f" : "json",
"q" : q,
"start" : start,
"num" : num,
"sortField" : sortField,
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 55; 2, function_name:exportImage; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 13; 3, 16; 3, 19; 3, 22; 3, 25; 3, 28; 3, 31; 3, 34; 3, 37; 3, 40; 3, 43; 3, 46; 3, 49; 3, 52; 4, identifier:self; 5, identifier:bbox; 6, identifier:imageSR; 7, identifier:bboxSR; 8,... | def exportImage(self,
bbox,
imageSR,
bboxSR,
size=[400,400],
time=None,
format="jpgpng",
pixelType="UNKNOWN",
noData=None,
noDataInterpretat... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 26; 2, function_name:measure; 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:fromGeometry; 6, identifier:toGeometry; 7, identifier:measureOperation; 8, default_parameter; 8, 9; 8, 10; 9, identifier... | def measure(self,fromGeometry,toGeometry,measureOperation,
geometryType="esriGeometryPoint",pixelSize=None,mosaicRule=None,
linearUnit=None,angularUnit=None,areaUnit=None):
url = self._url + "/measure"
params = {
"f" : "json",
"fromGeometry" : from... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:computeStatisticsHistograms; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 4, identifier:self; 5, identifier:geometry; 6, identifier:geometryType; 7, default_parameter; 7, 8; 7, 9; 8, identifier:mosaicRule; 9, None; 10, default_paramete... | def computeStatisticsHistograms(self,geometry,geometryType,mosaicRule=None,
renderingRule=None,pixelSize=None):
url = self._url + "/computeStatisticsHistograms"
params = {
"f" : "json",
"geometry" : geometry,
"geometryType": geometr... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:users; 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:1; 8, default_parameter; 8, 9; 8, 10; 9, identifier:num; 10, integer:10; 11, default_parameter; ... | def users(self,
start=1,
num=10,
sortField="fullName",
sortOrder="asc",
role=None):
users = []
url = self._url + "/users"
params = {
"f" : "json",
"start" : start,
"num" : num
}
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 36; 2, function_name:find; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 3, 27; 3, 30; 3, 33; 4, identifier:self; 5, identifier:text; 6, default_parameter; 6, 7; 6, 8; 7, identifier:magicKey; 8, None; 9, default_parameter; 9, 10; 9, 11;... | def find(self,
text,
magicKey=None,
sourceCountry=None,
bbox=None,
location=None,
distance=3218.69,
outSR=102100,
category=None,
outFields="*",
maxLocations=20,
forStorage=False... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 30; 2, function_name:search; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 3, 27; 4, identifier:self; 5, identifier:q; 6, default_parameter; 6, 7; 6, 8; 7, identifier:t; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:focus;... | def search(self,
q,
t=None,
focus=None,
bbox=None,
start=1,
num=10,
sortField=None,
sortOrder="asc",
useSecurity=True):
if self._url.endswith("/rest"):
url = self._url + "/se... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_models; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 30; 5, 38; 5, 45; 5, 49; 5, 53; 5, 137; 5, 146; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:model_names; 9, list_comprehension; 9, 10; 9, 13; 9... | def sort_models(self):
model_names = [
table.name for table in self.Base.metadata.sorted_tables if table.name in self.models
]
logger.debug("Unsorted models: %s", model_names)
model_count = len(model_names)
swapped = True
sort_round = 0
while swapped:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:keyed_helper; 3, parameters; 3, 4; 4, identifier:helper; 5, block; 5, 6; 5, 134; 5, 140; 6, decorated_definition; 6, 7; 6, 12; 7, decorator; 7, 8; 8, call; 8, 9; 8, 10; 9, identifier:wraps; 10, argument_list; 10, 11; 11, identifier:helper; 12, ... | def keyed_helper(helper):
@wraps(helper)
def wrapper(instance=None, key=None, attr=None, *args, **kwargs):
if set((instance, key, attr)) == {None}:
raise ValueError("If called directly, helper function '%s' requires either a model"
" instance, or a 'key' or 'attr... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:find_bin; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:x; 6, block; 6, 7; 6, 20; 6, 35; 6, 69; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:x; 10, call; 10, 11; 10, 19; 11, attribute; 11, 12; 11, 18; ... | def find_bin(self, x):
x = np.asarray(x).flatten()
right = np.digitize(x, self.bins, right=True)
if right.max() == len(self.bins):
right[right == len(self.bins)] = len(self.bins) - 1
return right |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 24; 1, 30; 2, function_name:filter_by_size; 3, parameters; 3, 4; 3, 8; 3, 16; 3, 20; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:feat_dir; 6, type; 6, 7; 7, identifier:Path; 8, typed_parameter; 8, 9; 8, 10; 9, identifier:prefixes; 10, type; 10, 11; 11, generic_t... | def filter_by_size(feat_dir: Path, prefixes: List[str], feat_type: str,
max_samples: int) -> List[str]:
prefix_lens = get_prefix_lens(Path(feat_dir), prefixes, feat_type)
prefixes = [prefix for prefix, length in prefix_lens
if length <= max_samples]
return prefixes |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 1, 34; 2, function_name:sort_annotations; 3, parameters; 3, 4; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:annotations; 6, type; 6, 7; 7, generic_type; 7, 8; 7, 9; 8, identifier:List; 9, type_parameter; 9, 10; 10, type; 10, 11; 11, generic_type; 11, 12; 11, ... | def sort_annotations(annotations: List[Tuple[int, int, str]]
) -> List[Tuple[int, int, str]]:
return sorted(annotations, key=lambda x: x[0]) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:default_sort_key; 3, parameters; 3, 4; 3, 5; 4, identifier:item; 5, default_parameter; 5, 6; 5, 7; 6, identifier:order; 7, None; 8, block; 8, 9; 8, 17; 8, 26; 8, 33; 8, 49; 8, 196; 9, import_from_statement; 9, 10; 9, 13; 9, 15; 10, dotted_name;... | def default_sort_key(item, order=None):
from sympy.core import S, Basic
from sympy.core.sympify import sympify, SympifyError
from sympy.core.compatibility import iterable
if isinstance(item, Basic):
return item.sort_key(order=order)
if iterable(item, exclude=string_types):
if isinsta... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:uintersect1d; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:arr1; 5, identifier:arr2; 6, default_parameter; 6, 7; 6, 8; 7, identifier:assume_unique; 8, False; 9, block; 9, 10; 9, 23; 9, 33; 10, expression_statement; 10, 11; 11, assignment; 11,... | def uintersect1d(arr1, arr2, assume_unique=False):
v = np.intersect1d(arr1, arr2, assume_unique=assume_unique)
v = _validate_numpy_wrapper_units(v, [arr1, arr2])
return v |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:argsort; 3, parameters; 3, 4; 3, 5; 3, 9; 3, 12; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:axis; 7, unary_operator:-; 7, 8; 8, integer:1; 9, default_parameter; 9, 10; 9, 11; 10, identifier:kind; 11, string:"quicksort"... | def argsort(self, axis=-1, kind="quicksort", order=None):
return self.view(np.ndarray).argsort(axis, kind, order) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:serve; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 4, identifier:info; 5, identifier:host; 6, identifier:port; 7, identifier:reload; 8, identifier:debugger; 9, identifier:eager_loading; 10, identifier:with_threads; 11, block; 11,... | def serve(info, host, port, reload, debugger, eager_loading, with_threads):
'''
Runs a local udata development server.
This local server is recommended for development purposes only but it
can also be used for simple intranet deployments.
By default it will not support any sort of concurrency at all... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:get_enabled_plugins; 3, parameters; 4, block; 4, 5; 4, 7; 4, 21; 4, 35; 4, 67; 5, expression_statement; 5, 6; 6, string:'''
Returns enabled preview plugins.
Plugins are sorted, defaults come last
'''; 7, expression_statement; 7, 8; ... | def get_enabled_plugins():
'''
Returns enabled preview plugins.
Plugins are sorted, defaults come last
'''
plugins = entrypoints.get_enabled('udata.preview', current_app).values()
valid = [p for p in plugins if issubclass(p, PreviewPlugin)]
for plugin in plugins:
if plugin not in val... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:extract_sort; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:params; 6, block; 6, 7; 6, 9; 6, 19; 6, 31; 6, 55; 7, expression_statement; 7, 8; 8, string:'''Extract and build sort query from parameters'''; 9, expression_statement; ... | def extract_sort(self, params):
'''Extract and build sort query from parameters'''
sorts = params.pop('sort', [])
sorts = [sorts] if isinstance(sorts, basestring) else sorts
sorts = [(s[1:], 'desc')
if s.startswith('-') else (s, 'asc')
for s in sorts]
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:ancestors_objects; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 44; 5, 58; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:ancestors_objects; 9, list:[]; 10, for_statement; 10, 11; 10, 12; 10, 15; 1... | def ancestors_objects(self):
ancestors_objects = []
for ancestor in self.ancestors:
try:
ancestor_object = GeoZone.objects.get(id=ancestor)
except GeoZone.DoesNotExist:
continue
ancestors_objects.append(ancestor_object)
ancestor... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:check_for_territories; 3, parameters; 3, 4; 4, identifier:query; 5, block; 5, 6; 5, 22; 5, 30; 5, 38; 5, 46; 5, 53; 5, 211; 5, 218; 6, if_statement; 6, 7; 6, 19; 7, boolean_operator:or; 7, 8; 7, 10; 8, not_operator; 8, 9; 9, identifier:query; 1... | def check_for_territories(query):
if not query or not current_app.config.get('ACTIVATE_TERRITORIES'):
return []
dbqs = db.Q()
query = query.lower()
is_digit = query.isdigit()
query_length = len(query)
for level in current_app.config.get('HANDLED_LEVELS'):
if level == 'country':
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.