repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
datacats/datacats
datacats/environment.py
Environment.interactive_shell
def interactive_shell(self, command=None, paster=False, detach=False): """ launch interactive shell session with all writable volumes :param: list of strings to execute instead of bash """ if not exists(self.target + '/.bash_profile'): # this file is required for act...
python
def interactive_shell(self, command=None, paster=False, detach=False): """ launch interactive shell session with all writable volumes :param: list of strings to execute instead of bash """ if not exists(self.target + '/.bash_profile'): # this file is required for act...
[ "def", "interactive_shell", "(", "self", ",", "command", "=", "None", ",", "paster", "=", "False", ",", "detach", "=", "False", ")", ":", "if", "not", "exists", "(", "self", ".", "target", "+", "'/.bash_profile'", ")", ":", "# this file is required for activ...
launch interactive shell session with all writable volumes :param: list of strings to execute instead of bash
[ "launch", "interactive", "shell", "session", "with", "all", "writable", "volumes" ]
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L698-L768
datacats/datacats
datacats/environment.py
Environment.install_package_requirements
def install_package_requirements(self, psrc, stream_output=None): """ Install from requirements.txt file found in psrc :param psrc: name of directory in environment directory """ package = self.target + '/' + psrc assert isdir(package), package reqname = '/requir...
python
def install_package_requirements(self, psrc, stream_output=None): """ Install from requirements.txt file found in psrc :param psrc: name of directory in environment directory """ package = self.target + '/' + psrc assert isdir(package), package reqname = '/requir...
[ "def", "install_package_requirements", "(", "self", ",", "psrc", ",", "stream_output", "=", "None", ")", ":", "package", "=", "self", ".", "target", "+", "'/'", "+", "psrc", "assert", "isdir", "(", "package", ")", ",", "package", "reqname", "=", "'/require...
Install from requirements.txt file found in psrc :param psrc: name of directory in environment directory
[ "Install", "from", "requirements", ".", "txt", "file", "found", "in", "psrc" ]
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L770-L789
datacats/datacats
datacats/environment.py
Environment.purge_data
def purge_data(self, which_sites=None, never_delete=False): """ Remove uploaded files, postgres db, solr index, venv """ # Default to the set of all sites if not exists(self.datadir + '/.version'): format_version = 1 else: with open(self.datadir + ...
python
def purge_data(self, which_sites=None, never_delete=False): """ Remove uploaded files, postgres db, solr index, venv """ # Default to the set of all sites if not exists(self.datadir + '/.version'): format_version = 1 else: with open(self.datadir + ...
[ "def", "purge_data", "(", "self", ",", "which_sites", "=", "None", ",", "never_delete", "=", "False", ")", ":", "# Default to the set of all sites", "if", "not", "exists", "(", "self", ".", "datadir", "+", "'/.version'", ")", ":", "format_version", "=", "1", ...
Remove uploaded files, postgres db, solr index, venv
[ "Remove", "uploaded", "files", "postgres", "db", "solr", "index", "venv" ]
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L856-L925
datacats/datacats
datacats/environment.py
Environment.logs
def logs(self, container, tail='all', follow=False, timestamps=False): """ :param container: 'web', 'solr' or 'postgres' :param tail: number of lines to show :param follow: True to return generator instead of list :param timestamps: True to include timestamps """ ...
python
def logs(self, container, tail='all', follow=False, timestamps=False): """ :param container: 'web', 'solr' or 'postgres' :param tail: number of lines to show :param follow: True to return generator instead of list :param timestamps: True to include timestamps """ ...
[ "def", "logs", "(", "self", ",", "container", ",", "tail", "=", "'all'", ",", "follow", "=", "False", ",", "timestamps", "=", "False", ")", ":", "return", "container_logs", "(", "self", ".", "_get_container_name", "(", "container", ")", ",", "tail", ",",...
:param container: 'web', 'solr' or 'postgres' :param tail: number of lines to show :param follow: True to return generator instead of list :param timestamps: True to include timestamps
[ ":", "param", "container", ":", "web", "solr", "or", "postgres", ":", "param", "tail", ":", "number", "of", "lines", "to", "show", ":", "param", "follow", ":", "True", "to", "return", "generator", "instead", "of", "list", ":", "param", "timestamps", ":",...
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L927-L938
datacats/datacats
datacats/environment.py
Environment._proxy_settings
def _proxy_settings(self): """ Create/replace ~/.datacats/run/proxy-environment and return entry for ro mount for containers """ if not ('https_proxy' in environ or 'HTTPS_PROXY' in environ or 'http_proxy' in environ or 'HTTP_PROXY' in environ): return...
python
def _proxy_settings(self): """ Create/replace ~/.datacats/run/proxy-environment and return entry for ro mount for containers """ if not ('https_proxy' in environ or 'HTTPS_PROXY' in environ or 'http_proxy' in environ or 'HTTP_PROXY' in environ): return...
[ "def", "_proxy_settings", "(", "self", ")", ":", "if", "not", "(", "'https_proxy'", "in", "environ", "or", "'HTTPS_PROXY'", "in", "environ", "or", "'http_proxy'", "in", "environ", "or", "'HTTP_PROXY'", "in", "environ", ")", ":", "return", "{", "}", "https_pr...
Create/replace ~/.datacats/run/proxy-environment and return entry for ro mount for containers
[ "Create", "/", "replace", "~", "/", ".", "datacats", "/", "run", "/", "proxy", "-", "environment", "and", "return", "entry", "for", "ro", "mount", "for", "containers" ]
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L949-L984
datacats/datacats
datacats/environment.py
Environment._get_container_name
def _get_container_name(self, container_type): """ Gets the full name of a container of the type specified. Currently the supported types are: - 'venv' - 'postgres' - 'solr' - 'web' - 'pgdata' - 'lessc' - 'datapu...
python
def _get_container_name(self, container_type): """ Gets the full name of a container of the type specified. Currently the supported types are: - 'venv' - 'postgres' - 'solr' - 'web' - 'pgdata' - 'lessc' - 'datapu...
[ "def", "_get_container_name", "(", "self", ",", "container_type", ")", ":", "if", "container_type", "in", "[", "'venv'", "]", ":", "return", "'datacats_{}_{}'", ".", "format", "(", "container_type", ",", "self", ".", "name", ")", "else", ":", "return", "'dat...
Gets the full name of a container of the type specified. Currently the supported types are: - 'venv' - 'postgres' - 'solr' - 'web' - 'pgdata' - 'lessc' - 'datapusher' - 'redis' The name will be formatted appr...
[ "Gets", "the", "full", "name", "of", "a", "container", "of", "the", "type", "specified", ".", "Currently", "the", "supported", "types", "are", ":", "-", "venv", "-", "postgres", "-", "solr", "-", "web", "-", "pgdata", "-", "lessc", "-", "datapusher", "...
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L986-L1006
datacats/datacats
datacats/cli/less.py
less
def less(environment, opts): # pylint: disable=unused-argument """Recompiles less files in an environment. Usage: datacats less [ENVIRONMENT] ENVIRONMENT may be an environment name or a path to an environment directory. Default: '.' """ require_extra_image(LESSC_IMAGE) print 'Converting .less files...
python
def less(environment, opts): # pylint: disable=unused-argument """Recompiles less files in an environment. Usage: datacats less [ENVIRONMENT] ENVIRONMENT may be an environment name or a path to an environment directory. Default: '.' """ require_extra_image(LESSC_IMAGE) print 'Converting .less files...
[ "def", "less", "(", "environment", ",", "opts", ")", ":", "# pylint: disable=unused-argument", "require_extra_image", "(", "LESSC_IMAGE", ")", "print", "'Converting .less files to .css...'", "for", "log", "in", "environment", ".", "compile_less", "(", ")", ":", "print...
Recompiles less files in an environment. Usage: datacats less [ENVIRONMENT] ENVIRONMENT may be an environment name or a path to an environment directory. Default: '.'
[ "Recompiles", "less", "files", "in", "an", "environment", "." ]
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/cli/less.py#L13-L27
Britefury/batchup
batchup/datasets/dataset.py
fetch_and_convert_dataset
def fetch_and_convert_dataset(source_files, target_filename): """ Decorator applied to a dataset conversion function that converts acquired source files into a dataset file that BatchUp can use. Parameters ---------- source_file: list of `AbstractSourceFile` instances A list of files to...
python
def fetch_and_convert_dataset(source_files, target_filename): """ Decorator applied to a dataset conversion function that converts acquired source files into a dataset file that BatchUp can use. Parameters ---------- source_file: list of `AbstractSourceFile` instances A list of files to...
[ "def", "fetch_and_convert_dataset", "(", "source_files", ",", "target_filename", ")", ":", "if", "not", "isinstance", "(", "target_filename", ",", "six", ".", "string_types", ")", "and", "not", "callable", "(", "target_filename", ")", ":", "raise", "TypeError", ...
Decorator applied to a dataset conversion function that converts acquired source files into a dataset file that BatchUp can use. Parameters ---------- source_file: list of `AbstractSourceFile` instances A list of files to be acquired target_filename: str or callable The name of the ...
[ "Decorator", "applied", "to", "a", "dataset", "conversion", "function", "that", "converts", "acquired", "source", "files", "into", "a", "dataset", "file", "that", "BatchUp", "can", "use", "." ]
train
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/datasets/dataset.py#L252-L399
Britefury/batchup
batchup/datasets/dataset.py
delete_dataset_cache
def delete_dataset_cache(*filenames): """ Delete the cache (converted files) for a dataset. Parameters ---------- filenames: str Filenames of files to delete """ for filename in filenames: filename = path_string(filename) path = config.get_data_path(filename) ...
python
def delete_dataset_cache(*filenames): """ Delete the cache (converted files) for a dataset. Parameters ---------- filenames: str Filenames of files to delete """ for filename in filenames: filename = path_string(filename) path = config.get_data_path(filename) ...
[ "def", "delete_dataset_cache", "(", "*", "filenames", ")", ":", "for", "filename", "in", "filenames", ":", "filename", "=", "path_string", "(", "filename", ")", "path", "=", "config", ".", "get_data_path", "(", "filename", ")", "if", "os", ".", "path", "."...
Delete the cache (converted files) for a dataset. Parameters ---------- filenames: str Filenames of files to delete
[ "Delete", "the", "cache", "(", "converted", "files", ")", "for", "a", "dataset", "." ]
train
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/datasets/dataset.py#L402-L415
Britefury/batchup
batchup/datasets/dataset.py
DownloadSourceFile.acquire
def acquire(self, **kwargs): """ Download the file and return its path Returns ------- str or None The path of the file in BatchUp's temporary directory or None if the download failed. """ return config.download_data(self.temp_filename, se...
python
def acquire(self, **kwargs): """ Download the file and return its path Returns ------- str or None The path of the file in BatchUp's temporary directory or None if the download failed. """ return config.download_data(self.temp_filename, se...
[ "def", "acquire", "(", "self", ",", "*", "*", "kwargs", ")", ":", "return", "config", ".", "download_data", "(", "self", ".", "temp_filename", ",", "self", ".", "url", ",", "self", ".", "sha256", ")" ]
Download the file and return its path Returns ------- str or None The path of the file in BatchUp's temporary directory or None if the download failed.
[ "Download", "the", "file", "and", "return", "its", "path" ]
train
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/datasets/dataset.py#L124-L135
Britefury/batchup
batchup/datasets/dataset.py
CopySourceFile.acquire
def acquire(self, **kwargs): """ Copy the file and return its path Returns ------- str or None The path of the file in BatchUp's temporary directory or None if the copy failed. """ if self.source_path is None: source_path = kwa...
python
def acquire(self, **kwargs): """ Copy the file and return its path Returns ------- str or None The path of the file in BatchUp's temporary directory or None if the copy failed. """ if self.source_path is None: source_path = kwa...
[ "def", "acquire", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "source_path", "is", "None", ":", "source_path", "=", "kwargs", "[", "self", ".", "arg_name", "]", "else", ":", "source_path", "=", "self", ".", "source_path", "return...
Copy the file and return its path Returns ------- str or None The path of the file in BatchUp's temporary directory or None if the copy failed.
[ "Copy", "the", "file", "and", "return", "its", "path" ]
train
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/datasets/dataset.py#L185-L199
Britefury/batchup
batchup/datasets/dataset.py
ExistingSourceFile.acquire
def acquire(self, **kwargs): """ Copy the file and return its path Returns ------- str or None The path of the file or None if it does not exist or if verification failed. """ path = path_string(self.path) if os.path.exists(path): ...
python
def acquire(self, **kwargs): """ Copy the file and return its path Returns ------- str or None The path of the file or None if it does not exist or if verification failed. """ path = path_string(self.path) if os.path.exists(path): ...
[ "def", "acquire", "(", "self", ",", "*", "*", "kwargs", ")", ":", "path", "=", "path_string", "(", "self", ".", "path", ")", "if", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "if", "config", ".", "verify_file", "(", "path", ",", "sel...
Copy the file and return its path Returns ------- str or None The path of the file or None if it does not exist or if verification failed.
[ "Copy", "the", "file", "and", "return", "its", "path" ]
train
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/datasets/dataset.py#L235-L249
datacats/datacats
datacats/cli/pull.py
_retry_func
def _retry_func(func, param, num, retry_notif, error_msg): """ A function which retries a given function num times and calls retry_notif each time the function is retried. :param func: The function to retry num times. :param num: The number of times to try before giving up. :param retry_notif: W...
python
def _retry_func(func, param, num, retry_notif, error_msg): """ A function which retries a given function num times and calls retry_notif each time the function is retried. :param func: The function to retry num times. :param num: The number of times to try before giving up. :param retry_notif: W...
[ "def", "_retry_func", "(", "func", ",", "param", ",", "num", ",", "retry_notif", ",", "error_msg", ")", ":", "for", "retry_num", "in", "range", "(", "num", ")", ":", "if", "retry_num", ":", "retry_notif", "(", "param", ",", "retry_num", ")", "try", ":"...
A function which retries a given function num times and calls retry_notif each time the function is retried. :param func: The function to retry num times. :param num: The number of times to try before giving up. :param retry_notif: Will be called with the same parameter as func if we have to retry the ...
[ "A", "function", "which", "retries", "a", "given", "function", "num", "times", "and", "calls", "retry_notif", "each", "time", "the", "function", "is", "retried", ".", ":", "param", "func", ":", "The", "function", "to", "retry", "num", "times", ".", ":", ...
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/cli/pull.py#L55-L77
Britefury/batchup
batchup/work_pool.py
WorkStream.retrieve
def retrieve(self): """ Retrieve a result from executing a task. Note that tasks are executed in order and that if the next task has not yet completed, this call will block until the result is available. Returns ------- A result from the result buffer. ""...
python
def retrieve(self): """ Retrieve a result from executing a task. Note that tasks are executed in order and that if the next task has not yet completed, this call will block until the result is available. Returns ------- A result from the result buffer. ""...
[ "def", "retrieve", "(", "self", ")", ":", "if", "len", "(", "self", ".", "__result_buffer", ")", ">", "0", ":", "res", "=", "self", ".", "__result_buffer", ".", "popleft", "(", ")", "value", "=", "res", ".", "get", "(", ")", "else", ":", "return", ...
Retrieve a result from executing a task. Note that tasks are executed in order and that if the next task has not yet completed, this call will block until the result is available. Returns ------- A result from the result buffer.
[ "Retrieve", "a", "result", "from", "executing", "a", "task", ".", "Note", "that", "tasks", "are", "executed", "in", "order", "and", "that", "if", "the", "next", "task", "has", "not", "yet", "completed", "this", "call", "will", "block", "until", "the", "r...
train
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/work_pool.py#L407-L425
datacats/datacats
datacats/cli/install.py
install
def install(environment, opts): """Install or reinstall Python packages within this environment Usage: datacats install [-q] [--address=IP] [ENVIRONMENT [PACKAGE ...]] datacats install -c [q] [--address=IP] [ENVIRONMENT] Options: --address=IP The address to bind to when reloading after install -c...
python
def install(environment, opts): """Install or reinstall Python packages within this environment Usage: datacats install [-q] [--address=IP] [ENVIRONMENT [PACKAGE ...]] datacats install -c [q] [--address=IP] [ENVIRONMENT] Options: --address=IP The address to bind to when reloading after install -c...
[ "def", "install", "(", "environment", ",", "opts", ")", ":", "environment", ".", "require_data", "(", ")", "install_all", "(", "environment", ",", "opts", "[", "'--clean'", "]", ",", "verbose", "=", "not", "opts", "[", "'--quiet'", "]", ",", "packages", ...
Install or reinstall Python packages within this environment Usage: datacats install [-q] [--address=IP] [ENVIRONMENT [PACKAGE ...]] datacats install -c [q] [--address=IP] [ENVIRONMENT] Options: --address=IP The address to bind to when reloading after install -c --clean Reinstall packages ...
[ "Install", "or", "reinstall", "Python", "packages", "within", "this", "environment" ]
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/cli/install.py#L20-L52
datacats/datacats
datacats/cli/migrate.py
migrate
def migrate(opts): """Migrate an environment to a given revision of the datadir format. Usage: datacats migrate [-y] [-r VERSION] [ENVIRONMENT_DIR] Options: -r --revision=VERSION The version of the datadir format you want to convert to [default: 2] -y --yes Answer yes...
python
def migrate(opts): """Migrate an environment to a given revision of the datadir format. Usage: datacats migrate [-y] [-r VERSION] [ENVIRONMENT_DIR] Options: -r --revision=VERSION The version of the datadir format you want to convert to [default: 2] -y --yes Answer yes...
[ "def", "migrate", "(", "opts", ")", ":", "try", ":", "version", "=", "int", "(", "opts", "[", "'--revision'", "]", ")", "except", ":", "raise", "DatacatsError", "(", "'--revision parameter must be an integer.'", ")", "always_yes", "=", "opts", "[", "'--yes'", ...
Migrate an environment to a given revision of the datadir format. Usage: datacats migrate [-y] [-r VERSION] [ENVIRONMENT_DIR] Options: -r --revision=VERSION The version of the datadir format you want to convert to [default: 2] -y --yes Answer yes to all questions. Defaul...
[ "Migrate", "an", "environment", "to", "a", "given", "revision", "of", "the", "datadir", "format", "." ]
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/cli/migrate.py#L8-L38
datacats/datacats
datacats/cli/deploy.py
deploy
def deploy(environment, opts, profile): """Deploy environment to production DataCats.com cloud service Usage: datacats deploy [--create] [ENVIRONMENT [TARGET_NAME]] Options: --create Create a new environment on DataCats.com instead of updating an existing environment ...
python
def deploy(environment, opts, profile): """Deploy environment to production DataCats.com cloud service Usage: datacats deploy [--create] [ENVIRONMENT [TARGET_NAME]] Options: --create Create a new environment on DataCats.com instead of updating an existing environment ...
[ "def", "deploy", "(", "environment", ",", "opts", ",", "profile", ")", ":", "target_name", "=", "opts", "[", "'TARGET_NAME'", "]", "if", "target_name", "is", "None", ":", "target_name", "=", "environment", ".", "name", "if", "not", "valid_deploy_name", "(", ...
Deploy environment to production DataCats.com cloud service Usage: datacats deploy [--create] [ENVIRONMENT [TARGET_NAME]] Options: --create Create a new environment on DataCats.com instead of updating an existing environment ENVIRONMENT may be an environment name or a pat...
[ "Deploy", "environment", "to", "production", "DataCats", ".", "com", "cloud", "service" ]
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/cli/deploy.py#L14-L53
Britefury/batchup
batchup/data_source.py
_trim_batch
def _trim_batch(batch, length): """Trim the mini-batch `batch` to the size `length`. `batch` can be: - a NumPy array, in which case it's first axis will be trimmed to size `length` - a tuple, in which case `_trim_batch` applied recursively to each element and the resulting tuple returned ...
python
def _trim_batch(batch, length): """Trim the mini-batch `batch` to the size `length`. `batch` can be: - a NumPy array, in which case it's first axis will be trimmed to size `length` - a tuple, in which case `_trim_batch` applied recursively to each element and the resulting tuple returned ...
[ "def", "_trim_batch", "(", "batch", ",", "length", ")", ":", "if", "isinstance", "(", "batch", ",", "tuple", ")", ":", "return", "tuple", "(", "[", "_trim_batch", "(", "b", ",", "length", ")", "for", "b", "in", "batch", "]", ")", "else", ":", "retu...
Trim the mini-batch `batch` to the size `length`. `batch` can be: - a NumPy array, in which case it's first axis will be trimmed to size `length` - a tuple, in which case `_trim_batch` applied recursively to each element and the resulting tuple returned As a consequence, mini-batches can b...
[ "Trim", "the", "mini", "-", "batch", "batch", "to", "the", "size", "length", "." ]
train
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/data_source.py#L41-L68
Britefury/batchup
batchup/data_source.py
batch_map_concat
def batch_map_concat(func, batch_iter, progress_iter_func=None, n_batches=None, prepend_args=None): """ Apply a function to all the samples that are accessed as mini-batches obtained from an iterator. Returns the per-sample results. The function `func` should return the result ...
python
def batch_map_concat(func, batch_iter, progress_iter_func=None, n_batches=None, prepend_args=None): """ Apply a function to all the samples that are accessed as mini-batches obtained from an iterator. Returns the per-sample results. The function `func` should return the result ...
[ "def", "batch_map_concat", "(", "func", ",", "batch_iter", ",", "progress_iter_func", "=", "None", ",", "n_batches", "=", "None", ",", "prepend_args", "=", "None", ")", ":", "# Accumulator for results and number of samples", "results", "=", "[", "]", "# If `progress...
Apply a function to all the samples that are accessed as mini-batches obtained from an iterator. Returns the per-sample results. The function `func` should return the result for each sample in the mini-batch as an array. To return multiple results (e.g. loss and errors) return a tuple of arrays (e....
[ "Apply", "a", "function", "to", "all", "the", "samples", "that", "are", "accessed", "as", "mini", "-", "batches", "obtained", "from", "an", "iterator", ".", "Returns", "the", "per", "-", "sample", "results", "." ]
train
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/data_source.py#L1478-L1599
Britefury/batchup
batchup/data_source.py
batch_map_mean
def batch_map_mean(func, batch_iter, progress_iter_func=None, sum_axis=None, n_batches=None, prepend_args=None): """ Apply a function to all the samples that are accessed as mini-batches obtained from an iterator. Returns the across-samples mean of the results returned by `func` ...
python
def batch_map_mean(func, batch_iter, progress_iter_func=None, sum_axis=None, n_batches=None, prepend_args=None): """ Apply a function to all the samples that are accessed as mini-batches obtained from an iterator. Returns the across-samples mean of the results returned by `func` ...
[ "def", "batch_map_mean", "(", "func", ",", "batch_iter", ",", "progress_iter_func", "=", "None", ",", "sum_axis", "=", "None", ",", "n_batches", "=", "None", ",", "prepend_args", "=", "None", ")", ":", "# Accumulator for results and number of samples", "results_accu...
Apply a function to all the samples that are accessed as mini-batches obtained from an iterator. Returns the across-samples mean of the results returned by `func` The `sum_axis` arguments tells `mean_batch_map` how to process the results of `func` before accumulating them: - If `sum_axis` is `None`...
[ "Apply", "a", "function", "to", "all", "the", "samples", "that", "are", "accessed", "as", "mini", "-", "batches", "obtained", "from", "an", "iterator", ".", "Returns", "the", "across", "-", "samples", "mean", "of", "the", "results", "returned", "by", "func...
train
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/data_source.py#L1602-L1779
Britefury/batchup
batchup/data_source.py
coerce_data_source
def coerce_data_source(x): """ Helper function to coerce an object into a data source, selecting the appropriate data source class for the given object. If `x` is already a data source it is returned as is. Parameters ---------- x: any The object to coerce. If `x` is a data source, ...
python
def coerce_data_source(x): """ Helper function to coerce an object into a data source, selecting the appropriate data source class for the given object. If `x` is already a data source it is returned as is. Parameters ---------- x: any The object to coerce. If `x` is a data source, ...
[ "def", "coerce_data_source", "(", "x", ")", ":", "if", "isinstance", "(", "x", ",", "AbstractDataSource", ")", ":", "return", "x", "elif", "isinstance", "(", "x", ",", "(", "list", ",", "tuple", ")", ")", ":", "# Sequence of array-likes", "items", "=", "...
Helper function to coerce an object into a data source, selecting the appropriate data source class for the given object. If `x` is already a data source it is returned as is. Parameters ---------- x: any The object to coerce. If `x` is a data source, it is returned as is. If it is ...
[ "Helper", "function", "to", "coerce", "an", "object", "into", "a", "data", "source", "selecting", "the", "appropriate", "data", "source", "class", "for", "the", "given", "object", ".", "If", "x", "is", "already", "a", "data", "source", "it", "is", "returne...
train
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/data_source.py#L1800-L1849
Britefury/batchup
batchup/data_source.py
AbstractDataSource.batch_map_concat
def batch_map_concat(self, func, batch_size, progress_iter_func=None, n_batches=None, prepend_args=None, **kwargs): """A batch oriented implementation of `map`. Applies a function to all the samples in this data source by breaking the data into mini-batches and applying ...
python
def batch_map_concat(self, func, batch_size, progress_iter_func=None, n_batches=None, prepend_args=None, **kwargs): """A batch oriented implementation of `map`. Applies a function to all the samples in this data source by breaking the data into mini-batches and applying ...
[ "def", "batch_map_concat", "(", "self", ",", "func", ",", "batch_size", ",", "progress_iter_func", "=", "None", ",", "n_batches", "=", "None", ",", "prepend_args", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "n_batches", "is", "None", ":", "n",...
A batch oriented implementation of `map`. Applies a function to all the samples in this data source by breaking the data into mini-batches and applying the function to each mini-batch. Returns the per-sample results. This method is a wrapper around the :func:`batch_map` function...
[ "A", "batch", "oriented", "implementation", "of", "map", ".", "Applies", "a", "function", "to", "all", "the", "samples", "in", "this", "data", "source", "by", "breaking", "the", "data", "into", "mini", "-", "batches", "and", "applying", "the", "function", ...
train
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/data_source.py#L123-L188
Britefury/batchup
batchup/data_source.py
RandomAccessDataSource.samples_by_indices
def samples_by_indices(self, indices): """ Gather a batch of samples by indices, applying the mapping described by the (optional) `indices` array passed to the constructor. Parameters ---------- indices: 1D-array of ints or slice The samples to retrie...
python
def samples_by_indices(self, indices): """ Gather a batch of samples by indices, applying the mapping described by the (optional) `indices` array passed to the constructor. Parameters ---------- indices: 1D-array of ints or slice The samples to retrie...
[ "def", "samples_by_indices", "(", "self", ",", "indices", ")", ":", "indices", "=", "self", ".", "sampler", ".", "map_indices", "(", "indices", ")", "return", "self", ".", "samples_by_indices_nomapping", "(", "indices", ")" ]
Gather a batch of samples by indices, applying the mapping described by the (optional) `indices` array passed to the constructor. Parameters ---------- indices: 1D-array of ints or slice The samples to retrieve Returns ------- list of arrays ...
[ "Gather", "a", "batch", "of", "samples", "by", "indices", "applying", "the", "mapping", "described", "by", "the", "(", "optional", ")", "indices", "array", "passed", "to", "the", "constructor", "." ]
train
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/data_source.py#L419-L436
Britefury/batchup
batchup/data_source.py
RandomAccessDataSource.batch_indices_iterator
def batch_indices_iterator(self, batch_size, shuffle=None, **kwargs): """ Create an iterator that generates mini-batch sample indices. The batches will have `batch_size` elements, with the exception of the final batch which will have less if there are insufficient elements left t...
python
def batch_indices_iterator(self, batch_size, shuffle=None, **kwargs): """ Create an iterator that generates mini-batch sample indices. The batches will have `batch_size` elements, with the exception of the final batch which will have less if there are insufficient elements left t...
[ "def", "batch_indices_iterator", "(", "self", ",", "batch_size", ",", "shuffle", "=", "None", ",", "*", "*", "kwargs", ")", ":", "shuffle_rng", "=", "self", ".", "_get_shuffle_rng", "(", "shuffle", ")", "if", "shuffle_rng", "is", "not", "None", ":", "retur...
Create an iterator that generates mini-batch sample indices. The batches will have `batch_size` elements, with the exception of the final batch which will have less if there are insufficient elements left to make a complete batch. If `shuffle` is `None` or `False` elements will be extra...
[ "Create", "an", "iterator", "that", "generates", "mini", "-", "batch", "sample", "indices", ".", "The", "batches", "will", "have", "batch_size", "elements", "with", "the", "exception", "of", "the", "final", "batch", "which", "will", "have", "less", "if", "th...
train
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/data_source.py#L438-L479
Britefury/batchup
batchup/data_source.py
RandomAccessDataSource.batch_iterator
def batch_iterator(self, batch_size, shuffle=None, **kwargs): """ Create an iterator that generates mini-batches extracted from this data source. The batches will have `batch_size` elements, with the exception of the final batch which will have less if there are insufficient ele...
python
def batch_iterator(self, batch_size, shuffle=None, **kwargs): """ Create an iterator that generates mini-batches extracted from this data source. The batches will have `batch_size` elements, with the exception of the final batch which will have less if there are insufficient ele...
[ "def", "batch_iterator", "(", "self", ",", "batch_size", ",", "shuffle", "=", "None", ",", "*", "*", "kwargs", ")", ":", "for", "batch_ndx", "in", "self", ".", "batch_indices_iterator", "(", "batch_size", ",", "shuffle", "=", "shuffle", ",", "*", "*", "k...
Create an iterator that generates mini-batches extracted from this data source. The batches will have `batch_size` elements, with the exception of the final batch which will have less if there are insufficient elements left to make a complete batch. If `shuffle` is `None` or `False` el...
[ "Create", "an", "iterator", "that", "generates", "mini", "-", "batches", "extracted", "from", "this", "data", "source", ".", "The", "batches", "will", "have", "batch_size", "elements", "with", "the", "exception", "of", "the", "final", "batch", "which", "will",...
train
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/data_source.py#L481-L518
Britefury/batchup
batchup/data_source.py
ArrayDataSource.samples_by_indices_nomapping
def samples_by_indices_nomapping(self, indices): """ Gather a batch of samples by indices *without* applying any index mapping resulting from the (optional) use of the `indices` array passed to the constructor. Parameters ---------- indices: 1D-array of ints or s...
python
def samples_by_indices_nomapping(self, indices): """ Gather a batch of samples by indices *without* applying any index mapping resulting from the (optional) use of the `indices` array passed to the constructor. Parameters ---------- indices: 1D-array of ints or s...
[ "def", "samples_by_indices_nomapping", "(", "self", ",", "indices", ")", ":", "batch", "=", "tuple", "(", "[", "d", "[", "indices", "]", "for", "d", "in", "self", ".", "data", "]", ")", "if", "self", ".", "include_indices", ":", "if", "isinstance", "("...
Gather a batch of samples by indices *without* applying any index mapping resulting from the (optional) use of the `indices` array passed to the constructor. Parameters ---------- indices: 1D-array of ints or slice The samples to retrieve Returns ---...
[ "Gather", "a", "batch", "of", "samples", "by", "indices", "*", "without", "*", "applying", "any", "index", "mapping", "resulting", "from", "the", "(", "optional", ")", "use", "of", "the", "indices", "array", "passed", "to", "the", "constructor", "." ]
train
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/data_source.py#L666-L689
Britefury/batchup
batchup/data_source.py
CallableDataSource.num_samples
def num_samples(self, **kwargs): """ Get the number of samples in this data source. Returns ------- int, `np.inf` or `None`. An int if the number of samples is known, `np.inf` if it is infinite or `None` if the number of samples is unknown. """ ...
python
def num_samples(self, **kwargs): """ Get the number of samples in this data source. Returns ------- int, `np.inf` or `None`. An int if the number of samples is known, `np.inf` if it is infinite or `None` if the number of samples is unknown. """ ...
[ "def", "num_samples", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "num_samples_fn", "is", "None", ":", "return", "None", "elif", "callable", "(", "self", ".", "num_samples_fn", ")", ":", "return", "self", ".", "num_samples_fn", "("...
Get the number of samples in this data source. Returns ------- int, `np.inf` or `None`. An int if the number of samples is known, `np.inf` if it is infinite or `None` if the number of samples is unknown.
[ "Get", "the", "number", "of", "samples", "in", "this", "data", "source", "." ]
train
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/data_source.py#L752-L767
Britefury/batchup
batchup/data_source.py
CompositeDataSource.samples_by_indices_nomapping
def samples_by_indices_nomapping(self, indices): """ Gather a batch of samples by indices *without* applying any index mapping. Parameters ---------- indices: list of either 1D-array of ints or slice A list of index arrays or slices; one for each data source ...
python
def samples_by_indices_nomapping(self, indices): """ Gather a batch of samples by indices *without* applying any index mapping. Parameters ---------- indices: list of either 1D-array of ints or slice A list of index arrays or slices; one for each data source ...
[ "def", "samples_by_indices_nomapping", "(", "self", ",", "indices", ")", ":", "if", "not", "self", ".", "_random_access", ":", "raise", "TypeError", "(", "'samples_by_indices_nomapping method not '", "'supported as one or more of the underlying '", "'data sources does not suppo...
Gather a batch of samples by indices *without* applying any index mapping. Parameters ---------- indices: list of either 1D-array of ints or slice A list of index arrays or slices; one for each data source that identify the samples to access Returns ...
[ "Gather", "a", "batch", "of", "samples", "by", "indices", "*", "without", "*", "applying", "any", "index", "mapping", "." ]
train
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/data_source.py#L982-L1009
Britefury/batchup
batchup/data_source.py
CompositeDataSource.batch_indices_iterator
def batch_indices_iterator(self, batch_size, **kwargs): """ Create an iterator that generates mini-batch sample indices The generated mini-batches indices take the form of nested lists of either: - 1D NumPy integer arrays - slices The list nesting structure with...
python
def batch_indices_iterator(self, batch_size, **kwargs): """ Create an iterator that generates mini-batch sample indices The generated mini-batches indices take the form of nested lists of either: - 1D NumPy integer arrays - slices The list nesting structure with...
[ "def", "batch_indices_iterator", "(", "self", ",", "batch_size", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "_random_access", ":", "raise", "TypeError", "(", "'batch_indices_iterator method not supported as '", "'one or more of the underlying data source...
Create an iterator that generates mini-batch sample indices The generated mini-batches indices take the form of nested lists of either: - 1D NumPy integer arrays - slices The list nesting structure with match that of the tree of data sources rooted at `self` Pa...
[ "Create", "an", "iterator", "that", "generates", "mini", "-", "batch", "sample", "indices" ]
train
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/data_source.py#L1040-L1071
Britefury/batchup
batchup/data_source.py
ChoiceDataSource.samples_by_indices_nomapping
def samples_by_indices_nomapping(self, indices): """ Gather a batch of samples by indices *without* applying any index mapping. Parameters ---------- indices: a tuple of the form `(dataset_index, sample_indices)` The `dataset_index` identifies the dataset fro...
python
def samples_by_indices_nomapping(self, indices): """ Gather a batch of samples by indices *without* applying any index mapping. Parameters ---------- indices: a tuple of the form `(dataset_index, sample_indices)` The `dataset_index` identifies the dataset fro...
[ "def", "samples_by_indices_nomapping", "(", "self", ",", "indices", ")", ":", "if", "not", "self", ".", "_random_access", ":", "raise", "TypeError", "(", "'samples_by_indices_nomapping method not '", "'supported as one or more of the underlying '", "'data sources does not suppo...
Gather a batch of samples by indices *without* applying any index mapping. Parameters ---------- indices: a tuple of the form `(dataset_index, sample_indices)` The `dataset_index` identifies the dataset from which to draw samples while `sample_indices` identifies...
[ "Gather", "a", "batch", "of", "samples", "by", "indices", "*", "without", "*", "applying", "any", "index", "mapping", "." ]
train
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/data_source.py#L1147-L1174
Britefury/batchup
batchup/data_source.py
ChoiceDataSource.batch_indices_iterator
def batch_indices_iterator(self, batch_size, shuffle=None, **kwargs): """ Create an iterator that generates mini-batch sample indices The generated mini-batches indices take the form of nested lists of either: - 1D NumPy integer arrays - slices The list nesting ...
python
def batch_indices_iterator(self, batch_size, shuffle=None, **kwargs): """ Create an iterator that generates mini-batch sample indices The generated mini-batches indices take the form of nested lists of either: - 1D NumPy integer arrays - slices The list nesting ...
[ "def", "batch_indices_iterator", "(", "self", ",", "batch_size", ",", "shuffle", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "_random_access", ":", "raise", "TypeError", "(", "'batch_indices_iterator method not supported as '", "'one ...
Create an iterator that generates mini-batch sample indices The generated mini-batches indices take the form of nested lists of either: - 1D NumPy integer arrays - slices The list nesting structure with match that of the tree of data sources rooted at `self` Pa...
[ "Create", "an", "iterator", "that", "generates", "mini", "-", "batch", "sample", "indices" ]
train
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/data_source.py#L1205-L1241
Britefury/batchup
batchup/data_source.py
MapDataSource.samples_by_indices_nomapping
def samples_by_indices_nomapping(self, indices): """ Gather a batch of samples by indices *without* applying any index mapping. Parameters ---------- indices: 1D-array of ints or slice An index array or a slice that selects the samples to retrieve Re...
python
def samples_by_indices_nomapping(self, indices): """ Gather a batch of samples by indices *without* applying any index mapping. Parameters ---------- indices: 1D-array of ints or slice An index array or a slice that selects the samples to retrieve Re...
[ "def", "samples_by_indices_nomapping", "(", "self", ",", "indices", ")", ":", "if", "not", "self", ".", "_random_access", ":", "raise", "TypeError", "(", "'samples_by_indices_nomapping method not '", "'supported as one or more of the underlying '", "'data sources does not suppo...
Gather a batch of samples by indices *without* applying any index mapping. Parameters ---------- indices: 1D-array of ints or slice An index array or a slice that selects the samples to retrieve Returns ------- nested list of arrays A min...
[ "Gather", "a", "batch", "of", "samples", "by", "indices", "*", "without", "*", "applying", "any", "index", "mapping", "." ]
train
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/data_source.py#L1404-L1424
Britefury/batchup
batchup/data_source.py
MapDataSource.samples_by_indices
def samples_by_indices(self, indices): """ Gather a batch of samples by indices, applying any index mapping defined by the underlying data sources. Parameters ---------- indices: 1D-array of ints or slice An index array or a slice that selects the samples to ...
python
def samples_by_indices(self, indices): """ Gather a batch of samples by indices, applying any index mapping defined by the underlying data sources. Parameters ---------- indices: 1D-array of ints or slice An index array or a slice that selects the samples to ...
[ "def", "samples_by_indices", "(", "self", ",", "indices", ")", ":", "if", "not", "self", ".", "_random_access", ":", "raise", "TypeError", "(", "'samples_by_indices method not supported as one '", "'or more of the underlying data sources does '", "'not support random access'", ...
Gather a batch of samples by indices, applying any index mapping defined by the underlying data sources. Parameters ---------- indices: 1D-array of ints or slice An index array or a slice that selects the samples to retrieve Returns ------- nested li...
[ "Gather", "a", "batch", "of", "samples", "by", "indices", "applying", "any", "index", "mapping", "defined", "by", "the", "underlying", "data", "sources", "." ]
train
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/data_source.py#L1426-L1446
Britefury/batchup
batchup/data_source.py
MapDataSource.batch_indices_iterator
def batch_indices_iterator(self, batch_size, **kwargs): """ Create an iterator that generates mini-batch sample indices The generated mini-batches indices take the form of nested lists of either: - 1D NumPy integer arrays - slices The list nesting structure with...
python
def batch_indices_iterator(self, batch_size, **kwargs): """ Create an iterator that generates mini-batch sample indices The generated mini-batches indices take the form of nested lists of either: - 1D NumPy integer arrays - slices The list nesting structure with...
[ "def", "batch_indices_iterator", "(", "self", ",", "batch_size", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "_random_access", ":", "raise", "TypeError", "(", "'batch_indices_iterator method not supported as '", "'one or more of the underlying data source...
Create an iterator that generates mini-batch sample indices The generated mini-batches indices take the form of nested lists of either: - 1D NumPy integer arrays - slices The list nesting structure with match that of the tree of data sources rooted at `self` Pa...
[ "Create", "an", "iterator", "that", "generates", "mini", "-", "batch", "sample", "indices" ]
train
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/data_source.py#L1448-L1475
datacats/datacats
datacats/cli/purge.py
purge
def purge(opts): """Purge environment database and uploaded files Usage: datacats purge [-s NAME | --delete-environment] [-y] [ENVIRONMENT] Options: --delete-environment Delete environment directory as well as its data, as well as the data for **all** sites. -s --site=NAME ...
python
def purge(opts): """Purge environment database and uploaded files Usage: datacats purge [-s NAME | --delete-environment] [-y] [ENVIRONMENT] Options: --delete-environment Delete environment directory as well as its data, as well as the data for **all** sites. -s --site=NAME ...
[ "def", "purge", "(", "opts", ")", ":", "old", "=", "False", "try", ":", "environment", "=", "Environment", ".", "load", "(", "opts", "[", "'ENVIRONMENT'", "]", ",", "opts", "[", "'--site'", "]", ")", "except", "DatacatsError", ":", "environment", "=", ...
Purge environment database and uploaded files Usage: datacats purge [-s NAME | --delete-environment] [-y] [ENVIRONMENT] Options: --delete-environment Delete environment directory as well as its data, as well as the data for **all** sites. -s --site=NAME Specify a site to be pu...
[ "Purge", "environment", "database", "and", "uploaded", "files" ]
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/cli/purge.py#L15-L59
datacats/datacats
datacats/error.py
DatacatsError.pretty_print
def pretty_print(self): """ Print the error message to stdout with colors and borders """ print colored.blue("-" * 40) print colored.red("datacats: problem was encountered:") print self.message print colored.blue("-" * 40)
python
def pretty_print(self): """ Print the error message to stdout with colors and borders """ print colored.blue("-" * 40) print colored.red("datacats: problem was encountered:") print self.message print colored.blue("-" * 40)
[ "def", "pretty_print", "(", "self", ")", ":", "print", "colored", ".", "blue", "(", "\"-\"", "*", "40", ")", "print", "colored", ".", "red", "(", "\"datacats: problem was encountered:\"", ")", "print", "self", ".", "message", "print", "colored", ".", "blue",...
Print the error message to stdout with colors and borders
[ "Print", "the", "error", "message", "to", "stdout", "with", "colors", "and", "borders" ]
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/error.py#L25-L32
datacats/datacats
datacats/password.py
generate_password
def generate_password(): """ Return a 16-character alphanumeric random string generated by the operating system's secure pseudo random number generator """ chars = uppercase + lowercase + digits return ''.join(SystemRandom().choice(chars) for x in xrange(16))
python
def generate_password(): """ Return a 16-character alphanumeric random string generated by the operating system's secure pseudo random number generator """ chars = uppercase + lowercase + digits return ''.join(SystemRandom().choice(chars) for x in xrange(16))
[ "def", "generate_password", "(", ")", ":", "chars", "=", "uppercase", "+", "lowercase", "+", "digits", "return", "''", ".", "join", "(", "SystemRandom", "(", ")", ".", "choice", "(", "chars", ")", "for", "x", "in", "xrange", "(", "16", ")", ")" ]
Return a 16-character alphanumeric random string generated by the operating system's secure pseudo random number generator
[ "Return", "a", "16", "-", "character", "alphanumeric", "random", "string", "generated", "by", "the", "operating", "system", "s", "secure", "pseudo", "random", "number", "generator" ]
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/password.py#L10-L16
datacats/datacats
datacats/docker.py
_machine_check_connectivity
def _machine_check_connectivity(): """ This method calls to docker-machine on the command line and makes sure that it is up and ready. Potential improvements to be made: - Support multiple machine names (run a `docker-machine ls` and then see which machines are active. Use a priority li...
python
def _machine_check_connectivity(): """ This method calls to docker-machine on the command line and makes sure that it is up and ready. Potential improvements to be made: - Support multiple machine names (run a `docker-machine ls` and then see which machines are active. Use a priority li...
[ "def", "_machine_check_connectivity", "(", ")", ":", "with", "open", "(", "devnull", ",", "'w'", ")", "as", "devnull_f", ":", "try", ":", "status", "=", "subprocess", ".", "check_output", "(", "[", "'docker-machine'", ",", "'status'", ",", "'dev'", "]", ",...
This method calls to docker-machine on the command line and makes sure that it is up and ready. Potential improvements to be made: - Support multiple machine names (run a `docker-machine ls` and then see which machines are active. Use a priority list)
[ "This", "method", "calls", "to", "docker", "-", "machine", "on", "the", "command", "line", "and", "makes", "sure", "that", "it", "is", "up", "and", "ready", "." ]
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/docker.py#L66-L92
datacats/datacats
datacats/docker.py
ro_rw_to_binds
def ro_rw_to_binds(ro, rw): """ ro and rw {localdir: binddir} dicts to docker-py's {localdir: {'bind': binddir, 'ro': T/F}} binds dicts """ out = {} if ro: for localdir, binddir in ro.iteritems(): out[localdir] = {'bind': binddir, 'ro': True} if rw: for localdir, ...
python
def ro_rw_to_binds(ro, rw): """ ro and rw {localdir: binddir} dicts to docker-py's {localdir: {'bind': binddir, 'ro': T/F}} binds dicts """ out = {} if ro: for localdir, binddir in ro.iteritems(): out[localdir] = {'bind': binddir, 'ro': True} if rw: for localdir, ...
[ "def", "ro_rw_to_binds", "(", "ro", ",", "rw", ")", ":", "out", "=", "{", "}", "if", "ro", ":", "for", "localdir", ",", "binddir", "in", "ro", ".", "iteritems", "(", ")", ":", "out", "[", "localdir", "]", "=", "{", "'bind'", ":", "binddir", ",", ...
ro and rw {localdir: binddir} dicts to docker-py's {localdir: {'bind': binddir, 'ro': T/F}} binds dicts
[ "ro", "and", "rw", "{", "localdir", ":", "binddir", "}", "dicts", "to", "docker", "-", "py", "s", "{", "localdir", ":", "{", "bind", ":", "binddir", "ro", ":", "T", "/", "F", "}}", "binds", "dicts" ]
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/docker.py#L140-L152
datacats/datacats
datacats/docker.py
web_command
def web_command(command, ro=None, rw=None, links=None, image='datacats/web', volumes_from=None, commit=False, clean_up=False, stream_output=None, entrypoint=None): """ Run a single command in a web image optionally preloaded with the ckan source and virtual envrionment. ...
python
def web_command(command, ro=None, rw=None, links=None, image='datacats/web', volumes_from=None, commit=False, clean_up=False, stream_output=None, entrypoint=None): """ Run a single command in a web image optionally preloaded with the ckan source and virtual envrionment. ...
[ "def", "web_command", "(", "command", ",", "ro", "=", "None", ",", "rw", "=", "None", ",", "links", "=", "None", ",", "image", "=", "'datacats/web'", ",", "volumes_from", "=", "None", ",", "commit", "=", "False", ",", "clean_up", "=", "False", ",", "...
Run a single command in a web image optionally preloaded with the ckan source and virtual envrionment. :param command: command to execute :param ro: {localdir: binddir} dict for read-only volumes :param rw: {localdir: binddir} dict for read-write volumes :param links: links passed to start :par...
[ "Run", "a", "single", "command", "in", "a", "web", "image", "optionally", "preloaded", "with", "the", "ckan", "source", "and", "virtual", "envrionment", "." ]
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/docker.py#L163-L212
datacats/datacats
datacats/docker.py
remote_server_command
def remote_server_command(command, environment, user_profile, **kwargs): """ Wraps web_command function with docker bindings needed to connect to a remote server (such as datacats.com) and run commands there (for example, when you want to copy your catalog to that server). The files binded ...
python
def remote_server_command(command, environment, user_profile, **kwargs): """ Wraps web_command function with docker bindings needed to connect to a remote server (such as datacats.com) and run commands there (for example, when you want to copy your catalog to that server). The files binded ...
[ "def", "remote_server_command", "(", "command", ",", "environment", ",", "user_profile", ",", "*", "*", "kwargs", ")", ":", "if", "environment", ".", "remote_server_key", ":", "temp", "=", "tempfile", ".", "NamedTemporaryFile", "(", "mode", "=", "\"wb\"", ")",...
Wraps web_command function with docker bindings needed to connect to a remote server (such as datacats.com) and run commands there (for example, when you want to copy your catalog to that server). The files binded to the docker image include the user's ssh credentials: ssh_config file, ...
[ "Wraps", "web_command", "function", "with", "docker", "bindings", "needed", "to", "connect", "to", "a", "remote", "server", "(", "such", "as", "datacats", ".", "com", ")", "and", "run", "commands", "there", "(", "for", "example", "when", "you", "want", "to...
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/docker.py#L215-L253
datacats/datacats
datacats/docker.py
run_container
def run_container(name, image, command=None, environment=None, ro=None, rw=None, links=None, detach=True, volumes_from=None, port_bindings=None, log_syslog=False): """ Wrapper for docker create_container, start calls :param log_syslog: bool flag to redirect container's l...
python
def run_container(name, image, command=None, environment=None, ro=None, rw=None, links=None, detach=True, volumes_from=None, port_bindings=None, log_syslog=False): """ Wrapper for docker create_container, start calls :param log_syslog: bool flag to redirect container's l...
[ "def", "run_container", "(", "name", ",", "image", ",", "command", "=", "None", ",", "environment", "=", "None", ",", "ro", "=", "None", ",", "rw", "=", "None", ",", "links", "=", "None", ",", "detach", "=", "True", ",", "volumes_from", "=", "None", ...
Wrapper for docker create_container, start calls :param log_syslog: bool flag to redirect container's logs to host's syslog :returns: container info dict or None if container couldn't be created Raises PortAllocatedError if container couldn't start on the requested port.
[ "Wrapper", "for", "docker", "create_container", "start", "calls" ]
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/docker.py#L256-L300
datacats/datacats
datacats/docker.py
remove_container
def remove_container(name, force=False): """ Wrapper for docker remove_container :returns: True if container was found and removed """ try: if not force: _get_docker().stop(name) except APIError: pass try: _get_docker().remove_container(name, force=True)...
python
def remove_container(name, force=False): """ Wrapper for docker remove_container :returns: True if container was found and removed """ try: if not force: _get_docker().stop(name) except APIError: pass try: _get_docker().remove_container(name, force=True)...
[ "def", "remove_container", "(", "name", ",", "force", "=", "False", ")", ":", "try", ":", "if", "not", "force", ":", "_get_docker", "(", ")", ".", "stop", "(", "name", ")", "except", "APIError", ":", "pass", "try", ":", "_get_docker", "(", ")", ".", ...
Wrapper for docker remove_container :returns: True if container was found and removed
[ "Wrapper", "for", "docker", "remove_container" ]
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/docker.py#L318-L334
datacats/datacats
datacats/docker.py
container_logs
def container_logs(name, tail, follow, timestamps): """ Wrapper for docker logs, attach commands. """ if follow: return _get_docker().attach( name, stdout=True, stderr=True, stream=True ) return _docker.logs( name, ...
python
def container_logs(name, tail, follow, timestamps): """ Wrapper for docker logs, attach commands. """ if follow: return _get_docker().attach( name, stdout=True, stderr=True, stream=True ) return _docker.logs( name, ...
[ "def", "container_logs", "(", "name", ",", "tail", ",", "follow", ",", "timestamps", ")", ":", "if", "follow", ":", "return", "_get_docker", "(", ")", ".", "attach", "(", "name", ",", "stdout", "=", "True", ",", "stderr", "=", "True", ",", "stream", ...
Wrapper for docker logs, attach commands.
[ "Wrapper", "for", "docker", "logs", "attach", "commands", "." ]
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/docker.py#L349-L367
datacats/datacats
datacats/docker.py
collect_logs
def collect_logs(name): """ Returns a string representation of the logs from a container. This is similar to container_logs but uses the `follow` option and flattens the logs into a string instead of a generator. :param name: The container name to grab logs for :return: A string representation ...
python
def collect_logs(name): """ Returns a string representation of the logs from a container. This is similar to container_logs but uses the `follow` option and flattens the logs into a string instead of a generator. :param name: The container name to grab logs for :return: A string representation ...
[ "def", "collect_logs", "(", "name", ")", ":", "logs", "=", "container_logs", "(", "name", ",", "\"all\"", ",", "True", ",", "None", ")", "string", "=", "\"\"", "for", "s", "in", "logs", ":", "string", "+=", "s", "return", "string" ]
Returns a string representation of the logs from a container. This is similar to container_logs but uses the `follow` option and flattens the logs into a string instead of a generator. :param name: The container name to grab logs for :return: A string representation of the logs
[ "Returns", "a", "string", "representation", "of", "the", "logs", "from", "a", "container", ".", "This", "is", "similar", "to", "container_logs", "but", "uses", "the", "follow", "option", "and", "flattens", "the", "logs", "into", "a", "string", "instead", "of...
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/docker.py#L370-L383
datacats/datacats
datacats/docker.py
pull_stream
def pull_stream(image): """ Return generator of pull status objects """ return (json.loads(s) for s in _get_docker().pull(image, stream=True))
python
def pull_stream(image): """ Return generator of pull status objects """ return (json.loads(s) for s in _get_docker().pull(image, stream=True))
[ "def", "pull_stream", "(", "image", ")", ":", "return", "(", "json", ".", "loads", "(", "s", ")", "for", "s", "in", "_get_docker", "(", ")", ".", "pull", "(", "image", ",", "stream", "=", "True", ")", ")" ]
Return generator of pull status objects
[ "Return", "generator", "of", "pull", "status", "objects" ]
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/docker.py#L394-L398
datacats/datacats
datacats/docker.py
data_only_container
def data_only_container(name, volumes): """ create "data-only container" if it doesn't already exist. We'd like to avoid these, but postgres + boot2docker make it difficult, see issue #5 """ info = inspect_container(name) if info: return c = _get_docker().create_container( ...
python
def data_only_container(name, volumes): """ create "data-only container" if it doesn't already exist. We'd like to avoid these, but postgres + boot2docker make it difficult, see issue #5 """ info = inspect_container(name) if info: return c = _get_docker().create_container( ...
[ "def", "data_only_container", "(", "name", ",", "volumes", ")", ":", "info", "=", "inspect_container", "(", "name", ")", "if", "info", ":", "return", "c", "=", "_get_docker", "(", ")", ".", "create_container", "(", "name", "=", "name", ",", "image", "=",...
create "data-only container" if it doesn't already exist. We'd like to avoid these, but postgres + boot2docker make it difficult, see issue #5
[ "create", "data", "-", "only", "container", "if", "it", "doesn", "t", "already", "exist", "." ]
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/docker.py#L401-L417
datacats/datacats
datacats/cli/main.py
main
def main(): """ The main entry point for datacats cli tool (as defined in setup.py's entry_points) It parses the cli arguments for corresponding options and runs the corresponding command """ # pylint: disable=bare-except try: command_fn, opts = _parse_arguments(sys.argv[1:]) ...
python
def main(): """ The main entry point for datacats cli tool (as defined in setup.py's entry_points) It parses the cli arguments for corresponding options and runs the corresponding command """ # pylint: disable=bare-except try: command_fn, opts = _parse_arguments(sys.argv[1:]) ...
[ "def", "main", "(", ")", ":", "# pylint: disable=bare-except", "try", ":", "command_fn", ",", "opts", "=", "_parse_arguments", "(", "sys", ".", "argv", "[", "1", ":", "]", ")", "# purge handles loading differently", "# 1 - Bail and just call the command if it doesn't ha...
The main entry point for datacats cli tool (as defined in setup.py's entry_points) It parses the cli arguments for corresponding options and runs the corresponding command
[ "The", "main", "entry", "point", "for", "datacats", "cli", "tool" ]
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/cli/main.py#L78-L128
datacats/datacats
datacats/cli/main.py
_subcommand_arguments
def _subcommand_arguments(args): """ Return (subcommand, (possibly adjusted) arguments for that subcommand) Returns (None, args) when no subcommand is found Parsing our arguments is hard. Each subcommand has its own docopt validation, and some subcommands (paster and shell) have positional opt...
python
def _subcommand_arguments(args): """ Return (subcommand, (possibly adjusted) arguments for that subcommand) Returns (None, args) when no subcommand is found Parsing our arguments is hard. Each subcommand has its own docopt validation, and some subcommands (paster and shell) have positional opt...
[ "def", "_subcommand_arguments", "(", "args", ")", ":", "skip_site", "=", "False", "# Find subcommand without docopt so that subcommand options may appear", "# anywhere", "for", "i", ",", "a", "in", "enumerate", "(", "args", ")", ":", "if", "skip_site", ":", "skip_site...
Return (subcommand, (possibly adjusted) arguments for that subcommand) Returns (None, args) when no subcommand is found Parsing our arguments is hard. Each subcommand has its own docopt validation, and some subcommands (paster and shell) have positional options (some options passed to datacats and oth...
[ "Return", "(", "subcommand", "(", "possibly", "adjusted", ")", "arguments", "for", "that", "subcommand", ")" ]
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/cli/main.py#L156-L213
datacats/datacats
datacats/cli/manage.py
start
def start(environment, opts): """Create containers and start serving environment Usage: datacats start [-b] [--site-url SITE_URL] [-p|--no-watch] [-s NAME] [-i] [--syslog] [--address=IP] [ENVIRONMENT [PORT]] datacats start -r [-b] [--site-url SITE_URL] [-s NAME] [--syslog] [-i...
python
def start(environment, opts): """Create containers and start serving environment Usage: datacats start [-b] [--site-url SITE_URL] [-p|--no-watch] [-s NAME] [-i] [--syslog] [--address=IP] [ENVIRONMENT [PORT]] datacats start -r [-b] [--site-url SITE_URL] [-s NAME] [--syslog] [-i...
[ "def", "start", "(", "environment", ",", "opts", ")", ":", "environment", ".", "require_data", "(", ")", "if", "environment", ".", "fully_running", "(", ")", ":", "print", "'Already running at {0}'", ".", "format", "(", "environment", ".", "web_address", "(", ...
Create containers and start serving environment Usage: datacats start [-b] [--site-url SITE_URL] [-p|--no-watch] [-s NAME] [-i] [--syslog] [--address=IP] [ENVIRONMENT [PORT]] datacats start -r [-b] [--site-url SITE_URL] [-s NAME] [--syslog] [-i] [--address=IP] [ENVIRONMENT] Optio...
[ "Create", "containers", "and", "start", "serving", "environment" ]
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/cli/manage.py#L41-L71
datacats/datacats
datacats/cli/manage.py
reload_
def reload_(environment, opts): """Reload environment source and configuration Usage: datacats reload [-b] [-p|--no-watch] [--syslog] [-s NAME] [--site-url=SITE_URL] [-i] [--address=IP] [ENVIRONMENT [PORT]] datacats reload -r [-b] [--syslog] [-s NAME] [--address=IP] [--site-url=SITE...
python
def reload_(environment, opts): """Reload environment source and configuration Usage: datacats reload [-b] [-p|--no-watch] [--syslog] [-s NAME] [--site-url=SITE_URL] [-i] [--address=IP] [ENVIRONMENT [PORT]] datacats reload -r [-b] [--syslog] [-s NAME] [--address=IP] [--site-url=SITE...
[ "def", "reload_", "(", "environment", ",", "opts", ")", ":", "if", "opts", "[", "'--interactive'", "]", ":", "# We can't wait for the server if we're tty'd", "opts", "[", "'--background'", "]", "=", "True", "if", "opts", "[", "'--address'", "]", "and", "is_boot2...
Reload environment source and configuration Usage: datacats reload [-b] [-p|--no-watch] [--syslog] [-s NAME] [--site-url=SITE_URL] [-i] [--address=IP] [ENVIRONMENT [PORT]] datacats reload -r [-b] [--syslog] [-s NAME] [--address=IP] [--site-url=SITE_URL] [-i] ...
[ "Reload", "environment", "source", "and", "configuration" ]
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/cli/manage.py#L74-L140
datacats/datacats
datacats/cli/manage.py
info
def info(environment, opts): """Display information about environment and running containers Usage: datacats info [-qr] [ENVIRONMENT] Options: -q --quiet Echo only the web URL or nothing if not running ENVIRONMENT may be an environment name or a path to an environment directory. Default: '.' """ ...
python
def info(environment, opts): """Display information about environment and running containers Usage: datacats info [-qr] [ENVIRONMENT] Options: -q --quiet Echo only the web URL or nothing if not running ENVIRONMENT may be an environment name or a path to an environment directory. Default: '.' """ ...
[ "def", "info", "(", "environment", ",", "opts", ")", ":", "damaged", "=", "False", "sites", "=", "environment", ".", "sites", "if", "not", "environment", ".", "sites", ":", "sites", "=", "[", "]", "damaged", "=", "True", "if", "opts", "[", "'--quiet'",...
Display information about environment and running containers Usage: datacats info [-qr] [ENVIRONMENT] Options: -q --quiet Echo only the web URL or nothing if not running ENVIRONMENT may be an environment name or a path to an environment directory. Default: '.'
[ "Display", "information", "about", "environment", "and", "running", "containers" ]
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/cli/manage.py#L143-L190
datacats/datacats
datacats/cli/manage.py
logs
def logs(environment, opts): """Display or follow container logs Usage: datacats logs [--postgres | --solr | --datapusher] [-s NAME] [-tr] [--tail=LINES] [ENVIRONMENT] datacats logs -f [--postgres | --solr | --datapusher] [-s NAME] [-r] [ENVIRONMENT] Options: --datapusher Show logs for datapusher inst...
python
def logs(environment, opts): """Display or follow container logs Usage: datacats logs [--postgres | --solr | --datapusher] [-s NAME] [-tr] [--tail=LINES] [ENVIRONMENT] datacats logs -f [--postgres | --solr | --datapusher] [-s NAME] [-r] [ENVIRONMENT] Options: --datapusher Show logs for datapusher inst...
[ "def", "logs", "(", "environment", ",", "opts", ")", ":", "container", "=", "'web'", "if", "opts", "[", "'--solr'", "]", ":", "container", "=", "'solr'", "if", "opts", "[", "'--postgres'", "]", ":", "container", "=", "'postgres'", "if", "opts", "[", "'...
Display or follow container logs Usage: datacats logs [--postgres | --solr | --datapusher] [-s NAME] [-tr] [--tail=LINES] [ENVIRONMENT] datacats logs -f [--postgres | --solr | --datapusher] [-s NAME] [-r] [ENVIRONMENT] Options: --datapusher Show logs for datapusher instead of web logs --postgres ...
[ "Display", "or", "follow", "container", "logs" ]
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/cli/manage.py#L206-L244
datacats/datacats
datacats/cli/manage.py
open_
def open_(environment, opts): # pylint: disable=unused-argument """Open web browser window to this environment Usage: datacats open [-r] [-s NAME] [ENVIRONMENT] Options: -s --site=NAME Choose a site to open [default: primary] ENVIRONMENT may be an environment name or a path to an environment director...
python
def open_(environment, opts): # pylint: disable=unused-argument """Open web browser window to this environment Usage: datacats open [-r] [-s NAME] [ENVIRONMENT] Options: -s --site=NAME Choose a site to open [default: primary] ENVIRONMENT may be an environment name or a path to an environment director...
[ "def", "open_", "(", "environment", ",", "opts", ")", ":", "# pylint: disable=unused-argument", "environment", ".", "require_data", "(", ")", "addr", "=", "environment", ".", "web_address", "(", ")", "if", "not", "addr", ":", "print", "\"Site not currently running...
Open web browser window to this environment Usage: datacats open [-r] [-s NAME] [ENVIRONMENT] Options: -s --site=NAME Choose a site to open [default: primary] ENVIRONMENT may be an environment name or a path to an environment directory. Default: '.'
[ "Open", "web", "browser", "window", "to", "this", "environment" ]
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/cli/manage.py#L247-L266
datacats/datacats
datacats/cli/manage.py
tweak
def tweak(environment, opts): """Commands operating on environment data Usage: datacats tweak --install-postgis [ENVIRONMENT] datacats tweak --add-redis [ENVIRONMENT] datacats tweak --admin-password [ENVIRONMENT] Options: --install-postgis Install postgis in ckan database --add-redis Adds re...
python
def tweak(environment, opts): """Commands operating on environment data Usage: datacats tweak --install-postgis [ENVIRONMENT] datacats tweak --add-redis [ENVIRONMENT] datacats tweak --admin-password [ENVIRONMENT] Options: --install-postgis Install postgis in ckan database --add-redis Adds re...
[ "def", "tweak", "(", "environment", ",", "opts", ")", ":", "environment", ".", "require_data", "(", ")", "if", "opts", "[", "'--install-postgis'", "]", ":", "print", "\"Installing postgis\"", "environment", ".", "install_postgis_sql", "(", ")", "if", "opts", "...
Commands operating on environment data Usage: datacats tweak --install-postgis [ENVIRONMENT] datacats tweak --add-redis [ENVIRONMENT] datacats tweak --admin-password [ENVIRONMENT] Options: --install-postgis Install postgis in ckan database --add-redis Adds redis next time this environment reload...
[ "Commands", "operating", "on", "environment", "data" ]
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/cli/manage.py#L269-L299
datacats/datacats
datacats/migrate.py
_split_path
def _split_path(path): """ A wrapper around the normal split function that ignores any trailing /. :return: A tuple of the form (dirname, last) where last is the last element in the path. """ # Get around a quirk in path_split where a / at the end will make the # dirname (split[0])...
python
def _split_path(path): """ A wrapper around the normal split function that ignores any trailing /. :return: A tuple of the form (dirname, last) where last is the last element in the path. """ # Get around a quirk in path_split where a / at the end will make the # dirname (split[0])...
[ "def", "_split_path", "(", "path", ")", ":", "# Get around a quirk in path_split where a / at the end will make the", "# dirname (split[0]) the entire path", "path", "=", "path", "[", ":", "-", "1", "]", "if", "path", "[", "-", "1", "]", "==", "'/'", "else", "path",...
A wrapper around the normal split function that ignores any trailing /. :return: A tuple of the form (dirname, last) where last is the last element in the path.
[ "A", "wrapper", "around", "the", "normal", "split", "function", "that", "ignores", "any", "trailing", "/", "." ]
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/migrate.py#L43-L54
datacats/datacats
datacats/migrate.py
_one_to_two
def _one_to_two(datadir): """After this command, your environment will be converted to format version {}. and will only work with datacats version exceeding and including 1.0.0. This migration is necessary to support multiple sites within the same environment. Your current site will be kept and will be named "prima...
python
def _one_to_two(datadir): """After this command, your environment will be converted to format version {}. and will only work with datacats version exceeding and including 1.0.0. This migration is necessary to support multiple sites within the same environment. Your current site will be kept and will be named "prima...
[ "def", "_one_to_two", "(", "datadir", ")", ":", "new_site_name", "=", "'primary'", "split", "=", "_split_path", "(", "datadir", ")", "print", "'Making sure that containers are stopped...'", "env_name", "=", "split", "[", "1", "]", "# Old-style names on purpose! We need ...
After this command, your environment will be converted to format version {}. and will only work with datacats version exceeding and including 1.0.0. This migration is necessary to support multiple sites within the same environment. Your current site will be kept and will be named "primary". Would you like to continue ...
[ "After", "this", "command", "your", "environment", "will", "be", "converted", "to", "format", "version", "{}", ".", "and", "will", "only", "work", "with", "datacats", "version", "exceeding", "and", "including", "1", ".", "0", ".", "0", ".", "This", "migrat...
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/migrate.py#L57-L130
datacats/datacats
datacats/migrate.py
_two_to_one
def _two_to_one(datadir): """After this command, your environment will be converted to format version {} and will not work with Datacats versions beyond and including 1.0.0. This format version doesn't support multiple sites, and after this only your "primary" site will be usable, though other sites will be maintai...
python
def _two_to_one(datadir): """After this command, your environment will be converted to format version {} and will not work with Datacats versions beyond and including 1.0.0. This format version doesn't support multiple sites, and after this only your "primary" site will be usable, though other sites will be maintai...
[ "def", "_two_to_one", "(", "datadir", ")", ":", "_", ",", "env_name", "=", "_split_path", "(", "datadir", ")", "print", "'Making sure that containers are stopped...'", "# New-style names", "remove_container", "(", "'datacats_web_{}_primary'", ".", "format", "(", "env_na...
After this command, your environment will be converted to format version {} and will not work with Datacats versions beyond and including 1.0.0. This format version doesn't support multiple sites, and after this only your "primary" site will be usable, though other sites will be maintained if you wish to do a migration...
[ "After", "this", "command", "your", "environment", "will", "be", "converted", "to", "format", "version", "{}", "and", "will", "not", "work", "with", "Datacats", "versions", "beyond", "and", "including", "1", ".", "0", ".", "0", ".", "This", "format", "vers...
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/migrate.py#L133-L190
datacats/datacats
datacats/migrate.py
convert_environment
def convert_environment(datadir, version, always_yes): """ Converts an environment TO the version specified by `version`. :param datadir: The datadir to convert. :param version: The version to convert TO. :param always_yes: True if the user shouldn't be prompted about the migration. """ # Si...
python
def convert_environment(datadir, version, always_yes): """ Converts an environment TO the version specified by `version`. :param datadir: The datadir to convert. :param version: The version to convert TO. :param always_yes: True if the user shouldn't be prompted about the migration. """ # Si...
[ "def", "convert_environment", "(", "datadir", ",", "version", ",", "always_yes", ")", ":", "# Since we don't call either load() or new() we have to call require_images ourselves.", "require_images", "(", ")", "inp", "=", "None", "old_version", "=", "_get_current_format", "(",...
Converts an environment TO the version specified by `version`. :param datadir: The datadir to convert. :param version: The version to convert TO. :param always_yes: True if the user shouldn't be prompted about the migration.
[ "Converts", "an", "environment", "TO", "the", "version", "specified", "by", "version", ".", ":", "param", "datadir", ":", "The", "datadir", "to", "convert", ".", ":", "param", "version", ":", "The", "version", "to", "convert", "TO", ".", ":", "param", "a...
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/migrate.py#L199-L237
supercoderz/pyflightdata
pyflightdata/flightdata.py
FlightData.get_history_by_flight_number
def get_history_by_flight_number(self, flight_number, page=1, limit=100): """Fetch the history of a flight by its number. This method can be used to get the history of a flight route by the number. It checks the user authentication and returns the data accordingly. Args: fl...
python
def get_history_by_flight_number(self, flight_number, page=1, limit=100): """Fetch the history of a flight by its number. This method can be used to get the history of a flight route by the number. It checks the user authentication and returns the data accordingly. Args: fl...
[ "def", "get_history_by_flight_number", "(", "self", ",", "flight_number", ",", "page", "=", "1", ",", "limit", "=", "100", ")", ":", "url", "=", "FLT_BASE", ".", "format", "(", "flight_number", ",", "str", "(", "self", ".", "AUTH_TOKEN", ")", ",", "page"...
Fetch the history of a flight by its number. This method can be used to get the history of a flight route by the number. It checks the user authentication and returns the data accordingly. Args: flight_number (str): The flight number, e.g. AI101 page (int): Optional pag...
[ "Fetch", "the", "history", "of", "a", "flight", "by", "its", "number", "." ]
train
https://github.com/supercoderz/pyflightdata/blob/2caf9f429288f9a171893d1b8377d0c6244541cc/pyflightdata/flightdata.py#L58-L83
supercoderz/pyflightdata
pyflightdata/flightdata.py
FlightData.get_history_by_tail_number
def get_history_by_tail_number(self, tail_number, page=1, limit=100): """Fetch the history of a particular aircraft by its tail number. This method can be used to get the history of a particular aircraft by its tail number. It checks the user authentication and returns the data accordingly. ...
python
def get_history_by_tail_number(self, tail_number, page=1, limit=100): """Fetch the history of a particular aircraft by its tail number. This method can be used to get the history of a particular aircraft by its tail number. It checks the user authentication and returns the data accordingly. ...
[ "def", "get_history_by_tail_number", "(", "self", ",", "tail_number", ",", "page", "=", "1", ",", "limit", "=", "100", ")", ":", "url", "=", "REG_BASE", ".", "format", "(", "tail_number", ",", "str", "(", "self", ".", "AUTH_TOKEN", ")", ",", "page", ",...
Fetch the history of a particular aircraft by its tail number. This method can be used to get the history of a particular aircraft by its tail number. It checks the user authentication and returns the data accordingly. Args: tail_number (str): The tail number, e.g. VT-ANL ...
[ "Fetch", "the", "history", "of", "a", "particular", "aircraft", "by", "its", "tail", "number", "." ]
train
https://github.com/supercoderz/pyflightdata/blob/2caf9f429288f9a171893d1b8377d0c6244541cc/pyflightdata/flightdata.py#L85-L110
supercoderz/pyflightdata
pyflightdata/flightdata.py
FlightData.get_airports
def get_airports(self, country): """Returns a list of all the airports For a given country this returns a list of dicts, one for each airport, with information like the iata code of the airport etc Args: country (str): The country for which the airports will be fetched Exam...
python
def get_airports(self, country): """Returns a list of all the airports For a given country this returns a list of dicts, one for each airport, with information like the iata code of the airport etc Args: country (str): The country for which the airports will be fetched Exam...
[ "def", "get_airports", "(", "self", ",", "country", ")", ":", "url", "=", "AIRPORT_BASE", ".", "format", "(", "country", ".", "replace", "(", "\" \"", ",", "\"-\"", ")", ")", "return", "self", ".", "_fr24", ".", "get_airports_data", "(", "url", ")" ]
Returns a list of all the airports For a given country this returns a list of dicts, one for each airport, with information like the iata code of the airport etc Args: country (str): The country for which the airports will be fetched Example:: from pyflightdata import ...
[ "Returns", "a", "list", "of", "all", "the", "airports", "For", "a", "given", "country", "this", "returns", "a", "list", "of", "dicts", "one", "for", "each", "airport", "with", "information", "like", "the", "iata", "code", "of", "the", "airport", "etc" ]
train
https://github.com/supercoderz/pyflightdata/blob/2caf9f429288f9a171893d1b8377d0c6244541cc/pyflightdata/flightdata.py#L118-L133
supercoderz/pyflightdata
pyflightdata/flightdata.py
FlightData.get_info_by_tail_number
def get_info_by_tail_number(self, tail_number, page=1, limit=100): """Fetch the details of a particular aircraft by its tail number. This method can be used to get the details of a particular aircraft by its tail number. Details include the serial number, age etc along with links to the images ...
python
def get_info_by_tail_number(self, tail_number, page=1, limit=100): """Fetch the details of a particular aircraft by its tail number. This method can be used to get the details of a particular aircraft by its tail number. Details include the serial number, age etc along with links to the images ...
[ "def", "get_info_by_tail_number", "(", "self", ",", "tail_number", ",", "page", "=", "1", ",", "limit", "=", "100", ")", ":", "url", "=", "REG_BASE", ".", "format", "(", "tail_number", ",", "str", "(", "self", ".", "AUTH_TOKEN", ")", ",", "page", ",", ...
Fetch the details of a particular aircraft by its tail number. This method can be used to get the details of a particular aircraft by its tail number. Details include the serial number, age etc along with links to the images of the aircraft. It checks the user authentication and returns the dat...
[ "Fetch", "the", "details", "of", "a", "particular", "aircraft", "by", "its", "tail", "number", "." ]
train
https://github.com/supercoderz/pyflightdata/blob/2caf9f429288f9a171893d1b8377d0c6244541cc/pyflightdata/flightdata.py#L135-L160
supercoderz/pyflightdata
pyflightdata/flightdata.py
FlightData.get_fleet
def get_fleet(self, airline_key): """Get the fleet for a particular airline. Given a airline code form the get_airlines() method output, this method returns the fleet for the airline. Args: airline_key (str): The code for the airline on flightradar24 Returns: A...
python
def get_fleet(self, airline_key): """Get the fleet for a particular airline. Given a airline code form the get_airlines() method output, this method returns the fleet for the airline. Args: airline_key (str): The code for the airline on flightradar24 Returns: A...
[ "def", "get_fleet", "(", "self", ",", "airline_key", ")", ":", "url", "=", "AIRLINE_FLEET_BASE", ".", "format", "(", "airline_key", ")", "return", "self", ".", "_fr24", ".", "get_airline_fleet_data", "(", "url", ",", "self", ".", "AUTH_TOKEN", "!=", "''", ...
Get the fleet for a particular airline. Given a airline code form the get_airlines() method output, this method returns the fleet for the airline. Args: airline_key (str): The code for the airline on flightradar24 Returns: A list of dicts, one for each aircraft in the ...
[ "Get", "the", "fleet", "for", "a", "particular", "airline", "." ]
train
https://github.com/supercoderz/pyflightdata/blob/2caf9f429288f9a171893d1b8377d0c6244541cc/pyflightdata/flightdata.py#L172-L191
supercoderz/pyflightdata
pyflightdata/flightdata.py
FlightData.get_flights
def get_flights(self, search_key): """Get the flights for a particular airline. Given a full or partial flight number string, this method returns the first 100 flights matching that string. Please note this method was different in earlier versions. The older versions took an airline code and r...
python
def get_flights(self, search_key): """Get the flights for a particular airline. Given a full or partial flight number string, this method returns the first 100 flights matching that string. Please note this method was different in earlier versions. The older versions took an airline code and r...
[ "def", "get_flights", "(", "self", ",", "search_key", ")", ":", "# assume limit 100 to return first 100 of any wild card search", "url", "=", "AIRLINE_FLT_BASE", ".", "format", "(", "search_key", ",", "100", ")", "return", "self", ".", "_fr24", ".", "get_airline_fligh...
Get the flights for a particular airline. Given a full or partial flight number string, this method returns the first 100 flights matching that string. Please note this method was different in earlier versions. The older versions took an airline code and returned all scheduled flights for that airline...
[ "Get", "the", "flights", "for", "a", "particular", "airline", "." ]
train
https://github.com/supercoderz/pyflightdata/blob/2caf9f429288f9a171893d1b8377d0c6244541cc/pyflightdata/flightdata.py#L193-L215
supercoderz/pyflightdata
pyflightdata/flightdata.py
FlightData.get_flights_from_to
def get_flights_from_to(self, origin, destination): """Get the flights for a particular origin and destination. Given an origin and destination this method returns the upcoming scheduled flights between these two points. The data returned has the airline, airport and schedule information - this...
python
def get_flights_from_to(self, origin, destination): """Get the flights for a particular origin and destination. Given an origin and destination this method returns the upcoming scheduled flights between these two points. The data returned has the airline, airport and schedule information - this...
[ "def", "get_flights_from_to", "(", "self", ",", "origin", ",", "destination", ")", ":", "# assume limit 100 to return first 100 of any wild card search", "url", "=", "AIRLINE_FLT_BASE_POINTS", ".", "format", "(", "origin", ",", "destination", ")", "return", "self", ".",...
Get the flights for a particular origin and destination. Given an origin and destination this method returns the upcoming scheduled flights between these two points. The data returned has the airline, airport and schedule information - this is subject to change in future. Args: ori...
[ "Get", "the", "flights", "for", "a", "particular", "origin", "and", "destination", "." ]
train
https://github.com/supercoderz/pyflightdata/blob/2caf9f429288f9a171893d1b8377d0c6244541cc/pyflightdata/flightdata.py#L217-L239
supercoderz/pyflightdata
pyflightdata/flightdata.py
FlightData.get_airport_weather
def get_airport_weather(self, iata, page=1, limit=100): """Retrieve the weather at an airport Given the IATA code of an airport, this method returns the weather information. Args: iata (str): The IATA code for an airport, e.g. HYD page (int): Optional page number; for u...
python
def get_airport_weather(self, iata, page=1, limit=100): """Retrieve the weather at an airport Given the IATA code of an airport, this method returns the weather information. Args: iata (str): The IATA code for an airport, e.g. HYD page (int): Optional page number; for u...
[ "def", "get_airport_weather", "(", "self", ",", "iata", ",", "page", "=", "1", ",", "limit", "=", "100", ")", ":", "url", "=", "AIRPORT_DATA_BASE", ".", "format", "(", "iata", ",", "str", "(", "self", ".", "AUTH_TOKEN", ")", ",", "page", ",", "limit"...
Retrieve the weather at an airport Given the IATA code of an airport, this method returns the weather information. Args: iata (str): The IATA code for an airport, e.g. HYD page (int): Optional page number; for users who are on a plan with flightradar24 they can pass in higher p...
[ "Retrieve", "the", "weather", "at", "an", "airport" ]
train
https://github.com/supercoderz/pyflightdata/blob/2caf9f429288f9a171893d1b8377d0c6244541cc/pyflightdata/flightdata.py#L241-L271
supercoderz/pyflightdata
pyflightdata/flightdata.py
FlightData.get_airport_metars
def get_airport_metars(self, iata, page=1, limit=100): """Retrieve the metar data at the current time Given the IATA code of an airport, this method returns the metar information. Args: iata (str): The IATA code for an airport, e.g. HYD page (int): Optional page number;...
python
def get_airport_metars(self, iata, page=1, limit=100): """Retrieve the metar data at the current time Given the IATA code of an airport, this method returns the metar information. Args: iata (str): The IATA code for an airport, e.g. HYD page (int): Optional page number;...
[ "def", "get_airport_metars", "(", "self", ",", "iata", ",", "page", "=", "1", ",", "limit", "=", "100", ")", ":", "url", "=", "AIRPORT_DATA_BASE", ".", "format", "(", "iata", ",", "str", "(", "self", ".", "AUTH_TOKEN", ")", ",", "page", ",", "limit",...
Retrieve the metar data at the current time Given the IATA code of an airport, this method returns the metar information. Args: iata (str): The IATA code for an airport, e.g. HYD page (int): Optional page number; for users who are on a plan with flightradar24 they can pass in h...
[ "Retrieve", "the", "metar", "data", "at", "the", "current", "time" ]
train
https://github.com/supercoderz/pyflightdata/blob/2caf9f429288f9a171893d1b8377d0c6244541cc/pyflightdata/flightdata.py#L273-L297
supercoderz/pyflightdata
pyflightdata/flightdata.py
FlightData.get_airport_metars_hist
def get_airport_metars_hist(self, iata): """Retrieve the metar data for past 72 hours. The data will not be parsed to readable format. Given the IATA code of an airport, this method returns the metar information for last 72 hours. Args: iata (str): The IATA code for an airport, e.g...
python
def get_airport_metars_hist(self, iata): """Retrieve the metar data for past 72 hours. The data will not be parsed to readable format. Given the IATA code of an airport, this method returns the metar information for last 72 hours. Args: iata (str): The IATA code for an airport, e.g...
[ "def", "get_airport_metars_hist", "(", "self", ",", "iata", ")", ":", "url", "=", "AIRPORT_BASE", ".", "format", "(", "iata", ")", "+", "\"/weather\"", "return", "self", ".", "_fr24", ".", "get_airport_metars_hist", "(", "url", ")" ]
Retrieve the metar data for past 72 hours. The data will not be parsed to readable format. Given the IATA code of an airport, this method returns the metar information for last 72 hours. Args: iata (str): The IATA code for an airport, e.g. HYD Returns: The metar data f...
[ "Retrieve", "the", "metar", "data", "for", "past", "72", "hours", ".", "The", "data", "will", "not", "be", "parsed", "to", "readable", "format", "." ]
train
https://github.com/supercoderz/pyflightdata/blob/2caf9f429288f9a171893d1b8377d0c6244541cc/pyflightdata/flightdata.py#L299-L320
supercoderz/pyflightdata
pyflightdata/flightdata.py
FlightData.get_airport_stats
def get_airport_stats(self, iata, page=1, limit=100): """Retrieve the performance statistics at an airport Given the IATA code of an airport, this method returns the performance statistics for the airport. Args: iata (str): The IATA code for an airport, e.g. HYD page (i...
python
def get_airport_stats(self, iata, page=1, limit=100): """Retrieve the performance statistics at an airport Given the IATA code of an airport, this method returns the performance statistics for the airport. Args: iata (str): The IATA code for an airport, e.g. HYD page (i...
[ "def", "get_airport_stats", "(", "self", ",", "iata", ",", "page", "=", "1", ",", "limit", "=", "100", ")", ":", "url", "=", "AIRPORT_DATA_BASE", ".", "format", "(", "iata", ",", "str", "(", "self", ".", "AUTH_TOKEN", ")", ",", "page", ",", "limit", ...
Retrieve the performance statistics at an airport Given the IATA code of an airport, this method returns the performance statistics for the airport. Args: iata (str): The IATA code for an airport, e.g. HYD page (int): Optional page number; for users who are on a plan with fligh...
[ "Retrieve", "the", "performance", "statistics", "at", "an", "airport" ]
train
https://github.com/supercoderz/pyflightdata/blob/2caf9f429288f9a171893d1b8377d0c6244541cc/pyflightdata/flightdata.py#L322-L346
supercoderz/pyflightdata
pyflightdata/flightdata.py
FlightData.get_airport_details
def get_airport_details(self, iata, page=1, limit=100): """Retrieve the details of an airport Given the IATA code of an airport, this method returns the detailed information like lat lon, full name, URL, codes etc. Args: iata (str): The IATA code for an airport, e.g. HYD ...
python
def get_airport_details(self, iata, page=1, limit=100): """Retrieve the details of an airport Given the IATA code of an airport, this method returns the detailed information like lat lon, full name, URL, codes etc. Args: iata (str): The IATA code for an airport, e.g. HYD ...
[ "def", "get_airport_details", "(", "self", ",", "iata", ",", "page", "=", "1", ",", "limit", "=", "100", ")", ":", "url", "=", "AIRPORT_DATA_BASE", ".", "format", "(", "iata", ",", "str", "(", "self", ".", "AUTH_TOKEN", ")", ",", "page", ",", "limit"...
Retrieve the details of an airport Given the IATA code of an airport, this method returns the detailed information like lat lon, full name, URL, codes etc. Args: iata (str): The IATA code for an airport, e.g. HYD page (int): Optional page number; for users who are on a plan wit...
[ "Retrieve", "the", "details", "of", "an", "airport" ]
train
https://github.com/supercoderz/pyflightdata/blob/2caf9f429288f9a171893d1b8377d0c6244541cc/pyflightdata/flightdata.py#L348-L376
supercoderz/pyflightdata
pyflightdata/flightdata.py
FlightData.get_images_by_tail_number
def get_images_by_tail_number(self, tail_number, page=1, limit=100): """Fetch the images of a particular aircraft by its tail number. This method can be used to get the images of the aircraft. The images are in 3 sizes and you can use what suits your need. Args: tail_number (str): ...
python
def get_images_by_tail_number(self, tail_number, page=1, limit=100): """Fetch the images of a particular aircraft by its tail number. This method can be used to get the images of the aircraft. The images are in 3 sizes and you can use what suits your need. Args: tail_number (str): ...
[ "def", "get_images_by_tail_number", "(", "self", ",", "tail_number", ",", "page", "=", "1", ",", "limit", "=", "100", ")", ":", "url", "=", "REG_BASE", ".", "format", "(", "tail_number", ",", "str", "(", "self", ".", "AUTH_TOKEN", ")", ",", "page", ","...
Fetch the images of a particular aircraft by its tail number. This method can be used to get the images of the aircraft. The images are in 3 sizes and you can use what suits your need. Args: tail_number (str): The tail number, e.g. VT-ANL page (int): Optional page number; for u...
[ "Fetch", "the", "images", "of", "a", "particular", "aircraft", "by", "its", "tail", "number", "." ]
train
https://github.com/supercoderz/pyflightdata/blob/2caf9f429288f9a171893d1b8377d0c6244541cc/pyflightdata/flightdata.py#L482-L505
supercoderz/pyflightdata
pyflightdata/flightdata.py
FlightData.login
def login(self, email, password): """Login to the flightradar24 session The API currently uses flightradar24 as the primary data source. The site provides different levels of data based on user plans. For users who have signed up for a plan, this method allows to login with the credentials from...
python
def login(self, email, password): """Login to the flightradar24 session The API currently uses flightradar24 as the primary data source. The site provides different levels of data based on user plans. For users who have signed up for a plan, this method allows to login with the credentials from...
[ "def", "login", "(", "self", ",", "email", ",", "password", ")", ":", "response", "=", "FlightData", ".", "session", ".", "post", "(", "url", "=", "LOGIN_URL", ",", "data", "=", "{", "'email'", ":", "email", ",", "'password'", ":", "password", ",", "...
Login to the flightradar24 session The API currently uses flightradar24 as the primary data source. The site provides different levels of data based on user plans. For users who have signed up for a plan, this method allows to login with the credentials from flightradar24. The API obtains a tok...
[ "Login", "to", "the", "flightradar24", "session" ]
train
https://github.com/supercoderz/pyflightdata/blob/2caf9f429288f9a171893d1b8377d0c6244541cc/pyflightdata/flightdata.py#L507-L543
supercoderz/pyflightdata
pyflightdata/flightdata.py
FlightData.decode_metar
def decode_metar(self, metar): """ Simple method that decodes a given metar string. Args: metar (str): The metar data Returns: The metar data in readable format Example:: from pyflightdata import FlightData f=FlightData() ...
python
def decode_metar(self, metar): """ Simple method that decodes a given metar string. Args: metar (str): The metar data Returns: The metar data in readable format Example:: from pyflightdata import FlightData f=FlightData() ...
[ "def", "decode_metar", "(", "self", ",", "metar", ")", ":", "try", ":", "from", "metar", "import", "Metar", "except", ":", "return", "\"Unable to parse metars. Please install parser from https://github.com/tomp/python-metar.\"", "m", "=", "Metar", ".", "Metar", "(", "...
Simple method that decodes a given metar string. Args: metar (str): The metar data Returns: The metar data in readable format Example:: from pyflightdata import FlightData f=FlightData() f.decode_metar('WSSS 181030Z 04009KT 010V080 ...
[ "Simple", "method", "that", "decodes", "a", "given", "metar", "string", "." ]
train
https://github.com/supercoderz/pyflightdata/blob/2caf9f429288f9a171893d1b8377d0c6244541cc/pyflightdata/flightdata.py#L556-L577
robgolding/django-radius
radiusauth/backends/radius.py
RADIUSBackend._get_auth_packet
def _get_auth_packet(self, username, password, client): """ Get the pyrad authentication packet for the username/password and the given pyrad client. """ pkt = client.CreateAuthPacket(code=AccessRequest, User_Name=username) pkt["User-...
python
def _get_auth_packet(self, username, password, client): """ Get the pyrad authentication packet for the username/password and the given pyrad client. """ pkt = client.CreateAuthPacket(code=AccessRequest, User_Name=username) pkt["User-...
[ "def", "_get_auth_packet", "(", "self", ",", "username", ",", "password", ",", "client", ")", ":", "pkt", "=", "client", ".", "CreateAuthPacket", "(", "code", "=", "AccessRequest", ",", "User_Name", "=", "username", ")", "pkt", "[", "\"User-Password\"", "]",...
Get the pyrad authentication packet for the username/password and the given pyrad client.
[ "Get", "the", "pyrad", "authentication", "packet", "for", "the", "username", "/", "password", "and", "the", "given", "pyrad", "client", "." ]
train
https://github.com/robgolding/django-radius/blob/5b90f4ae4cbd680988197386d882491317e6b20c/radiusauth/backends/radius.py#L75-L86
robgolding/django-radius
radiusauth/backends/radius.py
RADIUSBackend._get_client
def _get_client(self, server): """ Get the pyrad client for a given server. RADIUS server is described by a 3-tuple: (<hostname>, <port>, <secret>). """ return Client( server=server[0], authport=server[1], secret=server[2], dict=sel...
python
def _get_client(self, server): """ Get the pyrad client for a given server. RADIUS server is described by a 3-tuple: (<hostname>, <port>, <secret>). """ return Client( server=server[0], authport=server[1], secret=server[2], dict=sel...
[ "def", "_get_client", "(", "self", ",", "server", ")", ":", "return", "Client", "(", "server", "=", "server", "[", "0", "]", ",", "authport", "=", "server", "[", "1", "]", ",", "secret", "=", "server", "[", "2", "]", ",", "dict", "=", "self", "."...
Get the pyrad client for a given server. RADIUS server is described by a 3-tuple: (<hostname>, <port>, <secret>).
[ "Get", "the", "pyrad", "client", "for", "a", "given", "server", ".", "RADIUS", "server", "is", "described", "by", "a", "3", "-", "tuple", ":", "(", "<hostname", ">", "<port", ">", "<secret", ">", ")", "." ]
train
https://github.com/robgolding/django-radius/blob/5b90f4ae4cbd680988197386d882491317e6b20c/radiusauth/backends/radius.py#L88-L98
robgolding/django-radius
radiusauth/backends/radius.py
RADIUSBackend._perform_radius_auth
def _perform_radius_auth(self, client, packet): """ Perform the actual radius authentication by passing the given packet to the server which `client` is bound to. Returns True or False depending on whether the user is authenticated successfully. """ try: ...
python
def _perform_radius_auth(self, client, packet): """ Perform the actual radius authentication by passing the given packet to the server which `client` is bound to. Returns True or False depending on whether the user is authenticated successfully. """ try: ...
[ "def", "_perform_radius_auth", "(", "self", ",", "client", ",", "packet", ")", ":", "try", ":", "reply", "=", "client", ".", "SendPacket", "(", "packet", ")", "except", "Timeout", "as", "e", ":", "logging", ".", "error", "(", "\"RADIUS timeout occurred conta...
Perform the actual radius authentication by passing the given packet to the server which `client` is bound to. Returns True or False depending on whether the user is authenticated successfully.
[ "Perform", "the", "actual", "radius", "authentication", "by", "passing", "the", "given", "packet", "to", "the", "server", "which", "client", "is", "bound", "to", ".", "Returns", "True", "or", "False", "depending", "on", "whether", "the", "user", "is", "authe...
train
https://github.com/robgolding/django-radius/blob/5b90f4ae4cbd680988197386d882491317e6b20c/radiusauth/backends/radius.py#L110-L138
robgolding/django-radius
radiusauth/backends/radius.py
RADIUSBackend._radius_auth
def _radius_auth(self, server, username, password): """ Authenticate the given username/password against the RADIUS server described by `server`. """ client = self._get_client(server) packet = self._get_auth_packet(username, password, client) return self._perform_...
python
def _radius_auth(self, server, username, password): """ Authenticate the given username/password against the RADIUS server described by `server`. """ client = self._get_client(server) packet = self._get_auth_packet(username, password, client) return self._perform_...
[ "def", "_radius_auth", "(", "self", ",", "server", ",", "username", ",", "password", ")", ":", "client", "=", "self", ".", "_get_client", "(", "server", ")", "packet", "=", "self", ".", "_get_auth_packet", "(", "username", ",", "password", ",", "client", ...
Authenticate the given username/password against the RADIUS server described by `server`.
[ "Authenticate", "the", "given", "username", "/", "password", "against", "the", "RADIUS", "server", "described", "by", "server", "." ]
train
https://github.com/robgolding/django-radius/blob/5b90f4ae4cbd680988197386d882491317e6b20c/radiusauth/backends/radius.py#L140-L147
robgolding/django-radius
radiusauth/backends/radius.py
RADIUSBackend.get_django_user
def get_django_user(self, username, password=None): """ Get the Django user with the given username, or create one if it doesn't already exist. If `password` is given, then set the user's password to that (regardless of whether the user was created or not). """ try: ...
python
def get_django_user(self, username, password=None): """ Get the Django user with the given username, or create one if it doesn't already exist. If `password` is given, then set the user's password to that (regardless of whether the user was created or not). """ try: ...
[ "def", "get_django_user", "(", "self", ",", "username", ",", "password", "=", "None", ")", ":", "try", ":", "user", "=", "User", ".", "objects", ".", "get", "(", "username", "=", "username", ")", "except", "User", ".", "DoesNotExist", ":", "user", "=",...
Get the Django user with the given username, or create one if it doesn't already exist. If `password` is given, then set the user's password to that (regardless of whether the user was created or not).
[ "Get", "the", "Django", "user", "with", "the", "given", "username", "or", "create", "one", "if", "it", "doesn", "t", "already", "exist", ".", "If", "password", "is", "given", "then", "set", "the", "user", "s", "password", "to", "that", "(", "regardless",...
train
https://github.com/robgolding/django-radius/blob/5b90f4ae4cbd680988197386d882491317e6b20c/radiusauth/backends/radius.py#L149-L164
robgolding/django-radius
radiusauth/backends/radius.py
RADIUSBackend.authenticate
def authenticate(self, request, username=None, password=None): """ Check credentials against RADIUS server and return a User object or None. """ if isinstance(username, basestring): username = username.encode('utf-8') if isinstance(password, basestring): ...
python
def authenticate(self, request, username=None, password=None): """ Check credentials against RADIUS server and return a User object or None. """ if isinstance(username, basestring): username = username.encode('utf-8') if isinstance(password, basestring): ...
[ "def", "authenticate", "(", "self", ",", "request", ",", "username", "=", "None", ",", "password", "=", "None", ")", ":", "if", "isinstance", "(", "username", ",", "basestring", ")", ":", "username", "=", "username", ".", "encode", "(", "'utf-8'", ")", ...
Check credentials against RADIUS server and return a User object or None.
[ "Check", "credentials", "against", "RADIUS", "server", "and", "return", "a", "User", "object", "or", "None", "." ]
train
https://github.com/robgolding/django-radius/blob/5b90f4ae4cbd680988197386d882491317e6b20c/radiusauth/backends/radius.py#L166-L183
robgolding/django-radius
radiusauth/backends/radius.py
RADIUSRealmBackend.authenticate
def authenticate(self, request, username=None, password=None, realm=None): """ Check credentials against the RADIUS server identified by `realm` and return a User object or None. If no argument is supplied, Django will skip this backend and try the next one (as a TypeError will be raised...
python
def authenticate(self, request, username=None, password=None, realm=None): """ Check credentials against the RADIUS server identified by `realm` and return a User object or None. If no argument is supplied, Django will skip this backend and try the next one (as a TypeError will be raised...
[ "def", "authenticate", "(", "self", ",", "request", ",", "username", "=", "None", ",", "password", "=", "None", ",", "realm", "=", "None", ")", ":", "if", "isinstance", "(", "username", ",", "basestring", ")", ":", "username", "=", "username", ".", "en...
Check credentials against the RADIUS server identified by `realm` and return a User object or None. If no argument is supplied, Django will skip this backend and try the next one (as a TypeError will be raised and caught).
[ "Check", "credentials", "against", "the", "RADIUS", "server", "identified", "by", "realm", "and", "return", "a", "User", "object", "or", "None", ".", "If", "no", "argument", "is", "supplied", "Django", "will", "skip", "this", "backend", "and", "try", "the", ...
train
https://github.com/robgolding/django-radius/blob/5b90f4ae4cbd680988197386d882491317e6b20c/radiusauth/backends/radius.py#L229-L253
smartfile/django-transfer
django_transfer/__init__.py
ProxyUploadedFile.move
def move(self, dst): "Closes then moves the file to dst." self.close() shutil.move(self.path, dst)
python
def move(self, dst): "Closes then moves the file to dst." self.close() shutil.move(self.path, dst)
[ "def", "move", "(", "self", ",", "dst", ")", ":", "self", ".", "close", "(", ")", "shutil", ".", "move", "(", "self", ".", "path", ",", "dst", ")" ]
Closes then moves the file to dst.
[ "Closes", "then", "moves", "the", "file", "to", "dst", "." ]
train
https://github.com/smartfile/django-transfer/blob/65ef60e011c1b98d7f5a195debd81b3efde897dd/django_transfer/__init__.py#L110-L113
dwkim78/upsilon
upsilon/utils/utils.py
sigma_clipping
def sigma_clipping(date, mag, err, threshold=3, iteration=1): """ Remove any fluctuated data points by magnitudes. Parameters ---------- date : array_like An array of dates. mag : array_like An array of magnitudes. err : array_like An array of magnitude errors. t...
python
def sigma_clipping(date, mag, err, threshold=3, iteration=1): """ Remove any fluctuated data points by magnitudes. Parameters ---------- date : array_like An array of dates. mag : array_like An array of magnitudes. err : array_like An array of magnitude errors. t...
[ "def", "sigma_clipping", "(", "date", ",", "mag", ",", "err", ",", "threshold", "=", "3", ",", "iteration", "=", "1", ")", ":", "# Check length.", "if", "(", "len", "(", "date", ")", "!=", "len", "(", "mag", ")", ")", "or", "(", "len", "(", "date...
Remove any fluctuated data points by magnitudes. Parameters ---------- date : array_like An array of dates. mag : array_like An array of magnitudes. err : array_like An array of magnitude errors. threshold : float, optional Threshold for sigma-clipping. itera...
[ "Remove", "any", "fluctuated", "data", "points", "by", "magnitudes", "." ]
train
https://github.com/dwkim78/upsilon/blob/5f381453f26582ef56e62fb8fed7317ce67861af/upsilon/utils/utils.py#L4-L47
rix0rrr/gcl
gcl/schema.py
from_spec
def from_spec(spec): """Return a schema object from a spec. A spec is either a string for a scalar type, or a list of 0 or 1 specs, or a dictionary with two elements: {'fields': { ... }, required: [...]}. """ if spec == '': return any_schema if framework.is_str(spec): # Scalar type if spec not...
python
def from_spec(spec): """Return a schema object from a spec. A spec is either a string for a scalar type, or a list of 0 or 1 specs, or a dictionary with two elements: {'fields': { ... }, required: [...]}. """ if spec == '': return any_schema if framework.is_str(spec): # Scalar type if spec not...
[ "def", "from_spec", "(", "spec", ")", ":", "if", "spec", "==", "''", ":", "return", "any_schema", "if", "framework", ".", "is_str", "(", "spec", ")", ":", "# Scalar type", "if", "spec", "not", "in", "SCALAR_TYPES", ":", "raise", "exceptions", ".", "Schem...
Return a schema object from a spec. A spec is either a string for a scalar type, or a list of 0 or 1 specs, or a dictionary with two elements: {'fields': { ... }, required: [...]}.
[ "Return", "a", "schema", "object", "from", "a", "spec", "." ]
train
https://github.com/rix0rrr/gcl/blob/4e3bccc978a9c60aaaffd20f6f291c4d23775cdf/gcl/schema.py#L178-L199
rix0rrr/gcl
gcl/schema.py
validate
def validate(obj, schema): """Validate an object according to its own AND an externally imposed schema.""" if not framework.EvaluationContext.current().validate: # Short circuit evaluation when disabled return obj # Validate returned object according to its own schema if hasattr(obj, 'tuple_schema'): ...
python
def validate(obj, schema): """Validate an object according to its own AND an externally imposed schema.""" if not framework.EvaluationContext.current().validate: # Short circuit evaluation when disabled return obj # Validate returned object according to its own schema if hasattr(obj, 'tuple_schema'): ...
[ "def", "validate", "(", "obj", ",", "schema", ")", ":", "if", "not", "framework", ".", "EvaluationContext", ".", "current", "(", ")", ".", "validate", ":", "# Short circuit evaluation when disabled", "return", "obj", "# Validate returned object according to its own sche...
Validate an object according to its own AND an externally imposed schema.
[ "Validate", "an", "object", "according", "to", "its", "own", "AND", "an", "externally", "imposed", "schema", "." ]
train
https://github.com/rix0rrr/gcl/blob/4e3bccc978a9c60aaaffd20f6f291c4d23775cdf/gcl/schema.py#L208-L220
rix0rrr/gcl
gcl/schema.py
attach
def attach(obj, schema): """Attach the given schema to the given object.""" # We have a silly exception for lists, since they have no 'attach_schema' # method, and I don't feel like making a subclass for List just to add it. # So, we recursively search the list for tuples and attach the schema in # there. ...
python
def attach(obj, schema): """Attach the given schema to the given object.""" # We have a silly exception for lists, since they have no 'attach_schema' # method, and I don't feel like making a subclass for List just to add it. # So, we recursively search the list for tuples and attach the schema in # there. ...
[ "def", "attach", "(", "obj", ",", "schema", ")", ":", "# We have a silly exception for lists, since they have no 'attach_schema'", "# method, and I don't feel like making a subclass for List just to add it.", "# So, we recursively search the list for tuples and attach the schema in", "# there....
Attach the given schema to the given object.
[ "Attach", "the", "given", "schema", "to", "the", "given", "object", "." ]
train
https://github.com/rix0rrr/gcl/blob/4e3bccc978a9c60aaaffd20f6f291c4d23775cdf/gcl/schema.py#L223-L236
dwkim78/upsilon
upsilon/extract_features/feature_set.py
get_feature_set_all
def get_feature_set_all(): """ Return a list of entire features. A set of entire features regardless of being used to train a model or predict a class. Returns ------- feature_names : list A list of features' names. """ features = get_feature_set() features.append('cu...
python
def get_feature_set_all(): """ Return a list of entire features. A set of entire features regardless of being used to train a model or predict a class. Returns ------- feature_names : list A list of features' names. """ features = get_feature_set() features.append('cu...
[ "def", "get_feature_set_all", "(", ")", ":", "features", "=", "get_feature_set", "(", ")", "features", ".", "append", "(", "'cusum'", ")", "features", ".", "append", "(", "'eta'", ")", "features", ".", "append", "(", "'n_points'", ")", "features", ".", "ap...
Return a list of entire features. A set of entire features regardless of being used to train a model or predict a class. Returns ------- feature_names : list A list of features' names.
[ "Return", "a", "list", "of", "entire", "features", "." ]
train
https://github.com/dwkim78/upsilon/blob/5f381453f26582ef56e62fb8fed7317ce67861af/upsilon/extract_features/feature_set.py#L23-L49
hannes-brt/hebel
hebel/models/neural_net.py
NeuralNet.parameters
def parameters(self): """ A property that returns all of the model's parameters. """ parameters = [] for hl in self.hidden_layers: parameters.extend(hl.parameters) parameters.extend(self.top_layer.parameters) return parameters
python
def parameters(self): """ A property that returns all of the model's parameters. """ parameters = [] for hl in self.hidden_layers: parameters.extend(hl.parameters) parameters.extend(self.top_layer.parameters) return parameters
[ "def", "parameters", "(", "self", ")", ":", "parameters", "=", "[", "]", "for", "hl", "in", "self", ".", "hidden_layers", ":", "parameters", ".", "extend", "(", "hl", ".", "parameters", ")", "parameters", ".", "extend", "(", "self", ".", "top_layer", "...
A property that returns all of the model's parameters.
[ "A", "property", "that", "returns", "all", "of", "the", "model", "s", "parameters", "." ]
train
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/models/neural_net.py#L185-L191
hannes-brt/hebel
hebel/models/neural_net.py
NeuralNet.parameters
def parameters(self, value): """ Used to set all of the model's parameters to new values. **Parameters:** value : array_like New values for the model parameters. Must be of length ``self.n_parameters``. """ if len(value) != self.n_parameters: ...
python
def parameters(self, value): """ Used to set all of the model's parameters to new values. **Parameters:** value : array_like New values for the model parameters. Must be of length ``self.n_parameters``. """ if len(value) != self.n_parameters: ...
[ "def", "parameters", "(", "self", ",", "value", ")", ":", "if", "len", "(", "value", ")", "!=", "self", ".", "n_parameters", ":", "raise", "ValueError", "(", "\"Incorrect length of parameter vector. \"", "\"Model has %d parameters, but got %d\"", "%", "(", "self", ...
Used to set all of the model's parameters to new values. **Parameters:** value : array_like New values for the model parameters. Must be of length ``self.n_parameters``.
[ "Used", "to", "set", "all", "of", "the", "model", "s", "parameters", "to", "new", "values", "." ]
train
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/models/neural_net.py#L194-L214
hannes-brt/hebel
hebel/models/neural_net.py
NeuralNet.checksum
def checksum(self): """ Returns an MD5 digest of the model. This can be used to easily identify whether two models have the same architecture. """ m = md5() for hl in self.hidden_layers: m.update(str(hl.architecture)) m.update(str(self.top_la...
python
def checksum(self): """ Returns an MD5 digest of the model. This can be used to easily identify whether two models have the same architecture. """ m = md5() for hl in self.hidden_layers: m.update(str(hl.architecture)) m.update(str(self.top_la...
[ "def", "checksum", "(", "self", ")", ":", "m", "=", "md5", "(", ")", "for", "hl", "in", "self", ".", "hidden_layers", ":", "m", ".", "update", "(", "str", "(", "hl", ".", "architecture", ")", ")", "m", ".", "update", "(", "str", "(", "self", "....
Returns an MD5 digest of the model. This can be used to easily identify whether two models have the same architecture.
[ "Returns", "an", "MD5", "digest", "of", "the", "model", "." ]
train
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/models/neural_net.py#L243-L254
hannes-brt/hebel
hebel/models/neural_net.py
NeuralNet.evaluate
def evaluate(self, input_data, targets, return_cache=False, prediction=True): """ Evaluate the loss function without computing gradients. **Parameters:** input_data : GPUArray Data to evaluate targets: GPUArray Targets return_cache : b...
python
def evaluate(self, input_data, targets, return_cache=False, prediction=True): """ Evaluate the loss function without computing gradients. **Parameters:** input_data : GPUArray Data to evaluate targets: GPUArray Targets return_cache : b...
[ "def", "evaluate", "(", "self", ",", "input_data", ",", "targets", ",", "return_cache", "=", "False", ",", "prediction", "=", "True", ")", ":", "# Forward pass", "activations", ",", "hidden_cache", "=", "self", ".", "feed_forward", "(", "input_data", ",", "r...
Evaluate the loss function without computing gradients. **Parameters:** input_data : GPUArray Data to evaluate targets: GPUArray Targets return_cache : bool, optional Whether to return intermediary variables from the computation and the...
[ "Evaluate", "the", "loss", "function", "without", "computing", "gradients", "." ]
train
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/models/neural_net.py#L256-L308
hannes-brt/hebel
hebel/models/neural_net.py
NeuralNet.training_pass
def training_pass(self, input_data, targets): """ Perform a full forward and backward pass through the model. **Parameters:** input_data : GPUArray Data to train the model with. targets : GPUArray Training targets. **Returns:** loss : float ...
python
def training_pass(self, input_data, targets): """ Perform a full forward and backward pass through the model. **Parameters:** input_data : GPUArray Data to train the model with. targets : GPUArray Training targets. **Returns:** loss : float ...
[ "def", "training_pass", "(", "self", ",", "input_data", ",", "targets", ")", ":", "# Forward pass", "loss", ",", "hidden_cache", ",", "logistic_cache", "=", "self", ".", "evaluate", "(", "input_data", ",", "targets", ",", "return_cache", "=", "True", ",", "p...
Perform a full forward and backward pass through the model. **Parameters:** input_data : GPUArray Data to train the model with. targets : GPUArray Training targets. **Returns:** loss : float Value of loss function as evaluated on the data ...
[ "Perform", "a", "full", "forward", "and", "backward", "pass", "through", "the", "model", "." ]
train
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/models/neural_net.py#L310-L359
hannes-brt/hebel
hebel/models/neural_net.py
NeuralNet.feed_forward
def feed_forward(self, input_data, return_cache=False, prediction=True): """ Run data forward through the model. **Parameters:** input_data : GPUArray Data to run through the model. return_cache : bool, optional Whether to return the intermediary results. ...
python
def feed_forward(self, input_data, return_cache=False, prediction=True): """ Run data forward through the model. **Parameters:** input_data : GPUArray Data to run through the model. return_cache : bool, optional Whether to return the intermediary results. ...
[ "def", "feed_forward", "(", "self", ",", "input_data", ",", "return_cache", "=", "False", ",", "prediction", "=", "True", ")", ":", "hidden_cache", "=", "None", "# Create variable in case there are no hidden layers", "if", "self", ".", "hidden_layers", ":", "# Forwa...
Run data forward through the model. **Parameters:** input_data : GPUArray Data to run through the model. return_cache : bool, optional Whether to return the intermediary results. prediction : bool, optional Whether to run in prediction mode. Only r...
[ "Run", "data", "forward", "through", "the", "model", "." ]
train
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/models/neural_net.py#L399-L448
dwkim78/upsilon
upsilon/extract_features/extract_features.py
ExtractFeatures.shallow_run
def shallow_run(self): """Derive not-period-based features.""" # Number of data points self.n_points = len(self.date) # Weight calculation. # All zero values. if not self.err.any(): self.err = np.ones(len(self.mag)) * np.std(self.mag) # Some zero valu...
python
def shallow_run(self): """Derive not-period-based features.""" # Number of data points self.n_points = len(self.date) # Weight calculation. # All zero values. if not self.err.any(): self.err = np.ones(len(self.mag)) * np.std(self.mag) # Some zero valu...
[ "def", "shallow_run", "(", "self", ")", ":", "# Number of data points", "self", ".", "n_points", "=", "len", "(", "self", ".", "date", ")", "# Weight calculation.", "# All zero values.", "if", "not", "self", ".", "err", ".", "any", "(", ")", ":", "self", "...
Derive not-period-based features.
[ "Derive", "not", "-", "period", "-", "based", "features", "." ]
train
https://github.com/dwkim78/upsilon/blob/5f381453f26582ef56e62fb8fed7317ce67861af/upsilon/extract_features/extract_features.py#L86-L139
dwkim78/upsilon
upsilon/extract_features/extract_features.py
ExtractFeatures.deep_run
def deep_run(self): """Derive period-based features.""" # Lomb-Scargle period finding. self.get_period_LS(self.date, self.mag, self.n_threads, self.min_period) # Features based on a phase-folded light curve # such as Eta, slope-percentile, etc. # Should be called after t...
python
def deep_run(self): """Derive period-based features.""" # Lomb-Scargle period finding. self.get_period_LS(self.date, self.mag, self.n_threads, self.min_period) # Features based on a phase-folded light curve # such as Eta, slope-percentile, etc. # Should be called after t...
[ "def", "deep_run", "(", "self", ")", ":", "# Lomb-Scargle period finding.", "self", ".", "get_period_LS", "(", "self", ".", "date", ",", "self", ".", "mag", ",", "self", ".", "n_threads", ",", "self", ".", "min_period", ")", "# Features based on a phase-folded l...
Derive period-based features.
[ "Derive", "period", "-", "based", "features", "." ]
train
https://github.com/dwkim78/upsilon/blob/5f381453f26582ef56e62fb8fed7317ce67861af/upsilon/extract_features/extract_features.py#L141-L166
dwkim78/upsilon
upsilon/extract_features/extract_features.py
ExtractFeatures.get_period_LS
def get_period_LS(self, date, mag, n_threads, min_period): """ Period finding using the Lomb-Scargle algorithm. Finding two periods. The second period is estimated after whitening the first period. Calculating various other features as well using derived periods. Parame...
python
def get_period_LS(self, date, mag, n_threads, min_period): """ Period finding using the Lomb-Scargle algorithm. Finding two periods. The second period is estimated after whitening the first period. Calculating various other features as well using derived periods. Parame...
[ "def", "get_period_LS", "(", "self", ",", "date", ",", "mag", ",", "n_threads", ",", "min_period", ")", ":", "# DO NOT CHANGE THESE PARAMETERS.", "oversampling", "=", "3.", "hifac", "=", "int", "(", "(", "max", "(", "date", ")", "-", "min", "(", "date", ...
Period finding using the Lomb-Scargle algorithm. Finding two periods. The second period is estimated after whitening the first period. Calculating various other features as well using derived periods. Parameters ---------- date : array_like An array of obser...
[ "Period", "finding", "using", "the", "Lomb", "-", "Scargle", "algorithm", "." ]
train
https://github.com/dwkim78/upsilon/blob/5f381453f26582ef56e62fb8fed7317ce67861af/upsilon/extract_features/extract_features.py#L168-L273
dwkim78/upsilon
upsilon/extract_features/extract_features.py
ExtractFeatures.get_period_uncertainty
def get_period_uncertainty(self, fx, fy, jmax, fx_width=100): """ Get uncertainty of a period. The uncertainty is defined as the half width of the frequencies around the peak, that becomes lower than average + standard deviation of the power spectrum. Since we may not h...
python
def get_period_uncertainty(self, fx, fy, jmax, fx_width=100): """ Get uncertainty of a period. The uncertainty is defined as the half width of the frequencies around the peak, that becomes lower than average + standard deviation of the power spectrum. Since we may not h...
[ "def", "get_period_uncertainty", "(", "self", ",", "fx", ",", "fy", ",", "jmax", ",", "fx_width", "=", "100", ")", ":", "# Get subset", "start_index", "=", "jmax", "-", "fx_width", "end_index", "=", "jmax", "+", "fx_width", "if", "start_index", "<", "0", ...
Get uncertainty of a period. The uncertainty is defined as the half width of the frequencies around the peak, that becomes lower than average + standard deviation of the power spectrum. Since we may not have fine resolution around the peak, we do not assume it is gaussian. So, ...
[ "Get", "uncertainty", "of", "a", "period", "." ]
train
https://github.com/dwkim78/upsilon/blob/5f381453f26582ef56e62fb8fed7317ce67861af/upsilon/extract_features/extract_features.py#L275-L340
dwkim78/upsilon
upsilon/extract_features/extract_features.py
ExtractFeatures.residuals
def residuals(self, pars, x, y, order): """ Residual of Fourier Series. Parameters ---------- pars : array_like Fourier series parameters. x : array_like An array of date. y : array_like An array of true values to fit. ...
python
def residuals(self, pars, x, y, order): """ Residual of Fourier Series. Parameters ---------- pars : array_like Fourier series parameters. x : array_like An array of date. y : array_like An array of true values to fit. ...
[ "def", "residuals", "(", "self", ",", "pars", ",", "x", ",", "y", ",", "order", ")", ":", "return", "y", "-", "self", ".", "fourier_series", "(", "pars", ",", "x", ",", "order", ")" ]
Residual of Fourier Series. Parameters ---------- pars : array_like Fourier series parameters. x : array_like An array of date. y : array_like An array of true values to fit. order : int An order of Fourier Series.
[ "Residual", "of", "Fourier", "Series", "." ]
train
https://github.com/dwkim78/upsilon/blob/5f381453f26582ef56e62fb8fed7317ce67861af/upsilon/extract_features/extract_features.py#L342-L358
dwkim78/upsilon
upsilon/extract_features/extract_features.py
ExtractFeatures.fourier_series
def fourier_series(self, pars, x, order): """ Function to fit Fourier Series. Parameters ---------- x : array_like An array of date divided by period. It doesn't need to be sorted. pars : array_like Fourier series parameters. order : int ...
python
def fourier_series(self, pars, x, order): """ Function to fit Fourier Series. Parameters ---------- x : array_like An array of date divided by period. It doesn't need to be sorted. pars : array_like Fourier series parameters. order : int ...
[ "def", "fourier_series", "(", "self", ",", "pars", ",", "x", ",", "order", ")", ":", "sum", "=", "pars", "[", "0", "]", "for", "i", "in", "range", "(", "order", ")", ":", "sum", "+=", "pars", "[", "i", "*", "2", "+", "1", "]", "*", "np", "....
Function to fit Fourier Series. Parameters ---------- x : array_like An array of date divided by period. It doesn't need to be sorted. pars : array_like Fourier series parameters. order : int An order of Fourier series.
[ "Function", "to", "fit", "Fourier", "Series", "." ]
train
https://github.com/dwkim78/upsilon/blob/5f381453f26582ef56e62fb8fed7317ce67861af/upsilon/extract_features/extract_features.py#L360-L379
dwkim78/upsilon
upsilon/extract_features/extract_features.py
ExtractFeatures.get_stetson_k
def get_stetson_k(self, mag, avg, err): """ Return Stetson K feature. Parameters ---------- mag : array_like An array of magnitude. avg : float An average value of magnitudes. err : array_like An array of magnitude errors. ...
python
def get_stetson_k(self, mag, avg, err): """ Return Stetson K feature. Parameters ---------- mag : array_like An array of magnitude. avg : float An average value of magnitudes. err : array_like An array of magnitude errors. ...
[ "def", "get_stetson_k", "(", "self", ",", "mag", ",", "avg", ",", "err", ")", ":", "residual", "=", "(", "mag", "-", "avg", ")", "/", "err", "stetson_k", "=", "np", ".", "sum", "(", "np", ".", "fabs", "(", "residual", ")", ")", "/", "np", ".", ...
Return Stetson K feature. Parameters ---------- mag : array_like An array of magnitude. avg : float An average value of magnitudes. err : array_like An array of magnitude errors. Returns ------- stetson_k : float ...
[ "Return", "Stetson", "K", "feature", "." ]
train
https://github.com/dwkim78/upsilon/blob/5f381453f26582ef56e62fb8fed7317ce67861af/upsilon/extract_features/extract_features.py#L381-L404