repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
LucidtechAI/las-sdk-python
las/client.py
Client.put_document
def put_document(document_path: str, content_type: str, presigned_url: str) -> str: """Convenience method for putting a document to presigned url. >>> from las import Client >>> client = Client(endpoint='<api endpoint>') >>> client.put_document(document_path='document.jpeg', content_typ...
python
def put_document(document_path: str, content_type: str, presigned_url: str) -> str: """Convenience method for putting a document to presigned url. >>> from las import Client >>> client = Client(endpoint='<api endpoint>') >>> client.put_document(document_path='document.jpeg', content_typ...
[ "def", "put_document", "(", "document_path", ":", "str", ",", "content_type", ":", "str", ",", "presigned_url", ":", "str", ")", "->", "str", ":", "body", "=", "pathlib", ".", "Path", "(", "document_path", ")", ".", "read_bytes", "(", ")", "headers", "="...
Convenience method for putting a document to presigned url. >>> from las import Client >>> client = Client(endpoint='<api endpoint>') >>> client.put_document(document_path='document.jpeg', content_type='image/jpeg', >>> presigned_url='<presigned url>') :param document_path: Pat...
[ "Convenience", "method", "for", "putting", "a", "document", "to", "presigned", "url", "." ]
5f39dee7983baff28a1deb93c12d36414d835d12
https://github.com/LucidtechAI/las-sdk-python/blob/5f39dee7983baff28a1deb93c12d36414d835d12/las/client.py#L117-L140
train
owncloud/pyocclient
owncloud/owncloud.py
ShareInfo.get_expiration
def get_expiration(self): """Returns the expiration date. :returns: expiration date :rtype: datetime object """ exp = self._get_int('expiration') if exp is not None: return datetime.datetime.fromtimestamp( exp ) return None
python
def get_expiration(self): """Returns the expiration date. :returns: expiration date :rtype: datetime object """ exp = self._get_int('expiration') if exp is not None: return datetime.datetime.fromtimestamp( exp ) return None
[ "def", "get_expiration", "(", "self", ")", ":", "exp", "=", "self", ".", "_get_int", "(", "'expiration'", ")", "if", "exp", "is", "not", "None", ":", "return", "datetime", ".", "datetime", ".", "fromtimestamp", "(", "exp", ")", "return", "None" ]
Returns the expiration date. :returns: expiration date :rtype: datetime object
[ "Returns", "the", "expiration", "date", "." ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L140-L151
train
owncloud/pyocclient
owncloud/owncloud.py
Client.login
def login(self, user_id, password): """Authenticate to ownCloud. This will create a session on the server. :param user_id: user id :param password: password :raises: HTTPResponseError in case an HTTP error status was returned """ self._session = requests.session...
python
def login(self, user_id, password): """Authenticate to ownCloud. This will create a session on the server. :param user_id: user id :param password: password :raises: HTTPResponseError in case an HTTP error status was returned """ self._session = requests.session...
[ "def", "login", "(", "self", ",", "user_id", ",", "password", ")", ":", "self", ".", "_session", "=", "requests", ".", "session", "(", ")", "self", ".", "_session", ".", "verify", "=", "self", ".", "_verify_certs", "self", ".", "_session", ".", "auth",...
Authenticate to ownCloud. This will create a session on the server. :param user_id: user id :param password: password :raises: HTTPResponseError in case an HTTP error status was returned
[ "Authenticate", "to", "ownCloud", ".", "This", "will", "create", "a", "session", "on", "the", "server", "." ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L339-L366
train
owncloud/pyocclient
owncloud/owncloud.py
Client.file_info
def file_info(self, path): """Returns the file info for the given remote file :param path: path to the remote file :returns: file info :rtype: :class:`FileInfo` object or `None` if file was not found :raises: HTTPResponseError in case an HTTP error status was returne...
python
def file_info(self, path): """Returns the file info for the given remote file :param path: path to the remote file :returns: file info :rtype: :class:`FileInfo` object or `None` if file was not found :raises: HTTPResponseError in case an HTTP error status was returne...
[ "def", "file_info", "(", "self", ",", "path", ")", ":", "res", "=", "self", ".", "_make_dav_request", "(", "'PROPFIND'", ",", "path", ",", "headers", "=", "{", "'Depth'", ":", "'0'", "}", ")", "if", "res", ":", "return", "res", "[", "0", "]", "retu...
Returns the file info for the given remote file :param path: path to the remote file :returns: file info :rtype: :class:`FileInfo` object or `None` if file was not found :raises: HTTPResponseError in case an HTTP error status was returned
[ "Returns", "the", "file", "info", "for", "the", "given", "remote", "file" ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L378-L390
train
owncloud/pyocclient
owncloud/owncloud.py
Client.get_file_contents
def get_file_contents(self, path): """Returns the contents of a remote file :param path: path to the remote file :returns: file contents :rtype: binary data :raises: HTTPResponseError in case an HTTP error status was returned """ path = self._normalize_path(path)...
python
def get_file_contents(self, path): """Returns the contents of a remote file :param path: path to the remote file :returns: file contents :rtype: binary data :raises: HTTPResponseError in case an HTTP error status was returned """ path = self._normalize_path(path)...
[ "def", "get_file_contents", "(", "self", ",", "path", ")", ":", "path", "=", "self", ".", "_normalize_path", "(", "path", ")", "res", "=", "self", ".", "_session", ".", "get", "(", "self", ".", "_webdav_url", "+", "parse", ".", "quote", "(", "self", ...
Returns the contents of a remote file :param path: path to the remote file :returns: file contents :rtype: binary data :raises: HTTPResponseError in case an HTTP error status was returned
[ "Returns", "the", "contents", "of", "a", "remote", "file" ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L414-L430
train
owncloud/pyocclient
owncloud/owncloud.py
Client.get_directory_as_zip
def get_directory_as_zip(self, remote_path, local_file): """Downloads a remote directory as zip :param remote_path: path to the remote directory to download :param local_file: path and name of the target local file :returns: True if the operation succeeded, False otherwise :rais...
python
def get_directory_as_zip(self, remote_path, local_file): """Downloads a remote directory as zip :param remote_path: path to the remote directory to download :param local_file: path and name of the target local file :returns: True if the operation succeeded, False otherwise :rais...
[ "def", "get_directory_as_zip", "(", "self", ",", "remote_path", ",", "local_file", ")", ":", "remote_path", "=", "self", ".", "_normalize_path", "(", "remote_path", ")", "url", "=", "self", ".", "url", "+", "'index.php/apps/files/ajax/download.php?dir='", "+", "pa...
Downloads a remote directory as zip :param remote_path: path to the remote directory to download :param local_file: path and name of the target local file :returns: True if the operation succeeded, False otherwise :raises: HTTPResponseError in case an HTTP error status was returned
[ "Downloads", "a", "remote", "directory", "as", "zip" ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L461-L486
train
owncloud/pyocclient
owncloud/owncloud.py
Client.put_directory
def put_directory(self, target_path, local_directory, **kwargs): """Upload a directory with all its contents :param target_path: path of the directory to upload into :param local_directory: path to the local directory to upload :param \*\*kwargs: optional arguments that ``put_file`` acc...
python
def put_directory(self, target_path, local_directory, **kwargs): """Upload a directory with all its contents :param target_path: path of the directory to upload into :param local_directory: path to the local directory to upload :param \*\*kwargs: optional arguments that ``put_file`` acc...
[ "def", "put_directory", "(", "self", ",", "target_path", ",", "local_directory", ",", "**", "kwargs", ")", ":", "target_path", "=", "self", ".", "_normalize_path", "(", "target_path", ")", "if", "not", "target_path", ".", "endswith", "(", "'/'", ")", ":", ...
Upload a directory with all its contents :param target_path: path of the directory to upload into :param local_directory: path to the local directory to upload :param \*\*kwargs: optional arguments that ``put_file`` accepts :returns: True if the operation succeeded, False otherwise ...
[ "Upload", "a", "directory", "with", "all", "its", "contents" ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L536-L566
train
owncloud/pyocclient
owncloud/owncloud.py
Client._put_file_chunked
def _put_file_chunked(self, remote_path, local_source_file, **kwargs): """Uploads a file using chunks. If the file is smaller than ``chunk_size`` it will be uploaded directly. :param remote_path: path to the target file. A target directory can also be specified instead by appending a "/...
python
def _put_file_chunked(self, remote_path, local_source_file, **kwargs): """Uploads a file using chunks. If the file is smaller than ``chunk_size`` it will be uploaded directly. :param remote_path: path to the target file. A target directory can also be specified instead by appending a "/...
[ "def", "_put_file_chunked", "(", "self", ",", "remote_path", ",", "local_source_file", ",", "**", "kwargs", ")", ":", "chunk_size", "=", "kwargs", ".", "get", "(", "'chunk_size'", ",", "10", "*", "1024", "*", "1024", ")", "result", "=", "True", "transfer_i...
Uploads a file using chunks. If the file is smaller than ``chunk_size`` it will be uploaded directly. :param remote_path: path to the target file. A target directory can also be specified instead by appending a "/" :param local_source_file: path to the local file to upload :para...
[ "Uploads", "a", "file", "using", "chunks", ".", "If", "the", "file", "is", "smaller", "than", "chunk_size", "it", "will", "be", "uploaded", "directly", "." ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L568-L630
train
owncloud/pyocclient
owncloud/owncloud.py
Client.list_open_remote_share
def list_open_remote_share(self): """List all pending remote shares :returns: array of pending remote shares :raises: HTTPResponseError in case an HTTP error status was returned """ res = self._make_ocs_request( 'GET', self.OCS_SERVICE_SHARE, ...
python
def list_open_remote_share(self): """List all pending remote shares :returns: array of pending remote shares :raises: HTTPResponseError in case an HTTP error status was returned """ res = self._make_ocs_request( 'GET', self.OCS_SERVICE_SHARE, ...
[ "def", "list_open_remote_share", "(", "self", ")", ":", "res", "=", "self", ".", "_make_ocs_request", "(", "'GET'", ",", "self", ".", "OCS_SERVICE_SHARE", ",", "'remote_shares/pending'", ")", "if", "res", ".", "status_code", "==", "200", ":", "tree", "=", "E...
List all pending remote shares :returns: array of pending remote shares :raises: HTTPResponseError in case an HTTP error status was returned
[ "List", "all", "pending", "remote", "shares" ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L652-L676
train
owncloud/pyocclient
owncloud/owncloud.py
Client.accept_remote_share
def accept_remote_share(self, share_id): """Accepts a remote share :param share_id: Share ID (int) :returns: True if the operation succeeded, False otherwise :raises: HTTPResponseError in case an HTTP error status was returned """ if not isinstance(share_id, int): ...
python
def accept_remote_share(self, share_id): """Accepts a remote share :param share_id: Share ID (int) :returns: True if the operation succeeded, False otherwise :raises: HTTPResponseError in case an HTTP error status was returned """ if not isinstance(share_id, int): ...
[ "def", "accept_remote_share", "(", "self", ",", "share_id", ")", ":", "if", "not", "isinstance", "(", "share_id", ",", "int", ")", ":", "return", "False", "res", "=", "self", ".", "_make_ocs_request", "(", "'POST'", ",", "self", ".", "OCS_SERVICE_SHARE", "...
Accepts a remote share :param share_id: Share ID (int) :returns: True if the operation succeeded, False otherwise :raises: HTTPResponseError in case an HTTP error status was returned
[ "Accepts", "a", "remote", "share" ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L678-L695
train
owncloud/pyocclient
owncloud/owncloud.py
Client.update_share
def update_share(self, share_id, **kwargs): """Updates a given share :param share_id: (int) Share ID :param perms: (int) update permissions (see share_file_with_user() below) :param password: (string) updated password for public link Share :param public_upload: (boolean) enable/...
python
def update_share(self, share_id, **kwargs): """Updates a given share :param share_id: (int) Share ID :param perms: (int) update permissions (see share_file_with_user() below) :param password: (string) updated password for public link Share :param public_upload: (boolean) enable/...
[ "def", "update_share", "(", "self", ",", "share_id", ",", "**", "kwargs", ")", ":", "perms", "=", "kwargs", ".", "get", "(", "'perms'", ",", "None", ")", "password", "=", "kwargs", ".", "get", "(", "'password'", ",", "None", ")", "public_upload", "=", ...
Updates a given share :param share_id: (int) Share ID :param perms: (int) update permissions (see share_file_with_user() below) :param password: (string) updated password for public link Share :param public_upload: (boolean) enable/disable public upload for public shares :return...
[ "Updates", "a", "given", "share" ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L735-L772
train
owncloud/pyocclient
owncloud/owncloud.py
Client.share_file_with_link
def share_file_with_link(self, path, **kwargs): """Shares a remote file with link :param path: path to the remote file to share :param perms (optional): permission of the shared object defaults to read only (1) :param public_upload (optional): allows users to upload files or fol...
python
def share_file_with_link(self, path, **kwargs): """Shares a remote file with link :param path: path to the remote file to share :param perms (optional): permission of the shared object defaults to read only (1) :param public_upload (optional): allows users to upload files or fol...
[ "def", "share_file_with_link", "(", "self", ",", "path", ",", "**", "kwargs", ")", ":", "perms", "=", "kwargs", ".", "get", "(", "'perms'", ",", "None", ")", "public_upload", "=", "kwargs", ".", "get", "(", "'public_upload'", ",", "'false'", ")", "passwo...
Shares a remote file with link :param path: path to the remote file to share :param perms (optional): permission of the shared object defaults to read only (1) :param public_upload (optional): allows users to upload files or folders :param password (optional): sets a password ...
[ "Shares", "a", "remote", "file", "with", "link" ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L800-L847
train
owncloud/pyocclient
owncloud/owncloud.py
Client.is_shared
def is_shared(self, path): """Checks whether a path is already shared :param path: path to the share to be checked :returns: True if the path is already shared, else False :raises: HTTPResponseError in case an HTTP error status was returned """ # make sure that the path ...
python
def is_shared(self, path): """Checks whether a path is already shared :param path: path to the share to be checked :returns: True if the path is already shared, else False :raises: HTTPResponseError in case an HTTP error status was returned """ # make sure that the path ...
[ "def", "is_shared", "(", "self", ",", "path", ")", ":", "self", ".", "file_info", "(", "path", ")", "try", ":", "result", "=", "self", ".", "get_shares", "(", "path", ")", "if", "result", ":", "return", "len", "(", "result", ")", ">", "0", "except"...
Checks whether a path is already shared :param path: path to the share to be checked :returns: True if the path is already shared, else False :raises: HTTPResponseError in case an HTTP error status was returned
[ "Checks", "whether", "a", "path", "is", "already", "shared" ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L849-L866
train
owncloud/pyocclient
owncloud/owncloud.py
Client.get_share
def get_share(self, share_id): """Returns share information about known share :param share_id: id of the share to be checked :returns: instance of ShareInfo class :raises: ResponseError in case an HTTP error status was returned """ if (share_id is None) or not (isinstanc...
python
def get_share(self, share_id): """Returns share information about known share :param share_id: id of the share to be checked :returns: instance of ShareInfo class :raises: ResponseError in case an HTTP error status was returned """ if (share_id is None) or not (isinstanc...
[ "def", "get_share", "(", "self", ",", "share_id", ")", ":", "if", "(", "share_id", "is", "None", ")", "or", "not", "(", "isinstance", "(", "share_id", ",", "int", ")", ")", ":", "return", "None", "res", "=", "self", ".", "_make_ocs_request", "(", "'G...
Returns share information about known share :param share_id: id of the share to be checked :returns: instance of ShareInfo class :raises: ResponseError in case an HTTP error status was returned
[ "Returns", "share", "information", "about", "known", "share" ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L868-L887
train
owncloud/pyocclient
owncloud/owncloud.py
Client.get_shares
def get_shares(self, path='', **kwargs): """Returns array of shares :param path: path to the share to be checked :param reshares: (optional, boolean) returns not only the shares from the current user but all shares from the given file (default: False) :param subfiles: (optio...
python
def get_shares(self, path='', **kwargs): """Returns array of shares :param path: path to the share to be checked :param reshares: (optional, boolean) returns not only the shares from the current user but all shares from the given file (default: False) :param subfiles: (optio...
[ "def", "get_shares", "(", "self", ",", "path", "=", "''", ",", "**", "kwargs", ")", ":", "if", "not", "(", "isinstance", "(", "path", ",", "six", ".", "string_types", ")", ")", ":", "return", "None", "data", "=", "'shares'", "if", "path", "!=", "''...
Returns array of shares :param path: path to the share to be checked :param reshares: (optional, boolean) returns not only the shares from the current user but all shares from the given file (default: False) :param subfiles: (optional, boolean) returns all shares within ...
[ "Returns", "array", "of", "shares" ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L889-L943
train
owncloud/pyocclient
owncloud/owncloud.py
Client.create_user
def create_user(self, user_name, initial_password): """Create a new user with an initial password via provisioning API. It is not an error, if the user already existed before. If you get back an error 999, then the provisioning API is not enabled. :param user_name: name of user to be c...
python
def create_user(self, user_name, initial_password): """Create a new user with an initial password via provisioning API. It is not an error, if the user already existed before. If you get back an error 999, then the provisioning API is not enabled. :param user_name: name of user to be c...
[ "def", "create_user", "(", "self", ",", "user_name", ",", "initial_password", ")", ":", "res", "=", "self", ".", "_make_ocs_request", "(", "'POST'", ",", "self", ".", "OCS_SERVICE_CLOUD", ",", "'users'", ",", "data", "=", "{", "'password'", ":", "initial_pas...
Create a new user with an initial password via provisioning API. It is not an error, if the user already existed before. If you get back an error 999, then the provisioning API is not enabled. :param user_name: name of user to be created :param initial_password: password for user bein...
[ "Create", "a", "new", "user", "with", "an", "initial", "password", "via", "provisioning", "API", ".", "It", "is", "not", "an", "error", "if", "the", "user", "already", "existed", "before", ".", "If", "you", "get", "back", "an", "error", "999", "then", ...
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L945-L969
train
owncloud/pyocclient
owncloud/owncloud.py
Client.delete_user
def delete_user(self, user_name): """Deletes a user via provisioning API. If you get back an error 999, then the provisioning API is not enabled. :param user_name: name of user to be deleted :returns: True on success :raises: HTTPResponseError in case an HTTP error status was r...
python
def delete_user(self, user_name): """Deletes a user via provisioning API. If you get back an error 999, then the provisioning API is not enabled. :param user_name: name of user to be deleted :returns: True on success :raises: HTTPResponseError in case an HTTP error status was r...
[ "def", "delete_user", "(", "self", ",", "user_name", ")", ":", "res", "=", "self", ".", "_make_ocs_request", "(", "'DELETE'", ",", "self", ".", "OCS_SERVICE_CLOUD", ",", "'users/'", "+", "user_name", ")", "if", "res", ".", "status_code", "==", "200", ":", ...
Deletes a user via provisioning API. If you get back an error 999, then the provisioning API is not enabled. :param user_name: name of user to be deleted :returns: True on success :raises: HTTPResponseError in case an HTTP error status was returned
[ "Deletes", "a", "user", "via", "provisioning", "API", ".", "If", "you", "get", "back", "an", "error", "999", "then", "the", "provisioning", "API", "is", "not", "enabled", "." ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L971-L990
train
owncloud/pyocclient
owncloud/owncloud.py
Client.search_users
def search_users(self, user_name): """Searches for users via provisioning API. If you get back an error 999, then the provisioning API is not enabled. :param user_name: name of user to be searched for :returns: list of usernames that contain user_name as substring :raises: HTTP...
python
def search_users(self, user_name): """Searches for users via provisioning API. If you get back an error 999, then the provisioning API is not enabled. :param user_name: name of user to be searched for :returns: list of usernames that contain user_name as substring :raises: HTTP...
[ "def", "search_users", "(", "self", ",", "user_name", ")", ":", "action_path", "=", "'users'", "if", "user_name", ":", "action_path", "+=", "'?search={}'", ".", "format", "(", "user_name", ")", "res", "=", "self", ".", "_make_ocs_request", "(", "'GET'", ",",...
Searches for users via provisioning API. If you get back an error 999, then the provisioning API is not enabled. :param user_name: name of user to be searched for :returns: list of usernames that contain user_name as substring :raises: HTTPResponseError in case an HTTP error status was...
[ "Searches", "for", "users", "via", "provisioning", "API", ".", "If", "you", "get", "back", "an", "error", "999", "then", "the", "provisioning", "API", "is", "not", "enabled", "." ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L1004-L1029
train
owncloud/pyocclient
owncloud/owncloud.py
Client.set_user_attribute
def set_user_attribute(self, user_name, key, value): """Sets a user attribute :param user_name: name of user to modify :param key: key of the attribute to set :param value: value to set :returns: True if the operation succeeded, False otherwise :raises: HTTPResponseError...
python
def set_user_attribute(self, user_name, key, value): """Sets a user attribute :param user_name: name of user to modify :param key: key of the attribute to set :param value: value to set :returns: True if the operation succeeded, False otherwise :raises: HTTPResponseError...
[ "def", "set_user_attribute", "(", "self", ",", "user_name", ",", "key", ",", "value", ")", ":", "res", "=", "self", ".", "_make_ocs_request", "(", "'PUT'", ",", "self", ".", "OCS_SERVICE_CLOUD", ",", "'users/'", "+", "parse", ".", "quote", "(", "user_name"...
Sets a user attribute :param user_name: name of user to modify :param key: key of the attribute to set :param value: value to set :returns: True if the operation succeeded, False otherwise :raises: HTTPResponseError in case an HTTP error status was returned
[ "Sets", "a", "user", "attribute" ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L1041-L1063
train
owncloud/pyocclient
owncloud/owncloud.py
Client.add_user_to_group
def add_user_to_group(self, user_name, group_name): """Adds a user to a group. :param user_name: name of user to be added :param group_name: name of group user is to be added to :returns: True if user added :raises: HTTPResponseError in case an HTTP error status was returned ...
python
def add_user_to_group(self, user_name, group_name): """Adds a user to a group. :param user_name: name of user to be added :param group_name: name of group user is to be added to :returns: True if user added :raises: HTTPResponseError in case an HTTP error status was returned ...
[ "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", "=",...
Adds a user to a group. :param user_name: name of user to be added :param group_name: name of group user is to be added to :returns: True if user added :raises: HTTPResponseError in case an HTTP error status was returned
[ "Adds", "a", "user", "to", "a", "group", "." ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L1065-L1087
train
owncloud/pyocclient
owncloud/owncloud.py
Client.get_user_groups
def get_user_groups(self, user_name): """Get a list of groups associated to a user. :param user_name: name of user to list groups :returns: list of groups :raises: HTTPResponseError in case an HTTP error status was returned """ res = self._make_ocs_request( ...
python
def get_user_groups(self, user_name): """Get a list of groups associated to a user. :param user_name: name of user to list groups :returns: list of groups :raises: HTTPResponseError in case an HTTP error status was returned """ res = self._make_ocs_request( ...
[ "def", "get_user_groups", "(", "self", ",", "user_name", ")", ":", "res", "=", "self", ".", "_make_ocs_request", "(", "'GET'", ",", "self", ".", "OCS_SERVICE_CLOUD", ",", "'users/'", "+", "user_name", "+", "'/groups'", ",", ")", "if", "res", ".", "status_c...
Get a list of groups associated to a user. :param user_name: name of user to list groups :returns: list of groups :raises: HTTPResponseError in case an HTTP error status was returned
[ "Get", "a", "list", "of", "groups", "associated", "to", "a", "user", "." ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L1089-L1109
train
owncloud/pyocclient
owncloud/owncloud.py
Client.get_user
def get_user(self, user_name): """Retrieves information about a user :param user_name: name of user to query :returns: Dictionary of information about user :raises: ResponseError in case an HTTP error status was returned """ res = self._make_ocs_request( 'G...
python
def get_user(self, user_name): """Retrieves information about a user :param user_name: name of user to query :returns: Dictionary of information about user :raises: ResponseError in case an HTTP error status was returned """ res = self._make_ocs_request( 'G...
[ "def", "get_user", "(", "self", ",", "user_name", ")", ":", "res", "=", "self", ".", "_make_ocs_request", "(", "'GET'", ",", "self", ".", "OCS_SERVICE_CLOUD", ",", "'users/'", "+", "parse", ".", "quote", "(", "user_name", ")", ",", "data", "=", "{", "}...
Retrieves information about a user :param user_name: name of user to query :returns: Dictionary of information about user :raises: ResponseError in case an HTTP error status was returned
[ "Retrieves", "information", "about", "a", "user" ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L1121-L1145
train
owncloud/pyocclient
owncloud/owncloud.py
Client.get_user_subadmin_groups
def get_user_subadmin_groups(self, user_name): """Get a list of subadmin groups associated to a user. :param user_name: name of user :returns: list of subadmin groups :raises: HTTPResponseError in case an HTTP error status was returned """ res = self._make_ocs_request...
python
def get_user_subadmin_groups(self, user_name): """Get a list of subadmin groups associated to a user. :param user_name: name of user :returns: list of subadmin groups :raises: HTTPResponseError in case an HTTP error status was returned """ res = self._make_ocs_request...
[ "def", "get_user_subadmin_groups", "(", "self", ",", "user_name", ")", ":", "res", "=", "self", ".", "_make_ocs_request", "(", "'GET'", ",", "self", ".", "OCS_SERVICE_CLOUD", ",", "'users/'", "+", "user_name", "+", "'/subadmins'", ",", ")", "if", "res", ".",...
Get a list of subadmin groups associated to a user. :param user_name: name of user :returns: list of subadmin groups :raises: HTTPResponseError in case an HTTP error status was returned
[ "Get", "a", "list", "of", "subadmin", "groups", "associated", "to", "a", "user", "." ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L1194-L1217
train
owncloud/pyocclient
owncloud/owncloud.py
Client.share_file_with_user
def share_file_with_user(self, path, user, **kwargs): """Shares a remote file with specified user :param path: path to the remote file to share :param user: name of the user whom we want to share a file/folder :param perms (optional): permissions of the shared object default...
python
def share_file_with_user(self, path, user, **kwargs): """Shares a remote file with specified user :param path: path to the remote file to share :param user: name of the user whom we want to share a file/folder :param perms (optional): permissions of the shared object default...
[ "def", "share_file_with_user", "(", "self", ",", "path", ",", "user", ",", "**", "kwargs", ")", ":", "remote_user", "=", "kwargs", ".", "get", "(", "'remote_user'", ",", "False", ")", "perms", "=", "kwargs", ".", "get", "(", "'perms'", ",", "self", "."...
Shares a remote file with specified user :param path: path to the remote file to share :param user: name of the user whom we want to share a file/folder :param perms (optional): permissions of the shared object defaults to read only (1) http://doc.owncloud.org/server/6.0...
[ "Shares", "a", "remote", "file", "with", "specified", "user" ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L1229-L1281
train
owncloud/pyocclient
owncloud/owncloud.py
Client.delete_group
def delete_group(self, group_name): """Delete a group via provisioning API. If you get back an error 999, then the provisioning API is not enabled. :param group_name: name of group to be deleted :returns: True if group deleted :raises: HTTPResponseError in case an HTTP error st...
python
def delete_group(self, group_name): """Delete a group via provisioning API. If you get back an error 999, then the provisioning API is not enabled. :param group_name: name of group to be deleted :returns: True if group deleted :raises: HTTPResponseError in case an HTTP error st...
[ "def", "delete_group", "(", "self", ",", "group_name", ")", ":", "res", "=", "self", ".", "_make_ocs_request", "(", "'DELETE'", ",", "self", ".", "OCS_SERVICE_CLOUD", ",", "'groups/'", "+", "group_name", ")", "if", "res", ".", "status_code", "==", "200", "...
Delete a group via provisioning API. If you get back an error 999, then the provisioning API is not enabled. :param group_name: name of group to be deleted :returns: True if group deleted :raises: HTTPResponseError in case an HTTP error status was returned
[ "Delete", "a", "group", "via", "provisioning", "API", ".", "If", "you", "get", "back", "an", "error", "999", "then", "the", "provisioning", "API", "is", "not", "enabled", "." ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L1307-L1326
train
owncloud/pyocclient
owncloud/owncloud.py
Client.get_groups
def get_groups(self): """Get groups via provisioning API. If you get back an error 999, then the provisioning API is not enabled. :returns: list of groups :raises: HTTPResponseError in case an HTTP error status was returned """ res = self._make_ocs_request( ...
python
def get_groups(self): """Get groups via provisioning API. If you get back an error 999, then the provisioning API is not enabled. :returns: list of groups :raises: HTTPResponseError in case an HTTP error status was returned """ res = self._make_ocs_request( ...
[ "def", "get_groups", "(", "self", ")", ":", "res", "=", "self", ".", "_make_ocs_request", "(", "'GET'", ",", "self", ".", "OCS_SERVICE_CLOUD", ",", "'groups'", ")", "if", "res", ".", "status_code", "==", "200", ":", "tree", "=", "ET", ".", "fromstring", ...
Get groups via provisioning API. If you get back an error 999, then the provisioning API is not enabled. :returns: list of groups :raises: HTTPResponseError in case an HTTP error status was returned
[ "Get", "groups", "via", "provisioning", "API", ".", "If", "you", "get", "back", "an", "error", "999", "then", "the", "provisioning", "API", "is", "not", "enabled", "." ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L1328-L1348
train
owncloud/pyocclient
owncloud/owncloud.py
Client.get_group_members
def get_group_members(self, group_name): """Get group members via provisioning API. If you get back an error 999, then the provisioning API is not enabled. :param group_name: name of group to list members :returns: list of group members :raises: HTTPResponseError in case an HTT...
python
def get_group_members(self, group_name): """Get group members via provisioning API. If you get back an error 999, then the provisioning API is not enabled. :param group_name: name of group to list members :returns: list of group members :raises: HTTPResponseError in case an HTT...
[ "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", ...
Get group members via provisioning API. If you get back an error 999, then the provisioning API is not enabled. :param group_name: name of group to list members :returns: list of group members :raises: HTTPResponseError in case an HTTP error status was returned
[ "Get", "group", "members", "via", "provisioning", "API", ".", "If", "you", "get", "back", "an", "error", "999", "then", "the", "provisioning", "API", "is", "not", "enabled", "." ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L1350-L1370
train
owncloud/pyocclient
owncloud/owncloud.py
Client.group_exists
def group_exists(self, group_name): """Checks a group via provisioning API. If you get back an error 999, then the provisioning API is not enabled. :param group_name: name of group to be checked :returns: True if group exists :raises: HTTPResponseError in case an HTTP error sta...
python
def group_exists(self, group_name): """Checks a group via provisioning API. If you get back an error 999, then the provisioning API is not enabled. :param group_name: name of group to be checked :returns: True if group exists :raises: HTTPResponseError in case an HTTP error sta...
[ "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",...
Checks a group via provisioning API. If you get back an error 999, then the provisioning API is not enabled. :param group_name: name of group to be checked :returns: True if group exists :raises: HTTPResponseError in case an HTTP error status was returned
[ "Checks", "a", "group", "via", "provisioning", "API", ".", "If", "you", "get", "back", "an", "error", "999", "then", "the", "provisioning", "API", "is", "not", "enabled", "." ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L1372-L1396
train
owncloud/pyocclient
owncloud/owncloud.py
Client.share_file_with_group
def share_file_with_group(self, path, group, **kwargs): """Shares a remote file with specified group :param path: path to the remote file to share :param group: name of the group with which we want to share a file/folder :param perms (optional): permissions of the shared object ...
python
def share_file_with_group(self, path, group, **kwargs): """Shares a remote file with specified group :param path: path to the remote file to share :param group: name of the group with which we want to share a file/folder :param perms (optional): permissions of the shared object ...
[ "def", "share_file_with_group", "(", "self", ",", "path", ",", "group", ",", "**", "kwargs", ")", ":", "perms", "=", "kwargs", ".", "get", "(", "'perms'", ",", "self", ".", "OCS_PERMISSION_READ", ")", "if", "(", "(", "(", "not", "isinstance", "(", "per...
Shares a remote file with specified group :param path: path to the remote file to share :param group: name of the group with which we want to share a file/folder :param perms (optional): permissions of the shared object defaults to read only (1) http://doc.owncloud.org/s...
[ "Shares", "a", "remote", "file", "with", "specified", "group" ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L1398-L1438
train
owncloud/pyocclient
owncloud/owncloud.py
Client.get_attribute
def get_attribute(self, app=None, key=None): """Returns an application attribute :param app: application id :param key: attribute key or None to retrieve all values for the given application :returns: attribute value if key was specified, or an array of tuples (k...
python
def get_attribute(self, app=None, key=None): """Returns an application attribute :param app: application id :param key: attribute key or None to retrieve all values for the given application :returns: attribute value if key was specified, or an array of tuples (k...
[ "def", "get_attribute", "(", "self", ",", "app", "=", "None", ",", "key", "=", "None", ")", ":", "path", "=", "'getattribute'", "if", "app", "is", "not", "None", ":", "path", "+=", "'/'", "+", "parse", ".", "quote", "(", "app", ",", "''", ")", "i...
Returns an application attribute :param app: application id :param key: attribute key or None to retrieve all values for the given application :returns: attribute value if key was specified, or an array of tuples (key, value) for each attribute :raises: HTTPRespo...
[ "Returns", "an", "application", "attribute" ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L1469-L1508
train
owncloud/pyocclient
owncloud/owncloud.py
Client.set_attribute
def set_attribute(self, app, key, value): """Sets an application attribute :param app: application id :param key: key of the attribute to set :param value: value to set :returns: True if the operation succeeded, False otherwise :raises: HTTPResponseError in case an HTTP ...
python
def set_attribute(self, app, key, value): """Sets an application attribute :param app: application id :param key: key of the attribute to set :param value: value to set :returns: True if the operation succeeded, False otherwise :raises: HTTPResponseError in case an HTTP ...
[ "def", "set_attribute", "(", "self", ",", "app", ",", "key", ",", "value", ")", ":", "path", "=", "'setattribute/'", "+", "parse", ".", "quote", "(", "app", ",", "''", ")", "+", "'/'", "+", "parse", ".", "quote", "(", "self", ".", "_encode_string", ...
Sets an application attribute :param app: application id :param key: key of the attribute to set :param value: value to set :returns: True if the operation succeeded, False otherwise :raises: HTTPResponseError in case an HTTP error status was returned
[ "Sets", "an", "application", "attribute" ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L1510-L1531
train
owncloud/pyocclient
owncloud/owncloud.py
Client.get_apps
def get_apps(self): """ List all enabled apps through the provisioning api. :returns: a dict of apps, with values True/False, representing the enabled state. :raises: HTTPResponseError in case an HTTP error status was returned """ ena_apps = {} res = self._make_ocs_requ...
python
def get_apps(self): """ List all enabled apps through the provisioning api. :returns: a dict of apps, with values True/False, representing the enabled state. :raises: HTTPResponseError in case an HTTP error status was returned """ ena_apps = {} res = self._make_ocs_requ...
[ "def", "get_apps", "(", "self", ")", ":", "ena_apps", "=", "{", "}", "res", "=", "self", ".", "_make_ocs_request", "(", "'GET'", ",", "self", ".", "OCS_SERVICE_CLOUD", ",", "'apps'", ")", "if", "res", ".", "status_code", "!=", "200", ":", "raise", "HTT...
List all enabled apps through the provisioning api. :returns: a dict of apps, with values True/False, representing the enabled state. :raises: HTTPResponseError in case an HTTP error status was returned
[ "List", "all", "enabled", "apps", "through", "the", "provisioning", "api", "." ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L1554-L1580
train
owncloud/pyocclient
owncloud/owncloud.py
Client.enable_app
def enable_app(self, appname): """Enable an app through provisioning_api :param appname: Name of app to be enabled :returns: True if the operation succeeded, False otherwise :raises: HTTPResponseError in case an HTTP error status was returned """ res = self._make_ocs_r...
python
def enable_app(self, appname): """Enable an app through provisioning_api :param appname: Name of app to be enabled :returns: True if the operation succeeded, False otherwise :raises: HTTPResponseError in case an HTTP error status was returned """ res = self._make_ocs_r...
[ "def", "enable_app", "(", "self", ",", "appname", ")", ":", "res", "=", "self", ".", "_make_ocs_request", "(", "'POST'", ",", "self", ".", "OCS_SERVICE_CLOUD", ",", "'apps/'", "+", "appname", ")", "if", "res", ".", "status_code", "==", "200", ":", "retur...
Enable an app through provisioning_api :param appname: Name of app to be enabled :returns: True if the operation succeeded, False otherwise :raises: HTTPResponseError in case an HTTP error status was returned
[ "Enable", "an", "app", "through", "provisioning_api" ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L1601-L1614
train
owncloud/pyocclient
owncloud/owncloud.py
Client._encode_string
def _encode_string(s): """Encodes a unicode instance to utf-8. If a str is passed it will simply be returned :param s: str or unicode to encode :returns: encoded output as str """ if six.PY2 and isinstance(s, unicode): return s.encode('utf-8') return ...
python
def _encode_string(s): """Encodes a unicode instance to utf-8. If a str is passed it will simply be returned :param s: str or unicode to encode :returns: encoded output as str """ if six.PY2 and isinstance(s, unicode): return s.encode('utf-8') return ...
[ "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 simply be returned :param s: str or unicode to encode :returns: encoded output as str
[ "Encodes", "a", "unicode", "instance", "to", "utf", "-", "8", ".", "If", "a", "str", "is", "passed", "it", "will", "simply", "be", "returned" ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L1644-L1653
train
owncloud/pyocclient
owncloud/owncloud.py
Client._check_ocs_status
def _check_ocs_status(tree, accepted_codes=[100]): """Checks the status code of an OCS request :param tree: response parsed with elementtree :param accepted_codes: list of statuscodes we consider good. E.g. [100,102] can be used to accept a POST returning an 'already exists' cond...
python
def _check_ocs_status(tree, accepted_codes=[100]): """Checks the status code of an OCS request :param tree: response parsed with elementtree :param accepted_codes: list of statuscodes we consider good. E.g. [100,102] can be used to accept a POST returning an 'already exists' cond...
[ "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", ")", "n...
Checks the status code of an OCS request :param tree: response parsed with elementtree :param accepted_codes: list of statuscodes we consider good. E.g. [100,102] can be used to accept a POST returning an 'already exists' condition :raises: HTTPResponseError if the http status is...
[ "Checks", "the", "status", "code", "of", "an", "OCS", "request" ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L1656-L1672
train
owncloud/pyocclient
owncloud/owncloud.py
Client.make_ocs_request
def make_ocs_request(self, method, service, action, **kwargs): """Makes a OCS API request and analyses the response :param method: HTTP method :param service: service name :param action: action path :param \*\*kwargs: optional arguments that ``requests.Request.request`` accepts ...
python
def make_ocs_request(self, method, service, action, **kwargs): """Makes a OCS API request and analyses the response :param method: HTTP method :param service: service name :param action: action path :param \*\*kwargs: optional arguments that ``requests.Request.request`` accepts ...
[ "def", "make_ocs_request", "(", "self", ",", "method", ",", "service", ",", "action", ",", "**", "kwargs", ")", ":", "accepted_codes", "=", "kwargs", ".", "pop", "(", "'accepted_codes'", ",", "[", "100", "]", ")", "res", "=", "self", ".", "_make_ocs_requ...
Makes a OCS API request and analyses the response :param method: HTTP method :param service: service name :param action: action path :param \*\*kwargs: optional arguments that ``requests.Request.request`` accepts :returns :class:`requests.Response` instance
[ "Makes", "a", "OCS", "API", "request", "and", "analyses", "the", "response" ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L1674-L1692
train
owncloud/pyocclient
owncloud/owncloud.py
Client._make_ocs_request
def _make_ocs_request(self, method, service, action, **kwargs): """Makes a OCS API request :param method: HTTP method :param service: service name :param action: action path :param \*\*kwargs: optional arguments that ``requests.Request.request`` accepts :returns :class:`...
python
def _make_ocs_request(self, method, service, action, **kwargs): """Makes a OCS API request :param method: HTTP method :param service: service name :param action: action path :param \*\*kwargs: optional arguments that ``requests.Request.request`` accepts :returns :class:`...
[ "def", "_make_ocs_request", "(", "self", ",", "method", ",", "service", ",", "action", ",", "**", "kwargs", ")", ":", "slash", "=", "''", "if", "service", ":", "slash", "=", "'/'", "path", "=", "self", ".", "OCS_BASEPATH", "+", "service", "+", "slash",...
Makes a OCS API request :param method: HTTP method :param service: service name :param action: action path :param \*\*kwargs: optional arguments that ``requests.Request.request`` accepts :returns :class:`requests.Response` instance
[ "Makes", "a", "OCS", "API", "request" ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L1694-L1720
train
owncloud/pyocclient
owncloud/owncloud.py
Client._make_dav_request
def _make_dav_request(self, method, path, **kwargs): """Makes a WebDAV request :param method: HTTP method :param path: remote path of the targetted file :param \*\*kwargs: optional arguments that ``requests.Request.request`` accepts :returns array of :class:`FileInfo` if the res...
python
def _make_dav_request(self, method, path, **kwargs): """Makes a WebDAV request :param method: HTTP method :param path: remote path of the targetted file :param \*\*kwargs: optional arguments that ``requests.Request.request`` accepts :returns array of :class:`FileInfo` if the res...
[ "def", "_make_dav_request", "(", "self", ",", "method", ",", "path", ",", "**", "kwargs", ")", ":", "if", "self", ".", "_debug", ":", "print", "(", "'DAV request: %s %s'", "%", "(", "method", ",", "path", ")", ")", "if", "kwargs", ".", "get", "(", "'...
Makes a WebDAV request :param method: HTTP method :param path: remote path of the targetted file :param \*\*kwargs: optional arguments that ``requests.Request.request`` accepts :returns array of :class:`FileInfo` if the response contains it, or True if the operation succeded, Fa...
[ "Makes", "a", "WebDAV", "request" ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L1722-L1749
train
owncloud/pyocclient
owncloud/owncloud.py
Client._parse_dav_response
def _parse_dav_response(self, res): """Parses the DAV responses from a multi-status response :param res: DAV response :returns array of :class:`FileInfo` or False if the operation did not succeed """ if res.status_code == 207: tree = ET.fromstring(res.content...
python
def _parse_dav_response(self, res): """Parses the DAV responses from a multi-status response :param res: DAV response :returns array of :class:`FileInfo` or False if the operation did not succeed """ if res.status_code == 207: tree = ET.fromstring(res.content...
[ "def", "_parse_dav_response", "(", "self", ",", "res", ")", ":", "if", "res", ".", "status_code", "==", "207", ":", "tree", "=", "ET", ".", "fromstring", "(", "res", ".", "content", ")", "items", "=", "[", "]", "for", "child", "in", "tree", ":", "i...
Parses the DAV responses from a multi-status response :param res: DAV response :returns array of :class:`FileInfo` or False if the operation did not succeed
[ "Parses", "the", "DAV", "responses", "from", "a", "multi", "-", "status", "response" ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L1751-L1764
train
owncloud/pyocclient
owncloud/owncloud.py
Client._parse_dav_element
def _parse_dav_element(self, dav_response): """Parses a single DAV element :param dav_response: DAV response :returns :class:`FileInfo` """ href = parse.unquote( self._strip_dav_path(dav_response.find('{DAV:}href').text) ) if six.PY2: hre...
python
def _parse_dav_element(self, dav_response): """Parses a single DAV element :param dav_response: DAV response :returns :class:`FileInfo` """ href = parse.unquote( self._strip_dav_path(dav_response.find('{DAV:}href').text) ) if six.PY2: hre...
[ "def", "_parse_dav_element", "(", "self", ",", "dav_response", ")", ":", "href", "=", "parse", ".", "unquote", "(", "self", ".", "_strip_dav_path", "(", "dav_response", ".", "find", "(", "'{DAV:}href'", ")", ".", "text", ")", ")", "if", "six", ".", "PY2"...
Parses a single DAV element :param dav_response: DAV response :returns :class:`FileInfo`
[ "Parses", "a", "single", "DAV", "element" ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L1766-L1789
train
owncloud/pyocclient
owncloud/owncloud.py
Client._webdav_move_copy
def _webdav_move_copy(self, remote_path_source, remote_path_target, operation): """Copies or moves a remote file or directory :param remote_path_source: source file or folder to copy / move :param remote_path_target: target file to which to copy / move :param ...
python
def _webdav_move_copy(self, remote_path_source, remote_path_target, operation): """Copies or moves a remote file or directory :param remote_path_source: source file or folder to copy / move :param remote_path_target: target file to which to copy / move :param ...
[ "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...
Copies or moves a remote file or directory :param remote_path_source: source file or folder to copy / move :param remote_path_target: target file to which to copy / move :param operation: MOVE or COPY :returns: True if the operation succeeded, False otherwise :raises: HTTPRespo...
[ "Copies", "or", "moves", "a", "remote", "file", "or", "directory" ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L1801-L1832
train
owncloud/pyocclient
owncloud/owncloud.py
Client._xml_to_dict
def _xml_to_dict(self, element): """ Take an XML element, iterate over it and build a dict :param element: An xml.etree.ElementTree.Element, or a list of the same :returns: A dictionary """ return_dict = {} for el in element: return_dict[el.tag] = Non...
python
def _xml_to_dict(self, element): """ Take an XML element, iterate over it and build a dict :param element: An xml.etree.ElementTree.Element, or a list of the same :returns: A dictionary """ return_dict = {} for el in element: return_dict[el.tag] = Non...
[ "def", "_xml_to_dict", "(", "self", ",", "element", ")", ":", "return_dict", "=", "{", "}", "for", "el", "in", "element", ":", "return_dict", "[", "el", ".", "tag", "]", "=", "None", "children", "=", "el", ".", "getchildren", "(", ")", "if", "childre...
Take an XML element, iterate over it and build a dict :param element: An xml.etree.ElementTree.Element, or a list of the same :returns: A dictionary
[ "Take", "an", "XML", "element", "iterate", "over", "it", "and", "build", "a", "dict" ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L1834-L1849
train
owncloud/pyocclient
owncloud/owncloud.py
Client._get_shareinfo
def _get_shareinfo(self, data_el): """Simple helper which returns instance of ShareInfo class :param data_el: 'data' element extracted from _make_ocs_request :returns: instance of ShareInfo class """ if (data_el is None) or not (isinstance(data_el, ET.Element)): retu...
python
def _get_shareinfo(self, data_el): """Simple helper which returns instance of ShareInfo class :param data_el: 'data' element extracted from _make_ocs_request :returns: instance of ShareInfo class """ if (data_el is None) or not (isinstance(data_el, ET.Element)): retu...
[ "def", "_get_shareinfo", "(", "self", ",", "data_el", ")", ":", "if", "(", "data_el", "is", "None", ")", "or", "not", "(", "isinstance", "(", "data_el", ",", "ET", ".", "Element", ")", ")", ":", "return", "None", "return", "ShareInfo", "(", "self", "...
Simple helper which returns instance of ShareInfo class :param data_el: 'data' element extracted from _make_ocs_request :returns: instance of ShareInfo class
[ "Simple", "helper", "which", "returns", "instance", "of", "ShareInfo", "class" ]
b9e1f04cdbde74588e86f1bebb6144571d82966c
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L1851-L1859
train
dgovil/PySignal
PySignal.py
Signal.emit
def emit(self, *args, **kwargs): """ Calls all the connected slots with the provided args and kwargs unless block is activated """ if self._block: return for slot in self._slots: if not slot: continue elif isinstance(slot, par...
python
def emit(self, *args, **kwargs): """ Calls all the connected slots with the provided args and kwargs unless block is activated """ if self._block: return for slot in self._slots: if not slot: continue elif isinstance(slot, par...
[ "def", "emit", "(", "self", ",", "*", "args", ",", "**", "kwargs", ")", ":", "if", "self", ".", "_block", ":", "return", "for", "slot", "in", "self", ".", "_slots", ":", "if", "not", "slot", ":", "continue", "elif", "isinstance", "(", "slot", ",", ...
Calls all the connected slots with the provided args and kwargs unless block is activated
[ "Calls", "all", "the", "connected", "slots", "with", "the", "provided", "args", "and", "kwargs", "unless", "block", "is", "activated" ]
72f4ced949f81e5438bd8f15247ef7890e8cc5ff
https://github.com/dgovil/PySignal/blob/72f4ced949f81e5438bd8f15247ef7890e8cc5ff/PySignal.py#L25-L49
train
dgovil/PySignal
PySignal.py
Signal.connect
def connect(self, slot): """ Connects the signal to any callable object """ 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'...
python
def connect(self, slot): """ Connects the signal to any callable object """ 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'...
[ "def", "connect", "(", "self", ",", "slot", ")", ":", "if", "not", "callable", "(", "slot", ")", ":", "raise", "ValueError", "(", "\"Connection to non-callable '%s' object failed\"", "%", "slot", ".", "__class__", ".", "__name__", ")", "if", "(", "isinstance",...
Connects the signal to any callable object
[ "Connects", "the", "signal", "to", "any", "callable", "object" ]
72f4ced949f81e5438bd8f15247ef7890e8cc5ff
https://github.com/dgovil/PySignal/blob/72f4ced949f81e5438bd8f15247ef7890e8cc5ff/PySignal.py#L51-L73
train
dgovil/PySignal
PySignal.py
Signal.disconnect
def disconnect(self, slot): """ Disconnects the slot from the signal """ 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: ...
python
def disconnect(self, slot): """ Disconnects the slot from the signal """ 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: ...
[ "def", "disconnect", "(", "self", ",", "slot", ")", ":", "if", "not", "callable", "(", "slot", ")", ":", "return", "if", "inspect", ".", "ismethod", "(", "slot", ")", ":", "slotSelf", "=", "slot", ".", "__self__", "for", "s", "in", "self", ".", "_s...
Disconnects the slot from the signal
[ "Disconnects", "the", "slot", "from", "the", "signal" ]
72f4ced949f81e5438bd8f15247ef7890e8cc5ff
https://github.com/dgovil/PySignal/blob/72f4ced949f81e5438bd8f15247ef7890e8cc5ff/PySignal.py#L75-L100
train
dgovil/PySignal
PySignal.py
SignalFactory.block
def block(self, signals=None, isBlocked=True): """ Sets the block on any provided signals, or to all signals :param signals: defaults to all signals. Accepts either a single string or a list of strings :param isBlocked: the state to set the signal to """ if signals: ...
python
def block(self, signals=None, isBlocked=True): """ Sets the block on any provided signals, or to all signals :param signals: defaults to all signals. Accepts either a single string or a list of strings :param isBlocked: the state to set the signal to """ if signals: ...
[ "def", "block", "(", "self", ",", "signals", "=", "None", ",", "isBlocked", "=", "True", ")", ":", "if", "signals", ":", "try", ":", "if", "isinstance", "(", "signals", ",", "basestring", ")", ":", "signals", "=", "[", "signals", "]", "except", "Name...
Sets the block on any provided signals, or to all signals :param signals: defaults to all signals. Accepts either a single string or a list of strings :param isBlocked: the state to set the signal to
[ "Sets", "the", "block", "on", "any", "provided", "signals", "or", "to", "all", "signals" ]
72f4ced949f81e5438bd8f15247ef7890e8cc5ff
https://github.com/dgovil/PySignal/blob/72f4ced949f81e5438bd8f15247ef7890e8cc5ff/PySignal.py#L167-L187
train
craffel/mir_eval
mir_eval/io.py
_open
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, an `IOError` is raised. ''' if hasattr...
python
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, an `IOError` is raised. ''' if hasattr...
[ "def", "_open", "(", "file_or_str", ",", "**", "kwargs", ")", ":", "if", "hasattr", "(", "file_or_str", ",", "'read'", ")", ":", "yield", "file_or_str", "elif", "isinstance", "(", "file_or_str", ",", "six", ".", "string_types", ")", ":", "with", "open", ...
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, an `IOError` is raised.
[ "Either", "open", "a", "file", "handle", "or", "use", "an", "existing", "file", "-", "like", "object", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/io.py#L18-L33
train
craffel/mir_eval
mir_eval/io.py
load_delimited
def load_delimited(filename, converters, delimiter=r'\s+'): r"""Utility function for loading in data from an annotation file where columns are delimited. The number of columns is inferred from the length of the provided converters list. Examples -------- >>> # Load in a one-column list of even...
python
def load_delimited(filename, converters, delimiter=r'\s+'): r"""Utility function for loading in data from an annotation file where columns are delimited. The number of columns is inferred from the length of the provided converters list. Examples -------- >>> # Load in a one-column list of even...
[ "def", "load_delimited", "(", "filename", ",", "converters", ",", "delimiter", "=", "r'\\s+'", ")", ":", "r", "n_columns", "=", "len", "(", "converters", ")", "columns", "=", "tuple", "(", "list", "(", ")", "for", "_", "in", "range", "(", "n_columns", ...
r"""Utility function for loading in data from an annotation file where columns are delimited. The number of columns is inferred from the length of the provided converters list. Examples -------- >>> # Load in a one-column list of event times (floats) >>> load_delimited('events.txt', [float]) ...
[ "r", "Utility", "function", "for", "loading", "in", "data", "from", "an", "annotation", "file", "where", "columns", "are", "delimited", ".", "The", "number", "of", "columns", "is", "inferred", "from", "the", "length", "of", "the", "provided", "converters", "...
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/io.py#L36-L105
train
craffel/mir_eval
mir_eval/io.py
load_events
def load_events(filename, delimiter=r'\s+'): r"""Import time-stamp events from an annotation file. The file should consist of a single column of numeric values corresponding to the event times. This is primarily useful for processing events which lack duration, such as beats or onsets. Parameters ...
python
def load_events(filename, delimiter=r'\s+'): r"""Import time-stamp events from an annotation file. The file should consist of a single column of numeric values corresponding to the event times. This is primarily useful for processing events which lack duration, such as beats or onsets. Parameters ...
[ "def", "load_events", "(", "filename", ",", "delimiter", "=", "r'\\s+'", ")", ":", "r", "events", "=", "load_delimited", "(", "filename", ",", "[", "float", "]", ",", "delimiter", ")", "events", "=", "np", ".", "array", "(", "events", ")", "try", ":", ...
r"""Import time-stamp events from an annotation file. The file should consist of a single column of numeric values corresponding to the event times. This is primarily useful for processing events which lack duration, such as beats or onsets. Parameters ---------- filename : str Path to...
[ "r", "Import", "time", "-", "stamp", "events", "from", "an", "annotation", "file", ".", "The", "file", "should", "consist", "of", "a", "single", "column", "of", "numeric", "values", "corresponding", "to", "the", "event", "times", ".", "This", "is", "primar...
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/io.py#L108-L137
train
craffel/mir_eval
mir_eval/io.py
load_labeled_events
def load_labeled_events(filename, delimiter=r'\s+'): r"""Import labeled time-stamp events from an annotation file. The file should consist of two columns; the first having numeric values corresponding to the event times and the second having string labels for each event. This is primarily useful for p...
python
def load_labeled_events(filename, delimiter=r'\s+'): r"""Import labeled time-stamp events from an annotation file. The file should consist of two columns; the first having numeric values corresponding to the event times and the second having string labels for each event. This is primarily useful for p...
[ "def", "load_labeled_events", "(", "filename", ",", "delimiter", "=", "r'\\s+'", ")", ":", "r", "events", ",", "labels", "=", "load_delimited", "(", "filename", ",", "[", "float", ",", "str", "]", ",", "delimiter", ")", "events", "=", "np", ".", "array",...
r"""Import labeled time-stamp events from an annotation file. The file should consist of two columns; the first having numeric values corresponding to the event times and the second having string labels for each event. This is primarily useful for processing labeled events which lack duration, such as...
[ "r", "Import", "labeled", "time", "-", "stamp", "events", "from", "an", "annotation", "file", ".", "The", "file", "should", "consist", "of", "two", "columns", ";", "the", "first", "having", "numeric", "values", "corresponding", "to", "the", "event", "times",...
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/io.py#L140-L172
train
craffel/mir_eval
mir_eval/io.py
load_time_series
def load_time_series(filename, delimiter=r'\s+'): r"""Import a time series from an annotation file. The file should consist of two columns of numeric values corresponding to the time and value of each sample of the time series. Parameters ---------- filename : str Path to the annotatio...
python
def load_time_series(filename, delimiter=r'\s+'): r"""Import a time series from an annotation file. The file should consist of two columns of numeric values corresponding to the time and value of each sample of the time series. Parameters ---------- filename : str Path to the annotatio...
[ "def", "load_time_series", "(", "filename", ",", "delimiter", "=", "r'\\s+'", ")", ":", "r", "times", ",", "values", "=", "load_delimited", "(", "filename", ",", "[", "float", ",", "float", "]", ",", "delimiter", ")", "times", "=", "np", ".", "array", ...
r"""Import a time series from an annotation file. The file should consist of two columns of numeric values corresponding to the time and value of each sample of the time series. Parameters ---------- filename : str Path to the annotation file delimiter : str Separator regular e...
[ "r", "Import", "a", "time", "series", "from", "an", "annotation", "file", ".", "The", "file", "should", "consist", "of", "two", "columns", "of", "numeric", "values", "corresponding", "to", "the", "time", "and", "value", "of", "each", "sample", "of", "the",...
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/io.py#L245-L271
train
craffel/mir_eval
mir_eval/io.py
load_wav
def load_wav(path, mono=True): """Loads a .wav file as a numpy array using ``scipy.io.wavfile``. Parameters ---------- path : str Path to a .wav file mono : bool If the provided .wav has more than one channel, it will be converted to mono if ``mono=True``. (Default value = T...
python
def load_wav(path, mono=True): """Loads a .wav file as a numpy array using ``scipy.io.wavfile``. Parameters ---------- path : str Path to a .wav file mono : bool If the provided .wav has more than one channel, it will be converted to mono if ``mono=True``. (Default value = T...
[ "def", "load_wav", "(", "path", ",", "mono", "=", "True", ")", ":", "fs", ",", "audio_data", "=", "scipy", ".", "io", ".", "wavfile", ".", "read", "(", "path", ")", "if", "audio_data", ".", "dtype", "==", "'int8'", ":", "audio_data", "=", "audio_data...
Loads a .wav file as a numpy array using ``scipy.io.wavfile``. Parameters ---------- path : str Path to a .wav file mono : bool If the provided .wav has more than one channel, it will be converted to mono if ``mono=True``. (Default value = True) Returns ------- audi...
[ "Loads", "a", ".", "wav", "file", "as", "a", "numpy", "array", "using", "scipy", ".", "io", ".", "wavfile", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/io.py#L353-L387
train
craffel/mir_eval
mir_eval/io.py
load_ragged_time_series
def load_ragged_time_series(filename, dtype=float, delimiter=r'\s+', header=False): r"""Utility function for loading in data from a delimited time series annotation file with a variable number of columns. Assumes that column 0 contains time stamps and columns 1 through n contain ...
python
def load_ragged_time_series(filename, dtype=float, delimiter=r'\s+', header=False): r"""Utility function for loading in data from a delimited time series annotation file with a variable number of columns. Assumes that column 0 contains time stamps and columns 1 through n contain ...
[ "def", "load_ragged_time_series", "(", "filename", ",", "dtype", "=", "float", ",", "delimiter", "=", "r'\\s+'", ",", "header", "=", "False", ")", ":", "r", "times", "=", "[", "]", "values", "=", "[", "]", "splitter", "=", "re", ".", "compile", "(", ...
r"""Utility function for loading in data from a delimited time series annotation file with a variable number of columns. Assumes that column 0 contains time stamps and columns 1 through n contain values. n may be variable from time stamp to time stamp. Examples -------- >>> # Load a ragged list...
[ "r", "Utility", "function", "for", "loading", "in", "data", "from", "a", "delimited", "time", "series", "annotation", "file", "with", "a", "variable", "number", "of", "columns", ".", "Assumes", "that", "column", "0", "contains", "time", "stamps", "and", "col...
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/io.py#L511-L583
train
craffel/mir_eval
mir_eval/chord.py
pitch_class_to_semitone
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 class. ''' semitone = 0 for idx...
python
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 class. ''' semitone = 0 for idx...
[ "def", "pitch_class_to_semitone", "(", "pitch_class", ")", ":", "r", "semitone", "=", "0", "for", "idx", ",", "char", "in", "enumerate", "(", "pitch_class", ")", ":", "if", "char", "==", "'#'", "and", "idx", ">", "0", ":", "semitone", "+=", "1", "elif"...
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 class.
[ "r", "Convert", "a", "pitch", "class", "to", "semitone", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/chord.py#L143-L168
train
craffel/mir_eval
mir_eval/chord.py
scale_degree_to_semitone
def scale_degree_to_semitone(scale_degree): r"""Convert a scale degree to semitone. Parameters ---------- scale degree : str Spelling of a relative scale degree, e.g. 'b3', '7', '#5' Returns ------- semitone : int Relative semitone of the scale degree, wrapped to a single o...
python
def scale_degree_to_semitone(scale_degree): r"""Convert a scale degree to semitone. Parameters ---------- scale degree : str Spelling of a relative scale degree, e.g. 'b3', '7', '#5' Returns ------- semitone : int Relative semitone of the scale degree, wrapped to a single o...
[ "def", "scale_degree_to_semitone", "(", "scale_degree", ")", ":", "r", "semitone", "=", "0", "offset", "=", "0", "if", "scale_degree", ".", "startswith", "(", "\"#\"", ")", ":", "offset", "=", "scale_degree", ".", "count", "(", "\"#\"", ")", "scale_degree", ...
r"""Convert a scale degree to semitone. Parameters ---------- scale degree : str Spelling of a relative scale degree, e.g. 'b3', '7', '#5' Returns ------- semitone : int Relative semitone of the scale degree, wrapped to a single octave Raises ------ InvalidChordExc...
[ "r", "Convert", "a", "scale", "degree", "to", "semitone", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/chord.py#L175-L206
train
craffel/mir_eval
mir_eval/chord.py
scale_degree_to_bitmap
def scale_degree_to_bitmap(scale_degree, modulo=False, length=BITMAP_LENGTH): """Create a bitmap representation of a scale degree. Note that values in the bitmap may be negative, indicating that the semitone is to be removed. Parameters ---------- scale_degree : str Spelling of a relat...
python
def scale_degree_to_bitmap(scale_degree, modulo=False, length=BITMAP_LENGTH): """Create a bitmap representation of a scale degree. Note that values in the bitmap may be negative, indicating that the semitone is to be removed. Parameters ---------- scale_degree : str Spelling of a relat...
[ "def", "scale_degree_to_bitmap", "(", "scale_degree", ",", "modulo", "=", "False", ",", "length", "=", "BITMAP_LENGTH", ")", ":", "sign", "=", "1", "if", "scale_degree", ".", "startswith", "(", "\"*\"", ")", ":", "sign", "=", "-", "1", "scale_degree", "=",...
Create a bitmap representation of a scale degree. Note that values in the bitmap may be negative, indicating that the semitone is to be removed. Parameters ---------- scale_degree : str Spelling of a relative scale degree, e.g. 'b3', '7', '#5' modulo : bool, default=True If a s...
[ "Create", "a", "bitmap", "representation", "of", "a", "scale", "degree", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/chord.py#L209-L238
train
craffel/mir_eval
mir_eval/chord.py
quality_to_bitmap
def quality_to_bitmap(quality): """Return the bitmap for a given quality. Parameters ---------- quality : str Chord quality name. Returns ------- bitmap : np.ndarray Bitmap representation of this quality (12-dim). """ if quality not in QUALITIES: raise Inva...
python
def quality_to_bitmap(quality): """Return the bitmap for a given quality. Parameters ---------- quality : str Chord quality name. Returns ------- bitmap : np.ndarray Bitmap representation of this quality (12-dim). """ if quality not in QUALITIES: raise Inva...
[ "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",...
Return the bitmap for a given quality. Parameters ---------- quality : str Chord quality name. Returns ------- bitmap : np.ndarray Bitmap representation of this quality (12-dim).
[ "Return", "the", "bitmap", "for", "a", "given", "quality", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/chord.py#L276-L294
train
craffel/mir_eval
mir_eval/chord.py
validate_chord_label
def validate_chord_label(chord_label): """Test for well-formedness of a chord label. Parameters ---------- chord : str Chord label to validate. """ # This monster regexp is pulled from the JAMS chord namespace, # which is in turn derived from the context-free grammar of # Hart...
python
def validate_chord_label(chord_label): """Test for well-formedness of a chord label. Parameters ---------- chord : str Chord label to validate. """ # This monster regexp is pulled from the JAMS chord namespace, # which is in turn derived from the context-free grammar of # Hart...
[ "def", "validate_chord_label", "(", "chord_label", ")", ":", "pattern", "=", "re", ".", "compile", "(", "r", ")", "if", "not", "pattern", ".", "match", "(", "chord_label", ")", ":", "raise", "InvalidChordException", "(", "'Invalid chord label: '", "'{}'", ".",...
Test for well-formedness of a chord label. Parameters ---------- chord : str Chord label to validate.
[ "Test", "for", "well", "-", "formedness", "of", "a", "chord", "label", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/chord.py#L338-L357
train
craffel/mir_eval
mir_eval/chord.py
join
def join(chord_root, quality='', extensions=None, bass=''): r"""Join the parts of a chord into a complete chord label. Parameters ---------- chord_root : str Root pitch class of the chord, e.g. 'C', 'Eb' quality : str Quality of the chord, e.g. 'maj', 'hdim7' (Default value ...
python
def join(chord_root, quality='', extensions=None, bass=''): r"""Join the parts of a chord into a complete chord label. Parameters ---------- chord_root : str Root pitch class of the chord, e.g. 'C', 'Eb' quality : str Quality of the chord, e.g. 'maj', 'hdim7' (Default value ...
[ "def", "join", "(", "chord_root", ",", "quality", "=", "''", ",", "extensions", "=", "None", ",", "bass", "=", "''", ")", ":", "r", "chord_label", "=", "chord_root", "if", "quality", "or", "extensions", ":", "chord_label", "+=", "\":%s\"", "%", "quality"...
r"""Join the parts of a chord into a complete chord label. Parameters ---------- chord_root : str Root pitch class of the chord, e.g. 'C', 'Eb' quality : str Quality of the chord, e.g. 'maj', 'hdim7' (Default value = '') extensions : list Any added or absent scaled d...
[ "r", "Join", "the", "parts", "of", "a", "chord", "into", "a", "complete", "chord", "label", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/chord.py#L434-L465
train
craffel/mir_eval
mir_eval/chord.py
encode
def encode(chord_label, reduce_extended_chords=False, strict_bass_intervals=False): """Translate a chord label to numerical representations for evaluation. Parameters ---------- chord_label : str Chord label to encode. reduce_extended_chords : bool Whether to map the uppe...
python
def encode(chord_label, reduce_extended_chords=False, strict_bass_intervals=False): """Translate a chord label to numerical representations for evaluation. Parameters ---------- chord_label : str Chord label to encode. reduce_extended_chords : bool Whether to map the uppe...
[ "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", ...
Translate a chord label to numerical representations for evaluation. Parameters ---------- chord_label : str Chord label to encode. reduce_extended_chords : bool Whether to map the upper voicings of extended chords (9's, 11's, 13's) to semitone extensions. (Default value...
[ "Translate", "a", "chord", "label", "to", "numerical", "representations", "for", "evaluation", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/chord.py#L469-L520
train
craffel/mir_eval
mir_eval/chord.py
encode_many
def encode_many(chord_labels, reduce_extended_chords=False): """Translate a set of chord labels to numerical representations for sane evaluation. Parameters ---------- chord_labels : list Set of chord labels to encode. reduce_extended_chords : bool Whether to map the upper voici...
python
def encode_many(chord_labels, reduce_extended_chords=False): """Translate a set of chord labels to numerical representations for sane evaluation. Parameters ---------- chord_labels : list Set of chord labels to encode. reduce_extended_chords : bool Whether to map the upper voici...
[ "def", "encode_many", "(", "chord_labels", ",", "reduce_extended_chords", "=", "False", ")", ":", "num_items", "=", "len", "(", "chord_labels", ")", "roots", ",", "basses", "=", "np", ".", "zeros", "(", "[", "2", ",", "num_items", "]", ",", "dtype", "=",...
Translate a set of chord labels to numerical representations for sane evaluation. Parameters ---------- chord_labels : list Set of chord labels to encode. reduce_extended_chords : bool Whether to map the upper voicings of extended chords (9's, 11's, 13's) to semitone extensi...
[ "Translate", "a", "set", "of", "chord", "labels", "to", "numerical", "representations", "for", "sane", "evaluation", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/chord.py#L523-L556
train
craffel/mir_eval
mir_eval/chord.py
rotate_bitmap_to_root
def rotate_bitmap_to_root(bitmap, chord_root): """Circularly shift a relative bitmap to its asbolute pitch classes. For clarity, the best explanation is an example. Given 'G:Maj', the root and quality map are as follows:: root=5 quality=[1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0] # Relative chor...
python
def rotate_bitmap_to_root(bitmap, chord_root): """Circularly shift a relative bitmap to its asbolute pitch classes. For clarity, the best explanation is an example. Given 'G:Maj', the root and quality map are as follows:: root=5 quality=[1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0] # Relative chor...
[ "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"...
Circularly shift a relative bitmap to its asbolute pitch classes. For clarity, the best explanation is an example. Given 'G:Maj', the root and quality map are as follows:: root=5 quality=[1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0] # Relative chord shape After rotating to the root, the resulting...
[ "Circularly", "shift", "a", "relative", "bitmap", "to", "its", "asbolute", "pitch", "classes", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/chord.py#L559-L591
train
craffel/mir_eval
mir_eval/chord.py
rotate_bitmaps_to_roots
def rotate_bitmaps_to_roots(bitmaps, roots): """Circularly shift a relative bitmaps to asbolute pitch classes. See :func:`rotate_bitmap_to_root` for more information. Parameters ---------- bitmap : np.ndarray, shape=(N, 12) Bitmap of active notes, relative to the given root. root : np....
python
def rotate_bitmaps_to_roots(bitmaps, roots): """Circularly shift a relative bitmaps to asbolute pitch classes. See :func:`rotate_bitmap_to_root` for more information. Parameters ---------- bitmap : np.ndarray, shape=(N, 12) Bitmap of active notes, relative to the given root. root : np....
[ "def", "rotate_bitmaps_to_roots", "(", "bitmaps", ",", "roots", ")", ":", "abs_bitmaps", "=", "[", "]", "for", "bitmap", ",", "chord_root", "in", "zip", "(", "bitmaps", ",", "roots", ")", ":", "abs_bitmaps", ".", "append", "(", "rotate_bitmap_to_root", "(", ...
Circularly shift a relative bitmaps to asbolute pitch classes. See :func:`rotate_bitmap_to_root` for more information. Parameters ---------- bitmap : np.ndarray, shape=(N, 12) Bitmap of active notes, relative to the given root. root : np.ndarray, shape=(N,) Absolute pitch class num...
[ "Circularly", "shift", "a", "relative", "bitmaps", "to", "asbolute", "pitch", "classes", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/chord.py#L594-L615
train
craffel/mir_eval
mir_eval/chord.py
validate
def validate(reference_labels, estimated_labels): """Checks that the input annotations to a comparison function look like valid chord labels. Parameters ---------- reference_labels : list, len=n Reference chord labels to score against. estimated_labels : list, len=n Estimated ch...
python
def validate(reference_labels, estimated_labels): """Checks that the input annotations to a comparison function look like valid chord labels. Parameters ---------- reference_labels : list, len=n Reference chord labels to score against. estimated_labels : list, len=n Estimated ch...
[ "def", "validate", "(", "reference_labels", ",", "estimated_labels", ")", ":", "N", "=", "len", "(", "reference_labels", ")", "M", "=", "len", "(", "estimated_labels", ")", "if", "N", "!=", "M", ":", "raise", "ValueError", "(", "\"Chord comparison received dif...
Checks that the input annotations to a comparison function look like valid chord labels. Parameters ---------- reference_labels : list, len=n Reference chord labels to score against. estimated_labels : list, len=n Estimated chord labels to score against.
[ "Checks", "that", "the", "input", "annotations", "to", "a", "comparison", "function", "look", "like", "valid", "chord", "labels", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/chord.py#L619-L644
train
craffel/mir_eval
mir_eval/chord.py
weighted_accuracy
def weighted_accuracy(comparisons, weights): """Compute the weighted accuracy of a list of chord comparisons. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab') >>> (est_intervals, ... est_labels) = mir_eval.io.load_labeled_intervals('est...
python
def weighted_accuracy(comparisons, weights): """Compute the weighted accuracy of a list of chord comparisons. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab') >>> (est_intervals, ... est_labels) = mir_eval.io.load_labeled_intervals('est...
[ "def", "weighted_accuracy", "(", "comparisons", ",", "weights", ")", ":", "N", "=", "len", "(", "comparisons", ")", "if", "weights", ".", "shape", "[", "0", "]", "!=", "N", ":", "raise", "ValueError", "(", "'weights and comparisons should be of the same'", "' ...
Compute the weighted accuracy of a list of chord comparisons. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab') >>> (est_intervals, ... est_labels) = mir_eval.io.load_labeled_intervals('est.lab') >>> est_intervals, est_labels = mir_eval....
[ "Compute", "the", "weighted", "accuracy", "of", "a", "list", "of", "chord", "comparisons", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/chord.py#L647-L709
train
craffel/mir_eval
mir_eval/chord.py
thirds
def thirds(reference_labels, estimated_labels): """Compare chords along root & third relationships. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab') >>> (est_intervals, ... est_labels) = mir_eval.io.load_labeled_intervals('est.lab') ...
python
def thirds(reference_labels, estimated_labels): """Compare chords along root & third relationships. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab') >>> (est_intervals, ... est_labels) = mir_eval.io.load_labeled_intervals('est.lab') ...
[ "def", "thirds", "(", "reference_labels", ",", "estimated_labels", ")", ":", "validate", "(", "reference_labels", ",", "estimated_labels", ")", "ref_roots", ",", "ref_semitones", "=", "encode_many", "(", "reference_labels", ",", "False", ")", "[", ":", "2", "]",...
Compare chords along root & third relationships. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab') >>> (est_intervals, ... est_labels) = mir_eval.io.load_labeled_intervals('est.lab') >>> est_intervals, est_labels = mir_eval.util.adjust_i...
[ "Compare", "chords", "along", "root", "&", "third", "relationships", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/chord.py#L712-L756
train
craffel/mir_eval
mir_eval/chord.py
thirds_inv
def thirds_inv(reference_labels, estimated_labels): """Score chords along root, third, & bass relationships. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab') >>> (est_intervals, ... est_labels) = mir_eval.io.load_labeled_intervals('est....
python
def thirds_inv(reference_labels, estimated_labels): """Score chords along root, third, & bass relationships. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab') >>> (est_intervals, ... est_labels) = mir_eval.io.load_labeled_intervals('est....
[ "def", "thirds_inv", "(", "reference_labels", ",", "estimated_labels", ")", ":", "validate", "(", "reference_labels", ",", "estimated_labels", ")", "ref_roots", ",", "ref_semitones", ",", "ref_bass", "=", "encode_many", "(", "reference_labels", ",", "False", ")", ...
Score chords along root, third, & bass relationships. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab') >>> (est_intervals, ... est_labels) = mir_eval.io.load_labeled_intervals('est.lab') >>> est_intervals, est_labels = mir_eval.util.adj...
[ "Score", "chords", "along", "root", "third", "&", "bass", "relationships", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/chord.py#L759-L804
train
craffel/mir_eval
mir_eval/chord.py
root
def root(reference_labels, estimated_labels): """Compare chords according to roots. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab') >>> (est_intervals, ... est_labels) = mir_eval.io.load_labeled_intervals('est.lab') >>> est_interva...
python
def root(reference_labels, estimated_labels): """Compare chords according to roots. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab') >>> (est_intervals, ... est_labels) = mir_eval.io.load_labeled_intervals('est.lab') >>> est_interva...
[ "def", "root", "(", "reference_labels", ",", "estimated_labels", ")", ":", "validate", "(", "reference_labels", ",", "estimated_labels", ")", "ref_roots", ",", "ref_semitones", "=", "encode_many", "(", "reference_labels", ",", "False", ")", "[", ":", "2", "]", ...
Compare chords according to roots. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab') >>> (est_intervals, ... est_labels) = mir_eval.io.load_labeled_intervals('est.lab') >>> est_intervals, est_labels = mir_eval.util.adjust_intervals( ...
[ "Compare", "chords", "according", "to", "roots", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/chord.py#L999-L1042
train
craffel/mir_eval
mir_eval/chord.py
mirex
def mirex(reference_labels, estimated_labels): """Compare chords along MIREX rules. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab') >>> (est_intervals, ... est_labels) = mir_eval.io.load_labeled_intervals('est.lab') >>> est_interva...
python
def mirex(reference_labels, estimated_labels): """Compare chords along MIREX rules. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab') >>> (est_intervals, ... est_labels) = mir_eval.io.load_labeled_intervals('est.lab') >>> est_interva...
[ "def", "mirex", "(", "reference_labels", ",", "estimated_labels", ")", ":", "validate", "(", "reference_labels", ",", "estimated_labels", ")", "min_intersection", "=", "3", "ref_data", "=", "encode_many", "(", "reference_labels", ",", "False", ")", "ref_chroma", "...
Compare chords along MIREX rules. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab') >>> (est_intervals, ... est_labels) = mir_eval.io.load_labeled_intervals('est.lab') >>> est_intervals, est_labels = mir_eval.util.adjust_intervals( ....
[ "Compare", "chords", "along", "MIREX", "rules", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/chord.py#L1045-L1104
train
craffel/mir_eval
mir_eval/chord.py
seg
def seg(reference_intervals, estimated_intervals): """Compute the MIREX 'MeanSeg' score. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab') >>> (est_intervals, ... est_labels) = mir_eval.io.load_labeled_intervals('est.lab') >>> score ...
python
def seg(reference_intervals, estimated_intervals): """Compute the MIREX 'MeanSeg' score. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab') >>> (est_intervals, ... est_labels) = mir_eval.io.load_labeled_intervals('est.lab') >>> score ...
[ "def", "seg", "(", "reference_intervals", ",", "estimated_intervals", ")", ":", "return", "min", "(", "underseg", "(", "reference_intervals", ",", "estimated_intervals", ")", ",", "overseg", "(", "reference_intervals", ",", "estimated_intervals", ")", ")" ]
Compute the MIREX 'MeanSeg' score. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab') >>> (est_intervals, ... est_labels) = mir_eval.io.load_labeled_intervals('est.lab') >>> score = mir_eval.chord.seg(ref_intervals, est_intervals) Pa...
[ "Compute", "the", "MIREX", "MeanSeg", "score", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/chord.py#L1455-L1480
train
craffel/mir_eval
mir_eval/chord.py
merge_chord_intervals
def merge_chord_intervals(intervals, labels): """ Merge consecutive chord intervals if they represent the same chord. Parameters ---------- intervals : np.ndarray, shape=(n, 2), dtype=float Chord intervals to be merged, in the format returned by :func:`mir_eval.io.load_labeled_inter...
python
def merge_chord_intervals(intervals, labels): """ Merge consecutive chord intervals if they represent the same chord. Parameters ---------- intervals : np.ndarray, shape=(n, 2), dtype=float Chord intervals to be merged, in the format returned by :func:`mir_eval.io.load_labeled_inter...
[ "def", "merge_chord_intervals", "(", "intervals", ",", "labels", ")", ":", "roots", ",", "semitones", ",", "basses", "=", "encode_many", "(", "labels", ",", "True", ")", "merged_ivs", "=", "[", "]", "prev_rt", "=", "None", "prev_st", "=", "None", "prev_ba"...
Merge consecutive chord intervals if they represent the same chord. Parameters ---------- intervals : np.ndarray, shape=(n, 2), dtype=float Chord intervals to be merged, in the format returned by :func:`mir_eval.io.load_labeled_intervals`. labels : list, shape=(n,) Chord labels ...
[ "Merge", "consecutive", "chord", "intervals", "if", "they", "represent", "the", "same", "chord", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/chord.py#L1483-L1514
train
craffel/mir_eval
mir_eval/chord.py
evaluate
def evaluate(ref_intervals, ref_labels, est_intervals, est_labels, **kwargs): """Computes weighted accuracy for all comparison functions for the given reference and estimated annotations. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab') ...
python
def evaluate(ref_intervals, ref_labels, est_intervals, est_labels, **kwargs): """Computes weighted accuracy for all comparison functions for the given reference and estimated annotations. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab') ...
[ "def", "evaluate", "(", "ref_intervals", ",", "ref_labels", ",", "est_intervals", ",", "est_labels", ",", "**", "kwargs", ")", ":", "est_intervals", ",", "est_labels", "=", "util", ".", "adjust_intervals", "(", "est_intervals", ",", "est_labels", ",", "ref_inter...
Computes weighted accuracy for all comparison functions for the given reference and estimated annotations. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab') >>> (est_intervals, ... est_labels) = mir_eval.io.load_labeled_intervals('est.la...
[ "Computes", "weighted", "accuracy", "for", "all", "comparison", "functions", "for", "the", "given", "reference", "and", "estimated", "annotations", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/chord.py#L1517-L1604
train
craffel/mir_eval
mir_eval/pattern.py
_n_onset_midi
def _n_onset_midi(patterns): """Computes the number of onset_midi objects in a pattern Parameters ---------- patterns : A list of patterns using the format returned by :func:`mir_eval.io.load_patterns()` Returns ------- n_onsets : int Number of onsets within the pat...
python
def _n_onset_midi(patterns): """Computes the number of onset_midi objects in a pattern Parameters ---------- patterns : A list of patterns using the format returned by :func:`mir_eval.io.load_patterns()` Returns ------- n_onsets : int Number of onsets within the pat...
[ "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 Parameters ---------- patterns : A list of patterns using the format returned by :func:`mir_eval.io.load_patterns()` Returns ------- n_onsets : int Number of onsets within the pattern.
[ "Computes", "the", "number", "of", "onset_midi", "objects", "in", "a", "pattern" ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/pattern.py#L64-L79
train
craffel/mir_eval
mir_eval/pattern.py
validate
def validate(reference_patterns, estimated_patterns): """Checks that the input annotations to a metric look like valid pattern lists, and throws helpful errors if not. Parameters ---------- reference_patterns : list The reference patterns using the format returned by :func:`mir_eval...
python
def validate(reference_patterns, estimated_patterns): """Checks that the input annotations to a metric look like valid pattern lists, and throws helpful errors if not. Parameters ---------- reference_patterns : list The reference patterns using the format returned by :func:`mir_eval...
[ "def", "validate", "(", "reference_patterns", ",", "estimated_patterns", ")", ":", "if", "_n_onset_midi", "(", "reference_patterns", ")", "==", "0", ":", "warnings", ".", "warn", "(", "'Reference patterns are empty.'", ")", "if", "_n_onset_midi", "(", "estimated_pat...
Checks that the input annotations to a metric look like valid pattern lists, and throws helpful errors if not. Parameters ---------- reference_patterns : list The reference patterns using the format returned by :func:`mir_eval.io.load_patterns()` estimated_patterns : list Th...
[ "Checks", "that", "the", "input", "annotations", "to", "a", "metric", "look", "like", "valid", "pattern", "lists", "and", "throws", "helpful", "errors", "if", "not", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/pattern.py#L82-L112
train
craffel/mir_eval
mir_eval/pattern.py
_occurrence_intersection
def _occurrence_intersection(occ_P, occ_Q): """Computes the intersection between two occurrences. Parameters ---------- occ_P : list of tuples (onset, midi) pairs representing the reference occurrence. occ_Q : list second list of (onset, midi) tuples Returns ------- S :...
python
def _occurrence_intersection(occ_P, occ_Q): """Computes the intersection between two occurrences. Parameters ---------- occ_P : list of tuples (onset, midi) pairs representing the reference occurrence. occ_Q : list second list of (onset, midi) tuples Returns ------- S :...
[ "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"...
Computes the intersection between two occurrences. Parameters ---------- occ_P : list of tuples (onset, midi) pairs representing the reference occurrence. occ_Q : list second list of (onset, midi) tuples Returns ------- S : set Set of the intersection between occ_P ...
[ "Computes", "the", "intersection", "between", "two", "occurrences", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/pattern.py#L115-L133
train
craffel/mir_eval
mir_eval/pattern.py
_compute_score_matrix
def _compute_score_matrix(P, Q, similarity_metric="cardinality_score"): """Computes the score matrix between the patterns P and Q. Parameters ---------- P : list Pattern containing a list of occurrences. Q : list Pattern containing a list of occurrences. similarity_metric : str ...
python
def _compute_score_matrix(P, Q, similarity_metric="cardinality_score"): """Computes the score matrix between the patterns P and Q. Parameters ---------- P : list Pattern containing a list of occurrences. Q : list Pattern containing a list of occurrences. similarity_metric : str ...
[ "def", "_compute_score_matrix", "(", "P", ",", "Q", ",", "similarity_metric", "=", "\"cardinality_score\"", ")", ":", "sm", "=", "np", ".", "zeros", "(", "(", "len", "(", "P", ")", ",", "len", "(", "Q", ")", ")", ")", "for", "iP", ",", "occ_P", "in...
Computes the score matrix between the patterns P and Q. Parameters ---------- P : list Pattern containing a list of occurrences. Q : list Pattern containing a list of occurrences. similarity_metric : str A string representing the metric to be used when computing the ...
[ "Computes", "the", "score", "matrix", "between", "the", "patterns", "P", "and", "Q", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/pattern.py#L136-L170
train
craffel/mir_eval
mir_eval/pattern.py
standard_FPR
def standard_FPR(reference_patterns, estimated_patterns, tol=1e-5): """Standard F1 Score, Precision and Recall. This metric checks if the prototype patterns of the reference match possible translated patterns in the prototype patterns of the estimations. Since the sizes of these prototypes must be equa...
python
def standard_FPR(reference_patterns, estimated_patterns, tol=1e-5): """Standard F1 Score, Precision and Recall. This metric checks if the prototype patterns of the reference match possible translated patterns in the prototype patterns of the estimations. Since the sizes of these prototypes must be equa...
[ "def", "standard_FPR", "(", "reference_patterns", ",", "estimated_patterns", ",", "tol", "=", "1e-5", ")", ":", "validate", "(", "reference_patterns", ",", "estimated_patterns", ")", "nP", "=", "len", "(", "reference_patterns", ")", "nQ", "=", "len", "(", "est...
Standard F1 Score, Precision and Recall. This metric checks if the prototype patterns of the reference match possible translated patterns in the prototype patterns of the estimations. Since the sizes of these prototypes must be equal, this metric is quite restictive and it tends to be 0 in most of 2013...
[ "Standard", "F1", "Score", "Precision", "and", "Recall", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/pattern.py#L173-L239
train
craffel/mir_eval
mir_eval/pattern.py
three_layer_FPR
def three_layer_FPR(reference_patterns, estimated_patterns): """Three Layer F1 Score, Precision and Recall. As described by Meridith. Examples -------- >>> ref_patterns = mir_eval.io.load_patterns("ref_pattern.txt") >>> est_patterns = mir_eval.io.load_patterns("est_pattern.txt") >>> F, P, R = m...
python
def three_layer_FPR(reference_patterns, estimated_patterns): """Three Layer F1 Score, Precision and Recall. As described by Meridith. Examples -------- >>> ref_patterns = mir_eval.io.load_patterns("ref_pattern.txt") >>> est_patterns = mir_eval.io.load_patterns("est_pattern.txt") >>> F, P, R = m...
[ "def", "three_layer_FPR", "(", "reference_patterns", ",", "estimated_patterns", ")", ":", "validate", "(", "reference_patterns", ",", "estimated_patterns", ")", "def", "compute_first_layer_PR", "(", "ref_occs", ",", "est_occs", ")", ":", "s", "=", "len", "(", "_oc...
Three Layer F1 Score, Precision and Recall. As described by Meridith. Examples -------- >>> ref_patterns = mir_eval.io.load_patterns("ref_pattern.txt") >>> est_patterns = mir_eval.io.load_patterns("est_pattern.txt") >>> F, P, R = mir_eval.pattern.three_layer_FPR(ref_patterns, ... ...
[ "Three", "Layer", "F1", "Score", "Precision", "and", "Recall", ".", "As", "described", "by", "Meridith", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/pattern.py#L390-L520
train
craffel/mir_eval
mir_eval/pattern.py
first_n_three_layer_P
def first_n_three_layer_P(reference_patterns, estimated_patterns, n=5): """First n three-layer precision. This metric is basically the same as the three-layer FPR but it is only applied to the first n estimated patterns, and it only returns the precision. In MIREX and typically, n = 5. Examples ...
python
def first_n_three_layer_P(reference_patterns, estimated_patterns, n=5): """First n three-layer precision. This metric is basically the same as the three-layer FPR but it is only applied to the first n estimated patterns, and it only returns the precision. In MIREX and typically, n = 5. Examples ...
[ "def", "first_n_three_layer_P", "(", "reference_patterns", ",", "estimated_patterns", ",", "n", "=", "5", ")", ":", "validate", "(", "reference_patterns", ",", "estimated_patterns", ")", "if", "_n_onset_midi", "(", "reference_patterns", ")", "==", "0", "or", "_n_o...
First n three-layer precision. This metric is basically the same as the three-layer FPR but it is only applied to the first n estimated patterns, and it only returns the precision. In MIREX and typically, n = 5. Examples -------- >>> ref_patterns = mir_eval.io.load_patterns("ref_pattern.txt") ...
[ "First", "n", "three", "-", "layer", "precision", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/pattern.py#L523-L568
train
craffel/mir_eval
mir_eval/pattern.py
first_n_target_proportion_R
def first_n_target_proportion_R(reference_patterns, estimated_patterns, n=5): """First n target proportion establishment recall metric. This metric is similar is similar to the establishment FPR score, but it only takes into account the first n estimated patterns and it only outputs the Recall value of...
python
def first_n_target_proportion_R(reference_patterns, estimated_patterns, n=5): """First n target proportion establishment recall metric. This metric is similar is similar to the establishment FPR score, but it only takes into account the first n estimated patterns and it only outputs the Recall value of...
[ "def", "first_n_target_proportion_R", "(", "reference_patterns", ",", "estimated_patterns", ",", "n", "=", "5", ")", ":", "validate", "(", "reference_patterns", ",", "estimated_patterns", ")", "if", "_n_onset_midi", "(", "reference_patterns", ")", "==", "0", "or", ...
First n target proportion establishment recall metric. This metric is similar is similar to the establishment FPR score, but it only takes into account the first n estimated patterns and it only outputs the Recall value of it. Examples -------- >>> ref_patterns = mir_eval.io.load_patterns("ref...
[ "First", "n", "target", "proportion", "establishment", "recall", "metric", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/pattern.py#L571-L614
train
craffel/mir_eval
mir_eval/pattern.py
evaluate
def evaluate(ref_patterns, est_patterns, **kwargs): """Load data and perform the evaluation. Examples -------- >>> ref_patterns = mir_eval.io.load_patterns("ref_pattern.txt") >>> est_patterns = mir_eval.io.load_patterns("est_pattern.txt") >>> scores = mir_eval.pattern.evaluate(ref_patterns, est...
python
def evaluate(ref_patterns, est_patterns, **kwargs): """Load data and perform the evaluation. Examples -------- >>> ref_patterns = mir_eval.io.load_patterns("ref_pattern.txt") >>> est_patterns = mir_eval.io.load_patterns("est_pattern.txt") >>> scores = mir_eval.pattern.evaluate(ref_patterns, est...
[ "def", "evaluate", "(", "ref_patterns", ",", "est_patterns", ",", "**", "kwargs", ")", ":", "scores", "=", "collections", ".", "OrderedDict", "(", ")", "scores", "[", "'F'", "]", ",", "scores", "[", "'P'", "]", ",", "scores", "[", "'R'", "]", "=", "u...
Load data and perform the evaluation. Examples -------- >>> ref_patterns = mir_eval.io.load_patterns("ref_pattern.txt") >>> est_patterns = mir_eval.io.load_patterns("est_pattern.txt") >>> scores = mir_eval.pattern.evaluate(ref_patterns, est_patterns) Parameters ---------- ref_patterns ...
[ "Load", "data", "and", "perform", "the", "evaluation", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/pattern.py#L617-L683
train
craffel/mir_eval
mir_eval/transcription_velocity.py
validate
def validate(ref_intervals, ref_pitches, ref_velocities, est_intervals, est_pitches, est_velocities): """Checks that the input annotations have valid time intervals, pitches, and velocities, and throws helpful errors if not. Parameters ---------- ref_intervals : np.ndarray, shape=(n,2)...
python
def validate(ref_intervals, ref_pitches, ref_velocities, est_intervals, est_pitches, est_velocities): """Checks that the input annotations have valid time intervals, pitches, and velocities, and throws helpful errors if not. Parameters ---------- ref_intervals : np.ndarray, shape=(n,2)...
[ "def", "validate", "(", "ref_intervals", ",", "ref_pitches", ",", "ref_velocities", ",", "est_intervals", ",", "est_pitches", ",", "est_velocities", ")", ":", "transcription", ".", "validate", "(", "ref_intervals", ",", "ref_pitches", ",", "est_intervals", ",", "e...
Checks that the input annotations have valid time intervals, pitches, and velocities, and throws helpful errors if not. Parameters ---------- ref_intervals : np.ndarray, shape=(n,2) Array of reference notes time intervals (onset and offset times) ref_pitches : np.ndarray, shape=(n,) ...
[ "Checks", "that", "the", "input", "annotations", "have", "valid", "time", "intervals", "pitches", "and", "velocities", "and", "throws", "helpful", "errors", "if", "not", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/transcription_velocity.py#L62-L95
train
craffel/mir_eval
mir_eval/transcription_velocity.py
match_notes
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 considera...
python
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 considera...
[ "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", ",", ...
Match notes, taking note velocity into consideration. This function first calls :func:`mir_eval.transcription.match_notes` to match notes according to the supplied intervals, pitches, onset, offset, and pitch tolerances. The velocities of the matched notes are then used to estimate a slope and intercep...
[ "Match", "notes", "taking", "note", "velocity", "into", "consideration", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/transcription_velocity.py#L98-L201
train
craffel/mir_eval
mir_eval/beat.py
validate
def validate(reference_beats, estimated_beats): """Checks that the input annotations to a metric look like valid beat time arrays, and throws helpful errors if not. Parameters ---------- reference_beats : np.ndarray reference beat times, in seconds estimated_beats : np.ndarray e...
python
def validate(reference_beats, estimated_beats): """Checks that the input annotations to a metric look like valid beat time arrays, and throws helpful errors if not. Parameters ---------- reference_beats : np.ndarray reference beat times, in seconds estimated_beats : np.ndarray e...
[ "def", "validate", "(", "reference_beats", ",", "estimated_beats", ")", ":", "if", "reference_beats", ".", "size", "==", "0", ":", "warnings", ".", "warn", "(", "\"Reference beats are empty.\"", ")", "if", "estimated_beats", ".", "size", "==", "0", ":", "warni...
Checks that the input annotations to a metric look like valid beat time arrays, and throws helpful errors if not. Parameters ---------- reference_beats : np.ndarray reference beat times, in seconds estimated_beats : np.ndarray estimated beat times, in seconds
[ "Checks", "that", "the", "input", "annotations", "to", "a", "metric", "look", "like", "valid", "beat", "time", "arrays", "and", "throws", "helpful", "errors", "if", "not", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/beat.py#L77-L95
train
craffel/mir_eval
mir_eval/beat.py
_get_reference_beat_variations
def _get_reference_beat_variations(reference_beats): """Return metric variations of the reference beats Parameters ---------- reference_beats : np.ndarray beat locations in seconds Returns ------- reference_beats : np.ndarray Original beat locations off_beat : np.ndarra...
python
def _get_reference_beat_variations(reference_beats): """Return metric variations of the reference beats Parameters ---------- reference_beats : np.ndarray beat locations in seconds Returns ------- reference_beats : np.ndarray Original beat locations off_beat : np.ndarra...
[ "def", "_get_reference_beat_variations", "(", "reference_beats", ")", ":", "interpolated_indices", "=", "np", ".", "arange", "(", "0", ",", "reference_beats", ".", "shape", "[", "0", "]", "-", ".5", ",", ".5", ")", "original_indices", "=", "np", ".", "arange...
Return metric variations of the reference beats Parameters ---------- reference_beats : np.ndarray beat locations in seconds Returns ------- reference_beats : np.ndarray Original beat locations off_beat : np.ndarray 180 degrees out of phase from the original beat lo...
[ "Return", "metric", "variations", "of", "the", "reference", "beats" ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/beat.py#L98-L133
train
craffel/mir_eval
mir_eval/beat.py
f_measure
def f_measure(reference_beats, estimated_beats, f_measure_threshold=0.07): """Compute the F-measure of correct vs incorrectly predicted beats. "Correctness" is determined over a small window. Examples -------- >>> reference_beats = mir_eval.io.load_events('reference.txt'...
python
def f_measure(reference_beats, estimated_beats, f_measure_threshold=0.07): """Compute the F-measure of correct vs incorrectly predicted beats. "Correctness" is determined over a small window. Examples -------- >>> reference_beats = mir_eval.io.load_events('reference.txt'...
[ "def", "f_measure", "(", "reference_beats", ",", "estimated_beats", ",", "f_measure_threshold", "=", "0.07", ")", ":", "validate", "(", "reference_beats", ",", "estimated_beats", ")", "if", "estimated_beats", ".", "size", "==", "0", "or", "reference_beats", ".", ...
Compute the F-measure of correct vs incorrectly predicted beats. "Correctness" is determined over a small window. Examples -------- >>> reference_beats = mir_eval.io.load_events('reference.txt') >>> reference_beats = mir_eval.beat.trim_beats(reference_beats) >>> estimated_beats = mir_eval.io.lo...
[ "Compute", "the", "F", "-", "measure", "of", "correct", "vs", "incorrectly", "predicted", "beats", ".", "Correctness", "is", "determined", "over", "a", "small", "window", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/beat.py#L136-L178
train
craffel/mir_eval
mir_eval/beat.py
cemgil
def cemgil(reference_beats, estimated_beats, cemgil_sigma=0.04): """Cemgil's score, computes a gaussian error of each estimated beat. Compares against the original beat times and all metrical variations. Examples -------- >>> reference_beats = mir_eval.io.load_events('referenc...
python
def cemgil(reference_beats, estimated_beats, cemgil_sigma=0.04): """Cemgil's score, computes a gaussian error of each estimated beat. Compares against the original beat times and all metrical variations. Examples -------- >>> reference_beats = mir_eval.io.load_events('referenc...
[ "def", "cemgil", "(", "reference_beats", ",", "estimated_beats", ",", "cemgil_sigma", "=", "0.04", ")", ":", "validate", "(", "reference_beats", ",", "estimated_beats", ")", "if", "estimated_beats", ".", "size", "==", "0", "or", "reference_beats", ".", "size", ...
Cemgil's score, computes a gaussian error of each estimated beat. Compares against the original beat times and all metrical variations. Examples -------- >>> reference_beats = mir_eval.io.load_events('reference.txt') >>> reference_beats = mir_eval.beat.trim_beats(reference_beats) >>> estimated_...
[ "Cemgil", "s", "score", "computes", "a", "gaussian", "error", "of", "each", "estimated", "beat", ".", "Compares", "against", "the", "original", "beat", "times", "and", "all", "metrical", "variations", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/beat.py#L181-L233
train
craffel/mir_eval
mir_eval/beat.py
goto
def goto(reference_beats, estimated_beats, goto_threshold=0.35, goto_mu=0.2, goto_sigma=0.2): """Calculate Goto's score, a binary 1 or 0 depending on some specific heuristic criteria Examples -------- >>> reference_beats = mir_eval.io.load_events('reference.txt')...
python
def goto(reference_beats, estimated_beats, goto_threshold=0.35, goto_mu=0.2, goto_sigma=0.2): """Calculate Goto's score, a binary 1 or 0 depending on some specific heuristic criteria Examples -------- >>> reference_beats = mir_eval.io.load_events('reference.txt')...
[ "def", "goto", "(", "reference_beats", ",", "estimated_beats", ",", "goto_threshold", "=", "0.35", ",", "goto_mu", "=", "0.2", ",", "goto_sigma", "=", "0.2", ")", ":", "validate", "(", "reference_beats", ",", "estimated_beats", ")", "if", "estimated_beats", "....
Calculate Goto's score, a binary 1 or 0 depending on some specific heuristic criteria Examples -------- >>> reference_beats = mir_eval.io.load_events('reference.txt') >>> reference_beats = mir_eval.beat.trim_beats(reference_beats) >>> estimated_beats = mir_eval.io.load_events('estimated.txt') ...
[ "Calculate", "Goto", "s", "score", "a", "binary", "1", "or", "0", "depending", "on", "some", "specific", "heuristic", "criteria" ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/beat.py#L236-L335
train
craffel/mir_eval
mir_eval/beat.py
p_score
def p_score(reference_beats, estimated_beats, p_score_threshold=0.2): """Get McKinney's P-score. Based on the autocorrelation of the reference and estimated beats Examples -------- >>> reference_beats = mir_eval.io.load_events('reference.txt') >>> reference_beats = mir_e...
python
def p_score(reference_beats, estimated_beats, p_score_threshold=0.2): """Get McKinney's P-score. Based on the autocorrelation of the reference and estimated beats Examples -------- >>> reference_beats = mir_eval.io.load_events('reference.txt') >>> reference_beats = mir_e...
[ "def", "p_score", "(", "reference_beats", ",", "estimated_beats", ",", "p_score_threshold", "=", "0.2", ")", ":", "validate", "(", "reference_beats", ",", "estimated_beats", ")", "if", "reference_beats", ".", "size", "==", "1", ":", "warnings", ".", "warn", "(...
Get McKinney's P-score. Based on the autocorrelation of the reference and estimated beats Examples -------- >>> reference_beats = mir_eval.io.load_events('reference.txt') >>> reference_beats = mir_eval.beat.trim_beats(reference_beats) >>> estimated_beats = mir_eval.io.load_events('estimated.txt...
[ "Get", "McKinney", "s", "P", "-", "score", ".", "Based", "on", "the", "autocorrelation", "of", "the", "reference", "and", "estimated", "beats" ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/beat.py#L338-L412
train
craffel/mir_eval
mir_eval/beat.py
information_gain
def information_gain(reference_beats, estimated_beats, bins=41): """Get the information gain - K-L divergence of the beat error histogram to a uniform histogram Examples -------- >>> reference_beats = mir_eval.io.load_events('reference.txt') >>> referen...
python
def information_gain(reference_beats, estimated_beats, bins=41): """Get the information gain - K-L divergence of the beat error histogram to a uniform histogram Examples -------- >>> reference_beats = mir_eval.io.load_events('reference.txt') >>> referen...
[ "def", "information_gain", "(", "reference_beats", ",", "estimated_beats", ",", "bins", "=", "41", ")", ":", "validate", "(", "reference_beats", ",", "estimated_beats", ")", "if", "not", "bins", "%", "2", ":", "warnings", ".", "warn", "(", "\"bins parameter is...
Get the information gain - K-L divergence of the beat error histogram to a uniform histogram Examples -------- >>> reference_beats = mir_eval.io.load_events('reference.txt') >>> reference_beats = mir_eval.beat.trim_beats(reference_beats) >>> estimated_beats = mir_eval.io.load_events('estimated....
[ "Get", "the", "information", "gain", "-", "K", "-", "L", "divergence", "of", "the", "beat", "error", "histogram", "to", "a", "uniform", "histogram" ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/beat.py#L580-L639
train
craffel/mir_eval
mir_eval/util.py
index_labels
def index_labels(labels, case_sensitive=False): """Convert a list of string identifiers into numerical indices. Parameters ---------- labels : list of strings, shape=(n,) A list of annotations, e.g., segment or chord labels from an annotation file. case_sensitive : bool Set...
python
def index_labels(labels, case_sensitive=False): """Convert a list of string identifiers into numerical indices. Parameters ---------- labels : list of strings, shape=(n,) A list of annotations, e.g., segment or chord labels from an annotation file. case_sensitive : bool Set...
[ "def", "index_labels", "(", "labels", ",", "case_sensitive", "=", "False", ")", ":", "label_to_index", "=", "{", "}", "index_to_label", "=", "{", "}", "if", "not", "case_sensitive", ":", "labels", "=", "[", "str", "(", "s", ")", ".", "lower", "(", ")",...
Convert a list of string identifiers into numerical indices. Parameters ---------- labels : list of strings, shape=(n,) A list of annotations, e.g., segment or chord labels from an annotation file. case_sensitive : bool Set to True to enable case-sensitive label indexing ...
[ "Convert", "a", "list", "of", "string", "identifiers", "into", "numerical", "indices", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/util.py#L13-L52
train
craffel/mir_eval
mir_eval/util.py
intervals_to_samples
def intervals_to_samples(intervals, labels, offset=0, sample_size=0.1, fill_value=None): """Convert an array of labeled time intervals to annotated samples. Parameters ---------- intervals : np.ndarray, shape=(n, d) An array of time intervals, as returned by :fu...
python
def intervals_to_samples(intervals, labels, offset=0, sample_size=0.1, fill_value=None): """Convert an array of labeled time intervals to annotated samples. Parameters ---------- intervals : np.ndarray, shape=(n, d) An array of time intervals, as returned by :fu...
[ "def", "intervals_to_samples", "(", "intervals", ",", "labels", ",", "offset", "=", "0", ",", "sample_size", "=", "0.1", ",", "fill_value", "=", "None", ")", ":", "num_samples", "=", "int", "(", "np", ".", "floor", "(", "intervals", ".", "max", "(", ")...
Convert an array of labeled time intervals to annotated samples. Parameters ---------- intervals : np.ndarray, shape=(n, d) An array of time intervals, as returned by :func:`mir_eval.io.load_intervals()` or :func:`mir_eval.io.load_labeled_intervals()`. The ``i`` th interval ...
[ "Convert", "an", "array", "of", "labeled", "time", "intervals", "to", "annotated", "samples", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/util.py#L76-L126
train
craffel/mir_eval
mir_eval/util.py
interpolate_intervals
def interpolate_intervals(intervals, labels, time_points, fill_value=None): """Assign labels to a set of points in time given a set of intervals. Time points that do not lie within an interval are mapped to `fill_value`. Parameters ---------- intervals : np.ndarray, shape=(n, 2) An array o...
python
def interpolate_intervals(intervals, labels, time_points, fill_value=None): """Assign labels to a set of points in time given a set of intervals. Time points that do not lie within an interval are mapped to `fill_value`. Parameters ---------- intervals : np.ndarray, shape=(n, 2) An array o...
[ "def", "interpolate_intervals", "(", "intervals", ",", "labels", ",", "time_points", ",", "fill_value", "=", "None", ")", ":", "time_points", "=", "np", ".", "asarray", "(", "time_points", ")", "if", "np", ".", "any", "(", "time_points", "[", "1", ":", "...
Assign labels to a set of points in time given a set of intervals. Time points that do not lie within an interval are mapped to `fill_value`. Parameters ---------- intervals : np.ndarray, shape=(n, 2) An array of time intervals, as returned by :func:`mir_eval.io.load_intervals()`. ...
[ "Assign", "labels", "to", "a", "set", "of", "points", "in", "time", "given", "a", "set", "of", "intervals", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/util.py#L129-L180
train
craffel/mir_eval
mir_eval/util.py
sort_labeled_intervals
def sort_labeled_intervals(intervals, labels=None): '''Sort intervals, and optionally, their corresponding labels according to start time. Parameters ---------- intervals : np.ndarray, shape=(n, 2) The input intervals labels : list, optional Labels for each interval Return...
python
def sort_labeled_intervals(intervals, labels=None): '''Sort intervals, and optionally, their corresponding labels according to start time. Parameters ---------- intervals : np.ndarray, shape=(n, 2) The input intervals labels : list, optional Labels for each interval Return...
[ "def", "sort_labeled_intervals", "(", "intervals", ",", "labels", "=", "None", ")", ":", "idx", "=", "np", ".", "argsort", "(", "intervals", "[", ":", ",", "0", "]", ")", "intervals_sorted", "=", "intervals", "[", "idx", "]", "if", "labels", "is", "Non...
Sort intervals, and optionally, their corresponding labels according to start time. Parameters ---------- intervals : np.ndarray, shape=(n, 2) The input intervals labels : list, optional Labels for each interval Returns ------- intervals_sorted or (intervals_sorted, la...
[ "Sort", "intervals", "and", "optionally", "their", "corresponding", "labels", "according", "to", "start", "time", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/util.py#L183-L208
train
craffel/mir_eval
mir_eval/util.py
f_measure
def f_measure(precision, recall, beta=1.0): """Compute the f-measure from precision and recall scores. Parameters ---------- precision : float in (0, 1] Precision recall : float in (0, 1] Recall beta : float > 0 Weighting factor for f-measure (Default value = 1.0...
python
def f_measure(precision, recall, beta=1.0): """Compute the f-measure from precision and recall scores. Parameters ---------- precision : float in (0, 1] Precision recall : float in (0, 1] Recall beta : float > 0 Weighting factor for f-measure (Default value = 1.0...
[ "def", "f_measure", "(", "precision", ",", "recall", ",", "beta", "=", "1.0", ")", ":", "if", "precision", "==", "0", "and", "recall", "==", "0", ":", "return", "0.0", "return", "(", "1", "+", "beta", "**", "2", ")", "*", "precision", "*", "recall"...
Compute the f-measure from precision and recall scores. Parameters ---------- precision : float in (0, 1] Precision recall : float in (0, 1] Recall beta : float > 0 Weighting factor for f-measure (Default value = 1.0) Returns ------- f_measure : float ...
[ "Compute", "the", "f", "-", "measure", "from", "precision", "and", "recall", "scores", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/util.py#L211-L234
train
craffel/mir_eval
mir_eval/util.py
intervals_to_boundaries
def intervals_to_boundaries(intervals, q=5): """Convert interval times into boundaries. Parameters ---------- intervals : np.ndarray, shape=(n_events, 2) Array of interval start and end-times q : int Number of decimals to round to. (Default value = 5) Returns ------- bo...
python
def intervals_to_boundaries(intervals, q=5): """Convert interval times into boundaries. Parameters ---------- intervals : np.ndarray, shape=(n_events, 2) Array of interval start and end-times q : int Number of decimals to round to. (Default value = 5) Returns ------- bo...
[ "def", "intervals_to_boundaries", "(", "intervals", ",", "q", "=", "5", ")", ":", "return", "np", ".", "unique", "(", "np", ".", "ravel", "(", "np", ".", "round", "(", "intervals", ",", "decimals", "=", "q", ")", ")", ")" ]
Convert interval times into boundaries. Parameters ---------- intervals : np.ndarray, shape=(n_events, 2) Array of interval start and end-times q : int Number of decimals to round to. (Default value = 5) Returns ------- boundaries : np.ndarray Interval boundary time...
[ "Convert", "interval", "times", "into", "boundaries", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/util.py#L237-L254
train
craffel/mir_eval
mir_eval/util.py
boundaries_to_intervals
def boundaries_to_intervals(boundaries): """Convert an array of event times into intervals Parameters ---------- boundaries : list-like List-like of event times. These are assumed to be unique timestamps in ascending order. Returns ------- intervals : np.ndarray, shape=(n_...
python
def boundaries_to_intervals(boundaries): """Convert an array of event times into intervals Parameters ---------- boundaries : list-like List-like of event times. These are assumed to be unique timestamps in ascending order. Returns ------- intervals : np.ndarray, shape=(n_...
[ "def", "boundaries_to_intervals", "(", "boundaries", ")", ":", "if", "not", "np", ".", "allclose", "(", "boundaries", ",", "np", ".", "unique", "(", "boundaries", ")", ")", ":", "raise", "ValueError", "(", "'Boundary times are not unique or not ascending.'", ")", ...
Convert an array of event times into intervals Parameters ---------- boundaries : list-like List-like of event times. These are assumed to be unique timestamps in ascending order. Returns ------- intervals : np.ndarray, shape=(n_intervals, 2) Start and end time for eac...
[ "Convert", "an", "array", "of", "event", "times", "into", "intervals" ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/util.py#L257-L277
train
craffel/mir_eval
mir_eval/util.py
merge_labeled_intervals
def merge_labeled_intervals(x_intervals, x_labels, y_intervals, y_labels): r"""Merge the time intervals of two sequences. Parameters ---------- x_intervals : np.ndarray Array of interval times (seconds) x_labels : list or None List of labels y_intervals : np.ndarray Arra...
python
def merge_labeled_intervals(x_intervals, x_labels, y_intervals, y_labels): r"""Merge the time intervals of two sequences. Parameters ---------- x_intervals : np.ndarray Array of interval times (seconds) x_labels : list or None List of labels y_intervals : np.ndarray Arra...
[ "def", "merge_labeled_intervals", "(", "x_intervals", ",", "x_labels", ",", "y_intervals", ",", "y_labels", ")", ":", "r", "align_check", "=", "[", "x_intervals", "[", "0", ",", "0", "]", "==", "y_intervals", "[", "0", ",", "0", "]", ",", "x_intervals", ...
r"""Merge the time intervals of two sequences. Parameters ---------- x_intervals : np.ndarray Array of interval times (seconds) x_labels : list or None List of labels y_intervals : np.ndarray Array of interval times (seconds) y_labels : list or None List of label...
[ "r", "Merge", "the", "time", "intervals", "of", "two", "sequences", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/util.py#L501-L544
train
craffel/mir_eval
mir_eval/util.py
match_events
def match_events(ref, est, window, distance=None): """Compute a maximum matching between reference and estimated event times, subject to a window constraint. Given two lists of event times ``ref`` and ``est``, we seek the largest set of correspondences ``(ref[i], est[j])`` such that ``distance(ref[...
python
def match_events(ref, est, window, distance=None): """Compute a maximum matching between reference and estimated event times, subject to a window constraint. Given two lists of event times ``ref`` and ``est``, we seek the largest set of correspondences ``(ref[i], est[j])`` such that ``distance(ref[...
[ "def", "match_events", "(", "ref", ",", "est", ",", "window", ",", "distance", "=", "None", ")", ":", "if", "distance", "is", "not", "None", ":", "hits", "=", "np", ".", "where", "(", "distance", "(", "ref", ",", "est", ")", "<=", "window", ")", ...
Compute a maximum matching between reference and estimated event times, subject to a window constraint. Given two lists of event times ``ref`` and ``est``, we seek the largest set of correspondences ``(ref[i], est[j])`` such that ``distance(ref[i], est[j]) <= window``, and each ``ref[i]`` and ``est...
[ "Compute", "a", "maximum", "matching", "between", "reference", "and", "estimated", "event", "times", "subject", "to", "a", "window", "constraint", "." ]
f41c8dafaea04b411252a516d1965af43c7d531b
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/util.py#L663-L710
train