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
bbfamily/abu
2de85ae57923a720dac99a545b4f856f6b87304b
abupy/UtilBu/ABuProgress.py
python
AbuProgress.show
(self, a_progress=None, ext='', p_format="{}:{}:{}%")
进行进度控制显示主方法 :param ext: 可以添加额外的显示文字,str,默认空字符串 :param a_progress: 默认None, 即使用类内部计算的迭代次数进行进度显示 :param p_format: 进度显示格式,默认{}: {}%,即'self._label:round(self._progress / self._total * 100, 2))%'
进行进度控制显示主方法 :param ext: 可以添加额外的显示文字,str,默认空字符串 :param a_progress: 默认None, 即使用类内部计算的迭代次数进行进度显示 :param p_format: 进度显示格式,默认{}: {}%,即'self._label:round(self._progress / self._total * 100, 2))%'
[ "进行进度控制显示主方法", ":", "param", "ext", ":", "可以添加额外的显示文字,str,默认空字符串", ":", "param", "a_progress", ":", "默认None", "即使用类内部计算的迭代次数进行进度显示", ":", "param", "p_format", ":", "进度显示格式,默认", "{}", ":", "{}", "%,即", "self", ".", "_label", ":", "round", "(", "self", ".", "_...
def show(self, a_progress=None, ext='', p_format="{}:{}:{}%"): """ 进行进度控制显示主方法 :param ext: 可以添加额外的显示文字,str,默认空字符串 :param a_progress: 默认None, 即使用类内部计算的迭代次数进行进度显示 :param p_format: 进度显示格式,默认{}: {}%,即'self._label:round(self._progress / self._total * 100, 2))%' """ self.progress = a_progress if a_progress is not None else self.progress + 1 ps = round(self._progress / self._total * 100, 2) if self._label is not None: # 如果初始化label没有就只显示ui进度 self.f.write('\r') self.f.write(p_format.format(self._label, ext, ps)) if ABuEnv.g_is_ipython: if self.progress_widget is None: self.progress_widget = FloatProgress(value=0, min=0, max=100) display(self.progress_widget) self.progress_widget.value = ps # 这样会出现余数结束的情况,还是尽量使用上下文管理器控制结束 if self._progress == self._total: self.f.write('\r') if self.progress_widget is not None: self.progress_widget.close()
[ "def", "show", "(", "self", ",", "a_progress", "=", "None", ",", "ext", "=", "''", ",", "p_format", "=", "\"{}:{}:{}%\"", ")", ":", "self", ".", "progress", "=", "a_progress", "if", "a_progress", "is", "not", "None", "else", "self", ".", "progress", "+...
https://github.com/bbfamily/abu/blob/2de85ae57923a720dac99a545b4f856f6b87304b/abupy/UtilBu/ABuProgress.py#L412-L437
determined-ai/determined
f637264493acc14f12e66550cb51c520b5d27f6c
examples/features/data_layer_mnist_estimator/util.py
python
download_data
(download_directory)
return data_dir
Return the path of a directory with the MNIST dataset in TFRecord format. The dataset will be downloaded into download_directory, if it is not already present.
Return the path of a directory with the MNIST dataset in TFRecord format. The dataset will be downloaded into download_directory, if it is not already present.
[ "Return", "the", "path", "of", "a", "directory", "with", "the", "MNIST", "dataset", "in", "TFRecord", "format", ".", "The", "dataset", "will", "be", "downloaded", "into", "download_directory", "if", "it", "is", "not", "already", "present", "." ]
def download_data(download_directory) -> str: """ Return the path of a directory with the MNIST dataset in TFRecord format. The dataset will be downloaded into download_directory, if it is not already present. """ if not tf.io.gfile.exists(download_directory): tf.io.gfile.makedirs(download_directory) filepath = os.path.join(download_directory, MNIST_TF_RECORDS_FILE) if not tf.io.gfile.exists(filepath): logging.info("Downloading {}".format(MNIST_TF_RECORDS_URL)) r = requests.get(MNIST_TF_RECORDS_URL) with tf.io.gfile.GFile(filepath, "wb") as f: f.write(r.content) logging.info("Downloaded {} ({} bytes)".format(MNIST_TF_RECORDS_FILE, f.size())) logging.info("Extracting {} to {}".format(MNIST_TF_RECORDS_FILE, download_directory)) with tarfile.open(filepath, mode="r:gz") as f: f.extractall(path=download_directory) data_dir = os.path.join(download_directory, "mnist-tfrecord") assert tf.io.gfile.exists(data_dir) return data_dir
[ "def", "download_data", "(", "download_directory", ")", "->", "str", ":", "if", "not", "tf", ".", "io", ".", "gfile", ".", "exists", "(", "download_directory", ")", ":", "tf", ".", "io", ".", "gfile", ".", "makedirs", "(", "download_directory", ")", "fil...
https://github.com/determined-ai/determined/blob/f637264493acc14f12e66550cb51c520b5d27f6c/examples/features/data_layer_mnist_estimator/util.py#L14-L38
dimagi/commcare-hq
d67ff1d3b4c51fa050c19e60c3253a79d3452a39
corehq/apps/hqwebapp/templatetags/hq_shared_tags.py
python
BOOL
(obj)
return 'true' if obj else 'false'
[]
def BOOL(obj): try: obj = obj.to_json() except AttributeError: pass return 'true' if obj else 'false'
[ "def", "BOOL", "(", "obj", ")", ":", "try", ":", "obj", "=", "obj", ".", "to_json", "(", ")", "except", "AttributeError", ":", "pass", "return", "'true'", "if", "obj", "else", "'false'" ]
https://github.com/dimagi/commcare-hq/blob/d67ff1d3b4c51fa050c19e60c3253a79d3452a39/corehq/apps/hqwebapp/templatetags/hq_shared_tags.py#L58-L64
tribe29/checkmk
6260f2512e159e311f426e16b84b19d0b8e9ad0c
cmk/gui/views/__init__.py
python
View.breadcrumb
(self)
return self._host_hierarchy_breadcrumb()
Render the breadcrumb for the current view In case of views we not only have a hierarchy of 1. main menu 2. main menu topic We also have a hierarchy between some of the views (see _host_hierarchy_breadcrumb). But this is not the case for all views. A lot of the views are direct children of the topic level.
Render the breadcrumb for the current view
[ "Render", "the", "breadcrumb", "for", "the", "current", "view" ]
def breadcrumb(self) -> Breadcrumb: """Render the breadcrumb for the current view In case of views we not only have a hierarchy of 1. main menu 2. main menu topic We also have a hierarchy between some of the views (see _host_hierarchy_breadcrumb). But this is not the case for all views. A lot of the views are direct children of the topic level. """ # View without special hierarchy if "host" not in self.spec["single_infos"] or "host" in self.missing_single_infos: request_vars: HTTPVariables = [("view_name", self.name)] request_vars += list( visuals.get_singlecontext_vars(self.context, self.spec["single_infos"]).items() ) breadcrumb = make_topic_breadcrumb( mega_menu_registry.menu_monitoring(), pagetypes.PagetypeTopics.get_topic(self.spec["topic"]), ) breadcrumb.append( BreadcrumbItem( title=view_title(self.spec, self.context), url=makeuri_contextless(request, request_vars), ) ) return breadcrumb # Now handle the views within the host view hierarchy return self._host_hierarchy_breadcrumb()
[ "def", "breadcrumb", "(", "self", ")", "->", "Breadcrumb", ":", "# View without special hierarchy", "if", "\"host\"", "not", "in", "self", ".", "spec", "[", "\"single_infos\"", "]", "or", "\"host\"", "in", "self", ".", "missing_single_infos", ":", "request_vars", ...
https://github.com/tribe29/checkmk/blob/6260f2512e159e311f426e16b84b19d0b8e9ad0c/cmk/gui/views/__init__.py#L568-L601
GaoQ1/rasa_nlu_gq
aea2d037220f022b2773d0852cbcfbad582e8e25
rasa_nlu_gao/models/bert/tokenization.py
python
_is_control
(char)
return False
Checks whether `chars` is a control character.
Checks whether `chars` is a control character.
[ "Checks", "whether", "chars", "is", "a", "control", "character", "." ]
def _is_control(char): """Checks whether `chars` is a control character.""" # These are technically control characters but we count them as whitespace # characters. if char == "\t" or char == "\n" or char == "\r": return False cat = unicodedata.category(char) if cat.startswith("C"): return True return False
[ "def", "_is_control", "(", "char", ")", ":", "# These are technically control characters but we count them as whitespace", "# characters.", "if", "char", "==", "\"\\t\"", "or", "char", "==", "\"\\n\"", "or", "char", "==", "\"\\r\"", ":", "return", "False", "cat", "=",...
https://github.com/GaoQ1/rasa_nlu_gq/blob/aea2d037220f022b2773d0852cbcfbad582e8e25/rasa_nlu_gao/models/bert/tokenization.py#L325-L334
SanPen/GridCal
d3f4566d2d72c11c7e910c9d162538ef0e60df31
src/research/power_flow/fubm/jacobian_based_acdc_power_flow.py
python
dSbus_dV_with_numba
(Ybus, V)
return sp.csc_matrix((dS_dVa, Ybus.indices, Ybus.indptr)), sp.csc_matrix((dS_dVm, Ybus.indices, Ybus.indptr))
Call the numba sparse constructor of the derivatives :param Ybus: Ybus in CSC format :param V: Voltages vector :return: dS_dVm, dS_dVa in CSC format
Call the numba sparse constructor of the derivatives :param Ybus: Ybus in CSC format :param V: Voltages vector :return: dS_dVm, dS_dVa in CSC format
[ "Call", "the", "numba", "sparse", "constructor", "of", "the", "derivatives", ":", "param", "Ybus", ":", "Ybus", "in", "CSC", "format", ":", "param", "V", ":", "Voltages", "vector", ":", "return", ":", "dS_dVm", "dS_dVa", "in", "CSC", "format" ]
def dSbus_dV_with_numba(Ybus, V): """ Call the numba sparse constructor of the derivatives :param Ybus: Ybus in CSC format :param V: Voltages vector :return: dS_dVm, dS_dVa in CSC format """ # compute the derivatives' data fast dS_dVm, dS_dVa = dSbus_dV_numba_sparse_csc(Ybus.data, Ybus.indptr, Ybus.indices, V) # generate sparse CSC matrices with computed data and return them return sp.csc_matrix((dS_dVa, Ybus.indices, Ybus.indptr)), sp.csc_matrix((dS_dVm, Ybus.indices, Ybus.indptr))
[ "def", "dSbus_dV_with_numba", "(", "Ybus", ",", "V", ")", ":", "# compute the derivatives' data fast", "dS_dVm", ",", "dS_dVa", "=", "dSbus_dV_numba_sparse_csc", "(", "Ybus", ".", "data", ",", "Ybus", ".", "indptr", ",", "Ybus", ".", "indices", ",", "V", ")", ...
https://github.com/SanPen/GridCal/blob/d3f4566d2d72c11c7e910c9d162538ef0e60df31/src/research/power_flow/fubm/jacobian_based_acdc_power_flow.py#L111-L122
mherrmann/selenium-python-helium
02f9a5a872871999d683c84461ac0d0b3e9da192
helium/__init__.py
python
doubleclick
(element)
:param element: The element or point to click. :type element: str, unicode, :py:class:`HTMLElement`, \ :py:class:`selenium.webdriver.remote.webelement.WebElement` or :py:class:`Point` Performs a double-click on the given element or point. For example:: doubleclick("Double click here") doubleclick(Image("Directories")) doubleclick(Point(200, 300)) doubleclick(TextField("Username").top_left - (0, 20))
:param element: The element or point to click. :type element: str, unicode, :py:class:`HTMLElement`, \ :py:class:`selenium.webdriver.remote.webelement.WebElement` or :py:class:`Point`
[ ":", "param", "element", ":", "The", "element", "or", "point", "to", "click", ".", ":", "type", "element", ":", "str", "unicode", ":", "py", ":", "class", ":", "HTMLElement", "\\", ":", "py", ":", "class", ":", "selenium", ".", "webdriver", ".", "rem...
def doubleclick(element): """ :param element: The element or point to click. :type element: str, unicode, :py:class:`HTMLElement`, \ :py:class:`selenium.webdriver.remote.webelement.WebElement` or :py:class:`Point` Performs a double-click on the given element or point. For example:: doubleclick("Double click here") doubleclick(Image("Directories")) doubleclick(Point(200, 300)) doubleclick(TextField("Username").top_left - (0, 20)) """ _get_api_impl().doubleclick_impl(element)
[ "def", "doubleclick", "(", "element", ")", ":", "_get_api_impl", "(", ")", ".", "doubleclick_impl", "(", "element", ")" ]
https://github.com/mherrmann/selenium-python-helium/blob/02f9a5a872871999d683c84461ac0d0b3e9da192/helium/__init__.py#L275-L288
buke/GreenOdoo
3d8c55d426fb41fdb3f2f5a1533cfe05983ba1df
runtime/python/lib/python2.7/site-packages/distribute-0.6.34-py2.7.egg/setuptools/command/build_py.py
python
build_py._get_data_files
(self)
return data
Generate list of '(package,src_dir,build_dir,filenames)' tuples
Generate list of '(package,src_dir,build_dir,filenames)' tuples
[ "Generate", "list", "of", "(", "package", "src_dir", "build_dir", "filenames", ")", "tuples" ]
def _get_data_files(self): """Generate list of '(package,src_dir,build_dir,filenames)' tuples""" self.analyze_manifest() data = [] for package in self.packages or (): # Locate package source directory src_dir = self.get_package_dir(package) # Compute package build directory build_dir = os.path.join(*([self.build_lib] + package.split('.'))) # Length of path to strip from found files plen = len(src_dir)+1 # Strip directory from globbed filenames filenames = [ file[plen:] for file in self.find_data_files(package, src_dir) ] data.append( (package, src_dir, build_dir, filenames) ) return data
[ "def", "_get_data_files", "(", "self", ")", ":", "self", ".", "analyze_manifest", "(", ")", "data", "=", "[", "]", "for", "package", "in", "self", ".", "packages", "or", "(", ")", ":", "# Locate package source directory", "src_dir", "=", "self", ".", "get_...
https://github.com/buke/GreenOdoo/blob/3d8c55d426fb41fdb3f2f5a1533cfe05983ba1df/runtime/python/lib/python2.7/site-packages/distribute-0.6.34-py2.7.egg/setuptools/command/build_py.py#L111-L130
CenterForOpenScience/osf.io
cc02691be017e61e2cd64f19b848b2f4c18dcc84
osf/models/user.py
python
OSFUser.update_is_active
(self)
Update ``is_active`` to be consistent with the fields that it depends on.
Update ``is_active`` to be consistent with the fields that it depends on.
[ "Update", "is_active", "to", "be", "consistent", "with", "the", "fields", "that", "it", "depends", "on", "." ]
def update_is_active(self): """Update ``is_active`` to be consistent with the fields that it depends on. """ # The user can log in if they have set a password OR # have a verified external ID, e.g an ORCID can_login = self.has_usable_password() or ( 'VERIFIED' in sum([list(each.values()) for each in self.external_identity.values()], []) ) self.is_active = ( self.is_registered and self.is_confirmed and can_login and not self.is_merged and not self.is_disabled )
[ "def", "update_is_active", "(", "self", ")", ":", "# The user can log in if they have set a password OR", "# have a verified external ID, e.g an ORCID", "can_login", "=", "self", ".", "has_usable_password", "(", ")", "or", "(", "'VERIFIED'", "in", "sum", "(", "[", "list",...
https://github.com/CenterForOpenScience/osf.io/blob/cc02691be017e61e2cd64f19b848b2f4c18dcc84/osf/models/user.py#L1018-L1033
grantjenks/free-python-games
3f27c6555e2c72a9b1c668c4dd8506d7b8378d09
freegames/cannon.py
python
inside
(xy)
return -200 < xy.x < 200 and -200 < xy.y < 200
Return True if xy within screen.
Return True if xy within screen.
[ "Return", "True", "if", "xy", "within", "screen", "." ]
def inside(xy): """Return True if xy within screen.""" return -200 < xy.x < 200 and -200 < xy.y < 200
[ "def", "inside", "(", "xy", ")", ":", "return", "-", "200", "<", "xy", ".", "x", "<", "200", "and", "-", "200", "<", "xy", ".", "y", "<", "200" ]
https://github.com/grantjenks/free-python-games/blob/3f27c6555e2c72a9b1c668c4dd8506d7b8378d09/freegames/cannon.py#L30-L32
YosaiProject/yosai
7f96aa6b837ceae9bf3d7387cd7e35f5ab032575
yosai/core/mgt/abcs.py
python
RememberMeManager.get_remembered_identifiers
(self, subject_context)
Based on the specified subject context map being used to build a Subject instance, returns any previously remembered identifier for the subject for automatic identity association (aka 'Remember Me'). The context map is usually populated by a Subject.Builder implementation. See the SubjectFactory class constants for Yosai's known map keys. :param subject_context: the contextual data, usually provided by a Builder implementation, that is being used to construct a Subject instance :returns: the remembered identifier or None if none could be acquired
Based on the specified subject context map being used to build a Subject instance, returns any previously remembered identifier for the subject for automatic identity association (aka 'Remember Me').
[ "Based", "on", "the", "specified", "subject", "context", "map", "being", "used", "to", "build", "a", "Subject", "instance", "returns", "any", "previously", "remembered", "identifier", "for", "the", "subject", "for", "automatic", "identity", "association", "(", "...
def get_remembered_identifiers(self, subject_context): """ Based on the specified subject context map being used to build a Subject instance, returns any previously remembered identifier for the subject for automatic identity association (aka 'Remember Me'). The context map is usually populated by a Subject.Builder implementation. See the SubjectFactory class constants for Yosai's known map keys. :param subject_context: the contextual data, usually provided by a Builder implementation, that is being used to construct a Subject instance :returns: the remembered identifier or None if none could be acquired """ pass
[ "def", "get_remembered_identifiers", "(", "self", ",", "subject_context", ")", ":", "pass" ]
https://github.com/YosaiProject/yosai/blob/7f96aa6b837ceae9bf3d7387cd7e35f5ab032575/yosai/core/mgt/abcs.py#L37-L53
openbmc/openbmc
5f4109adae05f4d6925bfe960007d52f98c61086
poky/bitbake/lib/bb/utils.py
python
environment
(**envvars)
Context manager to selectively update the environment with the specified mapping.
Context manager to selectively update the environment with the specified mapping.
[ "Context", "manager", "to", "selectively", "update", "the", "environment", "with", "the", "specified", "mapping", "." ]
def environment(**envvars): """ Context manager to selectively update the environment with the specified mapping. """ backup = dict(os.environ) try: os.environ.update(envvars) yield finally: for var in envvars: if var in backup: os.environ[var] = backup[var] else: del os.environ[var]
[ "def", "environment", "(", "*", "*", "envvars", ")", ":", "backup", "=", "dict", "(", "os", ".", "environ", ")", "try", ":", "os", ".", "environ", ".", "update", "(", "envvars", ")", "yield", "finally", ":", "for", "var", "in", "envvars", ":", "if"...
https://github.com/openbmc/openbmc/blob/5f4109adae05f4d6925bfe960007d52f98c61086/poky/bitbake/lib/bb/utils.py#L1686-L1699
pluralsight/guides-cms
9e73a6bbc0f0747a66c08346d94b380892a49012
pskb_website/models/file.py
python
_parse_stacks_line
(line)
return [_force_unicode(m.group()) for m in STACK_RE.finditer(line.lower())]
Parse list of stacks from line of text :param line: Line of text to parse :returns: List of stacks
Parse list of stacks from line of text
[ "Parse", "list", "of", "stacks", "from", "line", "of", "text" ]
def _parse_stacks_line(line): """ Parse list of stacks from line of text :param line: Line of text to parse :returns: List of stacks """ return [_force_unicode(m.group()) for m in STACK_RE.finditer(line.lower())]
[ "def", "_parse_stacks_line", "(", "line", ")", ":", "return", "[", "_force_unicode", "(", "m", ".", "group", "(", ")", ")", "for", "m", "in", "STACK_RE", ".", "finditer", "(", "line", ".", "lower", "(", ")", ")", "]" ]
https://github.com/pluralsight/guides-cms/blob/9e73a6bbc0f0747a66c08346d94b380892a49012/pskb_website/models/file.py#L582-L590
securesystemslab/zippy
ff0e84ac99442c2c55fe1d285332cfd4e185e089
zippy/benchmarks/src/benchmarks/whoosh/src/whoosh/sorting.py
python
OrderedList.__repr__
(self)
return "<%s %r>" % (self.__class__.__name__, self.dict)
[]
def __repr__(self): return "<%s %r>" % (self.__class__.__name__, self.dict)
[ "def", "__repr__", "(", "self", ")", ":", "return", "\"<%s %r>\"", "%", "(", "self", ".", "__class__", ".", "__name__", ",", "self", ".", "dict", ")" ]
https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/benchmarks/src/benchmarks/whoosh/src/whoosh/sorting.py#L1003-L1004
splunk/splunk-sdk-python
ef88e9d3e90ab9d6cf48cf940c7376400ed759b8
splunklib/client.py
python
Service.kvstore
(self)
return KVStoreCollections(self)
Returns the collection of KV Store collections. sets the owner for the namespace, before retrieving the KVStore Collection :return: A :class:`KVStoreCollections` collection of :class:`KVStoreCollection` entities.
Returns the collection of KV Store collections.
[ "Returns", "the", "collection", "of", "KV", "Store", "collections", "." ]
def kvstore(self): """Returns the collection of KV Store collections. sets the owner for the namespace, before retrieving the KVStore Collection :return: A :class:`KVStoreCollections` collection of :class:`KVStoreCollection` entities. """ self.namespace['owner'] = self.kvstore_owner return KVStoreCollections(self)
[ "def", "kvstore", "(", "self", ")", ":", "self", ".", "namespace", "[", "'owner'", "]", "=", "self", ".", "kvstore_owner", "return", "KVStoreCollections", "(", "self", ")" ]
https://github.com/splunk/splunk-sdk-python/blob/ef88e9d3e90ab9d6cf48cf940c7376400ed759b8/splunklib/client.py#L699-L707
spectacles/CodeComplice
8ca8ee4236f72b58caa4209d2fbd5fa56bd31d62
libs/codeintel2/tcl_parser.py
python
Parser._parse_name_list
(self)
return vars
[]
def _parse_name_list(self): vars = [] while True: tok = self.tokenizer.get_next_token() if tok['style'] == shared_lexer.EOF_STYLE or \ self.classifier.is_operator(tok, "}"): break if self.classifier.is_identifier(tok): vars.append(tok['text']) return vars
[ "def", "_parse_name_list", "(", "self", ")", ":", "vars", "=", "[", "]", "while", "True", ":", "tok", "=", "self", ".", "tokenizer", ".", "get_next_token", "(", ")", "if", "tok", "[", "'style'", "]", "==", "shared_lexer", ".", "EOF_STYLE", "or", "self"...
https://github.com/spectacles/CodeComplice/blob/8ca8ee4236f72b58caa4209d2fbd5fa56bd31d62/libs/codeintel2/tcl_parser.py#L237-L246
misterch0c/shadowbroker
e3a069bea47a2c1009697941ac214adc6f90aa8d
windows/Resources/Python/Core/Lib/wsgiref/util.py
python
shift_path_info
(environ)
Shift a name from PATH_INFO to SCRIPT_NAME, returning it If there are no remaining path segments in PATH_INFO, return None. Note: 'environ' is modified in-place; use a copy if you need to keep the original PATH_INFO or SCRIPT_NAME. Note: when PATH_INFO is just a '/', this returns '' and appends a trailing '/' to SCRIPT_NAME, even though empty path segments are normally ignored, and SCRIPT_NAME doesn't normally end in a '/'. This is intentional behavior, to ensure that an application can tell the difference between '/x' and '/x/' when traversing to objects.
Shift a name from PATH_INFO to SCRIPT_NAME, returning it If there are no remaining path segments in PATH_INFO, return None. Note: 'environ' is modified in-place; use a copy if you need to keep the original PATH_INFO or SCRIPT_NAME. Note: when PATH_INFO is just a '/', this returns '' and appends a trailing '/' to SCRIPT_NAME, even though empty path segments are normally ignored, and SCRIPT_NAME doesn't normally end in a '/'. This is intentional behavior, to ensure that an application can tell the difference between '/x' and '/x/' when traversing to objects.
[ "Shift", "a", "name", "from", "PATH_INFO", "to", "SCRIPT_NAME", "returning", "it", "If", "there", "are", "no", "remaining", "path", "segments", "in", "PATH_INFO", "return", "None", ".", "Note", ":", "environ", "is", "modified", "in", "-", "place", ";", "us...
def shift_path_info(environ): """Shift a name from PATH_INFO to SCRIPT_NAME, returning it If there are no remaining path segments in PATH_INFO, return None. Note: 'environ' is modified in-place; use a copy if you need to keep the original PATH_INFO or SCRIPT_NAME. Note: when PATH_INFO is just a '/', this returns '' and appends a trailing '/' to SCRIPT_NAME, even though empty path segments are normally ignored, and SCRIPT_NAME doesn't normally end in a '/'. This is intentional behavior, to ensure that an application can tell the difference between '/x' and '/x/' when traversing to objects. """ path_info = environ.get('PATH_INFO', '') if not path_info: return else: path_parts = path_info.split('/') path_parts[1:-1] = [ p for p in path_parts[1:-1] if p and p != '.' ] name = path_parts[1] del path_parts[1] script_name = environ.get('SCRIPT_NAME', '') script_name = posixpath.normpath(script_name + '/' + name) if script_name.endswith('/'): script_name = script_name[:-1] if not name and not script_name.endswith('/'): script_name += '/' environ['SCRIPT_NAME'] = script_name environ['PATH_INFO'] = '/'.join(path_parts) if name == '.': name = None return name
[ "def", "shift_path_info", "(", "environ", ")", ":", "path_info", "=", "environ", ".", "get", "(", "'PATH_INFO'", ",", "''", ")", "if", "not", "path_info", ":", "return", "else", ":", "path_parts", "=", "path_info", ".", "split", "(", "'/'", ")", "path_pa...
https://github.com/misterch0c/shadowbroker/blob/e3a069bea47a2c1009697941ac214adc6f90aa8d/windows/Resources/Python/Core/Lib/wsgiref/util.py#L77-L108
LGE-ARC-AdvancedAI/auptimizer
50f6e3b4e0cb9146ca90fd74b9b24ca97ae22617
src/aup/compression/torch/pruning/structured_pruning.py
python
StructuredWeightMasker.get_channel_sum
(self, wrapper, wrapper_idx)
Calculate the importance weight for each channel. If want to support the dependency-aware mode for this one-shot pruner, this function must be implemented. Parameters ---------- wrapper: PrunerModuleWrapper layer wrapper of this layer wrapper_idx: int index of this wrapper in pruner's all wrappers Returns ------- tensor Tensor that indicates the importance of each channel
Calculate the importance weight for each channel. If want to support the dependency-aware mode for this one-shot pruner, this function must be implemented. Parameters ---------- wrapper: PrunerModuleWrapper layer wrapper of this layer wrapper_idx: int index of this wrapper in pruner's all wrappers Returns ------- tensor Tensor that indicates the importance of each channel
[ "Calculate", "the", "importance", "weight", "for", "each", "channel", ".", "If", "want", "to", "support", "the", "dependency", "-", "aware", "mode", "for", "this", "one", "-", "shot", "pruner", "this", "function", "must", "be", "implemented", ".", "Parameter...
def get_channel_sum(self, wrapper, wrapper_idx): """ Calculate the importance weight for each channel. If want to support the dependency-aware mode for this one-shot pruner, this function must be implemented. Parameters ---------- wrapper: PrunerModuleWrapper layer wrapper of this layer wrapper_idx: int index of this wrapper in pruner's all wrappers Returns ------- tensor Tensor that indicates the importance of each channel """ raise NotImplementedError( '{} get_channel_sum is not implemented'.format(self.__class__.__name__))
[ "def", "get_channel_sum", "(", "self", ",", "wrapper", ",", "wrapper_idx", ")", ":", "raise", "NotImplementedError", "(", "'{} get_channel_sum is not implemented'", ".", "format", "(", "self", ".", "__class__", ".", "__name__", ")", ")" ]
https://github.com/LGE-ARC-AdvancedAI/auptimizer/blob/50f6e3b4e0cb9146ca90fd74b9b24ca97ae22617/src/aup/compression/torch/pruning/structured_pruning.py#L320-L337
apache/bloodhound
c3e31294e68af99d4e040e64fbdf52394344df9e
bloodhound_search/bhsearch/api.py
python
IQueryParser.parse
(query_string, context)
Parse query from string
Parse query from string
[ "Parse", "query", "from", "string" ]
def parse(query_string, context): """Parse query from string"""
[ "def", "parse", "(", "query_string", ",", "context", ")", ":" ]
https://github.com/apache/bloodhound/blob/c3e31294e68af99d4e040e64fbdf52394344df9e/bloodhound_search/bhsearch/api.py#L198-L199
naftaliharris/tauthon
5587ceec329b75f7caf6d65a036db61ac1bae214
Lib/lib-tk/turtle.py
python
TurtleScreen.window_height
(self)
return self._window_size()[1]
Return the height of the turtle window. Example (for a TurtleScreen instance named screen): >>> screen.window_height() 480
Return the height of the turtle window.
[ "Return", "the", "height", "of", "the", "turtle", "window", "." ]
def window_height(self): """ Return the height of the turtle window. Example (for a TurtleScreen instance named screen): >>> screen.window_height() 480 """ return self._window_size()[1]
[ "def", "window_height", "(", "self", ")", ":", "return", "self", ".", "_window_size", "(", ")", "[", "1", "]" ]
https://github.com/naftaliharris/tauthon/blob/5587ceec329b75f7caf6d65a036db61ac1bae214/Lib/lib-tk/turtle.py#L1265-L1272
microsoft/debugpy
be8dd607f6837244e0b565345e497aff7a0c08bf
src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/process.py
python
Process.get_mapped_filenames
(self, memoryMap = None)
return mappedFilenames
Retrieves the filenames for memory mapped files in the debugee. @type memoryMap: list( L{win32.MemoryBasicInformation} ) @param memoryMap: (Optional) Memory map returned by L{get_memory_map}. If not given, the current memory map is used. @rtype: dict( int S{->} str ) @return: Dictionary mapping memory addresses to file names. Native filenames are converted to Win32 filenames when possible.
Retrieves the filenames for memory mapped files in the debugee.
[ "Retrieves", "the", "filenames", "for", "memory", "mapped", "files", "in", "the", "debugee", "." ]
def get_mapped_filenames(self, memoryMap = None): """ Retrieves the filenames for memory mapped files in the debugee. @type memoryMap: list( L{win32.MemoryBasicInformation} ) @param memoryMap: (Optional) Memory map returned by L{get_memory_map}. If not given, the current memory map is used. @rtype: dict( int S{->} str ) @return: Dictionary mapping memory addresses to file names. Native filenames are converted to Win32 filenames when possible. """ hProcess = self.get_handle( win32.PROCESS_VM_READ | win32.PROCESS_QUERY_INFORMATION ) if not memoryMap: memoryMap = self.get_memory_map() mappedFilenames = dict() for mbi in memoryMap: if mbi.Type not in (win32.MEM_IMAGE, win32.MEM_MAPPED): continue baseAddress = mbi.BaseAddress fileName = "" try: fileName = win32.GetMappedFileName(hProcess, baseAddress) fileName = PathOperations.native_to_win32_pathname(fileName) except WindowsError: #e = sys.exc_info()[1] #try: # msg = "Can't get mapped file name at address %s in process " \ # "%d, reason: %s" % (HexDump.address(baseAddress), # self.get_pid(), # e.strerror) # warnings.warn(msg, Warning) #except Exception: pass mappedFilenames[baseAddress] = fileName return mappedFilenames
[ "def", "get_mapped_filenames", "(", "self", ",", "memoryMap", "=", "None", ")", ":", "hProcess", "=", "self", ".", "get_handle", "(", "win32", ".", "PROCESS_VM_READ", "|", "win32", ".", "PROCESS_QUERY_INFORMATION", ")", "if", "not", "memoryMap", ":", "memoryMa...
https://github.com/microsoft/debugpy/blob/be8dd607f6837244e0b565345e497aff7a0c08bf/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/process.py#L3105-L3141
getavalon/core
31e8cb4760e00e3db64443f6f932b7fd8e96d41d
avalon/vendor/requests/packages/urllib3/util/retry.py
python
Retry.is_retry
(self, method, status_code, has_retry_after=False)
return (self.total and self.respect_retry_after_header and has_retry_after and (status_code in self.RETRY_AFTER_STATUS_CODES))
Is this method/status code retryable? (Based on whitelists and control variables such as the number of total retries to allow, whether to respect the Retry-After header, whether this header is present, and whether the returned status code is on the list of status codes to be retried upon on the presence of the aforementioned header)
Is this method/status code retryable? (Based on whitelists and control variables such as the number of total retries to allow, whether to respect the Retry-After header, whether this header is present, and whether the returned status code is on the list of status codes to be retried upon on the presence of the aforementioned header)
[ "Is", "this", "method", "/", "status", "code", "retryable?", "(", "Based", "on", "whitelists", "and", "control", "variables", "such", "as", "the", "number", "of", "total", "retries", "to", "allow", "whether", "to", "respect", "the", "Retry", "-", "After", ...
def is_retry(self, method, status_code, has_retry_after=False): """ Is this method/status code retryable? (Based on whitelists and control variables such as the number of total retries to allow, whether to respect the Retry-After header, whether this header is present, and whether the returned status code is on the list of status codes to be retried upon on the presence of the aforementioned header) """ if not self._is_method_retryable(method): return False if self.status_forcelist and status_code in self.status_forcelist: return True return (self.total and self.respect_retry_after_header and has_retry_after and (status_code in self.RETRY_AFTER_STATUS_CODES))
[ "def", "is_retry", "(", "self", ",", "method", ",", "status_code", ",", "has_retry_after", "=", "False", ")", ":", "if", "not", "self", ".", "_is_method_retryable", "(", "method", ")", ":", "return", "False", "if", "self", ".", "status_forcelist", "and", "...
https://github.com/getavalon/core/blob/31e8cb4760e00e3db64443f6f932b7fd8e96d41d/avalon/vendor/requests/packages/urllib3/util/retry.py#L294-L308
NVIDIA/NeMo
5b0c0b4dec12d87d3cd960846de4105309ce938e
nemo/collections/asr/modules/conv_asr.py
python
ConvASRDecoderClassification.input_example
(self)
return tuple([input_example])
Generates input examples for tracing etc. Returns: A tuple of input examples.
Generates input examples for tracing etc. Returns: A tuple of input examples.
[ "Generates", "input", "examples", "for", "tracing", "etc", ".", "Returns", ":", "A", "tuple", "of", "input", "examples", "." ]
def input_example(self): """ Generates input examples for tracing etc. Returns: A tuple of input examples. """ input_example = torch.randn(16, self._feat_in, 128).to(next(self.parameters()).device) return tuple([input_example])
[ "def", "input_example", "(", "self", ")", ":", "input_example", "=", "torch", ".", "randn", "(", "16", ",", "self", ".", "_feat_in", ",", "128", ")", ".", "to", "(", "next", "(", "self", ".", "parameters", "(", ")", ")", ".", "device", ")", "return...
https://github.com/NVIDIA/NeMo/blob/5b0c0b4dec12d87d3cd960846de4105309ce938e/nemo/collections/asr/modules/conv_asr.py#L564-L571
xmindltd/xmind-sdk-python
58b2c7f1971abd941cd0f28e88388ec93ed2c53d
xmind/core/__init__.py
python
Document.documentElement
(self)
return self._node.documentElement
Get root element of passed DOM implementation for manipulate
Get root element of passed DOM implementation for manipulate
[ "Get", "root", "element", "of", "passed", "DOM", "implementation", "for", "manipulate" ]
def documentElement(self): """ Get root element of passed DOM implementation for manipulate """ return self._node.documentElement
[ "def", "documentElement", "(", "self", ")", ":", "return", "self", ".", "_node", ".", "documentElement" ]
https://github.com/xmindltd/xmind-sdk-python/blob/58b2c7f1971abd941cd0f28e88388ec93ed2c53d/xmind/core/__init__.py#L171-L175
TensorSpeech/TensorflowTTS
34358d82a4c91fd70344872f8ea8a405ea84aedb
tensorflow_tts/models/parallel_wavegan.py
python
TFResidualBlock.call
(self, x, c, training=False)
return x, s
Calculate forward propagation. Args: x (Tensor): Input tensor (B, residual_channels, T). c (Tensor): Local conditioning auxiliary tensor (B, aux_channels, T). Returns: Tensor: Output tensor for residual connection (B, T, residual_channels). Tensor: Output tensor for skip connection (B, T, skip_channels).
Calculate forward propagation.
[ "Calculate", "forward", "propagation", "." ]
def call(self, x, c, training=False): """Calculate forward propagation. Args: x (Tensor): Input tensor (B, residual_channels, T). c (Tensor): Local conditioning auxiliary tensor (B, aux_channels, T). Returns: Tensor: Output tensor for residual connection (B, T, residual_channels). Tensor: Output tensor for skip connection (B, T, skip_channels). """ residual = x x = self.dropout(x, training=training) x = self.conv(x) # split into two part for gated activation xa, xb = tf.split(x, 2, axis=-1) # local conditioning if c is not None: assert self.conv1x1_aux is not None c = self.conv1x1_aux(c) ca, cb = tf.split(c, 2, axis=-1) xa, xb = xa + ca, xb + cb x = tf.nn.tanh(xa) * tf.nn.sigmoid(xb) # for skip connection s = self.conv1x1_skip(x) # for residual connection x = self.conv1x1_out(x) x = (x + residual) * tf.math.sqrt(0.5) return x, s
[ "def", "call", "(", "self", ",", "x", ",", "c", ",", "training", "=", "False", ")", ":", "residual", "=", "x", "x", "=", "self", ".", "dropout", "(", "x", ",", "training", "=", "training", ")", "x", "=", "self", ".", "conv", "(", "x", ")", "#...
https://github.com/TensorSpeech/TensorflowTTS/blob/34358d82a4c91fd70344872f8ea8a405ea84aedb/tensorflow_tts/models/parallel_wavegan.py#L138-L172
trakt/Plex-Trakt-Scrobbler
aeb0bfbe62fad4b06c164f1b95581da7f35dce0b
Trakttv.bundle/Contents/Libraries/Shared/sortedcontainers/sortedset.py
python
SortedSet.discard
(self, value)
Remove the first occurrence of *value*. If *value* is not a member, does nothing.
Remove the first occurrence of *value*. If *value* is not a member, does nothing.
[ "Remove", "the", "first", "occurrence", "of", "*", "value", "*", ".", "If", "*", "value", "*", "is", "not", "a", "member", "does", "nothing", "." ]
def discard(self, value): """ Remove the first occurrence of *value*. If *value* is not a member, does nothing. """ _set = self._set if value in _set: _set.remove(value) self._list.discard(value)
[ "def", "discard", "(", "self", ",", "value", ")", ":", "_set", "=", "self", ".", "_set", "if", "value", "in", "_set", ":", "_set", ".", "remove", "(", "value", ")", "self", ".", "_list", ".", "discard", "(", "value", ")" ]
https://github.com/trakt/Plex-Trakt-Scrobbler/blob/aeb0bfbe62fad4b06c164f1b95581da7f35dce0b/Trakttv.bundle/Contents/Libraries/Shared/sortedcontainers/sortedset.py#L172-L180
NoGameNoLife00/mybolg
afe17ea5bfe405e33766e5682c43a4262232ee12
libs/jinja2/filters.py
python
do_list
(value)
return list(value)
Convert the value into a list. If it was a string the returned list will be a list of characters.
Convert the value into a list. If it was a string the returned list will be a list of characters.
[ "Convert", "the", "value", "into", "a", "list", ".", "If", "it", "was", "a", "string", "the", "returned", "list", "will", "be", "a", "list", "of", "characters", "." ]
def do_list(value): """Convert the value into a list. If it was a string the returned list will be a list of characters. """ return list(value)
[ "def", "do_list", "(", "value", ")", ":", "return", "list", "(", "value", ")" ]
https://github.com/NoGameNoLife00/mybolg/blob/afe17ea5bfe405e33766e5682c43a4262232ee12/libs/jinja2/filters.py#L736-L740
spesmilo/electrum
bdbd59300fbd35b01605e66145458e5f396108e8
electrum/util.py
python
random_shuffled_copy
(x: Iterable[T])
return x_copy
Returns a shuffled copy of the input.
Returns a shuffled copy of the input.
[ "Returns", "a", "shuffled", "copy", "of", "the", "input", "." ]
def random_shuffled_copy(x: Iterable[T]) -> List[T]: """Returns a shuffled copy of the input.""" x_copy = list(x) # copy random.shuffle(x_copy) # shuffle in-place return x_copy
[ "def", "random_shuffled_copy", "(", "x", ":", "Iterable", "[", "T", "]", ")", "->", "List", "[", "T", "]", ":", "x_copy", "=", "list", "(", "x", ")", "# copy", "random", ".", "shuffle", "(", "x_copy", ")", "# shuffle in-place", "return", "x_copy" ]
https://github.com/spesmilo/electrum/blob/bdbd59300fbd35b01605e66145458e5f396108e8/electrum/util.py#L1623-L1627
burness/tensorflow-101
c775a54af86542940e6e69b7d90d8d7e8aa9aeb9
finetuning/deployment/model_deploy.py
python
DeploymentConfig.clone_scope
(self, clone_index)
return scope
Name scope to create the clone. Args: clone_index: Int, representing the clone_index. Returns: A name_scope suitable for `tf.name_scope()`. Raises: ValueError: if `clone_index` is greater or equal to the number of clones".
Name scope to create the clone.
[ "Name", "scope", "to", "create", "the", "clone", "." ]
def clone_scope(self, clone_index): """Name scope to create the clone. Args: clone_index: Int, representing the clone_index. Returns: A name_scope suitable for `tf.name_scope()`. Raises: ValueError: if `clone_index` is greater or equal to the number of clones". """ if clone_index >= self._num_clones: raise ValueError('clone_index must be less than num_clones') scope = '' if self._num_clones > 1: scope = 'clone_%d' % clone_index return scope
[ "def", "clone_scope", "(", "self", ",", "clone_index", ")", ":", "if", "clone_index", ">=", "self", ".", "_num_clones", ":", "raise", "ValueError", "(", "'clone_index must be less than num_clones'", ")", "scope", "=", "''", "if", "self", ".", "_num_clones", ">",...
https://github.com/burness/tensorflow-101/blob/c775a54af86542940e6e69b7d90d8d7e8aa9aeb9/finetuning/deployment/model_deploy.py#L645-L662
bitcoin-core/HWI
6871946c2176f2f9777b6ac8f0614d96d99bfa0e
hwilib/devices/ckcc/client.py
python
UnixSimulatorPipe.write
(self, buf)
return 65 if rv == 64 else rv
[]
def write(self, buf): assert len(buf) == 65 self.pipe.settimeout(10) rv = self.pipe.send(buf[1:]) return 65 if rv == 64 else rv
[ "def", "write", "(", "self", ",", "buf", ")", ":", "assert", "len", "(", "buf", ")", "==", "65", "self", ".", "pipe", ".", "settimeout", "(", "10", ")", "rv", "=", "self", ".", "pipe", ".", "send", "(", "buf", "[", "1", ":", "]", ")", "return...
https://github.com/bitcoin-core/HWI/blob/6871946c2176f2f9777b6ac8f0614d96d99bfa0e/hwilib/devices/ckcc/client.py#L381-L385
futurecore/python-csp
1f96b76de1531ecf6bf1759641eadb08266ff7e7
csp/os_thread.py
python
_CSPOpMixin.join
(self)
Join only if self is running.
Join only if self is running.
[ "Join", "only", "if", "self", "is", "running", "." ]
def join(self): """Join only if self is running.""" if self._Thread__started.is_set(): threading.Thread.join(self)
[ "def", "join", "(", "self", ")", ":", "if", "self", ".", "_Thread__started", ".", "is_set", "(", ")", ":", "threading", ".", "Thread", ".", "join", "(", "self", ")" ]
https://github.com/futurecore/python-csp/blob/1f96b76de1531ecf6bf1759641eadb08266ff7e7/csp/os_thread.py#L139-L142
XX-net/XX-Net
a9898cfcf0084195fb7e69b6bc834e59aecdf14f
python3.8.2/Lib/site-packages/pip/_vendor/pkg_resources/__init__.py
python
Distribution.get_entry_map
(self, group=None)
return ep_map
Return the entry point map for `group`, or the full entry map
Return the entry point map for `group`, or the full entry map
[ "Return", "the", "entry", "point", "map", "for", "group", "or", "the", "full", "entry", "map" ]
def get_entry_map(self, group=None): """Return the entry point map for `group`, or the full entry map""" try: ep_map = self._ep_map except AttributeError: ep_map = self._ep_map = EntryPoint.parse_map( self._get_metadata('entry_points.txt'), self ) if group is not None: return ep_map.get(group, {}) return ep_map
[ "def", "get_entry_map", "(", "self", ",", "group", "=", "None", ")", ":", "try", ":", "ep_map", "=", "self", ".", "_ep_map", "except", "AttributeError", ":", "ep_map", "=", "self", ".", "_ep_map", "=", "EntryPoint", ".", "parse_map", "(", "self", ".", ...
https://github.com/XX-net/XX-Net/blob/a9898cfcf0084195fb7e69b6bc834e59aecdf14f/python3.8.2/Lib/site-packages/pip/_vendor/pkg_resources/__init__.py#L2845-L2855
BMW-InnovationLab/BMW-TensorFlow-Training-GUI
4f10d1f00f9ac312ca833e5b28fd0f8952cfee17
training_api/research/object_detection/core/preprocessor.py
python
get_default_func_arg_map
(include_label_scores=False, include_multiclass_scores=False, include_instance_masks=False, include_keypoints=False)
return prep_func_arg_map
Returns the default mapping from a preprocessor function to its args. Args: include_label_scores: If True, preprocessing functions will modify the label scores, too. include_multiclass_scores: If True, preprocessing functions will modify the multiclass scores, too. include_instance_masks: If True, preprocessing functions will modify the instance masks, too. include_keypoints: If True, preprocessing functions will modify the keypoints, too. Returns: A map from preprocessing functions to the arguments they receive.
Returns the default mapping from a preprocessor function to its args.
[ "Returns", "the", "default", "mapping", "from", "a", "preprocessor", "function", "to", "its", "args", "." ]
def get_default_func_arg_map(include_label_scores=False, include_multiclass_scores=False, include_instance_masks=False, include_keypoints=False): """Returns the default mapping from a preprocessor function to its args. Args: include_label_scores: If True, preprocessing functions will modify the label scores, too. include_multiclass_scores: If True, preprocessing functions will modify the multiclass scores, too. include_instance_masks: If True, preprocessing functions will modify the instance masks, too. include_keypoints: If True, preprocessing functions will modify the keypoints, too. Returns: A map from preprocessing functions to the arguments they receive. """ groundtruth_label_scores = None if include_label_scores: groundtruth_label_scores = (fields.InputDataFields.groundtruth_label_scores) multiclass_scores = None if include_multiclass_scores: multiclass_scores = (fields.InputDataFields.multiclass_scores) groundtruth_instance_masks = None if include_instance_masks: groundtruth_instance_masks = ( fields.InputDataFields.groundtruth_instance_masks) groundtruth_keypoints = None if include_keypoints: groundtruth_keypoints = fields.InputDataFields.groundtruth_keypoints prep_func_arg_map = { normalize_image: (fields.InputDataFields.image,), random_horizontal_flip: ( fields.InputDataFields.image, fields.InputDataFields.groundtruth_boxes, groundtruth_instance_masks, groundtruth_keypoints, ), random_vertical_flip: ( fields.InputDataFields.image, fields.InputDataFields.groundtruth_boxes, groundtruth_instance_masks, groundtruth_keypoints, ), random_rotation90: ( fields.InputDataFields.image, fields.InputDataFields.groundtruth_boxes, groundtruth_instance_masks, groundtruth_keypoints, ), random_pixel_value_scale: (fields.InputDataFields.image,), random_image_scale: ( fields.InputDataFields.image, groundtruth_instance_masks, ), random_rgb_to_gray: (fields.InputDataFields.image,), random_adjust_brightness: (fields.InputDataFields.image,), random_adjust_contrast: (fields.InputDataFields.image,), random_adjust_hue: (fields.InputDataFields.image,), random_adjust_saturation: (fields.InputDataFields.image,), random_distort_color: (fields.InputDataFields.image,), random_jitter_boxes: (fields.InputDataFields.groundtruth_boxes,), random_crop_image: (fields.InputDataFields.image, fields.InputDataFields.groundtruth_boxes, fields.InputDataFields.groundtruth_classes, groundtruth_label_scores, multiclass_scores, groundtruth_instance_masks, groundtruth_keypoints), random_pad_image: (fields.InputDataFields.image, fields.InputDataFields.groundtruth_boxes), random_crop_pad_image: (fields.InputDataFields.image, fields.InputDataFields.groundtruth_boxes, fields.InputDataFields.groundtruth_classes, groundtruth_label_scores, multiclass_scores), random_crop_to_aspect_ratio: ( fields.InputDataFields.image, fields.InputDataFields.groundtruth_boxes, fields.InputDataFields.groundtruth_classes, groundtruth_label_scores, multiclass_scores, groundtruth_instance_masks, groundtruth_keypoints, ), random_pad_to_aspect_ratio: ( fields.InputDataFields.image, fields.InputDataFields.groundtruth_boxes, groundtruth_instance_masks, groundtruth_keypoints, ), random_black_patches: (fields.InputDataFields.image,), retain_boxes_above_threshold: ( fields.InputDataFields.groundtruth_boxes, fields.InputDataFields.groundtruth_classes, groundtruth_label_scores, multiclass_scores, groundtruth_instance_masks, groundtruth_keypoints, ), image_to_float: (fields.InputDataFields.image,), random_resize_method: (fields.InputDataFields.image,), resize_to_range: ( fields.InputDataFields.image, groundtruth_instance_masks, ), resize_to_min_dimension: ( fields.InputDataFields.image, groundtruth_instance_masks, ), scale_boxes_to_pixel_coordinates: ( fields.InputDataFields.image, fields.InputDataFields.groundtruth_boxes, groundtruth_keypoints, ), resize_image: ( fields.InputDataFields.image, groundtruth_instance_masks, ), subtract_channel_mean: (fields.InputDataFields.image,), one_hot_encoding: (fields.InputDataFields.groundtruth_image_classes,), rgb_to_gray: (fields.InputDataFields.image,), ssd_random_crop: (fields.InputDataFields.image, fields.InputDataFields.groundtruth_boxes, fields.InputDataFields.groundtruth_classes, groundtruth_label_scores, multiclass_scores, groundtruth_instance_masks, groundtruth_keypoints), ssd_random_crop_pad: (fields.InputDataFields.image, fields.InputDataFields.groundtruth_boxes, fields.InputDataFields.groundtruth_classes, groundtruth_label_scores, multiclass_scores), ssd_random_crop_fixed_aspect_ratio: ( fields.InputDataFields.image, fields.InputDataFields.groundtruth_boxes, fields.InputDataFields.groundtruth_classes, groundtruth_label_scores, multiclass_scores, groundtruth_instance_masks, groundtruth_keypoints), ssd_random_crop_pad_fixed_aspect_ratio: ( fields.InputDataFields.image, fields.InputDataFields.groundtruth_boxes, fields.InputDataFields.groundtruth_classes, groundtruth_label_scores, multiclass_scores, groundtruth_instance_masks, groundtruth_keypoints, ), convert_class_logits_to_softmax: (multiclass_scores,), } return prep_func_arg_map
[ "def", "get_default_func_arg_map", "(", "include_label_scores", "=", "False", ",", "include_multiclass_scores", "=", "False", ",", "include_instance_masks", "=", "False", ",", "include_keypoints", "=", "False", ")", ":", "groundtruth_label_scores", "=", "None", "if", ...
https://github.com/BMW-InnovationLab/BMW-TensorFlow-Training-GUI/blob/4f10d1f00f9ac312ca833e5b28fd0f8952cfee17/training_api/research/object_detection/core/preprocessor.py#L2951-L3102
spotify/gcp-audit
2d17578e8845db670505291076cfb58ede031901
gcp_audit/util/gcp.py
python
get_all_organizations
()
return [x['organizationId'] for x in resp['organizations']]
Get all organizations that the credentials have access to.
Get all organizations that the credentials have access to.
[ "Get", "all", "organizations", "that", "the", "credentials", "have", "access", "to", "." ]
def get_all_organizations(): """Get all organizations that the credentials have access to.""" resp = create_service('cloudresourcemanager', 'v1beta1') \ .organizations().list().execute() return [x['organizationId'] for x in resp['organizations']]
[ "def", "get_all_organizations", "(", ")", ":", "resp", "=", "create_service", "(", "'cloudresourcemanager'", ",", "'v1beta1'", ")", ".", "organizations", "(", ")", ".", "list", "(", ")", ".", "execute", "(", ")", "return", "[", "x", "[", "'organizationId'", ...
https://github.com/spotify/gcp-audit/blob/2d17578e8845db670505291076cfb58ede031901/gcp_audit/util/gcp.py#L128-L133
zhl2008/awd-platform
0416b31abea29743387b10b3914581fbe8e7da5e
web_flaskbb/lib/python2.7/site-packages/olefile/olefile.py
python
OleFileIO._check_duplicate_stream
(self, first_sect, minifat=False)
Checks if a stream has not been already referenced elsewhere. This method should only be called once for each known stream, and only if stream size is not null. :param first_sect: int, index of first sector of the stream in FAT :param minifat: bool, if True, stream is located in the MiniFAT, else in the FAT
Checks if a stream has not been already referenced elsewhere. This method should only be called once for each known stream, and only if stream size is not null.
[ "Checks", "if", "a", "stream", "has", "not", "been", "already", "referenced", "elsewhere", ".", "This", "method", "should", "only", "be", "called", "once", "for", "each", "known", "stream", "and", "only", "if", "stream", "size", "is", "not", "null", "." ]
def _check_duplicate_stream(self, first_sect, minifat=False): """ Checks if a stream has not been already referenced elsewhere. This method should only be called once for each known stream, and only if stream size is not null. :param first_sect: int, index of first sector of the stream in FAT :param minifat: bool, if True, stream is located in the MiniFAT, else in the FAT """ if minifat: log.debug('_check_duplicate_stream: sect=%Xh in MiniFAT' % first_sect) used_streams = self._used_streams_minifat else: log.debug('_check_duplicate_stream: sect=%Xh in FAT' % first_sect) # some values can be safely ignored (not a real stream): if first_sect in (DIFSECT,FATSECT,ENDOFCHAIN,FREESECT): return used_streams = self._used_streams_fat #TODO: would it be more efficient using a dict or hash values, instead # of a list of long ? if first_sect in used_streams: self._raise_defect(DEFECT_INCORRECT, 'Stream referenced twice') else: used_streams.append(first_sect)
[ "def", "_check_duplicate_stream", "(", "self", ",", "first_sect", ",", "minifat", "=", "False", ")", ":", "if", "minifat", ":", "log", ".", "debug", "(", "'_check_duplicate_stream: sect=%Xh in MiniFAT'", "%", "first_sect", ")", "used_streams", "=", "self", ".", ...
https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/lib/python2.7/site-packages/olefile/olefile.py#L1350-L1373
proycon/pynlpl
7707f69a91caaa6cde037f0d0379f1d42500a68b
pynlpl/fsa.py
python
NFA._states
(self, state, processedstates=[])
return processedstates
Iterate over all states in no particular order
Iterate over all states in no particular order
[ "Iterate", "over", "all", "states", "in", "no", "particular", "order" ]
def _states(self, state, processedstates=[]): #pylint: disable=dangerous-default-value """Iterate over all states in no particular order""" processedstates.append(state) for nextstate in state.epsilon: if not nextstate in processedstates: self._states(nextstate, processedstates) for _, nextstate in state.transitions: if not nextstate in processedstates: self._states(nextstate, processedstates) return processedstates
[ "def", "_states", "(", "self", ",", "state", ",", "processedstates", "=", "[", "]", ")", ":", "#pylint: disable=dangerous-default-value", "processedstates", ".", "append", "(", "state", ")", "for", "nextstate", "in", "state", ".", "epsilon", ":", "if", "not", ...
https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/fsa.py#L97-L109
scipy/scipy
e0a749f01e79046642ccfdc419edbf9e7ca141ad
scipy/sparse/linalg/_isolve/utils.py
python
make_system
(A, M, x0, b)
return A, M, x, b, postprocess
Make a linear system Ax=b Parameters ---------- A : LinearOperator sparse or dense matrix (or any valid input to aslinearoperator) M : {LinearOperator, Nones} preconditioner sparse or dense matrix (or any valid input to aslinearoperator) x0 : {array_like, str, None} initial guess to iterative method. ``x0 = 'Mb'`` means using the nonzero initial guess ``M @ b``. Default is `None`, which means using the zero initial guess. b : array_like right hand side Returns ------- (A, M, x, b, postprocess) A : LinearOperator matrix of the linear system M : LinearOperator preconditioner x : rank 1 ndarray initial guess b : rank 1 ndarray right hand side postprocess : function converts the solution vector to the appropriate type and dimensions (e.g. (N,1) matrix)
Make a linear system Ax=b
[ "Make", "a", "linear", "system", "Ax", "=", "b" ]
def make_system(A, M, x0, b): """Make a linear system Ax=b Parameters ---------- A : LinearOperator sparse or dense matrix (or any valid input to aslinearoperator) M : {LinearOperator, Nones} preconditioner sparse or dense matrix (or any valid input to aslinearoperator) x0 : {array_like, str, None} initial guess to iterative method. ``x0 = 'Mb'`` means using the nonzero initial guess ``M @ b``. Default is `None`, which means using the zero initial guess. b : array_like right hand side Returns ------- (A, M, x, b, postprocess) A : LinearOperator matrix of the linear system M : LinearOperator preconditioner x : rank 1 ndarray initial guess b : rank 1 ndarray right hand side postprocess : function converts the solution vector to the appropriate type and dimensions (e.g. (N,1) matrix) """ A_ = A A = aslinearoperator(A) if A.shape[0] != A.shape[1]: raise ValueError(f'expected square matrix, but got shape={(A.shape,)}') N = A.shape[0] b = asanyarray(b) if not (b.shape == (N,1) or b.shape == (N,)): raise ValueError(f'shapes of A {A.shape} and b {b.shape} are ' 'incompatible') if b.dtype.char not in 'fdFD': b = b.astype('d') # upcast non-FP types to double def postprocess(x): return x if hasattr(A,'dtype'): xtype = A.dtype.char else: xtype = A.matvec(b).dtype.char xtype = coerce(xtype, b.dtype.char) b = asarray(b,dtype=xtype) # make b the same type as x b = b.ravel() # process preconditioner if M is None: if hasattr(A_,'psolve'): psolve = A_.psolve else: psolve = id if hasattr(A_,'rpsolve'): rpsolve = A_.rpsolve else: rpsolve = id if psolve is id and rpsolve is id: M = IdentityOperator(shape=A.shape, dtype=A.dtype) else: M = LinearOperator(A.shape, matvec=psolve, rmatvec=rpsolve, dtype=A.dtype) else: M = aslinearoperator(M) if A.shape != M.shape: raise ValueError('matrix and preconditioner have different shapes') # set initial guess if x0 is None: x = zeros(N, dtype=xtype) elif isinstance(x0, str): if x0 == 'Mb': # use nonzero initial guess ``M @ b`` bCopy = b.copy() x = M.matvec(bCopy) else: x = array(x0, dtype=xtype) if not (x.shape == (N, 1) or x.shape == (N,)): raise ValueError(f'shapes of A {A.shape} and ' f'x0 {x.shape} are incompatible') x = x.ravel() return A, M, x, b, postprocess
[ "def", "make_system", "(", "A", ",", "M", ",", "x0", ",", "b", ")", ":", "A_", "=", "A", "A", "=", "aslinearoperator", "(", "A", ")", "if", "A", ".", "shape", "[", "0", "]", "!=", "A", ".", "shape", "[", "1", "]", ":", "raise", "ValueError", ...
https://github.com/scipy/scipy/blob/e0a749f01e79046642ccfdc419edbf9e7ca141ad/scipy/sparse/linalg/_isolve/utils.py#L32-L128
0vercl0k/stuffz
2ff82f4739d7e215c6140d4987efa8310db39d55
ql-chall-python-2014/fuby_ql.py
python
PythonDecompiler.__reduce_conditional_blocks
(self, stmts)
return stmts
Reduce conditional blocks
Reduce conditional blocks
[ "Reduce", "conditional", "blocks" ]
def __reduce_conditional_blocks(self, stmts): """ Reduce conditional blocks """ repass = True while repass: repass = False i = 0 while i < len(stmts): if isinstance(stmts[i], If) or isinstance(stmts[i], Elif): j = i + 1 while j < len(stmts): if isinstance(stmts[j], If) or isinstance(stmts[j], Elif): # (el)if x: z elif y: z => (el)if x or y: z if stmts[i].statements == stmts[j].statements: stmts[i].expr = BinaryOp(stmts[i].expr, 'or', stmts[j].expr) stmts.pop(j) repass = True continue j = j + 1 i = i + 1 i = 0 while i < len(stmts): # if x: if x and y: | if x: if not x or y: # if y: => foo | if y: => z # foo z | z # [z] | else: # z | z if isinstance(stmts[i], If) or isinstance(stmts[i], Elif): if len(stmts[i].statements) > 0 and isinstance(stmts[i].statements[0], If): if i < len(stmts) - 1 and isinstance(stmts[i+1], Else): if stmts[i].statements[0].statements == stmts[i+1].statements: stmts[i].expr = BinaryOp(UnaryOp('not ', stmts[i].expr), 'or', stmts[i].statements[0].expr) stmts[i].statements = stmts.pop(i+1).statements repass = True continue if stmts[i].statements[1:] == stmts[1-len(stmts[i].statements):] or stmts[i].statements[1:] == stmts[i+1:] or len(stmts[i].statements) == 1: stmts[i].expr = BinaryOp(stmts[i].expr, 'and', stmts[i].statements[0].expr) stmts[i].statements = stmts[i].statements[0].statements repass = True continue i = i + 1 return stmts
[ "def", "__reduce_conditional_blocks", "(", "self", ",", "stmts", ")", ":", "repass", "=", "True", "while", "repass", ":", "repass", "=", "False", "i", "=", "0", "while", "i", "<", "len", "(", "stmts", ")", ":", "if", "isinstance", "(", "stmts", "[", ...
https://github.com/0vercl0k/stuffz/blob/2ff82f4739d7e215c6140d4987efa8310db39d55/ql-chall-python-2014/fuby_ql.py#L1547-L1589
scrapinghub/spidermon
f2b21e45e70796f583bbb97f39b823c31d242b17
spidermon/results/monitor.py
python
MonitorResult._step_monitors_finished
(self)
return self._steps[settings.STEPS.MONITORS_FINISHED]
[]
def _step_monitors_finished(self): return self._steps[settings.STEPS.MONITORS_FINISHED]
[ "def", "_step_monitors_finished", "(", "self", ")", ":", "return", "self", ".", "_steps", "[", "settings", ".", "STEPS", ".", "MONITORS_FINISHED", "]" ]
https://github.com/scrapinghub/spidermon/blob/f2b21e45e70796f583bbb97f39b823c31d242b17/spidermon/results/monitor.py#L155-L156
cbrgm/telegram-robot-rss
58fe98de427121fdc152c8df0721f1891174e6c9
venv/lib/python2.7/site-packages/future/backports/http/server.py
python
BaseHTTPRequestHandler.version_string
(self)
return self.server_version + ' ' + self.sys_version
Return the server software version string.
Return the server software version string.
[ "Return", "the", "server", "software", "version", "string", "." ]
def version_string(self): """Return the server software version string.""" return self.server_version + ' ' + self.sys_version
[ "def", "version_string", "(", "self", ")", ":", "return", "self", ".", "server_version", "+", "' '", "+", "self", ".", "sys_version" ]
https://github.com/cbrgm/telegram-robot-rss/blob/58fe98de427121fdc152c8df0721f1891174e6c9/venv/lib/python2.7/site-packages/future/backports/http/server.py#L539-L541
poppy-project/pypot
c5d384fe23eef9f6ec98467f6f76626cdf20afb9
pypot/vrep/remoteApiBindings/vrep.py
python
simxStartSimulation
(clientID, operationMode)
return c_StartSimulation(clientID, operationMode)
Please have a look at the function description/documentation in the V-REP user manual
Please have a look at the function description/documentation in the V-REP user manual
[ "Please", "have", "a", "look", "at", "the", "function", "description", "/", "documentation", "in", "the", "V", "-", "REP", "user", "manual" ]
def simxStartSimulation(clientID, operationMode): ''' Please have a look at the function description/documentation in the V-REP user manual ''' return c_StartSimulation(clientID, operationMode)
[ "def", "simxStartSimulation", "(", "clientID", ",", "operationMode", ")", ":", "return", "c_StartSimulation", "(", "clientID", ",", "operationMode", ")" ]
https://github.com/poppy-project/pypot/blob/c5d384fe23eef9f6ec98467f6f76626cdf20afb9/pypot/vrep/remoteApiBindings/vrep.py#L404-L409
PacktPublishing/Hands-On-Intelligent-Agents-with-OpenAI-Gym
14ab6fc82018e48de130e87671cca6c57456d1a5
ch8/environment/carla_gym/envs/carla/driving_benchmark/experiment_suites/corl_2017.py
python
CoRL2017.build_experiments
(self)
return experiments_vector
Creates the whole set of experiment objects, The experiments created depend on the selected Town.
Creates the whole set of experiment objects, The experiments created depend on the selected Town.
[ "Creates", "the", "whole", "set", "of", "experiment", "objects", "The", "experiments", "created", "depend", "on", "the", "selected", "Town", "." ]
def build_experiments(self): """ Creates the whole set of experiment objects, The experiments created depend on the selected Town. """ # We set the camera # This single RGB camera is used on every experiment camera = Camera('CameraRGB') camera.set(FOV=100) camera.set_image_size(800, 600) camera.set_position(2.0, 0.0, 1.4) camera.set_rotation(-15.0, 0, 0) if self._city_name == 'Town01': poses_tasks = self._poses_town01() vehicles_tasks = [0, 0, 0, 20] pedestrians_tasks = [0, 0, 0, 50] else: poses_tasks = self._poses_town02() vehicles_tasks = [0, 0, 0, 15] pedestrians_tasks = [0, 0, 0, 50] experiments_vector = [] for weather in self.weathers: for iteration in range(len(poses_tasks)): poses = poses_tasks[iteration] vehicles = vehicles_tasks[iteration] pedestrians = pedestrians_tasks[iteration] conditions = CarlaSettings() conditions.set( SendNonPlayerAgentsInfo=True, NumberOfVehicles=vehicles, NumberOfPedestrians=pedestrians, WeatherId=weather ) # Add all the cameras that were set for this experiments conditions.add_sensor(camera) experiment = Experiment() experiment.set( Conditions=conditions, Poses=poses, Task=iteration, Repetitions=1 ) experiments_vector.append(experiment) return experiments_vector
[ "def", "build_experiments", "(", "self", ")", ":", "# We set the camera", "# This single RGB camera is used on every experiment", "camera", "=", "Camera", "(", "'CameraRGB'", ")", "camera", ".", "set", "(", "FOV", "=", "100", ")", "camera", ".", "set_image_size", "(...
https://github.com/PacktPublishing/Hands-On-Intelligent-Agents-with-OpenAI-Gym/blob/14ab6fc82018e48de130e87671cca6c57456d1a5/ch8/environment/carla_gym/envs/carla/driving_benchmark/experiment_suites/corl_2017.py#L89-L144
kuri65536/python-for-android
26402a08fc46b09ef94e8d7a6bbc3a54ff9d0891
python-modules/twisted/twisted/lore/tree.py
python
fixLinks
(document, ext)
Rewrite links to XHTML lore input documents so they point to lore XHTML output documents. Any node with an C{href} attribute which does not contain a value starting with C{http}, C{https}, C{ftp}, or C{mailto} and which does not have a C{class} attribute of C{absolute} or which contains C{listing} and which does point to an URL ending with C{html} will have that attribute value rewritten so that the filename extension is C{ext} instead of C{html}. @type document: A DOM Node or Document @param document: The input document which contains all of the content to be presented. @type ext: C{str} @param ext: The extension to use when selecting an output file name. This replaces the extension of the input file name. @return: C{None}
Rewrite links to XHTML lore input documents so they point to lore XHTML output documents.
[ "Rewrite", "links", "to", "XHTML", "lore", "input", "documents", "so", "they", "point", "to", "lore", "XHTML", "output", "documents", "." ]
def fixLinks(document, ext): """ Rewrite links to XHTML lore input documents so they point to lore XHTML output documents. Any node with an C{href} attribute which does not contain a value starting with C{http}, C{https}, C{ftp}, or C{mailto} and which does not have a C{class} attribute of C{absolute} or which contains C{listing} and which does point to an URL ending with C{html} will have that attribute value rewritten so that the filename extension is C{ext} instead of C{html}. @type document: A DOM Node or Document @param document: The input document which contains all of the content to be presented. @type ext: C{str} @param ext: The extension to use when selecting an output file name. This replaces the extension of the input file name. @return: C{None} """ supported_schemes=['http', 'https', 'ftp', 'mailto'] for node in domhelpers.findElementsWithAttribute(document, 'href'): href = node.getAttribute("href") if urlparse.urlparse(href)[0] in supported_schemes: continue if node.getAttribute("class") == "absolute": continue if node.getAttribute("class").find('listing') != -1: continue # This is a relative link, so it should be munged. if href.endswith('html') or href[:href.rfind('#')].endswith('html'): fname, fext = os.path.splitext(href) if '#' in fext: fext = ext+'#'+fext.split('#', 1)[1] else: fext = ext node.setAttribute("href", fname + fext)
[ "def", "fixLinks", "(", "document", ",", "ext", ")", ":", "supported_schemes", "=", "[", "'http'", ",", "'https'", ",", "'ftp'", ",", "'mailto'", "]", "for", "node", "in", "domhelpers", ".", "findElementsWithAttribute", "(", "document", ",", "'href'", ")", ...
https://github.com/kuri65536/python-for-android/blob/26402a08fc46b09ef94e8d7a6bbc3a54ff9d0891/python-modules/twisted/twisted/lore/tree.py#L21-L59
biopython/biopython
2dd97e71762af7b046d7f7f8a4f1e38db6b06c86
Bio/PDB/QCPSuperimposer/__init__.py
python
QCPSuperimposer.get_rotran
(self)
return self.rot, self.tran
Right multiplying rotation matrix and translation.
Right multiplying rotation matrix and translation.
[ "Right", "multiplying", "rotation", "matrix", "and", "translation", "." ]
def get_rotran(self): """Right multiplying rotation matrix and translation.""" if self.rot is None: raise Exception("Nothing superimposed yet.") return self.rot, self.tran
[ "def", "get_rotran", "(", "self", ")", ":", "if", "self", ".", "rot", "is", "None", ":", "raise", "Exception", "(", "\"Nothing superimposed yet.\"", ")", "return", "self", ".", "rot", ",", "self", ".", "tran" ]
https://github.com/biopython/biopython/blob/2dd97e71762af7b046d7f7f8a4f1e38db6b06c86/Bio/PDB/QCPSuperimposer/__init__.py#L147-L151
jwkvam/bowtie
220cd41367a70f2e206db846278cb7b6fd3649eb
bowtie/_progress.py
python
Progress._instantiate
(self)
return ''.join(self._tags)
Instantiate a progress bar. This is normally never used.
Instantiate a progress bar.
[ "Instantiate", "a", "progress", "bar", "." ]
def _instantiate(self) -> str: """Instantiate a progress bar. This is normally never used. """ return ''.join(self._tags)
[ "def", "_instantiate", "(", "self", ")", "->", "str", ":", "return", "''", ".", "join", "(", "self", ".", "_tags", ")" ]
https://github.com/jwkvam/bowtie/blob/220cd41367a70f2e206db846278cb7b6fd3649eb/bowtie/_progress.py#L54-L59
emesene/emesene
4548a4098310e21b16437bb36223a7f632a4f7bc
emesene/e3/xmpp/SleekXMPP/sleekxmpp/roster/multi.py
python
Roster.auto_subscribe
(self)
return self._auto_subscribe
Auto send requests for mutual subscriptions. If True, auto send mutual subscription requests.
Auto send requests for mutual subscriptions.
[ "Auto", "send", "requests", "for", "mutual", "subscriptions", "." ]
def auto_subscribe(self): """ Auto send requests for mutual subscriptions. If True, auto send mutual subscription requests. """ return self._auto_subscribe
[ "def", "auto_subscribe", "(", "self", ")", ":", "return", "self", ".", "_auto_subscribe" ]
https://github.com/emesene/emesene/blob/4548a4098310e21b16437bb36223a7f632a4f7bc/emesene/e3/xmpp/SleekXMPP/sleekxmpp/roster/multi.py#L204-L210
lovelylain/pyctp
fd304de4b50c4ddc31a4190b1caaeb5dec66bc5d
futures/ctp/ApiStruct.py
python
SettlementRef.__init__
(self, TradingDay='', SettlementID=0)
[]
def __init__(self, TradingDay='', SettlementID=0): self.TradingDay = 'Date' #交易日, char[9] self.SettlementID = ''
[ "def", "__init__", "(", "self", ",", "TradingDay", "=", "''", ",", "SettlementID", "=", "0", ")", ":", "self", ".", "TradingDay", "=", "'Date'", "#交易日, char[9]", "self", ".", "SettlementID", "=", "''" ]
https://github.com/lovelylain/pyctp/blob/fd304de4b50c4ddc31a4190b1caaeb5dec66bc5d/futures/ctp/ApiStruct.py#L2461-L2463
translate/translate
72816df696b5263abfe80ab59129b299b85ae749
translate/storage/poheader.py
python
poheader.makeheaderdict
( self, charset="CHARSET", encoding="ENCODING", project_id_version=None, pot_creation_date=None, po_revision_date=None, last_translator=None, language_team=None, mime_version=None, plural_forms=None, report_msgid_bugs_to=None, **kwargs, )
return update(defaultargs, add=True, **kwargs)
Create a header dictionary with useful defaults. pot_creation_date can be None (current date) or a value (datetime or string) po_revision_date can be None (form), False (=pot_creation_date), True (=now), or a value (datetime or string) :return: Dictionary with the header items :rtype: dict of strings
Create a header dictionary with useful defaults.
[ "Create", "a", "header", "dictionary", "with", "useful", "defaults", "." ]
def makeheaderdict( self, charset="CHARSET", encoding="ENCODING", project_id_version=None, pot_creation_date=None, po_revision_date=None, last_translator=None, language_team=None, mime_version=None, plural_forms=None, report_msgid_bugs_to=None, **kwargs, ): """Create a header dictionary with useful defaults. pot_creation_date can be None (current date) or a value (datetime or string) po_revision_date can be None (form), False (=pot_creation_date), True (=now), or a value (datetime or string) :return: Dictionary with the header items :rtype: dict of strings """ if project_id_version is None: project_id_version = "PACKAGE VERSION" if pot_creation_date is None or pot_creation_date is True: pot_creation_date = time.strftime("%Y-%m-%d %H:%M") + tzstring() if isinstance(pot_creation_date, time.struct_time): pot_creation_date = ( time.strftime("%Y-%m-%d %H:%M", pot_creation_date) + tzstring() ) if po_revision_date is None: po_revision_date = "YEAR-MO-DA HO:MI+ZONE" elif po_revision_date is False: po_revision_date = pot_creation_date elif po_revision_date is True: po_revision_date = time.strftime("%Y-%m-%d %H:%M") + tzstring() if isinstance(po_revision_date, time.struct_time): po_revision_date = ( time.strftime("%Y-%m-%d %H:%M", po_revision_date) + tzstring() ) if last_translator is None: last_translator = "FULL NAME <EMAIL@ADDRESS>" if language_team is None: language_team = "LANGUAGE <LL@li.org>" if mime_version is None: mime_version = "1.0" if report_msgid_bugs_to is None: report_msgid_bugs_to = "" defaultargs = OrderedDict() defaultargs["Project-Id-Version"] = project_id_version defaultargs["Report-Msgid-Bugs-To"] = report_msgid_bugs_to defaultargs["POT-Creation-Date"] = pot_creation_date defaultargs["PO-Revision-Date"] = po_revision_date defaultargs["Last-Translator"] = last_translator defaultargs["Language-Team"] = language_team defaultargs["MIME-Version"] = mime_version defaultargs["Content-Type"] = "text/plain; charset=%s" % charset defaultargs["Content-Transfer-Encoding"] = encoding if plural_forms: defaultargs["Plural-Forms"] = plural_forms defaultargs["X-Generator"] = self.x_generator return update(defaultargs, add=True, **kwargs)
[ "def", "makeheaderdict", "(", "self", ",", "charset", "=", "\"CHARSET\"", ",", "encoding", "=", "\"ENCODING\"", ",", "project_id_version", "=", "None", ",", "pot_creation_date", "=", "None", ",", "po_revision_date", "=", "None", ",", "last_translator", "=", "Non...
https://github.com/translate/translate/blob/72816df696b5263abfe80ab59129b299b85ae749/translate/storage/poheader.py#L135-L199
sagemath/sage
f9b2db94f675ff16963ccdefba4f1a3393b3fe0d
src/sage/rings/number_field/number_field_ideal.py
python
NumberFieldFractionalIdeal.small_residue
(self, f)
return k(k.pari_nf().nfeltreduce(f, self.pari_hnf()))
r""" Given an element `f` of the ambient number field, returns an element `g` such that `f - g` belongs to the ideal self (which must be integral), and `g` is small. .. note:: The reduced representative returned is not uniquely determined. ALGORITHM: Uses Pari function :pari:`nfeltreduce`. EXAMPLES: :: sage: k.<a> = NumberField(x^2 + 5) sage: I = k.ideal(a) sage: I.small_residue(14) 4 :: sage: K.<a> = NumberField(x^5 + 7*x^4 + 18*x^2 + x - 3) sage: I = K.ideal(5) sage: I.small_residue(a^2 -13) a^2 + 5*a - 3
r""" Given an element `f` of the ambient number field, returns an element `g` such that `f - g` belongs to the ideal self (which must be integral), and `g` is small.
[ "r", "Given", "an", "element", "f", "of", "the", "ambient", "number", "field", "returns", "an", "element", "g", "such", "that", "f", "-", "g", "belongs", "to", "the", "ideal", "self", "(", "which", "must", "be", "integral", ")", "and", "g", "is", "sm...
def small_residue(self, f): r""" Given an element `f` of the ambient number field, returns an element `g` such that `f - g` belongs to the ideal self (which must be integral), and `g` is small. .. note:: The reduced representative returned is not uniquely determined. ALGORITHM: Uses Pari function :pari:`nfeltreduce`. EXAMPLES: :: sage: k.<a> = NumberField(x^2 + 5) sage: I = k.ideal(a) sage: I.small_residue(14) 4 :: sage: K.<a> = NumberField(x^5 + 7*x^4 + 18*x^2 + x - 3) sage: I = K.ideal(5) sage: I.small_residue(a^2 -13) a^2 + 5*a - 3 """ if not self.is_integral(): raise ValueError("The ideal must be integral") k = self.number_field() return k(k.pari_nf().nfeltreduce(f, self.pari_hnf()))
[ "def", "small_residue", "(", "self", ",", "f", ")", ":", "if", "not", "self", ".", "is_integral", "(", ")", ":", "raise", "ValueError", "(", "\"The ideal must be integral\"", ")", "k", "=", "self", ".", "number_field", "(", ")", "return", "k", "(", "k", ...
https://github.com/sagemath/sage/blob/f9b2db94f675ff16963ccdefba4f1a3393b3fe0d/src/sage/rings/number_field/number_field_ideal.py#L2484-L2516
neuropsychology/NeuroKit
d01111b9b82364d28da01c002e6cbfc45d9493d9
neurokit2/eeg/mne_channel_add.py
python
mne_channel_add
( raw, channel, channel_type=None, channel_name=None, sync_index_raw=0, sync_index_channel=0 )
return raw
Add channel as array to MNE. Add a channel to a mne's Raw m/eeg file. It will basically synchronize the channel to the eeg data following a particular index and add it. Parameters ---------- raw : mne.io.Raw Raw EEG data from MNE. channel : list or array The signal to be added. channel_type : str Channel type. Currently supported fields are 'ecg', 'bio', 'stim', 'eog', 'misc', 'seeg', 'ecog', 'mag', 'eeg', 'ref_meg', 'grad', 'emg', 'hbr' or 'hbo'. channel_name : str Desired channel name. sync_index_raw : int or list An index (e.g., the onset of the same event marked in the same signal), in the raw data, by which to align the two inputs. This can be used in case the EEG data and the channel to add do not have the same onsets and must be aligned through some common event. sync_index_channel : int or list An index (e.g., the onset of the same event marked in the same signal), in the channel to add, by which to align the two inputs. This can be used in case the EEG data and the channel to add do not have the same onsets and must be aligned through some common event. Returns ---------- mne.io.Raw Raw data in FIF format. Example ---------- >>> import neurokit2 as nk >>> import mne >>> >>> raw = nk.mne_data("filt-0-40_raw") >>> ecg = nk.ecg_simulate(length=50000) >>> >>> # Let the 42nd sample point in the EEG signal correspond to the 333rd point in the ECG >>> event_index_in_eeg = 42 >>> event_index_in_ecg = 333 >>> >>> raw = nk.mne_channel_add(raw, ... ecg, ... sync_index_raw=event_index_in_eeg, ... sync_index_channel=event_index_in_ecg, ... channel_type="ecg") # doctest: +SKIP
Add channel as array to MNE.
[ "Add", "channel", "as", "array", "to", "MNE", "." ]
def mne_channel_add( raw, channel, channel_type=None, channel_name=None, sync_index_raw=0, sync_index_channel=0 ): """Add channel as array to MNE. Add a channel to a mne's Raw m/eeg file. It will basically synchronize the channel to the eeg data following a particular index and add it. Parameters ---------- raw : mne.io.Raw Raw EEG data from MNE. channel : list or array The signal to be added. channel_type : str Channel type. Currently supported fields are 'ecg', 'bio', 'stim', 'eog', 'misc', 'seeg', 'ecog', 'mag', 'eeg', 'ref_meg', 'grad', 'emg', 'hbr' or 'hbo'. channel_name : str Desired channel name. sync_index_raw : int or list An index (e.g., the onset of the same event marked in the same signal), in the raw data, by which to align the two inputs. This can be used in case the EEG data and the channel to add do not have the same onsets and must be aligned through some common event. sync_index_channel : int or list An index (e.g., the onset of the same event marked in the same signal), in the channel to add, by which to align the two inputs. This can be used in case the EEG data and the channel to add do not have the same onsets and must be aligned through some common event. Returns ---------- mne.io.Raw Raw data in FIF format. Example ---------- >>> import neurokit2 as nk >>> import mne >>> >>> raw = nk.mne_data("filt-0-40_raw") >>> ecg = nk.ecg_simulate(length=50000) >>> >>> # Let the 42nd sample point in the EEG signal correspond to the 333rd point in the ECG >>> event_index_in_eeg = 42 >>> event_index_in_ecg = 333 >>> >>> raw = nk.mne_channel_add(raw, ... ecg, ... sync_index_raw=event_index_in_eeg, ... sync_index_channel=event_index_in_ecg, ... channel_type="ecg") # doctest: +SKIP """ # Try loading mne try: import mne except ImportError: raise ImportError( "NeuroKit error: eeg_channel_add(): the 'mne' module is required for this function to run. ", "Please install it first (`pip install mne`).", ) if channel_name is None: if isinstance(channel, pd.Series): if channel.name is not None: channel_name = channel.name else: channel_name = "Added_Channel" else: channel_name = "Added_Channel" # Compute the distance between the two signals diff = sync_index_channel - sync_index_raw # Pre-empt the channel with nans if shorter or crop if longer if diff > 0: channel = list(channel)[diff : len(channel)] channel = channel + [np.nan] * diff if diff < 0: channel = [np.nan] * abs(diff) + list(channel) # Extend the channel with nans if shorter or crop if longer if len(channel) < len(raw): channel = list(channel) + [np.nan] * (len(raw) - len(channel)) else: # Crop to fit the raw data channel = list(channel)[0 : len(raw)] old_verbosity_level = mne.set_log_level(verbose="WARNING", return_old_level=True) # Create RawArray info = mne.create_info([channel_name], raw.info["sfreq"], ch_types=channel_type) channel = mne.io.RawArray([channel], info) # Add channel raw = raw.copy() raw.add_channels([channel], force_update_info=True) # In-place # Restore old verbosity level mne.set_log_level(old_verbosity_level) return raw
[ "def", "mne_channel_add", "(", "raw", ",", "channel", ",", "channel_type", "=", "None", ",", "channel_name", "=", "None", ",", "sync_index_raw", "=", "0", ",", "sync_index_channel", "=", "0", ")", ":", "# Try loading mne", "try", ":", "import", "mne", "excep...
https://github.com/neuropsychology/NeuroKit/blob/d01111b9b82364d28da01c002e6cbfc45d9493d9/neurokit2/eeg/mne_channel_add.py#L6-L106
svpcom/wifibroadcast
51251b8c484b8c4f548aa3bbb1633e0edbb605dc
telemetry/mavlink.py
python
MAVLink.open_drone_id_authentication_send
(self, target_system, target_component, id_or_mac, authentication_type, data_page, page_count, length, timestamp, authentication_data, force_mavlink1=False)
return self.send(self.open_drone_id_authentication_encode(target_system, target_component, id_or_mac, authentication_type, data_page, page_count, length, timestamp, authentication_data), force_mavlink1=force_mavlink1)
Data for filling the OpenDroneID Authentication message. The Authentication Message defines a field that can provide a means of authenticity for the identity of the UAS (Unmanned Aircraft System). The Authentication message can have two different formats. Five data pages are supported. For data page 0, the fields PageCount, Length and TimeStamp are present and AuthData is only 17 bytes. For data page 1 through 4, PageCount, Length and TimeStamp are not present and the size of AuthData is 23 bytes. target_system : System ID (0 for broadcast). (type:uint8_t) target_component : Component ID (0 for broadcast). (type:uint8_t) id_or_mac : Only used for drone ID data received from other UAs. See detailed description at https://mavlink.io/en/services/opendroneid.html. (type:uint8_t) authentication_type : Indicates the type of authentication. (type:uint8_t, values:MAV_ODID_AUTH_TYPE) data_page : Allowed range is 0 - 4. (type:uint8_t) page_count : This field is only present for page 0. Allowed range is 0 - 5. (type:uint8_t) length : This field is only present for page 0. Total bytes of authentication_data from all data pages. Allowed range is 0 - 109 (17 + 23*4). [bytes] (type:uint8_t) timestamp : This field is only present for page 0. 32 bit Unix Timestamp in seconds since 00:00:00 01/01/2019. [s] (type:uint32_t) authentication_data : Opaque authentication data. For page 0, the size is only 17 bytes. For other pages, the size is 23 bytes. Shall be filled with nulls in the unused portion of the field. (type:uint8_t)
Data for filling the OpenDroneID Authentication message. The Authentication Message defines a field that can provide a means of authenticity for the identity of the UAS (Unmanned Aircraft System). The Authentication message can have two different formats. Five data pages are supported. For data page 0, the fields PageCount, Length and TimeStamp are present and AuthData is only 17 bytes. For data page 1 through 4, PageCount, Length and TimeStamp are not present and the size of AuthData is 23 bytes.
[ "Data", "for", "filling", "the", "OpenDroneID", "Authentication", "message", ".", "The", "Authentication", "Message", "defines", "a", "field", "that", "can", "provide", "a", "means", "of", "authenticity", "for", "the", "identity", "of", "the", "UAS", "(", "Unm...
def open_drone_id_authentication_send(self, target_system, target_component, id_or_mac, authentication_type, data_page, page_count, length, timestamp, authentication_data, force_mavlink1=False): ''' Data for filling the OpenDroneID Authentication message. The Authentication Message defines a field that can provide a means of authenticity for the identity of the UAS (Unmanned Aircraft System). The Authentication message can have two different formats. Five data pages are supported. For data page 0, the fields PageCount, Length and TimeStamp are present and AuthData is only 17 bytes. For data page 1 through 4, PageCount, Length and TimeStamp are not present and the size of AuthData is 23 bytes. target_system : System ID (0 for broadcast). (type:uint8_t) target_component : Component ID (0 for broadcast). (type:uint8_t) id_or_mac : Only used for drone ID data received from other UAs. See detailed description at https://mavlink.io/en/services/opendroneid.html. (type:uint8_t) authentication_type : Indicates the type of authentication. (type:uint8_t, values:MAV_ODID_AUTH_TYPE) data_page : Allowed range is 0 - 4. (type:uint8_t) page_count : This field is only present for page 0. Allowed range is 0 - 5. (type:uint8_t) length : This field is only present for page 0. Total bytes of authentication_data from all data pages. Allowed range is 0 - 109 (17 + 23*4). [bytes] (type:uint8_t) timestamp : This field is only present for page 0. 32 bit Unix Timestamp in seconds since 00:00:00 01/01/2019. [s] (type:uint32_t) authentication_data : Opaque authentication data. For page 0, the size is only 17 bytes. For other pages, the size is 23 bytes. Shall be filled with nulls in the unused portion of the field. (type:uint8_t) ''' return self.send(self.open_drone_id_authentication_encode(target_system, target_component, id_or_mac, authentication_type, data_page, page_count, length, timestamp, authentication_data), force_mavlink1=force_mavlink1)
[ "def", "open_drone_id_authentication_send", "(", "self", ",", "target_system", ",", "target_component", ",", "id_or_mac", ",", "authentication_type", ",", "data_page", ",", "page_count", ",", "length", ",", "timestamp", ",", "authentication_data", ",", "force_mavlink1",...
https://github.com/svpcom/wifibroadcast/blob/51251b8c484b8c4f548aa3bbb1633e0edbb605dc/telemetry/mavlink.py#L29635-L29659
ilastik/ilastik
6acd2c554bc517e9c8ddad3623a7aaa2e6970c28
ilastik/applets/counting/countingGuiBoxesInterface.py
python
BoxInterpreter.__init__
(self, base: InterpreterABC, posModel: PositionModel, newBoxParent: QWidget)
Create new BoxInterpreter. Args: newBoxParent: Parent for the widget that is temporarily shown when a user draws a new box.
Create new BoxInterpreter.
[ "Create", "new", "BoxInterpreter", "." ]
def __init__(self, base: InterpreterABC, posModel: PositionModel, newBoxParent: QWidget): """Create new BoxInterpreter. Args: newBoxParent: Parent for the widget that is temporarily shown when a user draws a new box. """ super().__init__() self._base = base self._posModel = posModel self._rubberBand = RedRubberBand(QRubberBand.Rectangle, newBoxParent) self._origin = None self._originPos = None
[ "def", "__init__", "(", "self", ",", "base", ":", "InterpreterABC", ",", "posModel", ":", "PositionModel", ",", "newBoxParent", ":", "QWidget", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "self", ".", "_base", "=", "base", "self", ".", "_po...
https://github.com/ilastik/ilastik/blob/6acd2c554bc517e9c8ddad3623a7aaa2e6970c28/ilastik/applets/counting/countingGuiBoxesInterface.py#L627-L640
frappe/frappe
b64cab6867dfd860f10ccaf41a4ec04bc890b583
frappe/desk/form/utils.py
python
add_comment
(reference_doctype, reference_name, content, comment_email, comment_by)
return doc.as_dict()
allow any logged user to post a comment
allow any logged user to post a comment
[ "allow", "any", "logged", "user", "to", "post", "a", "comment" ]
def add_comment(reference_doctype, reference_name, content, comment_email, comment_by): """allow any logged user to post a comment""" doc = frappe.get_doc(dict( doctype='Comment', reference_doctype=reference_doctype, reference_name=reference_name, comment_email=comment_email, comment_type='Comment', comment_by=comment_by )) reference_doc = frappe.get_doc(reference_doctype, reference_name) doc.content = extract_images_from_html(reference_doc, content, is_private=True) doc.insert(ignore_permissions=True) follow_document(doc.reference_doctype, doc.reference_name, frappe.session.user) return doc.as_dict()
[ "def", "add_comment", "(", "reference_doctype", ",", "reference_name", ",", "content", ",", "comment_email", ",", "comment_by", ")", ":", "doc", "=", "frappe", ".", "get_doc", "(", "dict", "(", "doctype", "=", "'Comment'", ",", "reference_doctype", "=", "refer...
https://github.com/frappe/frappe/blob/b64cab6867dfd860f10ccaf41a4ec04bc890b583/frappe/desk/form/utils.py#L21-L36
Alexey-T/CudaText
6a8b9a974c5d5029c6c273bde83198c83b3a5fb9
app/cudatext.app/Contents/Resources/py/sys/requests/sessions.py
python
Session.mount
(self, prefix, adapter)
Registers a connection adapter to a prefix. Adapters are sorted in descending order by prefix length.
Registers a connection adapter to a prefix.
[ "Registers", "a", "connection", "adapter", "to", "a", "prefix", "." ]
def mount(self, prefix, adapter): """Registers a connection adapter to a prefix. Adapters are sorted in descending order by prefix length. """ self.adapters[prefix] = adapter keys_to_move = [k for k in self.adapters if len(k) < len(prefix)] for key in keys_to_move: self.adapters[key] = self.adapters.pop(key)
[ "def", "mount", "(", "self", ",", "prefix", ",", "adapter", ")", ":", "self", ".", "adapters", "[", "prefix", "]", "=", "adapter", "keys_to_move", "=", "[", "k", "for", "k", "in", "self", ".", "adapters", "if", "len", "(", "k", ")", "<", "len", "...
https://github.com/Alexey-T/CudaText/blob/6a8b9a974c5d5029c6c273bde83198c83b3a5fb9/app/cudatext.app/Contents/Resources/py/sys/requests/sessions.py#L749-L758
micahhausler/container-transform
68223fae98f30b8bb2ce0f02ba9e58afbc80f196
container_transform/chronos.py
python
ChronosTransformer.emit_volumes
(self, volumes)
return [ self._build_volume(volume) for volume in volumes ]
[]
def emit_volumes(self, volumes): return [ self._build_volume(volume) for volume in volumes ]
[ "def", "emit_volumes", "(", "self", ",", "volumes", ")", ":", "return", "[", "self", ".", "_build_volume", "(", "volume", ")", "for", "volume", "in", "volumes", "]" ]
https://github.com/micahhausler/container-transform/blob/68223fae98f30b8bb2ce0f02ba9e58afbc80f196/container_transform/chronos.py#L341-L346
dimagi/commcare-hq
d67ff1d3b4c51fa050c19e60c3253a79d3452a39
corehq/apps/hqadmin/views/system.py
python
_get_submodules
()
return [ line.strip()[1:].split()[1] for line in git.submodule() ]
returns something like ['corehq/apps/hqmedia/static/hqmedia/MediaUploader', ...]
returns something like ['corehq/apps/hqmedia/static/hqmedia/MediaUploader', ...]
[ "returns", "something", "like", "[", "corehq", "/", "apps", "/", "hqmedia", "/", "static", "/", "hqmedia", "/", "MediaUploader", "...", "]" ]
def _get_submodules(): """ returns something like ['corehq/apps/hqmedia/static/hqmedia/MediaUploader', ...] """ import sh git = sh.git.bake(_tty_out=False) return [ line.strip()[1:].split()[1] for line in git.submodule() ]
[ "def", "_get_submodules", "(", ")", ":", "import", "sh", "git", "=", "sh", ".", "git", ".", "bake", "(", "_tty_out", "=", "False", ")", "return", "[", "line", ".", "strip", "(", ")", "[", "1", ":", "]", ".", "split", "(", ")", "[", "1", "]", ...
https://github.com/dimagi/commcare-hq/blob/d67ff1d3b4c51fa050c19e60c3253a79d3452a39/corehq/apps/hqadmin/views/system.py#L252-L262
omz/PythonistaAppTemplate
f560f93f8876d82a21d108977f90583df08d55af
PythonistaAppTemplate/PythonistaKit.framework/pylib_ext/sympy/categories/diagram_drawing.py
python
XypicDiagramDrawer._build_xypic_string
(diagram, grid, morphisms, morphisms_str_info, diagram_format)
return result
Given a collection of :class:`ArrowStringDescription` describing the morphisms of a diagram and the object layout information of a diagram, produces the final Xy-pic picture.
Given a collection of :class:`ArrowStringDescription` describing the morphisms of a diagram and the object layout information of a diagram, produces the final Xy-pic picture.
[ "Given", "a", "collection", "of", ":", "class", ":", "ArrowStringDescription", "describing", "the", "morphisms", "of", "a", "diagram", "and", "the", "object", "layout", "information", "of", "a", "diagram", "produces", "the", "final", "Xy", "-", "pic", "picture...
def _build_xypic_string(diagram, grid, morphisms, morphisms_str_info, diagram_format): """ Given a collection of :class:`ArrowStringDescription` describing the morphisms of a diagram and the object layout information of a diagram, produces the final Xy-pic picture. """ # Build the mapping between objects and morphisms which have # them as domains. object_morphisms = {} for obj in diagram.objects: object_morphisms[obj] = [] for morphism in morphisms: object_morphisms[morphism.domain].append(morphism) result = "\\xymatrix%s{\n" % diagram_format for i in xrange(grid.height): for j in xrange(grid.width): obj = grid[i, j] if obj: result += latex(obj) + " " morphisms_to_draw = object_morphisms[obj] for morphism in morphisms_to_draw: result += str(morphisms_str_info[morphism]) + " " # Don't put the & after the last column. if j < grid.width - 1: result += "& " # Don't put the line break after the last row. if i < grid.height - 1: result += "\\\\" result += "\n" result += "}\n" return result
[ "def", "_build_xypic_string", "(", "diagram", ",", "grid", ",", "morphisms", ",", "morphisms_str_info", ",", "diagram_format", ")", ":", "# Build the mapping between objects and morphisms which have", "# them as domains.", "object_morphisms", "=", "{", "}", "for", "obj", ...
https://github.com/omz/PythonistaAppTemplate/blob/f560f93f8876d82a21d108977f90583df08d55af/PythonistaAppTemplate/PythonistaKit.framework/pylib_ext/sympy/categories/diagram_drawing.py#L2344-L2382
salesforce/cloudsplaining
c932ea61de7b0f12d77bb4144fee343245d68d3f
cloudsplaining/command/scan_multi_account.py
python
scan_accounts
( multi_account_config: MultiAccountConfig, exclusions: Exclusions, role_name: str, write_data_file: bool, profile: Optional[str] = None, output_directory: Optional[str] = None, output_bucket: Optional[str] = None, )
Use this method as a library to scan multiple accounts
Use this method as a library to scan multiple accounts
[ "Use", "this", "method", "as", "a", "library", "to", "scan", "multiple", "accounts" ]
def scan_accounts( multi_account_config: MultiAccountConfig, exclusions: Exclusions, role_name: str, write_data_file: bool, profile: Optional[str] = None, output_directory: Optional[str] = None, output_bucket: Optional[str] = None, ) -> None: """Use this method as a library to scan multiple accounts""" # TODO: Speed improvements? Multithreading? This currently runs sequentially. for target_account_name, target_account_id in multi_account_config.accounts.items(): print( f"{OK_GREEN}Scanning account: {target_account_name} (ID: {target_account_id}){END}" ) results = scan_account( target_account_id=target_account_id, target_role_name=role_name, exclusions=exclusions, profile=profile, ) html_report = HTMLReport( account_id=target_account_id, account_name=target_account_name, results=results, minimize=True, ) rendered_report = html_report.get_html_report() if not output_directory and not output_bucket: raise Exception( "Please supply --output-bucket and/or --output-directory as arguments." ) if output_bucket: s3 = aws_login.get_boto3_resource(service="s3", profile=profile) # Write the HTML file output_file = f"{target_account_name}.html" s3.Object(output_bucket, output_file).put( ACL="bucket-owner-full-control", Body=rendered_report ) utils.print_green( f"Saved the HTML report to: s3://{output_bucket}/{output_file}" ) # Write the JSON data file if write_data_file: output_file = f"{target_account_name}.json" body = json.dumps(results, sort_keys=True, default=str, indent=4) s3.Object(output_bucket, output_file).put( ACL="bucket-owner-full-control", Body=body ) utils.print_green( f"Saved the JSON data to: s3://{output_bucket}/{output_file}" ) if output_directory: # Write the HTML file html_output_file = os.path.join(output_directory, f"{target_account_name}.html") utils.write_file(html_output_file, rendered_report) utils.print_green( f"Saved the HTML report to: {os.path.relpath(html_output_file)}" ) # Write the JSON data file if write_data_file: results_data_file = os.path.join( output_directory, f"{target_account_name}.json" ) results_data_filepath = utils.write_results_data_file( results, results_data_file ) utils.print_green( f"Saved the JSON data to: {os.path.relpath(results_data_filepath)}" )
[ "def", "scan_accounts", "(", "multi_account_config", ":", "MultiAccountConfig", ",", "exclusions", ":", "Exclusions", ",", "role_name", ":", "str", ",", "write_data_file", ":", "bool", ",", "profile", ":", "Optional", "[", "str", "]", "=", "None", ",", "output...
https://github.com/salesforce/cloudsplaining/blob/c932ea61de7b0f12d77bb4144fee343245d68d3f/cloudsplaining/command/scan_multi_account.py#L85-L154
hasgeek/hasjob
38098e8034ee749704dea65394b366e8adc5c71f
hasjob/views/index.py
python
offline
()
return render_template('offline.html.jinja2')
[]
def offline(): return render_template('offline.html.jinja2')
[ "def", "offline", "(", ")", ":", "return", "render_template", "(", "'offline.html.jinja2'", ")" ]
https://github.com/hasgeek/hasjob/blob/38098e8034ee749704dea65394b366e8adc5c71f/hasjob/views/index.py#L1234-L1235
mlflow/mlflow
364aca7daf0fcee3ec407ae0b1b16d9cb3085081
mlflow/utils/autologging_utils/client.py
python
MlflowAutologgingQueueingClient.create_run
( self, experiment_id: str, start_time: Optional[int] = None, tags: Optional[Dict[str, Any]] = None, )
return run_id
Enqueues a CreateRun operation with the specified attributes, returning a `PendingRunId` instance that can be used as input to other client logging APIs (e.g. `log_metrics`, `log_params`, ...). :return: A `PendingRunId` that can be passed as the `run_id` parameter to other client logging APIs, such as `log_params` and `log_metrics`.
Enqueues a CreateRun operation with the specified attributes, returning a `PendingRunId` instance that can be used as input to other client logging APIs (e.g. `log_metrics`, `log_params`, ...).
[ "Enqueues", "a", "CreateRun", "operation", "with", "the", "specified", "attributes", "returning", "a", "PendingRunId", "instance", "that", "can", "be", "used", "as", "input", "to", "other", "client", "logging", "APIs", "(", "e", ".", "g", ".", "log_metrics", ...
def create_run( self, experiment_id: str, start_time: Optional[int] = None, tags: Optional[Dict[str, Any]] = None, ) -> PendingRunId: """ Enqueues a CreateRun operation with the specified attributes, returning a `PendingRunId` instance that can be used as input to other client logging APIs (e.g. `log_metrics`, `log_params`, ...). :return: A `PendingRunId` that can be passed as the `run_id` parameter to other client logging APIs, such as `log_params` and `log_metrics`. """ tags = tags or {} tags = _truncate_dict( tags, max_key_length=MAX_ENTITY_KEY_LENGTH, max_value_length=MAX_TAG_VAL_LENGTH ) run_id = PendingRunId() self._get_pending_operations(run_id).enqueue( create_run=_PendingCreateRun( experiment_id=experiment_id, start_time=start_time, tags=[RunTag(key, str(value)) for key, value in tags.items()], ) ) return run_id
[ "def", "create_run", "(", "self", ",", "experiment_id", ":", "str", ",", "start_time", ":", "Optional", "[", "int", "]", "=", "None", ",", "tags", ":", "Optional", "[", "Dict", "[", "str", ",", "Any", "]", "]", "=", "None", ",", ")", "->", "Pending...
https://github.com/mlflow/mlflow/blob/364aca7daf0fcee3ec407ae0b1b16d9cb3085081/mlflow/utils/autologging_utils/client.py#L134-L160
edgewall/trac
beb3e4eaf1e0a456d801a50a8614ecab06de29fc
trac/wiki/api.py
python
IWikiMacroProvider.get_macros
()
Return an iterable that provides the names of the provided macros.
Return an iterable that provides the names of the provided macros.
[ "Return", "an", "iterable", "that", "provides", "the", "names", "of", "the", "provided", "macros", "." ]
def get_macros(): """Return an iterable that provides the names of the provided macros. """
[ "def", "get_macros", "(", ")", ":" ]
https://github.com/edgewall/trac/blob/beb3e4eaf1e0a456d801a50a8614ecab06de29fc/trac/wiki/api.py#L94-L96
makerbot/ReplicatorG
d6f2b07785a5a5f1e172fb87cb4303b17c575d5d
skein_engines/skeinforge-35/fabmetheus_utilities/euclidean.py
python
getJoinOfXIntersectionIndexes
( xIntersectionIndexList )
return xIntersections
Get joined x intersections from surrounding layers.
Get joined x intersections from surrounding layers.
[ "Get", "joined", "x", "intersections", "from", "surrounding", "layers", "." ]
def getJoinOfXIntersectionIndexes( xIntersectionIndexList ): 'Get joined x intersections from surrounding layers.' xIntersections = [] solidTable = {} solid = False xIntersectionIndexList.sort() for xIntersectionIndex in xIntersectionIndexList: toggleHashtable(solidTable, xIntersectionIndex.index, '') oldSolid = solid solid = len(solidTable) > 0 if oldSolid != solid: xIntersections.append(xIntersectionIndex.x) return xIntersections
[ "def", "getJoinOfXIntersectionIndexes", "(", "xIntersectionIndexList", ")", ":", "xIntersections", "=", "[", "]", "solidTable", "=", "{", "}", "solid", "=", "False", "xIntersectionIndexList", ".", "sort", "(", ")", "for", "xIntersectionIndex", "in", "xIntersectionIn...
https://github.com/makerbot/ReplicatorG/blob/d6f2b07785a5a5f1e172fb87cb4303b17c575d5d/skein_engines/skeinforge-35/fabmetheus_utilities/euclidean.py#L968-L980
deep-spin/entmax
f18bab9318f9d2471a36545ee0b4c97be6d48a87
entmax/root_finding.py
python
sparsemax_bisect
(X, dim=-1, n_iter=50, ensure_sum_one=True)
return SparsemaxBisectFunction.apply(X, dim, n_iter, ensure_sum_one)
sparsemax: normalizing sparse transform (a la softmax), via bisection. Solves the projection: min_p ||x - p||_2 s.t. p >= 0, sum(p) == 1. Parameters ---------- X : torch.Tensor The input tensor. dim : int The dimension along which to apply sparsemax. n_iter : int Number of bisection iterations. For float32, 24 iterations should suffice for machine precision. ensure_sum_one : bool, Whether to divide the result by its sum. If false, the result might sum to close but not exactly 1, which might cause downstream problems. Note: This function does not yet support normalizing along anything except the last dimension. Please use transposing and views to achieve more general behavior. Returns ------- P : torch tensor, same shape as X The projection result, such that P.sum(dim=dim) == 1 elementwise.
sparsemax: normalizing sparse transform (a la softmax), via bisection.
[ "sparsemax", ":", "normalizing", "sparse", "transform", "(", "a", "la", "softmax", ")", "via", "bisection", "." ]
def sparsemax_bisect(X, dim=-1, n_iter=50, ensure_sum_one=True): """sparsemax: normalizing sparse transform (a la softmax), via bisection. Solves the projection: min_p ||x - p||_2 s.t. p >= 0, sum(p) == 1. Parameters ---------- X : torch.Tensor The input tensor. dim : int The dimension along which to apply sparsemax. n_iter : int Number of bisection iterations. For float32, 24 iterations should suffice for machine precision. ensure_sum_one : bool, Whether to divide the result by its sum. If false, the result might sum to close but not exactly 1, which might cause downstream problems. Note: This function does not yet support normalizing along anything except the last dimension. Please use transposing and views to achieve more general behavior. Returns ------- P : torch tensor, same shape as X The projection result, such that P.sum(dim=dim) == 1 elementwise. """ return SparsemaxBisectFunction.apply(X, dim, n_iter, ensure_sum_one)
[ "def", "sparsemax_bisect", "(", "X", ",", "dim", "=", "-", "1", ",", "n_iter", "=", "50", ",", "ensure_sum_one", "=", "True", ")", ":", "return", "SparsemaxBisectFunction", ".", "apply", "(", "X", ",", "dim", ",", "n_iter", ",", "ensure_sum_one", ")" ]
https://github.com/deep-spin/entmax/blob/f18bab9318f9d2471a36545ee0b4c97be6d48a87/entmax/root_finding.py#L180-L212
gammapy/gammapy
735b25cd5bbed35e2004d633621896dcd5295e8b
gammapy/datasets/map.py
python
MapDataset.to_region_map_dataset
(self, region, name=None)
return self.__class__(**kwargs)
Integrate the map dataset in a given region. Counts and background of the dataset are integrated in the given region, taking the safe mask into accounts. The exposure is averaged in the region again taking the safe mask into account. The PSF and energy dispersion kernel are taken at the center of the region. Parameters ---------- region : `~regions.SkyRegion` Region from which to extract the spectrum name : str Name of the new dataset. Returns ------- dataset : `~gammapy.datasets.MapDataset` the resulting reduced dataset
Integrate the map dataset in a given region.
[ "Integrate", "the", "map", "dataset", "in", "a", "given", "region", "." ]
def to_region_map_dataset(self, region, name=None): """Integrate the map dataset in a given region. Counts and background of the dataset are integrated in the given region, taking the safe mask into accounts. The exposure is averaged in the region again taking the safe mask into account. The PSF and energy dispersion kernel are taken at the center of the region. Parameters ---------- region : `~regions.SkyRegion` Region from which to extract the spectrum name : str Name of the new dataset. Returns ------- dataset : `~gammapy.datasets.MapDataset` the resulting reduced dataset """ name = make_name(name) kwargs = {"gti": self.gti, "name": name, "meta_table": self.meta_table} if self.mask_safe: kwargs["mask_safe"] = self.mask_safe.to_region_nd_map(region, func=np.any) if self.mask_fit: kwargs["mask_fit"] = self.mask_fit.to_region_nd_map(region, func=np.any) if self.counts: kwargs["counts"] = self.counts.to_region_nd_map( region, np.sum, weights=self.mask_safe ) if self.stat_type == "cash" and self.background: kwargs["background"] = self.background.to_region_nd_map( region, func=np.sum, weights=self.mask_safe ) if self.exposure: kwargs["exposure"] = self.exposure.to_region_nd_map(region, func=np.mean) region = region.center if region else None # TODO: Compute average psf in region if self.psf: kwargs["psf"] = self.psf.to_region_nd_map(region) # TODO: Compute average edisp in region if self.edisp is not None: kwargs["edisp"] = self.edisp.to_region_nd_map(region) return self.__class__(**kwargs)
[ "def", "to_region_map_dataset", "(", "self", ",", "region", ",", "name", "=", "None", ")", ":", "name", "=", "make_name", "(", "name", ")", "kwargs", "=", "{", "\"gti\"", ":", "self", ".", "gti", ",", "\"name\"", ":", "name", ",", "\"meta_table\"", ":"...
https://github.com/gammapy/gammapy/blob/735b25cd5bbed35e2004d633621896dcd5295e8b/gammapy/datasets/map.py#L1376-L1428
aravindsrinivas/flowpp
737fadb2218c1e2810a91b523498f97def2c30de
flows_imagenet/logistic.py
python
mixlogistic_logcdf
(*, x, prior_logits, means, logscales)
return tf.reduce_logsumexp( tf.nn.log_softmax(prior_logits, axis=-1) + logistic_logcdf( x=tf.expand_dims(x, -1), mean=means, logscale=logscales), axis=-1 )
log cumulative distribution function of a mixture of logistics
log cumulative distribution function of a mixture of logistics
[ "log", "cumulative", "distribution", "function", "of", "a", "mixture", "of", "logistics" ]
def mixlogistic_logcdf(*, x, prior_logits, means, logscales): """log cumulative distribution function of a mixture of logistics""" assert (len(x.get_shape()) + 1 == len(prior_logits.get_shape()) == len(means.get_shape()) == len(logscales.get_shape())) return tf.reduce_logsumexp( tf.nn.log_softmax(prior_logits, axis=-1) + logistic_logcdf( x=tf.expand_dims(x, -1), mean=means, logscale=logscales), axis=-1 )
[ "def", "mixlogistic_logcdf", "(", "*", ",", "x", ",", "prior_logits", ",", "means", ",", "logscales", ")", ":", "assert", "(", "len", "(", "x", ".", "get_shape", "(", ")", ")", "+", "1", "==", "len", "(", "prior_logits", ".", "get_shape", "(", ")", ...
https://github.com/aravindsrinivas/flowpp/blob/737fadb2218c1e2810a91b523498f97def2c30de/flows_imagenet/logistic.py#L64-L72
Antergos/Cnchi
13ac2209da9432d453e0097cf48a107640b563a9
src/pages/advanced.py
python
InstallationAdvanced.ssd_cell_toggled
(self, _widget, path)
User confirms selected disk is a ssd disk (or not)
User confirms selected disk is a ssd disk (or not)
[ "User", "confirms", "selected", "disk", "is", "a", "ssd", "disk", "(", "or", "not", ")" ]
def ssd_cell_toggled(self, _widget, path): """ User confirms selected disk is a ssd disk (or not) """ disk_path = self.partition_treeview.store[path][PartitionTreeview.COL_PATH] self.ssd[disk_path] = self.partition_treeview.store[path][PartitionTreeview.COL_SSD_ACTIVE]
[ "def", "ssd_cell_toggled", "(", "self", ",", "_widget", ",", "path", ")", ":", "disk_path", "=", "self", ".", "partition_treeview", ".", "store", "[", "path", "]", "[", "PartitionTreeview", ".", "COL_PATH", "]", "self", ".", "ssd", "[", "disk_path", "]", ...
https://github.com/Antergos/Cnchi/blob/13ac2209da9432d453e0097cf48a107640b563a9/src/pages/advanced.py#L167-L170
Podshot/MCEdit-Unified
90abfb170c65b877ac67193e717fa3a3ded635dd
pymclevel/cachefunc.py
python
lru_cache
(maxsize=100)
return decorating_function
Least-recently-used cache decorator. Arguments to the cached function must be hashable. Cache performance statistics stored in f.hits and f.misses. Clear the cache with f.clear(). http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used
Least-recently-used cache decorator.
[ "Least", "-", "recently", "-", "used", "cache", "decorator", "." ]
def lru_cache(maxsize=100): '''Least-recently-used cache decorator. Arguments to the cached function must be hashable. Cache performance statistics stored in f.hits and f.misses. Clear the cache with f.clear(). http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used ''' maxqueue = maxsize * 10 def decorating_function(user_function, len=len, iter=iter, tuple=tuple, sorted=sorted, KeyError=KeyError): cache = {} # mapping of args to results queue = collections.deque() # order that keys have been used refcount = Counter() # times each key is in the queue sentinel = object() # marker for looping around the queue kwd_mark = object() # separate positional and keyword args # lookup optimizations (ugly but fast) queue_append, queue_popleft = queue.append, queue.popleft queue_appendleft, queue_pop = queue.appendleft, queue.pop @functools.wraps(user_function) def wrapper(*args, **kwds): # cache key records both positional and keyword args key = args if kwds: key += (kwd_mark,) + tuple(sorted(kwds.items())) # record recent use of this key queue_append(key) refcount[key] += 1 # get cache entry or compute if not found try: result = cache[key] wrapper.hits += 1 except KeyError: result = user_function(*args, **kwds) cache[key] = result wrapper.misses += 1 # purge least recently used cache entry if len(cache) > maxsize: key = queue_popleft() refcount[key] -= 1 while refcount[key]: key = queue_popleft() refcount[key] -= 1 del cache[key], refcount[key] # periodically compact the queue by eliminating duplicate keys # while preserving order of most recent access if len(queue) > maxqueue: refcount.clear() queue_appendleft(sentinel) for key in ifilterfalse(refcount.__contains__, iter(queue_pop, sentinel)): queue_appendleft(key) refcount[key] = 1 return result def clear(): cache.clear() queue.clear() refcount.clear() wrapper.hits = wrapper.misses = 0 wrapper.hits = wrapper.misses = 0 wrapper.clear = clear return wrapper return decorating_function
[ "def", "lru_cache", "(", "maxsize", "=", "100", ")", ":", "maxqueue", "=", "maxsize", "*", "10", "def", "decorating_function", "(", "user_function", ",", "len", "=", "len", ",", "iter", "=", "iter", ",", "tuple", "=", "tuple", ",", "sorted", "=", "sort...
https://github.com/Podshot/MCEdit-Unified/blob/90abfb170c65b877ac67193e717fa3a3ded635dd/pymclevel/cachefunc.py#L17-L91
pvlib/pvlib-python
1ab0eb20f9cd9fb9f7a0ddf35f81283f2648e34a
pvlib/pvsystem.py
python
PVSystem.get_cell_temperature
(self, poa_global, temp_air, wind_speed, model, effective_irradiance=None)
return tuple( array.get_cell_temperature(poa_global, temp_air, wind_speed, model, effective_irradiance) for array, poa_global, temp_air, wind_speed, effective_irradiance in zip( self.arrays, poa_global, temp_air, wind_speed, effective_irradiance ) )
Determine cell temperature using the method specified by ``model``. Parameters ---------- poa_global : numeric or tuple of numeric Total incident irradiance in W/m^2. temp_air : numeric or tuple of numeric Ambient dry bulb temperature in degrees C. wind_speed : numeric or tuple of numeric Wind speed in m/s. model : str Supported models include ``'sapm'``, ``'pvsyst'``, ``'faiman'``, ``'fuentes'``, and ``'noct_sam'`` effective_irradiance : numeric or tuple of numeric, optional The irradiance that is converted to photocurrent in W/m^2. Only used for some models. Returns ------- numeric or tuple of numeric Values in degrees C. See Also -------- Array.get_cell_temperature Notes ----- The `temp_air` and `wind_speed` parameters may be passed as tuples to provide different values for each Array in the system. If passed as a tuple the length must be the same as the number of Arrays. If not passed as a tuple then the same value is used for each Array.
Determine cell temperature using the method specified by ``model``.
[ "Determine", "cell", "temperature", "using", "the", "method", "specified", "by", "model", "." ]
def get_cell_temperature(self, poa_global, temp_air, wind_speed, model, effective_irradiance=None): """ Determine cell temperature using the method specified by ``model``. Parameters ---------- poa_global : numeric or tuple of numeric Total incident irradiance in W/m^2. temp_air : numeric or tuple of numeric Ambient dry bulb temperature in degrees C. wind_speed : numeric or tuple of numeric Wind speed in m/s. model : str Supported models include ``'sapm'``, ``'pvsyst'``, ``'faiman'``, ``'fuentes'``, and ``'noct_sam'`` effective_irradiance : numeric or tuple of numeric, optional The irradiance that is converted to photocurrent in W/m^2. Only used for some models. Returns ------- numeric or tuple of numeric Values in degrees C. See Also -------- Array.get_cell_temperature Notes ----- The `temp_air` and `wind_speed` parameters may be passed as tuples to provide different values for each Array in the system. If passed as a tuple the length must be the same as the number of Arrays. If not passed as a tuple then the same value is used for each Array. """ poa_global = self._validate_per_array(poa_global) temp_air = self._validate_per_array(temp_air, system_wide=True) wind_speed = self._validate_per_array(wind_speed, system_wide=True) # Not used for all models, but Array.get_cell_temperature handles it effective_irradiance = self._validate_per_array(effective_irradiance, system_wide=True) return tuple( array.get_cell_temperature(poa_global, temp_air, wind_speed, model, effective_irradiance) for array, poa_global, temp_air, wind_speed, effective_irradiance in zip( self.arrays, poa_global, temp_air, wind_speed, effective_irradiance ) )
[ "def", "get_cell_temperature", "(", "self", ",", "poa_global", ",", "temp_air", ",", "wind_speed", ",", "model", ",", "effective_irradiance", "=", "None", ")", ":", "poa_global", "=", "self", ".", "_validate_per_array", "(", "poa_global", ")", "temp_air", "=", ...
https://github.com/pvlib/pvlib-python/blob/1ab0eb20f9cd9fb9f7a0ddf35f81283f2648e34a/pvlib/pvsystem.py#L426-L481
PaddlePaddle/PaddleX
2bab73f81ab54e328204e7871e6ae4a82e719f5d
paddlex/ppdet/engine/callbacks.py
python
LogPrinter.on_epoch_end
(self, status)
[]
def on_epoch_end(self, status): if dist.get_world_size() < 2 or dist.get_rank() == 0: mode = status['mode'] if mode == 'eval': sample_num = status['sample_num'] cost_time = status['cost_time'] logger.info('Total sample number: {}, averge FPS: {}'.format( sample_num, sample_num / cost_time))
[ "def", "on_epoch_end", "(", "self", ",", "status", ")", ":", "if", "dist", ".", "get_world_size", "(", ")", "<", "2", "or", "dist", ".", "get_rank", "(", ")", "==", "0", ":", "mode", "=", "status", "[", "'mode'", "]", "if", "mode", "==", "'eval'", ...
https://github.com/PaddlePaddle/PaddleX/blob/2bab73f81ab54e328204e7871e6ae4a82e719f5d/paddlex/ppdet/engine/callbacks.py#L150-L157
WikiTeam/wikiteam
7f1f9985f667c417501f0dc872ab4fe416b6acda
wikiteam/mediawiki.py
python
mwSaveSiteInfo
(config={})
Save a file with site info
Save a file with site info
[ "Save", "a", "file", "with", "site", "info" ]
def mwSaveSiteInfo(config={}): """ Save a file with site info """ if config['api']: if os.path.exists('%s/siteinfo.json' % (config['path'])): sys.stderr.write('siteinfo.json exists, do not overwrite') else: sys.stderr.write('Downloading site info as siteinfo.json') # MediaWiki 1.13+ raw = wikiteam.getURL(url=config['api'], data={ 'action': 'query', 'meta': 'siteinfo', 'siprop': 'general|namespaces|statistics|dbrepllag|interwikimap|namespacealiases|specialpagealiases|usergroups|extensions|skins|magicwords|fileextensions|rightsinfo', 'sinumberingroup': 1, 'format': 'json'}) wikiteam.delay(config=config) # MediaWiki 1.11-1.12 if not 'query' in wikiteam.getJSON(raw): raw = wikiteam.getURL(url=config['api'], data={ 'action': 'query', 'meta': 'siteinfo', 'siprop': 'general|namespaces|statistics|dbrepllag|interwikimap', 'format': 'json'}) # MediaWiki 1.8-1.10 if not 'query' in wikiteam.getJSON(raw): raw = wikiteam.getURL(url=config['api'], data={ 'action': 'query', 'meta': 'siteinfo', 'siprop': 'general|namespaces', 'format': 'json'}) result = wikiteam.getJSON(raw) wikiteam.delay(config=config) with open('%s/siteinfo.json' % (config['path']), 'w') as outfile: outfile.write(json.dumps(result, indent=4, sort_keys=True))
[ "def", "mwSaveSiteInfo", "(", "config", "=", "{", "}", ")", ":", "if", "config", "[", "'api'", "]", ":", "if", "os", ".", "path", ".", "exists", "(", "'%s/siteinfo.json'", "%", "(", "config", "[", "'path'", "]", ")", ")", ":", "sys", ".", "stderr",...
https://github.com/WikiTeam/wikiteam/blob/7f1f9985f667c417501f0dc872ab4fe416b6acda/wikiteam/mediawiki.py#L1022-L1056
testerSunshine/12306
a495af88346a0d794493c6030f6a6207debb5824
inter/GetSuccessRate.py
python
getSuccessRate.data_apr
(self)
return data
secretList 9vqa9%2B%2F%2Fsdozmm22hpSeDTGqRUwSuA2D0r%2BmU%2BLZj7MK7CDuf5Ep1xpxl4Dyxfmoah%2BaB9TZSesU%0AkxBbo5oNgR1vqMfvq66VP0T7tpQtH%2BbVGBz1FolZG8jDD%2FHqnz%2FnvdBP416Og6WGS14O%2F3iBSwT8%0AkRPsNF0Vq0U082g0tlJtP%2BPn7TzW3z7TDCceMJIjFcfEOA%2BW%2BuK%2Bpy6jCQMv0TmlkXf5aKcGnE02%0APuv4I8nF%2BOWjWzv9CrJyiCZiWaXd%2Bi7p69V3a9dhF787UgS660%2BqKRFB4RLwAfic3MkAlfpGWhMY%0ACfARVQ%3D%3D#O _json_att 候补一次只能补一个座位,默认取TICKET_TYPE第一个 :return:
secretList 9vqa9%2B%2F%2Fsdozmm22hpSeDTGqRUwSuA2D0r%2BmU%2BLZj7MK7CDuf5Ep1xpxl4Dyxfmoah%2BaB9TZSesU%0AkxBbo5oNgR1vqMfvq66VP0T7tpQtH%2BbVGBz1FolZG8jDD%2FHqnz%2FnvdBP416Og6WGS14O%2F3iBSwT8%0AkRPsNF0Vq0U082g0tlJtP%2BPn7TzW3z7TDCceMJIjFcfEOA%2BW%2BuK%2Bpy6jCQMv0TmlkXf5aKcGnE02%0APuv4I8nF%2BOWjWzv9CrJyiCZiWaXd%2Bi7p69V3a9dhF787UgS660%2BqKRFB4RLwAfic3MkAlfpGWhMY%0ACfARVQ%3D%3D#O _json_att 候补一次只能补一个座位,默认取TICKET_TYPE第一个 :return:
[ "secretList", "9vqa9%2B%2F%2Fsdozmm22hpSeDTGqRUwSuA2D0r%2BmU%2BLZj7MK7CDuf5Ep1xpxl4Dyxfmoah%2BaB9TZSesU%0AkxBbo5oNgR1vqMfvq66VP0T7tpQtH%2BbVGBz1FolZG8jDD%2FHqnz%2FnvdBP416Og6WGS14O%2F3iBSwT8%0AkRPsNF0Vq0U082g0tlJtP%2BPn7TzW3z7TDCceMJIjFcfEOA%2BW%2BuK%2Bpy6jCQMv0TmlkXf5aKcGnE02%0APuv4I8nF%2BOWjWzv9CrJyiCZiWaXd%2Bi...
def data_apr(self): """ secretList 9vqa9%2B%2F%2Fsdozmm22hpSeDTGqRUwSuA2D0r%2BmU%2BLZj7MK7CDuf5Ep1xpxl4Dyxfmoah%2BaB9TZSesU%0AkxBbo5oNgR1vqMfvq66VP0T7tpQtH%2BbVGBz1FolZG8jDD%2FHqnz%2FnvdBP416Og6WGS14O%2F3iBSwT8%0AkRPsNF0Vq0U082g0tlJtP%2BPn7TzW3z7TDCceMJIjFcfEOA%2BW%2BuK%2Bpy6jCQMv0TmlkXf5aKcGnE02%0APuv4I8nF%2BOWjWzv9CrJyiCZiWaXd%2Bi7p69V3a9dhF787UgS660%2BqKRFB4RLwAfic3MkAlfpGWhMY%0ACfARVQ%3D%3D#O _json_att 候补一次只能补一个座位,默认取TICKET_TYPE第一个 :return: """ ticker = TickerConfig.PASSENGER_TICKER_STR.get(TickerConfig.SET_TYPE[0]) data = OrderedDict() data["successSecret"] = f"{self.secretList}#{ticker}" data["_json_att"] = "" return data
[ "def", "data_apr", "(", "self", ")", ":", "ticker", "=", "TickerConfig", ".", "PASSENGER_TICKER_STR", ".", "get", "(", "TickerConfig", ".", "SET_TYPE", "[", "0", "]", ")", "data", "=", "OrderedDict", "(", ")", "data", "[", "\"successSecret\"", "]", "=", ...
https://github.com/testerSunshine/12306/blob/a495af88346a0d794493c6030f6a6207debb5824/inter/GetSuccessRate.py#L17-L29
angr/angr
4b04d56ace135018083d36d9083805be8146688b
angr/misc/bug_report.py
python
print_native_info
()
[]
def print_native_info(): print("######### Native Module Info ##########") for module, path in native_modules.items(): try: import_module(module) print("%s: %s" % (module, str(eval(path)))) except: print("%s: NOT FOUND" % (module))
[ "def", "print_native_info", "(", ")", ":", "print", "(", "\"######### Native Module Info ##########\"", ")", "for", "module", ",", "path", "in", "native_modules", ".", "items", "(", ")", ":", "try", ":", "import_module", "(", "module", ")", "print", "(", "\"%s...
https://github.com/angr/angr/blob/4b04d56ace135018083d36d9083805be8146688b/angr/misc/bug_report.py#L101-L108
ajinabraham/OWASP-Xenotix-XSS-Exploit-Framework
cb692f527e4e819b6c228187c5702d990a180043
external/Scripting Engine/Xenotix Python Scripting Engine/bin/x86/Debug/Lib/ctypes/macholib/framework.py
python
framework_info
(filename)
return is_framework.groupdict()
A framework name can take one of the following four forms: Location/Name.framework/Versions/SomeVersion/Name_Suffix Location/Name.framework/Versions/SomeVersion/Name Location/Name.framework/Name_Suffix Location/Name.framework/Name returns None if not found, or a mapping equivalent to: dict( location='Location', name='Name.framework/Versions/SomeVersion/Name_Suffix', shortname='Name', version='SomeVersion', suffix='Suffix', ) Note that SomeVersion and Suffix are optional and may be None if not present
A framework name can take one of the following four forms: Location/Name.framework/Versions/SomeVersion/Name_Suffix Location/Name.framework/Versions/SomeVersion/Name Location/Name.framework/Name_Suffix Location/Name.framework/Name
[ "A", "framework", "name", "can", "take", "one", "of", "the", "following", "four", "forms", ":", "Location", "/", "Name", ".", "framework", "/", "Versions", "/", "SomeVersion", "/", "Name_Suffix", "Location", "/", "Name", ".", "framework", "/", "Versions", ...
def framework_info(filename): """ A framework name can take one of the following four forms: Location/Name.framework/Versions/SomeVersion/Name_Suffix Location/Name.framework/Versions/SomeVersion/Name Location/Name.framework/Name_Suffix Location/Name.framework/Name returns None if not found, or a mapping equivalent to: dict( location='Location', name='Name.framework/Versions/SomeVersion/Name_Suffix', shortname='Name', version='SomeVersion', suffix='Suffix', ) Note that SomeVersion and Suffix are optional and may be None if not present """ is_framework = STRICT_FRAMEWORK_RE.match(filename) if not is_framework: return None return is_framework.groupdict()
[ "def", "framework_info", "(", "filename", ")", ":", "is_framework", "=", "STRICT_FRAMEWORK_RE", ".", "match", "(", "filename", ")", "if", "not", "is_framework", ":", "return", "None", "return", "is_framework", ".", "groupdict", "(", ")" ]
https://github.com/ajinabraham/OWASP-Xenotix-XSS-Exploit-Framework/blob/cb692f527e4e819b6c228187c5702d990a180043/external/Scripting Engine/Xenotix Python Scripting Engine/bin/x86/Debug/Lib/ctypes/macholib/framework.py#L22-L45
keiffster/program-y
8c99b56f8c32f01a7b9887b5daae9465619d0385
src/programy/clients/events/tcpsocket/client.py
python
ClientConnection.receive_data
(self)
return json.loads(json_data, encoding="utf-8")
[]
def receive_data(self): json_data = self._clientsocket.recv(self._max_buffer).decode() YLogger.debug(self, "Received: %s", json_data) return json.loads(json_data, encoding="utf-8")
[ "def", "receive_data", "(", "self", ")", ":", "json_data", "=", "self", ".", "_clientsocket", ".", "recv", "(", "self", ".", "_max_buffer", ")", ".", "decode", "(", ")", "YLogger", ".", "debug", "(", "self", ",", "\"Received: %s\"", ",", "json_data", ")"...
https://github.com/keiffster/program-y/blob/8c99b56f8c32f01a7b9887b5daae9465619d0385/src/programy/clients/events/tcpsocket/client.py#L33-L36
securesystemslab/zippy
ff0e84ac99442c2c55fe1d285332cfd4e185e089
zippy/lib-python/3/urllib/request.py
python
Request.get_host
(self)
return self.host
[]
def get_host(self): return self.host
[ "def", "get_host", "(", "self", ")", ":", "return", "self", ".", "host" ]
https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/lib-python/3/urllib/request.py#L230-L231
git-cola/git-cola
b48b8028e0c3baf47faf7b074b9773737358163d
cola/cmds.py
python
PrepareCommitMessageHook.__init__
(self, context)
[]
def __init__(self, context): super(PrepareCommitMessageHook, self).__init__(context) self.old_commitmsg = self.model.commitmsg
[ "def", "__init__", "(", "self", ",", "context", ")", ":", "super", "(", "PrepareCommitMessageHook", ",", "self", ")", ".", "__init__", "(", "context", ")", "self", ".", "old_commitmsg", "=", "self", ".", "model", ".", "commitmsg" ]
https://github.com/git-cola/git-cola/blob/b48b8028e0c3baf47faf7b074b9773737358163d/cola/cmds.py#L1594-L1596
mbj4668/pyang
97523476e7ada8609d27fd47880e1b5061073dc3
pyang/statements.py
python
has_type
(typestmt, names)
return None
Return type with name if `type` has name as one of its base types, and name is in the `names` list. otherwise, return None.
Return type with name if `type` has name as one of its base types, and name is in the `names` list. otherwise, return None.
[ "Return", "type", "with", "name", "if", "type", "has", "name", "as", "one", "of", "its", "base", "types", "and", "name", "is", "in", "the", "names", "list", ".", "otherwise", "return", "None", "." ]
def has_type(typestmt, names): """Return type with name if `type` has name as one of its base types, and name is in the `names` list. otherwise, return None.""" if typestmt.arg in names: return typestmt for t in typestmt.search('type'): # check all union's member types r = has_type(t, names) if r is not None: return r typedef = getattr(typestmt, 'i_typedef', None) if typedef is not None and getattr(typedef, 'i_is_circular', None) is False: t = typedef.search_one('type') if t is not None: return has_type(t, names) return None
[ "def", "has_type", "(", "typestmt", ",", "names", ")", ":", "if", "typestmt", ".", "arg", "in", "names", ":", "return", "typestmt", "for", "t", "in", "typestmt", ".", "search", "(", "'type'", ")", ":", "# check all union's member types", "r", "=", "has_typ...
https://github.com/mbj4668/pyang/blob/97523476e7ada8609d27fd47880e1b5061073dc3/pyang/statements.py#L2451-L2465
lvpengyuan/masktextspotter.caffe2
da99ef31f5ccb4de5248bb881d5b4a291910c8ae
lib/modeling/detector.py
python
DetectionModelHelper.UpdateWorkspaceLr
(self, cur_iter)
return new_lr
Updates the model's current learning rate and the workspace (learning rate and update history/momentum blobs).
Updates the model's current learning rate and the workspace (learning rate and update history/momentum blobs).
[ "Updates", "the", "model", "s", "current", "learning", "rate", "and", "the", "workspace", "(", "learning", "rate", "and", "update", "history", "/", "momentum", "blobs", ")", "." ]
def UpdateWorkspaceLr(self, cur_iter): """Updates the model's current learning rate and the workspace (learning rate and update history/momentum blobs). """ # The workspace is the one source of truth for the lr # The lr is always the same on all GPUs cur_lr = workspace.FetchBlob('gpu_0/lr')[0] new_lr = lr_policy.get_lr_at_iter(cur_iter) # There are no type conversions between the lr in Python and the lr in # the GPU (both are float32), so exact comparision is ok if cur_lr != new_lr: ratio = _get_lr_change_ratio(cur_lr, new_lr) if ratio > cfg.SOLVER.LOG_LR_CHANGE_THRESHOLD: logger.info( 'Changing learning rate {:.6f} -> {:.6f} at iter {:d}'. format(cur_lr, new_lr, cur_iter)) self._SetNewLr(cur_lr, new_lr) return new_lr
[ "def", "UpdateWorkspaceLr", "(", "self", ",", "cur_iter", ")", ":", "# The workspace is the one source of truth for the lr", "# The lr is always the same on all GPUs", "cur_lr", "=", "workspace", ".", "FetchBlob", "(", "'gpu_0/lr'", ")", "[", "0", "]", "new_lr", "=", "l...
https://github.com/lvpengyuan/masktextspotter.caffe2/blob/da99ef31f5ccb4de5248bb881d5b4a291910c8ae/lib/modeling/detector.py#L596-L613
Tautulli/Tautulli
2410eb33805aaac4bd1c5dad0f71e4f15afaf742
lib/rumps/rumps.py
python
SliderMenuItem.__repr__
(self)
return '<{0}: [value: {1}; callback: {2}]>'.format( type(self).__name__, self.value, repr(self.callback) )
[]
def __repr__(self): return '<{0}: [value: {1}; callback: {2}]>'.format( type(self).__name__, self.value, repr(self.callback) )
[ "def", "__repr__", "(", "self", ")", ":", "return", "'<{0}: [value: {1}; callback: {2}]>'", ".", "format", "(", "type", "(", "self", ")", ".", "__name__", ",", "self", ".", "value", ",", "repr", "(", "self", ".", "callback", ")", ")" ]
https://github.com/Tautulli/Tautulli/blob/2410eb33805aaac4bd1c5dad0f71e4f15afaf742/lib/rumps/rumps.py#L755-L760
annoviko/pyclustering
bf4f51a472622292627ec8c294eb205585e50f52
pyclustering/utils/__init__.py
python
draw_dynamics_set
(dynamics, xtitle=None, ytitle=None, xlim=None, ylim=None, xlabels=False, ylabels=False)
! @brief Draws dynamic of each neuron (oscillator) in an oscillatory network. @param[in] dynamics (list): List of network outputs that are represented by values of output of oscillators (used by y axis). @param[in] xtitle (string): Title for Y. @param[in] ytitle (string): Title for X. @param[in] xlim (double): X limit. @param[in] ylim (double): Y limit. @param[in] xlabels (bool): If True - shows X labels. @param[in] ylabels (bool): If True - shows Y labels.
!
[ "!" ]
def draw_dynamics_set(dynamics, xtitle=None, ytitle=None, xlim=None, ylim=None, xlabels=False, ylabels=False): """! @brief Draws dynamic of each neuron (oscillator) in an oscillatory network. @param[in] dynamics (list): List of network outputs that are represented by values of output of oscillators (used by y axis). @param[in] xtitle (string): Title for Y. @param[in] ytitle (string): Title for X. @param[in] xlim (double): X limit. @param[in] ylim (double): Y limit. @param[in] xlabels (bool): If True - shows X labels. @param[in] ylabels (bool): If True - shows Y labels. """ # Calculate edge for comfortable representation. number_dynamics = len(dynamics) if number_dynamics == 1: figure, _ = draw_dynamics(dynamics[0][0], dynamics[0][1], xtitle, ytitle, xlim, ylim, xlabels, ylabels) plt.close(figure) return number_cols = int(numpy.ceil(number_dynamics ** 0.5)) number_rows = int(numpy.ceil(number_dynamics / number_cols)) real_index = 0, 0 double_indexer = True if (number_cols == 1) or (number_rows == 1): real_index = 0 double_indexer = False figure, axarr = plt.subplots(number_rows, number_cols) #plt.setp([ax for ax in axarr], visible = False); for dynamic in dynamics: axarr[real_index] = draw_dynamics(dynamic[0], dynamic[1], xtitle, ytitle, xlim, ylim, xlabels, ylabels, axis=axarr[real_index]) #plt.setp(axarr[real_index], visible = True); if double_indexer is True: real_index = real_index[0], real_index[1] + 1 if real_index[1] >= number_cols: real_index = real_index[0] + 1, 0 else: real_index += 1 plt.show() plt.close(figure)
[ "def", "draw_dynamics_set", "(", "dynamics", ",", "xtitle", "=", "None", ",", "ytitle", "=", "None", ",", "xlim", "=", "None", ",", "ylim", "=", "None", ",", "xlabels", "=", "False", ",", "ylabels", "=", "False", ")", ":", "# Calculate edge for comfortable...
https://github.com/annoviko/pyclustering/blob/bf4f51a472622292627ec8c294eb205585e50f52/pyclustering/utils/__init__.py#L932-L976
plotly/plotly.py
cfad7862594b35965c0e000813bd7805e8494a5b
packages/python/plotly/plotly/graph_objs/contourcarpet/_colorbar.py
python
ColorBar.lenmode
(self)
return self["lenmode"]
Determines whether this color bar's length (i.e. the measure in the color variation direction) is set in units of plot "fraction" or in *pixels. Use `len` to set the value. The 'lenmode' property is an enumeration that may be specified as: - One of the following enumeration values: ['fraction', 'pixels'] Returns ------- Any
Determines whether this color bar's length (i.e. the measure in the color variation direction) is set in units of plot "fraction" or in *pixels. Use `len` to set the value. The 'lenmode' property is an enumeration that may be specified as: - One of the following enumeration values: ['fraction', 'pixels']
[ "Determines", "whether", "this", "color", "bar", "s", "length", "(", "i", ".", "e", ".", "the", "measure", "in", "the", "color", "variation", "direction", ")", "is", "set", "in", "units", "of", "plot", "fraction", "or", "in", "*", "pixels", ".", "Use",...
def lenmode(self): """ Determines whether this color bar's length (i.e. the measure in the color variation direction) is set in units of plot "fraction" or in *pixels. Use `len` to set the value. The 'lenmode' property is an enumeration that may be specified as: - One of the following enumeration values: ['fraction', 'pixels'] Returns ------- Any """ return self["lenmode"]
[ "def", "lenmode", "(", "self", ")", ":", "return", "self", "[", "\"lenmode\"", "]" ]
https://github.com/plotly/plotly.py/blob/cfad7862594b35965c0e000813bd7805e8494a5b/packages/python/plotly/plotly/graph_objs/contourcarpet/_colorbar.py#L287-L301
SpaceNetChallenge/SpaceNet_Off_Nadir_Solutions
014c4ca27a70b5907a183e942228004c989dcbe4
number13/number13/src/Mask_RCNN/mrcnn/model.py
python
log2_graph
(x)
return tf.log(x) / tf.log(2.0)
Implementatin of Log2. TF doesn't have a native implemenation.
Implementatin of Log2. TF doesn't have a native implemenation.
[ "Implementatin", "of", "Log2", ".", "TF", "doesn", "t", "have", "a", "native", "implemenation", "." ]
def log2_graph(x): """Implementatin of Log2. TF doesn't have a native implemenation.""" return tf.log(x) / tf.log(2.0)
[ "def", "log2_graph", "(", "x", ")", ":", "return", "tf", ".", "log", "(", "x", ")", "/", "tf", ".", "log", "(", "2.0", ")" ]
https://github.com/SpaceNetChallenge/SpaceNet_Off_Nadir_Solutions/blob/014c4ca27a70b5907a183e942228004c989dcbe4/number13/number13/src/Mask_RCNN/mrcnn/model.py#L336-L338
holzschu/Carnets
44effb10ddfc6aa5c8b0687582a724ba82c6b547
Library/lib/python3.7/idlelib/config_key.py
python
GetKeysDialog.bind_ok
(self, keys)
Return True if Tcl accepts the new keys else show message.
Return True if Tcl accepts the new keys else show message.
[ "Return", "True", "if", "Tcl", "accepts", "the", "new", "keys", "else", "show", "message", "." ]
def bind_ok(self, keys): "Return True if Tcl accepts the new keys else show message." try: binding = self.bind(keys, lambda: None) except TclError as err: self.showerror( title=self.keyerror_title, parent=self, message=(f'The entered key sequence is not accepted.\n\n' f'Error: {err}')) return False else: self.unbind(keys, binding) return True
[ "def", "bind_ok", "(", "self", ",", "keys", ")", ":", "try", ":", "binding", "=", "self", ".", "bind", "(", "keys", ",", "lambda", ":", "None", ")", "except", "TclError", "as", "err", ":", "self", ".", "showerror", "(", "title", "=", "self", ".", ...
https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/idlelib/config_key.py#L279-L292
getsentry/sentry
83b1f25aac3e08075e0e2495bc29efaf35aca18a
src/sentry/stacktraces/processing.py
python
_has_system_frames
(frames)
return bool(system_frames) and len(frames) != system_frames
Determines whether there are any frames in the stacktrace with in_app=false.
Determines whether there are any frames in the stacktrace with in_app=false.
[ "Determines", "whether", "there", "are", "any", "frames", "in", "the", "stacktrace", "with", "in_app", "=", "false", "." ]
def _has_system_frames(frames): """ Determines whether there are any frames in the stacktrace with in_app=false. """ system_frames = 0 for frame in frames: if not frame.get("in_app"): system_frames += 1 return bool(system_frames) and len(frames) != system_frames
[ "def", "_has_system_frames", "(", "frames", ")", ":", "system_frames", "=", "0", "for", "frame", "in", "frames", ":", "if", "not", "frame", ".", "get", "(", "\"in_app\"", ")", ":", "system_frames", "+=", "1", "return", "bool", "(", "system_frames", ")", ...
https://github.com/getsentry/sentry/blob/83b1f25aac3e08075e0e2495bc29efaf35aca18a/src/sentry/stacktraces/processing.py#L211-L220
conan7882/adversarial-autoencoders
4960f252784a7dd2fbe203d7dad65938b57ee9c2
src/models/layers.py
python
drop_out
(layer_dict, is_training, inputs=None, keep_prob=0.5)
return layer_dict['cur_input']
[]
def drop_out(layer_dict, is_training, inputs=None, keep_prob=0.5): if inputs is None: inputs = layer_dict['cur_input'] if is_training: layer_dict['cur_input'] = tf.nn.dropout(inputs, keep_prob=keep_prob) else: layer_dict['cur_input'] = inputs return layer_dict['cur_input']
[ "def", "drop_out", "(", "layer_dict", ",", "is_training", ",", "inputs", "=", "None", ",", "keep_prob", "=", "0.5", ")", ":", "if", "inputs", "is", "None", ":", "inputs", "=", "layer_dict", "[", "'cur_input'", "]", "if", "is_training", ":", "layer_dict", ...
https://github.com/conan7882/adversarial-autoencoders/blob/4960f252784a7dd2fbe203d7dad65938b57ee9c2/src/models/layers.py#L309-L316
Jenyay/outwiker
50530cf7b3f71480bb075b2829bc0669773b835b
plugins/webpage/webpage/libs/bs4/element.py
python
Tag.__init__
(self, parser=None, builder=None, name=None, namespace=None, prefix=None, attrs=None, parent=None, previous=None, is_xml=None, sourceline=None, sourcepos=None, can_be_empty_element=None, cdata_list_attributes=None, preserve_whitespace_tags=None )
Basic constructor. :param parser: A BeautifulSoup object. :param builder: A TreeBuilder. :param name: The name of the tag. :param namespace: The URI of this Tag's XML namespace, if any. :param prefix: The prefix for this Tag's XML namespace, if any. :param attrs: A dictionary of this Tag's attribute values. :param parent: The PageElement to use as this Tag's parent. :param previous: The PageElement that was parsed immediately before this tag. :param is_xml: If True, this is an XML tag. Otherwise, this is an HTML tag. :param sourceline: The line number where this tag was found in its source document. :param sourcepos: The character position within `sourceline` where this tag was found. :param can_be_empty_element: If True, this tag should be represented as <tag/>. If False, this tag should be represented as <tag></tag>. :param cdata_list_attributes: A list of attributes whose values should be treated as CDATA if they ever show up on this tag. :param preserve_whitespace_tags: A list of tag names whose contents should have their whitespace preserved.
Basic constructor.
[ "Basic", "constructor", "." ]
def __init__(self, parser=None, builder=None, name=None, namespace=None, prefix=None, attrs=None, parent=None, previous=None, is_xml=None, sourceline=None, sourcepos=None, can_be_empty_element=None, cdata_list_attributes=None, preserve_whitespace_tags=None ): """Basic constructor. :param parser: A BeautifulSoup object. :param builder: A TreeBuilder. :param name: The name of the tag. :param namespace: The URI of this Tag's XML namespace, if any. :param prefix: The prefix for this Tag's XML namespace, if any. :param attrs: A dictionary of this Tag's attribute values. :param parent: The PageElement to use as this Tag's parent. :param previous: The PageElement that was parsed immediately before this tag. :param is_xml: If True, this is an XML tag. Otherwise, this is an HTML tag. :param sourceline: The line number where this tag was found in its source document. :param sourcepos: The character position within `sourceline` where this tag was found. :param can_be_empty_element: If True, this tag should be represented as <tag/>. If False, this tag should be represented as <tag></tag>. :param cdata_list_attributes: A list of attributes whose values should be treated as CDATA if they ever show up on this tag. :param preserve_whitespace_tags: A list of tag names whose contents should have their whitespace preserved. """ if parser is None: self.parser_class = None else: # We don't actually store the parser object: that lets extracted # chunks be garbage-collected. self.parser_class = parser.__class__ if name is None: raise ValueError("No value provided for new tag's name.") self.name = name self.namespace = namespace self.prefix = prefix if ((not builder or builder.store_line_numbers) and (sourceline is not None or sourcepos is not None)): self.sourceline = sourceline self.sourcepos = sourcepos if attrs is None: attrs = {} elif attrs: if builder is not None and builder.cdata_list_attributes: attrs = builder._replace_cdata_list_attribute_values( self.name, attrs) else: attrs = dict(attrs) else: attrs = dict(attrs) # If possible, determine ahead of time whether this tag is an # XML tag. if builder: self.known_xml = builder.is_xml else: self.known_xml = is_xml self.attrs = attrs self.contents = [] self.setup(parent, previous) self.hidden = False if builder is None: # In the absence of a TreeBuilder, use whatever values were # passed in here. They're probably None, unless this is a copy of some # other tag. self.can_be_empty_element = can_be_empty_element self.cdata_list_attributes = cdata_list_attributes self.preserve_whitespace_tags = preserve_whitespace_tags else: # Set up any substitutions for this tag, such as the charset in a META tag. builder.set_up_substitutions(self) # Ask the TreeBuilder whether this tag might be an empty-element tag. self.can_be_empty_element = builder.can_be_empty_element(name) # Keep track of the list of attributes of this tag that # might need to be treated as a list. # # For performance reasons, we store the whole data structure # rather than asking the question of every tag. Asking would # require building a new data structure every time, and # (unlike can_be_empty_element), we almost never need # to check this. self.cdata_list_attributes = builder.cdata_list_attributes # Keep track of the names that might cause this tag to be treated as a # whitespace-preserved tag. self.preserve_whitespace_tags = builder.preserve_whitespace_tags
[ "def", "__init__", "(", "self", ",", "parser", "=", "None", ",", "builder", "=", "None", ",", "name", "=", "None", ",", "namespace", "=", "None", ",", "prefix", "=", "None", ",", "attrs", "=", "None", ",", "parent", "=", "None", ",", "previous", "=...
https://github.com/Jenyay/outwiker/blob/50530cf7b3f71480bb075b2829bc0669773b835b/plugins/webpage/webpage/libs/bs4/element.py#L989-L1083
twilio/twilio-python
6e1e811ea57a1edfadd5161ace87397c563f6915
twilio/rest/verify/v2/service/entity/new_factor.py
python
NewFactorInstance.binding
(self)
return self._properties['binding']
:returns: Unique external identifier of the Entity :rtype: dict
:returns: Unique external identifier of the Entity :rtype: dict
[ ":", "returns", ":", "Unique", "external", "identifier", "of", "the", "Entity", ":", "rtype", ":", "dict" ]
def binding(self): """ :returns: Unique external identifier of the Entity :rtype: dict """ return self._properties['binding']
[ "def", "binding", "(", "self", ")", ":", "return", "self", ".", "_properties", "[", "'binding'", "]" ]
https://github.com/twilio/twilio-python/blob/6e1e811ea57a1edfadd5161ace87397c563f6915/twilio/rest/verify/v2/service/entity/new_factor.py#L239-L244
techbliss/Python_editor
4c2b67bd0b1a2b9b9403f5ae31cf8f13c247c981
7.2/Add to ida python folder/sipconfig.py
python
ProgramMakefile.__init__
(self, configuration, build_file=None, install_dir=None, console=0, qt=0, opengl=0, python=0, threaded=0, warnings=1, debug=0, dir=None, makefile="Makefile", installs=None, universal=None, arch=None, deployment_target=None)
Initialise an instance of a program Makefile. build_file is the file containing the target specific information. If it is a dictionary instead then its contents are validated. install_dir is the directory the target will be installed in.
Initialise an instance of a program Makefile.
[ "Initialise", "an", "instance", "of", "a", "program", "Makefile", "." ]
def __init__(self, configuration, build_file=None, install_dir=None, console=0, qt=0, opengl=0, python=0, threaded=0, warnings=1, debug=0, dir=None, makefile="Makefile", installs=None, universal=None, arch=None, deployment_target=None): """Initialise an instance of a program Makefile. build_file is the file containing the target specific information. If it is a dictionary instead then its contents are validated. install_dir is the directory the target will be installed in. """ Makefile.__init__(self, configuration, console, qt, opengl, python, threaded, warnings, debug, dir, makefile, installs, universal, arch, deployment_target) self._install_dir = install_dir self._manifest = ("embed_manifest_exe" in self.optional_list("CONFIG")) self._target = None if build_file: self._build = self.parse_build_file(build_file) else: self._build = None
[ "def", "__init__", "(", "self", ",", "configuration", ",", "build_file", "=", "None", ",", "install_dir", "=", "None", ",", "console", "=", "0", ",", "qt", "=", "0", ",", "opengl", "=", "0", ",", "python", "=", "0", ",", "threaded", "=", "0", ",", ...
https://github.com/techbliss/Python_editor/blob/4c2b67bd0b1a2b9b9403f5ae31cf8f13c247c981/7.2/Add to ida python folder/sipconfig.py#L1928-L1948
malllabiisc/WordGCN
8a9418a5326a4abb2b1ae4910a51fc7dd9f1a23d
syngcn.py
python
SynGCN.load_data
(self)
Loads the text corpus and C++ batch creation script Parameters ---------- voc2id: Mapping of word to its unique identifier id2voc: Inverse of voc2id id2freq: Mapping of word id to its frequency in the corpus wrd_list: List of words for which embedding is required embed_dims: Dimension of the embedding voc_size: Total number of words in vocabulary wrd_list: List of words in the vocabulary de2id: Mapping of edge labels of dependency parse to unique identifier num_deLabel: Number of edge types in dependency graph rej_prob: Word rejection probability (frequent words are rejected with higher frequency) Returns -------
Loads the text corpus and C++ batch creation script
[ "Loads", "the", "text", "corpus", "and", "C", "++", "batch", "creation", "script" ]
def load_data(self): """ Loads the text corpus and C++ batch creation script Parameters ---------- voc2id: Mapping of word to its unique identifier id2voc: Inverse of voc2id id2freq: Mapping of word id to its frequency in the corpus wrd_list: List of words for which embedding is required embed_dims: Dimension of the embedding voc_size: Total number of words in vocabulary wrd_list: List of words in the vocabulary de2id: Mapping of edge labels of dependency parse to unique identifier num_deLabel: Number of edge types in dependency graph rej_prob: Word rejection probability (frequent words are rejected with higher frequency) Returns ------- """ self.logger.info("Loading data") self.voc2id = read_mappings('./data/voc2id.txt'); self.voc2id = {k: int(v) for k, v in self.voc2id.items()} self.id2freq = read_mappings('./data/id2freq.txt'); self.id2freq = {int(k): int(v) for k, v in self.id2freq.items()} self.id2voc = {v:k for k, v in self.voc2id.items()} self.vocab_size = len(self.voc2id) self.wrd_list = [self.id2voc[i] for i in range(self.vocab_size)] self.de2id = read_mappings('./data/de2id.txt'); self.de2id = {k: int(v) for k, v in self.de2id.items()} self.num_deLabel = len(self.de2id) # Calculating rejection probability corpus_size = np.sum(list(self.id2freq.values())) rel_freq = {_id: freq/corpus_size for _id, freq in self.id2freq.items()} self.rej_prob = {_id: (1-self.p.sample/rel_freq[_id])-np.sqrt(self.p.sample/rel_freq[_id]) for _id in self.id2freq} self.voc_freq_l = [self.id2freq[_id] for _id in range(len(self.voc2id))] if not self.p.context: self.p.win_size = 0 self.lib = ctypes.cdll.LoadLibrary('./batchGen.so') # Loads the C++ code for making batches self.lib.init() # Creating pointers required for creating batches self.edges = np.zeros(self.p.max_dep_len * self.p.batch_size*3, dtype=np.int32) self.wrds = np.zeros(self.p.max_sent_len * self.p.batch_size, dtype=np.int32) self.samp = np.zeros(self.p.max_sent_len * self.p.batch_size, dtype=np.int32) self.negs = np.zeros(self.p.max_sent_len * self.p.num_neg * self.p.batch_size, dtype=np.int32) self.wlen = np.zeros(self.p.batch_size, dtype=np.int32) self.elen = np.zeros(self.p.batch_size, dtype=np.int32) # Pointer address of above arrays self.edges_addr = self.edges.ctypes.data_as(ctypes.POINTER(ctypes.c_int)) self.wrds_addr = self.wrds.ctypes.data_as(ctypes.POINTER(ctypes.c_int)) self.negs_addr = self.negs.ctypes.data_as(ctypes.POINTER(ctypes.c_int)) self.samp_addr = self.samp.ctypes.data_as(ctypes.POINTER(ctypes.c_int)) self.wlen_addr = self.wlen.ctypes.data_as(ctypes.POINTER(ctypes.c_int)) self.elen_addr = self.elen.ctypes.data_as(ctypes.POINTER(ctypes.c_int))
[ "def", "load_data", "(", "self", ")", ":", "self", ".", "logger", ".", "info", "(", "\"Loading data\"", ")", "self", ".", "voc2id", "=", "read_mappings", "(", "'./data/voc2id.txt'", ")", "self", ".", "voc2id", "=", "{", "k", ":", "int", "(", "v", ")", ...
https://github.com/malllabiisc/WordGCN/blob/8a9418a5326a4abb2b1ae4910a51fc7dd9f1a23d/syngcn.py#L36-L92
Symbo1/wsltools
0b6e536fc85c707a1c81f0296c4e91ca835396a1
wsltools/utils/faker/providers/address/ko_KR/__init__.py
python
Provider.land_address
(self)
return self.generator.parse(pattern)
:example 세종특별자치시 어진동 507
:example 세종특별자치시 어진동 507
[ ":", "example", "세종특별자치시", "어진동", "507" ]
def land_address(self): """ :example 세종특별자치시 어진동 507 """ pattern = self.random_element(self.land_address_formats) return self.generator.parse(pattern)
[ "def", "land_address", "(", "self", ")", ":", "pattern", "=", "self", ".", "random_element", "(", "self", ".", "land_address_formats", ")", "return", "self", ".", "generator", ".", "parse", "(", "pattern", ")" ]
https://github.com/Symbo1/wsltools/blob/0b6e536fc85c707a1c81f0296c4e91ca835396a1/wsltools/utils/faker/providers/address/ko_KR/__init__.py#L275-L280
wistbean/learn_python3_spider
73c873f4845f4385f097e5057407d03dd37a117b
stackoverflow/venv/lib/python3.6/site-packages/twisted/spread/pb.py
python
Broker.sendDecRef
(self, objectID)
(internal) Send a DECREF directive. @param objectID: The object ID.
(internal) Send a DECREF directive.
[ "(", "internal", ")", "Send", "a", "DECREF", "directive", "." ]
def sendDecRef(self, objectID): """ (internal) Send a DECREF directive. @param objectID: The object ID. """ self.sendCall(b"decref", objectID)
[ "def", "sendDecRef", "(", "self", ",", "objectID", ")", ":", "self", ".", "sendCall", "(", "b\"decref\"", ",", "objectID", ")" ]
https://github.com/wistbean/learn_python3_spider/blob/73c873f4845f4385f097e5057407d03dd37a117b/stackoverflow/venv/lib/python3.6/site-packages/twisted/spread/pb.py#L1166-L1172
plaid/plaid-python
8c60fca608e426f3ff30da8857775946d29e122c
plaid/model/link_token_create_response.py
python
LinkTokenCreateResponse.openapi_types
()
return { 'link_token': (str,), # noqa: E501 'expiration': (datetime,), # noqa: E501 'request_id': (str,), # noqa: E501 }
This must be a method because a model may have properties that are of type self, this must run after the class is loaded Returns openapi_types (dict): The key is attribute name and the value is attribute type.
This must be a method because a model may have properties that are of type self, this must run after the class is loaded
[ "This", "must", "be", "a", "method", "because", "a", "model", "may", "have", "properties", "that", "are", "of", "type", "self", "this", "must", "run", "after", "the", "class", "is", "loaded" ]
def openapi_types(): """ This must be a method because a model may have properties that are of type self, this must run after the class is loaded Returns openapi_types (dict): The key is attribute name and the value is attribute type. """ return { 'link_token': (str,), # noqa: E501 'expiration': (datetime,), # noqa: E501 'request_id': (str,), # noqa: E501 }
[ "def", "openapi_types", "(", ")", ":", "return", "{", "'link_token'", ":", "(", "str", ",", ")", ",", "# noqa: E501", "'expiration'", ":", "(", "datetime", ",", ")", ",", "# noqa: E501", "'request_id'", ":", "(", "str", ",", ")", ",", "# noqa: E501", "}"...
https://github.com/plaid/plaid-python/blob/8c60fca608e426f3ff30da8857775946d29e122c/plaid/model/link_token_create_response.py#L69-L82
ring04h/wyportmap
c4201e2313504e780a7f25238eba2a2d3223e739
sqlalchemy/engine/base.py
python
Transaction.rollback
(self)
Roll back this :class:`.Transaction`.
Roll back this :class:`.Transaction`.
[ "Roll", "back", "this", ":", "class", ":", ".", "Transaction", "." ]
def rollback(self): """Roll back this :class:`.Transaction`. """ if not self._parent.is_active: return self._do_rollback() self.is_active = False
[ "def", "rollback", "(", "self", ")", ":", "if", "not", "self", ".", "_parent", ".", "is_active", ":", "return", "self", ".", "_do_rollback", "(", ")", "self", ".", "is_active", "=", "False" ]
https://github.com/ring04h/wyportmap/blob/c4201e2313504e780a7f25238eba2a2d3223e739/sqlalchemy/engine/base.py#L1316-L1323
rembo10/headphones
b3199605be1ebc83a7a8feab6b1e99b64014187c
lib/apscheduler/schedulers/asyncio.py
python
AsyncIOScheduler.wakeup
(self)
[]
def wakeup(self): self._stop_timer() wait_seconds = self._process_jobs() self._start_timer(wait_seconds)
[ "def", "wakeup", "(", "self", ")", ":", "self", ".", "_stop_timer", "(", ")", "wait_seconds", "=", "self", ".", "_process_jobs", "(", ")", "self", ".", "_start_timer", "(", "wait_seconds", ")" ]
https://github.com/rembo10/headphones/blob/b3199605be1ebc83a7a8feab6b1e99b64014187c/lib/apscheduler/schedulers/asyncio.py#L61-L64
larryhastings/gilectomy
4315ec3f1d6d4f813cc82ce27a24e7f784dbfc1a
Lib/_pydecimal.py
python
Decimal.logb
(self, context=None)
return ans._fix(context)
Returns the exponent of the magnitude of self's MSD. The result is the integer which is the exponent of the magnitude of the most significant digit of self (as though it were truncated to a single digit while maintaining the value of that digit and without limiting the resulting exponent).
Returns the exponent of the magnitude of self's MSD.
[ "Returns", "the", "exponent", "of", "the", "magnitude", "of", "self", "s", "MSD", "." ]
def logb(self, context=None): """ Returns the exponent of the magnitude of self's MSD. The result is the integer which is the exponent of the magnitude of the most significant digit of self (as though it were truncated to a single digit while maintaining the value of that digit and without limiting the resulting exponent). """ # logb(NaN) = NaN ans = self._check_nans(context=context) if ans: return ans if context is None: context = getcontext() # logb(+/-Inf) = +Inf if self._isinfinity(): return _Infinity # logb(0) = -Inf, DivisionByZero if not self: return context._raise_error(DivisionByZero, 'logb(0)', 1) # otherwise, simply return the adjusted exponent of self, as a # Decimal. Note that no attempt is made to fit the result # into the current context. ans = Decimal(self.adjusted()) return ans._fix(context)
[ "def", "logb", "(", "self", ",", "context", "=", "None", ")", ":", "# logb(NaN) = NaN", "ans", "=", "self", ".", "_check_nans", "(", "context", "=", "context", ")", "if", "ans", ":", "return", "ans", "if", "context", "is", "None", ":", "context", "=", ...
https://github.com/larryhastings/gilectomy/blob/4315ec3f1d6d4f813cc82ce27a24e7f784dbfc1a/Lib/_pydecimal.py#L3361-L3389
tlsnotary/tlsnotary
be3346ca8e754c7f1d027c33b183f7e799d2b0b0
src/auditee/tlsnotary-auditee.py
python
commit_session
(tlsn_session,response,sf)
return reply[1][len('sha1hmac_for_MS:'):]
Commit the encrypted server response and other data to auditor
Commit the encrypted server response and other data to auditor
[ "Commit", "the", "encrypted", "server", "response", "and", "other", "data", "to", "auditor" ]
def commit_session(tlsn_session,response,sf): '''Commit the encrypted server response and other data to auditor''' commit_dir = join(current_session_dir, 'commit') if not os.path.exists(commit_dir): os.makedirs(commit_dir) #Serialization of RC4 'IV' requires concatenating the box,x,y elements of the RC4 state tuple IV = shared.rc4_state_to_bytearray(tlsn_session.IV_after_finished) \ if tlsn_session.chosen_cipher_suite in [4,5] else tlsn_session.IV_after_finished stuff_to_be_committed = {'response':response,'IV':IV, 'cs':str(tlsn_session.chosen_cipher_suite), 'md5hmac':tlsn_session.p_auditee,'domain':tlsn_session.server_name} for k,v in stuff_to_be_committed.iteritems(): with open(join(commit_dir,k+sf),'wb') as f: f.write(v) commit_hash = sha256(response).digest() md5hmac_hash = sha256(tlsn_session.p_auditee).digest() reply = send_and_recv('commit_hash:'+commit_hash+md5hmac_hash) if reply[0] != 'success': raise Exception ('Failed to receive a reply') if not reply[1].startswith('sha1hmac_for_MS:'): raise Exception ('bad reply. Expected sha1hmac_for_MS') return reply[1][len('sha1hmac_for_MS:'):]
[ "def", "commit_session", "(", "tlsn_session", ",", "response", ",", "sf", ")", ":", "commit_dir", "=", "join", "(", "current_session_dir", ",", "'commit'", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "commit_dir", ")", ":", "os", ".", "maked...
https://github.com/tlsnotary/tlsnotary/blob/be3346ca8e754c7f1d027c33b183f7e799d2b0b0/src/auditee/tlsnotary-auditee.py#L638-L657
inasafe/inasafe
355eb2ce63f516b9c26af0c86a24f99e53f63f87
safe/gui/tools/extent_selector_dialog.py
python
ExtentSelectorDialog._populate_bookmarks_list
(self)
Read the sqlite database and populate the bookmarks list. If no bookmarks are found, the bookmarks radio button will be disabled and the label will be shown indicating that the user should add bookmarks in QGIS first. Every bookmark are reprojected to mapcanvas crs.
Read the sqlite database and populate the bookmarks list.
[ "Read", "the", "sqlite", "database", "and", "populate", "the", "bookmarks", "list", "." ]
def _populate_bookmarks_list(self): """Read the sqlite database and populate the bookmarks list. If no bookmarks are found, the bookmarks radio button will be disabled and the label will be shown indicating that the user should add bookmarks in QGIS first. Every bookmark are reprojected to mapcanvas crs. """ # Connect to the QGIS sqlite database and check if the table exists. # noinspection PyArgumentList db_file_path = QgsApplication.qgisUserDatabaseFilePath() db = sqlite3.connect(db_file_path) cursor = db.cursor() cursor.execute( 'SELECT COUNT(*) ' 'FROM sqlite_master ' 'WHERE type=\'table\' ' 'AND name=\'tbl_bookmarks\';') number_of_rows = cursor.fetchone()[0] if number_of_rows > 0: cursor.execute( 'SELECT * ' 'FROM tbl_bookmarks;') bookmarks = cursor.fetchall() canvas_crs = self.canvas.mapSettings().destinationCrs() for bookmark in bookmarks: name = bookmark[1] srid = bookmark[7] rectangle = QgsRectangle( bookmark[3], bookmark[4], bookmark[5], bookmark[6]) if srid != canvas_crs.srsid(): transform = QgsCoordinateTransform( QgsCoordinateReferenceSystem(srid), canvas_crs, QgsProject.instance() ) try: rectangle = transform.transform(rectangle) except QgsCsException: rectangle = QgsRectangle() if rectangle.isEmpty(): pass self.bookmarks_list.addItem(name, rectangle) if self.bookmarks_list.currentIndex() >= 0: self.create_bookmarks_label.hide() else: self.create_bookmarks_label.show() self.hazard_exposure_bookmark.setDisabled(True) self.bookmarks_list.hide()
[ "def", "_populate_bookmarks_list", "(", "self", ")", ":", "# Connect to the QGIS sqlite database and check if the table exists.", "# noinspection PyArgumentList", "db_file_path", "=", "QgsApplication", ".", "qgisUserDatabaseFilePath", "(", ")", "db", "=", "sqlite3", ".", "conne...
https://github.com/inasafe/inasafe/blob/355eb2ce63f516b9c26af0c86a24f99e53f63f87/safe/gui/tools/extent_selector_dialog.py#L365-L420
maas/maas
db2f89970c640758a51247c59bf1ec6f60cf4ab5
src/maasserver/models/interface.py
python
Interface.update_neighbour
(self, ip, mac, time, vid=None)
return neighbour
Updates the neighbour table for this interface.
Updates the neighbour table for this interface.
[ "Updates", "the", "neighbour", "table", "for", "this", "interface", "." ]
def update_neighbour(self, ip, mac, time, vid=None): """Updates the neighbour table for this interface.""" from maasserver.models.neighbour import Neighbour deleted = Neighbour.objects.delete_and_log_obsolete_neighbours( ip, mac, interface=self, vid=vid ) neighbour, created = Neighbour.objects.get_or_create( defaults={"time": time}, ip=ip, mac_address=mac, vid=vid, interface=self, ) if created: # If we deleted a previous neighbour, then we have already # generated a log statement about this neighbour. if not deleted: maaslog.info( f"{self.get_log_string()}: " "New MAC, IP binding " f"observed{Neighbour.objects.get_vid_log_snippet(vid)}: " f"{mac}, {ip}" ) else: neighbour.time = time neighbour.count += 1 neighbour.save(update_fields=["time", "count", "updated"]) return neighbour
[ "def", "update_neighbour", "(", "self", ",", "ip", ",", "mac", ",", "time", ",", "vid", "=", "None", ")", ":", "from", "maasserver", ".", "models", ".", "neighbour", "import", "Neighbour", "deleted", "=", "Neighbour", ".", "objects", ".", "delete_and_log_o...
https://github.com/maas/maas/blob/db2f89970c640758a51247c59bf1ec6f60cf4ab5/src/maasserver/models/interface.py#L1531-L1560
TencentCloud/tencentcloud-sdk-python
3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2
tencentcloud/tione/v20191022/models.py
python
DescribeTrainingJobRequest.__init__
(self)
r""" :param TrainingJobName: 训练任务名称 :type TrainingJobName: str
r""" :param TrainingJobName: 训练任务名称 :type TrainingJobName: str
[ "r", ":", "param", "TrainingJobName", ":", "训练任务名称", ":", "type", "TrainingJobName", ":", "str" ]
def __init__(self): r""" :param TrainingJobName: 训练任务名称 :type TrainingJobName: str """ self.TrainingJobName = None
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "TrainingJobName", "=", "None" ]
https://github.com/TencentCloud/tencentcloud-sdk-python/blob/3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2/tencentcloud/tione/v20191022/models.py#L1316-L1321
wbond/package_control
cfaaeb57612023e3679ecb7f8cd7ceac9f57990d
package_control/providers/gitlab_repository_provider.py
python
GitLabRepositoryProvider.get_broken_dependencies
(self)
return {}.items()
For API-compatibility with RepositoryProvider
For API-compatibility with RepositoryProvider
[ "For", "API", "-", "compatibility", "with", "RepositoryProvider" ]
def get_broken_dependencies(self): """ For API-compatibility with RepositoryProvider """ return {}.items()
[ "def", "get_broken_dependencies", "(", "self", ")", ":", "return", "{", "}", ".", "items", "(", ")" ]
https://github.com/wbond/package_control/blob/cfaaeb57612023e3679ecb7f8cd7ceac9f57990d/package_control/providers/gitlab_repository_provider.py#L79-L84