id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
6,600
tableau/document-api-python
tableaudocumentapi/xfile.py
xml_open
def xml_open(filename, expected_root=None): """Opens the provided 'filename'. Handles detecting if the file is an archive, detecting the document version, and validating the root tag.""" # Is the file a zip (.twbx or .tdsx) if zipfile.is_zipfile(filename): tree = get_xml_from_archive(filename) ...
python
def xml_open(filename, expected_root=None): """Opens the provided 'filename'. Handles detecting if the file is an archive, detecting the document version, and validating the root tag.""" # Is the file a zip (.twbx or .tdsx) if zipfile.is_zipfile(filename): tree = get_xml_from_archive(filename) ...
[ "def", "xml_open", "(", "filename", ",", "expected_root", "=", "None", ")", ":", "# Is the file a zip (.twbx or .tdsx)", "if", "zipfile", ".", "is_zipfile", "(", "filename", ")", ":", "tree", "=", "get_xml_from_archive", "(", "filename", ")", "else", ":", "tree"...
Opens the provided 'filename'. Handles detecting if the file is an archive, detecting the document version, and validating the root tag.
[ "Opens", "the", "provided", "filename", ".", "Handles", "detecting", "if", "the", "file", "is", "an", "archive", "detecting", "the", "document", "version", "and", "validating", "the", "root", "tag", "." ]
9097a5b351622c5dd2653fa94624bc012316d8a4
https://github.com/tableau/document-api-python/blob/9097a5b351622c5dd2653fa94624bc012316d8a4/tableaudocumentapi/xfile.py#L24-L46
6,601
tableau/document-api-python
tableaudocumentapi/xfile.py
build_archive_file
def build_archive_file(archive_contents, zip_file): """Build a Tableau-compatible archive file.""" # This is tested against Desktop and Server, and reverse engineered by lots # of trial and error. Do not change this logic. for root_dir, _, files in os.walk(archive_contents): relative_dir = os.p...
python
def build_archive_file(archive_contents, zip_file): """Build a Tableau-compatible archive file.""" # This is tested against Desktop and Server, and reverse engineered by lots # of trial and error. Do not change this logic. for root_dir, _, files in os.walk(archive_contents): relative_dir = os.p...
[ "def", "build_archive_file", "(", "archive_contents", ",", "zip_file", ")", ":", "# This is tested against Desktop and Server, and reverse engineered by lots", "# of trial and error. Do not change this logic.", "for", "root_dir", ",", "_", ",", "files", "in", "os", ".", "walk",...
Build a Tableau-compatible archive file.
[ "Build", "a", "Tableau", "-", "compatible", "archive", "file", "." ]
9097a5b351622c5dd2653fa94624bc012316d8a4
https://github.com/tableau/document-api-python/blob/9097a5b351622c5dd2653fa94624bc012316d8a4/tableaudocumentapi/xfile.py#L85-L96
6,602
tableau/document-api-python
tableaudocumentapi/connection.py
Connection.from_attributes
def from_attributes(cls, server, dbname, username, dbclass, port=None, query_band=None, initial_sql=None, authentication=''): """Creates a new connection that can be added into a Data Source. defaults to `''` which will be treated as 'prompt' by Tableau.""" root = ET.Ele...
python
def from_attributes(cls, server, dbname, username, dbclass, port=None, query_band=None, initial_sql=None, authentication=''): """Creates a new connection that can be added into a Data Source. defaults to `''` which will be treated as 'prompt' by Tableau.""" root = ET.Ele...
[ "def", "from_attributes", "(", "cls", ",", "server", ",", "dbname", ",", "username", ",", "dbclass", ",", "port", "=", "None", ",", "query_band", "=", "None", ",", "initial_sql", "=", "None", ",", "authentication", "=", "''", ")", ":", "root", "=", "ET...
Creates a new connection that can be added into a Data Source. defaults to `''` which will be treated as 'prompt' by Tableau.
[ "Creates", "a", "new", "connection", "that", "can", "be", "added", "into", "a", "Data", "Source", ".", "defaults", "to", "which", "will", "be", "treated", "as", "prompt", "by", "Tableau", "." ]
9097a5b351622c5dd2653fa94624bc012316d8a4
https://github.com/tableau/document-api-python/blob/9097a5b351622c5dd2653fa94624bc012316d8a4/tableaudocumentapi/connection.py#L28-L43
6,603
tableau/document-api-python
tableaudocumentapi/connection.py
Connection.dbname
def dbname(self, value): """ Set the connection's database name property. Args: value: New name of the database. String. Returns: Nothing. """ self._dbname = value self._connectionXML.set('dbname', value)
python
def dbname(self, value): """ Set the connection's database name property. Args: value: New name of the database. String. Returns: Nothing. """ self._dbname = value self._connectionXML.set('dbname', value)
[ "def", "dbname", "(", "self", ",", "value", ")", ":", "self", ".", "_dbname", "=", "value", "self", ".", "_connectionXML", ".", "set", "(", "'dbname'", ",", "value", ")" ]
Set the connection's database name property. Args: value: New name of the database. String. Returns: Nothing.
[ "Set", "the", "connection", "s", "database", "name", "property", "." ]
9097a5b351622c5dd2653fa94624bc012316d8a4
https://github.com/tableau/document-api-python/blob/9097a5b351622c5dd2653fa94624bc012316d8a4/tableaudocumentapi/connection.py#L51-L63
6,604
tableau/document-api-python
tableaudocumentapi/connection.py
Connection.server
def server(self, value): """ Set the connection's server property. Args: value: New server. String. Returns: Nothing. """ self._server = value self._connectionXML.set('server', value)
python
def server(self, value): """ Set the connection's server property. Args: value: New server. String. Returns: Nothing. """ self._server = value self._connectionXML.set('server', value)
[ "def", "server", "(", "self", ",", "value", ")", ":", "self", ".", "_server", "=", "value", "self", ".", "_connectionXML", ".", "set", "(", "'server'", ",", "value", ")" ]
Set the connection's server property. Args: value: New server. String. Returns: Nothing.
[ "Set", "the", "connection", "s", "server", "property", "." ]
9097a5b351622c5dd2653fa94624bc012316d8a4
https://github.com/tableau/document-api-python/blob/9097a5b351622c5dd2653fa94624bc012316d8a4/tableaudocumentapi/connection.py#L71-L83
6,605
tableau/document-api-python
tableaudocumentapi/connection.py
Connection.username
def username(self, value): """ Set the connection's username property. Args: value: New username value. String. Returns: Nothing. """ self._username = value self._connectionXML.set('username', value)
python
def username(self, value): """ Set the connection's username property. Args: value: New username value. String. Returns: Nothing. """ self._username = value self._connectionXML.set('username', value)
[ "def", "username", "(", "self", ",", "value", ")", ":", "self", ".", "_username", "=", "value", "self", ".", "_connectionXML", ".", "set", "(", "'username'", ",", "value", ")" ]
Set the connection's username property. Args: value: New username value. String. Returns: Nothing.
[ "Set", "the", "connection", "s", "username", "property", "." ]
9097a5b351622c5dd2653fa94624bc012316d8a4
https://github.com/tableau/document-api-python/blob/9097a5b351622c5dd2653fa94624bc012316d8a4/tableaudocumentapi/connection.py#L91-L103
6,606
tableau/document-api-python
tableaudocumentapi/connection.py
Connection.dbclass
def dbclass(self, value): """Set the connection's dbclass property. Args: value: New dbclass value. String. Returns: Nothing. """ if not is_valid_dbclass(value): raise AttributeError("'{}' is not a valid database type".format(value)) ...
python
def dbclass(self, value): """Set the connection's dbclass property. Args: value: New dbclass value. String. Returns: Nothing. """ if not is_valid_dbclass(value): raise AttributeError("'{}' is not a valid database type".format(value)) ...
[ "def", "dbclass", "(", "self", ",", "value", ")", ":", "if", "not", "is_valid_dbclass", "(", "value", ")", ":", "raise", "AttributeError", "(", "\"'{}' is not a valid database type\"", ".", "format", "(", "value", ")", ")", "self", ".", "_class", "=", "value...
Set the connection's dbclass property. Args: value: New dbclass value. String. Returns: Nothing.
[ "Set", "the", "connection", "s", "dbclass", "property", "." ]
9097a5b351622c5dd2653fa94624bc012316d8a4
https://github.com/tableau/document-api-python/blob/9097a5b351622c5dd2653fa94624bc012316d8a4/tableaudocumentapi/connection.py#L116-L130
6,607
tableau/document-api-python
tableaudocumentapi/connection.py
Connection.port
def port(self, value): """Set the connection's port property. Args: value: New port value. String. Returns: Nothing. """ self._port = value # If port is None we remove the element and don't write it to XML if value is None: ...
python
def port(self, value): """Set the connection's port property. Args: value: New port value. String. Returns: Nothing. """ self._port = value # If port is None we remove the element and don't write it to XML if value is None: ...
[ "def", "port", "(", "self", ",", "value", ")", ":", "self", ".", "_port", "=", "value", "# If port is None we remove the element and don't write it to XML", "if", "value", "is", "None", ":", "try", ":", "del", "self", ".", "_connectionXML", ".", "attrib", "[", ...
Set the connection's port property. Args: value: New port value. String. Returns: Nothing.
[ "Set", "the", "connection", "s", "port", "property", "." ]
9097a5b351622c5dd2653fa94624bc012316d8a4
https://github.com/tableau/document-api-python/blob/9097a5b351622c5dd2653fa94624bc012316d8a4/tableaudocumentapi/connection.py#L138-L156
6,608
tableau/document-api-python
tableaudocumentapi/connection.py
Connection.query_band
def query_band(self, value): """Set the connection's query_band property. Args: value: New query_band value. String. Returns: Nothing. """ self._query_band = value # If query band is None we remove the element and don't write it to XML ...
python
def query_band(self, value): """Set the connection's query_band property. Args: value: New query_band value. String. Returns: Nothing. """ self._query_band = value # If query band is None we remove the element and don't write it to XML ...
[ "def", "query_band", "(", "self", ",", "value", ")", ":", "self", ".", "_query_band", "=", "value", "# If query band is None we remove the element and don't write it to XML", "if", "value", "is", "None", ":", "try", ":", "del", "self", ".", "_connectionXML", ".", ...
Set the connection's query_band property. Args: value: New query_band value. String. Returns: Nothing.
[ "Set", "the", "connection", "s", "query_band", "property", "." ]
9097a5b351622c5dd2653fa94624bc012316d8a4
https://github.com/tableau/document-api-python/blob/9097a5b351622c5dd2653fa94624bc012316d8a4/tableaudocumentapi/connection.py#L164-L182
6,609
tableau/document-api-python
tableaudocumentapi/connection.py
Connection.initial_sql
def initial_sql(self, value): """Set the connection's initial_sql property. Args: value: New initial_sql value. String. Returns: Nothing. """ self._initial_sql = value # If initial_sql is None we remove the element and don't write it to XML ...
python
def initial_sql(self, value): """Set the connection's initial_sql property. Args: value: New initial_sql value. String. Returns: Nothing. """ self._initial_sql = value # If initial_sql is None we remove the element and don't write it to XML ...
[ "def", "initial_sql", "(", "self", ",", "value", ")", ":", "self", ".", "_initial_sql", "=", "value", "# If initial_sql is None we remove the element and don't write it to XML", "if", "value", "is", "None", ":", "try", ":", "del", "self", ".", "_connectionXML", ".",...
Set the connection's initial_sql property. Args: value: New initial_sql value. String. Returns: Nothing.
[ "Set", "the", "connection", "s", "initial_sql", "property", "." ]
9097a5b351622c5dd2653fa94624bc012316d8a4
https://github.com/tableau/document-api-python/blob/9097a5b351622c5dd2653fa94624bc012316d8a4/tableaudocumentapi/connection.py#L190-L208
6,610
tableau/document-api-python
tableaudocumentapi/datasource.py
base36encode
def base36encode(number): """Converts an integer into a base36 string.""" ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz" base36 = '' sign = '' if number < 0: sign = '-' number = -number if 0 <= number < len(ALPHABET): return sign + ALPHABET[number] while numbe...
python
def base36encode(number): """Converts an integer into a base36 string.""" ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz" base36 = '' sign = '' if number < 0: sign = '-' number = -number if 0 <= number < len(ALPHABET): return sign + ALPHABET[number] while numbe...
[ "def", "base36encode", "(", "number", ")", ":", "ALPHABET", "=", "\"0123456789abcdefghijklmnopqrstuvwxyz\"", "base36", "=", "''", "sign", "=", "''", "if", "number", "<", "0", ":", "sign", "=", "'-'", "number", "=", "-", "number", "if", "0", "<=", "number",...
Converts an integer into a base36 string.
[ "Converts", "an", "integer", "into", "a", "base36", "string", "." ]
9097a5b351622c5dd2653fa94624bc012316d8a4
https://github.com/tableau/document-api-python/blob/9097a5b351622c5dd2653fa94624bc012316d8a4/tableaudocumentapi/datasource.py#L63-L82
6,611
tableau/document-api-python
tableaudocumentapi/datasource.py
ConnectionParser.get_connections
def get_connections(self): """Find and return all connections based on file format version.""" if float(self._dsversion) < 10: connections = self._extract_legacy_connection() else: connections = self._extract_federated_connections() return connections
python
def get_connections(self): """Find and return all connections based on file format version.""" if float(self._dsversion) < 10: connections = self._extract_legacy_connection() else: connections = self._extract_federated_connections() return connections
[ "def", "get_connections", "(", "self", ")", ":", "if", "float", "(", "self", ".", "_dsversion", ")", "<", "10", ":", "connections", "=", "self", ".", "_extract_legacy_connection", "(", ")", "else", ":", "connections", "=", "self", ".", "_extract_federated_co...
Find and return all connections based on file format version.
[ "Find", "and", "return", "all", "connections", "based", "on", "file", "format", "version", "." ]
9097a5b351622c5dd2653fa94624bc012316d8a4
https://github.com/tableau/document-api-python/blob/9097a5b351622c5dd2653fa94624bc012316d8a4/tableaudocumentapi/datasource.py#L108-L115
6,612
tableau/document-api-python
tableaudocumentapi/datasource.py
Datasource.from_connections
def from_connections(cls, caption, connections): """Create a new Data Source give a list of Connections.""" root = ET.Element('datasource', caption=caption, version='10.0', inline='true') outer_connection = ET.SubElement(root, 'connection') outer_connection.set('class', 'federated') ...
python
def from_connections(cls, caption, connections): """Create a new Data Source give a list of Connections.""" root = ET.Element('datasource', caption=caption, version='10.0', inline='true') outer_connection = ET.SubElement(root, 'connection') outer_connection.set('class', 'federated') ...
[ "def", "from_connections", "(", "cls", ",", "caption", ",", "connections", ")", ":", "root", "=", "ET", ".", "Element", "(", "'datasource'", ",", "caption", "=", "caption", ",", "version", "=", "'10.0'", ",", "inline", "=", "'true'", ")", "outer_connection...
Create a new Data Source give a list of Connections.
[ "Create", "a", "new", "Data", "Source", "give", "a", "list", "of", "Connections", "." ]
9097a5b351622c5dd2653fa94624bc012316d8a4
https://github.com/tableau/document-api-python/blob/9097a5b351622c5dd2653fa94624bc012316d8a4/tableaudocumentapi/datasource.py#L149-L162
6,613
tableau/document-api-python
tableaudocumentapi/field.py
Field.name
def name(self): """ Provides a nice name for the field which is derived from the alias, caption, or the id. The name resolves as either the alias if it's defined, or the caption if alias is not defined, and finally the id which is the underlying name if neither of the fields exist. """ ...
python
def name(self): """ Provides a nice name for the field which is derived from the alias, caption, or the id. The name resolves as either the alias if it's defined, or the caption if alias is not defined, and finally the id which is the underlying name if neither of the fields exist. """ ...
[ "def", "name", "(", "self", ")", ":", "alias", "=", "getattr", "(", "self", ",", "'alias'", ",", "None", ")", "if", "alias", ":", "return", "alias", "caption", "=", "getattr", "(", "self", ",", "'caption'", ",", "None", ")", "if", "caption", ":", "...
Provides a nice name for the field which is derived from the alias, caption, or the id. The name resolves as either the alias if it's defined, or the caption if alias is not defined, and finally the id which is the underlying name if neither of the fields exist.
[ "Provides", "a", "nice", "name", "for", "the", "field", "which", "is", "derived", "from", "the", "alias", "caption", "or", "the", "id", "." ]
9097a5b351622c5dd2653fa94624bc012316d8a4
https://github.com/tableau/document-api-python/blob/9097a5b351622c5dd2653fa94624bc012316d8a4/tableaudocumentapi/field.py#L99-L112
6,614
maraujop/requests-oauth2
requests_oauth2/oauth2.py
OAuth2._check_configuration
def _check_configuration(self, *attrs): """Check that each named attr has been configured """ for attr in attrs: if getattr(self, attr, None) is None: raise ConfigurationError("{} not configured".format(attr))
python
def _check_configuration(self, *attrs): """Check that each named attr has been configured """ for attr in attrs: if getattr(self, attr, None) is None: raise ConfigurationError("{} not configured".format(attr))
[ "def", "_check_configuration", "(", "self", ",", "*", "attrs", ")", ":", "for", "attr", "in", "attrs", ":", "if", "getattr", "(", "self", ",", "attr", ",", "None", ")", "is", "None", ":", "raise", "ConfigurationError", "(", "\"{} not configured\"", ".", ...
Check that each named attr has been configured
[ "Check", "that", "each", "named", "attr", "has", "been", "configured" ]
191995aa571d0fbdf5bb166fb0668d5e73fe7817
https://github.com/maraujop/requests-oauth2/blob/191995aa571d0fbdf5bb166fb0668d5e73fe7817/requests_oauth2/oauth2.py#L41-L46
6,615
maraujop/requests-oauth2
requests_oauth2/oauth2.py
OAuth2._make_request
def _make_request(self, url, **kwargs): """ Make a request to an OAuth2 endpoint """ response = requests.post(url, **kwargs) try: return response.json() except ValueError: pass return parse_qs(response.content)
python
def _make_request(self, url, **kwargs): """ Make a request to an OAuth2 endpoint """ response = requests.post(url, **kwargs) try: return response.json() except ValueError: pass return parse_qs(response.content)
[ "def", "_make_request", "(", "self", ",", "url", ",", "*", "*", "kwargs", ")", ":", "response", "=", "requests", ".", "post", "(", "url", ",", "*", "*", "kwargs", ")", "try", ":", "return", "response", ".", "json", "(", ")", "except", "ValueError", ...
Make a request to an OAuth2 endpoint
[ "Make", "a", "request", "to", "an", "OAuth2", "endpoint" ]
191995aa571d0fbdf5bb166fb0668d5e73fe7817
https://github.com/maraujop/requests-oauth2/blob/191995aa571d0fbdf5bb166fb0668d5e73fe7817/requests_oauth2/oauth2.py#L48-L57
6,616
maraujop/requests-oauth2
requests_oauth2/oauth2.py
OAuth2.get_token
def get_token(self, code, headers=None, **kwargs): """ Requests an access token """ self._check_configuration("site", "token_url", "redirect_uri", "client_id", "client_secret") url = "%s%s" % (self.site, quote(self.token_url)) data = { ...
python
def get_token(self, code, headers=None, **kwargs): """ Requests an access token """ self._check_configuration("site", "token_url", "redirect_uri", "client_id", "client_secret") url = "%s%s" % (self.site, quote(self.token_url)) data = { ...
[ "def", "get_token", "(", "self", ",", "code", ",", "headers", "=", "None", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_check_configuration", "(", "\"site\"", ",", "\"token_url\"", ",", "\"redirect_uri\"", ",", "\"client_id\"", ",", "\"client_secret\"", ...
Requests an access token
[ "Requests", "an", "access", "token" ]
191995aa571d0fbdf5bb166fb0668d5e73fe7817
https://github.com/maraujop/requests-oauth2/blob/191995aa571d0fbdf5bb166fb0668d5e73fe7817/requests_oauth2/oauth2.py#L77-L92
6,617
maraujop/requests-oauth2
requests_oauth2/oauth2.py
OAuth2.refresh_token
def refresh_token(self, headers=None, **kwargs): """ Request a refreshed token """ self._check_configuration("site", "token_url", "client_id", "client_secret") url = "%s%s" % (self.site, quote(self.token_url)) data = { 'client...
python
def refresh_token(self, headers=None, **kwargs): """ Request a refreshed token """ self._check_configuration("site", "token_url", "client_id", "client_secret") url = "%s%s" % (self.site, quote(self.token_url)) data = { 'client...
[ "def", "refresh_token", "(", "self", ",", "headers", "=", "None", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_check_configuration", "(", "\"site\"", ",", "\"token_url\"", ",", "\"client_id\"", ",", "\"client_secret\"", ")", "url", "=", "\"%s%s\"", "%",...
Request a refreshed token
[ "Request", "a", "refreshed", "token" ]
191995aa571d0fbdf5bb166fb0668d5e73fe7817
https://github.com/maraujop/requests-oauth2/blob/191995aa571d0fbdf5bb166fb0668d5e73fe7817/requests_oauth2/oauth2.py#L94-L107
6,618
maraujop/requests-oauth2
requests_oauth2/oauth2.py
OAuth2.revoke_token
def revoke_token(self, token, headers=None, **kwargs): """ Revoke an access token """ self._check_configuration("site", "revoke_uri") url = "%s%s" % (self.site, quote(self.revoke_url)) data = {'token': token} data.update(kwargs) return self._make_request(...
python
def revoke_token(self, token, headers=None, **kwargs): """ Revoke an access token """ self._check_configuration("site", "revoke_uri") url = "%s%s" % (self.site, quote(self.revoke_url)) data = {'token': token} data.update(kwargs) return self._make_request(...
[ "def", "revoke_token", "(", "self", ",", "token", ",", "headers", "=", "None", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_check_configuration", "(", "\"site\"", ",", "\"revoke_uri\"", ")", "url", "=", "\"%s%s\"", "%", "(", "self", ".", "site", "...
Revoke an access token
[ "Revoke", "an", "access", "token" ]
191995aa571d0fbdf5bb166fb0668d5e73fe7817
https://github.com/maraujop/requests-oauth2/blob/191995aa571d0fbdf5bb166fb0668d5e73fe7817/requests_oauth2/oauth2.py#L109-L118
6,619
jorgenkg/python-neural-network
nimblenet/neuralnet.py
NeuralNet.save_network_to_file
def save_network_to_file(self, filename = "network0.pkl" ): import cPickle, os, re """ This save method pickles the parameters of the current network into a binary file for persistant storage. """ if filename == "network0.pkl": while os.path.exists( os.p...
python
def save_network_to_file(self, filename = "network0.pkl" ): import cPickle, os, re """ This save method pickles the parameters of the current network into a binary file for persistant storage. """ if filename == "network0.pkl": while os.path.exists( os.p...
[ "def", "save_network_to_file", "(", "self", ",", "filename", "=", "\"network0.pkl\"", ")", ":", "import", "cPickle", ",", "os", ",", "re", "if", "filename", "==", "\"network0.pkl\"", ":", "while", "os", ".", "path", ".", "exists", "(", "os", ".", "path", ...
This save method pickles the parameters of the current network into a binary file for persistant storage.
[ "This", "save", "method", "pickles", "the", "parameters", "of", "the", "current", "network", "into", "a", "binary", "file", "for", "persistant", "storage", "." ]
617b9940fa157d54d7831c42c0f7ba6857239b9a
https://github.com/jorgenkg/python-neural-network/blob/617b9940fa157d54d7831c42c0f7ba6857239b9a/nimblenet/neuralnet.py#L194-L212
6,620
jorgenkg/python-neural-network
nimblenet/neuralnet.py
NeuralNet.load_network_from_file
def load_network_from_file( filename ): import cPickle """ Load the complete configuration of a previously stored network. """ network = NeuralNet( {"n_inputs":1, "layers":[[0,None]]} ) with open( filename , 'rb') as file: store_dict = c...
python
def load_network_from_file( filename ): import cPickle """ Load the complete configuration of a previously stored network. """ network = NeuralNet( {"n_inputs":1, "layers":[[0,None]]} ) with open( filename , 'rb') as file: store_dict = c...
[ "def", "load_network_from_file", "(", "filename", ")", ":", "import", "cPickle", "network", "=", "NeuralNet", "(", "{", "\"n_inputs\"", ":", "1", ",", "\"layers\"", ":", "[", "[", "0", ",", "None", "]", "]", "}", ")", "with", "open", "(", "filename", "...
Load the complete configuration of a previously stored network.
[ "Load", "the", "complete", "configuration", "of", "a", "previously", "stored", "network", "." ]
617b9940fa157d54d7831c42c0f7ba6857239b9a
https://github.com/jorgenkg/python-neural-network/blob/617b9940fa157d54d7831c42c0f7ba6857239b9a/nimblenet/neuralnet.py#L216-L231
6,621
jorgenkg/python-neural-network
nimblenet/preprocessing.py
replace_nan
def replace_nan( trainingset, replace_with = None ): # if replace_with = None, replaces with mean value """ Replace instanced of "not a number" with either the mean of the signal feature or a specific value assigned by `replace_nan_with` """ training_data = np.array( [instance.features for instance ...
python
def replace_nan( trainingset, replace_with = None ): # if replace_with = None, replaces with mean value """ Replace instanced of "not a number" with either the mean of the signal feature or a specific value assigned by `replace_nan_with` """ training_data = np.array( [instance.features for instance ...
[ "def", "replace_nan", "(", "trainingset", ",", "replace_with", "=", "None", ")", ":", "# if replace_with = None, replaces with mean value", "training_data", "=", "np", ".", "array", "(", "[", "instance", ".", "features", "for", "instance", "in", "trainingset", "]", ...
Replace instanced of "not a number" with either the mean of the signal feature or a specific value assigned by `replace_nan_with`
[ "Replace", "instanced", "of", "not", "a", "number", "with", "either", "the", "mean", "of", "the", "signal", "feature", "or", "a", "specific", "value", "assigned", "by", "replace_nan_with" ]
617b9940fa157d54d7831c42c0f7ba6857239b9a
https://github.com/jorgenkg/python-neural-network/blob/617b9940fa157d54d7831c42c0f7ba6857239b9a/nimblenet/preprocessing.py#L47-L69
6,622
jorgenkg/python-neural-network
nimblenet/activation_functions.py
elliot_function
def elliot_function( signal, derivative=False ): """ A fast approximation of sigmoid """ s = 1 # steepness abs_signal = (1 + np.abs(signal * s)) if derivative: return 0.5 * s / abs_signal**2 else: # Return the activation signal return 0.5*(signal * s) / abs_signal + 0.5
python
def elliot_function( signal, derivative=False ): """ A fast approximation of sigmoid """ s = 1 # steepness abs_signal = (1 + np.abs(signal * s)) if derivative: return 0.5 * s / abs_signal**2 else: # Return the activation signal return 0.5*(signal * s) / abs_signal + 0.5
[ "def", "elliot_function", "(", "signal", ",", "derivative", "=", "False", ")", ":", "s", "=", "1", "# steepness", "abs_signal", "=", "(", "1", "+", "np", ".", "abs", "(", "signal", "*", "s", ")", ")", "if", "derivative", ":", "return", "0.5", "*", ...
A fast approximation of sigmoid
[ "A", "fast", "approximation", "of", "sigmoid" ]
617b9940fa157d54d7831c42c0f7ba6857239b9a
https://github.com/jorgenkg/python-neural-network/blob/617b9940fa157d54d7831c42c0f7ba6857239b9a/nimblenet/activation_functions.py#L39-L48
6,623
jorgenkg/python-neural-network
nimblenet/activation_functions.py
symmetric_elliot_function
def symmetric_elliot_function( signal, derivative=False ): """ A fast approximation of tanh """ s = 1.0 # steepness abs_signal = (1 + np.abs(signal * s)) if derivative: return s / abs_signal**2 else: # Return the activation signal return (signal * s) / abs_signal
python
def symmetric_elliot_function( signal, derivative=False ): """ A fast approximation of tanh """ s = 1.0 # steepness abs_signal = (1 + np.abs(signal * s)) if derivative: return s / abs_signal**2 else: # Return the activation signal return (signal * s) / abs_signal
[ "def", "symmetric_elliot_function", "(", "signal", ",", "derivative", "=", "False", ")", ":", "s", "=", "1.0", "# steepness", "abs_signal", "=", "(", "1", "+", "np", ".", "abs", "(", "signal", "*", "s", ")", ")", "if", "derivative", ":", "return", "s",...
A fast approximation of tanh
[ "A", "fast", "approximation", "of", "tanh" ]
617b9940fa157d54d7831c42c0f7ba6857239b9a
https://github.com/jorgenkg/python-neural-network/blob/617b9940fa157d54d7831c42c0f7ba6857239b9a/nimblenet/activation_functions.py#L52-L61
6,624
jorgenkg/python-neural-network
nimblenet/activation_functions.py
LReLU_function
def LReLU_function( signal, derivative=False, leakage = 0.01 ): """ Leaky Rectified Linear Unit """ if derivative: # Return the partial derivation of the activation function return np.clip(signal > 0, leakage, 1.0) else: # Return the activation signal output = np.copy...
python
def LReLU_function( signal, derivative=False, leakage = 0.01 ): """ Leaky Rectified Linear Unit """ if derivative: # Return the partial derivation of the activation function return np.clip(signal > 0, leakage, 1.0) else: # Return the activation signal output = np.copy...
[ "def", "LReLU_function", "(", "signal", ",", "derivative", "=", "False", ",", "leakage", "=", "0.01", ")", ":", "if", "derivative", ":", "# Return the partial derivation of the activation function", "return", "np", ".", "clip", "(", "signal", ">", "0", ",", "lea...
Leaky Rectified Linear Unit
[ "Leaky", "Rectified", "Linear", "Unit" ]
617b9940fa157d54d7831c42c0f7ba6857239b9a
https://github.com/jorgenkg/python-neural-network/blob/617b9940fa157d54d7831c42c0f7ba6857239b9a/nimblenet/activation_functions.py#L74-L85
6,625
mikusjelly/apkutils
apkutils/apkfile.py
is_zipfile
def is_zipfile(filename): """Quickly see if a file is a ZIP file by checking the magic number. The filename argument may be a file or file-like object too. """ result = False try: if hasattr(filename, "read"): result = _check_zipfile(fp=filename) else: with o...
python
def is_zipfile(filename): """Quickly see if a file is a ZIP file by checking the magic number. The filename argument may be a file or file-like object too. """ result = False try: if hasattr(filename, "read"): result = _check_zipfile(fp=filename) else: with o...
[ "def", "is_zipfile", "(", "filename", ")", ":", "result", "=", "False", "try", ":", "if", "hasattr", "(", "filename", ",", "\"read\"", ")", ":", "result", "=", "_check_zipfile", "(", "fp", "=", "filename", ")", "else", ":", "with", "open", "(", "filena...
Quickly see if a file is a ZIP file by checking the magic number. The filename argument may be a file or file-like object too.
[ "Quickly", "see", "if", "a", "file", "is", "a", "ZIP", "file", "by", "checking", "the", "magic", "number", "." ]
2db1ed0cdb610dfc55bfd77266e9a91e4764bba4
https://github.com/mikusjelly/apkutils/blob/2db1ed0cdb610dfc55bfd77266e9a91e4764bba4/apkutils/apkfile.py#L182-L196
6,626
mikusjelly/apkutils
apkutils/apkfile.py
ZipExtFile.readline
def readline(self, limit=-1): """Read and return a line from the stream. If limit is specified, at most limit bytes will be read. """ if not self._universal and limit < 0: # Shortcut common case - newline found in buffer. i = self._readbuffer.find(b'\n', self._o...
python
def readline(self, limit=-1): """Read and return a line from the stream. If limit is specified, at most limit bytes will be read. """ if not self._universal and limit < 0: # Shortcut common case - newline found in buffer. i = self._readbuffer.find(b'\n', self._o...
[ "def", "readline", "(", "self", ",", "limit", "=", "-", "1", ")", ":", "if", "not", "self", ".", "_universal", "and", "limit", "<", "0", ":", "# Shortcut common case - newline found in buffer.", "i", "=", "self", ".", "_readbuffer", ".", "find", "(", "b'\\...
Read and return a line from the stream. If limit is specified, at most limit bytes will be read.
[ "Read", "and", "return", "a", "line", "from", "the", "stream", "." ]
2db1ed0cdb610dfc55bfd77266e9a91e4764bba4
https://github.com/mikusjelly/apkutils/blob/2db1ed0cdb610dfc55bfd77266e9a91e4764bba4/apkutils/apkfile.py#L758-L806
6,627
mikusjelly/apkutils
apkutils/apkfile.py
ZipFile.setpassword
def setpassword(self, pwd): """Set default password for encrypted files.""" if pwd and not isinstance(pwd, bytes): raise TypeError("pwd: expected bytes, got %s" % type(pwd)) if pwd: self.pwd = pwd else: self.pwd = None
python
def setpassword(self, pwd): """Set default password for encrypted files.""" if pwd and not isinstance(pwd, bytes): raise TypeError("pwd: expected bytes, got %s" % type(pwd)) if pwd: self.pwd = pwd else: self.pwd = None
[ "def", "setpassword", "(", "self", ",", "pwd", ")", ":", "if", "pwd", "and", "not", "isinstance", "(", "pwd", ",", "bytes", ")", ":", "raise", "TypeError", "(", "\"pwd: expected bytes, got %s\"", "%", "type", "(", "pwd", ")", ")", "if", "pwd", ":", "se...
Set default password for encrypted files.
[ "Set", "default", "password", "for", "encrypted", "files", "." ]
2db1ed0cdb610dfc55bfd77266e9a91e4764bba4
https://github.com/mikusjelly/apkutils/blob/2db1ed0cdb610dfc55bfd77266e9a91e4764bba4/apkutils/apkfile.py#L1204-L1211
6,628
mikusjelly/apkutils
apkutils/apkfile.py
ZipFile._sanitize_windows_name
def _sanitize_windows_name(cls, arcname, pathsep): """Replace bad characters and remove trailing dots from parts.""" table = cls._windows_illegal_name_trans_table if not table: illegal = ':<>|"?*' table = str.maketrans(illegal, '_' * len(illegal)) cls._windows...
python
def _sanitize_windows_name(cls, arcname, pathsep): """Replace bad characters and remove trailing dots from parts.""" table = cls._windows_illegal_name_trans_table if not table: illegal = ':<>|"?*' table = str.maketrans(illegal, '_' * len(illegal)) cls._windows...
[ "def", "_sanitize_windows_name", "(", "cls", ",", "arcname", ",", "pathsep", ")", ":", "table", "=", "cls", ".", "_windows_illegal_name_trans_table", "if", "not", "table", ":", "illegal", "=", "':<>|\"?*'", "table", "=", "str", ".", "maketrans", "(", "illegal"...
Replace bad characters and remove trailing dots from parts.
[ "Replace", "bad", "characters", "and", "remove", "trailing", "dots", "from", "parts", "." ]
2db1ed0cdb610dfc55bfd77266e9a91e4764bba4
https://github.com/mikusjelly/apkutils/blob/2db1ed0cdb610dfc55bfd77266e9a91e4764bba4/apkutils/apkfile.py#L1341-L1353
6,629
mikusjelly/apkutils
apkutils/apkfile.py
ZipFile.close
def close(self): """Close the file, and for mode 'w', 'x' and 'a' write the ending records.""" if self.fp is None: return try: if self.mode in ('w', 'x', 'a') and self._didModify: # write ending records with self._lock: if sel...
python
def close(self): """Close the file, and for mode 'w', 'x' and 'a' write the ending records.""" if self.fp is None: return try: if self.mode in ('w', 'x', 'a') and self._didModify: # write ending records with self._lock: if sel...
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "fp", "is", "None", ":", "return", "try", ":", "if", "self", ".", "mode", "in", "(", "'w'", ",", "'x'", ",", "'a'", ")", "and", "self", ".", "_didModify", ":", "# write ending records", "wit...
Close the file, and for mode 'w', 'x' and 'a' write the ending records.
[ "Close", "the", "file", "and", "for", "mode", "w", "x", "and", "a", "write", "the", "ending", "records", "." ]
2db1ed0cdb610dfc55bfd77266e9a91e4764bba4
https://github.com/mikusjelly/apkutils/blob/2db1ed0cdb610dfc55bfd77266e9a91e4764bba4/apkutils/apkfile.py#L1588-L1603
6,630
mikusjelly/apkutils
apkutils/elf/elfparser.py
ELF.display_string_dump
def display_string_dump(self, section_spec): """ Display a strings dump of a section. section_spec is either a section number or a name. """ section = _section_from_spec(self.elf_file, section_spec) if section is None: print("Section '%s' does not exist in t...
python
def display_string_dump(self, section_spec): """ Display a strings dump of a section. section_spec is either a section number or a name. """ section = _section_from_spec(self.elf_file, section_spec) if section is None: print("Section '%s' does not exist in t...
[ "def", "display_string_dump", "(", "self", ",", "section_spec", ")", ":", "section", "=", "_section_from_spec", "(", "self", ".", "elf_file", ",", "section_spec", ")", "if", "section", "is", "None", ":", "print", "(", "\"Section '%s' does not exist in the file!\"", ...
Display a strings dump of a section. section_spec is either a section number or a name.
[ "Display", "a", "strings", "dump", "of", "a", "section", ".", "section_spec", "is", "either", "a", "section", "number", "or", "a", "name", "." ]
2db1ed0cdb610dfc55bfd77266e9a91e4764bba4
https://github.com/mikusjelly/apkutils/blob/2db1ed0cdb610dfc55bfd77266e9a91e4764bba4/apkutils/elf/elfparser.py#L57-L85
6,631
google/fleetspeak
fleetspeak/src/client/daemonservice/client/client.py
_EnvOpen
def _EnvOpen(var, mode): """Open a file descriptor identified by an environment variable.""" value = os.getenv(var) if value is None: raise ValueError("%s is not set" % var) fd = int(value) # If running on Windows, convert the file handle to a C file descriptor; see: # https://groups.google.com/forum/...
python
def _EnvOpen(var, mode): """Open a file descriptor identified by an environment variable.""" value = os.getenv(var) if value is None: raise ValueError("%s is not set" % var) fd = int(value) # If running on Windows, convert the file handle to a C file descriptor; see: # https://groups.google.com/forum/...
[ "def", "_EnvOpen", "(", "var", ",", "mode", ")", ":", "value", "=", "os", ".", "getenv", "(", "var", ")", "if", "value", "is", "None", ":", "raise", "ValueError", "(", "\"%s is not set\"", "%", "var", ")", "fd", "=", "int", "(", "value", ")", "# If...
Open a file descriptor identified by an environment variable.
[ "Open", "a", "file", "descriptor", "identified", "by", "an", "environment", "variable", "." ]
bc95dd6941494461d2e5dff0a7f4c78a07ff724d
https://github.com/google/fleetspeak/blob/bc95dd6941494461d2e5dff0a7f4c78a07ff724d/fleetspeak/src/client/daemonservice/client/client.py#L58-L71
6,632
google/fleetspeak
fleetspeak/src/client/daemonservice/client/client.py
FleetspeakConnection.Send
def Send(self, message): """Send a message through Fleetspeak. Args: message: A message protocol buffer. Returns: Size of the message in bytes. Raises: ValueError: If message is not a common_pb2.Message. """ if not isinstance(message, common_pb2.Message): raise ValueErro...
python
def Send(self, message): """Send a message through Fleetspeak. Args: message: A message protocol buffer. Returns: Size of the message in bytes. Raises: ValueError: If message is not a common_pb2.Message. """ if not isinstance(message, common_pb2.Message): raise ValueErro...
[ "def", "Send", "(", "self", ",", "message", ")", ":", "if", "not", "isinstance", "(", "message", ",", "common_pb2", ".", "Message", ")", ":", "raise", "ValueError", "(", "\"Send requires a fleetspeak.Message\"", ")", "if", "message", ".", "destination", ".", ...
Send a message through Fleetspeak. Args: message: A message protocol buffer. Returns: Size of the message in bytes. Raises: ValueError: If message is not a common_pb2.Message.
[ "Send", "a", "message", "through", "Fleetspeak", "." ]
bc95dd6941494461d2e5dff0a7f4c78a07ff724d
https://github.com/google/fleetspeak/blob/bc95dd6941494461d2e5dff0a7f4c78a07ff724d/fleetspeak/src/client/daemonservice/client/client.py#L126-L143
6,633
google/fleetspeak
fleetspeak/src/client/daemonservice/client/client.py
FleetspeakConnection.Recv
def Recv(self): """Accept a message from Fleetspeak. Returns: A tuple (common_pb2.Message, size of the message in bytes). Raises: ProtocolError: If we receive unexpected data from Fleetspeak. """ size = struct.unpack(_STRUCT_FMT, self._ReadN(_STRUCT_LEN))[0] if size > MAX_SIZE: ...
python
def Recv(self): """Accept a message from Fleetspeak. Returns: A tuple (common_pb2.Message, size of the message in bytes). Raises: ProtocolError: If we receive unexpected data from Fleetspeak. """ size = struct.unpack(_STRUCT_FMT, self._ReadN(_STRUCT_LEN))[0] if size > MAX_SIZE: ...
[ "def", "Recv", "(", "self", ")", ":", "size", "=", "struct", ".", "unpack", "(", "_STRUCT_FMT", ",", "self", ".", "_ReadN", "(", "_STRUCT_LEN", ")", ")", "[", "0", "]", "if", "size", ">", "MAX_SIZE", ":", "raise", "ProtocolError", "(", "\"Expected size...
Accept a message from Fleetspeak. Returns: A tuple (common_pb2.Message, size of the message in bytes). Raises: ProtocolError: If we receive unexpected data from Fleetspeak.
[ "Accept", "a", "message", "from", "Fleetspeak", "." ]
bc95dd6941494461d2e5dff0a7f4c78a07ff724d
https://github.com/google/fleetspeak/blob/bc95dd6941494461d2e5dff0a7f4c78a07ff724d/fleetspeak/src/client/daemonservice/client/client.py#L162-L181
6,634
google/fleetspeak
fleetspeak/src/client/daemonservice/client/client.py
FleetspeakConnection.Heartbeat
def Heartbeat(self): """Sends a heartbeat to the Fleetspeak client. If this daemonservice is configured to use heartbeats, clients that don't call this method often enough are considered faulty and are restarted by Fleetspeak. """ heartbeat_msg = common_pb2.Message( message_type="Heartb...
python
def Heartbeat(self): """Sends a heartbeat to the Fleetspeak client. If this daemonservice is configured to use heartbeats, clients that don't call this method often enough are considered faulty and are restarted by Fleetspeak. """ heartbeat_msg = common_pb2.Message( message_type="Heartb...
[ "def", "Heartbeat", "(", "self", ")", ":", "heartbeat_msg", "=", "common_pb2", ".", "Message", "(", "message_type", "=", "\"Heartbeat\"", ",", "destination", "=", "common_pb2", ".", "Address", "(", "service_name", "=", "\"system\"", ")", ")", "self", ".", "_...
Sends a heartbeat to the Fleetspeak client. If this daemonservice is configured to use heartbeats, clients that don't call this method often enough are considered faulty and are restarted by Fleetspeak.
[ "Sends", "a", "heartbeat", "to", "the", "Fleetspeak", "client", "." ]
bc95dd6941494461d2e5dff0a7f4c78a07ff724d
https://github.com/google/fleetspeak/blob/bc95dd6941494461d2e5dff0a7f4c78a07ff724d/fleetspeak/src/client/daemonservice/client/client.py#L183-L193
6,635
google/fleetspeak
fleetspeak/src/client/daemonservice/client/client.py
FleetspeakConnection._ReadN
def _ReadN(self, n): """Reads n characters from the input stream, or until EOF. This is equivalent to the current CPython implementation of read(n), but not guaranteed by the docs. Args: n: int Returns: string """ ret = "" while True: chunk = self._read_file.read(n -...
python
def _ReadN(self, n): """Reads n characters from the input stream, or until EOF. This is equivalent to the current CPython implementation of read(n), but not guaranteed by the docs. Args: n: int Returns: string """ ret = "" while True: chunk = self._read_file.read(n -...
[ "def", "_ReadN", "(", "self", ",", "n", ")", ":", "ret", "=", "\"\"", "while", "True", ":", "chunk", "=", "self", ".", "_read_file", ".", "read", "(", "n", "-", "len", "(", "ret", ")", ")", "ret", "+=", "chunk", "if", "len", "(", "ret", ")", ...
Reads n characters from the input stream, or until EOF. This is equivalent to the current CPython implementation of read(n), but not guaranteed by the docs. Args: n: int Returns: string
[ "Reads", "n", "characters", "from", "the", "input", "stream", "or", "until", "EOF", "." ]
bc95dd6941494461d2e5dff0a7f4c78a07ff724d
https://github.com/google/fleetspeak/blob/bc95dd6941494461d2e5dff0a7f4c78a07ff724d/fleetspeak/src/client/daemonservice/client/client.py#L214-L232
6,636
google/fleetspeak
setup.py
_CompileProtos
def _CompileProtos(): """Compiles all Fleetspeak protos.""" proto_files = [] for dir_path, _, filenames in os.walk(THIS_DIRECTORY): for filename in filenames: if filename.endswith(".proto"): proto_files.append(os.path.join(dir_path, filename)) if not proto_files: return protoc_command = ...
python
def _CompileProtos(): """Compiles all Fleetspeak protos.""" proto_files = [] for dir_path, _, filenames in os.walk(THIS_DIRECTORY): for filename in filenames: if filename.endswith(".proto"): proto_files.append(os.path.join(dir_path, filename)) if not proto_files: return protoc_command = ...
[ "def", "_CompileProtos", "(", ")", ":", "proto_files", "=", "[", "]", "for", "dir_path", ",", "_", ",", "filenames", "in", "os", ".", "walk", "(", "THIS_DIRECTORY", ")", ":", "for", "filename", "in", "filenames", ":", "if", "filename", ".", "endswith", ...
Compiles all Fleetspeak protos.
[ "Compiles", "all", "Fleetspeak", "protos", "." ]
bc95dd6941494461d2e5dff0a7f4c78a07ff724d
https://github.com/google/fleetspeak/blob/bc95dd6941494461d2e5dff0a7f4c78a07ff724d/setup.py#L42-L58
6,637
google/fleetspeak
fleetspeak/src/server/grpcservice/client/client.py
OutgoingConnection._RetryLoop
def _RetryLoop(self, func, timeout=None): """Retries an operation until success or deadline. Args: func: The function to run. Must take a timeout, in seconds, as a single parameter. If it raises grpc.RpcError and deadline has not be reached, it will be run again. timeout: Retries ...
python
def _RetryLoop(self, func, timeout=None): """Retries an operation until success or deadline. Args: func: The function to run. Must take a timeout, in seconds, as a single parameter. If it raises grpc.RpcError and deadline has not be reached, it will be run again. timeout: Retries ...
[ "def", "_RetryLoop", "(", "self", ",", "func", ",", "timeout", "=", "None", ")", ":", "timeout", "=", "timeout", "or", "self", ".", "DEFAULT_TIMEOUT", "deadline", "=", "time", ".", "time", "(", ")", "+", "timeout", "sleep", "=", "1", "while", "True", ...
Retries an operation until success or deadline. Args: func: The function to run. Must take a timeout, in seconds, as a single parameter. If it raises grpc.RpcError and deadline has not be reached, it will be run again. timeout: Retries will continue until timeout seconds have passed.
[ "Retries", "an", "operation", "until", "success", "or", "deadline", "." ]
bc95dd6941494461d2e5dff0a7f4c78a07ff724d
https://github.com/google/fleetspeak/blob/bc95dd6941494461d2e5dff0a7f4c78a07ff724d/fleetspeak/src/server/grpcservice/client/client.py#L150-L172
6,638
google/fleetspeak
fleetspeak/src/server/grpcservice/client/client.py
OutgoingConnection.InsertMessage
def InsertMessage(self, message, timeout=None): """Inserts a message into the Fleetspeak server. Sets message.source, if unset. Args: message: common_pb2.Message The message to send. timeout: How many seconds to try for. Raises: grpc.RpcError: if the RPC fails. Invali...
python
def InsertMessage(self, message, timeout=None): """Inserts a message into the Fleetspeak server. Sets message.source, if unset. Args: message: common_pb2.Message The message to send. timeout: How many seconds to try for. Raises: grpc.RpcError: if the RPC fails. Invali...
[ "def", "InsertMessage", "(", "self", ",", "message", ",", "timeout", "=", "None", ")", ":", "if", "not", "isinstance", "(", "message", ",", "common_pb2", ".", "Message", ")", ":", "raise", "InvalidArgument", "(", "\"Attempt to send unexpected message type: %s\"", ...
Inserts a message into the Fleetspeak server. Sets message.source, if unset. Args: message: common_pb2.Message The message to send. timeout: How many seconds to try for. Raises: grpc.RpcError: if the RPC fails. InvalidArgument: if message is not a common_pb2.Message.
[ "Inserts", "a", "message", "into", "the", "Fleetspeak", "server", "." ]
bc95dd6941494461d2e5dff0a7f4c78a07ff724d
https://github.com/google/fleetspeak/blob/bc95dd6941494461d2e5dff0a7f4c78a07ff724d/fleetspeak/src/server/grpcservice/client/client.py#L174-L202
6,639
google/fleetspeak
fleetspeak/src/server/grpcservice/client/client.py
OutgoingConnection.ListClients
def ListClients(self, request, timeout=None): """Provides basic information about Fleetspeak clients. Args: request: fleetspeak.admin.ListClientsRequest timeout: How many seconds to try for. Returns: fleetspeak.admin.ListClientsResponse """ return self._RetryLoop( lambda t: se...
python
def ListClients(self, request, timeout=None): """Provides basic information about Fleetspeak clients. Args: request: fleetspeak.admin.ListClientsRequest timeout: How many seconds to try for. Returns: fleetspeak.admin.ListClientsResponse """ return self._RetryLoop( lambda t: se...
[ "def", "ListClients", "(", "self", ",", "request", ",", "timeout", "=", "None", ")", ":", "return", "self", ".", "_RetryLoop", "(", "lambda", "t", ":", "self", ".", "_stub", ".", "ListClients", "(", "request", ",", "timeout", "=", "t", ")", ")" ]
Provides basic information about Fleetspeak clients. Args: request: fleetspeak.admin.ListClientsRequest timeout: How many seconds to try for. Returns: fleetspeak.admin.ListClientsResponse
[ "Provides", "basic", "information", "about", "Fleetspeak", "clients", "." ]
bc95dd6941494461d2e5dff0a7f4c78a07ff724d
https://github.com/google/fleetspeak/blob/bc95dd6941494461d2e5dff0a7f4c78a07ff724d/fleetspeak/src/server/grpcservice/client/client.py#L204-L215
6,640
google/fleetspeak
fleetspeak/src/server/grpcservice/client/client.py
InsecureGRPCServiceClient.Send
def Send(self, message): """Send one message. Deprecated, users should migrate to call self.outgoing.InsertMessage directly. """ if not self.outgoing: raise NotConfigured("Send address not provided.") self.outgoing.InsertMessage(message)
python
def Send(self, message): """Send one message. Deprecated, users should migrate to call self.outgoing.InsertMessage directly. """ if not self.outgoing: raise NotConfigured("Send address not provided.") self.outgoing.InsertMessage(message)
[ "def", "Send", "(", "self", ",", "message", ")", ":", "if", "not", "self", ".", "outgoing", ":", "raise", "NotConfigured", "(", "\"Send address not provided.\"", ")", "self", ".", "outgoing", ".", "InsertMessage", "(", "message", ")" ]
Send one message. Deprecated, users should migrate to call self.outgoing.InsertMessage directly.
[ "Send", "one", "message", "." ]
bc95dd6941494461d2e5dff0a7f4c78a07ff724d
https://github.com/google/fleetspeak/blob/bc95dd6941494461d2e5dff0a7f4c78a07ff724d/fleetspeak/src/server/grpcservice/client/client.py#L325-L333
6,641
reiinakano/xcessiv
xcessiv/automatedruns.py
start_naive_bayes
def start_naive_bayes(automated_run, session, path): """Starts naive bayes automated run Args: automated_run (xcessiv.models.AutomatedRun): Automated run object session: Valid SQLAlchemy session path (str, unicode): Path to project folder """ module = functions.import_string_c...
python
def start_naive_bayes(automated_run, session, path): """Starts naive bayes automated run Args: automated_run (xcessiv.models.AutomatedRun): Automated run object session: Valid SQLAlchemy session path (str, unicode): Path to project folder """ module = functions.import_string_c...
[ "def", "start_naive_bayes", "(", "automated_run", ",", "session", ",", "path", ")", ":", "module", "=", "functions", ".", "import_string_code_as_module", "(", "automated_run", ".", "source", ")", "random_state", "=", "8", "if", "not", "hasattr", "(", "module", ...
Starts naive bayes automated run Args: automated_run (xcessiv.models.AutomatedRun): Automated run object session: Valid SQLAlchemy session path (str, unicode): Path to project folder
[ "Starts", "naive", "bayes", "automated", "run" ]
a48dff7d370c84eb5c243bde87164c1f5fd096d5
https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/automatedruns.py#L139-L207
6,642
reiinakano/xcessiv
xcessiv/automatedruns.py
start_tpot
def start_tpot(automated_run, session, path): """Starts a TPOT automated run that exports directly to base learner setup Args: automated_run (xcessiv.models.AutomatedRun): Automated run object session: Valid SQLAlchemy session path (str, unicode): Path to project folder """ mo...
python
def start_tpot(automated_run, session, path): """Starts a TPOT automated run that exports directly to base learner setup Args: automated_run (xcessiv.models.AutomatedRun): Automated run object session: Valid SQLAlchemy session path (str, unicode): Path to project folder """ mo...
[ "def", "start_tpot", "(", "automated_run", ",", "session", ",", "path", ")", ":", "module", "=", "functions", ".", "import_string_code_as_module", "(", "automated_run", ".", "source", ")", "extraction", "=", "session", ".", "query", "(", "models", ".", "Extrac...
Starts a TPOT automated run that exports directly to base learner setup Args: automated_run (xcessiv.models.AutomatedRun): Automated run object session: Valid SQLAlchemy session path (str, unicode): Path to project folder
[ "Starts", "a", "TPOT", "automated", "run", "that", "exports", "directly", "to", "base", "learner", "setup" ]
a48dff7d370c84eb5c243bde87164c1f5fd096d5
https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/automatedruns.py#L210-L248
6,643
reiinakano/xcessiv
xcessiv/automatedruns.py
start_greedy_ensemble_search
def start_greedy_ensemble_search(automated_run, session, path): """Starts an automated ensemble search using greedy forward model selection. The steps for this search are adapted from "Ensemble Selection from Libraries of Models" by Caruana. 1. Start with the empty ensemble 2. Add to the ensemble...
python
def start_greedy_ensemble_search(automated_run, session, path): """Starts an automated ensemble search using greedy forward model selection. The steps for this search are adapted from "Ensemble Selection from Libraries of Models" by Caruana. 1. Start with the empty ensemble 2. Add to the ensemble...
[ "def", "start_greedy_ensemble_search", "(", "automated_run", ",", "session", ",", "path", ")", ":", "module", "=", "functions", ".", "import_string_code_as_module", "(", "automated_run", ".", "source", ")", "assert", "module", ".", "metric_to_optimize", "in", "autom...
Starts an automated ensemble search using greedy forward model selection. The steps for this search are adapted from "Ensemble Selection from Libraries of Models" by Caruana. 1. Start with the empty ensemble 2. Add to the ensemble the model in the library that maximizes the ensemmble's performanc...
[ "Starts", "an", "automated", "ensemble", "search", "using", "greedy", "forward", "model", "selection", "." ]
a48dff7d370c84eb5c243bde87164c1f5fd096d5
https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/automatedruns.py#L331-L398
6,644
reiinakano/xcessiv
xcessiv/rqtasks.py
extraction_data_statistics
def extraction_data_statistics(path): """ Generates data statistics for the given data extraction setup stored in Xcessiv notebook. This is in rqtasks.py but not as a job yet. Temporarily call this directly while I'm figuring out Javascript lel. Args: path (str, unicode): Path to xcessiv n...
python
def extraction_data_statistics(path): """ Generates data statistics for the given data extraction setup stored in Xcessiv notebook. This is in rqtasks.py but not as a job yet. Temporarily call this directly while I'm figuring out Javascript lel. Args: path (str, unicode): Path to xcessiv n...
[ "def", "extraction_data_statistics", "(", "path", ")", ":", "with", "functions", ".", "DBContextManager", "(", "path", ")", "as", "session", ":", "extraction", "=", "session", ".", "query", "(", "models", ".", "Extraction", ")", ".", "first", "(", ")", "X"...
Generates data statistics for the given data extraction setup stored in Xcessiv notebook. This is in rqtasks.py but not as a job yet. Temporarily call this directly while I'm figuring out Javascript lel. Args: path (str, unicode): Path to xcessiv notebook
[ "Generates", "data", "statistics", "for", "the", "given", "data", "extraction", "setup", "stored", "in", "Xcessiv", "notebook", "." ]
a48dff7d370c84eb5c243bde87164c1f5fd096d5
https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/rqtasks.py#L17-L95
6,645
reiinakano/xcessiv
xcessiv/rqtasks.py
generate_meta_features
def generate_meta_features(path, base_learner_id): """Generates meta-features for specified base learner After generation of meta-features, the file is saved into the meta-features folder Args: path (str): Path to Xcessiv notebook base_learner_id (str): Base learner ID """ with fu...
python
def generate_meta_features(path, base_learner_id): """Generates meta-features for specified base learner After generation of meta-features, the file is saved into the meta-features folder Args: path (str): Path to Xcessiv notebook base_learner_id (str): Base learner ID """ with fu...
[ "def", "generate_meta_features", "(", "path", ",", "base_learner_id", ")", ":", "with", "functions", ".", "DBContextManager", "(", "path", ")", "as", "session", ":", "base_learner", "=", "session", ".", "query", "(", "models", ".", "BaseLearner", ")", ".", "...
Generates meta-features for specified base learner After generation of meta-features, the file is saved into the meta-features folder Args: path (str): Path to Xcessiv notebook base_learner_id (str): Base learner ID
[ "Generates", "meta", "-", "features", "for", "specified", "base", "learner" ]
a48dff7d370c84eb5c243bde87164c1f5fd096d5
https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/rqtasks.py#L99-L171
6,646
reiinakano/xcessiv
xcessiv/rqtasks.py
start_automated_run
def start_automated_run(path, automated_run_id): """Starts automated run. This will automatically create base learners until the run finishes or errors out. Args: path (str): Path to Xcessiv notebook automated_run_id (str): Automated Run ID """ with functions.DBContextManager(path)...
python
def start_automated_run(path, automated_run_id): """Starts automated run. This will automatically create base learners until the run finishes or errors out. Args: path (str): Path to Xcessiv notebook automated_run_id (str): Automated Run ID """ with functions.DBContextManager(path)...
[ "def", "start_automated_run", "(", "path", ",", "automated_run_id", ")", ":", "with", "functions", ".", "DBContextManager", "(", "path", ")", "as", "session", ":", "automated_run", "=", "session", ".", "query", "(", "models", ".", "AutomatedRun", ")", ".", "...
Starts automated run. This will automatically create base learners until the run finishes or errors out. Args: path (str): Path to Xcessiv notebook automated_run_id (str): Automated Run ID
[ "Starts", "automated", "run", ".", "This", "will", "automatically", "create", "base", "learners", "until", "the", "run", "finishes", "or", "errors", "out", "." ]
a48dff7d370c84eb5c243bde87164c1f5fd096d5
https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/rqtasks.py#L175-L221
6,647
reiinakano/xcessiv
xcessiv/functions.py
hash_file
def hash_file(path, block_size=65536): """Returns SHA256 checksum of a file Args: path (string): Absolute file path of file to hash block_size (int, optional): Number of bytes to read per block """ sha256 = hashlib.sha256() with open(path, 'rb') as f: for block in iter(lamb...
python
def hash_file(path, block_size=65536): """Returns SHA256 checksum of a file Args: path (string): Absolute file path of file to hash block_size (int, optional): Number of bytes to read per block """ sha256 = hashlib.sha256() with open(path, 'rb') as f: for block in iter(lamb...
[ "def", "hash_file", "(", "path", ",", "block_size", "=", "65536", ")", ":", "sha256", "=", "hashlib", ".", "sha256", "(", ")", "with", "open", "(", "path", ",", "'rb'", ")", "as", "f", ":", "for", "block", "in", "iter", "(", "lambda", ":", "f", "...
Returns SHA256 checksum of a file Args: path (string): Absolute file path of file to hash block_size (int, optional): Number of bytes to read per block
[ "Returns", "SHA256", "checksum", "of", "a", "file" ]
a48dff7d370c84eb5c243bde87164c1f5fd096d5
https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/functions.py#L16-L28
6,648
reiinakano/xcessiv
xcessiv/functions.py
import_object_from_path
def import_object_from_path(path, object): """Used to import an object from an absolute path. This function takes an absolute path and imports it as a Python module. It then returns the object with name `object` from the imported module. Args: path (string): Absolute file path of .py file to i...
python
def import_object_from_path(path, object): """Used to import an object from an absolute path. This function takes an absolute path and imports it as a Python module. It then returns the object with name `object` from the imported module. Args: path (string): Absolute file path of .py file to i...
[ "def", "import_object_from_path", "(", "path", ",", "object", ")", ":", "with", "open", "(", "path", ")", "as", "f", ":", "return", "import_object_from_string_code", "(", "f", ".", "read", "(", ")", ",", "object", ")" ]
Used to import an object from an absolute path. This function takes an absolute path and imports it as a Python module. It then returns the object with name `object` from the imported module. Args: path (string): Absolute file path of .py file to import object (string): Name of object to ...
[ "Used", "to", "import", "an", "object", "from", "an", "absolute", "path", "." ]
a48dff7d370c84eb5c243bde87164c1f5fd096d5
https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/functions.py#L36-L48
6,649
reiinakano/xcessiv
xcessiv/functions.py
import_object_from_string_code
def import_object_from_string_code(code, object): """Used to import an object from arbitrary passed code. Passed in code is treated as a module and is imported and added to `sys.modules` with its SHA256 hash as key. Args: code (string): Python code to import as module object (string):...
python
def import_object_from_string_code(code, object): """Used to import an object from arbitrary passed code. Passed in code is treated as a module and is imported and added to `sys.modules` with its SHA256 hash as key. Args: code (string): Python code to import as module object (string):...
[ "def", "import_object_from_string_code", "(", "code", ",", "object", ")", ":", "sha256", "=", "hashlib", ".", "sha256", "(", "code", ".", "encode", "(", "'UTF-8'", ")", ")", ".", "hexdigest", "(", ")", "module", "=", "imp", ".", "new_module", "(", "sha25...
Used to import an object from arbitrary passed code. Passed in code is treated as a module and is imported and added to `sys.modules` with its SHA256 hash as key. Args: code (string): Python code to import as module object (string): Name of object to extract from imported module
[ "Used", "to", "import", "an", "object", "from", "arbitrary", "passed", "code", "." ]
a48dff7d370c84eb5c243bde87164c1f5fd096d5
https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/functions.py#L51-L72
6,650
reiinakano/xcessiv
xcessiv/functions.py
import_string_code_as_module
def import_string_code_as_module(code): """Used to run arbitrary passed code as a module Args: code (string): Python code to import as module Returns: module: Python module """ sha256 = hashlib.sha256(code.encode('UTF-8')).hexdigest() module = imp.new_module(sha256) try: ...
python
def import_string_code_as_module(code): """Used to run arbitrary passed code as a module Args: code (string): Python code to import as module Returns: module: Python module """ sha256 = hashlib.sha256(code.encode('UTF-8')).hexdigest() module = imp.new_module(sha256) try: ...
[ "def", "import_string_code_as_module", "(", "code", ")", ":", "sha256", "=", "hashlib", ".", "sha256", "(", "code", ".", "encode", "(", "'UTF-8'", ")", ")", ".", "hexdigest", "(", ")", "module", "=", "imp", ".", "new_module", "(", "sha256", ")", "try", ...
Used to run arbitrary passed code as a module Args: code (string): Python code to import as module Returns: module: Python module
[ "Used", "to", "run", "arbitrary", "passed", "code", "as", "a", "module" ]
a48dff7d370c84eb5c243bde87164c1f5fd096d5
https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/functions.py#L75-L91
6,651
reiinakano/xcessiv
xcessiv/functions.py
verify_dataset
def verify_dataset(X, y): """Verifies if a dataset is valid for use i.e. scikit-learn format Used to verify a dataset by returning shape and basic statistics of returned data. This will also provide quick and dirty check on capability of host machine to process the data. Args: X (array-lik...
python
def verify_dataset(X, y): """Verifies if a dataset is valid for use i.e. scikit-learn format Used to verify a dataset by returning shape and basic statistics of returned data. This will also provide quick and dirty check on capability of host machine to process the data. Args: X (array-lik...
[ "def", "verify_dataset", "(", "X", ",", "y", ")", ":", "X_shape", ",", "y_shape", "=", "np", ".", "array", "(", "X", ")", ".", "shape", ",", "np", ".", "array", "(", "y", ")", ".", "shape", "if", "len", "(", "X_shape", ")", "!=", "2", ":", "r...
Verifies if a dataset is valid for use i.e. scikit-learn format Used to verify a dataset by returning shape and basic statistics of returned data. This will also provide quick and dirty check on capability of host machine to process the data. Args: X (array-like): Features array y (ar...
[ "Verifies", "if", "a", "dataset", "is", "valid", "for", "use", "i", ".", "e", ".", "scikit", "-", "learn", "format" ]
a48dff7d370c84eb5c243bde87164c1f5fd096d5
https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/functions.py#L94-L127
6,652
reiinakano/xcessiv
xcessiv/functions.py
make_serializable
def make_serializable(json): """This function ensures that the dictionary is JSON serializable. If not, keys with non-serializable values are removed from the return value. Args: json (dict): Dictionary to convert to serializable Returns: new_dict (dict): New dictionary with non JSON s...
python
def make_serializable(json): """This function ensures that the dictionary is JSON serializable. If not, keys with non-serializable values are removed from the return value. Args: json (dict): Dictionary to convert to serializable Returns: new_dict (dict): New dictionary with non JSON s...
[ "def", "make_serializable", "(", "json", ")", ":", "new_dict", "=", "dict", "(", ")", "for", "key", ",", "value", "in", "iteritems", "(", "json", ")", ":", "if", "is_valid_json", "(", "value", ")", ":", "new_dict", "[", "key", "]", "=", "value", "ret...
This function ensures that the dictionary is JSON serializable. If not, keys with non-serializable values are removed from the return value. Args: json (dict): Dictionary to convert to serializable Returns: new_dict (dict): New dictionary with non JSON serializable values removed
[ "This", "function", "ensures", "that", "the", "dictionary", "is", "JSON", "serializable", ".", "If", "not", "keys", "with", "non", "-", "serializable", "values", "are", "removed", "from", "the", "return", "value", "." ]
a48dff7d370c84eb5c243bde87164c1f5fd096d5
https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/functions.py#L143-L158
6,653
reiinakano/xcessiv
xcessiv/functions.py
get_sample_dataset
def get_sample_dataset(dataset_properties): """Returns sample dataset Args: dataset_properties (dict): Dictionary corresponding to the properties of the dataset used to verify the estimator and metric generators. Returns: X (array-like): Features array y (array-like): ...
python
def get_sample_dataset(dataset_properties): """Returns sample dataset Args: dataset_properties (dict): Dictionary corresponding to the properties of the dataset used to verify the estimator and metric generators. Returns: X (array-like): Features array y (array-like): ...
[ "def", "get_sample_dataset", "(", "dataset_properties", ")", ":", "kwargs", "=", "dataset_properties", ".", "copy", "(", ")", "data_type", "=", "kwargs", ".", "pop", "(", "'type'", ")", "if", "data_type", "==", "'multiclass'", ":", "try", ":", "X", ",", "y...
Returns sample dataset Args: dataset_properties (dict): Dictionary corresponding to the properties of the dataset used to verify the estimator and metric generators. Returns: X (array-like): Features array y (array-like): Labels array splits (iterator): This is an...
[ "Returns", "sample", "dataset" ]
a48dff7d370c84eb5c243bde87164c1f5fd096d5
https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/functions.py#L161-L201
6,654
reiinakano/xcessiv
xcessiv/functions.py
verify_estimator_class
def verify_estimator_class(est, meta_feature_generator, metric_generators, dataset_properties): """Verify if estimator object is valid for use i.e. scikit-learn format Verifies if an estimator is fit for use by testing for existence of methods such as `get_params` and `set_params`. Must also be able to pro...
python
def verify_estimator_class(est, meta_feature_generator, metric_generators, dataset_properties): """Verify if estimator object is valid for use i.e. scikit-learn format Verifies if an estimator is fit for use by testing for existence of methods such as `get_params` and `set_params`. Must also be able to pro...
[ "def", "verify_estimator_class", "(", "est", ",", "meta_feature_generator", ",", "metric_generators", ",", "dataset_properties", ")", ":", "X", ",", "y", ",", "splits", "=", "get_sample_dataset", "(", "dataset_properties", ")", "if", "not", "hasattr", "(", "est", ...
Verify if estimator object is valid for use i.e. scikit-learn format Verifies if an estimator is fit for use by testing for existence of methods such as `get_params` and `set_params`. Must also be able to properly fit on and predict a sample iris dataset. Args: est: Estimator object with `fit`...
[ "Verify", "if", "estimator", "object", "is", "valid", "for", "use", "i", ".", "e", ".", "scikit", "-", "learn", "format" ]
a48dff7d370c84eb5c243bde87164c1f5fd096d5
https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/functions.py#L204-L275
6,655
reiinakano/xcessiv
xcessiv/functions.py
get_path_from_query_string
def get_path_from_query_string(req): """Gets path from query string Args: req (flask.request): Request object from Flask Returns: path (str): Value of "path" parameter from query string Raises: exceptions.UserError: If "path" is not found in query string """ if req.arg...
python
def get_path_from_query_string(req): """Gets path from query string Args: req (flask.request): Request object from Flask Returns: path (str): Value of "path" parameter from query string Raises: exceptions.UserError: If "path" is not found in query string """ if req.arg...
[ "def", "get_path_from_query_string", "(", "req", ")", ":", "if", "req", ".", "args", ".", "get", "(", "'path'", ")", "is", "None", ":", "raise", "exceptions", ".", "UserError", "(", "'Path not found in query string'", ")", "return", "req", ".", "args", ".", ...
Gets path from query string Args: req (flask.request): Request object from Flask Returns: path (str): Value of "path" parameter from query string Raises: exceptions.UserError: If "path" is not found in query string
[ "Gets", "path", "from", "query", "string" ]
a48dff7d370c84eb5c243bde87164c1f5fd096d5
https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/functions.py#L278-L292
6,656
reiinakano/xcessiv
xcessiv/models.py
Extraction.return_main_dataset
def return_main_dataset(self): """Returns main data set from self Returns: X (numpy.ndarray): Features y (numpy.ndarray): Labels """ if not self.main_dataset['source']: raise exceptions.UserError('Source is empty') extraction_code = self.mai...
python
def return_main_dataset(self): """Returns main data set from self Returns: X (numpy.ndarray): Features y (numpy.ndarray): Labels """ if not self.main_dataset['source']: raise exceptions.UserError('Source is empty') extraction_code = self.mai...
[ "def", "return_main_dataset", "(", "self", ")", ":", "if", "not", "self", ".", "main_dataset", "[", "'source'", "]", ":", "raise", "exceptions", ".", "UserError", "(", "'Source is empty'", ")", "extraction_code", "=", "self", ".", "main_dataset", "[", "\"sourc...
Returns main data set from self Returns: X (numpy.ndarray): Features y (numpy.ndarray): Labels
[ "Returns", "main", "data", "set", "from", "self" ]
a48dff7d370c84eb5c243bde87164c1f5fd096d5
https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/models.py#L70-L92
6,657
reiinakano/xcessiv
xcessiv/models.py
Extraction.return_train_dataset
def return_train_dataset(self): """Returns train data set Returns: X (numpy.ndarray): Features y (numpy.ndarray): Labels """ X, y = self.return_main_dataset() if self.test_dataset['method'] == 'split_from_main': X, X_test, y, y_test = train_...
python
def return_train_dataset(self): """Returns train data set Returns: X (numpy.ndarray): Features y (numpy.ndarray): Labels """ X, y = self.return_main_dataset() if self.test_dataset['method'] == 'split_from_main': X, X_test, y, y_test = train_...
[ "def", "return_train_dataset", "(", "self", ")", ":", "X", ",", "y", "=", "self", ".", "return_main_dataset", "(", ")", "if", "self", ".", "test_dataset", "[", "'method'", "]", "==", "'split_from_main'", ":", "X", ",", "X_test", ",", "y", ",", "y_test", ...
Returns train data set Returns: X (numpy.ndarray): Features y (numpy.ndarray): Labels
[ "Returns", "train", "data", "set" ]
a48dff7d370c84eb5c243bde87164c1f5fd096d5
https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/models.py#L94-L113
6,658
reiinakano/xcessiv
xcessiv/models.py
BaseLearnerOrigin.return_estimator
def return_estimator(self): """Returns estimator from base learner origin Returns: est (estimator): Estimator object """ extraction_code = self.source estimator = functions.import_object_from_string_code(extraction_code, "base_learner") return estimator
python
def return_estimator(self): """Returns estimator from base learner origin Returns: est (estimator): Estimator object """ extraction_code = self.source estimator = functions.import_object_from_string_code(extraction_code, "base_learner") return estimator
[ "def", "return_estimator", "(", "self", ")", ":", "extraction_code", "=", "self", ".", "source", "estimator", "=", "functions", ".", "import_object_from_string_code", "(", "extraction_code", ",", "\"base_learner\"", ")", "return", "estimator" ]
Returns estimator from base learner origin Returns: est (estimator): Estimator object
[ "Returns", "estimator", "from", "base", "learner", "origin" ]
a48dff7d370c84eb5c243bde87164c1f5fd096d5
https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/models.py#L192-L201
6,659
reiinakano/xcessiv
xcessiv/models.py
BaseLearnerOrigin.export_as_file
def export_as_file(self, filepath, hyperparameters): """Generates a Python file with the importable base learner set to ``hyperparameters`` This function generates a Python file in the specified file path that contains the base learner as an importable variable stored in ``base_learner``. The...
python
def export_as_file(self, filepath, hyperparameters): """Generates a Python file with the importable base learner set to ``hyperparameters`` This function generates a Python file in the specified file path that contains the base learner as an importable variable stored in ``base_learner``. The...
[ "def", "export_as_file", "(", "self", ",", "filepath", ",", "hyperparameters", ")", ":", "if", "not", "filepath", ".", "endswith", "(", "'.py'", ")", ":", "filepath", "+=", "'.py'", "file_contents", "=", "''", "file_contents", "+=", "self", ".", "source", ...
Generates a Python file with the importable base learner set to ``hyperparameters`` This function generates a Python file in the specified file path that contains the base learner as an importable variable stored in ``base_learner``. The base learner will be set to the appropriate hyperpara...
[ "Generates", "a", "Python", "file", "with", "the", "importable", "base", "learner", "set", "to", "hyperparameters" ]
a48dff7d370c84eb5c243bde87164c1f5fd096d5
https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/models.py#L212-L232
6,660
reiinakano/xcessiv
xcessiv/models.py
BaseLearner.return_estimator
def return_estimator(self): """Returns base learner using its origin and the given hyperparameters Returns: est (estimator): Estimator object """ estimator = self.base_learner_origin.return_estimator() estimator = estimator.set_params(**self.hyperparameters) ...
python
def return_estimator(self): """Returns base learner using its origin and the given hyperparameters Returns: est (estimator): Estimator object """ estimator = self.base_learner_origin.return_estimator() estimator = estimator.set_params(**self.hyperparameters) ...
[ "def", "return_estimator", "(", "self", ")", ":", "estimator", "=", "self", ".", "base_learner_origin", ".", "return_estimator", "(", ")", "estimator", "=", "estimator", ".", "set_params", "(", "*", "*", "self", ".", "hyperparameters", ")", "return", "estimato...
Returns base learner using its origin and the given hyperparameters Returns: est (estimator): Estimator object
[ "Returns", "base", "learner", "using", "its", "origin", "and", "the", "given", "hyperparameters" ]
a48dff7d370c84eb5c243bde87164c1f5fd096d5
https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/models.py#L307-L315
6,661
reiinakano/xcessiv
xcessiv/models.py
BaseLearner.meta_features_path
def meta_features_path(self, path): """Returns path for meta-features Args: path (str): Absolute/local path of xcessiv folder """ return os.path.join( path, app.config['XCESSIV_META_FEATURES_FOLDER'], str(self.id) )...
python
def meta_features_path(self, path): """Returns path for meta-features Args: path (str): Absolute/local path of xcessiv folder """ return os.path.join( path, app.config['XCESSIV_META_FEATURES_FOLDER'], str(self.id) )...
[ "def", "meta_features_path", "(", "self", ",", "path", ")", ":", "return", "os", ".", "path", ".", "join", "(", "path", ",", "app", ".", "config", "[", "'XCESSIV_META_FEATURES_FOLDER'", "]", ",", "str", "(", "self", ".", "id", ")", ")", "+", "'.npy'" ]
Returns path for meta-features Args: path (str): Absolute/local path of xcessiv folder
[ "Returns", "path", "for", "meta", "-", "features" ]
a48dff7d370c84eb5c243bde87164c1f5fd096d5
https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/models.py#L317-L327
6,662
reiinakano/xcessiv
xcessiv/models.py
BaseLearner.delete_meta_features
def delete_meta_features(self, path): """Deletes meta-features of base learner if it exists Args: path (str): Absolute/local path of xcessiv folder """ if os.path.exists(self.meta_features_path(path)): os.remove(self.meta_features_path(path))
python
def delete_meta_features(self, path): """Deletes meta-features of base learner if it exists Args: path (str): Absolute/local path of xcessiv folder """ if os.path.exists(self.meta_features_path(path)): os.remove(self.meta_features_path(path))
[ "def", "delete_meta_features", "(", "self", ",", "path", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "self", ".", "meta_features_path", "(", "path", ")", ")", ":", "os", ".", "remove", "(", "self", ".", "meta_features_path", "(", "path", ")"...
Deletes meta-features of base learner if it exists Args: path (str): Absolute/local path of xcessiv folder
[ "Deletes", "meta", "-", "features", "of", "base", "learner", "if", "it", "exists" ]
a48dff7d370c84eb5c243bde87164c1f5fd096d5
https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/models.py#L342-L349
6,663
reiinakano/xcessiv
xcessiv/models.py
StackedEnsemble.return_secondary_learner
def return_secondary_learner(self): """Returns secondary learner using its origin and the given hyperparameters Returns: est (estimator): Estimator object """ estimator = self.base_learner_origin.return_estimator() estimator = estimator.set_params(**self.secondary_le...
python
def return_secondary_learner(self): """Returns secondary learner using its origin and the given hyperparameters Returns: est (estimator): Estimator object """ estimator = self.base_learner_origin.return_estimator() estimator = estimator.set_params(**self.secondary_le...
[ "def", "return_secondary_learner", "(", "self", ")", ":", "estimator", "=", "self", ".", "base_learner_origin", ".", "return_estimator", "(", ")", "estimator", "=", "estimator", ".", "set_params", "(", "*", "*", "self", ".", "secondary_learner_hyperparameters", ")...
Returns secondary learner using its origin and the given hyperparameters Returns: est (estimator): Estimator object
[ "Returns", "secondary", "learner", "using", "its", "origin", "and", "the", "given", "hyperparameters" ]
a48dff7d370c84eb5c243bde87164c1f5fd096d5
https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/models.py#L402-L410
6,664
reiinakano/xcessiv
xcessiv/models.py
StackedEnsemble.export_as_code
def export_as_code(self, cv_source): """Returns a string value that contains the Python code for the ensemble Args: cv_source (str, unicode): String containing actual code for base learner cross-validation used to generate secondary meta-features. Returns: ...
python
def export_as_code(self, cv_source): """Returns a string value that contains the Python code for the ensemble Args: cv_source (str, unicode): String containing actual code for base learner cross-validation used to generate secondary meta-features. Returns: ...
[ "def", "export_as_code", "(", "self", ",", "cv_source", ")", ":", "rand_value", "=", "''", ".", "join", "(", "random", ".", "choice", "(", "string", ".", "ascii_uppercase", "+", "string", ".", "digits", ")", "for", "_", "in", "range", "(", "25", ")", ...
Returns a string value that contains the Python code for the ensemble Args: cv_source (str, unicode): String containing actual code for base learner cross-validation used to generate secondary meta-features. Returns: base_learner_code (str, unicode): String that...
[ "Returns", "a", "string", "value", "that", "contains", "the", "Python", "code", "for", "the", "ensemble" ]
a48dff7d370c84eb5c243bde87164c1f5fd096d5
https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/models.py#L412-L486
6,665
reiinakano/xcessiv
xcessiv/models.py
StackedEnsemble.export_as_file
def export_as_file(self, file_path, cv_source): """Export the ensemble as a single Python file and saves it to `file_path`. This is EXPERIMENTAL as putting different modules together would probably wreak havoc especially on modules that make heavy use of global variables. Args: ...
python
def export_as_file(self, file_path, cv_source): """Export the ensemble as a single Python file and saves it to `file_path`. This is EXPERIMENTAL as putting different modules together would probably wreak havoc especially on modules that make heavy use of global variables. Args: ...
[ "def", "export_as_file", "(", "self", ",", "file_path", ",", "cv_source", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "file_path", ")", ":", "raise", "exceptions", ".", "UserError", "(", "'{} already exists'", ".", "format", "(", "file_path", ")...
Export the ensemble as a single Python file and saves it to `file_path`. This is EXPERIMENTAL as putting different modules together would probably wreak havoc especially on modules that make heavy use of global variables. Args: file_path (str, unicode): Absolute/local path of place...
[ "Export", "the", "ensemble", "as", "a", "single", "Python", "file", "and", "saves", "it", "to", "file_path", "." ]
a48dff7d370c84eb5c243bde87164c1f5fd096d5
https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/models.py#L488-L504
6,666
reiinakano/xcessiv
xcessiv/models.py
StackedEnsemble.export_as_package
def export_as_package(self, package_path, cv_source): """Exports the ensemble as a Python package and saves it to `package_path`. Args: package_path (str, unicode): Absolute/local path of place to save package in cv_source (str, unicode): String containing actual code for base ...
python
def export_as_package(self, package_path, cv_source): """Exports the ensemble as a Python package and saves it to `package_path`. Args: package_path (str, unicode): Absolute/local path of place to save package in cv_source (str, unicode): String containing actual code for base ...
[ "def", "export_as_package", "(", "self", ",", "package_path", ",", "cv_source", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "package_path", ")", ":", "raise", "exceptions", ".", "UserError", "(", "'{} already exists'", ".", "format", "(", "package...
Exports the ensemble as a Python package and saves it to `package_path`. Args: package_path (str, unicode): Absolute/local path of place to save package in cv_source (str, unicode): String containing actual code for base learner cross-validation used to generate seconda...
[ "Exports", "the", "ensemble", "as", "a", "Python", "package", "and", "saves", "it", "to", "package_path", "." ]
a48dff7d370c84eb5c243bde87164c1f5fd096d5
https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/models.py#L506-L591
6,667
reiinakano/xcessiv
xcessiv/views.py
verify_full_extraction
def verify_full_extraction(): """This is an experimental endpoint to simultaneously verify data statistics and extraction for training, test, and holdout datasets. With this, the other three verification methods will no longer be necessary. """ path = functions.get_path_from_query_string(request...
python
def verify_full_extraction(): """This is an experimental endpoint to simultaneously verify data statistics and extraction for training, test, and holdout datasets. With this, the other three verification methods will no longer be necessary. """ path = functions.get_path_from_query_string(request...
[ "def", "verify_full_extraction", "(", ")", ":", "path", "=", "functions", ".", "get_path_from_query_string", "(", "request", ")", "if", "request", ".", "method", "==", "'POST'", ":", "rqtasks", ".", "extraction_data_statistics", "(", "path", ")", "with", "functi...
This is an experimental endpoint to simultaneously verify data statistics and extraction for training, test, and holdout datasets. With this, the other three verification methods will no longer be necessary.
[ "This", "is", "an", "experimental", "endpoint", "to", "simultaneously", "verify", "data", "statistics", "and", "extraction", "for", "training", "test", "and", "holdout", "datasets", ".", "With", "this", "the", "other", "three", "verification", "methods", "will", ...
a48dff7d370c84eb5c243bde87164c1f5fd096d5
https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/views.py#L156-L169
6,668
reiinakano/xcessiv
xcessiv/views.py
create_base_learner
def create_base_learner(id): """This creates a single base learner from a base learner origin and queues it up""" path = functions.get_path_from_query_string(request) with functions.DBContextManager(path) as session: base_learner_origin = session.query(models.BaseLearnerOrigin).filter_by(id=id).fir...
python
def create_base_learner(id): """This creates a single base learner from a base learner origin and queues it up""" path = functions.get_path_from_query_string(request) with functions.DBContextManager(path) as session: base_learner_origin = session.query(models.BaseLearnerOrigin).filter_by(id=id).fir...
[ "def", "create_base_learner", "(", "id", ")", ":", "path", "=", "functions", ".", "get_path_from_query_string", "(", "request", ")", "with", "functions", ".", "DBContextManager", "(", "path", ")", "as", "session", ":", "base_learner_origin", "=", "session", ".",...
This creates a single base learner from a base learner origin and queues it up
[ "This", "creates", "a", "single", "base", "learner", "from", "a", "base", "learner", "origin", "and", "queues", "it", "up" ]
a48dff7d370c84eb5c243bde87164c1f5fd096d5
https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/views.py#L306-L348
6,669
reiinakano/xcessiv
xcessiv/views.py
search_base_learner
def search_base_learner(id): """Creates a set of base learners from base learner origin using grid search and queues them up """ path = functions.get_path_from_query_string(request) req_body = request.get_json() if req_body['method'] == 'grid': param_grid = functions.import_object_from_s...
python
def search_base_learner(id): """Creates a set of base learners from base learner origin using grid search and queues them up """ path = functions.get_path_from_query_string(request) req_body = request.get_json() if req_body['method'] == 'grid': param_grid = functions.import_object_from_s...
[ "def", "search_base_learner", "(", "id", ")", ":", "path", "=", "functions", ".", "get_path_from_query_string", "(", "request", ")", "req_body", "=", "request", ".", "get_json", "(", ")", "if", "req_body", "[", "'method'", "]", "==", "'grid'", ":", "param_gr...
Creates a set of base learners from base learner origin using grid search and queues them up
[ "Creates", "a", "set", "of", "base", "learners", "from", "base", "learner", "origin", "using", "grid", "search", "and", "queues", "them", "up" ]
a48dff7d370c84eb5c243bde87164c1f5fd096d5
https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/views.py#L352-L424
6,670
reiinakano/xcessiv
xcessiv/views.py
get_automated_runs
def get_automated_runs(): """Return all automated runs""" path = functions.get_path_from_query_string(request) if request.method == 'GET': with functions.DBContextManager(path) as session: automated_runs = session.query(models.AutomatedRun).all() return jsonify(list(map(lamb...
python
def get_automated_runs(): """Return all automated runs""" path = functions.get_path_from_query_string(request) if request.method == 'GET': with functions.DBContextManager(path) as session: automated_runs = session.query(models.AutomatedRun).all() return jsonify(list(map(lamb...
[ "def", "get_automated_runs", "(", ")", ":", "path", "=", "functions", ".", "get_path_from_query_string", "(", "request", ")", "if", "request", ".", "method", "==", "'GET'", ":", "with", "functions", ".", "DBContextManager", "(", "path", ")", "as", "session", ...
Return all automated runs
[ "Return", "all", "automated", "runs" ]
a48dff7d370c84eb5c243bde87164c1f5fd096d5
https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/views.py#L428-L476
6,671
reiinakano/xcessiv
xcessiv/stacker.py
XcessivStackedEnsemble._process_using_meta_feature_generator
def _process_using_meta_feature_generator(self, X, meta_feature_generator): """Process using secondary learner meta-feature generator Since secondary learner meta-feature generator can be anything e.g. predict, predict_proba, this internal method gives the ability to use any string. Just make s...
python
def _process_using_meta_feature_generator(self, X, meta_feature_generator): """Process using secondary learner meta-feature generator Since secondary learner meta-feature generator can be anything e.g. predict, predict_proba, this internal method gives the ability to use any string. Just make s...
[ "def", "_process_using_meta_feature_generator", "(", "self", ",", "X", ",", "meta_feature_generator", ")", ":", "all_learner_meta_features", "=", "[", "]", "for", "idx", ",", "base_learner", "in", "enumerate", "(", "self", ".", "base_learners", ")", ":", "single_l...
Process using secondary learner meta-feature generator Since secondary learner meta-feature generator can be anything e.g. predict, predict_proba, this internal method gives the ability to use any string. Just make sure secondary learner has the method. Args: X (array-like)...
[ "Process", "using", "secondary", "learner", "meta", "-", "feature", "generator" ]
a48dff7d370c84eb5c243bde87164c1f5fd096d5
https://github.com/reiinakano/xcessiv/blob/a48dff7d370c84eb5c243bde87164c1f5fd096d5/xcessiv/stacker.py#L77-L103
6,672
madedotcom/photon-pump
photonpump/messages.py
NewEvent
def NewEvent( type: str, id: UUID = None, data: JsonDict = None, metadata: JsonDict = None ) -> NewEventData: """Build the data structure for a new event. Args: type: An event type. id: The uuid identifier for the event. data: A dict containing data for the event. These data ...
python
def NewEvent( type: str, id: UUID = None, data: JsonDict = None, metadata: JsonDict = None ) -> NewEventData: """Build the data structure for a new event. Args: type: An event type. id: The uuid identifier for the event. data: A dict containing data for the event. These data ...
[ "def", "NewEvent", "(", "type", ":", "str", ",", "id", ":", "UUID", "=", "None", ",", "data", ":", "JsonDict", "=", "None", ",", "metadata", ":", "JsonDict", "=", "None", ")", "->", "NewEventData", ":", "return", "NewEventData", "(", "id", "or", "uui...
Build the data structure for a new event. Args: type: An event type. id: The uuid identifier for the event. data: A dict containing data for the event. These data must be json serializable. metadata: A dict containing metadata about the event. These must be j...
[ "Build", "the", "data", "structure", "for", "a", "new", "event", "." ]
ff0736c9cacd43c1f783c9668eefb53d03a3a93e
https://github.com/madedotcom/photon-pump/blob/ff0736c9cacd43c1f783c9668eefb53d03a3a93e/photonpump/messages.py#L439-L453
6,673
madedotcom/photon-pump
photonpump/messages.py
Credential.from_bytes
def from_bytes(cls, data): """ I am so sorry. """ len_username = int.from_bytes(data[0:2], byteorder="big") offset_username = 2 + len_username username = data[2:offset_username].decode("UTF-8") offset_password = 2 + offset_username len_password = int.from_...
python
def from_bytes(cls, data): """ I am so sorry. """ len_username = int.from_bytes(data[0:2], byteorder="big") offset_username = 2 + len_username username = data[2:offset_username].decode("UTF-8") offset_password = 2 + offset_username len_password = int.from_...
[ "def", "from_bytes", "(", "cls", ",", "data", ")", ":", "len_username", "=", "int", ".", "from_bytes", "(", "data", "[", "0", ":", "2", "]", ",", "byteorder", "=", "\"big\"", ")", "offset_username", "=", "2", "+", "len_username", "username", "=", "data...
I am so sorry.
[ "I", "am", "so", "sorry", "." ]
ff0736c9cacd43c1f783c9668eefb53d03a3a93e
https://github.com/madedotcom/photon-pump/blob/ff0736c9cacd43c1f783c9668eefb53d03a3a93e/photonpump/messages.py#L155-L170
6,674
madedotcom/photon-pump
photonpump/connection.py
connect
def connect( host="localhost", port=1113, discovery_host=None, discovery_port=2113, username=None, password=None, loop=None, name=None, selector=select_random, ) -> Client: """ Create a new client. Examples: Since the Client is an async context manager, we ca...
python
def connect( host="localhost", port=1113, discovery_host=None, discovery_port=2113, username=None, password=None, loop=None, name=None, selector=select_random, ) -> Client: """ Create a new client. Examples: Since the Client is an async context manager, we ca...
[ "def", "connect", "(", "host", "=", "\"localhost\"", ",", "port", "=", "1113", ",", "discovery_host", "=", "None", ",", "discovery_port", "=", "2113", ",", "username", "=", "None", ",", "password", "=", "None", ",", "loop", "=", "None", ",", "name", "=...
Create a new client. Examples: Since the Client is an async context manager, we can use it in a with block for automatic connect/disconnect semantics. >>> async with connect(host='127.0.0.1', port=1113) as c: >>> await c.ping() Or we can call co...
[ "Create", "a", "new", "client", "." ]
ff0736c9cacd43c1f783c9668eefb53d03a3a93e
https://github.com/madedotcom/photon-pump/blob/ff0736c9cacd43c1f783c9668eefb53d03a3a93e/photonpump/connection.py#L1190-L1290
6,675
madedotcom/photon-pump
photonpump/connection.py
MessageReader.start
async def start(self): """Loop forever reading messages and invoking the operation that caused them""" while True: try: data = await self.reader.read(8192) if self._trace_enabled: self._logger.trace( "Re...
python
async def start(self): """Loop forever reading messages and invoking the operation that caused them""" while True: try: data = await self.reader.read(8192) if self._trace_enabled: self._logger.trace( "Re...
[ "async", "def", "start", "(", "self", ")", ":", "while", "True", ":", "try", ":", "data", "=", "await", "self", ".", "reader", ".", "read", "(", "8192", ")", "if", "self", ".", "_trace_enabled", ":", "self", ".", "_logger", ".", "trace", "(", "\"Re...
Loop forever reading messages and invoking the operation that caused them
[ "Loop", "forever", "reading", "messages", "and", "invoking", "the", "operation", "that", "caused", "them" ]
ff0736c9cacd43c1f783c9668eefb53d03a3a93e
https://github.com/madedotcom/photon-pump/blob/ff0736c9cacd43c1f783c9668eefb53d03a3a93e/photonpump/connection.py#L397-L416
6,676
madedotcom/photon-pump
photonpump/connection.py
Client.ping
async def ping(self, conversation_id: uuid.UUID = None) -> float: """ Send a message to the remote server to check liveness. Returns: The round-trip time to receive a Pong message in fractional seconds Examples: >>> async with connect() as conn: >>>...
python
async def ping(self, conversation_id: uuid.UUID = None) -> float: """ Send a message to the remote server to check liveness. Returns: The round-trip time to receive a Pong message in fractional seconds Examples: >>> async with connect() as conn: >>>...
[ "async", "def", "ping", "(", "self", ",", "conversation_id", ":", "uuid", ".", "UUID", "=", "None", ")", "->", "float", ":", "cmd", "=", "convo", ".", "Ping", "(", "conversation_id", "=", "conversation_id", "or", "uuid", ".", "uuid4", "(", ")", ")", ...
Send a message to the remote server to check liveness. Returns: The round-trip time to receive a Pong message in fractional seconds Examples: >>> async with connect() as conn: >>> print("Sending a PING to the server") >>> time_secs = await conn....
[ "Send", "a", "message", "to", "the", "remote", "server", "to", "check", "liveness", "." ]
ff0736c9cacd43c1f783c9668eefb53d03a3a93e
https://github.com/madedotcom/photon-pump/blob/ff0736c9cacd43c1f783c9668eefb53d03a3a93e/photonpump/connection.py#L581-L599
6,677
madedotcom/photon-pump
photonpump/connection.py
Client.publish_event
async def publish_event( self, stream: str, type: str, body: Optional[Any] = None, id: Optional[uuid.UUID] = None, metadata: Optional[Any] = None, expected_version: int = -2, require_master: bool = False, ) -> None: """ Publish a single...
python
async def publish_event( self, stream: str, type: str, body: Optional[Any] = None, id: Optional[uuid.UUID] = None, metadata: Optional[Any] = None, expected_version: int = -2, require_master: bool = False, ) -> None: """ Publish a single...
[ "async", "def", "publish_event", "(", "self", ",", "stream", ":", "str", ",", "type", ":", "str", ",", "body", ":", "Optional", "[", "Any", "]", "=", "None", ",", "id", ":", "Optional", "[", "uuid", ".", "UUID", "]", "=", "None", ",", "metadata", ...
Publish a single event to the EventStore. This method publishes a single event to the remote server and waits for acknowledgement. Args: stream: The stream to publish the event to. type: the event's type. body: a serializable body for the event. ...
[ "Publish", "a", "single", "event", "to", "the", "EventStore", "." ]
ff0736c9cacd43c1f783c9668eefb53d03a3a93e
https://github.com/madedotcom/photon-pump/blob/ff0736c9cacd43c1f783c9668eefb53d03a3a93e/photonpump/connection.py#L601-L663
6,678
madedotcom/photon-pump
photonpump/connection.py
Client.get_event
async def get_event( self, stream: str, event_number: int, resolve_links=True, require_master=False, correlation_id: uuid.UUID = None, ) -> msg.Event: """ Get a single event by stream and event number. Args: stream: The name of the...
python
async def get_event( self, stream: str, event_number: int, resolve_links=True, require_master=False, correlation_id: uuid.UUID = None, ) -> msg.Event: """ Get a single event by stream and event number. Args: stream: The name of the...
[ "async", "def", "get_event", "(", "self", ",", "stream", ":", "str", ",", "event_number", ":", "int", ",", "resolve_links", "=", "True", ",", "require_master", "=", "False", ",", "correlation_id", ":", "uuid", ".", "UUID", "=", "None", ",", ")", "->", ...
Get a single event by stream and event number. Args: stream: The name of the stream containing the event. event_number: The sequence number of the event to read. resolve_links (optional): True if eventstore should automatically resolve Link Events, otherwise ...
[ "Get", "a", "single", "event", "by", "stream", "and", "event", "number", "." ]
ff0736c9cacd43c1f783c9668eefb53d03a3a93e
https://github.com/madedotcom/photon-pump/blob/ff0736c9cacd43c1f783c9668eefb53d03a3a93e/photonpump/connection.py#L682-L724
6,679
madedotcom/photon-pump
photonpump/connection.py
Client.get
async def get( self, stream: str, direction: msg.StreamDirection = msg.StreamDirection.Forward, from_event: int = 0, max_count: int = 100, resolve_links: bool = True, require_master: bool = False, correlation_id: uuid.UUID = None, ): """ ...
python
async def get( self, stream: str, direction: msg.StreamDirection = msg.StreamDirection.Forward, from_event: int = 0, max_count: int = 100, resolve_links: bool = True, require_master: bool = False, correlation_id: uuid.UUID = None, ): """ ...
[ "async", "def", "get", "(", "self", ",", "stream", ":", "str", ",", "direction", ":", "msg", ".", "StreamDirection", "=", "msg", ".", "StreamDirection", ".", "Forward", ",", "from_event", ":", "int", "=", "0", ",", "max_count", ":", "int", "=", "100", ...
Read a range of events from a stream. Args: stream: The name of the stream to read direction (optional): Controls whether to read events forward or backward. defaults to Forward. from_event (optional): The first event to read. defaults to the begi...
[ "Read", "a", "range", "of", "events", "from", "a", "stream", "." ]
ff0736c9cacd43c1f783c9668eefb53d03a3a93e
https://github.com/madedotcom/photon-pump/blob/ff0736c9cacd43c1f783c9668eefb53d03a3a93e/photonpump/connection.py#L726-L786
6,680
madedotcom/photon-pump
photonpump/connection.py
Client.get_all
async def get_all( self, direction: msg.StreamDirection = msg.StreamDirection.Forward, from_position: Optional[Union[msg.Position, msg._PositionSentinel]] = None, max_count: int = 100, resolve_links: bool = True, require_master: bool = False, correlation_id: uuid....
python
async def get_all( self, direction: msg.StreamDirection = msg.StreamDirection.Forward, from_position: Optional[Union[msg.Position, msg._PositionSentinel]] = None, max_count: int = 100, resolve_links: bool = True, require_master: bool = False, correlation_id: uuid....
[ "async", "def", "get_all", "(", "self", ",", "direction", ":", "msg", ".", "StreamDirection", "=", "msg", ".", "StreamDirection", ".", "Forward", ",", "from_position", ":", "Optional", "[", "Union", "[", "msg", ".", "Position", ",", "msg", ".", "_PositionS...
Read a range of events from the whole database. Args: direction (optional): Controls whether to read events forward or backward. defaults to Forward. from_position (optional): The position to read from. defaults to the beginning of the stream when direction i...
[ "Read", "a", "range", "of", "events", "from", "the", "whole", "database", "." ]
ff0736c9cacd43c1f783c9668eefb53d03a3a93e
https://github.com/madedotcom/photon-pump/blob/ff0736c9cacd43c1f783c9668eefb53d03a3a93e/photonpump/connection.py#L788-L840
6,681
madedotcom/photon-pump
photonpump/connection.py
Client.iter
async def iter( self, stream: str, direction: msg.StreamDirection = msg.StreamDirection.Forward, from_event: int = None, batch_size: int = 100, resolve_links: bool = True, require_master: bool = False, correlation_id: uuid.UUID = None, ): """ ...
python
async def iter( self, stream: str, direction: msg.StreamDirection = msg.StreamDirection.Forward, from_event: int = None, batch_size: int = 100, resolve_links: bool = True, require_master: bool = False, correlation_id: uuid.UUID = None, ): """ ...
[ "async", "def", "iter", "(", "self", ",", "stream", ":", "str", ",", "direction", ":", "msg", ".", "StreamDirection", "=", "msg", ".", "StreamDirection", ".", "Forward", ",", "from_event", ":", "int", "=", "None", ",", "batch_size", ":", "int", "=", "1...
Read through a stream of events until the end and then stop. Args: stream: The name of the stream to read. direction: Controls whether to read forward or backward through the stream. Defaults to StreamDirection.Forward from_event: The sequence number of the fi...
[ "Read", "through", "a", "stream", "of", "events", "until", "the", "end", "and", "then", "stop", "." ]
ff0736c9cacd43c1f783c9668eefb53d03a3a93e
https://github.com/madedotcom/photon-pump/blob/ff0736c9cacd43c1f783c9668eefb53d03a3a93e/photonpump/connection.py#L842-L902
6,682
madedotcom/photon-pump
photonpump/connection.py
Client.iter_all
async def iter_all( self, direction: msg.StreamDirection = msg.StreamDirection.Forward, from_position: Optional[Union[msg.Position, msg._PositionSentinel]] = None, batch_size: int = 100, resolve_links: bool = True, require_master: bool = False, correlation_id: Opt...
python
async def iter_all( self, direction: msg.StreamDirection = msg.StreamDirection.Forward, from_position: Optional[Union[msg.Position, msg._PositionSentinel]] = None, batch_size: int = 100, resolve_links: bool = True, require_master: bool = False, correlation_id: Opt...
[ "async", "def", "iter_all", "(", "self", ",", "direction", ":", "msg", ".", "StreamDirection", "=", "msg", ".", "StreamDirection", ".", "Forward", ",", "from_position", ":", "Optional", "[", "Union", "[", "msg", ".", "Position", ",", "msg", ".", "_Position...
Read through all the events in the database. Args: direction (optional): Controls whether to read forward or backward through the events. Defaults to StreamDirection.Forward from_position (optional): The position to start reading from. Defaults to photonpump...
[ "Read", "through", "all", "the", "events", "in", "the", "database", "." ]
ff0736c9cacd43c1f783c9668eefb53d03a3a93e
https://github.com/madedotcom/photon-pump/blob/ff0736c9cacd43c1f783c9668eefb53d03a3a93e/photonpump/connection.py#L904-L965
6,683
madedotcom/photon-pump
photonpump/connection.py
Client.subscribe_to
async def subscribe_to( self, stream, start_from=-1, resolve_link_tos=True, batch_size: int = 100 ): """ Subscribe to receive notifications when a new event is published to a stream. Args: stream: The name of the stream. start_from (optional): The fir...
python
async def subscribe_to( self, stream, start_from=-1, resolve_link_tos=True, batch_size: int = 100 ): """ Subscribe to receive notifications when a new event is published to a stream. Args: stream: The name of the stream. start_from (optional): The fir...
[ "async", "def", "subscribe_to", "(", "self", ",", "stream", ",", "start_from", "=", "-", "1", ",", "resolve_link_tos", "=", "True", ",", "batch_size", ":", "int", "=", "100", ")", ":", "if", "start_from", "==", "-", "1", ":", "cmd", ":", "convo", "."...
Subscribe to receive notifications when a new event is published to a stream. Args: stream: The name of the stream. start_from (optional): The first event to read. This parameter defaults to the magic value -1 which is treated as meaning "from the...
[ "Subscribe", "to", "receive", "notifications", "when", "a", "new", "event", "is", "published", "to", "a", "stream", "." ]
ff0736c9cacd43c1f783c9668eefb53d03a3a93e
https://github.com/madedotcom/photon-pump/blob/ff0736c9cacd43c1f783c9668eefb53d03a3a93e/photonpump/connection.py#L1029-L1086
6,684
madedotcom/photon-pump
photonpump/discovery.py
prefer_master
def prefer_master(nodes: List[DiscoveredNode]) -> Optional[DiscoveredNode]: """ Select the master if available, otherwise fall back to a replica. """ return max(nodes, key=attrgetter("state"))
python
def prefer_master(nodes: List[DiscoveredNode]) -> Optional[DiscoveredNode]: """ Select the master if available, otherwise fall back to a replica. """ return max(nodes, key=attrgetter("state"))
[ "def", "prefer_master", "(", "nodes", ":", "List", "[", "DiscoveredNode", "]", ")", "->", "Optional", "[", "DiscoveredNode", "]", ":", "return", "max", "(", "nodes", ",", "key", "=", "attrgetter", "(", "\"state\"", ")", ")" ]
Select the master if available, otherwise fall back to a replica.
[ "Select", "the", "master", "if", "available", "otherwise", "fall", "back", "to", "a", "replica", "." ]
ff0736c9cacd43c1f783c9668eefb53d03a3a93e
https://github.com/madedotcom/photon-pump/blob/ff0736c9cacd43c1f783c9668eefb53d03a3a93e/photonpump/discovery.py#L60-L64
6,685
madedotcom/photon-pump
photonpump/discovery.py
prefer_replica
def prefer_replica(nodes: List[DiscoveredNode]) -> Optional[DiscoveredNode]: """ Select a random replica if any are available or fall back to the master. """ masters = [node for node in nodes if node.state == NodeState.Master] replicas = [node for node in nodes if node.state != NodeState.Master] ...
python
def prefer_replica(nodes: List[DiscoveredNode]) -> Optional[DiscoveredNode]: """ Select a random replica if any are available or fall back to the master. """ masters = [node for node in nodes if node.state == NodeState.Master] replicas = [node for node in nodes if node.state != NodeState.Master] ...
[ "def", "prefer_replica", "(", "nodes", ":", "List", "[", "DiscoveredNode", "]", ")", "->", "Optional", "[", "DiscoveredNode", "]", ":", "masters", "=", "[", "node", "for", "node", "in", "nodes", "if", "node", ".", "state", "==", "NodeState", ".", "Master...
Select a random replica if any are available or fall back to the master.
[ "Select", "a", "random", "replica", "if", "any", "are", "available", "or", "fall", "back", "to", "the", "master", "." ]
ff0736c9cacd43c1f783c9668eefb53d03a3a93e
https://github.com/madedotcom/photon-pump/blob/ff0736c9cacd43c1f783c9668eefb53d03a3a93e/photonpump/discovery.py#L67-L79
6,686
nteract/vdom
vdom/core.py
create_event_handler
def create_event_handler(event_type, handler): """Register a comm and return a serializable object with target name""" target_name = '{hash}_{event_type}'.format(hash=hash(handler), event_type=event_type) def handle_comm_opened(comm, msg): @comm.on_msg def _handle_msg(msg): dat...
python
def create_event_handler(event_type, handler): """Register a comm and return a serializable object with target name""" target_name = '{hash}_{event_type}'.format(hash=hash(handler), event_type=event_type) def handle_comm_opened(comm, msg): @comm.on_msg def _handle_msg(msg): dat...
[ "def", "create_event_handler", "(", "event_type", ",", "handler", ")", ":", "target_name", "=", "'{hash}_{event_type}'", ".", "format", "(", "hash", "=", "hash", "(", "handler", ")", ",", "event_type", "=", "event_type", ")", "def", "handle_comm_opened", "(", ...
Register a comm and return a serializable object with target name
[ "Register", "a", "comm", "and", "return", "a", "serializable", "object", "with", "target", "name" ]
d1ef48dc20d50379b8137a104125c92f64b916e4
https://github.com/nteract/vdom/blob/d1ef48dc20d50379b8137a104125c92f64b916e4/vdom/core.py#L49-L70
6,687
nteract/vdom
vdom/core.py
to_json
def to_json(el, schema=None): """Convert an element to VDOM JSON If you wish to validate the JSON, pass in a schema via the schema keyword argument. If a schema is provided, this raises a ValidationError if JSON does not match the schema. """ if type(el) is str: json_el = el elif ty...
python
def to_json(el, schema=None): """Convert an element to VDOM JSON If you wish to validate the JSON, pass in a schema via the schema keyword argument. If a schema is provided, this raises a ValidationError if JSON does not match the schema. """ if type(el) is str: json_el = el elif ty...
[ "def", "to_json", "(", "el", ",", "schema", "=", "None", ")", ":", "if", "type", "(", "el", ")", "is", "str", ":", "json_el", "=", "el", "elif", "type", "(", "el", ")", "is", "list", ":", "json_el", "=", "list", "(", "map", "(", "to_json", ",",...
Convert an element to VDOM JSON If you wish to validate the JSON, pass in a schema via the schema keyword argument. If a schema is provided, this raises a ValidationError if JSON does not match the schema.
[ "Convert", "an", "element", "to", "VDOM", "JSON" ]
d1ef48dc20d50379b8137a104125c92f64b916e4
https://github.com/nteract/vdom/blob/d1ef48dc20d50379b8137a104125c92f64b916e4/vdom/core.py#L73-L102
6,688
nteract/vdom
vdom/core.py
create_component
def create_component(tag_name, allow_children=True): """ Create a component for an HTML Tag Examples: >>> marquee = create_component('marquee') >>> marquee('woohoo') <marquee>woohoo</marquee> """ def _component(*children, **kwargs): if 'children' in kwargs: ...
python
def create_component(tag_name, allow_children=True): """ Create a component for an HTML Tag Examples: >>> marquee = create_component('marquee') >>> marquee('woohoo') <marquee>woohoo</marquee> """ def _component(*children, **kwargs): if 'children' in kwargs: ...
[ "def", "create_component", "(", "tag_name", ",", "allow_children", "=", "True", ")", ":", "def", "_component", "(", "*", "children", ",", "*", "*", "kwargs", ")", ":", "if", "'children'", "in", "kwargs", ":", "children", "=", "kwargs", ".", "pop", "(", ...
Create a component for an HTML Tag Examples: >>> marquee = create_component('marquee') >>> marquee('woohoo') <marquee>woohoo</marquee>
[ "Create", "a", "component", "for", "an", "HTML", "Tag" ]
d1ef48dc20d50379b8137a104125c92f64b916e4
https://github.com/nteract/vdom/blob/d1ef48dc20d50379b8137a104125c92f64b916e4/vdom/core.py#L301-L343
6,689
nteract/vdom
vdom/core.py
VDOM.validate
def validate(self, schema): """ Validate VDOM against given JSON Schema Raises ValidationError if schema does not match """ try: validate(instance=self.to_dict(), schema=schema, cls=Draft4Validator) except ValidationError as e: raise ValidationErr...
python
def validate(self, schema): """ Validate VDOM against given JSON Schema Raises ValidationError if schema does not match """ try: validate(instance=self.to_dict(), schema=schema, cls=Draft4Validator) except ValidationError as e: raise ValidationErr...
[ "def", "validate", "(", "self", ",", "schema", ")", ":", "try", ":", "validate", "(", "instance", "=", "self", ".", "to_dict", "(", ")", ",", "schema", "=", "schema", ",", "cls", "=", "Draft4Validator", ")", "except", "ValidationError", "as", "e", ":",...
Validate VDOM against given JSON Schema Raises ValidationError if schema does not match
[ "Validate", "VDOM", "against", "given", "JSON", "Schema" ]
d1ef48dc20d50379b8137a104125c92f64b916e4
https://github.com/nteract/vdom/blob/d1ef48dc20d50379b8137a104125c92f64b916e4/vdom/core.py#L174-L183
6,690
nteract/vdom
vdom/core.py
VDOM.to_dict
def to_dict(self): """Converts VDOM object to a dictionary that passes our schema """ attributes = dict(self.attributes.items()) if self.style: attributes.update({"style": dict(self.style.items())}) vdom_dict = {'tagName': self.tag_name, 'attributes': attributes} ...
python
def to_dict(self): """Converts VDOM object to a dictionary that passes our schema """ attributes = dict(self.attributes.items()) if self.style: attributes.update({"style": dict(self.style.items())}) vdom_dict = {'tagName': self.tag_name, 'attributes': attributes} ...
[ "def", "to_dict", "(", "self", ")", ":", "attributes", "=", "dict", "(", "self", ".", "attributes", ".", "items", "(", ")", ")", "if", "self", ".", "style", ":", "attributes", ".", "update", "(", "{", "\"style\"", ":", "dict", "(", "self", ".", "st...
Converts VDOM object to a dictionary that passes our schema
[ "Converts", "VDOM", "object", "to", "a", "dictionary", "that", "passes", "our", "schema" ]
d1ef48dc20d50379b8137a104125c92f64b916e4
https://github.com/nteract/vdom/blob/d1ef48dc20d50379b8137a104125c92f64b916e4/vdom/core.py#L185-L201
6,691
konstantint/PassportEye
passporteye/mrz/text.py
MRZ._guess_type
def _guess_type(mrz_lines): """Guesses the type of the MRZ from given lines. Returns 'TD1', 'TD2', 'TD3', 'MRVA', 'MRVB' or None. The algorithm is basically just counting lines, looking at their length and checking whether the first character is a 'V' >>> MRZ._guess_type([]) is None Tru...
python
def _guess_type(mrz_lines): """Guesses the type of the MRZ from given lines. Returns 'TD1', 'TD2', 'TD3', 'MRVA', 'MRVB' or None. The algorithm is basically just counting lines, looking at their length and checking whether the first character is a 'V' >>> MRZ._guess_type([]) is None Tru...
[ "def", "_guess_type", "(", "mrz_lines", ")", ":", "try", ":", "if", "len", "(", "mrz_lines", ")", "==", "3", ":", "return", "'TD1'", "elif", "len", "(", "mrz_lines", ")", "==", "2", "and", "len", "(", "mrz_lines", "[", "0", "]", ")", "<", "40", "...
Guesses the type of the MRZ from given lines. Returns 'TD1', 'TD2', 'TD3', 'MRVA', 'MRVB' or None. The algorithm is basically just counting lines, looking at their length and checking whether the first character is a 'V' >>> MRZ._guess_type([]) is None True >>> MRZ._guess_type([1]) is N...
[ "Guesses", "the", "type", "of", "the", "MRZ", "from", "given", "lines", ".", "Returns", "TD1", "TD2", "TD3", "MRVA", "MRVB", "or", "None", ".", "The", "algorithm", "is", "basically", "just", "counting", "lines", "looking", "at", "their", "length", "and", ...
b32afba0f5dc4eb600c4edc4f49e5d49959c5415
https://github.com/konstantint/PassportEye/blob/b32afba0f5dc4eb600c4edc4f49e5d49959c5415/passporteye/mrz/text.py#L129-L160
6,692
konstantint/PassportEye
passporteye/util/pipeline.py
Pipeline.remove_component
def remove_component(self, name): """Removes an existing component with a given name, invalidating all the values computed by the previous component.""" if name not in self.components: raise Exception("No component named %s" % name) del self.components[name] del self....
python
def remove_component(self, name): """Removes an existing component with a given name, invalidating all the values computed by the previous component.""" if name not in self.components: raise Exception("No component named %s" % name) del self.components[name] del self....
[ "def", "remove_component", "(", "self", ",", "name", ")", ":", "if", "name", "not", "in", "self", ".", "components", ":", "raise", "Exception", "(", "\"No component named %s\"", "%", "name", ")", "del", "self", ".", "components", "[", "name", "]", "del", ...
Removes an existing component with a given name, invalidating all the values computed by the previous component.
[ "Removes", "an", "existing", "component", "with", "a", "given", "name", "invalidating", "all", "the", "values", "computed", "by", "the", "previous", "component", "." ]
b32afba0f5dc4eb600c4edc4f49e5d49959c5415
https://github.com/konstantint/PassportEye/blob/b32afba0f5dc4eb600c4edc4f49e5d49959c5415/passporteye/util/pipeline.py#L68-L78
6,693
konstantint/PassportEye
passporteye/util/pipeline.py
Pipeline.replace_component
def replace_component(self, name, callable, provides=None, depends=None): """Changes an existing component with a given name, invalidating all the values computed by the previous component and its successors.""" self.remove_component(name) self.add_component(name, callable, provides, dep...
python
def replace_component(self, name, callable, provides=None, depends=None): """Changes an existing component with a given name, invalidating all the values computed by the previous component and its successors.""" self.remove_component(name) self.add_component(name, callable, provides, dep...
[ "def", "replace_component", "(", "self", ",", "name", ",", "callable", ",", "provides", "=", "None", ",", "depends", "=", "None", ")", ":", "self", ".", "remove_component", "(", "name", ")", "self", ".", "add_component", "(", "name", ",", "callable", ","...
Changes an existing component with a given name, invalidating all the values computed by the previous component and its successors.
[ "Changes", "an", "existing", "component", "with", "a", "given", "name", "invalidating", "all", "the", "values", "computed", "by", "the", "previous", "component", "and", "its", "successors", "." ]
b32afba0f5dc4eb600c4edc4f49e5d49959c5415
https://github.com/konstantint/PassportEye/blob/b32afba0f5dc4eb600c4edc4f49e5d49959c5415/passporteye/util/pipeline.py#L80-L84
6,694
konstantint/PassportEye
passporteye/util/pipeline.py
Pipeline.invalidate
def invalidate(self, key): """Remove the given data item along with all items that depend on it in the graph.""" if key not in self.data: return del self.data[key] # Find all components that used it and invalidate their results for cname in self.components: ...
python
def invalidate(self, key): """Remove the given data item along with all items that depend on it in the graph.""" if key not in self.data: return del self.data[key] # Find all components that used it and invalidate their results for cname in self.components: ...
[ "def", "invalidate", "(", "self", ",", "key", ")", ":", "if", "key", "not", "in", "self", ".", "data", ":", "return", "del", "self", ".", "data", "[", "key", "]", "# Find all components that used it and invalidate their results", "for", "cname", "in", "self", ...
Remove the given data item along with all items that depend on it in the graph.
[ "Remove", "the", "given", "data", "item", "along", "with", "all", "items", "that", "depend", "on", "it", "in", "the", "graph", "." ]
b32afba0f5dc4eb600c4edc4f49e5d49959c5415
https://github.com/konstantint/PassportEye/blob/b32afba0f5dc4eb600c4edc4f49e5d49959c5415/passporteye/util/pipeline.py#L86-L96
6,695
konstantint/PassportEye
passporteye/util/ocr.py
ocr
def ocr(img, mrz_mode=True, extra_cmdline_params=''): """Runs Tesseract on a given image. Writes an intermediate tempfile and then runs the tesseract command on the image. This is a simplified modification of image_to_string from PyTesseract, which is adapted to SKImage rather than PIL. In principle we co...
python
def ocr(img, mrz_mode=True, extra_cmdline_params=''): """Runs Tesseract on a given image. Writes an intermediate tempfile and then runs the tesseract command on the image. This is a simplified modification of image_to_string from PyTesseract, which is adapted to SKImage rather than PIL. In principle we co...
[ "def", "ocr", "(", "img", ",", "mrz_mode", "=", "True", ",", "extra_cmdline_params", "=", "''", ")", ":", "input_file_name", "=", "'%s.bmp'", "%", "_tempnam", "(", ")", "output_file_name_base", "=", "'%s'", "%", "_tempnam", "(", ")", "output_file_name", "=",...
Runs Tesseract on a given image. Writes an intermediate tempfile and then runs the tesseract command on the image. This is a simplified modification of image_to_string from PyTesseract, which is adapted to SKImage rather than PIL. In principle we could have reimplemented it just as well - there are some appar...
[ "Runs", "Tesseract", "on", "a", "given", "image", ".", "Writes", "an", "intermediate", "tempfile", "and", "then", "runs", "the", "tesseract", "command", "on", "the", "image", "." ]
b32afba0f5dc4eb600c4edc4f49e5d49959c5415
https://github.com/konstantint/PassportEye/blob/b32afba0f5dc4eb600c4edc4f49e5d49959c5415/passporteye/util/ocr.py#L16-L64
6,696
konstantint/PassportEye
passporteye/util/geometry.py
RotatedBox.approx_equal
def approx_equal(self, center, width, height, angle, tol=1e-6): "Method mainly useful for testing" return abs(self.cx - center[0]) < tol and abs(self.cy - center[1]) < tol and abs(self.width - width) < tol and \ abs(self.height - height) < tol and abs(self.angle - angle) < tol
python
def approx_equal(self, center, width, height, angle, tol=1e-6): "Method mainly useful for testing" return abs(self.cx - center[0]) < tol and abs(self.cy - center[1]) < tol and abs(self.width - width) < tol and \ abs(self.height - height) < tol and abs(self.angle - angle) < tol
[ "def", "approx_equal", "(", "self", ",", "center", ",", "width", ",", "height", ",", "angle", ",", "tol", "=", "1e-6", ")", ":", "return", "abs", "(", "self", ".", "cx", "-", "center", "[", "0", "]", ")", "<", "tol", "and", "abs", "(", "self", ...
Method mainly useful for testing
[ "Method", "mainly", "useful", "for", "testing" ]
b32afba0f5dc4eb600c4edc4f49e5d49959c5415
https://github.com/konstantint/PassportEye/blob/b32afba0f5dc4eb600c4edc4f49e5d49959c5415/passporteye/util/geometry.py#L49-L52
6,697
konstantint/PassportEye
passporteye/util/geometry.py
RotatedBox.rotated
def rotated(self, rotation_center, angle): """Returns a RotatedBox that is obtained by rotating this box around a given center by a given angle. >>> assert RotatedBox([2, 2], 2, 1, 0.1).rotated([1, 1], np.pi/2).approx_equal([0, 2], 2, 1, np.pi/2+0.1) """ rot = np.array([[np.cos(angle), ...
python
def rotated(self, rotation_center, angle): """Returns a RotatedBox that is obtained by rotating this box around a given center by a given angle. >>> assert RotatedBox([2, 2], 2, 1, 0.1).rotated([1, 1], np.pi/2).approx_equal([0, 2], 2, 1, np.pi/2+0.1) """ rot = np.array([[np.cos(angle), ...
[ "def", "rotated", "(", "self", ",", "rotation_center", ",", "angle", ")", ":", "rot", "=", "np", ".", "array", "(", "[", "[", "np", ".", "cos", "(", "angle", ")", ",", "np", ".", "sin", "(", "angle", ")", "]", ",", "[", "-", "np", ".", "sin",...
Returns a RotatedBox that is obtained by rotating this box around a given center by a given angle. >>> assert RotatedBox([2, 2], 2, 1, 0.1).rotated([1, 1], np.pi/2).approx_equal([0, 2], 2, 1, np.pi/2+0.1)
[ "Returns", "a", "RotatedBox", "that", "is", "obtained", "by", "rotating", "this", "box", "around", "a", "given", "center", "by", "a", "given", "angle", "." ]
b32afba0f5dc4eb600c4edc4f49e5d49959c5415
https://github.com/konstantint/PassportEye/blob/b32afba0f5dc4eb600c4edc4f49e5d49959c5415/passporteye/util/geometry.py#L54-L62
6,698
konstantint/PassportEye
passporteye/util/geometry.py
RotatedBox.as_poly
def as_poly(self, margin_width=0, margin_height=0): """Converts this box to a polygon, i.e. 4x2 array, representing the four corners starting from lower left to upper left counterclockwise. :param margin_width: The additional "margin" that will be added to the box along its width dimension (from both s...
python
def as_poly(self, margin_width=0, margin_height=0): """Converts this box to a polygon, i.e. 4x2 array, representing the four corners starting from lower left to upper left counterclockwise. :param margin_width: The additional "margin" that will be added to the box along its width dimension (from both s...
[ "def", "as_poly", "(", "self", ",", "margin_width", "=", "0", ",", "margin_height", "=", "0", ")", ":", "v_hor", "=", "(", "self", ".", "width", "/", "2", "+", "margin_width", ")", "*", "np", ".", "array", "(", "[", "np", ".", "cos", "(", "self",...
Converts this box to a polygon, i.e. 4x2 array, representing the four corners starting from lower left to upper left counterclockwise. :param margin_width: The additional "margin" that will be added to the box along its width dimension (from both sides) before conversion. :param margin_height: The addi...
[ "Converts", "this", "box", "to", "a", "polygon", "i", ".", "e", ".", "4x2", "array", "representing", "the", "four", "corners", "starting", "from", "lower", "left", "to", "upper", "left", "counterclockwise", "." ]
b32afba0f5dc4eb600c4edc4f49e5d49959c5415
https://github.com/konstantint/PassportEye/blob/b32afba0f5dc4eb600c4edc4f49e5d49959c5415/passporteye/util/geometry.py#L64-L94
6,699
konstantint/PassportEye
passporteye/util/geometry.py
RotatedBox.extract_from_image
def extract_from_image(self, img, scale=1.0, margin_width=5, margin_height=5): """Extracts the contents of this box from a given image. For that the image is "unrotated" by the appropriate angle, and the corresponding part is extracted from it. Returns an image with dimensions height*scale x wi...
python
def extract_from_image(self, img, scale=1.0, margin_width=5, margin_height=5): """Extracts the contents of this box from a given image. For that the image is "unrotated" by the appropriate angle, and the corresponding part is extracted from it. Returns an image with dimensions height*scale x wi...
[ "def", "extract_from_image", "(", "self", ",", "img", ",", "scale", "=", "1.0", ",", "margin_width", "=", "5", ",", "margin_height", "=", "5", ")", ":", "rotate_by", "=", "(", "np", ".", "pi", "/", "2", "-", "self", ".", "angle", ")", "*", "180", ...
Extracts the contents of this box from a given image. For that the image is "unrotated" by the appropriate angle, and the corresponding part is extracted from it. Returns an image with dimensions height*scale x width*scale. Note that the box coordinates are interpreted as "image coordinates" (i...
[ "Extracts", "the", "contents", "of", "this", "box", "from", "a", "given", "image", ".", "For", "that", "the", "image", "is", "unrotated", "by", "the", "appropriate", "angle", "and", "the", "corresponding", "part", "is", "extracted", "from", "it", "." ]
b32afba0f5dc4eb600c4edc4f49e5d49959c5415
https://github.com/konstantint/PassportEye/blob/b32afba0f5dc4eb600c4edc4f49e5d49959c5415/passporteye/util/geometry.py#L119-L149