id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
40,300
trevisanj/f311
f311/explorer/gui/a_XFileMainWindow.py
XFileMainWindowBase.keyPressEvent
def keyPressEvent(self, evt): """This handles Ctrl+PageUp, Ctrl+PageDown, Ctrl+Tab, Ctrl+Shift+Tab""" incr = 0 if evt.modifiers() == Qt.ControlModifier: n = self.tabWidget.count() if evt.key() in [Qt.Key_PageUp, Qt.Key_Backtab]: incr = -1 ...
python
def keyPressEvent(self, evt): """This handles Ctrl+PageUp, Ctrl+PageDown, Ctrl+Tab, Ctrl+Shift+Tab""" incr = 0 if evt.modifiers() == Qt.ControlModifier: n = self.tabWidget.count() if evt.key() in [Qt.Key_PageUp, Qt.Key_Backtab]: incr = -1 ...
[ "def", "keyPressEvent", "(", "self", ",", "evt", ")", ":", "incr", "=", "0", "if", "evt", ".", "modifiers", "(", ")", "==", "Qt", ".", "ControlModifier", ":", "n", "=", "self", ".", "tabWidget", ".", "count", "(", ")", "if", "evt", ".", "key", "(...
This handles Ctrl+PageUp, Ctrl+PageDown, Ctrl+Tab, Ctrl+Shift+Tab
[ "This", "handles", "Ctrl", "+", "PageUp", "Ctrl", "+", "PageDown", "Ctrl", "+", "Tab", "Ctrl", "+", "Shift", "+", "Tab" ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/explorer/gui/a_XFileMainWindow.py#L252-L267
40,301
trevisanj/f311
f311/explorer/gui/a_XFileMainWindow.py
XFileMainWindowBase._on_changed
def _on_changed(self): """Slot for changed events""" page = self._get_page() if not page.flag_autosave: page.flag_changed = True self._update_gui_text_tabs()
python
def _on_changed(self): """Slot for changed events""" page = self._get_page() if not page.flag_autosave: page.flag_changed = True self._update_gui_text_tabs()
[ "def", "_on_changed", "(", "self", ")", ":", "page", "=", "self", ".", "_get_page", "(", ")", "if", "not", "page", ".", "flag_autosave", ":", "page", ".", "flag_changed", "=", "True", "self", ".", "_update_gui_text_tabs", "(", ")" ]
Slot for changed events
[ "Slot", "for", "changed", "events" ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/explorer/gui/a_XFileMainWindow.py#L329-L334
40,302
trevisanj/f311
f311/explorer/gui/a_XFileMainWindow.py
XFileMainWindowBase._update_gui_text_tabs
def _update_gui_text_tabs(self): """Iterates through pages to update tab texts""" for index, page in enumerate(self.pages): self.tabWidget.setTabText(index, "{} (Alt+&{}){}".format(page.text_tab, index+1, (" (changed)" if page.flag_changed else "")))
python
def _update_gui_text_tabs(self): """Iterates through pages to update tab texts""" for index, page in enumerate(self.pages): self.tabWidget.setTabText(index, "{} (Alt+&{}){}".format(page.text_tab, index+1, (" (changed)" if page.flag_changed else "")))
[ "def", "_update_gui_text_tabs", "(", "self", ")", ":", "for", "index", ",", "page", "in", "enumerate", "(", "self", ".", "pages", ")", ":", "self", ".", "tabWidget", ".", "setTabText", "(", "index", ",", "\"{} (Alt+&{}){}\"", ".", "format", "(", "page", ...
Iterates through pages to update tab texts
[ "Iterates", "through", "pages", "to", "update", "tab", "texts" ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/explorer/gui/a_XFileMainWindow.py#L355-L358
40,303
trevisanj/f311
f311/explorer/gui/a_XFileMainWindow.py
XFileMainWindowBase.__generic_save
def __generic_save(self): """Returns False if user has cancelled a "save as" operation, otherwise True.""" page = self._get_page() f = page.editor.f if not f: return True if not page.editor.flag_valid: a99.show_error("Cannot save, {0!s} has error(s)...
python
def __generic_save(self): """Returns False if user has cancelled a "save as" operation, otherwise True.""" page = self._get_page() f = page.editor.f if not f: return True if not page.editor.flag_valid: a99.show_error("Cannot save, {0!s} has error(s)...
[ "def", "__generic_save", "(", "self", ")", ":", "page", "=", "self", ".", "_get_page", "(", ")", "f", "=", "page", ".", "editor", ".", "f", "if", "not", "f", ":", "return", "True", "if", "not", "page", ".", "editor", ".", "flag_valid", ":", "a99", ...
Returns False if user has cancelled a "save as" operation, otherwise True.
[ "Returns", "False", "if", "user", "has", "cancelled", "a", "save", "as", "operation", "otherwise", "True", "." ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/explorer/gui/a_XFileMainWindow.py#L373-L393
40,304
trevisanj/f311
f311/explorer/gui/a_XFileMainWindow.py
XFileMainWindowBase.__generic_save_as
def __generic_save_as(self): """Returns False if user has cancelled operation, otherwise True.""" page = self._get_page() if not page.editor.f: return True if page.editor.f.filename: d = page.editor.f.filename else: d = os.path.join(sel...
python
def __generic_save_as(self): """Returns False if user has cancelled operation, otherwise True.""" page = self._get_page() if not page.editor.f: return True if page.editor.f.filename: d = page.editor.f.filename else: d = os.path.join(sel...
[ "def", "__generic_save_as", "(", "self", ")", ":", "page", "=", "self", ".", "_get_page", "(", ")", "if", "not", "page", ".", "editor", ".", "f", ":", "return", "True", "if", "page", ".", "editor", ".", "f", ".", "filename", ":", "d", "=", "page", ...
Returns False if user has cancelled operation, otherwise True.
[ "Returns", "False", "if", "user", "has", "cancelled", "operation", "otherwise", "True", "." ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/explorer/gui/a_XFileMainWindow.py#L395-L414
40,305
TissueMAPS/TmDeploy
elasticluster/elasticluster/cluster.py
Cluster._start_nodes_sequentially
def _start_nodes_sequentially(self, nodes): """ Start the nodes sequentially without forking. Return set of nodes that were actually started. """ started_nodes = set() for node in copy(nodes): started = self._start_node(node) if started: ...
python
def _start_nodes_sequentially(self, nodes): """ Start the nodes sequentially without forking. Return set of nodes that were actually started. """ started_nodes = set() for node in copy(nodes): started = self._start_node(node) if started: ...
[ "def", "_start_nodes_sequentially", "(", "self", ",", "nodes", ")", ":", "started_nodes", "=", "set", "(", ")", "for", "node", "in", "copy", "(", "nodes", ")", ":", "started", "=", "self", ".", "_start_node", "(", "node", ")", "if", "started", ":", "st...
Start the nodes sequentially without forking. Return set of nodes that were actually started.
[ "Start", "the", "nodes", "sequentially", "without", "forking", "." ]
f891b4ffb21431988bc4a063ae871da3bf284a45
https://github.com/TissueMAPS/TmDeploy/blob/f891b4ffb21431988bc4a063ae871da3bf284a45/elasticluster/elasticluster/cluster.py#L415-L428
40,306
TissueMAPS/TmDeploy
elasticluster/elasticluster/cluster.py
Cluster._start_nodes_parallel
def _start_nodes_parallel(self, nodes, max_thread_pool_size): """ Start the nodes using a pool of multiprocessing threads for speed-up. Return set of nodes that were actually started. """ # Create one thread for each node to start thread_pool_size = min(len(nodes), max_t...
python
def _start_nodes_parallel(self, nodes, max_thread_pool_size): """ Start the nodes using a pool of multiprocessing threads for speed-up. Return set of nodes that were actually started. """ # Create one thread for each node to start thread_pool_size = min(len(nodes), max_t...
[ "def", "_start_nodes_parallel", "(", "self", ",", "nodes", ",", "max_thread_pool_size", ")", ":", "# Create one thread for each node to start", "thread_pool_size", "=", "min", "(", "len", "(", "nodes", ")", ",", "max_thread_pool_size", ")", "thread_pool", "=", "Pool",...
Start the nodes using a pool of multiprocessing threads for speed-up. Return set of nodes that were actually started.
[ "Start", "the", "nodes", "using", "a", "pool", "of", "multiprocessing", "threads", "for", "speed", "-", "up", "." ]
f891b4ffb21431988bc4a063ae871da3bf284a45
https://github.com/TissueMAPS/TmDeploy/blob/f891b4ffb21431988bc4a063ae871da3bf284a45/elasticluster/elasticluster/cluster.py#L430-L474
40,307
TissueMAPS/TmDeploy
elasticluster/elasticluster/cluster.py
Cluster._start_node
def _start_node(node): """ Start the given node VM. :return: bool -- True on success, False otherwise """ log.debug("_start_node: working on node `%s`", node.name) # FIXME: the following check is not optimal yet. When a node is still # in a starting state, it wil...
python
def _start_node(node): """ Start the given node VM. :return: bool -- True on success, False otherwise """ log.debug("_start_node: working on node `%s`", node.name) # FIXME: the following check is not optimal yet. When a node is still # in a starting state, it wil...
[ "def", "_start_node", "(", "node", ")", ":", "log", ".", "debug", "(", "\"_start_node: working on node `%s`\"", ",", "node", ".", "name", ")", "# FIXME: the following check is not optimal yet. When a node is still", "# in a starting state, it will start another node here, since the...
Start the given node VM. :return: bool -- True on success, False otherwise
[ "Start", "the", "given", "node", "VM", "." ]
f891b4ffb21431988bc4a063ae871da3bf284a45
https://github.com/TissueMAPS/TmDeploy/blob/f891b4ffb21431988bc4a063ae871da3bf284a45/elasticluster/elasticluster/cluster.py#L477-L499
40,308
TissueMAPS/TmDeploy
elasticluster/elasticluster/cluster.py
Cluster.get_all_nodes
def get_all_nodes(self): """Returns a list of all nodes in this cluster as a mixed list of different node kinds. :return: list of :py:class:`Node` """ nodes = self.nodes.values() if nodes: return reduce(operator.add, nodes, list()) else: r...
python
def get_all_nodes(self): """Returns a list of all nodes in this cluster as a mixed list of different node kinds. :return: list of :py:class:`Node` """ nodes = self.nodes.values() if nodes: return reduce(operator.add, nodes, list()) else: r...
[ "def", "get_all_nodes", "(", "self", ")", ":", "nodes", "=", "self", ".", "nodes", ".", "values", "(", ")", "if", "nodes", ":", "return", "reduce", "(", "operator", ".", "add", ",", "nodes", ",", "list", "(", ")", ")", "else", ":", "return", "[", ...
Returns a list of all nodes in this cluster as a mixed list of different node kinds. :return: list of :py:class:`Node`
[ "Returns", "a", "list", "of", "all", "nodes", "in", "this", "cluster", "as", "a", "mixed", "list", "of", "different", "node", "kinds", "." ]
f891b4ffb21431988bc4a063ae871da3bf284a45
https://github.com/TissueMAPS/TmDeploy/blob/f891b4ffb21431988bc4a063ae871da3bf284a45/elasticluster/elasticluster/cluster.py#L641-L651
40,309
TissueMAPS/TmDeploy
elasticluster/elasticluster/cluster.py
Cluster.get_frontend_node
def get_frontend_node(self): """Returns the first node of the class specified in the configuration file as `ssh_to`, or the first node of the first class in alphabetic order. :return: :py:class:`Node` :raise: :py:class:`elasticluster.exceptions.NodeNotFound` if no ...
python
def get_frontend_node(self): """Returns the first node of the class specified in the configuration file as `ssh_to`, or the first node of the first class in alphabetic order. :return: :py:class:`Node` :raise: :py:class:`elasticluster.exceptions.NodeNotFound` if no ...
[ "def", "get_frontend_node", "(", "self", ")", ":", "if", "self", ".", "ssh_to", ":", "if", "self", ".", "ssh_to", "in", "self", ".", "nodes", ":", "cls", "=", "self", ".", "nodes", "[", "self", ".", "ssh_to", "]", "if", "cls", ":", "return", "cls",...
Returns the first node of the class specified in the configuration file as `ssh_to`, or the first node of the first class in alphabetic order. :return: :py:class:`Node` :raise: :py:class:`elasticluster.exceptions.NodeNotFound` if no valid frontend node is found
[ "Returns", "the", "first", "node", "of", "the", "class", "specified", "in", "the", "configuration", "file", "as", "ssh_to", "or", "the", "first", "node", "of", "the", "first", "class", "in", "alphabetic", "order", "." ]
f891b4ffb21431988bc4a063ae871da3bf284a45
https://github.com/TissueMAPS/TmDeploy/blob/f891b4ffb21431988bc4a063ae871da3bf284a45/elasticluster/elasticluster/cluster.py#L731-L762
40,310
TissueMAPS/TmDeploy
elasticluster/elasticluster/cluster.py
NodeNamingPolicy.new
def new(self, kind, **extra): """ Return a host name for a new node of the given kind. The new name is formed by interpolating ``{}``-format specifiers in the string given as ``pattern`` argument to the class constructor. The following names can be used in the ``{}``-fo...
python
def new(self, kind, **extra): """ Return a host name for a new node of the given kind. The new name is formed by interpolating ``{}``-format specifiers in the string given as ``pattern`` argument to the class constructor. The following names can be used in the ``{}``-fo...
[ "def", "new", "(", "self", ",", "kind", ",", "*", "*", "extra", ")", ":", "if", "self", ".", "_free", "[", "kind", "]", ":", "index", "=", "self", ".", "_free", "[", "kind", "]", ".", "pop", "(", ")", "else", ":", "self", ".", "_top", "[", ...
Return a host name for a new node of the given kind. The new name is formed by interpolating ``{}``-format specifiers in the string given as ``pattern`` argument to the class constructor. The following names can be used in the ``{}``-format specifiers: * ``kind`` -- the `kind`...
[ "Return", "a", "host", "name", "for", "a", "new", "node", "of", "the", "given", "kind", "." ]
f891b4ffb21431988bc4a063ae871da3bf284a45
https://github.com/TissueMAPS/TmDeploy/blob/f891b4ffb21431988bc4a063ae871da3bf284a45/elasticluster/elasticluster/cluster.py#L933-L959
40,311
TissueMAPS/TmDeploy
elasticluster/elasticluster/cluster.py
NodeNamingPolicy.use
def use(self, kind, name): """ Mark a node name as used. """ try: params = self._parse(name) index = int(params['index'], 10) if index in self._free[kind]: self._free[kind].remove(index) top = self._top[kind] if ...
python
def use(self, kind, name): """ Mark a node name as used. """ try: params = self._parse(name) index = int(params['index'], 10) if index in self._free[kind]: self._free[kind].remove(index) top = self._top[kind] if ...
[ "def", "use", "(", "self", ",", "kind", ",", "name", ")", ":", "try", ":", "params", "=", "self", ".", "_parse", "(", "name", ")", "index", "=", "int", "(", "params", "[", "'index'", "]", ",", "10", ")", "if", "index", "in", "self", ".", "_free...
Mark a node name as used.
[ "Mark", "a", "node", "name", "as", "used", "." ]
f891b4ffb21431988bc4a063ae871da3bf284a45
https://github.com/TissueMAPS/TmDeploy/blob/f891b4ffb21431988bc4a063ae871da3bf284a45/elasticluster/elasticluster/cluster.py#L961-L977
40,312
TissueMAPS/TmDeploy
elasticluster/elasticluster/cluster.py
NodeNamingPolicy.free
def free(self, kind, name): """ Mark a node name as no longer in use. It could thus be recycled to name a new node. """ try: params = self._parse(name) index = int(params['index'], 10) self._free[kind].add(index) assert index <= se...
python
def free(self, kind, name): """ Mark a node name as no longer in use. It could thus be recycled to name a new node. """ try: params = self._parse(name) index = int(params['index'], 10) self._free[kind].add(index) assert index <= se...
[ "def", "free", "(", "self", ",", "kind", ",", "name", ")", ":", "try", ":", "params", "=", "self", ".", "_parse", "(", "name", ")", "index", "=", "int", "(", "params", "[", "'index'", "]", ",", "10", ")", "self", ".", "_free", "[", "kind", "]",...
Mark a node name as no longer in use. It could thus be recycled to name a new node.
[ "Mark", "a", "node", "name", "as", "no", "longer", "in", "use", "." ]
f891b4ffb21431988bc4a063ae871da3bf284a45
https://github.com/TissueMAPS/TmDeploy/blob/f891b4ffb21431988bc4a063ae871da3bf284a45/elasticluster/elasticluster/cluster.py#L979-L994
40,313
TissueMAPS/TmDeploy
elasticluster/elasticluster/cluster.py
Node.is_alive
def is_alive(self): """Checks if the current node is up and running in the cloud. It only checks the status provided by the cloud interface. Therefore a node might be running, but not yet ready to ssh into it. """ running = False if not self.instance_id: retur...
python
def is_alive(self): """Checks if the current node is up and running in the cloud. It only checks the status provided by the cloud interface. Therefore a node might be running, but not yet ready to ssh into it. """ running = False if not self.instance_id: retur...
[ "def", "is_alive", "(", "self", ")", ":", "running", "=", "False", "if", "not", "self", ".", "instance_id", ":", "return", "False", "try", ":", "log", ".", "debug", "(", "\"Getting information for instance %s\"", ",", "self", ".", "instance_id", ")", "runnin...
Checks if the current node is up and running in the cloud. It only checks the status provided by the cloud interface. Therefore a node might be running, but not yet ready to ssh into it.
[ "Checks", "if", "the", "current", "node", "is", "up", "and", "running", "in", "the", "cloud", ".", "It", "only", "checks", "the", "status", "provided", "by", "the", "cloud", "interface", ".", "Therefore", "a", "node", "might", "be", "running", "but", "no...
f891b4ffb21431988bc4a063ae871da3bf284a45
https://github.com/TissueMAPS/TmDeploy/blob/f891b4ffb21431988bc4a063ae871da3bf284a45/elasticluster/elasticluster/cluster.py#L1107-L1132
40,314
TissueMAPS/TmDeploy
elasticluster/elasticluster/cluster.py
Node.connect
def connect(self, keyfile=None): """Connect to the node via ssh using the paramiko library. :return: :py:class:`paramiko.SSHClient` - ssh connection or None on failure """ ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ...
python
def connect(self, keyfile=None): """Connect to the node via ssh using the paramiko library. :return: :py:class:`paramiko.SSHClient` - ssh connection or None on failure """ ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ...
[ "def", "connect", "(", "self", ",", "keyfile", "=", "None", ")", ":", "ssh", "=", "paramiko", ".", "SSHClient", "(", ")", "ssh", ".", "set_missing_host_key_policy", "(", "paramiko", ".", "AutoAddPolicy", "(", ")", ")", "if", "keyfile", "and", "os", ".", ...
Connect to the node via ssh using the paramiko library. :return: :py:class:`paramiko.SSHClient` - ssh connection or None on failure
[ "Connect", "to", "the", "node", "via", "ssh", "using", "the", "paramiko", "library", "." ]
f891b4ffb21431988bc4a063ae871da3bf284a45
https://github.com/TissueMAPS/TmDeploy/blob/f891b4ffb21431988bc4a063ae871da3bf284a45/elasticluster/elasticluster/cluster.py#L1141-L1194
40,315
trevisanj/a99
a99/config.py
AAConfigObj.set_item
def set_item(self, path_, value): """Sets item and automatically saves file""" section, path_ = self._get_section(path_) section[path_[-1]] = value self.write()
python
def set_item(self, path_, value): """Sets item and automatically saves file""" section, path_ = self._get_section(path_) section[path_[-1]] = value self.write()
[ "def", "set_item", "(", "self", ",", "path_", ",", "value", ")", ":", "section", ",", "path_", "=", "self", ".", "_get_section", "(", "path_", ")", "section", "[", "path_", "[", "-", "1", "]", "]", "=", "value", "self", ".", "write", "(", ")" ]
Sets item and automatically saves file
[ "Sets", "item", "and", "automatically", "saves", "file" ]
193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/config.py#L80-L84
40,316
CodyKochmann/generators
generators/all_subslices.py
all_subslices
def all_subslices(itr): """ generates every possible slice that can be generated from an iterable """ assert iterable(itr), 'generators.all_subslices only accepts iterable arguments, not {}'.format(itr) if not hasattr(itr, '__len__'): # if itr isnt materialized, make it a deque itr = deque(itr) ...
python
def all_subslices(itr): """ generates every possible slice that can be generated from an iterable """ assert iterable(itr), 'generators.all_subslices only accepts iterable arguments, not {}'.format(itr) if not hasattr(itr, '__len__'): # if itr isnt materialized, make it a deque itr = deque(itr) ...
[ "def", "all_subslices", "(", "itr", ")", ":", "assert", "iterable", "(", "itr", ")", ",", "'generators.all_subslices only accepts iterable arguments, not {}'", ".", "format", "(", "itr", ")", "if", "not", "hasattr", "(", "itr", ",", "'__len__'", ")", ":", "# if ...
generates every possible slice that can be generated from an iterable
[ "generates", "every", "possible", "slice", "that", "can", "be", "generated", "from", "an", "iterable" ]
e4ca4dd25d5023a94b0349c69d6224070cc2526f
https://github.com/CodyKochmann/generators/blob/e4ca4dd25d5023a94b0349c69d6224070cc2526f/generators/all_subslices.py#L22-L32
40,317
jkitzes/macroeco
macroeco/misc/format_data.py
data_read_write
def data_read_write(data_path_in, data_path_out, format_type, **kwargs): """ General function to read, format, and write data. Parameters ---------- data_path_in : str Path to the file that will be read data_path_out : str Path of the file that will be output format_type : s...
python
def data_read_write(data_path_in, data_path_out, format_type, **kwargs): """ General function to read, format, and write data. Parameters ---------- data_path_in : str Path to the file that will be read data_path_out : str Path of the file that will be output format_type : s...
[ "def", "data_read_write", "(", "data_path_in", ",", "data_path_out", ",", "format_type", ",", "*", "*", "kwargs", ")", ":", "if", "format_type", "==", "\"dense\"", ":", "# Set dense defaults", "kwargs", "=", "_set_dense_defaults_and_eval", "(", "kwargs", ")", "# T...
General function to read, format, and write data. Parameters ---------- data_path_in : str Path to the file that will be read data_path_out : str Path of the file that will be output format_type : str Either 'dense', 'grid', 'columnar', or 'transect' kwargs Speci...
[ "General", "function", "to", "read", "format", "and", "write", "data", "." ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/misc/format_data.py#L4-L61
40,318
jkitzes/macroeco
macroeco/misc/format_data.py
format_dense
def format_dense(base_data, non_label_cols, **kwargs): """ Formats dense data type to stacked data type. Takes in a dense data type and converts into a stacked data type. Parameters ---------- data : DataFrame The dense data non_label_cols : list A list of columns in the da...
python
def format_dense(base_data, non_label_cols, **kwargs): """ Formats dense data type to stacked data type. Takes in a dense data type and converts into a stacked data type. Parameters ---------- data : DataFrame The dense data non_label_cols : list A list of columns in the da...
[ "def", "format_dense", "(", "base_data", ",", "non_label_cols", ",", "*", "*", "kwargs", ")", ":", "kwargs", "=", "_set_dense_defaults_and_eval", "(", "kwargs", ")", "# Stack data in columnar form.", "indexed_data", "=", "base_data", ".", "set_index", "(", "keys", ...
Formats dense data type to stacked data type. Takes in a dense data type and converts into a stacked data type. Parameters ---------- data : DataFrame The dense data non_label_cols : list A list of columns in the data that are not label columns label_col : str Name of t...
[ "Formats", "dense", "data", "type", "to", "stacked", "data", "type", "." ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/misc/format_data.py#L64-L151
40,319
jkitzes/macroeco
macroeco/misc/format_data.py
_set_dense_defaults_and_eval
def _set_dense_defaults_and_eval(kwargs): """ Sets default values in kwargs if kwargs are not already given. Evaluates all values using eval Parameters ----------- kwargs : dict Dictionary of dense specific keyword args Returns ------- : dict Default, evaluated dic...
python
def _set_dense_defaults_and_eval(kwargs): """ Sets default values in kwargs if kwargs are not already given. Evaluates all values using eval Parameters ----------- kwargs : dict Dictionary of dense specific keyword args Returns ------- : dict Default, evaluated dic...
[ "def", "_set_dense_defaults_and_eval", "(", "kwargs", ")", ":", "kwargs", "[", "'delimiter'", "]", "=", "kwargs", ".", "get", "(", "'delimiter'", ",", "','", ")", "kwargs", "[", "'na_values'", "]", "=", "kwargs", ".", "get", "(", "'na_values'", ",", "''", ...
Sets default values in kwargs if kwargs are not already given. Evaluates all values using eval Parameters ----------- kwargs : dict Dictionary of dense specific keyword args Returns ------- : dict Default, evaluated dictionary
[ "Sets", "default", "values", "in", "kwargs", "if", "kwargs", "are", "not", "already", "given", "." ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/misc/format_data.py#L154-L185
40,320
trevisanj/f311
f311/explorer/vis/plotsp.py
plot_spectra_stacked
def plot_spectra_stacked(ss, title=None, num_rows=None, setup=_default_setup): """ Plots one or more stacked in subplots sharing same x-axis. Args: ss: list of Spectrum objects title=None: window title num_rows=None: (optional) number of rows for subplot grid. If not passed, num_r...
python
def plot_spectra_stacked(ss, title=None, num_rows=None, setup=_default_setup): """ Plots one or more stacked in subplots sharing same x-axis. Args: ss: list of Spectrum objects title=None: window title num_rows=None: (optional) number of rows for subplot grid. If not passed, num_r...
[ "def", "plot_spectra_stacked", "(", "ss", ",", "title", "=", "None", ",", "num_rows", "=", "None", ",", "setup", "=", "_default_setup", ")", ":", "draw_spectra_stacked", "(", "ss", ",", "title", ",", "num_rows", ",", "setup", ")", "plt", ".", "show", "("...
Plots one or more stacked in subplots sharing same x-axis. Args: ss: list of Spectrum objects title=None: window title num_rows=None: (optional) number of rows for subplot grid. If not passed, num_rows will be the number of plots, and the number of columns will be 1. If passed, nu...
[ "Plots", "one", "or", "more", "stacked", "in", "subplots", "sharing", "same", "x", "-", "axis", "." ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/explorer/vis/plotsp.py#L61-L76
40,321
trevisanj/f311
f311/explorer/vis/plotsp.py
plot_spectra_overlapped
def plot_spectra_overlapped(ss, title=None, setup=_default_setup): """ Plots one or more spectra in the same plot. Args: ss: list of Spectrum objects title=None: window title setup: PlotSpectrumSetup object """ plt.figure() draw_spectra_overlapped(ss, title, setup) plt.sh...
python
def plot_spectra_overlapped(ss, title=None, setup=_default_setup): """ Plots one or more spectra in the same plot. Args: ss: list of Spectrum objects title=None: window title setup: PlotSpectrumSetup object """ plt.figure() draw_spectra_overlapped(ss, title, setup) plt.sh...
[ "def", "plot_spectra_overlapped", "(", "ss", ",", "title", "=", "None", ",", "setup", "=", "_default_setup", ")", ":", "plt", ".", "figure", "(", ")", "draw_spectra_overlapped", "(", "ss", ",", "title", ",", "setup", ")", "plt", ".", "show", "(", ")" ]
Plots one or more spectra in the same plot. Args: ss: list of Spectrum objects title=None: window title setup: PlotSpectrumSetup object
[ "Plots", "one", "or", "more", "spectra", "in", "the", "same", "plot", "." ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/explorer/vis/plotsp.py#L80-L92
40,322
trevisanj/f311
f311/explorer/vis/plotsp.py
plot_spectra_pieces_pdf
def plot_spectra_pieces_pdf(ss, aint=10, pdf_filename='pieces.pdf', setup=_default_setup): """ Plots spectra, overlapped, in small wavelength intervals into a PDF file, one interval per page of the PDF file. Args: ss: list of Spectrum objects aint: wavelength interval for each plot pd...
python
def plot_spectra_pieces_pdf(ss, aint=10, pdf_filename='pieces.pdf', setup=_default_setup): """ Plots spectra, overlapped, in small wavelength intervals into a PDF file, one interval per page of the PDF file. Args: ss: list of Spectrum objects aint: wavelength interval for each plot pd...
[ "def", "plot_spectra_pieces_pdf", "(", "ss", ",", "aint", "=", "10", ",", "pdf_filename", "=", "'pieces.pdf'", ",", "setup", "=", "_default_setup", ")", ":", "import", "f311", ".", "explorer", "as", "ex", "xmin", ",", "xmax", ",", "ymin_", ",", "ymax", "...
Plots spectra, overlapped, in small wavelength intervals into a PDF file, one interval per page of the PDF file. Args: ss: list of Spectrum objects aint: wavelength interval for each plot pdf_filename: name of output file setup: PlotSpectrumSetup object **Note** overrides setup.fmt...
[ "Plots", "spectra", "overlapped", "in", "small", "wavelength", "intervals", "into", "a", "PDF", "file", "one", "interval", "per", "page", "of", "the", "PDF", "file", "." ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/explorer/vis/plotsp.py#L133-L184
40,323
trevisanj/f311
f311/explorer/vis/plotsp.py
plot_spectra_pages_pdf
def plot_spectra_pages_pdf(ss, pdf_filename='pages.pdf', setup=_default_setup): """ Plots spectra into a PDF file, one spectrum per page. Splits into several pieces of width Args: ss: list of Spectrum objects pdf_filename: name of output file """ logger = a99.get_python_logger() ...
python
def plot_spectra_pages_pdf(ss, pdf_filename='pages.pdf', setup=_default_setup): """ Plots spectra into a PDF file, one spectrum per page. Splits into several pieces of width Args: ss: list of Spectrum objects pdf_filename: name of output file """ logger = a99.get_python_logger() ...
[ "def", "plot_spectra_pages_pdf", "(", "ss", ",", "pdf_filename", "=", "'pages.pdf'", ",", "setup", "=", "_default_setup", ")", ":", "logger", "=", "a99", ".", "get_python_logger", "(", ")", "xmin", ",", "xmax", ",", "ymin_", ",", "ymax", ",", "xspan", ",",...
Plots spectra into a PDF file, one spectrum per page. Splits into several pieces of width Args: ss: list of Spectrum objects pdf_filename: name of output file
[ "Plots", "spectra", "into", "a", "PDF", "file", "one", "spectrum", "per", "page", "." ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/explorer/vis/plotsp.py#L187-L220
40,324
micha030201/aionationstates
aionationstates/wa_.py
_ProposalResolution.repeal_target
def repeal_target(self): """The resolution this resolution has repealed, or is attempting to repeal. Returns ------- :class:`ApiQuery` of :class:`Resolution` Raises ------ TypeError: If the resolution doesn't repeal anything. """ ...
python
def repeal_target(self): """The resolution this resolution has repealed, or is attempting to repeal. Returns ------- :class:`ApiQuery` of :class:`Resolution` Raises ------ TypeError: If the resolution doesn't repeal anything. """ ...
[ "def", "repeal_target", "(", "self", ")", ":", "if", "not", "self", ".", "category", "==", "'Repeal'", ":", "raise", "TypeError", "(", "\"This resolution doesn't repeal anything\"", ")", "return", "wa", ".", "resolution", "(", "int", "(", "self", ".", "option"...
The resolution this resolution has repealed, or is attempting to repeal. Returns ------- :class:`ApiQuery` of :class:`Resolution` Raises ------ TypeError: If the resolution doesn't repeal anything.
[ "The", "resolution", "this", "resolution", "has", "repealed", "or", "is", "attempting", "to", "repeal", "." ]
dc86b86d994cbab830b69ab8023601c73e778b3a
https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/wa_.py#L68-L83
40,325
micha030201/aionationstates
aionationstates/wa_.py
_WAShared.resolution
def resolution(self, index): """Resolution with a given index. Parameters ---------- index : int Resolution index. Global if this is the ``aionationstates.wa`` object, local if this is ``aionationstates.ga`` or ``aionationstates.sc``. Return...
python
def resolution(self, index): """Resolution with a given index. Parameters ---------- index : int Resolution index. Global if this is the ``aionationstates.wa`` object, local if this is ``aionationstates.ga`` or ``aionationstates.sc``. Return...
[ "def", "resolution", "(", "self", ",", "index", ")", ":", "@", "api_query", "(", "'resolution'", ",", "id", "=", "str", "(", "index", ")", ")", "async", "def", "result", "(", "_", ",", "root", ")", ":", "elem", "=", "root", ".", "find", "(", "'RE...
Resolution with a given index. Parameters ---------- index : int Resolution index. Global if this is the ``aionationstates.wa`` object, local if this is ``aionationstates.ga`` or ``aionationstates.sc``. Returns ------- :class:`ApiQue...
[ "Resolution", "with", "a", "given", "index", "." ]
dc86b86d994cbab830b69ab8023601c73e778b3a
https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/wa_.py#L339-L365
40,326
micha030201/aionationstates
aionationstates/wa_.py
_WACouncil.resolution_at_vote
async def resolution_at_vote(self, root): """The proposal currently being voted on. Returns ------- :class:`ApiQuery` of :class:`ResolutionAtVote` :class:`ApiQuery` of None If no resolution is currently at vote. """ elem = root.find('RESOLUTION') ...
python
async def resolution_at_vote(self, root): """The proposal currently being voted on. Returns ------- :class:`ApiQuery` of :class:`ResolutionAtVote` :class:`ApiQuery` of None If no resolution is currently at vote. """ elem = root.find('RESOLUTION') ...
[ "async", "def", "resolution_at_vote", "(", "self", ",", "root", ")", ":", "elem", "=", "root", ".", "find", "(", "'RESOLUTION'", ")", "if", "elem", ":", "resolution", "=", "ResolutionAtVote", "(", "elem", ")", "resolution", ".", "_council_id", "=", "self",...
The proposal currently being voted on. Returns ------- :class:`ApiQuery` of :class:`ResolutionAtVote` :class:`ApiQuery` of None If no resolution is currently at vote.
[ "The", "proposal", "currently", "being", "voted", "on", "." ]
dc86b86d994cbab830b69ab8023601c73e778b3a
https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/wa_.py#L437-L450
40,327
benoitbryon/rst2rst
rst2rst/writer.py
RSTTranslator.indent
def indent(self, levels, first_line=None): """Increase indentation by ``levels`` levels.""" self._indentation_levels.append(levels) self._indent_first_line.append(first_line)
python
def indent(self, levels, first_line=None): """Increase indentation by ``levels`` levels.""" self._indentation_levels.append(levels) self._indent_first_line.append(first_line)
[ "def", "indent", "(", "self", ",", "levels", ",", "first_line", "=", "None", ")", ":", "self", ".", "_indentation_levels", ".", "append", "(", "levels", ")", "self", ".", "_indent_first_line", ".", "append", "(", "first_line", ")" ]
Increase indentation by ``levels`` levels.
[ "Increase", "indentation", "by", "levels", "levels", "." ]
976eef709aacb1facc8dca87cf7032f01d53adfe
https://github.com/benoitbryon/rst2rst/blob/976eef709aacb1facc8dca87cf7032f01d53adfe/rst2rst/writer.py#L156-L159
40,328
benoitbryon/rst2rst
rst2rst/writer.py
RSTTranslator.wrap
def wrap(self, text, width=None, indent=None): """Return ``text`` wrapped to ``width`` and indented with ``indent``. By default: * ``width`` is ``self.options.wrap_length`` * ``indent`` is ``self.indentation``. """ width = width if width is not None else self.options.w...
python
def wrap(self, text, width=None, indent=None): """Return ``text`` wrapped to ``width`` and indented with ``indent``. By default: * ``width`` is ``self.options.wrap_length`` * ``indent`` is ``self.indentation``. """ width = width if width is not None else self.options.w...
[ "def", "wrap", "(", "self", ",", "text", ",", "width", "=", "None", ",", "indent", "=", "None", ")", ":", "width", "=", "width", "if", "width", "is", "not", "None", "else", "self", ".", "options", ".", "wrap_length", "indent", "=", "indent", "if", ...
Return ``text`` wrapped to ``width`` and indented with ``indent``. By default: * ``width`` is ``self.options.wrap_length`` * ``indent`` is ``self.indentation``.
[ "Return", "text", "wrapped", "to", "width", "and", "indented", "with", "indent", "." ]
976eef709aacb1facc8dca87cf7032f01d53adfe
https://github.com/benoitbryon/rst2rst/blob/976eef709aacb1facc8dca87cf7032f01d53adfe/rst2rst/writer.py#L171-L185
40,329
nuSTORM/gnomon
gnomon/DetectorConstruction.py
BoxDetectorConstruction.Construct
def Construct(self): # pylint: disable-msg=C0103 """Construct a cuboid from a GDML file without sensitive detector""" # Parse the GDML self.gdml_parser.Read(self.filename) self.world = self.gdml_parser.GetWorldVolume() self.log.info("Materials:") self.log.info(G4.G4Mate...
python
def Construct(self): # pylint: disable-msg=C0103 """Construct a cuboid from a GDML file without sensitive detector""" # Parse the GDML self.gdml_parser.Read(self.filename) self.world = self.gdml_parser.GetWorldVolume() self.log.info("Materials:") self.log.info(G4.G4Mate...
[ "def", "Construct", "(", "self", ")", ":", "# pylint: disable-msg=C0103", "# Parse the GDML", "self", ".", "gdml_parser", ".", "Read", "(", "self", ".", "filename", ")", "self", ".", "world", "=", "self", ".", "gdml_parser", ".", "GetWorldVolume", "(", ")", ...
Construct a cuboid from a GDML file without sensitive detector
[ "Construct", "a", "cuboid", "from", "a", "GDML", "file", "without", "sensitive", "detector" ]
7616486ecd6e26b76f677c380e62db1c0ade558a
https://github.com/nuSTORM/gnomon/blob/7616486ecd6e26b76f677c380e62db1c0ade558a/gnomon/DetectorConstruction.py#L38-L48
40,330
nuSTORM/gnomon
gnomon/DetectorConstruction.py
MagIronSamplingCaloDetectorConstruction.Construct
def Construct(self): # pylint: disable-msg=C0103 """Construct nuSTORM from a GDML file""" # Parse the GDML self.world = self.gdml_parser.GetWorldVolume() # Create sensitive detector self.sensitive_detector = ScintSD() # Get logical volume for X view, then attach SD ...
python
def Construct(self): # pylint: disable-msg=C0103 """Construct nuSTORM from a GDML file""" # Parse the GDML self.world = self.gdml_parser.GetWorldVolume() # Create sensitive detector self.sensitive_detector = ScintSD() # Get logical volume for X view, then attach SD ...
[ "def", "Construct", "(", "self", ")", ":", "# pylint: disable-msg=C0103", "# Parse the GDML", "self", ".", "world", "=", "self", ".", "gdml_parser", ".", "GetWorldVolume", "(", ")", "# Create sensitive detector", "self", ".", "sensitive_detector", "=", "ScintSD", "(...
Construct nuSTORM from a GDML file
[ "Construct", "nuSTORM", "from", "a", "GDML", "file" ]
7616486ecd6e26b76f677c380e62db1c0ade558a
https://github.com/nuSTORM/gnomon/blob/7616486ecd6e26b76f677c380e62db1c0ade558a/gnomon/DetectorConstruction.py#L94-L126
40,331
Aluriak/bubble-tools
bubbletools/validator.py
validate
def validate(bbllines:iter, *, profiling=False): """Yield lines of warnings and errors about input bbl lines. profiling -- yield also info lines about input bbl file. If bbllines is a valid file name, it will be read. Else, it should be an iterable of bubble file lines. """ if isinstance(bbll...
python
def validate(bbllines:iter, *, profiling=False): """Yield lines of warnings and errors about input bbl lines. profiling -- yield also info lines about input bbl file. If bbllines is a valid file name, it will be read. Else, it should be an iterable of bubble file lines. """ if isinstance(bbll...
[ "def", "validate", "(", "bbllines", ":", "iter", ",", "*", ",", "profiling", "=", "False", ")", ":", "if", "isinstance", "(", "bbllines", ",", "str", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "bbllines", ")", ":", "# filename containing bu...
Yield lines of warnings and errors about input bbl lines. profiling -- yield also info lines about input bbl file. If bbllines is a valid file name, it will be read. Else, it should be an iterable of bubble file lines.
[ "Yield", "lines", "of", "warnings", "and", "errors", "about", "input", "bbl", "lines", "." ]
f014f4a1986abefc80dc418feaa05ed258c2221a
https://github.com/Aluriak/bubble-tools/blob/f014f4a1986abefc80dc418feaa05ed258c2221a/bubbletools/validator.py#L11-L55
40,332
Aluriak/bubble-tools
bubbletools/validator.py
inclusions_validation
def inclusions_validation(tree:BubbleTree) -> iter: """Yield message about inclusions inconsistancies""" # search for powernode overlapping for one, two in it.combinations(tree.inclusions, 2): assert len(one) == len(one.strip()) assert len(two) == len(two.strip()) one_inc = set(inclu...
python
def inclusions_validation(tree:BubbleTree) -> iter: """Yield message about inclusions inconsistancies""" # search for powernode overlapping for one, two in it.combinations(tree.inclusions, 2): assert len(one) == len(one.strip()) assert len(two) == len(two.strip()) one_inc = set(inclu...
[ "def", "inclusions_validation", "(", "tree", ":", "BubbleTree", ")", "->", "iter", ":", "# search for powernode overlapping", "for", "one", ",", "two", "in", "it", ".", "combinations", "(", "tree", ".", "inclusions", ",", "2", ")", ":", "assert", "len", "(",...
Yield message about inclusions inconsistancies
[ "Yield", "message", "about", "inclusions", "inconsistancies" ]
f014f4a1986abefc80dc418feaa05ed258c2221a
https://github.com/Aluriak/bubble-tools/blob/f014f4a1986abefc80dc418feaa05ed258c2221a/bubbletools/validator.py#L58-L99
40,333
Aluriak/bubble-tools
bubbletools/validator.py
mergeability_validation
def mergeability_validation(tree:BubbleTree) -> iter: """Yield message about mergables powernodes""" def gen_warnings(one, two, inc_message:str) -> [str]: "Yield the warning for given (power)nodes if necessary" nodetype = '' if tree.inclusions[one] and tree.inclusions[two]: n...
python
def mergeability_validation(tree:BubbleTree) -> iter: """Yield message about mergables powernodes""" def gen_warnings(one, two, inc_message:str) -> [str]: "Yield the warning for given (power)nodes if necessary" nodetype = '' if tree.inclusions[one] and tree.inclusions[two]: n...
[ "def", "mergeability_validation", "(", "tree", ":", "BubbleTree", ")", "->", "iter", ":", "def", "gen_warnings", "(", "one", ",", "two", ",", "inc_message", ":", "str", ")", "->", "[", "str", "]", ":", "\"Yield the warning for given (power)nodes if necessary\"", ...
Yield message about mergables powernodes
[ "Yield", "message", "about", "mergables", "powernodes" ]
f014f4a1986abefc80dc418feaa05ed258c2221a
https://github.com/Aluriak/bubble-tools/blob/f014f4a1986abefc80dc418feaa05ed258c2221a/bubbletools/validator.py#L120-L139
40,334
hackedd/gw2api
gw2api/guild.py
guild_details
def guild_details(guild_id=None, name=None): """This resource returns details about a guild. :param guild_id: The guild id to query for. :param name: The guild name to query for. *Note: Only one parameter is required; if both are set, the guild Id takes precedence and a warning will be logged.* ...
python
def guild_details(guild_id=None, name=None): """This resource returns details about a guild. :param guild_id: The guild id to query for. :param name: The guild name to query for. *Note: Only one parameter is required; if both are set, the guild Id takes precedence and a warning will be logged.* ...
[ "def", "guild_details", "(", "guild_id", "=", "None", ",", "name", "=", "None", ")", ":", "if", "guild_id", "and", "name", ":", "warnings", ".", "warn", "(", "\"both guild_id and name are specified, \"", "\"name will be ignored\"", ")", "if", "guild_id", ":", "p...
This resource returns details about a guild. :param guild_id: The guild id to query for. :param name: The guild name to query for. *Note: Only one parameter is required; if both are set, the guild Id takes precedence and a warning will be logged.* The response is a dictionary with the following k...
[ "This", "resource", "returns", "details", "about", "a", "guild", "." ]
5543a78e6e3ed0573b7e84c142c44004b4779eac
https://github.com/hackedd/gw2api/blob/5543a78e6e3ed0573b7e84c142c44004b4779eac/gw2api/guild.py#L9-L68
40,335
CodyKochmann/generators
generators/chunks.py
chunks
def chunks(stream, chunk_size, output_type=tuple): ''' returns chunks of a stream ''' assert iterable(stream), 'chunks needs stream to be iterable' assert (isinstance(chunk_size, int) and chunk_size > 0) or callable(chunk_size), 'chunks needs chunk_size to be a positive int or callable' assert callable(...
python
def chunks(stream, chunk_size, output_type=tuple): ''' returns chunks of a stream ''' assert iterable(stream), 'chunks needs stream to be iterable' assert (isinstance(chunk_size, int) and chunk_size > 0) or callable(chunk_size), 'chunks needs chunk_size to be a positive int or callable' assert callable(...
[ "def", "chunks", "(", "stream", ",", "chunk_size", ",", "output_type", "=", "tuple", ")", ":", "assert", "iterable", "(", "stream", ")", ",", "'chunks needs stream to be iterable'", "assert", "(", "isinstance", "(", "chunk_size", ",", "int", ")", "and", "chunk...
returns chunks of a stream
[ "returns", "chunks", "of", "a", "stream" ]
e4ca4dd25d5023a94b0349c69d6224070cc2526f
https://github.com/CodyKochmann/generators/blob/e4ca4dd25d5023a94b0349c69d6224070cc2526f/generators/chunks.py#L20-L40
40,336
wuher/devil
devil/util.py
get_charset
def get_charset(request): """ Extract charset from the content type """ content_type = request.META.get('CONTENT_TYPE', None) if content_type: return extract_charset(content_type) if content_type else None else: return None
python
def get_charset(request): """ Extract charset from the content type """ content_type = request.META.get('CONTENT_TYPE', None) if content_type: return extract_charset(content_type) if content_type else None else: return None
[ "def", "get_charset", "(", "request", ")", ":", "content_type", "=", "request", ".", "META", ".", "get", "(", "'CONTENT_TYPE'", ",", "None", ")", "if", "content_type", ":", "return", "extract_charset", "(", "content_type", ")", "if", "content_type", "else", ...
Extract charset from the content type
[ "Extract", "charset", "from", "the", "content", "type" ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/util.py#L48-L56
40,337
wuher/devil
devil/util.py
parse_accept_header
def parse_accept_header(accept): """ Parse the Accept header todo: memoize :returns: list with pairs of (media_type, q_value), ordered by q values. """ def parse_media_range(accept_item): """ Parse media range and subtype """ return accept_item.split('/', 1) def comparat...
python
def parse_accept_header(accept): """ Parse the Accept header todo: memoize :returns: list with pairs of (media_type, q_value), ordered by q values. """ def parse_media_range(accept_item): """ Parse media range and subtype """ return accept_item.split('/', 1) def comparat...
[ "def", "parse_accept_header", "(", "accept", ")", ":", "def", "parse_media_range", "(", "accept_item", ")", ":", "\"\"\" Parse media range and subtype \"\"\"", "return", "accept_item", ".", "split", "(", "'/'", ",", "1", ")", "def", "comparator", "(", "a", ",", ...
Parse the Accept header todo: memoize :returns: list with pairs of (media_type, q_value), ordered by q values.
[ "Parse", "the", "Accept", "header" ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/util.py#L59-L112
40,338
openstack/stacktach-winchester
winchester/db/interface.py
DBInterface.in_session
def in_session(self): """Provide a session scope around a series of operations.""" session = self.get_session() try: yield session session.commit() except IntegrityError: session.rollback() raise DuplicateError("Duplicate unique value detec...
python
def in_session(self): """Provide a session scope around a series of operations.""" session = self.get_session() try: yield session session.commit() except IntegrityError: session.rollback() raise DuplicateError("Duplicate unique value detec...
[ "def", "in_session", "(", "self", ")", ":", "session", "=", "self", ".", "get_session", "(", ")", "try", ":", "yield", "session", "session", ".", "commit", "(", ")", "except", "IntegrityError", ":", "session", ".", "rollback", "(", ")", "raise", "Duplica...
Provide a session scope around a series of operations.
[ "Provide", "a", "session", "scope", "around", "a", "series", "of", "operations", "." ]
54f3ffc4a8fd84b6fb29ad9b65adb018e8927956
https://github.com/openstack/stacktach-winchester/blob/54f3ffc4a8fd84b6fb29ad9b65adb018e8927956/winchester/db/interface.py#L111-L129
40,339
robinagist/ezo
ezo/core/tm_utils.py
EzoABCI.info
def info(self, req) -> ResponseInfo: """ Since this will always respond with height=0, Tendermint will resync this app from the begining """ r = ResponseInfo() r.version = "1.0" r.last_block_height = 0 r.last_block_app_hash = b'' return r
python
def info(self, req) -> ResponseInfo: """ Since this will always respond with height=0, Tendermint will resync this app from the begining """ r = ResponseInfo() r.version = "1.0" r.last_block_height = 0 r.last_block_app_hash = b'' return r
[ "def", "info", "(", "self", ",", "req", ")", "->", "ResponseInfo", ":", "r", "=", "ResponseInfo", "(", ")", "r", ".", "version", "=", "\"1.0\"", "r", ".", "last_block_height", "=", "0", "r", ".", "last_block_app_hash", "=", "b''", "return", "r" ]
Since this will always respond with height=0, Tendermint will resync this app from the begining
[ "Since", "this", "will", "always", "respond", "with", "height", "=", "0", "Tendermint", "will", "resync", "this", "app", "from", "the", "begining" ]
fae896daa1c896c7c50f2c9cfe3f7f9cdb3fc986
https://github.com/robinagist/ezo/blob/fae896daa1c896c7c50f2c9cfe3f7f9cdb3fc986/ezo/core/tm_utils.py#L34-L43
40,340
robinagist/ezo
ezo/core/tm_utils.py
EzoABCI.check_tx
def check_tx(self, tx) -> ResponseCheckTx: """ Validate the Tx before entry into the mempool Checks the txs are submitted in order 1,2,3... If not an order, a non-zero code is returned and the tx will be dropped. """ value = decode_number(tx) if not value ...
python
def check_tx(self, tx) -> ResponseCheckTx: """ Validate the Tx before entry into the mempool Checks the txs are submitted in order 1,2,3... If not an order, a non-zero code is returned and the tx will be dropped. """ value = decode_number(tx) if not value ...
[ "def", "check_tx", "(", "self", ",", "tx", ")", "->", "ResponseCheckTx", ":", "value", "=", "decode_number", "(", "tx", ")", "if", "not", "value", "==", "(", "self", ".", "txCount", "+", "1", ")", ":", "# respond with non-zero code", "return", "ResponseChe...
Validate the Tx before entry into the mempool Checks the txs are submitted in order 1,2,3... If not an order, a non-zero code is returned and the tx will be dropped.
[ "Validate", "the", "Tx", "before", "entry", "into", "the", "mempool", "Checks", "the", "txs", "are", "submitted", "in", "order", "1", "2", "3", "...", "If", "not", "an", "order", "a", "non", "-", "zero", "code", "is", "returned", "and", "the", "tx", ...
fae896daa1c896c7c50f2c9cfe3f7f9cdb3fc986
https://github.com/robinagist/ezo/blob/fae896daa1c896c7c50f2c9cfe3f7f9cdb3fc986/ezo/core/tm_utils.py#L51-L62
40,341
robinagist/ezo
ezo/core/tm_utils.py
EzoABCI.query
def query(self, req) -> ResponseQuery: """Return the last tx count""" v = encode_number(self.txCount) return ResponseQuery(code=CodeTypeOk, value=v, height=self.last_block_height)
python
def query(self, req) -> ResponseQuery: """Return the last tx count""" v = encode_number(self.txCount) return ResponseQuery(code=CodeTypeOk, value=v, height=self.last_block_height)
[ "def", "query", "(", "self", ",", "req", ")", "->", "ResponseQuery", ":", "v", "=", "encode_number", "(", "self", ".", "txCount", ")", "return", "ResponseQuery", "(", "code", "=", "CodeTypeOk", ",", "value", "=", "v", ",", "height", "=", "self", ".", ...
Return the last tx count
[ "Return", "the", "last", "tx", "count" ]
fae896daa1c896c7c50f2c9cfe3f7f9cdb3fc986
https://github.com/robinagist/ezo/blob/fae896daa1c896c7c50f2c9cfe3f7f9cdb3fc986/ezo/core/tm_utils.py#L70-L73
40,342
robinagist/ezo
ezo/core/tm_utils.py
EzoABCI.commit
def commit(self) -> ResponseCommit: """Return the current encode state value to tendermint""" hash = struct.pack('>Q', self.txCount) return ResponseCommit(data=hash)
python
def commit(self) -> ResponseCommit: """Return the current encode state value to tendermint""" hash = struct.pack('>Q', self.txCount) return ResponseCommit(data=hash)
[ "def", "commit", "(", "self", ")", "->", "ResponseCommit", ":", "hash", "=", "struct", ".", "pack", "(", "'>Q'", ",", "self", ".", "txCount", ")", "return", "ResponseCommit", "(", "data", "=", "hash", ")" ]
Return the current encode state value to tendermint
[ "Return", "the", "current", "encode", "state", "value", "to", "tendermint" ]
fae896daa1c896c7c50f2c9cfe3f7f9cdb3fc986
https://github.com/robinagist/ezo/blob/fae896daa1c896c7c50f2c9cfe3f7f9cdb3fc986/ezo/core/tm_utils.py#L75-L78
40,343
chengsoonong/wib
wib/cli.py
track
def track(context, file_names): """Keep track of each file in list file_names. Tracking does not create or delete the actual file, it only tells the version control system whether to maintain versions (to keep track) of the file. """ context.obj.find_repo_type() for fn in file_names: ...
python
def track(context, file_names): """Keep track of each file in list file_names. Tracking does not create or delete the actual file, it only tells the version control system whether to maintain versions (to keep track) of the file. """ context.obj.find_repo_type() for fn in file_names: ...
[ "def", "track", "(", "context", ",", "file_names", ")", ":", "context", ".", "obj", ".", "find_repo_type", "(", ")", "for", "fn", "in", "file_names", ":", "context", ".", "obj", ".", "call", "(", "[", "context", ".", "obj", ".", "vc_name", ",", "'add...
Keep track of each file in list file_names. Tracking does not create or delete the actual file, it only tells the version control system whether to maintain versions (to keep track) of the file.
[ "Keep", "track", "of", "each", "file", "in", "list", "file_names", "." ]
ca701ed72cd9f23a8e887f72f36c0fb0af42ef70
https://github.com/chengsoonong/wib/blob/ca701ed72cd9f23a8e887f72f36c0fb0af42ef70/wib/cli.py#L58-L67
40,344
chengsoonong/wib
wib/cli.py
untrack
def untrack(context, file_names): """Forget about tracking each file in the list file_names Tracking does not create or delete the actual file, it only tells the version control system whether to maintain versions (to keep track) of the file. """ context.obj.find_repo_type() for fn in file_...
python
def untrack(context, file_names): """Forget about tracking each file in the list file_names Tracking does not create or delete the actual file, it only tells the version control system whether to maintain versions (to keep track) of the file. """ context.obj.find_repo_type() for fn in file_...
[ "def", "untrack", "(", "context", ",", "file_names", ")", ":", "context", ".", "obj", ".", "find_repo_type", "(", ")", "for", "fn", "in", "file_names", ":", "if", "context", ".", "obj", ".", "vc_name", "==", "'git'", ":", "context", ".", "obj", ".", ...
Forget about tracking each file in the list file_names Tracking does not create or delete the actual file, it only tells the version control system whether to maintain versions (to keep track) of the file.
[ "Forget", "about", "tracking", "each", "file", "in", "the", "list", "file_names" ]
ca701ed72cd9f23a8e887f72f36c0fb0af42ef70
https://github.com/chengsoonong/wib/blob/ca701ed72cd9f23a8e887f72f36c0fb0af42ef70/wib/cli.py#L73-L85
40,345
chengsoonong/wib
wib/cli.py
commit
def commit(context, message, name): """Commit saved changes to the repository. message - commit message name - tag name """ context.obj.find_repo_type() if context.obj.vc_name == 'git': context.obj.call(['git', 'commit', '-a', '-m', message]) elif context.obj.vc_name == 'hg': ...
python
def commit(context, message, name): """Commit saved changes to the repository. message - commit message name - tag name """ context.obj.find_repo_type() if context.obj.vc_name == 'git': context.obj.call(['git', 'commit', '-a', '-m', message]) elif context.obj.vc_name == 'hg': ...
[ "def", "commit", "(", "context", ",", "message", ",", "name", ")", ":", "context", ".", "obj", ".", "find_repo_type", "(", ")", "if", "context", ".", "obj", ".", "vc_name", "==", "'git'", ":", "context", ".", "obj", ".", "call", "(", "[", "'git'", ...
Commit saved changes to the repository. message - commit message name - tag name
[ "Commit", "saved", "changes", "to", "the", "repository", ".", "message", "-", "commit", "message", "name", "-", "tag", "name" ]
ca701ed72cd9f23a8e887f72f36c0fb0af42ef70
https://github.com/chengsoonong/wib/blob/ca701ed72cd9f23a8e887f72f36c0fb0af42ef70/wib/cli.py#L92-L105
40,346
chengsoonong/wib
wib/cli.py
revert
def revert(context, file_names): """Revert each file in the list file_names back to version in repo""" context.obj.find_repo_type() if len(file_names) == 0: click.echo('No file names to checkout specified.') click.echo('The following have changed since the last check in.') context.in...
python
def revert(context, file_names): """Revert each file in the list file_names back to version in repo""" context.obj.find_repo_type() if len(file_names) == 0: click.echo('No file names to checkout specified.') click.echo('The following have changed since the last check in.') context.in...
[ "def", "revert", "(", "context", ",", "file_names", ")", ":", "context", ".", "obj", ".", "find_repo_type", "(", ")", "if", "len", "(", "file_names", ")", "==", "0", ":", "click", ".", "echo", "(", "'No file names to checkout specified.'", ")", "click", "....
Revert each file in the list file_names back to version in repo
[ "Revert", "each", "file", "in", "the", "list", "file_names", "back", "to", "version", "in", "repo" ]
ca701ed72cd9f23a8e887f72f36c0fb0af42ef70
https://github.com/chengsoonong/wib/blob/ca701ed72cd9f23a8e887f72f36c0fb0af42ef70/wib/cli.py#L120-L131
40,347
chengsoonong/wib
wib/cli.py
status
def status(context): """See which files have changed, checked in, and uploaded""" context.obj.find_repo_type() context.obj.call([context.obj.vc_name, 'status'])
python
def status(context): """See which files have changed, checked in, and uploaded""" context.obj.find_repo_type() context.obj.call([context.obj.vc_name, 'status'])
[ "def", "status", "(", "context", ")", ":", "context", ".", "obj", ".", "find_repo_type", "(", ")", "context", ".", "obj", ".", "call", "(", "[", "context", ".", "obj", ".", "vc_name", ",", "'status'", "]", ")" ]
See which files have changed, checked in, and uploaded
[ "See", "which", "files", "have", "changed", "checked", "in", "and", "uploaded" ]
ca701ed72cd9f23a8e887f72f36c0fb0af42ef70
https://github.com/chengsoonong/wib/blob/ca701ed72cd9f23a8e887f72f36c0fb0af42ef70/wib/cli.py#L166-L169
40,348
chengsoonong/wib
wib/cli.py
diff
def diff(context, file_name): """See changes that occured since last check in""" context.obj.find_repo_type() if context.obj.vc_name == 'git': context.obj.call(['git', 'diff', '--color-words', '--ignore-space-change', file_name]) elif context.obj.vc_name == 'hg': ...
python
def diff(context, file_name): """See changes that occured since last check in""" context.obj.find_repo_type() if context.obj.vc_name == 'git': context.obj.call(['git', 'diff', '--color-words', '--ignore-space-change', file_name]) elif context.obj.vc_name == 'hg': ...
[ "def", "diff", "(", "context", ",", "file_name", ")", ":", "context", ".", "obj", ".", "find_repo_type", "(", ")", "if", "context", ".", "obj", ".", "vc_name", "==", "'git'", ":", "context", ".", "obj", ".", "call", "(", "[", "'git'", ",", "'diff'", ...
See changes that occured since last check in
[ "See", "changes", "that", "occured", "since", "last", "check", "in" ]
ca701ed72cd9f23a8e887f72f36c0fb0af42ef70
https://github.com/chengsoonong/wib/blob/ca701ed72cd9f23a8e887f72f36c0fb0af42ef70/wib/cli.py#L192-L199
40,349
chengsoonong/wib
wib/cli.py
Repo.find_repo_type
def find_repo_type(self): """Check for git or hg repository""" is_git = self.call(['git', 'rev-parse', '--is-inside-work-tree'], devnull=True) if is_git != 0: if self.debug: click.echo('not git') is_hg = self.call(['hg', '-q', 's...
python
def find_repo_type(self): """Check for git or hg repository""" is_git = self.call(['git', 'rev-parse', '--is-inside-work-tree'], devnull=True) if is_git != 0: if self.debug: click.echo('not git') is_hg = self.call(['hg', '-q', 's...
[ "def", "find_repo_type", "(", "self", ")", ":", "is_git", "=", "self", ".", "call", "(", "[", "'git'", ",", "'rev-parse'", ",", "'--is-inside-work-tree'", "]", ",", "devnull", "=", "True", ")", "if", "is_git", "!=", "0", ":", "if", "self", ".", "debug"...
Check for git or hg repository
[ "Check", "for", "git", "or", "hg", "repository" ]
ca701ed72cd9f23a8e887f72f36c0fb0af42ef70
https://github.com/chengsoonong/wib/blob/ca701ed72cd9f23a8e887f72f36c0fb0af42ef70/wib/cli.py#L31-L44
40,350
Cecca/lydoc
lydoc/__init__.py
main
def main(): """The main entry point of the program""" # Parse command line arguments argp = _cli_argument_parser() args = argp.parse_args() # setup logging logging.basicConfig( level=args.loglevel, format="%(levelname)s %(message)s") console.display("Collecting documentati...
python
def main(): """The main entry point of the program""" # Parse command line arguments argp = _cli_argument_parser() args = argp.parse_args() # setup logging logging.basicConfig( level=args.loglevel, format="%(levelname)s %(message)s") console.display("Collecting documentati...
[ "def", "main", "(", ")", ":", "# Parse command line arguments", "argp", "=", "_cli_argument_parser", "(", ")", "args", "=", "argp", ".", "parse_args", "(", ")", "# setup logging", "logging", ".", "basicConfig", "(", "level", "=", "args", ".", "loglevel", ",", ...
The main entry point of the program
[ "The", "main", "entry", "point", "of", "the", "program" ]
cd01dd5ed902b2574fb412c55bdc684276a88505
https://github.com/Cecca/lydoc/blob/cd01dd5ed902b2574fb412c55bdc684276a88505/lydoc/__init__.py#L45-L85
40,351
blockadeio/analyst_toolbench
blockade/cli/client.py
process_ioc
def process_ioc(args): """Process actions related to the IOC switch.""" client = IndicatorClient.from_config() client.set_debug(True) if args.get: response = client.get_indicators() elif args.single: response = client.add_indicators(indicators=[args.single], ...
python
def process_ioc(args): """Process actions related to the IOC switch.""" client = IndicatorClient.from_config() client.set_debug(True) if args.get: response = client.get_indicators() elif args.single: response = client.add_indicators(indicators=[args.single], ...
[ "def", "process_ioc", "(", "args", ")", ":", "client", "=", "IndicatorClient", ".", "from_config", "(", ")", "client", ".", "set_debug", "(", "True", ")", "if", "args", ".", "get", ":", "response", "=", "client", ".", "get_indicators", "(", ")", "elif", ...
Process actions related to the IOC switch.
[ "Process", "actions", "related", "to", "the", "IOC", "switch", "." ]
159b6f8cf8a91c5ff050f1579636ea90ab269863
https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/cli/client.py#L10-L35
40,352
blockadeio/analyst_toolbench
blockade/cli/client.py
process_events
def process_events(args): """Process actions related to events switch.""" client = EventsClient.from_config() client.set_debug(True) if args.get: response = client.get_events() elif args.flush: response = client.flush_events() return response
python
def process_events(args): """Process actions related to events switch.""" client = EventsClient.from_config() client.set_debug(True) if args.get: response = client.get_events() elif args.flush: response = client.flush_events() return response
[ "def", "process_events", "(", "args", ")", ":", "client", "=", "EventsClient", ".", "from_config", "(", ")", "client", ".", "set_debug", "(", "True", ")", "if", "args", ".", "get", ":", "response", "=", "client", ".", "get_events", "(", ")", "elif", "a...
Process actions related to events switch.
[ "Process", "actions", "related", "to", "events", "switch", "." ]
159b6f8cf8a91c5ff050f1579636ea90ab269863
https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/cli/client.py#L38-L46
40,353
blockadeio/analyst_toolbench
blockade/cli/client.py
main
def main(): """Run the code.""" parser = ArgumentParser(description="Blockade Analyst Bench") subs = parser.add_subparsers(dest='cmd') ioc = subs.add_parser('ioc', help="Perform actions with IOCs") ioc.add_argument('--single', '-s', help="Send a single IOC") ioc.add_argument('--file', '-f', hel...
python
def main(): """Run the code.""" parser = ArgumentParser(description="Blockade Analyst Bench") subs = parser.add_subparsers(dest='cmd') ioc = subs.add_parser('ioc', help="Perform actions with IOCs") ioc.add_argument('--single', '-s', help="Send a single IOC") ioc.add_argument('--file', '-f', hel...
[ "def", "main", "(", ")", ":", "parser", "=", "ArgumentParser", "(", "description", "=", "\"Blockade Analyst Bench\"", ")", "subs", "=", "parser", ".", "add_subparsers", "(", "dest", "=", "'cmd'", ")", "ioc", "=", "subs", ".", "add_parser", "(", "'ioc'", ",...
Run the code.
[ "Run", "the", "code", "." ]
159b6f8cf8a91c5ff050f1579636ea90ab269863
https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/cli/client.py#L49-L95
40,354
CodyKochmann/generators
generators/window.py
window
def window(iterable, size=2): ''' yields wondows of a given size ''' iterable = iter(iterable) d = deque(islice(iterable, size-1), maxlen=size) for _ in map(d.append, iterable): yield tuple(d)
python
def window(iterable, size=2): ''' yields wondows of a given size ''' iterable = iter(iterable) d = deque(islice(iterable, size-1), maxlen=size) for _ in map(d.append, iterable): yield tuple(d)
[ "def", "window", "(", "iterable", ",", "size", "=", "2", ")", ":", "iterable", "=", "iter", "(", "iterable", ")", "d", "=", "deque", "(", "islice", "(", "iterable", ",", "size", "-", "1", ")", ",", "maxlen", "=", "size", ")", "for", "_", "in", ...
yields wondows of a given size
[ "yields", "wondows", "of", "a", "given", "size" ]
e4ca4dd25d5023a94b0349c69d6224070cc2526f
https://github.com/CodyKochmann/generators/blob/e4ca4dd25d5023a94b0349c69d6224070cc2526f/generators/window.py#L12-L17
40,355
tradenity/python-sdk
tradenity/resources/credit_card_payment.py
CreditCardPayment.payment_mode
def payment_mode(self, payment_mode): """Sets the payment_mode of this CreditCardPayment. :param payment_mode: The payment_mode of this CreditCardPayment. :type: str """ allowed_values = ["authorize", "capture"] if payment_mode is not None and payment_mode not in allowe...
python
def payment_mode(self, payment_mode): """Sets the payment_mode of this CreditCardPayment. :param payment_mode: The payment_mode of this CreditCardPayment. :type: str """ allowed_values = ["authorize", "capture"] if payment_mode is not None and payment_mode not in allowe...
[ "def", "payment_mode", "(", "self", ",", "payment_mode", ")", ":", "allowed_values", "=", "[", "\"authorize\"", ",", "\"capture\"", "]", "if", "payment_mode", "is", "not", "None", "and", "payment_mode", "not", "in", "allowed_values", ":", "raise", "ValueError", ...
Sets the payment_mode of this CreditCardPayment. :param payment_mode: The payment_mode of this CreditCardPayment. :type: str
[ "Sets", "the", "payment_mode", "of", "this", "CreditCardPayment", "." ]
d13fbe23f4d6ff22554c6d8d2deaf209371adaf1
https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/credit_card_payment.py#L260-L274
40,356
ten10solutions/Geist
geist/matchers.py
match_via_correlation_coefficient
def match_via_correlation_coefficient(image, template, raw_tolerance=1, normed_tolerance=0.9): """ Matching algorithm based on 2-dimensional version of Pearson product-moment correlation coefficient. This is more robust in the case where the match might be scaled or slightly rotated. From experime...
python
def match_via_correlation_coefficient(image, template, raw_tolerance=1, normed_tolerance=0.9): """ Matching algorithm based on 2-dimensional version of Pearson product-moment correlation coefficient. This is more robust in the case where the match might be scaled or slightly rotated. From experime...
[ "def", "match_via_correlation_coefficient", "(", "image", ",", "template", ",", "raw_tolerance", "=", "1", ",", "normed_tolerance", "=", "0.9", ")", ":", "h", ",", "w", "=", "image", ".", "shape", "th", ",", "tw", "=", "template", ".", "shape", "temp_mean"...
Matching algorithm based on 2-dimensional version of Pearson product-moment correlation coefficient. This is more robust in the case where the match might be scaled or slightly rotated. From experimentation, this method is less prone to false positives than the correlation method.
[ "Matching", "algorithm", "based", "on", "2", "-", "dimensional", "version", "of", "Pearson", "product", "-", "moment", "correlation", "coefficient", "." ]
a1ef16d8b4c3777735008b671a50acfde3ce7bf1
https://github.com/ten10solutions/Geist/blob/a1ef16d8b4c3777735008b671a50acfde3ce7bf1/geist/matchers.py#L43-L59
40,357
ten10solutions/Geist
geist/matchers.py
match_positions
def match_positions(shape, list_of_coords): """ In cases where we have multiple matches, each highlighted by a region of coordinates, we need to separate matches, and find mean of each to return as match position """ match_array = np.zeros(shape) try: # excpetion hit on this line if noth...
python
def match_positions(shape, list_of_coords): """ In cases where we have multiple matches, each highlighted by a region of coordinates, we need to separate matches, and find mean of each to return as match position """ match_array = np.zeros(shape) try: # excpetion hit on this line if noth...
[ "def", "match_positions", "(", "shape", ",", "list_of_coords", ")", ":", "match_array", "=", "np", ".", "zeros", "(", "shape", ")", "try", ":", "# excpetion hit on this line if nothing in list_of_coords- i.e. no matches", "match_array", "[", "list_of_coords", "[", ":", ...
In cases where we have multiple matches, each highlighted by a region of coordinates, we need to separate matches, and find mean of each to return as match position
[ "In", "cases", "where", "we", "have", "multiple", "matches", "each", "highlighted", "by", "a", "region", "of", "coordinates", "we", "need", "to", "separate", "matches", "and", "find", "mean", "of", "each", "to", "return", "as", "match", "position" ]
a1ef16d8b4c3777735008b671a50acfde3ce7bf1
https://github.com/ten10solutions/Geist/blob/a1ef16d8b4c3777735008b671a50acfde3ce7bf1/geist/matchers.py#L114-L130
40,358
freevoid/django-datafilters
datafilters/filterform.py
FilterFormBase.is_empty
def is_empty(self): ''' Return `True` if form is valid and contains an empty lookup. ''' return (self.is_valid() and not self.simple_lookups and not self.complex_conditions and not self.extra_conditions)
python
def is_empty(self): ''' Return `True` if form is valid and contains an empty lookup. ''' return (self.is_valid() and not self.simple_lookups and not self.complex_conditions and not self.extra_conditions)
[ "def", "is_empty", "(", "self", ")", ":", "return", "(", "self", ".", "is_valid", "(", ")", "and", "not", "self", ".", "simple_lookups", "and", "not", "self", ".", "complex_conditions", "and", "not", "self", ".", "extra_conditions", ")" ]
Return `True` if form is valid and contains an empty lookup.
[ "Return", "True", "if", "form", "is", "valid", "and", "contains", "an", "empty", "lookup", "." ]
99051b3b3e97946981c0e9697576b0100093287c
https://github.com/freevoid/django-datafilters/blob/99051b3b3e97946981c0e9697576b0100093287c/datafilters/filterform.py#L118-L125
40,359
TissueMAPS/TmDeploy
tmdeploy/inventory.py
load_inventory
def load_inventory(hosts_file=HOSTS_FILE): '''Loads Ansible inventory from file. Parameters ---------- hosts_file: str, optional path to Ansible hosts file Returns ------- ConfigParser.SafeConfigParser content of `hosts_file` ''' inventory = SafeConfigParser(allow_n...
python
def load_inventory(hosts_file=HOSTS_FILE): '''Loads Ansible inventory from file. Parameters ---------- hosts_file: str, optional path to Ansible hosts file Returns ------- ConfigParser.SafeConfigParser content of `hosts_file` ''' inventory = SafeConfigParser(allow_n...
[ "def", "load_inventory", "(", "hosts_file", "=", "HOSTS_FILE", ")", ":", "inventory", "=", "SafeConfigParser", "(", "allow_no_value", "=", "True", ")", "if", "os", ".", "path", ".", "exists", "(", "hosts_file", ")", ":", "inventory", ".", "read", "(", "hos...
Loads Ansible inventory from file. Parameters ---------- hosts_file: str, optional path to Ansible hosts file Returns ------- ConfigParser.SafeConfigParser content of `hosts_file`
[ "Loads", "Ansible", "inventory", "from", "file", "." ]
f891b4ffb21431988bc4a063ae871da3bf284a45
https://github.com/TissueMAPS/TmDeploy/blob/f891b4ffb21431988bc4a063ae871da3bf284a45/tmdeploy/inventory.py#L147-L165
40,360
TissueMAPS/TmDeploy
tmdeploy/inventory.py
save_inventory
def save_inventory(inventory, hosts_file=HOSTS_FILE): '''Saves Ansible inventory to file. Parameters ---------- inventory: ConfigParser.SafeConfigParser content of the `hosts_file` hosts_file: str, optional path to Ansible hosts file ''' with open(hosts_file, 'w') as f: ...
python
def save_inventory(inventory, hosts_file=HOSTS_FILE): '''Saves Ansible inventory to file. Parameters ---------- inventory: ConfigParser.SafeConfigParser content of the `hosts_file` hosts_file: str, optional path to Ansible hosts file ''' with open(hosts_file, 'w') as f: ...
[ "def", "save_inventory", "(", "inventory", ",", "hosts_file", "=", "HOSTS_FILE", ")", ":", "with", "open", "(", "hosts_file", ",", "'w'", ")", "as", "f", ":", "inventory", ".", "write", "(", "f", ")" ]
Saves Ansible inventory to file. Parameters ---------- inventory: ConfigParser.SafeConfigParser content of the `hosts_file` hosts_file: str, optional path to Ansible hosts file
[ "Saves", "Ansible", "inventory", "to", "file", "." ]
f891b4ffb21431988bc4a063ae871da3bf284a45
https://github.com/TissueMAPS/TmDeploy/blob/f891b4ffb21431988bc4a063ae871da3bf284a45/tmdeploy/inventory.py#L168-L179
40,361
mobinrg/rpi_spark_drives
JMRPiSpark/Drives/Display/RPiDisplay.py
RPiDiaplay._init_config
def _init_config(self, width, height, spi=None, spiMosi= None, spiDC=None, spiCS=None, spiReset=None, spiClk=None): """! SPI hardware and display width, height initialization. """ self._spi = spi self._spi_mosi = spiMosi self._spi_dc = spiDC self._spi_cs = spiCS ...
python
def _init_config(self, width, height, spi=None, spiMosi= None, spiDC=None, spiCS=None, spiReset=None, spiClk=None): """! SPI hardware and display width, height initialization. """ self._spi = spi self._spi_mosi = spiMosi self._spi_dc = spiDC self._spi_cs = spiCS ...
[ "def", "_init_config", "(", "self", ",", "width", ",", "height", ",", "spi", "=", "None", ",", "spiMosi", "=", "None", ",", "spiDC", "=", "None", ",", "spiCS", "=", "None", ",", "spiReset", "=", "None", ",", "spiClk", "=", "None", ")", ":", "self",...
! SPI hardware and display width, height initialization.
[ "!", "SPI", "hardware", "and", "display", "width", "height", "initialization", "." ]
e1602d8268a5ef48e9e0a8b37de89e0233f946ea
https://github.com/mobinrg/rpi_spark_drives/blob/e1602d8268a5ef48e9e0a8b37de89e0233f946ea/JMRPiSpark/Drives/Display/RPiDisplay.py#L77-L89
40,362
mobinrg/rpi_spark_drives
JMRPiSpark/Drives/Display/RPiDisplay.py
RPiDiaplay._init_io
def _init_io(self): """! GPIO initialization. Set GPIO into BCM mode and init other IOs mode """ GPIO.setwarnings(False) GPIO.setmode( GPIO.BCM ) pins = [ self._spi_dc ] for pin in pins: GPIO.setup( pin, GPIO.OUT )
python
def _init_io(self): """! GPIO initialization. Set GPIO into BCM mode and init other IOs mode """ GPIO.setwarnings(False) GPIO.setmode( GPIO.BCM ) pins = [ self._spi_dc ] for pin in pins: GPIO.setup( pin, GPIO.OUT )
[ "def", "_init_io", "(", "self", ")", ":", "GPIO", ".", "setwarnings", "(", "False", ")", "GPIO", ".", "setmode", "(", "GPIO", ".", "BCM", ")", "pins", "=", "[", "self", ".", "_spi_dc", "]", "for", "pin", "in", "pins", ":", "GPIO", ".", "setup", "...
! GPIO initialization. Set GPIO into BCM mode and init other IOs mode
[ "!", "GPIO", "initialization", ".", "Set", "GPIO", "into", "BCM", "mode", "and", "init", "other", "IOs", "mode" ]
e1602d8268a5ef48e9e0a8b37de89e0233f946ea
https://github.com/mobinrg/rpi_spark_drives/blob/e1602d8268a5ef48e9e0a8b37de89e0233f946ea/JMRPiSpark/Drives/Display/RPiDisplay.py#L91-L100
40,363
mobinrg/rpi_spark_drives
JMRPiSpark/Drives/Display/RPiDisplay.py
RPiDiaplay.clear
def clear(self, fill = 0x00): """! Clear buffer data and other data RPiDiaplay object just implemented clear buffer data """ self._buffer = [ fill ] * ( self.width * self.height )
python
def clear(self, fill = 0x00): """! Clear buffer data and other data RPiDiaplay object just implemented clear buffer data """ self._buffer = [ fill ] * ( self.width * self.height )
[ "def", "clear", "(", "self", ",", "fill", "=", "0x00", ")", ":", "self", ".", "_buffer", "=", "[", "fill", "]", "*", "(", "self", ".", "width", "*", "self", ".", "height", ")" ]
! Clear buffer data and other data RPiDiaplay object just implemented clear buffer data
[ "!", "Clear", "buffer", "data", "and", "other", "data", "RPiDiaplay", "object", "just", "implemented", "clear", "buffer", "data" ]
e1602d8268a5ef48e9e0a8b37de89e0233f946ea
https://github.com/mobinrg/rpi_spark_drives/blob/e1602d8268a5ef48e9e0a8b37de89e0233f946ea/JMRPiSpark/Drives/Display/RPiDisplay.py#L116-L121
40,364
ONSdigital/sdc-rabbit
sdc/rabbit/consumers.py
AsyncConsumer.connect
def connect(self): """This method connects to RabbitMQ using a SelectConnection object, returning the connection handle. When the connection is established, the on_connection_open method will be invoked by pika. :rtype: pika.SelectConnection """ count = 1 ...
python
def connect(self): """This method connects to RabbitMQ using a SelectConnection object, returning the connection handle. When the connection is established, the on_connection_open method will be invoked by pika. :rtype: pika.SelectConnection """ count = 1 ...
[ "def", "connect", "(", "self", ")", ":", "count", "=", "1", "no_of_servers", "=", "len", "(", "self", ".", "_rabbit_urls", ")", "while", "True", ":", "server_choice", "=", "(", "count", "%", "no_of_servers", ")", "-", "1", "self", ".", "_url", "=", "...
This method connects to RabbitMQ using a SelectConnection object, returning the connection handle. When the connection is established, the on_connection_open method will be invoked by pika. :rtype: pika.SelectConnection
[ "This", "method", "connects", "to", "RabbitMQ", "using", "a", "SelectConnection", "object", "returning", "the", "connection", "handle", "." ]
985adfdb09cf1b263a1f311438baeb42cbcb503a
https://github.com/ONSdigital/sdc-rabbit/blob/985adfdb09cf1b263a1f311438baeb42cbcb503a/sdc/rabbit/consumers.py#L58-L88
40,365
ONSdigital/sdc-rabbit
sdc/rabbit/consumers.py
AsyncConsumer.nack_message
def nack_message(self, delivery_tag, **kwargs): """Negative acknowledge a message :param int delivery_tag: The deliver tag from the Basic.Deliver frame """ logger.info('Nacking message', delivery_tag=delivery_tag, **kwargs) self._channel.basic_nack(delivery_tag)
python
def nack_message(self, delivery_tag, **kwargs): """Negative acknowledge a message :param int delivery_tag: The deliver tag from the Basic.Deliver frame """ logger.info('Nacking message', delivery_tag=delivery_tag, **kwargs) self._channel.basic_nack(delivery_tag)
[ "def", "nack_message", "(", "self", ",", "delivery_tag", ",", "*", "*", "kwargs", ")", ":", "logger", ".", "info", "(", "'Nacking message'", ",", "delivery_tag", "=", "delivery_tag", ",", "*", "*", "kwargs", ")", "self", ".", "_channel", ".", "basic_nack",...
Negative acknowledge a message :param int delivery_tag: The deliver tag from the Basic.Deliver frame
[ "Negative", "acknowledge", "a", "message" ]
985adfdb09cf1b263a1f311438baeb42cbcb503a
https://github.com/ONSdigital/sdc-rabbit/blob/985adfdb09cf1b263a1f311438baeb42cbcb503a/sdc/rabbit/consumers.py#L266-L273
40,366
ONSdigital/sdc-rabbit
sdc/rabbit/consumers.py
MessageConsumer.tx_id
def tx_id(properties): """ Gets the tx_id for a message from a rabbit queue, using the message properties. Will raise KeyError if tx_id is missing from message headers. : param properties: Message properties : returns: tx_id of survey response : rtype: str ...
python
def tx_id(properties): """ Gets the tx_id for a message from a rabbit queue, using the message properties. Will raise KeyError if tx_id is missing from message headers. : param properties: Message properties : returns: tx_id of survey response : rtype: str ...
[ "def", "tx_id", "(", "properties", ")", ":", "tx_id", "=", "properties", ".", "headers", "[", "'tx_id'", "]", "logger", ".", "info", "(", "\"Retrieved tx_id from message properties: tx_id={}\"", ".", "format", "(", "tx_id", ")", ")", "return", "tx_id" ]
Gets the tx_id for a message from a rabbit queue, using the message properties. Will raise KeyError if tx_id is missing from message headers. : param properties: Message properties : returns: tx_id of survey response : rtype: str
[ "Gets", "the", "tx_id", "for", "a", "message", "from", "a", "rabbit", "queue", "using", "the", "message", "properties", ".", "Will", "raise", "KeyError", "if", "tx_id", "is", "missing", "from", "message", "headers", "." ]
985adfdb09cf1b263a1f311438baeb42cbcb503a
https://github.com/ONSdigital/sdc-rabbit/blob/985adfdb09cf1b263a1f311438baeb42cbcb503a/sdc/rabbit/consumers.py#L444-L457
40,367
ONSdigital/sdc-rabbit
sdc/rabbit/consumers.py
MessageConsumer.on_message
def on_message(self, unused_channel, basic_deliver, properties, body): """Called on receipt of a message from a queue. Processes the message using the self._process method or function and positively acknowledges the queue if successful. If processing is not succesful, the message can ei...
python
def on_message(self, unused_channel, basic_deliver, properties, body): """Called on receipt of a message from a queue. Processes the message using the self._process method or function and positively acknowledges the queue if successful. If processing is not succesful, the message can ei...
[ "def", "on_message", "(", "self", ",", "unused_channel", ",", "basic_deliver", ",", "properties", ",", "body", ")", ":", "if", "self", ".", "check_tx_id", ":", "try", ":", "tx_id", "=", "self", ".", "tx_id", "(", "properties", ")", "logger", ".", "info",...
Called on receipt of a message from a queue. Processes the message using the self._process method or function and positively acknowledges the queue if successful. If processing is not succesful, the message can either be rejected, quarantined or negatively acknowledged, depending on the...
[ "Called", "on", "receipt", "of", "a", "message", "from", "a", "queue", "." ]
985adfdb09cf1b263a1f311438baeb42cbcb503a
https://github.com/ONSdigital/sdc-rabbit/blob/985adfdb09cf1b263a1f311438baeb42cbcb503a/sdc/rabbit/consumers.py#L500-L580
40,368
objectrocket/python-client
objectrocket/auth.py
Auth.authenticate
def authenticate(self, username, password): """Authenticate against the ObjectRocket API. :param str username: The username to perform basic authentication against the API with. :param str password: The password to perform basic authentication against the API with. :returns: A token use...
python
def authenticate(self, username, password): """Authenticate against the ObjectRocket API. :param str username: The username to perform basic authentication against the API with. :param str password: The password to perform basic authentication against the API with. :returns: A token use...
[ "def", "authenticate", "(", "self", ",", "username", ",", "password", ")", ":", "# Update the username and password bound to this instance for re-authentication needs.", "self", ".", "_username", "=", "username", "self", ".", "_password", "=", "password", "# Attempt to auth...
Authenticate against the ObjectRocket API. :param str username: The username to perform basic authentication against the API with. :param str password: The password to perform basic authentication against the API with. :returns: A token used for authentication against token protected resources....
[ "Authenticate", "against", "the", "ObjectRocket", "API", "." ]
a65868c7511ff49a5fbe304e53bf592b7fc6d5ef
https://github.com/objectrocket/python-client/blob/a65868c7511ff49a5fbe304e53bf592b7fc6d5ef/objectrocket/auth.py#L27-L66
40,369
objectrocket/python-client
objectrocket/auth.py
Auth._refresh
def _refresh(self): """Refresh the API token using the currently bound credentials. This is simply a convenience method to be invoked automatically if authentication fails during normal client use. """ # Request and set a new API token. new_token = self.authenticate(self...
python
def _refresh(self): """Refresh the API token using the currently bound credentials. This is simply a convenience method to be invoked automatically if authentication fails during normal client use. """ # Request and set a new API token. new_token = self.authenticate(self...
[ "def", "_refresh", "(", "self", ")", ":", "# Request and set a new API token.", "new_token", "=", "self", ".", "authenticate", "(", "self", ".", "_username", ",", "self", ".", "_password", ")", "self", ".", "_token", "=", "new_token", "logger", ".", "info", ...
Refresh the API token using the currently bound credentials. This is simply a convenience method to be invoked automatically if authentication fails during normal client use.
[ "Refresh", "the", "API", "token", "using", "the", "currently", "bound", "credentials", "." ]
a65868c7511ff49a5fbe304e53bf592b7fc6d5ef
https://github.com/objectrocket/python-client/blob/a65868c7511ff49a5fbe304e53bf592b7fc6d5ef/objectrocket/auth.py#L86-L96
40,370
objectrocket/python-client
objectrocket/auth.py
Auth._verify
def _verify(self, token): """Verify that the given token is valid. :param str token: The API token to verify. :returns: The token's corresponding user model as a dict, or None if invalid. :rtype: dict """ # Attempt to authenticate. url = '{}{}/'.format(self._url,...
python
def _verify(self, token): """Verify that the given token is valid. :param str token: The API token to verify. :returns: The token's corresponding user model as a dict, or None if invalid. :rtype: dict """ # Attempt to authenticate. url = '{}{}/'.format(self._url,...
[ "def", "_verify", "(", "self", ",", "token", ")", ":", "# Attempt to authenticate.", "url", "=", "'{}{}/'", ".", "format", "(", "self", ".", "_url", ",", "'verify'", ")", "resp", "=", "requests", ".", "post", "(", "url", ",", "json", "=", "{", "'token'...
Verify that the given token is valid. :param str token: The API token to verify. :returns: The token's corresponding user model as a dict, or None if invalid. :rtype: dict
[ "Verify", "that", "the", "given", "token", "is", "valid", "." ]
a65868c7511ff49a5fbe304e53bf592b7fc6d5ef
https://github.com/objectrocket/python-client/blob/a65868c7511ff49a5fbe304e53bf592b7fc6d5ef/objectrocket/auth.py#L124-L140
40,371
wdbm/abstraction
es-1.py
preprocess
def preprocess(net, image): ''' convert to Caffe input image layout ''' return np.float32(np.rollaxis(image, 2)[::-1]) - net.transformer.mean["data"]
python
def preprocess(net, image): ''' convert to Caffe input image layout ''' return np.float32(np.rollaxis(image, 2)[::-1]) - net.transformer.mean["data"]
[ "def", "preprocess", "(", "net", ",", "image", ")", ":", "return", "np", ".", "float32", "(", "np", ".", "rollaxis", "(", "image", ",", "2", ")", "[", ":", ":", "-", "1", "]", ")", "-", "net", ".", "transformer", ".", "mean", "[", "\"data\"", "...
convert to Caffe input image layout
[ "convert", "to", "Caffe", "input", "image", "layout" ]
58c81e73954cc6b4cd2f79b2216467528a96376b
https://github.com/wdbm/abstraction/blob/58c81e73954cc6b4cd2f79b2216467528a96376b/es-1.py#L65-L69
40,372
wdbm/abstraction
es-1.py
make_step
def make_step( net, step_size = 1.5, end = "inception_4c/output", jitter = 32, clip = True, objective = objective_L2 ): ''' basic gradient ascent step ''' src = net.blobs["data"] dst = net.blobs[end] ox, oy = np.random.randint(- jitter, jitter + 1, 2)...
python
def make_step( net, step_size = 1.5, end = "inception_4c/output", jitter = 32, clip = True, objective = objective_L2 ): ''' basic gradient ascent step ''' src = net.blobs["data"] dst = net.blobs[end] ox, oy = np.random.randint(- jitter, jitter + 1, 2)...
[ "def", "make_step", "(", "net", ",", "step_size", "=", "1.5", ",", "end", "=", "\"inception_4c/output\"", ",", "jitter", "=", "32", ",", "clip", "=", "True", ",", "objective", "=", "objective_L2", ")", ":", "src", "=", "net", ".", "blobs", "[", "\"data...
basic gradient ascent step
[ "basic", "gradient", "ascent", "step" ]
58c81e73954cc6b4cd2f79b2216467528a96376b
https://github.com/wdbm/abstraction/blob/58c81e73954cc6b4cd2f79b2216467528a96376b/es-1.py#L83-L114
40,373
wdbm/abstraction
es-1.py
deepdream
def deepdream( net, base_image, iter_n = 10, octave_n = 4, octave_scale = 1.4, end = "inception_4c/output", clip = True, **step_params ): ''' an ascent through different scales called "octaves" ''' # Prepare base images for all octaves....
python
def deepdream( net, base_image, iter_n = 10, octave_n = 4, octave_scale = 1.4, end = "inception_4c/output", clip = True, **step_params ): ''' an ascent through different scales called "octaves" ''' # Prepare base images for all octaves....
[ "def", "deepdream", "(", "net", ",", "base_image", ",", "iter_n", "=", "10", ",", "octave_n", "=", "4", ",", "octave_scale", "=", "1.4", ",", "end", "=", "\"inception_4c/output\"", ",", "clip", "=", "True", ",", "*", "*", "step_params", ")", ":", "# Pr...
an ascent through different scales called "octaves"
[ "an", "ascent", "through", "different", "scales", "called", "octaves" ]
58c81e73954cc6b4cd2f79b2216467528a96376b
https://github.com/wdbm/abstraction/blob/58c81e73954cc6b4cd2f79b2216467528a96376b/es-1.py#L117-L175
40,374
jkitzes/macroeco
macroeco/main/_main.py
main
def main(param_path='parameters.txt'): """ Entry point function for analysis based on parameter files. Parameters ---------- param_path : str Path to user-generated parameter file """ # Confirm parameters file is present if not os.path.isfile(param_path): raise IOError...
python
def main(param_path='parameters.txt'): """ Entry point function for analysis based on parameter files. Parameters ---------- param_path : str Path to user-generated parameter file """ # Confirm parameters file is present if not os.path.isfile(param_path): raise IOError...
[ "def", "main", "(", "param_path", "=", "'parameters.txt'", ")", ":", "# Confirm parameters file is present", "if", "not", "os", ".", "path", ".", "isfile", "(", "param_path", ")", ":", "raise", "IOError", ",", "\"Parameter file not found at %s\"", "%", "param_path",...
Entry point function for analysis based on parameter files. Parameters ---------- param_path : str Path to user-generated parameter file
[ "Entry", "point", "function", "for", "analysis", "based", "on", "parameter", "files", "." ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/main/_main.py#L29-L96
40,375
jkitzes/macroeco
macroeco/main/_main.py
_do_analysis
def _do_analysis(options): """ Do analysis for a single run, as specified by options. Parameters ---------- options : dict Option names and values for analysis """ module = _function_location(options) core_results = _call_analysis_function(options, module) if module == 'e...
python
def _do_analysis(options): """ Do analysis for a single run, as specified by options. Parameters ---------- options : dict Option names and values for analysis """ module = _function_location(options) core_results = _call_analysis_function(options, module) if module == 'e...
[ "def", "_do_analysis", "(", "options", ")", ":", "module", "=", "_function_location", "(", "options", ")", "core_results", "=", "_call_analysis_function", "(", "options", ",", "module", ")", "if", "module", "==", "'emp'", "and", "(", "'models'", "in", "options...
Do analysis for a single run, as specified by options. Parameters ---------- options : dict Option names and values for analysis
[ "Do", "analysis", "for", "a", "single", "run", "as", "specified", "by", "options", "." ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/main/_main.py#L141-L160
40,376
jkitzes/macroeco
macroeco/main/_main.py
_call_analysis_function
def _call_analysis_function(options, module): """ Call function from module and get result, using inputs from options Parameters ---------- options : dict Option names and values for analysis module : str Short name of module within macroeco containing analysis function Ret...
python
def _call_analysis_function(options, module): """ Call function from module and get result, using inputs from options Parameters ---------- options : dict Option names and values for analysis module : str Short name of module within macroeco containing analysis function Ret...
[ "def", "_call_analysis_function", "(", "options", ",", "module", ")", ":", "args", ",", "kwargs", "=", "_get_args_kwargs", "(", "options", ",", "module", ")", "return", "eval", "(", "\"%s.%s(*args, **kwargs)\"", "%", "(", "module", ",", "options", "[", "'analy...
Call function from module and get result, using inputs from options Parameters ---------- options : dict Option names and values for analysis module : str Short name of module within macroeco containing analysis function Returns ------- dataframe, array, value, list of tupl...
[ "Call", "function", "from", "module", "and", "get", "result", "using", "inputs", "from", "options" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/main/_main.py#L180-L202
40,377
jkitzes/macroeco
macroeco/main/_main.py
_emp_extra_options
def _emp_extra_options(options): """ Get special options patch, cols, and splits if analysis in emp module """ # Check that metadata is valid metadata_path = os.path.normpath(os.path.join(options['param_dir'], options['metadata'])) if not os.pat...
python
def _emp_extra_options(options): """ Get special options patch, cols, and splits if analysis in emp module """ # Check that metadata is valid metadata_path = os.path.normpath(os.path.join(options['param_dir'], options['metadata'])) if not os.pat...
[ "def", "_emp_extra_options", "(", "options", ")", ":", "# Check that metadata is valid", "metadata_path", "=", "os", ".", "path", ".", "normpath", "(", "os", ".", "path", ".", "join", "(", "options", "[", "'param_dir'", "]", ",", "options", "[", "'metadata'", ...
Get special options patch, cols, and splits if analysis in emp module
[ "Get", "special", "options", "patch", "cols", "and", "splits", "if", "analysis", "in", "emp", "module" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/main/_main.py#L249-L272
40,378
jkitzes/macroeco
macroeco/main/_main.py
_fit_models
def _fit_models(options, core_results): """ Fit models to empirical result from a function in emp module Parameters ---------- options : dict Option names and values for analysis core_results : list of tuples Output of function in emp Returns ------- list of dicts ...
python
def _fit_models(options, core_results): """ Fit models to empirical result from a function in emp module Parameters ---------- options : dict Option names and values for analysis core_results : list of tuples Output of function in emp Returns ------- list of dicts ...
[ "def", "_fit_models", "(", "options", ",", "core_results", ")", ":", "logging", ".", "info", "(", "\"Fitting models\"", ")", "models", "=", "options", "[", "'models'", "]", ".", "replace", "(", "' '", ",", "''", ")", ".", "split", "(", "';'", ")", "# T...
Fit models to empirical result from a function in emp module Parameters ---------- options : dict Option names and values for analysis core_results : list of tuples Output of function in emp Returns ------- list of dicts Each element in list corresponds to a subset....
[ "Fit", "models", "to", "empirical", "result", "from", "a", "function", "in", "emp", "module" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/main/_main.py#L302-L345
40,379
jkitzes/macroeco
macroeco/main/_main.py
_save_results
def _save_results(options, module, core_results, fit_results): """ Save results of analysis as tables and figures Parameters ---------- options : dict Option names and values for analysis module : str Module that contained function used to generate core_results core_results ...
python
def _save_results(options, module, core_results, fit_results): """ Save results of analysis as tables and figures Parameters ---------- options : dict Option names and values for analysis module : str Module that contained function used to generate core_results core_results ...
[ "def", "_save_results", "(", "options", ",", "module", ",", "core_results", ",", "fit_results", ")", ":", "logging", ".", "info", "(", "\"Saving all results\"", ")", "# Use custom plot format", "mpl", ".", "rcParams", ".", "update", "(", "misc", ".", "rcparams",...
Save results of analysis as tables and figures Parameters ---------- options : dict Option names and values for analysis module : str Module that contained function used to generate core_results core_results : dataframe, array, value, list of tuples Results of main analysis ...
[ "Save", "results", "of", "analysis", "as", "tables", "and", "figures" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/main/_main.py#L398-L437
40,380
jkitzes/macroeco
macroeco/main/_main.py
_write_subset_index_file
def _write_subset_index_file(options, core_results): """ Write table giving index of subsets, giving number and subset string """ f_path = os.path.join(options['run_dir'], '_subset_index.csv') subset_strs = zip(*core_results)[0] index = np.arange(len(subset_strs)) + 1 df = pd.DataFrame({'su...
python
def _write_subset_index_file(options, core_results): """ Write table giving index of subsets, giving number and subset string """ f_path = os.path.join(options['run_dir'], '_subset_index.csv') subset_strs = zip(*core_results)[0] index = np.arange(len(subset_strs)) + 1 df = pd.DataFrame({'su...
[ "def", "_write_subset_index_file", "(", "options", ",", "core_results", ")", ":", "f_path", "=", "os", ".", "path", ".", "join", "(", "options", "[", "'run_dir'", "]", ",", "'_subset_index.csv'", ")", "subset_strs", "=", "zip", "(", "*", "core_results", ")",...
Write table giving index of subsets, giving number and subset string
[ "Write", "table", "giving", "index", "of", "subsets", "giving", "number", "and", "subset", "string" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/main/_main.py#L474-L483
40,381
jkitzes/macroeco
macroeco/main/_main.py
_pad_plot_frame
def _pad_plot_frame(ax, pad=0.01): """ Provides padding on sides of frame equal to pad fraction of plot """ xmin, xmax = ax.get_xlim() ymin, ymax = ax.get_ylim() xr = xmax - xmin yr = ymax - ymin ax.set_xlim(xmin - xr*pad, xmax + xr*pad) ax.set_ylim(ymin - yr*pad, ymax + yr*pad) ...
python
def _pad_plot_frame(ax, pad=0.01): """ Provides padding on sides of frame equal to pad fraction of plot """ xmin, xmax = ax.get_xlim() ymin, ymax = ax.get_ylim() xr = xmax - xmin yr = ymax - ymin ax.set_xlim(xmin - xr*pad, xmax + xr*pad) ax.set_ylim(ymin - yr*pad, ymax + yr*pad) ...
[ "def", "_pad_plot_frame", "(", "ax", ",", "pad", "=", "0.01", ")", ":", "xmin", ",", "xmax", "=", "ax", ".", "get_xlim", "(", ")", "ymin", ",", "ymax", "=", "ax", ".", "get_ylim", "(", ")", "xr", "=", "xmax", "-", "xmin", "yr", "=", "ymax", "-"...
Provides padding on sides of frame equal to pad fraction of plot
[ "Provides", "padding", "on", "sides", "of", "frame", "equal", "to", "pad", "fraction", "of", "plot" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/main/_main.py#L593-L606
40,382
jkitzes/macroeco
macroeco/main/_main.py
_output_cdf_plot
def _output_cdf_plot(core_result, spid, models, options, fit_results): """Function for plotting cdf""" # CDF x = core_result['y'].values df = emp.empirical_cdf(x) df.columns = ['x', 'empirical'] def calc_func(model, df, shapes): return eval("mod.%s.cdf(df['x'], *shapes)" % model) ...
python
def _output_cdf_plot(core_result, spid, models, options, fit_results): """Function for plotting cdf""" # CDF x = core_result['y'].values df = emp.empirical_cdf(x) df.columns = ['x', 'empirical'] def calc_func(model, df, shapes): return eval("mod.%s.cdf(df['x'], *shapes)" % model) ...
[ "def", "_output_cdf_plot", "(", "core_result", ",", "spid", ",", "models", ",", "options", ",", "fit_results", ")", ":", "# CDF", "x", "=", "core_result", "[", "'y'", "]", ".", "values", "df", "=", "emp", ".", "empirical_cdf", "(", "x", ")", "df", ".",...
Function for plotting cdf
[ "Function", "for", "plotting", "cdf" ]
ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/main/_main.py#L609-L623
40,383
mobinrg/rpi_spark_drives
JMRPiSpark/Drives/Attitude/MPU6050.py
MPU6050.openOnlyAccel
def openOnlyAccel(self, cycleFreq = 0x00 ): """! Trun on device into Accelerometer Only Low Power Mode @param cycleFreq can be choise: @see VAL_PWR_MGMT_2_LP_WAKE_CTRL_1_25HZ is default @see VAL_PWR_MGMT_2_LP_WAKE_CTRL_5HZ @see VAL_PWR_MGMT_2_LP_WAKE_CTRL_20H...
python
def openOnlyAccel(self, cycleFreq = 0x00 ): """! Trun on device into Accelerometer Only Low Power Mode @param cycleFreq can be choise: @see VAL_PWR_MGMT_2_LP_WAKE_CTRL_1_25HZ is default @see VAL_PWR_MGMT_2_LP_WAKE_CTRL_5HZ @see VAL_PWR_MGMT_2_LP_WAKE_CTRL_20H...
[ "def", "openOnlyAccel", "(", "self", ",", "cycleFreq", "=", "0x00", ")", ":", "self", ".", "openWith", "(", "accel", "=", "True", ",", "gyro", "=", "False", ",", "temp", "=", "False", ",", "cycle", "=", "True", ",", "cycleFreq", "=", "cycleFreq", ")"...
! Trun on device into Accelerometer Only Low Power Mode @param cycleFreq can be choise: @see VAL_PWR_MGMT_2_LP_WAKE_CTRL_1_25HZ is default @see VAL_PWR_MGMT_2_LP_WAKE_CTRL_5HZ @see VAL_PWR_MGMT_2_LP_WAKE_CTRL_20HZ @see VAL_PWR_MGMT_2_LP_WAKE_CTRL_40HZ
[ "!", "Trun", "on", "device", "into", "Accelerometer", "Only", "Low", "Power", "Mode" ]
e1602d8268a5ef48e9e0a8b37de89e0233f946ea
https://github.com/mobinrg/rpi_spark_drives/blob/e1602d8268a5ef48e9e0a8b37de89e0233f946ea/JMRPiSpark/Drives/Attitude/MPU6050.py#L272-L281
40,384
mobinrg/rpi_spark_drives
JMRPiSpark/Drives/Attitude/MPU6050.py
MPU6050.setMotionInt
def setMotionInt(self, motDHPF = 0x01, motTHR = 0x14, motDUR = 0x30, motDeteDec = 0x15 ): """! Set to enable Motion Detection Interrupt @param motDHPF Set the Digital High Pass Filter. Default is 0x01 (5Hz) @param motTHR Desired motion threshold. Default is 20 (0x14) @param mot...
python
def setMotionInt(self, motDHPF = 0x01, motTHR = 0x14, motDUR = 0x30, motDeteDec = 0x15 ): """! Set to enable Motion Detection Interrupt @param motDHPF Set the Digital High Pass Filter. Default is 0x01 (5Hz) @param motTHR Desired motion threshold. Default is 20 (0x14) @param mot...
[ "def", "setMotionInt", "(", "self", ",", "motDHPF", "=", "0x01", ",", "motTHR", "=", "0x14", ",", "motDUR", "=", "0x30", ",", "motDeteDec", "=", "0x15", ")", ":", "#After power on (0x00 to register (decimal) 107), the Motion Detection Interrupt can be enabled as follows:"...
! Set to enable Motion Detection Interrupt @param motDHPF Set the Digital High Pass Filter. Default is 0x01 (5Hz) @param motTHR Desired motion threshold. Default is 20 (0x14) @param motDUR Desired motion duration. Default is 48ms (0x30) @param motDeteDec Motion detection decre...
[ "!", "Set", "to", "enable", "Motion", "Detection", "Interrupt" ]
e1602d8268a5ef48e9e0a8b37de89e0233f946ea
https://github.com/mobinrg/rpi_spark_drives/blob/e1602d8268a5ef48e9e0a8b37de89e0233f946ea/JMRPiSpark/Drives/Attitude/MPU6050.py#L290-L346
40,385
mobinrg/rpi_spark_drives
JMRPiSpark/Drives/Attitude/MPU6050.py
MPU6050.readAccelRange
def readAccelRange( self ): """! Reads the range of accelerometer setup. @return an int value. It should be one of the following values: @see ACCEL_RANGE_2G @see ACCEL_RANGE_4G @see ACCEL_RANGE_8G @see ACCEL_RANGE_16G ...
python
def readAccelRange( self ): """! Reads the range of accelerometer setup. @return an int value. It should be one of the following values: @see ACCEL_RANGE_2G @see ACCEL_RANGE_4G @see ACCEL_RANGE_8G @see ACCEL_RANGE_16G ...
[ "def", "readAccelRange", "(", "self", ")", ":", "raw_data", "=", "self", ".", "_readByte", "(", "self", ".", "REG_ACCEL_CONFIG", ")", "raw_data", "=", "(", "raw_data", "|", "0xE7", ")", "^", "0xE7", "return", "raw_data" ]
! Reads the range of accelerometer setup. @return an int value. It should be one of the following values: @see ACCEL_RANGE_2G @see ACCEL_RANGE_4G @see ACCEL_RANGE_8G @see ACCEL_RANGE_16G
[ "!", "Reads", "the", "range", "of", "accelerometer", "setup", "." ]
e1602d8268a5ef48e9e0a8b37de89e0233f946ea
https://github.com/mobinrg/rpi_spark_drives/blob/e1602d8268a5ef48e9e0a8b37de89e0233f946ea/JMRPiSpark/Drives/Attitude/MPU6050.py#L414-L427
40,386
mobinrg/rpi_spark_drives
JMRPiSpark/Drives/Attitude/MPU6050.py
MPU6050.getAccelData
def getAccelData( self, raw = False ): """! Gets and returns the X, Y and Z values from the accelerometer. @param raw If raw is True, it will return the data in m/s^2,<br> If raw is False, it will return the data in g @return a dictionary with the measurement results or Boolean. ...
python
def getAccelData( self, raw = False ): """! Gets and returns the X, Y and Z values from the accelerometer. @param raw If raw is True, it will return the data in m/s^2,<br> If raw is False, it will return the data in g @return a dictionary with the measurement results or Boolean. ...
[ "def", "getAccelData", "(", "self", ",", "raw", "=", "False", ")", ":", "x", "=", "self", ".", "_readWord", "(", "self", ".", "REG_ACCEL_XOUT_H", ")", "y", "=", "self", ".", "_readWord", "(", "self", ".", "REG_ACCEL_YOUT_H", ")", "z", "=", "self", "....
! Gets and returns the X, Y and Z values from the accelerometer. @param raw If raw is True, it will return the data in m/s^2,<br> If raw is False, it will return the data in g @return a dictionary with the measurement results or Boolean. @retval {...} data in m/s^2 if raw is True. ...
[ "!", "Gets", "and", "returns", "the", "X", "Y", "and", "Z", "values", "from", "the", "accelerometer", "." ]
e1602d8268a5ef48e9e0a8b37de89e0233f946ea
https://github.com/mobinrg/rpi_spark_drives/blob/e1602d8268a5ef48e9e0a8b37de89e0233f946ea/JMRPiSpark/Drives/Attitude/MPU6050.py#L429-L467
40,387
mobinrg/rpi_spark_drives
JMRPiSpark/Drives/Attitude/MPU6050.py
MPU6050.readGyroRange
def readGyroRange( self ): """! Read range of gyroscope. @return an int value. It should be one of the following values (GYRO_RANGE_250DEG) @see GYRO_RANGE_250DEG @see GYRO_RANGE_500DEG @see GYRO_RANGE_1KDEG @see GYRO_RANGE_2KDEG """ raw_data = s...
python
def readGyroRange( self ): """! Read range of gyroscope. @return an int value. It should be one of the following values (GYRO_RANGE_250DEG) @see GYRO_RANGE_250DEG @see GYRO_RANGE_500DEG @see GYRO_RANGE_1KDEG @see GYRO_RANGE_2KDEG """ raw_data = s...
[ "def", "readGyroRange", "(", "self", ")", ":", "raw_data", "=", "self", ".", "_readByte", "(", "self", ".", "REG_GYRO_CONFIG", ")", "raw_data", "=", "(", "raw_data", "|", "0xE7", ")", "^", "0xE7", "return", "raw_data" ]
! Read range of gyroscope. @return an int value. It should be one of the following values (GYRO_RANGE_250DEG) @see GYRO_RANGE_250DEG @see GYRO_RANGE_500DEG @see GYRO_RANGE_1KDEG @see GYRO_RANGE_2KDEG
[ "!", "Read", "range", "of", "gyroscope", "." ]
e1602d8268a5ef48e9e0a8b37de89e0233f946ea
https://github.com/mobinrg/rpi_spark_drives/blob/e1602d8268a5ef48e9e0a8b37de89e0233f946ea/JMRPiSpark/Drives/Attitude/MPU6050.py#L483-L496
40,388
mobinrg/rpi_spark_drives
JMRPiSpark/Drives/Attitude/MPU6050.py
MPU6050.getGyroData
def getGyroData(self): """! Gets and returns the X, Y and Z values from the gyroscope @return a dictionary with the measurement results or Boolean. @retval {...} a dictionary data. @retval False means 'Unkown gyroscope range', that you need to check the "gyroscope range"...
python
def getGyroData(self): """! Gets and returns the X, Y and Z values from the gyroscope @return a dictionary with the measurement results or Boolean. @retval {...} a dictionary data. @retval False means 'Unkown gyroscope range', that you need to check the "gyroscope range"...
[ "def", "getGyroData", "(", "self", ")", ":", "x", "=", "self", ".", "_readWord", "(", "self", ".", "REG_GYRO_XOUT_H", ")", "y", "=", "self", ".", "_readWord", "(", "self", ".", "REG_GYRO_YOUT_H", ")", "z", "=", "self", ".", "_readWord", "(", "self", ...
! Gets and returns the X, Y and Z values from the gyroscope @return a dictionary with the measurement results or Boolean. @retval {...} a dictionary data. @retval False means 'Unkown gyroscope range', that you need to check the "gyroscope range" configuration @note Resul...
[ "!", "Gets", "and", "returns", "the", "X", "Y", "and", "Z", "values", "from", "the", "gyroscope" ]
e1602d8268a5ef48e9e0a8b37de89e0233f946ea
https://github.com/mobinrg/rpi_spark_drives/blob/e1602d8268a5ef48e9e0a8b37de89e0233f946ea/JMRPiSpark/Drives/Attitude/MPU6050.py#L498-L530
40,389
mobinrg/rpi_spark_drives
JMRPiSpark/Drives/Attitude/MPU6050.py
MPU6050.getAllData
def getAllData(self, temp = True, accel = True, gyro = True): """! Get all the available data. @param temp: True - Allow to return Temperature data @param accel: True - Allow to return Accelerometer data @param gyro: True - Allow to return Gyroscope data @return a dicti...
python
def getAllData(self, temp = True, accel = True, gyro = True): """! Get all the available data. @param temp: True - Allow to return Temperature data @param accel: True - Allow to return Accelerometer data @param gyro: True - Allow to return Gyroscope data @return a dicti...
[ "def", "getAllData", "(", "self", ",", "temp", "=", "True", ",", "accel", "=", "True", ",", "gyro", "=", "True", ")", ":", "allData", "=", "{", "}", "if", "temp", ":", "allData", "[", "\"temp\"", "]", "=", "self", ".", "getTemp", "(", ")", "if", ...
! Get all the available data. @param temp: True - Allow to return Temperature data @param accel: True - Allow to return Accelerometer data @param gyro: True - Allow to return Gyroscope data @return a dictionary data @retval {} Did not read any data @retv...
[ "!", "Get", "all", "the", "available", "data", "." ]
e1602d8268a5ef48e9e0a8b37de89e0233f946ea
https://github.com/mobinrg/rpi_spark_drives/blob/e1602d8268a5ef48e9e0a8b37de89e0233f946ea/JMRPiSpark/Drives/Attitude/MPU6050.py#L533-L555
40,390
CodyKochmann/generators
generators/repeater.py
repeater
def repeater(pipe, how_many=2): ''' this function repeats each value in the pipeline however many times you need ''' r = range(how_many) for i in pipe: for _ in r: yield i
python
def repeater(pipe, how_many=2): ''' this function repeats each value in the pipeline however many times you need ''' r = range(how_many) for i in pipe: for _ in r: yield i
[ "def", "repeater", "(", "pipe", ",", "how_many", "=", "2", ")", ":", "r", "=", "range", "(", "how_many", ")", "for", "i", "in", "pipe", ":", "for", "_", "in", "r", ":", "yield", "i" ]
this function repeats each value in the pipeline however many times you need
[ "this", "function", "repeats", "each", "value", "in", "the", "pipeline", "however", "many", "times", "you", "need" ]
e4ca4dd25d5023a94b0349c69d6224070cc2526f
https://github.com/CodyKochmann/generators/blob/e4ca4dd25d5023a94b0349c69d6224070cc2526f/generators/repeater.py#L7-L12
40,391
iron-lion/nJSD
src/njsd/entropy.py
kld
def kld(p1, p2): """Compute Kullback-Leibler divergence between p1 and p2. It assumes that p1 and p2 are already normalized that each of them sums to 1. """ return np.sum(np.where(p1 != 0, p1 * np.log(p1 / p2), 0))
python
def kld(p1, p2): """Compute Kullback-Leibler divergence between p1 and p2. It assumes that p1 and p2 are already normalized that each of them sums to 1. """ return np.sum(np.where(p1 != 0, p1 * np.log(p1 / p2), 0))
[ "def", "kld", "(", "p1", ",", "p2", ")", ":", "return", "np", ".", "sum", "(", "np", ".", "where", "(", "p1", "!=", "0", ",", "p1", "*", "np", ".", "log", "(", "p1", "/", "p2", ")", ",", "0", ")", ")" ]
Compute Kullback-Leibler divergence between p1 and p2. It assumes that p1 and p2 are already normalized that each of them sums to 1.
[ "Compute", "Kullback", "-", "Leibler", "divergence", "between", "p1", "and", "p2", ".", "It", "assumes", "that", "p1", "and", "p2", "are", "already", "normalized", "that", "each", "of", "them", "sums", "to", "1", "." ]
386397b7aa7251954771b2be4ce3a5d575033206
https://github.com/iron-lion/nJSD/blob/386397b7aa7251954771b2be4ce3a5d575033206/src/njsd/entropy.py#L42-L46
40,392
iron-lion/nJSD
src/njsd/entropy.py
jsd
def jsd(p1, p2): """Compute Jensen-Shannon divergence between p1 and p2. It assumes that p1 and p2 are already normalized that each of them sums to 1. """ m = (p1 + p2) / 2 return (kld(p1, m) + kld(p2, m)) / 2
python
def jsd(p1, p2): """Compute Jensen-Shannon divergence between p1 and p2. It assumes that p1 and p2 are already normalized that each of them sums to 1. """ m = (p1 + p2) / 2 return (kld(p1, m) + kld(p2, m)) / 2
[ "def", "jsd", "(", "p1", ",", "p2", ")", ":", "m", "=", "(", "p1", "+", "p2", ")", "/", "2", "return", "(", "kld", "(", "p1", ",", "m", ")", "+", "kld", "(", "p2", ",", "m", ")", ")", "/", "2" ]
Compute Jensen-Shannon divergence between p1 and p2. It assumes that p1 and p2 are already normalized that each of them sums to 1.
[ "Compute", "Jensen", "-", "Shannon", "divergence", "between", "p1", "and", "p2", ".", "It", "assumes", "that", "p1", "and", "p2", "are", "already", "normalized", "that", "each", "of", "them", "sums", "to", "1", "." ]
386397b7aa7251954771b2be4ce3a5d575033206
https://github.com/iron-lion/nJSD/blob/386397b7aa7251954771b2be4ce3a5d575033206/src/njsd/entropy.py#L49-L54
40,393
iron-lion/nJSD
src/njsd/entropy.py
njsd
def njsd(network, ref_gene_expression_dict, query_gene_expression_dict, gene_set): """Calculate Jensen-Shannon divergence between query and reference gene expression profile. """ gene_jsd_dict = dict() reference_genes = ref_gene_expression_dict.keys() assert len(reference_genes) != 'Reference g...
python
def njsd(network, ref_gene_expression_dict, query_gene_expression_dict, gene_set): """Calculate Jensen-Shannon divergence between query and reference gene expression profile. """ gene_jsd_dict = dict() reference_genes = ref_gene_expression_dict.keys() assert len(reference_genes) != 'Reference g...
[ "def", "njsd", "(", "network", ",", "ref_gene_expression_dict", ",", "query_gene_expression_dict", ",", "gene_set", ")", ":", "gene_jsd_dict", "=", "dict", "(", ")", "reference_genes", "=", "ref_gene_expression_dict", ".", "keys", "(", ")", "assert", "len", "(", ...
Calculate Jensen-Shannon divergence between query and reference gene expression profile.
[ "Calculate", "Jensen", "-", "Shannon", "divergence", "between", "query", "and", "reference", "gene", "expression", "profile", "." ]
386397b7aa7251954771b2be4ce3a5d575033206
https://github.com/iron-lion/nJSD/blob/386397b7aa7251954771b2be4ce3a5d575033206/src/njsd/entropy.py#L57-L83
40,394
nuSTORM/gnomon
gnomon/processors/__init__.py
lookupProcessor
def lookupProcessor(name): """Lookup processor class object by its name""" if name in _proc_lookup: return _proc_lookup[name] else: error_string = 'If you are creating a new processor, please read the\ documentation on creating a new processor' raise LookupError("Unknown processor %s...
python
def lookupProcessor(name): """Lookup processor class object by its name""" if name in _proc_lookup: return _proc_lookup[name] else: error_string = 'If you are creating a new processor, please read the\ documentation on creating a new processor' raise LookupError("Unknown processor %s...
[ "def", "lookupProcessor", "(", "name", ")", ":", "if", "name", "in", "_proc_lookup", ":", "return", "_proc_lookup", "[", "name", "]", "else", ":", "error_string", "=", "'If you are creating a new processor, please read the\\\ndocumentation on creating a new processor'", "ra...
Lookup processor class object by its name
[ "Lookup", "processor", "class", "object", "by", "its", "name" ]
7616486ecd6e26b76f677c380e62db1c0ade558a
https://github.com/nuSTORM/gnomon/blob/7616486ecd6e26b76f677c380e62db1c0ade558a/gnomon/processors/__init__.py#L39-L46
40,395
wuher/devil
devil/fields/__init__.py
serialize
def serialize(self, value, entity=None, request=None): """ Validate and serialize the value. This is the default implementation """ ret = self.from_python(value) self.validate(ret) self.run_validators(value) return ret
python
def serialize(self, value, entity=None, request=None): """ Validate and serialize the value. This is the default implementation """ ret = self.from_python(value) self.validate(ret) self.run_validators(value) return ret
[ "def", "serialize", "(", "self", ",", "value", ",", "entity", "=", "None", ",", "request", "=", "None", ")", ":", "ret", "=", "self", ".", "from_python", "(", "value", ")", "self", ".", "validate", "(", "ret", ")", "self", ".", "run_validators", "(",...
Validate and serialize the value. This is the default implementation
[ "Validate", "and", "serialize", "the", "value", "." ]
a8834d4f88d915a21754c6b96f99d0ad9123ad4d
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/fields/__init__.py#L23-L32
40,396
CodyKochmann/generators
generators/side_task.py
side_task
def side_task(pipe, *side_jobs): ''' allows you to run a function in a pipeline without affecting the data ''' # validate the input assert iterable(pipe), 'side_task needs the first argument to be iterable' for sj in side_jobs: assert callable(sj), 'all side_jobs need to be functions, not {}'.fo...
python
def side_task(pipe, *side_jobs): ''' allows you to run a function in a pipeline without affecting the data ''' # validate the input assert iterable(pipe), 'side_task needs the first argument to be iterable' for sj in side_jobs: assert callable(sj), 'all side_jobs need to be functions, not {}'.fo...
[ "def", "side_task", "(", "pipe", ",", "*", "side_jobs", ")", ":", "# validate the input", "assert", "iterable", "(", "pipe", ")", ",", "'side_task needs the first argument to be iterable'", "for", "sj", "in", "side_jobs", ":", "assert", "callable", "(", "sj", ")",...
allows you to run a function in a pipeline without affecting the data
[ "allows", "you", "to", "run", "a", "function", "in", "a", "pipeline", "without", "affecting", "the", "data" ]
e4ca4dd25d5023a94b0349c69d6224070cc2526f
https://github.com/CodyKochmann/generators/blob/e4ca4dd25d5023a94b0349c69d6224070cc2526f/generators/side_task.py#L24-L34
40,397
TissueMAPS/TmDeploy
elasticluster/elasticluster/providers/ec2_boto.py
BotoCloudProvider._connect
def _connect(self): """Connects to the ec2 cloud provider :return: :py:class:`boto.ec2.connection.EC2Connection` :raises: Generic exception on error """ # check for existing connection if self._ec2_connection: return self._ec2_connection if not self....
python
def _connect(self): """Connects to the ec2 cloud provider :return: :py:class:`boto.ec2.connection.EC2Connection` :raises: Generic exception on error """ # check for existing connection if self._ec2_connection: return self._ec2_connection if not self....
[ "def", "_connect", "(", "self", ")", ":", "# check for existing connection", "if", "self", ".", "_ec2_connection", ":", "return", "self", ".", "_ec2_connection", "if", "not", "self", ".", "_vpc", ":", "vpc_connection", "=", "None", "try", ":", "log", ".", "d...
Connects to the ec2 cloud provider :return: :py:class:`boto.ec2.connection.EC2Connection` :raises: Generic exception on error
[ "Connects", "to", "the", "ec2", "cloud", "provider" ]
f891b4ffb21431988bc4a063ae871da3bf284a45
https://github.com/TissueMAPS/TmDeploy/blob/f891b4ffb21431988bc4a063ae871da3bf284a45/elasticluster/elasticluster/providers/ec2_boto.py#L107-L167
40,398
CodyKochmann/generators
generators/split.py
split
def split(pipe, splitter, skip_empty=False): ''' this function works a lot like groupby but splits on given patterns, the same behavior as str.split provides. if skip_empty is True, split only yields pieces that have contents Example: splitting 1011101010101 by ...
python
def split(pipe, splitter, skip_empty=False): ''' this function works a lot like groupby but splits on given patterns, the same behavior as str.split provides. if skip_empty is True, split only yields pieces that have contents Example: splitting 1011101010101 by ...
[ "def", "split", "(", "pipe", ",", "splitter", ",", "skip_empty", "=", "False", ")", ":", "splitter", "=", "tuple", "(", "splitter", ")", "len_splitter", "=", "len", "(", "splitter", ")", "pipe", "=", "iter", "(", "pipe", ")", "current", "=", "deque", ...
this function works a lot like groupby but splits on given patterns, the same behavior as str.split provides. if skip_empty is True, split only yields pieces that have contents Example: splitting 1011101010101 by 10 returns ,11,,,,1 Or if s...
[ "this", "function", "works", "a", "lot", "like", "groupby", "but", "splits", "on", "given", "patterns", "the", "same", "behavior", "as", "str", ".", "split", "provides", ".", "if", "skip_empty", "is", "True", "split", "only", "yields", "pieces", "that", "h...
e4ca4dd25d5023a94b0349c69d6224070cc2526f
https://github.com/CodyKochmann/generators/blob/e4ca4dd25d5023a94b0349c69d6224070cc2526f/generators/split.py#L12-L46
40,399
erickgnavar/serpost
serpost/serpost.py
query_tracking_code
def query_tracking_code(tracking_code, year=None): """ Given a tracking_code return a list of events related the tracking code """ payload = { 'Anio': year or datetime.now().year, 'Tracking': tracking_code, } response = _make_request(TRACKING_URL, payload) if not response['d...
python
def query_tracking_code(tracking_code, year=None): """ Given a tracking_code return a list of events related the tracking code """ payload = { 'Anio': year or datetime.now().year, 'Tracking': tracking_code, } response = _make_request(TRACKING_URL, payload) if not response['d...
[ "def", "query_tracking_code", "(", "tracking_code", ",", "year", "=", "None", ")", ":", "payload", "=", "{", "'Anio'", ":", "year", "or", "datetime", ".", "now", "(", ")", ".", "year", ",", "'Tracking'", ":", "tracking_code", ",", "}", "response", "=", ...
Given a tracking_code return a list of events related the tracking code
[ "Given", "a", "tracking_code", "return", "a", "list", "of", "events", "related", "the", "tracking", "code" ]
1cf2ddd4e2fc2549ea6ebe426a14ec423f9ab0fa
https://github.com/erickgnavar/serpost/blob/1cf2ddd4e2fc2549ea6ebe426a14ec423f9ab0fa/serpost/serpost.py#L40-L61