nwo
stringlengths
5
106
sha
stringlengths
40
40
path
stringlengths
4
174
language
stringclasses
1 value
identifier
stringlengths
1
140
parameters
stringlengths
0
87.7k
argument_list
stringclasses
1 value
return_statement
stringlengths
0
426k
docstring
stringlengths
0
64.3k
docstring_summary
stringlengths
0
26.3k
docstring_tokens
list
function
stringlengths
18
4.83M
function_tokens
list
url
stringlengths
83
304
JiYou/openstack
8607dd488bde0905044b303eb6e52bdea6806923
packages/source/nova/nova/utils.py
python
is_valid_ipv4
(address)
Verify that address represents a valid IPv4 address.
Verify that address represents a valid IPv4 address.
[ "Verify", "that", "address", "represents", "a", "valid", "IPv4", "address", "." ]
def is_valid_ipv4(address): """Verify that address represents a valid IPv4 address.""" try: return netaddr.valid_ipv4(address) except Exception: return False
[ "def", "is_valid_ipv4", "(", "address", ")", ":", "try", ":", "return", "netaddr", ".", "valid_ipv4", "(", "address", ")", "except", "Exception", ":", "return", "False" ]
https://github.com/JiYou/openstack/blob/8607dd488bde0905044b303eb6e52bdea6806923/packages/source/nova/nova/utils.py#L887-L892
ucsb-seclab/karonte
427ac313e596f723e40768b95d13bd7a9fc92fd8
tool/taint_analysis/coretaint.py
python
CoreTaint.do_recursive_untaint
(self, dst, path)
return self._do_recursive_untaint_core(dst, path)
Perform the untaint operation (see do_recursive_untaint_core) :param dst: variable to untaint :param path: angr path :return:
Perform the untaint operation (see do_recursive_untaint_core)
[ "Perform", "the", "untaint", "operation", "(", "see", "do_recursive_untaint_core", ")" ]
def do_recursive_untaint(self, dst, path): """ Perform the untaint operation (see do_recursive_untaint_core) :param dst: variable to untaint :param path: angr path :return: """ return self._do_recursive_untaint_core(dst, path)
[ "def", "do_recursive_untaint", "(", "self", ",", "dst", ",", "path", ")", ":", "return", "self", ".", "_do_recursive_untaint_core", "(", "dst", ",", "path", ")" ]
https://github.com/ucsb-seclab/karonte/blob/427ac313e596f723e40768b95d13bd7a9fc92fd8/tool/taint_analysis/coretaint.py#L587-L596
PaddlePaddle/PaddleSlim
f895aebe441b2bef79ecc434626d3cac4b3cbd09
paddleslim/nas/early_stop/median_stop/median_stop.py
python
MedianStop._convert_running2completed
(self, exp_name, status)
Convert experiment record from running to complete. Args: exp_name<str>: the name of experiment. status<str>: the status of this experiment.
Convert experiment record from running to complete.
[ "Convert", "experiment", "record", "from", "running", "to", "complete", "." ]
def _convert_running2completed(self, exp_name, status): """ Convert experiment record from running to complete. Args: exp_name<str>: the name of experiment. status<str>: the status of this experiment. """ _logger.debug('the status of this experiment is {}'.format(status)) completed_avg_history = dict() if exp_name in self._running_history: if status == "GOOD": count = 0 history_sum = 0 result = [] for res in self._running_history[exp_name]: count += 1 history_sum += res result.append(history_sum / count) completed_avg_history[exp_name] = result self._running_history.pop(exp_name) if len(completed_avg_history) > 0: while True: try: new_dict = self._manager.get_completed_history() new_dict.update(completed_avg_history) break except Exception as err: _logger.error("update data error: {}".format(err))
[ "def", "_convert_running2completed", "(", "self", ",", "exp_name", ",", "status", ")", ":", "_logger", ".", "debug", "(", "'the status of this experiment is {}'", ".", "format", "(", "status", ")", ")", "completed_avg_history", "=", "dict", "(", ")", "if", "exp_...
https://github.com/PaddlePaddle/PaddleSlim/blob/f895aebe441b2bef79ecc434626d3cac4b3cbd09/paddleslim/nas/early_stop/median_stop/median_stop.py#L79-L108
PaddlePaddle/PaddleSpeech
26524031d242876b7fdb71582b0b3a7ea45c7d9d
utils/utility.py
python
download
(url, md5sum, target_dir)
return filepath
Download file from url to target_dir, and check md5sum.
Download file from url to target_dir, and check md5sum.
[ "Download", "file", "from", "url", "to", "target_dir", "and", "check", "md5sum", "." ]
def download(url, md5sum, target_dir): """Download file from url to target_dir, and check md5sum.""" if not os.path.exists(target_dir): os.makedirs(target_dir) filepath = os.path.join(target_dir, url.split("/")[-1]) if not (os.path.exists(filepath) and md5file(filepath) == md5sum): print("Downloading %s ..." % url) os.system("wget -c " + url + " -P " + target_dir) print("\nMD5 Chesksum %s ..." % filepath) if not md5file(filepath) == md5sum: raise RuntimeError("MD5 checksum failed.") else: print("File exists, skip downloading. (%s)" % filepath) return filepath
[ "def", "download", "(", "url", ",", "md5sum", ",", "target_dir", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "target_dir", ")", ":", "os", ".", "makedirs", "(", "target_dir", ")", "filepath", "=", "os", ".", "path", ".", "join", "...
https://github.com/PaddlePaddle/PaddleSpeech/blob/26524031d242876b7fdb71582b0b3a7ea45c7d9d/utils/utility.py#L136-L149
rhinstaller/anaconda
63edc8680f1b05cbfe11bef28703acba808c5174
pyanaconda/modules/storage/partitioning/custom/custom_module.py
python
CustomPartitioningModule.for_publication
(self)
return CustomPartitioningInterface(self)
Return a DBus representation.
Return a DBus representation.
[ "Return", "a", "DBus", "representation", "." ]
def for_publication(self): """Return a DBus representation.""" return CustomPartitioningInterface(self)
[ "def", "for_publication", "(", "self", ")", ":", "return", "CustomPartitioningInterface", "(", "self", ")" ]
https://github.com/rhinstaller/anaconda/blob/63edc8680f1b05cbfe11bef28703acba808c5174/pyanaconda/modules/storage/partitioning/custom/custom_module.py#L56-L58
wistbean/learn_python3_spider
73c873f4845f4385f097e5057407d03dd37a117b
stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_vendor/requests/models.py
python
Response.content
(self)
return self._content
Content of the response, in bytes.
Content of the response, in bytes.
[ "Content", "of", "the", "response", "in", "bytes", "." ]
def content(self): """Content of the response, in bytes.""" if self._content is False: # Read the contents. if self._content_consumed: raise RuntimeError( 'The content for this response was already consumed') if self.status_code == 0 or self.raw is None: self._content = None else: self._content = b''.join(self.iter_content(CONTENT_CHUNK_SIZE)) or b'' self._content_consumed = True # don't need to release the connection; that's been handled by urllib3 # since we exhausted the data. return self._content
[ "def", "content", "(", "self", ")", ":", "if", "self", ".", "_content", "is", "False", ":", "# Read the contents.", "if", "self", ".", "_content_consumed", ":", "raise", "RuntimeError", "(", "'The content for this response was already consumed'", ")", "if", "self", ...
https://github.com/wistbean/learn_python3_spider/blob/73c873f4845f4385f097e5057407d03dd37a117b/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_vendor/requests/models.py#L816-L833
OpenAgricultureFoundation/openag-device-software
a51d2de399c0a6781ae51d0dcfaae1583d75f346
device/controllers/modules/pid/pid.py
python
PID.setKi
(self, integral_gain: float)
Determines how aggressively the PID reacts to the current error with setting Integral Gain
Determines how aggressively the PID reacts to the current error with setting Integral Gain
[ "Determines", "how", "aggressively", "the", "PID", "reacts", "to", "the", "current", "error", "with", "setting", "Integral", "Gain" ]
def setKi(self, integral_gain: float) -> None: """Determines how aggressively the PID reacts to the current error with setting Integral Gain""" self.Ki = integral_gain
[ "def", "setKi", "(", "self", ",", "integral_gain", ":", "float", ")", "->", "None", ":", "self", ".", "Ki", "=", "integral_gain" ]
https://github.com/OpenAgricultureFoundation/openag-device-software/blob/a51d2de399c0a6781ae51d0dcfaae1583d75f346/device/controllers/modules/pid/pid.py#L106-L109
securesystemslab/zippy
ff0e84ac99442c2c55fe1d285332cfd4e185e089
zippy/lib-python/3/configparser.py
python
RawConfigParser.defaults
(self)
return self._defaults
[]
def defaults(self): return self._defaults
[ "def", "defaults", "(", "self", ")", ":", "return", "self", ".", "_defaults" ]
https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/lib-python/3/configparser.py#L633-L634
amonapp/amon
61ae3575ad98ec4854ea87c213aa8dfbb29a0199
amon/templatetags/math.py
python
substract
(element, second_element)
return result
[]
def substract(element, second_element): result = float(element)-float(second_element) return result
[ "def", "substract", "(", "element", ",", "second_element", ")", ":", "result", "=", "float", "(", "element", ")", "-", "float", "(", "second_element", ")", "return", "result" ]
https://github.com/amonapp/amon/blob/61ae3575ad98ec4854ea87c213aa8dfbb29a0199/amon/templatetags/math.py#L12-L14
gaojiuli/gain
2c8160c92943837613a773f681fb190a8c434bb2
gain/result/file_result.py
python
FileResult.save_to_file
(self, results)
save results to file Asynchronous :param results: str :return: None
save results to file Asynchronous :param results: str :return: None
[ "save", "results", "to", "file", "Asynchronous", ":", "param", "results", ":", "str", ":", "return", ":", "None" ]
async def save_to_file(self, results): """ save results to file Asynchronous :param results: str :return: None """ async with aiofiles.open(self.path, 'a+') as f: await f.write(results)
[ "async", "def", "save_to_file", "(", "self", ",", "results", ")", ":", "async", "with", "aiofiles", ".", "open", "(", "self", ".", "path", ",", "'a+'", ")", "as", "f", ":", "await", "f", ".", "write", "(", "results", ")" ]
https://github.com/gaojiuli/gain/blob/2c8160c92943837613a773f681fb190a8c434bb2/gain/result/file_result.py#L32-L39
learningequality/ka-lite
571918ea668013dcf022286ea85eff1c5333fb8b
kalite/packages/bundled/django/contrib/gis/geos/io.py
python
WKTReader.read
(self, wkt)
return GEOSGeometry(super(WKTReader, self).read(wkt))
Returns a GEOSGeometry for the given WKT string.
Returns a GEOSGeometry for the given WKT string.
[ "Returns", "a", "GEOSGeometry", "for", "the", "given", "WKT", "string", "." ]
def read(self, wkt): "Returns a GEOSGeometry for the given WKT string." return GEOSGeometry(super(WKTReader, self).read(wkt))
[ "def", "read", "(", "self", ",", "wkt", ")", ":", "return", "GEOSGeometry", "(", "super", "(", "WKTReader", ",", "self", ")", ".", "read", "(", "wkt", ")", ")" ]
https://github.com/learningequality/ka-lite/blob/571918ea668013dcf022286ea85eff1c5333fb8b/kalite/packages/bundled/django/contrib/gis/geos/io.py#L16-L18
microsoft/azure-devops-python-api
451cade4c475482792cbe9e522c1fee32393139e
azure-devops/azure/devops/v5_1/build/build_client.py
python
BuildClient.restore_webhooks
(self, trigger_types, project, provider_name, service_endpoint_id=None, repository=None)
RestoreWebhooks. [Preview API] Recreates the webhooks for the specified triggers in the given source code repository. :param [DefinitionTriggerType] trigger_types: The types of triggers to restore webhooks for. :param str project: Project ID or project name :param str provider_name: The name of the source provider. :param str service_endpoint_id: If specified, the ID of the service endpoint to query. Can only be omitted for providers that do not use service endpoints, e.g. TFVC or TFGit. :param str repository: If specified, the vendor-specific identifier or the name of the repository to get webhooks. Can only be omitted for providers that do not support multiple repositories.
RestoreWebhooks. [Preview API] Recreates the webhooks for the specified triggers in the given source code repository. :param [DefinitionTriggerType] trigger_types: The types of triggers to restore webhooks for. :param str project: Project ID or project name :param str provider_name: The name of the source provider. :param str service_endpoint_id: If specified, the ID of the service endpoint to query. Can only be omitted for providers that do not use service endpoints, e.g. TFVC or TFGit. :param str repository: If specified, the vendor-specific identifier or the name of the repository to get webhooks. Can only be omitted for providers that do not support multiple repositories.
[ "RestoreWebhooks", ".", "[", "Preview", "API", "]", "Recreates", "the", "webhooks", "for", "the", "specified", "triggers", "in", "the", "given", "source", "code", "repository", ".", ":", "param", "[", "DefinitionTriggerType", "]", "trigger_types", ":", "The", ...
def restore_webhooks(self, trigger_types, project, provider_name, service_endpoint_id=None, repository=None): """RestoreWebhooks. [Preview API] Recreates the webhooks for the specified triggers in the given source code repository. :param [DefinitionTriggerType] trigger_types: The types of triggers to restore webhooks for. :param str project: Project ID or project name :param str provider_name: The name of the source provider. :param str service_endpoint_id: If specified, the ID of the service endpoint to query. Can only be omitted for providers that do not use service endpoints, e.g. TFVC or TFGit. :param str repository: If specified, the vendor-specific identifier or the name of the repository to get webhooks. Can only be omitted for providers that do not support multiple repositories. """ route_values = {} if project is not None: route_values['project'] = self._serialize.url('project', project, 'str') if provider_name is not None: route_values['providerName'] = self._serialize.url('provider_name', provider_name, 'str') query_parameters = {} if service_endpoint_id is not None: query_parameters['serviceEndpointId'] = self._serialize.query('service_endpoint_id', service_endpoint_id, 'str') if repository is not None: query_parameters['repository'] = self._serialize.query('repository', repository, 'str') content = self._serialize.body(trigger_types, '[DefinitionTriggerType]') self._send(http_method='POST', location_id='793bceb8-9736-4030-bd2f-fb3ce6d6b478', version='5.1-preview.1', route_values=route_values, query_parameters=query_parameters, content=content)
[ "def", "restore_webhooks", "(", "self", ",", "trigger_types", ",", "project", ",", "provider_name", ",", "service_endpoint_id", "=", "None", ",", "repository", "=", "None", ")", ":", "route_values", "=", "{", "}", "if", "project", "is", "not", "None", ":", ...
https://github.com/microsoft/azure-devops-python-api/blob/451cade4c475482792cbe9e522c1fee32393139e/azure-devops/azure/devops/v5_1/build/build_client.py#L1863-L1888
TencentCloud/tencentcloud-sdk-python
3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2
tencentcloud/ocr/v20181119/models.py
python
EstateCertOCRResponse.__init__
(self)
r""" :param Obligee: 权利人 :type Obligee: str :param Ownership: 共有情况 :type Ownership: str :param Location: 坐落 :type Location: str :param Unit: 不动产单元号 :type Unit: str :param Type: 权利类型 :type Type: str :param Property: 权利性质 :type Property: str :param Usage: 用途 :type Usage: str :param Area: 面积 :type Area: str :param Term: 使用期限 :type Term: str :param Other: 权利其他状况,多行会用换行符\n连接。 :type Other: str :param Angle: 图片旋转角度 :type Angle: float :param Number: 不动产权号 :type Number: str :param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 :type RequestId: str
r""" :param Obligee: 权利人 :type Obligee: str :param Ownership: 共有情况 :type Ownership: str :param Location: 坐落 :type Location: str :param Unit: 不动产单元号 :type Unit: str :param Type: 权利类型 :type Type: str :param Property: 权利性质 :type Property: str :param Usage: 用途 :type Usage: str :param Area: 面积 :type Area: str :param Term: 使用期限 :type Term: str :param Other: 权利其他状况,多行会用换行符\n连接。 :type Other: str :param Angle: 图片旋转角度 :type Angle: float :param Number: 不动产权号 :type Number: str :param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 :type RequestId: str
[ "r", ":", "param", "Obligee", ":", "权利人", ":", "type", "Obligee", ":", "str", ":", "param", "Ownership", ":", "共有情况", ":", "type", "Ownership", ":", "str", ":", "param", "Location", ":", "坐落", ":", "type", "Location", ":", "str", ":", "param", "Unit"...
def __init__(self): r""" :param Obligee: 权利人 :type Obligee: str :param Ownership: 共有情况 :type Ownership: str :param Location: 坐落 :type Location: str :param Unit: 不动产单元号 :type Unit: str :param Type: 权利类型 :type Type: str :param Property: 权利性质 :type Property: str :param Usage: 用途 :type Usage: str :param Area: 面积 :type Area: str :param Term: 使用期限 :type Term: str :param Other: 权利其他状况,多行会用换行符\n连接。 :type Other: str :param Angle: 图片旋转角度 :type Angle: float :param Number: 不动产权号 :type Number: str :param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 :type RequestId: str """ self.Obligee = None self.Ownership = None self.Location = None self.Unit = None self.Type = None self.Property = None self.Usage = None self.Area = None self.Term = None self.Other = None self.Angle = None self.Number = None self.RequestId = None
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "Obligee", "=", "None", "self", ".", "Ownership", "=", "None", "self", ".", "Location", "=", "None", "self", ".", "Unit", "=", "None", "self", ".", "Type", "=", "None", "self", ".", "Property", ...
https://github.com/TencentCloud/tencentcloud-sdk-python/blob/3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2/tencentcloud/ocr/v20181119/models.py#L1691-L1732
fooying/3102
0faee38c30b2e24154f41e68457cfd8f7a61c040
thirdparty/attrdict/__init__.py
python
AttrDict.__delitem__
(self, key)
del adict[key] Delete a key-value pair in the instance.
del adict[key]
[ "del", "adict", "[", "key", "]" ]
def __delitem__(self, key): """ del adict[key] Delete a key-value pair in the instance. """ self._delete(key)
[ "def", "__delitem__", "(", "self", ",", "key", ")", ":", "self", ".", "_delete", "(", "key", ")" ]
https://github.com/fooying/3102/blob/0faee38c30b2e24154f41e68457cfd8f7a61c040/thirdparty/attrdict/__init__.py#L183-L189
riptideio/pymodbus
c5772b35ae3f29d1947f3ab453d8d00df846459f
pymodbus/transaction.py
python
ModbusTransactionManager.getNextTID
(self)
return self.tid
Retrieve the next unique transaction identifier This handles incrementing the identifier after retrieval :returns: The next unique transaction identifier
Retrieve the next unique transaction identifier
[ "Retrieve", "the", "next", "unique", "transaction", "identifier" ]
def getNextTID(self): """ Retrieve the next unique transaction identifier This handles incrementing the identifier after retrieval :returns: The next unique transaction identifier """ self.tid = (self.tid + 1) & 0xffff return self.tid
[ "def", "getNextTID", "(", "self", ")", ":", "self", ".", "tid", "=", "(", "self", ".", "tid", "+", "1", ")", "&", "0xffff", "return", "self", ".", "tid" ]
https://github.com/riptideio/pymodbus/blob/c5772b35ae3f29d1947f3ab453d8d00df846459f/pymodbus/transaction.py#L407-L416
jython/jython3
def4f8ec47cb7a9c799ea4c745f12badf92c5769
lib-python/3.5.1/tkinter/__init__.py
python
Misc.winfo_rooty
(self)
return self.tk.getint( self.tk.call('winfo', 'rooty', self._w))
Return y coordinate of upper left corner of this widget on the root window.
Return y coordinate of upper left corner of this widget on the root window.
[ "Return", "y", "coordinate", "of", "upper", "left", "corner", "of", "this", "widget", "on", "the", "root", "window", "." ]
def winfo_rooty(self): """Return y coordinate of upper left corner of this widget on the root window.""" return self.tk.getint( self.tk.call('winfo', 'rooty', self._w))
[ "def", "winfo_rooty", "(", "self", ")", ":", "return", "self", ".", "tk", ".", "getint", "(", "self", ".", "tk", ".", "call", "(", "'winfo'", ",", "'rooty'", ",", "self", ".", "_w", ")", ")" ]
https://github.com/jython/jython3/blob/def4f8ec47cb7a9c799ea4c745f12badf92c5769/lib-python/3.5.1/tkinter/__init__.py#L906-L910
CMA-ES/pycma
f6eed1ef7e747cec1ab2e5c835d6f2fd1ebc097f
cma/transformations.py
python
BoxConstraintsLinQuadTransformation.is_loosely_feasible_i
(self, x, i)
return lb - 2 * al - (ub - lb) / 2.0 <= x <= ub + 2 * au + (ub - lb) / 2.0
never used
never used
[ "never", "used" ]
def is_loosely_feasible_i(self, x, i): """never used""" lb = self._lb[self._index(i)] ub = self._ub[self._index(i)] al = self._al[self._index(i)] au = self._au[self._index(i)] return lb - 2 * al - (ub - lb) / 2.0 <= x <= ub + 2 * au + (ub - lb) / 2.0
[ "def", "is_loosely_feasible_i", "(", "self", ",", "x", ",", "i", ")", ":", "lb", "=", "self", ".", "_lb", "[", "self", ".", "_index", "(", "i", ")", "]", "ub", "=", "self", ".", "_ub", "[", "self", ".", "_index", "(", "i", ")", "]", "al", "="...
https://github.com/CMA-ES/pycma/blob/f6eed1ef7e747cec1ab2e5c835d6f2fd1ebc097f/cma/transformations.py#L360-L366
chribsen/simple-machine-learning-examples
dc94e52a4cebdc8bb959ff88b81ff8cfeca25022
venv/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/packages/ordered_dict.py
python
OrderedDict.viewkeys
(self)
return KeysView(self)
od.viewkeys() -> a set-like object providing a view on od's keys
od.viewkeys() -> a set-like object providing a view on od's keys
[ "od", ".", "viewkeys", "()", "-", ">", "a", "set", "-", "like", "object", "providing", "a", "view", "on", "od", "s", "keys" ]
def viewkeys(self): "od.viewkeys() -> a set-like object providing a view on od's keys" return KeysView(self)
[ "def", "viewkeys", "(", "self", ")", ":", "return", "KeysView", "(", "self", ")" ]
https://github.com/chribsen/simple-machine-learning-examples/blob/dc94e52a4cebdc8bb959ff88b81ff8cfeca25022/venv/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/packages/ordered_dict.py#L249-L251
krintoxi/NoobSec-Toolkit
38738541cbc03cedb9a3b3ed13b629f781ad64f6
NoobSecToolkit /scripts/sshbackdoors/backdoors/shell/pupy/pupy/packages/windows/all/pupwinutils/processes.py
python
is_process_64_from_handle
(hProcess)
return not iswow64.value
Take a process handle. return True if process is 64 bits, and False otherwise.
Take a process handle. return True if process is 64 bits, and False otherwise.
[ "Take", "a", "process", "handle", ".", "return", "True", "if", "process", "is", "64", "bits", "and", "False", "otherwise", "." ]
def is_process_64_from_handle(hProcess): """ Take a process handle. return True if process is 64 bits, and False otherwise. """ iswow64 = c_bool(False) if not hasattr(windll.kernel32,'IsWow64Process'): return False windll.kernel32.IsWow64Process(hProcess, byref(iswow64)) return not iswow64.value
[ "def", "is_process_64_from_handle", "(", "hProcess", ")", ":", "iswow64", "=", "c_bool", "(", "False", ")", "if", "not", "hasattr", "(", "windll", ".", "kernel32", ",", "'IsWow64Process'", ")", ":", "return", "False", "windll", ".", "kernel32", ".", "IsWow64...
https://github.com/krintoxi/NoobSec-Toolkit/blob/38738541cbc03cedb9a3b3ed13b629f781ad64f6/NoobSecToolkit /scripts/sshbackdoors/backdoors/shell/pupy/pupy/packages/windows/all/pupwinutils/processes.py#L35-L41
oilshell/oil
94388e7d44a9ad879b12615f6203b38596b5a2d3
Python-2.7.13/Lib/lib-tk/Tkinter.py
python
Canvas.select_clear
(self)
Clear the selection if it is in this widget.
Clear the selection if it is in this widget.
[ "Clear", "the", "selection", "if", "it", "is", "in", "this", "widget", "." ]
def select_clear(self): """Clear the selection if it is in this widget.""" self.tk.call(self._w, 'select', 'clear')
[ "def", "select_clear", "(", "self", ")", ":", "self", ".", "tk", ".", "call", "(", "self", ".", "_w", ",", "'select'", ",", "'clear'", ")" ]
https://github.com/oilshell/oil/blob/94388e7d44a9ad879b12615f6203b38596b5a2d3/Python-2.7.13/Lib/lib-tk/Tkinter.py#L2449-L2451
Garvit244/Leetcode
a1d31ff0f9f251f3dd0bee5cc8b191b7ebbccc29
1-100q/45.py
python
Solution.jump
(self, nums)
return steps if maxReach == len(nums) - 1 else 0
:type nums: List[int] :rtype: int
:type nums: List[int] :rtype: int
[ ":", "type", "nums", ":", "List", "[", "int", "]", ":", "rtype", ":", "int" ]
def jump(self, nums): """ :type nums: List[int] :rtype: int """ steps, lastRearch, maxReach = 0, 0 ,0 for index in range(len(nums)): if index > lastRearch: lastRearch = maxReach steps += 1 maxReach = max(maxReach, index + nums[index]) return steps if maxReach == len(nums) - 1 else 0
[ "def", "jump", "(", "self", ",", "nums", ")", ":", "steps", ",", "lastRearch", ",", "maxReach", "=", "0", ",", "0", ",", "0", "for", "index", "in", "range", "(", "len", "(", "nums", ")", ")", ":", "if", "index", ">", "lastRearch", ":", "lastRearc...
https://github.com/Garvit244/Leetcode/blob/a1d31ff0f9f251f3dd0bee5cc8b191b7ebbccc29/1-100q/45.py#L18-L31
linxid/Machine_Learning_Study_Path
558e82d13237114bbb8152483977806fc0c222af
Machine Learning In Action/Chapter4-NaiveBayes/venv/Lib/site-packages/pkg_resources/_vendor/pyparsing.py
python
ParserElement.__rxor__
(self, other )
return other ^ self
Implementation of ^ operator when left operand is not a C{L{ParserElement}}
Implementation of ^ operator when left operand is not a C{L{ParserElement}}
[ "Implementation", "of", "^", "operator", "when", "left", "operand", "is", "not", "a", "C", "{", "L", "{", "ParserElement", "}}" ]
def __rxor__(self, other ): """ Implementation of ^ operator when left operand is not a C{L{ParserElement}} """ if isinstance( other, basestring ): other = ParserElement._literalStringClass( other ) if not isinstance( other, ParserElement ): warnings.warn("Cannot combine element of type %s with ParserElement" % type(other), SyntaxWarning, stacklevel=2) return None return other ^ self
[ "def", "__rxor__", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "basestring", ")", ":", "other", "=", "ParserElement", ".", "_literalStringClass", "(", "other", ")", "if", "not", "isinstance", "(", "other", ",", "ParserElemen...
https://github.com/linxid/Machine_Learning_Study_Path/blob/558e82d13237114bbb8152483977806fc0c222af/Machine Learning In Action/Chapter4-NaiveBayes/venv/Lib/site-packages/pkg_resources/_vendor/pyparsing.py#L1943-L1953
Tautulli/Tautulli
2410eb33805aaac4bd1c5dad0f71e4f15afaf742
lib/future/backports/email/_header_value_parser.py
python
WhiteSpaceTerminal.value
(self)
return ' '
[]
def value(self): return ' '
[ "def", "value", "(", "self", ")", ":", "return", "' '" ]
https://github.com/Tautulli/Tautulli/blob/2410eb33805aaac4bd1c5dad0f71e4f15afaf742/lib/future/backports/email/_header_value_parser.py#L1277-L1278
iniqua/plecost
ef0d89bfdf1ef870bd11b1d8bdf93a8ce9ec6ca0
plecost_lib/libs/wordlist.py
python
get_wordlist
(wordlist_name)
Get and iterator of specified word list. :param wordlist_name: Word list name :type wordlist_name: basestring :return: iterator with each line of file. :rtype: str
Get and iterator of specified word list.
[ "Get", "and", "iterator", "of", "specified", "word", "list", "." ]
def get_wordlist(wordlist_name): """ Get and iterator of specified word list. :param wordlist_name: Word list name :type wordlist_name: basestring :return: iterator with each line of file. :rtype: str """ if not isinstance(wordlist_name, str): raise TypeError("Expected basestring, got '%s' instead" % type(wordlist_name)) word_list_name = join(get_data_folder(), wordlist_name) try: with open(word_list_name, "rU") as f: for word in f: yield word.replace("\n", "").replace("\r", "") except IOError as e: raise PlecostWordListNotFound("Wordlist '%s' not found. Error: %s" % (wordlist_name, e))
[ "def", "get_wordlist", "(", "wordlist_name", ")", ":", "if", "not", "isinstance", "(", "wordlist_name", ",", "str", ")", ":", "raise", "TypeError", "(", "\"Expected basestring, got '%s' instead\"", "%", "type", "(", "wordlist_name", ")", ")", "word_list_name", "="...
https://github.com/iniqua/plecost/blob/ef0d89bfdf1ef870bd11b1d8bdf93a8ce9ec6ca0/plecost_lib/libs/wordlist.py#L68-L88
dipy/dipy
be956a529465b28085f8fc435a756947ddee1c89
dipy/reconst/qtdmri.py
python
QtdmriFit.norm_of_laplacian_signal
(self)
return norm_laplacian
Calculates the norm of the laplacian of the fitted signal [1]_. This information could be useful to assess if the extrapolation of the fitted signal contains spurious oscillations. A high laplacian norm may indicate that these are present, and any q-space indices that use integrals of the signal may be corrupted (e.g. RTOP, RTAP, RTPP, QIV). In contrast to [1], the Laplacian now describes oscillations in the 4-dimensional qt-signal [2]. References ---------- .. [1]_ Fick, Rutger HJ, et al. "MAPL: Tissue microstructure estimation using Laplacian-regularized MAP-MRI and its application to HCP data." NeuroImage (2016). .. [2] Fick, Rutger HJ, et al. "Non-Parametric GraphNet-Regularized Representation of dMRI in Space and Time", Medical Image Analysis, 2017.
Calculates the norm of the laplacian of the fitted signal [1]_. This information could be useful to assess if the extrapolation of the fitted signal contains spurious oscillations. A high laplacian norm may indicate that these are present, and any q-space indices that use integrals of the signal may be corrupted (e.g. RTOP, RTAP, RTPP, QIV). In contrast to [1], the Laplacian now describes oscillations in the 4-dimensional qt-signal [2].
[ "Calculates", "the", "norm", "of", "the", "laplacian", "of", "the", "fitted", "signal", "[", "1", "]", "_", ".", "This", "information", "could", "be", "useful", "to", "assess", "if", "the", "extrapolation", "of", "the", "fitted", "signal", "contains", "spu...
def norm_of_laplacian_signal(self): """ Calculates the norm of the laplacian of the fitted signal [1]_. This information could be useful to assess if the extrapolation of the fitted signal contains spurious oscillations. A high laplacian norm may indicate that these are present, and any q-space indices that use integrals of the signal may be corrupted (e.g. RTOP, RTAP, RTPP, QIV). In contrast to [1], the Laplacian now describes oscillations in the 4-dimensional qt-signal [2]. References ---------- .. [1]_ Fick, Rutger HJ, et al. "MAPL: Tissue microstructure estimation using Laplacian-regularized MAP-MRI and its application to HCP data." NeuroImage (2016). .. [2] Fick, Rutger HJ, et al. "Non-Parametric GraphNet-Regularized Representation of dMRI in Space and Time", Medical Image Analysis, 2017. """ if self.model.cartesian: lap_matrix = qtdmri_laplacian_reg_matrix( self.model.ind_mat, self.us, self.ut, self.model.S_mat, self.model.T_mat, self.model.U_mat, self.model.part1_reg_mat_tau, self.model.part23_reg_mat_tau, self.model.part4_reg_mat_tau, normalization=self.model.normalization ) else: lap_matrix = qtdmri_isotropic_laplacian_reg_matrix( self.model.ind_mat, self.us, self.ut, self.model.part1_uq_iso_precomp, self.model.part1_reg_mat_tau, self.model.part23_reg_mat_tau, self.model.part4_reg_mat_tau, normalization=self.model.normalization ) norm_laplacian = np.dot(self._qtdmri_coef, np.dot(self._qtdmri_coef, lap_matrix)) return norm_laplacian
[ "def", "norm_of_laplacian_signal", "(", "self", ")", ":", "if", "self", ".", "model", ".", "cartesian", ":", "lap_matrix", "=", "qtdmri_laplacian_reg_matrix", "(", "self", ".", "model", ".", "ind_mat", ",", "self", ".", "us", ",", "self", ".", "ut", ",", ...
https://github.com/dipy/dipy/blob/be956a529465b28085f8fc435a756947ddee1c89/dipy/reconst/qtdmri.py#L1010-L1048
tern-tools/tern
723f43dcaae2f2f0a08a63e5e8de3938031a386e
tern/load/docker_api.py
python
build_and_dump
(dockerfile)
return image_metadata
Given a path to the dockerfile, use the Docker API to build the container image and extract the image into a working directory. Return true if this succeeded and false if it didn't
Given a path to the dockerfile, use the Docker API to build the container image and extract the image into a working directory. Return true if this succeeded and false if it didn't
[ "Given", "a", "path", "to", "the", "dockerfile", "use", "the", "Docker", "API", "to", "build", "the", "container", "image", "and", "extract", "the", "image", "into", "a", "working", "directory", ".", "Return", "true", "if", "this", "succeeded", "and", "fal...
def build_and_dump(dockerfile): """Given a path to the dockerfile, use the Docker API to build the container image and extract the image into a working directory. Return true if this succeeded and false if it didn't""" image_metadata = None # open up a client first # if this fails we cannot proceed further so we will exit client = check_docker_setup() image = build_image(dockerfile, client) if image: # the build succeeded, so we should be able to extract it if extract_image(image): image_metadata = image.attrs remove_image(image, client) else: # we didn't succeed building the image logger.warning("Could not build Docker image") close_client(client) return image_metadata
[ "def", "build_and_dump", "(", "dockerfile", ")", ":", "image_metadata", "=", "None", "# open up a client first", "# if this fails we cannot proceed further so we will exit", "client", "=", "check_docker_setup", "(", ")", "image", "=", "build_image", "(", "dockerfile", ",", ...
https://github.com/tern-tools/tern/blob/723f43dcaae2f2f0a08a63e5e8de3938031a386e/tern/load/docker_api.py#L128-L146
BMW-InnovationLab/BMW-TensorFlow-Training-GUI
4f10d1f00f9ac312ca833e5b28fd0f8952cfee17
training_api/research/object_detection/predictors/heads/mask_head.py
python
MaskRCNNMaskHead._get_mask_predictor_conv_depth
(self, num_feature_channels, num_classes, class_weight=3.0, feature_weight=2.0)
return int(math.pow(2.0, num_conv_channels_log))
Computes the depth of the mask predictor convolutions. Computes the depth of the mask predictor convolutions given feature channels and number of classes by performing a weighted average of the two in log space to compute the number of convolution channels. The weights that are used for computing the weighted average do not need to sum to 1. Args: num_feature_channels: An integer containing the number of feature channels. num_classes: An integer containing the number of classes. class_weight: Class weight used in computing the weighted average. feature_weight: Feature weight used in computing the weighted average. Returns: An integer containing the number of convolution channels used by mask predictor.
Computes the depth of the mask predictor convolutions.
[ "Computes", "the", "depth", "of", "the", "mask", "predictor", "convolutions", "." ]
def _get_mask_predictor_conv_depth(self, num_feature_channels, num_classes, class_weight=3.0, feature_weight=2.0): """Computes the depth of the mask predictor convolutions. Computes the depth of the mask predictor convolutions given feature channels and number of classes by performing a weighted average of the two in log space to compute the number of convolution channels. The weights that are used for computing the weighted average do not need to sum to 1. Args: num_feature_channels: An integer containing the number of feature channels. num_classes: An integer containing the number of classes. class_weight: Class weight used in computing the weighted average. feature_weight: Feature weight used in computing the weighted average. Returns: An integer containing the number of convolution channels used by mask predictor. """ num_feature_channels_log = math.log(float(num_feature_channels), 2.0) num_classes_log = math.log(float(num_classes), 2.0) weighted_num_feature_channels_log = ( num_feature_channels_log * feature_weight) weighted_num_classes_log = num_classes_log * class_weight total_weight = feature_weight + class_weight num_conv_channels_log = round( (weighted_num_feature_channels_log + weighted_num_classes_log) / total_weight) return int(math.pow(2.0, num_conv_channels_log))
[ "def", "_get_mask_predictor_conv_depth", "(", "self", ",", "num_feature_channels", ",", "num_classes", ",", "class_weight", "=", "3.0", ",", "feature_weight", "=", "2.0", ")", ":", "num_feature_channels_log", "=", "math", ".", "log", "(", "float", "(", "num_featur...
https://github.com/BMW-InnovationLab/BMW-TensorFlow-Training-GUI/blob/4f10d1f00f9ac312ca833e5b28fd0f8952cfee17/training_api/research/object_detection/predictors/heads/mask_head.py#L80-L112
saltstack/salt
fae5bc757ad0f1716483ce7ae180b451545c2058
salt/modules/x509.py
python
create_certificate
(path=None, text=False, overwrite=True, ca_server=None, **kwargs)
Create an X509 certificate. path: Path to write the certificate to. text: If ``True``, return the PEM text without writing to a file. Default ``False``. overwrite: If ``True`` (default), create_certificate will overwrite the entire PEM file. Set False to preserve existing private keys and dh params that may exist in the PEM file. kwargs: Any of the properties below can be included as additional keyword arguments. ca_server: Request a remotely signed certificate from ca_server. For this to work, a ``signing_policy`` must be specified, and that same policy must be configured on the ca_server. See ``signing_policy`` for details. Also, the salt master must permit peers to call the ``sign_remote_certificate`` function. Example: /etc/salt/master.d/peer.conf .. code-block:: yaml peer: .*: - x509.sign_remote_certificate subject properties: Any of the values below can be included to set subject properties Any other subject properties supported by OpenSSL should also work. C: 2 letter Country code CN: Certificate common name, typically the FQDN. Email: Email address GN: Given Name L: Locality O: Organization OU: Organization Unit SN: SurName ST: State or Province signing_private_key: A path or string of the private key in PEM format that will be used to sign this certificate. If neither ``signing_cert``, ``public_key``, or ``csr`` are included, it will be assumed that this is a self-signed certificate, and the public key matching ``signing_private_key`` will be used to create the certificate. signing_private_key_passphrase: Passphrase used to decrypt the signing_private_key. signing_cert: A certificate matching the private key that will be used to sign this certificate. This is used to populate the issuer values in the resulting certificate. Do not include this value for self-signed certificates. public_key: The public key to be included in this certificate. This can be sourced from a public key, certificate, CSR or private key. If a private key is used, the matching public key from the private key will be generated before any processing is done. This means you can request a certificate from a remote CA using a private key file as your public_key and only the public key will be sent across the network to the CA. If neither ``public_key`` or ``csr`` are specified, it will be assumed that this is a self-signed certificate, and the public key derived from ``signing_private_key`` will be used. Specify either ``public_key`` or ``csr``, not both. Because you can input a CSR as a public key or as a CSR, it is important to understand the difference. If you import a CSR as a public key, only the public key will be added to the certificate, subject or extension information in the CSR will be lost. public_key_passphrase: If the public key is supplied as a private key, this is the passphrase used to decrypt it. csr: A file or PEM string containing a certificate signing request. This will be used to supply the subject, extensions and public key of a certificate. Any subject or extensions specified explicitly will overwrite any in the CSR. basicConstraints: X509v3 Basic Constraints extension. extensions: The following arguments set X509v3 Extension values. If the value starts with ``critical``, the extension will be marked as critical. Some special extensions are ``subjectKeyIdentifier`` and ``authorityKeyIdentifier``. ``subjectKeyIdentifier`` can be an explicit value or it can be the special string ``hash``. ``hash`` will set the subjectKeyIdentifier equal to the SHA1 hash of the modulus of the public key in this certificate. Note that this is not the exact same hashing method used by OpenSSL when using the hash value. ``authorityKeyIdentifier`` Use values acceptable to the openssl CLI tools. This will automatically populate ``authorityKeyIdentifier`` with the ``subjectKeyIdentifier`` of ``signing_cert``. If this is a self-signed cert these values will be the same. basicConstraints: X509v3 Basic Constraints keyUsage: X509v3 Key Usage extendedKeyUsage: X509v3 Extended Key Usage subjectKeyIdentifier: X509v3 Subject Key Identifier issuerAltName: X509v3 Issuer Alternative Name subjectAltName: X509v3 Subject Alternative Name crlDistributionPoints: X509v3 CRL Distribution Points issuingDistributionPoint: X509v3 Issuing Distribution Point certificatePolicies: X509v3 Certificate Policies policyConstraints: X509v3 Policy Constraints inhibitAnyPolicy: X509v3 Inhibit Any Policy nameConstraints: X509v3 Name Constraints noCheck: X509v3 OCSP No Check nsComment: Netscape Comment nsCertType: Netscape Certificate Type days_valid: The number of days this certificate should be valid. This sets the ``notAfter`` property of the certificate. Defaults to 365. version: The version of the X509 certificate. Defaults to 3. This is automatically converted to the version value, so ``version=3`` sets the certificate version field to 0x2. serial_number: The serial number to assign to this certificate. If omitted a random serial number of size ``serial_bits`` is generated. serial_bits: The number of bits to use when randomly generating a serial number. Defaults to 64. algorithm: The hashing algorithm to be used for signing this certificate. Defaults to sha256. copypath: An additional path to copy the resulting certificate to. Can be used to maintain a copy of all certificates issued for revocation purposes. prepend_cn: If set to True, the CN and a dash will be prepended to the copypath's filename. Example: /etc/pki/issued_certs/www.example.com-DE:CA:FB:AD:00:00:00:00.crt signing_policy: A signing policy that should be used to create this certificate. Signing policies should be defined in the minion configuration, or in a minion pillar. It should be a YAML formatted list of arguments which will override any arguments passed to this function. If the ``minions`` key is included in the signing policy, only minions matching that pattern (see match.glob and match.compound) will be permitted to remotely request certificates from that policy. In order to ``match.compound`` to work salt master must peers permit peers to call it. Example: /etc/salt/master.d/peer.conf .. code-block:: yaml peer: .*: - match.compound Example: .. code-block:: yaml x509_signing_policies: www: - minions: 'www*' - signing_private_key: /etc/pki/ca.key - signing_cert: /etc/pki/ca.crt - C: US - ST: Utah - L: Salt Lake City - basicConstraints: "critical CA:false" - keyUsage: "critical cRLSign, keyCertSign" - subjectKeyIdentifier: hash - authorityKeyIdentifier: keyid,issuer:always - days_valid: 90 - copypath: /etc/pki/issued_certs/ The above signing policy can be invoked with ``signing_policy=www`` not_before: Initial validity date for the certificate. This date must be specified in the format '%Y-%m-%d %H:%M:%S'. .. versionadded:: 3001 not_after: Final validity date for the certificate. This date must be specified in the format '%Y-%m-%d %H:%M:%S'. .. versionadded:: 3001 CLI Example: .. code-block:: bash salt '*' x509.create_certificate path=/etc/pki/myca.crt signing_private_key='/etc/pki/myca.key' csr='/etc/pki/myca.csr'}
Create an X509 certificate.
[ "Create", "an", "X509", "certificate", "." ]
def create_certificate(path=None, text=False, overwrite=True, ca_server=None, **kwargs): """ Create an X509 certificate. path: Path to write the certificate to. text: If ``True``, return the PEM text without writing to a file. Default ``False``. overwrite: If ``True`` (default), create_certificate will overwrite the entire PEM file. Set False to preserve existing private keys and dh params that may exist in the PEM file. kwargs: Any of the properties below can be included as additional keyword arguments. ca_server: Request a remotely signed certificate from ca_server. For this to work, a ``signing_policy`` must be specified, and that same policy must be configured on the ca_server. See ``signing_policy`` for details. Also, the salt master must permit peers to call the ``sign_remote_certificate`` function. Example: /etc/salt/master.d/peer.conf .. code-block:: yaml peer: .*: - x509.sign_remote_certificate subject properties: Any of the values below can be included to set subject properties Any other subject properties supported by OpenSSL should also work. C: 2 letter Country code CN: Certificate common name, typically the FQDN. Email: Email address GN: Given Name L: Locality O: Organization OU: Organization Unit SN: SurName ST: State or Province signing_private_key: A path or string of the private key in PEM format that will be used to sign this certificate. If neither ``signing_cert``, ``public_key``, or ``csr`` are included, it will be assumed that this is a self-signed certificate, and the public key matching ``signing_private_key`` will be used to create the certificate. signing_private_key_passphrase: Passphrase used to decrypt the signing_private_key. signing_cert: A certificate matching the private key that will be used to sign this certificate. This is used to populate the issuer values in the resulting certificate. Do not include this value for self-signed certificates. public_key: The public key to be included in this certificate. This can be sourced from a public key, certificate, CSR or private key. If a private key is used, the matching public key from the private key will be generated before any processing is done. This means you can request a certificate from a remote CA using a private key file as your public_key and only the public key will be sent across the network to the CA. If neither ``public_key`` or ``csr`` are specified, it will be assumed that this is a self-signed certificate, and the public key derived from ``signing_private_key`` will be used. Specify either ``public_key`` or ``csr``, not both. Because you can input a CSR as a public key or as a CSR, it is important to understand the difference. If you import a CSR as a public key, only the public key will be added to the certificate, subject or extension information in the CSR will be lost. public_key_passphrase: If the public key is supplied as a private key, this is the passphrase used to decrypt it. csr: A file or PEM string containing a certificate signing request. This will be used to supply the subject, extensions and public key of a certificate. Any subject or extensions specified explicitly will overwrite any in the CSR. basicConstraints: X509v3 Basic Constraints extension. extensions: The following arguments set X509v3 Extension values. If the value starts with ``critical``, the extension will be marked as critical. Some special extensions are ``subjectKeyIdentifier`` and ``authorityKeyIdentifier``. ``subjectKeyIdentifier`` can be an explicit value or it can be the special string ``hash``. ``hash`` will set the subjectKeyIdentifier equal to the SHA1 hash of the modulus of the public key in this certificate. Note that this is not the exact same hashing method used by OpenSSL when using the hash value. ``authorityKeyIdentifier`` Use values acceptable to the openssl CLI tools. This will automatically populate ``authorityKeyIdentifier`` with the ``subjectKeyIdentifier`` of ``signing_cert``. If this is a self-signed cert these values will be the same. basicConstraints: X509v3 Basic Constraints keyUsage: X509v3 Key Usage extendedKeyUsage: X509v3 Extended Key Usage subjectKeyIdentifier: X509v3 Subject Key Identifier issuerAltName: X509v3 Issuer Alternative Name subjectAltName: X509v3 Subject Alternative Name crlDistributionPoints: X509v3 CRL Distribution Points issuingDistributionPoint: X509v3 Issuing Distribution Point certificatePolicies: X509v3 Certificate Policies policyConstraints: X509v3 Policy Constraints inhibitAnyPolicy: X509v3 Inhibit Any Policy nameConstraints: X509v3 Name Constraints noCheck: X509v3 OCSP No Check nsComment: Netscape Comment nsCertType: Netscape Certificate Type days_valid: The number of days this certificate should be valid. This sets the ``notAfter`` property of the certificate. Defaults to 365. version: The version of the X509 certificate. Defaults to 3. This is automatically converted to the version value, so ``version=3`` sets the certificate version field to 0x2. serial_number: The serial number to assign to this certificate. If omitted a random serial number of size ``serial_bits`` is generated. serial_bits: The number of bits to use when randomly generating a serial number. Defaults to 64. algorithm: The hashing algorithm to be used for signing this certificate. Defaults to sha256. copypath: An additional path to copy the resulting certificate to. Can be used to maintain a copy of all certificates issued for revocation purposes. prepend_cn: If set to True, the CN and a dash will be prepended to the copypath's filename. Example: /etc/pki/issued_certs/www.example.com-DE:CA:FB:AD:00:00:00:00.crt signing_policy: A signing policy that should be used to create this certificate. Signing policies should be defined in the minion configuration, or in a minion pillar. It should be a YAML formatted list of arguments which will override any arguments passed to this function. If the ``minions`` key is included in the signing policy, only minions matching that pattern (see match.glob and match.compound) will be permitted to remotely request certificates from that policy. In order to ``match.compound`` to work salt master must peers permit peers to call it. Example: /etc/salt/master.d/peer.conf .. code-block:: yaml peer: .*: - match.compound Example: .. code-block:: yaml x509_signing_policies: www: - minions: 'www*' - signing_private_key: /etc/pki/ca.key - signing_cert: /etc/pki/ca.crt - C: US - ST: Utah - L: Salt Lake City - basicConstraints: "critical CA:false" - keyUsage: "critical cRLSign, keyCertSign" - subjectKeyIdentifier: hash - authorityKeyIdentifier: keyid,issuer:always - days_valid: 90 - copypath: /etc/pki/issued_certs/ The above signing policy can be invoked with ``signing_policy=www`` not_before: Initial validity date for the certificate. This date must be specified in the format '%Y-%m-%d %H:%M:%S'. .. versionadded:: 3001 not_after: Final validity date for the certificate. This date must be specified in the format '%Y-%m-%d %H:%M:%S'. .. versionadded:: 3001 CLI Example: .. code-block:: bash salt '*' x509.create_certificate path=/etc/pki/myca.crt signing_private_key='/etc/pki/myca.key' csr='/etc/pki/myca.csr'} """ if ( not path and not text and ("testrun" not in kwargs or kwargs["testrun"] is False) ): raise salt.exceptions.SaltInvocationError( "Either path or text must be specified." ) if path and text: raise salt.exceptions.SaltInvocationError( "Either path or text must be specified, not both." ) if "public_key_passphrase" not in kwargs: kwargs["public_key_passphrase"] = None if ca_server: if "signing_policy" not in kwargs: raise salt.exceptions.SaltInvocationError( "signing_policy must be specified" "if requesting remote certificate from ca_server {}.".format(ca_server) ) if "csr" in kwargs: kwargs["csr"] = salt.utils.stringutils.to_str( get_pem_entry(kwargs["csr"], pem_type="CERTIFICATE REQUEST") ).replace("\n", "") if "public_key" in kwargs: # Strip newlines to make passing through as cli functions easier kwargs["public_key"] = salt.utils.stringutils.to_str( get_public_key( kwargs["public_key"], passphrase=kwargs["public_key_passphrase"] ) ).replace("\n", "") # Remove system entries in kwargs # Including listen_in and prerequired because they are not included # in STATE_INTERNAL_KEYWORDS # for salt 2014.7.2 for ignore in list(_STATE_INTERNAL_KEYWORDS) + [ "listen_in", "prerequired", "__prerequired__", ]: kwargs.pop(ignore, None) # TODO: Make timeout configurable in 3000 certs = __salt__["publish.publish"]( tgt=ca_server, fun="x509.sign_remote_certificate", arg=salt.utils.data.decode_dict(kwargs, to_str=True), timeout=30, ) if not any(certs): raise salt.exceptions.SaltInvocationError( "ca_server did not respond" " salt master must permit peers to" " call the sign_remote_certificate function." ) cert_txt = certs[ca_server] if isinstance(cert_txt, str): if not _valid_pem(cert_txt, "CERTIFICATE"): raise salt.exceptions.SaltInvocationError(cert_txt) if path: return write_pem( text=cert_txt, overwrite=overwrite, path=path, pem_type="CERTIFICATE" ) else: return cert_txt signing_policy = {} if "signing_policy" in kwargs: signing_policy = _get_signing_policy(kwargs["signing_policy"]) if isinstance(signing_policy, list): dict_ = {} for item in signing_policy: dict_.update(item) signing_policy = dict_ # Overwrite any arguments in kwargs with signing_policy kwargs.update(signing_policy) for prop, default in CERT_DEFAULTS.items(): if prop not in kwargs: kwargs[prop] = default cert = M2Crypto.X509.X509() # X509 Version 3 has a value of 2 in the field. # Version 2 has a value of 1. # https://tools.ietf.org/html/rfc5280#section-4.1.2.1 cert.set_version(kwargs["version"] - 1) # Random serial number if not specified if "serial_number" not in kwargs: kwargs["serial_number"] = _dec2hex(random.getrandbits(kwargs["serial_bits"])) serial_number = int(kwargs["serial_number"].replace(":", ""), 16) # With Python3 we occasionally end up with an INT that is greater than a C # long max_value. This causes an overflow error due to a bug in M2Crypto. # See issue: https://gitlab.com/m2crypto/m2crypto/issues/232 # Remove this after M2Crypto fixes the bug. if salt.utils.platform.is_windows(): INT_MAX = 2147483647 if serial_number >= INT_MAX: serial_number -= int(serial_number / INT_MAX) * INT_MAX else: if serial_number >= sys.maxsize: serial_number -= int(serial_number / sys.maxsize) * sys.maxsize cert.set_serial_number(serial_number) # Handle not_before and not_after dates for custom certificate validity fmt = "%Y-%m-%d %H:%M:%S" if "not_before" in kwargs: try: time = datetime.datetime.strptime(kwargs["not_before"], fmt) except: raise salt.exceptions.SaltInvocationError( "not_before: {} is not in required format {}".format( kwargs["not_before"], fmt ) ) # If we do not set an explicit timezone to this naive datetime object, # the M2Crypto code will assume it is from the local machine timezone # and will try to adjust the time shift. time = time.replace(tzinfo=M2Crypto.ASN1.UTC) asn1_not_before = M2Crypto.ASN1.ASN1_UTCTIME() asn1_not_before.set_datetime(time) cert.set_not_before(asn1_not_before) if "not_after" in kwargs: try: time = datetime.datetime.strptime(kwargs["not_after"], fmt) except: raise salt.exceptions.SaltInvocationError( "not_after: {} is not in required format {}".format( kwargs["not_after"], fmt ) ) # Forcing the datetime to have an explicit tzinfo here as well. time = time.replace(tzinfo=M2Crypto.ASN1.UTC) asn1_not_after = M2Crypto.ASN1.ASN1_UTCTIME() asn1_not_after.set_datetime(time) cert.set_not_after(asn1_not_after) # Set validity dates # if no 'not_before' or 'not_after' dates are setup, both of the following # dates will be the date of today. then the days_valid offset makes sense. not_before = M2Crypto.m2.x509_get_not_before(cert.x509) not_after = M2Crypto.m2.x509_get_not_after(cert.x509) # Only process the dynamic dates if start and end are not specified. if "not_before" not in kwargs: M2Crypto.m2.x509_gmtime_adj(not_before, 0) if "not_after" not in kwargs: valid_seconds = 60 * 60 * 24 * kwargs["days_valid"] # 60s * 60m * 24 * days M2Crypto.m2.x509_gmtime_adj(not_after, valid_seconds) # If neither public_key or csr are included, this cert is self-signed if "public_key" not in kwargs and "csr" not in kwargs: kwargs["public_key"] = kwargs["signing_private_key"] if "signing_private_key_passphrase" in kwargs: kwargs["public_key_passphrase"] = kwargs["signing_private_key_passphrase"] csrexts = {} if "csr" in kwargs: kwargs["public_key"] = kwargs["csr"] csr = _get_request_obj(kwargs["csr"]) cert.set_subject(csr.get_subject()) csrexts = read_csr(kwargs["csr"])["X509v3 Extensions"] cert.set_pubkey( get_public_key( kwargs["public_key"], passphrase=kwargs["public_key_passphrase"], asObj=True ) ) subject = cert.get_subject() for entry in sorted(subject.nid): if entry in kwargs: setattr(subject, entry, kwargs[entry]) if "signing_cert" in kwargs: signing_cert = _get_certificate_obj(kwargs["signing_cert"]) else: signing_cert = cert cert.set_issuer(signing_cert.get_subject()) for extname, extlongname in EXT_NAME_MAPPINGS.items(): if ( extname in kwargs or extlongname in kwargs or extname in csrexts or extlongname in csrexts ) is False: continue # Use explicitly set values first, fall back to CSR values. extval = ( kwargs.get(extname) or kwargs.get(extlongname) or csrexts.get(extname) or csrexts.get(extlongname) ) critical = False if extval.startswith("critical "): critical = True extval = extval[9:] if extname == "subjectKeyIdentifier" and "hash" in extval: extval = extval.replace("hash", _get_pubkey_hash(cert)) issuer = None if extname == "authorityKeyIdentifier": issuer = signing_cert if extname == "subjectAltName": extval = extval.replace("IP Address", "IP") ext = _new_extension( name=extname, value=extval, critical=critical, issuer=issuer ) if not ext.x509_ext: log.info("Invalid X509v3 Extension. %s: %s", extname, extval) continue cert.add_ext(ext) if "signing_private_key_passphrase" not in kwargs: kwargs["signing_private_key_passphrase"] = None if "testrun" in kwargs and kwargs["testrun"] is True: cert_props = read_certificate(cert) cert_props["Issuer Public Key"] = get_public_key( kwargs["signing_private_key"], passphrase=kwargs["signing_private_key_passphrase"], ) return cert_props if not verify_private_key( private_key=kwargs["signing_private_key"], passphrase=kwargs["signing_private_key_passphrase"], public_key=signing_cert, ): raise salt.exceptions.SaltInvocationError( "signing_private_key: {} does no match signing_cert: {}".format( kwargs["signing_private_key"], kwargs.get("signing_cert", "") ) ) cert.sign( _get_private_key_obj( kwargs["signing_private_key"], passphrase=kwargs["signing_private_key_passphrase"], ), kwargs["algorithm"], ) if not verify_signature(cert, signing_pub_key=signing_cert): raise salt.exceptions.SaltInvocationError( "failed to verify certificate signature" ) if "copypath" in kwargs: if "prepend_cn" in kwargs and kwargs["prepend_cn"] is True: prepend = str(kwargs["CN"]) + "-" else: prepend = "" write_pem( text=cert.as_pem(), path=os.path.join( kwargs["copypath"], prepend + kwargs["serial_number"] + ".crt" ), pem_type="CERTIFICATE", ) if path: return write_pem( text=cert.as_pem(), overwrite=overwrite, path=path, pem_type="CERTIFICATE" ) else: return salt.utils.stringutils.to_str(cert.as_pem())
[ "def", "create_certificate", "(", "path", "=", "None", ",", "text", "=", "False", ",", "overwrite", "=", "True", ",", "ca_server", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "(", "not", "path", "and", "not", "text", "and", "(", "\"testrun\...
https://github.com/saltstack/salt/blob/fae5bc757ad0f1716483ce7ae180b451545c2058/salt/modules/x509.py#L1135-L1688
isce-framework/isce2
0e5114a8bede3caf1d533d98e44dfe4b983e3f48
components/isceobj/TopsProc/runPrepESD.py
python
runPrepESD
(self)
Create additional layers for performing ESD.
Create additional layers for performing ESD.
[ "Create", "additional", "layers", "for", "performing", "ESD", "." ]
def runPrepESD(self): ''' Create additional layers for performing ESD. ''' if not self.doESD: return swathList = self._insar.getValidSwathList(self.swaths) for swath in swathList: if self._insar.numberOfCommonBursts[swath-1] < 2: print('Skipping prepesd for swath IW{0}'.format(swath)) continue minBurst, maxBurst = self._insar.commonReferenceBurstLimits(swath-1) secondaryBurstStart, secondaryBurstEnd = self._insar.commonSecondaryBurstLimits(swath-1) ####Load full products reference = self._insar.loadProduct( os.path.join(self._insar.referenceSlcProduct, 'IW{0}.xml'.format(swath))) secondary = self._insar.loadProduct( os.path.join(self._insar.secondarySlcProduct, 'IW{0}.xml'.format(swath))) ####Estimate relative shifts relShifts = getRelativeShifts(reference, secondary, minBurst, maxBurst, secondaryBurstStart) maxBurst = maxBurst - 1 ###For overlaps ####Load metadata for burst IFGs ifgTop = self._insar.loadProduct( os.path.join(self._insar.coarseIfgOverlapProduct, 'top_IW{0}.xml'.format(swath))) ifgBottom = self._insar.loadProduct( os.path.join(self._insar.coarseIfgOverlapProduct, 'bottom_IW{0}.xml'.format(swath))) print('Relative shifts for swath {0}:'.format(swath)) pprint.pprint(relShifts) ####Create ESD output directory esddir = self._insar.esdDirname os.makedirs(esddir, exist_ok=True) ####Overlap offsets directory offdir = os.path.join( self._insar.coarseOffsetsDirname, self._insar.overlapsSubDirname, 'IW{0}'.format(swath)) ifglist = [] factorlist = [] offsetlist = [] cohlist = [] for ii in range(minBurst, maxBurst): ind = ii - minBurst ###Index into overlaps sind = secondaryBurstStart + ind ###Index into secondary topShift = relShifts[sind] botShift = relShifts[sind+1] topBurstIfg = ifgTop.bursts[ind] botBurstIfg = ifgBottom.bursts[ind] ####Double difference interferograms topInt = np.memmap( topBurstIfg.image.filename, dtype=np.complex64, mode='r', shape = (topBurstIfg.numberOfLines, topBurstIfg.numberOfSamples)) botInt = np.memmap( botBurstIfg.image.filename, dtype=np.complex64, mode='r', shape = (botBurstIfg.numberOfLines, botBurstIfg.numberOfSamples)) intName = os.path.join(esddir, 'overlap_IW%d_%02d.int'%(swath,ii+1)) freqName = os.path.join(esddir, 'freq_IW%d_%02d.bin'%(swath,ii+1)) with open(intName, 'wb') as fid: fid.write( topInt * np.conj(botInt)) img = isceobj.createIntImage() img.setFilename(intName) img.setLength(topBurstIfg.numberOfLines) img.setWidth(topBurstIfg.numberOfSamples) img.setAccessMode('READ') img.renderHdr() multIntName= multilook(intName, alks = self.esdAzimuthLooks, rlks=self.esdRangeLooks) ifglist.append(multIntName) ####Estimate coherence of double different interferograms multCor = createCoherence(multIntName) cohlist.append(multCor) ####Estimate the frequency difference azTop = os.path.join(offdir, 'azimuth_top_%02d_%02d.off'%(ii+1,ii+2)) rgTop = os.path.join(offdir, 'range_top_%02d_%02d.off'%(ii+1,ii+2)) azBot = os.path.join(offdir, 'azimuth_bot_%02d_%02d.off'%(ii+1,ii+2)) rgBot = os.path.join(offdir, 'range_bot_%02d_%02d.off'%(ii+1,ii+2)) mFullTop = reference.bursts[ii] mFullBot = reference.bursts[ii+1] sFullTop = secondary.bursts[sind] sFullBot = secondary.bursts[sind+1] freqdiff = overlapSpectralSeparation(topBurstIfg, botBurstIfg, mFullTop, mFullBot, sFullTop, sFullBot, azTop, rgTop, azBot, rgBot) with open(freqName, 'wb') as fid: (freqdiff * 2 * np.pi * mFullTop.azimuthTimeInterval).astype(np.float32).tofile(fid) img = isceobj.createImage() img.setFilename(freqName) img.setWidth(topBurstIfg.numberOfSamples) img.setLength(topBurstIfg.numberOfLines) img.setAccessMode('READ') img.bands = 1 img.dataType = 'FLOAT' img.renderHdr() multConstName = multilook(freqName, alks = self.esdAzimuthLooks, rlks = self.esdRangeLooks) factorlist.append(multConstName)
[ "def", "runPrepESD", "(", "self", ")", ":", "if", "not", "self", ".", "doESD", ":", "return", "swathList", "=", "self", ".", "_insar", ".", "getValidSwathList", "(", "self", ".", "swaths", ")", "for", "swath", "in", "swathList", ":", "if", "self", ".",...
https://github.com/isce-framework/isce2/blob/0e5114a8bede3caf1d533d98e44dfe4b983e3f48/components/isceobj/TopsProc/runPrepESD.py#L209-L326
dropbox/changes
37e23c3141b75e4785cf398d015e3dbca41bdd56
changes/queue/task.py
python
TrackedTask._update
(self, kwargs)
return bool(count)
Update's the state of this Task. >>> task._update(status=Status.finished) Returns: bool: Whether anything was updated.
Update's the state of this Task.
[ "Update", "s", "the", "state", "of", "this", "Task", "." ]
def _update(self, kwargs): """ Update's the state of this Task. >>> task._update(status=Status.finished) Returns: bool: Whether anything was updated. """ assert self.task_id count = Task.query.filter( Task.task_name == self.task_name, Task.task_id == self.task_id, Task.parent_id == self.parent_id, ).update(kwargs, synchronize_session=False) return bool(count)
[ "def", "_update", "(", "self", ",", "kwargs", ")", ":", "assert", "self", ".", "task_id", "count", "=", "Task", ".", "query", ".", "filter", "(", "Task", ".", "task_name", "==", "self", ".", "task_name", ",", "Task", ".", "task_id", "==", "self", "."...
https://github.com/dropbox/changes/blob/37e23c3141b75e4785cf398d015e3dbca41bdd56/changes/queue/task.py#L167-L183
wistbean/fxxkpython
88e16d79d8dd37236ba6ecd0d0ff11d63143968c
vip/qyxuan/projects/venv/lib/python3.6/site-packages/pygame/examples/arraydemo.py
python
surfdemo_show
(array_img, name)
displays a surface, waits for user to continue
displays a surface, waits for user to continue
[ "displays", "a", "surface", "waits", "for", "user", "to", "continue" ]
def surfdemo_show(array_img, name): "displays a surface, waits for user to continue" screen = pygame.display.set_mode(array_img.shape[:2], 0, 32) surfarray.blit_array(screen, array_img) pygame.display.flip() pygame.display.set_caption(name) while 1: e = pygame.event.wait() if e.type == MOUSEBUTTONDOWN: break elif e.type == KEYDOWN and e.key == K_s: #pygame.image.save(screen, name+'.bmp') #s = pygame.Surface(screen.get_size(), 0, 32) #s = s.convert_alpha() #s.fill((0,0,0,255)) #s.blit(screen, (0,0)) #s.fill((222,0,0,50), (0,0,40,40)) #pygame.image.save_extended(s, name+'.png') #pygame.image.save(s, name+'.png') #pygame.image.save(screen, name+'_screen.png') #pygame.image.save(s, name+'.tga') pygame.image.save(screen, name+'.png') elif e.type == QUIT: raise SystemExit()
[ "def", "surfdemo_show", "(", "array_img", ",", "name", ")", ":", "screen", "=", "pygame", ".", "display", ".", "set_mode", "(", "array_img", ".", "shape", "[", ":", "2", "]", ",", "0", ",", "32", ")", "surfarray", ".", "blit_array", "(", "screen", ",...
https://github.com/wistbean/fxxkpython/blob/88e16d79d8dd37236ba6ecd0d0ff11d63143968c/vip/qyxuan/projects/venv/lib/python3.6/site-packages/pygame/examples/arraydemo.py#L11-L33
bruderstein/PythonScript
df9f7071ddf3a079e3a301b9b53a6dc78cf1208f
PythonLib/full/dbm/dumb.py
python
_Database._setval
(self, pos, val)
return (pos, len(val))
[]
def _setval(self, pos, val): with _io.open(self._datfile, 'rb+') as f: f.seek(pos) f.write(val) return (pos, len(val))
[ "def", "_setval", "(", "self", ",", "pos", ",", "val", ")", ":", "with", "_io", ".", "open", "(", "self", ".", "_datfile", ",", "'rb+'", ")", "as", "f", ":", "f", ".", "seek", "(", "pos", ")", "f", ".", "write", "(", "val", ")", "return", "("...
https://github.com/bruderstein/PythonScript/blob/df9f7071ddf3a079e3a301b9b53a6dc78cf1208f/PythonLib/full/dbm/dumb.py#L171-L175
rhinstaller/anaconda
63edc8680f1b05cbfe11bef28703acba808c5174
pyanaconda/core/configuration/anaconda.py
python
AnacondaConfiguration.set_from_opts
(self, opts)
Set the configuration from the Anaconda cmdline options. This code is too related to the Anaconda cmdline options, so it shouldn't be part of this class. We should find a better, more universal, way to change the Anaconda configuration. FIXME: This is a temporary solution. :param opts: a namespace of options
Set the configuration from the Anaconda cmdline options.
[ "Set", "the", "configuration", "from", "the", "Anaconda", "cmdline", "options", "." ]
def set_from_opts(self, opts): """Set the configuration from the Anaconda cmdline options. This code is too related to the Anaconda cmdline options, so it shouldn't be part of this class. We should find a better, more universal, way to change the Anaconda configuration. FIXME: This is a temporary solution. :param opts: a namespace of options """ if opts.debug: self.anaconda._set_option("debug", True) # Set "nosave flags". if "can_copy_input_kickstart" in opts: self.target._set_option("can_copy_input_kickstart", opts.can_copy_input_kickstart) if "can_save_output_kickstart" in opts: self.target._set_option("can_save_output_kickstart", opts.can_save_output_kickstart) if "can_save_installation_logs" in opts: self.target._set_option("can_save_installation_logs", opts.can_save_installation_logs) # Set the bootloader type. if opts.extlinux: self.bootloader._set_option("type", BootloaderType.EXTLINUX.value) # Set the boot loader flags. self.bootloader._set_option("nonibft_iscsi_boot", opts.nonibftiscsiboot) # Set the storage flags. self.storage._set_option("dmraid", opts.dmraid) self.storage._set_option("ibft", opts.ibft) if hasattr(opts, "gpt"): self.storage._set_option("gpt", opts.gpt) self.storage._set_option("multipath_friendly_names", opts.multipath_friendly_names) # Set up the rescue mode. if opts.rescue: self.storage._set_option("allow_imperfect_devices", True) # Set the security flags. self.security._set_option("selinux", opts.selinux) # Set the type of the installation system. if opts.liveinst: self.system._set_option("type", SystemType.LIVE_OS.value) elif opts.images or opts.dirinstall: self.system._set_option("type", SystemType.UNKNOWN.value) else: self.system._set_option("type", SystemType.BOOT_ISO.value) # Set the type of the installation target. if opts.images: # The image installation is requested. self.target._set_option("type", TargetType.IMAGE.value) elif opts.dirinstall: # The dir installation is requested. self.target._set_option("type", TargetType.DIRECTORY.value) self.target._set_option("physical_root", opts.dirinstall) # Set the payload flags. if opts.noverifyssl: self.payload._set_option("verify_ssl", not opts.noverifyssl) self.validate()
[ "def", "set_from_opts", "(", "self", ",", "opts", ")", ":", "if", "opts", ".", "debug", ":", "self", ".", "anaconda", ".", "_set_option", "(", "\"debug\"", ",", "True", ")", "# Set \"nosave flags\".", "if", "\"can_copy_input_kickstart\"", "in", "opts", ":", ...
https://github.com/rhinstaller/anaconda/blob/63edc8680f1b05cbfe11bef28703acba808c5174/pyanaconda/core/configuration/anaconda.py#L342-L406
shapely/shapely
9258e6dd4dcca61699d69c2a5853a486b132ed86
shapely/geometry/base.py
python
BaseGeometry.minimum_clearance
(self)
return float(shapely.minimum_clearance(self))
Unitless distance by which a node could be moved to produce an invalid geometry (float)
Unitless distance by which a node could be moved to produce an invalid geometry (float)
[ "Unitless", "distance", "by", "which", "a", "node", "could", "be", "moved", "to", "produce", "an", "invalid", "geometry", "(", "float", ")" ]
def minimum_clearance(self): """Unitless distance by which a node could be moved to produce an invalid geometry (float)""" return float(shapely.minimum_clearance(self))
[ "def", "minimum_clearance", "(", "self", ")", ":", "return", "float", "(", "shapely", ".", "minimum_clearance", "(", "self", ")", ")" ]
https://github.com/shapely/shapely/blob/9258e6dd4dcca61699d69c2a5853a486b132ed86/shapely/geometry/base.py#L250-L252
dropbox/dropbox-sdk-python
015437429be224732990041164a21a0501235db1
dropbox/team_log.py
python
EventDetails.get_sharing_change_link_enforce_password_policy_details
(self)
return self._value
Only call this if :meth:`is_sharing_change_link_enforce_password_policy_details` is true. :rtype: SharingChangeLinkEnforcePasswordPolicyDetails
Only call this if :meth:`is_sharing_change_link_enforce_password_policy_details` is true.
[ "Only", "call", "this", "if", ":", "meth", ":", "is_sharing_change_link_enforce_password_policy_details", "is", "true", "." ]
def get_sharing_change_link_enforce_password_policy_details(self): """ Only call this if :meth:`is_sharing_change_link_enforce_password_policy_details` is true. :rtype: SharingChangeLinkEnforcePasswordPolicyDetails """ if not self.is_sharing_change_link_enforce_password_policy_details(): raise AttributeError("tag 'sharing_change_link_enforce_password_policy_details' not set") return self._value
[ "def", "get_sharing_change_link_enforce_password_policy_details", "(", "self", ")", ":", "if", "not", "self", ".", "is_sharing_change_link_enforce_password_policy_details", "(", ")", ":", "raise", "AttributeError", "(", "\"tag 'sharing_change_link_enforce_password_policy_details' n...
https://github.com/dropbox/dropbox-sdk-python/blob/015437429be224732990041164a21a0501235db1/dropbox/team_log.py#L21299-L21307
ni/nidaqmx-python
62fc6b48cbbb330fe1bcc9aedadc86610a1269b6
nidaqmx/_task_modules/channels/ci_channel.py
python
CIChannel.ci_velocity_a_input_dig_fltr_enable
(self)
[]
def ci_velocity_a_input_dig_fltr_enable(self): cfunc = (lib_importer.windll. DAQmxResetCIVelocityEncoderAInputDigFltrEnable) if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ lib_importer.task_handle, ctypes_byte_str] error_code = cfunc( self._handle, self._name) check_for_error(error_code)
[ "def", "ci_velocity_a_input_dig_fltr_enable", "(", "self", ")", ":", "cfunc", "=", "(", "lib_importer", ".", "windll", ".", "DAQmxResetCIVelocityEncoderAInputDigFltrEnable", ")", "if", "cfunc", ".", "argtypes", "is", "None", ":", "with", "cfunc", ".", "arglock", "...
https://github.com/ni/nidaqmx-python/blob/62fc6b48cbbb330fe1bcc9aedadc86610a1269b6/nidaqmx/_task_modules/channels/ci_channel.py#L10849-L10860
openshift/openshift-tools
1188778e728a6e4781acf728123e5b356380fe6f
ansible/roles/lib_oa_openshift/library/oc_adm_router.py
python
RoleBindingConfig.create_dict
(self)
create a default rolebinding as a dict
create a default rolebinding as a dict
[ "create", "a", "default", "rolebinding", "as", "a", "dict" ]
def create_dict(self): ''' create a default rolebinding as a dict ''' self.data['apiVersion'] = 'v1' self.data['kind'] = 'RoleBinding' self.data['groupNames'] = self.group_names self.data['metadata']['name'] = self.name self.data['metadata']['namespace'] = self.namespace self.data['roleRef'] = self.role_ref self.data['subjects'] = self.subjects self.data['userNames'] = self.usernames
[ "def", "create_dict", "(", "self", ")", ":", "self", ".", "data", "[", "'apiVersion'", "]", "=", "'v1'", "self", ".", "data", "[", "'kind'", "]", "=", "'RoleBinding'", "self", ".", "data", "[", "'groupNames'", "]", "=", "self", ".", "group_names", "sel...
https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/ansible/roles/lib_oa_openshift/library/oc_adm_router.py#L2412-L2422
eleurent/highway-env
9d63973da854584fe51b00ccee7b24b1bf031418
highway_env/envs/common/abstract.py
python
AbstractEnv._reset
(self)
Reset the scene: roads and vehicles. This method must be overloaded by the environments.
Reset the scene: roads and vehicles.
[ "Reset", "the", "scene", ":", "roads", "and", "vehicles", "." ]
def _reset(self) -> None: """ Reset the scene: roads and vehicles. This method must be overloaded by the environments. """ raise NotImplementedError()
[ "def", "_reset", "(", "self", ")", "->", "None", ":", "raise", "NotImplementedError", "(", ")" ]
https://github.com/eleurent/highway-env/blob/9d63973da854584fe51b00ccee7b24b1bf031418/highway_env/envs/common/abstract.py#L193-L199
spl0k/supysonic
62bad3b9878a1d22cf040f25dab0fa28a252ba38
supysonic/daemon/client.py
python
AddWatchedFolderCommand.apply
(self, connection, daemon)
[]
def apply(self, connection, daemon): if daemon.watcher is not None: daemon.watcher.add_folder(self._folder)
[ "def", "apply", "(", "self", ",", "connection", ",", "daemon", ")", ":", "if", "daemon", ".", "watcher", "is", "not", "None", ":", "daemon", ".", "watcher", ".", "add_folder", "(", "self", ".", "_folder", ")" ]
https://github.com/spl0k/supysonic/blob/62bad3b9878a1d22cf040f25dab0fa28a252ba38/supysonic/daemon/client.py#L28-L30
nschloe/quadpy
c4c076d8ddfa968486a2443a95e2fb3780dcde0f
src/quadpy/c3/_classical.py
python
face_midpoint
()
return C3Scheme("Face-Midpoint", d, 3)
[]
def face_midpoint(): d = {"symm_r00": [[frac(1, 6)], [1]]} return C3Scheme("Face-Midpoint", d, 3)
[ "def", "face_midpoint", "(", ")", ":", "d", "=", "{", "\"symm_r00\"", ":", "[", "[", "frac", "(", "1", ",", "6", ")", "]", ",", "[", "1", "]", "]", "}", "return", "C3Scheme", "(", "\"Face-Midpoint\"", ",", "d", ",", "3", ")" ]
https://github.com/nschloe/quadpy/blob/c4c076d8ddfa968486a2443a95e2fb3780dcde0f/src/quadpy/c3/_classical.py#L16-L18
mehulj94/BrainDamage
49a29c2606d5f7c0d9705ae5f4201a6bb25cfe73
Echoes/ftpnavigator.py
python
FtpNavigator.read_file
(self, filepath)
return pwdFound
[]
def read_file(self, filepath): f = open(filepath, 'r') pwdFound = [] for ff in f.readlines(): values = {} info = ff.split(';') for i in info: i = i.split('=') if i[0] == 'Name': values['Name'] = i[1] if i[0] == 'Server': values['Server'] = i[1] if i[0] == 'Port': values['Port'] = i[1] if i[0] == 'User': values['User'] = i[1] if i[0] == "Password": if i[1] != '1' and i[1] != '0': values['Password'] = self.decode(i[1]) # used to save the password if it is an anonymous authentication if values['User'] == 'anonymous' and 'Password' not in values.keys(): values['Password'] = 'anonymous' pwdFound.append(values) # print the results return pwdFound
[ "def", "read_file", "(", "self", ",", "filepath", ")", ":", "f", "=", "open", "(", "filepath", ",", "'r'", ")", "pwdFound", "=", "[", "]", "for", "ff", "in", "f", ".", "readlines", "(", ")", ":", "values", "=", "{", "}", "info", "=", "ff", ".",...
https://github.com/mehulj94/BrainDamage/blob/49a29c2606d5f7c0d9705ae5f4201a6bb25cfe73/Echoes/ftpnavigator.py#L15-L41
betamaxpy/betamax
f06fe32d657a8c78b6e5a00048dff7fa50ad9be6
src/betamax/matchers/base.py
python
BaseMatcher.match
(self, request, recorded_request)
A method that must be implemented by the user. :param PreparedRequest request: A requests PreparedRequest object :param dict recorded_request: A dictionary containing the serialized request in the cassette :returns bool: True if they match else False
A method that must be implemented by the user.
[ "A", "method", "that", "must", "be", "implemented", "by", "the", "user", "." ]
def match(self, request, recorded_request): """A method that must be implemented by the user. :param PreparedRequest request: A requests PreparedRequest object :param dict recorded_request: A dictionary containing the serialized request in the cassette :returns bool: True if they match else False """ raise NotImplementedError('The match method must be implemented on' ' %s' % self.__class__.__name__)
[ "def", "match", "(", "self", ",", "request", ",", "recorded_request", ")", ":", "raise", "NotImplementedError", "(", "'The match method must be implemented on'", "' %s'", "%", "self", ".", "__class__", ".", "__name__", ")" ]
https://github.com/betamaxpy/betamax/blob/f06fe32d657a8c78b6e5a00048dff7fa50ad9be6/src/betamax/matchers/base.py#L53-L62
careermonk/data-structures-and-algorithmic-thinking-with-python
3c07d9dcec4fd06d0958a96fecd5e228f0378112
src/chapter06trees/FindMaxInBSTRecursive.py
python
BSTNode.rotateLeft
(self)
Q P / \ / \ C P ==> Q B / \ / \ A B C A
Q P / \ / \ C P ==> Q B / \ / \ A B C A
[ "Q", "P", "/", "\\", "/", "\\", "C", "P", "==", ">", "Q", "B", "/", "\\", "/", "\\", "A", "B", "C", "A" ]
def rotateLeft(self): ''' Q P / \ / \ C P ==> Q B / \ / \ A B C A ''' # If you do not understand at first, note that instead of # moving Q to C's position, I move P instead. So think on # terms of "P will be future Q" Q, P = self, self.right if not P: return Q.right = P.right P.right = P.left P.left = Q.left Q.left = P if P.left: P.left.parent = P if Q.right: Q.right.parent = Q P.data, Q.data = Q.data, P.data
[ "def", "rotateLeft", "(", "self", ")", ":", "# If you do not understand at first, note that instead of", "# moving Q to C's position, I move P instead. So think on", "# terms of \"P will be future Q\"", "Q", ",", "P", "=", "self", ",", "self", ".", "right", "if", "not", "P", ...
https://github.com/careermonk/data-structures-and-algorithmic-thinking-with-python/blob/3c07d9dcec4fd06d0958a96fecd5e228f0378112/src/chapter06trees/FindMaxInBSTRecursive.py#L167-L190
openshift/openshift-tools
1188778e728a6e4781acf728123e5b356380fe6f
openshift/installer/vendored/openshift-ansible-3.9.40/roles/openshift_facts/library/openshift_facts.py
python
delete_empty_keys
(keylist)
Delete dictionary elements from keylist where "value" is empty. Args: keylist(list): A list of builddefault configuration envs. Returns: none Example: keylist = [{'name': 'HTTP_PROXY', 'value': 'http://file.rdu.redhat.com:3128'}, {'name': 'HTTPS_PROXY', 'value': 'http://file.rdu.redhat.com:3128'}, {'name': 'NO_PROXY', 'value': ''}] After calling delete_empty_keys the provided list is modified to become: [{'name': 'HTTP_PROXY', 'value': 'http://file.rdu.redhat.com:3128'}, {'name': 'HTTPS_PROXY', 'value': 'http://file.rdu.redhat.com:3128'}]
Delete dictionary elements from keylist where "value" is empty.
[ "Delete", "dictionary", "elements", "from", "keylist", "where", "value", "is", "empty", "." ]
def delete_empty_keys(keylist): """ Delete dictionary elements from keylist where "value" is empty. Args: keylist(list): A list of builddefault configuration envs. Returns: none Example: keylist = [{'name': 'HTTP_PROXY', 'value': 'http://file.rdu.redhat.com:3128'}, {'name': 'HTTPS_PROXY', 'value': 'http://file.rdu.redhat.com:3128'}, {'name': 'NO_PROXY', 'value': ''}] After calling delete_empty_keys the provided list is modified to become: [{'name': 'HTTP_PROXY', 'value': 'http://file.rdu.redhat.com:3128'}, {'name': 'HTTPS_PROXY', 'value': 'http://file.rdu.redhat.com:3128'}] """ count = 0 for i in range(0, len(keylist)): if len(keylist[i - count]['value']) == 0: del keylist[i - count] count += 1
[ "def", "delete_empty_keys", "(", "keylist", ")", ":", "count", "=", "0", "for", "i", "in", "range", "(", "0", ",", "len", "(", "keylist", ")", ")", ":", "if", "len", "(", "keylist", "[", "i", "-", "count", "]", "[", "'value'", "]", ")", "==", "...
https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/openshift/installer/vendored/openshift-ansible-3.9.40/roles/openshift_facts/library/openshift_facts.py#L1201-L1224
zhl2008/awd-platform
0416b31abea29743387b10b3914581fbe8e7da5e
web_flaskbb/lib/python2.7/site-packages/whoosh/fields.py
python
ReverseField.subfields
(self)
[]
def subfields(self): yield "", self.subfield yield self.name_prefix, self
[ "def", "subfields", "(", "self", ")", ":", "yield", "\"\"", ",", "self", ".", "subfield", "yield", "self", ".", "name_prefix", ",", "self" ]
https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/lib/python2.7/site-packages/whoosh/fields.py#L1282-L1284
plotly/plotly.py
cfad7862594b35965c0e000813bd7805e8494a5b
packages/python/plotly/plotly/graph_objs/scattergeo/selected/_textfont.py
python
Textfont.color
(self)
return self["color"]
Sets the text font color of selected points. The 'color' property is a color and may be specified as: - A hex string (e.g. '#ff0000') - An rgb/rgba string (e.g. 'rgb(255,0,0)') - An hsl/hsla string (e.g. 'hsl(0,100%,50%)') - An hsv/hsva string (e.g. 'hsv(0,100%,100%)') - A named CSS color: aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, black, blanchedalmond, blue, blueviolet, brown, burlywood, cadetblue, chartreuse, chocolate, coral, cornflowerblue, cornsilk, crimson, cyan, darkblue, darkcyan, darkgoldenrod, darkgray, darkgrey, darkgreen, darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon, darkseagreen, darkslateblue, darkslategray, darkslategrey, darkturquoise, darkviolet, deeppink, deepskyblue, dimgray, dimgrey, dodgerblue, firebrick, floralwhite, forestgreen, fuchsia, gainsboro, ghostwhite, gold, goldenrod, gray, grey, green, greenyellow, honeydew, hotpink, indianred, indigo, ivory, khaki, lavender, lavenderblush, lawngreen, lemonchiffon, lightblue, lightcoral, lightcyan, lightgoldenrodyellow, lightgray, lightgrey, lightgreen, lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightslategrey, lightsteelblue, lightyellow, lime, limegreen, linen, magenta, maroon, mediumaquamarine, mediumblue, mediumorchid, mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, moccasin, navajowhite, navy, oldlace, olive, olivedrab, orange, orangered, orchid, palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip, peachpuff, peru, pink, plum, powderblue, purple, red, rosybrown, royalblue, rebeccapurple, saddlebrown, salmon, sandybrown, seagreen, seashell, sienna, silver, skyblue, slateblue, slategray, slategrey, snow, springgreen, steelblue, tan, teal, thistle, tomato, turquoise, violet, wheat, white, whitesmoke, yellow, yellowgreen Returns ------- str
Sets the text font color of selected points. The 'color' property is a color and may be specified as: - A hex string (e.g. '#ff0000') - An rgb/rgba string (e.g. 'rgb(255,0,0)') - An hsl/hsla string (e.g. 'hsl(0,100%,50%)') - An hsv/hsva string (e.g. 'hsv(0,100%,100%)') - A named CSS color: aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, black, blanchedalmond, blue, blueviolet, brown, burlywood, cadetblue, chartreuse, chocolate, coral, cornflowerblue, cornsilk, crimson, cyan, darkblue, darkcyan, darkgoldenrod, darkgray, darkgrey, darkgreen, darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon, darkseagreen, darkslateblue, darkslategray, darkslategrey, darkturquoise, darkviolet, deeppink, deepskyblue, dimgray, dimgrey, dodgerblue, firebrick, floralwhite, forestgreen, fuchsia, gainsboro, ghostwhite, gold, goldenrod, gray, grey, green, greenyellow, honeydew, hotpink, indianred, indigo, ivory, khaki, lavender, lavenderblush, lawngreen, lemonchiffon, lightblue, lightcoral, lightcyan, lightgoldenrodyellow, lightgray, lightgrey, lightgreen, lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightslategrey, lightsteelblue, lightyellow, lime, limegreen, linen, magenta, maroon, mediumaquamarine, mediumblue, mediumorchid, mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, moccasin, navajowhite, navy, oldlace, olive, olivedrab, orange, orangered, orchid, palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip, peachpuff, peru, pink, plum, powderblue, purple, red, rosybrown, royalblue, rebeccapurple, saddlebrown, salmon, sandybrown, seagreen, seashell, sienna, silver, skyblue, slateblue, slategray, slategrey, snow, springgreen, steelblue, tan, teal, thistle, tomato, turquoise, violet, wheat, white, whitesmoke, yellow, yellowgreen
[ "Sets", "the", "text", "font", "color", "of", "selected", "points", ".", "The", "color", "property", "is", "a", "color", "and", "may", "be", "specified", "as", ":", "-", "A", "hex", "string", "(", "e", ".", "g", ".", "#ff0000", ")", "-", "An", "rgb...
def color(self): """ Sets the text font color of selected points. The 'color' property is a color and may be specified as: - A hex string (e.g. '#ff0000') - An rgb/rgba string (e.g. 'rgb(255,0,0)') - An hsl/hsla string (e.g. 'hsl(0,100%,50%)') - An hsv/hsva string (e.g. 'hsv(0,100%,100%)') - A named CSS color: aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, black, blanchedalmond, blue, blueviolet, brown, burlywood, cadetblue, chartreuse, chocolate, coral, cornflowerblue, cornsilk, crimson, cyan, darkblue, darkcyan, darkgoldenrod, darkgray, darkgrey, darkgreen, darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon, darkseagreen, darkslateblue, darkslategray, darkslategrey, darkturquoise, darkviolet, deeppink, deepskyblue, dimgray, dimgrey, dodgerblue, firebrick, floralwhite, forestgreen, fuchsia, gainsboro, ghostwhite, gold, goldenrod, gray, grey, green, greenyellow, honeydew, hotpink, indianred, indigo, ivory, khaki, lavender, lavenderblush, lawngreen, lemonchiffon, lightblue, lightcoral, lightcyan, lightgoldenrodyellow, lightgray, lightgrey, lightgreen, lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightslategrey, lightsteelblue, lightyellow, lime, limegreen, linen, magenta, maroon, mediumaquamarine, mediumblue, mediumorchid, mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, moccasin, navajowhite, navy, oldlace, olive, olivedrab, orange, orangered, orchid, palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip, peachpuff, peru, pink, plum, powderblue, purple, red, rosybrown, royalblue, rebeccapurple, saddlebrown, salmon, sandybrown, seagreen, seashell, sienna, silver, skyblue, slateblue, slategray, slategrey, snow, springgreen, steelblue, tan, teal, thistle, tomato, turquoise, violet, wheat, white, whitesmoke, yellow, yellowgreen Returns ------- str """ return self["color"]
[ "def", "color", "(", "self", ")", ":", "return", "self", "[", "\"color\"", "]" ]
https://github.com/plotly/plotly.py/blob/cfad7862594b35965c0e000813bd7805e8494a5b/packages/python/plotly/plotly/graph_objs/scattergeo/selected/_textfont.py#L16-L66
IndicoDataSolutions/finetune
83ba222eed331df64b2fa7157bb64f0a2eef4a2c
finetune/optimizers/recompute_grads.py
python
underlying_variable_ref
(t)
Find the underlying variable ref. Traverses through Identity, ReadVariableOp, and Enter ops. Stops when op type has Variable or VarHandle in name. Args: t: a Tensor Returns: a Tensor that is a variable ref, or None on error.
Find the underlying variable ref. Traverses through Identity, ReadVariableOp, and Enter ops. Stops when op type has Variable or VarHandle in name. Args: t: a Tensor Returns: a Tensor that is a variable ref, or None on error.
[ "Find", "the", "underlying", "variable", "ref", ".", "Traverses", "through", "Identity", "ReadVariableOp", "and", "Enter", "ops", ".", "Stops", "when", "op", "type", "has", "Variable", "or", "VarHandle", "in", "name", ".", "Args", ":", "t", ":", "a", "Tens...
def underlying_variable_ref(t): """Find the underlying variable ref. Traverses through Identity, ReadVariableOp, and Enter ops. Stops when op type has Variable or VarHandle in name. Args: t: a Tensor Returns: a Tensor that is a variable ref, or None on error. """ while t.op.type in ["Identity", "ReadVariableOp", "Enter"]: t = t.op.inputs[0] op_type = t.op.type if "Variable" in op_type or "VarHandle" in op_type: return t else: return None
[ "def", "underlying_variable_ref", "(", "t", ")", ":", "while", "t", ".", "op", ".", "type", "in", "[", "\"Identity\"", ",", "\"ReadVariableOp\"", ",", "\"Enter\"", "]", ":", "t", "=", "t", ".", "op", ".", "inputs", "[", "0", "]", "op_type", "=", "t",...
https://github.com/IndicoDataSolutions/finetune/blob/83ba222eed331df64b2fa7157bb64f0a2eef4a2c/finetune/optimizers/recompute_grads.py#L138-L154
microsoft/debugpy
be8dd607f6837244e0b565345e497aff7a0c08bf
src/debugpy/_vendored/pydevd/third_party/pep8/autopep8.py
python
FixPEP8.fix_long_line_logically
(self, result, logical)
Try to make lines fit within --max-line-length characters.
Try to make lines fit within --max-line-length characters.
[ "Try", "to", "make", "lines", "fit", "within", "--", "max", "-", "line", "-", "length", "characters", "." ]
def fix_long_line_logically(self, result, logical): """Try to make lines fit within --max-line-length characters.""" if ( not logical or len(logical[2]) == 1 or self.source[result['line'] - 1].lstrip().startswith('#') ): return self.fix_long_line_physically(result) start_line_index = logical[0][0] end_line_index = logical[1][0] logical_lines = logical[2] previous_line = get_item(self.source, start_line_index - 1, default='') next_line = get_item(self.source, end_line_index + 1, default='') single_line = join_logical_line(''.join(logical_lines)) try: fixed = self.fix_long_line( target=single_line, previous_line=previous_line, next_line=next_line, original=''.join(logical_lines)) except (SyntaxError, tokenize.TokenError): return self.fix_long_line_physically(result) if fixed: for line_index in range(start_line_index, end_line_index + 1): self.source[line_index] = '' self.source[start_line_index] = fixed return range(start_line_index + 1, end_line_index + 1) else: return []
[ "def", "fix_long_line_logically", "(", "self", ",", "result", ",", "logical", ")", ":", "if", "(", "not", "logical", "or", "len", "(", "logical", "[", "2", "]", ")", "==", "1", "or", "self", ".", "source", "[", "result", "[", "'line'", "]", "-", "1...
https://github.com/microsoft/debugpy/blob/be8dd607f6837244e0b565345e497aff7a0c08bf/src/debugpy/_vendored/pydevd/third_party/pep8/autopep8.py#L817-L850
aws/aws-xray-sdk-python
71436ad7f275c603298da68bee072af7c214cfc3
aws_xray_sdk/core/models/dummy_entities.py
python
DummySubsegment.add_exception
(self, exception, stack, remote=False)
No-op
No-op
[ "No", "-", "op" ]
def add_exception(self, exception, stack, remote=False): """ No-op """ pass
[ "def", "add_exception", "(", "self", ",", "exception", ",", "stack", ",", "remote", "=", "False", ")", ":", "pass" ]
https://github.com/aws/aws-xray-sdk-python/blob/71436ad7f275c603298da68bee072af7c214cfc3/aws_xray_sdk/core/models/dummy_entities.py#L134-L138
ronf/asyncssh
ee1714c598d8c2ea6f5484e465443f38b68714aa
asyncssh/sftp.py
python
SFTPServerHandler._process_rename
(self, packet: SSHPacket)
Process an incoming SFTP rename request
Process an incoming SFTP rename request
[ "Process", "an", "incoming", "SFTP", "rename", "request" ]
async def _process_rename(self, packet: SSHPacket) -> None: """Process an incoming SFTP rename request""" oldpath = packet.get_string() newpath = packet.get_string() if self._version >= 5: flags = packet.get_uint32() flag_text = ', flags=0x%08x' % flags else: flags = 0 flag_text = '' if self._version < 6: packet.check_end() self.logger.debug1('Received rename request from %s to %s%s', oldpath, newpath, flag_text) if flags: result = self._server.posix_rename(oldpath, newpath) else: result = self._server.rename(oldpath, newpath) if inspect.isawaitable(result): assert result is not None await result
[ "async", "def", "_process_rename", "(", "self", ",", "packet", ":", "SSHPacket", ")", "->", "None", ":", "oldpath", "=", "packet", ".", "get_string", "(", ")", "newpath", "=", "packet", ".", "get_string", "(", ")", "if", "self", ".", "_version", ">=", ...
https://github.com/ronf/asyncssh/blob/ee1714c598d8c2ea6f5484e465443f38b68714aa/asyncssh/sftp.py#L5887-L5913
MrH0wl/Cloudmare
65e5bc9888f9d362ab2abfb103ea6c1e869d67aa
thirdparty/bs4/element.py
python
NavigableString.__getattr__
(self, attr)
text.string gives you text. This is for backwards compatibility for Navigable*String, but for CData* it lets you get the string without the CData wrapper.
text.string gives you text. This is for backwards compatibility for Navigable*String, but for CData* it lets you get the string without the CData wrapper.
[ "text", ".", "string", "gives", "you", "text", ".", "This", "is", "for", "backwards", "compatibility", "for", "Navigable", "*", "String", "but", "for", "CData", "*", "it", "lets", "you", "get", "the", "string", "without", "the", "CData", "wrapper", "." ]
def __getattr__(self, attr): """text.string gives you text. This is for backwards compatibility for Navigable*String, but for CData* it lets you get the string without the CData wrapper.""" if attr == 'string': return self else: raise AttributeError( "'%s' object has no attribute '%s'" % ( self.__class__.__name__, attr))
[ "def", "__getattr__", "(", "self", ",", "attr", ")", ":", "if", "attr", "==", "'string'", ":", "return", "self", "else", ":", "raise", "AttributeError", "(", "\"'%s' object has no attribute '%s'\"", "%", "(", "self", ".", "__class__", ".", "__name__", ",", "...
https://github.com/MrH0wl/Cloudmare/blob/65e5bc9888f9d362ab2abfb103ea6c1e869d67aa/thirdparty/bs4/element.py#L914-L923
jacoxu/encoder_decoder
6829c3bc42105aedfd1b8a81c81be19df4326c0a
keras/old_models.py
python
Sequential.save_weights
(self, filepath, overwrite=False)
Dump all layer weights to a HDF5 file.
Dump all layer weights to a HDF5 file.
[ "Dump", "all", "layer", "weights", "to", "a", "HDF5", "file", "." ]
def save_weights(self, filepath, overwrite=False): '''Dump all layer weights to a HDF5 file. ''' import h5py import os.path # if file exists and should not be overwritten if not overwrite and os.path.isfile(filepath): import sys get_input = input if sys.version_info[:2] <= (2, 7): get_input = raw_input overwrite = get_input('[WARNING] %s already exists - overwrite? ' '[y/n]' % (filepath)) while overwrite not in ['y', 'n']: overwrite = get_input('Enter "y" (overwrite) or "n" (cancel).') if overwrite == 'n': return print('[TIP] Next time specify overwrite=True in save_weights!') f = h5py.File(filepath, 'w') f.attrs['nb_layers'] = len(self.layers) for k, l in enumerate(self.layers): g = f.create_group('layer_{}'.format(k)) weights = l.get_weights() g.attrs['nb_params'] = len(weights) for n, param in enumerate(weights): param_name = 'param_{}'.format(n) param_dset = g.create_dataset(param_name, param.shape, dtype=param.dtype) param_dset[:] = param f.flush() f.close()
[ "def", "save_weights", "(", "self", ",", "filepath", ",", "overwrite", "=", "False", ")", ":", "import", "h5py", "import", "os", ".", "path", "# if file exists and should not be overwritten", "if", "not", "overwrite", "and", "os", ".", "path", ".", "isfile", "...
https://github.com/jacoxu/encoder_decoder/blob/6829c3bc42105aedfd1b8a81c81be19df4326c0a/keras/old_models.py#L865-L896
edisonlz/fastor
342078a18363ac41d3c6b1ab29dbdd44fdb0b7b3
base/site-packages/tencentcloud/vpc/v20170312/vpc_client.py
python
VpcClient.ModifySubnetAttribute
(self, request)
本接口(ModifySubnetAttribute)用于修改子网属性。 :param request: 调用ModifySubnetAttribute所需参数的结构体。 :type request: :class:`tencentcloud.vpc.v20170312.models.ModifySubnetAttributeRequest` :rtype: :class:`tencentcloud.vpc.v20170312.models.ModifySubnetAttributeResponse`
本接口(ModifySubnetAttribute)用于修改子网属性。
[ "本接口(ModifySubnetAttribute)用于修改子网属性。" ]
def ModifySubnetAttribute(self, request): """本接口(ModifySubnetAttribute)用于修改子网属性。 :param request: 调用ModifySubnetAttribute所需参数的结构体。 :type request: :class:`tencentcloud.vpc.v20170312.models.ModifySubnetAttributeRequest` :rtype: :class:`tencentcloud.vpc.v20170312.models.ModifySubnetAttributeResponse` """ try: params = request._serialize() body = self.call("ModifySubnetAttribute", params) response = json.loads(body) if "Error" not in response["Response"]: model = models.ModifySubnetAttributeResponse() model._deserialize(response["Response"]) return model else: code = response["Response"]["Error"]["Code"] message = response["Response"]["Error"]["Message"] reqid = response["Response"]["RequestId"] raise TencentCloudSDKException(code, message, reqid) except Exception as e: if isinstance(e, TencentCloudSDKException): raise e else: raise TencentCloudSDKException(e.message, e.message)
[ "def", "ModifySubnetAttribute", "(", "self", ",", "request", ")", ":", "try", ":", "params", "=", "request", ".", "_serialize", "(", ")", "body", "=", "self", ".", "call", "(", "\"ModifySubnetAttribute\"", ",", "params", ")", "response", "=", "json", ".", ...
https://github.com/edisonlz/fastor/blob/342078a18363ac41d3c6b1ab29dbdd44fdb0b7b3/base/site-packages/tencentcloud/vpc/v20170312/vpc_client.py#L2146-L2171
robotlearn/pyrobolearn
9cd7c060723fda7d2779fa255ac998c2c82b8436
pyrobolearn/returns/estimators.py
python
AdvantageEstimator.__init__
(self, storage, value, q_value, gamma=1., standardize=False)
Initialize the Advantage estimator. Args: storage (RolloutStorage): rollout storage value (Value): value function approximator. q_value (QValue, Estimator): Q-value function approximator, or estimator. gamma (float): discount factor standardize (bool): If True, it will standardize the advantage estimates.
Initialize the Advantage estimator.
[ "Initialize", "the", "Advantage", "estimator", "." ]
def __init__(self, storage, value, q_value, gamma=1., standardize=False): """ Initialize the Advantage estimator. Args: storage (RolloutStorage): rollout storage value (Value): value function approximator. q_value (QValue, Estimator): Q-value function approximator, or estimator. gamma (float): discount factor standardize (bool): If True, it will standardize the advantage estimates. """ super(AdvantageEstimator, self).__init__(storage=storage, gamma=gamma) # check value function if not isinstance(value, Value): raise TypeError("Expecting the given value to be an instance of `Value`, instead got: " "{}".format(type(value))) self._value = value # check q-value if not isinstance(q_value, (QValue, Estimator)): raise TypeError("Expecting the given q_value to be an instance of `QValue` or `Estimator`, instead got: " "{}".format(type(q_value))) self._q_value = q_value # set if we should standardize or not self._standardize = bool(standardize)
[ "def", "__init__", "(", "self", ",", "storage", ",", "value", ",", "q_value", ",", "gamma", "=", "1.", ",", "standardize", "=", "False", ")", ":", "super", "(", "AdvantageEstimator", ",", "self", ")", ".", "__init__", "(", "storage", "=", "storage", ",...
https://github.com/robotlearn/pyrobolearn/blob/9cd7c060723fda7d2779fa255ac998c2c82b8436/pyrobolearn/returns/estimators.py#L440-L466
skelsec/pypykatz
dd129ff36e00593d1340776b517f7e749ad8d314
pypykatz/crypto/des.py
python
triple_des.decrypt
(self, data, pad=None, padmode=None)
return self._unpadData(data, pad, padmode)
decrypt(data, [pad], [padmode]) -> bytes data : bytes to be encrypted pad : Optional argument for decryption padding. Must only be one byte padmode : Optional argument for overriding the padding mode. The data must be a multiple of 8 bytes and will be decrypted with the already specified key. In PAD_NORMAL mode, if the optional padding character is supplied, then the un-encrypted data will have the padding characters removed from the end of the bytes. This pad removal only occurs on the last 8 bytes of the data (last data block). In PAD_PKCS5 mode, the special padding end markers will be removed from the data after decrypting, no pad character is required for PAD_PKCS5.
decrypt(data, [pad], [padmode]) -> bytes
[ "decrypt", "(", "data", "[", "pad", "]", "[", "padmode", "]", ")", "-", ">", "bytes" ]
def decrypt(self, data, pad=None, padmode=None): """decrypt(data, [pad], [padmode]) -> bytes data : bytes to be encrypted pad : Optional argument for decryption padding. Must only be one byte padmode : Optional argument for overriding the padding mode. The data must be a multiple of 8 bytes and will be decrypted with the already specified key. In PAD_NORMAL mode, if the optional padding character is supplied, then the un-encrypted data will have the padding characters removed from the end of the bytes. This pad removal only occurs on the last 8 bytes of the data (last data block). In PAD_PKCS5 mode, the special padding end markers will be removed from the data after decrypting, no pad character is required for PAD_PKCS5. """ ENCRYPT = des.ENCRYPT DECRYPT = des.DECRYPT data = self._guardAgainstUnicode(data) if pad is not None: pad = self._guardAgainstUnicode(pad) if self.getMode() == CBC: self.__key1.setIV(self.getIV()) self.__key2.setIV(self.getIV()) self.__key3.setIV(self.getIV()) i = 0 result = [] while i < len(data): iv = data[i:i+8] block = self.__key3.crypt(iv, DECRYPT) block = self.__key2.crypt(block, ENCRYPT) block = self.__key1.crypt(block, DECRYPT) self.__key1.setIV(iv) self.__key2.setIV(iv) self.__key3.setIV(iv) result.append(block) i += 8 if _pythonMajorVersion < 3: data = ''.join(result) else: data = bytes.fromhex('').join(result) else: data = self.__key3.crypt(data, DECRYPT) data = self.__key2.crypt(data, ENCRYPT) data = self.__key1.crypt(data, DECRYPT) return self._unpadData(data, pad, padmode)
[ "def", "decrypt", "(", "self", ",", "data", ",", "pad", "=", "None", ",", "padmode", "=", "None", ")", ":", "ENCRYPT", "=", "des", ".", "ENCRYPT", "DECRYPT", "=", "des", ".", "DECRYPT", "data", "=", "self", ".", "_guardAgainstUnicode", "(", "data", "...
https://github.com/skelsec/pypykatz/blob/dd129ff36e00593d1340776b517f7e749ad8d314/pypykatz/crypto/des.py#L814-L859
Source-Python-Dev-Team/Source.Python
d0ffd8ccbd1e9923c9bc44936f20613c1c76b7fb
addons/source-python/packages/site-packages/sqlalchemy/sql/operators.py
python
ColumnOperators.__le__
(self, other)
return self.operate(le, other)
Implement the ``<=`` operator. In a column context, produces the clause ``a <= b``.
Implement the ``<=`` operator.
[ "Implement", "the", "<", "=", "operator", "." ]
def __le__(self, other): """Implement the ``<=`` operator. In a column context, produces the clause ``a <= b``. """ return self.operate(le, other)
[ "def", "__le__", "(", "self", ",", "other", ")", ":", "return", "self", ".", "operate", "(", "le", ",", "other", ")" ]
https://github.com/Source-Python-Dev-Team/Source.Python/blob/d0ffd8ccbd1e9923c9bc44936f20613c1c76b7fb/addons/source-python/packages/site-packages/sqlalchemy/sql/operators.py#L284-L290
MenglinLu/Chinese-clinical-NER
9614593ee2e1ba38d0985c44e957d316e178b93c
bert_sklearn_bioes/bert_sklearn/finetune.py
python
eval_model
(model, dataloader, config, desc="Validation")
return res
Evaluate model on validation data. Parameters ---------- model : BertPlusMLP Bert model plus mlp head dataloader : Dataloader validation dataloader device : torch.device device to run validation on model_type : string 'text_classifier' | 'text_regressor' | 'token_classifier' Returns ------- loss : float Loss calculated on eval data accy : float Classification accuracy for classifiers. Pearson coorelation for regressors.
Evaluate model on validation data.
[ "Evaluate", "model", "on", "validation", "data", "." ]
def eval_model(model, dataloader, config, desc="Validation"): """ Evaluate model on validation data. Parameters ---------- model : BertPlusMLP Bert model plus mlp head dataloader : Dataloader validation dataloader device : torch.device device to run validation on model_type : string 'text_classifier' | 'text_regressor' | 'token_classifier' Returns ------- loss : float Loss calculated on eval data accy : float Classification accuracy for classifiers. Pearson coorelation for regressors. """ device = config.device model_type = config.model_type ignore_label = config.ignore_label_id regression_stats = OnlinePearson() stats = OnlineF1(ignore_label=ignore_label) model.to(device) model.eval() loss = accy = 0. total_evals = 0 res = {} batch_iter = tqdm(dataloader, desc=desc, leave=False) for eval_steps, batch in enumerate(batch_iter): batch = tuple(t.to(device) for t in batch) _, _, _, y = batch with torch.no_grad(): tmp_eval_loss, output = model(*batch) loss += tmp_eval_loss.mean().item() if model_type == "text_classifier": _, y_pred = torch.max(output, 1) accy += torch.sum(y_pred == y) elif model_type == "text_regressor": y_pred = output # add to online stats calculator for xi, yi in zip(y.detach().cpu().numpy(), y_pred.detach().cpu().numpy()): regression_stats.add(xi, yi) elif model_type == "token_classifier": output = output.view(-1, output.shape[-1]) y_true = y.view(-1) valid_tokens = y_true != -1 _, y_pred = torch.max(output, 1) accy += torch.sum(y_pred[valid_tokens] == y_true[valid_tokens]) total_evals += torch.sum(valid_tokens).item() y_true = y_true[valid_tokens].detach().cpu().numpy() y_pred = y_pred[valid_tokens].detach().cpu().numpy() # add to online stats calculator stats.add(y_true=y_true, y_pred=y_pred) loss = loss/(eval_steps+1) if model_type == "text_classifier": accy = 100 * (accy.item() / len(dataloader.dataset)) elif model_type == "text_regressor": accy = 100 * regression_stats.pearson elif model_type == "token_classifier": accy = 100 * (accy.item() / total_evals) res['f1'] = stats.f1 res['precision'] = stats.precision res['recall'] = stats.recall res['loss'] = loss res['accy'] = accy return res
[ "def", "eval_model", "(", "model", ",", "dataloader", ",", "config", ",", "desc", "=", "\"Validation\"", ")", ":", "device", "=", "config", ".", "device", "model_type", "=", "config", ".", "model_type", "ignore_label", "=", "config", ".", "ignore_label_id", ...
https://github.com/MenglinLu/Chinese-clinical-NER/blob/9614593ee2e1ba38d0985c44e957d316e178b93c/bert_sklearn_bioes/bert_sklearn/finetune.py#L147-L234
facebookresearch/pytext
1a4e184b233856fcfb9997d74f167cbf5bbbfb8d
pytext/data/data_handler.py
python
DataHandler.preprocess_row
(self, row_data: Dict[str, Any])
return row_data
preprocess steps for a single input row, sub class should override it
preprocess steps for a single input row, sub class should override it
[ "preprocess", "steps", "for", "a", "single", "input", "row", "sub", "class", "should", "override", "it" ]
def preprocess_row(self, row_data: Dict[str, Any]) -> Dict[str, Any]: """ preprocess steps for a single input row, sub class should override it """ return row_data
[ "def", "preprocess_row", "(", "self", ",", "row_data", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "return", "row_data" ]
https://github.com/facebookresearch/pytext/blob/1a4e184b233856fcfb9997d74f167cbf5bbbfb8d/pytext/data/data_handler.py#L385-L389
commonsense/conceptnet
57e783facbff63a1ef5c581fe2e4a899f97a0ad1
conceptnet/concepttools/concepttools.py
python
ConceptTools.project_spatial
(self,textnode_list)
return self.spreading_activation(textnode_list,linktype_weights=linktype_weights_dict)
-inputs a list of concepts -computes the spatial projection, which consists of relevant locations, relevant objects in the same scene. -returns a rank-ordered list of concepts and their scores e.g.: (('concept1',score1), ('concept2,score2), ...)
-inputs a list of concepts -computes the spatial projection, which consists of relevant locations, relevant objects in the same scene. -returns a rank-ordered list of concepts and their scores e.g.: (('concept1',score1), ('concept2,score2), ...)
[ "-", "inputs", "a", "list", "of", "concepts", "-", "computes", "the", "spatial", "projection", "which", "consists", "of", "relevant", "locations", "relevant", "objects", "in", "the", "same", "scene", ".", "-", "returns", "a", "rank", "-", "ordered", "list", ...
def project_spatial(self,textnode_list): """ -inputs a list of concepts -computes the spatial projection, which consists of relevant locations, relevant objects in the same scene. -returns a rank-ordered list of concepts and their scores e.g.: (('concept1',score1), ('concept2,score2), ...) """ linktype_weights_dict = ({ 'AtLocation':1.0, 'ConceptuallyRelatedTo':0.5 }, {}) return self.spreading_activation(textnode_list,linktype_weights=linktype_weights_dict)
[ "def", "project_spatial", "(", "self", ",", "textnode_list", ")", ":", "linktype_weights_dict", "=", "(", "{", "'AtLocation'", ":", "1.0", ",", "'ConceptuallyRelatedTo'", ":", "0.5", "}", ",", "{", "}", ")", "return", "self", ".", "spreading_activation", "(", ...
https://github.com/commonsense/conceptnet/blob/57e783facbff63a1ef5c581fe2e4a899f97a0ad1/conceptnet/concepttools/concepttools.py#L393-L408
suavecode/SUAVE
4f83c467c5662b6cc611ce2ab6c0bdd25fd5c0a5
trunk/SUAVE/Core/Data.py
python
Data.append
(self,value,key=None)
Adds new values to the classes. Can also change an already appended key Assumptions: N/A Source: N/A Inputs: value key Outputs: N/A Properties Used: N/A
Adds new values to the classes. Can also change an already appended key Assumptions: N/A Source: N/A Inputs: value key Outputs: N/A Properties Used: N/A
[ "Adds", "new", "values", "to", "the", "classes", ".", "Can", "also", "change", "an", "already", "appended", "key", "Assumptions", ":", "N", "/", "A", "Source", ":", "N", "/", "A", "Inputs", ":", "value", "key", "Outputs", ":", "N", "/", "A", "Propert...
def append(self,value,key=None): """ Adds new values to the classes. Can also change an already appended key Assumptions: N/A Source: N/A Inputs: value key Outputs: N/A Properties Used: N/A """ if key is None: key = value.tag key = key.translate(t_table) if key in self: raise KeyError('key "%s" already exists' % key) self[key] = value
[ "def", "append", "(", "self", ",", "value", ",", "key", "=", "None", ")", ":", "if", "key", "is", "None", ":", "key", "=", "value", ".", "tag", "key", "=", "key", ".", "translate", "(", "t_table", ")", "if", "key", "in", "self", ":", "raise", "...
https://github.com/suavecode/SUAVE/blob/4f83c467c5662b6cc611ce2ab6c0bdd25fd5c0a5/trunk/SUAVE/Core/Data.py#L514-L536
cloudera/hue
23f02102d4547c17c32bd5ea0eb24e9eadd657a4
desktop/core/ext-py/kombu-4.3.0/kombu/log.py
python
get_loglevel
(level)
return level
Get loglevel by name.
Get loglevel by name.
[ "Get", "loglevel", "by", "name", "." ]
def get_loglevel(level): """Get loglevel by name.""" if isinstance(level, string_t): return LOG_LEVELS[level] return level
[ "def", "get_loglevel", "(", "level", ")", ":", "if", "isinstance", "(", "level", ",", "string_t", ")", ":", "return", "LOG_LEVELS", "[", "level", "]", "return", "level" ]
https://github.com/cloudera/hue/blob/23f02102d4547c17c32bd5ea0eb24e9eadd657a4/desktop/core/ext-py/kombu-4.3.0/kombu/log.py#L37-L41
rackerlabs/mimic
efd34108b6aa3eb7ecd26e22f1aa155c14a7885e
mimic/model/rackspace_images.py
python
RackspaceOnMetalCentOSImage.metadata_json
(self)
return { "flavor_classes": "onmetal", "image_type": "base", "os_type": "linux", "org.openstack__1__os_distro": "org.centos", "vm_mode": "metal", "auto_disk_config": "disabled" }
Create a JSON-serializable data structure describing ``metadata`` for an image.
Create a JSON-serializable data structure describing ``metadata`` for an image.
[ "Create", "a", "JSON", "-", "serializable", "data", "structure", "describing", "metadata", "for", "an", "image", "." ]
def metadata_json(self): """ Create a JSON-serializable data structure describing ``metadata`` for an image. """ return { "flavor_classes": "onmetal", "image_type": "base", "os_type": "linux", "org.openstack__1__os_distro": "org.centos", "vm_mode": "metal", "auto_disk_config": "disabled" }
[ "def", "metadata_json", "(", "self", ")", ":", "return", "{", "\"flavor_classes\"", ":", "\"onmetal\"", ",", "\"image_type\"", ":", "\"base\"", ",", "\"os_type\"", ":", "\"linux\"", ",", "\"org.openstack__1__os_distro\"", ":", "\"org.centos\"", ",", "\"vm_mode\"", "...
https://github.com/rackerlabs/mimic/blob/efd34108b6aa3eb7ecd26e22f1aa155c14a7885e/mimic/model/rackspace_images.py#L874-L886
openstack/cinder
23494a6d6c51451688191e1847a458f1d3cdcaa5
cinder/volume/drivers/nimble.py
python
NimbleBaseVolumeDriver.delete_group
(self, context, group, volumes)
return model_updates, volume_model_updates
Deletes a group.
Deletes a group.
[ "Deletes", "a", "group", "." ]
def delete_group(self, context, group, volumes): """Deletes a group.""" if not volume_utils.is_group_a_cg_snapshot_type(group): raise NotImplementedError() LOG.info("Delete Consistency Group %s.", group.id) model_updates = {"status": fields.GroupStatus.DELETED} error_statuses = [ fields.GroupStatus.ERROR, fields.GroupStatus.ERROR_DELETING, ] volume_model_updates = [] for tmp_volume in volumes: update_item = {"id": tmp_volume.id} try: self.delete_volume(tmp_volume) update_item["status"] = "deleted" except exception.VolumeBackendAPIException: update_item["status"] = fields.VolumeStatus.ERROR_DELETING if model_updates["status"] not in error_statuses: model_updates["status"] = fields.GroupStatus.ERROR_DELETING LOG.error("Failed to delete volume %(vol_id)s of " "group %(group_id)s.", {"vol_id": tmp_volume.id, "group_id": group.id}) volume_model_updates.append(update_item) cg_name = group.id cg_id = self.APIExecutor.get_volcoll_id_by_name(cg_name) self.APIExecutor.delete_volcoll(cg_id) return model_updates, volume_model_updates
[ "def", "delete_group", "(", "self", ",", "context", ",", "group", ",", "volumes", ")", ":", "if", "not", "volume_utils", ".", "is_group_a_cg_snapshot_type", "(", "group", ")", ":", "raise", "NotImplementedError", "(", ")", "LOG", ".", "info", "(", "\"Delete ...
https://github.com/openstack/cinder/blob/23494a6d6c51451688191e1847a458f1d3cdcaa5/cinder/volume/drivers/nimble.py#L811-L838
glouppe/info8006-introduction-to-ai
8360cc9a8c418559e402be1454ec885b6c1062d7
projects/project1/pacman_module/graphicsDisplay.py
python
PacmanGraphics.updateDistributions
(self, distributions)
Draws an agent's belief distributions
Draws an agent's belief distributions
[ "Draws", "an", "agent", "s", "belief", "distributions" ]
def updateDistributions(self, distributions): "Draws an agent's belief distributions" # copy all distributions so we don't change their state distributions = [np.copy(x) for x in distributions] if self.distributionImages is None: self.drawDistributions(self.previousState) for x in range(len(self.distributionImages)): for y in range(len(self.distributionImages[0])): image = self.distributionImages[x][y] weights = [dist[x][y] for dist in distributions] if sum(weights) != 0: pass # Fog of war color = [0.0, 0.0, 0.0] colors = GHOST_VEC_COLORS[1:] # With Pacman if self.capture: colors = GHOST_VEC_COLORS for weight, gcolor in zip(weights, colors): color = [min(1.0, c + 0.95 * g * weight ** .3) for c, g in zip(color, gcolor)] changeColor(image, formatColor(*color)) refresh()
[ "def", "updateDistributions", "(", "self", ",", "distributions", ")", ":", "# copy all distributions so we don't change their state", "distributions", "=", "[", "np", ".", "copy", "(", "x", ")", "for", "x", "in", "distributions", "]", "if", "self", ".", "distribut...
https://github.com/glouppe/info8006-introduction-to-ai/blob/8360cc9a8c418559e402be1454ec885b6c1062d7/projects/project1/pacman_module/graphicsDisplay.py#L839-L861
dask/dask
c2b962fec1ba45440fe928869dc64cfe9cc36506
dask/array/reductions.py
python
make_arg_reduction
(func, argfunc, is_nan_func=False)
return derived_from(np)(wrapped)
Create an argreduction callable Parameters ---------- func : callable The reduction (e.g. ``min``) argfunc : callable The argreduction (e.g. ``argmin``)
Create an argreduction callable
[ "Create", "an", "argreduction", "callable" ]
def make_arg_reduction(func, argfunc, is_nan_func=False): """Create an argreduction callable Parameters ---------- func : callable The reduction (e.g. ``min``) argfunc : callable The argreduction (e.g. ``argmin``) """ chunk = partial(arg_chunk, func, argfunc) combine = partial(arg_combine, func, argfunc) if is_nan_func: agg = partial(nanarg_agg, func, argfunc) else: agg = partial(arg_agg, func, argfunc) def wrapped(x, axis=None, split_every=None, out=None): return arg_reduction( x, chunk, combine, agg, axis, split_every=split_every, out=out ) wrapped.__name__ = func.__name__ return derived_from(np)(wrapped)
[ "def", "make_arg_reduction", "(", "func", ",", "argfunc", ",", "is_nan_func", "=", "False", ")", ":", "chunk", "=", "partial", "(", "arg_chunk", ",", "func", ",", "argfunc", ")", "combine", "=", "partial", "(", "arg_combine", ",", "func", ",", "argfunc", ...
https://github.com/dask/dask/blob/c2b962fec1ba45440fe928869dc64cfe9cc36506/dask/array/reductions.py#L1115-L1139
jython/jython3
def4f8ec47cb7a9c799ea4c745f12badf92c5769
lib-python/3.5.1/_collections_abc.py
python
MutableSet.discard
(self, value)
Remove an element. Do not raise an exception if absent.
Remove an element. Do not raise an exception if absent.
[ "Remove", "an", "element", ".", "Do", "not", "raise", "an", "exception", "if", "absent", "." ]
def discard(self, value): """Remove an element. Do not raise an exception if absent.""" raise NotImplementedError
[ "def", "discard", "(", "self", ",", "value", ")", ":", "raise", "NotImplementedError" ]
https://github.com/jython/jython3/blob/def4f8ec47cb7a9c799ea4c745f12badf92c5769/lib-python/3.5.1/_collections_abc.py#L511-L513
linxid/Machine_Learning_Study_Path
558e82d13237114bbb8152483977806fc0c222af
Machine Learning In Action/Chapter4-NaiveBayes/venv/Lib/site-packages/pip/_vendor/colorama/ansi.py
python
AnsiCursor.UP
(self, n=1)
return CSI + str(n) + 'A'
[]
def UP(self, n=1): return CSI + str(n) + 'A'
[ "def", "UP", "(", "self", ",", "n", "=", "1", ")", ":", "return", "CSI", "+", "str", "(", "n", ")", "+", "'A'" ]
https://github.com/linxid/Machine_Learning_Study_Path/blob/558e82d13237114bbb8152483977806fc0c222af/Machine Learning In Action/Chapter4-NaiveBayes/venv/Lib/site-packages/pip/_vendor/colorama/ansi.py#L37-L38
kupferlauncher/kupfer
1c1e9bcbce05a82f503f68f8b3955c20b02639b3
waflib/Build.py
python
BuildContext.add_post_fun
(self, meth)
Binds a callback method to execute immediately after the build is successful:: def call_ldconfig(bld): bld.exec_command('/sbin/ldconfig') def build(bld): if bld.cmd == 'install': bld.add_pre_fun(call_ldconfig)
Binds a callback method to execute immediately after the build is successful::
[ "Binds", "a", "callback", "method", "to", "execute", "immediately", "after", "the", "build", "is", "successful", "::" ]
def add_post_fun(self, meth): """ Binds a callback method to execute immediately after the build is successful:: def call_ldconfig(bld): bld.exec_command('/sbin/ldconfig') def build(bld): if bld.cmd == 'install': bld.add_pre_fun(call_ldconfig) """ try: self.post_funs.append(meth) except AttributeError: self.post_funs = [meth]
[ "def", "add_post_fun", "(", "self", ",", "meth", ")", ":", "try", ":", "self", ".", "post_funs", ".", "append", "(", "meth", ")", "except", "AttributeError", ":", "self", ".", "post_funs", "=", "[", "meth", "]" ]
https://github.com/kupferlauncher/kupfer/blob/1c1e9bcbce05a82f503f68f8b3955c20b02639b3/waflib/Build.py#L564-L578
HymanLiuTS/flaskTs
286648286976e85d9b9a5873632331efcafe0b21
flasky/lib/python2.7/site-packages/sqlalchemy/sql/operators.py
python
ColumnOperators.__lt__
(self, other)
return self.operate(lt, other)
Implement the ``<`` operator. In a column context, produces the clause ``a < b``.
Implement the ``<`` operator.
[ "Implement", "the", "<", "operator", "." ]
def __lt__(self, other): """Implement the ``<`` operator. In a column context, produces the clause ``a < b``. """ return self.operate(lt, other)
[ "def", "__lt__", "(", "self", ",", "other", ")", ":", "return", "self", ".", "operate", "(", "lt", ",", "other", ")" ]
https://github.com/HymanLiuTS/flaskTs/blob/286648286976e85d9b9a5873632331efcafe0b21/flasky/lib/python2.7/site-packages/sqlalchemy/sql/operators.py#L279-L285
qxf2/qxf2-page-object-model
8b2978e5bd2a5413d581f9e29a2098e5f5e742fd
utils/email_util.py
python
Email_Util.login
(self,username,password)
return result_flag
Login to the email
Login to the email
[ "Login", "to", "the", "email" ]
def login(self,username,password): "Login to the email" result_flag = False try: self.mail.login(username,password) except Exception as e: print('\nException in Email_Util.login') print('PYTHON SAYS:') print(e) print('\n') else: result_flag = True return result_flag
[ "def", "login", "(", "self", ",", "username", ",", "password", ")", ":", "result_flag", "=", "False", "try", ":", "self", ".", "mail", ".", "login", "(", "username", ",", "password", ")", "except", "Exception", "as", "e", ":", "print", "(", "'\\nExcept...
https://github.com/qxf2/qxf2-page-object-model/blob/8b2978e5bd2a5413d581f9e29a2098e5f5e742fd/utils/email_util.py#L30-L43
saic-vul/image_harmonization
7f71cc131cd81f7a9dc7116c52428d4d75046085
iharm/model/modeling/conv_autoencoder.py
python
DeconvDecoder.__init__
(self, depth, encoder_blocks_channels, norm_layer, attend_from=-1, image_fusion=False)
[]
def __init__(self, depth, encoder_blocks_channels, norm_layer, attend_from=-1, image_fusion=False): super(DeconvDecoder, self).__init__() self.image_fusion = image_fusion self.deconv_blocks = nn.ModuleList() in_channels = encoder_blocks_channels.pop() out_channels = in_channels for d in range(depth): out_channels = encoder_blocks_channels.pop() if len(encoder_blocks_channels) else in_channels // 2 self.deconv_blocks.append(SEDeconvBlock( in_channels, out_channels, norm_layer=norm_layer, padding=0 if d == 0 else 1, with_se=0 <= attend_from <= d )) in_channels = out_channels if self.image_fusion: self.conv_attention = nn.Conv2d(out_channels, 1, kernel_size=1) self.to_rgb = nn.Conv2d(out_channels, 3, kernel_size=1)
[ "def", "__init__", "(", "self", ",", "depth", ",", "encoder_blocks_channels", ",", "norm_layer", ",", "attend_from", "=", "-", "1", ",", "image_fusion", "=", "False", ")", ":", "super", "(", "DeconvDecoder", ",", "self", ")", ".", "__init__", "(", ")", "...
https://github.com/saic-vul/image_harmonization/blob/7f71cc131cd81f7a9dc7116c52428d4d75046085/iharm/model/modeling/conv_autoencoder.py#L68-L87
sergioburdisso/pyss3
70c37853f3f56a60c3df9b94b678ca3f0db843de
pyss3/server.py
python
get_http_body
(http_request)
return http_request.split("\r\n\r\n")[1]
Given a HTTP request, return the body.
Given a HTTP request, return the body.
[ "Given", "a", "HTTP", "request", "return", "the", "body", "." ]
def get_http_body(http_request): """Given a HTTP request, return the body.""" return http_request.split("\r\n\r\n")[1]
[ "def", "get_http_body", "(", "http_request", ")", ":", "return", "http_request", ".", "split", "(", "\"\\r\\n\\r\\n\"", ")", "[", "1", "]" ]
https://github.com/sergioburdisso/pyss3/blob/70c37853f3f56a60c3df9b94b678ca3f0db843de/pyss3/server.py#L132-L134
aiff22/PyNET-PyTorch
b05d817408cf729582b52a3fee214775ccab800c
msssim.py
python
SSIM.forward
(self, img1, img2)
return ssim(img1, img2, window=window, window_size=self.window_size, size_average=self.size_average)
[]
def forward(self, img1, img2): (_, channel, _, _) = img1.size() if channel == self.channel and self.window.dtype == img1.dtype: window = self.window else: window = create_window(self.window_size, channel).to(img1.device).type(img1.dtype) self.window = window self.channel = channel return ssim(img1, img2, window=window, window_size=self.window_size, size_average=self.size_average)
[ "def", "forward", "(", "self", ",", "img1", ",", "img2", ")", ":", "(", "_", ",", "channel", ",", "_", ",", "_", ")", "=", "img1", ".", "size", "(", ")", "if", "channel", "==", "self", ".", "channel", "and", "self", ".", "window", ".", "dtype",...
https://github.com/aiff22/PyNET-PyTorch/blob/b05d817408cf729582b52a3fee214775ccab800c/msssim.py#L112-L122
Tencent/bk-bcs-saas
2b437bf2f5fd5ce2078f7787c3a12df609f7679d
bcs-app/backend/container_service/observability/log_stream/views.py
python
LogStreamHandler.receive
(self, text_data)
获取消息, 目前只有推送, 只打印日志
获取消息, 目前只有推送, 只打印日志
[ "获取消息", "目前只有推送", "只打印日志" ]
async def receive(self, text_data): """获取消息, 目前只有推送, 只打印日志""" logger.info("receive message: %s", text_data)
[ "async", "def", "receive", "(", "self", ",", "text_data", ")", ":", "logger", ".", "info", "(", "\"receive message: %s\"", ",", "text_data", ")" ]
https://github.com/Tencent/bk-bcs-saas/blob/2b437bf2f5fd5ce2078f7787c3a12df609f7679d/bcs-app/backend/container_service/observability/log_stream/views.py#L126-L128
rowliny/DiffHelper
ab3a96f58f9579d0023aed9ebd785f4edf26f8af
Tool/SitePackages/urllib3/response.py
python
HTTPResponse.stream
(self, amt=2**16, decode_content=None)
A generator wrapper for the read() method. A call will block until ``amt`` bytes have been read from the connection or until the connection is closed. :param amt: How much of the content to read. The generator will return up to much data per iteration, but may return less. This is particularly likely when using compressed data. However, the empty string will never be returned. :param decode_content: If True, will attempt to decode the body based on the 'content-encoding' header.
A generator wrapper for the read() method. A call will block until ``amt`` bytes have been read from the connection or until the connection is closed.
[ "A", "generator", "wrapper", "for", "the", "read", "()", "method", ".", "A", "call", "will", "block", "until", "amt", "bytes", "have", "been", "read", "from", "the", "connection", "or", "until", "the", "connection", "is", "closed", "." ]
def stream(self, amt=2**16, decode_content=None): """ A generator wrapper for the read() method. A call will block until ``amt`` bytes have been read from the connection or until the connection is closed. :param amt: How much of the content to read. The generator will return up to much data per iteration, but may return less. This is particularly likely when using compressed data. However, the empty string will never be returned. :param decode_content: If True, will attempt to decode the body based on the 'content-encoding' header. """ if self.chunked and self.supports_chunked_reads(): for line in self.read_chunked(amt, decode_content=decode_content): yield line else: while not is_fp_closed(self._fp): data = self.read(amt=amt, decode_content=decode_content) if data: yield data
[ "def", "stream", "(", "self", ",", "amt", "=", "2", "**", "16", ",", "decode_content", "=", "None", ")", ":", "if", "self", ".", "chunked", "and", "self", ".", "supports_chunked_reads", "(", ")", ":", "for", "line", "in", "self", ".", "read_chunked", ...
https://github.com/rowliny/DiffHelper/blob/ab3a96f58f9579d0023aed9ebd785f4edf26f8af/Tool/SitePackages/urllib3/response.py#L475-L499
wxWidgets/Phoenix
b2199e299a6ca6d866aa6f3d0888499136ead9d6
wx/lib/ogl/basic.py
python
Shape.SetFormatMode
(self, mode, regionId = 0)
Set the format mode of the region. :param `mode`: can be a bit list of the following ============================== ============================== Format mode Description ============================== ============================== `FORMAT_NONE` No formatting `FORMAT_CENTRE_HORIZ` Horizontal centring `FORMAT_CENTRE_VERT` Vertical centring ============================== ============================== :param `regionId`: the region identifier, default=0
Set the format mode of the region.
[ "Set", "the", "format", "mode", "of", "the", "region", "." ]
def SetFormatMode(self, mode, regionId = 0): """ Set the format mode of the region. :param `mode`: can be a bit list of the following ============================== ============================== Format mode Description ============================== ============================== `FORMAT_NONE` No formatting `FORMAT_CENTRE_HORIZ` Horizontal centring `FORMAT_CENTRE_VERT` Vertical centring ============================== ============================== :param `regionId`: the region identifier, default=0 """ if regionId < len(self._regions): self._regions[regionId].SetFormatMode(mode)
[ "def", "SetFormatMode", "(", "self", ",", "mode", ",", "regionId", "=", "0", ")", ":", "if", "regionId", "<", "len", "(", "self", ".", "_regions", ")", ":", "self", ".", "_regions", "[", "regionId", "]", ".", "SetFormatMode", "(", "mode", ")" ]
https://github.com/wxWidgets/Phoenix/blob/b2199e299a6ca6d866aa6f3d0888499136ead9d6/wx/lib/ogl/basic.py#L810-L828
zhl2008/awd-platform
0416b31abea29743387b10b3914581fbe8e7da5e
web_flaskbb/lib/python2.7/site-packages/werkzeug/contrib/sessions.py
python
FilesystemSessionStore.delete
(self, session)
[]
def delete(self, session): fn = self.get_session_filename(session.sid) try: os.unlink(fn) except OSError: pass
[ "def", "delete", "(", "self", ",", "session", ")", ":", "fn", "=", "self", ".", "get_session_filename", "(", "session", ".", "sid", ")", "try", ":", "os", ".", "unlink", "(", "fn", ")", "except", "OSError", ":", "pass" ]
https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/lib/python2.7/site-packages/werkzeug/contrib/sessions.py#L256-L261
oilshell/oil
94388e7d44a9ad879b12615f6203b38596b5a2d3
Python-2.7.13/Lib/imghdr.py
python
test_xbm
(h, f)
X bitmap (X10 or X11)
X bitmap (X10 or X11)
[ "X", "bitmap", "(", "X10", "or", "X11", ")" ]
def test_xbm(h, f): """X bitmap (X10 or X11)""" s = '#define ' if h[:len(s)] == s: return 'xbm'
[ "def", "test_xbm", "(", "h", ",", "f", ")", ":", "s", "=", "'#define '", "if", "h", "[", ":", "len", "(", "s", ")", "]", "==", "s", ":", "return", "'xbm'" ]
https://github.com/oilshell/oil/blob/94388e7d44a9ad879b12615f6203b38596b5a2d3/Python-2.7.13/Lib/imghdr.py#L107-L111
mininet/mininet
8a50d3867c49781c60b6171acc6e4b46954b4281
examples/miniedit.py
python
MiniEdit.newTopology
( self )
New command.
New command.
[ "New", "command", "." ]
def newTopology( self ): "New command." for widget in tuple( self.widgetToItem ): self.deleteItem( self.widgetToItem[ widget ] ) self.hostCount = 0 self.switchCount = 0 self.controllerCount = 0 self.links = {} self.hostOpts = {} self.switchOpts = {} self.controllers = {} self.appPrefs["ipBase"]= self.defaultIpBase
[ "def", "newTopology", "(", "self", ")", ":", "for", "widget", "in", "tuple", "(", "self", ".", "widgetToItem", ")", ":", "self", ".", "deleteItem", "(", "self", ".", "widgetToItem", "[", "widget", "]", ")", "self", ".", "hostCount", "=", "0", "self", ...
https://github.com/mininet/mininet/blob/8a50d3867c49781c60b6171acc6e4b46954b4281/examples/miniedit.py#L1608-L1619
awslabs/deeplearning-benchmark
3e9a906422b402869537f91056ae771b66487a8e
tensorflow/inception/inception/slim/scopes.py
python
_get_arg_stack
()
[]
def _get_arg_stack(): stack = ops.get_collection(_ARGSTACK_KEY) if stack: return stack[0] else: stack = [{}] ops.add_to_collection(_ARGSTACK_KEY, stack) return stack
[ "def", "_get_arg_stack", "(", ")", ":", "stack", "=", "ops", ".", "get_collection", "(", "_ARGSTACK_KEY", ")", "if", "stack", ":", "return", "stack", "[", "0", "]", "else", ":", "stack", "=", "[", "{", "}", "]", "ops", ".", "add_to_collection", "(", ...
https://github.com/awslabs/deeplearning-benchmark/blob/3e9a906422b402869537f91056ae771b66487a8e/tensorflow/inception/inception/slim/scopes.py#L63-L70
c3nav/c3nav
0f4e699e3733459b1c70935a4c813959cffd86bd
src/c3nav/editor/wrappers.py
python
BaseWrapper._wrap_manager
(self, manager)
return ManagerWrapper(self._changeset, manager)
Wrap a manager with same changeset as this wrapper. Detects RelatedManager or ManyRelatedmanager instances and chooses the Wrapper accordingly.
Wrap a manager with same changeset as this wrapper. Detects RelatedManager or ManyRelatedmanager instances and chooses the Wrapper accordingly.
[ "Wrap", "a", "manager", "with", "same", "changeset", "as", "this", "wrapper", ".", "Detects", "RelatedManager", "or", "ManyRelatedmanager", "instances", "and", "chooses", "the", "Wrapper", "accordingly", "." ]
def _wrap_manager(self, manager): """ Wrap a manager with same changeset as this wrapper. Detects RelatedManager or ManyRelatedmanager instances and chooses the Wrapper accordingly. """ assert isinstance(manager, Manager) if hasattr(manager, 'through'): return ManyRelatedManagerWrapper(self._changeset, manager) if hasattr(manager, 'instance'): return RelatedManagerWrapper(self._changeset, manager) return ManagerWrapper(self._changeset, manager)
[ "def", "_wrap_manager", "(", "self", ",", "manager", ")", ":", "assert", "isinstance", "(", "manager", ",", "Manager", ")", "if", "hasattr", "(", "manager", ",", "'through'", ")", ":", "return", "ManyRelatedManagerWrapper", "(", "self", ".", "_changeset", ",...
https://github.com/c3nav/c3nav/blob/0f4e699e3733459b1c70935a4c813959cffd86bd/src/c3nav/editor/wrappers.py#L56-L66
kengz/SLM-Lab
667ba73349ad00c6f4b3e428dcd10eebbdab4c70
slm_lab/env/vec_env.py
python
DummyVecEnv.__init__
(self, env_fns)
@param env_fns iterable of functions that build environments
[]
def __init__(self, env_fns): ''' @param env_fns iterable of functions that build environments ''' self.envs = [fn() for fn in env_fns] env = self.envs[0] VecEnv.__init__(self, len(env_fns), env.observation_space, env.action_space) obs_space = env.observation_space self.keys, shapes, dtypes = obs_space_info(obs_space) self.buf_obs = {k: np.zeros((self.num_envs,) + tuple(shapes[k]), dtype=dtypes[k]) for k in self.keys} self.buf_dones = np.zeros((self.num_envs,), dtype=np.bool) self.buf_rews = np.zeros((self.num_envs,), dtype=np.float32) self.buf_infos = [{} for _ in range(self.num_envs)] self.actions = None self.spec = self.envs[0].spec
[ "def", "__init__", "(", "self", ",", "env_fns", ")", ":", "self", ".", "envs", "=", "[", "fn", "(", ")", "for", "fn", "in", "env_fns", "]", "env", "=", "self", ".", "envs", "[", "0", "]", "VecEnv", ".", "__init__", "(", "self", ",", "len", "(",...
https://github.com/kengz/SLM-Lab/blob/667ba73349ad00c6f4b3e428dcd10eebbdab4c70/slm_lab/env/vec_env.py#L272-L287
python/cpython
e13cdca0f5224ec4e23bdd04bb3120506964bc8b
Lib/venv/__init__.py
python
EnvBuilder.setup_python
(self, context)
Set up a Python executable in the environment. :param context: The information for the environment creation request being processed.
Set up a Python executable in the environment.
[ "Set", "up", "a", "Python", "executable", "in", "the", "environment", "." ]
def setup_python(self, context): """ Set up a Python executable in the environment. :param context: The information for the environment creation request being processed. """ binpath = context.bin_path path = context.env_exe copier = self.symlink_or_copy dirname = context.python_dir if os.name != 'nt': copier(context.executable, path) if not os.path.islink(path): os.chmod(path, 0o755) for suffix in ('python', 'python3', f'python3.{sys.version_info[1]}'): path = os.path.join(binpath, suffix) if not os.path.exists(path): # Issue 18807: make copies if # symlinks are not wanted copier(context.env_exe, path, relative_symlinks_ok=True) if not os.path.islink(path): os.chmod(path, 0o755) else: if self.symlinks: # For symlinking, we need a complete copy of the root directory # If symlinks fail, you'll get unnecessary copies of files, but # we assume that if you've opted into symlinks on Windows then # you know what you're doing. suffixes = [ f for f in os.listdir(dirname) if os.path.normcase(os.path.splitext(f)[1]) in ('.exe', '.dll') ] if sysconfig.is_python_build(True): suffixes = [ f for f in suffixes if os.path.normcase(f).startswith(('python', 'vcruntime')) ] else: suffixes = {'python.exe', 'python_d.exe', 'pythonw.exe', 'pythonw_d.exe'} base_exe = os.path.basename(context.env_exe) suffixes.add(base_exe) for suffix in suffixes: src = os.path.join(dirname, suffix) if os.path.lexists(src): copier(src, os.path.join(binpath, suffix)) if sysconfig.is_python_build(True): # copy init.tcl for root, dirs, files in os.walk(context.python_dir): if 'init.tcl' in files: tcldir = os.path.basename(root) tcldir = os.path.join(context.env_dir, 'Lib', tcldir) if not os.path.exists(tcldir): os.makedirs(tcldir) src = os.path.join(root, 'init.tcl') dst = os.path.join(tcldir, 'init.tcl') shutil.copyfile(src, dst) break
[ "def", "setup_python", "(", "self", ",", "context", ")", ":", "binpath", "=", "context", ".", "bin_path", "path", "=", "context", ".", "env_exe", "copier", "=", "self", ".", "symlink_or_copy", "dirname", "=", "context", ".", "python_dir", "if", "os", ".", ...
https://github.com/python/cpython/blob/e13cdca0f5224ec4e23bdd04bb3120506964bc8b/Lib/venv/__init__.py#L269-L328
sagemath/sage
f9b2db94f675ff16963ccdefba4f1a3393b3fe0d
src/sage/tensor/modules/free_module_automorphism.py
python
FreeModuleAutomorphism._del_derived
(self)
r""" Delete the derived quantities. EXAMPLES:: sage: M = FiniteRankFreeModule(QQ, 3, name='M') sage: e = M.basis('e') sage: a = M.automorphism(name='a') sage: a[e,:] = [[1,0,-1], [0,3,0], [0,0,2]] sage: b = a.inverse() sage: a._inverse Automorphism a^(-1) of the 3-dimensional vector space M over the Rational Field sage: a._del_derived() sage: a._inverse # has been reset to None
r""" Delete the derived quantities.
[ "r", "Delete", "the", "derived", "quantities", "." ]
def _del_derived(self): r""" Delete the derived quantities. EXAMPLES:: sage: M = FiniteRankFreeModule(QQ, 3, name='M') sage: e = M.basis('e') sage: a = M.automorphism(name='a') sage: a[e,:] = [[1,0,-1], [0,3,0], [0,0,2]] sage: b = a.inverse() sage: a._inverse Automorphism a^(-1) of the 3-dimensional vector space M over the Rational Field sage: a._del_derived() sage: a._inverse # has been reset to None """ # First delete the derived quantities pertaining to FreeModuleTensor: FreeModuleTensor._del_derived(self) # Then reset the inverse automorphism to None: if self._inverse is not None: self._inverse._inverse = None # (it was set to self) self._inverse = None # and delete the matrices: self._matrices.clear()
[ "def", "_del_derived", "(", "self", ")", ":", "# First delete the derived quantities pertaining to FreeModuleTensor:", "FreeModuleTensor", ".", "_del_derived", "(", "self", ")", "# Then reset the inverse automorphism to None:", "if", "self", ".", "_inverse", "is", "not", "Non...
https://github.com/sagemath/sage/blob/f9b2db94f675ff16963ccdefba4f1a3393b3fe0d/src/sage/tensor/modules/free_module_automorphism.py#L347-L372
007gzs/dingtalk-sdk
7979da2e259fdbc571728cae2425a04dbc65850a
dingtalk/client/api/microapp.py
python
MicroApp.update
(self, agent_id, app_icon=None, app_name=None, app_desc=None, homepage_url=None, pc_homepage_url=None, omp_link=None)
return self._post( '/microapp/update', { "agentId": agent_id, "appIcon": app_icon, "appName": app_name, "appDesc": app_desc, "homepageUrl": homepage_url, "pcHomepageUrl": pc_homepage_url, "ompLink": omp_link }, result_processor=lambda x: x['agentId'] )
更新微应用 :param agent_id: 微应用实例化id :param app_icon: 微应用的图标。需要调用上传接口将图标上传到钉钉服务器后获取到的mediaId :param app_name: 微应用的名称。长度限制为1~10个字符 :param app_desc: 微应用的描述。长度限制为1~20个字符 :param homepage_url: 微应用的移动端主页,必须以http开头或https开头 :param pc_homepage_url: 微应用的PC端主页,必须以http开头或https开头,如果不为空则必须与homepageUrl的域名一致 :param omp_link: 微应用的OA后台管理主页,必须以http开头或https开头。 :return: 微应用实例化id
更新微应用
[ "更新微应用" ]
def update(self, agent_id, app_icon=None, app_name=None, app_desc=None, homepage_url=None, pc_homepage_url=None, omp_link=None): """ 更新微应用 :param agent_id: 微应用实例化id :param app_icon: 微应用的图标。需要调用上传接口将图标上传到钉钉服务器后获取到的mediaId :param app_name: 微应用的名称。长度限制为1~10个字符 :param app_desc: 微应用的描述。长度限制为1~20个字符 :param homepage_url: 微应用的移动端主页,必须以http开头或https开头 :param pc_homepage_url: 微应用的PC端主页,必须以http开头或https开头,如果不为空则必须与homepageUrl的域名一致 :param omp_link: 微应用的OA后台管理主页,必须以http开头或https开头。 :return: 微应用实例化id """ return self._post( '/microapp/update', { "agentId": agent_id, "appIcon": app_icon, "appName": app_name, "appDesc": app_desc, "homepageUrl": homepage_url, "pcHomepageUrl": pc_homepage_url, "ompLink": omp_link }, result_processor=lambda x: x['agentId'] )
[ "def", "update", "(", "self", ",", "agent_id", ",", "app_icon", "=", "None", ",", "app_name", "=", "None", ",", "app_desc", "=", "None", ",", "homepage_url", "=", "None", ",", "pc_homepage_url", "=", "None", ",", "omp_link", "=", "None", ")", ":", "ret...
https://github.com/007gzs/dingtalk-sdk/blob/7979da2e259fdbc571728cae2425a04dbc65850a/dingtalk/client/api/microapp.py#L34-L60
geopython/pywps
7f228ff17594912664073a629b2c2ed9d4f5f615
pywps/app/Service.py
python
Service.create_complex_inputs
(self, source, inputs)
return outinputs
Create new ComplexInput as clone of original ComplexInput because of inputs can be more than one, take it just as Prototype. :param source: The process's input definition. :param inputs: The request input data. :return collections.deque:
Create new ComplexInput as clone of original ComplexInput because of inputs can be more than one, take it just as Prototype.
[ "Create", "new", "ComplexInput", "as", "clone", "of", "original", "ComplexInput", "because", "of", "inputs", "can", "be", "more", "than", "one", "take", "it", "just", "as", "Prototype", "." ]
def create_complex_inputs(self, source, inputs): """Create new ComplexInput as clone of original ComplexInput because of inputs can be more than one, take it just as Prototype. :param source: The process's input definition. :param inputs: The request input data. :return collections.deque: """ outinputs = deque(maxlen=source.max_occurs) for inpt in inputs: data_input = source.clone() frmt = data_input.supported_formats[0] if 'mimeType' in inpt: if inpt['mimeType']: frmt = data_input.get_format(inpt['mimeType']) else: frmt = data_input.data_format if frmt: data_input.data_format = frmt else: raise InvalidParameterValue( 'Invalid mimeType value {} for input {}'.format(inpt.get('mimeType'), source.identifier), 'mimeType') data_input.method = inpt.get('method', 'GET') data_input.process(inpt) outinputs.append(data_input) if len(outinputs) < source.min_occurs: description = "At least {} inputs are required. You provided {}.".format( source.min_occurs, len(outinputs), ) raise MissingParameterValue(description=description, locator=source.identifier) return outinputs
[ "def", "create_complex_inputs", "(", "self", ",", "source", ",", "inputs", ")", ":", "outinputs", "=", "deque", "(", "maxlen", "=", "source", ".", "max_occurs", ")", "for", "inpt", "in", "inputs", ":", "data_input", "=", "source", ".", "clone", "(", ")",...
https://github.com/geopython/pywps/blob/7f228ff17594912664073a629b2c2ed9d4f5f615/pywps/app/Service.py#L148-L185
topydo/topydo
57d7577c987515d4b49d5500f666da29080ca3c2
topydo/lib/TodoBase.py
python
TodoBase.source
(self)
return self.text(True)
Returns the source text of the todo. This is the raw text with all the tags included.
Returns the source text of the todo. This is the raw text with all the tags included.
[ "Returns", "the", "source", "text", "of", "the", "todo", ".", "This", "is", "the", "raw", "text", "with", "all", "the", "tags", "included", "." ]
def source(self): """ Returns the source text of the todo. This is the raw text with all the tags included. """ return self.text(True)
[ "def", "source", "(", "self", ")", ":", "return", "self", ".", "text", "(", "True", ")" ]
https://github.com/topydo/topydo/blob/57d7577c987515d4b49d5500f666da29080ca3c2/topydo/lib/TodoBase.py#L170-L175
DataDog/integrations-core
934674b29d94b70ccc008f76ea172d0cdae05e1e
couch/datadog_checks/couch/config_models/defaults.py
python
instance_auth_token
(field, value)
return get_default_field_value(field, value)
[]
def instance_auth_token(field, value): return get_default_field_value(field, value)
[ "def", "instance_auth_token", "(", "field", ",", "value", ")", ":", "return", "get_default_field_value", "(", "field", ",", "value", ")" ]
https://github.com/DataDog/integrations-core/blob/934674b29d94b70ccc008f76ea172d0cdae05e1e/couch/datadog_checks/couch/config_models/defaults.py#L33-L34
awslabs/autogluon
7309118f2ab1c9519f25acf61a283a95af95842b
tabular/src/autogluon/tabular/models/rf/rf_model.py
python
RFModel._fit
(self, X, y, num_cpus=-1, time_limit=None, sample_weight=None, **kwargs)
[]
def _fit(self, X, y, num_cpus=-1, time_limit=None, sample_weight=None, **kwargs): time_start = time.time() model_cls = self._get_model_type() max_memory_usage_ratio = self.params_aux['max_memory_usage_ratio'] self._set_cpu_params(num_cpus) params = self._get_model_params() n_estimators_final = params['n_estimators'] n_estimators_minimum = min(40, n_estimators_final) n_estimators_test = min(4, max(1, math.floor(n_estimators_minimum/5))) X = self.preprocess(X) n_estimator_increments = [n_estimators_final] num_trees_per_estimator = self._get_num_trees_per_estimator() bytes_per_estimator = num_trees_per_estimator * len(X) / 60000 * 1e6 # Underestimates by 3x on ExtraTrees available_mem = psutil.virtual_memory().available expected_memory_usage = n_estimators_final * bytes_per_estimator / available_mem if n_estimators_final > n_estimators_test * 2: if self.problem_type == MULTICLASS: n_estimator_increments = [n_estimators_test, n_estimators_final] params['warm_start'] = True else: if expected_memory_usage > (0.05 * max_memory_usage_ratio): # Somewhat arbitrary, consider finding a better value, should it scale by cores? # Causes ~10% training slowdown, so try to avoid if memory is not an issue n_estimator_increments = [n_estimators_test, n_estimators_final] params['warm_start'] = True params['n_estimators'] = n_estimator_increments[0] if self._daal: if params.get('warm_start', False): params['warm_start'] = False model = model_cls(**params) time_train_start = time.time() for i, n_estimators in enumerate(n_estimator_increments): if i != 0: if params.get('warm_start', False): model.n_estimators = n_estimators else: params['n_estimators'] = n_estimators model = model_cls(**params) model = model.fit(X, y, sample_weight=sample_weight) if (i == 0) and (len(n_estimator_increments) > 1): time_elapsed = time.time() - time_train_start model_size_bytes = 0 for estimator in model.estimators_: # Uses far less memory than pickling the entire forest at once model_size_bytes += sys.getsizeof(pickle.dumps(estimator)) expected_final_model_size_bytes = model_size_bytes * (n_estimators_final / model.n_estimators) available_mem = psutil.virtual_memory().available model_memory_ratio = expected_final_model_size_bytes / available_mem ideal_memory_ratio = 0.15 * max_memory_usage_ratio n_estimators_ideal = min(n_estimators_final, math.floor(ideal_memory_ratio / model_memory_ratio * n_estimators_final)) if n_estimators_final > n_estimators_ideal: if n_estimators_ideal < n_estimators_minimum: logger.warning(f'\tWarning: Model is expected to require {round(model_memory_ratio*100, 2)}% of available memory...') raise NotEnoughMemoryError # don't train full model to avoid OOM error logger.warning(f'\tWarning: Reducing model \'n_estimators\' from {n_estimators_final} -> {n_estimators_ideal} due to low memory. Expected memory usage reduced from {round(model_memory_ratio*100, 2)}% -> {round(ideal_memory_ratio*100, 2)}% of available memory...') if time_limit is not None: time_expected = time_train_start - time_start + (time_elapsed * n_estimators_ideal / n_estimators) n_estimators_time = math.floor((time_limit - time_train_start + time_start) * n_estimators / time_elapsed) if n_estimators_time < n_estimators_ideal: if n_estimators_time < n_estimators_minimum: logger.warning(f'\tWarning: Model is expected to require {round(time_expected, 1)}s to train, which exceeds the maximum time limit of {round(time_limit, 1)}s, skipping model...') raise TimeLimitExceeded logger.warning(f'\tWarning: Reducing model \'n_estimators\' from {n_estimators_ideal} -> {n_estimators_time} due to low time. Expected time usage reduced from {round(time_expected, 1)}s -> {round(time_limit, 1)}s...') n_estimators_ideal = n_estimators_time for j in range(len(n_estimator_increments)): if n_estimator_increments[j] > n_estimators_ideal: n_estimator_increments[j] = n_estimators_ideal self.model = model self.params_trained['n_estimators'] = self.model.n_estimators
[ "def", "_fit", "(", "self", ",", "X", ",", "y", ",", "num_cpus", "=", "-", "1", ",", "time_limit", "=", "None", ",", "sample_weight", "=", "None", ",", "*", "*", "kwargs", ")", ":", "time_start", "=", "time", ".", "time", "(", ")", "model_cls", "...
https://github.com/awslabs/autogluon/blob/7309118f2ab1c9519f25acf61a283a95af95842b/tabular/src/autogluon/tabular/models/rf/rf_model.py#L121-L207
petercorke/robotics-toolbox-python
51aa8bbb3663a7c815f9880d538d61e7c85bc470
roboticstoolbox/tools/urdf/urdf.py
python
URDFType._parse_simple_attribs
(cls, node)
return kwargs
Parse all attributes in the _ATTRIBS array for this class. Parameters ---------- node : :class:`lxml.etree.Element` The node to parse attributes for. Returns ------- kwargs : dict Map from attribute name to value. If the attribute is not required and is not present, that attribute's name will map to ``None``.
Parse all attributes in the _ATTRIBS array for this class. Parameters ---------- node : :class:`lxml.etree.Element` The node to parse attributes for. Returns ------- kwargs : dict Map from attribute name to value. If the attribute is not required and is not present, that attribute's name will map to ``None``.
[ "Parse", "all", "attributes", "in", "the", "_ATTRIBS", "array", "for", "this", "class", ".", "Parameters", "----------", "node", ":", ":", "class", ":", "lxml", ".", "etree", ".", "Element", "The", "node", "to", "parse", "attributes", "for", ".", "Returns"...
def _parse_simple_attribs(cls, node): """Parse all attributes in the _ATTRIBS array for this class. Parameters ---------- node : :class:`lxml.etree.Element` The node to parse attributes for. Returns ------- kwargs : dict Map from attribute name to value. If the attribute is not required and is not present, that attribute's name will map to ``None``. """ kwargs = {} for a in cls._ATTRIBS: t, r = cls._ATTRIBS[a] # t = type, r = required (bool) if r: try: v = cls._parse_attrib(t, node.attrib[a]) except Exception: # pragma nocover raise ValueError( "Missing required attribute {} when parsing an object " "of type {}".format(a, cls.__name__) ) else: v = None if a in node.attrib: v = cls._parse_attrib(t, node.attrib[a]) kwargs[a] = v return kwargs
[ "def", "_parse_simple_attribs", "(", "cls", ",", "node", ")", ":", "kwargs", "=", "{", "}", "for", "a", "in", "cls", ".", "_ATTRIBS", ":", "t", ",", "r", "=", "cls", ".", "_ATTRIBS", "[", "a", "]", "# t = type, r = required (bool)", "if", "r", ":", "...
https://github.com/petercorke/robotics-toolbox-python/blob/51aa8bbb3663a7c815f9880d538d61e7c85bc470/roboticstoolbox/tools/urdf/urdf.py#L69-L98
spotify/luigi
c3b66f4a5fa7eaa52f9a72eb6704b1049035c789
luigi/task.py
python
Task.process_resources
(self)
return self.resources
Override in "template" tasks which provide common resource functionality but allow subclasses to specify additional resources while preserving the name for consistent end-user experience.
Override in "template" tasks which provide common resource functionality but allow subclasses to specify additional resources while preserving the name for consistent end-user experience.
[ "Override", "in", "template", "tasks", "which", "provide", "common", "resource", "functionality", "but", "allow", "subclasses", "to", "specify", "additional", "resources", "while", "preserving", "the", "name", "for", "consistent", "end", "-", "user", "experience", ...
def process_resources(self): """ Override in "template" tasks which provide common resource functionality but allow subclasses to specify additional resources while preserving the name for consistent end-user experience. """ return self.resources
[ "def", "process_resources", "(", "self", ")", ":", "return", "self", ".", "resources" ]
https://github.com/spotify/luigi/blob/c3b66f4a5fa7eaa52f9a72eb6704b1049035c789/luigi/task.py#L631-L637
smart-mobile-software/gitstack
d9fee8f414f202143eb6e620529e8e5539a2af56
python/Lib/lib-tk/ttk.py
python
Treeview.detach
(self, *items)
Unlinks all of the specified items from the tree. The items and all of their descendants are still present, and may be reinserted at another point in the tree, but will not be displayed. The root item may not be detached.
Unlinks all of the specified items from the tree.
[ "Unlinks", "all", "of", "the", "specified", "items", "from", "the", "tree", "." ]
def detach(self, *items): """Unlinks all of the specified items from the tree. The items and all of their descendants are still present, and may be reinserted at another point in the tree, but will not be displayed. The root item may not be detached.""" self.tk.call(self._w, "detach", items)
[ "def", "detach", "(", "self", ",", "*", "items", ")", ":", "self", ".", "tk", ".", "call", "(", "self", ".", "_w", ",", "\"detach\"", ",", "items", ")" ]
https://github.com/smart-mobile-software/gitstack/blob/d9fee8f414f202143eb6e620529e8e5539a2af56/python/Lib/lib-tk/ttk.py#L1246-L1252
ArangoDB-Community/python-arango
77cbc6813b75daa1a6e232e2327259e56b0228ca
arango/formatter.py
python
format_replication_applier_config
(body: Json)
return verify_format(body, result)
Format replication applier configuration data. :param body: Input body. :type body: dict :return: Formatted body. :rtype: dict
Format replication applier configuration data.
[ "Format", "replication", "applier", "configuration", "data", "." ]
def format_replication_applier_config(body: Json) -> Json: """Format replication applier configuration data. :param body: Input body. :type body: dict :return: Formatted body. :rtype: dict """ result: Json = {} if "endpoint" in body: result["endpoint"] = body["endpoint"] if "database" in body: result["database"] = body["database"] if "username" in body: result["username"] = body["username"] if "verbose" in body: result["verbose"] = body["verbose"] if "incremental" in body: result["incremental"] = body["incremental"] if "requestTimeout" in body: result["request_timeout"] = body["requestTimeout"] if "connectTimeout" in body: result["connect_timeout"] = body["connectTimeout"] if "ignoreErrors" in body: result["ignore_errors"] = body["ignoreErrors"] if "maxConnectRetries" in body: result["max_connect_retries"] = body["maxConnectRetries"] if "lockTimeoutRetries" in body: result["lock_timeout_retries"] = body["lockTimeoutRetries"] if "sslProtocol" in body: result["ssl_protocol"] = body["sslProtocol"] if "chunkSize" in body: result["chunk_size"] = body["chunkSize"] if "skipCreateDrop" in body: result["skip_create_drop"] = body["skipCreateDrop"] if "autoStart" in body: result["auto_start"] = body["autoStart"] if "adaptivePolling" in body: result["adaptive_polling"] = body["adaptivePolling"] if "autoResync" in body: result["auto_resync"] = body["autoResync"] if "autoResyncRetries" in body: result["auto_resync_retries"] = body["autoResyncRetries"] if "maxPacketSize" in body: result["max_packet_size"] = body["maxPacketSize"] if "includeSystem" in body: result["include_system"] = body["includeSystem"] if "includeFoxxQueues" in body: result["include_foxx_queues"] = body["includeFoxxQueues"] if "requireFromPresent" in body: result["require_from_present"] = body["requireFromPresent"] if "restrictType" in body: result["restrict_type"] = body["restrictType"] if "restrictCollections" in body: result["restrict_collections"] = body["restrictCollections"] if "connectionRetryWaitTime" in body: result["connection_retry_wait_time"] = body["connectionRetryWaitTime"] if "initialSyncMaxWaitTime" in body: result["initial_sync_max_wait_time"] = body["initialSyncMaxWaitTime"] if "idleMinWaitTime" in body: result["idle_min_wait_time"] = body["idleMinWaitTime"] if "idleMaxWaitTime" in body: result["idle_max_wait_time"] = body["idleMaxWaitTime"] return verify_format(body, result)
[ "def", "format_replication_applier_config", "(", "body", ":", "Json", ")", "->", "Json", ":", "result", ":", "Json", "=", "{", "}", "if", "\"endpoint\"", "in", "body", ":", "result", "[", "\"endpoint\"", "]", "=", "body", "[", "\"endpoint\"", "]", "if", ...
https://github.com/ArangoDB-Community/python-arango/blob/77cbc6813b75daa1a6e232e2327259e56b0228ca/arango/formatter.py#L405-L469
openstack/manila
142990edc027e14839d5deaf4954dd6fc88de15e
manila/api/views/share_groups.py
python
ShareGroupViewBuilder.summary
(self, request, share_group)
return { 'share_group': { 'id': share_group.get('id'), 'name': share_group.get('name'), 'links': self._get_links(request, share_group['id']) } }
Generic, non-detailed view of a share group.
Generic, non-detailed view of a share group.
[ "Generic", "non", "-", "detailed", "view", "of", "a", "share", "group", "." ]
def summary(self, request, share_group): """Generic, non-detailed view of a share group.""" return { 'share_group': { 'id': share_group.get('id'), 'name': share_group.get('name'), 'links': self._get_links(request, share_group['id']) } }
[ "def", "summary", "(", "self", ",", "request", ",", "share_group", ")", ":", "return", "{", "'share_group'", ":", "{", "'id'", ":", "share_group", ".", "get", "(", "'id'", ")", ",", "'name'", ":", "share_group", ".", "get", "(", "'name'", ")", ",", "...
https://github.com/openstack/manila/blob/142990edc027e14839d5deaf4954dd6fc88de15e/manila/api/views/share_groups.py#L35-L43
9miao/G-Firefly
8fbeeb3ef9782600560be48228c91cfb8f5ff87d
gfirefly/gfirefly/utils/services.py
python
CommandService.unMapTarget
(self, target)
Remove a target from the service.
Remove a target from the service.
[ "Remove", "a", "target", "from", "the", "service", "." ]
def unMapTarget(self, target): """Remove a target from the service. """ key = int((target.__name__).split('_')[-1]) if key in self._targets: del self._targets[key]
[ "def", "unMapTarget", "(", "self", ",", "target", ")", ":", "key", "=", "int", "(", "(", "target", ".", "__name__", ")", ".", "split", "(", "'_'", ")", "[", "-", "1", "]", ")", "if", "key", "in", "self", ".", "_targets", ":", "del", "self", "."...
https://github.com/9miao/G-Firefly/blob/8fbeeb3ef9782600560be48228c91cfb8f5ff87d/gfirefly/gfirefly/utils/services.py#L85-L90
xMistt/fortnitepy-bot
407a4fa9cf37e61533054389dea355335bcdb2a7
partybot/party.py
python
PartyCommands.bp
(self, ctx: fortnitepy.ext.commands.Context, tier: int)
[]
async def bp(self, ctx: fortnitepy.ext.commands.Context, tier: int) -> None: await self.bot.party.me.set_battlepass_info( has_purchased=True, level=tier, ) await ctx.send(f'Set battle pass tier to {tier}.')
[ "async", "def", "bp", "(", "self", ",", "ctx", ":", "fortnitepy", ".", "ext", ".", "commands", ".", "Context", ",", "tier", ":", "int", ")", "->", "None", ":", "await", "self", ".", "bot", ".", "party", ".", "me", ".", "set_battlepass_info", "(", "...
https://github.com/xMistt/fortnitepy-bot/blob/407a4fa9cf37e61533054389dea355335bcdb2a7/partybot/party.py#L114-L120
accel-brain/accel-brain-code
86f489dc9be001a3bae6d053f48d6b57c0bedb95
Accel-Brain-Base/accelbrainbase/observabledata/_mxnet/transformermodel/transformer_encoder.py
python
TransformerEncoder.hybrid_forward
(self, F, x, m=None)
return self.forward_propagation(F, x, m)
Hybrid forward with Gluon API. Args: F: `mxnet.ndarray` or `mxnet.symbol`. x: `mxnet.ndarray` of observed data points. m: `mxnet.ndarray` of self-attention masks. Returns: `mxnet.ndarray` or `mxnet.symbol` of inferenced feature points.
Hybrid forward with Gluon API.
[ "Hybrid", "forward", "with", "Gluon", "API", "." ]
def hybrid_forward(self, F, x, m=None): ''' Hybrid forward with Gluon API. Args: F: `mxnet.ndarray` or `mxnet.symbol`. x: `mxnet.ndarray` of observed data points. m: `mxnet.ndarray` of self-attention masks. Returns: `mxnet.ndarray` or `mxnet.symbol` of inferenced feature points. ''' # rank-3 return self.forward_propagation(F, x, m)
[ "def", "hybrid_forward", "(", "self", ",", "F", ",", "x", ",", "m", "=", "None", ")", ":", "# rank-3", "return", "self", ".", "forward_propagation", "(", "F", ",", "x", ",", "m", ")" ]
https://github.com/accel-brain/accel-brain-code/blob/86f489dc9be001a3bae6d053f48d6b57c0bedb95/Accel-Brain-Base/accelbrainbase/observabledata/_mxnet/transformermodel/transformer_encoder.py#L290-L303
nlloyd/SubliminalCollaborator
5c619e17ddbe8acb9eea8996ec038169ddcd50a1
libs/twisted/words/xish/domish.py
python
Element.__str__
(self)
return ""
Retrieve the first CData (content) node
Retrieve the first CData (content) node
[ "Retrieve", "the", "first", "CData", "(", "content", ")", "node" ]
def __str__(self): """ Retrieve the first CData (content) node """ for n in self.children: if isinstance(n, types.StringTypes): return n return ""
[ "def", "__str__", "(", "self", ")", ":", "for", "n", "in", "self", ".", "children", ":", "if", "isinstance", "(", "n", ",", "types", ".", "StringTypes", ")", ":", "return", "n", "return", "\"\"" ]
https://github.com/nlloyd/SubliminalCollaborator/blob/5c619e17ddbe8acb9eea8996ec038169ddcd50a1/libs/twisted/words/xish/domish.py#L434-L439
rowliny/DiffHelper
ab3a96f58f9579d0023aed9ebd785f4edf26f8af
Tool/SitePackages/nltk/draw/util.py
python
CanvasWidget.hidden
(self)
return self.__hidden
:return: True if this canvas widget is hidden. :rtype: bool
:return: True if this canvas widget is hidden. :rtype: bool
[ ":", "return", ":", "True", "if", "this", "canvas", "widget", "is", "hidden", ".", ":", "rtype", ":", "bool" ]
def hidden(self): """ :return: True if this canvas widget is hidden. :rtype: bool """ return self.__hidden
[ "def", "hidden", "(", "self", ")", ":", "return", "self", ".", "__hidden" ]
https://github.com/rowliny/DiffHelper/blob/ab3a96f58f9579d0023aed9ebd785f4edf26f8af/Tool/SitePackages/nltk/draw/util.py#L480-L485
Cisco-Talos/BASS
6dd8b7aa4b13ddcd48f0c8fbd64ac43955157420
funcdb/server.py
python
_function_count_transitions
(func)
return sum(1 for bb in func.basic_blocks for _ in bb.successors)
Count the number of transitions between basic blocks in a function
Count the number of transitions between basic blocks in a function
[ "Count", "the", "number", "of", "transitions", "between", "basic", "blocks", "in", "a", "function" ]
def _function_count_transitions(func): """Count the number of transitions between basic blocks in a function""" return sum(1 for bb in func.basic_blocks for _ in bb.successors)
[ "def", "_function_count_transitions", "(", "func", ")", ":", "return", "sum", "(", "1", "for", "bb", "in", "func", ".", "basic_blocks", "for", "_", "in", "bb", ".", "successors", ")" ]
https://github.com/Cisco-Talos/BASS/blob/6dd8b7aa4b13ddcd48f0c8fbd64ac43955157420/funcdb/server.py#L97-L99