repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
riga/law
law/target/formatter.py
https://github.com/riga/law/blob/479f84ce06ecf3bafe9d33cb7b8fc52e39fb80a1/law/target/formatter.py#L73-L82
def find_formatter(name, path): """ Returns the formatter class whose name attribute is *name* when *name* is not *AUTO_FORMATTER*. Otherwise, the first formatter that accepts *path* is returned. Internally, this method simply uses :py:func:`get_formatter` or :py:func:`find_formatters` depending on the ...
[ "def", "find_formatter", "(", "name", ",", "path", ")", ":", "if", "name", "==", "AUTO_FORMATTER", ":", "return", "find_formatters", "(", "path", ",", "silent", "=", "False", ")", "[", "0", "]", "else", ":", "return", "get_formatter", "(", "name", ",", ...
Returns the formatter class whose name attribute is *name* when *name* is not *AUTO_FORMATTER*. Otherwise, the first formatter that accepts *path* is returned. Internally, this method simply uses :py:func:`get_formatter` or :py:func:`find_formatters` depending on the value of *name*.
[ "Returns", "the", "formatter", "class", "whose", "name", "attribute", "is", "*", "name", "*", "when", "*", "name", "*", "is", "not", "*", "AUTO_FORMATTER", "*", ".", "Otherwise", "the", "first", "formatter", "that", "accepts", "*", "path", "*", "is", "re...
python
train
onelogin/python3-saml
src/onelogin/saml2/logout_response.py
https://github.com/onelogin/python3-saml/blob/064b7275fba1e5f39a9116ba1cdcc5d01fc34daa/src/onelogin/saml2/logout_response.py#L69-L142
def is_valid(self, request_data, request_id=None, raise_exceptions=False): """ Determines if the SAML LogoutResponse is valid :param request_id: The ID of the LogoutRequest sent by this SP to the IdP :type request_id: string :param raise_exceptions: Whether to return false on fa...
[ "def", "is_valid", "(", "self", ",", "request_data", ",", "request_id", "=", "None", ",", "raise_exceptions", "=", "False", ")", ":", "self", ".", "__error", "=", "None", "try", ":", "idp_data", "=", "self", ".", "__settings", ".", "get_idp_data", "(", "...
Determines if the SAML LogoutResponse is valid :param request_id: The ID of the LogoutRequest sent by this SP to the IdP :type request_id: string :param raise_exceptions: Whether to return false on failure or raise an exception :type raise_exceptions: Boolean :return: Returns i...
[ "Determines", "if", "the", "SAML", "LogoutResponse", "is", "valid", ":", "param", "request_id", ":", "The", "ID", "of", "the", "LogoutRequest", "sent", "by", "this", "SP", "to", "the", "IdP", ":", "type", "request_id", ":", "string" ]
python
train
bitesofcode/projexui
projexui/widgets/xchart/xchartaxis.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xchart/xchartaxis.py#L118-L133
def labelCount(self): """ Returns the label count for this axis. If the labels have been defined then the length of the labels list will be provided, otherwise the hardcoded label count will be returned. :return <int> """ if self._labels is N...
[ "def", "labelCount", "(", "self", ")", ":", "if", "self", ".", "_labels", "is", "None", ":", "count", "=", "self", ".", "maximumLabelCount", "(", ")", "if", "count", "is", "None", ":", "return", "1", "else", ":", "return", "count", "return", "len", "...
Returns the label count for this axis. If the labels have been defined then the length of the labels list will be provided, otherwise the hardcoded label count will be returned. :return <int>
[ "Returns", "the", "label", "count", "for", "this", "axis", ".", "If", "the", "labels", "have", "been", "defined", "then", "the", "length", "of", "the", "labels", "list", "will", "be", "provided", "otherwise", "the", "hardcoded", "label", "count", "will", "...
python
train
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/api.py
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/api.py#L170-L187
def get_kb_mapping(kb_name="", key="", value="", match_type="e", default="", limit=None): """Get one unique mapping. If not found, return default. :param kb_name: the name of the kb :param key: include only lines matching this on left side in the results :param value: include only li...
[ "def", "get_kb_mapping", "(", "kb_name", "=", "\"\"", ",", "key", "=", "\"\"", ",", "value", "=", "\"\"", ",", "match_type", "=", "\"e\"", ",", "default", "=", "\"\"", ",", "limit", "=", "None", ")", ":", "mappings", "=", "get_kb_mappings", "(", "kb_na...
Get one unique mapping. If not found, return default. :param kb_name: the name of the kb :param key: include only lines matching this on left side in the results :param value: include only lines matching this on right side in the results :param match_type: s = substring match, e = exact match :para...
[ "Get", "one", "unique", "mapping", ".", "If", "not", "found", "return", "default", "." ]
python
train
saltstack/salt
salt/modules/win_lgpo.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_lgpo.py#L6596-L6615
def _regexSearchKeyValueCombo(policy_data, policy_regpath, policy_regkey): ''' helper function to do a search of Policy data from a registry.pol file for a policy_regpath and policy_regkey combo ''' if policy_data: specialValueRegex = salt.utils.stringutils.to_bytes(r'(\*\*Del\.|\*\*DelVals\...
[ "def", "_regexSearchKeyValueCombo", "(", "policy_data", ",", "policy_regpath", ",", "policy_regkey", ")", ":", "if", "policy_data", ":", "specialValueRegex", "=", "salt", ".", "utils", ".", "stringutils", ".", "to_bytes", "(", "r'(\\*\\*Del\\.|\\*\\*DelVals\\.){0,1}'", ...
helper function to do a search of Policy data from a registry.pol file for a policy_regpath and policy_regkey combo
[ "helper", "function", "to", "do", "a", "search", "of", "Policy", "data", "from", "a", "registry", ".", "pol", "file", "for", "a", "policy_regpath", "and", "policy_regkey", "combo" ]
python
train
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L306-L322
def medianscore(inlist): """ Returns the 'middle' score of the passed list. If there is an even number of scores, the mean of the 2 middle scores is returned. Usage: lmedianscore(inlist) """ newlist = copy.deepcopy(inlist) newlist.sort() if len(newlist) % 2 == 0: # if even number of scores, avera...
[ "def", "medianscore", "(", "inlist", ")", ":", "newlist", "=", "copy", ".", "deepcopy", "(", "inlist", ")", "newlist", ".", "sort", "(", ")", "if", "len", "(", "newlist", ")", "%", "2", "==", "0", ":", "# if even number of scores, average middle 2", "index...
Returns the 'middle' score of the passed list. If there is an even number of scores, the mean of the 2 middle scores is returned. Usage: lmedianscore(inlist)
[ "Returns", "the", "middle", "score", "of", "the", "passed", "list", ".", "If", "there", "is", "an", "even", "number", "of", "scores", "the", "mean", "of", "the", "2", "middle", "scores", "is", "returned", "." ]
python
train
saltstack/salt
salt/client/ssh/__init__.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/__init__.py#L1535-L1555
def lowstate_file_refs(chunks): ''' Create a list of file ref objects to reconcile ''' refs = {} for chunk in chunks: saltenv = 'base' crefs = [] for state in chunk: if state == '__env__': saltenv = chunk[state] elif state == 'saltenv':...
[ "def", "lowstate_file_refs", "(", "chunks", ")", ":", "refs", "=", "{", "}", "for", "chunk", "in", "chunks", ":", "saltenv", "=", "'base'", "crefs", "=", "[", "]", "for", "state", "in", "chunk", ":", "if", "state", "==", "'__env__'", ":", "saltenv", ...
Create a list of file ref objects to reconcile
[ "Create", "a", "list", "of", "file", "ref", "objects", "to", "reconcile" ]
python
train
consbio/parserutils
parserutils/elements.py
https://github.com/consbio/parserutils/blob/f13f80db99ed43479336b116e38512e3566e4623/parserutils/elements.py#L500-L515
def remove_element_attributes(elem_to_parse, *args): """ Removes the specified keys from the element's attributes, and returns a dict containing the attributes that have been removed. """ element = get_element(elem_to_parse) if element is None: return element if len(args): ...
[ "def", "remove_element_attributes", "(", "elem_to_parse", ",", "*", "args", ")", ":", "element", "=", "get_element", "(", "elem_to_parse", ")", "if", "element", "is", "None", ":", "return", "element", "if", "len", "(", "args", ")", ":", "attribs", "=", "el...
Removes the specified keys from the element's attributes, and returns a dict containing the attributes that have been removed.
[ "Removes", "the", "specified", "keys", "from", "the", "element", "s", "attributes", "and", "returns", "a", "dict", "containing", "the", "attributes", "that", "have", "been", "removed", "." ]
python
train
adrn/gala
gala/dynamics/_genfunc/toy_potentials.py
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/_genfunc/toy_potentials.py#L18-L26
def angact_ho(x,omega): """ Calculate angle and action variable in sho potential with parameter omega """ action = (x[3:]**2+(omega*x[:3])**2)/(2.*omega) angle = np.array([np.arctan(-x[3+i]/omega[i]/x[i]) if x[i]!=0. else -np.sign(x[3+i])*np.pi/2. for i in range(3)]) for i in range(3): if(x[...
[ "def", "angact_ho", "(", "x", ",", "omega", ")", ":", "action", "=", "(", "x", "[", "3", ":", "]", "**", "2", "+", "(", "omega", "*", "x", "[", ":", "3", "]", ")", "**", "2", ")", "/", "(", "2.", "*", "omega", ")", "angle", "=", "np", "...
Calculate angle and action variable in sho potential with parameter omega
[ "Calculate", "angle", "and", "action", "variable", "in", "sho", "potential", "with", "parameter", "omega" ]
python
train
saltstack/salt
salt/states/ssh_auth.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/ssh_auth.py#L392-L509
def absent(name, user, enc='ssh-rsa', comment='', source='', options=None, config='.ssh/authorized_keys', fingerprint_hash_type=None): ''' Verifies that the specified SSH key is absent name The SSH key to manage user ...
[ "def", "absent", "(", "name", ",", "user", ",", "enc", "=", "'ssh-rsa'", ",", "comment", "=", "''", ",", "source", "=", "''", ",", "options", "=", "None", ",", "config", "=", "'.ssh/authorized_keys'", ",", "fingerprint_hash_type", "=", "None", ")", ":", ...
Verifies that the specified SSH key is absent name The SSH key to manage user The user who owns the SSH authorized keys file to modify enc Defines what type of key is being used; can be ed25519, ecdsa, ssh-rsa or ssh-dss comment The comment to be placed with t...
[ "Verifies", "that", "the", "specified", "SSH", "key", "is", "absent" ]
python
train
JarryShaw/PyPCAPKit
src/interface/__init__.py
https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/interface/__init__.py#L53-L131
def extract(fin=None, fout=None, format=None, # basic settings auto=True, extension=True, store=True, # internal settings files=False, nofile=False, verbose=False, # output settings engine=None, layer=None, protocol=Non...
[ "def", "extract", "(", "fin", "=", "None", ",", "fout", "=", "None", ",", "format", "=", "None", ",", "# basic settings", "auto", "=", "True", ",", "extension", "=", "True", ",", "store", "=", "True", ",", "# internal settings", "files", "=", "False", ...
Extract a PCAP file. Keyword arguments: * fin -- str, file name to be read; if file not exist, raise an error * fout -- str, file name to be written * format -- str, file format of output <keyword> 'plist' / 'json' / 'tree' / 'html' * auto -- bool, if auto...
[ "Extract", "a", "PCAP", "file", "." ]
python
train
mitsei/dlkit
dlkit/json_/learning/objects.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/learning/objects.py#L375-L387
def clear_cognitive_process(self): """Clears the cognitive process. raise: NoAccess - ``Metadata.isRequired()`` or ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osid.resourc...
[ "def", "clear_cognitive_process", "(", "self", ")", ":", "# Implemented from template for osid.resource.ResourceForm.clear_avatar_template", "if", "(", "self", ".", "get_cognitive_process_metadata", "(", ")", ".", "is_read_only", "(", ")", "or", "self", ".", "get_cognitive_...
Clears the cognitive process. raise: NoAccess - ``Metadata.isRequired()`` or ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory -- This method must be implemented.*
[ "Clears", "the", "cognitive", "process", "." ]
python
train
davidrpugh/pyCollocation
pycollocation/solvers/solvers.py
https://github.com/davidrpugh/pyCollocation/blob/9376f3488a992dc416cfd2a4dbb396d094927569/pycollocation/solvers/solvers.py#L41-L58
def _evaluate_rhs(cls, funcs, nodes, problem): """ Compute the value of the right-hand side of the system of ODEs. Parameters ---------- basis_funcs : list(function) nodes : numpy.ndarray problem : TwoPointBVPLike Returns ------- evaluate...
[ "def", "_evaluate_rhs", "(", "cls", ",", "funcs", ",", "nodes", ",", "problem", ")", ":", "evald_funcs", "=", "cls", ".", "_evaluate_functions", "(", "funcs", ",", "nodes", ")", "evald_rhs", "=", "problem", ".", "rhs", "(", "nodes", ",", "*", "evald_func...
Compute the value of the right-hand side of the system of ODEs. Parameters ---------- basis_funcs : list(function) nodes : numpy.ndarray problem : TwoPointBVPLike Returns ------- evaluated_rhs : list(float)
[ "Compute", "the", "value", "of", "the", "right", "-", "hand", "side", "of", "the", "system", "of", "ODEs", "." ]
python
train
ga4gh/ga4gh-server
ga4gh/server/datamodel/obo_parser.py
https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/ga4gh/server/datamodel/obo_parser.py#L492-L497
def write_hier_all(self, out=sys.stdout, len_dash=1, max_depth=None, num_child=None, short_prt=False): """Write hierarchy for all GO Terms in obo file.""" # Print: [biological_process, molecular_function, and cellular_component] for go_id in ['GO:0008150', 'GO:0003674', 'GO...
[ "def", "write_hier_all", "(", "self", ",", "out", "=", "sys", ".", "stdout", ",", "len_dash", "=", "1", ",", "max_depth", "=", "None", ",", "num_child", "=", "None", ",", "short_prt", "=", "False", ")", ":", "# Print: [biological_process, molecular_function, a...
Write hierarchy for all GO Terms in obo file.
[ "Write", "hierarchy", "for", "all", "GO", "Terms", "in", "obo", "file", "." ]
python
train
mbj4668/pyang
pyang/plugins/sample-xml-skeleton.py
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/plugins/sample-xml-skeleton.py#L228-L237
def list_comment(self, node, elem, minel): """Add list annotation to `elem`.""" lo = "0" if minel is None else minel.arg maxel = node.search_one("max-elements") hi = "" if maxel is None else maxel.arg elem.insert(0, etree.Comment( " # entries: %s..%s " % (lo, hi))) ...
[ "def", "list_comment", "(", "self", ",", "node", ",", "elem", ",", "minel", ")", ":", "lo", "=", "\"0\"", "if", "minel", "is", "None", "else", "minel", ".", "arg", "maxel", "=", "node", ".", "search_one", "(", "\"max-elements\"", ")", "hi", "=", "\"\...
Add list annotation to `elem`.
[ "Add", "list", "annotation", "to", "elem", "." ]
python
train
boriel/zxbasic
zxbpp.py
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxbpp.py#L324-L333
def p_include_once(p): """ include_once : INCLUDE ONCE STRING """ if ENABLED: p[0] = include_once(p[3], p.lineno(3), local_first=True) else: p[0] = [] if not p[0]: p.lexer.next_token = '_ENDFILE_'
[ "def", "p_include_once", "(", "p", ")", ":", "if", "ENABLED", ":", "p", "[", "0", "]", "=", "include_once", "(", "p", "[", "3", "]", ",", "p", ".", "lineno", "(", "3", ")", ",", "local_first", "=", "True", ")", "else", ":", "p", "[", "0", "]"...
include_once : INCLUDE ONCE STRING
[ "include_once", ":", "INCLUDE", "ONCE", "STRING" ]
python
train
josiahcarlson/rom
rom/util.py
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/util.py#L520-L554
def save(self, *objects, **kwargs): ''' This method is an alternate API for saving many entities (possibly not tracked by the session). You can call:: session.save(obj) session.save(obj1, obj2, ...) session.save([obj1, obj2, ...]) And the entities wi...
[ "def", "save", "(", "self", ",", "*", "objects", ",", "*", "*", "kwargs", ")", ":", "from", "rom", "import", "Model", "full", "=", "kwargs", ".", "get", "(", "'full'", ")", "all", "=", "kwargs", ".", "get", "(", "'all'", ")", "force", "=", "kwarg...
This method is an alternate API for saving many entities (possibly not tracked by the session). You can call:: session.save(obj) session.save(obj1, obj2, ...) session.save([obj1, obj2, ...]) And the entities will be flushed to Redis. You can pass the keywor...
[ "This", "method", "is", "an", "alternate", "API", "for", "saving", "many", "entities", "(", "possibly", "not", "tracked", "by", "the", "session", ")", ".", "You", "can", "call", "::" ]
python
test
StackStorm/pybind
pybind/slxos/v17r_2_00/cluster/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17r_2_00/cluster/__init__.py#L418-L441
def _set_client_pw(self, v, load=False): """ Setter method for client_pw, mapped from YANG variable /cluster/client_pw (container) If this variable is read-only (config: false) in the source YANG file, then _set_client_pw is considered as a private method. Backends looking to populate this variable ...
[ "def", "_set_client_pw", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v", ",", "base...
Setter method for client_pw, mapped from YANG variable /cluster/client_pw (container) If this variable is read-only (config: false) in the source YANG file, then _set_client_pw is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_client_pw()...
[ "Setter", "method", "for", "client_pw", "mapped", "from", "YANG", "variable", "/", "cluster", "/", "client_pw", "(", "container", ")", "If", "this", "variable", "is", "read", "-", "only", "(", "config", ":", "false", ")", "in", "the", "source", "YANG", "...
python
train
riptano/ccm
ccmlib/node.py
https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/node.py#L422-L433
def mark_log(self, filename='system.log'): """ Returns "a mark" to the current position of this node Cassandra log. This is for use with the from_mark parameter of watch_log_for_* methods, allowing to watch the log from the position when this method was called. """ log_fi...
[ "def", "mark_log", "(", "self", ",", "filename", "=", "'system.log'", ")", ":", "log_file", "=", "os", ".", "path", ".", "join", "(", "self", ".", "get_path", "(", ")", ",", "'logs'", ",", "filename", ")", "if", "not", "os", ".", "path", ".", "exis...
Returns "a mark" to the current position of this node Cassandra log. This is for use with the from_mark parameter of watch_log_for_* methods, allowing to watch the log from the position when this method was called.
[ "Returns", "a", "mark", "to", "the", "current", "position", "of", "this", "node", "Cassandra", "log", ".", "This", "is", "for", "use", "with", "the", "from_mark", "parameter", "of", "watch_log_for_", "*", "methods", "allowing", "to", "watch", "the", "log", ...
python
train
DAI-Lab/Copulas
copulas/univariate/gaussian.py
https://github.com/DAI-Lab/Copulas/blob/821df61c3d36a6b81ef2883935f935c2eaaa862c/copulas/univariate/gaussian.py#L69-L79
def cumulative_distribution(self, X): """Cumulative distribution function for gaussian distribution. Arguments: X: `np.ndarray` of shape (n, 1). Returns: np.ndarray: Cumulative density for X. """ self.check_fit() return norm.cdf(X, loc=self.mean,...
[ "def", "cumulative_distribution", "(", "self", ",", "X", ")", ":", "self", ".", "check_fit", "(", ")", "return", "norm", ".", "cdf", "(", "X", ",", "loc", "=", "self", ".", "mean", ",", "scale", "=", "self", ".", "std", ")" ]
Cumulative distribution function for gaussian distribution. Arguments: X: `np.ndarray` of shape (n, 1). Returns: np.ndarray: Cumulative density for X.
[ "Cumulative", "distribution", "function", "for", "gaussian", "distribution", "." ]
python
train
erinxocon/spotify-local
src/spotify_local/utils.py
https://github.com/erinxocon/spotify-local/blob/8188eef221e3d8b9f408ff430d80e74560360459/src/spotify_local/utils.py#L34-L38
def get_csrf_token(): """Retrieve a simple csrf token for to prevent cross site request forgery.""" url = get_url("/simplecsrf/token.json") r = s.get(url=url, headers=DEFAULT_ORIGIN) return r.json()["token"]
[ "def", "get_csrf_token", "(", ")", ":", "url", "=", "get_url", "(", "\"/simplecsrf/token.json\"", ")", "r", "=", "s", ".", "get", "(", "url", "=", "url", ",", "headers", "=", "DEFAULT_ORIGIN", ")", "return", "r", ".", "json", "(", ")", "[", "\"token\""...
Retrieve a simple csrf token for to prevent cross site request forgery.
[ "Retrieve", "a", "simple", "csrf", "token", "for", "to", "prevent", "cross", "site", "request", "forgery", "." ]
python
train
casacore/python-casacore
casacore/util/substitute.py
https://github.com/casacore/python-casacore/blob/975510861ea005f7919dd9e438b5f98a1682eebe/casacore/util/substitute.py#L62-L206
def substitute(s, objlist=(), globals={}, locals={}): """Substitute global python variables in a command string. This function parses a string and tries to substitute parts like `$name` by their value. It is uses by :mod:`image` and :mod:`table` to handle image and table objects in a command, but also ...
[ "def", "substitute", "(", "s", ",", "objlist", "=", "(", ")", ",", "globals", "=", "{", "}", ",", "locals", "=", "{", "}", ")", ":", "# Get the local variables at the caller level if not given.", "if", "not", "locals", ":", "locals", "=", "getlocals", "(", ...
Substitute global python variables in a command string. This function parses a string and tries to substitute parts like `$name` by their value. It is uses by :mod:`image` and :mod:`table` to handle image and table objects in a command, but also other variables (integers, strings, etc.) can be substitu...
[ "Substitute", "global", "python", "variables", "in", "a", "command", "string", "." ]
python
train
jcushman/pdfquery
pdfquery/pdfquery.py
https://github.com/jcushman/pdfquery/blob/f1c05d15e0c1b7c523a0971bc89b5610d8560f79/pdfquery/pdfquery.py#L439-L454
def get_pyquery(self, tree=None, page_numbers=None): """ Wrap given tree in pyquery and return. If no tree supplied, will generate one from given page_numbers, or all page numbers. """ if not page_numbers: page_numbers = [] if tree ...
[ "def", "get_pyquery", "(", "self", ",", "tree", "=", "None", ",", "page_numbers", "=", "None", ")", ":", "if", "not", "page_numbers", ":", "page_numbers", "=", "[", "]", "if", "tree", "is", "None", ":", "if", "not", "page_numbers", "and", "self", ".", ...
Wrap given tree in pyquery and return. If no tree supplied, will generate one from given page_numbers, or all page numbers.
[ "Wrap", "given", "tree", "in", "pyquery", "and", "return", ".", "If", "no", "tree", "supplied", "will", "generate", "one", "from", "given", "page_numbers", "or", "all", "page", "numbers", "." ]
python
train
SmokinCaterpillar/pypet
pypet/pypetlogging.py
https://github.com/SmokinCaterpillar/pypet/blob/97ad3e80d46dbdea02deeb98ea41f05a19565826/pypet/pypetlogging.py#L710-L716
def finalize(self): """Disables redirection""" if self._original_steam is not None and self._redirection: sys.stdout = self._original_steam print('Disabled redirection of `stdout`.') self._redirection = False self._original_steam = None
[ "def", "finalize", "(", "self", ")", ":", "if", "self", ".", "_original_steam", "is", "not", "None", "and", "self", ".", "_redirection", ":", "sys", ".", "stdout", "=", "self", ".", "_original_steam", "print", "(", "'Disabled redirection of `stdout`.'", ")", ...
Disables redirection
[ "Disables", "redirection" ]
python
test
eyurtsev/FlowCytometryTools
FlowCytometryTools/__init__.py
https://github.com/eyurtsev/FlowCytometryTools/blob/4355632508b875273d68c7e2972c17668bcf7b40/FlowCytometryTools/__init__.py#L15-L21
def _get_paths(): """Generate paths to test data. Done in a function to protect namespace a bit.""" import os base_path = os.path.dirname(os.path.abspath(__file__)) test_data_dir = os.path.join(base_path, 'tests', 'data', 'Plate01') test_data_file = os.path.join(test_data_dir, 'RFP_Well_A3.fcs') ...
[ "def", "_get_paths", "(", ")", ":", "import", "os", "base_path", "=", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "abspath", "(", "__file__", ")", ")", "test_data_dir", "=", "os", ".", "path", ".", "join", "(", "base_path", ",", ...
Generate paths to test data. Done in a function to protect namespace a bit.
[ "Generate", "paths", "to", "test", "data", ".", "Done", "in", "a", "function", "to", "protect", "namespace", "a", "bit", "." ]
python
train
xhtml2pdf/xhtml2pdf
xhtml2pdf/paragraph.py
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/paragraph.py#L483-L502
def split(self, availWidth, availHeight): """ Split ourselves in two paragraphs. """ logger.debug("*** split (%f, %f)", availWidth, availHeight) splitted = [] if self.splitIndex: text1 = self.text[:self.splitIndex] text2 = self.text[self.splitInd...
[ "def", "split", "(", "self", ",", "availWidth", ",", "availHeight", ")", ":", "logger", ".", "debug", "(", "\"*** split (%f, %f)\"", ",", "availWidth", ",", "availHeight", ")", "splitted", "=", "[", "]", "if", "self", ".", "splitIndex", ":", "text1", "=", ...
Split ourselves in two paragraphs.
[ "Split", "ourselves", "in", "two", "paragraphs", "." ]
python
train
OpenTreeOfLife/peyotl
peyotl/phylesystem/git_workflows.py
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/phylesystem/git_workflows.py#L91-L100
def merge_from_master(git_action, study_id, auth_info, parent_sha): """merge from master into the WIP for this study/author this is needed to allow a worker's future saves to be merged seamlessly into master """ return _merge_from_master(git_action, doc_id=study_id, ...
[ "def", "merge_from_master", "(", "git_action", ",", "study_id", ",", "auth_info", ",", "parent_sha", ")", ":", "return", "_merge_from_master", "(", "git_action", ",", "doc_id", "=", "study_id", ",", "auth_info", "=", "auth_info", ",", "parent_sha", "=", "parent_...
merge from master into the WIP for this study/author this is needed to allow a worker's future saves to be merged seamlessly into master
[ "merge", "from", "master", "into", "the", "WIP", "for", "this", "study", "/", "author", "this", "is", "needed", "to", "allow", "a", "worker", "s", "future", "saves", "to", "be", "merged", "seamlessly", "into", "master" ]
python
train
ga4gh/ga4gh-server
ga4gh/server/backend.py
https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/ga4gh/server/backend.py#L655-L663
def runGetCallSet(self, id_): """ Returns a callset with the given id """ compoundId = datamodel.CallSetCompoundId.parse(id_) dataset = self.getDataRepository().getDataset(compoundId.dataset_id) variantSet = dataset.getVariantSet(compoundId.variant_set_id) callSet...
[ "def", "runGetCallSet", "(", "self", ",", "id_", ")", ":", "compoundId", "=", "datamodel", ".", "CallSetCompoundId", ".", "parse", "(", "id_", ")", "dataset", "=", "self", ".", "getDataRepository", "(", ")", ".", "getDataset", "(", "compoundId", ".", "data...
Returns a callset with the given id
[ "Returns", "a", "callset", "with", "the", "given", "id" ]
python
train
eaton-lab/toytree
versioner.py
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L121-L127
def _get_init_release_tag(self): """ parses init.py to get previous version """ self.init_version = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", open(self.init_file, "r").read(), re.M).group(1)
[ "def", "_get_init_release_tag", "(", "self", ")", ":", "self", ".", "init_version", "=", "re", ".", "search", "(", "r\"^__version__ = ['\\\"]([^'\\\"]*)['\\\"]\"", ",", "open", "(", "self", ".", "init_file", ",", "\"r\"", ")", ".", "read", "(", ")", ",", "re...
parses init.py to get previous version
[ "parses", "init", ".", "py", "to", "get", "previous", "version" ]
python
train
xen/webcraft
webcraft/admin/saform.py
https://github.com/xen/webcraft/blob/74ff1e5b253048d9260446bfbc95de2e402a8005/webcraft/admin/saform.py#L91-L117
def generate_form(model, only=None, meta=None): """ Generate WTForm based on SQLAlchemy table :param model: SQLAlchemy sa.Table :param only: list or set of columns that should be used in final form :param meta: Meta class with settings for form :return: WTForm object """ fields = Ordered...
[ "def", "generate_form", "(", "model", ",", "only", "=", "None", ",", "meta", "=", "None", ")", ":", "fields", "=", "OrderedDict", "(", ")", "if", "meta", ":", "fields", "[", "'Meta'", "]", "=", "meta", "for", "name", ",", "column", "in", "model", "...
Generate WTForm based on SQLAlchemy table :param model: SQLAlchemy sa.Table :param only: list or set of columns that should be used in final form :param meta: Meta class with settings for form :return: WTForm object
[ "Generate", "WTForm", "based", "on", "SQLAlchemy", "table", ":", "param", "model", ":", "SQLAlchemy", "sa", ".", "Table", ":", "param", "only", ":", "list", "or", "set", "of", "columns", "that", "should", "be", "used", "in", "final", "form", ":", "param"...
python
train
mitsei/dlkit
dlkit/handcar/repository/managers.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/repository/managers.py#L2919-L2945
def get_composition_repository_assignment_session(self, proxy): """Gets the session for assigning composition to repository mappings. arg proxy (osid.proxy.Proxy): a proxy return: (osid.repository.CompositionRepositoryAssignmentSession) - a CompositionRepositoryAssig...
[ "def", "get_composition_repository_assignment_session", "(", "self", ",", "proxy", ")", ":", "if", "not", "self", ".", "supports_composition_repository_assignment", "(", ")", ":", "raise", "Unimplemented", "(", ")", "try", ":", "from", ".", "import", "sessions", "...
Gets the session for assigning composition to repository mappings. arg proxy (osid.proxy.Proxy): a proxy return: (osid.repository.CompositionRepositoryAssignmentSession) - a CompositionRepositoryAssignmentSession raise: OperationFailed - unable to complete request ...
[ "Gets", "the", "session", "for", "assigning", "composition", "to", "repository", "mappings", "." ]
python
train
simon-anders/htseq
python2/src/StepVector.py
https://github.com/simon-anders/htseq/blob/6f7d66e757e610228c33ebf2bb5dc8cc5051c7f0/python2/src/StepVector.py#L466-L495
def create( cls, length = sys.maxint, typecode = 'd', start_index = 0 ): """Construct a StepVector of the given length, with indices starting at the given start_index and counting up to (but not including) start_index + length. The typecode may be: 'd' for float values (C type 'double')...
[ "def", "create", "(", "cls", ",", "length", "=", "sys", ".", "maxint", ",", "typecode", "=", "'d'", ",", "start_index", "=", "0", ")", ":", "if", "typecode", "==", "'d'", ":", "swigclass", "=", "_StepVector_float", "elif", "typecode", "==", "'i'", ":",...
Construct a StepVector of the given length, with indices starting at the given start_index and counting up to (but not including) start_index + length. The typecode may be: 'd' for float values (C type 'double'), 'i' for int values, 'b' for Boolean values, 'O' for arbi...
[ "Construct", "a", "StepVector", "of", "the", "given", "length", "with", "indices", "starting", "at", "the", "given", "start_index", "and", "counting", "up", "to", "(", "but", "not", "including", ")", "start_index", "+", "length", "." ]
python
train
indico/indico-plugins
chat/indico_chat/xmpp.py
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/chat/indico_chat/xmpp.py#L44-L56
def create_room(room): """Creates a MUC room on the XMPP server.""" if room.custom_server: return def _create_room(xmpp): muc = xmpp.plugin['xep_0045'] muc.joinMUC(room.jid, xmpp.requested_jid.user) muc.configureRoom(room.jid, _set_form_values(xmpp, room)) current_plug...
[ "def", "create_room", "(", "room", ")", ":", "if", "room", ".", "custom_server", ":", "return", "def", "_create_room", "(", "xmpp", ")", ":", "muc", "=", "xmpp", ".", "plugin", "[", "'xep_0045'", "]", "muc", ".", "joinMUC", "(", "room", ".", "jid", "...
Creates a MUC room on the XMPP server.
[ "Creates", "a", "MUC", "room", "on", "the", "XMPP", "server", "." ]
python
train
KE-works/pykechain
pykechain/models/scope.py
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/scope.py#L225-L235
def add_manager(self, manager): """ Add a single manager to the scope. :param manager: single username to be added to the scope list of managers :type manager: basestring :raises APIError: when unable to update the scope manager """ select_action = 'add_manager' ...
[ "def", "add_manager", "(", "self", ",", "manager", ")", ":", "select_action", "=", "'add_manager'", "self", ".", "_update_scope_project_team", "(", "select_action", "=", "select_action", ",", "user", "=", "manager", ",", "user_type", "=", "'manager'", ")" ]
Add a single manager to the scope. :param manager: single username to be added to the scope list of managers :type manager: basestring :raises APIError: when unable to update the scope manager
[ "Add", "a", "single", "manager", "to", "the", "scope", "." ]
python
train
cloudendpoints/endpoints-python
endpoints/protojson.py
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/protojson.py#L68-L84
def __pad_value(value, pad_len_multiple, pad_char): """Add padding characters to the value if needed. Args: value: The string value to be padded. pad_len_multiple: Pad the result so its length is a multiple of pad_len_multiple. pad_char: The character to use for padding. Return...
[ "def", "__pad_value", "(", "value", ",", "pad_len_multiple", ",", "pad_char", ")", ":", "assert", "pad_len_multiple", ">", "0", "assert", "len", "(", "pad_char", ")", "==", "1", "padding_length", "=", "(", "pad_len_multiple", "-", "(", "len", "(", "value", ...
Add padding characters to the value if needed. Args: value: The string value to be padded. pad_len_multiple: Pad the result so its length is a multiple of pad_len_multiple. pad_char: The character to use for padding. Returns: The string value with padding characters added.
[ "Add", "padding", "characters", "to", "the", "value", "if", "needed", "." ]
python
train
limix/numpy-sugar
numpy_sugar/linalg/dot.py
https://github.com/limix/numpy-sugar/blob/4bdfa26913135c76ef3cd542a332f4e5861e948b/numpy_sugar/linalg/dot.py#L60-L83
def cdot(L, out=None): r"""Product of a Cholesky matrix with itself transposed. Args: L (array_like): Cholesky matrix. out (:class:`numpy.ndarray`, optional): copy result to. Returns: :class:`numpy.ndarray`: :math:`\mathrm L\mathrm L^\intercal`. """ L = asarray(L, float) ...
[ "def", "cdot", "(", "L", ",", "out", "=", "None", ")", ":", "L", "=", "asarray", "(", "L", ",", "float", ")", "layout_error", "=", "\"Wrong matrix layout.\"", "if", "L", ".", "ndim", "!=", "2", ":", "raise", "ValueError", "(", "layout_error", ")", "i...
r"""Product of a Cholesky matrix with itself transposed. Args: L (array_like): Cholesky matrix. out (:class:`numpy.ndarray`, optional): copy result to. Returns: :class:`numpy.ndarray`: :math:`\mathrm L\mathrm L^\intercal`.
[ "r", "Product", "of", "a", "Cholesky", "matrix", "with", "itself", "transposed", "." ]
python
train
fhcrc/taxtastic
taxtastic/utils.py
https://github.com/fhcrc/taxtastic/blob/4e874b7f2cc146178828bfba386314f8c342722b/taxtastic/utils.py#L274-L292
def sqlite_default(): ''' Prepend default scheme if none is specified. This helps provides backwards compatibility with old versions of taxtastic where sqlite was the automatic default database. ''' def parse_url(url): # TODO: need separate option for a config file if url.endswit...
[ "def", "sqlite_default", "(", ")", ":", "def", "parse_url", "(", "url", ")", ":", "# TODO: need separate option for a config file", "if", "url", ".", "endswith", "(", "'.db'", ")", "or", "url", ".", "endswith", "(", "'.sqlite'", ")", ":", "if", "not", "url",...
Prepend default scheme if none is specified. This helps provides backwards compatibility with old versions of taxtastic where sqlite was the automatic default database.
[ "Prepend", "default", "scheme", "if", "none", "is", "specified", ".", "This", "helps", "provides", "backwards", "compatibility", "with", "old", "versions", "of", "taxtastic", "where", "sqlite", "was", "the", "automatic", "default", "database", "." ]
python
train
njsmith/colorspacious
colorspacious/illuminants.py
https://github.com/njsmith/colorspacious/blob/59e0226003fb1b894597c5081e8ca5a3aa4fcefd/colorspacious/illuminants.py#L97-L116
def as_XYZ100_w(whitepoint): """A convenience function for getting whitepoints. ``whitepoint`` can be either a string naming a standard illuminant (see :func:`standard_illuminant_XYZ100`), or else a whitepoint given explicitly as an array-like of XYZ values. We internally call this function anywhe...
[ "def", "as_XYZ100_w", "(", "whitepoint", ")", ":", "if", "isinstance", "(", "whitepoint", ",", "str", ")", ":", "return", "standard_illuminant_XYZ100", "(", "whitepoint", ")", "else", ":", "whitepoint", "=", "np", ".", "asarray", "(", "whitepoint", ",", "dty...
A convenience function for getting whitepoints. ``whitepoint`` can be either a string naming a standard illuminant (see :func:`standard_illuminant_XYZ100`), or else a whitepoint given explicitly as an array-like of XYZ values. We internally call this function anywhere you have to specify a whitepoint ...
[ "A", "convenience", "function", "for", "getting", "whitepoints", "." ]
python
train
monarch-initiative/dipper
dipper/sources/Panther.py
https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/Panther.py#L92-L107
def parse(self, limit=None): """ :return: None """ if self.test_only: self.test_mode = True if self.tax_ids is None: LOG.info("No taxon filter set; Dumping all orthologous associations.") else: LOG.info("Only the following taxa will b...
[ "def", "parse", "(", "self", ",", "limit", "=", "None", ")", ":", "if", "self", ".", "test_only", ":", "self", ".", "test_mode", "=", "True", "if", "self", ".", "tax_ids", "is", "None", ":", "LOG", ".", "info", "(", "\"No taxon filter set; Dumping all or...
:return: None
[ ":", "return", ":", "None" ]
python
train
mabuchilab/QNET
src/qnet/printing/sympy.py
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/printing/sympy.py#L50-L93
def derationalize_denom(expr): """Try to de-rationalize the denominator of the given expression. The purpose is to allow to reconstruct e.g. ``1/sqrt(2)`` from ``sqrt(2)/2``. Specifically, this matches `expr` against the following pattern:: Mul(..., Rational(n, d), Pow(d, Rational(1, 2)), ......
[ "def", "derationalize_denom", "(", "expr", ")", ":", "r_pos", "=", "-", "1", "p_pos", "=", "-", "1", "numerator", "=", "S", ".", "Zero", "denom_sq", "=", "S", ".", "One", "post_factors", "=", "[", "]", "if", "isinstance", "(", "expr", ",", "Mul", "...
Try to de-rationalize the denominator of the given expression. The purpose is to allow to reconstruct e.g. ``1/sqrt(2)`` from ``sqrt(2)/2``. Specifically, this matches `expr` against the following pattern:: Mul(..., Rational(n, d), Pow(d, Rational(1, 2)), ...) and returns a tuple ``(numerato...
[ "Try", "to", "de", "-", "rationalize", "the", "denominator", "of", "the", "given", "expression", "." ]
python
train
tweekmonster/moult
moult/filesystem_scanner.py
https://github.com/tweekmonster/moult/blob/38d3a3b9002336219897ebe263ca1d8dcadbecf5/moult/filesystem_scanner.py#L114-L149
def scan_directory(pym, directory, sentinel, installed, depth=0): '''Entry point scan that creates a PyModule instance if needed. ''' if not pym: d = os.path.abspath(directory) basename = os.path.basename(d) pym = utils.find_package(basename, installed) if not pym: ...
[ "def", "scan_directory", "(", "pym", ",", "directory", ",", "sentinel", ",", "installed", ",", "depth", "=", "0", ")", ":", "if", "not", "pym", ":", "d", "=", "os", ".", "path", ".", "abspath", "(", "directory", ")", "basename", "=", "os", ".", "pa...
Entry point scan that creates a PyModule instance if needed.
[ "Entry", "point", "scan", "that", "creates", "a", "PyModule", "instance", "if", "needed", "." ]
python
train
fermiPy/fermipy
fermipy/irfs.py
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/irfs.py#L846-L873
def calc_counts(skydir, ltc, event_class, event_types, egy_bins, cth_bins, fn, npts=1): """Calculate the expected counts vs. true energy and incidence angle for a source with spectral parameterization ``fn``. Parameters ---------- skydir : `~astropy.coordinate.SkyCoord` ltc : `...
[ "def", "calc_counts", "(", "skydir", ",", "ltc", ",", "event_class", ",", "event_types", ",", "egy_bins", ",", "cth_bins", ",", "fn", ",", "npts", "=", "1", ")", ":", "#npts = int(np.ceil(32. / bins_per_dec(egy_bins)))", "egy_bins", "=", "np", ".", "exp", "(",...
Calculate the expected counts vs. true energy and incidence angle for a source with spectral parameterization ``fn``. Parameters ---------- skydir : `~astropy.coordinate.SkyCoord` ltc : `~fermipy.irfs.LTCube` egy_bins : `~numpy.ndarray` Bin edges in observed energy in MeV. cth_bi...
[ "Calculate", "the", "expected", "counts", "vs", ".", "true", "energy", "and", "incidence", "angle", "for", "a", "source", "with", "spectral", "parameterization", "fn", "." ]
python
train
ihgazni2/elist
elist/elist.py
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L516-L527
def array_map(ol,map_func,*args): ''' obseleted,just for compatible from elist.elist import * ol = [1,2,3,4] def map_func(ele,mul,plus): return(ele*mul+plus) array_map(ol,map_func,2,100) ''' rslt = list(map(lambda ele:map_func(ele,*args),ol)) return(r...
[ "def", "array_map", "(", "ol", ",", "map_func", ",", "*", "args", ")", ":", "rslt", "=", "list", "(", "map", "(", "lambda", "ele", ":", "map_func", "(", "ele", ",", "*", "args", ")", ",", "ol", ")", ")", "return", "(", "rslt", ")" ]
obseleted,just for compatible from elist.elist import * ol = [1,2,3,4] def map_func(ele,mul,plus): return(ele*mul+plus) array_map(ol,map_func,2,100)
[ "obseleted", "just", "for", "compatible", "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "2", "3", "4", "]", "def", "map_func", "(", "ele", "mul", "plus", ")", ":", "return", "(", "ele", "*", "mul", "+", "plus", ")" ]
python
valid
wmayner/pyphi
pyphi/macro.py
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/macro.py#L289-L301
def _coarsegrain_space(coarse_grain, is_cut, system): """Spatially coarse-grain the TPM and CM.""" tpm = coarse_grain.macro_tpm( system.tpm, check_independence=(not is_cut)) node_indices = coarse_grain.macro_indices state = coarse_grain.macro_state(system.state) # U...
[ "def", "_coarsegrain_space", "(", "coarse_grain", ",", "is_cut", ",", "system", ")", ":", "tpm", "=", "coarse_grain", ".", "macro_tpm", "(", "system", ".", "tpm", ",", "check_independence", "=", "(", "not", "is_cut", ")", ")", "node_indices", "=", "coarse_gr...
Spatially coarse-grain the TPM and CM.
[ "Spatially", "coarse", "-", "grain", "the", "TPM", "and", "CM", "." ]
python
train
xypnox/email_purifier
epurifier/email_checker.py
https://github.com/xypnox/email_purifier/blob/a9ecde9c5293b5c283e0c5b4cf8744c76418fb6f/epurifier/email_checker.py#L46-L52
def CorrectWrongEmails(self, askInput=True): '''Corrects Emails in wrong_emails''' for email in self.wrong_emails: corrected_email = self.CorrectEmail(email) self.emails[self.emails.index(email)] = corrected_email self.wrong_emails = []
[ "def", "CorrectWrongEmails", "(", "self", ",", "askInput", "=", "True", ")", ":", "for", "email", "in", "self", ".", "wrong_emails", ":", "corrected_email", "=", "self", ".", "CorrectEmail", "(", "email", ")", "self", ".", "emails", "[", "self", ".", "em...
Corrects Emails in wrong_emails
[ "Corrects", "Emails", "in", "wrong_emails" ]
python
train
tensorflow/tensor2tensor
tensor2tensor/layers/discretization.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/discretization.py#L1254-L1371
def gumbel_softmax_discrete_bottleneck(x, bottleneck_bits, beta=0.25, decay=0.999, epsilon=1e-5, temperature_warmup_steps=150...
[ "def", "gumbel_softmax_discrete_bottleneck", "(", "x", ",", "bottleneck_bits", ",", "beta", "=", "0.25", ",", "decay", "=", "0.999", ",", "epsilon", "=", "1e-5", ",", "temperature_warmup_steps", "=", "150000", ",", "hard", "=", "False", ",", "summary", "=", ...
VQ-VAE using Gumbel-Softmax. Different from `gumbel_softmax()` function as this function calculates the KL by using the discrete entropy instead of taking the argmax, and it also uses an exponential moving average to update the codebook while the `gumbel_softmax()` function includes no codebook update. Ar...
[ "VQ", "-", "VAE", "using", "Gumbel", "-", "Softmax", "." ]
python
train
ray-project/ray
python/ray/tune/automlboard/frontend/view.py
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/frontend/view.py#L134-L161
def get_trial_info(current_trial): """Get job information for current trial.""" if current_trial.end_time and ("_" in current_trial.end_time): # end time is parsed from result.json and the format # is like: yyyy-mm-dd_hh-MM-ss, which will be converted # to yyyy-mm-dd hh:MM:ss here ...
[ "def", "get_trial_info", "(", "current_trial", ")", ":", "if", "current_trial", ".", "end_time", "and", "(", "\"_\"", "in", "current_trial", ".", "end_time", ")", ":", "# end time is parsed from result.json and the format", "# is like: yyyy-mm-dd_hh-MM-ss, which will be conve...
Get job information for current trial.
[ "Get", "job", "information", "for", "current", "trial", "." ]
python
train
gwpy/gwpy
gwpy/signal/filter_design.py
https://github.com/gwpy/gwpy/blob/7a92b917e7dd2d99b15895293a1fa1d66cdb210a/gwpy/signal/filter_design.py#L569-L629
def notch(frequency, sample_rate, type='iir', **kwargs): """Design a ZPK notch filter for the given frequency and sampling rate Parameters ---------- frequency : `float`, `~astropy.units.Quantity` frequency (default in Hertz) at which to apply the notch sample_rate : `float`, `~astropy.unit...
[ "def", "notch", "(", "frequency", ",", "sample_rate", ",", "type", "=", "'iir'", ",", "*", "*", "kwargs", ")", ":", "frequency", "=", "Quantity", "(", "frequency", ",", "'Hz'", ")", ".", "value", "sample_rate", "=", "Quantity", "(", "sample_rate", ",", ...
Design a ZPK notch filter for the given frequency and sampling rate Parameters ---------- frequency : `float`, `~astropy.units.Quantity` frequency (default in Hertz) at which to apply the notch sample_rate : `float`, `~astropy.units.Quantity` number of samples per second for `TimeSeries...
[ "Design", "a", "ZPK", "notch", "filter", "for", "the", "given", "frequency", "and", "sampling", "rate" ]
python
train
ihgazni2/elist
elist/elist.py
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L6851-L6860
def get_wfsmat(l): ''' l = ['v_7', 'v_3', 'v_1', 'v_4', ['v_4', 'v_2'], 'v_5', 'v_6', 'v_1', 'v_6', 'v_7', 'v_5', ['v_4', ['v_1', 'v_8', 'v_3', 'v_4', 'v_2', 'v_7', [['v_3', 'v_2'], 'v_4', 'v_5', 'v_1', 'v_3', 'v_1', 'v_2', 'v_5', 'v_8', 'v_8', 'v_7'], 'v_5', 'v_8', 'v_7', 'v_1', 'v_5'], 'v_6'], 'v_4', 'v_5'...
[ "def", "get_wfsmat", "(", "l", ")", ":", "ltree", "=", "ListTree", "(", "l", ")", "vdescmat", "=", "ltree", ".", "desc", "wfsmat", "=", "matrix_map", "(", "vdescmat", ",", "lambda", "v", ",", "ix", ",", "iy", ":", "v", "[", "'path'", "]", ")", "w...
l = ['v_7', 'v_3', 'v_1', 'v_4', ['v_4', 'v_2'], 'v_5', 'v_6', 'v_1', 'v_6', 'v_7', 'v_5', ['v_4', ['v_1', 'v_8', 'v_3', 'v_4', 'v_2', 'v_7', [['v_3', 'v_2'], 'v_4', 'v_5', 'v_1', 'v_3', 'v_1', 'v_2', 'v_5', 'v_8', 'v_8', 'v_7'], 'v_5', 'v_8', 'v_7', 'v_1', 'v_5'], 'v_6'], 'v_4', 'v_5', 'v_8', 'v_5'] get_wfs(l)
[ "l", "=", "[", "v_7", "v_3", "v_1", "v_4", "[", "v_4", "v_2", "]", "v_5", "v_6", "v_1", "v_6", "v_7", "v_5", "[", "v_4", "[", "v_1", "v_8", "v_3", "v_4", "v_2", "v_7", "[[", "v_3", "v_2", "]", "v_4", "v_5", "v_1", "v_3", "v_1", "v_2", "v_5", ...
python
valid
floydhub/floyd-cli
floyd/cli/run.py
https://github.com/floydhub/floyd-cli/blob/ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c/floyd/cli/run.py#L227-L350
def run(ctx, cpu, gpu, env, message, data, mode, open_notebook, follow, tensorboard, gpu2, cpu2, max_runtime, task, command): """ Start a new job on FloydHub. Floyd will upload contents of the current directory and run your command. """ # cli_default is used for any option that has default valu...
[ "def", "run", "(", "ctx", ",", "cpu", ",", "gpu", ",", "env", ",", "message", ",", "data", ",", "mode", ",", "open_notebook", ",", "follow", ",", "tensorboard", ",", "gpu2", ",", "cpu2", ",", "max_runtime", ",", "task", ",", "command", ")", ":", "#...
Start a new job on FloydHub. Floyd will upload contents of the current directory and run your command.
[ "Start", "a", "new", "job", "on", "FloydHub", "." ]
python
train
saltstack/salt
salt/utils/aws.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/aws.py#L371-L540
def query(params=None, setname=None, requesturl=None, location=None, return_url=False, return_root=False, opts=None, provider=None, endpoint=None, product='ec2', sigver='2'): ''' Perform a query against AWS services using Signature Version 2 Signing Process. This is documented at: h...
[ "def", "query", "(", "params", "=", "None", ",", "setname", "=", "None", ",", "requesturl", "=", "None", ",", "location", "=", "None", ",", "return_url", "=", "False", ",", "return_root", "=", "False", ",", "opts", "=", "None", ",", "provider", "=", ...
Perform a query against AWS services using Signature Version 2 Signing Process. This is documented at: http://docs.aws.amazon.com/general/latest/gr/signature-version-2.html Regions and endpoints are documented at: http://docs.aws.amazon.com/general/latest/gr/rande.html Default ``product`` is ``e...
[ "Perform", "a", "query", "against", "AWS", "services", "using", "Signature", "Version", "2", "Signing", "Process", ".", "This", "is", "documented", "at", ":" ]
python
train
tkem/uritools
uritools/encoding.py
https://github.com/tkem/uritools/blob/e77ba4acd937b68da9850138563debd4c925ef9f/uritools/encoding.py#L40-L53
def uriencode(uristring, safe='', encoding='utf-8', errors='strict'): """Encode a URI string or string component.""" if not isinstance(uristring, bytes): uristring = uristring.encode(encoding, errors) if not isinstance(safe, bytes): safe = safe.encode('ascii') try: encoded = _enc...
[ "def", "uriencode", "(", "uristring", ",", "safe", "=", "''", ",", "encoding", "=", "'utf-8'", ",", "errors", "=", "'strict'", ")", ":", "if", "not", "isinstance", "(", "uristring", ",", "bytes", ")", ":", "uristring", "=", "uristring", ".", "encode", ...
Encode a URI string or string component.
[ "Encode", "a", "URI", "string", "or", "string", "component", "." ]
python
train
lepture/python-livereload
livereload/server.py
https://github.com/lepture/python-livereload/blob/f80cb3ae0f8f2cdf38203a712fe25ef7f1899c34/livereload/server.py#L181-L209
def watch(self, filepath, func=None, delay=None, ignore=None): """Add the given filepath for watcher list. Once you have intialized a server, watch file changes before serve the server:: server.watch('static/*.stylus', 'make static') def alert(): print('...
[ "def", "watch", "(", "self", ",", "filepath", ",", "func", "=", "None", ",", "delay", "=", "None", ",", "ignore", "=", "None", ")", ":", "if", "isinstance", "(", "func", ",", "string_types", ")", ":", "cmd", "=", "func", "func", "=", "shell", "(", ...
Add the given filepath for watcher list. Once you have intialized a server, watch file changes before serve the server:: server.watch('static/*.stylus', 'make static') def alert(): print('foo') server.watch('foo.txt', alert) server.serve(...
[ "Add", "the", "given", "filepath", "for", "watcher", "list", "." ]
python
train
gregreen/dustmaps
dustmaps/json_serializers.py
https://github.com/gregreen/dustmaps/blob/c8f571a71da0d951bf8ea865621bee14492bdfd9/dustmaps/json_serializers.py#L308-L380
def get_encoder(ndarray_mode='b64'): """ Returns a JSON encoder that can handle: * :obj:`numpy.ndarray` * :obj:`numpy.floating` (converted to :obj:`float`) * :obj:`numpy.integer` (converted to :obj:`int`) * :obj:`numpy.dtype` * :obj:`astropy.units.Quantity` * :obj...
[ "def", "get_encoder", "(", "ndarray_mode", "=", "'b64'", ")", ":", "# Use specified numpy.ndarray serialization mode", "serialize_fns", "=", "{", "'b64'", ":", "serialize_ndarray_b64", ",", "'readable'", ":", "serialize_ndarray_readable", ",", "'npy'", ":", "serialize_nda...
Returns a JSON encoder that can handle: * :obj:`numpy.ndarray` * :obj:`numpy.floating` (converted to :obj:`float`) * :obj:`numpy.integer` (converted to :obj:`int`) * :obj:`numpy.dtype` * :obj:`astropy.units.Quantity` * :obj:`astropy.coordinates.SkyCoord` Args: ...
[ "Returns", "a", "JSON", "encoder", "that", "can", "handle", ":", "*", ":", "obj", ":", "numpy", ".", "ndarray", "*", ":", "obj", ":", "numpy", ".", "floating", "(", "converted", "to", ":", "obj", ":", "float", ")", "*", ":", "obj", ":", "numpy", ...
python
train
quizl/quizler
quizler/utils.py
https://github.com/quizl/quizler/blob/44b3fd91f7074e7013ffde8147455f45ebdccc46/quizler/utils.py#L32-L44
def get_common_terms(*api_envs): """Get all term duplicates across all user word sets as a list of (title of first word set, title of second word set, set of terms) tuples.""" common_terms = [] # pylint: disable=no-value-for-parameter wordsets = get_user_sets(*api_envs) # pylint: enable=no-value...
[ "def", "get_common_terms", "(", "*", "api_envs", ")", ":", "common_terms", "=", "[", "]", "# pylint: disable=no-value-for-parameter", "wordsets", "=", "get_user_sets", "(", "*", "api_envs", ")", "# pylint: enable=no-value-for-parameter", "for", "wordset1", ",", "wordset...
Get all term duplicates across all user word sets as a list of (title of first word set, title of second word set, set of terms) tuples.
[ "Get", "all", "term", "duplicates", "across", "all", "user", "word", "sets", "as", "a", "list", "of", "(", "title", "of", "first", "word", "set", "title", "of", "second", "word", "set", "set", "of", "terms", ")", "tuples", "." ]
python
train
mental32/spotify.py
spotify/models/player.py
https://github.com/mental32/spotify.py/blob/bb296cac7c3dd289908906b7069bd80f43950515/spotify/models/player.py#L137-L146
async def next(self, *, device: Optional[SomeDevice] = None): """Skips to next track in the user’s queue. Parameters ---------- device : Optional[:obj:`SomeDevice`] The Device object or id of the device this command is targeting. If not supplied, the user’s curre...
[ "async", "def", "next", "(", "self", ",", "*", ",", "device", ":", "Optional", "[", "SomeDevice", "]", "=", "None", ")", ":", "await", "self", ".", "_user", ".", "http", ".", "skip_next", "(", "device_id", "=", "str", "(", "device", ")", ")" ]
Skips to next track in the user’s queue. Parameters ---------- device : Optional[:obj:`SomeDevice`] The Device object or id of the device this command is targeting. If not supplied, the user’s currently active device is the target.
[ "Skips", "to", "next", "track", "in", "the", "user’s", "queue", "." ]
python
test
theolind/pymysensors
mysensors/gateway_tcp.py
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/gateway_tcp.py#L127-L161
def _connect(self): """Connect to the socket.""" try: while True: _LOGGER.info('Trying to connect to %s', self.server_address) try: yield from asyncio.wait_for( self.loop.create_connection( ...
[ "def", "_connect", "(", "self", ")", ":", "try", ":", "while", "True", ":", "_LOGGER", ".", "info", "(", "'Trying to connect to %s'", ",", "self", ".", "server_address", ")", "try", ":", "yield", "from", "asyncio", ".", "wait_for", "(", "self", ".", "loo...
Connect to the socket.
[ "Connect", "to", "the", "socket", "." ]
python
train
NuGrid/NuGridPy
nugridpy/mesa.py
https://github.com/NuGrid/NuGridPy/blob/eee8047446e398be77362d82c1d8b3310054fab0/nugridpy/mesa.py#L3725-L3774
def _read_mesafile(filename,data_rows=0,only='all'): """ private routine that is not directly called by the user""" f=open(filename,'r') vv=[] v=[] lines = [] line = '' for i in range(0,6): line = f.readline() lines.extend([line]) hval = lines[2].split() hlist = li...
[ "def", "_read_mesafile", "(", "filename", ",", "data_rows", "=", "0", ",", "only", "=", "'all'", ")", ":", "f", "=", "open", "(", "filename", ",", "'r'", ")", "vv", "=", "[", "]", "v", "=", "[", "]", "lines", "=", "[", "]", "line", "=", "''", ...
private routine that is not directly called by the user
[ "private", "routine", "that", "is", "not", "directly", "called", "by", "the", "user" ]
python
train
widdowquinn/pyani
bin/genbank_get_genomes_by_taxon.py
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/bin/genbank_get_genomes_by_taxon.py#L263-L275
def extract_filestem(data): """Extract filestem from Entrez eSummary data. Function expects esummary['DocumentSummarySet']['DocumentSummary'][0] Some illegal characters may occur in AssemblyName - for these, a more robust regex replace/escape may be required. Sadly, NCBI don't just use standard pe...
[ "def", "extract_filestem", "(", "data", ")", ":", "escapes", "=", "re", ".", "compile", "(", "r\"[\\s/,#\\(\\)]\"", ")", "escname", "=", "re", ".", "sub", "(", "escapes", ",", "'_'", ",", "data", "[", "'AssemblyName'", "]", ")", "return", "'_'", ".", "...
Extract filestem from Entrez eSummary data. Function expects esummary['DocumentSummarySet']['DocumentSummary'][0] Some illegal characters may occur in AssemblyName - for these, a more robust regex replace/escape may be required. Sadly, NCBI don't just use standard percent escapes, but instead replace ...
[ "Extract", "filestem", "from", "Entrez", "eSummary", "data", "." ]
python
train
django-import-export/django-import-export
import_export/resources.py
https://github.com/django-import-export/django-import-export/blob/127f00d03fd0ad282615b064b7f444a639e6ff0c/import_export/resources.py#L297-L310
def save_instance(self, instance, using_transactions=True, dry_run=False): """ Takes care of saving the object to the database. Keep in mind that this is done by calling ``instance.save()``, so objects are not created in bulk! """ self.before_save_instance(instance, usin...
[ "def", "save_instance", "(", "self", ",", "instance", ",", "using_transactions", "=", "True", ",", "dry_run", "=", "False", ")", ":", "self", ".", "before_save_instance", "(", "instance", ",", "using_transactions", ",", "dry_run", ")", "if", "not", "using_tran...
Takes care of saving the object to the database. Keep in mind that this is done by calling ``instance.save()``, so objects are not created in bulk!
[ "Takes", "care", "of", "saving", "the", "object", "to", "the", "database", "." ]
python
train
Clinical-Genomics/scout
scout/commands/update/genes.py
https://github.com/Clinical-Genomics/scout/blob/90a551e2e1653a319e654c2405c2866f93d0ebb9/scout/commands/update/genes.py#L42-L106
def genes(context, build, api_key): """ Load the hgnc aliases to the mongo database. """ LOG.info("Running scout update genes") adapter = context.obj['adapter'] # Fetch the omim information api_key = api_key or context.obj.get('omim_api_key') if not api_key: LOG.warning("Please ...
[ "def", "genes", "(", "context", ",", "build", ",", "api_key", ")", ":", "LOG", ".", "info", "(", "\"Running scout update genes\"", ")", "adapter", "=", "context", ".", "obj", "[", "'adapter'", "]", "# Fetch the omim information", "api_key", "=", "api_key", "or...
Load the hgnc aliases to the mongo database.
[ "Load", "the", "hgnc", "aliases", "to", "the", "mongo", "database", "." ]
python
test
chriso/timeseries
timeseries/data_frame.py
https://github.com/chriso/timeseries/blob/8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d/timeseries/data_frame.py#L26-L30
def forecast(self, horizon, **kwargs): '''Forecast all time series in the group. See the `TimeSeries.forecast()` method for more information.''' return DataFrame({ name: series.forecast(horizon, **kwargs) \ for name, series in self.groups.iteritems() })
[ "def", "forecast", "(", "self", ",", "horizon", ",", "*", "*", "kwargs", ")", ":", "return", "DataFrame", "(", "{", "name", ":", "series", ".", "forecast", "(", "horizon", ",", "*", "*", "kwargs", ")", "for", "name", ",", "series", "in", "self", "....
Forecast all time series in the group. See the `TimeSeries.forecast()` method for more information.
[ "Forecast", "all", "time", "series", "in", "the", "group", ".", "See", "the", "TimeSeries", ".", "forecast", "()", "method", "for", "more", "information", "." ]
python
train
celery/django-celery
djcelery/loaders.py
https://github.com/celery/django-celery/blob/5d1ecb09c6304d22cc447c7c08fba0bd1febc2ef/djcelery/loaders.py#L57-L66
def read_configuration(self): """Load configuration from Django settings.""" self.configured = True # Default backend needs to be the database backend for backward # compatibility. backend = (getattr(settings, 'CELERY_RESULT_BACKEND', None) or getattr(settings,...
[ "def", "read_configuration", "(", "self", ")", ":", "self", ".", "configured", "=", "True", "# Default backend needs to be the database backend for backward", "# compatibility.", "backend", "=", "(", "getattr", "(", "settings", ",", "'CELERY_RESULT_BACKEND'", ",", "None",...
Load configuration from Django settings.
[ "Load", "configuration", "from", "Django", "settings", "." ]
python
train
matiskay/html-similarity
html_similarity/style_similarity.py
https://github.com/matiskay/html-similarity/blob/eef5586b1cf30134254690b2150260ef82cbd18f/html_similarity/style_similarity.py#L26-L41
def style_similarity(page1, page2): """ Computes CSS style Similarity between two DOM trees A = classes(Document_1) B = classes(Document_2) style_similarity = |A & B| / (|A| + |B| - |A & B|) :param page1: html of the page1 :param page2: html of the page2 :return: Number between 0 and ...
[ "def", "style_similarity", "(", "page1", ",", "page2", ")", ":", "classes_page1", "=", "get_classes", "(", "page1", ")", "classes_page2", "=", "get_classes", "(", "page2", ")", "return", "jaccard_similarity", "(", "classes_page1", ",", "classes_page2", ")" ]
Computes CSS style Similarity between two DOM trees A = classes(Document_1) B = classes(Document_2) style_similarity = |A & B| / (|A| + |B| - |A & B|) :param page1: html of the page1 :param page2: html of the page2 :return: Number between 0 and 1. If the number is next to 1 the page are reall...
[ "Computes", "CSS", "style", "Similarity", "between", "two", "DOM", "trees" ]
python
train
CZ-NIC/yangson
yangson/xpathparser.py
https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/xpathparser.py#L303-L323
def _qname(self) -> Optional[QualName]: """Parse XML QName.""" if self.test_string("*"): self.skip_ws() return False ident = self.yang_identifier() ws = self.skip_ws() try: next = self.peek() except EndOfInput: return ident,...
[ "def", "_qname", "(", "self", ")", "->", "Optional", "[", "QualName", "]", ":", "if", "self", ".", "test_string", "(", "\"*\"", ")", ":", "self", ".", "skip_ws", "(", ")", "return", "False", "ident", "=", "self", ".", "yang_identifier", "(", ")", "ws...
Parse XML QName.
[ "Parse", "XML", "QName", "." ]
python
train
annoviko/pyclustering
pyclustering/cluster/bang.py
https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/cluster/bang.py#L731-L749
def __calculate_volume(self): """! @brief Calculates volume of current spatial block. @details If empty dimension is detected (where all points has the same value) then such dimension is ignored during calculation of volume. @return (double) Volume of current spa...
[ "def", "__calculate_volume", "(", "self", ")", ":", "volume", "=", "0.0", "for", "i", "in", "range", "(", "0", ",", "len", "(", "self", ".", "__max_corner", ")", ")", ":", "side_length", "=", "self", ".", "__max_corner", "[", "i", "]", "-", "self", ...
! @brief Calculates volume of current spatial block. @details If empty dimension is detected (where all points has the same value) then such dimension is ignored during calculation of volume. @return (double) Volume of current spatial block.
[ "!" ]
python
valid
valency/deeputils
deeputils/common.py
https://github.com/valency/deeputils/blob/27efd91668de0223ed8b07cfadf2151632521520/deeputils/common.py#L65-L82
def dict_merge(a, b, k): """ Merge two dictionary lists :param a: original list :param b: alternative list, element will replace the one in original list with same key :param k: key :return: the merged list """ c = a.copy() for j in range(len(b)): flag = False for i i...
[ "def", "dict_merge", "(", "a", ",", "b", ",", "k", ")", ":", "c", "=", "a", ".", "copy", "(", ")", "for", "j", "in", "range", "(", "len", "(", "b", ")", ")", ":", "flag", "=", "False", "for", "i", "in", "range", "(", "len", "(", "c", ")",...
Merge two dictionary lists :param a: original list :param b: alternative list, element will replace the one in original list with same key :param k: key :return: the merged list
[ "Merge", "two", "dictionary", "lists", ":", "param", "a", ":", "original", "list", ":", "param", "b", ":", "alternative", "list", "element", "will", "replace", "the", "one", "in", "original", "list", "with", "same", "key", ":", "param", "k", ":", "key", ...
python
valid
StellarCN/py-stellar-base
stellar_base/operation.py
https://github.com/StellarCN/py-stellar-base/blob/cce2e782064fb3955c85e1696e630d67b1010848/stellar_base/operation.py#L681-L737
def from_xdr_object(cls, op_xdr_object): """Creates a :class:`SetOptions` object from an XDR Operation object. """ if not op_xdr_object.sourceAccount: source = None else: source = encode_check( 'account', op_xdr_object.sourceAccount[0].ed2...
[ "def", "from_xdr_object", "(", "cls", ",", "op_xdr_object", ")", ":", "if", "not", "op_xdr_object", ".", "sourceAccount", ":", "source", "=", "None", "else", ":", "source", "=", "encode_check", "(", "'account'", ",", "op_xdr_object", ".", "sourceAccount", "[",...
Creates a :class:`SetOptions` object from an XDR Operation object.
[ "Creates", "a", ":", "class", ":", "SetOptions", "object", "from", "an", "XDR", "Operation", "object", "." ]
python
train
arne-cl/discoursegraphs
src/discoursegraphs/readwrite/rst/rs3/rs3graph.py
https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/rst/rs3/rs3graph.py#L468-L549
def get_rst_spans(rst_graph): """ Returns a list of 5-tuples describing each RST span (i.e. the nucleus or satellite of a relation) in the document. (This function is meant for people who prefer to work with R / DataFrames / CSV files instead of graphs.) Parameters ---------- docgraph :...
[ "def", "get_rst_spans", "(", "rst_graph", ")", ":", "token_map", "=", "TokenMapper", "(", "rst_graph", ")", ".", "id2index", "rst_relations", "=", "get_rst_relations", "(", "rst_graph", ")", "all_spans", "=", "[", "]", "for", "dom_node", "in", "rst_relations", ...
Returns a list of 5-tuples describing each RST span (i.e. the nucleus or satellite of a relation) in the document. (This function is meant for people who prefer to work with R / DataFrames / CSV files instead of graphs.) Parameters ---------- docgraph : DiscourseDocumentGraph a document...
[ "Returns", "a", "list", "of", "5", "-", "tuples", "describing", "each", "RST", "span", "(", "i", ".", "e", ".", "the", "nucleus", "or", "satellite", "of", "a", "relation", ")", "in", "the", "document", ".", "(", "This", "function", "is", "meant", "fo...
python
train
tensorflow/tensor2tensor
tensor2tensor/utils/yellowfin.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/yellowfin.py#L460-L519
def apply_gradients(self, grads_and_vars, global_step=None, name=None): """Applying gradients and tune hyperparams with YellowFin. Args: grads_and_vars: List of (gradient, variable) pairs as returned by compute_gradients(). global_step: Optional Variable to increment by one after the ...
[ "def", "apply_gradients", "(", "self", ",", "grads_and_vars", ",", "global_step", "=", "None", ",", "name", "=", "None", ")", ":", "self", ".", "_grad", ",", "self", ".", "_vars", "=", "zip", "(", "*", "[", "(", "g", ",", "t", ")", "for", "g", ",...
Applying gradients and tune hyperparams with YellowFin. Args: grads_and_vars: List of (gradient, variable) pairs as returned by compute_gradients(). global_step: Optional Variable to increment by one after the variables have been updated. name: Optional name for the returned oper...
[ "Applying", "gradients", "and", "tune", "hyperparams", "with", "YellowFin", "." ]
python
train
tanghaibao/jcvi
jcvi/assembly/patch.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/assembly/patch.py#L174-L202
def pasteprepare(args): """ %prog pasteprepare bacs.fasta Prepare sequences for paste. """ p = OptionParser(pasteprepare.__doc__) p.add_option("--flank", default=5000, type="int", help="Get the seq of size on two ends [default: %default]") opts, args = p.parse_args(args) ...
[ "def", "pasteprepare", "(", "args", ")", ":", "p", "=", "OptionParser", "(", "pasteprepare", ".", "__doc__", ")", "p", ".", "add_option", "(", "\"--flank\"", ",", "default", "=", "5000", ",", "type", "=", "\"int\"", ",", "help", "=", "\"Get the seq of size...
%prog pasteprepare bacs.fasta Prepare sequences for paste.
[ "%prog", "pasteprepare", "bacs", ".", "fasta" ]
python
train
arne-cl/discoursegraphs
src/discoursegraphs/readwrite/rst/urml.py
https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/rst/urml.py#L366-L385
def extract_relationtypes(urml_xml_tree): """ extracts the allowed RST relation names and relation types from an URML XML file. Parameters ---------- urml_xml_tree : lxml.etree._ElementTree lxml ElementTree representation of an URML XML file Returns ------- relations : dict...
[ "def", "extract_relationtypes", "(", "urml_xml_tree", ")", ":", "return", "{", "rel", ".", "attrib", "[", "'name'", "]", ":", "rel", ".", "attrib", "[", "'type'", "]", "for", "rel", "in", "urml_xml_tree", ".", "iterfind", "(", "'//header/reltypes/rel'", ")",...
extracts the allowed RST relation names and relation types from an URML XML file. Parameters ---------- urml_xml_tree : lxml.etree._ElementTree lxml ElementTree representation of an URML XML file Returns ------- relations : dict of (str, str) Returns a dictionary with RST r...
[ "extracts", "the", "allowed", "RST", "relation", "names", "and", "relation", "types", "from", "an", "URML", "XML", "file", "." ]
python
train
aws/aws-encryption-sdk-python
src/aws_encryption_sdk/internal/formatting/serialize.py
https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/formatting/serialize.py#L184-L252
def serialize_frame( algorithm, plaintext, message_id, data_encryption_key, frame_length, sequence_number, is_final_frame, signer=None ): """Receives a message plaintext, breaks off a frame, encrypts and serializes the frame, and returns the encrypted frame and the remaining plaintext. :param algorithm...
[ "def", "serialize_frame", "(", "algorithm", ",", "plaintext", ",", "message_id", ",", "data_encryption_key", ",", "frame_length", ",", "sequence_number", ",", "is_final_frame", ",", "signer", "=", "None", ")", ":", "if", "sequence_number", "<", "1", ":", "raise"...
Receives a message plaintext, breaks off a frame, encrypts and serializes the frame, and returns the encrypted frame and the remaining plaintext. :param algorithm: Algorithm to use for encryption :type algorithm: aws_encryption_sdk.identifiers.Algorithm :param bytes plaintext: Source plaintext to encry...
[ "Receives", "a", "message", "plaintext", "breaks", "off", "a", "frame", "encrypts", "and", "serializes", "the", "frame", "and", "returns", "the", "encrypted", "frame", "and", "the", "remaining", "plaintext", "." ]
python
train
eandersson/amqpstorm
amqpstorm/channel.py
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/channel.py#L297-L318
def start_consuming(self, to_tuple=False, auto_decode=True): """Start consuming messages. :param bool to_tuple: Should incoming messages be converted to a tuple before delivery. :param bool auto_decode: Auto-decode strings when possible. :raises AMQPChanne...
[ "def", "start_consuming", "(", "self", ",", "to_tuple", "=", "False", ",", "auto_decode", "=", "True", ")", ":", "while", "not", "self", ".", "is_closed", ":", "self", ".", "process_data_events", "(", "to_tuple", "=", "to_tuple", ",", "auto_decode", "=", "...
Start consuming messages. :param bool to_tuple: Should incoming messages be converted to a tuple before delivery. :param bool auto_decode: Auto-decode strings when possible. :raises AMQPChannelError: Raises if the channel encountered an error. :raises AMQP...
[ "Start", "consuming", "messages", "." ]
python
train
wakatime/wakatime
wakatime/packages/urllib3/util/selectors.py
https://github.com/wakatime/wakatime/blob/74519ace04e8472f3a3993269963732b9946a01d/wakatime/packages/urllib3/util/selectors.py#L565-L581
def DefaultSelector(): """ This function serves as a first call for DefaultSelector to detect if the select module is being monkey-patched incorrectly by eventlet, greenlet, and preserve proper behavior. """ global _DEFAULT_SELECTOR if _DEFAULT_SELECTOR is None: if _can_allocate('kqueue'): ...
[ "def", "DefaultSelector", "(", ")", ":", "global", "_DEFAULT_SELECTOR", "if", "_DEFAULT_SELECTOR", "is", "None", ":", "if", "_can_allocate", "(", "'kqueue'", ")", ":", "_DEFAULT_SELECTOR", "=", "KqueueSelector", "elif", "_can_allocate", "(", "'epoll'", ")", ":", ...
This function serves as a first call for DefaultSelector to detect if the select module is being monkey-patched incorrectly by eventlet, greenlet, and preserve proper behavior.
[ "This", "function", "serves", "as", "a", "first", "call", "for", "DefaultSelector", "to", "detect", "if", "the", "select", "module", "is", "being", "monkey", "-", "patched", "incorrectly", "by", "eventlet", "greenlet", "and", "preserve", "proper", "behavior", ...
python
train
creare-com/pydem
pydem/dem_processing.py
https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L234-L244
def get(self, key, side): """ Returns an edge given a particular key Parmeters ---------- key : tuple (te, be, le, re) tuple that identifies a tile side : str top, bottom, left, or right, which edge to return """ return getattr(self...
[ "def", "get", "(", "self", ",", "key", ",", "side", ")", ":", "return", "getattr", "(", "self", ",", "side", ")", ".", "ravel", "(", ")", "[", "self", ".", "keys", "[", "key", "]", "]" ]
Returns an edge given a particular key Parmeters ---------- key : tuple (te, be, le, re) tuple that identifies a tile side : str top, bottom, left, or right, which edge to return
[ "Returns", "an", "edge", "given", "a", "particular", "key", "Parmeters", "----------", "key", ":", "tuple", "(", "te", "be", "le", "re", ")", "tuple", "that", "identifies", "a", "tile", "side", ":", "str", "top", "bottom", "left", "or", "right", "which",...
python
train
O365/python-o365
O365/drive.py
https://github.com/O365/python-o365/blob/02a71cf3775cc6a3c042e003365d6a07c8c75a73/O365/drive.py#L741-L761
def get_versions(self): """ Returns a list of available versions for this item :return: list of versions :rtype: list[DriveItemVersion] """ if not self.object_id: return [] url = self.build_url( self._endpoints.get('versions').format(id=self.obje...
[ "def", "get_versions", "(", "self", ")", ":", "if", "not", "self", ".", "object_id", ":", "return", "[", "]", "url", "=", "self", ".", "build_url", "(", "self", ".", "_endpoints", ".", "get", "(", "'versions'", ")", ".", "format", "(", "id", "=", "...
Returns a list of available versions for this item :return: list of versions :rtype: list[DriveItemVersion]
[ "Returns", "a", "list", "of", "available", "versions", "for", "this", "item" ]
python
train
mitsei/dlkit
dlkit/services/relationship.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/services/relationship.py#L935-L943
def use_isolated_family_view(self): """Pass through to provider RelationshipLookupSession.use_isolated_family_view""" self._family_view = ISOLATED # self._get_provider_session('relationship_lookup_session') # To make sure the session is tracked for session in self._get_provider_sessions(...
[ "def", "use_isolated_family_view", "(", "self", ")", ":", "self", ".", "_family_view", "=", "ISOLATED", "# self._get_provider_session('relationship_lookup_session') # To make sure the session is tracked", "for", "session", "in", "self", ".", "_get_provider_sessions", "(", ")", ...
Pass through to provider RelationshipLookupSession.use_isolated_family_view
[ "Pass", "through", "to", "provider", "RelationshipLookupSession", ".", "use_isolated_family_view" ]
python
train
joanvila/aioredlock
aioredlock/redis.py
https://github.com/joanvila/aioredlock/blob/6c62f0895c93b26b87ca8e3fe36bc024c81be421/aioredlock/redis.py#L71-L83
async def _create_redis_pool(*args, **kwargs): """ Adapter to support both aioredis-0.3.0 and aioredis-1.0.0 For aioredis-1.0.0 and later calls: aioredis.create_redis_pool(*args, **kwargs) For aioredis-0.3.0 calls: aioredis.create_pool(*args, **kwargs) """...
[ "async", "def", "_create_redis_pool", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "StrictVersion", "(", "aioredis", ".", "__version__", ")", ">=", "StrictVersion", "(", "'1.0.0'", ")", ":", "# pragma no cover", "return", "await", "aioredis", "...
Adapter to support both aioredis-0.3.0 and aioredis-1.0.0 For aioredis-1.0.0 and later calls: aioredis.create_redis_pool(*args, **kwargs) For aioredis-0.3.0 calls: aioredis.create_pool(*args, **kwargs)
[ "Adapter", "to", "support", "both", "aioredis", "-", "0", ".", "3", ".", "0", "and", "aioredis", "-", "1", ".", "0", ".", "0", "For", "aioredis", "-", "1", ".", "0", ".", "0", "and", "later", "calls", ":", "aioredis", ".", "create_redis_pool", "(",...
python
train
singularityhub/singularity-cli
spython/main/parse/docker.py
https://github.com/singularityhub/singularity-cli/blob/cb36b4504812ca87e29c6a40b222a545d1865799/spython/main/parse/docker.py#L299-L310
def _expose(self, line): '''Again, just add to metadata, and comment in install. Parameters ========== line: the line from the recipe file to parse to INSTALL ''' ports = self._setup('EXPOSE', line) if len(ports) > 0: self.ports += ports ...
[ "def", "_expose", "(", "self", ",", "line", ")", ":", "ports", "=", "self", ".", "_setup", "(", "'EXPOSE'", ",", "line", ")", "if", "len", "(", "ports", ")", ">", "0", ":", "self", ".", "ports", "+=", "ports", "return", "self", ".", "_comment", "...
Again, just add to metadata, and comment in install. Parameters ========== line: the line from the recipe file to parse to INSTALL
[ "Again", "just", "add", "to", "metadata", "and", "comment", "in", "install", ".", "Parameters", "==========", "line", ":", "the", "line", "from", "the", "recipe", "file", "to", "parse", "to", "INSTALL" ]
python
train
PlaidWeb/Publ
publ/caching.py
https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/caching.py#L20-L35
def do_not_cache(): """ Return whether we should cache a page render """ from . import index # pylint: disable=cyclic-import if index.in_progress(): # We are reindexing the site return True if request.if_none_match or request.if_modified_since: # we might be returning a 304 N...
[ "def", "do_not_cache", "(", ")", ":", "from", ".", "import", "index", "# pylint: disable=cyclic-import", "if", "index", ".", "in_progress", "(", ")", ":", "# We are reindexing the site", "return", "True", "if", "request", ".", "if_none_match", "or", "request", "."...
Return whether we should cache a page render
[ "Return", "whether", "we", "should", "cache", "a", "page", "render" ]
python
train
atlassian-api/atlassian-python-api
atlassian/jira.py
https://github.com/atlassian-api/atlassian-python-api/blob/540d269905c3e7547b666fe30c647b2d512cf358/atlassian/jira.py#L293-L306
def update_project(self, project_key, data, expand=None): """ Updates a project. Update project: /rest/api/2/project/{projectIdOrKey} :param project_key: project key of project that needs to be updated :param data: dictionary containing the data to be updated :param expa...
[ "def", "update_project", "(", "self", ",", "project_key", ",", "data", ",", "expand", "=", "None", ")", ":", "if", "expand", ":", "url", "=", "'/rest/api/2/project/{projectIdOrKey}?expand={expand}'", ".", "format", "(", "projectIdOrKey", "=", "project_key", ",", ...
Updates a project. Update project: /rest/api/2/project/{projectIdOrKey} :param project_key: project key of project that needs to be updated :param data: dictionary containing the data to be updated :param expand: the parameters to expand
[ "Updates", "a", "project", ".", "Update", "project", ":", "/", "rest", "/", "api", "/", "2", "/", "project", "/", "{", "projectIdOrKey", "}" ]
python
train
contains-io/containment
containment/builder.py
https://github.com/contains-io/containment/blob/4f7e2c2338e0ca7c107a7b3a9913bb5e6e07245f/containment/builder.py#L126-L134
def pave_community(self): """ Usage: containment pave_community """ settings.project_config.path.mkdir() settings.project_config.base.write_text(self.context.base_text) settings.project_config.os_packages.write_text("[]") settings.project_config.lang_pac...
[ "def", "pave_community", "(", "self", ")", ":", "settings", ".", "project_config", ".", "path", ".", "mkdir", "(", ")", "settings", ".", "project_config", ".", "base", ".", "write_text", "(", "self", ".", "context", ".", "base_text", ")", "settings", ".", ...
Usage: containment pave_community
[ "Usage", ":", "containment", "pave_community" ]
python
train
twisted/epsilon
epsilon/amprouter.py
https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/amprouter.py#L147-L168
def bindRoute(self, receiver, routeName=_unspecified): """ Create a new route to associate the given route name with the given receiver. @type routeName: C{unicode} or L{NoneType} @param routeName: The identifier for the newly created route. If C{None}, boxes with n...
[ "def", "bindRoute", "(", "self", ",", "receiver", ",", "routeName", "=", "_unspecified", ")", ":", "if", "routeName", "is", "_unspecified", ":", "routeName", "=", "self", ".", "createRouteIdentifier", "(", ")", "# self._sender may yet be None; if so, this route goes i...
Create a new route to associate the given route name with the given receiver. @type routeName: C{unicode} or L{NoneType} @param routeName: The identifier for the newly created route. If C{None}, boxes with no route in them will be delivered to this receiver. @r...
[ "Create", "a", "new", "route", "to", "associate", "the", "given", "route", "name", "with", "the", "given", "receiver", "." ]
python
train
fprimex/zdesk
zdesk/zdesk_api.py
https://github.com/fprimex/zdesk/blob/851611c13b4d530e9df31390b3ec709baf0a0188/zdesk/zdesk_api.py#L3400-L3404
def ticket_comments(self, ticket_id, **kwargs): "https://developer.zendesk.com/rest_api/docs/core/ticket_comments#list-comments" api_path = "/api/v2/tickets/{ticket_id}/comments.json" api_path = api_path.format(ticket_id=ticket_id) return self.call(api_path, **kwargs)
[ "def", "ticket_comments", "(", "self", ",", "ticket_id", ",", "*", "*", "kwargs", ")", ":", "api_path", "=", "\"/api/v2/tickets/{ticket_id}/comments.json\"", "api_path", "=", "api_path", ".", "format", "(", "ticket_id", "=", "ticket_id", ")", "return", "self", "...
https://developer.zendesk.com/rest_api/docs/core/ticket_comments#list-comments
[ "https", ":", "//", "developer", ".", "zendesk", ".", "com", "/", "rest_api", "/", "docs", "/", "core", "/", "ticket_comments#list", "-", "comments" ]
python
train
StanfordVL/robosuite
robosuite/devices/keyboard.py
https://github.com/StanfordVL/robosuite/blob/65cd16810e2ed647e3ec88746af3412065b7f278/robosuite/devices/keyboard.py#L65-L74
def get_controller_state(self): """Returns the current state of the keyboard, a dictionary of pos, orn, grasp, and reset.""" dpos = self.pos - self.last_pos self.last_pos = np.array(self.pos) return dict( dpos=dpos, rotation=self.rotation, grasp=int(se...
[ "def", "get_controller_state", "(", "self", ")", ":", "dpos", "=", "self", ".", "pos", "-", "self", ".", "last_pos", "self", ".", "last_pos", "=", "np", ".", "array", "(", "self", ".", "pos", ")", "return", "dict", "(", "dpos", "=", "dpos", ",", "r...
Returns the current state of the keyboard, a dictionary of pos, orn, grasp, and reset.
[ "Returns", "the", "current", "state", "of", "the", "keyboard", "a", "dictionary", "of", "pos", "orn", "grasp", "and", "reset", "." ]
python
train
saltstack/salt
salt/fileserver/__init__.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileserver/__init__.py#L570-L579
def file_find(self, load): ''' Convenience function for calls made using the LocalClient ''' path = load.get('path') if not path: return {'path': '', 'rel': ''} tgt_env = load.get('saltenv', 'base') return self.find_file(path, tgt_e...
[ "def", "file_find", "(", "self", ",", "load", ")", ":", "path", "=", "load", ".", "get", "(", "'path'", ")", "if", "not", "path", ":", "return", "{", "'path'", ":", "''", ",", "'rel'", ":", "''", "}", "tgt_env", "=", "load", ".", "get", "(", "'...
Convenience function for calls made using the LocalClient
[ "Convenience", "function", "for", "calls", "made", "using", "the", "LocalClient" ]
python
train
ChrisCummins/labm8
fs.py
https://github.com/ChrisCummins/labm8/blob/dd10d67a757aefb180cb508f86696f99440c94f5/fs.py#L411-L419
def mkdir(*components, **kwargs): """ Make directory "path", including any required parents. If directory already exists, do nothing. """ _path = path(*components) if not isdir(_path): os.makedirs(_path, **kwargs) return _path
[ "def", "mkdir", "(", "*", "components", ",", "*", "*", "kwargs", ")", ":", "_path", "=", "path", "(", "*", "components", ")", "if", "not", "isdir", "(", "_path", ")", ":", "os", ".", "makedirs", "(", "_path", ",", "*", "*", "kwargs", ")", "return...
Make directory "path", including any required parents. If directory already exists, do nothing.
[ "Make", "directory", "path", "including", "any", "required", "parents", ".", "If", "directory", "already", "exists", "do", "nothing", "." ]
python
train
numenta/nupic
src/nupic/support/console_printer.py
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/support/console_printer.py#L52-L90
def cPrint(self, level, message, *args, **kw): """Print a message to the console. Prints only if level <= self.consolePrinterVerbosity Printing with level 0 is equivalent to using a print statement, and should normally be avoided. :param level: (int) indicating the urgency of the message with ...
[ "def", "cPrint", "(", "self", ",", "level", ",", "message", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "if", "level", ">", "self", ".", "consolePrinterVerbosity", ":", "return", "if", "len", "(", "kw", ")", ">", "1", ":", "raise", "KeyError",...
Print a message to the console. Prints only if level <= self.consolePrinterVerbosity Printing with level 0 is equivalent to using a print statement, and should normally be avoided. :param level: (int) indicating the urgency of the message with lower values meaning more urgent (messages at l...
[ "Print", "a", "message", "to", "the", "console", "." ]
python
valid
abw333/dominoes
dominoes/game.py
https://github.com/abw333/dominoes/blob/ea9f532c9b834117a5c07d214711515872f7537e/dominoes/game.py#L16-L28
def _validate_player(player): ''' Checks that a player is a valid player. Valid players are: 0, 1, 2, and 3. :param int player: player to be validated :return: None :raises NoSuchPlayerException: if the player is invalid ''' valid_players = range(4) if player not in valid_players: ...
[ "def", "_validate_player", "(", "player", ")", ":", "valid_players", "=", "range", "(", "4", ")", "if", "player", "not", "in", "valid_players", ":", "valid_players", "=", "', '", ".", "join", "(", "str", "(", "p", ")", "for", "p", "in", "valid_players", ...
Checks that a player is a valid player. Valid players are: 0, 1, 2, and 3. :param int player: player to be validated :return: None :raises NoSuchPlayerException: if the player is invalid
[ "Checks", "that", "a", "player", "is", "a", "valid", "player", ".", "Valid", "players", "are", ":", "0", "1", "2", "and", "3", "." ]
python
train
AkihikoITOH/capybara
capybara/virtualenv/lib/python2.7/site-packages/setuptools/command/build_py.py
https://github.com/AkihikoITOH/capybara/blob/e86c2173ea386654f4ae061148e8fbe3f25e715c/capybara/virtualenv/lib/python2.7/site-packages/setuptools/command/build_py.py#L70-L89
def _get_data_files(self): """Generate list of '(package,src_dir,build_dir,filenames)' tuples""" self.analyze_manifest() data = [] for package in self.packages or (): # Locate package source directory src_dir = self.get_package_dir(package) # Compute ...
[ "def", "_get_data_files", "(", "self", ")", ":", "self", ".", "analyze_manifest", "(", ")", "data", "=", "[", "]", "for", "package", "in", "self", ".", "packages", "or", "(", ")", ":", "# Locate package source directory", "src_dir", "=", "self", ".", "get_...
Generate list of '(package,src_dir,build_dir,filenames)' tuples
[ "Generate", "list", "of", "(", "package", "src_dir", "build_dir", "filenames", ")", "tuples" ]
python
test
openstack/horizon
openstack_dashboard/dashboards/project/instances/utils.py
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/dashboards/project/instances/utils.py#L171-L191
def flavor_field_data(request, include_empty_option=False): """Returns a list of tuples of all image flavors. Generates a list of image flavors available. And returns a list of (id, name) tuples. :param request: django http request object :param include_empty_option: flag to include a empty tuple ...
[ "def", "flavor_field_data", "(", "request", ",", "include_empty_option", "=", "False", ")", ":", "flavors", "=", "flavor_list", "(", "request", ")", "if", "flavors", ":", "flavors_list", "=", "sort_flavor_list", "(", "request", ",", "flavors", ")", "if", "incl...
Returns a list of tuples of all image flavors. Generates a list of image flavors available. And returns a list of (id, name) tuples. :param request: django http request object :param include_empty_option: flag to include a empty tuple in the front of the list :return: list of (id, name) tu...
[ "Returns", "a", "list", "of", "tuples", "of", "all", "image", "flavors", "." ]
python
train
openstack/networking-cisco
networking_cisco/apps/saf/server/dfa_server.py
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/dfa_server.py#L1690-L1701
def sync_projects(self): """Sync projects. This function will retrieve project from keystone and populate them dfa database and dcnm """ p = self.keystone_event._service.projects.list() for proj in p: if proj.name in not_create_project_name: ...
[ "def", "sync_projects", "(", "self", ")", ":", "p", "=", "self", ".", "keystone_event", ".", "_service", ".", "projects", ".", "list", "(", ")", "for", "proj", "in", "p", ":", "if", "proj", ".", "name", "in", "not_create_project_name", ":", "continue", ...
Sync projects. This function will retrieve project from keystone and populate them dfa database and dcnm
[ "Sync", "projects", "." ]
python
train
lago-project/lago
lago/providers/libvirt/vm.py
https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/providers/libvirt/vm.py#L409-L446
def extract_paths_dead(self, paths, ignore_nopath): """ Extract the given paths from the domain using guestfs. Using guestfs can have side-effects and should be used as a second option, mainly when SSH is not available. Args: paths(list of str): paths to extract ...
[ "def", "extract_paths_dead", "(", "self", ",", "paths", ",", "ignore_nopath", ")", ":", "if", "not", "self", ".", "_has_guestfs", ":", "raise", "LagoException", "(", "(", "'guestfs module not available, cannot '", ")", "(", "'extract files with libguestfs'", ")", ")...
Extract the given paths from the domain using guestfs. Using guestfs can have side-effects and should be used as a second option, mainly when SSH is not available. Args: paths(list of str): paths to extract ignore_nopath(boolean): if True will ignore none existing paths....
[ "Extract", "the", "given", "paths", "from", "the", "domain", "using", "guestfs", ".", "Using", "guestfs", "can", "have", "side", "-", "effects", "and", "should", "be", "used", "as", "a", "second", "option", "mainly", "when", "SSH", "is", "not", "available"...
python
train
bcbio/bcbio-nextgen
bcbio/structural/__init__.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/__init__.py#L87-L126
def finalize_sv(samples, config): """Combine results from multiple sv callers into a single ordered 'sv' key. """ by_bam = collections.OrderedDict() for x in samples: batch = dd.get_batch(x) or [dd.get_sample_name(x)] try: by_bam[x["align_bam"], tuple(batch)].append(x) ...
[ "def", "finalize_sv", "(", "samples", ",", "config", ")", ":", "by_bam", "=", "collections", ".", "OrderedDict", "(", ")", "for", "x", "in", "samples", ":", "batch", "=", "dd", ".", "get_batch", "(", "x", ")", "or", "[", "dd", ".", "get_sample_name", ...
Combine results from multiple sv callers into a single ordered 'sv' key.
[ "Combine", "results", "from", "multiple", "sv", "callers", "into", "a", "single", "ordered", "sv", "key", "." ]
python
train
python-openxml/python-docx
docx/dml/color.py
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/dml/color.py#L63-L80
def theme_color(self): """ A member of :ref:`MsoThemeColorIndex` or |None| if no theme color is specified. When :attr:`type` is `MSO_COLOR_TYPE.THEME`, the value of this property will always be a member of :ref:`MsoThemeColorIndex`. When :attr:`type` has any other value, the valu...
[ "def", "theme_color", "(", "self", ")", ":", "color", "=", "self", ".", "_color", "if", "color", "is", "None", "or", "color", ".", "themeColor", "is", "None", ":", "return", "None", "return", "color", ".", "themeColor" ]
A member of :ref:`MsoThemeColorIndex` or |None| if no theme color is specified. When :attr:`type` is `MSO_COLOR_TYPE.THEME`, the value of this property will always be a member of :ref:`MsoThemeColorIndex`. When :attr:`type` has any other value, the value of this property is |None|. ...
[ "A", "member", "of", ":", "ref", ":", "MsoThemeColorIndex", "or", "|None|", "if", "no", "theme", "color", "is", "specified", ".", "When", ":", "attr", ":", "type", "is", "MSO_COLOR_TYPE", ".", "THEME", "the", "value", "of", "this", "property", "will", "a...
python
train
DataONEorg/d1_python
gmn/src/d1_gmn/app/management/commands/async_client.py
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/management/commands/async_client.py#L285-L290
def _datetime_to_iso8601(self, query_dict): """Encode any datetime query parameters to ISO8601.""" return { k: v if not isinstance(v, datetime.datetime) else v.isoformat() for k, v in list(query_dict.items()) }
[ "def", "_datetime_to_iso8601", "(", "self", ",", "query_dict", ")", ":", "return", "{", "k", ":", "v", "if", "not", "isinstance", "(", "v", ",", "datetime", ".", "datetime", ")", "else", "v", ".", "isoformat", "(", ")", "for", "k", ",", "v", "in", ...
Encode any datetime query parameters to ISO8601.
[ "Encode", "any", "datetime", "query", "parameters", "to", "ISO8601", "." ]
python
train
apple/turicreate
src/unity/python/turicreate/toolkits/_supervised_learning.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/_supervised_learning.py#L261-L334
def create(dataset, target, model_name, features=None, validation_set='auto', distributed='auto', verbose=True, seed=None, **kwargs): """ Create a :class:`~turicreate.toolkits.SupervisedLearningModel`, This is generic function that allows you to create any model that implements Su...
[ "def", "create", "(", "dataset", ",", "target", ",", "model_name", ",", "features", "=", "None", ",", "validation_set", "=", "'auto'", ",", "distributed", "=", "'auto'", ",", "verbose", "=", "True", ",", "seed", "=", "None", ",", "*", "*", "kwargs", ")...
Create a :class:`~turicreate.toolkits.SupervisedLearningModel`, This is generic function that allows you to create any model that implements SupervisedLearningModel This function is normally not called, call specific model's create function instead Parameters ---------- dataset : SFrame ...
[ "Create", "a", ":", "class", ":", "~turicreate", ".", "toolkits", ".", "SupervisedLearningModel" ]
python
train
materialsproject/pymatgen
pymatgen/io/abinit/abitimer.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/abitimer.py#L233-L247
def get_sections(self, section_name): """ Return the list of sections stored in self.timers() given `section_name` A fake section is returned if the timer does not have section_name. """ sections = [] for timer in self.timers(): for sect in timer.sections: ...
[ "def", "get_sections", "(", "self", ",", "section_name", ")", ":", "sections", "=", "[", "]", "for", "timer", "in", "self", ".", "timers", "(", ")", ":", "for", "sect", "in", "timer", ".", "sections", ":", "if", "sect", ".", "name", "==", "section_na...
Return the list of sections stored in self.timers() given `section_name` A fake section is returned if the timer does not have section_name.
[ "Return", "the", "list", "of", "sections", "stored", "in", "self", ".", "timers", "()", "given", "section_name", "A", "fake", "section", "is", "returned", "if", "the", "timer", "does", "not", "have", "section_name", "." ]
python
train
mozilla/socorrolib
socorrolib/lib/transform_rules.py
https://github.com/mozilla/socorrolib/blob/4ec08c6a4ee2c8a69150268afdd324f5f22b90c8/socorrolib/lib/transform_rules.py#L57-L73
def predicate(self, *args, **kwargs): """the default predicate for Support Classifiers invokes any derivied _predicate function, trapping any exceptions raised in the process. We are obligated to catch these exceptions to give subsequent rules the opportunity to act. An error during th...
[ "def", "predicate", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "self", ".", "_predicate", "(", "*", "args", ",", "*", "*", "kwargs", ")", "except", "Exception", ",", "x", ":", "self", ".", "config", "....
the default predicate for Support Classifiers invokes any derivied _predicate function, trapping any exceptions raised in the process. We are obligated to catch these exceptions to give subsequent rules the opportunity to act. An error during the predicate application is a failure of t...
[ "the", "default", "predicate", "for", "Support", "Classifiers", "invokes", "any", "derivied", "_predicate", "function", "trapping", "any", "exceptions", "raised", "in", "the", "process", ".", "We", "are", "obligated", "to", "catch", "these", "exceptions", "to", ...
python
train