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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
holoviz/panel | 5e25cb09447d8edf0b316f130ee1318a2aeb880f | panel/pane/base.py | python | ReplacementPane.select | (self, selector=None) | return selected | Iterates over the Viewable and any potential children in the
applying the Selector.
Arguments
---------
selector: type or callable or None
The selector allows selecting a subset of Viewables by
declaring a type or callable function to filter by.
Returns
... | Iterates over the Viewable and any potential children in the
applying the Selector. | [
"Iterates",
"over",
"the",
"Viewable",
"and",
"any",
"potential",
"children",
"in",
"the",
"applying",
"the",
"Selector",
"."
] | def select(self, selector=None):
"""
Iterates over the Viewable and any potential children in the
applying the Selector.
Arguments
---------
selector: type or callable or None
The selector allows selecting a subset of Viewables by
declaring a type or ... | [
"def",
"select",
"(",
"self",
",",
"selector",
"=",
"None",
")",
":",
"selected",
"=",
"super",
"(",
")",
".",
"select",
"(",
"selector",
")",
"selected",
"+=",
"self",
".",
"_inner_layout",
".",
"select",
"(",
"selector",
")",
"return",
"selected"
] | https://github.com/holoviz/panel/blob/5e25cb09447d8edf0b316f130ee1318a2aeb880f/panel/pane/base.py#L430-L447 | |
AppScale/gts | 46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9 | AppServer/lib/django-1.3/django/contrib/admindocs/utils.py | python | parse_docstring | (docstring) | return title, body, metadata | Parse out the parts of a docstring. Returns (title, body, metadata). | Parse out the parts of a docstring. Returns (title, body, metadata). | [
"Parse",
"out",
"the",
"parts",
"of",
"a",
"docstring",
".",
"Returns",
"(",
"title",
"body",
"metadata",
")",
"."
] | def parse_docstring(docstring):
"""
Parse out the parts of a docstring. Returns (title, body, metadata).
"""
docstring = trim_docstring(docstring)
parts = re.split(r'\n{2,}', docstring)
title = parts[0]
if len(parts) == 1:
body = ''
metadata = {}
else:
parser = H... | [
"def",
"parse_docstring",
"(",
"docstring",
")",
":",
"docstring",
"=",
"trim_docstring",
"(",
"docstring",
")",
"parts",
"=",
"re",
".",
"split",
"(",
"r'\\n{2,}'",
",",
"docstring",
")",
"title",
"=",
"parts",
"[",
"0",
"]",
"if",
"len",
"(",
"parts",
... | https://github.com/AppScale/gts/blob/46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9/AppServer/lib/django-1.3/django/contrib/admindocs/utils.py#L32-L55 | |
google/flax | 89e1126cc43588c6946bc85506987dc812909575 | examples/wmt/decode.py | python | add_beam_dim | (x, beam_size) | return jnp.tile(x, tile_dims) | Creates new beam dimension in non-scalar array and tiles into it. | Creates new beam dimension in non-scalar array and tiles into it. | [
"Creates",
"new",
"beam",
"dimension",
"in",
"non",
"-",
"scalar",
"array",
"and",
"tiles",
"into",
"it",
"."
] | def add_beam_dim(x, beam_size):
"""Creates new beam dimension in non-scalar array and tiles into it."""
if x.ndim == 0: # ignore scalars (e.g. cache index)
return x
x = jnp.expand_dims(x, axis=1)
tile_dims = [1] * x.ndim
tile_dims[1] = beam_size
return jnp.tile(x, tile_dims) | [
"def",
"add_beam_dim",
"(",
"x",
",",
"beam_size",
")",
":",
"if",
"x",
".",
"ndim",
"==",
"0",
":",
"# ignore scalars (e.g. cache index)",
"return",
"x",
"x",
"=",
"jnp",
".",
"expand_dims",
"(",
"x",
",",
"axis",
"=",
"1",
")",
"tile_dims",
"=",
"[",... | https://github.com/google/flax/blob/89e1126cc43588c6946bc85506987dc812909575/examples/wmt/decode.py#L49-L56 | |
hakril/PythonForWindows | 61e027a678d5b87aa64fcf8a37a6661a86236589 | windows/alpc.py | python | AlpcMessage.handle_attribute | (self) | return self.attributes.get_attribute(gdef.ALPC_MESSAGE_HANDLE_ATTRIBUTE) | The :data:`~windows.generated_def.ALPC_MESSAGE_HANDLE_ATTRIBUTE` of the message:
:type: :class:`ALPC_HANDLE_ATTR` | The :data:`~windows.generated_def.ALPC_MESSAGE_HANDLE_ATTRIBUTE` of the message: | [
"The",
":",
"data",
":",
"~windows",
".",
"generated_def",
".",
"ALPC_MESSAGE_HANDLE_ATTRIBUTE",
"of",
"the",
"message",
":"
] | def handle_attribute(self):
"""The :data:`~windows.generated_def.ALPC_MESSAGE_HANDLE_ATTRIBUTE` of the message:
:type: :class:`ALPC_HANDLE_ATTR`
"""
return self.attributes.get_attribute(gdef.ALPC_MESSAGE_HANDLE_ATTRIBUTE) | [
"def",
"handle_attribute",
"(",
"self",
")",
":",
"return",
"self",
".",
"attributes",
".",
"get_attribute",
"(",
"gdef",
".",
"ALPC_MESSAGE_HANDLE_ATTRIBUTE",
")"
] | https://github.com/hakril/PythonForWindows/blob/61e027a678d5b87aa64fcf8a37a6661a86236589/windows/alpc.py#L89-L94 | |
bear/python-twitter | 1a148ead5029d06bec58c1cbc879764aa4b2bc74 | twitter/api.py | python | Api.GetFriendsPaged | (self,
user_id=None,
screen_name=None,
cursor=-1,
count=200,
skip_status=False,
include_user_entities=True) | return self._GetFriendsFollowersPaged(url,
user_id,
screen_name,
cursor,
count,
skip_statu... | Make a cursor driven call to return the list of all friends.
Args:
user_id:
The twitter id of the user whose friends you are fetching.
If not specified, defaults to the authenticated user. [Optional]
screen_name:
The twitter name of the user whose friends... | Make a cursor driven call to return the list of all friends. | [
"Make",
"a",
"cursor",
"driven",
"call",
"to",
"return",
"the",
"list",
"of",
"all",
"friends",
"."
] | def GetFriendsPaged(self,
user_id=None,
screen_name=None,
cursor=-1,
count=200,
skip_status=False,
include_user_entities=True):
"""Make a cursor driven call to return t... | [
"def",
"GetFriendsPaged",
"(",
"self",
",",
"user_id",
"=",
"None",
",",
"screen_name",
"=",
"None",
",",
"cursor",
"=",
"-",
"1",
",",
"count",
"=",
"200",
",",
"skip_status",
"=",
"False",
",",
"include_user_entities",
"=",
"True",
")",
":",
"url",
"... | https://github.com/bear/python-twitter/blob/1a148ead5029d06bec58c1cbc879764aa4b2bc74/twitter/api.py#L2672-L2711 | |
adobe/brackets-shell | c180d7ea812759ba50d25ab0685434c345343008 | gyp/pylib/gyp/generator/analyzer.py | python | _WasBuildFileModified | (build_file, data, files, toplevel_dir) | return False | Returns true if the build file |build_file| is either in |files| or
one of the files included by |build_file| is in |files|. |toplevel_dir| is
the root of the source tree. | Returns true if the build file |build_file| is either in |files| or
one of the files included by |build_file| is in |files|. |toplevel_dir| is
the root of the source tree. | [
"Returns",
"true",
"if",
"the",
"build",
"file",
"|build_file|",
"is",
"either",
"in",
"|files|",
"or",
"one",
"of",
"the",
"files",
"included",
"by",
"|build_file|",
"is",
"in",
"|files|",
".",
"|toplevel_dir|",
"is",
"the",
"root",
"of",
"the",
"source",
... | def _WasBuildFileModified(build_file, data, files, toplevel_dir):
"""Returns true if the build file |build_file| is either in |files| or
one of the files included by |build_file| is in |files|. |toplevel_dir| is
the root of the source tree."""
if _ToLocalPath(toplevel_dir, _ToGypPath(build_file)) in files:
... | [
"def",
"_WasBuildFileModified",
"(",
"build_file",
",",
"data",
",",
"files",
",",
"toplevel_dir",
")",
":",
"if",
"_ToLocalPath",
"(",
"toplevel_dir",
",",
"_ToGypPath",
"(",
"build_file",
")",
")",
"in",
"files",
":",
"if",
"debug",
":",
"print",
"'gyp fil... | https://github.com/adobe/brackets-shell/blob/c180d7ea812759ba50d25ab0685434c345343008/gyp/pylib/gyp/generator/analyzer.py#L275-L297 | |
Nuitka/Nuitka | 39262276993757fa4e299f497654065600453fc9 | nuitka/build/inline_copy/lib/scons-3.1.2/SCons/Script/SConscript.py | python | SConsEnvironment.EnsurePythonVersion | (self, major, minor) | Exit abnormally if the Python version is not late enough. | Exit abnormally if the Python version is not late enough. | [
"Exit",
"abnormally",
"if",
"the",
"Python",
"version",
"is",
"not",
"late",
"enough",
"."
] | def EnsurePythonVersion(self, major, minor):
"""Exit abnormally if the Python version is not late enough."""
if sys.version_info < (major, minor):
v = sys.version.split()[0]
print("Python %d.%d or greater required, but you have Python %s" %(major,minor,v))
sys.exit(2) | [
"def",
"EnsurePythonVersion",
"(",
"self",
",",
"major",
",",
"minor",
")",
":",
"if",
"sys",
".",
"version_info",
"<",
"(",
"major",
",",
"minor",
")",
":",
"v",
"=",
"sys",
".",
"version",
".",
"split",
"(",
")",
"[",
"0",
"]",
"print",
"(",
"\... | https://github.com/Nuitka/Nuitka/blob/39262276993757fa4e299f497654065600453fc9/nuitka/build/inline_copy/lib/scons-3.1.2/SCons/Script/SConscript.py#L508-L513 | ||
spotify/luigi | c3b66f4a5fa7eaa52f9a72eb6704b1049035c789 | luigi/scheduler.py | python | Scheduler.unpause | (self) | [] | def unpause(self):
if self._config.pause_enabled:
self._paused = False | [
"def",
"unpause",
"(",
"self",
")",
":",
"if",
"self",
".",
"_config",
".",
"pause_enabled",
":",
"self",
".",
"_paused",
"=",
"False"
] | https://github.com/spotify/luigi/blob/c3b66f4a5fa7eaa52f9a72eb6704b1049035c789/luigi/scheduler.py#L1008-L1010 | ||||
general03/flask-autoindex | 424246242c9f40aeb9ac2c8c63f4d2234024256e | .eggs/Werkzeug-1.0.1-py3.7.egg/werkzeug/http.py | python | is_entity_header | (header) | return header.lower() in _entity_headers | Check if a header is an entity header.
.. versionadded:: 0.5
:param header: the header to test.
:return: `True` if it's an entity header, `False` otherwise. | Check if a header is an entity header. | [
"Check",
"if",
"a",
"header",
"is",
"an",
"entity",
"header",
"."
] | def is_entity_header(header):
"""Check if a header is an entity header.
.. versionadded:: 0.5
:param header: the header to test.
:return: `True` if it's an entity header, `False` otherwise.
"""
return header.lower() in _entity_headers | [
"def",
"is_entity_header",
"(",
"header",
")",
":",
"return",
"header",
".",
"lower",
"(",
")",
"in",
"_entity_headers"
] | https://github.com/general03/flask-autoindex/blob/424246242c9f40aeb9ac2c8c63f4d2234024256e/.eggs/Werkzeug-1.0.1-py3.7.egg/werkzeug/http.py#L1068-L1076 | |
cortex-lab/phy | 9a330b9437a3d0b40a37a201d147224e6e7fb462 | phy/plot/gloo/variable.py | python | Variable.gtype | (self) | return self._gtype | Type of the underlying variable (as a GL constant) | Type of the underlying variable (as a GL constant) | [
"Type",
"of",
"the",
"underlying",
"variable",
"(",
"as",
"a",
"GL",
"constant",
")"
] | def gtype(self):
""" Type of the underlying variable (as a GL constant) """
return self._gtype | [
"def",
"gtype",
"(",
"self",
")",
":",
"return",
"self",
".",
"_gtype"
] | https://github.com/cortex-lab/phy/blob/9a330b9437a3d0b40a37a201d147224e6e7fb462/phy/plot/gloo/variable.py#L149-L152 | |
oracle/graalpython | 577e02da9755d916056184ec441c26e00b70145c | graalpython/lib-python/3/idlelib/autocomplete_w.py | python | AutoCompleteWindow.hide_event | (self, event) | [] | def hide_event(self, event):
# Hide autocomplete list if it exists and does not have focus or
# mouse click on widget / text area.
if self.is_active():
if event.type == EventType.FocusOut:
# On Windows platform, it will need to delay the check for
# ac... | [
"def",
"hide_event",
"(",
"self",
",",
"event",
")",
":",
"# Hide autocomplete list if it exists and does not have focus or",
"# mouse click on widget / text area.",
"if",
"self",
".",
"is_active",
"(",
")",
":",
"if",
"event",
".",
"type",
"==",
"EventType",
".",
"Fo... | https://github.com/oracle/graalpython/blob/577e02da9755d916056184ec441c26e00b70145c/graalpython/lib-python/3/idlelib/autocomplete_w.py#L283-L294 | ||||
alibaba/iOSSecAudit | f94ed3254263f3382f374e3f05afae8a1fe79f20 | smartconsole.py | python | SimpleCompleter.complete | (self, text, state) | return response | [] | def complete(self, text, state):
response = None
if state == 0:
# This is the first time for this text, so build a match list.
if text:
self.matches = [s
for s in self.options
if s and s.startswith(... | [
"def",
"complete",
"(",
"self",
",",
"text",
",",
"state",
")",
":",
"response",
"=",
"None",
"if",
"state",
"==",
"0",
":",
"# This is the first time for this text, so build a match list.",
"if",
"text",
":",
"self",
".",
"matches",
"=",
"[",
"s",
"for",
"s... | https://github.com/alibaba/iOSSecAudit/blob/f94ed3254263f3382f374e3f05afae8a1fe79f20/smartconsole.py#L969-L990 | |||
EmpireProject/EmPyre | c73854ed9d90d2bba1717d3fe6df758d18c20b8f | lib/common/empyre.py | python | ListenerMenu.complete_unset | (self, text, line, begidx, endidx) | return [s[offs:] for s in self.options if s.startswith(mline)] | Tab-complete listener option values. | Tab-complete listener option values. | [
"Tab",
"-",
"complete",
"listener",
"option",
"values",
"."
] | def complete_unset(self, text, line, begidx, endidx):
"Tab-complete listener option values."
mline = line.partition(' ')[2]
offs = len(mline) - len(text)
return [s[offs:] for s in self.options if s.startswith(mline)] | [
"def",
"complete_unset",
"(",
"self",
",",
"text",
",",
"line",
",",
"begidx",
",",
"endidx",
")",
":",
"mline",
"=",
"line",
".",
"partition",
"(",
"' '",
")",
"[",
"2",
"]",
"offs",
"=",
"len",
"(",
"mline",
")",
"-",
"len",
"(",
"text",
")",
... | https://github.com/EmpireProject/EmPyre/blob/c73854ed9d90d2bba1717d3fe6df758d18c20b8f/lib/common/empyre.py#L1928-L1933 | |
gramps-project/gramps | 04d4651a43eb210192f40a9f8c2bad8ee8fa3753 | gramps/gen/user.py | python | UserBase.step_progress | (self) | Advance the progress meter.
Don't use this method directly, use progress instead. | Advance the progress meter. | [
"Advance",
"the",
"progress",
"meter",
"."
] | def step_progress(self):
"""
Advance the progress meter.
Don't use this method directly, use progress instead.
""" | [
"def",
"step_progress",
"(",
"self",
")",
":"
] | https://github.com/gramps-project/gramps/blob/04d4651a43eb210192f40a9f8c2bad8ee8fa3753/gramps/gen/user.py#L62-L67 | ||
vispy/vispy | 26256fdc2574259dd227022fbce0767cae4e244b | vispy/util/quaternion.py | python | Quaternion.create_from_euler_angles | (cls, rx, ry, rz, degrees=False) | return qx*qy*qz | Classmethod to create a quaternion given the euler angles. | Classmethod to create a quaternion given the euler angles. | [
"Classmethod",
"to",
"create",
"a",
"quaternion",
"given",
"the",
"euler",
"angles",
"."
] | def create_from_euler_angles(cls, rx, ry, rz, degrees=False):
"""Classmethod to create a quaternion given the euler angles."""
if degrees:
rx, ry, rz = np.radians([rx, ry, rz])
# Obtain quaternions
qx = Quaternion(np.cos(rx/2), 0, 0, np.sin(rx/2))
qy = Quaternion(np.c... | [
"def",
"create_from_euler_angles",
"(",
"cls",
",",
"rx",
",",
"ry",
",",
"rz",
",",
"degrees",
"=",
"False",
")",
":",
"if",
"degrees",
":",
"rx",
",",
"ry",
",",
"rz",
"=",
"np",
".",
"radians",
"(",
"[",
"rx",
",",
"ry",
",",
"rz",
"]",
")",... | https://github.com/vispy/vispy/blob/26256fdc2574259dd227022fbce0767cae4e244b/vispy/util/quaternion.py#L220-L229 | |
geekan/scrapy-examples | edb1cb116bd6def65a6ef01f953b58eb43e54305 | zhibo8/zhibo8/spiders/hupu_news_spider.py | python | HupuNewsSpider.parse | (self, response) | [] | def parse(self, response):
# refer : http://scrapy-chs.readthedocs.org/zh_CN/0.24/topics/selectors.html#topics-selectors-relative-xpaths
li_list = response.xpath('//div[@class="news-list"]/ul/li')
for li in li_list:
#print li.extract()
a = li.xpath('div/h4/a[1]')
... | [
"def",
"parse",
"(",
"self",
",",
"response",
")",
":",
"# refer : http://scrapy-chs.readthedocs.org/zh_CN/0.24/topics/selectors.html#topics-selectors-relative-xpaths",
"li_list",
"=",
"response",
".",
"xpath",
"(",
"'//div[@class=\"news-list\"]/ul/li'",
")",
"for",
"li",
"in",... | https://github.com/geekan/scrapy-examples/blob/edb1cb116bd6def65a6ef01f953b58eb43e54305/zhibo8/zhibo8/spiders/hupu_news_spider.py#L12-L21 | ||||
python/cpython | e13cdca0f5224ec4e23bdd04bb3120506964bc8b | Lib/distutils/command/check.py | python | check.check_metadata | (self) | Ensures that all required elements of meta-data are supplied.
Required fields:
name, version, URL
Recommended fields:
(author and author_email) or (maintainer and maintainer_email)
Warns if any are missing. | Ensures that all required elements of meta-data are supplied. | [
"Ensures",
"that",
"all",
"required",
"elements",
"of",
"meta",
"-",
"data",
"are",
"supplied",
"."
] | def check_metadata(self):
"""Ensures that all required elements of meta-data are supplied.
Required fields:
name, version, URL
Recommended fields:
(author and author_email) or (maintainer and maintainer_email)
Warns if any are missing.
"""
metad... | [
"def",
"check_metadata",
"(",
"self",
")",
":",
"metadata",
"=",
"self",
".",
"distribution",
".",
"metadata",
"missing",
"=",
"[",
"]",
"for",
"attr",
"in",
"(",
"'name'",
",",
"'version'",
",",
"'url'",
")",
":",
"if",
"not",
"(",
"hasattr",
"(",
"... | https://github.com/python/cpython/blob/e13cdca0f5224ec4e23bdd04bb3120506964bc8b/Lib/distutils/command/check.py#L79-L110 | ||
rcorcs/NatI | fdf014f4292afdc95250add7b6658468043228e1 | en/parser/nltk_lite/wordnet/wordnet.py | python | _partition | (sequence, size, count) | return (partitions, sequence[size * count:]) | Partition sequence into count subsequences of size
length, and a remainder.
Return (partitions, remainder), where partitions is a sequence of
count subsequences of cardinality count, and
apply(append, partitions) + remainder == sequence. | Partition sequence into count subsequences of size
length, and a remainder.
Return (partitions, remainder), where partitions is a sequence of
count subsequences of cardinality count, and
apply(append, partitions) + remainder == sequence. | [
"Partition",
"sequence",
"into",
"count",
"subsequences",
"of",
"size",
"length",
"and",
"a",
"remainder",
".",
"Return",
"(",
"partitions",
"remainder",
")",
"where",
"partitions",
"is",
"a",
"sequence",
"of",
"count",
"subsequences",
"of",
"cardinality",
"coun... | def _partition(sequence, size, count):
"""Partition sequence into count subsequences of size
length, and a remainder.
Return (partitions, remainder), where partitions is a sequence of
count subsequences of cardinality count, and
apply(append, partitions) + remainder == sequence."""
par... | [
"def",
"_partition",
"(",
"sequence",
",",
"size",
",",
"count",
")",
":",
"partitions",
"=",
"[",
"]",
"for",
"index",
"in",
"range",
"(",
"0",
",",
"size",
"*",
"count",
",",
"size",
")",
":",
"partitions",
".",
"append",
"(",
"sequence",
"[",
"i... | https://github.com/rcorcs/NatI/blob/fdf014f4292afdc95250add7b6658468043228e1/en/parser/nltk_lite/wordnet/wordnet.py#L1218-L1229 | |
weewx/weewx | cb594fce224560bd8696050fc5c7843c7839320e | bin/six.py | python | _import_module | (name) | return sys.modules[name] | Import module, returning the module after the last dot. | Import module, returning the module after the last dot. | [
"Import",
"module",
"returning",
"the",
"module",
"after",
"the",
"last",
"dot",
"."
] | def _import_module(name):
"""Import module, returning the module after the last dot."""
__import__(name)
return sys.modules[name] | [
"def",
"_import_module",
"(",
"name",
")",
":",
"__import__",
"(",
"name",
")",
"return",
"sys",
".",
"modules",
"[",
"name",
"]"
] | https://github.com/weewx/weewx/blob/cb594fce224560bd8696050fc5c7843c7839320e/bin/six.py#L80-L83 | |
UncleGoogle/galaxy-integration-humblebundle | ffe063ed3c047053039851256cf23a5343317f2e | src/settings.py | python | Settings.installed | (self) | return self._installed | [] | def installed(self) -> InstalledSettings:
return self._installed | [
"def",
"installed",
"(",
"self",
")",
"->",
"InstalledSettings",
":",
"return",
"self",
".",
"_installed"
] | https://github.com/UncleGoogle/galaxy-integration-humblebundle/blob/ffe063ed3c047053039851256cf23a5343317f2e/src/settings.py#L122-L123 | |||
Kozea/WeasyPrint | 6cce2978165134e37683cb5b3d156cac6a11a7f9 | weasyprint/svg/css.py | python | find_stylesheets_rules | (tree, stylesheet_rules, url) | Find rules among stylesheet rules and imports. | Find rules among stylesheet rules and imports. | [
"Find",
"rules",
"among",
"stylesheet",
"rules",
"and",
"imports",
"."
] | def find_stylesheets_rules(tree, stylesheet_rules, url):
"""Find rules among stylesheet rules and imports."""
for rule in stylesheet_rules:
if rule.type == 'at-rule':
if rule.lower_at_keyword == 'import' and rule.content is None:
# TODO: support media types in @import
... | [
"def",
"find_stylesheets_rules",
"(",
"tree",
",",
"stylesheet_rules",
",",
"url",
")",
":",
"for",
"rule",
"in",
"stylesheet_rules",
":",
"if",
"rule",
".",
"type",
"==",
"'at-rule'",
":",
"if",
"rule",
".",
"lower_at_keyword",
"==",
"'import'",
"and",
"rul... | https://github.com/Kozea/WeasyPrint/blob/6cce2978165134e37683cb5b3d156cac6a11a7f9/weasyprint/svg/css.py#L17-L34 | ||
blinktrade/bitex | a4896e7faef9c4aa0ca5325f18b77db67003764e | tools/arbitrage/arbitrator.py | python | BlinkTradeArbitrator.on_blinktrade_balance | (self, sender, msg) | [] | def on_blinktrade_balance(self, sender, msg):
if str(self.blinktrade_broker['BrokerID']) in msg:
if self.fiat_currency in msg[str(self.blinktrade_broker['BrokerID'])]:
self.fiat_balance = msg[str(self.blinktrade_broker['BrokerID'])][self.fiat_currency]
if self.crypto_currency in msg[str(self.bli... | [
"def",
"on_blinktrade_balance",
"(",
"self",
",",
"sender",
",",
"msg",
")",
":",
"if",
"str",
"(",
"self",
".",
"blinktrade_broker",
"[",
"'BrokerID'",
"]",
")",
"in",
"msg",
":",
"if",
"self",
".",
"fiat_currency",
"in",
"msg",
"[",
"str",
"(",
"self... | https://github.com/blinktrade/bitex/blob/a4896e7faef9c4aa0ca5325f18b77db67003764e/tools/arbitrage/arbitrator.py#L104-L109 | ||||
JPCERTCC/aa-tools | 404eceb256447e51c476a61e461c5cf386d50d16 | redleavesscan.py | python | redleavesScan.get_vad_base | (self, task, address) | return None | [] | def get_vad_base(self, task, address):
for vad in task.VadRoot.traverse():
if address >= vad.Start and address < vad.End:
return vad.Start
return None | [
"def",
"get_vad_base",
"(",
"self",
",",
"task",
",",
"address",
")",
":",
"for",
"vad",
"in",
"task",
".",
"VadRoot",
".",
"traverse",
"(",
")",
":",
"if",
"address",
">=",
"vad",
".",
"Start",
"and",
"address",
"<",
"vad",
".",
"End",
":",
"retur... | https://github.com/JPCERTCC/aa-tools/blob/404eceb256447e51c476a61e461c5cf386d50d16/redleavesscan.py#L90-L95 | |||
SpockBotMC/SpockBot | f89911551f18357720034fbaa52837a0d09f66ea | spockbot/plugins/tools/smpmap.py | python | ChunkData.get | (self, x, y, z) | return self.data[x + ((y * 16) + z) * 16] | [] | def get(self, x, y, z):
self.fill()
return self.data[x + ((y * 16) + z) * 16] | [
"def",
"get",
"(",
"self",
",",
"x",
",",
"y",
",",
"z",
")",
":",
"self",
".",
"fill",
"(",
")",
"return",
"self",
".",
"data",
"[",
"x",
"+",
"(",
"(",
"y",
"*",
"16",
")",
"+",
"z",
")",
"*",
"16",
"]"
] | https://github.com/SpockBotMC/SpockBot/blob/f89911551f18357720034fbaa52837a0d09f66ea/spockbot/plugins/tools/smpmap.py#L115-L117 | |||
kubeflow/pipelines | bea751c9259ff0ae85290f873170aae89284ba8e | samples/core/tfx-oss/utils/taxi_utils.py | python | trainer_fn | (hparams, schema) | return {
'estimator': estimator,
'train_spec': train_spec,
'eval_spec': eval_spec,
'eval_input_receiver_fn': receiver_fn
} | Build the estimator using the high level API.
Args:
hparams: Holds hyperparameters used to train the model as name/value pairs.
schema: Holds the schema of the training examples.
Returns:
A dict of the following:
- estimator: The estimator that will be used for training and eval.
- train_s... | Build the estimator using the high level API. | [
"Build",
"the",
"estimator",
"using",
"the",
"high",
"level",
"API",
"."
] | def trainer_fn(hparams, schema):
"""Build the estimator using the high level API.
Args:
hparams: Holds hyperparameters used to train the model as name/value pairs.
schema: Holds the schema of the training examples.
Returns:
A dict of the following:
- estimator: The estimator that will be used ... | [
"def",
"trainer_fn",
"(",
"hparams",
",",
"schema",
")",
":",
"# Number of nodes in the first layer of the DNN",
"first_dnn_layer_size",
"=",
"100",
"num_dnn_layers",
"=",
"4",
"dnn_decay_factor",
"=",
"0.7",
"train_batch_size",
"=",
"40",
"eval_batch_size",
"=",
"40",
... | https://github.com/kubeflow/pipelines/blob/bea751c9259ff0ae85290f873170aae89284ba8e/samples/core/tfx-oss/utils/taxi_utils.py#L287-L358 | |
home-assistant/core | 265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1 | homeassistant/components/fritz/switch.py | python | get_deflections | (
avm_device: FritzBoxTools, service_name: str
) | return items | Get deflection switch info. | Get deflection switch info. | [
"Get",
"deflection",
"switch",
"info",
"."
] | def get_deflections(
avm_device: FritzBoxTools, service_name: str
) -> list[OrderedDict[Any, Any]] | None:
"""Get deflection switch info."""
deflection_list = service_call_action(
avm_device,
service_name,
"1",
"GetDeflections",
)
if not deflection_list:
ret... | [
"def",
"get_deflections",
"(",
"avm_device",
":",
"FritzBoxTools",
",",
"service_name",
":",
"str",
")",
"->",
"list",
"[",
"OrderedDict",
"[",
"Any",
",",
"Any",
"]",
"]",
"|",
"None",
":",
"deflection_list",
"=",
"service_call_action",
"(",
"avm_device",
"... | https://github.com/home-assistant/core/blob/265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1/homeassistant/components/fritz/switch.py#L115-L133 | |
leapcode/bitmask_client | d2fe20df24fc6eaf146fa5ce1e847de6ab515688 | src/leap/bitmask/logs/log_silencer.py | python | SelectiveSilencerFilter.__init__ | (self) | Tries to load silencer rules from the default path,
or load from the SILENCER_RULES tuple if not found. | Tries to load silencer rules from the default path,
or load from the SILENCER_RULES tuple if not found. | [
"Tries",
"to",
"load",
"silencer",
"rules",
"from",
"the",
"default",
"path",
"or",
"load",
"from",
"the",
"SILENCER_RULES",
"tuple",
"if",
"not",
"found",
"."
] | def __init__(self):
"""
Tries to load silencer rules from the default path,
or load from the SILENCER_RULES tuple if not found.
"""
self._inclusion_path = os.path.join(get_path_prefix(), "leap",
self.INCLUSION_CONFIG_FILE)
self... | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"_inclusion_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"get_path_prefix",
"(",
")",
",",
"\"leap\"",
",",
"self",
".",
"INCLUSION_CONFIG_FILE",
")",
"self",
".",
"_exclusion_path",
"=",
"os",
"... | https://github.com/leapcode/bitmask_client/blob/d2fe20df24fc6eaf146fa5ce1e847de6ab515688/src/leap/bitmask/logs/log_silencer.py#L66-L77 | ||
triaquae/triaquae | bbabf736b3ba56a0c6498e7f04e16c13b8b8f2b9 | TriAquae/models/django/db/models/fields/__init__.py | python | CharField.__init__ | (self, *args, **kwargs) | [] | def __init__(self, *args, **kwargs):
super(CharField, self).__init__(*args, **kwargs)
self.validators.append(validators.MaxLengthValidator(self.max_length)) | [
"def",
"__init__",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"CharField",
",",
"self",
")",
".",
"__init__",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"validators",
".",
"append",
"(",
"val... | https://github.com/triaquae/triaquae/blob/bbabf736b3ba56a0c6498e7f04e16c13b8b8f2b9/TriAquae/models/django/db/models/fields/__init__.py#L625-L627 | ||||
zestedesavoir/zds-site | 2ba922223c859984a413cc6c108a8aa4023b113e | zds/tutorialv2/models/database.py | python | PublishableContent.in_validation | (self) | return (self.sha_validation is not None) and (self.sha_validation.strip() != "") | A tutorial is not in validation if sha_validation is ``None`` or empty
:return: ``True`` if the tutorial is in validation, ``False`` otherwise
:rtype: bool | A tutorial is not in validation if sha_validation is ``None`` or empty | [
"A",
"tutorial",
"is",
"not",
"in",
"validation",
"if",
"sha_validation",
"is",
"None",
"or",
"empty"
] | def in_validation(self):
"""A tutorial is not in validation if sha_validation is ``None`` or empty
:return: ``True`` if the tutorial is in validation, ``False`` otherwise
:rtype: bool
"""
return (self.sha_validation is not None) and (self.sha_validation.strip() != "") | [
"def",
"in_validation",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"sha_validation",
"is",
"not",
"None",
")",
"and",
"(",
"self",
".",
"sha_validation",
".",
"strip",
"(",
")",
"!=",
"\"\"",
")"
] | https://github.com/zestedesavoir/zds-site/blob/2ba922223c859984a413cc6c108a8aa4023b113e/zds/tutorialv2/models/database.py#L257-L263 | |
rwl/PYPOWER | f5be0406aa54dcebded075de075454f99e2a46e6 | pypower/case14.py | python | case14 | () | return ppc | Power flow data for IEEE 14 bus test case.
Please see L{caseformat} for details on the case file format.
This data was converted from IEEE Common Data Format
(ieee14cdf.txt) on 20-Sep-2004 by cdf2matp, rev. 1.11
Converted from IEEE CDF file from:
U{http://www.ee.washington.edu/research/pstca/}
... | Power flow data for IEEE 14 bus test case.
Please see L{caseformat} for details on the case file format. | [
"Power",
"flow",
"data",
"for",
"IEEE",
"14",
"bus",
"test",
"case",
".",
"Please",
"see",
"L",
"{",
"caseformat",
"}",
"for",
"details",
"on",
"the",
"case",
"file",
"format",
"."
] | def case14():
"""Power flow data for IEEE 14 bus test case.
Please see L{caseformat} for details on the case file format.
This data was converted from IEEE Common Data Format
(ieee14cdf.txt) on 20-Sep-2004 by cdf2matp, rev. 1.11
Converted from IEEE CDF file from:
U{http://www.ee.washington.edu... | [
"def",
"case14",
"(",
")",
":",
"ppc",
"=",
"{",
"\"version\"",
":",
"'2'",
"}",
"##----- Power Flow Data -----##",
"## system MVA base",
"ppc",
"[",
"\"baseMVA\"",
"]",
"=",
"100.0",
"## bus data",
"# bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin",
"ppc",
"... | https://github.com/rwl/PYPOWER/blob/f5be0406aa54dcebded075de075454f99e2a46e6/pypower/case14.py#L10-L97 | |
boston-dynamics/spot-sdk | 5ffa12e6943a47323c7279d86e30346868755f52 | python/bosdyn-core/src/bosdyn/bddf/file_indexer.py | python | FileIndexer.add_series_descriptor | (self, series_descriptor, series_block_file_offset) | Add the given series_descriptor to the index, with the given file offset.
Args:
series_descriptor SeriesDescriptor to add to the index
series_block_file_offset Location in file where SeriesDescriptor will be written, or
was read from. | Add the given series_descriptor to the index, with the given file offset. | [
"Add",
"the",
"given",
"series_descriptor",
"to",
"the",
"index",
"with",
"the",
"given",
"file",
"offset",
"."
] | def add_series_descriptor(self, series_descriptor, series_block_file_offset):
"""Add the given series_descriptor to the index, with the given file offset.
Args:
series_descriptor SeriesDescriptor to add to the index
series_block_file_offset Location in file where SeriesDescri... | [
"def",
"add_series_descriptor",
"(",
"self",
",",
"series_descriptor",
",",
"series_block_file_offset",
")",
":",
"assert",
"series_descriptor",
".",
"series_index",
"==",
"len",
"(",
"self",
".",
"_series_descriptors",
")",
"# Update the file index.",
"self",
".",
"f... | https://github.com/boston-dynamics/spot-sdk/blob/5ffa12e6943a47323c7279d86e30346868755f52/python/bosdyn-core/src/bosdyn/bddf/file_indexer.py#L62-L77 | ||
cloudera/impyla | 0c736af4cad2bade9b8e313badc08ec50e81c948 | impala/_thrift_gen/hive_metastore/ttypes.py | python | ConfigValSecurityException.write | (self, oprot) | [] | def write(self, oprot):
if oprot._fast_encode is not None and self.thrift_spec is not None:
oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec]))
return
oprot.writeStructBegin('ConfigValSecurityException')
if self.message is not None:
... | [
"def",
"write",
"(",
"self",
",",
"oprot",
")",
":",
"if",
"oprot",
".",
"_fast_encode",
"is",
"not",
"None",
"and",
"self",
".",
"thrift_spec",
"is",
"not",
"None",
":",
"oprot",
".",
"trans",
".",
"write",
"(",
"oprot",
".",
"_fast_encode",
"(",
"s... | https://github.com/cloudera/impyla/blob/0c736af4cad2bade9b8e313badc08ec50e81c948/impala/_thrift_gen/hive_metastore/ttypes.py#L11461-L11471 | ||||
felipecode/coiltraine | 29060ab5fd2ea5531686e72c621aaaca3b23f4fb | carla08/agent/modules/waypointer.py | python | Waypointer._shift_points | (self, distance_to_center, lane_points, inflection_position) | return shifted_lane_vec | Function to take the route points in the middle of the road and shift then to the
center of the lane
Args:
distance_to_center: The distance you want to shift
lane_points: the lane points used
inflection_position: A corner case, when there is a turn.
Retur... | Function to take the route points in the middle of the road and shift then to the
center of the lane
Args:
distance_to_center: The distance you want to shift
lane_points: the lane points used
inflection_position: A corner case, when there is a turn. | [
"Function",
"to",
"take",
"the",
"route",
"points",
"in",
"the",
"middle",
"of",
"the",
"road",
"and",
"shift",
"then",
"to",
"the",
"center",
"of",
"the",
"lane",
"Args",
":",
"distance_to_center",
":",
"The",
"distance",
"you",
"want",
"to",
"shift",
"... | def _shift_points(self, distance_to_center, lane_points, inflection_position):
"""
Function to take the route points in the middle of the road and shift then to the
center of the lane
Args:
distance_to_center: The distance you want to shift
lane_points: th... | [
"def",
"_shift_points",
"(",
"self",
",",
"distance_to_center",
",",
"lane_points",
",",
"inflection_position",
")",
":",
"shifted_lane_vec",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"lane_points",
"[",
":",
"-",
"1",
"]",
")",
")",
":"... | https://github.com/felipecode/coiltraine/blob/29060ab5fd2ea5531686e72c621aaaca3b23f4fb/carla08/agent/modules/waypointer.py#L113-L150 | |
tensorflow/models | 6b8bb0cbeb3e10415c7a87448f08adc3c484c1d3 | official/vision/beta/projects/simclr/losses/contrastive_losses.py | python | ContrastiveLoss.__call__ | (self, projection1: tf.Tensor, projection2: tf.Tensor) | return loss_local, (logits_ab, labels) | Compute the contrastive loss for contrastive learning.
Note that projection2 is generated with the same batch (same order) of raw
images, but with different augmentation. More specifically:
image[i] -> random augmentation 1 -> projection -> projection1[i]
image[i] -> random augmentation 2 -> projection... | Compute the contrastive loss for contrastive learning. | [
"Compute",
"the",
"contrastive",
"loss",
"for",
"contrastive",
"learning",
"."
] | def __call__(self, projection1: tf.Tensor, projection2: tf.Tensor):
"""Compute the contrastive loss for contrastive learning.
Note that projection2 is generated with the same batch (same order) of raw
images, but with different augmentation. More specifically:
image[i] -> random augmentation 1 -> proje... | [
"def",
"__call__",
"(",
"self",
",",
"projection1",
":",
"tf",
".",
"Tensor",
",",
"projection2",
":",
"tf",
".",
"Tensor",
")",
":",
"# Get (normalized) hidden1 and hidden2.",
"if",
"self",
".",
"_projection_norm",
":",
"projection1",
"=",
"tf",
".",
"math",
... | https://github.com/tensorflow/models/blob/6b8bb0cbeb3e10415c7a87448f08adc3c484c1d3/official/vision/beta/projects/simclr/losses/contrastive_losses.py#L73-L134 | |
biopython/biopython | 2dd97e71762af7b046d7f7f8a4f1e38db6b06c86 | Bio/Blast/NCBIXML.py | python | BlastParser.set_hit_id | (self) | Record the identifier of the database sequence (PRIVATE). | Record the identifier of the database sequence (PRIVATE). | [
"Record",
"the",
"identifier",
"of",
"the",
"database",
"sequence",
"(",
"PRIVATE",
")",
"."
] | def set_hit_id(self):
"""Record the identifier of the database sequence (PRIVATE)."""
self._hit.hit_id = self._value
self._hit.title = self._value + " " | [
"def",
"set_hit_id",
"(",
"self",
")",
":",
"self",
".",
"_hit",
".",
"hit_id",
"=",
"self",
".",
"_value",
"self",
".",
"_hit",
".",
"title",
"=",
"self",
".",
"_value",
"+",
"\" \""
] | https://github.com/biopython/biopython/blob/2dd97e71762af7b046d7f7f8a4f1e38db6b06c86/Bio/Blast/NCBIXML.py#L525-L528 | ||
matrix-org/synapse | 8e57584a5859a9002759963eb546d523d2498a01 | synapse/metrics/background_process_metrics.py | python | BackgroundProcessLoggingContext.start | (self, rusage: "Optional[resource.struct_rusage]") | Log context has started running (again). | Log context has started running (again). | [
"Log",
"context",
"has",
"started",
"running",
"(",
"again",
")",
"."
] | def start(self, rusage: "Optional[resource.struct_rusage]") -> None:
"""Log context has started running (again)."""
super().start(rusage)
# We've become active again so we make sure we're in the list of active
# procs. (Note that "start" here means we've become active, as opposed
... | [
"def",
"start",
"(",
"self",
",",
"rusage",
":",
"\"Optional[resource.struct_rusage]\"",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"start",
"(",
"rusage",
")",
"# We've become active again so we make sure we're in the list of active",
"# procs. (Note that \"start\" he... | https://github.com/matrix-org/synapse/blob/8e57584a5859a9002759963eb546d523d2498a01/synapse/metrics/background_process_metrics.py#L303-L312 | ||
DataDog/integrations-core | 934674b29d94b70ccc008f76ea172d0cdae05e1e | mongo/datadog_checks/mongo/config_models/instance.py | python | InstanceConfig._run_validations | (cls, v, field) | return getattr(validators, f'instance_{field.name}', identity)(v, field=field) | [] | def _run_validations(cls, v, field):
if not v:
return v
return getattr(validators, f'instance_{field.name}', identity)(v, field=field) | [
"def",
"_run_validations",
"(",
"cls",
",",
"v",
",",
"field",
")",
":",
"if",
"not",
"v",
":",
"return",
"v",
"return",
"getattr",
"(",
"validators",
",",
"f'instance_{field.name}'",
",",
"identity",
")",
"(",
"v",
",",
"field",
"=",
"field",
")"
] | https://github.com/DataDog/integrations-core/blob/934674b29d94b70ccc008f76ea172d0cdae05e1e/mongo/datadog_checks/mongo/config_models/instance.py#L86-L90 | |||
google/trax | d6cae2067dedd0490b78d831033607357e975015 | trax/tf_numpy/extensions/extensions.py | python | _PmapConfig.__init__ | (self) | [] | def __init__(self):
super(_PmapConfig, self).__init__()
self._axis_name = None
self._devices = None | [
"def",
"__init__",
"(",
"self",
")",
":",
"super",
"(",
"_PmapConfig",
",",
"self",
")",
".",
"__init__",
"(",
")",
"self",
".",
"_axis_name",
"=",
"None",
"self",
".",
"_devices",
"=",
"None"
] | https://github.com/google/trax/blob/d6cae2067dedd0490b78d831033607357e975015/trax/tf_numpy/extensions/extensions.py#L1572-L1575 | ||||
inasafe/inasafe | 355eb2ce63f516b9c26af0c86a24f99e53f63f87 | safe/utilities/gis.py | python | extent_string_to_array | (extent_text) | return coordinates | Convert an extent string to an array.
.. versionadded: 2.2.0
:param extent_text: String representing an extent e.g.
109.829170982, -8.13333290561, 111.005344795, -7.49226294379
:type extent_text: str
:returns: A list of floats, or None
:rtype: list, None | Convert an extent string to an array. | [
"Convert",
"an",
"extent",
"string",
"to",
"an",
"array",
"."
] | def extent_string_to_array(extent_text):
"""Convert an extent string to an array.
.. versionadded: 2.2.0
:param extent_text: String representing an extent e.g.
109.829170982, -8.13333290561, 111.005344795, -7.49226294379
:type extent_text: str
:returns: A list of floats, or None
:rtyp... | [
"def",
"extent_string_to_array",
"(",
"extent_text",
")",
":",
"coordinates",
"=",
"extent_text",
".",
"replace",
"(",
"' '",
",",
"''",
")",
".",
"split",
"(",
"','",
")",
"count",
"=",
"len",
"(",
"coordinates",
")",
"if",
"count",
"!=",
"4",
":",
"m... | https://github.com/inasafe/inasafe/blob/355eb2ce63f516b9c26af0c86a24f99e53f63f87/safe/utilities/gis.py#L26-L53 | |
eirannejad/pyRevit | 49c0b7eb54eb343458ce1365425e6552d0c47d44 | site-packages/sqlalchemy/sql/schema.py | python | Sequence.__init__ | (self, name, start=None, increment=None, minvalue=None,
maxvalue=None, nominvalue=None, nomaxvalue=None, cycle=None,
schema=None, cache=None, order=None, optional=False,
quote=None, metadata=None, quote_schema=None,
for_update=False) | Construct a :class:`.Sequence` object.
:param name: The name of the sequence.
:param start: the starting index of the sequence. This value is
used when the CREATE SEQUENCE command is emitted to the database
as the value of the "START WITH" clause. If ``None``, the
clause i... | Construct a :class:`.Sequence` object. | [
"Construct",
"a",
":",
"class",
":",
".",
"Sequence",
"object",
"."
] | def __init__(self, name, start=None, increment=None, minvalue=None,
maxvalue=None, nominvalue=None, nomaxvalue=None, cycle=None,
schema=None, cache=None, order=None, optional=False,
quote=None, metadata=None, quote_schema=None,
for_update=False):
... | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"start",
"=",
"None",
",",
"increment",
"=",
"None",
",",
"minvalue",
"=",
"None",
",",
"maxvalue",
"=",
"None",
",",
"nominvalue",
"=",
"None",
",",
"nomaxvalue",
"=",
"None",
",",
"cycle",
"=",
"Non... | https://github.com/eirannejad/pyRevit/blob/49c0b7eb54eb343458ce1365425e6552d0c47d44/site-packages/sqlalchemy/sql/schema.py#L2121-L2271 | ||
krintoxi/NoobSec-Toolkit | 38738541cbc03cedb9a3b3ed13b629f781ad64f6 | NoobSecToolkit /tools/sqli/thirdparty/colorama/winterm.py | python | WinTerm.get_position | (self, handle) | return position | [] | def get_position(self, handle):
position = win32.GetConsoleScreenBufferInfo(handle).dwCursorPosition
# Because Windows coordinates are 0-based,
# and win32.SetConsoleCursorPosition expects 1-based.
position.X += 1
position.Y += 1
return position | [
"def",
"get_position",
"(",
"self",
",",
"handle",
")",
":",
"position",
"=",
"win32",
".",
"GetConsoleScreenBufferInfo",
"(",
"handle",
")",
".",
"dwCursorPosition",
"# Because Windows coordinates are 0-based,",
"# and win32.SetConsoleCursorPosition expects 1-based.",
"posit... | https://github.com/krintoxi/NoobSec-Toolkit/blob/38738541cbc03cedb9a3b3ed13b629f781ad64f6/NoobSecToolkit /tools/sqli/thirdparty/colorama/winterm.py#L69-L75 | |||
demisto/content | 5c664a65b992ac8ca90ac3f11b1b2cdf11ee9b07 | Packs/MicrosoftManagementActivity/Integrations/MicrosoftManagementActivity/MicrosoftManagementActivity.py | python | Client.http_request | (self, method, url_suffix='', full_url=None, headers=None, params=None, timeout=None, ok_codes=None,
return_empty_response=False, **kwargs) | return self._http_request(method=method, url_suffix=url_suffix, full_url=full_url, params=params,
ok_codes=ok_codes, headers=headers, return_empty_response=return_empty_response,
timeout=timeout, **kwargs) | Calls the built in http_request, replacing a None timeout with self.timeout | Calls the built in http_request, replacing a None timeout with self.timeout | [
"Calls",
"the",
"built",
"in",
"http_request",
"replacing",
"a",
"None",
"timeout",
"with",
"self",
".",
"timeout"
] | def http_request(self, method, url_suffix='', full_url=None, headers=None, params=None, timeout=None, ok_codes=None,
return_empty_response=False, **kwargs):
"""
Calls the built in http_request, replacing a None timeout with self.timeout
"""
if timeout is None:
... | [
"def",
"http_request",
"(",
"self",
",",
"method",
",",
"url_suffix",
"=",
"''",
",",
"full_url",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"params",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"ok_codes",
"=",
"None",
",",
"return_empty_response... | https://github.com/demisto/content/blob/5c664a65b992ac8ca90ac3f11b1b2cdf11ee9b07/Packs/MicrosoftManagementActivity/Integrations/MicrosoftManagementActivity/MicrosoftManagementActivity.py#L99-L108 | |
TabbycatDebate/tabbycat | 7cc3b2fa1cc34569501a4be10fe9234b98c65df3 | tabbycat/results/forms.py | python | ScoresMixin.populate_result_with_scores | (self, result) | Should populate `result` with speaker scores in-place, using the data
in `self.cleaned_data`. Must be implemented by subclasses. | Should populate `result` with speaker scores in-place, using the data
in `self.cleaned_data`. Must be implemented by subclasses. | [
"Should",
"populate",
"result",
"with",
"speaker",
"scores",
"in",
"-",
"place",
"using",
"the",
"data",
"in",
"self",
".",
"cleaned_data",
".",
"Must",
"be",
"implemented",
"by",
"subclasses",
"."
] | def populate_result_with_scores(self, result):
"""Should populate `result` with speaker scores in-place, using the data
in `self.cleaned_data`. Must be implemented by subclasses."""
raise NotImplementedError | [
"def",
"populate_result_with_scores",
"(",
"self",
",",
"result",
")",
":",
"raise",
"NotImplementedError"
] | https://github.com/TabbycatDebate/tabbycat/blob/7cc3b2fa1cc34569501a4be10fe9234b98c65df3/tabbycat/results/forms.py#L609-L612 | ||
Qiskit/qiskit-terra | b66030e3b9192efdd3eb95cf25c6545fe0a13da4 | qiskit/algorithms/linear_solvers/matrices/numpy_matrix.py | python | NumPyMatrix.evolution_time | (self) | return self._evolution_time | Return the time of the evolution. | Return the time of the evolution. | [
"Return",
"the",
"time",
"of",
"the",
"evolution",
"."
] | def evolution_time(self) -> float:
"""Return the time of the evolution."""
return self._evolution_time | [
"def",
"evolution_time",
"(",
"self",
")",
"->",
"float",
":",
"return",
"self",
".",
"_evolution_time"
] | https://github.com/Qiskit/qiskit-terra/blob/b66030e3b9192efdd3eb95cf25c6545fe0a13da4/qiskit/algorithms/linear_solvers/matrices/numpy_matrix.py#L119-L121 | |
openshift/openshift-tools | 1188778e728a6e4781acf728123e5b356380fe6f | openshift/installer/vendored/openshift-ansible-3.11.28-1/roles/lib_vendored_deps/library/oc_edit.py | python | OpenShiftCLIConfig.config_options | (self) | return self._options | return config options | return config options | [
"return",
"config",
"options"
] | def config_options(self):
''' return config options '''
return self._options | [
"def",
"config_options",
"(",
"self",
")",
":",
"return",
"self",
".",
"_options"
] | https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/openshift/installer/vendored/openshift-ansible-3.11.28-1/roles/lib_vendored_deps/library/oc_edit.py#L1481-L1483 | |
hzy46/Deep-Learning-21-Examples | 15c2d9edccad090cd67b033f24a43c544e5cba3e | chapter_16/nmt/model_helper.py | python | get_initializer | (init_op, seed=None, init_weight=None) | Create an initializer. init_weight is only for uniform. | Create an initializer. init_weight is only for uniform. | [
"Create",
"an",
"initializer",
".",
"init_weight",
"is",
"only",
"for",
"uniform",
"."
] | def get_initializer(init_op, seed=None, init_weight=None):
"""Create an initializer. init_weight is only for uniform."""
if init_op == "uniform":
assert init_weight
return tf.random_uniform_initializer(
-init_weight, init_weight, seed=seed)
elif init_op == "glorot_normal":
return tf.contrib.ke... | [
"def",
"get_initializer",
"(",
"init_op",
",",
"seed",
"=",
"None",
",",
"init_weight",
"=",
"None",
")",
":",
"if",
"init_op",
"==",
"\"uniform\"",
":",
"assert",
"init_weight",
"return",
"tf",
".",
"random_uniform_initializer",
"(",
"-",
"init_weight",
",",
... | https://github.com/hzy46/Deep-Learning-21-Examples/blob/15c2d9edccad090cd67b033f24a43c544e5cba3e/chapter_16/nmt/model_helper.py#L18-L31 | ||
mozillazg/pypy | 2ff5cd960c075c991389f842c6d59e71cf0cb7d0 | lib-python/2.7/difflib.py | python | HtmlDiff._format_line | (self,side,flag,linenum,text) | return '<td class="diff_header"%s>%s</td><td nowrap="nowrap">%s</td>' \
% (id,linenum,text) | Returns HTML markup of "from" / "to" text lines
side -- 0 or 1 indicating "from" or "to" text
flag -- indicates if difference on line
linenum -- line number (used for line number column)
text -- line text to be marked up | Returns HTML markup of "from" / "to" text lines | [
"Returns",
"HTML",
"markup",
"of",
"from",
"/",
"to",
"text",
"lines"
] | def _format_line(self,side,flag,linenum,text):
"""Returns HTML markup of "from" / "to" text lines
side -- 0 or 1 indicating "from" or "to" text
flag -- indicates if difference on line
linenum -- line number (used for line number column)
text -- line text to be marked up
... | [
"def",
"_format_line",
"(",
"self",
",",
"side",
",",
"flag",
",",
"linenum",
",",
"text",
")",
":",
"try",
":",
"linenum",
"=",
"'%d'",
"%",
"linenum",
"id",
"=",
"' id=\"%s%s\"'",
"%",
"(",
"self",
".",
"_prefix",
"[",
"side",
"]",
",",
"linenum",
... | https://github.com/mozillazg/pypy/blob/2ff5cd960c075c991389f842c6d59e71cf0cb7d0/lib-python/2.7/difflib.py#L1860-L1881 | |
jamiecaesar/securecrt-tools | f3cbb49223a485fc9af86e9799b5c940f19e8027 | securecrt_tools/settings.py | python | SettingsImporter.getlist | (self, section, setting) | return filter(None, map(lambda x: x.strip(), raw_setting.split(','))) | A wrapper function to simplify the retrieval of an individual setting as a list. Requires the setting to be
a comma separated list, with no quotations.
:param section: The section of the settings file where the setting can be found.
:type section: str
:param setting: The name of the se... | A wrapper function to simplify the retrieval of an individual setting as a list. Requires the setting to be
a comma separated list, with no quotations. | [
"A",
"wrapper",
"function",
"to",
"simplify",
"the",
"retrieval",
"of",
"an",
"individual",
"setting",
"as",
"a",
"list",
".",
"Requires",
"the",
"setting",
"to",
"be",
"a",
"comma",
"separated",
"list",
"with",
"no",
"quotations",
"."
] | def getlist(self, section, setting):
"""
A wrapper function to simplify the retrieval of an individual setting as a list. Requires the setting to be
a comma separated list, with no quotations.
:param section: The section of the settings file where the setting can be found.
:typ... | [
"def",
"getlist",
"(",
"self",
",",
"section",
",",
"setting",
")",
":",
"# Get the raw string from the settings file.",
"raw_setting",
"=",
"self",
".",
"config",
".",
"get",
"(",
"section",
",",
"setting",
")",
"# Split the raw string on the comma, and save each item ... | https://github.com/jamiecaesar/securecrt-tools/blob/f3cbb49223a485fc9af86e9799b5c940f19e8027/securecrt_tools/settings.py#L136-L152 | |
inspurer/WorkAttendanceSystem | 1221e2d67bdf5bb15fe99517cc3ded58ccb066df | V2.0/venv/Lib/site-packages/pip-9.0.1-py3.5.egg/pip/req/req_set.py | python | RequirementSet._prepare_file | (self,
finder,
req_to_install,
require_hashes=False,
ignore_dependencies=False) | return more_reqs | Prepare a single requirements file.
:return: A list of additional InstallRequirements to also install. | Prepare a single requirements file. | [
"Prepare",
"a",
"single",
"requirements",
"file",
"."
] | def _prepare_file(self,
finder,
req_to_install,
require_hashes=False,
ignore_dependencies=False):
"""Prepare a single requirements file.
:return: A list of additional InstallRequirements to also install.
"""... | [
"def",
"_prepare_file",
"(",
"self",
",",
"finder",
",",
"req_to_install",
",",
"require_hashes",
"=",
"False",
",",
"ignore_dependencies",
"=",
"False",
")",
":",
"# Tell user what we are doing for this requirement:",
"# obtain (editable), skipping, processing (local url), col... | https://github.com/inspurer/WorkAttendanceSystem/blob/1221e2d67bdf5bb15fe99517cc3ded58ccb066df/V2.0/venv/Lib/site-packages/pip-9.0.1-py3.5.egg/pip/req/req_set.py#L459-L722 | |
fedspendingtransparency/usaspending-api | b13bd5bcba0369ff8512f61a34745626c3969391 | usaspending_api/etl/award_helpers.py | python | update_procurement_awards | (award_tuple: Optional[tuple] = None) | return execute_database_statement(fpds_award_update_sql_string.format(predicate=predicate), values) | Update procurement-specific award data based on the info in child transactions. | Update procurement-specific award data based on the info in child transactions. | [
"Update",
"procurement",
"-",
"specific",
"award",
"data",
"based",
"on",
"the",
"info",
"in",
"child",
"transactions",
"."
] | def update_procurement_awards(award_tuple: Optional[tuple] = None) -> int:
"""Update procurement-specific award data based on the info in child transactions."""
if award_tuple:
values = [award_tuple, award_tuple, award_tuple]
predicate = "WHERE tn.award_id IN %s"
else:
values = None
... | [
"def",
"update_procurement_awards",
"(",
"award_tuple",
":",
"Optional",
"[",
"tuple",
"]",
"=",
"None",
")",
"->",
"int",
":",
"if",
"award_tuple",
":",
"values",
"=",
"[",
"award_tuple",
",",
"award_tuple",
",",
"award_tuple",
"]",
"predicate",
"=",
"\"WHE... | https://github.com/fedspendingtransparency/usaspending-api/blob/b13bd5bcba0369ff8512f61a34745626c3969391/usaspending_api/etl/award_helpers.py#L353-L362 | |
svip-lab/impersonator | b041dd415157c1e7f5b46e579a1ad4dffabb2e66 | thirdparty/his_evaluators/his_evaluators/metrics/yolov3/models.py | python | create_modules | (module_defs) | return hyperparams, module_list | Constructs module list of layer blocks from module configuration in module_defs | Constructs module list of layer blocks from module configuration in module_defs | [
"Constructs",
"module",
"list",
"of",
"layer",
"blocks",
"from",
"module",
"configuration",
"in",
"module_defs"
] | def create_modules(module_defs):
"""
Constructs module list of layer blocks from module configuration in module_defs
"""
hyperparams = module_defs.pop(0)
output_filters = [int(hyperparams["channels"])]
module_list = nn.ModuleList()
for module_i, module_def in enumerate(module_defs):
... | [
"def",
"create_modules",
"(",
"module_defs",
")",
":",
"hyperparams",
"=",
"module_defs",
".",
"pop",
"(",
"0",
")",
"output_filters",
"=",
"[",
"int",
"(",
"hyperparams",
"[",
"\"channels\"",
"]",
")",
"]",
"module_list",
"=",
"nn",
".",
"ModuleList",
"("... | https://github.com/svip-lab/impersonator/blob/b041dd415157c1e7f5b46e579a1ad4dffabb2e66/thirdparty/his_evaluators/his_evaluators/metrics/yolov3/models.py#L12-L79 | |
williballenthin/python-registry | 11e857623469dd28ed14519a08d2db7c8228ca0c | Registry/RegistryLog.py | python | RegistryLog.recover_hive | (self) | Recover the hive from the transaction log file.
Returns the sequence number of the last log entry applied or None. | Recover the hive from the transaction log file.
Returns the sequence number of the last log entry applied or None. | [
"Recover",
"the",
"hive",
"from",
"the",
"transaction",
"log",
"file",
".",
"Returns",
"the",
"sequence",
"number",
"of",
"the",
"last",
"log",
"entry",
"applied",
"or",
"None",
"."
] | def recover_hive(self):
"""
Recover the hive from the transaction log file.
Returns the sequence number of the last log entry applied or None.
"""
recover = self._primary_regf.recovery_required()
if recover.recover_header:
self._primary.seek(0)
se... | [
"def",
"recover_hive",
"(",
"self",
")",
":",
"recover",
"=",
"self",
".",
"_primary_regf",
".",
"recovery_required",
"(",
")",
"if",
"recover",
".",
"recover_header",
":",
"self",
".",
"_primary",
".",
"seek",
"(",
"0",
")",
"self",
".",
"_primary",
"."... | https://github.com/williballenthin/python-registry/blob/11e857623469dd28ed14519a08d2db7c8228ca0c/Registry/RegistryLog.py#L162-L184 | ||
skylander86/lambda-text-extractor | 6da52d077a2fc571e38bfe29c33ae68f6443cd5a | lib-linux_x64/docx/oxml/table.py | python | CT_Tc._move_content_to | (self, other_tc) | Append the content of this cell to *other_tc*, leaving this cell with
a single empty ``<w:p>`` element. | Append the content of this cell to *other_tc*, leaving this cell with
a single empty ``<w:p>`` element. | [
"Append",
"the",
"content",
"of",
"this",
"cell",
"to",
"*",
"other_tc",
"*",
"leaving",
"this",
"cell",
"with",
"a",
"single",
"empty",
"<w",
":",
"p",
">",
"element",
"."
] | def _move_content_to(self, other_tc):
"""
Append the content of this cell to *other_tc*, leaving this cell with
a single empty ``<w:p>`` element.
"""
if other_tc is self:
return
if self._is_empty:
return
other_tc._remove_trailing_empty_p()
... | [
"def",
"_move_content_to",
"(",
"self",
",",
"other_tc",
")",
":",
"if",
"other_tc",
"is",
"self",
":",
"return",
"if",
"self",
".",
"_is_empty",
":",
"return",
"other_tc",
".",
"_remove_trailing_empty_p",
"(",
")",
"# appending moves each element from self to other... | https://github.com/skylander86/lambda-text-extractor/blob/6da52d077a2fc571e38bfe29c33ae68f6443cd5a/lib-linux_x64/docx/oxml/table.py#L531-L545 | ||
udacity/artificial-intelligence | d8bc7ee2511f8aff486e0fba010a7f12a7d268d4 | Projects/2_Classical Planning/aimacode/search.py | python | Node.expand | (self, problem) | return (self.child_node(problem, action)
for action in problem.actions(self.state)) | List the nodes reachable in one step from this node. | List the nodes reachable in one step from this node. | [
"List",
"the",
"nodes",
"reachable",
"in",
"one",
"step",
"from",
"this",
"node",
"."
] | def expand(self, problem):
"List the nodes reachable in one step from this node."
return (self.child_node(problem, action)
for action in problem.actions(self.state)) | [
"def",
"expand",
"(",
"self",
",",
"problem",
")",
":",
"return",
"(",
"self",
".",
"child_node",
"(",
"problem",
",",
"action",
")",
"for",
"action",
"in",
"problem",
".",
"actions",
"(",
"self",
".",
"state",
")",
")"
] | https://github.com/udacity/artificial-intelligence/blob/d8bc7ee2511f8aff486e0fba010a7f12a7d268d4/Projects/2_Classical Planning/aimacode/search.py#L97-L100 | |
triaquae/triaquae | bbabf736b3ba56a0c6498e7f04e16c13b8b8f2b9 | TriAquae/models/django/contrib/formtools/wizard/storage/cookie.py | python | CookieStorage.__init__ | (self, *args, **kwargs) | [] | def __init__(self, *args, **kwargs):
super(CookieStorage, self).__init__(*args, **kwargs)
self.data = self.load_data()
if self.data is None:
self.init_data() | [
"def",
"__init__",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"CookieStorage",
",",
"self",
")",
".",
"__init__",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"data",
"=",
"self",
".",
"load_da... | https://github.com/triaquae/triaquae/blob/bbabf736b3ba56a0c6498e7f04e16c13b8b8f2b9/TriAquae/models/django/contrib/formtools/wizard/storage/cookie.py#L12-L16 | ||||
openhatch/oh-mainline | ce29352a034e1223141dcc2f317030bbc3359a51 | vendor/packages/Django/docs/_ext/djangodocs.py | python | parse_django_adminopt_node | (env, sig, signode) | return firstname | A copy of sphinx.directives.CmdoptionDesc.parse_signature() | A copy of sphinx.directives.CmdoptionDesc.parse_signature() | [
"A",
"copy",
"of",
"sphinx",
".",
"directives",
".",
"CmdoptionDesc",
".",
"parse_signature",
"()"
] | def parse_django_adminopt_node(env, sig, signode):
"""A copy of sphinx.directives.CmdoptionDesc.parse_signature()"""
from sphinx.domains.std import option_desc_re
count = 0
firstname = ''
for m in option_desc_re.finditer(sig):
optname, args = m.groups()
if count:
signode ... | [
"def",
"parse_django_adminopt_node",
"(",
"env",
",",
"sig",
",",
"signode",
")",
":",
"from",
"sphinx",
".",
"domains",
".",
"std",
"import",
"option_desc_re",
"count",
"=",
"0",
"firstname",
"=",
"''",
"for",
"m",
"in",
"option_desc_re",
".",
"finditer",
... | https://github.com/openhatch/oh-mainline/blob/ce29352a034e1223141dcc2f317030bbc3359a51/vendor/packages/Django/docs/_ext/djangodocs.py#L168-L194 | |
hasegaw/IkaLog | bd476da541fcc296f792d4db76a6b9174c4777ad | tools/IkaClips.py | python | IkaClips.__init__ | (self) | [] | def __init__(self):
self.scenes = []
self.tmp_dir = '/tmp/'
self.out_dir = './' | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"scenes",
"=",
"[",
"]",
"self",
".",
"tmp_dir",
"=",
"'/tmp/'",
"self",
".",
"out_dir",
"=",
"'./'"
] | https://github.com/hasegaw/IkaLog/blob/bd476da541fcc296f792d4db76a6b9174c4777ad/tools/IkaClips.py#L205-L208 | ||||
wanggrun/Adaptively-Connected-Neural-Networks | e27066ef52301bdafa5932f43af8feeb23647edb | tensorpack-installed/tensorpack/models/utils.py | python | VariableHolder.all | (self) | return list(six.itervalues(self._vars)) | Returns:
list of all variables | Returns:
list of all variables | [
"Returns",
":",
"list",
"of",
"all",
"variables"
] | def all(self):
"""
Returns:
list of all variables
"""
return list(six.itervalues(self._vars)) | [
"def",
"all",
"(",
"self",
")",
":",
"return",
"list",
"(",
"six",
".",
"itervalues",
"(",
"self",
".",
"_vars",
")",
")"
] | https://github.com/wanggrun/Adaptively-Connected-Neural-Networks/blob/e27066ef52301bdafa5932f43af8feeb23647edb/tensorpack-installed/tensorpack/models/utils.py#L33-L38 | |
twisted/twisted | dee676b040dd38b847ea6fb112a712cb5e119490 | src/twisted/web/iweb.py | python | IRequest.getClientAddress | () | Return the address of the client who submitted this request.
The address may not be a network address. Callers must check
its type before using it.
@since: 18.4
@return: the client's address.
@rtype: an L{IAddress} provider. | Return the address of the client who submitted this request. | [
"Return",
"the",
"address",
"of",
"the",
"client",
"who",
"submitted",
"this",
"request",
"."
] | def getClientAddress():
"""
Return the address of the client who submitted this request.
The address may not be a network address. Callers must check
its type before using it.
@since: 18.4
@return: the client's address.
@rtype: an L{IAddress} provider.
... | [
"def",
"getClientAddress",
"(",
")",
":"
] | https://github.com/twisted/twisted/blob/dee676b040dd38b847ea6fb112a712cb5e119490/src/twisted/web/iweb.py#L140-L151 | ||
Fenixin/Minecraft-Region-Fixer | bfafd378ceb65116e4ea48cab24f1e6394051978 | progressbar/widgets.py | python | FormatLabel.__init__ | (self, format) | [] | def __init__(self, format):
self.format_string = format | [
"def",
"__init__",
"(",
"self",
",",
"format",
")",
":",
"self",
".",
"format_string",
"=",
"format"
] | https://github.com/Fenixin/Minecraft-Region-Fixer/blob/bfafd378ceb65116e4ea48cab24f1e6394051978/progressbar/widgets.py#L247-L248 | ||||
qutebrowser/qutebrowser | 3a2aaaacbf97f4bf0c72463f3da94ed2822a5442 | setup.py | python | read_file | (name) | Get the string contained in the file named name. | Get the string contained in the file named name. | [
"Get",
"the",
"string",
"contained",
"in",
"the",
"file",
"named",
"name",
"."
] | def read_file(name):
"""Get the string contained in the file named name."""
with common.open_file(name, 'r', encoding='utf-8') as f:
return f.read() | [
"def",
"read_file",
"(",
"name",
")",
":",
"with",
"common",
".",
"open_file",
"(",
"name",
",",
"'r'",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"f",
":",
"return",
"f",
".",
"read",
"(",
")"
] | https://github.com/qutebrowser/qutebrowser/blob/3a2aaaacbf97f4bf0c72463f3da94ed2822a5442/setup.py#L40-L43 | ||
home-assistant/core | 265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1 | homeassistant/components/apcupsd/binary_sensor.py | python | OnlineStatus.__init__ | (self, config, data) | Initialize the APCUPSd binary device. | Initialize the APCUPSd binary device. | [
"Initialize",
"the",
"APCUPSd",
"binary",
"device",
"."
] | def __init__(self, config, data):
"""Initialize the APCUPSd binary device."""
self._data = data
self._attr_name = config[CONF_NAME] | [
"def",
"__init__",
"(",
"self",
",",
"config",
",",
"data",
")",
":",
"self",
".",
"_data",
"=",
"data",
"self",
".",
"_attr_name",
"=",
"config",
"[",
"CONF_NAME",
"]"
] | https://github.com/home-assistant/core/blob/265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1/homeassistant/components/apcupsd/binary_sensor.py#L36-L39 | ||
wwqgtxx/wwqLyParse | 33136508e52821babd9294fdecffbdf02d73a6fc | wwqLyParse/lib/python-3.7.2-embed-win32/Crypto/PublicKey/__init__.py | python | _extract_subject_public_key_info | (x509_certificate) | return tbs_certificate[index] | Extract subjectPublicKeyInfo from a DER X.509 certificate. | Extract subjectPublicKeyInfo from a DER X.509 certificate. | [
"Extract",
"subjectPublicKeyInfo",
"from",
"a",
"DER",
"X",
".",
"509",
"certificate",
"."
] | def _extract_subject_public_key_info(x509_certificate):
"""Extract subjectPublicKeyInfo from a DER X.509 certificate."""
certificate = DerSequence().decode(x509_certificate, nr_elements=3)
tbs_certificate = DerSequence().decode(certificate[0],
nr_elements=list(ran... | [
"def",
"_extract_subject_public_key_info",
"(",
"x509_certificate",
")",
":",
"certificate",
"=",
"DerSequence",
"(",
")",
".",
"decode",
"(",
"x509_certificate",
",",
"nr_elements",
"=",
"3",
")",
"tbs_certificate",
"=",
"DerSequence",
"(",
")",
".",
"decode",
... | https://github.com/wwqgtxx/wwqLyParse/blob/33136508e52821babd9294fdecffbdf02d73a6fc/wwqLyParse/lib/python-3.7.2-embed-win32/Crypto/PublicKey/__init__.py#L77-L95 | |
linxid/Machine_Learning_Study_Path | 558e82d13237114bbb8152483977806fc0c222af | Machine Learning In Action/Chapter8-Regression/venv/Lib/site-packages/pip-9.0.1-py3.6.egg/pip/_vendor/distlib/version.py | python | Version.__le__ | (self, other) | return self.__lt__(other) or self.__eq__(other) | [] | def __le__(self, other):
return self.__lt__(other) or self.__eq__(other) | [
"def",
"__le__",
"(",
"self",
",",
"other",
")",
":",
"return",
"self",
".",
"__lt__",
"(",
"other",
")",
"or",
"self",
".",
"__eq__",
"(",
"other",
")"
] | https://github.com/linxid/Machine_Learning_Study_Path/blob/558e82d13237114bbb8152483977806fc0c222af/Machine Learning In Action/Chapter8-Regression/venv/Lib/site-packages/pip-9.0.1-py3.6.egg/pip/_vendor/distlib/version.py#L57-L58 | |||
openai/safety-gym | f31042f2f9ee61b9034dd6a416955972911544f5 | safety_gym/bench/bench_utils.py | python | normalize | (env, ret, cost, costrate, cost_limit=25, round=False) | return normed_ret, normed_cost, normed_costrate | Compute normalized metrics in a given environment for a given cost limit.
Inputs:
env: environment name. a string like 'Safexp-PointGoal1-v0'
ret: the average episodic return of the final policy
cost: the average episodic sum of costs of the final policy
costrate: ... | Compute normalized metrics in a given environment for a given cost limit. | [
"Compute",
"normalized",
"metrics",
"in",
"a",
"given",
"environment",
"for",
"a",
"given",
"cost",
"limit",
"."
] | def normalize(env, ret, cost, costrate, cost_limit=25, round=False):
"""
Compute normalized metrics in a given environment for a given cost limit.
Inputs:
env: environment name. a string like 'Safexp-PointGoal1-v0'
ret: the average episodic return of the final policy
co... | [
"def",
"normalize",
"(",
"env",
",",
"ret",
",",
"cost",
",",
"costrate",
",",
"cost_limit",
"=",
"25",
",",
"round",
"=",
"False",
")",
":",
"env",
"=",
"env",
".",
"split",
"(",
"'-'",
")",
"[",
"1",
"]",
".",
"lower",
"(",
")",
"with",
"open... | https://github.com/openai/safety-gym/blob/f31042f2f9ee61b9034dd6a416955972911544f5/safety_gym/bench/bench_utils.py#L40-L75 | |
epsy/clize | 84fef2080d7748dd36e465bc2048b48ed578d73f | clize/converters.py | python | datetime | (arg) | return dparser.parse(arg) | Parses a date into a `datetime` value
Requires ``dateutil`` to be installed. | Parses a date into a `datetime` value | [
"Parses",
"a",
"date",
"into",
"a",
"datetime",
"value"
] | def datetime(arg):
"""Parses a date into a `datetime` value
Requires ``dateutil`` to be installed.
"""
from dateutil import parser as dparser
return dparser.parse(arg) | [
"def",
"datetime",
"(",
"arg",
")",
":",
"from",
"dateutil",
"import",
"parser",
"as",
"dparser",
"return",
"dparser",
".",
"parse",
"(",
"arg",
")"
] | https://github.com/epsy/clize/blob/84fef2080d7748dd36e465bc2048b48ed578d73f/clize/converters.py#L16-L23 | |
dbpedia/fact-extractor | b6eb344e028a47ce0b7b706cefcb6cc1fb132cb0 | lib/entity_linking.py | python | twm_link_articles | (raw_articles) | return articles | Run Machine Linking on a list of raw text articles
:param list raw_articles: List of dictionaries with info about each article,
should have keys url, title and text
:return: The articles with the TWM linked entities, a new list of dictionaries
with the same keys as raw_articles plus an 'entitites' list
:rt... | Run Machine Linking on a list of raw text articles | [
"Run",
"Machine",
"Linking",
"on",
"a",
"list",
"of",
"raw",
"text",
"articles"
] | def twm_link_articles(raw_articles):
"""Run Machine Linking on a list of raw text articles
:param list raw_articles: List of dictionaries with info about each article,
should have keys url, title and text
:return: The articles with the TWM linked entities, a new list of dictionaries
with the same keys as r... | [
"def",
"twm_link_articles",
"(",
"raw_articles",
")",
":",
"articles",
"=",
"[",
"]",
"for",
"raw",
"in",
"raw_articles",
":",
"linked",
"=",
"{",
"'url'",
":",
"raw",
"[",
"'url'",
"]",
",",
"'title'",
":",
"raw",
"[",
"'title'",
"]",
"}",
"TWM_DATA",... | https://github.com/dbpedia/fact-extractor/blob/b6eb344e028a47ce0b7b706cefcb6cc1fb132cb0/lib/entity_linking.py#L66-L87 | |
tjweir/liftbook | e977a7face13ade1a4558e1909a6951d2f8928dd | elyxer.py | python | SymbolFunction.detect | (self, pos) | return pos.current() in SymbolFunction.commandmap | Find the symbol | Find the symbol | [
"Find",
"the",
"symbol"
] | def detect(self, pos):
"Find the symbol"
return pos.current() in SymbolFunction.commandmap | [
"def",
"detect",
"(",
"self",
",",
"pos",
")",
":",
"return",
"pos",
".",
"current",
"(",
")",
"in",
"SymbolFunction",
".",
"commandmap"
] | https://github.com/tjweir/liftbook/blob/e977a7face13ade1a4558e1909a6951d2f8928dd/elyxer.py#L4593-L4595 | |
pyparallel/pyparallel | 11e8c6072d48c8f13641925d17b147bf36ee0ba3 | Lib/datetime.py | python | _ymd2ord | (year, month, day) | return (_days_before_year(year) +
_days_before_month(year, month) +
day) | year, month, day -> ordinal, considering 01-Jan-0001 as day 1. | year, month, day -> ordinal, considering 01-Jan-0001 as day 1. | [
"year",
"month",
"day",
"-",
">",
"ordinal",
"considering",
"01",
"-",
"Jan",
"-",
"0001",
"as",
"day",
"1",
"."
] | def _ymd2ord(year, month, day):
"year, month, day -> ordinal, considering 01-Jan-0001 as day 1."
assert 1 <= month <= 12, 'month must be in 1..12'
dim = _days_in_month(year, month)
assert 1 <= day <= dim, ('day must be in 1..%d' % dim)
return (_days_before_year(year) +
_days_before_month... | [
"def",
"_ymd2ord",
"(",
"year",
",",
"month",
",",
"day",
")",
":",
"assert",
"1",
"<=",
"month",
"<=",
"12",
",",
"'month must be in 1..12'",
"dim",
"=",
"_days_in_month",
"(",
"year",
",",
"month",
")",
"assert",
"1",
"<=",
"day",
"<=",
"dim",
",",
... | https://github.com/pyparallel/pyparallel/blob/11e8c6072d48c8f13641925d17b147bf36ee0ba3/Lib/datetime.py#L56-L63 | |
geekcomputers/Python | 557a684f91aedcddbade3758793738225e1a4eb4 | XORcipher/XOR_cipher.py | python | XORCipher.decrypt_file | (self, file, key) | return True | input: filename (str) and a key (int)
output: returns true if decrypt process was
successful otherwise false
if key not passed the method uses the key by the constructor.
otherwise key = 1 | input: filename (str) and a key (int)
output: returns true if decrypt process was
successful otherwise false
if key not passed the method uses the key by the constructor.
otherwise key = 1 | [
"input",
":",
"filename",
"(",
"str",
")",
"and",
"a",
"key",
"(",
"int",
")",
"output",
":",
"returns",
"true",
"if",
"decrypt",
"process",
"was",
"successful",
"otherwise",
"false",
"if",
"key",
"not",
"passed",
"the",
"method",
"uses",
"the",
"key",
... | def decrypt_file(self, file, key):
"""
input: filename (str) and a key (int)
output: returns true if decrypt process was
successful otherwise false
if key not passed the method uses the key by the constructor.
otherwise key = 1
"""
# p... | [
"def",
"decrypt_file",
"(",
"self",
",",
"file",
",",
"key",
")",
":",
"# precondition",
"assert",
"(",
"isinstance",
"(",
"file",
",",
"str",
")",
"and",
"isinstance",
"(",
"key",
",",
"int",
")",
")",
"try",
":",
"with",
"open",
"(",
"file",
",",
... | https://github.com/geekcomputers/Python/blob/557a684f91aedcddbade3758793738225e1a4eb4/XORcipher/XOR_cipher.py#L156-L178 | |
mit-han-lab/data-efficient-gans | 6858275f08f43a33026844c8c2ac4e703e8a07ba | DiffAugment-stylegan2-pytorch/calc_metrics.py | python | subprocess_fn | (rank, args, temp_dir) | [] | def subprocess_fn(rank, args, temp_dir):
dnnlib.util.Logger(should_flush=True)
# Init torch.distributed.
if args.num_gpus > 1:
init_file = os.path.abspath(os.path.join(temp_dir, '.torch_distributed_init'))
if os.name == 'nt':
init_method = 'file:///' + init_file.replace('\\', '/... | [
"def",
"subprocess_fn",
"(",
"rank",
",",
"args",
",",
"temp_dir",
")",
":",
"dnnlib",
".",
"util",
".",
"Logger",
"(",
"should_flush",
"=",
"True",
")",
"# Init torch.distributed.",
"if",
"args",
".",
"num_gpus",
">",
"1",
":",
"init_file",
"=",
"os",
"... | https://github.com/mit-han-lab/data-efficient-gans/blob/6858275f08f43a33026844c8c2ac4e703e8a07ba/DiffAugment-stylegan2-pytorch/calc_metrics.py#L28-L72 | ||||
openhatch/oh-mainline | ce29352a034e1223141dcc2f317030bbc3359a51 | vendor/packages/python-social-auth/social/apps/django_app/default/fields.py | python | JSONField.value_to_string | (self, obj) | return smart_text(self.get_prep_value(self._get_val_from_obj(obj))) | Return value from object converted to string properly | Return value from object converted to string properly | [
"Return",
"value",
"from",
"object",
"converted",
"to",
"string",
"properly"
] | def value_to_string(self, obj):
"""Return value from object converted to string properly"""
return smart_text(self.get_prep_value(self._get_val_from_obj(obj))) | [
"def",
"value_to_string",
"(",
"self",
",",
"obj",
")",
":",
"return",
"smart_text",
"(",
"self",
".",
"get_prep_value",
"(",
"self",
".",
"_get_val_from_obj",
"(",
"obj",
")",
")",
")"
] | https://github.com/openhatch/oh-mainline/blob/ce29352a034e1223141dcc2f317030bbc3359a51/vendor/packages/python-social-auth/social/apps/django_app/default/fields.py#L62-L64 | |
bruderstein/PythonScript | df9f7071ddf3a079e3a301b9b53a6dc78cf1208f | PythonLib/full/idlelib/editor.py | python | EditorWindow.fill_menus | (self, menudefs=None, keydefs=None) | Add appropriate entries to the menus and submenus
Menus that are absent or None in self.menudict are ignored. | Add appropriate entries to the menus and submenus | [
"Add",
"appropriate",
"entries",
"to",
"the",
"menus",
"and",
"submenus"
] | def fill_menus(self, menudefs=None, keydefs=None):
"""Add appropriate entries to the menus and submenus
Menus that are absent or None in self.menudict are ignored.
"""
if menudefs is None:
menudefs = self.mainmenu.menudefs
if keydefs is None:
keydefs = se... | [
"def",
"fill_menus",
"(",
"self",
",",
"menudefs",
"=",
"None",
",",
"keydefs",
"=",
"None",
")",
":",
"if",
"menudefs",
"is",
"None",
":",
"menudefs",
"=",
"self",
".",
"mainmenu",
".",
"menudefs",
"if",
"keydefs",
"is",
"None",
":",
"keydefs",
"=",
... | https://github.com/bruderstein/PythonScript/blob/df9f7071ddf3a079e3a301b9b53a6dc78cf1208f/PythonLib/full/idlelib/editor.py#L1157-L1192 | ||
WenmuZhou/PytorchOCR | 0b2b3a67814ae40b20f3814d6793f5d75d644e38 | torchocr/utils/CreateRecAug.py | python | MotionBlur.setparam | (self, degree=5, angle=180) | [] | def setparam(self, degree=5, angle=180):
self.degree = degree
self.angle = angle | [
"def",
"setparam",
"(",
"self",
",",
"degree",
"=",
"5",
",",
"angle",
"=",
"180",
")",
":",
"self",
".",
"degree",
"=",
"degree",
"self",
".",
"angle",
"=",
"angle"
] | https://github.com/WenmuZhou/PytorchOCR/blob/0b2b3a67814ae40b20f3814d6793f5d75d644e38/torchocr/utils/CreateRecAug.py#L279-L281 | ||||
osmr/imgclsmob | f2993d3ce73a2f7ddba05da3891defb08547d504 | pytorch/pytorchcv/models/mobilenetv2.py | python | mobilenetv2_w3d4 | (**kwargs) | return get_mobilenetv2(width_scale=0.75, model_name="mobilenetv2_w3d4", **kwargs) | 0.75 MobileNetV2-224 model from 'MobileNetV2: Inverted Residuals and Linear Bottlenecks,'
https://arxiv.org/abs/1801.04381.
Parameters:
----------
pretrained : bool, default False
Whether to load the pretrained weights for model.
root : str, default '~/.torch/models'
Location for ke... | 0.75 MobileNetV2-224 model from 'MobileNetV2: Inverted Residuals and Linear Bottlenecks,'
https://arxiv.org/abs/1801.04381. | [
"0",
".",
"75",
"MobileNetV2",
"-",
"224",
"model",
"from",
"MobileNetV2",
":",
"Inverted",
"Residuals",
"and",
"Linear",
"Bottlenecks",
"https",
":",
"//",
"arxiv",
".",
"org",
"/",
"abs",
"/",
"1801",
".",
"04381",
"."
] | def mobilenetv2_w3d4(**kwargs):
"""
0.75 MobileNetV2-224 model from 'MobileNetV2: Inverted Residuals and Linear Bottlenecks,'
https://arxiv.org/abs/1801.04381.
Parameters:
----------
pretrained : bool, default False
Whether to load the pretrained weights for model.
root : str, defau... | [
"def",
"mobilenetv2_w3d4",
"(",
"*",
"*",
"kwargs",
")",
":",
"return",
"get_mobilenetv2",
"(",
"width_scale",
"=",
"0.75",
",",
"model_name",
"=",
"\"mobilenetv2_w3d4\"",
",",
"*",
"*",
"kwargs",
")"
] | https://github.com/osmr/imgclsmob/blob/f2993d3ce73a2f7ddba05da3891defb08547d504/pytorch/pytorchcv/models/mobilenetv2.py#L228-L240 | |
benoitc/gunicorn | 76f8da24cbb992d168e01bda811452bcf3b8f5b3 | gunicorn/arbiter.py | python | Arbiter.kill_workers | (self, sig) | \
Kill all workers with the signal `sig`
:attr sig: `signal.SIG*` value | \
Kill all workers with the signal `sig`
:attr sig: `signal.SIG*` value | [
"\\",
"Kill",
"all",
"workers",
"with",
"the",
"signal",
"sig",
":",
"attr",
"sig",
":",
"signal",
".",
"SIG",
"*",
"value"
] | def kill_workers(self, sig):
"""\
Kill all workers with the signal `sig`
:attr sig: `signal.SIG*` value
"""
worker_pids = list(self.WORKERS.keys())
for pid in worker_pids:
self.kill_worker(pid, sig) | [
"def",
"kill_workers",
"(",
"self",
",",
"sig",
")",
":",
"worker_pids",
"=",
"list",
"(",
"self",
".",
"WORKERS",
".",
"keys",
"(",
")",
")",
"for",
"pid",
"in",
"worker_pids",
":",
"self",
".",
"kill_worker",
"(",
"pid",
",",
"sig",
")"
] | https://github.com/benoitc/gunicorn/blob/76f8da24cbb992d168e01bda811452bcf3b8f5b3/gunicorn/arbiter.py#L619-L626 | ||
sagemath/sage | f9b2db94f675ff16963ccdefba4f1a3393b3fe0d | src/sage/topology/simplicial_complex_examples.py | python | MatchingComplex | (n) | return UniqueSimplicialComplex(facets, name='Matching complex on {} vertices'.format(n)) | The matching complex of graphs on `n` vertices.
Fix an integer `n>0` and consider a set `V` of `n` vertices.
A 'partial matching' on `V` is a graph formed by edges so that
each vertex is in at most one edge. If `G` is a partial
matching, then so is any graph obtained by deleting edges from
`G`. T... | The matching complex of graphs on `n` vertices. | [
"The",
"matching",
"complex",
"of",
"graphs",
"on",
"n",
"vertices",
"."
] | def MatchingComplex(n):
"""
The matching complex of graphs on `n` vertices.
Fix an integer `n>0` and consider a set `V` of `n` vertices.
A 'partial matching' on `V` is a graph formed by edges so that
each vertex is in at most one edge. If `G` is a partial
matching, then so is any graph obtaine... | [
"def",
"MatchingComplex",
"(",
"n",
")",
":",
"G_vertices",
"=",
"Set",
"(",
"range",
"(",
"1",
",",
"n",
"+",
"1",
")",
")",
"facets",
"=",
"[",
"]",
"if",
"is_even",
"(",
"n",
")",
":",
"half",
"=",
"int",
"(",
"n",
"/",
"2",
")",
"half_n_s... | https://github.com/sagemath/sage/blob/f9b2db94f675ff16963ccdefba4f1a3393b3fe0d/src/sage/topology/simplicial_complex_examples.py#L1084-L1154 | |
django/djangosnippets.org | 0b273ce13135e157267009631d460835387d9975 | ratings/utils.py | python | sim_euclidean_distance | (ratings_queryset, factor_a, factor_b) | return 1 / (1 + sum_of_squares) | [] | def sim_euclidean_distance(ratings_queryset, factor_a, factor_b):
rating_model = ratings_queryset.model
if isinstance(factor_a, User):
filter_field = "user_id"
match_on = "hashed"
lookup_a = factor_a.pk
lookup_b = factor_b.pk
else:
filter_field = "hashed"
mat... | [
"def",
"sim_euclidean_distance",
"(",
"ratings_queryset",
",",
"factor_a",
",",
"factor_b",
")",
":",
"rating_model",
"=",
"ratings_queryset",
".",
"model",
"if",
"isinstance",
"(",
"factor_a",
",",
"User",
")",
":",
"filter_field",
"=",
"\"user_id\"",
"match_on",... | https://github.com/django/djangosnippets.org/blob/0b273ce13135e157267009631d460835387d9975/ratings/utils.py#L22-L76 | |||
hermanschaaf/mafan | c6ff629089cb1b69808620e3d6b95122585e3190 | mafan/text.py | python | is_chinese | (text) | return all([c in hanzidentifier.ALL_CHARS for c in text]) | u"""
Determine whether the entire string contains only Chinese characters.
This checks every character, so it is pretty slow - try to use only on
short sentences or words.
>>> is_chinese(u'這是麻煩啦')
True
>>> is_chinese(u'Hello,這是麻煩啦')
False
>>> is_chinese(u'♪')
False | u"""
Determine whether the entire string contains only Chinese characters.
This checks every character, so it is pretty slow - try to use only on
short sentences or words. | [
"u",
"Determine",
"whether",
"the",
"entire",
"string",
"contains",
"only",
"Chinese",
"characters",
".",
"This",
"checks",
"every",
"character",
"so",
"it",
"is",
"pretty",
"slow",
"-",
"try",
"to",
"use",
"only",
"on",
"short",
"sentences",
"or",
"words",
... | def is_chinese(text):
u"""
Determine whether the entire string contains only Chinese characters.
This checks every character, so it is pretty slow - try to use only on
short sentences or words.
>>> is_chinese(u'這是麻煩啦')
True
>>> is_chinese(u'Hello,這是麻煩啦')
False
>>> is_chinese(u'♪')
... | [
"def",
"is_chinese",
"(",
"text",
")",
":",
"return",
"all",
"(",
"[",
"c",
"in",
"hanzidentifier",
".",
"ALL_CHARS",
"for",
"c",
"in",
"text",
"]",
")"
] | https://github.com/hermanschaaf/mafan/blob/c6ff629089cb1b69808620e3d6b95122585e3190/mafan/text.py#L185-L198 | |
equinor/segyio | a98c2bc21d238de00b9b65be331d7a011d8a6372 | python/segyio/field.py | python | Field.binary | (cls, segy) | return Field(buf, kind='binary',
filehandle=segy.xfd,
readonly=segy.readonly,
).reload() | [] | def binary(cls, segy):
buf = bytearray(segyio._segyio.binsize())
return Field(buf, kind='binary',
filehandle=segy.xfd,
readonly=segy.readonly,
).reload() | [
"def",
"binary",
"(",
"cls",
",",
"segy",
")",
":",
"buf",
"=",
"bytearray",
"(",
"segyio",
".",
"_segyio",
".",
"binsize",
"(",
")",
")",
"return",
"Field",
"(",
"buf",
",",
"kind",
"=",
"'binary'",
",",
"filehandle",
"=",
"segy",
".",
"xfd",
",",... | https://github.com/equinor/segyio/blob/a98c2bc21d238de00b9b65be331d7a011d8a6372/python/segyio/field.py#L529-L534 | |||
intel/fMBT | a221c55cd7b6367aa458781b134ae155aa47a71f | utils3/fmbtwindows.py | python | ViewItem.expand | (self) | Expands a widget which supports this kind of operation, like a TreeView. | Expands a widget which supports this kind of operation, like a TreeView. | [
"Expands",
"a",
"widget",
"which",
"supports",
"this",
"kind",
"of",
"operation",
"like",
"a",
"TreeView",
"."
] | def expand(self):
"""
Expands a widget which supports this kind of operation, like a TreeView.
"""
self._checkUIautomation()
self._view._device._conn.sendExpand(self.id()) | [
"def",
"expand",
"(",
"self",
")",
":",
"self",
".",
"_checkUIautomation",
"(",
")",
"self",
".",
"_view",
".",
"_device",
".",
"_conn",
".",
"sendExpand",
"(",
"self",
".",
"id",
"(",
")",
")"
] | https://github.com/intel/fMBT/blob/a221c55cd7b6367aa458781b134ae155aa47a71f/utils3/fmbtwindows.py#L372-L377 | ||
huggingface/transformers | 623b4f7c63f60cce917677ee704d6c93ee960b4b | src/transformers/models/mobilebert/modeling_tf_mobilebert.py | python | TFMobileBertEmbeddings.build | (self, input_shape) | [] | def build(self, input_shape):
with tf.name_scope("word_embeddings"):
self.weight = self.add_weight(
name="weight",
shape=[self.vocab_size, self.embedding_size],
initializer=get_initializer(initializer_range=self.initializer_range),
)
... | [
"def",
"build",
"(",
"self",
",",
"input_shape",
")",
":",
"with",
"tf",
".",
"name_scope",
"(",
"\"word_embeddings\"",
")",
":",
"self",
".",
"weight",
"=",
"self",
".",
"add_weight",
"(",
"name",
"=",
"\"weight\"",
",",
"shape",
"=",
"[",
"self",
"."... | https://github.com/huggingface/transformers/blob/623b4f7c63f60cce917677ee704d6c93ee960b4b/src/transformers/models/mobilebert/modeling_tf_mobilebert.py#L133-L155 | ||||
Nuitka/Nuitka | 39262276993757fa4e299f497654065600453fc9 | nuitka/build/inline_copy/lib/scons-2.3.2/SCons/compat/_scons_sets.py | python | BaseSet.__and__ | (self, other) | return self.intersection(other) | Return the intersection of two sets as a new set.
(I.e. all elements that are in both sets.) | Return the intersection of two sets as a new set. | [
"Return",
"the",
"intersection",
"of",
"two",
"sets",
"as",
"a",
"new",
"set",
"."
] | def __and__(self, other):
"""Return the intersection of two sets as a new set.
(I.e. all elements that are in both sets.)
"""
if not isinstance(other, BaseSet):
return NotImplemented
return self.intersection(other) | [
"def",
"__and__",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"BaseSet",
")",
":",
"return",
"NotImplemented",
"return",
"self",
".",
"intersection",
"(",
"other",
")"
] | https://github.com/Nuitka/Nuitka/blob/39262276993757fa4e299f497654065600453fc9/nuitka/build/inline_copy/lib/scons-2.3.2/SCons/compat/_scons_sets.py#L194-L201 | |
Chaffelson/nipyapi | d3b186fd701ce308c2812746d98af9120955e810 | nipyapi/nifi/apis/reporting_tasks_api.py | python | ReportingTasksApi.get_verification_request_with_http_info | (self, id, request_id, **kwargs) | return self.api_client.call_api('/reporting-tasks/{id}/config/verification-requests/{requestId}', 'GET',
path_params,
query_params,
header_params,
body=body_par... | Returns the Verification Request with the given ID
Returns the Verification Request with the given ID. Once an Verification Request has been created, that request can subsequently be retrieved via this endpoint, and the request that is fetched will contain the updated state, such as percent complete, the curren... | Returns the Verification Request with the given ID
Returns the Verification Request with the given ID. Once an Verification Request has been created, that request can subsequently be retrieved via this endpoint, and the request that is fetched will contain the updated state, such as percent complete, the curren... | [
"Returns",
"the",
"Verification",
"Request",
"with",
"the",
"given",
"ID",
"Returns",
"the",
"Verification",
"Request",
"with",
"the",
"given",
"ID",
".",
"Once",
"an",
"Verification",
"Request",
"has",
"been",
"created",
"that",
"request",
"can",
"subsequently"... | def get_verification_request_with_http_info(self, id, request_id, **kwargs):
"""
Returns the Verification Request with the given ID
Returns the Verification Request with the given ID. Once an Verification Request has been created, that request can subsequently be retrieved via this endpoint, and... | [
"def",
"get_verification_request_with_http_info",
"(",
"self",
",",
"id",
",",
"request_id",
",",
"*",
"*",
"kwargs",
")",
":",
"all_params",
"=",
"[",
"'id'",
",",
"'request_id'",
"]",
"all_params",
".",
"append",
"(",
"'callback'",
")",
"all_params",
".",
... | https://github.com/Chaffelson/nipyapi/blob/d3b186fd701ce308c2812746d98af9120955e810/nipyapi/nifi/apis/reporting_tasks_api.py#L727-L811 | |
SebKuzminsky/pycam | 55e3129f518e470040e79bb00515b4bfcf36c172 | pycam/Utils/FontCache.py | python | FontCache.get_font_names | (self) | return self.fonts.keys() | [] | def get_font_names(self):
self._load_all_files()
return self.fonts.keys() | [
"def",
"get_font_names",
"(",
"self",
")",
":",
"self",
".",
"_load_all_files",
"(",
")",
"return",
"self",
".",
"fonts",
".",
"keys",
"(",
")"
] | https://github.com/SebKuzminsky/pycam/blob/55e3129f518e470040e79bb00515b4bfcf36c172/pycam/Utils/FontCache.py#L73-L75 | |||
SpikeKing/DL-Project-Template | b8f16954140007880761d0920f69ed5270f4a688 | utils/utils.py | python | invert_dict | (d) | return dict((v, k) for k, v in d.iteritems()) | 当字典的元素不重复时, 反转字典
:param d: 字典
:return: 反转后的字典 | 当字典的元素不重复时, 反转字典
:param d: 字典
:return: 反转后的字典 | [
"当字典的元素不重复时",
"反转字典",
":",
"param",
"d",
":",
"字典",
":",
"return",
":",
"反转后的字典"
] | def invert_dict(d):
"""
当字典的元素不重复时, 反转字典
:param d: 字典
:return: 反转后的字典
"""
return dict((v, k) for k, v in d.iteritems()) | [
"def",
"invert_dict",
"(",
"d",
")",
":",
"return",
"dict",
"(",
"(",
"v",
",",
"k",
")",
"for",
"k",
",",
"v",
"in",
"d",
".",
"iteritems",
"(",
")",
")"
] | https://github.com/SpikeKing/DL-Project-Template/blob/b8f16954140007880761d0920f69ed5270f4a688/utils/utils.py#L245-L251 | |
IronLanguages/ironpython3 | 7a7bb2a872eeab0d1009fc8a6e24dca43f65b693 | Src/StdLib/Lib/ftplib.py | python | FTP.delete | (self, filename) | Delete a file. | Delete a file. | [
"Delete",
"a",
"file",
"."
] | def delete(self, filename):
'''Delete a file.'''
resp = self.sendcmd('DELE ' + filename)
if resp[:3] in {'250', '200'}:
return resp
else:
raise error_reply(resp) | [
"def",
"delete",
"(",
"self",
",",
"filename",
")",
":",
"resp",
"=",
"self",
".",
"sendcmd",
"(",
"'DELE '",
"+",
"filename",
")",
"if",
"resp",
"[",
":",
"3",
"]",
"in",
"{",
"'250'",
",",
"'200'",
"}",
":",
"return",
"resp",
"else",
":",
"rais... | https://github.com/IronLanguages/ironpython3/blob/7a7bb2a872eeab0d1009fc8a6e24dca43f65b693/Src/StdLib/Lib/ftplib.py#L613-L619 | ||
nccgroup/featherduster | 9229158e601be2e47b60f41bc862f38b12b162a3 | cryptanalib/helpers.py | python | show_histogram | (frequency_table, width=80, sort=True) | Take a frequency distribution, such as one generated by
generate_frequency_table() and represent it as a histogram with the
specified width in characters
frequency_table - A frequency distribution
width - The width in characters for the histogram
sort - (bool) Sort the histogram by frequency value? | Take a frequency distribution, such as one generated by
generate_frequency_table() and represent it as a histogram with the
specified width in characters | [
"Take",
"a",
"frequency",
"distribution",
"such",
"as",
"one",
"generated",
"by",
"generate_frequency_table",
"()",
"and",
"represent",
"it",
"as",
"a",
"histogram",
"with",
"the",
"specified",
"width",
"in",
"characters"
] | def show_histogram(frequency_table, width=80, sort=True):
'''
Take a frequency distribution, such as one generated by
generate_frequency_table() and represent it as a histogram with the
specified width in characters
frequency_table - A frequency distribution
width - The width in characters for the hi... | [
"def",
"show_histogram",
"(",
"frequency_table",
",",
"width",
"=",
"80",
",",
"sort",
"=",
"True",
")",
":",
"max_value",
"=",
"max",
"(",
"frequency_table",
".",
"values",
"(",
")",
")",
"normalizing_multiplier",
"=",
"width",
"/",
"max_value",
"if",
"so... | https://github.com/nccgroup/featherduster/blob/9229158e601be2e47b60f41bc862f38b12b162a3/cryptanalib/helpers.py#L103-L127 | ||
matplotlib/matplotlib | 8d7a2b9d2a38f01ee0d6802dd4f9e98aec812322 | lib/matplotlib/backend_bases.py | python | FigureCanvasBase.mpl_connect | (self, s, func) | return self.callbacks.connect(s, func) | Bind function *func* to event *s*.
Parameters
----------
s : str
One of the following events ids:
- 'button_press_event'
- 'button_release_event'
- 'draw_event'
- 'key_press_event'
- 'key_release_event'
- 'moti... | Bind function *func* to event *s*. | [
"Bind",
"function",
"*",
"func",
"*",
"to",
"event",
"*",
"s",
"*",
"."
] | def mpl_connect(self, s, func):
"""
Bind function *func* to event *s*.
Parameters
----------
s : str
One of the following events ids:
- 'button_press_event'
- 'button_release_event'
- 'draw_event'
- 'key_press_event'
... | [
"def",
"mpl_connect",
"(",
"self",
",",
"s",
",",
"func",
")",
":",
"return",
"self",
".",
"callbacks",
".",
"connect",
"(",
"s",
",",
"func",
")"
] | https://github.com/matplotlib/matplotlib/blob/8d7a2b9d2a38f01ee0d6802dd4f9e98aec812322/lib/matplotlib/backend_bases.py#L2333-L2386 | |
wiseman/mavelous | eef41c096cc282bb3acd33a747146a88d2bd1eee | modules/sensors.py | python | cmd_sensors | (args) | show key sensors | show key sensors | [
"show",
"key",
"sensors"
] | def cmd_sensors(args):
'''show key sensors'''
if mpstate.master().WIRE_PROTOCOL_VERSION == '1.0':
gps_heading = mpstate.status.msgs['GPS_RAW_INT'].cog * 0.01
else:
gps_heading = mpstate.status.msgs['GPS_RAW'].hdg
mpstate.console.writeln("heading: %u/%u alt: %u/%u r/p: %u/%u s... | [
"def",
"cmd_sensors",
"(",
"args",
")",
":",
"if",
"mpstate",
".",
"master",
"(",
")",
".",
"WIRE_PROTOCOL_VERSION",
"==",
"'1.0'",
":",
"gps_heading",
"=",
"mpstate",
".",
"status",
".",
"msgs",
"[",
"'GPS_RAW_INT'",
"]",
".",
"cog",
"*",
"0.01",
"else"... | https://github.com/wiseman/mavelous/blob/eef41c096cc282bb3acd33a747146a88d2bd1eee/modules/sensors.py#L34-L50 | ||
pculture/mirovideoconverter3 | 27efad91845c8ae544dc27034adb0d3e18ca8f1f | helperscripts/windows-virtualenv/virtualenv.py | python | create_environment | (home_dir, site_packages=False, clear=False,
unzip_setuptools=False, use_distribute=False,
prompt=None, search_dirs=None, never_download=False) | Creates a new environment in ``home_dir``.
If ``site_packages`` is true, then the global ``site-packages/``
directory will be on the path.
If ``clear`` is true (default False) then the environment will
first be cleared. | Creates a new environment in ``home_dir``. | [
"Creates",
"a",
"new",
"environment",
"in",
"home_dir",
"."
] | def create_environment(home_dir, site_packages=False, clear=False,
unzip_setuptools=False, use_distribute=False,
prompt=None, search_dirs=None, never_download=False):
"""
Creates a new environment in ``home_dir``.
If ``site_packages`` is true, then the global `... | [
"def",
"create_environment",
"(",
"home_dir",
",",
"site_packages",
"=",
"False",
",",
"clear",
"=",
"False",
",",
"unzip_setuptools",
"=",
"False",
",",
"use_distribute",
"=",
"False",
",",
"prompt",
"=",
"None",
",",
"search_dirs",
"=",
"None",
",",
"never... | https://github.com/pculture/mirovideoconverter3/blob/27efad91845c8ae544dc27034adb0d3e18ca8f1f/helperscripts/windows-virtualenv/virtualenv.py#L1013-L1044 | ||
AppScale/gts | 46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9 | AppServer/lib/django-1.3/django/db/transaction.py | python | savepoint_commit | (sid, using=None) | Commits the most recent savepoint (if one exists). Does nothing if
savepoints are not supported. | Commits the most recent savepoint (if one exists). Does nothing if
savepoints are not supported. | [
"Commits",
"the",
"most",
"recent",
"savepoint",
"(",
"if",
"one",
"exists",
")",
".",
"Does",
"nothing",
"if",
"savepoints",
"are",
"not",
"supported",
"."
] | def savepoint_commit(sid, using=None):
"""
Commits the most recent savepoint (if one exists). Does nothing if
savepoints are not supported.
"""
if using is None:
using = DEFAULT_DB_ALIAS
connection = connections[using]
connection.savepoint_commit(sid) | [
"def",
"savepoint_commit",
"(",
"sid",
",",
"using",
"=",
"None",
")",
":",
"if",
"using",
"is",
"None",
":",
"using",
"=",
"DEFAULT_DB_ALIAS",
"connection",
"=",
"connections",
"[",
"using",
"]",
"connection",
".",
"savepoint_commit",
"(",
"sid",
")"
] | https://github.com/AppScale/gts/blob/46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9/AppServer/lib/django-1.3/django/db/transaction.py#L174-L182 | ||
frerich/clcache | cae73d8255d78db8ba11e23c51fd2c9a89e7475b | clcache/__main__.py | python | filterSourceFiles | (cmdLine: List[str], sourceFiles: List[Tuple[str, str]]) | [] | def filterSourceFiles(cmdLine: List[str], sourceFiles: List[Tuple[str, str]]) -> Iterator[str]:
setOfSources = set(sourceFile for sourceFile, _ in sourceFiles)
skippedArgs = ('/Tc', '/Tp', '-Tp', '-Tc')
yield from (
arg for arg in cmdLine
if not (arg in setOfSources or arg.startswith(skipped... | [
"def",
"filterSourceFiles",
"(",
"cmdLine",
":",
"List",
"[",
"str",
"]",
",",
"sourceFiles",
":",
"List",
"[",
"Tuple",
"[",
"str",
",",
"str",
"]",
"]",
")",
"->",
"Iterator",
"[",
"str",
"]",
":",
"setOfSources",
"=",
"set",
"(",
"sourceFile",
"fo... | https://github.com/frerich/clcache/blob/cae73d8255d78db8ba11e23c51fd2c9a89e7475b/clcache/__main__.py#L1681-L1687 | ||||
golismero/golismero | 7d605b937e241f51c1ca4f47b20f755eeefb9d76 | thirdparty_libs/django/http/response.py | python | HttpResponseBase._convert_to_charset | (self, value, charset, mime_encode=False) | return value | Converts headers key/value to ascii/latin1 native strings.
`charset` must be 'ascii' or 'latin-1'. If `mime_encode` is True and
`value` value can't be represented in the given charset, MIME-encoding
is applied. | Converts headers key/value to ascii/latin1 native strings. | [
"Converts",
"headers",
"key",
"/",
"value",
"to",
"ascii",
"/",
"latin1",
"native",
"strings",
"."
] | def _convert_to_charset(self, value, charset, mime_encode=False):
"""Converts headers key/value to ascii/latin1 native strings.
`charset` must be 'ascii' or 'latin-1'. If `mime_encode` is True and
`value` value can't be represented in the given charset, MIME-encoding
is applied.
... | [
"def",
"_convert_to_charset",
"(",
"self",
",",
"value",
",",
"charset",
",",
"mime_encode",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"(",
"bytes",
",",
"six",
".",
"text_type",
")",
")",
":",
"value",
"=",
"str",
"(",
"v... | https://github.com/golismero/golismero/blob/7d605b937e241f51c1ca4f47b20f755eeefb9d76/thirdparty_libs/django/http/response.py#L73-L106 | |
viewfinderco/viewfinder | 453845b5d64ab5b3b826c08b02546d1ca0a07c14 | marketing/tornado/ioloop.py | python | IOLoop.current | () | return current | Returns the current thread's `IOLoop`.
If an `IOLoop` is currently running or has been marked as current
by `make_current`, returns that instance. Otherwise returns
`IOLoop.instance()`, i.e. the main thread's `IOLoop`.
A common pattern for classes that depend on ``IOLoops`` is to use
... | Returns the current thread's `IOLoop`. | [
"Returns",
"the",
"current",
"thread",
"s",
"IOLoop",
"."
] | def current():
"""Returns the current thread's `IOLoop`.
If an `IOLoop` is currently running or has been marked as current
by `make_current`, returns that instance. Otherwise returns
`IOLoop.instance()`, i.e. the main thread's `IOLoop`.
A common pattern for classes that depend... | [
"def",
"current",
"(",
")",
":",
"current",
"=",
"getattr",
"(",
"IOLoop",
".",
"_current",
",",
"\"instance\"",
",",
"None",
")",
"if",
"current",
"is",
"None",
":",
"return",
"IOLoop",
".",
"instance",
"(",
")",
"return",
"current"
] | https://github.com/viewfinderco/viewfinder/blob/453845b5d64ab5b3b826c08b02546d1ca0a07c14/marketing/tornado/ioloop.py#L157-L180 | |
plotly/plotly.py | cfad7862594b35965c0e000813bd7805e8494a5b | packages/python/plotly/plotly/graph_objs/mesh3d/_colorbar.py | python | ColorBar.separatethousands | (self) | return self["separatethousands"] | If "true", even 4-digit integers are separated
The 'separatethousands' property must be specified as a bool
(either True, or False)
Returns
-------
bool | If "true", even 4-digit integers are separated
The 'separatethousands' property must be specified as a bool
(either True, or False) | [
"If",
"true",
"even",
"4",
"-",
"digit",
"integers",
"are",
"separated",
"The",
"separatethousands",
"property",
"must",
"be",
"specified",
"as",
"a",
"bool",
"(",
"either",
"True",
"or",
"False",
")"
] | def separatethousands(self):
"""
If "true", even 4-digit integers are separated
The 'separatethousands' property must be specified as a bool
(either True, or False)
Returns
-------
bool
"""
return self["separatethousands"] | [
"def",
"separatethousands",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"separatethousands\"",
"]"
] | https://github.com/plotly/plotly.py/blob/cfad7862594b35965c0e000813bd7805e8494a5b/packages/python/plotly/plotly/graph_objs/mesh3d/_colorbar.py#L455-L466 | |
sabri-zaki/EasY_HaCk | 2a39ac384dd0d6fc51c0dd22e8d38cece683fdb9 | .modules/.metagoofil/hachoir_core/bits.py | python | _createStructFormat | () | return format | Create a dictionnary (endian, size_byte) => struct format used
by str2long() to convert raw data to positive integer. | Create a dictionnary (endian, size_byte) => struct format used
by str2long() to convert raw data to positive integer. | [
"Create",
"a",
"dictionnary",
"(",
"endian",
"size_byte",
")",
"=",
">",
"struct",
"format",
"used",
"by",
"str2long",
"()",
"to",
"convert",
"raw",
"data",
"to",
"positive",
"integer",
"."
] | def _createStructFormat():
"""
Create a dictionnary (endian, size_byte) => struct format used
by str2long() to convert raw data to positive integer.
"""
format = {
BIG_ENDIAN: {},
LITTLE_ENDIAN: {},
}
for struct_format in "BHILQ":
try:
size = calcsize(s... | [
"def",
"_createStructFormat",
"(",
")",
":",
"format",
"=",
"{",
"BIG_ENDIAN",
":",
"{",
"}",
",",
"LITTLE_ENDIAN",
":",
"{",
"}",
",",
"}",
"for",
"struct_format",
"in",
"\"BHILQ\"",
":",
"try",
":",
"size",
"=",
"calcsize",
"(",
"struct_format",
")",
... | https://github.com/sabri-zaki/EasY_HaCk/blob/2a39ac384dd0d6fc51c0dd22e8d38cece683fdb9/.modules/.metagoofil/hachoir_core/bits.py#L248-L264 | |
uber/doubles | 15e68dcf98f709b19a581915fa6af5ef49ebdd8a | doubles/method_double.py | python | MethodDouble._find_matching_double | (self, args, kwargs) | Returns the first matching expectation or allowance.
Returns the first allowance or expectation that matches the ones declared. Tries one
with specific arguments first, then falls back to an expectation that allows arbitrary
arguments.
:return: The matching ``Allowance`` or ``Expectati... | Returns the first matching expectation or allowance. | [
"Returns",
"the",
"first",
"matching",
"expectation",
"or",
"allowance",
"."
] | def _find_matching_double(self, args, kwargs):
"""Returns the first matching expectation or allowance.
Returns the first allowance or expectation that matches the ones declared. Tries one
with specific arguments first, then falls back to an expectation that allows arbitrary
arguments.
... | [
"def",
"_find_matching_double",
"(",
"self",
",",
"args",
",",
"kwargs",
")",
":",
"expectation",
"=",
"self",
".",
"_find_matching_expectation",
"(",
"args",
",",
"kwargs",
")",
"if",
"expectation",
":",
"return",
"expectation",
"allowance",
"=",
"self",
".",... | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/method_double.py#L90-L109 | ||
daoluan/decode-Django | d46a858b45b56de48b0355f50dd9e45402d04cfd | Django-1.5.1/django/contrib/gis/gdal/datasource.py | python | DataSource.__str__ | (self) | return '%s (%s)' % (self.name, str(self.driver)) | Returns OGR GetName and Driver for the Data Source. | Returns OGR GetName and Driver for the Data Source. | [
"Returns",
"OGR",
"GetName",
"and",
"Driver",
"for",
"the",
"Data",
"Source",
"."
] | def __str__(self):
"Returns OGR GetName and Driver for the Data Source."
return '%s (%s)' % (self.name, str(self.driver)) | [
"def",
"__str__",
"(",
"self",
")",
":",
"return",
"'%s (%s)'",
"%",
"(",
"self",
".",
"name",
",",
"str",
"(",
"self",
".",
"driver",
")",
")"
] | https://github.com/daoluan/decode-Django/blob/d46a858b45b56de48b0355f50dd9e45402d04cfd/Django-1.5.1/django/contrib/gis/gdal/datasource.py#L122-L124 | |
maxhumber/gazpacho | 49d8258908729b67e4189a339e1b4c99dd003778 | gazpacho/soup2.py | python | Soup._handle_start | (self, tag, attrs) | [] | def _handle_start(self, tag, attrs):
html, attrs_dict = recover_html_and_attrs(tag, attrs)
query_attrs = {} if not self.attrs else self.attrs
matching = match(query_attrs, attrs_dict, partial=self._partial)
if (tag == self.tag) and (matching) and (not self._active):
self._gr... | [
"def",
"_handle_start",
"(",
"self",
",",
"tag",
",",
"attrs",
")",
":",
"html",
",",
"attrs_dict",
"=",
"recover_html_and_attrs",
"(",
"tag",
",",
"attrs",
")",
"query_attrs",
"=",
"{",
"}",
"if",
"not",
"self",
".",
"attrs",
"else",
"self",
".",
"att... | https://github.com/maxhumber/gazpacho/blob/49d8258908729b67e4189a339e1b4c99dd003778/gazpacho/soup2.py#L85-L100 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.