_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q239900 | Node.signals | train | def signals(self, skip_not_present=True):
"""
Returns an iterator that provides nodes for all immediate signals of
this component.
Parameters
----------
skip_not_present : bool
If True, skips children whose 'ispresent' property is set to False
Yields... | python | {
"resource": ""
} |
q239901 | Node.fields | train | def fields(self, skip_not_present=True):
"""
Returns an iterator that provides nodes for all immediate fields of
this component.
Parameters
----------
skip_not_present : bool
If True, skips children whose 'ispresent' property is set to False
Yields
... | python | {
"resource": ""
} |
q239902 | Node.registers | train | def registers(self, unroll=False, skip_not_present=True):
"""
Returns an iterator that provides nodes for all immediate registers of
this component.
Parameters
----------
unroll : bool
If True, any children that are arrays are unrolled.
skip_not_pres... | python | {
"resource": ""
} |
q239903 | Node.find_by_path | train | 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... | python | {
"resource": ""
} |
q239904 | Node.get_property | train | 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... | python | {
"resource": ""
} |
q239905 | Node.list_properties | train | def list_properties(self, list_all=False):
"""
Lists properties associated with this node.
By default, only lists properties that were explicitly set. If ``list_all`` is
set to ``True`` then lists all valid properties of this component type
Parameters
----------
... | python | {
"resource": ""
} |
q239906 | Node.get_path | train | def get_path(self, hier_separator=".", array_suffix="[{index:d}]", empty_array_suffix="[]"):
"""
Generate an absolute path string to this node
Parameters
----------
hier_separator: str
Override the hierarchy separator
array_suffix: str
Override ho... | python | {
"resource": ""
} |
q239907 | Node.get_html_desc | train | def get_html_desc(self, markdown_inst=None):
"""
Translates the node's 'desc' property into HTML.
Any RDLFormatCode tags used in the description are converted to HTML.
The text is also fed through a Markdown processor.
The additional Markdown processing allows designers the cho... | python | {
"resource": ""
} |
q239908 | AddressableNode.address_offset | train | def address_offset(self):
"""
Byte address offset of this node relative to it's parent
If this node is an array, it's index must be known
Raises
------
ValueError
If this property is referenced on a node whose array index is not
fully defined
... | python | {
"resource": ""
} |
q239909 | AddressableNode.absolute_address | train | def absolute_address(self):
"""
Get the absolute byte address of this node.
Indexes of all arrays in the node's lineage must be known
Raises
------
ValueError
If this property is referenced on a node whose array lineage is not
fully defined
... | python | {
"resource": ""
} |
q239910 | RootNode.top | train | def top(self):
"""
Returns the top-level addrmap node
"""
for child in self.children(skip_not_present=False):
if not isinstance(child, AddrmapNode):
continue
return child
raise RuntimeError | python | {
"resource": ""
} |
q239911 | FieldNode.is_sw_writable | train | def is_sw_writable(self):
"""
Field is writable by software
"""
sw = self.get_property('sw')
return sw in (rdltypes.AccessType.rw, rdltypes.AccessType.rw1,
rdltypes.AccessType.w, rdltypes.AccessType.w1) | python | {
"resource": ""
} |
q239912 | FieldNode.is_sw_readable | train | def is_sw_readable(self):
"""
Field is readable by software
"""
sw = self.get_property('sw')
return sw in (rdltypes.AccessType.rw, rdltypes.AccessType.rw1,
rdltypes.AccessType.r) | python | {
"resource": ""
} |
q239913 | FieldNode.implements_storage | train | def implements_storage(self):
"""
True if combination of field access properties imply that the field
implements a storage element.
"""
# 9.4.1, Table 12
sw = self.get_property('sw')
hw = self.get_property('hw')
if sw in (rdltypes.AccessType.rw, rdltypes.... | python | {
"resource": ""
} |
q239914 | ComponentVisitor.visitComponent_def | train | def visitComponent_def(self, ctx:SystemRDLParser.Component_defContext):
"""
Create, and possibly instantiate a component
"""
# Get definition. Returns Component
if ctx.component_anon_def() is not None:
comp_def = self.visit(ctx.component_anon_def())
elif ctx.... | python | {
"resource": ""
} |
q239915 | ComponentVisitor.define_component | train | def define_component(self, body, type_token, def_name, param_defs):
"""
Given component definition, recurse to another ComponentVisitor
to define a new component
"""
for subclass in ComponentVisitor.__subclasses__():
if subclass.comp_type == self._CompType_Map[type_to... | python | {
"resource": ""
} |
q239916 | ComponentVisitor.get_instance_assignment | train | def get_instance_assignment(self, ctx):
"""
Gets the integer expression in any of the four instance assignment
operators ('=' '@' '+=' '%=')
"""
if ctx is None:
return None
visitor = ExprVisitor(self.compiler)
expr = visitor.visit(ctx.expr())
... | python | {
"resource": ""
} |
q239917 | ComponentVisitor.visitParam_def | train | def visitParam_def(self, ctx:SystemRDLParser.Param_defContext):
"""
Parameter Definition block
"""
self.compiler.namespace.enter_scope()
param_defs = []
for elem in ctx.getTypedRuleContexts(SystemRDLParser.Param_def_elemContext):
param_def = self.visit(elem)
... | python | {
"resource": ""
} |
q239918 | ComponentVisitor.visitParam_def_elem | train | def visitParam_def_elem(self, ctx:SystemRDLParser.Param_def_elemContext):
"""
Individual parameter definition elements
"""
# Construct parameter type
data_type_token = self.visit(ctx.data_type())
param_data_type = self.datatype_from_token(data_type_token)
if ctx.... | python | {
"resource": ""
} |
q239919 | BaseVisitor.datatype_from_token | train | def datatype_from_token(self, token):
"""
Given a SystemRDLParser token, lookup the type
This only includes types under the "data_type" grammar rule
"""
if token.type == SystemRDLParser.ID:
# Is an identifier for either an enum or struct type
typ = self.... | python | {
"resource": ""
} |
q239920 | get_rdltype | train | def get_rdltype(value):
"""
Given a value, return the type identifier object used within the RDL compiler
If not a supported type, return None
"""
if isinstance(value, (int, bool, str)):
# Pass canonical types as-is
return type(value)
elif is_user_enum(type(value)):
retu... | python | {
"resource": ""
} |
q239921 | UserEnum.get_html_desc | train | def get_html_desc(self, markdown_inst=None):
"""
Translates the enum's 'desc' property into HTML.
Any RDLFormatCode tags used in the description are converted to HTML.
The text is also fed through a Markdown processor.
The additional Markdown processing allows designers the cho... | python | {
"resource": ""
} |
q239922 | UserEnum.get_scope_path | train | def get_scope_path(cls, scope_separator="::"):
"""
Generate a string that represents this enum's declaration namespace
scope.
Parameters
----------
scope_separator: str
Override the separator between namespace scopes
"""
if cls.get_parent_scop... | python | {
"resource": ""
} |
q239923 | UserStruct.define_new | train | def define_new(cls, name, members, is_abstract=False):
"""
Define a new struct type derived from the current type.
Parameters
----------
name: str
Name of the struct type
members: {member_name : type}
Dictionary of struct member types.
is_... | python | {
"resource": ""
} |
q239924 | RDLCompiler.define_udp | train | def define_udp(self, name, valid_type, valid_components=None, default=None):
"""
Pre-define a user-defined property.
This is the equivalent to the following RDL:
.. code-block:: none
property <name> {
type = <valid_type>;
component = <valid_... | python | {
"resource": ""
} |
q239925 | RDLCompiler.compile_file | train | def compile_file(self, path, incl_search_paths=None):
"""
Parse & compile a single file and append it to RDLCompiler's root
namespace.
If any exceptions (:class:`~systemrdl.RDLCompileError` or other)
occur during compilation, then the RDLCompiler object should be discarded.
... | python | {
"resource": ""
} |
q239926 | RDLCompiler.elaborate | train | 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... | python | {
"resource": ""
} |
q239927 | PropertyRuleBoolPair.get_default | train | def get_default(self, node):
"""
If not explicitly set, check if the opposite was set first before returning
default
"""
if self.opposite_property in node.inst.properties:
return not node.inst.properties[self.opposite_property]
else:
return self.de... | python | {
"resource": ""
} |
q239928 | Prop_rset.get_default | train | def get_default(self, node):
"""
If not explicitly set, check if onread sets the equivalent
"""
if node.inst.properties.get("onread", None) == rdltypes.OnReadType.rset:
return True
else:
return self.default | python | {
"resource": ""
} |
q239929 | Prop_onread.assign_value | train | def assign_value(self, comp_def, value, src_ref):
"""
Overrides other related properties
"""
super().assign_value(comp_def, value, src_ref)
if "rclr" in comp_def.properties:
del comp_def.properties["rclr"]
if "rset" in comp_def.properties:
del comp... | python | {
"resource": ""
} |
q239930 | Prop_onread.get_default | train | def get_default(self, node):
"""
If not explicitly set, check if rset or rclr imply the value
"""
if node.inst.properties.get("rset", False):
return rdltypes.OnReadType.rset
elif node.inst.properties.get("rclr", False):
return rdltypes.OnReadType.rclr
... | python | {
"resource": ""
} |
q239931 | Prop_woclr.get_default | train | def get_default(self, node):
"""
If not explicitly set, check if onwrite sets the equivalent
"""
if node.inst.properties.get("onwrite", None) == rdltypes.OnWriteType.woclr:
return True
else:
return self.default | python | {
"resource": ""
} |
q239932 | Prop_onwrite.get_default | train | def get_default(self, node):
"""
If not explicitly set, check if woset or woclr imply the value
"""
if node.inst.properties.get("woset", False):
return rdltypes.OnWriteType.woset
elif node.inst.properties.get("woclr", False):
return rdltypes.OnWriteType.wo... | python | {
"resource": ""
} |
q239933 | Prop_threshold.assign_value | train | def assign_value(self, comp_def, value, src_ref):
"""
Set both alias and actual value
"""
super().assign_value(comp_def, value, src_ref)
comp_def.properties['incrthreshold'] = value | python | {
"resource": ""
} |
q239934 | Prop_stickybit.get_default | train | def get_default(self, node):
"""
Unless specified otherwise, intr fields are implicitly stickybit
"""
if node.inst.properties.get("intr", False):
# Interrupt is set!
# Default is implicitly stickybit, unless the mutually-exclusive
# sticky property was... | python | {
"resource": ""
} |
q239935 | StructuralPlacementListener.resolve_addresses | train | 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:
... | python | {
"resource": ""
} |
q239936 | get_ID_text | train | def get_ID_text(token):
"""
Get the text from the ID token.
Strips off leading slash escape if present
"""
if isinstance(token, CommonToken):
text = token.text
else:
text = token.getText()
text = text.lstrip('\\')
return text | python | {
"resource": ""
} |
q239937 | SegmentMap.derive_source_offset | train | def derive_source_offset(self, offset, is_end=False):
"""
Given a post-preprocessed coordinate, derives the corresponding coordinate
in the original source file.
Returns result in the following tuple:
(src_offset, src_path, include_ref)
where:
- src_offse... | python | {
"resource": ""
} |
q239938 | FilePreprocessor.preprocess | train | def preprocess(self):
"""
Run preprocessor on a top-level file.
Performs the following preprocess steps:
- Expand `include directives
- Perl Preprocessor
Returns
-------
tuple
(preprocessed_text, SegmentMap)
"""
tokens = self... | python | {
"resource": ""
} |
q239939 | FilePreprocessor.tokenize | train | def tokenize(self):
"""
Tokenize the input text
Scans for instances of perl tags and include directives.
Tokenization skips line and block comments.
Returns
-------
list
List of tuples: (typ, start, end)
Where:
- typ is "per... | python | {
"resource": ""
} |
q239940 | FilePreprocessor.parse_include | train | 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 = ... | python | {
"resource": ""
} |
q239941 | FilePreprocessor.run_perl_miniscript | train | def run_perl_miniscript(self, segments):
"""
Generates and runs a perl miniscript that derives the text that will be
emitted from the preprocessor
returns the resulting emit list
"""
# Check if perl is installed
if shutil.which("perl") is None:
self.... | python | {
"resource": ""
} |
q239942 | NamespaceRegistry.get_default_properties | train | def get_default_properties(self, comp_type):
"""
Returns a flattened dictionary of all default property assignments
visible in the current scope that apply to the current component type.
"""
# Flatten out all the default assignments that apply to the current scope
# This ... | python | {
"resource": ""
} |
q239943 | Component.get_scope_path | train | def get_scope_path(self, scope_separator="::"):
"""
Generate a string that represents this component's declaration namespace
scope.
Parameters
----------
scope_separator: str
Override the separator between namespace scopes
"""
if self.parent_s... | python | {
"resource": ""
} |
q239944 | AddressableComponent.n_elements | train | def n_elements(self):
"""
Total number of array elements.
If array is multidimensional, array is flattened.
Returns 1 if not an array.
"""
if self.is_array:
return functools.reduce(operator.mul, self.array_dimensions)
else:
return 1 | python | {
"resource": ""
} |
q239945 | RDLWalker.walk | train | def walk(self, node, *listeners:RDLListener):
"""
Initiates the walker to traverse the current ``node`` and its children.
Calls the corresponding callback for each of the ``listeners`` provided in
the order that they are listed.
Parameters
----------
node : :clas... | python | {
"resource": ""
} |
q239946 | get_function | train | def get_function(fn_name):
"""Retrieve the function defined by the function_name.
Arguments:
fn_name: specification of the type module:function_name.
"""
module_name, callable_name = fn_name.split(':')
current = globals()
if not callable_name:
callable_name = module_name
else... | python | {
"resource": ""
} |
q239947 | parse_command_line | train | def parse_command_line(argv):
"""Parse command line argument. See -h option.
Arguments:
argv: arguments on the command line must include caller file name.
"""
import textwrap
example = textwrap.dedent("""
Examples:
# Simple string substitution (-e). Will show a diff. No changes appl... | python | {
"resource": ""
} |
q239948 | get_paths | train | 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... | python | {
"resource": ""
} |
q239949 | edit_files | train | 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... | python | {
"resource": ""
} |
q239950 | command_line | train | def command_line(argv):
"""Instantiate an editor and process arguments.
Optional argument:
- processed_paths: paths processed are appended to the list.
"""
arguments = parse_command_line(argv)
if arguments.generate:
generate_fixer_file(arguments.generate)
paths = edit_files(argum... | python | {
"resource": ""
} |
q239951 | MassEdit.import_module | train | def import_module(module): # pylint: disable=R0201
"""Import module that are needed for the code expr to compile.
Argument:
module (str or list): module(s) to import.
"""
if isinstance(module, list):
all_modules = module
else:
all_modules = [m... | python | {
"resource": ""
} |
q239952 | MassEdit.__edit_line | train | def __edit_line(line, code, code_obj): # pylint: disable=R0201
"""Edit a line with one code object built in the ctor."""
try:
# pylint: disable=eval-used
result = eval(code_obj, globals(), locals())
except TypeError as ex:
log.error("failed to execute %s: %s"... | python | {
"resource": ""
} |
q239953 | MassEdit.edit_line | train | def edit_line(self, line):
"""Edit a single line using the code expression."""
for code, code_obj in self.code_objs.items():
line = self.__edit_line(line, code, code_obj)
return line | python | {
"resource": ""
} |
q239954 | MassEdit.edit_content | train | def edit_content(self, original_lines, file_name):
"""Processes a file contents.
First processes the contents line by line applying the registered
expressions, then process the resulting contents using the
registered functions.
Arguments:
original_lines (list of str):... | python | {
"resource": ""
} |
q239955 | MassEdit.append_code_expr | train | def append_code_expr(self, code):
"""Compile argument and adds it to the list of code objects."""
# expects a string.
if isinstance(code, str) and not isinstance(code, unicode):
code = unicode(code)
if not isinstance(code, unicode):
raise TypeError("string expecte... | python | {
"resource": ""
} |
q239956 | MassEdit.append_function | train | def append_function(self, function):
"""Append the function to the list of functions to be called.
If the function is already a callable, use it. If it's a type str
try to interpret it as [module]:?<callable>, load the module
if there is one and retrieve the callable.
Argument:... | python | {
"resource": ""
} |
q239957 | MassEdit.append_executable | train | def append_executable(self, executable):
"""Append san executable os command to the list to be called.
Argument:
executable (str): os callable executable.
"""
if isinstance(executable, str) and not isinstance(executable, unicode):
executable = unicode(executable)
... | python | {
"resource": ""
} |
q239958 | MassEdit.set_functions | train | def set_functions(self, functions):
"""Check functions passed as argument and set them to be used."""
for func in functions:
try:
self.append_function(func)
except (ValueError, AttributeError) as ex:
log.error("'%s' is not a callable function: %s",... | python | {
"resource": ""
} |
q239959 | write_mnefiff | train | def write_mnefiff(data, filename):
"""Export data to MNE using FIFF format.
Parameters
----------
data : instance of ChanTime
data with only one trial
filename : path to file
file to export to (include '.mat')
Notes
-----
It cannot store data larger than 2 GB.
The d... | python | {
"resource": ""
} |
q239960 | detect_UCSD | train | def detect_UCSD(dat_orig, s_freq, time, opts):
"""Spindle detection based on the UCSD method
Parameters
----------
dat_orig : ndarray (dtype='float')
vector with the data for one channel
s_freq : float
sampling frequency
time : ndarray (dtype='float')
vector with the tim... | python | {
"resource": ""
} |
q239961 | detect_Concordia | train | def detect_Concordia(dat_orig, s_freq, time, opts):
"""Spindle detection, experimental Concordia method. Similar to Moelle 2011
and Nir2011.
Parameters
----------
dat_orig : ndarray (dtype='float')
vector with the data for one channel
s_freq : float
sampling frequency
opts :... | python | {
"resource": ""
} |
q239962 | define_threshold | train | def define_threshold(dat, s_freq, method, value, nbins=120):
"""Return the value of the threshold based on relative values.
Parameters
----------
dat : ndarray (dtype='float')
vector with the data after selection-transformation
s_freq : float
sampling frequency
method : str
... | python | {
"resource": ""
} |
q239963 | detect_events | train | 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 :... | python | {
"resource": ""
} |
q239964 | select_events | train | def select_events(dat, detected, method, value):
"""Select start sample and end sample of the events.
Parameters
----------
dat : ndarray (dtype='float')
vector with the data after selection-transformation
detected : ndarray (dtype='int')
N x 3 matrix with start, peak, end samples
... | python | {
"resource": ""
} |
q239965 | merge_close | train | 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.... | python | {
"resource": ""
} |
q239966 | within_duration | train | def within_duration(events, time, limits):
"""Check whether event is within time limits.
Parameters
----------
events : ndarray (dtype='int')
N x M matrix with start sample first and end samples last on M
time : ndarray (dtype='float')
vector with time points
limits : tuple of f... | python | {
"resource": ""
} |
q239967 | remove_straddlers | train | def remove_straddlers(events, time, s_freq, toler=0.1):
"""Reject an event if it straddles a stitch, by comparing its
duration to its timespan.
Parameters
----------
events : ndarray (dtype='int')
N x M matrix with start, ..., end samples
time : ndarray (dtype='float')
vector w... | python | {
"resource": ""
} |
q239968 | power_ratio | train | def power_ratio(events, dat, s_freq, limits, ratio_thresh):
"""Estimate the ratio in power between spindle band and lower frequencies.
Parameters
----------
events : ndarray (dtype='int')
N x 3 matrix with start, peak, end samples
dat : ndarray (dtype='float')
vector with the origin... | python | {
"resource": ""
} |
q239969 | peak_in_power | train | def peak_in_power(events, dat, s_freq, method, value=None):
"""Define peak in power of the signal.
Parameters
----------
events : ndarray (dtype='int')
N x 3 matrix with start, peak, end samples
dat : ndarray (dtype='float')
vector with the original data
s_freq : float
s... | python | {
"resource": ""
} |
q239970 | power_in_band | train | def power_in_band(events, dat, s_freq, frequency):
"""Define power of the signal within frequency band.
Parameters
----------
events : ndarray (dtype='int')
N x 3 matrix with start, peak, end samples
dat : ndarray (dtype='float')
vector with the original data
s_freq : float
... | python | {
"resource": ""
} |
q239971 | make_spindles | train | def make_spindles(events, power_peaks, powers, dat_det, dat_orig, time,
s_freq):
"""Create dict for each spindle, based on events of time points.
Parameters
----------
events : ndarray (dtype='int')
N x 3 matrix with start, peak, end samples, and peak frequency
power_peaks... | python | {
"resource": ""
} |
q239972 | _remove_duplicate | train | 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)
... | python | {
"resource": ""
} |
q239973 | _detect_start_end | train | def _detect_start_end(true_values):
"""From ndarray of bool values, return intervals of True values.
Parameters
----------
true_values : ndarray (dtype='bool')
array with bool values
Returns
-------
ndarray (dtype='int')
N x 2 matrix with starting and ending times.
"""
... | python | {
"resource": ""
} |
q239974 | _merge_close | train | def _merge_close(dat, events, time, min_interval):
"""Merge together events separated by less than a minimum interval.
Parameters
----------
dat : ndarray (dtype='float')
vector with the data after selection-transformation
events : ndarray (dtype='int')
N x 3 matrix with start, peak... | python | {
"resource": ""
} |
q239975 | _wmorlet | train | def _wmorlet(f0, sd, sampling_rate, ns=5):
"""
adapted from nitime
returns a complex morlet wavelet in the time domain
Parameters
----------
f0 : center frequency
sd : standard deviation of frequency
sampling_rate : samplingrate
ns : window length in number of stand... | python | {
"resource": ""
} |
q239976 | _realwavelets | train | def _realwavelets(s_freq, freqs, dur, width):
"""Create real wavelets, for UCSD.
Parameters
----------
s_freq : int
sampling frequency
freqs : ndarray
vector with frequencies of interest
dur : float
duration of the wavelets in s
width : float
parameter contro... | python | {
"resource": ""
} |
q239977 | SpindleDialog.count_channels | train | def count_channels(self):
"""If more than one channel selected, activate merge checkbox."""
merge = self.index['merge']
if len(self.idx_chan.selectedItems()) > 1:
if merge.isEnabled():
return
else:
merge.setEnabled(True)
else:
... | python | {
"resource": ""
} |
q239978 | math | train | 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... | python | {
"resource": ""
} |
q239979 | get_descriptives | train | def get_descriptives(data):
"""Get mean, SD, and mean and SD of log values.
Parameters
----------
data : ndarray
Data with segment as first dimension
and all other dimensions raveled into second dimension.
Returns
-------
dict of ndarray
each entry is a 1-D vector o... | python | {
"resource": ""
} |
q239980 | _read_info_as_dict | train | def _read_info_as_dict(fid, values):
"""Convenience function to read info in axon data to a nicely organized
dict.
"""
output = {}
for key, fmt in values:
val = unpack(fmt, fid.read(calcsize(fmt)))
if len(val) == 1:
output[key] = val[0]
else:
output[ke... | python | {
"resource": ""
} |
q239981 | read_settings | train | def read_settings(widget, value_name):
"""Read Settings information, either from INI or from default values.
Parameters
----------
widget : str
name of the widget
value_name : str
name of the value of interest.
Returns
-------
multiple types
type depends on the ... | python | {
"resource": ""
} |
q239982 | Settings.create_settings | train | def create_settings(self):
"""Create the widget, organized in two parts.
Notes
-----
When you add widgets in config, remember to update show_settings too
"""
bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Apply |
QDialogBut... | python | {
"resource": ""
} |
q239983 | Config.create_values | train | def create_values(self, value_names):
"""Read original values from the settings or the defaults.
Parameters
----------
value_names : list of str
list of value names to read
Returns
-------
dict
dictionary with the value names as keys
... | python | {
"resource": ""
} |
q239984 | Config.get_values | train | def get_values(self):
"""Get values from the GUI and save them in preference file."""
for value_name, widget in self.index.items():
self.value[value_name] = widget.get_value(self.value[value_name])
setting_name = self.widget + '/' + value_name
settings.setValue(setti... | python | {
"resource": ""
} |
q239985 | Config.put_values | train | def put_values(self):
"""Put values to the GUI.
Notes
-----
In addition, when one small widget has been changed, it calls
set_modified, so that we know that the preference widget was modified.
"""
for value_name, widget in self.index.items():
widget.... | python | {
"resource": ""
} |
q239986 | _get_indices | train | def _get_indices(values, selected, tolerance):
"""Get indices based on user-selected values.
Parameters
----------
values : ndarray (any dtype)
values present in the axis.
selected : ndarray (any dtype) or tuple or list
values selected by the user
tolerance : float
avoid... | python | {
"resource": ""
} |
q239987 | Data.number_of | train | def number_of(self, axis):
"""Return the number of in one axis, as generally as possible.
Parameters
----------
axis : str
Name of the axis (such as 'trial', 'time', etc)
Returns
-------
int or ndarray (dtype='int')
number of trial (as in... | python | {
"resource": ""
} |
q239988 | Data._copy | train | def _copy(self, axis=True, attr=True, data=False):
"""Create a new instance of Data, but does not copy the data
necessarily.
Parameters
----------
axis : bool, optional
deep copy the axes (default: True)
attr : bool, optional
deep copy the attribu... | python | {
"resource": ""
} |
q239989 | Data.export | train | def export(self, filename, export_format='FieldTrip', **options):
"""Export data in other formats.
Parameters
----------
filename : path to file
file to write
export_format : str, optional
supported export format is currently FieldTrip, EDF, FIFF, Wonambi... | python | {
"resource": ""
} |
q239990 | ChannelsGroup.highlight_channels | train | def highlight_channels(self, l, selected_chan):
"""Highlight channels in the list of channels.
Parameters
----------
selected_chan : list of str
channels to indicate as selected.
"""
for row in range(l.count()):
item = l.item(row)
if i... | python | {
"resource": ""
} |
q239991 | ChannelsGroup.rereference | train | def rereference(self):
"""Automatically highlight channels to use as reference, based on
selected channels."""
selectedItems = self.idx_l0.selectedItems()
chan_to_plot = []
for selected in selectedItems:
chan_to_plot.append(selected.text())
self.highlight_cha... | python | {
"resource": ""
} |
q239992 | ChannelsGroup.get_info | train | def get_info(self):
"""Get the information about the channel groups.
Returns
-------
dict
information about this channel group
Notes
-----
The items in selectedItems() are ordered based on the user's selection
(which appears pretty random). I... | python | {
"resource": ""
} |
q239993 | Channels.create | train | def create(self):
"""Create Channels Widget"""
add_button = QPushButton('New')
add_button.clicked.connect(self.new_group)
color_button = QPushButton('Color')
color_button.clicked.connect(self.color_group)
del_button = QPushButton('Delete')
del_button.clicked.conne... | python | {
"resource": ""
} |
q239994 | Channels.create_action | train | def create_action(self):
"""Create actions related to channel selection."""
actions = {}
act = QAction('Load Montage...', self)
act.triggered.connect(self.load_channels)
act.setEnabled(False)
actions['load_channels'] = act
act = QAction('Save Montage...', self)
... | python | {
"resource": ""
} |
q239995 | Channels.new_group | train | def new_group(self, checked=False, test_name=None):
"""Create a new channel group.
Parameters
----------
checked : bool
comes from QAbstractButton.clicked
test_name : str
used for testing purposes to avoid modal window
Notes
-----
... | python | {
"resource": ""
} |
q239996 | Channels.color_group | train | def color_group(self, checked=False, test_color=None):
"""Change the color of the group."""
group = self.tabs.currentWidget()
if test_color is None:
newcolor = QColorDialog.getColor(group.idx_color)
else:
newcolor = test_color
group.idx_color = newcolor
... | python | {
"resource": ""
} |
q239997 | Channels.del_group | train | def del_group(self):
"""Delete current group."""
idx = self.tabs.currentIndex()
self.tabs.removeTab(idx)
self.apply() | python | {
"resource": ""
} |
q239998 | Channels.apply | train | def apply(self):
"""Apply changes to the plots."""
self.read_group_info()
if self.tabs.count() == 0:
# disactivate buttons
self.button_color.setEnabled(False)
self.button_del.setEnabled(False)
self.button_apply.setEnabled(False)
else:
... | python | {
"resource": ""
} |
q239999 | Channels.read_group_info | train | def read_group_info(self):
"""Get information about groups directly from the widget."""
self.groups = []
for i in range(self.tabs.count()):
one_group = self.tabs.widget(i).get_info()
# one_group['name'] = self.tabs.tabText(i)
self.groups.append(one_group) | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.