sequence stringlengths 1.19k 35k | code stringlengths 75 8.58k |
|---|---|
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'intersect_range_array'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'chil... | def intersect_range_array(bed1,beds2,payload=None,is_sorted=False):
if not is_sorted: beds2 = sort_ranges(beds2)
output = []
for bed2 in beds2:
cval = bed2.cmp(bed1)
if cval == -1: continue
elif cval == 0:
output.append(bed1.intersect(bed2))
if payload==1:
output[-1].set_payload(be... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_genomic_ranges'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | def sort_genomic_ranges(rngs):
return sorted(rngs, key=lambda x: (x.chr, x.start, x.end)) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'topological_sort'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def topological_sort(dependencies, start_nodes):
retval = []
def edges(node): return dependencies[node][1]
def in_degree(node): return dependencies[node][0]
def remove_incoming(node): dependencies[node][0] = in_degree(node) - 1
while start_nodes:
node = start_nodes.pop()
retval.appen... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_do_parse'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | def _do_parse(inp, fmt, encoding, force_types):
res = {}
_check_lib_installed(fmt, 'parse')
if fmt == 'ini':
cfg = configobj.ConfigObj(inp, encoding=encoding)
res = cfg.dict()
elif fmt == 'json':
if six.PY3:
inp = io.TextIOWrapper(inp, encoding=encoding)
res =... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_do_serialize'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | def _do_serialize(struct, fmt, encoding):
res = None
_check_lib_installed(fmt, 'serialize')
if fmt == 'ini':
config = configobj.ConfigObj(encoding=encoding)
for k, v in struct.items():
config[k] = v
res = b'\n'.join(config.write())
elif fmt in ['json', 'json5']:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_header'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'heade... | def sort_header(header_text):
lines = header_text.rstrip().split("\n")
rlens = {}
for ln in lines:
m = re.match('@SQ\tSN:(\S+)\tLN:(\S+)',ln)
if m:
rlens[m.group(1)] = m.group(2)
output = ''
done_lens = False
for ln in lines:
if re.match('@SQ\tSN:',ln):
if not done_lens:
done... |
{'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, field, direction="asc"):
if not isinstance(field, basestring):
raise ValueError("Field should be a string")
if direction not in ["asc", "desc"]:
raise ValueError("Sort direction should be `asc` or `desc`")
self.sorts.append({field: direction}) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove_sort'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | def remove_sort(self, field_name):
self.sorts = [dict(field=value) for field, value in self.sorts if field
is not field_name] |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'aggregate_registry_timers'}, {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '8', '2... | def aggregate_registry_timers():
import itertools
timers = sorted(shared_registry.values(), key=lambda t: t.desc)
aggregate_timers = []
for k, g in itertools.groupby(timers, key=lambda t: t.desc):
group = list(g)
num_calls = len(group)
total_elapsed_ms = sum(t.elapsed_time_ms for... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'spread'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'iterable'}... | def spread(iterable):
if len(iterable) == 1:
return 0
iterable = iterable.copy()
iterable.sort()
max_diff = max(abs(i - j) for (i, j) in zip(iterable[1:], iterable[:-1]))
return max_diff |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_transcripts'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | def sort_transcripts(self):
txs = sorted(self.transcripts,key=lambda x: (x.range.chr, x.range.start, x.range.end))
self._transcripts = txs |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'in1d_events'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | def in1d_events(ar1, ar2):
ar1 = np.ascontiguousarray(ar1)
ar2 = np.ascontiguousarray(ar2)
tmp = np.empty_like(ar1, dtype=np.uint8)
return analysis_functions.get_in1d_sorted(ar1, ar2, tmp) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_by_priority'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [],... | def sort_by_priority(iterable, reverse=False, default_priority=10):
return sorted(iterable, reverse=reverse, key=lambda o: getattr(o, 'priority', default_priority)) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'apply'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier', 'children': [],... | def apply(self, func, mapping=None, new_dtype=None, **kwargs):
if callable(func):
return Series(func(self.values,
weld_type=self.weld_type,
**kwargs),
self.index,
self.dtype,
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'weld_sort'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], '... | def weld_sort(arrays, weld_types, readable_text, ascending=True):
weld_obj_sort = _weld_sort(arrays, weld_types, ascending)
weld_obj_struct = weld_vec_of_struct_to_struct_of_vec(weld_obj_sort, weld_types)
weld_obj_indices = weld_select_from_struct(weld_obj_struct, 0)
intermediate_result = LazyArrayResul... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'chooseBestDuplicates'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifie... | def chooseBestDuplicates(tped, samples, oldSamples, completion,
concordance_all, prefix):
chosenFile = None
try:
chosenFile = open(prefix + ".chosen_samples.info", "w")
except IOError:
msg = "%(prefix)s.chosen_samples.info: can't write file" % locals()
raise ... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'order_qc_dir'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'dirn... | def order_qc_dir(dirnames):
return sorted(
dirnames, key=lambda dn: time.strptime(
os.path.basename(dn.rstrip("/"))[14:],
"%Y-%m-%d_%H.%M.%S",
)
) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fetch'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}... | def fetch(self, webfonts):
sorted_keys = sorted(webfonts.keys())
for webfont_name in sorted_keys:
self.get(webfont_name, webfonts[webfont_name]) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_index'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | def sort_index(self, ascending=True):
if isinstance(self.index, MultiIndex):
raise NotImplementedError('Weld does not yet support sorting on multiple columns')
return self.sort_values(self.index._gather_names(), ascending) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_values'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def sort_values(self, by, ascending=True):
check_type(ascending, bool)
check_str_or_list_str(by)
by = as_list(by)
if len(by) > 1:
raise NotImplementedError('Weld does not yet support sorting on multiple columns')
all_data = self.reset_index()
by_data = all_dat... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '23']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'optimize_with_repeates'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20']}; {'id': '4', 'type':... | def optimize_with_repeates(self,fast=None,verbose=None,n_times=10,lambd=None,lambd_g=None,lambd_n=None):
verbose = dlimix.getVerbose(verbose)
if not self.init: self._initGP(fast)
opt_list = []
fixed0 = sp.zeros_like(self.gp.getParams()['dataTerm'])
for i in range(n_times):
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_prefixes'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | def sort_prefixes(orig, prefixes='@+'):
new = ''
for prefix in prefixes:
if prefix in orig:
new += prefix
return new |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_children'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | def sort_children(self, attribute=None, reverse_order=False):
sorted_children = []
if attribute:
sortable_children = []
unsortable_children = []
for child in self.__children:
if child.attribute_exists(attribute):
sortable_children.a... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_sort_kw_matches'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def _sort_kw_matches(skw_matches, limit=0):
sorted_keywords = list(skw_matches.items())
sorted(sorted_keywords, key=cmp_to_key(_skw_matches_comparator))
return limit and sorted_keywords[:limit] or sorted_keywords |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'trim'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'},... | def trim(self, n_peaks):
self.sortByIntensity()
ims.spectrum_trim(self.ptr, n_peaks) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'centroids'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | def centroids(self, window_size=5):
self.sortByMass()
mzs = _cffi_buffer(self.masses, 'd')
intensities = _cffi_buffer(self.intensities, 'f')
n = self.size
p = ims.spectrum_new_from_raw(n, mzs.ptr, intensities.ptr, int(window_size))
return _new_spectrum(CentroidedSpectrum,... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list_engines_by_priority'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children':... | def list_engines_by_priority(engines=None):
if engines is None:
engines = ENGINES
return sorted(engines, key=operator.methodcaller("priority")) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'union'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'dict1'... | def union(dict1, dict2):
for key, value in dict2.items():
if key in dict1 and isinstance(value, dict):
dict1[key] = union(dict1[key], value)
else:
dict1[key] = value
return dict1 |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_format_data'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | def _format_data(self, data):
return [spectrum for spectrum in \
sorted(data if isinstance(data, (list, tuple)) else [data],
key=lambda x: x.disp[0]) if np.any(np.isfinite(spectrum.flux))] |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_sorting'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def get_sorting(self, request, **resources):
sorting = []
if not request.GET:
return sorting
prefix = self._meta.dyn_prefix + 'sort'
return request.GET.getlist(prefix) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'},... | def sort(self, *sort_tuples):
''' pymongo-style sorting. Accepts a list of tuples.
:param sort_tuples: varargs of sort tuples.
'''
query = self
for name, direction in sort_tuples:
field = resolve_name(self.type, name)
if direction in (ASCENDING, 1):
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_has_bad_coords'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | def _has_bad_coords(root, stream):
if stream == "com.dc3/dc3.broker":
return True
if not stream.split('/')[0] == 'nasa.gsfc.gcn':
return False
toplevel_params = vp.get_toplevel_params(root)
if "Coords_String" in toplevel_params:
if (toplevel_params["Coords_String"]['value'] ==
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '19', '31']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sorted_chain'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', ... | def sorted_chain(*ranges: Iterable[Tuple[int, int]]) -> List[Tuple[int, int]]:
return sorted(itertools.chain(*ranges)) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'partition_range'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | def partition_range(stop, annotations=None):
annotations = annotations or []
partitioning = []
part_start, part_levels = 0, None
for p in sorted(set(itertools.chain([0, stop],
*itertools.chain(*annotations)))):
if p == stop:
partitioning.append... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pprint_sequence'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14']}; {'id': '4', 'type': 'identifier', 'chi... | def pprint_sequence(sequence, annotations=None, block_length=10,
blocks_per_line=6, format=PlaintextFormat):
annotations = annotations or []
partitioning = partition_range(len(sequence), annotations)
margin = int(math.floor(math.log(max(len(sequence), 1), 10))
+ 1) + len... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '32']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'tabulate'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20', '23', '26', '29']}; {'id': '4', 'ty... | def tabulate(
obj,
v_level_indexes=None,
h_level_indexes=None,
v_level_visibility=None,
h_level_visibility=None,
v_level_sort_keys=None,
h_level_sort_keys=None,
v_level_titles=None,
h_level_titles=None,
empty="",
):
level_keys = breadth_first(obj)
v_level_indexes, h_level... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_ordered_entries'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | def get_ordered_entries(self, queryset=False):
if queryset:
self.queryset = queryset
else:
self.queryset = EntryCategory.objects.all()
if self.queryset:
for category in self.queryset:
entries = category.get_entries()
if entries:... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '26']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parallel_progbar'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18', '21', '24']}; {'id': '4', 't... | def parallel_progbar(mapper, iterable, nprocs=None, starmap=False, flatmap=False, shuffle=False,
verbose=True, verbose_flatmap=None, **kwargs):
results = _parallel_progbar_launch(mapper, iterable, nprocs, starmap, flatmap, shuffle, verbose, verbose_flatmap, **kwargs)
return [x for i, x in s... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '30']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'iparallel_progbar'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18', '21', '24', '28']}; {'id': ... | def iparallel_progbar(mapper, iterable, nprocs=None, starmap=False, flatmap=False, shuffle=False,
verbose=True, verbose_flatmap=None, max_cache=-1, **kwargs):
results = _parallel_progbar_launch(mapper, iterable, nprocs, starmap, flatmap, shuffle, verbose,
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_creation_date_tags'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children'... | def get_creation_date_tags(url, domain, as_dicts=False):
creation_date_tags = [
mementoweb_api_tags(url),
get_whois_tags(domain),
]
creation_date_tags = sorted(
sum(creation_date_tags, []),
key=lambda x: x.date
)
if not as_dicts:
return creation_date_tags
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'image_from_name'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | def image_from_name(name, images):
prefixed_images = [i for i in images if i.name.startswith(name)]
if name in [i.name for i in prefixed_images]:
return [i for i in prefixed_images if i.name == name][-1]
decorated = sorted(
[(int(re.search('\d+', i.name).group(0)), i) for i in prefixed_image... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'func_on_enter'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'fun... | def func_on_enter(func):
def function_after_enter_pressed(ev):
ev.stopPropagation()
if ev.keyCode == 13:
func(ev)
return function_after_enter_pressed |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'prev_next_group'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | def prev_next_group(project, group):
groups = sorted(x for x in project.groups if x.submissions)
try:
index = groups.index(group)
except ValueError:
return None, None
prev_group = groups[index - 1] if index > 0 else None
next_group = groups[index + 1] if index + 1 < len(groups) else ... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'do_minus'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | def do_minus(self, parser, group):
'''This filter sorts nodes in a flat group into "required", "default",
and "banned" subgroups based on the presence of plus and minus nodes.
'''
grouper = group.__class__()
next_not = None
for node in group:
if isinstance(nod... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'topological_sort'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | def topological_sort(dependency_pairs):
"Sort values subject to dependency constraints"
num_heads = defaultdict(int)
tails = defaultdict(list)
heads = []
for h, t in dependency_pairs:
num_heads[t] += 1
if h in tails:
tails[h].append(t)
else:
tails[h] =... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'multisorted'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | def multisorted(items, *keys):
if len(keys) == 0:
keys = [asc()]
for key in reversed(keys):
items = sorted(items, key=key.func, reverse=key.reverse)
return items |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'tuplesorted'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | def tuplesorted(items, *keys):
tuple_keys = [
Key(func=lambda t, i=index, k=key: k.func(t[i]), reverse=key.reverse)
for index, key in enumerate(keys)
]
return multisorted(items, *tuple_keys) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list_formats'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': []... | def list_formats(self, node, path=(), formats=None):
if formats == None:
formats = []
for child in node.children:
self.list_formats(child, path + (child.name,), formats)
path and formats.append(".".join(path))
return sorted(formats) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ls'}, {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6'... | def ls(root=".", abspaths=False, recursive=False):
def _expand_subdirs(file):
if isdir(path(root, file)):
return [file] + [path(file, x) for x in
ls(path(root, file), recursive=True)]
else:
return [file]
if isfile(root):
return [abspat... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '19']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17']}; {'id': '4', 'type': 'identifier', 'children... | def list(self, offset=0, limit=0, fields=None, sort=None, **kwargs):
try:
cursor = self._cursor(offset=offset, limit=limit, fields=fields,
sort=sort, **kwargs)
return list(cursor), cursor.count()
except pymongo.errors.OperationFailure as exc:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '19']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_cursor'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17']}; {'id': '4', 'type': 'identifier', 'child... | def _cursor(self, offset=0, limit=0, fields=None, sort=None, **kwargs):
projection = {'_id': False}
if fields:
projection.update({field: True for field in fields})
results = self._collection.find(kwargs, projection)
if sort:
sort_pairs = sort[:]
for in... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'insert'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | def insert(self, item, low_value):
return c_void_p(lib.zlistx_insert(self._as_parameter_, item, low_value)) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reorder'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | def reorder(self, handle, low_value):
return lib.zlistx_reorder(self._as_parameter_, handle, low_value) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'process_params'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children':... | def process_params(request, standard_params=STANDARD_QUERY_PARAMS,
filter_fields=None, defaults=None):
if not filter_fields:
filter_fields = []
unfilterable = (set(request.query.keys()) - set(filter_fields) -
set(standard_params))
if unfilterable:
bottl... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_weave_dohist'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '12']}; {'id': '4', 'type': 'identifier... | def _weave_dohist(data, s, binsize, hist, rev, dorev=False, verbose=0):
if dorev:
dorev=1
else:
dorev=0
code =
scipy.weave.inline(code, ['data','s','binsize','hist','rev','dorev'],
type_converters = scipy.weave.converters.blitz, verbose=verbose)
return |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'loose_search'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': []... | def loose_search(self, asset_manager_id, query='', **kwargs):
self.logger.info('Asset Search - Asset Manager: %s', asset_manager_id)
url = '{endpoint}/assets/search/{asset_manager_id}'.format(
asset_manager_id=asset_manager_id,
endpoint=self.endpoint,
)
params = {... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'natural_sort'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'item... | def natural_sort(item):
if item is None:
return 0
def try_int(s):
try:
return int(s)
except ValueError:
return s
return tuple(map(try_int, re.findall(r'(\d+|\D+)', item))) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_html_attrs'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6'... | def get_html_attrs(kwargs=None):
kwargs = kwargs or {}
attrs = []
props = []
classes = kwargs.get('classes', '').strip()
if classes:
classes = ' '.join(re.split(r'\s+', classes))
classes = to_unicode(quoteattr(classes))
attrs.append('class=%s' % classes)
try:
del ... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_dependencies'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | def sort_dependencies(objects):
from django.db.models import get_model
model_dependencies = []
models = set()
model_list = set()
objs_by_model = defaultdict(list)
for o in objects:
model = o.__class__
objs_by_model[model].append(o)
model_list.add(model)
for model in m... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_languages'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | def sort_languages(self, order=Qt.AscendingOrder):
self.beginResetModel()
self.__languages = sorted(self.__languages, key=lambda x: (x.name), reverse=order)
self.endResetModel() |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fmt_pairs'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | def fmt_pairs(obj, indent=4, sort_key=None):
lengths = [len(x[0]) for x in obj]
if not lengths:
return ''
longest = max(lengths)
obj = sorted(obj, key=sort_key)
formatter = '%s{: <%d} {}' % (' ' * indent, longest)
string = '\n'.join([formatter.format(k, v) for k, v in obj])
return st... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'serialize'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | def serialize(self, as_dict=False, sort=None):
files = getattr(self, 'files', self.run())
if as_dict:
return dict((fn, p.to_dict()) for fn, p in files.items())
data = (p.to_dict() for p in files.values())
if callable(sort):
return sorted(data, key=sort)
el... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'iteritems'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'},... | def iteritems(self):
sorted_data = sorted(self.data.iteritems(), self.cmp, self.key,
self.reverse)
for k,v in sorted_data:
yield k,v |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_posts'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], ... | def get_posts(self, num=None, tag=None, private=False):
posts = self.posts
if not private:
posts = [post for post in posts if post.public]
if tag:
posts = [post for post in posts if tag in post.tags]
if num:
return posts[:num]
return posts |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_sort_function'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | def get_sort_function(order):
stable = tuple((d['key'], -1 if d['reverse'] else 1) for d in order)
def sort_function(a, b):
for name, direction in stable:
v = cmp(getattr(a, name) if a else a, getattr(b, name) if b else b)
if v != 0:
return v * direction
r... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_proxy_model'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | def create_proxy_model(self, model):
proxy = ReftrackSortFilterModel(self)
proxy.setSourceModel(model)
model.rowsInserted.connect(self.sort_model)
return proxy |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_model'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | def sort_model(self, *args, **kwargs):
self.proxy.sort(17)
self.proxy.sort(2)
self.proxy.sort(1)
self.proxy.sort(0) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'prepare_value'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | def prepare_value(self, value):
if value is None and self.required:
choices =list(self.choices)
if len(choices) == 1:
value = choices[0][0]
return super(TemplateChoiceField, self).prepare_value(value) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_sort'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'i... | def _sort(self):
self._log.debug('Sorting responses by priority')
self._responses = OrderedDict(sorted(list(self._responses.items()), reverse=True))
self.sorted = True |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'csv_row_to_transaction'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15']}; {'id': '4', 'type': 'ident... | def csv_row_to_transaction(index, row, source_encoding="latin1",
date_format="%d-%m-%Y", thousand_sep=".", decimal_sep=","):
xfer, posted, message, amount, total = row
xfer = Parse.date(xfer)
posted = Parse.date(posted)
message = Parse.to_utf8(message, source_encoding)
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'csv_to_transactions'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14']}; {'id': '4', 'type': 'identifier', ... | def csv_to_transactions(handle, source_encoding="latin1",
date_format="%d-%m-%Y", thousand_sep=".", decimal_sep=","):
trans = Transactions()
rows = csv.reader(handle, delimiter=";", quotechar="\"")
for index, row in enumerate(rows):
trans.append(Parse.csv_row_to_transacti... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'filterAcceptsRow'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], ... | def filterAcceptsRow(self, row, parentindex):
if not super(ReftrackSortFilterModel, self).filterAcceptsRow(row, parentindex):
return False
if parentindex.isValid():
m = parentindex.model()
else:
m = self.sourceModel()
i = m.index(row, 18, parentindex)
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_grid_data'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children':... | def load_grid_data(file_list, data_type="binary", sort=True, delim=" "):
if not type(file_list) is list:
file_list = [file_list]
elif sort:
file_list.sort(key=lambda f: int(re.sub("[^0-9]", "", f)))
world_size = get_world_dimensions(file_list[0], delim)
data = initialize_grid(world_size,... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id... | def sort(self):
for priority, triggers in self._triggers.items():
self._log.debug('Sorting priority {priority} triggers'.format(priority=priority))
atomics = [trigger for trigger in triggers if trigger.pattern_is_atomic]
wildcards = [trigger for trigger in triggers if not tri... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'log_message'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def log_message(self, user, message):
if isinstance(user, SeshetUser):
user = user.nick
elif not isinstance(user, IRCstr):
user = IRCstr(user)
time = datetime.utcnow()
self.message_log.append((time, user, message))
while len(self.message_log) > self._log_s... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '22']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_item'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13', '16', '19']}; {'id': '4', 'type': 'identif... | def add_item(self, path, name, icon=None, url=None, order=None, permission=None, active_regex=None):
if self.root_item is None:
self.root_item = MenuItem('ROOT', 'ROOT')
root_item = self.root_item
current_path = ''
for node in path.split('/')[:-1]:
if not node:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'assist'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], ... | def assist(self, project_path, source, position, filename):
return self._call('assist', project_path, source, position, filename) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sorted_key_list'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | def sorted_key_list(self):
if not self.is_baked:
self.bake()
key_value_tuple = sorted(self.dct.items(),
key=lambda x: x[1]['__abs_time__'])
skl = [k[0] for k in key_value_tuple]
return skl |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_used_key_frames'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | def get_used_key_frames(self):
skl = self.key_frame_list.sorted_key_list()
used_key_frames = []
for kf in skl:
if kf in self.dct['keys']:
used_key_frames.append((kf, self.dct['keys'][kf]))
return used_key_frames |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'flds_firstsort'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'd'... | def flds_firstsort(d):
'''
Perform a lexsort and return the sort indices and shape as a tuple.
'''
shape = [ len( np.unique(d[l]) )
for l in ['xs', 'ys', 'zs'] ];
si = np.lexsort((d['z'],d['y'],d['x']));
return si,shape; |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'flds_sort'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'd'... | def flds_sort(d,s):
'''
Sort based on position. Sort with s as a tuple of the sort
indices and shape from first sort.
Parameters:
-----------
d -- the flds/sclr data
s -- (si, shape) sorting and shaping data from firstsort.
'''
labels = [ key for key in d.keys()
if... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'fname'}... | def read(fname,**kw):
'''
Reads an lsp output file and returns a raw dump of data,
sectioned into quantities either as an dictionary or a typed numpy array.
Parameters:
-----------
fname -- filename of thing to read
Keyword Arguments:
------------------
vprint -- Verbose printer. ... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_region_nt_counts'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': ... | def get_region_nt_counts(region, bam, stranded=False):
if type(bam) == str:
bam = pysam.AlignmentFile(bam, 'rb')
if type(region) is str:
r = parse_region(region)
if len(r) == 3:
chrom, start, end = r
elif len(r) == 4:
chrom, start, end, strand = r
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'nt_counts'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier', 'children':... | def nt_counts(bam, positions, stranded=False, vcf=False, bed=False):
if not bed and not vcf:
if type(positions) == pbt.bedtool.BedTool:
df = positions.to_dataframe()
elif positions[-4:] == '.bed':
bed = True
elif positions[-4:] == '.vcf':
vcf = True
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_host'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | def add_host(self, host, group_names=None, host_vars=None):
gnames = group_names if group_names else []
hvars = host_vars if host_vars else {}
gnames.sort()
hvars[A.server.GROUP_NAMES] = gnames
hvars[A.server.INV_NAME] = host
hvars[A.server.INV_NAME_SHORT] = host.split('.... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'beds_to_boolean'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14']}; {'id': '4', 'type': 'identifier', 'chi... | def beds_to_boolean(beds, ref=None, beds_sorted=False, ref_sorted=False,
**kwargs):
beds = copy.deepcopy(beds)
fns = []
for i,v in enumerate(beds):
if type(v) == str:
fns.append(v)
beds[i] = pbt.BedTool(v)
else:
fns.append(v.fn)
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'combine'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | def combine(beds, beds_sorted=False, postmerge=True):
beds = copy.deepcopy(beds)
for i,v in enumerate(beds):
if type(v) == str:
beds[i] = pbt.BedTool(v)
if not beds_sorted:
beds[i] = beds[i].sort()
out = reduce(lambda x,y : x.cat(y, postmerge=False), beds)
out = o... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sanitize_config_loglevel'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | def sanitize_config_loglevel(level):
'''
Kinda sorta backport of loglevel sanitization for Python 2.6.
'''
if sys.version_info[:2] != (2, 6) or isinstance(level, (int, long)):
return level
lvl = None
if isinstance(level, basestring):
lvl = logging._levelNames.get(level)
if no... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'prt_js'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | def prt_js(js, sort_keys=True, indent=4):
print(js2str(js, sort_keys, indent)) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_field_names'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14']}; {'id': '4', 'type': 'identifier', 'ch... | def find_field_names(fields, model=DEFAULT_MODEL, app=DEFAULT_APP, score_cutoff=50, pad_with_none=False):
fields = util.listify(fields)
model = get_model(model, app)
available_field_names = model._meta.get_all_field_names()
matched_fields = []
for field_name in fields:
match = fuzzy.extractO... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '34']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'lagged_in_date'}, {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10', '13', '16', '19', '22', '25', '28', '31']}; {'id': '... | def lagged_in_date(x=None, y=None, filter_dict=None, model='WikiItem', app=DEFAULT_APP, sort=True, limit=30000, lag=1, pad=0, truncate=True):
lag = int(lag or 0)
if isinstance(x, basestring) and isinstance(y, basestring):
x, y = sequence_from_filter_spec([find_synonymous_field(x), find_synonymous_field(... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'percentile'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def percentile(sorted_list, percent, key=lambda x: x):
if not sorted_list:
return None
if percent == 1:
return float(sorted_list[-1])
if percent == 0:
return float(sorted_list[0])
n = len(sorted_list)
i = percent * n
if ceil(i) == i:
i = int(i)
return (sor... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'tags'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id... | def tags(self):
'''Return a list of all tags that have this semantic tag, sorted by name.
:rtype: list of ckan.model.tag.Tag objects
'''
q = meta.Session.query(_tag.Tag)
q = q.join(TagSemanticTag)
q = q.filter_by(tag_id=self.id)
q = q.order_by(_tag.Tag.name)
tags = q.all()
return tags |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'ERROR', 'children': ['2', '178', '195', '203', '213']}; {'id': '2', 'type': 'function_definition', 'children': ['3', '4', '10']}, {'id': '3', 'type': 'function_name', 'children': [], 'value': 'make_feature_bed'}; {'id': '4', 'type': 'parameters', 'c... | def make_feature_bed(gtf, feature, out=None):
bed_lines = []
with open(gtf) as f:
line = f.readline().strip()
while line != '':
if line[0] != '
line = line.split('\t')
if line[2] == feature:
chrom = line[0]
start... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'filter'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | def filter(self, order_by=None, limit=0, **kwargs):
with rconnect() as conn:
if len(kwargs) == 0:
raise ValueError
try:
query = self._base()
query = query.filter(kwargs)
if order_by is not None:
query = s... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'all'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | def all(self, order_by=None, limit=0):
with rconnect() as conn:
try:
query = self._base()
if order_by is not None:
query = self._order_by(query, order_by)
if limit > 0:
query = self._limit(query, limit)
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'safe_dump_js'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier', 'childre... | def safe_dump_js(js, abspath,
fastmode=False, compress=False, enable_verbose=True):
abspath = str(abspath)
temp_abspath = "%s.tmp" % abspath
dump_js(js, temp_abspath, fastmode=fastmode,
replace=True, compress=compress, enable_verbose=enable_verbose)
shutil.move(temp_abspat... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'all_selectors'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | def all_selectors(Class, fn):
selectors = []
cssparser = cssutils.CSSParser(validate=False)
css = cssparser.parseFile(fn)
for rule in [r for r in css.cssRules if type(r)==cssutils.css.CSSStyleRule]:
selectors += [sel.selectorText for sel in rule.selectorList]
se... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_logger'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | def create_logger(self, args={}):
logger = logging.getLogger("SmartFileSorter")
logger.level = logging.INFO
if '--debug' in args and args['--debug'] is True:
logger.setLevel(logging.DEBUG)
file_log_formatter = logging.Formatter('%(asctime)s %(name)s %(levelname)s %(message)s'... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, ... | def get(self, slug):
kb = api.get_kb_by_slug(slug)
check_knowledge_access(kb)
parser = reqparse.RequestParser()
parser.add_argument(
'from', type=str,
help="Return only entries where key matches this.")
parser.add_argument(
'to', type=str,
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.