repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
estnltk/estnltk
estnltk/mw_verbs/verbchain_detector.py
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/mw_verbs/verbchain_detector.py#L37-L85
def removeRedundantVerbChains( foundChains, removeOverlapping = True, removeSingleAraAndEi = False ): ''' Eemaldab yleliigsed verbiahelad: ahelad, mis katavad osaliselt v6i t2ielikult teisi ahelaid (removeOverlapping == True), yhes6nalised 'ei' ja 'ära' ahelad (kui removeSingleAraAndEi == True)...
[ "def", "removeRedundantVerbChains", "(", "foundChains", ",", "removeOverlapping", "=", "True", ",", "removeSingleAraAndEi", "=", "False", ")", ":", "toDelete", "=", "[", "]", "for", "i", "in", "range", "(", "len", "(", "foundChains", ")", ")", ":", "matchObj...
Eemaldab yleliigsed verbiahelad: ahelad, mis katavad osaliselt v6i t2ielikult teisi ahelaid (removeOverlapping == True), yhes6nalised 'ei' ja 'ära' ahelad (kui removeSingleAraAndEi == True); Yldiselt on nii, et ylekattuvaid ei tohiks palju olla, kuna fraaside laiendamisel ...
[ "Eemaldab", "yleliigsed", "verbiahelad", ":", "ahelad", "mis", "katavad", "osaliselt", "v6i", "t2ielikult", "teisi", "ahelaid", "(", "removeOverlapping", "==", "True", ")", "yhes6nalised", "ei", "ja", "ära", "ahelad", "(", "kui", "removeSingleAraAndEi", "==", "Tru...
python
train
60.632653
thunder-project/thunder
thunder/series/series.py
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L233-L237
def sum(self): """ Compute the sum across records. """ return self._constructor(self.values.sum(axis=self.baseaxes, keepdims=True))
[ "def", "sum", "(", "self", ")", ":", "return", "self", ".", "_constructor", "(", "self", ".", "values", ".", "sum", "(", "axis", "=", "self", ".", "baseaxes", ",", "keepdims", "=", "True", ")", ")" ]
Compute the sum across records.
[ "Compute", "the", "sum", "across", "records", "." ]
python
train
31.8
DataONEorg/d1_python
lib_client/src/d1_client/baseclient_1_1.py
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/baseclient_1_1.py#L88-L109
def query( self, queryEngine, query_str, vendorSpecific=None, do_post=False, **kwargs ): """See Also: queryResponse() Args: queryEngine: query_str: vendorSpecific: do_post: **kwargs: Returns: """ response = self.que...
[ "def", "query", "(", "self", ",", "queryEngine", ",", "query_str", ",", "vendorSpecific", "=", "None", ",", "do_post", "=", "False", ",", "*", "*", "kwargs", ")", ":", "response", "=", "self", ".", "queryResponse", "(", "queryEngine", ",", "query_str", "...
See Also: queryResponse() Args: queryEngine: query_str: vendorSpecific: do_post: **kwargs: Returns:
[ "See", "Also", ":", "queryResponse", "()" ]
python
train
25.590909
Capitains/MyCapytain
MyCapytain/common/utils/xml.py
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/utils/xml.py#L202-L304
def passageLoop(parent, new_tree, xpath1, xpath2=None, preceding_siblings=False, following_siblings=False): """ Loop over passages to construct and increment new tree given a parent and XPaths :param parent: Parent on which to perform xpath :param new_tree: Parent on which to add nodes :param xpath1: L...
[ "def", "passageLoop", "(", "parent", ",", "new_tree", ",", "xpath1", ",", "xpath2", "=", "None", ",", "preceding_siblings", "=", "False", ",", "following_siblings", "=", "False", ")", ":", "current_1", ",", "queue_1", "=", "__formatXpath__", "(", "xpath1", "...
Loop over passages to construct and increment new tree given a parent and XPaths :param parent: Parent on which to perform xpath :param new_tree: Parent on which to add nodes :param xpath1: List of xpath elements :type xpath1: [str] :param xpath2: List of xpath elements :type xpath2: [str] ...
[ "Loop", "over", "passages", "to", "construct", "and", "increment", "new", "tree", "given", "a", "parent", "and", "XPaths" ]
python
train
41.893204
DataBiosphere/dsub
dsub/providers/google_v2.py
https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/providers/google_v2.py#L405-L416
def _map(self, event): """Extract elements from an operation event and map to a named event.""" description = event.get('description', '') start_time = google_base.parse_rfc3339_utc_string( event.get('timestamp', '')) for name, regex in _EVENT_REGEX_MAP.items(): match = regex.match(descri...
[ "def", "_map", "(", "self", ",", "event", ")", ":", "description", "=", "event", ".", "get", "(", "'description'", ",", "''", ")", "start_time", "=", "google_base", ".", "parse_rfc3339_utc_string", "(", "event", ".", "get", "(", "'timestamp'", ",", "''", ...
Extract elements from an operation event and map to a named event.
[ "Extract", "elements", "from", "an", "operation", "event", "and", "map", "to", "a", "named", "event", "." ]
python
valid
38.333333
saltstack/salt
salt/modules/inspectlib/fsdb.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/fsdb.py#L142-L154
def open(self, dbname=None): ''' Open database from the path with the name or latest. If there are no yet databases, create a new implicitly. :return: ''' databases = self.list() if self.is_closed(): self.db_path = os.path.join(self.path, dbname or (d...
[ "def", "open", "(", "self", ",", "dbname", "=", "None", ")", ":", "databases", "=", "self", ".", "list", "(", ")", "if", "self", ".", "is_closed", "(", ")", ":", "self", ".", "db_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "pa...
Open database from the path with the name or latest. If there are no yet databases, create a new implicitly. :return:
[ "Open", "database", "from", "the", "path", "with", "the", "name", "or", "latest", ".", "If", "there", "are", "no", "yet", "databases", "create", "a", "new", "implicitly", "." ]
python
train
34.846154
mota/i3-cycle
i3_cycle.py
https://github.com/mota/i3-cycle/blob/58947cccb1060c0543a6d9c1f974ee80069110e1/i3_cycle.py#L76-L98
def main(): """ Entry point """ parser = ArgumentParser() parser.add_argument("direction", choices=( "up", "down", "left", "right", "next", "prev" ), help="Direction to put...
[ "def", "main", "(", ")", ":", "parser", "=", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "\"direction\"", ",", "choices", "=", "(", "\"up\"", ",", "\"down\"", ",", "\"left\"", ",", "\"right\"", ",", "\"next\"", ",", "\"prev\"", ")", "...
Entry point
[ "Entry", "point" ]
python
train
25.173913
ClearcodeHQ/mirakuru
src/mirakuru/base.py
https://github.com/ClearcodeHQ/mirakuru/blob/38203f328479ac9356d468a20daa743807194698/src/mirakuru/base.py#L416-L432
def start(self): """ Start executor with additional checks. Checks if previous executor isn't running then start process (executor) and wait until it's started. :returns: itself :rtype: Executor """ if self.pre_start_check(): # Some other exec...
[ "def", "start", "(", "self", ")", ":", "if", "self", ".", "pre_start_check", "(", ")", ":", "# Some other executor (or process) is running with same config:", "raise", "AlreadyRunning", "(", "self", ")", "super", "(", "Executor", ",", "self", ")", ".", "start", ...
Start executor with additional checks. Checks if previous executor isn't running then start process (executor) and wait until it's started. :returns: itself :rtype: Executor
[ "Start", "executor", "with", "additional", "checks", "." ]
python
train
29.058824
ofa/django-bouncy
django_bouncy/views.py
https://github.com/ofa/django-bouncy/blob/a386dfa8c4ce59bd18978a3537c03cd6ad07bf06/django_bouncy/views.py#L235-L272
def process_delivery(message, notification): """Function to process a delivery notification""" mail = message['mail'] delivery = message['delivery'] if 'timestamp' in delivery: delivered_datetime = clean_time(delivery['timestamp']) else: delivered_datetime = None deliveries = [...
[ "def", "process_delivery", "(", "message", ",", "notification", ")", ":", "mail", "=", "message", "[", "'mail'", "]", "delivery", "=", "message", "[", "'delivery'", "]", "if", "'timestamp'", "in", "delivery", ":", "delivered_datetime", "=", "clean_time", "(", ...
Function to process a delivery notification
[ "Function", "to", "process", "a", "delivery", "notification" ]
python
train
32.710526
dw/mitogen
ansible_mitogen/runner.py
https://github.com/dw/mitogen/blob/a7fdb55e1300a7e0a5e404b09eb730cf9a525da7/ansible_mitogen/runner.py#L195-L216
def check(self): """ Compare the :func:`os.stat` for the pam_env style environmnt file `path` with the previous result `old_st`, which may be :data:`None` if the previous stat attempt failed. Reload its contents if the file has changed or appeared since last attempt. :re...
[ "def", "check", "(", "self", ")", ":", "st", "=", "self", ".", "_stat", "(", ")", "if", "self", ".", "_st", "==", "st", ":", "return", "self", ".", "_st", "=", "st", "self", ".", "_remove_existing", "(", ")", "if", "st", "is", "None", ":", "LOG...
Compare the :func:`os.stat` for the pam_env style environmnt file `path` with the previous result `old_st`, which may be :data:`None` if the previous stat attempt failed. Reload its contents if the file has changed or appeared since last attempt. :returns: New :func:`os.stat...
[ "Compare", "the", ":", "func", ":", "os", ".", "stat", "for", "the", "pam_env", "style", "environmnt", "file", "path", "with", "the", "previous", "result", "old_st", "which", "may", "be", ":", "data", ":", "None", "if", "the", "previous", "stat", "attemp...
python
train
31.909091
jsvine/tinyapi
tinyapi/draft.py
https://github.com/jsvine/tinyapi/blob/ac2cf0400b2a9b22bd0b1f43b36be99f5d1a787c/tinyapi/draft.py#L83-L87
def delete(self): """Delete the draft.""" response = self.session.request("delete:Message", [ self.message_id ]) self.data = response return self
[ "def", "delete", "(", "self", ")", ":", "response", "=", "self", ".", "session", ".", "request", "(", "\"delete:Message\"", ",", "[", "self", ".", "message_id", "]", ")", "self", ".", "data", "=", "response", "return", "self" ]
Delete the draft.
[ "Delete", "the", "draft", "." ]
python
train
34.6
deep-compute/logagg
logagg/formatters.py
https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/formatters.py#L162-L196
def mongodb(line): ''' >>> import pprint >>> input_line1 = '2017-08-17T07:56:33.489+0200 I REPL [signalProcessingThread] shutting down replication subsystems' >>> output_line1 = mongodb(input_line1) >>> pprint.pprint(output_line1) {'data': {'component': 'REPL', 'context': '[sig...
[ "def", "mongodb", "(", "line", ")", ":", "keys", "=", "[", "'timestamp'", ",", "'severity'", ",", "'component'", ",", "'context'", ",", "'message'", "]", "values", "=", "re", ".", "split", "(", "r'\\s+'", ",", "line", ",", "maxsplit", "=", "4", ")", ...
>>> import pprint >>> input_line1 = '2017-08-17T07:56:33.489+0200 I REPL [signalProcessingThread] shutting down replication subsystems' >>> output_line1 = mongodb(input_line1) >>> pprint.pprint(output_line1) {'data': {'component': 'REPL', 'context': '[signalProcessingThread]', ...
[ ">>>", "import", "pprint", ">>>", "input_line1", "=", "2017", "-", "08", "-", "17T07", ":", "56", ":", "33", ".", "489", "+", "0200", "I", "REPL", "[", "signalProcessingThread", "]", "shutting", "down", "replication", "subsystems", ">>>", "output_line1", "...
python
train
37.685714
bitesofcode/projex
projex/dataset.py
https://github.com/bitesofcode/projex/blob/d31743ec456a41428709968ab11a2cf6c6c76247/projex/dataset.py#L90-L112
def fromXml(cls, xparent): """ Loads the settings for this dataset to the inputted parent xml. :param xparent | <xml.etree.ElementTree.Element> """ output = cls() for xentry in xparent: key = xentry.get('key') if not key: ...
[ "def", "fromXml", "(", "cls", ",", "xparent", ")", ":", "output", "=", "cls", "(", ")", "for", "xentry", "in", "xparent", ":", "key", "=", "xentry", ".", "get", "(", "'key'", ")", "if", "not", "key", ":", "continue", "typ", "=", "xentry", ".", "g...
Loads the settings for this dataset to the inputted parent xml. :param xparent | <xml.etree.ElementTree.Element>
[ "Loads", "the", "settings", "for", "this", "dataset", "to", "the", "inputted", "parent", "xml", ".", ":", "param", "xparent", "|", "<xml", ".", "etree", ".", "ElementTree", ".", "Element", ">" ]
python
train
25.391304
saltstack/salt
salt/cli/support/collector.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/support/collector.py#L409-L419
def _get_action_type(self, action): ''' Get action type. :param action: :return: ''' action_name = next(iter(action or {'': None})) if ':' not in action_name: action_name = '{}:{}'.format(self.CALL_TYPE, action_name) return action_name.split('...
[ "def", "_get_action_type", "(", "self", ",", "action", ")", ":", "action_name", "=", "next", "(", "iter", "(", "action", "or", "{", "''", ":", "None", "}", ")", ")", "if", "':'", "not", "in", "action_name", ":", "action_name", "=", "'{}:{}'", ".", "f...
Get action type. :param action: :return:
[ "Get", "action", "type", ".", ":", "param", "action", ":", ":", "return", ":" ]
python
train
29.454545
kevinconway/daemons
daemons/startstop/simple.py
https://github.com/kevinconway/daemons/blob/b0fe0db5821171a35aa9078596d19d630c570b38/daemons/startstop/simple.py#L24-L49
def start(self): """Start the process with daemonization. If the process is already started this call should exit with code ALREADY_RUNNING. Otherwise it must call the 'daemonize' method and then call 'run'. """ if self.pid is not None: LOG.error( ...
[ "def", "start", "(", "self", ")", ":", "if", "self", ".", "pid", "is", "not", "None", ":", "LOG", ".", "error", "(", "\"The process is already running with pid {0}.\"", ".", "format", "(", "self", ".", "pid", ")", ")", "sys", ".", "exit", "(", "exit", ...
Start the process with daemonization. If the process is already started this call should exit with code ALREADY_RUNNING. Otherwise it must call the 'daemonize' method and then call 'run'.
[ "Start", "the", "process", "with", "daemonization", "." ]
python
train
27.076923
apple/turicreate
src/unity/python/turicreate/toolkits/object_detector/util/_visualization.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/object_detector/util/_visualization.py#L14-L19
def _string_hash(s): """String hash (djb2) with consistency between py2/py3 and persistency between runs (unlike `hash`).""" h = 5381 for c in s: h = h * 33 + ord(c) return h
[ "def", "_string_hash", "(", "s", ")", ":", "h", "=", "5381", "for", "c", "in", "s", ":", "h", "=", "h", "*", "33", "+", "ord", "(", "c", ")", "return", "h" ]
String hash (djb2) with consistency between py2/py3 and persistency between runs (unlike `hash`).
[ "String", "hash", "(", "djb2", ")", "with", "consistency", "between", "py2", "/", "py3", "and", "persistency", "between", "runs", "(", "unlike", "hash", ")", "." ]
python
train
32.166667
Riparo/nougat
nougat/utils.py
https://github.com/Riparo/nougat/blob/8453bc37e0b782f296952f0a418532ebbbcd74f3/nougat/utils.py#L16-L38
def is_middleware(func) -> bool: """ test whether it is a middleware :return: Boolean """ if inspect.isfunction(func): _check = func _name = func.__name__ else: _check = func.__call__ _name = func.__class__.__name__ if not inspect.iscoroutinefunction(_check)...
[ "def", "is_middleware", "(", "func", ")", "->", "bool", ":", "if", "inspect", ".", "isfunction", "(", "func", ")", ":", "_check", "=", "func", "_name", "=", "func", ".", "__name__", "else", ":", "_check", "=", "func", ".", "__call__", "_name", "=", "...
test whether it is a middleware :return: Boolean
[ "test", "whether", "it", "is", "a", "middleware", ":", "return", ":", "Boolean" ]
python
train
30.913043
ThreatConnect-Inc/tcex
tcex/tcex_bin_run.py
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_run.py#L1516-L1561
def stage_tc_batch(self, owner, staging_data): """Stage data in ThreatConnect Platform using batch API. Args: owner (str): The ThreatConnect owner to submit batch job. staging_data (dict): A dict of ThreatConnect batch data. """ batch = self.tcex.batch(owner) ...
[ "def", "stage_tc_batch", "(", "self", ",", "owner", ",", "staging_data", ")", ":", "batch", "=", "self", ".", "tcex", ".", "batch", "(", "owner", ")", "for", "group", "in", "staging_data", ".", "get", "(", "'group'", ")", "or", "[", "]", ":", "# add ...
Stage data in ThreatConnect Platform using batch API. Args: owner (str): The ThreatConnect owner to submit batch job. staging_data (dict): A dict of ThreatConnect batch data.
[ "Stage", "data", "in", "ThreatConnect", "Platform", "using", "batch", "API", "." ]
python
train
46.543478
quantopian/pyfolio
pyfolio/risk.py
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/risk.py#L328-L354
def plot_cap_exposures_longshort(long_exposures, short_exposures, ax=None): """ Plots outputs of compute_cap_exposures as area charts Parameters ---------- long_exposures, short_exposures : arrays Arrays of long and short market cap exposures (output of compute_cap_exposures). "...
[ "def", "plot_cap_exposures_longshort", "(", "long_exposures", ",", "short_exposures", ",", "ax", "=", "None", ")", ":", "if", "ax", "is", "None", ":", "ax", "=", "plt", ".", "gca", "(", ")", "color_list", "=", "plt", ".", "cm", ".", "gist_rainbow", "(", ...
Plots outputs of compute_cap_exposures as area charts Parameters ---------- long_exposures, short_exposures : arrays Arrays of long and short market cap exposures (output of compute_cap_exposures).
[ "Plots", "outputs", "of", "compute_cap_exposures", "as", "area", "charts" ]
python
valid
35.074074
boriel/zxbasic
asmparse.py
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L826-L832
def p_namespace(p): """ asm : NAMESPACE ID """ global NAMESPACE NAMESPACE = normalize_namespace(p[2]) __DEBUG__('Setting namespace to ' + (NAMESPACE.rstrip(DOT) or DOT), level=1)
[ "def", "p_namespace", "(", "p", ")", ":", "global", "NAMESPACE", "NAMESPACE", "=", "normalize_namespace", "(", "p", "[", "2", "]", ")", "__DEBUG__", "(", "'Setting namespace to '", "+", "(", "NAMESPACE", ".", "rstrip", "(", "DOT", ")", "or", "DOT", ")", ...
asm : NAMESPACE ID
[ "asm", ":", "NAMESPACE", "ID" ]
python
train
27.571429
ergo/ziggurat_foundations
ziggurat_foundations/models/base.py
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/base.py#L45-L51
def get_appstruct(self): """ return list of tuples keys and values corresponding to this model's data """ result = [] for k in self._get_keys(): result.append((k, getattr(self, k))) return result
[ "def", "get_appstruct", "(", "self", ")", ":", "result", "=", "[", "]", "for", "k", "in", "self", ".", "_get_keys", "(", ")", ":", "result", ".", "append", "(", "(", "k", ",", "getattr", "(", "self", ",", "k", ")", ")", ")", "return", "result" ]
return list of tuples keys and values corresponding to this model's data
[ "return", "list", "of", "tuples", "keys", "and", "values", "corresponding", "to", "this", "model", "s", "data" ]
python
train
34.428571
learningequality/morango
morango/controller.py
https://github.com/learningequality/morango/blob/c3ec2554b026f65ac5f0fc5c9d439277fbac14f9/morango/controller.py#L5-L13
def _self_referential_fk(klass_model): """ Return whether this model has a self ref FK, and the name for the field """ for f in klass_model._meta.concrete_fields: if f.related_model: if issubclass(klass_model, f.related_model): return f.attname return None
[ "def", "_self_referential_fk", "(", "klass_model", ")", ":", "for", "f", "in", "klass_model", ".", "_meta", ".", "concrete_fields", ":", "if", "f", ".", "related_model", ":", "if", "issubclass", "(", "klass_model", ",", "f", ".", "related_model", ")", ":", ...
Return whether this model has a self ref FK, and the name for the field
[ "Return", "whether", "this", "model", "has", "a", "self", "ref", "FK", "and", "the", "name", "for", "the", "field" ]
python
valid
33.777778
miyakogi/wdom
wdom/options.py
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/options.py#L133-L145
def parse_command_line() -> Namespace: """Parse command line options and set them to ``config``. This function skips unknown command line options. After parsing options, set log level and set options in ``tornado.options``. """ import tornado.options parser.parse_known_args(namespace=config) ...
[ "def", "parse_command_line", "(", ")", "->", "Namespace", ":", "import", "tornado", ".", "options", "parser", ".", "parse_known_args", "(", "namespace", "=", "config", ")", "set_loglevel", "(", ")", "# set new log level based on commanline option", "for", "k", ",", ...
Parse command line options and set them to ``config``. This function skips unknown command line options. After parsing options, set log level and set options in ``tornado.options``.
[ "Parse", "command", "line", "options", "and", "set", "them", "to", "config", "." ]
python
train
39.538462
peterwittek/somoclu
src/Python/somoclu/train.py
https://github.com/peterwittek/somoclu/blob/b31dfbeba6765e64aedddcf8259626d6684f5349/src/Python/somoclu/train.py#L183-L231
def train(self, data=None, epochs=10, radius0=0, radiusN=1, radiuscooling="linear", scale0=0.1, scaleN=0.01, scalecooling="linear"): """Train the map on the current data in the Somoclu object. :param data: Optional parameter to provide training data. It is not ...
[ "def", "train", "(", "self", ",", "data", "=", "None", ",", "epochs", "=", "10", ",", "radius0", "=", "0", ",", "radiusN", "=", "1", ",", "radiuscooling", "=", "\"linear\"", ",", "scale0", "=", "0.1", ",", "scaleN", "=", "0.01", ",", "scalecooling", ...
Train the map on the current data in the Somoclu object. :param data: Optional parameter to provide training data. It is not necessary if the data was added via the method `update_data`. :type data: 2D numpy.array of float32. :param epochs: The number of...
[ "Train", "the", "map", "on", "the", "current", "data", "in", "the", "Somoclu", "object", ".", ":", "param", "data", ":", "Optional", "parameter", "to", "provide", "training", "data", ".", "It", "is", "not", "necessary", "if", "the", "data", "was", "added...
python
train
54.408163
jborean93/smbprotocol
smbprotocol/tree.py
https://github.com/jborean93/smbprotocol/blob/d8eb00fbc824f97d0f4946e3f768c5e6c723499a/smbprotocol/tree.py#L250-L275
def disconnect(self): """ Disconnects the tree connection. """ if not self._connected: return log.info("Session: %s, Tree: %s - Disconnecting from Tree Connect" % (self.session.username, self.share_name)) req = SMB2TreeDisconnect() l...
[ "def", "disconnect", "(", "self", ")", ":", "if", "not", "self", ".", "_connected", ":", "return", "log", ".", "info", "(", "\"Session: %s, Tree: %s - Disconnecting from Tree Connect\"", "%", "(", "self", ".", "session", ".", "username", ",", "self", ".", "sha...
Disconnects the tree connection.
[ "Disconnects", "the", "tree", "connection", "." ]
python
train
41.653846
log2timeline/plaso
plaso/analyzers/hashers/manager.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/analyzers/hashers/manager.py#L149-L166
def RegisterHasher(cls, hasher_class): """Registers a hasher class. The hasher classes are identified based on their lower case name. Args: hasher_class (type): class object of the hasher. Raises: KeyError: if hasher class is already set for the corresponding name. """ hasher_name...
[ "def", "RegisterHasher", "(", "cls", ",", "hasher_class", ")", ":", "hasher_name", "=", "hasher_class", ".", "NAME", ".", "lower", "(", ")", "if", "hasher_name", "in", "cls", ".", "_hasher_classes", ":", "raise", "KeyError", "(", "(", "'hasher class already se...
Registers a hasher class. The hasher classes are identified based on their lower case name. Args: hasher_class (type): class object of the hasher. Raises: KeyError: if hasher class is already set for the corresponding name.
[ "Registers", "a", "hasher", "class", "." ]
python
train
30.388889
mabuchilab/QNET
src/qnet/printing/treeprinting.py
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/printing/treeprinting.py#L11-L22
def _shorten_render(renderer, max_len): """Return a modified that returns the representation of expr, or '...' if that representation is longer than `max_len`""" def short_renderer(expr): res = renderer(expr) if len(res) > max_len: return '...' else: return r...
[ "def", "_shorten_render", "(", "renderer", ",", "max_len", ")", ":", "def", "short_renderer", "(", "expr", ")", ":", "res", "=", "renderer", "(", "expr", ")", "if", "len", "(", "res", ")", ">", "max_len", ":", "return", "'...'", "else", ":", "return", ...
Return a modified that returns the representation of expr, or '...' if that representation is longer than `max_len`
[ "Return", "a", "modified", "that", "returns", "the", "representation", "of", "expr", "or", "...", "if", "that", "representation", "is", "longer", "than", "max_len" ]
python
train
28.166667
saltstack/salt
salt/modules/dracr.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dracr.py#L1285-L1314
def set_chassis_location(location, host=None, admin_username=None, admin_password=None): ''' Set the location of the chassis. location The name of the location to be set on the chassis. host The chassis host. ...
[ "def", "set_chassis_location", "(", "location", ",", "host", "=", "None", ",", "admin_username", "=", "None", ",", "admin_password", "=", "None", ")", ":", "return", "__execute_cmd", "(", "'setsysinfo -c chassislocation {0}'", ".", "format", "(", "location", ")", ...
Set the location of the chassis. location The name of the location to be set on the chassis. host The chassis host. admin_username The username used to access the chassis. admin_password The password used to access the chassis. CLI Example: .. code-block:: b...
[ "Set", "the", "location", "of", "the", "chassis", "." ]
python
train
27.166667
tensorflow/probability
tensorflow_probability/python/mcmc/replica_exchange_mc.py
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/mcmc/replica_exchange_mc.py#L519-L556
def bootstrap_results(self, init_state): """Returns an object with the same type as returned by `one_step`. Args: init_state: `Tensor` or Python `list` of `Tensor`s representing the initial state(s) of the Markov chain(s). Returns: kernel_results: A (possibly nested) `tuple`, `namedtup...
[ "def", "bootstrap_results", "(", "self", ",", "init_state", ")", ":", "with", "tf", ".", "compat", ".", "v1", ".", "name_scope", "(", "name", "=", "mcmc_util", ".", "make_name", "(", "self", ".", "name", ",", "'remc'", ",", "'bootstrap_results'", ")", ",...
Returns an object with the same type as returned by `one_step`. Args: init_state: `Tensor` or Python `list` of `Tensor`s representing the initial state(s) of the Markov chain(s). Returns: kernel_results: A (possibly nested) `tuple`, `namedtuple` or `list` of `Tensor`s representing ...
[ "Returns", "an", "object", "with", "the", "same", "type", "as", "returned", "by", "one_step", "." ]
python
test
35.552632
marcinmiklitz/pywindow
pywindow/trajectory.py
https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/trajectory.py#L1262-L1297
def _map_trajectory(self): """ Return filepath as a class attribute""" self.trajectory_map = {} with open(self.filepath, 'r') as trajectory_file: with closing( mmap( trajectory_file.fileno(), 0, access=ACCESS_READ)) ...
[ "def", "_map_trajectory", "(", "self", ")", ":", "self", ".", "trajectory_map", "=", "{", "}", "with", "open", "(", "self", ".", "filepath", ",", "'r'", ")", "as", "trajectory_file", ":", "with", "closing", "(", "mmap", "(", "trajectory_file", ".", "file...
Return filepath as a class attribute
[ "Return", "filepath", "as", "a", "class", "attribute" ]
python
train
48.888889
tanghaibao/jcvi
jcvi/apps/grid.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/apps/grid.py#L490-L545
def kill(args): """ %prog kill [options] JOBNAMEPAT/JOBIDs Kill jobs based on JOBNAME pattern matching (case-sensitive) or list of JOBIDs (comma separated) Examples: %prog kill "pyth*" # Use regex %prog kill 160253,160245,160252 # Use list of job ids %prog kill all ...
[ "def", "kill", "(", "args", ")", ":", "import", "shlex", "from", "jcvi", ".", "apps", ".", "base", "import", "sh", ",", "getusername", "from", "subprocess", "import", "check_output", ",", "CalledProcessError", "import", "xml", ".", "etree", ".", "ElementTree...
%prog kill [options] JOBNAMEPAT/JOBIDs Kill jobs based on JOBNAME pattern matching (case-sensitive) or list of JOBIDs (comma separated) Examples: %prog kill "pyth*" # Use regex %prog kill 160253,160245,160252 # Use list of job ids %prog kill all # Everyth...
[ "%prog", "kill", "[", "options", "]", "JOBNAMEPAT", "/", "JOBIDs" ]
python
train
31.535714
JohnVinyard/featureflow
featureflow/feature.py
https://github.com/JohnVinyard/featureflow/blob/7731487b00e38fa4f58c88b7881870fda2d69fdb/featureflow/feature.py#L107-L130
def copy( self, extractor=None, needs=None, store=None, data_writer=None, persistence=None, extractor_args=None): """ Use self as a template to build a new feature, replacing values in kwargs """ ...
[ "def", "copy", "(", "self", ",", "extractor", "=", "None", ",", "needs", "=", "None", ",", "store", "=", "None", ",", "data_writer", "=", "None", ",", "persistence", "=", "None", ",", "extractor_args", "=", "None", ")", ":", "f", "=", "Feature", "(",...
Use self as a template to build a new feature, replacing values in kwargs
[ "Use", "self", "as", "a", "template", "to", "build", "a", "new", "feature", "replacing", "values", "in", "kwargs" ]
python
train
29.083333
RudolfCardinal/pythonlib
cardinal_pythonlib/ui.py
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/ui.py#L63-L81
def get_save_as_filename(defaultfilename: str, defaultextension: str, title: str = "Save As") -> str: """ Provides a GUI "Save As" dialogue (via ``tkinter``) and returns the filename. """ root = tkinter.Tk() # create and get Tk topmost window # ...
[ "def", "get_save_as_filename", "(", "defaultfilename", ":", "str", ",", "defaultextension", ":", "str", ",", "title", ":", "str", "=", "\"Save As\"", ")", "->", "str", ":", "root", "=", "tkinter", ".", "Tk", "(", ")", "# create and get Tk topmost window", "# (...
Provides a GUI "Save As" dialogue (via ``tkinter``) and returns the filename.
[ "Provides", "a", "GUI", "Save", "As", "dialogue", "(", "via", "tkinter", ")", "and", "returns", "the", "filename", "." ]
python
train
40.526316
PMEAL/OpenPNM
openpnm/models/geometry/throat_surface_area.py
https://github.com/PMEAL/OpenPNM/blob/0547b5724ffedc0a593aae48639d36fe10e0baed/openpnm/models/geometry/throat_surface_area.py#L54-L78
def extrusion(target, throat_perimeter='throat.perimeter', throat_length='throat.length'): r""" Calculate surface area for an arbitrary shaped throat give the perimeter and length. Parameters ---------- target : OpenPNM Object The object which this model is associated with...
[ "def", "extrusion", "(", "target", ",", "throat_perimeter", "=", "'throat.perimeter'", ",", "throat_length", "=", "'throat.length'", ")", ":", "P", "=", "target", "[", "throat_perimeter", "]", "L", "=", "target", "[", "throat_length", "]", "value", "=", "P", ...
r""" Calculate surface area for an arbitrary shaped throat give the perimeter and length. Parameters ---------- target : OpenPNM Object The object which this model is associated with. This controls the length of the calculated array, and also provides access to other necessa...
[ "r", "Calculate", "surface", "area", "for", "an", "arbitrary", "shaped", "throat", "give", "the", "perimeter", "and", "length", "." ]
python
train
30.28
ensime/ensime-vim
ensime_shared/ensime.py
https://github.com/ensime/ensime-vim/blob/caa734e84f002b25446c615706283a74edd4ecfe/ensime_shared/ensime.py#L67-L79
def client_status(self, config_path): """Get status of client for a project, given path to its config.""" c = self.client_for(config_path) status = "stopped" if not c or not c.ensime: status = 'unloaded' elif c.ensime.is_ready(): status = 'ready' e...
[ "def", "client_status", "(", "self", ",", "config_path", ")", ":", "c", "=", "self", ".", "client_for", "(", "config_path", ")", "status", "=", "\"stopped\"", "if", "not", "c", "or", "not", "c", ".", "ensime", ":", "status", "=", "'unloaded'", "elif", ...
Get status of client for a project, given path to its config.
[ "Get", "status", "of", "client", "for", "a", "project", "given", "path", "to", "its", "config", "." ]
python
train
34.692308
marcomusy/vtkplotter
vtkplotter/actors.py
https://github.com/marcomusy/vtkplotter/blob/692c3396782722ec525bc1346a26999868c650c6/vtkplotter/actors.py#L2429-L2453
def crop(self, top=None, bottom=None, right=None, left=None): """Crop image. :param float top: fraction to crop from the top margin :param float bottom: fraction to crop from the bottom margin :param float left: fraction to crop from the left margin :param float right: f...
[ "def", "crop", "(", "self", ",", "top", "=", "None", ",", "bottom", "=", "None", ",", "right", "=", "None", ",", "left", "=", "None", ")", ":", "extractVOI", "=", "vtk", ".", "vtkExtractVOI", "(", ")", "extractVOI", ".", "SetInputData", "(", "self", ...
Crop image. :param float top: fraction to crop from the top margin :param float bottom: fraction to crop from the bottom margin :param float left: fraction to crop from the left margin :param float right: fraction to crop from the right margin
[ "Crop", "image", ".", ":", "param", "float", "top", ":", "fraction", "to", "crop", "from", "the", "top", "margin", ":", "param", "float", "bottom", ":", "fraction", "to", "crop", "from", "the", "bottom", "margin", ":", "param", "float", "left", ":", "f...
python
train
42.28
ray-project/ray
python/ray/log_monitor.py
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/log_monitor.py#L210-L223
def run(self): """Run the log monitor. This will query Redis once every second to check if there are new log files to monitor. It will also store those log files in Redis. """ while True: self.update_log_filenames() self.open_closed_files() an...
[ "def", "run", "(", "self", ")", ":", "while", "True", ":", "self", ".", "update_log_filenames", "(", ")", "self", ".", "open_closed_files", "(", ")", "anything_published", "=", "self", ".", "check_log_files_and_publish_updates", "(", ")", "# If nothing was publish...
Run the log monitor. This will query Redis once every second to check if there are new log files to monitor. It will also store those log files in Redis.
[ "Run", "the", "log", "monitor", "." ]
python
train
40.785714
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_interface_ext.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_interface_ext.py#L880-L896
def get_interface_detail_output_interface_line_protocol_exception_info(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_interface_detail = ET.Element("get_interface_detail") config = get_interface_detail output = ET.SubElement(get_interface_de...
[ "def", "get_interface_detail_output_interface_line_protocol_exception_info", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "get_interface_detail", "=", "ET", ".", "Element", "(", "\"get_interface_detail\""...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
54
spyder-ide/spyder
spyder/app/mainwindow.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/mainwindow.py#L2859-L2871
def apply_statusbar_settings(self): """Update status bar widgets settings""" show_status_bar = CONF.get('main', 'show_status_bar') self.statusBar().setVisible(show_status_bar) if show_status_bar: for widget, name in ((self.mem_status, 'memory_usage'), ...
[ "def", "apply_statusbar_settings", "(", "self", ")", ":", "show_status_bar", "=", "CONF", ".", "get", "(", "'main'", ",", "'show_status_bar'", ")", "self", ".", "statusBar", "(", ")", ".", "setVisible", "(", "show_status_bar", ")", "if", "show_status_bar", ":"...
Update status bar widgets settings
[ "Update", "status", "bar", "widgets", "settings" ]
python
train
45.307692
bitesofcode/projexui
projexui/widgets/xnodewidget/xnodeconnection.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xnodewidget/xnodeconnection.py#L1438-L1449
def setDirty(self, state=True): """ Flags the connection as being dirty and needing a rebuild. :param state | <bool> """ self._dirty = state # set if this connection should be visible if self._inputNode and self._outputNode: vis = self...
[ "def", "setDirty", "(", "self", ",", "state", "=", "True", ")", ":", "self", ".", "_dirty", "=", "state", "# set if this connection should be visible", "if", "self", ".", "_inputNode", "and", "self", ".", "_outputNode", ":", "vis", "=", "self", ".", "_inputN...
Flags the connection as being dirty and needing a rebuild. :param state | <bool>
[ "Flags", "the", "connection", "as", "being", "dirty", "and", "needing", "a", "rebuild", ".", ":", "param", "state", "|", "<bool", ">" ]
python
train
33.166667
manns/pyspread
pyspread/src/actions/_grid_actions.py
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L756-L770
def insert_tabs(self, tab, no_tabs=1): """Adds no_tabs tabs before table, appends if tab > maxtabs and marks grid as changed """ # Mark content as changed post_command_event(self.main_window, self.ContentChangedMsg) self.code_array.insert(tab, no_tabs, axis=2) ...
[ "def", "insert_tabs", "(", "self", ",", "tab", ",", "no_tabs", "=", "1", ")", ":", "# Mark content as changed", "post_command_event", "(", "self", ".", "main_window", ",", "self", ".", "ContentChangedMsg", ")", "self", ".", "code_array", ".", "insert", "(", ...
Adds no_tabs tabs before table, appends if tab > maxtabs and marks grid as changed
[ "Adds", "no_tabs", "tabs", "before", "table", "appends", "if", "tab", ">", "maxtabs" ]
python
train
30.4
biolink/biolink-model
metamodel/utils/generator.py
https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/utils/generator.py#L95-L106
def cls_slots(self, cls: CLASS_OR_CLASSNAME) -> List[SlotDefinition]: """ Return the list of slots directly included in the class definition. Includes slots whose domain is cls -- as declared in slot.domain or class.slots Does not include slots declared in mixins, apply_to or is_a links ...
[ "def", "cls_slots", "(", "self", ",", "cls", ":", "CLASS_OR_CLASSNAME", ")", "->", "List", "[", "SlotDefinition", "]", ":", "if", "not", "isinstance", "(", "cls", ",", "ClassDefinition", ")", ":", "cls", "=", "self", ".", "schema", ".", "classes", "[", ...
Return the list of slots directly included in the class definition. Includes slots whose domain is cls -- as declared in slot.domain or class.slots Does not include slots declared in mixins, apply_to or is_a links @param cls: class name or class definition name @return: all direct cla...
[ "Return", "the", "list", "of", "slots", "directly", "included", "in", "the", "class", "definition", ".", "Includes", "slots", "whose", "domain", "is", "cls", "--", "as", "declared", "in", "slot", ".", "domain", "or", "class", ".", "slots" ]
python
train
46.666667
apache/spark
python/pyspark/mllib/evaluation.py
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/evaluation.py#L504-L511
def precision(self, label=None): """ Returns precision or precision for a given label (category) if specified. """ if label is None: return self.call("precision") else: return self.call("precision", float(label))
[ "def", "precision", "(", "self", ",", "label", "=", "None", ")", ":", "if", "label", "is", "None", ":", "return", "self", ".", "call", "(", "\"precision\"", ")", "else", ":", "return", "self", ".", "call", "(", "\"precision\"", ",", "float", "(", "la...
Returns precision or precision for a given label (category) if specified.
[ "Returns", "precision", "or", "precision", "for", "a", "given", "label", "(", "category", ")", "if", "specified", "." ]
python
train
33.625
davidfokkema/artist
artist/multi_plot.py
https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/multi_plot.py#L86-L95
def set_empty_for_all(self, row_column_list): """Keep all specified subplots completely empty. :param row_column_list: a list containing (row, column) tuples to specify the subplots, or None to indicate *all* subplots. :type row_column_list: list or None """ for row...
[ "def", "set_empty_for_all", "(", "self", ",", "row_column_list", ")", ":", "for", "row", ",", "column", "in", "row_column_list", ":", "self", ".", "set_empty", "(", "row", ",", "column", ")" ]
Keep all specified subplots completely empty. :param row_column_list: a list containing (row, column) tuples to specify the subplots, or None to indicate *all* subplots. :type row_column_list: list or None
[ "Keep", "all", "specified", "subplots", "completely", "empty", "." ]
python
train
37.9
fabioz/PyDev.Debugger
_pydev_imps/_pydev_SimpleXMLRPCServer.py
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydev_imps/_pydev_SimpleXMLRPCServer.py#L544-L553
def handle_xmlrpc(self, request_text): """Handle a single XML-RPC request""" response = self._marshaled_dispatch(request_text) sys.stdout.write('Content-Type: text/xml\n') sys.stdout.write('Content-Length: %d\n' % len(response)) sys.stdout.write('\n') sys.stdout.write(...
[ "def", "handle_xmlrpc", "(", "self", ",", "request_text", ")", ":", "response", "=", "self", ".", "_marshaled_dispatch", "(", "request_text", ")", "sys", ".", "stdout", ".", "write", "(", "'Content-Type: text/xml\\n'", ")", "sys", ".", "stdout", ".", "write", ...
Handle a single XML-RPC request
[ "Handle", "a", "single", "XML", "-", "RPC", "request" ]
python
train
32
zhanglab/psamm
psamm/fastcore.py
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fastcore.py#L89-L114
def lp10(self, subset_k, subset_p, weights={}): """Force reactions in K above epsilon while minimizing support of P. This program forces reactions in subset K to attain flux > epsilon while minimizing the sum of absolute flux values for reactions in subset P (L1-regularization). ...
[ "def", "lp10", "(", "self", ",", "subset_k", ",", "subset_p", ",", "weights", "=", "{", "}", ")", ":", "if", "self", ".", "_z", "is", "None", ":", "self", ".", "_add_minimization_vars", "(", ")", "positive", "=", "set", "(", "subset_k", ")", "-", "...
Force reactions in K above epsilon while minimizing support of P. This program forces reactions in subset K to attain flux > epsilon while minimizing the sum of absolute flux values for reactions in subset P (L1-regularization).
[ "Force", "reactions", "in", "K", "above", "epsilon", "while", "minimizing", "support", "of", "P", "." ]
python
train
34.115385
googledatalab/pydatalab
google/datalab/storage/_api.py
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/storage/_api.py#L124-L146
def object_download(self, bucket, key, start_offset=0, byte_count=None): """Reads the contents of an object as text. Args: bucket: the name of the bucket containing the object. key: the key of the object to be read. start_offset: the start offset of bytes to read. byte_count: the number...
[ "def", "object_download", "(", "self", ",", "bucket", ",", "key", ",", "start_offset", "=", "0", ",", "byte_count", "=", "None", ")", ":", "args", "=", "{", "'alt'", ":", "'media'", "}", "headers", "=", "{", "}", "if", "start_offset", ">", "0", "or",...
Reads the contents of an object as text. Args: bucket: the name of the bucket containing the object. key: the key of the object to be read. start_offset: the start offset of bytes to read. byte_count: the number of bytes to read. If None, it reads to the end. Returns: The text con...
[ "Reads", "the", "contents", "of", "an", "object", "as", "text", "." ]
python
train
42.347826
romanz/trezor-agent
libagent/gpg/protocol.py
https://github.com/romanz/trezor-agent/blob/513b1259c4d7aca5f88cd958edc11828d0712f1b/libagent/gpg/protocol.py#L209-L217
def data(self): """Data for packet creation.""" header = struct.pack('>BLB', 4, # version self.created, # creation self.algo_id) # public key algorithm ID oid = util.prefix_len('>B', self.curve_i...
[ "def", "data", "(", "self", ")", ":", "header", "=", "struct", ".", "pack", "(", "'>BLB'", ",", "4", ",", "# version", "self", ".", "created", ",", "# creation", "self", ".", "algo_id", ")", "# public key algorithm ID", "oid", "=", "util", ".", "prefix_l...
Data for packet creation.
[ "Data", "for", "packet", "creation", "." ]
python
train
49
jobovy/galpy
galpy/potential/MiyamotoNagaiPotential.py
https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/potential/MiyamotoNagaiPotential.py#L106-L129
def _zforce(self,R,z,phi=0.,t=0.): """ NAME: _zforce PURPOSE: evaluate the vertical force for this potential INPUT: R - Galactocentric cylindrical radius z - vertical height phi - azimuth t - time OUTPUT: ...
[ "def", "_zforce", "(", "self", ",", "R", ",", "z", ",", "phi", "=", "0.", ",", "t", "=", "0.", ")", ":", "sqrtbz", "=", "nu", ".", "sqrt", "(", "self", ".", "_b2", "+", "z", "**", "2.", ")", "asqrtbz", "=", "self", ".", "_a", "+", "sqrtbz",...
NAME: _zforce PURPOSE: evaluate the vertical force for this potential INPUT: R - Galactocentric cylindrical radius z - vertical height phi - azimuth t - time OUTPUT: the vertical force HISTORY: 2010-0...
[ "NAME", ":", "_zforce", "PURPOSE", ":", "evaluate", "the", "vertical", "force", "for", "this", "potential", "INPUT", ":", "R", "-", "Galactocentric", "cylindrical", "radius", "z", "-", "vertical", "height", "phi", "-", "azimuth", "t", "-", "time", "OUTPUT", ...
python
train
31.166667
quodlibet/mutagen
mutagen/ogg.py
https://github.com/quodlibet/mutagen/blob/e393df5971ba41ba5a50de9c2c9e7e5484d82c4e/mutagen/ogg.py#L243-L276
def to_packets(pages, strict=False): """Construct a list of packet data from a list of Ogg pages. If strict is true, the first page must start a new packet, and the last page must end the last packet. """ serial = pages[0].serial sequence = pages[0].sequence pac...
[ "def", "to_packets", "(", "pages", ",", "strict", "=", "False", ")", ":", "serial", "=", "pages", "[", "0", "]", ".", "serial", "sequence", "=", "pages", "[", "0", "]", ".", "sequence", "packets", "=", "[", "]", "if", "strict", ":", "if", "pages", ...
Construct a list of packet data from a list of Ogg pages. If strict is true, the first page must start a new packet, and the last page must end the last packet.
[ "Construct", "a", "list", "of", "packet", "data", "from", "a", "list", "of", "Ogg", "pages", "." ]
python
train
33.823529
saltstack/salt
salt/cloud/clouds/gce.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L452-L466
def __get_host(node, vm_): ''' Return public IP, private IP, or hostname for the libcloud 'node' object ''' if __get_ssh_interface(vm_) == 'private_ips' or vm_['external_ip'] is None: ip_address = node.private_ips[0] log.info('Salt node data. Private_ip: %s', ip_address) else: ...
[ "def", "__get_host", "(", "node", ",", "vm_", ")", ":", "if", "__get_ssh_interface", "(", "vm_", ")", "==", "'private_ips'", "or", "vm_", "[", "'external_ip'", "]", "is", "None", ":", "ip_address", "=", "node", ".", "private_ips", "[", "0", "]", "log", ...
Return public IP, private IP, or hostname for the libcloud 'node' object
[ "Return", "public", "IP", "private", "IP", "or", "hostname", "for", "the", "libcloud", "node", "object" ]
python
train
31.266667
recurly/recurly-client-python
recurly/__init__.py
https://github.com/recurly/recurly-client-python/blob/682217c4e85ec5c8d4e41519ee0620d2dc4d84d7/recurly/__init__.py#L346-L360
def update_billing_info(self, billing_info): """Change this account's billing information to the given `BillingInfo`.""" url = urljoin(self._url, '/billing_info') response = billing_info.http_request(url, 'PUT', billing_info, {'Content-Type': 'application/xml; charset=utf-8'}) ...
[ "def", "update_billing_info", "(", "self", ",", "billing_info", ")", ":", "url", "=", "urljoin", "(", "self", ".", "_url", ",", "'/billing_info'", ")", "response", "=", "billing_info", ".", "http_request", "(", "url", ",", "'PUT'", ",", "billing_info", ",", ...
Change this account's billing information to the given `BillingInfo`.
[ "Change", "this", "account", "s", "billing", "information", "to", "the", "given", "BillingInfo", "." ]
python
train
47.133333
UCL-INGI/INGInious
inginious/frontend/accessible_time.py
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/accessible_time.py#L11-L25
def parse_date(date, default=None): """ Parse a valid date """ if date == "": if default is not None: return default else: raise Exception("Unknown format for " + date) for format_type in ["%Y-%m-%d %H:%M:%S", "%Y-%m-%d %H:%M", "%Y-%m-%d %H", "%Y-%m-%d", "%d/%m/%Y %H...
[ "def", "parse_date", "(", "date", ",", "default", "=", "None", ")", ":", "if", "date", "==", "\"\"", ":", "if", "default", "is", "not", "None", ":", "return", "default", "else", ":", "raise", "Exception", "(", "\"Unknown format for \"", "+", "date", ")",...
Parse a valid date
[ "Parse", "a", "valid", "date" ]
python
train
36.466667
etcher-be/epab
epab/utils/_repo.py
https://github.com/etcher-be/epab/blob/024cde74d058281aa66e6e4b7b71dccbe803b1c1/epab/utils/_repo.py#L54-L71
def list_tags(self, pattern: str = None) -> typing.List[str]: """ Returns list of tags, optionally matching "pattern" :param pattern: optional pattern to filter results :type pattern: str :return: existing tags :rtype: list of str """ tags: typing.List[st...
[ "def", "list_tags", "(", "self", ",", "pattern", ":", "str", "=", "None", ")", "->", "typing", ".", "List", "[", "str", "]", ":", "tags", ":", "typing", ".", "List", "[", "str", "]", "=", "[", "str", "(", "tag", ")", "for", "tag", "in", "self",...
Returns list of tags, optionally matching "pattern" :param pattern: optional pattern to filter results :type pattern: str :return: existing tags :rtype: list of str
[ "Returns", "list", "of", "tags", "optionally", "matching", "pattern" ]
python
train
37.944444
jhuapl-boss/intern
intern/service/boss/project.py
https://github.com/jhuapl-boss/intern/blob/d8fc6df011d8f212c87e6a1fd4cc21cfb5d103ed/intern/service/boss/project.py#L376-L386
def delete_user(self, user): """Delete the given user. Args: user (string): User name. Raises: requests.HTTPError on failure. """ self.service.delete_user( user, self.url_prefix, self.auth, self.session, self.session_send_opts)
[ "def", "delete_user", "(", "self", ",", "user", ")", ":", "self", ".", "service", ".", "delete_user", "(", "user", ",", "self", ".", "url_prefix", ",", "self", ".", "auth", ",", "self", ".", "session", ",", "self", ".", "session_send_opts", ")" ]
Delete the given user. Args: user (string): User name. Raises: requests.HTTPError on failure.
[ "Delete", "the", "given", "user", "." ]
python
train
26.818182
pysathq/pysat
pysat/card.py
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/pysat/card.py#L220-L282
def atleast(cls, lits, bound=1, top_id=None, encoding=EncType.seqcounter): """ This method can be used for creating a CNF encoding of an AtLeastK constraint, i.e. of :math:`\sum_{i=1}^{n}{x_i}\geq k`. The method takes 1 mandatory argument ``lits`` and 3 default arguments can ...
[ "def", "atleast", "(", "cls", ",", "lits", ",", "bound", "=", "1", ",", "top_id", "=", "None", ",", "encoding", "=", "EncType", ".", "seqcounter", ")", ":", "if", "encoding", "<", "0", "or", "encoding", ">", "9", ":", "raise", "(", "NoSuchEncodingErr...
This method can be used for creating a CNF encoding of an AtLeastK constraint, i.e. of :math:`\sum_{i=1}^{n}{x_i}\geq k`. The method takes 1 mandatory argument ``lits`` and 3 default arguments can be specified: ``bound``, ``top_id``, and ``encoding``. :param lits: a list...
[ "This", "method", "can", "be", "used", "for", "creating", "a", "CNF", "encoding", "of", "an", "AtLeastK", "constraint", "i", ".", "e", ".", "of", ":", "math", ":", "\\", "sum_", "{", "i", "=", "1", "}", "^", "{", "n", "}", "{", "x_i", "}", "\\"...
python
train
40.634921
rwl/pylon
pylon/io/psat.py
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/psat.py#L281-L316
def _get_supply_array_construct(self): """ Returns a construct for an array of power supply data. """ bus_no = integer.setResultsName("bus_no") s_rating = real.setResultsName("s_rating") # MVA p_direction = real.setResultsName("p_direction") # CPF p_bid_max = real.setResu...
[ "def", "_get_supply_array_construct", "(", "self", ")", ":", "bus_no", "=", "integer", ".", "setResultsName", "(", "\"bus_no\"", ")", "s_rating", "=", "real", ".", "setResultsName", "(", "\"s_rating\"", ")", "# MVA", "p_direction", "=", "real", ".", "setResultsN...
Returns a construct for an array of power supply data.
[ "Returns", "a", "construct", "for", "an", "array", "of", "power", "supply", "data", "." ]
python
train
52.527778
hyperledger/indy-plenum
plenum/server/node.py
https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L2464-L2528
def processRequest(self, request: Request, frm: str): """ Handle a REQUEST from the client. If the request has already been executed, the node re-sends the reply to the client. Otherwise, the node acknowledges the client request, adds it to its list of client requests, and sends ...
[ "def", "processRequest", "(", "self", ",", "request", ":", "Request", ",", "frm", ":", "str", ")", ":", "logger", ".", "debug", "(", "\"{} received client request: {} from {}\"", ".", "format", "(", "self", ".", "name", ",", "request", ",", "frm", ")", ")"...
Handle a REQUEST from the client. If the request has already been executed, the node re-sends the reply to the client. Otherwise, the node acknowledges the client request, adds it to its list of client requests, and sends a PROPAGATE to the remaining nodes. :param request: the R...
[ "Handle", "a", "REQUEST", "from", "the", "client", ".", "If", "the", "request", "has", "already", "been", "executed", "the", "node", "re", "-", "sends", "the", "reply", "to", "the", "client", ".", "Otherwise", "the", "node", "acknowledges", "the", "client"...
python
train
42.046154
datascopeanalytics/scrubadub
scrubadub/scrubbers.py
https://github.com/datascopeanalytics/scrubadub/blob/914bda49a16130b44af43df6a2f84755477c407c/scrubadub/scrubbers.py#L44-L62
def clean(self, text, **kwargs): """This is the master method that cleans all of the filth out of the dirty dirty ``text``. All keyword arguments to this function are passed through to the ``Filth.replace_with`` method to fine-tune how the ``Filth`` is cleaned. """ if sy...
[ "def", "clean", "(", "self", ",", "text", ",", "*", "*", "kwargs", ")", ":", "if", "sys", ".", "version_info", "<", "(", "3", ",", "0", ")", ":", "# Only in Python 2. In 3 every string is a Python 2 unicode", "if", "not", "isinstance", "(", "text", ",", "u...
This is the master method that cleans all of the filth out of the dirty dirty ``text``. All keyword arguments to this function are passed through to the ``Filth.replace_with`` method to fine-tune how the ``Filth`` is cleaned.
[ "This", "is", "the", "master", "method", "that", "cleans", "all", "of", "the", "filth", "out", "of", "the", "dirty", "dirty", "text", ".", "All", "keyword", "arguments", "to", "this", "function", "are", "passed", "through", "to", "the", "Filth", ".", "re...
python
train
44.157895
saltstack/salt
salt/modules/status.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/status.py#L1254-L1431
def netdev(): ''' .. versionchanged:: 2016.3.2 Return the network device stats for this minion .. versionchanged:: 2016.11.4 Added support for AIX CLI Example: .. code-block:: bash salt '*' status.netdev ''' def linux_netdev(): ''' linux specific i...
[ "def", "netdev", "(", ")", ":", "def", "linux_netdev", "(", ")", ":", "'''\n linux specific implementation of netdev\n '''", "ret", "=", "{", "}", "try", ":", "with", "salt", ".", "utils", ".", "files", ".", "fopen", "(", "'/proc/net/dev'", ",", ...
.. versionchanged:: 2016.3.2 Return the network device stats for this minion .. versionchanged:: 2016.11.4 Added support for AIX CLI Example: .. code-block:: bash salt '*' status.netdev
[ "..", "versionchanged", "::", "2016", ".", "3", ".", "2", "Return", "the", "network", "device", "stats", "for", "this", "minion" ]
python
train
40.646067
django-leonardo/django-leonardo
leonardo/utils/settings.py
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/settings.py#L144-L162
def get_conf_from_module(mod): """return configuration from module with defaults no worry about None type """ conf = ModuleConfig(CONF_SPEC) # get imported module mod = _get_correct_module(mod) conf.set_module(mod) # extarct from default object or from module if hasattr(mod, 'defaul...
[ "def", "get_conf_from_module", "(", "mod", ")", ":", "conf", "=", "ModuleConfig", "(", "CONF_SPEC", ")", "# get imported module", "mod", "=", "_get_correct_module", "(", "mod", ")", "conf", ".", "set_module", "(", "mod", ")", "# extarct from default object or from m...
return configuration from module with defaults no worry about None type
[ "return", "configuration", "from", "module", "with", "defaults", "no", "worry", "about", "None", "type" ]
python
train
23.894737
JoeVirtual/KonFoo
konfoo/core.py
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L1105-L1121
def read_from(self, provider, **options): """ All :class:`Pointer` fields in the `Sequence` read the necessary number of bytes from the data :class:`Provider` for their referenced :attr:`~Pointer.data` object. Null pointer are ignored. :param Provider provider: data :class:`Provider`. ...
[ "def", "read_from", "(", "self", ",", "provider", ",", "*", "*", "options", ")", ":", "for", "item", "in", "iter", "(", "self", ")", ":", "# Container or Pointer", "if", "is_mixin", "(", "item", ")", ":", "item", ".", "read_from", "(", "provider", ",",...
All :class:`Pointer` fields in the `Sequence` read the necessary number of bytes from the data :class:`Provider` for their referenced :attr:`~Pointer.data` object. Null pointer are ignored. :param Provider provider: data :class:`Provider`. :keyword bool nested: if ``True`` all :class:`P...
[ "All", ":", "class", ":", "Pointer", "fields", "in", "the", "Sequence", "read", "the", "necessary", "number", "of", "bytes", "from", "the", "data", ":", "class", ":", "Provider", "for", "their", "referenced", ":", "attr", ":", "~Pointer", ".", "data", "o...
python
train
52.470588
python-bugzilla/python-bugzilla
bugzilla/_cli.py
https://github.com/python-bugzilla/python-bugzilla/blob/7de8b225104f24a1eee3e837bf1e02d60aefe69f/bugzilla/_cli.py#L100-L111
def get_default_url(): """ Grab a default URL from bugzillarc [DEFAULT] url=X """ from bugzilla.base import _open_bugzillarc cfg = _open_bugzillarc() if cfg: cfgurl = cfg.defaults().get("url", None) if cfgurl is not None: log.debug("bugzillarc: found cli url=%s", cfgu...
[ "def", "get_default_url", "(", ")", ":", "from", "bugzilla", ".", "base", "import", "_open_bugzillarc", "cfg", "=", "_open_bugzillarc", "(", ")", "if", "cfg", ":", "cfgurl", "=", "cfg", ".", "defaults", "(", ")", ".", "get", "(", "\"url\"", ",", "None", ...
Grab a default URL from bugzillarc [DEFAULT] url=X
[ "Grab", "a", "default", "URL", "from", "bugzillarc", "[", "DEFAULT", "]", "url", "=", "X" ]
python
train
30
QUANTAXIS/QUANTAXIS
QUANTAXIS/QAFetch/QATdx.py
https://github.com/QUANTAXIS/QUANTAXIS/blob/bb1fe424e4108b62a1f712b81a05cf829297a5c0/QUANTAXIS/QAFetch/QATdx.py#L1331-L1351
def QA_fetch_get_hkfund_list(ip=None, port=None): """[summary] Keyword Arguments: ip {[type]} -- [description] (default: {None}) port {[type]} -- [description] (default: {None}) # 港股 HKMARKET 27 5 香港指数 FH 31 2 香港主板 KH 48 ...
[ "def", "QA_fetch_get_hkfund_list", "(", "ip", "=", "None", ",", "port", "=", "None", ")", ":", "global", "extension_market_list", "extension_market_list", "=", "QA_fetch_get_extensionmarket_list", "(", ")", "if", "extension_market_list", "is", "None", "else", "extensi...
[summary] Keyword Arguments: ip {[type]} -- [description] (default: {None}) port {[type]} -- [description] (default: {None}) # 港股 HKMARKET 27 5 香港指数 FH 31 2 香港主板 KH 48 2 香港创业板 KG 49 2 香港基...
[ "[", "summary", "]" ]
python
train
30.333333
tk0miya/tk.phpautodoc
src/phply/phpparse.py
https://github.com/tk0miya/tk.phpautodoc/blob/cf789f64abaf76351485cee231a075227e665fb6/src/phply/phpparse.py#L678-L680
def p_expr_new(p): 'expr : NEW class_name_reference ctor_arguments' p[0] = ast.New(p[2], p[3], lineno=p.lineno(1))
[ "def", "p_expr_new", "(", "p", ")", ":", "p", "[", "0", "]", "=", "ast", ".", "New", "(", "p", "[", "2", "]", ",", "p", "[", "3", "]", ",", "lineno", "=", "p", ".", "lineno", "(", "1", ")", ")" ]
expr : NEW class_name_reference ctor_arguments
[ "expr", ":", "NEW", "class_name_reference", "ctor_arguments" ]
python
train
40
F483/btctxstore
btctxstore/api.py
https://github.com/F483/btctxstore/blob/5790ace3a3d4c9bcc759e7c931fc4a57d40b6c25/btctxstore/api.py#L259-L263
def get_data_blob(self, rawtx): """TODO add docstring""" tx = deserialize.tx(rawtx) data = control.get_data_blob(tx) return serialize.data(data)
[ "def", "get_data_blob", "(", "self", ",", "rawtx", ")", ":", "tx", "=", "deserialize", ".", "tx", "(", "rawtx", ")", "data", "=", "control", ".", "get_data_blob", "(", "tx", ")", "return", "serialize", ".", "data", "(", "data", ")" ]
TODO add docstring
[ "TODO", "add", "docstring" ]
python
train
34.4
esterhui/pypu
scripts/build_json_from_gps.py
https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/scripts/build_json_from_gps.py#L169-L194
def lookupGeoInfo(positions): """Looks up lat/lon info with goole given a list of positions as parsed by parsePositionFile. Returns google results in form of dicionary """ list_data=[] oldlat=0 oldlon=0 d={} for pos in positions: # Only lookup point if it is above threshold ...
[ "def", "lookupGeoInfo", "(", "positions", ")", ":", "list_data", "=", "[", "]", "oldlat", "=", "0", "oldlon", "=", "0", "d", "=", "{", "}", "for", "pos", "in", "positions", ":", "# Only lookup point if it is above threshold", "diff_lat", "=", "abs", "(", "...
Looks up lat/lon info with goole given a list of positions as parsed by parsePositionFile. Returns google results in form of dicionary
[ "Looks", "up", "lat", "/", "lon", "info", "with", "goole", "given", "a", "list", "of", "positions", "as", "parsed", "by", "parsePositionFile", ".", "Returns", "google", "results", "in", "form", "of", "dicionary" ]
python
train
32.769231
google/grr
grr/client/grr_response_client/client_actions/tempfiles.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/tempfiles.py#L228-L264
def DeleteGRRTempFile(path): """Delete a GRR temp file. To limit possible damage the path must be absolute and either the file must be within any of the Client.tempdir_roots or the file name must begin with Client.tempfile_prefix. Args: path: path string to file to be deleted. Raises: OSError: Pe...
[ "def", "DeleteGRRTempFile", "(", "path", ")", ":", "precondition", ".", "AssertType", "(", "path", ",", "Text", ")", "if", "not", "os", ".", "path", ".", "isabs", "(", "path", ")", ":", "raise", "ErrorBadPath", "(", "\"Path must be absolute\"", ")", "prefi...
Delete a GRR temp file. To limit possible damage the path must be absolute and either the file must be within any of the Client.tempdir_roots or the file name must begin with Client.tempfile_prefix. Args: path: path string to file to be deleted. Raises: OSError: Permission denied, or file not found...
[ "Delete", "a", "GRR", "temp", "file", "." ]
python
train
33.486486
nsqio/pynsq
nsq/reader.py
https://github.com/nsqio/pynsq/blob/48bf62d65ea63cddaa401efb23187b95511dbc84/nsq/reader.py#L446-L484
def connect_to_nsqd(self, host, port): """ Adds a connection to ``nsqd`` at the specified address. :param host: the address to connect to :param port: the port to connect to """ assert isinstance(host, string_types) assert isinstance(port, int) conn = As...
[ "def", "connect_to_nsqd", "(", "self", ",", "host", ",", "port", ")", ":", "assert", "isinstance", "(", "host", ",", "string_types", ")", "assert", "isinstance", "(", "port", ",", "int", ")", "conn", "=", "AsyncConn", "(", "host", ",", "port", ",", "*"...
Adds a connection to ``nsqd`` at the specified address. :param host: the address to connect to :param port: the port to connect to
[ "Adds", "a", "connection", "to", "nsqd", "at", "the", "specified", "address", "." ]
python
test
41.128205
glomex/gcdt
gcdt/kumo_core.py
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/kumo_core.py#L632-L645
def delete_change_set(awsclient, change_set_name, stack_name): """Delete specified change set. Currently we only use this during automated regression testing. But we have plans so lets locate this functionality here :param awsclient: :param change_set_name: :param stack_name: """ client...
[ "def", "delete_change_set", "(", "awsclient", ",", "change_set_name", ",", "stack_name", ")", ":", "client", "=", "awsclient", ".", "get_client", "(", "'cloudformation'", ")", "response", "=", "client", ".", "delete_change_set", "(", "ChangeSetName", "=", "change_...
Delete specified change set. Currently we only use this during automated regression testing. But we have plans so lets locate this functionality here :param awsclient: :param change_set_name: :param stack_name:
[ "Delete", "specified", "change", "set", ".", "Currently", "we", "only", "use", "this", "during", "automated", "regression", "testing", ".", "But", "we", "have", "plans", "so", "lets", "locate", "this", "functionality", "here" ]
python
train
32.785714
apache/incubator-heron
third_party/python/cpplint/cpplint.py
https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/third_party/python/cpplint/cpplint.py#L5088-L5107
def IsDerivedFunction(clean_lines, linenum): """Check if current line contains an inherited function. Args: clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. Returns: True if current line contains a function with "override" virt-specifier. """ ...
[ "def", "IsDerivedFunction", "(", "clean_lines", ",", "linenum", ")", ":", "# Scan back a few lines for start of current function", "for", "i", "in", "xrange", "(", "linenum", ",", "max", "(", "-", "1", ",", "linenum", "-", "10", ")", ",", "-", "1", ")", ":",...
Check if current line contains an inherited function. Args: clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. Returns: True if current line contains a function with "override" virt-specifier.
[ "Check", "if", "current", "line", "contains", "an", "inherited", "function", "." ]
python
valid
38
pyBookshelf/bookshelf
bookshelf/api_v1.py
https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v1.py#L874-L883
def down_ec2(instance_id, region, access_key_id, secret_access_key): """ shutdown of an existing EC2 instance """ conn = connect_to_ec2(region, access_key_id, secret_access_key) # get the instance_id from the state file, and stop the instance instance = conn.stop_instances(instance_ids=instance_id)[0] ...
[ "def", "down_ec2", "(", "instance_id", ",", "region", ",", "access_key_id", ",", "secret_access_key", ")", ":", "conn", "=", "connect_to_ec2", "(", "region", ",", "access_key_id", ",", "secret_access_key", ")", "# get the instance_id from the state file, and stop the inst...
shutdown of an existing EC2 instance
[ "shutdown", "of", "an", "existing", "EC2", "instance" ]
python
train
50.3
tanghaibao/jcvi
jcvi/projects/synfind.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/projects/synfind.py#L731-L812
def cartoon(args): """ %prog synteny.py Generate cartoon illustration of SynFind. """ p = OptionParser(cartoon.__doc__) opts, args, iopts = p.set_image_options(args, figsize="10x7") fig = plt.figure(1, (iopts.w, iopts.h)) root = fig.add_axes([0, 0, 1, 1]) # Panel A A = Cartoon...
[ "def", "cartoon", "(", "args", ")", ":", "p", "=", "OptionParser", "(", "cartoon", ".", "__doc__", ")", "opts", ",", "args", ",", "iopts", "=", "p", ".", "set_image_options", "(", "args", ",", "figsize", "=", "\"10x7\"", ")", "fig", "=", "plt", ".", ...
%prog synteny.py Generate cartoon illustration of SynFind.
[ "%prog", "synteny", ".", "py" ]
python
train
30.914634
senaite/senaite.core
bika/lims/browser/fields/remarksfield.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/browser/fields/remarksfield.py#L82-L89
def getRaw(self, instance, **kwargs): """Returns raw field value (possible wrapped in BaseUnit) """ value = ObjectField.get(self, instance, **kwargs) # getattr(instance, "Remarks") returns a BaseUnit if callable(value): value = value() return value
[ "def", "getRaw", "(", "self", ",", "instance", ",", "*", "*", "kwargs", ")", ":", "value", "=", "ObjectField", ".", "get", "(", "self", ",", "instance", ",", "*", "*", "kwargs", ")", "# getattr(instance, \"Remarks\") returns a BaseUnit", "if", "callable", "(...
Returns raw field value (possible wrapped in BaseUnit)
[ "Returns", "raw", "field", "value", "(", "possible", "wrapped", "in", "BaseUnit", ")" ]
python
train
37.625
pandas-dev/pandas
pandas/core/internals/blocks.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2109-L2145
def _try_coerce_args(self, values, other): """ Coerce values and other to dtype 'i8'. NaN and NaT convert to the smallest i8, and will correctly round-trip to NaT if converted back in _try_coerce_result. values is always ndarray-like, other may not be Parameters ...
[ "def", "_try_coerce_args", "(", "self", ",", "values", ",", "other", ")", ":", "values", "=", "values", ".", "view", "(", "'i8'", ")", "if", "isinstance", "(", "other", ",", "bool", ")", ":", "raise", "TypeError", "elif", "is_null_datetimelike", "(", "ot...
Coerce values and other to dtype 'i8'. NaN and NaT convert to the smallest i8, and will correctly round-trip to NaT if converted back in _try_coerce_result. values is always ndarray-like, other may not be Parameters ---------- values : ndarray-like other : ndarra...
[ "Coerce", "values", "and", "other", "to", "dtype", "i8", ".", "NaN", "and", "NaT", "convert", "to", "the", "smallest", "i8", "and", "will", "correctly", "round", "-", "trip", "to", "NaT", "if", "converted", "back", "in", "_try_coerce_result", ".", "values"...
python
train
33.108108
woolfson-group/isambard
isambard/optimisation/base_evo_opt.py
https://github.com/woolfson-group/isambard/blob/ebc33b48a28ad217e18f93b910dfba46e6e71e07/isambard/optimisation/base_evo_opt.py#L341-L381
def log_results(self, output_path=None, run_id=None): """Saves files for the minimization. Notes ----- Currently saves a logfile with best individual and a pdb of the best model. """ best_ind = self.halloffame[0] model_params = self.parse_individual( ...
[ "def", "log_results", "(", "self", ",", "output_path", "=", "None", ",", "run_id", "=", "None", ")", ":", "best_ind", "=", "self", ".", "halloffame", "[", "0", "]", "model_params", "=", "self", ".", "parse_individual", "(", "best_ind", ")", "# need to chan...
Saves files for the minimization. Notes ----- Currently saves a logfile with best individual and a pdb of the best model.
[ "Saves", "files", "for", "the", "minimization", "." ]
python
train
44.219512
molmod/molmod
molmod/pairff.py
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/pairff.py#L129-L162
def hessian_component(self, index1, index2): """Compute the hessian of the energy for one atom pair""" result = np.zeros((3, 3), float) if index1 == index2: for index3 in range(self.numc): if self.scaling[index1, index3] > 0: d_1 = 1/self.distances...
[ "def", "hessian_component", "(", "self", ",", "index1", ",", "index2", ")", ":", "result", "=", "np", ".", "zeros", "(", "(", "3", ",", "3", ")", ",", "float", ")", "if", "index1", "==", "index2", ":", "for", "index3", "in", "range", "(", "self", ...
Compute the hessian of the energy for one atom pair
[ "Compute", "the", "hessian", "of", "the", "energy", "for", "one", "atom", "pair" ]
python
train
52.382353
lucapinello/Haystack
haystack/external.py
https://github.com/lucapinello/Haystack/blob/cc080d741f36cd77b07c0b59d08ea6a4cf0ef2f7/haystack/external.py#L1090-L1096
def copy(self): """ m.copy() -- Return a 'deep' copy of the motif """ a = Motif() a.__dict__ = self.__dict__.copy() return a
[ "def", "copy", "(", "self", ")", ":", "a", "=", "Motif", "(", ")", "a", ".", "__dict__", "=", "self", ".", "__dict__", ".", "copy", "(", ")", "return", "a" ]
m.copy() -- Return a 'deep' copy of the motif
[ "m", ".", "copy", "()", "--", "Return", "a", "deep", "copy", "of", "the", "motif" ]
python
train
23.714286
desbma/sacad
sacad/http_helpers.py
https://github.com/desbma/sacad/blob/a7a010c4d9618a0c90927f1acb530101ca05fac4/sacad/http_helpers.py#L189-L198
async def fastStreamedQuery(self, url, *, headers=None, verify=True): """ Send a GET request with short timeout, do not retry, and return streamed response. """ response = await self.session.get(url, headers=self._buildHeaders(headers), ...
[ "async", "def", "fastStreamedQuery", "(", "self", ",", "url", ",", "*", ",", "headers", "=", "None", ",", "verify", "=", "True", ")", ":", "response", "=", "await", "self", ".", "session", ".", "get", "(", "url", ",", "headers", "=", "self", ".", "...
Send a GET request with short timeout, do not retry, and return streamed response.
[ "Send", "a", "GET", "request", "with", "short", "timeout", "do", "not", "retry", "and", "return", "streamed", "response", "." ]
python
train
44.3
adrn/gala
gala/dynamics/_genfunc/solver.py
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/_genfunc/solver.py#L35-L78
def solver(AA, N_max, symNx = 2, throw_out_modes=False): """ Constructs the matrix A and the vector b from a timeseries of toy action-angles AA to solve for the vector x = (J_0,J_1,J_2,S...) where x contains all Fourier components of the generating function with |n|<N_max """ # Find all integer compone...
[ "def", "solver", "(", "AA", ",", "N_max", ",", "symNx", "=", "2", ",", "throw_out_modes", "=", "False", ")", ":", "# Find all integer component n_vectors which lie within sphere of radius N_max", "# Here we have assumed that the potential is symmetric x->-x, y->-y, z->-z", "# Thi...
Constructs the matrix A and the vector b from a timeseries of toy action-angles AA to solve for the vector x = (J_0,J_1,J_2,S...) where x contains all Fourier components of the generating function with |n|<N_max
[ "Constructs", "the", "matrix", "A", "and", "the", "vector", "b", "from", "a", "timeseries", "of", "toy", "action", "-", "angles", "AA", "to", "solve", "for", "the", "vector", "x", "=", "(", "J_0", "J_1", "J_2", "S", "...", ")", "where", "x", "contain...
python
train
43.659091
zero-os/zerotier_client
zerotier/client_support.py
https://github.com/zero-os/zerotier_client/blob/03993da11e69d837a0308a2f41ae7b378692fd82/zerotier/client_support.py#L75-L90
def val_factory(val, datatypes): """ return an instance of `val` that is of type `datatype`. keep track of exceptions so we can produce meaningful error messages. """ exceptions = [] for dt in datatypes: try: if isinstance(val, dt): return val retu...
[ "def", "val_factory", "(", "val", ",", "datatypes", ")", ":", "exceptions", "=", "[", "]", "for", "dt", "in", "datatypes", ":", "try", ":", "if", "isinstance", "(", "val", ",", "dt", ")", ":", "return", "val", "return", "type_handler_object", "(", "val...
return an instance of `val` that is of type `datatype`. keep track of exceptions so we can produce meaningful error messages.
[ "return", "an", "instance", "of", "val", "that", "is", "of", "type", "datatype", ".", "keep", "track", "of", "exceptions", "so", "we", "can", "produce", "meaningful", "error", "messages", "." ]
python
train
40.5
trailofbits/manticore
manticore/native/cpu/x86.py
https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/native/cpu/x86.py#L3956-L3968
def _getMemoryBit(cpu, bitbase, bitoffset): """ Calculate address and bit offset given a base address and a bit offset relative to that address (in the form of asm operands) """ assert bitbase.type == 'memory' assert bitbase.size >= bitoffset.size addr = bitbase.address() ...
[ "def", "_getMemoryBit", "(", "cpu", ",", "bitbase", ",", "bitoffset", ")", ":", "assert", "bitbase", ".", "type", "==", "'memory'", "assert", "bitbase", ".", "size", ">=", "bitoffset", ".", "size", "addr", "=", "bitbase", ".", "address", "(", ")", "offt"...
Calculate address and bit offset given a base address and a bit offset relative to that address (in the form of asm operands)
[ "Calculate", "address", "and", "bit", "offset", "given", "a", "base", "address", "and", "a", "bit", "offset", "relative", "to", "that", "address", "(", "in", "the", "form", "of", "asm", "operands", ")" ]
python
valid
48.923077
ralphje/imagemounter
imagemounter/volume.py
https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume.py#L342-L359
def detect_volume_shadow_copies(self): """Method to call vshadowmount and mount NTFS volume shadow copies. :return: iterable with the :class:`Volume` objects of the VSS :raises CommandNotFoundError: if the underlying command does not exist :raises SubSystemError: if the underlying comma...
[ "def", "detect_volume_shadow_copies", "(", "self", ")", ":", "self", ".", "_make_mountpoint", "(", "var_name", "=", "'vss'", ",", "suffix", "=", "\"vss\"", ",", "in_paths", "=", "True", ")", "try", ":", "_util", ".", "check_call_", "(", "[", "\"vshadowmount\...
Method to call vshadowmount and mount NTFS volume shadow copies. :return: iterable with the :class:`Volume` objects of the VSS :raises CommandNotFoundError: if the underlying command does not exist :raises SubSystemError: if the underlying command fails :raises NoMountpointAvailableErro...
[ "Method", "to", "call", "vshadowmount", "and", "mount", "NTFS", "volume", "shadow", "copies", "." ]
python
train
45.666667
takaakiaoki/ofblockmeshdicthelper
ofblockmeshdicthelper/__init__.py
https://github.com/takaakiaoki/ofblockmeshdicthelper/blob/df99e6b0e4f0334c9afe075b4f3ceaccb5bac9fd/ofblockmeshdicthelper/__init__.py#L193-L201
def format(self, vertices): """Format instance to dump vertices is dict of name to Vertex """ index = ' '.join(str(vertices[vn].index) for vn in self.vnames) vcom = ' '.join(self.vnames) # for comment return 'hex ({0:s}) {2:s} ({1[0]:d} {1[1]:d} {1[2]:d}) '\ ...
[ "def", "format", "(", "self", ",", "vertices", ")", ":", "index", "=", "' '", ".", "join", "(", "str", "(", "vertices", "[", "vn", "]", ".", "index", ")", "for", "vn", "in", "self", ".", "vnames", ")", "vcom", "=", "' '", ".", "join", "(", "sel...
Format instance to dump vertices is dict of name to Vertex
[ "Format", "instance", "to", "dump", "vertices", "is", "dict", "of", "name", "to", "Vertex" ]
python
train
47.444444
ellmetha/django-machina
machina/apps/forum_moderation/views.py
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum_moderation/views.py#L357-L385
def get_context_data(self, **kwargs): """ Returns the context data to provide to the template. """ context = super().get_context_data(**kwargs) post = self.object topic = post.topic # Handles the case when a poll is associated to the topic. try: if hasattr(t...
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "context", "=", "super", "(", ")", ".", "get_context_data", "(", "*", "*", "kwargs", ")", "post", "=", "self", ".", "object", "topic", "=", "post", ".", "topic", "# Handles the ...
Returns the context data to provide to the template.
[ "Returns", "the", "context", "data", "to", "provide", "to", "the", "template", "." ]
python
train
37.586207
JMSwag/dsdev-utils
dsdev_utils/paths.py
https://github.com/JMSwag/dsdev-utils/blob/5adbf9b3fd9fff92d1dd714423b08e26a5038e14/dsdev_utils/paths.py#L36-L47
def get_mac_dot_app_dir(directory): """Returns parent directory of mac .app Args: directory (str): Current directory Returns: (str): Parent directory of mac .app """ return os.path.dirname(os.path.dirname(os.path.dirname(directory)))
[ "def", "get_mac_dot_app_dir", "(", "directory", ")", ":", "return", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "dirname", "(", "directory", ")", ")", ")" ]
Returns parent directory of mac .app Args: directory (str): Current directory Returns: (str): Parent directory of mac .app
[ "Returns", "parent", "directory", "of", "mac", ".", "app" ]
python
train
21.666667
linkhub-sdk/popbill.py
popbill/closedownService.py
https://github.com/linkhub-sdk/popbill.py/blob/68a0dd7f7a937603318e93be321fde73c50b96cc/popbill/closedownService.py#L73-L88
def checkCorpNums(self, MemberCorpNum, CorpNumList): """ 휴폐업조회 대량 확인, 최대 1000건 args MemberCorpNum : 팝빌회원 사업자번호 CorpNumList : 조회할 사업자번호 배열 return 휴폐업정보 Object as List raise PopbillException """ if ...
[ "def", "checkCorpNums", "(", "self", ",", "MemberCorpNum", ",", "CorpNumList", ")", ":", "if", "CorpNumList", "==", "None", "or", "len", "(", "CorpNumList", ")", "<", "1", ":", "raise", "PopbillException", "(", "-", "99999999", ",", "\"조죄할 사업자번호 목록이 입력되지 않았습니다...
휴폐업조회 대량 확인, 최대 1000건 args MemberCorpNum : 팝빌회원 사업자번호 CorpNumList : 조회할 사업자번호 배열 return 휴폐업정보 Object as List raise PopbillException
[ "휴폐업조회", "대량", "확인", "최대", "1000건", "args", "MemberCorpNum", ":", "팝빌회원", "사업자번호", "CorpNumList", ":", "조회할", "사업자번호", "배열", "return", "휴폐업정보", "Object", "as", "List", "raise", "PopbillException" ]
python
train
33.8125
mabuchilab/QNET
src/qnet/convert/to_qutip.py
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/convert/to_qutip.py#L121-L178
def SLH_to_qutip(slh, full_space=None, time_symbol=None, convert_as='pyfunc'): """Generate and return QuTiP representation matrices for the Hamiltonian and the collapse operators. Any inhomogeneities in the Lindblad operators (resulting from coherent drives) will be moved into the Hamiltoni...
[ "def", "SLH_to_qutip", "(", "slh", ",", "full_space", "=", "None", ",", "time_symbol", "=", "None", ",", "convert_as", "=", "'pyfunc'", ")", ":", "if", "full_space", ":", "if", "not", "full_space", ">=", "slh", ".", "space", ":", "raise", "AlgebraError", ...
Generate and return QuTiP representation matrices for the Hamiltonian and the collapse operators. Any inhomogeneities in the Lindblad operators (resulting from coherent drives) will be moved into the Hamiltonian, cf. :func:`~qnet.algebra.circuit_algebra.move_drive_to_H`. Args: slh (SLH): The SL...
[ "Generate", "and", "return", "QuTiP", "representation", "matrices", "for", "the", "Hamiltonian", "and", "the", "collapse", "operators", ".", "Any", "inhomogeneities", "in", "the", "Lindblad", "operators", "(", "resulting", "from", "coherent", "drives", ")", "will"...
python
train
43.758621
kevinconway/confpy
confpy/core/namespace.py
https://github.com/kevinconway/confpy/blob/1ee8afcab46ac6915a5ff4184180434ac7b84a60/confpy/core/namespace.py#L81-L100
def register(self, name, option): """Register a new option with the namespace. Args: name (str): The name to register the option under. option (option.Option): The option object to register. Raises: TypeError: If the option is not an option.Option ob...
[ "def", "register", "(", "self", ",", "name", ",", "option", ")", ":", "if", "name", "in", "self", ".", "_options", ":", "raise", "ValueError", "(", "\"Option {0} already exists.\"", ".", "format", "(", "name", ")", ")", "if", "not", "isinstance", "(", "o...
Register a new option with the namespace. Args: name (str): The name to register the option under. option (option.Option): The option object to register. Raises: TypeError: If the option is not an option.Option object. ValueError: If the name is ...
[ "Register", "a", "new", "option", "with", "the", "namespace", ".", "Args", ":", "name", "(", "str", ")", ":", "The", "name", "to", "register", "the", "option", "under", ".", "option", "(", "option", ".", "Option", ")", ":", "The", "option", "object", ...
python
train
32.25
Groundworkstech/pybfd
pybfd/section.py
https://github.com/Groundworkstech/pybfd/blob/9e722435929b4ad52212043a6f1e9e9ce60b5d72/pybfd/section.py#L477-L479
def get_content(self, offset, size): """Return the specified number of bytes from the current section.""" return _bfd.section_get_content(self.bfd, self._ptr, offset, size)
[ "def", "get_content", "(", "self", ",", "offset", ",", "size", ")", ":", "return", "_bfd", ".", "section_get_content", "(", "self", ".", "bfd", ",", "self", ".", "_ptr", ",", "offset", ",", "size", ")" ]
Return the specified number of bytes from the current section.
[ "Return", "the", "specified", "number", "of", "bytes", "from", "the", "current", "section", "." ]
python
train
62
tensorpack/tensorpack
tensorpack/tfutils/varmanip.py
https://github.com/tensorpack/tensorpack/blob/d7a13cb74c9066bc791d7aafc3b744b60ee79a9f/tensorpack/tfutils/varmanip.py#L196-L211
def load_chkpt_vars(model_path): """ Load all variables from a checkpoint to a dict. Args: model_path(str): path to a checkpoint. Returns: dict: a name:value dict """ model_path = get_checkpoint_path(model_path) reader = tfv1.train.NewCheckpointReader(model_path) var_names ...
[ "def", "load_chkpt_vars", "(", "model_path", ")", ":", "model_path", "=", "get_checkpoint_path", "(", "model_path", ")", "reader", "=", "tfv1", ".", "train", ".", "NewCheckpointReader", "(", "model_path", ")", "var_names", "=", "reader", ".", "get_variable_to_shap...
Load all variables from a checkpoint to a dict. Args: model_path(str): path to a checkpoint. Returns: dict: a name:value dict
[ "Load", "all", "variables", "from", "a", "checkpoint", "to", "a", "dict", "." ]
python
train
27.9375
upsight/doctor
doctor/docs/base.py
https://github.com/upsight/doctor/blob/2cf1d433f6f1aa1355644b449a757c0660793cdd/doctor/docs/base.py#L365-L448
def get_resource_object_doc_lines() -> List[str]: """Generate documentation lines for all collected resource objects. As API documentation is generated we keep a running list of objects used in request parameters and responses. This section will generate documentation for each object and provide an in...
[ "def", "get_resource_object_doc_lines", "(", ")", "->", "List", "[", "str", "]", ":", "# First loop through all resources and make sure to add any properties that", "# are objects and not already in `ALL_RESOURCES`. We iterate over a copy", "# since we will be modifying the dict during the...
Generate documentation lines for all collected resource objects. As API documentation is generated we keep a running list of objects used in request parameters and responses. This section will generate documentation for each object and provide an inline reference in the API documentation. :return...
[ "Generate", "documentation", "lines", "for", "all", "collected", "resource", "objects", "." ]
python
train
51.321429
F-Secure/see
plugins/agent.py
https://github.com/F-Secure/see/blob/3e053e52a45229f96a12db9e98caf7fb3880e811/plugins/agent.py#L97-L105
def store_file(self, folder, name): """Stores the uploaded file in the given path.""" path = os.path.join(folder, name) length = self.headers['content-length'] with open(path, 'wb') as sample: sample.write(self.rfile.read(int(length))) return path
[ "def", "store_file", "(", "self", ",", "folder", ",", "name", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "folder", ",", "name", ")", "length", "=", "self", ".", "headers", "[", "'content-length'", "]", "with", "open", "(", "path", ...
Stores the uploaded file in the given path.
[ "Stores", "the", "uploaded", "file", "in", "the", "given", "path", "." ]
python
train
32.555556
praekeltfoundation/molo.commenting
molo/commenting/managers.py
https://github.com/praekeltfoundation/molo.commenting/blob/94549bd75e4a5c5b3db43149e32d636330b3969c/molo/commenting/managers.py#L9-L18
def for_model(self, model): """ QuerySet for all comments for a particular model (either an instance or a class). """ ct = ContentType.objects.get_for_model(model) qs = self.get_queryset().filter(content_type=ct) if isinstance(model, models.Model): qs ...
[ "def", "for_model", "(", "self", ",", "model", ")", ":", "ct", "=", "ContentType", ".", "objects", ".", "get_for_model", "(", "model", ")", "qs", "=", "self", ".", "get_queryset", "(", ")", ".", "filter", "(", "content_type", "=", "ct", ")", "if", "i...
QuerySet for all comments for a particular model (either an instance or a class).
[ "QuerySet", "for", "all", "comments", "for", "a", "particular", "model", "(", "either", "an", "instance", "or", "a", "class", ")", "." ]
python
train
38.3
SwissDataScienceCenter/renku-python
renku/models/projects.py
https://github.com/SwissDataScienceCenter/renku-python/blob/691644d695b055a01e0ca22b2620e55bbd928c0d/renku/models/projects.py#L74-L82
def create(self, name=None, **kwargs): """Create a new project. :param name: The name of the project. :returns: An instance of the newly create project. :rtype: renku.models.projects.Project """ data = self._client.api.create_project({'name': name}) return self.M...
[ "def", "create", "(", "self", ",", "name", "=", "None", ",", "*", "*", "kwargs", ")", ":", "data", "=", "self", ".", "_client", ".", "api", ".", "create_project", "(", "{", "'name'", ":", "name", "}", ")", "return", "self", ".", "Meta", ".", "mod...
Create a new project. :param name: The name of the project. :returns: An instance of the newly create project. :rtype: renku.models.projects.Project
[ "Create", "a", "new", "project", "." ]
python
train
40.555556
basho/riak-python-client
riak/client/operations.py
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/client/operations.py#L1034-L1064
def get_counter(self, transport, bucket, key, r=None, pr=None, basic_quorum=None, notfound_ok=None): """get_counter(bucket, key, r=None, pr=None, basic_quorum=None,\ notfound_ok=None) Gets the value of a counter. .. deprecated:: 2.1.0 (Riak 2.0) Riak ...
[ "def", "get_counter", "(", "self", ",", "transport", ",", "bucket", ",", "key", ",", "r", "=", "None", ",", "pr", "=", "None", ",", "basic_quorum", "=", "None", ",", "notfound_ok", "=", "None", ")", ":", "return", "transport", ".", "get_counter", "(", ...
get_counter(bucket, key, r=None, pr=None, basic_quorum=None,\ notfound_ok=None) Gets the value of a counter. .. deprecated:: 2.1.0 (Riak 2.0) Riak 1.4-style counters are deprecated in favor of the :class:`~riak.datatypes.Counter` datatype. .. note:...
[ "get_counter", "(", "bucket", "key", "r", "=", "None", "pr", "=", "None", "basic_quorum", "=", "None", "\\", "notfound_ok", "=", "None", ")" ]
python
train
37.903226
Robpol86/terminaltables
terminaltables/width_and_alignment.py
https://github.com/Robpol86/terminaltables/blob/ad8f46e50afdbaea377fc1f713bc0e7a31c4fccc/terminaltables/width_and_alignment.py#L11-L39
def visible_width(string): """Get the visible width of a unicode string. Some CJK unicode characters are more than one byte unlike ASCII and latin unicode characters. From: https://github.com/Robpol86/terminaltables/pull/9 :param str string: String to measure. :return: String's width. :rtype...
[ "def", "visible_width", "(", "string", ")", ":", "if", "'\\033'", "in", "string", ":", "string", "=", "RE_COLOR_ANSI", ".", "sub", "(", "''", ",", "string", ")", "# Convert to unicode.", "try", ":", "string", "=", "string", ".", "decode", "(", "'u8'", ")...
Get the visible width of a unicode string. Some CJK unicode characters are more than one byte unlike ASCII and latin unicode characters. From: https://github.com/Robpol86/terminaltables/pull/9 :param str string: String to measure. :return: String's width. :rtype: int
[ "Get", "the", "visible", "width", "of", "a", "unicode", "string", "." ]
python
train
23.793103
mjirik/io3d
io3d/datareader.py
https://github.com/mjirik/io3d/blob/ccaf3e378dcc967f2565d477fc27583fd0f61fcc/io3d/datareader.py#L276-L288
def _fix_sitk_bug(path, metadata): """There is a bug in simple ITK for Z axis in 3D images. This is a fix. :param path: path to dicom file to read :param metadata: metadata to correct :return: corrected metadata """ ds = dicom.read_file(path) try: met...
[ "def", "_fix_sitk_bug", "(", "path", ",", "metadata", ")", ":", "ds", "=", "dicom", ".", "read_file", "(", "path", ")", "try", ":", "metadata", "[", "\"voxelsize_mm\"", "]", "[", "0", "]", "=", "ds", ".", "SpacingBetweenSlices", "except", "Exception", "a...
There is a bug in simple ITK for Z axis in 3D images. This is a fix. :param path: path to dicom file to read :param metadata: metadata to correct :return: corrected metadata
[ "There", "is", "a", "bug", "in", "simple", "ITK", "for", "Z", "axis", "in", "3D", "images", ".", "This", "is", "a", "fix", "." ]
python
train
37.615385
cni/MRS
MRS/data.py
https://github.com/cni/MRS/blob/16098b3cf4830780efd787fee9efa46513850283/MRS/data.py#L87-L105
def check_md5(filename, stored_md5): """ Computes the md5 of filename and check if it matches with the supplied string md5 Input ----- filename : string Path to a file. md5 : string Known md5 of filename to check against. """ computed_md5 = _get_file_md5(filename) ...
[ "def", "check_md5", "(", "filename", ",", "stored_md5", ")", ":", "computed_md5", "=", "_get_file_md5", "(", "filename", ")", "if", "stored_md5", "!=", "computed_md5", ":", "print", "(", "\"MD5 checksum of filename\"", ",", "filename", ",", "\"failed. Expected MD5 w...
Computes the md5 of filename and check if it matches with the supplied string md5 Input ----- filename : string Path to a file. md5 : string Known md5 of filename to check against.
[ "Computes", "the", "md5", "of", "filename", "and", "check", "if", "it", "matches", "with", "the", "supplied", "string", "md5" ]
python
train
32.263158
saltstack/salt
salt/modules/mysql.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L1022-L1046
def db_get(name, **connection_args): ''' Return a list of databases of a MySQL server using the output from the ``SELECT DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME='dbname';`` query. CLI Example: .. code-block:: bash salt '*' ...
[ "def", "db_get", "(", "name", ",", "*", "*", "connection_args", ")", ":", "dbc", "=", "_connect", "(", "*", "*", "connection_args", ")", "if", "dbc", "is", "None", ":", "return", "[", "]", "cur", "=", "dbc", ".", "cursor", "(", ")", "qry", "=", "...
Return a list of databases of a MySQL server using the output from the ``SELECT DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME='dbname';`` query. CLI Example: .. code-block:: bash salt '*' mysql.db_get test
[ "Return", "a", "list", "of", "databases", "of", "a", "MySQL", "server", "using", "the", "output", "from", "the", "SELECT", "DEFAULT_CHARACTER_SET_NAME", "DEFAULT_COLLATION_NAME", "FROM", "INFORMATION_SCHEMA", ".", "SCHEMATA", "WHERE", "SCHEMA_NAME", "=", "dbname", "...
python
train
31