sequence stringlengths 1.19k 35k | code stringlengths 75 8.58k |
|---|---|
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def sort(self, cmp=None, key=None, reverse=False):
if not key and self._keys:
key = self.KeyValue
super(CliTable, self).sort(cmp=cmp, key=key, reverse=reverse) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def sort(self, cmp=None, key=None, reverse=False):
def _DefaultKey(value):
result = []
for key in self.header:
try:
result.append(float(value[key]))
except ValueError:
result.append(value[key])
return res... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_order'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'graph'... | def find_order(graph):
'''
Do a topological sort on the dependency graph dict.
'''
while graph:
leftmost = [l for l, s in graph.items() if not s]
if not leftmost:
raise ValueError('Dependency cycle detected! %s' % graph)
leftmost.sort()
for result in leftmost:... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'do_sort'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'valu... | def do_sort(value, case_sensitive=False):
if not case_sensitive:
def sort_func(item):
if isinstance(item, basestring):
item = item.lower()
return item
else:
sort_func = None
return sorted(seq, key=sort_func) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dedupe'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | def dedupe(contains_dupes, threshold=70, scorer=fuzz.token_set_ratio):
extractor = []
for item in contains_dupes:
matches = extract(item, contains_dupes, limit=None, scorer=scorer)
filtered = [x for x in matches if x[1] > threshold]
if len(filtered) == 1:
extractor.append(fil... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_process_and_sort'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [],... | def _process_and_sort(s, force_ascii, full_process=True):
ts = utils.full_process(s, force_ascii=force_ascii) if full_process else s
tokens = ts.split()
sorted_string = u" ".join(sorted(tokens))
return sorted_string.strip() |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'token_sort_ratio'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children'... | def token_sort_ratio(s1, s2, force_ascii=True, full_process=True):
return _token_sort(s1, s2, partial=False, force_ascii=force_ascii, full_process=full_process) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'partial_token_sort_ratio'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'c... | def partial_token_sort_ratio(s1, s2, force_ascii=True, full_process=True):
return _token_sort(s1, s2, partial=True, force_ascii=force_ascii, full_process=full_process) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'WRatio'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | def WRatio(s1, s2, force_ascii=True, full_process=True):
if full_process:
p1 = utils.full_process(s1, force_ascii=force_ascii)
p2 = utils.full_process(s2, force_ascii=force_ascii)
else:
p1 = s1
p2 = s2
if not utils.validate_string(p1):
return 0
if not utils.valida... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_depth'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'v... | def sort_depth(vals, reverse=False):
lst = [[float(price), quantity] for price, quantity in vals.items()]
lst = sorted(lst, key=itemgetter(0), reverse=reverse)
return lst |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_fields'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [],... | def _get_fields(attrs, field_class, pop=False, ordered=False):
fields = [
(field_name, field_value)
for field_name, field_value in iteritems(attrs)
if is_instance_or_subclass(field_value, field_class)
]
if pop:
for field_name, _ in fields:
del attrs[field_name]
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '66']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'extract_features'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20', '23', '28', '33', '38', '43... | def extract_features(timeseries_container, default_fc_parameters=None,
kind_to_fc_parameters=None,
column_id=None, column_sort=None, column_kind=None, column_value=None,
chunksize=defaults.CHUNKSIZE,
n_jobs=defaults.N_PROCESSES, show_wa... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'convert_to_output_format'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | def convert_to_output_format(param):
def add_parenthesis_if_string_value(x):
if isinstance(x, string_types):
return '"' + str(x) + '"'
else:
return str(x)
return "__".join(str(key) + "_" + add_parenthesis_if_string_value(param[key]) for key in sorted(param.keys())) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'end_profiling'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | def end_profiling(profiler, filename, sorting=None):
profiler.disable()
s = six.StringIO()
ps = pstats.Stats(profiler, stream=s).sort_stats(sorting)
ps.print_stats()
with open(filename, "w+") as f:
_logger.info("[calculate_ts_features] Finished profiling of time series feature extraction")
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '95']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'extract_relevant_features'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18', '21', '24', '27', '... | def extract_relevant_features(timeseries_container, y, X=None,
default_fc_parameters=None,
kind_to_fc_parameters=None,
column_id=None, column_sort=None, column_kind=None, column_value=None,
show_warni... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'user_agents'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | def user_agents(self):
return (self.get_query()
.select(
PageView.headers['User-Agent'],
fn.Count(PageView.id))
.group_by(PageView.headers['User-Agent'])
.order_by(fn.Count(PageView.id).desc())
.tuples()) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'languages'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'},... | def languages(self):
language = PageView.headers['Accept-Language']
first_language = fn.SubStr(
language,
1,
fn.StrPos(language, ';'))
return (self.get_query()
.select(first_language, fn.Count(PageView.id))
.group_by(first_langu... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'error_router'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | def error_router(self, original_handler, e):
if self._has_fr_route():
try:
return self.handle_error(e)
except Exception:
pass
return original_handler(e) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'smooth_knn_dist'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier', 'chil... | def smooth_knn_dist(distances, k, n_iter=64, local_connectivity=1.0, bandwidth=1.0):
target = np.log2(k) * bandwidth
rho = np.zeros(distances.shape[0])
result = np.zeros(distances.shape[0])
for i in range(distances.shape[0]):
lo = 0.0
hi = NPY_INFINITY
mid = 1.0
ith_dista... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_visible_units'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | def _visible_units(self):
for u in sorted(self._obs.observation.raw_data.units,
key=lambda u: (u.pos.z, u.owner != 16, -u.radius, u.tag)):
yield u, point.Point.build(u.pos) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '19']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'interp'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17']}; {'id': '4', 'type': 'identifier', 'childr... | def interp(self, coords=None, method='linear', assume_sorted=False,
kwargs={}, **coords_kwargs):
if self.dtype.kind not in 'uifc':
raise TypeError('interp only works for a numeric type array. '
'Given {}.'.format(self.dtype))
ds = self._to_temp_data... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'interp_like'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier', 'children... | def interp_like(self, other, method='linear', assume_sorted=False,
kwargs={}):
if self.dtype.kind not in 'uifc':
raise TypeError('interp only works for a numeric type array. '
'Given {}.'.format(self.dtype))
ds = self._to_temp_dataset().interp_... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'is_uniform_spaced'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [],... | def is_uniform_spaced(arr, **kwargs) -> bool:
arr = np.array(arr, dtype=float)
diffs = np.diff(arr)
return bool(np.isclose(diffs.min(), diffs.max(), **kwargs)) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'broadcast_variables'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'list_splat_pattern', 'children': ['5... | def broadcast_variables(*variables):
dims_map = _unified_dims(variables)
dims_tuple = tuple(dims_map)
return tuple(var.set_dims(dims_map) if var.dims != dims_tuple else var
for var in variables) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '19']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'interp'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17']}; {'id': '4', 'type': 'identifier', 'childr... | def interp(self, coords=None, method='linear', assume_sorted=False,
kwargs={}, **coords_kwargs):
from . import missing
coords = either_dict_or_kwargs(coords, coords_kwargs, 'interp')
indexers = OrderedDict(self._validate_indexers(coords))
obj = self if assume_sorted else s... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'interp_like'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier', 'children... | def interp_like(self, other, method='linear', assume_sorted=False,
kwargs={}):
coords = alignment.reindex_like_indexers(self, other)
numeric_coords = OrderedDict()
object_coords = OrderedDict()
for k, v in coords.items():
if v.dtype.kind in 'uifcMm':
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'transpose'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | def transpose(self, *dims):
if dims:
if set(dims) ^ set(self.dims):
raise ValueError('arguments to transpose (%s) must be '
'permuted dataset dimensions (%s)'
% (dims, tuple(self.dims)))
ds = self.copy()
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_dask_dataframe'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': []... | def to_dask_dataframe(self, dim_order=None, set_index=False):
import dask.array as da
import dask.dataframe as dd
if dim_order is None:
dim_order = list(self.dims)
elif set(dim_order) != set(self.dims):
raise ValueError(
'dim_order {} does not matc... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'interp'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def interp(var, indexes_coords, method, **kwargs):
if not indexes_coords:
return var.copy()
if method in ['linear', 'nearest']:
var, indexes_coords = _localize(var, indexes_coords)
kwargs['bounds_error'] = kwargs.get('bounds_error', False)
dims = list(indexes_coords)
x, new_x = zip(*... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'coerce_pandas_values'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | def coerce_pandas_values(objects):
from .dataset import Dataset
from .dataarray import DataArray
out = []
for obj in objects:
if isinstance(obj, Dataset):
variables = obj
else:
variables = OrderedDict()
if isinstance(obj, PANDAS_TYPES):
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'unique_value_groups'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | def unique_value_groups(ar, sort=True):
inverse, values = pd.factorize(ar, sort=sort)
groups = [[] for _ in range(len(values))]
for n, g in enumerate(inverse):
if g >= 0:
groups[g].append(n)
return values, groups |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'order'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'i... | def order(self):
if self.stage:
for st in STAGES:
if st in self.stage:
stage = (STAGES.index(st), self.stage)
break
else:
stage = (len(STAGES),)
return (int(self.major), int(self.minor), int(self.patch)) + stage |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '19']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zadd'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13', '16']}; {'id': '4', 'type': 'identifier', 'chi... | def zadd(self, name, mapping, nx=False, xx=False, ch=False, incr=False):
if not mapping:
raise DataError("ZADD requires at least one element/score pair")
if nx and xx:
raise DataError("ZADD allows either 'nx' or 'xx', not both")
if incr and len(mapping) != 1:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zincrby'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | def zincrby(self, name, amount, value):
"Increment the score of ``value`` in sorted set ``name`` by ``amount``"
return self.execute_command('ZINCRBY', name, amount, value) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zinterstore'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [],... | def zinterstore(self, dest, keys, aggregate=None):
return self._zaggregate('ZINTERSTORE', dest, keys, aggregate) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zlexcount'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | def zlexcount(self, name, min, max):
return self.execute_command('ZLEXCOUNT', name, min, max) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zpopmax'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | def zpopmax(self, name, count=None):
args = (count is not None) and [count] or []
options = {
'withscores': True
}
return self.execute_command('ZPOPMAX', name, *args, **options) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zpopmin'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | def zpopmin(self, name, count=None):
args = (count is not None) and [count] or []
options = {
'withscores': True
}
return self.execute_command('ZPOPMIN', name, *args, **options) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'bzpopmax'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | def bzpopmax(self, keys, timeout=0):
if timeout is None:
timeout = 0
keys = list_or_args(keys, None)
keys.append(timeout)
return self.execute_command('BZPOPMAX', *keys) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'bzpopmin'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | def bzpopmin(self, keys, timeout=0):
if timeout is None:
timeout = 0
keys = list_or_args(keys, None)
keys.append(timeout)
return self.execute_command('BZPOPMIN', *keys) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zremrangebylex'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [... | def zremrangebylex(self, name, min, max):
return self.execute_command('ZREMRANGEBYLEX', name, min, max) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zremrangebyrank'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': ... | def zremrangebyrank(self, name, min, max):
return self.execute_command('ZREMRANGEBYRANK', name, min, max) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'argsort_k_smallest'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | def argsort_k_smallest(x, k):
if k == 0:
return np.array([], dtype=np.intp)
if k is None or k >= len(x):
return np.argsort(x)
indices = np.argpartition(x, k)[:k]
values = x[indices]
return indices[np.argsort(values)] |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'lookup'}, {'id': '3', 'type': 'parameters', 'children': ['4', '8']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}, ... | async def lookup(source_id: str, schema_id: str):
try:
schema = Schema(source_id, '', '', [])
if not hasattr(Schema.lookup, "cb"):
schema.logger.debug("vcx_schema_get_attributes: Creating callback")
Schema.lookup.cb = create_cb(CFUNCTYPE(None, c_uint32, c_... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'interleave_keys'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | def interleave_keys(a, b):
def interleave(args):
return ''.join([x for t in zip(*args) for x in t])
return int(''.join(interleave(format(x, '016b') for x in (a, b))), base=2) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '24']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pool'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '15', '18', '21']}; {'id': '4', 'type': 'identifier', 'chi... | def pool(data, batch_size, key, batch_size_fn=lambda new, count, sofar: count,
random_shuffler=None, shuffle=False, sort_within_batch=False):
if random_shuffler is None:
random_shuffler = random.shuffle
for p in batch(data, batch_size * 100, batch_size_fn):
p_batch = batch(sorted(p, key... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'data'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id... | def data(self):
if self.sort:
xs = sorted(self.dataset, key=self.sort_key)
elif self.shuffle:
xs = [self.dataset[i] for i in self.random_shuffler(range(len(self.dataset)))]
else:
xs = self.dataset
return xs |
{'id': '0', 'type': 'module', 'children': ['1', '302']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'color_table'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17']}; {'id': '4', 'type': 'identifi... | def color_table(color, N=1, sort=False, sort_values=False, inline=False, as_html=False):
if isinstance(color, list):
c_ = ''
rgb_tup = [normalize(c) for c in color]
if sort:
rgb_tup.sort()
elif isinstance(color, dict):
c_ = ''
items = [(k, normalize(v), hex_to... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_nearest_edge'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def get_nearest_edge(G, point):
start_time = time.time()
gdf = graph_to_gdfs(G, nodes=False, fill_edge_geometry=True)
graph_edges = gdf[["geometry", "u", "v"]].values.tolist()
edges_with_distances = [
(
graph_edge,
Point(tuple(reversed(point))).distance(graph_edge[0])
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_http_headers'}, {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10']}; {'id': '4', 'type': 'default_parameter', 'childr... | def get_http_headers(user_agent=None, referer=None, accept_language=None):
if user_agent is None:
user_agent = settings.default_user_agent
if referer is None:
referer = settings.default_referer
if accept_language is None:
accept_language = settings.default_accept_language
headers... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_has_sorted_sa_indices'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [],... | def _has_sorted_sa_indices(s_indices, a_indices):
L = len(s_indices)
for i in range(L-1):
if s_indices[i] > s_indices[i+1]:
return False
if s_indices[i] == s_indices[i+1]:
if a_indices[i] >= a_indices[i+1]:
return False
return True |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_generate_a_indptr'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': []... | def _generate_a_indptr(num_states, s_indices, out):
idx = 0
out[0] = 0
for s in range(num_states-1):
while(s_indices[idx] == s):
idx += 1
out[s+1] = idx
out[num_states] = len(s_indices) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_topologically'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | def sort_topologically(dag):
dag = copy.deepcopy(dag)
sorted_nodes = []
independent_nodes = deque(get_independent_nodes(dag))
while independent_nodes:
node = independent_nodes.popleft()
sorted_nodes.append(node)
downstream_nodes = dag[node]
while downstream_nodes:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'set_topological_dag_upstreams'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier'... | def set_topological_dag_upstreams(dag, ops, op_runs, runs_by_ops):
sorted_ops = dags.sort_topologically(dag=dag)
for op_id in sorted_ops:
op_run_id = runs_by_ops[op_id]
op_run = op_runs[op_run_id]
set_op_upstreams(op_run=op_run, op=ops[op_id]) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'generate_from_text'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | def generate_from_text(self, text):
words = self.process_text(text)
self.generate_from_frequencies(words)
return self |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_update_pods_metrics'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': ... | def _update_pods_metrics(self, instance, pods):
tags_map = defaultdict(int)
for pod in pods['items']:
pod_meta = pod.get('metadata', {})
pod_tags = self.kubeutil.get_pod_creator_tags(pod_meta, legacy_rep_controller_tag=True)
services = self.kubeutil.match_services_for... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_agent_tags'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | def get_agent_tags(since, to):
agent_tags = sorted(parse_version_info(t) for t in git_tag_list(r'^\d+\.\d+\.\d+$'))
if to:
to = parse_version_info(to)
else:
to = agent_tags[-1]
since = parse_version_info(since)
agent_tags = [t for t in agent_tags if since <= t <= to]
return [str(... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | def sort(self, key_or_list, direction=None):
self.__check_okay_to_chain()
keys = helpers._index_list(key_or_list, direction)
self.__ordering = helpers._index_document(keys)
return self |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '23']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_one_and_replace'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13', '16', '21']}; {'id': '4', 'typ... | def find_one_and_replace(self, filter, replacement,
projection=None, sort=None, upsert=False,
return_document=ReturnDocument.BEFORE, **kwargs):
common.validate_ok_for_replace(replacement)
kwargs['update'] = replacement
return self.__find_... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '23']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_one_and_update'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13', '16', '21']}; {'id': '4', 'type... | def find_one_and_update(self, filter, update,
projection=None, sort=None, upsert=False,
return_document=ReturnDocument.BEFORE, **kwargs):
common.validate_ok_for_update(update)
kwargs['update'] = update
return self.__find_and_modify(filter, ... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '26']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'feature_correlation'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18', '21', '24']}; {'id': '4',... | def feature_correlation(X, y, ax=None, method='pearson',
labels=None, sort=False, feature_index=None,
feature_names=None, **kwargs):
viz = FeatureCorrelation(ax, method, labels, sort,
feature_index, feature_names, **kwargs)
viz.fit(X, ... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '29']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dispersion'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18', '21', '24', '27']}; {'id': '4', 't... | def dispersion(words, corpus, y=None, ax=None, colors=None, colormap=None,
labels=None, annotate_docs=False, ignore_case=False, **kwargs):
visualizer = DispersionPlot(
words, ax=ax, colors=colors, colormap=colormap,
ignore_case=ignore_case, labels=labels,
annotate_docs=annotat... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sorted_product_set'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | def sorted_product_set(array_a, array_b):
return np.sort(
np.concatenate(
[array_a[i] * array_b for i in xrange(len(array_a))], axis=0)
)[::-1] |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_sorted_inputs'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | def _get_sorted_inputs(filename):
with tf.gfile.Open(filename) as f:
records = f.read().split("\n")
inputs = [record.strip() for record in records]
if not inputs[-1]:
inputs.pop()
input_lens = [(i, len(line.split())) for i, line in enumerate(inputs)]
sorted_input_lens = sorted(input_lens, key=la... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'games_by_time'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | def games_by_time(self, start_game, end_game):
move_count = b'move_count'
rows = self.bt_table.read_rows(
ROWCOUNT_PREFIX.format(start_game),
ROWCOUNT_PREFIX.format(end_game),
filter_=bigtable_row_filters.ColumnRangeFilter(
METADATA, move_count, move_c... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'bleakest_moves'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | def bleakest_moves(self, start_game, end_game):
bleak = b'bleakest_q'
rows = self.bt_table.read_rows(
ROW_PREFIX.format(start_game),
ROW_PREFIX.format(end_game),
filter_=bigtable_row_filters.ColumnRangeFilter(
METADATA, bleak, bleak))
def parse... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_generate_subtokens'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10']}; {'id': '4', 'type': 'identifier', '... | def _generate_subtokens(
token_counts, alphabet, min_count, num_iterations=4,
reserved_tokens=None):
if reserved_tokens is None:
reserved_tokens = RESERVED_TOKENS
subtoken_list = reserved_tokens + list(alphabet)
max_subtoken_length = 1
for i in xrange(num_iterations):
tf.logging.info("\tGenerati... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sparse_svd'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | def sparse_svd(sparse_matrix, num_values, max_iter):
if num_values <= 0:
raise ValueError("num_values should be > 0 but instead is %d." % num_values)
if max_iter is not None and max_iter < 0:
raise ValueError("max_iter should be >= 0 but instead is %d." % max_iter)
if max_iter is None:
max_iter = FLAG... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'build_collate_fn'}, {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10']}; {'id': '4', 'type': 'default_parameter', 'childr... | def build_collate_fn(batch_first=False, parallel=True, sort=False):
def collate_seq(seq):
lengths = [len(s) for s in seq]
batch_length = max(lengths)
shape = (batch_length, len(seq))
seq_tensor = torch.full(shape, config.PAD, dtype=torch.int64)
for i, s in enumerate(seq):
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_golden_chunk_records'}, {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '21']}, ... | def get_golden_chunk_records():
pattern = os.path.join(fsdb.golden_chunk_dir(), '*.zz')
return sorted(tf.gfile.Glob(pattern), reverse=True)[:FLAGS.window_size] |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_sorted_results'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | def _sorted_results(self, results_dicts):
print('results dicts:', results_dicts)
sorted_dict = sorted(results_dicts, key=lambda k: k['start_time'])
results = []
for entry in sorted_dict:
results.append(entry['dt'])
return results |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_models'}, {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '24', '39', '62']}, {'... | def get_models():
all_models = gfile.Glob(os.path.join(models_dir(), '*.meta'))
model_filenames = [os.path.basename(m) for m in all_models]
model_numbers_names = sorted([
(shipname.detect_model_num(m), shipname.detect_model_name(m))
for m in model_filenames])
return model_numbers_names |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17', '19']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sorted_by'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6'... | def sorted_by(key: Callable[[raw_types.Qid], Any]) -> 'QubitOrder':
return QubitOrder(lambda qubits: tuple(sorted(qubits, key=key))) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '32', '36']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'diagonalize_real_symmetric_and_sorted_diagonal_matrices'}, {'id': '3', 'type': 'parameters', 'children': ['4', '10', '16', '17'... | def diagonalize_real_symmetric_and_sorted_diagonal_matrices(
symmetric_matrix: np.ndarray,
diagonal_matrix: np.ndarray,
*,
rtol: float = 1e-5,
atol: float = 1e-8,
check_preconditions: bool = True) -> np.ndarray:
if check_preconditions:
if (np.any(np.imag(symme... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '34', '48']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'findall_operations_between'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '17', '29']}; {'id': '4', 'type': 'ident... | def findall_operations_between(self,
start_frontier: Dict[ops.Qid, int],
end_frontier: Dict[ops.Qid, int],
omit_crossing_operations: bool = False
) -> List[Tuple[int, ops.Operation... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_GetUnsortedNotifications'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'childr... | def _GetUnsortedNotifications(self,
queue_shard,
notifications_by_session_id=None):
if notifications_by_session_id is None:
notifications_by_session_id = {}
end_time = self.frozen_timestamp or rdfvalue.RDFDatetime.Now()
for notification i... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'Dump'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'o... | def Dump(obj,
sort_keys = False,
encoder = None):
text = json.dumps(
obj,
indent=2,
sort_keys=sort_keys,
ensure_ascii=False,
cls=encoder,
separators=_SEPARATORS)
if compatibility.PY2 and isinstance(text, bytes):
text = text.decode("utf-8")
return text |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'NamedPlaceholders'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | def NamedPlaceholders(iterable):
placeholders = ", ".join("%({})s".format(key) for key in sorted(iterable))
return "({})".format(placeholders) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'Columns'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'iterable'... | def Columns(iterable):
columns = sorted(iterable)
return "({})".format(", ".join("`{}`".format(col) for col in columns)) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'GetArtifactsForCollection'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': ... | def GetArtifactsForCollection(os_name, artifact_list):
artifact_arranger = ArtifactArranger(os_name, artifact_list)
artifact_names = artifact_arranger.GetArtifactsInProperOrder()
return artifact_names |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_FilterOutPathInfoDuplicates'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': []... | def _FilterOutPathInfoDuplicates(path_infos):
pi_dict = {}
for pi in path_infos:
path_key = (pi.path_type, pi.GetPathID())
pi_dict.setdefault(path_key, []).append(pi)
def _SortKey(pi):
return (
pi.stat_entry.st_ctime,
pi.stat_entry.st_mtime,
pi.stat_entry.st_atime,
pi.s... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'DrainTaskSchedulerQueueForClient'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', ... | def DrainTaskSchedulerQueueForClient(self, client, max_count=None):
if max_count is None:
max_count = self.max_queue_size
if max_count <= 0:
return []
client = rdf_client.ClientURN(client)
start_time = time.time()
if data_store.RelationalDBEnabled():
action_requests = data_store.RE... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '71']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'federated_query'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18', '21', '24', '27', '30', '33',... | def federated_query(self,
environment_id,
filter=None,
query=None,
natural_language_query=None,
passages=None,
aggregation=None,
count=None,
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '27']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'query_relations'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13', '16', '19', '22', '25']}; {'id': '4... | def query_relations(self,
environment_id,
collection_id,
entities=None,
context=None,
sort=None,
filter=None,
count=None,
eviden... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '22']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'query_log'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20']}; {'id': '4', 'type': 'identifier'... | def query_log(self,
filter=None,
query=None,
count=None,
offset=None,
sort=None,
**kwargs):
headers = {}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
sdk_heade... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '22']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list_workspaces'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20']}; {'id': '4', 'type': 'ident... | def list_workspaces(self,
page_limit=None,
include_count=None,
sort=None,
cursor=None,
include_audit=None,
**kwargs):
headers = {}
if 'headers' in kwargs:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '55']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list_feedback'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20', '23', '26', '29', '32', '35', ... | def list_feedback(self,
feedback_type=None,
before=None,
after=None,
document_title=None,
model_id=None,
model_version=None,
category_removed=None,
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'multi_index_insert_row'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children'... | def multi_index_insert_row(df, index_row, values_row):
row_index = pd.MultiIndex(levels=[[i] for i in index_row],
labels=[[0] for i in index_row])
row = pd.DataFrame(values_row, index=row_index, columns=df.columns)
df = pd.concat((df, row))
if df.index.lexsort_depth == len(... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'substring_search'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def substring_search(word, collection):
return [item for item in sorted(collection) if item.startswith(word)] |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_nodes'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'... | def _nodes(self):
return list(set([node for node, timeslice in
super(DynamicBayesianNetwork, self).nodes()])) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_edge'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | def add_edge(self, start, end, **kwargs):
try:
if len(start) != 2 or len(end) != 2:
raise ValueError('Nodes must be of type (node, time_slice).')
elif not isinstance(start[1], int) or not isinstance(end[1], int):
raise ValueError('Nodes must be of type (no... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'estimate'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], '... | def estimate(self, start=None, tabu_length=0, max_indegree=None):
epsilon = 1e-8
nodes = self.state_names.keys()
if start is None:
start = DAG()
start.add_nodes_from(nodes)
elif not isinstance(start, DAG) or not set(start.nodes()) == set(nodes):
raise ... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_node'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | def add_node(self, node, weight=None):
if isinstance(node, tuple) and len(node) == 2 and isinstance(node[1], dict):
node, attrs = node
if attrs.get('weight', None) is not None:
attrs['weight'] = weight
else:
attrs = {'weight': weight}
super(DAG... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_nodes_from'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | def add_nodes_from(self, nodes, weights=None):
nodes = list(nodes)
if weights:
if len(nodes) != len(weights):
raise ValueError("The number of elements in nodes and weights"
"should be equal.")
for index in range(len(nodes)):
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'rank_items'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children':... | def rank_items(self, userid, user_items, selected_items, recalculate_user=False):
if max(selected_items) >= user_items.shape[1] or min(selected_items) < 0:
raise IndexError("Some of selected itemids are not in the model")
liked_vector = user_items[userid]
recommendations = liked_vect... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_sorted_structure'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children':... | def get_sorted_structure(self, key=None, reverse=False):
sites = sorted(self, key=key, reverse=reverse)
return self.__class__.from_sites(sites, charge=self._charge) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_str'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13']}; {'id': '4', 'type': 'identifier', 'child... | def from_str(cls, input_string, fmt, primitive=False, sort=False,
merge_tol=0.0):
from pymatgen.io.cif import CifParser
from pymatgen.io.vasp import Poscar
from pymatgen.io.cssr import Cssr
from pymatgen.io.xcrysden import XSF
from pymatgen.io.atat import Mcsqs
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_transition_chempots'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': []... | def get_transition_chempots(self, element):
if element not in self.elements:
raise ValueError("get_transition_chempots can only be called with "
"elements in the phase diagram.")
critical_chempots = []
for facet in self.facets:
chempots = self... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_dir'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | def from_dir(cls, top, exts=None, exclude_dirs="_*"):
pseudos = []
if exts == "all_files":
for f in [os.path.join(top, fn) for fn in os.listdir(top)]:
if os.path.isfile(f):
try:
p = Pseudo.from_file(f)
if p:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sorted'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | def sorted(self, attrname, reverse=False):
attrs = []
for i, pseudo in self:
try:
a = getattr(pseudo, attrname)
except AttributeError:
a = np.inf
attrs.append((i, a))
return self.__class__([self[a[0]] for a in sorted(attrs, key=... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.