repo stringlengths 7 54 | path stringlengths 4 192 | url stringlengths 87 284 | code stringlengths 78 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|
tgbugs/pyontutils | ilxutils/ilxutils/interlex_ingestion.py | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/interlex_ingestion.py#L86-L101 | def fragment_search(self, fragement:str) -> List[dict]:
''' Returns the rows in InterLex associated with the fragment
Note:
Pressumed to have duplicate fragements in InterLex
Args:
fragment: The fragment_id of the curie pertaining to the ontology
Returns:
... | [
"def",
"fragment_search",
"(",
"self",
",",
"fragement",
":",
"str",
")",
"->",
"List",
"[",
"dict",
"]",
":",
"fragement",
"=",
"self",
".",
"extract_fragment",
"(",
"fragement",
")",
"ilx_rows",
"=",
"self",
".",
"fragment2rows",
".",
"get",
"(",
"frag... | Returns the rows in InterLex associated with the fragment
Note:
Pressumed to have duplicate fragements in InterLex
Args:
fragment: The fragment_id of the curie pertaining to the ontology
Returns:
None or List[dict] | [
"Returns",
"the",
"rows",
"in",
"InterLex",
"associated",
"with",
"the",
"fragment"
] | python | train |
tk0miya/tk.phpautodoc | src/phply/phpparse.py | https://github.com/tk0miya/tk.phpautodoc/blob/cf789f64abaf76351485cee231a075227e665fb6/src/phply/phpparse.py#L305-L311 | def p_elseif_list(p):
'''elseif_list : empty
| elseif_list ELSEIF LPAREN expr RPAREN statement'''
if len(p) == 2:
p[0] = []
else:
p[0] = p[1] + [ast.ElseIf(p[4], p[6], lineno=p.lineno(2))] | [
"def",
"p_elseif_list",
"(",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"2",
":",
"p",
"[",
"0",
"]",
"=",
"[",
"]",
"else",
":",
"p",
"[",
"0",
"]",
"=",
"p",
"[",
"1",
"]",
"+",
"[",
"ast",
".",
"ElseIf",
"(",
"p",
"[",
"4",
"... | elseif_list : empty
| elseif_list ELSEIF LPAREN expr RPAREN statement | [
"elseif_list",
":",
"empty",
"|",
"elseif_list",
"ELSEIF",
"LPAREN",
"expr",
"RPAREN",
"statement"
] | python | train |
census-instrumentation/opencensus-python | contrib/opencensus-ext-stackdriver/opencensus/ext/stackdriver/trace_exporter/__init__.py | https://github.com/census-instrumentation/opencensus-python/blob/992b223f7e34c5dcb65922b7d5c827e7a1351e7d/contrib/opencensus-ext-stackdriver/opencensus/ext/stackdriver/trace_exporter/__init__.py#L77-L115 | def set_monitored_resource_attributes(span):
"""Set labels to span that can be used for tracing.
:param span: Span object
"""
resource = monitored_resource.get_instance()
if resource is not None:
resource_type = resource.get_type()
resource_labels = resource.get_labels()
if ... | [
"def",
"set_monitored_resource_attributes",
"(",
"span",
")",
":",
"resource",
"=",
"monitored_resource",
".",
"get_instance",
"(",
")",
"if",
"resource",
"is",
"not",
"None",
":",
"resource_type",
"=",
"resource",
".",
"get_type",
"(",
")",
"resource_labels",
"... | Set labels to span that can be used for tracing.
:param span: Span object | [
"Set",
"labels",
"to",
"span",
"that",
"can",
"be",
"used",
"for",
"tracing",
".",
":",
"param",
"span",
":",
"Span",
"object"
] | python | train |
manns/pyspread | pyspread/src/lib/vlc.py | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/vlc.py#L3940-L3952 | def libvlc_log_get_context(ctx):
'''Gets debugging information about a log message: the name of the VLC module
emitting the message and the message location within the source code.
The returned module name and file name will be NULL if unknown.
The returned line number will similarly be zero if unknown.... | [
"def",
"libvlc_log_get_context",
"(",
"ctx",
")",
":",
"f",
"=",
"_Cfunctions",
".",
"get",
"(",
"'libvlc_log_get_context'",
",",
"None",
")",
"or",
"_Cfunction",
"(",
"'libvlc_log_get_context'",
",",
"(",
"(",
"1",
",",
")",
",",
"(",
"2",
",",
")",
","... | Gets debugging information about a log message: the name of the VLC module
emitting the message and the message location within the source code.
The returned module name and file name will be NULL if unknown.
The returned line number will similarly be zero if unknown.
@param ctx: message context (as pas... | [
"Gets",
"debugging",
"information",
"about",
"a",
"log",
"message",
":",
"the",
"name",
"of",
"the",
"VLC",
"module",
"emitting",
"the",
"message",
"and",
"the",
"message",
"location",
"within",
"the",
"source",
"code",
".",
"The",
"returned",
"module",
"nam... | python | train |
marrow/uri | uri/uri.py | https://github.com/marrow/uri/blob/1d8220f11111920cd625a0a32ba6a354edead825/uri/uri.py#L256-L270 | def resolve(self, uri=None, **parts):
"""Attempt to resolve a new URI given an updated URI, partial or complete."""
if uri:
result = self.__class__(urljoin(str(self), str(uri)))
else:
result = self.__class__(self)
for part, value in parts.items():
if part not in self.__all_parts__:
raise Type... | [
"def",
"resolve",
"(",
"self",
",",
"uri",
"=",
"None",
",",
"*",
"*",
"parts",
")",
":",
"if",
"uri",
":",
"result",
"=",
"self",
".",
"__class__",
"(",
"urljoin",
"(",
"str",
"(",
"self",
")",
",",
"str",
"(",
"uri",
")",
")",
")",
"else",
... | Attempt to resolve a new URI given an updated URI, partial or complete. | [
"Attempt",
"to",
"resolve",
"a",
"new",
"URI",
"given",
"an",
"updated",
"URI",
"partial",
"or",
"complete",
"."
] | python | train |
fabioz/PyDev.Debugger | _pydevd_frame_eval/pydevd_modify_bytecode.py | https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydevd_frame_eval/pydevd_modify_bytecode.py#L46-L79 | def _modify_new_lines(code_to_modify, offset, code_to_insert):
"""
Update new lines: the bytecode inserted should be the last instruction of the previous line.
:return: bytes sequence of code with updated lines offsets
"""
# There's a nice overview of co_lnotab in
# https://github.com/python/cpy... | [
"def",
"_modify_new_lines",
"(",
"code_to_modify",
",",
"offset",
",",
"code_to_insert",
")",
":",
"# There's a nice overview of co_lnotab in",
"# https://github.com/python/cpython/blob/3.6/Objects/lnotab_notes.txt",
"new_list",
"=",
"list",
"(",
"code_to_modify",
".",
"co_lnotab... | Update new lines: the bytecode inserted should be the last instruction of the previous line.
:return: bytes sequence of code with updated lines offsets | [
"Update",
"new",
"lines",
":",
"the",
"bytecode",
"inserted",
"should",
"be",
"the",
"last",
"instruction",
"of",
"the",
"previous",
"line",
".",
":",
"return",
":",
"bytes",
"sequence",
"of",
"code",
"with",
"updated",
"lines",
"offsets"
] | python | train |
Jaymon/captain | captain/__init__.py | https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/__init__.py#L229-L248 | def run(self, raw_args):
"""parse and import the script, and then run the script's main function"""
parser = self.parser
args, kwargs = parser.parse_callback_args(raw_args)
callback = kwargs.pop("main_callback")
if parser.has_injected_quiet():
levels = kwargs.pop("qu... | [
"def",
"run",
"(",
"self",
",",
"raw_args",
")",
":",
"parser",
"=",
"self",
".",
"parser",
"args",
",",
"kwargs",
"=",
"parser",
".",
"parse_callback_args",
"(",
"raw_args",
")",
"callback",
"=",
"kwargs",
".",
"pop",
"(",
"\"main_callback\"",
")",
"if"... | parse and import the script, and then run the script's main function | [
"parse",
"and",
"import",
"the",
"script",
"and",
"then",
"run",
"the",
"script",
"s",
"main",
"function"
] | python | valid |
ronaldguillen/wave | wave/views.py | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/views.py#L223-L229 | def get_view_name(self):
"""
Return the view name, as used in OPTIONS responses and in the
browsable API.
"""
func = self.settings.VIEW_NAME_FUNCTION
return func(self.__class__, getattr(self, 'suffix', None)) | [
"def",
"get_view_name",
"(",
"self",
")",
":",
"func",
"=",
"self",
".",
"settings",
".",
"VIEW_NAME_FUNCTION",
"return",
"func",
"(",
"self",
".",
"__class__",
",",
"getattr",
"(",
"self",
",",
"'suffix'",
",",
"None",
")",
")"
] | Return the view name, as used in OPTIONS responses and in the
browsable API. | [
"Return",
"the",
"view",
"name",
"as",
"used",
"in",
"OPTIONS",
"responses",
"and",
"in",
"the",
"browsable",
"API",
"."
] | python | train |
wummel/linkchecker | linkcheck/plugins/locationinfo.py | https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/plugins/locationinfo.py#L43-L48 | def check(self, url_data):
"""Try to ask GeoIP database for country info."""
location = get_location(url_data.host)
if location:
url_data.add_info(_("URL is located in %(location)s.") %
{"location": _(location)}) | [
"def",
"check",
"(",
"self",
",",
"url_data",
")",
":",
"location",
"=",
"get_location",
"(",
"url_data",
".",
"host",
")",
"if",
"location",
":",
"url_data",
".",
"add_info",
"(",
"_",
"(",
"\"URL is located in %(location)s.\"",
")",
"%",
"{",
"\"location\"... | Try to ask GeoIP database for country info. | [
"Try",
"to",
"ask",
"GeoIP",
"database",
"for",
"country",
"info",
"."
] | python | train |
jaraco/path.py | path/__init__.py | https://github.com/jaraco/path.py/blob/bbe7d99e7a64a004f866ace9ec12bd9b296908f5/path/__init__.py#L860-L869 | def _hash(self, hash_name):
""" Returns a hash object for the file at the current path.
`hash_name` should be a hash algo name (such as ``'md5'``
or ``'sha1'``) that's available in the :mod:`hashlib` module.
"""
m = hashlib.new(hash_name)
for chunk in self.chunks(8192, m... | [
"def",
"_hash",
"(",
"self",
",",
"hash_name",
")",
":",
"m",
"=",
"hashlib",
".",
"new",
"(",
"hash_name",
")",
"for",
"chunk",
"in",
"self",
".",
"chunks",
"(",
"8192",
",",
"mode",
"=",
"\"rb\"",
")",
":",
"m",
".",
"update",
"(",
"chunk",
")"... | Returns a hash object for the file at the current path.
`hash_name` should be a hash algo name (such as ``'md5'``
or ``'sha1'``) that's available in the :mod:`hashlib` module. | [
"Returns",
"a",
"hash",
"object",
"for",
"the",
"file",
"at",
"the",
"current",
"path",
"."
] | python | train |
costastf/locationsharinglib | _CI/library/patch.py | https://github.com/costastf/locationsharinglib/blob/dcd74b0cdb59b951345df84987238763e50ef282/_CI/library/patch.py#L123-L134 | def xisabs(filename):
""" Cross-platform version of `os.path.isabs()`
Returns True if `filename` is absolute on
Linux, OS X or Windows.
"""
if filename.startswith(b'/'): # Linux/Unix
return True
elif filename.startswith(b'\\'): # Windows
return True
elif re.match(b'\\w:[\\\\/]', filen... | [
"def",
"xisabs",
"(",
"filename",
")",
":",
"if",
"filename",
".",
"startswith",
"(",
"b'/'",
")",
":",
"# Linux/Unix",
"return",
"True",
"elif",
"filename",
".",
"startswith",
"(",
"b'\\\\'",
")",
":",
"# Windows",
"return",
"True",
"elif",
"re",
".",
"... | Cross-platform version of `os.path.isabs()`
Returns True if `filename` is absolute on
Linux, OS X or Windows. | [
"Cross",
"-",
"platform",
"version",
"of",
"os",
".",
"path",
".",
"isabs",
"()",
"Returns",
"True",
"if",
"filename",
"is",
"absolute",
"on",
"Linux",
"OS",
"X",
"or",
"Windows",
"."
] | python | train |
JoelBender/bacpypes | py25/bacpypes/tcp.py | https://github.com/JoelBender/bacpypes/blob/4111b8604a16fa2b7f80d8104a43b9f3e28dfc78/py25/bacpypes/tcp.py#L576-L584 | def handle_error(self, error=None):
"""Trap for TCPServer errors, otherwise continue."""
if _debug: TCPServerActor._debug("handle_error %r", error)
# pass along to the director
if error is not None:
self.director.actor_error(self, error)
else:
TCPServer.h... | [
"def",
"handle_error",
"(",
"self",
",",
"error",
"=",
"None",
")",
":",
"if",
"_debug",
":",
"TCPServerActor",
".",
"_debug",
"(",
"\"handle_error %r\"",
",",
"error",
")",
"# pass along to the director",
"if",
"error",
"is",
"not",
"None",
":",
"self",
"."... | Trap for TCPServer errors, otherwise continue. | [
"Trap",
"for",
"TCPServer",
"errors",
"otherwise",
"continue",
"."
] | python | train |
zetaops/pyoko | pyoko/model.py | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/model.py#L457-L504 | def save(self, internal=False, meta=None, index_fields=None):
"""
Save's object to DB.
Do not override this method, use pre_save and post_save methods.
Args:
internal (bool): True if called within model.
Used to prevent unneccessary calls to pre_save and
... | [
"def",
"save",
"(",
"self",
",",
"internal",
"=",
"False",
",",
"meta",
"=",
"None",
",",
"index_fields",
"=",
"None",
")",
":",
"for",
"f",
"in",
"self",
".",
"on_save",
":",
"f",
"(",
"self",
")",
"if",
"not",
"(",
"internal",
"or",
"self",
"."... | Save's object to DB.
Do not override this method, use pre_save and post_save methods.
Args:
internal (bool): True if called within model.
Used to prevent unneccessary calls to pre_save and
post_save methods.
meta (dict): JSON serializable meta da... | [
"Save",
"s",
"object",
"to",
"DB",
"."
] | python | train |
mastro35/flows | flows/Actions/PassOnInterval.py | https://github.com/mastro35/flows/blob/05e488385673a69597b5b39c7728795aa4d5eb18/flows/Actions/PassOnInterval.py#L71-L73 | def verify_day(self, now):
'''Verify the day'''
return self.day == "*" or str(now.day) in self.day.split(" ") | [
"def",
"verify_day",
"(",
"self",
",",
"now",
")",
":",
"return",
"self",
".",
"day",
"==",
"\"*\"",
"or",
"str",
"(",
"now",
".",
"day",
")",
"in",
"self",
".",
"day",
".",
"split",
"(",
"\" \"",
")"
] | Verify the day | [
"Verify",
"the",
"day"
] | python | train |
Parquery/icontract | icontract/_checkers.py | https://github.com/Parquery/icontract/blob/846e3187869a9ba790e9b893c98e5055e1cce274/icontract/_checkers.py#L252-L346 | def decorate_with_checker(func: CallableT) -> CallableT:
"""Decorate the function with a checker that verifies the preconditions and postconditions."""
assert not hasattr(func, "__preconditions__"), \
"Expected func to have no list of preconditions (there should be only a single contract checker per fun... | [
"def",
"decorate_with_checker",
"(",
"func",
":",
"CallableT",
")",
"->",
"CallableT",
":",
"assert",
"not",
"hasattr",
"(",
"func",
",",
"\"__preconditions__\"",
")",
",",
"\"Expected func to have no list of preconditions (there should be only a single contract checker per fun... | Decorate the function with a checker that verifies the preconditions and postconditions. | [
"Decorate",
"the",
"function",
"with",
"a",
"checker",
"that",
"verifies",
"the",
"preconditions",
"and",
"postconditions",
"."
] | python | train |
ndokter/dsmr_parser | dsmr_parser/clients/protocol.py | https://github.com/ndokter/dsmr_parser/blob/c04b0a5add58ce70153eede1a87ca171876b61c7/dsmr_parser/clients/protocol.py#L39-L46 | def create_dsmr_reader(port, dsmr_version, telegram_callback, loop=None):
"""Creates a DSMR asyncio protocol coroutine using serial port."""
protocol, serial_settings = create_dsmr_protocol(
dsmr_version, telegram_callback, loop=None)
serial_settings['url'] = port
conn = create_serial_connectio... | [
"def",
"create_dsmr_reader",
"(",
"port",
",",
"dsmr_version",
",",
"telegram_callback",
",",
"loop",
"=",
"None",
")",
":",
"protocol",
",",
"serial_settings",
"=",
"create_dsmr_protocol",
"(",
"dsmr_version",
",",
"telegram_callback",
",",
"loop",
"=",
"None",
... | Creates a DSMR asyncio protocol coroutine using serial port. | [
"Creates",
"a",
"DSMR",
"asyncio",
"protocol",
"coroutine",
"using",
"serial",
"port",
"."
] | python | test |
tmux-python/libtmux | libtmux/common.py | https://github.com/tmux-python/libtmux/blob/8eb2f8bbea3a025c1567b1516653414dbc24e1fc/libtmux/common.py#L353-L378 | def get_by_id(self, id):
"""
Return object based on ``child_id_attribute``.
Parameters
----------
val : str
Returns
-------
object
Notes
-----
Based on `.get()`_ from `backbone.js`_.
.. _backbone.js: http://backbonejs.or... | [
"def",
"get_by_id",
"(",
"self",
",",
"id",
")",
":",
"for",
"child",
"in",
"self",
".",
"children",
":",
"if",
"child",
"[",
"self",
".",
"child_id_attribute",
"]",
"==",
"id",
":",
"return",
"child",
"else",
":",
"continue",
"return",
"None"
] | Return object based on ``child_id_attribute``.
Parameters
----------
val : str
Returns
-------
object
Notes
-----
Based on `.get()`_ from `backbone.js`_.
.. _backbone.js: http://backbonejs.org/
.. _.get(): http://backbonejs.org/... | [
"Return",
"object",
"based",
"on",
"child_id_attribute",
"."
] | python | train |
graphql-python/graphql-core-next | graphql/language/parser.py | https://github.com/graphql-python/graphql-core-next/blob/073dce3f002f897d40f9348ffd8f107815160540/graphql/language/parser.py#L105-L121 | def parse_value(source: SourceType, **options: dict) -> ValueNode:
"""Parse the AST for a given string containing a GraphQL value.
Throws GraphQLError if a syntax error is encountered.
This is useful within tools that operate upon GraphQL Values directly and in
isolation of complete GraphQL documents.... | [
"def",
"parse_value",
"(",
"source",
":",
"SourceType",
",",
"*",
"*",
"options",
":",
"dict",
")",
"->",
"ValueNode",
":",
"if",
"isinstance",
"(",
"source",
",",
"str",
")",
":",
"source",
"=",
"Source",
"(",
"source",
")",
"lexer",
"=",
"Lexer",
"... | Parse the AST for a given string containing a GraphQL value.
Throws GraphQLError if a syntax error is encountered.
This is useful within tools that operate upon GraphQL Values directly and in
isolation of complete GraphQL documents.
Consider providing the results to the utility function: `value_from_... | [
"Parse",
"the",
"AST",
"for",
"a",
"given",
"string",
"containing",
"a",
"GraphQL",
"value",
"."
] | python | train |
5monkeys/content-io | cio/backends/base.py | https://github.com/5monkeys/content-io/blob/8c8519c74cbadab871f7151c0e02252cb5753759/cio/backends/base.py#L26-L34 | def get(self, uri):
"""
Return node for uri or None if not exists:
{uri: x, content: y}
"""
cache_key = self._build_cache_key(uri)
value = self._get(cache_key)
if value is not None:
return self._decode_node(uri, value) | [
"def",
"get",
"(",
"self",
",",
"uri",
")",
":",
"cache_key",
"=",
"self",
".",
"_build_cache_key",
"(",
"uri",
")",
"value",
"=",
"self",
".",
"_get",
"(",
"cache_key",
")",
"if",
"value",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_decode_no... | Return node for uri or None if not exists:
{uri: x, content: y} | [
"Return",
"node",
"for",
"uri",
"or",
"None",
"if",
"not",
"exists",
":",
"{",
"uri",
":",
"x",
"content",
":",
"y",
"}"
] | python | train |
inveniosoftware-contrib/invenio-workflows | invenio_workflows/api.py | https://github.com/inveniosoftware-contrib/invenio-workflows/blob/9c09fd29509a3db975ac2aba337e6760d8cfd3c2/invenio_workflows/api.py#L280-L297 | def set_action(self, action, message):
"""Set the action to be taken for this object.
Assign an special "action" to this object to be taken
in consideration in Holding Pen. The widget is referred to
by a string with the filename minus extension.
A message is also needed to tell... | [
"def",
"set_action",
"(",
"self",
",",
"action",
",",
"message",
")",
":",
"self",
".",
"extra_data",
"[",
"\"_action\"",
"]",
"=",
"action",
"self",
".",
"extra_data",
"[",
"\"_message\"",
"]",
"=",
"message"
] | Set the action to be taken for this object.
Assign an special "action" to this object to be taken
in consideration in Holding Pen. The widget is referred to
by a string with the filename minus extension.
A message is also needed to tell the user the action
required in a textual... | [
"Set",
"the",
"action",
"to",
"be",
"taken",
"for",
"this",
"object",
"."
] | python | train |
martinkosir/neverbounce-python | neverbounce/client.py | https://github.com/martinkosir/neverbounce-python/blob/8d8b3f381dbff2a753a8770fac0d2bfab80d5bec/neverbounce/client.py#L18-L25 | def verify(self, email):
"""
Verify a single email address.
:param str email: Email address to verify.
:return: A VerifiedEmail object.
"""
resp = self._call(endpoint='single', data={'email': email})
return VerifiedEmail(email, resp['result']) | [
"def",
"verify",
"(",
"self",
",",
"email",
")",
":",
"resp",
"=",
"self",
".",
"_call",
"(",
"endpoint",
"=",
"'single'",
",",
"data",
"=",
"{",
"'email'",
":",
"email",
"}",
")",
"return",
"VerifiedEmail",
"(",
"email",
",",
"resp",
"[",
"'result'"... | Verify a single email address.
:param str email: Email address to verify.
:return: A VerifiedEmail object. | [
"Verify",
"a",
"single",
"email",
"address",
".",
":",
"param",
"str",
"email",
":",
"Email",
"address",
"to",
"verify",
".",
":",
"return",
":",
"A",
"VerifiedEmail",
"object",
"."
] | python | train |
Mxit/python-mxit | mxit/services.py | https://github.com/Mxit/python-mxit/blob/6b18a54ef6fbfe1f9d94755ba3d4ad77743c8b0c/mxit/services.py#L71-L84 | def get_user_id(self, mxit_id, scope='profile/public'):
"""
Retrieve the Mxit user's internal "user ID"
No user authentication required
"""
user_id = _get(
token=self.oauth.get_app_token(scope),
uri='/user/lookup/' + urllib.quote(mxit_id)
)
... | [
"def",
"get_user_id",
"(",
"self",
",",
"mxit_id",
",",
"scope",
"=",
"'profile/public'",
")",
":",
"user_id",
"=",
"_get",
"(",
"token",
"=",
"self",
".",
"oauth",
".",
"get_app_token",
"(",
"scope",
")",
",",
"uri",
"=",
"'/user/lookup/'",
"+",
"urllib... | Retrieve the Mxit user's internal "user ID"
No user authentication required | [
"Retrieve",
"the",
"Mxit",
"user",
"s",
"internal",
"user",
"ID",
"No",
"user",
"authentication",
"required"
] | python | train |
shkarupa-alex/tfunicode | tfunicode/python/ops/__init__.py | https://github.com/shkarupa-alex/tfunicode/blob/72ee2f484b6202394dcda3db47245bc78ae2267d/tfunicode/python/ops/__init__.py#L26-L51 | def _combine_sparse_successor(parent_indices, parent_shape, child_indices, child_values, child_shape, name=None):
"""Combines two string `SparseTensor`s, where second `SparseTensor` is the result of expanding
first `SparseTensor`'s values.
Args:
parent_indices: 2D int64 `Tensor` with parent `Sparse... | [
"def",
"_combine_sparse_successor",
"(",
"parent_indices",
",",
"parent_shape",
",",
"child_indices",
",",
"child_values",
",",
"child_shape",
",",
"name",
"=",
"None",
")",
":",
"with",
"ops",
".",
"name_scope",
"(",
"name",
",",
"\"CombineSparseSuccessor\"",
","... | Combines two string `SparseTensor`s, where second `SparseTensor` is the result of expanding
first `SparseTensor`'s values.
Args:
parent_indices: 2D int64 `Tensor` with parent `SparseTensor` indices
parent_shape: 1D int64 `Tensor` with parent `SparseTensor` dense_shape
child_indices: 2D ... | [
"Combines",
"two",
"string",
"SparseTensor",
"s",
"where",
"second",
"SparseTensor",
"is",
"the",
"result",
"of",
"expanding",
"first",
"SparseTensor",
"s",
"values",
"."
] | python | train |
portfors-lab/sparkle | sparkle/stim/auto_parameter_model.py | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/stim/auto_parameter_model.py#L131-L150 | def nStepsForParam(self, param):
"""Gets the number of steps *parameter* will yeild
:param param: parameter to get the expansion count for
:type param: dict
"""
if param['parameter'] == 'filename':
return len(param['names'])
else:
if param['step']... | [
"def",
"nStepsForParam",
"(",
"self",
",",
"param",
")",
":",
"if",
"param",
"[",
"'parameter'",
"]",
"==",
"'filename'",
":",
"return",
"len",
"(",
"param",
"[",
"'names'",
"]",
")",
"else",
":",
"if",
"param",
"[",
"'step'",
"]",
">",
"0",
":",
"... | Gets the number of steps *parameter* will yeild
:param param: parameter to get the expansion count for
:type param: dict | [
"Gets",
"the",
"number",
"of",
"steps",
"*",
"parameter",
"*",
"will",
"yeild"
] | python | train |
fprimex/zdesk | zdesk/zdesk_api.py | https://github.com/fprimex/zdesk/blob/851611c13b4d530e9df31390b3ec709baf0a0188/zdesk/zdesk_api.py#L2252-L2256 | def macros_attachment_show(self, id, **kwargs):
"https://developer.zendesk.com/rest_api/docs/core/macros#show-macro-attachment"
api_path = "/api/v2/macros/attachments/{id}.json"
api_path = api_path.format(id=id)
return self.call(api_path, **kwargs) | [
"def",
"macros_attachment_show",
"(",
"self",
",",
"id",
",",
"*",
"*",
"kwargs",
")",
":",
"api_path",
"=",
"\"/api/v2/macros/attachments/{id}.json\"",
"api_path",
"=",
"api_path",
".",
"format",
"(",
"id",
"=",
"id",
")",
"return",
"self",
".",
"call",
"("... | https://developer.zendesk.com/rest_api/docs/core/macros#show-macro-attachment | [
"https",
":",
"//",
"developer",
".",
"zendesk",
".",
"com",
"/",
"rest_api",
"/",
"docs",
"/",
"core",
"/",
"macros#show",
"-",
"macro",
"-",
"attachment"
] | python | train |
collectiveacuity/labPack | labpack/messaging/telegram.py | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/messaging/telegram.py#L229-L254 | def _validate_type(self, file_name, extension_map, method_title, argument_title):
''' a helper method to validate extension type of file
:param file_name: string with file name to test
:param extension_map: dictionary with extensions names and regex patterns
:param method_title: ... | [
"def",
"_validate_type",
"(",
"self",
",",
"file_name",
",",
"extension_map",
",",
"method_title",
",",
"argument_title",
")",
":",
"# validate file extension\r",
"from",
"labpack",
".",
"parsing",
".",
"regex",
"import",
"labRegex",
"file_extension",
"=",
"''",
"... | a helper method to validate extension type of file
:param file_name: string with file name to test
:param extension_map: dictionary with extensions names and regex patterns
:param method_title: string with title of feeder method
:param argument_title: string with title of argument ... | [
"a",
"helper",
"method",
"to",
"validate",
"extension",
"type",
"of",
"file",
":",
"param",
"file_name",
":",
"string",
"with",
"file",
"name",
"to",
"test",
":",
"param",
"extension_map",
":",
"dictionary",
"with",
"extensions",
"names",
"and",
"regex",
"pa... | python | train |
GoogleCloudPlatform/appengine-mapreduce | python/src/mapreduce/records.py | https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/records.py#L289-L338 | def read(self):
"""Reads record from current position in reader.
Returns:
original bytes stored in a single record.
"""
data = None
while True:
last_offset = self.tell()
try:
(chunk, record_type) = self.__try_read_record()
if record_type == _RECORD_TYPE_NONE:
... | [
"def",
"read",
"(",
"self",
")",
":",
"data",
"=",
"None",
"while",
"True",
":",
"last_offset",
"=",
"self",
".",
"tell",
"(",
")",
"try",
":",
"(",
"chunk",
",",
"record_type",
")",
"=",
"self",
".",
"__try_read_record",
"(",
")",
"if",
"record_type... | Reads record from current position in reader.
Returns:
original bytes stored in a single record. | [
"Reads",
"record",
"from",
"current",
"position",
"in",
"reader",
"."
] | python | train |
kencochrane/django-defender | defender/utils.py | https://github.com/kencochrane/django-defender/blob/e3e547dbb83235e0d564a6d64652c7df00412ff2/defender/utils.py#L304-L310 | def is_user_already_locked(username):
"""Is this username already locked?"""
if username is None:
return False
if config.DISABLE_USERNAME_LOCKOUT:
return False
return REDIS_SERVER.get(get_username_blocked_cache_key(username)) | [
"def",
"is_user_already_locked",
"(",
"username",
")",
":",
"if",
"username",
"is",
"None",
":",
"return",
"False",
"if",
"config",
".",
"DISABLE_USERNAME_LOCKOUT",
":",
"return",
"False",
"return",
"REDIS_SERVER",
".",
"get",
"(",
"get_username_blocked_cache_key",
... | Is this username already locked? | [
"Is",
"this",
"username",
"already",
"locked?"
] | python | train |
mayfield/shellish | shellish/layout/table.py | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/layout/table.py#L671-L702 | def _column_pack_filter(self, next_filter):
""" Top-align column data irrespective of original row alignment. E.g.
INPUT: [
["1a", "2a"],
[None, "2b"],
["1b", "2c"],
[None, "2d"]
]
OUTPUT: [
["1a... | [
"def",
"_column_pack_filter",
"(",
"self",
",",
"next_filter",
")",
":",
"next",
"(",
"next_filter",
")",
"col_count",
"=",
"len",
"(",
"self",
".",
"widths",
")",
"queues",
"=",
"[",
"collections",
".",
"deque",
"(",
")",
"for",
"_",
"in",
"range",
"(... | Top-align column data irrespective of original row alignment. E.g.
INPUT: [
["1a", "2a"],
[None, "2b"],
["1b", "2c"],
[None, "2d"]
]
OUTPUT: [
["1a", "2a"],
["1b", "2b"],
... | [
"Top",
"-",
"align",
"column",
"data",
"irrespective",
"of",
"original",
"row",
"alignment",
".",
"E",
".",
"g",
".",
"INPUT",
":",
"[",
"[",
"1a",
"2a",
"]",
"[",
"None",
"2b",
"]",
"[",
"1b",
"2c",
"]",
"[",
"None",
"2d",
"]",
"]",
"OUTPUT",
... | python | train |
DLR-RM/RAFCON | source/rafcon/utils/type_helpers.py | https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/utils/type_helpers.py#L33-L70 | def convert_string_to_type(string_value):
"""Converts a string into a type or class
:param string_value: the string to be converted, e.g. "int"
:return: The type derived from string_value, e.g. int
"""
# If the parameter is already a type, return it
if string_value in ['None', type(None).__name... | [
"def",
"convert_string_to_type",
"(",
"string_value",
")",
":",
"# If the parameter is already a type, return it",
"if",
"string_value",
"in",
"[",
"'None'",
",",
"type",
"(",
"None",
")",
".",
"__name__",
"]",
":",
"return",
"type",
"(",
"None",
")",
"if",
"isi... | Converts a string into a type or class
:param string_value: the string to be converted, e.g. "int"
:return: The type derived from string_value, e.g. int | [
"Converts",
"a",
"string",
"into",
"a",
"type",
"or",
"class"
] | python | train |
DistrictDataLabs/yellowbrick | yellowbrick/classifier/class_prediction_error.py | https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/classifier/class_prediction_error.py#L128-L145 | def draw(self):
"""
Renders the class prediction error across the axis.
"""
indices = np.arange(len(self.classes_))
prev = np.zeros(len(self.classes_))
colors = resolve_colors(
colors=self.colors,
n_colors=len(self.classes_))
for idx, ro... | [
"def",
"draw",
"(",
"self",
")",
":",
"indices",
"=",
"np",
".",
"arange",
"(",
"len",
"(",
"self",
".",
"classes_",
")",
")",
"prev",
"=",
"np",
".",
"zeros",
"(",
"len",
"(",
"self",
".",
"classes_",
")",
")",
"colors",
"=",
"resolve_colors",
"... | Renders the class prediction error across the axis. | [
"Renders",
"the",
"class",
"prediction",
"error",
"across",
"the",
"axis",
"."
] | python | train |
pingali/dgit | dgitcore/datasets/common.py | https://github.com/pingali/dgit/blob/ecde01f40b98f0719dbcfb54452270ed2f86686d/dgitcore/datasets/common.py#L497-L514 | def annotate_metadata_code(repo, files):
"""
Update metadata with the commit information
"""
package = repo.package
package['code'] = []
for p in files:
matching_files = glob2.glob("**/{}".format(p))
for f in matching_files:
absf = os.path.abspath(f)
prin... | [
"def",
"annotate_metadata_code",
"(",
"repo",
",",
"files",
")",
":",
"package",
"=",
"repo",
".",
"package",
"package",
"[",
"'code'",
"]",
"=",
"[",
"]",
"for",
"p",
"in",
"files",
":",
"matching_files",
"=",
"glob2",
".",
"glob",
"(",
"\"**/{}\"",
"... | Update metadata with the commit information | [
"Update",
"metadata",
"with",
"the",
"commit",
"information"
] | python | valid |
mattsolo1/hmmerclust | hmmerclust/hmmerclust.py | https://github.com/mattsolo1/hmmerclust/blob/471596043a660097ed8b11430d42118a8fd25798/hmmerclust/hmmerclust.py#L539-L555 | def import_tree_order_from_file(self, MyOrganismDB, filename):
'''
Import the accession list that has been ordered by position
in a phylogenetic tree. Get the index in the list, and
add this to the Organism object. Later we can use this position
to make a heatmap that matches up... | [
"def",
"import_tree_order_from_file",
"(",
"self",
",",
"MyOrganismDB",
",",
"filename",
")",
":",
"tree_order",
"=",
"[",
"acc",
".",
"strip",
"(",
")",
"for",
"acc",
"in",
"open",
"(",
"filename",
")",
"]",
"#print tree_order",
"for",
"org",
"in",
"MyOrg... | Import the accession list that has been ordered by position
in a phylogenetic tree. Get the index in the list, and
add this to the Organism object. Later we can use this position
to make a heatmap that matches up to a phylogenetic tree. | [
"Import",
"the",
"accession",
"list",
"that",
"has",
"been",
"ordered",
"by",
"position",
"in",
"a",
"phylogenetic",
"tree",
".",
"Get",
"the",
"index",
"in",
"the",
"list",
"and",
"add",
"this",
"to",
"the",
"Organism",
"object",
".",
"Later",
"we",
"ca... | python | train |
clinicedc/edc-auth | edc_auth/import_users.py | https://github.com/clinicedc/edc-auth/blob/e633a5461139d3799f389f7bed0e02c9d2c1e103/edc_auth/import_users.py#L27-L91 | def import_users(
path,
resource_name=None,
send_email_to_user=None,
alternate_email=None,
verbose=None,
export_to_file=None,
**kwargs,
):
"""Import users from a CSV file with columns:
username
first_name
last_name
email
sites: a comma-separated li... | [
"def",
"import_users",
"(",
"path",
",",
"resource_name",
"=",
"None",
",",
"send_email_to_user",
"=",
"None",
",",
"alternate_email",
"=",
"None",
",",
"verbose",
"=",
"None",
",",
"export_to_file",
"=",
"None",
",",
"*",
"*",
"kwargs",
",",
")",
":",
"... | Import users from a CSV file with columns:
username
first_name
last_name
email
sites: a comma-separated list of sites
groups: a comma-separated list of groups
job_title | [
"Import",
"users",
"from",
"a",
"CSV",
"file",
"with",
"columns",
":",
"username",
"first_name",
"last_name",
"email",
"sites",
":",
"a",
"comma",
"-",
"separated",
"list",
"of",
"sites",
"groups",
":",
"a",
"comma",
"-",
"separated",
"list",
"of",
"groups... | python | train |
eqcorrscan/EQcorrscan | eqcorrscan/utils/plotting.py | https://github.com/eqcorrscan/EQcorrscan/blob/3121b4aca801ee5d38f56ca297ce1c0f9515d9ff/eqcorrscan/utils/plotting.py#L1913-L1992 | def spec_trace(traces, cmap=None, wlen=0.4, log=False, trc='k', tralpha=0.9,
size=(10, 13), fig=None, **kwargs):
"""
Plots seismic data with spectrogram behind.
Takes a stream or list of traces and plots the trace with the spectra
beneath it.
:type traces: list
:param traces: Tr... | [
"def",
"spec_trace",
"(",
"traces",
",",
"cmap",
"=",
"None",
",",
"wlen",
"=",
"0.4",
",",
"log",
"=",
"False",
",",
"trc",
"=",
"'k'",
",",
"tralpha",
"=",
"0.9",
",",
"size",
"=",
"(",
"10",
",",
"13",
")",
",",
"fig",
"=",
"None",
",",
"*... | Plots seismic data with spectrogram behind.
Takes a stream or list of traces and plots the trace with the spectra
beneath it.
:type traces: list
:param traces: Traces to be plotted, can be a single
:class:`obspy.core.stream.Stream`, or a list of
:class:`obspy.core.trace.Trace`.
:ty... | [
"Plots",
"seismic",
"data",
"with",
"spectrogram",
"behind",
"."
] | python | train |
DataDog/integrations-core | tokumx/datadog_checks/tokumx/vendor/pymongo/topology.py | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/topology.py#L312-L316 | def request_check_all(self, wait_time=5):
"""Wake all monitors, wait for at least one to check its server."""
with self._lock:
self._request_check_all()
self._condition.wait(wait_time) | [
"def",
"request_check_all",
"(",
"self",
",",
"wait_time",
"=",
"5",
")",
":",
"with",
"self",
".",
"_lock",
":",
"self",
".",
"_request_check_all",
"(",
")",
"self",
".",
"_condition",
".",
"wait",
"(",
"wait_time",
")"
] | Wake all monitors, wait for at least one to check its server. | [
"Wake",
"all",
"monitors",
"wait",
"for",
"at",
"least",
"one",
"to",
"check",
"its",
"server",
"."
] | python | train |
zetaops/zengine | zengine/engine.py | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L657-L690 | def check_for_lane_permission(self):
"""
One or more permissions can be associated with a lane
of a workflow. In a similar way, a lane can be
restricted with relation to other lanes of the workflow.
This method called on lane changes and checks user has
required permissi... | [
"def",
"check_for_lane_permission",
"(",
"self",
")",
":",
"# TODO: Cache lane_data in app memory",
"if",
"self",
".",
"current",
".",
"lane_permission",
":",
"log",
".",
"debug",
"(",
"\"HAS LANE PERM: %s\"",
"%",
"self",
".",
"current",
".",
"lane_permission",
")"... | One or more permissions can be associated with a lane
of a workflow. In a similar way, a lane can be
restricted with relation to other lanes of the workflow.
This method called on lane changes and checks user has
required permissions and relations.
Raises:
HTTPForb... | [
"One",
"or",
"more",
"permissions",
"can",
"be",
"associated",
"with",
"a",
"lane",
"of",
"a",
"workflow",
".",
"In",
"a",
"similar",
"way",
"a",
"lane",
"can",
"be",
"restricted",
"with",
"relation",
"to",
"other",
"lanes",
"of",
"the",
"workflow",
"."
... | python | train |
maweigert/gputools | gputools/convolve/generic_separable_filters.py | https://github.com/maweigert/gputools/blob/6ab26efeb05dceef74cf13aadeeeb9b009b529dd/gputools/convolve/generic_separable_filters.py#L216-L248 | def _gauss_filter(data, sigma=4, res_g=None, sub_blocks=(1, 1, 1)):
"""
gaussian filter of given size
Parameters
----------
data: 2 or 3 dimensional ndarray or OCLArray of type float32
input data
size: scalar, tuple
the size of the patch to consider
res_g: OCLArray
... | [
"def",
"_gauss_filter",
"(",
"data",
",",
"sigma",
"=",
"4",
",",
"res_g",
"=",
"None",
",",
"sub_blocks",
"=",
"(",
"1",
",",
"1",
",",
"1",
")",
")",
":",
"truncate",
"=",
"4.",
"radius",
"=",
"tuple",
"(",
"int",
"(",
"truncate",
"*",
"s",
"... | gaussian filter of given size
Parameters
----------
data: 2 or 3 dimensional ndarray or OCLArray of type float32
input data
size: scalar, tuple
the size of the patch to consider
res_g: OCLArray
store result in buffer if given
sub_blocks:
perform over subblock til... | [
"gaussian",
"filter",
"of",
"given",
"size"
] | python | train |
wummel/linkchecker | linkcheck/logger/text.py | https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/logger/text.py#L205-L209 | def write_warning (self, url_data):
"""Write url_data.warning."""
self.write(self.part("warning") + self.spaces("warning"))
warning_msgs = [u"[%s] %s" % x for x in url_data.warnings]
self.writeln(self.wrap(warning_msgs, 65), color=self.colorwarning) | [
"def",
"write_warning",
"(",
"self",
",",
"url_data",
")",
":",
"self",
".",
"write",
"(",
"self",
".",
"part",
"(",
"\"warning\"",
")",
"+",
"self",
".",
"spaces",
"(",
"\"warning\"",
")",
")",
"warning_msgs",
"=",
"[",
"u\"[%s] %s\"",
"%",
"x",
"for"... | Write url_data.warning. | [
"Write",
"url_data",
".",
"warning",
"."
] | python | train |
pyhys/minimalmodbus | minimalmodbus.py | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L1773-L1802 | def _createBitpattern(functioncode, value):
"""Create the bit pattern that is used for writing single bits.
This is basically a storage of numerical constants.
Args:
* functioncode (int): can be 5 or 15
* value (int): can be 0 or 1
Returns:
The bit pattern (string).
Raise... | [
"def",
"_createBitpattern",
"(",
"functioncode",
",",
"value",
")",
":",
"_checkFunctioncode",
"(",
"functioncode",
",",
"[",
"5",
",",
"15",
"]",
")",
"_checkInt",
"(",
"value",
",",
"minvalue",
"=",
"0",
",",
"maxvalue",
"=",
"1",
",",
"description",
"... | Create the bit pattern that is used for writing single bits.
This is basically a storage of numerical constants.
Args:
* functioncode (int): can be 5 or 15
* value (int): can be 0 or 1
Returns:
The bit pattern (string).
Raises:
TypeError, ValueError | [
"Create",
"the",
"bit",
"pattern",
"that",
"is",
"used",
"for",
"writing",
"single",
"bits",
"."
] | python | train |
orbingol/NURBS-Python | geomdl/operations.py | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/operations.py#L1607-L1638 | def scale(obj, multiplier, **kwargs):
""" Scales curves, surfaces or volumes by the input multiplier.
Keyword Arguments:
* ``inplace``: if False, operation applied to a copy of the object. *Default: False*
:param obj: input geometry
:type obj: abstract.SplineGeometry, multi.AbstractGeometry
... | [
"def",
"scale",
"(",
"obj",
",",
"multiplier",
",",
"*",
"*",
"kwargs",
")",
":",
"# Input validity checks",
"if",
"not",
"isinstance",
"(",
"multiplier",
",",
"(",
"int",
",",
"float",
")",
")",
":",
"raise",
"GeomdlException",
"(",
"\"The multiplier must b... | Scales curves, surfaces or volumes by the input multiplier.
Keyword Arguments:
* ``inplace``: if False, operation applied to a copy of the object. *Default: False*
:param obj: input geometry
:type obj: abstract.SplineGeometry, multi.AbstractGeometry
:param multiplier: scaling multiplier
:t... | [
"Scales",
"curves",
"surfaces",
"or",
"volumes",
"by",
"the",
"input",
"multiplier",
"."
] | python | train |
secdev/scapy | scapy/utils6.py | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L525-L534 | def in6_iseui64(x):
"""
Return True if provided address has an interface identifier part
created in modified EUI-64 format (meaning it matches *::*:*ff:fe*:*).
Otherwise, False is returned. Address must be passed in printable
format.
"""
eui64 = inet_pton(socket.AF_INET6, '::ff:fe00:0')
... | [
"def",
"in6_iseui64",
"(",
"x",
")",
":",
"eui64",
"=",
"inet_pton",
"(",
"socket",
".",
"AF_INET6",
",",
"'::ff:fe00:0'",
")",
"x",
"=",
"in6_and",
"(",
"inet_pton",
"(",
"socket",
".",
"AF_INET6",
",",
"x",
")",
",",
"eui64",
")",
"return",
"x",
"=... | Return True if provided address has an interface identifier part
created in modified EUI-64 format (meaning it matches *::*:*ff:fe*:*).
Otherwise, False is returned. Address must be passed in printable
format. | [
"Return",
"True",
"if",
"provided",
"address",
"has",
"an",
"interface",
"identifier",
"part",
"created",
"in",
"modified",
"EUI",
"-",
"64",
"format",
"(",
"meaning",
"it",
"matches",
"*",
"::",
"*",
":",
"*",
"ff",
":",
"fe",
"*",
":",
"*",
")",
".... | python | train |
gem/oq-engine | openquake/risklib/scientific.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/scientific.py#L1021-L1068 | def conditional_loss_ratio(loss_ratios, poes, probability):
"""
Return the loss ratio corresponding to the given PoE (Probability
of Exceendance). We can have four cases:
1. If `probability` is in `poes` it takes the bigger
corresponding loss_ratios.
2. If it is in `(poe1, poe2)` wher... | [
"def",
"conditional_loss_ratio",
"(",
"loss_ratios",
",",
"poes",
",",
"probability",
")",
":",
"assert",
"len",
"(",
"loss_ratios",
")",
">=",
"3",
",",
"loss_ratios",
"rpoes",
"=",
"poes",
"[",
":",
":",
"-",
"1",
"]",
"if",
"probability",
">",
"poes",... | Return the loss ratio corresponding to the given PoE (Probability
of Exceendance). We can have four cases:
1. If `probability` is in `poes` it takes the bigger
corresponding loss_ratios.
2. If it is in `(poe1, poe2)` where both `poe1` and `poe2` are
in `poes`, then we perform a linea... | [
"Return",
"the",
"loss",
"ratio",
"corresponding",
"to",
"the",
"given",
"PoE",
"(",
"Probability",
"of",
"Exceendance",
")",
".",
"We",
"can",
"have",
"four",
"cases",
":"
] | python | train |
KrzyHonk/bpmn-python | bpmn_python/bpmn_diagram_export.py | https://github.com/KrzyHonk/bpmn-python/blob/6e5e28e3d656dbf5bd3d85d78fe8e3f2fb462629/bpmn_python/bpmn_diagram_export.py#L213-L228 | def export_process_element(definitions, process_id, process_attributes_dictionary):
"""
Creates process element for exported BPMN XML file.
:param process_id: string object. ID of exported process element,
:param definitions: an XML element ('definitions'), root element of BPMN 2.0 docu... | [
"def",
"export_process_element",
"(",
"definitions",
",",
"process_id",
",",
"process_attributes_dictionary",
")",
":",
"process",
"=",
"eTree",
".",
"SubElement",
"(",
"definitions",
",",
"consts",
".",
"Consts",
".",
"process",
")",
"process",
".",
"set",
"(",... | Creates process element for exported BPMN XML file.
:param process_id: string object. ID of exported process element,
:param definitions: an XML element ('definitions'), root element of BPMN 2.0 document
:param process_attributes_dictionary: dictionary that holds attribute values of 'process' e... | [
"Creates",
"process",
"element",
"for",
"exported",
"BPMN",
"XML",
"file",
"."
] | python | train |
seequent/properties | properties/base/union.py | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/base/union.py#L125-L134 | def default(self):
"""Default value of the property"""
prop_def = getattr(self, '_default', utils.undefined)
for prop in self.props:
if prop.default is utils.undefined:
continue
if prop_def is utils.undefined:
prop_def = prop.default
... | [
"def",
"default",
"(",
"self",
")",
":",
"prop_def",
"=",
"getattr",
"(",
"self",
",",
"'_default'",
",",
"utils",
".",
"undefined",
")",
"for",
"prop",
"in",
"self",
".",
"props",
":",
"if",
"prop",
".",
"default",
"is",
"utils",
".",
"undefined",
"... | Default value of the property | [
"Default",
"value",
"of",
"the",
"property"
] | python | train |
JoeVirtual/KonFoo | konfoo/core.py | https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L2692-L2724 | def _set_bit_size(self, size, step=1, auto_align=False):
""" Sets the *size* of the `Decimal` field.
:param int size: is the *size* of the `Decimal` field in bits,
can be between ``1`` and ``64``.
:param int step: is the minimal required step *size* for the `Decimal`
fie... | [
"def",
"_set_bit_size",
"(",
"self",
",",
"size",
",",
"step",
"=",
"1",
",",
"auto_align",
"=",
"False",
")",
":",
"# Field size",
"bit_size",
"=",
"int",
"(",
"size",
")",
"# Invalid field size",
"if",
"bit_size",
"%",
"step",
"!=",
"0",
"or",
"not",
... | Sets the *size* of the `Decimal` field.
:param int size: is the *size* of the `Decimal` field in bits,
can be between ``1`` and ``64``.
:param int step: is the minimal required step *size* for the `Decimal`
field in bits.
:param bool auto_align: if ``True`` the `Decimal`... | [
"Sets",
"the",
"*",
"size",
"*",
"of",
"the",
"Decimal",
"field",
"."
] | python | train |
ttinoco/OPTALG | optalg/lin_solver/_mumps/__init__.py | https://github.com/ttinoco/OPTALG/blob/d4f141292f281eea4faa71473258139e7f433001/optalg/lin_solver/_mumps/__init__.py#L156-L163 | def set_distributed_assembled_values(self, a_loc):
"""Set the distributed assembled matrix values.
Distributed assembled matrices require setting icntl(18) != 0.
"""
assert a_loc.size == self._refs['irn_loc'].size
self._refs.update(a_loc=a_loc)
self.id.a_loc = self.cast_... | [
"def",
"set_distributed_assembled_values",
"(",
"self",
",",
"a_loc",
")",
":",
"assert",
"a_loc",
".",
"size",
"==",
"self",
".",
"_refs",
"[",
"'irn_loc'",
"]",
".",
"size",
"self",
".",
"_refs",
".",
"update",
"(",
"a_loc",
"=",
"a_loc",
")",
"self",
... | Set the distributed assembled matrix values.
Distributed assembled matrices require setting icntl(18) != 0. | [
"Set",
"the",
"distributed",
"assembled",
"matrix",
"values",
"."
] | python | train |
graphql-python/graphql-core-next | graphql/language/parser.py | https://github.com/graphql-python/graphql-core-next/blob/073dce3f002f897d40f9348ffd8f107815160540/graphql/language/parser.py#L547-L554 | def parse_type_system_definition(lexer: Lexer) -> TypeSystemDefinitionNode:
"""TypeSystemDefinition"""
# Many definitions begin with a description and require a lookahead.
keyword_token = lexer.lookahead() if peek_description(lexer) else lexer.token
func = _parse_type_system_definition_functions.get(cas... | [
"def",
"parse_type_system_definition",
"(",
"lexer",
":",
"Lexer",
")",
"->",
"TypeSystemDefinitionNode",
":",
"# Many definitions begin with a description and require a lookahead.",
"keyword_token",
"=",
"lexer",
".",
"lookahead",
"(",
")",
"if",
"peek_description",
"(",
"... | TypeSystemDefinition | [
"TypeSystemDefinition"
] | python | train |
PaulHancock/Aegean | AegeanTools/wcs_helpers.py | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/wcs_helpers.py#L120-L137 | def pix2sky(self, pixel):
"""
Convert pixel coordinates into sky coordinates.
Parameters
----------
pixel : (float, float)
The (x,y) pixel coordinates
Returns
-------
sky : (float, float)
The (ra,dec) sky coordinates in degrees
... | [
"def",
"pix2sky",
"(",
"self",
",",
"pixel",
")",
":",
"x",
",",
"y",
"=",
"pixel",
"# wcs and pyfits have oposite ideas of x/y",
"return",
"self",
".",
"wcs",
".",
"wcs_pix2world",
"(",
"[",
"[",
"y",
",",
"x",
"]",
"]",
",",
"1",
")",
"[",
"0",
"]"... | Convert pixel coordinates into sky coordinates.
Parameters
----------
pixel : (float, float)
The (x,y) pixel coordinates
Returns
-------
sky : (float, float)
The (ra,dec) sky coordinates in degrees | [
"Convert",
"pixel",
"coordinates",
"into",
"sky",
"coordinates",
"."
] | python | train |
pybel/pybel | src/pybel/manager/cache_manager.py | https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/manager/cache_manager.py#L399-L401 | def has_name_version(self, name: str, version: str) -> bool:
"""Check if there exists a network with the name/version combination in the database."""
return self.session.query(exists().where(and_(Network.name == name, Network.version == version))).scalar() | [
"def",
"has_name_version",
"(",
"self",
",",
"name",
":",
"str",
",",
"version",
":",
"str",
")",
"->",
"bool",
":",
"return",
"self",
".",
"session",
".",
"query",
"(",
"exists",
"(",
")",
".",
"where",
"(",
"and_",
"(",
"Network",
".",
"name",
"=... | Check if there exists a network with the name/version combination in the database. | [
"Check",
"if",
"there",
"exists",
"a",
"network",
"with",
"the",
"name",
"/",
"version",
"combination",
"in",
"the",
"database",
"."
] | python | train |
openstack/pyghmi | pyghmi/ipmi/command.py | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L720-L738 | def get_sensor_reading(self, sensorname):
"""Get a sensor reading by name
Returns a single decoded sensor reading per the name
passed in
:param sensorname: Name of the desired sensor
:returns: sdr.SensorReading object
"""
self.init_sdr()
for sensor in s... | [
"def",
"get_sensor_reading",
"(",
"self",
",",
"sensorname",
")",
":",
"self",
".",
"init_sdr",
"(",
")",
"for",
"sensor",
"in",
"self",
".",
"_sdr",
".",
"get_sensor_numbers",
"(",
")",
":",
"if",
"self",
".",
"_sdr",
".",
"sensors",
"[",
"sensor",
"]... | Get a sensor reading by name
Returns a single decoded sensor reading per the name
passed in
:param sensorname: Name of the desired sensor
:returns: sdr.SensorReading object | [
"Get",
"a",
"sensor",
"reading",
"by",
"name"
] | python | train |
StackStorm/pybind | pybind/nos/v6_0_2f/rbridge_id/ipv6/ipv6route/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/rbridge_id/ipv6/ipv6route/__init__.py#L92-L113 | def _set_route(self, v, load=False):
"""
Setter method for route, mapped from YANG variable /rbridge_id/ipv6/ipv6route/route (list)
If this variable is read-only (config: false) in the
source YANG file, then _set_route is considered as a private
method. Backends looking to populate this variable sho... | [
"def",
"_set_route",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
"base",
... | Setter method for route, mapped from YANG variable /rbridge_id/ipv6/ipv6route/route (list)
If this variable is read-only (config: false) in the
source YANG file, then _set_route is considered as a private
method. Backends looking to populate this variable should
do so via calling thisObj._set_route() di... | [
"Setter",
"method",
"for",
"route",
"mapped",
"from",
"YANG",
"variable",
"/",
"rbridge_id",
"/",
"ipv6",
"/",
"ipv6route",
"/",
"route",
"(",
"list",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"(",
"config",
":",
"false",
")",
"in",
"th... | python | train |
joshspeagle/dynesty | dynesty/nestedsamplers.py | https://github.com/joshspeagle/dynesty/blob/9e482aafeb5cf84bedb896fa6f07a761d917983e/dynesty/nestedsamplers.py#L813-L839 | def propose_unif(self):
"""Propose a new live point by sampling *uniformly* within
the union of N-spheres defined by our live points."""
# Initialize a K-D Tree to assist nearest neighbor searches.
if self.use_kdtree:
kdtree = spatial.KDTree(self.live_u)
else:
... | [
"def",
"propose_unif",
"(",
"self",
")",
":",
"# Initialize a K-D Tree to assist nearest neighbor searches.",
"if",
"self",
".",
"use_kdtree",
":",
"kdtree",
"=",
"spatial",
".",
"KDTree",
"(",
"self",
".",
"live_u",
")",
"else",
":",
"kdtree",
"=",
"None",
"whi... | Propose a new live point by sampling *uniformly* within
the union of N-spheres defined by our live points. | [
"Propose",
"a",
"new",
"live",
"point",
"by",
"sampling",
"*",
"uniformly",
"*",
"within",
"the",
"union",
"of",
"N",
"-",
"spheres",
"defined",
"by",
"our",
"live",
"points",
"."
] | python | train |
ahmedaljazzar/django-mako | djangomako/backends.py | https://github.com/ahmedaljazzar/django-mako/blob/3a4099e8ae679f431eeb2c35024b2e6028f8a096/djangomako/backends.py#L117-L131 | def get_template(self, template_name):
"""
Trying to get a compiled template given a template name
:param template_name: The template name.
:raises: - TemplateDoesNotExist if no such template exists.
- TemplateSyntaxError if we couldn't compile the
t... | [
"def",
"get_template",
"(",
"self",
",",
"template_name",
")",
":",
"try",
":",
"return",
"self",
".",
"template_class",
"(",
"self",
".",
"engine",
".",
"get_template",
"(",
"template_name",
")",
")",
"except",
"mako_exceptions",
".",
"TemplateLookupException",... | Trying to get a compiled template given a template name
:param template_name: The template name.
:raises: - TemplateDoesNotExist if no such template exists.
- TemplateSyntaxError if we couldn't compile the
template using Mako syntax.
:return: Compiled Templa... | [
"Trying",
"to",
"get",
"a",
"compiled",
"template",
"given",
"a",
"template",
"name",
":",
"param",
"template_name",
":",
"The",
"template",
"name",
".",
":",
"raises",
":",
"-",
"TemplateDoesNotExist",
"if",
"no",
"such",
"template",
"exists",
".",
"-",
"... | python | train |
saltstack/salt | salt/modules/lxd.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L478-L536 | def container_list(list_names=False, remote_addr=None,
cert=None, key=None, verify_cert=True):
'''
Lists containers
list_names : False
Only return a list of names when True
remote_addr :
An URL to a remote Server, you also have to give cert and key if
you pro... | [
"def",
"container_list",
"(",
"list_names",
"=",
"False",
",",
"remote_addr",
"=",
"None",
",",
"cert",
"=",
"None",
",",
"key",
"=",
"None",
",",
"verify_cert",
"=",
"True",
")",
":",
"client",
"=",
"pylxd_client_get",
"(",
"remote_addr",
",",
"cert",
"... | Lists containers
list_names : False
Only return a list of names when True
remote_addr :
An URL to a remote Server, you also have to give cert and key if
you provide remote_addr and its a TCP Address!
Examples:
https://myserver.lan:8443
/var/lib/mysocket... | [
"Lists",
"containers"
] | python | train |
aht/stream.py | stream.py | https://github.com/aht/stream.py/blob/6a4945cbddaf74138eee5ba33eee3988cfceb84d/stream.py#L1023-L1034 | def close(self):
"""Signal that the executor will no longer accept job submission.
Worker threads/processes are now allowed to terminate after all
jobs have been are completed. Without a call to close(), they will
stay around forever waiting for more jobs to come.
"""
with self.lock:
if self.closed:
... | [
"def",
"close",
"(",
"self",
")",
":",
"with",
"self",
".",
"lock",
":",
"if",
"self",
".",
"closed",
":",
"return",
"self",
".",
"waitqueue",
".",
"put",
"(",
"StopIteration",
")",
"self",
".",
"closed",
"=",
"True"
] | Signal that the executor will no longer accept job submission.
Worker threads/processes are now allowed to terminate after all
jobs have been are completed. Without a call to close(), they will
stay around forever waiting for more jobs to come. | [
"Signal",
"that",
"the",
"executor",
"will",
"no",
"longer",
"accept",
"job",
"submission",
".",
"Worker",
"threads",
"/",
"processes",
"are",
"now",
"allowed",
"to",
"terminate",
"after",
"all",
"jobs",
"have",
"been",
"are",
"completed",
".",
"Without",
"a... | python | train |
hydraplatform/hydra-base | hydra_base/lib/notes.py | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/notes.py#L64-L80 | def add_note(note, **kwargs):
"""
Add a new note
"""
note_i = Note()
note_i.ref_key = note.ref_key
note_i.set_ref(note.ref_key, note.ref_id)
note_i.value = note.value
note_i.created_by = kwargs.get('user_id')
db.DBSession.add(note_i)
db.DBSession.flush()
return note_i | [
"def",
"add_note",
"(",
"note",
",",
"*",
"*",
"kwargs",
")",
":",
"note_i",
"=",
"Note",
"(",
")",
"note_i",
".",
"ref_key",
"=",
"note",
".",
"ref_key",
"note_i",
".",
"set_ref",
"(",
"note",
".",
"ref_key",
",",
"note",
".",
"ref_id",
")",
"note... | Add a new note | [
"Add",
"a",
"new",
"note"
] | python | train |
tensorflow/tensorboard | tensorboard/plugins/text/summary_v2.py | https://github.com/tensorflow/tensorboard/blob/8e5f497b48e40f2a774f85416b8a35ac0693c35e/tensorboard/plugins/text/summary_v2.py#L29-L60 | def text(name, data, step=None, description=None):
"""Write a text summary.
Arguments:
name: A name for this summary. The summary tag used for TensorBoard will
be this name prefixed by any active name scopes.
data: A UTF-8 string tensor value.
step: Explicit `int64`-castable monotonic step value ... | [
"def",
"text",
"(",
"name",
",",
"data",
",",
"step",
"=",
"None",
",",
"description",
"=",
"None",
")",
":",
"summary_metadata",
"=",
"metadata",
".",
"create_summary_metadata",
"(",
"display_name",
"=",
"None",
",",
"description",
"=",
"description",
")",
... | Write a text summary.
Arguments:
name: A name for this summary. The summary tag used for TensorBoard will
be this name prefixed by any active name scopes.
data: A UTF-8 string tensor value.
step: Explicit `int64`-castable monotonic step value for this summary. If
omitted, this defaults to `tf... | [
"Write",
"a",
"text",
"summary",
"."
] | python | train |
openstack/horizon | horizon/tables/actions.py | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tables/actions.py#L752-L756 | def get_default_attrs(self):
"""Returns a list of the default HTML attributes for the action."""
attrs = super(BatchAction, self).get_default_attrs()
attrs.update({'data-batch-action': 'true'})
return attrs | [
"def",
"get_default_attrs",
"(",
"self",
")",
":",
"attrs",
"=",
"super",
"(",
"BatchAction",
",",
"self",
")",
".",
"get_default_attrs",
"(",
")",
"attrs",
".",
"update",
"(",
"{",
"'data-batch-action'",
":",
"'true'",
"}",
")",
"return",
"attrs"
] | Returns a list of the default HTML attributes for the action. | [
"Returns",
"a",
"list",
"of",
"the",
"default",
"HTML",
"attributes",
"for",
"the",
"action",
"."
] | python | train |
pandas-dev/pandas | pandas/io/pytables.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/pytables.py#L1784-L1792 | def validate_metadata(self, handler):
""" validate that kind=category does not change the categories """
if self.meta == 'category':
new_metadata = self.metadata
cur_metadata = handler.read_metadata(self.cname)
if (new_metadata is not None and cur_metadata is not None... | [
"def",
"validate_metadata",
"(",
"self",
",",
"handler",
")",
":",
"if",
"self",
".",
"meta",
"==",
"'category'",
":",
"new_metadata",
"=",
"self",
".",
"metadata",
"cur_metadata",
"=",
"handler",
".",
"read_metadata",
"(",
"self",
".",
"cname",
")",
"if",... | validate that kind=category does not change the categories | [
"validate",
"that",
"kind",
"=",
"category",
"does",
"not",
"change",
"the",
"categories"
] | python | train |
google/grr | grr/server/grr_response_server/databases/mysql_clients.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_clients.py#L345-L376 | def ReadClientStartupInfoHistory(self, client_id, timerange=None,
cursor=None):
"""Reads the full startup history for a particular client."""
client_id_int = db_utils.ClientIDToInt(client_id)
query = ("SELECT startup_info, UNIX_TIMESTAMP(timestamp) "
"FROM c... | [
"def",
"ReadClientStartupInfoHistory",
"(",
"self",
",",
"client_id",
",",
"timerange",
"=",
"None",
",",
"cursor",
"=",
"None",
")",
":",
"client_id_int",
"=",
"db_utils",
".",
"ClientIDToInt",
"(",
"client_id",
")",
"query",
"=",
"(",
"\"SELECT startup_info, U... | Reads the full startup history for a particular client. | [
"Reads",
"the",
"full",
"startup",
"history",
"for",
"a",
"particular",
"client",
"."
] | python | train |
mardiros/pyshop | pyshop/helpers/i18n.py | https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/helpers/i18n.py#L16-L22 | def locale_negotiator(request):
"""Locale negotiator base on the `Accept-Language` header"""
locale = 'en'
if request.accept_language:
locale = request.accept_language.best_match(LANGUAGES)
locale = LANGUAGES.get(locale, 'en')
return locale | [
"def",
"locale_negotiator",
"(",
"request",
")",
":",
"locale",
"=",
"'en'",
"if",
"request",
".",
"accept_language",
":",
"locale",
"=",
"request",
".",
"accept_language",
".",
"best_match",
"(",
"LANGUAGES",
")",
"locale",
"=",
"LANGUAGES",
".",
"get",
"("... | Locale negotiator base on the `Accept-Language` header | [
"Locale",
"negotiator",
"base",
"on",
"the",
"Accept",
"-",
"Language",
"header"
] | python | train |
osrg/ryu | ryu/lib/type_desc.py | https://github.com/osrg/ryu/blob/6f906e72c92e10bd0264c9b91a2f7bb85b97780c/ryu/lib/type_desc.py#L57-L62 | def _split_str(s, n):
"""
split string into list of strings by specified number.
"""
length = len(s)
return [s[i:i + n] for i in range(0, length, n)] | [
"def",
"_split_str",
"(",
"s",
",",
"n",
")",
":",
"length",
"=",
"len",
"(",
"s",
")",
"return",
"[",
"s",
"[",
"i",
":",
"i",
"+",
"n",
"]",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"length",
",",
"n",
")",
"]"
] | split string into list of strings by specified number. | [
"split",
"string",
"into",
"list",
"of",
"strings",
"by",
"specified",
"number",
"."
] | python | train |
ECESeniorDesign/lazy_record | lazy_record/repo.py | https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/repo.py#L256-L273 | def update(self, **data):
"""
Update records in the table with +data+. Often combined with `where`,
as it acts on all records in the table unless restricted.
ex)
>>> Repo("foos").update(name="bar")
UPDATE foos SET name = "bar"
"""
data = data.items()
... | [
"def",
"update",
"(",
"self",
",",
"*",
"*",
"data",
")",
":",
"data",
"=",
"data",
".",
"items",
"(",
")",
"update_command_arg",
"=",
"\", \"",
".",
"join",
"(",
"\"{} = ?\"",
".",
"format",
"(",
"entry",
"[",
"0",
"]",
")",
"for",
"entry",
"in",
... | Update records in the table with +data+. Often combined with `where`,
as it acts on all records in the table unless restricted.
ex)
>>> Repo("foos").update(name="bar")
UPDATE foos SET name = "bar" | [
"Update",
"records",
"in",
"the",
"table",
"with",
"+",
"data",
"+",
".",
"Often",
"combined",
"with",
"where",
"as",
"it",
"acts",
"on",
"all",
"records",
"in",
"the",
"table",
"unless",
"restricted",
"."
] | python | train |
ynop/audiomate | audiomate/corpus/corpus.py | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/corpus.py#L404-L433 | def merge_corpus(self, corpus):
"""
Merge the given corpus into this corpus. All assets (tracks, utterances, issuers, ...) are copied into
this corpus. If any ids (utt-idx, track-idx, issuer-idx, subview-idx, ...) are occurring in both corpora,
the ids from the merging corpus are suffixe... | [
"def",
"merge_corpus",
"(",
"self",
",",
"corpus",
")",
":",
"# Create a copy, so objects aren't changed in the original merging corpus",
"merging_corpus",
"=",
"Corpus",
".",
"from_corpus",
"(",
"corpus",
")",
"self",
".",
"import_tracks",
"(",
"corpus",
".",
"tracks",... | Merge the given corpus into this corpus. All assets (tracks, utterances, issuers, ...) are copied into
this corpus. If any ids (utt-idx, track-idx, issuer-idx, subview-idx, ...) are occurring in both corpora,
the ids from the merging corpus are suffixed by a number (starting from 1 until no other is mat... | [
"Merge",
"the",
"given",
"corpus",
"into",
"this",
"corpus",
".",
"All",
"assets",
"(",
"tracks",
"utterances",
"issuers",
"...",
")",
"are",
"copied",
"into",
"this",
"corpus",
".",
"If",
"any",
"ids",
"(",
"utt",
"-",
"idx",
"track",
"-",
"idx",
"iss... | python | train |
SeleniumHQ/selenium | py/selenium/webdriver/remote/webdriver.py | https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/webdriver.py#L65-L95 | def _make_w3c_caps(caps):
"""Makes a W3C alwaysMatch capabilities object.
Filters out capability names that are not in the W3C spec. Spec-compliant
drivers will reject requests containing unknown capability names.
Moves the Firefox profile, if present, from the old location to the new Firefox
opti... | [
"def",
"_make_w3c_caps",
"(",
"caps",
")",
":",
"caps",
"=",
"copy",
".",
"deepcopy",
"(",
"caps",
")",
"profile",
"=",
"caps",
".",
"get",
"(",
"'firefox_profile'",
")",
"always_match",
"=",
"{",
"}",
"if",
"caps",
".",
"get",
"(",
"'proxy'",
")",
"... | Makes a W3C alwaysMatch capabilities object.
Filters out capability names that are not in the W3C spec. Spec-compliant
drivers will reject requests containing unknown capability names.
Moves the Firefox profile, if present, from the old location to the new Firefox
options object.
:Args:
- ca... | [
"Makes",
"a",
"W3C",
"alwaysMatch",
"capabilities",
"object",
"."
] | python | train |
numenta/nupic | src/nupic/regions/sp_region.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/sp_region.py#L887-L906 | def readFromProto(cls, proto):
"""
Overrides :meth:`~nupic.bindings.regions.PyRegion.PyRegion.readFromProto`.
Read state from proto object.
:param proto: SPRegionProto capnproto object
"""
instance = cls(proto.columnCount, proto.inputWidth)
instance.spatialImp = proto.spatialImp
i... | [
"def",
"readFromProto",
"(",
"cls",
",",
"proto",
")",
":",
"instance",
"=",
"cls",
"(",
"proto",
".",
"columnCount",
",",
"proto",
".",
"inputWidth",
")",
"instance",
".",
"spatialImp",
"=",
"proto",
".",
"spatialImp",
"instance",
".",
"learningMode",
"="... | Overrides :meth:`~nupic.bindings.regions.PyRegion.PyRegion.readFromProto`.
Read state from proto object.
:param proto: SPRegionProto capnproto object | [
"Overrides",
":",
"meth",
":",
"~nupic",
".",
"bindings",
".",
"regions",
".",
"PyRegion",
".",
"PyRegion",
".",
"readFromProto",
"."
] | python | valid |
django-fluent/django-fluent-contents | fluent_contents/extensions/pluginbase.py | https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/extensions/pluginbase.py#L414-L434 | def set_cached_output(self, placeholder_name, instance, output):
"""
.. versionadded:: 0.9
Store the cached output for a rendered item.
This method can be overwritten to implement custom caching mechanisms.
By default, this function generates the cache key using :func:`... | [
"def",
"set_cached_output",
"(",
"self",
",",
"placeholder_name",
",",
"instance",
",",
"output",
")",
":",
"cachekey",
"=",
"self",
".",
"get_output_cache_key",
"(",
"placeholder_name",
",",
"instance",
")",
"if",
"self",
".",
"cache_timeout",
"is",
"not",
"D... | .. versionadded:: 0.9
Store the cached output for a rendered item.
This method can be overwritten to implement custom caching mechanisms.
By default, this function generates the cache key using :func:`~fluent_contents.cache.get_rendering_cache_key`
and stores the results in ... | [
"..",
"versionadded",
"::",
"0",
".",
"9",
"Store",
"the",
"cached",
"output",
"for",
"a",
"rendered",
"item",
"."
] | python | train |
EUDAT-B2SAFE/B2HANDLE | b2handle/handleclient.py | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L1226-L1271 | def __exchange_URL_in_13020loc(self, oldurl, newurl, list_of_entries, handle):
'''
Exchange every occurrence of oldurl against newurl in a 10320/LOC entry.
This does not change the ids or other xml attributes of the
<location> element.
:param oldurl: The URL that will be... | [
"def",
"__exchange_URL_in_13020loc",
"(",
"self",
",",
"oldurl",
",",
"newurl",
",",
"list_of_entries",
",",
"handle",
")",
":",
"# Find existing 10320/LOC entries",
"python_indices",
"=",
"self",
".",
"__get_python_indices_for_key",
"(",
"'10320/LOC'",
",",
"list_of_en... | Exchange every occurrence of oldurl against newurl in a 10320/LOC entry.
This does not change the ids or other xml attributes of the
<location> element.
:param oldurl: The URL that will be overwritten.
:param newurl: The URL to write into the entry.
:param list_of_entrie... | [
"Exchange",
"every",
"occurrence",
"of",
"oldurl",
"against",
"newurl",
"in",
"a",
"10320",
"/",
"LOC",
"entry",
".",
"This",
"does",
"not",
"change",
"the",
"ids",
"or",
"other",
"xml",
"attributes",
"of",
"the",
"<location",
">",
"element",
"."
] | python | train |
googlefonts/fontbakery | Lib/fontbakery/profiles/googlefonts.py | https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/profiles/googlefonts.py#L3326-L3341 | def com_google_fonts_check_varfont_generate_static(ttFont):
""" Check a static ttf can be generated from a variable font. """
import tempfile
from fontTools.varLib import mutator
try:
loc = {k.axisTag: float((k.maxValue + k.minValue) / 2)
for k in ttFont['fvar'].axes}
with tempfile.Temporary... | [
"def",
"com_google_fonts_check_varfont_generate_static",
"(",
"ttFont",
")",
":",
"import",
"tempfile",
"from",
"fontTools",
".",
"varLib",
"import",
"mutator",
"try",
":",
"loc",
"=",
"{",
"k",
".",
"axisTag",
":",
"float",
"(",
"(",
"k",
".",
"maxValue",
"... | Check a static ttf can be generated from a variable font. | [
"Check",
"a",
"static",
"ttf",
"can",
"be",
"generated",
"from",
"a",
"variable",
"font",
"."
] | python | train |
peterbrittain/asciimatics | asciimatics/widgets.py | https://github.com/peterbrittain/asciimatics/blob/f471427d7786ce2d5f1eeb2dae0e67d19e46e085/asciimatics/widgets.py#L1483-L1492 | def get_location(self):
"""
Return the absolute location of this widget on the Screen, taking into account the
current state of the Frame that is displaying it and any label offsets of the Widget.
:returns: A tuple of the form (<X coordinate>, <Y coordinate>).
"""
origin... | [
"def",
"get_location",
"(",
"self",
")",
":",
"origin",
"=",
"self",
".",
"_frame",
".",
"canvas",
".",
"origin",
"return",
"(",
"self",
".",
"_x",
"+",
"origin",
"[",
"0",
"]",
"+",
"self",
".",
"_offset",
",",
"self",
".",
"_y",
"+",
"origin",
... | Return the absolute location of this widget on the Screen, taking into account the
current state of the Frame that is displaying it and any label offsets of the Widget.
:returns: A tuple of the form (<X coordinate>, <Y coordinate>). | [
"Return",
"the",
"absolute",
"location",
"of",
"this",
"widget",
"on",
"the",
"Screen",
"taking",
"into",
"account",
"the",
"current",
"state",
"of",
"the",
"Frame",
"that",
"is",
"displaying",
"it",
"and",
"any",
"label",
"offsets",
"of",
"the",
"Widget",
... | python | train |
timstaley/voevent-parse | src/voeventparse/voevent.py | https://github.com/timstaley/voevent-parse/blob/58fc1eb3af5eca23d9e819c727204950615402a7/src/voeventparse/voevent.py#L430-L437 | def _listify(x):
"""Ensure x is iterable; if not then enclose it in a list and return it."""
if isinstance(x, string_types):
return [x]
elif isinstance(x, collections.Iterable):
return x
else:
return [x] | [
"def",
"_listify",
"(",
"x",
")",
":",
"if",
"isinstance",
"(",
"x",
",",
"string_types",
")",
":",
"return",
"[",
"x",
"]",
"elif",
"isinstance",
"(",
"x",
",",
"collections",
".",
"Iterable",
")",
":",
"return",
"x",
"else",
":",
"return",
"[",
"... | Ensure x is iterable; if not then enclose it in a list and return it. | [
"Ensure",
"x",
"is",
"iterable",
";",
"if",
"not",
"then",
"enclose",
"it",
"in",
"a",
"list",
"and",
"return",
"it",
"."
] | python | train |
awslabs/sockeye | sockeye/data_io.py | https://github.com/awslabs/sockeye/blob/5d64a1ee1ef3cbba17c6d1d94bc061020c43f6ab/sockeye/data_io.py#L522-L531 | def get_num_shards(num_samples: int, samples_per_shard: int, min_num_shards: int) -> int:
"""
Returns the number of shards.
:param num_samples: Number of training data samples.
:param samples_per_shard: Samples per shard.
:param min_num_shards: Minimum number of shards.
:return: Number of shard... | [
"def",
"get_num_shards",
"(",
"num_samples",
":",
"int",
",",
"samples_per_shard",
":",
"int",
",",
"min_num_shards",
":",
"int",
")",
"->",
"int",
":",
"return",
"max",
"(",
"int",
"(",
"math",
".",
"ceil",
"(",
"num_samples",
"/",
"samples_per_shard",
")... | Returns the number of shards.
:param num_samples: Number of training data samples.
:param samples_per_shard: Samples per shard.
:param min_num_shards: Minimum number of shards.
:return: Number of shards. | [
"Returns",
"the",
"number",
"of",
"shards",
"."
] | python | train |
pypa/pipenv | pipenv/vendor/tomlkit/parser.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/tomlkit/parser.py#L272-L325 | def _parse_comment_trail(self): # type: () -> Tuple[str, str, str]
"""
Returns (comment_ws, comment, trail)
If there is no comment, comment_ws and comment will
simply be empty.
"""
if self.end():
return "", "", ""
comment = ""
comment_ws = ""... | [
"def",
"_parse_comment_trail",
"(",
"self",
")",
":",
"# type: () -> Tuple[str, str, str]",
"if",
"self",
".",
"end",
"(",
")",
":",
"return",
"\"\"",
",",
"\"\"",
",",
"\"\"",
"comment",
"=",
"\"\"",
"comment_ws",
"=",
"\"\"",
"self",
".",
"mark",
"(",
")... | Returns (comment_ws, comment, trail)
If there is no comment, comment_ws and comment will
simply be empty. | [
"Returns",
"(",
"comment_ws",
"comment",
"trail",
")",
"If",
"there",
"is",
"no",
"comment",
"comment_ws",
"and",
"comment",
"will",
"simply",
"be",
"empty",
"."
] | python | train |
tensorflow/tensor2tensor | tensor2tensor/bin/t2t_attack.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/bin/t2t_attack.py#L83-L131 | def create_surrogate_run_config(hp):
"""Create a run config.
Args:
hp: model hyperparameters
Returns:
a run config
"""
save_ckpt_steps = max(FLAGS.iterations_per_loop, FLAGS.local_eval_frequency)
save_ckpt_secs = FLAGS.save_checkpoints_secs or None
if save_ckpt_secs:
save_ckpt_steps = None
... | [
"def",
"create_surrogate_run_config",
"(",
"hp",
")",
":",
"save_ckpt_steps",
"=",
"max",
"(",
"FLAGS",
".",
"iterations_per_loop",
",",
"FLAGS",
".",
"local_eval_frequency",
")",
"save_ckpt_secs",
"=",
"FLAGS",
".",
"save_checkpoints_secs",
"or",
"None",
"if",
"s... | Create a run config.
Args:
hp: model hyperparameters
Returns:
a run config | [
"Create",
"a",
"run",
"config",
"."
] | python | train |
bitesofcode/projexui | projexui/widgets/xdocktoolbar.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xdocktoolbar.py#L643-L652 | def setMaximumPixmapSize(self, size):
"""
Sets the maximum pixmap size for this toolbar.
:param size | <int>
"""
self._maximumPixmapSize = size
position = self.position()
self._position = None
self.setPosition(position) | [
"def",
"setMaximumPixmapSize",
"(",
"self",
",",
"size",
")",
":",
"self",
".",
"_maximumPixmapSize",
"=",
"size",
"position",
"=",
"self",
".",
"position",
"(",
")",
"self",
".",
"_position",
"=",
"None",
"self",
".",
"setPosition",
"(",
"position",
")"
] | Sets the maximum pixmap size for this toolbar.
:param size | <int> | [
"Sets",
"the",
"maximum",
"pixmap",
"size",
"for",
"this",
"toolbar",
".",
":",
"param",
"size",
"|",
"<int",
">"
] | python | train |
gwastro/pycbc | pycbc/inference/io/base_multitemper.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/inference/io/base_multitemper.py#L77-L81 | def write_sampler_metadata(self, sampler):
"""Adds writing ntemps to file.
"""
super(MultiTemperedMetadataIO, self).write_sampler_metadata(sampler)
self[self.sampler_group].attrs["ntemps"] = sampler.ntemps | [
"def",
"write_sampler_metadata",
"(",
"self",
",",
"sampler",
")",
":",
"super",
"(",
"MultiTemperedMetadataIO",
",",
"self",
")",
".",
"write_sampler_metadata",
"(",
"sampler",
")",
"self",
"[",
"self",
".",
"sampler_group",
"]",
".",
"attrs",
"[",
"\"ntemps\... | Adds writing ntemps to file. | [
"Adds",
"writing",
"ntemps",
"to",
"file",
"."
] | python | train |
trailofbits/manticore | manticore/native/cpu/x86.py | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/native/cpu/x86.py#L1388-L1445 | def DAA(cpu):
"""
Decimal adjusts AL after addition.
Adjusts the sum of two packed BCD values to create a packed BCD result. The AL register
is the implied source and destination operand. If a decimal carry is detected, the CF
and AF flags are set accordingly.
The CF and... | [
"def",
"DAA",
"(",
"cpu",
")",
":",
"cpu",
".",
"AF",
"=",
"Operators",
".",
"OR",
"(",
"(",
"cpu",
".",
"AL",
"&",
"0x0f",
")",
">",
"9",
",",
"cpu",
".",
"AF",
")",
"oldAL",
"=",
"cpu",
".",
"AL",
"cpu",
".",
"AL",
"=",
"Operators",
".",
... | Decimal adjusts AL after addition.
Adjusts the sum of two packed BCD values to create a packed BCD result. The AL register
is the implied source and destination operand. If a decimal carry is detected, the CF
and AF flags are set accordingly.
The CF and AF flags are set if the adjustmen... | [
"Decimal",
"adjusts",
"AL",
"after",
"addition",
"."
] | python | valid |
ibm-watson-iot/iot-python | src/wiotp/sdk/api/status/__init__.py | https://github.com/ibm-watson-iot/iot-python/blob/195f05adce3fba4ec997017e41e02ebd85c0c4cc/src/wiotp/sdk/api/status/__init__.py#L40-L51 | def serviceStatus(self):
"""
Retrieve the organization-specific status of each of the services offered by the IBM Watson IoT Platform.
In case of failure it throws APIException
"""
r = self._apiClient.get("api/v0002/service-status")
if r.status_code == 200:
... | [
"def",
"serviceStatus",
"(",
"self",
")",
":",
"r",
"=",
"self",
".",
"_apiClient",
".",
"get",
"(",
"\"api/v0002/service-status\"",
")",
"if",
"r",
".",
"status_code",
"==",
"200",
":",
"return",
"ServiceStatus",
"(",
"*",
"*",
"r",
".",
"json",
"(",
... | Retrieve the organization-specific status of each of the services offered by the IBM Watson IoT Platform.
In case of failure it throws APIException | [
"Retrieve",
"the",
"organization",
"-",
"specific",
"status",
"of",
"each",
"of",
"the",
"services",
"offered",
"by",
"the",
"IBM",
"Watson",
"IoT",
"Platform",
".",
"In",
"case",
"of",
"failure",
"it",
"throws",
"APIException"
] | python | test |
loli/medpy | medpy/features/intensity.py | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L733-L744 | def _substract_hemispheres(active, reference, active_sigma, reference_sigma, voxel_spacing):
"""
Helper function for `_extract_hemispheric_difference`.
Smoothes both images and then substracts the reference from the active image.
"""
active_kernel = _create_structure_array(active_sigma, voxel_spacin... | [
"def",
"_substract_hemispheres",
"(",
"active",
",",
"reference",
",",
"active_sigma",
",",
"reference_sigma",
",",
"voxel_spacing",
")",
":",
"active_kernel",
"=",
"_create_structure_array",
"(",
"active_sigma",
",",
"voxel_spacing",
")",
"active_smoothed",
"=",
"gau... | Helper function for `_extract_hemispheric_difference`.
Smoothes both images and then substracts the reference from the active image. | [
"Helper",
"function",
"for",
"_extract_hemispheric_difference",
".",
"Smoothes",
"both",
"images",
"and",
"then",
"substracts",
"the",
"reference",
"from",
"the",
"active",
"image",
"."
] | python | train |
mrjoes/sockjs-tornado | sockjs/tornado/basehandler.py | https://github.com/mrjoes/sockjs-tornado/blob/bd3a99b407f1181f054b3b1730f438dde375ca1c/sockjs/tornado/basehandler.py#L42-L46 | def finish(self, chunk=None):
"""Tornado `finish` handler"""
self._log_disconnect()
super(BaseHandler, self).finish(chunk) | [
"def",
"finish",
"(",
"self",
",",
"chunk",
"=",
"None",
")",
":",
"self",
".",
"_log_disconnect",
"(",
")",
"super",
"(",
"BaseHandler",
",",
"self",
")",
".",
"finish",
"(",
"chunk",
")"
] | Tornado `finish` handler | [
"Tornado",
"finish",
"handler"
] | python | train |
astorfi/speechpy | speechpy/feature.py | https://github.com/astorfi/speechpy/blob/9e99ae81398e7584e6234db371d6d7b5e8736192/speechpy/feature.py#L102-L153 | def mfcc(
signal,
sampling_frequency,
frame_length=0.020,
frame_stride=0.01,
num_cepstral=13,
num_filters=40,
fft_length=512,
low_frequency=0,
high_frequency=None,
dc_elimination=True):
"""Compute MFCC features from an audio signal.
... | [
"def",
"mfcc",
"(",
"signal",
",",
"sampling_frequency",
",",
"frame_length",
"=",
"0.020",
",",
"frame_stride",
"=",
"0.01",
",",
"num_cepstral",
"=",
"13",
",",
"num_filters",
"=",
"40",
",",
"fft_length",
"=",
"512",
",",
"low_frequency",
"=",
"0",
",",... | Compute MFCC features from an audio signal.
Args:
signal (array): the audio signal from which to compute features.
Should be an N x 1 array
sampling_frequency (int): the sampling frequency of the signal
we are working with.
frame_length (float): the length of e... | [
"Compute",
"MFCC",
"features",
"from",
"an",
"audio",
"signal",
"."
] | python | train |
edx/edx-enterprise | enterprise/migrations/0066_add_system_wide_enterprise_operator_role.py | https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/migrations/0066_add_system_wide_enterprise_operator_role.py#L16-L21 | def delete_roles(apps, schema_editor):
"""Delete the enterprise roles."""
SystemWideEnterpriseRole = apps.get_model('enterprise', 'SystemWideEnterpriseRole')
SystemWideEnterpriseRole.objects.filter(
name__in=[ENTERPRISE_OPERATOR_ROLE]
).delete() | [
"def",
"delete_roles",
"(",
"apps",
",",
"schema_editor",
")",
":",
"SystemWideEnterpriseRole",
"=",
"apps",
".",
"get_model",
"(",
"'enterprise'",
",",
"'SystemWideEnterpriseRole'",
")",
"SystemWideEnterpriseRole",
".",
"objects",
".",
"filter",
"(",
"name__in",
"=... | Delete the enterprise roles. | [
"Delete",
"the",
"enterprise",
"roles",
"."
] | python | valid |
Cue/scales | src/greplin/scales/__init__.py | https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/__init__.py#L669-L673 | def filterCollapsedItems(data):
"""Return a filtered iteration over a list of items."""
return ((key, value)\
for key, value in six.iteritems(data) \
if not (isinstance(value, StatContainer) and value.isCollapsed())) | [
"def",
"filterCollapsedItems",
"(",
"data",
")",
":",
"return",
"(",
"(",
"key",
",",
"value",
")",
"for",
"key",
",",
"value",
"in",
"six",
".",
"iteritems",
"(",
"data",
")",
"if",
"not",
"(",
"isinstance",
"(",
"value",
",",
"StatContainer",
")",
... | Return a filtered iteration over a list of items. | [
"Return",
"a",
"filtered",
"iteration",
"over",
"a",
"list",
"of",
"items",
"."
] | python | train |
jadolg/rocketchat_API | rocketchat_API/rocketchat.py | https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L328-L330 | def channels_open(self, room_id, **kwargs):
"""Adds the channel back to the user’s list of channels."""
return self.__call_api_post('channels.open', roomId=room_id, kwargs=kwargs) | [
"def",
"channels_open",
"(",
"self",
",",
"room_id",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"__call_api_post",
"(",
"'channels.open'",
",",
"roomId",
"=",
"room_id",
",",
"kwargs",
"=",
"kwargs",
")"
] | Adds the channel back to the user’s list of channels. | [
"Adds",
"the",
"channel",
"back",
"to",
"the",
"user’s",
"list",
"of",
"channels",
"."
] | python | train |
dusktreader/flask-praetorian | flask_praetorian/base.py | https://github.com/dusktreader/flask-praetorian/blob/d530cf3ffeffd61bfff1b8c79e8b45e9bfa0db0c/flask_praetorian/base.py#L198-L206 | def encrypt_password(self, raw_password):
"""
Encrypts a plaintext password using the stored passlib password context
"""
PraetorianError.require_condition(
self.pwd_ctx is not None,
"Praetorian must be initialized before this method is available",
)
... | [
"def",
"encrypt_password",
"(",
"self",
",",
"raw_password",
")",
":",
"PraetorianError",
".",
"require_condition",
"(",
"self",
".",
"pwd_ctx",
"is",
"not",
"None",
",",
"\"Praetorian must be initialized before this method is available\"",
",",
")",
"return",
"self",
... | Encrypts a plaintext password using the stored passlib password context | [
"Encrypts",
"a",
"plaintext",
"password",
"using",
"the",
"stored",
"passlib",
"password",
"context"
] | python | train |
tornadoweb/tornado | tornado/curl_httpclient.py | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/curl_httpclient.py#L141-L157 | def _handle_events(self, fd: int, events: int) -> None:
"""Called by IOLoop when there is activity on one of our
file descriptors.
"""
action = 0
if events & ioloop.IOLoop.READ:
action |= pycurl.CSELECT_IN
if events & ioloop.IOLoop.WRITE:
action |=... | [
"def",
"_handle_events",
"(",
"self",
",",
"fd",
":",
"int",
",",
"events",
":",
"int",
")",
"->",
"None",
":",
"action",
"=",
"0",
"if",
"events",
"&",
"ioloop",
".",
"IOLoop",
".",
"READ",
":",
"action",
"|=",
"pycurl",
".",
"CSELECT_IN",
"if",
"... | Called by IOLoop when there is activity on one of our
file descriptors. | [
"Called",
"by",
"IOLoop",
"when",
"there",
"is",
"activity",
"on",
"one",
"of",
"our",
"file",
"descriptors",
"."
] | python | train |
RudolfCardinal/pythonlib | cardinal_pythonlib/hash.py | https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/hash.py#L452-L512 | def murmur3_64(data: Union[bytes, bytearray], seed: int = 19820125) -> int:
"""
Pure 64-bit Python implementation of MurmurHash3; see
http://stackoverflow.com/questions/13305290/is-there-a-pure-python-implementation-of-murmurhash
(plus RNC bugfixes).
Args:
data: data to hash
s... | [
"def",
"murmur3_64",
"(",
"data",
":",
"Union",
"[",
"bytes",
",",
"bytearray",
"]",
",",
"seed",
":",
"int",
"=",
"19820125",
")",
"->",
"int",
":",
"# noqa",
"m",
"=",
"0xc6a4a7935bd1e995",
"r",
"=",
"47",
"mask",
"=",
"2",
"**",
"64",
"-",
"1",
... | Pure 64-bit Python implementation of MurmurHash3; see
http://stackoverflow.com/questions/13305290/is-there-a-pure-python-implementation-of-murmurhash
(plus RNC bugfixes).
Args:
data: data to hash
seed: seed
Returns:
integer hash | [
"Pure",
"64",
"-",
"bit",
"Python",
"implementation",
"of",
"MurmurHash3",
";",
"see",
"http",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"questions",
"/",
"13305290",
"/",
"is",
"-",
"there",
"-",
"a",
"-",
"pure",
"-",
"python",
"-",
"implementation"... | python | train |
polysquare/polysquare-generic-file-linter | polysquarelinter/spelling.py | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/spelling.py#L285-L301 | def filter_nonspellcheckable_tokens(line, block_out_regexes=None):
"""Return line with paths, urls and emails filtered out.
Block out other strings of text matching :block_out_regexes: if passed in.
"""
all_block_out_regexes = [
r"[^\s]*:[^\s]*[/\\][^\s]*",
r"[^\s]*[/\\][^\s]*",
... | [
"def",
"filter_nonspellcheckable_tokens",
"(",
"line",
",",
"block_out_regexes",
"=",
"None",
")",
":",
"all_block_out_regexes",
"=",
"[",
"r\"[^\\s]*:[^\\s]*[/\\\\][^\\s]*\"",
",",
"r\"[^\\s]*[/\\\\][^\\s]*\"",
",",
"r\"\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]+\\b\"",
"]",... | Return line with paths, urls and emails filtered out.
Block out other strings of text matching :block_out_regexes: if passed in. | [
"Return",
"line",
"with",
"paths",
"urls",
"and",
"emails",
"filtered",
"out",
"."
] | python | train |
Microsoft/knack | knack/arguments.py | https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/arguments.py#L306-L317 | def ignore(self, argument_dest, **kwargs):
""" Register an argument with type knack.arguments.ignore_type (hidden/ignored)
:param argument_dest: The destination argument to apply the ignore type to
:type argument_dest: str
"""
self._check_stale()
if not self._applicable(... | [
"def",
"ignore",
"(",
"self",
",",
"argument_dest",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_check_stale",
"(",
")",
"if",
"not",
"self",
".",
"_applicable",
"(",
")",
":",
"return",
"dest_option",
"=",
"[",
"'--__{}'",
".",
"format",
"(",
"... | Register an argument with type knack.arguments.ignore_type (hidden/ignored)
:param argument_dest: The destination argument to apply the ignore type to
:type argument_dest: str | [
"Register",
"an",
"argument",
"with",
"type",
"knack",
".",
"arguments",
".",
"ignore_type",
"(",
"hidden",
"/",
"ignored",
")"
] | python | train |
pgmpy/pgmpy | pgmpy/models/MarkovChain.py | https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/MarkovChain.py#L152-L171 | def add_variables_from(self, variables, cards):
"""
Add several variables to the model at once.
Parameters:
-----------
variables: array-like iterable object
List of variables to be added.
cards: array-like iterable object
List of cardinalities o... | [
"def",
"add_variables_from",
"(",
"self",
",",
"variables",
",",
"cards",
")",
":",
"for",
"var",
",",
"card",
"in",
"zip",
"(",
"variables",
",",
"cards",
")",
":",
"self",
".",
"add_variable",
"(",
"var",
",",
"card",
")"
] | Add several variables to the model at once.
Parameters:
-----------
variables: array-like iterable object
List of variables to be added.
cards: array-like iterable object
List of cardinalities of the variables to be added.
Examples:
---------
... | [
"Add",
"several",
"variables",
"to",
"the",
"model",
"at",
"once",
"."
] | python | train |
Syndace/python-x3dh | x3dh/state.py | https://github.com/Syndace/python-x3dh/blob/a6cec1ae858121b88bef1b178f5cda5e43d5c391/x3dh/state.py#L329-L438 | def getSharedSecretActive(
self,
other_public_bundle,
allow_zero_otpks = False
):
"""
Do the key exchange, as the active party. This involves selecting keys from the
passive parties' public bundle.
:param other_public_bundle: An instance of PublicBundle, fill... | [
"def",
"getSharedSecretActive",
"(",
"self",
",",
"other_public_bundle",
",",
"allow_zero_otpks",
"=",
"False",
")",
":",
"self",
".",
"__checkSPKTimestamp",
"(",
")",
"other_ik",
"=",
"self",
".",
"__KeyPair",
"(",
"pub",
"=",
"other_public_bundle",
".",
"ik",
... | Do the key exchange, as the active party. This involves selecting keys from the
passive parties' public bundle.
:param other_public_bundle: An instance of PublicBundle, filled with the public
data of the passive party.
:param allow_zero_otpks: A flag indicating whether bundles with ... | [
"Do",
"the",
"key",
"exchange",
"as",
"the",
"active",
"party",
".",
"This",
"involves",
"selecting",
"keys",
"from",
"the",
"passive",
"parties",
"public",
"bundle",
"."
] | python | train |
RJT1990/pyflux | pyflux/arma/arimax.py | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/arma/arimax.py#L298-L354 | def _mb_normal_model(self, beta, mini_batch):
""" Creates the structure of the model (model matrices, etc) for
a mini-batch Normal family ARIMAX model.
Here the structure is the same as for _normal_model() but we are going to
sample a random choice of data points (of length mini_batch).... | [
"def",
"_mb_normal_model",
"(",
"self",
",",
"beta",
",",
"mini_batch",
")",
":",
"rand_int",
"=",
"np",
".",
"random",
".",
"randint",
"(",
"low",
"=",
"0",
",",
"high",
"=",
"self",
".",
"data_length",
"-",
"mini_batch",
"-",
"self",
".",
"max_lag",
... | Creates the structure of the model (model matrices, etc) for
a mini-batch Normal family ARIMAX model.
Here the structure is the same as for _normal_model() but we are going to
sample a random choice of data points (of length mini_batch).
Parameters
----------
beta : np.... | [
"Creates",
"the",
"structure",
"of",
"the",
"model",
"(",
"model",
"matrices",
"etc",
")",
"for",
"a",
"mini",
"-",
"batch",
"Normal",
"family",
"ARIMAX",
"model",
"."
] | python | train |
gwww/elkm1 | elkm1_lib/counters.py | https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/counters.py#L13-L15 | def set(self, value):
"""(Helper) Set counter to value"""
self._elk.send(cx_encode(self._index, value)) | [
"def",
"set",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"_elk",
".",
"send",
"(",
"cx_encode",
"(",
"self",
".",
"_index",
",",
"value",
")",
")"
] | (Helper) Set counter to value | [
"(",
"Helper",
")",
"Set",
"counter",
"to",
"value"
] | python | train |
synw/goerr | goerr/__init__.py | https://github.com/synw/goerr/blob/08b3809d6715bffe26899a769d96fa5de8573faf/goerr/__init__.py#L75-L81 | def info(self, *args) -> "Err":
"""
Creates an info message
"""
error = self._create_err("info", *args)
print(self._errmsg(error))
return error | [
"def",
"info",
"(",
"self",
",",
"*",
"args",
")",
"->",
"\"Err\"",
":",
"error",
"=",
"self",
".",
"_create_err",
"(",
"\"info\"",
",",
"*",
"args",
")",
"print",
"(",
"self",
".",
"_errmsg",
"(",
"error",
")",
")",
"return",
"error"
] | Creates an info message | [
"Creates",
"an",
"info",
"message"
] | python | train |
ThomasChiroux/attowiki | src/attowiki/git_tools.py | https://github.com/ThomasChiroux/attowiki/blob/6c93c420305490d324fdc95a7b40b2283a222183/src/attowiki/git_tools.py#L115-L133 | def reset_to_last_commit():
"""reset a modified file to his last commit status
This method does the same than a ::
$ git reset --hard
Keyword Arguments:
<none>
Returns:
<nothing>
"""
try:
repo = Repo()
gitcmd = repo.git
gitcmd.reset(hard=True)
... | [
"def",
"reset_to_last_commit",
"(",
")",
":",
"try",
":",
"repo",
"=",
"Repo",
"(",
")",
"gitcmd",
"=",
"repo",
".",
"git",
"gitcmd",
".",
"reset",
"(",
"hard",
"=",
"True",
")",
"except",
"Exception",
":",
"pass"
] | reset a modified file to his last commit status
This method does the same than a ::
$ git reset --hard
Keyword Arguments:
<none>
Returns:
<nothing> | [
"reset",
"a",
"modified",
"file",
"to",
"his",
"last",
"commit",
"status"
] | python | train |
Kaggle/kaggle-api | kaggle/api/kaggle_api_extended.py | https://github.com/Kaggle/kaggle-api/blob/65f14b1386470c5784d4753e491478e7537660d9/kaggle/api/kaggle_api_extended.py#L2038-L2051 | def kernels_output_cli(self,
kernel,
kernel_opt=None,
path=None,
force=False,
quiet=False):
""" client wrapper for kernels_output, with same arguments. Extra
argumen... | [
"def",
"kernels_output_cli",
"(",
"self",
",",
"kernel",
",",
"kernel_opt",
"=",
"None",
",",
"path",
"=",
"None",
",",
"force",
"=",
"False",
",",
"quiet",
"=",
"False",
")",
":",
"kernel",
"=",
"kernel",
"or",
"kernel_opt",
"self",
".",
"kernels_output... | client wrapper for kernels_output, with same arguments. Extra
arguments are described below, and see kernels_output for others.
Parameters
==========
kernel_opt: option from client instead of kernel, if not defined | [
"client",
"wrapper",
"for",
"kernels_output",
"with",
"same",
"arguments",
".",
"Extra",
"arguments",
"are",
"described",
"below",
"and",
"see",
"kernels_output",
"for",
"others",
".",
"Parameters",
"==========",
"kernel_opt",
":",
"option",
"from",
"client",
"ins... | python | train |
AndrewAnnex/SpiceyPy | spiceypy/spiceypy.py | https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L15405-L15425 | def wnexpd(left, right, window):
"""
Expand each of the intervals of a double precision window.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/wnexpd_c.html
:param left: Amount subtracted from each left endpoint.
:type left: float
:param right: Amount added to each right endpoint.
... | [
"def",
"wnexpd",
"(",
"left",
",",
"right",
",",
"window",
")",
":",
"assert",
"isinstance",
"(",
"window",
",",
"stypes",
".",
"SpiceCell",
")",
"assert",
"window",
".",
"dtype",
"==",
"1",
"left",
"=",
"ctypes",
".",
"c_double",
"(",
"left",
")",
"... | Expand each of the intervals of a double precision window.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/wnexpd_c.html
:param left: Amount subtracted from each left endpoint.
:type left: float
:param right: Amount added to each right endpoint.
:type right: float
:param window: Wind... | [
"Expand",
"each",
"of",
"the",
"intervals",
"of",
"a",
"double",
"precision",
"window",
"."
] | python | train |
programa-stic/barf-project | barf/barf.py | https://github.com/programa-stic/barf-project/blob/18ed9e5eace55f7bf6015ec57f037c364099021c/barf/barf.py#L128-L138 | def _setup_x86_arch(self, arch_mode=None):
"""Set up x86 architecture.
"""
if arch_mode is None:
arch_mode = self.binary.architecture_mode
# Set up architecture information
self.name = "x86"
self.arch_info = X86ArchitectureInformation(arch_mode)
self.... | [
"def",
"_setup_x86_arch",
"(",
"self",
",",
"arch_mode",
"=",
"None",
")",
":",
"if",
"arch_mode",
"is",
"None",
":",
"arch_mode",
"=",
"self",
".",
"binary",
".",
"architecture_mode",
"# Set up architecture information",
"self",
".",
"name",
"=",
"\"x86\"",
"... | Set up x86 architecture. | [
"Set",
"up",
"x86",
"architecture",
"."
] | python | train |
ewels/MultiQC | multiqc/modules/bowtie2/bowtie2.py | https://github.com/ewels/MultiQC/blob/2037d6322b2554146a74efbf869156ad20d4c4ec/multiqc/modules/bowtie2/bowtie2.py#L206-L263 | def bowtie2_alignment_plot (self):
""" Make the HighCharts HTML to plot the alignment rates """
half_warning = ''
for s_name in self.bowtie2_data:
if 'paired_aligned_mate_one_halved' in self.bowtie2_data[s_name] or 'paired_aligned_mate_multi_halved' in self.bowtie2_data[s_name] or '... | [
"def",
"bowtie2_alignment_plot",
"(",
"self",
")",
":",
"half_warning",
"=",
"''",
"for",
"s_name",
"in",
"self",
".",
"bowtie2_data",
":",
"if",
"'paired_aligned_mate_one_halved'",
"in",
"self",
".",
"bowtie2_data",
"[",
"s_name",
"]",
"or",
"'paired_aligned_mate... | Make the HighCharts HTML to plot the alignment rates | [
"Make",
"the",
"HighCharts",
"HTML",
"to",
"plot",
"the",
"alignment",
"rates"
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.