sequence stringlengths 546 16.2k | code stringlengths 108 19.3k |
|---|---|
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_find_cert_in_list; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:cert; 5, identifier:issuer; 6, identifier:certificate_list; 7, identifier:crl_issuer; 8, block; 8, 9; 8, 11; 8, 19; 8, 25; 8, 31; 8, 42; 8, 48; 8, 126; 9, expression_state... | def _find_cert_in_list(cert, issuer, certificate_list, crl_issuer):
"""
Looks for a cert in the list of revoked certificates
:param cert:
An asn1crypto.x509.Certificate object of the cert being checked
:param issuer:
An asn1crypto.x509.Certificate object of the cert issuer
:param ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:derive_coordinates; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 15; 5, 72; 5, 76; 5, 80; 5, 84; 5, 85; 5, 113; 5, 295; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 12; 8, 13; 9, attribute; 9, 10; 9,... | def derive_coordinates(self):
"""
Depending on the compilation source, some members of the SourceRef
object may be incomplete.
Calling this function performs the necessary derivations to complete the
object.
"""
if self._coordinates_resolved:
# Coordi... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:children; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:unroll; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:skip_not_present; 10, True; 11, block; 11, 12; 11, 14; 12, expres... | def children(self, unroll=False, skip_not_present=True):
"""
Returns an iterator that provides nodes for all immediate children of
this component.
Parameters
----------
unroll : bool
If True, any children that are arrays are unrolled.
skip_not_presen... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:find_by_path; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:path; 6, block; 6, 7; 6, 9; 6, 18; 6, 22; 6, 177; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifi... | def find_by_path(self, path):
"""
Finds the descendant node that is located at the relative path
Returns ``None`` if not found
Raises exception if path is malformed, or array index is out of range
Parameters
----------
path: str
Path to target relativ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_property; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:prop_name; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 11; 8, 15; 8, 19; 8, 37; 8, 38; 8, 57; 8, 58; 8, 117; 8, 123; 8, 124; 8, 137... | def get_property(self, prop_name, **kwargs):
"""
Gets the SystemRDL component property
If a property was not explicitly set in the RDL source, its default
value is derived. In some cases, a default value is implied according to
other property values.
Properties values t... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:elaborate; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:top_def_name; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:inst_name; 10, None; 11, default_parameter; 11, 12; ... | def elaborate(self, top_def_name=None, inst_name=None, parameters=None):
"""
Elaborates the design for the given top-level addrmap component.
During elaboration, the following occurs:
- An instance of the ``$root`` meta-component is created.
- The addrmap component specified by... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:resolve_addresses; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:node; 6, block; 6, 7; 6, 9; 6, 10; 6, 11; 6, 20; 6, 30; 6, 34; 6, 277; 6, 278; 6, 279; 6, 303; 7, expression_statement; 7, 8; 8, comment; 9, comment; 10, comment; 1... | def resolve_addresses(self, node):
"""
Resolve addresses of children of Addrmap and Regfile components
"""
# Get alignment based on 'alignment' property
# This remains constant for all children
prop_alignment = self.alignment_stack[-1]
if prop_alignment is None:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:parse_include; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:start; 6, block; 6, 7; 6, 9; 6, 10; 6, 14; 6, 35; 6, 39; 6, 40; 6, 92; 6, 93; 6, 102; 6, 114; 6, 144; 6, 160; 6, 171; 6, 180; 6, 181; 6, 182; 6, 191; 6, 260; 6, 261; 6,... | def parse_include(self, start):
"""
Extract include from text based on start position of token
Returns
-------
(end, incl_path)
- end: last char in include
- incl_path: Resolved path to include
"""
# Seek back to start of line
i = ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:get_paths; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:patterns; 5, default_parameter; 5, 6; 5, 7; 6, identifier:start_dirs; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:max_depth; 10, integer:1; 11, block; 11, 12; 11, 14; 11, ... | def get_paths(patterns, start_dirs=None, max_depth=1):
"""Retrieve files that match any of the patterns."""
# Shortcut: if there is only one pattern, make sure we process just that.
if len(patterns) == 1 and not start_dirs:
pattern = patterns[0]
directory = os.path.dirname(pattern)
i... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 34; 2, function_name:edit_files; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 28; 3, 31; 4, identifier:patterns; 5, default_parameter; 5, 6; 5, 7; 6, identifier:expressions; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:functi... | def edit_files(patterns, expressions=None,
functions=None, executables=None,
start_dirs=None, max_depth=1, dry_run=True,
output=sys.stdout, encoding=None, newline=None):
"""Process patterns with MassEdit.
Arguments:
patterns: file pattern to identify the files... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:detect_events; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:dat; 5, identifier:method; 6, default_parameter; 6, 7; 6, 8; 7, identifier:value; 8, None; 9, block; 9, 10; 9, 12; 9, 204; 9, 247; 10, expression_statement; 10, 11; 11, comment; 12, ... | def detect_events(dat, method, value=None):
"""Detect events using 'above_thresh', 'below_thresh' or
'maxima' method.
Parameters
----------
dat : ndarray (dtype='float')
vector with the data after transformation
method : str
'above_thresh', 'below_thresh' or 'maxima'
value :... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:merge_close; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:events; 5, identifier:min_interval; 6, default_parameter; 6, 7; 6, 8; 7, identifier:merge_to_longer; 8, False; 9, block; 9, 10; 9, 12; 9, 18; 9, 22; 9, 144; 10, expression_statement; 1... | def merge_close(events, min_interval, merge_to_longer=False):
"""Merge events that are separated by a less than a minimum interval.
Parameters
----------
events : list of dict
events with 'start' and 'end' times, from one or several channels.
**Events must be sorted by their start time.... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_remove_duplicate; 3, parameters; 3, 4; 3, 5; 4, identifier:old_events; 5, identifier:dat; 6, block; 6, 7; 6, 9; 6, 19; 6, 44; 6, 48; 6, 49; 6, 62; 6, 78; 6, 101; 6, 105; 6, 109; 6, 188; 7, expression_statement; 7, 8; 8, comment; 9, expression_... | def _remove_duplicate(old_events, dat):
"""Remove duplicates from the events.
Parameters
----------
old_events : ndarray (dtype='int')
N x 3 matrix with start, peak, end samples
dat : ndarray (dtype='float')
vector with the data after detection-transformation (to compute peak)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:math; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:data; 5, default_parameter; 5, 6; 5, 7; 6, identifier:operator; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:operator_name; 10, None; 11, default_parameter; 11, 12; 11, 1... | def math(data, operator=None, operator_name=None, axis=None):
"""Apply mathematical operation to each trial and channel individually.
Parameters
----------
data : instance of DataTime, DataFreq, or DataTimeFreq
operator : function or tuple of functions, optional
function(s) to run on the d... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:detect_Massimini2004; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:dat_orig; 5, identifier:s_freq; 6, identifier:time; 7, identifier:opts; 8, block; 8, 9; 8, 11; 8, 21; 8, 33; 8, 44; 8, 48; 8, 135; 8, 150; 9, expression_statement; 9, 10... | def detect_Massimini2004(dat_orig, s_freq, time, opts):
"""Slow wave detection based on Massimini et al., 2004.
Parameters
----------
dat_orig : ndarray (dtype='float')
vector with the data for one channel
s_freq : float
sampling frequency
time : ndarray (dtype='float')
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 29; 2, function_name:filter_; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 4, identifier:data; 5, default_parameter; 5, 6; 5, 7; 6, identifier:axis; 7, string:'time'; 8, default_parameter; 8, 9; 8, 10; 9, identifier:low_cut; 10, None;... | def filter_(data, axis='time', low_cut=None, high_cut=None, order=4,
ftype='butter', Rs=None, notchfreq=50, notchquality=25):
"""Design filter and apply it.
Parameters
----------
ftype : str
'butter', 'cheby1', 'cheby2', 'ellip', 'bessel', 'diff', or 'notch'
axis : str, optional... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:select; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:data; 5, default_parameter; 5, 6; 5, 7; 6, identifier:trial; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:invert; 10, False; 11, dictionary_splat_pattern; 11, 12; 12, i... | def select(data, trial=None, invert=False, **axes_to_select):
"""Define the selection of trials, using ranges or actual values.
Parameters
----------
data : instance of Data
data to select from.
trial : list of int or ndarray (dtype='i'), optional
index of trials of interest
**a... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 49; 2, function_name:fetch; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 13; 3, 16; 3, 19; 3, 22; 3, 25; 3, 28; 3, 31; 3, 34; 3, 37; 3, 40; 3, 43; 3, 46; 4, identifier:dataset; 5, identifier:annot; 6, default_parameter; 6, 7; 6, 8; 7, identifier:cat; 8, tuple; 8, 9; 8, 10;... | def fetch(dataset, annot, cat=(0, 0, 0, 0), evt_type=None, stage=None,
cycle=None, chan_full=None, epoch=None, epoch_dur=30,
epoch_overlap=0, epoch_step=None, reject_epoch=False,
reject_artf=False, min_dur=0, buffer=0):
"""Create instance of Segments for analysis, complete with info ab... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:get_times; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:annot; 5, default_parameter; 5, 6; 5, 7; 6, identifier:evt_type; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:stage; 10, None; 11, default_param... | def get_times(annot, evt_type=None, stage=None, cycle=None, chan=None,
exclude=False, buffer=0):
"""Get start and end times for selected segments of data, bundled
together with info.
Parameters
----------
annot: instance of Annotations
The annotation file containing events and... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:_concat; 3, parameters; 3, 4; 3, 5; 4, identifier:bundles; 5, default_parameter; 5, 6; 5, 7; 6, identifier:cat; 7, tuple; 7, 8; 7, 9; 7, 10; 7, 11; 8, integer:0; 9, integer:0; 10, integer:0; 11, integer:0; 12, block; 12, 13; 12, 15; 12, 31; 12... | def _concat(bundles, cat=(0, 0, 0, 0)):
"""Prepare event or epoch start and end times for concatenation."""
chan = sorted(set([x['chan'] for x in bundles]))
cycle = sorted(set([x['cycle'] for x in bundles]))
stage = sorted(set([x['stage'] for x in bundles]))
evt_type = sorted(set([x['name'] for x in... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:toggle_pac; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 95; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 12; 9, comparison_operator:is; 9, 10; 9, 11; 10, identifier:Pac; 11, None; 12, block; 12, 13;... | def toggle_pac(self):
"""Enable and disable PAC options."""
if Pac is not None:
pac_on = self.pac['pac_on'].get_value()
self.pac['prep'].setEnabled(pac_on)
self.pac['box_metric'].setEnabled(pac_on)
self.pac['box_complex'].setEnabled(pac_on)
sel... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_segments; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 9; 5, 31; 5, 41; 5, 53; 5, 65; 5, 69; 5, 73; 5, 123; 5, 124; 5, 134; 5, 135; 5, 142; 5, 143; 5, 147; 5, 151; 5, 218; 5, 219; 5, 231; 5, 232; 5, 242; 5, 278; 5, 279;... | def get_segments(self):
"""Get segments for analysis. Creates instance of trans.Segments."""
# Chunking
chunk = {k: v.isChecked() for k, v in self.chunk.items()}
lock_to_staging = self.lock_to_staging.get_value()
epoch_dur = self.epoch_param['dur'].get_value()
epoch_overl... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:compute_evt_params; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 14; 5, 36; 5, 60; 5, 84; 5, 106; 5, 116; 5, 126; 5, 134; 5, 140; 5, 155; 5, 177; 5, 181; 5, 185; 5, 199; 5, 273; 6, expression_statement; 6, 7; 7, comment; 8,... | def compute_evt_params(self):
"""Compute event parameters."""
ev = self.event
glob = {k: v.get_value() for k, v in ev['global'].items()}
params = {k: v[0].get_value() for k, v in ev['local'].items()}
prep = {k: v[1].get_value() for k, v in ev['local'].items()}
slopes = {k... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:detect_format; 3, parameters; 3, 4; 4, identifier:filename; 5, block; 5, 6; 5, 8; 5, 15; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:filename; 11, call; 11, 12; 11, 13; 1... | def detect_format(filename):
"""Detect file format.
Parameters
----------
filename : str or Path
name of the filename or directory.
Returns
-------
class used to read the data.
"""
filename = Path(filename)
if filename.is_dir():
if list(filename.glob('*.stc')) ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:read_videos; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:begtime; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:endtime; 10, None; 11, block; 11, 12; 11, 14; 11, 31; 11, 46; ... | def read_videos(self, begtime=None, endtime=None):
"""Return list of videos with start and end times for a period.
Parameters
----------
begtime : int or datedelta or datetime or list
start of the data to read;
if it's int, it's assumed it's s;
if it'... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:read_data; 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:chan; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:begtime; 10, None; 11, default_paramete... | def read_data(self, chan=None, begtime=None, endtime=None, begsam=None,
endsam=None, s_freq=None):
"""Read the data and creates a ChanTime instance
Parameters
----------
chan : list of strings
names of the channels to read
begtime : int or datedelta... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:export_freq_band; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:xfreq; 5, identifier:bands; 6, identifier:filename; 7, block; 7, 8; 7, 10; 7, 23; 7, 36; 7, 56; 7, 64; 7, 106; 7, 147; 7, 154; 8, expression_statement; 8, 9; 9, comment; 10, expre... | def export_freq_band(xfreq, bands, filename):
"""Write frequency analysis data to CSV by pre-defined band."""
heading_row_1 = ['Segment index',
'Start time',
'End time',
'Duration',
'Stitches',
'Stage',
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_cycles; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 19; 5, 25; 5, 46; 5, 67; 5, 71; 5, 80; 5, 98; 5, 184; 5, 188; 5, 217; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; ... | def get_cycles(self):
"""Return the cycle start and end times.
Returns
-------
list of tuple of float
start and end times for each cycle, in seconds from recording start
and the cycle index starting at 1
"""
cycles = self.rater.find('cycles')
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_read_erd; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:erd_file; 5, identifier:begsam; 6, identifier:endsam; 7, block; 7, 8; 7, 10; 7, 17; 7, 23; 7, 29; 7, 30; 7, 37; 7, 47; 7, 65; 7, 78; 7, 84; 7, 93; 7, 100; 7, 101; 7, 113; 7, 119; 7, 131;... | def _read_erd(erd_file, begsam, endsam):
"""Read the raw data and return a matrix, converted to microvolts.
Parameters
----------
erd_file : str
one of the .erd files to read
begsam : int
index of the first sample to read
endsam : int
index of the last sample (excluded, ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:return_markers; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 19; 5, 38; 5, 321; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:ent_file; 11, call; 11, 1... | def return_markers(self):
"""Reads the notes of the Ktlx recordings.
"""
ent_file = self._filename.with_suffix('.ent')
if not ent_file.exists():
ent_file = self._filename.with_suffix('.ent.old')
try:
ent_notes = _read_ent(ent_file)
except (FileNo... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:band_power; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:data; 5, identifier:freq; 6, default_parameter; 6, 7; 6, 8; 7, identifier:scaling; 8, string:'power'; 9, default_parameter; 9, 10; 9, 11; 10, identifier:n_fft; 11, ... | def band_power(data, freq, scaling='power', n_fft=None, detrend=None,
array_out=False):
"""Compute power or energy acoss a frequency band, and its peak frequency.
Power is estimated using the mid-point rectangle rule. Input can be
ChanTime or ChanFreq.
Parameters
----------
data... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 24; 2, function_name:morlet; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 4, identifier:freq; 5, identifier:s_freq; 6, default_parameter; 6, 7; 6, 8; 7, identifier:ratio; 8, integer:5; 9, default_parameter; 9, 10; 9, 11; 10, identifier:sigma_... | def morlet(freq, s_freq, ratio=5, sigma_f=None, dur_in_sd=4, dur_in_s=None,
normalization='peak', zero_mean=False):
"""Create a Morlet wavelet.
Parameters
----------
freq : float
central frequency of the wavelet
s_freq : int
sampling frequency
ratio : float
ra... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_convert_timestr_to_seconds; 3, parameters; 3, 4; 3, 5; 4, identifier:time_str; 5, identifier:rec_start; 6, block; 6, 7; 6, 9; 6, 23; 6, 124; 7, expression_statement; 7, 8; 8, comment; 9, if_statement; 9, 10; 9, 17; 10, not_operator; 10, 11; 11... | def _convert_timestr_to_seconds(time_str, rec_start):
"""Convert input from user about time string to an absolute time for
the recordings.
Parameters
----------
time_str : str
time information as '123' or '22:30' or '22:30:22'
rec_start: instance of datetime
absolute start time ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:mouseReleaseEvent; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:event; 6, block; 6, 7; 6, 9; 6, 16; 6, 22; 6, 34; 6, 41; 6, 57; 6, 73; 6, 84; 6, 370; 6, 371; 6, 377; 6, 385; 7, expression_statement; 7, 8; 8, comment; 9, if_state... | def mouseReleaseEvent(self, event):
"""Create a new event or marker, or show the previous power spectrum
"""
if not self.scene:
return
if self.event_sel:
return
if self.deselect:
self.deselect = False
return
if not self.r... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:next_event; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:delete; 7, False; 8, block; 8, 9; 8, 11; 8, 67; 8, 73; 8, 79; 8, 87; 8, 131; 8, 143; 8, 162; 8, 218; 8, 232; 8, 294; 8, 300; 8, 309; 9, e... | def next_event(self, delete=False):
"""Go to next event."""
if delete:
msg = "Delete this event? This cannot be undone."
msgbox = QMessageBox(QMessageBox.Question, 'Delete event', msg)
msgbox.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
msgbox.setD... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:montage; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:data; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ref_chan; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ref_to_avg; 10, False; 11, default_parameter; 11, 1... | def montage(data, ref_chan=None, ref_to_avg=False, bipolar=None,
method='average'):
"""Apply linear transformation to the channels.
Parameters
----------
data : instance of DataRaw
the data to filter
ref_chan : list of str
list of channels used as reference
ref_to_av... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:remove_artf_evts; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:times; 5, identifier:annot; 6, default_parameter; 6, 7; 6, 8; 7, identifier:chan; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:min_dur; 11, float:0.1; 12, bl... | def remove_artf_evts(times, annot, chan=None, min_dur=0.1):
"""Correct times to remove events marked 'Artefact'.
Parameters
----------
times : list of tuple of float
the start and end times of each segment
annot : instance of Annotations
the annotation file containing events and epo... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_build_app_dict; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:site; 5, identifier:request; 6, default_parameter; 6, 7; 6, 8; 7, identifier:label; 8, None; 9, block; 9, 10; 9, 12; 9, 16; 9, 53; 9, 261; 9, 271; 10, expression_statement; 10, 11;... | def _build_app_dict(site, request, label=None):
"""
Builds the app dictionary. Takes an optional label parameters to filter
models of a specific app.
"""
app_dict = {}
if label:
models = {
m: m_a for m, m_a in site._registry.items()
if m._meta.app_label == label
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_app_list; 3, parameters; 3, 4; 3, 5; 4, identifier:site; 5, identifier:request; 6, block; 6, 7; 6, 9; 6, 17; 6, 18; 6, 41; 6, 42; 6, 62; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, ... | def get_app_list(site, request):
"""
Returns a sorted list of all the installed apps that have been
registered in this site.
"""
app_dict = _build_app_dict(site, request)
# Sort the apps alphabetically.
app_list = sorted(app_dict.values(), key=lambda x: x['name'].lower())
# Sort the mo... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:format_query_results; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:r; 6, identifier:prop_nr; 7, block; 7, 8; 7, 10; 7, 19; 8, expression_statement; 8, 9; 9, comment; 10, expression_statement; 10, 11; 11, assignment; 11, 12... | def format_query_results(self, r, prop_nr):
"""
`r` is the results of the sparql query in _query_data and is modified in place
`prop_nr` is needed to get the property datatype to determine how to format the value
`r` is a list of dicts. The keys are:
item: the subject. the i... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:times; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:p; 5, identifier:mint; 6, default_parameter; 6, 7; 6, 8; 7, identifier:maxt; 8, None; 9, block; 9, 10; 9, 12; 9, 19; 9, 164; 10, expression_statement; 10, 11; 11, string:'''Repeat a parser b... | def times(p, mint, maxt=None):
'''Repeat a parser between `mint` and `maxt` times. DO AS MUCH MATCH AS IT CAN.
Return a list of values.'''
maxt = maxt if maxt else mint
@Parser
def times_parser(text, index):
cnt, values, res = 0, Value.success(index, []), None
while cnt < maxt:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:separated; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:p; 5, identifier:sep; 6, identifier:mint; 7, default_parameter; 7, 8; 7, 9; 8, identifier:maxt; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifier:end; 12, None... | def separated(p, sep, mint, maxt=None, end=None):
'''Repeat a parser `p` separated by `s` between `mint` and `maxt` times.
When `end` is None, a trailing separator is optional.
When `end` is True, a trailing separator is required.
When `end` is False, a trailing separator is not allowed.
MATCHES AS ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:route; 3, parameters; 3, 4; 4, list_splat_pattern; 4, 5; 5, identifier:args; 6, block; 6, 7; 6, 9; 6, 57; 6, 196; 6, 201; 7, expression_statement; 7, 8; 8, comment; 9, function_definition; 9, 10; 9, 11; 9, 13; 10, function_name:_validate_route;... | def route(*args):
"""
This function is used to define an explicit route for a path segment.
You generally only want to use this in situations where your desired path
segment is not a valid Python variable/function name.
For example, if you wanted to be able to route to:
/path/with-dashes/
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:find_object; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:obj; 5, identifier:remainder; 6, identifier:notfound_handlers; 7, identifier:request; 8, block; 8, 9; 8, 11; 8, 15; 9, expression_statement; 9, 10; 10, string:'''
'Walks' the... | def find_object(obj, remainder, notfound_handlers, request):
'''
'Walks' the url path in search of an action for which a controller is
implemented and returns that controller object along with what's left
of the remainder.
'''
prev_obj = None
while True:
if obj is None:
r... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:make_app; 3, parameters; 3, 4; 3, 5; 4, identifier:root; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kw; 7, block; 7, 8; 7, 10; 7, 11; 7, 21; 7, 31; 7, 98; 7, 99; 7, 108; 7, 109; 7, 119; 7, 129; 7, 130; 7, 147; 7, 162; 7, 163; 7, 174; 7, 1... | def make_app(root, **kw):
'''
Utility for creating the Pecan application object. This function should
generally be called from the ``setup_app`` function in your project's
``app.py`` file.
:param root: A string representing a root controller object (e.g.,
"myapp.controller.root.Ro... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 22; 2, function_name:redirect; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 4, default_parameter; 4, 5; 4, 6; 5, identifier:location; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:internal; 9, False; 10, default_parameter; 10, 11; 10, 12; 11, ... | def redirect(location=None, internal=False, code=None, headers={},
add_slash=False, request=None):
'''
Perform a redirect, either internal or external. An internal redirect
performs the redirect server-side, while the external redirect utilizes
an HTTP 302 status code.
:param location:... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:get_args; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:self; 5, identifier:state; 6, identifier:all_params; 7, identifier:remainder; 8, identifier:argspec; 9, identifier:im_self; 10, block; 10, 11; 10, 13; 10, 17; 10, 21; 1... | def get_args(self, state, all_params, remainder, argspec, im_self):
'''
Determines the arguments for a controller based upon parameters
passed the argument specification for the controller.
'''
args = []
varargs = []
kwargs = dict()
valid_args = argspec.ar... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_route; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:args; 6, default_parameter; 6, 7; 6, 8; 7, identifier:request; 8, None; 9, block; 9, 10; 9, 12; 9, 22; 9, 23; 9, 41; 9, 42; 9, 60; 9, 61; 9, 71; 9, 76; 9, 77; 9, 90; 9, ... | def _route(self, args, request=None):
'''
Routes a request to the appropriate controller and returns its result.
Performs a bit of validation - refuses to route delete and put actions
via a GET request).
'''
if request is None:
from pecan import request
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:_handle_get; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:method; 6, identifier:remainder; 7, default_parameter; 7, 8; 7, 9; 8, identifier:request; 9, None; 10, block; 10, 11; 10, 13; 10, 27; 10, 28; 10, 83; 10, 90;... | def _handle_get(self, method, remainder, request=None):
'''
Routes ``GET`` actions to the appropriate controller.
'''
if request is None:
self._raise_method_deprecation_warning(self._handle_get)
# route to a get_all or get if no additional parts are available
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:_handle_delete; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:method; 6, identifier:remainder; 7, default_parameter; 7, 8; 7, 9; 8, identifier:request; 9, None; 10, block; 10, 11; 10, 13; 10, 27; 10, 77; 10, 78; 10, ... | def _handle_delete(self, method, remainder, request=None):
'''
Routes ``DELETE`` actions to the appropriate controller.
'''
if request is None:
self._raise_method_deprecation_warning(self._handle_delete)
if remainder:
match = self._handle_custom_action(me... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:gunicorn_run; 3, parameters; 4, block; 4, 5; 4, 7; 4, 55; 4, 233; 5, expression_statement; 5, 6; 6, comment; 7, try_statement; 7, 8; 7, 16; 8, block; 8, 9; 9, import_from_statement; 9, 10; 9, 14; 10, dotted_name; 10, 11; 10, 12; 10, 13; 11, ide... | def gunicorn_run():
"""
The ``gunicorn_pecan`` command for launching ``pecan`` applications
"""
try:
from gunicorn.app.wsgiapp import WSGIApplication
except ImportError as exc:
args = exc.args
arg0 = args[0] if args else ''
arg0 += ' (are you sure `gunicorn` is instal... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:expose; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 4, default_parameter; 4, 5; 4, 6; 5, identifier:template; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:generic; 9, False; 10, default_parameter; 10, 11; 10, 12; 11, identifier:route;... | def expose(template=None,
generic=False,
route=None,
**kw):
'''
Decorator used to flag controller methods as being "exposed" for
access via HTTP, and to configure that access.
:param template: The path to a template, relative to the base template
d... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:add_operations_bulk; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:payload; 6, block; 6, 7; 6, 9; 6, 10; 6, 22; 6, 32; 6, 36; 6, 40; 6, 44; 6, 137; 6, 147; 7, expression_statement; 7, 8; 8, comment; 9, comment; 10, expression_sta... | def add_operations_bulk(self, payload):
"""Add operations to a group of agents.
:param list payload: contains the informations necessary for the action.
It's in the form [{"id": agent_id, "operations": operations}]
With id that is an str containing only characters in "a-zA-Z0-9_-"
and must be betwe... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:parse; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:cls; 5, identifier:line; 6, default_parameter; 6, 7; 6, 8; 7, identifier:encoding; 8, attribute; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:pydle; 11, identifier:protocol; 12, ... | def parse(cls, line, encoding=pydle.protocol.DEFAULT_ENCODING):
"""
Parse given line into IRC message structure.
Returns a Message.
"""
valid = True
# Decode message.
try:
message = line.decode(encoding)
except UnicodeDecodeError:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:construct; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:force; 7, False; 8, block; 8, 9; 8, 11; 8, 12; 8, 21; 8, 58; 8, 66; 8, 67; 8, 77; 8, 149; 8, 150; 8, 167; 8, 168; 8, 210; 8, 211; 8, 217; ... | def construct(self, force=False):
""" Construct a raw IRC message. """
# Sanity check for command.
command = str(self.command)
if not protocol.COMMAND_PATTERN.match(command) and not force:
raise pydle.protocol.ProtocolViolation('The constructed command does not follow the com... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:split; 3, parameters; 3, 4; 4, identifier:url; 5, block; 5, 6; 5, 8; 5, 20; 5, 29; 5, 38; 5, 52; 5, 98; 5, 106; 5, 115; 5, 124; 5, 133; 5, 283; 5, 316; 5, 331; 5, 345; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9,... | def split(url):
"""Split URL into scheme, netloc, path, query and fragment.
>>> split('http://www.example.com/abc?x=1&y=2#foo')
SplitResult(scheme='http', netloc='www.example.com', path='/abc', query='x=1&y=2', fragment='foo')
"""
scheme = netloc = path = query = fragment = ''
ip6_start = url.f... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:issue_cmd; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:cmd; 6, identifier:value; 7, default_parameter; 7, 8; 7, 9; 8, identifier:retry; 9, integer:3; 10, block; 10, 11; 10, 13; 11, expression_statement; 11, 12; 12,... | async def issue_cmd(self, cmd, value, retry=3):
"""
Issue a command, then await and return the return value.
This method is a coroutine
"""
async with self._cmd_lock:
if not self.connected:
_LOGGER.debug(
"Serial transport closed, ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_reports; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 12; 5, 16; 5, 57; 5, 117; 5, 126; 5, 152; 5, 161; 5, 189; 5, 198; 5, 240; 5, 249; 5, 277; 5, 286; 5, 304; 5, 313; 5, 331; 5, 356; 5, 363; 6, expression_statement; 6,... | async def get_reports(self):
"""
Update the pyotgw object with the information from all of the
PR commands and return the updated status dict.
This method is a coroutine
"""
cmd = OTGW_CMD_REPORT
reports = {}
for value in OTGW_REPORTS.keys():
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:build; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:client; 6, default_parameter; 6, 7; 6, 8; 7, identifier:nobuild; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:usecache; 11, True; 12, defaul... | def build(self, client,
nobuild=False,
usecache=True,
pull=False):
"""
Drives the build of the final image - get the list of steps and execute them.
Args:
client (docker.Client): docker client object that will build the image
nob... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_check_yaml_and_paths; 3, parameters; 3, 4; 3, 5; 4, identifier:ymlfilepath; 5, identifier:yamldefs; 6, block; 6, 7; 6, 9; 6, 20; 6, 31; 6, 49; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 1... | def _check_yaml_and_paths(ymlfilepath, yamldefs):
""" Checks YAML for errors and resolves all paths
"""
relpath = os.path.relpath(ymlfilepath)
if '/' not in relpath:
relpath = './%s' % relpath
pathroot = os.path.abspath(os.path.dirname(ymlfilepath))
for image... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:generate_build; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 4, identifier:self; 5, identifier:image; 6, identifier:targetname; 7, default_parameter; 7, 8; 7, 9; 8, identifier:rebuilds; 9, None; 10, default_parameter; 10,... | def generate_build(self, image, targetname, rebuilds=None, cache_repo='', cache_tag='',
buildargs=None, **kwargs):
"""
Separate the build into a series of one or more intermediate steps.
Each specified build directory gets its own step
Args:
image (str... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:sort_dependencies; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:image; 6, default_parameter; 6, 7; 6, 8; 7, identifier:dependencies; 8, None; 9, block; 9, 10; 9, 12; 9, 24; 9, 30; 9, 44; 9, 56; 9, 62; 10, expression_statem... | def sort_dependencies(self, image, dependencies=None):
"""
Topologically sort the docker commands by their requirements
Note:
Circular "requires" dependencies are assumed to have already been checked in
get_external_base_image, they are not checked here
Args:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_external_base_image; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:image; 6, default_parameter; 6, 7; 6, 8; 7, identifier:stack; 8, None; 9, block; 9, 10; 9, 12; 9, 23; 9, 31; 9, 57; 9, 64; 9, 65; 9, 85; 9, 139; 9, 149;... | def get_external_base_image(self, image, stack=None):
""" Makes sure that this image has exactly one unique external base image
"""
if stack is None:
stack = list()
mydef = self.ymldefs[image]
if image in stack:
stack.append(image)
raise erro... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_htmlRenderDict; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:pathParts; 5, identifier:statDict; 6, identifier:output; 7, block; 7, 8; 7, 10; 7, 21; 7, 27; 7, 31; 7, 38; 7, 175; 7, 189; 8, expression_statement; 8, 9; 9, comment; 10, expressio... | def _htmlRenderDict(pathParts, statDict, output):
"""Render a dictionary as a table - recursing as necessary."""
keys = list(statDict.keys())
keys.sort()
links = []
output.write('<div class="level">')
for key in keys:
keyStr = cgi.escape(_utf8str(key))
value = statDict[key]
if hasattr(value, '... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 96; 1, 98; 2, function_name:create_session; 3, parameters; 3, 4; 3, 5; 3, 9; 3, 14; 3, 23; 3, 32; 3, 41; 3, 46; 3, 51; 3, 56; 3, 61; 3, 66; 3, 75; 3, 80; 3, 85; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:kind; 7, type; 7, 8; 8, identifier:Se... | def create_session(
self,
kind: SessionKind,
proxy_user: str = None,
jars: List[str] = None,
py_files: List[str] = None,
files: List[str] = None,
driver_memory: str = None,
driver_cores: int = None,
executor_memory: str = None,
executor_cor... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:sine_psd; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:data; 5, identifier:delta; 6, default_parameter; 6, 7; 6, 8; 7, identifier:number_of_tapers; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:number... | def sine_psd(data, delta, number_of_tapers=None, number_of_iterations=2,
degree_of_smoothing=1.0, statistics=False, verbose=False):
"""
Wrapper method for the sine_psd subroutine in the library by German A.
Prieto.
The subroutine is in charge of estimating the adaptive sine multitaper as
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 25; 2, function_name:mt_deconvolve; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 4, identifier:data_a; 5, identifier:data_b; 6, identifier:delta; 7, default_parameter; 7, 8; 7, 9; 8, identifier:nfft; 9, None; 10, default_parameter; 10,... | def mt_deconvolve(data_a, data_b, delta, nfft=None, time_bandwidth=None,
number_of_tapers=None, weights="adaptive", demean=True,
fmax=0.0):
"""
Deconvolve two time series using multitapers.
This uses the eigencoefficients and the weights from the multitaper
spectral ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:create_server; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:loop; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:as_coroutine; 10, False; 11, default_parameter; 1... | def create_server(self,
loop=None,
as_coroutine=False,
protocol_factory=None,
**server_config):
"""
Helper function which constructs a listening server, using the
default growler.http.protocol.Protocol which ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:event_emitter; 3, parameters; 3, 4; 3, 7; 3, 8; 4, default_parameter; 4, 5; 4, 6; 5, identifier:cls_; 6, None; 7, keyword_separator; 8, default_parameter; 8, 9; 8, 10; 9, identifier:events; 10, tuple; 10, 11; 11, string:'*'; 12, block; 12, 13;... | def event_emitter(cls_=None, *, events=('*', )):
"""
A class-decorator which will add the specified events and the methods 'on'
and 'emit' to the class.
"""
# create a dictionary from items in the 'events' parameter and with empty
# lists as values
event_dict = dict.fromkeys(events, [])
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_build_production_name; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:glyph; 6, block; 6, 7; 6, 9; 6, 10; 6, 35; 6, 36; 6, 42; 6, 60; 6, 61; 6, 73; 6, 108; 6, 109; 6, 121; 6, 163; 6, 243; 7, expression_statement; 7, 8; 8, comment... | def _build_production_name(self, glyph):
"""Build a production name for a single glyph."""
# use PostScript names from UFO lib if available
if self._postscriptNames:
production_name = self._postscriptNames.get(glyph.name)
return production_name if production_name else gl... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:makeOfficialGlyphOrder; 3, parameters; 3, 4; 3, 5; 4, identifier:font; 5, default_parameter; 5, 6; 5, 7; 6, identifier:glyphOrder; 7, None; 8, block; 8, 9; 8, 11; 8, 25; 8, 36; 8, 40; 8, 59; 8, 83; 8, 93; 9, expression_statement; 9, 10; 10, com... | def makeOfficialGlyphOrder(font, glyphOrder=None):
""" Make the final glyph order for 'font'.
If glyphOrder is None, try getting the font.glyphOrder list.
If not explicit glyphOrder is defined, sort glyphs alphabetically.
If ".notdef" glyph is present in the font, force this to always be
the first... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:from_layer; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:cls; 5, identifier:font; 6, default_parameter; 6, 7; 6, 8; 7, identifier:layerName; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:copy; 11, False; 12, defaul... | def from_layer(cls, font, layerName=None, copy=False, skipExportGlyphs=None):
"""Return a mapping of glyph names to glyph objects from `font`."""
if layerName is not None:
layer = font.layers[layerName]
else:
layer = font.layers.defaultLayer
if copy:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 38; 2, function_name:compileInterpolatableTTFs; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 3, 35; 4, identifier:ufos; 5, default_parameter; 5, 6; 5, 7; 6, identifier:preProcessorClass; 7, identifier:TTFInterpolatablePr... | def compileInterpolatableTTFs(
ufos,
preProcessorClass=TTFInterpolatablePreProcessor,
outlineCompilerClass=OutlineTTFCompiler,
featureCompilerClass=None,
featureWriters=None,
glyphOrder=None,
useProductionNames=None,
cubicConversionError=None,
reverseDirection=True,
inplace=False... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_propagate_glyph_anchors; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:glyphSet; 5, identifier:composite; 6, identifier:processed; 7, block; 7, 8; 7, 10; 7, 18; 7, 27; 7, 34; 7, 38; 7, 42; 7, 48; 7, 52; 7, 145; 7, 227; 7, 260; 7, 271; 7, 272;... | def _propagate_glyph_anchors(glyphSet, composite, processed):
"""
Propagate anchors from base glyphs to a given composite
glyph, and to all composite glyphs used in between.
"""
if composite.name in processed:
return
processed.add(composite.name)
if not composite.components:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:setupTable_name; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 16; 5, 22; 5, 35; 5, 41; 5, 42; 5, 104; 5, 105; 5, 115; 5, 129; 5, 139; 5, 149; 5, 157; 5, 284; 5, 285; 5, 298; 5, 311; 5, 312; 5, 328; 6, expression_statement; ... | def setupTable_name(self):
"""
Make the name table.
**This should not be called externally.** Subclasses
may override or supplement this method to handle the
table creation in a different way if desired.
"""
if "name" not in self.tables:
return
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:setupTable_cmap; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 16; 5, 24; 5, 48; 5, 86; 5, 87; 5, 94; 5, 100; 5, 106; 5, 112; 5, 118; 5, 119; 5, 126; 5, 132; 5, 138; 5, 144; 5, 150; 5, 151; 5, 164; 5, 170; 5, 178; 5, 179; 5,... | def setupTable_cmap(self):
"""
Make the cmap table.
**This should not be called externally.** Subclasses
may override or supplement this method to handle the
table creation in a different way if desired.
"""
if "cmap" not in self.tables:
return
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_setupTable_hhea_or_vhea; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:tag; 6, block; 6, 7; 6, 9; 6, 17; 6, 32; 6, 45; 6, 60; 6, 66; 6, 83; 6, 84; 6, 85; 6, 86; 6, 87; 6, 88; 6, 89; 6, 90; 6, 100; 6, 119; 6, 153; 6, 179; 6, 180;... | def _setupTable_hhea_or_vhea(self, tag):
"""
Make the hhea table or the vhea table. This assume the hmtx or
the vmtx were respectively made first.
"""
if tag not in self.tables:
return
if tag == "hhea":
isHhea = True
else:
isHh... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:dir; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:methods; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:showall; 10, True; 11, block; 11, 12; 11, 14; 11, 17; 11, 18; 11, 54; ... | def dir(self,methods=True,showall=True):
"""Show this object's attributes and methods."""
import inspect
#print "[attributes]"
for k,v in sorted(self.__dict__.items()):
if k.startswith("_"): continue
print makeminlength("."+k,being.linelen),"\t",v
if not methods:
return
entmethods=dir(entity)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:tree; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:offset; 7, integer:0; 8, default_parameter; 8, 9; 8, 10; 9, identifier:prefix_inherited; 10, string:""; 11, default_parameter; 11... | def tree(self,offset=0,prefix_inherited="",nofeatsplease=['Phoneme']):
"""Print a tree-structure of this object's phonological representation."""
tree = ""
numchild=0
for child in self.children:
if type(child)==type([]):
child=child[0]
numchild+=1
classname=child.classname()
if classname=="Wor... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:stats_positions; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:meter; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:all_parses; 10, False; 11, block; 11, 12; 11, 14; 11, 16; 11... | def stats_positions(self,meter=None,all_parses=False):
"""Produce statistics from the parser"""
"""Positions
All feats of slots
All constraint violations
"""
parses = self.allParses(meter=meter) if all_parses else [[parse] for parse in self.bestParses(meter=meter)]
dx={}
for parselist in parses:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:iparse; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:meter; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:num_processes; 10, integer:1; 11, default_parameter; 11... | def iparse(self,meter=None,num_processes=1,arbiter='Line',line_lim=None):
"""Parse this text metrically, yielding it line by line."""
from Meter import Meter,genDefault,parse_ent,parse_ent_mp
import multiprocessing as mp
meter=self.get_meter(meter)
# set internal attributes
self.__parses[meter.id]=[]
sel... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:from_representation; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:representation; 6, block; 6, 7; 6, 9; 6, 13; 6, 17; 6, 173; 6, 207; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10,... | def from_representation(self, representation):
"""Convert given representation dict into internal object.
Internal object is simply a dictionary of values with respect to field
sources.
This does not check if all required fields exist or values are
valid in terms of value valid... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:require_params; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:req; 6, block; 6, 7; 6, 9; 6, 13; 6, 208; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:par... | def require_params(self, req):
"""Require all defined parameters from request query string.
Raises ``falcon.errors.HTTPMissingParam`` exception if any of required
parameters is missing and ``falcon.errors.HTTPInvalidParam`` if any
of parameters could not be understood (wrong format).
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:parse; 3, parameters; 3, 4; 3, 5; 4, identifier:celf; 5, identifier:s; 6, block; 6, 7; 6, 9; 6, 283; 6, 284; 6, 285; 6, 294; 6, 301; 7, expression_statement; 7, 8; 8, string:"generates an Introspection tree from the given XML string description... | def parse(celf, s) :
"generates an Introspection tree from the given XML string description."
def from_string_elts(celf, attrs, tree) :
elts = dict((k, attrs[k]) for k in attrs)
child_tags = dict \
(
(childclass.tag_name, childclass)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:unparse; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:indent_step; 7, integer:4; 8, default_parameter; 8, 9; 8, 10; 9, identifier:max_linelen; 10, integer:72; 11, block; 11, 12; 11, 14; 1... | def unparse(self, indent_step = 4, max_linelen = 72) :
"returns an XML string description of this Introspection tree."
out = io.StringIO()
def to_string(obj, indent) :
tag_name = obj.tag_name
attrs = []
for attrname in obj.tag_attrs :
attr = ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:AddMethod; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:self; 5, identifier:interface; 6, identifier:name; 7, identifier:in_sig; 8, identifier:out_sig; 9, identifier:code; 10, block; 10, 11; 10, 13; 10, 23; 10, 35; 10, 36; ... | def AddMethod(self, interface, name, in_sig, out_sig, code):
'''Add a method to this object
interface: D-Bus interface to add this to. For convenience you can
specify '' here to add the method to the object's main
interface (as specified on construction).
n... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:AddTemplate; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:template; 6, identifier:parameters; 7, block; 7, 8; 7, 10; 7, 44; 7, 45; 7, 62; 7, 63; 7, 137; 7, 146; 7, 154; 7, 155; 7, 156; 7, 162; 8, expression_statement; 8, 9... | def AddTemplate(self, template, parameters):
'''Load a template into the mock.
python-dbusmock ships a set of standard mocks for common system
services such as UPower and NetworkManager. With these the actual tests
become a lot simpler, as they only have to set up the particular
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:format_args; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:args; 6, block; 6, 7; 6, 9; 6, 197; 6, 201; 6, 219; 6, 228; 7, expression_statement; 7, 8; 8, string:'''Format a D-Bus argument tuple into an appropriate logging string.'... | def format_args(self, args):
'''Format a D-Bus argument tuple into an appropriate logging string.'''
def format_arg(a):
if isinstance(a, dbus.Boolean):
return str(bool(a))
if isinstance(a, dbus.Byte):
return str(int(a))
if isinstance(a... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:Introspect; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:object_path; 6, identifier:connection; 7, block; 7, 8; 7, 10; 7, 11; 7, 27; 7, 35; 7, 43; 7, 79; 7, 87; 7, 102; 7, 111; 7, 213; 7, 233; 7, 234; 7, 242; 8, expression... | def Introspect(self, object_path, connection):
'''Return XML description of this object's interfaces, methods and signals.
This wraps dbus-python's Introspect() method to include the dynamic
methods and properties.
'''
# temporarily add our dynamic methods
cls = self.__c... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:argument; 3, parameters; 3, 4; 3, 6; 3, 9; 4, list_splat_pattern; 4, 5; 5, identifier:param_decls; 6, default_parameter; 6, 7; 6, 8; 7, identifier:cls; 8, None; 9, dictionary_splat_pattern; 9, 10; 10, identifier:attrs; 11, block; 11, 12; 11, 1... | def argument(*param_decls, cls=None, **attrs):
"""
Arguments are positional parameters to a command. They generally
provide fewer features than options but can have infinite ``nargs``
and are required by default.
:param param_decls: the parameter declarations for this option or
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:option; 3, parameters; 3, 4; 3, 6; 3, 9; 4, list_splat_pattern; 4, 5; 5, identifier:param_decls; 6, default_parameter; 6, 7; 6, 8; 7, identifier:cls; 8, None; 9, dictionary_splat_pattern; 9, 10; 10, identifier:attrs; 11, block; 11, 12; 11, 14;... | def option(*param_decls, cls=None, **attrs):
"""
Options are usually optional values on the command line and
have some extra features that arguments don't have.
:param param_decls: the parameter declarations for this option or
argument. This is a list of flags or argument
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 1, 14; 2, function_name:add_to_loader_class; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:cls; 5, default_parameter; 5, 6; 5, 7; 6, identifier:loader_class; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:tag; 10, None; 11, dictionary_splat_... | def add_to_loader_class(cls, loader_class=None, tag=None, **kwargs):
# type: (type(yaml.Loader), str, **str)-> YamlIncludeConstructor
"""
Create an instance of the constructor, and add it to the YAML `Loader` class
:param loader_class: The `Loader` class add constructor to.
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 26; 1, 28; 2, function_name:print_table; 3, parameters; 3, 4; 3, 8; 3, 12; 3, 21; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:column_names; 6, type; 6, 7; 7, identifier:IterableOfStrings; 8, typed_parameter; 8, 9; 8, 10; 9, identifier:rows; 10, type; 10, 11; 11,... | def print_table(column_names: IterableOfStrings,
rows: IterableOfTuples,
column_alignments: Optional[IterableOfStrings] = None,
primary_column_idx: int = 0,
) -> None:
"""
Prints a table of information to the console. Automatically determines if th... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 26; 2, function_name:model_fields; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 4, identifier:model; 5, default_parameter; 5, 6; 5, 7; 6, identifier:db_session; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:only; 10, None; 11, de... | def model_fields(model, db_session=None, only=None, exclude=None,
field_args=None, converter=None, exclude_pk=False,
exclude_fk=False):
"""
Generate a dictionary of fields for a given SQLAlchemy model.
See `model_form` docstring for description of parameters.
"""
m... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:singularize; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:word; 5, default_parameter; 5, 6; 5, 7; 6, identifier:pos; 7, identifier:NOUN; 8, default_parameter; 8, 9; 8, 10; 9, identifier:custom; 10, None; 11, block; 11, 12; 11, 14; 11, 25; 11... | def singularize(word, pos=NOUN, custom=None):
""" Returns the singular of a given word.
"""
if custom and word in custom:
return custom[word]
# Recurse compound words (e.g. mothers-in-law).
if "-" in word:
w = word.split("-")
if len(w) > 1 and w[1] in plural_prepositions:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 37; 1, 39; 2, function_name:login_user; 3, parameters; 3, 4; 3, 5; 3, 9; 3, 18; 3, 27; 3, 32; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:user; 7, type; 7, 8; 8, identifier:User; 9, typed_default_parameter; 9, 10; 9, 11; 9, 17; 10, identifier... | def login_user(self,
user: User,
remember: Optional[bool] = None,
duration: Optional[timedelta] = None,
force: bool = False,
fresh: bool = True,
) -> bool:
"""
Logs a user in. You should pas... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 70; 1, 78; 2, function_name:url_for; 3, parameters; 3, 4; 3, 8; 3, 17; 3, 32; 3, 41; 3, 50; 3, 59; 3, 68; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:endpoint_or_url_or_config_key; 6, type; 6, 7; 7, identifier:str; 8, typed_default_parameter; 8, 9; 8, 10; 8, 16;... | def url_for(endpoint_or_url_or_config_key: str,
_anchor: Optional[str] = None,
_cls: Optional[Union[object, type]] = None,
_external: Optional[bool] = False,
_external_host: Optional[str] = None,
_method: Optional[str] = None,
_scheme: Optional[str... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 93; 1, 95; 2, function_name:redirect; 3, parameters; 3, 4; 3, 13; 3, 22; 3, 31; 3, 40; 3, 55; 3, 64; 3, 73; 3, 82; 3, 91; 4, typed_default_parameter; 4, 5; 4, 6; 4, 12; 5, identifier:where; 6, type; 6, 7; 7, generic_type; 7, 8; 7, 9; 8, identifier:Optional; 9, typ... | def redirect(where: Optional[str] = None,
default: Optional[str] = None,
override: Optional[str] = None,
_anchor: Optional[str] = None,
_cls: Optional[Union[object, type]] = None,
_external: Optional[bool] = False,
_external_host: Optional[st... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:auth_required; 3, parameters; 3, 4; 3, 7; 4, default_parameter; 4, 5; 4, 6; 5, identifier:decorated_fn; 6, None; 7, dictionary_splat_pattern; 7, 8; 8, identifier:role_rules; 9, block; 9, 10; 9, 12; 9, 16; 9, 20; 9, 78; 9, 123; 9, 136; 10, expre... | def auth_required(decorated_fn=None, **role_rules):
"""
Decorator for requiring an authenticated user, optionally with roles.
Roles are passed as keyword arguments, like so::
@auth_required(role='REQUIRE_THIS_ONE_ROLE')
@auth_required(roles=['REQUIRE', 'ALL', 'OF', 'THESE', 'ROLES'])
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:build_tree; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 14; 5, 26; 5, 351; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, identifier:built; 12,... | def build_tree(self):
"""Bulids the tree with all the fields converted to Elements
"""
if self.built:
return
self.doc_root = self.root.element()
for key in self.sorted_fields():
if key not in self._fields:
continue
field = self.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.