partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
oauth_token_exchange_cli
Command line function for obtaining the refresh token/code. For more information visit :func:`oauth2_token_exchange<ohapi.api.oauth2_token_exchange>`.
ohapi/command_line.py
def oauth_token_exchange_cli(client_id, client_secret, redirect_uri, base_url=OH_BASE_URL, code=None, refresh_token=None): """ Command line function for obtaining the refresh token/code. For more information visit :func:`oauth2_token_exchange<oha...
def oauth_token_exchange_cli(client_id, client_secret, redirect_uri, base_url=OH_BASE_URL, code=None, refresh_token=None): """ Command line function for obtaining the refresh token/code. For more information visit :func:`oauth2_token_exchange<oha...
[ "Command", "line", "function", "for", "obtaining", "the", "refresh", "token", "/", "code", ".", "For", "more", "information", "visit", ":", "func", ":", "oauth2_token_exchange<ohapi", ".", "api", ".", "oauth2_token_exchange", ">", "." ]
OpenHumans/open-humans-api
python
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L427-L436
[ "def", "oauth_token_exchange_cli", "(", "client_id", ",", "client_secret", ",", "redirect_uri", ",", "base_url", "=", "OH_BASE_URL", ",", "code", "=", "None", ",", "refresh_token", "=", "None", ")", ":", "print", "(", "oauth2_token_exchange", "(", "client_id", "...
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
train
oauth2_auth_url_cli
Command line function for obtaining the Oauth2 url. For more information visit :func:`oauth2_auth_url<ohapi.api.oauth2_auth_url>`.
ohapi/command_line.py
def oauth2_auth_url_cli(redirect_uri=None, client_id=None, base_url=OH_BASE_URL): """ Command line function for obtaining the Oauth2 url. For more information visit :func:`oauth2_auth_url<ohapi.api.oauth2_auth_url>`. """ result = oauth2_auth_url(redirect_uri, client_id, b...
def oauth2_auth_url_cli(redirect_uri=None, client_id=None, base_url=OH_BASE_URL): """ Command line function for obtaining the Oauth2 url. For more information visit :func:`oauth2_auth_url<ohapi.api.oauth2_auth_url>`. """ result = oauth2_auth_url(redirect_uri, client_id, b...
[ "Command", "line", "function", "for", "obtaining", "the", "Oauth2", "url", ".", "For", "more", "information", "visit", ":", "func", ":", "oauth2_auth_url<ohapi", ".", "api", ".", "oauth2_auth_url", ">", "." ]
OpenHumans/open-humans-api
python
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L444-L453
[ "def", "oauth2_auth_url_cli", "(", "redirect_uri", "=", "None", ",", "client_id", "=", "None", ",", "base_url", "=", "OH_BASE_URL", ")", ":", "result", "=", "oauth2_auth_url", "(", "redirect_uri", ",", "client_id", ",", "base_url", ")", "print", "(", "'The req...
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
train
message_cli
Command line function for sending email to a single user or in bulk. For more information visit :func:`message<ohapi.api.message>`.
ohapi/command_line.py
def message_cli(subject, message_body, access_token, all_members=False, project_member_ids=None, base_url=OH_BASE_URL, verbose=False, debug=False): """ Command line function for sending email to a single user or in bulk. For more information visit :func:`message<ohapi.api...
def message_cli(subject, message_body, access_token, all_members=False, project_member_ids=None, base_url=OH_BASE_URL, verbose=False, debug=False): """ Command line function for sending email to a single user or in bulk. For more information visit :func:`message<ohapi.api...
[ "Command", "line", "function", "for", "sending", "email", "to", "a", "single", "user", "or", "in", "bulk", ".", "For", "more", "information", "visit", ":", "func", ":", "message<ohapi", ".", "api", ".", "message", ">", "." ]
OpenHumans/open-humans-api
python
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L468-L480
[ "def", "message_cli", "(", "subject", ",", "message_body", ",", "access_token", ",", "all_members", "=", "False", ",", "project_member_ids", "=", "None", ",", "base_url", "=", "OH_BASE_URL", ",", "verbose", "=", "False", ",", "debug", "=", "False", ")", ":",...
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
train
delete_cli
Command line function for deleting files. For more information visit :func:`delete_file<ohapi.api.delete_file>`.
ohapi/command_line.py
def delete_cli(access_token, project_member_id, base_url=OH_BASE_URL, file_basename=None, file_id=None, all_files=False): """ Command line function for deleting files. For more information visit :func:`delete_file<ohapi.api.delete_file>`. """ response = delete_file(access_token, p...
def delete_cli(access_token, project_member_id, base_url=OH_BASE_URL, file_basename=None, file_id=None, all_files=False): """ Command line function for deleting files. For more information visit :func:`delete_file<ohapi.api.delete_file>`. """ response = delete_file(access_token, p...
[ "Command", "line", "function", "for", "deleting", "files", ".", "For", "more", "information", "visit", ":", "func", ":", "delete_file<ohapi", ".", "api", ".", "delete_file", ">", "." ]
OpenHumans/open-humans-api
python
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L491-L503
[ "def", "delete_cli", "(", "access_token", ",", "project_member_id", ",", "base_url", "=", "OH_BASE_URL", ",", "file_basename", "=", "None", ",", "file_id", "=", "None", ",", "all_files", "=", "False", ")", ":", "response", "=", "delete_file", "(", "access_toke...
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
train
public_data_download_cli
Command line tools for downloading public data.
ohapi/command_line.py
def public_data_download_cli(source, username, directory, max_size, quiet, debug): """ Command line tools for downloading public data. """ return public_download(source, username, directory, max_size, quiet, debug)
def public_data_download_cli(source, username, directory, max_size, quiet, debug): """ Command line tools for downloading public data. """ return public_download(source, username, directory, max_size, quiet, debug)
[ "Command", "line", "tools", "for", "downloading", "public", "data", "." ]
OpenHumans/open-humans-api
python
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L517-L522
[ "def", "public_data_download_cli", "(", "source", ",", "username", ",", "directory", ",", "max_size", ",", "quiet", ",", "debug", ")", ":", "return", "public_download", "(", "source", ",", "username", ",", "directory", ",", "max_size", ",", "quiet", ",", "de...
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
train
download_url
Download a file. :param result: This field contains a url from which data will be downloaded. :param directory: This field is the target directory to which data will be downloaded. :param max_bytes: This field is the maximum file size in bytes.
ohapi/public.py
def download_url(result, directory, max_bytes): """ Download a file. :param result: This field contains a url from which data will be downloaded. :param directory: This field is the target directory to which data will be downloaded. :param max_bytes: This field is the maximum file s...
def download_url(result, directory, max_bytes): """ Download a file. :param result: This field contains a url from which data will be downloaded. :param directory: This field is the target directory to which data will be downloaded. :param max_bytes: This field is the maximum file s...
[ "Download", "a", "file", "." ]
OpenHumans/open-humans-api
python
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/public.py#L37-L99
[ "def", "download_url", "(", "result", ",", "directory", ",", "max_bytes", ")", ":", "response", "=", "requests", ".", "get", "(", "result", "[", "'download_url'", "]", ",", "stream", "=", "True", ")", "# TODO: make this more robust by parsing the URL", "filename",...
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
train
download
Download public data from Open Humans. :param source: This field is the data source from which to download. It's default value is None. :param username: This fiels is username of user. It's default value is None. :param directory: This field is the target directory to which data is ...
ohapi/public.py
def download(source=None, username=None, directory='.', max_size='128m', quiet=None, debug=None): """ Download public data from Open Humans. :param source: This field is the data source from which to download. It's default value is None. :param username: This fiels is username of u...
def download(source=None, username=None, directory='.', max_size='128m', quiet=None, debug=None): """ Download public data from Open Humans. :param source: This field is the data source from which to download. It's default value is None. :param username: This fiels is username of u...
[ "Download", "public", "data", "from", "Open", "Humans", "." ]
OpenHumans/open-humans-api
python
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/public.py#L102-L172
[ "def", "download", "(", "source", "=", "None", ",", "username", "=", "None", ",", "directory", "=", "'.'", ",", "max_size", "=", "'128m'", ",", "quiet", "=", "None", ",", "debug", "=", "None", ")", ":", "if", "debug", ":", "logging", ".", "basicConfi...
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
train
get_members_by_source
Function returns which members have joined each activity. :param base_url: It is URL: `https://www.openhumans.org/api/public-data`.
ohapi/public.py
def get_members_by_source(base_url=BASE_URL_API): """ Function returns which members have joined each activity. :param base_url: It is URL: `https://www.openhumans.org/api/public-data`. """ url = '{}members-by-source/'.format(base_url) response = get_page(url) return response
def get_members_by_source(base_url=BASE_URL_API): """ Function returns which members have joined each activity. :param base_url: It is URL: `https://www.openhumans.org/api/public-data`. """ url = '{}members-by-source/'.format(base_url) response = get_page(url) return response
[ "Function", "returns", "which", "members", "have", "joined", "each", "activity", "." ]
OpenHumans/open-humans-api
python
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/public.py#L175-L183
[ "def", "get_members_by_source", "(", "base_url", "=", "BASE_URL_API", ")", ":", "url", "=", "'{}members-by-source/'", ".", "format", "(", "base_url", ")", "response", "=", "get_page", "(", "url", ")", "return", "response" ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
train
get_sources_by_member
Function returns which activities each member has joined. :param base_url: It is URL: `https://www.openhumans.org/api/public-data`. :param limit: It is the limit of data send by one request.
ohapi/public.py
def get_sources_by_member(base_url=BASE_URL_API, limit=LIMIT_DEFAULT): """ Function returns which activities each member has joined. :param base_url: It is URL: `https://www.openhumans.org/api/public-data`. :param limit: It is the limit of data send by one request. """ url = '{}sources-by-membe...
def get_sources_by_member(base_url=BASE_URL_API, limit=LIMIT_DEFAULT): """ Function returns which activities each member has joined. :param base_url: It is URL: `https://www.openhumans.org/api/public-data`. :param limit: It is the limit of data send by one request. """ url = '{}sources-by-membe...
[ "Function", "returns", "which", "activities", "each", "member", "has", "joined", "." ]
OpenHumans/open-humans-api
python
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/public.py#L186-L203
[ "def", "get_sources_by_member", "(", "base_url", "=", "BASE_URL_API", ",", "limit", "=", "LIMIT_DEFAULT", ")", ":", "url", "=", "'{}sources-by-member/'", ".", "format", "(", "base_url", ")", "page", "=", "'{}?{}'", ".", "format", "(", "url", ",", "urlencode", ...
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
train
OHProject._get_member_file_data
Helper function to get file data of member of a project. :param member_data: This field is data related to member in a project.
ohapi/projects.py
def _get_member_file_data(member_data, id_filename=False): """ Helper function to get file data of member of a project. :param member_data: This field is data related to member in a project. """ file_data = {} for datafile in member_data['data']: if id_filena...
def _get_member_file_data(member_data, id_filename=False): """ Helper function to get file data of member of a project. :param member_data: This field is data related to member in a project. """ file_data = {} for datafile in member_data['data']: if id_filena...
[ "Helper", "function", "to", "get", "file", "data", "of", "member", "of", "a", "project", "." ]
OpenHumans/open-humans-api
python
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/projects.py#L27-L43
[ "def", "_get_member_file_data", "(", "member_data", ",", "id_filename", "=", "False", ")", ":", "file_data", "=", "{", "}", "for", "datafile", "in", "member_data", "[", "'data'", "]", ":", "if", "id_filename", ":", "basename", "=", "'{}.{}'", ".", "format", ...
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
train
OHProject.update_data
Returns data for all users including shared data files.
ohapi/projects.py
def update_data(self): """ Returns data for all users including shared data files. """ url = ('https://www.openhumans.org/api/direct-sharing/project/' 'members/?access_token={}'.format(self.master_access_token)) results = get_all_results(url) self.project_d...
def update_data(self): """ Returns data for all users including shared data files. """ url = ('https://www.openhumans.org/api/direct-sharing/project/' 'members/?access_token={}'.format(self.master_access_token)) results = get_all_results(url) self.project_d...
[ "Returns", "data", "for", "all", "users", "including", "shared", "data", "files", "." ]
OpenHumans/open-humans-api
python
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/projects.py#L45-L63
[ "def", "update_data", "(", "self", ")", ":", "url", "=", "(", "'https://www.openhumans.org/api/direct-sharing/project/'", "'members/?access_token={}'", ".", "format", "(", "self", ".", "master_access_token", ")", ")", "results", "=", "get_all_results", "(", "url", ")"...
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
train
OHProject.download_member_project_data
Download files to sync a local dir to match OH member project data. :param member_data: This field is data related to member in a project. :param target_member_dir: This field is the target directory where data will be downloaded. :param max_size: This field is the maximum file size...
ohapi/projects.py
def download_member_project_data(cls, member_data, target_member_dir, max_size=MAX_SIZE_DEFAULT, id_filename=False): """ Download files to sync a local dir to match OH member project data. :param member_data: This field i...
def download_member_project_data(cls, member_data, target_member_dir, max_size=MAX_SIZE_DEFAULT, id_filename=False): """ Download files to sync a local dir to match OH member project data. :param member_data: This field i...
[ "Download", "files", "to", "sync", "a", "local", "dir", "to", "match", "OH", "member", "project", "data", "." ]
OpenHumans/open-humans-api
python
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/projects.py#L66-L91
[ "def", "download_member_project_data", "(", "cls", ",", "member_data", ",", "target_member_dir", ",", "max_size", "=", "MAX_SIZE_DEFAULT", ",", "id_filename", "=", "False", ")", ":", "logging", ".", "debug", "(", "'Download member project data...'", ")", "sources_shar...
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
train
OHProject.download_member_shared
Download files to sync a local dir to match OH member shared data. Files are downloaded to match their "basename" on Open Humans. If there are multiple files with the same name, the most recent is downloaded. :param member_data: This field is data related to member in a project. ...
ohapi/projects.py
def download_member_shared(cls, member_data, target_member_dir, source=None, max_size=MAX_SIZE_DEFAULT, id_filename=False): """ Download files to sync a local dir to match OH member shared data. Files are downloaded to match their "basename" on Open Humans. ...
def download_member_shared(cls, member_data, target_member_dir, source=None, max_size=MAX_SIZE_DEFAULT, id_filename=False): """ Download files to sync a local dir to match OH member shared data. Files are downloaded to match their "basename" on Open Humans. ...
[ "Download", "files", "to", "sync", "a", "local", "dir", "to", "match", "OH", "member", "shared", "data", "." ]
OpenHumans/open-humans-api
python
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/projects.py#L94-L137
[ "def", "download_member_shared", "(", "cls", ",", "member_data", ",", "target_member_dir", ",", "source", "=", "None", ",", "max_size", "=", "MAX_SIZE_DEFAULT", ",", "id_filename", "=", "False", ")", ":", "logging", ".", "debug", "(", "'Download member shared data...
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
train
OHProject.download_all
Download data for all users including shared data files. :param target_dir: This field is the target directory to download data. :param source: This field is the data source. It's default value is None. :param project_data: This field is data related to particular project. ...
ohapi/projects.py
def download_all(self, target_dir, source=None, project_data=False, memberlist=None, excludelist=None, max_size=MAX_SIZE_DEFAULT, id_filename=False): """ Download data for all users including shared data files. :param target_dir: This field is the targe...
def download_all(self, target_dir, source=None, project_data=False, memberlist=None, excludelist=None, max_size=MAX_SIZE_DEFAULT, id_filename=False): """ Download data for all users including shared data files. :param target_dir: This field is the targe...
[ "Download", "data", "for", "all", "users", "including", "shared", "data", "files", "." ]
OpenHumans/open-humans-api
python
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/projects.py#L139-L180
[ "def", "download_all", "(", "self", ",", "target_dir", ",", "source", "=", "None", ",", "project_data", "=", "False", ",", "memberlist", "=", "None", ",", "excludelist", "=", "None", ",", "max_size", "=", "MAX_SIZE_DEFAULT", ",", "id_filename", "=", "False",...
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
train
OHProject.upload_member_from_dir
Upload files in target directory to an Open Humans member's account. The default behavior is to overwrite files with matching filenames on Open Humans, but not otherwise delete files. If the 'mode' parameter is 'safe': matching filenames will not be overwritten. If the 'mode' ...
ohapi/projects.py
def upload_member_from_dir(member_data, target_member_dir, metadata, access_token, mode='default', max_size=MAX_SIZE_DEFAULT): """ Upload files in target directory to an Open Humans member's account. The default behavior is to overwr...
def upload_member_from_dir(member_data, target_member_dir, metadata, access_token, mode='default', max_size=MAX_SIZE_DEFAULT): """ Upload files in target directory to an Open Humans member's account. The default behavior is to overwr...
[ "Upload", "files", "in", "target", "directory", "to", "an", "Open", "Humans", "member", "s", "account", "." ]
OpenHumans/open-humans-api
python
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/projects.py#L183-L232
[ "def", "upload_member_from_dir", "(", "member_data", ",", "target_member_dir", ",", "metadata", ",", "access_token", ",", "mode", "=", "'default'", ",", "max_size", "=", "MAX_SIZE_DEFAULT", ")", ":", "if", "not", "validate_metadata", "(", "target_member_dir", ",", ...
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
train
oauth2_auth_url
Returns an OAuth2 authorization URL for a project, given Client ID. This function constructs an authorization URL for a user to follow. The user will be redirected to Authorize Open Humans data for our external application. An OAuth2 project on Open Humans is required for this to properly work. To learn...
ohapi/api.py
def oauth2_auth_url(redirect_uri=None, client_id=None, base_url=OH_BASE_URL): """ Returns an OAuth2 authorization URL for a project, given Client ID. This function constructs an authorization URL for a user to follow. The user will be redirected to Authorize Open Humans data for our external applica...
def oauth2_auth_url(redirect_uri=None, client_id=None, base_url=OH_BASE_URL): """ Returns an OAuth2 authorization URL for a project, given Client ID. This function constructs an authorization URL for a user to follow. The user will be redirected to Authorize Open Humans data for our external applica...
[ "Returns", "an", "OAuth2", "authorization", "URL", "for", "a", "project", "given", "Client", "ID", ".", "This", "function", "constructs", "an", "authorization", "URL", "for", "a", "user", "to", "follow", ".", "The", "user", "will", "be", "redirected", "to", ...
OpenHumans/open-humans-api
python
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L27-L60
[ "def", "oauth2_auth_url", "(", "redirect_uri", "=", "None", ",", "client_id", "=", "None", ",", "base_url", "=", "OH_BASE_URL", ")", ":", "if", "not", "client_id", ":", "client_id", "=", "os", ".", "getenv", "(", "'OHAPI_CLIENT_ID'", ")", "if", "not", "cli...
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
train
oauth2_token_exchange
Exchange code or refresh token for a new token and refresh token. For the first time when a project is created, code is required to generate refresh token. Once the refresh token is obtained, it can be used later on for obtaining new access token and refresh token. The user must store the refresh token ...
ohapi/api.py
def oauth2_token_exchange(client_id, client_secret, redirect_uri, base_url=OH_BASE_URL, code=None, refresh_token=None): """ Exchange code or refresh token for a new token and refresh token. For the first time when a project is created, code is required to generate refresh token...
def oauth2_token_exchange(client_id, client_secret, redirect_uri, base_url=OH_BASE_URL, code=None, refresh_token=None): """ Exchange code or refresh token for a new token and refresh token. For the first time when a project is created, code is required to generate refresh token...
[ "Exchange", "code", "or", "refresh", "token", "for", "a", "new", "token", "and", "refresh", "token", ".", "For", "the", "first", "time", "when", "a", "project", "is", "created", "code", "is", "required", "to", "generate", "refresh", "token", ".", "Once", ...
OpenHumans/open-humans-api
python
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L63-L101
[ "def", "oauth2_token_exchange", "(", "client_id", ",", "client_secret", ",", "redirect_uri", ",", "base_url", "=", "OH_BASE_URL", ",", "code", "=", "None", ",", "refresh_token", "=", "None", ")", ":", "if", "not", "(", "code", "or", "refresh_token", ")", "or...
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
train
get_page
Get a single page of results. :param url: This field is the url from which data will be requested.
ohapi/api.py
def get_page(url): """ Get a single page of results. :param url: This field is the url from which data will be requested. """ response = requests.get(url) handle_error(response, 200) data = response.json() return data
def get_page(url): """ Get a single page of results. :param url: This field is the url from which data will be requested. """ response = requests.get(url) handle_error(response, 200) data = response.json() return data
[ "Get", "a", "single", "page", "of", "results", "." ]
OpenHumans/open-humans-api
python
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L104-L113
[ "def", "get_page", "(", "url", ")", ":", "response", "=", "requests", ".", "get", "(", "url", ")", "handle_error", "(", "response", ",", "200", ")", "data", "=", "response", ".", "json", "(", ")", "return", "data" ]
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
train
get_all_results
Given starting API query for Open Humans, iterate to get all results. :param starting page: This field is the first page, starting from which results will be obtained.
ohapi/api.py
def get_all_results(starting_page): """ Given starting API query for Open Humans, iterate to get all results. :param starting page: This field is the first page, starting from which results will be obtained. """ logging.info('Retrieving all results for {}'.format(starting_page)) page = ...
def get_all_results(starting_page): """ Given starting API query for Open Humans, iterate to get all results. :param starting page: This field is the first page, starting from which results will be obtained. """ logging.info('Retrieving all results for {}'.format(starting_page)) page = ...
[ "Given", "starting", "API", "query", "for", "Open", "Humans", "iterate", "to", "get", "all", "results", "." ]
OpenHumans/open-humans-api
python
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L116-L138
[ "def", "get_all_results", "(", "starting_page", ")", ":", "logging", ".", "info", "(", "'Retrieving all results for {}'", ".", "format", "(", "starting_page", ")", ")", "page", "=", "starting_page", "results", "=", "[", "]", "while", "True", ":", "logging", "....
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
train
exchange_oauth2_member
Returns data for a specific user, including shared data files. :param access_token: This field is the user specific access_token. :param base_url: It is this URL `https://www.openhumans.org`.
ohapi/api.py
def exchange_oauth2_member(access_token, base_url=OH_BASE_URL, all_files=False): """ Returns data for a specific user, including shared data files. :param access_token: This field is the user specific access_token. :param base_url: It is this URL `https://www.openhumans.org`....
def exchange_oauth2_member(access_token, base_url=OH_BASE_URL, all_files=False): """ Returns data for a specific user, including shared data files. :param access_token: This field is the user specific access_token. :param base_url: It is this URL `https://www.openhumans.org`....
[ "Returns", "data", "for", "a", "specific", "user", "including", "shared", "data", "files", "." ]
OpenHumans/open-humans-api
python
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L141-L164
[ "def", "exchange_oauth2_member", "(", "access_token", ",", "base_url", "=", "OH_BASE_URL", ",", "all_files", "=", "False", ")", ":", "url", "=", "urlparse", ".", "urljoin", "(", "base_url", ",", "'/api/direct-sharing/project/exchange-member/?{}'", ".", "format", "("...
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
train
delete_file
Delete project member files by file_basename, file_id, or all_files. To learn more about Open Humans OAuth2 projects, go to: https://www.openhumans.org/direct-sharing/oauth2-features/. :param access_token: This field is user specific access_token. :param project_member_id: This field is the pro...
ohapi/api.py
def delete_file(access_token, project_member_id=None, base_url=OH_BASE_URL, file_basename=None, file_id=None, all_files=False): """ Delete project member files by file_basename, file_id, or all_files. To learn more about Open Humans OAuth2 projects, go to: https://www.openhumans....
def delete_file(access_token, project_member_id=None, base_url=OH_BASE_URL, file_basename=None, file_id=None, all_files=False): """ Delete project member files by file_basename, file_id, or all_files. To learn more about Open Humans OAuth2 projects, go to: https://www.openhumans....
[ "Delete", "project", "member", "files", "by", "file_basename", "file_id", "or", "all_files", ".", "To", "learn", "more", "about", "Open", "Humans", "OAuth2", "projects", "go", "to", ":", "https", ":", "//", "www", ".", "openhumans", ".", "org", "/", "direc...
OpenHumans/open-humans-api
python
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L166-L203
[ "def", "delete_file", "(", "access_token", ",", "project_member_id", "=", "None", ",", "base_url", "=", "OH_BASE_URL", ",", "file_basename", "=", "None", ",", "file_id", "=", "None", ",", "all_files", "=", "False", ")", ":", "url", "=", "urlparse", ".", "u...
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
train
message
Send an email to individual users or in bulk. To learn more about Open Humans OAuth2 projects, go to: https://www.openhumans.org/direct-sharing/oauth2-features/ :param subject: This field is the subject of the email. :param message: This field is the body of the email. :param access_token: This is ...
ohapi/api.py
def message(subject, message, access_token, all_members=False, project_member_ids=None, base_url=OH_BASE_URL): """ Send an email to individual users or in bulk. To learn more about Open Humans OAuth2 projects, go to: https://www.openhumans.org/direct-sharing/oauth2-features/ :param subj...
def message(subject, message, access_token, all_members=False, project_member_ids=None, base_url=OH_BASE_URL): """ Send an email to individual users or in bulk. To learn more about Open Humans OAuth2 projects, go to: https://www.openhumans.org/direct-sharing/oauth2-features/ :param subj...
[ "Send", "an", "email", "to", "individual", "users", "or", "in", "bulk", ".", "To", "learn", "more", "about", "Open", "Humans", "OAuth2", "projects", "go", "to", ":", "https", ":", "//", "www", ".", "openhumans", ".", "org", "/", "direct", "-", "sharing...
OpenHumans/open-humans-api
python
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L214-L247
[ "def", "message", "(", "subject", ",", "message", ",", "access_token", ",", "all_members", "=", "False", ",", "project_member_ids", "=", "None", ",", "base_url", "=", "OH_BASE_URL", ")", ":", "url", "=", "urlparse", ".", "urljoin", "(", "base_url", ",", "'...
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
train
handle_error
Helper function to match reponse of a request to the expected status code :param r: This field is the response of request. :param expected_code: This field is the expected status code for the function.
ohapi/api.py
def handle_error(r, expected_code): """ Helper function to match reponse of a request to the expected status code :param r: This field is the response of request. :param expected_code: This field is the expected status code for the function. """ code = r.status_code if code != e...
def handle_error(r, expected_code): """ Helper function to match reponse of a request to the expected status code :param r: This field is the response of request. :param expected_code: This field is the expected status code for the function. """ code = r.status_code if code != e...
[ "Helper", "function", "to", "match", "reponse", "of", "a", "request", "to", "the", "expected", "status", "code" ]
OpenHumans/open-humans-api
python
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L258-L277
[ "def", "handle_error", "(", "r", ",", "expected_code", ")", ":", "code", "=", "r", ".", "status_code", "if", "code", "!=", "expected_code", ":", "info", "=", "'API response status code {}'", ".", "format", "(", "code", ")", "try", ":", "if", "'detail'", "i...
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
train
upload_stream
Upload a file object using the "direct upload" feature, which uploads to an S3 bucket URL provided by the Open Humans API. To learn more about this API endpoint see: * https://www.openhumans.org/direct-sharing/on-site-data-upload/ * https://www.openhumans.org/direct-sharing/oauth2-data-upload/ :par...
ohapi/api.py
def upload_stream(stream, filename, metadata, access_token, base_url=OH_BASE_URL, remote_file_info=None, project_member_id=None, max_bytes=MAX_FILE_DEFAULT, file_identifier=None): """ Upload a file object using the "direct upload" feature, which uploads to ...
def upload_stream(stream, filename, metadata, access_token, base_url=OH_BASE_URL, remote_file_info=None, project_member_id=None, max_bytes=MAX_FILE_DEFAULT, file_identifier=None): """ Upload a file object using the "direct upload" feature, which uploads to ...
[ "Upload", "a", "file", "object", "using", "the", "direct", "upload", "feature", "which", "uploads", "to", "an", "S3", "bucket", "URL", "provided", "by", "the", "Open", "Humans", "API", ".", "To", "learn", "more", "about", "this", "API", "endpoint", "see", ...
OpenHumans/open-humans-api
python
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L280-L355
[ "def", "upload_stream", "(", "stream", ",", "filename", ",", "metadata", ",", "access_token", ",", "base_url", "=", "OH_BASE_URL", ",", "remote_file_info", "=", "None", ",", "project_member_id", "=", "None", ",", "max_bytes", "=", "MAX_FILE_DEFAULT", ",", "file_...
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
train
upload_file
Upload a file from a local filepath using the "direct upload" API. To learn more about this API endpoint see: * https://www.openhumans.org/direct-sharing/on-site-data-upload/ * https://www.openhumans.org/direct-sharing/oauth2-data-upload/ :param target_filepath: This field is the filepath of the file t...
ohapi/api.py
def upload_file(target_filepath, metadata, access_token, base_url=OH_BASE_URL, remote_file_info=None, project_member_id=None, max_bytes=MAX_FILE_DEFAULT): """ Upload a file from a local filepath using the "direct upload" API. To learn more about this API endpoint see: * h...
def upload_file(target_filepath, metadata, access_token, base_url=OH_BASE_URL, remote_file_info=None, project_member_id=None, max_bytes=MAX_FILE_DEFAULT): """ Upload a file from a local filepath using the "direct upload" API. To learn more about this API endpoint see: * h...
[ "Upload", "a", "file", "from", "a", "local", "filepath", "using", "the", "direct", "upload", "API", ".", "To", "learn", "more", "about", "this", "API", "endpoint", "see", ":", "*", "https", ":", "//", "www", ".", "openhumans", ".", "org", "/", "direct"...
OpenHumans/open-humans-api
python
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L358-L385
[ "def", "upload_file", "(", "target_filepath", ",", "metadata", ",", "access_token", ",", "base_url", "=", "OH_BASE_URL", ",", "remote_file_info", "=", "None", ",", "project_member_id", "=", "None", ",", "max_bytes", "=", "MAX_FILE_DEFAULT", ")", ":", "with", "op...
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
train
upload_aws
Upload a file from a local filepath using the "direct upload" API. Equivalent to upload_file. To learn more about this API endpoint see: * https://www.openhumans.org/direct-sharing/on-site-data-upload/ * https://www.openhumans.org/direct-sharing/oauth2-data-upload/ :param target_filepath: This field is...
ohapi/api.py
def upload_aws(target_filepath, metadata, access_token, base_url=OH_BASE_URL, remote_file_info=None, project_member_id=None, max_bytes=MAX_FILE_DEFAULT): """ Upload a file from a local filepath using the "direct upload" API. Equivalent to upload_file. To learn more about this A...
def upload_aws(target_filepath, metadata, access_token, base_url=OH_BASE_URL, remote_file_info=None, project_member_id=None, max_bytes=MAX_FILE_DEFAULT): """ Upload a file from a local filepath using the "direct upload" API. Equivalent to upload_file. To learn more about this A...
[ "Upload", "a", "file", "from", "a", "local", "filepath", "using", "the", "direct", "upload", "API", ".", "Equivalent", "to", "upload_file", ".", "To", "learn", "more", "about", "this", "API", "endpoint", "see", ":", "*", "https", ":", "//", "www", ".", ...
OpenHumans/open-humans-api
python
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L388-L411
[ "def", "upload_aws", "(", "target_filepath", ",", "metadata", ",", "access_token", ",", "base_url", "=", "OH_BASE_URL", ",", "remote_file_info", "=", "None", ",", "project_member_id", "=", "None", ",", "max_bytes", "=", "MAX_FILE_DEFAULT", ")", ":", "return", "u...
ca2a28cf5d55cfdae13dd222ba58c25565bdb86e
train
pack_list
Return the wire packed version of `from_`. `pack_type` should be some subclass of `xcffib.Struct`, or a string that can be passed to `struct.pack`. You must pass `size` if `pack_type` is a struct.pack string.
module/__init__.py
def pack_list(from_, pack_type): """ Return the wire packed version of `from_`. `pack_type` should be some subclass of `xcffib.Struct`, or a string that can be passed to `struct.pack`. You must pass `size` if `pack_type` is a struct.pack string. """ # We need from_ to not be empty if len(from_) ...
def pack_list(from_, pack_type): """ Return the wire packed version of `from_`. `pack_type` should be some subclass of `xcffib.Struct`, or a string that can be passed to `struct.pack`. You must pass `size` if `pack_type` is a struct.pack string. """ # We need from_ to not be empty if len(from_) ...
[ "Return", "the", "wire", "packed", "version", "of", "from_", ".", "pack_type", "should", "be", "some", "subclass", "of", "xcffib", ".", "Struct", "or", "a", "string", "that", "can", "be", "passed", "to", "struct", ".", "pack", ".", "You", "must", "pass",...
tych0/xcffib
python
https://github.com/tych0/xcffib/blob/c9c50c3ce513b130821f430be78c4c733626c707/module/__init__.py#L751-L793
[ "def", "pack_list", "(", "from_", ",", "pack_type", ")", ":", "# We need from_ to not be empty", "if", "len", "(", "from_", ")", "==", "0", ":", "return", "bytes", "(", ")", "if", "pack_type", "==", "'c'", ":", "if", "isinstance", "(", "from_", ",", "byt...
c9c50c3ce513b130821f430be78c4c733626c707
train
Connection.ensure_connected
Check that the connection is valid both before and after the function is invoked.
module/__init__.py
def ensure_connected(f): """ Check that the connection is valid both before and after the function is invoked. """ @functools.wraps(f) def wrapper(*args): self = args[0] self.invalid() try: return f(*args) fi...
def ensure_connected(f): """ Check that the connection is valid both before and after the function is invoked. """ @functools.wraps(f) def wrapper(*args): self = args[0] self.invalid() try: return f(*args) fi...
[ "Check", "that", "the", "connection", "is", "valid", "both", "before", "and", "after", "the", "function", "is", "invoked", "." ]
tych0/xcffib
python
https://github.com/tych0/xcffib/blob/c9c50c3ce513b130821f430be78c4c733626c707/module/__init__.py#L560-L573
[ "def", "ensure_connected", "(", "f", ")", ":", "@", "functools", ".", "wraps", "(", "f", ")", "def", "wrapper", "(", "*", "args", ")", ":", "self", "=", "args", "[", "0", "]", "self", ".", "invalid", "(", ")", "try", ":", "return", "f", "(", "*...
c9c50c3ce513b130821f430be78c4c733626c707
train
Connection.get_screen_pointers
Returns the xcb_screen_t for every screen useful for other bindings
module/__init__.py
def get_screen_pointers(self): """ Returns the xcb_screen_t for every screen useful for other bindings """ root_iter = lib.xcb_setup_roots_iterator(self._setup) screens = [root_iter.data] for i in range(self._setup.roots_len - 1): lib.xcb_screen_next(...
def get_screen_pointers(self): """ Returns the xcb_screen_t for every screen useful for other bindings """ root_iter = lib.xcb_setup_roots_iterator(self._setup) screens = [root_iter.data] for i in range(self._setup.roots_len - 1): lib.xcb_screen_next(...
[ "Returns", "the", "xcb_screen_t", "for", "every", "screen", "useful", "for", "other", "bindings" ]
tych0/xcffib
python
https://github.com/tych0/xcffib/blob/c9c50c3ce513b130821f430be78c4c733626c707/module/__init__.py#L586-L597
[ "def", "get_screen_pointers", "(", "self", ")", ":", "root_iter", "=", "lib", ".", "xcb_setup_roots_iterator", "(", "self", ".", "_setup", ")", "screens", "=", "[", "root_iter", ".", "data", "]", "for", "i", "in", "range", "(", "self", ".", "_setup", "."...
c9c50c3ce513b130821f430be78c4c733626c707
train
Connection.hoist_event
Hoist an xcb_generic_event_t to the right xcffib structure.
module/__init__.py
def hoist_event(self, e): """ Hoist an xcb_generic_event_t to the right xcffib structure. """ if e.response_type == 0: return self._process_error(ffi.cast("xcb_generic_error_t *", e)) # We mask off the high bit here because events sent with SendEvent have # this bit set. We ...
def hoist_event(self, e): """ Hoist an xcb_generic_event_t to the right xcffib structure. """ if e.response_type == 0: return self._process_error(ffi.cast("xcb_generic_error_t *", e)) # We mask off the high bit here because events sent with SendEvent have # this bit set. We ...
[ "Hoist", "an", "xcb_generic_event_t", "to", "the", "right", "xcffib", "structure", "." ]
tych0/xcffib
python
https://github.com/tych0/xcffib/blob/c9c50c3ce513b130821f430be78c4c733626c707/module/__init__.py#L681-L693
[ "def", "hoist_event", "(", "self", ",", "e", ")", ":", "if", "e", ".", "response_type", "==", "0", ":", "return", "self", ".", "_process_error", "(", "ffi", ".", "cast", "(", "\"xcb_generic_error_t *\"", ",", "e", ")", ")", "# We mask off the high bit here b...
c9c50c3ce513b130821f430be78c4c733626c707
train
ColumnList.serialize
Greedy serialization requires the value to either be a column or convertible to a column, whereas non-greedy serialization will pass through any string as-is and will only serialize Column objects. Non-greedy serialization is useful when preparing queries with custom filters or ...
googleanalytics/columns.py
def serialize(self, value, greedy=True): """ Greedy serialization requires the value to either be a column or convertible to a column, whereas non-greedy serialization will pass through any string as-is and will only serialize Column objects. Non-greedy serialization is ...
def serialize(self, value, greedy=True): """ Greedy serialization requires the value to either be a column or convertible to a column, whereas non-greedy serialization will pass through any string as-is and will only serialize Column objects. Non-greedy serialization is ...
[ "Greedy", "serialization", "requires", "the", "value", "to", "either", "be", "a", "column", "or", "convertible", "to", "a", "column", "whereas", "non", "-", "greedy", "serialization", "will", "pass", "through", "any", "string", "as", "-", "is", "and", "will"...
debrouwere/google-analytics
python
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/columns.py#L237-L254
[ "def", "serialize", "(", "self", ",", "value", ",", "greedy", "=", "True", ")", ":", "if", "greedy", "and", "not", "isinstance", "(", "value", ",", "Column", ")", ":", "value", "=", "self", ".", "normalize", "(", "value", ")", "if", "isinstance", "("...
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
train
describe
Generate a query by describing it as a series of actions and parameters to those actions. These map directly to Query methods and arguments to those methods. This is an alternative to the chaining interface. Mostly useful if you'd like to put your queries in a file, rather than in Python code.
googleanalytics/query.py
def describe(profile, description): """ Generate a query by describing it as a series of actions and parameters to those actions. These map directly to Query methods and arguments to those methods. This is an alternative to the chaining interface. Mostly useful if you'd like to put your queries...
def describe(profile, description): """ Generate a query by describing it as a series of actions and parameters to those actions. These map directly to Query methods and arguments to those methods. This is an alternative to the chaining interface. Mostly useful if you'd like to put your queries...
[ "Generate", "a", "query", "by", "describing", "it", "as", "a", "series", "of", "actions", "and", "parameters", "to", "those", "actions", ".", "These", "map", "directly", "to", "Query", "methods", "and", "arguments", "to", "those", "methods", "." ]
debrouwere/google-analytics
python
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L1093-L1105
[ "def", "describe", "(", "profile", ",", "description", ")", ":", "api_type", "=", "description", ".", "pop", "(", "'type'", ",", "'core'", ")", "api", "=", "getattr", "(", "profile", ",", "api_type", ")", "return", "refine", "(", "api", ".", "query", "...
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
train
refine
Refine a query from a dictionary of parameters that describes it. See `describe` for more information.
googleanalytics/query.py
def refine(query, description): """ Refine a query from a dictionary of parameters that describes it. See `describe` for more information. """ for attribute, arguments in description.items(): if hasattr(query, attribute): attribute = getattr(query, attribute) else: ...
def refine(query, description): """ Refine a query from a dictionary of parameters that describes it. See `describe` for more information. """ for attribute, arguments in description.items(): if hasattr(query, attribute): attribute = getattr(query, attribute) else: ...
[ "Refine", "a", "query", "from", "a", "dictionary", "of", "parameters", "that", "describes", "it", ".", "See", "describe", "for", "more", "information", "." ]
debrouwere/google-analytics
python
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L1107-L1135
[ "def", "refine", "(", "query", ",", "description", ")", ":", "for", "attribute", ",", "arguments", "in", "description", ".", "items", "(", ")", ":", "if", "hasattr", "(", "query", ",", "attribute", ")", ":", "attribute", "=", "getattr", "(", "query", "...
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
train
Query.set
`set` is a way to add raw properties to the request, for features that this module does not support or supports incompletely. For convenience's sake, it will serialize Column objects but will leave any other kind of value alone.
googleanalytics/query.py
def set(self, key=None, value=None, **kwargs): """ `set` is a way to add raw properties to the request, for features that this module does not support or supports incompletely. For convenience's sake, it will serialize Column objects but will leave any other kind of value...
def set(self, key=None, value=None, **kwargs): """ `set` is a way to add raw properties to the request, for features that this module does not support or supports incompletely. For convenience's sake, it will serialize Column objects but will leave any other kind of value...
[ "set", "is", "a", "way", "to", "add", "raw", "properties", "to", "the", "request", "for", "features", "that", "this", "module", "does", "not", "support", "or", "supports", "incompletely", ".", "For", "convenience", "s", "sake", "it", "will", "serialize", "...
debrouwere/google-analytics
python
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L430-L451
[ "def", "set", "(", "self", ",", "key", "=", "None", ",", "value", "=", "None", ",", "*", "*", "kwargs", ")", ":", "serialize", "=", "partial", "(", "self", ".", "api", ".", "columns", ".", "serialize", ",", "greedy", "=", "False", ")", "if", "key...
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
train
Query.description
A list of the metrics this query will ask for.
googleanalytics/query.py
def description(self): """ A list of the metrics this query will ask for. """ if 'metrics' in self.raw: metrics = self.raw['metrics'] head = metrics[0:-1] or metrics[0:1] text = ", ".join(head) if len(metrics) > 1: tail = m...
def description(self): """ A list of the metrics this query will ask for. """ if 'metrics' in self.raw: metrics = self.raw['metrics'] head = metrics[0:-1] or metrics[0:1] text = ", ".join(head) if len(metrics) > 1: tail = m...
[ "A", "list", "of", "the", "metrics", "this", "query", "will", "ask", "for", "." ]
debrouwere/google-analytics
python
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L469-L484
[ "def", "description", "(", "self", ")", ":", "if", "'metrics'", "in", "self", ".", "raw", ":", "metrics", "=", "self", ".", "raw", "[", "'metrics'", "]", "head", "=", "metrics", "[", "0", ":", "-", "1", "]", "or", "metrics", "[", "0", ":", "1", ...
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
train
Query.sort
Return a new query which will produce results sorted by one or more metrics or dimensions. You may use plain strings for the columns, or actual `Column`, `Metric` and `Dimension` objects. Add a minus in front of the metric (either the string or the object) to sort in descending ...
googleanalytics/query.py
def sort(self, *columns, **options): """ Return a new query which will produce results sorted by one or more metrics or dimensions. You may use plain strings for the columns, or actual `Column`, `Metric` and `Dimension` objects. Add a minus in front of the metric (either...
def sort(self, *columns, **options): """ Return a new query which will produce results sorted by one or more metrics or dimensions. You may use plain strings for the columns, or actual `Column`, `Metric` and `Dimension` objects. Add a minus in front of the metric (either...
[ "Return", "a", "new", "query", "which", "will", "produce", "results", "sorted", "by", "one", "or", "more", "metrics", "or", "dimensions", ".", "You", "may", "use", "plain", "strings", "for", "the", "columns", "or", "actual", "Column", "Metric", "and", "Dim...
debrouwere/google-analytics
python
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L515-L556
[ "def", "sort", "(", "self", ",", "*", "columns", ",", "*", "*", "options", ")", ":", "sorts", "=", "self", ".", "meta", ".", "setdefault", "(", "'sort'", ",", "[", "]", ")", "for", "column", "in", "columns", ":", "if", "isinstance", "(", "column", ...
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
train
Query.filter
Most of the actual functionality lives on the Column object and the `all` and `any` functions.
googleanalytics/query.py
def filter(self, value=None, exclude=False, **selection): """ Most of the actual functionality lives on the Column object and the `all` and `any` functions. """ filters = self.meta.setdefault('filters', []) if value and len(selection): raise ValueError("Cannot specify a filt...
def filter(self, value=None, exclude=False, **selection): """ Most of the actual functionality lives on the Column object and the `all` and `any` functions. """ filters = self.meta.setdefault('filters', []) if value and len(selection): raise ValueError("Cannot specify a filt...
[ "Most", "of", "the", "actual", "functionality", "lives", "on", "the", "Column", "object", "and", "the", "all", "and", "any", "functions", "." ]
debrouwere/google-analytics
python
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L559-L573
[ "def", "filter", "(", "self", ",", "value", "=", "None", ",", "exclude", "=", "False", ",", "*", "*", "selection", ")", ":", "filters", "=", "self", ".", "meta", ".", "setdefault", "(", "'filters'", ",", "[", "]", ")", "if", "value", "and", "len", ...
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
train
CoreQuery.precision
For queries that should run faster, you may specify a lower precision, and for those that need to be more precise, a higher precision: ```python # faster queries query.range('2014-01-01', '2014-01-31', precision=0) query.range('2014-01-01', '2014-01-31', precision='FASTER') ...
googleanalytics/query.py
def precision(self, precision): """ For queries that should run faster, you may specify a lower precision, and for those that need to be more precise, a higher precision: ```python # faster queries query.range('2014-01-01', '2014-01-31', precision=0) query.range(...
def precision(self, precision): """ For queries that should run faster, you may specify a lower precision, and for those that need to be more precise, a higher precision: ```python # faster queries query.range('2014-01-01', '2014-01-31', precision=0) query.range(...
[ "For", "queries", "that", "should", "run", "faster", "you", "may", "specify", "a", "lower", "precision", "and", "for", "those", "that", "need", "to", "be", "more", "precise", "a", "higher", "precision", ":" ]
debrouwere/google-analytics
python
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L702-L731
[ "def", "precision", "(", "self", ",", "precision", ")", ":", "if", "isinstance", "(", "precision", ",", "int", ")", ":", "precision", "=", "self", ".", "PRECISION_LEVELS", "[", "precision", "]", "if", "precision", "not", "in", "self", ".", "PRECISION_LEVEL...
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
train
CoreQuery.interval
Note that if you don't specify a granularity (either through the `interval` method or through the `hourly`, `daily`, `weekly`, `monthly` or `yearly` shortcut methods) you will get only a single result, encompassing the entire date range, per metric.
googleanalytics/query.py
def interval(self, granularity): """ Note that if you don't specify a granularity (either through the `interval` method or through the `hourly`, `daily`, `weekly`, `monthly` or `yearly` shortcut methods) you will get only a single result, encompassing the entire date range, per m...
def interval(self, granularity): """ Note that if you don't specify a granularity (either through the `interval` method or through the `hourly`, `daily`, `weekly`, `monthly` or `yearly` shortcut methods) you will get only a single result, encompassing the entire date range, per m...
[ "Note", "that", "if", "you", "don", "t", "specify", "a", "granularity", "(", "either", "through", "the", "interval", "method", "or", "through", "the", "hourly", "daily", "weekly", "monthly", "or", "yearly", "shortcut", "methods", ")", "you", "will", "get", ...
debrouwere/google-analytics
python
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L734-L755
[ "def", "interval", "(", "self", ",", "granularity", ")", ":", "if", "granularity", "==", "'total'", ":", "return", "self", "if", "not", "isinstance", "(", "granularity", ",", "int", ")", ":", "if", "granularity", "in", "self", ".", "GRANULARITY_LEVELS", ":...
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
train
CoreQuery.range
Return a new query that fetches metrics within a certain date range. ```python query.range('2014-01-01', '2014-06-30') ``` If you don't specify a `stop` argument, the date range will end today. If instead you meant to fetch just a single day's results, try: ```python ...
googleanalytics/query.py
def range(self, start=None, stop=None, months=0, days=0): """ Return a new query that fetches metrics within a certain date range. ```python query.range('2014-01-01', '2014-06-30') ``` If you don't specify a `stop` argument, the date range will end today. If instead ...
def range(self, start=None, stop=None, months=0, days=0): """ Return a new query that fetches metrics within a certain date range. ```python query.range('2014-01-01', '2014-06-30') ``` If you don't specify a `stop` argument, the date range will end today. If instead ...
[ "Return", "a", "new", "query", "that", "fetches", "metrics", "within", "a", "certain", "date", "range", "." ]
debrouwere/google-analytics
python
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L758-L798
[ "def", "range", "(", "self", ",", "start", "=", "None", ",", "stop", "=", "None", ",", "months", "=", "0", ",", "days", "=", "0", ")", ":", "start", ",", "stop", "=", "utils", ".", "date", ".", "range", "(", "start", ",", "stop", ",", "months",...
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
train
CoreQuery.limit
Return a new query, limited to a certain number of results. ```python # first 100 query.limit(100) # 50 to 60 query.limit(50, 10) ``` Please note carefully that Google Analytics uses 1-indexing on its rows.
googleanalytics/query.py
def limit(self, *_range): """ Return a new query, limited to a certain number of results. ```python # first 100 query.limit(100) # 50 to 60 query.limit(50, 10) ``` Please note carefully that Google Analytics uses 1-indexing on its rows. ...
def limit(self, *_range): """ Return a new query, limited to a certain number of results. ```python # first 100 query.limit(100) # 50 to 60 query.limit(50, 10) ``` Please note carefully that Google Analytics uses 1-indexing on its rows. ...
[ "Return", "a", "new", "query", "limited", "to", "a", "certain", "number", "of", "results", "." ]
debrouwere/google-analytics
python
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L866-L895
[ "def", "limit", "(", "self", ",", "*", "_range", ")", ":", "# uses the same argument order as", "# LIMIT in a SQL database", "if", "len", "(", "_range", ")", "==", "2", ":", "start", ",", "maximum", "=", "_range", "else", ":", "start", "=", "1", "maximum", ...
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
train
CoreQuery.segment
Return a new query, limited to a segment of all users or sessions. Accepts segment objects, filtered segment objects and segment names: ```python query.segment(account.segments['browser']) query.segment('browser') query.segment(account.segments['browser'].any('Chrome', 'Firefox...
googleanalytics/query.py
def segment(self, value=None, scope=None, metric_scope=None, **selection): """ Return a new query, limited to a segment of all users or sessions. Accepts segment objects, filtered segment objects and segment names: ```python query.segment(account.segments['browser']) qu...
def segment(self, value=None, scope=None, metric_scope=None, **selection): """ Return a new query, limited to a segment of all users or sessions. Accepts segment objects, filtered segment objects and segment names: ```python query.segment(account.segments['browser']) qu...
[ "Return", "a", "new", "query", "limited", "to", "a", "segment", "of", "all", "users", "or", "sessions", "." ]
debrouwere/google-analytics
python
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L909-L1003
[ "def", "segment", "(", "self", ",", "value", "=", "None", ",", "scope", "=", "None", ",", "metric_scope", "=", "None", ",", "*", "*", "selection", ")", ":", "\"\"\"\n Technical note to self about segments:\n\n * users or sessions\n * sequence or condi...
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
train
CoreQuery.next
Return a new query with a modified `start_index`. Mainly used internally to paginate through results.
googleanalytics/query.py
def next(self): """ Return a new query with a modified `start_index`. Mainly used internally to paginate through results. """ step = self.raw.get('max_results', 1000) start = self.raw.get('start_index', 1) + step self.raw['start_index'] = start return self
def next(self): """ Return a new query with a modified `start_index`. Mainly used internally to paginate through results. """ step = self.raw.get('max_results', 1000) start = self.raw.get('start_index', 1) + step self.raw['start_index'] = start return self
[ "Return", "a", "new", "query", "with", "a", "modified", "start_index", ".", "Mainly", "used", "internally", "to", "paginate", "through", "results", "." ]
debrouwere/google-analytics
python
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L1012-L1020
[ "def", "next", "(", "self", ")", ":", "step", "=", "self", ".", "raw", ".", "get", "(", "'max_results'", ",", "1000", ")", "start", "=", "self", ".", "raw", ".", "get", "(", "'start_index'", ",", "1", ")", "+", "step", "self", ".", "raw", "[", ...
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
train
CoreQuery.get
Run the query and return a `Report`. This method transparently handles paginated results, so even for results that are larger than the maximum amount of rows the Google Analytics API will return in a single request, or larger than the amount of rows as specified through `CoreQuery#step`...
googleanalytics/query.py
def get(self): """ Run the query and return a `Report`. This method transparently handles paginated results, so even for results that are larger than the maximum amount of rows the Google Analytics API will return in a single request, or larger than the amount of rows as specifi...
def get(self): """ Run the query and return a `Report`. This method transparently handles paginated results, so even for results that are larger than the maximum amount of rows the Google Analytics API will return in a single request, or larger than the amount of rows as specifi...
[ "Run", "the", "query", "and", "return", "a", "Report", "." ]
debrouwere/google-analytics
python
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L1022-L1050
[ "def", "get", "(", "self", ")", ":", "cursor", "=", "self", "report", "=", "None", "is_complete", "=", "False", "is_enough", "=", "False", "while", "not", "(", "is_enough", "or", "is_complete", ")", ":", "chunk", "=", "cursor", ".", "execute", "(", ")"...
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
train
RealTimeQuery.limit
Return a new query, limited to a certain number of results. Unlike core reporting queries, you cannot specify a starting point for live queries, just the maximum results returned. ```python # first 50 query.limit(50) ```
googleanalytics/query.py
def limit(self, maximum): """ Return a new query, limited to a certain number of results. Unlike core reporting queries, you cannot specify a starting point for live queries, just the maximum results returned. ```python # first 50 query.limit(50) ``` ...
def limit(self, maximum): """ Return a new query, limited to a certain number of results. Unlike core reporting queries, you cannot specify a starting point for live queries, just the maximum results returned. ```python # first 50 query.limit(50) ``` ...
[ "Return", "a", "new", "query", "limited", "to", "a", "certain", "number", "of", "results", "." ]
debrouwere/google-analytics
python
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L1068-L1085
[ "def", "limit", "(", "self", ",", "maximum", ")", ":", "self", ".", "meta", "[", "'limit'", "]", "=", "maximum", "self", ".", "raw", ".", "update", "(", "{", "'max_results'", ":", "maximum", ",", "}", ")", "return", "self" ]
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
train
Credentials.valid
Valid credentials are not necessarily correct, but they contain all necessary information for an authentication attempt.
googleanalytics/auth/credentials.py
def valid(self): """ Valid credentials are not necessarily correct, but they contain all necessary information for an authentication attempt. """ two_legged = self.client_email and self.private_key three_legged = self.client_id and self.client_secret return two_legged or ...
def valid(self): """ Valid credentials are not necessarily correct, but they contain all necessary information for an authentication attempt. """ two_legged = self.client_email and self.private_key three_legged = self.client_id and self.client_secret return two_legged or ...
[ "Valid", "credentials", "are", "not", "necessarily", "correct", "but", "they", "contain", "all", "necessary", "information", "for", "an", "authentication", "attempt", "." ]
debrouwere/google-analytics
python
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/auth/credentials.py#L136-L142
[ "def", "valid", "(", "self", ")", ":", "two_legged", "=", "self", ".", "client_email", "and", "self", ".", "private_key", "three_legged", "=", "self", ".", "client_id", "and", "self", ".", "client_secret", "return", "two_legged", "or", "three_legged", "or", ...
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
train
Credentials.complete
Complete credentials are valid and are either two-legged or include a token.
googleanalytics/auth/credentials.py
def complete(self): """ Complete credentials are valid and are either two-legged or include a token. """ return self.valid and (self.access_token or self.refresh_token or self.type == 2)
def complete(self): """ Complete credentials are valid and are either two-legged or include a token. """ return self.valid and (self.access_token or self.refresh_token or self.type == 2)
[ "Complete", "credentials", "are", "valid", "and", "are", "either", "two", "-", "legged", "or", "include", "a", "token", "." ]
debrouwere/google-analytics
python
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/auth/credentials.py#L149-L151
[ "def", "complete", "(", "self", ")", ":", "return", "self", ".", "valid", "and", "(", "self", ".", "access_token", "or", "self", ".", "refresh_token", "or", "self", ".", "type", "==", "2", ")" ]
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
train
authenticate
The `authenticate` function will authenticate the user with the Google Analytics API, using a variety of strategies: keyword arguments provided to this function, credentials stored in in environment variables, credentials stored in the keychain and, finally, by asking for missing information interactively i...
googleanalytics/auth/__init__.py
def authenticate( client_id=None, client_secret=None, client_email=None, private_key=None, access_token=None, refresh_token=None, account=None, webproperty=None, profile=None, identity=None, prefix=None, suffix=None, interactive=False, save=False): """ The `authen...
def authenticate( client_id=None, client_secret=None, client_email=None, private_key=None, access_token=None, refresh_token=None, account=None, webproperty=None, profile=None, identity=None, prefix=None, suffix=None, interactive=False, save=False): """ The `authen...
[ "The", "authenticate", "function", "will", "authenticate", "the", "user", "with", "the", "Google", "Analytics", "API", "using", "a", "variety", "of", "strategies", ":", "keyword", "arguments", "provided", "to", "this", "function", "credentials", "stored", "in", ...
debrouwere/google-analytics
python
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/auth/__init__.py#L43-L97
[ "def", "authenticate", "(", "client_id", "=", "None", ",", "client_secret", "=", "None", ",", "client_email", "=", "None", ",", "private_key", "=", "None", ",", "access_token", "=", "None", ",", "refresh_token", "=", "None", ",", "account", "=", "None", ",...
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
train
revoke
Given a client id, client secret and either an access token or a refresh token, revoke OAuth access to the Google Analytics data and remove any stored credentials that use these tokens.
googleanalytics/auth/__init__.py
def revoke(client_id, client_secret, client_email=None, private_key=None, access_token=None, refresh_token=None, identity=None, prefix=None, suffix=None): """ Given a client id, client secret and either an access token or a refresh token, revoke OAuth access to the Google Analytics ...
def revoke(client_id, client_secret, client_email=None, private_key=None, access_token=None, refresh_token=None, identity=None, prefix=None, suffix=None): """ Given a client id, client secret and either an access token or a refresh token, revoke OAuth access to the Google Analytics ...
[ "Given", "a", "client", "id", "client", "secret", "and", "either", "an", "access", "token", "or", "a", "refresh", "token", "revoke", "OAuth", "access", "to", "the", "Google", "Analytics", "data", "and", "remove", "any", "stored", "credentials", "that", "use"...
debrouwere/google-analytics
python
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/auth/__init__.py#L123-L151
[ "def", "revoke", "(", "client_id", ",", "client_secret", ",", "client_email", "=", "None", ",", "private_key", "=", "None", ",", "access_token", "=", "None", ",", "refresh_token", "=", "None", ",", "identity", "=", "None", ",", "prefix", "=", "None", ",", ...
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
train
query
e.g. googleanalytics --identity debrouwere --account debrouwere --webproperty http://debrouwere.org \ query pageviews \ --start yesterday --limit -10 --sort -pageviews \ --dimensions pagepath \ --debug
googleanalytics/commands/query.py
def query(scope, blueprint, debug, output, with_metadata, realtime, **description): """ e.g. googleanalytics --identity debrouwere --account debrouwere --webproperty http://debrouwere.org \ query pageviews \ --start yesterday --limit -10 --sort -pageviews \ --dimensi...
def query(scope, blueprint, debug, output, with_metadata, realtime, **description): """ e.g. googleanalytics --identity debrouwere --account debrouwere --webproperty http://debrouwere.org \ query pageviews \ --start yesterday --limit -10 --sort -pageviews \ --dimensi...
[ "e", ".", "g", "." ]
debrouwere/google-analytics
python
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/commands/query.py#L102-L130
[ "def", "query", "(", "scope", ",", "blueprint", ",", "debug", ",", "output", ",", "with_metadata", ",", "realtime", ",", "*", "*", "description", ")", ":", "if", "realtime", ":", "description", "[", "'type'", "]", "=", "'realtime'", "if", "blueprint", ":...
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
train
vectorize
Allows a method to accept one or more values, but internally deal only with a single item, and returning a list or a single item depending on what is desired.
googleanalytics/utils/functional.py
def vectorize(fn): """ Allows a method to accept one or more values, but internally deal only with a single item, and returning a list or a single item depending on what is desired. """ @functools.wraps(fn) def vectorized_method(self, values, *vargs, **kwargs): wrap = not isinst...
def vectorize(fn): """ Allows a method to accept one or more values, but internally deal only with a single item, and returning a list or a single item depending on what is desired. """ @functools.wraps(fn) def vectorized_method(self, values, *vargs, **kwargs): wrap = not isinst...
[ "Allows", "a", "method", "to", "accept", "one", "or", "more", "values", "but", "internally", "deal", "only", "with", "a", "single", "item", "and", "returning", "a", "list", "or", "a", "single", "item", "depending", "on", "what", "is", "desired", "." ]
debrouwere/google-analytics
python
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/utils/functional.py#L20-L45
[ "def", "vectorize", "(", "fn", ")", ":", "@", "functools", ".", "wraps", "(", "fn", ")", "def", "vectorized_method", "(", "self", ",", "values", ",", "*", "vargs", ",", "*", "*", "kwargs", ")", ":", "wrap", "=", "not", "isinstance", "(", "values", ...
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
train
Account.webproperties
A list of all web properties on this account. You may select a specific web property using its name, its id or an index. ```python account.webproperties[0] account.webproperties['UA-9234823-5'] account.webproperties['debrouwere.org'] ```
googleanalytics/account.py
def webproperties(self): """ A list of all web properties on this account. You may select a specific web property using its name, its id or an index. ```python account.webproperties[0] account.webproperties['UA-9234823-5'] account.webproperties['debrouwer...
def webproperties(self): """ A list of all web properties on this account. You may select a specific web property using its name, its id or an index. ```python account.webproperties[0] account.webproperties['UA-9234823-5'] account.webproperties['debrouwer...
[ "A", "list", "of", "all", "web", "properties", "on", "this", "account", ".", "You", "may", "select", "a", "specific", "web", "property", "using", "its", "name", "its", "id", "or", "an", "index", "." ]
debrouwere/google-analytics
python
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/account.py#L47-L63
[ "def", "webproperties", "(", "self", ")", ":", "raw_properties", "=", "self", ".", "service", ".", "management", "(", ")", ".", "webproperties", "(", ")", ".", "list", "(", "accountId", "=", "self", ".", "id", ")", ".", "execute", "(", ")", "[", "'it...
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
train
WebProperty.profiles
A list of all profiles on this web property. You may select a specific profile using its name, its id or an index. ```python property.profiles[0] property.profiles['9234823'] property.profiles['marketing profile'] ```
googleanalytics/account.py
def profiles(self): """ A list of all profiles on this web property. You may select a specific profile using its name, its id or an index. ```python property.profiles[0] property.profiles['9234823'] property.profiles['marketing profile'] ``` ...
def profiles(self): """ A list of all profiles on this web property. You may select a specific profile using its name, its id or an index. ```python property.profiles[0] property.profiles['9234823'] property.profiles['marketing profile'] ``` ...
[ "A", "list", "of", "all", "profiles", "on", "this", "web", "property", ".", "You", "may", "select", "a", "specific", "profile", "using", "its", "name", "its", "id", "or", "an", "index", "." ]
debrouwere/google-analytics
python
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/account.py#L98-L114
[ "def", "profiles", "(", "self", ")", ":", "raw_profiles", "=", "self", ".", "account", ".", "service", ".", "management", "(", ")", ".", "profiles", "(", ")", ".", "list", "(", "accountId", "=", "self", ".", "account", ".", "id", ",", "webPropertyId", ...
7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c
train
check_output_input
Run command with arguments and return its output as a byte string. If the exit code was non-zero it raises a CalledProcessError. The CalledProcessError object will have the return code in the returncode attribute and output in the output attribute. The arguments are the same as for the Popen construc...
texcla/libs/fastTextWikiTokenizer/subprocess_fix.py
def check_output_input(*popenargs, **kwargs): """Run command with arguments and return its output as a byte string. If the exit code was non-zero it raises a CalledProcessError. The CalledProcessError object will have the return code in the returncode attribute and output in the output attribute. ...
def check_output_input(*popenargs, **kwargs): """Run command with arguments and return its output as a byte string. If the exit code was non-zero it raises a CalledProcessError. The CalledProcessError object will have the return code in the returncode attribute and output in the output attribute. ...
[ "Run", "command", "with", "arguments", "and", "return", "its", "output", "as", "a", "byte", "string", "." ]
jfilter/text-classification-keras
python
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/libs/fastTextWikiTokenizer/subprocess_fix.py#L7-L63
[ "def", "check_output_input", "(", "*", "popenargs", ",", "*", "*", "kwargs", ")", ":", "if", "'stdout'", "in", "kwargs", ":", "raise", "ValueError", "(", "'stdout argument not allowed, it will be overridden.'", ")", "if", "'input'", "in", "kwargs", ":", "if", "'...
a59c652805da41d18937c7fdad0d9fd943cf8578
train
Tokenizer.create_token_indices
If `apply_encoding_options` is inadequate, one can retrieve tokens from `self.token_counts`, filter with a desired strategy and regenerate `token_index` using this method. The token index is subsequently used when `encode_texts` or `decode_texts` methods are called.
texcla/preprocessing/tokenizer.py
def create_token_indices(self, tokens): """If `apply_encoding_options` is inadequate, one can retrieve tokens from `self.token_counts`, filter with a desired strategy and regenerate `token_index` using this method. The token index is subsequently used when `encode_texts` or `decode_texts` method...
def create_token_indices(self, tokens): """If `apply_encoding_options` is inadequate, one can retrieve tokens from `self.token_counts`, filter with a desired strategy and regenerate `token_index` using this method. The token index is subsequently used when `encode_texts` or `decode_texts` method...
[ "If", "apply_encoding_options", "is", "inadequate", "one", "can", "retrieve", "tokens", "from", "self", ".", "token_counts", "filter", "with", "a", "desired", "strategy", "and", "regenerate", "token_index", "using", "this", "method", ".", "The", "token", "index", ...
jfilter/text-classification-keras
python
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/tokenizer.py#L70-L80
[ "def", "create_token_indices", "(", "self", ",", "tokens", ")", ":", "start_index", "=", "len", "(", "self", ".", "special_token", ")", "indices", "=", "list", "(", "range", "(", "len", "(", "tokens", ")", "+", "start_index", ")", ")", "# prepend because t...
a59c652805da41d18937c7fdad0d9fd943cf8578
train
Tokenizer.apply_encoding_options
Applies the given settings for subsequent calls to `encode_texts` and `decode_texts`. This allows you to play with different settings without having to re-run tokenization on the entire corpus. Args: min_token_count: The minimum token count (frequency) in order to include during encoding. A...
texcla/preprocessing/tokenizer.py
def apply_encoding_options(self, min_token_count=1, limit_top_tokens=None): """Applies the given settings for subsequent calls to `encode_texts` and `decode_texts`. This allows you to play with different settings without having to re-run tokenization on the entire corpus. Args: min_...
def apply_encoding_options(self, min_token_count=1, limit_top_tokens=None): """Applies the given settings for subsequent calls to `encode_texts` and `decode_texts`. This allows you to play with different settings without having to re-run tokenization on the entire corpus. Args: min_...
[ "Applies", "the", "given", "settings", "for", "subsequent", "calls", "to", "encode_texts", "and", "decode_texts", ".", "This", "allows", "you", "to", "play", "with", "different", "settings", "without", "having", "to", "re", "-", "run", "tokenization", "on", "t...
jfilter/text-classification-keras
python
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/tokenizer.py#L82-L111
[ "def", "apply_encoding_options", "(", "self", ",", "min_token_count", "=", "1", ",", "limit_top_tokens", "=", "None", ")", ":", "if", "not", "self", ".", "has_vocab", ":", "raise", "ValueError", "(", "\"You need to build the vocabulary using `build_vocab` \"", "\"befo...
a59c652805da41d18937c7fdad0d9fd943cf8578
train
Tokenizer.encode_texts
Encodes the given texts using internal vocabulary with optionally applied encoding options. See ``apply_encoding_options` to set various options. Args: texts: The list of text items to encode. unknown_token: The token to replace words that out of vocabulary. If none, those words...
texcla/preprocessing/tokenizer.py
def encode_texts(self, texts, unknown_token="<UNK>", verbose=1, **kwargs): """Encodes the given texts using internal vocabulary with optionally applied encoding options. See ``apply_encoding_options` to set various options. Args: texts: The list of text items to encode. ...
def encode_texts(self, texts, unknown_token="<UNK>", verbose=1, **kwargs): """Encodes the given texts using internal vocabulary with optionally applied encoding options. See ``apply_encoding_options` to set various options. Args: texts: The list of text items to encode. ...
[ "Encodes", "the", "given", "texts", "using", "internal", "vocabulary", "with", "optionally", "applied", "encoding", "options", ".", "See", "apply_encoding_options", "to", "set", "various", "options", "." ]
jfilter/text-classification-keras
python
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/tokenizer.py#L113-L151
[ "def", "encode_texts", "(", "self", ",", "texts", ",", "unknown_token", "=", "\"<UNK>\"", ",", "verbose", "=", "1", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "has_vocab", ":", "raise", "ValueError", "(", "\"You need to build the vocabulary...
a59c652805da41d18937c7fdad0d9fd943cf8578
train
Tokenizer.decode_texts
Decodes the texts using internal vocabulary. The list structure is maintained. Args: encoded_texts: The list of texts to decode. unknown_token: The placeholder value for unknown token. (Default value: "<UNK>") inplace: True to make changes inplace. (Default value: True) ...
texcla/preprocessing/tokenizer.py
def decode_texts(self, encoded_texts, unknown_token="<UNK>", inplace=True): """Decodes the texts using internal vocabulary. The list structure is maintained. Args: encoded_texts: The list of texts to decode. unknown_token: The placeholder value for unknown token. (Default value:...
def decode_texts(self, encoded_texts, unknown_token="<UNK>", inplace=True): """Decodes the texts using internal vocabulary. The list structure is maintained. Args: encoded_texts: The list of texts to decode. unknown_token: The placeholder value for unknown token. (Default value:...
[ "Decodes", "the", "texts", "using", "internal", "vocabulary", ".", "The", "list", "structure", "is", "maintained", "." ]
jfilter/text-classification-keras
python
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/tokenizer.py#L153-L176
[ "def", "decode_texts", "(", "self", ",", "encoded_texts", ",", "unknown_token", "=", "\"<UNK>\"", ",", "inplace", "=", "True", ")", ":", "if", "len", "(", "self", ".", "_token2idx", ")", "==", "0", ":", "raise", "ValueError", "(", "\"You need to build vocabu...
a59c652805da41d18937c7fdad0d9fd943cf8578
train
Tokenizer.build_vocab
Builds the internal vocabulary and computes various statistics. Args: texts: The list of text items to encode. verbose: The verbosity level for progress. Can be 0, 1, 2. (Default value = 1) **kwargs: The kwargs for `token_generator`.
texcla/preprocessing/tokenizer.py
def build_vocab(self, texts, verbose=1, **kwargs): """Builds the internal vocabulary and computes various statistics. Args: texts: The list of text items to encode. verbose: The verbosity level for progress. Can be 0, 1, 2. (Default value = 1) **kwargs: The kwargs fo...
def build_vocab(self, texts, verbose=1, **kwargs): """Builds the internal vocabulary and computes various statistics. Args: texts: The list of text items to encode. verbose: The verbosity level for progress. Can be 0, 1, 2. (Default value = 1) **kwargs: The kwargs fo...
[ "Builds", "the", "internal", "vocabulary", "and", "computes", "various", "statistics", "." ]
jfilter/text-classification-keras
python
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/tokenizer.py#L207-L239
[ "def", "build_vocab", "(", "self", ",", "texts", ",", "verbose", "=", "1", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "has_vocab", ":", "logger", ".", "warn", "(", "\"Tokenizer already has existing vocabulary. Overriding and building new vocabulary.\"", ...
a59c652805da41d18937c7fdad0d9fd943cf8578
train
Tokenizer.pad_sequences
Pads each sequence to the same fixed length (length of the longest sequence or provided override). Args: sequences: list of list (samples, words) or list of list of list (samples, sentences, words) fixed_sentences_seq_length: The fix sentence sequence length to use. If None, largest sen...
texcla/preprocessing/tokenizer.py
def pad_sequences(self, sequences, fixed_sentences_seq_length=None, fixed_token_seq_length=None, padding='pre', truncating='post', padding_token="<PAD>"): """Pads each sequence to the same fixed length (length of the longest sequence or provided override). Args: sequen...
def pad_sequences(self, sequences, fixed_sentences_seq_length=None, fixed_token_seq_length=None, padding='pre', truncating='post', padding_token="<PAD>"): """Pads each sequence to the same fixed length (length of the longest sequence or provided override). Args: sequen...
[ "Pads", "each", "sequence", "to", "the", "same", "fixed", "length", "(", "length", "of", "the", "longest", "sequence", "or", "provided", "override", ")", "." ]
jfilter/text-classification-keras
python
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/tokenizer.py#L241-L271
[ "def", "pad_sequences", "(", "self", ",", "sequences", ",", "fixed_sentences_seq_length", "=", "None", ",", "fixed_token_seq_length", "=", "None", ",", "padding", "=", "'pre'", ",", "truncating", "=", "'post'", ",", "padding_token", "=", "\"<PAD>\"", ")", ":", ...
a59c652805da41d18937c7fdad0d9fd943cf8578
train
Tokenizer.get_stats
Gets the standard statistics for aux_index `i`. For example, if `token_generator` generates `(text_idx, sentence_idx, word)`, then `get_stats(0)` will return various statistics about sentence lengths across texts. Similarly, `get_counts(1)` will return statistics of token lengths across sentences. ...
texcla/preprocessing/tokenizer.py
def get_stats(self, i): """Gets the standard statistics for aux_index `i`. For example, if `token_generator` generates `(text_idx, sentence_idx, word)`, then `get_stats(0)` will return various statistics about sentence lengths across texts. Similarly, `get_counts(1)` will return statistics of to...
def get_stats(self, i): """Gets the standard statistics for aux_index `i`. For example, if `token_generator` generates `(text_idx, sentence_idx, word)`, then `get_stats(0)` will return various statistics about sentence lengths across texts. Similarly, `get_counts(1)` will return statistics of to...
[ "Gets", "the", "standard", "statistics", "for", "aux_index", "i", ".", "For", "example", "if", "token_generator", "generates", "(", "text_idx", "sentence_idx", "word", ")", "then", "get_stats", "(", "0", ")", "will", "return", "various", "statistics", "about", ...
jfilter/text-classification-keras
python
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/tokenizer.py#L286-L299
[ "def", "get_stats", "(", "self", ",", "i", ")", ":", "# OrderedDict to always show same order if printed.", "result", "=", "OrderedDict", "(", ")", "result", "[", "'min'", "]", "=", "np", ".", "min", "(", "self", ".", "_counts", "[", "i", "]", ")", "result...
a59c652805da41d18937c7fdad0d9fd943cf8578
train
build_embedding_weights
Builds an embedding matrix for all words in vocab using embeddings_index
texcla/embeddings.py
def build_embedding_weights(word_index, embeddings_index): """Builds an embedding matrix for all words in vocab using embeddings_index """ logger.info('Loading embeddings for all words in the corpus') embedding_dim = list(embeddings_index.values())[0].shape[-1] # setting special tokens such as UNK ...
def build_embedding_weights(word_index, embeddings_index): """Builds an embedding matrix for all words in vocab using embeddings_index """ logger.info('Loading embeddings for all words in the corpus') embedding_dim = list(embeddings_index.values())[0].shape[-1] # setting special tokens such as UNK ...
[ "Builds", "an", "embedding", "matrix", "for", "all", "words", "in", "vocab", "using", "embeddings_index" ]
jfilter/text-classification-keras
python
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/embeddings.py#L146-L161
[ "def", "build_embedding_weights", "(", "word_index", ",", "embeddings_index", ")", ":", "logger", ".", "info", "(", "'Loading embeddings for all words in the corpus'", ")", "embedding_dim", "=", "list", "(", "embeddings_index", ".", "values", "(", ")", ")", "[", "0"...
a59c652805da41d18937c7fdad0d9fd943cf8578
train
build_fasttext_wiki_embedding_obj
FastText pre-trained word vectors for 294 languages, with 300 dimensions, trained on Wikipedia. It's recommended to use the same tokenizer for your data that was used to construct the embeddings. It's implemented as 'FasttextWikiTokenizer'. More information: https://fasttext.cc/docs/en/pretrained-vectors.html. Arg...
texcla/embeddings.py
def build_fasttext_wiki_embedding_obj(embedding_type): """FastText pre-trained word vectors for 294 languages, with 300 dimensions, trained on Wikipedia. It's recommended to use the same tokenizer for your data that was used to construct the embeddings. It's implemented as 'FasttextWikiTokenizer'. More information:...
def build_fasttext_wiki_embedding_obj(embedding_type): """FastText pre-trained word vectors for 294 languages, with 300 dimensions, trained on Wikipedia. It's recommended to use the same tokenizer for your data that was used to construct the embeddings. It's implemented as 'FasttextWikiTokenizer'. More information:...
[ "FastText", "pre", "-", "trained", "word", "vectors", "for", "294", "languages", "with", "300", "dimensions", "trained", "on", "Wikipedia", ".", "It", "s", "recommended", "to", "use", "the", "same", "tokenizer", "for", "your", "data", "that", "was", "used", ...
jfilter/text-classification-keras
python
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/embeddings.py#L164-L177
[ "def", "build_fasttext_wiki_embedding_obj", "(", "embedding_type", ")", ":", "lang", "=", "embedding_type", ".", "split", "(", "'.'", ")", "[", "2", "]", "return", "{", "'file'", ":", "'wiki.{}.vec'", ".", "format", "(", "lang", ")", ",", "'url'", ":", "'h...
a59c652805da41d18937c7fdad0d9fd943cf8578
train
build_fasttext_cc_embedding_obj
FastText pre-trained word vectors for 157 languages, with 300 dimensions, trained on Common Crawl and Wikipedia. Released in 2018, it succeesed the 2017 FastText Wikipedia embeddings. It's recommended to use the same tokenizer for your data that was used to construct the embeddings. This information and more can be fin...
texcla/embeddings.py
def build_fasttext_cc_embedding_obj(embedding_type): """FastText pre-trained word vectors for 157 languages, with 300 dimensions, trained on Common Crawl and Wikipedia. Released in 2018, it succeesed the 2017 FastText Wikipedia embeddings. It's recommended to use the same tokenizer for your data that was used to co...
def build_fasttext_cc_embedding_obj(embedding_type): """FastText pre-trained word vectors for 157 languages, with 300 dimensions, trained on Common Crawl and Wikipedia. Released in 2018, it succeesed the 2017 FastText Wikipedia embeddings. It's recommended to use the same tokenizer for your data that was used to co...
[ "FastText", "pre", "-", "trained", "word", "vectors", "for", "157", "languages", "with", "300", "dimensions", "trained", "on", "Common", "Crawl", "and", "Wikipedia", ".", "Released", "in", "2018", "it", "succeesed", "the", "2017", "FastText", "Wikipedia", "emb...
jfilter/text-classification-keras
python
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/embeddings.py#L180-L193
[ "def", "build_fasttext_cc_embedding_obj", "(", "embedding_type", ")", ":", "lang", "=", "embedding_type", ".", "split", "(", "'.'", ")", "[", "2", "]", "return", "{", "'file'", ":", "'cc.{}.300.vec.gz'", ".", "format", "(", "lang", ")", ",", "'url'", ":", ...
a59c652805da41d18937c7fdad0d9fd943cf8578
train
get_embeddings_index
Retrieves embeddings index from embedding name or path. Will automatically download and cache as needed. Args: embedding_type: The embedding type to load. embedding_path: Path to a local embedding to use instead of the embedding type. Ignores `embedding_type` if specified. Returns: The...
texcla/embeddings.py
def get_embeddings_index(embedding_type='glove.42B.300d', embedding_dims=None, embedding_path=None, cache=True): """Retrieves embeddings index from embedding name or path. Will automatically download and cache as needed. Args: embedding_type: The embedding type to load. embedding_path: Path to ...
def get_embeddings_index(embedding_type='glove.42B.300d', embedding_dims=None, embedding_path=None, cache=True): """Retrieves embeddings index from embedding name or path. Will automatically download and cache as needed. Args: embedding_type: The embedding type to load. embedding_path: Path to ...
[ "Retrieves", "embeddings", "index", "from", "embedding", "name", "or", "path", ".", "Will", "automatically", "download", "and", "cache", "as", "needed", "." ]
jfilter/text-classification-keras
python
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/embeddings.py#L211-L257
[ "def", "get_embeddings_index", "(", "embedding_type", "=", "'glove.42B.300d'", ",", "embedding_dims", "=", "None", ",", "embedding_path", "=", "None", ",", "cache", "=", "True", ")", ":", "if", "embedding_path", "is", "not", "None", ":", "embedding_type", "=", ...
a59c652805da41d18937c7fdad0d9fd943cf8578
train
CharTokenizer.token_generator
Yields tokens from texts as `(text_idx, character)`
texcla/preprocessing/char_tokenizer.py
def token_generator(self, texts, **kwargs): """Yields tokens from texts as `(text_idx, character)` """ for text_idx, text in enumerate(texts): if self.lower: text = text.lower() for char in text: yield text_idx, char
def token_generator(self, texts, **kwargs): """Yields tokens from texts as `(text_idx, character)` """ for text_idx, text in enumerate(texts): if self.lower: text = text.lower() for char in text: yield text_idx, char
[ "Yields", "tokens", "from", "texts", "as", "(", "text_idx", "character", ")" ]
jfilter/text-classification-keras
python
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/char_tokenizer.py#L27-L34
[ "def", "token_generator", "(", "self", ",", "texts", ",", "*", "*", "kwargs", ")", ":", "for", "text_idx", ",", "text", "in", "enumerate", "(", "texts", ")", ":", "if", "self", ".", "lower", ":", "text", "=", "text", ".", "lower", "(", ")", "for", ...
a59c652805da41d18937c7fdad0d9fd943cf8578
train
SentenceCharTokenizer.token_generator
Yields tokens from texts as `(text_idx, sent_idx, character)` Args: texts: The list of texts. **kwargs: Supported args include: n_threads/num_threads: Number of threads to use. Uses num_cpus - 1 by default. batch_size: The number of texts to accumulate in...
texcla/preprocessing/char_tokenizer.py
def token_generator(self, texts, **kwargs): """Yields tokens from texts as `(text_idx, sent_idx, character)` Args: texts: The list of texts. **kwargs: Supported args include: n_threads/num_threads: Number of threads to use. Uses num_cpus - 1 by default. ...
def token_generator(self, texts, **kwargs): """Yields tokens from texts as `(text_idx, sent_idx, character)` Args: texts: The list of texts. **kwargs: Supported args include: n_threads/num_threads: Number of threads to use. Uses num_cpus - 1 by default. ...
[ "Yields", "tokens", "from", "texts", "as", "(", "text_idx", "sent_idx", "character", ")" ]
jfilter/text-classification-keras
python
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/char_tokenizer.py#L53-L80
[ "def", "token_generator", "(", "self", ",", "texts", ",", "*", "*", "kwargs", ")", ":", "# Perf optimization. Only process what is necessary.", "n_threads", ",", "batch_size", "=", "utils", ".", "_parse_spacy_kwargs", "(", "*", "*", "kwargs", ")", "nlp", "=", "s...
a59c652805da41d18937c7fdad0d9fd943cf8578
train
equal_distribution_folds
Creates `folds` number of indices that has roughly balanced multi-label distribution. Args: y: The multi-label outputs. folds: The number of folds to create. Returns: `folds` number of indices that have roughly equal multi-label distributions.
texcla/utils/sampling.py
def equal_distribution_folds(y, folds=2): """Creates `folds` number of indices that has roughly balanced multi-label distribution. Args: y: The multi-label outputs. folds: The number of folds to create. Returns: `folds` number of indices that have roughly equal multi-label distribu...
def equal_distribution_folds(y, folds=2): """Creates `folds` number of indices that has roughly balanced multi-label distribution. Args: y: The multi-label outputs. folds: The number of folds to create. Returns: `folds` number of indices that have roughly equal multi-label distribu...
[ "Creates", "folds", "number", "of", "indices", "that", "has", "roughly", "balanced", "multi", "-", "label", "distribution", "." ]
jfilter/text-classification-keras
python
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/utils/sampling.py#L11-L44
[ "def", "equal_distribution_folds", "(", "y", ",", "folds", "=", "2", ")", ":", "n", ",", "classes", "=", "y", ".", "shape", "# Compute sample distribution over classes", "dist", "=", "y", ".", "sum", "(", "axis", "=", "0", ")", ".", "astype", "(", "'floa...
a59c652805da41d18937c7fdad0d9fd943cf8578
train
SentenceModelFactory.build_model
Builds a model that first encodes all words within sentences using `token_encoder_model`, followed by `sentence_encoder_model`. Args: token_encoder_model: An instance of `SequenceEncoderBase` for encoding tokens within sentences. This model will be applied across all sentenc...
texcla/models/sentence_model.py
def build_model(self, token_encoder_model, sentence_encoder_model, trainable_embeddings=True, output_activation='softmax'): """Builds a model that first encodes all words within sentences using `token_encoder_model`, followed by `sentence_encoder_model`. Args: to...
def build_model(self, token_encoder_model, sentence_encoder_model, trainable_embeddings=True, output_activation='softmax'): """Builds a model that first encodes all words within sentences using `token_encoder_model`, followed by `sentence_encoder_model`. Args: to...
[ "Builds", "a", "model", "that", "first", "encodes", "all", "words", "within", "sentences", "using", "token_encoder_model", "followed", "by", "sentence_encoder_model", "." ]
jfilter/text-classification-keras
python
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/models/sentence_model.py#L45-L104
[ "def", "build_model", "(", "self", ",", "token_encoder_model", ",", "sentence_encoder_model", ",", "trainable_embeddings", "=", "True", ",", "output_activation", "=", "'softmax'", ")", ":", "if", "not", "isinstance", "(", "token_encoder_model", ",", "SequenceEncoderBa...
a59c652805da41d18937c7fdad0d9fd943cf8578
train
process_save
Process text and save as Dataset
texcla/experiment.py
def process_save(X, y, tokenizer, proc_data_path, max_len=400, train=False, ngrams=None, limit_top_tokens=None): """Process text and save as Dataset """ if train and limit_top_tokens is not None: tokenizer.apply_encoding_options(limit_top_tokens=limit_top_tokens) X_encoded = tokenizer.encode_te...
def process_save(X, y, tokenizer, proc_data_path, max_len=400, train=False, ngrams=None, limit_top_tokens=None): """Process text and save as Dataset """ if train and limit_top_tokens is not None: tokenizer.apply_encoding_options(limit_top_tokens=limit_top_tokens) X_encoded = tokenizer.encode_te...
[ "Process", "text", "and", "save", "as", "Dataset" ]
jfilter/text-classification-keras
python
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/experiment.py#L106-L126
[ "def", "process_save", "(", "X", ",", "y", ",", "tokenizer", ",", "proc_data_path", ",", "max_len", "=", "400", ",", "train", "=", "False", ",", "ngrams", "=", "None", ",", "limit_top_tokens", "=", "None", ")", ":", "if", "train", "and", "limit_top_token...
a59c652805da41d18937c7fdad0d9fd943cf8578
train
setup_data
Setup data Args: X: text data, y: data labels, tokenizer: A Tokenizer instance proc_data_path: Path for the processed data
texcla/experiment.py
def setup_data(X, y, tokenizer, proc_data_path, **kwargs): """Setup data Args: X: text data, y: data labels, tokenizer: A Tokenizer instance proc_data_path: Path for the processed data """ # only build vocabulary once (e.g. training data) train = ...
def setup_data(X, y, tokenizer, proc_data_path, **kwargs): """Setup data Args: X: text data, y: data labels, tokenizer: A Tokenizer instance proc_data_path: Path for the processed data """ # only build vocabulary once (e.g. training data) train = ...
[ "Setup", "data" ]
jfilter/text-classification-keras
python
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/experiment.py#L129-L145
[ "def", "setup_data", "(", "X", ",", "y", ",", "tokenizer", ",", "proc_data_path", ",", "*", "*", "kwargs", ")", ":", "# only build vocabulary once (e.g. training data)", "train", "=", "not", "tokenizer", ".", "has_vocab", "if", "train", ":", "tokenizer", ".", ...
a59c652805da41d18937c7fdad0d9fd943cf8578
train
split_data
Splits data into a training, validation, and test set. Args: X: text data y: data labels ratio: the ratio for splitting. Default: (0.8, 0.1, 0.1) Returns: split data: X_train, X_val, X_test, y_train, y_val, y_test
texcla/experiment.py
def split_data(X, y, ratio=(0.8, 0.1, 0.1)): """Splits data into a training, validation, and test set. Args: X: text data y: data labels ratio: the ratio for splitting. Default: (0.8, 0.1, 0.1) Returns: split data: X_train, X_val, X_test, y_train, y_...
def split_data(X, y, ratio=(0.8, 0.1, 0.1)): """Splits data into a training, validation, and test set. Args: X: text data y: data labels ratio: the ratio for splitting. Default: (0.8, 0.1, 0.1) Returns: split data: X_train, X_val, X_test, y_train, y_...
[ "Splits", "data", "into", "a", "training", "validation", "and", "test", "set", "." ]
jfilter/text-classification-keras
python
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/experiment.py#L148-L164
[ "def", "split_data", "(", "X", ",", "y", ",", "ratio", "=", "(", "0.8", ",", "0.1", ",", "0.1", ")", ")", ":", "assert", "(", "sum", "(", "ratio", ")", "==", "1", "and", "len", "(", "ratio", ")", "==", "3", ")", "X_train", ",", "X_rest", ",",...
a59c652805da41d18937c7fdad0d9fd943cf8578
train
setup_data_split
Setup data while splitting into a training, validation, and test set. Args: X: text data, y: data labels, tokenizer: A Tokenizer instance proc_data_dir: Directory for the split and processed data
texcla/experiment.py
def setup_data_split(X, y, tokenizer, proc_data_dir, **kwargs): """Setup data while splitting into a training, validation, and test set. Args: X: text data, y: data labels, tokenizer: A Tokenizer instance proc_data_dir: Directory for the split and processed d...
def setup_data_split(X, y, tokenizer, proc_data_dir, **kwargs): """Setup data while splitting into a training, validation, and test set. Args: X: text data, y: data labels, tokenizer: A Tokenizer instance proc_data_dir: Directory for the split and processed d...
[ "Setup", "data", "while", "splitting", "into", "a", "training", "validation", "and", "test", "set", "." ]
jfilter/text-classification-keras
python
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/experiment.py#L167-L186
[ "def", "setup_data_split", "(", "X", ",", "y", ",", "tokenizer", ",", "proc_data_dir", ",", "*", "*", "kwargs", ")", ":", "X_train", ",", "X_val", ",", "X_test", ",", "y_train", ",", "y_val", ",", "y_test", "=", "split_data", "(", "X", ",", "y", ")",...
a59c652805da41d18937c7fdad0d9fd943cf8578
train
load_data_split
Loads a split dataset Args: proc_data_dir: Directory with the split and processed data Returns: (Training Data, Validation Data, Test Data)
texcla/experiment.py
def load_data_split(proc_data_dir): """Loads a split dataset Args: proc_data_dir: Directory with the split and processed data Returns: (Training Data, Validation Data, Test Data) """ ds_train = Dataset.load(path.join(proc_data_dir, 'train.bin')) ds_val = Dataset...
def load_data_split(proc_data_dir): """Loads a split dataset Args: proc_data_dir: Directory with the split and processed data Returns: (Training Data, Validation Data, Test Data) """ ds_train = Dataset.load(path.join(proc_data_dir, 'train.bin')) ds_val = Dataset...
[ "Loads", "a", "split", "dataset" ]
jfilter/text-classification-keras
python
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/experiment.py#L189-L201
[ "def", "load_data_split", "(", "proc_data_dir", ")", ":", "ds_train", "=", "Dataset", ".", "load", "(", "path", ".", "join", "(", "proc_data_dir", ",", "'train.bin'", ")", ")", "ds_val", "=", "Dataset", ".", "load", "(", "path", ".", "join", "(", "proc_d...
a59c652805da41d18937c7fdad0d9fd943cf8578
train
TokenModelFactory.build_model
Builds a model using the given `text_model` Args: token_encoder_model: An instance of `SequenceEncoderBase` for encoding all the tokens within a document. This encoding is then fed into a final `Dense` layer for classification. trainable_embeddings: Whether or not to fin...
texcla/models/token_model.py
def build_model(self, token_encoder_model, trainable_embeddings=True, output_activation='softmax'): """Builds a model using the given `text_model` Args: token_encoder_model: An instance of `SequenceEncoderBase` for encoding all the tokens within a document. This encoding is ...
def build_model(self, token_encoder_model, trainable_embeddings=True, output_activation='softmax'): """Builds a model using the given `text_model` Args: token_encoder_model: An instance of `SequenceEncoderBase` for encoding all the tokens within a document. This encoding is ...
[ "Builds", "a", "model", "using", "the", "given", "text_model" ]
jfilter/text-classification-keras
python
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/models/token_model.py#L39-L83
[ "def", "build_model", "(", "self", ",", "token_encoder_model", ",", "trainable_embeddings", "=", "True", ",", "output_activation", "=", "'softmax'", ")", ":", "if", "not", "isinstance", "(", "token_encoder_model", ",", "SequenceEncoderBase", ")", ":", "raise", "Va...
a59c652805da41d18937c7fdad0d9fd943cf8578
train
_softmax
Computes softmax along a specified dim. Keras currently lacks this feature.
texcla/models/layers.py
def _softmax(x, dim): """Computes softmax along a specified dim. Keras currently lacks this feature. """ if K.backend() == 'tensorflow': import tensorflow as tf return tf.nn.softmax(x, dim) elif K.backend() is 'cntk': import cntk return cntk.softmax(x, dim) elif K.ba...
def _softmax(x, dim): """Computes softmax along a specified dim. Keras currently lacks this feature. """ if K.backend() == 'tensorflow': import tensorflow as tf return tf.nn.softmax(x, dim) elif K.backend() is 'cntk': import cntk return cntk.softmax(x, dim) elif K.ba...
[ "Computes", "softmax", "along", "a", "specified", "dim", ".", "Keras", "currently", "lacks", "this", "feature", "." ]
jfilter/text-classification-keras
python
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/models/layers.py#L10-L33
[ "def", "_softmax", "(", "x", ",", "dim", ")", ":", "if", "K", ".", "backend", "(", ")", "==", "'tensorflow'", ":", "import", "tensorflow", "as", "tf", "return", "tf", ".", "nn", ".", "softmax", "(", "x", ",", "dim", ")", "elif", "K", ".", "backen...
a59c652805da41d18937c7fdad0d9fd943cf8578
train
SpacyTokenizer._apply_options
Applies various filtering and processing options on token. Returns: The processed token. None if filtered.
texcla/preprocessing/word_tokenizer.py
def _apply_options(self, token): """Applies various filtering and processing options on token. Returns: The processed token. None if filtered. """ # Apply work token filtering. if token.is_punct and self.remove_punct: return None if token.is_stop ...
def _apply_options(self, token): """Applies various filtering and processing options on token. Returns: The processed token. None if filtered. """ # Apply work token filtering. if token.is_punct and self.remove_punct: return None if token.is_stop ...
[ "Applies", "various", "filtering", "and", "processing", "options", "on", "token", "." ]
jfilter/text-classification-keras
python
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/word_tokenizer.py#L52-L77
[ "def", "_apply_options", "(", "self", ",", "token", ")", ":", "# Apply work token filtering.", "if", "token", ".", "is_punct", "and", "self", ".", "remove_punct", ":", "return", "None", "if", "token", ".", "is_stop", "and", "self", ".", "remove_stop_words", ":...
a59c652805da41d18937c7fdad0d9fd943cf8578
train
SpacyTokenizer.token_generator
Yields tokens from texts as `(text_idx, word)` Args: texts: The list of texts. **kwargs: Supported args include: n_threads/num_threads: Number of threads to use. Uses num_cpus - 1 by default. batch_size: The number of texts to accumulate into a common wor...
texcla/preprocessing/word_tokenizer.py
def token_generator(self, texts, **kwargs): """Yields tokens from texts as `(text_idx, word)` Args: texts: The list of texts. **kwargs: Supported args include: n_threads/num_threads: Number of threads to use. Uses num_cpus - 1 by default. batch_si...
def token_generator(self, texts, **kwargs): """Yields tokens from texts as `(text_idx, word)` Args: texts: The list of texts. **kwargs: Supported args include: n_threads/num_threads: Number of threads to use. Uses num_cpus - 1 by default. batch_si...
[ "Yields", "tokens", "from", "texts", "as", "(", "text_idx", "word", ")" ]
jfilter/text-classification-keras
python
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/word_tokenizer.py#L79-L107
[ "def", "token_generator", "(", "self", ",", "texts", ",", "*", "*", "kwargs", ")", ":", "# Perf optimization. Only process what is necessary.", "n_threads", ",", "batch_size", "=", "utils", ".", "_parse_spacy_kwargs", "(", "*", "*", "kwargs", ")", "nlp", "=", "s...
a59c652805da41d18937c7fdad0d9fd943cf8578
train
_append
Adds `value` to `lst` list indexed by `indices`. Will create sub lists as required.
texcla/preprocessing/utils.py
def _append(lst, indices, value): """Adds `value` to `lst` list indexed by `indices`. Will create sub lists as required. """ for i, idx in enumerate(indices): # We need to loop because sometimes indices can increment by more than 1 due to missing tokens. # Example: Sentence with no words aft...
def _append(lst, indices, value): """Adds `value` to `lst` list indexed by `indices`. Will create sub lists as required. """ for i, idx in enumerate(indices): # We need to loop because sometimes indices can increment by more than 1 due to missing tokens. # Example: Sentence with no words aft...
[ "Adds", "value", "to", "lst", "list", "indexed", "by", "indices", ".", "Will", "create", "sub", "lists", "as", "required", "." ]
jfilter/text-classification-keras
python
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/utils.py#L82-L95
[ "def", "_append", "(", "lst", ",", "indices", ",", "value", ")", ":", "for", "i", ",", "idx", "in", "enumerate", "(", "indices", ")", ":", "# We need to loop because sometimes indices can increment by more than 1 due to missing tokens.", "# Example: Sentence with no words a...
a59c652805da41d18937c7fdad0d9fd943cf8578
train
_parse_spacy_kwargs
Supported args include: Args: n_threads/num_threads: Number of threads to use. Uses num_cpus - 1 by default. batch_size: The number of texts to accumulate into a common working set before processing. (Default value: 1000)
texcla/preprocessing/utils.py
def _parse_spacy_kwargs(**kwargs): """Supported args include: Args: n_threads/num_threads: Number of threads to use. Uses num_cpus - 1 by default. batch_size: The number of texts to accumulate into a common working set before processing. (Default value: 1000) """ n_threads =...
def _parse_spacy_kwargs(**kwargs): """Supported args include: Args: n_threads/num_threads: Number of threads to use. Uses num_cpus - 1 by default. batch_size: The number of texts to accumulate into a common working set before processing. (Default value: 1000) """ n_threads =...
[ "Supported", "args", "include", ":" ]
jfilter/text-classification-keras
python
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/utils.py#L113-L128
[ "def", "_parse_spacy_kwargs", "(", "*", "*", "kwargs", ")", ":", "n_threads", "=", "kwargs", ".", "get", "(", "'n_threads'", ")", "or", "kwargs", ".", "get", "(", "'num_threads'", ")", "batch_size", "=", "kwargs", ".", "get", "(", "'batch_size'", ")", "i...
a59c652805da41d18937c7fdad0d9fd943cf8578
train
_CountTracker.update
Updates counts based on indices. The algorithm tracks the index change at i and update global counts for all indices beyond i with local counts tracked so far.
texcla/preprocessing/utils.py
def update(self, indices): """Updates counts based on indices. The algorithm tracks the index change at i and update global counts for all indices beyond i with local counts tracked so far. """ # Initialize various lists for the first time based on length of indices. if self._pre...
def update(self, indices): """Updates counts based on indices. The algorithm tracks the index change at i and update global counts for all indices beyond i with local counts tracked so far. """ # Initialize various lists for the first time based on length of indices. if self._pre...
[ "Updates", "counts", "based", "on", "indices", ".", "The", "algorithm", "tracks", "the", "index", "change", "at", "i", "and", "update", "global", "counts", "for", "all", "indices", "beyond", "i", "with", "local", "counts", "tracked", "so", "far", "." ]
jfilter/text-classification-keras
python
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/utils.py#L34-L62
[ "def", "update", "(", "self", ",", "indices", ")", ":", "# Initialize various lists for the first time based on length of indices.", "if", "self", ".", "_prev_indices", "is", "None", ":", "self", ".", "_prev_indices", "=", "indices", "# +1 to track token counts in the last ...
a59c652805da41d18937c7fdad0d9fd943cf8578
train
_CountTracker.finalize
This will add the very last document to counts. We also get rid of counts[0] since that represents document level which doesnt come under anything else. We also convert all count values to numpy arrays so that stats can be computed easily.
texcla/preprocessing/utils.py
def finalize(self): """This will add the very last document to counts. We also get rid of counts[0] since that represents document level which doesnt come under anything else. We also convert all count values to numpy arrays so that stats can be computed easily. """ for i in rang...
def finalize(self): """This will add the very last document to counts. We also get rid of counts[0] since that represents document level which doesnt come under anything else. We also convert all count values to numpy arrays so that stats can be computed easily. """ for i in rang...
[ "This", "will", "add", "the", "very", "last", "document", "to", "counts", ".", "We", "also", "get", "rid", "of", "counts", "[", "0", "]", "since", "that", "represents", "document", "level", "which", "doesnt", "come", "under", "anything", "else", ".", "We...
jfilter/text-classification-keras
python
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/utils.py#L64-L74
[ "def", "finalize", "(", "self", ")", ":", "for", "i", "in", "range", "(", "1", ",", "len", "(", "self", ".", "_local_counts", ")", ")", ":", "self", ".", "counts", "[", "i", "]", ".", "append", "(", "self", ".", "_local_counts", "[", "i", "]", ...
a59c652805da41d18937c7fdad0d9fd943cf8578
train
read_folder
read text files in directory and returns them as array Args: directory: where the text files are Returns: Array of text
texcla/corpus.py
def read_folder(directory): """read text files in directory and returns them as array Args: directory: where the text files are Returns: Array of text """ res = [] for filename in os.listdir(directory): with io.open(os.path.join(directory, filename), encoding="utf-8") a...
def read_folder(directory): """read text files in directory and returns them as array Args: directory: where the text files are Returns: Array of text """ res = [] for filename in os.listdir(directory): with io.open(os.path.join(directory, filename), encoding="utf-8") a...
[ "read", "text", "files", "in", "directory", "and", "returns", "them", "as", "array" ]
jfilter/text-classification-keras
python
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/corpus.py#L8-L22
[ "def", "read_folder", "(", "directory", ")", ":", "res", "=", "[", "]", "for", "filename", "in", "os", ".", "listdir", "(", "directory", ")", ":", "with", "io", ".", "open", "(", "os", ".", "path", ".", "join", "(", "directory", ",", "filename", ")...
a59c652805da41d18937c7fdad0d9fd943cf8578
train
read_pos_neg_data
returns array with positive and negative examples
texcla/corpus.py
def read_pos_neg_data(path, folder, limit): """returns array with positive and negative examples""" training_pos_path = os.path.join(path, folder, 'pos') training_neg_path = os.path.join(path, folder, 'neg') X_pos = read_folder(training_pos_path) X_neg = read_folder(training_neg_path) if limit...
def read_pos_neg_data(path, folder, limit): """returns array with positive and negative examples""" training_pos_path = os.path.join(path, folder, 'pos') training_neg_path = os.path.join(path, folder, 'neg') X_pos = read_folder(training_pos_path) X_neg = read_folder(training_neg_path) if limit...
[ "returns", "array", "with", "positive", "and", "negative", "examples" ]
jfilter/text-classification-keras
python
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/corpus.py#L25-L40
[ "def", "read_pos_neg_data", "(", "path", ",", "folder", ",", "limit", ")", ":", "training_pos_path", "=", "os", ".", "path", ".", "join", "(", "path", ",", "folder", ",", "'pos'", ")", "training_neg_path", "=", "os", ".", "path", ".", "join", "(", "pat...
a59c652805da41d18937c7fdad0d9fd943cf8578
train
imdb
Downloads (and caches) IMDB Moview Reviews. 25k training data, 25k test data Args: limit: get only first N items for each class Returns: [X_train, y_train, X_test, y_test]
texcla/corpus.py
def imdb(limit=None, shuffle=True): """Downloads (and caches) IMDB Moview Reviews. 25k training data, 25k test data Args: limit: get only first N items for each class Returns: [X_train, y_train, X_test, y_test] """ movie_review_url = 'http://ai.stanford.edu/~amaas/data/sentiment/a...
def imdb(limit=None, shuffle=True): """Downloads (and caches) IMDB Moview Reviews. 25k training data, 25k test data Args: limit: get only first N items for each class Returns: [X_train, y_train, X_test, y_test] """ movie_review_url = 'http://ai.stanford.edu/~amaas/data/sentiment/a...
[ "Downloads", "(", "and", "caches", ")", "IMDB", "Moview", "Reviews", ".", "25k", "training", "data", "25k", "test", "data" ]
jfilter/text-classification-keras
python
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/corpus.py#L43-L66
[ "def", "imdb", "(", "limit", "=", "None", ",", "shuffle", "=", "True", ")", ":", "movie_review_url", "=", "'http://ai.stanford.edu/~amaas/data/sentiment/aclImdb_v1.tar.gz'", "# download and extract, thus remove the suffix '.tar.gz'", "path", "=", "keras", ".", "utils", ".",...
a59c652805da41d18937c7fdad0d9fd943cf8578
train
Dial.to_absolute
Converts coordinates provided with reference to the center \ of the canvas (0, 0) to absolute coordinates which are used \ by the canvas object in which (0, 0) is located in the top \ left of the object. :param x: x value in pixels :param y: x value in pixels :return: No...
tk_tools/canvas.py
def to_absolute(self, x, y): """ Converts coordinates provided with reference to the center \ of the canvas (0, 0) to absolute coordinates which are used \ by the canvas object in which (0, 0) is located in the top \ left of the object. :param x: x value in pixels ...
def to_absolute(self, x, y): """ Converts coordinates provided with reference to the center \ of the canvas (0, 0) to absolute coordinates which are used \ by the canvas object in which (0, 0) is located in the top \ left of the object. :param x: x value in pixels ...
[ "Converts", "coordinates", "provided", "with", "reference", "to", "the", "center", "\\", "of", "the", "canvas", "(", "0", "0", ")", "to", "absolute", "coordinates", "which", "are", "used", "\\", "by", "the", "canvas", "object", "in", "which", "(", "0", "...
slightlynybbled/tk_tools
python
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/canvas.py#L43-L54
[ "def", "to_absolute", "(", "self", ",", "x", ",", "y", ")", ":", "return", "x", "+", "self", ".", "size", "/", "2", ",", "y", "+", "self", ".", "size", "/", "2" ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
train
RotaryScale.set_value
Sets the value of the graphic :param number: the number (must be between 0 and \ 'max_range' or the scale will peg the limits :return: None
tk_tools/canvas.py
def set_value(self, number: (float, int)): """ Sets the value of the graphic :param number: the number (must be between 0 and \ 'max_range' or the scale will peg the limits :return: None """ self.canvas.delete('all') self.canvas.create_image(0, 0, image=s...
def set_value(self, number: (float, int)): """ Sets the value of the graphic :param number: the number (must be between 0 and \ 'max_range' or the scale will peg the limits :return: None """ self.canvas.delete('all') self.canvas.create_image(0, 0, image=s...
[ "Sets", "the", "value", "of", "the", "graphic" ]
slightlynybbled/tk_tools
python
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/canvas.py#L112-L145
[ "def", "set_value", "(", "self", ",", "number", ":", "(", "float", ",", "int", ")", ")", ":", "self", ".", "canvas", ".", "delete", "(", "'all'", ")", "self", ".", "canvas", ".", "create_image", "(", "0", ",", "0", ",", "image", "=", "self", ".",...
7c1792cad42890251a34f0617ce9b4b3e7abcf50
train
RotaryScale._draw_background
Draws the background of the dial :param divisions: the number of divisions between 'ticks' shown on the dial :return: None
tk_tools/canvas.py
def _draw_background(self, divisions=10): """ Draws the background of the dial :param divisions: the number of divisions between 'ticks' shown on the dial :return: None """ self.canvas.create_arc(2, 2, self.size-2, self.size-2, styl...
def _draw_background(self, divisions=10): """ Draws the background of the dial :param divisions: the number of divisions between 'ticks' shown on the dial :return: None """ self.canvas.create_arc(2, 2, self.size-2, self.size-2, styl...
[ "Draws", "the", "background", "of", "the", "dial" ]
slightlynybbled/tk_tools
python
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/canvas.py#L147-L179
[ "def", "_draw_background", "(", "self", ",", "divisions", "=", "10", ")", ":", "self", ".", "canvas", ".", "create_arc", "(", "2", ",", "2", ",", "self", ".", "size", "-", "2", ",", "self", ".", "size", "-", "2", ",", "style", "=", "tk", ".", "...
7c1792cad42890251a34f0617ce9b4b3e7abcf50
train
Graph.draw_axes
Removes all existing series and re-draws the axes. :return: None
tk_tools/canvas.py
def draw_axes(self): """ Removes all existing series and re-draws the axes. :return: None """ self.canvas.delete('all') rect = 50, 50, self.w - 50, self.h - 50 self.canvas.create_rectangle(rect, outline="black") for x in self.frange(0, self.x_max - self...
def draw_axes(self): """ Removes all existing series and re-draws the axes. :return: None """ self.canvas.delete('all') rect = 50, 50, self.w - 50, self.h - 50 self.canvas.create_rectangle(rect, outline="black") for x in self.frange(0, self.x_max - self...
[ "Removes", "all", "existing", "series", "and", "re", "-", "draws", "the", "axes", "." ]
slightlynybbled/tk_tools
python
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/canvas.py#L391-L423
[ "def", "draw_axes", "(", "self", ")", ":", "self", ".", "canvas", ".", "delete", "(", "'all'", ")", "rect", "=", "50", ",", "50", ",", "self", ".", "w", "-", "50", ",", "self", ".", "h", "-", "50", "self", ".", "canvas", ".", "create_rectangle", ...
7c1792cad42890251a34f0617ce9b4b3e7abcf50
train
Graph.plot_point
Places a single point on the grid :param x: the x coordinate :param y: the y coordinate :param visible: True if the individual point should be visible :param color: the color of the point :param size: the point size in pixels :return: The absolute coordinates as a tuple
tk_tools/canvas.py
def plot_point(self, x, y, visible=True, color='black', size=5): """ Places a single point on the grid :param x: the x coordinate :param y: the y coordinate :param visible: True if the individual point should be visible :param color: the color of the point :param...
def plot_point(self, x, y, visible=True, color='black', size=5): """ Places a single point on the grid :param x: the x coordinate :param y: the y coordinate :param visible: True if the individual point should be visible :param color: the color of the point :param...
[ "Places", "a", "single", "point", "on", "the", "grid" ]
slightlynybbled/tk_tools
python
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/canvas.py#L425-L451
[ "def", "plot_point", "(", "self", ",", "x", ",", "y", ",", "visible", "=", "True", ",", "color", "=", "'black'", ",", "size", "=", "5", ")", ":", "xp", "=", "(", "self", ".", "px_x", "*", "(", "x", "-", "self", ".", "x_min", ")", ")", "/", ...
7c1792cad42890251a34f0617ce9b4b3e7abcf50
train
Graph.plot_line
Plot a line of points :param points: a list of tuples, each tuple containing an (x, y) point :param color: the color of the line :param point_visibility: True if the points \ should be individually visible :return: None
tk_tools/canvas.py
def plot_line(self, points: list, color='black', point_visibility=False): """ Plot a line of points :param points: a list of tuples, each tuple containing an (x, y) point :param color: the color of the line :param point_visibility: True if the points \ should be individu...
def plot_line(self, points: list, color='black', point_visibility=False): """ Plot a line of points :param points: a list of tuples, each tuple containing an (x, y) point :param color: the color of the line :param point_visibility: True if the points \ should be individu...
[ "Plot", "a", "line", "of", "points" ]
slightlynybbled/tk_tools
python
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/canvas.py#L453-L470
[ "def", "plot_line", "(", "self", ",", "points", ":", "list", ",", "color", "=", "'black'", ",", "point_visibility", "=", "False", ")", ":", "last_point", "=", "(", ")", "for", "point", "in", "points", ":", "this_point", "=", "self", ".", "plot_point", ...
7c1792cad42890251a34f0617ce9b4b3e7abcf50
train
Graph.frange
Works like range for doubles :param start: starting value :param stop: ending value :param step: the increment_value :param digits_to_round: the digits to which to round \ (makes floating-point numbers much easier to work with) :return: generator
tk_tools/canvas.py
def frange(start, stop, step, digits_to_round=3): """ Works like range for doubles :param start: starting value :param stop: ending value :param step: the increment_value :param digits_to_round: the digits to which to round \ (makes floating-point numbers much ea...
def frange(start, stop, step, digits_to_round=3): """ Works like range for doubles :param start: starting value :param stop: ending value :param step: the increment_value :param digits_to_round: the digits to which to round \ (makes floating-point numbers much ea...
[ "Works", "like", "range", "for", "doubles" ]
slightlynybbled/tk_tools
python
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/canvas.py#L474-L487
[ "def", "frange", "(", "start", ",", "stop", ",", "step", ",", "digits_to_round", "=", "3", ")", ":", "while", "start", "<", "stop", ":", "yield", "round", "(", "start", ",", "digits_to_round", ")", "start", "+=", "step" ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
train
Led._load_new
Load a new image. :param img_data: the image data as a base64 string :return: None
tk_tools/canvas.py
def _load_new(self, img_data: str): """ Load a new image. :param img_data: the image data as a base64 string :return: None """ self._image = tk.PhotoImage(data=img_data) self._image = self._image.subsample(int(200 / self._size), ...
def _load_new(self, img_data: str): """ Load a new image. :param img_data: the image data as a base64 string :return: None """ self._image = tk.PhotoImage(data=img_data) self._image = self._image.subsample(int(200 / self._size), ...
[ "Load", "a", "new", "image", "." ]
slightlynybbled/tk_tools
python
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/canvas.py#L534-L548
[ "def", "_load_new", "(", "self", ",", "img_data", ":", "str", ")", ":", "self", ".", "_image", "=", "tk", ".", "PhotoImage", "(", "data", "=", "img_data", ")", "self", ".", "_image", "=", "self", ".", "_image", ".", "subsample", "(", "int", "(", "2...
7c1792cad42890251a34f0617ce9b4b3e7abcf50
train
Led.to_grey
Change the LED to grey. :param on: Unused, here for API consistency with the other states :return: None
tk_tools/canvas.py
def to_grey(self, on: bool=False): """ Change the LED to grey. :param on: Unused, here for API consistency with the other states :return: None """ self._on = False self._load_new(led_grey)
def to_grey(self, on: bool=False): """ Change the LED to grey. :param on: Unused, here for API consistency with the other states :return: None """ self._on = False self._load_new(led_grey)
[ "Change", "the", "LED", "to", "grey", "." ]
slightlynybbled/tk_tools
python
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/canvas.py#L550-L558
[ "def", "to_grey", "(", "self", ",", "on", ":", "bool", "=", "False", ")", ":", "self", ".", "_on", "=", "False", "self", ".", "_load_new", "(", "led_grey", ")" ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
train
Led.to_green
Change the LED to green (on or off). :param on: True or False :return: None
tk_tools/canvas.py
def to_green(self, on: bool=False): """ Change the LED to green (on or off). :param on: True or False :return: None """ self._on = on if on: self._load_new(led_green_on) if self._toggle_on_click: self._canvas.bind('<Button...
def to_green(self, on: bool=False): """ Change the LED to green (on or off). :param on: True or False :return: None """ self._on = on if on: self._load_new(led_green_on) if self._toggle_on_click: self._canvas.bind('<Button...
[ "Change", "the", "LED", "to", "green", "(", "on", "or", "off", ")", "." ]
slightlynybbled/tk_tools
python
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/canvas.py#L560-L577
[ "def", "to_green", "(", "self", ",", "on", ":", "bool", "=", "False", ")", ":", "self", ".", "_on", "=", "on", "if", "on", ":", "self", ".", "_load_new", "(", "led_green_on", ")", "if", "self", ".", "_toggle_on_click", ":", "self", ".", "_canvas", ...
7c1792cad42890251a34f0617ce9b4b3e7abcf50
train
Led.to_red
Change the LED to red (on or off) :param on: True or False :return: None
tk_tools/canvas.py
def to_red(self, on: bool=False): """ Change the LED to red (on or off) :param on: True or False :return: None """ self._on = on if on: self._load_new(led_red_on) if self._toggle_on_click: self._canvas.bind('<Button-1>', la...
def to_red(self, on: bool=False): """ Change the LED to red (on or off) :param on: True or False :return: None """ self._on = on if on: self._load_new(led_red_on) if self._toggle_on_click: self._canvas.bind('<Button-1>', la...
[ "Change", "the", "LED", "to", "red", "(", "on", "or", "off", ")", ":", "param", "on", ":", "True", "or", "False", ":", "return", ":", "None" ]
slightlynybbled/tk_tools
python
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/canvas.py#L579-L595
[ "def", "to_red", "(", "self", ",", "on", ":", "bool", "=", "False", ")", ":", "self", ".", "_on", "=", "on", "if", "on", ":", "self", ".", "_load_new", "(", "led_red_on", ")", "if", "self", ".", "_toggle_on_click", ":", "self", ".", "_canvas", ".",...
7c1792cad42890251a34f0617ce9b4b3e7abcf50
train
Led.to_yellow
Change the LED to yellow (on or off) :param on: True or False :return: None
tk_tools/canvas.py
def to_yellow(self, on: bool=False): """ Change the LED to yellow (on or off) :param on: True or False :return: None """ self._on = on if on: self._load_new(led_yellow_on) if self._toggle_on_click: self._canvas.bind('<Butto...
def to_yellow(self, on: bool=False): """ Change the LED to yellow (on or off) :param on: True or False :return: None """ self._on = on if on: self._load_new(led_yellow_on) if self._toggle_on_click: self._canvas.bind('<Butto...
[ "Change", "the", "LED", "to", "yellow", "(", "on", "or", "off", ")", ":", "param", "on", ":", "True", "or", "False", ":", "return", ":", "None" ]
slightlynybbled/tk_tools
python
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/canvas.py#L597-L615
[ "def", "to_yellow", "(", "self", ",", "on", ":", "bool", "=", "False", ")", ":", "self", ".", "_on", "=", "on", "if", "on", ":", "self", ".", "_load_new", "(", "led_yellow_on", ")", "if", "self", ".", "_toggle_on_click", ":", "self", ".", "_canvas", ...
7c1792cad42890251a34f0617ce9b4b3e7abcf50
train
_Grid._redraw
Forgets the current layout and redraws with the most recent information :return: None
tk_tools/groups.py
def _redraw(self): """ Forgets the current layout and redraws with the most recent information :return: None """ for row in self._rows: for widget in row: widget.grid_forget() offset = 0 if not self.headers else 1 for i, row in enumer...
def _redraw(self): """ Forgets the current layout and redraws with the most recent information :return: None """ for row in self._rows: for widget in row: widget.grid_forget() offset = 0 if not self.headers else 1 for i, row in enumer...
[ "Forgets", "the", "current", "layout", "and", "redraws", "with", "the", "most", "recent", "information" ]
slightlynybbled/tk_tools
python
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/groups.py#L56-L69
[ "def", "_redraw", "(", "self", ")", ":", "for", "row", "in", "self", ".", "_rows", ":", "for", "widget", "in", "row", ":", "widget", ".", "grid_forget", "(", ")", "offset", "=", "0", "if", "not", "self", ".", "headers", "else", "1", "for", "i", "...
7c1792cad42890251a34f0617ce9b4b3e7abcf50
train
_Grid.remove_row
Removes a specified row of data :param row_number: the row to remove (defaults to the last row) :return: None
tk_tools/groups.py
def remove_row(self, row_number: int=-1): """ Removes a specified row of data :param row_number: the row to remove (defaults to the last row) :return: None """ if len(self._rows) == 0: return row = self._rows.pop(row_number) for widget in row...
def remove_row(self, row_number: int=-1): """ Removes a specified row of data :param row_number: the row to remove (defaults to the last row) :return: None """ if len(self._rows) == 0: return row = self._rows.pop(row_number) for widget in row...
[ "Removes", "a", "specified", "row", "of", "data" ]
slightlynybbled/tk_tools
python
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/groups.py#L71-L83
[ "def", "remove_row", "(", "self", ",", "row_number", ":", "int", "=", "-", "1", ")", ":", "if", "len", "(", "self", ".", "_rows", ")", "==", "0", ":", "return", "row", "=", "self", ".", "_rows", ".", "pop", "(", "row_number", ")", "for", "widget"...
7c1792cad42890251a34f0617ce9b4b3e7abcf50
train
LabelGrid.add_row
Add a row of data to the current widget :param data: a row of data :return: None
tk_tools/groups.py
def add_row(self, data: list): """ Add a row of data to the current widget :param data: a row of data :return: None """ # validation if self.headers: if len(self.headers) != len(data): raise ValueError if len(data) != self.num...
def add_row(self, data: list): """ Add a row of data to the current widget :param data: a row of data :return: None """ # validation if self.headers: if len(self.headers) != len(data): raise ValueError if len(data) != self.num...
[ "Add", "a", "row", "of", "data", "to", "the", "current", "widget" ]
slightlynybbled/tk_tools
python
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/groups.py#L109-L132
[ "def", "add_row", "(", "self", ",", "data", ":", "list", ")", ":", "# validation", "if", "self", ".", "headers", ":", "if", "len", "(", "self", ".", "headers", ")", "!=", "len", "(", "data", ")", ":", "raise", "ValueError", "if", "len", "(", "data"...
7c1792cad42890251a34f0617ce9b4b3e7abcf50