sequence stringlengths 492 15.9k | code stringlengths 75 8.58k |
|---|---|
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_loc; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:key; 6, default_parameter; 6, 7; 6, 8; 7, identifier:method; 8, None; 9, block; 9, 10; 9, 22; 9, 97; 9, 122; 9, 129; 9, 151; 9, 171; 9, 177; 9, 193; 9, 214; 9, 224; 9, ... | def get_loc(self, key, method=None):
if method is not None:
raise NotImplementedError('only the default get_loc method is '
'currently supported for MultiIndex')
def _maybe_to_slice(loc):
if not isinstance(loc, np.ndarray) or loc.dtype != 'in... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:union; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:other; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sort; 8, None; 9, block; 9, 10; 9, 17; 9, 24; 9, 35; 9, 52; 9, 70; 10, expression_statement; 10, 11; 11, call; 11, ... | def union(self, other, sort=None):
self._validate_sort_keyword(sort)
self._assert_can_do_setop(other)
other, result_names = self._convert_can_do_setop(other)
if len(other) == 0 or self.equals(other):
return self
uniq_tuples = lib.fast_unique_multiple([self._ndarray_va... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:intersection; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:other; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sort; 8, False; 9, block; 9, 10; 9, 17; 9, 24; 9, 35; 9, 45; 9, 51; 9, 57; 9, 69; 9, 81; 10, expression_stat... | def intersection(self, other, sort=False):
self._validate_sort_keyword(sort)
self._assert_can_do_setop(other)
other, result_names = self._convert_can_do_setop(other)
if self.equals(other):
return self
self_tuples = self._ndarray_values
other_tuples = other._nd... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:difference; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:other; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sort; 8, None; 9, block; 9, 10; 9, 17; 9, 24; 9, 35; 9, 45; 9, 76; 9, 84; 9, 93; 9, 112; 9, 132; 9, 143; 9, 15... | def difference(self, other, sort=None):
self._validate_sort_keyword(sort)
self._assert_can_do_setop(other)
other, result_names = self._convert_can_do_setop(other)
if len(other) == 0:
return self
if self.equals(other):
return MultiIndex(levels=self.levels,
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:unique; 3, parameters; 3, 4; 4, identifier:values; 5, block; 5, 6; 5, 13; 5, 25; 5, 29; 5, 41; 5, 51; 5, 60; 5, 69; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:values; 9, call; 9, 10; 9, 11; 10, identifier:_ensure_ar... | def unique(values):
values = _ensure_arraylike(values)
if is_extension_array_dtype(values):
return values.unique()
original = values
htable, _, values, dtype, ndtype = _get_hashtable_algo(values)
table = htable(len(values))
uniques = table.unique(values)
uniques = _reconstruct_data(u... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:value_counts; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:values; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ascending; 10, False; 11, default_paramet... | def value_counts(values, sort=True, ascending=False, normalize=False,
bins=None, dropna=True):
from pandas.core.series import Series, Index
name = getattr(values, 'name', None)
if bins is not None:
try:
from pandas.core.reshape.tile import cut
values = Series... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:validate_argsort_with_ascending; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:ascending; 5, identifier:args; 6, identifier:kwargs; 7, block; 7, 8; 7, 29; 7, 38; 8, if_statement; 8, 9; 8, 17; 9, boolean_operator:or; 9, 10; 9, 14; 10, call; 10,... | def validate_argsort_with_ascending(ascending, args, kwargs):
if is_integer(ascending) or ascending is None:
args = (ascending,) + args
ascending = True
validate_argsort_kind(args, kwargs, max_fname_arg_count=3)
return ascending |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 44; 2, function_name:merge_asof; 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, 35; 3, 38; 3, 41; 4, identifier:left; 5, identifier:right; 6, default_parameter; 6, 7; 6, 8; 7, identifier:on; 8, None; 9, default_parameter... | def merge_asof(left, right, on=None,
left_on=None, right_on=None,
left_index=False, right_index=False,
by=None, left_by=None, right_by=None,
suffixes=('_x', '_y'),
tolerance=None,
allow_exact_matches=True,
direction... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:generate_classes; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:items; 6, block; 6, 7; 6, 9; 6, 15; 6, 31; 6, 38; 6, 44; 7, expression_statement; 7, 8; 8, string:"Generate classes from `items` by taking the sorted unique values."... | def generate_classes(self, items):
"Generate classes from `items` by taking the sorted unique values."
classes = set()
for c in items: classes = classes.union(set(c))
classes = list(classes)
classes.sort()
return classes |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 1, 29; 2, function_name:most_confused; 3, parameters; 3, 4; 3, 5; 3, 10; 4, identifier:self; 5, typed_default_parameter; 5, 6; 5, 7; 5, 9; 6, identifier:min_val; 7, type; 7, 8; 8, identifier:int; 9, integer:1; 10, typed_default_parameter; 10, 11; 10, 12; 10, 1... | def most_confused(self, min_val:int=1, slice_size:int=1)->Collection[Tuple[str,str,int]]:
"Sorted descending list of largest non-diagonal entries of confusion matrix, presented as actual, predicted, number of occurrences."
cm = self.confusion_matrix(slice_size=slice_size)
np.fill_diagonal(cm, 0)... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_toplosses_idxs; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:cls; 5, identifier:learn; 6, identifier:n_imgs; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 12; 9, 20; 9, 33; 9, 52; 9, 64; 10, expression... | def get_toplosses_idxs(cls, learn, n_imgs, **kwargs):
"Sorts `ds_type` dataset by top losses and returns dataset and sorted indices."
dl = learn.data.fix_dl
if not n_imgs: n_imgs = len(dl.dataset)
_,_,top_losses = learn.get_preds(ds_type=DatasetType.Fix, with_loss=True)
idxs = to... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_idxs; 3, parameters; 3, 4; 3, 5; 4, identifier:cls; 5, identifier:similarities; 6, block; 6, 7; 6, 9; 6, 22; 6, 48; 7, expression_statement; 7, 8; 8, string:"Sorts `similarities` and return the indexes in pairs ordered by highest similarit... | def sort_idxs(cls, similarities):
"Sorts `similarities` and return the indexes in pairs ordered by highest similarity."
idxs = cls.largest_indices(similarities, len(similarities))
idxs = [(idxs[0][i], idxs[1][i]) for i in range(len(idxs[0]))]
return [e for l in idxs for e in l] |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 1, 15; 2, function_name:uniqueify; 3, parameters; 3, 4; 3, 8; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:x; 6, type; 6, 7; 7, identifier:Series; 8, typed_default_parameter; 8, 9; 8, 10; 8, 12; 9, identifier:sort; 10, type; 10, 11; 11, identifier:bool; 12, F... | def uniqueify(x:Series, sort:bool=False)->List:
"Return sorted unique values of `x`."
res = list(OrderedDict.fromkeys(x).keys())
if sort: res.sort()
return res |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_imported_modules; 3, parameters; 3, 4; 3, 5; 4, identifier:cells; 5, default_parameter; 5, 6; 5, 7; 6, identifier:nb_module_name; 7, string:''; 8, block; 8, 9; 8, 11; 8, 17; 8, 46; 8, 55; 8, 78; 8, 86; 8, 100; 9, expression_statement; 9, 10... | def get_imported_modules(cells, nb_module_name=''):
"Finds all submodules of notebook - sorted by submodules > top level modules > manual imports. This gives notebook imports priority"
module_names = get_top_level_modules()
nb_imports = [match.group(1) for cell in cells for match in IMPORT_RE.finditer(cell[... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:numericalize_tok; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:tokens; 5, default_parameter; 5, 6; 5, 7; 6, identifier:max_vocab; 7, integer:50000; 8, default_parameter; 8, 9; 8, 10; 9, identifier:min_freq; 10, in... | def numericalize_tok(tokens, max_vocab=50000, min_freq=0, unk_tok="_unk_", pad_tok="_pad_", bos_tok="_bos_", eos_tok="_eos_"):
if isinstance(tokens, str):
raise ValueError("Expected to receive a list of tokens. Received a string instead")
if isinstance(tokens[0], list):
tokens = [p for o in toke... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_freq_tuples; 3, parameters; 3, 4; 3, 5; 4, identifier:my_list; 5, identifier:print_total_threshold; 6, block; 6, 7; 6, 11; 6, 29; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:d; 10, dictionary; 11, for_statement;... | def get_freq_tuples(my_list, print_total_threshold):
d = {}
for token in my_list:
d.setdefault(token, 0)
d[token] += 1
return sorted(d.items(), key=operator.itemgetter(1), reverse=True)[:print_total_threshold] |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_levels; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:arcs; 6, block; 6, 7; 6, 27; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:levels; 10, call; 10, 11; 10, 12; 11, identifier:set; 12, argument_li... | def get_levels(self, arcs):
levels = set(map(lambda arc: arc["end"] - arc["start"], arcs))
return sorted(list(levels)) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:organize_commands; 3, parameters; 3, 4; 4, identifier:corrected_commands; 5, block; 5, 6; 5, 22; 5, 45; 5, 60; 5, 88; 6, try_statement; 6, 7; 6, 18; 7, block; 7, 8; 7, 15; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifi... | def organize_commands(corrected_commands):
try:
first_command = next(corrected_commands)
yield first_command
except StopIteration:
return
without_duplicates = {
command for command in sorted(
corrected_commands, key=lambda command: command.priority)
if com... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_corrected_commands; 3, parameters; 3, 4; 4, identifier:command; 5, block; 5, 6; 5, 31; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:corrected_commands; 9, generator_expression; 9, 10; 9, 11; 9, 16; 9, 23; 10, iden... | def get_corrected_commands(command):
corrected_commands = (
corrected for rule in get_rules()
if rule.is_match(command)
for corrected in rule.get_corrected_commands(command))
return organize_commands(corrected_commands) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:_partition_query; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:cls; 5, identifier:table_name; 6, default_parameter; 6, 7; 6, 8; 7, identifier:limit; 8, integer:0; 9, default_parameter; 9, 10; 9, 11; 10, identifier:order_by; 11, ... | def _partition_query(
cls, table_name, limit=0, order_by=None, filters=None):
limit_clause = 'LIMIT {}'.format(limit) if limit else ''
order_by_clause = ''
if order_by:
l = []
for field, desc in order_by:
l.append(field + ' DESC' if desc else '... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:cocktail_shaker_sort; 3, parameters; 3, 4; 4, identifier:arr; 5, block; 5, 6; 5, 28; 5, 35; 5, 39; 5, 123; 6, function_definition; 6, 7; 6, 8; 6, 11; 7, function_name:swap; 8, parameters; 8, 9; 8, 10; 9, identifier:i; 10, identifier:j; 11, bloc... | def cocktail_shaker_sort(arr):
def swap(i, j):
arr[i], arr[j] = arr[j], arr[i]
n = len(arr)
swapped = True
while swapped:
swapped = False
for i in range(1, n):
if arr[i - 1] > arr[i]:
swap(i - 1, i)
swapped = True
if swapped == ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:max_heapify; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:arr; 5, identifier:end; 6, identifier:simulation; 7, identifier:iteration; 8, block; 8, 9; 8, 18; 8, 119; 8, 135; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; ... | def max_heapify(arr, end, simulation, iteration):
last_parent = (end - 1) // 2
for parent in range(last_parent, -1, -1):
current_parent = parent
while current_parent <= last_parent:
child = 2 * current_parent + 1
if child + 1 <= end and arr[child] < arr[child + 1]:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:min_heapify; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:arr; 5, identifier:start; 6, identifier:simulation; 7, identifier:iteration; 8, block; 8, 9; 8, 18; 8, 29; 8, 149; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12;... | def min_heapify(arr, start, simulation, iteration):
end = len(arr) - 1
last_parent = (end - start - 1) // 2
for parent in range(last_parent, -1, -1):
current_parent = parent
while current_parent <= last_parent:
child = 2 * current_parent + 1
if child + 1 <= end - star... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:pancake_sort; 3, parameters; 3, 4; 4, identifier:arr; 5, block; 5, 6; 5, 13; 5, 20; 5, 96; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:len_arr; 9, call; 9, 10; 9, 11; 10, identifier:len; 11, argument_list; 11, 12; 12... | def pancake_sort(arr):
len_arr = len(arr)
if len_arr <= 1:
return arr
for cur in range(len(arr), 1, -1):
index_max = arr.index(max(arr[0:cur]))
if index_max+1 != cur:
if index_max != 0:
arr[:index_max+1] = reversed(arr[:index_max+1])
arr[:cur] ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:natural_sort; 3, parameters; 3, 4; 3, 5; 4, identifier:list; 5, default_parameter; 5, 6; 5, 7; 6, identifier:key; 7, lambda; 7, 8; 7, 10; 8, lambda_parameters; 8, 9; 9, identifier:s; 10, identifier:s; 11, block; 11, 12; 11, 55; 11, 62; 12, fun... | def natural_sort(list, key=lambda s:s):
def get_alphanum_key_func(key):
convert = lambda text: int(text) if text.isdigit() else text
return lambda s: [convert(c) for c in re.split('([0-9]+)', key(s))]
sort_key = get_alphanum_key_func(key)
list.sort(key=sort_key) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_build_vocab; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:filename; 5, identifier:vocab_path; 6, identifier:vocab_size; 7, block; 7, 8; 7, 15; 7, 24; 7, 48; 7, 61; 7, 69; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identi... | def _build_vocab(filename, vocab_path, vocab_size):
data = _read_words(filename)
counter = collections.Counter(data)
count_pairs = sorted(counter.items(), key=lambda x: (-x[1], x[0]))
words, _ = list(zip(*count_pairs))
words = words[:vocab_size]
with open(vocab_path, "w") as f:
f.write("\n".join(words)) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:_read_stepfiles_list; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:path_prefix; 5, default_parameter; 5, 6; 5, 7; 6, identifier:path_suffix; 7, string:".index"; 8, default_parameter; 8, 9; 8, 10; 9, identifier:min_steps; 10, integer:0; 11, b... | def _read_stepfiles_list(path_prefix, path_suffix=".index", min_steps=0):
stepfiles = []
for filename in _try_twice_tf_glob(path_prefix + "*-[0-9]*" + path_suffix):
basename = filename[:-len(path_suffix)] if path_suffix else filename
try:
steps = int(basename.rsplit("-")[-1])
except ValueError:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:to_json; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:indent; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:separators; 10, None; 11, default_parameter; 11, 12; 11, 13;... | def to_json(self, indent=None, separators=None, sort_keys=False):
def remove_callables(x):
if isinstance(x, dict):
return {k: remove_callables(v) for k, v in six.iteritems(x)
if not callable(v)}
elif isinstance(x, list):
return [remove_callables(i) for i in x if not calla... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_create_topk_unique; 3, parameters; 3, 4; 3, 5; 4, identifier:inputs; 5, identifier:k; 6, block; 6, 7; 6, 15; 6, 23; 6, 40; 6, 56; 6, 62; 6, 78; 6, 82; 6, 98; 6, 204; 6, 228; 6, 234; 6, 240; 6, 249; 6, 261; 6, 273; 6, 285; 7, expression_stateme... | def _create_topk_unique(inputs, k):
height = inputs.shape[0]
width = inputs.shape[1]
neg_inf_r0 = tf.constant(-np.inf, dtype=tf.float32)
ones = tf.ones([height, width], dtype=tf.float32)
neg_inf_r2 = ones * neg_inf_r0
inputs = tf.where(tf.is_nan(inputs), neg_inf_r2, inputs)
tmp = inputs
topk_r2 = tf.zer... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:top_k_with_unique; 3, parameters; 3, 4; 3, 5; 4, identifier:inputs; 5, identifier:k; 6, block; 6, 7; 6, 22; 6, 32; 6, 44; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:unique_inputs; 10, call; 10, 11; 10, 12; 11, iden... | def top_k_with_unique(inputs, k):
unique_inputs = _create_make_unique(tf.cast(inputs, tf.float32))
top_values, indices = _create_topk_unique(unique_inputs, k)
top_values = tf.cast(top_values, inputs.dtype)
return top_values, indices |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_rowwise_unsorted_segment_sum; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:values; 5, identifier:indices; 6, identifier:n; 7, block; 7, 8; 7, 27; 7, 56; 7, 77; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 13; 10, pattern_list; 10,... | def _rowwise_unsorted_segment_sum(values, indices, n):
batch, k = tf.unstack(tf.shape(indices), num=2)
indices_flat = tf.reshape(indices, [-1]) + tf.div(tf.range(batch * k), k) * n
ret_flat = tf.unsorted_segment_sum(
tf.reshape(values, [-1]), indices_flat, batch * n)
return tf.reshape(ret_flat, [batch, n]... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_get_sorted_inputs; 3, parameters; 3, 4; 3, 5; 4, identifier:filename; 5, default_parameter; 5, 6; 5, 7; 6, identifier:delimiter; 7, string:"\n"; 8, block; 8, 9; 8, 18; 8, 75; 8, 98; 8, 113; 8, 117; 8, 121; 8, 147; 9, expression_statement; 9, 1... | def _get_sorted_inputs(filename, delimiter="\n"):
tf.logging.info("Getting sorted inputs")
with tf.gfile.Open(filename) as f:
text = f.read()
records = text.split(delimiter)
inputs = [record.strip() for record in records]
if not inputs[-1]:
inputs.pop()
input_lens = [(i, -len(line.split())) ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:sort_batch_by_length; 3, parameters; 3, 4; 3, 10; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:tensor; 6, type; 6, 7; 7, attribute; 7, 8; 7, 9; 8, identifier:torch; 9, identifier:Tensor; 10, typed_parameter; 10, 11; 10, 12; 11, identifier:seq... | def sort_batch_by_length(tensor: torch.Tensor, sequence_lengths: torch.Tensor):
if not isinstance(tensor, torch.Tensor) or not isinstance(sequence_lengths, torch.Tensor):
raise ConfigurationError("Both the tensor and sequence lengths must be torch.Tensors.")
sorted_sequence_lengths, permutation_index = ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 1, 15; 2, function_name:render_config; 3, parameters; 3, 4; 3, 8; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:config; 6, type; 6, 7; 7, identifier:Config; 8, typed_default_parameter; 8, 9; 8, 10; 8, 12; 9, identifier:indent; 10, type; 10, 11; 11, identifier:... | def render_config(config: Config, indent: str = "") -> str:
new_indent = indent + " "
return "".join([
"{\n",
f'{new_indent}"type": "{config.typ3}",\n' if config.typ3 else '',
"".join(_render(item, new_indent) for item in config.items),
indent,
"}\n... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 54; 2, function_name:sort_and_run_forward; 3, parameters; 3, 4; 3, 5; 3, 33; 3, 39; 3, 45; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:module; 7, type; 7, 8; 8, generic_type; 8, 9; 8, 10; 9, identifier:Callable; 10, type_parameter; 10, 11; 10... | def sort_and_run_forward(self,
module: Callable[[PackedSequence, Optional[RnnState]],
Tuple[Union[PackedSequence, torch.Tensor], RnnState]],
inputs: torch.Tensor,
mask: torch.Tensor,
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 1, 25; 2, function_name:_get_initial_states; 3, parameters; 3, 4; 3, 5; 3, 9; 3, 13; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:batch_size; 7, type; 7, 8; 8, identifier:int; 9, typed_parameter; 9, 10; 9, 11; 10, identifier:num_valid; 11,... | def _get_initial_states(self,
batch_size: int,
num_valid: int,
sorting_indices: torch.LongTensor) -> Optional[RnnState]:
if self._states is None:
return None
if batch_size > self._states[0].size(1):
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 1, 17; 2, function_name:_update_states; 3, parameters; 3, 4; 3, 5; 3, 9; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:final_states; 7, type; 7, 8; 8, identifier:RnnStateStorage; 9, typed_parameter; 9, 10; 9, 11; 10, identifier:restoration_... | def _update_states(self,
final_states: RnnStateStorage,
restoration_indices: torch.LongTensor) -> None:
new_unsorted_states = [state.index_select(1, restoration_indices)
for state in final_states]
if self._states is None:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 1, 27; 2, function_name:_prune_beam; 3, parameters; 3, 4; 3, 12; 3, 16; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:states; 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:State; 12, ... | def _prune_beam(states: List[State],
beam_size: int,
sort_states: bool = False) -> List[State]:
states_by_batch_index: Dict[int, List[State]] = defaultdict(list)
for state in states:
assert len(state.batch_indices) == 1
batch_index = state.... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 1, 29; 2, function_name:take_step; 3, parameters; 3, 4; 3, 5; 3, 9; 3, 14; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:state; 7, type; 7, 8; 8, identifier:StateType; 9, typed_default_parameter; 9, 10; 9, 11; 9, 13; 10, identifier:max_acti... | def take_step(self,
state: StateType,
max_actions: int = None,
allowed_actions: List[Set] = None) -> List[StateType]:
raise NotImplementedError |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:row_sparse_pull; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:key; 6, default_parameter; 6, 7; 6, 8; 7, identifier:out; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:priority; 11, integer:0; 12,... | def row_sparse_pull(self, key, out=None, priority=0, row_ids=None):
assert(out is not None)
assert(row_ids is not None)
if isinstance(row_ids, NDArray):
row_ids = [row_ids]
assert(isinstance(row_ids, list)), \
"row_ids should be NDArray or list of NDArray"
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:row_sparse_array; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:arg1; 5, default_parameter; 5, 6; 5, 7; 6, identifier:shape; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ctx; 10, None; 11, default_parameter; 11, 12; 11, 13... | def row_sparse_array(arg1, shape=None, ctx=None, dtype=None):
if isinstance(arg1, tuple):
arg_len = len(arg1)
if arg_len < 2:
raise ValueError("Unexpected length of input tuple: " + str(arg_len))
elif arg_len > 2:
_check_shape(arg1, shape)
return empty('ro... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 22; 5, 44; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:beams; 9, list_comprehension; 9, 10; 9, 11; 10, identifier:v; 11, for_in_clause; 11, 12; 11, 15... | def sort(self):
beams = [v for (_, v) in self.entries.items()]
sortedBeams = sorted(beams, reverse=True, key=lambda x: x.prTotal*x.prText)
return [x.labeling for x in sortedBeams] |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:runtime; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:X; 5, identifier:y; 6, identifier:model_generator; 7, identifier:method_name; 8, block; 8, 9; 8, 19; 8, 28; 8, 32; 8, 144; 8, 153; 9, expression_statement; 9, 10; 10, assignment; 10,... | def runtime(X, y, model_generator, method_name):
old_seed = np.random.seed()
np.random.seed(3293)
method_reps = []
for i in range(1):
X_train, X_test, y_train, _ = train_test_split(__toarray(X), y, test_size=100, random_state=i)
model = model_generator()
model.fit(X_train, y_trai... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:local_accuracy; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:X; 5, identifier:y; 6, identifier:model_generator; 7, identifier:method_name; 8, block; 8, 9; 8, 100; 8, 128; 9, function_definition; 9, 10; 9, 11; 9, 14; 10, function_name:sc... | def local_accuracy(X, y, model_generator, method_name):
def score_map(true, pred):
v = min(1.0, np.std(pred - true) / (np.std(true) + 1e-8))
if v < 1e-6:
return 1.0
elif v < 0.01:
return 0.9
elif v < 0.05:
return 0.75
elif v < 0.1:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_checkpoints_for_actor; 3, parameters; 3, 4; 4, identifier:actor_id; 5, block; 5, 6; 5, 19; 5, 26; 5, 48; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:checkpoint_info; 9, call; 9, 10; 9, 17; 10, attribute; 10, 11; ... | def get_checkpoints_for_actor(actor_id):
checkpoint_info = ray.worker.global_state.actor_checkpoint_info(actor_id)
if checkpoint_info is None:
return []
checkpoints = [
Checkpoint(checkpoint_id, timestamp) for checkpoint_id, timestamp in
zip(checkpoint_info["CheckpointIds"], checkpoi... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_naturalize; 3, parameters; 3, 4; 4, identifier:string; 5, block; 5, 6; 5, 16; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:splits; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:re; 12, identifi... | def _naturalize(string):
splits = re.split("([0-9]+)", string)
return [int(text) if text.isdigit() else text.lower() for text in splits] |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:mount; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:prefix; 6, identifier:adapter; 7, block; 7, 8; 7, 16; 7, 36; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 15; 10, subscript; 10, 11; 10, 14; 11, attribute; 11,... | def mount(self, prefix, adapter):
self.adapters[prefix] = adapter
keys_to_move = [k for k in self.adapters if len(k) < len(prefix)]
for key in keys_to_move:
self.adapters[key] = self.adapters.pop(key) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sorted_outrows; 3, parameters; 3, 4; 4, identifier:outrows; 5, block; 5, 6; 6, return_statement; 6, 7; 7, call; 7, 8; 7, 9; 8, identifier:sorted; 9, argument_list; 9, 10; 9, 11; 10, identifier:outrows; 11, keyword_argument; 11, 12; 11, 13; 12, ... | def sorted_outrows(outrows):
return sorted(outrows, key=lambda row: tuple(str(x) for x in row)) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:traceParseAction; 3, parameters; 3, 4; 4, identifier:f; 5, block; 5, 6; 5, 13; 5, 123; 5, 137; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:f; 9, call; 9, 10; 9, 11; 10, identifier:_trim_arity; 11, argument_list; 11, ... | def traceParseAction(f):
f = _trim_arity(f)
def z(*paArgs):
thisFunc = f.__name__
s,l,t = paArgs[-3:]
if len(paArgs)>3:
thisFunc = paArgs[0].__class__.__name__ + '.' + thisFunc
sys.stderr.write( ">>entering %s(line: '%s', %d, %r)\n" % (thisFunc,line(l,s),l,t) )
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sorted_tree; 3, parameters; 3, 4; 4, identifier:tree; 5, block; 5, 6; 6, return_statement; 6, 7; 7, call; 7, 8; 7, 9; 8, identifier:OrderedDict; 9, argument_list; 9, 10; 10, call; 10, 11; 10, 12; 11, identifier:sorted; 12, argument_list; 12, 13... | def sorted_tree(tree):
return OrderedDict(sorted([(k, sorted(v, key=attrgetter('key')))
for k, v in tree.items()],
key=lambda kv: kv[0].key)) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:do_sort; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:environment; 5, identifier:value; 6, default_parameter; 6, 7; 6, 8; 7, identifier:reverse; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:case_sensitive; 11, Fa... | def do_sort(
environment, value, reverse=False, case_sensitive=False, attribute=None
):
key_func = make_attrgetter(
environment, attribute,
postprocess=ignore_case if not case_sensitive else None
)
return sorted(value, key=key_func, reverse=reverse) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sorted; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:wantdirs; 7, False; 8, block; 8, 9; 8, 62; 8, 71; 8, 101; 9, function_definition; 9, 10; 9, 11; 9, 14; 10, function_name:add_dir; 11, paramet... | def sorted(self, wantdirs=False):
def add_dir(dirs, d):
dirs.add(d)
logger.debug('add_dir added %s', d)
if d != self.base:
parent, _ = os.path.split(d)
assert parent not in ('', '/')
add_dir(dirs, parent)
result = set(se... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:next_event_indexer; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:all_dates; 5, identifier:data_query_cutoff; 6, identifier:all_sids; 7, identifier:event_dates; 8, identifier:event_timestamps; 9, identifier:event_sids; 10, b... | def next_event_indexer(all_dates,
data_query_cutoff,
all_sids,
event_dates,
event_timestamps,
event_sids):
validate_event_metadata(event_dates, event_timestamps, event_sids)
out = np.full((len(all_... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:previous_event_indexer; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:data_query_cutoff_times; 5, identifier:all_sids; 6, identifier:event_dates; 7, identifier:event_timestamps; 8, identifier:event_sids; 9, block; 9, 10; 9, 17; 9, ... | def previous_event_indexer(data_query_cutoff_times,
all_sids,
event_dates,
event_timestamps,
event_sids):
validate_event_metadata(event_dates, event_timestamps, event_sids)
out = np.full(
(len(dat... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:last_in_date_group; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 4, identifier:df; 5, identifier:data_query_cutoff_times; 6, identifier:assets; 7, default_parameter; 7, 8; 7, 9; 8, identifier:reindex; 9, True; 10, default_parameter; 10... | def last_in_date_group(df,
data_query_cutoff_times,
assets,
reindex=True,
have_sids=True,
extra_groupers=None):
idx = [data_query_cutoff_times[data_query_cutoff_times.searchsorted(
df[TS_FIELD_... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:risk_metric_period; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:cls; 5, identifier:start_session; 6, identifier:end_session; 7, identifier:algorithm_returns; 8, identifier:benchmark_returns; 9, identifier:algorithm_leverag... | def risk_metric_period(cls,
start_session,
end_session,
algorithm_returns,
benchmark_returns,
algorithm_leverages):
algorithm_returns = algorithm_returns[
(algorithm... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_last_data_per_qtr; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:assets_with_data; 6, identifier:columns; 7, identifier:dates; 8, identifier:data_query_cutoff_times; 9, block; 9, 10; 9, 28; 9, 34; 9, 43; 9, ... | def get_last_data_per_qtr(self,
assets_with_data,
columns,
dates,
data_query_cutoff_times):
last_per_qtr = last_in_date_group(
self.estimates,
data_query_cutoff_times,
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_zeroth_quarter_idx; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:stacked_last_per_qtr; 6, block; 6, 7; 6, 44; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:previous_releases_per_date; 10, call; 10,... | def get_zeroth_quarter_idx(self, stacked_last_per_qtr):
previous_releases_per_date = stacked_last_per_qtr.loc[
stacked_last_per_qtr[EVENT_DATE_FIELD_NAME] <=
stacked_last_per_qtr.index.get_level_values(SIMULATION_DATES)
].groupby(
level=[SIMULATION_DATES, SID_FIELD_NA... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:rank; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:method; 7, string:'ordinal'; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ascending; 10, True; 11, default_parameter; ... | def rank(self,
method='ordinal',
ascending=True,
mask=NotSpecified,
groupby=NotSpecified):
if groupby is NotSpecified:
return Rank(self, method=method, ascending=ascending, mask=mask)
return GroupedRowTransform(
transform=rankda... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:find_in_sorted_index; 3, parameters; 3, 4; 3, 5; 4, identifier:dts; 5, identifier:dt; 6, block; 6, 7; 6, 16; 6, 45; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:ix; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11... | def find_in_sorted_index(dts, dt):
ix = dts.searchsorted(dt)
if ix == len(dts) or dts[ix] != dt:
raise LookupError("{dt} is not in {dts}".format(dt=dt, dts=dts))
return ix |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:nearest_unequal_elements; 3, parameters; 3, 4; 3, 5; 4, identifier:dts; 5, identifier:dt; 6, block; 6, 7; 6, 18; 6, 29; 6, 40; 6, 52; 6, 70; 6, 114; 6, 125; 6, 139; 7, if_statement; 7, 8; 7, 12; 8, not_operator; 8, 9; 9, attribute; 9, 10; 9, 11... | def nearest_unequal_elements(dts, dt):
if not dts.is_unique:
raise ValueError("dts must be unique")
if not dts.is_monotonic_increasing:
raise ValueError("dts must be sorted in increasing order")
if not len(dts):
return None, None
sortpos = dts.searchsorted(dt, side='left')
tr... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:date_sorted_sources; 3, parameters; 3, 4; 4, list_splat_pattern; 4, 5; 5, identifier:sources; 6, block; 6, 7; 6, 24; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:sorted_stream; 10, call; 10, 11; 10, 14; 11, attribute... | def date_sorted_sources(*sources):
sorted_stream = heapq.merge(*(_decorate_source(s) for s in sources))
for _, message in sorted_stream:
yield message |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:execution_order; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:refcounts; 6, block; 6, 7; 7, return_statement; 7, 8; 8, call; 8, 9; 8, 10; 9, identifier:iter; 10, argument_list; 10, 11; 11, call; 11, 12; 11, 15; 12, attribute; 12... | def execution_order(self, refcounts):
return iter(nx.topological_sort(
self.graph.subgraph(
{term for term, refcount in refcounts.items() if refcount > 0},
),
)) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 1, 11; 2, function_name:parse; 3, parameters; 3, 4; 3, 5; 4, identifier:cls; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:headers; 7, type; 7, 8; 8, identifier:str; 9, type; 9, 10; 10, string:"HTTPHeaders"; 11, block; 11, 12; 11, 18; 11, 37; 12, expression_sta... | def parse(cls, headers: str) -> "HTTPHeaders":
h = cls()
for line in _CRLF_RE.split(headers):
if line:
h.parse_line(line)
return h |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:lovasz_grad; 3, parameters; 3, 4; 4, identifier:gt_sorted; 5, block; 5, 6; 5, 13; 5, 21; 5, 36; 5, 54; 5, 62; 5, 89; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:p; 9, call; 9, 10; 9, 11; 10, identifier:len; 11, argum... | def lovasz_grad(gt_sorted):
p = len(gt_sorted)
gts = gt_sorted.sum()
intersection = gts - gt_sorted.float().cumsum(0)
union = gts + (1 - gt_sorted).float().cumsum(0)
jaccard = 1. - intersection / union
if p > 1:
jaccard[1:p] = jaccard[1:p] - jaccard[0:-1]
return jaccard |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 41; 2, function_name:merge; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 3, 27; 3, 32; 3, 35; 3, 38; 4, identifier:left; 5, identifier:right; 6, default_parameter; 6, 7; 6, 8; 7, identifier:how; 8, string:"inner"; 9, default_parameter;... | def merge(
left,
right,
how="inner",
on=None,
left_on=None,
right_on=None,
left_index=False,
right_index=False,
sort=False,
suffixes=("_x", "_y"),
copy=True,
indicator=False,
validate=None,
):
if not isinstance(left, DataFrame):
raise ValueError(
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:copartition; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:self; 5, identifier:axis; 6, identifier:other; 7, identifier:how_to_join; 8, identifier:sort; 9, default_parameter; 9, 10; 9, 11; 10, identifier:force_repartition; 1... | def copartition(self, axis, other, how_to_join, sort, force_repartition=False):
if isinstance(other, type(self)):
other = [other]
index_obj = (
[o.index for o in other] if axis == 0 else [o.columns for o in other]
)
joined_index = self._join_index_objects(
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:sort_index; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 18; 7, 29; 7, 39; 7, 48; 7, 54; 7, 89; 7, 100; 7, 110; 7, 161; 8, expression_statement; 8, 9; 9, assignment; ... | def sort_index(self, **kwargs):
axis = kwargs.pop("axis", 0)
index = self.columns if axis else self.index
ascending = kwargs.pop("ascending", True)
if ascending is None:
ascending = False
kwargs["ascending"] = ascending
def sort_index_builder(df, **kwargs):
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sample_row_keys; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 16; 5, 32; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:data_client; 9, attribute; 9, 10; 9, 15; 10, attribute; 10, 11; 10, 14; 11, attribut... | def sample_row_keys(self):
data_client = self._instance._client.table_data_client
response_iterator = data_client.sample_row_keys(
self.name, app_profile_id=self._app_profile_id
)
return response_iterator |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 53; 2, function_name:search_profiles; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 3, 25; 3, 28; 3, 39; 3, 50; 4, identifier:self; 5, identifier:parent; 6, identifier:request_metadata; 7, default_parameter; 7, 8; 7, 9; 8, identifier:pr... | def search_profiles(
self,
parent,
request_metadata,
profile_query=None,
page_size=None,
offset=None,
disable_spell_check=None,
order_by=None,
case_sensitive_sort=None,
histogram_queries=None,
retry=google.api_core.gapic_v1.method.D... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 68; 2, function_name:search_jobs; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 3, 25; 3, 28; 3, 31; 3, 34; 3, 37; 3, 40; 3, 43; 3, 54; 3, 65; 4, identifier:self; 5, identifier:parent; 6, identifier:request_metadata; 7, default_paramete... | def search_jobs(
self,
parent,
request_metadata,
search_mode=None,
job_query=None,
enable_broadening=None,
require_precise_result_size=None,
histogram_queries=None,
job_view=None,
offset=None,
page_size=None,
order_by=None,
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 46; 2, function_name:list_findings; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 32; 3, 43; 4, identifier:self; 5, identifier:parent; 6, default_parameter; 6, 7; 6, 8; 7, identifier:filter_; 8, None; 9, default_parameter; 9, 10; 9, 11; 10,... | def list_findings(
self,
parent,
filter_=None,
order_by=None,
read_time=None,
field_mask=None,
page_size=None,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None,
):
if ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 49; 2, function_name:list_traces; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 3, 35; 3, 46; 4, identifier:self; 5, identifier:project_id; 6, default_parameter; 6, 7; 6, 8; 7, identifier:view; 8, None; 9, default_parameter; 9, 10; 9, 1... | def list_traces(
self,
project_id,
view=None,
page_size=None,
start_time=None,
end_time=None,
filter_=None,
order_by=None,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:order; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:value; 6, block; 6, 7; 6, 19; 7, if_statement; 7, 8; 7, 13; 8, call; 8, 9; 8, 10; 9, identifier:isinstance; 10, argument_list; 10, 11; 10, 12; 11, identifier:value; 12, identif... | def order(self, value):
if isinstance(value, str):
value = [value]
self._order[:] = value |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_canonical_headers; 3, parameters; 3, 4; 4, identifier:headers; 5, block; 5, 6; 5, 33; 5, 41; 5, 50; 5, 91; 5, 114; 5, 128; 6, if_statement; 6, 7; 6, 10; 6, 15; 7, comparison_operator:is; 7, 8; 7, 9; 8, identifier:headers; 9, None; 10, block... | def get_canonical_headers(headers):
if headers is None:
headers = []
elif isinstance(headers, dict):
headers = list(headers.items())
if not headers:
return [], []
normalized = collections.defaultdict(list)
for key, val in headers:
key = key.lower().strip()
val... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_sorted_resource_labels; 3, parameters; 3, 4; 4, identifier:labels; 5, block; 5, 6; 5, 18; 5, 32; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:head; 9, list_comprehension; 9, 10; 9, 11; 9, 14; 10, identifier:label; 11... | def _sorted_resource_labels(labels):
head = [label for label in TOP_RESOURCE_LABELS if label in labels]
tail = sorted(label for label in labels if label not in TOP_RESOURCE_LABELS)
return head + tail |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 45; 2, function_name:partition_read; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 31; 3, 42; 4, identifier:self; 5, identifier:session; 6, identifier:table; 7, identifier:key_set; 8, default_parameter; 8, 9; 8, 10; 9, identifier:tran... | def partition_read(
self,
session,
table,
key_set,
transaction=None,
index=None,
columns=None,
partition_options=None,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None,
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 50; 2, function_name:list_documents; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 3, 25; 3, 36; 3, 47; 4, identifier:self; 5, identifier:parent; 6, identifier:collection_id; 7, default_parameter; 7, 8; 7, 9; 8, identifier:page_size; 9,... | def list_documents(
self,
parent,
collection_id,
page_size=None,
order_by=None,
mask=None,
transaction=None,
read_time=None,
show_missing=None,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_core.gapic_v1.method.D... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:predict; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:dataset; 6, default_parameter; 6, 7; 6, 8; 7, identifier:output_type; 8, string:'class'; 9, default_parameter; 9, 10; 9, 11; 10, identifier:missing_value_action;... | def predict(self, dataset, output_type='class', missing_value_action='auto'):
_check_categorical_option_type('output_type', output_type,
['class', 'margin', 'probability', 'probability_vector'])
return super(_Classifier, self).predict(dataset,
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_sort_topk_votes; 3, parameters; 3, 4; 3, 5; 4, identifier:x; 5, identifier:k; 6, block; 6, 7; 6, 33; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:y; 10, subscript; 10, 11; 10, 30; 11, call; 11, 12; 11, 13; 12, ident... | def _sort_topk_votes(x, k):
y = sorted(x.items(), key=lambda x: x[1], reverse=True)[:k]
return [{'class': i[0], 'votes': i[1]} for i in y] |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:sort; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:key_column_names; 6, default_parameter; 6, 7; 6, 8; 7, identifier:ascending; 8, True; 9, block; 9, 10; 9, 14; 9, 18; 9, 141; 9, 158; 9, 169; 9, 226; 10, expression_stateme... | def sort(self, key_column_names, ascending=True):
sort_column_names = []
sort_column_orders = []
if (type(key_column_names) == str):
sort_column_names = [key_column_names]
elif (type(key_column_names) == list):
if (len(key_column_names) == 0):
rais... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:MakeSimpleProtoClass; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:fields; 5, default_parameter; 5, 6; 5, 7; 6, identifier:full_name; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:pool; 10, None; 11, block; 11, 12; 11, 23; 11, 44... | def MakeSimpleProtoClass(fields, full_name=None, pool=None):
factory = message_factory.MessageFactory(pool=pool)
if full_name is not None:
try:
proto_cls = _GetMessageFromFactory(factory, full_name)
return proto_cls
except KeyError:
pass
field_items = fields.items()
if not isinstance(f... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:value_counts; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 15; 6, import_from_statement; 6, 7; 6, 11; 7, relative_import; 7, 8; 7, 9; 8, import_prefix; 9, dotted_name; 9, 10; 10, identifier:sframe; 11, aliased_import; 11, 12; 11,... | def value_counts(self):
from .sframe import SFrame as _SFrame
return _SFrame({'value':self}).groupby('value', {'count':_aggregate.COUNT}).sort('count', ascending=False) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sort; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ascending; 7, True; 8, block; 8, 9; 8, 18; 8, 36; 8, 42; 8, 48; 9, import_from_statement; 9, 10; 9, 14; 10, relative_import; 10, 11; 10, 12; 11... | def sort(self, ascending=True):
from .sframe import SFrame as _SFrame
if self.dtype not in (int, float, str, datetime.datetime):
raise TypeError("Only sarray with type (int, float, str, datetime.datetime) can be sorted")
sf = _SFrame()
sf['a'] = self
return sf.sort('a... |
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:dataset; 6, default_parameter; 6, 7; 6, 8; 7, identifier:output_type; 8, string:'class'; 9, block; 9, 10; 9, 18; 9, 26; 9, 30; 10, expression_statement; 10, 11; 11, ass... | def predict(self, dataset, output_type='class'):
m = self.__proxy__['classifier']
target = self.__proxy__['target']
f = _BOW_FEATURE_EXTRACTOR
return m.predict(f(dataset, target), output_type=output_type) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:format_json; 3, parameters; 3, 4; 3, 5; 4, identifier:event; 5, identifier:colored; 6, block; 6, 7; 6, 48; 7, try_statement; 7, 8; 7, 44; 8, block; 8, 9; 9, if_statement; 9, 10; 9, 18; 10, call; 10, 11; 10, 16; 11, attribute; 11, 12; 11, 15; 12... | def format_json(event, colored):
try:
if event.message.startswith("{"):
msg_dict = json.loads(event.message)
event.message = json.dumps(msg_dict, indent=2)
except Exception:
pass
return event |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:explain_instance_with_data; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 13; 4, identifier:self; 5, identifier:neighborhood_data; 6, identifier:neighborhood_labels; 7, identifier:distances; 8, identifier:label; 9, identifier:nu... | def explain_instance_with_data(self,
neighborhood_data,
neighborhood_labels,
distances,
label,
num_features,
f... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:serialize_json; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:obj; 5, default_parameter; 5, 6; 5, 7; 6, identifier:pretty; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:indent; 10, None; 11, dictionary_splat_pattern; 11, 12... | def serialize_json(obj, pretty=None, indent=None, **kwargs):
''' Return a serialized JSON representation of objects, suitable to
send to BokehJS.
This function is typically used to serialize single python objects in
the manner expected by BokehJS. In particular, many datetime values are
automaticall... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_item_children; 3, parameters; 3, 4; 4, identifier:item; 5, block; 5, 6; 5, 26; 5, 49; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:children; 9, list_comprehension; 9, 10; 9, 16; 10, call; 10, 11; 10, 14; 11, attri... | def get_item_children(item):
children = [item.child(index) for index in range(item.childCount())]
for child in children[:]:
others = get_item_children(child)
if others is not None:
children += others
return sorted(children, key=lambda child: child.line) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:__sort_toplevel_items; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 34; 5, 93; 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:show_all_fi... | def __sort_toplevel_items(self):
if self.show_all_files is False:
return
current_ordered_items = [self.topLevelItem(index) for index in
range(self.topLevelItemCount())]
if self.sort_files_alphabetically:
new_ordered_items = sorted(
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sortByColumn; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:index; 6, block; 6, 7; 6, 24; 6, 34; 6, 42; 6, 96; 7, if_statement; 7, 8; 7, 14; 8, comparison_operator:==; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:self;... | def sortByColumn(self, index):
if self.sort_old == [None]:
self.header_class.setSortIndicatorShown(True)
sort_order = self.header_class.sortIndicatorOrder()
self.sig_sort_by_column.emit()
if not self.model().sort(index, sort_order):
if len(self.sort_old) != ... |
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:column; 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, column, order=Qt.AscendingOrder):
ascending = order == Qt.AscendingOrder
self.model.sort(self.COLUMN_INDEX, order=ascending)
return True |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sortByIndex; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:index; 6, block; 6, 7; 6, 20; 6, 34; 6, 48; 7, expression_statement; 7, 8; 8, call; 8, 9; 8, 18; 9, attribute; 9, 10; 9, 17; 10, call; 10, 11; 10, 16; 11, attribute; 11, ... | def sortByIndex(self, index):
self.table_level.horizontalHeader().setSortIndicatorShown(True)
sort_order = self.table_level.horizontalHeader().sortIndicatorOrder()
self.table_index.model().sort(index, sort_order)
self._sort_update() |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_file_tabs_alphabetically; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, while_statement; 6, 7; 6, 14; 7, comparison_operator:is; 7, 8; 7, 13; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, identifi... | def sort_file_tabs_alphabetically(self):
while self.sorted() is False:
for i in range(0, self.tabs.tabBar().count()):
if(self.tabs.tabBar().tabText(i) >
self.tabs.tabBar().tabText(i + 1)):
self.tabs.tabBar().moveTab(i, i + 1) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_top_level_items; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:key; 6, block; 6, 7; 6, 13; 6, 39; 6, 56; 7, expression_statement; 7, 8; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, identifier:sa... | def sort_top_level_items(self, key):
self.save_expanded_state()
items = sorted([self.takeTopLevelItem(0)
for index in range(self.topLevelItemCount())], key=key)
for index, item in enumerate(items):
self.insertTopLevelItem(index, item)
self.restor... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:set_sorting; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:flag; 6, block; 6, 7; 6, 15; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 14; 9, subscript; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12... | def set_sorting(self, flag):
self.sorting['status'] = flag
self.header().setSectionsClickable(flag == ON) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:set_filter; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:text; 6, block; 6, 7; 6, 16; 6, 41; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, identifier:pattern; 12,... | def set_filter(self, text):
self.pattern = get_search_regex(text)
if self.pattern:
self._parent.setSortingEnabled(False)
else:
self._parent.setSortingEnabled(True)
self.invalidateFilter() |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_get_content_hash; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 12; 5, 16; 5, 33; 5, 56; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:content; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, identi... | def _get_content_hash(self):
content = self._local_config
relevant_content = {}
for key in self._relevant_keys:
relevant_content[key] = content.get(key)
content_hash = sha256(
json.dumps(relevant_content, sort_keys=True).encode()
).hexdigest()
retu... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:missing_datetimes; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:finite_datetimes; 6, block; 6, 7; 7, return_statement; 7, 8; 8, list_comprehension; 8, 9; 8, 10; 8, 13; 9, identifier:d; 10, for_in_clause; 10, 11; 10, 12; 11, iden... | def missing_datetimes(self, finite_datetimes):
return [d for d in finite_datetimes if not self._instantiate_task_cls(self.datetime_to_parameter(d)).complete()] |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_partition_tasks; 3, parameters; 3, 4; 4, identifier:worker; 5, block; 5, 6; 5, 12; 5, 27; 5, 31; 5, 52; 5, 79; 5, 96; 5, 108; 5, 125; 5, 157; 5, 188; 5, 196; 5, 204; 5, 212; 5, 220; 5, 228; 5, 236; 6, expression_statement; 6, 7; 7, assignment;... | def _partition_tasks(worker):
task_history = worker._add_task_history
pending_tasks = {task for(task, status, ext) in task_history if status == 'PENDING'}
set_tasks = {}
set_tasks["completed"] = {task for (task, status, ext) in task_history if status == 'DONE' and task in pending_tasks}
set_tasks["a... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.