sequence
stringlengths
546
16.2k
code
stringlengths
108
19.3k
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:previous; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 19; 5, 30; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 14; 9, comparison_operator:==; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifi...
def previous(self): """ Gets the previous page, respecting sort order """ if self._order_by == 'oldest': return self.older if self._order_by == 'newest': return self.newer return None
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:next; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 19; 5, 30; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 14; 9, comparison_operator:==; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:s...
def next(self): """ Gets the next page, respecting sort order """ if self._order_by == 'oldest': return self.newer if self._order_by == 'newest': return self.older return None
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:newest; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 19; 5, 30; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 14; 9, comparison_operator:==; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier...
def newest(self): """ Gets the newest entry in the view, regardless of sort order """ 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))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:oldest; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 19; 5, 30; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 14; 9, comparison_operator:==; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier...
def oldest(self): """ Gets the oldest entry in the view, regardless of sort order """ 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))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_dataframe_cols; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 9; 5, 17; 5, 41; 5, 50; 5, 54; 5, 55; 5, 73; 5, 83; 5, 87; 5, 88; 5, 102; 5, 103; 5, 122; 5, 123; 5, 130; 5, 131; 5, 164; 5, 165; 5, 175; 6, expression_state...
def sort_dataframe_cols(self): """ Sort self.df so that self.name is the first column, and the rest of the columns are sorted by group. """ # get the group for each column cols = self.df.columns groups = list(map(lambda x: self.data_model.get_group_for_col(self.dt...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_diclist; 3, parameters; 3, 4; 3, 5; 4, identifier:undecorated; 5, identifier:sort_on; 6, block; 6, 7; 6, 9; 6, 40; 6, 46; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identi...
def sort_diclist(undecorated, sort_on): """ Sort a list of dictionaries by the value in each dictionary for the sorting key Parameters ---------- undecorated : list of dicts sort_on : str, numeric key that is present in all dicts to sort on Returns --------- ordered lis...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:process_data_for_mean; 3, parameters; 3, 4; 3, 5; 4, identifier:data; 5, identifier:direction_type_key; 6, block; 6, 7; 6, 9; 6, 19; 6, 20; 6, 42; 6, 50; 6, 58; 6, 65; 6, 66; 6, 377; 7, expression_statement; 7, 8; 8, comment; 9, expression_stat...
def process_data_for_mean(data, direction_type_key): """ takes list of dicts with dec and inc as well as direction_type if possible or method_codes and sorts the data into lines and planes and process it for fisher means @param: data - list of dicts with dec inc and some manner of PCA type info @param:...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:main; 3, parameters; 4, block; 4, 5; 4, 7; 4, 11; 4, 15; 4, 43; 4, 63; 4, 91; 4, 105; 4, 113; 4, 123; 4, 124; 4, 125; 4, 126; 4, 137; 4, 154; 4, 155; 4, 165; 4, 254; 4, 255; 5, expression_statement; 5, 6; 6, comment; 7, expression_statement; 7,...
def main(): """ NAME sort_specimens.py DESCRIPTION Reads in a pmag_specimen formatted file and separates it into different components (A,B...etc.) SYNTAX sort_specimens.py [-h] [command line options] INPUT takes pmag_specimens.txt formatted input file OPTIONS...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:read_magic_file; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:path; 6, identifier:sort_by_this_name; 7, block; 7, 8; 7, 10; 7, 14; 7, 48; 7, 49; 7, 50; 7, 56; 7, 70; 7, 74; 7, 171; 7, 172; 7, 178; 8, expression_statement; ...
def read_magic_file(self, path, sort_by_this_name): """ reads a magic formated data file from path and sorts the keys according to sort_by_this_name Parameters ---------- path : path to file to read sort_by_this_name : variable to sort data by """ ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:plot_teq; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:fignum; 5, identifier:araiblock; 6, identifier:s; 7, identifier:pars; 8, block; 8, 9; 8, 11; 8, 23; 8, 24; 8, 33; 8, 39; 8, 49; 8, 90; 8, 95; 8, 137; 8, 179; 8, 202; 8, 215; 8, 216;...
def plot_teq(fignum, araiblock, s, pars): """ plots directions of pTRM steps and zero field steps Parameters __________ fignum : figure number for matplotlib object araiblock : nested list of data from pmag.sortarai() s : specimen name pars : default is "", otherwise is diction...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_sort_records_map; 3, parameters; 3, 4; 4, identifier:records; 5, block; 5, 6; 5, 8; 5, 16; 5, 23; 5, 30; 5, 37; 5, 75; 5, 82; 5, 91; 5, 98; 5, 106; 5, 115; 5, 124; 5, 159; 5, 167; 5, 179; 5, 208; 5, 215; 5, 221; 5, 240; 6, expression_statement...
def _sort_records_map(records): """Map function sorting records. Converts records to KeyValue protos, sorts them by key and writes them into new GCS file. Creates _OutputFile entity to record resulting file name. Args: records: list of records which are serialized KeyValue protos. """ ctx = context....
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:find_all_by_mapreduce_state; 3, parameters; 3, 4; 3, 5; 4, identifier:cls; 5, identifier:mapreduce_state; 6, block; 6, 7; 6, 9; 6, 18; 6, 22; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10,...
def find_all_by_mapreduce_state(cls, mapreduce_state): """Find all shard states for given mapreduce. Args: mapreduce_state: MapreduceState instance Yields: shard states sorted by shard id. """ keys = cls.calculate_keys_by_mapreduce_state(mapreduce_state) i = 0 while i < len(key...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:calculate_keys_by_mapreduce_state; 3, parameters; 3, 4; 3, 5; 4, identifier:cls; 5, identifier:mapreduce_state; 6, block; 6, 7; 6, 9; 6, 16; 6, 20; 6, 63; 7, expression_statement; 7, 8; 8, comment; 9, if_statement; 9, 10; 9, 13; 10, comparison_...
def calculate_keys_by_mapreduce_state(cls, mapreduce_state): """Calculate all shard states keys for given mapreduce. Args: mapreduce_state: MapreduceState instance Returns: A list of keys for shard states, sorted by shard id. The corresponding shard states may not exist. """ if m...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 32; 1, 33; 2, function_name:split; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 29; 4, identifier:cls; 5, identifier:n; 6, identifier:contiguous; 7, default_parameter; 7, 8; 7, 9; 8, identifier:can_query; 9, attribute; 9, 10; 9, 28; 10, call; 10, 11; 10, 14; 11, attr...
def split(cls, n, contiguous, can_query=itertools.chain(itertools.repeat(True, 50), itertools.repeat(False)).next, _app=None): # pylint: disable=g-doc-args """Splits the complete NamespaceRange into n equally-sized NamespaceRa...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:_parse_raw_members; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:self; 5, identifier:leaderboard_name; 6, identifier:members; 7, default_parameter; 7, 8; 7, 9; 8, identifier:members_only; 9, False; 10, dictionary_splat_pattern; ...
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_nam...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 163; 2, function_name:search; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 3, 25; 3, 28; 3, 31; 3, 34; 3, 37; 3, 40; 3, 43; 3, 46; 3, 49; 3, 52; 3, 55; 3, 58; 3, 61; 3, 64; 3, 67; 3, 70; 3, 73; 3, 76; 3, 79; 3, 82; 3, 85; 3, 88; 3, 91; 3, 94; 3, 9...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:list_campaigns; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 10; 7, 19; 7, 30; 7, 41; 8, expression_statement; 8, 9; 9, comment; 10, expression_statement; 10, 11; 11,...
def list_campaigns(self, **kwargs): """List all update campaigns. :param int limit: number of campaigns to retrieve :param str order: sort direction of campaigns when ordered by creation time (desc|asc) :param str after: get campaigns after given campaign ID :param dict filters:...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:list_campaign_device_states; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:campaign_id; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 11; 8, 20; 8, 31; 8, 37; 8, 48; 9, expression_statement; 9,...
def list_campaign_device_states(self, campaign_id, **kwargs): """List campaign devices status. :param str campaign_id: Id of the update campaign (Required) :param int limit: number of devices state to retrieve :param str order: sort direction of device state when ordered by creation tim...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:list_firmware_manifests; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 10; 7, 19; 7, 30; 7, 41; 8, expression_statement; 8, 9; 9, comment; 10, expression_statement; 10...
def list_firmware_manifests(self, **kwargs): """List all manifests. :param int limit: number of manifests to retrieve :param str order: sort direction of manifests when ordered by time. 'desc' or 'asc' :param str after: get manifests after given `image_id` :param dict filters: D...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:merge_bams; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:self; 5, identifier:input_bams; 6, identifier:merged_bam; 7, default_parameter; 7, 8; 7, 9; 8, identifier:in_sorted; 9, string:"TRUE"; 10, default_parameter; 10, 11; 10, 1...
def merge_bams(self, input_bams, merged_bam, in_sorted="TRUE", tmp_dir=None): """ Combine multiple files into one. The tmp_dir parameter is important because on poorly configured systems, the default can sometimes fill up. :param Iterable[str] input_bams: Paths to files to comb...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:samtools_view; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:file_name; 6, identifier:param; 7, default_parameter; 7, 8; 7, 9; 8, identifier:postpend; 9, string:""; 10, block; 10, 11; 10, 13; 10, 29; 11, expression_s...
def samtools_view(self, file_name, param, postpend=""): """ Run samtools view, with flexible parameters and post-processing. This is used internally to implement the various count_reads functions. :param str file_name: file_name :param str param: String of parameters to pass to...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:sam_conversions; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:sam_file; 6, default_parameter; 6, 7; 6, 8; 7, identifier:depth; 8, True; 9, block; 9, 10; 9, 12; 9, 36; 9, 66; 9, 86; 9, 119; 10, expression_statement; 10, 11;...
def sam_conversions(self, sam_file, depth=True): """ Convert sam files to bam files, then sort and index them for later use. :param bool depth: also calculate coverage over each position """ cmd = self.tools.samtools + " view -bS " + sam_file + " > " + sam_file.replace(".sam", "...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:bam_conversions; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:bam_file; 6, default_parameter; 6, 7; 6, 8; 7, identifier:depth; 8, True; 9, block; 9, 10; 9, 12; 9, 36; 9, 60; 9, 80; 9, 113; 10, expression_statement; 10, 11;...
def bam_conversions(self, bam_file, depth=True): """ Sort and index bam files for later use. :param bool depth: also calculate coverage over each position """ cmd = self.tools.samtools + " view -h " + bam_file + " > " + bam_file.replace(".bam", ".sam") + "\n" cmd += self...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_checkpoint; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:stage; 6, block; 6, 7; 6, 9; 6, 10; 6, 11; 6, 12; 6, 19; 6, 111; 6, 121; 6, 147; 7, expression_statement; 7, 8; 8, comment; 9, comment; 10, comment; 11, comment; 12, if_s...
def _checkpoint(self, stage): """ Decide whether to stop processing of a pipeline. This is the hook A pipeline can report various "checkpoints" as sort of status markers that designate the logical processing phase that's just been completed. The initiation of a pipeline can preo...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:geolocation_sort; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:field_name; 5, identifier:argument; 6, identifier:unit; 7, default_parameter; 7, 8; 7, 9; 8, identifier:mode; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, ide...
def geolocation_sort(field_name, argument, unit, mode=None, distance_type=None): """Sort field factory for geo-location based sorting. :param argument: Name of URL query string field to parse pin location from. Multiple locations can be provided. Each location can be either a ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:eval_field; 3, parameters; 3, 4; 3, 5; 4, identifier:field; 5, identifier:asc; 6, block; 6, 7; 6, 9; 7, expression_statement; 7, 8; 8, comment; 9, if_statement; 9, 10; 9, 15; 9, 63; 9, 74; 10, call; 10, 11; 10, 12; 11, identifier:isinstance; 12...
def eval_field(field, asc): """Evaluate a field for sorting purpose. :param field: Field definition (string, dict or callable). :param asc: ``True`` if order is ascending, ``False`` if descending. :returns: Dictionary with the sort field query. """ if isinstance(field, dict): if asc: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:default_sorter_factory; 3, parameters; 3, 4; 3, 5; 4, identifier:search; 5, identifier:index; 6, block; 6, 7; 6, 9; 6, 13; 6, 28; 6, 29; 6, 73; 6, 74; 6, 83; 6, 84; 6, 103; 6, 112; 6, 113; 6, 133; 7, expression_statement; 7, 8; 8, comment; 9, e...
def default_sorter_factory(search, index): """Default sort query factory. :param query: Search query. :param index: Index to search in. :returns: Tuple of (query, URL arguments). """ sort_arg_name = 'sort' urlfield = request.values.get(sort_arg_name, '', type=str) # Get default sorting...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:MakeHistFromList; 3, parameters; 3, 4; 3, 5; 4, identifier:t; 5, default_parameter; 5, 6; 5, 7; 6, identifier:name; 7, string:''; 8, block; 8, 9; 8, 11; 8, 20; 8, 31; 9, expression_statement; 9, 10; 10, comment; 11, expression_statement; 11, 12...
def MakeHistFromList(t, name=''): """Makes a histogram from an unsorted sequence of values. Args: t: sequence of numbers name: string name for this histogram Returns: Hist object """ hist = Hist(name=name) [hist.Incr(x) for x in t] return hist
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:MakePmfFromList; 3, parameters; 3, 4; 3, 5; 4, identifier:t; 5, default_parameter; 5, 6; 5, 7; 6, identifier:name; 7, string:''; 8, block; 8, 9; 8, 11; 8, 18; 8, 26; 8, 34; 8, 40; 9, expression_statement; 9, 10; 10, comment; 11, expression_stat...
def MakePmfFromList(t, name=''): """Makes a PMF from an unsorted sequence of values. Args: t: sequence of numbers name: string name for this PMF Returns: Pmf object """ hist = MakeHistFromList(t) d = hist.GetDict() pmf = Pmf(d, name) pmf.Normalize() return p...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:MakeSuiteFromList; 3, parameters; 3, 4; 3, 5; 4, identifier:t; 5, default_parameter; 5, 6; 5, 7; 6, identifier:name; 7, string:''; 8, block; 8, 9; 8, 11; 8, 18; 8, 26; 9, expression_statement; 9, 10; 10, comment; 11, expression_statement; 11, 1...
def MakeSuiteFromList(t, name=''): """Makes a suite from an unsorted sequence of values. Args: t: sequence of numbers name: string name for this suite Returns: Suite object """ hist = MakeHistFromList(t) d = hist.GetDict() return MakeSuiteFromDict(d)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_precursor; 3, parameters; 3, 4; 3, 5; 4, identifier:c; 5, identifier:loci; 6, block; 6, 7; 6, 9; 6, 10; 6, 11; 6, 12; 6, 64; 6, 80; 7, expression_statement; 7, 8; 8, comment; 9, comment; 10, comment; 11, comment; 12, expression_statement; ...
def sort_precursor(c, loci): """ Sort loci according to number of sequences mapped there. """ # Original Py 2.7 code #data_loci = map(lambda (x): [x, loci[x].chr, int(loci[x].start), int(loci[x].end), loci[x].strand, len(c.loci2seq[x])], c.loci2seq.keys()) # 2to3 suggested Py 3 rewrite data_...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_merge_similar; 3, parameters; 3, 4; 3, 5; 4, identifier:loci; 5, identifier:loci_similarity; 6, block; 6, 7; 6, 9; 6, 13; 6, 17; 6, 21; 6, 43; 6, 308; 6, 320; 6, 336; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 1...
def _merge_similar(loci, loci_similarity): """ Internal function to reduce loci complexity :param loci: class cluster :param locilen_sorted: list of loci sorted by size :return c: updated class cluster """ n_cluster = 0 internal_cluster = {} clus_seen = {} loci_sorted = so...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:_solve_loci_deprecated; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:c; 5, identifier:locilen_sorted; 6, identifier:seen_seqs; 7, identifier:filtered; 8, identifier:maxseq; 9, identifier:n_cluster; 10, block; 10, 11; 10, 13...
def _solve_loci_deprecated(c, locilen_sorted, seen_seqs, filtered, maxseq, n_cluster): """internal function to reduce loci complexity The function will read the all loci in a cluster of sequences and will determine if all loci are part of the same transcriptional unit(TU) by most-vote locus or by e...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:hash_prefix_list_checksum; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:threat_list; 6, block; 6, 7; 6, 9; 6, 13; 6, 26; 6, 80; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 1...
def hash_prefix_list_checksum(self, threat_list): """Returns SHA256 checksum for alphabetically-sorted concatenated list of hash prefixes""" q = '''SELECT value FROM hash_prefix WHERE threat_type=? AND platform_type=? AND threat_entry_type=? ORDER BY value ''' ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:remove_hash_prefix_indices; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:threat_list; 6, identifier:indices; 7, block; 7, 8; 7, 10; 7, 14; 7, 18; 7, 28; 8, expression_statement; 8, 9; 9, comment; 10, expression_statement; ...
def remove_hash_prefix_indices(self, threat_list, indices): """Remove records matching idices from a lexicographically-sorted local threat list.""" batch_size = 40 q = '''DELETE FROM hash_prefix WHERE threat_type=? AND platform_type=? AND threat_entry_type=? AND value IN ({}) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:has_equal_value; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:state; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ordered; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ndigits; 10, None; 11, default_parameter; 11, 12;...
def has_equal_value(state, ordered=False, ndigits=None, incorrect_msg=None): """Verify if a student and solution query result match up. This function must always be used after 'zooming' in on certain columns or records (check_column, check_row or check_result). ``has_equal_value`` then goes over all column...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sorted_releases; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 25; 5, 34; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:releases; 11, list_comprehension...
def sorted_releases(self): """ Releases sorted by version. """ releases = [(parse_version(release.version), release) for release in self.releases] releases.sort(reverse=True) return [release[1] for release in releases]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 33; 2, function_name:image_position_stochastic; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 3, 18; 3, 21; 3, 24; 3, 27; 3, 30; 4, identifier:self; 5, identifier:source_x; 6, identifier:source_y; 7, identifier:kwargs_lens; 8, default_parameter; 8, 9; 8, 10;...
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): """ Solves the lens equation stochastical...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 42; 2, function_name:image_position_from_source; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 3, 14; 3, 21; 3, 24; 3, 27; 3, 30; 3, 33; 3, 36; 3, 39; 4, identifier:self; 5, identifier:sourcePos_x; 6, identifier:sourcePos_y; 7, identifier:kwargs_lens; 8, def...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 29; 2, function_name:count; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 4, identifier:event_collection; 5, default_parameter; 5, 6; 5, 7; 6, identifier:timeframe; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:timezone; 10...
def count(event_collection, timeframe=None, timezone=None, interval=None, filters=None, group_by=None, order_by=None, max_age=None, limit=None): """ Performs a count query Counts the number of events that meet the given criteria. :param event_collection: string, the name of the collection to que...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 30; 2, function_name:sum; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 3, 27; 4, identifier:event_collection; 5, identifier:target_property; 6, default_parameter; 6, 7; 6, 8; 7, identifier:timeframe; 8, None; 9, default_parameter; 9, 1...
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): """ Performs a sum query Adds the values of a target property for events that meet the given criteria. :param event_collection: string, th...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 30; 2, function_name:multi_analysis; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 3, 27; 4, identifier:event_collection; 5, identifier:analyses; 6, default_parameter; 6, 7; 6, 8; 7, identifier:timeframe; 8, None; 9, default_parameter; ...
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): """ Performs a multi-analysis query Returns a dictionary of analysis results. :param event_collection: string, the name of ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 31; 2, function_name:select_unique; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 3, 25; 3, 28; 4, identifier:self; 5, identifier:event_collection; 6, identifier:target_property; 7, default_parameter; 7, 8; 7, 9; 8, identifier:timeframe...
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): """ Performs a select unique query Returns an array of the unique values of a target property for events ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:check_voltage; 3, parameters; 3, 4; 3, 5; 4, identifier:grid; 5, identifier:mode; 6, block; 6, 7; 6, 9; 6, 13; 6, 141; 6, 159; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identi...
def check_voltage(grid, mode): """ Checks for voltage stability issues at all nodes for MV or LV grid Parameters ---------- grid : GridDing0 Grid identifier. mode : str Kind of grid ('MV' or 'LV'). Returns ------- :any:`list` of :any:`GridDing0` List of critical...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:compute_savings_list; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:graph; 6, block; 6, 7; 6, 9; 6, 13; 6, 103; 6, 128; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11...
def compute_savings_list(self, graph): """Compute Clarke and Wright savings list A saving list is a matrix containing the saving amount S between i and j S is calculated by S = d(0,i) + d(0,j) - d(i,j) (CLARKE; WRIGHT, 1964) Args ---- graph: :networkx:`NetworkX...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 26; 1, 28; 2, function_name:ask_choice; 3, parameters; 3, 4; 3, 9; 3, 17; 4, typed_parameter; 4, 5; 4, 7; 5, list_splat_pattern; 5, 6; 6, identifier:prompt; 7, type; 7, 8; 8, identifier:Token; 9, typed_parameter; 9, 10; 9, 11; 10, identifier:choices; 11, type; 11,...
def ask_choice( *prompt: Token, choices: List[Any], func_desc: Optional[FuncDesc] = None ) -> Any: """Ask the user to choose from a list of choices. :return: the selected choice ``func_desc`` will be called on every list item for displaying and sorting the list. If not given, will default to t...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:list; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 12; 5, 37; 5, 54; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:backups; 11, list:[]; 12, for_statem...
def list(self): """ List all backups as WorkspaceBackup objects, sorted descending by lastmod. """ backups = [] for d in glob(join(self.backup_directory, '*')): backups.append(WorkspaceBackup.from_path(d)) backups.sort(key=lambda b: b.lastmod, reverse=True) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:retrieve; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:operation; 6, default_parameter; 6, 7; 6, 8; 7, identifier:field; 8, None; 9, block; 9, 10; 9, 12; 9, 22; 9, 43; 10, expression_statement; 10, 11; 11, comment; 12, exp...
def retrieve(self, operation, field=None): """Retrieve a position in this collection. :param operation: Name of an operation :type operation: :class:`Operation` :param field: Name of field for sort order :type field: str :return: The position for this operation :...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:query; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:properties; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:criteria; 10, None; 11, default_parameter; 11, 12; ...
def query(self, properties=None, criteria=None, distinct_key=None, **kwargs): """ Convenience method for database access. All properties and criteria can be specified using simplified names defined in Aliases. You can use the supported_properties property to get the list ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:sort_rows; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:rows; 6, identifier:section; 7, block; 7, 8; 7, 10; 7, 11; 7, 12; 7, 39; 8, expression_statement; 8, 9; 9, comment; 10, comment; 11, comment; 12, if_statement; 12, 13...
def sort_rows(self, rows, section): """Sort the rows, as appropriate for the section. :param rows: List of tuples (all same length, same values in each position) :param section: Name of section, should match const in Differ class :return: None; rows are sorted in-place """ ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_free_crypto_domains; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:crypto_adapters; 7, None; 8, block; 8, 9; 8, 11; 8, 29; 8, 36; 8, 37; 8, 38; 8, 39; 8, 40; 8, 41; 8, 45; 8, 46; 8, 73; 8, 79...
def get_free_crypto_domains(self, crypto_adapters=None): """ Return a list of crypto domains that are free for usage on a list of crypto adapters in this CPC. A crypto domain is considered free for usage if it is not assigned to any defined partition of this CPC in access mode '...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:topological; 3, parameters; 3, 4; 4, identifier:nodes; 5, block; 5, 6; 5, 8; 5, 23; 5, 97; 5, 109; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 14; 10, pattern_list; 10, 11; 10, 12; 10, 13; ...
def topological(nodes): """Return nodes in a topological order.""" order, enter, state = deque(), set(nodes), {} def dfs(node): """Visit nodes in depth-first order.""" state[node] = GRAY for parent in nodes.get(node, ()): color = state.get(parent, None) if co...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_teachers_sorted; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 16; 5, 33; 5, 67; 5, 94; 5, 112; 5, 113; 5, 123; 5, 145; 5, 151; 5, 178; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignm...
def get_teachers_sorted(self): """Get teachers sorted by last name. This is used for the announcement request page. """ 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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 17; 2, function_name:sorted_bits; 3, parameters; 3, 4; 4, identifier:self; 5, type; 5, 6; 6, generic_type; 6, 7; 6, 8; 7, identifier:List; 8, type_parameter; 8, 9; 9, type; 9, 10; 10, generic_type; 10, 11; 10, 12; 11, identifier:Tuple; 12, type_parameter; 12...
def sorted_bits(self) -> List[Tuple[str, int]]: """Return list of bit items sorted by position.""" return sorted(self.bit.items(), key=lambda x: x[1])
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 17; 2, function_name:sorted_enums; 3, parameters; 3, 4; 4, identifier:self; 5, type; 5, 6; 6, generic_type; 6, 7; 6, 8; 7, identifier:List; 8, type_parameter; 8, 9; 9, type; 9, 10; 10, generic_type; 10, 11; 10, 12; 11, identifier:Tuple; 12, type_parameter; 1...
def sorted_enums(self) -> List[Tuple[str, int]]: """Return list of enum items sorted by value.""" return sorted(self.enum.items(), key=lambda x: x[1])
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:collate; 3, parameters; 3, 4; 3, 6; 4, list_splat_pattern; 4, 5; 5, identifier:iterables; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 11; 8, 24; 8, 34; 8, 41; 8, 54; 8, 58; 8, 62; 8, 101; 8, 116; 9, expression_st...
def collate(*iterables, **kwargs): """Return an iterable ordered collation of the already-sorted items from each of ``iterables``, compared by kwarg ``key``. If ``reverse=True`` is passed, iterables must return their results in descending order rather than ascending. """ key = kwargs.pop('key'...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:order_key_defs; 3, parameters; 3, 4; 4, identifier:key_def; 5, block; 5, 6; 5, 8; 5, 12; 5, 13; 5, 63; 5, 75; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:_int; 11, list:[...
def order_key_defs(key_def): """ Sort a set of key definitions. A key definition that defines more then one usage type are splitted into as many definitions as the number of usage types specified. One key definition per usage type. :param key_def: A set of key definitions :return: The set of de...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:wait; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:condition_or_value; 6, default_parameter; 6, 7; 6, 8; 7, identifier:timeout; 8, None; 9, block; 9, 10; 9, 12; 9, 34; 9, 52; 9, 64; 9, 70; 9, 83; 9, 152; 9, 162; 9, 163; 9,...
def wait(self, condition_or_value, timeout=None): """Wait for the sensor to satisfy a condition. Parameters ---------- condition_or_value : obj or callable, or seq of objs or callables If obj, sensor.value is compared with obj. If callable, condition_or_value(rea...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_find_nearest_conn_objects; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:network; 5, identifier:node; 6, identifier:branches; 7, block; 7, 8; 7, 10; 7, 11; 7, 21; 7, 25; 7, 38; 7, 253; 7, 254; 7, 273; 8, expression_statement; 8, 9; 9, comment...
def _find_nearest_conn_objects(network, node, branches): """Searches all branches for the nearest possible connection object per branch It picks out 1 object out of 3 possible objects: 2 branch-adjacent stations and 1 potentially created branch tee on the line (using perpendicular projection). The resu...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:mv_voltage_deviation; 3, parameters; 3, 4; 3, 5; 4, identifier:network; 5, default_parameter; 5, 6; 5, 7; 6, identifier:voltage_levels; 7, string:'mv_lv'; 8, block; 8, 9; 8, 11; 8, 15; 8, 19; 8, 25; 8, 31; 8, 41; 8, 51; 8, 149; 8, 150; 8, 176; ...
def mv_voltage_deviation(network, voltage_levels='mv_lv'): """ Checks for voltage stability issues in MV grid. Parameters ---------- network : :class:`~.grid.network.Network` voltage_levels : :obj:`str` Specifies which allowed voltage deviations to use. Possible options are: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:calc_geo_lines_in_buffer; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:network; 5, identifier:node; 6, identifier:grid; 7, identifier:radius; 8, identifier:radius_inc; 9, block; 9, 10; 9, 12; 9, 16; 9, 101; 10, expression_statemen...
def calc_geo_lines_in_buffer(network, node, grid, radius, radius_inc): """Determines lines in nodes' associated graph that are at least partly within buffer of radius from node. If there are no lines, the buffer is successively extended by radius_inc until lines are found. Parameters ---------- ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_group_by_size_greedy; 3, parameters; 3, 4; 3, 5; 4, identifier:obj_list; 5, identifier:tot_groups; 6, block; 6, 7; 6, 9; 6, 27; 6, 38; 6, 65; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10...
def _group_by_size_greedy(obj_list, tot_groups): """Partition a list of objects in even buckets The idea is to choose the bucket for an object in a round-robin fashion. The list of objects is sorted to also try to keep the total size in bytes as balanced as possible. :param obj_list: a list of dict...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:dimensions_from_subgroups; 3, parameters; 3, 4; 4, identifier:s; 5, block; 5, 6; 5, 8; 5, 12; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:letters; 11, string:'XYABCDEFGHI...
def dimensions_from_subgroups(s): """ Given a sorted list of subgroups, return a string appropriate to provide as a composite track's `dimensions` arg. Parameters ---------- s : list of SubGroup objects (or anything with a `name` attribute) """ letters = 'XYABCDEFGHIJKLMNOPQRSTUVWZ' ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:filter_composite_from_subgroups; 3, parameters; 3, 4; 4, identifier:s; 5, block; 5, 6; 5, 8; 5, 12; 5, 38; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:dims; 11, list:[]; ...
def filter_composite_from_subgroups(s): """ Given a sorted list of subgroups, return a string appropriate to provide as the a composite track's `filterComposite` argument >>> import trackhub >>> trackhub.helpers.filter_composite_from_subgroups(['cell', 'ab', 'lab', 'knockdown']) 'dimA dimB' ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:_get_videos_for_filter; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 13; 4, identifier:video_filter; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort_field; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sort_dir; 10, attribute; 10, 11; ...
def _get_videos_for_filter(video_filter, sort_field=None, sort_dir=SortDirection.asc, pagination_conf=None): """ Returns a generator expression that contains the videos found, sorted by the given field and direction, with ties broken by edx_video_id to ensure a total order. """ videos = Video.ob...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:get_videos_for_course; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 13; 4, identifier:course_id; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort_field; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sort_dir; 10, attribute; 10, 11; 10, ...
def get_videos_for_course(course_id, sort_field=None, sort_dir=SortDirection.asc, pagination_conf=None): """ Returns an iterator of videos for the given course id. Args: course_id (String) sort_field (VideoSortField) sort_dir (SortDirection) Returns: A generator express...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:get_videos_for_ids; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:edx_video_ids; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort_field; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sort_dir; 10, attribute; 10, 11; 10, 12; 11...
def get_videos_for_ids( edx_video_ids, sort_field=None, sort_dir=SortDirection.asc ): """ Returns an iterator of videos that match the given list of ids. Args: edx_video_ids (list) sort_field (VideoSortField) sort_dir (SortDirection) Returns: A g...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:put; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:block_id; 6, identifier:priority; 7, default_parameter; 7, 8; 7, 9; 8, identifier:pb_type; 9, string:'offline'; 10, block; 10, 11; 10, 13; 10, 25; 11, expression_sta...
def put(self, block_id, priority, pb_type='offline'): """Add a Processing Block to the queue. When a new entry it added, the queue is (re-)sorted by priority followed by insertion order (older blocks with equal priority are first). Args: block_id (str): Processing B...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_device; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 16; 5, 17; 5, 18; 5, 22; 5, 26; 5, 114; 5, 121; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, call; 9, 10; 9, 15; 10, attribute; 10, 1...
def sort_device(self): """ Sort device to follow the order of initialization :return: None """ self.devices.sort() # idx: the indices of order-sensitive models # names: an ordered list of order-sensitive models idx = [] names = [] for dev...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:export_csv; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:self; 5, identifier:path; 6, default_parameter; 6, 7; 6, 8; 7, identifier:idx; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:header; 11, None; ...
def export_csv(self, path, idx=None, header=None, formatted=False, sort_idx=True, fmt='%.18e'): """ Export to a csv file Parameters ---------- path : str path of the csv file to save idx : None or array-like, optional the indice...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_event_times; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 12; 5, 25; 5, 50; 5, 66; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:times; 11, list:[]...
def get_event_times(self): """ Return event times of Fault, Breaker and other timed events Returns ------- list A sorted list of event times """ times = [] times.extend(self.Breaker.get_times()) for model in self.__dict__['Event'].al...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_sort_field; 3, parameters; 3, 4; 4, identifier:request; 5, block; 5, 6; 5, 8; 5, 19; 5, 36; 5, 45; 5, 59; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:sort_direction; ...
def get_sort_field(request): """ Retrieve field used for sorting a queryset :param request: HTTP request :return: the sorted field name, prefixed with "-" if ordering is descending """ sort_direction = request.GET.get("dir") field_name = (request.GET.get("sort") or "") if sort_direction els...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:linkage_group_ordering; 3, parameters; 3, 4; 4, identifier:linkage_records; 5, block; 5, 6; 5, 8; 5, 14; 5, 79; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:new_records; 1...
def linkage_group_ordering(linkage_records): """Convert degenerate linkage records into ordered info_frags-like records for comparison purposes. Simple example: >>> linkage_records = [ ... ['linkage_group_1', 31842, 94039, 'sctg_207'], ... ['linkage_group_1', 95303, 95303, 'sctg_20...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 43; 2, function_name:get_issues; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 3, 25; 3, 28; 3, 31; 3, 34; 3, 37; 3, 40; 4, default_parameter; 4, 5; 4, 6; 5, identifier:repo_name; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:profile; 9,...
def get_issues(repo_name=None, profile='github', milestone=None, state='open', assignee=None, creator=None, mentioned=None, labels=None, sort='created', direction='desc', ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 25; 2, function_name:get_milestones; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 4, default_parameter; 4, 5; 4, 6; 5, identifier:repo_name; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:profile; 9, string:'github'; 10, default_paramete...
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. ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 31; 2, function_name:get_prs; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 3, 25; 3, 28; 4, default_parameter; 4, 5; 4, 6; 5, identifier:repo_name; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:profile; 9, string:'github'; 10, default_p...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_diff_lists; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:old; 5, identifier:new; 6, identifier:comparator; 7, block; 7, 8; 7, 10; 7, 48; 7, 64; 7, 65; 7, 74; 7, 152; 7, 158; 8, expression_statement; 8, 9; 9, string:''' Compare lists to e...
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 ord...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_job_sorting_key; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:job; 6, block; 6, 7; 6, 9; 6, 19; 6, 23; 6, 34; 7, expression_statement; 7, 8; 8, comment; 9, if_statement; 9, 10; 9, 15; 9, 16; 10, comparison_operator:is; 10, 11; ...
def _job_sorting_key(self, job): """ Get the sorting key of a CFGJob instance. :param CFGJob job: the CFGJob object. :return: An integer that determines the order of this job in the queue. :rtype: int """ if self._base_graph is None: # we don't do so...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:instruction_addresses; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 12; 5, 41; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:addrs; 11, list:[ ]; 12, f...
def instruction_addresses(self): """ Get all instruction addresses in the binary. :return: A list of sorted instruction addresses. :rtype: list """ addrs = [ ] for b in sorted(self.blocks, key=lambda x: x.addr): # type: BasicBlock addrs.extend(b.ins...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:desymbolize; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 14; 5, 31; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self;...
def desymbolize(self): """ We believe this was a pointer and symbolized it before. Now we want to desymbolize it. The following actions are performed: - Reload content from memory - Mark the sort as 'unknown' :return: None """ self.sort = 'unknown' ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 1, 15; 2, function_name:append_data; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 4, identifier:self; 5, identifier:name; 6, identifier:initial_content; 7, identifier:size; 8, default_parameter; 8, 9; 8, 10; 9, identifier:readonly; 10, False; 11, defaul...
def append_data(self, name, initial_content, size, readonly=False, sort="unknown"): # pylint:disable=unused-argument """ Append a new data entry into the binary with specific name, content, and size. :param str name: Name of the data entry. Will be used as the label. :param bytes initi...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:pop_job; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:returning; 7, True; 8, block; 8, 9; 8, 11; 8, 17; 8, 40; 8, 41; 8, 69; 9, expression_statement; 9, 10; 10, comment; 11, if_statement; 11, 12...
def pop_job(self, returning=True): """ Pop a job from the pending jobs list. When returning == True, we prioritize the jobs whose functions are known to be returning (function.returning is True). As an optimization, we are sorting the pending jobs list according to job.function.returnin...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_get_min_addr; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 34; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 13; 9, not_operator; 9, 10; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, identi...
def _get_min_addr(self): """ Get the minimum address out of all regions. We assume self._regions is sorted. :return: The minimum address. :rtype: int """ if not self._regions: if self.project.arch.name != "Soot": l.error("self._regions is em...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_job_sorting_key; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:job; 6, block; 6, 7; 6, 9; 6, 13; 6, 39; 6, 70; 6, 110; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11...
def _job_sorting_key(self, job): """ Get the sorting key of a VFGJob instance. :param VFGJob job: the VFGJob object. :return: An integer that determines the order of this job in the queue. :rtype: int """ MAX_BLOCKS_PER_FUNCTION = 1000000 task_functions...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_merge_points; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:function_address; 6, block; 6, 7; 6, 9; 6, 10; 6, 11; 6, 29; 6, 59; 7, expression_statement; 7, 8; 8, comment; 9, comment; 10, comment; 11, try_statement; 11, 12; 11, 2...
def _merge_points(self, function_address): """ Return the ordered merge points for a specific function. :param int function_address: Address of the querying function. :return: A list of sorted merge points (addresses). :rtype: list """ # we are entering a new fu...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_widening_points; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:function_address; 6, block; 6, 7; 6, 9; 6, 10; 6, 11; 6, 29; 6, 71; 7, expression_statement; 7, 8; 8, comment; 9, comment; 10, comment; 11, try_statement; 11, 12; 11...
def _widening_points(self, function_address): """ Return the ordered widening points for a specific function. :param int function_address: Address of the querying function. :return: A list of sorted merge points (addresses). :rtype: list """ # we are entering a ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:get_variables; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:collapse_same_ident; 10, False; 11, block; 11, 12; 11, 14; 11, ...
def get_variables(self, sort=None, collapse_same_ident=False): """ Get a list of variables. :param str or None sort: Sort of the variable to get. :param collapse_same_ident: Whether variables of the same identifier should be collapsed or not. :return: A lis...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 1, 8; 2, function_name:find_merge_points; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:function_addr; 5, identifier:function_endpoints; 6, identifier:graph; 7, comment; 8, block; 8, 9; 8, 11; 8, 17; 8, 42; 8, 52; 8, 62; 9, expression_statement; 9, 10; 10, com...
def find_merge_points(function_addr, function_endpoints, graph): # pylint:disable=unused-argument """ Given a local transition graph of a function, find all merge points inside, and then perform a quasi-topological sort of those merge points. A merge point might be one of the following...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:reverse_post_order_sort_nodes; 3, parameters; 3, 4; 3, 5; 4, identifier:graph; 5, default_parameter; 5, 6; 5, 7; 6, identifier:nodes; 7, None; 8, block; 8, 9; 8, 11; 8, 20; 8, 33; 8, 37; 8, 54; 9, expression_statement; 9, 10; 10, comment; 11, e...
def reverse_post_order_sort_nodes(graph, nodes=None): """ Sort a given set of nodes in reverse post ordering. :param networkx.DiGraph graph: A local transition graph of a function. :param iterable nodes: A collection of nodes to sort. :return: A list of sorted nodes. :rt...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:split; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:stash_splitter; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:stash_ranker; 10, None; 11, defau...
def split(self, stash_splitter=None, stash_ranker=None, state_ranker=None, limit=8, from_stash='active', to_stash='stashed'): """ Split a stash of states into two stashes depending on the specified options. The stash from_stash will be split into two stashes depending on the other...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:_executable_memory_regions; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:objects; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:force_segment; 10, False; 11, block; 11, 12; 11...
def _executable_memory_regions(self, objects=None, force_segment=False): """ Get all executable memory regions from the binaries :param objects: A collection of binary objects to collect regions from. If None, regions from all project binary objects are used. :pa...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_debug_check; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 9; 5, 13; 5, 17; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:old_end; 12, ...
def _debug_check(self): """ Iterates over list checking segments with same sort do not overlap :raise: Exception: if segments overlap space with same sort """ # old_start = 0 old_end = 0 old_sort = "" for segment in self._list: if segment.star...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:next_pos_with_sort_not_in; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:address; 6, identifier:sorts; 7, default_parameter; 7, 8; 7, 9; 8, identifier:max_distance; 9, None; 10, block; 10, 11; 10, 13; 10, 22; 10, 31;...
def next_pos_with_sort_not_in(self, address, sorts, max_distance=None): """ Returns the address of the next occupied block whose sort is not one of the specified ones. :param int address: The address to begin the search with (including itself). :param sorts: A collection of sort s...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:occupied_by_sort; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:address; 6, block; 6, 7; 6, 9; 6, 18; 6, 30; 6, 56; 6, 84; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12;...
def occupied_by_sort(self, address): """ Check if an address belongs to any segment, and if yes, returns the sort of the segment :param int address: The address to check :return: Sort of the segment that occupies this address :rtype: str """ idx = self._search(a...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:_binary_insert; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:lst; 5, identifier:elem; 6, identifier:key; 7, default_parameter; 7, 8; 7, 9; 8, identifier:lo; 9, integer:0; 10, default_parameter; 10, 11; 10, 12; 11, identifier:hi;...
def _binary_insert(lst, elem, key, lo=0, hi=None): """ Insert an element into a sorted list, and keep the list sorted. The major difference from bisect.bisect_left is that this function supports a key method, so user doesn't have to create the key array for each insertion. :par...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:_sort_io_counters; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:process; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sortedby; 7, string:'io_counters'; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sortedby_secondary; 10, string:'memo...
def _sort_io_counters(process, sortedby='io_counters', sortedby_secondary='memory_percent'): """Specific case for io_counters Sum of io_r + io_w""" return process[sortedby][0] - process[sortedby][2] + process[sortedby][1] - process[sortedby][3]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:_sort_lambda; 3, parameters; 3, 4; 3, 7; 4, default_parameter; 4, 5; 4, 6; 5, identifier:sortedby; 6, string:'cpu_percent'; 7, default_parameter; 7, 8; 7, 9; 8, identifier:sortedby_secondary; 9, string:'memory_percent'; 10, block; 10, 11; 10, ...
def _sort_lambda(sortedby='cpu_percent', sortedby_secondary='memory_percent'): """Return a sort lambda function for the sortedbykey""" ret = None if sortedby == 'io_counters': ret = _sort_io_counters elif sortedby == 'cpu_times': ret = _sort_cpu_times return ret
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:loop_position; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 28; 6, expression_statement; 6, 7; 7, comment; 8, for_statement; 8, 9; 8, 12; 8, 18; 9, pattern_list; 9, 10; 9, 11; 10, identifier:i; 11, identifier:v; 12, call; 1...
def loop_position(self): """Return the current sort in the loop""" for i, v in enumerate(self._sort_loop): if v == glances_processes.sort_key: return i return 0
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_event_sort_key; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:event_type; 6, block; 6, 7; 6, 9; 6, 10; 6, 43; 7, expression_statement; 7, 8; 8, comment; 9, comment; 10, if_statement; 10, 11; 10, 17; 10, 18; 10, 23; 10, 36; 11...
def get_event_sort_key(self, event_type): """Return the process sort key""" # Process sort depending on alert type if event_type.startswith("MEM"): # Sort TOP process by memory_percent ret = 'memory_percent' elif event_type.startswith("CPU_IOWAIT"): # ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:set_process_sort; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:event_type; 6, block; 6, 7; 6, 9; 7, expression_statement; 7, 8; 8, comment; 9, if_statement; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:glances_pro...
def set_process_sort(self, event_type): """Define the process auto sort key from the alert type.""" if glances_processes.auto_sort: glances_processes.sort_key = self.get_event_sort_key(event_type)