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
FSecureLABS/Jandroid
e31d0dab58a2bfd6ed8e0a387172b8bd7c893436
libs/platform-tools/platform-tools_linux/systrace/catapult/systrace/systrace/tracing_agents/__init__.py
python
TracingAgent.SupportsExplicitClockSync
(self)
Find out if this agent supports recording of clock sync markers. Returns: Boolean value indicating whether this agent supports recording of clock sync markers.
Find out if this agent supports recording of clock sync markers.
[ "Find", "out", "if", "this", "agent", "supports", "recording", "of", "clock", "sync", "markers", "." ]
def SupportsExplicitClockSync(self): '''Find out if this agent supports recording of clock sync markers. Returns: Boolean value indicating whether this agent supports recording of clock sync markers. ''' raise NotImplementedError
[ "def", "SupportsExplicitClockSync", "(", "self", ")", ":", "raise", "NotImplementedError" ]
https://github.com/FSecureLABS/Jandroid/blob/e31d0dab58a2bfd6ed8e0a387172b8bd7c893436/libs/platform-tools/platform-tools_linux/systrace/catapult/systrace/systrace/tracing_agents/__init__.py#L58-L65
gammapy/gammapy
735b25cd5bbed35e2004d633621896dcd5295e8b
gammapy/maps/wcs/geom.py
python
WcsGeom.axes_names
(self)
return ["lon", "lat"] + self.axes.names
All axes names
All axes names
[ "All", "axes", "names" ]
def axes_names(self): """All axes names""" return ["lon", "lat"] + self.axes.names
[ "def", "axes_names", "(", "self", ")", ":", "return", "[", "\"lon\"", ",", "\"lat\"", "]", "+", "self", ".", "axes", ".", "names" ]
https://github.com/gammapy/gammapy/blob/735b25cd5bbed35e2004d633621896dcd5295e8b/gammapy/maps/wcs/geom.py#L128-L130
securesystemslab/zippy
ff0e84ac99442c2c55fe1d285332cfd4e185e089
zippy/benchmarks/src/benchmarks/sympy/sympy/physics/quantum/spin.py
python
Rotation._represent_default_basis
(self, **options)
return self._represent_JzOp(None, **options)
[]
def _represent_default_basis(self, **options): return self._represent_JzOp(None, **options)
[ "def", "_represent_default_basis", "(", "self", ",", "*", "*", "options", ")", ":", "return", "self", ".", "_represent_JzOp", "(", "None", ",", "*", "*", "options", ")" ]
https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/benchmarks/src/benchmarks/sympy/sympy/physics/quantum/spin.py#L619-L620
dot-osk/monitor_ctrl
5e5a6d151478e5dd5b0361ff401a96b609b98c84
monitor_ctrl.py
python
parse_arg
()
Parse command line arguments. :return:
Parse command line arguments. :return:
[ "Parse", "command", "line", "arguments", ".", ":", "return", ":" ]
def parse_arg(): """ Parse command line arguments. :return: """ parser = argparse.ArgumentParser(description='通过DDC/CI设置显示器参数.') parser.add_argument('-m', action='store', type=str, default='*', help='指定要应用到的Monitor Model,' '不指定则应用到所有可操作的显示器') parser.add_argument('-s', action='store', type=str, help='property1=value1{}property2="value 2" 应用多项设置' .format(ARG_SPLITTER)) parser.add_argument('-r', action='store_true', default=False, help='将显示器恢复出厂设置') parser.add_argument('-t', action='store_true', default=False, help='对输入执行自动调整(仅VGA输入需要)') parser.add_argument('-c', action='store_true', default=False, help='不启用GUI') parser.add_argument('-l', action='store_true', help='显示可操作的显示器model') parser.add_argument('-v', action='store_true', help='Verbose logging') opts = parser.parse_args() global APP_OPTIONS APP_OPTIONS['apply_to_model'] = opts.m APP_OPTIONS['list_monitors'] = opts.l APP_OPTIONS['setting_value_string'] = opts.s APP_OPTIONS['restore_factory'] = opts.r APP_OPTIONS['perform_auto_setup'] = opts.t # if specified -c argument or tkinter not imported if opts.c or (not TK_IMPORTED): APP_OPTIONS['console'] = True # log to console APP_OPTIONS['log_file'] = None else: APP_OPTIONS['console'] = False # log to file APP_OPTIONS['log_file'] = DEFAULT_LOGFILE_PATH # logging level if opts.v: APP_OPTIONS['log_level'] = logging.DEBUG else: APP_OPTIONS['log_level'] = logging.INFO
[ "def", "parse_arg", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'通过DDC/CI设置显示器参数.')", "", "parser", ".", "add_argument", "(", "'-m'", ",", "action", "=", "'store'", ",", "type", "=", "str", ",", "default", "="...
https://github.com/dot-osk/monitor_ctrl/blob/5e5a6d151478e5dd5b0361ff401a96b609b98c84/monitor_ctrl.py#L41-L79
sagemath/sage
f9b2db94f675ff16963ccdefba4f1a3393b3fe0d
src/sage/crypto/mq/rijndael_gf.py
python
RijndaelGF.key_length
(self)
return self._Nk
r""" Return the key length of this instantiation of Rijndael-GF. EXAMPLES:: sage: from sage.crypto.mq.rijndael_gf import RijndaelGF sage: rgf = RijndaelGF(4, 8) sage: rgf.key_length() 8
r""" Return the key length of this instantiation of Rijndael-GF.
[ "r", "Return", "the", "key", "length", "of", "this", "instantiation", "of", "Rijndael", "-", "GF", "." ]
def key_length(self): r""" Return the key length of this instantiation of Rijndael-GF. EXAMPLES:: sage: from sage.crypto.mq.rijndael_gf import RijndaelGF sage: rgf = RijndaelGF(4, 8) sage: rgf.key_length() 8 """ return self._Nk
[ "def", "key_length", "(", "self", ")", ":", "return", "self", ".", "_Nk" ]
https://github.com/sagemath/sage/blob/f9b2db94f675ff16963ccdefba4f1a3393b3fe0d/src/sage/crypto/mq/rijndael_gf.py#L647-L658
apache/tvm
6eb4ed813ebcdcd9558f0906a1870db8302ff1e0
python/tvm/script/tir/scope_handler.py
python
ForScopeHandler.create_loop_info
( self, begin: PrimExpr, end: PrimExpr, kind: ForKind, thread_binding: Optional[str] = None, annotations: Optional[Mapping[str, Object]] = None, )
Helper function for creating For in TVM Script parser. Parameters ---------- begin : PrimExpr The beginning value. end : PrimExpr The endding value. kind : ForKind The type of the for. thread_binding: Optional[str] The thread this loop binds to. annotations : Optional[Mapping[str, Object]] Additional annotation hints. span : Optional[Span] The location of this for in the source code. Returns ------- for : For The constructed For.
Helper function for creating For in TVM Script parser.
[ "Helper", "function", "for", "creating", "For", "in", "TVM", "Script", "parser", "." ]
def create_loop_info( self, begin: PrimExpr, end: PrimExpr, kind: ForKind, thread_binding: Optional[str] = None, annotations: Optional[Mapping[str, Object]] = None, ) -> None: """ Helper function for creating For in TVM Script parser. Parameters ---------- begin : PrimExpr The beginning value. end : PrimExpr The endding value. kind : ForKind The type of the for. thread_binding: Optional[str] The thread this loop binds to. annotations : Optional[Mapping[str, Object]] Additional annotation hints. span : Optional[Span] The location of this for in the source code. Returns ------- for : For The constructed For. """ assert self.context and self.node, "call 'exit_scope' before 'enter_scope'" extent = end if begin == 0 else self.context.analyzer.simplify(end - begin) self.annotations = annotations self.loop_info.append(LoopInfo(begin, extent, kind, thread_binding, self.annotations))
[ "def", "create_loop_info", "(", "self", ",", "begin", ":", "PrimExpr", ",", "end", ":", "PrimExpr", ",", "kind", ":", "ForKind", ",", "thread_binding", ":", "Optional", "[", "str", "]", "=", "None", ",", "annotations", ":", "Optional", "[", "Mapping", "[...
https://github.com/apache/tvm/blob/6eb4ed813ebcdcd9558f0906a1870db8302ff1e0/python/tvm/script/tir/scope_handler.py#L448-L487
OpenCobolIDE/OpenCobolIDE
c78d0d335378e5fe0a5e74f53c19b68b55e85388
open_cobol_ide/extlibs/pyqode/core/modes/caret_line_highlight.py
python
CaretLineHighlighterMode.background
(self)
Background color of the caret line. Default is to use a color slightly darker/lighter than the background color. You can override the automatic color by setting up this property
Background color of the caret line. Default is to use a color slightly darker/lighter than the background color. You can override the automatic color by setting up this property
[ "Background", "color", "of", "the", "caret", "line", ".", "Default", "is", "to", "use", "a", "color", "slightly", "darker", "/", "lighter", "than", "the", "background", "color", ".", "You", "can", "override", "the", "automatic", "color", "by", "setting", "...
def background(self): """ Background color of the caret line. Default is to use a color slightly darker/lighter than the background color. You can override the automatic color by setting up this property """ if self._color or not self.editor: return self._color else: return drift_color(self.editor.background, 110)
[ "def", "background", "(", "self", ")", ":", "if", "self", ".", "_color", "or", "not", "self", ".", "editor", ":", "return", "self", ".", "_color", "else", ":", "return", "drift_color", "(", "self", ".", "editor", ".", "background", ",", "110", ")" ]
https://github.com/OpenCobolIDE/OpenCobolIDE/blob/c78d0d335378e5fe0a5e74f53c19b68b55e85388/open_cobol_ide/extlibs/pyqode/core/modes/caret_line_highlight.py#L14-L23
Komodo/KomodoEdit
61edab75dce2bdb03943b387b0608ea36f548e8e
src/udl/luddite.py
python
Shell.do_lexhtml
(self, subcmd, opts, lang, path)
${cmd_name}: lex the given file to styled HTML (for debugging) ${cmd_usage} ${cmd_option_list}
${cmd_name}: lex the given file to styled HTML (for debugging)
[ "$", "{", "cmd_name", "}", ":", "lex", "the", "given", "file", "to", "styled", "HTML", "(", "for", "debugging", ")" ]
def do_lexhtml(self, subcmd, opts, lang, path): """${cmd_name}: lex the given file to styled HTML (for debugging) ${cmd_usage} ${cmd_option_list} """ from ludditelib.debug import lex_to_html content = open(path, 'r').read() html = lex_to_html(content, lang) if opts.output == '-': output_path = None output_file = sys.stdout else: if opts.output: output_path = opts.output else: output_path = path+".html" if exists(output_path): os.remove(output_path) output_file = open(output_path, 'w') if output_file: output_file.write(html) if output_path: output_file.close() if opts.browse: if not output_path: raise LudditeError("cannot open in browser if stdout used " "for output") import webbrowser url = _url_from_local_path(output_path) webbrowser.open_new(url)
[ "def", "do_lexhtml", "(", "self", ",", "subcmd", ",", "opts", ",", "lang", ",", "path", ")", ":", "from", "ludditelib", ".", "debug", "import", "lex_to_html", "content", "=", "open", "(", "path", ",", "'r'", ")", ".", "read", "(", ")", "html", "=", ...
https://github.com/Komodo/KomodoEdit/blob/61edab75dce2bdb03943b387b0608ea36f548e8e/src/udl/luddite.py#L256-L288
SteveDoyle2/pyNastran
eda651ac2d4883d95a34951f8a002ff94f642a1a
pyNastran/bdf/cards/aero/aero.py
python
CAERO2._update_field_helper
(self, n, value)
Updates complicated parameters on the CAERO2 card Parameters ---------- n : int The field number to update value : int, float, None The value for the appropriate field
Updates complicated parameters on the CAERO2 card
[ "Updates", "complicated", "parameters", "on", "the", "CAERO2", "card" ]
def _update_field_helper(self, n, value): """ Updates complicated parameters on the CAERO2 card Parameters ---------- n : int The field number to update value : int, float, None The value for the appropriate field """ if n == 9: self.p1[0] = value elif n == 10: self.p1[1] = value elif n == 11: self.p1[2] = value else: raise KeyError('Field %r=%r is an invalid CAERO2 entry.' % (n, value))
[ "def", "_update_field_helper", "(", "self", ",", "n", ",", "value", ")", ":", "if", "n", "==", "9", ":", "self", ".", "p1", "[", "0", "]", "=", "value", "elif", "n", "==", "10", ":", "self", ".", "p1", "[", "1", "]", "=", "value", "elif", "n"...
https://github.com/SteveDoyle2/pyNastran/blob/eda651ac2d4883d95a34951f8a002ff94f642a1a/pyNastran/bdf/cards/aero/aero.py#L2162-L2181
arthurdejong/python-stdnum
02dec52602ae0709b940b781fc1fcebfde7340b7
update/isbn.py
python
ranges
(group)
Provide the ranges for the group.
Provide the ranges for the group.
[ "Provide", "the", "ranges", "for", "the", "group", "." ]
def ranges(group): """Provide the ranges for the group.""" for rule in group.findall('./Rules/Rule'): length = int(rule.find('./Length').text.strip()) if length: yield '-'.join( x[:length] for x in rule.find('./Range').text.strip().split('-'))
[ "def", "ranges", "(", "group", ")", ":", "for", "rule", "in", "group", ".", "findall", "(", "'./Rules/Rule'", ")", ":", "length", "=", "int", "(", "rule", ".", "find", "(", "'./Length'", ")", ".", "text", ".", "strip", "(", ")", ")", "if", "length"...
https://github.com/arthurdejong/python-stdnum/blob/02dec52602ae0709b940b781fc1fcebfde7340b7/update/isbn.py#L36-L43
Tencent/QT4A
cc99ce12bd10f864c95b7bf0675fd1b757bce4bb
qt4a/andrcontrols.py
python
ListItem.__getattr__
(self, attr)
return getattr(self._view, attr)
委托self._view实现
委托self._view实现
[ "委托self", ".", "_view实现" ]
def __getattr__(self, attr): '''委托self._view实现 ''' return getattr(self._view, attr)
[ "def", "__getattr__", "(", "self", ",", "attr", ")", ":", "return", "getattr", "(", "self", ".", "_view", ",", "attr", ")" ]
https://github.com/Tencent/QT4A/blob/cc99ce12bd10f864c95b7bf0675fd1b757bce4bb/qt4a/andrcontrols.py#L1646-L1649
nerdvegas/rez
d392c65bf63b4bca8106f938cec49144ba54e770
src/rez/utils/memcached.py
python
Client.flush
(self, hard=False)
Drop existing entries from the cache. Args: hard (bool): If True, all current entries are flushed from the server(s), which affects all users. If False, only the local process is affected.
Drop existing entries from the cache.
[ "Drop", "existing", "entries", "from", "the", "cache", "." ]
def flush(self, hard=False): """Drop existing entries from the cache. Args: hard (bool): If True, all current entries are flushed from the server(s), which affects all users. If False, only the local process is affected. """ if not self.servers: return if hard: self.client.flush_all() self.reset_stats() else: from uuid import uuid4 tag = uuid4().hex if self.debug: tag = "flushed" + tag self.current = tag
[ "def", "flush", "(", "self", ",", "hard", "=", "False", ")", ":", "if", "not", "self", ".", "servers", ":", "return", "if", "hard", ":", "self", ".", "client", ".", "flush_all", "(", ")", "self", ".", "reset_stats", "(", ")", "else", ":", "from", ...
https://github.com/nerdvegas/rez/blob/d392c65bf63b4bca8106f938cec49144ba54e770/src/rez/utils/memcached.py#L147-L165
out0fmemory/GoAgent-Always-Available
c4254984fea633ce3d1893fe5901debd9f22c2a9
server/lib/six/__init__.py
python
_SixMetaPathImporter.get_code
(self, fullname)
return None
Return None Required, if is_package is implemented
Return None
[ "Return", "None" ]
def get_code(self, fullname): """Return None Required, if is_package is implemented""" self.__get_module(fullname) # eventually raises ImportError return None
[ "def", "get_code", "(", "self", ",", "fullname", ")", ":", "self", ".", "__get_module", "(", "fullname", ")", "# eventually raises ImportError", "return", "None" ]
https://github.com/out0fmemory/GoAgent-Always-Available/blob/c4254984fea633ce3d1893fe5901debd9f22c2a9/server/lib/six/__init__.py#L214-L219
Jenyay/outwiker
50530cf7b3f71480bb075b2829bc0669773b835b
plugins/updatenotifier/updatenotifier/updatecontroller.py
python
UpdateController.__init__
(self, application, plugin)
application - instance of the ApplicationParams class. pluginPath - path to UpdateNotifier plugin.
application - instance of the ApplicationParams class. pluginPath - path to UpdateNotifier plugin.
[ "application", "-", "instance", "of", "the", "ApplicationParams", "class", ".", "pluginPath", "-", "path", "to", "UpdateNotifier", "plugin", "." ]
def __init__(self, application, plugin): ''' application - instance of the ApplicationParams class. pluginPath - path to UpdateNotifier plugin. ''' global _ _ = get_() join = os.path.join self._application = application self._plugin = plugin self._config = UpdatesConfig(self._application.config) self._dataPath = join(plugin.pluginPath, u'data') self._updateTemplatePath = join(self._dataPath, u'update.html') self.__deletedPlugins = {} self.vl = VersionList() # to load app info from the internet. # Special string id for stable and unstable OutWiker URL self._OUTWIKER_STABLE_KEY = u'OUTWIKER_STABLE' self._OUTWIKER_UNSTABLE_KEY = u'OUTWIKER_UNSTABLE' # Dictionary. Key - plugin name or special string id, # Value - URL to XML file with versions information. self._updateUrls = {} self._updateUrls[self._OUTWIKER_STABLE_KEY] = u'https://jenyay.net/uploads/Soft/Outwiker/versions.xml' self._updateUrls[self._OUTWIKER_UNSTABLE_KEY] = u'https://jenyay.net/uploads/Outwiker/Unstable/versions.xml' # update dialog instance self._dialog = None # The thread to check updates in the silence mode (after program start) self._silenceThread = None if self._application.mainWindow is not None: self._application.mainWindow.Bind( EVT_UPDATE_VERSIONS, handler=self._onVersionUpdate)
[ "def", "__init__", "(", "self", ",", "application", ",", "plugin", ")", ":", "global", "_", "_", "=", "get_", "(", ")", "join", "=", "os", ".", "path", ".", "join", "self", ".", "_application", "=", "application", "self", ".", "_plugin", "=", "plugin...
https://github.com/Jenyay/outwiker/blob/50530cf7b3f71480bb075b2829bc0669773b835b/plugins/updatenotifier/updatenotifier/updatecontroller.py#L44-L79
NVlabs/Deep_Object_Pose
c50e5fcd3741802484bf59c0f7bcf507b918e417
scripts/train2/inference/cuboid.py
python
Cuboid3d.get_vertex
(self, vertex_type)
return self._vertices[vertex_type]
Returns the location of a vertex. Args: vertex_type: enum of type CuboidVertexType Returns: Numpy array(3) - Location of the vertex type in the cuboid
Returns the location of a vertex.
[ "Returns", "the", "location", "of", "a", "vertex", "." ]
def get_vertex(self, vertex_type): """Returns the location of a vertex. Args: vertex_type: enum of type CuboidVertexType Returns: Numpy array(3) - Location of the vertex type in the cuboid """ return self._vertices[vertex_type]
[ "def", "get_vertex", "(", "self", ",", "vertex_type", ")", ":", "return", "self", ".", "_vertices", "[", "vertex_type", "]" ]
https://github.com/NVlabs/Deep_Object_Pose/blob/c50e5fcd3741802484bf59c0f7bcf507b918e417/scripts/train2/inference/cuboid.py#L63-L72
minio/minio-py
b3ba3bf99fe6b9ff2b28855550d6ab5345c134e3
minio/credentials/providers.py
python
WebIdentityClientGrantsProvider.retrieve
(self)
return self._credentials
Retrieve credentials.
Retrieve credentials.
[ "Retrieve", "credentials", "." ]
def retrieve(self): """Retrieve credentials.""" if self._credentials and not self._credentials.is_expired(): return self._credentials jwt = self._jwt_provider_func() query_params = {"Version": "2011-06-15"} duration_seconds = self._get_duration_seconds( int(jwt.get("expires_in", "0")), ) if duration_seconds: query_params["DurationSeconds"] = str(duration_seconds) if self._policy: query_params["Policy"] = self._policy if self._is_web_identity(): query_params["Action"] = "AssumeRoleWithWebIdentity" query_params["WebIdentityToken"] = jwt.get("access_token") if self._role_arn: query_params["RoleArn"] = self._role_arn query_params["RoleSessionName"] = ( self._role_session_name if self._role_session_name else str(time.time()).replace(".", "") ) else: query_params["Action"] = "AssumeRoleWithClientGrants" query_params["Token"] = jwt.get("access_token") url = self._sts_endpoint + "?" + urlencode(query_params) res = _urlopen(self._http_client, "POST", url) self._credentials = _parse_credentials( res.data.decode(), ( "AssumeRoleWithWebIdentityResult" if self._is_web_identity() else "AssumeRoleWithClientGrantsResult" ), ) return self._credentials
[ "def", "retrieve", "(", "self", ")", ":", "if", "self", ".", "_credentials", "and", "not", "self", ".", "_credentials", ".", "is_expired", "(", ")", ":", "return", "self", ".", "_credentials", "jwt", "=", "self", ".", "_jwt_provider_func", "(", ")", "que...
https://github.com/minio/minio-py/blob/b3ba3bf99fe6b9ff2b28855550d6ab5345c134e3/minio/credentials/providers.py#L527-L570
XX-net/XX-Net
a9898cfcf0084195fb7e69b6bc834e59aecdf14f
python3.8.2/Lib/mailbox.py
python
Babyl.remove
(self, key)
Remove the keyed message; raise KeyError if it doesn't exist.
Remove the keyed message; raise KeyError if it doesn't exist.
[ "Remove", "the", "keyed", "message", ";", "raise", "KeyError", "if", "it", "doesn", "t", "exist", "." ]
def remove(self, key): """Remove the keyed message; raise KeyError if it doesn't exist.""" _singlefileMailbox.remove(self, key) if key in self._labels: del self._labels[key]
[ "def", "remove", "(", "self", ",", "key", ")", ":", "_singlefileMailbox", ".", "remove", "(", "self", ",", "key", ")", "if", "key", "in", "self", ".", "_labels", ":", "del", "self", ".", "_labels", "[", "key", "]" ]
https://github.com/XX-net/XX-Net/blob/a9898cfcf0084195fb7e69b6bc834e59aecdf14f/python3.8.2/Lib/mailbox.py#L1255-L1259
pympler/pympler
8019a883eec547d91ecda6ba12669d4f4504c625
pympler/asizeof.py
python
_len_int
(obj)
return n
Length of multi-precision int (aka long) in digits.
Length of multi-precision int (aka long) in digits.
[ "Length", "of", "multi", "-", "precision", "int", "(", "aka", "long", ")", "in", "digits", "." ]
def _len_int(obj): '''Length of multi-precision int (aka long) in digits. ''' if obj: n, i = 1, abs(obj) if i > _digitmax: # no log(x[, base]) in Python 2.2 n += int(log(i) * _digitlog) else: # zero n = 0 return n
[ "def", "_len_int", "(", "obj", ")", ":", "if", "obj", ":", "n", ",", "i", "=", "1", ",", "abs", "(", "obj", ")", "if", "i", ">", "_digitmax", ":", "# no log(x[, base]) in Python 2.2", "n", "+=", "int", "(", "log", "(", "i", ")", "*", "_digitlog", ...
https://github.com/pympler/pympler/blob/8019a883eec547d91ecda6ba12669d4f4504c625/pympler/asizeof.py#L880-L890
cagbal/ros_people_object_detection_tensorflow
982ffd4a54b8059638f5cd4aa167299c7fc9e61f
src/object_detection/core/box_predictor.py
python
RfcnBoxPredictor.num_classes
(self)
return self._num_classes
[]
def num_classes(self): return self._num_classes
[ "def", "num_classes", "(", "self", ")", ":", "return", "self", ".", "_num_classes" ]
https://github.com/cagbal/ros_people_object_detection_tensorflow/blob/982ffd4a54b8059638f5cd4aa167299c7fc9e61f/src/object_detection/core/box_predictor.py#L179-L180
wmayner/pyphi
299fccd4a8152dcfa4bb989d7d739e245343b0a5
pyphi/models/mechanism.py
python
Concept.to_json
(self)
return {attr: getattr(self, attr) for attr in _concept_attributes + ["time"]}
Return a JSON-serializable representation.
Return a JSON-serializable representation.
[ "Return", "a", "JSON", "-", "serializable", "representation", "." ]
def to_json(self): """Return a JSON-serializable representation.""" return {attr: getattr(self, attr) for attr in _concept_attributes + ["time"]}
[ "def", "to_json", "(", "self", ")", ":", "return", "{", "attr", ":", "getattr", "(", "self", ",", "attr", ")", "for", "attr", "in", "_concept_attributes", "+", "[", "\"time\"", "]", "}" ]
https://github.com/wmayner/pyphi/blob/299fccd4a8152dcfa4bb989d7d739e245343b0a5/pyphi/models/mechanism.py#L505-L507
wikimedia/pywikibot
81a01ffaec7271bf5b4b170f85a80388420a4e78
pywikibot/site/_apisite.py
python
APISite.is_uploaddisabled
(self)
Return True if upload is disabled on site. When the version is at least 1.27wmf9, uses general siteinfo. If not called directly, it is cached by the first attempted upload action.
Return True if upload is disabled on site.
[ "Return", "True", "if", "upload", "is", "disabled", "on", "site", "." ]
def is_uploaddisabled(self): """Return True if upload is disabled on site. When the version is at least 1.27wmf9, uses general siteinfo. If not called directly, it is cached by the first attempted upload action. """ if self.mw_version >= '1.27wmf9': return not self._siteinfo.get('general')['uploadsenabled'] if hasattr(self, '_uploaddisabled'): return self._uploaddisabled # attempt a fake upload; on enabled sites will fail for: # missingparam: One of the parameters # filekey, file, url, statuskey is required # TODO: is there another way? try: req = self._request(throttle=False, parameters={'action': 'upload', 'token': self.tokens['edit']}) req.submit() except APIError as error: if error.code == 'uploaddisabled': self._uploaddisabled = True elif error.code == 'missingparam': # If the upload module is enabled, the above dummy request # does not have sufficient parameters and will cause a # 'missingparam' error. self._uploaddisabled = False else: # Unexpected error raise return self._uploaddisabled raise RuntimeError( 'Unexpected success of upload action without parameters.')
[ "def", "is_uploaddisabled", "(", "self", ")", ":", "if", "self", ".", "mw_version", ">=", "'1.27wmf9'", ":", "return", "not", "self", ".", "_siteinfo", ".", "get", "(", "'general'", ")", "[", "'uploadsenabled'", "]", "if", "hasattr", "(", "self", ",", "'...
https://github.com/wikimedia/pywikibot/blob/81a01ffaec7271bf5b4b170f85a80388420a4e78/pywikibot/site/_apisite.py#L2470-L2506
SekoiaLab/Fastir_Collector
7586e1fb30b97714a40bebdcc845027e1a5ec257
registry/reg.py
python
_Reg.__get_user_assist
(self, is_win7_or_further)
return to_csv_list
Extracts information from UserAssist registry key which contains information about executed programs The count offset is for Windows versions before 7, where it would start at 6
Extracts information from UserAssist registry key which contains information about executed programs The count offset is for Windows versions before 7, where it would start at 6
[ "Extracts", "information", "from", "UserAssist", "registry", "key", "which", "contains", "information", "about", "executed", "programs", "The", "count", "offset", "is", "for", "Windows", "versions", "before", "7", "where", "it", "would", "start", "at", "6" ]
def __get_user_assist(self, is_win7_or_further): """ Extracts information from UserAssist registry key which contains information about executed programs The count offset is for Windows versions before 7, where it would start at 6 """ self.logger.info("Extracting user assist") path = r"Software\Microsoft\Windows\CurrentVersion\Explorer\\UserAssist" count = "\Count" # logged on users users = registry_obj.RegistryKey(registry_obj.HKEY_USERS) hive_list = [] for i in xrange(users.get_number_of_sub_keys()): user = users.get_sub_key(i) user_assist_key = user.get_sub_key_by_path(path) if user_assist_key: for j in xrange(user_assist_key.get_number_of_sub_keys()): # getting Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\*\Count path_no_sid = "\\".join(user_assist_key.get_sub_key(j).get_path().split("\\")[1:]) hive_list += self._get_list_from_registry_key(registry_obj.HKEY_USERS, path_no_sid + count) if is_win7_or_further: to_csv_list = [("COMPUTER_NAME", "TYPE", "LAST_WRITE_TIME", "HIVE", "KEY_PATH", "ATTR_NAME", "REG_TYPE", "ATTR_TYPE", "ATTR_DATA", "DATA_SESSION", "DATA_COUNT", "DATA_FOCUS", "DATA_LAST_EXEC")] else: to_csv_list = [("COMPUTER_NAME", "TYPE", "LAST_WRITE_TIME", "HIVE", "KEY_PATH", "ATTR_NAME", "REG_TYPE", "ATTR_TYPE", "ATTR_DATA", "DATA_SESSION", "DATA_COUNT", "DATA_LAST_EXEC")] for item in hive_list: if item[KEY_VALUE_STR] == "VALUE": str_value_name = codecs.decode(item[VALUE_NAME], "rot_13") str_value_datatmp = item[VALUE_DATA] # some data are less than 16 bytes for some reason... if len(str_value_datatmp) < 16: to_csv_list.append((self.computer_name, "userassist", item[VALUE_LAST_WRITE_TIME], "HKEY_USERS", item[VALUE_PATH], item[VALUE_NAME], item[KEY_VALUE_STR], registry_obj.get_str_type(item[VALUE_TYPE]), str_value_name)) else: if is_win7_or_further: data = csv_user_assist_value_decode_win7_and_after(str_value_datatmp) else: data = csv_user_assist_value_decode_before_win7(str_value_datatmp) to_csv_list.append((self.computer_name, "user_assist", item[VALUE_LAST_WRITE_TIME], "HKEY_USERS", item[VALUE_PATH], item[VALUE_NAME], item[KEY_VALUE_STR], registry_obj.get_str_type(item[VALUE_TYPE]), str_value_name) + tuple(data)) return to_csv_list
[ "def", "__get_user_assist", "(", "self", ",", "is_win7_or_further", ")", ":", "self", ".", "logger", ".", "info", "(", "\"Extracting user assist\"", ")", "path", "=", "r\"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\\\UserAssist\"", "count", "=", "\"\\Count\"", ...
https://github.com/SekoiaLab/Fastir_Collector/blob/7586e1fb30b97714a40bebdcc845027e1a5ec257/registry/reg.py#L432-L486
zhl2008/awd-platform
0416b31abea29743387b10b3914581fbe8e7da5e
web_flaskbb/lib/python2.7/site-packages/sqlalchemy/sql/elements.py
python
Grouping.__getattr__
(self, attr)
return getattr(self.element, attr)
[]
def __getattr__(self, attr): return getattr(self.element, attr)
[ "def", "__getattr__", "(", "self", ",", "attr", ")", ":", "return", "getattr", "(", "self", ".", "element", ",", "attr", ")" ]
https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/lib/python2.7/site-packages/sqlalchemy/sql/elements.py#L3087-L3088
hunkim/DeepLearningStars
8672d23c23fc9ebe6113f1808a09aa1ae5b9cd99
list2md.multiprocess.py
python
dict2md
(dict_)
return "| [{name}]({url}) | {stars} | {description} |".format(**dict_)
Convert a dictionary to a markdown format
Convert a dictionary to a markdown format
[ "Convert", "a", "dictionary", "to", "a", "markdown", "format" ]
def dict2md(dict_): """Convert a dictionary to a markdown format""" return "| [{name}]({url}) | {stars} | {description} |".format(**dict_)
[ "def", "dict2md", "(", "dict_", ")", ":", "return", "\"| [{name}]({url}) | {stars} | {description} |\"", ".", "format", "(", "*", "*", "dict_", ")" ]
https://github.com/hunkim/DeepLearningStars/blob/8672d23c23fc9ebe6113f1808a09aa1ae5b9cd99/list2md.multiprocess.py#L71-L73
shiba24/3d-unet
57e0ca31b371a833d7e60f14ca857844dc8bcc02
tensorflow/model.py
python
error_rate
(predictions, labels)
return 100.0 - ( 100.0 * np.sum(np.argmax(predictions, 3) == np.argmax(labels, 3)) / (predictions.shape[0]*predictions.shape[1]*predictions.shape[2]))
Return the error rate based on dense predictions and 1-hot labels.
Return the error rate based on dense predictions and 1-hot labels.
[ "Return", "the", "error", "rate", "based", "on", "dense", "predictions", "and", "1", "-", "hot", "labels", "." ]
def error_rate(predictions, labels): """ Return the error rate based on dense predictions and 1-hot labels. """ return 100.0 - ( 100.0 * np.sum(np.argmax(predictions, 3) == np.argmax(labels, 3)) / (predictions.shape[0]*predictions.shape[1]*predictions.shape[2]))
[ "def", "error_rate", "(", "predictions", ",", "labels", ")", ":", "return", "100.0", "-", "(", "100.0", "*", "np", ".", "sum", "(", "np", ".", "argmax", "(", "predictions", ",", "3", ")", "==", "np", ".", "argmax", "(", "labels", ",", "3", ")", "...
https://github.com/shiba24/3d-unet/blob/57e0ca31b371a833d7e60f14ca857844dc8bcc02/tensorflow/model.py#L457-L465
brython-dev/brython
9cba5fb7f43a9b52fff13e89b403e02a1dfaa5f3
www/src/Lib/shutil.py
python
_copyfileobj_readinto
(fsrc, fdst, length=COPY_BUFSIZE)
readinto()/memoryview() based variant of copyfileobj(). *fsrc* must support readinto() method and both files must be open in binary mode.
readinto()/memoryview() based variant of copyfileobj(). *fsrc* must support readinto() method and both files must be open in binary mode.
[ "readinto", "()", "/", "memoryview", "()", "based", "variant", "of", "copyfileobj", "()", ".", "*", "fsrc", "*", "must", "support", "readinto", "()", "method", "and", "both", "files", "must", "be", "open", "in", "binary", "mode", "." ]
def _copyfileobj_readinto(fsrc, fdst, length=COPY_BUFSIZE): """readinto()/memoryview() based variant of copyfileobj(). *fsrc* must support readinto() method and both files must be open in binary mode. """ # Localize variable access to minimize overhead. fsrc_readinto = fsrc.readinto fdst_write = fdst.write with memoryview(bytearray(length)) as mv: while True: n = fsrc_readinto(mv) if not n: break elif n < length: with mv[:n] as smv: fdst.write(smv) else: fdst_write(mv)
[ "def", "_copyfileobj_readinto", "(", "fsrc", ",", "fdst", ",", "length", "=", "COPY_BUFSIZE", ")", ":", "# Localize variable access to minimize overhead.", "fsrc_readinto", "=", "fsrc", ".", "readinto", "fdst_write", "=", "fdst", ".", "write", "with", "memoryview", ...
https://github.com/brython-dev/brython/blob/9cba5fb7f43a9b52fff13e89b403e02a1dfaa5f3/www/src/Lib/shutil.py#L168-L185
CGATOxford/cgat
326aad4694bdfae8ddc194171bb5d73911243947
obsolete/pipeline_proj007.py
python
annotateLiverTestesMergedTranscriptTSSDistance
( infile, outfile )
Compute distance from CAPseq intervals to nearest transcript TSS
Compute distance from CAPseq intervals to nearest transcript TSS
[ "Compute", "distance", "from", "CAPseq", "intervals", "to", "nearest", "transcript", "TSS" ]
def annotateLiverTestesMergedTranscriptTSSDistance( infile, outfile ): '''Compute distance from CAPseq intervals to nearest transcript TSS''' to_cluster = True annotation_file = os.path.join( PARAMS["geneset_dir"],PARAMS["geneset_transcript_tss"] ) statement = """cat < %(infile)s | python %(scriptsdir)s/bed2gff.py --as-gtf | python %(scriptsdir)s/gtf2table.py --counter=distance-tss --log=%(outfile)s.log --filename-gff=%(annotation_file)s --filename-format="bed" > %(outfile)s""" P.run()
[ "def", "annotateLiverTestesMergedTranscriptTSSDistance", "(", "infile", ",", "outfile", ")", ":", "to_cluster", "=", "True", "annotation_file", "=", "os", ".", "path", ".", "join", "(", "PARAMS", "[", "\"geneset_dir\"", "]", ",", "PARAMS", "[", "\"geneset_transcri...
https://github.com/CGATOxford/cgat/blob/326aad4694bdfae8ddc194171bb5d73911243947/obsolete/pipeline_proj007.py#L3317-L3329
akfamily/akshare
590e50eece9ec067da3538c7059fd660b71f1339
akshare/fortune/fortune_xincaifu_500.py
python
xincaifu_rank
(year: str = "2020")
return temp_df
新财富 500 人富豪榜 http://www.xcf.cn/zhuanti/ztzz/hdzt1/500frb/index.html :param year: 具体排名年份, 数据从 2003-至今 :type year: str :return: 排行榜 :rtype: pandas.DataFrame
新财富 500 人富豪榜 http://www.xcf.cn/zhuanti/ztzz/hdzt1/500frb/index.html :param year: 具体排名年份, 数据从 2003-至今 :type year: str :return: 排行榜 :rtype: pandas.DataFrame
[ "新财富", "500", "人富豪榜", "http", ":", "//", "www", ".", "xcf", ".", "cn", "/", "zhuanti", "/", "ztzz", "/", "hdzt1", "/", "500frb", "/", "index", ".", "html", ":", "param", "year", ":", "具体排名年份", "数据从", "2003", "-", "至今", ":", "type", "year", ":", ...
def xincaifu_rank(year: str = "2020") -> pd.DataFrame: """ 新财富 500 人富豪榜 http://www.xcf.cn/zhuanti/ztzz/hdzt1/500frb/index.html :param year: 具体排名年份, 数据从 2003-至今 :type year: str :return: 排行榜 :rtype: pandas.DataFrame """ url = "http://service.ikuyu.cn/XinCaiFu2/pcremoting/bdListAction.do" params = { "method": "getPage", "callback": "jsonpCallback", "sortBy": "", "order": "", "type": "4", "keyword": "", "pageSize": "1000", "year": year, "pageNo": "1", "from": "jsonp", "_": "1604722171732", } r = requests.get(url, params=params) data_text = r.text data_json = json.loads(data_text[data_text.find("{") : -1]) temp_df = pd.DataFrame(data_json["data"]["rows"]) temp_df.columns = [ "_", "财富", "性别", "排名", "年龄", "主要公司", "姓名", "公司总部", "年份", "_", "相关行业", ] temp_df = temp_df[ [ "排名", "财富", "姓名", "主要公司", "相关行业", "公司总部", "性别", "年龄", "年份", ] ] return temp_df
[ "def", "xincaifu_rank", "(", "year", ":", "str", "=", "\"2020\"", ")", "->", "pd", ".", "DataFrame", ":", "url", "=", "\"http://service.ikuyu.cn/XinCaiFu2/pcremoting/bdListAction.do\"", "params", "=", "{", "\"method\"", ":", "\"getPage\"", ",", "\"callback\"", ":", ...
https://github.com/akfamily/akshare/blob/590e50eece9ec067da3538c7059fd660b71f1339/akshare/fortune/fortune_xincaifu_500.py#L14-L67
seppius-xbmc-repo/ru
d0879d56ec8243b2c7af44fda5cf3d1ff77fd2e2
plugin.video.stepashka.com/resources/lib/BeautifulSoup.py
python
Tag.get
(self, key, default=None)
return self._getAttrMap().get(key, default)
Returns the value of the 'key' attribute for the tag, or the value given for 'default' if it doesn't have that attribute.
Returns the value of the 'key' attribute for the tag, or the value given for 'default' if it doesn't have that attribute.
[ "Returns", "the", "value", "of", "the", "key", "attribute", "for", "the", "tag", "or", "the", "value", "given", "for", "default", "if", "it", "doesn", "t", "have", "that", "attribute", "." ]
def get(self, key, default=None): """Returns the value of the 'key' attribute for the tag, or the value given for 'default' if it doesn't have that attribute.""" return self._getAttrMap().get(key, default)
[ "def", "get", "(", "self", ",", "key", ",", "default", "=", "None", ")", ":", "return", "self", ".", "_getAttrMap", "(", ")", ".", "get", "(", "key", ",", "default", ")" ]
https://github.com/seppius-xbmc-repo/ru/blob/d0879d56ec8243b2c7af44fda5cf3d1ff77fd2e2/plugin.video.stepashka.com/resources/lib/BeautifulSoup.py#L590-L594
openshift/openshift-tools
1188778e728a6e4781acf728123e5b356380fe6f
openshift/installer/vendored/openshift-ansible-3.10.0-0.29.0/roles/lib_vendored_deps/library/oc_obj.py
python
Yedit.yaml_dict
(self)
return self.__yaml_dict
getter method for yaml_dict
getter method for yaml_dict
[ "getter", "method", "for", "yaml_dict" ]
def yaml_dict(self): ''' getter method for yaml_dict ''' return self.__yaml_dict
[ "def", "yaml_dict", "(", "self", ")", ":", "return", "self", ".", "__yaml_dict" ]
https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/openshift/installer/vendored/openshift-ansible-3.10.0-0.29.0/roles/lib_vendored_deps/library/oc_obj.py#L207-L209
conansherry/detectron2
72c935d9aad8935406b1038af408aa06077d950a
detectron2/modeling/backbone/resnet.py
python
BottleneckBlock.__init__
( self, in_channels, out_channels, *, bottleneck_channels, stride=1, num_groups=1, norm="BN", stride_in_1x1=False, dilation=1, )
Args: norm (str or callable): a callable that takes the number of channels and return a `nn.Module`, or a pre-defined string (one of {"FrozenBN", "BN", "GN"}). stride_in_1x1 (bool): when stride==2, whether to put stride in the first 1x1 convolution or the bottleneck 3x3 convolution.
Args: norm (str or callable): a callable that takes the number of channels and return a `nn.Module`, or a pre-defined string (one of {"FrozenBN", "BN", "GN"}). stride_in_1x1 (bool): when stride==2, whether to put stride in the first 1x1 convolution or the bottleneck 3x3 convolution.
[ "Args", ":", "norm", "(", "str", "or", "callable", ")", ":", "a", "callable", "that", "takes", "the", "number", "of", "channels", "and", "return", "a", "nn", ".", "Module", "or", "a", "pre", "-", "defined", "string", "(", "one", "of", "{", "FrozenBN"...
def __init__( self, in_channels, out_channels, *, bottleneck_channels, stride=1, num_groups=1, norm="BN", stride_in_1x1=False, dilation=1, ): """ Args: norm (str or callable): a callable that takes the number of channels and return a `nn.Module`, or a pre-defined string (one of {"FrozenBN", "BN", "GN"}). stride_in_1x1 (bool): when stride==2, whether to put stride in the first 1x1 convolution or the bottleneck 3x3 convolution. """ super().__init__(in_channels, out_channels, stride) if in_channels != out_channels: self.shortcut = Conv2d( in_channels, out_channels, kernel_size=1, stride=stride, bias=False, norm=get_norm(norm, out_channels), ) else: self.shortcut = None # The original MSRA ResNet models have stride in the first 1x1 conv # The subsequent fb.torch.resnet and Caffe2 ResNe[X]t implementations have # stride in the 3x3 conv stride_1x1, stride_3x3 = (stride, 1) if stride_in_1x1 else (1, stride) self.conv1 = Conv2d( in_channels, bottleneck_channels, kernel_size=1, stride=stride_1x1, bias=False, norm=get_norm(norm, bottleneck_channels), ) self.conv2 = Conv2d( bottleneck_channels, bottleneck_channels, kernel_size=3, stride=stride_3x3, padding=1 * dilation, bias=False, groups=num_groups, dilation=dilation, norm=get_norm(norm, bottleneck_channels), ) self.conv3 = Conv2d( bottleneck_channels, out_channels, kernel_size=1, bias=False, norm=get_norm(norm, out_channels), ) for layer in [self.conv1, self.conv2, self.conv3, self.shortcut]: if layer is not None: # shortcut can be None weight_init.c2_msra_fill(layer)
[ "def", "__init__", "(", "self", ",", "in_channels", ",", "out_channels", ",", "*", ",", "bottleneck_channels", ",", "stride", "=", "1", ",", "num_groups", "=", "1", ",", "norm", "=", "\"BN\"", ",", "stride_in_1x1", "=", "False", ",", "dilation", "=", "1"...
https://github.com/conansherry/detectron2/blob/72c935d9aad8935406b1038af408aa06077d950a/detectron2/modeling/backbone/resnet.py#L54-L124
tomplus/kubernetes_asyncio
f028cc793e3a2c519be6a52a49fb77ff0b014c9b
kubernetes_asyncio/client/api/storage_v1_api.py
python
StorageV1Api.read_volume_attachment
(self, name, **kwargs)
return self.read_volume_attachment_with_http_info(name, **kwargs)
read_volume_attachment # noqa: E501 read the specified VolumeAttachment # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.read_volume_attachment(name, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str name: name of the VolumeAttachment (required) :param str pretty: If 'true', then the output is pretty printed. :param bool exact: Should the export be exact. Exact export maintains cluster-specific fields like 'Namespace'. Deprecated. Planned for removal in 1.18. :param bool export: Should this value be exported. Export strips fields that a user can not specify. Deprecated. Planned for removal in 1.18. :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :return: V1VolumeAttachment If the method is called asynchronously, returns the request thread.
read_volume_attachment # noqa: E501
[ "read_volume_attachment", "#", "noqa", ":", "E501" ]
def read_volume_attachment(self, name, **kwargs): # noqa: E501 """read_volume_attachment # noqa: E501 read the specified VolumeAttachment # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.read_volume_attachment(name, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str name: name of the VolumeAttachment (required) :param str pretty: If 'true', then the output is pretty printed. :param bool exact: Should the export be exact. Exact export maintains cluster-specific fields like 'Namespace'. Deprecated. Planned for removal in 1.18. :param bool export: Should this value be exported. Export strips fields that a user can not specify. Deprecated. Planned for removal in 1.18. :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :return: V1VolumeAttachment If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True return self.read_volume_attachment_with_http_info(name, **kwargs)
[ "def", "read_volume_attachment", "(", "self", ",", "name", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "return", "self", ".", "read_volume_attachment_with_http_info", "(", "name", ",", "*", "*",...
https://github.com/tomplus/kubernetes_asyncio/blob/f028cc793e3a2c519be6a52a49fb77ff0b014c9b/kubernetes_asyncio/client/api/storage_v1_api.py#L3658-L3684
pantsbuild/pex
473c6ac732ed4bc338b4b20a9ec930d1d722c9b4
pex/vendor/_vendored/packaging/packaging/_structures.py
python
NegativeInfinityType.__lt__
(self, other)
return True
[]
def __lt__(self, other): # type: (object) -> bool return True
[ "def", "__lt__", "(", "self", ",", "other", ")", ":", "# type: (object) -> bool", "return", "True" ]
https://github.com/pantsbuild/pex/blob/473c6ac732ed4bc338b4b20a9ec930d1d722c9b4/pex/vendor/_vendored/packaging/packaging/_structures.py#L57-L59
CedricGuillemet/Imogen
ee417b42747ed5b46cb11b02ef0c3630000085b3
bin/Lib/urllib/parse.py
python
clear_cache
()
Clear the parse cache and the quoters cache.
Clear the parse cache and the quoters cache.
[ "Clear", "the", "parse", "cache", "and", "the", "quoters", "cache", "." ]
def clear_cache(): """Clear the parse cache and the quoters cache.""" _parse_cache.clear() _safe_quoters.clear()
[ "def", "clear_cache", "(", ")", ":", "_parse_cache", ".", "clear", "(", ")", "_safe_quoters", ".", "clear", "(", ")" ]
https://github.com/CedricGuillemet/Imogen/blob/ee417b42747ed5b46cb11b02ef0c3630000085b3/bin/Lib/urllib/parse.py#L83-L86
libtcod/python-tcod
e12c4172baa9efdfd74aff6ee9bab8454a835248
tcod/context.py
python
Context.__init__
(self, context_p: Any)
Creates a context from a cffi pointer.
Creates a context from a cffi pointer.
[ "Creates", "a", "context", "from", "a", "cffi", "pointer", "." ]
def __init__(self, context_p: Any): """Creates a context from a cffi pointer.""" self._context_p = context_p
[ "def", "__init__", "(", "self", ",", "context_p", ":", "Any", ")", ":", "self", ".", "_context_p", "=", "context_p" ]
https://github.com/libtcod/python-tcod/blob/e12c4172baa9efdfd74aff6ee9bab8454a835248/tcod/context.py#L166-L168
omz/PythonistaAppTemplate
f560f93f8876d82a21d108977f90583df08d55af
PythonistaAppTemplate/PythonistaKit.framework/pylib/site-packages/mechanize/_clientcookie.py
python
eff_request_host
(request)
return req_host, erhn
Return a tuple (request-host, effective request-host name).
Return a tuple (request-host, effective request-host name).
[ "Return", "a", "tuple", "(", "request", "-", "host", "effective", "request", "-", "host", "name", ")", "." ]
def eff_request_host(request): """Return a tuple (request-host, effective request-host name).""" erhn = req_host = request_host(request) if req_host.find(".") == -1 and not IPV4_RE.search(req_host): erhn = req_host + ".local" return req_host, erhn
[ "def", "eff_request_host", "(", "request", ")", ":", "erhn", "=", "req_host", "=", "request_host", "(", "request", ")", "if", "req_host", ".", "find", "(", "\".\"", ")", "==", "-", "1", "and", "not", "IPV4_RE", ".", "search", "(", "req_host", ")", ":",...
https://github.com/omz/PythonistaAppTemplate/blob/f560f93f8876d82a21d108977f90583df08d55af/PythonistaAppTemplate/PythonistaKit.framework/pylib/site-packages/mechanize/_clientcookie.py#L169-L174
SigmaHQ/sigma
6f7d28b52a6468b2430e8d7dfefb79dc01e2f1af
tools/sigma/backends/splunk.py
python
SplunkXMLBackend.finalize
(self)
return self.queries
[]
def finalize(self): self.queries += self.dash_suf return self.queries
[ "def", "finalize", "(", "self", ")", ":", "self", ".", "queries", "+=", "self", ".", "dash_suf", "return", "self", ".", "queries" ]
https://github.com/SigmaHQ/sigma/blob/6f7d28b52a6468b2430e8d7dfefb79dc01e2f1af/tools/sigma/backends/splunk.py#L171-L173
vmware/vcd-cli
648dced8c2f6b14493b69b7c3f67344a1b5dbcc5
vcd_cli/service_certificates.py
python
get_service_certificate
(ctx, gateway_name, id)
return certificate
Get the sdk's certificate object. It will restore sessions if expired. It will read the client.
Get the sdk's certificate object.
[ "Get", "the", "sdk", "s", "certificate", "object", "." ]
def get_service_certificate(ctx, gateway_name, id): """Get the sdk's certificate object. It will restore sessions if expired. It will read the client. """ restore_session(ctx, vdc_required=True) client = ctx.obj['client'] certificate = Certificate(client=client, gateway_name=gateway_name, resource_id=id) return certificate
[ "def", "get_service_certificate", "(", "ctx", ",", "gateway_name", ",", "id", ")", ":", "restore_session", "(", "ctx", ",", "vdc_required", "=", "True", ")", "client", "=", "ctx", ".", "obj", "[", "'client'", "]", "certificate", "=", "Certificate", "(", "c...
https://github.com/vmware/vcd-cli/blob/648dced8c2f6b14493b69b7c3f67344a1b5dbcc5/vcd_cli/service_certificates.py#L115-L125
encode/django-rest-framework
c5be86a6dbf3d21b00a296af5994fa075826bf0b
rest_framework/request.py
python
clone_request
(request, method)
return ret
Internal helper method to clone a request, replacing with a different HTTP method. Used for checking permissions against other methods.
Internal helper method to clone a request, replacing with a different HTTP method. Used for checking permissions against other methods.
[ "Internal", "helper", "method", "to", "clone", "a", "request", "replacing", "with", "a", "different", "HTTP", "method", ".", "Used", "for", "checking", "permissions", "against", "other", "methods", "." ]
def clone_request(request, method): """ Internal helper method to clone a request, replacing with a different HTTP method. Used for checking permissions against other methods. """ ret = Request(request=request._request, parsers=request.parsers, authenticators=request.authenticators, negotiator=request.negotiator, parser_context=request.parser_context) ret._data = request._data ret._files = request._files ret._full_data = request._full_data ret._content_type = request._content_type ret._stream = request._stream ret.method = method if hasattr(request, '_user'): ret._user = request._user if hasattr(request, '_auth'): ret._auth = request._auth if hasattr(request, '_authenticator'): ret._authenticator = request._authenticator if hasattr(request, 'accepted_renderer'): ret.accepted_renderer = request.accepted_renderer if hasattr(request, 'accepted_media_type'): ret.accepted_media_type = request.accepted_media_type if hasattr(request, 'version'): ret.version = request.version if hasattr(request, 'versioning_scheme'): ret.versioning_scheme = request.versioning_scheme return ret
[ "def", "clone_request", "(", "request", ",", "method", ")", ":", "ret", "=", "Request", "(", "request", "=", "request", ".", "_request", ",", "parsers", "=", "request", ".", "parsers", ",", "authenticators", "=", "request", ".", "authenticators", ",", "neg...
https://github.com/encode/django-rest-framework/blob/c5be86a6dbf3d21b00a296af5994fa075826bf0b/rest_framework/request.py#L93-L123
ansible/ansible
4676c08f188fb5dca98df61630c76dba1f0d2d77
lib/ansible/module_utils/compat/_selectors2.py
python
BaseSelector.get_key
(self, fileobj)
Return the key associated with a registered file object.
Return the key associated with a registered file object.
[ "Return", "the", "key", "associated", "with", "a", "registered", "file", "object", "." ]
def get_key(self, fileobj): """ Return the key associated with a registered file object. """ mapping = self.get_map() if mapping is None: raise RuntimeError("Selector is closed") try: return mapping[fileobj] except KeyError: raise KeyError("{0!r} is not registered".format(fileobj))
[ "def", "get_key", "(", "self", ",", "fileobj", ")", ":", "mapping", "=", "self", ".", "get_map", "(", ")", "if", "mapping", "is", "None", ":", "raise", "RuntimeError", "(", "\"Selector is closed\"", ")", "try", ":", "return", "mapping", "[", "fileobj", "...
https://github.com/ansible/ansible/blob/4676c08f188fb5dca98df61630c76dba1f0d2d77/lib/ansible/module_utils/compat/_selectors2.py#L282-L290
WikidPad/WikidPad
558109638807bc76b4672922686e416ab2d5f79c
WikidPad/lib/aui/framemanager.py
python
AuiPaneInfo.HasMaximizeButton
(self)
return self.HasFlag(self.buttonMaximize)
Returns ``True`` if the pane displays a button to maximize the pane.
Returns ``True`` if the pane displays a button to maximize the pane.
[ "Returns", "True", "if", "the", "pane", "displays", "a", "button", "to", "maximize", "the", "pane", "." ]
def HasMaximizeButton(self): """ Returns ``True`` if the pane displays a button to maximize the pane. """ return self.HasFlag(self.buttonMaximize)
[ "def", "HasMaximizeButton", "(", "self", ")", ":", "return", "self", ".", "HasFlag", "(", "self", ".", "buttonMaximize", ")" ]
https://github.com/WikidPad/WikidPad/blob/558109638807bc76b4672922686e416ab2d5f79c/WikidPad/lib/aui/framemanager.py#L804-L807
jparkhill/TensorMol
d52104dc7ee46eec8301d332a95d672270ac0bd1
TensorMol/TFNetworks/TFMolInstance.py
python
MolInstance_fc_sqdiff_BP_Update.train_step
(self, step)
return
Perform a single training step (complete processing of all input), using minibatches of size self.batch_size Args: step: the index of this step.
Perform a single training step (complete processing of all input), using minibatches of size self.batch_size
[ "Perform", "a", "single", "training", "step", "(", "complete", "processing", "of", "all", "input", ")", "using", "minibatches", "of", "size", "self", ".", "batch_size" ]
def train_step(self, step): """ Perform a single training step (complete processing of all input), using minibatches of size self.batch_size 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_output),dtype=np.float64) for ministep in range (0, int(Ncase_train/self.batch_size)): #print ("ministep: ", ministep, " Ncase_train:", Ncase_train, " self.batch_size", self.batch_size) batch_data = self.TData.GetTrainBatch(self.batch_size,self.batch_size_output) actual_mols = np.count_nonzero(batch_data[2]) #print ("index:", batch_data[1][0][:40], batch_data[1][1][:20]) dump_, dump_2, total_loss_value, loss_value, mol_output, atom_outputs = self.sess.run([self.check, self.train_op, self.total_loss, self.loss, self.output, self.atom_outputs], feed_dict=self.fill_feed_dict(batch_data)) #np.set_printoptions(threshold=np.nan) #print ("self.atom_outputs", atom_outputs[0][0][:40], "\n", atom_outputs[1][0][:20], atom_outputs[1].shape, "\n mol_outputs:", mol_output[:20], mol_output.shape) #print ("self.gradient:", gradient) train_loss = train_loss + loss_value duration = time.time() - start_time num_of_mols += actual_mols #print ("atom_outputs:", atom_outputs, " mol outputs:", mol_output) #print ("atom_outputs shape:", atom_outputs[0].shape, " mol outputs", mol_output.shape) #print("train diff:", (mol_output[0]-batch_data[2])[:actual_mols], np.sum(np.square((mol_output[0]-batch_data[2])[:actual_mols]))) #print ("train_loss:", train_loss, " Ncase_train:", Ncase_train, train_loss/num_of_mols) #print ("diff:", mol_output - batch_data[2], " shape:", mol_output.shape) 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/TFMolInstance.py#L1248-L1278
rembo10/headphones
b3199605be1ebc83a7a8feab6b1e99b64014187c
lib/cherrypy/process/wspbus.py
python
Bus.wait
(self, state, interval=0.1, channel=None)
Poll for the given state(s) at intervals; publish to channel.
Poll for the given state(s) at intervals; publish to channel.
[ "Poll", "for", "the", "given", "state", "(", "s", ")", "at", "intervals", ";", "publish", "to", "channel", "." ]
def wait(self, state, interval=0.1, channel=None): """Poll for the given state(s) at intervals; publish to channel.""" if isinstance(state, (tuple, list)): states = state else: states = [state] def _wait(): while self.state not in states: time.sleep(interval) self.publish(channel) # From http://psyco.sourceforge.net/psycoguide/bugs.html: # "The compiled machine code does not include the regular polling # done by Python, meaning that a KeyboardInterrupt will not be # detected before execution comes back to the regular Python # interpreter. Your program cannot be interrupted if caught # into an infinite Psyco-compiled loop." try: sys.modules['psyco'].cannotcompile(_wait) except (KeyError, AttributeError): pass _wait()
[ "def", "wait", "(", "self", ",", "state", ",", "interval", "=", "0.1", ",", "channel", "=", "None", ")", ":", "if", "isinstance", "(", "state", ",", "(", "tuple", ",", "list", ")", ")", ":", "states", "=", "state", "else", ":", "states", "=", "["...
https://github.com/rembo10/headphones/blob/b3199605be1ebc83a7a8feab6b1e99b64014187c/lib/cherrypy/process/wspbus.py#L350-L373
joxeankoret/diaphora
dcb5a25ac9fe23a285b657e5389cf770de7ac928
jkutils/factor.py
python
_difference
(num1, num2)
return diffs, s
[]
def _difference(num1, num2): nums = [num1, num2] s = [] for num in nums: if num in FACTORS_CACHE: x = FACTORS_CACHE[num] else: x = factorization(int(num)) FACTORS_CACHE[num] = x s.append(x) diffs = {} for x in list(s[0].keys()): if x in list(s[1].keys()): if s[0][x] != s[1][x]: diffs[x] = max(s[0][x], s[1][x]) - min(s[0][x], s[1][x]) else: diffs[x] = s[0][x] for x in list(s[1].keys()): if x in list(s[0].keys()): if s[1][x] != s[0][x]: diffs[x] = max(s[0][x], s[1][x]) - min(s[0][x], s[1][x]) else: diffs[x] = s[1][x] return diffs, s
[ "def", "_difference", "(", "num1", ",", "num2", ")", ":", "nums", "=", "[", "num1", ",", "num2", "]", "s", "=", "[", "]", "for", "num", "in", "nums", ":", "if", "num", "in", "FACTORS_CACHE", ":", "x", "=", "FACTORS_CACHE", "[", "num", "]", "else"...
https://github.com/joxeankoret/diaphora/blob/dcb5a25ac9fe23a285b657e5389cf770de7ac928/jkutils/factor.py#L159-L186
scikit-image/scikit-image
ed642e2bc822f362504d24379dee94978d6fa9de
skimage/draw/_random_shapes.py
python
_generate_rectangle_mask
(point, image, shape, random)
return rectangle, label
Generate a mask for a filled rectangle shape. The height and width of the rectangle are generated randomly. Parameters ---------- point : tuple The row and column of the top left corner of the rectangle. image : tuple The height, width and depth of the image into which the shape is placed. shape : tuple The minimum and maximum size of the shape to fit. random : `numpy.random.Generator` The random state to use for random sampling. Raises ------ ArithmeticError When a shape cannot be fit into the image with the given starting coordinates. This usually means the image dimensions are too small or shape dimensions too large. Returns ------- label : tuple A (category, ((r0, r1), (c0, c1))) tuple specifying the category and bounding box coordinates of the shape. indices : 2-D array A mask of indices that the shape fills.
Generate a mask for a filled rectangle shape.
[ "Generate", "a", "mask", "for", "a", "filled", "rectangle", "shape", "." ]
def _generate_rectangle_mask(point, image, shape, random): """Generate a mask for a filled rectangle shape. The height and width of the rectangle are generated randomly. Parameters ---------- point : tuple The row and column of the top left corner of the rectangle. image : tuple The height, width and depth of the image into which the shape is placed. shape : tuple The minimum and maximum size of the shape to fit. random : `numpy.random.Generator` The random state to use for random sampling. Raises ------ ArithmeticError When a shape cannot be fit into the image with the given starting coordinates. This usually means the image dimensions are too small or shape dimensions too large. Returns ------- label : tuple A (category, ((r0, r1), (c0, c1))) tuple specifying the category and bounding box coordinates of the shape. indices : 2-D array A mask of indices that the shape fills. """ available_width = min(image[1] - point[1], shape[1]) - shape[0] available_height = min(image[0] - point[0], shape[1]) - shape[0] # Pick random widths and heights. r = shape[0] + random.integers(max(1, available_height)) - 1 c = shape[0] + random.integers(max(1, available_width)) - 1 rectangle = draw_polygon([ point[0], point[0] + r, point[0] + r, point[0], ], [ point[1], point[1], point[1] + c, point[1] + c, ]) label = ('rectangle', ((point[0], point[0] + r + 1), (point[1], point[1] + c + 1))) return rectangle, label
[ "def", "_generate_rectangle_mask", "(", "point", ",", "image", ",", "shape", ",", "random", ")", ":", "available_width", "=", "min", "(", "image", "[", "1", "]", "-", "point", "[", "1", "]", ",", "shape", "[", "1", "]", ")", "-", "shape", "[", "0",...
https://github.com/scikit-image/scikit-image/blob/ed642e2bc822f362504d24379dee94978d6fa9de/skimage/draw/_random_shapes.py#L9-L63
phoenix2/phoenix
2c83ee6e7c509d2a9378bcd15634a3740adf7666
phoenix2/backend/MMPProtocol.py
python
MMPProtocolBase.handleCommand
(self, cmd, args)
Handle a parsed command. This function takes care of converting arguments to their appropriate types and then calls the function handler. If a command is unknown, it is dispatched to illegalCommand.
Handle a parsed command.
[ "Handle", "a", "parsed", "command", "." ]
def handleCommand(self, cmd, args): """Handle a parsed command. This function takes care of converting arguments to their appropriate types and then calls the function handler. If a command is unknown, it is dispatched to illegalCommand. """ function = getattr(self, 'cmd_' + cmd, None) if function is None or cmd not in self.commands: return types = self.commands[cmd] if len(types) != len(args): converted = False else: converted = True # Unless the below loop has a conversion problem. for i,t in enumerate(types): try: args[i] = t(args[i]) except (ValueError, TypeError): converted = False break if converted: function(*args) else: self.illegalCommand(cmd)
[ "def", "handleCommand", "(", "self", ",", "cmd", ",", "args", ")", ":", "function", "=", "getattr", "(", "self", ",", "'cmd_'", "+", "cmd", ",", "None", ")", "if", "function", "is", "None", "or", "cmd", "not", "in", "self", ".", "commands", ":", "r...
https://github.com/phoenix2/phoenix/blob/2c83ee6e7c509d2a9378bcd15634a3740adf7666/phoenix2/backend/MMPProtocol.py#L46-L74
jython/jython3
def4f8ec47cb7a9c799ea4c745f12badf92c5769
lib-python/3.5.1/http/cookiejar.py
python
request_host
(request)
return host.lower()
Return request-host, as defined by RFC 2965. Variation from RFC: returned value is lowercased, for convenient comparison.
Return request-host, as defined by RFC 2965.
[ "Return", "request", "-", "host", "as", "defined", "by", "RFC", "2965", "." ]
def request_host(request): """Return request-host, as defined by RFC 2965. Variation from RFC: returned value is lowercased, for convenient comparison. """ url = request.get_full_url() host = urllib.parse.urlparse(url)[1] if host == "": host = request.get_header("Host", "") # remove port, if present host = cut_port_re.sub("", host, 1) return host.lower()
[ "def", "request_host", "(", "request", ")", ":", "url", "=", "request", ".", "get_full_url", "(", ")", "host", "=", "urllib", ".", "parse", ".", "urlparse", "(", "url", ")", "[", "1", "]", "if", "host", "==", "\"\"", ":", "host", "=", "request", "....
https://github.com/jython/jython3/blob/def4f8ec47cb7a9c799ea4c745f12badf92c5769/lib-python/3.5.1/http/cookiejar.py#L606-L620
home-assistant-libs/netdisco
477db5a1dc93919a6c5bd61b4b1d3c80e75785bd
netdisco/mdns.py
python
MDNS.entries
(self)
return list( itertools.chain( *[ self.zeroconf.cache.entries_with_name(name) for name in self.zeroconf.cache.names() ] ) )
Return all entries in the cache.
Return all entries in the cache.
[ "Return", "all", "entries", "in", "the", "cache", "." ]
def entries(self): """Return all entries in the cache.""" return list( itertools.chain( *[ self.zeroconf.cache.entries_with_name(name) for name in self.zeroconf.cache.names() ] ) )
[ "def", "entries", "(", "self", ")", ":", "return", "list", "(", "itertools", ".", "chain", "(", "*", "[", "self", ".", "zeroconf", ".", "cache", ".", "entries_with_name", "(", "name", ")", "for", "name", "in", "self", ".", "zeroconf", ".", "cache", "...
https://github.com/home-assistant-libs/netdisco/blob/477db5a1dc93919a6c5bd61b4b1d3c80e75785bd/netdisco/mdns.py#L92-L101
quantumlib/OpenFermion
6187085f2a7707012b68370b625acaeed547e62b
src/openfermion/hamiltonians/special_operators.py
python
sz_operator
(n_spatial_orbitals: int)
return operator
r"""Return the sz operator. $$ \begin{align} S^{z} = \frac{1}{2}\sum_{i = 1}^{n}(n_{i, \alpha} - n_{i, \beta}) \end{align} $$ Args: n_spatial_orbitals: number of spatial orbitals (n_qubits // 2). Returns: operator (FermionOperator): corresponding to the sz operator over n_spatial_orbitals. Note: The indexing convention used is that even indices correspond to spin-up (alpha) modes and odd indices correspond to spin-down (beta) modes.
r"""Return the sz operator.
[ "r", "Return", "the", "sz", "operator", "." ]
def sz_operator(n_spatial_orbitals: int) -> FermionOperator: r"""Return the sz operator. $$ \begin{align} S^{z} = \frac{1}{2}\sum_{i = 1}^{n}(n_{i, \alpha} - n_{i, \beta}) \end{align} $$ Args: n_spatial_orbitals: number of spatial orbitals (n_qubits // 2). Returns: operator (FermionOperator): corresponding to the sz operator over n_spatial_orbitals. Note: The indexing convention used is that even indices correspond to spin-up (alpha) modes and odd indices correspond to spin-down (beta) modes. """ if not isinstance(n_spatial_orbitals, int): raise TypeError("n_orbitals must be specified as an integer") operator = FermionOperator() n_spinless_orbitals = 2 * n_spatial_orbitals for ni in range(n_spatial_orbitals): operator += (number_operator(n_spinless_orbitals, up_index(ni), 0.5) + number_operator(n_spinless_orbitals, down_index(ni), -0.5)) return operator
[ "def", "sz_operator", "(", "n_spatial_orbitals", ":", "int", ")", "->", "FermionOperator", ":", "if", "not", "isinstance", "(", "n_spatial_orbitals", ",", "int", ")", ":", "raise", "TypeError", "(", "\"n_orbitals must be specified as an integer\"", ")", "operator", ...
https://github.com/quantumlib/OpenFermion/blob/6187085f2a7707012b68370b625acaeed547e62b/src/openfermion/hamiltonians/special_operators.py#L149-L179
biolab/orange3
41685e1c7b1d1babe680113685a2d44bcc9fec0b
Orange/widgets/data/oweditdomain.py
python
DiscreteVariableEditor.__categories_mapping
(self)
return res
Encode and return the current state as a CategoriesMappingType
Encode and return the current state as a CategoriesMappingType
[ "Encode", "and", "return", "the", "current", "state", "as", "a", "CategoriesMappingType" ]
def __categories_mapping(self): # type: () -> CategoriesMappingType """ Encode and return the current state as a CategoriesMappingType """ model = self.values_model source = self.var.categories res = [] # type: CategoriesMappingType for i in range(model.rowCount()): midx = model.index(i, 0) category = midx.data(Qt.EditRole) source_pos = midx.data(SourcePosRole) # type: Optional[int] if source_pos is not None: source_name = source[source_pos] else: source_name = None state = midx.data(EditStateRole) if state == ItemEditState.Dropped: res.append((source_name, None)) elif state == ItemEditState.Added: res.append((None, category)) else: res.append((source_name, category)) return res
[ "def", "__categories_mapping", "(", "self", ")", ":", "# type: () -> CategoriesMappingType", "model", "=", "self", ".", "values_model", "source", "=", "self", ".", "var", ".", "categories", "res", "=", "[", "]", "# type: CategoriesMappingType", "for", "i", "in", ...
https://github.com/biolab/orange3/blob/41685e1c7b1d1babe680113685a2d44bcc9fec0b/Orange/widgets/data/oweditdomain.py#L1331-L1355
holzschu/Carnets
44effb10ddfc6aa5c8b0687582a724ba82c6b547
Library/lib/python3.7/site-packages/qtconsole/console_widget.py
python
ConsoleWidget._get_line_end_pos
(self)
return self._get_line_end_cursor().position()
Get the position of the last character of the current line.
Get the position of the last character of the current line.
[ "Get", "the", "position", "of", "the", "last", "character", "of", "the", "current", "line", "." ]
def _get_line_end_pos(self): """ Get the position of the last character of the current line. """ return self._get_line_end_cursor().position()
[ "def", "_get_line_end_pos", "(", "self", ")", ":", "return", "self", ".", "_get_line_end_cursor", "(", ")", ".", "position", "(", ")" ]
https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/site-packages/qtconsole/console_widget.py#L1655-L1658
Qirky/FoxDot
76318f9630bede48ff3994146ed644affa27bfa4
FoxDot/lib/Workspace/Simple/SimpleEditor.py
python
workspace.__init__
(self, CodeClass)
[]
def __init__(self, CodeClass): self.app = wx.App(False) self.root = Editor(None, 'FoxDot - Live Coding with Python and SuperCollider')
[ "def", "__init__", "(", "self", ",", "CodeClass", ")", ":", "self", ".", "app", "=", "wx", ".", "App", "(", "False", ")", "self", ".", "root", "=", "Editor", "(", "None", ",", "'FoxDot - Live Coding with Python and SuperCollider'", ")" ]
https://github.com/Qirky/FoxDot/blob/76318f9630bede48ff3994146ed644affa27bfa4/FoxDot/lib/Workspace/Simple/SimpleEditor.py#L18-L21
duo-labs/isthislegit
5d51fd2e0fe070cacd1ee169ca8a371a72e005ef
dashboard/lib/flanker/mime/message/utils.py
python
_guess_and_convert_with
(value, detector=chardet)
Try to guess the encoding of the passed value with the provided detector and decode it. The detector is either chardet or cchardet module.
Try to guess the encoding of the passed value with the provided detector and decode it.
[ "Try", "to", "guess", "the", "encoding", "of", "the", "passed", "value", "with", "the", "provided", "detector", "and", "decode", "it", "." ]
def _guess_and_convert_with(value, detector=chardet): """ Try to guess the encoding of the passed value with the provided detector and decode it. The detector is either chardet or cchardet module. """ charset = detector.detect(value) if not charset["encoding"]: raise errors.DecodingError("Failed to guess encoding") try: value = value.decode(charset["encoding"], "replace") return value except (UnicodeError, LookupError) as e: raise errors.DecodingError(str(e))
[ "def", "_guess_and_convert_with", "(", "value", ",", "detector", "=", "chardet", ")", ":", "charset", "=", "detector", ".", "detect", "(", "value", ")", "if", "not", "charset", "[", "\"encoding\"", "]", ":", "raise", "errors", ".", "DecodingError", "(", "\...
https://github.com/duo-labs/isthislegit/blob/5d51fd2e0fe070cacd1ee169ca8a371a72e005ef/dashboard/lib/flanker/mime/message/utils.py#L15-L32
debian-calibre/calibre
020fc81d3936a64b2ac51459ecb796666ab6a051
src/calibre/ebooks/lrf/html/table.py
python
Table.get_widths
(self, maxwidth)
return [i+self.colpad for i in widths]
Return widths of columns + self.colpad
Return widths of columns + self.colpad
[ "Return", "widths", "of", "columns", "+", "self", ".", "colpad" ]
def get_widths(self, maxwidth): ''' Return widths of columns + self.colpad ''' rows, cols = self.number_or_rows(), self.number_of_columns() widths = list(range(cols)) for c in range(cols): cellwidths = [0 for i in range(rows)] for r in range(rows): try: cellwidths[r] = self.rows[r].preferred_width(c) except IndexError: continue widths[c] = max(cellwidths) min_widths = [self.minimum_width(i)+10 for i in range(cols)] for i in range(len(widths)): wp = self.width_percent(i) if wp >= 0: widths[i] = max(min_widths[i], ceil((wp/100) * (maxwidth - (cols-1)*self.colpad))) itercount = 0 while sum(widths) > maxwidth-((len(widths)-1)*self.colpad) and itercount < 100: for i in range(cols): widths[i] = ceil((95/100)*widths[i]) if \ ceil((95/100)*widths[i]) >= min_widths[i] else widths[i] itercount += 1 return [i+self.colpad for i in widths]
[ "def", "get_widths", "(", "self", ",", "maxwidth", ")", ":", "rows", ",", "cols", "=", "self", ".", "number_or_rows", "(", ")", ",", "self", ".", "number_of_columns", "(", ")", "widths", "=", "list", "(", "range", "(", "cols", ")", ")", "for", "c", ...
https://github.com/debian-calibre/calibre/blob/020fc81d3936a64b2ac51459ecb796666ab6a051/src/calibre/ebooks/lrf/html/table.py#L308-L337
RasaHQ/rasa
54823b68c1297849ba7ae841a4246193cd1223a1
rasa/core/training/interactive.py
python
_split_conversation_at_restarts
( events: List[Dict[Text, Any]] )
return [[event.as_dict() for event in events] for events in split_events]
Split a conversation at restart events. Returns an array of event lists, without the restart events.
Split a conversation at restart events.
[ "Split", "a", "conversation", "at", "restart", "events", "." ]
def _split_conversation_at_restarts( events: List[Dict[Text, Any]] ) -> List[List[Dict[Text, Any]]]: """Split a conversation at restart events. Returns an array of event lists, without the restart events.""" deserialized_events = [Event.from_parameters(event) for event in events] split_events = rasa.shared.core.events.split_events( deserialized_events, Restarted, include_splitting_event=False ) return [[event.as_dict() for event in events] for events in split_events]
[ "def", "_split_conversation_at_restarts", "(", "events", ":", "List", "[", "Dict", "[", "Text", ",", "Any", "]", "]", ")", "->", "List", "[", "List", "[", "Dict", "[", "Text", ",", "Any", "]", "]", "]", ":", "deserialized_events", "=", "[", "Event", ...
https://github.com/RasaHQ/rasa/blob/54823b68c1297849ba7ae841a4246193cd1223a1/rasa/core/training/interactive.py#L756-L767
gramps-project/gramps
04d4651a43eb210192f40a9f8c2bad8ee8fa3753
gramps/gui/display.py
python
display_help
(webpage='', section='')
Display the specified webpage and section from the Gramps wiki.
Display the specified webpage and section from the Gramps wiki.
[ "Display", "the", "specified", "webpage", "and", "section", "from", "the", "Gramps", "wiki", "." ]
def display_help(webpage='', section=''): """ Display the specified webpage and section from the Gramps wiki. """ if not webpage: link = URL_WIKISTRING + URL_MANUAL_PAGE + EXTENSION else: link = URL_WIKISTRING + quote(webpage) + EXTENSION if section: link += '#' + quote(section.replace(' ', '_')).replace('%', '.') display_url(link)
[ "def", "display_help", "(", "webpage", "=", "''", ",", "section", "=", "''", ")", ":", "if", "not", "webpage", ":", "link", "=", "URL_WIKISTRING", "+", "URL_MANUAL_PAGE", "+", "EXTENSION", "else", ":", "link", "=", "URL_WIKISTRING", "+", "quote", "(", "w...
https://github.com/gramps-project/gramps/blob/04d4651a43eb210192f40a9f8c2bad8ee8fa3753/gramps/gui/display.py#L62-L72
gammapy/gammapy
735b25cd5bbed35e2004d633621896dcd5295e8b
gammapy/maps/geom.py
python
Geom.data_shape
(self)
Shape of the Numpy data array matching this geometry.
Shape of the Numpy data array matching this geometry.
[ "Shape", "of", "the", "Numpy", "data", "array", "matching", "this", "geometry", "." ]
def data_shape(self): """Shape of the Numpy data array matching this geometry.""" pass
[ "def", "data_shape", "(", "self", ")", ":", "pass" ]
https://github.com/gammapy/gammapy/blob/735b25cd5bbed35e2004d633621896dcd5295e8b/gammapy/maps/geom.py#L73-L75
ajinabraham/OWASP-Xenotix-XSS-Exploit-Framework
cb692f527e4e819b6c228187c5702d990a180043
external/Scripting Engine/packages/IronPython.StdLib.2.7.4/content/Lib/lib2to3/fixer_util.py
python
String
(string, prefix=None)
return Leaf(token.STRING, string, prefix=prefix)
A string leaf
A string leaf
[ "A", "string", "leaf" ]
def String(string, prefix=None): """A string leaf""" return Leaf(token.STRING, string, prefix=prefix)
[ "def", "String", "(", "string", ",", "prefix", "=", "None", ")", ":", "return", "Leaf", "(", "token", ".", "STRING", ",", "string", ",", "prefix", "=", "prefix", ")" ]
https://github.com/ajinabraham/OWASP-Xenotix-XSS-Exploit-Framework/blob/cb692f527e4e819b6c228187c5702d990a180043/external/Scripting Engine/packages/IronPython.StdLib.2.7.4/content/Lib/lib2to3/fixer_util.py#L85-L87
LabPy/lantz
3e878e3f765a4295b0089d04e241d4beb7b8a65b
lantz/drivers/legacy/ni/daqmx/base.py
python
Task.unreserve
(self)
Release all reserved resources.
Release all reserved resources.
[ "Release", "all", "reserved", "resources", "." ]
def unreserve(self): """Release all reserved resources. """ self.alter_state('unreserve')
[ "def", "unreserve", "(", "self", ")", ":", "self", ".", "alter_state", "(", "'unreserve'", ")" ]
https://github.com/LabPy/lantz/blob/3e878e3f765a4295b0089d04e241d4beb7b8a65b/lantz/drivers/legacy/ni/daqmx/base.py#L545-L548
apkudo/adbusbini
a5493afa4339e3b5f3645ae6052636fbf70a6fbc
adbusbini_scrape.py
python
handle_vendor
(vendor_id, vendor_name)
[]
def handle_vendor(vendor_id, vendor_name): if not vendor_exists_file(vendor_id, adb_usb_ini): vendor_add_adb(vendor_id) if not vendor_exists_file(vendor_id, vendors): vendor_add_listing(vendor_id, vendor_name)
[ "def", "handle_vendor", "(", "vendor_id", ",", "vendor_name", ")", ":", "if", "not", "vendor_exists_file", "(", "vendor_id", ",", "adb_usb_ini", ")", ":", "vendor_add_adb", "(", "vendor_id", ")", "if", "not", "vendor_exists_file", "(", "vendor_id", ",", "vendors...
https://github.com/apkudo/adbusbini/blob/a5493afa4339e3b5f3645ae6052636fbf70a6fbc/adbusbini_scrape.py#L47-L51
fossasia/pslab-python
bb53a334b729d0956ed9f4ce6899903f3e4868ef
pslab/bus/spi.py
python
SPISlave.transfer16_bulk
(self, data: List[int])
return data_in
Transfer 16-bit data array over SPI. Parameters ---------- data : list of int List of 16-bit data to transmit. Returns ------- data_in : list of int List of 16-bit data returned by slave device.
Transfer 16-bit data array over SPI.
[ "Transfer", "16", "-", "bit", "data", "array", "over", "SPI", "." ]
def transfer16_bulk(self, data: List[int]) -> List[int]: """Transfer 16-bit data array over SPI. Parameters ---------- data : list of int List of 16-bit data to transmit. Returns ------- data_in : list of int List of 16-bit data returned by slave device. """ self._start() data_in = self._transfer_bulk(data, 16) self._stop() return data_in
[ "def", "transfer16_bulk", "(", "self", ",", "data", ":", "List", "[", "int", "]", ")", "->", "List", "[", "int", "]", ":", "self", ".", "_start", "(", ")", "data_in", "=", "self", ".", "_transfer_bulk", "(", "data", ",", "16", ")", "self", ".", "...
https://github.com/fossasia/pslab-python/blob/bb53a334b729d0956ed9f4ce6899903f3e4868ef/pslab/bus/spi.py#L557-L574
abseil/abseil-py
a1c1af693b9f15bd0f67fe383cb05e7cc955556b
absl/logging/__init__.py
python
level_error
()
return get_verbosity() >= ERROR
Returns True if error logging is turned on.
Returns True if error logging is turned on.
[ "Returns", "True", "if", "error", "logging", "is", "turned", "on", "." ]
def level_error(): """Returns True if error logging is turned on.""" return get_verbosity() >= ERROR
[ "def", "level_error", "(", ")", ":", "return", "get_verbosity", "(", ")", ">=", "ERROR" ]
https://github.com/abseil/abseil-py/blob/a1c1af693b9f15bd0f67fe383cb05e7cc955556b/absl/logging/__init__.py#L627-L629
inasafe/inasafe
355eb2ce63f516b9c26af0c86a24f99e53f63f87
safe/gui/widgets/dock.py
python
Dock.toggle_aggregation_layer_combo
(self)
Toggle the aggregation combo enabled status. Whether the combo is toggled on or off will depend on the current dock status.
Toggle the aggregation combo enabled status.
[ "Toggle", "the", "aggregation", "combo", "enabled", "status", "." ]
def toggle_aggregation_layer_combo(self): """Toggle the aggregation combo enabled status. Whether the combo is toggled on or off will depend on the current dock status. """ selected_hazard_layer = layer_from_combo(self.hazard_layer_combo) selected_exposure_layer = layer_from_combo(self.exposure_layer_combo) # more than 1 because No aggregation is always there if ((self.aggregation_layer_combo.count() > 1) and (selected_hazard_layer is not None) and (selected_exposure_layer is not None)): self.aggregation_layer_combo.setEnabled(True) else: self.aggregation_layer_combo.setCurrentIndex(0) self.aggregation_layer_combo.setEnabled(False)
[ "def", "toggle_aggregation_layer_combo", "(", "self", ")", ":", "selected_hazard_layer", "=", "layer_from_combo", "(", "self", ".", "hazard_layer_combo", ")", "selected_exposure_layer", "=", "layer_from_combo", "(", "self", ".", "exposure_layer_combo", ")", "# more than 1...
https://github.com/inasafe/inasafe/blob/355eb2ce63f516b9c26af0c86a24f99e53f63f87/safe/gui/widgets/dock.py#L603-L619
frappe/frappe
b64cab6867dfd860f10ccaf41a4ec04bc890b583
frappe/__init__.py
python
scrub
(txt)
return txt.replace(' ', '_').replace('-', '_').lower()
Returns sluggified string. e.g. `Sales Order` becomes `sales_order`.
Returns sluggified string. e.g. `Sales Order` becomes `sales_order`.
[ "Returns", "sluggified", "string", ".", "e", ".", "g", ".", "Sales", "Order", "becomes", "sales_order", "." ]
def scrub(txt): """Returns sluggified string. e.g. `Sales Order` becomes `sales_order`.""" return txt.replace(' ', '_').replace('-', '_').lower()
[ "def", "scrub", "(", "txt", ")", ":", "return", "txt", ".", "replace", "(", "' '", ",", "'_'", ")", ".", "replace", "(", "'-'", ",", "'_'", ")", ".", "lower", "(", ")" ]
https://github.com/frappe/frappe/blob/b64cab6867dfd860f10ccaf41a4ec04bc890b583/frappe/__init__.py#L998-L1000
gdlg/pytorch_compact_bilinear_pooling
ecbb98bdccaf8987f2c2432ac0f1db5f370811e8
compact_bilinear_pooling/__init__.py
python
ComplexMultiply.backward
(ctx,grad_Z_re, grad_Z_im)
return ComplexMultiply_backward(X_re,X_im,Y_re,Y_im, grad_Z_re, grad_Z_im)
[]
def backward(ctx,grad_Z_re, grad_Z_im): X_re,X_im,Y_re,Y_im = ctx.saved_tensors return ComplexMultiply_backward(X_re,X_im,Y_re,Y_im, grad_Z_re, grad_Z_im)
[ "def", "backward", "(", "ctx", ",", "grad_Z_re", ",", "grad_Z_im", ")", ":", "X_re", ",", "X_im", ",", "Y_re", ",", "Y_im", "=", "ctx", ".", "saved_tensors", "return", "ComplexMultiply_backward", "(", "X_re", ",", "X_im", ",", "Y_re", ",", "Y_im", ",", ...
https://github.com/gdlg/pytorch_compact_bilinear_pooling/blob/ecbb98bdccaf8987f2c2432ac0f1db5f370811e8/compact_bilinear_pooling/__init__.py#L136-L138
MeanEYE/Sunflower
1024bbdde3b8e202ddad3553b321a7b6230bffc9
sunflower/gui/preferences/associations.py
python
AssociationsOptions.__add_mime_type
(self, widget, data=None)
Show dialog for adding mime type
Show dialog for adding mime type
[ "Show", "dialog", "for", "adding", "mime", "type" ]
def __add_mime_type(self, widget, data=None): """Show dialog for adding mime type""" dialog = InputDialog(self._application) dialog.set_title(_('Add mime type')) dialog.set_label(_('Enter MIME type (eg. image/png):')) response = dialog.get_response() # add new mime type to the table if response[0] == Gtk.ResponseType.OK: mime_type = response[1] description = self._application.associations_manager.get_mime_description(mime_type) # add item to the store self._associations.append(None, (description, mime_type)) # enable save button on parent self._parent.enable_save()
[ "def", "__add_mime_type", "(", "self", ",", "widget", ",", "data", "=", "None", ")", ":", "dialog", "=", "InputDialog", "(", "self", ".", "_application", ")", "dialog", ".", "set_title", "(", "_", "(", "'Add mime type'", ")", ")", "dialog", ".", "set_lab...
https://github.com/MeanEYE/Sunflower/blob/1024bbdde3b8e202ddad3553b321a7b6230bffc9/sunflower/gui/preferences/associations.py#L73-L90
qutebrowser/qutebrowser
3a2aaaacbf97f4bf0c72463f3da94ed2822a5442
qutebrowser/config/websettings.py
python
AbstractSettings.set_default_text_encoding
(self, encoding: Union[str, usertypes.Unset])
Set the default text encoding to use.
Set the default text encoding to use.
[ "Set", "the", "default", "text", "encoding", "to", "use", "." ]
def set_default_text_encoding(self, encoding: Union[str, usertypes.Unset]) -> None: """Set the default text encoding to use.""" assert encoding is not usertypes.UNSET # unclear how to reset self._settings.setDefaultTextEncoding(encoding)
[ "def", "set_default_text_encoding", "(", "self", ",", "encoding", ":", "Union", "[", "str", ",", "usertypes", ".", "Unset", "]", ")", "->", "None", ":", "assert", "encoding", "is", "not", "usertypes", ".", "UNSET", "# unclear how to reset", "self", ".", "_se...
https://github.com/qutebrowser/qutebrowser/blob/3a2aaaacbf97f4bf0c72463f3da94ed2822a5442/qutebrowser/config/websettings.py#L162-L165
dswah/pyGAM
b57b4cf8783a90976031e1857e748ca3e6ec650b
pygam/utils.py
python
check_iterable_depth
(obj, max_depth=100)
return depth
find the maximum depth of nesting of the iterable Parameters ---------- obj : iterable max_depth : int, default: 100 maximum depth beyond which we stop counting Returns ------- int
find the maximum depth of nesting of the iterable
[ "find", "the", "maximum", "depth", "of", "nesting", "of", "the", "iterable" ]
def check_iterable_depth(obj, max_depth=100): """find the maximum depth of nesting of the iterable Parameters ---------- obj : iterable max_depth : int, default: 100 maximum depth beyond which we stop counting Returns ------- int """ def find_iterables(obj): iterables = [] for item in obj: if isiterable(item): iterables += list(item) return iterables depth = 0 while (depth < max_depth) and isiterable(obj) and len(obj) > 0: depth += 1 obj = find_iterables(obj) return depth
[ "def", "check_iterable_depth", "(", "obj", ",", "max_depth", "=", "100", ")", ":", "def", "find_iterables", "(", "obj", ")", ":", "iterables", "=", "[", "]", "for", "item", "in", "obj", ":", "if", "isiterable", "(", "item", ")", ":", "iterables", "+=",...
https://github.com/dswah/pyGAM/blob/b57b4cf8783a90976031e1857e748ca3e6ec650b/pygam/utils.py#L778-L802
saltstack/pepper
8096e0896417ef9b533c7b99dac77535c6eba15d
pepper/libpepper.py
python
Pepper.req_requests
(self, path, data=None)
return resp.json()
A thin wrapper around request and request_kerberos to send requests and return the response If the current instance contains an authentication token it will be attached to the request as a custom header. :rtype: dictionary
A thin wrapper around request and request_kerberos to send requests and return the response
[ "A", "thin", "wrapper", "around", "request", "and", "request_kerberos", "to", "send", "requests", "and", "return", "the", "response" ]
def req_requests(self, path, data=None): ''' A thin wrapper around request and request_kerberos to send requests and return the response If the current instance contains an authentication token it will be attached to the request as a custom header. :rtype: dictionary ''' import requests from requests_gssapi import HTTPSPNEGOAuth, OPTIONAL auth = HTTPSPNEGOAuth(mutual_authentication=OPTIONAL) headers = { 'Accept': 'application/json', 'Content-Type': 'application/json', 'X-Requested-With': 'XMLHttpRequest', } if self.auth and 'token' in self.auth and self.auth['token']: headers.setdefault('X-Auth-Token', self.auth['token']) # Optionally toggle SSL verification params = {'url': self._construct_url(path), 'headers': headers, 'verify': self._ssl_verify is True, 'auth': auth, 'data': json.dumps(data), } logger.debug('postdata {0}'.format(params)) resp = requests.post(**params) if resp.status_code == 401: # TODO should be resp.raise_from_status raise PepperException('Authentication denied') if resp.status_code == 500: # TODO should be resp.raise_from_status raise PepperException('Server error.') if not self.salt_version and 'x-salt-version' in resp.headers: self._parse_salt_version(resp.headers['x-salt-version']) return resp.json()
[ "def", "req_requests", "(", "self", ",", "path", ",", "data", "=", "None", ")", ":", "import", "requests", "from", "requests_gssapi", "import", "HTTPSPNEGOAuth", ",", "OPTIONAL", "auth", "=", "HTTPSPNEGOAuth", "(", "mutual_authentication", "=", "OPTIONAL", ")", ...
https://github.com/saltstack/pepper/blob/8096e0896417ef9b533c7b99dac77535c6eba15d/pepper/libpepper.py#L258-L298
JBakamovic/cxxd
142c19649b036bd6f6bdcd4684de735ea11a6c94
api.py
python
project_builder_start
(handle)
[]
def project_builder_start(handle): _server_start_service(handle, ServiceId.PROJECT_BUILDER)
[ "def", "project_builder_start", "(", "handle", ")", ":", "_server_start_service", "(", "handle", ",", "ServiceId", ".", "PROJECT_BUILDER", ")" ]
https://github.com/JBakamovic/cxxd/blob/142c19649b036bd6f6bdcd4684de735ea11a6c94/api.py#L130-L131
openedx/edx-platform
68dd185a0ab45862a2a61e0f803d7e03d2be71b5
lms/djangoapps/commerce/utils.py
python
EcommerceService.get_order_dashboard_url
(self)
return self.get_absolute_ecommerce_url(CommerceConfiguration.DEFAULT_ORDER_DASHBOARD_URL)
Return the URL to the ecommerce dashboard orders page. Returns: String: order dashboard url.
Return the URL to the ecommerce dashboard orders page.
[ "Return", "the", "URL", "to", "the", "ecommerce", "dashboard", "orders", "page", "." ]
def get_order_dashboard_url(self): """ Return the URL to the ecommerce dashboard orders page. Returns: String: order dashboard url. """ return self.get_absolute_ecommerce_url(CommerceConfiguration.DEFAULT_ORDER_DASHBOARD_URL)
[ "def", "get_order_dashboard_url", "(", "self", ")", ":", "return", "self", ".", "get_absolute_ecommerce_url", "(", "CommerceConfiguration", ".", "DEFAULT_ORDER_DASHBOARD_URL", ")" ]
https://github.com/openedx/edx-platform/blob/68dd185a0ab45862a2a61e0f803d7e03d2be71b5/lms/djangoapps/commerce/utils.py#L62-L68
phaethon/kamene
bf679a65d456411942ee4a907818ba3d6a183bfe
kamene/fields.py
python
Field.i2len
(self, pkt, x)
return self.sz
Convert internal value to a length usable by a FieldLenField
Convert internal value to a length usable by a FieldLenField
[ "Convert", "internal", "value", "to", "a", "length", "usable", "by", "a", "FieldLenField" ]
def i2len(self, pkt, x): """Convert internal value to a length usable by a FieldLenField""" return self.sz
[ "def", "i2len", "(", "self", ",", "pkt", ",", "x", ")", ":", "return", "self", ".", "sz" ]
https://github.com/phaethon/kamene/blob/bf679a65d456411942ee4a907818ba3d6a183bfe/kamene/fields.py#L38-L40
SteveDoyle2/pyNastran
eda651ac2d4883d95a34951f8a002ff94f642a1a
pyNastran/op2/tables/geom/edt.py
python
EDT._read_uxvec
(self, data: bytes, n: int)
return n
MSC 2020 Word Name Type Description 1 ID I Control vector identification number 2 LABEL(2) CHAR4 Controller name 4 UX RS Magnitude of aerodynamic extra point dof Words 2 thru 4 repeat until (-1,-1) occurs data = (5001, 'PLOAD ', 1.0, 'INTERCPT', 0.0, -1, -1)
MSC 2020
[ "MSC", "2020" ]
def _read_uxvec(self, data: bytes, n: int) -> int: """ MSC 2020 Word Name Type Description 1 ID I Control vector identification number 2 LABEL(2) CHAR4 Controller name 4 UX RS Magnitude of aerodynamic extra point dof Words 2 thru 4 repeat until (-1,-1) occurs data = (5001, 'PLOAD ', 1.0, 'INTERCPT', 0.0, -1, -1) """ op2 = self.op2 ntotal1 = 4 * self.factor # 4*1 ntotal_end = 8 * self.factor # 4*2 ntotal2 = 12 * self.factor # 4*3 #ndatai = len(data) - n #ncards = ndatai // ntotal #assert ndatai % ntotal == 0 struct1 = Struct(mapfmt(op2._endian + b'i', self.size)) struct2 = Struct(mapfmt(op2._endian + b'8s f', self.size)) struct_end = Struct(mapfmt(op2._endian + b'2i', self.size)) #for unused_i in range(ncards): #edata = data[n:n + ntotal] #aeparm_id, label_bytes, units_bytes = structi.unpack(edata) #label = label_bytes.decode(op2._encoding).rstrip() #units = units_bytes.decode(op2._encoding).rstrip() #op2.add_uxvec() #n += ntotal while n < len(data): edata1 = data[n:n+ntotal1] idi, = struct1.unpack(edata1) n += ntotal1 labels = [] uxs = [] edata_end = data[n:n+ntotal_end] while struct_end.unpack(edata_end) != (-1, -1): edata2 = data[n:n+ntotal2] label_bytes, ux = struct2.unpack(edata2) label = reshape_bytes_block_size(label_bytes, self.size) labels.append(label) uxs.append(ux) n += ntotal2 edata_end = data[n:n+ntotal_end] n += ntotal_end uxvec = op2.add_uxvec(idi, labels, uxs) str(uxvec) return n
[ "def", "_read_uxvec", "(", "self", ",", "data", ":", "bytes", ",", "n", ":", "int", ")", "->", "int", ":", "op2", "=", "self", ".", "op2", "ntotal1", "=", "4", "*", "self", ".", "factor", "# 4*1", "ntotal_end", "=", "8", "*", "self", ".", "factor...
https://github.com/SteveDoyle2/pyNastran/blob/eda651ac2d4883d95a34951f8a002ff94f642a1a/pyNastran/op2/tables/geom/edt.py#L633-L682
omriher/CapTipper
3fb2836c0afe60eb6bd5902b4214f564268e9b4d
pefile.py
python
PE.trim
(self)
return self.__data__[:]
Return the just data defined by the PE headers, removing any overlayed data.
Return the just data defined by the PE headers, removing any overlayed data.
[ "Return", "the", "just", "data", "defined", "by", "the", "PE", "headers", "removing", "any", "overlayed", "data", "." ]
def trim(self): """Return the just data defined by the PE headers, removing any overlayed data.""" overlay_data_offset = self.get_overlay_data_start_offset() if overlay_data_offset is not None: return self.__data__[ : overlay_data_offset ] return self.__data__[:]
[ "def", "trim", "(", "self", ")", ":", "overlay_data_offset", "=", "self", ".", "get_overlay_data_start_offset", "(", ")", "if", "overlay_data_offset", "is", "not", "None", ":", "return", "self", ".", "__data__", "[", ":", "overlay_data_offset", "]", "return", ...
https://github.com/omriher/CapTipper/blob/3fb2836c0afe60eb6bd5902b4214f564268e9b4d/pefile.py#L5266-L5274
ray-project/ray
703c1610348615dcb8c2d141a0c46675084660f5
python/ray/serve/storage/checkpoint_path.py
python
make_kv_store
(checkpoint_path, namespace)
Create KVStore instance based on checkpoint_path configuration
Create KVStore instance based on checkpoint_path configuration
[ "Create", "KVStore", "instance", "based", "on", "checkpoint_path", "configuration" ]
def make_kv_store(checkpoint_path, namespace): """Create KVStore instance based on checkpoint_path configuration""" if checkpoint_path == DEFAULT_CHECKPOINT_PATH: logger.info("Using RayInternalKVStore for controller " "checkpoint and recovery.") return RayInternalKVStore(namespace) else: parsed_url = urlparse(checkpoint_path) if parsed_url.scheme not in {"gs", "s3", "file", "custom"}: raise ValueError( f"Checkpoint must be one of `{DEFAULT_CHECKPOINT_PATH}`, " "`file://path...`, `gs://path...`, `s3://path...`, or " "`custom://my_module.ClassName?arg1=val1`. But it is " f"{checkpoint_path}") if parsed_url.scheme == "file": db_path = parsed_url.netloc + parsed_url.path logger.info("Using RayLocalKVStore for controller " f"checkpoint and recovery: path={db_path}") return RayLocalKVStore(namespace, db_path) if parsed_url.scheme == "gs": bucket = parsed_url.netloc # We need to strip leading "/" in path as right key to use in # gcs. Ex: gs://bucket/folder/file.zip -> key = "folder/file.zip" prefix = parsed_url.path.lstrip("/") logger.info("Using Ray GCS KVStore for controller checkpoint and" " recovery: " f"bucket={bucket} checkpoint_path={checkpoint_path}") return RayGcsKVStore( namespace, bucket=bucket, prefix=prefix, ) if parsed_url.scheme == "s3": bucket = parsed_url.netloc # We need to strip leading "/" in path as right key to use in # boto3. Ex: s3://bucket/folder/file.zip -> key = "folder/file.zip" prefix = parsed_url.path.lstrip("/") logger.info( "Using Ray S3 KVStore for controller checkpoint and recovery: " f"bucket={bucket} checkpoint_path={checkpoint_path}") return RayS3KVStore( namespace, bucket=bucket, prefix=prefix, ) if parsed_url.scheme == "custom": kwargs = dict(parse_qsl(parsed_url.query)) # Prepare the parameters to initialize imported class. checkpoint_provider = parsed_url.netloc KVStoreClass = import_attr(checkpoint_provider) if not issubclass(KVStoreClass, KVStoreBase): raise ValueError( f"{KVStoreClass} doesn't inherit from " "`ray.serve.storage.kv_store_base.KVStoreBase`.") logger.info( f"Using {checkpoint_provider} for controller checkpoint and " f"recovery: kwargs={kwargs}") return KVStoreClass(namespace=namespace, **kwargs) raise RuntimeError("This shouldn't be reachable.")
[ "def", "make_kv_store", "(", "checkpoint_path", ",", "namespace", ")", ":", "if", "checkpoint_path", "==", "DEFAULT_CHECKPOINT_PATH", ":", "logger", ".", "info", "(", "\"Using RayInternalKVStore for controller \"", "\"checkpoint and recovery.\"", ")", "return", "RayInternal...
https://github.com/ray-project/ray/blob/703c1610348615dcb8c2d141a0c46675084660f5/python/ray/serve/storage/checkpoint_path.py#L12-L78
vmware/vsphere-automation-sdk-python
ba7d4e0742f58a641dfed9538ecbbb1db4f3891e
samples/vmc/draas/site_recovery_activation_ops.py
python
main
()
[]
def main(): srm_activation_ops = SiteRecoveryActivationOperations() srm_activation_ops.setup() srm_activation_ops.activate_srm() srm_activation_ops.deactivate_srm()
[ "def", "main", "(", ")", ":", "srm_activation_ops", "=", "SiteRecoveryActivationOperations", "(", ")", "srm_activation_ops", ".", "setup", "(", ")", "srm_activation_ops", ".", "activate_srm", "(", ")", "srm_activation_ops", ".", "deactivate_srm", "(", ")" ]
https://github.com/vmware/vsphere-automation-sdk-python/blob/ba7d4e0742f58a641dfed9538ecbbb1db4f3891e/samples/vmc/draas/site_recovery_activation_ops.py#L98-L102
zhl2008/awd-platform
0416b31abea29743387b10b3914581fbe8e7da5e
web_flaskbb/lib/python2.7/site-packages/whoosh/matching/binary.py
python
DisjunctionMaxMatcher.block_quality
(self)
return max(self.a.block_quality(), self.b.block_quality())
[]
def block_quality(self): return max(self.a.block_quality(), self.b.block_quality())
[ "def", "block_quality", "(", "self", ")", ":", "return", "max", "(", "self", ".", "a", ".", "block_quality", "(", ")", ",", "self", ".", "b", ".", "block_quality", "(", ")", ")" ]
https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/lib/python2.7/site-packages/whoosh/matching/binary.py#L381-L382
gavinfish/leetcode-share
92bf28abf81a4cbf988d6595b9e42a6ee1b9071d
python/142 Linked List Cycle II.py
python
Solution.detectCycle
(self, head)
return None
:type head: ListNode :rtype: ListNode
:type head: ListNode :rtype: ListNode
[ ":", "type", "head", ":", "ListNode", ":", "rtype", ":", "ListNode" ]
def detectCycle(self, head): """ :type head: ListNode :rtype: ListNode """ slow = fast = head while fast and fast.next: slow = slow.next fast = fast.next.next if slow == fast: node = head while node != slow: node = node.next slow = slow.next return node return None
[ "def", "detectCycle", "(", "self", ",", "head", ")", ":", "slow", "=", "fast", "=", "head", "while", "fast", "and", "fast", ".", "next", ":", "slow", "=", "slow", ".", "next", "fast", "=", "fast", ".", "next", ".", "next", "if", "slow", "==", "fa...
https://github.com/gavinfish/leetcode-share/blob/92bf28abf81a4cbf988d6595b9e42a6ee1b9071d/python/142 Linked List Cycle II.py#L18-L33
SimonShi1994/Princess-connection-farm
c189de660677602167b7245846c2b0e53d5e777e
core/MoveRecord.py
python
moveset.T_if
(self, key, value=1, mode="==")
return self._T_if(cmd)
模板:只有当key满足条件时才执行后续语句块内容 :param key: key名称 :param value: key比较值 :param mode: 比较模式(==,<=,>=,!=,<,>...) :return: start的ID
模板:只有当key满足条件时才执行后续语句块内容 :param key: key名称 :param value: key比较值 :param mode: 比较模式(==,<=,>=,!=,<,>...) :return: start的ID
[ "模板:只有当key满足条件时才执行后续语句块内容", ":", "param", "key", ":", "key名称", ":", "param", "value", ":", "key比较值", ":", "param", "mode", ":", "比较模式", "(", "==", "<", "=", ">", "=", "!", "=", "<", ">", "...", ")", ":", "return", ":", "start的ID" ]
def T_if(self, key, value=1, mode="=="): """ 模板:只有当key满足条件时才执行后续语句块内容 :param key: key名称 :param value: key比较值 :param mode: 比较模式(==,<=,>=,!=,<,>...) :return: start的ID """ cmd = "'%s' in var and var['%s']%s%s" % (str(key), str(key), mode, str(value)) return self._T_if(cmd)
[ "def", "T_if", "(", "self", ",", "key", ",", "value", "=", "1", ",", "mode", "=", "\"==\"", ")", ":", "cmd", "=", "\"'%s' in var and var['%s']%s%s\"", "%", "(", "str", "(", "key", ")", ",", "str", "(", "key", ")", ",", "mode", ",", "str", "(", "v...
https://github.com/SimonShi1994/Princess-connection-farm/blob/c189de660677602167b7245846c2b0e53d5e777e/core/MoveRecord.py#L780-L789
PySimpleGUI/PySimpleGUI
6c0d1fb54f493d45e90180b322fbbe70f7a5af3c
DemoPrograms/Demo_Desktop_Widget_RAM_Square.py
python
human_size
(bytes, units=(' bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'))
return str(bytes) + ' ' + units[0] if bytes < 1024 else human_size(bytes >> 10, units[1:])
Returns a human readable string reprentation of bytes
Returns a human readable string reprentation of bytes
[ "Returns", "a", "human", "readable", "string", "reprentation", "of", "bytes" ]
def human_size(bytes, units=(' bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB')): """ Returns a human readable string reprentation of bytes""" return str(bytes) + ' ' + units[0] if bytes < 1024 else human_size(bytes >> 10, units[1:])
[ "def", "human_size", "(", "bytes", ",", "units", "=", "(", "' bytes'", ",", "'KB'", ",", "'MB'", ",", "'GB'", ",", "'TB'", ",", "'PB'", ",", "'EB'", ")", ")", ":", "return", "str", "(", "bytes", ")", "+", "' '", "+", "units", "[", "0", "]", "if...
https://github.com/PySimpleGUI/PySimpleGUI/blob/6c0d1fb54f493d45e90180b322fbbe70f7a5af3c/DemoPrograms/Demo_Desktop_Widget_RAM_Square.py#L21-L23
ajinabraham/OWASP-Xenotix-XSS-Exploit-Framework
cb692f527e4e819b6c228187c5702d990a180043
external/Scripting Engine/Xenotix Python Scripting Engine/Lib/decimal.py
python
Context.number_class
(self, a)
return a.number_class(context=self)
Returns an indication of the class of the operand. The class is one of the following strings: -sNaN -NaN -Infinity -Normal -Subnormal -Zero +Zero +Subnormal +Normal +Infinity >>> c = Context(ExtendedContext) >>> c.Emin = -999 >>> c.Emax = 999 >>> c.number_class(Decimal('Infinity')) '+Infinity' >>> c.number_class(Decimal('1E-10')) '+Normal' >>> c.number_class(Decimal('2.50')) '+Normal' >>> c.number_class(Decimal('0.1E-999')) '+Subnormal' >>> c.number_class(Decimal('0')) '+Zero' >>> c.number_class(Decimal('-0')) '-Zero' >>> c.number_class(Decimal('-0.1E-999')) '-Subnormal' >>> c.number_class(Decimal('-1E-10')) '-Normal' >>> c.number_class(Decimal('-2.50')) '-Normal' >>> c.number_class(Decimal('-Infinity')) '-Infinity' >>> c.number_class(Decimal('NaN')) 'NaN' >>> c.number_class(Decimal('-NaN')) 'NaN' >>> c.number_class(Decimal('sNaN')) 'sNaN' >>> c.number_class(123) '+Normal'
Returns an indication of the class of the operand.
[ "Returns", "an", "indication", "of", "the", "class", "of", "the", "operand", "." ]
def number_class(self, a): """Returns an indication of the class of the operand. The class is one of the following strings: -sNaN -NaN -Infinity -Normal -Subnormal -Zero +Zero +Subnormal +Normal +Infinity >>> c = Context(ExtendedContext) >>> c.Emin = -999 >>> c.Emax = 999 >>> c.number_class(Decimal('Infinity')) '+Infinity' >>> c.number_class(Decimal('1E-10')) '+Normal' >>> c.number_class(Decimal('2.50')) '+Normal' >>> c.number_class(Decimal('0.1E-999')) '+Subnormal' >>> c.number_class(Decimal('0')) '+Zero' >>> c.number_class(Decimal('-0')) '-Zero' >>> c.number_class(Decimal('-0.1E-999')) '-Subnormal' >>> c.number_class(Decimal('-1E-10')) '-Normal' >>> c.number_class(Decimal('-2.50')) '-Normal' >>> c.number_class(Decimal('-Infinity')) '-Infinity' >>> c.number_class(Decimal('NaN')) 'NaN' >>> c.number_class(Decimal('-NaN')) 'NaN' >>> c.number_class(Decimal('sNaN')) 'sNaN' >>> c.number_class(123) '+Normal' """ a = _convert_other(a, raiseit=True) return a.number_class(context=self)
[ "def", "number_class", "(", "self", ",", "a", ")", ":", "a", "=", "_convert_other", "(", "a", ",", "raiseit", "=", "True", ")", "return", "a", ".", "number_class", "(", "context", "=", "self", ")" ]
https://github.com/ajinabraham/OWASP-Xenotix-XSS-Exploit-Framework/blob/cb692f527e4e819b6c228187c5702d990a180043/external/Scripting Engine/Xenotix Python Scripting Engine/Lib/decimal.py#L4876-L4924
googlearchive/pywebsocket
c459a5f9a04714e596726e876fcb46951c61a5f7
mod_pywebsocket/http_header_util.py
python
_is_char
(c)
return ord(c) <= 127
Returns true iff c is in CHAR as specified in HTTP RFC.
Returns true iff c is in CHAR as specified in HTTP RFC.
[ "Returns", "true", "iff", "c", "is", "in", "CHAR", "as", "specified", "in", "HTTP", "RFC", "." ]
def _is_char(c): """Returns true iff c is in CHAR as specified in HTTP RFC.""" return ord(c) <= 127
[ "def", "_is_char", "(", "c", ")", ":", "return", "ord", "(", "c", ")", "<=", "127" ]
https://github.com/googlearchive/pywebsocket/blob/c459a5f9a04714e596726e876fcb46951c61a5f7/mod_pywebsocket/http_header_util.py#L42-L45
django-mptt/django-mptt
7a6a54c6d2572a45ea63bd639c25507108fff3e6
mptt/managers.py
python
TreeManager.left_attr
(self)
return self.model._mptt_meta.left_attr
[]
def left_attr(self): return self.model._mptt_meta.left_attr
[ "def", "left_attr", "(", "self", ")", ":", "return", "self", ".", "model", ".", "_mptt_meta", ".", "left_attr" ]
https://github.com/django-mptt/django-mptt/blob/7a6a54c6d2572a45ea63bd639c25507108fff3e6/mptt/managers.py#L353-L354
rowliny/DiffHelper
ab3a96f58f9579d0023aed9ebd785f4edf26f8af
Tool/SitePackages/nltk/sentiment/util.py
python
demo_vader_tweets
(n_instances=None, output=None)
Classify 10000 positive and negative tweets using Vader approach. :param n_instances: the number of total tweets that have to be classified. :param output: the output file where results have to be reported.
Classify 10000 positive and negative tweets using Vader approach.
[ "Classify", "10000", "positive", "and", "negative", "tweets", "using", "Vader", "approach", "." ]
def demo_vader_tweets(n_instances=None, output=None): """ Classify 10000 positive and negative tweets using Vader approach. :param n_instances: the number of total tweets that have to be classified. :param output: the output file where results have to be reported. """ from collections import defaultdict from nltk.corpus import twitter_samples from nltk.metrics import accuracy as eval_accuracy from nltk.metrics import f_measure as eval_f_measure from nltk.metrics import precision as eval_precision from nltk.metrics import recall as eval_recall from nltk.sentiment import SentimentIntensityAnalyzer if n_instances is not None: n_instances = int(n_instances / 2) fields = ["id", "text"] positive_json = twitter_samples.abspath("positive_tweets.json") positive_csv = "positive_tweets.csv" json2csv_preprocess( positive_json, positive_csv, fields, strip_off_emoticons=False, limit=n_instances, ) negative_json = twitter_samples.abspath("negative_tweets.json") negative_csv = "negative_tweets.csv" json2csv_preprocess( negative_json, negative_csv, fields, strip_off_emoticons=False, limit=n_instances, ) pos_docs = parse_tweets_set(positive_csv, label="pos") neg_docs = parse_tweets_set(negative_csv, label="neg") # We separately split subjective and objective instances to keep a balanced # uniform class distribution in both train and test sets. train_pos_docs, test_pos_docs = split_train_test(pos_docs) train_neg_docs, test_neg_docs = split_train_test(neg_docs) training_tweets = train_pos_docs + train_neg_docs testing_tweets = test_pos_docs + test_neg_docs vader_analyzer = SentimentIntensityAnalyzer() gold_results = defaultdict(set) test_results = defaultdict(set) acc_gold_results = [] acc_test_results = [] labels = set() num = 0 for i, (text, label) in enumerate(testing_tweets): labels.add(label) gold_results[label].add(i) acc_gold_results.append(label) score = vader_analyzer.polarity_scores(text)["compound"] if score > 0: observed = "pos" else: observed = "neg" num += 1 acc_test_results.append(observed) test_results[observed].add(i) metrics_results = {} for label in labels: accuracy_score = eval_accuracy(acc_gold_results, acc_test_results) metrics_results["Accuracy"] = accuracy_score precision_score = eval_precision(gold_results[label], test_results[label]) metrics_results[f"Precision [{label}]"] = precision_score recall_score = eval_recall(gold_results[label], test_results[label]) metrics_results[f"Recall [{label}]"] = recall_score f_measure_score = eval_f_measure(gold_results[label], test_results[label]) metrics_results[f"F-measure [{label}]"] = f_measure_score for result in sorted(metrics_results): print(f"{result}: {metrics_results[result]}") if output: output_markdown( output, Approach="Vader", Dataset="labeled_tweets", Instances=n_instances, Results=metrics_results, )
[ "def", "demo_vader_tweets", "(", "n_instances", "=", "None", ",", "output", "=", "None", ")", ":", "from", "collections", "import", "defaultdict", "from", "nltk", ".", "corpus", "import", "twitter_samples", "from", "nltk", ".", "metrics", "import", "accuracy", ...
https://github.com/rowliny/DiffHelper/blob/ab3a96f58f9579d0023aed9ebd785f4edf26f8af/Tool/SitePackages/nltk/sentiment/util.py#L773-L865
bikalims/bika.lims
35e4bbdb5a3912cae0b5eb13e51097c8b0486349
bika/lims/upgrade/to320.py
python
create_CAS_IdentifierType
(portal)
LIMS-1391 The CAS Nr IdentifierType is normally created by setuphandlers during site initialisation.
LIMS-1391 The CAS Nr IdentifierType is normally created by setuphandlers during site initialisation.
[ "LIMS", "-", "1391", "The", "CAS", "Nr", "IdentifierType", "is", "normally", "created", "by", "setuphandlers", "during", "site", "initialisation", "." ]
def create_CAS_IdentifierType(portal): """LIMS-1391 The CAS Nr IdentifierType is normally created by setuphandlers during site initialisation. """ bsc = getToolByName(portal, 'bika_catalog', None) idtypes = bsc(portal_type = 'IdentifierType', title='CAS Nr') if not idtypes: folder = portal.bika_setup.bika_identifiertypes idtype = _createObjectByType('IdentifierType', folder, tmpID()) idtype.processForm() idtype.edit(title='CAS Nr', description='Chemical Abstracts Registry number', portal_types=['Analysis Service'])
[ "def", "create_CAS_IdentifierType", "(", "portal", ")", ":", "bsc", "=", "getToolByName", "(", "portal", ",", "'bika_catalog'", ",", "None", ")", "idtypes", "=", "bsc", "(", "portal_type", "=", "'IdentifierType'", ",", "title", "=", "'CAS Nr'", ")", "if", "n...
https://github.com/bikalims/bika.lims/blob/35e4bbdb5a3912cae0b5eb13e51097c8b0486349/bika/lims/upgrade/to320.py#L195-L207
weechat/scripts
99ec0e7eceefabb9efb0f11ec26d45d6e8e84335
python/listbuffer.py
python
lb_close_cb
(*kwargs)
return weechat.WEECHAT_RC_OK
A callback for buffer closing.
A callback for buffer closing.
[ "A", "callback", "for", "buffer", "closing", "." ]
def lb_close_cb(*kwargs): """ A callback for buffer closing. """ global lb_buffer lb_buffer = None return weechat.WEECHAT_RC_OK
[ "def", "lb_close_cb", "(", "*", "kwargs", ")", ":", "global", "lb_buffer", "lb_buffer", "=", "None", "return", "weechat", ".", "WEECHAT_RC_OK" ]
https://github.com/weechat/scripts/blob/99ec0e7eceefabb9efb0f11ec26d45d6e8e84335/python/listbuffer.py#L421-L426
holzschu/Carnets
44effb10ddfc6aa5c8b0687582a724ba82c6b547
Library/lib/python3.7/site-packages/sympy/solvers/ode.py
python
lie_heuristic_bivariate
(match, comp=False)
r""" The third heuristic assumes the infinitesimals `\xi` and `\eta` to be bi-variate polynomials in `x` and `y`. The assumption made here for the logic below is that `h` is a rational function in `x` and `y` though that may not be necessary for the infinitesimals to be bivariate polynomials. The coefficients of the infinitesimals are found out by substituting them in the PDE and grouping similar terms that are polynomials and since they form a linear system, solve and check for non trivial solutions. The degree of the assumed bivariates are increased till a certain maximum value. References ========== - Lie Groups and Differential Equations pp. 327 - pp. 329
r""" The third heuristic assumes the infinitesimals `\xi` and `\eta` to be bi-variate polynomials in `x` and `y`. The assumption made here for the logic below is that `h` is a rational function in `x` and `y` though that may not be necessary for the infinitesimals to be bivariate polynomials. The coefficients of the infinitesimals are found out by substituting them in the PDE and grouping similar terms that are polynomials and since they form a linear system, solve and check for non trivial solutions. The degree of the assumed bivariates are increased till a certain maximum value.
[ "r", "The", "third", "heuristic", "assumes", "the", "infinitesimals", "\\", "xi", "and", "\\", "eta", "to", "be", "bi", "-", "variate", "polynomials", "in", "x", "and", "y", ".", "The", "assumption", "made", "here", "for", "the", "logic", "below", "is", ...
def lie_heuristic_bivariate(match, comp=False): r""" The third heuristic assumes the infinitesimals `\xi` and `\eta` to be bi-variate polynomials in `x` and `y`. The assumption made here for the logic below is that `h` is a rational function in `x` and `y` though that may not be necessary for the infinitesimals to be bivariate polynomials. The coefficients of the infinitesimals are found out by substituting them in the PDE and grouping similar terms that are polynomials and since they form a linear system, solve and check for non trivial solutions. The degree of the assumed bivariates are increased till a certain maximum value. References ========== - Lie Groups and Differential Equations pp. 327 - pp. 329 """ h = match['h'] hx = match['hx'] hy = match['hy'] func = match['func'] x = func.args[0] y = match['y'] xi = Function('xi')(x, func) eta = Function('eta')(x, func) if h.is_rational_function(): # The maximum degree that the infinitesimals can take is # calculated by this technique. etax, etay, etad, xix, xiy, xid = symbols("etax etay etad xix xiy xid") ipde = etax + (etay - xix)*h - xiy*h**2 - xid*hx - etad*hy num, denom = cancel(ipde).as_numer_denom() deg = Poly(num, x, y).total_degree() deta = Function('deta')(x, y) dxi = Function('dxi')(x, y) ipde = (deta.diff(x) + (deta.diff(y) - dxi.diff(x))*h - (dxi.diff(y))*h**2 - dxi*hx - deta*hy) xieq = Symbol("xi0") etaeq = Symbol("eta0") for i in range(deg + 1): if i: xieq += Add(*[ Symbol("xi_" + str(power) + "_" + str(i - power))*x**power*y**(i - power) for power in range(i + 1)]) etaeq += Add(*[ Symbol("eta_" + str(power) + "_" + str(i - power))*x**power*y**(i - power) for power in range(i + 1)]) pden, denom = (ipde.subs({dxi: xieq, deta: etaeq}).doit()).as_numer_denom() pden = expand(pden) # If the individual terms are monomials, the coefficients # are grouped if pden.is_polynomial(x, y) and pden.is_Add: polyy = Poly(pden, x, y).as_dict() if polyy: symset = xieq.free_symbols.union(etaeq.free_symbols) - {x, y} soldict = solve(polyy.values(), *symset) if isinstance(soldict, list): soldict = soldict[0] if any(soldict.values()): xired = xieq.subs(soldict) etared = etaeq.subs(soldict) # Scaling is done by substituting one for the parameters # This can be any number except zero. dict_ = dict((sym, 1) for sym in symset) inf = {eta: etared.subs(dict_).subs(y, func), xi: xired.subs(dict_).subs(y, func)} return [inf]
[ "def", "lie_heuristic_bivariate", "(", "match", ",", "comp", "=", "False", ")", ":", "h", "=", "match", "[", "'h'", "]", "hx", "=", "match", "[", "'hx'", "]", "hy", "=", "match", "[", "'hy'", "]", "func", "=", "match", "[", "'func'", "]", "x", "=...
https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/site-packages/sympy/solvers/ode.py#L6793-L6863
tribe29/checkmk
6260f2512e159e311f426e16b84b19d0b8e9ad0c
cmk/gui/views/__init__.py
python
_get_combined_graphs_entry
( view: View, info: VisualInfo, is_single_info: bool )
return PageMenuEntry( title=_("All metrics of same type in one graph"), icon_name="graph", item=make_simple_link(url), )
Detect whether or not to add a combined graphs link to the dropdown currently being rendered In which dropdown to expect the "All metrics of same type in one graph" link?
Detect whether or not to add a combined graphs link to the dropdown currently being rendered
[ "Detect", "whether", "or", "not", "to", "add", "a", "combined", "graphs", "link", "to", "the", "dropdown", "currently", "being", "rendered" ]
def _get_combined_graphs_entry( view: View, info: VisualInfo, is_single_info: bool ) -> Optional[PageMenuEntry]: """Detect whether or not to add a combined graphs link to the dropdown currently being rendered In which dropdown to expect the "All metrics of same type in one graph" link? """ if not _show_combined_graphs_context_button(view): return None if not _show_in_current_dropdown(view, info.ident, is_single_info): return None httpvars: HTTPVariables = [ ("single_infos", ",".join(view.spec["single_infos"])), ("datasource", view.datasource.ident), ("view_title", view_title(view.spec, view.context)), ] url = makeuri(request, httpvars, filename="combined_graphs.py") return PageMenuEntry( title=_("All metrics of same type in one graph"), icon_name="graph", item=make_simple_link(url), )
[ "def", "_get_combined_graphs_entry", "(", "view", ":", "View", ",", "info", ":", "VisualInfo", ",", "is_single_info", ":", "bool", ")", "->", "Optional", "[", "PageMenuEntry", "]", ":", "if", "not", "_show_combined_graphs_context_button", "(", "view", ")", ":", ...
https://github.com/tribe29/checkmk/blob/6260f2512e159e311f426e16b84b19d0b8e9ad0c/cmk/gui/views/__init__.py#L3105-L3130
TencentCloud/tencentcloud-sdk-python
3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2
tencentcloud/iai/v20200303/models.py
python
FaceQualityInfo.__init__
(self)
r""" :param Score: 质量分: [0,100],综合评价图像质量是否适合人脸识别,分数越高质量越好。 正常情况,只需要使用Score作为质量分总体的判断标准即可。Sharpness、Brightness、Completeness等细项分仅供参考。 参考范围:[0,40]较差,[40,60] 一般,[60,80]较好,[80,100]很好。 建议:人脸入库选取70以上的图片。 注意:此字段可能返回 null,表示取不到有效值。 :type Score: int :param Sharpness: 清晰分:[0,100],评价图片清晰程度,分数越高越清晰。 参考范围:[0,40]特别模糊,[40,60]模糊,[60,80]一般,[80,100]清晰。 建议:人脸入库选取80以上的图片。 注意:此字段可能返回 null,表示取不到有效值。 :type Sharpness: int :param Brightness: 光照分:[0,100],评价图片光照程度,分数越高越亮。 参考范围: [0,30]偏暗,[30,70]光照正常,[70,100]偏亮。 建议:人脸入库选取[30,70]的图片。 注意:此字段可能返回 null,表示取不到有效值。 :type Brightness: int :param Completeness: 五官遮挡分,评价眉毛(Eyebrow)、眼睛(Eye)、鼻子(Nose)、脸颊(Cheek)、嘴巴(Mouth)、下巴(Chin)的被遮挡程度。 注意:此字段可能返回 null,表示取不到有效值。 :type Completeness: :class:`tencentcloud.iai.v20200303.models.FaceQualityCompleteness`
r""" :param Score: 质量分: [0,100],综合评价图像质量是否适合人脸识别,分数越高质量越好。 正常情况,只需要使用Score作为质量分总体的判断标准即可。Sharpness、Brightness、Completeness等细项分仅供参考。 参考范围:[0,40]较差,[40,60] 一般,[60,80]较好,[80,100]很好。 建议:人脸入库选取70以上的图片。 注意:此字段可能返回 null,表示取不到有效值。 :type Score: int :param Sharpness: 清晰分:[0,100],评价图片清晰程度,分数越高越清晰。 参考范围:[0,40]特别模糊,[40,60]模糊,[60,80]一般,[80,100]清晰。 建议:人脸入库选取80以上的图片。 注意:此字段可能返回 null,表示取不到有效值。 :type Sharpness: int :param Brightness: 光照分:[0,100],评价图片光照程度,分数越高越亮。 参考范围: [0,30]偏暗,[30,70]光照正常,[70,100]偏亮。 建议:人脸入库选取[30,70]的图片。 注意:此字段可能返回 null,表示取不到有效值。 :type Brightness: int :param Completeness: 五官遮挡分,评价眉毛(Eyebrow)、眼睛(Eye)、鼻子(Nose)、脸颊(Cheek)、嘴巴(Mouth)、下巴(Chin)的被遮挡程度。 注意:此字段可能返回 null,表示取不到有效值。 :type Completeness: :class:`tencentcloud.iai.v20200303.models.FaceQualityCompleteness`
[ "r", ":", "param", "Score", ":", "质量分", ":", "[", "0", "100", "]", ",综合评价图像质量是否适合人脸识别,分数越高质量越好。", "正常情况,只需要使用Score作为质量分总体的判断标准即可。Sharpness、Brightness、Completeness等细项分仅供参考。", "参考范围:", "[", "0", "40", "]", "较差,", "[", "40", "60", "]", "一般,", "[", "60", "80", "]", ...
def __init__(self): r""" :param Score: 质量分: [0,100],综合评价图像质量是否适合人脸识别,分数越高质量越好。 正常情况,只需要使用Score作为质量分总体的判断标准即可。Sharpness、Brightness、Completeness等细项分仅供参考。 参考范围:[0,40]较差,[40,60] 一般,[60,80]较好,[80,100]很好。 建议:人脸入库选取70以上的图片。 注意:此字段可能返回 null,表示取不到有效值。 :type Score: int :param Sharpness: 清晰分:[0,100],评价图片清晰程度,分数越高越清晰。 参考范围:[0,40]特别模糊,[40,60]模糊,[60,80]一般,[80,100]清晰。 建议:人脸入库选取80以上的图片。 注意:此字段可能返回 null,表示取不到有效值。 :type Sharpness: int :param Brightness: 光照分:[0,100],评价图片光照程度,分数越高越亮。 参考范围: [0,30]偏暗,[30,70]光照正常,[70,100]偏亮。 建议:人脸入库选取[30,70]的图片。 注意:此字段可能返回 null,表示取不到有效值。 :type Brightness: int :param Completeness: 五官遮挡分,评价眉毛(Eyebrow)、眼睛(Eye)、鼻子(Nose)、脸颊(Cheek)、嘴巴(Mouth)、下巴(Chin)的被遮挡程度。 注意:此字段可能返回 null,表示取不到有效值。 :type Completeness: :class:`tencentcloud.iai.v20200303.models.FaceQualityCompleteness` """ self.Score = None self.Sharpness = None self.Brightness = None self.Completeness = None
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "Score", "=", "None", "self", ".", "Sharpness", "=", "None", "self", ".", "Brightness", "=", "None", "self", ".", "Completeness", "=", "None" ]
https://github.com/TencentCloud/tencentcloud-sdk-python/blob/3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2/tencentcloud/iai/v20200303/models.py#L2151-L2176
cloudera/impyla
0c736af4cad2bade9b8e313badc08ec50e81c948
impala/_thrift_gen/TCLIService/ttypes.py
python
TGetTypeInfoReq.read
(self, iprot)
[]
def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: (fname, ftype, fid) = iprot.readFieldBegin() if ftype == TType.STOP: break if fid == 1: if ftype == TType.STRUCT: self.sessionHandle = TSessionHandle() self.sessionHandle.read(iprot) else: iprot.skip(ftype) else: iprot.skip(ftype) iprot.readFieldEnd() iprot.readStructEnd()
[ "def", "read", "(", "self", ",", "iprot", ")", ":", "if", "iprot", ".", "_fast_decode", "is", "not", "None", "and", "isinstance", "(", "iprot", ".", "trans", ",", "TTransport", ".", "CReadableTransport", ")", "and", "self", ".", "thrift_spec", "is", "not...
https://github.com/cloudera/impyla/blob/0c736af4cad2bade9b8e313badc08ec50e81c948/impala/_thrift_gen/TCLIService/ttypes.py#L3825-L3843
huggingface/transformers
623b4f7c63f60cce917677ee704d6c93ee960b4b
src/transformers/models/gpt_neo/modeling_flax_gpt_neo.py
python
FlaxGPTNeoSelfAttention._concatenate_to_cache
(self, key, value, query, attention_mask)
return key, value, attention_mask
This function takes projected key, value states from a single input token and concatenates the states to cached states from previous steps. This function is slighly adapted from the official Flax repository: https://github.com/google/flax/blob/491ce18759622506588784b4fca0e4bf05f8c8cd/flax/linen/attention.py#L252
This function takes projected key, value states from a single input token and concatenates the states to cached states from previous steps. This function is slighly adapted from the official Flax repository: https://github.com/google/flax/blob/491ce18759622506588784b4fca0e4bf05f8c8cd/flax/linen/attention.py#L252
[ "This", "function", "takes", "projected", "key", "value", "states", "from", "a", "single", "input", "token", "and", "concatenates", "the", "states", "to", "cached", "states", "from", "previous", "steps", ".", "This", "function", "is", "slighly", "adapted", "fr...
def _concatenate_to_cache(self, key, value, query, attention_mask): """ This function takes projected key, value states from a single input token and concatenates the states to cached states from previous steps. This function is slighly adapted from the official Flax repository: https://github.com/google/flax/blob/491ce18759622506588784b4fca0e4bf05f8c8cd/flax/linen/attention.py#L252 """ # detect if we're initializing by absence of existing cache data. is_initialized = self.has_variable("cache", "cached_key") cached_key = self.variable("cache", "cached_key", jnp.zeros, key.shape, key.dtype) cached_value = self.variable("cache", "cached_value", jnp.zeros, value.shape, value.dtype) cache_index = self.variable("cache", "cache_index", lambda: jnp.array(0, dtype=jnp.int32)) if is_initialized: *batch_dims, max_length, num_heads, depth_per_head = cached_key.value.shape # update key, value caches with our new 1d spatial slices cur_index = cache_index.value indices = (0,) * len(batch_dims) + (cur_index, 0, 0) key = lax.dynamic_update_slice(cached_key.value, key, indices) value = lax.dynamic_update_slice(cached_value.value, value, indices) cached_key.value = key cached_value.value = value num_updated_cache_vectors = query.shape[1] cache_index.value = cache_index.value + num_updated_cache_vectors # causal mask for cached decoder self-attention: our single query position should only attend to those key positions that have already been generated and cached, not the remaining zero elements. pad_mask = jnp.broadcast_to( jnp.arange(max_length) < cur_index + num_updated_cache_vectors, tuple(batch_dims) + (1, num_updated_cache_vectors, max_length), ) attention_mask = combine_masks(pad_mask, attention_mask) return key, value, attention_mask
[ "def", "_concatenate_to_cache", "(", "self", ",", "key", ",", "value", ",", "query", ",", "attention_mask", ")", ":", "# detect if we're initializing by absence of existing cache data.", "is_initialized", "=", "self", ".", "has_variable", "(", "\"cache\"", ",", "\"cache...
https://github.com/huggingface/transformers/blob/623b4f7c63f60cce917677ee704d6c93ee960b4b/src/transformers/models/gpt_neo/modeling_flax_gpt_neo.py#L149-L178
glue-viz/glue
840b4c1364b0fa63bf67c914540c93dd71df41e1
glue/core/layer_artist.py
python
LayerArtistBase.disable_invalid_attributes
(self, *attributes)
Disable a layer because visualization depends on knowing a set of ComponentIDs that cannot be derived from a dataset or subset Automatically generates a disabled message. Parameters ---------- attributes : sequence of ComponentIDs
Disable a layer because visualization depends on knowing a set of ComponentIDs that cannot be derived from a dataset or subset
[ "Disable", "a", "layer", "because", "visualization", "depends", "on", "knowing", "a", "set", "of", "ComponentIDs", "that", "cannot", "be", "derived", "from", "a", "dataset", "or", "subset" ]
def disable_invalid_attributes(self, *attributes): """ Disable a layer because visualization depends on knowing a set of ComponentIDs that cannot be derived from a dataset or subset Automatically generates a disabled message. Parameters ---------- attributes : sequence of ComponentIDs """ if len(attributes) == 0: self.disable('') return datasets = ', '.join(sorted(set([cid.parent.label for cid in attributes]))) self.disable(DISABLED_LAYER_WARNING.format(datasets))
[ "def", "disable_invalid_attributes", "(", "self", ",", "*", "attributes", ")", ":", "if", "len", "(", "attributes", ")", "==", "0", ":", "self", ".", "disable", "(", "''", ")", "return", "datasets", "=", "', '", ".", "join", "(", "sorted", "(", "set", ...
https://github.com/glue-viz/glue/blob/840b4c1364b0fa63bf67c914540c93dd71df41e1/glue/core/layer_artist.py#L133-L149
daniilidis-group/neural_renderer
b2a1e6ce16a54f94f26f86fe1dc3814637e15251
neural_renderer/perspective.py
python
perspective
(vertices, angle=30.)
return vertices
Compute perspective distortion from a given angle
Compute perspective distortion from a given angle
[ "Compute", "perspective", "distortion", "from", "a", "given", "angle" ]
def perspective(vertices, angle=30.): ''' Compute perspective distortion from a given angle ''' if (vertices.ndimension() != 3): raise ValueError('vertices Tensor should have 3 dimensions') device = vertices.device angle = torch.tensor(angle / 180 * math.pi, dtype=torch.float32, device=device) angle = angle[None] width = torch.tan(angle) width = width[:, None] z = vertices[:, :, 2] x = vertices[:, :, 0] / z / width y = vertices[:, :, 1] / z / width vertices = torch.stack((x,y,z), dim=2) return vertices
[ "def", "perspective", "(", "vertices", ",", "angle", "=", "30.", ")", ":", "if", "(", "vertices", ".", "ndimension", "(", ")", "!=", "3", ")", ":", "raise", "ValueError", "(", "'vertices Tensor should have 3 dimensions'", ")", "device", "=", "vertices", ".",...
https://github.com/daniilidis-group/neural_renderer/blob/b2a1e6ce16a54f94f26f86fe1dc3814637e15251/neural_renderer/perspective.py#L6-L21
tensorflow/lingvo
ce10019243d954c3c3ebe739f7589b5eebfdf907
lingvo/core/py_utils.py
python
TensorSpecs
(nmap, keep_shape=True)
return Transform(fn, nmap)
Transforms tensors in the input nested structure to TensorSpecs.
Transforms tensors in the input nested structure to TensorSpecs.
[ "Transforms", "tensors", "in", "the", "input", "nested", "structure", "to", "TensorSpecs", "." ]
def TensorSpecs(nmap, keep_shape=True): """Transforms tensors in the input nested structure to TensorSpecs.""" if nmap is None: return None fn = lambda t: tf.TensorSpec(t.shape if keep_shape else None, t.dtype) return Transform(fn, nmap)
[ "def", "TensorSpecs", "(", "nmap", ",", "keep_shape", "=", "True", ")", ":", "if", "nmap", "is", "None", ":", "return", "None", "fn", "=", "lambda", "t", ":", "tf", ".", "TensorSpec", "(", "t", ".", "shape", "if", "keep_shape", "else", "None", ",", ...
https://github.com/tensorflow/lingvo/blob/ce10019243d954c3c3ebe739f7589b5eebfdf907/lingvo/core/py_utils.py#L5148-L5153
cloudera/hue
23f02102d4547c17c32bd5ea0eb24e9eadd657a4
desktop/core/ext-py/boto-2.46.1/boto/s3/multipart.py
python
MultiPartUpload.copy_part_from_key
(self, src_bucket_name, src_key_name, part_num, start=None, end=None, src_version_id=None, headers=None)
return self.bucket.copy_key(self.key_name, src_bucket_name, src_key_name, src_version_id=src_version_id, storage_class=None, headers=headers, query_args=query_args)
Copy another part of this MultiPart Upload. :type src_bucket_name: string :param src_bucket_name: Name of the bucket containing the source key :type src_key_name: string :param src_key_name: Name of the source key :type part_num: int :param part_num: The number of this part. :type start: int :param start: Zero-based byte offset to start copying from :type end: int :param end: Zero-based byte offset to copy to :type src_version_id: string :param src_version_id: version_id of source object to copy from :type headers: dict :param headers: Any headers to pass along in the request
Copy another part of this MultiPart Upload.
[ "Copy", "another", "part", "of", "this", "MultiPart", "Upload", "." ]
def copy_part_from_key(self, src_bucket_name, src_key_name, part_num, start=None, end=None, src_version_id=None, headers=None): """ Copy another part of this MultiPart Upload. :type src_bucket_name: string :param src_bucket_name: Name of the bucket containing the source key :type src_key_name: string :param src_key_name: Name of the source key :type part_num: int :param part_num: The number of this part. :type start: int :param start: Zero-based byte offset to start copying from :type end: int :param end: Zero-based byte offset to copy to :type src_version_id: string :param src_version_id: version_id of source object to copy from :type headers: dict :param headers: Any headers to pass along in the request """ if part_num < 1: raise ValueError('Part numbers must be greater than zero') query_args = 'uploadId=%s&partNumber=%d' % (self.id, part_num) if start is not None and end is not None: rng = 'bytes=%s-%s' % (start, end) provider = self.bucket.connection.provider if headers is None: headers = {} else: headers = headers.copy() headers[provider.copy_source_range_header] = rng return self.bucket.copy_key(self.key_name, src_bucket_name, src_key_name, src_version_id=src_version_id, storage_class=None, headers=headers, query_args=query_args)
[ "def", "copy_part_from_key", "(", "self", ",", "src_bucket_name", ",", "src_key_name", ",", "part_num", ",", "start", "=", "None", ",", "end", "=", "None", ",", "src_version_id", "=", "None", ",", "headers", "=", "None", ")", ":", "if", "part_num", "<", ...
https://github.com/cloudera/hue/blob/23f02102d4547c17c32bd5ea0eb24e9eadd657a4/desktop/core/ext-py/boto-2.46.1/boto/s3/multipart.py#L264-L307
GiulioRossetti/cdlib
b2c6311b99725bb2b029556f531d244a2af14a2a
cdlib/algorithms/internal/CONGA.py
python
remove_edge_or_split_vertex
(G)
return split
The heart of the CONGA algorithm. Decides which edge should be removed or which vertex should be split. Returns True if the modification split the graph.
The heart of the CONGA algorithm. Decides which edge should be removed or which vertex should be split. Returns True if the modification split the graph.
[ "The", "heart", "of", "the", "CONGA", "algorithm", ".", "Decides", "which", "edge", "should", "be", "removed", "or", "which", "vertex", "should", "be", "split", ".", "Returns", "True", "if", "the", "modification", "split", "the", "graph", "." ]
def remove_edge_or_split_vertex(G): """ The heart of the CONGA algorithm. Decides which edge should be removed or which vertex should be split. Returns True if the modification split the graph. """ # has the graph split this iteration? split = False eb = G.edge_betweenness() maxIndex, maxEb = max(enumerate(eb), key=operator.itemgetter(1)) # We might be able to calculate vertex betweenness and edge # betweenness at the same time. The current internal is slower # than the builtin, though. vb = G.betweenness() # Only consider vertices with vertex betweenness >= max # edge betweenness. From Gregory 2007 step 3 vi = [i for i, b in enumerate(vb) if b > maxEb] edge = G.es[maxIndex].tuple if not vi: split = delete_edge(G, edge) else: pb = pair_betweenness(G, vi) maxSplit, vNum, splitInstructions = max_split_betweenness(G, pb) if maxSplit > maxEb: split = split_vertex(G, vNum, splitInstructions[0]) else: split = delete_edge(G, edge) return split
[ "def", "remove_edge_or_split_vertex", "(", "G", ")", ":", "# has the graph split this iteration?", "split", "=", "False", "eb", "=", "G", ".", "edge_betweenness", "(", ")", "maxIndex", ",", "maxEb", "=", "max", "(", "enumerate", "(", "eb", ")", ",", "key", "...
https://github.com/GiulioRossetti/cdlib/blob/b2c6311b99725bb2b029556f531d244a2af14a2a/cdlib/algorithms/internal/CONGA.py#L314-L345
plotly/plotly.py
cfad7862594b35965c0e000813bd7805e8494a5b
packages/python/plotly/plotly/graph_objs/_cone.py
python
Cone.xhoverformat
(self)
return self["xhoverformat"]
Sets the hover text formatting rulefor `x` using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format. And for dates see: https://github.com/d3/d3-time- format/tree/v2.2.3#locale_format. We add two items to d3's date formatter: "%h" for half of the year as a decimal number as well as "%{n}f" for fractional seconds with n digits. For example, *2016-10-13 09:15:23.456* with tickformat "%H~%M~%S.%2f" would display *09~15~23.46*By default the values are formatted using `xaxis.hoverformat`. The 'xhoverformat' property is a string and must be specified as: - A string - A number that will be converted to a string Returns ------- str
Sets the hover text formatting rulefor `x` using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format. And for dates see: https://github.com/d3/d3-time- format/tree/v2.2.3#locale_format. We add two items to d3's date formatter: "%h" for half of the year as a decimal number as well as "%{n}f" for fractional seconds with n digits. For example, *2016-10-13 09:15:23.456* with tickformat "%H~%M~%S.%2f" would display *09~15~23.46*By default the values are formatted using `xaxis.hoverformat`. The 'xhoverformat' property is a string and must be specified as: - A string - A number that will be converted to a string
[ "Sets", "the", "hover", "text", "formatting", "rulefor", "x", "using", "d3", "formatting", "mini", "-", "languages", "which", "are", "very", "similar", "to", "those", "in", "Python", ".", "For", "numbers", "see", ":", "https", ":", "//", "github", ".", "...
def xhoverformat(self): """ Sets the hover text formatting rulefor `x` using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format. And for dates see: https://github.com/d3/d3-time- format/tree/v2.2.3#locale_format. We add two items to d3's date formatter: "%h" for half of the year as a decimal number as well as "%{n}f" for fractional seconds with n digits. For example, *2016-10-13 09:15:23.456* with tickformat "%H~%M~%S.%2f" would display *09~15~23.46*By default the values are formatted using `xaxis.hoverformat`. The 'xhoverformat' property is a string and must be specified as: - A string - A number that will be converted to a string Returns ------- str """ return self["xhoverformat"]
[ "def", "xhoverformat", "(", "self", ")", ":", "return", "self", "[", "\"xhoverformat\"", "]" ]
https://github.com/plotly/plotly.py/blob/cfad7862594b35965c0e000813bd7805e8494a5b/packages/python/plotly/plotly/graph_objs/_cone.py#L1617-L1639
riverloopsec/tumblerf
ad79f9dbbfee0612433be3d71c859d6918395f10
tumblerf/generators/base.py
python
BaseTestCaseGenerator.yield_control_case
(self, count=1)
Is a Python generator which yields potential control cases. These can be transmitted to gauge if the environment is ready for testing. These should cause the expected "valid" behavior on the target, e.g., causing an ACK response. :yield: A byte array generated as a control case.
Is a Python generator which yields potential control cases. These can be transmitted to gauge if the environment is ready for testing. These should cause the expected "valid" behavior on the target, e.g., causing an ACK response. :yield: A byte array generated as a control case.
[ "Is", "a", "Python", "generator", "which", "yields", "potential", "control", "cases", ".", "These", "can", "be", "transmitted", "to", "gauge", "if", "the", "environment", "is", "ready", "for", "testing", ".", "These", "should", "cause", "the", "expected", "v...
def yield_control_case(self, count=1): """ Is a Python generator which yields potential control cases. These can be transmitted to gauge if the environment is ready for testing. These should cause the expected "valid" behavior on the target, e.g., causing an ACK response. :yield: A byte array generated as a control case. """ raise NotImplementedError
[ "def", "yield_control_case", "(", "self", ",", "count", "=", "1", ")", ":", "raise", "NotImplementedError" ]
https://github.com/riverloopsec/tumblerf/blob/ad79f9dbbfee0612433be3d71c859d6918395f10/tumblerf/generators/base.py#L86-L93
python-openxml/python-docx
36cac78de080d412e9e50d56c2784e33655cad59
docx/table.py
python
Table.cell
(self, row_idx, col_idx)
return self._cells[cell_idx]
Return |_Cell| instance correponding to table cell at *row_idx*, *col_idx* intersection, where (0, 0) is the top, left-most cell.
Return |_Cell| instance correponding to table cell at *row_idx*, *col_idx* intersection, where (0, 0) is the top, left-most cell.
[ "Return", "|_Cell|", "instance", "correponding", "to", "table", "cell", "at", "*", "row_idx", "*", "*", "col_idx", "*", "intersection", "where", "(", "0", "0", ")", "is", "the", "top", "left", "-", "most", "cell", "." ]
def cell(self, row_idx, col_idx): """ Return |_Cell| instance correponding to table cell at *row_idx*, *col_idx* intersection, where (0, 0) is the top, left-most cell. """ cell_idx = col_idx + (row_idx * self._column_count) return self._cells[cell_idx]
[ "def", "cell", "(", "self", ",", "row_idx", ",", "col_idx", ")", ":", "cell_idx", "=", "col_idx", "+", "(", "row_idx", "*", "self", ".", "_column_count", ")", "return", "self", ".", "_cells", "[", "cell_idx", "]" ]
https://github.com/python-openxml/python-docx/blob/36cac78de080d412e9e50d56c2784e33655cad59/docx/table.py#L75-L81
deepfakes/faceswap
09c7d8aca3c608d1afad941ea78e9fd9b64d9219
plugins/train/model/_base.py
python
_Inference._get_filtered_structure
(self)
return struct
Obtain the structure of the inference model. This parses the model config (in reverse) to obtain the required layers for an inference model. Returns ------- :class:`collections.OrderedDict` The layer name as key with the input name and output index as value.
Obtain the structure of the inference model.
[ "Obtain", "the", "structure", "of", "the", "inference", "model", "." ]
def _get_filtered_structure(self): """ Obtain the structure of the inference model. This parses the model config (in reverse) to obtain the required layers for an inference model. Returns ------- :class:`collections.OrderedDict` The layer name as key with the input name and output index as value. """ # Filter output layer out = np.array(self._config["output_layers"], dtype="object") if out.ndim == 2: out = np.expand_dims(out, axis=1) # Needs to be expanded for _get_nodes outputs = self._get_nodes(out) # Iterate backwards from the required output to get the reversed model structure current_layers = [outputs[0]] next_layers = [] struct = OrderedDict() drop_input = self._input_names[abs(self._input_idx - 1)] switch_input = self._input_names[self._input_idx] while True: layer_info = current_layers.pop(0) current_layer = next(lyr for lyr in self._config["layers"] if lyr["name"] == layer_info[0]) inbound = current_layer["inbound_nodes"] if not inbound: break inbound_info = self._get_nodes(inbound) if any(inb[0] == drop_input for inb in inbound_info): # Switch inputs inbound_info = [(switch_input if inb[0] == drop_input else inb[0], inb[1]) for inb in inbound_info] struct[layer_info[0]] = inbound_info next_layers.extend(inbound_info) if not current_layers: current_layers = next_layers next_layers = [] struct[switch_input] = [] # Add the input layer logger.debug("Model structure: %s", struct) return struct
[ "def", "_get_filtered_structure", "(", "self", ")", ":", "# Filter output layer", "out", "=", "np", ".", "array", "(", "self", ".", "_config", "[", "\"output_layers\"", "]", ",", "dtype", "=", "\"object\"", ")", "if", "out", ".", "ndim", "==", "2", ":", ...
https://github.com/deepfakes/faceswap/blob/09c7d8aca3c608d1afad941ea78e9fd9b64d9219/plugins/train/model/_base.py#L1711-L1757