repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
jaraco/irc
irc/client.py
Reactor.add_global_handler
def add_global_handler(self, event, handler, priority=0): """Adds a global handler function for a specific event type. Arguments: event -- Event type (a string). Check the values of numeric_events for possible event types. handler -- Callback function tak...
python
def add_global_handler(self, event, handler, priority=0): """Adds a global handler function for a specific event type. Arguments: event -- Event type (a string). Check the values of numeric_events for possible event types. handler -- Callback function tak...
[ "def", "add_global_handler", "(", "self", ",", "event", ",", "handler", ",", "priority", "=", "0", ")", ":", "handler", "=", "PrioritizedHandler", "(", "priority", ",", "handler", ")", "with", "self", ".", "mutex", ":", "event_handlers", "=", "self", ".", ...
Adds a global handler function for a specific event type. Arguments: event -- Event type (a string). Check the values of numeric_events for possible event types. handler -- Callback function taking 'connection' and 'event' parameters. ...
[ "Adds", "a", "global", "handler", "function", "for", "a", "specific", "event", "type", "." ]
571c1f448d5d5bb92bbe2605c33148bf6e698413
https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/client.py#L850-L874
train
jaraco/irc
irc/client.py
Reactor.remove_global_handler
def remove_global_handler(self, event, handler): """Removes a global handler function. Arguments: event -- Event type (a string). handler -- Callback function. Returns 1 on success, otherwise 0. """ with self.mutex: if event not in self.hand...
python
def remove_global_handler(self, event, handler): """Removes a global handler function. Arguments: event -- Event type (a string). handler -- Callback function. Returns 1 on success, otherwise 0. """ with self.mutex: if event not in self.hand...
[ "def", "remove_global_handler", "(", "self", ",", "event", ",", "handler", ")", ":", "with", "self", ".", "mutex", ":", "if", "event", "not", "in", "self", ".", "handlers", ":", "return", "0", "for", "h", "in", "self", ".", "handlers", "[", "event", ...
Removes a global handler function. Arguments: event -- Event type (a string). handler -- Callback function. Returns 1 on success, otherwise 0.
[ "Removes", "a", "global", "handler", "function", "." ]
571c1f448d5d5bb92bbe2605c33148bf6e698413
https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/client.py#L876-L892
train
jaraco/irc
irc/client.py
Reactor.dcc
def dcc(self, dcctype="chat"): """Creates and returns a DCCConnection object. Arguments: dcctype -- "chat" for DCC CHAT connections or "raw" for DCC SEND (or other DCC types). If "chat", incoming data will be split in newline-separated ...
python
def dcc(self, dcctype="chat"): """Creates and returns a DCCConnection object. Arguments: dcctype -- "chat" for DCC CHAT connections or "raw" for DCC SEND (or other DCC types). If "chat", incoming data will be split in newline-separated ...
[ "def", "dcc", "(", "self", ",", "dcctype", "=", "\"chat\"", ")", ":", "with", "self", ".", "mutex", ":", "conn", "=", "DCCConnection", "(", "self", ",", "dcctype", ")", "self", ".", "connections", ".", "append", "(", "conn", ")", "return", "conn" ]
Creates and returns a DCCConnection object. Arguments: dcctype -- "chat" for DCC CHAT connections or "raw" for DCC SEND (or other DCC types). If "chat", incoming data will be split in newline-separated chunks. If "raw", incoming ...
[ "Creates", "and", "returns", "a", "DCCConnection", "object", "." ]
571c1f448d5d5bb92bbe2605c33148bf6e698413
https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/client.py#L894-L907
train
jaraco/irc
irc/client.py
Reactor._handle_event
def _handle_event(self, connection, event): """ Handle an Event event incoming on ServerConnection connection. """ with self.mutex: matching_handlers = sorted( self.handlers.get("all_events", []) + self.handlers.get(event.type, []) ...
python
def _handle_event(self, connection, event): """ Handle an Event event incoming on ServerConnection connection. """ with self.mutex: matching_handlers = sorted( self.handlers.get("all_events", []) + self.handlers.get(event.type, []) ...
[ "def", "_handle_event", "(", "self", ",", "connection", ",", "event", ")", ":", "with", "self", ".", "mutex", ":", "matching_handlers", "=", "sorted", "(", "self", ".", "handlers", ".", "get", "(", "\"all_events\"", ",", "[", "]", ")", "+", "self", "."...
Handle an Event event incoming on ServerConnection connection.
[ "Handle", "an", "Event", "event", "incoming", "on", "ServerConnection", "connection", "." ]
571c1f448d5d5bb92bbe2605c33148bf6e698413
https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/client.py#L909-L921
train
jaraco/irc
irc/client.py
DCCConnection.disconnect
def disconnect(self, message=""): """Hang up the connection and close the object. Arguments: message -- Quit message. """ try: del self.connected except AttributeError: return try: self.socket.shutdown(socket.SHUT_WR) ...
python
def disconnect(self, message=""): """Hang up the connection and close the object. Arguments: message -- Quit message. """ try: del self.connected except AttributeError: return try: self.socket.shutdown(socket.SHUT_WR) ...
[ "def", "disconnect", "(", "self", ",", "message", "=", "\"\"", ")", ":", "try", ":", "del", "self", ".", "connected", "except", "AttributeError", ":", "return", "try", ":", "self", ".", "socket", ".", "shutdown", "(", "socket", ".", "SHUT_WR", ")", "se...
Hang up the connection and close the object. Arguments: message -- Quit message.
[ "Hang", "up", "the", "connection", "and", "close", "the", "object", "." ]
571c1f448d5d5bb92bbe2605c33148bf6e698413
https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/client.py#L1004-L1025
train
jaraco/irc
irc/client.py
DCCConnection.privmsg
def privmsg(self, text): """ Send text to DCC peer. The text will be padded with a newline if it's a DCC CHAT session. """ if self.dcctype == 'chat': text += '\n' return self.send_bytes(self.encode(text))
python
def privmsg(self, text): """ Send text to DCC peer. The text will be padded with a newline if it's a DCC CHAT session. """ if self.dcctype == 'chat': text += '\n' return self.send_bytes(self.encode(text))
[ "def", "privmsg", "(", "self", ",", "text", ")", ":", "if", "self", ".", "dcctype", "==", "'chat'", ":", "text", "+=", "'\\n'", "return", "self", ".", "send_bytes", "(", "self", ".", "encode", "(", "text", ")", ")" ]
Send text to DCC peer. The text will be padded with a newline if it's a DCC CHAT session.
[ "Send", "text", "to", "DCC", "peer", "." ]
571c1f448d5d5bb92bbe2605c33148bf6e698413
https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/client.py#L1081-L1089
train
jaraco/irc
irc/client.py
DCCConnection.send_bytes
def send_bytes(self, bytes): """ Send data to DCC peer. """ try: self.socket.send(bytes) log.debug("TO PEER: %r\n", bytes) except socket.error: self.disconnect("Connection reset by peer.")
python
def send_bytes(self, bytes): """ Send data to DCC peer. """ try: self.socket.send(bytes) log.debug("TO PEER: %r\n", bytes) except socket.error: self.disconnect("Connection reset by peer.")
[ "def", "send_bytes", "(", "self", ",", "bytes", ")", ":", "try", ":", "self", ".", "socket", ".", "send", "(", "bytes", ")", "log", ".", "debug", "(", "\"TO PEER: %r\\n\"", ",", "bytes", ")", "except", "socket", ".", "error", ":", "self", ".", "disco...
Send data to DCC peer.
[ "Send", "data", "to", "DCC", "peer", "." ]
571c1f448d5d5bb92bbe2605c33148bf6e698413
https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/client.py#L1091-L1099
train
jaraco/irc
irc/client.py
SimpleIRCClient.dcc
def dcc(self, *args, **kwargs): """Create and associate a new DCCConnection object. Use the returned object to listen for or connect to a DCC peer. """ dcc = self.reactor.dcc(*args, **kwargs) self.dcc_connections.append(dcc) return dcc
python
def dcc(self, *args, **kwargs): """Create and associate a new DCCConnection object. Use the returned object to listen for or connect to a DCC peer. """ dcc = self.reactor.dcc(*args, **kwargs) self.dcc_connections.append(dcc) return dcc
[ "def", "dcc", "(", "self", ",", "*", "args", ",", "**", "kwargs", ")", ":", "dcc", "=", "self", ".", "reactor", ".", "dcc", "(", "*", "args", ",", "**", "kwargs", ")", "self", ".", "dcc_connections", ".", "append", "(", "dcc", ")", "return", "dcc...
Create and associate a new DCCConnection object. Use the returned object to listen for or connect to a DCC peer.
[ "Create", "and", "associate", "a", "new", "DCCConnection", "object", "." ]
571c1f448d5d5bb92bbe2605c33148bf6e698413
https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/client.py#L1162-L1170
train
jaraco/irc
irc/client.py
SimpleIRCClient.dcc_connect
def dcc_connect(self, address, port, dcctype="chat"): """Connect to a DCC peer. Arguments: address -- IP address of the peer. port -- Port to connect to. Returns a DCCConnection instance. """ warnings.warn("Use self.dcc(type).connect()", DeprecationWar...
python
def dcc_connect(self, address, port, dcctype="chat"): """Connect to a DCC peer. Arguments: address -- IP address of the peer. port -- Port to connect to. Returns a DCCConnection instance. """ warnings.warn("Use self.dcc(type).connect()", DeprecationWar...
[ "def", "dcc_connect", "(", "self", ",", "address", ",", "port", ",", "dcctype", "=", "\"chat\"", ")", ":", "warnings", ".", "warn", "(", "\"Use self.dcc(type).connect()\"", ",", "DeprecationWarning", ")", "return", "self", ".", "dcc", "(", "dcctype", ")", "....
Connect to a DCC peer. Arguments: address -- IP address of the peer. port -- Port to connect to. Returns a DCCConnection instance.
[ "Connect", "to", "a", "DCC", "peer", "." ]
571c1f448d5d5bb92bbe2605c33148bf6e698413
https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/client.py#L1172-L1184
train
jaraco/irc
irc/client.py
SimpleIRCClient.dcc_listen
def dcc_listen(self, dcctype="chat"): """Listen for connections from a DCC peer. Returns a DCCConnection instance. """ warnings.warn("Use self.dcc(type).listen()", DeprecationWarning) return self.dcc(dcctype).listen()
python
def dcc_listen(self, dcctype="chat"): """Listen for connections from a DCC peer. Returns a DCCConnection instance. """ warnings.warn("Use self.dcc(type).listen()", DeprecationWarning) return self.dcc(dcctype).listen()
[ "def", "dcc_listen", "(", "self", ",", "dcctype", "=", "\"chat\"", ")", ":", "warnings", ".", "warn", "(", "\"Use self.dcc(type).listen()\"", ",", "DeprecationWarning", ")", "return", "self", ".", "dcc", "(", "dcctype", ")", ".", "listen", "(", ")" ]
Listen for connections from a DCC peer. Returns a DCCConnection instance.
[ "Listen", "for", "connections", "from", "a", "DCC", "peer", "." ]
571c1f448d5d5bb92bbe2605c33148bf6e698413
https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/client.py#L1186-L1192
train
jaraco/irc
irc/ctcp.py
dequote
def dequote(message): """ Dequote a message according to CTCP specifications. The function returns a list where each element can be either a string (normal message) or a tuple of one or two strings (tagged messages). If a tuple has only one element (ie is a singleton), that element is the tag;...
python
def dequote(message): """ Dequote a message according to CTCP specifications. The function returns a list where each element can be either a string (normal message) or a tuple of one or two strings (tagged messages). If a tuple has only one element (ie is a singleton), that element is the tag;...
[ "def", "dequote", "(", "message", ")", ":", "message", "=", "low_level_regexp", ".", "sub", "(", "_low_level_replace", ",", "message", ")", "if", "DELIMITER", "not", "in", "message", ":", "return", "[", "message", "]", "chunks", "=", "message", ".", "split...
Dequote a message according to CTCP specifications. The function returns a list where each element can be either a string (normal message) or a tuple of one or two strings (tagged messages). If a tuple has only one element (ie is a singleton), that element is the tag; otherwise the tuple has two eleme...
[ "Dequote", "a", "message", "according", "to", "CTCP", "specifications", "." ]
571c1f448d5d5bb92bbe2605c33148bf6e698413
https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/ctcp.py#L30-L54
train
sibson/vncdotool
vncdotool/api.py
connect
def connect(server, password=None, factory_class=VNCDoToolFactory, proxy=ThreadedVNCClientProxy, timeout=None): """ Connect to a VNCServer and return a Client instance that is usable in the main thread of non-Twisted Python Applications, EXPERIMENTAL. >>> from vncdotool import api >>> with api....
python
def connect(server, password=None, factory_class=VNCDoToolFactory, proxy=ThreadedVNCClientProxy, timeout=None): """ Connect to a VNCServer and return a Client instance that is usable in the main thread of non-Twisted Python Applications, EXPERIMENTAL. >>> from vncdotool import api >>> with api....
[ "def", "connect", "(", "server", ",", "password", "=", "None", ",", "factory_class", "=", "VNCDoToolFactory", ",", "proxy", "=", "ThreadedVNCClientProxy", ",", "timeout", "=", "None", ")", ":", "if", "not", "reactor", ".", "running", ":", "global", "_THREAD"...
Connect to a VNCServer and return a Client instance that is usable in the main thread of non-Twisted Python Applications, EXPERIMENTAL. >>> from vncdotool import api >>> with api.connect('host') as client >>> client.keyPress('c') You may then call any regular VNCDoToolClient method on client f...
[ "Connect", "to", "a", "VNCServer", "and", "return", "a", "Client", "instance", "that", "is", "usable", "in", "the", "main", "thread", "of", "non", "-", "Twisted", "Python", "Applications", "EXPERIMENTAL", "." ]
e133a8916efaa0f5ed421e0aa737196624635b0c
https://github.com/sibson/vncdotool/blob/e133a8916efaa0f5ed421e0aa737196624635b0c/vncdotool/api.py#L121-L156
train
sibson/vncdotool
vncdotool/client.py
VNCDoToolClient.keyPress
def keyPress(self, key): """ Send a key press to the server key: string: either [a-z] or a from KEYMAP """ log.debug('keyPress %s', key) self.keyDown(key) self.keyUp(key) return self
python
def keyPress(self, key): """ Send a key press to the server key: string: either [a-z] or a from KEYMAP """ log.debug('keyPress %s', key) self.keyDown(key) self.keyUp(key) return self
[ "def", "keyPress", "(", "self", ",", "key", ")", ":", "log", ".", "debug", "(", "'keyPress %s'", ",", "key", ")", "self", ".", "keyDown", "(", "key", ")", "self", ".", "keyUp", "(", "key", ")", "return", "self" ]
Send a key press to the server key: string: either [a-z] or a from KEYMAP
[ "Send", "a", "key", "press", "to", "the", "server" ]
e133a8916efaa0f5ed421e0aa737196624635b0c
https://github.com/sibson/vncdotool/blob/e133a8916efaa0f5ed421e0aa737196624635b0c/vncdotool/client.py#L165-L174
train
sibson/vncdotool
vncdotool/client.py
VNCDoToolClient.mousePress
def mousePress(self, button): """ Send a mouse click at the last set position button: int: [1-n] """ log.debug('mousePress %s', button) buttons = self.buttons | (1 << (button - 1)) self.mouseDown(button) self.mouseUp(button) return self
python
def mousePress(self, button): """ Send a mouse click at the last set position button: int: [1-n] """ log.debug('mousePress %s', button) buttons = self.buttons | (1 << (button - 1)) self.mouseDown(button) self.mouseUp(button) return self
[ "def", "mousePress", "(", "self", ",", "button", ")", ":", "log", ".", "debug", "(", "'mousePress %s'", ",", "button", ")", "buttons", "=", "self", ".", "buttons", "|", "(", "1", "<<", "(", "button", "-", "1", ")", ")", "self", ".", "mouseDown", "(...
Send a mouse click at the last set position button: int: [1-n]
[ "Send", "a", "mouse", "click", "at", "the", "last", "set", "position" ]
e133a8916efaa0f5ed421e0aa737196624635b0c
https://github.com/sibson/vncdotool/blob/e133a8916efaa0f5ed421e0aa737196624635b0c/vncdotool/client.py#L192-L203
train
sibson/vncdotool
vncdotool/client.py
VNCDoToolClient.mouseDown
def mouseDown(self, button): """ Send a mouse button down at the last set position button: int: [1-n] """ log.debug('mouseDown %s', button) self.buttons |= 1 << (button - 1) self.pointerEvent(self.x, self.y, buttonmask=self.buttons) return self
python
def mouseDown(self, button): """ Send a mouse button down at the last set position button: int: [1-n] """ log.debug('mouseDown %s', button) self.buttons |= 1 << (button - 1) self.pointerEvent(self.x, self.y, buttonmask=self.buttons) return self
[ "def", "mouseDown", "(", "self", ",", "button", ")", ":", "log", ".", "debug", "(", "'mouseDown %s'", ",", "button", ")", "self", ".", "buttons", "|=", "1", "<<", "(", "button", "-", "1", ")", "self", ".", "pointerEvent", "(", "self", ".", "x", ","...
Send a mouse button down at the last set position button: int: [1-n]
[ "Send", "a", "mouse", "button", "down", "at", "the", "last", "set", "position" ]
e133a8916efaa0f5ed421e0aa737196624635b0c
https://github.com/sibson/vncdotool/blob/e133a8916efaa0f5ed421e0aa737196624635b0c/vncdotool/client.py#L205-L215
train
sibson/vncdotool
vncdotool/client.py
VNCDoToolClient.captureRegion
def captureRegion(self, filename, x, y, w, h): """ Save a region of the current display to filename """ log.debug('captureRegion %s', filename) return self._capture(filename, x, y, x+w, y+h)
python
def captureRegion(self, filename, x, y, w, h): """ Save a region of the current display to filename """ log.debug('captureRegion %s', filename) return self._capture(filename, x, y, x+w, y+h)
[ "def", "captureRegion", "(", "self", ",", "filename", ",", "x", ",", "y", ",", "w", ",", "h", ")", ":", "log", ".", "debug", "(", "'captureRegion %s'", ",", "filename", ")", "return", "self", ".", "_capture", "(", "filename", ",", "x", ",", "y", ",...
Save a region of the current display to filename
[ "Save", "a", "region", "of", "the", "current", "display", "to", "filename" ]
e133a8916efaa0f5ed421e0aa737196624635b0c
https://github.com/sibson/vncdotool/blob/e133a8916efaa0f5ed421e0aa737196624635b0c/vncdotool/client.py#L235-L239
train
sibson/vncdotool
vncdotool/client.py
VNCDoToolClient.expectScreen
def expectScreen(self, filename, maxrms=0): """ Wait until the display matches a target image filename: an image file to read and compare against maxrms: the maximum root mean square between histograms of the screen and target image """ log.debug('exp...
python
def expectScreen(self, filename, maxrms=0): """ Wait until the display matches a target image filename: an image file to read and compare against maxrms: the maximum root mean square between histograms of the screen and target image """ log.debug('exp...
[ "def", "expectScreen", "(", "self", ",", "filename", ",", "maxrms", "=", "0", ")", ":", "log", ".", "debug", "(", "'expectScreen %s'", ",", "filename", ")", "return", "self", ".", "_expectFramebuffer", "(", "filename", ",", "0", ",", "0", ",", "maxrms", ...
Wait until the display matches a target image filename: an image file to read and compare against maxrms: the maximum root mean square between histograms of the screen and target image
[ "Wait", "until", "the", "display", "matches", "a", "target", "image" ]
e133a8916efaa0f5ed421e0aa737196624635b0c
https://github.com/sibson/vncdotool/blob/e133a8916efaa0f5ed421e0aa737196624635b0c/vncdotool/client.py#L261-L269
train
sibson/vncdotool
vncdotool/client.py
VNCDoToolClient.expectRegion
def expectRegion(self, filename, x, y, maxrms=0): """ Wait until a portion of the screen matches the target image The region compared is defined by the box (x, y), (x + image.width, y + image.height) """ log.debug('expectRegion %s (%s, %s)', filename, x, y) retur...
python
def expectRegion(self, filename, x, y, maxrms=0): """ Wait until a portion of the screen matches the target image The region compared is defined by the box (x, y), (x + image.width, y + image.height) """ log.debug('expectRegion %s (%s, %s)', filename, x, y) retur...
[ "def", "expectRegion", "(", "self", ",", "filename", ",", "x", ",", "y", ",", "maxrms", "=", "0", ")", ":", "log", ".", "debug", "(", "'expectRegion %s (%s, %s)'", ",", "filename", ",", "x", ",", "y", ")", "return", "self", ".", "_expectFramebuffer", "...
Wait until a portion of the screen matches the target image The region compared is defined by the box (x, y), (x + image.width, y + image.height)
[ "Wait", "until", "a", "portion", "of", "the", "screen", "matches", "the", "target", "image" ]
e133a8916efaa0f5ed421e0aa737196624635b0c
https://github.com/sibson/vncdotool/blob/e133a8916efaa0f5ed421e0aa737196624635b0c/vncdotool/client.py#L271-L278
train
sibson/vncdotool
vncdotool/client.py
VNCDoToolClient.setImageMode
def setImageMode(self): """ Extracts color ordering and 24 vs. 32 bpp info out of the pixel format information """ if self._version_server == 3.889: self.setPixelFormat( bpp = 16, depth = 16, bigendian = 0, truecolor = 1, redmax = 31, greenmax ...
python
def setImageMode(self): """ Extracts color ordering and 24 vs. 32 bpp info out of the pixel format information """ if self._version_server == 3.889: self.setPixelFormat( bpp = 16, depth = 16, bigendian = 0, truecolor = 1, redmax = 31, greenmax ...
[ "def", "setImageMode", "(", "self", ")", ":", "if", "self", ".", "_version_server", "==", "3.889", ":", "self", ".", "setPixelFormat", "(", "bpp", "=", "16", ",", "depth", "=", "16", ",", "bigendian", "=", "0", ",", "truecolor", "=", "1", ",", "redma...
Extracts color ordering and 24 vs. 32 bpp info out of the pixel format information
[ "Extracts", "color", "ordering", "and", "24", "vs", ".", "32", "bpp", "info", "out", "of", "the", "pixel", "format", "information" ]
e133a8916efaa0f5ed421e0aa737196624635b0c
https://github.com/sibson/vncdotool/blob/e133a8916efaa0f5ed421e0aa737196624635b0c/vncdotool/client.py#L344-L363
train
sibson/vncdotool
vncdotool/rfb.py
RFBClient._handleDecodeHextileRAW
def _handleDecodeHextileRAW(self, block, bg, color, x, y, width, height, tx, ty, tw, th): """the tile is in raw encoding""" self.updateRectangle(tx, ty, tw, th, block) self._doNextHextileSubrect(bg, color, x, y, width, height, tx, ty)
python
def _handleDecodeHextileRAW(self, block, bg, color, x, y, width, height, tx, ty, tw, th): """the tile is in raw encoding""" self.updateRectangle(tx, ty, tw, th, block) self._doNextHextileSubrect(bg, color, x, y, width, height, tx, ty)
[ "def", "_handleDecodeHextileRAW", "(", "self", ",", "block", ",", "bg", ",", "color", ",", "x", ",", "y", ",", "width", ",", "height", ",", "tx", ",", "ty", ",", "tw", ",", "th", ")", ":", "self", ".", "updateRectangle", "(", "tx", ",", "ty", ","...
the tile is in raw encoding
[ "the", "tile", "is", "in", "raw", "encoding" ]
e133a8916efaa0f5ed421e0aa737196624635b0c
https://github.com/sibson/vncdotool/blob/e133a8916efaa0f5ed421e0aa737196624635b0c/vncdotool/rfb.py#L452-L455
train
sibson/vncdotool
vncdotool/rfb.py
RFBClient._handleDecodeHextileSubrectsColoured
def _handleDecodeHextileSubrectsColoured(self, block, bg, color, subrects, x, y, width, height, tx, ty, tw, th): """subrects with their own color""" sz = self.bypp + 2 pos = 0 end = len(block) while pos < end: pos2 = pos + self.bypp color = block[pos:pos2]...
python
def _handleDecodeHextileSubrectsColoured(self, block, bg, color, subrects, x, y, width, height, tx, ty, tw, th): """subrects with their own color""" sz = self.bypp + 2 pos = 0 end = len(block) while pos < end: pos2 = pos + self.bypp color = block[pos:pos2]...
[ "def", "_handleDecodeHextileSubrectsColoured", "(", "self", ",", "block", ",", "bg", ",", "color", ",", "subrects", ",", "x", ",", "y", ",", "width", ",", "height", ",", "tx", ",", "ty", ",", "tw", ",", "th", ")", ":", "sz", "=", "self", ".", "bypp...
subrects with their own color
[ "subrects", "with", "their", "own", "color" ]
e133a8916efaa0f5ed421e0aa737196624635b0c
https://github.com/sibson/vncdotool/blob/e133a8916efaa0f5ed421e0aa737196624635b0c/vncdotool/rfb.py#L457-L473
train
sibson/vncdotool
vncdotool/rfb.py
RFBClient.fillRectangle
def fillRectangle(self, x, y, width, height, color): """fill the area with the color. the color is a string in the pixel format set up earlier""" #fallback variant, use update recatngle #override with specialized function for better performance self.updateRectangle(x, y, width...
python
def fillRectangle(self, x, y, width, height, color): """fill the area with the color. the color is a string in the pixel format set up earlier""" #fallback variant, use update recatngle #override with specialized function for better performance self.updateRectangle(x, y, width...
[ "def", "fillRectangle", "(", "self", ",", "x", ",", "y", ",", "width", ",", "height", ",", "color", ")", ":", "self", ".", "updateRectangle", "(", "x", ",", "y", ",", "width", ",", "height", ",", "color", "*", "width", "*", "height", ")" ]
fill the area with the color. the color is a string in the pixel format set up earlier
[ "fill", "the", "area", "with", "the", "color", ".", "the", "color", "is", "a", "string", "in", "the", "pixel", "format", "set", "up", "earlier" ]
e133a8916efaa0f5ed421e0aa737196624635b0c
https://github.com/sibson/vncdotool/blob/e133a8916efaa0f5ed421e0aa737196624635b0c/vncdotool/rfb.py#L634-L639
train
sibson/vncdotool
vncdotool/rfb.py
RFBDes.setKey
def setKey(self, key): """RFB protocol for authentication requires client to encrypt challenge sent by server with password using DES method. However, bits in each byte of the password are put in reverse order before using it as encryption key.""" newkey = [] for...
python
def setKey(self, key): """RFB protocol for authentication requires client to encrypt challenge sent by server with password using DES method. However, bits in each byte of the password are put in reverse order before using it as encryption key.""" newkey = [] for...
[ "def", "setKey", "(", "self", ",", "key", ")", ":", "newkey", "=", "[", "]", "for", "ki", "in", "range", "(", "len", "(", "key", ")", ")", ":", "bsrc", "=", "ord", "(", "key", "[", "ki", "]", ")", "btgt", "=", "0", "for", "i", "in", "range"...
RFB protocol for authentication requires client to encrypt challenge sent by server with password using DES method. However, bits in each byte of the password are put in reverse order before using it as encryption key.
[ "RFB", "protocol", "for", "authentication", "requires", "client", "to", "encrypt", "challenge", "sent", "by", "server", "with", "password", "using", "DES", "method", ".", "However", "bits", "in", "each", "byte", "of", "the", "password", "are", "put", "in", "...
e133a8916efaa0f5ed421e0aa737196624635b0c
https://github.com/sibson/vncdotool/blob/e133a8916efaa0f5ed421e0aa737196624635b0c/vncdotool/rfb.py#L667-L680
train
meraki-analytics/cassiopeia
cassiopeia/core/league.py
MiniSeries.not_played
def not_played(self) -> int: """The number of games in the player's promos that they haven't played yet.""" return len(self._data[MiniSeriesData].progress) - len(self.progress)
python
def not_played(self) -> int: """The number of games in the player's promos that they haven't played yet.""" return len(self._data[MiniSeriesData].progress) - len(self.progress)
[ "def", "not_played", "(", "self", ")", "->", "int", ":", "return", "len", "(", "self", ".", "_data", "[", "MiniSeriesData", "]", ".", "progress", ")", "-", "len", "(", "self", ".", "progress", ")" ]
The number of games in the player's promos that they haven't played yet.
[ "The", "number", "of", "games", "in", "the", "player", "s", "promos", "that", "they", "haven", "t", "played", "yet", "." ]
de3db568586b34c0edf1f7736279485a4510822f
https://github.com/meraki-analytics/cassiopeia/blob/de3db568586b34c0edf1f7736279485a4510822f/cassiopeia/core/league.py#L134-L136
train
meraki-analytics/cassiopeia
cassiopeia/datastores/uniquekeys.py
_rgetattr
def _rgetattr(obj, key): """Recursive getattr for handling dots in keys.""" for k in key.split("."): obj = getattr(obj, k) return obj
python
def _rgetattr(obj, key): """Recursive getattr for handling dots in keys.""" for k in key.split("."): obj = getattr(obj, k) return obj
[ "def", "_rgetattr", "(", "obj", ",", "key", ")", ":", "for", "k", "in", "key", ".", "split", "(", "\".\"", ")", ":", "obj", "=", "getattr", "(", "obj", ",", "k", ")", "return", "obj" ]
Recursive getattr for handling dots in keys.
[ "Recursive", "getattr", "for", "handling", "dots", "in", "keys", "." ]
de3db568586b34c0edf1f7736279485a4510822f
https://github.com/meraki-analytics/cassiopeia/blob/de3db568586b34c0edf1f7736279485a4510822f/cassiopeia/datastores/uniquekeys.py#L37-L41
train
wong2/pick
pick/__init__.py
Picker.draw
def draw(self): """draw the curses ui on the screen, handle scroll if needed""" self.screen.clear() x, y = 1, 1 # start point max_y, max_x = self.screen.getmaxyx() max_rows = max_y - y # the max rows we can draw lines, current_line = self.get_lines() # calcul...
python
def draw(self): """draw the curses ui on the screen, handle scroll if needed""" self.screen.clear() x, y = 1, 1 # start point max_y, max_x = self.screen.getmaxyx() max_rows = max_y - y # the max rows we can draw lines, current_line = self.get_lines() # calcul...
[ "def", "draw", "(", "self", ")", ":", "self", ".", "screen", ".", "clear", "(", ")", "x", ",", "y", "=", "1", ",", "1", "max_y", ",", "max_x", "=", "self", ".", "screen", ".", "getmaxyx", "(", ")", "max_rows", "=", "max_y", "-", "y", "lines", ...
draw the curses ui on the screen, handle scroll if needed
[ "draw", "the", "curses", "ui", "on", "the", "screen", "handle", "scroll", "if", "needed" ]
bde1809387b17a0dd0b3250f03039e9123ecd9c7
https://github.com/wong2/pick/blob/bde1809387b17a0dd0b3250f03039e9123ecd9c7/pick/__init__.py#L114-L141
train
chovanecm/sacredboard
sacredboard/app/webapi/files.py
get_file
def get_file(file_id: str, download): """ Get a specific file from GridFS. Returns a binary stream response or HTTP 404 if not found. """ data = current_app.config["data"] # type: DataStorage dao = data.get_files_dao() file_fp, filename, upload_date = dao.get(file_id) if download: ...
python
def get_file(file_id: str, download): """ Get a specific file from GridFS. Returns a binary stream response or HTTP 404 if not found. """ data = current_app.config["data"] # type: DataStorage dao = data.get_files_dao() file_fp, filename, upload_date = dao.get(file_id) if download: ...
[ "def", "get_file", "(", "file_id", ":", "str", ",", "download", ")", ":", "data", "=", "current_app", ".", "config", "[", "\"data\"", "]", "dao", "=", "data", ".", "get_files_dao", "(", ")", "file_fp", ",", "filename", ",", "upload_date", "=", "dao", "...
Get a specific file from GridFS. Returns a binary stream response or HTTP 404 if not found.
[ "Get", "a", "specific", "file", "from", "GridFS", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/webapi/files.py#L36-L64
train
chovanecm/sacredboard
sacredboard/app/webapi/files.py
get_files_zip
def get_files_zip(run_id: int, filetype: _FileType): """Send all artifacts or sources of a run as ZIP.""" data = current_app.config["data"] dao_runs = data.get_run_dao() dao_files = data.get_files_dao() run = dao_runs.get(run_id) if filetype == _FileType.ARTIFACT: target_files = run['ar...
python
def get_files_zip(run_id: int, filetype: _FileType): """Send all artifacts or sources of a run as ZIP.""" data = current_app.config["data"] dao_runs = data.get_run_dao() dao_files = data.get_files_dao() run = dao_runs.get(run_id) if filetype == _FileType.ARTIFACT: target_files = run['ar...
[ "def", "get_files_zip", "(", "run_id", ":", "int", ",", "filetype", ":", "_FileType", ")", ":", "data", "=", "current_app", ".", "config", "[", "\"data\"", "]", "dao_runs", "=", "data", ".", "get_run_dao", "(", ")", "dao_files", "=", "data", ".", "get_fi...
Send all artifacts or sources of a run as ZIP.
[ "Send", "all", "artifacts", "or", "sources", "of", "a", "run", "as", "ZIP", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/webapi/files.py#L67-L93
train
chovanecm/sacredboard
sacredboard/app/data/pymongo/filesdao.py
MongoFilesDAO.get
def get(self, file_id: Union[str, bson.ObjectId]) -> [typing.BinaryIO, str, datetime.datetime]: """ Return the file identified by a file_id string. The return value is a file-like object which also has the following attributes: filename: str upload_date: datetime """ ...
python
def get(self, file_id: Union[str, bson.ObjectId]) -> [typing.BinaryIO, str, datetime.datetime]: """ Return the file identified by a file_id string. The return value is a file-like object which also has the following attributes: filename: str upload_date: datetime """ ...
[ "def", "get", "(", "self", ",", "file_id", ":", "Union", "[", "str", ",", "bson", ".", "ObjectId", "]", ")", "->", "[", "typing", ".", "BinaryIO", ",", "str", ",", "datetime", ".", "datetime", "]", ":", "if", "isinstance", "(", "file_id", ",", "str...
Return the file identified by a file_id string. The return value is a file-like object which also has the following attributes: filename: str upload_date: datetime
[ "Return", "the", "file", "identified", "by", "a", "file_id", "string", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/data/pymongo/filesdao.py#L27-L38
train
chovanecm/sacredboard
sacredboard/app/data/pymongo/genericdao.py
GenericDAO.find_record
def find_record(self, collection_name, query): """ Return the first record mathing the given Mongo query. :param collection_name: Name of the collection to search in. :param query: MongoDB Query, e.g. {_id: 123} :return: A single MongoDB record or None if not found. :ra...
python
def find_record(self, collection_name, query): """ Return the first record mathing the given Mongo query. :param collection_name: Name of the collection to search in. :param query: MongoDB Query, e.g. {_id: 123} :return: A single MongoDB record or None if not found. :ra...
[ "def", "find_record", "(", "self", ",", "collection_name", ",", "query", ")", ":", "cursor", "=", "self", ".", "_get_collection", "(", "collection_name", ")", ".", "find", "(", "query", ")", "for", "record", "in", "cursor", ":", "return", "record", "return...
Return the first record mathing the given Mongo query. :param collection_name: Name of the collection to search in. :param query: MongoDB Query, e.g. {_id: 123} :return: A single MongoDB record or None if not found. :raise DataSourceError
[ "Return", "the", "first", "record", "mathing", "the", "given", "Mongo", "query", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/data/pymongo/genericdao.py#L32-L47
train
chovanecm/sacredboard
sacredboard/app/data/pymongo/genericdao.py
GenericDAO.find_records
def find_records(self, collection_name, query={}, sort_by=None, sort_direction=None, start=0, limit=None): """ Return a cursor of records from the given MongoDB collection. :param collection_name: Name of the MongoDB collection to query. :param query: Standard Mongo...
python
def find_records(self, collection_name, query={}, sort_by=None, sort_direction=None, start=0, limit=None): """ Return a cursor of records from the given MongoDB collection. :param collection_name: Name of the MongoDB collection to query. :param query: Standard Mongo...
[ "def", "find_records", "(", "self", ",", "collection_name", ",", "query", "=", "{", "}", ",", "sort_by", "=", "None", ",", "sort_direction", "=", "None", ",", "start", "=", "0", ",", "limit", "=", "None", ")", ":", "cursor", "=", "self", ".", "_get_c...
Return a cursor of records from the given MongoDB collection. :param collection_name: Name of the MongoDB collection to query. :param query: Standard MongoDB query. By default no restriction. :param sort_by: Name of a single field to sort by. :param sort_direction: The direction to sort...
[ "Return", "a", "cursor", "of", "records", "from", "the", "given", "MongoDB", "collection", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/data/pymongo/genericdao.py#L49-L70
train
chovanecm/sacredboard
sacredboard/app/data/pymongo/genericdao.py
GenericDAO._get_database
def _get_database(self, database_name): """ Get PyMongo client pointing to the current database. :return: MongoDB client of the current database. :raise DataSourceError """ try: return self._client[database_name] except InvalidName as ex: ...
python
def _get_database(self, database_name): """ Get PyMongo client pointing to the current database. :return: MongoDB client of the current database. :raise DataSourceError """ try: return self._client[database_name] except InvalidName as ex: ...
[ "def", "_get_database", "(", "self", ",", "database_name", ")", ":", "try", ":", "return", "self", ".", "_client", "[", "database_name", "]", "except", "InvalidName", "as", "ex", ":", "raise", "DataSourceError", "(", "\"Cannot connect to database %s!\"", "%", "s...
Get PyMongo client pointing to the current database. :return: MongoDB client of the current database. :raise DataSourceError
[ "Get", "PyMongo", "client", "pointing", "to", "the", "current", "database", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/data/pymongo/genericdao.py#L76-L87
train
chovanecm/sacredboard
sacredboard/app/data/pymongo/genericdao.py
GenericDAO._get_collection
def _get_collection(self, collection_name): """ Get PyMongo client pointing to the current DB and the given collection. :return: MongoDB client of the current database and given collection. :raise DataSourceError """ try: return self._database[collection_name...
python
def _get_collection(self, collection_name): """ Get PyMongo client pointing to the current DB and the given collection. :return: MongoDB client of the current database and given collection. :raise DataSourceError """ try: return self._database[collection_name...
[ "def", "_get_collection", "(", "self", ",", "collection_name", ")", ":", "try", ":", "return", "self", ".", "_database", "[", "collection_name", "]", "except", "InvalidName", "as", "ex", ":", "raise", "DataSourceError", "(", "\"Cannot access MongoDB collection %s!\"...
Get PyMongo client pointing to the current DB and the given collection. :return: MongoDB client of the current database and given collection. :raise DataSourceError
[ "Get", "PyMongo", "client", "pointing", "to", "the", "current", "DB", "and", "the", "given", "collection", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/data/pymongo/genericdao.py#L89-L104
train
chovanecm/sacredboard
sacredboard/app/data/pymongo/rundao.py
MongoRunDAO.get
def get(self, run_id): """ Get a single run from the database. :param run_id: The ID of the run. :return: The whole object from the database. :raise NotFoundError when not found """ id = self._parse_id(run_id) run = self.generic_dao.find_record(self.coll...
python
def get(self, run_id): """ Get a single run from the database. :param run_id: The ID of the run. :return: The whole object from the database. :raise NotFoundError when not found """ id = self._parse_id(run_id) run = self.generic_dao.find_record(self.coll...
[ "def", "get", "(", "self", ",", "run_id", ")", ":", "id", "=", "self", ".", "_parse_id", "(", "run_id", ")", "run", "=", "self", ".", "generic_dao", ".", "find_record", "(", "self", ".", "collection_name", ",", "{", "\"_id\"", ":", "id", "}", ")", ...
Get a single run from the database. :param run_id: The ID of the run. :return: The whole object from the database. :raise NotFoundError when not found
[ "Get", "a", "single", "run", "from", "the", "database", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/data/pymongo/rundao.py#L72-L86
train
chovanecm/sacredboard
sacredboard/app/data/pymongo/rundao.py
MongoRunDAO._apply_sort
def _apply_sort(cursor, sort_by, sort_direction): """ Apply sort to a cursor. :param cursor: The cursor to apply sort on. :param sort_by: The field name to sort by. :param sort_direction: The direction to sort, "asc" or "desc". :return: """ if sort_direc...
python
def _apply_sort(cursor, sort_by, sort_direction): """ Apply sort to a cursor. :param cursor: The cursor to apply sort on. :param sort_by: The field name to sort by. :param sort_direction: The direction to sort, "asc" or "desc". :return: """ if sort_direc...
[ "def", "_apply_sort", "(", "cursor", ",", "sort_by", ",", "sort_direction", ")", ":", "if", "sort_direction", "is", "not", "None", "and", "sort_direction", ".", "lower", "(", ")", "==", "\"desc\"", ":", "sort", "=", "pymongo", ".", "DESCENDING", "else", ":...
Apply sort to a cursor. :param cursor: The cursor to apply sort on. :param sort_by: The field name to sort by. :param sort_direction: The direction to sort, "asc" or "desc". :return:
[ "Apply", "sort", "to", "a", "cursor", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/data/pymongo/rundao.py#L97-L111
train
chovanecm/sacredboard
sacredboard/app/data/pymongo/rundao.py
MongoRunDAO._to_mongo_query
def _to_mongo_query(query): """ Convert the query received by the Sacred Web API to a MongoDB query. Takes a query in format {"type": "and", "filters": [ {"field": "host.hostname", "operator": "==", "value": "ntbacer"}, {"type": "or", "filters": [ {"field":...
python
def _to_mongo_query(query): """ Convert the query received by the Sacred Web API to a MongoDB query. Takes a query in format {"type": "and", "filters": [ {"field": "host.hostname", "operator": "==", "value": "ntbacer"}, {"type": "or", "filters": [ {"field":...
[ "def", "_to_mongo_query", "(", "query", ")", ":", "mongo_query", "=", "[", "]", "for", "clause", "in", "query", "[", "\"filters\"", "]", ":", "if", "clause", ".", "get", "(", "\"type\"", ")", "is", "None", ":", "mongo_clause", "=", "MongoRunDAO", ".", ...
Convert the query received by the Sacred Web API to a MongoDB query. Takes a query in format {"type": "and", "filters": [ {"field": "host.hostname", "operator": "==", "value": "ntbacer"}, {"type": "or", "filters": [ {"field": "result", "operator": "==", "value": 2403.52}, ...
[ "Convert", "the", "query", "received", "by", "the", "Sacred", "Web", "API", "to", "a", "MongoDB", "query", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/data/pymongo/rundao.py#L114-L146
train
chovanecm/sacredboard
sacredboard/app/data/pymongo/rundao.py
MongoRunDAO._simple_clause_to_query
def _simple_clause_to_query(clause): """ Convert a clause from the Sacred Web API format to the MongoDB format. :param clause: A clause to be converted. It must have "field", "operator" and "value" fields. :return: A MongoDB clause. """ # It's a regular clause ...
python
def _simple_clause_to_query(clause): """ Convert a clause from the Sacred Web API format to the MongoDB format. :param clause: A clause to be converted. It must have "field", "operator" and "value" fields. :return: A MongoDB clause. """ # It's a regular clause ...
[ "def", "_simple_clause_to_query", "(", "clause", ")", ":", "mongo_clause", "=", "{", "}", "value", "=", "clause", "[", "\"value\"", "]", "if", "clause", "[", "\"field\"", "]", "==", "\"status\"", "and", "clause", "[", "\"value\"", "]", "in", "[", "\"DEAD\"...
Convert a clause from the Sacred Web API format to the MongoDB format. :param clause: A clause to be converted. It must have "field", "operator" and "value" fields. :return: A MongoDB clause.
[ "Convert", "a", "clause", "from", "the", "Sacred", "Web", "API", "format", "to", "the", "MongoDB", "format", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/data/pymongo/rundao.py#L149-L178
train
chovanecm/sacredboard
sacredboard/app/data/pymongo/rundao.py
MongoRunDAO._status_filter_to_query
def _status_filter_to_query(clause): """ Convert a clause querying for an experiment state RUNNING or DEAD. Queries that check for experiment state RUNNING and DEAD need to be replaced by the logic that decides these two states as both of them are stored in the Mongo Database as...
python
def _status_filter_to_query(clause): """ Convert a clause querying for an experiment state RUNNING or DEAD. Queries that check for experiment state RUNNING and DEAD need to be replaced by the logic that decides these two states as both of them are stored in the Mongo Database as...
[ "def", "_status_filter_to_query", "(", "clause", ")", ":", "if", "clause", "[", "\"value\"", "]", "==", "\"RUNNING\"", ":", "mongo_clause", "=", "MongoRunDAO", ".", "RUNNING_NOT_DEAD_CLAUSE", "elif", "clause", "[", "\"value\"", "]", "==", "\"DEAD\"", ":", "mongo...
Convert a clause querying for an experiment state RUNNING or DEAD. Queries that check for experiment state RUNNING and DEAD need to be replaced by the logic that decides these two states as both of them are stored in the Mongo Database as "RUNNING". We use querying by last heartbeat tim...
[ "Convert", "a", "clause", "querying", "for", "an", "experiment", "state", "RUNNING", "or", "DEAD", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/data/pymongo/rundao.py#L181-L200
train
chovanecm/sacredboard
sacredboard/app/data/pymongo/rundao.py
MongoRunDAO.delete
def delete(self, run_id): """ Delete run with the given id from the backend. :param run_id: Id of the run to delete. :raise NotImplementedError If not supported by the backend. :raise DataSourceError General data source error. :raise NotFoundError The run was not found. ...
python
def delete(self, run_id): """ Delete run with the given id from the backend. :param run_id: Id of the run to delete. :raise NotImplementedError If not supported by the backend. :raise DataSourceError General data source error. :raise NotFoundError The run was not found. ...
[ "def", "delete", "(", "self", ",", "run_id", ")", ":", "return", "self", ".", "generic_dao", ".", "delete_record", "(", "self", ".", "collection_name", ",", "self", ".", "_parse_id", "(", "run_id", ")", ")" ]
Delete run with the given id from the backend. :param run_id: Id of the run to delete. :raise NotImplementedError If not supported by the backend. :raise DataSourceError General data source error. :raise NotFoundError The run was not found. (Some backends may succeed even if the...
[ "Delete", "run", "with", "the", "given", "id", "from", "the", "backend", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/data/pymongo/rundao.py#L202-L213
train
chovanecm/sacredboard
sacredboard/bootstrap.py
add_mongo_config
def add_mongo_config(app, simple_connection_string, mongo_uri, collection_name): """ Configure the application to use MongoDB. :param app: Flask application :param simple_connection_string: Expects host:port:database_name or database_name Mutally_exc...
python
def add_mongo_config(app, simple_connection_string, mongo_uri, collection_name): """ Configure the application to use MongoDB. :param app: Flask application :param simple_connection_string: Expects host:port:database_name or database_name Mutally_exc...
[ "def", "add_mongo_config", "(", "app", ",", "simple_connection_string", ",", "mongo_uri", ",", "collection_name", ")", ":", "if", "mongo_uri", "!=", "(", "None", ",", "None", ")", ":", "add_mongo_config_with_uri", "(", "app", ",", "mongo_uri", "[", "0", "]", ...
Configure the application to use MongoDB. :param app: Flask application :param simple_connection_string: Expects host:port:database_name or database_name Mutally_exclusive with mongo_uri :param mongo_uri: Expects mongodb://... as defined in https://docs.mongo...
[ "Configure", "the", "application", "to", "use", "MongoDB", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/bootstrap.py#L133-L158
train
chovanecm/sacredboard
sacredboard/bootstrap.py
add_mongo_config_simple
def add_mongo_config_simple(app, connection_string, collection_name): """ Configure the app to use MongoDB. :param app: Flask Application :type app: Flask :param connection_string: in format host:port:database or database (default: sacred) :type connection_string: str :param co...
python
def add_mongo_config_simple(app, connection_string, collection_name): """ Configure the app to use MongoDB. :param app: Flask Application :type app: Flask :param connection_string: in format host:port:database or database (default: sacred) :type connection_string: str :param co...
[ "def", "add_mongo_config_simple", "(", "app", ",", "connection_string", ",", "collection_name", ")", ":", "split_string", "=", "connection_string", ".", "split", "(", "\":\"", ")", "config", "=", "{", "\"host\"", ":", "\"localhost\"", ",", "\"port\"", ":", "2701...
Configure the app to use MongoDB. :param app: Flask Application :type app: Flask :param connection_string: in format host:port:database or database (default: sacred) :type connection_string: str :param collection_name: Name of the collection :type collection_name: str
[ "Configure", "the", "app", "to", "use", "MongoDB", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/bootstrap.py#L161-L183
train
chovanecm/sacredboard
sacredboard/bootstrap.py
add_mongo_config_with_uri
def add_mongo_config_with_uri(app, connection_string_uri, database_name, collection_name): """ Configure PyMongo with a MongoDB connection string. :param app: Flask application :param connection_string_uri: MongoDB connection string :param database_name: Sacred databas...
python
def add_mongo_config_with_uri(app, connection_string_uri, database_name, collection_name): """ Configure PyMongo with a MongoDB connection string. :param app: Flask application :param connection_string_uri: MongoDB connection string :param database_name: Sacred databas...
[ "def", "add_mongo_config_with_uri", "(", "app", ",", "connection_string_uri", ",", "database_name", ",", "collection_name", ")", ":", "app", ".", "config", "[", "\"data\"", "]", "=", "PyMongoDataAccess", ".", "build_data_access_with_uri", "(", "connection_string_uri", ...
Configure PyMongo with a MongoDB connection string. :param app: Flask application :param connection_string_uri: MongoDB connection string :param database_name: Sacred database name :param collection_name: Sacred's collection with runs :return:
[ "Configure", "PyMongo", "with", "a", "MongoDB", "connection", "string", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/bootstrap.py#L186-L199
train
chovanecm/sacredboard
sacredboard/app/process/tensorboard.py
stop_all_tensorboards
def stop_all_tensorboards(): """Terminate all TensorBoard instances.""" for process in Process.instances: print("Process '%s', running %d" % (process.command[0], process.is_running())) if process.is_running() and process.command[0] == "tensorboard": ...
python
def stop_all_tensorboards(): """Terminate all TensorBoard instances.""" for process in Process.instances: print("Process '%s', running %d" % (process.command[0], process.is_running())) if process.is_running() and process.command[0] == "tensorboard": ...
[ "def", "stop_all_tensorboards", "(", ")", ":", "for", "process", "in", "Process", ".", "instances", ":", "print", "(", "\"Process '%s', running %d\"", "%", "(", "process", ".", "command", "[", "0", "]", ",", "process", ".", "is_running", "(", ")", ")", ")"...
Terminate all TensorBoard instances.
[ "Terminate", "all", "TensorBoard", "instances", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/process/tensorboard.py#L11-L17
train
chovanecm/sacredboard
sacredboard/app/process/tensorboard.py
run_tensorboard
def run_tensorboard(logdir, listen_on="0.0.0.0", port=0, tensorboard_args=None, timeout=10): """ Launch a new TensorBoard instance. :param logdir: Path to a TensorFlow summary directory :param listen_on: The IP address TensorBoard should listen on. :param port: Port number to listen on. 0 for a ran...
python
def run_tensorboard(logdir, listen_on="0.0.0.0", port=0, tensorboard_args=None, timeout=10): """ Launch a new TensorBoard instance. :param logdir: Path to a TensorFlow summary directory :param listen_on: The IP address TensorBoard should listen on. :param port: Port number to listen on. 0 for a ran...
[ "def", "run_tensorboard", "(", "logdir", ",", "listen_on", "=", "\"0.0.0.0\"", ",", "port", "=", "0", ",", "tensorboard_args", "=", "None", ",", "timeout", "=", "10", ")", ":", "if", "tensorboard_args", "is", "None", ":", "tensorboard_args", "=", "[", "]",...
Launch a new TensorBoard instance. :param logdir: Path to a TensorFlow summary directory :param listen_on: The IP address TensorBoard should listen on. :param port: Port number to listen on. 0 for a random port. :param tensorboard_args: Additional TensorBoard arguments. :param timeout: Timeout afte...
[ "Launch", "a", "new", "TensorBoard", "instance", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/process/tensorboard.py#L26-L68
train
chovanecm/sacredboard
sacredboard/app/process/tensorboard.py
parse_port_from_tensorboard_output
def parse_port_from_tensorboard_output(tensorboard_output: str) -> int: """ Parse tensorboard port from its outputted message. :param tensorboard_output: Output message of Tensorboard in format TensorBoard 1.8.0 at http://martin-VirtualBox:36869 :return: Returns the port TensorBoard is listening on...
python
def parse_port_from_tensorboard_output(tensorboard_output: str) -> int: """ Parse tensorboard port from its outputted message. :param tensorboard_output: Output message of Tensorboard in format TensorBoard 1.8.0 at http://martin-VirtualBox:36869 :return: Returns the port TensorBoard is listening on...
[ "def", "parse_port_from_tensorboard_output", "(", "tensorboard_output", ":", "str", ")", "->", "int", ":", "search", "=", "re", ".", "search", "(", "\"at http://[^:]+:([0-9]+)\"", ",", "tensorboard_output", ")", "if", "search", "is", "not", "None", ":", "port", ...
Parse tensorboard port from its outputted message. :param tensorboard_output: Output message of Tensorboard in format TensorBoard 1.8.0 at http://martin-VirtualBox:36869 :return: Returns the port TensorBoard is listening on. :raise UnexpectedOutputError
[ "Parse", "tensorboard", "port", "from", "its", "outputted", "message", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/process/tensorboard.py#L71-L86
train
chovanecm/sacredboard
sacredboard/app/data/pymongo/mongodb.py
PyMongoDataAccess.connect
def connect(self): """Initialize the database connection.""" self._client = self._create_client() self._db = getattr(self._client, self._db_name) self._generic_dao = GenericDAO(self._client, self._db_name)
python
def connect(self): """Initialize the database connection.""" self._client = self._create_client() self._db = getattr(self._client, self._db_name) self._generic_dao = GenericDAO(self._client, self._db_name)
[ "def", "connect", "(", "self", ")", ":", "self", ".", "_client", "=", "self", ".", "_create_client", "(", ")", "self", ".", "_db", "=", "getattr", "(", "self", ".", "_client", ",", "self", ".", "_db_name", ")", "self", ".", "_generic_dao", "=", "Gene...
Initialize the database connection.
[ "Initialize", "the", "database", "connection", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/data/pymongo/mongodb.py#L44-L48
train
chovanecm/sacredboard
sacredboard/app/data/pymongo/mongodb.py
PyMongoDataAccess.build_data_access
def build_data_access(host, port, database_name, collection_name): """ Create data access gateway. :param host: The database server to connect to. :type host: str :param port: Database port. :type port: int :param database_name: Database name. :type datab...
python
def build_data_access(host, port, database_name, collection_name): """ Create data access gateway. :param host: The database server to connect to. :type host: str :param port: Database port. :type port: int :param database_name: Database name. :type datab...
[ "def", "build_data_access", "(", "host", ",", "port", ",", "database_name", ",", "collection_name", ")", ":", "return", "PyMongoDataAccess", "(", "\"mongodb://%s:%d\"", "%", "(", "host", ",", "port", ")", ",", "database_name", ",", "collection_name", ")" ]
Create data access gateway. :param host: The database server to connect to. :type host: str :param port: Database port. :type port: int :param database_name: Database name. :type database_name: str :param collection_name: Name of the collection with Sacred runs. ...
[ "Create", "data", "access", "gateway", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/data/pymongo/mongodb.py#L55-L69
train
chovanecm/sacredboard
sacredboard/app/webapi/routes.py
run_tensorboard
def run_tensorboard(run_id, tflog_id): """Launch TensorBoard for a given run ID and log ID of that run.""" data = current_app.config["data"] # optimisticaly suppose the run exists... run = data.get_run_dao().get(run_id) base_dir = Path(run["experiment"]["base_dir"]) log_dir = Path(run["info"]["t...
python
def run_tensorboard(run_id, tflog_id): """Launch TensorBoard for a given run ID and log ID of that run.""" data = current_app.config["data"] # optimisticaly suppose the run exists... run = data.get_run_dao().get(run_id) base_dir = Path(run["experiment"]["base_dir"]) log_dir = Path(run["info"]["t...
[ "def", "run_tensorboard", "(", "run_id", ",", "tflog_id", ")", ":", "data", "=", "current_app", ".", "config", "[", "\"data\"", "]", "run", "=", "data", ".", "get_run_dao", "(", ")", ".", "get", "(", "run_id", ")", "base_dir", "=", "Path", "(", "run", ...
Launch TensorBoard for a given run ID and log ID of that run.
[ "Launch", "TensorBoard", "for", "a", "given", "run", "ID", "and", "log", "ID", "of", "that", "run", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/webapi/routes.py#L39-L56
train
chovanecm/sacredboard
sacredboard/app/data/pymongo/metricsdao.py
MongoMetricsDAO.get
def get(self, run_id, metric_id): """ Read a metric of the given id and run. The returned object has the following format (timestamps are datetime objects). .. code:: {"steps": [0,1,20,40,...], "timestamps": [timestamp1,timestamp2,timestamp3,...], ...
python
def get(self, run_id, metric_id): """ Read a metric of the given id and run. The returned object has the following format (timestamps are datetime objects). .. code:: {"steps": [0,1,20,40,...], "timestamps": [timestamp1,timestamp2,timestamp3,...], ...
[ "def", "get", "(", "self", ",", "run_id", ",", "metric_id", ")", ":", "run_id", "=", "self", ".", "_parse_run_id", "(", "run_id", ")", "query", "=", "self", ".", "_build_query", "(", "run_id", ",", "metric_id", ")", "row", "=", "self", ".", "_read_metr...
Read a metric of the given id and run. The returned object has the following format (timestamps are datetime objects). .. code:: {"steps": [0,1,20,40,...], "timestamps": [timestamp1,timestamp2,timestamp3,...], "values": [0,1 2,3,4,5,6,...], "na...
[ "Read", "a", "metric", "of", "the", "given", "id", "and", "run", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/data/pymongo/metricsdao.py#L29-L55
train
chovanecm/sacredboard
sacredboard/app/data/pymongo/metricsdao.py
MongoMetricsDAO.delete
def delete(self, run_id): """ Delete all metrics belonging to the given run. :param run_id: ID of the Run that the metric belongs to. """ self.generic_dao.delete_record( self.metrics_collection_name, {"run_id": self._parse_run_id(run_id)})
python
def delete(self, run_id): """ Delete all metrics belonging to the given run. :param run_id: ID of the Run that the metric belongs to. """ self.generic_dao.delete_record( self.metrics_collection_name, {"run_id": self._parse_run_id(run_id)})
[ "def", "delete", "(", "self", ",", "run_id", ")", ":", "self", ".", "generic_dao", ".", "delete_record", "(", "self", ".", "metrics_collection_name", ",", "{", "\"run_id\"", ":", "self", ".", "_parse_run_id", "(", "run_id", ")", "}", ")" ]
Delete all metrics belonging to the given run. :param run_id: ID of the Run that the metric belongs to.
[ "Delete", "all", "metrics", "belonging", "to", "the", "given", "run", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/data/pymongo/metricsdao.py#L57-L65
train
chovanecm/sacredboard
sacredboard/app/business/runfacade.py
RunFacade.delete_run
def delete_run(self, run_id): """ Delete run of the given run_id. :raise NotImplementedError If not supported by the backend. :raise DataSourceError General data source error. :raise NotFoundError The run was not found. (Some backends may succeed even if the run does not exist. ...
python
def delete_run(self, run_id): """ Delete run of the given run_id. :raise NotImplementedError If not supported by the backend. :raise DataSourceError General data source error. :raise NotFoundError The run was not found. (Some backends may succeed even if the run does not exist. ...
[ "def", "delete_run", "(", "self", ",", "run_id", ")", ":", "ds", "=", "self", ".", "datastorage", "ds", ".", "get_metrics_dao", "(", ")", ".", "delete", "(", "run_id", ")", "ds", ".", "get_run_dao", "(", ")", ".", "delete", "(", "run_id", ")" ]
Delete run of the given run_id. :raise NotImplementedError If not supported by the backend. :raise DataSourceError General data source error. :raise NotFoundError The run was not found. (Some backends may succeed even if the run does not exist.
[ "Delete", "run", "of", "the", "given", "run_id", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/business/runfacade.py#L11-L24
train
chovanecm/sacredboard
sacredboard/app/data/filestorage/rundao.py
FileStoreRunDAO.get_runs
def get_runs(self, sort_by=None, sort_direction=None, start=0, limit=None, query={"type": "and", "filters": []}): """ Return all runs in the file store. If a run is corrupt, e.g. missing files, it is skipped. :param sort_by: NotImplemented :param sort_direction: NotImplemented...
python
def get_runs(self, sort_by=None, sort_direction=None, start=0, limit=None, query={"type": "and", "filters": []}): """ Return all runs in the file store. If a run is corrupt, e.g. missing files, it is skipped. :param sort_by: NotImplemented :param sort_direction: NotImplemented...
[ "def", "get_runs", "(", "self", ",", "sort_by", "=", "None", ",", "sort_direction", "=", "None", ",", "start", "=", "0", ",", "limit", "=", "None", ",", "query", "=", "{", "\"type\"", ":", "\"and\"", ",", "\"filters\"", ":", "[", "]", "}", ")", ":"...
Return all runs in the file store. If a run is corrupt, e.g. missing files, it is skipped. :param sort_by: NotImplemented :param sort_direction: NotImplemented :param start: NotImplemented :param limit: NotImplemented :param query: NotImplemented :return: FileS...
[ "Return", "all", "runs", "in", "the", "file", "store", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/data/filestorage/rundao.py#L20-L49
train
chovanecm/sacredboard
sacredboard/app/data/filestorage/rundao.py
FileStoreRunDAO.get
def get(self, run_id): """ Return the run associated with a particular `run_id`. :param run_id: :return: dict :raises FileNotFoundError """ config = _read_json(_path_to_config(self.directory, run_id)) run = _read_json(_path_to_run(self.directory, run_id))...
python
def get(self, run_id): """ Return the run associated with a particular `run_id`. :param run_id: :return: dict :raises FileNotFoundError """ config = _read_json(_path_to_config(self.directory, run_id)) run = _read_json(_path_to_run(self.directory, run_id))...
[ "def", "get", "(", "self", ",", "run_id", ")", ":", "config", "=", "_read_json", "(", "_path_to_config", "(", "self", ".", "directory", ",", "run_id", ")", ")", "run", "=", "_read_json", "(", "_path_to_run", "(", "self", ".", "directory", ",", "run_id", ...
Return the run associated with a particular `run_id`. :param run_id: :return: dict :raises FileNotFoundError
[ "Return", "the", "run", "associated", "with", "a", "particular", "run_id", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/data/filestorage/rundao.py#L51-L66
train
chovanecm/sacredboard
sacredboard/app/webapi/metrics.py
get_metric
def get_metric(run_id, metric_id): """ Get a specific Sacred metric from the database. Returns a JSON response or HTTP 404 if not found. Issue: https://github.com/chovanecm/sacredboard/issues/58 """ data = current_app.config["data"] # type: DataStorage dao = data.get_metrics_dao() metr...
python
def get_metric(run_id, metric_id): """ Get a specific Sacred metric from the database. Returns a JSON response or HTTP 404 if not found. Issue: https://github.com/chovanecm/sacredboard/issues/58 """ data = current_app.config["data"] # type: DataStorage dao = data.get_metrics_dao() metr...
[ "def", "get_metric", "(", "run_id", ",", "metric_id", ")", ":", "data", "=", "current_app", ".", "config", "[", "\"data\"", "]", "dao", "=", "data", ".", "get_metrics_dao", "(", ")", "metric", "=", "dao", ".", "get", "(", "run_id", ",", "metric_id", ")...
Get a specific Sacred metric from the database. Returns a JSON response or HTTP 404 if not found. Issue: https://github.com/chovanecm/sacredboard/issues/58
[ "Get", "a", "specific", "Sacred", "metric", "from", "the", "database", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/webapi/metrics.py#L15-L34
train
chovanecm/sacredboard
sacredboard/app/webapi/wsgi_server.py
ServerRunner.initialize
def initialize(self, app: Flask, app_config): """ Prepare the server to run and determine the port. :param app: The Flask Application. :param app_config: Configuration dictionary. This module uses the `debug` (`True`/`False`) and `http.port` attributes. """ debug...
python
def initialize(self, app: Flask, app_config): """ Prepare the server to run and determine the port. :param app: The Flask Application. :param app_config: Configuration dictionary. This module uses the `debug` (`True`/`False`) and `http.port` attributes. """ debug...
[ "def", "initialize", "(", "self", ",", "app", ":", "Flask", ",", "app_config", ")", ":", "debug", "=", "app_config", "[", "\"debug\"", "]", "port", "=", "app_config", "[", "\"http.port\"", "]", "if", "debug", ":", "self", ".", "started_on_port", "=", "po...
Prepare the server to run and determine the port. :param app: The Flask Application. :param app_config: Configuration dictionary. This module uses the `debug` (`True`/`False`) and `http.port` attributes.
[ "Prepare", "the", "server", "to", "run", "and", "determine", "the", "port", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/webapi/wsgi_server.py#L14-L36
train
chovanecm/sacredboard
sacredboard/app/webapi/runs.py
api_run_delete
def api_run_delete(run_id): """Delete the given run and corresponding entities.""" data = current_app.config["data"] # type: DataStorage RunFacade(data).delete_run(run_id) return "DELETED run %s" % run_id
python
def api_run_delete(run_id): """Delete the given run and corresponding entities.""" data = current_app.config["data"] # type: DataStorage RunFacade(data).delete_run(run_id) return "DELETED run %s" % run_id
[ "def", "api_run_delete", "(", "run_id", ")", ":", "data", "=", "current_app", ".", "config", "[", "\"data\"", "]", "RunFacade", "(", "data", ")", ".", "delete_run", "(", "run_id", ")", "return", "\"DELETED run %s\"", "%", "run_id" ]
Delete the given run and corresponding entities.
[ "Delete", "the", "given", "run", "and", "corresponding", "entities", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/webapi/runs.py#L20-L24
train
chovanecm/sacredboard
sacredboard/app/webapi/runs.py
api_run_get
def api_run_get(run_id): """Return a single run as a JSON object.""" data = current_app.config["data"] run = data.get_run_dao().get(run_id) records_total = 1 if run is not None else 0 if records_total == 0: return Response( render_template( "api/error.js", ...
python
def api_run_get(run_id): """Return a single run as a JSON object.""" data = current_app.config["data"] run = data.get_run_dao().get(run_id) records_total = 1 if run is not None else 0 if records_total == 0: return Response( render_template( "api/error.js", ...
[ "def", "api_run_get", "(", "run_id", ")", ":", "data", "=", "current_app", ".", "config", "[", "\"data\"", "]", "run", "=", "data", ".", "get_run_dao", "(", ")", ".", "get", "(", "run_id", ")", "records_total", "=", "1", "if", "run", "is", "not", "No...
Return a single run as a JSON object.
[ "Return", "a", "single", "run", "as", "a", "JSON", "object", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/webapi/runs.py#L28-L46
train
chovanecm/sacredboard
sacredboard/app/webapi/runs.py
parse_int_arg
def parse_int_arg(name, default): """Return a given URL parameter as int or return the default value.""" return default if request.args.get(name) is None \ else int(request.args.get(name))
python
def parse_int_arg(name, default): """Return a given URL parameter as int or return the default value.""" return default if request.args.get(name) is None \ else int(request.args.get(name))
[ "def", "parse_int_arg", "(", "name", ",", "default", ")", ":", "return", "default", "if", "request", ".", "args", ".", "get", "(", "name", ")", "is", "None", "else", "int", "(", "request", ".", "args", ".", "get", "(", "name", ")", ")" ]
Return a given URL parameter as int or return the default value.
[ "Return", "a", "given", "URL", "parameter", "as", "int", "or", "return", "the", "default", "value", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/webapi/runs.py#L49-L52
train
chovanecm/sacredboard
sacredboard/app/webapi/runs.py
parse_query_filter
def parse_query_filter(): """Parse the Run query filter from the URL as a dictionary.""" query_string = request.args.get("queryFilter") if query_string is None: return {"type": "and", "filters": []} query = json.loads(query_string) assert type(query) == dict assert type(query.get("type")...
python
def parse_query_filter(): """Parse the Run query filter from the URL as a dictionary.""" query_string = request.args.get("queryFilter") if query_string is None: return {"type": "and", "filters": []} query = json.loads(query_string) assert type(query) == dict assert type(query.get("type")...
[ "def", "parse_query_filter", "(", ")", ":", "query_string", "=", "request", ".", "args", ".", "get", "(", "\"queryFilter\"", ")", "if", "query_string", "is", "None", ":", "return", "{", "\"type\"", ":", "\"and\"", ",", "\"filters\"", ":", "[", "]", "}", ...
Parse the Run query filter from the URL as a dictionary.
[ "Parse", "the", "Run", "query", "filter", "from", "the", "URL", "as", "a", "dictionary", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/webapi/runs.py#L55-L63
train
chovanecm/sacredboard
sacredboard/app/webapi/runs.py
get_runs
def get_runs(): """Get all runs, sort it and return a response.""" data = current_app.config["data"] draw = parse_int_arg("draw", 1) start = parse_int_arg("start", 0) length = parse_int_arg("length", -1) length = length if length >= 0 else None order_column = request.args.get("order[0][colum...
python
def get_runs(): """Get all runs, sort it and return a response.""" data = current_app.config["data"] draw = parse_int_arg("draw", 1) start = parse_int_arg("start", 0) length = parse_int_arg("length", -1) length = length if length >= 0 else None order_column = request.args.get("order[0][colum...
[ "def", "get_runs", "(", ")", ":", "data", "=", "current_app", ".", "config", "[", "\"data\"", "]", "draw", "=", "parse_int_arg", "(", "\"draw\"", ",", "1", ")", "start", "=", "parse_int_arg", "(", "\"start\"", ",", "0", ")", "length", "=", "parse_int_arg...
Get all runs, sort it and return a response.
[ "Get", "all", "runs", "sort", "it", "and", "return", "a", "response", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/webapi/runs.py#L66-L95
train
chovanecm/sacredboard
sacredboard/app/data/filestorage/filesdao.py
FileStoreFilesDAO.get
def get(self, file_id: str) -> [typing.BinaryIO, str, datetime.datetime]: """Return the file identified by a file_id string, its file name and upload date.""" raise NotImplementedError("Downloading files for downloading files in FileStore has not been implemented yet.")
python
def get(self, file_id: str) -> [typing.BinaryIO, str, datetime.datetime]: """Return the file identified by a file_id string, its file name and upload date.""" raise NotImplementedError("Downloading files for downloading files in FileStore has not been implemented yet.")
[ "def", "get", "(", "self", ",", "file_id", ":", "str", ")", "->", "[", "typing", ".", "BinaryIO", ",", "str", ",", "datetime", ".", "datetime", "]", ":", "raise", "NotImplementedError", "(", "\"Downloading files for downloading files in FileStore has not been implem...
Return the file identified by a file_id string, its file name and upload date.
[ "Return", "the", "file", "identified", "by", "a", "file_id", "string", "its", "file", "name", "and", "upload", "date", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/data/filestorage/filesdao.py#L20-L22
train
chovanecm/sacredboard
sacredboard/app/config/jinja_filters.py
timediff
def timediff(time): """Return the difference in seconds between now and the given time.""" now = datetime.datetime.utcnow() diff = now - time diff_sec = diff.total_seconds() return diff_sec
python
def timediff(time): """Return the difference in seconds between now and the given time.""" now = datetime.datetime.utcnow() diff = now - time diff_sec = diff.total_seconds() return diff_sec
[ "def", "timediff", "(", "time", ")", ":", "now", "=", "datetime", ".", "datetime", ".", "utcnow", "(", ")", "diff", "=", "now", "-", "time", "diff_sec", "=", "diff", ".", "total_seconds", "(", ")", "return", "diff_sec" ]
Return the difference in seconds between now and the given time.
[ "Return", "the", "difference", "in", "seconds", "between", "now", "and", "the", "given", "time", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/config/jinja_filters.py#L25-L30
train
chovanecm/sacredboard
sacredboard/app/config/jinja_filters.py
last_line
def last_line(text): """ Get the last meaningful line of the text, that is the last non-empty line. :param text: Text to search the last line :type text: str :return: :rtype: str """ last_line_of_text = "" while last_line_of_text == "" and len(text) > 0: last_line_start = te...
python
def last_line(text): """ Get the last meaningful line of the text, that is the last non-empty line. :param text: Text to search the last line :type text: str :return: :rtype: str """ last_line_of_text = "" while last_line_of_text == "" and len(text) > 0: last_line_start = te...
[ "def", "last_line", "(", "text", ")", ":", "last_line_of_text", "=", "\"\"", "while", "last_line_of_text", "==", "\"\"", "and", "len", "(", "text", ")", ">", "0", ":", "last_line_start", "=", "text", ".", "rfind", "(", "\"\\n\"", ")", "last_line_start", "=...
Get the last meaningful line of the text, that is the last non-empty line. :param text: Text to search the last line :type text: str :return: :rtype: str
[ "Get", "the", "last", "meaningful", "line", "of", "the", "text", "that", "is", "the", "last", "non", "-", "empty", "line", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/config/jinja_filters.py#L34-L50
train
chovanecm/sacredboard
sacredboard/app/config/jinja_filters.py
dump_json
def dump_json(obj): """Dump Python object as JSON string.""" return simplejson.dumps(obj, ignore_nan=True, default=json_util.default)
python
def dump_json(obj): """Dump Python object as JSON string.""" return simplejson.dumps(obj, ignore_nan=True, default=json_util.default)
[ "def", "dump_json", "(", "obj", ")", ":", "return", "simplejson", ".", "dumps", "(", "obj", ",", "ignore_nan", "=", "True", ",", "default", "=", "json_util", ".", "default", ")" ]
Dump Python object as JSON string.
[ "Dump", "Python", "object", "as", "JSON", "string", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/config/jinja_filters.py#L60-L62
train
chovanecm/sacredboard
sacredboard/app/process/process.py
Process.terminate
def terminate(self, wait=False): """Terminate the process.""" if self.proc is not None: self.proc.stdout.close() try: self.proc.terminate() except ProcessLookupError: pass if wait: self.proc.wait()
python
def terminate(self, wait=False): """Terminate the process.""" if self.proc is not None: self.proc.stdout.close() try: self.proc.terminate() except ProcessLookupError: pass if wait: self.proc.wait()
[ "def", "terminate", "(", "self", ",", "wait", "=", "False", ")", ":", "if", "self", ".", "proc", "is", "not", "None", ":", "self", ".", "proc", ".", "stdout", ".", "close", "(", ")", "try", ":", "self", ".", "proc", ".", "terminate", "(", ")", ...
Terminate the process.
[ "Terminate", "the", "process", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/process/process.py#L88-L97
train
chovanecm/sacredboard
sacredboard/app/process/process.py
Process.terminate_all
def terminate_all(wait=False): """ Terminate all processes. :param wait: Wait for each to terminate :type wait: bool :return: :rtype: """ for instance in Process.instances: if instance.is_running(): instance.terminate(wait)
python
def terminate_all(wait=False): """ Terminate all processes. :param wait: Wait for each to terminate :type wait: bool :return: :rtype: """ for instance in Process.instances: if instance.is_running(): instance.terminate(wait)
[ "def", "terminate_all", "(", "wait", "=", "False", ")", ":", "for", "instance", "in", "Process", ".", "instances", ":", "if", "instance", ".", "is_running", "(", ")", ":", "instance", ".", "terminate", "(", "wait", ")" ]
Terminate all processes. :param wait: Wait for each to terminate :type wait: bool :return: :rtype:
[ "Terminate", "all", "processes", "." ]
47e1c99e3be3c1b099d3772bc077f5666020eb0b
https://github.com/chovanecm/sacredboard/blob/47e1c99e3be3c1b099d3772bc077f5666020eb0b/sacredboard/app/process/process.py#L107-L118
train
noahbenson/neuropythy
neuropythy/commands/atlas.py
calc_worklog
def calc_worklog(stdout=Ellipsis, stderr=Ellipsis, verbose=False): ''' calc_worklog constructs the worklog from the stdout, stderr, stdin, and verbose arguments. ''' try: cols = int(os.environ['COLUMNS']) except Exception: cols = 80 return pimms.worklog(columns=cols, stdout=stdout, stderr=stderr...
python
def calc_worklog(stdout=Ellipsis, stderr=Ellipsis, verbose=False): ''' calc_worklog constructs the worklog from the stdout, stderr, stdin, and verbose arguments. ''' try: cols = int(os.environ['COLUMNS']) except Exception: cols = 80 return pimms.worklog(columns=cols, stdout=stdout, stderr=stderr...
[ "def", "calc_worklog", "(", "stdout", "=", "Ellipsis", ",", "stderr", "=", "Ellipsis", ",", "verbose", "=", "False", ")", ":", "try", ":", "cols", "=", "int", "(", "os", ".", "environ", "[", "'COLUMNS'", "]", ")", "except", "Exception", ":", "cols", ...
calc_worklog constructs the worklog from the stdout, stderr, stdin, and verbose arguments.
[ "calc_worklog", "constructs", "the", "worklog", "from", "the", "stdout", "stderr", "stdin", "and", "verbose", "arguments", "." ]
b588889f6db36ddb9602ae4a72c1c0d3f41586b2
https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/commands/atlas.py#L24-L30
train
noahbenson/neuropythy
neuropythy/commands/atlas.py
calc_subject
def calc_subject(argv, worklog): ''' calc_subject converts a subject_id into a subject object. Afferent parameters: @ argv The FreeSurfer subject name(s), HCP subject ID(s), or path(s) of the subject(s) to which the atlas should be applied. ''' if len(argv) == 0: raise ValueEr...
python
def calc_subject(argv, worklog): ''' calc_subject converts a subject_id into a subject object. Afferent parameters: @ argv The FreeSurfer subject name(s), HCP subject ID(s), or path(s) of the subject(s) to which the atlas should be applied. ''' if len(argv) == 0: raise ValueEr...
[ "def", "calc_subject", "(", "argv", ",", "worklog", ")", ":", "if", "len", "(", "argv", ")", "==", "0", ":", "raise", "ValueError", "(", "'No subject-id given'", ")", "elif", "len", "(", "argv", ")", ">", "1", ":", "worklog", ".", "warn", "(", "'WARN...
calc_subject converts a subject_id into a subject object. Afferent parameters: @ argv The FreeSurfer subject name(s), HCP subject ID(s), or path(s) of the subject(s) to which the atlas should be applied.
[ "calc_subject", "converts", "a", "subject_id", "into", "a", "subject", "object", "." ]
b588889f6db36ddb9602ae4a72c1c0d3f41586b2
https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/commands/atlas.py#L32-L56
train
noahbenson/neuropythy
neuropythy/commands/atlas.py
calc_atlases
def calc_atlases(worklog, atlas_subject_id='fsaverage'): ''' cacl_atlases finds all available atlases in the possible subject directories of the given atlas subject. In order to be a template, it must either be a collection of files (either mgh/mgz or FreeSurfer curv/morph-data files) named as '<he...
python
def calc_atlases(worklog, atlas_subject_id='fsaverage'): ''' cacl_atlases finds all available atlases in the possible subject directories of the given atlas subject. In order to be a template, it must either be a collection of files (either mgh/mgz or FreeSurfer curv/morph-data files) named as '<he...
[ "def", "calc_atlases", "(", "worklog", ",", "atlas_subject_id", "=", "'fsaverage'", ")", ":", "try", ":", "sub", "=", "freesurfer_subject", "(", "atlas_subject_id", ")", "except", "Exception", ":", "sub", "=", "None", "if", "sub", "is", "None", ":", "try", ...
cacl_atlases finds all available atlases in the possible subject directories of the given atlas subject. In order to be a template, it must either be a collection of files (either mgh/mgz or FreeSurfer curv/morph-data files) named as '<hemi>.<template>_<quantity><ending>' such as the files 'lh.wang2015...
[ "cacl_atlases", "finds", "all", "available", "atlases", "in", "the", "possible", "subject", "directories", "of", "the", "given", "atlas", "subject", "." ]
b588889f6db36ddb9602ae4a72c1c0d3f41586b2
https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/commands/atlas.py#L58-L116
train
noahbenson/neuropythy
neuropythy/commands/atlas.py
calc_filemap
def calc_filemap(atlas_properties, subject, atlas_version_tags, worklog, output_path=None, overwrite=False, output_format='mgz', create_directory=False): ''' calc_filemap is a calculator that converts the atlas properties nested-map into a single-depth map whose keys are filenames and whose...
python
def calc_filemap(atlas_properties, subject, atlas_version_tags, worklog, output_path=None, overwrite=False, output_format='mgz', create_directory=False): ''' calc_filemap is a calculator that converts the atlas properties nested-map into a single-depth map whose keys are filenames and whose...
[ "def", "calc_filemap", "(", "atlas_properties", ",", "subject", ",", "atlas_version_tags", ",", "worklog", ",", "output_path", "=", "None", ",", "overwrite", "=", "False", ",", "output_format", "=", "'mgz'", ",", "create_directory", "=", "False", ")", ":", "if...
calc_filemap is a calculator that converts the atlas properties nested-map into a single-depth map whose keys are filenames and whose values are the interpolated property data. Afferent parameters @ output_path The directory into which the atlas files should be written. If not provided or None t...
[ "calc_filemap", "is", "a", "calculator", "that", "converts", "the", "atlas", "properties", "nested", "-", "map", "into", "a", "single", "-", "depth", "map", "whose", "keys", "are", "filenames", "and", "whose", "values", "are", "the", "interpolated", "property"...
b588889f6db36ddb9602ae4a72c1c0d3f41586b2
https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/commands/atlas.py#L245-L311
train
noahbenson/neuropythy
neuropythy/mri/images.py
ImageType.parse_type
def parse_type(self, hdat, dataobj=None): ''' Parses the dtype out of the header data or the array, depending on which is given; if both, then the header-data overrides the array; if neither, then np.float32. ''' try: dataobj = dataobj.dataobj except Exception: pass ...
python
def parse_type(self, hdat, dataobj=None): ''' Parses the dtype out of the header data or the array, depending on which is given; if both, then the header-data overrides the array; if neither, then np.float32. ''' try: dataobj = dataobj.dataobj except Exception: pass ...
[ "def", "parse_type", "(", "self", ",", "hdat", ",", "dataobj", "=", "None", ")", ":", "try", ":", "dataobj", "=", "dataobj", ".", "dataobj", "except", "Exception", ":", "pass", "dtype", "=", "np", ".", "asarray", "(", "dataobj", ")", ".", "dtype", "i...
Parses the dtype out of the header data or the array, depending on which is given; if both, then the header-data overrides the array; if neither, then np.float32.
[ "Parses", "the", "dtype", "out", "of", "the", "header", "data", "or", "the", "array", "depending", "on", "which", "is", "given", ";", "if", "both", "then", "the", "header", "-", "data", "overrides", "the", "array", ";", "if", "neither", "then", "np", "...
b588889f6db36ddb9602ae4a72c1c0d3f41586b2
https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/mri/images.py#L54-L64
train
noahbenson/neuropythy
neuropythy/mri/images.py
ImageType.parse_affine
def parse_affine(self, hdat, dataobj=None): ''' Parses the affine out of the given header data and yields it. ''' if 'affine' in hdat: return to_affine(hdat['affine']) else: return to_affine(self.default_affine())
python
def parse_affine(self, hdat, dataobj=None): ''' Parses the affine out of the given header data and yields it. ''' if 'affine' in hdat: return to_affine(hdat['affine']) else: return to_affine(self.default_affine())
[ "def", "parse_affine", "(", "self", ",", "hdat", ",", "dataobj", "=", "None", ")", ":", "if", "'affine'", "in", "hdat", ":", "return", "to_affine", "(", "hdat", "[", "'affine'", "]", ")", "else", ":", "return", "to_affine", "(", "self", ".", "default_a...
Parses the affine out of the given header data and yields it.
[ "Parses", "the", "affine", "out", "of", "the", "given", "header", "data", "and", "yields", "it", "." ]
b588889f6db36ddb9602ae4a72c1c0d3f41586b2
https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/mri/images.py#L66-L71
train
noahbenson/neuropythy
neuropythy/registration/core.py
_parse_field_arguments
def _parse_field_arguments(arg, faces, edges, coords): '''See mesh_register.''' if not hasattr(arg, '__iter__'): raise RuntimeError('field argument must be a list-like collection of instructions') pot = [_parse_field_argument(instruct, faces, edges, coords) for instruct in arg] # make a new Pote...
python
def _parse_field_arguments(arg, faces, edges, coords): '''See mesh_register.''' if not hasattr(arg, '__iter__'): raise RuntimeError('field argument must be a list-like collection of instructions') pot = [_parse_field_argument(instruct, faces, edges, coords) for instruct in arg] # make a new Pote...
[ "def", "_parse_field_arguments", "(", "arg", ",", "faces", ",", "edges", ",", "coords", ")", ":", "if", "not", "hasattr", "(", "arg", ",", "'__iter__'", ")", ":", "raise", "RuntimeError", "(", "'field argument must be a list-like collection of instructions'", ")", ...
See mesh_register.
[ "See", "mesh_register", "." ]
b588889f6db36ddb9602ae4a72c1c0d3f41586b2
https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/registration/core.py#L96-L107
train
noahbenson/neuropythy
neuropythy/graphics/core.py
retino_colors
def retino_colors(vcolorfn, *args, **kwargs): 'See eccen_colors, angle_colors, sigma_colors, and varea_colors.' if len(args) == 0: def _retino_color_pass(*args, **new_kwargs): return retino_colors(vcolorfn, *args, **{k:(new_kwargs[k] if k in new_kwargs else k...
python
def retino_colors(vcolorfn, *args, **kwargs): 'See eccen_colors, angle_colors, sigma_colors, and varea_colors.' if len(args) == 0: def _retino_color_pass(*args, **new_kwargs): return retino_colors(vcolorfn, *args, **{k:(new_kwargs[k] if k in new_kwargs else k...
[ "def", "retino_colors", "(", "vcolorfn", ",", "*", "args", ",", "**", "kwargs", ")", ":", "'See eccen_colors, angle_colors, sigma_colors, and varea_colors.'", "if", "len", "(", "args", ")", "==", "0", ":", "def", "_retino_color_pass", "(", "*", "args", ",", "**"...
See eccen_colors, angle_colors, sigma_colors, and varea_colors.
[ "See", "eccen_colors", "angle_colors", "sigma_colors", "and", "varea_colors", "." ]
b588889f6db36ddb9602ae4a72c1c0d3f41586b2
https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/graphics/core.py#L482-L516
train
noahbenson/neuropythy
neuropythy/hcp/files.py
_load_fsLR_atlasroi
def _load_fsLR_atlasroi(filename, data): ''' Loads the appropriate atlas for the given data; data may point to a cifti file whose atlas is needed or to an atlas file. ''' (fdir, fnm) = os.path.split(filename) fparts = fnm.split('.') atl = fparts[-3] if atl in _load_fsLR_atlasroi.atlases:...
python
def _load_fsLR_atlasroi(filename, data): ''' Loads the appropriate atlas for the given data; data may point to a cifti file whose atlas is needed or to an atlas file. ''' (fdir, fnm) = os.path.split(filename) fparts = fnm.split('.') atl = fparts[-3] if atl in _load_fsLR_atlasroi.atlases:...
[ "def", "_load_fsLR_atlasroi", "(", "filename", ",", "data", ")", ":", "(", "fdir", ",", "fnm", ")", "=", "os", ".", "path", ".", "split", "(", "filename", ")", "fparts", "=", "fnm", ".", "split", "(", "'.'", ")", "atl", "=", "fparts", "[", "-", "...
Loads the appropriate atlas for the given data; data may point to a cifti file whose atlas is needed or to an atlas file.
[ "Loads", "the", "appropriate", "atlas", "for", "the", "given", "data", ";", "data", "may", "point", "to", "a", "cifti", "file", "whose", "atlas", "is", "needed", "or", "to", "an", "atlas", "file", "." ]
b588889f6db36ddb9602ae4a72c1c0d3f41586b2
https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/hcp/files.py#L248-L268
train
noahbenson/neuropythy
neuropythy/hcp/files.py
_load_fsLR_atlasroi_for_size
def _load_fsLR_atlasroi_for_size(size, sid=100610): ''' Loads the appropriate atlas for the given size of data; size should be the number of stored vertices and sub-corticel voxels stored in the cifti file. ''' from .core import subject # it doesn't matter what subject we request, so just use an...
python
def _load_fsLR_atlasroi_for_size(size, sid=100610): ''' Loads the appropriate atlas for the given size of data; size should be the number of stored vertices and sub-corticel voxels stored in the cifti file. ''' from .core import subject # it doesn't matter what subject we request, so just use an...
[ "def", "_load_fsLR_atlasroi_for_size", "(", "size", ",", "sid", "=", "100610", ")", ":", "from", ".", "core", "import", "subject", "fls", "=", "_load_fsLR_atlasroi_for_size", ".", "sizes", "if", "size", "not", "in", "fls", ":", "raise", "ValueError", "(", "'...
Loads the appropriate atlas for the given size of data; size should be the number of stored vertices and sub-corticel voxels stored in the cifti file.
[ "Loads", "the", "appropriate", "atlas", "for", "the", "given", "size", "of", "data", ";", "size", "should", "be", "the", "number", "of", "stored", "vertices", "and", "sub", "-", "corticel", "voxels", "stored", "in", "the", "cifti", "file", "." ]
b588889f6db36ddb9602ae4a72c1c0d3f41586b2
https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/hcp/files.py#L270-L282
train
noahbenson/neuropythy
neuropythy/commands/register_retinotopy.py
calc_arguments
def calc_arguments(args): ''' calc_arguments is a calculator that parses the command-line arguments for the registration command and produces the subject, the model, the log function, and the additional options. ''' (args, opts) = _retinotopy_parser(args) # We do some of the options right here.....
python
def calc_arguments(args): ''' calc_arguments is a calculator that parses the command-line arguments for the registration command and produces the subject, the model, the log function, and the additional options. ''' (args, opts) = _retinotopy_parser(args) # We do some of the options right here.....
[ "def", "calc_arguments", "(", "args", ")", ":", "(", "args", ",", "opts", ")", "=", "_retinotopy_parser", "(", "args", ")", "if", "opts", "[", "'help'", "]", ":", "print", "(", "info", ",", "file", "=", "sys", ".", "stdout", ")", "sys", ".", "exit"...
calc_arguments is a calculator that parses the command-line arguments for the registration command and produces the subject, the model, the log function, and the additional options.
[ "calc_arguments", "is", "a", "calculator", "that", "parses", "the", "command", "-", "line", "arguments", "for", "the", "registration", "command", "and", "produces", "the", "subject", "the", "model", "the", "log", "function", "and", "the", "additional", "options"...
b588889f6db36ddb9602ae4a72c1c0d3f41586b2
https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/commands/register_retinotopy.py#L305-L361
train
noahbenson/neuropythy
neuropythy/commands/register_retinotopy.py
calc_retinotopy
def calc_retinotopy(note, error, subject, clean, run_lh, run_rh, invert_rh_angle, max_in_eccen, min_in_eccen, angle_lh_file, theta_lh_file, eccen_lh_file, rho_lh_file, weight_lh_file, radius_lh_file, angle_rh_file, theta...
python
def calc_retinotopy(note, error, subject, clean, run_lh, run_rh, invert_rh_angle, max_in_eccen, min_in_eccen, angle_lh_file, theta_lh_file, eccen_lh_file, rho_lh_file, weight_lh_file, radius_lh_file, angle_rh_file, theta...
[ "def", "calc_retinotopy", "(", "note", ",", "error", ",", "subject", ",", "clean", ",", "run_lh", ",", "run_rh", ",", "invert_rh_angle", ",", "max_in_eccen", ",", "min_in_eccen", ",", "angle_lh_file", ",", "theta_lh_file", ",", "eccen_lh_file", ",", "rho_lh_file...
calc_retinotopy extracts the retinotopy options from the command line, loads the relevant files, and stores them as properties on the subject's lh and rh cortices.
[ "calc_retinotopy", "extracts", "the", "retinotopy", "options", "from", "the", "command", "line", "loads", "the", "relevant", "files", "and", "stores", "them", "as", "properties", "on", "the", "subject", "s", "lh", "and", "rh", "cortices", "." ]
b588889f6db36ddb9602ae4a72c1c0d3f41586b2
https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/commands/register_retinotopy.py#L363-L431
train
noahbenson/neuropythy
neuropythy/commands/register_retinotopy.py
calc_registrations
def calc_registrations(note, error, cortices, model, model_sym, weight_min, scale, prior, max_out_eccen, max_steps, max_step_size, radius_weight, field_sign_weight, resample, invert_rh_angle, part_vol_correct): ''' calc_registrations is the ca...
python
def calc_registrations(note, error, cortices, model, model_sym, weight_min, scale, prior, max_out_eccen, max_steps, max_step_size, radius_weight, field_sign_weight, resample, invert_rh_angle, part_vol_correct): ''' calc_registrations is the ca...
[ "def", "calc_registrations", "(", "note", ",", "error", ",", "cortices", ",", "model", ",", "model_sym", ",", "weight_min", ",", "scale", ",", "prior", ",", "max_out_eccen", ",", "max_steps", ",", "max_step_size", ",", "radius_weight", ",", "field_sign_weight", ...
calc_registrations is the calculator that performs the registrations for the left and right hemisphere; these are returned as the immutable maps yielded from the register_retinotopy command.
[ "calc_registrations", "is", "the", "calculator", "that", "performs", "the", "registrations", "for", "the", "left", "and", "right", "hemisphere", ";", "these", "are", "returned", "as", "the", "immutable", "maps", "yielded", "from", "the", "register_retinotopy", "co...
b588889f6db36ddb9602ae4a72c1c0d3f41586b2
https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/commands/register_retinotopy.py#L433-L466
train
noahbenson/neuropythy
neuropythy/commands/register_retinotopy.py
save_surface_files
def save_surface_files(note, error, registrations, subject, no_surf_export, no_reg_export, surface_format, surface_path, angle_tag, eccen_tag, label_tag, radius_tag, registration_name): ''' save_surface_files is the calculator that saves the registration data out as...
python
def save_surface_files(note, error, registrations, subject, no_surf_export, no_reg_export, surface_format, surface_path, angle_tag, eccen_tag, label_tag, radius_tag, registration_name): ''' save_surface_files is the calculator that saves the registration data out as...
[ "def", "save_surface_files", "(", "note", ",", "error", ",", "registrations", ",", "subject", ",", "no_surf_export", ",", "no_reg_export", ",", "surface_format", ",", "surface_path", ",", "angle_tag", ",", "eccen_tag", ",", "label_tag", ",", "radius_tag", ",", "...
save_surface_files is the calculator that saves the registration data out as surface files, which are put back in the registration as the value 'surface_files'.
[ "save_surface_files", "is", "the", "calculator", "that", "saves", "the", "registration", "data", "out", "as", "surface", "files", "which", "are", "put", "back", "in", "the", "registration", "as", "the", "value", "surface_files", "." ]
b588889f6db36ddb9602ae4a72c1c0d3f41586b2
https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/commands/register_retinotopy.py#L468-L515
train
noahbenson/neuropythy
neuropythy/commands/register_retinotopy.py
save_volume_files
def save_volume_files(note, error, registrations, subject, no_vol_export, volume_format, volume_path, angle_tag, eccen_tag, label_tag, radius_tag): ''' save_volume_files is the calculator that saves the registration data out as volume files, which are put back in ...
python
def save_volume_files(note, error, registrations, subject, no_vol_export, volume_format, volume_path, angle_tag, eccen_tag, label_tag, radius_tag): ''' save_volume_files is the calculator that saves the registration data out as volume files, which are put back in ...
[ "def", "save_volume_files", "(", "note", ",", "error", ",", "registrations", ",", "subject", ",", "no_vol_export", ",", "volume_format", ",", "volume_path", ",", "angle_tag", ",", "eccen_tag", ",", "label_tag", ",", "radius_tag", ")", ":", "if", "no_vol_export",...
save_volume_files is the calculator that saves the registration data out as volume files, which are put back in the registration as the value 'volume_files'.
[ "save_volume_files", "is", "the", "calculator", "that", "saves", "the", "registration", "data", "out", "as", "volume", "files", "which", "are", "put", "back", "in", "the", "registration", "as", "the", "value", "volume_files", "." ]
b588889f6db36ddb9602ae4a72c1c0d3f41586b2
https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/commands/register_retinotopy.py#L517-L559
train
noahbenson/neuropythy
neuropythy/vision/retinotopy.py
calc_empirical_retinotopy
def calc_empirical_retinotopy(cortex, polar_angle=None, eccentricity=None, pRF_radius=None, weight=None, eccentricity_range=None, weight_min=0, invert_rh_angle=False, partial_voluming_correction=False...
python
def calc_empirical_retinotopy(cortex, polar_angle=None, eccentricity=None, pRF_radius=None, weight=None, eccentricity_range=None, weight_min=0, invert_rh_angle=False, partial_voluming_correction=False...
[ "def", "calc_empirical_retinotopy", "(", "cortex", ",", "polar_angle", "=", "None", ",", "eccentricity", "=", "None", ",", "pRF_radius", "=", "None", ",", "weight", "=", "None", ",", "eccentricity_range", "=", "None", ",", "weight_min", "=", "0", ",", "inver...
calc_empirical_retinotopy computes the value empirical_retinotopy, which is an itable object storing the retinotopy data for the registration. Required afferent parameters: @ cortex Must be the cortex object that is to be registered to the model of retinotopy. Optional afferent parameters: ...
[ "calc_empirical_retinotopy", "computes", "the", "value", "empirical_retinotopy", "which", "is", "an", "itable", "object", "storing", "the", "retinotopy", "data", "for", "the", "registration", "." ]
b588889f6db36ddb9602ae4a72c1c0d3f41586b2
https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/vision/retinotopy.py#L1051-L1117
train
noahbenson/neuropythy
neuropythy/vision/retinotopy.py
calc_model
def calc_model(cortex, model_argument, model_hemi=Ellipsis, radius=np.pi/3): ''' calc_model loads the appropriate model object given the model argument, which may given the name of the model or a model object itself. Required afferent parameters: @ model_argument Must be either a RegisteredRetino...
python
def calc_model(cortex, model_argument, model_hemi=Ellipsis, radius=np.pi/3): ''' calc_model loads the appropriate model object given the model argument, which may given the name of the model or a model object itself. Required afferent parameters: @ model_argument Must be either a RegisteredRetino...
[ "def", "calc_model", "(", "cortex", ",", "model_argument", ",", "model_hemi", "=", "Ellipsis", ",", "radius", "=", "np", ".", "pi", "/", "3", ")", ":", "if", "pimms", ".", "is_str", "(", "model_argument", ")", ":", "h", "=", "cortex", ".", "chirality",...
calc_model loads the appropriate model object given the model argument, which may given the name of the model or a model object itself. Required afferent parameters: @ model_argument Must be either a RegisteredRetinotopyModel object or the name of a model that can be loaded. Optional afferen...
[ "calc_model", "loads", "the", "appropriate", "model", "object", "given", "the", "model", "argument", "which", "may", "given", "the", "name", "of", "the", "model", "or", "a", "model", "object", "itself", "." ]
b588889f6db36ddb9602ae4a72c1c0d3f41586b2
https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/vision/retinotopy.py#L1119-L1145
train
noahbenson/neuropythy
neuropythy/vision/retinotopy.py
calc_anchors
def calc_anchors(preregistration_map, model, model_hemi, scale=1, sigma=Ellipsis, radius_weight=0, field_sign_weight=0, invert_rh_field_sign=False): ''' calc_anchors is a calculator that creates a set of anchor instructions for a registration. Required afferent parameters:...
python
def calc_anchors(preregistration_map, model, model_hemi, scale=1, sigma=Ellipsis, radius_weight=0, field_sign_weight=0, invert_rh_field_sign=False): ''' calc_anchors is a calculator that creates a set of anchor instructions for a registration. Required afferent parameters:...
[ "def", "calc_anchors", "(", "preregistration_map", ",", "model", ",", "model_hemi", ",", "scale", "=", "1", ",", "sigma", "=", "Ellipsis", ",", "radius_weight", "=", "0", ",", "field_sign_weight", "=", "0", ",", "invert_rh_field_sign", "=", "False", ")", ":"...
calc_anchors is a calculator that creates a set of anchor instructions for a registration. Required afferent parameters: @ invert_rh_field_sign May be set to True (default is False) to indicate that the right hemisphere's field signs will be incorrect relative to the model; this generally should be ...
[ "calc_anchors", "is", "a", "calculator", "that", "creates", "a", "set", "of", "anchor", "instructions", "for", "a", "registration", "." ]
b588889f6db36ddb9602ae4a72c1c0d3f41586b2
https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/vision/retinotopy.py#L1212-L1236
train
noahbenson/neuropythy
neuropythy/vision/retinotopy.py
calc_registration
def calc_registration(preregistration_map, anchors, max_steps=2000, max_step_size=0.05, method='random'): ''' calc_registration is a calculator that creates the registration coordinates. ''' # if max steps is a tuple (max, stride) then a trajectory is saved into # the registere...
python
def calc_registration(preregistration_map, anchors, max_steps=2000, max_step_size=0.05, method='random'): ''' calc_registration is a calculator that creates the registration coordinates. ''' # if max steps is a tuple (max, stride) then a trajectory is saved into # the registere...
[ "def", "calc_registration", "(", "preregistration_map", ",", "anchors", ",", "max_steps", "=", "2000", ",", "max_step_size", "=", "0.05", ",", "method", "=", "'random'", ")", ":", "pmap", "=", "preregistration_map", "if", "is_tuple", "(", "max_steps", ")", "or...
calc_registration is a calculator that creates the registration coordinates.
[ "calc_registration", "is", "a", "calculator", "that", "creates", "the", "registration", "coordinates", "." ]
b588889f6db36ddb9602ae4a72c1c0d3f41586b2
https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/vision/retinotopy.py#L1239-L1274
train
noahbenson/neuropythy
neuropythy/vision/retinotopy.py
calc_prediction
def calc_prediction(registered_map, preregistration_mesh, native_mesh, model): ''' calc_registration_prediction is a pimms calculator that creates the both the prediction and the registration_prediction, both of which are pimms itables including the fields 'polar_angle', 'eccentricity', and 'visual_area...
python
def calc_prediction(registered_map, preregistration_mesh, native_mesh, model): ''' calc_registration_prediction is a pimms calculator that creates the both the prediction and the registration_prediction, both of which are pimms itables including the fields 'polar_angle', 'eccentricity', and 'visual_area...
[ "def", "calc_prediction", "(", "registered_map", ",", "preregistration_mesh", ",", "native_mesh", ",", "model", ")", ":", "coords3d", "=", "np", ".", "array", "(", "preregistration_mesh", ".", "coordinates", ")", "idcs", "=", "registered_map", ".", "labels", "co...
calc_registration_prediction is a pimms calculator that creates the both the prediction and the registration_prediction, both of which are pimms itables including the fields 'polar_angle', 'eccentricity', and 'visual_area'. The registration_prediction data describe the vertices for the registered_map, not n...
[ "calc_registration_prediction", "is", "a", "pimms", "calculator", "that", "creates", "the", "both", "the", "prediction", "and", "the", "registration_prediction", "both", "of", "which", "are", "pimms", "itables", "including", "the", "fields", "polar_angle", "eccentrici...
b588889f6db36ddb9602ae4a72c1c0d3f41586b2
https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/vision/retinotopy.py#L1276-L1338
train
barnumbirr/coinmarketcap
coinmarketcap/core.py
Market.ticker
def ticker(self, currency="", **kwargs): """ This endpoint displays cryptocurrency ticker data in order of rank. The maximum number of results per call is 100. Pagination is possible by using the start and limit parameters. GET /ticker/ Optional parameters: (int) start - return results from rank [sta...
python
def ticker(self, currency="", **kwargs): """ This endpoint displays cryptocurrency ticker data in order of rank. The maximum number of results per call is 100. Pagination is possible by using the start and limit parameters. GET /ticker/ Optional parameters: (int) start - return results from rank [sta...
[ "def", "ticker", "(", "self", ",", "currency", "=", "\"\"", ",", "**", "kwargs", ")", ":", "params", "=", "{", "}", "params", ".", "update", "(", "kwargs", ")", "if", "currency", ":", "currency", "=", "str", "(", "currency", ")", "+", "'/'", "respo...
This endpoint displays cryptocurrency ticker data in order of rank. The maximum number of results per call is 100. Pagination is possible by using the start and limit parameters. GET /ticker/ Optional parameters: (int) start - return results from rank [start] and above (default is 1) (int) limit - r...
[ "This", "endpoint", "displays", "cryptocurrency", "ticker", "data", "in", "order", "of", "rank", ".", "The", "maximum", "number", "of", "results", "per", "call", "is", "100", ".", "Pagination", "is", "possible", "by", "using", "the", "start", "and", "limit",...
d1d76a73bc48a64a4c2883dd28c6199bfbd3ebc6
https://github.com/barnumbirr/coinmarketcap/blob/d1d76a73bc48a64a4c2883dd28c6199bfbd3ebc6/coinmarketcap/core.py#L59-L96
train
HHammond/PrettyPandas
prettypandas/formatters.py
_surpress_formatting_errors
def _surpress_formatting_errors(fn): """ I know this is dangerous and the wrong way to solve the problem, but when using both row and columns summaries it's easier to just swallow errors so users can format their tables how they need. """ @wraps(fn) def inner(*args, **kwargs): try: ...
python
def _surpress_formatting_errors(fn): """ I know this is dangerous and the wrong way to solve the problem, but when using both row and columns summaries it's easier to just swallow errors so users can format their tables how they need. """ @wraps(fn) def inner(*args, **kwargs): try: ...
[ "def", "_surpress_formatting_errors", "(", "fn", ")", ":", "@", "wraps", "(", "fn", ")", "def", "inner", "(", "*", "args", ",", "**", "kwargs", ")", ":", "try", ":", "return", "fn", "(", "*", "args", ",", "**", "kwargs", ")", "except", "ValueError", ...
I know this is dangerous and the wrong way to solve the problem, but when using both row and columns summaries it's easier to just swallow errors so users can format their tables how they need.
[ "I", "know", "this", "is", "dangerous", "and", "the", "wrong", "way", "to", "solve", "the", "problem", "but", "when", "using", "both", "row", "and", "columns", "summaries", "it", "s", "easier", "to", "just", "swallow", "errors", "so", "users", "can", "fo...
99a814ffc3aa61f66eaf902afaa4b7802518d33a
https://github.com/HHammond/PrettyPandas/blob/99a814ffc3aa61f66eaf902afaa4b7802518d33a/prettypandas/formatters.py#L12-L24
train
HHammond/PrettyPandas
prettypandas/formatters.py
_format_numer
def _format_numer(number_format, prefix='', suffix=''): """Format a number to a string.""" @_surpress_formatting_errors def inner(v): if isinstance(v, Number): return ("{{}}{{:{}}}{{}}" .format(number_format) .format(prefix, v, suffix)) els...
python
def _format_numer(number_format, prefix='', suffix=''): """Format a number to a string.""" @_surpress_formatting_errors def inner(v): if isinstance(v, Number): return ("{{}}{{:{}}}{{}}" .format(number_format) .format(prefix, v, suffix)) els...
[ "def", "_format_numer", "(", "number_format", ",", "prefix", "=", "''", ",", "suffix", "=", "''", ")", ":", "@", "_surpress_formatting_errors", "def", "inner", "(", "v", ")", ":", "if", "isinstance", "(", "v", ",", "Number", ")", ":", "return", "(", "\...
Format a number to a string.
[ "Format", "a", "number", "to", "a", "string", "." ]
99a814ffc3aa61f66eaf902afaa4b7802518d33a
https://github.com/HHammond/PrettyPandas/blob/99a814ffc3aa61f66eaf902afaa4b7802518d33a/prettypandas/formatters.py#L27-L37
train
HHammond/PrettyPandas
prettypandas/formatters.py
as_percent
def as_percent(precision=2, **kwargs): """Convert number to percentage string. Parameters: ----------- :param v: numerical value to be converted :param precision: int decimal places to round to """ if not isinstance(precision, Integral): raise TypeError("Precision must be an...
python
def as_percent(precision=2, **kwargs): """Convert number to percentage string. Parameters: ----------- :param v: numerical value to be converted :param precision: int decimal places to round to """ if not isinstance(precision, Integral): raise TypeError("Precision must be an...
[ "def", "as_percent", "(", "precision", "=", "2", ",", "**", "kwargs", ")", ":", "if", "not", "isinstance", "(", "precision", ",", "Integral", ")", ":", "raise", "TypeError", "(", "\"Precision must be an integer.\"", ")", "return", "_surpress_formatting_errors", ...
Convert number to percentage string. Parameters: ----------- :param v: numerical value to be converted :param precision: int decimal places to round to
[ "Convert", "number", "to", "percentage", "string", "." ]
99a814ffc3aa61f66eaf902afaa4b7802518d33a
https://github.com/HHammond/PrettyPandas/blob/99a814ffc3aa61f66eaf902afaa4b7802518d33a/prettypandas/formatters.py#L40-L54
train
HHammond/PrettyPandas
prettypandas/formatters.py
as_unit
def as_unit(unit, precision=2, location='suffix'): """Convert value to unit. Parameters: ----------- :param v: numerical value :param unit: string of unit :param precision: int decimal places to round to :param location: 'prefix' or 'suffix' representing where the currency s...
python
def as_unit(unit, precision=2, location='suffix'): """Convert value to unit. Parameters: ----------- :param v: numerical value :param unit: string of unit :param precision: int decimal places to round to :param location: 'prefix' or 'suffix' representing where the currency s...
[ "def", "as_unit", "(", "unit", ",", "precision", "=", "2", ",", "location", "=", "'suffix'", ")", ":", "if", "not", "isinstance", "(", "precision", ",", "Integral", ")", ":", "raise", "TypeError", "(", "\"Precision must be an integer.\"", ")", "if", "locatio...
Convert value to unit. Parameters: ----------- :param v: numerical value :param unit: string of unit :param precision: int decimal places to round to :param location: 'prefix' or 'suffix' representing where the currency symbol falls relative to the value
[ "Convert", "value", "to", "unit", "." ]
99a814ffc3aa61f66eaf902afaa4b7802518d33a
https://github.com/HHammond/PrettyPandas/blob/99a814ffc3aa61f66eaf902afaa4b7802518d33a/prettypandas/formatters.py#L57-L82
train
HHammond/PrettyPandas
prettypandas/summarizer.py
Aggregate.apply
def apply(self, df): """Compute aggregate over DataFrame""" if self.subset: if _axis_is_rows(self.axis): df = df[self.subset] if _axis_is_cols(self.axis): df = df.loc[self.subset] result = df.agg(self.func, axis=self.axis, *self.args, **s...
python
def apply(self, df): """Compute aggregate over DataFrame""" if self.subset: if _axis_is_rows(self.axis): df = df[self.subset] if _axis_is_cols(self.axis): df = df.loc[self.subset] result = df.agg(self.func, axis=self.axis, *self.args, **s...
[ "def", "apply", "(", "self", ",", "df", ")", ":", "if", "self", ".", "subset", ":", "if", "_axis_is_rows", "(", "self", ".", "axis", ")", ":", "df", "=", "df", "[", "self", ".", "subset", "]", "if", "_axis_is_cols", "(", "self", ".", "axis", ")",...
Compute aggregate over DataFrame
[ "Compute", "aggregate", "over", "DataFrame" ]
99a814ffc3aa61f66eaf902afaa4b7802518d33a
https://github.com/HHammond/PrettyPandas/blob/99a814ffc3aa61f66eaf902afaa4b7802518d33a/prettypandas/summarizer.py#L53-L64
train
HHammond/PrettyPandas
prettypandas/summarizer.py
Formatter.apply
def apply(self, styler): """Apply Summary over Pandas Styler""" return styler.format(self.formatter, *self.args, **self.kwargs)
python
def apply(self, styler): """Apply Summary over Pandas Styler""" return styler.format(self.formatter, *self.args, **self.kwargs)
[ "def", "apply", "(", "self", ",", "styler", ")", ":", "return", "styler", ".", "format", "(", "self", ".", "formatter", ",", "*", "self", ".", "args", ",", "**", "self", ".", "kwargs", ")" ]
Apply Summary over Pandas Styler
[ "Apply", "Summary", "over", "Pandas", "Styler" ]
99a814ffc3aa61f66eaf902afaa4b7802518d33a
https://github.com/HHammond/PrettyPandas/blob/99a814ffc3aa61f66eaf902afaa4b7802518d33a/prettypandas/summarizer.py#L85-L87
train
HHammond/PrettyPandas
prettypandas/summarizer.py
PrettyPandas._apply_summaries
def _apply_summaries(self): """Add all summary rows and columns.""" def as_frame(r): if isinstance(r, pd.Series): return r.to_frame() else: return r df = self.data if df.index.nlevels > 1: raise ValueError( ...
python
def _apply_summaries(self): """Add all summary rows and columns.""" def as_frame(r): if isinstance(r, pd.Series): return r.to_frame() else: return r df = self.data if df.index.nlevels > 1: raise ValueError( ...
[ "def", "_apply_summaries", "(", "self", ")", ":", "def", "as_frame", "(", "r", ")", ":", "if", "isinstance", "(", "r", ",", "pd", ".", "Series", ")", ":", "return", "r", ".", "to_frame", "(", ")", "else", ":", "return", "r", "df", "=", "self", "....
Add all summary rows and columns.
[ "Add", "all", "summary", "rows", "and", "columns", "." ]
99a814ffc3aa61f66eaf902afaa4b7802518d33a
https://github.com/HHammond/PrettyPandas/blob/99a814ffc3aa61f66eaf902afaa4b7802518d33a/prettypandas/summarizer.py#L162-L190
train
HHammond/PrettyPandas
prettypandas/summarizer.py
PrettyPandas.style
def style(self): """Add summaries and convert to Pandas Styler""" row_titles = [a.title for a in self._cleaned_summary_rows] col_titles = [a.title for a in self._cleaned_summary_cols] row_ix = pd.IndexSlice[row_titles, :] col_ix = pd.IndexSlice[:, col_titles] def handle_...
python
def style(self): """Add summaries and convert to Pandas Styler""" row_titles = [a.title for a in self._cleaned_summary_rows] col_titles = [a.title for a in self._cleaned_summary_cols] row_ix = pd.IndexSlice[row_titles, :] col_ix = pd.IndexSlice[:, col_titles] def handle_...
[ "def", "style", "(", "self", ")", ":", "row_titles", "=", "[", "a", ".", "title", "for", "a", "in", "self", ".", "_cleaned_summary_rows", "]", "col_titles", "=", "[", "a", ".", "title", "for", "a", "in", "self", ".", "_cleaned_summary_cols", "]", "row_...
Add summaries and convert to Pandas Styler
[ "Add", "summaries", "and", "convert", "to", "Pandas", "Styler" ]
99a814ffc3aa61f66eaf902afaa4b7802518d33a
https://github.com/HHammond/PrettyPandas/blob/99a814ffc3aa61f66eaf902afaa4b7802518d33a/prettypandas/summarizer.py#L202-L226
train
HHammond/PrettyPandas
prettypandas/summarizer.py
PrettyPandas.summary
def summary(self, func=methodcaller('sum'), title='Total', axis=0, subset=None, *args, **kwargs): """Add multiple summary rows or columns to the dataframe. Parameters ---------- :param func: ...
python
def summary(self, func=methodcaller('sum'), title='Total', axis=0, subset=None, *args, **kwargs): """Add multiple summary rows or columns to the dataframe. Parameters ---------- :param func: ...
[ "def", "summary", "(", "self", ",", "func", "=", "methodcaller", "(", "'sum'", ")", ",", "title", "=", "'Total'", ",", "axis", "=", "0", ",", "subset", "=", "None", ",", "*", "args", ",", "**", "kwargs", ")", ":", "if", "axis", "is", "None", ":",...
Add multiple summary rows or columns to the dataframe. Parameters ---------- :param func: function to be used for a summary. :param titles: Title for this summary column. :param axis: Same as numpy and pandas axis argument. A value of None will cause the ...
[ "Add", "multiple", "summary", "rows", "or", "columns", "to", "the", "dataframe", "." ]
99a814ffc3aa61f66eaf902afaa4b7802518d33a
https://github.com/HHammond/PrettyPandas/blob/99a814ffc3aa61f66eaf902afaa4b7802518d33a/prettypandas/summarizer.py#L240-L285
train
HHammond/PrettyPandas
prettypandas/summarizer.py
PrettyPandas.as_percent
def as_percent(self, precision=2, *args, **kwargs): """Format subset as percentages :param precision: Decimal precision :param subset: Pandas subset """ f = Formatter(as_percent(precision), args, kwargs) return self._add_formatter(f)
python
def as_percent(self, precision=2, *args, **kwargs): """Format subset as percentages :param precision: Decimal precision :param subset: Pandas subset """ f = Formatter(as_percent(precision), args, kwargs) return self._add_formatter(f)
[ "def", "as_percent", "(", "self", ",", "precision", "=", "2", ",", "*", "args", ",", "**", "kwargs", ")", ":", "f", "=", "Formatter", "(", "as_percent", "(", "precision", ")", ",", "args", ",", "kwargs", ")", "return", "self", ".", "_add_formatter", ...
Format subset as percentages :param precision: Decimal precision :param subset: Pandas subset
[ "Format", "subset", "as", "percentages" ]
99a814ffc3aa61f66eaf902afaa4b7802518d33a
https://github.com/HHammond/PrettyPandas/blob/99a814ffc3aa61f66eaf902afaa4b7802518d33a/prettypandas/summarizer.py#L335-L342
train
HHammond/PrettyPandas
prettypandas/summarizer.py
PrettyPandas.as_currency
def as_currency(self, currency='USD', locale=LOCALE_OBJ, *args, **kwargs): """Format subset as currency :param currency: Currency :param locale: Babel locale for currency formatting :param subset: Pandas subset """ f = Formatter( as_currency(currency=currency...
python
def as_currency(self, currency='USD', locale=LOCALE_OBJ, *args, **kwargs): """Format subset as currency :param currency: Currency :param locale: Babel locale for currency formatting :param subset: Pandas subset """ f = Formatter( as_currency(currency=currency...
[ "def", "as_currency", "(", "self", ",", "currency", "=", "'USD'", ",", "locale", "=", "LOCALE_OBJ", ",", "*", "args", ",", "**", "kwargs", ")", ":", "f", "=", "Formatter", "(", "as_currency", "(", "currency", "=", "currency", ",", "locale", "=", "local...
Format subset as currency :param currency: Currency :param locale: Babel locale for currency formatting :param subset: Pandas subset
[ "Format", "subset", "as", "currency" ]
99a814ffc3aa61f66eaf902afaa4b7802518d33a
https://github.com/HHammond/PrettyPandas/blob/99a814ffc3aa61f66eaf902afaa4b7802518d33a/prettypandas/summarizer.py#L344-L356
train
HHammond/PrettyPandas
prettypandas/summarizer.py
PrettyPandas.as_unit
def as_unit(self, unit, location='suffix', *args, **kwargs): """Format subset as with units :param unit: string to use as unit :param location: prefix or suffix :param subset: Pandas subset """ f = Formatter( as_unit(unit, location=location), args...
python
def as_unit(self, unit, location='suffix', *args, **kwargs): """Format subset as with units :param unit: string to use as unit :param location: prefix or suffix :param subset: Pandas subset """ f = Formatter( as_unit(unit, location=location), args...
[ "def", "as_unit", "(", "self", ",", "unit", ",", "location", "=", "'suffix'", ",", "*", "args", ",", "**", "kwargs", ")", ":", "f", "=", "Formatter", "(", "as_unit", "(", "unit", ",", "location", "=", "location", ")", ",", "args", ",", "kwargs", ")...
Format subset as with units :param unit: string to use as unit :param location: prefix or suffix :param subset: Pandas subset
[ "Format", "subset", "as", "with", "units" ]
99a814ffc3aa61f66eaf902afaa4b7802518d33a
https://github.com/HHammond/PrettyPandas/blob/99a814ffc3aa61f66eaf902afaa4b7802518d33a/prettypandas/summarizer.py#L358-L370
train
TUT-ARG/sed_eval
sed_eval/sound_event.py
EventBasedMetrics.validate_onset
def validate_onset(reference_event, estimated_event, t_collar=0.200): """Validate estimated event based on event onset Parameters ---------- reference_event : dict Reference event. estimated_event: dict Estimated event. t_collar : float > 0, sec...
python
def validate_onset(reference_event, estimated_event, t_collar=0.200): """Validate estimated event based on event onset Parameters ---------- reference_event : dict Reference event. estimated_event: dict Estimated event. t_collar : float > 0, sec...
[ "def", "validate_onset", "(", "reference_event", ",", "estimated_event", ",", "t_collar", "=", "0.200", ")", ":", "if", "'event_onset'", "in", "reference_event", "and", "'event_onset'", "in", "estimated_event", ":", "return", "math", ".", "fabs", "(", "reference_e...
Validate estimated event based on event onset Parameters ---------- reference_event : dict Reference event. estimated_event: dict Estimated event. t_collar : float > 0, seconds Time collar with which the estimated onset has to be in order to...
[ "Validate", "estimated", "event", "based", "on", "event", "onset" ]
0cb1b6d11ceec4fe500cc9b31079c9d8666ed6eb
https://github.com/TUT-ARG/sed_eval/blob/0cb1b6d11ceec4fe500cc9b31079c9d8666ed6eb/sed_eval/sound_event.py#L1604-L1630
train