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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
eliben/pyelftools | 8f7a0becaface09435c4374947548b7851e3d1a2 | elftools/dwarf/die.py | python | DIE.__init__ | (self, cu, stream, offset) | cu:
CompileUnit object this DIE belongs to. Used to obtain context
information (structs, abbrev table, etc.)
stream, offset:
The stream and offset into it where this DIE's data is located | cu:
CompileUnit object this DIE belongs to. Used to obtain context
information (structs, abbrev table, etc.) | [
"cu",
":",
"CompileUnit",
"object",
"this",
"DIE",
"belongs",
"to",
".",
"Used",
"to",
"obtain",
"context",
"information",
"(",
"structs",
"abbrev",
"table",
"etc",
".",
")"
] | def __init__(self, cu, stream, offset):
""" cu:
CompileUnit object this DIE belongs to. Used to obtain context
information (structs, abbrev table, etc.)
stream, offset:
The stream and offset into it where this DIE's data is located
"""
... | [
"def",
"__init__",
"(",
"self",
",",
"cu",
",",
"stream",
",",
"offset",
")",
":",
"self",
".",
"cu",
"=",
"cu",
"self",
".",
"dwarfinfo",
"=",
"self",
".",
"cu",
".",
"dwarfinfo",
"# get DWARFInfo context",
"self",
".",
"stream",
"=",
"stream",
"self"... | https://github.com/eliben/pyelftools/blob/8f7a0becaface09435c4374947548b7851e3d1a2/elftools/dwarf/die.py#L71-L94 | ||
golismero/golismero | 7d605b937e241f51c1ca4f47b20f755eeefb9d76 | tools/sqlmap/thirdparty/bottle/bottle.py | python | run | (app=None, server='wsgiref', host='127.0.0.1', port=8080,
interval=1, reloader=False, quiet=False, plugins=None,
debug=False, **kargs) | Start a server instance. This method blocks until the server terminates.
:param app: WSGI application or target string supported by
:func:`load_app`. (default: :func:`default_app`)
:param server: Server adapter to use. See :data:`server_names` keys
for valid names or pass ... | Start a server instance. This method blocks until the server terminates. | [
"Start",
"a",
"server",
"instance",
".",
"This",
"method",
"blocks",
"until",
"the",
"server",
"terminates",
"."
] | def run(app=None, server='wsgiref', host='127.0.0.1', port=8080,
interval=1, reloader=False, quiet=False, plugins=None,
debug=False, **kargs):
""" Start a server instance. This method blocks until the server terminates.
:param app: WSGI application or target string supported by
... | [
"def",
"run",
"(",
"app",
"=",
"None",
",",
"server",
"=",
"'wsgiref'",
",",
"host",
"=",
"'127.0.0.1'",
",",
"port",
"=",
"8080",
",",
"interval",
"=",
"1",
",",
"reloader",
"=",
"False",
",",
"quiet",
"=",
"False",
",",
"plugins",
"=",
"None",
",... | https://github.com/golismero/golismero/blob/7d605b937e241f51c1ca4f47b20f755eeefb9d76/tools/sqlmap/thirdparty/bottle/bottle.py#L2629-L2717 | ||
pikpikcu/Pentest-Tools-Framework | cd6e6107764a809943dc4e073cde8149c1a2cd03 | modules/dirsearch/thirdparty/requests/utils.py | python | select_proxy | (url, proxies) | return proxy | Select a proxy for the url, if applicable.
:param url: The url being for the request
:param proxies: A dictionary of schemes or schemes and hosts to proxy URLs | Select a proxy for the url, if applicable. | [
"Select",
"a",
"proxy",
"for",
"the",
"url",
"if",
"applicable",
"."
] | def select_proxy(url, proxies):
"""Select a proxy for the url, if applicable.
:param url: The url being for the request
:param proxies: A dictionary of schemes or schemes and hosts to proxy URLs
"""
proxies = proxies or {}
urlparts = urlparse(url)
proxy = proxies.get(urlparts.scheme+'://'+u... | [
"def",
"select_proxy",
"(",
"url",
",",
"proxies",
")",
":",
"proxies",
"=",
"proxies",
"or",
"{",
"}",
"urlparts",
"=",
"urlparse",
"(",
"url",
")",
"proxy",
"=",
"proxies",
".",
"get",
"(",
"urlparts",
".",
"scheme",
"+",
"'://'",
"+",
"urlparts",
... | https://github.com/pikpikcu/Pentest-Tools-Framework/blob/cd6e6107764a809943dc4e073cde8149c1a2cd03/modules/dirsearch/thirdparty/requests/utils.py#L540-L551 | |
cournape/Bento | 37de23d784407a7c98a4a15770ffc570d5f32d70 | bento/private/_yaku/yaku/tools/cxxtasks.py | python | CXXBuilder.clone | (self) | return CXXBuilder(self.ctx) | [] | def clone(self):
return CXXBuilder(self.ctx) | [
"def",
"clone",
"(",
"self",
")",
":",
"return",
"CXXBuilder",
"(",
"self",
".",
"ctx",
")"
] | https://github.com/cournape/Bento/blob/37de23d784407a7c98a4a15770ffc570d5f32d70/bento/private/_yaku/yaku/tools/cxxtasks.py#L66-L67 | |||
EventGhost/EventGhost | 177be516849e74970d2e13cda82244be09f277ce | eg/Classes/Log.py | python | Log.PrintDebugNotice | (self, *args) | Logs a message if eg.debugLevel is set. | Logs a message if eg.debugLevel is set. | [
"Logs",
"a",
"message",
"if",
"eg",
".",
"debugLevel",
"is",
"set",
"."
] | def PrintDebugNotice(self, *args):
"""
Logs a message if eg.debugLevel is set.
"""
if eg.debugLevel:
msg = _build_notice(DEBUG_ICON, args)
self.Write(msg, DEBUG_ICON) | [
"def",
"PrintDebugNotice",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"eg",
".",
"debugLevel",
":",
"msg",
"=",
"_build_notice",
"(",
"DEBUG_ICON",
",",
"args",
")",
"self",
".",
"Write",
"(",
"msg",
",",
"DEBUG_ICON",
")"
] | https://github.com/EventGhost/EventGhost/blob/177be516849e74970d2e13cda82244be09f277ce/eg/Classes/Log.py#L187-L193 | ||
buke/GreenOdoo | 3d8c55d426fb41fdb3f2f5a1533cfe05983ba1df | runtime/python/lib/python2.7/site-packages/Werkzeug-0.8.3-py2.7.egg/werkzeug/contrib/sessions.py | python | ModificationTrackingDict.copy | (self) | return result | Create a flat copy of the dict. | Create a flat copy of the dict. | [
"Create",
"a",
"flat",
"copy",
"of",
"the",
"dict",
"."
] | def copy(self):
"""Create a flat copy of the dict."""
missing = object()
result = object.__new__(self.__class__)
for name in self.__slots__:
val = getattr(self, name, missing)
if val is not missing:
setattr(result, name, val)
return result | [
"def",
"copy",
"(",
"self",
")",
":",
"missing",
"=",
"object",
"(",
")",
"result",
"=",
"object",
".",
"__new__",
"(",
"self",
".",
"__class__",
")",
"for",
"name",
"in",
"self",
".",
"__slots__",
":",
"val",
"=",
"getattr",
"(",
"self",
",",
"nam... | https://github.com/buke/GreenOdoo/blob/3d8c55d426fb41fdb3f2f5a1533cfe05983ba1df/runtime/python/lib/python2.7/site-packages/Werkzeug-0.8.3-py2.7.egg/werkzeug/contrib/sessions.py#L96-L104 | |
bruderstein/PythonScript | df9f7071ddf3a079e3a301b9b53a6dc78cf1208f | PythonLib/full/enum.py | python | Enum.__reduce_ex__ | (self, proto) | return self.__class__, (self._value_, ) | [] | def __reduce_ex__(self, proto):
return self.__class__, (self._value_, ) | [
"def",
"__reduce_ex__",
"(",
"self",
",",
"proto",
")",
":",
"return",
"self",
".",
"__class__",
",",
"(",
"self",
".",
"_value_",
",",
")"
] | https://github.com/bruderstein/PythonScript/blob/df9f7071ddf3a079e3a301b9b53a6dc78cf1208f/PythonLib/full/enum.py#L786-L787 | |||
etetoolkit/ete | 2b207357dc2a40ccad7bfd8f54964472c72e4726 | examples/treeview/item_faces.py | python | random_color | (h=None) | return _hls2hex(h, l, s) | Generates a random color in RGB format. | Generates a random color in RGB format. | [
"Generates",
"a",
"random",
"color",
"in",
"RGB",
"format",
"."
] | def random_color(h=None):
"""Generates a random color in RGB format."""
if not h:
h = random.random()
s = 0.5
l = 0.5
return _hls2hex(h, l, s) | [
"def",
"random_color",
"(",
"h",
"=",
"None",
")",
":",
"if",
"not",
"h",
":",
"h",
"=",
"random",
".",
"random",
"(",
")",
"s",
"=",
"0.5",
"l",
"=",
"0.5",
"return",
"_hls2hex",
"(",
"h",
",",
"l",
",",
"s",
")"
] | https://github.com/etetoolkit/ete/blob/2b207357dc2a40ccad7bfd8f54964472c72e4726/examples/treeview/item_faces.py#L42-L48 | |
wintoncode/winton-kafka-streams | 5867a1c42fc80bba07173fd1d004b2849b429fdf | winton_kafka_streams/processor/processor_context.py | python | ProcessorContext.forward | (self, key, value) | Forward the key/value to the next node in the topology | Forward the key/value to the next node in the topology | [
"Forward",
"the",
"key",
"/",
"value",
"to",
"the",
"next",
"node",
"in",
"the",
"topology"
] | def forward(self, key, value):
"""
Forward the key/value to the next node in the topology
"""
previous_node = self.current_node
try:
for child in self.current_node.children:
self.current_node = child
child.process(key, value)
f... | [
"def",
"forward",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"previous_node",
"=",
"self",
".",
"current_node",
"try",
":",
"for",
"child",
"in",
"self",
".",
"current_node",
".",
"children",
":",
"self",
".",
"current_node",
"=",
"child",
"child",... | https://github.com/wintoncode/winton-kafka-streams/blob/5867a1c42fc80bba07173fd1d004b2849b429fdf/winton_kafka_streams/processor/processor_context.py#L40-L51 | ||
dpp/simply_lift | cf49f7dcce81c7f1557314dd0f0bb08aaedc73da | elyxer.py | python | Path.getmtime | (self) | return os.path.getmtime(self.path) | Return last modification time | Return last modification time | [
"Return",
"last",
"modification",
"time"
] | def getmtime(self):
"Return last modification time"
return os.path.getmtime(self.path) | [
"def",
"getmtime",
"(",
"self",
")",
":",
"return",
"os",
".",
"path",
".",
"getmtime",
"(",
"self",
".",
"path",
")"
] | https://github.com/dpp/simply_lift/blob/cf49f7dcce81c7f1557314dd0f0bb08aaedc73da/elyxer.py#L6215-L6217 | |
holzschu/Carnets | 44effb10ddfc6aa5c8b0687582a724ba82c6b547 | Library/lib/python3.7/random.py | python | Random.vonmisesvariate | (self, mu, kappa) | return theta | Circular data distribution.
mu is the mean angle, expressed in radians between 0 and 2*pi, and
kappa is the concentration parameter, which must be greater than or
equal to zero. If kappa is equal to zero, this distribution reduces
to a uniform random angle over the range 0 to 2*pi. | Circular data distribution. | [
"Circular",
"data",
"distribution",
"."
] | def vonmisesvariate(self, mu, kappa):
"""Circular data distribution.
mu is the mean angle, expressed in radians between 0 and 2*pi, and
kappa is the concentration parameter, which must be greater than or
equal to zero. If kappa is equal to zero, this distribution reduces
to a u... | [
"def",
"vonmisesvariate",
"(",
"self",
",",
"mu",
",",
"kappa",
")",
":",
"# mu: mean angle (in radians between 0 and 2*pi)",
"# kappa: concentration parameter kappa (>= 0)",
"# if kappa = 0 generate uniform random angle",
"# Based upon an algorithm published in: Fisher, N.I.,",
"# \"... | https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/random.py#L456-L500 | |
s-block/django-nested-inline | 51936d8c003c8619b5f952dfb177385931ad62d5 | nested_inline/admin.py | python | NestedModelAdmin.save_formset | (self, request, form, formset, change) | Given an inline formset save it to the database. | Given an inline formset save it to the database. | [
"Given",
"an",
"inline",
"formset",
"save",
"it",
"to",
"the",
"database",
"."
] | def save_formset(self, request, form, formset, change):
"""
Given an inline formset save it to the database.
"""
formset.save()
for form in formset.forms:
if hasattr(form, 'nested_formsets') and form not in formset.deleted_forms:
for nested_formset in... | [
"def",
"save_formset",
"(",
"self",
",",
"request",
",",
"form",
",",
"formset",
",",
"change",
")",
":",
"formset",
".",
"save",
"(",
")",
"for",
"form",
"in",
"formset",
".",
"forms",
":",
"if",
"hasattr",
"(",
"form",
",",
"'nested_formsets'",
")",
... | https://github.com/s-block/django-nested-inline/blob/51936d8c003c8619b5f952dfb177385931ad62d5/nested_inline/admin.py#L54-L63 | ||
llSourcell/AI_Artist | 3038c06c2e389b9c919c881c9a169efe2fd7810e | lib/python2.7/site-packages/pip/_vendor/requests/utils.py | python | get_netrc_auth | (url, raise_errors=False) | Returns the Requests tuple auth for a given url from netrc. | Returns the Requests tuple auth for a given url from netrc. | [
"Returns",
"the",
"Requests",
"tuple",
"auth",
"for",
"a",
"given",
"url",
"from",
"netrc",
"."
] | def get_netrc_auth(url, raise_errors=False):
"""Returns the Requests tuple auth for a given url from netrc."""
try:
from netrc import netrc, NetrcParseError
netrc_path = None
for f in NETRC_FILES:
try:
loc = os.path.expanduser('~/{0}'.format(f))
... | [
"def",
"get_netrc_auth",
"(",
"url",
",",
"raise_errors",
"=",
"False",
")",
":",
"try",
":",
"from",
"netrc",
"import",
"netrc",
",",
"NetrcParseError",
"netrc_path",
"=",
"None",
"for",
"f",
"in",
"NETRC_FILES",
":",
"try",
":",
"loc",
"=",
"os",
".",
... | https://github.com/llSourcell/AI_Artist/blob/3038c06c2e389b9c919c881c9a169efe2fd7810e/lib/python2.7/site-packages/pip/_vendor/requests/utils.py#L96-L144 | ||
reviewboard/reviewboard | 7395902e4c181bcd1d633f61105012ffb1d18e1b | reviewboard/reviews/models/review_request.py | python | ReviewRequest.close | (self, close_type=None, user=None, description=None,
rich_text=False, **kwargs) | Closes the review request.
Args:
close_type (unicode):
How the close occurs. This should be one of
:py:attr:`SUBMITTED` or :py:attr:`DISCARDED`.
user (django.contrib.auth.models.User):
The user who is closing the review request.
... | Closes the review request. | [
"Closes",
"the",
"review",
"request",
"."
] | def close(self, close_type=None, user=None, description=None,
rich_text=False, **kwargs):
"""Closes the review request.
Args:
close_type (unicode):
How the close occurs. This should be one of
:py:attr:`SUBMITTED` or :py:attr:`DISCARDED`.
... | [
"def",
"close",
"(",
"self",
",",
"close_type",
"=",
"None",
",",
"user",
"=",
"None",
",",
"description",
"=",
"None",
",",
"rich_text",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"close_type",
"is",
"None",
":",
"try",
":",
"close_type"... | https://github.com/reviewboard/reviewboard/blob/7395902e4c181bcd1d633f61105012ffb1d18e1b/reviewboard/reviews/models/review_request.py#L951-L1068 | ||
JiYou/openstack | 8607dd488bde0905044b303eb6e52bdea6806923 | packages/source/ceilometer/tools/notificationclient.py | python | monitor_messages | (connection, topic) | Listen to notification.info messages and print them. | Listen to notification.info messages and print them. | [
"Listen",
"to",
"notification",
".",
"info",
"messages",
"and",
"print",
"them",
"."
] | def monitor_messages(connection, topic):
"""Listen to notification.info messages and print them."""
def process_event(msg):
body = msg['args']['data']
if 'resource_id' in body:
print ('%s: %s/%-15s: %s' %
(body.get('timestamp'),
body.get('resour... | [
"def",
"monitor_messages",
"(",
"connection",
",",
"topic",
")",
":",
"def",
"process_event",
"(",
"msg",
")",
":",
"body",
"=",
"msg",
"[",
"'args'",
"]",
"[",
"'data'",
"]",
"if",
"'resource_id'",
"in",
"body",
":",
"print",
"(",
"'%s: %s/%-15s: %s'",
... | https://github.com/JiYou/openstack/blob/8607dd488bde0905044b303eb6e52bdea6806923/packages/source/ceilometer/tools/notificationclient.py#L53-L74 | ||
robotframework/RIDE | 6e8a50774ff33dead3a2757a11b0b4418ab205c0 | src/robotide/lib/robot/libraries/BuiltIn.py | python | _Misc.evaluate | (self, expression, modules=None, namespace=None) | Evaluates the given expression in Python and returns the results.
``expression`` is evaluated in Python as explained in `Evaluating
expressions`.
``modules`` argument can be used to specify a comma separated
list of Python modules to be imported and added to the evaluation
name... | Evaluates the given expression in Python and returns the results. | [
"Evaluates",
"the",
"given",
"expression",
"in",
"Python",
"and",
"returns",
"the",
"results",
"."
] | def evaluate(self, expression, modules=None, namespace=None):
"""Evaluates the given expression in Python and returns the results.
``expression`` is evaluated in Python as explained in `Evaluating
expressions`.
``modules`` argument can be used to specify a comma separated
list ... | [
"def",
"evaluate",
"(",
"self",
",",
"expression",
",",
"modules",
"=",
"None",
",",
"namespace",
"=",
"None",
")",
":",
"if",
"is_string",
"(",
"expression",
")",
"and",
"'$'",
"in",
"expression",
":",
"expression",
",",
"variables",
"=",
"self",
".",
... | https://github.com/robotframework/RIDE/blob/6e8a50774ff33dead3a2757a11b0b4418ab205c0/src/robotide/lib/robot/libraries/BuiltIn.py#L2958-L3003 | ||
hzlzh/AlfredWorkflow.com | 7055f14f6922c80ea5943839eb0caff11ae57255 | Sources/Workflows/alfred-pushbullet/lib/requests/packages/urllib3/connectionpool.py | python | HTTPConnectionPool._make_request | (self, conn, method, url, timeout=_Default,
**httplib_request_kw) | return httplib_response | Perform a request on a given urllib connection object taken from our
pool.
:param conn:
a connection from one of our connection pools
:param timeout:
Socket timeout in seconds for the request. This can be a
float or integer, which will set the same timeout v... | Perform a request on a given urllib connection object taken from our
pool. | [
"Perform",
"a",
"request",
"on",
"a",
"given",
"urllib",
"connection",
"object",
"taken",
"from",
"our",
"pool",
"."
] | def _make_request(self, conn, method, url, timeout=_Default,
**httplib_request_kw):
"""
Perform a request on a given urllib connection object taken from our
pool.
:param conn:
a connection from one of our connection pools
:param timeout:
... | [
"def",
"_make_request",
"(",
"self",
",",
"conn",
",",
"method",
",",
"url",
",",
"timeout",
"=",
"_Default",
",",
"*",
"*",
"httplib_request_kw",
")",
":",
"self",
".",
"num_requests",
"+=",
"1",
"timeout_obj",
"=",
"self",
".",
"_get_timeout",
"(",
"ti... | https://github.com/hzlzh/AlfredWorkflow.com/blob/7055f14f6922c80ea5943839eb0caff11ae57255/Sources/Workflows/alfred-pushbullet/lib/requests/packages/urllib3/connectionpool.py#L321-L396 | |
PaddlePaddle/PaddleHub | 107ee7e1a49d15e9c94da3956475d88a53fc165f | paddlehub/module/cv_module.py | python | ImageColorizeModule.run_cmd | (self, argvs: list) | return results | Run as a command. | Run as a command. | [
"Run",
"as",
"a",
"command",
"."
] | def run_cmd(self, argvs: list):
"""
Run as a command.
"""
self.parser = argparse.ArgumentParser(
description="Run the {} module.".format(self.name),
prog='hub run {}'.format(self.name),
usage='%(prog)s',
add_help=True)
self.arg_inpu... | [
"def",
"run_cmd",
"(",
"self",
",",
"argvs",
":",
"list",
")",
":",
"self",
".",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"Run the {} module.\"",
".",
"format",
"(",
"self",
".",
"name",
")",
",",
"prog",
"=",
"'hub ru... | https://github.com/PaddlePaddle/PaddleHub/blob/107ee7e1a49d15e9c94da3956475d88a53fc165f/paddlehub/module/cv_module.py#L294-L311 | |
pjkundert/cpppo | 4c217b6c06b88bede3888cc5ea2731f271a95086 | automata.py | python | remembering.__init__ | ( self, *args, **kwds ) | [] | def __init__( self, *args, **kwds ):
super( remembering, self ).__init__( *args, **kwds )
self.memory = [] | [
"def",
"__init__",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwds",
")",
":",
"super",
"(",
"remembering",
",",
"self",
")",
".",
"__init__",
"(",
"*",
"args",
",",
"*",
"*",
"kwds",
")",
"self",
".",
"memory",
"=",
"[",
"]"
] | https://github.com/pjkundert/cpppo/blob/4c217b6c06b88bede3888cc5ea2731f271a95086/automata.py#L240-L242 | ||||
grnet/synnefo | d06ec8c7871092131cdaabf6b03ed0b504c93e43 | snf-astakos-app/astakos/im/util.py | python | restrict_reverse | (*args, **kwargs) | return restrict_next(url, domain=domain) | Like reverse, with an additional restrict_next call to the reverse result. | Like reverse, with an additional restrict_next call to the reverse result. | [
"Like",
"reverse",
"with",
"an",
"additional",
"restrict_next",
"call",
"to",
"the",
"reverse",
"result",
"."
] | def restrict_reverse(*args, **kwargs):
"""
Like reverse, with an additional restrict_next call to the reverse result.
"""
domain = kwargs.pop('restrict_domain', settings.COOKIE_DOMAIN)
url = reverse(*args, **kwargs)
return restrict_next(url, domain=domain) | [
"def",
"restrict_reverse",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"domain",
"=",
"kwargs",
".",
"pop",
"(",
"'restrict_domain'",
",",
"settings",
".",
"COOKIE_DOMAIN",
")",
"url",
"=",
"reverse",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",... | https://github.com/grnet/synnefo/blob/d06ec8c7871092131cdaabf6b03ed0b504c93e43/snf-astakos-app/astakos/im/util.py#L168-L174 | |
21dotco/two1-python | 4e833300fd5a58363e3104ed4c097631e5d296d3 | two1/bitcoin/utils.py | python | pack_u32 | (i) | return struct.pack('<I', i) | Serializes a 32-bit integer into little-endian form.
Args:
i (int): integer to be serialized.
Returns:
b (bytes): 4 bytes containing the little-endian serialization of i. | Serializes a 32-bit integer into little-endian form. | [
"Serializes",
"a",
"32",
"-",
"bit",
"integer",
"into",
"little",
"-",
"endian",
"form",
"."
] | def pack_u32(i):
""" Serializes a 32-bit integer into little-endian form.
Args:
i (int): integer to be serialized.
Returns:
b (bytes): 4 bytes containing the little-endian serialization of i.
"""
return struct.pack('<I', i) | [
"def",
"pack_u32",
"(",
"i",
")",
":",
"return",
"struct",
".",
"pack",
"(",
"'<I'",
",",
"i",
")"
] | https://github.com/21dotco/two1-python/blob/4e833300fd5a58363e3104ed4c097631e5d296d3/two1/bitcoin/utils.py#L135-L144 | |
LonamiWebs/Telethon | f9643bf7376a5953da2050a5361c9b465f7ee7d9 | telethon_examples/gui.py | python | App.send_message | (self, event=None) | Sends a message. Does nothing if the client is not connected. | Sends a message. Does nothing if the client is not connected. | [
"Sends",
"a",
"message",
".",
"Does",
"nothing",
"if",
"the",
"client",
"is",
"not",
"connected",
"."
] | async def send_message(self, event=None):
"""
Sends a message. Does nothing if the client is not connected.
"""
if not self.cl.is_connected():
return
# The user needs to configure a chat where the message should be sent.
#
# If the chat ID does not ex... | [
"async",
"def",
"send_message",
"(",
"self",
",",
"event",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"cl",
".",
"is_connected",
"(",
")",
":",
"return",
"# The user needs to configure a chat where the message should be sent.",
"#",
"# If the chat ID does not ex... | https://github.com/LonamiWebs/Telethon/blob/f9643bf7376a5953da2050a5361c9b465f7ee7d9/telethon_examples/gui.py#L227-L305 | ||
cloudmarker/cloudmarker | 0dd2daadfa0203b3d1062e5067b14e4e0f189697 | cloudmarker/events/azlogprofileretentionevent.py | python | AzLogProfileRetentionEvent.eval | (self, record) | Evaluate Azure log profiles for retention policy.
Arguments:
record (dict): An Azure log profile record.
Yields:
dict: An event record representing an Azure log profile
with retention set to less than the required days. | Evaluate Azure log profiles for retention policy. | [
"Evaluate",
"Azure",
"log",
"profiles",
"for",
"retention",
"policy",
"."
] | def eval(self, record):
"""Evaluate Azure log profiles for retention policy.
Arguments:
record (dict): An Azure log profile record.
Yields:
dict: An event record representing an Azure log profile
with retention set to less than the required days.
""... | [
"def",
"eval",
"(",
"self",
",",
"record",
")",
":",
"com",
"=",
"record",
".",
"get",
"(",
"'com'",
",",
"{",
"}",
")",
"if",
"com",
"is",
"None",
":",
"return",
"if",
"com",
".",
"get",
"(",
"'cloud_type'",
")",
"!=",
"'azure'",
":",
"return",
... | https://github.com/cloudmarker/cloudmarker/blob/0dd2daadfa0203b3d1062e5067b14e4e0f189697/cloudmarker/events/azlogprofileretentionevent.py#L32-L64 | ||
IJDykeman/wangTiles | 7c1ee2095ebdf7f72bce07d94c6484915d5cae8b | experimental_code/venv/lib/python2.7/site-packages/setuptools/dist.py | python | Distribution._exclude_misc | (self,name,value) | Handle 'exclude()' for list/tuple attrs without a special handler | Handle 'exclude()' for list/tuple attrs without a special handler | [
"Handle",
"exclude",
"()",
"for",
"list",
"/",
"tuple",
"attrs",
"without",
"a",
"special",
"handler"
] | def _exclude_misc(self,name,value):
"""Handle 'exclude()' for list/tuple attrs without a special handler"""
if not isinstance(value,sequence):
raise DistutilsSetupError(
"%s: setting must be a list or tuple (%r)" % (name, value)
)
try:
old = ge... | [
"def",
"_exclude_misc",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"sequence",
")",
":",
"raise",
"DistutilsSetupError",
"(",
"\"%s: setting must be a list or tuple (%r)\"",
"%",
"(",
"name",
",",
"value",
"... | https://github.com/IJDykeman/wangTiles/blob/7c1ee2095ebdf7f72bce07d94c6484915d5cae8b/experimental_code/venv/lib/python2.7/site-packages/setuptools/dist.py#L513-L530 | ||
IronLanguages/ironpython3 | 7a7bb2a872eeab0d1009fc8a6e24dca43f65b693 | Src/StdLib/Lib/xml/dom/minidom.py | python | Comment.writexml | (self, writer, indent="", addindent="", newl="") | [] | def writexml(self, writer, indent="", addindent="", newl=""):
if "--" in self.data:
raise ValueError("'--' is not allowed in a comment node")
writer.write("%s<!--%s-->%s" % (indent, self.data, newl)) | [
"def",
"writexml",
"(",
"self",
",",
"writer",
",",
"indent",
"=",
"\"\"",
",",
"addindent",
"=",
"\"\"",
",",
"newl",
"=",
"\"\"",
")",
":",
"if",
"\"--\"",
"in",
"self",
".",
"data",
":",
"raise",
"ValueError",
"(",
"\"'--' is not allowed in a comment no... | https://github.com/IronLanguages/ironpython3/blob/7a7bb2a872eeab0d1009fc8a6e24dca43f65b693/Src/StdLib/Lib/xml/dom/minidom.py#L1184-L1187 | ||||
huggingface/transformers | 623b4f7c63f60cce917677ee704d6c93ee960b4b | examples/research_projects/lxmert/utils.py | python | img_tensorize | (im, input_format="RGB") | return img | [] | def img_tensorize(im, input_format="RGB"):
assert isinstance(im, str)
if os.path.isfile(im):
img = cv2.imread(im)
else:
img = get_image_from_url(im)
assert img is not None, f"could not connect to: {im}"
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
if input_format == "RGB":
... | [
"def",
"img_tensorize",
"(",
"im",
",",
"input_format",
"=",
"\"RGB\"",
")",
":",
"assert",
"isinstance",
"(",
"im",
",",
"str",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"im",
")",
":",
"img",
"=",
"cv2",
".",
"imread",
"(",
"im",
")",
"... | https://github.com/huggingface/transformers/blob/623b4f7c63f60cce917677ee704d6c93ee960b4b/examples/research_projects/lxmert/utils.py#L545-L555 | |||
NervanaSystems/ngraph-python | ac032c83c7152b615a9ad129d54d350f9d6a2986 | ngraph/frontends/common/utils.py | python | make_poolparams | (op, pool_shape, strides, padding) | return poolparams | Make the poolparams dictionary to be used by core ngraph
Arguments:
op (str): One of the supported pooling op types. Currently ["avg", "max"].
pool_shape (dict): int filter shape with keys of "C", "D", "H", and "W"
strides (dict): int strides with keys of "C", "D", "H", and "W"
padd... | Make the poolparams dictionary to be used by core ngraph | [
"Make",
"the",
"poolparams",
"dictionary",
"to",
"be",
"used",
"by",
"core",
"ngraph"
] | def make_poolparams(op, pool_shape, strides, padding):
"""
Make the poolparams dictionary to be used by core ngraph
Arguments:
op (str): One of the supported pooling op types. Currently ["avg", "max"].
pool_shape (dict): int filter shape with keys of "C", "D", "H", and "W"
strides (... | [
"def",
"make_poolparams",
"(",
"op",
",",
"pool_shape",
",",
"strides",
",",
"padding",
")",
":",
"poolparams",
"=",
"dict",
"(",
")",
"poolparams",
"[",
"\"op\"",
"]",
"=",
"op",
"for",
"name",
",",
"value",
"in",
"zip",
"(",
"\"JTRS\"",
",",
"[",
"... | https://github.com/NervanaSystems/ngraph-python/blob/ac032c83c7152b615a9ad129d54d350f9d6a2986/ngraph/frontends/common/utils.py#L240-L263 | |
cesc-park/attend2u | 2154219558e9ca4dc781041aaea74d2b0607bb27 | scripts/vgg_preprocessing.py | python | _central_crop | (image_list, crop_height, crop_width) | return outputs | Performs central crops of the given image list.
Args:
image_list: a list of image tensors of the same dimension but possibly
varying channel.
crop_height: the height of the image following the crop.
crop_width: the width of the image following the crop.
Returns:
the list of cropped images. | Performs central crops of the given image list. | [
"Performs",
"central",
"crops",
"of",
"the",
"given",
"image",
"list",
"."
] | def _central_crop(image_list, crop_height, crop_width):
"""Performs central crops of the given image list.
Args:
image_list: a list of image tensors of the same dimension but possibly
varying channel.
crop_height: the height of the image following the crop.
crop_width: the width of the image foll... | [
"def",
"_central_crop",
"(",
"image_list",
",",
"crop_height",
",",
"crop_width",
")",
":",
"outputs",
"=",
"[",
"]",
"for",
"image",
"in",
"image_list",
":",
"image_height",
"=",
"tf",
".",
"shape",
"(",
"image",
")",
"[",
"0",
"]",
"image_width",
"=",
... | https://github.com/cesc-park/attend2u/blob/2154219558e9ca4dc781041aaea74d2b0607bb27/scripts/vgg_preprocessing.py#L178-L200 | |
pycollada/pycollada | 5b2d53333f03047b0fdfc25e394f8b77b57b62fc | collada/material.py | python | Map.__init__ | (self, sampler, texcoord, xmlnode=None) | Create a map instance to a sampler using a texcoord channel.
:param collada.material.Sampler2D sampler:
A sampler object to map
:param str texcoord:
Texture coordinate channel symbol to use
:param xmlnode:
If loaded from xml, the xml node | Create a map instance to a sampler using a texcoord channel. | [
"Create",
"a",
"map",
"instance",
"to",
"a",
"sampler",
"using",
"a",
"texcoord",
"channel",
"."
] | def __init__(self, sampler, texcoord, xmlnode=None):
"""Create a map instance to a sampler using a texcoord channel.
:param collada.material.Sampler2D sampler:
A sampler object to map
:param str texcoord:
Texture coordinate channel symbol to use
:param xmlnode:
... | [
"def",
"__init__",
"(",
"self",
",",
"sampler",
",",
"texcoord",
",",
"xmlnode",
"=",
"None",
")",
":",
"self",
".",
"sampler",
"=",
"sampler",
"\"\"\":class:`collada.material.Sampler2D` object to map\"\"\"",
"self",
".",
"texcoord",
"=",
"texcoord",
"\"\"\"Texture ... | https://github.com/pycollada/pycollada/blob/5b2d53333f03047b0fdfc25e394f8b77b57b62fc/collada/material.py#L349-L368 | ||
coherence-project/Coherence | 88016204c7778bf0d3ad1ae331b4d8fd725dd2af | coherence/backends/appletrailers_storage.py | python | AppleTrailersStore._parse_into_trailer | (self, item) | info = item.find('info')
for attr in ('title', 'runtime', 'rating', 'studio', 'postdate',
'releasedate', 'copyright', 'director', 'description'):
setattr(trailer, attr, info.find(attr).text) | info = item.find('info') | [
"info",
"=",
"item",
".",
"find",
"(",
"info",
")"
] | def _parse_into_trailer(self, item):
"""
info = item.find('info')
for attr in ('title', 'runtime', 'rating', 'studio', 'postdate',
'releasedate', 'copyright', 'director', 'description'):
setattr(trailer, attr, info.find(attr).text)
"""
data = {}... | [
"def",
"_parse_into_trailer",
"(",
"self",
",",
"item",
")",
":",
"data",
"=",
"{",
"}",
"data",
"[",
"'id'",
"]",
"=",
"item",
".",
"get",
"(",
"'id'",
")",
"data",
"[",
"'name'",
"]",
"=",
"item",
".",
"find",
"(",
"'./info/title'",
")",
".",
"... | https://github.com/coherence-project/Coherence/blob/88016204c7778bf0d3ad1ae331b4d8fd725dd2af/coherence/backends/appletrailers_storage.py#L137-L213 | ||
amzn/metalearn-leap | 9d6fa0c1c27fa7812cb9510ab0b23d5f25f575f0 | src/maml/maml/optim.py | python | Adam.__init__ | (self, *args, detach=False, **kwargs) | [] | def __init__(self, *args, detach=False, **kwargs):
self.detach = detach
super(Adam, self).__init__(*args, **kwargs) | [
"def",
"__init__",
"(",
"self",
",",
"*",
"args",
",",
"detach",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"detach",
"=",
"detach",
"super",
"(",
"Adam",
",",
"self",
")",
".",
"__init__",
"(",
"*",
"args",
",",
"*",
"*",
"k... | https://github.com/amzn/metalearn-leap/blob/9d6fa0c1c27fa7812cb9510ab0b23d5f25f575f0/src/maml/maml/optim.py#L108-L110 | ||||
dulwich/dulwich | 1f66817d712e3563ce1ff53b1218491a2eae39da | dulwich/server.py | python | main | (argv=sys.argv) | Entry point for starting a TCP git server. | Entry point for starting a TCP git server. | [
"Entry",
"point",
"for",
"starting",
"a",
"TCP",
"git",
"server",
"."
] | def main(argv=sys.argv):
"""Entry point for starting a TCP git server."""
import optparse
parser = optparse.OptionParser()
parser.add_option(
"-l",
"--listen_address",
dest="listen_address",
default="localhost",
help="Binding IP address.",
)
parser.add_op... | [
"def",
"main",
"(",
"argv",
"=",
"sys",
".",
"argv",
")",
":",
"import",
"optparse",
"parser",
"=",
"optparse",
".",
"OptionParser",
"(",
")",
"parser",
".",
"add_option",
"(",
"\"-l\"",
",",
"\"--listen_address\"",
",",
"dest",
"=",
"\"listen_address\"",
... | https://github.com/dulwich/dulwich/blob/1f66817d712e3563ce1ff53b1218491a2eae39da/dulwich/server.py#L1186-L1216 | ||
PyHDI/veriloggen | 2382d200deabf59cfcfd741f5eba371010aaf2bb | veriloggen/thread/ttypes.py | python | intrinsic | (fsm, func, *args, **kwargs) | function call as an intrinsic | function call as an intrinsic | [
"function",
"call",
"as",
"an",
"intrinsic"
] | def intrinsic(fsm, func, *args, **kwargs):
""" function call as an intrinsic """
func(fsm, *args, **kwargs) | [
"def",
"intrinsic",
"(",
"fsm",
",",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"func",
"(",
"fsm",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | https://github.com/PyHDI/veriloggen/blob/2382d200deabf59cfcfd741f5eba371010aaf2bb/veriloggen/thread/ttypes.py#L19-L21 | ||
geopython/OWSLib | 414375413c9e2bab33a2d09608ab209875ce6daf | owslib/catalogue/csw3.py | python | CatalogueServiceWeb.harvest | (self, source, resourcetype, resourceformat=None, harvestinterval=None, responsehandler=None) | Construct and process a Harvest request
Parameters
----------
- source: a URI to harvest
- resourcetype: namespace identifying the type of resource
- resourceformat: MIME type of the resource
- harvestinterval: frequency of harvesting, in ISO8601
- responsehandl... | [] | def harvest(self, source, resourcetype, resourceformat=None, harvestinterval=None, responsehandler=None):
"""
Construct and process a Harvest request
Parameters
----------
- source: a URI to harvest
- resourcetype: namespace identifying the type of resource
- r... | [
"def",
"harvest",
"(",
"self",
",",
"source",
",",
"resourcetype",
",",
"resourceformat",
"=",
"None",
",",
"harvestinterval",
"=",
"None",
",",
"responsehandler",
"=",
"None",
")",
":",
"# construct request",
"node0",
"=",
"self",
".",
"_setrootelement",
"(",... | https://github.com/geopython/OWSLib/blob/414375413c9e2bab33a2d09608ab209875ce6daf/owslib/catalogue/csw3.py#L373-L417 | |||
theotherp/nzbhydra | 4b03d7f769384b97dfc60dade4806c0fc987514e | libs/werkzeug/http.py | python | http_date | (timestamp=None) | return _dump_date(timestamp, ' ') | Formats the time to match the RFC1123 date format.
Accepts a floating point number expressed in seconds since the epoch in, a
datetime object or a timetuple. All times in UTC. The :func:`parse_date`
function can be used to parse such a date.
Outputs a string in the format ``Wdy, DD Mon YYYY HH:MM:SS... | Formats the time to match the RFC1123 date format. | [
"Formats",
"the",
"time",
"to",
"match",
"the",
"RFC1123",
"date",
"format",
"."
] | def http_date(timestamp=None):
"""Formats the time to match the RFC1123 date format.
Accepts a floating point number expressed in seconds since the epoch in, a
datetime object or a timetuple. All times in UTC. The :func:`parse_date`
function can be used to parse such a date.
Outputs a string in ... | [
"def",
"http_date",
"(",
"timestamp",
"=",
"None",
")",
":",
"return",
"_dump_date",
"(",
"timestamp",
",",
"' '",
")"
] | https://github.com/theotherp/nzbhydra/blob/4b03d7f769384b97dfc60dade4806c0fc987514e/libs/werkzeug/http.py#L733-L744 | |
theotherp/nzbhydra | 4b03d7f769384b97dfc60dade4806c0fc987514e | libs/passlib/handlers/mssql.py | python | _parse_mssql | (hash, csize, bsize, handler) | common parser for mssql 2000/2005; returns 4 byte salt + checksum | common parser for mssql 2000/2005; returns 4 byte salt + checksum | [
"common",
"parser",
"for",
"mssql",
"2000",
"/",
"2005",
";",
"returns",
"4",
"byte",
"salt",
"+",
"checksum"
] | def _parse_mssql(hash, csize, bsize, handler):
"""common parser for mssql 2000/2005; returns 4 byte salt + checksum"""
if isinstance(hash, unicode):
if len(hash) == csize and hash.startswith(UIDENT):
try:
return unhexlify(hash[6:].encode("utf-8"))
except TypeError... | [
"def",
"_parse_mssql",
"(",
"hash",
",",
"csize",
",",
"bsize",
",",
"handler",
")",
":",
"if",
"isinstance",
"(",
"hash",
",",
"unicode",
")",
":",
"if",
"len",
"(",
"hash",
")",
"==",
"csize",
"and",
"hash",
".",
"startswith",
"(",
"UIDENT",
")",
... | https://github.com/theotherp/nzbhydra/blob/4b03d7f769384b97dfc60dade4806c0fc987514e/libs/passlib/handlers/mssql.py#L80-L100 | ||
Azure/azure-devops-cli-extension | 11334cd55806bef0b99c3bee5a438eed71e44037 | azure-devops/azext_devops/devops_sdk/v5_0/policy/policy_client.py | python | PolicyClient.get_policy_type | (self, project, type_id) | return self._deserialize('PolicyType', response) | GetPolicyType.
Retrieve a specific policy type by ID.
:param str project: Project ID or project name
:param str type_id: The policy ID.
:rtype: :class:`<PolicyType> <azure.devops.v5_0.policy.models.PolicyType>` | GetPolicyType.
Retrieve a specific policy type by ID.
:param str project: Project ID or project name
:param str type_id: The policy ID.
:rtype: :class:`<PolicyType> <azure.devops.v5_0.policy.models.PolicyType>` | [
"GetPolicyType",
".",
"Retrieve",
"a",
"specific",
"policy",
"type",
"by",
"ID",
".",
":",
"param",
"str",
"project",
":",
"Project",
"ID",
"or",
"project",
"name",
":",
"param",
"str",
"type_id",
":",
"The",
"policy",
"ID",
".",
":",
"rtype",
":",
":"... | def get_policy_type(self, project, type_id):
"""GetPolicyType.
Retrieve a specific policy type by ID.
:param str project: Project ID or project name
:param str type_id: The policy ID.
:rtype: :class:`<PolicyType> <azure.devops.v5_0.policy.models.PolicyType>`
"""
r... | [
"def",
"get_policy_type",
"(",
"self",
",",
"project",
",",
"type_id",
")",
":",
"route_values",
"=",
"{",
"}",
"if",
"project",
"is",
"not",
"None",
":",
"route_values",
"[",
"'project'",
"]",
"=",
"self",
".",
"_serialize",
".",
"url",
"(",
"'project'"... | https://github.com/Azure/azure-devops-cli-extension/blob/11334cd55806bef0b99c3bee5a438eed71e44037/azure-devops/azext_devops/devops_sdk/v5_0/policy/policy_client.py#L239-L255 | |
OpenEndedGroup/Field | 4f7c8edfb01bb0ccc927b78d3c500f018a4ae37c | Contents/lib/python/subprocess.py | python | list2cmdline | (seq) | return ''.join(result) | Translate a sequence of arguments into a command line
string, using the same rules as the MS C runtime:
1) Arguments are delimited by white space, which is either a
space or a tab.
2) A string surrounded by double quotation marks is
interpreted as a single argument, regardless of white space... | Translate a sequence of arguments into a command line
string, using the same rules as the MS C runtime: | [
"Translate",
"a",
"sequence",
"of",
"arguments",
"into",
"a",
"command",
"line",
"string",
"using",
"the",
"same",
"rules",
"as",
"the",
"MS",
"C",
"runtime",
":"
] | def list2cmdline(seq):
"""
Translate a sequence of arguments into a command line
string, using the same rules as the MS C runtime:
1) Arguments are delimited by white space, which is either a
space or a tab.
2) A string surrounded by double quotation marks is
interpreted as a single ... | [
"def",
"list2cmdline",
"(",
"seq",
")",
":",
"# See",
"# http://msdn.microsoft.com/library/en-us/vccelng/htm/progs_12.asp",
"result",
"=",
"[",
"]",
"needquote",
"=",
"False",
"for",
"arg",
"in",
"seq",
":",
"bs_buf",
"=",
"[",
"]",
"# Add a space to separate this arg... | https://github.com/OpenEndedGroup/Field/blob/4f7c8edfb01bb0ccc927b78d3c500f018a4ae37c/Contents/lib/python/subprocess.py#L478-L543 | |
uranusjr/django-tutorial-for-programmers | 9301a5428f04148e3e40b3b57b90f36f7d198fdd | lunch/lunch/stores/models.py | python | Store.get_absolute_url | (self) | return reverse('store_detail', kwargs={'pk': self.pk}) | [] | def get_absolute_url(self):
return reverse('store_detail', kwargs={'pk': self.pk}) | [
"def",
"get_absolute_url",
"(",
"self",
")",
":",
"return",
"reverse",
"(",
"'store_detail'",
",",
"kwargs",
"=",
"{",
"'pk'",
":",
"self",
".",
"pk",
"}",
")"
] | https://github.com/uranusjr/django-tutorial-for-programmers/blob/9301a5428f04148e3e40b3b57b90f36f7d198fdd/lunch/lunch/stores/models.py#L27-L28 | |||
mit-han-lab/gan-compression | d25dfb871e6cd2923d8a745f247d0c72945faf4b | utils/html.py | python | HTML.add_header | (self, text) | Insert a header to the HTML file
Parameters:
text (str) -- the header text | Insert a header to the HTML file | [
"Insert",
"a",
"header",
"to",
"the",
"HTML",
"file"
] | def add_header(self, text):
"""Insert a header to the HTML file
Parameters:
text (str) -- the header text
"""
with self.doc:
h3(text) | [
"def",
"add_header",
"(",
"self",
",",
"text",
")",
":",
"with",
"self",
".",
"doc",
":",
"h3",
"(",
"text",
")"
] | https://github.com/mit-han-lab/gan-compression/blob/d25dfb871e6cd2923d8a745f247d0c72945faf4b/utils/html.py#L39-L46 | ||
eirannejad/pyRevit | 49c0b7eb54eb343458ce1365425e6552d0c47d44 | site-packages/natsort/natsort.py | python | index_natsorted | (seq, key=None, reverse=False, alg=ns.DEFAULT) | return [x for x, _ in index_seq_pair] | Determine the list of the indexes used to sort the input sequence.
Sorts a sequence naturally, but returns a list of sorted the
indexes and not the sorted list itself. This list of indexes
can be used to sort multiple lists by the sorted order of the
given sequence.
Parameters
----------
s... | Determine the list of the indexes used to sort the input sequence. | [
"Determine",
"the",
"list",
"of",
"the",
"indexes",
"used",
"to",
"sort",
"the",
"input",
"sequence",
"."
] | def index_natsorted(seq, key=None, reverse=False, alg=ns.DEFAULT):
"""
Determine the list of the indexes used to sort the input sequence.
Sorts a sequence naturally, but returns a list of sorted the
indexes and not the sorted list itself. This list of indexes
can be used to sort multiple lists by t... | [
"def",
"index_natsorted",
"(",
"seq",
",",
"key",
"=",
"None",
",",
"reverse",
"=",
"False",
",",
"alg",
"=",
"ns",
".",
"DEFAULT",
")",
":",
"if",
"key",
"is",
"None",
":",
"newkey",
"=",
"itemgetter",
"(",
"1",
")",
"else",
":",
"def",
"newkey",
... | https://github.com/eirannejad/pyRevit/blob/49c0b7eb54eb343458ce1365425e6552d0c47d44/site-packages/natsort/natsort.py#L380-L446 | |
klb3713/sentence2vec | e38a4f5ad431ff8e5ae8015040a5da551be3b72e | utils.py | python | pyro_daemon | (name, obj, random_suffix=False, ip=None, port=None) | Register object with name server (starting the name server if not running
yet) and block until the daemon is terminated. The object is registered under
`name`, or `name`+ some random suffix if `random_suffix` is set. | Register object with name server (starting the name server if not running
yet) and block until the daemon is terminated. The object is registered under
`name`, or `name`+ some random suffix if `random_suffix` is set. | [
"Register",
"object",
"with",
"name",
"server",
"(",
"starting",
"the",
"name",
"server",
"if",
"not",
"running",
"yet",
")",
"and",
"block",
"until",
"the",
"daemon",
"is",
"terminated",
".",
"The",
"object",
"is",
"registered",
"under",
"name",
"or",
"na... | def pyro_daemon(name, obj, random_suffix=False, ip=None, port=None):
"""
Register object with name server (starting the name server if not running
yet) and block until the daemon is terminated. The object is registered under
`name`, or `name`+ some random suffix if `random_suffix` is set.
"""
i... | [
"def",
"pyro_daemon",
"(",
"name",
",",
"obj",
",",
"random_suffix",
"=",
"False",
",",
"ip",
"=",
"None",
",",
"port",
"=",
"None",
")",
":",
"if",
"random_suffix",
":",
"name",
"+=",
"'.'",
"+",
"hex",
"(",
"random",
".",
"randint",
"(",
"0",
","... | https://github.com/klb3713/sentence2vec/blob/e38a4f5ad431ff8e5ae8015040a5da551be3b72e/utils.py#L740-L757 | ||
cagbal/ros_people_object_detection_tensorflow | 982ffd4a54b8059638f5cd4aa167299c7fc9e61f | src/object_detection/utils/ops.py | python | normalize_to_target | (inputs,
target_norm_value,
dim,
epsilon=1e-7,
trainable=True,
scope='NormalizeToTarget',
summarize=True) | L2 normalizes the inputs across the specified dimension to a target norm.
This op implements the L2 Normalization layer introduced in
Liu, Wei, et al. "SSD: Single Shot MultiBox Detector."
and Liu, Wei, Andrew Rabinovich, and Alexander C. Berg.
"Parsenet: Looking wider to see better." and is useful for bringin... | L2 normalizes the inputs across the specified dimension to a target norm. | [
"L2",
"normalizes",
"the",
"inputs",
"across",
"the",
"specified",
"dimension",
"to",
"a",
"target",
"norm",
"."
] | def normalize_to_target(inputs,
target_norm_value,
dim,
epsilon=1e-7,
trainable=True,
scope='NormalizeToTarget',
summarize=True):
"""L2 normalizes the inputs across the speci... | [
"def",
"normalize_to_target",
"(",
"inputs",
",",
"target_norm_value",
",",
"dim",
",",
"epsilon",
"=",
"1e-7",
",",
"trainable",
"=",
"True",
",",
"scope",
"=",
"'NormalizeToTarget'",
",",
"summarize",
"=",
"True",
")",
":",
"with",
"tf",
".",
"variable_sco... | https://github.com/cagbal/ros_people_object_detection_tensorflow/blob/982ffd4a54b8059638f5cd4aa167299c7fc9e61f/src/object_detection/utils/ops.py#L459-L533 | ||
tomplus/kubernetes_asyncio | f028cc793e3a2c519be6a52a49fb77ff0b014c9b | kubernetes_asyncio/client/api/core_v1_api.py | python | CoreV1Api.replace_persistent_volume_status | (self, name, body, **kwargs) | return self.replace_persistent_volume_status_with_http_info(name, body, **kwargs) | replace_persistent_volume_status # noqa: E501
replace status of the specified PersistentVolume # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.replace_persistent_volume_status(name,... | replace_persistent_volume_status # noqa: E501 | [
"replace_persistent_volume_status",
"#",
"noqa",
":",
"E501"
] | def replace_persistent_volume_status(self, name, body, **kwargs): # noqa: E501
"""replace_persistent_volume_status # noqa: E501
replace status of the specified PersistentVolume # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request,... | [
"def",
"replace_persistent_volume_status",
"(",
"self",
",",
"name",
",",
"body",
",",
"*",
"*",
"kwargs",
")",
":",
"# noqa: E501",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"return",
"self",
".",
"replace_persistent_volume_status_with_http_info",
... | https://github.com/tomplus/kubernetes_asyncio/blob/f028cc793e3a2c519be6a52a49fb77ff0b014c9b/kubernetes_asyncio/client/api/core_v1_api.py#L28707-L28734 | |
mme/vergeml | 3dc30ba4e0f3d038743b6d468860cbcf3681acc6 | vergeml/option.py | python | Option.transform_value | (self, value) | [] | def transform_value(self, value):
if self.transform:
return self.transform(value)
else:
return value | [
"def",
"transform_value",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"transform",
":",
"return",
"self",
".",
"transform",
"(",
"value",
")",
"else",
":",
"return",
"value"
] | https://github.com/mme/vergeml/blob/3dc30ba4e0f3d038743b6d468860cbcf3681acc6/vergeml/option.py#L316-L320 | ||||
Tautulli/Tautulli | 2410eb33805aaac4bd1c5dad0f71e4f15afaf742 | lib/mako/ext/linguaplugin.py | python | LinguaMakoExtractor.process_python | (self, code, code_lineno, translator_strings) | [] | def process_python(self, code, code_lineno, translator_strings):
source = code.getvalue().strip()
if source.endswith(compat.b(":")):
if source in (
compat.b("try:"),
compat.b("else:"),
) or source.startswith(compat.b("except")):
sou... | [
"def",
"process_python",
"(",
"self",
",",
"code",
",",
"code_lineno",
",",
"translator_strings",
")",
":",
"source",
"=",
"code",
".",
"getvalue",
"(",
")",
".",
"strip",
"(",
")",
"if",
"source",
".",
"endswith",
"(",
"compat",
".",
"b",
"(",
"\":\""... | https://github.com/Tautulli/Tautulli/blob/2410eb33805aaac4bd1c5dad0f71e4f15afaf742/lib/mako/ext/linguaplugin.py#L40-L65 | ||||
qutip/qutip | 52d01da181a21b810c3407812c670f35fdc647e8 | qutip/bloch3d.py | python | Bloch3d.save | (self, name=None, format='png', dirc=None) | Saves Bloch sphere to file of type ``format`` in directory ``dirc``.
Parameters
----------
name : str
Name of saved image. Must include path and format as well.
i.e. '/Users/Paul/Desktop/bloch.png'
This overrides the 'format' and 'dirc' arguments.
for... | Saves Bloch sphere to file of type ``format`` in directory ``dirc``. | [
"Saves",
"Bloch",
"sphere",
"to",
"file",
"of",
"type",
"format",
"in",
"directory",
"dirc",
"."
] | def save(self, name=None, format='png', dirc=None):
"""Saves Bloch sphere to file of type ``format`` in directory ``dirc``.
Parameters
----------
name : str
Name of saved image. Must include path and format as well.
i.e. '/Users/Paul/Desktop/bloch.png'
... | [
"def",
"save",
"(",
"self",
",",
"name",
"=",
"None",
",",
"format",
"=",
"'png'",
",",
"dirc",
"=",
"None",
")",
":",
"from",
"mayavi",
"import",
"mlab",
"import",
"os",
"self",
".",
"make_sphere",
"(",
")",
"mlab",
".",
"view",
"(",
"azimuth",
"=... | https://github.com/qutip/qutip/blob/52d01da181a21b810c3407812c670f35fdc647e8/qutip/bloch3d.py#L468-L505 | ||
TencentCloud/tencentcloud-sdk-python | 3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2 | tencentcloud/mps/v20190612/models.py | python | ExpressionConfigInfo.__init__ | (self) | r"""
:param Switch: 表情识别任务开关,可选值:
<li>ON:开启;</li>
<li>OFF:关闭。</li>
:type Switch: str | r"""
:param Switch: 表情识别任务开关,可选值:
<li>ON:开启;</li>
<li>OFF:关闭。</li>
:type Switch: str | [
"r",
":",
"param",
"Switch",
":",
"表情识别任务开关,可选值:",
"<li",
">",
"ON:开启;<",
"/",
"li",
">",
"<li",
">",
"OFF:关闭。<",
"/",
"li",
">",
":",
"type",
"Switch",
":",
"str"
] | def __init__(self):
r"""
:param Switch: 表情识别任务开关,可选值:
<li>ON:开启;</li>
<li>OFF:关闭。</li>
:type Switch: str
"""
self.Switch = None | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"Switch",
"=",
"None"
] | https://github.com/TencentCloud/tencentcloud-sdk-python/blob/3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2/tencentcloud/mps/v20190612/models.py#L7163-L7170 | ||
MultiAgentLearning/playground | 8c06a21da5758b570b708e9dd3337e1fa1e67e71 | pommerman/configs.py | python | team_competition_fast_env | () | return locals() | Start up a Team config with the competition settings. | Start up a Team config with the competition settings. | [
"Start",
"up",
"a",
"Team",
"config",
"with",
"the",
"competition",
"settings",
"."
] | def team_competition_fast_env():
"""Start up a Team config with the competition settings."""
env = envs.v0.Pomme
game_type = constants.GameType.Team
env_entry_point = 'pommerman.envs.v0:Pomme'
env_id = 'PommeTeamCompetitionFast-v0'
env_kwargs = {
'game_type': game_type,
'board_si... | [
"def",
"team_competition_fast_env",
"(",
")",
":",
"env",
"=",
"envs",
".",
"v0",
".",
"Pomme",
"game_type",
"=",
"constants",
".",
"GameType",
".",
"Team",
"env_entry_point",
"=",
"'pommerman.envs.v0:Pomme'",
"env_id",
"=",
"'PommeTeamCompetitionFast-v0'",
"env_kwa... | https://github.com/MultiAgentLearning/playground/blob/8c06a21da5758b570b708e9dd3337e1fa1e67e71/pommerman/configs.py#L102-L121 | |
gcollazo/BrowserRefresh-Sublime | daee0eda6480c07f8636ed24e5c555d24e088886 | win/pywinauto/controls/Accessability HwndWrapper.py | python | HwndWrapper.Parent | (self) | return self._cache["parent"] | Return the parent of this control
Note that the parent of a control is not necesarily a dialog or
other main window. A group box may be the parent of some radio
buttons for example.
To get the main (or top level) window then use
HwndWrapper.TopLevelParent(). | Return the parent of this control | [
"Return",
"the",
"parent",
"of",
"this",
"control"
] | def Parent(self):
"""Return the parent of this control
Note that the parent of a control is not necesarily a dialog or
other main window. A group box may be the parent of some radio
buttons for example.
To get the main (or top level) window then use
HwndWrapper.TopLevel... | [
"def",
"Parent",
"(",
"self",
")",
":",
"if",
"\"parent\"",
"not",
"in",
"self",
".",
"_cache",
":",
"parent_hwnd",
"=",
"handleprops",
".",
"parent",
"(",
"self",
")",
"if",
"parent_hwnd",
":",
"#return WrapHandle(parent_hwnd)",
"self",
".",
"_cache",
"[",
... | https://github.com/gcollazo/BrowserRefresh-Sublime/blob/daee0eda6480c07f8636ed24e5c555d24e088886/win/pywinauto/controls/Accessability HwndWrapper.py#L517-L539 | |
getlogbook/logbook | 3e0badb395ed8d0038d02996d38aa0505441327e | logbook/compat.py | python | LoggingHandler.convert_time | (self, dt) | return seconds | Converts a datetime object into a timestamp. | Converts a datetime object into a timestamp. | [
"Converts",
"a",
"datetime",
"object",
"into",
"a",
"timestamp",
"."
] | def convert_time(self, dt):
"""Converts a datetime object into a timestamp."""
year, month, day, hour, minute, second = dt.utctimetuple()[:6]
days = date(year, month, 1).toordinal() - _epoch_ord + day - 1
hours = days * 24 + hour
minutes = hours * 60 + minute
seconds = mi... | [
"def",
"convert_time",
"(",
"self",
",",
"dt",
")",
":",
"year",
",",
"month",
",",
"day",
",",
"hour",
",",
"minute",
",",
"second",
"=",
"dt",
".",
"utctimetuple",
"(",
")",
"[",
":",
"6",
"]",
"days",
"=",
"date",
"(",
"year",
",",
"month",
... | https://github.com/getlogbook/logbook/blob/3e0badb395ed8d0038d02996d38aa0505441327e/logbook/compat.py#L194-L201 | |
araffin/robotics-rl-srl | eae7c1ab310c79662f6e68c0d255e08641037ffa | environments/robobo_gym/robobo_env.py | python | RoboboEnv.render | (self, mode='rgb_array') | return self.observation | :param mode: (str)
:return: (numpy array) BGR image | :param mode: (str)
:return: (numpy array) BGR image | [
":",
"param",
"mode",
":",
"(",
"str",
")",
":",
"return",
":",
"(",
"numpy",
"array",
")",
"BGR",
"image"
] | def render(self, mode='rgb_array'):
"""
:param mode: (str)
:return: (numpy array) BGR image
"""
if mode != "rgb_array":
print('render in human mode not yet supported')
return np.array([])
if self._renders:
plt.ion() # needed for inter... | [
"def",
"render",
"(",
"self",
",",
"mode",
"=",
"'rgb_array'",
")",
":",
"if",
"mode",
"!=",
"\"rgb_array\"",
":",
"print",
"(",
"'render in human mode not yet supported'",
")",
"return",
"np",
".",
"array",
"(",
"[",
"]",
")",
"if",
"self",
".",
"_renders... | https://github.com/araffin/robotics-rl-srl/blob/eae7c1ab310c79662f6e68c0d255e08641037ffa/environments/robobo_gym/robobo_env.py#L241-L261 | |
ogroth/tf-gqn | 8a517f0142b06f766f0cfd576b7ecdf16e92eab7 | gqn/gqn_draw.py | python | GQNLSTMCell.call | (self, inputs, state, scope=None) | return output, new_state | :param inputs: list of inputs
:param state: cell (c), and hidden (h) states
:param scope:
:return: | :param inputs: list of inputs
:param state: cell (c), and hidden (h) states
:param scope:
:return: | [
":",
"param",
"inputs",
":",
"list",
"of",
"inputs",
":",
"param",
"state",
":",
"cell",
"(",
"c",
")",
"and",
"hidden",
"(",
"h",
")",
"states",
":",
"param",
"scope",
":",
":",
"return",
":"
] | def call(self, inputs, state, scope=None):
"""
:param inputs: list of inputs
:param state: cell (c), and hidden (h) states
:param scope:
:return:
"""
cell_state, hidden_state = state
inputs[self._hidden_state_name] = hidden_state
with tf.name_scope("InputConv"):
new_hidden = ... | [
"def",
"call",
"(",
"self",
",",
"inputs",
",",
"state",
",",
"scope",
"=",
"None",
")",
":",
"cell_state",
",",
"hidden_state",
"=",
"state",
"inputs",
"[",
"self",
".",
"_hidden_state_name",
"]",
"=",
"hidden_state",
"with",
"tf",
".",
"name_scope",
"(... | https://github.com/ogroth/tf-gqn/blob/8a517f0142b06f766f0cfd576b7ecdf16e92eab7/gqn/gqn_draw.py#L89-L117 | |
Ultimaker/Cura | a1622c77ea7259ecb956acd6de07b7d34b7ac52b | cura/Scene/ConvexHullNode.py | python | ConvexHullNode.__init__ | (self, node: SceneNode, hull: Optional[Polygon], thickness: float, parent: Optional[SceneNode] = None) | Convex hull node is a special type of scene node that is used to display an area, to indicate the
location an object uses on the buildplate. This area (or area's in case of one at a time printing) is
then displayed as a transparent shadow. If the adhesion type is set to raft, the area is extruded
... | Convex hull node is a special type of scene node that is used to display an area, to indicate the | [
"Convex",
"hull",
"node",
"is",
"a",
"special",
"type",
"of",
"scene",
"node",
"that",
"is",
"used",
"to",
"display",
"an",
"area",
"to",
"indicate",
"the"
] | def __init__(self, node: SceneNode, hull: Optional[Polygon], thickness: float, parent: Optional[SceneNode] = None) -> None:
"""Convex hull node is a special type of scene node that is used to display an area, to indicate the
location an object uses on the buildplate. This area (or area's in case of one... | [
"def",
"__init__",
"(",
"self",
",",
"node",
":",
"SceneNode",
",",
"hull",
":",
"Optional",
"[",
"Polygon",
"]",
",",
"thickness",
":",
"float",
",",
"parent",
":",
"Optional",
"[",
"SceneNode",
"]",
"=",
"None",
")",
"->",
"None",
":",
"super",
"("... | https://github.com/Ultimaker/Cura/blob/a1622c77ea7259ecb956acd6de07b7d34b7ac52b/cura/Scene/ConvexHullNode.py#L21-L74 | ||
bigmlcom/python | 35f69d2f3121f1b3dde43495cf145d4992796ad5 | bigml/linear.py | python | LinearRegression.predict | (self, input_data, full=False) | return result | Returns the prediction and the confidence intervals
input_data: Input data to be predicted
full: Boolean that controls whether to include the prediction's
attributes. By default, only the prediction is produced. If set
to True, the rest of available information is added in a... | Returns the prediction and the confidence intervals | [
"Returns",
"the",
"prediction",
"and",
"the",
"confidence",
"intervals"
] | def predict(self, input_data, full=False):
"""Returns the prediction and the confidence intervals
input_data: Input data to be predicted
full: Boolean that controls whether to include the prediction's
attributes. By default, only the prediction is produced. If set
to... | [
"def",
"predict",
"(",
"self",
",",
"input_data",
",",
"full",
"=",
"False",
")",
":",
"# Checks and cleans input_data leaving the fields used in the model",
"unused_fields",
"=",
"[",
"]",
"norm_input_data",
"=",
"self",
".",
"filter_input_data",
"(",
"input_data",
"... | https://github.com/bigmlcom/python/blob/35f69d2f3121f1b3dde43495cf145d4992796ad5/bigml/linear.py#L285-L336 | |
tobegit3hub/deep_image_model | 8a53edecd9e00678b278bb10f6fb4bdb1e4ee25e | java_predict_client/src/main/proto/tensorflow/models/embedding/word2vec.py | python | Word2Vec._predict | (self, analogy) | return idx | Predict the top 4 answers for analogy questions. | Predict the top 4 answers for analogy questions. | [
"Predict",
"the",
"top",
"4",
"answers",
"for",
"analogy",
"questions",
"."
] | def _predict(self, analogy):
"""Predict the top 4 answers for analogy questions."""
idx, = self._session.run([self._analogy_pred_idx], {
self._analogy_a: analogy[:, 0],
self._analogy_b: analogy[:, 1],
self._analogy_c: analogy[:, 2]
})
return idx | [
"def",
"_predict",
"(",
"self",
",",
"analogy",
")",
":",
"idx",
",",
"=",
"self",
".",
"_session",
".",
"run",
"(",
"[",
"self",
".",
"_analogy_pred_idx",
"]",
",",
"{",
"self",
".",
"_analogy_a",
":",
"analogy",
"[",
":",
",",
"0",
"]",
",",
"s... | https://github.com/tobegit3hub/deep_image_model/blob/8a53edecd9e00678b278bb10f6fb4bdb1e4ee25e/java_predict_client/src/main/proto/tensorflow/models/embedding/word2vec.py#L434-L441 | |
scikit-learn/scikit-learn | 1d1aadd0711b87d2a11c80aad15df6f8cf156712 | sklearn/covariance/_robust_covariance.py | python | MinCovDet.fit | (self, X, y=None) | return self | Fit a Minimum Covariance Determinant with the FastMCD algorithm.
Parameters
----------
X : array-like of shape (n_samples, n_features)
Training data, where `n_samples` is the number of samples
and `n_features` is the number of features.
y : Ignored
N... | Fit a Minimum Covariance Determinant with the FastMCD algorithm. | [
"Fit",
"a",
"Minimum",
"Covariance",
"Determinant",
"with",
"the",
"FastMCD",
"algorithm",
"."
] | def fit(self, X, y=None):
"""Fit a Minimum Covariance Determinant with the FastMCD algorithm.
Parameters
----------
X : array-like of shape (n_samples, n_features)
Training data, where `n_samples` is the number of samples
and `n_features` is the number of feature... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
")",
":",
"X",
"=",
"self",
".",
"_validate_data",
"(",
"X",
",",
"ensure_min_samples",
"=",
"2",
",",
"estimator",
"=",
"\"MinCovDet\"",
")",
"random_state",
"=",
"check_random_state",
"(",
"... | https://github.com/scikit-learn/scikit-learn/blob/1d1aadd0711b87d2a11c80aad15df6f8cf156712/sklearn/covariance/_robust_covariance.py#L716-L767 | |
odlgroup/odl | 0b088df8dc4621c68b9414c3deff9127f4c4f11d | odl/solvers/functional/functional.py | python | FunctionalQuadraticPerturb.convex_conj | (self) | r"""Convex conjugate functional of the functional.
Notes
-----
Given a functional :math:`f`, the convex conjugate of a linearly
perturbed version :math:`f(x) + <y, x>` is given by a translation of
the convex conjugate of :math:`f`:
.. math::
(f + \langle y, ... | r"""Convex conjugate functional of the functional. | [
"r",
"Convex",
"conjugate",
"functional",
"of",
"the",
"functional",
"."
] | def convex_conj(self):
r"""Convex conjugate functional of the functional.
Notes
-----
Given a functional :math:`f`, the convex conjugate of a linearly
perturbed version :math:`f(x) + <y, x>` is given by a translation of
the convex conjugate of :math:`f`:
.. math... | [
"def",
"convex_conj",
"(",
"self",
")",
":",
"if",
"self",
".",
"quadratic_coeff",
"==",
"0",
":",
"cconj",
"=",
"self",
".",
"functional",
".",
"convex_conj",
".",
"translated",
"(",
"self",
".",
"linear_term",
")",
"if",
"self",
".",
"constant",
"!=",
... | https://github.com/odlgroup/odl/blob/0b088df8dc4621c68b9414c3deff9127f4c4f11d/odl/solvers/functional/functional.py#L1070-L1104 | ||
chapmanb/cloudbiolinux | f6d0414bdba495944aaccf19ae55ba50b13da892 | cloudbio/custom/bio_nextgen.py | python | install_echo | (env) | ECHO: A reference-free short-read error correction algorithm
http://uc-echo.sourceforge.net/ | ECHO: A reference-free short-read error correction algorithm
http://uc-echo.sourceforge.net/ | [
"ECHO",
":",
"A",
"reference",
"-",
"free",
"short",
"-",
"read",
"error",
"correction",
"algorithm",
"http",
":",
"//",
"uc",
"-",
"echo",
".",
"sourceforge",
".",
"net",
"/"
] | def install_echo(env):
"""ECHO: A reference-free short-read error correction algorithm
http://uc-echo.sourceforge.net/
"""
version = "1_12"
url = "http://downloads.sourceforge.net/project/uc-echo/source%20release/" \
"echo_v{0}.tgz".format(version)
_get_install_local(url, env, _make_co... | [
"def",
"install_echo",
"(",
"env",
")",
":",
"version",
"=",
"\"1_12\"",
"url",
"=",
"\"http://downloads.sourceforge.net/project/uc-echo/source%20release/\"",
"\"echo_v{0}.tgz\"",
".",
"format",
"(",
"version",
")",
"_get_install_local",
"(",
"url",
",",
"env",
",",
"... | https://github.com/chapmanb/cloudbiolinux/blob/f6d0414bdba495944aaccf19ae55ba50b13da892/cloudbio/custom/bio_nextgen.py#L377-L384 | ||
weechat/scripts | 99ec0e7eceefabb9efb0f11ec26d45d6e8e84335 | python/mnotify.py | python | notify_dcc_send_start | (match) | Notify on DCC send start. | Notify on DCC send start. | [
"Notify",
"on",
"DCC",
"send",
"start",
"."
] | def notify_dcc_send_start(match):
'Notify on DCC send start.'
if (weechat.config_get_plugin("show_dcc") == "on"
or (weechat.config_get_plugin("show_dcc") == "away"
and STATE['is_away'])):
nick = match.group(1)
file_name = match.group(3)
a_notify(
'DCC',
... | [
"def",
"notify_dcc_send_start",
"(",
"match",
")",
":",
"if",
"(",
"weechat",
".",
"config_get_plugin",
"(",
"\"show_dcc\"",
")",
"==",
"\"on\"",
"or",
"(",
"weechat",
".",
"config_get_plugin",
"(",
"\"show_dcc\"",
")",
"==",
"\"away\"",
"and",
"STATE",
"[",
... | https://github.com/weechat/scripts/blob/99ec0e7eceefabb9efb0f11ec26d45d6e8e84335/python/mnotify.py#L406-L416 | ||
KhronosGroup/NNEF-Tools | c913758ca687dab8cb7b49e8f1556819a2d0ca25 | nnef_tools/io/tf/lite/flatbuffers/FloorDivOptions.py | python | FloorDivOptions.FloorDivOptionsBufferHasIdentifier | (cls, buf, offset, size_prefixed=False) | return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) | [] | def FloorDivOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) | [
"def",
"FloorDivOptionsBufferHasIdentifier",
"(",
"cls",
",",
"buf",
",",
"offset",
",",
"size_prefixed",
"=",
"False",
")",
":",
"return",
"flatbuffers",
".",
"util",
".",
"BufferHasIdentifier",
"(",
"buf",
",",
"offset",
",",
"b\"\\x54\\x46\\x4C\\x33\"",
",",
... | https://github.com/KhronosGroup/NNEF-Tools/blob/c913758ca687dab8cb7b49e8f1556819a2d0ca25/nnef_tools/io/tf/lite/flatbuffers/FloorDivOptions.py#L20-L21 | |||
asteroid-team/asteroid | fae2f7d1d4eb83da741818a5c375267fe8d98847 | asteroid/metrics.py | python | WERTracker.__call__ | (
self,
*,
mix: np.ndarray,
clean: np.ndarray,
estimate: np.ndarray,
sample_rate: int,
wav_id: List[str],
) | return dict(
input_wer=self.wer_from_hsdi(**dict(local_mix_counter)),
clean_wer=self.wer_from_hsdi(**dict(local_clean_counter)),
wer=self.wer_from_hsdi(**dict(local_est_counter)),
) | Compute and store best hypothesis for the mixture and the estimates | Compute and store best hypothesis for the mixture and the estimates | [
"Compute",
"and",
"store",
"best",
"hypothesis",
"for",
"the",
"mixture",
"and",
"the",
"estimates"
] | def __call__(
self,
*,
mix: np.ndarray,
clean: np.ndarray,
estimate: np.ndarray,
sample_rate: int,
wav_id: List[str],
):
"""Compute and store best hypothesis for the mixture and the estimates"""
if sample_rate != self.sample_rate:
m... | [
"def",
"__call__",
"(",
"self",
",",
"*",
",",
"mix",
":",
"np",
".",
"ndarray",
",",
"clean",
":",
"np",
".",
"ndarray",
",",
"estimate",
":",
"np",
".",
"ndarray",
",",
"sample_rate",
":",
"int",
",",
"wav_id",
":",
"List",
"[",
"str",
"]",
","... | https://github.com/asteroid-team/asteroid/blob/fae2f7d1d4eb83da741818a5c375267fe8d98847/asteroid/metrics.py#L258-L328 | |
cloudera/hue | 23f02102d4547c17c32bd5ea0eb24e9eadd657a4 | desktop/core/ext-py/pysaml2-4.9.0/src/saml2/server.py | python | Server.parse_authn_query | (self, xml_string, binding) | return self._parse_request(xml_string, AuthnQuery,
"authn_query_service", binding) | Parse an authn query
:param xml_string: The AuthnQuery as an XML string
:param binding: Which binding that was used when receiving this query
:return: Query instance | Parse an authn query | [
"Parse",
"an",
"authn",
"query"
] | def parse_authn_query(self, xml_string, binding):
""" Parse an authn query
:param xml_string: The AuthnQuery as an XML string
:param binding: Which binding that was used when receiving this query
:return: Query instance
"""
return self._parse_request(xml_string, AuthnQu... | [
"def",
"parse_authn_query",
"(",
"self",
",",
"xml_string",
",",
"binding",
")",
":",
"return",
"self",
".",
"_parse_request",
"(",
"xml_string",
",",
"AuthnQuery",
",",
"\"authn_query_service\"",
",",
"binding",
")"
] | https://github.com/cloudera/hue/blob/23f02102d4547c17c32bd5ea0eb24e9eadd657a4/desktop/core/ext-py/pysaml2-4.9.0/src/saml2/server.py#L266-L275 | |
isce-framework/isce2 | 0e5114a8bede3caf1d533d98e44dfe4b983e3f48 | components/isceobj/IsceProc/IsceProc.py | python | IsceProc.average | (self, objdict) | return s / float(N) | Average values in a dict of dict: { k1: { k2: ... } } | Average values in a dict of dict: { k1: { k2: ... } } | [
"Average",
"values",
"in",
"a",
"dict",
"of",
"dict",
":",
"{",
"k1",
":",
"{",
"k2",
":",
"...",
"}",
"}"
] | def average(self, objdict):
"""
Average values in a dict of dict: { k1: { k2: ... } }
"""
N = 0 ##number of values
s = 0 ##sum
vals = objdict.values()
for val in vals:
###val is a dictionary
N += len(val)
s += sum(val.values())
... | [
"def",
"average",
"(",
"self",
",",
"objdict",
")",
":",
"N",
"=",
"0",
"##number of values",
"s",
"=",
"0",
"##sum",
"vals",
"=",
"objdict",
".",
"values",
"(",
")",
"for",
"val",
"in",
"vals",
":",
"###val is a dictionary",
"N",
"+=",
"len",
"(",
"... | https://github.com/isce-framework/isce2/blob/0e5114a8bede3caf1d533d98e44dfe4b983e3f48/components/isceobj/IsceProc/IsceProc.py#L361-L372 | |
napari/napari | dbf4158e801fa7a429de8ef1cdee73bf6d64c61e | napari/layers/utils/layer_utils.py | python | validate_properties | (
properties: Optional[Union[Dict[str, Array], pd.DataFrame]],
expected_len: Optional[int] = None,
) | return {k: np.asarray(v) for k, v in properties.items()} | Validate the type and size of properties and coerce values to numpy arrays.
Parameters
----------
properties : dict[str, Array] or DataFrame
The property values.
expected_len : int
The expected length of each property value array.
Returns
-------
Dict[str, np.ndarray]
... | Validate the type and size of properties and coerce values to numpy arrays.
Parameters
----------
properties : dict[str, Array] or DataFrame
The property values.
expected_len : int
The expected length of each property value array.
Returns
-------
Dict[str, np.ndarray]
... | [
"Validate",
"the",
"type",
"and",
"size",
"of",
"properties",
"and",
"coerce",
"values",
"to",
"numpy",
"arrays",
".",
"Parameters",
"----------",
"properties",
":",
"dict",
"[",
"str",
"Array",
"]",
"or",
"DataFrame",
"The",
"property",
"values",
".",
"expe... | def validate_properties(
properties: Optional[Union[Dict[str, Array], pd.DataFrame]],
expected_len: Optional[int] = None,
) -> Dict[str, np.ndarray]:
"""Validate the type and size of properties and coerce values to numpy arrays.
Parameters
----------
properties : dict[str, Array] or DataFrame
... | [
"def",
"validate_properties",
"(",
"properties",
":",
"Optional",
"[",
"Union",
"[",
"Dict",
"[",
"str",
",",
"Array",
"]",
",",
"pd",
".",
"DataFrame",
"]",
"]",
",",
"expected_len",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
")",
"->",
"Di... | https://github.com/napari/napari/blob/dbf4158e801fa7a429de8ef1cdee73bf6d64c61e/napari/layers/utils/layer_utils.py#L377-L410 | |
shawnwun/NNDIAL | 740f6d34594bcdd889080ce60c95384bda7594a2 | utils/bleu.py | python | sentence_bleu_4 | (hyp,refs,weights=[0.25,0.25,0.25,0.25]) | return bleu_hyp | print
print hyp
print refs
print clip_count
print count
print r, c
print bp
print p_ns
print math.exp(s)
print bleu_hyp
raw_input() | print
print hyp
print refs | [
"print",
"print",
"hyp",
"print",
"refs"
] | def sentence_bleu_4(hyp,refs,weights=[0.25,0.25,0.25,0.25]):
# input : single sentence, multiple references
count = [0,0,0,0]
clip_count = [0,0,0,0]
r = 0
c = 0
for i in range(4):
hypcnts = Counter(ngrams(hyp, i+1))
cnt = sum(hypcnts.values())
count[i] += cnt
... | [
"def",
"sentence_bleu_4",
"(",
"hyp",
",",
"refs",
",",
"weights",
"=",
"[",
"0.25",
",",
"0.25",
",",
"0.25",
",",
"0.25",
"]",
")",
":",
"# input : single sentence, multiple references",
"count",
"=",
"[",
"0",
",",
"0",
",",
"0",
",",
"0",
"]",
"cli... | https://github.com/shawnwun/NNDIAL/blob/740f6d34594bcdd889080ce60c95384bda7594a2/utils/bleu.py#L12-L65 | |
astropy/photutils | 3caa48e4e4d139976ed7457dc41583fb2c56ba20 | photutils/segmentation/catalog.py | python | SourceCatalog.covar_sigxy | (self) | return self._covariance[:, 0, 1] * u.pix**2 | r"""
The ``(0, 1)`` and ``(1, 0)`` elements of the `covariance`
matrix, representing :math:`\sigma_x \sigma_y`, in units of
pixel**2. | r"""
The ``(0, 1)`` and ``(1, 0)`` elements of the `covariance`
matrix, representing :math:`\sigma_x \sigma_y`, in units of
pixel**2. | [
"r",
"The",
"(",
"0",
"1",
")",
"and",
"(",
"1",
"0",
")",
"elements",
"of",
"the",
"covariance",
"matrix",
"representing",
":",
"math",
":",
"\\",
"sigma_x",
"\\",
"sigma_y",
"in",
"units",
"of",
"pixel",
"**",
"2",
"."
] | def covar_sigxy(self):
r"""
The ``(0, 1)`` and ``(1, 0)`` elements of the `covariance`
matrix, representing :math:`\sigma_x \sigma_y`, in units of
pixel**2.
"""
return self._covariance[:, 0, 1] * u.pix**2 | [
"def",
"covar_sigxy",
"(",
"self",
")",
":",
"return",
"self",
".",
"_covariance",
"[",
":",
",",
"0",
",",
"1",
"]",
"*",
"u",
".",
"pix",
"**",
"2"
] | https://github.com/astropy/photutils/blob/3caa48e4e4d139976ed7457dc41583fb2c56ba20/photutils/segmentation/catalog.py#L1875-L1881 | |
Abjad/abjad | d0646dfbe83db3dc5ab268f76a0950712b87b7fd | abjad/pattern.py | python | Pattern.get_boolean_vector | (self, total_length=None) | return boolean_vector | Gets boolean vector of pattern applied to input sequence with
``total_length``.
.. container:: example
Gets boolean vector of acyclic pattern:
>>> pattern = abjad.Pattern(
... indices=[4, 5, 6, 7],
... )
>>> pattern.get_boolean_ve... | Gets boolean vector of pattern applied to input sequence with
``total_length``. | [
"Gets",
"boolean",
"vector",
"of",
"pattern",
"applied",
"to",
"input",
"sequence",
"with",
"total_length",
"."
] | def get_boolean_vector(self, total_length=None):
"""
Gets boolean vector of pattern applied to input sequence with
``total_length``.
.. container:: example
Gets boolean vector of acyclic pattern:
>>> pattern = abjad.Pattern(
... indices=[4, 5, ... | [
"def",
"get_boolean_vector",
"(",
"self",
",",
"total_length",
"=",
"None",
")",
":",
"total_length",
"=",
"total_length",
"or",
"len",
"(",
"self",
")",
"boolean_vector",
"=",
"[",
"]",
"for",
"index",
"in",
"range",
"(",
"total_length",
")",
":",
"result... | https://github.com/Abjad/abjad/blob/d0646dfbe83db3dc5ab268f76a0950712b87b7fd/abjad/pattern.py#L1247-L1435 | |
awslabs/aws-ec2rescue-linux | 8ecf40e7ea0d2563dac057235803fca2221029d2 | lib/urllib3/filepost.py | python | choose_boundary | () | return boundary | Our embarrassingly-simple replacement for mimetools.choose_boundary. | Our embarrassingly-simple replacement for mimetools.choose_boundary. | [
"Our",
"embarrassingly",
"-",
"simple",
"replacement",
"for",
"mimetools",
".",
"choose_boundary",
"."
] | def choose_boundary():
"""
Our embarrassingly-simple replacement for mimetools.choose_boundary.
"""
boundary = binascii.hexlify(os.urandom(16))
if not six.PY2:
boundary = boundary.decode("ascii")
return boundary | [
"def",
"choose_boundary",
"(",
")",
":",
"boundary",
"=",
"binascii",
".",
"hexlify",
"(",
"os",
".",
"urandom",
"(",
"16",
")",
")",
"if",
"not",
"six",
".",
"PY2",
":",
"boundary",
"=",
"boundary",
".",
"decode",
"(",
"\"ascii\"",
")",
"return",
"b... | https://github.com/awslabs/aws-ec2rescue-linux/blob/8ecf40e7ea0d2563dac057235803fca2221029d2/lib/urllib3/filepost.py#L15-L22 | |
raymontag/keepassc | 3a3c7ef7b3ee1ceb16b613176d54dad89c0408df | keepassc/daemon.py | python | Daemon.run | (self) | You should override this method when you subclass Daemon.
It will be called after the process has been daemonized by
start() or restart(). | You should override this method when you subclass Daemon.
It will be called after the process has been daemonized by
start() or restart(). | [
"You",
"should",
"override",
"this",
"method",
"when",
"you",
"subclass",
"Daemon",
".",
"It",
"will",
"be",
"called",
"after",
"the",
"process",
"has",
"been",
"daemonized",
"by",
"start",
"()",
"or",
"restart",
"()",
"."
] | def run(self):
"""You should override this method when you subclass Daemon.
It will be called after the process has been daemonized by
start() or restart().""" | [
"def",
"run",
"(",
"self",
")",
":"
] | https://github.com/raymontag/keepassc/blob/3a3c7ef7b3ee1ceb16b613176d54dad89c0408df/keepassc/daemon.py#L118-L122 | ||
AppScale/gts | 46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9 | AppServer/google/appengine/ext/ndb/blobstore.py | python | BlobInfo.get_multi | (cls, blob_keys, **ctx_options) | return [fut.get_result() for fut in futs] | Multi-key version of get().
Args:
blob_keys: A list of blob keys.
**ctx_options: Context options for Model().get_by_id().
Returns:
A list whose items are each either a BlobInfo entity or None. | Multi-key version of get(). | [
"Multi",
"-",
"key",
"version",
"of",
"get",
"()",
"."
] | def get_multi(cls, blob_keys, **ctx_options):
"""Multi-key version of get().
Args:
blob_keys: A list of blob keys.
**ctx_options: Context options for Model().get_by_id().
Returns:
A list whose items are each either a BlobInfo entity or None.
"""
futs = cls.get_multi_async(blob_ke... | [
"def",
"get_multi",
"(",
"cls",
",",
"blob_keys",
",",
"*",
"*",
"ctx_options",
")",
":",
"futs",
"=",
"cls",
".",
"get_multi_async",
"(",
"blob_keys",
",",
"*",
"*",
"ctx_options",
")",
"return",
"[",
"fut",
".",
"get_result",
"(",
")",
"for",
"fut",
... | https://github.com/AppScale/gts/blob/46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9/AppServer/google/appengine/ext/ndb/blobstore.py#L176-L187 | |
nopernik/mpDNS | b17dc39e7068406df82cb3431b3042e74e520cf9 | circuits/net/sockets.py | python | parse_ipv4_parameter | (bind_parameter) | return bind | [] | def parse_ipv4_parameter(bind_parameter):
if isinstance(bind_parameter, int):
try:
bind = (gethostbyname(gethostname()), bind_parameter)
except gaierror:
bind = ("0.0.0.0", bind_parameter)
elif isinstance(bind_parameter, str) and ":" in bind_parameter:
host, port ... | [
"def",
"parse_ipv4_parameter",
"(",
"bind_parameter",
")",
":",
"if",
"isinstance",
"(",
"bind_parameter",
",",
"int",
")",
":",
"try",
":",
"bind",
"=",
"(",
"gethostbyname",
"(",
"gethostname",
"(",
")",
")",
",",
"bind_parameter",
")",
"except",
"gaierror... | https://github.com/nopernik/mpDNS/blob/b17dc39e7068406df82cb3431b3042e74e520cf9/circuits/net/sockets.py#L666-L679 | |||
ronf/asyncssh | ee1714c598d8c2ea6f5484e465443f38b68714aa | asyncssh/packet.py | python | UInt32 | (value: int) | return value.to_bytes(4, 'big') | Encode a 32-bit integer value | Encode a 32-bit integer value | [
"Encode",
"a",
"32",
"-",
"bit",
"integer",
"value"
] | def UInt32(value: int) -> bytes:
"""Encode a 32-bit integer value"""
return value.to_bytes(4, 'big') | [
"def",
"UInt32",
"(",
"value",
":",
"int",
")",
"->",
"bytes",
":",
"return",
"value",
".",
"to_bytes",
"(",
"4",
",",
"'big'",
")"
] | https://github.com/ronf/asyncssh/blob/ee1714c598d8c2ea6f5484e465443f38b68714aa/asyncssh/packet.py#L55-L58 | |
openedx/edx-platform | 68dd185a0ab45862a2a61e0f803d7e03d2be71b5 | common/djangoapps/student/views/dashboard.py | python | get_org_black_and_whitelist_for_site | () | return org_whitelist, org_blacklist | Returns the org blacklist and whitelist for the current site.
Returns:
(org_whitelist, org_blacklist): A tuple of lists of orgs that serve as
either a blacklist or a whitelist of orgs for the current site. The
whitelist takes precedence, and the blacklist is used if the
... | Returns the org blacklist and whitelist for the current site. | [
"Returns",
"the",
"org",
"blacklist",
"and",
"whitelist",
"for",
"the",
"current",
"site",
"."
] | def get_org_black_and_whitelist_for_site():
"""
Returns the org blacklist and whitelist for the current site.
Returns:
(org_whitelist, org_blacklist): A tuple of lists of orgs that serve as
either a blacklist or a whitelist of orgs for the current site. The
whitelist takes p... | [
"def",
"get_org_black_and_whitelist_for_site",
"(",
")",
":",
"# Default blacklist is empty.",
"org_blacklist",
"=",
"None",
"# Whitelist the orgs configured for the current site. Each site outside",
"# of edx.org has a list of orgs associated with its configuration.",
"org_whitelist",
"=",... | https://github.com/openedx/edx-platform/blob/68dd185a0ab45862a2a61e0f803d7e03d2be71b5/common/djangoapps/student/views/dashboard.py#L68-L90 | |
beringresearch/ivis | 690d610d62be786b7a9a98debe57129bae678095 | ivis/data/generators/triplet_generators.py | python | TripletGenerator.gen_negative_indices | (self, neighbour_matrix) | return cands | Generate random candidate negative indices until the candidate for every
row is not present in corresponding row of neighbour_matrix. | Generate random candidate negative indices until the candidate for every
row is not present in corresponding row of neighbour_matrix. | [
"Generate",
"random",
"candidate",
"negative",
"indices",
"until",
"the",
"candidate",
"for",
"every",
"row",
"is",
"not",
"present",
"in",
"corresponding",
"row",
"of",
"neighbour_matrix",
"."
] | def gen_negative_indices(self, neighbour_matrix):
"""Generate random candidate negative indices until the candidate for every
row is not present in corresponding row of neighbour_matrix."""
neighbour_matrix = np.asarray(neighbour_matrix)
generate_cands = partial(np.random.randint, self.X... | [
"def",
"gen_negative_indices",
"(",
"self",
",",
"neighbour_matrix",
")",
":",
"neighbour_matrix",
"=",
"np",
".",
"asarray",
"(",
"neighbour_matrix",
")",
"generate_cands",
"=",
"partial",
"(",
"np",
".",
"random",
".",
"randint",
",",
"self",
".",
"X",
"."... | https://github.com/beringresearch/ivis/blob/690d610d62be786b7a9a98debe57129bae678095/ivis/data/generators/triplet_generators.py#L92-L106 | |
danilobellini/audiolazy | dba0a278937909980ed40b976d866b8e97c35dee | audiolazy/lazy_itertools.py | python | accumulate | (iterable) | Return series of accumulated sums. | Return series of accumulated sums. | [
"Return",
"series",
"of",
"accumulated",
"sums",
"."
] | def accumulate(iterable):
" Return series of accumulated sums. "
iterator = iter(iterable)
sum_data = next(iterator)
yield sum_data
for el in iterator:
sum_data += el
yield sum_data | [
"def",
"accumulate",
"(",
"iterable",
")",
":",
"iterator",
"=",
"iter",
"(",
"iterable",
")",
"sum_data",
"=",
"next",
"(",
"iterator",
")",
"yield",
"sum_data",
"for",
"el",
"in",
"iterator",
":",
"sum_data",
"+=",
"el",
"yield",
"sum_data"
] | https://github.com/danilobellini/audiolazy/blob/dba0a278937909980ed40b976d866b8e97c35dee/audiolazy/lazy_itertools.py#L69-L76 | ||
AppScale/gts | 46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9 | AppServer/lib/webapp2-2.5.2/webapp2_extras/i18n.py | python | I18n.parse_decimal | (self, string) | return numbers.parse_decimal(string, locale=self.locale) | Parses localized decimal string into a float. Example::
>>> parse_decimal('1,099.98', locale='en_US')
1099.98
>>> parse_decimal('1.099,98', locale='de')
1099.98
When the given string cannot be parsed, an exception is raised::
>>> parse_decimal('2,10... | Parses localized decimal string into a float. Example:: | [
"Parses",
"localized",
"decimal",
"string",
"into",
"a",
"float",
".",
"Example",
"::"
] | def parse_decimal(self, string):
"""Parses localized decimal string into a float. Example::
>>> parse_decimal('1,099.98', locale='en_US')
1099.98
>>> parse_decimal('1.099,98', locale='de')
1099.98
When the given string cannot be parsed, an exception is r... | [
"def",
"parse_decimal",
"(",
"self",
",",
"string",
")",
":",
"return",
"numbers",
".",
"parse_decimal",
"(",
"string",
",",
"locale",
"=",
"self",
".",
"locale",
")"
] | https://github.com/AppScale/gts/blob/46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9/AppServer/lib/webapp2-2.5.2/webapp2_extras/i18n.py#L655-L678 | |
a312863063/seeprettyface-face_editor | 0a318ef8128ffca6929aea348457a70e6127087d | dnnlib/tflib/optimizer.py | python | Optimizer.register_gradients | (self, loss: TfExpression, trainable_vars: Union[List, dict]) | Register the gradients of the given loss function with respect to the given variables.
Intended to be called once per GPU. | Register the gradients of the given loss function with respect to the given variables.
Intended to be called once per GPU. | [
"Register",
"the",
"gradients",
"of",
"the",
"given",
"loss",
"function",
"with",
"respect",
"to",
"the",
"given",
"variables",
".",
"Intended",
"to",
"be",
"called",
"once",
"per",
"GPU",
"."
] | def register_gradients(self, loss: TfExpression, trainable_vars: Union[List, dict]) -> None:
"""Register the gradients of the given loss function with respect to the given variables.
Intended to be called once per GPU."""
assert not self._updates_applied
# Validate arguments.
if... | [
"def",
"register_gradients",
"(",
"self",
",",
"loss",
":",
"TfExpression",
",",
"trainable_vars",
":",
"Union",
"[",
"List",
",",
"dict",
"]",
")",
"->",
"None",
":",
"assert",
"not",
"self",
".",
"_updates_applied",
"# Validate arguments.",
"if",
"isinstance... | https://github.com/a312863063/seeprettyface-face_editor/blob/0a318ef8128ffca6929aea348457a70e6127087d/dnnlib/tflib/optimizer.py#L67-L100 | ||
home-assistant/core | 265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1 | homeassistant/helpers/device_registry.py | python | DeviceRegistry.async_load | (self) | Load the device registry. | Load the device registry. | [
"Load",
"the",
"device",
"registry",
"."
] | async def async_load(self) -> None:
"""Load the device registry."""
async_setup_cleanup(self.hass, self)
data = await self._store.async_load()
devices = OrderedDict()
deleted_devices = OrderedDict()
if data is not None:
data = cast("dict[str, Any]", data)
... | [
"async",
"def",
"async_load",
"(",
"self",
")",
"->",
"None",
":",
"async_setup_cleanup",
"(",
"self",
".",
"hass",
",",
"self",
")",
"data",
"=",
"await",
"self",
".",
"_store",
".",
"async_load",
"(",
")",
"devices",
"=",
"OrderedDict",
"(",
")",
"de... | https://github.com/home-assistant/core/blob/265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1/homeassistant/helpers/device_registry.py#L538-L585 | ||
beville/ComicStreamer | 62eb914652695ea41a5e1f0cfbd044cbc6854e84 | comicstreamerlib/bookmarker.py | python | Bookmarker.stop | (self) | [] | def stop(self):
self.quit = True
self.join() | [
"def",
"stop",
"(",
"self",
")",
":",
"self",
".",
"quit",
"=",
"True",
"self",
".",
"join",
"(",
")"
] | https://github.com/beville/ComicStreamer/blob/62eb914652695ea41a5e1f0cfbd044cbc6854e84/comicstreamerlib/bookmarker.py#L41-L43 | ||||
skylander86/lambda-text-extractor | 6da52d077a2fc571e38bfe29c33ae68f6443cd5a | lib-linux_x64/odf/odf2xhtml.py | python | ODF2XHTML.s_table_table_cell | (self, tag, attrs) | Start a table cell | Start a table cell | [
"Start",
"a",
"table",
"cell"
] | def s_table_table_cell(self, tag, attrs):
""" Start a table cell """
#FIXME: number-columns-repeated § 8.1.3
#repeated = int(attrs.get( (TABLENS,'number-columns-repeated'), 1))
htmlattrs = {}
rowspan = attrs.get( (TABLENS,'number-rows-spanned') )
if rowspan:
h... | [
"def",
"s_table_table_cell",
"(",
"self",
",",
"tag",
",",
"attrs",
")",
":",
"#FIXME: number-columns-repeated § 8.1.3",
"#repeated = int(attrs.get( (TABLENS,'number-columns-repeated'), 1))",
"htmlattrs",
"=",
"{",
"}",
"rowspan",
"=",
"attrs",
".",
"get",
"(",
"(",
"TA... | https://github.com/skylander86/lambda-text-extractor/blob/6da52d077a2fc571e38bfe29c33ae68f6443cd5a/lib-linux_x64/odf/odf2xhtml.py#L1096-L1112 | ||
nikitakit/self-attentive-parser | 24435a156a64d7433829e9a500a81f46b7e58030 | src/transliterate.py | python | hebrew | (inp) | return out | Undo Hebrew transliteration
See: http://www.phil.uu.nl/ozsl/articles/simaan02.pdf
This code inspired by:
https://github.com/habeanf/yap/blob/b57502364b73ef78f3510eb890319ae268eeacca/nlp/parser/xliter8/types.go | Undo Hebrew transliteration | [
"Undo",
"Hebrew",
"transliteration"
] | def hebrew(inp):
"""
Undo Hebrew transliteration
See: http://www.phil.uu.nl/ozsl/articles/simaan02.pdf
This code inspired by:
https://github.com/habeanf/yap/blob/b57502364b73ef78f3510eb890319ae268eeacca/nlp/parser/xliter8/types.go
"""
out = "".join(
HEBREW_MAP.get(char, char)
... | [
"def",
"hebrew",
"(",
"inp",
")",
":",
"out",
"=",
"\"\"",
".",
"join",
"(",
"HEBREW_MAP",
".",
"get",
"(",
"char",
",",
"char",
")",
"for",
"char",
"in",
"HEBREW_UNESCAPE",
".",
"get",
"(",
"inp",
",",
"inp",
")",
")",
"if",
"out",
"and",
"(",
... | https://github.com/nikitakit/self-attentive-parser/blob/24435a156a64d7433829e9a500a81f46b7e58030/src/transliterate.py#L142-L156 | |
Northxw/Python3_WebSpider | 903044564a09f470516a51ab2fa457b3c6f6c7a9 | 09-Bilibili/bilibili.py | python | Crack_bb.move_to_gap | (self, slider, tracks) | 拖动滑块到缺口位置
:param slider: 滑块
:param tracks: 轨迹
:return: None | 拖动滑块到缺口位置
:param slider: 滑块
:param tracks: 轨迹
:return: None | [
"拖动滑块到缺口位置",
":",
"param",
"slider",
":",
"滑块",
":",
"param",
"tracks",
":",
"轨迹",
":",
"return",
":",
"None"
] | def move_to_gap(self, slider, tracks):
"""
拖动滑块到缺口位置
:param slider: 滑块
:param tracks: 轨迹
:return: None
"""
# 按住鼠标准备拖动
ActionChains(self.browser).click_and_hold(slider).perform()
# 拖动滑块
for x in tracks:
ActionChains(self.browser)... | [
"def",
"move_to_gap",
"(",
"self",
",",
"slider",
",",
"tracks",
")",
":",
"# 按住鼠标准备拖动",
"ActionChains",
"(",
"self",
".",
"browser",
")",
".",
"click_and_hold",
"(",
"slider",
")",
".",
"perform",
"(",
")",
"# 拖动滑块",
"for",
"x",
"in",
"tracks",
":",
"... | https://github.com/Northxw/Python3_WebSpider/blob/903044564a09f470516a51ab2fa457b3c6f6c7a9/09-Bilibili/bilibili.py#L179-L193 | ||
mdiazcl/fuzzbunch-debian | 2b76c2249ade83a389ae3badb12a1bd09901fd2c | windows/Resources/Python/Core/Lib/random.py | python | Random._randbelow | (self, n, _log=_log, int=int, _maxwidth=1 << BPF, _Method=_MethodType, _BuiltinMethod=_BuiltinMethodType) | return int(self.random() * n) | Return a random int in the range [0,n)
Handles the case where n has more bits than returned
by a single call to the underlying generator. | Return a random int in the range [0,n)
Handles the case where n has more bits than returned
by a single call to the underlying generator. | [
"Return",
"a",
"random",
"int",
"in",
"the",
"range",
"[",
"0",
"n",
")",
"Handles",
"the",
"case",
"where",
"n",
"has",
"more",
"bits",
"than",
"returned",
"by",
"a",
"single",
"call",
"to",
"the",
"underlying",
"generator",
"."
] | def _randbelow(self, n, _log=_log, int=int, _maxwidth=1 << BPF, _Method=_MethodType, _BuiltinMethod=_BuiltinMethodType):
"""Return a random int in the range [0,n)
Handles the case where n has more bits than returned
by a single call to the underlying generator.
"""
try:
... | [
"def",
"_randbelow",
"(",
"self",
",",
"n",
",",
"_log",
"=",
"_log",
",",
"int",
"=",
"int",
",",
"_maxwidth",
"=",
"1",
"<<",
"BPF",
",",
"_Method",
"=",
"_MethodType",
",",
"_BuiltinMethod",
"=",
"_BuiltinMethodType",
")",
":",
"try",
":",
"getrandb... | https://github.com/mdiazcl/fuzzbunch-debian/blob/2b76c2249ade83a389ae3badb12a1bd09901fd2c/windows/Resources/Python/Core/Lib/random.py#L203-L224 | |
VLSIDA/OpenRAM | f66aac3264598eeae31225c62b6a4af52412d407 | compiler/pgates/pinv.py | python | pinv.create_layout | (self) | Calls all functions related to the generation of the layout | Calls all functions related to the generation of the layout | [
"Calls",
"all",
"functions",
"related",
"to",
"the",
"generation",
"of",
"the",
"layout"
] | def create_layout(self):
""" Calls all functions related to the generation of the layout """
self.place_ptx()
if self.add_wells:
self.add_well_contacts()
self.determine_width()
self.extend_wells()
self.route_input_gate(self.pmos_inst,
... | [
"def",
"create_layout",
"(",
"self",
")",
":",
"self",
".",
"place_ptx",
"(",
")",
"if",
"self",
".",
"add_wells",
":",
"self",
".",
"add_well_contacts",
"(",
")",
"self",
".",
"determine_width",
"(",
")",
"self",
".",
"extend_wells",
"(",
")",
"self",
... | https://github.com/VLSIDA/OpenRAM/blob/f66aac3264598eeae31225c62b6a4af52412d407/compiler/pgates/pinv.py#L57-L72 | ||
mysql/mysql-connector-python | c5460bcbb0dff8e4e48bf4af7a971c89bf486d85 | lib/mysqlx/result.py | python | Result.get_generated_ids | (self) | return self._generated_ids | Returns the generated ids. | Returns the generated ids. | [
"Returns",
"the",
"generated",
"ids",
"."
] | def get_generated_ids(self):
"""Returns the generated ids.
"""
return self._generated_ids | [
"def",
"get_generated_ids",
"(",
"self",
")",
":",
"return",
"self",
".",
"_generated_ids"
] | https://github.com/mysql/mysql-connector-python/blob/c5460bcbb0dff8e4e48bf4af7a971c89bf486d85/lib/mysqlx/result.py#L918-L921 | |
dayorbyte/MongoAlchemy | e64ef0c87feff385637459707fe6090bd789e116 | mongoalchemy/query.py | python | Query.descending | (self, qfield) | return self.__sort(qfield, DESCENDING) | Sort the result based on ``qfield`` in ascending order. These calls
can be chained to sort by multiple fields.
:param qfield: Instance of :class:``mongoalchemy.query.QueryField`` \
specifying which field to sort by. | Sort the result based on ``qfield`` in ascending order. These calls
can be chained to sort by multiple fields. | [
"Sort",
"the",
"result",
"based",
"on",
"qfield",
"in",
"ascending",
"order",
".",
"These",
"calls",
"can",
"be",
"chained",
"to",
"sort",
"by",
"multiple",
"fields",
"."
] | def descending(self, qfield):
''' Sort the result based on ``qfield`` in ascending order. These calls
can be chained to sort by multiple fields.
:param qfield: Instance of :class:``mongoalchemy.query.QueryField`` \
specifying which field to sort by.
'''
... | [
"def",
"descending",
"(",
"self",
",",
"qfield",
")",
":",
"return",
"self",
".",
"__sort",
"(",
"qfield",
",",
"DESCENDING",
")"
] | https://github.com/dayorbyte/MongoAlchemy/blob/e64ef0c87feff385637459707fe6090bd789e116/mongoalchemy/query.py#L268-L275 | |
deepgram/kur | fd0c120e50815c1e5be64e5dde964dcd47234556 | kur/utils/cuda.py | python | ready | (func) | return wrapper | Decorator for a class instance method which requires that the class's
"_ready" property be set. | Decorator for a class instance method which requires that the class's
"_ready" property be set. | [
"Decorator",
"for",
"a",
"class",
"instance",
"method",
"which",
"requires",
"that",
"the",
"class",
"s",
"_ready",
"property",
"be",
"set",
"."
] | def ready(func):
""" Decorator for a class instance method which requires that the class's
"_ready" property be set.
"""
###########################################################################
@wraps(func)
def wrapper(self, *args, **kwargs):
""" The wrapped function.
"""
if not self._ready:
raise V... | [
"def",
"ready",
"(",
"func",
")",
":",
"###########################################################################",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\" The wrapped function.\n\... | https://github.com/deepgram/kur/blob/fd0c120e50815c1e5be64e5dde964dcd47234556/kur/utils/cuda.py#L57-L73 | |
jacoxu/encoder_decoder | 6829c3bc42105aedfd1b8a81c81be19df4326c0a | keras/models.py | python | model_from_yaml | (yaml_string, custom_objects={}) | return model_from_config(config, custom_objects=custom_objects) | Returns a model generated from a local yaml file,
which is either created by hand or from to_yaml method
of Sequential or Graph | Returns a model generated from a local yaml file,
which is either created by hand or from to_yaml method
of Sequential or Graph | [
"Returns",
"a",
"model",
"generated",
"from",
"a",
"local",
"yaml",
"file",
"which",
"is",
"either",
"created",
"by",
"hand",
"or",
"from",
"to_yaml",
"method",
"of",
"Sequential",
"or",
"Graph"
] | def model_from_yaml(yaml_string, custom_objects={}):
'''
Returns a model generated from a local yaml file,
which is either created by hand or from to_yaml method
of Sequential or Graph
'''
import yaml
config = yaml.load(yaml_string)
return model_from_config(config, custom_obj... | [
"def",
"model_from_yaml",
"(",
"yaml_string",
",",
"custom_objects",
"=",
"{",
"}",
")",
":",
"import",
"yaml",
"config",
"=",
"yaml",
".",
"load",
"(",
"yaml_string",
")",
"return",
"model_from_config",
"(",
"config",
",",
"custom_objects",
"=",
"custom_objec... | https://github.com/jacoxu/encoder_decoder/blob/6829c3bc42105aedfd1b8a81c81be19df4326c0a/keras/models.py#L152-L160 | |
cltk/cltk | 1a8c2f5ef72389e2579dfce1fa5af8e59ebc9ec1 | src/cltk/tag/pos.py | python | POSTag.tag_tnt | (self, untagged_string: str) | return tagged_text | Tag POS with TnT tagger.
:type untagged_string: str
:param : An untagged, untokenized string of text.
:rtype tagged_text: str | Tag POS with TnT tagger.
:type untagged_string: str
:param : An untagged, untokenized string of text.
:rtype tagged_text: str | [
"Tag",
"POS",
"with",
"TnT",
"tagger",
".",
":",
"type",
"untagged_string",
":",
"str",
":",
"param",
":",
"An",
"untagged",
"untokenized",
"string",
"of",
"text",
".",
":",
"rtype",
"tagged_text",
":",
"str"
] | def tag_tnt(self, untagged_string: str):
"""Tag POS with TnT tagger.
:type untagged_string: str
:param : An untagged, untokenized string of text.
:rtype tagged_text: str
"""
untagged_tokens = wordpunct_tokenize(untagged_string)
tagger = self._load_model("tnt")
... | [
"def",
"tag_tnt",
"(",
"self",
",",
"untagged_string",
":",
"str",
")",
":",
"untagged_tokens",
"=",
"wordpunct_tokenize",
"(",
"untagged_string",
")",
"tagger",
"=",
"self",
".",
"_load_model",
"(",
"\"tnt\"",
")",
"tagged_text",
"=",
"tagger",
".",
"tag",
... | https://github.com/cltk/cltk/blob/1a8c2f5ef72389e2579dfce1fa5af8e59ebc9ec1/src/cltk/tag/pos.py#L143-L152 | |
facebookresearch/pyrobot | 27ffd64bbb7ce3ff6ec4b2122d84b438d5641d0f | examples/grasping/grasp_samplers/grasp_object.py | python | GraspTorchObj.convert_hw | (self, h) | return torch.FloatTensor(h) | Converts a list of floats to a torch Tensor
:param h: List of floats
:type h: list
:returns: A torch FloatTensor
:rtype: torch FloatTensor | Converts a list of floats to a torch Tensor
:param h: List of floats
:type h: list
:returns: A torch FloatTensor
:rtype: torch FloatTensor | [
"Converts",
"a",
"list",
"of",
"floats",
"to",
"a",
"torch",
"Tensor",
":",
"param",
"h",
":",
"List",
"of",
"floats",
":",
"type",
"h",
":",
"list",
":",
"returns",
":",
"A",
"torch",
"FloatTensor",
":",
"rtype",
":",
"torch",
"FloatTensor"
] | def convert_hw(self, h):
"""
Converts a list of floats to a torch Tensor
:param h: List of floats
:type h: list
:returns: A torch FloatTensor
:rtype: torch FloatTensor
"""
return torch.FloatTensor(h) | [
"def",
"convert_hw",
"(",
"self",
",",
"h",
")",
":",
"return",
"torch",
".",
"FloatTensor",
"(",
"h",
")"
] | https://github.com/facebookresearch/pyrobot/blob/27ffd64bbb7ce3ff6ec4b2122d84b438d5641d0f/examples/grasping/grasp_samplers/grasp_object.py#L119-L129 | |
Project-Platypus/Platypus | a4e56410a772798e905407e99f80d03b86296ad3 | platypus/algorithms.py | python | SMPSO._mutate | (self) | [] | def _mutate(self):
for i in range(self.swarm_size):
if i % 6 == 0:
self.particles[i] = self.mutate.mutate(self.particles[i]) | [
"def",
"_mutate",
"(",
"self",
")",
":",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"swarm_size",
")",
":",
"if",
"i",
"%",
"6",
"==",
"0",
":",
"self",
".",
"particles",
"[",
"i",
"]",
"=",
"self",
".",
"mutate",
".",
"mutate",
"(",
"self",
... | https://github.com/Project-Platypus/Platypus/blob/a4e56410a772798e905407e99f80d03b86296ad3/platypus/algorithms.py#L1023-L1026 | ||||
PyMVPA/PyMVPA | 76c476b3de8264b0bb849bf226da5674d659564e | mvpa2/clfs/model_selector.py | python | ModelSelector.__init__ | (self, parametric_model, dataset) | TODO: | TODO: | [
"TODO",
":"
] | def __init__(self, parametric_model, dataset):
"""TODO:
"""
self.parametric_model = parametric_model
self.dataset = dataset
self.hyperparameters_best = None
self.log_marginal_likelihood_best = None
self.problem = None
pass | [
"def",
"__init__",
"(",
"self",
",",
"parametric_model",
",",
"dataset",
")",
":",
"self",
".",
"parametric_model",
"=",
"parametric_model",
"self",
".",
"dataset",
"=",
"dataset",
"self",
".",
"hyperparameters_best",
"=",
"None",
"self",
".",
"log_marginal_like... | https://github.com/PyMVPA/PyMVPA/blob/76c476b3de8264b0bb849bf226da5674d659564e/mvpa2/clfs/model_selector.py#L51-L59 | ||
rajarshd/Multi-Step-Reasoning | 3218d626839f7217554f38d82e00e4f460b508e4 | msr/reader/utils.py | python | f1_score | (prediction, ground_truth) | return f1 | Compute the geometric mean of precision and recall for answer tokens. | Compute the geometric mean of precision and recall for answer tokens. | [
"Compute",
"the",
"geometric",
"mean",
"of",
"precision",
"and",
"recall",
"for",
"answer",
"tokens",
"."
] | def f1_score(prediction, ground_truth):
"""Compute the geometric mean of precision and recall for answer tokens."""
prediction_tokens = normalize_answer(prediction).split()
ground_truth_tokens = normalize_answer(ground_truth).split()
common = Counter(prediction_tokens) & Counter(ground_truth_tokens)
... | [
"def",
"f1_score",
"(",
"prediction",
",",
"ground_truth",
")",
":",
"prediction_tokens",
"=",
"normalize_answer",
"(",
"prediction",
")",
".",
"split",
"(",
")",
"ground_truth_tokens",
"=",
"normalize_answer",
"(",
"ground_truth",
")",
".",
"split",
"(",
")",
... | https://github.com/rajarshd/Multi-Step-Reasoning/blob/3218d626839f7217554f38d82e00e4f460b508e4/msr/reader/utils.py#L201-L212 | |
GenTang/intro_ds | 886e678e5353e9b4c0d4f3da83a00d6b9a2f06a5 | ch10-unsupervised/dimension_reduction/kernel_pca.py | python | trainKernelPCA | (data) | return model | 使用带有核函数的主成分分析对数据进行降维 | 使用带有核函数的主成分分析对数据进行降维 | [
"使用带有核函数的主成分分析对数据进行降维"
] | def trainKernelPCA(data):
"""
使用带有核函数的主成分分析对数据进行降维
"""
model = KernelPCA(n_components=2, kernel="rbf", gamma=25)
model.fit(data)
return model | [
"def",
"trainKernelPCA",
"(",
"data",
")",
":",
"model",
"=",
"KernelPCA",
"(",
"n_components",
"=",
"2",
",",
"kernel",
"=",
"\"rbf\"",
",",
"gamma",
"=",
"25",
")",
"model",
".",
"fit",
"(",
"data",
")",
"return",
"model"
] | https://github.com/GenTang/intro_ds/blob/886e678e5353e9b4c0d4f3da83a00d6b9a2f06a5/ch10-unsupervised/dimension_reduction/kernel_pca.py#L34-L40 | |
DataDog/dd-trace-py | 13f9c6c1a8b4820365b299ab204f2bb5189d2a49 | ddtrace/contrib/rq/__init__.py | python | traced_perform_job | (rq, pin, func, instance, args, kwargs) | Trace rq.Worker.perform_job | Trace rq.Worker.perform_job | [
"Trace",
"rq",
".",
"Worker",
".",
"perform_job"
] | def traced_perform_job(rq, pin, func, instance, args, kwargs):
"""Trace rq.Worker.perform_job"""
# `perform_job` is executed in a freshly forked, short-lived instance
job = get_argument_value(args, kwargs, 0, "job")
if config.rq_worker.distributed_tracing_enabled:
ctx = HTTPPropagator.extract(j... | [
"def",
"traced_perform_job",
"(",
"rq",
",",
"pin",
",",
"func",
",",
"instance",
",",
"args",
",",
"kwargs",
")",
":",
"# `perform_job` is executed in a freshly forked, short-lived instance",
"job",
"=",
"get_argument_value",
"(",
"args",
",",
"kwargs",
",",
"0",
... | https://github.com/DataDog/dd-trace-py/blob/13f9c6c1a8b4820365b299ab204f2bb5189d2a49/ddtrace/contrib/rq/__init__.py#L152-L180 | ||
mcfletch/pyopengl | 02d11dad9ff18e50db10e975c4756e17bf198464 | OpenGL/GL/ATI/envmap_bumpmap.py | python | glInitEnvmapBumpmapATI | () | return extensions.hasGLExtension( _EXTENSION_NAME ) | Return boolean indicating whether this extension is available | Return boolean indicating whether this extension is available | [
"Return",
"boolean",
"indicating",
"whether",
"this",
"extension",
"is",
"available"
] | def glInitEnvmapBumpmapATI():
'''Return boolean indicating whether this extension is available'''
from OpenGL import extensions
return extensions.hasGLExtension( _EXTENSION_NAME ) | [
"def",
"glInitEnvmapBumpmapATI",
"(",
")",
":",
"from",
"OpenGL",
"import",
"extensions",
"return",
"extensions",
".",
"hasGLExtension",
"(",
"_EXTENSION_NAME",
")"
] | https://github.com/mcfletch/pyopengl/blob/02d11dad9ff18e50db10e975c4756e17bf198464/OpenGL/GL/ATI/envmap_bumpmap.py#L35-L38 | |
WikidPad/WikidPad | 558109638807bc76b4672922686e416ab2d5f79c | WikidPad/lib/pwiki/WikiHtmlView2.py | python | WikiHtmlView2.addZoom | (self, step) | Modify the zoom setting by step relative to current zoom in
configuration.
html2.SetZoom only has 5 different zoom levels (0-4)
It may be worth using a javascript based zoom which would
allow for finer control | Modify the zoom setting by step relative to current zoom in
configuration. | [
"Modify",
"the",
"zoom",
"setting",
"by",
"step",
"relative",
"to",
"current",
"zoom",
"in",
"configuration",
"."
] | def addZoom(self, step):
"""
Modify the zoom setting by step relative to current zoom in
configuration.
html2.SetZoom only has 5 different zoom levels (0-4)
It may be worth using a javascript based zoom which would
allow for finer control
"""
zoom = self... | [
"def",
"addZoom",
"(",
"self",
",",
"step",
")",
":",
"zoom",
"=",
"self",
".",
"presenter",
".",
"getConfig",
"(",
")",
".",
"getint",
"(",
"\"main\"",
",",
"\"preview_zoom\"",
",",
"0",
")",
"zoom",
"+=",
"step",
"# Restrict to allowed range.",
"# In the... | https://github.com/WikidPad/WikidPad/blob/558109638807bc76b4672922686e416ab2d5f79c/WikidPad/lib/pwiki/WikiHtmlView2.py#L1324-L1353 | ||
AppScale/gts | 46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9 | AppServer/lib/mox/mox.py | python | Mox.ResetAll | (self) | Call reset on all mock objects. This does not unset stubs. | Call reset on all mock objects. This does not unset stubs. | [
"Call",
"reset",
"on",
"all",
"mock",
"objects",
".",
"This",
"does",
"not",
"unset",
"stubs",
"."
] | def ResetAll(self):
"""Call reset on all mock objects. This does not unset stubs."""
for mock_obj in self._mock_objects:
mock_obj._Reset() | [
"def",
"ResetAll",
"(",
"self",
")",
":",
"for",
"mock_obj",
"in",
"self",
".",
"_mock_objects",
":",
"mock_obj",
".",
"_Reset",
"(",
")"
] | https://github.com/AppScale/gts/blob/46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9/AppServer/lib/mox/mox.py#L286-L290 | ||
Trusted-AI/adversarial-robustness-toolbox | 9fabffdbb92947efa1ecc5d825d634d30dfbaf29 | art/defences/detector/poison/activation_defence.py | python | measure_misclassification | (
classifier: "CLASSIFIER_NEURALNETWORK_TYPE", x_test: np.ndarray, y_test: np.ndarray
) | return 1.0 - np.sum(predictions == np.argmax(y_test, axis=1)) / y_test.shape[0] | Computes 1-accuracy given x_test and y_test
:param classifier: Classifier to be used for predictions.
:param x_test: Test set.
:param y_test: Labels for test set.
:return: 1-accuracy. | Computes 1-accuracy given x_test and y_test | [
"Computes",
"1",
"-",
"accuracy",
"given",
"x_test",
"and",
"y_test"
] | def measure_misclassification(
classifier: "CLASSIFIER_NEURALNETWORK_TYPE", x_test: np.ndarray, y_test: np.ndarray
) -> float:
"""
Computes 1-accuracy given x_test and y_test
:param classifier: Classifier to be used for predictions.
:param x_test: Test set.
:param y_test: Labels for test set.
... | [
"def",
"measure_misclassification",
"(",
"classifier",
":",
"\"CLASSIFIER_NEURALNETWORK_TYPE\"",
",",
"x_test",
":",
"np",
".",
"ndarray",
",",
"y_test",
":",
"np",
".",
"ndarray",
")",
"->",
"float",
":",
"predictions",
"=",
"np",
".",
"argmax",
"(",
"classif... | https://github.com/Trusted-AI/adversarial-robustness-toolbox/blob/9fabffdbb92947efa1ecc5d825d634d30dfbaf29/art/defences/detector/poison/activation_defence.py#L617-L629 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.