partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
apply_threshold
This function performs the thresholding of the values in array in1 based on the estimated standard deviation given by the MAD (median absolute deviation) estimator about zero. INPUTS: in1 (no default): The array which is to be thresholded. sigma_level (no default): The number of est...
pymoresane/iuwt_toolbox.py
def apply_threshold(in1, threshold, sigma_level=4): """ This function performs the thresholding of the values in array in1 based on the estimated standard deviation given by the MAD (median absolute deviation) estimator about zero. INPUTS: in1 (no default): The array which is to be th...
def apply_threshold(in1, threshold, sigma_level=4): """ This function performs the thresholding of the values in array in1 based on the estimated standard deviation given by the MAD (median absolute deviation) estimator about zero. INPUTS: in1 (no default): The array which is to be th...
[ "This", "function", "performs", "the", "thresholding", "of", "the", "values", "in", "array", "in1", "based", "on", "the", "estimated", "standard", "deviation", "given", "by", "the", "MAD", "(", "median", "absolute", "deviation", ")", "estimator", "about", "zer...
ratt-ru/PyMORESANE
python
https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/iuwt_toolbox.py#L50-L75
[ "def", "apply_threshold", "(", "in1", ",", "threshold", ",", "sigma_level", "=", "4", ")", ":", "out1", "=", "np", ".", "empty_like", "(", "in1", ")", "# The conditional here ensures that the function works even when only one scale is considered. Both cases are the", "# sam...
b024591ad0bbb69320d08841f28a2c27f62ae1af
train
source_extraction
Convenience function for allocating work to cpu or gpu, depending on the selected mode. INPUTS: in1 (no default): Array containing the wavelet decomposition. tolerance (no default): Percentage of maximum coefficient at which objects are deemed significant. mode (default="cpu"):Mode...
pymoresane/iuwt_toolbox.py
def source_extraction(in1, tolerance, mode="cpu", store_on_gpu=False, neg_comp=False): """ Convenience function for allocating work to cpu or gpu, depending on the selected mode. INPUTS: in1 (no default): Array containing the wavelet decomposition. tolerance (no de...
def source_extraction(in1, tolerance, mode="cpu", store_on_gpu=False, neg_comp=False): """ Convenience function for allocating work to cpu or gpu, depending on the selected mode. INPUTS: in1 (no default): Array containing the wavelet decomposition. tolerance (no de...
[ "Convenience", "function", "for", "allocating", "work", "to", "cpu", "or", "gpu", "depending", "on", "the", "selected", "mode", "." ]
ratt-ru/PyMORESANE
python
https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/iuwt_toolbox.py#L77-L94
[ "def", "source_extraction", "(", "in1", ",", "tolerance", ",", "mode", "=", "\"cpu\"", ",", "store_on_gpu", "=", "False", ",", "neg_comp", "=", "False", ")", ":", "if", "mode", "==", "\"cpu\"", ":", "return", "cpu_source_extraction", "(", "in1", ",", "tole...
b024591ad0bbb69320d08841f28a2c27f62ae1af
train
cpu_source_extraction
The following function determines connectivity within a given wavelet decomposition. These connected and labelled structures are thresholded to within some tolerance of the maximum coefficient at the scale. This determines whether on not an object is to be considered as significant. Significant objects are extr...
pymoresane/iuwt_toolbox.py
def cpu_source_extraction(in1, tolerance, neg_comp): """ The following function determines connectivity within a given wavelet decomposition. These connected and labelled structures are thresholded to within some tolerance of the maximum coefficient at the scale. This determines whether on not an object...
def cpu_source_extraction(in1, tolerance, neg_comp): """ The following function determines connectivity within a given wavelet decomposition. These connected and labelled structures are thresholded to within some tolerance of the maximum coefficient at the scale. This determines whether on not an object...
[ "The", "following", "function", "determines", "connectivity", "within", "a", "given", "wavelet", "decomposition", ".", "These", "connected", "and", "labelled", "structures", "are", "thresholded", "to", "within", "some", "tolerance", "of", "the", "maximum", "coeffici...
ratt-ru/PyMORESANE
python
https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/iuwt_toolbox.py#L97-L154
[ "def", "cpu_source_extraction", "(", "in1", ",", "tolerance", ",", "neg_comp", ")", ":", "# The following initialises some variables for storing the labelled image and the number of labels. The per scale", "# maxima are also initialised here.", "scale_maxima", "=", "np", ".", "empty"...
b024591ad0bbb69320d08841f28a2c27f62ae1af
train
gpu_source_extraction
The following function determines connectivity within a given wavelet decomposition. These connected and labelled structures are thresholded to within some tolerance of the maximum coefficient at the scale. This determines whether on not an object is to be considered as significant. Significant objects are extr...
pymoresane/iuwt_toolbox.py
def gpu_source_extraction(in1, tolerance, store_on_gpu, neg_comp): """ The following function determines connectivity within a given wavelet decomposition. These connected and labelled structures are thresholded to within some tolerance of the maximum coefficient at the scale. This determines whether on...
def gpu_source_extraction(in1, tolerance, store_on_gpu, neg_comp): """ The following function determines connectivity within a given wavelet decomposition. These connected and labelled structures are thresholded to within some tolerance of the maximum coefficient at the scale. This determines whether on...
[ "The", "following", "function", "determines", "connectivity", "within", "a", "given", "wavelet", "decomposition", ".", "These", "connected", "and", "labelled", "structures", "are", "thresholded", "to", "within", "some", "tolerance", "of", "the", "maximum", "coeffici...
ratt-ru/PyMORESANE
python
https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/iuwt_toolbox.py#L156-L290
[ "def", "gpu_source_extraction", "(", "in1", ",", "tolerance", ",", "store_on_gpu", ",", "neg_comp", ")", ":", "# The following are pycuda kernels which are executed on the gpu. Specifically, these both perform thresholding", "# operations. The gpu is much faster at this on large arrays due...
b024591ad0bbb69320d08841f28a2c27f62ae1af
train
snr_ratio
The following function simply calculates the signal to noise ratio between two signals. INPUTS: in1 (no default): Array containing values for signal 1. in2 (no default): Array containing values for signal 2. OUTPUTS: out1 The ratio of the signal to noise ...
pymoresane/iuwt_toolbox.py
def snr_ratio(in1, in2): """ The following function simply calculates the signal to noise ratio between two signals. INPUTS: in1 (no default): Array containing values for signal 1. in2 (no default): Array containing values for signal 2. OUTPUTS: out1 ...
def snr_ratio(in1, in2): """ The following function simply calculates the signal to noise ratio between two signals. INPUTS: in1 (no default): Array containing values for signal 1. in2 (no default): Array containing values for signal 2. OUTPUTS: out1 ...
[ "The", "following", "function", "simply", "calculates", "the", "signal", "to", "noise", "ratio", "between", "two", "signals", "." ]
ratt-ru/PyMORESANE
python
https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/iuwt_toolbox.py#L292-L306
[ "def", "snr_ratio", "(", "in1", ",", "in2", ")", ":", "out1", "=", "20", "*", "(", "np", ".", "log10", "(", "np", ".", "linalg", ".", "norm", "(", "in1", ")", "/", "np", ".", "linalg", ".", "norm", "(", "in1", "-", "in2", ")", ")", ")", "re...
b024591ad0bbb69320d08841f28a2c27f62ae1af
train
RabbitMQContainer.wait_for_start
Wait for the RabbitMQ process to be come up.
seaworthy/containers/rabbitmq.py
def wait_for_start(self): """ Wait for the RabbitMQ process to be come up. """ er = self.exec_rabbitmqctl( 'wait', ['--pid', '1', '--timeout', str(int(self.wait_timeout))]) output_lines(er, error_exc=TimeoutError)
def wait_for_start(self): """ Wait for the RabbitMQ process to be come up. """ er = self.exec_rabbitmqctl( 'wait', ['--pid', '1', '--timeout', str(int(self.wait_timeout))]) output_lines(er, error_exc=TimeoutError)
[ "Wait", "for", "the", "RabbitMQ", "process", "to", "be", "come", "up", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/containers/rabbitmq.py#L56-L62
[ "def", "wait_for_start", "(", "self", ")", ":", "er", "=", "self", ".", "exec_rabbitmqctl", "(", "'wait'", ",", "[", "'--pid'", ",", "'1'", ",", "'--timeout'", ",", "str", "(", "int", "(", "self", ".", "wait_timeout", ")", ")", "]", ")", "output_lines"...
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
RabbitMQContainer.exec_rabbitmqctl
Execute a ``rabbitmqctl`` command inside a running container. :param command: the command to run :param args: a list of args for the command :param rabbitmqctl_opts: a list of extra options to pass to ``rabbitmqctl`` :returns: a tuple of the command exit code and output
seaworthy/containers/rabbitmq.py
def exec_rabbitmqctl(self, command, args=[], rabbitmqctl_opts=['-q']): """ Execute a ``rabbitmqctl`` command inside a running container. :param command: the command to run :param args: a list of args for the command :param rabbitmqctl_opts: a list of extra options to...
def exec_rabbitmqctl(self, command, args=[], rabbitmqctl_opts=['-q']): """ Execute a ``rabbitmqctl`` command inside a running container. :param command: the command to run :param args: a list of args for the command :param rabbitmqctl_opts: a list of extra options to...
[ "Execute", "a", "rabbitmqctl", "command", "inside", "a", "running", "container", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/containers/rabbitmq.py#L87-L98
[ "def", "exec_rabbitmqctl", "(", "self", ",", "command", ",", "args", "=", "[", "]", ",", "rabbitmqctl_opts", "=", "[", "'-q'", "]", ")", ":", "cmd", "=", "[", "'rabbitmqctl'", "]", "+", "rabbitmqctl_opts", "+", "[", "command", "]", "+", "args", "return...
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
RabbitMQContainer.exec_rabbitmqctl_list
Execute a ``rabbitmqctl`` command to list the given resources. :param resources: the resources to list, e.g. ``'vhosts'`` :param args: a list of args for the command :param rabbitmqctl_opts: a list of extra options to pass to ``rabbitmqctl`` :returns: a tuple of the command ...
seaworthy/containers/rabbitmq.py
def exec_rabbitmqctl_list(self, resources, args=[], rabbitmq_opts=['-q', '--no-table-headers']): """ Execute a ``rabbitmqctl`` command to list the given resources. :param resources: the resources to list, e.g. ``'vhosts'`` :param args: a list of args for th...
def exec_rabbitmqctl_list(self, resources, args=[], rabbitmq_opts=['-q', '--no-table-headers']): """ Execute a ``rabbitmqctl`` command to list the given resources. :param resources: the resources to list, e.g. ``'vhosts'`` :param args: a list of args for th...
[ "Execute", "a", "rabbitmqctl", "command", "to", "list", "the", "given", "resources", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/containers/rabbitmq.py#L100-L112
[ "def", "exec_rabbitmqctl_list", "(", "self", ",", "resources", ",", "args", "=", "[", "]", ",", "rabbitmq_opts", "=", "[", "'-q'", ",", "'--no-table-headers'", "]", ")", ":", "command", "=", "'list_{}'", ".", "format", "(", "resources", ")", "return", "sel...
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
RabbitMQContainer.list_queues
Run the ``list_queues`` command (for the default vhost) and return a list of tuples describing the queues. :return: A list of 2-element tuples. The first element is the queue name, the second is the current queue size.
seaworthy/containers/rabbitmq.py
def list_queues(self): """ Run the ``list_queues`` command (for the default vhost) and return a list of tuples describing the queues. :return: A list of 2-element tuples. The first element is the queue name, the second is the current queue size. """ ...
def list_queues(self): """ Run the ``list_queues`` command (for the default vhost) and return a list of tuples describing the queues. :return: A list of 2-element tuples. The first element is the queue name, the second is the current queue size. """ ...
[ "Run", "the", "list_queues", "command", "(", "for", "the", "default", "vhost", ")", "and", "return", "a", "list", "of", "tuples", "describing", "the", "queues", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/containers/rabbitmq.py#L120-L131
[ "def", "list_queues", "(", "self", ")", ":", "lines", "=", "output_lines", "(", "self", ".", "exec_rabbitmqctl_list", "(", "'queues'", ",", "[", "'-p'", ",", "self", ".", "vhost", "]", ")", ")", "return", "[", "tuple", "(", "line", ".", "split", "(", ...
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
RabbitMQContainer.list_users
Run the ``list_users`` command and return a list of tuples describing the users. :return: A list of 2-element tuples. The first element is the username, the second a list of tags for the user.
seaworthy/containers/rabbitmq.py
def list_users(self): """ Run the ``list_users`` command and return a list of tuples describing the users. :return: A list of 2-element tuples. The first element is the username, the second a list of tags for the user. """ lines = output_lines(sel...
def list_users(self): """ Run the ``list_users`` command and return a list of tuples describing the users. :return: A list of 2-element tuples. The first element is the username, the second a list of tags for the user. """ lines = output_lines(sel...
[ "Run", "the", "list_users", "command", "and", "return", "a", "list", "of", "tuples", "describing", "the", "users", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/containers/rabbitmq.py#L133-L143
[ "def", "list_users", "(", "self", ")", ":", "lines", "=", "output_lines", "(", "self", ".", "exec_rabbitmqctl_list", "(", "'users'", ")", ")", "return", "[", "_parse_rabbitmq_user", "(", "line", ")", "for", "line", "in", "lines", "]" ]
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
RabbitMQContainer.broker_url
Returns a "broker URL" for use with Celery.
seaworthy/containers/rabbitmq.py
def broker_url(self): """ Returns a "broker URL" for use with Celery. """ return 'amqp://{}:{}@{}/{}'.format( self.user, self.password, self.name, self.vhost)
def broker_url(self): """ Returns a "broker URL" for use with Celery. """ return 'amqp://{}:{}@{}/{}'.format( self.user, self.password, self.name, self.vhost)
[ "Returns", "a", "broker", "URL", "for", "use", "with", "Celery", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/containers/rabbitmq.py#L145-L148
[ "def", "broker_url", "(", "self", ")", ":", "return", "'amqp://{}:{}@{}/{}'", ".", "format", "(", "self", ".", "user", ",", "self", ".", "password", ",", "self", ".", "name", ",", "self", ".", "vhost", ")" ]
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
PostgreSQLContainer.exec_pg_success
Execute a command inside a running container as the postgres user, asserting success.
seaworthy/containers/postgresql.py
def exec_pg_success(self, cmd): """ Execute a command inside a running container as the postgres user, asserting success. """ result = self.inner().exec_run(cmd, user='postgres') assert result.exit_code == 0, result.output.decode('utf-8') return result
def exec_pg_success(self, cmd): """ Execute a command inside a running container as the postgres user, asserting success. """ result = self.inner().exec_run(cmd, user='postgres') assert result.exit_code == 0, result.output.decode('utf-8') return result
[ "Execute", "a", "command", "inside", "a", "running", "container", "as", "the", "postgres", "user", "asserting", "success", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/containers/postgresql.py#L63-L70
[ "def", "exec_pg_success", "(", "self", ",", "cmd", ")", ":", "result", "=", "self", ".", "inner", "(", ")", ".", "exec_run", "(", "cmd", ",", "user", "=", "'postgres'", ")", "assert", "result", ".", "exit_code", "==", "0", ",", "result", ".", "output...
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
PostgreSQLContainer.clean
Remove all data by dropping and recreating the configured database. .. note:: Only the configured database is removed. Any other databases remain untouched.
seaworthy/containers/postgresql.py
def clean(self): """ Remove all data by dropping and recreating the configured database. .. note:: Only the configured database is removed. Any other databases remain untouched. """ self.exec_pg_success(['dropdb', '-U', self.user, self.database]) ...
def clean(self): """ Remove all data by dropping and recreating the configured database. .. note:: Only the configured database is removed. Any other databases remain untouched. """ self.exec_pg_success(['dropdb', '-U', self.user, self.database]) ...
[ "Remove", "all", "data", "by", "dropping", "and", "recreating", "the", "configured", "database", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/containers/postgresql.py#L72-L82
[ "def", "clean", "(", "self", ")", ":", "self", ".", "exec_pg_success", "(", "[", "'dropdb'", ",", "'-U'", ",", "self", ".", "user", ",", "self", ".", "database", "]", ")", "self", ".", "exec_pg_success", "(", "[", "'createdb'", ",", "'-U'", ",", "sel...
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
PostgreSQLContainer.exec_psql
Execute a ``psql`` command inside a running container. By default the container's database is connected to. :param command: the command to run (passed to ``-c``) :param psql_opts: a list of extra options to pass to ``psql`` :returns: a tuple of the command exit code and output
seaworthy/containers/postgresql.py
def exec_psql(self, command, psql_opts=['-qtA']): """ Execute a ``psql`` command inside a running container. By default the container's database is connected to. :param command: the command to run (passed to ``-c``) :param psql_opts: a list of extra options to pass to ``psql`` ...
def exec_psql(self, command, psql_opts=['-qtA']): """ Execute a ``psql`` command inside a running container. By default the container's database is connected to. :param command: the command to run (passed to ``-c``) :param psql_opts: a list of extra options to pass to ``psql`` ...
[ "Execute", "a", "psql", "command", "inside", "a", "running", "container", ".", "By", "default", "the", "container", "s", "database", "is", "connected", "to", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/containers/postgresql.py#L84-L98
[ "def", "exec_psql", "(", "self", ",", "command", ",", "psql_opts", "=", "[", "'-qtA'", "]", ")", ":", "cmd", "=", "[", "'psql'", "]", "+", "psql_opts", "+", "[", "'--dbname'", ",", "self", ".", "database", ",", "'-U'", ",", "self", ".", "user", ","...
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
PostgreSQLContainer.list_databases
Runs the ``\\list`` command and returns a list of column values with information about all databases.
seaworthy/containers/postgresql.py
def list_databases(self): """ Runs the ``\\list`` command and returns a list of column values with information about all databases. """ lines = output_lines(self.exec_psql('\\list')) return [line.split('|') for line in lines]
def list_databases(self): """ Runs the ``\\list`` command and returns a list of column values with information about all databases. """ lines = output_lines(self.exec_psql('\\list')) return [line.split('|') for line in lines]
[ "Runs", "the", "\\\\", "list", "command", "and", "returns", "a", "list", "of", "column", "values", "with", "information", "about", "all", "databases", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/containers/postgresql.py#L100-L106
[ "def", "list_databases", "(", "self", ")", ":", "lines", "=", "output_lines", "(", "self", ".", "exec_psql", "(", "'\\\\list'", ")", ")", "return", "[", "line", ".", "split", "(", "'|'", ")", "for", "line", "in", "lines", "]" ]
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
PostgreSQLContainer.list_tables
Runs the ``\\dt`` command and returns a list of column values with information about all tables in the database.
seaworthy/containers/postgresql.py
def list_tables(self): """ Runs the ``\\dt`` command and returns a list of column values with information about all tables in the database. """ lines = output_lines(self.exec_psql('\\dt')) return [line.split('|') for line in lines]
def list_tables(self): """ Runs the ``\\dt`` command and returns a list of column values with information about all tables in the database. """ lines = output_lines(self.exec_psql('\\dt')) return [line.split('|') for line in lines]
[ "Runs", "the", "\\\\", "dt", "command", "and", "returns", "a", "list", "of", "column", "values", "with", "information", "about", "all", "tables", "in", "the", "database", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/containers/postgresql.py#L108-L114
[ "def", "list_tables", "(", "self", ")", ":", "lines", "=", "output_lines", "(", "self", ".", "exec_psql", "(", "'\\\\dt'", ")", ")", "return", "[", "line", ".", "split", "(", "'|'", ")", "for", "line", "in", "lines", "]" ]
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
PostgreSQLContainer.list_users
Runs the ``\\du`` command and returns a list of column values with information about all user roles.
seaworthy/containers/postgresql.py
def list_users(self): """ Runs the ``\\du`` command and returns a list of column values with information about all user roles. """ lines = output_lines(self.exec_psql('\\du')) return [line.split('|') for line in lines]
def list_users(self): """ Runs the ``\\du`` command and returns a list of column values with information about all user roles. """ lines = output_lines(self.exec_psql('\\du')) return [line.split('|') for line in lines]
[ "Runs", "the", "\\\\", "du", "command", "and", "returns", "a", "list", "of", "column", "values", "with", "information", "about", "all", "user", "roles", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/containers/postgresql.py#L116-L122
[ "def", "list_users", "(", "self", ")", ":", "lines", "=", "output_lines", "(", "self", ".", "exec_psql", "(", "'\\\\du'", ")", ")", "return", "[", "line", ".", "split", "(", "'|'", ")", "for", "line", "in", "lines", "]" ]
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
PostgreSQLContainer.database_url
Returns a "database URL" for use with DJ-Database-URL and similar libraries.
seaworthy/containers/postgresql.py
def database_url(self): """ Returns a "database URL" for use with DJ-Database-URL and similar libraries. """ return 'postgres://{}:{}@{}/{}'.format( self.user, self.password, self.name, self.database)
def database_url(self): """ Returns a "database URL" for use with DJ-Database-URL and similar libraries. """ return 'postgres://{}:{}@{}/{}'.format( self.user, self.password, self.name, self.database)
[ "Returns", "a", "database", "URL", "for", "use", "with", "DJ", "-", "Database", "-", "URL", "and", "similar", "libraries", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/containers/postgresql.py#L124-L130
[ "def", "database_url", "(", "self", ")", ":", "return", "'postgres://{}:{}@{}/{}'", ".", "format", "(", "self", ".", "user", ",", "self", ".", "password", ",", "self", ".", "name", ",", "self", ".", "database", ")" ]
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
from_config
Generate a matrix from a configuration dictionary.
src/matrix/__init__.py
def from_config(config): """ Generate a matrix from a configuration dictionary. """ matrix = {} variables = config.keys() for entries in product(*config.values()): combination = dict(zip(variables, entries)) include = True for value in combination.values(): fo...
def from_config(config): """ Generate a matrix from a configuration dictionary. """ matrix = {} variables = config.keys() for entries in product(*config.values()): combination = dict(zip(variables, entries)) include = True for value in combination.values(): fo...
[ "Generate", "a", "matrix", "from", "a", "configuration", "dictionary", "." ]
ionelmc/python-matrix
python
https://github.com/ionelmc/python-matrix/blob/e1a63879a6c94c37c3883386f1d86eb7c2179a5b/src/matrix/__init__.py#L131-L156
[ "def", "from_config", "(", "config", ")", ":", "matrix", "=", "{", "}", "variables", "=", "config", ".", "keys", "(", ")", "for", "entries", "in", "product", "(", "*", "config", ".", "values", "(", ")", ")", ":", "combination", "=", "dict", "(", "z...
e1a63879a6c94c37c3883386f1d86eb7c2179a5b
train
from_file
Generate a matrix from a .ini file. Configuration is expected to be in a ``[matrix]`` section.
src/matrix/__init__.py
def from_file(filename, section='matrix'): """ Generate a matrix from a .ini file. Configuration is expected to be in a ``[matrix]`` section. """ config = parse_config(open(filename), section=section) return from_config(config)
def from_file(filename, section='matrix'): """ Generate a matrix from a .ini file. Configuration is expected to be in a ``[matrix]`` section. """ config = parse_config(open(filename), section=section) return from_config(config)
[ "Generate", "a", "matrix", "from", "a", ".", "ini", "file", ".", "Configuration", "is", "expected", "to", "be", "in", "a", "[", "matrix", "]", "section", "." ]
ionelmc/python-matrix
python
https://github.com/ionelmc/python-matrix/blob/e1a63879a6c94c37c3883386f1d86eb7c2179a5b/src/matrix/__init__.py#L159-L164
[ "def", "from_file", "(", "filename", ",", "section", "=", "'matrix'", ")", ":", "config", "=", "parse_config", "(", "open", "(", "filename", ")", ",", "section", "=", "section", ")", "return", "from_config", "(", "config", ")" ]
e1a63879a6c94c37c3883386f1d86eb7c2179a5b
train
from_string
Generate a matrix from a .ini file. Configuration is expected to be in a ``[matrix]`` section.
src/matrix/__init__.py
def from_string(string, section='matrix'): """ Generate a matrix from a .ini file. Configuration is expected to be in a ``[matrix]`` section. """ config = parse_config(StringIO(string), section=section) return from_config(config)
def from_string(string, section='matrix'): """ Generate a matrix from a .ini file. Configuration is expected to be in a ``[matrix]`` section. """ config = parse_config(StringIO(string), section=section) return from_config(config)
[ "Generate", "a", "matrix", "from", "a", ".", "ini", "file", ".", "Configuration", "is", "expected", "to", "be", "in", "a", "[", "matrix", "]", "section", "." ]
ionelmc/python-matrix
python
https://github.com/ionelmc/python-matrix/blob/e1a63879a6c94c37c3883386f1d86eb7c2179a5b/src/matrix/__init__.py#L167-L172
[ "def", "from_string", "(", "string", ",", "section", "=", "'matrix'", ")", ":", "config", "=", "parse_config", "(", "StringIO", "(", "string", ")", ",", "section", "=", "section", ")", "return", "from_config", "(", "config", ")" ]
e1a63879a6c94c37c3883386f1d86eb7c2179a5b
train
no_raise
Decorator/wrapper function to force return None instead of raising module exceptions. Exceptions that can be ignored are found in mypolr.exceptions.
mypolr/exceptions.py
def no_raise(f): """Decorator/wrapper function to force return None instead of raising module exceptions. Exceptions that can be ignored are found in mypolr.exceptions.""" @wraps(f) def new_f(*args, **kwargs): try: return f(*args, **kwargs) except MypolrError: pa...
def no_raise(f): """Decorator/wrapper function to force return None instead of raising module exceptions. Exceptions that can be ignored are found in mypolr.exceptions.""" @wraps(f) def new_f(*args, **kwargs): try: return f(*args, **kwargs) except MypolrError: pa...
[ "Decorator", "/", "wrapper", "function", "to", "force", "return", "None", "instead", "of", "raising", "module", "exceptions", "." ]
fauskanger/mypolr
python
https://github.com/fauskanger/mypolr/blob/46eb4fc5ba0f65412634a37e30e05de79fc9db4c/mypolr/exceptions.py#L7-L18
[ "def", "no_raise", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "new_f", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "f", "(", "*", "args", ",", "*", "*", "kwargs", ")", "except", "MypolrError", ":", ...
46eb4fc5ba0f65412634a37e30e05de79fc9db4c
train
StatusWorkerThread.flush
This only needs to be called manually from unit tests
src/automate/worker.py
def flush(self): """ This only needs to be called manually from unit tests """ self.logger.debug('Flush joining') self.queue.join() self.logger.debug('Flush joining ready')
def flush(self): """ This only needs to be called manually from unit tests """ self.logger.debug('Flush joining') self.queue.join() self.logger.debug('Flush joining ready')
[ "This", "only", "needs", "to", "be", "called", "manually", "from", "unit", "tests" ]
tuomas2/automate
python
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/worker.py#L112-L119
[ "def", "flush", "(", "self", ")", ":", "self", ".", "logger", ".", "debug", "(", "'Flush joining'", ")", "self", ".", "queue", ".", "join", "(", ")", "self", ".", "logger", ".", "debug", "(", "'Flush joining ready'", ")" ]
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
train
output_lines
Convert bytestring container output or the result of a container exec command into a sequence of unicode lines. :param output: Container output bytes or an :class:`docker.models.containers.ExecResult` instance. :param encoding: The encoding to use when converting bytes to unicode ...
seaworthy/utils.py
def output_lines(output, encoding='utf-8', error_exc=None): """ Convert bytestring container output or the result of a container exec command into a sequence of unicode lines. :param output: Container output bytes or an :class:`docker.models.containers.ExecResult` instance. :param e...
def output_lines(output, encoding='utf-8', error_exc=None): """ Convert bytestring container output or the result of a container exec command into a sequence of unicode lines. :param output: Container output bytes or an :class:`docker.models.containers.ExecResult` instance. :param e...
[ "Convert", "bytestring", "container", "output", "or", "the", "result", "of", "a", "container", "exec", "command", "into", "a", "sequence", "of", "unicode", "lines", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/utils.py#L4-L27
[ "def", "output_lines", "(", "output", ",", "encoding", "=", "'utf-8'", ",", "error_exc", "=", "None", ")", ":", "if", "isinstance", "(", "output", ",", "ExecResult", ")", ":", "exit_code", ",", "output", "=", "output", "if", "exit_code", "!=", "0", "and"...
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
WeedFS.get_file
Get file from WeedFS. Returns file content. May be problematic for large files as content is stored in memory. Args: **fid**: File identifier <volume_id>,<file_name_hash> Returns: Content of the file with provided fid or None if file doesn't exist o...
pyseaweed/weed.py
def get_file(self, fid): """Get file from WeedFS. Returns file content. May be problematic for large files as content is stored in memory. Args: **fid**: File identifier <volume_id>,<file_name_hash> Returns: Content of the file with provided fid or None...
def get_file(self, fid): """Get file from WeedFS. Returns file content. May be problematic for large files as content is stored in memory. Args: **fid**: File identifier <volume_id>,<file_name_hash> Returns: Content of the file with provided fid or None...
[ "Get", "file", "from", "WeedFS", "." ]
utek/pyseaweed
python
https://github.com/utek/pyseaweed/blob/218049329885425a2b8370157fa44952e64516be/pyseaweed/weed.py#L50-L66
[ "def", "get_file", "(", "self", ",", "fid", ")", ":", "url", "=", "self", ".", "get_file_url", "(", "fid", ")", "return", "self", ".", "conn", ".", "get_raw_data", "(", "url", ")" ]
218049329885425a2b8370157fa44952e64516be
train
WeedFS.get_file_url
Get url for the file :param string fid: File ID :param boolean public: public or internal url :rtype: string
pyseaweed/weed.py
def get_file_url(self, fid, public=None): """ Get url for the file :param string fid: File ID :param boolean public: public or internal url :rtype: string """ try: volume_id, rest = fid.strip().split(",") except ValueError: raise B...
def get_file_url(self, fid, public=None): """ Get url for the file :param string fid: File ID :param boolean public: public or internal url :rtype: string """ try: volume_id, rest = fid.strip().split(",") except ValueError: raise B...
[ "Get", "url", "for", "the", "file" ]
utek/pyseaweed
python
https://github.com/utek/pyseaweed/blob/218049329885425a2b8370157fa44952e64516be/pyseaweed/weed.py#L68-L87
[ "def", "get_file_url", "(", "self", ",", "fid", ",", "public", "=", "None", ")", ":", "try", ":", "volume_id", ",", "rest", "=", "fid", ".", "strip", "(", ")", ".", "split", "(", "\",\"", ")", "except", "ValueError", ":", "raise", "BadFidFormat", "("...
218049329885425a2b8370157fa44952e64516be
train
WeedFS.get_file_location
Get location for the file, WeedFS volume is choosed randomly :param integer volume_id: volume_id :rtype: namedtuple `FileLocation` `{"public_url":"", "url":""}`
pyseaweed/weed.py
def get_file_location(self, volume_id): """ Get location for the file, WeedFS volume is choosed randomly :param integer volume_id: volume_id :rtype: namedtuple `FileLocation` `{"public_url":"", "url":""}` """ url = ("http://{master_addr}:{master_port}/" ...
def get_file_location(self, volume_id): """ Get location for the file, WeedFS volume is choosed randomly :param integer volume_id: volume_id :rtype: namedtuple `FileLocation` `{"public_url":"", "url":""}` """ url = ("http://{master_addr}:{master_port}/" ...
[ "Get", "location", "for", "the", "file", "WeedFS", "volume", "is", "choosed", "randomly" ]
utek/pyseaweed
python
https://github.com/utek/pyseaweed/blob/218049329885425a2b8370157fa44952e64516be/pyseaweed/weed.py#L89-L105
[ "def", "get_file_location", "(", "self", ",", "volume_id", ")", ":", "url", "=", "(", "\"http://{master_addr}:{master_port}/\"", "\"dir/lookup?volumeId={volume_id}\"", ")", ".", "format", "(", "master_addr", "=", "self", ".", "master_addr", ",", "master_port", "=", ...
218049329885425a2b8370157fa44952e64516be
train
WeedFS.get_file_size
Gets size of uploaded file Or None if file doesn't exist. Args: **fid**: File identifier <volume_id>,<file_name_hash> Returns: Int or None
pyseaweed/weed.py
def get_file_size(self, fid): """ Gets size of uploaded file Or None if file doesn't exist. Args: **fid**: File identifier <volume_id>,<file_name_hash> Returns: Int or None """ url = self.get_file_url(fid) res = self.conn.head(url...
def get_file_size(self, fid): """ Gets size of uploaded file Or None if file doesn't exist. Args: **fid**: File identifier <volume_id>,<file_name_hash> Returns: Int or None """ url = self.get_file_url(fid) res = self.conn.head(url...
[ "Gets", "size", "of", "uploaded", "file", "Or", "None", "if", "file", "doesn", "t", "exist", "." ]
utek/pyseaweed
python
https://github.com/utek/pyseaweed/blob/218049329885425a2b8370157fa44952e64516be/pyseaweed/weed.py#L107-L124
[ "def", "get_file_size", "(", "self", ",", "fid", ")", ":", "url", "=", "self", ".", "get_file_url", "(", "fid", ")", "res", "=", "self", ".", "conn", ".", "head", "(", "url", ")", "if", "res", "is", "not", "None", ":", "size", "=", "res", ".", ...
218049329885425a2b8370157fa44952e64516be
train
WeedFS.file_exists
Checks if file with provided fid exists Args: **fid**: File identifier <volume_id>,<file_name_hash> Returns: True if file exists. False if not.
pyseaweed/weed.py
def file_exists(self, fid): """Checks if file with provided fid exists Args: **fid**: File identifier <volume_id>,<file_name_hash> Returns: True if file exists. False if not. """ res = self.get_file_size(fid) if res is not None: retur...
def file_exists(self, fid): """Checks if file with provided fid exists Args: **fid**: File identifier <volume_id>,<file_name_hash> Returns: True if file exists. False if not. """ res = self.get_file_size(fid) if res is not None: retur...
[ "Checks", "if", "file", "with", "provided", "fid", "exists" ]
utek/pyseaweed
python
https://github.com/utek/pyseaweed/blob/218049329885425a2b8370157fa44952e64516be/pyseaweed/weed.py#L126-L138
[ "def", "file_exists", "(", "self", ",", "fid", ")", ":", "res", "=", "self", ".", "get_file_size", "(", "fid", ")", "if", "res", "is", "not", "None", ":", "return", "True", "return", "False" ]
218049329885425a2b8370157fa44952e64516be
train
WeedFS.delete_file
Delete file from WeedFS :param string fid: File ID
pyseaweed/weed.py
def delete_file(self, fid): """ Delete file from WeedFS :param string fid: File ID """ url = self.get_file_url(fid) return self.conn.delete_data(url)
def delete_file(self, fid): """ Delete file from WeedFS :param string fid: File ID """ url = self.get_file_url(fid) return self.conn.delete_data(url)
[ "Delete", "file", "from", "WeedFS" ]
utek/pyseaweed
python
https://github.com/utek/pyseaweed/blob/218049329885425a2b8370157fa44952e64516be/pyseaweed/weed.py#L140-L147
[ "def", "delete_file", "(", "self", ",", "fid", ")", ":", "url", "=", "self", ".", "get_file_url", "(", "fid", ")", "return", "self", ".", "conn", ".", "delete_data", "(", "url", ")" ]
218049329885425a2b8370157fa44952e64516be
train
WeedFS.upload_file
Uploads file to WeedFS I takes either path or stream and name and upload it to WeedFS server. Returns fid of the uploaded file. :param string path: :param string stream: :param string name: :rtype: string or None
pyseaweed/weed.py
def upload_file(self, path=None, stream=None, name=None, **kwargs): """ Uploads file to WeedFS I takes either path or stream and name and upload it to WeedFS server. Returns fid of the uploaded file. :param string path: :param string stream: :param stri...
def upload_file(self, path=None, stream=None, name=None, **kwargs): """ Uploads file to WeedFS I takes either path or stream and name and upload it to WeedFS server. Returns fid of the uploaded file. :param string path: :param string stream: :param stri...
[ "Uploads", "file", "to", "WeedFS" ]
utek/pyseaweed
python
https://github.com/utek/pyseaweed/blob/218049329885425a2b8370157fa44952e64516be/pyseaweed/weed.py#L149-L192
[ "def", "upload_file", "(", "self", ",", "path", "=", "None", ",", "stream", "=", "None", ",", "name", "=", "None", ",", "*", "*", "kwargs", ")", ":", "params", "=", "\"&\"", ".", "join", "(", "[", "\"%s=%s\"", "%", "(", "k", ",", "v", ")", "for...
218049329885425a2b8370157fa44952e64516be
train
WeedFS.vacuum
Force garbage collection :param float threshold (optional): The threshold is optional, and will not change the default threshold. :rtype: boolean
pyseaweed/weed.py
def vacuum(self, threshold=0.3): ''' Force garbage collection :param float threshold (optional): The threshold is optional, and will not change the default threshold. :rtype: boolean ''' url = ("http://{master_addr}:{master_port}/" "vol/vacuum?gar...
def vacuum(self, threshold=0.3): ''' Force garbage collection :param float threshold (optional): The threshold is optional, and will not change the default threshold. :rtype: boolean ''' url = ("http://{master_addr}:{master_port}/" "vol/vacuum?gar...
[ "Force", "garbage", "collection" ]
utek/pyseaweed
python
https://github.com/utek/pyseaweed/blob/218049329885425a2b8370157fa44952e64516be/pyseaweed/weed.py#L194-L211
[ "def", "vacuum", "(", "self", ",", "threshold", "=", "0.3", ")", ":", "url", "=", "(", "\"http://{master_addr}:{master_port}/\"", "\"vol/vacuum?garbageThreshold={threshold}\"", ")", ".", "format", "(", "master_addr", "=", "self", ".", "master_addr", ",", "master_por...
218049329885425a2b8370157fa44952e64516be
train
WeedFS.version
Returns Weed-FS master version :rtype: string
pyseaweed/weed.py
def version(self): ''' Returns Weed-FS master version :rtype: string ''' url = "http://{master_addr}:{master_port}/dir/status".format( master_addr=self.master_addr, master_port=self.master_port) data = self.conn.get_data(url) response_data...
def version(self): ''' Returns Weed-FS master version :rtype: string ''' url = "http://{master_addr}:{master_port}/dir/status".format( master_addr=self.master_addr, master_port=self.master_port) data = self.conn.get_data(url) response_data...
[ "Returns", "Weed", "-", "FS", "master", "version" ]
utek/pyseaweed
python
https://github.com/utek/pyseaweed/blob/218049329885425a2b8370157fa44952e64516be/pyseaweed/weed.py#L214-L225
[ "def", "version", "(", "self", ")", ":", "url", "=", "\"http://{master_addr}:{master_port}/dir/status\"", ".", "format", "(", "master_addr", "=", "self", ".", "master_addr", ",", "master_port", "=", "self", ".", "master_port", ")", "data", "=", "self", ".", "c...
218049329885425a2b8370157fa44952e64516be
train
fft_convolve
This function determines the convolution of two inputs using the FFT. Contains an implementation for both CPU and GPU. INPUTS: in1 (no default): Array containing one set of data, possibly an image. in2 (no default): Gpuarray containing the FFT of the PSF. ...
pymoresane/iuwt_convolution.py
def fft_convolve(in1, in2, conv_device="cpu", conv_mode="linear", store_on_gpu=False): """ This function determines the convolution of two inputs using the FFT. Contains an implementation for both CPU and GPU. INPUTS: in1 (no default): Array containing one set of data, possibl...
def fft_convolve(in1, in2, conv_device="cpu", conv_mode="linear", store_on_gpu=False): """ This function determines the convolution of two inputs using the FFT. Contains an implementation for both CPU and GPU. INPUTS: in1 (no default): Array containing one set of data, possibl...
[ "This", "function", "determines", "the", "convolution", "of", "two", "inputs", "using", "the", "FFT", ".", "Contains", "an", "implementation", "for", "both", "CPU", "and", "GPU", "." ]
ratt-ru/PyMORESANE
python
https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/iuwt_convolution.py#L18-L73
[ "def", "fft_convolve", "(", "in1", ",", "in2", ",", "conv_device", "=", "\"cpu\"", ",", "conv_mode", "=", "\"linear\"", ",", "store_on_gpu", "=", "False", ")", ":", "# NOTE: Circular convolution assumes a periodic repetition of the input. This can cause edge effects. Linear",...
b024591ad0bbb69320d08841f28a2c27f62ae1af
train
gpu_r2c_fft
This function makes use of the scikits implementation of the FFT for GPUs to take the real to complex FFT. INPUTS: in1 (no default): The array on which the FFT is to be performed. is_gpuarray (default=True): Boolean specifier for whether or not input is on the gpu. store_on_gp...
pymoresane/iuwt_convolution.py
def gpu_r2c_fft(in1, is_gpuarray=False, store_on_gpu=False): """ This function makes use of the scikits implementation of the FFT for GPUs to take the real to complex FFT. INPUTS: in1 (no default): The array on which the FFT is to be performed. is_gpuarray (default=True): ...
def gpu_r2c_fft(in1, is_gpuarray=False, store_on_gpu=False): """ This function makes use of the scikits implementation of the FFT for GPUs to take the real to complex FFT. INPUTS: in1 (no default): The array on which the FFT is to be performed. is_gpuarray (default=True): ...
[ "This", "function", "makes", "use", "of", "the", "scikits", "implementation", "of", "the", "FFT", "for", "GPUs", "to", "take", "the", "real", "to", "complex", "FFT", "." ]
ratt-ru/PyMORESANE
python
https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/iuwt_convolution.py#L76-L106
[ "def", "gpu_r2c_fft", "(", "in1", ",", "is_gpuarray", "=", "False", ",", "store_on_gpu", "=", "False", ")", ":", "if", "is_gpuarray", ":", "gpu_in1", "=", "in1", "else", ":", "gpu_in1", "=", "gpuarray", ".", "to_gpu_async", "(", "in1", ".", "astype", "("...
b024591ad0bbb69320d08841f28a2c27f62ae1af
train
gpu_c2r_ifft
This function makes use of the scikits implementation of the FFT for GPUs to take the complex to real IFFT. INPUTS: in1 (no default): The array on which the IFFT is to be performed. is_gpuarray (default=True): Boolean specifier for whether or not input is on the gpu. store_on_...
pymoresane/iuwt_convolution.py
def gpu_c2r_ifft(in1, is_gpuarray=False, store_on_gpu=False): """ This function makes use of the scikits implementation of the FFT for GPUs to take the complex to real IFFT. INPUTS: in1 (no default): The array on which the IFFT is to be performed. is_gpuarray (default=True): ...
def gpu_c2r_ifft(in1, is_gpuarray=False, store_on_gpu=False): """ This function makes use of the scikits implementation of the FFT for GPUs to take the complex to real IFFT. INPUTS: in1 (no default): The array on which the IFFT is to be performed. is_gpuarray (default=True): ...
[ "This", "function", "makes", "use", "of", "the", "scikits", "implementation", "of", "the", "FFT", "for", "GPUs", "to", "take", "the", "complex", "to", "real", "IFFT", "." ]
ratt-ru/PyMORESANE
python
https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/iuwt_convolution.py#L108-L139
[ "def", "gpu_c2r_ifft", "(", "in1", ",", "is_gpuarray", "=", "False", ",", "store_on_gpu", "=", "False", ")", ":", "if", "is_gpuarray", ":", "gpu_in1", "=", "in1", "else", ":", "gpu_in1", "=", "gpuarray", ".", "to_gpu_async", "(", "in1", ".", "astype", "(...
b024591ad0bbb69320d08841f28a2c27f62ae1af
train
pad_array
Simple convenience function to pad arrays for linear convolution. INPUTS: in1 (no default): Input array which is to be padded. OUTPUTS: out1 Padded version of the input.
pymoresane/iuwt_convolution.py
def pad_array(in1): """ Simple convenience function to pad arrays for linear convolution. INPUTS: in1 (no default): Input array which is to be padded. OUTPUTS: out1 Padded version of the input. """ padded_size = 2*np.array(in1.shape) out1 = np.zeros([padd...
def pad_array(in1): """ Simple convenience function to pad arrays for linear convolution. INPUTS: in1 (no default): Input array which is to be padded. OUTPUTS: out1 Padded version of the input. """ padded_size = 2*np.array(in1.shape) out1 = np.zeros([padd...
[ "Simple", "convenience", "function", "to", "pad", "arrays", "for", "linear", "convolution", "." ]
ratt-ru/PyMORESANE
python
https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/iuwt_convolution.py#L142-L158
[ "def", "pad_array", "(", "in1", ")", ":", "padded_size", "=", "2", "*", "np", ".", "array", "(", "in1", ".", "shape", ")", "out1", "=", "np", ".", "zeros", "(", "[", "padded_size", "[", "0", "]", ",", "padded_size", "[", "1", "]", "]", ")", "ou...
b024591ad0bbb69320d08841f28a2c27f62ae1af
train
fft_shift
This function performs the FFT shift operation on the GPU to restore the correct output shape. INPUTS: in1 (no default): Array containing data which has been FFTed and IFFTed. OUTPUTS: in1 FFT-shifted version of in1.
pymoresane/iuwt_convolution.py
def fft_shift(in1): """ This function performs the FFT shift operation on the GPU to restore the correct output shape. INPUTS: in1 (no default): Array containing data which has been FFTed and IFFTed. OUTPUTS: in1 FFT-shifted version of in1. """ ker = SourceMo...
def fft_shift(in1): """ This function performs the FFT shift operation on the GPU to restore the correct output shape. INPUTS: in1 (no default): Array containing data which has been FFTed and IFFTed. OUTPUTS: in1 FFT-shifted version of in1. """ ker = SourceMo...
[ "This", "function", "performs", "the", "FFT", "shift", "operation", "on", "the", "GPU", "to", "restore", "the", "correct", "output", "shape", "." ]
ratt-ru/PyMORESANE
python
https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/iuwt_convolution.py#L161-L201
[ "def", "fft_shift", "(", "in1", ")", ":", "ker", "=", "SourceModule", "(", "\"\"\"\n __global__ void fft_shift_ker(float *in1)\n {\n const int len = gridDim.x*blockDim.x;\n const int col = (blockD...
b024591ad0bbb69320d08841f28a2c27f62ae1af
train
contiguous_slice
This function unpads an array on the GPU in such a way as to make it contiguous. INPUTS: in1 (no default): Array containing data which has been padded. OUTPUTS: gpu_out1 Array containing unpadded, contiguous data.
pymoresane/iuwt_convolution.py
def contiguous_slice(in1): """ This function unpads an array on the GPU in such a way as to make it contiguous. INPUTS: in1 (no default): Array containing data which has been padded. OUTPUTS: gpu_out1 Array containing unpadded, contiguous data. """ ker = SourceMod...
def contiguous_slice(in1): """ This function unpads an array on the GPU in such a way as to make it contiguous. INPUTS: in1 (no default): Array containing data which has been padded. OUTPUTS: gpu_out1 Array containing unpadded, contiguous data. """ ker = SourceMod...
[ "This", "function", "unpads", "an", "array", "on", "the", "GPU", "in", "such", "a", "way", "as", "to", "make", "it", "contiguous", "." ]
ratt-ru/PyMORESANE
python
https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/iuwt_convolution.py#L204-L239
[ "def", "contiguous_slice", "(", "in1", ")", ":", "ker", "=", "SourceModule", "(", "\"\"\"\n __global__ void contiguous_slice_ker(float *in1, float *out1)\n {\n const int len = gridDim.x*blockDim.x;\n ...
b024591ad0bbb69320d08841f28a2c27f62ae1af
train
scale_fft
This function performs in-place scaling after the IFFT without recompilation. INPUTS: in1 (no default): Array containing data which is to be scaled.
pymoresane/iuwt_convolution.py
def scale_fft(in1): """ This function performs in-place scaling after the IFFT without recompilation. INPUTS: in1 (no default): Array containing data which is to be scaled. """ ker = SourceModule(""" __global__ void scale_fft_ker(float *in1) ...
def scale_fft(in1): """ This function performs in-place scaling after the IFFT without recompilation. INPUTS: in1 (no default): Array containing data which is to be scaled. """ ker = SourceModule(""" __global__ void scale_fft_ker(float *in1) ...
[ "This", "function", "performs", "in", "-", "place", "scaling", "after", "the", "IFFT", "without", "recompilation", "." ]
ratt-ru/PyMORESANE
python
https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/iuwt_convolution.py#L242-L265
[ "def", "scale_fft", "(", "in1", ")", ":", "ker", "=", "SourceModule", "(", "\"\"\"\n __global__ void scale_fft_ker(float *in1)\n {\n const int len = gridDim.x*blockDim.x;\n const int col = (blockD...
b024591ad0bbb69320d08841f28a2c27f62ae1af
train
DragonAPI.is_dragon
Check if host is a dragon. Check if the specified host is a dragon based on simple heuristic. The code simply checks if particular strings are in the index page. It should work for DragonMint or Innosilicon branded miners.
dragon_rest/dragons.py
def is_dragon(host, timeout=1): """ Check if host is a dragon. Check if the specified host is a dragon based on simple heuristic. The code simply checks if particular strings are in the index page. It should work for DragonMint or Innosilicon branded miners. """ ...
def is_dragon(host, timeout=1): """ Check if host is a dragon. Check if the specified host is a dragon based on simple heuristic. The code simply checks if particular strings are in the index page. It should work for DragonMint or Innosilicon branded miners. """ ...
[ "Check", "if", "host", "is", "a", "dragon", "." ]
brndnmtthws/dragon-rest
python
https://github.com/brndnmtthws/dragon-rest/blob/10ea09a6203c0cbfeeeb854702764bd778769887/dragon_rest/dragons.py#L49-L65
[ "def", "is_dragon", "(", "host", ",", "timeout", "=", "1", ")", ":", "try", ":", "r", "=", "requests", ".", "get", "(", "'http://{}/'", ".", "format", "(", "host", ")", ",", "timeout", "=", "timeout", ")", "if", "r", ".", "status_code", "==", "200"...
10ea09a6203c0cbfeeeb854702764bd778769887
train
DragonAPI.auth
Authenticate with the miner and obtain a JSON web token (JWT).
dragon_rest/dragons.py
def auth(self): """Authenticate with the miner and obtain a JSON web token (JWT).""" response = requests.post( parse.urljoin(self.base_url, '/api/auth'), timeout=self.timeout, data={'username': self.username, 'password': self.password}) response.raise_for_stat...
def auth(self): """Authenticate with the miner and obtain a JSON web token (JWT).""" response = requests.post( parse.urljoin(self.base_url, '/api/auth'), timeout=self.timeout, data={'username': self.username, 'password': self.password}) response.raise_for_stat...
[ "Authenticate", "with", "the", "miner", "and", "obtain", "a", "JSON", "web", "token", "(", "JWT", ")", "." ]
brndnmtthws/dragon-rest
python
https://github.com/brndnmtthws/dragon-rest/blob/10ea09a6203c0cbfeeeb854702764bd778769887/dragon_rest/dragons.py#L118-L129
[ "def", "auth", "(", "self", ")", ":", "response", "=", "requests", ".", "post", "(", "parse", ".", "urljoin", "(", "self", ".", "base_url", ",", "'/api/auth'", ")", ",", "timeout", "=", "self", ".", "timeout", ",", "data", "=", "{", "'username'", ":"...
10ea09a6203c0cbfeeeb854702764bd778769887
train
DragonAPI.updatePools
Change the pools of the miner. This call will restart cgminer.
dragon_rest/dragons.py
def updatePools(self, pool1, username1, password1, pool2=None, username2=None, password2=None, pool3=None, username3=None, password3=None): ...
def updatePools(self, pool1, username1, password1, pool2=None, username2=None, password2=None, pool3=None, username3=None, password3=None): ...
[ "Change", "the", "pools", "of", "the", "miner", ".", "This", "call", "will", "restart", "cgminer", "." ]
brndnmtthws/dragon-rest
python
https://github.com/brndnmtthws/dragon-rest/blob/10ea09a6203c0cbfeeeb854702764bd778769887/dragon_rest/dragons.py#L148-L170
[ "def", "updatePools", "(", "self", ",", "pool1", ",", "username1", ",", "password1", ",", "pool2", "=", "None", ",", "username2", "=", "None", ",", "password2", "=", "None", ",", "pool3", "=", "None", ",", "username3", "=", "None", ",", "password3", "=...
10ea09a6203c0cbfeeeb854702764bd778769887
train
DragonAPI.updatePassword
Change the password of a user.
dragon_rest/dragons.py
def updatePassword(self, user, currentPassword, newPassword): """Change the password of a user.""" return self.__post('/api/updatePassword', data={ 'user': user, ...
def updatePassword(self, user, currentPassword, newPassword): """Change the password of a user.""" return self.__post('/api/updatePassword', data={ 'user': user, ...
[ "Change", "the", "password", "of", "a", "user", "." ]
brndnmtthws/dragon-rest
python
https://github.com/brndnmtthws/dragon-rest/blob/10ea09a6203c0cbfeeeb854702764bd778769887/dragon_rest/dragons.py#L172-L182
[ "def", "updatePassword", "(", "self", ",", "user", ",", "currentPassword", ",", "newPassword", ")", ":", "return", "self", ".", "__post", "(", "'/api/updatePassword'", ",", "data", "=", "{", "'user'", ":", "user", ",", "'currentPassword'", ":", "currentPasswor...
10ea09a6203c0cbfeeeb854702764bd778769887
train
DragonAPI.updateNetwork
Change the current network settings.
dragon_rest/dragons.py
def updateNetwork(self, dhcp='dhcp', ipaddress=None, netmask=None, gateway=None, dns=None): """Change the current network settings.""" return self.__post('/api/updateNetwork', ...
def updateNetwork(self, dhcp='dhcp', ipaddress=None, netmask=None, gateway=None, dns=None): """Change the current network settings.""" return self.__post('/api/updateNetwork', ...
[ "Change", "the", "current", "network", "settings", "." ]
brndnmtthws/dragon-rest
python
https://github.com/brndnmtthws/dragon-rest/blob/10ea09a6203c0cbfeeeb854702764bd778769887/dragon_rest/dragons.py#L188-L202
[ "def", "updateNetwork", "(", "self", ",", "dhcp", "=", "'dhcp'", ",", "ipaddress", "=", "None", ",", "netmask", "=", "None", ",", "gateway", "=", "None", ",", "dns", "=", "None", ")", ":", "return", "self", ".", "__post", "(", "'/api/updateNetwork'", "...
10ea09a6203c0cbfeeeb854702764bd778769887
train
DragonAPI.upgradeUpload
Upgrade the firmware of the miner.
dragon_rest/dragons.py
def upgradeUpload(self, file): """Upgrade the firmware of the miner.""" files = {'upfile': open(file, 'rb')} return self.__post_files('/upgrade/upload', files=files)
def upgradeUpload(self, file): """Upgrade the firmware of the miner.""" files = {'upfile': open(file, 'rb')} return self.__post_files('/upgrade/upload', files=files)
[ "Upgrade", "the", "firmware", "of", "the", "miner", "." ]
brndnmtthws/dragon-rest
python
https://github.com/brndnmtthws/dragon-rest/blob/10ea09a6203c0cbfeeeb854702764bd778769887/dragon_rest/dragons.py#L237-L241
[ "def", "upgradeUpload", "(", "self", ",", "file", ")", ":", "files", "=", "{", "'upfile'", ":", "open", "(", "file", ",", "'rb'", ")", "}", "return", "self", ".", "__post_files", "(", "'/upgrade/upload'", ",", "files", "=", "files", ")" ]
10ea09a6203c0cbfeeeb854702764bd778769887
train
StatusObject.is_program
A property which can be used to check if StatusObject uses program features or not.
src/automate/statusobject.py
def is_program(self): """ A property which can be used to check if StatusObject uses program features or not. """ from automate.callables import Empty return not (isinstance(self.on_activate, Empty) and isinstance(self.on_deactivate, Empty) ...
def is_program(self): """ A property which can be used to check if StatusObject uses program features or not. """ from automate.callables import Empty return not (isinstance(self.on_activate, Empty) and isinstance(self.on_deactivate, Empty) ...
[ "A", "property", "which", "can", "be", "used", "to", "check", "if", "StatusObject", "uses", "program", "features", "or", "not", "." ]
tuomas2/automate
python
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/statusobject.py#L208-L215
[ "def", "is_program", "(", "self", ")", ":", "from", "automate", ".", "callables", "import", "Empty", "return", "not", "(", "isinstance", "(", "self", ".", "on_activate", ",", "Empty", ")", "and", "isinstance", "(", "self", ".", "on_deactivate", ",", "Empty...
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
train
StatusObject.get_status_display
Define how status is displayed in UIs (add units etc.).
src/automate/statusobject.py
def get_status_display(self, **kwargs): """ Define how status is displayed in UIs (add units etc.). """ if 'value' in kwargs: value = kwargs['value'] else: value = self.status if self.show_stdev_seconds: stdev = self.stdev(self.sho...
def get_status_display(self, **kwargs): """ Define how status is displayed in UIs (add units etc.). """ if 'value' in kwargs: value = kwargs['value'] else: value = self.status if self.show_stdev_seconds: stdev = self.stdev(self.sho...
[ "Define", "how", "status", "is", "displayed", "in", "UIs", "(", "add", "units", "etc", ".", ")", "." ]
tuomas2/automate
python
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/statusobject.py#L223-L236
[ "def", "get_status_display", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "'value'", "in", "kwargs", ":", "value", "=", "kwargs", "[", "'value'", "]", "else", ":", "value", "=", "self", ".", "status", "if", "self", ".", "show_stdev_seconds", "...
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
train
StatusObject.get_as_datadict
Get data of this object as a data dictionary. Used by websocket service.
src/automate/statusobject.py
def get_as_datadict(self): """ Get data of this object as a data dictionary. Used by websocket service. """ d = super().get_as_datadict() d.update(dict(status=self.status, data_type=self.data_type, editable=self.editable)) return d
def get_as_datadict(self): """ Get data of this object as a data dictionary. Used by websocket service. """ d = super().get_as_datadict() d.update(dict(status=self.status, data_type=self.data_type, editable=self.editable)) return d
[ "Get", "data", "of", "this", "object", "as", "a", "data", "dictionary", ".", "Used", "by", "websocket", "service", "." ]
tuomas2/automate
python
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/statusobject.py#L238-L244
[ "def", "get_as_datadict", "(", "self", ")", ":", "d", "=", "super", "(", ")", ".", "get_as_datadict", "(", ")", "d", ".", "update", "(", "dict", "(", "status", "=", "self", ".", "status", ",", "data_type", "=", "self", ".", "data_type", ",", "editabl...
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
train
StatusObject._do_change_status
This function is called by - set_status - _update_program_stack if active program is being changed - thia may be launched by sensor status change. status lock is necessary because these happen from different threads. This does not directly change sta...
src/automate/statusobject.py
def _do_change_status(self, status, force=False): """ This function is called by - set_status - _update_program_stack if active program is being changed - thia may be launched by sensor status change. status lock is necessary because these happen from diff...
def _do_change_status(self, status, force=False): """ This function is called by - set_status - _update_program_stack if active program is being changed - thia may be launched by sensor status change. status lock is necessary because these happen from diff...
[ "This", "function", "is", "called", "by", "-", "set_status", "-", "_update_program_stack", "if", "active", "program", "is", "being", "changed", "-", "thia", "may", "be", "launched", "by", "sensor", "status", "change", ".", "status", "lock", "is", "necessary", ...
tuomas2/automate
python
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/statusobject.py#L354-L366
[ "def", "_do_change_status", "(", "self", ",", "status", ",", "force", "=", "False", ")", ":", "self", ".", "system", ".", "worker_thread", ".", "put", "(", "DummyStatusWorkerTask", "(", "self", ".", "_request_status_change_in_queue", ",", "status", ",", "force...
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
train
AbstractSensor.set_status
Compatibility to actuator class. Also :class:`~automate.callables.builtin_callables.SetStatus` callable can be used for sensors too, if so desired.
src/automate/statusobject.py
def set_status(self, status, origin=None, force=False): """ Compatibility to actuator class. Also :class:`~automate.callables.builtin_callables.SetStatus` callable can be used for sensors too, if so desired. """ if status != self.default: self._se...
def set_status(self, status, origin=None, force=False): """ Compatibility to actuator class. Also :class:`~automate.callables.builtin_callables.SetStatus` callable can be used for sensors too, if so desired. """ if status != self.default: self._se...
[ "Compatibility", "to", "actuator", "class", ".", "Also", ":", "class", ":", "~automate", ".", "callables", ".", "builtin_callables", ".", "SetStatus", "callable", "can", "be", "used", "for", "sensors", "too", "if", "so", "desired", "." ]
tuomas2/automate
python
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/statusobject.py#L472-L485
[ "def", "set_status", "(", "self", ",", "status", ",", "origin", "=", "None", ",", "force", "=", "False", ")", ":", "if", "status", "!=", "self", ".", "default", ":", "self", ".", "_setup_reset_delay", "(", ")", "if", "self", ".", "status_filter", ":", ...
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
train
AbstractActuator.set_status
For programs, to set current status of the actuator. Each active program has its status in :attr:`.program_stack` dictionary and the highest priority is realized in the actuator
src/automate/statusobject.py
def set_status(self, status, origin=None, force=False): """ For programs, to set current status of the actuator. Each active program has its status in :attr:`.program_stack` dictionary and the highest priority is realized in the actuator """ if not self.slave and origin not in s...
def set_status(self, status, origin=None, force=False): """ For programs, to set current status of the actuator. Each active program has its status in :attr:`.program_stack` dictionary and the highest priority is realized in the actuator """ if not self.slave and origin not in s...
[ "For", "programs", "to", "set", "current", "status", "of", "the", "actuator", ".", "Each", "active", "program", "has", "its", "status", "in", ":", "attr", ":", ".", "program_stack", "dictionary", "and", "the", "highest", "priority", "is", "realized", "in", ...
tuomas2/automate
python
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/statusobject.py#L555-L576
[ "def", "set_status", "(", "self", ",", "status", ",", "origin", "=", "None", ",", "force", "=", "False", ")", ":", "if", "not", "self", ".", "slave", "and", "origin", "not", "in", "self", ".", "program_stack", ":", "raise", "ValueError", "(", "'Status ...
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
train
AbstractActuator.activate_program
Called by program which desires to manipulate this actuator, when it is activated.
src/automate/statusobject.py
def activate_program(self, program): """ Called by program which desires to manipulate this actuator, when it is activated. """ self.logger.debug("activate_program %s", program) if program in self.program_stack: return with self._program_lock: ...
def activate_program(self, program): """ Called by program which desires to manipulate this actuator, when it is activated. """ self.logger.debug("activate_program %s", program) if program in self.program_stack: return with self._program_lock: ...
[ "Called", "by", "program", "which", "desires", "to", "manipulate", "this", "actuator", "when", "it", "is", "activated", "." ]
tuomas2/automate
python
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/statusobject.py#L578-L589
[ "def", "activate_program", "(", "self", ",", "program", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"activate_program %s\"", ",", "program", ")", "if", "program", "in", "self", ".", "program_stack", ":", "return", "with", "self", ".", "_program_loc...
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
train
AbstractActuator.deactivate_program
Called by program, when it is deactivated.
src/automate/statusobject.py
def deactivate_program(self, program): """ Called by program, when it is deactivated. """ self.logger.debug("deactivate_program %s", program) with self._program_lock: self.logger.debug("deactivate_program got through %s", program) if program not in se...
def deactivate_program(self, program): """ Called by program, when it is deactivated. """ self.logger.debug("deactivate_program %s", program) with self._program_lock: self.logger.debug("deactivate_program got through %s", program) if program not in se...
[ "Called", "by", "program", "when", "it", "is", "deactivated", "." ]
tuomas2/automate
python
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/statusobject.py#L591-L605
[ "def", "deactivate_program", "(", "self", ",", "program", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"deactivate_program %s\"", ",", "program", ")", "with", "self", ".", "_program_lock", ":", "self", ".", "logger", ".", "debug", "(", "\"deactivate...
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
train
stream_logs
Stream logs from a Docker container within a timeout. :param ~docker.models.containers.Container container: Container who's log lines to stream. :param timeout: Timeout value in seconds. :param logs_kwargs: Additional keyword arguments to pass to ``container.logs()``. For ex...
seaworthy/stream/logs.py
def stream_logs(container, timeout=10.0, **logs_kwargs): """ Stream logs from a Docker container within a timeout. :param ~docker.models.containers.Container container: Container who's log lines to stream. :param timeout: Timeout value in seconds. :param logs_kwargs: Additio...
def stream_logs(container, timeout=10.0, **logs_kwargs): """ Stream logs from a Docker container within a timeout. :param ~docker.models.containers.Container container: Container who's log lines to stream. :param timeout: Timeout value in seconds. :param logs_kwargs: Additio...
[ "Stream", "logs", "from", "a", "Docker", "container", "within", "a", "timeout", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/stream/logs.py#L8-L26
[ "def", "stream_logs", "(", "container", ",", "timeout", "=", "10.0", ",", "*", "*", "logs_kwargs", ")", ":", "stream", "=", "container", ".", "logs", "(", "stream", "=", "True", ",", "*", "*", "logs_kwargs", ")", "return", "stream_timeout", "(", "stream"...
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
wait_for_logs_matching
Wait for matching log line(s) from the given container by streaming the container's stdout and/or stderr outputs. Each log line is decoded and any trailing whitespace is stripped before the line is matched. :param ~docker.models.containers.Container container: Container who's log lines to wait...
seaworthy/stream/logs.py
def wait_for_logs_matching(container, matcher, timeout=10, encoding='utf-8', **logs_kwargs): """ Wait for matching log line(s) from the given container by streaming the container's stdout and/or stderr outputs. Each log line is decoded and any trailing whitespace is stripped ...
def wait_for_logs_matching(container, matcher, timeout=10, encoding='utf-8', **logs_kwargs): """ Wait for matching log line(s) from the given container by streaming the container's stdout and/or stderr outputs. Each log line is decoded and any trailing whitespace is stripped ...
[ "Wait", "for", "matching", "log", "line", "(", "s", ")", "from", "the", "given", "container", "by", "streaming", "the", "container", "s", "stdout", "and", "/", "or", "stderr", "outputs", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/stream/logs.py#L29-L79
[ "def", "wait_for_logs_matching", "(", "container", ",", "matcher", ",", "timeout", "=", "10", ",", "encoding", "=", "'utf-8'", ",", "*", "*", "logs_kwargs", ")", ":", "try", ":", "for", "line", "in", "stream_logs", "(", "container", ",", "timeout", "=", ...
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
fetch_image
Fetch an image if it isn't already present. This works like ``docker pull`` and will pull the tag ``latest`` if no tag is specified in the image name.
seaworthy/helpers.py
def fetch_image(client, name): """ Fetch an image if it isn't already present. This works like ``docker pull`` and will pull the tag ``latest`` if no tag is specified in the image name. """ try: image = client.images.get(name) except docker.errors.ImageNotFound: name, tag = ...
def fetch_image(client, name): """ Fetch an image if it isn't already present. This works like ``docker pull`` and will pull the tag ``latest`` if no tag is specified in the image name. """ try: image = client.images.get(name) except docker.errors.ImageNotFound: name, tag = ...
[ "Fetch", "an", "image", "if", "it", "isn", "t", "already", "present", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/helpers.py#L27-L44
[ "def", "fetch_image", "(", "client", ",", "name", ")", ":", "try", ":", "image", "=", "client", ".", "images", ".", "get", "(", "name", ")", "except", "docker", ".", "errors", ".", "ImageNotFound", ":", "name", ",", "tag", "=", "_parse_image_tag", "(",...
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
_HelperBase._get_id_and_model
Get both the model and ID of an object that could be an ID or a model. :param id_or_model: The object that could be an ID string or a model object. :param model_collection: The collection to which the model belongs.
seaworthy/helpers.py
def _get_id_and_model(self, id_or_model): """ Get both the model and ID of an object that could be an ID or a model. :param id_or_model: The object that could be an ID string or a model object. :param model_collection: The collection to which the model belongs. ...
def _get_id_and_model(self, id_or_model): """ Get both the model and ID of an object that could be an ID or a model. :param id_or_model: The object that could be an ID string or a model object. :param model_collection: The collection to which the model belongs. ...
[ "Get", "both", "the", "model", "and", "ID", "of", "an", "object", "that", "could", "be", "an", "ID", "or", "a", "model", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/helpers.py#L82-L100
[ "def", "_get_id_and_model", "(", "self", ",", "id_or_model", ")", ":", "if", "isinstance", "(", "id_or_model", ",", "self", ".", "collection", ".", "model", ")", ":", "model", "=", "id_or_model", "elif", "isinstance", "(", "id_or_model", ",", "str", ")", "...
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
_HelperBase.create
Create an instance of this resource type.
seaworthy/helpers.py
def create(self, name, *args, **kwargs): """ Create an instance of this resource type. """ resource_name = self._resource_name(name) log.info( "Creating {} '{}'...".format(self._model_name, resource_name)) resource = self.collection.create(*args, name=resource...
def create(self, name, *args, **kwargs): """ Create an instance of this resource type. """ resource_name = self._resource_name(name) log.info( "Creating {} '{}'...".format(self._model_name, resource_name)) resource = self.collection.create(*args, name=resource...
[ "Create", "an", "instance", "of", "this", "resource", "type", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/helpers.py#L102-L111
[ "def", "create", "(", "self", ",", "name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "resource_name", "=", "self", ".", "_resource_name", "(", "name", ")", "log", ".", "info", "(", "\"Creating {} '{}'...\"", ".", "format", "(", "self", ".", ...
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
_HelperBase.remove
Remove an instance of this resource type.
seaworthy/helpers.py
def remove(self, resource, **kwargs): """ Remove an instance of this resource type. """ log.info( "Removing {} '{}'...".format(self._model_name, resource.name)) resource.remove(**kwargs) self._ids.remove(resource.id)
def remove(self, resource, **kwargs): """ Remove an instance of this resource type. """ log.info( "Removing {} '{}'...".format(self._model_name, resource.name)) resource.remove(**kwargs) self._ids.remove(resource.id)
[ "Remove", "an", "instance", "of", "this", "resource", "type", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/helpers.py#L113-L120
[ "def", "remove", "(", "self", ",", "resource", ",", "*", "*", "kwargs", ")", ":", "log", ".", "info", "(", "\"Removing {} '{}'...\"", ".", "format", "(", "self", ".", "_model_name", ",", "resource", ".", "name", ")", ")", "resource", ".", "remove", "("...
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
ContainerHelper.create
Create a new container. :param name: The name for the container. This will be prefixed with the namespace. :param image: The image tag or image object to create the container from. :param network: The network to connect the container to. The conta...
seaworthy/helpers.py
def create(self, name, image, fetch_image=False, network=None, volumes={}, **kwargs): """ Create a new container. :param name: The name for the container. This will be prefixed with the namespace. :param image: The image tag or image ob...
def create(self, name, image, fetch_image=False, network=None, volumes={}, **kwargs): """ Create a new container. :param name: The name for the container. This will be prefixed with the namespace. :param image: The image tag or image ob...
[ "Create", "a", "new", "container", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/helpers.py#L155-L213
[ "def", "create", "(", "self", ",", "name", ",", "image", ",", "fetch_image", "=", "False", ",", "network", "=", "None", ",", "volumes", "=", "{", "}", ",", "*", "*", "kwargs", ")", ":", "create_kwargs", "=", "{", "'detach'", ":", "True", ",", "}", ...
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
ContainerHelper.remove
Remove a container. :param container: The container to remove. :param force: Whether to force the removal of the container, even if it is running. Note that this defaults to True, unlike the Docker default. :param volumes: Whether to remove any vo...
seaworthy/helpers.py
def remove(self, container, force=True, volumes=True): """ Remove a container. :param container: The container to remove. :param force: Whether to force the removal of the container, even if it is running. Note that this defaults to True, unlike the Docker ...
def remove(self, container, force=True, volumes=True): """ Remove a container. :param container: The container to remove. :param force: Whether to force the removal of the container, even if it is running. Note that this defaults to True, unlike the Docker ...
[ "Remove", "a", "container", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/helpers.py#L266-L283
[ "def", "remove", "(", "self", ",", "container", ",", "force", "=", "True", ",", "volumes", "=", "True", ")", ":", "super", "(", ")", ".", "remove", "(", "container", ",", "force", "=", "force", ",", "v", "=", "volumes", ")" ]
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
NetworkHelper.get_default
Get the default bridge network that containers are connected to if no other network options are specified. :param create: Whether or not to create the network if it doesn't already exist.
seaworthy/helpers.py
def get_default(self, create=True): """ Get the default bridge network that containers are connected to if no other network options are specified. :param create: Whether or not to create the network if it doesn't already exist. """ if self._default_network is...
def get_default(self, create=True): """ Get the default bridge network that containers are connected to if no other network options are specified. :param create: Whether or not to create the network if it doesn't already exist. """ if self._default_network is...
[ "Get", "the", "default", "bridge", "network", "that", "containers", "are", "connected", "to", "if", "no", "other", "network", "options", "are", "specified", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/helpers.py#L326-L338
[ "def", "get_default", "(", "self", ",", "create", "=", "True", ")", ":", "if", "self", ".", "_default_network", "is", "None", "and", "create", ":", "log", ".", "debug", "(", "\"Creating default network...\"", ")", "self", ".", "_default_network", "=", "self"...
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
NetworkHelper.create
Create a new network. :param name: The name for the network. This will be prefixed with the namespace. :param check_duplicate: Whether or not to check for networks with the same name. Docker allows the creation of multiple networks with the same name (unlike ...
seaworthy/helpers.py
def create(self, name, check_duplicate=True, **kwargs): """ Create a new network. :param name: The name for the network. This will be prefixed with the namespace. :param check_duplicate: Whether or not to check for networks with the same name. Docker ...
def create(self, name, check_duplicate=True, **kwargs): """ Create a new network. :param name: The name for the network. This will be prefixed with the namespace. :param check_duplicate: Whether or not to check for networks with the same name. Docker ...
[ "Create", "a", "new", "network", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/helpers.py#L340-L356
[ "def", "create", "(", "self", ",", "name", ",", "check_duplicate", "=", "True", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", ")", ".", "create", "(", "name", ",", "check_duplicate", "=", "check_duplicate", ",", "*", "*", "kwargs", ")" ]
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
DockerHelper._helper_for_model
Get the helper for a given type of Docker model. For use by resource definitions.
seaworthy/helpers.py
def _helper_for_model(self, model_type): """ Get the helper for a given type of Docker model. For use by resource definitions. """ if model_type is models.containers.Container: return self.containers if model_type is models.images.Image: return sel...
def _helper_for_model(self, model_type): """ Get the helper for a given type of Docker model. For use by resource definitions. """ if model_type is models.containers.Container: return self.containers if model_type is models.images.Image: return sel...
[ "Get", "the", "helper", "for", "a", "given", "type", "of", "Docker", "model", ".", "For", "use", "by", "resource", "definitions", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/helpers.py#L398-L412
[ "def", "_helper_for_model", "(", "self", ",", "model_type", ")", ":", "if", "model_type", "is", "models", ".", "containers", ".", "Container", ":", "return", "self", ".", "containers", "if", "model_type", "is", "models", ".", "images", ".", "Image", ":", "...
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
DockerHelper.teardown
Clean up all resources when we're done with them.
seaworthy/helpers.py
def teardown(self): """ Clean up all resources when we're done with them. """ self.containers._teardown() self.networks._teardown() self.volumes._teardown() # We need to close the underlying APIClient explicitly to avoid # ResourceWarnings from unclosed H...
def teardown(self): """ Clean up all resources when we're done with them. """ self.containers._teardown() self.networks._teardown() self.volumes._teardown() # We need to close the underlying APIClient explicitly to avoid # ResourceWarnings from unclosed H...
[ "Clean", "up", "all", "resources", "when", "we", "re", "done", "with", "them", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/helpers.py#L414-L424
[ "def", "teardown", "(", "self", ")", ":", "self", ".", "containers", ".", "_teardown", "(", ")", "self", ".", "networks", ".", "_teardown", "(", ")", "self", ".", "volumes", ".", "_teardown", "(", ")", "# We need to close the underlying APIClient explicitly to a...
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
RedisContainer.exec_redis_cli
Execute a ``redis-cli`` command inside a running container. :param command: the command to run :param args: a list of args for the command :param db: the db number to query (default ``0``) :param redis_cli_opts: a list of extra options to pass to ``redis-cli`` :returns: a tuple ...
seaworthy/containers/redis.py
def exec_redis_cli(self, command, args=[], db=0, redis_cli_opts=[]): """ Execute a ``redis-cli`` command inside a running container. :param command: the command to run :param args: a list of args for the command :param db: the db number to query (default ``0``) :param re...
def exec_redis_cli(self, command, args=[], db=0, redis_cli_opts=[]): """ Execute a ``redis-cli`` command inside a running container. :param command: the command to run :param args: a list of args for the command :param db: the db number to query (default ``0``) :param re...
[ "Execute", "a", "redis", "-", "cli", "command", "inside", "a", "running", "container", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/containers/redis.py#L40-L52
[ "def", "exec_redis_cli", "(", "self", ",", "command", ",", "args", "=", "[", "]", ",", "db", "=", "0", ",", "redis_cli_opts", "=", "[", "]", ")", ":", "cli_opts", "=", "[", "'-n'", ",", "str", "(", "db", ")", "]", "+", "redis_cli_opts", "cmd", "=...
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
RedisContainer.list_keys
Run the ``KEYS`` command and return the list of matching keys. :param pattern: the pattern to filter keys by (default ``*``) :param db: the db number to query (default ``0``)
seaworthy/containers/redis.py
def list_keys(self, pattern='*', db=0): """ Run the ``KEYS`` command and return the list of matching keys. :param pattern: the pattern to filter keys by (default ``*``) :param db: the db number to query (default ``0``) """ lines = output_lines(self.exec_redis_cli('KEYS',...
def list_keys(self, pattern='*', db=0): """ Run the ``KEYS`` command and return the list of matching keys. :param pattern: the pattern to filter keys by (default ``*``) :param db: the db number to query (default ``0``) """ lines = output_lines(self.exec_redis_cli('KEYS',...
[ "Run", "the", "KEYS", "command", "and", "return", "the", "list", "of", "matching", "keys", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/containers/redis.py#L54-L62
[ "def", "list_keys", "(", "self", ",", "pattern", "=", "'*'", ",", "db", "=", "0", ")", ":", "lines", "=", "output_lines", "(", "self", ".", "exec_redis_cli", "(", "'KEYS'", ",", "[", "pattern", "]", ",", "db", "=", "db", ")", ")", "return", "[", ...
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
threaded
uses thread_init as a decorator-style
src/automate/common.py
def threaded(system, func, *args, **kwargs): """ uses thread_init as a decorator-style """ @wraps(func) def wrapper(*args, **kwargs): try: return func(*args, **kwargs) except Exception as e: if system.raven_client: system.raven_client.captureException(...
def threaded(system, func, *args, **kwargs): """ uses thread_init as a decorator-style """ @wraps(func) def wrapper(*args, **kwargs): try: return func(*args, **kwargs) except Exception as e: if system.raven_client: system.raven_client.captureException(...
[ "uses", "thread_init", "as", "a", "decorator", "-", "style" ]
tuomas2/automate
python
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/common.py#L96-L108
[ "def", "threaded", "(", "system", ",", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "func", "(", "*", ...
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
train
list_container_processes
List the processes running inside a container. We use an exec rather than `container.top()` because we want to run 'ps' inside the container. This is because we want to get PIDs and usernames in the container's namespaces. `container.top()` uses 'ps' from outside the container in the host's namespaces. ...
seaworthy/ps.py
def list_container_processes(container): """ List the processes running inside a container. We use an exec rather than `container.top()` because we want to run 'ps' inside the container. This is because we want to get PIDs and usernames in the container's namespaces. `container.top()` uses 'ps' from...
def list_container_processes(container): """ List the processes running inside a container. We use an exec rather than `container.top()` because we want to run 'ps' inside the container. This is because we want to get PIDs and usernames in the container's namespaces. `container.top()` uses 'ps' from...
[ "List", "the", "processes", "running", "inside", "a", "container", ".", "We", "use", "an", "exec", "rather", "than", "container", ".", "top", "()", "because", "we", "want", "to", "run", "ps", "inside", "the", "container", ".", "This", "is", "because", "w...
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/ps.py#L36-L66
[ "def", "list_container_processes", "(", "container", ")", ":", "cmd", "=", "[", "'ps'", ",", "'ax'", ",", "'-o'", ",", "','", ".", "join", "(", "PsRow", ".", "columns", "(", ")", ")", "]", "ps_lines", "=", "output_lines", "(", "container", ".", "exec_r...
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
build_process_tree
Build a tree structure from a list of PsRow objects. :param ps_rows: a list of PsRow objects :return: a PsTree object
seaworthy/ps.py
def build_process_tree(ps_rows): """ Build a tree structure from a list of PsRow objects. :param ps_rows: a list of PsRow objects :return: a PsTree object """ ps_tree = None for row in ps_rows: if row.ppid == 0: if ps_tree is not None: raise PsException("T...
def build_process_tree(ps_rows): """ Build a tree structure from a list of PsRow objects. :param ps_rows: a list of PsRow objects :return: a PsTree object """ ps_tree = None for row in ps_rows: if row.ppid == 0: if ps_tree is not None: raise PsException("T...
[ "Build", "a", "tree", "structure", "from", "a", "list", "of", "PsRow", "objects", ".", ":", "param", "ps_rows", ":", "a", "list", "of", "PsRow", "objects", ":", "return", ":", "a", "PsTree", "object" ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/ps.py#L95-L113
[ "def", "build_process_tree", "(", "ps_rows", ")", ":", "ps_tree", "=", "None", "for", "row", "in", "ps_rows", ":", "if", "row", ".", "ppid", "==", "0", ":", "if", "ps_tree", "is", "not", "None", ":", "raise", "PsException", "(", "\"Too many process tree ro...
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
cmd_balance
Посмотреть баланс основного счёта.
rock_cli/cli/balance.py
def cmd_balance(): """ Посмотреть баланс основного счёта. """ r = rocket.operations.cool_feed.get(params={"per_page": 1}) r = handle_error(r) j = r.json() template = "".join([ click.style("{rur} {code}, ", fg="green", bold=True), "{miles} рокетрублей"]) click.echo(templa...
def cmd_balance(): """ Посмотреть баланс основного счёта. """ r = rocket.operations.cool_feed.get(params={"per_page": 1}) r = handle_error(r) j = r.json() template = "".join([ click.style("{rur} {code}, ", fg="green", bold=True), "{miles} рокетрублей"]) click.echo(templa...
[ "Посмотреть", "баланс", "основного", "счёта", "." ]
notpushkin/rock
python
https://github.com/notpushkin/rock/blob/c1451a7604b462c19e4929f0eb171cbcf23e50ab/rock_cli/cli/balance.py#L6-L20
[ "def", "cmd_balance", "(", ")", ":", "r", "=", "rocket", ".", "operations", ".", "cool_feed", ".", "get", "(", "params", "=", "{", "\"per_page\"", ":", "1", "}", ")", "r", "=", "handle_error", "(", "r", ")", "j", "=", "r", ".", "json", "(", ")", ...
c1451a7604b462c19e4929f0eb171cbcf23e50ab
train
OrderedMatcher.match
Return ``True`` if the expected matchers are matched in the expected order, otherwise ``False``.
seaworthy/stream/matchers.py
def match(self, item): """ Return ``True`` if the expected matchers are matched in the expected order, otherwise ``False``. """ if self._position == len(self._matchers): raise RuntimeError('Matcher exhausted, no more matchers to use') matcher = self._matchers...
def match(self, item): """ Return ``True`` if the expected matchers are matched in the expected order, otherwise ``False``. """ if self._position == len(self._matchers): raise RuntimeError('Matcher exhausted, no more matchers to use') matcher = self._matchers...
[ "Return", "True", "if", "the", "expected", "matchers", "are", "matched", "in", "the", "expected", "order", "otherwise", "False", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/stream/matchers.py#L81-L97
[ "def", "match", "(", "self", ",", "item", ")", ":", "if", "self", ".", "_position", "==", "len", "(", "self", ".", "_matchers", ")", ":", "raise", "RuntimeError", "(", "'Matcher exhausted, no more matchers to use'", ")", "matcher", "=", "self", ".", "_matche...
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
OrderedMatcher.args_str
Return an args string for the repr.
seaworthy/stream/matchers.py
def args_str(self): """ Return an args string for the repr. """ matched = [str(m) for m in self._matchers[:self._position]] unmatched = [str(m) for m in self._matchers[self._position:]] return 'matched=[{}], unmatched=[{}]'.format( ', '.join(matched), ', '.joi...
def args_str(self): """ Return an args string for the repr. """ matched = [str(m) for m in self._matchers[:self._position]] unmatched = [str(m) for m in self._matchers[self._position:]] return 'matched=[{}], unmatched=[{}]'.format( ', '.join(matched), ', '.joi...
[ "Return", "an", "args", "string", "for", "the", "repr", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/stream/matchers.py#L99-L106
[ "def", "args_str", "(", "self", ")", ":", "matched", "=", "[", "str", "(", "m", ")", "for", "m", "in", "self", ".", "_matchers", "[", ":", "self", ".", "_position", "]", "]", "unmatched", "=", "[", "str", "(", "m", ")", "for", "m", "in", "self"...
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
UnorderedMatcher.match
Return ``True`` if the expected matchers are matched in any order, otherwise ``False``.
seaworthy/stream/matchers.py
def match(self, item): """ Return ``True`` if the expected matchers are matched in any order, otherwise ``False``. """ if not self._unused_matchers: raise RuntimeError('Matcher exhausted, no more matchers to use') for matcher in self._unused_matchers: ...
def match(self, item): """ Return ``True`` if the expected matchers are matched in any order, otherwise ``False``. """ if not self._unused_matchers: raise RuntimeError('Matcher exhausted, no more matchers to use') for matcher in self._unused_matchers: ...
[ "Return", "True", "if", "the", "expected", "matchers", "are", "matched", "in", "any", "order", "otherwise", "False", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/stream/matchers.py#L129-L146
[ "def", "match", "(", "self", ",", "item", ")", ":", "if", "not", "self", ".", "_unused_matchers", ":", "raise", "RuntimeError", "(", "'Matcher exhausted, no more matchers to use'", ")", "for", "matcher", "in", "self", ".", "_unused_matchers", ":", "if", "matcher...
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
UnorderedMatcher.args_str
Return an args string for the repr.
seaworthy/stream/matchers.py
def args_str(self): """ Return an args string for the repr. """ matched = [str(m) for m in self._used_matchers] unmatched = [str(m) for m in self._unused_matchers] return 'matched=[{}], unmatched=[{}]'.format( ', '.join(matched), ', '.join(unmatched))
def args_str(self): """ Return an args string for the repr. """ matched = [str(m) for m in self._used_matchers] unmatched = [str(m) for m in self._unused_matchers] return 'matched=[{}], unmatched=[{}]'.format( ', '.join(matched), ', '.join(unmatched))
[ "Return", "an", "args", "string", "for", "the", "repr", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/stream/matchers.py#L148-L155
[ "def", "args_str", "(", "self", ")", ":", "matched", "=", "[", "str", "(", "m", ")", "for", "m", "in", "self", ".", "_used_matchers", "]", "unmatched", "=", "[", "str", "(", "m", ")", "for", "m", "in", "self", ".", "_unused_matchers", "]", "return"...
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
DataImage.moresane
Primary method for wavelet analysis and subsequent deconvolution. INPUTS: subregion (default=None): Size, in pixels, of the central region to be analyzed and deconvolved. scale_count (default=None): Maximum scale to be considered - maximum scale considered during ...
pymoresane/main.py
def moresane(self, subregion=None, scale_count=None, sigma_level=4, loop_gain=0.1, tolerance=0.75, accuracy=1e-6, major_loop_miter=100, minor_loop_miter=30, all_on_gpu=False, decom_mode="ser", core_count=1, conv_device='cpu', conv_mode='linear', extraction_mode='cpu', enforce_positivit...
def moresane(self, subregion=None, scale_count=None, sigma_level=4, loop_gain=0.1, tolerance=0.75, accuracy=1e-6, major_loop_miter=100, minor_loop_miter=30, all_on_gpu=False, decom_mode="ser", core_count=1, conv_device='cpu', conv_mode='linear', extraction_mode='cpu', enforce_positivit...
[ "Primary", "method", "for", "wavelet", "analysis", "and", "subsequent", "deconvolution", "." ]
ratt-ru/PyMORESANE
python
https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/main.py#L53-L521
[ "def", "moresane", "(", "self", ",", "subregion", "=", "None", ",", "scale_count", "=", "None", ",", "sigma_level", "=", "4", ",", "loop_gain", "=", "0.1", ",", "tolerance", "=", "0.75", ",", "accuracy", "=", "1e-6", ",", "major_loop_miter", "=", "100", ...
b024591ad0bbb69320d08841f28a2c27f62ae1af
train
DataImage.moresane_by_scale
Extension of the MORESANE algorithm. This takes a scale-by-scale approach, attempting to remove all sources at the lower scales before moving onto the higher ones. At each step the algorithm may return to previous scales to remove the sources uncovered by the deconvolution. INPUTS: star...
pymoresane/main.py
def moresane_by_scale(self, start_scale=1, stop_scale=20, subregion=None, sigma_level=4, loop_gain=0.1, tolerance=0.75, accuracy=1e-6, major_loop_miter=100, minor_loop_miter=30, all_on_gpu=False, decom_mode="ser", core_count=1, conv_device='cpu', conv_mode='linear', e...
def moresane_by_scale(self, start_scale=1, stop_scale=20, subregion=None, sigma_level=4, loop_gain=0.1, tolerance=0.75, accuracy=1e-6, major_loop_miter=100, minor_loop_miter=30, all_on_gpu=False, decom_mode="ser", core_count=1, conv_device='cpu', conv_mode='linear', e...
[ "Extension", "of", "the", "MORESANE", "algorithm", ".", "This", "takes", "a", "scale", "-", "by", "-", "scale", "approach", "attempting", "to", "remove", "all", "sources", "at", "the", "lower", "scales", "before", "moving", "onto", "the", "higher", "ones", ...
ratt-ru/PyMORESANE
python
https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/main.py#L523-L599
[ "def", "moresane_by_scale", "(", "self", ",", "start_scale", "=", "1", ",", "stop_scale", "=", "20", ",", "subregion", "=", "None", ",", "sigma_level", "=", "4", ",", "loop_gain", "=", "0.1", ",", "tolerance", "=", "0.75", ",", "accuracy", "=", "1e-6", ...
b024591ad0bbb69320d08841f28a2c27f62ae1af
train
DataImage.restore
This method constructs the restoring beam and then adds the convolution to the residual.
pymoresane/main.py
def restore(self): """ This method constructs the restoring beam and then adds the convolution to the residual. """ clean_beam, beam_params = beam_fit(self.psf_data, self.cdelt1, self.cdelt2) if np.all(np.array(self.psf_data_shape)==2*np.array(self.dirty_data_shape)): ...
def restore(self): """ This method constructs the restoring beam and then adds the convolution to the residual. """ clean_beam, beam_params = beam_fit(self.psf_data, self.cdelt1, self.cdelt2) if np.all(np.array(self.psf_data_shape)==2*np.array(self.dirty_data_shape)): ...
[ "This", "method", "constructs", "the", "restoring", "beam", "and", "then", "adds", "the", "convolution", "to", "the", "residual", "." ]
ratt-ru/PyMORESANE
python
https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/main.py#L601-L616
[ "def", "restore", "(", "self", ")", ":", "clean_beam", ",", "beam_params", "=", "beam_fit", "(", "self", ".", "psf_data", ",", "self", ".", "cdelt1", ",", "self", ".", "cdelt2", ")", "if", "np", ".", "all", "(", "np", ".", "array", "(", "self", "."...
b024591ad0bbb69320d08841f28a2c27f62ae1af
train
DataImage.handle_input
This method tries to ensure that the input data has the correct dimensions. INPUTS: input_hdr (no default) Header from which data shape is to be extracted.
pymoresane/main.py
def handle_input(self, input_hdr): """ This method tries to ensure that the input data has the correct dimensions. INPUTS: input_hdr (no default) Header from which data shape is to be extracted. """ input_slice = input_hdr['NAXIS']*[0] for i in range(input...
def handle_input(self, input_hdr): """ This method tries to ensure that the input data has the correct dimensions. INPUTS: input_hdr (no default) Header from which data shape is to be extracted. """ input_slice = input_hdr['NAXIS']*[0] for i in range(input...
[ "This", "method", "tries", "to", "ensure", "that", "the", "input", "data", "has", "the", "correct", "dimensions", "." ]
ratt-ru/PyMORESANE
python
https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/main.py#L618-L634
[ "def", "handle_input", "(", "self", ",", "input_hdr", ")", ":", "input_slice", "=", "input_hdr", "[", "'NAXIS'", "]", "*", "[", "0", "]", "for", "i", "in", "range", "(", "input_hdr", "[", "'NAXIS'", "]", ")", ":", "if", "input_hdr", "[", "'CTYPE%d'", ...
b024591ad0bbb69320d08841f28a2c27f62ae1af
train
DataImage.save_fits
This method simply saves the model components and the residual. INPUTS: data (no default) Data which is to be saved. name (no default) File name for new .fits file. Will overwrite.
pymoresane/main.py
def save_fits(self, data, name): """ This method simply saves the model components and the residual. INPUTS: data (no default) Data which is to be saved. name (no default) File name for new .fits file. Will overwrite. """ data = data.reshape(1, 1, dat...
def save_fits(self, data, name): """ This method simply saves the model components and the residual. INPUTS: data (no default) Data which is to be saved. name (no default) File name for new .fits file. Will overwrite. """ data = data.reshape(1, 1, dat...
[ "This", "method", "simply", "saves", "the", "model", "components", "and", "the", "residual", "." ]
ratt-ru/PyMORESANE
python
https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/main.py#L636-L646
[ "def", "save_fits", "(", "self", ",", "data", ",", "name", ")", ":", "data", "=", "data", ".", "reshape", "(", "1", ",", "1", ",", "data", ".", "shape", "[", "0", "]", ",", "data", ".", "shape", "[", "0", "]", ")", "new_file", "=", "pyfits", ...
b024591ad0bbb69320d08841f28a2c27f62ae1af
train
DataImage.make_logger
Convenience function which creates a logger for the module. INPUTS: level (default="INFO"): Minimum log level for logged/streamed messages. OUTPUTS: logger Logger for the function. NOTE: Must be bound to variable named logger.
pymoresane/main.py
def make_logger(self, level="INFO"): """ Convenience function which creates a logger for the module. INPUTS: level (default="INFO"): Minimum log level for logged/streamed messages. OUTPUTS: logger Logger for the function. NOTE: Must be bound to ...
def make_logger(self, level="INFO"): """ Convenience function which creates a logger for the module. INPUTS: level (default="INFO"): Minimum log level for logged/streamed messages. OUTPUTS: logger Logger for the function. NOTE: Must be bound to ...
[ "Convenience", "function", "which", "creates", "a", "logger", "for", "the", "module", "." ]
ratt-ru/PyMORESANE
python
https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/main.py#L648-L676
[ "def", "make_logger", "(", "self", ",", "level", "=", "\"INFO\"", ")", ":", "level", "=", "getattr", "(", "logging", ",", "level", ".", "upper", "(", ")", ")", "logger", "=", "logging", ".", "getLogger", "(", "__name__", ")", "logger", ".", "setLevel",...
b024591ad0bbb69320d08841f28a2c27f62ae1af
train
TextUIService.ls
List actuators, programs or sensors (what is string)
src/automate/services/textui.py
def ls(self, what): """List actuators, programs or sensors (what is string)""" for i in getattr(self.system, what): self.logger.info('%s: %s: %s', i.__class__.__name__, i, i.status) return True
def ls(self, what): """List actuators, programs or sensors (what is string)""" for i in getattr(self.system, what): self.logger.info('%s: %s: %s', i.__class__.__name__, i, i.status) return True
[ "List", "actuators", "programs", "or", "sensors", "(", "what", "is", "string", ")" ]
tuomas2/automate
python
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/services/textui.py#L65-L69
[ "def", "ls", "(", "self", ",", "what", ")", ":", "for", "i", "in", "getattr", "(", "self", ".", "system", ",", "what", ")", ":", "self", ".", "logger", ".", "info", "(", "'%s: %s: %s'", ",", "i", ".", "__class__", ".", "__name__", ",", "i", ",", ...
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
train
TextUIService.help
Print Automate help if no parameter is given. Otherwise, act as pydoc.help()
src/automate/services/textui.py
def help(self, *args, **kwargs): """Print Automate help if no parameter is given. Otherwise, act as pydoc.help()""" if len(args) > 0 or len(kwargs) > 0: import pydoc pydoc.help(*args, **kwargs) else: hstr = helpstr for i in hstr.split("...
def help(self, *args, **kwargs): """Print Automate help if no parameter is given. Otherwise, act as pydoc.help()""" if len(args) > 0 or len(kwargs) > 0: import pydoc pydoc.help(*args, **kwargs) else: hstr = helpstr for i in hstr.split("...
[ "Print", "Automate", "help", "if", "no", "parameter", "is", "given", ".", "Otherwise", "act", "as", "pydoc", ".", "help", "()" ]
tuomas2/automate
python
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/services/textui.py#L83-L94
[ "def", "help", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "args", ")", ">", "0", "or", "len", "(", "kwargs", ")", ">", "0", ":", "import", "pydoc", "pydoc", ".", "help", "(", "*", "args", ",", "*", "...
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
train
TextUIService.text_ui
Start Text UI main loop
src/automate/services/textui.py
def text_ui(self): """ Start Text UI main loop """ self.logger.info("Starting command line interface") self.help() try: self.ipython_ui() except ImportError: self.fallback_ui() self.system.cleanup()
def text_ui(self): """ Start Text UI main loop """ self.logger.info("Starting command line interface") self.help() try: self.ipython_ui() except ImportError: self.fallback_ui() self.system.cleanup()
[ "Start", "Text", "UI", "main", "loop" ]
tuomas2/automate
python
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/services/textui.py#L96-L106
[ "def", "text_ui", "(", "self", ")", ":", "self", ".", "logger", ".", "info", "(", "\"Starting command line interface\"", ")", "self", ".", "help", "(", ")", "try", ":", "self", ".", "ipython_ui", "(", ")", "except", "ImportError", ":", "self", ".", "fall...
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
train
Connection._prepare_headers
Prepare headers for http communication. Return dict of header to be used in requests. Args: .. versionadded:: 0.3.2 **additional_headers**: (optional) Additional headers to be used with request Returns: Headers dict. Key and values are s...
pyseaweed/utils.py
def _prepare_headers(self, additional_headers=None, **kwargs): """Prepare headers for http communication. Return dict of header to be used in requests. Args: .. versionadded:: 0.3.2 **additional_headers**: (optional) Additional headers to be used wit...
def _prepare_headers(self, additional_headers=None, **kwargs): """Prepare headers for http communication. Return dict of header to be used in requests. Args: .. versionadded:: 0.3.2 **additional_headers**: (optional) Additional headers to be used wit...
[ "Prepare", "headers", "for", "http", "communication", "." ]
utek/pyseaweed
python
https://github.com/utek/pyseaweed/blob/218049329885425a2b8370157fa44952e64516be/pyseaweed/utils.py#L21-L39
[ "def", "_prepare_headers", "(", "self", ",", "additional_headers", "=", "None", ",", "*", "*", "kwargs", ")", ":", "user_agent", "=", "\"pyseaweed/{version}\"", ".", "format", "(", "version", "=", "__version__", ")", "headers", "=", "{", "\"User-Agent\"", ":",...
218049329885425a2b8370157fa44952e64516be
train
Connection.head
Returns response to http HEAD on provided url
pyseaweed/utils.py
def head(self, url, *args, **kwargs): """Returns response to http HEAD on provided url """ res = self._conn.head(url, headers=self._prepare_headers(**kwargs)) if res.status_code == 200: return res return None
def head(self, url, *args, **kwargs): """Returns response to http HEAD on provided url """ res = self._conn.head(url, headers=self._prepare_headers(**kwargs)) if res.status_code == 200: return res return None
[ "Returns", "response", "to", "http", "HEAD", "on", "provided", "url" ]
utek/pyseaweed
python
https://github.com/utek/pyseaweed/blob/218049329885425a2b8370157fa44952e64516be/pyseaweed/utils.py#L41-L48
[ "def", "head", "(", "self", ",", "url", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "res", "=", "self", ".", "_conn", ".", "head", "(", "url", ",", "headers", "=", "self", ".", "_prepare_headers", "(", "*", "*", "kwargs", ")", ")", "if...
218049329885425a2b8370157fa44952e64516be
train
Connection.get_data
Gets data from url as text Returns content under the provided url as text Args: **url**: address of the wanted data .. versionadded:: 0.3.2 **additional_headers**: (optional) Additional headers to be used with request Returns: ...
pyseaweed/utils.py
def get_data(self, url, *args, **kwargs): """Gets data from url as text Returns content under the provided url as text Args: **url**: address of the wanted data .. versionadded:: 0.3.2 **additional_headers**: (optional) Additional headers ...
def get_data(self, url, *args, **kwargs): """Gets data from url as text Returns content under the provided url as text Args: **url**: address of the wanted data .. versionadded:: 0.3.2 **additional_headers**: (optional) Additional headers ...
[ "Gets", "data", "from", "url", "as", "text" ]
utek/pyseaweed
python
https://github.com/utek/pyseaweed/blob/218049329885425a2b8370157fa44952e64516be/pyseaweed/utils.py#L50-L70
[ "def", "get_data", "(", "self", ",", "url", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "res", "=", "self", ".", "_conn", ".", "get", "(", "url", ",", "headers", "=", "self", ".", "_prepare_headers", "(", "*", "*", "kwargs", ")", ")", ...
218049329885425a2b8370157fa44952e64516be
train
Connection.get_raw_data
Gets data from url as bytes Returns content under the provided url as bytes ie. for binary data Args: **url**: address of the wanted data .. versionadded:: 0.3.2 **additional_headers**: (optional) Additional headers to be used with reque...
pyseaweed/utils.py
def get_raw_data(self, url, *args, **kwargs): """Gets data from url as bytes Returns content under the provided url as bytes ie. for binary data Args: **url**: address of the wanted data .. versionadded:: 0.3.2 **additional_headers**: (optional)...
def get_raw_data(self, url, *args, **kwargs): """Gets data from url as bytes Returns content under the provided url as bytes ie. for binary data Args: **url**: address of the wanted data .. versionadded:: 0.3.2 **additional_headers**: (optional)...
[ "Gets", "data", "from", "url", "as", "bytes" ]
utek/pyseaweed
python
https://github.com/utek/pyseaweed/blob/218049329885425a2b8370157fa44952e64516be/pyseaweed/utils.py#L72-L93
[ "def", "get_raw_data", "(", "self", ",", "url", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "res", "=", "self", ".", "_conn", ".", "get", "(", "url", ",", "headers", "=", "self", ".", "_prepare_headers", "(", "*", "*", "kwargs", ")", ")"...
218049329885425a2b8370157fa44952e64516be
train
Connection.post_file
Uploads file to provided url. Returns contents as text Args: **url**: address where to upload file **filename**: Name of the uploaded file **file_stream**: file like object to upload .. versionadded:: 0.3.2 **additional_headers**: (opt...
pyseaweed/utils.py
def post_file(self, url, filename, file_stream, *args, **kwargs): """Uploads file to provided url. Returns contents as text Args: **url**: address where to upload file **filename**: Name of the uploaded file **file_stream**: file like object to upload ...
def post_file(self, url, filename, file_stream, *args, **kwargs): """Uploads file to provided url. Returns contents as text Args: **url**: address where to upload file **filename**: Name of the uploaded file **file_stream**: file like object to upload ...
[ "Uploads", "file", "to", "provided", "url", "." ]
utek/pyseaweed
python
https://github.com/utek/pyseaweed/blob/218049329885425a2b8370157fa44952e64516be/pyseaweed/utils.py#L95-L119
[ "def", "post_file", "(", "self", ",", "url", ",", "filename", ",", "file_stream", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "res", "=", "self", ".", "_conn", ".", "post", "(", "url", ",", "files", "=", "{", "filename", ":", "file_stream"...
218049329885425a2b8370157fa44952e64516be
train
Connection.delete_data
Deletes data under provided url Returns status as boolean. Args: **url**: address of file to be deleted .. versionadded:: 0.3.2 **additional_headers**: (optional) Additional headers to be used with request Returns: Boolean. ...
pyseaweed/utils.py
def delete_data(self, url, *args, **kwargs): """Deletes data under provided url Returns status as boolean. Args: **url**: address of file to be deleted .. versionadded:: 0.3.2 **additional_headers**: (optional) Additional headers to be u...
def delete_data(self, url, *args, **kwargs): """Deletes data under provided url Returns status as boolean. Args: **url**: address of file to be deleted .. versionadded:: 0.3.2 **additional_headers**: (optional) Additional headers to be u...
[ "Deletes", "data", "under", "provided", "url" ]
utek/pyseaweed
python
https://github.com/utek/pyseaweed/blob/218049329885425a2b8370157fa44952e64516be/pyseaweed/utils.py#L121-L140
[ "def", "delete_data", "(", "self", ",", "url", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "res", "=", "self", ".", "_conn", ".", "delete", "(", "url", ",", "headers", "=", "self", ".", "_prepare_headers", "(", "*", "*", "kwargs", ")", "...
218049329885425a2b8370157fa44952e64516be
train
cmd_feed
Показывает последние операции в ленте.
rock_cli/cli/feed.py
def cmd_feed(): """ Показывает последние операции в ленте. """ r = rocket.operations.cool_feed.get() r = handle_error(r) j = r.json() lines = [] for date, operations in sorted(list(j["dates"].items())): lines += [[ click.style("===== %s =====" % date, fg="blue", bol...
def cmd_feed(): """ Показывает последние операции в ленте. """ r = rocket.operations.cool_feed.get() r = handle_error(r) j = r.json() lines = [] for date, operations in sorted(list(j["dates"].items())): lines += [[ click.style("===== %s =====" % date, fg="blue", bol...
[ "Показывает", "последние", "операции", "в", "ленте", "." ]
notpushkin/rock
python
https://github.com/notpushkin/rock/blob/c1451a7604b462c19e4929f0eb171cbcf23e50ab/rock_cli/cli/feed.py#L7-L30
[ "def", "cmd_feed", "(", ")", ":", "r", "=", "rocket", ".", "operations", ".", "cool_feed", ".", "get", "(", ")", "r", "=", "handle_error", "(", "r", ")", "j", "=", "r", ".", "json", "(", ")", "lines", "=", "[", "]", "for", "date", ",", "operati...
c1451a7604b462c19e4929f0eb171cbcf23e50ab
train
cmd_transfer
Перевести деньги на номер карты.
rock_cli/cli/transfer.py
def cmd_transfer(recipient, amount): """ Перевести деньги на номер карты. """ r = rocket.card2card.transfer.post(params={ "source_card": recipient, "amount": amount }) r = handle_error(r) j = r.json() if j["status"] == "approved": template = "".join([ ...
def cmd_transfer(recipient, amount): """ Перевести деньги на номер карты. """ r = rocket.card2card.transfer.post(params={ "source_card": recipient, "amount": amount }) r = handle_error(r) j = r.json() if j["status"] == "approved": template = "".join([ ...
[ "Перевести", "деньги", "на", "номер", "карты", "." ]
notpushkin/rock
python
https://github.com/notpushkin/rock/blob/c1451a7604b462c19e4929f0eb171cbcf23e50ab/rock_cli/cli/transfer.py#L10-L27
[ "def", "cmd_transfer", "(", "recipient", ",", "amount", ")", ":", "r", "=", "rocket", ".", "card2card", ".", "transfer", ".", "post", "(", "params", "=", "{", "\"source_card\"", ":", "recipient", ",", "\"amount\"", ":", "amount", "}", ")", "r", "=", "h...
c1451a7604b462c19e4929f0eb171cbcf23e50ab
train
extract_diacritic
Given a collection of Unicode diacritics, return a function that takes a Unicode character and returns the member of the collection the character has (or None).
greek_accentuation/characters.py
def extract_diacritic(*diacritics): """ Given a collection of Unicode diacritics, return a function that takes a Unicode character and returns the member of the collection the character has (or None). """ def _(ch): decomposed_form = unicodedata.normalize("NFD", ch) for diacritic...
def extract_diacritic(*diacritics): """ Given a collection of Unicode diacritics, return a function that takes a Unicode character and returns the member of the collection the character has (or None). """ def _(ch): decomposed_form = unicodedata.normalize("NFD", ch) for diacritic...
[ "Given", "a", "collection", "of", "Unicode", "diacritics", "return", "a", "function", "that", "takes", "a", "Unicode", "character", "and", "returns", "the", "member", "of", "the", "collection", "the", "character", "has", "(", "or", "None", ")", "." ]
jtauber/greek-accentuation
python
https://github.com/jtauber/greek-accentuation/blob/330796cd97f7c7adcbecbd05bd91be984f9b9f67/greek_accentuation/characters.py#L8-L19
[ "def", "extract_diacritic", "(", "*", "diacritics", ")", ":", "def", "_", "(", "ch", ")", ":", "decomposed_form", "=", "unicodedata", ".", "normalize", "(", "\"NFD\"", ",", "ch", ")", "for", "diacritic", "in", "diacritics", ":", "if", "diacritic", "in", ...
330796cd97f7c7adcbecbd05bd91be984f9b9f67
train
add_breathing
Add the given breathing to the given (possibly accented) character.
greek_accentuation/characters.py
def add_breathing(ch, breathing): """ Add the given breathing to the given (possibly accented) character. """ decomposed = unicodedata.normalize("NFD", ch) if len(decomposed) > 1 and decomposed[1] == LONG: return unicodedata.normalize( "NFC", decomposed[0:2] + breathing + decompo...
def add_breathing(ch, breathing): """ Add the given breathing to the given (possibly accented) character. """ decomposed = unicodedata.normalize("NFD", ch) if len(decomposed) > 1 and decomposed[1] == LONG: return unicodedata.normalize( "NFC", decomposed[0:2] + breathing + decompo...
[ "Add", "the", "given", "breathing", "to", "the", "given", "(", "possibly", "accented", ")", "character", "." ]
jtauber/greek-accentuation
python
https://github.com/jtauber/greek-accentuation/blob/330796cd97f7c7adcbecbd05bd91be984f9b9f67/greek_accentuation/characters.py#L29-L39
[ "def", "add_breathing", "(", "ch", ",", "breathing", ")", ":", "decomposed", "=", "unicodedata", ".", "normalize", "(", "\"NFD\"", ",", "ch", ")", "if", "len", "(", "decomposed", ")", ">", "1", "and", "decomposed", "[", "1", "]", "==", "LONG", ":", "...
330796cd97f7c7adcbecbd05bd91be984f9b9f67
train
remove_diacritic
Given a collection of Unicode diacritics, return a function that takes a string and returns the string without those diacritics.
greek_accentuation/characters.py
def remove_diacritic(*diacritics): """ Given a collection of Unicode diacritics, return a function that takes a string and returns the string without those diacritics. """ def _(text): return unicodedata.normalize("NFC", "".join( ch for ch in unicodedata.normalize("NF...
def remove_diacritic(*diacritics): """ Given a collection of Unicode diacritics, return a function that takes a string and returns the string without those diacritics. """ def _(text): return unicodedata.normalize("NFC", "".join( ch for ch in unicodedata.normalize("NF...
[ "Given", "a", "collection", "of", "Unicode", "diacritics", "return", "a", "function", "that", "takes", "a", "string", "and", "returns", "the", "string", "without", "those", "diacritics", "." ]
jtauber/greek-accentuation
python
https://github.com/jtauber/greek-accentuation/blob/330796cd97f7c7adcbecbd05bd91be984f9b9f67/greek_accentuation/characters.py#L42-L53
[ "def", "remove_diacritic", "(", "*", "diacritics", ")", ":", "def", "_", "(", "text", ")", ":", "return", "unicodedata", ".", "normalize", "(", "\"NFC\"", ",", "\"\"", ".", "join", "(", "ch", "for", "ch", "in", "unicodedata", ".", "normalize", "(", "\"...
330796cd97f7c7adcbecbd05bd91be984f9b9f67
train
ArduinoService.change_digital
Change digital Pin value (boolean). Also PWM supported(float)
src/automate/extensions/arduino/arduino_service.py
def change_digital(self, pin_nr, value): """ Change digital Pin value (boolean). Also PWM supported(float)""" if not self._board: return with self._lock: self._act_digital[pin_nr].pin.write(value)
def change_digital(self, pin_nr, value): """ Change digital Pin value (boolean). Also PWM supported(float)""" if not self._board: return with self._lock: self._act_digital[pin_nr].pin.write(value)
[ "Change", "digital", "Pin", "value", "(", "boolean", ")", ".", "Also", "PWM", "supported", "(", "float", ")" ]
tuomas2/automate
python
https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/extensions/arduino/arduino_service.py#L506-L511
[ "def", "change_digital", "(", "self", ",", "pin_nr", ",", "value", ")", ":", "if", "not", "self", ".", "_board", ":", "return", "with", "self", ".", "_lock", ":", "self", ".", "_act_digital", "[", "pin_nr", "]", ".", "pin", ".", "write", "(", "value"...
d8a8cd03cd0da047e033a2d305f3f260f8c4e017
train
deep_merge
Recursively merge all input dicts into a single dict.
seaworthy/definitions.py
def deep_merge(*dicts): """ Recursively merge all input dicts into a single dict. """ result = {} for d in dicts: if not isinstance(d, dict): raise Exception('Can only deep_merge dicts, got {}'.format(d)) for k, v in d.items(): # Whenever the value is a dict, ...
def deep_merge(*dicts): """ Recursively merge all input dicts into a single dict. """ result = {} for d in dicts: if not isinstance(d, dict): raise Exception('Can only deep_merge dicts, got {}'.format(d)) for k, v in d.items(): # Whenever the value is a dict, ...
[ "Recursively", "merge", "all", "input", "dicts", "into", "a", "single", "dict", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/definitions.py#L21-L37
[ "def", "deep_merge", "(", "*", "dicts", ")", ":", "result", "=", "{", "}", "for", "d", "in", "dicts", ":", "if", "not", "isinstance", "(", "d", ",", "dict", ")", ":", "raise", "Exception", "(", "'Can only deep_merge dicts, got {}'", ".", "format", "(", ...
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
_DefinitionBase.create
Create an instance of this resource definition. Only one instance may exist at any given time.
seaworthy/definitions.py
def create(self, **kwargs): """ Create an instance of this resource definition. Only one instance may exist at any given time. """ if self.created: raise RuntimeError( '{} already created.'.format(self.__model_type__.__name__)) kwargs = self....
def create(self, **kwargs): """ Create an instance of this resource definition. Only one instance may exist at any given time. """ if self.created: raise RuntimeError( '{} already created.'.format(self.__model_type__.__name__)) kwargs = self....
[ "Create", "an", "instance", "of", "this", "resource", "definition", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/definitions.py#L54-L67
[ "def", "create", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "created", ":", "raise", "RuntimeError", "(", "'{} already created.'", ".", "format", "(", "self", ".", "__model_type__", ".", "__name__", ")", ")", "kwargs", "=", "self"...
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c
train
_DefinitionBase.remove
Remove an instance of this resource definition.
seaworthy/definitions.py
def remove(self, **kwargs): """ Remove an instance of this resource definition. """ self.helper.remove(self.inner(), **kwargs) self._inner = None
def remove(self, **kwargs): """ Remove an instance of this resource definition. """ self.helper.remove(self.inner(), **kwargs) self._inner = None
[ "Remove", "an", "instance", "of", "this", "resource", "definition", "." ]
praekeltfoundation/seaworthy
python
https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/definitions.py#L69-L74
[ "def", "remove", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "helper", ".", "remove", "(", "self", ".", "inner", "(", ")", ",", "*", "*", "kwargs", ")", "self", ".", "_inner", "=", "None" ]
6f10a19b45d4ea1dc3bd0553cc4d0438696c079c