repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
redhat-cip/python-dciclient
dciclient/v1/api/base.py
create
def create(context, resource, **kwargs): """Create a resource""" data = utils.sanitize_kwargs(**kwargs) uri = '%s/%s' % (context.dci_cs_api, resource) r = context.session.post(uri, timeout=HTTP_TIMEOUT, json=data) return r
python
def create(context, resource, **kwargs): """Create a resource""" data = utils.sanitize_kwargs(**kwargs) uri = '%s/%s' % (context.dci_cs_api, resource) r = context.session.post(uri, timeout=HTTP_TIMEOUT, json=data) return r
[ "def", "create", "(", "context", ",", "resource", ",", "*", "*", "kwargs", ")", ":", "data", "=", "utils", ".", "sanitize_kwargs", "(", "*", "*", "kwargs", ")", "uri", "=", "'%s/%s'", "%", "(", "context", ".", "dci_cs_api", ",", "resource", ")", "r",...
Create a resource
[ "Create", "a", "resource" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/api/base.py#L22-L28
train
Create a resource
redhat-cip/python-dciclient
dciclient/v1/api/base.py
list
def list(context, resource, **kwargs): """List all resources""" data = utils.sanitize_kwargs(**kwargs) id = data.pop('id', None) subresource = data.pop('subresource', None) if subresource: uri = '%s/%s/%s/%s' % (context.dci_cs_api, resource, id, subresource) else: uri = '%s/%s' ...
python
def list(context, resource, **kwargs): """List all resources""" data = utils.sanitize_kwargs(**kwargs) id = data.pop('id', None) subresource = data.pop('subresource', None) if subresource: uri = '%s/%s/%s/%s' % (context.dci_cs_api, resource, id, subresource) else: uri = '%s/%s' ...
[ "def", "list", "(", "context", ",", "resource", ",", "*", "*", "kwargs", ")", ":", "data", "=", "utils", ".", "sanitize_kwargs", "(", "*", "*", "kwargs", ")", "id", "=", "data", ".", "pop", "(", "'id'", ",", "None", ")", "subresource", "=", "data",...
List all resources
[ "List", "all", "resources" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/api/base.py#L31-L42
train
List all resources in a resource.
redhat-cip/python-dciclient
dciclient/v1/api/base.py
iter
def iter(context, resource, **kwargs): """List all resources""" data = utils.sanitize_kwargs(**kwargs) id = data.pop('id', None) subresource = data.pop('subresource', None) data['limit'] = data.get('limit', 20) if subresource: uri = '%s/%s/%s/%s' % (context.dci_cs_api, resource, id, sub...
python
def iter(context, resource, **kwargs): """List all resources""" data = utils.sanitize_kwargs(**kwargs) id = data.pop('id', None) subresource = data.pop('subresource', None) data['limit'] = data.get('limit', 20) if subresource: uri = '%s/%s/%s/%s' % (context.dci_cs_api, resource, id, sub...
[ "def", "iter", "(", "context", ",", "resource", ",", "*", "*", "kwargs", ")", ":", "data", "=", "utils", ".", "sanitize_kwargs", "(", "*", "*", "kwargs", ")", "id", "=", "data", ".", "pop", "(", "'id'", ",", "None", ")", "subresource", "=", "data",...
List all resources
[ "List", "all", "resources" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/api/base.py#L45-L66
train
List all resources in a resource
redhat-cip/python-dciclient
dciclient/v1/api/base.py
get
def get(context, resource, **kwargs): """List a specific resource""" uri = '%s/%s/%s' % (context.dci_cs_api, resource, kwargs.pop('id')) r = context.session.get(uri, timeout=HTTP_TIMEOUT, params=kwargs) return r
python
def get(context, resource, **kwargs): """List a specific resource""" uri = '%s/%s/%s' % (context.dci_cs_api, resource, kwargs.pop('id')) r = context.session.get(uri, timeout=HTTP_TIMEOUT, params=kwargs) return r
[ "def", "get", "(", "context", ",", "resource", ",", "*", "*", "kwargs", ")", ":", "uri", "=", "'%s/%s/%s'", "%", "(", "context", ".", "dci_cs_api", ",", "resource", ",", "kwargs", ".", "pop", "(", "'id'", ")", ")", "r", "=", "context", ".", "sessio...
List a specific resource
[ "List", "a", "specific", "resource" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/api/base.py#L69-L73
train
List a specific resource
redhat-cip/python-dciclient
dciclient/v1/api/base.py
get_data
def get_data(context, resource, **kwargs): """Retrieve data field from a resource""" url_suffix = '' if 'keys' in kwargs and kwargs['keys']: url_suffix = '/?keys=%s' % ','.join(kwargs.pop('keys')) uri = '%s/%s/%s/data%s' % (context.dci_cs_api, resource, kwargs.po...
python
def get_data(context, resource, **kwargs): """Retrieve data field from a resource""" url_suffix = '' if 'keys' in kwargs and kwargs['keys']: url_suffix = '/?keys=%s' % ','.join(kwargs.pop('keys')) uri = '%s/%s/%s/data%s' % (context.dci_cs_api, resource, kwargs.po...
[ "def", "get_data", "(", "context", ",", "resource", ",", "*", "*", "kwargs", ")", ":", "url_suffix", "=", "''", "if", "'keys'", "in", "kwargs", "and", "kwargs", "[", "'keys'", "]", ":", "url_suffix", "=", "'/?keys=%s'", "%", "','", ".", "join", "(", ...
Retrieve data field from a resource
[ "Retrieve", "data", "field", "from", "a", "resource" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/api/base.py#L76-L87
train
Retrieve data field from a resource
redhat-cip/python-dciclient
dciclient/v1/api/base.py
update
def update(context, resource, **kwargs): """Update a specific resource""" etag = kwargs.pop('etag') id = kwargs.pop('id') data = utils.sanitize_kwargs(**kwargs) uri = '%s/%s/%s' % (context.dci_cs_api, resource, id) r = context.session.put(uri, timeout=HTTP_TIMEOUT, he...
python
def update(context, resource, **kwargs): """Update a specific resource""" etag = kwargs.pop('etag') id = kwargs.pop('id') data = utils.sanitize_kwargs(**kwargs) uri = '%s/%s/%s' % (context.dci_cs_api, resource, id) r = context.session.put(uri, timeout=HTTP_TIMEOUT, he...
[ "def", "update", "(", "context", ",", "resource", ",", "*", "*", "kwargs", ")", ":", "etag", "=", "kwargs", ".", "pop", "(", "'etag'", ")", "id", "=", "kwargs", ".", "pop", "(", "'id'", ")", "data", "=", "utils", ".", "sanitize_kwargs", "(", "*", ...
Update a specific resource
[ "Update", "a", "specific", "resource" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/api/base.py#L90-L99
train
Update a specific resource
redhat-cip/python-dciclient
dciclient/v1/api/base.py
delete
def delete(context, resource, id, **kwargs): """Delete a specific resource""" etag = kwargs.pop('etag', None) id = id subresource = kwargs.pop('subresource', None) subresource_id = kwargs.pop('subresource_id', None) uri = '%s/%s/%s' % (context.dci_cs_api, resource, id) if subresource: ...
python
def delete(context, resource, id, **kwargs): """Delete a specific resource""" etag = kwargs.pop('etag', None) id = id subresource = kwargs.pop('subresource', None) subresource_id = kwargs.pop('subresource_id', None) uri = '%s/%s/%s' % (context.dci_cs_api, resource, id) if subresource: ...
[ "def", "delete", "(", "context", ",", "resource", ",", "id", ",", "*", "*", "kwargs", ")", ":", "etag", "=", "kwargs", ".", "pop", "(", "'etag'", ",", "None", ")", "id", "=", "id", "subresource", "=", "kwargs", ".", "pop", "(", "'subresource'", ","...
Delete a specific resource
[ "Delete", "a", "specific", "resource" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/api/base.py#L102-L116
train
Delete a specific resource
redhat-cip/python-dciclient
dciclient/v1/api/base.py
purge
def purge(context, resource, **kwargs): """Purge resource type.""" uri = '%s/%s/purge' % (context.dci_cs_api, resource) if 'force' in kwargs and kwargs['force']: r = context.session.post(uri, timeout=HTTP_TIMEOUT) else: r = context.session.get(uri, timeout=HTTP_TIMEOUT) return r
python
def purge(context, resource, **kwargs): """Purge resource type.""" uri = '%s/%s/purge' % (context.dci_cs_api, resource) if 'force' in kwargs and kwargs['force']: r = context.session.post(uri, timeout=HTTP_TIMEOUT) else: r = context.session.get(uri, timeout=HTTP_TIMEOUT) return r
[ "def", "purge", "(", "context", ",", "resource", ",", "*", "*", "kwargs", ")", ":", "uri", "=", "'%s/%s/purge'", "%", "(", "context", ".", "dci_cs_api", ",", "resource", ")", "if", "'force'", "in", "kwargs", "and", "kwargs", "[", "'force'", "]", ":", ...
Purge resource type.
[ "Purge", "resource", "type", "." ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/api/base.py#L119-L126
train
Purge the resource type.
lsst-sqre/documenteer
documenteer/sphinxext/utils.py
parse_rst_content
def parse_rst_content(content, state): """Parse rST-formatted string content into docutils nodes Parameters ---------- content : `str` ReStructuredText-formatted content state : ``docutils.statemachine.State`` Usually the directive's ``state`` attribute. Returns ------- ...
python
def parse_rst_content(content, state): """Parse rST-formatted string content into docutils nodes Parameters ---------- content : `str` ReStructuredText-formatted content state : ``docutils.statemachine.State`` Usually the directive's ``state`` attribute. Returns ------- ...
[ "def", "parse_rst_content", "(", "content", ",", "state", ")", ":", "# http://www.sphinx-doc.org/en/master/extdev/markupapi.html", "# #parsing-directive-content-as-rest", "container_node", "=", "nodes", ".", "section", "(", ")", "container_node", ".", "document", "=", "stat...
Parse rST-formatted string content into docutils nodes Parameters ---------- content : `str` ReStructuredText-formatted content state : ``docutils.statemachine.State`` Usually the directive's ``state`` attribute. Returns ------- instance from ``docutils.nodes`` Docu...
[ "Parse", "rST", "-", "formatted", "string", "content", "into", "docutils", "nodes" ]
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxext/utils.py#L14-L41
train
Parse the rST - formatted string content into docutils nodes.
lsst-sqre/documenteer
documenteer/sphinxext/utils.py
make_python_xref_nodes
def make_python_xref_nodes(py_typestr, state, hide_namespace=False): """Make docutils nodes containing a cross-reference to a Python object. Parameters ---------- py_typestr : `str` Name of the Python object. For example ``'mypackage.mymodule.MyClass'``. If you have the object itself, o...
python
def make_python_xref_nodes(py_typestr, state, hide_namespace=False): """Make docutils nodes containing a cross-reference to a Python object. Parameters ---------- py_typestr : `str` Name of the Python object. For example ``'mypackage.mymodule.MyClass'``. If you have the object itself, o...
[ "def", "make_python_xref_nodes", "(", "py_typestr", ",", "state", ",", "hide_namespace", "=", "False", ")", ":", "if", "hide_namespace", ":", "template", "=", "':py:obj:`~{}`\\n'", "else", ":", "template", "=", "':py:obj:`{}`\\n'", "xref_text", "=", "template", "....
Make docutils nodes containing a cross-reference to a Python object. Parameters ---------- py_typestr : `str` Name of the Python object. For example ``'mypackage.mymodule.MyClass'``. If you have the object itself, or its type, use the `make_python_xref_nodes_for_type` function inste...
[ "Make", "docutils", "nodes", "containing", "a", "cross", "-", "reference", "to", "a", "Python", "object", "." ]
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxext/utils.py#L44-L83
train
Make docutils nodes containing a cross - reference to a Python object.
lsst-sqre/documenteer
documenteer/sphinxext/utils.py
make_python_xref_nodes_for_type
def make_python_xref_nodes_for_type(py_type, state, hide_namespace=False): """Make docutils nodes containing a cross-reference to a Python object, given the object's type. Parameters ---------- py_type : `obj` Type of an object. For example ``mypackage.mymodule.MyClass``. If you hav...
python
def make_python_xref_nodes_for_type(py_type, state, hide_namespace=False): """Make docutils nodes containing a cross-reference to a Python object, given the object's type. Parameters ---------- py_type : `obj` Type of an object. For example ``mypackage.mymodule.MyClass``. If you hav...
[ "def", "make_python_xref_nodes_for_type", "(", "py_type", ",", "state", ",", "hide_namespace", "=", "False", ")", ":", "if", "py_type", ".", "__module__", "==", "'builtins'", ":", "typestr", "=", "py_type", ".", "__name__", "else", ":", "typestr", "=", "'.'", ...
Make docutils nodes containing a cross-reference to a Python object, given the object's type. Parameters ---------- py_type : `obj` Type of an object. For example ``mypackage.mymodule.MyClass``. If you have instance of the type, use ``type(myinstance)``. state : ``docutils.statemach...
[ "Make", "docutils", "nodes", "containing", "a", "cross", "-", "reference", "to", "a", "Python", "object", "given", "the", "object", "s", "type", "." ]
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxext/utils.py#L86-L126
train
Make docutils nodes containing a cross - reference to a Python object.
lsst-sqre/documenteer
documenteer/sphinxext/utils.py
make_section
def make_section(section_id=None, contents=None): """Make a docutils section node. Parameters ---------- section_id : `str` Section identifier, which is appended to both the ``ids`` and ``names`` attributes. contents : `list` of ``docutils.nodes`` List of docutils nodes that...
python
def make_section(section_id=None, contents=None): """Make a docutils section node. Parameters ---------- section_id : `str` Section identifier, which is appended to both the ``ids`` and ``names`` attributes. contents : `list` of ``docutils.nodes`` List of docutils nodes that...
[ "def", "make_section", "(", "section_id", "=", "None", ",", "contents", "=", "None", ")", ":", "section", "=", "nodes", ".", "section", "(", ")", "section", "[", "'ids'", "]", ".", "append", "(", "nodes", ".", "make_id", "(", "section_id", ")", ")", ...
Make a docutils section node. Parameters ---------- section_id : `str` Section identifier, which is appended to both the ``ids`` and ``names`` attributes. contents : `list` of ``docutils.nodes`` List of docutils nodes that are inserted into the section. Returns ------- ...
[ "Make", "a", "docutils", "section", "node", "." ]
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxext/utils.py#L129-L150
train
Create a new section node.
lsst-sqre/documenteer
documenteer/sphinxext/utils.py
split_role_content
def split_role_content(role_rawsource): """Split the ``rawsource`` of a role into standard components. Parameters ---------- role_rawsource : `str` The content of the role: its ``rawsource`` attribute. Returns ------- parts : `dict` Dictionary with keys: ``last_com...
python
def split_role_content(role_rawsource): """Split the ``rawsource`` of a role into standard components. Parameters ---------- role_rawsource : `str` The content of the role: its ``rawsource`` attribute. Returns ------- parts : `dict` Dictionary with keys: ``last_com...
[ "def", "split_role_content", "(", "role_rawsource", ")", ":", "parts", "=", "{", "'last_component'", ":", "False", ",", "'display'", ":", "None", ",", "'ref'", ":", "None", "}", "if", "role_rawsource", ".", "startswith", "(", "'~'", ")", ":", "# Only the las...
Split the ``rawsource`` of a role into standard components. Parameters ---------- role_rawsource : `str` The content of the role: its ``rawsource`` attribute. Returns ------- parts : `dict` Dictionary with keys: ``last_component`` (`bool`) If `True`, the dis...
[ "Split", "the", "rawsource", "of", "a", "role", "into", "standard", "components", "." ]
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxext/utils.py#L156-L212
train
Split the rawsource of a role into standard components.
mojaie/chorus
chorus/molutil.py
assign_descriptors
def assign_descriptors(mol): """ Throws: RuntimeError: if minify_ring failed """ topology.recognize(mol) descriptor.assign_valence(mol) descriptor.assign_rotatable(mol) topology.minify_ring(mol) descriptor.assign_aromatic(mol)
python
def assign_descriptors(mol): """ Throws: RuntimeError: if minify_ring failed """ topology.recognize(mol) descriptor.assign_valence(mol) descriptor.assign_rotatable(mol) topology.minify_ring(mol) descriptor.assign_aromatic(mol)
[ "def", "assign_descriptors", "(", "mol", ")", ":", "topology", ".", "recognize", "(", "mol", ")", "descriptor", ".", "assign_valence", "(", "mol", ")", "descriptor", ".", "assign_rotatable", "(", "mol", ")", "topology", ".", "minify_ring", "(", "mol", ")", ...
Throws: RuntimeError: if minify_ring failed
[ "Throws", ":", "RuntimeError", ":", "if", "minify_ring", "failed" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/molutil.py#L25-L34
train
Assign descriptors to the topology.
mojaie/chorus
chorus/molutil.py
make_Hs_implicit
def make_Hs_implicit(original_mol, keep_stereo=True): """Return molecule that explicit hydrogens removed TODO: this query function should be renamed to "explicitHs_removed" """ mol = clone(original_mol) mol.descriptors.clear() # Reset descriptor to_remove = set() for i, nbrs in mol.neighbor...
python
def make_Hs_implicit(original_mol, keep_stereo=True): """Return molecule that explicit hydrogens removed TODO: this query function should be renamed to "explicitHs_removed" """ mol = clone(original_mol) mol.descriptors.clear() # Reset descriptor to_remove = set() for i, nbrs in mol.neighbor...
[ "def", "make_Hs_implicit", "(", "original_mol", ",", "keep_stereo", "=", "True", ")", ":", "mol", "=", "clone", "(", "original_mol", ")", "mol", ".", "descriptors", ".", "clear", "(", ")", "# Reset descriptor", "to_remove", "=", "set", "(", ")", "for", "i"...
Return molecule that explicit hydrogens removed TODO: this query function should be renamed to "explicitHs_removed"
[ "Return", "molecule", "that", "explicit", "hydrogens", "removed", "TODO", ":", "this", "query", "function", "should", "be", "renamed", "to", "explicitHs_removed" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/molutil.py#L37-L54
train
Return molecule that explicit hydrogens removed
mojaie/chorus
chorus/molutil.py
largest_graph
def largest_graph(mol): """Return a molecule which has largest graph in the compound Passing single molecule object will results as same as molutil.clone """ mol.require("Valence") mol.require("Topology") m = clone(mol) # Avoid modification of original object if m.isolated: for k in...
python
def largest_graph(mol): """Return a molecule which has largest graph in the compound Passing single molecule object will results as same as molutil.clone """ mol.require("Valence") mol.require("Topology") m = clone(mol) # Avoid modification of original object if m.isolated: for k in...
[ "def", "largest_graph", "(", "mol", ")", ":", "mol", ".", "require", "(", "\"Valence\"", ")", "mol", ".", "require", "(", "\"Topology\"", ")", "m", "=", "clone", "(", "mol", ")", "# Avoid modification of original object", "if", "m", ".", "isolated", ":", "...
Return a molecule which has largest graph in the compound Passing single molecule object will results as same as molutil.clone
[ "Return", "a", "molecule", "which", "has", "largest", "graph", "in", "the", "compound", "Passing", "single", "molecule", "object", "will", "results", "as", "same", "as", "molutil", ".", "clone" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/molutil.py#L64-L74
train
Returns a molecule which has largest graph in the compound Passing single molecule object will results as same as molutil. clone
mojaie/chorus
chorus/molutil.py
mw
def mw(mol, ndigits=2): """Return standard molecular weight :param ndigits: number of digits """ mol.require("Valence") return round(sum(a.mw() for _, a in mol.atoms_iter()), ndigits)
python
def mw(mol, ndigits=2): """Return standard molecular weight :param ndigits: number of digits """ mol.require("Valence") return round(sum(a.mw() for _, a in mol.atoms_iter()), ndigits)
[ "def", "mw", "(", "mol", ",", "ndigits", "=", "2", ")", ":", "mol", ".", "require", "(", "\"Valence\"", ")", "return", "round", "(", "sum", "(", "a", ".", "mw", "(", ")", "for", "_", ",", "a", "in", "mol", ".", "atoms_iter", "(", ")", ")", ",...
Return standard molecular weight :param ndigits: number of digits
[ "Return", "standard", "molecular", "weight", ":", "param", "ndigits", ":", "number", "of", "digits" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/molutil.py#L77-L82
train
Return standard molecular weight
mojaie/chorus
chorus/molutil.py
mw_wo_sw
def mw_wo_sw(mol, ndigits=2): """Molecular weight without salt and water :param ndigits: number of digits """ cp = clone(mol) # Avoid modification of original object remover.remove_water(cp) remover.remove_salt(cp) return round(sum(a.mw() for _, a in cp.atoms_iter()), ndigits)
python
def mw_wo_sw(mol, ndigits=2): """Molecular weight without salt and water :param ndigits: number of digits """ cp = clone(mol) # Avoid modification of original object remover.remove_water(cp) remover.remove_salt(cp) return round(sum(a.mw() for _, a in cp.atoms_iter()), ndigits)
[ "def", "mw_wo_sw", "(", "mol", ",", "ndigits", "=", "2", ")", ":", "cp", "=", "clone", "(", "mol", ")", "# Avoid modification of original object", "remover", ".", "remove_water", "(", "cp", ")", "remover", ".", "remove_salt", "(", "cp", ")", "return", "rou...
Molecular weight without salt and water :param ndigits: number of digits
[ "Molecular", "weight", "without", "salt", "and", "water", ":", "param", "ndigits", ":", "number", "of", "digits" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/molutil.py#L85-L92
train
Molecular weight without salt and water
mojaie/chorus
chorus/molutil.py
H_donor_count
def H_donor_count(mol): """Hydrogen bond donor count """ mol.require("Valence") return sum(1 for _, a in mol.atoms_iter() if a.H_donor)
python
def H_donor_count(mol): """Hydrogen bond donor count """ mol.require("Valence") return sum(1 for _, a in mol.atoms_iter() if a.H_donor)
[ "def", "H_donor_count", "(", "mol", ")", ":", "mol", ".", "require", "(", "\"Valence\"", ")", "return", "sum", "(", "1", "for", "_", ",", "a", "in", "mol", ".", "atoms_iter", "(", ")", "if", "a", ".", "H_donor", ")" ]
Hydrogen bond donor count
[ "Hydrogen", "bond", "donor", "count" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/molutil.py#L105-L108
train
Hydrogen bond donor count
mojaie/chorus
chorus/molutil.py
H_acceptor_count
def H_acceptor_count(mol): """Hydrogen bond acceptor count """ mol.require("Valence") return sum(1 for _, a in mol.atoms_iter() if a.H_acceptor)
python
def H_acceptor_count(mol): """Hydrogen bond acceptor count """ mol.require("Valence") return sum(1 for _, a in mol.atoms_iter() if a.H_acceptor)
[ "def", "H_acceptor_count", "(", "mol", ")", ":", "mol", ".", "require", "(", "\"Valence\"", ")", "return", "sum", "(", "1", "for", "_", ",", "a", "in", "mol", ".", "atoms_iter", "(", ")", "if", "a", ".", "H_acceptor", ")" ]
Hydrogen bond acceptor count
[ "Hydrogen", "bond", "acceptor", "count" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/molutil.py#L111-L114
train
Returns the number of hydrogen bond acceptor atoms in a molecule.
mojaie/chorus
chorus/molutil.py
rotatable_count
def rotatable_count(mol): """Rotatable bond count """ mol.require("Rotatable") return sum(1 for _, _, b in mol.bonds_iter() if b.rotatable)
python
def rotatable_count(mol): """Rotatable bond count """ mol.require("Rotatable") return sum(1 for _, _, b in mol.bonds_iter() if b.rotatable)
[ "def", "rotatable_count", "(", "mol", ")", ":", "mol", ".", "require", "(", "\"Rotatable\"", ")", "return", "sum", "(", "1", "for", "_", ",", "_", ",", "b", "in", "mol", ".", "bonds_iter", "(", ")", "if", "b", ".", "rotatable", ")" ]
Rotatable bond count
[ "Rotatable", "bond", "count" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/molutil.py#L117-L120
train
Count the number of rotatable bonds in a single molecule.
mojaie/chorus
chorus/molutil.py
rule_of_five_violation
def rule_of_five_violation(mol): """Lipinski's rule of five violation count """ v = 0 if mw(mol) > 500: v += 1 if H_donor_count(mol) > 5: v += 1 if H_acceptor_count(mol) > 10: v += 1 try: if wclogp.wclogp(mol) > 5: v += 1 except TypeError: # N/A ...
python
def rule_of_five_violation(mol): """Lipinski's rule of five violation count """ v = 0 if mw(mol) > 500: v += 1 if H_donor_count(mol) > 5: v += 1 if H_acceptor_count(mol) > 10: v += 1 try: if wclogp.wclogp(mol) > 5: v += 1 except TypeError: # N/A ...
[ "def", "rule_of_five_violation", "(", "mol", ")", ":", "v", "=", "0", "if", "mw", "(", "mol", ")", ">", "500", ":", "v", "+=", "1", "if", "H_donor_count", "(", "mol", ")", ">", "5", ":", "v", "+=", "1", "if", "H_acceptor_count", "(", "mol", ")", ...
Lipinski's rule of five violation count
[ "Lipinski", "s", "rule", "of", "five", "violation", "count" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/molutil.py#L123-L137
train
Lipinski s rule of five violation count
mojaie/chorus
chorus/molutil.py
composition
def composition(mol): """Molecular composition in dict format (ex. Glucose {'C': 6, 'H': 12, 'O': 6}). """ mol.require("Valence") c = Counter() for _, a in mol.atoms_iter(): c += a.composition() return c
python
def composition(mol): """Molecular composition in dict format (ex. Glucose {'C': 6, 'H': 12, 'O': 6}). """ mol.require("Valence") c = Counter() for _, a in mol.atoms_iter(): c += a.composition() return c
[ "def", "composition", "(", "mol", ")", ":", "mol", ".", "require", "(", "\"Valence\"", ")", "c", "=", "Counter", "(", ")", "for", "_", ",", "a", "in", "mol", ".", "atoms_iter", "(", ")", ":", "c", "+=", "a", ".", "composition", "(", ")", "return"...
Molecular composition in dict format (ex. Glucose {'C': 6, 'H': 12, 'O': 6}).
[ "Molecular", "composition", "in", "dict", "format", "(", "ex", ".", "Glucose", "{", "C", ":", "6", "H", ":", "12", "O", ":", "6", "}", ")", "." ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/molutil.py#L140-L148
train
Molecular composition in dict format
mojaie/chorus
chorus/molutil.py
formula
def formula(mol): """Chemical formula. Atoms should be arranged in order of C, H and other atoms. Molecules should be arranged in order of length of formula text. """ mol.require("Valence") mol.require("Topology") total_cntr = Counter() for m in sorted(mols_iter(mol), key=len, reverse=Tr...
python
def formula(mol): """Chemical formula. Atoms should be arranged in order of C, H and other atoms. Molecules should be arranged in order of length of formula text. """ mol.require("Valence") mol.require("Topology") total_cntr = Counter() for m in sorted(mols_iter(mol), key=len, reverse=Tr...
[ "def", "formula", "(", "mol", ")", ":", "mol", ".", "require", "(", "\"Valence\"", ")", "mol", ".", "require", "(", "\"Topology\"", ")", "total_cntr", "=", "Counter", "(", ")", "for", "m", "in", "sorted", "(", "mols_iter", "(", "mol", ")", ",", "key"...
Chemical formula. Atoms should be arranged in order of C, H and other atoms. Molecules should be arranged in order of length of formula text.
[ "Chemical", "formula", ".", "Atoms", "should", "be", "arranged", "in", "order", "of", "C", "H", "and", "other", "atoms", ".", "Molecules", "should", "be", "arranged", "in", "order", "of", "length", "of", "formula", "text", "." ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/molutil.py#L164-L200
train
Chemical formula.
zsimic/runez
src/runez/click.py
command
def command(epilog=None, help=None, width=140, **attrs): """Same as `@click.command()`, but with common settings (ie: "-h" for help, epilog, slightly larger help display)""" if epilog is None: epilog = _get_caller_doc() attrs = settings(epilog=epilog, help=help, width=width, **attrs) return clic...
python
def command(epilog=None, help=None, width=140, **attrs): """Same as `@click.command()`, but with common settings (ie: "-h" for help, epilog, slightly larger help display)""" if epilog is None: epilog = _get_caller_doc() attrs = settings(epilog=epilog, help=help, width=width, **attrs) return clic...
[ "def", "command", "(", "epilog", "=", "None", ",", "help", "=", "None", ",", "width", "=", "140", ",", "*", "*", "attrs", ")", ":", "if", "epilog", "is", "None", ":", "epilog", "=", "_get_caller_doc", "(", ")", "attrs", "=", "settings", "(", "epilo...
Same as `@click.command()`, but with common settings (ie: "-h" for help, epilog, slightly larger help display)
[ "Same", "as" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/click.py#L26-L31
train
Same as click. command but with common settings
zsimic/runez
src/runez/click.py
group
def group(epilog=None, help=None, width=140, **attrs): """Same as `@click.group()`, but with common settings (ie: "-h" for help, epilog, slightly larger help display)""" if epilog is None: epilog = _get_caller_doc() attrs = settings(epilog=epilog, help=help, width=width, **attrs) return click.gr...
python
def group(epilog=None, help=None, width=140, **attrs): """Same as `@click.group()`, but with common settings (ie: "-h" for help, epilog, slightly larger help display)""" if epilog is None: epilog = _get_caller_doc() attrs = settings(epilog=epilog, help=help, width=width, **attrs) return click.gr...
[ "def", "group", "(", "epilog", "=", "None", ",", "help", "=", "None", ",", "width", "=", "140", ",", "*", "*", "attrs", ")", ":", "if", "epilog", "is", "None", ":", "epilog", "=", "_get_caller_doc", "(", ")", "attrs", "=", "settings", "(", "epilog"...
Same as `@click.group()`, but with common settings (ie: "-h" for help, epilog, slightly larger help display)
[ "Same", "as" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/click.py#L34-L39
train
Same as click. group but with common settings
zsimic/runez
src/runez/click.py
config
def config(*args, **attrs): """Override configuration""" attrs.setdefault("metavar", "KEY=VALUE") attrs.setdefault("multiple", True) return option(config, *args, **attrs)
python
def config(*args, **attrs): """Override configuration""" attrs.setdefault("metavar", "KEY=VALUE") attrs.setdefault("multiple", True) return option(config, *args, **attrs)
[ "def", "config", "(", "*", "args", ",", "*", "*", "attrs", ")", ":", "attrs", ".", "setdefault", "(", "\"metavar\"", ",", "\"KEY=VALUE\"", ")", "attrs", ".", "setdefault", "(", "\"multiple\"", ",", "True", ")", "return", "option", "(", "config", ",", "...
Override configuration
[ "Override", "configuration" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/click.py#L42-L46
train
Override configuration
zsimic/runez
src/runez/click.py
debug
def debug(*args, **attrs): """Show debugging information.""" attrs.setdefault("is_flag", True) attrs.setdefault("default", None) return option(debug, *args, **attrs)
python
def debug(*args, **attrs): """Show debugging information.""" attrs.setdefault("is_flag", True) attrs.setdefault("default", None) return option(debug, *args, **attrs)
[ "def", "debug", "(", "*", "args", ",", "*", "*", "attrs", ")", ":", "attrs", ".", "setdefault", "(", "\"is_flag\"", ",", "True", ")", "attrs", ".", "setdefault", "(", "\"default\"", ",", "None", ")", "return", "option", "(", "debug", ",", "*", "args"...
Show debugging information.
[ "Show", "debugging", "information", "." ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/click.py#L49-L53
train
Show debugging information.
zsimic/runez
src/runez/click.py
dryrun
def dryrun(*args, **attrs): """Perform a dryrun.""" attrs.setdefault("is_flag", True) attrs.setdefault("default", None) return option(dryrun, *args, **attrs)
python
def dryrun(*args, **attrs): """Perform a dryrun.""" attrs.setdefault("is_flag", True) attrs.setdefault("default", None) return option(dryrun, *args, **attrs)
[ "def", "dryrun", "(", "*", "args", ",", "*", "*", "attrs", ")", ":", "attrs", ".", "setdefault", "(", "\"is_flag\"", ",", "True", ")", "attrs", ".", "setdefault", "(", "\"default\"", ",", "None", ")", "return", "option", "(", "dryrun", ",", "*", "arg...
Perform a dryrun.
[ "Perform", "a", "dryrun", "." ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/click.py#L56-L60
train
Perform a dryrun.
zsimic/runez
src/runez/click.py
log
def log(*args, **attrs): """Override log file location.""" attrs.setdefault("metavar", "PATH") attrs.setdefault("show_default", False) return option(log, *args, **attrs)
python
def log(*args, **attrs): """Override log file location.""" attrs.setdefault("metavar", "PATH") attrs.setdefault("show_default", False) return option(log, *args, **attrs)
[ "def", "log", "(", "*", "args", ",", "*", "*", "attrs", ")", ":", "attrs", ".", "setdefault", "(", "\"metavar\"", ",", "\"PATH\"", ")", "attrs", ".", "setdefault", "(", "\"show_default\"", ",", "False", ")", "return", "option", "(", "log", ",", "*", ...
Override log file location.
[ "Override", "log", "file", "location", "." ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/click.py#L63-L67
train
Override log file location.
zsimic/runez
src/runez/click.py
version
def version(*args, **attrs): """Show the version and exit.""" if hasattr(sys, "_getframe"): package = attrs.pop("package", sys._getframe(1).f_globals.get("__package__")) if package: attrs.setdefault("version", get_version(package)) return click.version_option(*args, **attrs)
python
def version(*args, **attrs): """Show the version and exit.""" if hasattr(sys, "_getframe"): package = attrs.pop("package", sys._getframe(1).f_globals.get("__package__")) if package: attrs.setdefault("version", get_version(package)) return click.version_option(*args, **attrs)
[ "def", "version", "(", "*", "args", ",", "*", "*", "attrs", ")", ":", "if", "hasattr", "(", "sys", ",", "\"_getframe\"", ")", ":", "package", "=", "attrs", ".", "pop", "(", "\"package\"", ",", "sys", ".", "_getframe", "(", "1", ")", ".", "f_globals...
Show the version and exit.
[ "Show", "the", "version", "and", "exit", "." ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/click.py#L70-L76
train
Show the version and exit.
zsimic/runez
src/runez/click.py
settings
def settings(epilog=None, help=None, width=140, **attrs): """ Args: epilog (str | unicode | None): Help epilog, defaults to __doc__ of caller module help (list[str | unicode] | str | unicode | None): List of flags to show help, default: -h and --help width (int): Constrain help to ...
python
def settings(epilog=None, help=None, width=140, **attrs): """ Args: epilog (str | unicode | None): Help epilog, defaults to __doc__ of caller module help (list[str | unicode] | str | unicode | None): List of flags to show help, default: -h and --help width (int): Constrain help to ...
[ "def", "settings", "(", "epilog", "=", "None", ",", "help", "=", "None", ",", "width", "=", "140", ",", "*", "*", "attrs", ")", ":", "if", "epilog", "is", "None", ":", "epilog", "=", "_get_caller_doc", "(", ")", "if", "help", "is", "None", ":", "...
Args: epilog (str | unicode | None): Help epilog, defaults to __doc__ of caller module help (list[str | unicode] | str | unicode | None): List of flags to show help, default: -h and --help width (int): Constrain help to **attrs: Returns: dict: Dict passable to @click.command...
[ "Args", ":", "epilog", "(", "str", "|", "unicode", "|", "None", ")", ":", "Help", "epilog", "defaults", "to", "__doc__", "of", "caller", "module", "help", "(", "list", "[", "str", "|", "unicode", "]", "|", "str", "|", "unicode", "|", "None", ")", "...
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/click.py#L79-L104
train
Return a dictionary of context settings for the current module.
zsimic/runez
src/runez/click.py
option
def option(func, *args, **attrs): """ Args: func (function): Function defining this option *args: Optional extra short flag name **attrs: Optional attr overrides provided by caller Returns: function: Click decorator """ if click is None: return func def ...
python
def option(func, *args, **attrs): """ Args: func (function): Function defining this option *args: Optional extra short flag name **attrs: Optional attr overrides provided by caller Returns: function: Click decorator """ if click is None: return func def ...
[ "def", "option", "(", "func", ",", "*", "args", ",", "*", "*", "attrs", ")", ":", "if", "click", "is", "None", ":", "return", "func", "def", "decorator", "(", "f", ")", ":", "name", "=", "attrs", ".", "pop", "(", "\"name\"", ",", "func", ".", "...
Args: func (function): Function defining this option *args: Optional extra short flag name **attrs: Optional attr overrides provided by caller Returns: function: Click decorator
[ "Args", ":", "func", "(", "function", ")", ":", "Function", "defining", "this", "option", "*", "args", ":", "Optional", "extra", "short", "flag", "name", "**", "attrs", ":", "Optional", "attr", "overrides", "provided", "by", "caller" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/click.py#L107-L132
train
Decorator for click. option that adds extra short flag to the name of the current item.
mojaie/chorus
chorus/rdkit.py
to_rdmol
def to_rdmol(mol): """Convert molecule to RDMol""" rwmol = Chem.RWMol(Chem.MolFromSmiles('')) key_to_idx = {} bond_type = {1: Chem.BondType.SINGLE, 2: Chem.BondType.DOUBLE, 3: Chem.BondType.TRIPLE} conf = Chem.Conformer(rwmol.GetNumAtoms()) for k, a in mol.atoms...
python
def to_rdmol(mol): """Convert molecule to RDMol""" rwmol = Chem.RWMol(Chem.MolFromSmiles('')) key_to_idx = {} bond_type = {1: Chem.BondType.SINGLE, 2: Chem.BondType.DOUBLE, 3: Chem.BondType.TRIPLE} conf = Chem.Conformer(rwmol.GetNumAtoms()) for k, a in mol.atoms...
[ "def", "to_rdmol", "(", "mol", ")", ":", "rwmol", "=", "Chem", ".", "RWMol", "(", "Chem", ".", "MolFromSmiles", "(", "''", ")", ")", "key_to_idx", "=", "{", "}", "bond_type", "=", "{", "1", ":", "Chem", ".", "BondType", ".", "SINGLE", ",", "2", "...
Convert molecule to RDMol
[ "Convert", "molecule", "to", "RDMol" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/rdkit.py#L20-L39
train
Convert a molecule to RDMol
mojaie/chorus
chorus/rdkit.py
from_rdmol
def from_rdmol(rdmol, assign_descriptor=True): """Convert RDMol to molecule""" mol = Compound() conf = rdmol.GetConformer() Chem.Kekulize(rdmol) for atom in rdmol.GetAtoms(): key = atom.GetIdx() a = Atom(atom.GetSymbol()) a.coords = conf.GetAtomPosition(key) mol.add_a...
python
def from_rdmol(rdmol, assign_descriptor=True): """Convert RDMol to molecule""" mol = Compound() conf = rdmol.GetConformer() Chem.Kekulize(rdmol) for atom in rdmol.GetAtoms(): key = atom.GetIdx() a = Atom(atom.GetSymbol()) a.coords = conf.GetAtomPosition(key) mol.add_a...
[ "def", "from_rdmol", "(", "rdmol", ",", "assign_descriptor", "=", "True", ")", ":", "mol", "=", "Compound", "(", ")", "conf", "=", "rdmol", ".", "GetConformer", "(", ")", "Chem", ".", "Kekulize", "(", "rdmol", ")", "for", "atom", "in", "rdmol", ".", ...
Convert RDMol to molecule
[ "Convert", "RDMol", "to", "molecule" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/rdkit.py#L42-L60
train
Convert a RDMol to a Molecule object
mojaie/chorus
chorus/rdkit.py
morgan_sim
def morgan_sim(mol1, mol2, radius=2, digit=3): """Calculate morgan fingerprint similarity by using RDKit radius=2 roughly equivalent to ECFP4 """ rdmol1 = to_rdmol(mol1) rdmol2 = to_rdmol(mol2) fp1 = AllChem.GetMorganFingerprint(rdmol1, radius) fp2 = AllChem.GetMorganFingerprint(rdmol2, radi...
python
def morgan_sim(mol1, mol2, radius=2, digit=3): """Calculate morgan fingerprint similarity by using RDKit radius=2 roughly equivalent to ECFP4 """ rdmol1 = to_rdmol(mol1) rdmol2 = to_rdmol(mol2) fp1 = AllChem.GetMorganFingerprint(rdmol1, radius) fp2 = AllChem.GetMorganFingerprint(rdmol2, radi...
[ "def", "morgan_sim", "(", "mol1", ",", "mol2", ",", "radius", "=", "2", ",", "digit", "=", "3", ")", ":", "rdmol1", "=", "to_rdmol", "(", "mol1", ")", "rdmol2", "=", "to_rdmol", "(", "mol2", ")", "fp1", "=", "AllChem", ".", "GetMorganFingerprint", "(...
Calculate morgan fingerprint similarity by using RDKit radius=2 roughly equivalent to ECFP4
[ "Calculate", "morgan", "fingerprint", "similarity", "by", "using", "RDKit", "radius", "=", "2", "roughly", "equivalent", "to", "ECFP4" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/rdkit.py#L63-L71
train
Calculate morgan fingerprint similarity by using RDKit radius = 2 roughly equivalent to ECFP4 digit = 3
maljovec/topopy
topopy/MergeTree.py
MergeTree._internal_build
def _internal_build(self): """ This function assumes the self.__tree object has been setup, though it doesn't care how. It will then setup all python side data structures to be used for querying this object. """ self.nodes = self.__tree.Nodes() self.edges = self._...
python
def _internal_build(self): """ This function assumes the self.__tree object has been setup, though it doesn't care how. It will then setup all python side data structures to be used for querying this object. """ self.nodes = self.__tree.Nodes() self.edges = self._...
[ "def", "_internal_build", "(", "self", ")", ":", "self", ".", "nodes", "=", "self", ".", "__tree", ".", "Nodes", "(", ")", "self", ".", "edges", "=", "self", ".", "__tree", ".", "Edges", "(", ")", "self", ".", "augmentedEdges", "=", "{", "}", "for"...
This function assumes the self.__tree object has been setup, though it doesn't care how. It will then setup all python side data structures to be used for querying this object.
[ "This", "function", "assumes", "the", "self", ".", "__tree", "object", "has", "been", "setup", "though", "it", "doesn", "t", "care", "how", ".", "It", "will", "then", "setup", "all", "python", "side", "data", "structures", "to", "be", "used", "for", "que...
4be598d51c4e4043b73d4ad44beed6d289e2f088
https://github.com/maljovec/topopy/blob/4be598d51c4e4043b73d4ad44beed6d289e2f088/topopy/MergeTree.py#L71-L101
train
This function builds the internal structure of the object.
maljovec/topopy
topopy/MergeTree.py
MergeTree.build
def build(self, X, Y, w=None, edges=None): """ Assigns data to this object and builds the Merge Tree @ In, X, an m-by-n array of values specifying m n-dimensional samples @ In, Y, a m vector of values specifying the output responses corresponding to the m samples ...
python
def build(self, X, Y, w=None, edges=None): """ Assigns data to this object and builds the Merge Tree @ In, X, an m-by-n array of values specifying m n-dimensional samples @ In, Y, a m vector of values specifying the output responses corresponding to the m samples ...
[ "def", "build", "(", "self", ",", "X", ",", "Y", ",", "w", "=", "None", ",", "edges", "=", "None", ")", ":", "super", "(", "MergeTree", ",", "self", ")", ".", "build", "(", "X", ",", "Y", ",", "w", ",", "edges", ")", "if", "self", ".", "deb...
Assigns data to this object and builds the Merge Tree @ In, X, an m-by-n array of values specifying m n-dimensional samples @ In, Y, a m vector of values specifying the output responses corresponding to the m samples specified by X @ In, w, an optional m vecto...
[ "Assigns", "data", "to", "this", "object", "and", "builds", "the", "Merge", "Tree" ]
4be598d51c4e4043b73d4ad44beed6d289e2f088
https://github.com/maljovec/topopy/blob/4be598d51c4e4043b73d4ad44beed6d289e2f088/topopy/MergeTree.py#L103-L133
train
Assigns data to this object and builds the Merge Tree object.
maljovec/topopy
topopy/MergeTree.py
MergeTree.build_for_contour_tree
def build_for_contour_tree(self, contour_tree, negate=False): """ A helper function that will reduce duplication of data by reusing the parent contour tree's parameters and data """ if self.debug: tree_type = "Join" if negate: tree_type = "Spli...
python
def build_for_contour_tree(self, contour_tree, negate=False): """ A helper function that will reduce duplication of data by reusing the parent contour tree's parameters and data """ if self.debug: tree_type = "Join" if negate: tree_type = "Spli...
[ "def", "build_for_contour_tree", "(", "self", ",", "contour_tree", ",", "negate", "=", "False", ")", ":", "if", "self", ".", "debug", ":", "tree_type", "=", "\"Join\"", "if", "negate", ":", "tree_type", "=", "\"Split\"", "sys", ".", "stdout", ".", "write",...
A helper function that will reduce duplication of data by reusing the parent contour tree's parameters and data
[ "A", "helper", "function", "that", "will", "reduce", "duplication", "of", "data", "by", "reusing", "the", "parent", "contour", "tree", "s", "parameters", "and", "data" ]
4be598d51c4e4043b73d4ad44beed6d289e2f088
https://github.com/maljovec/topopy/blob/4be598d51c4e4043b73d4ad44beed6d289e2f088/topopy/MergeTree.py#L135-L160
train
This method will build the contour tree for the given contour tree.
mojaie/chorus
chorus/util/geometry.py
scale
def scale(p, factor, o=(0, 0)): """ scale vector Args: p: point (x, y) factor: scaling factor o: origin (x, y) """ v = vector(o, p) sv = v[0] * factor, v[1] * factor return translate(sv, o)
python
def scale(p, factor, o=(0, 0)): """ scale vector Args: p: point (x, y) factor: scaling factor o: origin (x, y) """ v = vector(o, p) sv = v[0] * factor, v[1] * factor return translate(sv, o)
[ "def", "scale", "(", "p", ",", "factor", ",", "o", "=", "(", "0", ",", "0", ")", ")", ":", "v", "=", "vector", "(", "o", ",", "p", ")", "sv", "=", "v", "[", "0", "]", "*", "factor", ",", "v", "[", "1", "]", "*", "factor", "return", "tra...
scale vector Args: p: point (x, y) factor: scaling factor o: origin (x, y)
[ "scale", "vector", "Args", ":", "p", ":", "point", "(", "x", "y", ")", "factor", ":", "scaling", "factor", "o", ":", "origin", "(", "x", "y", ")" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/util/geometry.py#L35-L44
train
Scale vector by a factor
mojaie/chorus
chorus/util/geometry.py
unit
def unit(v, lg=1): """ unit vector Args: v: vector (x, y) lg: length Raises: ValueError: Null vector was given """ try: res = scale(v, lg / distance((0, 0), v)) except ZeroDivisionError: raise ValueError("Null vector was given") return res
python
def unit(v, lg=1): """ unit vector Args: v: vector (x, y) lg: length Raises: ValueError: Null vector was given """ try: res = scale(v, lg / distance((0, 0), v)) except ZeroDivisionError: raise ValueError("Null vector was given") return res
[ "def", "unit", "(", "v", ",", "lg", "=", "1", ")", ":", "try", ":", "res", "=", "scale", "(", "v", ",", "lg", "/", "distance", "(", "(", "0", ",", "0", ")", ",", "v", ")", ")", "except", "ZeroDivisionError", ":", "raise", "ValueError", "(", "...
unit vector Args: v: vector (x, y) lg: length Raises: ValueError: Null vector was given
[ "unit", "vector", "Args", ":", "v", ":", "vector", "(", "x", "y", ")", "lg", ":", "length", "Raises", ":", "ValueError", ":", "Null", "vector", "was", "given" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/util/geometry.py#L47-L59
train
unit vector returns a new vector
mojaie/chorus
chorus/util/geometry.py
rotate
def rotate(p, rad, o=(0, 0)): """ rotate vector Args: p: point (x, y) rad: angle(radian) o: origin (x, y) """ v = vector(o, p) fx = lambda x, y, d: x * cos(d) - y * sin(d) fy = lambda x, y, d: x * sin(d) + y * cos(d) rv = fx(v[0], v[1], rad), fy(v[0], v[1], rad) return ...
python
def rotate(p, rad, o=(0, 0)): """ rotate vector Args: p: point (x, y) rad: angle(radian) o: origin (x, y) """ v = vector(o, p) fx = lambda x, y, d: x * cos(d) - y * sin(d) fy = lambda x, y, d: x * sin(d) + y * cos(d) rv = fx(v[0], v[1], rad), fy(v[0], v[1], rad) return ...
[ "def", "rotate", "(", "p", ",", "rad", ",", "o", "=", "(", "0", ",", "0", ")", ")", ":", "v", "=", "vector", "(", "o", ",", "p", ")", "fx", "=", "lambda", "x", ",", "y", ",", "d", ":", "x", "*", "cos", "(", "d", ")", "-", "y", "*", ...
rotate vector Args: p: point (x, y) rad: angle(radian) o: origin (x, y)
[ "rotate", "vector", "Args", ":", "p", ":", "point", "(", "x", "y", ")", "rad", ":", "angle", "(", "radian", ")", "o", ":", "origin", "(", "x", "y", ")" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/util/geometry.py#L62-L73
train
rotate vector
mojaie/chorus
chorus/util/geometry.py
cross_product
def cross_product(p1, p2, o=(0, 0)): """ Returns cross product Args: p1, p2: point (x, y) o: origin """ v1 = vector(o, p1) v2 = vector(o, p2) return v1[0] * v2[1] - v1[1] * v2[0]
python
def cross_product(p1, p2, o=(0, 0)): """ Returns cross product Args: p1, p2: point (x, y) o: origin """ v1 = vector(o, p1) v2 = vector(o, p2) return v1[0] * v2[1] - v1[1] * v2[0]
[ "def", "cross_product", "(", "p1", ",", "p2", ",", "o", "=", "(", "0", ",", "0", ")", ")", ":", "v1", "=", "vector", "(", "o", ",", "p1", ")", "v2", "=", "vector", "(", "o", ",", "p2", ")", "return", "v1", "[", "0", "]", "*", "v2", "[", ...
Returns cross product Args: p1, p2: point (x, y) o: origin
[ "Returns", "cross", "product", "Args", ":", "p1", "p2", ":", "point", "(", "x", "y", ")", "o", ":", "origin" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/util/geometry.py#L76-L84
train
Returns the cross product of two points.
mojaie/chorus
chorus/util/geometry.py
dot_product
def dot_product(p1, p2, o=(0, 0)): """ Returns dot product Args: p1, p2: point (x, y) o: origin """ v1 = vector(o, p1) v2 = vector(o, p2) return v1[0] * v2[0] + v1[1] * v2[1]
python
def dot_product(p1, p2, o=(0, 0)): """ Returns dot product Args: p1, p2: point (x, y) o: origin """ v1 = vector(o, p1) v2 = vector(o, p2) return v1[0] * v2[0] + v1[1] * v2[1]
[ "def", "dot_product", "(", "p1", ",", "p2", ",", "o", "=", "(", "0", ",", "0", ")", ")", ":", "v1", "=", "vector", "(", "o", ",", "p1", ")", "v2", "=", "vector", "(", "o", ",", "p2", ")", "return", "v1", "[", "0", "]", "*", "v2", "[", "...
Returns dot product Args: p1, p2: point (x, y) o: origin
[ "Returns", "dot", "product", "Args", ":", "p1", "p2", ":", "point", "(", "x", "y", ")", "o", ":", "origin" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/util/geometry.py#L87-L95
train
Returns the dot product of two points.
mojaie/chorus
chorus/util/geometry.py
interior_angle
def interior_angle(p1, p2, o=(0, 0)): """ Returns interior angle of two vector(0 <= θ <= pi) Args: p1, p2: point (x, y) o: origin Raises: ValueError: p1 or p2 is overlapped with origin """ v1 = vector(o, p1) v2 = vector(o, p2) len1 = distance(o, p1) len2 = distance(o, p...
python
def interior_angle(p1, p2, o=(0, 0)): """ Returns interior angle of two vector(0 <= θ <= pi) Args: p1, p2: point (x, y) o: origin Raises: ValueError: p1 or p2 is overlapped with origin """ v1 = vector(o, p1) v2 = vector(o, p2) len1 = distance(o, p1) len2 = distance(o, p...
[ "def", "interior_angle", "(", "p1", ",", "p2", ",", "o", "=", "(", "0", ",", "0", ")", ")", ":", "v1", "=", "vector", "(", "o", ",", "p1", ")", "v2", "=", "vector", "(", "o", ",", "p2", ")", "len1", "=", "distance", "(", "o", ",", "p1", "...
Returns interior angle of two vector(0 <= θ <= pi) Args: p1, p2: point (x, y) o: origin Raises: ValueError: p1 or p2 is overlapped with origin
[ "Returns", "interior", "angle", "of", "two", "vector", "(", "0", "<", "=", "θ", "<", "=", "pi", ")", "Args", ":", "p1", "p2", ":", "point", "(", "x", "y", ")", "o", ":", "origin", "Raises", ":", "ValueError", ":", "p1", "or", "p2", "is", "overl...
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/util/geometry.py#L98-L113
train
Returns the interior angle of two points.
mojaie/chorus
chorus/util/geometry.py
m_seg
def m_seg(p1, p2, rad, dist): """ move segment by distance Args: p1, p2: point(x, y) rad: relative direction angle(radian) dist: distance Return: translated segment(p1, p2) """ v = vector(p1, p2) m = unit(rotate(v, rad), dist) return translate(p1, m), translate(p2, m)
python
def m_seg(p1, p2, rad, dist): """ move segment by distance Args: p1, p2: point(x, y) rad: relative direction angle(radian) dist: distance Return: translated segment(p1, p2) """ v = vector(p1, p2) m = unit(rotate(v, rad), dist) return translate(p1, m), translate(p2, m)
[ "def", "m_seg", "(", "p1", ",", "p2", ",", "rad", ",", "dist", ")", ":", "v", "=", "vector", "(", "p1", ",", "p2", ")", "m", "=", "unit", "(", "rotate", "(", "v", ",", "rad", ")", ",", "dist", ")", "return", "translate", "(", "p1", ",", "m"...
move segment by distance Args: p1, p2: point(x, y) rad: relative direction angle(radian) dist: distance Return: translated segment(p1, p2)
[ "move", "segment", "by", "distance", "Args", ":", "p1", "p2", ":", "point", "(", "x", "y", ")", "rad", ":", "relative", "direction", "angle", "(", "radian", ")", "dist", ":", "distance", "Return", ":", "translated", "segment", "(", "p1", "p2", ")" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/util/geometry.py#L116-L127
train
Move segment by distance
mojaie/chorus
chorus/util/geometry.py
t_seg
def t_seg(p1, p2, t, align=0): """ trim segment Args: p1, p2: point(x, y) t: scaling factor (1 - trimed segment / original segment) align: 1: trim p2, 2: trim p1, 0: both side Return: trimmed segment(p1, p2) """ v = vector(p1, p2) result = { 1: lambda a, b: (a, tr...
python
def t_seg(p1, p2, t, align=0): """ trim segment Args: p1, p2: point(x, y) t: scaling factor (1 - trimed segment / original segment) align: 1: trim p2, 2: trim p1, 0: both side Return: trimmed segment(p1, p2) """ v = vector(p1, p2) result = { 1: lambda a, b: (a, tr...
[ "def", "t_seg", "(", "p1", ",", "p2", ",", "t", ",", "align", "=", "0", ")", ":", "v", "=", "vector", "(", "p1", ",", "p2", ")", "result", "=", "{", "1", ":", "lambda", "a", ",", "b", ":", "(", "a", ",", "translate", "(", "b", ",", "scale...
trim segment Args: p1, p2: point(x, y) t: scaling factor (1 - trimed segment / original segment) align: 1: trim p2, 2: trim p1, 0: both side Return: trimmed segment(p1, p2)
[ "trim", "segment", "Args", ":", "p1", "p2", ":", "point", "(", "x", "y", ")", "t", ":", "scaling", "factor", "(", "1", "-", "trimed", "segment", "/", "original", "segment", ")", "align", ":", "1", ":", "trim", "p2", "2", ":", "trim", "p1", "0", ...
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/util/geometry.py#L130-L146
train
t_seg takes two points p1 and p2 and returns the segment with the given scaling factor t
mojaie/chorus
chorus/util/geometry.py
p_seg
def p_seg(p1, p2, cw, interval, trim=0, align=0): """ parallel segment Args: p1, p2: point(x, y) cw: m_seg rad True: -π/2, False: π/2 interval: m_seg dist trim: t_seg trim align: t_seg align """ case = {True: pi / -2, False: pi / 2} p1m, p2m = m_seg(p1, p2, case[cw], in...
python
def p_seg(p1, p2, cw, interval, trim=0, align=0): """ parallel segment Args: p1, p2: point(x, y) cw: m_seg rad True: -π/2, False: π/2 interval: m_seg dist trim: t_seg trim align: t_seg align """ case = {True: pi / -2, False: pi / 2} p1m, p2m = m_seg(p1, p2, case[cw], in...
[ "def", "p_seg", "(", "p1", ",", "p2", ",", "cw", ",", "interval", ",", "trim", "=", "0", ",", "align", "=", "0", ")", ":", "case", "=", "{", "True", ":", "pi", "/", "-", "2", ",", "False", ":", "pi", "/", "2", "}", "p1m", ",", "p2m", "=",...
parallel segment Args: p1, p2: point(x, y) cw: m_seg rad True: -π/2, False: π/2 interval: m_seg dist trim: t_seg trim align: t_seg align
[ "parallel", "segment", "Args", ":", "p1", "p2", ":", "point", "(", "x", "y", ")", "cw", ":", "m_seg", "rad", "True", ":", "-", "π", "/", "2", "False", ":", "π", "/", "2", "interval", ":", "m_seg", "dist", "trim", ":", "t_seg", "trim", "align", ...
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/util/geometry.py#L149-L160
train
parallel segmentation function
mojaie/chorus
chorus/util/geometry.py
is_clockwise
def is_clockwise(vertices): """ Evaluate whether vertices are in clockwise order. Args: vertices: list of vertices (x, y) in polygon. Returns: True: clockwise, False: counter-clockwise Raises: ValueError: the polygon is complex or overlapped. """ it = iterator.consecutive(cycle...
python
def is_clockwise(vertices): """ Evaluate whether vertices are in clockwise order. Args: vertices: list of vertices (x, y) in polygon. Returns: True: clockwise, False: counter-clockwise Raises: ValueError: the polygon is complex or overlapped. """ it = iterator.consecutive(cycle...
[ "def", "is_clockwise", "(", "vertices", ")", ":", "it", "=", "iterator", ".", "consecutive", "(", "cycle", "(", "vertices", ")", ",", "3", ")", "clockwise", "=", "0", "counter", "=", "0", "for", "_", "in", "range", "(", "len", "(", "vertices", ")", ...
Evaluate whether vertices are in clockwise order. Args: vertices: list of vertices (x, y) in polygon. Returns: True: clockwise, False: counter-clockwise Raises: ValueError: the polygon is complex or overlapped.
[ "Evaluate", "whether", "vertices", "are", "in", "clockwise", "order", ".", "Args", ":", "vertices", ":", "list", "of", "vertices", "(", "x", "y", ")", "in", "polygon", ".", "Returns", ":", "True", ":", "clockwise", "False", ":", "counter", "-", "clockwis...
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/util/geometry.py#L163-L190
train
Evaluate whether the given list of vertices are in clockwise order.
zsimic/runez
src/runez/context.py
verify_abort
def verify_abort(func, *args, **kwargs): """ Convenient wrapper around functions that should exit or raise an exception Example: assert "Can't create folder" in verify_abort(ensure_folder, "/dev/null/not-there") Args: func (callable): Function to execute *args: Args to pass to ...
python
def verify_abort(func, *args, **kwargs): """ Convenient wrapper around functions that should exit or raise an exception Example: assert "Can't create folder" in verify_abort(ensure_folder, "/dev/null/not-there") Args: func (callable): Function to execute *args: Args to pass to ...
[ "def", "verify_abort", "(", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "expected_exception", "=", "kwargs", ".", "pop", "(", "\"expected_exception\"", ",", "runez", ".", "system", ".", "AbortException", ")", "with", "CaptureOutput", "(", ...
Convenient wrapper around functions that should exit or raise an exception Example: assert "Can't create folder" in verify_abort(ensure_folder, "/dev/null/not-there") Args: func (callable): Function to execute *args: Args to pass to 'func' **kwargs: Named args to pass to 'func'...
[ "Convenient", "wrapper", "around", "functions", "that", "should", "exit", "or", "raise", "an", "exception" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/context.py#L248-L270
train
Decorator to execute a function that should exit or raise an exception
zsimic/runez
src/runez/context.py
CapturedStream.pop
def pop(self, strip=False): """Current content popped, useful for testing""" r = self.contents() self.clear() if r and strip: r = r.strip() return r
python
def pop(self, strip=False): """Current content popped, useful for testing""" r = self.contents() self.clear() if r and strip: r = r.strip() return r
[ "def", "pop", "(", "self", ",", "strip", "=", "False", ")", ":", "r", "=", "self", ".", "contents", "(", ")", "self", ".", "clear", "(", ")", "if", "r", "and", "strip", ":", "r", "=", "r", ".", "strip", "(", ")", "return", "r" ]
Current content popped, useful for testing
[ "Current", "content", "popped", "useful", "for", "testing" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/context.py#L72-L78
train
Pop the current content from the list.
mojaie/chorus
chorus/draw/svg.py
SVG.contents
def contents(self): """Get svg string """ c = self._header[:] c.append(' font-weight="{}"'.format(self.font_weight)) c.append(' font-family="{}"'.format(self.font_family)) c.append(' width="{}" height="{}"'.format(*self.screen_size)) sclw = self.original_size[0] *...
python
def contents(self): """Get svg string """ c = self._header[:] c.append(' font-weight="{}"'.format(self.font_weight)) c.append(' font-family="{}"'.format(self.font_family)) c.append(' width="{}" height="{}"'.format(*self.screen_size)) sclw = self.original_size[0] *...
[ "def", "contents", "(", "self", ")", ":", "c", "=", "self", ".", "_header", "[", ":", "]", "c", ".", "append", "(", "' font-weight=\"{}\"'", ".", "format", "(", "self", ".", "font_weight", ")", ")", "c", ".", "append", "(", "' font-family=\"{}\"'", "."...
Get svg string
[ "Get", "svg", "string" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/draw/svg.py#L49-L70
train
Get the contents of the image.
mojaie/chorus
chorus/draw/svg.py
SVG.data_url_scheme
def data_url_scheme(self): """Get svg in Data URL Scheme format. """ # TODO: move to web.app or make it function # remove #svg from dataframe encoded = base64.b64encode(self.contents().encode()) return "data:image/svg+xml;base64," + encoded.decode()
python
def data_url_scheme(self): """Get svg in Data URL Scheme format. """ # TODO: move to web.app or make it function # remove #svg from dataframe encoded = base64.b64encode(self.contents().encode()) return "data:image/svg+xml;base64," + encoded.decode()
[ "def", "data_url_scheme", "(", "self", ")", ":", "# TODO: move to web.app or make it function", "# remove #svg from dataframe", "encoded", "=", "base64", ".", "b64encode", "(", "self", ".", "contents", "(", ")", ".", "encode", "(", ")", ")", "return", "\"data:image/...
Get svg in Data URL Scheme format.
[ "Get", "svg", "in", "Data", "URL", "Scheme", "format", "." ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/draw/svg.py#L72-L78
train
Get svg in Data URL Scheme format.
mojaie/chorus
chorus/draw/svg.py
SVG.save
def save(self, path): """Save svg as file(.svg) Args: path (str): destination to save file """ with open(path, 'w') as f: f.write(self.contents())
python
def save(self, path): """Save svg as file(.svg) Args: path (str): destination to save file """ with open(path, 'w') as f: f.write(self.contents())
[ "def", "save", "(", "self", ",", "path", ")", ":", "with", "open", "(", "path", ",", "'w'", ")", "as", "f", ":", "f", ".", "write", "(", "self", ".", "contents", "(", ")", ")" ]
Save svg as file(.svg) Args: path (str): destination to save file
[ "Save", "svg", "as", "file", "(", ".", "svg", ")" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/draw/svg.py#L80-L87
train
Save the current object as file.
mojaie/chorus
chorus/draw/svg.py
SVG._coords_conv
def _coords_conv(self, pos): """For Svg coordinate system, reflect over X axis and translate from center to top-left """ px = (self.original_size[0] / 2 + pos[0]) * self.scale_factor py = (self.original_size[1] / 2 - pos[1]) * self.scale_factor return round(px, 2), round(...
python
def _coords_conv(self, pos): """For Svg coordinate system, reflect over X axis and translate from center to top-left """ px = (self.original_size[0] / 2 + pos[0]) * self.scale_factor py = (self.original_size[1] / 2 - pos[1]) * self.scale_factor return round(px, 2), round(...
[ "def", "_coords_conv", "(", "self", ",", "pos", ")", ":", "px", "=", "(", "self", ".", "original_size", "[", "0", "]", "/", "2", "+", "pos", "[", "0", "]", ")", "*", "self", ".", "scale_factor", "py", "=", "(", "self", ".", "original_size", "[", ...
For Svg coordinate system, reflect over X axis and translate from center to top-left
[ "For", "Svg", "coordinate", "system", "reflect", "over", "X", "axis", "and", "translate", "from", "center", "to", "top", "-", "left" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/draw/svg.py#L89-L95
train
Convert from pixel coordinates to pixel coordinates
mastro35/flows
flows/FlowsLogger.py
FlowsLogger.default_instance
def default_instance(cls): """ For use like a singleton, return the existing instance of the object or a new instance """ if cls._instance is None: with cls._instance_lock: if cls._instance is None: cls._instance = FlowsLogger() ...
python
def default_instance(cls): """ For use like a singleton, return the existing instance of the object or a new instance """ if cls._instance is None: with cls._instance_lock: if cls._instance is None: cls._instance = FlowsLogger() ...
[ "def", "default_instance", "(", "cls", ")", ":", "if", "cls", ".", "_instance", "is", "None", ":", "with", "cls", ".", "_instance_lock", ":", "if", "cls", ".", "_instance", "is", "None", ":", "cls", ".", "_instance", "=", "FlowsLogger", "(", ")", "retu...
For use like a singleton, return the existing instance of the object or a new instance
[ "For", "use", "like", "a", "singleton", "return", "the", "existing", "instance", "of", "the", "object", "or", "a", "new", "instance" ]
05e488385673a69597b5b39c7728795aa4d5eb18
https://github.com/mastro35/flows/blob/05e488385673a69597b5b39c7728795aa4d5eb18/flows/FlowsLogger.py#L27-L37
train
Returns the default instance of FlowsLogger.
mastro35/flows
flows/FlowsLogger.py
FlowsLogger.get_logger
def get_logger(self): """ Returns the standard logger """ if Global.LOGGER: Global.LOGGER.debug('configuring a logger') if self._logger_instance is not None: return self._logger_instance self._logger_instance = logging.getLogger("flowsLogger") ...
python
def get_logger(self): """ Returns the standard logger """ if Global.LOGGER: Global.LOGGER.debug('configuring a logger') if self._logger_instance is not None: return self._logger_instance self._logger_instance = logging.getLogger("flowsLogger") ...
[ "def", "get_logger", "(", "self", ")", ":", "if", "Global", ".", "LOGGER", ":", "Global", ".", "LOGGER", ".", "debug", "(", "'configuring a logger'", ")", "if", "self", ".", "_logger_instance", "is", "not", "None", ":", "return", "self", ".", "_logger_inst...
Returns the standard logger
[ "Returns", "the", "standard", "logger" ]
05e488385673a69597b5b39c7728795aa4d5eb18
https://github.com/mastro35/flows/blob/05e488385673a69597b5b39c7728795aa4d5eb18/flows/FlowsLogger.py#L39-L61
train
Returns the standard logger instance
mastro35/flows
flows/FlowsLogger.py
FlowsLogger.reconfigure_log_level
def reconfigure_log_level(self): """ Returns a new standard logger instance """ if Global.LOGGER: Global.LOGGER.debug('reconfiguring logger level') stream_handlers = filter(lambda x: type(x) is logging.StreamHandler, self._logger_insta...
python
def reconfigure_log_level(self): """ Returns a new standard logger instance """ if Global.LOGGER: Global.LOGGER.debug('reconfiguring logger level') stream_handlers = filter(lambda x: type(x) is logging.StreamHandler, self._logger_insta...
[ "def", "reconfigure_log_level", "(", "self", ")", ":", "if", "Global", ".", "LOGGER", ":", "Global", ".", "LOGGER", ".", "debug", "(", "'reconfiguring logger level'", ")", "stream_handlers", "=", "filter", "(", "lambda", "x", ":", "type", "(", "x", ")", "i...
Returns a new standard logger instance
[ "Returns", "a", "new", "standard", "logger", "instance" ]
05e488385673a69597b5b39c7728795aa4d5eb18
https://github.com/mastro35/flows/blob/05e488385673a69597b5b39c7728795aa4d5eb18/flows/FlowsLogger.py#L63-L75
train
Reconfigure the log level of all handlers.
lsst-sqre/documenteer
documenteer/sphinxext/packagetoctree.py
_filter_index_pages
def _filter_index_pages(docnames, base_dir): """Filter docnames to only yield paths of the form ``<base_dir>/<name>/index`` Parameters ---------- docnames : `list` of `str` List of document names (``env.found_docs``). base_dir : `str` Base directory of all sub-directories contai...
python
def _filter_index_pages(docnames, base_dir): """Filter docnames to only yield paths of the form ``<base_dir>/<name>/index`` Parameters ---------- docnames : `list` of `str` List of document names (``env.found_docs``). base_dir : `str` Base directory of all sub-directories contai...
[ "def", "_filter_index_pages", "(", "docnames", ",", "base_dir", ")", ":", "for", "docname", "in", "docnames", ":", "parts", "=", "docname", ".", "split", "(", "'/'", ")", "if", "len", "(", "parts", ")", "==", "3", "and", "parts", "[", "0", "]", "==",...
Filter docnames to only yield paths of the form ``<base_dir>/<name>/index`` Parameters ---------- docnames : `list` of `str` List of document names (``env.found_docs``). base_dir : `str` Base directory of all sub-directories containing index pages. Yields ------ docname...
[ "Filter", "docnames", "to", "only", "yield", "paths", "of", "the", "form", "<base_dir", ">", "/", "<name", ">", "/", "index" ]
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxext/packagetoctree.py#L206-L225
train
Filter docnames to only yield index pages.
lsst-sqre/documenteer
documenteer/sphinxext/packagetoctree.py
_build_toctree_node
def _build_toctree_node(parent=None, entries=None, includefiles=None, caption=None): """Factory for a toctree node. """ # Add the toctree's node itself subnode = sphinx.addnodes.toctree() subnode['parent'] = parent subnode['entries'] = entries subnode['includefiles'] ...
python
def _build_toctree_node(parent=None, entries=None, includefiles=None, caption=None): """Factory for a toctree node. """ # Add the toctree's node itself subnode = sphinx.addnodes.toctree() subnode['parent'] = parent subnode['entries'] = entries subnode['includefiles'] ...
[ "def", "_build_toctree_node", "(", "parent", "=", "None", ",", "entries", "=", "None", ",", "includefiles", "=", "None", ",", "caption", "=", "None", ")", ":", "# Add the toctree's node itself", "subnode", "=", "sphinx", ".", "addnodes", ".", "toctree", "(", ...
Factory for a toctree node.
[ "Factory", "for", "a", "toctree", "node", "." ]
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxext/packagetoctree.py#L228-L247
train
Build a toctree node.
lsst-sqre/documenteer
documenteer/sphinxext/packagetoctree.py
ModuleTocTree.run
def run(self): """Main entrypoint method. Returns ------- new_nodes : `list` Nodes to add to the doctree. """ if getLogger is not None: # Sphinx 1.6+ logger = getLogger(__name__) else: # Previously Sphinx's app was ...
python
def run(self): """Main entrypoint method. Returns ------- new_nodes : `list` Nodes to add to the doctree. """ if getLogger is not None: # Sphinx 1.6+ logger = getLogger(__name__) else: # Previously Sphinx's app was ...
[ "def", "run", "(", "self", ")", ":", "if", "getLogger", "is", "not", "None", ":", "# Sphinx 1.6+", "logger", "=", "getLogger", "(", "__name__", ")", "else", ":", "# Previously Sphinx's app was also the logger", "logger", "=", "self", ".", "state", ".", "docume...
Main entrypoint method. Returns ------- new_nodes : `list` Nodes to add to the doctree.
[ "Main", "entrypoint", "method", "." ]
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxext/packagetoctree.py#L42-L92
train
Main entry point method.
lsst-sqre/documenteer
documenteer/sphinxext/packagetoctree.py
ModuleTocTree._parse_skip_option
def _parse_skip_option(self): """Parse the ``skip`` option of skipped module names. """ try: skip_text = self.options['skip'] except KeyError: return [] modules = [module.strip() for module in skip_text.split(',')] return modules
python
def _parse_skip_option(self): """Parse the ``skip`` option of skipped module names. """ try: skip_text = self.options['skip'] except KeyError: return [] modules = [module.strip() for module in skip_text.split(',')] return modules
[ "def", "_parse_skip_option", "(", "self", ")", ":", "try", ":", "skip_text", "=", "self", ".", "options", "[", "'skip'", "]", "except", "KeyError", ":", "return", "[", "]", "modules", "=", "[", "module", ".", "strip", "(", ")", "for", "module", "in", ...
Parse the ``skip`` option of skipped module names.
[ "Parse", "the", "skip", "option", "of", "skipped", "module", "names", "." ]
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxext/packagetoctree.py#L94-L103
train
Parse the skip option of skipped module names.
lsst-sqre/documenteer
documenteer/sphinxext/packagetoctree.py
PackageTocTree._parse_skip_option
def _parse_skip_option(self): """Parse the ``skip`` option of skipped package names. """ try: skip_text = self.options['skip'] except KeyError: return [] packages = [package.strip() for package in skip_text.split(',')] return packages
python
def _parse_skip_option(self): """Parse the ``skip`` option of skipped package names. """ try: skip_text = self.options['skip'] except KeyError: return [] packages = [package.strip() for package in skip_text.split(',')] return packages
[ "def", "_parse_skip_option", "(", "self", ")", ":", "try", ":", "skip_text", "=", "self", ".", "options", "[", "'skip'", "]", "except", "KeyError", ":", "return", "[", "]", "packages", "=", "[", "package", ".", "strip", "(", ")", "for", "package", "in"...
Parse the ``skip`` option of skipped package names.
[ "Parse", "the", "skip", "option", "of", "skipped", "package", "names", "." ]
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxext/packagetoctree.py#L188-L197
train
Parse the skip option of skipped package names.
mastro35/flows
flows/FlowsManager.py
FlowsManager._set_command_line_arguments
def _set_command_line_arguments(self, args): """ Set internal configuration variables according to the input parameters """ Global.LOGGER.debug("setting command line arguments") if args.VERBOSE: Global.LOGGER.debug("verbose mode active") Global.C...
python
def _set_command_line_arguments(self, args): """ Set internal configuration variables according to the input parameters """ Global.LOGGER.debug("setting command line arguments") if args.VERBOSE: Global.LOGGER.debug("verbose mode active") Global.C...
[ "def", "_set_command_line_arguments", "(", "self", ",", "args", ")", ":", "Global", ".", "LOGGER", ".", "debug", "(", "\"setting command line arguments\"", ")", "if", "args", ".", "VERBOSE", ":", "Global", ".", "LOGGER", ".", "debug", "(", "\"verbose mode active...
Set internal configuration variables according to the input parameters
[ "Set", "internal", "configuration", "variables", "according", "to", "the", "input", "parameters" ]
05e488385673a69597b5b39c7728795aa4d5eb18
https://github.com/mastro35/flows/blob/05e488385673a69597b5b39c7728795aa4d5eb18/flows/FlowsManager.py#L66-L99
train
Set internal configuration variables according to the input parameters
mastro35/flows
flows/FlowsManager.py
FlowsManager.start
def start(self): """ Start all the processes """ Global.LOGGER.info("starting the flow manager") self._start_actions() self._start_message_fetcher() Global.LOGGER.debug("flow manager started")
python
def start(self): """ Start all the processes """ Global.LOGGER.info("starting the flow manager") self._start_actions() self._start_message_fetcher() Global.LOGGER.debug("flow manager started")
[ "def", "start", "(", "self", ")", ":", "Global", ".", "LOGGER", ".", "info", "(", "\"starting the flow manager\"", ")", "self", ".", "_start_actions", "(", ")", "self", ".", "_start_message_fetcher", "(", ")", "Global", ".", "LOGGER", ".", "debug", "(", "\...
Start all the processes
[ "Start", "all", "the", "processes" ]
05e488385673a69597b5b39c7728795aa4d5eb18
https://github.com/mastro35/flows/blob/05e488385673a69597b5b39c7728795aa4d5eb18/flows/FlowsManager.py#L102-L109
train
Start all the processes and message fetcher
mastro35/flows
flows/FlowsManager.py
FlowsManager.stop
def stop(self): """ Stop all the processes """ Global.LOGGER.info("stopping the flow manager") self._stop_actions() self.isrunning = False Global.LOGGER.debug("flow manager stopped")
python
def stop(self): """ Stop all the processes """ Global.LOGGER.info("stopping the flow manager") self._stop_actions() self.isrunning = False Global.LOGGER.debug("flow manager stopped")
[ "def", "stop", "(", "self", ")", ":", "Global", ".", "LOGGER", ".", "info", "(", "\"stopping the flow manager\"", ")", "self", ".", "_stop_actions", "(", ")", "self", ".", "isrunning", "=", "False", "Global", ".", "LOGGER", ".", "debug", "(", "\"flow manag...
Stop all the processes
[ "Stop", "all", "the", "processes" ]
05e488385673a69597b5b39c7728795aa4d5eb18
https://github.com/mastro35/flows/blob/05e488385673a69597b5b39c7728795aa4d5eb18/flows/FlowsManager.py#L111-L118
train
Stop all the processes and stop the flow manager.
mastro35/flows
flows/FlowsManager.py
FlowsManager.restart
def restart(self): """ Restart all the processes """ Global.LOGGER.info("restarting the flow manager") self._stop_actions() # stop the old actions self.actions = [] # clear the action list self._start_actions() # start the configured actions Glo...
python
def restart(self): """ Restart all the processes """ Global.LOGGER.info("restarting the flow manager") self._stop_actions() # stop the old actions self.actions = [] # clear the action list self._start_actions() # start the configured actions Glo...
[ "def", "restart", "(", "self", ")", ":", "Global", ".", "LOGGER", ".", "info", "(", "\"restarting the flow manager\"", ")", "self", ".", "_stop_actions", "(", ")", "# stop the old actions", "self", ".", "actions", "=", "[", "]", "# clear the action list", "self"...
Restart all the processes
[ "Restart", "all", "the", "processes" ]
05e488385673a69597b5b39c7728795aa4d5eb18
https://github.com/mastro35/flows/blob/05e488385673a69597b5b39c7728795aa4d5eb18/flows/FlowsManager.py#L120-L128
train
Restart all the processes and actions.
mastro35/flows
flows/FlowsManager.py
FlowsManager._start_actions
def _start_actions(self): """ Start all the actions for the recipes """ Global.LOGGER.info("starting actions") for recipe in Global.CONFIG_MANAGER.recipes: Global.CONFIG_MANAGER.read_recipe(recipe) list(map(lambda section: self._start_action_for_section( ...
python
def _start_actions(self): """ Start all the actions for the recipes """ Global.LOGGER.info("starting actions") for recipe in Global.CONFIG_MANAGER.recipes: Global.CONFIG_MANAGER.read_recipe(recipe) list(map(lambda section: self._start_action_for_section( ...
[ "def", "_start_actions", "(", "self", ")", ":", "Global", ".", "LOGGER", ".", "info", "(", "\"starting actions\"", ")", "for", "recipe", "in", "Global", ".", "CONFIG_MANAGER", ".", "recipes", ":", "Global", ".", "CONFIG_MANAGER", ".", "read_recipe", "(", "re...
Start all the actions for the recipes
[ "Start", "all", "the", "actions", "for", "the", "recipes" ]
05e488385673a69597b5b39c7728795aa4d5eb18
https://github.com/mastro35/flows/blob/05e488385673a69597b5b39c7728795aa4d5eb18/flows/FlowsManager.py#L130-L140
train
Start all the actions for all the recipes in the current locale.
mastro35/flows
flows/FlowsManager.py
FlowsManager._start_action_for_section
def _start_action_for_section(self, section): """ Start all the actions for a particular section """ if section == "configuration": return Global.LOGGER.debug("starting actions for section " + section) # read the configuration of the action action_co...
python
def _start_action_for_section(self, section): """ Start all the actions for a particular section """ if section == "configuration": return Global.LOGGER.debug("starting actions for section " + section) # read the configuration of the action action_co...
[ "def", "_start_action_for_section", "(", "self", ",", "section", ")", ":", "if", "section", "==", "\"configuration\"", ":", "return", "Global", ".", "LOGGER", ".", "debug", "(", "\"starting actions for section \"", "+", "section", ")", "# read the configuration of the...
Start all the actions for a particular section
[ "Start", "all", "the", "actions", "for", "a", "particular", "section" ]
05e488385673a69597b5b39c7728795aa4d5eb18
https://github.com/mastro35/flows/blob/05e488385673a69597b5b39c7728795aa4d5eb18/flows/FlowsManager.py#L142-L185
train
Start all the actions for a particular section.
mastro35/flows
flows/FlowsManager.py
FlowsManager._stop_actions
def _stop_actions(self): """ Stop all the actions """ Global.LOGGER.info("stopping actions") list(map(lambda x: x.stop(), self.actions)) Global.LOGGER.info("actions stopped")
python
def _stop_actions(self): """ Stop all the actions """ Global.LOGGER.info("stopping actions") list(map(lambda x: x.stop(), self.actions)) Global.LOGGER.info("actions stopped")
[ "def", "_stop_actions", "(", "self", ")", ":", "Global", ".", "LOGGER", ".", "info", "(", "\"stopping actions\"", ")", "list", "(", "map", "(", "lambda", "x", ":", "x", ".", "stop", "(", ")", ",", "self", ".", "actions", ")", ")", "Global", ".", "L...
Stop all the actions
[ "Stop", "all", "the", "actions" ]
05e488385673a69597b5b39c7728795aa4d5eb18
https://github.com/mastro35/flows/blob/05e488385673a69597b5b39c7728795aa4d5eb18/flows/FlowsManager.py#L187-L195
train
Stop all the actions in the current thread.
mastro35/flows
flows/FlowsManager.py
FlowsManager._perform_system_check
def _perform_system_check(self): """ Perform a system check to define if we need to throttle to handle all the incoming messages """ if Global.CONFIG_MANAGER.tracing_mode: Global.LOGGER.debug("performing a system check") now = datetime.datetime.now() ...
python
def _perform_system_check(self): """ Perform a system check to define if we need to throttle to handle all the incoming messages """ if Global.CONFIG_MANAGER.tracing_mode: Global.LOGGER.debug("performing a system check") now = datetime.datetime.now() ...
[ "def", "_perform_system_check", "(", "self", ")", ":", "if", "Global", ".", "CONFIG_MANAGER", ".", "tracing_mode", ":", "Global", ".", "LOGGER", ".", "debug", "(", "\"performing a system check\"", ")", "now", "=", "datetime", ".", "datetime", ".", "now", "(", ...
Perform a system check to define if we need to throttle to handle all the incoming messages
[ "Perform", "a", "system", "check", "to", "define", "if", "we", "need", "to", "throttle", "to", "handle", "all", "the", "incoming", "messages" ]
05e488385673a69597b5b39c7728795aa4d5eb18
https://github.com/mastro35/flows/blob/05e488385673a69597b5b39c7728795aa4d5eb18/flows/FlowsManager.py#L197-L227
train
Perform a system check for all incoming messages in the current page.
mastro35/flows
flows/FlowsManager.py
FlowsManager._deliver_message
def _deliver_message(self, msg): """ Deliver the message to the subscripted actions """ my_subscribed_actions = self.subscriptions.get(msg.sender, []) for action in my_subscribed_actions: if Global.CONFIG_MANAGER.tracing_mode: Global.LOGGER.debug(f"del...
python
def _deliver_message(self, msg): """ Deliver the message to the subscripted actions """ my_subscribed_actions = self.subscriptions.get(msg.sender, []) for action in my_subscribed_actions: if Global.CONFIG_MANAGER.tracing_mode: Global.LOGGER.debug(f"del...
[ "def", "_deliver_message", "(", "self", ",", "msg", ")", ":", "my_subscribed_actions", "=", "self", ".", "subscriptions", ".", "get", "(", "msg", ".", "sender", ",", "[", "]", ")", "for", "action", "in", "my_subscribed_actions", ":", "if", "Global", ".", ...
Deliver the message to the subscripted actions
[ "Deliver", "the", "message", "to", "the", "subscripted", "actions" ]
05e488385673a69597b5b39c7728795aa4d5eb18
https://github.com/mastro35/flows/blob/05e488385673a69597b5b39c7728795aa4d5eb18/flows/FlowsManager.py#L229-L237
train
Deliver the message to the subscripted actions.
mastro35/flows
flows/FlowsManager.py
FlowsManager._fetch_messages
def _fetch_messages(self): """ Get an input message from the socket """ try: [_, msg] = self.socket.recv_multipart(flags=zmq.NOBLOCK) if Global.CONFIG_MANAGER.tracing_mode: Global.LOGGER.debug("fetched a new message") self.fetched = se...
python
def _fetch_messages(self): """ Get an input message from the socket """ try: [_, msg] = self.socket.recv_multipart(flags=zmq.NOBLOCK) if Global.CONFIG_MANAGER.tracing_mode: Global.LOGGER.debug("fetched a new message") self.fetched = se...
[ "def", "_fetch_messages", "(", "self", ")", ":", "try", ":", "[", "_", ",", "msg", "]", "=", "self", ".", "socket", ".", "recv_multipart", "(", "flags", "=", "zmq", ".", "NOBLOCK", ")", "if", "Global", ".", "CONFIG_MANAGER", ".", "tracing_mode", ":", ...
Get an input message from the socket
[ "Get", "an", "input", "message", "from", "the", "socket" ]
05e488385673a69597b5b39c7728795aa4d5eb18
https://github.com/mastro35/flows/blob/05e488385673a69597b5b39c7728795aa4d5eb18/flows/FlowsManager.py#L239-L256
train
Fetch a message from the socket and deliver it to the manager.
mastro35/flows
flows/FlowsManager.py
FlowsManager.message_fetcher_coroutine
async def message_fetcher_coroutine(self, loop): """ Register callback for message fetcher coroutines """ Global.LOGGER.debug('registering callbacks for message fetcher coroutine') self.isrunning = True while self.isrunning: loop.call_soon(self._fetch_messages...
python
async def message_fetcher_coroutine(self, loop): """ Register callback for message fetcher coroutines """ Global.LOGGER.debug('registering callbacks for message fetcher coroutine') self.isrunning = True while self.isrunning: loop.call_soon(self._fetch_messages...
[ "async", "def", "message_fetcher_coroutine", "(", "self", ",", "loop", ")", ":", "Global", ".", "LOGGER", ".", "debug", "(", "'registering callbacks for message fetcher coroutine'", ")", "self", ".", "isrunning", "=", "True", "while", "self", ".", "isrunning", ":"...
Register callback for message fetcher coroutines
[ "Register", "callback", "for", "message", "fetcher", "coroutines" ]
05e488385673a69597b5b39c7728795aa4d5eb18
https://github.com/mastro35/flows/blob/05e488385673a69597b5b39c7728795aa4d5eb18/flows/FlowsManager.py#L258-L269
train
Coroutine to run the message fetcher.
mastro35/flows
flows/FlowsManager.py
FlowsManager._start_message_fetcher
def _start_message_fetcher(self): """ Start the message fetcher (called from coroutine) """ Global.LOGGER.debug('starting the message fetcher') event_loop = asyncio.get_event_loop() try: Global.LOGGER.debug('entering event loop for message fetcher coro...
python
def _start_message_fetcher(self): """ Start the message fetcher (called from coroutine) """ Global.LOGGER.debug('starting the message fetcher') event_loop = asyncio.get_event_loop() try: Global.LOGGER.debug('entering event loop for message fetcher coro...
[ "def", "_start_message_fetcher", "(", "self", ")", ":", "Global", ".", "LOGGER", ".", "debug", "(", "'starting the message fetcher'", ")", "event_loop", "=", "asyncio", ".", "get_event_loop", "(", ")", "try", ":", "Global", ".", "LOGGER", ".", "debug", "(", ...
Start the message fetcher (called from coroutine)
[ "Start", "the", "message", "fetcher", "(", "called", "from", "coroutine", ")" ]
05e488385673a69597b5b39c7728795aa4d5eb18
https://github.com/mastro35/flows/blob/05e488385673a69597b5b39c7728795aa4d5eb18/flows/FlowsManager.py#L271-L282
train
Start the message fetcher.
mastro35/flows
flows/FlowsManager.py
FlowsManager._adapt_sleep_interval
def _adapt_sleep_interval(self, sent, received, queue, now): """ Adapt sleep time based on the number of the messages in queue """ Global.LOGGER.debug("adjusting sleep interval") dispatched_since_last_check = sent - self.last_queue_check_count seconds_since_last_check = ...
python
def _adapt_sleep_interval(self, sent, received, queue, now): """ Adapt sleep time based on the number of the messages in queue """ Global.LOGGER.debug("adjusting sleep interval") dispatched_since_last_check = sent - self.last_queue_check_count seconds_since_last_check = ...
[ "def", "_adapt_sleep_interval", "(", "self", ",", "sent", ",", "received", ",", "queue", ",", "now", ")", ":", "Global", ".", "LOGGER", ".", "debug", "(", "\"adjusting sleep interval\"", ")", "dispatched_since_last_check", "=", "sent", "-", "self", ".", "last_...
Adapt sleep time based on the number of the messages in queue
[ "Adapt", "sleep", "time", "based", "on", "the", "number", "of", "the", "messages", "in", "queue" ]
05e488385673a69597b5b39c7728795aa4d5eb18
https://github.com/mastro35/flows/blob/05e488385673a69597b5b39c7728795aa4d5eb18/flows/FlowsManager.py#L284-L314
train
Adapt sleep time based on the number of messages in queue and now.
mastro35/flows
flows/FlowsManager.py
FlowsManager._parse_input_parameters
def _parse_input_parameters(self): """ Set the configuration for the Logger """ Global.LOGGER.debug("define and parsing command line arguments") parser = argparse.ArgumentParser( description='A workflow engine for Pythonistas', formatter_class=argparse.RawTextHelpForm...
python
def _parse_input_parameters(self): """ Set the configuration for the Logger """ Global.LOGGER.debug("define and parsing command line arguments") parser = argparse.ArgumentParser( description='A workflow engine for Pythonistas', formatter_class=argparse.RawTextHelpForm...
[ "def", "_parse_input_parameters", "(", "self", ")", ":", "Global", ".", "LOGGER", ".", "debug", "(", "\"define and parsing command line arguments\"", ")", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'A workflow engine for Pythonistas'", "...
Set the configuration for the Logger
[ "Set", "the", "configuration", "for", "the", "Logger" ]
05e488385673a69597b5b39c7728795aa4d5eb18
https://github.com/mastro35/flows/blob/05e488385673a69597b5b39c7728795aa4d5eb18/flows/FlowsManager.py#L316-L340
train
Parse the command line arguments and return the parsed arguments.
mesbahamin/chronophore
scripts/chronophore_migrate.py
migrate_050_to_051
def migrate_050_to_051(session): """Set time_out field of all flagged timesheet entries to Null. """ entries_to_update = session.query(Entry).filter( Entry.forgot_sign_out.is_(True)).filter( Entry.time_out.isnot(None)) for entry in entries_to_update: entry.time_out =...
python
def migrate_050_to_051(session): """Set time_out field of all flagged timesheet entries to Null. """ entries_to_update = session.query(Entry).filter( Entry.forgot_sign_out.is_(True)).filter( Entry.time_out.isnot(None)) for entry in entries_to_update: entry.time_out =...
[ "def", "migrate_050_to_051", "(", "session", ")", ":", "entries_to_update", "=", "session", ".", "query", "(", "Entry", ")", ".", "filter", "(", "Entry", ".", "forgot_sign_out", ".", "is_", "(", "True", ")", ")", ".", "filter", "(", "Entry", ".", "time_o...
Set time_out field of all flagged timesheet entries to Null.
[ "Set", "time_out", "field", "of", "all", "flagged", "timesheet", "entries", "to", "Null", "." ]
ee140c61b4dfada966f078de8304bac737cec6f7
https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/scripts/chronophore_migrate.py#L17-L29
train
Migrate all flagged Videos to 050 and 505 timesheet entries to Null.
redhat-cip/python-dciclient
dciclient/v1/shell_commands/remoteci.py
create
def create(context, name, team_id, data, active): """create(context, name, team_id, data, active) Create a Remote CI >>> dcictl remoteci-create [OPTIONS] :param string name: Name of the Remote CI [required] :param string team_id: ID of the team to associate this remote CI with [required] ...
python
def create(context, name, team_id, data, active): """create(context, name, team_id, data, active) Create a Remote CI >>> dcictl remoteci-create [OPTIONS] :param string name: Name of the Remote CI [required] :param string team_id: ID of the team to associate this remote CI with [required] ...
[ "def", "create", "(", "context", ",", "name", ",", "team_id", ",", "data", ",", "active", ")", ":", "state", "=", "utils", ".", "active_string", "(", "active", ")", "team_id", "=", "team_id", "or", "identity", ".", "my_team_id", "(", "context", ")", "r...
create(context, name, team_id, data, active) Create a Remote CI >>> dcictl remoteci-create [OPTIONS] :param string name: Name of the Remote CI [required] :param string team_id: ID of the team to associate this remote CI with [required] :param string data: JSON data to pass during remote C...
[ "create", "(", "context", "name", "team_id", "data", "active", ")" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/remoteci.py#L56-L75
train
Create a Remote CI
redhat-cip/python-dciclient
dciclient/v1/shell_commands/remoteci.py
get_data
def get_data(context, id, keys): """get_data(context, id, keys) Retrieve data field from a remoteci. >>> dcictl remoteci-get-data [OPTIONS] :param string id: ID of the remote CI to show [required] :param string id: Keys of the data field to retrieve [optional] """ if keys: keys =...
python
def get_data(context, id, keys): """get_data(context, id, keys) Retrieve data field from a remoteci. >>> dcictl remoteci-get-data [OPTIONS] :param string id: ID of the remote CI to show [required] :param string id: Keys of the data field to retrieve [optional] """ if keys: keys =...
[ "def", "get_data", "(", "context", ",", "id", ",", "keys", ")", ":", "if", "keys", ":", "keys", "=", "keys", ".", "split", "(", "','", ")", "result", "=", "remoteci", ".", "get_data", "(", "context", ",", "id", "=", "id", ",", "keys", "=", "keys"...
get_data(context, id, keys) Retrieve data field from a remoteci. >>> dcictl remoteci-get-data [OPTIONS] :param string id: ID of the remote CI to show [required] :param string id: Keys of the data field to retrieve [optional]
[ "get_data", "(", "context", "id", "keys", ")" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/remoteci.py#L149-L163
train
Retrieve data field from a remote CI
redhat-cip/python-dciclient
dciclient/v1/shell_commands/remoteci.py
refresh_keys
def refresh_keys(context, id, etag): """refresh_keys(context, id, etag) Refresh a remoteci key pair. >>> dcictl remoteci-refresh-keys [OPTIONS] :param string id: ID of the remote CI [required] :param string etag: Entity tag of the remote CI resource [required] """ result = remoteci.refres...
python
def refresh_keys(context, id, etag): """refresh_keys(context, id, etag) Refresh a remoteci key pair. >>> dcictl remoteci-refresh-keys [OPTIONS] :param string id: ID of the remote CI [required] :param string etag: Entity tag of the remote CI resource [required] """ result = remoteci.refres...
[ "def", "refresh_keys", "(", "context", ",", "id", ",", "etag", ")", ":", "result", "=", "remoteci", ".", "refresh_keys", "(", "context", ",", "id", "=", "id", ",", "etag", "=", "etag", ")", "utils", ".", "format_output", "(", "result", ",", "context", ...
refresh_keys(context, id, etag) Refresh a remoteci key pair. >>> dcictl remoteci-refresh-keys [OPTIONS] :param string id: ID of the remote CI [required] :param string etag: Entity tag of the remote CI resource [required]
[ "refresh_keys", "(", "context", "id", "etag", ")" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/remoteci.py#L264-L275
train
Refresh a remote key pair.
redhat-cip/python-dciclient
dciclient/v1/shell_commands/remoteci.py
attach_user
def attach_user(context, id, user_id): """attach_user(context, id, user_id) Attach a user to a remoteci. >>> dcictl remoteci-attach-user [OPTIONS] :param string id: ID of the remoteci to attach the user to [required] :param string user_id: ID of the user to attach [required] """ result = ...
python
def attach_user(context, id, user_id): """attach_user(context, id, user_id) Attach a user to a remoteci. >>> dcictl remoteci-attach-user [OPTIONS] :param string id: ID of the remoteci to attach the user to [required] :param string user_id: ID of the user to attach [required] """ result = ...
[ "def", "attach_user", "(", "context", ",", "id", ",", "user_id", ")", ":", "result", "=", "remoteci", ".", "add_user", "(", "context", ",", "id", "=", "id", ",", "user_id", "=", "user_id", ")", "utils", ".", "format_output", "(", "result", ",", "contex...
attach_user(context, id, user_id) Attach a user to a remoteci. >>> dcictl remoteci-attach-user [OPTIONS] :param string id: ID of the remoteci to attach the user to [required] :param string user_id: ID of the user to attach [required]
[ "attach_user", "(", "context", "id", "user_id", ")" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/remoteci.py#L283-L295
train
Attach a user to a remoteci.
redhat-cip/python-dciclient
dciclient/v1/shell_commands/remoteci.py
list_user
def list_user(context, id, sort, limit, where, verbose): """list_user(context, id, sort, limit, where, verbose) List users attached to a remoteci. >>> dcictl remoteci-list-user [OPTIONS] :param string id: ID of the remoteci to list the user from [required] :param string sort...
python
def list_user(context, id, sort, limit, where, verbose): """list_user(context, id, sort, limit, where, verbose) List users attached to a remoteci. >>> dcictl remoteci-list-user [OPTIONS] :param string id: ID of the remoteci to list the user from [required] :param string sort...
[ "def", "list_user", "(", "context", ",", "id", ",", "sort", ",", "limit", ",", "where", ",", "verbose", ")", ":", "result", "=", "remoteci", ".", "list_users", "(", "context", ",", "id", "=", "id", ",", "sort", "=", "sort", ",", "limit", "=", "limi...
list_user(context, id, sort, limit, where, verbose) List users attached to a remoteci. >>> dcictl remoteci-list-user [OPTIONS] :param string id: ID of the remoteci to list the user from [required] :param string sort: Field to apply sort :param integer limit: Max number of ro...
[ "list_user", "(", "context", "id", "sort", "limit", "where", "verbose", ")" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/remoteci.py#L308-L324
train
List users attached to a remoteci.
redhat-cip/python-dciclient
dciclient/v1/shell_commands/remoteci.py
unattach_user
def unattach_user(context, id, user_id): """unattach_user(context, id, user_id) Unattach a user from a remoteci. >>> dcictl remoteci-unattach-user [OPTIONS] :param string id: ID of the remoteci to unattach the user from [required] :param string user_id: ID of the user to una...
python
def unattach_user(context, id, user_id): """unattach_user(context, id, user_id) Unattach a user from a remoteci. >>> dcictl remoteci-unattach-user [OPTIONS] :param string id: ID of the remoteci to unattach the user from [required] :param string user_id: ID of the user to una...
[ "def", "unattach_user", "(", "context", ",", "id", ",", "user_id", ")", ":", "result", "=", "remoteci", ".", "remove_user", "(", "context", ",", "id", "=", "id", ",", "user_id", "=", "user_id", ")", "if", "result", ".", "status_code", "==", "204", ":",...
unattach_user(context, id, user_id) Unattach a user from a remoteci. >>> dcictl remoteci-unattach-user [OPTIONS] :param string id: ID of the remoteci to unattach the user from [required] :param string user_id: ID of the user to unattach [required]
[ "unattach_user", "(", "context", "id", "user_id", ")" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/remoteci.py#L332-L349
train
Unattach a user from a RemoteCI
redhat-cip/python-dciclient
dciclient/v1/shell_commands/remoteci.py
attach_rconfiguration
def attach_rconfiguration(context, id, name, topic_id, component_types, data): """attach_rconfiguration(context, name, topic_id, component_types, data): Attach an rconfiguration to a Remote CI >>> dcictl remoteci-attach-rconfiguration ID [OPTIONS] :param string id: id of the remoteci :param strin...
python
def attach_rconfiguration(context, id, name, topic_id, component_types, data): """attach_rconfiguration(context, name, topic_id, component_types, data): Attach an rconfiguration to a Remote CI >>> dcictl remoteci-attach-rconfiguration ID [OPTIONS] :param string id: id of the remoteci :param strin...
[ "def", "attach_rconfiguration", "(", "context", ",", "id", ",", "name", ",", "topic_id", ",", "component_types", ",", "data", ")", ":", "result", "=", "remoteci", ".", "add_rconfiguration", "(", "context", ",", "id", ",", "name", ",", "topic_id", ",", "com...
attach_rconfiguration(context, name, topic_id, component_types, data): Attach an rconfiguration to a Remote CI >>> dcictl remoteci-attach-rconfiguration ID [OPTIONS] :param string id: id of the remoteci :param string name: name of the rconfiguration [required] :param string topic_id: ID of the to...
[ "attach_rconfiguration", "(", "context", "name", "topic_id", "component_types", "data", ")", ":" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/remoteci.py#L359-L377
train
This function will attach an rconfiguration to a Remote CI
redhat-cip/python-dciclient
dciclient/v1/shell_commands/remoteci.py
list_rconfigurations
def list_rconfigurations(context, id, sort, limit, where, verbose): """list_rconfigurations(context, id, sort, limit, where, verbose) List rconfigurations attached to a remoteci. >>> dcictl remoteci-list-rconfigurations ID [OPTIONS] :param string id: ID of the remoteci to list the rconfigurations fro...
python
def list_rconfigurations(context, id, sort, limit, where, verbose): """list_rconfigurations(context, id, sort, limit, where, verbose) List rconfigurations attached to a remoteci. >>> dcictl remoteci-list-rconfigurations ID [OPTIONS] :param string id: ID of the remoteci to list the rconfigurations fro...
[ "def", "list_rconfigurations", "(", "context", ",", "id", ",", "sort", ",", "limit", ",", "where", ",", "verbose", ")", ":", "result", "=", "remoteci", ".", "list_rconfigurations", "(", "context", ",", "id", "=", "id", ",", "sort", "=", "sort", ",", "l...
list_rconfigurations(context, id, sort, limit, where, verbose) List rconfigurations attached to a remoteci. >>> dcictl remoteci-list-rconfigurations ID [OPTIONS] :param string id: ID of the remoteci to list the rconfigurations from [required] :param string sort: Field to apply s...
[ "list_rconfigurations", "(", "context", "id", "sort", "limit", "where", "verbose", ")" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/remoteci.py#L390-L406
train
List rconfigurations attached to a remoteci.
redhat-cip/python-dciclient
dciclient/v1/shell_commands/remoteci.py
unattach_rconfiguration
def unattach_rconfiguration(context, id, rconfiguration_id): """unattach_rconfiguration(context, id, rconfiguration_id): Unattach a rconfiguration from a remoteci. >>> dcictl remoteci-unattach-rconfiguration id [OPTIONS] :param string id: ID of the remoteci to unattach the rconfiguration from ...
python
def unattach_rconfiguration(context, id, rconfiguration_id): """unattach_rconfiguration(context, id, rconfiguration_id): Unattach a rconfiguration from a remoteci. >>> dcictl remoteci-unattach-rconfiguration id [OPTIONS] :param string id: ID of the remoteci to unattach the rconfiguration from ...
[ "def", "unattach_rconfiguration", "(", "context", ",", "id", ",", "rconfiguration_id", ")", ":", "result", "=", "remoteci", ".", "delete_rconfiguration", "(", "context", ",", "id", "=", "id", ",", "rconfiguration_id", "=", "rconfiguration_id", ")", "if", "result...
unattach_rconfiguration(context, id, rconfiguration_id): Unattach a rconfiguration from a remoteci. >>> dcictl remoteci-unattach-rconfiguration id [OPTIONS] :param string id: ID of the remoteci to unattach the rconfiguration from [required] :param string rconfiguration_id: ID of...
[ "unattach_rconfiguration", "(", "context", "id", "rconfiguration_id", ")", ":" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/remoteci.py#L414-L432
train
Unattach an rconfiguration from a RemoteCI
ehansis/ozelot
ozelot/etl/tasks.py
get_task_param_string
def get_task_param_string(task): """Get all parameters of a task as one string Returns: str: task parameter string """ # get dict str -> str from luigi param_dict = task.to_str_params() # sort keys, serialize items = [] for key in sorted(param_dict.keys()): items.append...
python
def get_task_param_string(task): """Get all parameters of a task as one string Returns: str: task parameter string """ # get dict str -> str from luigi param_dict = task.to_str_params() # sort keys, serialize items = [] for key in sorted(param_dict.keys()): items.append...
[ "def", "get_task_param_string", "(", "task", ")", ":", "# get dict str -> str from luigi", "param_dict", "=", "task", ".", "to_str_params", "(", ")", "# sort keys, serialize", "items", "=", "[", "]", "for", "key", "in", "sorted", "(", "param_dict", ".", "keys", ...
Get all parameters of a task as one string Returns: str: task parameter string
[ "Get", "all", "parameters", "of", "a", "task", "as", "one", "string" ]
948675e02eb6fca940450f5cb814f53e97159e5b
https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/ozelot/etl/tasks.py#L18-L32
train
Get all parameters of a task as one string
ehansis/ozelot
ozelot/etl/tasks.py
check_completion
def check_completion(task, mark_incomplete=False, clear=False, return_stats=False): """Recursively check if a task and all its requirements are complete Args: task (derived from luigi.Task): Task to check completion for; check everything 'downstream' from that task. mark_incomplete...
python
def check_completion(task, mark_incomplete=False, clear=False, return_stats=False): """Recursively check if a task and all its requirements are complete Args: task (derived from luigi.Task): Task to check completion for; check everything 'downstream' from that task. mark_incomplete...
[ "def", "check_completion", "(", "task", ",", "mark_incomplete", "=", "False", ",", "clear", "=", "False", ",", "return_stats", "=", "False", ")", ":", "# run recursive task checking, get stats", "to_clear", "=", "dict", "(", ")", "is_complete", ",", "stats", "="...
Recursively check if a task and all its requirements are complete Args: task (derived from luigi.Task): Task to check completion for; check everything 'downstream' from that task. mark_incomplete (bool): If ``True`` set any task as incomplete for which a requirement is foun...
[ "Recursively", "check", "if", "a", "task", "and", "all", "its", "requirements", "are", "complete" ]
948675e02eb6fca940450f5cb814f53e97159e5b
https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/ozelot/etl/tasks.py#L191-L257
train
Recursively checks if a task and all its requirements are complete and returns True if the task and all its requirements are complete False otherwise.
ehansis/ozelot
ozelot/etl/tasks.py
_check_completion
def _check_completion(task, mark_incomplete, clear, stats, visited, to_clear): """Core recursion function for :func:`check_completion`, see there for more documentation Args: task (luigi.Task): task instance mark_incomplete (bool): see :func:`check_completion` clear (bool): see :func:...
python
def _check_completion(task, mark_incomplete, clear, stats, visited, to_clear): """Core recursion function for :func:`check_completion`, see there for more documentation Args: task (luigi.Task): task instance mark_incomplete (bool): see :func:`check_completion` clear (bool): see :func:...
[ "def", "_check_completion", "(", "task", ",", "mark_incomplete", ",", "clear", ",", "stats", ",", "visited", ",", "to_clear", ")", ":", "# is this task (recursively) complete?", "task_complete", "=", "task", ".", "complete", "(", ")", "is_complete", "=", "task_com...
Core recursion function for :func:`check_completion`, see there for more documentation Args: task (luigi.Task): task instance mark_incomplete (bool): see :func:`check_completion` clear (bool): see :func:`check_completion` stats (dict): task checking statistics (counts of incomple...
[ "Core", "recursion", "function", "for", ":", "func", ":", "check_completion", "see", "there", "for", "more", "documentation" ]
948675e02eb6fca940450f5cb814f53e97159e5b
https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/ozelot/etl/tasks.py#L260-L334
train
Recursive function to check the completion of a task instance.
ehansis/ozelot
ozelot/etl/tasks.py
TaskBase.build
def build(cls, local_scheduler=True, **task_params): """Instantiate the task and build it with luigi Args: local_scheduler (bool): use a local scheduler (True, default) or a remote scheduler task_params: parameters to pass to task for instantiation """ luigi.buil...
python
def build(cls, local_scheduler=True, **task_params): """Instantiate the task and build it with luigi Args: local_scheduler (bool): use a local scheduler (True, default) or a remote scheduler task_params: parameters to pass to task for instantiation """ luigi.buil...
[ "def", "build", "(", "cls", ",", "local_scheduler", "=", "True", ",", "*", "*", "task_params", ")", ":", "luigi", ".", "build", "(", "[", "cls", "(", "*", "*", "task_params", ")", "]", ",", "local_scheduler", "=", "local_scheduler", ")" ]
Instantiate the task and build it with luigi Args: local_scheduler (bool): use a local scheduler (True, default) or a remote scheduler task_params: parameters to pass to task for instantiation
[ "Instantiate", "the", "task", "and", "build", "it", "with", "luigi" ]
948675e02eb6fca940450f5cb814f53e97159e5b
https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/ozelot/etl/tasks.py#L63-L70
train
Instantiate the task and build it with luigi.
ehansis/ozelot
ozelot/etl/tasks.py
ORMTask.client
def client(self): """Get the DB client associated with the task (open a new one if necessary) Returns: ozelot.client.Client: DB client """ if self._client is None: self._client = client.get_client() return self._client
python
def client(self): """Get the DB client associated with the task (open a new one if necessary) Returns: ozelot.client.Client: DB client """ if self._client is None: self._client = client.get_client() return self._client
[ "def", "client", "(", "self", ")", ":", "if", "self", ".", "_client", "is", "None", ":", "self", ".", "_client", "=", "client", ".", "get_client", "(", ")", "return", "self", ".", "_client" ]
Get the DB client associated with the task (open a new one if necessary) Returns: ozelot.client.Client: DB client
[ "Get", "the", "DB", "client", "associated", "with", "the", "task", "(", "open", "a", "new", "one", "if", "necessary", ")" ]
948675e02eb6fca940450f5cb814f53e97159e5b
https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/ozelot/etl/tasks.py#L119-L128
train
Get the DB client associated with the task
ehansis/ozelot
ozelot/etl/tasks.py
ORMTask.session
def session(self): """Get the DB session associated with the task (open a new one if necessary) Returns: sqlalchemy.orm.session.Session: DB session """ if self._session is None: self._session = self.client.create_session() return self._session
python
def session(self): """Get the DB session associated with the task (open a new one if necessary) Returns: sqlalchemy.orm.session.Session: DB session """ if self._session is None: self._session = self.client.create_session() return self._session
[ "def", "session", "(", "self", ")", ":", "if", "self", ".", "_session", "is", "None", ":", "self", ".", "_session", "=", "self", ".", "client", ".", "create_session", "(", ")", "return", "self", ".", "_session" ]
Get the DB session associated with the task (open a new one if necessary) Returns: sqlalchemy.orm.session.Session: DB session
[ "Get", "the", "DB", "session", "associated", "with", "the", "task", "(", "open", "a", "new", "one", "if", "necessary", ")" ]
948675e02eb6fca940450f5cb814f53e97159e5b
https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/ozelot/etl/tasks.py#L131-L140
train
Get the DB session associated with the task
ehansis/ozelot
ozelot/etl/tasks.py
ORMTask.close_session
def close_session(self, commit=True): """Commit and close the DB session associated with this task (no error is raised if None is open) Args: commit (bool): commit session before closing (default=True) """ if self._session is not None: if commit: ...
python
def close_session(self, commit=True): """Commit and close the DB session associated with this task (no error is raised if None is open) Args: commit (bool): commit session before closing (default=True) """ if self._session is not None: if commit: ...
[ "def", "close_session", "(", "self", ",", "commit", "=", "True", ")", ":", "if", "self", ".", "_session", "is", "not", "None", ":", "if", "commit", ":", "self", ".", "_session", ".", "commit", "(", ")", "self", ".", "_session", ".", "close", "(", "...
Commit and close the DB session associated with this task (no error is raised if None is open) Args: commit (bool): commit session before closing (default=True)
[ "Commit", "and", "close", "the", "DB", "session", "associated", "with", "this", "task", "(", "no", "error", "is", "raised", "if", "None", "is", "open", ")" ]
948675e02eb6fca940450f5cb814f53e97159e5b
https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/ozelot/etl/tasks.py#L142-L152
train
Commit and close the DB session associated with this task.
ehansis/ozelot
ozelot/etl/tasks.py
ORMObjectCreatorMixin.clear
def clear( self # type: ORMTask ): """Delete all objects created by this task. Iterate over `self.object_classes` and delete all objects of the listed classes. """ # mark this task as incomplete self.mark_incomplete() # delete objects for object...
python
def clear( self # type: ORMTask ): """Delete all objects created by this task. Iterate over `self.object_classes` and delete all objects of the listed classes. """ # mark this task as incomplete self.mark_incomplete() # delete objects for object...
[ "def", "clear", "(", "self", "# type: ORMTask", ")", ":", "# mark this task as incomplete", "self", ".", "mark_incomplete", "(", ")", "# delete objects", "for", "object_class", "in", "self", ".", "object_classes", ":", "self", ".", "session", ".", "query", "(", ...
Delete all objects created by this task. Iterate over `self.object_classes` and delete all objects of the listed classes.
[ "Delete", "all", "objects", "created", "by", "this", "task", "." ]
948675e02eb6fca940450f5cb814f53e97159e5b
https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/ozelot/etl/tasks.py#L347-L361
train
Clears all objects created by this task.
ehansis/ozelot
ozelot/etl/tasks.py
ORMWrapperTask.complete
def complete(self): """Task is complete if completion marker is set and all requirements are complete """ is_complete = super(ORMWrapperTask, self).complete() for req in self.requires(): is_complete &= req.complete() return is_complete
python
def complete(self): """Task is complete if completion marker is set and all requirements are complete """ is_complete = super(ORMWrapperTask, self).complete() for req in self.requires(): is_complete &= req.complete() return is_complete
[ "def", "complete", "(", "self", ")", ":", "is_complete", "=", "super", "(", "ORMWrapperTask", ",", "self", ")", ".", "complete", "(", ")", "for", "req", "in", "self", ".", "requires", "(", ")", ":", "is_complete", "&=", "req", ".", "complete", "(", "...
Task is complete if completion marker is set and all requirements are complete
[ "Task", "is", "complete", "if", "completion", "marker", "is", "set", "and", "all", "requirements", "are", "complete" ]
948675e02eb6fca940450f5cb814f53e97159e5b
https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/ozelot/etl/tasks.py#L390-L397
train
Task is complete if completion marker is set and all requirements are complete
maljovec/topopy
topopy/MorseSmaleComplex.py
MorseSmaleComplex.reset
def reset(self): """ Empties all internal storage containers """ super(MorseSmaleComplex, self).reset() self.base_partitions = {} self.merge_sequence = {} self.persistences = [] self.min_indices = [] self.max_indices = [] # State pro...
python
def reset(self): """ Empties all internal storage containers """ super(MorseSmaleComplex, self).reset() self.base_partitions = {} self.merge_sequence = {} self.persistences = [] self.min_indices = [] self.max_indices = [] # State pro...
[ "def", "reset", "(", "self", ")", ":", "super", "(", "MorseSmaleComplex", ",", "self", ")", ".", "reset", "(", ")", "self", ".", "base_partitions", "=", "{", "}", "self", ".", "merge_sequence", "=", "{", "}", "self", ".", "persistences", "=", "[", "]...
Empties all internal storage containers
[ "Empties", "all", "internal", "storage", "containers" ]
4be598d51c4e4043b73d4ad44beed6d289e2f088
https://github.com/maljovec/topopy/blob/4be598d51c4e4043b73d4ad44beed6d289e2f088/topopy/MorseSmaleComplex.py#L89-L103
train
Resets internal storage containers to empty state.
maljovec/topopy
topopy/MorseSmaleComplex.py
MorseSmaleComplex.build
def build(self, X, Y, w=None, edges=None): """ Assigns data to this object and builds the Morse-Smale Complex @ In, X, an m-by-n array of values specifying m n-dimensional samples @ In, Y, a m vector of values specifying the output responses correspond...
python
def build(self, X, Y, w=None, edges=None): """ Assigns data to this object and builds the Morse-Smale Complex @ In, X, an m-by-n array of values specifying m n-dimensional samples @ In, Y, a m vector of values specifying the output responses correspond...
[ "def", "build", "(", "self", ",", "X", ",", "Y", ",", "w", "=", "None", ",", "edges", "=", "None", ")", ":", "super", "(", "MorseSmaleComplex", ",", "self", ")", ".", "build", "(", "X", ",", "Y", ",", "w", ",", "edges", ")", "if", "self", "."...
Assigns data to this object and builds the Morse-Smale Complex @ In, X, an m-by-n array of values specifying m n-dimensional samples @ In, Y, a m vector of values specifying the output responses corresponding to the m samples specified by X @ In, w...
[ "Assigns", "data", "to", "this", "object", "and", "builds", "the", "Morse", "-", "Smale", "Complex" ]
4be598d51c4e4043b73d4ad44beed6d289e2f088
https://github.com/maljovec/topopy/blob/4be598d51c4e4043b73d4ad44beed6d289e2f088/topopy/MorseSmaleComplex.py#L105-L157
train
Assigns data to this object and builds the Morse - Smale complex object.
maljovec/topopy
topopy/MorseSmaleComplex.py
MorseSmaleComplex.save
def save(self, filename=None): """ Saves a constructed Morse-Smale Complex in json file @ In, filename, a filename for storing the hierarchical merging of features and the base level partitions of the data """ if filename is None: filename = "morse...
python
def save(self, filename=None): """ Saves a constructed Morse-Smale Complex in json file @ In, filename, a filename for storing the hierarchical merging of features and the base level partitions of the data """ if filename is None: filename = "morse...
[ "def", "save", "(", "self", ",", "filename", "=", "None", ")", ":", "if", "filename", "is", "None", ":", "filename", "=", "\"morse_smale_complex.json\"", "with", "open", "(", "filename", ",", "\"w\"", ")", "as", "fp", ":", "fp", ".", "write", "(", "sel...
Saves a constructed Morse-Smale Complex in json file @ In, filename, a filename for storing the hierarchical merging of features and the base level partitions of the data
[ "Saves", "a", "constructed", "Morse", "-", "Smale", "Complex", "in", "json", "file" ]
4be598d51c4e4043b73d4ad44beed6d289e2f088
https://github.com/maljovec/topopy/blob/4be598d51c4e4043b73d4ad44beed6d289e2f088/topopy/MorseSmaleComplex.py#L159-L168
train
Saves the Morse - Smale Complex in json file containing the hierarchical Morse - Smale Complex data.
maljovec/topopy
topopy/MorseSmaleComplex.py
MorseSmaleComplex.get_partitions
def get_partitions(self, persistence=None): """ Returns the partitioned data based on a specified persistence level. @ In, persistence, a floating point value specifying the size of the smallest feature we want to track. Default = None means consider all features....
python
def get_partitions(self, persistence=None): """ Returns the partitioned data based on a specified persistence level. @ In, persistence, a floating point value specifying the size of the smallest feature we want to track. Default = None means consider all features....
[ "def", "get_partitions", "(", "self", ",", "persistence", "=", "None", ")", ":", "if", "persistence", "is", "None", ":", "persistence", "=", "self", ".", "persistence", "partitions", "=", "{", "}", "# TODO: Possibly cache at the critical persistence values,", "# pre...
Returns the partitioned data based on a specified persistence level. @ In, persistence, a floating point value specifying the size of the smallest feature we want to track. Default = None means consider all features. @ Out, a dictionary lists where each key is...
[ "Returns", "the", "partitioned", "data", "based", "on", "a", "specified", "persistence", "level", "." ]
4be598d51c4e4043b73d4ad44beed6d289e2f088
https://github.com/maljovec/topopy/blob/4be598d51c4e4043b73d4ad44beed6d289e2f088/topopy/MorseSmaleComplex.py#L195-L236
train
Returns the partitions of the base sequence based on a specified persistence level.