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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
stopstalk/stopstalk-deployment | 10c3ab44c4ece33ae515f6888c15033db2004bb1 | aws_lambda/spoj_aws_lambda_function/lambda_code/pip/_vendor/urllib3/connectionpool.py | python | HTTPConnectionPool._make_request | (self, conn, method, url, timeout=_Default, chunked=False,
**httplib_request_kw) | return httplib_response | Perform a request on a given urllib connection object taken from our
pool.
:param conn:
a connection from one of our connection pools
:param timeout:
Socket timeout in seconds for the request. This can be a
float or integer, which will set the same timeout v... | Perform a request on a given urllib connection object taken from our
pool. | [
"Perform",
"a",
"request",
"on",
"a",
"given",
"urllib",
"connection",
"object",
"taken",
"from",
"our",
"pool",
"."
] | def _make_request(self, conn, method, url, timeout=_Default, chunked=False,
**httplib_request_kw):
"""
Perform a request on a given urllib connection object taken from our
pool.
:param conn:
a connection from one of our connection pools
:param ... | [
"def",
"_make_request",
"(",
"self",
",",
"conn",
",",
"method",
",",
"url",
",",
"timeout",
"=",
"_Default",
",",
"chunked",
"=",
"False",
",",
"*",
"*",
"httplib_request_kw",
")",
":",
"self",
".",
"num_requests",
"+=",
"1",
"timeout_obj",
"=",
"self",... | https://github.com/stopstalk/stopstalk-deployment/blob/10c3ab44c4ece33ae515f6888c15033db2004bb1/aws_lambda/spoj_aws_lambda_function/lambda_code/pip/_vendor/urllib3/connectionpool.py#L319-L402 | |
learnables/cherry | 80e78f8bb53c2e6bb8eece0ba74122e5d6d6216f | cherry/pg.py | python | generalized_advantage | (gamma,
tau,
rewards,
dones,
values,
next_value) | return advantages | **Description**
Computes the generalized advantage estimator. (GAE)
**References**
1. Schulman et al. 2015. “High-Dimensional Continuous Control Using Generalized Advantage Estimation”
2. https://github.com/joschu/modular_rl/blob/master/modular_rl/core.py#L49
**Arguments**
* **gamma** (floa... | **Description** | [
"**",
"Description",
"**"
] | def generalized_advantage(gamma,
tau,
rewards,
dones,
values,
next_value):
"""
**Description**
Computes the generalized advantage estimator. (GAE)
**References**
1. Sc... | [
"def",
"generalized_advantage",
"(",
"gamma",
",",
"tau",
",",
"rewards",
",",
"dones",
",",
"values",
",",
"next_value",
")",
":",
"rewards",
"=",
"_reshape_helper",
"(",
"rewards",
")",
"dones",
"=",
"_reshape_helper",
"(",
"dones",
")",
"values",
"=",
"... | https://github.com/learnables/cherry/blob/80e78f8bb53c2e6bb8eece0ba74122e5d6d6216f/cherry/pg.py#L15-L69 | |
JulianEberius/SublimePythonIDE | d70e40abc0c9f347af3204c7b910e0d6bfd6e459 | server/lib/python2/rope/refactor/suites.py | python | find_visible | (node, lines) | return find_visible_for_suite(root, lines) | Return the line which is visible from all `lines` | Return the line which is visible from all `lines` | [
"Return",
"the",
"line",
"which",
"is",
"visible",
"from",
"all",
"lines"
] | def find_visible(node, lines):
"""Return the line which is visible from all `lines`"""
root = ast_suite_tree(node)
return find_visible_for_suite(root, lines) | [
"def",
"find_visible",
"(",
"node",
",",
"lines",
")",
":",
"root",
"=",
"ast_suite_tree",
"(",
"node",
")",
"return",
"find_visible_for_suite",
"(",
"root",
",",
"lines",
")"
] | https://github.com/JulianEberius/SublimePythonIDE/blob/d70e40abc0c9f347af3204c7b910e0d6bfd6e459/server/lib/python2/rope/refactor/suites.py#L4-L7 | |
Chaffelson/nipyapi | d3b186fd701ce308c2812746d98af9120955e810 | nipyapi/nifi/models/process_group_name_dto.py | python | ProcessGroupNameDTO.__ne__ | (self, other) | return not self == other | Returns true if both objects are not equal | Returns true if both objects are not equal | [
"Returns",
"true",
"if",
"both",
"objects",
"are",
"not",
"equal"
] | def __ne__(self, other):
"""
Returns true if both objects are not equal
"""
return not self == other | [
"def",
"__ne__",
"(",
"self",
",",
"other",
")",
":",
"return",
"not",
"self",
"==",
"other"
] | https://github.com/Chaffelson/nipyapi/blob/d3b186fd701ce308c2812746d98af9120955e810/nipyapi/nifi/models/process_group_name_dto.py#L149-L153 | |
zhl2008/awd-platform | 0416b31abea29743387b10b3914581fbe8e7da5e | web_flaskbb/Python-2.7.9/Demo/metaclasses/Trace.py | python | NotTracingWrapper.__call__ | (self, *args, **kw) | return apply(self.func, (self.inst,) + args, kw) | [] | def __call__(self, *args, **kw):
return apply(self.func, (self.inst,) + args, kw) | [
"def",
"__call__",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"return",
"apply",
"(",
"self",
".",
"func",
",",
"(",
"self",
".",
"inst",
",",
")",
"+",
"args",
",",
"kw",
")"
] | https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/Python-2.7.9/Demo/metaclasses/Trace.py#L87-L88 | |||
django-extensions/django-extensions | f67ff680cd6d7264cdce05309b537ac2e1ee4a70 | django_extensions/management/commands/graph_models.py | python | Command.render_output_pydot | (self, dotdata, **kwargs) | Render model data as image using pydot. | Render model data as image using pydot. | [
"Render",
"model",
"data",
"as",
"image",
"using",
"pydot",
"."
] | def render_output_pydot(self, dotdata, **kwargs):
"""Render model data as image using pydot."""
if not HAS_PYDOT:
raise CommandError("You need to install pydot python module")
graph = pydot.graph_from_dot_data(dotdata)
if not graph:
raise CommandError("pydot retu... | [
"def",
"render_output_pydot",
"(",
"self",
",",
"dotdata",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"HAS_PYDOT",
":",
"raise",
"CommandError",
"(",
"\"You need to install pydot python module\"",
")",
"graph",
"=",
"pydot",
".",
"graph_from_dot_data",
"(",
... | https://github.com/django-extensions/django-extensions/blob/f67ff680cd6d7264cdce05309b537ac2e1ee4a70/django_extensions/management/commands/graph_models.py#L310-L333 | ||
pycontribs/pyrax | a0c022981f76a4cba96a22ecc19bb52843ac4fbe | pyrax/image.py | python | ImageClient.add_image_tag | (self, img, tag) | return img.add_tag(tag) | Adds the tag to the specified image. | Adds the tag to the specified image. | [
"Adds",
"the",
"tag",
"to",
"the",
"specified",
"image",
"."
] | def add_image_tag(self, img, tag):
"""
Adds the tag to the specified image.
"""
return img.add_tag(tag) | [
"def",
"add_image_tag",
"(",
"self",
",",
"img",
",",
"tag",
")",
":",
"return",
"img",
".",
"add_tag",
"(",
"tag",
")"
] | https://github.com/pycontribs/pyrax/blob/a0c022981f76a4cba96a22ecc19bb52843ac4fbe/pyrax/image.py#L641-L645 | |
architv/chcli | e9e387b9a85c6b64bc74b1a7c5b85baa4d4ea7d7 | challenges/writers.py | python | write_contest_header | (contest_type) | Prints the header for the type of contest | Prints the header for the type of contest | [
"Prints",
"the",
"header",
"for",
"the",
"type",
"of",
"contest"
] | def write_contest_header(contest_type):
"""Prints the header for the type of contest"""
if contest_type == challenge().ACTIVE:
click.secho("%-3s %-50s %-20s %-11s %-15s" %
("NO.", "NAME", "ENDS IN", "DURATION", "PLATFORM"))
elif contest_type == challenge().UPCOMING:
click.secho("%-3s %-50s... | [
"def",
"write_contest_header",
"(",
"contest_type",
")",
":",
"if",
"contest_type",
"==",
"challenge",
"(",
")",
".",
"ACTIVE",
":",
"click",
".",
"secho",
"(",
"\"%-3s %-50s %-20s %-11s %-15s\"",
"%",
"(",
"\"NO.\"",
",",
"\"NAME\"",
",",
"\"ENDS IN\"",... | https://github.com/architv/chcli/blob/e9e387b9a85c6b64bc74b1a7c5b85baa4d4ea7d7/challenges/writers.py#L75-L85 | ||
saltstack/salt | fae5bc757ad0f1716483ce7ae180b451545c2058 | salt/pillar/etcd_pillar.py | python | __virtual__ | () | return __virtualname__ if HAS_LIBS else False | Only return if python-etcd is installed | Only return if python-etcd is installed | [
"Only",
"return",
"if",
"python",
"-",
"etcd",
"is",
"installed"
] | def __virtual__():
"""
Only return if python-etcd is installed
"""
return __virtualname__ if HAS_LIBS else False | [
"def",
"__virtual__",
"(",
")",
":",
"return",
"__virtualname__",
"if",
"HAS_LIBS",
"else",
"False"
] | https://github.com/saltstack/salt/blob/fae5bc757ad0f1716483ce7ae180b451545c2058/salt/pillar/etcd_pillar.py#L76-L80 | |
kuri65536/python-for-android | 26402a08fc46b09ef94e8d7a6bbc3a54ff9d0891 | python-modules/twisted/twisted/lore/tree.py | python | getHeaders | (document) | return domhelpers.findElements(
document,
lambda n, m=re.compile('h[23]$').match: m(n.nodeName)) | Return all H2 and H3 nodes in the given document.
@type document: A DOM Node or Document
@rtype: C{list} | Return all H2 and H3 nodes in the given document. | [
"Return",
"all",
"H2",
"and",
"H3",
"nodes",
"in",
"the",
"given",
"document",
"."
] | def getHeaders(document):
"""
Return all H2 and H3 nodes in the given document.
@type document: A DOM Node or Document
@rtype: C{list}
"""
return domhelpers.findElements(
document,
lambda n, m=re.compile('h[23]$').match: m(n.nodeName)) | [
"def",
"getHeaders",
"(",
"document",
")",
":",
"return",
"domhelpers",
".",
"findElements",
"(",
"document",
",",
"lambda",
"n",
",",
"m",
"=",
"re",
".",
"compile",
"(",
"'h[23]$'",
")",
".",
"match",
":",
"m",
"(",
"n",
".",
"nodeName",
")",
")"
] | https://github.com/kuri65536/python-for-android/blob/26402a08fc46b09ef94e8d7a6bbc3a54ff9d0891/python-modules/twisted/twisted/lore/tree.py#L308-L318 | |
PyHDI/veriloggen | 2382d200deabf59cfcfd741f5eba371010aaf2bb | veriloggen/types/fixed.py | python | _FixedVariable.assign | (self, value) | return vtypes._Variable.assign(self, v) | [] | def assign(self, value):
v = self._adjust(value)
return vtypes._Variable.assign(self, v) | [
"def",
"assign",
"(",
"self",
",",
"value",
")",
":",
"v",
"=",
"self",
".",
"_adjust",
"(",
"value",
")",
"return",
"vtypes",
".",
"_Variable",
".",
"assign",
"(",
"self",
",",
"v",
")"
] | https://github.com/PyHDI/veriloggen/blob/2382d200deabf59cfcfd741f5eba371010aaf2bb/veriloggen/types/fixed.py#L395-L397 | |||
openstack/solum | 93f8cc562d3c2ea0ab3af4061c07348e61f30806 | solum/deployer/handlers/heat.py | python | Handler._parse_server_ip | (self, heat_output) | return None | Parse server ip from heat-stack-show output. | Parse server ip from heat-stack-show output. | [
"Parse",
"server",
"ip",
"from",
"heat",
"-",
"stack",
"-",
"show",
"output",
"."
] | def _parse_server_ip(self, heat_output):
"""Parse server ip from heat-stack-show output."""
if 'outputs' in heat_output._info:
for outputs in heat_output._info['outputs']:
if outputs['output_key'] == 'public_ip':
return outputs['output_value']
retu... | [
"def",
"_parse_server_ip",
"(",
"self",
",",
"heat_output",
")",
":",
"if",
"'outputs'",
"in",
"heat_output",
".",
"_info",
":",
"for",
"outputs",
"in",
"heat_output",
".",
"_info",
"[",
"'outputs'",
"]",
":",
"if",
"outputs",
"[",
"'output_key'",
"]",
"==... | https://github.com/openstack/solum/blob/93f8cc562d3c2ea0ab3af4061c07348e61f30806/solum/deployer/handlers/heat.py#L767-L773 | |
khanhnamle1994/natural-language-processing | 01d450d5ac002b0156ef4cf93a07cb508c1bcdc5 | assignment1/.env/lib/python2.7/site-packages/jinja2/lexer.py | python | describe_token | (token) | return _describe_token_type(token.type) | Returns a description of the token. | Returns a description of the token. | [
"Returns",
"a",
"description",
"of",
"the",
"token",
"."
] | def describe_token(token):
"""Returns a description of the token."""
if token.type == 'name':
return token.value
return _describe_token_type(token.type) | [
"def",
"describe_token",
"(",
"token",
")",
":",
"if",
"token",
".",
"type",
"==",
"'name'",
":",
"return",
"token",
".",
"value",
"return",
"_describe_token_type",
"(",
"token",
".",
"type",
")"
] | https://github.com/khanhnamle1994/natural-language-processing/blob/01d450d5ac002b0156ef4cf93a07cb508c1bcdc5/assignment1/.env/lib/python2.7/site-packages/jinja2/lexer.py#L164-L168 | |
IronLanguages/ironpython3 | 7a7bb2a872eeab0d1009fc8a6e24dca43f65b693 | Src/StdLib/Lib/imp.py | python | find_module | (name, path=None) | return file, file_path, (suffix, mode, type_) | **DEPRECATED**
Search for a module.
If path is omitted or None, search for a built-in, frozen or special
module and continue search in sys.path. The module name cannot
contain '.'; to search for a submodule of a package, pass the
submodule name and the package's __path__. | **DEPRECATED** | [
"**",
"DEPRECATED",
"**"
] | def find_module(name, path=None):
"""**DEPRECATED**
Search for a module.
If path is omitted or None, search for a built-in, frozen or special
module and continue search in sys.path. The module name cannot
contain '.'; to search for a submodule of a package, pass the
submodule name and the pack... | [
"def",
"find_module",
"(",
"name",
",",
"path",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"name",
",",
"str",
")",
":",
"raise",
"TypeError",
"(",
"\"'name' must be a str, not {}\"",
".",
"format",
"(",
"type",
"(",
"name",
")",
")",
")",
... | https://github.com/IronLanguages/ironpython3/blob/7a7bb2a872eeab0d1009fc8a6e24dca43f65b693/Src/StdLib/Lib/imp.py#L255-L304 | |
bruderstein/PythonScript | df9f7071ddf3a079e3a301b9b53a6dc78cf1208f | PythonLib/full/xml/etree/ElementTree.py | python | ProcessingInstruction | (target, text=None) | return element | Processing Instruction element factory.
This function creates a special element which the standard serializer
serializes as an XML comment.
*target* is a string containing the processing instruction, *text* is a
string containing the processing instruction contents, if any. | Processing Instruction element factory. | [
"Processing",
"Instruction",
"element",
"factory",
"."
] | def ProcessingInstruction(target, text=None):
"""Processing Instruction element factory.
This function creates a special element which the standard serializer
serializes as an XML comment.
*target* is a string containing the processing instruction, *text* is a
string containing the processing inst... | [
"def",
"ProcessingInstruction",
"(",
"target",
",",
"text",
"=",
"None",
")",
":",
"element",
"=",
"Element",
"(",
"ProcessingInstruction",
")",
"element",
".",
"text",
"=",
"target",
"if",
"text",
":",
"element",
".",
"text",
"=",
"element",
".",
"text",
... | https://github.com/bruderstein/PythonScript/blob/df9f7071ddf3a079e3a301b9b53a6dc78cf1208f/PythonLib/full/xml/etree/ElementTree.py#L458-L472 | |
saltstack/salt | fae5bc757ad0f1716483ce7ae180b451545c2058 | salt/cloud/clouds/virtualbox.py | python | start | (name, call=None) | return treat_machine_dict(machine) | Start a machine.
@param name: Machine to start
@type name: str
@param call: Must be "action"
@type call: str | Start a machine. | [
"Start",
"a",
"machine",
"."
] | def start(name, call=None):
"""
Start a machine.
@param name: Machine to start
@type name: str
@param call: Must be "action"
@type call: str
"""
if call != "action":
raise SaltCloudSystemExit(
"The instance action must be called with -a or --action."
)
lo... | [
"def",
"start",
"(",
"name",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"!=",
"\"action\"",
":",
"raise",
"SaltCloudSystemExit",
"(",
"\"The instance action must be called with -a or --action.\"",
")",
"log",
".",
"info",
"(",
"\"Starting machine: %s\"",
",",... | https://github.com/saltstack/salt/blob/fae5bc757ad0f1716483ce7ae180b451545c2058/salt/cloud/clouds/virtualbox.py#L393-L410 | |
wecatch/app-turbo | d3b931db1b0f210d8af1da109edbf88756fa427d | turbo/util.py | python | camel_to_underscore | (name) | return ''.join(as_list) | convert CamelCase style to under_score_case | convert CamelCase style to under_score_case | [
"convert",
"CamelCase",
"style",
"to",
"under_score_case"
] | def camel_to_underscore(name):
"""
convert CamelCase style to under_score_case
"""
as_list = []
length = len(name)
for index, i in enumerate(name):
if index != 0 and index != length - 1 and i.isupper():
as_list.append('_%s' % i.lower())
else:
as_list.appen... | [
"def",
"camel_to_underscore",
"(",
"name",
")",
":",
"as_list",
"=",
"[",
"]",
"length",
"=",
"len",
"(",
"name",
")",
"for",
"index",
",",
"i",
"in",
"enumerate",
"(",
"name",
")",
":",
"if",
"index",
"!=",
"0",
"and",
"index",
"!=",
"length",
"-"... | https://github.com/wecatch/app-turbo/blob/d3b931db1b0f210d8af1da109edbf88756fa427d/turbo/util.py#L224-L236 | |
krintoxi/NoobSec-Toolkit | 38738541cbc03cedb9a3b3ed13b629f781ad64f6 | NoobSecToolkit /tools/sqli/thirdparty/bottle/bottle.py | python | MultiDict.__contains__ | (self, key) | return key in self.dict | [] | def __contains__(self, key): return key in self.dict | [
"def",
"__contains__",
"(",
"self",
",",
"key",
")",
":",
"return",
"key",
"in",
"self",
".",
"dict"
] | https://github.com/krintoxi/NoobSec-Toolkit/blob/38738541cbc03cedb9a3b3ed13b629f781ad64f6/NoobSecToolkit /tools/sqli/thirdparty/bottle/bottle.py#L1702-L1702 | |||
thatmattlove/hyperglass | c52a6f609843177671d38bcad59b8bd658f46b64 | hyperglass/external/msteams.py | python | MSTeams.__init__ | (self, config) | Initialize external base class with Microsoft Teams connection details. | Initialize external base class with Microsoft Teams connection details. | [
"Initialize",
"external",
"base",
"class",
"with",
"Microsoft",
"Teams",
"connection",
"details",
"."
] | def __init__(self, config):
"""Initialize external base class with Microsoft Teams connection details."""
super().__init__(
base_url="https://outlook.office.com", config=config, parse=False
) | [
"def",
"__init__",
"(",
"self",
",",
"config",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"base_url",
"=",
"\"https://outlook.office.com\"",
",",
"config",
"=",
"config",
",",
"parse",
"=",
"False",
")"
] | https://github.com/thatmattlove/hyperglass/blob/c52a6f609843177671d38bcad59b8bd658f46b64/hyperglass/external/msteams.py#L12-L17 | ||
timonwong/OmniMarkupPreviewer | 21921ac7a99d2b5924a2219b33679a5b53621392 | OmniMarkupLib/Renderers/libs/markdown/odict.py | python | OrderedDict.index_for_location | (self, location) | return i | Return index or None for a given location. | Return index or None for a given location. | [
"Return",
"index",
"or",
"None",
"for",
"a",
"given",
"location",
"."
] | def index_for_location(self, location):
""" Return index or None for a given location. """
if location == '_begin':
i = 0
elif location == '_end':
i = None
elif location.startswith('<') or location.startswith('>'):
i = self.index(location[1:])
... | [
"def",
"index_for_location",
"(",
"self",
",",
"location",
")",
":",
"if",
"location",
"==",
"'_begin'",
":",
"i",
"=",
"0",
"elif",
"location",
"==",
"'_end'",
":",
"i",
"=",
"None",
"elif",
"location",
".",
"startswith",
"(",
"'<'",
")",
"or",
"locat... | https://github.com/timonwong/OmniMarkupPreviewer/blob/21921ac7a99d2b5924a2219b33679a5b53621392/OmniMarkupLib/Renderers/libs/markdown/odict.py#L149-L166 | |
openedx/edx-platform | 68dd185a0ab45862a2a61e0f803d7e03d2be71b5 | common/lib/xmodule/xmodule/modulestore/xml.py | python | LibraryXMLModuleStore.patch_descriptor_kvs | (library_descriptor) | Metadata inheritance can be done purely through XBlocks, but in the import phase
a root block with an InheritanceKeyValueStore is assumed to be at the top of the hierarchy.
This should change in the future, but as XBlocks don't have this KVS, we have to patch it
here manually. | Metadata inheritance can be done purely through XBlocks, but in the import phase
a root block with an InheritanceKeyValueStore is assumed to be at the top of the hierarchy.
This should change in the future, but as XBlocks don't have this KVS, we have to patch it
here manually. | [
"Metadata",
"inheritance",
"can",
"be",
"done",
"purely",
"through",
"XBlocks",
"but",
"in",
"the",
"import",
"phase",
"a",
"root",
"block",
"with",
"an",
"InheritanceKeyValueStore",
"is",
"assumed",
"to",
"be",
"at",
"the",
"top",
"of",
"the",
"hierarchy",
... | def patch_descriptor_kvs(library_descriptor):
"""
Metadata inheritance can be done purely through XBlocks, but in the import phase
a root block with an InheritanceKeyValueStore is assumed to be at the top of the hierarchy.
This should change in the future, but as XBlocks don't have this ... | [
"def",
"patch_descriptor_kvs",
"(",
"library_descriptor",
")",
":",
"init_dict",
"=",
"{",
"key",
":",
"getattr",
"(",
"library_descriptor",
",",
"key",
")",
"for",
"key",
"in",
"library_descriptor",
".",
"fields",
".",
"keys",
"(",
")",
"}",
"# if set, invali... | https://github.com/openedx/edx-platform/blob/68dd185a0ab45862a2a61e0f803d7e03d2be71b5/common/lib/xmodule/xmodule/modulestore/xml.py#L895-L907 | ||
sagemath/sage | f9b2db94f675ff16963ccdefba4f1a3393b3fe0d | src/sage/combinat/words/morphism.py | python | WordMorphism.letter_growth_types | (self) | return mortal, polynomial, exponential | r"""
Return the mortal, polynomial and exponential growing letters.
The growth of `| s^n(a) |` as `n` goes to `\infty` is always of the
form `\alpha^n n^\beta` (where `\alpha` is a Perron number and
`\beta` an integer).
Without doing any linear algebra three cases can be differ... | r"""
Return the mortal, polynomial and exponential growing letters. | [
"r",
"Return",
"the",
"mortal",
"polynomial",
"and",
"exponential",
"growing",
"letters",
"."
] | def letter_growth_types(self):
r"""
Return the mortal, polynomial and exponential growing letters.
The growth of `| s^n(a) |` as `n` goes to `\infty` is always of the
form `\alpha^n n^\beta` (where `\alpha` is a Perron number and
`\beta` an integer).
Without doing any l... | [
"def",
"letter_growth_types",
"(",
"self",
")",
":",
"immortal",
"=",
"set",
"(",
"self",
".",
"immortal_letters",
"(",
")",
")",
"mortal",
"=",
"[",
"a",
"for",
"a",
"in",
"self",
".",
"domain",
"(",
")",
".",
"alphabet",
"(",
")",
"if",
"a",
"not... | https://github.com/sagemath/sage/blob/f9b2db94f675ff16963ccdefba4f1a3393b3fe0d/src/sage/combinat/words/morphism.py#L3211-L3349 | |
openshift/openshift-tools | 1188778e728a6e4781acf728123e5b356380fe6f | openshift/installer/vendored/openshift-ansible-3.10.0-0.29.0/roles/lib_utils/library/docker_creds.py | python | check_dest_dir_exists | (module, dest) | Check if dest dir is present and is a directory | Check if dest dir is present and is a directory | [
"Check",
"if",
"dest",
"dir",
"is",
"present",
"and",
"is",
"a",
"directory"
] | def check_dest_dir_exists(module, dest):
'''Check if dest dir is present and is a directory'''
dir_exists = os.path.exists(dest)
if dir_exists:
if not os.path.isdir(dest):
msg = "{} exists but is not a directory".format(dest)
result = {'failed': True,
'c... | [
"def",
"check_dest_dir_exists",
"(",
"module",
",",
"dest",
")",
":",
"dir_exists",
"=",
"os",
".",
"path",
".",
"exists",
"(",
"dest",
")",
"if",
"dir_exists",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"dest",
")",
":",
"msg",
"=",
"... | https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/openshift/installer/vendored/openshift-ansible-3.10.0-0.29.0/roles/lib_utils/library/docker_creds.py#L72-L86 | ||
HunterMcGushion/hyperparameter_hunter | 28b1d48e01a993818510811b82a677e0a7a232b2 | hyperparameter_hunter/space/dimensions.py | python | Dimension._check_distance | (self, a, b) | Check that two points fit within the dimension's bounds
Raises
------
RuntimeError
If either `a` or `b` fall outside the dimension's original (untransformed) bounds | Check that two points fit within the dimension's bounds | [
"Check",
"that",
"two",
"points",
"fit",
"within",
"the",
"dimension",
"s",
"bounds"
] | def _check_distance(self, a, b):
"""Check that two points fit within the dimension's bounds
Raises
------
RuntimeError
If either `a` or `b` fall outside the dimension's original (untransformed) bounds"""
if not (a in self and b in self):
raise RuntimeErro... | [
"def",
"_check_distance",
"(",
"self",
",",
"a",
",",
"b",
")",
":",
"if",
"not",
"(",
"a",
"in",
"self",
"and",
"b",
"in",
"self",
")",
":",
"raise",
"RuntimeError",
"(",
"f\"Distance computation requires values within space. Received {a} and {b}\"",
")"
] | https://github.com/HunterMcGushion/hyperparameter_hunter/blob/28b1d48e01a993818510811b82a677e0a7a232b2/hyperparameter_hunter/space/dimensions.py#L286-L296 | ||
golismero/golismero | 7d605b937e241f51c1ca4f47b20f755eeefb9d76 | thirdparty_libs/texttable.py | python | Texttable._str | (self, i, x) | Handles string formatting of cell data
i - index of the cell datatype in self._dtype
x - cell data to format | Handles string formatting of cell data | [
"Handles",
"string",
"formatting",
"of",
"cell",
"data"
] | def _str(self, i, x):
"""Handles string formatting of cell data
i - index of the cell datatype in self._dtype
x - cell data to format
"""
try:
f = float(x)
except:
return str(x)
n = self._precision
dtype = self._dtype[i]
... | [
"def",
"_str",
"(",
"self",
",",
"i",
",",
"x",
")",
":",
"try",
":",
"f",
"=",
"float",
"(",
"x",
")",
"except",
":",
"return",
"str",
"(",
"x",
")",
"n",
"=",
"self",
".",
"_precision",
"dtype",
"=",
"self",
".",
"_dtype",
"[",
"i",
"]",
... | https://github.com/golismero/golismero/blob/7d605b937e241f51c1ca4f47b20f755eeefb9d76/thirdparty_libs/texttable.py#L369-L401 | ||
carnal0wnage/weirdAAL | c14e36d7bb82447f38a43da203f4bc29429f4cf4 | libs/aws/brute.py | python | brute_cloudsearch_permissions | () | return generic_permission_bruteforcer('cloudsearch', tests) | http://boto3.readthedocs.io/en/latest/reference/services/cloudsearch.html | http://boto3.readthedocs.io/en/latest/reference/services/cloudsearch.html | [
"http",
":",
"//",
"boto3",
".",
"readthedocs",
".",
"io",
"/",
"en",
"/",
"latest",
"/",
"reference",
"/",
"services",
"/",
"cloudsearch",
".",
"html"
] | def brute_cloudsearch_permissions():
'''
http://boto3.readthedocs.io/en/latest/reference/services/cloudsearch.html
'''
print("### Enumerating CloudSearch Permissions ###")
tests = [('DescribeDomains', 'describe_domains', (), {}, ),
('ListDomainNames', 'list_domain_names', (), {}, ), ]
... | [
"def",
"brute_cloudsearch_permissions",
"(",
")",
":",
"print",
"(",
"\"### Enumerating CloudSearch Permissions ###\"",
")",
"tests",
"=",
"[",
"(",
"'DescribeDomains'",
",",
"'describe_domains'",
",",
"(",
")",
",",
"{",
"}",
",",
")",
",",
"(",
"'ListDomainNames... | https://github.com/carnal0wnage/weirdAAL/blob/c14e36d7bb82447f38a43da203f4bc29429f4cf4/libs/aws/brute.py#L530-L537 | |
biolab/orange2 | db40a9449cb45b507d63dcd5739b223f9cffb8e6 | Orange/OrangeCanvas/document/interactions.py | python | UserInteraction.isCanceled | (self) | return self.__canceled | Was the interaction canceled. | Was the interaction canceled. | [
"Was",
"the",
"interaction",
"canceled",
"."
] | def isCanceled(self):
"""
Was the interaction canceled.
"""
return self.__canceled | [
"def",
"isCanceled",
"(",
"self",
")",
":",
"return",
"self",
".",
"__canceled"
] | https://github.com/biolab/orange2/blob/db40a9449cb45b507d63dcd5739b223f9cffb8e6/Orange/OrangeCanvas/document/interactions.py#L143-L147 | |
FSX/momoko | ad2f602c85b5df09e54dcb997c2f81ccc3d2b221 | momoko/connection.py | python | Pool.register_hstore | (self, *args, **kwargs) | return self._operate(Connection.register_hstore, args, kwargs) | Register adapter and typecaster for ``dict-hstore`` conversions.
See :py:meth:`momoko.Connection.register_hstore` for documentation about
the parameters. This method has no ``globally`` parameter, because it
already registers hstore to all the connections in the pool. | Register adapter and typecaster for ``dict-hstore`` conversions. | [
"Register",
"adapter",
"and",
"typecaster",
"for",
"dict",
"-",
"hstore",
"conversions",
"."
] | def register_hstore(self, *args, **kwargs):
"""
Register adapter and typecaster for ``dict-hstore`` conversions.
See :py:meth:`momoko.Connection.register_hstore` for documentation about
the parameters. This method has no ``globally`` parameter, because it
already registers hstor... | [
"def",
"register_hstore",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"\"globally\"",
"]",
"=",
"True",
"return",
"self",
".",
"_operate",
"(",
"Connection",
".",
"register_hstore",
",",
"args",
",",
"kwargs",
")"
] | https://github.com/FSX/momoko/blob/ad2f602c85b5df09e54dcb997c2f81ccc3d2b221/momoko/connection.py#L428-L437 | |
autorope/donkeycar | a3df79a3573127dff31fc9b2953588056875b214 | donkeycar/parts/pins.py | python | pca9685 | (busnum: int, address: int, frequency: int = 60) | return pca | pca9685 factory allocates driver for pca9685
at given bus number and i2c address.
If we have already created one for that bus/addr
pair then use that singleton. If frequency is
not the same, then error.
:param busnum: I2C bus number of PCA9685
:param address: address of PCA9685 on I2C bus
:... | pca9685 factory allocates driver for pca9685
at given bus number and i2c address.
If we have already created one for that bus/addr
pair then use that singleton. If frequency is
not the same, then error.
:param busnum: I2C bus number of PCA9685
:param address: address of PCA9685 on I2C bus
:... | [
"pca9685",
"factory",
"allocates",
"driver",
"for",
"pca9685",
"at",
"given",
"bus",
"number",
"and",
"i2c",
"address",
".",
"If",
"we",
"have",
"already",
"created",
"one",
"for",
"that",
"bus",
"/",
"addr",
"pair",
"then",
"use",
"that",
"singleton",
"."... | def pca9685(busnum: int, address: int, frequency: int = 60):
"""
pca9685 factory allocates driver for pca9685
at given bus number and i2c address.
If we have already created one for that bus/addr
pair then use that singleton. If frequency is
not the same, then error.
:param busnum: I2C bus ... | [
"def",
"pca9685",
"(",
"busnum",
":",
"int",
",",
"address",
":",
"int",
",",
"frequency",
":",
"int",
"=",
"60",
")",
":",
"key",
"=",
"str",
"(",
"busnum",
")",
"+",
"\":\"",
"+",
"hex",
"(",
"address",
")",
"pca",
"=",
"_pca9685",
".",
"get",
... | https://github.com/autorope/donkeycar/blob/a3df79a3573127dff31fc9b2953588056875b214/donkeycar/parts/pins.py#L598-L621 | |
SickChill/SickChill | 01020f3636d01535f60b83464d8127ea0efabfc7 | sickchill/adba/aniDBresponses.py | python | NotificationStateResponse.__init__ | (self, cmd, restag, rescode, resstr, datalines) | attributes:
data:
notifies - pending notifies
msgs - pending msgs
buddys - number of online buddys | attributes: | [
"attributes",
":"
] | def __init__(self, cmd, restag, rescode, resstr, datalines):
"""
attributes:
data:
notifies - pending notifies
msgs - pending msgs
buddys - number of online buddys
"""
super().__init__(cmd, restag, rescode, resstr, datalines)
self.codestr = "NOTI... | [
"def",
"__init__",
"(",
"self",
",",
"cmd",
",",
"restag",
",",
"rescode",
",",
"resstr",
",",
"datalines",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"cmd",
",",
"restag",
",",
"rescode",
",",
"resstr",
",",
"datalines",
")",
"self",
".",
... | https://github.com/SickChill/SickChill/blob/01020f3636d01535f60b83464d8127ea0efabfc7/sickchill/adba/aniDBresponses.py#L974-L994 | ||
aws-cloudformation/cfn-lint | 16df5d0ca0d8ebcf9330ebea701e83d883b47217 | src/cfnlint/rules/functions/DynamicReferenceSecureString.py | python | DynamicReferenceSecureString.__init__ | (self) | Init | Init | [
"Init"
] | def __init__(self):
"""Init """
super(DynamicReferenceSecureString, self).__init__()
self.property_specs = []
self.resource_specs = []
self.exceptions = {
'AWS::DirectoryService::MicrosoftAD': 'Password',
'AWS::DirectoryService::SimpleAD': 'Password',
... | [
"def",
"__init__",
"(",
"self",
")",
":",
"super",
"(",
"DynamicReferenceSecureString",
",",
"self",
")",
".",
"__init__",
"(",
")",
"self",
".",
"property_specs",
"=",
"[",
"]",
"self",
".",
"resource_specs",
"=",
"[",
"]",
"self",
".",
"exceptions",
"=... | https://github.com/aws-cloudformation/cfn-lint/blob/16df5d0ca0d8ebcf9330ebea701e83d883b47217/src/cfnlint/rules/functions/DynamicReferenceSecureString.py#L23-L40 | ||
andresriancho/w3af | cd22e5252243a87aaa6d0ddea47cf58dacfe00a9 | w3af/plugins/attack/db/sqlmap/thirdparty/bottle/bottle.py | python | Bottle.add_route | (self, route) | Add a route object, but do not change the :data:`Route.app`
attribute. | Add a route object, but do not change the :data:`Route.app`
attribute. | [
"Add",
"a",
"route",
"object",
"but",
"do",
"not",
"change",
"the",
":",
"data",
":",
"Route",
".",
"app",
"attribute",
"."
] | def add_route(self, route):
""" Add a route object, but do not change the :data:`Route.app`
attribute."""
self.routes.append(route)
self.router.add(route.rule, route.method, route, name=route.name)
if DEBUG: route.prepare() | [
"def",
"add_route",
"(",
"self",
",",
"route",
")",
":",
"self",
".",
"routes",
".",
"append",
"(",
"route",
")",
"self",
".",
"router",
".",
"add",
"(",
"route",
".",
"rule",
",",
"route",
".",
"method",
",",
"route",
",",
"name",
"=",
"route",
... | https://github.com/andresriancho/w3af/blob/cd22e5252243a87aaa6d0ddea47cf58dacfe00a9/w3af/plugins/attack/db/sqlmap/thirdparty/bottle/bottle.py#L834-L839 | ||
StackStorm/st2 | 85ae05b73af422efd3097c9c05351f7f1cc8369e | st2exporter/dist_utils.py | python | apply_vagrant_workaround | () | Function which detects if the script is being executed inside vagrant and if it is, it deletes
"os.link" attribute.
Note: Without this workaround, setup.py sdist will fail when running inside a shared directory
(nfs / virtualbox shared folders). | Function which detects if the script is being executed inside vagrant and if it is, it deletes
"os.link" attribute.
Note: Without this workaround, setup.py sdist will fail when running inside a shared directory
(nfs / virtualbox shared folders). | [
"Function",
"which",
"detects",
"if",
"the",
"script",
"is",
"being",
"executed",
"inside",
"vagrant",
"and",
"if",
"it",
"is",
"it",
"deletes",
"os",
".",
"link",
"attribute",
".",
"Note",
":",
"Without",
"this",
"workaround",
"setup",
".",
"py",
"sdist",... | def apply_vagrant_workaround():
"""
Function which detects if the script is being executed inside vagrant and if it is, it deletes
"os.link" attribute.
Note: Without this workaround, setup.py sdist will fail when running inside a shared directory
(nfs / virtualbox shared folders).
"""
if os.... | [
"def",
"apply_vagrant_workaround",
"(",
")",
":",
"if",
"os",
".",
"environ",
".",
"get",
"(",
"\"USER\"",
",",
"None",
")",
"==",
"\"vagrant\"",
":",
"del",
"os",
".",
"link"
] | https://github.com/StackStorm/st2/blob/85ae05b73af422efd3097c9c05351f7f1cc8369e/st2exporter/dist_utils.py#L146-L154 | ||
fritzy/SleekXMPP | cc1d470397de768ffcc41d2ed5ac3118d19f09f5 | examples/pubsub_events.py | python | PubsubEvents._purge | (self, msg) | Handle receiving a node purge event. | Handle receiving a node purge event. | [
"Handle",
"receiving",
"a",
"node",
"purge",
"event",
"."
] | def _purge(self, msg):
"""Handle receiving a node purge event."""
print('Purged all items from %s' % (
msg['pubsub_event']['purge']['node'])) | [
"def",
"_purge",
"(",
"self",
",",
"msg",
")",
":",
"print",
"(",
"'Purged all items from %s'",
"%",
"(",
"msg",
"[",
"'pubsub_event'",
"]",
"[",
"'purge'",
"]",
"[",
"'node'",
"]",
")",
")"
] | https://github.com/fritzy/SleekXMPP/blob/cc1d470397de768ffcc41d2ed5ac3118d19f09f5/examples/pubsub_events.py#L74-L77 | ||
openshift/openshift-tools | 1188778e728a6e4781acf728123e5b356380fe6f | ansible/roles/lib_oa_openshift/library/oc_adm_registry.py | python | Secret.add_secret | (self, key, value) | return True | add a secret | add a secret | [
"add",
"a",
"secret"
] | def add_secret(self, key, value):
''' add a secret '''
if self.secrets:
self.secrets[key] = value
else:
self.put(Secret.secret_path, {key: value})
return True | [
"def",
"add_secret",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"if",
"self",
".",
"secrets",
":",
"self",
".",
"secrets",
"[",
"key",
"]",
"=",
"value",
"else",
":",
"self",
".",
"put",
"(",
"Secret",
".",
"secret_path",
",",
"{",
"key",
"... | https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/ansible/roles/lib_oa_openshift/library/oc_adm_registry.py#L2007-L2014 | |
apache/libcloud | 90971e17bfd7b6bb97b2489986472c531cc8e140 | libcloud/compute/drivers/openstack.py | python | OpenStackSecurityGroup.__init__ | (
self, id, tenant_id, name, description, driver, rules=None, extra=None
) | Constructor.
:keyword id: Group id.
:type id: ``str``
:keyword tenant_id: Owner of the security group.
:type tenant_id: ``str``
:keyword name: Human-readable name for the security group. Might
not be unique.
:type na... | Constructor. | [
"Constructor",
"."
] | def __init__(
self, id, tenant_id, name, description, driver, rules=None, extra=None
):
"""
Constructor.
:keyword id: Group id.
:type id: ``str``
:keyword tenant_id: Owner of the security group.
:type tenant_id: ``str``
:keyword ... | [
"def",
"__init__",
"(",
"self",
",",
"id",
",",
"tenant_id",
",",
"name",
",",
"description",
",",
"driver",
",",
"rules",
"=",
"None",
",",
"extra",
"=",
"None",
")",
":",
"self",
".",
"id",
"=",
"id",
"self",
".",
"tenant_id",
"=",
"tenant_id",
"... | https://github.com/apache/libcloud/blob/90971e17bfd7b6bb97b2489986472c531cc8e140/libcloud/compute/drivers/openstack.py#L1255-L1288 | ||
Blizzard/heroprotocol | 3d36eaf44fc4c8ff3331c2ae2f1dc08a94535f1c | heroprotocol/versions/protocol48583.py | python | decode_replay_game_events | (contents) | Decodes and yields each game event from the contents byte string. | Decodes and yields each game event from the contents byte string. | [
"Decodes",
"and",
"yields",
"each",
"game",
"event",
"from",
"the",
"contents",
"byte",
"string",
"."
] | def decode_replay_game_events(contents):
"""Decodes and yields each game event from the contents byte string."""
decoder = BitPackedDecoder(contents, typeinfos)
for event in _decode_event_stream(decoder,
game_eventid_typeid,
game_ev... | [
"def",
"decode_replay_game_events",
"(",
"contents",
")",
":",
"decoder",
"=",
"BitPackedDecoder",
"(",
"contents",
",",
"typeinfos",
")",
"for",
"event",
"in",
"_decode_event_stream",
"(",
"decoder",
",",
"game_eventid_typeid",
",",
"game_event_types",
",",
"decode... | https://github.com/Blizzard/heroprotocol/blob/3d36eaf44fc4c8ff3331c2ae2f1dc08a94535f1c/heroprotocol/versions/protocol48583.py#L395-L402 | ||
bruceyang2012/Face-detection-with-mobilenet-ssd | 58fafb6e93d28531797aac1e9a4436730c8cee7c | face_generator.py | python | BatchGenerator.__init__ | (self,
images_path,
include_classes='all',
box_output_format=['class_id', 'xmin', 'xmax', 'ymin', 'ymax']) | Arguments:
images_path (str): The filepath to the image samples.
include_classes (list, optional): Either 'all' or a list of integers containing the class IDs that
are to be included in the dataset. Defaults to 'all', in which case all boxes will be included
in th... | Arguments:
images_path (str): The filepath to the image samples.
include_classes (list, optional): Either 'all' or a list of integers containing the class IDs that
are to be included in the dataset. Defaults to 'all', in which case all boxes will be included
in th... | [
"Arguments",
":",
"images_path",
"(",
"str",
")",
":",
"The",
"filepath",
"to",
"the",
"image",
"samples",
".",
"include_classes",
"(",
"list",
"optional",
")",
":",
"Either",
"all",
"or",
"a",
"list",
"of",
"integers",
"containing",
"the",
"class",
"IDs",... | def __init__(self,
images_path,
include_classes='all',
box_output_format=['class_id', 'xmin', 'xmax', 'ymin', 'ymax']):
'''
Arguments:
images_path (str): The filepath to the image samples.
include_classes (list, optional): Either... | [
"def",
"__init__",
"(",
"self",
",",
"images_path",
",",
"include_classes",
"=",
"'all'",
",",
"box_output_format",
"=",
"[",
"'class_id'",
",",
"'xmin'",
",",
"'xmax'",
",",
"'ymin'",
",",
"'ymax'",
"]",
")",
":",
"# These are the variables we always need",
"se... | https://github.com/bruceyang2012/Face-detection-with-mobilenet-ssd/blob/58fafb6e93d28531797aac1e9a4436730c8cee7c/face_generator.py#L229-L268 | ||
clinton-hall/nzbToMedia | 27669389216902d1085660167e7bda0bd8527ecf | libs/common/validate.py | python | Validator.get_default_value | (self, check) | return self._check_value(value, fun_name, fun_args, fun_kwargs) | Given a check, return the default value for the check
(converted to the right type).
If the check doesn't specify a default value then a
``KeyError`` will be raised. | Given a check, return the default value for the check
(converted to the right type).
If the check doesn't specify a default value then a
``KeyError`` will be raised. | [
"Given",
"a",
"check",
"return",
"the",
"default",
"value",
"for",
"the",
"check",
"(",
"converted",
"to",
"the",
"right",
"type",
")",
".",
"If",
"the",
"check",
"doesn",
"t",
"specify",
"a",
"default",
"value",
"then",
"a",
"KeyError",
"will",
"be",
... | def get_default_value(self, check):
"""
Given a check, return the default value for the check
(converted to the right type).
If the check doesn't specify a default value then a
``KeyError`` will be raised.
"""
fun_name, fun_args, fun_kwargs, default = sel... | [
"def",
"get_default_value",
"(",
"self",
",",
"check",
")",
":",
"fun_name",
",",
"fun_args",
",",
"fun_kwargs",
",",
"default",
"=",
"self",
".",
"_parse_with_caching",
"(",
"check",
")",
"if",
"default",
"is",
"None",
":",
"raise",
"KeyError",
"(",
"'Che... | https://github.com/clinton-hall/nzbToMedia/blob/27669389216902d1085660167e7bda0bd8527ecf/libs/common/validate.py#L729-L743 | |
LumaPictures/pymel | fa88a3f4fa18e09bb8aa9bdf4dab53d984bada72 | pymel/util/nameparse.py | python | MayaNodePath.isDagName | (self) | return len(self.nodes) > 1 | True if this object is specified including one or more dag parents | True if this object is specified including one or more dag parents | [
"True",
"if",
"this",
"object",
"is",
"specified",
"including",
"one",
"or",
"more",
"dag",
"parents"
] | def isDagName(self):
""" True if this object is specified including one or more dag parents """
return len(self.nodes) > 1 | [
"def",
"isDagName",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"nodes",
")",
">",
"1"
] | https://github.com/LumaPictures/pymel/blob/fa88a3f4fa18e09bb8aa9bdf4dab53d984bada72/pymel/util/nameparse.py#L1119-L1121 | |
jjhelmus/nmrglue | f47397dcda84854d2136395a9998fe0b57356cbf | nmrglue/process/proc_base.py | python | neg_middle | (data) | return data | Negate middle half. | Negate middle half. | [
"Negate",
"middle",
"half",
"."
] | def neg_middle(data):
"""
Negate middle half.
"""
data[..., int(data.shape[-1] * 1. / 4.):int(data.shape[-1] * 3. / 4.)] = \
-data[..., int(data.shape[-1] * 1. / 4.):int(data.shape[-1] * 3. / 4.)]
return data | [
"def",
"neg_middle",
"(",
"data",
")",
":",
"data",
"[",
"...",
",",
"int",
"(",
"data",
".",
"shape",
"[",
"-",
"1",
"]",
"*",
"1.",
"/",
"4.",
")",
":",
"int",
"(",
"data",
".",
"shape",
"[",
"-",
"1",
"]",
"*",
"3.",
"/",
"4.",
")",
"]... | https://github.com/jjhelmus/nmrglue/blob/f47397dcda84854d2136395a9998fe0b57356cbf/nmrglue/process/proc_base.py#L1715-L1721 | |
guildai/guildai | 1665985a3d4d788efc1a3180ca51cc417f71ca78 | guild/external/pip/_vendor/pyparsing.py | python | pyparsing_common.stripHTMLTags | (s, l, tokens) | return pyparsing_common._html_stripper.transformString(tokens[0]) | Parse action to remove HTML tags from web page HTML source
Example::
# strip HTML links from normal text
text = '<td>More info at the <a href="http://pyparsing.wikispaces.com">pyparsing</a> wiki page</td>'
td,td_end = makeHTMLTags("TD")
table_text = td + SkipTo(... | Parse action to remove HTML tags from web page HTML source | [
"Parse",
"action",
"to",
"remove",
"HTML",
"tags",
"from",
"web",
"page",
"HTML",
"source"
] | def stripHTMLTags(s, l, tokens):
"""
Parse action to remove HTML tags from web page HTML source
Example::
# strip HTML links from normal text
text = '<td>More info at the <a href="http://pyparsing.wikispaces.com">pyparsing</a> wiki page</td>'
td,td_end = mak... | [
"def",
"stripHTMLTags",
"(",
"s",
",",
"l",
",",
"tokens",
")",
":",
"return",
"pyparsing_common",
".",
"_html_stripper",
".",
"transformString",
"(",
"tokens",
"[",
"0",
"]",
")"
] | https://github.com/guildai/guildai/blob/1665985a3d4d788efc1a3180ca51cc417f71ca78/guild/external/pip/_vendor/pyparsing.py#L5625-L5637 | |
linuxscout/mishkal | 4f4ae0ebc2d6acbeb3de3f0303151ec7b54d2f76 | support/spellcheck/spellcheck.py | python | SpellcheckClass.enableAjustVocalization | (self) | Enable the Ajust Vocalization option. | Enable the Ajust Vocalization option. | [
"Enable",
"the",
"Ajust",
"Vocalization",
"option",
"."
] | def enableAjustVocalization(self):
"""
Enable the Ajust Vocalization option.
"""
self.enabledAjustVocalization=True; | [
"def",
"enableAjustVocalization",
"(",
"self",
")",
":",
"self",
".",
"enabledAjustVocalization",
"=",
"True"
] | https://github.com/linuxscout/mishkal/blob/4f4ae0ebc2d6acbeb3de3f0303151ec7b54d2f76/support/spellcheck/spellcheck.py#L173-L177 | ||
microsoft/msticpy | 2a401444ee529114004f496f4c0376ff25b5268a | msticpy/config/compound_ctrls.py | python | UserDefLoadComponent.value | (self, value: Union[str, Dict[str, Optional[str]]]) | Set value of controls from dict. | Set value of controls from dict. | [
"Set",
"value",
"of",
"controls",
"from",
"dict",
"."
] | def value(self, value: Union[str, Dict[str, Optional[str]]]):
"""Set value of controls from dict."""
if isinstance(value, dict):
self._set_ctrl_from_val(path="", value=value) | [
"def",
"value",
"(",
"self",
",",
"value",
":",
"Union",
"[",
"str",
",",
"Dict",
"[",
"str",
",",
"Optional",
"[",
"str",
"]",
"]",
"]",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"self",
".",
"_set_ctrl_from_val",
"(",
"... | https://github.com/microsoft/msticpy/blob/2a401444ee529114004f496f4c0376ff25b5268a/msticpy/config/compound_ctrls.py#L476-L479 | ||
enthought/chaco | 0907d1dedd07a499202efbaf2fe2a4e51b4c8e5f | chaco/plots/line_scatterplot_1d.py | python | LineScatterPlot1D._render | (self, gc, lines) | Render a sequence of line values, accounting for selections | Render a sequence of line values, accounting for selections | [
"Render",
"a",
"sequence",
"of",
"line",
"values",
"accounting",
"for",
"selections"
] | def _render(self, gc, lines):
""" Render a sequence of line values, accounting for selections """
with gc:
gc.clip_to_rect(self.x, self.y, self.width, self.height)
if not self.index:
return
name = self.selection_metadata_name
md = self.inde... | [
"def",
"_render",
"(",
"self",
",",
"gc",
",",
"lines",
")",
":",
"with",
"gc",
":",
"gc",
".",
"clip_to_rect",
"(",
"self",
".",
"x",
",",
"self",
".",
"y",
",",
"self",
".",
"width",
",",
"self",
".",
"height",
")",
"if",
"not",
"self",
".",
... | https://github.com/enthought/chaco/blob/0907d1dedd07a499202efbaf2fe2a4e51b4c8e5f/chaco/plots/line_scatterplot_1d.py#L87-L121 | ||
bytedance/fedlearner | 89f5a2341d9b3c9100c799473fe5f436da7e87a2 | fedlearner/common/metrics.py | python | Metrics.remove_handler | (self, hdlr) | Remove the specified handler from this logger. | Remove the specified handler from this logger. | [
"Remove",
"the",
"specified",
"handler",
"from",
"this",
"logger",
"."
] | def remove_handler(self, hdlr):
"""
Remove the specified handler from this logger.
"""
with self._lock:
if hdlr in self.handlers:
self.handlers.remove(hdlr) | [
"def",
"remove_handler",
"(",
"self",
",",
"hdlr",
")",
":",
"with",
"self",
".",
"_lock",
":",
"if",
"hdlr",
"in",
"self",
".",
"handlers",
":",
"self",
".",
"handlers",
".",
"remove",
"(",
"hdlr",
")"
] | https://github.com/bytedance/fedlearner/blob/89f5a2341d9b3c9100c799473fe5f436da7e87a2/fedlearner/common/metrics.py#L198-L204 | ||
Qiskit/qiskit-terra | b66030e3b9192efdd3eb95cf25c6545fe0a13da4 | qiskit/opflow/state_fns/cvar_measurement.py | python | CVaRMeasurement.to_density_matrix | (self, massive: bool = False) | Not defined. | Not defined. | [
"Not",
"defined",
"."
] | def to_density_matrix(self, massive: bool = False):
"""Not defined."""
raise NotImplementedError | [
"def",
"to_density_matrix",
"(",
"self",
",",
"massive",
":",
"bool",
"=",
"False",
")",
":",
"raise",
"NotImplementedError"
] | https://github.com/Qiskit/qiskit-terra/blob/b66030e3b9192efdd3eb95cf25c6545fe0a13da4/qiskit/opflow/state_fns/cvar_measurement.py#L129-L131 | ||
haiwen/seahub | e92fcd44e3e46260597d8faa9347cb8222b8b10d | seahub/share/models.py | python | FileShare.is_file_share_link | (self) | return True if self.s_type == 'f' else False | [] | def is_file_share_link(self):
return True if self.s_type == 'f' else False | [
"def",
"is_file_share_link",
"(",
"self",
")",
":",
"return",
"True",
"if",
"self",
".",
"s_type",
"==",
"'f'",
"else",
"False"
] | https://github.com/haiwen/seahub/blob/e92fcd44e3e46260597d8faa9347cb8222b8b10d/seahub/share/models.py#L347-L348 | |||
yourlabs/django-autocomplete-light | 3eb84a09c5828e4a9409f0aec14c2874bcbe17df | src/dal/views.py | python | BaseQuerySetView.get_search_fields | (self) | Get the fields to search over. | Get the fields to search over. | [
"Get",
"the",
"fields",
"to",
"search",
"over",
"."
] | def get_search_fields(self):
"""Get the fields to search over."""
if self.search_fields:
return self.search_fields
else:
return [self.model_field_name] | [
"def",
"get_search_fields",
"(",
"self",
")",
":",
"if",
"self",
".",
"search_fields",
":",
"return",
"self",
".",
"search_fields",
"else",
":",
"return",
"[",
"self",
".",
"model_field_name",
"]"
] | https://github.com/yourlabs/django-autocomplete-light/blob/3eb84a09c5828e4a9409f0aec14c2874bcbe17df/src/dal/views.py#L114-L119 | ||
ShiyuLiang/odin-pytorch | 34e53f5a982811a0d74baba049538d34efc0732d | code/wideresnet.py | python | NetworkBlock.__init__ | (self, nb_layers, in_planes, out_planes, block, stride, dropRate=0.0) | [] | def __init__(self, nb_layers, in_planes, out_planes, block, stride, dropRate=0.0):
super(NetworkBlock, self).__init__()
self.layer = self._make_layer(block, in_planes, out_planes, nb_layers, stride, dropRate) | [
"def",
"__init__",
"(",
"self",
",",
"nb_layers",
",",
"in_planes",
",",
"out_planes",
",",
"block",
",",
"stride",
",",
"dropRate",
"=",
"0.0",
")",
":",
"super",
"(",
"NetworkBlock",
",",
"self",
")",
".",
"__init__",
"(",
")",
"self",
".",
"layer",
... | https://github.com/ShiyuLiang/odin-pytorch/blob/34e53f5a982811a0d74baba049538d34efc0732d/code/wideresnet.py#L34-L36 | ||||
openedx/edx-platform | 68dd185a0ab45862a2a61e0f803d7e03d2be71b5 | openedx/features/enterprise_support/api.py | python | enterprise_customer_uuid_from_session | (request) | return _CACHE_MISS | Retrieve an enterprise customer UUID from the request's session,
returning a ``__CACHE_MISS__`` if absent. Note that this may
return ``None``, which indicates that we've previously looked
for an associated customer for this request's user, and
none was present. | Retrieve an enterprise customer UUID from the request's session,
returning a ``__CACHE_MISS__`` if absent. Note that this may
return ``None``, which indicates that we've previously looked
for an associated customer for this request's user, and
none was present. | [
"Retrieve",
"an",
"enterprise",
"customer",
"UUID",
"from",
"the",
"request",
"s",
"session",
"returning",
"a",
"__CACHE_MISS__",
"if",
"absent",
".",
"Note",
"that",
"this",
"may",
"return",
"None",
"which",
"indicates",
"that",
"we",
"ve",
"previously",
"loo... | def enterprise_customer_uuid_from_session(request):
"""
Retrieve an enterprise customer UUID from the request's session,
returning a ``__CACHE_MISS__`` if absent. Note that this may
return ``None``, which indicates that we've previously looked
for an associated customer for this request's user, and... | [
"def",
"enterprise_customer_uuid_from_session",
"(",
"request",
")",
":",
"customer_data",
"=",
"enterprise_customer_from_session",
"(",
"request",
")",
"if",
"customer_data",
"is",
"not",
"_CACHE_MISS",
":",
"customer_data",
"=",
"customer_data",
"or",
"{",
"}",
"ret... | https://github.com/openedx/edx-platform/blob/68dd185a0ab45862a2a61e0f803d7e03d2be71b5/openedx/features/enterprise_support/api.py#L427-L439 | |
mikedh/trimesh | 6b1e05616b44e6dd708d9bc748b211656ebb27ec | trimesh/visual/texture.py | python | TextureVisuals.to_color | (self) | return vis | Convert textured visuals to a ColorVisuals with vertex
color calculated from texture.
Returns
-----------
vis : trimesh.visuals.ColorVisuals
Contains vertex color from texture | Convert textured visuals to a ColorVisuals with vertex
color calculated from texture. | [
"Convert",
"textured",
"visuals",
"to",
"a",
"ColorVisuals",
"with",
"vertex",
"color",
"calculated",
"from",
"texture",
"."
] | def to_color(self):
"""
Convert textured visuals to a ColorVisuals with vertex
color calculated from texture.
Returns
-----------
vis : trimesh.visuals.ColorVisuals
Contains vertex color from texture
"""
# find the color at each UV coordinate
... | [
"def",
"to_color",
"(",
"self",
")",
":",
"# find the color at each UV coordinate",
"colors",
"=",
"self",
".",
"material",
".",
"to_color",
"(",
"self",
".",
"uv",
")",
"# create ColorVisuals from result",
"vis",
"=",
"color",
".",
"ColorVisuals",
"(",
"vertex_co... | https://github.com/mikedh/trimesh/blob/6b1e05616b44e6dd708d9bc748b211656ebb27ec/trimesh/visual/texture.py#L148-L162 | |
s3rvac/weechat-notify-send | d99632574a11098c05bc2b6075e149aaea77be0d | notify_send.py | python | parse_tags | (tags) | return tags.split(',') | Parses the given "list" of tags (str) from WeeChat into a list. | Parses the given "list" of tags (str) from WeeChat into a list. | [
"Parses",
"the",
"given",
"list",
"of",
"tags",
"(",
"str",
")",
"from",
"WeeChat",
"into",
"a",
"list",
"."
] | def parse_tags(tags):
"""Parses the given "list" of tags (str) from WeeChat into a list."""
return tags.split(',') | [
"def",
"parse_tags",
"(",
"tags",
")",
":",
"return",
"tags",
".",
"split",
"(",
"','",
")"
] | https://github.com/s3rvac/weechat-notify-send/blob/d99632574a11098c05bc2b6075e149aaea77be0d/notify_send.py#L244-L246 | |
anatolikalysch/VMAttack | 67dcce6087163d85bbe7780e3f6e6e9e72e2212a | lib/Instruction.py | python | Instruction.is_add_basepointer | (self) | return (('ADD' in self.Instruction.mnemonic) and
(self.Instruction.instructionClass == 'ISC_INTEGER') and
(self.Instruction.operands[0].name == 'EBP' or
self.Instruction.operands[0].name == 'RBP')) | @brief Tests if the instruction adds something to the
basepointer | [] | def is_add_basepointer(self):
"""
@brief Tests if the instruction adds something to the
basepointer
"""
return (('ADD' in self.Instruction.mnemonic) and
(self.Instruction.instructionClass == 'ISC_INTEGER') and
(self.Instruction.operands[0].name == ... | [
"def",
"is_add_basepointer",
"(",
"self",
")",
":",
"return",
"(",
"(",
"'ADD'",
"in",
"self",
".",
"Instruction",
".",
"mnemonic",
")",
"and",
"(",
"self",
".",
"Instruction",
".",
"instructionClass",
"==",
"'ISC_INTEGER'",
")",
"and",
"(",
"self",
".",
... | https://github.com/anatolikalysch/VMAttack/blob/67dcce6087163d85bbe7780e3f6e6e9e72e2212a/lib/Instruction.py#L446-L454 | ||
sympy/sympy | d822fcba181155b85ff2b29fe525adbafb22b448 | sympy/vector/vector.py | python | dot | (vect1, vect2) | return Dot(vect1, vect2) | Returns dot product of two vectors.
Examples
========
>>> from sympy.vector import CoordSys3D
>>> from sympy.vector.vector import dot
>>> R = CoordSys3D('R')
>>> v1 = R.i + R.j + R.k
>>> v2 = R.x * R.i + R.y * R.j + R.z * R.k
>>> dot(v1, v2)
R.x + R.y + R.z | Returns dot product of two vectors. | [
"Returns",
"dot",
"product",
"of",
"two",
"vectors",
"."
] | def dot(vect1, vect2):
"""
Returns dot product of two vectors.
Examples
========
>>> from sympy.vector import CoordSys3D
>>> from sympy.vector.vector import dot
>>> R = CoordSys3D('R')
>>> v1 = R.i + R.j + R.k
>>> v2 = R.x * R.i + R.y * R.j + R.z * R.k
>>> dot(v1, v2)
R.x +... | [
"def",
"dot",
"(",
"vect1",
",",
"vect2",
")",
":",
"if",
"isinstance",
"(",
"vect1",
",",
"Add",
")",
":",
"return",
"Add",
".",
"fromiter",
"(",
"dot",
"(",
"i",
",",
"vect2",
")",
"for",
"i",
"in",
"vect1",
".",
"args",
")",
"if",
"isinstance"... | https://github.com/sympy/sympy/blob/d822fcba181155b85ff2b29fe525adbafb22b448/sympy/vector/vector.py#L578-L617 | |
duo-labs/isthislegit | 5d51fd2e0fe070cacd1ee169ca8a371a72e005ef | dashboard/lib/flanker/addresslib/lexer.py | python | t_comment_RPAREN | (t) | return t | r'\) | r'\) | [
"r",
"\\",
")"
] | def t_comment_RPAREN(t):
r'\)'
t.lexer.begin('INITIAL')
return t | [
"def",
"t_comment_RPAREN",
"(",
"t",
")",
":",
"t",
".",
"lexer",
".",
"begin",
"(",
"'INITIAL'",
")",
"return",
"t"
] | https://github.com/duo-labs/isthislegit/blob/5d51fd2e0fe070cacd1ee169ca8a371a72e005ef/dashboard/lib/flanker/addresslib/lexer.py#L183-L186 | |
bikalims/bika.lims | 35e4bbdb5a3912cae0b5eb13e51097c8b0486349 | bika/lims/browser/fields/aranalysesfield.py | python | ARAnalysesField.Services | (self) | return self._v_services | Return analysis services | Return analysis services | [
"Return",
"analysis",
"services"
] | def Services(self):
""" Return analysis services
"""
bsc = getToolByName(self.context, 'bika_setup_catalog')
if not shasattr(self, '_v_services'):
self._v_services = [service.getObject()
for service in bsc(portal_type='AnalysisService')]
... | [
"def",
"Services",
"(",
"self",
")",
":",
"bsc",
"=",
"getToolByName",
"(",
"self",
".",
"context",
",",
"'bika_setup_catalog'",
")",
"if",
"not",
"shasattr",
"(",
"self",
",",
"'_v_services'",
")",
":",
"self",
".",
"_v_services",
"=",
"[",
"service",
"... | https://github.com/bikalims/bika.lims/blob/35e4bbdb5a3912cae0b5eb13e51097c8b0486349/bika/lims/browser/fields/aranalysesfield.py#L215-L222 | |
google/active-qa | bd96fab78255b8ef4f1147f78bd571abf2b919b3 | px/nmt/train.py | python | run_full_eval | (model_dir,
infer_model,
infer_sess,
eval_model,
eval_sess,
hparams,
summary_writer,
sample_src_data,
sample_ctx_data,
sample_tgt_data,
samp... | return result_summary, global_step, metrics | Wrapper for running sample_decode, internal_eval and external_eval. | Wrapper for running sample_decode, internal_eval and external_eval. | [
"Wrapper",
"for",
"running",
"sample_decode",
"internal_eval",
"and",
"external_eval",
"."
] | def run_full_eval(model_dir,
infer_model,
infer_sess,
eval_model,
eval_sess,
hparams,
summary_writer,
sample_src_data,
sample_ctx_data,
sample_tgt_data,
... | [
"def",
"run_full_eval",
"(",
"model_dir",
",",
"infer_model",
",",
"infer_sess",
",",
"eval_model",
",",
"eval_sess",
",",
"hparams",
",",
"summary_writer",
",",
"sample_src_data",
",",
"sample_ctx_data",
",",
"sample_tgt_data",
",",
"sample_annot_data",
",",
"avg_c... | https://github.com/google/active-qa/blob/bd96fab78255b8ef4f1147f78bd571abf2b919b3/px/nmt/train.py#L223-L276 | |
yt-project/yt | dc7b24f9b266703db4c843e329c6c8644d47b824 | yt/geometry/grid_geometry_handler.py | python | GridIndex._chunk_all | (self, dobj, cache=True, fast_index=None) | [] | def _chunk_all(self, dobj, cache=True, fast_index=None):
gobjs = getattr(dobj._current_chunk, "objs", dobj._chunk_info)
fast_index = fast_index or getattr(dobj._current_chunk, "_fast_index", None)
yield YTDataChunk(dobj, "all", gobjs, dobj.size, cache, fast_index=fast_index) | [
"def",
"_chunk_all",
"(",
"self",
",",
"dobj",
",",
"cache",
"=",
"True",
",",
"fast_index",
"=",
"None",
")",
":",
"gobjs",
"=",
"getattr",
"(",
"dobj",
".",
"_current_chunk",
",",
"\"objs\"",
",",
"dobj",
".",
"_chunk_info",
")",
"fast_index",
"=",
"... | https://github.com/yt-project/yt/blob/dc7b24f9b266703db4c843e329c6c8644d47b824/yt/geometry/grid_geometry_handler.py#L365-L368 | ||||
pytorch/examples | 151944ecaf9ba2c8288ee550143ae7ffdaa90a80 | super_resolution/main.py | python | checkpoint | (epoch) | [] | def checkpoint(epoch):
model_out_path = "model_epoch_{}.pth".format(epoch)
torch.save(model, model_out_path)
print("Checkpoint saved to {}".format(model_out_path)) | [
"def",
"checkpoint",
"(",
"epoch",
")",
":",
"model_out_path",
"=",
"\"model_epoch_{}.pth\"",
".",
"format",
"(",
"epoch",
")",
"torch",
".",
"save",
"(",
"model",
",",
"model_out_path",
")",
"print",
"(",
"\"Checkpoint saved to {}\"",
".",
"format",
"(",
"mod... | https://github.com/pytorch/examples/blob/151944ecaf9ba2c8288ee550143ae7ffdaa90a80/super_resolution/main.py#L75-L78 | ||||
khanhnamle1994/natural-language-processing | 01d450d5ac002b0156ef4cf93a07cb508c1bcdc5 | assignment1/.env/lib/python2.7/site-packages/IPython/config/loader.py | python | LazyConfigValue.prepend | (self, other) | like list.extend, but for the front | like list.extend, but for the front | [
"like",
"list",
".",
"extend",
"but",
"for",
"the",
"front"
] | def prepend(self, other):
"""like list.extend, but for the front"""
self._prepend[:0] = other | [
"def",
"prepend",
"(",
"self",
",",
"other",
")",
":",
"self",
".",
"_prepend",
"[",
":",
"0",
"]",
"=",
"other"
] | https://github.com/khanhnamle1994/natural-language-processing/blob/01d450d5ac002b0156ef4cf93a07cb508c1bcdc5/assignment1/.env/lib/python2.7/site-packages/IPython/config/loader.py#L103-L105 | ||
google/grr | 8ad8a4d2c5a93c92729206b7771af19d92d4f915 | grr/core/grr_response_core/lib/parsers/linux_service_parser.py | python | LinuxXinetdParser._GenService | (self, name, cfg) | return service | [] | def _GenService(self, name, cfg):
# Merge the config values.
service = rdf_client.LinuxServiceInformation(name=name)
service.config = self._GenConfig(cfg)
if service.config.disable == ["no"]:
service.starts = True
service.start_mode = "XINETD"
service.start_after = ["xinetd"]
retur... | [
"def",
"_GenService",
"(",
"self",
",",
"name",
",",
"cfg",
")",
":",
"# Merge the config values.",
"service",
"=",
"rdf_client",
".",
"LinuxServiceInformation",
"(",
"name",
"=",
"name",
")",
"service",
".",
"config",
"=",
"self",
".",
"_GenConfig",
"(",
"c... | https://github.com/google/grr/blob/8ad8a4d2c5a93c92729206b7771af19d92d4f915/grr/core/grr_response_core/lib/parsers/linux_service_parser.py#L263-L271 | |||
Stiivi/bubbles | b3c9332b8a9534655bd77821586e45a5086b1ddc | bubbles/stores.py | python | FileSystemStore.get_object | (self, name) | Returns a CSVSource object with filename constructed from store's
path and extension | Returns a CSVSource object with filename constructed from store's
path and extension | [
"Returns",
"a",
"CSVSource",
"object",
"with",
"filename",
"constructed",
"from",
"store",
"s",
"path",
"and",
"extension"
] | def get_object(self, name):
"""Returns a CSVSource object with filename constructed from store's
path and extension"""
path = os.path.join(self.path, name)
ext = os.path.splitext(name)[1]
ext = ext[1:] if ext else ext
if ext == "csv":
return data_object("csv... | [
"def",
"get_object",
"(",
"self",
",",
"name",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"path",
",",
"name",
")",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"name",
")",
"[",
"1",
"]",
"ext",
"=",
"ex... | https://github.com/Stiivi/bubbles/blob/b3c9332b8a9534655bd77821586e45a5086b1ddc/bubbles/stores.py#L140-L153 | ||
django/django | 0a17666045de6739ae1c2ac695041823d5f827f7 | django/db/migrations/questioner.py | python | InteractiveMigrationQuestioner.ask_auto_now_add_addition | (self, field_name, model_name) | return None | Adding an auto_now_add field to a model. | Adding an auto_now_add field to a model. | [
"Adding",
"an",
"auto_now_add",
"field",
"to",
"a",
"model",
"."
] | def ask_auto_now_add_addition(self, field_name, model_name):
"""Adding an auto_now_add field to a model."""
if not self.dry_run:
choice = self._choice_input(
f"It is impossible to add the field '{field_name}' with "
f"'auto_now_add=True' to {model_name} withou... | [
"def",
"ask_auto_now_add_addition",
"(",
"self",
",",
"field_name",
",",
"model_name",
")",
":",
"if",
"not",
"self",
".",
"dry_run",
":",
"choice",
"=",
"self",
".",
"_choice_input",
"(",
"f\"It is impossible to add the field '{field_name}' with \"",
"f\"'auto_now_add=... | https://github.com/django/django/blob/0a17666045de6739ae1c2ac695041823d5f827f7/django/db/migrations/questioner.py#L227-L245 | |
CvvT/dumpDex | 92ab3b7e996194a06bf1dd5538a4954e8a5ee9c1 | python/idaapi.py | python | isSeg1 | (*args) | return _idaapi.isSeg1(*args) | isSeg1(F) -> bool | isSeg1(F) -> bool | [
"isSeg1",
"(",
"F",
")",
"-",
">",
"bool"
] | def isSeg1(*args):
"""
isSeg1(F) -> bool
"""
return _idaapi.isSeg1(*args) | [
"def",
"isSeg1",
"(",
"*",
"args",
")",
":",
"return",
"_idaapi",
".",
"isSeg1",
"(",
"*",
"args",
")"
] | https://github.com/CvvT/dumpDex/blob/92ab3b7e996194a06bf1dd5538a4954e8a5ee9c1/python/idaapi.py#L22184-L22188 | |
KhronosGroup/NNEF-Tools | c913758ca687dab8cb7b49e8f1556819a2d0ca25 | nnef_tools/io/tf/lite/flatbuffers/QuantizationParameters.py | python | QuantizationParameters.QuantizedDimension | (self) | return 0 | [] | def QuantizedDimension(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
if o != 0:
return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
return 0 | [
"def",
"QuantizedDimension",
"(",
"self",
")",
":",
"o",
"=",
"flatbuffers",
".",
"number_types",
".",
"UOffsetTFlags",
".",
"py_type",
"(",
"self",
".",
"_tab",
".",
"Offset",
"(",
"16",
")",
")",
"if",
"o",
"!=",
"0",
":",
"return",
"self",
".",
"_... | https://github.com/KhronosGroup/NNEF-Tools/blob/c913758ca687dab8cb7b49e8f1556819a2d0ca25/nnef_tools/io/tf/lite/flatbuffers/QuantizationParameters.py#L153-L157 | |||
drj11/pypng | 1b5bc2d7e7a068a2f0b41bfce282349748bf133b | code/png.py | python | Reader._iter_straight_packed | (self, byte_blocks) | Iterator that undoes the effect of filtering;
yields each row as a sequence of packed bytes.
Assumes input is straightlaced.
`byte_blocks` should be an iterable that yields the raw bytes
in blocks of arbitrary size. | Iterator that undoes the effect of filtering;
yields each row as a sequence of packed bytes.
Assumes input is straightlaced.
`byte_blocks` should be an iterable that yields the raw bytes
in blocks of arbitrary size. | [
"Iterator",
"that",
"undoes",
"the",
"effect",
"of",
"filtering",
";",
"yields",
"each",
"row",
"as",
"a",
"sequence",
"of",
"packed",
"bytes",
".",
"Assumes",
"input",
"is",
"straightlaced",
".",
"byte_blocks",
"should",
"be",
"an",
"iterable",
"that",
"yie... | def _iter_straight_packed(self, byte_blocks):
"""Iterator that undoes the effect of filtering;
yields each row as a sequence of packed bytes.
Assumes input is straightlaced.
`byte_blocks` should be an iterable that yields the raw bytes
in blocks of arbitrary size.
"""
... | [
"def",
"_iter_straight_packed",
"(",
"self",
",",
"byte_blocks",
")",
":",
"# length of row, in bytes",
"rb",
"=",
"self",
".",
"row_bytes",
"a",
"=",
"bytearray",
"(",
")",
"# The previous (reconstructed) scanline.",
"# None indicates first line of image.",
"recon",
"=",... | https://github.com/drj11/pypng/blob/1b5bc2d7e7a068a2f0b41bfce282349748bf133b/code/png.py#L1557-L1584 | ||
oilshell/oil | 94388e7d44a9ad879b12615f6203b38596b5a2d3 | Python-2.7.13/Lib/email/parser.py | python | Parser.parse | (self, fp, headersonly=False) | return feedparser.close() | Create a message structure from the data in a file.
Reads all the data from the file and returns the root of the message
structure. Optional headersonly is a flag specifying whether to stop
parsing after reading the headers or not. The default is False,
meaning it parses the entire co... | Create a message structure from the data in a file. | [
"Create",
"a",
"message",
"structure",
"from",
"the",
"data",
"in",
"a",
"file",
"."
] | def parse(self, fp, headersonly=False):
"""Create a message structure from the data in a file.
Reads all the data from the file and returns the root of the message
structure. Optional headersonly is a flag specifying whether to stop
parsing after reading the headers or not. The defaul... | [
"def",
"parse",
"(",
"self",
",",
"fp",
",",
"headersonly",
"=",
"False",
")",
":",
"feedparser",
"=",
"FeedParser",
"(",
"self",
".",
"_class",
")",
"if",
"headersonly",
":",
"feedparser",
".",
"_set_headersonly",
"(",
")",
"while",
"True",
":",
"data",... | https://github.com/oilshell/oil/blob/94388e7d44a9ad879b12615f6203b38596b5a2d3/Python-2.7.13/Lib/email/parser.py#L56-L72 | |
lordmauve/pgzero | 46a889fb918ccd606d39ba63680386d7f8fcbc5a | pgzero/clock.py | python | Clock.schedule | (self, callback, delay) | Schedule callback to be called once, at `delay` seconds from now.
:param callback: A parameterless callable to be called.
:param delay: The delay before the call (in clock time / seconds). | Schedule callback to be called once, at `delay` seconds from now. | [
"Schedule",
"callback",
"to",
"be",
"called",
"once",
"at",
"delay",
"seconds",
"from",
"now",
"."
] | def schedule(self, callback, delay):
"""Schedule callback to be called once, at `delay` seconds from now.
:param callback: A parameterless callable to be called.
:param delay: The delay before the call (in clock time / seconds).
"""
heapq.heappush(self.events, Event(self.t + de... | [
"def",
"schedule",
"(",
"self",
",",
"callback",
",",
"delay",
")",
":",
"heapq",
".",
"heappush",
"(",
"self",
".",
"events",
",",
"Event",
"(",
"self",
".",
"t",
"+",
"delay",
",",
"callback",
",",
"None",
")",
")"
] | https://github.com/lordmauve/pgzero/blob/46a889fb918ccd606d39ba63680386d7f8fcbc5a/pgzero/clock.py#L98-L105 | ||
pypa/pipenv | b21baade71a86ab3ee1429f71fbc14d4f95fb75d | pipenv/vendor/vistir/path.py | python | get_converted_relative_path | (path, relative_to=None) | return relpath_s | Convert `path` to be relative.
Given a vague relative path, return the path relative to the given
location.
:param str path: The location of a target path
:param str relative_to: The starting path to build against, optional
:returns: A relative posix-style path with a leading `./`
This perfor... | Convert `path` to be relative. | [
"Convert",
"path",
"to",
"be",
"relative",
"."
] | def get_converted_relative_path(path, relative_to=None):
# type: (TPath, Optional[TPath]) -> str
"""Convert `path` to be relative.
Given a vague relative path, return the path relative to the given
location.
:param str path: The location of a target path
:param str relative_to: The starting pa... | [
"def",
"get_converted_relative_path",
"(",
"path",
",",
"relative_to",
"=",
"None",
")",
":",
"# type: (TPath, Optional[TPath]) -> str",
"from",
".",
"misc",
"import",
"to_text",
",",
"to_bytes",
"# noqa",
"if",
"not",
"relative_to",
":",
"relative_to",
"=",
"os",
... | https://github.com/pypa/pipenv/blob/b21baade71a86ab3ee1429f71fbc14d4f95fb75d/pipenv/vendor/vistir/path.py#L575-L628 | |
twilio/twilio-python | 6e1e811ea57a1edfadd5161ace87397c563f6915 | twilio/rest/verify/v2/service/entity/__init__.py | python | EntityInstance.links | (self) | return self._properties['links'] | :returns: Nested resource URLs.
:rtype: unicode | :returns: Nested resource URLs.
:rtype: unicode | [
":",
"returns",
":",
"Nested",
"resource",
"URLs",
".",
":",
"rtype",
":",
"unicode"
] | def links(self):
"""
:returns: Nested resource URLs.
:rtype: unicode
"""
return self._properties['links'] | [
"def",
"links",
"(",
"self",
")",
":",
"return",
"self",
".",
"_properties",
"[",
"'links'",
"]"
] | https://github.com/twilio/twilio-python/blob/6e1e811ea57a1edfadd5161ace87397c563f6915/twilio/rest/verify/v2/service/entity/__init__.py#L418-L423 | |
plasticityai/magnitude | 7ac0baeaf181263b661c3ae00643d21e3fd90216 | pymagnitude/third_party/_apsw/tools/shell.py | python | Shell.command_backup | (self, cmd) | backup ?DB? FILE: Backup DB (default "main") to FILE
Copies the contents of the current database to FILE
overwriting whatever was in FILE. If you have attached databases
then you can specify their name instead of the default of "main".
The backup is done at the page level - SQLite cop... | backup ?DB? FILE: Backup DB (default "main") to FILE | [
"backup",
"?DB?",
"FILE",
":",
"Backup",
"DB",
"(",
"default",
"main",
")",
"to",
"FILE"
] | def command_backup(self, cmd):
"""backup ?DB? FILE: Backup DB (default "main") to FILE
Copies the contents of the current database to FILE
overwriting whatever was in FILE. If you have attached databases
then you can specify their name instead of the default of "main".
The bac... | [
"def",
"command_backup",
"(",
"self",
",",
"cmd",
")",
":",
"dbname",
"=",
"\"main\"",
"if",
"len",
"(",
"cmd",
")",
"==",
"1",
":",
"fname",
"=",
"cmd",
"[",
"0",
"]",
"elif",
"len",
"(",
"cmd",
")",
"==",
"2",
":",
"dbname",
"=",
"cmd",
"[",
... | https://github.com/plasticityai/magnitude/blob/7ac0baeaf181263b661c3ae00643d21e3fd90216/pymagnitude/third_party/_apsw/tools/shell.py#L944-L969 | ||
zakird/pyad | d95ff67745065cafca4f2653aab1fbce2df91fb9 | pyad/pyadutils.py | python | convert_datetime | (adsi_time_com_obj) | return datetime.datetime.fromtimestamp(date_value) | Converts 64-bit integer COM object representing time into a python datetime object. | Converts 64-bit integer COM object representing time into a python datetime object. | [
"Converts",
"64",
"-",
"bit",
"integer",
"COM",
"object",
"representing",
"time",
"into",
"a",
"python",
"datetime",
"object",
"."
] | def convert_datetime(adsi_time_com_obj):
"""Converts 64-bit integer COM object representing time into a python datetime object."""
# credit goes to John Nielsen who documented this at
# http://docs.activestate.com/activepython/2.6/pywin32/html/com/help/active_directory.html.
high_part = int(adsi_time_c... | [
"def",
"convert_datetime",
"(",
"adsi_time_com_obj",
")",
":",
"# credit goes to John Nielsen who documented this at",
"# http://docs.activestate.com/activepython/2.6/pywin32/html/com/help/active_directory.html.",
"high_part",
"=",
"int",
"(",
"adsi_time_com_obj",
".",
"highpart",
")",... | https://github.com/zakird/pyad/blob/d95ff67745065cafca4f2653aab1fbce2df91fb9/pyad/pyadutils.py#L81-L97 | |
QCoDeS/Qcodes | 3cda2cef44812e2aa4672781f2423bf5f816f9f9 | qcodes/dataset/measurements.py | python | DataSaver._validate_result_types | (
results_dict: Mapping[ParamSpecBase, np.ndarray]) | Validate the type of the results | Validate the type of the results | [
"Validate",
"the",
"type",
"of",
"the",
"results"
] | def _validate_result_types(
results_dict: Mapping[ParamSpecBase, np.ndarray]) -> None:
"""
Validate the type of the results
"""
allowed_kinds = {'numeric': 'iuf', 'text': 'SU', 'array': 'iufcSUmM',
'complex': 'c'}
for ps, vals in results_dic... | [
"def",
"_validate_result_types",
"(",
"results_dict",
":",
"Mapping",
"[",
"ParamSpecBase",
",",
"np",
".",
"ndarray",
"]",
")",
"->",
"None",
":",
"allowed_kinds",
"=",
"{",
"'numeric'",
":",
"'iuf'",
",",
"'text'",
":",
"'SU'",
",",
"'array'",
":",
"'iuf... | https://github.com/QCoDeS/Qcodes/blob/3cda2cef44812e2aa4672781f2423bf5f816f9f9/qcodes/dataset/measurements.py#L434-L447 | ||
inasafe/inasafe | 355eb2ce63f516b9c26af0c86a24f99e53f63f87 | safe/gui/tools/minimum_needs/needs_manager_dialog.py | python | NeedsManagerDialog.page_changed | (self, index) | Slot for when tab changes in the stacked widget changes.
:param index: Index of the now active tab.
:type index: int | Slot for when tab changes in the stacked widget changes. | [
"Slot",
"for",
"when",
"tab",
"changes",
"in",
"the",
"stacked",
"widget",
"changes",
"."
] | def page_changed(self, index):
"""Slot for when tab changes in the stacked widget changes.
:param index: Index of the now active tab.
:type index: int
"""
if index == 0: # profile edit page
for item in self.resource_editing_buttons:
item.hide()
... | [
"def",
"page_changed",
"(",
"self",
",",
"index",
")",
":",
"if",
"index",
"==",
"0",
":",
"# profile edit page",
"for",
"item",
"in",
"self",
".",
"resource_editing_buttons",
":",
"item",
".",
"hide",
"(",
")",
"for",
"item",
"in",
"self",
".",
"profile... | https://github.com/inasafe/inasafe/blob/355eb2ce63f516b9c26af0c86a24f99e53f63f87/safe/gui/tools/minimum_needs/needs_manager_dialog.py#L765-L784 | ||
replit-archive/empythoned | 977ec10ced29a3541a4973dc2b59910805695752 | cpython/Lib/pydoc.py | python | HTMLDoc.page | (self, title, contents) | return '''
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: %s</title>
</head><body bgcolor="#f0f0f8">
%s
</body></html>''' % (title, contents) | Format an HTML page. | Format an HTML page. | [
"Format",
"an",
"HTML",
"page",
"."
] | def page(self, title, contents):
"""Format an HTML page."""
return '''
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: %s</title>
</head><body bgcolor="#f0f0f8">
%s
</body></html>''' % (title, contents) | [
"def",
"page",
"(",
"self",
",",
"title",
",",
"contents",
")",
":",
"return",
"'''\n<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n<html><head><title>Python: %s</title>\n</head><body bgcolor=\"#f0f0f8\">\n%s\n</body></html>'''",
"%",
"(",
"title",
",",
"contents",... | https://github.com/replit-archive/empythoned/blob/977ec10ced29a3541a4973dc2b59910805695752/cpython/Lib/pydoc.py#L425-L432 | |
tkarras/progressive_growing_of_gans | 2504c3f3cb98ca58751610ad61fa1097313152bd | dataset_tool.py | python | create_celeba | (tfrecord_dir, celeba_dir, cx=89, cy=121) | [] | def create_celeba(tfrecord_dir, celeba_dir, cx=89, cy=121):
print('Loading CelebA from "%s"' % celeba_dir)
glob_pattern = os.path.join(celeba_dir, 'img_align_celeba_png', '*.png')
image_filenames = sorted(glob.glob(glob_pattern))
expected_images = 202599
if len(image_filenames) != expected_images:
... | [
"def",
"create_celeba",
"(",
"tfrecord_dir",
",",
"celeba_dir",
",",
"cx",
"=",
"89",
",",
"cy",
"=",
"121",
")",
":",
"print",
"(",
"'Loading CelebA from \"%s\"'",
"%",
"celeba_dir",
")",
"glob_pattern",
"=",
"os",
".",
"path",
".",
"join",
"(",
"celeba_d... | https://github.com/tkarras/progressive_growing_of_gans/blob/2504c3f3cb98ca58751610ad61fa1097313152bd/dataset_tool.py#L435-L450 | ||||
kamalgill/flask-appengine-template | 11760f83faccbb0d0afe416fc58e67ecfb4643c2 | src/lib/werkzeug/debug/tbtools.py | python | Line.classes | (self) | return rv | [] | def classes(self):
rv = ['line']
if self.in_frame:
rv.append('in-frame')
if self.current:
rv.append('current')
return rv | [
"def",
"classes",
"(",
"self",
")",
":",
"rv",
"=",
"[",
"'line'",
"]",
"if",
"self",
".",
"in_frame",
":",
"rv",
".",
"append",
"(",
"'in-frame'",
")",
"if",
"self",
".",
"current",
":",
"rv",
".",
"append",
"(",
"'current'",
")",
"return",
"rv"
] | https://github.com/kamalgill/flask-appengine-template/blob/11760f83faccbb0d0afe416fc58e67ecfb4643c2/src/lib/werkzeug/debug/tbtools.py#L200-L206 | |||
ilayn/harold | 2bfa00fca4549313d47386991a27c84c8fc91637 | harold/_polynomial_ops.py | python | haroldpoly | (rootlist) | Takes a 1D array-like numerical elements as roots and forms the polynomial | Takes a 1D array-like numerical elements as roots and forms the polynomial | [
"Takes",
"a",
"1D",
"array",
"-",
"like",
"numerical",
"elements",
"as",
"roots",
"and",
"forms",
"the",
"polynomial"
] | def haroldpoly(rootlist):
"""
Takes a 1D array-like numerical elements as roots and forms the polynomial
"""
if isinstance(rootlist, collections.abc.Iterable):
r = np.array([x for x in rootlist], dtype=complex)
else:
raise TypeError('The argument must be something iterable,\nsuch as ... | [
"def",
"haroldpoly",
"(",
"rootlist",
")",
":",
"if",
"isinstance",
"(",
"rootlist",
",",
"collections",
".",
"abc",
".",
"Iterable",
")",
":",
"r",
"=",
"np",
".",
"array",
"(",
"[",
"x",
"for",
"x",
"in",
"rootlist",
"]",
",",
"dtype",
"=",
"comp... | https://github.com/ilayn/harold/blob/2bfa00fca4549313d47386991a27c84c8fc91637/harold/_polynomial_ops.py#L319-L342 | ||
huggingface/transformers | 623b4f7c63f60cce917677ee704d6c93ee960b4b | src/transformers/models/fsmt/modeling_fsmt.py | python | _reorder_buffer | (attn_cache, new_order) | return attn_cache | [] | def _reorder_buffer(attn_cache, new_order):
for k, input_buffer_k in attn_cache.items():
if input_buffer_k is not None:
attn_cache[k] = input_buffer_k.index_select(0, new_order)
return attn_cache | [
"def",
"_reorder_buffer",
"(",
"attn_cache",
",",
"new_order",
")",
":",
"for",
"k",
",",
"input_buffer_k",
"in",
"attn_cache",
".",
"items",
"(",
")",
":",
"if",
"input_buffer_k",
"is",
"not",
"None",
":",
"attn_cache",
"[",
"k",
"]",
"=",
"input_buffer_k... | https://github.com/huggingface/transformers/blob/623b4f7c63f60cce917677ee704d6c93ee960b4b/src/transformers/models/fsmt/modeling_fsmt.py#L799-L803 | |||
sagemath/sage | f9b2db94f675ff16963ccdefba4f1a3393b3fe0d | src/sage/algebras/quantum_groups/ace_quantum_onsager.py | python | ACEQuantumOnsagerAlgebra._dagger_on_basis | (self, x) | return self.prod(A[tw(m)]**e for m,e in reversed(x._sorted_items())) | r"""
Return the action of the `\dagger` antiautomorphism on the basis element
indexed by ``x``.
EXAMPLES::
sage: A = algebras.AlternatingCentralExtensionQuantumOnsager(QQ)
sage: I = A._indices.monoid_generators()
sage: A._dagger_on_basis(I[0,1] * I[1,-1] * I... | r"""
Return the action of the `\dagger` antiautomorphism on the basis element
indexed by ``x``. | [
"r",
"Return",
"the",
"action",
"of",
"the",
"\\",
"dagger",
"antiautomorphism",
"on",
"the",
"basis",
"element",
"indexed",
"by",
"x",
"."
] | def _dagger_on_basis(self, x):
r"""
Return the action of the `\dagger` antiautomorphism on the basis element
indexed by ``x``.
EXAMPLES::
sage: A = algebras.AlternatingCentralExtensionQuantumOnsager(QQ)
sage: I = A._indices.monoid_generators()
sage: ... | [
"def",
"_dagger_on_basis",
"(",
"self",
",",
"x",
")",
":",
"def",
"tw",
"(",
"m",
")",
":",
"if",
"m",
"[",
"0",
"]",
"==",
"0",
":",
"return",
"(",
"2",
",",
"m",
"[",
"1",
"]",
")",
"if",
"m",
"[",
"0",
"]",
"==",
"1",
":",
"return",
... | https://github.com/sagemath/sage/blob/f9b2db94f675ff16963ccdefba4f1a3393b3fe0d/src/sage/algebras/quantum_groups/ace_quantum_onsager.py#L620-L651 | |
aaronportnoy/toolbag | 2d39457a7617b2f334d203d8c8cf88a5a25ef1fa | toolbag/agent/dbg/cobra/cluster.py | python | ClusterServer.failWork | (self, work) | This is called for a work unit that is in a failed state. This is most
commonly that the work() method has raised an exception. | This is called for a work unit that is in a failed state. This is most
commonly that the work() method has raised an exception. | [
"This",
"is",
"called",
"for",
"a",
"work",
"unit",
"that",
"is",
"in",
"a",
"failed",
"state",
".",
"This",
"is",
"most",
"commonly",
"that",
"the",
"work",
"()",
"method",
"has",
"raised",
"an",
"exception",
"."
] | def failWork(self, work):
"""
This is called for a work unit that is in a failed state. This is most
commonly that the work() method has raised an exception.
"""
self.__cleanWork(work.id)
if self.callback:
self.callback.workFailed(self, work) | [
"def",
"failWork",
"(",
"self",
",",
"work",
")",
":",
"self",
".",
"__cleanWork",
"(",
"work",
".",
"id",
")",
"if",
"self",
".",
"callback",
":",
"self",
".",
"callback",
".",
"workFailed",
"(",
"self",
",",
"work",
")"
] | https://github.com/aaronportnoy/toolbag/blob/2d39457a7617b2f334d203d8c8cf88a5a25ef1fa/toolbag/agent/dbg/cobra/cluster.py#L310-L317 | ||
postlund/pyatv | 4ed1f5539f37d86d80272663d1f2ea34a6c41ec4 | pyatv/protocols/companion/protocol.py | python | CompanionProtocol.send_opack | (self, frame_type: FrameType, data: Dict[str, Any]) | Send data encoded with OPACK. | Send data encoded with OPACK. | [
"Send",
"data",
"encoded",
"with",
"OPACK",
"."
] | def send_opack(self, frame_type: FrameType, data: Dict[str, Any]) -> None:
"""Send data encoded with OPACK."""
# Add XID if not present
if "_x" not in data:
data["_x"] = self._xid
self._xid += 1
_LOGGER.debug("Send OPACK: %s", data)
self.connection.send(f... | [
"def",
"send_opack",
"(",
"self",
",",
"frame_type",
":",
"FrameType",
",",
"data",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"None",
":",
"# Add XID if not present",
"if",
"\"_x\"",
"not",
"in",
"data",
":",
"data",
"[",
"\"_x\"",
"]",
"=",... | https://github.com/postlund/pyatv/blob/4ed1f5539f37d86d80272663d1f2ea34a6c41ec4/pyatv/protocols/companion/protocol.py#L182-L190 | ||
prompt-toolkit/ptpython | d8b5c90d20cc1e8d88837aa7163289950c231f74 | ptpython/python_input.py | python | PythonInput.selected_option | (self) | Return the currently selected option. | Return the currently selected option. | [
"Return",
"the",
"currently",
"selected",
"option",
"."
] | def selected_option(self) -> Option:
"Return the currently selected option."
i = 0
for category in self.options:
for o in category.options:
if i == self.selected_option_index:
return o
else:
i += 1
raise... | [
"def",
"selected_option",
"(",
"self",
")",
"->",
"Option",
":",
"i",
"=",
"0",
"for",
"category",
"in",
"self",
".",
"options",
":",
"for",
"o",
"in",
"category",
".",
"options",
":",
"if",
"i",
"==",
"self",
".",
"selected_option_index",
":",
"return... | https://github.com/prompt-toolkit/ptpython/blob/d8b5c90d20cc1e8d88837aa7163289950c231f74/ptpython/python_input.py#L411-L421 | ||
TengXiaoDai/DistributedCrawling | f5c2439e6ce68dd9b49bde084d76473ff9ed4963 | Lib/shutil.py | python | copyfileobj | (fsrc, fdst, length=16*1024) | copy data from file-like object fsrc to file-like object fdst | copy data from file-like object fsrc to file-like object fdst | [
"copy",
"data",
"from",
"file",
"-",
"like",
"object",
"fsrc",
"to",
"file",
"-",
"like",
"object",
"fdst"
] | def copyfileobj(fsrc, fdst, length=16*1024):
"""copy data from file-like object fsrc to file-like object fdst"""
while 1:
buf = fsrc.read(length)
if not buf:
break
fdst.write(buf) | [
"def",
"copyfileobj",
"(",
"fsrc",
",",
"fdst",
",",
"length",
"=",
"16",
"*",
"1024",
")",
":",
"while",
"1",
":",
"buf",
"=",
"fsrc",
".",
"read",
"(",
"length",
")",
"if",
"not",
"buf",
":",
"break",
"fdst",
".",
"write",
"(",
"buf",
")"
] | https://github.com/TengXiaoDai/DistributedCrawling/blob/f5c2439e6ce68dd9b49bde084d76473ff9ed4963/Lib/shutil.py#L76-L82 | ||
geometalab/Vector-Tiles-Reader-QGIS-Plugin | a31ae86959c8f3b7d6f332f84191cd7ca4683e1d | plugin/vt_reader.py | python | VtReader._load_tiles | (self) | [] | def _load_tiles(self):
if not self._source or self.connection()["type"] == ConnectionTypes.MBTiles:
# recreate source to assure the source belongs to the new thread, SQLite3 isn't happy about it otherwise
self._source = self._create_source(self.connection())
try:
sel... | [
"def",
"_load_tiles",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_source",
"or",
"self",
".",
"connection",
"(",
")",
"[",
"\"type\"",
"]",
"==",
"ConnectionTypes",
".",
"MBTiles",
":",
"# recreate source to assure the source belongs to the new thread, SQLite... | https://github.com/geometalab/Vector-Tiles-Reader-QGIS-Plugin/blob/a31ae86959c8f3b7d6f332f84191cd7ca4683e1d/plugin/vt_reader.py#L231-L306 | ||||
gwpy/gwpy | 82becd78d166a32985cb657a54d0d39f6a207739 | gwpy/io/datafind.py | python | find_best_frametype | (channel, start, end,
frametype_match=None, allow_tape=True,
connection=None, host=None, port=None) | Intelligently select the best frametype from which to read this channel
Parameters
----------
channel : `str`, `~gwpy.detector.Channel`
the channel to be found
start : `~gwpy.time.LIGOTimeGPS`, `float`, `str`
GPS start time of period of interest,
any input parseable by `~gwpy.t... | Intelligently select the best frametype from which to read this channel | [
"Intelligently",
"select",
"the",
"best",
"frametype",
"from",
"which",
"to",
"read",
"this",
"channel"
] | def find_best_frametype(channel, start, end,
frametype_match=None, allow_tape=True,
connection=None, host=None, port=None):
"""Intelligently select the best frametype from which to read this channel
Parameters
----------
channel : `str`, `~gwpy.detector.C... | [
"def",
"find_best_frametype",
"(",
"channel",
",",
"start",
",",
"end",
",",
"frametype_match",
"=",
"None",
",",
"allow_tape",
"=",
"True",
",",
"connection",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
")",
":",
"try",
":",
"retu... | https://github.com/gwpy/gwpy/blob/82becd78d166a32985cb657a54d0d39f6a207739/gwpy/io/datafind.py#L614-L678 | ||
1040003585/WebScrapingWithPython | a770fa5b03894076c8c9539b1ffff34424ffc016 | portia_examle/lib/python2.7/site-packages/pip/_vendor/pkg_resources/__init__.py | python | find_eggs_in_zip | (importer, path_item, only=False) | Find eggs in zip files; possibly multiple nested eggs. | Find eggs in zip files; possibly multiple nested eggs. | [
"Find",
"eggs",
"in",
"zip",
"files",
";",
"possibly",
"multiple",
"nested",
"eggs",
"."
] | def find_eggs_in_zip(importer, path_item, only=False):
"""
Find eggs in zip files; possibly multiple nested eggs.
"""
if importer.archive.endswith('.whl'):
# wheels are not supported with this finder
# they don't have PKG-INFO metadata, and won't ever contain eggs
return
meta... | [
"def",
"find_eggs_in_zip",
"(",
"importer",
",",
"path_item",
",",
"only",
"=",
"False",
")",
":",
"if",
"importer",
".",
"archive",
".",
"endswith",
"(",
"'.whl'",
")",
":",
"# wheels are not supported with this finder",
"# they don't have PKG-INFO metadata, and won't ... | https://github.com/1040003585/WebScrapingWithPython/blob/a770fa5b03894076c8c9539b1ffff34424ffc016/portia_examle/lib/python2.7/site-packages/pip/_vendor/pkg_resources/__init__.py#L1940-L1958 | ||
openshift/openshift-tools | 1188778e728a6e4781acf728123e5b356380fe6f | openshift/installer/vendored/openshift-ansible-3.11.28-1/roles/lib_openshift/src/lib/deploymentconfig.py | python | DeploymentConfig.exists_env_value | (self, key, value) | return False | return whether a key, value pair exists | return whether a key, value pair exists | [
"return",
"whether",
"a",
"key",
"value",
"pair",
"exists"
] | def exists_env_value(self, key, value):
''' return whether a key, value pair exists '''
results = self.get_env_vars()
if not results:
return False
for result in results:
if result['name'] == key:
if 'value' not in result:
if v... | [
"def",
"exists_env_value",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"results",
"=",
"self",
".",
"get_env_vars",
"(",
")",
"if",
"not",
"results",
":",
"return",
"False",
"for",
"result",
"in",
"results",
":",
"if",
"result",
"[",
"'name'",
"]"... | https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/openshift/installer/vendored/openshift-ansible-3.11.28-1/roles/lib_openshift/src/lib/deploymentconfig.py#L84-L98 | |
wxWidgets/Phoenix | b2199e299a6ca6d866aa6f3d0888499136ead9d6 | wx/lib/agw/customtreectrl.py | python | CustomTreeCtrl.ChildrenClosing | (self, item) | We are about to destroy the item children.
:param `item`: an instance of :class:`GenericTreeItem`. | We are about to destroy the item children. | [
"We",
"are",
"about",
"to",
"destroy",
"the",
"item",
"children",
"."
] | def ChildrenClosing(self, item):
"""
We are about to destroy the item children.
:param `item`: an instance of :class:`GenericTreeItem`.
"""
if self._editCtrl is not None and item != self._editCtrl.item() and self.IsDescendantOf(item, self._editCtrl.item()):
self._ed... | [
"def",
"ChildrenClosing",
"(",
"self",
",",
"item",
")",
":",
"if",
"self",
".",
"_editCtrl",
"is",
"not",
"None",
"and",
"item",
"!=",
"self",
".",
"_editCtrl",
".",
"item",
"(",
")",
"and",
"self",
".",
"IsDescendantOf",
"(",
"item",
",",
"self",
"... | https://github.com/wxWidgets/Phoenix/blob/b2199e299a6ca6d866aa6f3d0888499136ead9d6/wx/lib/agw/customtreectrl.py#L5427-L5446 | ||
jason9693/MusicTransformer-tensorflow2.0 | f7c06c0cb2e9cdddcbf6db779cb39cd650282778 | custom/callback.py | python | CustomSchedule.__call__ | (self, step) | return tf.math.rsqrt(self.d_model) * tf.math.minimum(arg1, arg2) | [] | def __call__(self, step):
arg1 = tf.math.rsqrt(step)
arg2 = step * (self.warmup_steps ** -1.5)
return tf.math.rsqrt(self.d_model) * tf.math.minimum(arg1, arg2) | [
"def",
"__call__",
"(",
"self",
",",
"step",
")",
":",
"arg1",
"=",
"tf",
".",
"math",
".",
"rsqrt",
"(",
"step",
")",
"arg2",
"=",
"step",
"*",
"(",
"self",
".",
"warmup_steps",
"**",
"-",
"1.5",
")",
"return",
"tf",
".",
"math",
".",
"rsqrt",
... | https://github.com/jason9693/MusicTransformer-tensorflow2.0/blob/f7c06c0cb2e9cdddcbf6db779cb39cd650282778/custom/callback.py#L66-L70 | |||
trigger/trigger | c089f761a150f537f7e3201422a3964ec52ff245 | trigger/netdevices/__init__.py | python | NetDevice.can_ssh_async | (self) | return self._can_ssh('async') | Am I enabled to use SSH async? | Am I enabled to use SSH async? | [
"Am",
"I",
"enabled",
"to",
"use",
"SSH",
"async?"
] | def can_ssh_async(self):
"""Am I enabled to use SSH async?"""
return self._can_ssh('async') | [
"def",
"can_ssh_async",
"(",
"self",
")",
":",
"return",
"self",
".",
"_can_ssh",
"(",
"'async'",
")"
] | https://github.com/trigger/trigger/blob/c089f761a150f537f7e3201422a3964ec52ff245/trigger/netdevices/__init__.py#L824-L826 | |
deepfakes/faceswap | 09c7d8aca3c608d1afad941ea78e9fd9b64d9219 | lib/gui/display_analysis.py | python | StatsData._resize_frame | (self, event) | Resize the options frame to fit the canvas.
Parameters
----------
event: `tkinter.Event`
The tkinter resize event | Resize the options frame to fit the canvas. | [
"Resize",
"the",
"options",
"frame",
"to",
"fit",
"the",
"canvas",
"."
] | def _resize_frame(self, event):
""" Resize the options frame to fit the canvas.
Parameters
----------
event: `tkinter.Event`
The tkinter resize event
"""
logger.debug("Resize Analysis Frame")
canvas_width = event.width
canvas_height = event.he... | [
"def",
"_resize_frame",
"(",
"self",
",",
"event",
")",
":",
"logger",
".",
"debug",
"(",
"\"Resize Analysis Frame\"",
")",
"canvas_width",
"=",
"event",
".",
"width",
"canvas_height",
"=",
"event",
".",
"height",
"self",
".",
"_canvas",
".",
"itemconfig",
"... | https://github.com/deepfakes/faceswap/blob/09c7d8aca3c608d1afad941ea78e9fd9b64d9219/lib/gui/display_analysis.py#L416-L428 | ||
markovmodel/PyEMMA | e9d08d715dde17ceaa96480a9ab55d5e87d3a4b3 | pyemma/coordinates/data/_base/datasource.py | python | DataSourceIterator._itraj | (self, value) | Reader-internal property that tracks the upcoming trajectory index. Should not be used within iterator loop.
Parameters
----------
value : int
The upcoming trajectory index. | Reader-internal property that tracks the upcoming trajectory index. Should not be used within iterator loop.
Parameters
----------
value : int
The upcoming trajectory index. | [
"Reader",
"-",
"internal",
"property",
"that",
"tracks",
"the",
"upcoming",
"trajectory",
"index",
".",
"Should",
"not",
"be",
"used",
"within",
"iterator",
"loop",
".",
"Parameters",
"----------",
"value",
":",
"int",
"The",
"upcoming",
"trajectory",
"index",
... | def _itraj(self, value):
"""
Reader-internal property that tracks the upcoming trajectory index. Should not be used within iterator loop.
Parameters
----------
value : int
The upcoming trajectory index.
"""
if value != self._selected_itraj:
... | [
"def",
"_itraj",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"!=",
"self",
".",
"_selected_itraj",
":",
"self",
".",
"state",
".",
"itraj",
"=",
"value",
"# TODO: this side effect is unexpected.",
"self",
".",
"state",
".",
"t",
"=",
"0"
] | https://github.com/markovmodel/PyEMMA/blob/e9d08d715dde17ceaa96480a9ab55d5e87d3a4b3/pyemma/coordinates/data/_base/datasource.py#L865-L876 | ||
misterch0c/shadowbroker | e3a069bea47a2c1009697941ac214adc6f90aa8d | windows/Resources/Python/Core/Lib/email/base64mime.py | python | header_encode | (header, charset='iso-8859-1', keep_eols=False, maxlinelen=76, eol=NL) | return joiner.join(lines) | r"""Encode a single header line with Base64 encoding in a given charset.
Defined in RFC 2045, this Base64 encoding is identical to normal Base64
encoding, except that each line must be intelligently wrapped (respecting
the Base64 encoding), and subsequent lines must start with a space.
charset... | r"""Encode a single header line with Base64 encoding in a given charset.
Defined in RFC 2045, this Base64 encoding is identical to normal Base64
encoding, except that each line must be intelligently wrapped (respecting
the Base64 encoding), and subsequent lines must start with a space.
charset... | [
"r",
"Encode",
"a",
"single",
"header",
"line",
"with",
"Base64",
"encoding",
"in",
"a",
"given",
"charset",
".",
"Defined",
"in",
"RFC",
"2045",
"this",
"Base64",
"encoding",
"is",
"identical",
"to",
"normal",
"Base64",
"encoding",
"except",
"that",
"each",... | def header_encode(header, charset='iso-8859-1', keep_eols=False, maxlinelen=76, eol=NL):
r"""Encode a single header line with Base64 encoding in a given charset.
Defined in RFC 2045, this Base64 encoding is identical to normal Base64
encoding, except that each line must be intelligently wrapped (respec... | [
"def",
"header_encode",
"(",
"header",
",",
"charset",
"=",
"'iso-8859-1'",
",",
"keep_eols",
"=",
"False",
",",
"maxlinelen",
"=",
"76",
",",
"eol",
"=",
"NL",
")",
":",
"if",
"not",
"header",
":",
"return",
"header",
"if",
"not",
"keep_eols",
":",
"h... | https://github.com/misterch0c/shadowbroker/blob/e3a069bea47a2c1009697941ac214adc6f90aa8d/windows/Resources/Python/Core/Lib/email/base64mime.py#L52-L95 | |
openstack/manila | 142990edc027e14839d5deaf4954dd6fc88de15e | manila/api/v1/share_snapshots.py | python | ShareSnapshotMixin.update | (self, req, id, body) | return self._view_builder.detail(req, snapshot) | Update a snapshot. | Update a snapshot. | [
"Update",
"a",
"snapshot",
"."
] | def update(self, req, id, body):
"""Update a snapshot."""
context = req.environ['manila.context']
if not body or 'snapshot' not in body:
raise exc.HTTPUnprocessableEntity()
snapshot_data = body['snapshot']
valid_update_keys = (
'display_name',
... | [
"def",
"update",
"(",
"self",
",",
"req",
",",
"id",
",",
"body",
")",
":",
"context",
"=",
"req",
".",
"environ",
"[",
"'manila.context'",
"]",
"if",
"not",
"body",
"or",
"'snapshot'",
"not",
"in",
"body",
":",
"raise",
"exc",
".",
"HTTPUnprocessableE... | https://github.com/openstack/manila/blob/142990edc027e14839d5deaf4954dd6fc88de15e/manila/api/v1/share_snapshots.py#L146-L171 | |
ping/instagram_private_api | 0fda0369ac02bc03d56f5f3f99bc9de2cc25ffaa | instagram_private_api/utils.py | python | chunk_generator | (chunk_count, chunk_size, file_data) | Generic chunk generator logic
:param chunk_count: Number of chunks wanted
:param chunk_size: Size of each chunk
:param file_data: bytes to be split into chunk
:return: | Generic chunk generator logic | [
"Generic",
"chunk",
"generator",
"logic"
] | def chunk_generator(chunk_count, chunk_size, file_data):
"""
Generic chunk generator logic
:param chunk_count: Number of chunks wanted
:param chunk_size: Size of each chunk
:param file_data: bytes to be split into chunk
:return:
"""
try:
total_len = len(file_data)
is_fp ... | [
"def",
"chunk_generator",
"(",
"chunk_count",
",",
"chunk_size",
",",
"file_data",
")",
":",
"try",
":",
"total_len",
"=",
"len",
"(",
"file_data",
")",
"is_fp",
"=",
"False",
"except",
"TypeError",
":",
"total_len",
"=",
"get_file_size",
"(",
"file_data",
"... | https://github.com/ping/instagram_private_api/blob/0fda0369ac02bc03d56f5f3f99bc9de2cc25ffaa/instagram_private_api/utils.py#L81-L104 | ||
facelessuser/RegReplace | c127d48c9f81a610eb01dbd78f4cc40182ab6800 | support.py | python | is_installed_by_package_control | () | return str(__pc_name__ in set(settings.get('installed_packages', []))) | Check if installed by package control. | Check if installed by package control. | [
"Check",
"if",
"installed",
"by",
"package",
"control",
"."
] | def is_installed_by_package_control():
"""Check if installed by package control."""
settings = sublime.load_settings('Package Control.sublime-settings')
return str(__pc_name__ in set(settings.get('installed_packages', []))) | [
"def",
"is_installed_by_package_control",
"(",
")",
":",
"settings",
"=",
"sublime",
".",
"load_settings",
"(",
"'Package Control.sublime-settings'",
")",
"return",
"str",
"(",
"__pc_name__",
"in",
"set",
"(",
"settings",
".",
"get",
"(",
"'installed_packages'",
","... | https://github.com/facelessuser/RegReplace/blob/c127d48c9f81a610eb01dbd78f4cc40182ab6800/support.py#L70-L74 | |
khanhnamle1994/natural-language-processing | 01d450d5ac002b0156ef4cf93a07cb508c1bcdc5 | assignment1/.env/lib/python2.7/site-packages/IPython/html/services/notebooks/filenbmanager.py | python | FileNotebookManager.is_hidden | (self, path) | return is_hidden(os_path, self.notebook_dir) | Does the API style path correspond to a hidden directory or file?
Parameters
----------
path : string
The path to check. This is an API path (`/` separated,
relative to base notebook-dir).
Returns
-------
exists : bool
... | Does the API style path correspond to a hidden directory or file?
Parameters
----------
path : string
The path to check. This is an API path (`/` separated,
relative to base notebook-dir).
Returns
-------
exists : bool
... | [
"Does",
"the",
"API",
"style",
"path",
"correspond",
"to",
"a",
"hidden",
"directory",
"or",
"file?",
"Parameters",
"----------",
"path",
":",
"string",
"The",
"path",
"to",
"check",
".",
"This",
"is",
"an",
"API",
"path",
"(",
"/",
"separated",
"relative"... | def is_hidden(self, path):
"""Does the API style path correspond to a hidden directory or file?
Parameters
----------
path : string
The path to check. This is an API path (`/` separated,
relative to base notebook-dir).
Returns
---... | [
"def",
"is_hidden",
"(",
"self",
",",
"path",
")",
":",
"path",
"=",
"path",
".",
"strip",
"(",
"'/'",
")",
"os_path",
"=",
"self",
".",
"_get_os_path",
"(",
"path",
"=",
"path",
")",
"return",
"is_hidden",
"(",
"os_path",
",",
"self",
".",
"notebook... | https://github.com/khanhnamle1994/natural-language-processing/blob/01d450d5ac002b0156ef4cf93a07cb508c1bcdc5/assignment1/.env/lib/python2.7/site-packages/IPython/html/services/notebooks/filenbmanager.py#L113-L130 | |
buke/GreenOdoo | 3d8c55d426fb41fdb3f2f5a1533cfe05983ba1df | runtime/python/lib/python2.7/site-packages/gdata/apps/organization/client.py | python | OrganizationUnitProvisioningClient.update_org_unit | (self, customer_id, org_unit_path, org_unit_entry,
**kwargs) | return self.update(org_unit_entry,
uri=self.MakeOrganizationUnitOrgunitProvisioningUri(
customer_id, org_unit_path=org_unit_path), **kwargs) | Update a Organization Unit.
Args:
customer_id: string The ID of the Google Apps customer.
org_unit_path: string The organization's full path name.
[Note: Each element of the path MUST be URL encoded
(example: finance%2Forganization/suborganization)]
org_u... | Update a Organization Unit. | [
"Update",
"a",
"Organization",
"Unit",
"."
] | def update_org_unit(self, customer_id, org_unit_path, org_unit_entry,
**kwargs):
"""Update a Organization Unit.
Args:
customer_id: string The ID of the Google Apps customer.
org_unit_path: string The organization's full path name.
[Note: Each element of th... | [
"def",
"update_org_unit",
"(",
"self",
",",
"customer_id",
",",
"org_unit_path",
",",
"org_unit_entry",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"org_unit_entry",
".",
"GetParentOrgUnitPath",
"(",
")",
":",
"org_unit_entry",
".",
"SetParentOrgUnitPath",
"... | https://github.com/buke/GreenOdoo/blob/3d8c55d426fb41fdb3f2f5a1533cfe05983ba1df/runtime/python/lib/python2.7/site-packages/gdata/apps/organization/client.py#L216-L236 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.