sequence stringlengths 1.19k 35k | code stringlengths 75 8.58k |
|---|---|
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'previous'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, ... | def previous(self):
if self._order_by == 'oldest':
return self.older
if self._order_by == 'newest':
return self.newer
return None |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'next'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id... | def next(self):
if self._order_by == 'oldest':
return self.newer
if self._order_by == 'newest':
return self.older
return None |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'newest'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'... | def newest(self):
if self._order_by == 'newest':
return self.first
if self._order_by == 'oldest':
return self.last
return max(self.entries, key=lambda x: (x.date, x.id)) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'oldest'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'... | def oldest(self):
if self._order_by == 'newest':
return self.last
if self._order_by == 'oldest':
return self.first
return min(self.entries, key=lambda x: (x.date, -x.id)) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_dataframe_cols'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | def sort_dataframe_cols(self):
cols = self.df.columns
groups = list(map(lambda x: self.data_model.get_group_for_col(self.dtype, x), cols))
sorted_cols = cols.groupby(groups)
ordered_cols = []
try:
names = sorted_cols.pop('Names')
except KeyError:
n... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_diclist'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | def sort_diclist(undecorated, sort_on):
decorated = [(len(dict_[sort_on]) if hasattr(dict_[sort_on], '__len__') else dict_[
sort_on], index) for (index, dict_) in enumerate(undecorated)]
decorated.sort()
return[undecorated[index] for (key, index) in decorated] |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'process_data_for_mean'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], ... | def process_data_for_mean(data, direction_type_key):
dec_key, inc_key, meth_key = 'dec', 'inc', 'magic_method_codes'
if 'dir_dec' in data[0].keys():
dec_key, inc_key, meth_key = 'dir_dec', 'dir_inc', 'method_codes'
n_lines, n_planes = 0, 0
L, fdata = [], []
E = [0, 0, 0]
for rec in data:... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'main'}, {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '9', '13', '41', '61', '89',... | def main():
dir_path='.'
inspec="pmag_specimens.txt"
if '-WD' in sys.argv:
ind=sys.argv.index('-WD')
dir_path=sys.argv[ind+1]
if '-h' in sys.argv:
print(main.__doc__)
sys.exit()
if '-f' in sys.argv:
ind=sys.argv.index('-f')
inspec=sys.argv[ind+1]
b... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read_magic_file'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], '... | def read_magic_file(self, path, sort_by_this_name):
DATA = {}
try:
with open(path, 'r') as finput:
lines = list(finput.readlines()[1:])
except FileNotFoundError:
return []
line = lines[0]
header = line.strip('\n').split('\t')
error_... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'plot_teq'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | def plot_teq(fignum, araiblock, s, pars):
first_Z, first_I = araiblock[0], araiblock[1]
plt.figure(num=fignum)
plt.clf()
ZIblock, IZblock, pTblock = [], [], []
for zrec in first_Z:
if zrec[4] == 1:
ZIblock.append([zrec[1], zrec[2]])
else:
IZblock.append([zrec[... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_sort_records_map'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | def _sort_records_map(records):
ctx = context.get()
l = len(records)
key_records = [None] * l
logging.debug("Parsing")
for i in range(l):
proto = kv_pb.KeyValue()
proto.ParseFromString(records[i])
key_records[i] = (proto.key(), records[i])
logging.debug("Sorting")
key_records.sort(cmp=_compare... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_all_by_mapreduce_state'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children'... | def find_all_by_mapreduce_state(cls, mapreduce_state):
keys = cls.calculate_keys_by_mapreduce_state(mapreduce_state)
i = 0
while i < len(keys):
@db.non_transactional
def no_tx_get(i):
return db.get(keys[i:i+cls._MAX_STATES_IN_MEMORY])
states = no_tx_get(i)
for s in states:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'calculate_keys_by_mapreduce_state'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'chi... | def calculate_keys_by_mapreduce_state(cls, mapreduce_state):
if mapreduce_state is None:
return []
keys = []
for i in range(mapreduce_state.mapreduce_spec.mapper.shard_count):
shard_id = cls.shard_id_from_number(mapreduce_state.key().name(), i)
keys.append(cls.get_key_by_shard_id(shard_id)... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '32']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'split'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '29']}; {'id': '4', 'type': 'identifier', 'children': [],... | def split(cls,
n,
contiguous,
can_query=itertools.chain(itertools.repeat(True, 50),
itertools.repeat(False)).next,
_app=None):
if n < 1:
raise ValueError('n must be >= 1')
ranges = None
if can_query():
if not c... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_parse_raw_members'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10']}; {'id': '4', 'type': 'identifier', 'c... | def _parse_raw_members(
self, leaderboard_name, members, members_only=False, **options):
'''
Parse the raw leaders data as returned from a given leader board query. Do associative
lookups with the member to rank, score and potentially sort the results.
@param leaderboard_name... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '163']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'search'}, {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10', '13', '16', '19', '22', '25', '28', '31', '34', '37', '40',... | def search(title=None, artist=None, artist_id=None, combined=None, description=None, style=None, mood=None,
results=None, start=None, max_tempo=None, min_tempo=None,
max_duration=None, min_duration=None, max_loudness=None, min_loudness=None,
artist_max_familiarity=None, artist_min_famil... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list_campaigns'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | def list_campaigns(self, **kwargs):
kwargs = self._verify_sort_options(kwargs)
kwargs = self._verify_filters(kwargs, Campaign, True)
api = self._get_api(update_service.DefaultApi)
return PaginatedResponse(api.update_campaign_list, lwrap_type=Campaign, **kwargs) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list_campaign_device_states'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'chil... | def list_campaign_device_states(self, campaign_id, **kwargs):
kwargs = self._verify_sort_options(kwargs)
kwargs = self._verify_filters(kwargs, CampaignDeviceState, True)
kwargs["campaign_id"] = campaign_id
api = self._get_api(update_service.DefaultApi)
return PaginatedResponse(ap... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list_firmware_manifests'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': []... | def list_firmware_manifests(self, **kwargs):
kwargs = self._verify_sort_options(kwargs)
kwargs = self._verify_filters(kwargs, FirmwareManifest, True)
api = self._get_api(update_service.DefaultApi)
return PaginatedResponse(api.firmware_manifest_list, lwrap_type=FirmwareManifest, **kwargs) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'merge_bams'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10']}; {'id': '4', 'type': 'identifier', 'children'... | def merge_bams(self, input_bams, merged_bam, in_sorted="TRUE", tmp_dir=None):
if not len(input_bams) > 1:
print("No merge required")
return 0
outdir, _ = os.path.split(merged_bam)
if outdir and not os.path.exists(outdir):
print("Creating path to merge file's f... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'samtools_view'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [... | def samtools_view(self, file_name, param, postpend=""):
cmd = "{} view {} {} {}".format(
self.tools.samtools, param, file_name, postpend)
return subprocess.check_output(cmd, shell=True) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sam_conversions'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], '... | def sam_conversions(self, sam_file, depth=True):
cmd = self.tools.samtools + " view -bS " + sam_file + " > " + sam_file.replace(".sam", ".bam") + "\n"
cmd += self.tools.samtools + " sort " + sam_file.replace(".sam", ".bam") + " -o " + sam_file.replace(".sam", "_sorted.bam") + "\n"
cmd += self.to... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'bam_conversions'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], '... | def bam_conversions(self, bam_file, depth=True):
cmd = self.tools.samtools + " view -h " + bam_file + " > " + bam_file.replace(".bam", ".sam") + "\n"
cmd += self.tools.samtools + " sort " + bam_file + " -o " + bam_file.replace(".bam", "_sorted.bam") + "\n"
cmd += self.tools.samtools + " index " ... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_checkpoint'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | def _checkpoint(self, stage):
if stage is None:
return False
try:
is_checkpoint = stage.checkpoint
except AttributeError:
if hasattr(stage, "__call__"):
stage = stage.__name__
else:
base, ext = os.path.splitext(stage... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'geolocation_sort'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10']}; {'id': '4', 'type': 'identifier', 'chi... | def geolocation_sort(field_name, argument, unit, mode=None,
distance_type=None):
def inner(asc):
locations = request.values.getlist(argument, type=str)
field = {
'_geo_distance': {
field_name: locations,
'order': 'asc' if asc else 'des... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'eval_field'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'f... | def eval_field(field, asc):
if isinstance(field, dict):
if asc:
return field
else:
field = copy.deepcopy(field)
key = list(field.keys())[0]
field[key]['order'] = reverse_order(field[key]['order'])
return field
elif callable(field):
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'default_sorter_factory'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [],... | def default_sorter_factory(search, index):
sort_arg_name = 'sort'
urlfield = request.values.get(sort_arg_name, '', type=str)
if not urlfield:
has_query = request.values.get('q', type=six.text_type)
urlfield = current_app.config['RECORDS_REST_DEFAULT_SORT'].get(
index, {}).get('qu... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'MakeHistFromList'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def MakeHistFromList(t, name=''):
hist = Hist(name=name)
[hist.Incr(x) for x in t]
return hist |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'MakePmfFromList'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | def MakePmfFromList(t, name=''):
hist = MakeHistFromList(t)
d = hist.GetDict()
pmf = Pmf(d, name)
pmf.Normalize()
return pmf |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'MakeSuiteFromList'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | def MakeSuiteFromList(t, name=''):
hist = MakeHistFromList(t)
d = hist.GetDict()
return MakeSuiteFromDict(d) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_precursor'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | def sort_precursor(c, loci):
data_loci = [[x, loci[x].chr, int(loci[x].start), int(loci[x].end), loci[x].strand, len(c.loci2seq[x])] for x in list(c.loci2seq.keys())]
data_loci = sorted(data_loci, key=itemgetter(5), reverse=True)
return data_loci |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_merge_similar'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | def _merge_similar(loci, loci_similarity):
n_cluster = 0
internal_cluster = {}
clus_seen = {}
loci_sorted = sorted(loci_similarity.iteritems(), key=operator.itemgetter(1), reverse=True)
for pairs, sim in loci_sorted:
common = sim > parameters.similar
n_cluster += 1
logger.deb... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_solve_loci_deprecated'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identif... | def _solve_loci_deprecated(c, locilen_sorted, seen_seqs, filtered, maxseq, n_cluster):
first_run = 0
seen_seqs = list()
n_cluster += 1
logger.debug("_solve_loci:new cluster %s" % n_cluster)
new_c = cluster(n_cluster)
for idl, lenl in locilen_sorted:
locus_seqs = c.loci2seq[idl]
i... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'hash_prefix_list_checksum'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': ... | def hash_prefix_list_checksum(self, threat_list):
q = '''SELECT value FROM hash_prefix
WHERE threat_type=? AND platform_type=? AND threat_entry_type=?
ORDER BY value
'''
params = [threat_list.threat_type, threat_list.platform_type, threat_list.threat_entry_type]
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove_hash_prefix_indices'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'child... | def remove_hash_prefix_indices(self, threat_list, indices):
batch_size = 40
q = '''DELETE FROM hash_prefix
WHERE threat_type=? AND platform_type=? AND threat_entry_type=? AND value IN ({})
'''
prefixes_to_remove = self.get_hash_prefix_values_to_remove(threat_list, indices... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'has_equal_value'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children'... | def has_equal_value(state, ordered=False, ndigits=None, incorrect_msg=None):
if not hasattr(state, "parent"):
raise ValueError(
"You can only use has_equal_value() on the state resulting from check_column, check_row or check_result."
)
if incorrect_msg is None:
incorrect_msg ... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sorted_releases'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | def sorted_releases(self):
releases = [(parse_version(release.version), release)
for release in self.releases]
releases.sort(reverse=True)
return [release[1] for release in releases] |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '33']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'image_position_stochastic'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '11', '18', '21', '24', '27', '3... | def image_position_stochastic(self, source_x, source_y, kwargs_lens, search_window=10,
precision_limit=10**(-10), arrival_time_sort=True, x_center=0,
y_center=0, num_random=1000, verbose=False):
x_solve, y_solve = [], []
for i in range(... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '42']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'image_position_from_source'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '11', '14', '21', '24', '27', '... | def image_position_from_source(self, sourcePos_x, sourcePos_y, kwargs_lens, min_distance=0.1, search_window=10,
precision_limit=10**(-10), num_iter_max=100, arrival_time_sort=True,
initial_guess_cut=True, verbose=False, x_center=0, y_center=0, num_ra... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '29']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'count'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20', '23', '26']}; {'id': '4', 'type': 'ide... | def count(event_collection, timeframe=None, timezone=None, interval=None, filters=None, group_by=None, order_by=None,
max_age=None, limit=None):
_initialize_client_from_environment()
return _client.count(event_collection=event_collection, timeframe=timeframe, timezone=timezone,
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '30']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sum'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18', '21', '24', '27']}; {'id': '4', 'type': '... | def sum(event_collection, target_property, timeframe=None, timezone=None, interval=None, filters=None,
group_by=None, order_by=None, max_age=None, limit=None):
_initialize_client_from_environment()
return _client.sum(event_collection=event_collection, timeframe=timeframe, timezone=timezone,
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '30']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'multi_analysis'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18', '21', '24', '27']}; {'id': '4'... | def multi_analysis(event_collection, analyses, timeframe=None, interval=None, timezone=None,
filters=None, group_by=None, order_by=None, max_age=None, limit=None):
_initialize_client_from_environment()
return _client.multi_analysis(event_collection=event_collection, timeframe=timeframe,
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '31']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'select_unique'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13', '16', '19', '22', '25', '28']}; {'id'... | def select_unique(self, event_collection, target_property, timeframe=None, timezone=None, interval=None,
filters=None, group_by=None, order_by=None, max_age=None, limit=None):
params = self.get_params(event_collection=event_collection, timeframe=timeframe, timezone=timezone,
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_voltage'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | def check_voltage(grid, mode):
crit_nodes = {}
if mode == 'MV':
mv_max_v_level_lc_diff_normal = float(cfg_ding0.get('mv_routing_tech_constraints',
'mv_max_v_level_lc_diff_normal'))
mv_max_v_level_fc_diff_normal = float(cfg_ding0.get('mv... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'compute_savings_list'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], '... | def compute_savings_list(self, graph):
savings_list = {}
for i, j in graph.edges():
if repr(i) < repr(j):
t = (i, j)
else:
t = (j, i)
if i == graph.depot() or j == graph.depot():
continue
savings_list[t] = gr... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '26', '28']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ask_choice'}, {'id': '3', 'type': 'parameters', 'children': ['4', '9', '17']}; {'id': '4', 'type': 'typed_parameter', 'children... | def ask_choice(
*prompt: Token, choices: List[Any], func_desc: Optional[FuncDesc] = None
) -> Any:
if func_desc is None:
func_desc = lambda x: str(x)
tokens = get_ask_tokens(prompt)
info(*tokens)
choices.sort(key=func_desc)
for i, choice in enumerate(choices, start=1):
choice_des... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id... | def list(self):
backups = []
for d in glob(join(self.backup_directory, '*')):
backups.append(WorkspaceBackup.from_path(d))
backups.sort(key=lambda b: b.lastmod, reverse=True)
return backups |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'retrieve'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | def retrieve(self, operation, field=None):
obj = self._get(operation, field)
if obj is None:
return Mark(collection=self.collection, operation=operation, field=field)
return Mark.from_dict(self.collection, obj) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'query'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14']}; {'id': '4', 'type': 'identifier', 'children': []... | def query(self, properties=None, criteria=None, distinct_key=None,
**kwargs):
if properties is not None:
props, prop_dict = self._parse_properties(properties)
else:
props, prop_dict = None, None
crit = self._parse_criteria(criteria)
if self.query_pos... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_rows'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | def sort_rows(self, rows, section):
if section.lower() == Differ.CHANGED.lower():
sort_key = Differ.CHANGED_DELTA
else:
sort_key = None
if sort_key is not None:
rows.sort(key=itemgetter(sort_key)) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_free_crypto_domains'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': []... | def get_free_crypto_domains(self, crypto_adapters=None):
if crypto_adapters is None:
crypto_adapters = self.adapters.findall(type='crypto')
if not crypto_adapters:
return None
max_domains = None
for ca in crypto_adapters:
if max_domains is None:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'topological'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'nodes... | def topological(nodes):
order, enter, state = deque(), set(nodes), {}
def dfs(node):
state[node] = GRAY
for parent in nodes.get(node, ()):
color = state.get(parent, None)
if color == GRAY:
raise ValueError('cycle')
if color == BLACK:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_teachers_sorted'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | def get_teachers_sorted(self):
teachers = self.get_teachers()
teachers = [(u.last_name, u.first_name, u.id) for u in teachers]
for t in teachers:
if t is None or t[0] is None or t[1] is None or t[2] is None:
teachers.remove(t)
for t in teachers:
if... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sorted_bits'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | def sorted_bits(self) -> List[Tuple[str, int]]:
return sorted(self.bit.items(), key=lambda x: x[1]) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sorted_enums'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | def sorted_enums(self) -> List[Tuple[str, int]]:
return sorted(self.enum.items(), key=lambda x: x[1]) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'collate'}, {'id': '3', 'type': 'parameters', 'children': ['4', '6']}; {'id': '4', 'type': 'list_splat_pattern', 'children': ['5']}, {'... | def collate(*iterables, **kwargs):
key = kwargs.pop('key', lambda a: a)
reverse = kwargs.pop('reverse', False)
min_or_max = max if reverse else min
rows = [iter(iterable) for iterable in iterables if iterable]
next_values = {}
by_key = []
def gather_next_value(row, index):
try:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'order_key_defs'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ke... | def order_key_defs(key_def):
_int = []
for kd in key_def:
if len(kd['use']) > 1:
for _use in kd['use']:
_kd = kd.copy()
_kd['use'] = _use
_int.append(_kd)
else:
_int.append(kd)
_int.sort(key=cmp_to_key(sort_func))
re... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'wait'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | def wait(self, condition_or_value, timeout=None):
if (isinstance(condition_or_value, collections.Sequence) and not
isinstance(condition_or_value, basestring)):
raise NotImplementedError(
'Currently only single conditions are supported')
condition_test = (condi... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_find_nearest_conn_objects'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'child... | def _find_nearest_conn_objects(network, node, branches):
conn_diff_tolerance = network.config['grid_connection'][
'conn_diff_tolerance']
conn_objects_min_stack = []
node_shp = transform(proj2equidistant(network), node.geom)
for branch in branches:
stations = branch['adj_nodes']
s... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'mv_voltage_deviation'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], '... | def mv_voltage_deviation(network, voltage_levels='mv_lv'):
crit_nodes = {}
v_dev_allowed_per_case = {}
v_dev_allowed_per_case['feedin_case_lower'] = 0.9
v_dev_allowed_per_case['load_case_upper'] = 1.1
offset = network.config[
'grid_expansion_allowed_voltage_deviations']['hv_mv_trafo_offset']... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'calc_geo_lines_in_buffer'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier'... | def calc_geo_lines_in_buffer(network, node, grid, radius, radius_inc):
lines = []
while not lines:
node_shp = transform(proj2equidistant(network), node.geom)
buffer_zone_shp = node_shp.buffer(radius)
for line in grid.graph.lines():
nodes = line['adj_nodes']
branch... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_group_by_size_greedy'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], ... | def _group_by_size_greedy(obj_list, tot_groups):
sorted_list = sorted(obj_list, key=lambda x: x['size'], reverse=True)
groups = [[] for _ in range(tot_groups)]
for index, obj in enumerate(sorted_list):
current_group = groups[index % len(groups)]
current_group.append(obj)
return groups |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dimensions_from_subgroups'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], '... | def dimensions_from_subgroups(s):
letters = 'XYABCDEFGHIJKLMNOPQRSTUVWZ'
return ' '.join(['dim{0}={1}'.format(dim, sg.name) for dim, sg in zip(letters, s)]) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'filter_composite_from_subgroups'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children':... | def filter_composite_from_subgroups(s):
dims = []
for letter, sg in zip('ABCDEFGHIJKLMNOPQRSTUVWZ', s[2:]):
dims.append('dim{0}'.format(letter))
if dims:
return ' '.join(dims) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_videos_for_filter'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '13']}; {'id': '4', 'type': 'identifier', 'ch... | def _get_videos_for_filter(video_filter, sort_field=None, sort_dir=SortDirection.asc, pagination_conf=None):
videos = Video.objects.filter(**video_filter)
paginator_context = {}
if sort_field:
videos = videos.order_by(sort_field.value, "edx_video_id")
if sort_dir == SortDirection.desc:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_videos_for_course'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '13']}; {'id': '4', 'type': 'identifier', 'chi... | def get_videos_for_course(course_id, sort_field=None, sort_dir=SortDirection.asc, pagination_conf=None):
return _get_videos_for_filter(
{'courses__course_id': six.text_type(course_id), 'courses__is_hidden': False},
sort_field,
sort_dir,
pagination_conf,
) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_videos_for_ids'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [... | def get_videos_for_ids(
edx_video_ids,
sort_field=None,
sort_dir=SortDirection.asc
):
videos, __ = _get_videos_for_filter(
{"edx_video_id__in":edx_video_ids},
sort_field,
sort_dir,
)
return videos |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'put'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | def put(self, block_id, priority, pb_type='offline'):
if pb_type not in ('offline', 'realtime'):
raise ValueError('Invalid PB type.')
with self._mutex:
added_time = datetime.datetime.utcnow().isoformat()
entry = (priority, sys.maxsize-self._index, block_id, pb_type,
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_device'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | def sort_device(self):
self.devices.sort()
idx = []
names = []
for dev in order:
if dev in all_models:
all_dev = list(sorted(all_models[dev].keys()))
for item in all_dev:
if item in self.devices:
idx.... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '21']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'export_csv'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18']}; {'id': '4', 'type': 'identifier'... | def export_csv(self, path, idx=None, header=None, formatted=False,
sort_idx=True, fmt='%.18e'):
if not idx:
idx = self._idx
if not header:
header = self.get_header(idx, formatted=formatted)
assert len(idx) == len(header), \
"Idx length does ... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_event_times'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | def get_event_times(self):
times = []
times.extend(self.Breaker.get_times())
for model in self.__dict__['Event'].all_models:
times.extend(self.__dict__[model].get_times())
if times:
times = sorted(list(set(times)))
return times |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_sort_field'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 're... | def get_sort_field(request):
sort_direction = request.GET.get("dir")
field_name = (request.GET.get("sort") or "") if sort_direction else ""
sort_sign = "-" if sort_direction == "desc" else ""
result_field = "{sign}{field}".format(sign=sort_sign, field=field_name)
return result_field |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'linkage_group_ordering'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | def linkage_group_ordering(linkage_records):
new_records = dict()
for lg_name, linkage_group in itertools.groupby(
linkage_records, operator.itemgetter(0)
):
new_records[lg_name] = []
for record in linkage_group:
init_contig = record[-1]
start = record[1]
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '43']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_issues'}, {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10', '13', '16', '19', '22', '25', '28', '31', '34', '37', '4... | def get_issues(repo_name=None,
profile='github',
milestone=None,
state='open',
assignee=None,
creator=None,
mentioned=None,
labels=None,
sort='created',
direction='desc',
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '25']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_milestones'}, {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10', '13', '16', '19', '22']}; {'id': '4', 'type': 'defau... | def get_milestones(repo_name=None,
profile='github',
state='open',
sort='due_on',
direction='asc',
output='min',
per_page=None):
'''
Return information about milestones for a given repository.
.... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '31']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_prs'}, {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10', '13', '16', '19', '22', '25', '28']}; {'id': '4', 'type': '... | def get_prs(repo_name=None,
profile='github',
state='open',
head=None,
base=None,
sort='created',
direction='desc',
output='min',
per_page=None):
'''
Returns information for all pull requests in a given repository, b... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_diff_lists'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def _diff_lists(old, new, comparator):
'''
Compare lists to extract the changes
:param old: old list
:param new: new list
:return: a dictionary with ``unchanged``, ``new``, ``deleted`` and ``sorted`` keys
The sorted list is the union of unchanged and new lists, but keeping the original
order... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_job_sorting_key'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def _job_sorting_key(self, job):
if self._base_graph is None:
return 0
MAX_JOBS = 1000000
if job.addr not in self._node_addr_visiting_order:
return MAX_JOBS
return self._node_addr_visiting_order.index(job.addr) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'instruction_addresses'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def instruction_addresses(self):
addrs = [ ]
for b in sorted(self.blocks, key=lambda x: x.addr):
addrs.extend(b.instruction_addresses())
return sorted(set(addrs), key=lambda x: x[0]) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'desymbolize'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | def desymbolize(self):
self.sort = 'unknown'
content = self.binary.fast_memory_load(self.addr, self.size, bytes)
self.content = [ content ] |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'append_data'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '11']}; {'id': '4', 'type': 'identifier', 'chi... | def append_data(self, name, initial_content, size, readonly=False, sort="unknown"):
if readonly:
section_name = ".rodata"
else:
section_name = '.data'
if initial_content is None:
initial_content = b""
initial_content = initial_content.ljust(size, b"\x0... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pop_job'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self... | def pop_job(self, returning=True):
if not self:
return None
if not returning:
return self._pop_job(next(reversed(self._jobs.keys())))
for func_addr in reversed(self._jobs.keys()):
if func_addr not in self._returning_functions:
continue
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_min_addr'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | def _get_min_addr(self):
if not self._regions:
if self.project.arch.name != "Soot":
l.error("self._regions is empty or not properly set.")
return None
return next(self._regions.irange()) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_job_sorting_key'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def _job_sorting_key(self, job):
MAX_BLOCKS_PER_FUNCTION = 1000000
task_functions = list(reversed(
list(task.function_address for task in self._task_stack if isinstance(task, FunctionAnalysis))
))
try:
function_pos = task_functions.index(job.func_addr)
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_merge_points'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | def _merge_points(self, function_address):
try:
new_function = self.kb.functions[function_address]
except KeyError:
return [ ]
if function_address not in self._function_merge_points:
ordered_merge_points = CFGUtils.find_merge_points(function_address, new_funct... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_widening_points'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def _widening_points(self, function_address):
try:
new_function = self.kb.functions[function_address]
except KeyError:
return [ ]
if function_address not in self._function_widening_points:
if not new_function.normalized:
new_function.normalize(... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_variables'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | def get_variables(self, sort=None, collapse_same_ident=False):
variables = [ ]
if collapse_same_ident:
raise NotImplementedError()
for var in self._variables:
if sort == 'stack' and not isinstance(var, SimStackVariable):
continue
if sort == 're... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_merge_points'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [],... | def find_merge_points(function_addr, function_endpoints, graph):
merge_points = set()
for node in graph.nodes():
if graph.in_degree(node) > 1:
merge_points.add(node)
ordered_merge_points = CFGUtils.quasi_topological_sort_nodes(graph, merge_points)
addrs = [n.a... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reverse_post_order_sort_nodes'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'childre... | def reverse_post_order_sort_nodes(graph, nodes=None):
post_order = networkx.dfs_postorder_nodes(graph)
if nodes is None:
return reversed(list(post_order))
addrs_to_index = {}
for i, n in enumerate(post_order):
addrs_to_index[n.addr] = i
return sorted(nodes... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '23']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'split'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20']}; {'id': '4', 'type': 'identifier', 'c... | def split(self, stash_splitter=None, stash_ranker=None, state_ranker=None,
limit=8, from_stash='active', to_stash='stashed'):
states = self._fetch_states(stash=from_stash)
if stash_splitter is not None:
keep, split = stash_splitter(states)
elif stash_ranker is not None:... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_executable_memory_regions'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'chil... | def _executable_memory_regions(self, objects=None, force_segment=False):
if objects is None:
binaries = self.project.loader.all_objects
else:
binaries = objects
memory_regions = [ ]
for b in binaries:
if isinstance(b, ELF):
if not force... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_debug_check'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self... | def _debug_check(self):
old_end = 0
old_sort = ""
for segment in self._list:
if segment.start <= old_end and segment.sort == old_sort:
raise AngrCFGError("Error in SegmentList: blocks are not merged")
old_end = segment.end
old_sort = segment.so... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'next_pos_with_sort_not_in'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', '... | def next_pos_with_sort_not_in(self, address, sorts, max_distance=None):
list_length = len(self._list)
idx = self._search(address)
if idx < list_length:
block = self._list[idx]
if max_distance is not None and address + max_distance < block.start:
return Non... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'occupied_by_sort'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def occupied_by_sort(self, address):
idx = self._search(address)
if len(self._list) <= idx:
return None
if self._list[idx].start <= address < self._list[idx].end:
return self._list[idx].sort
if idx > 0 and address < self._list[idx - 1].end:
return self... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_binary_insert'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10']}; {'id': '4', 'type': 'identifier', 'child... | def _binary_insert(lst, elem, key, lo=0, hi=None):
if lo < 0:
raise ValueError("lo must be a non-negative number")
if hi is None:
hi = len(lst)
while lo < hi:
mid = (lo + hi) // 2
if key(lst[mid]) < key(elem):
lo = mid + 1
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_sort_io_counters'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': []... | def _sort_io_counters(process,
sortedby='io_counters',
sortedby_secondary='memory_percent'):
return process[sortedby][0] - process[sortedby][2] + process[sortedby][1] - process[sortedby][3] |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_sort_lambda'}, {'id': '3', 'type': 'parameters', 'children': ['4', '7']}; {'id': '4', 'type': 'default_parameter', 'children': ['5',... | def _sort_lambda(sortedby='cpu_percent',
sortedby_secondary='memory_percent'):
ret = None
if sortedby == 'io_counters':
ret = _sort_io_counters
elif sortedby == 'cpu_times':
ret = _sort_cpu_times
return ret |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'loop_position'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | def loop_position(self):
for i, v in enumerate(self._sort_loop):
if v == glances_processes.sort_key:
return i
return 0 |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_event_sort_key'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | def get_event_sort_key(self, event_type):
if event_type.startswith("MEM"):
ret = 'memory_percent'
elif event_type.startswith("CPU_IOWAIT"):
ret = 'io_counters'
else:
ret = 'cpu_percent'
return ret |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'set_process_sort'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def set_process_sort(self, event_type):
if glances_processes.auto_sort:
glances_processes.sort_key = self.get_event_sort_key(event_type) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.