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
x0rz/EQGRP_Lost_in_Translation
6692b1486f562f027567a49523b8c151a4050988
windows/fuzzbunch/pyreadline/console/ironpython_console.py
python
Console.pos
(self, x=None, y=None)
return x,y
Move or query the window cursor.
Move or query the window cursor.
[ "Move", "or", "query", "the", "window", "cursor", "." ]
def pos(self, x=None, y=None): '''Move or query the window cursor.''' if x is not None: System.Console.CursorLeft=x else: x=System.Console.CursorLeft if y is not None: System.Console.CursorTop=y else: y=System.Console.CursorTop return x,y
[ "def", "pos", "(", "self", ",", "x", "=", "None", ",", "y", "=", "None", ")", ":", "if", "x", "is", "not", "None", ":", "System", ".", "Console", ".", "CursorLeft", "=", "x", "else", ":", "x", "=", "System", ".", "Console", ".", "CursorLeft", "...
https://github.com/x0rz/EQGRP_Lost_in_Translation/blob/6692b1486f562f027567a49523b8c151a4050988/windows/fuzzbunch/pyreadline/console/ironpython_console.py#L105-L115
twisted/klein
365f033010b76c6a060531d0abcd4146c726918f
src/klein/_plating.py
python
PlatedElement.lookupRenderMethod
(self, name)
@return: a renderer.
[]
def lookupRenderMethod(self, name): """ @return: a renderer. """ if name in self._renderers: wrapped = self._renderers[name] @modified("plated render wrapper", wrapped) def renderWrapper( request: IRequest, tag: Tag, *args: Any, **kw: Any ) -> Any: return _call( self._boundInstance, wrapped, request, tag, *args, **kw ) return renderWrapper if ":" not in name: raise MissingRenderMethod(self, name) slot, type = name.split(":", 1) def renderList(request, tag): for item in self.slot_data[slot]: yield tag.fillSlots(item=_extra_types(item)) types = { "list": renderList, } if type in types: return types[type] else: raise MissingRenderMethod(self, name)
[ "def", "lookupRenderMethod", "(", "self", ",", "name", ")", ":", "if", "name", "in", "self", ".", "_renderers", ":", "wrapped", "=", "self", ".", "_renderers", "[", "name", "]", "@", "modified", "(", "\"plated render wrapper\"", ",", "wrapped", ")", "def",...
https://github.com/twisted/klein/blob/365f033010b76c6a060531d0abcd4146c726918f/src/klein/_plating.py#L162-L192
haiwen/seahub
e92fcd44e3e46260597d8faa9347cb8222b8b10d
seahub/api2/models.py
python
TokenV2.save
(self, *args, **kwargs)
return super(TokenV2, self).save(*args, **kwargs)
[]
def save(self, *args, **kwargs): if not self.key: self.key = self.generate_key() return super(TokenV2, self).save(*args, **kwargs)
[ "def", "save", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "key", ":", "self", ".", "key", "=", "self", ".", "generate_key", "(", ")", "return", "super", "(", "TokenV2", ",", "self", ")", ".", "sa...
https://github.com/haiwen/seahub/blob/e92fcd44e3e46260597d8faa9347cb8222b8b10d/seahub/api2/models.py#L193-L196
achael/eht-imaging
bbd3aeb06bef52bf89fa1c06de71e5509a5b0015
ehtim/imager.py
python
Imager.out_last
(self)
return self._out_list[-1]
Return last result.
Return last result.
[ "Return", "last", "result", "." ]
def out_last(self): """Return last result. """ if self.nruns == 0: print("No imager runs yet!") return return self._out_list[-1]
[ "def", "out_last", "(", "self", ")", ":", "if", "self", ".", "nruns", "==", "0", ":", "print", "(", "\"No imager runs yet!\"", ")", "return", "return", "self", ".", "_out_list", "[", "-", "1", "]" ]
https://github.com/achael/eht-imaging/blob/bbd3aeb06bef52bf89fa1c06de71e5509a5b0015/ehtim/imager.py#L693-L699
hakril/PythonForWindows
61e027a678d5b87aa64fcf8a37a6661a86236589
windows/winproxy/apis/advapi32.py
python
ConvertSecurityDescriptorToStringSecurityDescriptorW
(SecurityDescriptor, RequestedStringSDRevision, SecurityInformation, StringSecurityDescriptor, StringSecurityDescriptorLen)
return ConvertSecurityDescriptorToStringSecurityDescriptorW.ctypes_function(SecurityDescriptor, RequestedStringSDRevision, SecurityInformation, StringSecurityDescriptor, StringSecurityDescriptorLen)
[]
def ConvertSecurityDescriptorToStringSecurityDescriptorW(SecurityDescriptor, RequestedStringSDRevision, SecurityInformation, StringSecurityDescriptor, StringSecurityDescriptorLen): return ConvertSecurityDescriptorToStringSecurityDescriptorW.ctypes_function(SecurityDescriptor, RequestedStringSDRevision, SecurityInformation, StringSecurityDescriptor, StringSecurityDescriptorLen)
[ "def", "ConvertSecurityDescriptorToStringSecurityDescriptorW", "(", "SecurityDescriptor", ",", "RequestedStringSDRevision", ",", "SecurityInformation", ",", "StringSecurityDescriptor", ",", "StringSecurityDescriptorLen", ")", ":", "return", "ConvertSecurityDescriptorToStringSecurityDes...
https://github.com/hakril/PythonForWindows/blob/61e027a678d5b87aa64fcf8a37a6661a86236589/windows/winproxy/apis/advapi32.py#L216-L217
realpython/book2-exercises
cde325eac8e6d8cff2316601c2e5b36bb46af7d0
web2py/venv/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.py
python
TarIter.__iter__
(self)
return self
Return iterator object.
Return iterator object.
[ "Return", "iterator", "object", "." ]
def __iter__(self): """Return iterator object. """ return self
[ "def", "__iter__", "(", "self", ")", ":", "return", "self" ]
https://github.com/realpython/book2-exercises/blob/cde325eac8e6d8cff2316601c2e5b36bb46af7d0/web2py/venv/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.py#L2565-L2568
bruderstein/PythonScript
df9f7071ddf3a079e3a301b9b53a6dc78cf1208f
PythonLib/min/_pydecimal.py
python
Decimal._check_nans
(self, other=None, context=None)
return 0
Returns whether the number is not actually one. if self, other are sNaN, signal if self, other are NaN return nan return 0 Done before operations.
Returns whether the number is not actually one.
[ "Returns", "whether", "the", "number", "is", "not", "actually", "one", "." ]
def _check_nans(self, other=None, context=None): """Returns whether the number is not actually one. if self, other are sNaN, signal if self, other are NaN return nan return 0 Done before operations. """ self_is_nan = self._isnan() if other is None: other_is_nan = False else: other_is_nan = other._isnan() if self_is_nan or other_is_nan: if context is None: context = getcontext() if self_is_nan == 2: return context._raise_error(InvalidOperation, 'sNaN', self) if other_is_nan == 2: return context._raise_error(InvalidOperation, 'sNaN', other) if self_is_nan: return self._fix_nan(context) return other._fix_nan(context) return 0
[ "def", "_check_nans", "(", "self", ",", "other", "=", "None", ",", "context", "=", "None", ")", ":", "self_is_nan", "=", "self", ".", "_isnan", "(", ")", "if", "other", "is", "None", ":", "other_is_nan", "=", "False", "else", ":", "other_is_nan", "=", ...
https://github.com/bruderstein/PythonScript/blob/df9f7071ddf3a079e3a301b9b53a6dc78cf1208f/PythonLib/min/_pydecimal.py#L745-L775
TarrySingh/Artificial-Intelligence-Deep-Learning-Machine-Learning-Tutorials
5bb97d7e3ffd913abddb4cfa7d78a1b4c868890e
deep-learning/fastai-docs/fastai_docs-master/dev_nb/nb_004b.py
python
to_fp16
(learn:Learner, loss_scale:float=512., flat_master:bool=False)
return learn
Transforms the learner in FP16 precision
Transforms the learner in FP16 precision
[ "Transforms", "the", "learner", "in", "FP16", "precision" ]
def to_fp16(learn:Learner, loss_scale:float=512., flat_master:bool=False)->Learner: "Transforms the learner in FP16 precision" learn.model = model2half(learn.model) learn.mp_cb = MixedPrecision(learn, loss_scale=loss_scale, flat_master=flat_master) learn.callbacks.append(learn.mp_cb) return learn
[ "def", "to_fp16", "(", "learn", ":", "Learner", ",", "loss_scale", ":", "float", "=", "512.", ",", "flat_master", ":", "bool", "=", "False", ")", "->", "Learner", ":", "learn", ".", "model", "=", "model2half", "(", "learn", ".", "model", ")", "learn", ...
https://github.com/TarrySingh/Artificial-Intelligence-Deep-Learning-Machine-Learning-Tutorials/blob/5bb97d7e3ffd913abddb4cfa7d78a1b4c868890e/deep-learning/fastai-docs/fastai_docs-master/dev_nb/nb_004b.py#L134-L139
leo-editor/leo-editor
383d6776d135ef17d73d935a2f0ecb3ac0e99494
leo/plugins/obsolete/wxGui.py
python
wxLeoTree.item2vnode
(self,item)
Override baseNativeTreeWidget.item2vnode.
Override baseNativeTreeWidget.item2vnode.
[ "Override", "baseNativeTreeWidget", ".", "item2vnode", "." ]
def item2vnode (self,item): '''Override baseNativeTreeWidget.item2vnode.''' w = self.treeWidget if item and item.IsOk(): v = self.getItemData(item) return v else: return None
[ "def", "item2vnode", "(", "self", ",", "item", ")", ":", "w", "=", "self", ".", "treeWidget", "if", "item", "and", "item", ".", "IsOk", "(", ")", ":", "v", "=", "self", ".", "getItemData", "(", "item", ")", "return", "v", "else", ":", "return", "...
https://github.com/leo-editor/leo-editor/blob/383d6776d135ef17d73d935a2f0ecb3ac0e99494/leo/plugins/obsolete/wxGui.py#L4166-L4176
holoviz/hvplot
25f3285c8ac315e96929b57504e4674d40b947b5
hvplot/interactive.py
python
Interactive.eval
(self)
return obj
Returns the currrent state of the interactive expression. The returned object is no longer interactive.
Returns the currrent state of the interactive expression. The returned object is no longer interactive.
[ "Returns", "the", "currrent", "state", "of", "the", "interactive", "expression", ".", "The", "returned", "object", "is", "no", "longer", "interactive", "." ]
def eval(self): """ Returns the currrent state of the interactive expression. The returned object is no longer interactive. """ obj = self._current if self._method: return getattr(obj, self._method, obj) return obj
[ "def", "eval", "(", "self", ")", ":", "obj", "=", "self", ".", "_current", "if", "self", ".", "_method", ":", "return", "getattr", "(", "obj", ",", "self", ".", "_method", ",", "obj", ")", "return", "obj" ]
https://github.com/holoviz/hvplot/blob/25f3285c8ac315e96929b57504e4674d40b947b5/hvplot/interactive.py#L370-L378
numenta/numenta-apps
02903b0062c89c2c259b533eea2df6e8bb44eaf3
taurus_metric_collectors/taurus_metric_collectors/common_services/metric_maintenance_agent.py
python
_purgeDeprecatedCompanies
()
Purge cached data and Taurus Engine metrics/models corresponding to symbols that are in xignite_security table, but not in metrics configuration.
Purge cached data and Taurus Engine metrics/models corresponding to symbols that are in xignite_security table, but not in metrics configuration.
[ "Purge", "cached", "data", "and", "Taurus", "Engine", "metrics", "/", "models", "corresponding", "to", "symbols", "that", "are", "in", "xignite_security", "table", "but", "not", "in", "metrics", "configuration", "." ]
def _purgeDeprecatedCompanies(): """Purge cached data and Taurus Engine metrics/models corresponding to symbols that are in xignite_security table, but not in metrics configuration. """ activeCompanySymbols = set(security[0] for security in metric_utils.getAllMetricSecurities()) deprecatedSymbols = set(_queryCachedCompanySymbols()) - activeCompanySymbols if deprecatedSymbols: delete_companies.deleteCompanies( tickerSymbols=deprecatedSymbols, engineServer=_TAURUS_HTM_SERVER, engineApiKey=_TAURUS_API_KEY, warnAboutDestructiveAction=False) else: g_log.info("There were no deprecated companies to remove")
[ "def", "_purgeDeprecatedCompanies", "(", ")", ":", "activeCompanySymbols", "=", "set", "(", "security", "[", "0", "]", "for", "security", "in", "metric_utils", ".", "getAllMetricSecurities", "(", ")", ")", "deprecatedSymbols", "=", "set", "(", "_queryCachedCompany...
https://github.com/numenta/numenta-apps/blob/02903b0062c89c2c259b533eea2df6e8bb44eaf3/taurus_metric_collectors/taurus_metric_collectors/common_services/metric_maintenance_agent.py#L122-L138
cloudant/bigcouch
8e9c1ec0ed1676ff152f10658f5c83a1a91fa8fe
couchjs/scons/scons-time.py
python
SConsTimer.doc_to_help
(self, obj)
return self.outdent(doc)
Translates an object's __doc__ string into help text. This strips a consistent number of spaces from each line in the help text, essentially "outdenting" the text to the left-most column.
Translates an object's __doc__ string into help text.
[ "Translates", "an", "object", "s", "__doc__", "string", "into", "help", "text", "." ]
def doc_to_help(self, obj): """ Translates an object's __doc__ string into help text. This strips a consistent number of spaces from each line in the help text, essentially "outdenting" the text to the left-most column. """ doc = obj.__doc__ if doc is None: return '' return self.outdent(doc)
[ "def", "doc_to_help", "(", "self", ",", "obj", ")", ":", "doc", "=", "obj", ".", "__doc__", "if", "doc", "is", "None", ":", "return", "''", "return", "self", ".", "outdent", "(", "doc", ")" ]
https://github.com/cloudant/bigcouch/blob/8e9c1ec0ed1676ff152f10658f5c83a1a91fa8fe/couchjs/scons/scons-time.py#L576-L587
edisonlz/fastor
342078a18363ac41d3c6b1ab29dbdd44fdb0b7b3
base/site-packages/redis_model/models/base.py
python
ModelBase._initialize_attributes
(self,model_class, name, bases, attrs)
Initialize the attributes of the model. param: model_class:object name:string bases:base model attrs:attribute
Initialize the attributes of the model. param: model_class:object name:string bases:base model attrs:attribute
[ "Initialize", "the", "attributes", "of", "the", "model", ".", "param", ":", "model_class", ":", "object", "name", ":", "string", "bases", ":", "base", "model", "attrs", ":", "attribute" ]
def _initialize_attributes(self,model_class, name, bases, attrs): """ Initialize the attributes of the model. param: model_class:object name:string bases:base model attrs:attribute """ #主要功能:添加属性列表 model_class.attributes = {} for k, v in attrs.iteritems(): if isinstance(v,Attribute): model_class.attributes[k] = v v.name = v.name or k
[ "def", "_initialize_attributes", "(", "self", ",", "model_class", ",", "name", ",", "bases", ",", "attrs", ")", ":", "#主要功能:添加属性列表", "model_class", ".", "attributes", "=", "{", "}", "for", "k", ",", "v", "in", "attrs", ".", "iteritems", "(", ")", ":", ...
https://github.com/edisonlz/fastor/blob/342078a18363ac41d3c6b1ab29dbdd44fdb0b7b3/base/site-packages/redis_model/models/base.py#L56-L70
pytorch/translate
564d011b10b4cef4e110c092c2912277ed64c713
pytorch_translate/transformer_aan.py
python
TransformerAANDecoder.max_positions
(self)
return min(self.max_target_positions, self.embed_positions.max_positions)
Maximum output length supported by the decoder.
Maximum output length supported by the decoder.
[ "Maximum", "output", "length", "supported", "by", "the", "decoder", "." ]
def max_positions(self): """Maximum output length supported by the decoder.""" if self.embed_positions is None: return self.max_target_positions return min(self.max_target_positions, self.embed_positions.max_positions)
[ "def", "max_positions", "(", "self", ")", ":", "if", "self", ".", "embed_positions", "is", "None", ":", "return", "self", ".", "max_target_positions", "return", "min", "(", "self", ".", "max_target_positions", ",", "self", ".", "embed_positions", ".", "max_pos...
https://github.com/pytorch/translate/blob/564d011b10b4cef4e110c092c2912277ed64c713/pytorch_translate/transformer_aan.py#L494-L498
sagemath/sage
f9b2db94f675ff16963ccdefba4f1a3393b3fe0d
src/sage/coding/relative_finite_field_extension.py
python
RelativeFiniteFieldExtension._latex_
(self)
return "\\textnormal{Relative field extension between %s and %s}" % (self.absolute_field()._latex_(), self.relative_field()._latex_())
r""" Returns a latex representation of ``self``. EXAMPLES:: sage: from sage.coding.relative_finite_field_extension import * sage: Fqm.<aa> = GF(16) sage: Fq.<a> = GF(4) sage: latex(RelativeFiniteFieldExtension(Fqm, Fq)) \textnormal{Relative field extension between \Bold{F}_{2^{4}} and \Bold{F}_{2^{2}}}
r""" Returns a latex representation of ``self``.
[ "r", "Returns", "a", "latex", "representation", "of", "self", "." ]
def _latex_(self): r""" Returns a latex representation of ``self``. EXAMPLES:: sage: from sage.coding.relative_finite_field_extension import * sage: Fqm.<aa> = GF(16) sage: Fq.<a> = GF(4) sage: latex(RelativeFiniteFieldExtension(Fqm, Fq)) \textnormal{Relative field extension between \Bold{F}_{2^{4}} and \Bold{F}_{2^{2}}} """ return "\\textnormal{Relative field extension between %s and %s}" % (self.absolute_field()._latex_(), self.relative_field()._latex_())
[ "def", "_latex_", "(", "self", ")", ":", "return", "\"\\\\textnormal{Relative field extension between %s and %s}\"", "%", "(", "self", ".", "absolute_field", "(", ")", ".", "_latex_", "(", ")", ",", "self", ".", "relative_field", "(", ")", ".", "_latex_", "(", ...
https://github.com/sagemath/sage/blob/f9b2db94f675ff16963ccdefba4f1a3393b3fe0d/src/sage/coding/relative_finite_field_extension.py#L153-L166
thaines/helit
04bd36ee0fb6b762c63d746e2cd8813641dceda9
handwriting/corpus/extract_text.py
python
each_prefixed_paragraph
(lines, attribution, prefix)
Same as each_named_paragraph, but where each title has a prefix.
Same as each_named_paragraph, but where each title has a prefix.
[ "Same", "as", "each_named_paragraph", "but", "where", "each", "title", "has", "a", "prefix", "." ]
def each_prefixed_paragraph(lines, attribution, prefix): """Same as each_named_paragraph, but where each title has a prefix.""" buf = [] title = 'Unknown' for line in lines: line = line.strip() line = line.replace('_','') if has_letters(line): buf.append(line) elif len(buf)!=0: text = '\n'.join(buf) if has_lower(text): yield Block(text, attribution%title) elif text.startswith(prefix): title = string.capwords(text[len(prefix):].replace('\n','')) buf = [] if len(buf)!=0: text = '\n'.join(buf) if has_lower(text): yield Block(text, attribution%title)
[ "def", "each_prefixed_paragraph", "(", "lines", ",", "attribution", ",", "prefix", ")", ":", "buf", "=", "[", "]", "title", "=", "'Unknown'", "for", "line", "in", "lines", ":", "line", "=", "line", ".", "strip", "(", ")", "line", "=", "line", ".", "r...
https://github.com/thaines/helit/blob/04bd36ee0fb6b762c63d746e2cd8813641dceda9/handwriting/corpus/extract_text.py#L140-L163
hack12306/12306-booking
726c830c2e771d5cd8e09772e7646e480dddb086
booking/remind.py
python
remind_left_ticket
()
有票提醒
有票提醒
[ "有票提醒" ]
def remind_left_ticket(): """ 有票提醒 """ cmd = 'open %s --hide --background' % settings.TRAIN_AUDIO_FILE os.system(cmd)
[ "def", "remind_left_ticket", "(", ")", ":", "cmd", "=", "'open %s --hide --background'", "%", "settings", ".", "TRAIN_AUDIO_FILE", "os", ".", "system", "(", "cmd", ")" ]
https://github.com/hack12306/12306-booking/blob/726c830c2e771d5cd8e09772e7646e480dddb086/booking/remind.py#L14-L19
realpython/book2-exercises
cde325eac8e6d8cff2316601c2e5b36bb46af7d0
web2py/venv/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py
python
ssl_wrap_socket
(sock, keyfile=None, certfile=None, cert_reqs=None, ca_certs=None, server_hostname=None, ssl_version=None, ciphers=None, ssl_context=None, ca_cert_dir=None)
return context.wrap_socket(sock)
All arguments except for server_hostname, ssl_context, and ca_cert_dir have the same meaning as they do when using :func:`ssl.wrap_socket`. :param server_hostname: When SNI is supported, the expected hostname of the certificate :param ssl_context: A pre-made :class:`SSLContext` object. If none is provided, one will be created using :func:`create_urllib3_context`. :param ciphers: A string of ciphers we wish the client to support. This is not supported on Python 2.6 as the ssl module does not support it. :param ca_cert_dir: A directory containing CA certificates in multiple separate files, as supported by OpenSSL's -CApath flag or the capath argument to SSLContext.load_verify_locations().
All arguments except for server_hostname, ssl_context, and ca_cert_dir have the same meaning as they do when using :func:`ssl.wrap_socket`.
[ "All", "arguments", "except", "for", "server_hostname", "ssl_context", "and", "ca_cert_dir", "have", "the", "same", "meaning", "as", "they", "do", "when", "using", ":", "func", ":", "ssl", ".", "wrap_socket", "." ]
def ssl_wrap_socket(sock, keyfile=None, certfile=None, cert_reqs=None, ca_certs=None, server_hostname=None, ssl_version=None, ciphers=None, ssl_context=None, ca_cert_dir=None): """ All arguments except for server_hostname, ssl_context, and ca_cert_dir have the same meaning as they do when using :func:`ssl.wrap_socket`. :param server_hostname: When SNI is supported, the expected hostname of the certificate :param ssl_context: A pre-made :class:`SSLContext` object. If none is provided, one will be created using :func:`create_urllib3_context`. :param ciphers: A string of ciphers we wish the client to support. This is not supported on Python 2.6 as the ssl module does not support it. :param ca_cert_dir: A directory containing CA certificates in multiple separate files, as supported by OpenSSL's -CApath flag or the capath argument to SSLContext.load_verify_locations(). """ context = ssl_context if context is None: context = create_urllib3_context(ssl_version, cert_reqs, ciphers=ciphers) if ca_certs or ca_cert_dir: try: context.load_verify_locations(ca_certs, ca_cert_dir) except IOError as e: # Platform-specific: Python 2.6, 2.7, 3.2 raise SSLError(e) # Py33 raises FileNotFoundError which subclasses OSError # These are not equivalent unless we check the errno attribute except OSError as e: # Platform-specific: Python 3.3 and beyond if e.errno == errno.ENOENT: raise SSLError(e) raise if certfile: context.load_cert_chain(certfile, keyfile) if HAS_SNI: # Platform-specific: OpenSSL with enabled SNI return context.wrap_socket(sock, server_hostname=server_hostname) warnings.warn( 'An HTTPS request has been made, but the SNI (Subject Name ' 'Indication) extension to TLS is not available on this platform. ' 'This may cause the server to present an incorrect TLS ' 'certificate, which can cause validation failures. You can upgrade to ' 'a newer version of Python to solve this. For more information, see ' 'https://urllib3.readthedocs.io/en/latest/security.html' '#snimissingwarning.', SNIMissingWarning ) return context.wrap_socket(sock)
[ "def", "ssl_wrap_socket", "(", "sock", ",", "keyfile", "=", "None", ",", "certfile", "=", "None", ",", "cert_reqs", "=", "None", ",", "ca_certs", "=", "None", ",", "server_hostname", "=", "None", ",", "ssl_version", "=", "None", ",", "ciphers", "=", "Non...
https://github.com/realpython/book2-exercises/blob/cde325eac8e6d8cff2316601c2e5b36bb46af7d0/web2py/venv/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py#L267-L320
wrye-bash/wrye-bash
d495c47cfdb44475befa523438a40c4419cb386f
Mopy/bash/basher/files_links.py
python
File_Redate._perform_refresh
(self)
Refreshes the data store -
Refreshes the data store -
[ "Refreshes", "the", "data", "store", "-" ]
def _perform_refresh(self): """Refreshes the data store - """ self.window.data_store.refresh(refresh_infos=False)
[ "def", "_perform_refresh", "(", "self", ")", ":", "self", ".", "window", ".", "data_store", ".", "refresh", "(", "refresh_infos", "=", "False", ")" ]
https://github.com/wrye-bash/wrye-bash/blob/d495c47cfdb44475befa523438a40c4419cb386f/Mopy/bash/basher/files_links.py#L345-L347
igraph/python-igraph
e9f83e8af08f24ea025596e745917197d8b44d94
src/igraph/statistics.py
python
RunningMean.mean
(self)
return self._mean
Returns the current mean
Returns the current mean
[ "Returns", "the", "current", "mean" ]
def mean(self): """Returns the current mean""" return self._mean
[ "def", "mean", "(", "self", ")", ":", "return", "self", ".", "_mean" ]
https://github.com/igraph/python-igraph/blob/e9f83e8af08f24ea025596e745917197d8b44d94/src/igraph/statistics.py#L423-L425
yhlleo/tensorflow.cifar10
cd950323e7157e30391c123b665804b6276e38a6
cifar10.py
python
loss
(logits, labels)
return tf.add_n(tf.get_collection('losses'), name='total_loss')
Add L2Loss to all the trainable variables. Add summary for for "Loss" and "Loss/avg". Args: logits: Logits from inference(). labels: Labels from distorted_inputs or inputs(). 1-D tensor of shape [batch_size] Returns: Loss tensor of type float.
Add L2Loss to all the trainable variables.
[ "Add", "L2Loss", "to", "all", "the", "trainable", "variables", "." ]
def loss(logits, labels): """Add L2Loss to all the trainable variables. Add summary for for "Loss" and "Loss/avg". Args: logits: Logits from inference(). labels: Labels from distorted_inputs or inputs(). 1-D tensor of shape [batch_size] Returns: Loss tensor of type float. """ # Reshape the labels into a dense Tensor of # shape [batch_size, NUM_CLASSES]. sparse_labels = tf.reshape(labels, [FLAGS.batch_size, 1]) # indices = tf.reshape(tfrange(FLAGS.batch_size), [FLAGS.batch_size, 1]) indices = tf.reshape(range(FLAGS.batch_size), [FLAGS.batch_size, 1]) concated = tf.concat(1, [indices, sparse_labels]) dense_labels = tf.sparse_to_dense(concated, [FLAGS.batch_size, NUM_CLASSES], 1.0, 0.0) # Calculate the average cross entropy loss across the batch. cross_entropy = tf.nn.softmax_cross_entropy_with_logits( logits, dense_labels, name='cross_entropy_per_example') cross_entropy_mean = tf.reduce_mean(cross_entropy, name='cross_entropy') tf.add_to_collection('losses', cross_entropy_mean) # The total loss is defined as the cross entropy loss plus all of the weight # decay terms (L2 loss). return tf.add_n(tf.get_collection('losses'), name='total_loss')
[ "def", "loss", "(", "logits", ",", "labels", ")", ":", "# Reshape the labels into a dense Tensor of", "# shape [batch_size, NUM_CLASSES].", "sparse_labels", "=", "tf", ".", "reshape", "(", "labels", ",", "[", "FLAGS", ".", "batch_size", ",", "1", "]", ")", "# indi...
https://github.com/yhlleo/tensorflow.cifar10/blob/cd950323e7157e30391c123b665804b6276e38a6/cifar10.py#L257-L287
robinhood/faust
01b4c0ad8390221db71751d80001b0fd879291e2
faust/channels.py
python
get_topic_name
(self)
Get the topic name, or raise if this is not a named channel.
Get the topic name, or raise if this is not a named channel.
[ "Get", "the", "topic", "name", "or", "raise", "if", "this", "is", "not", "a", "named", "channel", "." ]
def get_topic_name(self) -> str: """Get the topic name, or raise if this is not a named channel.""" raise NotImplementedError('Channels are unnamed topics')
[ "def", "get_topic_name", "(", "self", ")", "->", "str", ":", "raise", "NotImplementedError", "(", "'Channels are unnamed topics'", ")" ]
https://github.com/robinhood/faust/blob/01b4c0ad8390221db71751d80001b0fd879291e2/faust/channels.py#L191-L193
holzschu/Carnets
44effb10ddfc6aa5c8b0687582a724ba82c6b547
Library/lib/python3.7/site-packages/sympy/solvers/ode.py
python
_nonlinear_3eq_order1_type1
(x, y, z, t, eq)
return [sol1, sol2, sol3]
r""" Equations: .. math:: a x' = (b - c) y z, \enspace b y' = (c - a) z x, \enspace c z' = (a - b) x y First Integrals: .. math:: a x^{2} + b y^{2} + c z^{2} = C_1 .. math:: a^{2} x^{2} + b^{2} y^{2} + c^{2} z^{2} = C_2 where `C_1` and `C_2` are arbitrary constants. On solving the integrals for `y` and `z` and on substituting the resulting expressions into the first equation of the system, we arrives at a separable first-order equation on `x`. Similarly doing that for other two equations, we will arrive at first order equation on `y` and `z` too. References ========== -http://eqworld.ipmnet.ru/en/solutions/sysode/sode0401.pdf
r""" Equations:
[ "r", "Equations", ":" ]
def _nonlinear_3eq_order1_type1(x, y, z, t, eq): r""" Equations: .. math:: a x' = (b - c) y z, \enspace b y' = (c - a) z x, \enspace c z' = (a - b) x y First Integrals: .. math:: a x^{2} + b y^{2} + c z^{2} = C_1 .. math:: a^{2} x^{2} + b^{2} y^{2} + c^{2} z^{2} = C_2 where `C_1` and `C_2` are arbitrary constants. On solving the integrals for `y` and `z` and on substituting the resulting expressions into the first equation of the system, we arrives at a separable first-order equation on `x`. Similarly doing that for other two equations, we will arrive at first order equation on `y` and `z` too. References ========== -http://eqworld.ipmnet.ru/en/solutions/sysode/sode0401.pdf """ C1, C2 = get_numbered_constants(eq, num=2) u, v, w = symbols('u, v, w') p = Wild('p', exclude=[x(t), y(t), z(t), t]) q = Wild('q', exclude=[x(t), y(t), z(t), t]) s = Wild('s', exclude=[x(t), y(t), z(t), t]) r = (diff(x(t),t) - eq[0]).match(p*y(t)*z(t)) r.update((diff(y(t),t) - eq[1]).match(q*z(t)*x(t))) r.update((diff(z(t),t) - eq[2]).match(s*x(t)*y(t))) n1, d1 = r[p].as_numer_denom() n2, d2 = r[q].as_numer_denom() n3, d3 = r[s].as_numer_denom() val = solve([n1*u-d1*v+d1*w, d2*u+n2*v-d2*w, d3*u-d3*v-n3*w],[u,v]) vals = [val[v], val[u]] c = lcm(vals[0].as_numer_denom()[1], vals[1].as_numer_denom()[1]) b = vals[0].subs(w, c) a = vals[1].subs(w, c) y_x = sqrt(((c*C1-C2) - a*(c-a)*x(t)**2)/(b*(c-b))) z_x = sqrt(((b*C1-C2) - a*(b-a)*x(t)**2)/(c*(b-c))) z_y = sqrt(((a*C1-C2) - b*(a-b)*y(t)**2)/(c*(a-c))) x_y = sqrt(((c*C1-C2) - b*(c-b)*y(t)**2)/(a*(c-a))) x_z = sqrt(((b*C1-C2) - c*(b-c)*z(t)**2)/(a*(b-a))) y_z = sqrt(((a*C1-C2) - c*(a-c)*z(t)**2)/(b*(a-b))) sol1 = dsolve(a*diff(x(t),t) - (b-c)*y_x*z_x) sol2 = dsolve(b*diff(y(t),t) - (c-a)*z_y*x_y) sol3 = dsolve(c*diff(z(t),t) - (a-b)*x_z*y_z) return [sol1, sol2, sol3]
[ "def", "_nonlinear_3eq_order1_type1", "(", "x", ",", "y", ",", "z", ",", "t", ",", "eq", ")", ":", "C1", ",", "C2", "=", "get_numbered_constants", "(", "eq", ",", "num", "=", "2", ")", "u", ",", "v", ",", "w", "=", "symbols", "(", "'u, v, w'", ")...
https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/site-packages/sympy/solvers/ode.py#L9025-L9072
JinnLynn/alfred-workflows
1fc663b00f56b4dc3f9fa2212a8600e6da616fc1
lib/six/__init__.py
python
with_metaclass
(meta, base=object)
return meta("NewBase", (base,), {})
Create a base class with a metaclass.
Create a base class with a metaclass.
[ "Create", "a", "base", "class", "with", "a", "metaclass", "." ]
def with_metaclass(meta, base=object): """Create a base class with a metaclass.""" return meta("NewBase", (base,), {})
[ "def", "with_metaclass", "(", "meta", ",", "base", "=", "object", ")", ":", "return", "meta", "(", "\"NewBase\"", ",", "(", "base", ",", ")", ",", "{", "}", ")" ]
https://github.com/JinnLynn/alfred-workflows/blob/1fc663b00f56b4dc3f9fa2212a8600e6da616fc1/lib/six/__init__.py#L402-L404
zhl2008/awd-platform
0416b31abea29743387b10b3914581fbe8e7da5e
web_hxb2/lib/python3.5/site-packages/PIL/PngImagePlugin.py
python
PngImageFile.load_end
(self)
internal: finished reading image data
internal: finished reading image data
[ "internal", ":", "finished", "reading", "image", "data" ]
def load_end(self): "internal: finished reading image data" self.png.close() self.png = None
[ "def", "load_end", "(", "self", ")", ":", "self", ".", "png", ".", "close", "(", ")", "self", ".", "png", "=", "None" ]
https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_hxb2/lib/python3.5/site-packages/PIL/PngImagePlugin.py#L611-L615
WilsonWangTHU/mbbl
bb88a016de2fcd8ea0ed9c4d5c539817d2b476e7
mbbl/env/gym_env/noise_gym_cartpole.py
python
env._set_groundtruth_api
(self)
@brief: In this function, we could provide the ground-truth dynamics and rewards APIs for the agent to call. For the new environments, if we don't set their ground-truth apis, then we cannot test the algorithm using ground-truth dynamics or reward
[]
def _set_groundtruth_api(self): """ @brief: In this function, we could provide the ground-truth dynamics and rewards APIs for the agent to call. For the new environments, if we don't set their ground-truth apis, then we cannot test the algorithm using ground-truth dynamics or reward """ self._set_reward_api() self._set_dynamics_api()
[ "def", "_set_groundtruth_api", "(", "self", ")", ":", "self", ".", "_set_reward_api", "(", ")", "self", ".", "_set_dynamics_api", "(", ")" ]
https://github.com/WilsonWangTHU/mbbl/blob/bb88a016de2fcd8ea0ed9c4d5c539817d2b476e7/mbbl/env/gym_env/noise_gym_cartpole.py#L98-L107
ironport/shrapnel
9496a64c46271b0c5cef0feb8f2cdf33cb752bb6
coro/http/client.py
python
request.wake
(self)
signal that a reply to this request has been received
signal that a reply to this request has been received
[ "signal", "that", "a", "reply", "to", "this", "request", "has", "been", "received" ]
def wake (self): "signal that a reply to this request has been received" if self.rfile and self.force: self.content = self.rfile.read() self.latch.wake_all() if self.rfile and not self.force: self.rfile.wait()
[ "def", "wake", "(", "self", ")", ":", "if", "self", ".", "rfile", "and", "self", ".", "force", ":", "self", ".", "content", "=", "self", ".", "rfile", ".", "read", "(", ")", "self", ".", "latch", ".", "wake_all", "(", ")", "if", "self", ".", "r...
https://github.com/ironport/shrapnel/blob/9496a64c46271b0c5cef0feb8f2cdf33cb752bb6/coro/http/client.py#L41-L47
sefakilic/goodreads
5187100d66b87c87db8b095bbf576e1b92422a23
goodreads/event.py
python
GoodreadsEvent.start_at
(self)
return self._event_dict['start_at']['#text']
Event starts at
Event starts at
[ "Event", "starts", "at" ]
def start_at(self): """Event starts at""" return self._event_dict['start_at']['#text']
[ "def", "start_at", "(", "self", ")", ":", "return", "self", ".", "_event_dict", "[", "'start_at'", "]", "[", "'#text'", "]" ]
https://github.com/sefakilic/goodreads/blob/5187100d66b87c87db8b095bbf576e1b92422a23/goodreads/event.py#L102-L104
materialsproject/fireworks
83a907c19baf2a5c9fdcf63996f9797c3c85b785
fireworks/core/launchpad.py
python
LaunchPad.defuse_wf
(self, fw_id, defuse_all_states=True)
Defuse the workflow containing the given firework id. Args: fw_id (int): firework id defuse_all_states (bool)
Defuse the workflow containing the given firework id.
[ "Defuse", "the", "workflow", "containing", "the", "given", "firework", "id", "." ]
def defuse_wf(self, fw_id, defuse_all_states=True): """ Defuse the workflow containing the given firework id. Args: fw_id (int): firework id defuse_all_states (bool) """ wf = self.get_wf_by_fw_id_lzyfw(fw_id) for fw in wf: if fw.state not in ["COMPLETED", "FIZZLED"] or defuse_all_states: self.defuse_fw(fw.fw_id)
[ "def", "defuse_wf", "(", "self", ",", "fw_id", ",", "defuse_all_states", "=", "True", ")", ":", "wf", "=", "self", ".", "get_wf_by_fw_id_lzyfw", "(", "fw_id", ")", "for", "fw", "in", "wf", ":", "if", "fw", ".", "state", "not", "in", "[", "\"COMPLETED\"...
https://github.com/materialsproject/fireworks/blob/83a907c19baf2a5c9fdcf63996f9797c3c85b785/fireworks/core/launchpad.py#L1052-L1063
plotly/plotly.py
cfad7862594b35965c0e000813bd7805e8494a5b
packages/python/plotly/plotly/graph_objs/scatter/_legendgrouptitle.py
python
Legendgrouptitle.__init__
(self, arg=None, font=None, text=None, **kwargs)
Construct a new Legendgrouptitle object Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.scatter.Legendgrouptitle` font Sets this legend group's title font. text Sets the title of the legend group. Returns ------- Legendgrouptitle
Construct a new Legendgrouptitle object Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.scatter.Legendgrouptitle` font Sets this legend group's title font. text Sets the title of the legend group.
[ "Construct", "a", "new", "Legendgrouptitle", "object", "Parameters", "----------", "arg", "dict", "of", "properties", "compatible", "with", "this", "constructor", "or", "an", "instance", "of", ":", "class", ":", "plotly", ".", "graph_objs", ".", "scatter", ".", ...
def __init__(self, arg=None, font=None, text=None, **kwargs): """ Construct a new Legendgrouptitle object Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.scatter.Legendgrouptitle` font Sets this legend group's title font. text Sets the title of the legend group. Returns ------- Legendgrouptitle """ super(Legendgrouptitle, self).__init__("legendgrouptitle") if "_parent" in kwargs: self._parent = kwargs["_parent"] return # Validate arg # ------------ if arg is None: arg = {} elif isinstance(arg, self.__class__): arg = arg.to_plotly_json() elif isinstance(arg, dict): arg = _copy.copy(arg) else: raise ValueError( """\ The first argument to the plotly.graph_objs.scatter.Legendgrouptitle constructor must be a dict or an instance of :class:`plotly.graph_objs.scatter.Legendgrouptitle`""" ) # Handle skip_invalid # ------------------- self._skip_invalid = kwargs.pop("skip_invalid", False) self._validate = kwargs.pop("_validate", True) # Populate data dict with properties # ---------------------------------- _v = arg.pop("font", None) _v = font if font is not None else _v if _v is not None: self["font"] = _v _v = arg.pop("text", None) _v = text if text is not None else _v if _v is not None: self["text"] = _v # Process unknown kwargs # ---------------------- self._process_kwargs(**dict(arg, **kwargs)) # Reset skip_invalid # ------------------ self._skip_invalid = False
[ "def", "__init__", "(", "self", ",", "arg", "=", "None", ",", "font", "=", "None", ",", "text", "=", "None", ",", "*", "*", "kwargs", ")", ":", "super", "(", "Legendgrouptitle", ",", "self", ")", ".", "__init__", "(", "\"legendgrouptitle\"", ")", "if...
https://github.com/plotly/plotly.py/blob/cfad7862594b35965c0e000813bd7805e8494a5b/packages/python/plotly/plotly/graph_objs/scatter/_legendgrouptitle.py#L91-L154
robinhood/faust
01b4c0ad8390221db71751d80001b0fd879291e2
faust/streams.py
python
Stream.on_stop
(self)
Signal that the stream is stopping.
Signal that the stream is stopping.
[ "Signal", "that", "the", "stream", "is", "stopping", "." ]
async def on_stop(self) -> None: """Signal that the stream is stopping.""" self._passive = False self._passive_started.clear() for table_or_stream in self.combined: await table_or_stream.remove_from_stream(self)
[ "async", "def", "on_stop", "(", "self", ")", "->", "None", ":", "self", ".", "_passive", "=", "False", "self", ".", "_passive_started", ".", "clear", "(", ")", "for", "table_or_stream", "in", "self", ".", "combined", ":", "await", "table_or_stream", ".", ...
https://github.com/robinhood/faust/blob/01b4c0ad8390221db71751d80001b0fd879291e2/faust/streams.py#L740-L745
krintoxi/NoobSec-Toolkit
38738541cbc03cedb9a3b3ed13b629f781ad64f6
NoobSecToolkit - MAC OSX/tools/inject/plugins/generic/search.py
python
Search.searchTable
(self)
[]
def searchTable(self): bruteForce = False if Backend.isDbms(DBMS.MYSQL) and not kb.data.has_information_schema: errMsg = "information_schema not available, " errMsg += "back-end DBMS is MySQL < 5.0" bruteForce = True if bruteForce: message = "do you want to use common table existence check? %s" % ("[Y/n/q]" if Backend.getIdentifiedDbms() in (DBMS.ACCESS,) else "[y/N/q]") test = readInput(message, default="Y" if "Y" in message else "N") if test[0] in ("n", "N"): return elif test[0] in ("q", "Q"): raise SqlmapUserQuitException else: regex = "|".join(conf.tbl.split(",")) return tableExists(paths.COMMON_TABLES, regex) foundTbls = {} tblList = conf.tbl.split(",") rootQuery = queries[Backend.getIdentifiedDbms()].search_table tblCond = rootQuery.inband.condition dbCond = rootQuery.inband.condition2 tblConsider, tblCondParam = self.likeOrExact("table") for tbl in tblList: values = [] tbl = safeSQLIdentificatorNaming(tbl, True) if Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2, DBMS.FIREBIRD): tbl = tbl.upper() infoMsg = "searching table" if tblConsider == "1": infoMsg += "s LIKE" infoMsg += " '%s'" % unsafeSQLIdentificatorNaming(tbl) if dbCond and conf.db and conf.db != CURRENT_DB: _ = conf.db.split(",") whereDbsQuery = " AND (" + " OR ".join("%s = '%s'" % (dbCond, unsafeSQLIdentificatorNaming(db)) for db in _) + ")" infoMsg += " for database%s '%s'" % ("s" if len(_) > 1 else "", ", ".join(db for db in _)) elif conf.excludeSysDbs: whereDbsQuery = "".join(" AND '%s' != %s" % (unsafeSQLIdentificatorNaming(db), dbCond) for db in self.excludeDbsList) infoMsg2 = "skipping system database%s '%s'" % ("s" if len(self.excludeDbsList) > 1 else "", ", ".join(db for db in self.excludeDbsList)) logger.info(infoMsg2) else: whereDbsQuery = "" logger.info(infoMsg) tblQuery = "%s%s" % (tblCond, tblCondParam) tblQuery = tblQuery % unsafeSQLIdentificatorNaming(tbl) if any(isTechniqueAvailable(_) for _ in (PAYLOAD.TECHNIQUE.UNION, PAYLOAD.TECHNIQUE.ERROR, PAYLOAD.TECHNIQUE.QUERY)) or conf.direct: query = rootQuery.inband.query query = query % (tblQuery + whereDbsQuery) values = inject.getValue(query, blind=False, time=False) if values and Backend.getIdentifiedDbms() in (DBMS.SQLITE, DBMS.FIREBIRD): newValues = [] if isinstance(values, basestring): values = [values] for value in values: dbName = "SQLite" if Backend.isDbms(DBMS.SQLITE) else "Firebird" newValues.append(["%s%s" % (dbName, METADB_SUFFIX), value]) values = newValues for foundDb, foundTbl in filterPairValues(values): foundDb = safeSQLIdentificatorNaming(foundDb) foundTbl = safeSQLIdentificatorNaming(foundTbl, True) if foundDb is None or foundTbl is None: continue if foundDb in foundTbls: foundTbls[foundDb].append(foundTbl) else: foundTbls[foundDb] = [foundTbl] if not values and isInferenceAvailable() and not conf.direct: if Backend.getIdentifiedDbms() not in (DBMS.SQLITE, DBMS.FIREBIRD): if len(whereDbsQuery) == 0: infoMsg = "fetching number of databases with table" if tblConsider == "1": infoMsg += "s LIKE" infoMsg += " '%s'" % unsafeSQLIdentificatorNaming(tbl) logger.info(infoMsg) query = rootQuery.blind.count query = query % (tblQuery + whereDbsQuery) count = inject.getValue(query, union=False, error=False, expected=EXPECTED.INT, charsetType=CHARSET_TYPE.DIGITS) if not isNumPosStrValue(count): warnMsg = "no databases have table" if tblConsider == "1": warnMsg += "s LIKE" warnMsg += " '%s'" % unsafeSQLIdentificatorNaming(tbl) logger.warn(warnMsg) continue indexRange = getLimitRange(count) for index in indexRange: query = rootQuery.blind.query query = query % (tblQuery + whereDbsQuery) query = agent.limitQuery(index, query) foundDb = unArrayizeValue(inject.getValue(query, union=False, error=False)) foundDb = safeSQLIdentificatorNaming(foundDb) if foundDb not in foundTbls: foundTbls[foundDb] = [] if tblConsider == "2": foundTbls[foundDb].append(tbl) if tblConsider == "2": continue else: for db in conf.db.split(",") if conf.db else (self.getCurrentDb(),): db = safeSQLIdentificatorNaming(db) if db not in foundTbls: foundTbls[db] = [] else: dbName = "SQLite" if Backend.isDbms(DBMS.SQLITE) else "Firebird" foundTbls["%s%s" % (dbName, METADB_SUFFIX)] = [] for db in foundTbls.keys(): db = safeSQLIdentificatorNaming(db) infoMsg = "fetching number of table" if tblConsider == "1": infoMsg += "s LIKE" infoMsg += " '%s' in database '%s'" % (unsafeSQLIdentificatorNaming(tbl), unsafeSQLIdentificatorNaming(db)) logger.info(infoMsg) query = rootQuery.blind.count2 if Backend.getIdentifiedDbms() not in (DBMS.SQLITE, DBMS.FIREBIRD): query = query % unsafeSQLIdentificatorNaming(db) query += " AND %s" % tblQuery count = inject.getValue(query, union=False, error=False, expected=EXPECTED.INT, charsetType=CHARSET_TYPE.DIGITS) if not isNumPosStrValue(count): warnMsg = "no table" if tblConsider == "1": warnMsg += "s LIKE" warnMsg += " '%s' " % unsafeSQLIdentificatorNaming(tbl) warnMsg += "in database '%s'" % unsafeSQLIdentificatorNaming(db) logger.warn(warnMsg) continue indexRange = getLimitRange(count) for index in indexRange: query = rootQuery.blind.query2 if query.endswith("'%s')"): query = query[:-1] + " AND %s)" % tblQuery else: query += " AND %s" % tblQuery if Backend.isDbms(DBMS.FIREBIRD): query = safeStringFormat(query, index) if Backend.getIdentifiedDbms() not in (DBMS.SQLITE, DBMS.FIREBIRD): query = safeStringFormat(query, unsafeSQLIdentificatorNaming(db)) if not Backend.isDbms(DBMS.FIREBIRD): query = agent.limitQuery(index, query) foundTbl = unArrayizeValue(inject.getValue(query, union=False, error=False)) if not isNoneValue(foundTbl): kb.hintValue = foundTbl foundTbl = safeSQLIdentificatorNaming(foundTbl, True) foundTbls[db].append(foundTbl) for db in foundTbls.keys(): if isNoneValue(foundTbls[db]): del foundTbls[db] if not foundTbls: warnMsg = "no databases contain any of the provided tables" logger.warn(warnMsg) return conf.dumper.dbTables(foundTbls) self.dumpFoundTables(foundTbls)
[ "def", "searchTable", "(", "self", ")", ":", "bruteForce", "=", "False", "if", "Backend", ".", "isDbms", "(", "DBMS", ".", "MYSQL", ")", "and", "not", "kb", ".", "data", ".", "has_information_schema", ":", "errMsg", "=", "\"information_schema not available, \"...
https://github.com/krintoxi/NoobSec-Toolkit/blob/38738541cbc03cedb9a3b3ed13b629f781ad64f6/NoobSecToolkit - MAC OSX/tools/inject/plugins/generic/search.py#L139-L333
jparkhill/TensorMol
d52104dc7ee46eec8301d332a95d672270ac0bd1
TensorMol/TFNetworks/TFBehlerParinelloSymEE.py
python
MolInstance_DirectBP_Charge_SymFunction.train_step
(self, step)
return
Perform a single training step (complete processing of all input), using minibatches of size self.batch_size. Training object including dipole, energy and gradient Args: step: the index of this step.
Perform a single training step (complete processing of all input), using minibatches of size self.batch_size. Training object including dipole, energy and gradient
[ "Perform", "a", "single", "training", "step", "(", "complete", "processing", "of", "all", "input", ")", "using", "minibatches", "of", "size", "self", ".", "batch_size", ".", "Training", "object", "including", "dipole", "energy", "and", "gradient" ]
def train_step(self, step): """ Perform a single training step (complete processing of all input), using minibatches of size self.batch_size. Training object including dipole, energy and gradient Args: step: the index of this step. """ Ncase_train = self.TData.NTrain start_time = time.time() train_loss = 0.0 num_of_mols = 0 pre_output = np.zeros((self.batch_size),dtype=np.float64) for ministep in range (0, int(Ncase_train/self.batch_size)): batch_data = self.TData.GetTrainBatch(self.batch_size)+ [self.keep_prob] actual_mols = self.batch_size t = time.time() dump_2, total_loss_value, dipole_loss, dipole, charge, debug1 = self.sess.run([self.train_op, self.total_loss, self.dipole_loss, self.dipole, self.charge, self.debug1], feed_dict=self.fill_feed_dict(batch_data)) train_loss = train_loss + dipole_loss duration = time.time() - start_time num_of_mols += actual_mols #print ("dipole:", dipole, dipole.shape, dipole[0], np.sum(dipole[0])) #print ("charge:", charge, charge.shape, charge[-1], np.sum(charge[-1])) #print ("debug1:", debug1, debug1.shape, debug1[-1], np.sum(debug1[-1])) #xyz = batch_data[0][-1]*BOHRPERA #natom = int(1/ batch_data[-2][-1]) #charge = charge[-1] #field = np.zeros(3) #for i in range(0, natom-1): # field += charge[i]*(xyz[natom-1] - xyz[i])/np.linalg.norm(xyz[natom-1] - xyz[i])**2 #print ("xyz:", xyz,"charge:", charge, "field:", field) self.print_training(step, train_loss, num_of_mols, duration) return
[ "def", "train_step", "(", "self", ",", "step", ")", ":", "Ncase_train", "=", "self", ".", "TData", ".", "NTrain", "start_time", "=", "time", ".", "time", "(", ")", "train_loss", "=", "0.0", "num_of_mols", "=", "0", "pre_output", "=", "np", ".", "zeros"...
https://github.com/jparkhill/TensorMol/blob/d52104dc7ee46eec8301d332a95d672270ac0bd1/TensorMol/TFNetworks/TFBehlerParinelloSymEE.py#L2156-L2189
tribe29/checkmk
6260f2512e159e311f426e16b84b19d0b8e9ad0c
cmk/gui/livestatus_utils/commands/downtimes.py
python
delete_downtime
(connection, downtime_id)
Delete a scheduled downtime based upon the downtime id
Delete a scheduled downtime based upon the downtime id
[ "Delete", "a", "scheduled", "downtime", "based", "upon", "the", "downtime", "id" ]
def delete_downtime(connection, downtime_id): """Delete a scheduled downtime based upon the downtime id""" with detailed_connection(connection) as conn: entry = Query( [Downtimes.is_service], Downtimes.id == downtime_id, ).fetchone(conn) if entry["is_service"]: del_service_downtime(connection, downtime_id, entry["site"]) else: del_host_downtime(connection, downtime_id, entry["site"])
[ "def", "delete_downtime", "(", "connection", ",", "downtime_id", ")", ":", "with", "detailed_connection", "(", "connection", ")", "as", "conn", ":", "entry", "=", "Query", "(", "[", "Downtimes", ".", "is_service", "]", ",", "Downtimes", ".", "id", "==", "d...
https://github.com/tribe29/checkmk/blob/6260f2512e159e311f426e16b84b19d0b8e9ad0c/cmk/gui/livestatus_utils/commands/downtimes.py#L110-L120
Azure/azure-storage-python
4306898850dd21617644fc537a57d025e833db74
azure-storage-blob/azure/storage/blob/blockblobservice.py
python
BlockBlobService.__init__
(self, account_name=None, account_key=None, sas_token=None, is_emulated=False, protocol=DEFAULT_PROTOCOL, endpoint_suffix=SERVICE_HOST_BASE, custom_domain=None, request_session=None, connection_string=None, socket_timeout=None, token_credential=None)
:param str account_name: The storage account name. This is used to authenticate requests signed with an account key and to construct the storage endpoint. It is required unless a connection string is given, or if a custom domain is used with anonymous authentication. :param str account_key: The storage account key. This is used for shared key authentication. If neither account key or sas token is specified, anonymous access will be used. :param str sas_token: A shared access signature token to use to authenticate requests instead of the account key. If account key and sas token are both specified, account key will be used to sign. If neither are specified, anonymous access will be used. :param bool is_emulated: Whether to use the emulator. Defaults to False. If specified, will override all other parameters besides connection string and request session. :param str protocol: The protocol to use for requests. Defaults to https. :param str endpoint_suffix: The host base component of the url, minus the account name. Defaults to Azure (core.windows.net). Override this to use the China cloud (core.chinacloudapi.cn). :param str custom_domain: The custom domain to use. This can be set in the Azure Portal. For example, 'www.mydomain.com'. :param requests.Session request_session: The session object to use for http requests. :param str connection_string: If specified, this will override all other parameters besides request session. See http://azure.microsoft.com/en-us/documentation/articles/storage-configure-connection-string/ for the connection string format. :param int socket_timeout: If specified, this will override the default socket timeout. The timeout specified is in seconds. See DEFAULT_SOCKET_TIMEOUT in _constants.py for the default value. :param token_credential: A token credential used to authenticate HTTPS requests. The token value should be updated before its expiration. :type `~azure.storage.common.TokenCredential`
:param str account_name: The storage account name. This is used to authenticate requests signed with an account key and to construct the storage endpoint. It is required unless a connection string is given, or if a custom domain is used with anonymous authentication. :param str account_key: The storage account key. This is used for shared key authentication. If neither account key or sas token is specified, anonymous access will be used. :param str sas_token: A shared access signature token to use to authenticate requests instead of the account key. If account key and sas token are both specified, account key will be used to sign. If neither are specified, anonymous access will be used. :param bool is_emulated: Whether to use the emulator. Defaults to False. If specified, will override all other parameters besides connection string and request session. :param str protocol: The protocol to use for requests. Defaults to https. :param str endpoint_suffix: The host base component of the url, minus the account name. Defaults to Azure (core.windows.net). Override this to use the China cloud (core.chinacloudapi.cn). :param str custom_domain: The custom domain to use. This can be set in the Azure Portal. For example, 'www.mydomain.com'. :param requests.Session request_session: The session object to use for http requests. :param str connection_string: If specified, this will override all other parameters besides request session. See http://azure.microsoft.com/en-us/documentation/articles/storage-configure-connection-string/ for the connection string format. :param int socket_timeout: If specified, this will override the default socket timeout. The timeout specified is in seconds. See DEFAULT_SOCKET_TIMEOUT in _constants.py for the default value. :param token_credential: A token credential used to authenticate HTTPS requests. The token value should be updated before its expiration. :type `~azure.storage.common.TokenCredential`
[ ":", "param", "str", "account_name", ":", "The", "storage", "account", "name", ".", "This", "is", "used", "to", "authenticate", "requests", "signed", "with", "an", "account", "key", "and", "to", "construct", "the", "storage", "endpoint", ".", "It", "is", "...
def __init__(self, account_name=None, account_key=None, sas_token=None, is_emulated=False, protocol=DEFAULT_PROTOCOL, endpoint_suffix=SERVICE_HOST_BASE, custom_domain=None, request_session=None, connection_string=None, socket_timeout=None, token_credential=None): ''' :param str account_name: The storage account name. This is used to authenticate requests signed with an account key and to construct the storage endpoint. It is required unless a connection string is given, or if a custom domain is used with anonymous authentication. :param str account_key: The storage account key. This is used for shared key authentication. If neither account key or sas token is specified, anonymous access will be used. :param str sas_token: A shared access signature token to use to authenticate requests instead of the account key. If account key and sas token are both specified, account key will be used to sign. If neither are specified, anonymous access will be used. :param bool is_emulated: Whether to use the emulator. Defaults to False. If specified, will override all other parameters besides connection string and request session. :param str protocol: The protocol to use for requests. Defaults to https. :param str endpoint_suffix: The host base component of the url, minus the account name. Defaults to Azure (core.windows.net). Override this to use the China cloud (core.chinacloudapi.cn). :param str custom_domain: The custom domain to use. This can be set in the Azure Portal. For example, 'www.mydomain.com'. :param requests.Session request_session: The session object to use for http requests. :param str connection_string: If specified, this will override all other parameters besides request session. See http://azure.microsoft.com/en-us/documentation/articles/storage-configure-connection-string/ for the connection string format. :param int socket_timeout: If specified, this will override the default socket timeout. The timeout specified is in seconds. See DEFAULT_SOCKET_TIMEOUT in _constants.py for the default value. :param token_credential: A token credential used to authenticate HTTPS requests. The token value should be updated before its expiration. :type `~azure.storage.common.TokenCredential` ''' self.blob_type = _BlobTypes.BlockBlob super(BlockBlobService, self).__init__( account_name, account_key, sas_token, is_emulated, protocol, endpoint_suffix, custom_domain, request_session, connection_string, socket_timeout, token_credential)
[ "def", "__init__", "(", "self", ",", "account_name", "=", "None", ",", "account_key", "=", "None", ",", "sas_token", "=", "None", ",", "is_emulated", "=", "False", ",", "protocol", "=", "DEFAULT_PROTOCOL", ",", "endpoint_suffix", "=", "SERVICE_HOST_BASE", ",",...
https://github.com/Azure/azure-storage-python/blob/4306898850dd21617644fc537a57d025e833db74/azure-storage-blob/azure/storage/blob/blockblobservice.py#L101-L150
PaddlePaddle/Research
2da0bd6c72d60e9df403aff23a7802779561c4a1
KG/DuEE_baseline/bin/utils/utils.py
python
read_by_lines
(path, encoding="utf-8")
return result
read the data by line
read the data by line
[ "read", "the", "data", "by", "line" ]
def read_by_lines(path, encoding="utf-8"): """read the data by line""" result = list() with open(path, "r") as infile: for line in infile: result.append(line.strip().decode(encoding)) return result
[ "def", "read_by_lines", "(", "path", ",", "encoding", "=", "\"utf-8\"", ")", ":", "result", "=", "list", "(", ")", "with", "open", "(", "path", ",", "\"r\"", ")", "as", "infile", ":", "for", "line", "in", "infile", ":", "result", ".", "append", "(", ...
https://github.com/PaddlePaddle/Research/blob/2da0bd6c72d60e9df403aff23a7802779561c4a1/KG/DuEE_baseline/bin/utils/utils.py#L9-L15
caiiiac/Machine-Learning-with-Python
1a26c4467da41ca4ebc3d5bd789ea942ef79422f
MachineLearning/venv/lib/python3.5/site-packages/sklearn/linear_model/stochastic_gradient.py
python
BaseSGDRegressor.fit
(self, X, y, coef_init=None, intercept_init=None, sample_weight=None)
return self._fit(X, y, alpha=self.alpha, C=1.0, loss=self.loss, learning_rate=self.learning_rate, coef_init=coef_init, intercept_init=intercept_init, sample_weight=sample_weight)
Fit linear model with Stochastic Gradient Descent. Parameters ---------- X : {array-like, sparse matrix}, shape (n_samples, n_features) Training data y : numpy array, shape (n_samples,) Target values coef_init : array, shape (n_features,) The initial coefficients to warm-start the optimization. intercept_init : array, shape (1,) The initial intercept to warm-start the optimization. sample_weight : array-like, shape (n_samples,), optional Weights applied to individual samples (1. for unweighted). Returns ------- self : returns an instance of self.
Fit linear model with Stochastic Gradient Descent.
[ "Fit", "linear", "model", "with", "Stochastic", "Gradient", "Descent", "." ]
def fit(self, X, y, coef_init=None, intercept_init=None, sample_weight=None): """Fit linear model with Stochastic Gradient Descent. Parameters ---------- X : {array-like, sparse matrix}, shape (n_samples, n_features) Training data y : numpy array, shape (n_samples,) Target values coef_init : array, shape (n_features,) The initial coefficients to warm-start the optimization. intercept_init : array, shape (1,) The initial intercept to warm-start the optimization. sample_weight : array-like, shape (n_samples,), optional Weights applied to individual samples (1. for unweighted). Returns ------- self : returns an instance of self. """ return self._fit(X, y, alpha=self.alpha, C=1.0, loss=self.loss, learning_rate=self.learning_rate, coef_init=coef_init, intercept_init=intercept_init, sample_weight=sample_weight)
[ "def", "fit", "(", "self", ",", "X", ",", "y", ",", "coef_init", "=", "None", ",", "intercept_init", "=", "None", ",", "sample_weight", "=", "None", ")", ":", "return", "self", ".", "_fit", "(", "X", ",", "y", ",", "alpha", "=", "self", ".", "alp...
https://github.com/caiiiac/Machine-Learning-with-Python/blob/1a26c4467da41ca4ebc3d5bd789ea942ef79422f/MachineLearning/venv/lib/python3.5/site-packages/sklearn/linear_model/stochastic_gradient.py#L944-L973
microsoft/ptvsd
99c8513921021d2cc7cd82e132b65c644c256768
src/ptvsd/_vendored/pydevd/stubs/_django_manager_body.py
python
_update
(self, *args, **kwargs)
A version of update that accepts field objects instead of field names. Used primarily for model saving and not intended for use by general code (it requires too much poking around at model internals to be useful at that level).
A version of update that accepts field objects instead of field names. Used primarily for model saving and not intended for use by general code (it requires too much poking around at model internals to be useful at that level).
[ "A", "version", "of", "update", "that", "accepts", "field", "objects", "instead", "of", "field", "names", ".", "Used", "primarily", "for", "model", "saving", "and", "not", "intended", "for", "use", "by", "general", "code", "(", "it", "requires", "too", "mu...
def _update(self, *args, **kwargs): """ A version of update that accepts field objects instead of field names. Used primarily for model saving and not intended for use by general code (it requires too much poking around at model internals to be useful at that level). """
[ "def", "_update", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":" ]
https://github.com/microsoft/ptvsd/blob/99c8513921021d2cc7cd82e132b65c644c256768/src/ptvsd/_vendored/pydevd/stubs/_django_manager_body.py#L68-L74
Source-Python-Dev-Team/Source.Python
d0ffd8ccbd1e9923c9bc44936f20613c1c76b7fb
addons/source-python/Python3/email/message.py
python
Message.keys
(self)
return [k for k, v in self._headers]
Return a list of all the message's header field names. These will be sorted in the order they appeared in the original message, or were added to the message, and may contain duplicates. Any fields deleted and re-inserted are always appended to the header list.
Return a list of all the message's header field names.
[ "Return", "a", "list", "of", "all", "the", "message", "s", "header", "field", "names", "." ]
def keys(self): """Return a list of all the message's header field names. These will be sorted in the order they appeared in the original message, or were added to the message, and may contain duplicates. Any fields deleted and re-inserted are always appended to the header list. """ return [k for k, v in self._headers]
[ "def", "keys", "(", "self", ")", ":", "return", "[", "k", "for", "k", ",", "v", "in", "self", ".", "_headers", "]" ]
https://github.com/Source-Python-Dev-Team/Source.Python/blob/d0ffd8ccbd1e9923c9bc44936f20613c1c76b7fb/addons/source-python/Python3/email/message.py#L430-L438
holzschu/Carnets
44effb10ddfc6aa5c8b0687582a724ba82c6b547
Library/lib/python3.7/site-packages/matplotlib-3.0.3-py3.7-macosx-10.9-x86_64.egg/matplotlib/ticker.py
python
FixedLocator.set_params
(self, nbins=None)
Set parameters within this locator.
Set parameters within this locator.
[ "Set", "parameters", "within", "this", "locator", "." ]
def set_params(self, nbins=None): """Set parameters within this locator.""" if nbins is not None: self.nbins = nbins
[ "def", "set_params", "(", "self", ",", "nbins", "=", "None", ")", ":", "if", "nbins", "is", "not", "None", ":", "self", ".", "nbins", "=", "nbins" ]
https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/site-packages/matplotlib-3.0.3-py3.7-macosx-10.9-x86_64.egg/matplotlib/ticker.py#L1542-L1545
general03/flask-autoindex
424246242c9f40aeb9ac2c8c63f4d2234024256e
.eggs/Werkzeug-1.0.1-py3.7.egg/werkzeug/wrappers/base_response.py
python
BaseResponse.get_app_iter
(self, environ)
return ClosingIterator(iterable, self.close)
Returns the application iterator for the given environ. Depending on the request method and the current status code the return value might be an empty response rather than the one from the response. If the request method is `HEAD` or the status code is in a range where the HTTP specification requires an empty response, an empty iterable is returned. .. versionadded:: 0.6 :param environ: the WSGI environment of the request. :return: a response iterable.
Returns the application iterator for the given environ. Depending on the request method and the current status code the return value might be an empty response rather than the one from the response.
[ "Returns", "the", "application", "iterator", "for", "the", "given", "environ", ".", "Depending", "on", "the", "request", "method", "and", "the", "current", "status", "code", "the", "return", "value", "might", "be", "an", "empty", "response", "rather", "than", ...
def get_app_iter(self, environ): """Returns the application iterator for the given environ. Depending on the request method and the current status code the return value might be an empty response rather than the one from the response. If the request method is `HEAD` or the status code is in a range where the HTTP specification requires an empty response, an empty iterable is returned. .. versionadded:: 0.6 :param environ: the WSGI environment of the request. :return: a response iterable. """ status = self.status_code if ( environ["REQUEST_METHOD"] == "HEAD" or 100 <= status < 200 or status in (204, 304) ): iterable = () elif self.direct_passthrough: if __debug__: _warn_if_string(self.response) return self.response else: iterable = self.iter_encoded() return ClosingIterator(iterable, self.close)
[ "def", "get_app_iter", "(", "self", ",", "environ", ")", ":", "status", "=", "self", ".", "status_code", "if", "(", "environ", "[", "\"REQUEST_METHOD\"", "]", "==", "\"HEAD\"", "or", "100", "<=", "status", "<", "200", "or", "status", "in", "(", "204", ...
https://github.com/general03/flask-autoindex/blob/424246242c9f40aeb9ac2c8c63f4d2234024256e/.eggs/Werkzeug-1.0.1-py3.7.egg/werkzeug/wrappers/base_response.py#L644-L671
Liusifei/UVC
36bc6b2c99366a6d1a6033229d395f3c88ff656b
libs/vis_utils.py
python
compute_color
(u, v)
return img
compute optical flow color map :param u: optical flow horizontal map :param v: optical flow vertical map :return: optical flow in color code
compute optical flow color map :param u: optical flow horizontal map :param v: optical flow vertical map :return: optical flow in color code
[ "compute", "optical", "flow", "color", "map", ":", "param", "u", ":", "optical", "flow", "horizontal", "map", ":", "param", "v", ":", "optical", "flow", "vertical", "map", ":", "return", ":", "optical", "flow", "in", "color", "code" ]
def compute_color(u, v): """ compute optical flow color map :param u: optical flow horizontal map :param v: optical flow vertical map :return: optical flow in color code """ [h, w] = u.shape img = np.zeros([h, w, 3]) nanIdx = np.isnan(u) | np.isnan(v) u[nanIdx] = 0 v[nanIdx] = 0 colorwheel = make_color_wheel() ncols = np.size(colorwheel, 0) rad = np.sqrt(u**2+v**2) a = np.arctan2(-v, -u) / np.pi fk = (a+1) / 2 * (ncols - 1) + 1 k0 = np.floor(fk).astype(int) k1 = k0 + 1 k1[k1 == ncols+1] = 1 f = fk - k0 for i in range(0, np.size(colorwheel,1)): tmp = colorwheel[:, i] col0 = tmp[k0-1] / 255 col1 = tmp[k1-1] / 255 col = (1-f) * col0 + f * col1 idx = rad <= 1 col[idx] = 1-rad[idx]*(1-col[idx]) notidx = np.logical_not(idx) col[notidx] *= 0.75 img[:, :, i] = np.uint8(np.floor(255 * col*(1-nanIdx))) return img
[ "def", "compute_color", "(", "u", ",", "v", ")", ":", "[", "h", ",", "w", "]", "=", "u", ".", "shape", "img", "=", "np", ".", "zeros", "(", "[", "h", ",", "w", ",", "3", "]", ")", "nanIdx", "=", "np", ".", "isnan", "(", "u", ")", "|", "...
https://github.com/Liusifei/UVC/blob/36bc6b2c99366a6d1a6033229d395f3c88ff656b/libs/vis_utils.py#L66-L107
mikew/ss-plex.bundle
031566c06205e08a8cb15c57a0c143fba5270493
Contents/Libraries/Shared/ss/mechanize/_opener.py
python
OpenerDirector.retrieve
(self, fullurl, filename=None, reporthook=None, data=None, timeout=_sockettimeout._GLOBAL_DEFAULT_TIMEOUT, open=open_file)
return result
Returns (filename, headers). For remote objects, the default filename will refer to a temporary file. Temporary files are removed when the OpenerDirector.close() method is called. For file: URLs, at present the returned filename is None. This may change in future. If the actual number of bytes read is less than indicated by the Content-Length header, raises ContentTooShortError (a URLError subclass). The exception's .result attribute contains the (filename, headers) that would have been returned.
Returns (filename, headers).
[ "Returns", "(", "filename", "headers", ")", "." ]
def retrieve(self, fullurl, filename=None, reporthook=None, data=None, timeout=_sockettimeout._GLOBAL_DEFAULT_TIMEOUT, open=open_file): """Returns (filename, headers). For remote objects, the default filename will refer to a temporary file. Temporary files are removed when the OpenerDirector.close() method is called. For file: URLs, at present the returned filename is None. This may change in future. If the actual number of bytes read is less than indicated by the Content-Length header, raises ContentTooShortError (a URLError subclass). The exception's .result attribute contains the (filename, headers) that would have been returned. """ req = self._request(fullurl, data, False, timeout) scheme = req.get_type() fp = self.open(req) try: headers = fp.info() if filename is None and scheme == 'file': # XXX req.get_selector() seems broken here, return None, # pending sanity :-/ return None, headers #return urllib.url2pathname(req.get_selector()), headers if filename: tfp = open(filename, 'wb') else: path = _rfc3986.urlsplit(req.get_full_url())[2] suffix = os.path.splitext(path)[1] fd, filename = tempfile.mkstemp(suffix) self._tempfiles.append(filename) tfp = os.fdopen(fd, 'wb') try: result = filename, headers bs = self.BLOCK_SIZE size = -1 read = 0 blocknum = 0 if reporthook: if "content-length" in headers: size = int(headers["Content-Length"]) reporthook(blocknum, bs, size) while 1: block = fp.read(bs) if block == "": break read += len(block) tfp.write(block) blocknum += 1 if reporthook: reporthook(blocknum, bs, size) finally: tfp.close() finally: fp.close() # raise exception if actual size does not match content-length header if size >= 0 and read < size: raise ContentTooShortError( "retrieval incomplete: " "got only %i out of %i bytes" % (read, size), result ) return result
[ "def", "retrieve", "(", "self", ",", "fullurl", ",", "filename", "=", "None", ",", "reporthook", "=", "None", ",", "data", "=", "None", ",", "timeout", "=", "_sockettimeout", ".", "_GLOBAL_DEFAULT_TIMEOUT", ",", "open", "=", "open_file", ")", ":", "req", ...
https://github.com/mikew/ss-plex.bundle/blob/031566c06205e08a8cb15c57a0c143fba5270493/Contents/Libraries/Shared/ss/mechanize/_opener.py#L230-L298
Tautulli/Tautulli
2410eb33805aaac4bd1c5dad0f71e4f15afaf742
lib/gntp/core.py
python
GNTPRegister.validate
(self)
Validate required headers and validate notification headers
Validate required headers and validate notification headers
[ "Validate", "required", "headers", "and", "validate", "notification", "headers" ]
def validate(self): '''Validate required headers and validate notification headers''' for header in self._requiredHeaders: if not self.headers.get(header, False): raise errors.ParseError('Missing Registration Header: ' + header) for notice in self.notifications: for header in self._requiredNotificationHeaders: if not notice.get(header, False): raise errors.ParseError('Missing Notification Header: ' + header)
[ "def", "validate", "(", "self", ")", ":", "for", "header", "in", "self", ".", "_requiredHeaders", ":", "if", "not", "self", ".", "headers", ".", "get", "(", "header", ",", "False", ")", ":", "raise", "errors", ".", "ParseError", "(", "'Missing Registrati...
https://github.com/Tautulli/Tautulli/blob/2410eb33805aaac4bd1c5dad0f71e4f15afaf742/lib/gntp/core.py#L307-L315
delira-dev/delira
cd3ad277d6fad5f837d6c5147e6eee2ada648596
delira/data_loading/augmenter.py
python
Augmenter.__iter__
(self)
Makes the Augmenter iterable by generators Returns ------- Generator a generator function yielding the arguments
Makes the Augmenter iterable by generators Returns ------- Generator a generator function yielding the arguments
[ "Makes", "the", "Augmenter", "iterable", "by", "generators", "Returns", "-------", "Generator", "a", "generator", "function", "yielding", "the", "arguments" ]
def __iter__(self): """ Makes the Augmenter iterable by generators Returns ------- Generator a generator function yielding the arguments """ yield from self._augmenter
[ "def", "__iter__", "(", "self", ")", ":", "yield", "from", "self", ".", "_augmenter" ]
https://github.com/delira-dev/delira/blob/cd3ad277d6fad5f837d6c5147e6eee2ada648596/delira/data_loading/augmenter.py#L503-L511
ajinabraham/OWASP-Xenotix-XSS-Exploit-Framework
cb692f527e4e819b6c228187c5702d990a180043
external/Scripting Engine/packages/IronPython.StdLib.2.7.4/content/Lib/mhlib.py
python
Folder.removefromallsequences
(self, list)
Remove one or more messages from all sequences (including last) -- but not from 'cur'!!!
Remove one or more messages from all sequences (including last) -- but not from 'cur'!!!
[ "Remove", "one", "or", "more", "messages", "from", "all", "sequences", "(", "including", "last", ")", "--", "but", "not", "from", "cur", "!!!" ]
def removefromallsequences(self, list): """Remove one or more messages from all sequences (including last) -- but not from 'cur'!!!""" if hasattr(self, 'last') and self.last in list: del self.last sequences = self.getsequences() changed = 0 for name, seq in sequences.items(): if name == 'cur': continue for n in list: if n in seq: seq.remove(n) changed = 1 if not seq: del sequences[name] if changed: self.putsequences(sequences)
[ "def", "removefromallsequences", "(", "self", ",", "list", ")", ":", "if", "hasattr", "(", "self", ",", "'last'", ")", "and", "self", ".", "last", "in", "list", ":", "del", "self", ".", "last", "sequences", "=", "self", ".", "getsequences", "(", ")", ...
https://github.com/ajinabraham/OWASP-Xenotix-XSS-Exploit-Framework/blob/cb692f527e4e819b6c228187c5702d990a180043/external/Scripting Engine/packages/IronPython.StdLib.2.7.4/content/Lib/mhlib.py#L630-L647
XX-net/XX-Net
a9898cfcf0084195fb7e69b6bc834e59aecdf14f
python3.8.2/Lib/_pyio.py
python
IOBase.writelines
(self, lines)
Write a list of lines to the stream. Line separators are not added, so it is usual for each of the lines provided to have a line separator at the end.
Write a list of lines to the stream.
[ "Write", "a", "list", "of", "lines", "to", "the", "stream", "." ]
def writelines(self, lines): """Write a list of lines to the stream. Line separators are not added, so it is usual for each of the lines provided to have a line separator at the end. """ self._checkClosed() for line in lines: self.write(line)
[ "def", "writelines", "(", "self", ",", "lines", ")", ":", "self", ".", "_checkClosed", "(", ")", "for", "line", "in", "lines", ":", "self", ".", "write", "(", "line", ")" ]
https://github.com/XX-net/XX-Net/blob/a9898cfcf0084195fb7e69b6bc834e59aecdf14f/python3.8.2/Lib/_pyio.py#L593-L601
selinon/selinon
3613153566d454022a138639f0375c63f490c4cb
selinon/selective_run_function.py
python
SelectiveRunFunction.from_dict
(cls, dict_)
return cls(name, import_path)
Instantiate selective run function based on definition in a dictionary. :return: selective run function that will be used based on configuration :rtype: SelectiveRunFunction
Instantiate selective run function based on definition in a dictionary.
[ "Instantiate", "selective", "run", "function", "based", "on", "definition", "in", "a", "dictionary", "." ]
def from_dict(cls, dict_): """Instantiate selective run function based on definition in a dictionary. :return: selective run function that will be used based on configuration :rtype: SelectiveRunFunction """ if not dict_: return cls.get_default() unknown_conf = check_conf_keys(dict_, known_conf_opts=('name', 'import')) if unknown_conf: raise ConfigurationError("Unknown configuration options for selective run function supplied: %s" % (unknown_conf.keys())) name = dict_.pop('name', cls._DEFAULT_FUNCTION_NAME) import_path = dict_.pop('import', cls._DEFAULT_IMPORT_PATH) return cls(name, import_path)
[ "def", "from_dict", "(", "cls", ",", "dict_", ")", ":", "if", "not", "dict_", ":", "return", "cls", ".", "get_default", "(", ")", "unknown_conf", "=", "check_conf_keys", "(", "dict_", ",", "known_conf_opts", "=", "(", "'name'", ",", "'import'", ")", ")",...
https://github.com/selinon/selinon/blob/3613153566d454022a138639f0375c63f490c4cb/selinon/selective_run_function.py#L54-L71
lifting-bits/mcsema
b7492e2ffb9f2fa64b5ef269753ba1d134bdf2f2
tools/mcsema_disass/ida7/util.py
python
get_destructor_segment
()
Returns the start address of the global destructor section
Returns the start address of the global destructor section
[ "Returns", "the", "start", "address", "of", "the", "global", "destructor", "section" ]
def get_destructor_segment(): """Returns the start address of the global destructor section""" for seg_ea in idautils.Segments(): seg_name = idc.get_segm_name(seg_ea).lower() if seg_name in [".fini_array", ".dtor"]: return seg_ea;
[ "def", "get_destructor_segment", "(", ")", ":", "for", "seg_ea", "in", "idautils", ".", "Segments", "(", ")", ":", "seg_name", "=", "idc", ".", "get_segm_name", "(", "seg_ea", ")", ".", "lower", "(", ")", "if", "seg_name", "in", "[", "\".fini_array\"", "...
https://github.com/lifting-bits/mcsema/blob/b7492e2ffb9f2fa64b5ef269753ba1d134bdf2f2/tools/mcsema_disass/ida7/util.py#L404-L409
armancohan/long-summarization
1328d4f37b3a3a460f455e93e84ed4ddcd10dab1
model.py
python
SummarizationModel._add_seq2seq
(self)
Add the whole sequence-to-sequence model to the graph.
Add the whole sequence-to-sequence model to the graph.
[ "Add", "the", "whole", "sequence", "-", "to", "-", "sequence", "model", "to", "the", "graph", "." ]
def _add_seq2seq(self): """Add the whole sequence-to-sequence model to the graph.""" hps = self._hps vsize = self._vocab.size() # size of the vocabulary with tf.variable_scope('seq2seq'): # Some initializers self.rand_unif_init = tf.random_uniform_initializer(-hps.rand_unif_init_mag, hps.rand_unif_init_mag, seed=123) self.trunc_norm_init = tf.truncated_normal_initializer(stddev=hps.trunc_norm_init_std) with tf.variable_scope('embedding'): if hps.pretrained_embeddings: word2vec = load_embeddings(hps.embeddings_path, self._vocab.word2id, hps.rand_unif_init_mag) self.embedding = tf.get_variable('embedding', [vsize, hps.emb_dim], dtype=tf.float32, initializer=tf.constant_initializer(word2vec)) # self.assign_embedding = tf.assign(self.embedding, word2vec) else: self.embedding = tf.get_variable('embedding', [vsize, hps.emb_dim], dtype=tf.float32, initializer=self.trunc_norm_init) if hps.mode=="train": self._add_emb_vis(self.embedding) # add to tensorboard # tensor with shape (batch_size, max_enc_steps, emb_size) emb_enc_inputs = tf.nn.embedding_lookup(self.embedding, self._enc_batch) if self._hps.hier: enc_batch_sections = tf.unstack(self._enc_batch_sections, axis=1) sec_emb_enc_inputs = [tf.nn.embedding_lookup(self.embedding, section) for section in enc_batch_sections] # list length max_dec_steps containing shape (batch_size, emb_size) emb_dec_inputs = [tf.nn.embedding_lookup(self.embedding, x) for x in tf.unstack(self._dec_batch, axis=1)] # Hierarchical attention model if self._hps.hier: with tf.variable_scope('encoder'), tf.device(self._next_device()): sec_enc_outs = [] states_fw = [] states_bw = [] states = [] # level 1, encode words to sections with tf.variable_scope("word_level_encoder", reuse=tf.AUTO_REUSE) as scope: encoder_outputs_words = [] cell_fw = tf.contrib.rnn.LSTMCell(self._hps.hidden_dim, initializer=self.rand_unif_init, state_is_tuple=True) cell_bw = tf.contrib.rnn.LSTMCell(self._hps.hidden_dim, initializer=self.rand_unif_init, state_is_tuple=True) fw_st, bw_st = None, None if self._hps.use_do: # DropOut cell_fw = tf.contrib.rnn.DropoutWrapper(cell_fw, output_keep_prob=1.0 - self._hps.do_prob) cell_bw = tf.contrib.rnn.DropoutWrapper(cell_bw, output_keep_prob=1.0 - self._hps.do_prob) for i in range(self._hps.num_sections): encoder_tmp_output, (fw_st, bw_st) = tf.nn.bidirectional_dynamic_rnn( cell_fw, cell_bw, inputs=sec_emb_enc_inputs[i], dtype=tf.float32, sequence_length=self._batch_sections_len[:,i], swap_memory=True, initial_state_bw=bw_st, initial_state_fw=fw_st) # concatenate the forwards and backwards states encoder_tmp_output = tf.concat(axis=2, values=encoder_tmp_output) #shape=[batch x seq_len x hidden_size] encoder_outputs_words.append(encoder_tmp_output) # instead of concating the fw and bw states, we use a ff network combined_state = self._reduce_states(fw_st, bw_st) states.append(combined_state) scope.reuse_variables() # level 2, encode sections to doc encoder_outputs_words = tf.stack(encoder_outputs_words, axis=1) # shape [batch x num_sections x seq_len x hidden_size] shapes = encoder_outputs_words.shape encoder_outputs_words = tf.reshape(encoder_outputs_words, (shapes[0].value, -1, shapes[-1].value)) #shape=[batch x (seq_len * num_sections) x hidden_size] doc_sections_h = tf.stack([s.h for s in states], axis=1) # [batch x num_sections x hidden_size] doc_sections_c = tf.stack([s.c for s in states], axis=1) # [batch x num_sections x hidden_size] with tf.variable_scope("section_level_encoder"): if FLAGS.section_level_encoder == 'RNN': cell_fw_1 = tf.contrib.rnn.LSTMCell(self._hps.hidden_dim, initializer=self.rand_unif_init, state_is_tuple=True) cell_bw_1 = tf.contrib.rnn.LSTMCell(self._hps.hidden_dim, initializer=self.rand_unif_init, state_is_tuple=True) if self._hps.use_do: cell_fw_1 = tf.contrib.rnn.DropoutWrapper(cell_fw_1, output_keep_prob=1.0 - self._hps.do_prob) cell_bw_1 = tf.contrib.rnn.DropoutWrapper(cell_bw_1, output_keep_prob=1.0 - self._hps.do_prob) encoder_output_sections, (fw_st_2, bw_st_2) =\ tf.nn.bidirectional_dynamic_rnn(cell_fw_1, cell_bw_1, inputs=doc_sections_h, sequence_length=self._doc_sec_lens, dtype=tf.float32, swap_memory=True) encoder_output_sections = tf.concat(axis=2, values=encoder_output_sections) doc_sections_state = self._reduce_states(fw_st_2, bw_st_2) else: if FLAGS.section_level_encoder == 'AVG': # average section cells doc_sections_state_h = tf.reduce_mean(doc_sections_h, axis=1) doc_sections_state_c = tf.reduce_mean(doc_sections_c, axis=1) elif FLAGS.section_level_encoder == 'FF': # use a feedforward network to combine section cells doc_sections_state_h = tf.reshape([doc_sections_h.shape[0].eval(), -1]) doc_sections_state_h = tf.layers.dense( inputs=doc_sections_state_h, units=self._hps.hidden, activation=tf.nn.relu) doc_sections_state_c = tf.reshape([doc_sections_c.shape[0].eval(), -1]) doc_sections_state_c = tf.layers.dense( inputs=doc_sections_state_c, units=self._hps.hidden, activation=tf.nn.relu) else: raise AttributeError('FLAGS.section_level_encoder={} is not a valid option'.format(FLAGS.section_level_encoder)) doc_sections_state = tf.contrib.rnn.LSTMStateTuple(doc_sections_state_c, doc_sections_state_h) encoder_output_sections = doc_sections_h elif not self._hps.multi_layer_encoder: with tf.variable_scope('encoder'): with tf.variable_scope('word_level_encoder'): cell_fw = tf.contrib.rnn.LSTMCell(self._hps.hidden_dim, initializer=self.rand_unif_init, state_is_tuple=True) cell_bw = tf.contrib.rnn.LSTMCell(self._hps.hidden_dim, initializer=self.rand_unif_init, state_is_tuple=True) (encoder_outputs, (fw_st, bw_st)) =\ tf.nn.bidirectional_dynamic_rnn(cell_fw, cell_bw, inputs=emb_enc_inputs, dtype=tf.float32, sequence_length=self._enc_lens, swap_memory=True) # concatenate the forwards and backwards states encoder_outputs = tf.concat(axis=2, values=encoder_outputs) # stack n layers of lstms for encoder elif self._hps.multi_layer_encoder: # TODO: check for layer_i in xrange(self._hps.enc_layers): with tf.variable_scope('encoder%d'%layer_i), tf.device( self._next_device()): cell_fw = tf.contrib.rnn.LSTMCell(self._hps.hidden_dim, initializer=self.rand_unif_init, state_is_tuple=True) cell_bw = tf.contrib.rnn.LSTMCell(self._hps.hidden_dim, initializer=self.rand_unif_init, state_is_tuple=True) if self._hps.use_do: # add dropout cell_fw = tf.contrib.rnn.DropoutWrapper(cell_fw, output_keep_prob=1.0 - self._hps.do_prob) cell_bw = tf.contrib.rnn.DropoutWrapper(cell_bw, output_keep_prob=1.0 - self._hps.do_prob) emb_enc_inputs, (fw_st, bw_st) =\ tf.nn.bidirectional_dynamic_rnn(cell_fw, cell_bw, inputs=emb_enc_inputs, dtype=tf.float32, sequence_length=self._enc_lens, swap_memory=True) emb_enc_inputs = tf.concat(axis=2, values=emb_enc_inputs) encoder_outputs = emb_enc_inputs if self._hps.hier: self._enc_sec_states = encoder_output_sections self._enc_states = encoder_outputs_words else: self._enc_states = encoder_outputs self._enc_sec_states = None # convert the encoder bidirectional hidden state to the decoder state # (unidirectional) by an MLP if self._hps.hier: self._dec_in_state = doc_sections_state else: with tf.variable_scope('encoder'): with tf.variable_scope('word_level_encoder'): self._dec_in_state = self._reduce_states(fw_st, bw_st) # Add the decoder with tf.variable_scope('decoder'), tf.device(self._next_device()): cell = tf.contrib.rnn.LSTMCell( self._hps.hidden_dim, state_is_tuple=True, initializer=self.rand_unif_init) # We need to pass in the previous step's coverage vector each time prev_coverage = self.prev_coverage\ if hps.mode=="decode" and self._hps.coverage \ else None if self._hps.hier: decoder_outputs, self._dec_out_state, self.attn_dists, self.p_gens, self.coverage, self.attn_dists_sec =\ self.attn_decoder(emb_dec_inputs, self._dec_in_state, self._enc_states, cell, self._enc_sec_states, num_words_section=self._batch_sections_len, enc_padding_mask=self._enc_padding_mask, enc_section_padding_mask=self._enc_section_padding_mask, initial_state_attention=(self._hps.mode=="decode"), pointer_gen=self._hps.pointer_gen, use_coverage=self._hps.coverage, prev_coverage=prev_coverage, temperature=self._hps.temperature ) else: decoder_outputs, self._dec_out_state, self.attn_dists, self.p_gens, self.coverage, _ =\ self.attn_decoder(emb_dec_inputs, self._dec_in_state, self._enc_states, cell, encoder_section_states=None, num_words_section=None, enc_padding_mask=self._enc_padding_mask, initial_state_attention=(self._hps.mode=="decode"), pointer_gen=self._hps.pointer_gen, use_coverage=self._hps.coverage, prev_coverage=prev_coverage, ) # Project decoder output to vocabulary with tf.variable_scope('output_projection'), tf.device(self._next_device()): if self._hps.output_weight_sharing: # share weights of embedding layer with projection # self.embedding is in shape [vsize, hps.emb_dim] w_proj = tf.get_variable('w_proj', [self._hps.emb_dim, self._hps.hidden_dim], dtype=tf.float32, initializer=self.trunc_norm_init) w = tf.tanh(tf.transpose(tf.matmul(self.embedding, w_proj))) # shape = [vsize, hps.hidden_dim] # w_t = tf.transpose(w) b = tf.get_variable('b', [vsize], dtype=tf.float32, initializer=self.trunc_norm_init) else: w = tf.get_variable('w', [self._hps.hidden_dim, vsize], dtype=tf.float32, initializer=self.trunc_norm_init) # w_t = tf.transpose(w) b = tf.get_variable('b', [vsize], dtype=tf.float32, initializer=self.trunc_norm_init) # vocabulary score at each decoder step vocab_scores = [] for i,output in enumerate(decoder_outputs): if i > 0: tf.get_variable_scope().reuse_variables() vocab_scores.append(tf.nn.xw_plus_b(output, w, b)) # apply the linear layer # the final vocab distribution for each decoder time step # shape of each element is [batch_size, vsize] vocab_dists = [tf.nn.softmax(s) for s in vocab_scores] # pointing / generating if FLAGS.pointer_gen: final_dists = self._calc_final_dist(vocab_dists, self.attn_dists) # log_dists = [tf.log(dist) for dist in final_dists] else: # log_dists = [tf.log(dist) for dist in vocab_dists] final_dists = vocab_dists # Calculate Losses: if self._hps.mode in ['train', 'eval']: # Calculate the loss with tf.variable_scope('loss'), tf.device(self._next_device()): if FLAGS.pointer_gen: # Calculate the loss per step # This is fiddly; we use tf.gather_nd to pick out the gold target words # will be list length max_dec_steps containing shape (batch_size) loss_per_step = [] batch_nums = tf.range(0, limit=hps.batch_size) # shape (batch_size) for dec_step, dist in enumerate(final_dists): # The indices of the target words. shape (batch_size) targets = self._target_batch[:,dec_step] indices = tf.stack( (batch_nums, targets), axis=1) # shape (batch_size, 2) # shape (batch_size). loss on this step for each batch gold_probs = tf.gather_nd(dist, indices) losses = -tf.log(gold_probs) loss_per_step.append(losses) # Apply dec_padding_mask mask and get loss self._loss = _mask_and_avg(loss_per_step, self._dec_padding_mask) else: # baseline model # this applies softmax internally self._loss = tf.contrib.seq2seq.sequence_loss( tf.stack(vocab_scores, axis=1), self._target_batch, self._dec_padding_mask) # this applies softmax internally tf.summary.scalar('loss', self._loss) # Calculate coverage loss from the attention distributions if self._hps.coverage: with tf.variable_scope('coverage_loss'): self._coverage_loss = _coverage_loss(self.attn_dists, self._dec_padding_mask) tf.summary.scalar('coverage_loss', self._coverage_loss) self._total_loss = self._loss + self._hps.cov_loss_wt * self._coverage_loss tf.summary.scalar('total_loss', self._total_loss) # ---------------------------/ if self._hps.mode == "decode": assert len(final_dists) == 1 # final_dists is a singleton list containing shape (batch_size, extended_vsize) final_dists = final_dists[0] topk_probs, self._topk_ids = tf.nn.top_k(final_dists, hps.batch_size*2) # take the k largest probs. note batch_size=beam_size in decode mode self._topk_log_probs = tf.log(topk_probs)
[ "def", "_add_seq2seq", "(", "self", ")", ":", "hps", "=", "self", ".", "_hps", "vsize", "=", "self", ".", "_vocab", ".", "size", "(", ")", "# size of the vocabulary", "with", "tf", ".", "variable_scope", "(", "'seq2seq'", ")", ":", "# Some initializers", "...
https://github.com/armancohan/long-summarization/blob/1328d4f37b3a3a460f455e93e84ed4ddcd10dab1/model.py#L243-L519
sahana/eden
1696fa50e90ce967df69f66b571af45356cc18da
static/scripts/tools/pep8.py
python
Checker.check_logical
(self)
Build a line from tokens and run all logical checks on it.
Build a line from tokens and run all logical checks on it.
[ "Build", "a", "line", "from", "tokens", "and", "run", "all", "logical", "checks", "on", "it", "." ]
def check_logical(self): """ Build a line from tokens and run all logical checks on it. """ options.counters['logical lines'] = \ options.counters.get('logical lines', 0) + 1 self.build_tokens_line() first_line = self.lines[self.mapping[0][1][2][0] - 1] indent = first_line[:self.mapping[0][1][2][1]] self.previous_indent_level = self.indent_level self.indent_level = expand_indent(indent) if options.verbose >= 2: print self.logical_line[:80].rstrip() for name, check, argument_names in self.logical_checks: if options.verbose >= 3: print ' ', name result = self.run_check(check, argument_names) if result is not None: offset, text = result if type(offset) is tuple: original_number, original_offset = offset else: for token_offset, token in self.mapping: if offset >= token_offset: original_number = token[2][0] original_offset = (token[2][1] + offset - token_offset) self.report_error(original_number, original_offset, text, check) self.previous_logical = self.logical_line
[ "def", "check_logical", "(", "self", ")", ":", "options", ".", "counters", "[", "'logical lines'", "]", "=", "options", ".", "counters", ".", "get", "(", "'logical lines'", ",", "0", ")", "+", "1", "self", ".", "build_tokens_line", "(", ")", "first_line", ...
https://github.com/sahana/eden/blob/1696fa50e90ce967df69f66b571af45356cc18da/static/scripts/tools/pep8.py#L577-L606
ihaveamac/ninfs
dee583ba3205c4e050e0b193a85a4177eb334159
ninfs/mount/ncch.py
python
NCCHContainerMount.init
(self, path, _setup_romfs=True)
[]
def init(self, path, _setup_romfs=True): decrypted_filename = '/decrypted.' + ('cxi' if self.reader.flags.executable else 'cfa') self.files[decrypted_filename] = NCCHSection.FullDecrypted self.files['/ncch.bin'] = NCCHSection.Header if NCCHSection.ExtendedHeader in self.reader.sections: self.files['/extheader.bin'] = NCCHSection.ExtendedHeader if NCCHSection.Logo in self.reader.sections: self.files['/logo.bin'] = NCCHSection.Logo if NCCHSection.Plain in self.reader.sections: self.files['/plain.bin'] = NCCHSection.Plain if NCCHSection.ExeFS in self.reader.sections: self.files['/exefs.bin'] = NCCHSection.ExeFS self.exefs_fuse = ExeFSMount(self.reader.exefs, g_stat=self.g_stat, decompress_code=True) self.exefs_fuse.init(path) if NCCHSection.RomFS in self.reader.sections: self.files['/romfs.bin'] = NCCHSection.RomFS self.romfs_fuse = RomFSMount(self.reader.romfs, g_stat=self.g_stat)
[ "def", "init", "(", "self", ",", "path", ",", "_setup_romfs", "=", "True", ")", ":", "decrypted_filename", "=", "'/decrypted.'", "+", "(", "'cxi'", "if", "self", ".", "reader", ".", "flags", ".", "executable", "else", "'cfa'", ")", "self", ".", "files", ...
https://github.com/ihaveamac/ninfs/blob/dee583ba3205c4e050e0b193a85a4177eb334159/ninfs/mount/ncch.py#L52-L74
securesystemslab/zippy
ff0e84ac99442c2c55fe1d285332cfd4e185e089
zippy/lib-python/3/fileinput.py
python
isfirstline
()
return _state.isfirstline()
Returns true the line just read is the first line of its file, otherwise returns false.
Returns true the line just read is the first line of its file, otherwise returns false.
[ "Returns", "true", "the", "line", "just", "read", "is", "the", "first", "line", "of", "its", "file", "otherwise", "returns", "false", "." ]
def isfirstline(): """ Returns true the line just read is the first line of its file, otherwise returns false. """ if not _state: raise RuntimeError("no active input()") return _state.isfirstline()
[ "def", "isfirstline", "(", ")", ":", "if", "not", "_state", ":", "raise", "RuntimeError", "(", "\"no active input()\"", ")", "return", "_state", ".", "isfirstline", "(", ")" ]
https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/lib-python/3/fileinput.py#L167-L174
svip-lab/impersonator
b041dd415157c1e7f5b46e579a1ad4dffabb2e66
thirdparty/his_evaluators/his_evaluators/evaluators/motion_imitation.py
python
MotionImitationRunnerProcessor.post_format_metric_file_list
(self, si_preds_files, si_ref_files, ci_preds_files, ci_ref_files)
return si_preds_ref_files, ci_preds_ref_files
make [(si_pred, si_ref), ...], and [(ci_pred, ci_ref), ...] Args: si_preds_files: si_ref_files: ci_preds_files: ci_ref_files: Returns: si_preds_ref_files: ci_preds_ref_files:
make [(si_pred, si_ref), ...], and [(ci_pred, ci_ref), ...] Args: si_preds_files: si_ref_files: ci_preds_files: ci_ref_files:
[ "make", "[", "(", "si_pred", "si_ref", ")", "...", "]", "and", "[", "(", "ci_pred", "ci_ref", ")", "...", "]", "Args", ":", "si_preds_files", ":", "si_ref_files", ":", "ci_preds_files", ":", "ci_ref_files", ":" ]
def post_format_metric_file_list(self, si_preds_files, si_ref_files, ci_preds_files, ci_ref_files): """ make [(si_pred, si_ref), ...], and [(ci_pred, ci_ref), ...] Args: si_preds_files: si_ref_files: ci_preds_files: ci_ref_files: Returns: si_preds_ref_files: ci_preds_ref_files: """ si_preds_ref_files = list(zip(si_preds_files, si_ref_files)) ci_preds_ref_files = list(zip(ci_preds_files, ci_ref_files)) return si_preds_ref_files, ci_preds_ref_files
[ "def", "post_format_metric_file_list", "(", "self", ",", "si_preds_files", ",", "si_ref_files", ",", "ci_preds_files", ",", "ci_ref_files", ")", ":", "si_preds_ref_files", "=", "list", "(", "zip", "(", "si_preds_files", ",", "si_ref_files", ")", ")", "ci_preds_ref_f...
https://github.com/svip-lab/impersonator/blob/b041dd415157c1e7f5b46e579a1ad4dffabb2e66/thirdparty/his_evaluators/his_evaluators/evaluators/motion_imitation.py#L143-L159
openai/multiagent-competition
b2e081a192429913b7d21a89525901d59c85e7f3
gym-compete/gym_compete/new_envs/agents/agent.py
python
Agent.set_env
(self, env)
[]
def set_env(self, env): self.env = env self._env_init = True self._set_body() self._set_joint() if self.n_agents > 1: self._set_other_joint() self.set_observation_space() self.set_action_space()
[ "def", "set_env", "(", "self", ",", "env", ")", ":", "self", ".", "env", "=", "env", "self", ".", "_env_init", "=", "True", "self", ".", "_set_body", "(", ")", "self", ".", "_set_joint", "(", ")", "if", "self", ".", "n_agents", ">", "1", ":", "se...
https://github.com/openai/multiagent-competition/blob/b2e081a192429913b7d21a89525901d59c85e7f3/gym-compete/gym_compete/new_envs/agents/agent.py#L33-L41
BEEmod/BEE2.4
02767f3cf476581789425ab308ca1bea978f6a74
src/app/sound.py
python
PygletSound.fx
(self, sound: str)
Play a sound effect.
Play a sound effect.
[ "Play", "a", "sound", "effect", "." ]
async def fx(self, sound: str) -> None: """Play a sound effect.""" global sounds if play_sound: try: snd = self.sources[sound] except KeyError: # We were called before the BG thread loaded em, load it now. LOGGER.warning('Sound "{}" couldn\'t be loaded in time!', sound) snd = await self.load(sound) try: if snd is not None: snd.play() except Exception: LOGGER.exception("Couldn't play sound {}:", sound) LOGGER.info('UI sounds disabled.') _nursery.cancel_scope.cancel() sounds = NullSound()
[ "async", "def", "fx", "(", "self", ",", "sound", ":", "str", ")", "->", "None", ":", "global", "sounds", "if", "play_sound", ":", "try", ":", "snd", "=", "self", ".", "sources", "[", "sound", "]", "except", "KeyError", ":", "# We were called before the B...
https://github.com/BEEmod/BEE2.4/blob/02767f3cf476581789425ab308ca1bea978f6a74/src/app/sound.py#L127-L144
zhl2008/awd-platform
0416b31abea29743387b10b3914581fbe8e7da5e
web_hxb2/lib/python3.5/site-packages/django/http/multipartparser.py
python
ChunkIter.__next__
(self)
[]
def __next__(self): try: data = self.flo.read(self.chunk_size) except InputStreamExhausted: raise StopIteration() if data: return data else: raise StopIteration()
[ "def", "__next__", "(", "self", ")", ":", "try", ":", "data", "=", "self", ".", "flo", ".", "read", "(", "self", ".", "chunk_size", ")", "except", "InputStreamExhausted", ":", "raise", "StopIteration", "(", ")", "if", "data", ":", "return", "data", "el...
https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_hxb2/lib/python3.5/site-packages/django/http/multipartparser.py#L447-L455
monero-ecosystem/monero-python
9c3c841624f635a4fd154f1f278206af8a6d2c1d
monero/wallet.py
python
Wallet.address
(self)
return self.accounts[0].address()
Returns wallet's master address. :rtype: :class:`Address <monero.address.Address>`
Returns wallet's master address.
[ "Returns", "wallet", "s", "master", "address", "." ]
def address(self): """ Returns wallet's master address. :rtype: :class:`Address <monero.address.Address>` """ return self.accounts[0].address()
[ "def", "address", "(", "self", ")", ":", "return", "self", ".", "accounts", "[", "0", "]", ".", "address", "(", ")" ]
https://github.com/monero-ecosystem/monero-python/blob/9c3c841624f635a4fd154f1f278206af8a6d2c1d/monero/wallet.py#L180-L186
Buroni/booksoup
da4470654a820e6450fdb6759d6d625c5fd3b5eb
booksoup/BookSoup.py
python
BookSoup.load_conversation
(self, search_name, interval="month")
return None
[]
def load_conversation(self, search_name, interval="month"): # If search_name is an integer, simply get the HTML file whose name is that integer. if isinstance(search_name, int): contact = Conversation(os.path.join(self.__path, "messages", str(search_name)+".html"), interval=interval) self.conversations[contact.name] = contact return contact # If the search name is a string, get the list of links leading to conversations, # find the relative link and load the conversation using the link path. with open(os.path.join(self.__path,"html", "messages.htm"), "r") as infile: soup = BeautifulSoup(infile.read(), "html.parser") convo_links = soup.find_all("a", {"href": re.compile('.*messages.*')}) for link in convo_links: if link.text != search_name: continue contact = Conversation(os.path.join(self.__path, link["href"])) self.conversations[contact.name] = contact return contact return None
[ "def", "load_conversation", "(", "self", ",", "search_name", ",", "interval", "=", "\"month\"", ")", ":", "# If search_name is an integer, simply get the HTML file whose name is that integer.", "if", "isinstance", "(", "search_name", ",", "int", ")", ":", "contact", "=", ...
https://github.com/Buroni/booksoup/blob/da4470654a820e6450fdb6759d6d625c5fd3b5eb/booksoup/BookSoup.py#L33-L51
returntocorp/bento
05b365da71b65170d41fe92a702480ab76c1d17c
bento/git.py
python
user_email
(path: Optional[Path] = None)
[]
def user_email(path: Optional[Path] = None) -> Optional[str]: r = repo(path) if r is None: return None try: return r.config_reader().get_value("user", "email").strip("\"'") except configparser.NoSectionError: return None except configparser.NoOptionError: return None
[ "def", "user_email", "(", "path", ":", "Optional", "[", "Path", "]", "=", "None", ")", "->", "Optional", "[", "str", "]", ":", "r", "=", "repo", "(", "path", ")", "if", "r", "is", "None", ":", "return", "None", "try", ":", "return", "r", ".", "...
https://github.com/returntocorp/bento/blob/05b365da71b65170d41fe92a702480ab76c1d17c/bento/git.py#L25-L34
nosmokingbandit/watcher
dadacd21a5790ee609058a98a17fcc8954d24439
lib/sqlalchemy/sql/selectable.py
python
Select.self_group
(self, against=None)
return FromGrouping(self)
return a 'grouping' construct as per the ClauseElement specification. This produces an element that can be embedded in an expression. Note that this method is called automatically as needed when constructing expressions and should not require explicit use.
return a 'grouping' construct as per the ClauseElement specification.
[ "return", "a", "grouping", "construct", "as", "per", "the", "ClauseElement", "specification", "." ]
def self_group(self, against=None): """return a 'grouping' construct as per the ClauseElement specification. This produces an element that can be embedded in an expression. Note that this method is called automatically as needed when constructing expressions and should not require explicit use. """ if isinstance(against, CompoundSelect) and \ not self._needs_parens_for_grouping(): return self return FromGrouping(self)
[ "def", "self_group", "(", "self", ",", "against", "=", "None", ")", ":", "if", "isinstance", "(", "against", ",", "CompoundSelect", ")", "and", "not", "self", ".", "_needs_parens_for_grouping", "(", ")", ":", "return", "self", "return", "FromGrouping", "(", ...
https://github.com/nosmokingbandit/watcher/blob/dadacd21a5790ee609058a98a17fcc8954d24439/lib/sqlalchemy/sql/selectable.py#L3485-L3497
omz/PythonistaAppTemplate
f560f93f8876d82a21d108977f90583df08d55af
PythonistaAppTemplate/PythonistaKit.framework/pylib_ext/matplotlib/colors.py
python
LinearSegmentedColormap.__init__
(self, name, segmentdata, N=256, gamma=1.0)
Create color map from linear mapping segments segmentdata argument is a dictionary with a red, green and blue entries. Each entry should be a list of *x*, *y0*, *y1* tuples, forming rows in a table. Entries for alpha are optional. Example: suppose you want red to increase from 0 to 1 over the bottom half, green to do the same over the middle half, and blue over the top half. Then you would use:: cdict = {'red': [(0.0, 0.0, 0.0), (0.5, 1.0, 1.0), (1.0, 1.0, 1.0)], 'green': [(0.0, 0.0, 0.0), (0.25, 0.0, 0.0), (0.75, 1.0, 1.0), (1.0, 1.0, 1.0)], 'blue': [(0.0, 0.0, 0.0), (0.5, 0.0, 0.0), (1.0, 1.0, 1.0)]} Each row in the table for a given color is a sequence of *x*, *y0*, *y1* tuples. In each sequence, *x* must increase monotonically from 0 to 1. For any input value *z* falling between *x[i]* and *x[i+1]*, the output value of a given color will be linearly interpolated between *y1[i]* and *y0[i+1]*:: row i: x y0 y1 / / row i+1: x y0 y1 Hence y0 in the first row and y1 in the last row are never used. .. seealso:: :meth:`LinearSegmentedColormap.from_list` Static method; factory function for generating a smoothly-varying LinearSegmentedColormap. :func:`makeMappingArray` For information about making a mapping array.
Create color map from linear mapping segments
[ "Create", "color", "map", "from", "linear", "mapping", "segments" ]
def __init__(self, name, segmentdata, N=256, gamma=1.0): """Create color map from linear mapping segments segmentdata argument is a dictionary with a red, green and blue entries. Each entry should be a list of *x*, *y0*, *y1* tuples, forming rows in a table. Entries for alpha are optional. Example: suppose you want red to increase from 0 to 1 over the bottom half, green to do the same over the middle half, and blue over the top half. Then you would use:: cdict = {'red': [(0.0, 0.0, 0.0), (0.5, 1.0, 1.0), (1.0, 1.0, 1.0)], 'green': [(0.0, 0.0, 0.0), (0.25, 0.0, 0.0), (0.75, 1.0, 1.0), (1.0, 1.0, 1.0)], 'blue': [(0.0, 0.0, 0.0), (0.5, 0.0, 0.0), (1.0, 1.0, 1.0)]} Each row in the table for a given color is a sequence of *x*, *y0*, *y1* tuples. In each sequence, *x* must increase monotonically from 0 to 1. For any input value *z* falling between *x[i]* and *x[i+1]*, the output value of a given color will be linearly interpolated between *y1[i]* and *y0[i+1]*:: row i: x y0 y1 / / row i+1: x y0 y1 Hence y0 in the first row and y1 in the last row are never used. .. seealso:: :meth:`LinearSegmentedColormap.from_list` Static method; factory function for generating a smoothly-varying LinearSegmentedColormap. :func:`makeMappingArray` For information about making a mapping array. """ # True only if all colors in map are identical; needed for contouring. self.monochrome = False Colormap.__init__(self, name, N) self._segmentdata = segmentdata self._gamma = gamma
[ "def", "__init__", "(", "self", ",", "name", ",", "segmentdata", ",", "N", "=", "256", ",", "gamma", "=", "1.0", ")", ":", "# True only if all colors in map are identical; needed for contouring.", "self", ".", "monochrome", "=", "False", "Colormap", ".", "__init__...
https://github.com/omz/PythonistaAppTemplate/blob/f560f93f8876d82a21d108977f90583df08d55af/PythonistaAppTemplate/PythonistaKit.framework/pylib_ext/matplotlib/colors.py#L669-L720
vicariousinc/science_rcn
821d8ce4c7d3a7bf0827fc00a5a405a9f87cc67e
science_rcn/preproc.py
python
get_gabor_filters
(size=21, filter_scale=4., num_orients=16, weights=False)
return filts
Get Gabor filter bank. See Preproc for parameters and returns.
Get Gabor filter bank. See Preproc for parameters and returns.
[ "Get", "Gabor", "filter", "bank", ".", "See", "Preproc", "for", "parameters", "and", "returns", "." ]
def get_gabor_filters(size=21, filter_scale=4., num_orients=16, weights=False): """Get Gabor filter bank. See Preproc for parameters and returns.""" def _get_sparse_gaussian(): """Sparse Gaussian.""" size = 2 * np.ceil(np.sqrt(2.) * filter_scale) + 1 alt = np.zeros((int(size), int(size)), np.float32) alt[int(size // 2), int(size // 2)] = 1 gaussian = gaussian_filter(alt, filter_scale / np.sqrt(2.), mode='constant') gaussian[gaussian < 0.05 * gaussian.max()] = 0 return gaussian gaussian = _get_sparse_gaussian() filts = [] for angle in np.linspace(0., 2 * np.pi, num_orients, endpoint=False): acts = np.zeros((size, size), np.float32) x, y = np.cos(angle) * filter_scale, np.sin(angle) * filter_scale acts[int(size / 2 + y), int(size / 2 + x)] = 1. acts[int(size / 2 - y), int(size / 2 - x)] = -1. filt = fftconvolve(acts, gaussian, mode='same') filt /= np.abs(filt).sum() # Normalize to ensure the maximum output is 1 if weights: filt = np.abs(filt) filts.append(filt) return filts
[ "def", "get_gabor_filters", "(", "size", "=", "21", ",", "filter_scale", "=", "4.", ",", "num_orients", "=", "16", ",", "weights", "=", "False", ")", ":", "def", "_get_sparse_gaussian", "(", ")", ":", "\"\"\"Sparse Gaussian.\"\"\"", "size", "=", "2", "*", ...
https://github.com/vicariousinc/science_rcn/blob/821d8ce4c7d3a7bf0827fc00a5a405a9f87cc67e/science_rcn/preproc.py#L97-L120
gwpy/gwpy
82becd78d166a32985cb657a54d0d39f6a207739
gwpy/io/datafind.py
python
_error_missing_channels
(required, found, gpstime, allow_tape)
Raise an exception if required channels are not found
Raise an exception if required channels are not found
[ "Raise", "an", "exception", "if", "required", "channels", "are", "not", "found" ]
def _error_missing_channels(required, found, gpstime, allow_tape): """Raise an exception if required channels are not found """ missing = set(required) - set(found) if not missing: # success return # failure msg = "Cannot locate the following channel(s) in any known frametype" if gpstime: msg += f" at GPS={gpstime}" msg += ":\n " + "\n ".join(missing) if not allow_tape: msg += ("\n[files on tape have not been checked, use " "allow_tape=True for a complete search]") raise ValueError(msg)
[ "def", "_error_missing_channels", "(", "required", ",", "found", ",", "gpstime", ",", "allow_tape", ")", ":", "missing", "=", "set", "(", "required", ")", "-", "set", "(", "found", ")", "if", "not", "missing", ":", "# success", "return", "# failure", "msg"...
https://github.com/gwpy/gwpy/blob/82becd78d166a32985cb657a54d0d39f6a207739/gwpy/io/datafind.py#L394-L410
plotly/plotly.py
cfad7862594b35965c0e000813bd7805e8494a5b
packages/python/plotly/plotly/graph_objs/layout/_xaxis.py
python
XAxis.tickformatstopdefaults
(self)
return self["tickformatstopdefaults"]
When used in a template (as layout.template.layout.xaxis.tickformatstopdefaults), sets the default property values to use for elements of layout.xaxis.tickformatstops The 'tickformatstopdefaults' property is an instance of Tickformatstop that may be specified as: - An instance of :class:`plotly.graph_objs.layout.xaxis.Tickformatstop` - A dict of string/value properties that will be passed to the Tickformatstop constructor Supported dict properties: Returns ------- plotly.graph_objs.layout.xaxis.Tickformatstop
When used in a template (as layout.template.layout.xaxis.tickformatstopdefaults), sets the default property values to use for elements of layout.xaxis.tickformatstops The 'tickformatstopdefaults' property is an instance of Tickformatstop that may be specified as: - An instance of :class:`plotly.graph_objs.layout.xaxis.Tickformatstop` - A dict of string/value properties that will be passed to the Tickformatstop constructor Supported dict properties:
[ "When", "used", "in", "a", "template", "(", "as", "layout", ".", "template", ".", "layout", ".", "xaxis", ".", "tickformatstopdefaults", ")", "sets", "the", "default", "property", "values", "to", "use", "for", "elements", "of", "layout", ".", "xaxis", ".",...
def tickformatstopdefaults(self): """ When used in a template (as layout.template.layout.xaxis.tickformatstopdefaults), sets the default property values to use for elements of layout.xaxis.tickformatstops The 'tickformatstopdefaults' property is an instance of Tickformatstop that may be specified as: - An instance of :class:`plotly.graph_objs.layout.xaxis.Tickformatstop` - A dict of string/value properties that will be passed to the Tickformatstop constructor Supported dict properties: Returns ------- plotly.graph_objs.layout.xaxis.Tickformatstop """ return self["tickformatstopdefaults"]
[ "def", "tickformatstopdefaults", "(", "self", ")", ":", "return", "self", "[", "\"tickformatstopdefaults\"", "]" ]
https://github.com/plotly/plotly.py/blob/cfad7862594b35965c0e000813bd7805e8494a5b/packages/python/plotly/plotly/graph_objs/layout/_xaxis.py#L1927-L1946
nlloyd/SubliminalCollaborator
5c619e17ddbe8acb9eea8996ec038169ddcd50a1
libs/twisted/spread/pb.py
python
Broker.dontNotifyOnDisconnect
(self, notifier)
Remove a callback from list of disconnect callbacks.
Remove a callback from list of disconnect callbacks.
[ "Remove", "a", "callback", "from", "list", "of", "disconnect", "callbacks", "." ]
def dontNotifyOnDisconnect(self, notifier): """Remove a callback from list of disconnect callbacks.""" try: self.disconnects.remove(notifier) except ValueError: pass
[ "def", "dontNotifyOnDisconnect", "(", "self", ",", "notifier", ")", ":", "try", ":", "self", ".", "disconnects", ".", "remove", "(", "notifier", ")", "except", "ValueError", ":", "pass" ]
https://github.com/nlloyd/SubliminalCollaborator/blob/5c619e17ddbe8acb9eea8996ec038169ddcd50a1/libs/twisted/spread/pb.py#L678-L683
mozillazg/pypy
2ff5cd960c075c991389f842c6d59e71cf0cb7d0
pypy/module/cpyext/stubs.py
python
PySys_ResetWarnOptions
(space)
Reset sys.warnoptions to an empty list.
Reset sys.warnoptions to an empty list.
[ "Reset", "sys", ".", "warnoptions", "to", "an", "empty", "list", "." ]
def PySys_ResetWarnOptions(space): """Reset sys.warnoptions to an empty list.""" raise NotImplementedError
[ "def", "PySys_ResetWarnOptions", "(", "space", ")", ":", "raise", "NotImplementedError" ]
https://github.com/mozillazg/pypy/blob/2ff5cd960c075c991389f842c6d59e71cf0cb7d0/pypy/module/cpyext/stubs.py#L1324-L1326
AppScale/gts
46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9
AppServer/lib/django-1.2/django/core/serializers/base.py
python
Serializer.handle_fk_field
(self, obj, field)
Called to handle a ForeignKey field.
Called to handle a ForeignKey field.
[ "Called", "to", "handle", "a", "ForeignKey", "field", "." ]
def handle_fk_field(self, obj, field): """ Called to handle a ForeignKey field. """ raise NotImplementedError
[ "def", "handle_fk_field", "(", "self", ",", "obj", ",", "field", ")", ":", "raise", "NotImplementedError" ]
https://github.com/AppScale/gts/blob/46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9/AppServer/lib/django-1.2/django/core/serializers/base.py#L93-L97
lipiji/hierarchical-encoder-decoder
fa4ab3ddfbbb55ffebafedaa17b1b22472fc0936
utils_pg.py
python
use_gpu
(gpu_id)
[]
def use_gpu(gpu_id): if gpu_id > -1: theano.sandbox.cuda.use("gpu" + str(gpu_id))
[ "def", "use_gpu", "(", "gpu_id", ")", ":", "if", "gpu_id", ">", "-", "1", ":", "theano", ".", "sandbox", ".", "cuda", ".", "use", "(", "\"gpu\"", "+", "str", "(", "gpu_id", ")", ")" ]
https://github.com/lipiji/hierarchical-encoder-decoder/blob/fa4ab3ddfbbb55ffebafedaa17b1b22472fc0936/utils_pg.py#L9-L11
F-Secure/mittn
7808552dc85a7998895038fdb2fa5c5bbed90c3e
mittn/httpfuzzer/steps.py
python
step_impl
(context)
Go through responses and store any that contain a string from user-supplied list of strings into the database
Go through responses and store any that contain a string from user-supplied list of strings into the database
[ "Go", "through", "responses", "and", "store", "any", "that", "contain", "a", "string", "from", "user", "-", "supplied", "list", "of", "strings", "into", "the", "database" ]
def step_impl(context): """Go through responses and store any that contain a string from user-supplied list of strings into the database """ # Create a regex from the error response list error_list = [] for row in context.table: error_list.append(row['string']) error_list_regex = "(" + ")|(".join(error_list) + ")" # For each response, check that it isn't in the error response list new_findings = 0 for response in context.responses: if re.search(error_list_regex, response.get('resp_body'), re.IGNORECASE) is not None: response['server_error_text_detected'] = True if fuzzdb.known_false_positive(context, response) is False: fuzzdb.add_false_positive(context, response) new_findings += 1 if new_findings > 0: context.new_findings += new_findings assert True
[ "def", "step_impl", "(", "context", ")", ":", "# Create a regex from the error response list", "error_list", "=", "[", "]", "for", "row", "in", "context", ".", "table", ":", "error_list", ".", "append", "(", "row", "[", "'string'", "]", ")", "error_list_regex", ...
https://github.com/F-Secure/mittn/blob/7808552dc85a7998895038fdb2fa5c5bbed90c3e/mittn/httpfuzzer/steps.py#L209-L231
quantopian/zipline
014f1fc339dc8b7671d29be2d85ce57d3daec343
zipline/utils/memoize.py
python
weak_lru_cache
(maxsize=100)
return desc
Weak least-recently-used cache decorator. If *maxsize* is set to None, the LRU features are disabled and the cache can grow without bound. Arguments to the cached function must be hashable. Any that are weak- referenceable will be stored by weak reference. Once any of the args have been garbage collected, the entry will be removed from the cache. View the cache statistics named tuple (hits, misses, maxsize, currsize) with f.cache_info(). Clear the cache and statistics with f.cache_clear(). See: http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used
Weak least-recently-used cache decorator.
[ "Weak", "least", "-", "recently", "-", "used", "cache", "decorator", "." ]
def weak_lru_cache(maxsize=100): """Weak least-recently-used cache decorator. If *maxsize* is set to None, the LRU features are disabled and the cache can grow without bound. Arguments to the cached function must be hashable. Any that are weak- referenceable will be stored by weak reference. Once any of the args have been garbage collected, the entry will be removed from the cache. View the cache statistics named tuple (hits, misses, maxsize, currsize) with f.cache_info(). Clear the cache and statistics with f.cache_clear(). See: http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used """ class desc(lazyval): def __get__(self, instance, owner): if instance is None: return self try: return self._cache[instance] except KeyError: inst = ref(instance) @_weak_lru_cache(maxsize) @wraps(self._get) def wrapper(*args, **kwargs): return self._get(inst(), *args, **kwargs) self._cache[instance] = wrapper return wrapper @_weak_lru_cache(maxsize) def __call__(self, *args, **kwargs): return self._get(*args, **kwargs) return desc
[ "def", "weak_lru_cache", "(", "maxsize", "=", "100", ")", ":", "class", "desc", "(", "lazyval", ")", ":", "def", "__get__", "(", "self", ",", "instance", ",", "owner", ")", ":", "if", "instance", "is", "None", ":", "return", "self", "try", ":", "retu...
https://github.com/quantopian/zipline/blob/014f1fc339dc8b7671d29be2d85ce57d3daec343/zipline/utils/memoize.py#L211-L248
inasafe/inasafe
355eb2ce63f516b9c26af0c86a24f99e53f63f87
safe/gui/tools/wizard/step_fc25_hazlayer_from_browser.py
python
StepFcHazLayerFromBrowser.get_next_step
(self)
return new_step
Find the proper step when user clicks the Next button. :returns: The step to be switched to :rtype: WizardStep instance or None
Find the proper step when user clicks the Next button.
[ "Find", "the", "proper", "step", "when", "user", "clicks", "the", "Next", "button", "." ]
def get_next_step(self): """Find the proper step when user clicks the Next button. :returns: The step to be switched to :rtype: WizardStep instance or None """ if self.parent.is_selected_layer_keywordless: # insert keyword creation thread here self.parent.parent_step = self self.parent.existing_keywords = None self.parent.set_mode_label_to_keywords_creation() new_step = self.parent.step_kw_purpose else: new_step = self.parent.step_fc_explayer_origin return new_step
[ "def", "get_next_step", "(", "self", ")", ":", "if", "self", ".", "parent", ".", "is_selected_layer_keywordless", ":", "# insert keyword creation thread here", "self", ".", "parent", ".", "parent_step", "=", "self", "self", ".", "parent", ".", "existing_keywords", ...
https://github.com/inasafe/inasafe/blob/355eb2ce63f516b9c26af0c86a24f99e53f63f87/safe/gui/tools/wizard/step_fc25_hazlayer_from_browser.py#L46-L60
ncbi-nlp/bluebert
ccc828c74e0eed942fd1ececff3638babc38269c
bert/run_classifier.py
python
MrpcProcessor._create_examples
(self, lines, set_type)
return examples
Creates examples for the training and dev sets.
Creates examples for the training and dev sets.
[ "Creates", "examples", "for", "the", "training", "and", "dev", "sets", "." ]
def _create_examples(self, lines, set_type): """Creates examples for the training and dev sets.""" examples = [] for (i, line) in enumerate(lines): if i == 0: continue guid = "%s-%s" % (set_type, i) text_a = tokenization.convert_to_unicode(line[3]) text_b = tokenization.convert_to_unicode(line[4]) if set_type == "test": label = "0" else: label = tokenization.convert_to_unicode(line[0]) examples.append( InputExample(guid=guid, text_a=text_a, text_b=text_b, label=label)) return examples
[ "def", "_create_examples", "(", "self", ",", "lines", ",", "set_type", ")", ":", "examples", "=", "[", "]", "for", "(", "i", ",", "line", ")", "in", "enumerate", "(", "lines", ")", ":", "if", "i", "==", "0", ":", "continue", "guid", "=", "\"%s-%s\"...
https://github.com/ncbi-nlp/bluebert/blob/ccc828c74e0eed942fd1ececff3638babc38269c/bert/run_classifier.py#L317-L332
chribsen/simple-machine-learning-examples
dc94e52a4cebdc8bb959ff88b81ff8cfeca25022
venv/lib/python2.7/site-packages/scipy/_lib/_util.py
python
_lazywhere
(cond, arrays, f, fillvalue=None, f2=None)
return out
np.where(cond, x, fillvalue) always evaluates x even where cond is False. This one only evaluates f(arr1[cond], arr2[cond], ...). For example, >>> a, b = np.array([1, 2, 3, 4]), np.array([5, 6, 7, 8]) >>> def f(a, b): return a*b >>> _lazywhere(a > 2, (a, b), f, np.nan) array([ nan, nan, 21., 32.]) Notice it assumes that all `arrays` are of the same shape, or can be broadcasted together.
np.where(cond, x, fillvalue) always evaluates x even where cond is False. This one only evaluates f(arr1[cond], arr2[cond], ...). For example, >>> a, b = np.array([1, 2, 3, 4]), np.array([5, 6, 7, 8]) >>> def f(a, b): return a*b >>> _lazywhere(a > 2, (a, b), f, np.nan) array([ nan, nan, 21., 32.])
[ "np", ".", "where", "(", "cond", "x", "fillvalue", ")", "always", "evaluates", "x", "even", "where", "cond", "is", "False", ".", "This", "one", "only", "evaluates", "f", "(", "arr1", "[", "cond", "]", "arr2", "[", "cond", "]", "...", ")", ".", "For...
def _lazywhere(cond, arrays, f, fillvalue=None, f2=None): """ np.where(cond, x, fillvalue) always evaluates x even where cond is False. This one only evaluates f(arr1[cond], arr2[cond], ...). For example, >>> a, b = np.array([1, 2, 3, 4]), np.array([5, 6, 7, 8]) >>> def f(a, b): return a*b >>> _lazywhere(a > 2, (a, b), f, np.nan) array([ nan, nan, 21., 32.]) Notice it assumes that all `arrays` are of the same shape, or can be broadcasted together. """ if fillvalue is None: if f2 is None: raise ValueError("One of (fillvalue, f2) must be given.") else: fillvalue = np.nan else: if f2 is not None: raise ValueError("Only one of (fillvalue, f2) can be given.") arrays = np.broadcast_arrays(*arrays) temp = tuple(np.extract(cond, arr) for arr in arrays) tcode = np.mintypecode([a.dtype.char for a in arrays]) out = _valarray(np.shape(arrays[0]), value=fillvalue, typecode=tcode) np.place(out, cond, f(*temp)) if f2 is not None: temp = tuple(np.extract(~cond, arr) for arr in arrays) np.place(out, ~cond, f2(*temp)) return out
[ "def", "_lazywhere", "(", "cond", ",", "arrays", ",", "f", ",", "fillvalue", "=", "None", ",", "f2", "=", "None", ")", ":", "if", "fillvalue", "is", "None", ":", "if", "f2", "is", "None", ":", "raise", "ValueError", "(", "\"One of (fillvalue, f2) must be...
https://github.com/chribsen/simple-machine-learning-examples/blob/dc94e52a4cebdc8bb959ff88b81ff8cfeca25022/venv/lib/python2.7/site-packages/scipy/_lib/_util.py#L26-L59
cudamat/cudamat
21baa0a82f189fae40cab3ab607c11cabfee8899
cudamat/cudamat.py
python
CUDAMatrix.add_row_vec
(self, vec, target=None)
return target
Add vector vec to every row of the matrix. If a target is provided, it is used to store the result instead of self.
Add vector vec to every row of the matrix. If a target is provided, it is used to store the result instead of self.
[ "Add", "vector", "vec", "to", "every", "row", "of", "the", "matrix", ".", "If", "a", "target", "is", "provided", "it", "is", "used", "to", "store", "the", "result", "instead", "of", "self", "." ]
def add_row_vec(self, vec, target=None): """ Add vector vec to every row of the matrix. If a target is provided, it is used to store the result instead of self. """ if not target: target = self err_code = _cudamat.add_row_vec(self.p_mat, vec.p_mat, target.p_mat) if err_code: raise generate_exception(err_code) return target
[ "def", "add_row_vec", "(", "self", ",", "vec", ",", "target", "=", "None", ")", ":", "if", "not", "target", ":", "target", "=", "self", "err_code", "=", "_cudamat", ".", "add_row_vec", "(", "self", ".", "p_mat", ",", "vec", ".", "p_mat", ",", "target...
https://github.com/cudamat/cudamat/blob/21baa0a82f189fae40cab3ab607c11cabfee8899/cudamat/cudamat.py#L557-L570
deepmind/hanabi-learning-environment
54e79594f4b6fb40ebb3004289c6db0e34a8b5fb
hanabi_learning_environment/pyhanabi.py
python
HanabiGame.hand_size
(self)
return lib.HandSize(self._game)
Returns the maximum number of cards in each player hand. The number of cards in a player's hand may be smaller than this maximum a) at the beginning of the game before cards are dealt out, b) after any Play or Discard action and before the subsequent deal event, and c) after the deck is empty and cards can no longer be dealt to a player.
Returns the maximum number of cards in each player hand.
[ "Returns", "the", "maximum", "number", "of", "cards", "in", "each", "player", "hand", "." ]
def hand_size(self): """Returns the maximum number of cards in each player hand. The number of cards in a player's hand may be smaller than this maximum a) at the beginning of the game before cards are dealt out, b) after any Play or Discard action and before the subsequent deal event, and c) after the deck is empty and cards can no longer be dealt to a player. """ return lib.HandSize(self._game)
[ "def", "hand_size", "(", "self", ")", ":", "return", "lib", ".", "HandSize", "(", "self", ".", "_game", ")" ]
https://github.com/deepmind/hanabi-learning-environment/blob/54e79594f4b6fb40ebb3004289c6db0e34a8b5fb/hanabi_learning_environment/pyhanabi.py#L748-L756
SirVer/ultisnips
2c83e40ce66814bf813457bb58ea96184ab9bb81
pythonx/UltiSnips/snippet/definition/base.py
python
SnippetDefinition._re_match
(self, trigger)
return False
Test if a the current regex trigger matches `trigger`. If so, set _last_re and _matched.
Test if a the current regex trigger matches `trigger`.
[ "Test", "if", "a", "the", "current", "regex", "trigger", "matches", "trigger", "." ]
def _re_match(self, trigger): """Test if a the current regex trigger matches `trigger`. If so, set _last_re and _matched. """ for match in re.finditer(self._trigger, trigger): if match.end() != len(trigger): continue else: self._matched = trigger[match.start() : match.end()] self._last_re = match return match return False
[ "def", "_re_match", "(", "self", ",", "trigger", ")", ":", "for", "match", "in", "re", ".", "finditer", "(", "self", ".", "_trigger", ",", "trigger", ")", ":", "if", "match", ".", "end", "(", ")", "!=", "len", "(", "trigger", ")", ":", "continue", ...
https://github.com/SirVer/ultisnips/blob/2c83e40ce66814bf813457bb58ea96184ab9bb81/pythonx/UltiSnips/snippet/definition/base.py#L124-L138
google/capirca
679e3885e3a5e5e129dc2dfab204ec44d63b26a4
capirca/lib/windows_ipsec.py
python
Term._ComposeFilter
(self, srcaddr, dstaddr, proto, srcmask, dstmask, srcport, dstport)
return (self.CMD_PREFIX + self._FILTER_FORMAT.substitute( name=self.term_name + self._LIST_SUFFIX, atoms=' '.join(atoms)))
Convert the given parameters to a netsh filter rule string.
Convert the given parameters to a netsh filter rule string.
[ "Convert", "the", "given", "parameters", "to", "a", "netsh", "filter", "rule", "string", "." ]
def _ComposeFilter(self, srcaddr, dstaddr, proto, srcmask, dstmask, srcport, dstport): """Convert the given parameters to a netsh filter rule string.""" atoms = [] if srcmask == 0: atoms.append(self._ADDR_ATOM.substitute(dir='src', addr='any', mask='')) else: mask_atom = self._MASK_ATOM.substitute(dir='src', mask=srcmask) atoms.append(self._ADDR_ATOM.substitute( dir='src', addr=srcaddr, mask=mask_atom)) if dstmask == 0: atoms.append(self._ADDR_ATOM.substitute(dir='dst', addr='any', mask='')) else: mask_atom = self._MASK_ATOM.substitute(dir='dst', mask=dstmask) atoms.append(self._ADDR_ATOM.substitute( dir='dst', addr=dstaddr, mask=mask_atom)) if srcport: atoms.append(self._PORT_ATOM.substitute(dir='src', port=srcport)) if dstport: atoms.append(self._PORT_ATOM.substitute(dir='dst', port=dstport)) if proto: atoms.append(self._PROTO_ATOM.substitute(protocol=proto)) return (self.CMD_PREFIX + self._FILTER_FORMAT.substitute( name=self.term_name + self._LIST_SUFFIX, atoms=' '.join(atoms)))
[ "def", "_ComposeFilter", "(", "self", ",", "srcaddr", ",", "dstaddr", ",", "proto", ",", "srcmask", ",", "dstmask", ",", "srcport", ",", "dstport", ")", ":", "atoms", "=", "[", "]", "if", "srcmask", "==", "0", ":", "atoms", ".", "append", "(", "self"...
https://github.com/google/capirca/blob/679e3885e3a5e5e129dc2dfab204ec44d63b26a4/capirca/lib/windows_ipsec.py#L138-L168
TencentCloud/tencentcloud-sdk-python
3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2
tencentcloud/tcr/v20190924/models.py
python
DescribeInstanceTokenResponse.__init__
(self)
r""" :param TotalCount: 长期访问凭证总数 :type TotalCount: int :param Tokens: 长期访问凭证列表 :type Tokens: list of TcrInstanceToken :param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 :type RequestId: str
r""" :param TotalCount: 长期访问凭证总数 :type TotalCount: int :param Tokens: 长期访问凭证列表 :type Tokens: list of TcrInstanceToken :param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 :type RequestId: str
[ "r", ":", "param", "TotalCount", ":", "长期访问凭证总数", ":", "type", "TotalCount", ":", "int", ":", "param", "Tokens", ":", "长期访问凭证列表", ":", "type", "Tokens", ":", "list", "of", "TcrInstanceToken", ":", "param", "RequestId", ":", "唯一请求", "ID,每次请求都会返回。定位问题时需要提供该次请求的"...
def __init__(self): r""" :param TotalCount: 长期访问凭证总数 :type TotalCount: int :param Tokens: 长期访问凭证列表 :type Tokens: list of TcrInstanceToken :param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 :type RequestId: str """ self.TotalCount = None self.Tokens = None self.RequestId = None
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "TotalCount", "=", "None", "self", ".", "Tokens", "=", "None", "self", ".", "RequestId", "=", "None" ]
https://github.com/TencentCloud/tencentcloud-sdk-python/blob/3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2/tencentcloud/tcr/v20190924/models.py#L2836-L2847
tp4a/teleport
1fafd34f1f775d2cf80ea4af6e44468d8e0b24ad
server/www/packages/packages-linux/x64/cryptography/x509/name.py
python
RelativeDistinguishedName.get_attributes_for_oid
(self, oid)
return [i for i in self if i.oid == oid]
[]
def get_attributes_for_oid(self, oid): return [i for i in self if i.oid == oid]
[ "def", "get_attributes_for_oid", "(", "self", ",", "oid", ")", ":", "return", "[", "i", "for", "i", "in", "self", "if", "i", ".", "oid", "==", "oid", "]" ]
https://github.com/tp4a/teleport/blob/1fafd34f1f775d2cf80ea4af6e44468d8e0b24ad/server/www/packages/packages-linux/x64/cryptography/x509/name.py#L162-L163
pandas-dev/pandas
5ba7d714014ae8feaccc0dd4a98890828cf2832d
pandas/core/ops/__init__.py
python
should_reindex_frame_op
( left: DataFrame, right, op, axis, default_axis, fill_value, level )
return False
Check if this is an operation between DataFrames that will need to reindex.
Check if this is an operation between DataFrames that will need to reindex.
[ "Check", "if", "this", "is", "an", "operation", "between", "DataFrames", "that", "will", "need", "to", "reindex", "." ]
def should_reindex_frame_op( left: DataFrame, right, op, axis, default_axis, fill_value, level ) -> bool: """ Check if this is an operation between DataFrames that will need to reindex. """ assert isinstance(left, ABCDataFrame) if op is operator.pow or op is roperator.rpow: # GH#32685 pow has special semantics for operating with null values return False if not isinstance(right, ABCDataFrame): return False if fill_value is None and level is None and axis is default_axis: # TODO: any other cases we should handle here? # Intersection is always unique so we have to check the unique columns left_uniques = left.columns.unique() right_uniques = right.columns.unique() cols = left_uniques.intersection(right_uniques) if len(cols) and not (cols.equals(left_uniques) and cols.equals(right_uniques)): # TODO: is there a shortcut available when len(cols) == 0? return True return False
[ "def", "should_reindex_frame_op", "(", "left", ":", "DataFrame", ",", "right", ",", "op", ",", "axis", ",", "default_axis", ",", "fill_value", ",", "level", ")", "->", "bool", ":", "assert", "isinstance", "(", "left", ",", "ABCDataFrame", ")", "if", "op", ...
https://github.com/pandas-dev/pandas/blob/5ba7d714014ae8feaccc0dd4a98890828cf2832d/pandas/core/ops/__init__.py#L315-L341
partho-maple/coding-interview-gym
f9b28916da31935a27900794cfb8b91be3b38b9b
leetcode.com/python/21_Merge_Two_Sorted_Lists.py
python
MyLinkedList.getNode
(self, index)
return node
:type index: int :rtype: Node | None
:type index: int :rtype: Node | None
[ ":", "type", "index", ":", "int", ":", "rtype", ":", "Node", "|", "None" ]
def getNode(self, index): """ :type index: int :rtype: Node | None """ if index >= self.size or index < 0: return None node = self.first while index > 0: node = node.next index -= 1 return node
[ "def", "getNode", "(", "self", ",", "index", ")", ":", "if", "index", ">=", "self", ".", "size", "or", "index", "<", "0", ":", "return", "None", "node", "=", "self", ".", "first", "while", "index", ">", "0", ":", "node", "=", "node", ".", "next",...
https://github.com/partho-maple/coding-interview-gym/blob/f9b28916da31935a27900794cfb8b91be3b38b9b/leetcode.com/python/21_Merge_Two_Sorted_Lists.py#L23-L34
luispedro/milk
abc2a28b526c199414d42c0a26092938968c3caf
milk/unsupervised/nnmf/hoyer.py
python
sparse_nnmf
(V, r, sparsenessW=None, sparsenessH=None, max_iter=10000, R=None)
return W,H
W,H = hoyer.sparse_nnmf(V, r, sparsenessW = None, sparsenessH = None, max_iter=10000, R=None) Implement sparse nonnegative matrix factorisation. Parameters ---------- V : 2-D matrix input feature matrix r : integer number of latent features sparsenessW : double, optional sparseness contraint on W (default: no sparsity contraint) sparsenessH : double, optional sparseness contraint on H (default: no sparsity contraint) max_iter : integer, optional maximum nr of iterations (default: 10000) R : integer, optional source of randomness Returns ------- W : 2-ndarray H : 2-ndarray Reference --------- "Non-negative Matrix Factorisation with Sparseness Constraints" by Patrik Hoyer in Journal of Machine Learning Research 5 (2004) 1457--1469
W,H = hoyer.sparse_nnmf(V, r, sparsenessW = None, sparsenessH = None, max_iter=10000, R=None)
[ "W", "H", "=", "hoyer", ".", "sparse_nnmf", "(", "V", "r", "sparsenessW", "=", "None", "sparsenessH", "=", "None", "max_iter", "=", "10000", "R", "=", "None", ")" ]
def sparse_nnmf(V, r, sparsenessW=None, sparsenessH=None, max_iter=10000, R=None): ''' W,H = hoyer.sparse_nnmf(V, r, sparsenessW = None, sparsenessH = None, max_iter=10000, R=None) Implement sparse nonnegative matrix factorisation. Parameters ---------- V : 2-D matrix input feature matrix r : integer number of latent features sparsenessW : double, optional sparseness contraint on W (default: no sparsity contraint) sparsenessH : double, optional sparseness contraint on H (default: no sparsity contraint) max_iter : integer, optional maximum nr of iterations (default: 10000) R : integer, optional source of randomness Returns ------- W : 2-ndarray H : 2-ndarray Reference --------- "Non-negative Matrix Factorisation with Sparseness Constraints" by Patrik Hoyer in Journal of Machine Learning Research 5 (2004) 1457--1469 ''' n,m = V.shape R = get_nprandom(R) mu_W = .15 mu_H = .15 eps = 1e-8 W = R.standard_normal((n,r))**2 H = R.standard_normal((r,m))**2 def fix(X, sparseness): for i in range(r): row = X[i] L2 = np.sqrt(np.dot(row, row)) row /= L2 X[i] = _project(row, _L1for(sparseness, row, 1.), 1.) def fixW(): fix(W.T, sparsenessW) def fixH(): fix(H, sparsenessH) if sparsenessW is not None: fixW() if sparsenessH is not None: fixH() for i in range(max_iter): if sparsenessW is not None: W -= mu_W * np.dot(np.dot(W,H)-V,H.T) fixW() else: updateW = np.dot(V,H.T)/(np.dot(W,np.dot(H,H.T))+eps) W *= updateW if sparsenessH is not None: H -= mu_H * np.dot(W.T,np.dot(W,H)-V) fixH() else: updateH = np.dot(W.T,V)/(np.dot(np.dot(W.T,W),H)+eps) H *= updateH return W,H
[ "def", "sparse_nnmf", "(", "V", ",", "r", ",", "sparsenessW", "=", "None", ",", "sparsenessH", "=", "None", ",", "max_iter", "=", "10000", ",", "R", "=", "None", ")", ":", "n", ",", "m", "=", "V", ".", "shape", "R", "=", "get_nprandom", "(", "R",...
https://github.com/luispedro/milk/blob/abc2a28b526c199414d42c0a26092938968c3caf/milk/unsupervised/nnmf/hoyer.py#L75-L143
astropy/photutils
3caa48e4e4d139976ed7457dc41583fb2c56ba20
photutils/psf/matching/windows.py
python
SplitCosineBellWindow.__call__
(self, shape)
return f
Return a 2D split cosine bell. Parameters ---------- shape : tuple of int The size of the output array along each axis. Returns ------- result : `~numpy.ndarray` A 2D array containing the cosine bell values.
Return a 2D split cosine bell.
[ "Return", "a", "2D", "split", "cosine", "bell", "." ]
def __call__(self, shape): """ Return a 2D split cosine bell. Parameters ---------- shape : tuple of int The size of the output array along each axis. Returns ------- result : `~numpy.ndarray` A 2D array containing the cosine bell values. """ radial_dist = _radial_distance(shape) npts = (np.array(shape).min() - 1.) / 2. r_inner = self.beta * npts r = radial_dist - r_inner r_taper = int(np.floor(self.alpha * npts)) if r_taper != 0: f = 0.5 * (1.0 + np.cos(np.pi * r / r_taper)) else: f = np.ones(shape) f[radial_dist < r_inner] = 1. r_cut = r_inner + r_taper f[radial_dist > r_cut] = 0. return f
[ "def", "__call__", "(", "self", ",", "shape", ")", ":", "radial_dist", "=", "_radial_distance", "(", "shape", ")", "npts", "=", "(", "np", ".", "array", "(", "shape", ")", ".", "min", "(", ")", "-", "1.", ")", "/", "2.", "r_inner", "=", "self", "...
https://github.com/astropy/photutils/blob/3caa48e4e4d139976ed7457dc41583fb2c56ba20/photutils/psf/matching/windows.py#L79-L108
dimagi/commcare-hq
d67ff1d3b4c51fa050c19e60c3253a79d3452a39
corehq/apps/users/models.py
python
UserReportingMetadataStaging.add_heartbeat
(cls, domain, user_id, app_id, build_id, sync_date, device_id, app_version, num_unsent_forms, num_quarantined_forms, commcare_version, build_profile_id)
[]
def add_heartbeat(cls, domain, user_id, app_id, build_id, sync_date, device_id, app_version, num_unsent_forms, num_quarantined_forms, commcare_version, build_profile_id): params = { 'domain': domain, 'user_id': user_id, 'app_id': app_id, 'build_id': build_id, 'sync_date': sync_date, 'device_id': device_id, 'app_version': app_version, 'num_unsent_forms': num_unsent_forms, 'num_quarantined_forms': num_quarantined_forms, 'commcare_version': commcare_version, 'build_profile_id': build_profile_id, } with connection.cursor() as cursor: cursor.execute(f""" INSERT INTO {cls._meta.db_table} AS staging ( domain, user_id, app_id, modified_on, created_on, build_id, sync_date, device_id, app_version, num_unsent_forms, num_quarantined_forms, commcare_version, build_profile_id, last_heartbeat ) VALUES ( %(domain)s, %(user_id)s, %(app_id)s, CLOCK_TIMESTAMP(), CLOCK_TIMESTAMP(), %(build_id)s, %(sync_date)s, %(device_id)s, %(app_version)s, %(num_unsent_forms)s, %(num_quarantined_forms)s, %(commcare_version)s, %(build_profile_id)s, CLOCK_TIMESTAMP() ) ON CONFLICT (domain, user_id, app_id) DO UPDATE SET modified_on = CLOCK_TIMESTAMP(), build_id = COALESCE(EXCLUDED.build_id, staging.build_id), sync_date = COALESCE(EXCLUDED.sync_date, staging.sync_date), device_id = COALESCE(EXCLUDED.device_id, staging.device_id), app_version = EXCLUDED.app_version, num_unsent_forms = EXCLUDED.num_unsent_forms, num_quarantined_forms = EXCLUDED.num_quarantined_forms, commcare_version = EXCLUDED.commcare_version, build_profile_id = EXCLUDED.build_profile_id, last_heartbeat = CLOCK_TIMESTAMP() WHERE staging.last_heartbeat is NULL or EXCLUDED.last_heartbeat > staging.last_heartbeat """, params)
[ "def", "add_heartbeat", "(", "cls", ",", "domain", ",", "user_id", ",", "app_id", ",", "build_id", ",", "sync_date", ",", "device_id", ",", "app_version", ",", "num_unsent_forms", ",", "num_quarantined_forms", ",", "commcare_version", ",", "build_profile_id", ")",...
https://github.com/dimagi/commcare-hq/blob/d67ff1d3b4c51fa050c19e60c3253a79d3452a39/corehq/apps/users/models.py#L2935-L2978
Epistimio/orion
732e739d99561020dbe620760acf062ade746006
src/orion/core/evc/adapters.py
python
apply_if_valid
(name, trial, callback=None, raise_if_not=True)
return False
Detect a parameter in trial and call a callback on it if provided Parameters ---------- name: str Name of the param to look for trial: `orion.core.worker.trial.Trial` Instance of trial to investigate callback: None of callable Function to call with (trial, param) with a parameter is found. Defaults to None raise_if_not: bool raises RuntimeError if no parameter is found. Defaults to True. Returns ------- bool False if parameter is not found and `raise_if_not is False`. True if parameter is found and callback is None. Else, output of callback(trial, item).
Detect a parameter in trial and call a callback on it if provided
[ "Detect", "a", "parameter", "in", "trial", "and", "call", "a", "callback", "on", "it", "if", "provided" ]
def apply_if_valid(name, trial, callback=None, raise_if_not=True): """Detect a parameter in trial and call a callback on it if provided Parameters ---------- name: str Name of the param to look for trial: `orion.core.worker.trial.Trial` Instance of trial to investigate callback: None of callable Function to call with (trial, param) with a parameter is found. Defaults to None raise_if_not: bool raises RuntimeError if no parameter is found. Defaults to True. Returns ------- bool False if parameter is not found and `raise_if_not is False`. True if parameter is found and callback is None. Else, output of callback(trial, item). """ for param in trial._params: # pylint: disable=protected-access if param.name == name: return callback is None or callback(trial, param) if raise_if_not: raise RuntimeError( "Provided trial does not have a compatible configuration. " "A dimension named '%s' should be present.\n %s" % (name, trial) ) return False
[ "def", "apply_if_valid", "(", "name", ",", "trial", ",", "callback", "=", "None", ",", "raise_if_not", "=", "True", ")", ":", "for", "param", "in", "trial", ".", "_params", ":", "# pylint: disable=protected-access", "if", "param", ".", "name", "==", "name", ...
https://github.com/Epistimio/orion/blob/732e739d99561020dbe620760acf062ade746006/src/orion/core/evc/adapters.py#L228-L262
optuna/optuna
2c44c1a405ba059efd53f4b9c8e849d20fb95c0a
optuna/study/_optimize.py
python
_optimize
( study: "optuna.Study", func: "optuna.study.study.ObjectiveFuncType", n_trials: Optional[int] = None, timeout: Optional[float] = None, n_jobs: int = 1, catch: Tuple[Type[Exception], ...] = (), callbacks: Optional[List[Callable[["optuna.Study", FrozenTrial], None]]] = None, gc_after_trial: bool = False, show_progress_bar: bool = False, )
[]
def _optimize( study: "optuna.Study", func: "optuna.study.study.ObjectiveFuncType", n_trials: Optional[int] = None, timeout: Optional[float] = None, n_jobs: int = 1, catch: Tuple[Type[Exception], ...] = (), callbacks: Optional[List[Callable[["optuna.Study", FrozenTrial], None]]] = None, gc_after_trial: bool = False, show_progress_bar: bool = False, ) -> None: if not isinstance(catch, tuple): raise TypeError( "The catch argument is of type '{}' but must be a tuple.".format(type(catch).__name__) ) if not study._optimize_lock.acquire(False): raise RuntimeError("Nested invocation of `Study.optimize` method isn't allowed.") # TODO(crcrpar): Make progress bar work when n_jobs != 1. progress_bar = pbar_module._ProgressBar(show_progress_bar and n_jobs == 1, n_trials, timeout) study._stop_flag = False try: if n_jobs == 1: _optimize_sequential( study, func, n_trials, timeout, catch, callbacks, gc_after_trial, reseed_sampler_rng=False, time_start=None, progress_bar=progress_bar, ) else: if show_progress_bar: warnings.warn("Progress bar only supports serial execution (`n_jobs=1`).") if n_jobs == -1: n_jobs = os.cpu_count() or 1 time_start = datetime.datetime.now() futures: Set[Future] = set() with ThreadPoolExecutor(max_workers=n_jobs) as executor: for n_submitted_trials in itertools.count(): if study._stop_flag: break if ( timeout is not None and (datetime.datetime.now() - time_start).total_seconds() > timeout ): break if n_trials is not None and n_submitted_trials >= n_trials: break if len(futures) >= n_jobs: completed, futures = wait(futures, return_when=FIRST_COMPLETED) # Raise if exception occurred in executing the completed futures. for f in completed: f.result() futures.add( executor.submit( _optimize_sequential, study, func, 1, timeout, catch, callbacks, gc_after_trial, True, time_start, None, ) ) finally: study._optimize_lock.release() progress_bar.close()
[ "def", "_optimize", "(", "study", ":", "\"optuna.Study\"", ",", "func", ":", "\"optuna.study.study.ObjectiveFuncType\"", ",", "n_trials", ":", "Optional", "[", "int", "]", "=", "None", ",", "timeout", ":", "Optional", "[", "float", "]", "=", "None", ",", "n_...
https://github.com/optuna/optuna/blob/2c44c1a405ba059efd53f4b9c8e849d20fb95c0a/optuna/study/_optimize.py#L40-L125
vita-epfl/monoloco
f5e82c48e8ee5af352f2c9b1690050f4e02fc1b6
monoloco/prep/preprocess_nu.py
python
factory
(dataset, dir_nuscenes)
return nusc, scenes, split_train, split_val
Define dataset type and split training and validation
Define dataset type and split training and validation
[ "Define", "dataset", "type", "and", "split", "training", "and", "validation" ]
def factory(dataset, dir_nuscenes): """Define dataset type and split training and validation""" assert dataset in ['nuscenes', 'nuscenes_mini', 'nuscenes_teaser'] if dataset == 'nuscenes_mini': version = 'v1.0-mini' else: version = 'v1.0-trainval' nusc = NuScenes(version=version, dataroot=dir_nuscenes, verbose=True) scenes = nusc.scene if dataset == 'nuscenes_teaser': with open("splits/nuscenes_teaser_scenes.txt", "r") as file: teaser_scenes = file.read().splitlines() scenes = [scene for scene in scenes if scene['token'] in teaser_scenes] with open("splits/split_nuscenes_teaser.json", "r") as file: dic_split = json.load(file) split_train = [scene['name'] for scene in scenes if scene['token'] in dic_split['train']] split_val = [scene['name'] for scene in scenes if scene['token'] in dic_split['val']] else: split_scenes = splits.create_splits_scenes() split_train, split_val = split_scenes['train'], split_scenes['val'] return nusc, scenes, split_train, split_val
[ "def", "factory", "(", "dataset", ",", "dir_nuscenes", ")", ":", "assert", "dataset", "in", "[", "'nuscenes'", ",", "'nuscenes_mini'", ",", "'nuscenes_teaser'", "]", "if", "dataset", "==", "'nuscenes_mini'", ":", "version", "=", "'v1.0-mini'", "else", ":", "ve...
https://github.com/vita-epfl/monoloco/blob/f5e82c48e8ee5af352f2c9b1690050f4e02fc1b6/monoloco/prep/preprocess_nu.py#L185-L209
yaml/pyyaml
8cdff2c80573b8be8e8ad28929264a913a63aa33
lib/yaml/__init__.py
python
add_multi_constructor
(tag_prefix, multi_constructor, Loader=None)
Add a multi-constructor for the given tag prefix. Multi-constructor is called for a node if its tag starts with tag_prefix. Multi-constructor accepts a Loader instance, a tag suffix, and a node object and produces the corresponding Python object.
Add a multi-constructor for the given tag prefix. Multi-constructor is called for a node if its tag starts with tag_prefix. Multi-constructor accepts a Loader instance, a tag suffix, and a node object and produces the corresponding Python object.
[ "Add", "a", "multi", "-", "constructor", "for", "the", "given", "tag", "prefix", ".", "Multi", "-", "constructor", "is", "called", "for", "a", "node", "if", "its", "tag", "starts", "with", "tag_prefix", ".", "Multi", "-", "constructor", "accepts", "a", "...
def add_multi_constructor(tag_prefix, multi_constructor, Loader=None): """ Add a multi-constructor for the given tag prefix. Multi-constructor is called for a node if its tag starts with tag_prefix. Multi-constructor accepts a Loader instance, a tag suffix, and a node object and produces the corresponding Python object. """ if Loader is None: loader.Loader.add_multi_constructor(tag_prefix, multi_constructor) loader.FullLoader.add_multi_constructor(tag_prefix, multi_constructor) loader.UnsafeLoader.add_multi_constructor(tag_prefix, multi_constructor) else: Loader.add_multi_constructor(tag_prefix, multi_constructor)
[ "def", "add_multi_constructor", "(", "tag_prefix", ",", "multi_constructor", ",", "Loader", "=", "None", ")", ":", "if", "Loader", "is", "None", ":", "loader", ".", "Loader", ".", "add_multi_constructor", "(", "tag_prefix", ",", "multi_constructor", ")", "loader...
https://github.com/yaml/pyyaml/blob/8cdff2c80573b8be8e8ad28929264a913a63aa33/lib/yaml/__init__.py#L315-L327
NervanaSystems/neon
8c3fb8a93b4a89303467b25817c60536542d08bd
neon/layers/layer.py
python
BranchNode.bprop
(self, error, alpha=1.0, beta=0.0)
Branch nodes should be skipped in bprop, since their deltas are shared Arguments: error (Tensor): deltas back propagated from the adjacent higher layer alpha (float, optional): scale to apply to input for activation gradient bprop. Defaults to 1.0 beta (float, optional): scale to apply to output activation gradient bprop. Defaults to 0.0 Returns: Tensor: deltas to propagate to the adjacent lower layer
Branch nodes should be skipped in bprop, since their deltas are shared
[ "Branch", "nodes", "should", "be", "skipped", "in", "bprop", "since", "their", "deltas", "are", "shared" ]
def bprop(self, error, alpha=1.0, beta=0.0): """ Branch nodes should be skipped in bprop, since their deltas are shared Arguments: error (Tensor): deltas back propagated from the adjacent higher layer alpha (float, optional): scale to apply to input for activation gradient bprop. Defaults to 1.0 beta (float, optional): scale to apply to output activation gradient bprop. Defaults to 0.0 Returns: Tensor: deltas to propagate to the adjacent lower layer """ pass
[ "def", "bprop", "(", "self", ",", "error", ",", "alpha", "=", "1.0", ",", "beta", "=", "0.0", ")", ":", "pass" ]
https://github.com/NervanaSystems/neon/blob/8c3fb8a93b4a89303467b25817c60536542d08bd/neon/layers/layer.py#L417-L431
plotly/plotly.py
cfad7862594b35965c0e000813bd7805e8494a5b
packages/python/plotly/plotly/graph_objs/layout/_shape.py
python
Shape.yanchor
(self)
return self["yanchor"]
Only relevant in conjunction with `ysizemode` set to "pixel". Specifies the anchor point on the y axis to which `y0`, `y1` and y coordinates within `path` are relative to. E.g. useful to attach a pixel sized shape to a certain data value. No effect when `ysizemode` not set to "pixel". The 'yanchor' property accepts values of any type Returns ------- Any
Only relevant in conjunction with `ysizemode` set to "pixel". Specifies the anchor point on the y axis to which `y0`, `y1` and y coordinates within `path` are relative to. E.g. useful to attach a pixel sized shape to a certain data value. No effect when `ysizemode` not set to "pixel". The 'yanchor' property accepts values of any type
[ "Only", "relevant", "in", "conjunction", "with", "ysizemode", "set", "to", "pixel", ".", "Specifies", "the", "anchor", "point", "on", "the", "y", "axis", "to", "which", "y0", "y1", "and", "y", "coordinates", "within", "path", "are", "relative", "to", ".", ...
def yanchor(self): """ Only relevant in conjunction with `ysizemode` set to "pixel". Specifies the anchor point on the y axis to which `y0`, `y1` and y coordinates within `path` are relative to. E.g. useful to attach a pixel sized shape to a certain data value. No effect when `ysizemode` not set to "pixel". The 'yanchor' property accepts values of any type Returns ------- Any """ return self["yanchor"]
[ "def", "yanchor", "(", "self", ")", ":", "return", "self", "[", "\"yanchor\"", "]" ]
https://github.com/plotly/plotly.py/blob/cfad7862594b35965c0e000813bd7805e8494a5b/packages/python/plotly/plotly/graph_objs/layout/_shape.py#L528-L542
nchammas/flintrock
fad4e15877a5bf7058395ecbc7be717b21ef6b85
flintrock/flintrock.py
python
format_message
(*, message: str, indent: int=4, wrap: int=70)
return textwrap.indent( textwrap.fill( textwrap.dedent(text=message), width=wrap), prefix=' ' * indent)
Format a lengthy message for printing to screen.
Format a lengthy message for printing to screen.
[ "Format", "a", "lengthy", "message", "for", "printing", "to", "screen", "." ]
def format_message(*, message: str, indent: int=4, wrap: int=70): """ Format a lengthy message for printing to screen. """ return textwrap.indent( textwrap.fill( textwrap.dedent(text=message), width=wrap), prefix=' ' * indent)
[ "def", "format_message", "(", "*", ",", "message", ":", "str", ",", "indent", ":", "int", "=", "4", ",", "wrap", ":", "int", "=", "70", ")", ":", "return", "textwrap", ".", "indent", "(", "textwrap", ".", "fill", "(", "textwrap", ".", "dedent", "("...
https://github.com/nchammas/flintrock/blob/fad4e15877a5bf7058395ecbc7be717b21ef6b85/flintrock/flintrock.py#L46-L54
openstack/nova
b49b7663e1c3073917d5844b81d38db8e86d05c4
nova/compute/manager.py
python
ComputeManager._confirm_snapshot_based_resize_delete_port_bindings
( self, ctxt, instance)
Delete port bindings for the source host when confirming snapshot-based resize on the source host." :param ctxt: nova auth RequestContext :param instance: Instance object that was resized/cold migrated
Delete port bindings for the source host when confirming snapshot-based resize on the source host."
[ "Delete", "port", "bindings", "for", "the", "source", "host", "when", "confirming", "snapshot", "-", "based", "resize", "on", "the", "source", "host", "." ]
def _confirm_snapshot_based_resize_delete_port_bindings( self, ctxt, instance): """Delete port bindings for the source host when confirming snapshot-based resize on the source host." :param ctxt: nova auth RequestContext :param instance: Instance object that was resized/cold migrated """ LOG.debug('Deleting port bindings for source host.', instance=instance) try: self.network_api.cleanup_instance_network_on_host( ctxt, instance, self.host) except exception.PortBindingDeletionFailed as e: # Do not let this stop us from cleaning up since the guest # is already gone. LOG.error('Failed to delete port bindings from source host. ' 'Error: %s', str(e), instance=instance)
[ "def", "_confirm_snapshot_based_resize_delete_port_bindings", "(", "self", ",", "ctxt", ",", "instance", ")", ":", "LOG", ".", "debug", "(", "'Deleting port bindings for source host.'", ",", "instance", "=", "instance", ")", "try", ":", "self", ".", "network_api", "...
https://github.com/openstack/nova/blob/b49b7663e1c3073917d5844b81d38db8e86d05c4/nova/compute/manager.py#L4562-L4579
assertpy/assertpy
c970c6612a80aa10769dc612324630d27019e1b5
assertpy/string.py
python
StringMixin.contains_ignoring_case
(self, *items)
return self
Asserts that val is string and contains the given item or items. Walks val and checks for item or items using the ``==`` operator and ``str.lower()``. Args: *items: the item or items expected to be contained Examples: Usage:: assert_that('foo').contains_ignoring_case('F', 'oO') assert_that(['a', 'B']).contains_ignoring_case('A', 'b') assert_that({'a': 1, 'B': 2}).contains_ignoring_case('A', 'b') assert_that({'a', 'B'}).contains_ignoring_case('A', 'b') Returns: AssertionBuilder: returns this instance to chain to the next assertion Raises: AssertionError: if val does **not** contain the case-insensitive item or items
Asserts that val is string and contains the given item or items.
[ "Asserts", "that", "val", "is", "string", "and", "contains", "the", "given", "item", "or", "items", "." ]
def contains_ignoring_case(self, *items): """Asserts that val is string and contains the given item or items. Walks val and checks for item or items using the ``==`` operator and ``str.lower()``. Args: *items: the item or items expected to be contained Examples: Usage:: assert_that('foo').contains_ignoring_case('F', 'oO') assert_that(['a', 'B']).contains_ignoring_case('A', 'b') assert_that({'a': 1, 'B': 2}).contains_ignoring_case('A', 'b') assert_that({'a', 'B'}).contains_ignoring_case('A', 'b') Returns: AssertionBuilder: returns this instance to chain to the next assertion Raises: AssertionError: if val does **not** contain the case-insensitive item or items """ if len(items) == 0: raise ValueError('one or more args must be given') if isinstance(self.val, str_types): if len(items) == 1: if not isinstance(items[0], str_types): raise TypeError('given arg must be a string') if items[0].lower() not in self.val.lower(): return self.error('Expected <%s> to case-insensitive contain item <%s>, but did not.' % (self.val, items[0])) else: missing = [] for i in items: if not isinstance(i, str_types): raise TypeError('given args must all be strings') if i.lower() not in self.val.lower(): missing.append(i) if missing: return self.error('Expected <%s> to case-insensitive contain items %s, but did not contain %s.' % ( self.val, self._fmt_items(items), self._fmt_items(missing))) elif isinstance(self.val, Iterable): missing = [] for i in items: if not isinstance(i, str_types): raise TypeError('given args must all be strings') found = False for v in self.val: if not isinstance(v, str_types): raise TypeError('val items must all be strings') if i.lower() == v.lower(): found = True break if not found: missing.append(i) if missing: return self.error('Expected <%s> to case-insensitive contain items %s, but did not contain %s.' % ( self.val, self._fmt_items(items), self._fmt_items(missing))) else: raise TypeError('val is not a string or iterable') return self
[ "def", "contains_ignoring_case", "(", "self", ",", "*", "items", ")", ":", "if", "len", "(", "items", ")", "==", "0", ":", "raise", "ValueError", "(", "'one or more args must be given'", ")", "if", "isinstance", "(", "self", ".", "val", ",", "str_types", "...
https://github.com/assertpy/assertpy/blob/c970c6612a80aa10769dc612324630d27019e1b5/assertpy/string.py#L77-L136
oilshell/oil
94388e7d44a9ad879b12615f6203b38596b5a2d3
Python-2.7.13/Lib/urllib2.py
python
FileHandler.file_open
(self, req)
[]
def file_open(self, req): url = req.get_selector() if url[:2] == '//' and url[2:3] != '/' and (req.host and req.host != 'localhost'): req.type = 'ftp' return self.parent.open(req) else: return self.open_local_file(req)
[ "def", "file_open", "(", "self", ",", "req", ")", ":", "url", "=", "req", ".", "get_selector", "(", ")", "if", "url", "[", ":", "2", "]", "==", "'//'", "and", "url", "[", "2", ":", "3", "]", "!=", "'/'", "and", "(", "req", ".", "host", "and",...
https://github.com/oilshell/oil/blob/94388e7d44a9ad879b12615f6203b38596b5a2d3/Python-2.7.13/Lib/urllib2.py#L1329-L1336
blurstudio/cross3d
277968d1227de740fc87ef61005c75034420eadf
cross3d/studiomax/studiomaxscene.py
python
StudiomaxScene.renderOutputPath
(self)
return mxs.rendOutputFilename
\remarks return the render output file path for the scene \return <str>
\remarks return the render output file path for the scene \return <str>
[ "\\", "remarks", "return", "the", "render", "output", "file", "path", "for", "the", "scene", "\\", "return", "<str", ">" ]
def renderOutputPath(self): """ \remarks return the render output file path for the scene \return <str> """ return mxs.rendOutputFilename
[ "def", "renderOutputPath", "(", "self", ")", ":", "return", "mxs", ".", "rendOutputFilename" ]
https://github.com/blurstudio/cross3d/blob/277968d1227de740fc87ef61005c75034420eadf/cross3d/studiomax/studiomaxscene.py#L2836-L2841
golismero/golismero
7d605b937e241f51c1ca4f47b20f755eeefb9d76
golismero/api/data/vulnerability/suspicious/header.py
python
SuspiciousHeader.name
(self)
return self.__name
:returns: Header name. :rtype: str
:returns: Header name. :rtype: str
[ ":", "returns", ":", "Header", "name", ".", ":", "rtype", ":", "str" ]
def name(self): """ :returns: Header name. :rtype: str """ return self.__name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "__name" ]
https://github.com/golismero/golismero/blob/7d605b937e241f51c1ca4f47b20f755eeefb9d76/golismero/api/data/vulnerability/suspicious/header.py#L79-L84
ceph/ceph-ansible
583e60af84180f0414d67ee52c3ec7cd64ddb4dd
library/ceph_key.py
python
get_key
(cluster, user, user_key, name, dest, container_image=None)
return cmd_list
Get a CephX key (write on the filesystem)
Get a CephX key (write on the filesystem)
[ "Get", "a", "CephX", "key", "(", "write", "on", "the", "filesystem", ")" ]
def get_key(cluster, user, user_key, name, dest, container_image=None): ''' Get a CephX key (write on the filesystem) ''' cmd_list = [] args = [ 'get', name, '-o', dest, ] cmd_list.append(generate_ceph_cmd(sub_cmd=['auth'], args=args, cluster=cluster, user=user, user_key=user_key, container_image=container_image)) return cmd_list
[ "def", "get_key", "(", "cluster", ",", "user", ",", "user_key", ",", "name", ",", "dest", ",", "container_image", "=", "None", ")", ":", "cmd_list", "=", "[", "]", "args", "=", "[", "'get'", ",", "name", ",", "'-o'", ",", "dest", ",", "]", "cmd_lis...
https://github.com/ceph/ceph-ansible/blob/583e60af84180f0414d67ee52c3ec7cd64ddb4dd/library/ceph_key.py#L339-L360
IronLanguages/ironpython3
7a7bb2a872eeab0d1009fc8a6e24dca43f65b693
Src/StdLib/Lib/tkinter/__init__.py
python
Wm.wm_overrideredirect
(self, boolean=None)
return self._getboolean(self.tk.call( 'wm', 'overrideredirect', self._w, boolean))
Instruct the window manager to ignore this widget if BOOLEAN is given with 1. Return the current value if None is given.
Instruct the window manager to ignore this widget if BOOLEAN is given with 1. Return the current value if None is given.
[ "Instruct", "the", "window", "manager", "to", "ignore", "this", "widget", "if", "BOOLEAN", "is", "given", "with", "1", ".", "Return", "the", "current", "value", "if", "None", "is", "given", "." ]
def wm_overrideredirect(self, boolean=None): """Instruct the window manager to ignore this widget if BOOLEAN is given with 1. Return the current value if None is given.""" return self._getboolean(self.tk.call( 'wm', 'overrideredirect', self._w, boolean))
[ "def", "wm_overrideredirect", "(", "self", ",", "boolean", "=", "None", ")", ":", "return", "self", ".", "_getboolean", "(", "self", ".", "tk", ".", "call", "(", "'wm'", ",", "'overrideredirect'", ",", "self", ".", "_w", ",", "boolean", ")", ")" ]
https://github.com/IronLanguages/ironpython3/blob/7a7bb2a872eeab0d1009fc8a6e24dca43f65b693/Src/StdLib/Lib/tkinter/__init__.py#L1776-L1781
aleju/imgaug
0101108d4fed06bc5056c4a03e2bcb0216dac326
imgaug/augmenters/color.py
python
RemoveSaturation.__init__
(self, mul=1, from_colorspace=CSPACE_RGB, seed=None, name=None, random_state="deprecated", deterministic="deprecated")
[]
def __init__(self, mul=1, from_colorspace=CSPACE_RGB, seed=None, name=None, random_state="deprecated", deterministic="deprecated"): mul = iap.Subtract( 1.0, iap.handle_continuous_param(mul, "mul", value_range=(0.0, 1.0), tuple_to_uniform=True, list_to_choice=True), elementwise=True ) super(RemoveSaturation, self).__init__( mul, from_colorspace=from_colorspace, seed=seed, name=name, random_state=random_state, deterministic=deterministic)
[ "def", "__init__", "(", "self", ",", "mul", "=", "1", ",", "from_colorspace", "=", "CSPACE_RGB", ",", "seed", "=", "None", ",", "name", "=", "None", ",", "random_state", "=", "\"deprecated\"", ",", "deterministic", "=", "\"deprecated\"", ")", ":", "mul", ...
https://github.com/aleju/imgaug/blob/0101108d4fed06bc5056c4a03e2bcb0216dac326/imgaug/augmenters/color.py#L2180-L2194