Code stringlengths 103 85.9k | Summary listlengths 0 94 |
|---|---|
Please provide a description of the function:def get_shares(self, path='', **kwargs):
if not (isinstance(path, six.string_types)):
return None
data = 'shares'
if path != '':
data += '?'
path = self._encode_string(self._normalize_path(path))
... | [
"Returns array of shares\n\n :param path: path to the share to be checked\n :param reshares: (optional, boolean) returns not only the shares from\n the current user but all shares from the given file (default: False)\n :param subfiles: (optional, boolean) returns all shares within\n ... |
Please provide a description of the function:def create_user(self, user_name, initial_password):
res = self._make_ocs_request(
'POST',
self.OCS_SERVICE_CLOUD,
'users',
data={'password': initial_password, 'userid': user_name}
)
# We get 20... | [
"Create a new user with an initial password via provisioning API.\n It is not an error, if the user already existed before.\n If you get back an error 999, then the provisioning API is not enabled.\n\n :param user_name: name of user to be created\n :param initial_password: password for... |
Please provide a description of the function:def delete_user(self, user_name):
res = self._make_ocs_request(
'DELETE',
self.OCS_SERVICE_CLOUD,
'users/' + user_name
)
# We get 200 when the user was deleted.
if res.status_code == 200:
... | [
"Deletes a user via provisioning API.\n If you get back an error 999, then the provisioning API is not enabled.\n\n :param user_name: name of user to be deleted\n :returns: True on success\n :raises: HTTPResponseError in case an HTTP error status was returned\n\n "
] |
Please provide a description of the function:def search_users(self, user_name):
action_path = 'users'
if user_name:
action_path += '?search={}'.format(user_name)
res = self._make_ocs_request(
'GET',
self.OCS_SERVICE_CLOUD,
action_path
... | [
"Searches for users via provisioning API.\n If you get back an error 999, then the provisioning API is not enabled.\n\n :param user_name: name of user to be searched for\n :returns: list of usernames that contain user_name as substring\n :raises: HTTPResponseError in case an HTTP error ... |
Please provide a description of the function:def set_user_attribute(self, user_name, key, value):
res = self._make_ocs_request(
'PUT',
self.OCS_SERVICE_CLOUD,
'users/' + parse.quote(user_name),
data={'key': self._encode_string(key),
'va... | [
"Sets a user attribute\n\n :param user_name: name of user to modify\n :param key: key of the attribute to set\n :param value: value to set\n :returns: True if the operation succeeded, False otherwise\n :raises: HTTPResponseError in case an HTTP error status was returned\n "... |
Please provide a description of the function:def add_user_to_group(self, user_name, group_name):
res = self._make_ocs_request(
'POST',
self.OCS_SERVICE_CLOUD,
'users/' + user_name + '/groups',
data={'groupid': group_name}
)
if res.status... | [
"Adds a user to a group.\n\n :param user_name: name of user to be added\n :param group_name: name of group user is to be added to\n :returns: True if user added\n :raises: HTTPResponseError in case an HTTP error status was returned\n\n "
] |
Please provide a description of the function:def get_user_groups(self, user_name):
res = self._make_ocs_request(
'GET',
self.OCS_SERVICE_CLOUD,
'users/' + user_name + '/groups',
)
if res.status_code == 200:
tree = ET.fromstring(res.conte... | [
"Get a list of groups associated to a user.\n\n :param user_name: name of user to list groups\n :returns: list of groups\n :raises: HTTPResponseError in case an HTTP error status was returned\n\n "
] |
Please provide a description of the function:def get_user(self, user_name):
res = self._make_ocs_request(
'GET',
self.OCS_SERVICE_CLOUD,
'users/' + parse.quote(user_name),
data={}
)
tree = ET.fromstring(res.content)
self._check_oc... | [
"Retrieves information about a user\n\n :param user_name: name of user to query\n\n :returns: Dictionary of information about user\n :raises: ResponseError in case an HTTP error status was returned\n "
] |
Please provide a description of the function:def get_user_subadmin_groups(self, user_name):
res = self._make_ocs_request(
'GET',
self.OCS_SERVICE_CLOUD,
'users/' + user_name + '/subadmins',
)
if res.status_code == 200:
tree = ET.fromstri... | [
"Get a list of subadmin groups associated to a user.\n\n :param user_name: name of user\n :returns: list of subadmin groups\n :raises: HTTPResponseError in case an HTTP error status was returned\n\n "
] |
Please provide a description of the function:def share_file_with_user(self, path, user, **kwargs):
remote_user = kwargs.get('remote_user', False)
perms = kwargs.get('perms', self.OCS_PERMISSION_READ)
if (((not isinstance(perms, int)) or (perms > self.OCS_PERMISSION_ALL))
... | [
"Shares a remote file with specified user\n\n :param path: path to the remote file to share\n :param user: name of the user whom we want to share a file/folder\n :param perms (optional): permissions of the shared object\n defaults to read only (1)\n http://doc.owncloud.org... |
Please provide a description of the function:def delete_group(self, group_name):
res = self._make_ocs_request(
'DELETE',
self.OCS_SERVICE_CLOUD,
'groups/' + group_name
)
# We get 200 when the group was just deleted.
if res.status_code == 200:... | [
"Delete a group via provisioning API.\n If you get back an error 999, then the provisioning API is not enabled.\n\n :param group_name: name of group to be deleted\n :returns: True if group deleted\n :raises: HTTPResponseError in case an HTTP error status was returned\n\n "
] |
Please provide a description of the function:def get_groups(self):
res = self._make_ocs_request(
'GET',
self.OCS_SERVICE_CLOUD,
'groups'
)
if res.status_code == 200:
tree = ET.fromstring(res.content)
groups = [x.text for x in ... | [
"Get groups via provisioning API.\n If you get back an error 999, then the provisioning API is not enabled.\n\n :returns: list of groups\n :raises: HTTPResponseError in case an HTTP error status was returned\n\n "
] |
Please provide a description of the function:def get_group_members(self, group_name):
res = self._make_ocs_request(
'GET',
self.OCS_SERVICE_CLOUD,
'groups/' + group_name
)
if res.status_code == 200:
tree = ET.fromstring(res.content)
... | [
"Get group members via provisioning API.\n If you get back an error 999, then the provisioning API is not enabled.\n\n :param group_name: name of group to list members\n :returns: list of group members\n :raises: HTTPResponseError in case an HTTP error status was returned\n\n "
] |
Please provide a description of the function:def group_exists(self, group_name):
res = self._make_ocs_request(
'GET',
self.OCS_SERVICE_CLOUD,
'groups?search=' + group_name
)
if res.status_code == 200:
tree = ET.fromstring(res.content)
... | [
"Checks a group via provisioning API.\n If you get back an error 999, then the provisioning API is not enabled.\n\n :param group_name: name of group to be checked\n :returns: True if group exists\n :raises: HTTPResponseError in case an HTTP error status was returned\n\n "
] |
Please provide a description of the function:def share_file_with_group(self, path, group, **kwargs):
perms = kwargs.get('perms', self.OCS_PERMISSION_READ)
if (((not isinstance(perms, int)) or (perms > self.OCS_PERMISSION_ALL))
or ((not isinstance(group, six.string_types)) or (gr... | [
"Shares a remote file with specified group\n\n :param path: path to the remote file to share\n :param group: name of the group with which we want to share a file/folder\n :param perms (optional): permissions of the shared object\n defaults to read only (1)\n http://doc.own... |
Please provide a description of the function:def get_config(self):
path = 'config'
res = self._make_ocs_request(
'GET',
'',
path
)
if res.status_code == 200:
tree = ET.fromstring(res.content)
self._check_ocs_status(tree... | [
"Returns ownCloud config information\n :returns: array of tuples (key, value) for each information\n e.g. [('version', '1.7'), ('website', 'ownCloud'), ('host', 'cloud.example.com'),\n ('contact', ''), ('ssl', 'false')]\n :raises: HTTPResponseError in case an HTTP error status wa... |
Please provide a description of the function:def get_attribute(self, app=None, key=None):
path = 'getattribute'
if app is not None:
path += '/' + parse.quote(app, '')
if key is not None:
path += '/' + parse.quote(self._encode_string(key), '')
res ... | [
"Returns an application attribute\n\n :param app: application id\n :param key: attribute key or None to retrieve all values for the\n given application\n :returns: attribute value if key was specified, or an array of tuples\n (key, value) for each attribute\n :raise... |
Please provide a description of the function:def set_attribute(self, app, key, value):
path = 'setattribute/' + parse.quote(app, '') + '/' + parse.quote(
self._encode_string(key), '')
res = self._make_ocs_request(
'POST',
self.OCS_SERVICE_PRIVATEDATA,
... | [
"Sets an application attribute\n\n :param app: application id\n :param key: key of the attribute to set\n :param value: value to set\n :returns: True if the operation succeeded, False otherwise\n :raises: HTTPResponseError in case an HTTP error status was returned\n "
] |
Please provide a description of the function:def get_apps(self):
ena_apps = {}
res = self._make_ocs_request('GET', self.OCS_SERVICE_CLOUD, 'apps')
if res.status_code != 200:
raise HTTPResponseError(res)
tree = ET.fromstring(res.content)
self._check_ocs_statu... | [
" List all enabled apps through the provisioning api.\n\n :returns: a dict of apps, with values True/False, representing the enabled state.\n :raises: HTTPResponseError in case an HTTP error status was returned\n "
] |
Please provide a description of the function:def enable_app(self, appname):
res = self._make_ocs_request('POST', self.OCS_SERVICE_CLOUD,
'apps/' + appname)
if res.status_code == 200:
return True
raise HTTPResponseError(res) | [
"Enable an app through provisioning_api\n\n :param appname: Name of app to be enabled\n :returns: True if the operation succeeded, False otherwise\n :raises: HTTPResponseError in case an HTTP error status was returned\n\n "
] |
Please provide a description of the function:def _normalize_path(path):
if isinstance(path, FileInfo):
path = path.path
if len(path) == 0:
return '/'
if not path.startswith('/'):
path = '/' + path
return path | [
"Makes sure the path starts with a \"/\"\n "
] |
Please provide a description of the function:def _encode_string(s):
if six.PY2 and isinstance(s, unicode):
return s.encode('utf-8')
return s | [
"Encodes a unicode instance to utf-8. If a str is passed it will\n simply be returned\n\n :param s: str or unicode to encode\n :returns: encoded output as str\n "
] |
Please provide a description of the function:def _check_ocs_status(tree, accepted_codes=[100]):
code_el = tree.find('meta/statuscode')
if code_el is not None and int(code_el.text) not in accepted_codes:
r = requests.Response()
msg_el = tree.find('meta/message')
... | [
"Checks the status code of an OCS request\n\n :param tree: response parsed with elementtree\n :param accepted_codes: list of statuscodes we consider good. E.g. [100,102] can be used to accept a POST\n returning an 'already exists' condition\n :raises: HTTPResponseError if the http... |
Please provide a description of the function:def make_ocs_request(self, method, service, action, **kwargs):
accepted_codes = kwargs.pop('accepted_codes', [100])
res = self._make_ocs_request(method, service, action, **kwargs)
if res.status_code == 200:
tree = ET.fromstring(... | [
"Makes a OCS API request and analyses the response\n\n :param method: HTTP method\n :param service: service name\n :param action: action path\n :param \\*\\*kwargs: optional arguments that ``requests.Request.request`` accepts\n :returns :class:`requests.Response` instance\n ... |
Please provide a description of the function:def _make_ocs_request(self, method, service, action, **kwargs):
slash = ''
if service:
slash = '/'
path = self.OCS_BASEPATH + service + slash + action
attributes = kwargs.copy()
if 'headers' not in attributes:
... | [
"Makes a OCS API request\n\n :param method: HTTP method\n :param service: service name\n :param action: action path\n :param \\*\\*kwargs: optional arguments that ``requests.Request.request`` accepts\n :returns :class:`requests.Response` instance\n "
] |
Please provide a description of the function:def _make_dav_request(self, method, path, **kwargs):
if self._debug:
print('DAV request: %s %s' % (method, path))
if kwargs.get('headers'):
print('Headers: ', kwargs.get('headers'))
path = self._normalize_path... | [
"Makes a WebDAV request\n\n :param method: HTTP method\n :param path: remote path of the targetted file\n :param \\*\\*kwargs: optional arguments that ``requests.Request.request`` accepts\n :returns array of :class:`FileInfo` if the response\n contains it, or True if the operation... |
Please provide a description of the function:def _parse_dav_response(self, res):
if res.status_code == 207:
tree = ET.fromstring(res.content)
items = []
for child in tree:
items.append(self._parse_dav_element(child))
return items
r... | [
"Parses the DAV responses from a multi-status response\n\n :param res: DAV response\n :returns array of :class:`FileInfo` or False if\n the operation did not succeed\n "
] |
Please provide a description of the function:def _parse_dav_element(self, dav_response):
href = parse.unquote(
self._strip_dav_path(dav_response.find('{DAV:}href').text)
)
if six.PY2:
href = href.decode('utf-8')
file_type = 'file'
if href[-1] ==... | [
"Parses a single DAV element\n\n :param dav_response: DAV response\n :returns :class:`FileInfo`\n "
] |
Please provide a description of the function:def _strip_dav_path(self, path):
if path.startswith(self._davpath):
return path[len(self._davpath):]
return path | [
"Removes the leading \"remote.php/webdav\" path from the given path\n\n :param path: path containing the remote DAV path \"remote.php/webdav\"\n :returns: path stripped of the remote DAV path\n "
] |
Please provide a description of the function:def _webdav_move_copy(self, remote_path_source, remote_path_target,
operation):
if operation != "MOVE" and operation != "COPY":
return False
if remote_path_target[-1] == '/':
remote_path_target += ... | [
"Copies or moves a remote file or directory\n\n :param remote_path_source: source file or folder to copy / move\n :param remote_path_target: target file to which to copy / move\n :param operation: MOVE or COPY\n\n :returns: True if the operation succeeded, False otherwise\n :raise... |
Please provide a description of the function:def _xml_to_dict(self, element):
return_dict = {}
for el in element:
return_dict[el.tag] = None
children = el.getchildren()
if children:
return_dict[el.tag] = self._xml_to_dict(children)
... | [
"\n Take an XML element, iterate over it and build a dict\n\n :param element: An xml.etree.ElementTree.Element, or a list of the same\n :returns: A dictionary\n "
] |
Please provide a description of the function:def _get_shareinfo(self, data_el):
if (data_el is None) or not (isinstance(data_el, ET.Element)):
return None
return ShareInfo(self._xml_to_dict(data_el)) | [
"Simple helper which returns instance of ShareInfo class\n\n :param data_el: 'data' element extracted from _make_ocs_request\n :returns: instance of ShareInfo class\n "
] |
Please provide a description of the function:def emit(self, *args, **kwargs):
if self._block:
return
for slot in self._slots:
if not slot:
continue
elif isinstance(slot, partial):
slot()
elif isinstance(slot, weak... | [
"\n Calls all the connected slots with the provided args and kwargs unless block is activated\n "
] |
Please provide a description of the function:def connect(self, slot):
if not callable(slot):
raise ValueError("Connection to non-callable '%s' object failed" % slot.__class__.__name__)
if (isinstance(slot, partial) or '<' in slot.__name__):
# If it's a partial or a lamb... | [
"\n Connects the signal to any callable object\n "
] |
Please provide a description of the function:def disconnect(self, slot):
if not callable(slot):
return
if inspect.ismethod(slot):
# If it's a method, then find it by its instance
slotSelf = slot.__self__
for s in self._slots:
if i... | [
"\n Disconnects the slot from the signal\n "
] |
Please provide a description of the function:def register(self, name, *slots):
# setdefault initializes the object even if it exists. This is more efficient
if name not in self:
self[name] = Signal()
for slot in slots:
self[name].connect(slot) | [
"\n Registers a given signal\n :param name: the signal to register\n "
] |
Please provide a description of the function:def emit(self, signalName, *args, **kwargs):
assert signalName in self, "%s is not a registered signal" % signalName
self[signalName].emit(*args, **kwargs) | [
"\n Emits a signal by name if it exists. Any additional args or kwargs are passed to the signal\n :param signalName: the signal name to emit\n "
] |
Please provide a description of the function:def connect(self, signalName, slot):
assert signalName in self, "%s is not a registered signal" % signalName
self[signalName].connect(slot) | [
"\n Connects a given signal to a given slot\n :param signalName: the signal name to connect to\n :param slot: the callable slot to register\n "
] |
Please provide a description of the function:def block(self, signals=None, isBlocked=True):
if signals:
try:
if isinstance(signals, basestring):
signals = [signals]
except NameError:
if isinstance(signals, str):
... | [
"\n Sets the block on any provided signals, or to all signals\n\n :param signals: defaults to all signals. Accepts either a single string or a list of strings\n :param isBlocked: the state to set the signal to\n "
] |
Please provide a description of the function:def _open(file_or_str, **kwargs):
'''Either open a file handle, or use an existing file-like object.
This will behave as the `open` function if `file_or_str` is a string.
If `file_or_str` has the `read` attribute, it will return `file_or_str`.
Otherwise, a... | [] |
Please provide a description of the function:def load_delimited(filename, converters, delimiter=r'\s+'):
r
# Initialize list of empty lists
n_columns = len(converters)
columns = tuple(list() for _ in range(n_columns))
# Create re object for splitting lines
splitter = re.compile(delimiter)
... | [
"Utility function for loading in data from an annotation file where columns\n are delimited. The number of columns is inferred from the length of\n the provided converters list.\n\n Examples\n --------\n >>> # Load in a one-column list of event times (floats)\n >>> load_delimited('events.txt', [f... |
Please provide a description of the function:def load_events(filename, delimiter=r'\s+'):
r
# Use our universal function to load in the events
events = load_delimited(filename, [float], delimiter)
events = np.array(events)
# Validate them, but throw a warning in place of an error
try:
ut... | [
"Import time-stamp events from an annotation file. The file should\n consist of a single column of numeric values corresponding to the event\n times. This is primarily useful for processing events which lack duration,\n such as beats or onsets.\n\n Parameters\n ----------\n filename : str\n ... |
Please provide a description of the function:def load_labeled_events(filename, delimiter=r'\s+'):
r
# Use our universal function to load in the events
events, labels = load_delimited(filename, [float, str], delimiter)
events = np.array(events)
# Validate them, but throw a warning in place of an erro... | [
"Import labeled time-stamp events from an annotation file. The file should\n consist of two columns; the first having numeric values corresponding to\n the event times and the second having string labels for each event. This\n is primarily useful for processing labeled events which lack duration, such\n ... |
Please provide a description of the function:def load_labeled_intervals(filename, delimiter=r'\s+'):
r
# Use our universal function to load in the events
starts, ends, labels = load_delimited(filename, [float, float, str],
delimiter)
# Stack into an interval mat... | [
"Import labeled intervals from an annotation file. The file should consist\n of three columns: Two consisting of numeric values corresponding to start\n and end time of each interval and a third corresponding to the label of\n each interval. This is primarily useful for processing events which span a\n ... |
Please provide a description of the function:def load_time_series(filename, delimiter=r'\s+'):
r
# Use our universal function to load in the events
times, values = load_delimited(filename, [float, float], delimiter)
times = np.array(times)
values = np.array(values)
return times, values | [
"Import a time series from an annotation file. The file should consist of\n two columns of numeric values corresponding to the time and value of each\n sample of the time series.\n\n Parameters\n ----------\n filename : str\n Path to the annotation file\n delimiter : str\n Separator... |
Please provide a description of the function:def load_patterns(filename):
# List with all the patterns
pattern_list = []
# Current pattern, which will contain all occs
pattern = []
# Current occurrence, containing (onset, midi)
occurrence = []
with _open(filename, mode='r') as input_fi... | [
"Loads the patters contained in the filename and puts them into a list\n of patterns, each pattern being a list of occurrence, and each\n occurrence being a list of (onset, midi) pairs.\n\n The input file must be formatted as described in MIREX 2013:\n http://www.music-ir.org/mirex/wiki/2013:Discovery_o... |
Please provide a description of the function:def load_wav(path, mono=True):
fs, audio_data = scipy.io.wavfile.read(path)
# Make float in range [-1, 1]
if audio_data.dtype == 'int8':
audio_data = audio_data/float(2**8)
elif audio_data.dtype == 'int16':
audio_data = audio_data/float(... | [
"Loads a .wav file as a numpy array using ``scipy.io.wavfile``.\n\n Parameters\n ----------\n path : str\n Path to a .wav file\n mono : bool\n If the provided .wav has more than one channel, it will be\n converted to mono if ``mono=True``. (Default value = True)\n\n Returns\n ... |
Please provide a description of the function:def load_key(filename, delimiter=r'\s+'):
r
# Use our universal function to load the key and mode strings
scale, mode = load_delimited(filename, [str, str], delimiter)
if len(scale) != 1:
raise ValueError('Key file should contain only one line.')
... | [
"Load key labels from an annotation file. The file should\n consist of two string columns: One denoting the key scale degree\n (semitone), and the other denoting the mode (major or minor). The file\n should contain only one row.\n\n Parameters\n ----------\n filename : str\n Path to the an... |
Please provide a description of the function:def load_tempo(filename, delimiter=r'\s+'):
r
# Use our universal function to load the key and mode strings
t1, t2, weight = load_delimited(filename, [float, float, float], delimiter)
weight = weight[0]
tempi = np.concatenate([t1, t2])
if len(t1) !=... | [
"Load tempo estimates from an annotation file in MIREX format.\n The file should consist of three numeric columns: the first two\n correspond to tempo estimates (in beats-per-minute), and the third\n denotes the relative confidence of the first value compared to the\n second (in the range [0, 1]). The f... |
Please provide a description of the function:def load_ragged_time_series(filename, dtype=float, delimiter=r'\s+',
header=False):
r
# Initialize empty lists
times = []
values = []
# Create re object for splitting lines
splitter = re.compile(delimiter)
if header:
... | [
"Utility function for loading in data from a delimited time series\n annotation file with a variable number of columns.\n Assumes that column 0 contains time stamps and columns 1 through n contain\n values. n may be variable from time stamp to time stamp.\n\n Examples\n --------\n >>> # Load a rag... |
Please provide a description of the function:def _pitch_classes():
r'''Map from pitch class (str) to semitone (int).'''
pitch_classes = ['C', 'D', 'E', 'F', 'G', 'A', 'B']
semitones = [0, 2, 4, 5, 7, 9, 11]
return dict([(c, s) for c, s in zip(pitch_classes, semitones)]) | [] |
Please provide a description of the function:def _scale_degrees():
r'''Mapping from scale degrees (str) to semitones (int).'''
degrees = ['1', '2', '3', '4', '5', '6', '7',
'8', '9', '10', '11', '12', '13']
semitones = [0, 2, 4, 5, 7, 9, 11, 12, 14, 16, 17, 19, 21]
return dict([(d, s) ... | [] |
Please provide a description of the function:def pitch_class_to_semitone(pitch_class):
r'''Convert a pitch class to semitone.
Parameters
----------
pitch_class : str
Spelling of a given pitch class, e.g. 'C#', 'Gbb'
Returns
-------
semitone : int
Semitone value of the pitch... | [] |
Please provide a description of the function:def scale_degree_to_semitone(scale_degree):
r
semitone = 0
offset = 0
if scale_degree.startswith("#"):
offset = scale_degree.count("#")
scale_degree = scale_degree.strip("#")
elif scale_degree.startswith('b'):
offset = -1 * scale_d... | [
"Convert a scale degree to semitone.\n\n Parameters\n ----------\n scale degree : str\n Spelling of a relative scale degree, e.g. 'b3', '7', '#5'\n\n Returns\n -------\n semitone : int\n Relative semitone of the scale degree, wrapped to a single octave\n\n Raises\n ------\n ... |
Please provide a description of the function:def scale_degree_to_bitmap(scale_degree, modulo=False, length=BITMAP_LENGTH):
sign = 1
if scale_degree.startswith("*"):
sign = -1
scale_degree = scale_degree.strip("*")
edit_map = [0] * length
sd_idx = scale_degree_to_semitone(scale_degre... | [
"Create a bitmap representation of a scale degree.\n\n Note that values in the bitmap may be negative, indicating that the\n semitone is to be removed.\n\n Parameters\n ----------\n scale_degree : str\n Spelling of a relative scale degree, e.g. 'b3', '7', '#5'\n modulo : bool, default=True\... |
Please provide a description of the function:def quality_to_bitmap(quality):
if quality not in QUALITIES:
raise InvalidChordException(
"Unsupported chord quality shorthand: '%s' "
"Did you mean to reduce extended chords?" % quality)
return np.array(QUALITIES[quality]) | [
"Return the bitmap for a given quality.\n\n Parameters\n ----------\n quality : str\n Chord quality name.\n\n Returns\n -------\n bitmap : np.ndarray\n Bitmap representation of this quality (12-dim).\n\n "
] |
Please provide a description of the function:def validate_chord_label(chord_label):
# This monster regexp is pulled from the JAMS chord namespace,
# which is in turn derived from the context-free grammar of
# Harte et al., 2005.
pattern = re.compile(r'''^((N|X)|(([A-G](b*|#*))((:(maj|min|dim|aug|... | [
"Test for well-formedness of a chord label.\n\n Parameters\n ----------\n chord : str\n Chord label to validate.\n\n "
] |
Please provide a description of the function:def split(chord_label, reduce_extended_chords=False):
chord_label = str(chord_label)
validate_chord_label(chord_label)
if chord_label == NO_CHORD:
return [chord_label, '', set(), '']
bass = '1'
if "/" in chord_label:
chord_label, bas... | [
"Parse a chord label into its four constituent parts:\n - root\n - quality shorthand\n - scale degrees\n - bass\n\n Note: Chords lacking quality AND interval information are major.\n - If a quality is specified, it is returned.\n - If an interval is specified WITHOUT a quali... |
Please provide a description of the function:def join(chord_root, quality='', extensions=None, bass=''):
r
chord_label = chord_root
if quality or extensions:
chord_label += ":%s" % quality
if extensions:
chord_label += "(%s)" % ",".join(extensions)
if bass and bass != '1':
ch... | [
"Join the parts of a chord into a complete chord label.\n\n Parameters\n ----------\n chord_root : str\n Root pitch class of the chord, e.g. 'C', 'Eb'\n quality : str\n Quality of the chord, e.g. 'maj', 'hdim7'\n (Default value = '')\n extensions : list\n Any added or abse... |
Please provide a description of the function:def encode(chord_label, reduce_extended_chords=False,
strict_bass_intervals=False):
if chord_label == NO_CHORD:
return NO_CHORD_ENCODED
if chord_label == X_CHORD:
return X_CHORD_ENCODED
chord_root, quality, scale_degrees, bass = s... | [
"Translate a chord label to numerical representations for evaluation.\n\n Parameters\n ----------\n chord_label : str\n Chord label to encode.\n reduce_extended_chords : bool\n Whether to map the upper voicings of extended chords (9's, 11's, 13's)\n to semitone extensions.\n ... |
Please provide a description of the function:def encode_many(chord_labels, reduce_extended_chords=False):
num_items = len(chord_labels)
roots, basses = np.zeros([2, num_items], dtype=np.int)
semitones = np.zeros([num_items, 12], dtype=np.int)
local_cache = dict()
for i, label in enumerate(chord... | [
"Translate a set of chord labels to numerical representations for sane\n evaluation.\n\n Parameters\n ----------\n chord_labels : list\n Set of chord labels to encode.\n reduce_extended_chords : bool\n Whether to map the upper voicings of extended chords (9's, 11's, 13's)\n to se... |
Please provide a description of the function:def rotate_bitmap_to_root(bitmap, chord_root):
bitmap = np.asarray(bitmap)
assert bitmap.ndim == 1, "Currently only 1D bitmaps are supported."
idxs = list(np.nonzero(bitmap))
idxs[-1] = (idxs[-1] + chord_root) % 12
abs_bitmap = np.zeros_like(bitmap)
... | [
"Circularly shift a relative bitmap to its asbolute pitch classes.\n\n For clarity, the best explanation is an example. Given 'G:Maj', the root\n and quality map are as follows::\n\n root=5\n quality=[1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0] # Relative chord shape\n\n After rotating to the root, ... |
Please provide a description of the function:def rotate_bitmaps_to_roots(bitmaps, roots):
abs_bitmaps = []
for bitmap, chord_root in zip(bitmaps, roots):
abs_bitmaps.append(rotate_bitmap_to_root(bitmap, chord_root))
return np.asarray(abs_bitmaps) | [
"Circularly shift a relative bitmaps to asbolute pitch classes.\n\n See :func:`rotate_bitmap_to_root` for more information.\n\n Parameters\n ----------\n bitmap : np.ndarray, shape=(N, 12)\n Bitmap of active notes, relative to the given root.\n root : np.ndarray, shape=(N,)\n Absolute p... |
Please provide a description of the function:def validate(reference_labels, estimated_labels):
N = len(reference_labels)
M = len(estimated_labels)
if N != M:
raise ValueError(
"Chord comparison received different length lists: "
"len(reference)=%d\tlen(estimates)=%d" % (... | [
"Checks that the input annotations to a comparison function look like\n valid chord labels.\n\n Parameters\n ----------\n reference_labels : list, len=n\n Reference chord labels to score against.\n estimated_labels : list, len=n\n Estimated chord labels to score against.\n\n "
] |
Please provide a description of the function:def weighted_accuracy(comparisons, weights):
N = len(comparisons)
# There should be as many weights as comparisons
if weights.shape[0] != N:
raise ValueError('weights and comparisons should be of the same'
' length. len(weigh... | [
"Compute the weighted accuracy of a list of chord comparisons.\n\n Examples\n --------\n >>> (ref_intervals,\n ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab')\n >>> (est_intervals,\n ... est_labels) = mir_eval.io.load_labeled_intervals('est.lab')\n >>> est_intervals, est_label... |
Please provide a description of the function:def thirds(reference_labels, estimated_labels):
validate(reference_labels, estimated_labels)
ref_roots, ref_semitones = encode_many(reference_labels, False)[:2]
est_roots, est_semitones = encode_many(estimated_labels, False)[:2]
eq_roots = ref_roots == ... | [
"Compare chords along root & third relationships.\n\n Examples\n --------\n >>> (ref_intervals,\n ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab')\n >>> (est_intervals,\n ... est_labels) = mir_eval.io.load_labeled_intervals('est.lab')\n >>> est_intervals, est_labels = mir_eval.... |
Please provide a description of the function:def thirds_inv(reference_labels, estimated_labels):
validate(reference_labels, estimated_labels)
ref_roots, ref_semitones, ref_bass = encode_many(reference_labels, False)
est_roots, est_semitones, est_bass = encode_many(estimated_labels, False)
eq_root ... | [
"Score chords along root, third, & bass relationships.\n\n Examples\n --------\n >>> (ref_intervals,\n ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab')\n >>> (est_intervals,\n ... est_labels) = mir_eval.io.load_labeled_intervals('est.lab')\n >>> est_intervals, est_labels = mir_... |
Please provide a description of the function:def triads(reference_labels, estimated_labels):
validate(reference_labels, estimated_labels)
ref_roots, ref_semitones = encode_many(reference_labels, False)[:2]
est_roots, est_semitones = encode_many(estimated_labels, False)[:2]
eq_roots = ref_roots == ... | [
"Compare chords along triad (root & quality to #5) relationships.\n\n Examples\n --------\n >>> (ref_intervals,\n ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab')\n >>> (est_intervals,\n ... est_labels) = mir_eval.io.load_labeled_intervals('est.lab')\n >>> est_intervals, est_la... |
Please provide a description of the function:def triads_inv(reference_labels, estimated_labels):
validate(reference_labels, estimated_labels)
ref_roots, ref_semitones, ref_bass = encode_many(reference_labels, False)
est_roots, est_semitones, est_bass = encode_many(estimated_labels, False)
eq_roots... | [
"Score chords along triad (root, quality to #5, & bass) relationships.\n\n Examples\n --------\n >>> (ref_intervals,\n ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab')\n >>> (est_intervals,\n ... est_labels) = mir_eval.io.load_labeled_intervals('est.lab')\n >>> est_intervals, e... |
Please provide a description of the function:def root(reference_labels, estimated_labels):
validate(reference_labels, estimated_labels)
ref_roots, ref_semitones = encode_many(reference_labels, False)[:2]
est_roots = encode_many(estimated_labels, False)[0]
comparison_scores = (ref_roots == est_root... | [
"Compare chords according to roots.\n\n Examples\n --------\n >>> (ref_intervals,\n ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab')\n >>> (est_intervals,\n ... est_labels) = mir_eval.io.load_labeled_intervals('est.lab')\n >>> est_intervals, est_labels = mir_eval.util.adjust_in... |
Please provide a description of the function:def mirex(reference_labels, estimated_labels):
validate(reference_labels, estimated_labels)
# TODO(?): Should this be an argument?
min_intersection = 3
ref_data = encode_many(reference_labels, False)
ref_chroma = rotate_bitmaps_to_roots(ref_data[1], ... | [
"Compare chords along MIREX rules.\n\n Examples\n --------\n >>> (ref_intervals,\n ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab')\n >>> (est_intervals,\n ... est_labels) = mir_eval.io.load_labeled_intervals('est.lab')\n >>> est_intervals, est_labels = mir_eval.util.adjust_int... |
Please provide a description of the function:def majmin(reference_labels, estimated_labels):
validate(reference_labels, estimated_labels)
maj_semitones = np.array(QUALITIES['maj'][:8])
min_semitones = np.array(QUALITIES['min'][:8])
ref_roots, ref_semitones, _ = encode_many(reference_labels, False)... | [
"Compare chords along major-minor rules. Chords with qualities outside\n Major/minor/no-chord are ignored.\n\n Examples\n --------\n >>> (ref_intervals,\n ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab')\n >>> (est_intervals,\n ... est_labels) = mir_eval.io.load_labeled_interva... |
Please provide a description of the function:def majmin_inv(reference_labels, estimated_labels):
validate(reference_labels, estimated_labels)
maj_semitones = np.array(QUALITIES['maj'][:8])
min_semitones = np.array(QUALITIES['min'][:8])
ref_roots, ref_semitones, ref_bass = encode_many(reference_lab... | [
"Compare chords along major-minor rules, with inversions. Chords with\n qualities outside Major/minor/no-chord are ignored, and the bass note must\n exist in the triad (bass in [1, 3, 5]).\n\n Examples\n --------\n >>> (ref_intervals,\n ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.la... |
Please provide a description of the function:def sevenths(reference_labels, estimated_labels):
validate(reference_labels, estimated_labels)
seventh_qualities = ['maj', 'min', 'maj7', '7', 'min7', '']
valid_semitones = np.array([QUALITIES[name] for name in seventh_qualities])
ref_roots, ref_semiton... | [
"Compare chords along MIREX 'sevenths' rules. Chords with qualities\n outside [maj, maj7, 7, min, min7, N] are ignored.\n\n Examples\n --------\n >>> (ref_intervals,\n ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab')\n >>> (est_intervals,\n ... est_labels) = mir_eval.io.load_la... |
Please provide a description of the function:def sevenths_inv(reference_labels, estimated_labels):
validate(reference_labels, estimated_labels)
seventh_qualities = ['maj', 'min', 'maj7', '7', 'min7', '']
valid_semitones = np.array([QUALITIES[name] for name in seventh_qualities])
ref_roots, ref_sem... | [
"Compare chords along MIREX 'sevenths' rules. Chords with qualities\n outside [maj, maj7, 7, min, min7, N] are ignored.\n\n Examples\n --------\n >>> (ref_intervals,\n ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab')\n >>> (est_intervals,\n ... est_labels) = mir_eval.io.load_la... |
Please provide a description of the function:def directional_hamming_distance(reference_intervals, estimated_intervals):
util.validate_intervals(estimated_intervals)
util.validate_intervals(reference_intervals)
# make sure chord intervals do not overlap
if len(reference_intervals) > 1 and (referen... | [
"Compute the directional hamming distance between reference and\n estimated intervals as defined by [#harte2010towards]_ and used for MIREX\n 'OverSeg', 'UnderSeg' and 'MeanSeg' measures.\n\n Examples\n --------\n >>> (ref_intervals,\n ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab... |
Please provide a description of the function:def seg(reference_intervals, estimated_intervals):
return min(underseg(reference_intervals, estimated_intervals),
overseg(reference_intervals, estimated_intervals)) | [
"Compute the MIREX 'MeanSeg' score.\n\n Examples\n --------\n >>> (ref_intervals,\n ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab')\n >>> (est_intervals,\n ... est_labels) = mir_eval.io.load_labeled_intervals('est.lab')\n >>> score = mir_eval.chord.seg(ref_intervals, est_inter... |
Please provide a description of the function:def merge_chord_intervals(intervals, labels):
roots, semitones, basses = encode_many(labels, True)
merged_ivs = []
prev_rt = None
prev_st = None
prev_ba = None
for s, e, rt, st, ba in zip(intervals[:, 0], intervals[:, 1],
... | [
"\n Merge consecutive chord intervals if they represent the same chord.\n\n Parameters\n ----------\n intervals : np.ndarray, shape=(n, 2), dtype=float\n Chord intervals to be merged, in the format returned by\n :func:`mir_eval.io.load_labeled_intervals`.\n labels : list, shape=(n,)\n ... |
Please provide a description of the function:def evaluate(ref_intervals, ref_labels, est_intervals, est_labels, **kwargs):
# Append or crop estimated intervals so their span is the same as reference
est_intervals, est_labels = util.adjust_intervals(
est_intervals, est_labels, ref_intervals.min(), r... | [
"Computes weighted accuracy for all comparison functions for the given\n reference and estimated annotations.\n\n Examples\n --------\n >>> (ref_intervals,\n ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab')\n >>> (est_intervals,\n ... est_labels) = mir_eval.io.load_labeled_inte... |
Please provide a description of the function:def _n_onset_midi(patterns):
return len([o_m for pat in patterns for occ in pat for o_m in occ]) | [
"Computes the number of onset_midi objects in a pattern\n\n Parameters\n ----------\n patterns :\n A list of patterns using the format returned by\n :func:`mir_eval.io.load_patterns()`\n\n Returns\n -------\n n_onsets : int\n Number of onsets within the pattern.\n\n "
] |
Please provide a description of the function:def validate(reference_patterns, estimated_patterns):
# Warn if pattern lists are empty
if _n_onset_midi(reference_patterns) == 0:
warnings.warn('Reference patterns are empty.')
if _n_onset_midi(estimated_patterns) == 0:
warnings.warn('Estima... | [
"Checks that the input annotations to a metric look like valid pattern\n lists, and throws helpful errors if not.\n\n Parameters\n ----------\n reference_patterns : list\n The reference patterns using the format returned by\n :func:`mir_eval.io.load_patterns()`\n estimated_patterns : li... |
Please provide a description of the function:def _occurrence_intersection(occ_P, occ_Q):
set_P = set([tuple(onset_midi) for onset_midi in occ_P])
set_Q = set([tuple(onset_midi) for onset_midi in occ_Q])
return set_P & set_Q | [
"Computes the intersection between two occurrences.\n\n Parameters\n ----------\n occ_P : list of tuples\n (onset, midi) pairs representing the reference occurrence.\n occ_Q : list\n second list of (onset, midi) tuples\n\n Returns\n -------\n S : set\n Set of the intersecti... |
Please provide a description of the function:def _compute_score_matrix(P, Q, similarity_metric="cardinality_score"):
sm = np.zeros((len(P), len(Q))) # The score matrix
for iP, occ_P in enumerate(P):
for iQ, occ_Q in enumerate(Q):
if similarity_metric == "cardinality_score":
... | [
"Computes the score matrix between the patterns P and Q.\n\n Parameters\n ----------\n P : list\n Pattern containing a list of occurrences.\n Q : list\n Pattern containing a list of occurrences.\n similarity_metric : str\n A string representing the metric to be used\n when... |
Please provide a description of the function:def standard_FPR(reference_patterns, estimated_patterns, tol=1e-5):
validate(reference_patterns, estimated_patterns)
nP = len(reference_patterns) # Number of patterns in the reference
nQ = len(estimated_patterns) # Number of patterns in the estimation
... | [
"Standard F1 Score, Precision and Recall.\n\n This metric checks if the prototype patterns of the reference match\n possible translated patterns in the prototype patterns of the estimations.\n Since the sizes of these prototypes must be equal, this metric is quite\n restictive and it tends to be 0 in mo... |
Please provide a description of the function:def establishment_FPR(reference_patterns, estimated_patterns,
similarity_metric="cardinality_score"):
validate(reference_patterns, estimated_patterns)
nP = len(reference_patterns) # Number of elements in reference
nQ = len(estimated_... | [
"Establishment F1 Score, Precision and Recall.\n\n Examples\n --------\n >>> ref_patterns = mir_eval.io.load_patterns(\"ref_pattern.txt\")\n >>> est_patterns = mir_eval.io.load_patterns(\"est_pattern.txt\")\n >>> F, P, R = mir_eval.pattern.establishment_FPR(ref_patterns,\n ... ... |
Please provide a description of the function:def occurrence_FPR(reference_patterns, estimated_patterns, thres=.75,
similarity_metric="cardinality_score"):
validate(reference_patterns, estimated_patterns)
# Number of elements in reference
nP = len(reference_patterns)
# Number of e... | [
"Establishment F1 Score, Precision and Recall.\n\n\n Examples\n --------\n >>> ref_patterns = mir_eval.io.load_patterns(\"ref_pattern.txt\")\n >>> est_patterns = mir_eval.io.load_patterns(\"est_pattern.txt\")\n >>> F, P, R = mir_eval.pattern.occurrence_FPR(ref_patterns,\n ... ... |
Please provide a description of the function:def three_layer_FPR(reference_patterns, estimated_patterns):
validate(reference_patterns, estimated_patterns)
def compute_first_layer_PR(ref_occs, est_occs):
# Find the length of the intersection between reference and estimation
s = len... | [
"Three Layer F1 Score, Precision and Recall. As described by Meridith.\n\n Examples\n --------\n >>> ref_patterns = mir_eval.io.load_patterns(\"ref_pattern.txt\")\n >>> est_patterns = mir_eval.io.load_patterns(\"est_pattern.txt\")\n >>> F, P, R = mir_eval.pattern.three_layer_FPR(ref_patterns,\n ..... |
Please provide a description of the function:def first_n_three_layer_P(reference_patterns, estimated_patterns, n=5):
validate(reference_patterns, estimated_patterns)
# If no patterns were provided, metric is zero
if _n_onset_midi(reference_patterns) == 0 or \
_n_onset_midi(estimated_patterns) =... | [
"First n three-layer precision.\n\n This metric is basically the same as the three-layer FPR but it is only\n applied to the first n estimated patterns, and it only returns the\n precision. In MIREX and typically, n = 5.\n\n Examples\n --------\n >>> ref_patterns = mir_eval.io.load_patterns(\"ref_... |
Please provide a description of the function:def first_n_target_proportion_R(reference_patterns, estimated_patterns, n=5):
validate(reference_patterns, estimated_patterns)
# If no patterns were provided, metric is zero
if _n_onset_midi(reference_patterns) == 0 or \
_n_onset_midi(estimated_patte... | [
"First n target proportion establishment recall metric.\n\n This metric is similar is similar to the establishment FPR score, but it\n only takes into account the first n estimated patterns and it only\n outputs the Recall value of it.\n\n Examples\n --------\n >>> ref_patterns = mir_eval.io.load_... |
Please provide a description of the function:def evaluate(ref_patterns, est_patterns, **kwargs):
# Compute all the metrics
scores = collections.OrderedDict()
# Standard scores
scores['F'], scores['P'], scores['R'] = \
util.filter_kwargs(standard_FPR, ref_patterns, est_patterns, **kwargs)
... | [
"Load data and perform the evaluation.\n\n Examples\n --------\n >>> ref_patterns = mir_eval.io.load_patterns(\"ref_pattern.txt\")\n >>> est_patterns = mir_eval.io.load_patterns(\"est_pattern.txt\")\n >>> scores = mir_eval.pattern.evaluate(ref_patterns, est_patterns)\n\n Parameters\n ----------... |
Please provide a description of the function:def validate(ref_intervals, ref_pitches, ref_velocities, est_intervals,
est_pitches, est_velocities):
transcription.validate(ref_intervals, ref_pitches, est_intervals,
est_pitches)
# Check that velocities have the same len... | [
"Checks that the input annotations have valid time intervals, pitches,\n and velocities, and throws helpful errors if not.\n\n Parameters\n ----------\n ref_intervals : np.ndarray, shape=(n,2)\n Array of reference notes time intervals (onset and offset times)\n ref_pitches : np.ndarray, shape=... |
Please provide a description of the function:def match_notes(
ref_intervals, ref_pitches, ref_velocities, est_intervals, est_pitches,
est_velocities, onset_tolerance=0.05, pitch_tolerance=50.0,
offset_ratio=0.2, offset_min_tolerance=0.05, strict=False,
velocity_tolerance=0.1):
#... | [
"Match notes, taking note velocity into consideration.\n\n This function first calls :func:`mir_eval.transcription.match_notes` to\n match notes according to the supplied intervals, pitches, onset, offset,\n and pitch tolerances. The velocities of the matched notes are then used to\n estimate a slope an... |
Please provide a description of the function:def evaluate(ref_intervals, ref_pitches, ref_velocities, est_intervals,
est_pitches, est_velocities, **kwargs):
# Compute all the metrics
scores = collections.OrderedDict()
# Precision, recall and f-measure taking note offsets into account
... | [
"Compute all metrics for the given reference and estimated annotations.\n\n Parameters\n ----------\n ref_intervals : np.ndarray, shape=(n,2)\n Array of reference notes time intervals (onset and offset times)\n ref_pitches : np.ndarray, shape=(n,)\n Array of reference pitch values in Hertz... |
Please provide a description of the function:def validate(reference_beats, estimated_beats):
# If reference or estimated beats are empty,
# warn because metric will be 0
if reference_beats.size == 0:
warnings.warn("Reference beats are empty.")
if estimated_beats.size == 0:
warnings.... | [
"Checks that the input annotations to a metric look like valid beat time\n arrays, and throws helpful errors if not.\n\n Parameters\n ----------\n reference_beats : np.ndarray\n reference beat times, in seconds\n estimated_beats : np.ndarray\n estimated beat times, in seconds\n "
] |
Please provide a description of the function:def _get_reference_beat_variations(reference_beats):
# Create annotations at twice the metric level
interpolated_indices = np.arange(0, reference_beats.shape[0]-.5, .5)
original_indices = np.arange(0, reference_beats.shape[0])
double_reference_beats = n... | [
"Return metric variations of the reference beats\n\n Parameters\n ----------\n reference_beats : np.ndarray\n beat locations in seconds\n\n Returns\n -------\n reference_beats : np.ndarray\n Original beat locations\n off_beat : np.ndarray\n 180 degrees out of phase from the... |
Please provide a description of the function:def f_measure(reference_beats,
estimated_beats,
f_measure_threshold=0.07):
validate(reference_beats, estimated_beats)
# When estimated beats are empty, no beats are correct; metric is 0
if estimated_beats.size == 0 or reference_be... | [
"Compute the F-measure of correct vs incorrectly predicted beats.\n \"Correctness\" is determined over a small window.\n\n Examples\n --------\n >>> reference_beats = mir_eval.io.load_events('reference.txt')\n >>> reference_beats = mir_eval.beat.trim_beats(reference_beats)\n >>> estimated_beats = ... |
Please provide a description of the function:def cemgil(reference_beats,
estimated_beats,
cemgil_sigma=0.04):
validate(reference_beats, estimated_beats)
# When estimated beats are empty, no beats are correct; metric is 0
if estimated_beats.size == 0 or reference_beats.size == 0:
... | [
"Cemgil's score, computes a gaussian error of each estimated beat.\n Compares against the original beat times and all metrical variations.\n\n Examples\n --------\n >>> reference_beats = mir_eval.io.load_events('reference.txt')\n >>> reference_beats = mir_eval.beat.trim_beats(reference_beats)\n >>... |
Please provide a description of the function:def goto(reference_beats,
estimated_beats,
goto_threshold=0.35,
goto_mu=0.2,
goto_sigma=0.2):
validate(reference_beats, estimated_beats)
# When estimated beats are empty, no beats are correct; metric is 0
if estimated_beat... | [
"Calculate Goto's score, a binary 1 or 0 depending on some specific\n heuristic criteria\n\n Examples\n --------\n >>> reference_beats = mir_eval.io.load_events('reference.txt')\n >>> reference_beats = mir_eval.beat.trim_beats(reference_beats)\n >>> estimated_beats = mir_eval.io.load_events('estim... |
Please provide a description of the function:def p_score(reference_beats,
estimated_beats,
p_score_threshold=0.2):
validate(reference_beats, estimated_beats)
# Warn when only one beat is provided for either estimated or reference,
# report a warning
if reference_beats.size =... | [
"Get McKinney's P-score.\n Based on the autocorrelation of the reference and estimated beats\n\n Examples\n --------\n >>> reference_beats = mir_eval.io.load_events('reference.txt')\n >>> reference_beats = mir_eval.beat.trim_beats(reference_beats)\n >>> estimated_beats = mir_eval.io.load_events('e... |
Please provide a description of the function:def continuity(reference_beats,
estimated_beats,
continuity_phase_threshold=0.175,
continuity_period_threshold=0.175):
validate(reference_beats, estimated_beats)
# Warn when only one beat is provided for either estima... | [
"Get metrics based on how much of the estimated beat sequence is\n continually correct.\n\n Examples\n --------\n >>> reference_beats = mir_eval.io.load_events('reference.txt')\n >>> reference_beats = mir_eval.beat.trim_beats(reference_beats)\n >>> estimated_beats = mir_eval.io.load_events('estima... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.