_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 31 13.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q249100 | FitnessFunctions.schwefelmult | train | def schwefelmult(self, x, pen_fac=1e4):
"""multimodal Schwefel function with domain -500..500"""
y = [x] if isscalar(x[0]) else x
N = len(y[0])
f = array([418.9829 * N - 1.27275661e-5 * N - sum(x * np.sin(np.abs(x)**0.5))
| python | {
"resource": ""
} |
q249101 | FitnessFunctions.lincon | train | def lincon(self, x, theta=0.01):
"""ridge like linear function with one linear constraint"""
if x[0] < 0:
| python | {
"resource": ""
} |
q249102 | FitnessFunctions.rosen_nesterov | train | def rosen_nesterov(self, x, rho=100):
"""needs exponential number of steps in a non-increasing f-sequence.
x_0 = (-1,1,...,1)
See Jarre (2011) "On Nesterov's Smooth Chebyshev-Rosenbrock Function"
| python | {
"resource": ""
} |
q249103 | FitnessFunctions.bukin | train | def bukin(self, x):
"""Bukin function from Wikipedia, generalized simplistically from 2-D.
http://en.wikipedia.org/wiki/Test_functions_for_optimization"""
s = 0
for k in xrange((1+len(x)) // 2):
| python | {
"resource": ""
} |
q249104 | DMPs.check_offset | train | def check_offset(self):
"""Check to see if initial position and goal are the same
if they are, offset slightly so that the forcing term is not 0"""
| python | {
"resource": ""
} |
q249105 | DMPs.rollout | train | def rollout(self, timesteps=None, **kwargs):
"""Generate a system trial, no feedback is incorporated."""
self.reset_state()
if timesteps is None:
if kwargs.has_key('tau'):
timesteps = int(self.timesteps / kwargs['tau'])
else:
timesteps =... | python | {
"resource": ""
} |
q249106 | DMPs.reset_state | train | def reset_state(self):
"""Reset the system state"""
self.y = self.y0.copy()
self.dy = np.zeros(self.dmps)
| python | {
"resource": ""
} |
q249107 | DMPs.step | train | def step(self, tau=1.0, state_fb=None):
"""Run the DMP system for a single timestep.
tau float: scales the timestep
increase tau to make the system execute faster
state_fb np.array: optional system feedback
"""
# run canonical system
cs_args = {'tau':tau... | python | {
"resource": ""
} |
q249108 | step | train | def step(weights, duration):
""" This function creates a sum of boxcar functions.
:param numpy.array weight: height of each boxcar function.
:param float duration: duration of the generated trajectory.
"""
dt = duration / len(weights)
def activate(t, dt):
"""This function returns 1 if... | python | {
"resource": ""
} |
q249109 | cartesian | train | def cartesian(n, states):
""" This function computes cartesians coordinates from the states returned by the simulate function.
:param int n: number of particules suspended to the top one
:param numpy.array states: list of the positions and speeds at a certain time.
"""
length = 1. / n # arm_length... | python | {
"resource": ""
} |
q249110 | SwaggerRoute.build_swagger_data | train | def build_swagger_data(self, loader):
""" Prepare data when schema loaded
:param swagger_schema: loaded schema
"""
if self.is_built:
return
self.is_built = True
self._required = []
self._parameters = {}
if not self._swagger_data:
r... | python | {
"resource": ""
} |
q249111 | SwaggerRoute.validate | train | async def validate(self, request: web.Request):
""" Returns parameters extract from request and multidict errors
:param request: Request
:return: tuple of parameters and errors
"""
parameters = {}
files = {}
errors = self.errors_factory()
body = None
... | python | {
"resource": ""
} |
q249112 | SwaggerRouter.include | train | def include(self, spec, *,
basePath=None,
operationId_mapping=None,
name=None):
""" Adds a new specification to a router
:param spec: path to specification
:param basePath: override base path specify in specification
:param operationId_map... | python | {
"resource": ""
} |
q249113 | SwaggerRouter.setup | train | def setup(self, app: web.Application):
""" Installation routes to app.router
:param app: instance of aiohttp.web.Application
"""
if self.app is app:
raise ValueError('The router is already configured '
'for this application')
self.app = a... | python | {
"resource": ""
} |
q249114 | template | train | def template(template_name, *, app_key=APP_KEY, encoding='utf-8', status=200):
"""
Decorator compatible with aiohttp_apiset router
"""
def wrapper(func):
@functools.wraps(func)
async def wrapped(*args, **kwargs):
if asyncio.iscoroutinefunction(func):
coro = f... | python | {
"resource": ""
} |
q249115 | get_collection | train | def get_collection(source, name, collection_format, default):
"""get collection named `name` from the given `source` that
formatted accordingly to `collection_format`.
"""
if collection_format in COLLECTION_SEP:
separator = COLLECTION_SEP[collection_format]
value = source.get(name, None)... | python | {
"resource": ""
} |
q249116 | CompatRouter.add_get | train | def add_get(self, *args, **kwargs):
"""
Shortcut for add_route with method GET
"""
| python | {
"resource": ""
} |
q249117 | OperationIdMapping.add | train | def add(self, *args, **kwargs):
""" Add new mapping from args and kwargs
>>> om = OperationIdMapping()
>>> om.add(
... OperationIdMapping(),
... 'aiohttp_apiset.swagger.operations', # any module
... getPets='mymod.handler',
... getPet='mymod.get_... | python | {
"resource": ""
} |
q249118 | str_repr | train | def str_repr(klass):
"""
Implements string conversion methods for the given class.
The given class must implement the __str__ method. This decorat
will add __repr__ and __unicode__ (for Python 2).
"""
if PY2:
klass.__unicode__ = klass.__str__
| python | {
"resource": ""
} |
q249119 | _clean_slice | train | def _clean_slice(key, length):
"""
Validates and normalizes a cell range slice.
>>> _clean_slice(slice(None, None), 10)
(0, 10)
>>> _clean_slice(slice(-10, 10), 10)
(0, 10)
>>> _clean_slice(slice(-11, 11), 10)
(0, 10)
>>> _clean_slice(slice('x', 'y'), 10)
Traceback (most recent ... | python | {
"resource": ""
} |
q249120 | _clean_index | train | def _clean_index(key, length):
"""
Validates and normalizes a cell range index.
>>> _clean_index(0, 10)
0
>>> _clean_index(-10, 10)
0
>>> _clean_index(10, 10)
Traceback (most recent call last):
...
IndexError: Cell index out of range.
>>> _clean_index(-11, 10)
Traceback ... | python | {
"resource": ""
} |
q249121 | _col_name | train | def _col_name(index):
"""
Converts a column index to a column name.
>>> _col_name(0)
'A'
>>> _col_name(26)
'AA'
"""
for exp in itertools.count(1):
limit = 26 ** exp
if index < limit:
| python | {
"resource": ""
} |
q249122 | Axis.__set_title | train | def __set_title(self, value):
"""
Sets title of this axis.
"""
# OpenOffice on Debian "squeeze" ignore value of target.XAxis.String
# unless target.HasXAxisTitle is set to True first. (Despite the
# fact that target.HasXAxisTitle is reported to be False until
# ta... | python | {
"resource": ""
} |
q249123 | Chart.ranges | train | def ranges(self):
"""
Returns a list of addresses with source data.
"""
| python | {
"resource": ""
} |
q249124 | Chart.diagram | train | def diagram(self):
"""
Diagram - inner content of this chart.
The diagram can be replaced by another type using change_type method. | python | {
"resource": ""
} |
q249125 | Chart.change_type | train | def change_type(self, cls):
"""
Change type of diagram in this chart.
Accepts one of classes which extend Diagram.
| python | {
"resource": ""
} |
q249126 | ChartCollection.create | train | def create(self, name, position, ranges=(), col_header=False, row_header=False):
"""
Creates and inserts a new chart.
"""
rect | python | {
"resource": ""
} |
q249127 | SheetCursor.get_target | train | def get_target(self, row, col, row_count, col_count):
"""
Moves cursor to the specified position and returns in.
"""
# This method is called for almost any operation so it should
# be maximally optimized.
#
# Any comparison here is negligible compared to UNO call.... | python | {
"resource": ""
} |
q249128 | Cell.__set_value | train | def __set_value(self, value):
"""
Sets cell value to a string or number based on the given value.
"""
| python | {
"resource": ""
} |
q249129 | Cell.__set_formula | train | def __set_formula(self, formula):
"""
Sets a formula in this cell.
Any cell value can be set using this method. Actual | python | {
"resource": ""
} |
q249130 | TabularCellRange.__set_values | train | def __set_values(self, values):
"""
Sets values in this cell range from an iterable of iterables.
"""
# Tuple of tuples is required | python | {
"resource": ""
} |
q249131 | TabularCellRange.__set_formulas | train | def __set_formulas(self, formulas):
"""
Sets formulas in this cell range from an iterable of iterables.
Any cell values can be set using this method. Actual formulas must
start with an equal sign.
"""
# Tuple of | python | {
"resource": ""
} |
q249132 | VerticalCellRange.__get_values | train | def __get_values(self):
"""
Gets values in this cell range as a tuple.
This is much more effective than reading cell values one by one.
"""
| python | {
"resource": ""
} |
q249133 | VerticalCellRange.__set_values | train | def __set_values(self, values):
"""
Sets values in this cell range from an iterable.
This is much more effective than writing cell values one by one.
""" | python | {
"resource": ""
} |
q249134 | VerticalCellRange.__get_formulas | train | def __get_formulas(self):
"""
Gets formulas in this cell range as a tuple.
If cells contain actual formulas then the returned values start
with an equal sign but all values are returned.
"""
| python | {
"resource": ""
} |
q249135 | VerticalCellRange.__set_formulas | train | def __set_formulas(self, formulas):
"""
Sets formulas in this cell range from an iterable.
Any cell values can be set using this method. Actual formulas must
start with an equal sign.
"""
| python | {
"resource": ""
} |
q249136 | SpreadsheetCollection.create | train | def create(self, name, index=None):
"""
Creates a new sheet with the given name.
If an optional index argument is not provided then the created
sheet is appended at the end. Returns the new sheet.
"""
| python | {
"resource": ""
} |
q249137 | SpreadsheetCollection.copy | train | def copy(self, old_name, new_name, index=None):
"""
Copies an old sheet with the old_name to a new sheet with new_name.
If an optional index argument is not provided then the created
sheet is appended at the end. Returns the new sheet.
"""
| python | {
"resource": ""
} |
q249138 | SpreadsheetDocument.save | train | def save(self, path=None, filter_name=None):
"""
Saves this document to a local file system.
The optional first argument defaults to the document's path.
Accept optional second argument which defines type of
the saved file. Use one of FILTER_* constants or see list of
... | python | {
"resource": ""
} |
q249139 | SpreadsheetDocument.get_locale | train | def get_locale(self, language=None, country=None, variant=None):
"""
Returns locale which can be used for access to number formats.
"""
# http://www.openoffice.org/api/docs/common/ref/com/sun/star/lang/Locale.html
locale = uno.createUnoStruct('com.sun.star.lang.Locale')
i... | python | {
"resource": ""
} |
q249140 | SpreadsheetDocument.sheets | train | def sheets(self):
"""
Collection of sheets in this document.
"""
# http://www.openoffice.org/api/docs/common/ref/com/sun/star/sheet/XSpreadsheetDocument.html#getSheets
try:
return self._sheets
except AttributeError:
| python | {
"resource": ""
} |
q249141 | SpreadsheetDocument.date_from_number | train | def date_from_number(self, value):
"""
Converts a float value to corresponding datetime instance.
"""
if not isinstance(value, numbers.Real):
return None
| python | {
"resource": ""
} |
q249142 | SpreadsheetDocument.date_to_number | train | def date_to_number(self, date):
"""
Converts a date or datetime instance to a corresponding float value.
"""
if isinstance(date, datetime.datetime):
delta = date - self._null_date
elif isinstance(date, datetime.date):
| python | {
"resource": ""
} |
q249143 | SpreadsheetDocument.time_from_number | train | def time_from_number(self, value):
"""
Converts a float value to corresponding time instance.
"""
if not isinstance(value, numbers.Real):
return None
delta = datetime.timedelta(days=value)
minutes, second | python | {
"resource": ""
} |
q249144 | SpreadsheetDocument.time_to_number | train | def time_to_number(self, time):
"""
Converts a time instance to a corresponding float value.
"""
if not isinstance(time, datetime.time):
| python | {
"resource": ""
} |
q249145 | SpreadsheetDocument._null_date | train | def _null_date(self):
"""
Returns date which is represented by a integer 0.
"""
# http://www.openoffice.org/api/docs/common/ref/com/sun/star/util/NumberFormatSettings.html#NullDate
try:
return self.__null_date
except AttributeError:
| python | {
"resource": ""
} |
q249146 | LazyDesktop.create_spreadsheet | train | def create_spreadsheet(self):
"""
Creates a new spreadsheet document.
"""
desktop | python | {
"resource": ""
} |
q249147 | PlotTim.vcontoursf1D | train | def vcontoursf1D(self, x1, x2, nx, levels, labels=False, decimals=0, color=None,
nudge=1e-6, newfig=True, figsize=None, layout=True, ax=None):
"""
Vertical contour for 1D model
"""
naq = self.aq.naq
xflow = np.linspace(x1 + nudge, x2 - nudge, nx)
Qx ... | python | {
"resource": ""
} |
q249148 | LineSink1DBase.discharge | train | def discharge(self):
"""Discharge per unit length"""
| python | {
"resource": ""
} |
q249149 | LineSinkStringBase2.discharge | train | def discharge(self):
"""Discharge of the element in each layer
"""
rv = np.zeros(self.aq[0].naq)
Qls = self.parameters[:, 0] * self.dischargeinf()
Qls.shape = (self.nls, self.nlayers, self.order + 1)
Qls = np.sum(Qls, 2)
for | python | {
"resource": ""
} |
q249150 | AquiferData.findlayer | train | def findlayer(self, z):
'''
Returns layer-number, layer-type and model-layer-number'''
if z > self.z[0]:
modellayer, ltype = -1, 'above'
layernumber = None
elif z < self.z[-1]:
modellayer, ltype = len(self.layernumber), 'below'
layernumber ... | python | {
"resource": ""
} |
q249151 | Model.remove_element | train | def remove_element(self, e):
"""Remove element `e` from model
"""
| python | {
"resource": ""
} |
q249152 | read_plink | train | def read_plink(file_prefix, verbose=True):
r"""Read PLINK files into Pandas data frames.
Parameters
----------
file_prefix : str
Path prefix to the set of PLINK files. It supports loading many BED
files at once using globstrings wildcard.
verbose : bool
``True`` for progress... | python | {
"resource": ""
} |
q249153 | read_files | train | def read_files(*files):
"""Read files into setup"""
text = ""
for single_file in files:
| python | {
"resource": ""
} |
q249154 | read | train | def read(afile):
"""Read a file into setup"""
the_relative_file = os.path.join(HERE, afile)
with codecs.open(the_relative_file, 'r', 'utf-8') as opened_file:
| python | {
"resource": ""
} |
q249155 | main | train | def main():
"""
program entry point
"""
parser = create_parser()
options = vars(parser.parse_args())
HASH_STORE.IGNORE_CACHE_FILE = options[constants.LABEL_FORCE]
moban_file = options[constants.LABEL_MOBANFILE]
load_engine_factory_and_engines() # Error: jinja2 if removed
if moban_fi... | python | {
"resource": ""
} |
q249156 | create_parser | train | def create_parser():
"""
construct the program options
"""
parser = argparse.ArgumentParser(
prog=constants.PROGRAM_NAME, description=constants.PROGRAM_DESCRIPTION
)
parser.add_argument(
"-cd",
"--%s" % constants.LABEL_CONFIG_DIR,
help="the directory for configura... | python | {
"resource": ""
} |
q249157 | handle_moban_file | train | def handle_moban_file(moban_file, options):
"""
act upon default moban file
"""
moban_file_configurations = load_data(None, moban_file)
if moban_file_configurations is None:
raise exceptions.MobanfileGrammarException(
constants.ERROR_INVALID_MOBAN_FILE % moban_file
)
... | python | {
"resource": ""
} |
q249158 | handle_command_line | train | def handle_command_line(options):
"""
act upon command options
"""
options = merge(options, constants.DEFAULT_OPTIONS)
engine = plugins.ENGINES.get_engine(
options[constants.LABEL_TEMPLATE_TYPE],
options[constants.LABEL_TMPL_DIRS],
options[constants.LABEL_CONFIG_DIR],
)
... | python | {
"resource": ""
} |
q249159 | by_symbol | train | def by_symbol(symbol, country_code=None):
"""Get list of possible currencies for symbol; filter by country_code
Look for all currencies that use the `symbol`. If there are currencies used
in the country of `country_code`, return only those; otherwise return all
found currencies.
Parameters:
... | python | {
"resource": ""
} |
q249160 | parse | train | def parse(v, country_code=None):
"""Try parse `v` to currencies; filter by country_code
If `v` is a number, try `by_code_num()`; otherwise try:
1) if `v` is 3 character uppercase: `by_alpha3()`
2) Exact symbol match: `by_symbol()`
3) Exact country code match: `by_country()`
4) F... | python | {
"resource": ""
} |
q249161 | open_json | train | def open_json(file_name):
"""
returns json contents as string
| python | {
"resource": ""
} |
q249162 | merge | train | def merge(left, right):
"""
deep merge dictionary on the left with the one
on the right.
Fill in left dictionary with right one where
the value of the key from the right one in
the left one is missing or None.
| python | {
"resource": ""
} |
q249163 | ZmqFactory.shutdown | train | def shutdown(self):
"""
Shutdown factory.
This is shutting down all created connections
and terminating ZeroMQ context. Also cleans up
Twisted reactor.
"""
for connection in self.connections.copy():
connection.shutdown()
self.connections = No... | python | {
"resource": ""
} |
q249164 | ZmqPubConnection.publish | train | def publish(self, message, tag=b''):
"""
Publish `message` with specified `tag`.
:param message: message data
:type message: str
| python | {
"resource": ""
} |
q249165 | ZmqREQConnection._getNextId | train | def _getNextId(self):
"""
Returns an unique id.
By default, generates pool of UUID in increments
of ``UUID_POOL_GEN_SIZE``. Could be overridden to
provide custom ID generation.
:return: generated unique "on the wire" message ID
:rtype: str
| python | {
"resource": ""
} |
q249166 | ZmqREQConnection._releaseId | train | def _releaseId(self, msgId):
"""
Release message ID to the pool.
@param msgId: message ID, no longer on the wire
@type msgId: C{str}
"""
self._uuids.append(msgId)
| python | {
"resource": ""
} |
q249167 | ZmqREQConnection._cancel | train | def _cancel(self, msgId):
"""
Cancel outstanding REQ, drop reply silently.
@param msgId: message ID to cancel
| python | {
"resource": ""
} |
q249168 | ZmqREQConnection._timeoutRequest | train | def _timeoutRequest(self, msgId):
"""
Cancel timedout request.
@param msgId: message ID to cancel
| python | {
"resource": ""
} |
q249169 | ZmqREQConnection.sendMsg | train | def sendMsg(self, *messageParts, **kwargs):
"""
Send request and deliver response back when available.
:param messageParts: message data
:type messageParts: tuple
:param timeout: as keyword argument, timeout on request
:type timeout: float
:return: Deferred that ... | python | {
"resource": ""
} |
q249170 | ZmqREPConnection.reply | train | def reply(self, messageId, *messageParts):
"""
Send reply to request with specified ``messageId``.
:param messageId: message uuid
:type messageId: str
:param messageParts: message data
:type messageParts: list
| python | {
"resource": ""
} |
q249171 | CorpusReader.load | train | def load(self, path):
"""
Load and return the corpus from the given path.
Args:
path (str): Path to the data set to load.
Returns:
Corpus: The loaded corpus
Raises:
IOError: When the data set is invalid, for example because required files (a... | python | {
"resource": ""
} |
q249172 | TudaReader.get_ids_from_folder | train | def get_ids_from_folder(path, part_name):
"""
Return all ids from the given folder, which have a corresponding beamformedSignal file.
"""
valid_ids = set({})
for xml_file in glob.glob(os.path.join(path, '*.xml')):
| python | {
"resource": ""
} |
q249173 | TudaReader.load_file | train | def load_file(folder_path, idx, corpus):
"""
Load speaker, file, utterance, labels for the file with the given id.
"""
xml_path = os.path.join(folder_path, '{}.xml'.format(idx))
wav_paths = glob.glob(os.path.join(folder_path, '{}_*.wav'.format(idx)))
if len(wav_paths) ==... | python | {
"resource": ""
} |
q249174 | read_file | train | def read_file(path):
"""
Reads a ctm file.
Args:
path (str): Path to the file
Returns:
(dict): Dictionary with entries.
Example::
>>> read_file('/path/to/file.txt')
{
'wave-ab': [
['1', 0.00, 0.07, 'HI', 1],
['1', 0.09, ... | python | {
"resource": ""
} |
q249175 | split_identifiers | train | def split_identifiers(identifiers=[], proportions={}):
"""
Split the given identifiers by the given proportions.
Args:
identifiers (list): List of identifiers (str).
proportions (dict): A dictionary containing the proportions with the identifier from the
input as key.
Returns:
... | python | {
"resource": ""
} |
q249176 | select_balanced_subset | train | def select_balanced_subset(items, select_count, categories, select_count_values=None, seed=None):
"""
Select items so the summed category weights are balanced.
Each item has a dictionary containing the category weights.
Items are selected until ``select_count`` is reached.
The value that is added to... | python | {
"resource": ""
} |
q249177 | length_of_overlap | train | def length_of_overlap(first_start, first_end, second_start, second_end):
"""
Find the length of the overlapping part of two segments.
Args:
first_start (float): Start of the first segment.
first_end (float): End of the first segment.
second_start (float): Start of the second segment... | python | {
"resource": ""
} |
q249178 | find_missing_projections | train | def find_missing_projections(label_list, projections):
"""
Finds all combinations of labels in `label_list` that are not covered by an entry in the dictionary of
`projections`. Returns a list containing tuples of uncovered label combinations or en empty list if there are none.
All uncovered label combin... | python | {
"resource": ""
} |
q249179 | load_projections | train | def load_projections(projections_file):
"""
Loads projections defined in the given `projections_file`.
The `projections_file` is expected to be in the following format::
old_label_1 | new_label_1
old_label_1 old_label_2 | new_label_2
old_label_3 |
You can define one projection... | python | {
"resource": ""
} |
q249180 | SubsetGenerator.random_subset_by_duration | train | def random_subset_by_duration(self, relative_duration, balance_labels=False, label_list_ids=None):
"""
Create a subview of random utterances with a approximate duration relative to the full corpus.
Random utterances are selected so that the sum of all utterance durations
equals to the re... | python | {
"resource": ""
} |
q249181 | SubsetGenerator.random_subsets | train | def random_subsets(self, relative_sizes, by_duration=False, balance_labels=False, label_list_ids=None):
"""
Create a bunch of subsets with the given sizes relative to the size or duration of the full corpus.
Basically the same as calling ``random_subset`` or ``random_subset_by_duration`` multipl... | python | {
"resource": ""
} |
q249182 | remove_punctuation | train | def remove_punctuation(text, exceptions=[]):
"""
Return a string with punctuation removed.
Parameters:
text (str): The text to remove punctuation from.
exceptions (list): List of symbols to keep in the given text.
Return:
str: The input text without the punctuation.
"""
| python | {
"resource": ""
} |
q249183 | starts_with_prefix_in_list | train | def starts_with_prefix_in_list(text, prefixes):
"""
Return True if the given string starts with one of the prefixes in the given list, otherwise
return False.
Arguments:
text (str): Text to check for prefixes.
prefixes (list): List of prefixes to check for.
Returns:
bool: | python | {
"resource": ""
} |
q249184 | TatoebaDownloader._load_audio_list | train | def _load_audio_list(self, path):
"""
Load and filter the audio list.
Args:
path (str): Path to the audio list file.
Returns:
dict: Dictionary of filtered sentences (id : username, license, attribution-url)
"""
result = {}
for entry in ... | python | {
"resource": ""
} |
q249185 | TatoebaDownloader._load_sentence_list | train | def _load_sentence_list(self, path):
"""
Load and filter the sentence list.
Args:
path (str): Path to the sentence list.
Returns:
dict: Dictionary of sentences (id : language, transcription)
"""
result = {}
for entry | python | {
"resource": ""
} |
q249186 | TatoebaDownloader._download_audio_files | train | def _download_audio_files(self, records, target_path):
"""
Download all audio files based on the given records.
"""
for record in records:
audio_folder = os.path.join(target_path, 'audio', record[2]) | python | {
"resource": ""
} |
q249187 | Splitter.split_by_proportionally_distribute_labels | train | def split_by_proportionally_distribute_labels(self, proportions={}, use_lengths=True):
"""
Split the corpus into subsets, so the occurrence of the labels is distributed amongst the
subsets according to the given proportions.
Args:
proportions (dict): A dictionary containing ... | python | {
"resource": ""
} |
q249188 | Splitter._subviews_from_utterance_splits | train | def _subviews_from_utterance_splits(self, splits):
"""
Create subviews from a dict containing utterance-ids for each subview.
e.g. {'train': ['utt-1', 'utt-2'], 'test': [...], ...}
"""
subviews = {}
for idx, subview_utterances in splits.items():
| python | {
"resource": ""
} |
q249189 | ContainerTrack.sampling_rate | train | def sampling_rate(self):
"""
Return the sampling rate.
| python | {
"resource": ""
} |
q249190 | ContainerTrack.duration | train | def duration(self):
"""
Return the duration in seconds.
"""
with self.container.open_if_needed(mode='r') | python | {
"resource": ""
} |
q249191 | ContainerTrack.read_samples | train | def read_samples(self, sr=None, offset=0, duration=None):
"""
Return the samples from the track in the container.
Uses librosa for resampling, if needed.
Args:
sr (int): If ``None``, uses the sampling rate given by the file,
otherwise resamples to the g... | python | {
"resource": ""
} |
q249192 | write_json_to_file | train | def write_json_to_file(path, data):
"""
Writes data as json to file.
Parameters:
path (str): Path to write to
data | python | {
"resource": ""
} |
q249193 | read_json_file | train | def read_json_file(path):
"""
Reads and return the data from the json file at the given path.
Parameters:
path (str): Path to read
Returns:
| python | {
"resource": ""
} |
q249194 | LabelList.add | train | def add(self, label):
"""
Add a label to the end of the list.
Args:
| python | {
"resource": ""
} |
q249195 | LabelList.merge_overlaps | train | def merge_overlaps(self, threshold=0.0):
"""
Merge overlapping labels with the same value.
Two labels are considered overlapping,
if ``l2.start - l1.end < threshold``.
Args:
threshold (float): Maximal distance between two labels
to be c... | python | {
"resource": ""
} |
q249196 | LabelList.label_total_duration | train | def label_total_duration(self):
"""
Return for each distinct label value the total duration of all occurrences.
Returns:
dict: A dictionary containing for every label-value (key)
the total duration in seconds (value).
Example:
>>> ll = LabelLis... | python | {
"resource": ""
} |
q249197 | LabelList.label_values | train | def label_values(self):
"""
Return a list of all occuring label values.
Returns:
list: Lexicographically sorted list (str) of label values.
Example:
>>> ll = LabelList(labels=[
>>> Label('a', 3.2, 4.5),
>>> Label('b', 5.1, 8.9),
... | python | {
"resource": ""
} |
q249198 | LabelList.label_count | train | def label_count(self):
"""
Return for each label the number of occurrences within the list.
Returns:
dict: A dictionary containing for every label-value (key)
the number of occurrences (value).
Example:
>>> ll = LabelList(labels=[
>>> ... | python | {
"resource": ""
} |
q249199 | LabelList.all_tokens | train | def all_tokens(self, delimiter=' '):
"""
Return a list of all tokens occurring in the label-list.
Args:
delimiter (str): The delimiter used to split labels into tokens
| python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.