repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
bokeh/bokeh
bokeh/util/deprecation.py
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/util/deprecation.py#L45-L68
def deprecated(since_or_msg, old=None, new=None, extra=None): """ Issue a nicely formatted deprecation warning. """ if isinstance(since_or_msg, tuple): if old is None or new is None: raise ValueError("deprecated entity and a replacement are required") if len(since_or_msg) != 3 or n...
[ "def", "deprecated", "(", "since_or_msg", ",", "old", "=", "None", ",", "new", "=", "None", ",", "extra", "=", "None", ")", ":", "if", "isinstance", "(", "since_or_msg", ",", "tuple", ")", ":", "if", "old", "is", "None", "or", "new", "is", "None", ...
Issue a nicely formatted deprecation warning.
[ "Issue", "a", "nicely", "formatted", "deprecation", "warning", "." ]
python
train
hannes-brt/hebel
hebel/pycuda_ops/cudart.py
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/pycuda_ops/cudart.py#L665-L682
def cudaGetDevice(): """ Get current CUDA device. Return the identifying number of the device currently used to process CUDA operations. Returns ------- dev : int Device number. """ dev = ctypes.c_int() status = _libcudart.cudaGetDevice(ctypes.byref(dev)) cudaChec...
[ "def", "cudaGetDevice", "(", ")", ":", "dev", "=", "ctypes", ".", "c_int", "(", ")", "status", "=", "_libcudart", ".", "cudaGetDevice", "(", "ctypes", ".", "byref", "(", "dev", ")", ")", "cudaCheckStatus", "(", "status", ")", "return", "dev", ".", "val...
Get current CUDA device. Return the identifying number of the device currently used to process CUDA operations. Returns ------- dev : int Device number.
[ "Get", "current", "CUDA", "device", "." ]
python
train
mozilla/build-mar
src/mardor/reader.py
https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/reader.py#L228-L237
def productinfo(self): """Return the productversion and channel of this MAR if present.""" if not self.mardata.additional: return None for s in self.mardata.additional.sections: if s.id == 1: return str(s.productversion), str(s.channel) return No...
[ "def", "productinfo", "(", "self", ")", ":", "if", "not", "self", ".", "mardata", ".", "additional", ":", "return", "None", "for", "s", "in", "self", ".", "mardata", ".", "additional", ".", "sections", ":", "if", "s", ".", "id", "==", "1", ":", "re...
Return the productversion and channel of this MAR if present.
[ "Return", "the", "productversion", "and", "channel", "of", "this", "MAR", "if", "present", "." ]
python
train
KnorrFG/pyparadigm
pyparadigm/misc.py
https://github.com/KnorrFG/pyparadigm/blob/69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3/pyparadigm/misc.py#L70-L87
def display(surface): """Displays a pygame.Surface in the window. in pygame the window is represented through a surface, on which you can draw as on any other pygame.Surface. A refernce to to the screen can be optained via the :py:func:`pygame.display.get_surface` function. To display the conte...
[ "def", "display", "(", "surface", ")", ":", "screen", "=", "pygame", ".", "display", ".", "get_surface", "(", ")", "screen", ".", "blit", "(", "surface", ",", "(", "0", ",", "0", ")", ")", "pygame", ".", "display", ".", "flip", "(", ")" ]
Displays a pygame.Surface in the window. in pygame the window is represented through a surface, on which you can draw as on any other pygame.Surface. A refernce to to the screen can be optained via the :py:func:`pygame.display.get_surface` function. To display the contents of the screen surface in ...
[ "Displays", "a", "pygame", ".", "Surface", "in", "the", "window", ".", "in", "pygame", "the", "window", "is", "represented", "through", "a", "surface", "on", "which", "you", "can", "draw", "as", "on", "any", "other", "pygame", ".", "Surface", ".", "A", ...
python
train
saltstack/salt
salt/states/cloud.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/cloud.py#L384-L439
def volume_attached(name, server_name, provider=None, **kwargs): ''' Check if a block volume is attached. ''' ret = _check_name(name) if not ret['result']: return ret ret = _check_name(server_name) if not ret['result']: return ret volumes = __salt__['cloud.volume_list']...
[ "def", "volume_attached", "(", "name", ",", "server_name", ",", "provider", "=", "None", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "_check_name", "(", "name", ")", "if", "not", "ret", "[", "'result'", "]", ":", "return", "ret", "ret", "=", "_che...
Check if a block volume is attached.
[ "Check", "if", "a", "block", "volume", "is", "attached", "." ]
python
train
pallets/werkzeug
src/werkzeug/debug/__init__.py
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/debug/__init__.py#L337-L350
def display_console(self, request): """Display a standalone shell.""" if 0 not in self.frames: if self.console_init_func is None: ns = {} else: ns = dict(self.console_init_func()) ns.setdefault("app", self.app) self.frames[0...
[ "def", "display_console", "(", "self", ",", "request", ")", ":", "if", "0", "not", "in", "self", ".", "frames", ":", "if", "self", ".", "console_init_func", "is", "None", ":", "ns", "=", "{", "}", "else", ":", "ns", "=", "dict", "(", "self", ".", ...
Display a standalone shell.
[ "Display", "a", "standalone", "shell", "." ]
python
train
Opentrons/opentrons
api/src/opentrons/server/endpoints/serverlib_fallback.py
https://github.com/Opentrons/opentrons/blob/a7c15cc2636ecb64ab56c7edc1d8a57163aaeadf/api/src/opentrons/server/endpoints/serverlib_fallback.py#L73-L81
def _set_ignored_version(version): """ Private helper function that writes the most updated API version that was ignored by a user in the app :param version: Most recent ignored API update """ data = {'version': version} with open(filepath, 'w') as data_file: json.dump(data, data_fil...
[ "def", "_set_ignored_version", "(", "version", ")", ":", "data", "=", "{", "'version'", ":", "version", "}", "with", "open", "(", "filepath", ",", "'w'", ")", "as", "data_file", ":", "json", ".", "dump", "(", "data", ",", "data_file", ")" ]
Private helper function that writes the most updated API version that was ignored by a user in the app :param version: Most recent ignored API update
[ "Private", "helper", "function", "that", "writes", "the", "most", "updated", "API", "version", "that", "was", "ignored", "by", "a", "user", "in", "the", "app", ":", "param", "version", ":", "Most", "recent", "ignored", "API", "update" ]
python
train
saltstack/salt
salt/engines/libvirt_events.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/engines/libvirt_events.py#L336-L345
def _domain_event_disk_change_cb(conn, domain, old_src, new_src, dev, reason, opaque): ''' Domain disk change events handler ''' _salt_send_domain_event(opaque, conn, domain, opaque['event'], { 'oldSrcPath': old_src, 'newSrcPath': new_src, 'dev': dev, 'reason': _get_libvi...
[ "def", "_domain_event_disk_change_cb", "(", "conn", ",", "domain", ",", "old_src", ",", "new_src", ",", "dev", ",", "reason", ",", "opaque", ")", ":", "_salt_send_domain_event", "(", "opaque", ",", "conn", ",", "domain", ",", "opaque", "[", "'event'", "]", ...
Domain disk change events handler
[ "Domain", "disk", "change", "events", "handler" ]
python
train
paramiko/paramiko
paramiko/packet.py
https://github.com/paramiko/paramiko/blob/cf7d49d66f3b1fbc8b0853518a54050182b3b5eb/paramiko/packet.py#L241-L255
def handshake_timed_out(self): """ Checks if the handshake has timed out. If `start_handshake` wasn't called before the call to this function, the return value will always be `False`. If the handshake completed before a timeout was reached, the return value will be `False` ...
[ "def", "handshake_timed_out", "(", "self", ")", ":", "if", "not", "self", ".", "__timer", ":", "return", "False", "if", "self", ".", "__handshake_complete", ":", "return", "False", "return", "self", ".", "__timer_expired" ]
Checks if the handshake has timed out. If `start_handshake` wasn't called before the call to this function, the return value will always be `False`. If the handshake completed before a timeout was reached, the return value will be `False` :return: handshake time out status, as a `bool`
[ "Checks", "if", "the", "handshake", "has", "timed", "out", "." ]
python
train
phaethon/kamene
kamene/contrib/gsm_um.py
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L2428-L2439
def ptmsiReallocationCommand(PTmsiSignature_presence=0): """P-TMSI REALLOCATION COMMAND Section 9.4.7""" a = TpPd(pd=0x3) b = MessageType(mesType=0x10) # 00010000 c = MobileId() d = RoutingAreaIdentification() e = ForceToStandbyAndSpareHalfOctets() packet = a / b / c / d / e if PTmsiSig...
[ "def", "ptmsiReallocationCommand", "(", "PTmsiSignature_presence", "=", "0", ")", ":", "a", "=", "TpPd", "(", "pd", "=", "0x3", ")", "b", "=", "MessageType", "(", "mesType", "=", "0x10", ")", "# 00010000", "c", "=", "MobileId", "(", ")", "d", "=", "Rou...
P-TMSI REALLOCATION COMMAND Section 9.4.7
[ "P", "-", "TMSI", "REALLOCATION", "COMMAND", "Section", "9", ".", "4", ".", "7" ]
python
train
gem/oq-engine
openquake/hazardlib/probability_map.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/probability_map.py#L222-L245
def convert2(self, imtls, sids): """ Convert a probability map into a composite array of shape (N,) and dtype `imtls.dt`. :param imtls: DictArray instance :param sids: the IDs of the sites we are interested in :returns: an array of cur...
[ "def", "convert2", "(", "self", ",", "imtls", ",", "sids", ")", ":", "assert", "self", ".", "shape_z", "==", "1", ",", "self", ".", "shape_z", "curves", "=", "numpy", ".", "zeros", "(", "len", "(", "sids", ")", ",", "imtls", ".", "dt", ")", "for"...
Convert a probability map into a composite array of shape (N,) and dtype `imtls.dt`. :param imtls: DictArray instance :param sids: the IDs of the sites we are interested in :returns: an array of curves of shape (N,)
[ "Convert", "a", "probability", "map", "into", "a", "composite", "array", "of", "shape", "(", "N", ")", "and", "dtype", "imtls", ".", "dt", "." ]
python
train
kubernetes-client/python
kubernetes/client/apis/autoscaling_v2beta1_api.py
https://github.com/kubernetes-client/python/blob/5e512ff564c244c50cab780d821542ed56aa965a/kubernetes/client/apis/autoscaling_v2beta1_api.py#L1219-L1243
def replace_namespaced_horizontal_pod_autoscaler(self, name, namespace, body, **kwargs): """ replace the specified HorizontalPodAutoscaler This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.re...
[ "def", "replace_namespaced_horizontal_pod_autoscaler", "(", "self", ",", "name", ",", "namespace", ",", "body", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async_req'", ")",...
replace the specified HorizontalPodAutoscaler This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.replace_namespaced_horizontal_pod_autoscaler(name, namespace, body, async_req=True) >>> result = thread...
[ "replace", "the", "specified", "HorizontalPodAutoscaler", "This", "method", "makes", "a", "synchronous", "HTTP", "request", "by", "default", ".", "To", "make", "an", "asynchronous", "HTTP", "request", "please", "pass", "async_req", "=", "True", ">>>", "thread", ...
python
train
knipknap/exscript
Exscript/account.py
https://github.com/knipknap/exscript/blob/72718eee3e87b345d5a5255be9824e867e42927b/Exscript/account.py#L105-L121
def acquire(self, signal=True): """ Locks the account. Method has no effect if the constructor argument `needs_lock` wsa set to False. :type signal: bool :param signal: Whether to emit the acquired_event signal. """ if not self.needs_lock: ret...
[ "def", "acquire", "(", "self", ",", "signal", "=", "True", ")", ":", "if", "not", "self", ".", "needs_lock", ":", "return", "with", "self", ".", "synclock", ":", "while", "not", "self", ".", "lock", ".", "acquire", "(", "False", ")", ":", "self", "...
Locks the account. Method has no effect if the constructor argument `needs_lock` wsa set to False. :type signal: bool :param signal: Whether to emit the acquired_event signal.
[ "Locks", "the", "account", ".", "Method", "has", "no", "effect", "if", "the", "constructor", "argument", "needs_lock", "wsa", "set", "to", "False", "." ]
python
train
astropy/regions
regions/io/ds9/read.py
https://github.com/astropy/regions/blob/452d962c417e4ff20d1268f99535c6ff89c83437/regions/io/ds9/read.py#L215-L224
def set_coordsys(self, coordsys): """ Transform coordinate system # TODO: needs expert attention """ if coordsys in self.coordsys_mapping: self.coordsys = self.coordsys_mapping[coordsys] else: self.coordsys = coordsys
[ "def", "set_coordsys", "(", "self", ",", "coordsys", ")", ":", "if", "coordsys", "in", "self", ".", "coordsys_mapping", ":", "self", ".", "coordsys", "=", "self", ".", "coordsys_mapping", "[", "coordsys", "]", "else", ":", "self", ".", "coordsys", "=", "...
Transform coordinate system # TODO: needs expert attention
[ "Transform", "coordinate", "system" ]
python
train
PSPC-SPAC-buyandsell/von_anchor
von_anchor/anchor/issuer.py
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/issuer.py#L424-L462
async def create_cred_offer(self, schema_seq_no: int) -> str: """ Create credential offer as Issuer for given schema. Raise CorruptWallet if the wallet has no private key for the corresponding credential definition. Raise WalletState for closed wallet. :param schema_seq_no: sch...
[ "async", "def", "create_cred_offer", "(", "self", ",", "schema_seq_no", ":", "int", ")", "->", "str", ":", "LOGGER", ".", "debug", "(", "'Issuer.create_cred_offer >>> schema_seq_no: %s'", ",", "schema_seq_no", ")", "if", "not", "self", ".", "wallet", ".", "handl...
Create credential offer as Issuer for given schema. Raise CorruptWallet if the wallet has no private key for the corresponding credential definition. Raise WalletState for closed wallet. :param schema_seq_no: schema sequence number :return: credential offer json for use in storing cred...
[ "Create", "credential", "offer", "as", "Issuer", "for", "given", "schema", "." ]
python
train
blockstack/blockstack-core
blockstack/lib/fast_sync.py
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/fast_sync.py#L243-L407
def fast_sync_snapshot(working_dir, export_path, private_key, block_number ): """ Export all the local state for fast-sync. If block_number is given, then the name database at that particular block number will be taken. The exported tarball will be signed with the given private key, and the sig...
[ "def", "fast_sync_snapshot", "(", "working_dir", ",", "export_path", ",", "private_key", ",", "block_number", ")", ":", "db_paths", "=", "None", "found", "=", "True", "tmpdir", "=", "None", "namedb_path", "=", "None", "def", "_cleanup", "(", "path", ")", ":"...
Export all the local state for fast-sync. If block_number is given, then the name database at that particular block number will be taken. The exported tarball will be signed with the given private key, and the signature will be appended to the end of the file. Return True if we succeed Return ...
[ "Export", "all", "the", "local", "state", "for", "fast", "-", "sync", ".", "If", "block_number", "is", "given", "then", "the", "name", "database", "at", "that", "particular", "block", "number", "will", "be", "taken", "." ]
python
train
profitbricks/profitbricks-sdk-python
examples/pb_createDatacenter.py
https://github.com/profitbricks/profitbricks-sdk-python/blob/2c804b141688eccb07d6ae56601d5c60a62abebd/examples/pb_createDatacenter.py#L443-L663
def main(argv=None): '''Parse command line options and create a server/volume composite.''' if argv is None: argv = sys.argv else: sys.argv.extend(argv) program_name = os.path.basename(sys.argv[0]) program_version = "v%s" % __version__ program_build_date = str(__updated__) ...
[ "def", "main", "(", "argv", "=", "None", ")", ":", "if", "argv", "is", "None", ":", "argv", "=", "sys", ".", "argv", "else", ":", "sys", ".", "argv", ".", "extend", "(", "argv", ")", "program_name", "=", "os", ".", "path", ".", "basename", "(", ...
Parse command line options and create a server/volume composite.
[ "Parse", "command", "line", "options", "and", "create", "a", "server", "/", "volume", "composite", "." ]
python
valid
emichael/PyREM
pyrem/task.py
https://github.com/emichael/PyREM/blob/2609249ead197cd9496d164f4998ca9985503579/pyrem/task.py#L133-L149
def stop(self): """Stop a task immediately. Raises: RuntimeError: If the task hasn't been started or has already been stopped. """ if self._status is TaskStatus.STOPPED: return if self._status is not TaskStatus.STARTED: raise ...
[ "def", "stop", "(", "self", ")", ":", "if", "self", ".", "_status", "is", "TaskStatus", ".", "STOPPED", ":", "return", "if", "self", ".", "_status", "is", "not", "TaskStatus", ".", "STARTED", ":", "raise", "RuntimeError", "(", "\"Cannot stop %s in state %s\"...
Stop a task immediately. Raises: RuntimeError: If the task hasn't been started or has already been stopped.
[ "Stop", "a", "task", "immediately", "." ]
python
train
F5Networks/f5-common-python
f5/bigip/tm/ltm/policy.py
https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/tm/ltm/policy.py#L64-L79
def _filter_version_specific_options(self, tmos_ver, **kwargs): '''Filter version-specific optional parameters Some optional parameters only exist in v12.1.0 and greater, filter these out for earlier versions to allow backward comatibility. ''' if LooseVersion(tmos_ver) < Loose...
[ "def", "_filter_version_specific_options", "(", "self", ",", "tmos_ver", ",", "*", "*", "kwargs", ")", ":", "if", "LooseVersion", "(", "tmos_ver", ")", "<", "LooseVersion", "(", "'12.1.0'", ")", ":", "for", "k", ",", "parms", "in", "self", ".", "_meta_data...
Filter version-specific optional parameters Some optional parameters only exist in v12.1.0 and greater, filter these out for earlier versions to allow backward comatibility.
[ "Filter", "version", "-", "specific", "optional", "parameters" ]
python
train
cihai/cihai
cihai/conversion.py
https://github.com/cihai/cihai/blob/43b0c2931da18c1ef1ff1cdd71e4b1c5eca24a41/cihai/conversion.py#L114-L124
def euc_to_utf8(euchex): """ Convert EUC hex (e.g. "d2bb") to UTF8 hex (e.g. "e4 b8 80"). """ utf8 = euc_to_python(euchex).encode("utf-8") uf8 = utf8.decode('unicode_escape') uf8 = uf8.encode('latin1') uf8 = uf8.decode('euc-jp') return uf8
[ "def", "euc_to_utf8", "(", "euchex", ")", ":", "utf8", "=", "euc_to_python", "(", "euchex", ")", ".", "encode", "(", "\"utf-8\"", ")", "uf8", "=", "utf8", ".", "decode", "(", "'unicode_escape'", ")", "uf8", "=", "uf8", ".", "encode", "(", "'latin1'", "...
Convert EUC hex (e.g. "d2bb") to UTF8 hex (e.g. "e4 b8 80").
[ "Convert", "EUC", "hex", "(", "e", ".", "g", ".", "d2bb", ")", "to", "UTF8", "hex", "(", "e", ".", "g", ".", "e4", "b8", "80", ")", "." ]
python
train
log2timeline/plaso
plaso/parsers/winevt.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/parsers/winevt.py#L181-L217
def _ParseRecords(self, parser_mediator, evt_file): """Parses Windows EventLog (EVT) records. Args: parser_mediator (ParserMediator): mediates interactions between parsers and other components, such as storage and dfvfs. evt_file (pyevt.file): Windows EventLog (EVT) file. """ # To...
[ "def", "_ParseRecords", "(", "self", ",", "parser_mediator", ",", "evt_file", ")", ":", "# To handle errors when parsing a Windows EventLog (EVT) file in the most", "# granular way the following code iterates over every event record. The", "# call to evt_file.get_record() and access to membe...
Parses Windows EventLog (EVT) records. Args: parser_mediator (ParserMediator): mediates interactions between parsers and other components, such as storage and dfvfs. evt_file (pyevt.file): Windows EventLog (EVT) file.
[ "Parses", "Windows", "EventLog", "(", "EVT", ")", "records", "." ]
python
train
federico123579/Trading212-API
tradingAPI/low_level.py
https://github.com/federico123579/Trading212-API/blob/0fab20b71a2348e72bbe76071b81f3692128851f/tradingAPI/low_level.py#L131-L166
def login(self, username, password, mode="demo"): """login function""" url = "https://trading212.com/it/login" try: logger.debug(f"visiting %s" % url) self.browser.visit(url) logger.debug(f"connected to %s" % url) except selenium.common.exceptions.WebD...
[ "def", "login", "(", "self", ",", "username", ",", "password", ",", "mode", "=", "\"demo\"", ")", ":", "url", "=", "\"https://trading212.com/it/login\"", "try", ":", "logger", ".", "debug", "(", "f\"visiting %s\"", "%", "url", ")", "self", ".", "browser", ...
login function
[ "login", "function" ]
python
train
hfaran/progressive
progressive/cursor.py
https://github.com/hfaran/progressive/blob/e39c7fb17405dbe997c3417a5993b94ef16dab0a/progressive/cursor.py#L46-L49
def newline(self): """Effects a newline by moving the cursor down and clearing""" self.write(self.term.move_down) self.write(self.term.clear_bol)
[ "def", "newline", "(", "self", ")", ":", "self", ".", "write", "(", "self", ".", "term", ".", "move_down", ")", "self", ".", "write", "(", "self", ".", "term", ".", "clear_bol", ")" ]
Effects a newline by moving the cursor down and clearing
[ "Effects", "a", "newline", "by", "moving", "the", "cursor", "down", "and", "clearing" ]
python
train
closeio/quotequail
quotequail/_internal.py
https://github.com/closeio/quotequail/blob/8a3960c033d595b25a8bbc2c340be898e3065b5f/quotequail/_internal.py#L9-L27
def find_pattern_on_line(lines, n, max_wrap_lines): """ Finds a forward/reply pattern within the given lines on text on the given line number and returns a tuple with the type ('reply' or 'forward') and line number of where the pattern ends. The returned line number may be different from the given l...
[ "def", "find_pattern_on_line", "(", "lines", ",", "n", ",", "max_wrap_lines", ")", ":", "for", "typ", ",", "regexes", "in", "COMPILED_PATTERN_MAP", ".", "items", "(", ")", ":", "for", "regex", "in", "regexes", ":", "for", "m", "in", "range", "(", "max_wr...
Finds a forward/reply pattern within the given lines on text on the given line number and returns a tuple with the type ('reply' or 'forward') and line number of where the pattern ends. The returned line number may be different from the given line number in case the pattern wraps over multiple lines. ...
[ "Finds", "a", "forward", "/", "reply", "pattern", "within", "the", "given", "lines", "on", "text", "on", "the", "given", "line", "number", "and", "returns", "a", "tuple", "with", "the", "type", "(", "reply", "or", "forward", ")", "and", "line", "number",...
python
train
deepmind/sonnet
sonnet/python/modules/nets/alexnet.py
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/nets/alexnet.py#L154-L179
def _calc_min_size(self, conv_layers): """Calculates the minimum size of the input layer. Given a set of convolutional layers, calculate the minimum value of the `input_height` and `input_width`, i.e. such that the output has size 1x1. Assumes snt.VALID padding. Args: conv_layers: List of tu...
[ "def", "_calc_min_size", "(", "self", ",", "conv_layers", ")", ":", "input_size", "=", "1", "for", "_", ",", "conv_params", ",", "max_pooling", "in", "reversed", "(", "conv_layers", ")", ":", "if", "max_pooling", "is", "not", "None", ":", "kernel_size", ",...
Calculates the minimum size of the input layer. Given a set of convolutional layers, calculate the minimum value of the `input_height` and `input_width`, i.e. such that the output has size 1x1. Assumes snt.VALID padding. Args: conv_layers: List of tuples `(output_channels, (kernel_size, stride),...
[ "Calculates", "the", "minimum", "size", "of", "the", "input", "layer", "." ]
python
train
ladybug-tools/ladybug
ladybug/skymodel.py
https://github.com/ladybug-tools/ladybug/blob/c08b7308077a48d5612f644943f92d5b5dade583/ladybug/skymodel.py#L823-L1157
def _get_dirint_coeffs(): """ Here be a large multi-dimensional matrix of dirint coefficients. Returns: Array with shape ``(6, 6, 7, 5)``. Ordering is ``[kt_prime_bin, zenith_bin, delta_kt_prime_bin, w_bin]`` """ coeffs = [[0 for i in range(6)] for j in range(6)] coeffs[0][0] =...
[ "def", "_get_dirint_coeffs", "(", ")", ":", "coeffs", "=", "[", "[", "0", "for", "i", "in", "range", "(", "6", ")", "]", "for", "j", "in", "range", "(", "6", ")", "]", "coeffs", "[", "0", "]", "[", "0", "]", "=", "[", "[", "0.385230", ",", ...
Here be a large multi-dimensional matrix of dirint coefficients. Returns: Array with shape ``(6, 6, 7, 5)``. Ordering is ``[kt_prime_bin, zenith_bin, delta_kt_prime_bin, w_bin]``
[ "Here", "be", "a", "large", "multi", "-", "dimensional", "matrix", "of", "dirint", "coefficients", "." ]
python
train
elbow-jason/Uno-deprecated
uno/decorators.py
https://github.com/elbow-jason/Uno-deprecated/blob/4ad07d7b84e5b6e3e2b2c89db69448906f24b4e4/uno/decorators.py#L11-L27
def change_return_type(f): """ Converts the returned value of wrapped function to the type of the first arg or to the type specified by a kwarg key return_type's value. """ @wraps(f) def wrapper(*args, **kwargs): if kwargs.has_key('return_type'): return_type = kwargs['return_...
[ "def", "change_return_type", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "kwargs", ".", "has_key", "(", "'return_type'", ")", ":", "return_type", "=", "kwargs", "[", ...
Converts the returned value of wrapped function to the type of the first arg or to the type specified by a kwarg key return_type's value.
[ "Converts", "the", "returned", "value", "of", "wrapped", "function", "to", "the", "type", "of", "the", "first", "arg", "or", "to", "the", "type", "specified", "by", "a", "kwarg", "key", "return_type", "s", "value", "." ]
python
train
CamDavidsonPilon/lifelines
lifelines/fitters/cox_time_varying_fitter.py
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/cox_time_varying_fitter.py#L612-L668
def print_summary(self, decimals=2, **kwargs): """ Print summary statistics describing the fit, the coefficients, and the error bounds. Parameters ----------- decimals: int, optional (default=2) specify the number of decimal places to show kwargs: ...
[ "def", "print_summary", "(", "self", ",", "decimals", "=", "2", ",", "*", "*", "kwargs", ")", ":", "# Print information about data first", "justify", "=", "string_justify", "(", "18", ")", "print", "(", "self", ")", "print", "(", "\"{} = '{}'\"", ".", "forma...
Print summary statistics describing the fit, the coefficients, and the error bounds. Parameters ----------- decimals: int, optional (default=2) specify the number of decimal places to show kwargs: print additional meta data in the output (useful to provide model ...
[ "Print", "summary", "statistics", "describing", "the", "fit", "the", "coefficients", "and", "the", "error", "bounds", "." ]
python
train
Azure/azure-cosmos-table-python
azure-cosmosdb-table/azure/cosmosdb/table/tableservice.py
https://github.com/Azure/azure-cosmos-table-python/blob/a7b618f6bddc465c9fdf899ea2971dfe4d04fcf0/azure-cosmosdb-table/azure/cosmosdb/table/tableservice.py#L335-L369
def get_table_service_stats(self, timeout=None): ''' Retrieves statistics related to replication for the Table service. It is only available when read-access geo-redundant replication is enabled for the storage account. With geo-redundant replication, Azure Storage maintains y...
[ "def", "get_table_service_stats", "(", "self", ",", "timeout", "=", "None", ")", ":", "request", "=", "HTTPRequest", "(", ")", "request", ".", "method", "=", "'GET'", "request", ".", "host_locations", "=", "self", ".", "_get_host_locations", "(", "primary", ...
Retrieves statistics related to replication for the Table service. It is only available when read-access geo-redundant replication is enabled for the storage account. With geo-redundant replication, Azure Storage maintains your data durable in two locations. In both locations, Azure ...
[ "Retrieves", "statistics", "related", "to", "replication", "for", "the", "Table", "service", ".", "It", "is", "only", "available", "when", "read", "-", "access", "geo", "-", "redundant", "replication", "is", "enabled", "for", "the", "storage", "account", "." ]
python
train
ptcryan/hydrawiser
hydrawiser/core.py
https://github.com/ptcryan/hydrawiser/blob/53acafb08b5cee0f6628414044b9b9f9a0b15e50/hydrawiser/core.py#L132-L161
def suspend_zone(self, days, zone=None): """ Suspend or unsuspend a zone or all zones for an amount of time. :param days: Number of days to suspend the zone(s) :type days: int :param zone: The zone to suspend. If no zone is specified then suspend all zones ...
[ "def", "suspend_zone", "(", "self", ",", "days", ",", "zone", "=", "None", ")", ":", "if", "zone", "is", "None", ":", "zone_cmd", "=", "'suspendall'", "relay_id", "=", "None", "else", ":", "if", "zone", "<", "0", "or", "zone", ">", "(", "len", "(",...
Suspend or unsuspend a zone or all zones for an amount of time. :param days: Number of days to suspend the zone(s) :type days: int :param zone: The zone to suspend. If no zone is specified then suspend all zones :type zone: int or None :returns: The response...
[ "Suspend", "or", "unsuspend", "a", "zone", "or", "all", "zones", "for", "an", "amount", "of", "time", "." ]
python
train
PaloAltoNetworks/pancloud
pancloud/logging.py
https://github.com/PaloAltoNetworks/pancloud/blob/c51e4c8aca3c988c60f062291007534edcb55285/pancloud/logging.py#L298-L330
def write(self, vendor_id=None, log_type=None, json=None, **kwargs): """Write log records to the Logging Service. This API requires a JSON array in its request body, each element of which represents a single log record. Log records are provided as JSON objects. Every log record must inc...
[ "def", "write", "(", "self", ",", "vendor_id", "=", "None", ",", "log_type", "=", "None", ",", "json", "=", "None", ",", "*", "*", "kwargs", ")", ":", "path", "=", "\"/logging-service/v1/logs/{}/{}\"", ".", "format", "(", "vendor_id", ",", "log_type", ")...
Write log records to the Logging Service. This API requires a JSON array in its request body, each element of which represents a single log record. Log records are provided as JSON objects. Every log record must include the primary timestamp field that you identified when you registered...
[ "Write", "log", "records", "to", "the", "Logging", "Service", "." ]
python
train
cjdrake/pyeda
pyeda/boolalg/expr.py
https://github.com/cjdrake/pyeda/blob/554ee53aa678f4b61bcd7e07ba2c74ddc749d665/pyeda/boolalg/expr.py#L136-L180
def exprvar(name, index=None): r"""Return a unique Expression variable. A Boolean *variable* is an abstract numerical quantity that may assume any value in the set :math:`B = \{0, 1\}`. The ``exprvar`` function returns a unique Boolean variable instance represented by a logic expression. Variab...
[ "def", "exprvar", "(", "name", ",", "index", "=", "None", ")", ":", "bvar", "=", "boolfunc", ".", "var", "(", "name", ",", "index", ")", "try", ":", "var", "=", "_LITS", "[", "bvar", ".", "uniqid", "]", "except", "KeyError", ":", "var", "=", "_LI...
r"""Return a unique Expression variable. A Boolean *variable* is an abstract numerical quantity that may assume any value in the set :math:`B = \{0, 1\}`. The ``exprvar`` function returns a unique Boolean variable instance represented by a logic expression. Variable instances may be used to symboli...
[ "r", "Return", "a", "unique", "Expression", "variable", "." ]
python
train
praekeltfoundation/molo.commenting
molo/commenting/admin.py
https://github.com/praekeltfoundation/molo.commenting/blob/94549bd75e4a5c5b3db43149e32d636330b3969c/molo/commenting/admin.py#L156-L170
def change_view(self, request, object_id, form_url='', extra_context=None): """ Override change view to add extra context enabling moderate tool. """ context = { 'has_moderate_tool': True } if extra_context: context.update(extra_context) re...
[ "def", "change_view", "(", "self", ",", "request", ",", "object_id", ",", "form_url", "=", "''", ",", "extra_context", "=", "None", ")", ":", "context", "=", "{", "'has_moderate_tool'", ":", "True", "}", "if", "extra_context", ":", "context", ".", "update"...
Override change view to add extra context enabling moderate tool.
[ "Override", "change", "view", "to", "add", "extra", "context", "enabling", "moderate", "tool", "." ]
python
train
splunk/splunk-sdk-python
splunklib/client.py
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L2690-L2699
def is_done(self): """Indicates whether this job finished running. :return: ``True`` if the job is done, ``False`` if not. :rtype: ``boolean`` """ if not self.is_ready(): return False done = (self._state.content['isDone'] == '1') return done
[ "def", "is_done", "(", "self", ")", ":", "if", "not", "self", ".", "is_ready", "(", ")", ":", "return", "False", "done", "=", "(", "self", ".", "_state", ".", "content", "[", "'isDone'", "]", "==", "'1'", ")", "return", "done" ]
Indicates whether this job finished running. :return: ``True`` if the job is done, ``False`` if not. :rtype: ``boolean``
[ "Indicates", "whether", "this", "job", "finished", "running", "." ]
python
train
ioam/lancet
lancet/launch.py
https://github.com/ioam/lancet/blob/1fbbf88fa0e8974ff9ed462e3cb11722ddebdd6e/lancet/launch.py#L1019-L1051
def _review_all(self, launchers): """ Runs the review process for all the launchers. """ # Run review of launch args if necessary if self.launch_args is not None: proceed = self.review_args(self.launch_args, show_repr=True, ...
[ "def", "_review_all", "(", "self", ",", "launchers", ")", ":", "# Run review of launch args if necessary", "if", "self", ".", "launch_args", "is", "not", "None", ":", "proceed", "=", "self", ".", "review_args", "(", "self", ".", "launch_args", ",", "show_repr", ...
Runs the review process for all the launchers.
[ "Runs", "the", "review", "process", "for", "all", "the", "launchers", "." ]
python
valid
junaruga/rpm-py-installer
install.py
https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L1761-L1767
def sh_e_out(cls, cmd, **kwargs): """Run the command. and returns the stdout.""" cmd_kwargs = { 'stdout': subprocess.PIPE, } cmd_kwargs.update(kwargs) return cls.sh_e(cmd, **cmd_kwargs)[0]
[ "def", "sh_e_out", "(", "cls", ",", "cmd", ",", "*", "*", "kwargs", ")", ":", "cmd_kwargs", "=", "{", "'stdout'", ":", "subprocess", ".", "PIPE", ",", "}", "cmd_kwargs", ".", "update", "(", "kwargs", ")", "return", "cls", ".", "sh_e", "(", "cmd", "...
Run the command. and returns the stdout.
[ "Run", "the", "command", ".", "and", "returns", "the", "stdout", "." ]
python
train
gem/oq-engine
openquake/hazardlib/sourceconverter.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L80-L97
def collect(cls, sources): """ :param sources: dictionaries with a key 'tectonicRegion' :returns: an ordered list of SourceGroup instances """ source_stats_dict = {} for src in sources: trt = src['tectonicRegion'] if trt not in source_stats_dict: ...
[ "def", "collect", "(", "cls", ",", "sources", ")", ":", "source_stats_dict", "=", "{", "}", "for", "src", "in", "sources", ":", "trt", "=", "src", "[", "'tectonicRegion'", "]", "if", "trt", "not", "in", "source_stats_dict", ":", "source_stats_dict", "[", ...
:param sources: dictionaries with a key 'tectonicRegion' :returns: an ordered list of SourceGroup instances
[ ":", "param", "sources", ":", "dictionaries", "with", "a", "key", "tectonicRegion", ":", "returns", ":", "an", "ordered", "list", "of", "SourceGroup", "instances" ]
python
train
mbj4668/pyang
pyang/translators/schemanode.py
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/translators/schemanode.py#L152-L155
def annot(self, node): """Add `node` as an annotation of the receiver.""" self.annots.append(node) node.parent = self
[ "def", "annot", "(", "self", ",", "node", ")", ":", "self", ".", "annots", ".", "append", "(", "node", ")", "node", ".", "parent", "=", "self" ]
Add `node` as an annotation of the receiver.
[ "Add", "node", "as", "an", "annotation", "of", "the", "receiver", "." ]
python
train
dade-ai/snipy
snipy/decotool.py
https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/decotool.py#L85-L114
def bindargs(fun, *argsbind, **kwbind): """ _ = bind.placeholder # unbound placeholder (arg) f = bind(fun, _, _, arg3, kw=kw1, kw2=kw2), f(arg1, arg2) :param fun: :param argsbind: :param kwbind: :return: """ assert argsbind argsb = list(argsbind) iargs = [i for i in range(...
[ "def", "bindargs", "(", "fun", ",", "*", "argsbind", ",", "*", "*", "kwbind", ")", ":", "assert", "argsbind", "argsb", "=", "list", "(", "argsbind", ")", "iargs", "=", "[", "i", "for", "i", "in", "range", "(", "len", "(", "argsbind", ")", ")", "i...
_ = bind.placeholder # unbound placeholder (arg) f = bind(fun, _, _, arg3, kw=kw1, kw2=kw2), f(arg1, arg2) :param fun: :param argsbind: :param kwbind: :return:
[ "_", "=", "bind", ".", "placeholder", "#", "unbound", "placeholder", "(", "arg", ")", "f", "=", "bind", "(", "fun", "_", "_", "arg3", "kw", "=", "kw1", "kw2", "=", "kw2", ")", "f", "(", "arg1", "arg2", ")", ":", "param", "fun", ":", ":", "param...
python
valid
Kozea/cairocffi
cairocffi/context.py
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/context.py#L1456-L1471
def in_fill(self, x, y): """Tests whether the given point is inside the area that would be affected by a :meth:`fill` operation given the current path and filling parameters. Surface dimensions and clipping are not taken into account. See :meth:`fill`, :meth:`set_fill_rule` and ...
[ "def", "in_fill", "(", "self", ",", "x", ",", "y", ")", ":", "return", "bool", "(", "cairo", ".", "cairo_in_fill", "(", "self", ".", "_pointer", ",", "x", ",", "y", ")", ")" ]
Tests whether the given point is inside the area that would be affected by a :meth:`fill` operation given the current path and filling parameters. Surface dimensions and clipping are not taken into account. See :meth:`fill`, :meth:`set_fill_rule` and :meth:`fill_preserve`. :par...
[ "Tests", "whether", "the", "given", "point", "is", "inside", "the", "area", "that", "would", "be", "affected", "by", "a", ":", "meth", ":", "fill", "operation", "given", "the", "current", "path", "and", "filling", "parameters", ".", "Surface", "dimensions", ...
python
train
SiLab-Bonn/basil
basil/HL/SussProber.py
https://github.com/SiLab-Bonn/basil/blob/99052482d9334dd1f5598eb2d2fb4d5399a32291/basil/HL/SussProber.py#L27-L32
def move_position(self, dx, dy, speed=None): ''' Move chuck relative to actual position in um''' if speed: self._intf.write('MoveChuckPosition %1.1f %1.1f R Y %d' % (dx, dy, speed)) else: self._intf.write('MoveChuckPosition %1.1f %1.1f R Y' % (dx, dy))
[ "def", "move_position", "(", "self", ",", "dx", ",", "dy", ",", "speed", "=", "None", ")", ":", "if", "speed", ":", "self", ".", "_intf", ".", "write", "(", "'MoveChuckPosition %1.1f %1.1f R Y %d'", "%", "(", "dx", ",", "dy", ",", "speed", ")", ")", ...
Move chuck relative to actual position in um
[ "Move", "chuck", "relative", "to", "actual", "position", "in", "um" ]
python
train
batiste/django-page-cms
pages/utils.py
https://github.com/batiste/django-page-cms/blob/3c72111eb7c3997a63c462c1776ffd8ce8c50a5d/pages/utils.py#L139-L154
def slugify(value, allow_unicode=False): """ Convert to ASCII if 'allow_unicode' is False. Convert spaces to hyphens. Remove characters that aren't alphanumerics, underscores, or hyphens. Convert to lowercase. Also strip leading and trailing whitespace. Copyright: https://docs.djangoproject.com/en/1...
[ "def", "slugify", "(", "value", ",", "allow_unicode", "=", "False", ")", ":", "value", "=", "force_text", "(", "value", ")", "if", "allow_unicode", ":", "value", "=", "unicodedata", ".", "normalize", "(", "'NFKC'", ",", "value", ")", "value", "=", "re", ...
Convert to ASCII if 'allow_unicode' is False. Convert spaces to hyphens. Remove characters that aren't alphanumerics, underscores, or hyphens. Convert to lowercase. Also strip leading and trailing whitespace. Copyright: https://docs.djangoproject.com/en/1.9/_modules/django/utils/text/#slugify TODO: repl...
[ "Convert", "to", "ASCII", "if", "allow_unicode", "is", "False", ".", "Convert", "spaces", "to", "hyphens", ".", "Remove", "characters", "that", "aren", "t", "alphanumerics", "underscores", "or", "hyphens", ".", "Convert", "to", "lowercase", ".", "Also", "strip...
python
train
robertpeteuil/multi-cloud-control
mcc/core.py
https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/core.py#L115-L132
def config_cred(config, providers): """Read credentials from configfile.""" expected = ['aws', 'azure', 'gcp', 'alicloud'] cred = {} to_remove = [] for item in providers: if any(item.startswith(itemb) for itemb in expected): try: cred[item] = dict(list(config[item...
[ "def", "config_cred", "(", "config", ",", "providers", ")", ":", "expected", "=", "[", "'aws'", ",", "'azure'", ",", "'gcp'", ",", "'alicloud'", "]", "cred", "=", "{", "}", "to_remove", "=", "[", "]", "for", "item", "in", "providers", ":", "if", "any...
Read credentials from configfile.
[ "Read", "credentials", "from", "configfile", "." ]
python
train
twilio/twilio-python
twilio/rest/trunking/v1/trunk/terminating_sip_domain.py
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/trunking/v1/trunk/terminating_sip_domain.py#L309-L323
def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: TerminatingSipDomainContext for this TerminatingSipDomainInstance :rtype: twilio.rest.trunking.v1...
[ "def", "_proxy", "(", "self", ")", ":", "if", "self", ".", "_context", "is", "None", ":", "self", ".", "_context", "=", "TerminatingSipDomainContext", "(", "self", ".", "_version", ",", "trunk_sid", "=", "self", ".", "_solution", "[", "'trunk_sid'", "]", ...
Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: TerminatingSipDomainContext for this TerminatingSipDomainInstance :rtype: twilio.rest.trunking.v1.trunk.terminating_sip_domain.Terminat...
[ "Generate", "an", "instance", "context", "for", "the", "instance", "the", "context", "is", "capable", "of", "performing", "various", "actions", ".", "All", "instance", "actions", "are", "proxied", "to", "the", "context" ]
python
train
danilobellini/audiolazy
audiolazy/lazy_analysis.py
https://github.com/danilobellini/audiolazy/blob/dba0a278937909980ed40b976d866b8e97c35dee/audiolazy/lazy_analysis.py#L865-L1143
def stft(func=None, **kwparams): """ Short Time Fourier Transform block processor / phase vocoder wrapper. This function can be used in many ways: * Directly as a signal processor builder, wrapping a spectrum block/grain processor function; * Directly as a decorator to a block processor; * Called with...
[ "def", "stft", "(", "func", "=", "None", ",", "*", "*", "kwparams", ")", ":", "# Using as a decorator or to \"replicate\" this function with other defaults", "if", "func", "is", "None", ":", "cfi", "=", "chain", ".", "from_iterable", "mix_dict", "=", "lambda", "*"...
Short Time Fourier Transform block processor / phase vocoder wrapper. This function can be used in many ways: * Directly as a signal processor builder, wrapping a spectrum block/grain processor function; * Directly as a decorator to a block processor; * Called without the ``func`` parameter for a partial ...
[ "Short", "Time", "Fourier", "Transform", "block", "processor", "/", "phase", "vocoder", "wrapper", "." ]
python
train
lordmauve/lepton
examples/games/bonk/controls.py
https://github.com/lordmauve/lepton/blob/bf03f2c20ea8c51ade632f692d0a21e520fbba7c/examples/games/bonk/controls.py#L95-L100
def configure_keys(self): """Configure key map""" self.active_functions = set() self.key2func = {} for funcname, key in self.key_map.items(): self.key2func[key] = getattr(self, funcname)
[ "def", "configure_keys", "(", "self", ")", ":", "self", ".", "active_functions", "=", "set", "(", ")", "self", ".", "key2func", "=", "{", "}", "for", "funcname", ",", "key", "in", "self", ".", "key_map", ".", "items", "(", ")", ":", "self", ".", "k...
Configure key map
[ "Configure", "key", "map" ]
python
train
erikrose/more-itertools
more_itertools/more.py
https://github.com/erikrose/more-itertools/blob/6a91b4e25c8e12fcf9fc2b53cf8ee0fba293e6f9/more_itertools/more.py#L334-L345
def _collate(*iterables, key=lambda a: a, reverse=False): """Helper for ``collate()``, called when the user is using the ``reverse`` or ``key`` keyword arguments on Python versions below 3.5. """ min_or_max = partial(max if reverse else min, key=itemgetter(0)) peekables = [peekable(it) for it in it...
[ "def", "_collate", "(", "*", "iterables", ",", "key", "=", "lambda", "a", ":", "a", ",", "reverse", "=", "False", ")", ":", "min_or_max", "=", "partial", "(", "max", "if", "reverse", "else", "min", ",", "key", "=", "itemgetter", "(", "0", ")", ")",...
Helper for ``collate()``, called when the user is using the ``reverse`` or ``key`` keyword arguments on Python versions below 3.5.
[ "Helper", "for", "collate", "()", "called", "when", "the", "user", "is", "using", "the", "reverse", "or", "key", "keyword", "arguments", "on", "Python", "versions", "below", "3", ".", "5", "." ]
python
train
Calysto/calysto
calysto/ai/conx.py
https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L2128-L2136
def activationFunctionASIG(self, x): """ Determine the activation of a node based on that nodes net input. """ def act(v): if v < -15.0: return 0.0 elif v > 15.0: return 1.0 else: return 1.0 / (1.0 + Numeric.exp(-v)) return Numeric.array(lis...
[ "def", "activationFunctionASIG", "(", "self", ",", "x", ")", ":", "def", "act", "(", "v", ")", ":", "if", "v", "<", "-", "15.0", ":", "return", "0.0", "elif", "v", ">", "15.0", ":", "return", "1.0", "else", ":", "return", "1.0", "/", "(", "1.0", ...
Determine the activation of a node based on that nodes net input.
[ "Determine", "the", "activation", "of", "a", "node", "based", "on", "that", "nodes", "net", "input", "." ]
python
train
ChristopherRabotin/bungiesearch
bungiesearch/utils.py
https://github.com/ChristopherRabotin/bungiesearch/blob/13768342bc2698b214eb0003c2d113b6e273c30d/bungiesearch/utils.py#L90-L103
def create_indexed_document(index_instance, model_items, action): ''' Creates the document that will be passed into the bulk index function. Either a list of serialized objects to index, or a a dictionary specifying the primary keys of items to be delete. ''' data = [] if action == 'delete': ...
[ "def", "create_indexed_document", "(", "index_instance", ",", "model_items", ",", "action", ")", ":", "data", "=", "[", "]", "if", "action", "==", "'delete'", ":", "for", "pk", "in", "model_items", ":", "data", ".", "append", "(", "{", "'_id'", ":", "pk"...
Creates the document that will be passed into the bulk index function. Either a list of serialized objects to index, or a a dictionary specifying the primary keys of items to be delete.
[ "Creates", "the", "document", "that", "will", "be", "passed", "into", "the", "bulk", "index", "function", ".", "Either", "a", "list", "of", "serialized", "objects", "to", "index", "or", "a", "a", "dictionary", "specifying", "the", "primary", "keys", "of", ...
python
train
rytilahti/python-eq3bt
eq3bt/eq3btsmart.py
https://github.com/rytilahti/python-eq3bt/blob/595459d9885920cf13b7059a1edd2cf38cede1f0/eq3bt/eq3btsmart.py#L314-L324
def window_open_config(self, temperature, duration): """Configures the window open behavior. The duration is specified in 5 minute increments.""" _LOGGER.debug("Window open config, temperature: %s duration: %s", temperature, duration) self._verify_temperature(temperature) if dura...
[ "def", "window_open_config", "(", "self", ",", "temperature", ",", "duration", ")", ":", "_LOGGER", ".", "debug", "(", "\"Window open config, temperature: %s duration: %s\"", ",", "temperature", ",", "duration", ")", "self", ".", "_verify_temperature", "(", "temperatu...
Configures the window open behavior. The duration is specified in 5 minute increments.
[ "Configures", "the", "window", "open", "behavior", ".", "The", "duration", "is", "specified", "in", "5", "minute", "increments", "." ]
python
train
catherinedevlin/ddl-generator
ddlgenerator/console.py
https://github.com/catherinedevlin/ddl-generator/blob/db6741216d1e9ad84b07d4ad281bfff021d344ea/ddlgenerator/console.py#L72-L112
def generate(args=None, namespace=None, file=None): """ Genereate DDL from data sources named. :args: String or list of strings to be parsed for arguments :namespace: Namespace to extract arguments from :file: Write to this open file object (default stdout) """ if hasattr(args, 's...
[ "def", "generate", "(", "args", "=", "None", ",", "namespace", "=", "None", ",", "file", "=", "None", ")", ":", "if", "hasattr", "(", "args", ",", "'split'", ")", ":", "args", "=", "args", ".", "split", "(", ")", "args", "=", "parser", ".", "pars...
Genereate DDL from data sources named. :args: String or list of strings to be parsed for arguments :namespace: Namespace to extract arguments from :file: Write to this open file object (default stdout)
[ "Genereate", "DDL", "from", "data", "sources", "named", "." ]
python
train
openego/eDisGo
edisgo/flex_opt/check_tech_constraints.py
https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/flex_opt/check_tech_constraints.py#L314-L408
def mv_voltage_deviation(network, voltage_levels='mv_lv'): """ Checks for voltage stability issues in MV grid. Parameters ---------- network : :class:`~.grid.network.Network` voltage_levels : :obj:`str` Specifies which allowed voltage deviations to use. Possible options are: ...
[ "def", "mv_voltage_deviation", "(", "network", ",", "voltage_levels", "=", "'mv_lv'", ")", ":", "crit_nodes", "=", "{", "}", "v_dev_allowed_per_case", "=", "{", "}", "v_dev_allowed_per_case", "[", "'feedin_case_lower'", "]", "=", "0.9", "v_dev_allowed_per_case", "["...
Checks for voltage stability issues in MV grid. Parameters ---------- network : :class:`~.grid.network.Network` voltage_levels : :obj:`str` Specifies which allowed voltage deviations to use. Possible options are: * 'mv_lv' This is the default. The allowed voltage devi...
[ "Checks", "for", "voltage", "stability", "issues", "in", "MV", "grid", "." ]
python
train
reingart/gui2py
gui/controls/gridview.py
https://github.com/reingart/gui2py/blob/aca0a05f6fcde55c94ad7cc058671a06608b01a4/gui/controls/gridview.py#L291-L296
def UpdateValues(self, grid): "Update all displayed values" # This sends an event to the grid table to update all of the values msg = gridlib.GridTableMessage(self, gridlib.GRIDTABLE_REQUEST_VIEW_GET_VALUES) grid.ProcessTableMessage(msg)
[ "def", "UpdateValues", "(", "self", ",", "grid", ")", ":", "# This sends an event to the grid table to update all of the values\r", "msg", "=", "gridlib", ".", "GridTableMessage", "(", "self", ",", "gridlib", ".", "GRIDTABLE_REQUEST_VIEW_GET_VALUES", ")", "grid", ".", "...
Update all displayed values
[ "Update", "all", "displayed", "values" ]
python
test
phoebe-project/phoebe2
phoebe/backend/mesh.py
https://github.com/phoebe-project/phoebe2/blob/e64b8be683977064e2d55dd1b3ac400f64c3e379/phoebe/backend/mesh.py#L1353-L1363
def visibilities(self): """ Return the array of visibilities, where each item is a scalar/float between 0 (completely hidden/invisible) and 1 (completely visible). (Nx1) """ if self._visibilities is not None: return self._visibilities else: ...
[ "def", "visibilities", "(", "self", ")", ":", "if", "self", ".", "_visibilities", "is", "not", "None", ":", "return", "self", ".", "_visibilities", "else", ":", "return", "np", ".", "ones", "(", "self", ".", "Ntriangles", ")" ]
Return the array of visibilities, where each item is a scalar/float between 0 (completely hidden/invisible) and 1 (completely visible). (Nx1)
[ "Return", "the", "array", "of", "visibilities", "where", "each", "item", "is", "a", "scalar", "/", "float", "between", "0", "(", "completely", "hidden", "/", "invisible", ")", "and", "1", "(", "completely", "visible", ")", "." ]
python
train
rwl/pylon
contrib/cvxopf.py
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/contrib/cvxopf.py#L114-L118
def _update_case(self, bs, ln, gn, base_mva, Bf, Pfinj, Va, Pg, lmbda): """ Calculates the result attribute values. """ for i, bus in enumerate(bs): bus.v_angle = Va[i] * 180.0 / pi
[ "def", "_update_case", "(", "self", ",", "bs", ",", "ln", ",", "gn", ",", "base_mva", ",", "Bf", ",", "Pfinj", ",", "Va", ",", "Pg", ",", "lmbda", ")", ":", "for", "i", ",", "bus", "in", "enumerate", "(", "bs", ")", ":", "bus", ".", "v_angle", ...
Calculates the result attribute values.
[ "Calculates", "the", "result", "attribute", "values", "." ]
python
train
ToucanToco/toucan-data-sdk
toucan_data_sdk/utils/decorators.py
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/decorators.py#L158-L182
def log(logger=None, start_message='Starting...', end_message='Done...'): """ Basic log decorator Can be used as : - @log (with default logger) - @log(mylogger) - @log(start_message='Hello !", logger=mylogger, end_message='Bye !') """ def actual_log(f, real_logger=logger): logger...
[ "def", "log", "(", "logger", "=", "None", ",", "start_message", "=", "'Starting...'", ",", "end_message", "=", "'Done...'", ")", ":", "def", "actual_log", "(", "f", ",", "real_logger", "=", "logger", ")", ":", "logger", "=", "real_logger", "or", "_logger",...
Basic log decorator Can be used as : - @log (with default logger) - @log(mylogger) - @log(start_message='Hello !", logger=mylogger, end_message='Bye !')
[ "Basic", "log", "decorator", "Can", "be", "used", "as", ":", "-" ]
python
test
fabioz/PyDev.Debugger
_pydev_imps/_pydev_inspect.py
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydev_imps/_pydev_inspect.py#L646-L651
def strseq(object, convert, join=joinseq): """Recursively walk a sequence, stringifying each element.""" if type(object) in [types.ListType, types.TupleType]: return join(map(lambda o, c=convert, j=join: strseq(o, c, j), object)) else: return convert(object)
[ "def", "strseq", "(", "object", ",", "convert", ",", "join", "=", "joinseq", ")", ":", "if", "type", "(", "object", ")", "in", "[", "types", ".", "ListType", ",", "types", ".", "TupleType", "]", ":", "return", "join", "(", "map", "(", "lambda", "o"...
Recursively walk a sequence, stringifying each element.
[ "Recursively", "walk", "a", "sequence", "stringifying", "each", "element", "." ]
python
train
tensorflow/tensorboard
tensorboard/compat/tensorflow_stub/io/gfile.py
https://github.com/tensorflow/tensorboard/blob/8e5f497b48e40f2a774f85416b8a35ac0693c35e/tensorboard/compat/tensorflow_stub/io/gfile.py#L463-L510
def walk(top, topdown=True, onerror=None): """Recursive directory tree generator for directories. Args: top: string, a Directory name topdown: bool, Traverse pre order if True, post order if False. onerror: optional handler for errors. Should be a function, it will be called with the ...
[ "def", "walk", "(", "top", ",", "topdown", "=", "True", ",", "onerror", "=", "None", ")", ":", "top", "=", "compat", ".", "as_str_any", "(", "top", ")", "fs", "=", "get_filesystem", "(", "top", ")", "try", ":", "listing", "=", "listdir", "(", "top"...
Recursive directory tree generator for directories. Args: top: string, a Directory name topdown: bool, Traverse pre order if True, post order if False. onerror: optional handler for errors. Should be a function, it will be called with the error as argument. Rethrowing the error aborts the...
[ "Recursive", "directory", "tree", "generator", "for", "directories", "." ]
python
train
CalebBell/thermo
thermo/eos.py
https://github.com/CalebBell/thermo/blob/3857ed023a3e64fd3039a32d53576c24990ef1c3/thermo/eos.py#L480-L551
def volume_solutions(T, P, b, delta, epsilon, a_alpha, quick=True): r'''Solution of this form of the cubic EOS in terms of volumes. Returns three values, all with some complex part. Parameters ---------- T : float Temperature, [K] P : float Pres...
[ "def", "volume_solutions", "(", "T", ",", "P", ",", "b", ",", "delta", ",", "epsilon", ",", "a_alpha", ",", "quick", "=", "True", ")", ":", "if", "quick", ":", "x0", "=", "1.", "/", "P", "x1", "=", "P", "*", "b", "x2", "=", "R", "*", "T", "...
r'''Solution of this form of the cubic EOS in terms of volumes. Returns three values, all with some complex part. Parameters ---------- T : float Temperature, [K] P : float Pressure, [Pa] b : float Coefficient calculated by EOS-speci...
[ "r", "Solution", "of", "this", "form", "of", "the", "cubic", "EOS", "in", "terms", "of", "volumes", ".", "Returns", "three", "values", "all", "with", "some", "complex", "part", "." ]
python
valid
knipknap/exscript
Exscript/protocols/osguesser.py
https://github.com/knipknap/exscript/blob/72718eee3e87b345d5a5255be9824e867e42927b/Exscript/protocols/osguesser.py#L54-L65
def set(self, key, value, confidence=100): """ Defines the given value with the given confidence, unless the same value is already defined with a higher confidence level. """ if value is None: return if key in self.info: old_confidence, old_value =...
[ "def", "set", "(", "self", ",", "key", ",", "value", ",", "confidence", "=", "100", ")", ":", "if", "value", "is", "None", ":", "return", "if", "key", "in", "self", ".", "info", ":", "old_confidence", ",", "old_value", "=", "self", ".", "info", "."...
Defines the given value with the given confidence, unless the same value is already defined with a higher confidence level.
[ "Defines", "the", "given", "value", "with", "the", "given", "confidence", "unless", "the", "same", "value", "is", "already", "defined", "with", "a", "higher", "confidence", "level", "." ]
python
train
ThreatConnect-Inc/tcex
tcex/tcex.py
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex.py#L860-L889
def s(self, data, errors='strict'): """Decode value using correct Python 2/3 method. This method is intended to replace the :py:meth:`~tcex.tcex.TcEx.to_string` method with better logic to handle poorly encoded unicode data in Python2 and still work in Python3. Args: data (...
[ "def", "s", "(", "self", ",", "data", ",", "errors", "=", "'strict'", ")", ":", "try", ":", "if", "data", "is", "None", "or", "isinstance", "(", "data", ",", "(", "int", ",", "list", ",", "dict", ")", ")", ":", "pass", "# Do nothing with these types"...
Decode value using correct Python 2/3 method. This method is intended to replace the :py:meth:`~tcex.tcex.TcEx.to_string` method with better logic to handle poorly encoded unicode data in Python2 and still work in Python3. Args: data (any): Data to ve validated and (de)encoded ...
[ "Decode", "value", "using", "correct", "Python", "2", "/", "3", "method", "." ]
python
train
genialis/resolwe
resolwe/flow/elastic_indexes/base.py
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/elastic_indexes/base.py#L61-L66
def get_owner_names_value(self, obj): """Extract owners' names.""" return [ self._get_user(user) for user in get_users_with_permission(obj, get_full_perm('owner', obj)) ]
[ "def", "get_owner_names_value", "(", "self", ",", "obj", ")", ":", "return", "[", "self", ".", "_get_user", "(", "user", ")", "for", "user", "in", "get_users_with_permission", "(", "obj", ",", "get_full_perm", "(", "'owner'", ",", "obj", ")", ")", "]" ]
Extract owners' names.
[ "Extract", "owners", "names", "." ]
python
train
ktbyers/netmiko
netmiko/cisco_base_connection.py
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco_base_connection.py#L41-L51
def config_mode(self, config_command="config term", pattern=""): """ Enter into configuration mode on remote device. Cisco IOS devices abbreviate the prompt at 20 chars in config mode """ if not pattern: pattern = re.escape(self.base_prompt[:16]) return super...
[ "def", "config_mode", "(", "self", ",", "config_command", "=", "\"config term\"", ",", "pattern", "=", "\"\"", ")", ":", "if", "not", "pattern", ":", "pattern", "=", "re", ".", "escape", "(", "self", ".", "base_prompt", "[", ":", "16", "]", ")", "retur...
Enter into configuration mode on remote device. Cisco IOS devices abbreviate the prompt at 20 chars in config mode
[ "Enter", "into", "configuration", "mode", "on", "remote", "device", "." ]
python
train
googleapis/google-cloud-python
trace/google/cloud/trace/_gapic.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/trace/google/cloud/trace/_gapic.py#L245-L258
def _dict_mapping_to_pb(mapping, proto_type): """ Convert a dict to protobuf. Args: mapping (dict): A dict that needs to be converted to protobuf. proto_type (str): The type of the Protobuf. Returns: An instance of the specified protobuf. """ converted_pb = getattr(trac...
[ "def", "_dict_mapping_to_pb", "(", "mapping", ",", "proto_type", ")", ":", "converted_pb", "=", "getattr", "(", "trace_pb2", ",", "proto_type", ")", "(", ")", "ParseDict", "(", "mapping", ",", "converted_pb", ")", "return", "converted_pb" ]
Convert a dict to protobuf. Args: mapping (dict): A dict that needs to be converted to protobuf. proto_type (str): The type of the Protobuf. Returns: An instance of the specified protobuf.
[ "Convert", "a", "dict", "to", "protobuf", "." ]
python
train
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_common_def.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_common_def.py#L501-L511
def ip_rtm_config_load_sharing(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") ip = ET.SubElement(config, "ip", xmlns="urn:brocade.com:mgmt:brocade-common-def") rtm_config = ET.SubElement(ip, "rtm-config", xmlns="urn:brocade.com:mgmt:brocade-rtm") ...
[ "def", "ip_rtm_config_load_sharing", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "ip", "=", "ET", ".", "SubElement", "(", "config", ",", "\"ip\"", ",", "xmlns", "=", "\"urn:brocade.com:mgmt:b...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
duguyue100/minesweeper
minesweeper/gui.py
https://github.com/duguyue100/minesweeper/blob/38b1910f4c34d0275ac10a300285aba6f1d91d61/minesweeper/gui.py#L46-L62
def init_ui(self): """Setup control widget UI.""" self.control_layout = QHBoxLayout() self.setLayout(self.control_layout) self.reset_button = QPushButton() self.reset_button.setFixedSize(40, 40) self.reset_button.setIcon(QtGui.QIcon(WIN_PATH)) self.game_timer = QL...
[ "def", "init_ui", "(", "self", ")", ":", "self", ".", "control_layout", "=", "QHBoxLayout", "(", ")", "self", ".", "setLayout", "(", "self", ".", "control_layout", ")", "self", ".", "reset_button", "=", "QPushButton", "(", ")", "self", ".", "reset_button",...
Setup control widget UI.
[ "Setup", "control", "widget", "UI", "." ]
python
train
klahnakoski/pyLibrary
mo_threads/queues.py
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_threads/queues.py#L72-L96
def add(self, value, timeout=None, force=False): """ :param value: ADDED THE THE QUEUE :param timeout: HOW LONG TO WAIT FOR QUEUE TO NOT BE FULL :param force: ADD TO QUEUE, EVEN IF FULL (USE ONLY WHEN CONSUMER IS RETURNING WORK TO THE QUEUE) :return: self """ w...
[ "def", "add", "(", "self", ",", "value", ",", "timeout", "=", "None", ",", "force", "=", "False", ")", ":", "with", "self", ".", "lock", ":", "if", "value", "is", "THREAD_STOP", ":", "# INSIDE THE lock SO THAT EXITING WILL RELEASE wait()", "self", ".", "queu...
:param value: ADDED THE THE QUEUE :param timeout: HOW LONG TO WAIT FOR QUEUE TO NOT BE FULL :param force: ADD TO QUEUE, EVEN IF FULL (USE ONLY WHEN CONSUMER IS RETURNING WORK TO THE QUEUE) :return: self
[ ":", "param", "value", ":", "ADDED", "THE", "THE", "QUEUE", ":", "param", "timeout", ":", "HOW", "LONG", "TO", "WAIT", "FOR", "QUEUE", "TO", "NOT", "BE", "FULL", ":", "param", "force", ":", "ADD", "TO", "QUEUE", "EVEN", "IF", "FULL", "(", "USE", "O...
python
train
saltstack/salt
salt/crypt.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L1406-L1426
def encrypt(self, data): ''' encrypt data with AES-CBC and sign it with HMAC-SHA256 ''' aes_key, hmac_key = self.keys pad = self.AES_BLOCK_SIZE - len(data) % self.AES_BLOCK_SIZE if six.PY2: data = data + pad * chr(pad) else: data = data + s...
[ "def", "encrypt", "(", "self", ",", "data", ")", ":", "aes_key", ",", "hmac_key", "=", "self", ".", "keys", "pad", "=", "self", ".", "AES_BLOCK_SIZE", "-", "len", "(", "data", ")", "%", "self", ".", "AES_BLOCK_SIZE", "if", "six", ".", "PY2", ":", "...
encrypt data with AES-CBC and sign it with HMAC-SHA256
[ "encrypt", "data", "with", "AES", "-", "CBC", "and", "sign", "it", "with", "HMAC", "-", "SHA256" ]
python
train
ondryaso/pi-rc522
pirc522/util.py
https://github.com/ondryaso/pi-rc522/blob/9d9103e9701c105ba2348155e91f21ef338c4bd3/pirc522/util.py#L99-L122
def rewrite(self, block_address, new_bytes): """ Rewrites block with new bytes, keeping the old ones if None is passed. Tag and auth must be set - does auth. Returns error state. """ if not self.is_tag_set_auth(): return True error = self.do_auth(block_addres...
[ "def", "rewrite", "(", "self", ",", "block_address", ",", "new_bytes", ")", ":", "if", "not", "self", ".", "is_tag_set_auth", "(", ")", ":", "return", "True", "error", "=", "self", ".", "do_auth", "(", "block_address", ")", "if", "not", "error", ":", "...
Rewrites block with new bytes, keeping the old ones if None is passed. Tag and auth must be set - does auth. Returns error state.
[ "Rewrites", "block", "with", "new", "bytes", "keeping", "the", "old", "ones", "if", "None", "is", "passed", ".", "Tag", "and", "auth", "must", "be", "set", "-", "does", "auth", ".", "Returns", "error", "state", "." ]
python
train
juju/charm-helpers
charmhelpers/core/kernel_factory/centos.py
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/kernel_factory/centos.py#L5-L12
def persistent_modprobe(module): """Load a kernel module and configure for auto-load on reboot.""" if not os.path.exists('/etc/rc.modules'): open('/etc/rc.modules', 'a') os.chmod('/etc/rc.modules', 111) with open('/etc/rc.modules', 'r+') as modules: if module not in modules.read(): ...
[ "def", "persistent_modprobe", "(", "module", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "'/etc/rc.modules'", ")", ":", "open", "(", "'/etc/rc.modules'", ",", "'a'", ")", "os", ".", "chmod", "(", "'/etc/rc.modules'", ",", "111", ")", "w...
Load a kernel module and configure for auto-load on reboot.
[ "Load", "a", "kernel", "module", "and", "configure", "for", "auto", "-", "load", "on", "reboot", "." ]
python
train
idlesign/uwsgiconf
uwsgiconf/utils.py
https://github.com/idlesign/uwsgiconf/blob/475407acb44199edbf7e0a66261bfeb51de1afae/uwsgiconf/utils.py#L316-L331
def cmd_reload(self, force=False, workers_only=False, workers_chain=False): """Reloads uWSGI master process, workers. :param bool force: Use forced (brutal) reload instead of a graceful one. :param bool workers_only: Reload only workers. :param bool workers_chain: Run chained workers re...
[ "def", "cmd_reload", "(", "self", ",", "force", "=", "False", ",", "workers_only", "=", "False", ",", "workers_chain", "=", "False", ")", ":", "if", "workers_chain", ":", "return", "self", ".", "send_command", "(", "b'c'", ")", "if", "workers_only", ":", ...
Reloads uWSGI master process, workers. :param bool force: Use forced (brutal) reload instead of a graceful one. :param bool workers_only: Reload only workers. :param bool workers_chain: Run chained workers reload (one after another, instead of destroying all of them in bulk).
[ "Reloads", "uWSGI", "master", "process", "workers", "." ]
python
train
quantumlib/Cirq
cirq/linalg/operator_spaces.py
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/linalg/operator_spaces.py#L52-L66
def expand_matrix_in_orthogonal_basis( m: np.ndarray, basis: Dict[str, np.ndarray], ) -> value.LinearDict[str]: """Computes coefficients of expansion of m in basis. We require that basis be orthogonal w.r.t. the Hilbert-Schmidt inner product. We do not require that basis be orthonormal. Not...
[ "def", "expand_matrix_in_orthogonal_basis", "(", "m", ":", "np", ".", "ndarray", ",", "basis", ":", "Dict", "[", "str", ",", "np", ".", "ndarray", "]", ",", ")", "->", "value", ".", "LinearDict", "[", "str", "]", ":", "return", "value", ".", "LinearDic...
Computes coefficients of expansion of m in basis. We require that basis be orthogonal w.r.t. the Hilbert-Schmidt inner product. We do not require that basis be orthonormal. Note that Pauli basis (I, X, Y, Z) is orthogonal, but not orthonormal.
[ "Computes", "coefficients", "of", "expansion", "of", "m", "in", "basis", "." ]
python
train
signetlabdei/sem
sem/cli.py
https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/cli.py#L286-L335
def merge(move, output_dir, sources): """ Merge multiple results folder into one, by copying the results over to a new folder. For a faster operation (which on the other hand destroys the campaign data if interrupted), the move option can be used to directly move results to the new folder. """ ...
[ "def", "merge", "(", "move", ",", "output_dir", ",", "sources", ")", ":", "# Get paths for all campaign JSONS", "jsons", "=", "[", "]", "for", "s", "in", "sources", ":", "filename", "=", "\"%s.json\"", "%", "os", ".", "path", ".", "split", "(", "s", ")",...
Merge multiple results folder into one, by copying the results over to a new folder. For a faster operation (which on the other hand destroys the campaign data if interrupted), the move option can be used to directly move results to the new folder.
[ "Merge", "multiple", "results", "folder", "into", "one", "by", "copying", "the", "results", "over", "to", "a", "new", "folder", "." ]
python
train
automl/HpBandSter
hpbandster/core/master.py
https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/core/master.py#L248-L269
def job_callback(self, job): """ method to be called when a job has finished this will do some book keeping and call the user defined new_result_callback if one was specified """ self.logger.debug('job_callback for %s started'%str(job.id)) with self.thread_cond: self.logger.debug('job_callback for %s ...
[ "def", "job_callback", "(", "self", ",", "job", ")", ":", "self", ".", "logger", ".", "debug", "(", "'job_callback for %s started'", "%", "str", "(", "job", ".", "id", ")", ")", "with", "self", ".", "thread_cond", ":", "self", ".", "logger", ".", "debu...
method to be called when a job has finished this will do some book keeping and call the user defined new_result_callback if one was specified
[ "method", "to", "be", "called", "when", "a", "job", "has", "finished" ]
python
train
LogicalDash/LiSE
ELiDE/ELiDE/card.py
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/card.py#L462-L471
def scroll_deck_y(self, decknum, scroll_y): """Move a deck up or down.""" if decknum >= len(self.decks): raise IndexError("I have no deck at {}".format(decknum)) if decknum >= len(self.deck_y_hint_offsets): self.deck_y_hint_offsets = list(self.deck_y_hint_offsets) + [0] *...
[ "def", "scroll_deck_y", "(", "self", ",", "decknum", ",", "scroll_y", ")", ":", "if", "decknum", ">=", "len", "(", "self", ".", "decks", ")", ":", "raise", "IndexError", "(", "\"I have no deck at {}\"", ".", "format", "(", "decknum", ")", ")", "if", "dec...
Move a deck up or down.
[ "Move", "a", "deck", "up", "or", "down", "." ]
python
train
sosreport/sos
sos/plugins/__init__.py
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L1135-L1152
def add_udev_info(self, device, attrs=False): """Collect udevadm info output for a given device :param device: A string or list of strings of device names or sysfs paths. E.G. either '/sys/class/scsi_host/host0' or '/dev/sda' is valid. :param attrs:...
[ "def", "add_udev_info", "(", "self", ",", "device", ",", "attrs", "=", "False", ")", ":", "udev_cmd", "=", "'udevadm info'", "if", "attrs", ":", "udev_cmd", "+=", "' -a'", "if", "isinstance", "(", "device", ",", "six", ".", "string_types", ")", ":", "dev...
Collect udevadm info output for a given device :param device: A string or list of strings of device names or sysfs paths. E.G. either '/sys/class/scsi_host/host0' or '/dev/sda' is valid. :param attrs: If True, run udevadm with the --attribute-walk option.
[ "Collect", "udevadm", "info", "output", "for", "a", "given", "device" ]
python
train
googledatalab/pydatalab
google/datalab/utils/facets/base_generic_feature_statistics_generator.py
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/utils/facets/base_generic_feature_statistics_generator.py#L288-L305
def _PopulateQuantilesHistogram(self, hist, nums): """Fills in the histogram with quantile information from the provided array. Args: hist: A Histogram proto message to fill in. nums: A list of numbers to create a quantiles histogram from. """ if not nums: return num_quantile_bucke...
[ "def", "_PopulateQuantilesHistogram", "(", "self", ",", "hist", ",", "nums", ")", ":", "if", "not", "nums", ":", "return", "num_quantile_buckets", "=", "10", "quantiles_to_get", "=", "[", "x", "*", "100", "/", "num_quantile_buckets", "for", "x", "in", "range...
Fills in the histogram with quantile information from the provided array. Args: hist: A Histogram proto message to fill in. nums: A list of numbers to create a quantiles histogram from.
[ "Fills", "in", "the", "histogram", "with", "quantile", "information", "from", "the", "provided", "array", ".", "Args", ":", "hist", ":", "A", "Histogram", "proto", "message", "to", "fill", "in", ".", "nums", ":", "A", "list", "of", "numbers", "to", "crea...
python
train
nugget/python-insteonplm
insteonplm/plm.py
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/plm.py#L139-L153
def connection_lost(self, exc): """Reestablish the connection to the transport. Called when asyncio.Protocol loses the network connection. """ if exc is None: _LOGGER.warning('End of file received from Insteon Modem') else: _LOGGER.warning('Lost connectio...
[ "def", "connection_lost", "(", "self", ",", "exc", ")", ":", "if", "exc", "is", "None", ":", "_LOGGER", ".", "warning", "(", "'End of file received from Insteon Modem'", ")", "else", ":", "_LOGGER", ".", "warning", "(", "'Lost connection to Insteon Modem: %s'", ",...
Reestablish the connection to the transport. Called when asyncio.Protocol loses the network connection.
[ "Reestablish", "the", "connection", "to", "the", "transport", "." ]
python
train
tensorflow/tensor2tensor
tensor2tensor/trax/rlax/ppo.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/trax/rlax/ppo.py#L649-L695
def ppo_loss_given_predictions(log_probab_actions_new, log_probab_actions_old, predicted_values, padded_actions, padded_rewards, reward_mask, ...
[ "def", "ppo_loss_given_predictions", "(", "log_probab_actions_new", ",", "log_probab_actions_old", ",", "predicted_values", ",", "padded_actions", ",", "padded_rewards", ",", "reward_mask", ",", "gamma", "=", "0.99", ",", "lambda_", "=", "0.95", ",", "epsilon", "=", ...
PPO objective, with an eventual minus sign, given predictions.
[ "PPO", "objective", "with", "an", "eventual", "minus", "sign", "given", "predictions", "." ]
python
train
westonplatter/fast_arrow
fast_arrow/resources/stock_marketdata.py
https://github.com/westonplatter/fast_arrow/blob/514cbca4994f52a97222058167830a302e313d04/fast_arrow/resources/stock_marketdata.py#L22-L34
def quotes_by_instrument_urls(cls, client, urls): """ fetch and return results """ instruments = ",".join(urls) params = {"instruments": instruments} url = "https://api.robinhood.com/marketdata/quotes/" data = client.get(url, params=params) results = data[...
[ "def", "quotes_by_instrument_urls", "(", "cls", ",", "client", ",", "urls", ")", ":", "instruments", "=", "\",\"", ".", "join", "(", "urls", ")", "params", "=", "{", "\"instruments\"", ":", "instruments", "}", "url", "=", "\"https://api.robinhood.com/marketdata/...
fetch and return results
[ "fetch", "and", "return", "results" ]
python
train
ArchiveTeam/wpull
wpull/url.py
https://github.com/ArchiveTeam/wpull/blob/ddf051aa3322479325ba20aa778cb2cb97606bf5/wpull/url.py#L700-L740
def flatten_path(path, flatten_slashes=False): '''Flatten an absolute URL path by removing the dot segments. :func:`urllib.parse.urljoin` has some support for removing dot segments, but it is conservative and only removes them as needed. Arguments: path (str): The URL path. flatten_sla...
[ "def", "flatten_path", "(", "path", ",", "flatten_slashes", "=", "False", ")", ":", "# Based on posixpath.normpath", "# Fast path", "if", "not", "path", "or", "path", "==", "'/'", ":", "return", "'/'", "# Take off leading slash", "if", "path", "[", "0", "]", "...
Flatten an absolute URL path by removing the dot segments. :func:`urllib.parse.urljoin` has some support for removing dot segments, but it is conservative and only removes them as needed. Arguments: path (str): The URL path. flatten_slashes (bool): If True, consecutive slashes are removed....
[ "Flatten", "an", "absolute", "URL", "path", "by", "removing", "the", "dot", "segments", "." ]
python
train
pyca/pyopenssl
src/OpenSSL/_util.py
https://github.com/pyca/pyopenssl/blob/1fbe064c50fd030948141d7d630673761525b0d0/src/OpenSSL/_util.py#L127-L147
def text_to_bytes_and_warn(label, obj): """ If ``obj`` is text, emit a warning that it should be bytes instead and try to convert it to bytes automatically. :param str label: The name of the parameter from which ``obj`` was taken (so a developer can easily find the source of the problem and cor...
[ "def", "text_to_bytes_and_warn", "(", "label", ",", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "text_type", ")", ":", "warnings", ".", "warn", "(", "_TEXT_WARNING", ".", "format", "(", "label", ")", ",", "category", "=", "DeprecationWarning", ",...
If ``obj`` is text, emit a warning that it should be bytes instead and try to convert it to bytes automatically. :param str label: The name of the parameter from which ``obj`` was taken (so a developer can easily find the source of the problem and correct it). :return: If ``obj`` is the te...
[ "If", "obj", "is", "text", "emit", "a", "warning", "that", "it", "should", "be", "bytes", "instead", "and", "try", "to", "convert", "it", "to", "bytes", "automatically", "." ]
python
test
log2timeline/plaso
plaso/parsers/winreg_plugins/mrulistex.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/parsers/winreg_plugins/mrulistex.py#L40-L59
def Match(self, registry_key): """Determines if a Windows Registry key matches the filter. Args: registry_key (dfwinreg.WinRegistryKey): Windows Registry key. Returns: bool: True if the Windows Registry key matches the filter. """ key_path_upper = registry_key.path.upper() # Preven...
[ "def", "Match", "(", "self", ",", "registry_key", ")", ":", "key_path_upper", "=", "registry_key", ".", "path", ".", "upper", "(", ")", "# Prevent this filter matching non-string MRUListEx values.", "for", "ignore_key_path_suffix", "in", "self", ".", "_IGNORE_KEY_PATH_S...
Determines if a Windows Registry key matches the filter. Args: registry_key (dfwinreg.WinRegistryKey): Windows Registry key. Returns: bool: True if the Windows Registry key matches the filter.
[ "Determines", "if", "a", "Windows", "Registry", "key", "matches", "the", "filter", "." ]
python
train
swharden/SWHLab
swhlab/command.py
https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/swhlab/command.py#L23-L64
def processArgs(): """check out the arguments and figure out what to do.""" if len(sys.argv)<2: print("\n\nERROR:") print("this script requires arguments!") print('try "python command.py info"') return if sys.argv[1]=='info': print("import paths:\n ","\n ".join(sys.p...
[ "def", "processArgs", "(", ")", ":", "if", "len", "(", "sys", ".", "argv", ")", "<", "2", ":", "print", "(", "\"\\n\\nERROR:\"", ")", "print", "(", "\"this script requires arguments!\"", ")", "print", "(", "'try \"python command.py info\"'", ")", "return", "if...
check out the arguments and figure out what to do.
[ "check", "out", "the", "arguments", "and", "figure", "out", "what", "to", "do", "." ]
python
valid
xsleonard/pystmark
pystmark.py
https://github.com/xsleonard/pystmark/blob/329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6/pystmark.py#L123-L138
def send_batch(messages, api_key=None, secure=None, test=None, **request_args): '''Send a batch of messages. :param messages: Messages to send. :type message: A list of `dict` or :class:`Message` :param api_key: Your Postmark API key. Required, if `test` is not `True`. :param secure: Use the https ...
[ "def", "send_batch", "(", "messages", ",", "api_key", "=", "None", ",", "secure", "=", "None", ",", "test", "=", "None", ",", "*", "*", "request_args", ")", ":", "return", "_default_pyst_batch_sender", ".", "send", "(", "messages", "=", "messages", ",", ...
Send a batch of messages. :param messages: Messages to send. :type message: A list of `dict` or :class:`Message` :param api_key: Your Postmark API key. Required, if `test` is not `True`. :param secure: Use the https scheme for the Postmark API. Defaults to `True` :param test: Use the Postma...
[ "Send", "a", "batch", "of", "messages", "." ]
python
train
wavycloud/pyboto3
pyboto3/ec2.py
https://github.com/wavycloud/pyboto3/blob/924957ccf994303713a4eed90b775ff2ab95b2e5/pyboto3/ec2.py#L14547-L15213
def run_instances(DryRun=None, ImageId=None, MinCount=None, MaxCount=None, KeyName=None, SecurityGroups=None, SecurityGroupIds=None, UserData=None, InstanceType=None, Placement=None, KernelId=None, RamdiskId=None, BlockDeviceMappings=None, Monitoring=None, SubnetId=None, DisableApiTermination=None, InstanceInitiatedShu...
[ "def", "run_instances", "(", "DryRun", "=", "None", ",", "ImageId", "=", "None", ",", "MinCount", "=", "None", ",", "MaxCount", "=", "None", ",", "KeyName", "=", "None", ",", "SecurityGroups", "=", "None", ",", "SecurityGroupIds", "=", "None", ",", "User...
Launches the specified number of instances using an AMI for which you have permissions. You can specify a number of options, or leave the default options. The following rules apply: To ensure faster instance launches, break up large requests into smaller batches. For example, create 5 separate launch requests f...
[ "Launches", "the", "specified", "number", "of", "instances", "using", "an", "AMI", "for", "which", "you", "have", "permissions", ".", "You", "can", "specify", "a", "number", "of", "options", "or", "leave", "the", "default", "options", ".", "The", "following"...
python
train
alanjds/drf-nested-routers
rest_framework_nested/viewsets.py
https://github.com/alanjds/drf-nested-routers/blob/8c48cae40522612debaca761503b4e1a6f1cdba4/rest_framework_nested/viewsets.py#L2-L13
def get_queryset(self): """ Filter the `QuerySet` based on its parents as defined in the `serializer_class.parent_lookup_kwargs`. """ queryset = super(NestedViewSetMixin, self).get_queryset() if hasattr(self.serializer_class, 'parent_lookup_kwargs'): orm_filte...
[ "def", "get_queryset", "(", "self", ")", ":", "queryset", "=", "super", "(", "NestedViewSetMixin", ",", "self", ")", ".", "get_queryset", "(", ")", "if", "hasattr", "(", "self", ".", "serializer_class", ",", "'parent_lookup_kwargs'", ")", ":", "orm_filters", ...
Filter the `QuerySet` based on its parents as defined in the `serializer_class.parent_lookup_kwargs`.
[ "Filter", "the", "QuerySet", "based", "on", "its", "parents", "as", "defined", "in", "the", "serializer_class", ".", "parent_lookup_kwargs", "." ]
python
train
farshidce/touchworks-python
touchworks/api/http.py
https://github.com/farshidce/touchworks-python/blob/ea8f93a0f4273de1317a318e945a571f5038ba62/touchworks/api/http.py#L139-L161
def get_token(self, appname, username, password): """ get the security token by connecting to TouchWorks API """ ext_exception = TouchWorksException( TouchWorksErrorMessages.GET_TOKEN_FAILED_ERROR) data = {'Username': username, 'Password': password...
[ "def", "get_token", "(", "self", ",", "appname", ",", "username", ",", "password", ")", ":", "ext_exception", "=", "TouchWorksException", "(", "TouchWorksErrorMessages", ".", "GET_TOKEN_FAILED_ERROR", ")", "data", "=", "{", "'Username'", ":", "username", ",", "'...
get the security token by connecting to TouchWorks API
[ "get", "the", "security", "token", "by", "connecting", "to", "TouchWorks", "API" ]
python
train
pypa/pipenv
pipenv/vendor/pep517/_in_process.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pep517/_in_process.py#L43-L54
def get_requires_for_build_wheel(config_settings): """Invoke the optional get_requires_for_build_wheel hook Returns [] if the hook is not defined. """ backend = _build_backend() try: hook = backend.get_requires_for_build_wheel except AttributeError: return [] else: r...
[ "def", "get_requires_for_build_wheel", "(", "config_settings", ")", ":", "backend", "=", "_build_backend", "(", ")", "try", ":", "hook", "=", "backend", ".", "get_requires_for_build_wheel", "except", "AttributeError", ":", "return", "[", "]", "else", ":", "return"...
Invoke the optional get_requires_for_build_wheel hook Returns [] if the hook is not defined.
[ "Invoke", "the", "optional", "get_requires_for_build_wheel", "hook" ]
python
train
inasafe/inasafe
safe/gui/tools/wizard/wizard_help.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/wizard_help.py#L63-L66
def restore_button_state(self): """Helper to restore button state.""" self.parent.pbnNext.setEnabled(self.next_button_state) self.parent.pbnBack.setEnabled(self.back_button_state)
[ "def", "restore_button_state", "(", "self", ")", ":", "self", ".", "parent", ".", "pbnNext", ".", "setEnabled", "(", "self", ".", "next_button_state", ")", "self", ".", "parent", ".", "pbnBack", ".", "setEnabled", "(", "self", ".", "back_button_state", ")" ]
Helper to restore button state.
[ "Helper", "to", "restore", "button", "state", "." ]
python
train
zhebrak/raftos
raftos/state.py
https://github.com/zhebrak/raftos/blob/0d6f9e049b526279b1035f597291a96cf50c9b40/raftos/state.py#L260-L267
async def execute_command(self, command): """Write to log & send AppendEntries RPC""" self.apply_future = asyncio.Future(loop=self.loop) entry = self.log.write(self.storage.term, command) asyncio.ensure_future(self.append_entries(), loop=self.loop) await self.apply_future
[ "async", "def", "execute_command", "(", "self", ",", "command", ")", ":", "self", ".", "apply_future", "=", "asyncio", ".", "Future", "(", "loop", "=", "self", ".", "loop", ")", "entry", "=", "self", ".", "log", ".", "write", "(", "self", ".", "stora...
Write to log & send AppendEntries RPC
[ "Write", "to", "log", "&", "send", "AppendEntries", "RPC" ]
python
train
nigma/django-easy-pdf
easy_pdf/views.py
https://github.com/nigma/django-easy-pdf/blob/327605b91a445b453d8969b341ef74b12ab00a83/easy_pdf/views.py#L47-L61
def get_pdf_response(self, context, **response_kwargs): """ Renders PDF document and prepares response. :returns: Django HTTP response :rtype: :class:`django.http.HttpResponse` """ return render_to_pdf_response( request=self.request, template=self...
[ "def", "get_pdf_response", "(", "self", ",", "context", ",", "*", "*", "response_kwargs", ")", ":", "return", "render_to_pdf_response", "(", "request", "=", "self", ".", "request", ",", "template", "=", "self", ".", "get_template_names", "(", ")", ",", "cont...
Renders PDF document and prepares response. :returns: Django HTTP response :rtype: :class:`django.http.HttpResponse`
[ "Renders", "PDF", "document", "and", "prepares", "response", "." ]
python
train
dfm/celerite
celerite/celerite.py
https://github.com/dfm/celerite/blob/ad3f471f06b18d233f3dab71bb1c20a316173cae/celerite/celerite.py#L97-L139
def compute(self, t, yerr=1.123e-12, check_sorted=True, A=None, U=None, V=None): """ Compute the extended form of the covariance matrix and factorize Args: x (array[n]): The independent coordinates of the data points. This array must be _sorted_ in as...
[ "def", "compute", "(", "self", ",", "t", ",", "yerr", "=", "1.123e-12", ",", "check_sorted", "=", "True", ",", "A", "=", "None", ",", "U", "=", "None", ",", "V", "=", "None", ")", ":", "t", "=", "np", ".", "atleast_1d", "(", "t", ")", "if", "...
Compute the extended form of the covariance matrix and factorize Args: x (array[n]): The independent coordinates of the data points. This array must be _sorted_ in ascending order. yerr (Optional[float or array[n]]): The measurement uncertainties for the ...
[ "Compute", "the", "extended", "form", "of", "the", "covariance", "matrix", "and", "factorize" ]
python
train
senaite/senaite.core
bika/lims/content/client.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/content/client.py#L234-L239
def getCountry(self, default=None): """Return the Country from the Physical or Postal Address """ physical_address = self.getPhysicalAddress().get("country", default) postal_address = self.getPostalAddress().get("country", default) return physical_address or postal_address
[ "def", "getCountry", "(", "self", ",", "default", "=", "None", ")", ":", "physical_address", "=", "self", ".", "getPhysicalAddress", "(", ")", ".", "get", "(", "\"country\"", ",", "default", ")", "postal_address", "=", "self", ".", "getPostalAddress", "(", ...
Return the Country from the Physical or Postal Address
[ "Return", "the", "Country", "from", "the", "Physical", "or", "Postal", "Address" ]
python
train
scheibler/khard
khard/carddav_object.py
https://github.com/scheibler/khard/blob/0f69430c2680f1ff5f073a977a3c5b753b96cc17/khard/carddav_object.py#L415-L431
def get_email_addresses(self): """ : returns: dict of type and email address list :rtype: dict(str, list(str)) """ email_dict = {} for child in self.vcard.getChildren(): if child.name == "EMAIL": type = helpers.list_to_string( ...
[ "def", "get_email_addresses", "(", "self", ")", ":", "email_dict", "=", "{", "}", "for", "child", "in", "self", ".", "vcard", ".", "getChildren", "(", ")", ":", "if", "child", ".", "name", "==", "\"EMAIL\"", ":", "type", "=", "helpers", ".", "list_to_s...
: returns: dict of type and email address list :rtype: dict(str, list(str))
[ ":", "returns", ":", "dict", "of", "type", "and", "email", "address", "list", ":", "rtype", ":", "dict", "(", "str", "list", "(", "str", "))" ]
python
test
juju/charm-helpers
charmhelpers/core/host.py
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L897-L923
def chownr(path, owner, group, follow_links=True, chowntopdir=False): """Recursively change user and group ownership of files and directories in given path. Doesn't chown path itself by default, only its children. :param str path: The string path to start changing ownership. :param str owner: The owner...
[ "def", "chownr", "(", "path", ",", "owner", ",", "group", ",", "follow_links", "=", "True", ",", "chowntopdir", "=", "False", ")", ":", "uid", "=", "pwd", ".", "getpwnam", "(", "owner", ")", ".", "pw_uid", "gid", "=", "grp", ".", "getgrnam", "(", "...
Recursively change user and group ownership of files and directories in given path. Doesn't chown path itself by default, only its children. :param str path: The string path to start changing ownership. :param str owner: The owner string to use when looking up the uid. :param str group: The group strin...
[ "Recursively", "change", "user", "and", "group", "ownership", "of", "files", "and", "directories", "in", "given", "path", ".", "Doesn", "t", "chown", "path", "itself", "by", "default", "only", "its", "children", "." ]
python
train
jonathf/chaospy
chaospy/poly/collection/linalg.py
https://github.com/jonathf/chaospy/blob/25ecfa7bf5608dc10c0b31d142ded0e3755f5d74/chaospy/poly/collection/linalg.py#L125-L154
def dot(poly1, poly2): """ Dot product of polynomial vectors. Args: poly1 (Poly) : left part of product. poly2 (Poly) : right part of product. Returns: (Poly) : product of poly1 and poly2. Examples: >>> poly = cp.prange(3, 1) >>> print(poly) [1, q0,...
[ "def", "dot", "(", "poly1", ",", "poly2", ")", ":", "if", "not", "isinstance", "(", "poly1", ",", "Poly", ")", "and", "not", "isinstance", "(", "poly2", ",", "Poly", ")", ":", "return", "numpy", ".", "dot", "(", "poly1", ",", "poly2", ")", "poly1",...
Dot product of polynomial vectors. Args: poly1 (Poly) : left part of product. poly2 (Poly) : right part of product. Returns: (Poly) : product of poly1 and poly2. Examples: >>> poly = cp.prange(3, 1) >>> print(poly) [1, q0, q0^2] >>> print(cp.dot(pol...
[ "Dot", "product", "of", "polynomial", "vectors", "." ]
python
train
seznam/shelter
shelter/core/processes.py
https://github.com/seznam/shelter/blob/c652b0ff1cca70158f8fc97d9210c1fa5961ac1c/shelter/core/processes.py#L68-L110
def run(self): """ Child process. Repeatedly call :meth:`loop` method every :attribute:`interval` seconds. """ setproctitle.setproctitle("{:s}: {:s}".format( self.context.config.name, self.__class__.__name__)) self.logger.info( "Worker '%s' has bee...
[ "def", "run", "(", "self", ")", ":", "setproctitle", ".", "setproctitle", "(", "\"{:s}: {:s}\"", ".", "format", "(", "self", ".", "context", ".", "config", ".", "name", ",", "self", ".", "__class__", ".", "__name__", ")", ")", "self", ".", "logger", "....
Child process. Repeatedly call :meth:`loop` method every :attribute:`interval` seconds.
[ "Child", "process", ".", "Repeatedly", "call", ":", "meth", ":", "loop", "method", "every", ":", "attribute", ":", "interval", "seconds", "." ]
python
train
davgeo/clear
clear/renamer.py
https://github.com/davgeo/clear/blob/5ec85d27efd28afddfcd4c3f44df17f0115a77aa/clear/renamer.py#L302-L378
def _MoveFileToLibrary(self, oldPath, newPath): """ Move file from old file path to new file path. This follows certain conditions: - If file already exists at destination do rename inplace. - If file destination is on same file system and doesn't exist rename and move. - If source and de...
[ "def", "_MoveFileToLibrary", "(", "self", ",", "oldPath", ",", "newPath", ")", ":", "if", "oldPath", "==", "newPath", ":", "return", "False", "goodlogging", ".", "Log", ".", "Info", "(", "\"RENAMER\"", ",", "\"PROCESSING FILE: {0}\"", ".", "format", "(", "ol...
Move file from old file path to new file path. This follows certain conditions: - If file already exists at destination do rename inplace. - If file destination is on same file system and doesn't exist rename and move. - If source and destination are on different file systems do rename in-place, ...
[ "Move", "file", "from", "old", "file", "path", "to", "new", "file", "path", ".", "This", "follows", "certain", "conditions", ":" ]
python
train
zero-os/0-core
client/py-client/zeroos/core0/client/client.py
https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L2551-L2564
def migrate(self, uuid, desturi): """ Migrate a vm to another node :param uuid: uuid of the kvm container (same as the used in create) :param desturi: the uri of the destination node :return: """ args = { 'uuid': uuid, 'desturi': desturi, ...
[ "def", "migrate", "(", "self", ",", "uuid", ",", "desturi", ")", ":", "args", "=", "{", "'uuid'", ":", "uuid", ",", "'desturi'", ":", "desturi", ",", "}", "self", ".", "_migrate_action_chk", ".", "check", "(", "args", ")", "self", ".", "_client", "."...
Migrate a vm to another node :param uuid: uuid of the kvm container (same as the used in create) :param desturi: the uri of the destination node :return:
[ "Migrate", "a", "vm", "to", "another", "node", ":", "param", "uuid", ":", "uuid", "of", "the", "kvm", "container", "(", "same", "as", "the", "used", "in", "create", ")", ":", "param", "desturi", ":", "the", "uri", "of", "the", "destination", "node", ...
python
train