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
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
ajdavis/mongo-mockup-db
mockupdb/__init__.py
Request.client_port
def client_port(self): """Client connection's TCP port.""" address = self._client.getpeername() if isinstance(address, tuple): return address[1] # Maybe a Unix domain socket connection. return 0
python
def client_port(self): """Client connection's TCP port.""" address = self._client.getpeername() if isinstance(address, tuple): return address[1] # Maybe a Unix domain socket connection. return 0
[ "def", "client_port", "(", "self", ")", ":", "address", "=", "self", ".", "_client", ".", "getpeername", "(", ")", "if", "isinstance", "(", "address", ",", "tuple", ")", ":", "return", "address", "[", "1", "]", "# Maybe a Unix domain socket connection.", "re...
Client connection's TCP port.
[ "Client", "connection", "s", "TCP", "port", "." ]
ff8a3f793def59e9037397ef60607fbda6949dac
https://github.com/ajdavis/mongo-mockup-db/blob/ff8a3f793def59e9037397ef60607fbda6949dac/mockupdb/__init__.py#L408-L415
train
61,800
ajdavis/mongo-mockup-db
mockupdb/__init__.py
Request.command_err
def command_err(self, code=1, errmsg='MockupDB command failure', *args, **kwargs): """Error reply to a command. Returns True so it is suitable as an `~MockupDB.autoresponds` handler. """ kwargs.setdefault('ok', 0) kwargs['code'] = code kwargs['errmsg'...
python
def command_err(self, code=1, errmsg='MockupDB command failure', *args, **kwargs): """Error reply to a command. Returns True so it is suitable as an `~MockupDB.autoresponds` handler. """ kwargs.setdefault('ok', 0) kwargs['code'] = code kwargs['errmsg'...
[ "def", "command_err", "(", "self", ",", "code", "=", "1", ",", "errmsg", "=", "'MockupDB command failure'", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "'ok'", ",", "0", ")", "kwargs", "[", "'code'", "]", "=...
Error reply to a command. Returns True so it is suitable as an `~MockupDB.autoresponds` handler.
[ "Error", "reply", "to", "a", "command", "." ]
ff8a3f793def59e9037397ef60607fbda6949dac
https://github.com/ajdavis/mongo-mockup-db/blob/ff8a3f793def59e9037397ef60607fbda6949dac/mockupdb/__init__.py#L461-L471
train
61,801
ajdavis/mongo-mockup-db
mockupdb/__init__.py
OpMsg.unpack
def unpack(cls, msg, client, server, request_id): """Parse message and return an `OpMsg`. Takes the client message as bytes, the client and server socket objects, and the client request id. """ payload_document = OrderedDict() flags, = _UNPACK_UINT(msg[:4]) pos =...
python
def unpack(cls, msg, client, server, request_id): """Parse message and return an `OpMsg`. Takes the client message as bytes, the client and server socket objects, and the client request id. """ payload_document = OrderedDict() flags, = _UNPACK_UINT(msg[:4]) pos =...
[ "def", "unpack", "(", "cls", ",", "msg", ",", "client", ",", "server", ",", "request_id", ")", ":", "payload_document", "=", "OrderedDict", "(", ")", "flags", ",", "=", "_UNPACK_UINT", "(", "msg", "[", ":", "4", "]", ")", "pos", "=", "4", "if", "fl...
Parse message and return an `OpMsg`. Takes the client message as bytes, the client and server socket objects, and the client request id.
[ "Parse", "message", "and", "return", "an", "OpMsg", "." ]
ff8a3f793def59e9037397ef60607fbda6949dac
https://github.com/ajdavis/mongo-mockup-db/blob/ff8a3f793def59e9037397ef60607fbda6949dac/mockupdb/__init__.py#L625-L660
train
61,802
ajdavis/mongo-mockup-db
mockupdb/__init__.py
OpQuery.unpack
def unpack(cls, msg, client, server, request_id): """Parse message and return an `OpQuery` or `Command`. Takes the client message as bytes, the client and server socket objects, and the client request id. """ flags, = _UNPACK_INT(msg[:4]) namespace, pos = _get_c_string(m...
python
def unpack(cls, msg, client, server, request_id): """Parse message and return an `OpQuery` or `Command`. Takes the client message as bytes, the client and server socket objects, and the client request id. """ flags, = _UNPACK_INT(msg[:4]) namespace, pos = _get_c_string(m...
[ "def", "unpack", "(", "cls", ",", "msg", ",", "client", ",", "server", ",", "request_id", ")", ":", "flags", ",", "=", "_UNPACK_INT", "(", "msg", "[", ":", "4", "]", ")", "namespace", ",", "pos", "=", "_get_c_string", "(", "msg", ",", "4", ")", "...
Parse message and return an `OpQuery` or `Command`. Takes the client message as bytes, the client and server socket objects, and the client request id.
[ "Parse", "message", "and", "return", "an", "OpQuery", "or", "Command", "." ]
ff8a3f793def59e9037397ef60607fbda6949dac
https://github.com/ajdavis/mongo-mockup-db/blob/ff8a3f793def59e9037397ef60607fbda6949dac/mockupdb/__init__.py#L713-L742
train
61,803
ajdavis/mongo-mockup-db
mockupdb/__init__.py
OpGetMore.unpack
def unpack(cls, msg, client, server, request_id): """Parse message and return an `OpGetMore`. Takes the client message as bytes, the client and server socket objects, and the client request id. """ flags, = _UNPACK_INT(msg[:4]) namespace, pos = _get_c_string(msg, 4) ...
python
def unpack(cls, msg, client, server, request_id): """Parse message and return an `OpGetMore`. Takes the client message as bytes, the client and server socket objects, and the client request id. """ flags, = _UNPACK_INT(msg[:4]) namespace, pos = _get_c_string(msg, 4) ...
[ "def", "unpack", "(", "cls", ",", "msg", ",", "client", ",", "server", ",", "request_id", ")", ":", "flags", ",", "=", "_UNPACK_INT", "(", "msg", "[", ":", "4", "]", ")", "namespace", ",", "pos", "=", "_get_c_string", "(", "msg", ",", "4", ")", "...
Parse message and return an `OpGetMore`. Takes the client message as bytes, the client and server socket objects, and the client request id.
[ "Parse", "message", "and", "return", "an", "OpGetMore", "." ]
ff8a3f793def59e9037397ef60607fbda6949dac
https://github.com/ajdavis/mongo-mockup-db/blob/ff8a3f793def59e9037397ef60607fbda6949dac/mockupdb/__init__.py#L813-L826
train
61,804
ajdavis/mongo-mockup-db
mockupdb/__init__.py
OpKillCursors.unpack
def unpack(cls, msg, client, server, _): """Parse message and return an `OpKillCursors`. Takes the client message as bytes, the client and server socket objects, and the client request id. """ # Leading 4 bytes are reserved. num_of_cursor_ids, = _UNPACK_INT(msg[4:8]) ...
python
def unpack(cls, msg, client, server, _): """Parse message and return an `OpKillCursors`. Takes the client message as bytes, the client and server socket objects, and the client request id. """ # Leading 4 bytes are reserved. num_of_cursor_ids, = _UNPACK_INT(msg[4:8]) ...
[ "def", "unpack", "(", "cls", ",", "msg", ",", "client", ",", "server", ",", "_", ")", ":", "# Leading 4 bytes are reserved.", "num_of_cursor_ids", ",", "=", "_UNPACK_INT", "(", "msg", "[", "4", ":", "8", "]", ")", "cursor_ids", "=", "[", "]", "pos", "=...
Parse message and return an `OpKillCursors`. Takes the client message as bytes, the client and server socket objects, and the client request id.
[ "Parse", "message", "and", "return", "an", "OpKillCursors", "." ]
ff8a3f793def59e9037397ef60607fbda6949dac
https://github.com/ajdavis/mongo-mockup-db/blob/ff8a3f793def59e9037397ef60607fbda6949dac/mockupdb/__init__.py#L848-L862
train
61,805
ajdavis/mongo-mockup-db
mockupdb/__init__.py
OpInsert.unpack
def unpack(cls, msg, client, server, request_id): """Parse message and return an `OpInsert`. Takes the client message as bytes, the client and server socket objects, and the client request id. """ flags, = _UNPACK_INT(msg[:4]) namespace, pos = _get_c_string(msg, 4) ...
python
def unpack(cls, msg, client, server, request_id): """Parse message and return an `OpInsert`. Takes the client message as bytes, the client and server socket objects, and the client request id. """ flags, = _UNPACK_INT(msg[:4]) namespace, pos = _get_c_string(msg, 4) ...
[ "def", "unpack", "(", "cls", ",", "msg", ",", "client", ",", "server", ",", "request_id", ")", ":", "flags", ",", "=", "_UNPACK_INT", "(", "msg", "[", ":", "4", "]", ")", "namespace", ",", "pos", "=", "_get_c_string", "(", "msg", ",", "4", ")", "...
Parse message and return an `OpInsert`. Takes the client message as bytes, the client and server socket objects, and the client request id.
[ "Parse", "message", "and", "return", "an", "OpInsert", "." ]
ff8a3f793def59e9037397ef60607fbda6949dac
https://github.com/ajdavis/mongo-mockup-db/blob/ff8a3f793def59e9037397ef60607fbda6949dac/mockupdb/__init__.py#L887-L897
train
61,806
ajdavis/mongo-mockup-db
mockupdb/__init__.py
OpReply.reply_bytes
def reply_bytes(self, request): """Take a `Request` and return an OP_REPLY message as bytes.""" flags = struct.pack("<i", self._flags) cursor_id = struct.pack("<q", self._cursor_id) starting_from = struct.pack("<i", self._starting_from) number_returned = struct.pack("<i", len(sel...
python
def reply_bytes(self, request): """Take a `Request` and return an OP_REPLY message as bytes.""" flags = struct.pack("<i", self._flags) cursor_id = struct.pack("<q", self._cursor_id) starting_from = struct.pack("<i", self._starting_from) number_returned = struct.pack("<i", len(sel...
[ "def", "reply_bytes", "(", "self", ",", "request", ")", ":", "flags", "=", "struct", ".", "pack", "(", "\"<i\"", ",", "self", ".", "_flags", ")", "cursor_id", "=", "struct", ".", "pack", "(", "\"<q\"", ",", "self", ".", "_cursor_id", ")", "starting_fro...
Take a `Request` and return an OP_REPLY message as bytes.
[ "Take", "a", "Request", "and", "return", "an", "OP_REPLY", "message", "as", "bytes", "." ]
ff8a3f793def59e9037397ef60607fbda6949dac
https://github.com/ajdavis/mongo-mockup-db/blob/ff8a3f793def59e9037397ef60607fbda6949dac/mockupdb/__init__.py#L998-L1014
train
61,807
ajdavis/mongo-mockup-db
mockupdb/__init__.py
OpMsgReply.reply_bytes
def reply_bytes(self, request): """Take a `Request` and return an OP_MSG message as bytes.""" flags = struct.pack("<I", self._flags) payload_type = struct.pack("<b", 0) payload_data = bson.BSON.encode(self.doc) data = b''.join([flags, payload_type, payload_data]) reply_i...
python
def reply_bytes(self, request): """Take a `Request` and return an OP_MSG message as bytes.""" flags = struct.pack("<I", self._flags) payload_type = struct.pack("<b", 0) payload_data = bson.BSON.encode(self.doc) data = b''.join([flags, payload_type, payload_data]) reply_i...
[ "def", "reply_bytes", "(", "self", ",", "request", ")", ":", "flags", "=", "struct", ".", "pack", "(", "\"<I\"", ",", "self", ".", "_flags", ")", "payload_type", "=", "struct", ".", "pack", "(", "\"<b\"", ",", "0", ")", "payload_data", "=", "bson", "...
Take a `Request` and return an OP_MSG message as bytes.
[ "Take", "a", "Request", "and", "return", "an", "OP_MSG", "message", "as", "bytes", "." ]
ff8a3f793def59e9037397ef60607fbda6949dac
https://github.com/ajdavis/mongo-mockup-db/blob/ff8a3f793def59e9037397ef60607fbda6949dac/mockupdb/__init__.py#L1045-L1057
train
61,808
ajdavis/mongo-mockup-db
mockupdb/__init__.py
MockupDB.run
def run(self): """Begin serving. Returns the bound port, or 0 for domain socket.""" self._listening_sock, self._address = ( bind_domain_socket(self._address) if self._uds_path else bind_tcp_socket(self._address)) if self._ssl: certfile = os.path.j...
python
def run(self): """Begin serving. Returns the bound port, or 0 for domain socket.""" self._listening_sock, self._address = ( bind_domain_socket(self._address) if self._uds_path else bind_tcp_socket(self._address)) if self._ssl: certfile = os.path.j...
[ "def", "run", "(", "self", ")", ":", "self", ".", "_listening_sock", ",", "self", ".", "_address", "=", "(", "bind_domain_socket", "(", "self", ".", "_address", ")", "if", "self", ".", "_uds_path", "else", "bind_tcp_socket", "(", "self", ".", "_address", ...
Begin serving. Returns the bound port, or 0 for domain socket.
[ "Begin", "serving", ".", "Returns", "the", "bound", "port", "or", "0", "for", "domain", "socket", "." ]
ff8a3f793def59e9037397ef60607fbda6949dac
https://github.com/ajdavis/mongo-mockup-db/blob/ff8a3f793def59e9037397ef60607fbda6949dac/mockupdb/__init__.py#L1264-L1280
train
61,809
ajdavis/mongo-mockup-db
mockupdb/__init__.py
MockupDB.stop
def stop(self): """Stop serving. Always call this to clean up after yourself.""" self._stopped = True threads = [self._accept_thread] threads.extend(self._server_threads) self._listening_sock.close() for sock in list(self._server_socks): try: s...
python
def stop(self): """Stop serving. Always call this to clean up after yourself.""" self._stopped = True threads = [self._accept_thread] threads.extend(self._server_threads) self._listening_sock.close() for sock in list(self._server_socks): try: s...
[ "def", "stop", "(", "self", ")", ":", "self", ".", "_stopped", "=", "True", "threads", "=", "[", "self", ".", "_accept_thread", "]", "threads", ".", "extend", "(", "self", ".", "_server_threads", ")", "self", ".", "_listening_sock", ".", "close", "(", ...
Stop serving. Always call this to clean up after yourself.
[ "Stop", "serving", ".", "Always", "call", "this", "to", "clean", "up", "after", "yourself", "." ]
ff8a3f793def59e9037397ef60607fbda6949dac
https://github.com/ajdavis/mongo-mockup-db/blob/ff8a3f793def59e9037397ef60607fbda6949dac/mockupdb/__init__.py#L1283-L1308
train
61,810
ajdavis/mongo-mockup-db
mockupdb/__init__.py
MockupDB.receives
def receives(self, *args, **kwargs): """Pop the next `Request` and assert it matches. Returns None if the server is stopped. Pass a `Request` or request pattern to specify what client request to expect. See the tutorial for examples. Pass ``timeout`` as a keyword argument to ov...
python
def receives(self, *args, **kwargs): """Pop the next `Request` and assert it matches. Returns None if the server is stopped. Pass a `Request` or request pattern to specify what client request to expect. See the tutorial for examples. Pass ``timeout`` as a keyword argument to ov...
[ "def", "receives", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "timeout", "=", "kwargs", ".", "pop", "(", "'timeout'", ",", "self", ".", "_request_timeout", ")", "end", "=", "time", ".", "time", "(", ")", "+", "timeout", "matc...
Pop the next `Request` and assert it matches. Returns None if the server is stopped. Pass a `Request` or request pattern to specify what client request to expect. See the tutorial for examples. Pass ``timeout`` as a keyword argument to override this server's ``request_timeout``.
[ "Pop", "the", "next", "Request", "and", "assert", "it", "matches", "." ]
ff8a3f793def59e9037397ef60607fbda6949dac
https://github.com/ajdavis/mongo-mockup-db/blob/ff8a3f793def59e9037397ef60607fbda6949dac/mockupdb/__init__.py#L1310-L1335
train
61,811
ajdavis/mongo-mockup-db
mockupdb/__init__.py
MockupDB.autoresponds
def autoresponds(self, matcher, *args, **kwargs): """Send a canned reply to all matching client requests. ``matcher`` is a `Matcher` or a command name, or an instance of `OpInsert`, `OpQuery`, etc. >>> s = MockupDB() >>> port = s.run() >>> >>> from pymon...
python
def autoresponds(self, matcher, *args, **kwargs): """Send a canned reply to all matching client requests. ``matcher`` is a `Matcher` or a command name, or an instance of `OpInsert`, `OpQuery`, etc. >>> s = MockupDB() >>> port = s.run() >>> >>> from pymon...
[ "def", "autoresponds", "(", "self", ",", "matcher", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_insert_responder", "(", "\"top\"", ",", "matcher", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Send a canned reply to all matching client requests. ``matcher`` is a `Matcher` or a command name, or an instance of `OpInsert`, `OpQuery`, etc. >>> s = MockupDB() >>> port = s.run() >>> >>> from pymongo import MongoClient >>> client = MongoClient(s.uri)...
[ "Send", "a", "canned", "reply", "to", "all", "matching", "client", "requests", ".", "matcher", "is", "a", "Matcher", "or", "a", "command", "name", "or", "an", "instance", "of", "OpInsert", "OpQuery", "etc", "." ]
ff8a3f793def59e9037397ef60607fbda6949dac
https://github.com/ajdavis/mongo-mockup-db/blob/ff8a3f793def59e9037397ef60607fbda6949dac/mockupdb/__init__.py#L1401-L1497
train
61,812
ajdavis/mongo-mockup-db
mockupdb/__init__.py
MockupDB.append_responder
def append_responder(self, matcher, *args, **kwargs): """Add a responder of last resort. Like `.autoresponds`, but instead of adding a responder to the top of the stack, add it to the bottom. This responder will be called if no others match. """ return self._insert_respo...
python
def append_responder(self, matcher, *args, **kwargs): """Add a responder of last resort. Like `.autoresponds`, but instead of adding a responder to the top of the stack, add it to the bottom. This responder will be called if no others match. """ return self._insert_respo...
[ "def", "append_responder", "(", "self", ",", "matcher", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_insert_responder", "(", "\"bottom\"", ",", "matcher", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Add a responder of last resort. Like `.autoresponds`, but instead of adding a responder to the top of the stack, add it to the bottom. This responder will be called if no others match.
[ "Add", "a", "responder", "of", "last", "resort", "." ]
ff8a3f793def59e9037397ef60607fbda6949dac
https://github.com/ajdavis/mongo-mockup-db/blob/ff8a3f793def59e9037397ef60607fbda6949dac/mockupdb/__init__.py#L1503-L1510
train
61,813
ajdavis/mongo-mockup-db
mockupdb/__init__.py
MockupDB.uri
def uri(self): """Connection string to pass to `~pymongo.mongo_client.MongoClient`.""" if self._uds_path: uri = 'mongodb://%s' % (quote_plus(self._uds_path),) else: uri = 'mongodb://%s' % (format_addr(self._address),) return uri + '/?ssl=true' if self._ssl else ur...
python
def uri(self): """Connection string to pass to `~pymongo.mongo_client.MongoClient`.""" if self._uds_path: uri = 'mongodb://%s' % (quote_plus(self._uds_path),) else: uri = 'mongodb://%s' % (format_addr(self._address),) return uri + '/?ssl=true' if self._ssl else ur...
[ "def", "uri", "(", "self", ")", ":", "if", "self", ".", "_uds_path", ":", "uri", "=", "'mongodb://%s'", "%", "(", "quote_plus", "(", "self", ".", "_uds_path", ")", ",", ")", "else", ":", "uri", "=", "'mongodb://%s'", "%", "(", "format_addr", "(", "se...
Connection string to pass to `~pymongo.mongo_client.MongoClient`.
[ "Connection", "string", "to", "pass", "to", "~pymongo", ".", "mongo_client", ".", "MongoClient", "." ]
ff8a3f793def59e9037397ef60607fbda6949dac
https://github.com/ajdavis/mongo-mockup-db/blob/ff8a3f793def59e9037397ef60607fbda6949dac/mockupdb/__init__.py#L1557-L1563
train
61,814
ajdavis/mongo-mockup-db
mockupdb/__init__.py
MockupDB._accept_loop
def _accept_loop(self): """Accept client connections and spawn a thread for each.""" self._listening_sock.setblocking(0) while not self._stopped and not _shutting_down: try: # Wait a short time to accept. if select.select([self._listening_sock.fileno()...
python
def _accept_loop(self): """Accept client connections and spawn a thread for each.""" self._listening_sock.setblocking(0) while not self._stopped and not _shutting_down: try: # Wait a short time to accept. if select.select([self._listening_sock.fileno()...
[ "def", "_accept_loop", "(", "self", ")", ":", "self", ".", "_listening_sock", ".", "setblocking", "(", "0", ")", "while", "not", "self", ".", "_stopped", "and", "not", "_shutting_down", ":", "try", ":", "# Wait a short time to accept.", "if", "select", ".", ...
Accept client connections and spawn a thread for each.
[ "Accept", "client", "connections", "and", "spawn", "a", "thread", "for", "each", "." ]
ff8a3f793def59e9037397ef60607fbda6949dac
https://github.com/ajdavis/mongo-mockup-db/blob/ff8a3f793def59e9037397ef60607fbda6949dac/mockupdb/__init__.py#L1611-L1641
train
61,815
ajdavis/mongo-mockup-db
mockupdb/__init__.py
MockupDB._server_loop
def _server_loop(self, client, client_addr): """Read requests from one client socket, 'client'.""" while not self._stopped and not _shutting_down: try: with self._unlock(): request = mock_server_receive_request(client, self) self._requests...
python
def _server_loop(self, client, client_addr): """Read requests from one client socket, 'client'.""" while not self._stopped and not _shutting_down: try: with self._unlock(): request = mock_server_receive_request(client, self) self._requests...
[ "def", "_server_loop", "(", "self", ",", "client", ",", "client_addr", ")", ":", "while", "not", "self", ".", "_stopped", "and", "not", "_shutting_down", ":", "try", ":", "with", "self", ".", "_unlock", "(", ")", ":", "request", "=", "mock_server_receive_r...
Read requests from one client socket, 'client'.
[ "Read", "requests", "from", "one", "client", "socket", "client", "." ]
ff8a3f793def59e9037397ef60607fbda6949dac
https://github.com/ajdavis/mongo-mockup-db/blob/ff8a3f793def59e9037397ef60607fbda6949dac/mockupdb/__init__.py#L1644-L1677
train
61,816
02strich/django-auth-kerberos
django_auth_kerberos/backends.py
KrbBackend.check_password
def check_password(self, username, password): """The actual password checking logic. Separated from the authenticate code from Django for easier updating""" try: if SUPPORTS_VERIFY: kerberos.checkPassword(username.lower(), password, getattr(settings, "KRB5_SERVICE", ""), geta...
python
def check_password(self, username, password): """The actual password checking logic. Separated from the authenticate code from Django for easier updating""" try: if SUPPORTS_VERIFY: kerberos.checkPassword(username.lower(), password, getattr(settings, "KRB5_SERVICE", ""), geta...
[ "def", "check_password", "(", "self", ",", "username", ",", "password", ")", ":", "try", ":", "if", "SUPPORTS_VERIFY", ":", "kerberos", ".", "checkPassword", "(", "username", ".", "lower", "(", ")", ",", "password", ",", "getattr", "(", "settings", ",", ...
The actual password checking logic. Separated from the authenticate code from Django for easier updating
[ "The", "actual", "password", "checking", "logic", ".", "Separated", "from", "the", "authenticate", "code", "from", "Django", "for", "easier", "updating" ]
416c2e2fafe6f0dbddf79bef6f6dbb90b04ceedc
https://github.com/02strich/django-auth-kerberos/blob/416c2e2fafe6f0dbddf79bef6f6dbb90b04ceedc/django_auth_kerberos/backends.py#L53-L69
train
61,817
ajdavis/mongo-mockup-db
mockupdb/__main__.py
main
def main(): """Start an interactive `MockupDB`. Use like ``python -m mockupdb``. """ from optparse import OptionParser parser = OptionParser('Start mock MongoDB server') parser.add_option('-p', '--port', dest='port', default=27017, help='port on which mock mongod listens')...
python
def main(): """Start an interactive `MockupDB`. Use like ``python -m mockupdb``. """ from optparse import OptionParser parser = OptionParser('Start mock MongoDB server') parser.add_option('-p', '--port', dest='port', default=27017, help='port on which mock mongod listens')...
[ "def", "main", "(", ")", ":", "from", "optparse", "import", "OptionParser", "parser", "=", "OptionParser", "(", "'Start mock MongoDB server'", ")", "parser", ".", "add_option", "(", "'-p'", ",", "'--port'", ",", "dest", "=", "'port'", ",", "default", "=", "2...
Start an interactive `MockupDB`. Use like ``python -m mockupdb``.
[ "Start", "an", "interactive", "MockupDB", "." ]
ff8a3f793def59e9037397ef60607fbda6949dac
https://github.com/ajdavis/mongo-mockup-db/blob/ff8a3f793def59e9037397ef60607fbda6949dac/mockupdb/__main__.py#L23-L46
train
61,818
stephantul/somber
somber/som.py
BaseSom._initialize_distance_grid
def _initialize_distance_grid(self): """Initialize the distance grid by calls to _grid_dist.""" p = [self._grid_distance(i) for i in range(self.num_neurons)] return np.array(p)
python
def _initialize_distance_grid(self): """Initialize the distance grid by calls to _grid_dist.""" p = [self._grid_distance(i) for i in range(self.num_neurons)] return np.array(p)
[ "def", "_initialize_distance_grid", "(", "self", ")", ":", "p", "=", "[", "self", ".", "_grid_distance", "(", "i", ")", "for", "i", "in", "range", "(", "self", ".", "num_neurons", ")", "]", "return", "np", ".", "array", "(", "p", ")" ]
Initialize the distance grid by calls to _grid_dist.
[ "Initialize", "the", "distance", "grid", "by", "calls", "to", "_grid_dist", "." ]
b7a13e646239500cc393668c01a7169c3e50b7b5
https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/som.py#L94-L97
train
61,819
stephantul/somber
somber/som.py
BaseSom._grid_distance
def _grid_distance(self, index): """ Calculate the distance grid for a single index position. This is pre-calculated for fast neighborhood calculations later on (see _calc_influence). """ # Take every dimension but the first in reverse # then reverse that list ag...
python
def _grid_distance(self, index): """ Calculate the distance grid for a single index position. This is pre-calculated for fast neighborhood calculations later on (see _calc_influence). """ # Take every dimension but the first in reverse # then reverse that list ag...
[ "def", "_grid_distance", "(", "self", ",", "index", ")", ":", "# Take every dimension but the first in reverse", "# then reverse that list again.", "dimensions", "=", "np", ".", "cumprod", "(", "self", ".", "map_dimensions", "[", "1", ":", ":", "]", "[", ":", ":",...
Calculate the distance grid for a single index position. This is pre-calculated for fast neighborhood calculations later on (see _calc_influence).
[ "Calculate", "the", "distance", "grid", "for", "a", "single", "index", "position", "." ]
b7a13e646239500cc393668c01a7169c3e50b7b5
https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/som.py#L99-L131
train
61,820
stephantul/somber
somber/som.py
BaseSom.topographic_error
def topographic_error(self, X, batch_size=1): """ Calculate the topographic error. The topographic error is a measure of the spatial organization of the map. Maps in which the most similar neurons are also close on the grid have low topographic error and indicate that a problem ...
python
def topographic_error(self, X, batch_size=1): """ Calculate the topographic error. The topographic error is a measure of the spatial organization of the map. Maps in which the most similar neurons are also close on the grid have low topographic error and indicate that a problem ...
[ "def", "topographic_error", "(", "self", ",", "X", ",", "batch_size", "=", "1", ")", ":", "dist", "=", "self", ".", "transform", "(", "X", ",", "batch_size", ")", "# Sort the distances and get the indices of the two smallest distances", "# for each datapoint.", "res",...
Calculate the topographic error. The topographic error is a measure of the spatial organization of the map. Maps in which the most similar neurons are also close on the grid have low topographic error and indicate that a problem has been learned correctly. Formally, the topogra...
[ "Calculate", "the", "topographic", "error", "." ]
b7a13e646239500cc393668c01a7169c3e50b7b5
https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/som.py#L133-L168
train
61,821
stephantul/somber
somber/som.py
BaseSom.neighbors
def neighbors(self, distance=2.0): """Get all neighbors for all neurons.""" dgrid = self.distance_grid.reshape(self.num_neurons, self.num_neurons) for x, y in zip(*np.nonzero(dgrid <= distance)): if x != y: yield x, y
python
def neighbors(self, distance=2.0): """Get all neighbors for all neurons.""" dgrid = self.distance_grid.reshape(self.num_neurons, self.num_neurons) for x, y in zip(*np.nonzero(dgrid <= distance)): if x != y: yield x, y
[ "def", "neighbors", "(", "self", ",", "distance", "=", "2.0", ")", ":", "dgrid", "=", "self", ".", "distance_grid", ".", "reshape", "(", "self", ".", "num_neurons", ",", "self", ".", "num_neurons", ")", "for", "x", ",", "y", "in", "zip", "(", "*", ...
Get all neighbors for all neurons.
[ "Get", "all", "neighbors", "for", "all", "neurons", "." ]
b7a13e646239500cc393668c01a7169c3e50b7b5
https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/som.py#L170-L175
train
61,822
stephantul/somber
somber/som.py
BaseSom.neighbor_difference
def neighbor_difference(self): """Get the euclidean distance between a node and its neighbors.""" differences = np.zeros(self.num_neurons) num_neighbors = np.zeros(self.num_neurons) distance, _ = self.distance_function(self.weights, self.weights) for x, y in self.neighbors(): ...
python
def neighbor_difference(self): """Get the euclidean distance between a node and its neighbors.""" differences = np.zeros(self.num_neurons) num_neighbors = np.zeros(self.num_neurons) distance, _ = self.distance_function(self.weights, self.weights) for x, y in self.neighbors(): ...
[ "def", "neighbor_difference", "(", "self", ")", ":", "differences", "=", "np", ".", "zeros", "(", "self", ".", "num_neurons", ")", "num_neighbors", "=", "np", ".", "zeros", "(", "self", ".", "num_neurons", ")", "distance", ",", "_", "=", "self", ".", "...
Get the euclidean distance between a node and its neighbors.
[ "Get", "the", "euclidean", "distance", "between", "a", "node", "and", "its", "neighbors", "." ]
b7a13e646239500cc393668c01a7169c3e50b7b5
https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/som.py#L177-L187
train
61,823
stephantul/somber
somber/som.py
BaseSom.spread
def spread(self, X): """ Calculate the average spread for each node. The average spread is a measure of how far each neuron is from the data points which cluster to it. Parameters ---------- X : numpy array The input data. Returns --...
python
def spread(self, X): """ Calculate the average spread for each node. The average spread is a measure of how far each neuron is from the data points which cluster to it. Parameters ---------- X : numpy array The input data. Returns --...
[ "def", "spread", "(", "self", ",", "X", ")", ":", "distance", ",", "_", "=", "self", ".", "distance_function", "(", "X", ",", "self", ".", "weights", ")", "dists_per_neuron", "=", "defaultdict", "(", "list", ")", "for", "x", ",", "y", "in", "zip", ...
Calculate the average spread for each node. The average spread is a measure of how far each neuron is from the data points which cluster to it. Parameters ---------- X : numpy array The input data. Returns ------- spread : numpy array ...
[ "Calculate", "the", "average", "spread", "for", "each", "node", "." ]
b7a13e646239500cc393668c01a7169c3e50b7b5
https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/som.py#L189-L218
train
61,824
stephantul/somber
somber/som.py
BaseSom.receptive_field
def receptive_field(self, X, identities, max_len=10, threshold=0.9, batch_size=1): """ Calculate the receptive field of the SOM on some data. The receptive field is the common...
python
def receptive_field(self, X, identities, max_len=10, threshold=0.9, batch_size=1): """ Calculate the receptive field of the SOM on some data. The receptive field is the common...
[ "def", "receptive_field", "(", "self", ",", "X", ",", "identities", ",", "max_len", "=", "10", ",", "threshold", "=", "0.9", ",", "batch_size", "=", "1", ")", ":", "receptive_fields", "=", "defaultdict", "(", "list", ")", "predictions", "=", "self", ".",...
Calculate the receptive field of the SOM on some data. The receptive field is the common ending of all sequences which lead to the activation of a given BMU. If a SOM is well-tuned to specific sequences, it will have longer receptive fields, and therefore gives a better description of t...
[ "Calculate", "the", "receptive", "field", "of", "the", "SOM", "on", "some", "data", "." ]
b7a13e646239500cc393668c01a7169c3e50b7b5
https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/som.py#L220-L287
train
61,825
stephantul/somber
somber/som.py
BaseSom.invert_projection
def invert_projection(self, X, identities): """ Calculate the inverted projection. The inverted projectio of a SOM is created by association each weight with the input which matches it the most, thus giving a good approximation of the "influence" of each input item. Wor...
python
def invert_projection(self, X, identities): """ Calculate the inverted projection. The inverted projectio of a SOM is created by association each weight with the input which matches it the most, thus giving a good approximation of the "influence" of each input item. Wor...
[ "def", "invert_projection", "(", "self", ",", "X", ",", "identities", ")", ":", "distances", "=", "self", ".", "transform", "(", "X", ")", "if", "len", "(", "distances", ")", "!=", "len", "(", "identities", ")", ":", "raise", "ValueError", "(", "\"X an...
Calculate the inverted projection. The inverted projectio of a SOM is created by association each weight with the input which matches it the most, thus giving a good approximation of the "influence" of each input item. Works best for symbolic (instead of continuous) input data. ...
[ "Calculate", "the", "inverted", "projection", "." ]
b7a13e646239500cc393668c01a7169c3e50b7b5
https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/som.py#L289-L324
train
61,826
stephantul/somber
somber/som.py
BaseSom.map_weights
def map_weights(self): """ Reshaped weights for visualization. The weights are reshaped as (W.shape[0], prod(W.shape[1:-1]), W.shape[2]). This allows one to easily see patterns, even for hyper-dimensional soms. For one-dimensional SOMs, the returned array is of ...
python
def map_weights(self): """ Reshaped weights for visualization. The weights are reshaped as (W.shape[0], prod(W.shape[1:-1]), W.shape[2]). This allows one to easily see patterns, even for hyper-dimensional soms. For one-dimensional SOMs, the returned array is of ...
[ "def", "map_weights", "(", "self", ")", ":", "first_dim", "=", "self", ".", "map_dimensions", "[", "0", "]", "if", "len", "(", "self", ".", "map_dimensions", ")", "!=", "1", ":", "second_dim", "=", "np", ".", "prod", "(", "self", ".", "map_dimensions",...
Reshaped weights for visualization. The weights are reshaped as (W.shape[0], prod(W.shape[1:-1]), W.shape[2]). This allows one to easily see patterns, even for hyper-dimensional soms. For one-dimensional SOMs, the returned array is of shape (W.shape[0], 1, W.shape[2]) ...
[ "Reshaped", "weights", "for", "visualization", "." ]
b7a13e646239500cc393668c01a7169c3e50b7b5
https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/som.py#L326-L354
train
61,827
stephantul/somber
somber/som.py
Som.load
def load(cls, path): """ Load a SOM from a JSON file saved with this package.. Parameters ---------- path : str The path to the JSON file. Returns ------- s : cls A som of the specified class. """ data = json.load...
python
def load(cls, path): """ Load a SOM from a JSON file saved with this package.. Parameters ---------- path : str The path to the JSON file. Returns ------- s : cls A som of the specified class. """ data = json.load...
[ "def", "load", "(", "cls", ",", "path", ")", ":", "data", "=", "json", ".", "load", "(", "open", "(", "path", ")", ")", "weights", "=", "data", "[", "'weights'", "]", "weights", "=", "np", ".", "asarray", "(", "weights", ",", "dtype", "=", "np", ...
Load a SOM from a JSON file saved with this package.. Parameters ---------- path : str The path to the JSON file. Returns ------- s : cls A som of the specified class.
[ "Load", "a", "SOM", "from", "a", "JSON", "file", "saved", "with", "this", "package", ".." ]
b7a13e646239500cc393668c01a7169c3e50b7b5
https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/som.py#L447-L477
train
61,828
cloudnull/turbolift
turbolift/methods/__init__.py
BaseMethod.remove_dirs
def remove_dirs(self, directory): """Delete a directory recursively. :param directory: $PATH to directory. :type directory: ``str`` """ LOG.info('Removing directory [ %s ]', directory) local_files = self._drectory_local_files(directory=directory) for file_name i...
python
def remove_dirs(self, directory): """Delete a directory recursively. :param directory: $PATH to directory. :type directory: ``str`` """ LOG.info('Removing directory [ %s ]', directory) local_files = self._drectory_local_files(directory=directory) for file_name i...
[ "def", "remove_dirs", "(", "self", ",", "directory", ")", ":", "LOG", ".", "info", "(", "'Removing directory [ %s ]'", ",", "directory", ")", "local_files", "=", "self", ".", "_drectory_local_files", "(", "directory", "=", "directory", ")", "for", "file_name", ...
Delete a directory recursively. :param directory: $PATH to directory. :type directory: ``str``
[ "Delete", "a", "directory", "recursively", "." ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/methods/__init__.py#L139-L167
train
61,829
cloudnull/turbolift
turbolift/methods/__init__.py
BaseMethod._return_container_objects
def _return_container_objects(self): """Return a list of objects to delete. The return tuple will indicate if it was a userd efined list of objects as True of False. The list of objects is a list of dictionaries with the key being "container_object". :returns: tuple (`...
python
def _return_container_objects(self): """Return a list of objects to delete. The return tuple will indicate if it was a userd efined list of objects as True of False. The list of objects is a list of dictionaries with the key being "container_object". :returns: tuple (`...
[ "def", "_return_container_objects", "(", "self", ")", ":", "container_objects", "=", "self", ".", "job_args", ".", "get", "(", "'object'", ")", "if", "container_objects", ":", "return", "True", ",", "[", "{", "'container_object'", ":", "i", "}", "for", "i", ...
Return a list of objects to delete. The return tuple will indicate if it was a userd efined list of objects as True of False. The list of objects is a list of dictionaries with the key being "container_object". :returns: tuple (``bol``, ``list``)
[ "Return", "a", "list", "of", "objects", "to", "delete", "." ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/methods/__init__.py#L342-L383
train
61,830
cloudnull/turbolift
turbolift/methods/__init__.py
BaseMethod._index_fs
def _index_fs(self): """Returns a deque object full of local file system items. :returns: ``deque`` """ indexed_objects = self._return_deque() directory = self.job_args.get('directory') if directory: indexed_objects = self._return_deque( deq...
python
def _index_fs(self): """Returns a deque object full of local file system items. :returns: ``deque`` """ indexed_objects = self._return_deque() directory = self.job_args.get('directory') if directory: indexed_objects = self._return_deque( deq...
[ "def", "_index_fs", "(", "self", ")", ":", "indexed_objects", "=", "self", ".", "_return_deque", "(", ")", "directory", "=", "self", ".", "job_args", ".", "get", "(", "'directory'", ")", "if", "directory", ":", "indexed_objects", "=", "self", ".", "_return...
Returns a deque object full of local file system items. :returns: ``deque``
[ "Returns", "a", "deque", "object", "full", "of", "local", "file", "system", "items", "." ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/methods/__init__.py#L497-L523
train
61,831
cloudnull/turbolift
turbolift/methods/__init__.py
BaseMethod.match_filter
def match_filter(self, idx_list, pattern, dict_type=False, dict_key='name'): """Return Matched items in indexed files. :param idx_list: :return list """ if dict_type is False: return self._return_deque([ obj for obj in idx_list ...
python
def match_filter(self, idx_list, pattern, dict_type=False, dict_key='name'): """Return Matched items in indexed files. :param idx_list: :return list """ if dict_type is False: return self._return_deque([ obj for obj in idx_list ...
[ "def", "match_filter", "(", "self", ",", "idx_list", ",", "pattern", ",", "dict_type", "=", "False", ",", "dict_key", "=", "'name'", ")", ":", "if", "dict_type", "is", "False", ":", "return", "self", ".", "_return_deque", "(", "[", "obj", "for", "obj", ...
Return Matched items in indexed files. :param idx_list: :return list
[ "Return", "Matched", "items", "in", "indexed", "files", "." ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/methods/__init__.py#L580-L599
train
61,832
cloudnull/turbolift
turbolift/methods/__init__.py
BaseMethod.print_horiz_table
def print_horiz_table(self, data): """Print a horizontal pretty table from data.""" # Build list of returned objects return_objects = list() fields = self.job_args.get('fields') if not fields: fields = set() for item_dict in data: for fiel...
python
def print_horiz_table(self, data): """Print a horizontal pretty table from data.""" # Build list of returned objects return_objects = list() fields = self.job_args.get('fields') if not fields: fields = set() for item_dict in data: for fiel...
[ "def", "print_horiz_table", "(", "self", ",", "data", ")", ":", "# Build list of returned objects", "return_objects", "=", "list", "(", ")", "fields", "=", "self", ".", "job_args", ".", "get", "(", "'fields'", ")", "if", "not", "fields", ":", "fields", "=", ...
Print a horizontal pretty table from data.
[ "Print", "a", "horizontal", "pretty", "table", "from", "data", "." ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/methods/__init__.py#L601-L632
train
61,833
cloudnull/turbolift
turbolift/methods/__init__.py
BaseMethod.print_virt_table
def print_virt_table(self, data): """Print a vertical pretty table from data.""" table = prettytable.PrettyTable() keys = sorted(data.keys()) table.add_column('Keys', keys) table.add_column('Values', [data.get(i) for i in keys]) for tbl in table.align.keys(): ...
python
def print_virt_table(self, data): """Print a vertical pretty table from data.""" table = prettytable.PrettyTable() keys = sorted(data.keys()) table.add_column('Keys', keys) table.add_column('Values', [data.get(i) for i in keys]) for tbl in table.align.keys(): ...
[ "def", "print_virt_table", "(", "self", ",", "data", ")", ":", "table", "=", "prettytable", ".", "PrettyTable", "(", ")", "keys", "=", "sorted", "(", "data", ".", "keys", "(", ")", ")", "table", ".", "add_column", "(", "'Keys'", ",", "keys", ")", "ta...
Print a vertical pretty table from data.
[ "Print", "a", "vertical", "pretty", "table", "from", "data", "." ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/methods/__init__.py#L634-L644
train
61,834
cloudnull/turbolift
turbolift/methods/__init__.py
BaseMethod.printer
def printer(self, message, color_level='info'): """Print Messages and Log it. :param message: item to print to screen """ if self.job_args.get('colorized'): print(cloud_utils.return_colorized(msg=message, color=color_level)) else: print(message)
python
def printer(self, message, color_level='info'): """Print Messages and Log it. :param message: item to print to screen """ if self.job_args.get('colorized'): print(cloud_utils.return_colorized(msg=message, color=color_level)) else: print(message)
[ "def", "printer", "(", "self", ",", "message", ",", "color_level", "=", "'info'", ")", ":", "if", "self", ".", "job_args", ".", "get", "(", "'colorized'", ")", ":", "print", "(", "cloud_utils", ".", "return_colorized", "(", "msg", "=", "message", ",", ...
Print Messages and Log it. :param message: item to print to screen
[ "Print", "Messages", "and", "Log", "it", "." ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/methods/__init__.py#L646-L655
train
61,835
cloudnull/turbolift
turbolift/worker.py
Worker._get_method
def _get_method(method): """Return an imported object. :param method: ``str`` DOT notation for import with Colin used to separate the class used for the job. :returns: ``object`` Loaded class object from imported method. """ # Split the class out ...
python
def _get_method(method): """Return an imported object. :param method: ``str`` DOT notation for import with Colin used to separate the class used for the job. :returns: ``object`` Loaded class object from imported method. """ # Split the class out ...
[ "def", "_get_method", "(", "method", ")", ":", "# Split the class out from the job", "module", "=", "method", ".", "split", "(", "':'", ")", "# Set the import module", "_module_import", "=", "module", "[", "0", "]", "# Set the class name to use", "class_name", "=", ...
Return an imported object. :param method: ``str`` DOT notation for import with Colin used to separate the class used for the job. :returns: ``object`` Loaded class object from imported method.
[ "Return", "an", "imported", "object", "." ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/worker.py#L37-L58
train
61,836
cloudnull/turbolift
turbolift/worker.py
Worker.run_manager
def run_manager(self, job_override=None): """The run manager. The run manager is responsible for loading the plugin required based on what the user has inputted using the parsed_command value as found in the job_args dict. If the user provides a *job_override* the method will at...
python
def run_manager(self, job_override=None): """The run manager. The run manager is responsible for loading the plugin required based on what the user has inputted using the parsed_command value as found in the job_args dict. If the user provides a *job_override* the method will at...
[ "def", "run_manager", "(", "self", ",", "job_override", "=", "None", ")", ":", "for", "arg_name", ",", "arg_value", "in", "self", ".", "job_args", ".", "items", "(", ")", ":", "if", "arg_name", ".", "endswith", "(", "'_headers'", ")", ":", "if", "isins...
The run manager. The run manager is responsible for loading the plugin required based on what the user has inputted using the parsed_command value as found in the job_args dict. If the user provides a *job_override* the method will attempt to import the module and class as provided by t...
[ "The", "run", "manager", "." ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/worker.py#L80-L130
train
61,837
stephantul/somber
somber/components/initializers.py
range_initialization
def range_initialization(X, num_weights): """ Initialize the weights by calculating the range of the data. The data range is calculated by reshaping the input matrix to a 2D matrix, and then taking the min and max values over the columns. Parameters ---------- X : numpy array The i...
python
def range_initialization(X, num_weights): """ Initialize the weights by calculating the range of the data. The data range is calculated by reshaping the input matrix to a 2D matrix, and then taking the min and max values over the columns. Parameters ---------- X : numpy array The i...
[ "def", "range_initialization", "(", "X", ",", "num_weights", ")", ":", "# Randomly initialize weights to cover the range of each feature.", "X_", "=", "X", ".", "reshape", "(", "-", "1", ",", "X", ".", "shape", "[", "-", "1", "]", ")", "min_val", ",", "max_val...
Initialize the weights by calculating the range of the data. The data range is calculated by reshaping the input matrix to a 2D matrix, and then taking the min and max values over the columns. Parameters ---------- X : numpy array The input data. The data range is calculated over the last ...
[ "Initialize", "the", "weights", "by", "calculating", "the", "range", "of", "the", "data", "." ]
b7a13e646239500cc393668c01a7169c3e50b7b5
https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/components/initializers.py#L10-L37
train
61,838
stephantul/somber
somber/base.py
Base.fit
def fit(self, X, num_epochs=10, updates_epoch=None, stop_param_updates=dict(), batch_size=1, show_progressbar=False, show_epoch=False, refit=True): """ Fit the learner to some data. Parameters ...
python
def fit(self, X, num_epochs=10, updates_epoch=None, stop_param_updates=dict(), batch_size=1, show_progressbar=False, show_epoch=False, refit=True): """ Fit the learner to some data. Parameters ...
[ "def", "fit", "(", "self", ",", "X", ",", "num_epochs", "=", "10", ",", "updates_epoch", "=", "None", ",", "stop_param_updates", "=", "dict", "(", ")", ",", "batch_size", "=", "1", ",", "show_progressbar", "=", "False", ",", "show_epoch", "=", "False", ...
Fit the learner to some data. Parameters ---------- X : numpy array. The input data. num_epochs : int, optional, default 10 The number of epochs to train for. updates_epoch : int, optional, default 10 The number of updates to perform on the le...
[ "Fit", "the", "learner", "to", "some", "data", "." ]
b7a13e646239500cc393668c01a7169c3e50b7b5
https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/base.py#L91-L157
train
61,839
stephantul/somber
somber/base.py
Base._init_weights
def _init_weights(self, X): """Set the weights and normalize data before starting training.""" X = np.asarray(X, dtype=np.float64) if self.scaler is not None: X = self.scaler.fit_transform(X) if self.initializer is not None: self.weights = ...
python
def _init_weights(self, X): """Set the weights and normalize data before starting training.""" X = np.asarray(X, dtype=np.float64) if self.scaler is not None: X = self.scaler.fit_transform(X) if self.initializer is not None: self.weights = ...
[ "def", "_init_weights", "(", "self", ",", "X", ")", ":", "X", "=", "np", ".", "asarray", "(", "X", ",", "dtype", "=", "np", ".", "float64", ")", "if", "self", ".", "scaler", "is", "not", "None", ":", "X", "=", "self", ".", "scaler", ".", "fit_t...
Set the weights and normalize data before starting training.
[ "Set", "the", "weights", "and", "normalize", "data", "before", "starting", "training", "." ]
b7a13e646239500cc393668c01a7169c3e50b7b5
https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/base.py#L159-L173
train
61,840
stephantul/somber
somber/base.py
Base._pre_train
def _pre_train(self, stop_param_updates, num_epochs, updates_epoch): """Set parameters and constants before training.""" # Calculate the total number of updates given early stopping. updates = {k: stop_param_updates.get(k, num_epochs) * up...
python
def _pre_train(self, stop_param_updates, num_epochs, updates_epoch): """Set parameters and constants before training.""" # Calculate the total number of updates given early stopping. updates = {k: stop_param_updates.get(k, num_epochs) * up...
[ "def", "_pre_train", "(", "self", ",", "stop_param_updates", ",", "num_epochs", ",", "updates_epoch", ")", ":", "# Calculate the total number of updates given early stopping.", "updates", "=", "{", "k", ":", "stop_param_updates", ".", "get", "(", "k", ",", "num_epochs...
Set parameters and constants before training.
[ "Set", "parameters", "and", "constants", "before", "training", "." ]
b7a13e646239500cc393668c01a7169c3e50b7b5
https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/base.py#L175-L195
train
61,841
stephantul/somber
somber/base.py
Base.fit_predict
def fit_predict(self, X, num_epochs=10, updates_epoch=10, stop_param_updates=dict(), batch_size=1, show_progressbar=False): """First fit, then predict.""" self.fit(X, ...
python
def fit_predict(self, X, num_epochs=10, updates_epoch=10, stop_param_updates=dict(), batch_size=1, show_progressbar=False): """First fit, then predict.""" self.fit(X, ...
[ "def", "fit_predict", "(", "self", ",", "X", ",", "num_epochs", "=", "10", ",", "updates_epoch", "=", "10", ",", "stop_param_updates", "=", "dict", "(", ")", ",", "batch_size", "=", "1", ",", "show_progressbar", "=", "False", ")", ":", "self", ".", "fi...
First fit, then predict.
[ "First", "fit", "then", "predict", "." ]
b7a13e646239500cc393668c01a7169c3e50b7b5
https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/base.py#L197-L212
train
61,842
stephantul/somber
somber/base.py
Base.fit_transform
def fit_transform(self, X, num_epochs=10, updates_epoch=10, stop_param_updates=dict(), batch_size=1, show_progressbar=False, show_epoch=False): """First fit, ...
python
def fit_transform(self, X, num_epochs=10, updates_epoch=10, stop_param_updates=dict(), batch_size=1, show_progressbar=False, show_epoch=False): """First fit, ...
[ "def", "fit_transform", "(", "self", ",", "X", ",", "num_epochs", "=", "10", ",", "updates_epoch", "=", "10", ",", "stop_param_updates", "=", "dict", "(", ")", ",", "batch_size", "=", "1", ",", "show_progressbar", "=", "False", ",", "show_epoch", "=", "F...
First fit, then transform.
[ "First", "fit", "then", "transform", "." ]
b7a13e646239500cc393668c01a7169c3e50b7b5
https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/base.py#L214-L231
train
61,843
stephantul/somber
somber/base.py
Base._update_params
def _update_params(self, constants): """Update params and return new influence.""" for k, v in constants.items(): self.params[k]['value'] *= v influence = self._calculate_influence(self.params['infl']['value']) return influence * self.params['lr']['value']
python
def _update_params(self, constants): """Update params and return new influence.""" for k, v in constants.items(): self.params[k]['value'] *= v influence = self._calculate_influence(self.params['infl']['value']) return influence * self.params['lr']['value']
[ "def", "_update_params", "(", "self", ",", "constants", ")", ":", "for", "k", ",", "v", "in", "constants", ".", "items", "(", ")", ":", "self", ".", "params", "[", "k", "]", "[", "'value'", "]", "*=", "v", "influence", "=", "self", ".", "_calculate...
Update params and return new influence.
[ "Update", "params", "and", "return", "new", "influence", "." ]
b7a13e646239500cc393668c01a7169c3e50b7b5
https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/base.py#L295-L301
train
61,844
stephantul/somber
somber/base.py
Base._create_batches
def _create_batches(self, X, batch_size, shuffle_data=True): """ Create batches out of a sequence of data. This function will append zeros to the end of your data to ensure that all batches are even-sized. These are masked out during training. """ if shuffle_data: ...
python
def _create_batches(self, X, batch_size, shuffle_data=True): """ Create batches out of a sequence of data. This function will append zeros to the end of your data to ensure that all batches are even-sized. These are masked out during training. """ if shuffle_data: ...
[ "def", "_create_batches", "(", "self", ",", "X", ",", "batch_size", ",", "shuffle_data", "=", "True", ")", ":", "if", "shuffle_data", ":", "X", "=", "shuffle", "(", "X", ")", "if", "batch_size", ">", "X", ".", "shape", "[", "0", "]", ":", "batch_size...
Create batches out of a sequence of data. This function will append zeros to the end of your data to ensure that all batches are even-sized. These are masked out during training.
[ "Create", "batches", "out", "of", "a", "sequence", "of", "data", "." ]
b7a13e646239500cc393668c01a7169c3e50b7b5
https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/base.py#L311-L327
train
61,845
stephantul/somber
somber/base.py
Base._propagate
def _propagate(self, x, influences, **kwargs): """Propagate a single batch of examples through the network.""" activation, difference_x = self.forward(x) update = self.backward(difference_x, influences, activation) # If batch size is 1 we can leave out the call to mean. if update...
python
def _propagate(self, x, influences, **kwargs): """Propagate a single batch of examples through the network.""" activation, difference_x = self.forward(x) update = self.backward(difference_x, influences, activation) # If batch size is 1 we can leave out the call to mean. if update...
[ "def", "_propagate", "(", "self", ",", "x", ",", "influences", ",", "*", "*", "kwargs", ")", ":", "activation", ",", "difference_x", "=", "self", ".", "forward", "(", "x", ")", "update", "=", "self", ".", "backward", "(", "difference_x", ",", "influenc...
Propagate a single batch of examples through the network.
[ "Propagate", "a", "single", "batch", "of", "examples", "through", "the", "network", "." ]
b7a13e646239500cc393668c01a7169c3e50b7b5
https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/base.py#L329-L339
train
61,846
stephantul/somber
somber/base.py
Base._check_input
def _check_input(self, X): """ Check the input for validity. Ensures that the input data, X, is a 2-dimensional matrix, and that the second dimension of this matrix has the same dimensionality as the weight matrix. """ if np.ndim(X) == 1: X = np.resha...
python
def _check_input(self, X): """ Check the input for validity. Ensures that the input data, X, is a 2-dimensional matrix, and that the second dimension of this matrix has the same dimensionality as the weight matrix. """ if np.ndim(X) == 1: X = np.resha...
[ "def", "_check_input", "(", "self", ",", "X", ")", ":", "if", "np", ".", "ndim", "(", "X", ")", "==", "1", ":", "X", "=", "np", ".", "reshape", "(", "X", ",", "(", "1", ",", "-", "1", ")", ")", "if", "X", ".", "ndim", "!=", "2", ":", "r...
Check the input for validity. Ensures that the input data, X, is a 2-dimensional matrix, and that the second dimension of this matrix has the same dimensionality as the weight matrix.
[ "Check", "the", "input", "for", "validity", "." ]
b7a13e646239500cc393668c01a7169c3e50b7b5
https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/base.py#L413-L432
train
61,847
stephantul/somber
somber/base.py
Base.transform
def transform(self, X, batch_size=100, show_progressbar=False): """ Transform input to a distance matrix by measuring the L2 distance. Parameters ---------- X : numpy array. The input data. batch_size : int, optional, default 100 The batch size to...
python
def transform(self, X, batch_size=100, show_progressbar=False): """ Transform input to a distance matrix by measuring the L2 distance. Parameters ---------- X : numpy array. The input data. batch_size : int, optional, default 100 The batch size to...
[ "def", "transform", "(", "self", ",", "X", ",", "batch_size", "=", "100", ",", "show_progressbar", "=", "False", ")", ":", "X", "=", "self", ".", "_check_input", "(", "X", ")", "batched", "=", "self", ".", "_create_batches", "(", "X", ",", "batch_size"...
Transform input to a distance matrix by measuring the L2 distance. Parameters ---------- X : numpy array. The input data. batch_size : int, optional, default 100 The batch size to use in transformation. This may affect the transformation in stateful, ...
[ "Transform", "input", "to", "a", "distance", "matrix", "by", "measuring", "the", "L2", "distance", "." ]
b7a13e646239500cc393668c01a7169c3e50b7b5
https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/base.py#L434-L469
train
61,848
stephantul/somber
somber/base.py
Base.predict
def predict(self, X, batch_size=1, show_progressbar=False): """ Predict the BMU for each input data. Parameters ---------- X : numpy array. The input data. batch_size : int, optional, default 100 The batch size to use in prediction. This may affec...
python
def predict(self, X, batch_size=1, show_progressbar=False): """ Predict the BMU for each input data. Parameters ---------- X : numpy array. The input data. batch_size : int, optional, default 100 The batch size to use in prediction. This may affec...
[ "def", "predict", "(", "self", ",", "X", ",", "batch_size", "=", "1", ",", "show_progressbar", "=", "False", ")", ":", "dist", "=", "self", ".", "transform", "(", "X", ",", "batch_size", ",", "show_progressbar", ")", "res", "=", "dist", ".", "__getattr...
Predict the BMU for each input data. Parameters ---------- X : numpy array. The input data. batch_size : int, optional, default 100 The batch size to use in prediction. This may affect prediction in stateful, i.e. sequential SOMs. show_progres...
[ "Predict", "the", "BMU", "for", "each", "input", "data", "." ]
b7a13e646239500cc393668c01a7169c3e50b7b5
https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/base.py#L471-L494
train
61,849
stephantul/somber
somber/base.py
Base.quantization_error
def quantization_error(self, X, batch_size=1): """ Calculate the quantization error. Find the the minimum euclidean distance between the units and some input. Parameters ---------- X : numpy array. The input data. batch_size : int ...
python
def quantization_error(self, X, batch_size=1): """ Calculate the quantization error. Find the the minimum euclidean distance between the units and some input. Parameters ---------- X : numpy array. The input data. batch_size : int ...
[ "def", "quantization_error", "(", "self", ",", "X", ",", "batch_size", "=", "1", ")", ":", "dist", "=", "self", ".", "transform", "(", "X", ",", "batch_size", ")", "res", "=", "dist", ".", "__getattribute__", "(", "self", ".", "valfunc", ")", "(", "1...
Calculate the quantization error. Find the the minimum euclidean distance between the units and some input. Parameters ---------- X : numpy array. The input data. batch_size : int The batch size to use for processing. Returns ---...
[ "Calculate", "the", "quantization", "error", "." ]
b7a13e646239500cc393668c01a7169c3e50b7b5
https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/base.py#L496-L519
train
61,850
stephantul/somber
somber/base.py
Base.load
def load(cls, path): """ Load a SOM from a JSON file saved with this package. Parameters ---------- path : str The path to the JSON file. Returns ------- s : cls A som of the specified class. """ data = json.load(...
python
def load(cls, path): """ Load a SOM from a JSON file saved with this package. Parameters ---------- path : str The path to the JSON file. Returns ------- s : cls A som of the specified class. """ data = json.load(...
[ "def", "load", "(", "cls", ",", "path", ")", ":", "data", "=", "json", ".", "load", "(", "open", "(", "path", ")", ")", "weights", "=", "data", "[", "'weights'", "]", "weights", "=", "np", ".", "asarray", "(", "weights", ",", "dtype", "=", "np", ...
Load a SOM from a JSON file saved with this package. Parameters ---------- path : str The path to the JSON file. Returns ------- s : cls A som of the specified class.
[ "Load", "a", "SOM", "from", "a", "JSON", "file", "saved", "with", "this", "package", "." ]
b7a13e646239500cc393668c01a7169c3e50b7b5
https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/base.py#L593-L625
train
61,851
stephantul/somber
somber/base.py
Base.save
def save(self, path): """Save a SOM to a JSON file.""" to_save = {} for x in self.param_names: attr = self.__getattribute__(x) if type(attr) == np.ndarray: attr = [[float(x) for x in row] for row in attr] elif isinstance(attr, types.FunctionTyp...
python
def save(self, path): """Save a SOM to a JSON file.""" to_save = {} for x in self.param_names: attr = self.__getattribute__(x) if type(attr) == np.ndarray: attr = [[float(x) for x in row] for row in attr] elif isinstance(attr, types.FunctionTyp...
[ "def", "save", "(", "self", ",", "path", ")", ":", "to_save", "=", "{", "}", "for", "x", "in", "self", ".", "param_names", ":", "attr", "=", "self", ".", "__getattribute__", "(", "x", ")", "if", "type", "(", "attr", ")", "==", "np", ".", "ndarray...
Save a SOM to a JSON file.
[ "Save", "a", "SOM", "to", "a", "JSON", "file", "." ]
b7a13e646239500cc393668c01a7169c3e50b7b5
https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/base.py#L627-L638
train
61,852
cloudnull/turbolift
turbolift/authentication/utils.py
get_authversion
def get_authversion(job_args): """Get or infer the auth version. Based on the information found in the *AUTH_VERSION_MAP* the authentication version will be set to a correct value as determined by the **os_auth_version** parameter as found in the `job_args`. :param job_args: ``dict`` :returns:...
python
def get_authversion(job_args): """Get or infer the auth version. Based on the information found in the *AUTH_VERSION_MAP* the authentication version will be set to a correct value as determined by the **os_auth_version** parameter as found in the `job_args`. :param job_args: ``dict`` :returns:...
[ "def", "get_authversion", "(", "job_args", ")", ":", "_version", "=", "job_args", ".", "get", "(", "'os_auth_version'", ")", "for", "version", ",", "variants", "in", "AUTH_VERSION_MAP", ".", "items", "(", ")", ":", "if", "_version", "in", "variants", ":", ...
Get or infer the auth version. Based on the information found in the *AUTH_VERSION_MAP* the authentication version will be set to a correct value as determined by the **os_auth_version** parameter as found in the `job_args`. :param job_args: ``dict`` :returns: ``str``
[ "Get", "or", "infer", "the", "auth", "version", "." ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/authentication/utils.py#L53-L73
train
61,853
cloudnull/turbolift
turbolift/authentication/utils.py
V1Authentication.get_headers
def get_headers(self): """Setup headers for authentication request.""" try: return { 'X-Auth-User': self.job_args['os_user'], 'X-Auth-Key': self.job_args['os_apikey'] } except KeyError as exp: raise exceptions.AuthenticationPro...
python
def get_headers(self): """Setup headers for authentication request.""" try: return { 'X-Auth-User': self.job_args['os_user'], 'X-Auth-Key': self.job_args['os_apikey'] } except KeyError as exp: raise exceptions.AuthenticationPro...
[ "def", "get_headers", "(", "self", ")", ":", "try", ":", "return", "{", "'X-Auth-User'", ":", "self", ".", "job_args", "[", "'os_user'", "]", ",", "'X-Auth-Key'", ":", "self", ".", "job_args", "[", "'os_apikey'", "]", "}", "except", "KeyError", "as", "ex...
Setup headers for authentication request.
[ "Setup", "headers", "for", "authentication", "request", "." ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/authentication/utils.py#L104-L116
train
61,854
cloudnull/turbolift
turbolift/authentication/utils.py
OSAuthentication.auth_request
def auth_request(self, url, headers, body): """Perform auth request for token.""" return self.req.post(url, headers, body=body)
python
def auth_request(self, url, headers, body): """Perform auth request for token.""" return self.req.post(url, headers, body=body)
[ "def", "auth_request", "(", "self", ",", "url", ",", "headers", ",", "body", ")", ":", "return", "self", ".", "req", ".", "post", "(", "url", ",", "headers", ",", "body", "=", "body", ")" ]
Perform auth request for token.
[ "Perform", "auth", "request", "for", "token", "." ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/authentication/utils.py#L150-L153
train
61,855
cloudnull/turbolift
turbolift/authentication/utils.py
OSAuthentication.parse_reqtype
def parse_reqtype(self): """Return the authentication body.""" if self.job_args['os_auth_version'] == 'v1.0': return dict() else: setup = { 'username': self.job_args.get('os_user') } # Check if any prefix items are set. A prefix s...
python
def parse_reqtype(self): """Return the authentication body.""" if self.job_args['os_auth_version'] == 'v1.0': return dict() else: setup = { 'username': self.job_args.get('os_user') } # Check if any prefix items are set. A prefix s...
[ "def", "parse_reqtype", "(", "self", ")", ":", "if", "self", ".", "job_args", "[", "'os_auth_version'", "]", "==", "'v1.0'", ":", "return", "dict", "(", ")", "else", ":", "setup", "=", "{", "'username'", ":", "self", ".", "job_args", ".", "get", "(", ...
Return the authentication body.
[ "Return", "the", "authentication", "body", "." ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/authentication/utils.py#L155-L224
train
61,856
cloudnull/turbolift
turbolift/executable.py
execute
def execute(): """This is the run section of the application Turbolift.""" if len(sys.argv) <= 1: raise SystemExit( 'No Arguments provided. use [--help] for more information.' ) # Capture user arguments _args = arguments.ArgumentParserator( arguments_dict=turbolift....
python
def execute(): """This is the run section of the application Turbolift.""" if len(sys.argv) <= 1: raise SystemExit( 'No Arguments provided. use [--help] for more information.' ) # Capture user arguments _args = arguments.ArgumentParserator( arguments_dict=turbolift....
[ "def", "execute", "(", ")", ":", "if", "len", "(", "sys", ".", "argv", ")", "<=", "1", ":", "raise", "SystemExit", "(", "'No Arguments provided. use [--help] for more information.'", ")", "# Capture user arguments", "_args", "=", "arguments", ".", "ArgumentParserato...
This is the run section of the application Turbolift.
[ "This", "is", "the", "run", "section", "of", "the", "application", "Turbolift", "." ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/executable.py#L21-L59
train
61,857
Clivern/PyLogging
pylogging/storage.py
TextStorage.write
def write(self, log_file, msg): """ Append message to .log file """ try: with open(log_file, 'a') as LogFile: LogFile.write(msg + os.linesep) except: raise Exception('Error Configuring PyLogger.TextStorage Class.') return os.path.isfile(log_file)
python
def write(self, log_file, msg): """ Append message to .log file """ try: with open(log_file, 'a') as LogFile: LogFile.write(msg + os.linesep) except: raise Exception('Error Configuring PyLogger.TextStorage Class.') return os.path.isfile(log_file)
[ "def", "write", "(", "self", ",", "log_file", ",", "msg", ")", ":", "try", ":", "with", "open", "(", "log_file", ",", "'a'", ")", "as", "LogFile", ":", "LogFile", ".", "write", "(", "msg", "+", "os", ".", "linesep", ")", "except", ":", "raise", "...
Append message to .log file
[ "Append", "message", "to", ".", "log", "file" ]
46a1442ec63796302ec7fe3d49bd06a0f7a2fe70
https://github.com/Clivern/PyLogging/blob/46a1442ec63796302ec7fe3d49bd06a0f7a2fe70/pylogging/storage.py#L12-L20
train
61,858
Clivern/PyLogging
pylogging/storage.py
TextStorage.read
def read(self, log_file): """ Read messages from .log file """ if os.path.isdir(os.path.dirname(log_file)) and os.path.isfile(log_file): with open(log_file, 'r') as LogFile: data = LogFile.readlines() data = "".join(line for line in data) else: ...
python
def read(self, log_file): """ Read messages from .log file """ if os.path.isdir(os.path.dirname(log_file)) and os.path.isfile(log_file): with open(log_file, 'r') as LogFile: data = LogFile.readlines() data = "".join(line for line in data) else: ...
[ "def", "read", "(", "self", ",", "log_file", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "os", ".", "path", ".", "dirname", "(", "log_file", ")", ")", "and", "os", ".", "path", ".", "isfile", "(", "log_file", ")", ":", "with", "open", ...
Read messages from .log file
[ "Read", "messages", "from", ".", "log", "file" ]
46a1442ec63796302ec7fe3d49bd06a0f7a2fe70
https://github.com/Clivern/PyLogging/blob/46a1442ec63796302ec7fe3d49bd06a0f7a2fe70/pylogging/storage.py#L22-L30
train
61,859
stephantul/somber
somber/components/utilities.py
Scaler.fit
def fit(self, X): """ Fit the scaler based on some data. Takes the columnwise mean and standard deviation of the entire input array. If the array has more than 2 dimensions, it is flattened. Parameters ---------- X : numpy array Returns ...
python
def fit(self, X): """ Fit the scaler based on some data. Takes the columnwise mean and standard deviation of the entire input array. If the array has more than 2 dimensions, it is flattened. Parameters ---------- X : numpy array Returns ...
[ "def", "fit", "(", "self", ",", "X", ")", ":", "if", "X", ".", "ndim", ">", "2", ":", "X", "=", "X", ".", "reshape", "(", "(", "np", ".", "prod", "(", "X", ".", "shape", "[", ":", "-", "1", "]", ")", ",", "X", ".", "shape", "[", "-", ...
Fit the scaler based on some data. Takes the columnwise mean and standard deviation of the entire input array. If the array has more than 2 dimensions, it is flattened. Parameters ---------- X : numpy array Returns ------- scaled : numpy array ...
[ "Fit", "the", "scaler", "based", "on", "some", "data", "." ]
b7a13e646239500cc393668c01a7169c3e50b7b5
https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/components/utilities.py#L31-L54
train
61,860
stephantul/somber
somber/components/utilities.py
Scaler.transform
def transform(self, X): """Transform your data to zero mean unit variance.""" if not self.is_fit: raise ValueError("The scaler has not been fit yet.") return (X-self.mean) / (self.std + 10e-7)
python
def transform(self, X): """Transform your data to zero mean unit variance.""" if not self.is_fit: raise ValueError("The scaler has not been fit yet.") return (X-self.mean) / (self.std + 10e-7)
[ "def", "transform", "(", "self", ",", "X", ")", ":", "if", "not", "self", ".", "is_fit", ":", "raise", "ValueError", "(", "\"The scaler has not been fit yet.\"", ")", "return", "(", "X", "-", "self", ".", "mean", ")", "/", "(", "self", ".", "std", "+",...
Transform your data to zero mean unit variance.
[ "Transform", "your", "data", "to", "zero", "mean", "unit", "variance", "." ]
b7a13e646239500cc393668c01a7169c3e50b7b5
https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/components/utilities.py#L56-L60
train
61,861
cloudnull/turbolift
turbolift/clouderator/utils.py
stupid_hack
def stupid_hack(most=10, wait=None): """Return a random time between 1 - 10 Seconds.""" # Stupid Hack For Public Cloud so it is not overwhelmed with API requests. if wait is not None: time.sleep(wait) else: time.sleep(random.randrange(1, most))
python
def stupid_hack(most=10, wait=None): """Return a random time between 1 - 10 Seconds.""" # Stupid Hack For Public Cloud so it is not overwhelmed with API requests. if wait is not None: time.sleep(wait) else: time.sleep(random.randrange(1, most))
[ "def", "stupid_hack", "(", "most", "=", "10", ",", "wait", "=", "None", ")", ":", "# Stupid Hack For Public Cloud so it is not overwhelmed with API requests.", "if", "wait", "is", "not", "None", ":", "time", ".", "sleep", "(", "wait", ")", "else", ":", "time", ...
Return a random time between 1 - 10 Seconds.
[ "Return", "a", "random", "time", "between", "1", "-", "10", "Seconds", "." ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/clouderator/utils.py#L51-L58
train
61,862
cloudnull/turbolift
turbolift/clouderator/utils.py
time_stamp
def time_stamp(): """Setup time functions :returns: ``tuple`` """ # Time constants fmt = '%Y-%m-%dT%H:%M:%S.%f' date = datetime.datetime date_delta = datetime.timedelta now = datetime.datetime.utcnow() return fmt, date, date_delta, now
python
def time_stamp(): """Setup time functions :returns: ``tuple`` """ # Time constants fmt = '%Y-%m-%dT%H:%M:%S.%f' date = datetime.datetime date_delta = datetime.timedelta now = datetime.datetime.utcnow() return fmt, date, date_delta, now
[ "def", "time_stamp", "(", ")", ":", "# Time constants", "fmt", "=", "'%Y-%m-%dT%H:%M:%S.%f'", "date", "=", "datetime", ".", "datetime", "date_delta", "=", "datetime", ".", "timedelta", "now", "=", "datetime", ".", "datetime", ".", "utcnow", "(", ")", "return",...
Setup time functions :returns: ``tuple``
[ "Setup", "time", "functions" ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/clouderator/utils.py#L61-L73
train
61,863
cloudnull/turbolift
turbolift/clouderator/utils.py
unique_list_dicts
def unique_list_dicts(dlist, key): """Return a list of dictionaries which are sorted for only unique entries. :param dlist: :param key: :return list: """ return list(dict((val[key], val) for val in dlist).values())
python
def unique_list_dicts(dlist, key): """Return a list of dictionaries which are sorted for only unique entries. :param dlist: :param key: :return list: """ return list(dict((val[key], val) for val in dlist).values())
[ "def", "unique_list_dicts", "(", "dlist", ",", "key", ")", ":", "return", "list", "(", "dict", "(", "(", "val", "[", "key", "]", ",", "val", ")", "for", "val", "in", "dlist", ")", ".", "values", "(", ")", ")" ]
Return a list of dictionaries which are sorted for only unique entries. :param dlist: :param key: :return list:
[ "Return", "a", "list", "of", "dictionaries", "which", "are", "sorted", "for", "only", "unique", "entries", "." ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/clouderator/utils.py#L76-L84
train
61,864
cloudnull/turbolift
turbolift/clouderator/utils.py
quoter
def quoter(obj): """Return a Quoted URL. The quote function will return a URL encoded string. If there is an exception in the job which results in a "KeyError" the original string will be returned as it will be assumed to already be URL encoded. :param obj: ``basestring`` :return: ``str``...
python
def quoter(obj): """Return a Quoted URL. The quote function will return a URL encoded string. If there is an exception in the job which results in a "KeyError" the original string will be returned as it will be assumed to already be URL encoded. :param obj: ``basestring`` :return: ``str``...
[ "def", "quoter", "(", "obj", ")", ":", "try", ":", "try", ":", "return", "urllib", ".", "quote", "(", "obj", ")", "except", "AttributeError", ":", "return", "urllib", ".", "parse", ".", "quote", "(", "obj", ")", "except", "KeyError", ":", "return", "...
Return a Quoted URL. The quote function will return a URL encoded string. If there is an exception in the job which results in a "KeyError" the original string will be returned as it will be assumed to already be URL encoded. :param obj: ``basestring`` :return: ``str``
[ "Return", "a", "Quoted", "URL", "." ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/clouderator/utils.py#L136-L154
train
61,865
cloudnull/turbolift
turbolift/methods/clone.py
CloneRunMethod.start
def start(self): """Clone objects from one container to another. This method was built to clone a container between data-centers while using the same credentials. The method assumes that an authentication token will be valid within the two data centers. """ LOG.info('Cl...
python
def start(self): """Clone objects from one container to another. This method was built to clone a container between data-centers while using the same credentials. The method assumes that an authentication token will be valid within the two data centers. """ LOG.info('Cl...
[ "def", "start", "(", "self", ")", ":", "LOG", ".", "info", "(", "'Clone warm up...'", ")", "# Create the target args", "self", ".", "_target_auth", "(", ")", "last_list_obj", "=", "None", "while", "True", ":", "self", ".", "indicator_options", "[", "'msg'", ...
Clone objects from one container to another. This method was built to clone a container between data-centers while using the same credentials. The method assumes that an authentication token will be valid within the two data centers.
[ "Clone", "objects", "from", "one", "container", "to", "another", "." ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/methods/clone.py#L162-L195
train
61,866
cloudnull/turbolift
turbolift/authentication/auth.py
authenticate
def authenticate(job_args): """Authentication For Openstack API. Pulls the full Openstack Service Catalog Credentials are the Users API Username and Key/Password. Set a DC Endpoint and Authentication URL for the OpenStack environment """ # Load any authentication plugins as needed job_arg...
python
def authenticate(job_args): """Authentication For Openstack API. Pulls the full Openstack Service Catalog Credentials are the Users API Username and Key/Password. Set a DC Endpoint and Authentication URL for the OpenStack environment """ # Load any authentication plugins as needed job_arg...
[ "def", "authenticate", "(", "job_args", ")", ":", "# Load any authentication plugins as needed", "job_args", "=", "utils", ".", "check_auth_plugin", "(", "job_args", ")", "# Set the auth version", "auth_version", "=", "utils", ".", "get_authversion", "(", "job_args", "=...
Authentication For Openstack API. Pulls the full Openstack Service Catalog Credentials are the Users API Username and Key/Password. Set a DC Endpoint and Authentication URL for the OpenStack environment
[ "Authentication", "For", "Openstack", "API", "." ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/authentication/auth.py#L14-L74
train
61,867
Clivern/PyLogging
pylogging/pylogging.py
PyLogging.getConfig
def getConfig(self, key): """ Get a Config Value """ if hasattr(self, key): return getattr(self, key) else: return False
python
def getConfig(self, key): """ Get a Config Value """ if hasattr(self, key): return getattr(self, key) else: return False
[ "def", "getConfig", "(", "self", ",", "key", ")", ":", "if", "hasattr", "(", "self", ",", "key", ")", ":", "return", "getattr", "(", "self", ",", "key", ")", "else", ":", "return", "False" ]
Get a Config Value
[ "Get", "a", "Config", "Value" ]
46a1442ec63796302ec7fe3d49bd06a0f7a2fe70
https://github.com/Clivern/PyLogging/blob/46a1442ec63796302ec7fe3d49bd06a0f7a2fe70/pylogging/pylogging.py#L91-L96
train
61,868
Clivern/PyLogging
pylogging/pylogging.py
PyLogging.addFilter
def addFilter(self, filter): """ Register Custom Filter """ self.FILTERS.append(filter) return "FILTER#{}".format(len(self.FILTERS) - 1)
python
def addFilter(self, filter): """ Register Custom Filter """ self.FILTERS.append(filter) return "FILTER#{}".format(len(self.FILTERS) - 1)
[ "def", "addFilter", "(", "self", ",", "filter", ")", ":", "self", ".", "FILTERS", ".", "append", "(", "filter", ")", "return", "\"FILTER#{}\"", ".", "format", "(", "len", "(", "self", ".", "FILTERS", ")", "-", "1", ")" ]
Register Custom Filter
[ "Register", "Custom", "Filter" ]
46a1442ec63796302ec7fe3d49bd06a0f7a2fe70
https://github.com/Clivern/PyLogging/blob/46a1442ec63796302ec7fe3d49bd06a0f7a2fe70/pylogging/pylogging.py#L103-L106
train
61,869
Clivern/PyLogging
pylogging/pylogging.py
PyLogging.addAction
def addAction(self, action): """ Register Custom Action """ self.ACTIONS.append(action) return "ACTION#{}".format(len(self.ACTIONS) - 1)
python
def addAction(self, action): """ Register Custom Action """ self.ACTIONS.append(action) return "ACTION#{}".format(len(self.ACTIONS) - 1)
[ "def", "addAction", "(", "self", ",", "action", ")", ":", "self", ".", "ACTIONS", ".", "append", "(", "action", ")", "return", "\"ACTION#{}\"", ".", "format", "(", "len", "(", "self", ".", "ACTIONS", ")", "-", "1", ")" ]
Register Custom Action
[ "Register", "Custom", "Action" ]
46a1442ec63796302ec7fe3d49bd06a0f7a2fe70
https://github.com/Clivern/PyLogging/blob/46a1442ec63796302ec7fe3d49bd06a0f7a2fe70/pylogging/pylogging.py#L108-L111
train
61,870
Clivern/PyLogging
pylogging/pylogging.py
PyLogging.removeFilter
def removeFilter(self, filter): """ Remove Registered Filter """ filter = filter.split('#') del self.FILTERS[int(filter[1])] return True
python
def removeFilter(self, filter): """ Remove Registered Filter """ filter = filter.split('#') del self.FILTERS[int(filter[1])] return True
[ "def", "removeFilter", "(", "self", ",", "filter", ")", ":", "filter", "=", "filter", ".", "split", "(", "'#'", ")", "del", "self", ".", "FILTERS", "[", "int", "(", "filter", "[", "1", "]", ")", "]", "return", "True" ]
Remove Registered Filter
[ "Remove", "Registered", "Filter" ]
46a1442ec63796302ec7fe3d49bd06a0f7a2fe70
https://github.com/Clivern/PyLogging/blob/46a1442ec63796302ec7fe3d49bd06a0f7a2fe70/pylogging/pylogging.py#L113-L117
train
61,871
Clivern/PyLogging
pylogging/pylogging.py
PyLogging.removeAction
def removeAction(self, action): """ Remove Registered Action """ action = action.split('#') del self.ACTIONS[int(action[1])] return True
python
def removeAction(self, action): """ Remove Registered Action """ action = action.split('#') del self.ACTIONS[int(action[1])] return True
[ "def", "removeAction", "(", "self", ",", "action", ")", ":", "action", "=", "action", ".", "split", "(", "'#'", ")", "del", "self", ".", "ACTIONS", "[", "int", "(", "action", "[", "1", "]", ")", "]", "return", "True" ]
Remove Registered Action
[ "Remove", "Registered", "Action" ]
46a1442ec63796302ec7fe3d49bd06a0f7a2fe70
https://github.com/Clivern/PyLogging/blob/46a1442ec63796302ec7fe3d49bd06a0f7a2fe70/pylogging/pylogging.py#L119-L123
train
61,872
Clivern/PyLogging
pylogging/pylogging.py
PyLogging.info
def info(self, msg): """ Log Info Messages """ self._execActions('info', msg) msg = self._execFilters('info', msg) self._processMsg('info', msg) self._sendMsg('info', msg)
python
def info(self, msg): """ Log Info Messages """ self._execActions('info', msg) msg = self._execFilters('info', msg) self._processMsg('info', msg) self._sendMsg('info', msg)
[ "def", "info", "(", "self", ",", "msg", ")", ":", "self", ".", "_execActions", "(", "'info'", ",", "msg", ")", "msg", "=", "self", ".", "_execFilters", "(", "'info'", ",", "msg", ")", "self", ".", "_processMsg", "(", "'info'", ",", "msg", ")", "sel...
Log Info Messages
[ "Log", "Info", "Messages" ]
46a1442ec63796302ec7fe3d49bd06a0f7a2fe70
https://github.com/Clivern/PyLogging/blob/46a1442ec63796302ec7fe3d49bd06a0f7a2fe70/pylogging/pylogging.py#L125-L130
train
61,873
Clivern/PyLogging
pylogging/pylogging.py
PyLogging.warning
def warning(self, msg): """ Log Warning Messages """ self._execActions('warning', msg) msg = self._execFilters('warning', msg) self._processMsg('warning', msg) self._sendMsg('warning', msg)
python
def warning(self, msg): """ Log Warning Messages """ self._execActions('warning', msg) msg = self._execFilters('warning', msg) self._processMsg('warning', msg) self._sendMsg('warning', msg)
[ "def", "warning", "(", "self", ",", "msg", ")", ":", "self", ".", "_execActions", "(", "'warning'", ",", "msg", ")", "msg", "=", "self", ".", "_execFilters", "(", "'warning'", ",", "msg", ")", "self", ".", "_processMsg", "(", "'warning'", ",", "msg", ...
Log Warning Messages
[ "Log", "Warning", "Messages" ]
46a1442ec63796302ec7fe3d49bd06a0f7a2fe70
https://github.com/Clivern/PyLogging/blob/46a1442ec63796302ec7fe3d49bd06a0f7a2fe70/pylogging/pylogging.py#L132-L137
train
61,874
Clivern/PyLogging
pylogging/pylogging.py
PyLogging.error
def error(self, msg): """ Log Error Messages """ self._execActions('error', msg) msg = self._execFilters('error', msg) self._processMsg('error', msg) self._sendMsg('error', msg)
python
def error(self, msg): """ Log Error Messages """ self._execActions('error', msg) msg = self._execFilters('error', msg) self._processMsg('error', msg) self._sendMsg('error', msg)
[ "def", "error", "(", "self", ",", "msg", ")", ":", "self", ".", "_execActions", "(", "'error'", ",", "msg", ")", "msg", "=", "self", ".", "_execFilters", "(", "'error'", ",", "msg", ")", "self", ".", "_processMsg", "(", "'error'", ",", "msg", ")", ...
Log Error Messages
[ "Log", "Error", "Messages" ]
46a1442ec63796302ec7fe3d49bd06a0f7a2fe70
https://github.com/Clivern/PyLogging/blob/46a1442ec63796302ec7fe3d49bd06a0f7a2fe70/pylogging/pylogging.py#L139-L144
train
61,875
Clivern/PyLogging
pylogging/pylogging.py
PyLogging.critical
def critical(self, msg): """ Log Critical Messages """ self._execActions('critical', msg) msg = self._execFilters('critical', msg) self._processMsg('critical', msg) self._sendMsg('critical', msg)
python
def critical(self, msg): """ Log Critical Messages """ self._execActions('critical', msg) msg = self._execFilters('critical', msg) self._processMsg('critical', msg) self._sendMsg('critical', msg)
[ "def", "critical", "(", "self", ",", "msg", ")", ":", "self", ".", "_execActions", "(", "'critical'", ",", "msg", ")", "msg", "=", "self", ".", "_execFilters", "(", "'critical'", ",", "msg", ")", "self", ".", "_processMsg", "(", "'critical'", ",", "msg...
Log Critical Messages
[ "Log", "Critical", "Messages" ]
46a1442ec63796302ec7fe3d49bd06a0f7a2fe70
https://github.com/Clivern/PyLogging/blob/46a1442ec63796302ec7fe3d49bd06a0f7a2fe70/pylogging/pylogging.py#L146-L151
train
61,876
Clivern/PyLogging
pylogging/pylogging.py
PyLogging.log
def log(self, msg): """ Log Normal Messages """ self._execActions('log', msg) msg = self._execFilters('log', msg) self._processMsg('log', msg) self._sendMsg('log', msg)
python
def log(self, msg): """ Log Normal Messages """ self._execActions('log', msg) msg = self._execFilters('log', msg) self._processMsg('log', msg) self._sendMsg('log', msg)
[ "def", "log", "(", "self", ",", "msg", ")", ":", "self", ".", "_execActions", "(", "'log'", ",", "msg", ")", "msg", "=", "self", ".", "_execFilters", "(", "'log'", ",", "msg", ")", "self", ".", "_processMsg", "(", "'log'", ",", "msg", ")", "self", ...
Log Normal Messages
[ "Log", "Normal", "Messages" ]
46a1442ec63796302ec7fe3d49bd06a0f7a2fe70
https://github.com/Clivern/PyLogging/blob/46a1442ec63796302ec7fe3d49bd06a0f7a2fe70/pylogging/pylogging.py#L153-L158
train
61,877
Clivern/PyLogging
pylogging/pylogging.py
PyLogging._processMsg
def _processMsg(self, type, msg): """ Process Debug Messages """ now = datetime.datetime.now() # Check If Path not provided if self.LOG_FILE_PATH == '': self.LOG_FILE_PATH = os.path.dirname(os.path.abspath(__file__)) + '/' # Build absolute Path log_file = se...
python
def _processMsg(self, type, msg): """ Process Debug Messages """ now = datetime.datetime.now() # Check If Path not provided if self.LOG_FILE_PATH == '': self.LOG_FILE_PATH = os.path.dirname(os.path.abspath(__file__)) + '/' # Build absolute Path log_file = se...
[ "def", "_processMsg", "(", "self", ",", "type", ",", "msg", ")", ":", "now", "=", "datetime", ".", "datetime", ".", "now", "(", ")", "# Check If Path not provided", "if", "self", ".", "LOG_FILE_PATH", "==", "''", ":", "self", ".", "LOG_FILE_PATH", "=", "...
Process Debug Messages
[ "Process", "Debug", "Messages" ]
46a1442ec63796302ec7fe3d49bd06a0f7a2fe70
https://github.com/Clivern/PyLogging/blob/46a1442ec63796302ec7fe3d49bd06a0f7a2fe70/pylogging/pylogging.py#L160-L196
train
61,878
Clivern/PyLogging
pylogging/pylogging.py
PyLogging._configMailer
def _configMailer(self): """ Config Mailer Class """ self._MAILER = Mailer(self.MAILER_HOST, self.MAILER_PORT) self._MAILER.login(self.MAILER_USER, self.MAILER_PWD)
python
def _configMailer(self): """ Config Mailer Class """ self._MAILER = Mailer(self.MAILER_HOST, self.MAILER_PORT) self._MAILER.login(self.MAILER_USER, self.MAILER_PWD)
[ "def", "_configMailer", "(", "self", ")", ":", "self", ".", "_MAILER", "=", "Mailer", "(", "self", ".", "MAILER_HOST", ",", "self", ".", "MAILER_PORT", ")", "self", ".", "_MAILER", ".", "login", "(", "self", ".", "MAILER_USER", ",", "self", ".", "MAILE...
Config Mailer Class
[ "Config", "Mailer", "Class" ]
46a1442ec63796302ec7fe3d49bd06a0f7a2fe70
https://github.com/Clivern/PyLogging/blob/46a1442ec63796302ec7fe3d49bd06a0f7a2fe70/pylogging/pylogging.py#L198-L201
train
61,879
Clivern/PyLogging
pylogging/pylogging.py
PyLogging._sendMsg
def _sendMsg(self, type, msg): """ Send Alert Message To Emails """ if self.ALERT_STATUS and type in self.ALERT_TYPES: self._configMailer() self._MAILER.send(self.MAILER_FROM, self.ALERT_EMAIL, self.ALERT_SUBJECT, msg)
python
def _sendMsg(self, type, msg): """ Send Alert Message To Emails """ if self.ALERT_STATUS and type in self.ALERT_TYPES: self._configMailer() self._MAILER.send(self.MAILER_FROM, self.ALERT_EMAIL, self.ALERT_SUBJECT, msg)
[ "def", "_sendMsg", "(", "self", ",", "type", ",", "msg", ")", ":", "if", "self", ".", "ALERT_STATUS", "and", "type", "in", "self", ".", "ALERT_TYPES", ":", "self", ".", "_configMailer", "(", ")", "self", ".", "_MAILER", ".", "send", "(", "self", ".",...
Send Alert Message To Emails
[ "Send", "Alert", "Message", "To", "Emails" ]
46a1442ec63796302ec7fe3d49bd06a0f7a2fe70
https://github.com/Clivern/PyLogging/blob/46a1442ec63796302ec7fe3d49bd06a0f7a2fe70/pylogging/pylogging.py#L203-L207
train
61,880
Clivern/PyLogging
pylogging/pylogging.py
PyLogging._execFilters
def _execFilters(self, type, msg): """ Execute Registered Filters """ for filter in self.FILTERS: msg = filter(type, msg) return msg
python
def _execFilters(self, type, msg): """ Execute Registered Filters """ for filter in self.FILTERS: msg = filter(type, msg) return msg
[ "def", "_execFilters", "(", "self", ",", "type", ",", "msg", ")", ":", "for", "filter", "in", "self", ".", "FILTERS", ":", "msg", "=", "filter", "(", "type", ",", "msg", ")", "return", "msg" ]
Execute Registered Filters
[ "Execute", "Registered", "Filters" ]
46a1442ec63796302ec7fe3d49bd06a0f7a2fe70
https://github.com/Clivern/PyLogging/blob/46a1442ec63796302ec7fe3d49bd06a0f7a2fe70/pylogging/pylogging.py#L209-L213
train
61,881
Clivern/PyLogging
pylogging/pylogging.py
PyLogging._execActions
def _execActions(self, type, msg): """ Execute Registered Actions """ for action in self.ACTIONS: action(type, msg)
python
def _execActions(self, type, msg): """ Execute Registered Actions """ for action in self.ACTIONS: action(type, msg)
[ "def", "_execActions", "(", "self", ",", "type", ",", "msg", ")", ":", "for", "action", "in", "self", ".", "ACTIONS", ":", "action", "(", "type", ",", "msg", ")" ]
Execute Registered Actions
[ "Execute", "Registered", "Actions" ]
46a1442ec63796302ec7fe3d49bd06a0f7a2fe70
https://github.com/Clivern/PyLogging/blob/46a1442ec63796302ec7fe3d49bd06a0f7a2fe70/pylogging/pylogging.py#L215-L218
train
61,882
cloudnull/turbolift
turbolift/__init__.py
auth_plugins
def auth_plugins(auth_plugins=None): """Authentication plugins. Usage, Add any plugin here that will serve as a rapid means to authenticate to an OpenStack environment. Syntax is as follows: >>> __auth_plugins__ = { ... 'new_plugin_name': { ... 'os_auth_url': 'https://localhost...
python
def auth_plugins(auth_plugins=None): """Authentication plugins. Usage, Add any plugin here that will serve as a rapid means to authenticate to an OpenStack environment. Syntax is as follows: >>> __auth_plugins__ = { ... 'new_plugin_name': { ... 'os_auth_url': 'https://localhost...
[ "def", "auth_plugins", "(", "auth_plugins", "=", "None", ")", ":", "__auth_plugins__", "=", "{", "'os_rax_auth'", ":", "{", "'os_auth_url'", ":", "'https://identity.api.rackspacecloud.com/v2.0/'", "'tokens'", ",", "'os_prefix'", ":", "{", "'os_apikey'", ":", "'RAX-KSK...
Authentication plugins. Usage, Add any plugin here that will serve as a rapid means to authenticate to an OpenStack environment. Syntax is as follows: >>> __auth_plugins__ = { ... 'new_plugin_name': { ... 'os_auth_url': 'https://localhost:5000/v2.0/tokens', ... 'os_pref...
[ "Authentication", "plugins", "." ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/__init__.py#L999-L1121
train
61,883
cloudnull/turbolift
turbolift/utils.py
check_basestring
def check_basestring(item): """Return ``bol`` on string check item. :param item: Item to check if its a string :type item: ``str`` :returns: ``bol`` """ try: return isinstance(item, (basestring, unicode)) except NameError: return isinstance(item, str)
python
def check_basestring(item): """Return ``bol`` on string check item. :param item: Item to check if its a string :type item: ``str`` :returns: ``bol`` """ try: return isinstance(item, (basestring, unicode)) except NameError: return isinstance(item, str)
[ "def", "check_basestring", "(", "item", ")", ":", "try", ":", "return", "isinstance", "(", "item", ",", "(", "basestring", ",", "unicode", ")", ")", "except", "NameError", ":", "return", "isinstance", "(", "item", ",", "str", ")" ]
Return ``bol`` on string check item. :param item: Item to check if its a string :type item: ``str`` :returns: ``bol``
[ "Return", "bol", "on", "string", "check", "item", "." ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/utils.py#L12-L22
train
61,884
stephantul/somber
somber/sequential.py
SequentialMixin.predict_distance
def predict_distance(self, X, batch_size=1, show_progressbar=False): """Predict distances to some input data.""" X = self._check_input(X) X_shape = reduce(np.multiply, X.shape[:-1], 1) batched = self._create_batches(X, batch_size, shuffle_data=False) activations = [] ...
python
def predict_distance(self, X, batch_size=1, show_progressbar=False): """Predict distances to some input data.""" X = self._check_input(X) X_shape = reduce(np.multiply, X.shape[:-1], 1) batched = self._create_batches(X, batch_size, shuffle_data=False) activations = [] ...
[ "def", "predict_distance", "(", "self", ",", "X", ",", "batch_size", "=", "1", ",", "show_progressbar", "=", "False", ")", ":", "X", "=", "self", ".", "_check_input", "(", "X", ")", "X_shape", "=", "reduce", "(", "np", ".", "multiply", ",", "X", ".",...
Predict distances to some input data.
[ "Predict", "distances", "to", "some", "input", "data", "." ]
b7a13e646239500cc393668c01a7169c3e50b7b5
https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/sequential.py#L48-L66
train
61,885
stephantul/somber
somber/sequential.py
SequentialMixin.generate
def generate(self, num_to_generate, starting_place): """Generate data based on some initial position.""" res = [] activ = starting_place[None, :] index = activ.__getattribute__(self.argfunc)(1) item = self.weights[index] for x in range(num_to_generate): activ ...
python
def generate(self, num_to_generate, starting_place): """Generate data based on some initial position.""" res = [] activ = starting_place[None, :] index = activ.__getattribute__(self.argfunc)(1) item = self.weights[index] for x in range(num_to_generate): activ ...
[ "def", "generate", "(", "self", ",", "num_to_generate", ",", "starting_place", ")", ":", "res", "=", "[", "]", "activ", "=", "starting_place", "[", "None", ",", ":", "]", "index", "=", "activ", ".", "__getattribute__", "(", "self", ".", "argfunc", ")", ...
Generate data based on some initial position.
[ "Generate", "data", "based", "on", "some", "initial", "position", "." ]
b7a13e646239500cc393668c01a7169c3e50b7b5
https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/sequential.py#L68-L80
train
61,886
stephantul/somber
somber/sequential.py
RecursiveMixin.forward
def forward(self, x, **kwargs): """ Perform a forward pass through the network. The forward pass in recursive som is based on a combination between the activation in the last time-step and the current time-step. Parameters ---------- x : numpy array ...
python
def forward(self, x, **kwargs): """ Perform a forward pass through the network. The forward pass in recursive som is based on a combination between the activation in the last time-step and the current time-step. Parameters ---------- x : numpy array ...
[ "def", "forward", "(", "self", ",", "x", ",", "*", "*", "kwargs", ")", ":", "prev", "=", "kwargs", "[", "'prev_activation'", "]", "# Differences is the components of the weights subtracted from", "# the weight vector.", "distance_x", ",", "diff_x", "=", "self", ".",...
Perform a forward pass through the network. The forward pass in recursive som is based on a combination between the activation in the last time-step and the current time-step. Parameters ---------- x : numpy array The input data. prev_activation : numpy arra...
[ "Perform", "a", "forward", "pass", "through", "the", "network", "." ]
b7a13e646239500cc393668c01a7169c3e50b7b5
https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/sequential.py#L167-L200
train
61,887
stephantul/somber
somber/sequential.py
RecursiveMixin.load
def load(cls, path): """ Load a recursive SOM from a JSON file. You can use this function to load weights of other SOMs. If there are no context weights, they will be set to 0. Parameters ---------- path : str The path to the JSON file. Retu...
python
def load(cls, path): """ Load a recursive SOM from a JSON file. You can use this function to load weights of other SOMs. If there are no context weights, they will be set to 0. Parameters ---------- path : str The path to the JSON file. Retu...
[ "def", "load", "(", "cls", ",", "path", ")", ":", "data", "=", "json", ".", "load", "(", "open", "(", "path", ")", ")", "weights", "=", "data", "[", "'weights'", "]", "weights", "=", "np", ".", "asarray", "(", "weights", ",", "dtype", "=", "np", ...
Load a recursive SOM from a JSON file. You can use this function to load weights of other SOMs. If there are no context weights, they will be set to 0. Parameters ---------- path : str The path to the JSON file. Returns ------- s : cls ...
[ "Load", "a", "recursive", "SOM", "from", "a", "JSON", "file", "." ]
b7a13e646239500cc393668c01a7169c3e50b7b5
https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/sequential.py#L203-L253
train
61,888
cloudnull/turbolift
turbolift/clouderator/actions.py
CloudActions._return_base_data
def _return_base_data(self, url, container, container_object=None, container_headers=None, object_headers=None): """Return headers and a parsed url. :param url: :param container: :param container_object: :param container_headers: :return: ``tupl...
python
def _return_base_data(self, url, container, container_object=None, container_headers=None, object_headers=None): """Return headers and a parsed url. :param url: :param container: :param container_object: :param container_headers: :return: ``tupl...
[ "def", "_return_base_data", "(", "self", ",", "url", ",", "container", ",", "container_object", "=", "None", ",", "container_headers", "=", "None", ",", "object_headers", "=", "None", ")", ":", "headers", "=", "self", ".", "job_args", "[", "'base_headers'", ...
Return headers and a parsed url. :param url: :param container: :param container_object: :param container_headers: :return: ``tuple``
[ "Return", "headers", "and", "a", "parsed", "url", "." ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/clouderator/actions.py#L48-L79
train
61,889
cloudnull/turbolift
turbolift/clouderator/actions.py
CloudActions._chunk_putter
def _chunk_putter(self, uri, open_file, headers=None): """Make many PUT request for a single chunked object. Objects that are processed by this method have a SHA256 hash appended to the name as well as a count for object indexing which starts at 0. To make a PUT request pass, ``url`` ...
python
def _chunk_putter(self, uri, open_file, headers=None): """Make many PUT request for a single chunked object. Objects that are processed by this method have a SHA256 hash appended to the name as well as a count for object indexing which starts at 0. To make a PUT request pass, ``url`` ...
[ "def", "_chunk_putter", "(", "self", ",", "uri", ",", "open_file", ",", "headers", "=", "None", ")", ":", "count", "=", "0", "dynamic_hash", "=", "hashlib", ".", "sha256", "(", "self", ".", "job_args", ".", "get", "(", "'container'", ")", ")", "dynamic...
Make many PUT request for a single chunked object. Objects that are processed by this method have a SHA256 hash appended to the name as well as a count for object indexing which starts at 0. To make a PUT request pass, ``url`` :param uri: ``str`` :param open_file: ``object`` ...
[ "Make", "many", "PUT", "request", "for", "a", "single", "chunked", "object", "." ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/clouderator/actions.py#L102-L153
train
61,890
cloudnull/turbolift
turbolift/clouderator/actions.py
CloudActions._putter
def _putter(self, uri, headers, local_object=None): """Place object into the container. :param uri: :param headers: :param local_object: """ if not local_object: return self.http.put(url=uri, headers=headers) with open(local_object, 'rb') as f_open...
python
def _putter(self, uri, headers, local_object=None): """Place object into the container. :param uri: :param headers: :param local_object: """ if not local_object: return self.http.put(url=uri, headers=headers) with open(local_object, 'rb') as f_open...
[ "def", "_putter", "(", "self", ",", "uri", ",", "headers", ",", "local_object", "=", "None", ")", ":", "if", "not", "local_object", ":", "return", "self", ".", "http", ".", "put", "(", "url", "=", "uri", ",", "headers", "=", "headers", ")", "with", ...
Place object into the container. :param uri: :param headers: :param local_object:
[ "Place", "object", "into", "the", "container", "." ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/clouderator/actions.py#L156-L196
train
61,891
cloudnull/turbolift
turbolift/clouderator/actions.py
CloudActions._header_poster
def _header_poster(self, uri, headers): """POST Headers on a specified object in the container. :param uri: ``str`` :param headers: ``dict`` """ resp = self.http.post(url=uri, body=None, headers=headers) self._resp_exception(resp=resp) return resp
python
def _header_poster(self, uri, headers): """POST Headers on a specified object in the container. :param uri: ``str`` :param headers: ``dict`` """ resp = self.http.post(url=uri, body=None, headers=headers) self._resp_exception(resp=resp) return resp
[ "def", "_header_poster", "(", "self", ",", "uri", ",", "headers", ")", ":", "resp", "=", "self", ".", "http", ".", "post", "(", "url", "=", "uri", ",", "body", "=", "None", ",", "headers", "=", "headers", ")", "self", ".", "_resp_exception", "(", "...
POST Headers on a specified object in the container. :param uri: ``str`` :param headers: ``dict``
[ "POST", "Headers", "on", "a", "specified", "object", "in", "the", "container", "." ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/clouderator/actions.py#L274-L283
train
61,892
cloudnull/turbolift
turbolift/clouderator/actions.py
CloudActions._obj_index
def _obj_index(self, uri, base_path, marked_path, headers, spr=False): """Return an index of objects from within the container. :param uri: :param base_path: :param marked_path: :param headers: :param spr: "single page return" Limit the returned data to one page ...
python
def _obj_index(self, uri, base_path, marked_path, headers, spr=False): """Return an index of objects from within the container. :param uri: :param base_path: :param marked_path: :param headers: :param spr: "single page return" Limit the returned data to one page ...
[ "def", "_obj_index", "(", "self", ",", "uri", ",", "base_path", ",", "marked_path", ",", "headers", ",", "spr", "=", "False", ")", ":", "object_list", "=", "list", "(", ")", "l_obj", "=", "None", "container_uri", "=", "uri", ".", "geturl", "(", ")", ...
Return an index of objects from within the container. :param uri: :param base_path: :param marked_path: :param headers: :param spr: "single page return" Limit the returned data to one page :type spr: ``bol`` :return:
[ "Return", "an", "index", "of", "objects", "from", "within", "the", "container", "." ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/clouderator/actions.py#L296-L344
train
61,893
cloudnull/turbolift
turbolift/clouderator/actions.py
CloudActions._list_getter
def _list_getter(self, uri, headers, last_obj=None, spr=False): """Get a list of all objects in a container. :param uri: :param headers: :return list: :param spr: "single page return" Limit the returned data to one page :type spr: ``bol`` """ # Quote the...
python
def _list_getter(self, uri, headers, last_obj=None, spr=False): """Get a list of all objects in a container. :param uri: :param headers: :return list: :param spr: "single page return" Limit the returned data to one page :type spr: ``bol`` """ # Quote the...
[ "def", "_list_getter", "(", "self", ",", "uri", ",", "headers", ",", "last_obj", "=", "None", ",", "spr", "=", "False", ")", ":", "# Quote the file path.", "base_path", "=", "marked_path", "=", "(", "'%s?limit=10000&format=json'", "%", "uri", ".", "path", ")...
Get a list of all objects in a container. :param uri: :param headers: :return list: :param spr: "single page return" Limit the returned data to one page :type spr: ``bol``
[ "Get", "a", "list", "of", "all", "objects", "in", "a", "container", "." ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/clouderator/actions.py#L346-L384
train
61,894
cloudnull/turbolift
turbolift/clouderator/actions.py
CloudActions._resp_exception
def _resp_exception(self, resp): """If we encounter an exception in our upload. we will look at how we can attempt to resolve the exception. :param resp: """ message = [ 'Url: [ %s ] Reason: [ %s ] Request: [ %s ] Status Code: [ %s ]. ', resp.url, ...
python
def _resp_exception(self, resp): """If we encounter an exception in our upload. we will look at how we can attempt to resolve the exception. :param resp: """ message = [ 'Url: [ %s ] Reason: [ %s ] Request: [ %s ] Status Code: [ %s ]. ', resp.url, ...
[ "def", "_resp_exception", "(", "self", ",", "resp", ")", ":", "message", "=", "[", "'Url: [ %s ] Reason: [ %s ] Request: [ %s ] Status Code: [ %s ]. '", ",", "resp", ".", "url", ",", "resp", ".", "reason", ",", "resp", ".", "request", ",", "resp", ".", "status_c...
If we encounter an exception in our upload. we will look at how we can attempt to resolve the exception. :param resp:
[ "If", "we", "encounter", "an", "exception", "in", "our", "upload", "." ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/clouderator/actions.py#L386-L449
train
61,895
cloudnull/turbolift
turbolift/clouderator/actions.py
CloudActions.list_items
def list_items(self, url, container=None, last_obj=None, spr=False): """Builds a long list of objects found in a container. NOTE: This could be millions of Objects. :param url: :param container: :param last_obj: :param spr: "single page return" Limit the returned data t...
python
def list_items(self, url, container=None, last_obj=None, spr=False): """Builds a long list of objects found in a container. NOTE: This could be millions of Objects. :param url: :param container: :param last_obj: :param spr: "single page return" Limit the returned data t...
[ "def", "list_items", "(", "self", ",", "url", ",", "container", "=", "None", ",", "last_obj", "=", "None", ",", "spr", "=", "False", ")", ":", "headers", ",", "container_uri", "=", "self", ".", "_return_base_data", "(", "url", "=", "url", ",", "contain...
Builds a long list of objects found in a container. NOTE: This could be millions of Objects. :param url: :param container: :param last_obj: :param spr: "single page return" Limit the returned data to one page :type spr: ``bol`` :return None | list:
[ "Builds", "a", "long", "list", "of", "objects", "found", "in", "a", "container", "." ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/clouderator/actions.py#L452-L481
train
61,896
cloudnull/turbolift
turbolift/clouderator/actions.py
CloudActions.update_object
def update_object(self, url, container, container_object, object_headers, container_headers): """Update an existing object in a swift container. This method will place new headers on an existing object or container. :param url: :param container: :param con...
python
def update_object(self, url, container, container_object, object_headers, container_headers): """Update an existing object in a swift container. This method will place new headers on an existing object or container. :param url: :param container: :param con...
[ "def", "update_object", "(", "self", ",", "url", ",", "container", ",", "container_object", ",", "object_headers", ",", "container_headers", ")", ":", "headers", ",", "container_uri", "=", "self", ".", "_return_base_data", "(", "url", "=", "url", ",", "contain...
Update an existing object in a swift container. This method will place new headers on an existing object or container. :param url: :param container: :param container_object:
[ "Update", "an", "existing", "object", "in", "a", "swift", "container", "." ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/clouderator/actions.py#L504-L526
train
61,897
cloudnull/turbolift
turbolift/clouderator/actions.py
CloudActions.container_cdn_command
def container_cdn_command(self, url, container, container_object, cdn_headers): """Command your CDN enabled Container. :param url: :param container: """ headers, container_uri = self._return_base_data( url=url, container=con...
python
def container_cdn_command(self, url, container, container_object, cdn_headers): """Command your CDN enabled Container. :param url: :param container: """ headers, container_uri = self._return_base_data( url=url, container=con...
[ "def", "container_cdn_command", "(", "self", ",", "url", ",", "container", ",", "container_object", ",", "cdn_headers", ")", ":", "headers", ",", "container_uri", "=", "self", ".", "_return_base_data", "(", "url", "=", "url", ",", "container", "=", "container"...
Command your CDN enabled Container. :param url: :param container:
[ "Command", "your", "CDN", "enabled", "Container", "." ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/clouderator/actions.py#L529-L553
train
61,898
cloudnull/turbolift
turbolift/clouderator/actions.py
CloudActions.put_container
def put_container(self, url, container, container_headers=None): """Create a container if it is not Found. :param url: :param container: """ headers, container_uri = self._return_base_data( url=url, container=container, container_headers=cont...
python
def put_container(self, url, container, container_headers=None): """Create a container if it is not Found. :param url: :param container: """ headers, container_uri = self._return_base_data( url=url, container=container, container_headers=cont...
[ "def", "put_container", "(", "self", ",", "url", ",", "container", ",", "container_headers", "=", "None", ")", ":", "headers", ",", "container_uri", "=", "self", ".", "_return_base_data", "(", "url", "=", "url", ",", "container", "=", "container", ",", "co...
Create a container if it is not Found. :param url: :param container:
[ "Create", "a", "container", "if", "it", "is", "not", "Found", "." ]
da33034e88959226529ce762e2895e6f6356c448
https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/clouderator/actions.py#L556-L576
train
61,899