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
iotile/coretools
iotilecore/iotile/core/hw/virtual/base_runnable.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/virtual/base_runnable.py#L16-L45
def create_worker(self, func, interval, *args, **kwargs): """Spawn a worker thread running func. The worker will be automatically be started when start() is called and terminated when stop() is called on this object. This must be called only from the main thread, not from a worker threa...
[ "def", "create_worker", "(", "self", ",", "func", ",", "interval", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "thread", "=", "StoppableWorkerThread", "(", "func", ",", "interval", ",", "args", ",", "kwargs", ")", "self", ".", "_workers", ".",...
Spawn a worker thread running func. The worker will be automatically be started when start() is called and terminated when stop() is called on this object. This must be called only from the main thread, not from a worker thread. create_worker must not be called after stop() has been ca...
[ "Spawn", "a", "worker", "thread", "running", "func", "." ]
python
train
spyder-ide/spyder
spyder/preferences/languageserver.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/languageserver.py#L512-L516
def selection(self, index): """Update selected row.""" self.update() self.isActiveWindow() self._parent.delete_btn.setEnabled(True)
[ "def", "selection", "(", "self", ",", "index", ")", ":", "self", ".", "update", "(", ")", "self", ".", "isActiveWindow", "(", ")", "self", ".", "_parent", ".", "delete_btn", ".", "setEnabled", "(", "True", ")" ]
Update selected row.
[ "Update", "selected", "row", "." ]
python
train
linkedin/Zopkio
zopkio/deployer.py
https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/deployer.py#L164-L172
def sleep(self, unique_id, delay, configs=None): """ Pauses the process for the specified delay and then resumes it :Parameter unique_id: the name of the process :Parameter delay: delay time in seconds """ self.pause(unique_id, configs) time.sleep(delay) self.resume(unique_id, configs)
[ "def", "sleep", "(", "self", ",", "unique_id", ",", "delay", ",", "configs", "=", "None", ")", ":", "self", ".", "pause", "(", "unique_id", ",", "configs", ")", "time", ".", "sleep", "(", "delay", ")", "self", ".", "resume", "(", "unique_id", ",", ...
Pauses the process for the specified delay and then resumes it :Parameter unique_id: the name of the process :Parameter delay: delay time in seconds
[ "Pauses", "the", "process", "for", "the", "specified", "delay", "and", "then", "resumes", "it" ]
python
train
ubccr/pinky
pinky/perception/figueras.py
https://github.com/ubccr/pinky/blob/e9d6e8ff72aa7f670b591e3bd3629cb879db1a93/pinky/perception/figueras.py#L300-L365
def checkEdges(ringSet, lookup, oatoms): """atoms, lookup -> ring atoms must be in the order of traversal around a ring! break an optimal non N2 node and return the largest ring found """ bondedAtoms = map( None, ringSet[:-1], ringSet[1:] ) bondedAtoms += [ (ringSet[-1], ringSet[0]) ] #...
[ "def", "checkEdges", "(", "ringSet", ",", "lookup", ",", "oatoms", ")", ":", "bondedAtoms", "=", "map", "(", "None", ",", "ringSet", "[", ":", "-", "1", "]", ",", "ringSet", "[", "1", ":", "]", ")", "bondedAtoms", "+=", "[", "(", "ringSet", "[", ...
atoms, lookup -> ring atoms must be in the order of traversal around a ring! break an optimal non N2 node and return the largest ring found
[ "atoms", "lookup", "-", ">", "ring", "atoms", "must", "be", "in", "the", "order", "of", "traversal", "around", "a", "ring!", "break", "an", "optimal", "non", "N2", "node", "and", "return", "the", "largest", "ring", "found" ]
python
train
gbiggs/rtctree
rtctree/component.py
https://github.com/gbiggs/rtctree/blob/bd725a47ac87c259c8bce06156ccc9ab71111c26/rtctree/component.py#L678-L697
def reset_in_ec(self, ec_index): '''Reset this component in an execution context. @param ec_index The index of the execution context to reset in. This index is into the total array of contexts, that is both owned and participating contexts. If the value o...
[ "def", "reset_in_ec", "(", "self", ",", "ec_index", ")", ":", "with", "self", ".", "_mutex", ":", "if", "ec_index", ">=", "len", "(", "self", ".", "owned_ecs", ")", ":", "ec_index", "-=", "len", "(", "self", ".", "owned_ecs", ")", "if", "ec_index", "...
Reset this component in an execution context. @param ec_index The index of the execution context to reset in. This index is into the total array of contexts, that is both owned and participating contexts. If the value of ec_index is greate...
[ "Reset", "this", "component", "in", "an", "execution", "context", "." ]
python
train
cltk/cltk
cltk/prosody/latin/scanner.py
https://github.com/cltk/cltk/blob/ed9c025b7ec43c949481173251b70e05e4dffd27/cltk/prosody/latin/scanner.py#L82-L100
def _qu_fix(self, sents_syllables): """ Ensure that 'qu' is not treated as its own syllable. :param sents_syllables: Sentence of words of syllables. :return: syllabified syllables with 'qu' counted as a single consonant :rtype : list """ for sentence in sents_syl...
[ "def", "_qu_fix", "(", "self", ",", "sents_syllables", ")", ":", "for", "sentence", "in", "sents_syllables", ":", "for", "word", "in", "sentence", ":", "for", "syllable", "in", "word", ":", "if", "'qu'", "in", "syllable", ":", "qu_syll_index", "=", "word",...
Ensure that 'qu' is not treated as its own syllable. :param sents_syllables: Sentence of words of syllables. :return: syllabified syllables with 'qu' counted as a single consonant :rtype : list
[ "Ensure", "that", "qu", "is", "not", "treated", "as", "its", "own", "syllable", ".", ":", "param", "sents_syllables", ":", "Sentence", "of", "words", "of", "syllables", ".", ":", "return", ":", "syllabified", "syllables", "with", "qu", "counted", "as", "a"...
python
train
dpgaspar/Flask-AppBuilder
flask_appbuilder/base.py
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/base.py#L295-L312
def _add_addon_views(self): """ Registers declared addon's """ for addon in self._addon_managers: addon_class = dynamic_class_import(addon) if addon_class: # Instantiate manager with appbuilder (self) addon_class = addon_class(s...
[ "def", "_add_addon_views", "(", "self", ")", ":", "for", "addon", "in", "self", ".", "_addon_managers", ":", "addon_class", "=", "dynamic_class_import", "(", "addon", ")", "if", "addon_class", ":", "# Instantiate manager with appbuilder (self)", "addon_class", "=", ...
Registers declared addon's
[ "Registers", "declared", "addon", "s" ]
python
train
fake-name/ChromeController
ChromeController/Generator/Generated.py
https://github.com/fake-name/ChromeController/blob/914dd136184e8f1165c7aa6ef30418aaf10c61f0/ChromeController/Generator/Generated.py#L3495-L3524
def DOM_getSearchResults(self, searchId, fromIndex, toIndex): """ Function path: DOM.getSearchResults Domain: DOM Method name: getSearchResults WARNING: This function is marked 'Experimental'! Parameters: Required arguments: 'searchId' (type: string) -> Unique search session identifier. ...
[ "def", "DOM_getSearchResults", "(", "self", ",", "searchId", ",", "fromIndex", ",", "toIndex", ")", ":", "assert", "isinstance", "(", "searchId", ",", "(", "str", ",", ")", ")", ",", "\"Argument 'searchId' must be of type '['str']'. Received type: '%s'\"", "%", "typ...
Function path: DOM.getSearchResults Domain: DOM Method name: getSearchResults WARNING: This function is marked 'Experimental'! Parameters: Required arguments: 'searchId' (type: string) -> Unique search session identifier. 'fromIndex' (type: integer) -> Start index of the search result to...
[ "Function", "path", ":", "DOM", ".", "getSearchResults", "Domain", ":", "DOM", "Method", "name", ":", "getSearchResults", "WARNING", ":", "This", "function", "is", "marked", "Experimental", "!", "Parameters", ":", "Required", "arguments", ":", "searchId", "(", ...
python
train
lra/mackup
mackup/config.py
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/config.py#L196-L221
def _parse_path(self): """ Parse the storage path in the config. Returns: str """ if self.engine == ENGINE_DROPBOX: path = get_dropbox_folder_location() elif self.engine == ENGINE_GDRIVE: path = get_google_drive_folder_location() ...
[ "def", "_parse_path", "(", "self", ")", ":", "if", "self", ".", "engine", "==", "ENGINE_DROPBOX", ":", "path", "=", "get_dropbox_folder_location", "(", ")", "elif", "self", ".", "engine", "==", "ENGINE_GDRIVE", ":", "path", "=", "get_google_drive_folder_location...
Parse the storage path in the config. Returns: str
[ "Parse", "the", "storage", "path", "in", "the", "config", "." ]
python
train
aganezov/bg
bg/breakpoint_graph.py
https://github.com/aganezov/bg/blob/1ec758193441e49e7b34e0da09571480f4c24455/bg/breakpoint_graph.py#L453-L503
def __split_bgedge(self, bgedge, guidance=None, sorted_guidance=False, account_for_colors_multiplicity_in_guidance=True, key=None): """ Splits a :class:`bg.edge.BGEdge` in current :class:`BreakpointGraph` most similar to supplied one (if no unique identifier ``key`` is provided) with resp...
[ "def", "__split_bgedge", "(", "self", ",", "bgedge", ",", "guidance", "=", "None", ",", "sorted_guidance", "=", "False", ",", "account_for_colors_multiplicity_in_guidance", "=", "True", ",", "key", "=", "None", ")", ":", "candidate_id", "=", "None", "candidate_s...
Splits a :class:`bg.edge.BGEdge` in current :class:`BreakpointGraph` most similar to supplied one (if no unique identifier ``key`` is provided) with respect to supplied guidance. If no unique identifier for edge to be changed is specified, edge to be split is determined by iterating over all edges between vert...
[ "Splits", "a", ":", "class", ":", "bg", ".", "edge", ".", "BGEdge", "in", "current", ":", "class", ":", "BreakpointGraph", "most", "similar", "to", "supplied", "one", "(", "if", "no", "unique", "identifier", "key", "is", "provided", ")", "with", "respect...
python
train
andreikop/qutepart
qutepart/bookmarks.py
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/bookmarks.py#L46-L52
def clear(self, startBlock, endBlock): """Clear bookmarks on block range including start and end """ for block in qutepart.iterateBlocksFrom(startBlock): self._setBlockMarked(block, False) if block == endBlock: break
[ "def", "clear", "(", "self", ",", "startBlock", ",", "endBlock", ")", ":", "for", "block", "in", "qutepart", ".", "iterateBlocksFrom", "(", "startBlock", ")", ":", "self", ".", "_setBlockMarked", "(", "block", ",", "False", ")", "if", "block", "==", "end...
Clear bookmarks on block range including start and end
[ "Clear", "bookmarks", "on", "block", "range", "including", "start", "and", "end" ]
python
train
dedupeio/dedupe
dedupe/clustering.py
https://github.com/dedupeio/dedupe/blob/9f7c9f84473a4bcacf0f2b11152d8ed3eb35d48b/dedupe/clustering.py#L177-L196
def confidences(cluster, condensed_distances, d): ''' We calculate a per record score that is similar to a standard deviation. The main reason is that these record scores can be used to calculate the standard deviation of an entire cluster, which is a reasonable metric for clusters. ''' sc...
[ "def", "confidences", "(", "cluster", ",", "condensed_distances", ",", "d", ")", ":", "scores", "=", "dict", ".", "fromkeys", "(", "cluster", ",", "0.0", ")", "squared_distances", "=", "condensed_distances", "**", "2", "for", "i", ",", "j", "in", "itertool...
We calculate a per record score that is similar to a standard deviation. The main reason is that these record scores can be used to calculate the standard deviation of an entire cluster, which is a reasonable metric for clusters.
[ "We", "calculate", "a", "per", "record", "score", "that", "is", "similar", "to", "a", "standard", "deviation", ".", "The", "main", "reason", "is", "that", "these", "record", "scores", "can", "be", "used", "to", "calculate", "the", "standard", "deviation", ...
python
train
h2oai/h2o-3
h2o-py/h2o/utils/typechecks.py
https://github.com/h2oai/h2o-3/blob/dd62aaa1e7f680a8b16ee14bc66b0fb5195c2ad8/h2o-py/h2o/utils/typechecks.py#L461-L473
def assert_matches(v, regex): """ Assert that string variable matches the provided regular expression. :param v: variable to check. :param regex: regular expression to check against (can be either a string, or compiled regexp). """ m = re.match(regex, v) if m is None: vn = _retrieve...
[ "def", "assert_matches", "(", "v", ",", "regex", ")", ":", "m", "=", "re", ".", "match", "(", "regex", ",", "v", ")", "if", "m", "is", "None", ":", "vn", "=", "_retrieve_assert_arguments", "(", ")", "[", "0", "]", "message", "=", "\"Argument `{var}` ...
Assert that string variable matches the provided regular expression. :param v: variable to check. :param regex: regular expression to check against (can be either a string, or compiled regexp).
[ "Assert", "that", "string", "variable", "matches", "the", "provided", "regular", "expression", "." ]
python
test
polyaxon/polyaxon
polyaxon/pipelines/utils.py
https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/pipelines/utils.py#L28-L46
def create_pipeline_run(pipeline, context_by_op): """Create a pipeline run/instance.""" pipeline_run = PipelineRun.objects.create(pipeline=pipeline) dag, ops = pipeline.dag # Go trough the operation and create operation runs and the upstreams op_runs = {} runs_by_ops = {} for op_id in dag.ke...
[ "def", "create_pipeline_run", "(", "pipeline", ",", "context_by_op", ")", ":", "pipeline_run", "=", "PipelineRun", ".", "objects", ".", "create", "(", "pipeline", "=", "pipeline", ")", "dag", ",", "ops", "=", "pipeline", ".", "dag", "# Go trough the operation an...
Create a pipeline run/instance.
[ "Create", "a", "pipeline", "run", "/", "instance", "." ]
python
train
hatemile/hatemile-for-python
hatemile/implementation/css.py
https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/implementation/css.py#L445-L463
def _is_valid_inherit_element(self, element): """ Check that the children of element can be manipulated to apply the CSS properties. :param element: The element. :type element: hatemile.util.html.htmldomelement.HTMLDOMElement :return: True if the children of element can ...
[ "def", "_is_valid_inherit_element", "(", "self", ",", "element", ")", ":", "# pylint: disable=no-self-use", "tag_name", "=", "element", ".", "get_tag_name", "(", ")", "return", "(", "(", "tag_name", "in", "AccessibleCSSImplementation", ".", "VALID_INHERIT_TAGS", ")", ...
Check that the children of element can be manipulated to apply the CSS properties. :param element: The element. :type element: hatemile.util.html.htmldomelement.HTMLDOMElement :return: True if the children of element can be manipulated to apply the CSS properties or Fal...
[ "Check", "that", "the", "children", "of", "element", "can", "be", "manipulated", "to", "apply", "the", "CSS", "properties", "." ]
python
train
Jajcus/pyxmpp2
pyxmpp2/ext/vcard.py
https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/ext/vcard.py#L547-L555
def rfc2426(self): """RFC2426-encode the field content. :return: the field in the RFC 2426 format. :returntype: `str`""" return rfc2425encode("adr",u';'.join(quote_semicolon(val) for val in (self.pobox,self.extadr,self.street,self.locality, self.r...
[ "def", "rfc2426", "(", "self", ")", ":", "return", "rfc2425encode", "(", "\"adr\"", ",", "u';'", ".", "join", "(", "quote_semicolon", "(", "val", ")", "for", "val", "in", "(", "self", ".", "pobox", ",", "self", ".", "extadr", ",", "self", ".", "stree...
RFC2426-encode the field content. :return: the field in the RFC 2426 format. :returntype: `str`
[ "RFC2426", "-", "encode", "the", "field", "content", "." ]
python
valid
openstack/networking-cisco
networking_cisco/apps/saf/server/dfa_events_handler.py
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/dfa_events_handler.py#L125-L150
def callback(self, timestamp, event_type, payload): """Callback method for processing events in notification queue. :param timestamp: time the message is received. :param event_type: event type in the notification queue such as identity.project.created, identity.proje...
[ "def", "callback", "(", "self", ",", "timestamp", ",", "event_type", ",", "payload", ")", ":", "try", ":", "data", "=", "(", "event_type", ",", "payload", ")", "LOG", ".", "debug", "(", "'RX NOTIFICATION ==>\\nevent_type: %(event)s, '", "'payload: %(payload)s\\n'"...
Callback method for processing events in notification queue. :param timestamp: time the message is received. :param event_type: event type in the notification queue such as identity.project.created, identity.project.deleted. :param payload: Contains information of an ...
[ "Callback", "method", "for", "processing", "events", "in", "notification", "queue", "." ]
python
train
Xion/taipan
taipan/objective/classes.py
https://github.com/Xion/taipan/blob/f333f0287c8bd0915182c7d5308e5f05ef0cca78/taipan/objective/classes.py#L57-L71
def ensure_direct_subclass(class_, of): """Check whether given class is a direct subclass of another. :param class_: Class to check :param of: Superclass to check against :return: ``class_``, if the check succeeds :raise TypeError: When the check fails .. versionadded:: 0.0.4 """ if n...
[ "def", "ensure_direct_subclass", "(", "class_", ",", "of", ")", ":", "if", "not", "is_direct_subclass", "(", "class_", ",", "of", ")", ":", "raise", "TypeError", "(", "\"expected a direct subclass of %r, got %s instead\"", "%", "(", "of", ",", "class_", ".", "__...
Check whether given class is a direct subclass of another. :param class_: Class to check :param of: Superclass to check against :return: ``class_``, if the check succeeds :raise TypeError: When the check fails .. versionadded:: 0.0.4
[ "Check", "whether", "given", "class", "is", "a", "direct", "subclass", "of", "another", "." ]
python
train
DallasMorningNews/django-datafreezer
datafreezer/views.py
https://github.com/DallasMorningNews/django-datafreezer/blob/982dcf2015c80a280f1a093e32977cb71d4ea7aa/datafreezer/views.py#L1049-L1052
def generate_page_title(self, data_slug): """Generates remainder of page title specific to data_slug (tag).""" tag = Tag.objects.filter(slug=data_slug) return tag[0].word
[ "def", "generate_page_title", "(", "self", ",", "data_slug", ")", ":", "tag", "=", "Tag", ".", "objects", ".", "filter", "(", "slug", "=", "data_slug", ")", "return", "tag", "[", "0", "]", ".", "word" ]
Generates remainder of page title specific to data_slug (tag).
[ "Generates", "remainder", "of", "page", "title", "specific", "to", "data_slug", "(", "tag", ")", "." ]
python
train
riptano/ccm
ccmlib/node.py
https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/node.py#L241-L249
def get_install_dir(self): """ Returns the path to the cassandra source directory used by this node. """ if self.__install_dir is None: return self.cluster.get_install_dir() else: common.validate_install_dir(self.__install_dir) return self.__in...
[ "def", "get_install_dir", "(", "self", ")", ":", "if", "self", ".", "__install_dir", "is", "None", ":", "return", "self", ".", "cluster", ".", "get_install_dir", "(", ")", "else", ":", "common", ".", "validate_install_dir", "(", "self", ".", "__install_dir",...
Returns the path to the cassandra source directory used by this node.
[ "Returns", "the", "path", "to", "the", "cassandra", "source", "directory", "used", "by", "this", "node", "." ]
python
train
twilio/twilio-python
twilio/rest/serverless/v1/service/environment/variable.py
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/serverless/v1/service/environment/variable.py#L258-L279
def fetch(self): """ Fetch a VariableInstance :returns: Fetched VariableInstance :rtype: twilio.rest.serverless.v1.service.environment.variable.VariableInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, ...
[ "def", "fetch", "(", "self", ")", ":", "params", "=", "values", ".", "of", "(", "{", "}", ")", "payload", "=", "self", ".", "_version", ".", "fetch", "(", "'GET'", ",", "self", ".", "_uri", ",", "params", "=", "params", ",", ")", "return", "Varia...
Fetch a VariableInstance :returns: Fetched VariableInstance :rtype: twilio.rest.serverless.v1.service.environment.variable.VariableInstance
[ "Fetch", "a", "VariableInstance" ]
python
train
dwavesystems/dwave-cloud-client
dwave/cloud/solver.py
https://github.com/dwavesystems/dwave-cloud-client/blob/df3221a8385dc0c04d7b4d84f740bf3ad6706230/dwave/cloud/solver.py#L308-L346
def sample_qubo(self, qubo, **params): """Sample from the specified QUBO. Args: qubo (dict of (int, int):float): Coefficients of a quadratic unconstrained binary optimization (QUBO) model. **params: Parameters for the sampling method, specified per solver. ...
[ "def", "sample_qubo", "(", "self", ",", "qubo", ",", "*", "*", "params", ")", ":", "# In a QUBO the linear and quadratic terms in the objective are mixed into", "# a matrix. For the sake of encoding, we will separate them before calling `_sample`", "linear", "=", "{", "i1", ":", ...
Sample from the specified QUBO. Args: qubo (dict of (int, int):float): Coefficients of a quadratic unconstrained binary optimization (QUBO) model. **params: Parameters for the sampling method, specified per solver. Returns: :obj:`Future` Exa...
[ "Sample", "from", "the", "specified", "QUBO", "." ]
python
train
swift-nav/libsbp
python/sbp/client/drivers/cdc_driver.py
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/client/drivers/cdc_driver.py#L50-L65
def write(self, s): """ Write wrapper. Parameters ---------- s : bytes Bytes to write """ try: return self.handle.write(s) except OSError: print() print("Piksi disconnected") print() ra...
[ "def", "write", "(", "self", ",", "s", ")", ":", "try", ":", "return", "self", ".", "handle", ".", "write", "(", "s", ")", "except", "OSError", ":", "print", "(", ")", "print", "(", "\"Piksi disconnected\"", ")", "print", "(", ")", "raise", "IOError"...
Write wrapper. Parameters ---------- s : bytes Bytes to write
[ "Write", "wrapper", "." ]
python
train
ekmmetering/ekmmeters
ekmmeters.py
https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L964-L982
def initPort(self): """ Required initialization call, wraps pyserial constructor. """ try: self.m_ser = serial.Serial(port=self.m_ttyport, baudrate=self.m_baudrate, timeout=0, ...
[ "def", "initPort", "(", "self", ")", ":", "try", ":", "self", ".", "m_ser", "=", "serial", ".", "Serial", "(", "port", "=", "self", ".", "m_ttyport", ",", "baudrate", "=", "self", ".", "m_baudrate", ",", "timeout", "=", "0", ",", "parity", "=", "se...
Required initialization call, wraps pyserial constructor.
[ "Required", "initialization", "call", "wraps", "pyserial", "constructor", "." ]
python
test
vatlab/SoS
src/sos/eval.py
https://github.com/vatlab/SoS/blob/6b60ed0770916d135e17322e469520d778e9d4e7/src/sos/eval.py#L127-L168
def SoS_exec(script: str, _dict: dict = None, return_result: bool = True) -> None: '''Execute a statement.''' if _dict is None: _dict = env.sos_dict.dict() if not return_result: exec( compile(script, filename=stmtHash.hash(script), mode='exec'), _dict) retur...
[ "def", "SoS_exec", "(", "script", ":", "str", ",", "_dict", ":", "dict", "=", "None", ",", "return_result", ":", "bool", "=", "True", ")", "->", "None", ":", "if", "_dict", "is", "None", ":", "_dict", "=", "env", ".", "sos_dict", ".", "dict", "(", ...
Execute a statement.
[ "Execute", "a", "statement", "." ]
python
train
decryptus/sonicprobe
sonicprobe/libs/urisup.py
https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/libs/urisup.py#L386-L400
def unsplit_query(query): """ Create a query string using the tuple query with a format as the one returned by split_query() """ def unsplit_assignment((x, y)): if (x is not None) and (y is not None): return x + '=' + y elif x is not None: return x eli...
[ "def", "unsplit_query", "(", "query", ")", ":", "def", "unsplit_assignment", "(", "(", "x", ",", "y", ")", ")", ":", "if", "(", "x", "is", "not", "None", ")", "and", "(", "y", "is", "not", "None", ")", ":", "return", "x", "+", "'='", "+", "y", ...
Create a query string using the tuple query with a format as the one returned by split_query()
[ "Create", "a", "query", "string", "using", "the", "tuple", "query", "with", "a", "format", "as", "the", "one", "returned", "by", "split_query", "()" ]
python
train
src-d/modelforge
modelforge/registry.py
https://github.com/src-d/modelforge/blob/4f73c2bf0318261ac01bc8b6c0d4250a5d303418/modelforge/registry.py#L111-L134
def delete_model(args: argparse.Namespace, backend: StorageBackend, log: logging.Logger): """ Delete a model. :param args: :class:`argparse.Namespace` with "input", "backend", "args", "meta", \ "update_default", "username", "password", "remote_repo", \ "templ...
[ "def", "delete_model", "(", "args", ":", "argparse", ".", "Namespace", ",", "backend", ":", "StorageBackend", ",", "log", ":", "logging", ".", "Logger", ")", ":", "try", ":", "meta", "=", "backend", ".", "index", ".", "remove_model", "(", "args", ".", ...
Delete a model. :param args: :class:`argparse.Namespace` with "input", "backend", "args", "meta", \ "update_default", "username", "password", "remote_repo", \ "template_model", "template_readme" and "log_level". :param backend: Backend which is responsible for wo...
[ "Delete", "a", "model", "." ]
python
train
django-extensions/django-extensions
django_extensions/management/commands/export_emails.py
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/export_emails.py#L117-L138
def vcard(self, qs): """VCARD format.""" try: import vobject except ImportError: print(self.style.ERROR("Please install vobject to use the vcard export format.")) sys.exit(1) out = sys.stdout for ent in qs: card = vobject.vCard() ...
[ "def", "vcard", "(", "self", ",", "qs", ")", ":", "try", ":", "import", "vobject", "except", "ImportError", ":", "print", "(", "self", ".", "style", ".", "ERROR", "(", "\"Please install vobject to use the vcard export format.\"", ")", ")", "sys", ".", "exit", ...
VCARD format.
[ "VCARD", "format", "." ]
python
train
Shizmob/pydle
pydle/features/rfc1459/client.py
https://github.com/Shizmob/pydle/blob/7ec7d65d097318ed0bcdc5d8401470287d8c7cf7/pydle/features/rfc1459/client.py#L802-L813
async def on_raw_312(self, message): """ WHOIS server info. """ target, nickname, server, serverinfo = message.params info = { 'server': server, 'server_info': serverinfo } if nickname in self._pending['whois']: self._whois_info[nickname].upda...
[ "async", "def", "on_raw_312", "(", "self", ",", "message", ")", ":", "target", ",", "nickname", ",", "server", ",", "serverinfo", "=", "message", ".", "params", "info", "=", "{", "'server'", ":", "server", ",", "'server_info'", ":", "serverinfo", "}", "i...
WHOIS server info.
[ "WHOIS", "server", "info", "." ]
python
train
coala/coala-decorators-USE-cOALA-UTILS-INSTEAD
coala_decorators/__init__.py
https://github.com/coala/coala-decorators-USE-cOALA-UTILS-INSTEAD/blob/b1c4463f364bbcd0ad5138f697a52f11c9afe326/coala_decorators/__init__.py#L6-L29
def yield_once(iterator): """ Decorator to make an iterator returned by a method yield each result only once. >>> @yield_once ... def generate_list(foo): ... return foo >>> list(generate_list([1, 2, 1])) [1, 2] :param iterator: Any method that returns an iterator :return: ...
[ "def", "yield_once", "(", "iterator", ")", ":", "@", "wraps", "(", "iterator", ")", "def", "yield_once_generator", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "yielded", "=", "set", "(", ")", "for", "item", "in", "iterator", "(", "*", "args"...
Decorator to make an iterator returned by a method yield each result only once. >>> @yield_once ... def generate_list(foo): ... return foo >>> list(generate_list([1, 2, 1])) [1, 2] :param iterator: Any method that returns an iterator :return: An method returning an iterator...
[ "Decorator", "to", "make", "an", "iterator", "returned", "by", "a", "method", "yield", "each", "result", "only", "once", "." ]
python
train
open-homeautomation/miflora
demo.py
https://github.com/open-homeautomation/miflora/blob/916606e7edc70bdc017dfbe681bc81771e0df7f3/demo.py#L47-L57
def _get_backend(args): """Extract the backend class from the command line arguments.""" if args.backend == 'gatttool': backend = GatttoolBackend elif args.backend == 'bluepy': backend = BluepyBackend elif args.backend == 'pygatt': backend = PygattBackend else: raise ...
[ "def", "_get_backend", "(", "args", ")", ":", "if", "args", ".", "backend", "==", "'gatttool'", ":", "backend", "=", "GatttoolBackend", "elif", "args", ".", "backend", "==", "'bluepy'", ":", "backend", "=", "BluepyBackend", "elif", "args", ".", "backend", ...
Extract the backend class from the command line arguments.
[ "Extract", "the", "backend", "class", "from", "the", "command", "line", "arguments", "." ]
python
train
codelv/enaml-native-cli
enamlnativecli/main.py
https://github.com/codelv/enaml-native-cli/blob/81d6faa7e3dd437956f661c512031e49c0d44b63/enamlnativecli/main.py#L1466-L1502
def run_tornado(self, args): """ Tornado dev server implementation """ server = self import tornado.ioloop import tornado.web import tornado.websocket ioloop = tornado.ioloop.IOLoop.current() class DevWebSocketHandler(tornado.websocket.WebSocketHandler): ...
[ "def", "run_tornado", "(", "self", ",", "args", ")", ":", "server", "=", "self", "import", "tornado", ".", "ioloop", "import", "tornado", ".", "web", "import", "tornado", ".", "websocket", "ioloop", "=", "tornado", ".", "ioloop", ".", "IOLoop", ".", "cur...
Tornado dev server implementation
[ "Tornado", "dev", "server", "implementation" ]
python
train
dmsimard/python-cachetclient
cachetclient/cachet.py
https://github.com/dmsimard/python-cachetclient/blob/31bbc6d17ba5de088846e1ffae259b6755e672a0/cachetclient/cachet.py#L37-L47
def check_required_args(required_args, args): """ Checks if all required_args have a value. :param required_args: list of required args :param args: kwargs :return: True (if an exception isn't raised) """ for arg in required_args: if arg not in args: raise KeyError('Requi...
[ "def", "check_required_args", "(", "required_args", ",", "args", ")", ":", "for", "arg", "in", "required_args", ":", "if", "arg", "not", "in", "args", ":", "raise", "KeyError", "(", "'Required argument: %s'", "%", "arg", ")", "return", "True" ]
Checks if all required_args have a value. :param required_args: list of required args :param args: kwargs :return: True (if an exception isn't raised)
[ "Checks", "if", "all", "required_args", "have", "a", "value", ".", ":", "param", "required_args", ":", "list", "of", "required", "args", ":", "param", "args", ":", "kwargs", ":", "return", ":", "True", "(", "if", "an", "exception", "isn", "t", "raised", ...
python
train
pymupdf/PyMuPDF
fitz/fitz.py
https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/fitz.py#L2591-L2602
def addInkAnnot(self, list): """Add a 'handwriting' as a list of list of point-likes. Each sublist forms an independent stroke.""" CheckParent(self) val = _fitz.Page_addInkAnnot(self, list) if not val: return val.thisown = True val.parent = weakref.proxy(self) s...
[ "def", "addInkAnnot", "(", "self", ",", "list", ")", ":", "CheckParent", "(", "self", ")", "val", "=", "_fitz", ".", "Page_addInkAnnot", "(", "self", ",", "list", ")", "if", "not", "val", ":", "return", "val", ".", "thisown", "=", "True", "val", ".",...
Add a 'handwriting' as a list of list of point-likes. Each sublist forms an independent stroke.
[ "Add", "a", "handwriting", "as", "a", "list", "of", "list", "of", "point", "-", "likes", ".", "Each", "sublist", "forms", "an", "independent", "stroke", "." ]
python
train
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/breakpoint.py
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/breakpoint.py#L3076-L3085
def get_process_page_breakpoints(self, dwProcessId): """ @type dwProcessId: int @param dwProcessId: Process global ID. @rtype: list of L{PageBreakpoint} @return: All page breakpoints for the given process. """ return [ bp for ((pid, address), bp) in compat.iter...
[ "def", "get_process_page_breakpoints", "(", "self", ",", "dwProcessId", ")", ":", "return", "[", "bp", "for", "(", "(", "pid", ",", "address", ")", ",", "bp", ")", "in", "compat", ".", "iteritems", "(", "self", ".", "__pageBP", ")", "if", "pid", "==", ...
@type dwProcessId: int @param dwProcessId: Process global ID. @rtype: list of L{PageBreakpoint} @return: All page breakpoints for the given process.
[ "@type", "dwProcessId", ":", "int", "@param", "dwProcessId", ":", "Process", "global", "ID", "." ]
python
train
bspaans/python-mingus
mingus/extra/tablature.py
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/tablature.py#L399-L422
def from_Suite(suite, maxwidth=80): """Convert a mingus.containers.Suite to an ASCII tablature string, complete with headers. This function makes use of the Suite's title, subtitle, author, email and description attributes. """ subtitle = str(len(suite.compositions)) + ' Compositions' if suite....
[ "def", "from_Suite", "(", "suite", ",", "maxwidth", "=", "80", ")", ":", "subtitle", "=", "str", "(", "len", "(", "suite", ".", "compositions", ")", ")", "+", "' Compositions'", "if", "suite", ".", "subtitle", "==", "''", "else", "suite", ".", "subtitl...
Convert a mingus.containers.Suite to an ASCII tablature string, complete with headers. This function makes use of the Suite's title, subtitle, author, email and description attributes.
[ "Convert", "a", "mingus", ".", "containers", ".", "Suite", "to", "an", "ASCII", "tablature", "string", "complete", "with", "headers", "." ]
python
train
materialsproject/pymatgen
pymatgen/analysis/surface_analysis.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/surface_analysis.py#L1749-L1800
def plot_one_stability_map(self, analyzer, max_r, delu_dict=None, label="", increments=50, delu_default=0, plt=None, from_sphere_area=False, e_units="keV", r_units="nanometers", normalize=False, s...
[ "def", "plot_one_stability_map", "(", "self", ",", "analyzer", ",", "max_r", ",", "delu_dict", "=", "None", ",", "label", "=", "\"\"", ",", "increments", "=", "50", ",", "delu_default", "=", "0", ",", "plt", "=", "None", ",", "from_sphere_area", "=", "Fa...
Returns the plot of the formation energy of a particle against its effect radius Args: analyzer (SurfaceEnergyPlotter): Analyzer associated with the first polymorph max_r (float): The maximum radius of the particle to plot up to. delu_dict (Dict):...
[ "Returns", "the", "plot", "of", "the", "formation", "energy", "of", "a", "particle", "against", "its", "effect", "radius" ]
python
train
openstack/networking-arista
networking_arista/common/db_lib.py
https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/common/db_lib.py#L230-L238
def get_segments(segment_id=None): """Returns list of all network segments that may be relevant on CVX""" session = db.get_reader_session() with session.begin(): model = segment_models.NetworkSegment segments = session.query(model).filter_unnecessary_segments() if segment_id: ...
[ "def", "get_segments", "(", "segment_id", "=", "None", ")", ":", "session", "=", "db", ".", "get_reader_session", "(", ")", "with", "session", ".", "begin", "(", ")", ":", "model", "=", "segment_models", ".", "NetworkSegment", "segments", "=", "session", "...
Returns list of all network segments that may be relevant on CVX
[ "Returns", "list", "of", "all", "network", "segments", "that", "may", "be", "relevant", "on", "CVX" ]
python
train
googledatalab/pydatalab
solutionbox/image_classification/mltoolbox/image/classification/_local.py
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_local.py#L70-L79
def predict(model_dir, image_files, resize, show_image): """Predict using an model in a local or GCS directory.""" from . import _predictor images = _util.load_images(image_files, resize=resize) labels_and_scores = _predictor.predict(model_dir, images) results = zip(image_files, images, labels_and...
[ "def", "predict", "(", "model_dir", ",", "image_files", ",", "resize", ",", "show_image", ")", ":", "from", ".", "import", "_predictor", "images", "=", "_util", ".", "load_images", "(", "image_files", ",", "resize", "=", "resize", ")", "labels_and_scores", "...
Predict using an model in a local or GCS directory.
[ "Predict", "using", "an", "model", "in", "a", "local", "or", "GCS", "directory", "." ]
python
train
yeraydiazdiaz/lunr.py
lunr/match_data.py
https://github.com/yeraydiazdiaz/lunr.py/blob/28ec3f6d4888295eed730211ee9617aa488d6ba3/lunr/match_data.py#L25-L51
def combine(self, other): """An instance of lunr.MatchData will be created for every term that matches a document. However only one instance is required in a lunr.Index~Result. This method combines metadata from another instance of MatchData with this object's metadata. ...
[ "def", "combine", "(", "self", ",", "other", ")", ":", "for", "term", "in", "other", ".", "metadata", ".", "keys", "(", ")", ":", "if", "term", "not", "in", "self", ".", "metadata", ":", "self", ".", "metadata", "[", "term", "]", "=", "{", "}", ...
An instance of lunr.MatchData will be created for every term that matches a document. However only one instance is required in a lunr.Index~Result. This method combines metadata from another instance of MatchData with this object's metadata.
[ "An", "instance", "of", "lunr", ".", "MatchData", "will", "be", "created", "for", "every", "term", "that", "matches", "a", "document", "." ]
python
train
fermiPy/fermipy
fermipy/jobs/slac_impl.py
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/slac_impl.py#L242-L262
def get_slac_default_args(job_time=1500): """ Create a batch job interface object. Parameters ---------- job_time : int Expected max length of the job, in seconds. This is used to select the batch queue and set the job_check_sleep parameter that sets how often we check ...
[ "def", "get_slac_default_args", "(", "job_time", "=", "1500", ")", ":", "slac_default_args", "=", "dict", "(", "lsf_args", "=", "{", "'W'", ":", "job_time", ",", "'R'", ":", "'\\\"select[rhel60&&!fell]\\\"'", "}", ",", "max_jobs", "=", "500", ",", "time_per_cy...
Create a batch job interface object. Parameters ---------- job_time : int Expected max length of the job, in seconds. This is used to select the batch queue and set the job_check_sleep parameter that sets how often we check for job completion.
[ "Create", "a", "batch", "job", "interface", "object", "." ]
python
train
ulf1/oxyba
oxyba/jackknife_stats.py
https://github.com/ulf1/oxyba/blob/b3043116050de275124365cb11e7df91fb40169d/oxyba/jackknife_stats.py#L1-L105
def jackknife_stats(theta_subs, theta_full, N=None, d=1): """Compute Jackknife Estimates, SE, Bias, t-scores, p-values Parameters: ----------- theta_subs : ndarray The metrics, estimates, parameters, etc. of the model (see "func") for each subsample. It is a <C x M> matrix, i.e....
[ "def", "jackknife_stats", "(", "theta_subs", ",", "theta_full", ",", "N", "=", "None", ",", "d", "=", "1", ")", ":", "# The biased Jackknife Estimate", "import", "numpy", "as", "np", "theta_biased", "=", "np", ".", "mean", "(", "theta_subs", ",", "axis", "...
Compute Jackknife Estimates, SE, Bias, t-scores, p-values Parameters: ----------- theta_subs : ndarray The metrics, estimates, parameters, etc. of the model (see "func") for each subsample. It is a <C x M> matrix, i.e. C=binocoeff(N,d) subsamples, and M parameters that are r...
[ "Compute", "Jackknife", "Estimates", "SE", "Bias", "t", "-", "scores", "p", "-", "values" ]
python
train
vanheeringen-lab/gimmemotifs
gimmemotifs/scanner.py
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/scanner.py#L378-L428
def set_background(self, fname=None, genome=None, length=200, nseq=10000): """Set the background to use for FPR and z-score calculations. Background can be specified either as a genome name or as the name of a FASTA file. Parameters ---------- fname : str, opti...
[ "def", "set_background", "(", "self", ",", "fname", "=", "None", ",", "genome", "=", "None", ",", "length", "=", "200", ",", "nseq", "=", "10000", ")", ":", "length", "=", "int", "(", "length", ")", "if", "genome", "and", "fname", ":", "raise", "Va...
Set the background to use for FPR and z-score calculations. Background can be specified either as a genome name or as the name of a FASTA file. Parameters ---------- fname : str, optional Name of FASTA file to use as background. genome : str, optio...
[ "Set", "the", "background", "to", "use", "for", "FPR", "and", "z", "-", "score", "calculations", "." ]
python
train
apache/incubator-superset
superset/models/helpers.py
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/models/helpers.py#L99-L184
def import_from_dict(cls, session, dict_rep, parent=None, recursive=True, sync=[]): """Import obj from a dictionary""" parent_refs = cls._parent_foreign_key_mappings() export_fields = set(cls.export_fields) | set(parent_refs.keys()) new_children = {c: dict_rep.ge...
[ "def", "import_from_dict", "(", "cls", ",", "session", ",", "dict_rep", ",", "parent", "=", "None", ",", "recursive", "=", "True", ",", "sync", "=", "[", "]", ")", ":", "parent_refs", "=", "cls", ".", "_parent_foreign_key_mappings", "(", ")", "export_field...
Import obj from a dictionary
[ "Import", "obj", "from", "a", "dictionary" ]
python
train
ponty/confduino
confduino/libinstall.py
https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/libinstall.py#L130-L143
def move_examples(root, lib_dir): """find examples not under lib dir, and move into ``examples``""" all_pde = files_multi_pattern(root, INO_PATTERNS) lib_pde = files_multi_pattern(lib_dir, INO_PATTERNS) stray_pde = all_pde.difference(lib_pde) if len(stray_pde) and not len(lib_pde): log.debug...
[ "def", "move_examples", "(", "root", ",", "lib_dir", ")", ":", "all_pde", "=", "files_multi_pattern", "(", "root", ",", "INO_PATTERNS", ")", "lib_pde", "=", "files_multi_pattern", "(", "lib_dir", ",", "INO_PATTERNS", ")", "stray_pde", "=", "all_pde", ".", "dif...
find examples not under lib dir, and move into ``examples``
[ "find", "examples", "not", "under", "lib", "dir", "and", "move", "into", "examples" ]
python
train
adamkerz/django-presentation
django_presentation/forms/fields/TypedChoiceField.py
https://github.com/adamkerz/django-presentation/blob/1e812faa5f682e021fa6580509d8d324cfcc119c/django_presentation/forms/fields/TypedChoiceField.py#L15-L27
def to_python(self,value): """ Validates that the value is in self.choices and can be coerced to the right type. """ if value==self.emptyValue or value in EMPTY_VALUES: return self.emptyValue try: value=self.coerce(value) except(ValueErro...
[ "def", "to_python", "(", "self", ",", "value", ")", ":", "if", "value", "==", "self", ".", "emptyValue", "or", "value", "in", "EMPTY_VALUES", ":", "return", "self", ".", "emptyValue", "try", ":", "value", "=", "self", ".", "coerce", "(", "value", ")", ...
Validates that the value is in self.choices and can be coerced to the right type.
[ "Validates", "that", "the", "value", "is", "in", "self", ".", "choices", "and", "can", "be", "coerced", "to", "the", "right", "type", "." ]
python
train
avanwyk/cipy
cipy/algorithms/pso/functions.py
https://github.com/avanwyk/cipy/blob/98450dd01767b3615c113e50dc396f135e177b29/cipy/algorithms/pso/functions.py#L168-L194
def update_particle(position_update, velocity_update, state, nbest_topology, idx_particle): """ Update function for a particle. Calculates and updates the velocity and position of a particle for a single iteration of the PSO algorithm. Social best particle is determined by the state...
[ "def", "update_particle", "(", "position_update", ",", "velocity_update", ",", "state", ",", "nbest_topology", ",", "idx_particle", ")", ":", "(", "idx", ",", "particle", ")", "=", "idx_particle", "nbest", "=", "state", ".", "swarm", "[", "nbest_topology", "["...
Update function for a particle. Calculates and updates the velocity and position of a particle for a single iteration of the PSO algorithm. Social best particle is determined by the state.params['topology'] function. Args: state: cipy.algorithms.pso.State: The state of the PSO algorithm. ...
[ "Update", "function", "for", "a", "particle", "." ]
python
train
pycontribs/python-crowd
crowd.py
https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L321-L380
def add_user(self, username, raise_on_error=False, **kwargs): """Add a user to the directory Args: username: The account username raise_on_error: optional (default: False) **kwargs: key-value pairs: password: mandatory ...
[ "def", "add_user", "(", "self", ",", "username", ",", "raise_on_error", "=", "False", ",", "*", "*", "kwargs", ")", ":", "# Check that mandatory elements have been provided", "if", "'password'", "not", "in", "kwargs", ":", "raise", "ValueError", "(", "\"missing pa...
Add a user to the directory Args: username: The account username raise_on_error: optional (default: False) **kwargs: key-value pairs: password: mandatory email: mandatory first_name: optional ...
[ "Add", "a", "user", "to", "the", "directory" ]
python
train
HHammond/PrettyPandas
prettypandas/summarizer.py
https://github.com/HHammond/PrettyPandas/blob/99a814ffc3aa61f66eaf902afaa4b7802518d33a/prettypandas/summarizer.py#L335-L342
def as_percent(self, precision=2, *args, **kwargs): """Format subset as percentages :param precision: Decimal precision :param subset: Pandas subset """ f = Formatter(as_percent(precision), args, kwargs) return self._add_formatter(f)
[ "def", "as_percent", "(", "self", ",", "precision", "=", "2", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "f", "=", "Formatter", "(", "as_percent", "(", "precision", ")", ",", "args", ",", "kwargs", ")", "return", "self", ".", "_add_formatte...
Format subset as percentages :param precision: Decimal precision :param subset: Pandas subset
[ "Format", "subset", "as", "percentages" ]
python
train
linode/linode_api4-python
linode_api4/login_client.py
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/login_client.py#L417-L441
def expire_token(self, token): """ Given a token, makes a request to the authentication server to expire it immediately. This is considered a responsible way to log out a user. If you simply remove the session your application has for the user without expiring their token, the ...
[ "def", "expire_token", "(", "self", ",", "token", ")", ":", "r", "=", "requests", ".", "post", "(", "self", ".", "_login_uri", "(", "\"/oauth/token/expire\"", ")", ",", "data", "=", "{", "\"client_id\"", ":", "self", ".", "client_id", ",", "\"client_secret...
Given a token, makes a request to the authentication server to expire it immediately. This is considered a responsible way to log out a user. If you simply remove the session your application has for the user without expiring their token, the user is not _really_ logged out. :param to...
[ "Given", "a", "token", "makes", "a", "request", "to", "the", "authentication", "server", "to", "expire", "it", "immediately", ".", "This", "is", "considered", "a", "responsible", "way", "to", "log", "out", "a", "user", ".", "If", "you", "simply", "remove",...
python
train
moderngl/moderngl
examples/window/__init__.py
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/examples/window/__init__.py#L65-L99
def parse_args(args=None): """Parse arguments from sys.argv""" parser = argparse.ArgumentParser() parser.add_argument( '-w', '--window', default="pyqt5", choices=find_window_classes(), help='Name for the window type to use', ) parser.add_argument( ...
[ "def", "parse_args", "(", "args", "=", "None", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "'-w'", ",", "'--window'", ",", "default", "=", "\"pyqt5\"", ",", "choices", "=", "find_window_classes", ...
Parse arguments from sys.argv
[ "Parse", "arguments", "from", "sys", ".", "argv" ]
python
train
vinci1it2000/schedula
schedula/utils/sol.py
https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/sol.py#L1089-L1127
def _see_remote_link_node(self, node_id, fringe=None, dist=None, check_dsp=lambda x: True): """ See data remote links of the node (set output to remote links). :param node_id: Node id. :type node_id: str :param fringe: Heapq...
[ "def", "_see_remote_link_node", "(", "self", ",", "node_id", ",", "fringe", "=", "None", ",", "dist", "=", "None", ",", "check_dsp", "=", "lambda", "x", ":", "True", ")", ":", "# Namespace shortcut.", "node", ",", "p_id", ",", "c_i", "=", "self", ".", ...
See data remote links of the node (set output to remote links). :param node_id: Node id. :type node_id: str :param fringe: Heapq of closest available nodes. :type fringe: list[(float | int, bool, (str, Dispatcher)] :param dist: Distance from...
[ "See", "data", "remote", "links", "of", "the", "node", "(", "set", "output", "to", "remote", "links", ")", "." ]
python
train
jazzband/django-analytical
analytical/templatetags/gosquared.py
https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/templatetags/gosquared.py#L38-L48
def gosquared(parser, token): """ GoSquared tracking template tag. Renders Javascript code to track page visits. You must supply your GoSquared site token in the ``GOSQUARED_SITE_TOKEN`` setting. """ bits = token.split_contents() if len(bits) > 1: raise TemplateSyntaxError("'%s' ta...
[ "def", "gosquared", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "if", "len", "(", "bits", ")", ">", "1", ":", "raise", "TemplateSyntaxError", "(", "\"'%s' takes no arguments\"", "%", "bits", "[", "0", "]"...
GoSquared tracking template tag. Renders Javascript code to track page visits. You must supply your GoSquared site token in the ``GOSQUARED_SITE_TOKEN`` setting.
[ "GoSquared", "tracking", "template", "tag", "." ]
python
valid
spacetelescope/drizzlepac
drizzlepac/runastrodriz.py
https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/runastrodriz.py#L609-L613
def _restoreResults(newdir,origdir): """ Move (not copy) all files from newdir back to the original directory """ for fname in glob.glob(os.path.join(newdir,'*')): shutil.move(fname,os.path.join(origdir,os.path.basename(fname)))
[ "def", "_restoreResults", "(", "newdir", ",", "origdir", ")", ":", "for", "fname", "in", "glob", ".", "glob", "(", "os", ".", "path", ".", "join", "(", "newdir", ",", "'*'", ")", ")", ":", "shutil", ".", "move", "(", "fname", ",", "os", ".", "pat...
Move (not copy) all files from newdir back to the original directory
[ "Move", "(", "not", "copy", ")", "all", "files", "from", "newdir", "back", "to", "the", "original", "directory" ]
python
train
saltstack/salt
salt/modules/mac_pkgutil.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mac_pkgutil.py#L85-L112
def install(source, package_id): ''' Install a .pkg from an URI or an absolute path. :param str source: The path to a package. :param str package_id: The package ID :return: True if successful, otherwise False :rtype: bool CLI Example: .. code-block:: bash salt '*' pkgutil....
[ "def", "install", "(", "source", ",", "package_id", ")", ":", "if", "is_installed", "(", "package_id", ")", ":", "return", "True", "uri", "=", "urllib", ".", "parse", ".", "urlparse", "(", "source", ")", "if", "not", "uri", ".", "scheme", "==", "''", ...
Install a .pkg from an URI or an absolute path. :param str source: The path to a package. :param str package_id: The package ID :return: True if successful, otherwise False :rtype: bool CLI Example: .. code-block:: bash salt '*' pkgutil.install source=/vagrant/build_essentials.pkg ...
[ "Install", "a", ".", "pkg", "from", "an", "URI", "or", "an", "absolute", "path", "." ]
python
train
timClicks/slate
src/slate/classes.py
https://github.com/timClicks/slate/blob/e796bbb09ea5ab473aa33ce2984bf9fc2bebb64b/src/slate/classes.py#L92-L103
def text(self, clean=True): """ Returns the text of the PDF as a single string. Options: :clean: Removes misc cruft, like lots of whitespace. """ if clean: return utils.normalise_whitespace(''.join(self).replace('\n', ' ')) else: ...
[ "def", "text", "(", "self", ",", "clean", "=", "True", ")", ":", "if", "clean", ":", "return", "utils", ".", "normalise_whitespace", "(", "''", ".", "join", "(", "self", ")", ".", "replace", "(", "'\\n'", ",", "' '", ")", ")", "else", ":", "return"...
Returns the text of the PDF as a single string. Options: :clean: Removes misc cruft, like lots of whitespace.
[ "Returns", "the", "text", "of", "the", "PDF", "as", "a", "single", "string", ".", "Options", ":" ]
python
train
Alignak-monitoring/alignak
alignak/daemons/arbiterdaemon.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daemons/arbiterdaemon.py#L1801-L1826
def get_monitoring_problems(self): """Get the schedulers satellites problems list :return: problems dictionary :rtype: dict """ res = self.get_id() res['problems'] = {} # Report our schedulers information, but only if a dispatcher exists if getattr(self,...
[ "def", "get_monitoring_problems", "(", "self", ")", ":", "res", "=", "self", ".", "get_id", "(", ")", "res", "[", "'problems'", "]", "=", "{", "}", "# Report our schedulers information, but only if a dispatcher exists", "if", "getattr", "(", "self", ",", "'dispatc...
Get the schedulers satellites problems list :return: problems dictionary :rtype: dict
[ "Get", "the", "schedulers", "satellites", "problems", "list" ]
python
train
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/tailf_confd_monitoring.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/tailf_confd_monitoring.py#L271-L283
def confd_state_webui_listen_tcp_ip(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") confd_state = ET.SubElement(config, "confd-state", xmlns="http://tail-f.com/yang/confd-monitoring") webui = ET.SubElement(confd_state, "webui") listen = ET.SubEle...
[ "def", "confd_state_webui_listen_tcp_ip", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "confd_state", "=", "ET", ".", "SubElement", "(", "config", ",", "\"confd-state\"", ",", "xmlns", "=", "\...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
python-cmd2/cmd2
cmd2/cmd2.py
https://github.com/python-cmd2/cmd2/blob/b22c0bd891ed08c8b09df56df9d91f48166a5e2a/cmd2/cmd2.py#L4031-L4034
def register_postcmd_hook(self, func: Callable[[plugin.PostcommandData], plugin.PostcommandData]) -> None: """Register a hook to be called after the command function.""" self._validate_prepostcmd_hook(func, plugin.PostcommandData) self._postcmd_hooks.append(func)
[ "def", "register_postcmd_hook", "(", "self", ",", "func", ":", "Callable", "[", "[", "plugin", ".", "PostcommandData", "]", ",", "plugin", ".", "PostcommandData", "]", ")", "->", "None", ":", "self", ".", "_validate_prepostcmd_hook", "(", "func", ",", "plugi...
Register a hook to be called after the command function.
[ "Register", "a", "hook", "to", "be", "called", "after", "the", "command", "function", "." ]
python
train
chrislit/abydos
abydos/fingerprint/_occurrence_halved.py
https://github.com/chrislit/abydos/blob/165466b3ff6afd8024a4c8660421b0c4e7773db9/abydos/fingerprint/_occurrence_halved.py#L42-L99
def fingerprint(self, word, n_bits=16, most_common=MOST_COMMON_LETTERS_CG): """Return the occurrence halved fingerprint. Based on the occurrence halved fingerprint from :cite:`Cislak:2017`. Parameters ---------- word : str The word to fingerprint n_bits : in...
[ "def", "fingerprint", "(", "self", ",", "word", ",", "n_bits", "=", "16", ",", "most_common", "=", "MOST_COMMON_LETTERS_CG", ")", ":", "if", "n_bits", "%", "2", ":", "n_bits", "+=", "1", "w_len", "=", "len", "(", "word", ")", "//", "2", "w_1", "=", ...
Return the occurrence halved fingerprint. Based on the occurrence halved fingerprint from :cite:`Cislak:2017`. Parameters ---------- word : str The word to fingerprint n_bits : int Number of bits in the fingerprint returned most_common : list ...
[ "Return", "the", "occurrence", "halved", "fingerprint", "." ]
python
valid
kejbaly2/metrique
metrique/utils.py
https://github.com/kejbaly2/metrique/blob/a10b076097441b7dde687949139f702f5c1e1b35/metrique/utils.py#L270-L320
def daemonize(pid_file=None, cwd=None): """ Detach a process from the controlling terminal and run it in the background as a daemon. Modified version of: code.activestate.com/recipes/278731-creating-a-daemon-the-python-way/ author = "Chad J. Schroeder" copyright = "Copyright (C) 2005 C...
[ "def", "daemonize", "(", "pid_file", "=", "None", ",", "cwd", "=", "None", ")", ":", "cwd", "=", "cwd", "or", "'/'", "try", ":", "pid", "=", "os", ".", "fork", "(", ")", "except", "OSError", "as", "e", ":", "raise", "Exception", "(", "\"%s [%d]\"",...
Detach a process from the controlling terminal and run it in the background as a daemon. Modified version of: code.activestate.com/recipes/278731-creating-a-daemon-the-python-way/ author = "Chad J. Schroeder" copyright = "Copyright (C) 2005 Chad J. Schroeder"
[ "Detach", "a", "process", "from", "the", "controlling", "terminal", "and", "run", "it", "in", "the", "background", "as", "a", "daemon", "." ]
python
train
Kozea/cairocffi
cairocffi/context.py
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/context.py#L1766-L1775
def get_font_face(self): """Return the current font face. :param font_face: A new :class:`FontFace` object wrapping an existing cairo object. """ return FontFace._from_pointer( cairo.cairo_get_font_face(self._pointer), incref=True)
[ "def", "get_font_face", "(", "self", ")", ":", "return", "FontFace", ".", "_from_pointer", "(", "cairo", ".", "cairo_get_font_face", "(", "self", ".", "_pointer", ")", ",", "incref", "=", "True", ")" ]
Return the current font face. :param font_face: A new :class:`FontFace` object wrapping an existing cairo object.
[ "Return", "the", "current", "font", "face", "." ]
python
train
jobovy/galpy
galpy/df/diskdf.py
https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/df/diskdf.py#L1012-L1055
def oortC(self,R,romberg=False,nsigma=None,phi=0.): """ NAME: oortC PURPOSE: calculate the Oort function C INPUT: R - radius at which to calculate C (can be Quantity) OPTIONAL INPUT: nsigma - number of sigma to integrate the velo...
[ "def", "oortC", "(", "self", ",", "R", ",", "romberg", "=", "False", ",", "nsigma", "=", "None", ",", "phi", "=", "0.", ")", ":", "#2C= -meanvR/R-dmeanvphi/R/dphi+dmeanvR/dR", "meanvr", "=", "self", ".", "meanvR", "(", "R", ",", "romberg", "=", "romberg"...
NAME: oortC PURPOSE: calculate the Oort function C INPUT: R - radius at which to calculate C (can be Quantity) OPTIONAL INPUT: nsigma - number of sigma to integrate the velocities over KEYWORDS: romberg - if True, use a romb...
[ "NAME", ":" ]
python
train
CityOfZion/neo-python
neo/Core/State/AssetState.py
https://github.com/CityOfZion/neo-python/blob/fe90f62e123d720d4281c79af0598d9df9e776fb/neo/Core/State/AssetState.py#L97-L129
def Deserialize(self, reader): """ Deserialize full object. Args: reader (neocore.IO.BinaryReader): """ super(AssetState, self).Deserialize(reader) self.AssetId = reader.ReadUInt256() self.AssetType = reader.ReadByte() self.Name = reader.ReadV...
[ "def", "Deserialize", "(", "self", ",", "reader", ")", ":", "super", "(", "AssetState", ",", "self", ")", ".", "Deserialize", "(", "reader", ")", "self", ".", "AssetId", "=", "reader", ".", "ReadUInt256", "(", ")", "self", ".", "AssetType", "=", "reade...
Deserialize full object. Args: reader (neocore.IO.BinaryReader):
[ "Deserialize", "full", "object", "." ]
python
train
MillionIntegrals/vel
vel/storage/backend/mongodb.py
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/storage/backend/mongodb.py#L13-L15
def clean(self, initial_epoch): """ Remove entries from database that would get overwritten """ self.db.metrics.delete_many({'run_name': self.model_config.run_name, 'epoch_idx': {'$gt': initial_epoch}})
[ "def", "clean", "(", "self", ",", "initial_epoch", ")", ":", "self", ".", "db", ".", "metrics", ".", "delete_many", "(", "{", "'run_name'", ":", "self", ".", "model_config", ".", "run_name", ",", "'epoch_idx'", ":", "{", "'$gt'", ":", "initial_epoch", "}...
Remove entries from database that would get overwritten
[ "Remove", "entries", "from", "database", "that", "would", "get", "overwritten" ]
python
train
Autodesk/aomi
aomi/filez.py
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/filez.py#L135-L152
def thaw(vault_client, src_file, opt): """Given the combination of a Secretfile and the output of a freeze operation, will restore secrets to usable locations""" if not os.path.exists(src_file): raise aomi.exceptions.AomiFile("%s does not exist" % src_file) tmp_dir = ensure_tmpdir() zip_fil...
[ "def", "thaw", "(", "vault_client", ",", "src_file", ",", "opt", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "src_file", ")", ":", "raise", "aomi", ".", "exceptions", ".", "AomiFile", "(", "\"%s does not exist\"", "%", "src_file", ")", ...
Given the combination of a Secretfile and the output of a freeze operation, will restore secrets to usable locations
[ "Given", "the", "combination", "of", "a", "Secretfile", "and", "the", "output", "of", "a", "freeze", "operation", "will", "restore", "secrets", "to", "usable", "locations" ]
python
train
9seconds/pep3134
pep3134/utils.py
https://github.com/9seconds/pep3134/blob/6b6fae903bb63cb2ac24004bb2c18ebc6a7d41d0/pep3134/utils.py#L9-L44
def construct_exc_class(cls): """Constructs proxy class for the exception.""" class ProxyException(cls, BaseException): __pep3134__ = True @property def __traceback__(self): if self.__fixed_traceback__: return self.__fixed_traceback__ current_ex...
[ "def", "construct_exc_class", "(", "cls", ")", ":", "class", "ProxyException", "(", "cls", ",", "BaseException", ")", ":", "__pep3134__", "=", "True", "@", "property", "def", "__traceback__", "(", "self", ")", ":", "if", "self", ".", "__fixed_traceback__", "...
Constructs proxy class for the exception.
[ "Constructs", "proxy", "class", "for", "the", "exception", "." ]
python
train
HewlettPackard/python-hpOneView
hpOneView/resources/storage/volumes.py
https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/storage/volumes.py#L153-L175
def create_from_snapshot(self, data, timeout=-1): """ Creates a new volume on the storage system from a snapshot of a volume. A volume template must also be specified when creating a volume from a snapshot. The global setting "StorageVolumeTemplateRequired" controls whether or n...
[ "def", "create_from_snapshot", "(", "self", ",", "data", ",", "timeout", "=", "-", "1", ")", ":", "uri", "=", "self", ".", "URI", "+", "\"/from-snapshot\"", "return", "self", ".", "_client", ".", "create", "(", "data", ",", "uri", "=", "uri", ",", "t...
Creates a new volume on the storage system from a snapshot of a volume. A volume template must also be specified when creating a volume from a snapshot. The global setting "StorageVolumeTemplateRequired" controls whether or not root volume templates can be used to provision volumes. The...
[ "Creates", "a", "new", "volume", "on", "the", "storage", "system", "from", "a", "snapshot", "of", "a", "volume", ".", "A", "volume", "template", "must", "also", "be", "specified", "when", "creating", "a", "volume", "from", "a", "snapshot", "." ]
python
train
piface/pifacecommon
pifacecommon/interrupts.py
https://github.com/piface/pifacecommon/blob/006bca14c18d43ba2d9eafaa84ef83b512c51cf6/pifacecommon/interrupts.py#L229-L238
def gpio_interrupts_enable(self): """Enables GPIO interrupts.""" try: bring_gpio_interrupt_into_userspace() set_gpio_interrupt_edge() except Timeout as e: raise InterruptEnableException( "There was an error bringing gpio%d into userspace. %s" %...
[ "def", "gpio_interrupts_enable", "(", "self", ")", ":", "try", ":", "bring_gpio_interrupt_into_userspace", "(", ")", "set_gpio_interrupt_edge", "(", ")", "except", "Timeout", "as", "e", ":", "raise", "InterruptEnableException", "(", "\"There was an error bringing gpio%d i...
Enables GPIO interrupts.
[ "Enables", "GPIO", "interrupts", "." ]
python
test
manns/pyspread
pyspread/src/model/model.py
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/model/model.py#L1214-L1230
def _get_updated_environment(self, env_dict=None): """Returns globals environment with 'magic' variable Parameters ---------- env_dict: Dict, defaults to {'S': self} \tDict that maps global variable name to value """ if env_dict is None: env_dict = ...
[ "def", "_get_updated_environment", "(", "self", ",", "env_dict", "=", "None", ")", ":", "if", "env_dict", "is", "None", ":", "env_dict", "=", "{", "'S'", ":", "self", "}", "env", "=", "globals", "(", ")", ".", "copy", "(", ")", "env", ".", "update", ...
Returns globals environment with 'magic' variable Parameters ---------- env_dict: Dict, defaults to {'S': self} \tDict that maps global variable name to value
[ "Returns", "globals", "environment", "with", "magic", "variable" ]
python
train
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/process.py
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/process.py#L1507-L1542
def search_hexa(self, hexa, minAddr = None, maxAddr = None): """ Search for the given hexadecimal pattern within the process memory. Hex patterns must be in this form:: "68 65 6c 6c 6f 20 77 6f 72 6c 64" # "hello world" Spaces are optional. Capitalization of hex digits doe...
[ "def", "search_hexa", "(", "self", ",", "hexa", ",", "minAddr", "=", "None", ",", "maxAddr", "=", "None", ")", ":", "pattern", "=", "HexPattern", "(", "hexa", ")", "matches", "=", "Search", ".", "search_process", "(", "self", ",", "pattern", ",", "minA...
Search for the given hexadecimal pattern within the process memory. Hex patterns must be in this form:: "68 65 6c 6c 6f 20 77 6f 72 6c 64" # "hello world" Spaces are optional. Capitalization of hex digits doesn't matter. This is exactly equivalent to the previous example:: ...
[ "Search", "for", "the", "given", "hexadecimal", "pattern", "within", "the", "process", "memory", "." ]
python
train
celiao/tmdbsimple
tmdbsimple/search.py
https://github.com/celiao/tmdbsimple/blob/ff17893110c99771d6398a62c35d36dd9735f4b9/tmdbsimple/search.py#L81-L105
def tv(self, **kwargs): """ Search for TV shows by title. Args: query: CGI escpaed string. page: (optional) Minimum value of 1. Expected value is an integer. language: (optional) ISO 639-1 code. first_air_date_year: (optional) Filter the results t...
[ "def", "tv", "(", "self", ",", "*", "*", "kwargs", ")", ":", "path", "=", "self", ".", "_get_path", "(", "'tv'", ")", "response", "=", "self", ".", "_GET", "(", "path", ",", "kwargs", ")", "self", ".", "_set_attrs_to_values", "(", "response", ")", ...
Search for TV shows by title. Args: query: CGI escpaed string. page: (optional) Minimum value of 1. Expected value is an integer. language: (optional) ISO 639-1 code. first_air_date_year: (optional) Filter the results to only match ...
[ "Search", "for", "TV", "shows", "by", "title", "." ]
python
test
edx/XBlock
xblock/fields.py
https://github.com/edx/XBlock/blob/368bf46e2c0ee69bbb21817f428c4684936e18ee/xblock/fields.py#L983-L991
def to_json(self, value): """ Serialize the date as an ISO-formatted date string, or None. """ if isinstance(value, datetime.datetime): return value.strftime(self.DATETIME_FORMAT) if value is None: return None raise TypeError("Value stored must be ...
[ "def", "to_json", "(", "self", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "datetime", ".", "datetime", ")", ":", "return", "value", ".", "strftime", "(", "self", ".", "DATETIME_FORMAT", ")", "if", "value", "is", "None", ":", "return...
Serialize the date as an ISO-formatted date string, or None.
[ "Serialize", "the", "date", "as", "an", "ISO", "-", "formatted", "date", "string", "or", "None", "." ]
python
train
gem/oq-engine
openquake/hazardlib/gsim/berge_thierry_2003.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/berge_thierry_2003.py#L77-L88
def _get_stddevs(self, C, stddev_types, num_sites, mag_conversion_sigma): """ Return total standard deviation. """ assert all(stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES for stddev_type in stddev_types) sigma = np.zeros(num_sites) + C['sigma'] * n...
[ "def", "_get_stddevs", "(", "self", ",", "C", ",", "stddev_types", ",", "num_sites", ",", "mag_conversion_sigma", ")", ":", "assert", "all", "(", "stddev_type", "in", "self", ".", "DEFINED_FOR_STANDARD_DEVIATION_TYPES", "for", "stddev_type", "in", "stddev_types", ...
Return total standard deviation.
[ "Return", "total", "standard", "deviation", "." ]
python
train
cltk/cltk
cltk/prosody/latin/hexameter_scanner.py
https://github.com/cltk/cltk/blob/ed9c025b7ec43c949481173251b70e05e4dffd27/cltk/prosody/latin/hexameter_scanner.py#L54-L273
def scan(self, original_line: str, optional_transform: bool = False, dactyl_smoothing: bool = False) -> Verse: """ Scan a line of Latin hexameter and produce a scansion pattern, and other data. :param original_line: the original line of Latin verse :param optional_transform...
[ "def", "scan", "(", "self", ",", "original_line", ":", "str", ",", "optional_transform", ":", "bool", "=", "False", ",", "dactyl_smoothing", ":", "bool", "=", "False", ")", "->", "Verse", ":", "verse", "=", "Verse", "(", "original_line", ",", "meter", "=...
Scan a line of Latin hexameter and produce a scansion pattern, and other data. :param original_line: the original line of Latin verse :param optional_transform: whether or not to perform i to j transform for syllabification :param dactyl_smoothing: whether or not to perform dactyl smoothing ...
[ "Scan", "a", "line", "of", "Latin", "hexameter", "and", "produce", "a", "scansion", "pattern", "and", "other", "data", "." ]
python
train
sirfoga/pyhal
hal/files/models/system.py
https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/files/models/system.py#L291-L300
def rename(self, new_path): """Renames to new path :param new_path: new path to use """ rename_path = fix_raw_path(new_path) if is_folder(self.path): os.rename(self.path, rename_path) else: os.renames(self.path, rename_path)
[ "def", "rename", "(", "self", ",", "new_path", ")", ":", "rename_path", "=", "fix_raw_path", "(", "new_path", ")", "if", "is_folder", "(", "self", ".", "path", ")", ":", "os", ".", "rename", "(", "self", ".", "path", ",", "rename_path", ")", "else", ...
Renames to new path :param new_path: new path to use
[ "Renames", "to", "new", "path" ]
python
train
lablup/backend.ai-client-py
src/ai/backend/client/cli/admin/images.py
https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/cli/admin/images.py#L72-L83
def dealias_image(alias): '''Remove an image alias.''' with Session() as session: try: result = session.Image.dealiasImage(alias) except Exception as e: print_error(e) sys.exit(1) if result['ok']: print("alias {0} removed.".format(alias)) ...
[ "def", "dealias_image", "(", "alias", ")", ":", "with", "Session", "(", ")", "as", "session", ":", "try", ":", "result", "=", "session", ".", "Image", ".", "dealiasImage", "(", "alias", ")", "except", "Exception", "as", "e", ":", "print_error", "(", "e...
Remove an image alias.
[ "Remove", "an", "image", "alias", "." ]
python
train
brutasse/graphite-api
graphite_api/functions.py
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L3443-L3470
def isNonNull(requestContext, seriesList): """ Takes a metric or wild card seriesList and counts up how many non-null values are specified. This is useful for understanding which metrics have data at a given point in time (ie, to count which servers are alive). Example:: &target=isNonN...
[ "def", "isNonNull", "(", "requestContext", ",", "seriesList", ")", ":", "def", "transform", "(", "v", ")", ":", "if", "v", "is", "None", ":", "return", "0", "else", ":", "return", "1", "for", "series", "in", "seriesList", ":", "series", ".", "name", ...
Takes a metric or wild card seriesList and counts up how many non-null values are specified. This is useful for understanding which metrics have data at a given point in time (ie, to count which servers are alive). Example:: &target=isNonNull(webapp.pages.*.views) Returns a seriesList whe...
[ "Takes", "a", "metric", "or", "wild", "card", "seriesList", "and", "counts", "up", "how", "many", "non", "-", "null", "values", "are", "specified", ".", "This", "is", "useful", "for", "understanding", "which", "metrics", "have", "data", "at", "a", "given",...
python
train
saltstack/salt
salt/states/pcs.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/pcs.py#L984-L1021
def resource_present(name, resource_id, resource_type, resource_options=None, cibname=None): ''' Ensure that a resource is created Should be run on one cluster node only (there may be races) Can only be run on a node with a functional pacemaker/corosync name Irrelevant, not used (recom...
[ "def", "resource_present", "(", "name", ",", "resource_id", ",", "resource_type", ",", "resource_options", "=", "None", ",", "cibname", "=", "None", ")", ":", "return", "_item_present", "(", "name", "=", "name", ",", "item", "=", "'resource'", ",", "item_id"...
Ensure that a resource is created Should be run on one cluster node only (there may be races) Can only be run on a node with a functional pacemaker/corosync name Irrelevant, not used (recommended: {{formulaname}}__resource_present_{{resource_id}}) resource_id name for the resource ...
[ "Ensure", "that", "a", "resource", "is", "created" ]
python
train
openstack/networking-cisco
networking_cisco/ml2_drivers/nexus/mech_cisco_nexus.py
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/ml2_drivers/nexus/mech_cisco_nexus.py#L1338-L1436
def configure_switch_entries(self, switch_ip, port_bindings): """Create a nexus switch entry in Nexus. The port_bindings is sorted by vlan_id, vni, port_id. When there is a change in vlan_id or vni, then vlan data is configured in Nexus device. Otherwise we check if there is a c...
[ "def", "configure_switch_entries", "(", "self", ",", "switch_ip", ",", "port_bindings", ")", ":", "prev_vlan", "=", "-", "1", "prev_vni", "=", "-", "1", "prev_port", "=", "None", "prev_native_vlan", "=", "0", "starttime", "=", "time", ".", "time", "(", ")"...
Create a nexus switch entry in Nexus. The port_bindings is sorted by vlan_id, vni, port_id. When there is a change in vlan_id or vni, then vlan data is configured in Nexus device. Otherwise we check if there is a change in port_id where we configure the port with vlan trunk conf...
[ "Create", "a", "nexus", "switch", "entry", "in", "Nexus", "." ]
python
train
rushter/heamy
heamy/feature.py
https://github.com/rushter/heamy/blob/c330854cee3c547417eb353a4a4a23331b40b4bc/heamy/feature.py#L126-L152
def mean_target(df, feature_name, target_name, C=None): """Mean target. Original idea: Stanislav Semenov Parameters ---------- C : float, default None Regularization coefficient. The higher, the more conservative result. The optimal value lies between 10 and 50 depending on the data...
[ "def", "mean_target", "(", "df", ",", "feature_name", ",", "target_name", ",", "C", "=", "None", ")", ":", "def", "group_mean", "(", "group", ")", ":", "group_size", "=", "float", "(", "group", ".", "shape", "[", "0", "]", ")", "if", "C", "is", "No...
Mean target. Original idea: Stanislav Semenov Parameters ---------- C : float, default None Regularization coefficient. The higher, the more conservative result. The optimal value lies between 10 and 50 depending on the data. feature_name : str target_name : str df: DataFram...
[ "Mean", "target", ".", "Original", "idea", ":", "Stanislav", "Semenov" ]
python
train
polysquare/polysquare-setuptools-lint
polysquare_setuptools_lint/__init__.py
https://github.com/polysquare/polysquare-setuptools-lint/blob/5df5a6401c7ad6a90b42230eeb99c82cc56952b6/polysquare_setuptools_lint/__init__.py#L71-L82
def _stamped_deps(stamp_directory, func, dependencies, *args, **kwargs): """Run func, assumed to have dependencies as its first argument.""" if not isinstance(dependencies, list): jobstamps_dependencies = [dependencies] else: jobstamps_dependencies = dependencies kwargs.update({ ...
[ "def", "_stamped_deps", "(", "stamp_directory", ",", "func", ",", "dependencies", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "isinstance", "(", "dependencies", ",", "list", ")", ":", "jobstamps_dependencies", "=", "[", "dependencies", ...
Run func, assumed to have dependencies as its first argument.
[ "Run", "func", "assumed", "to", "have", "dependencies", "as", "its", "first", "argument", "." ]
python
train
rigetti/quantumflow
quantumflow/forest/__init__.py
https://github.com/rigetti/quantumflow/blob/13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb/quantumflow/forest/__init__.py#L171-L185
def circuit_to_pyquil(circuit: Circuit) -> pyquil.Program: """Convert a QuantumFlow circuit to a pyQuil program""" prog = pyquil.Program() for elem in circuit.elements: if isinstance(elem, Gate) and elem.name in QUIL_GATES: params = list(elem.params.values()) if elem.params else [] ...
[ "def", "circuit_to_pyquil", "(", "circuit", ":", "Circuit", ")", "->", "pyquil", ".", "Program", ":", "prog", "=", "pyquil", ".", "Program", "(", ")", "for", "elem", "in", "circuit", ".", "elements", ":", "if", "isinstance", "(", "elem", ",", "Gate", "...
Convert a QuantumFlow circuit to a pyQuil program
[ "Convert", "a", "QuantumFlow", "circuit", "to", "a", "pyQuil", "program" ]
python
train
secnot/rectpack
rectpack/skyline.py
https://github.com/secnot/rectpack/blob/21d46be48fd453500ea49de699bc9eabc427bdf7/rectpack/skyline.py#L192-L208
def fitness(self, width, height): """Search for the best fitness """ assert(width > 0 and height >0) if width > max(self.width, self.height) or\ height > max(self.height, self.width): return None # If there is room in wasted space, FREE PACKING!! ...
[ "def", "fitness", "(", "self", ",", "width", ",", "height", ")", ":", "assert", "(", "width", ">", "0", "and", "height", ">", "0", ")", "if", "width", ">", "max", "(", "self", ".", "width", ",", "self", ".", "height", ")", "or", "height", ">", ...
Search for the best fitness
[ "Search", "for", "the", "best", "fitness" ]
python
train
apache/incubator-superset
superset/views/core.py
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/core.py#L1517-L1532
def checkbox(self, model_view, id_, attr, value): """endpoint for checking/unchecking any boolean in a sqla model""" modelview_to_model = { '{}ColumnInlineView'.format(name.capitalize()): source.column_class for name, source in ConnectorRegistry.sources.items() } ...
[ "def", "checkbox", "(", "self", ",", "model_view", ",", "id_", ",", "attr", ",", "value", ")", ":", "modelview_to_model", "=", "{", "'{}ColumnInlineView'", ".", "format", "(", "name", ".", "capitalize", "(", ")", ")", ":", "source", ".", "column_class", ...
endpoint for checking/unchecking any boolean in a sqla model
[ "endpoint", "for", "checking", "/", "unchecking", "any", "boolean", "in", "a", "sqla", "model" ]
python
train
ev3dev/ev3dev-lang-python
ev3dev2/control/GyroBalancer.py
https://github.com/ev3dev/ev3dev-lang-python/blob/afc98d35004b533dc161a01f7c966e78607d7c1e/ev3dev2/control/GyroBalancer.py#L475-L481
def _move(self, speed=0, steering=0, seconds=None): """Move robot.""" self.drive_queue.put((speed, steering)) if seconds is not None: time.sleep(seconds) self.drive_queue.put((0, 0)) self.drive_queue.join()
[ "def", "_move", "(", "self", ",", "speed", "=", "0", ",", "steering", "=", "0", ",", "seconds", "=", "None", ")", ":", "self", ".", "drive_queue", ".", "put", "(", "(", "speed", ",", "steering", ")", ")", "if", "seconds", "is", "not", "None", ":"...
Move robot.
[ "Move", "robot", "." ]
python
train
its-rigs/Trolly
trolly/client.py
https://github.com/its-rigs/Trolly/blob/483dc94c352df40dc05ead31820b059b2545cf82/trolly/client.py#L195-L207
def create_member(self, member_json): ''' Create a Member object from JSON object Returns: Member: The member from the given `member_json`. ''' return trolly.member.Member( trello_client=self, member_id=member_json['id'], name=memb...
[ "def", "create_member", "(", "self", ",", "member_json", ")", ":", "return", "trolly", ".", "member", ".", "Member", "(", "trello_client", "=", "self", ",", "member_id", "=", "member_json", "[", "'id'", "]", ",", "name", "=", "member_json", "[", "'fullName...
Create a Member object from JSON object Returns: Member: The member from the given `member_json`.
[ "Create", "a", "Member", "object", "from", "JSON", "object" ]
python
test
spyder-ide/spyder
spyder/plugins/console/widgets/console.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/console/widgets/console.py#L72-L115
def set_style(self): """ Set font style with the following attributes: 'foreground_color', 'background_color', 'italic', 'bold' and 'underline' """ if self.current_format is None: assert self.base_format is not None self.current_format = QTextCharF...
[ "def", "set_style", "(", "self", ")", ":", "if", "self", ".", "current_format", "is", "None", ":", "assert", "self", ".", "base_format", "is", "not", "None", "self", ".", "current_format", "=", "QTextCharFormat", "(", "self", ".", "base_format", ")", "# Fo...
Set font style with the following attributes: 'foreground_color', 'background_color', 'italic', 'bold' and 'underline'
[ "Set", "font", "style", "with", "the", "following", "attributes", ":", "foreground_color", "background_color", "italic", "bold", "and", "underline" ]
python
train
AlpacaDB/selectivesearch
selectivesearch/selectivesearch.py
https://github.com/AlpacaDB/selectivesearch/blob/52f7f83bb247b1ed941b099c6a610da1b0e30451/selectivesearch/selectivesearch.py#L58-L66
def _sim_fill(r1, r2, imsize): """ calculate the fill similarity over the image """ bbsize = ( (max(r1["max_x"], r2["max_x"]) - min(r1["min_x"], r2["min_x"])) * (max(r1["max_y"], r2["max_y"]) - min(r1["min_y"], r2["min_y"])) ) return 1.0 - (bbsize - r1["size"] - r2["size"]) /...
[ "def", "_sim_fill", "(", "r1", ",", "r2", ",", "imsize", ")", ":", "bbsize", "=", "(", "(", "max", "(", "r1", "[", "\"max_x\"", "]", ",", "r2", "[", "\"max_x\"", "]", ")", "-", "min", "(", "r1", "[", "\"min_x\"", "]", ",", "r2", "[", "\"min_x\"...
calculate the fill similarity over the image
[ "calculate", "the", "fill", "similarity", "over", "the", "image" ]
python
train
nickoala/telepot
telepot/aio/helper.py
https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/aio/helper.py#L74-L129
def answer(self, inline_query, compute_fn, *compute_args, **compute_kwargs): """ Create a task that calls ``compute fn`` (along with additional arguments ``*compute_args`` and ``**compute_kwargs``), then applies the returned value to :meth:`.Bot.answerInlineQuery` to answer the inline qu...
[ "def", "answer", "(", "self", ",", "inline_query", ",", "compute_fn", ",", "*", "compute_args", ",", "*", "*", "compute_kwargs", ")", ":", "from_id", "=", "inline_query", "[", "'from'", "]", "[", "'id'", "]", "async", "def", "compute_and_answer", "(", ")",...
Create a task that calls ``compute fn`` (along with additional arguments ``*compute_args`` and ``**compute_kwargs``), then applies the returned value to :meth:`.Bot.answerInlineQuery` to answer the inline query. If a preceding task is already working for a user, that task is cancelled, t...
[ "Create", "a", "task", "that", "calls", "compute", "fn", "(", "along", "with", "additional", "arguments", "*", "compute_args", "and", "**", "compute_kwargs", ")", "then", "applies", "the", "returned", "value", "to", ":", "meth", ":", ".", "Bot", ".", "answ...
python
train
RI-imaging/qpimage
qpimage/core.py
https://github.com/RI-imaging/qpimage/blob/863c0fce5735b4c0ae369f75c0df9a33411b2bb2/qpimage/core.py#L597-L655
def copyh5(inh5, outh5): """Recursively copy all hdf5 data from one group to another Data from links is copied. Parameters ---------- inh5: str, h5py.File, or h5py.Group The input hdf5 data. This can be either a file name or an hdf5 object. outh5: str, h5py.File, h5py.Group, or...
[ "def", "copyh5", "(", "inh5", ",", "outh5", ")", ":", "if", "not", "isinstance", "(", "inh5", ",", "h5py", ".", "Group", ")", ":", "inh5", "=", "h5py", ".", "File", "(", "inh5", ",", "mode", "=", "\"r\"", ")", "if", "outh5", "is", "None", ":", ...
Recursively copy all hdf5 data from one group to another Data from links is copied. Parameters ---------- inh5: str, h5py.File, or h5py.Group The input hdf5 data. This can be either a file name or an hdf5 object. outh5: str, h5py.File, h5py.Group, or None The output hdf5 da...
[ "Recursively", "copy", "all", "hdf5", "data", "from", "one", "group", "to", "another" ]
python
train
log2timeline/plaso
plaso/parsers/winreg_plugins/mrulist.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/parsers/winreg_plugins/mrulist.py#L77-L99
def _ParseMRUListValue(self, registry_key): """Parses the MRUList value in a given Registry key. Args: registry_key (dfwinreg.WinRegistryKey): Windows Registry key that contains the MRUList value. Returns: mrulist_entries: MRUList entries or None if not available. """ mrulis...
[ "def", "_ParseMRUListValue", "(", "self", ",", "registry_key", ")", ":", "mrulist_value", "=", "registry_key", ".", "GetValueByName", "(", "'MRUList'", ")", "# The key exists but does not contain a value named \"MRUList\".", "if", "not", "mrulist_value", ":", "return", "N...
Parses the MRUList value in a given Registry key. Args: registry_key (dfwinreg.WinRegistryKey): Windows Registry key that contains the MRUList value. Returns: mrulist_entries: MRUList entries or None if not available.
[ "Parses", "the", "MRUList", "value", "in", "a", "given", "Registry", "key", "." ]
python
train
jim-easterbrook/pywws
src/pywws/weatherstation.py
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/weatherstation.py#L731-L741
def get_fixed_block(self, keys=[], unbuffered=False): """Get the decoded "fixed block" of settings and min/max data. A subset of the entire block can be selected by keys.""" if unbuffered or not self._fixed_block: self._fixed_block = self._read_fixed_block() format = self.fi...
[ "def", "get_fixed_block", "(", "self", ",", "keys", "=", "[", "]", ",", "unbuffered", "=", "False", ")", ":", "if", "unbuffered", "or", "not", "self", ".", "_fixed_block", ":", "self", ".", "_fixed_block", "=", "self", ".", "_read_fixed_block", "(", ")",...
Get the decoded "fixed block" of settings and min/max data. A subset of the entire block can be selected by keys.
[ "Get", "the", "decoded", "fixed", "block", "of", "settings", "and", "min", "/", "max", "data", "." ]
python
train
aiogram/aiogram
aiogram/types/chat.py
https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/types/chat.py#L291-L306
async def pin_message(self, message_id: int, disable_notification: bool = False): """ Use this method to pin a message in a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Source: https://core.telegram.org/bots/api#pi...
[ "async", "def", "pin_message", "(", "self", ",", "message_id", ":", "int", ",", "disable_notification", ":", "bool", "=", "False", ")", ":", "return", "await", "self", ".", "bot", ".", "pin_chat_message", "(", "self", ".", "id", ",", "message_id", ",", "...
Use this method to pin a message in a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Source: https://core.telegram.org/bots/api#pinchatmessage :param message_id: Identifier of a message to pin :type message_id: :obj...
[ "Use", "this", "method", "to", "pin", "a", "message", "in", "a", "supergroup", ".", "The", "bot", "must", "be", "an", "administrator", "in", "the", "chat", "for", "this", "to", "work", "and", "must", "have", "the", "appropriate", "admin", "rights", "." ]
python
train
raiden-network/raiden
raiden/api/rest.py
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/api/rest.py#L540-L548
def unhandled_exception(self, exception: Exception): """ Flask.errorhandler when an exception wasn't correctly handled """ log.critical( 'Unhandled exception when processing endpoint request', exc_info=True, node=pex(self.rest_api.raiden_api.address), ) ...
[ "def", "unhandled_exception", "(", "self", ",", "exception", ":", "Exception", ")", ":", "log", ".", "critical", "(", "'Unhandled exception when processing endpoint request'", ",", "exc_info", "=", "True", ",", "node", "=", "pex", "(", "self", ".", "rest_api", "...
Flask.errorhandler when an exception wasn't correctly handled
[ "Flask", ".", "errorhandler", "when", "an", "exception", "wasn", "t", "correctly", "handled" ]
python
train
thespacedoctor/sherlock
sherlock/transient_classifier.py
https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/transient_classifier.py#L542-L621
def _remove_previous_ned_queries( self, coordinateList): """iterate through the transient locations to see if we have recent local NED coverage of that area already **Key Arguments:** - ``coordinateList`` -- set of coordinate to check for previous queries **...
[ "def", "_remove_previous_ned_queries", "(", "self", ",", "coordinateList", ")", ":", "self", ".", "log", ".", "debug", "(", "'starting the ``_remove_previous_ned_queries`` method'", ")", "# 1 DEGREE QUERY RADIUS", "radius", "=", "60.", "*", "60.", "updatedCoordinateList",...
iterate through the transient locations to see if we have recent local NED coverage of that area already **Key Arguments:** - ``coordinateList`` -- set of coordinate to check for previous queries **Return:** - ``updatedCoordinateList`` -- coordinate list with previous queries r...
[ "iterate", "through", "the", "transient", "locations", "to", "see", "if", "we", "have", "recent", "local", "NED", "coverage", "of", "that", "area", "already" ]
python
train
juju/python-libjuju
juju/user.py
https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/user.py#L82-L86
async def enable(self): """Re-enable this user. """ await self.controller.enable_user(self.username) self._user_info.disabled = False
[ "async", "def", "enable", "(", "self", ")", ":", "await", "self", ".", "controller", ".", "enable_user", "(", "self", ".", "username", ")", "self", ".", "_user_info", ".", "disabled", "=", "False" ]
Re-enable this user.
[ "Re", "-", "enable", "this", "user", "." ]
python
train
litters/shrew
shrew/cli.py
https://github.com/litters/shrew/blob/ed4b1879321d858d6bc884d14fea7557372a4d41/shrew/cli.py#L222-L230
def add_username_password(self, use_store=False): """ Add --username and --password options :param bool use_store: Name of the section (concept, command line options, API reference) """ self.argparser.add_argument('--username', default=None, help='Username') self.argparser.add_...
[ "def", "add_username_password", "(", "self", ",", "use_store", "=", "False", ")", ":", "self", ".", "argparser", ".", "add_argument", "(", "'--username'", ",", "default", "=", "None", ",", "help", "=", "'Username'", ")", "self", ".", "argparser", ".", "add...
Add --username and --password options :param bool use_store: Name of the section (concept, command line options, API reference)
[ "Add", "--", "username", "and", "--", "password", "options", ":", "param", "bool", "use_store", ":", "Name", "of", "the", "section", "(", "concept", "command", "line", "options", "API", "reference", ")" ]
python
train
3DLIRIOUS/MeshLabXML
meshlabxml/create.py
https://github.com/3DLIRIOUS/MeshLabXML/blob/177cce21e92baca500f56a932d66bd9a33257af8/meshlabxml/create.py#L510-L583
def plane_hires_edges(script, size=1.0, x_segments=1, y_segments=1, center=False, color=None): """ Creates a plane with a specified number of vertices on it sides, but no vertices on the interior. Currently used to create a simpler bottom for cube_hires. """ size = util.make_...
[ "def", "plane_hires_edges", "(", "script", ",", "size", "=", "1.0", ",", "x_segments", "=", "1", ",", "y_segments", "=", "1", ",", "center", "=", "False", ",", "color", "=", "None", ")", ":", "size", "=", "util", ".", "make_list", "(", "size", ",", ...
Creates a plane with a specified number of vertices on it sides, but no vertices on the interior. Currently used to create a simpler bottom for cube_hires.
[ "Creates", "a", "plane", "with", "a", "specified", "number", "of", "vertices", "on", "it", "sides", "but", "no", "vertices", "on", "the", "interior", "." ]
python
test
joelfrederico/SciSalt
scisalt/matplotlib/less_labels.py
https://github.com/joelfrederico/SciSalt/blob/7bf57c49c7dde0a8b0aa337fbd2fbd527ce7a67f/scisalt/matplotlib/less_labels.py#L7-L15
def less_labels(ax, x_fraction=0.5, y_fraction=0.5): """ Scale the number of tick labels in x and y by *x_fraction* and *y_fraction* respectively. """ nbins = _np.size(ax.get_xticklabels()) ax.locator_params(nbins=_np.floor(nbins*x_fraction), axis='x') nbins = _np.size(ax.get_yticklabels()) ...
[ "def", "less_labels", "(", "ax", ",", "x_fraction", "=", "0.5", ",", "y_fraction", "=", "0.5", ")", ":", "nbins", "=", "_np", ".", "size", "(", "ax", ".", "get_xticklabels", "(", ")", ")", "ax", ".", "locator_params", "(", "nbins", "=", "_np", ".", ...
Scale the number of tick labels in x and y by *x_fraction* and *y_fraction* respectively.
[ "Scale", "the", "number", "of", "tick", "labels", "in", "x", "and", "y", "by", "*", "x_fraction", "*", "and", "*", "y_fraction", "*", "respectively", "." ]
python
valid