nwo stringlengths 5 106 | sha stringlengths 40 40 | path stringlengths 4 174 | language stringclasses 1
value | identifier stringlengths 1 140 | parameters stringlengths 0 87.7k | argument_list stringclasses 1
value | return_statement stringlengths 0 426k | docstring stringlengths 0 64.3k | docstring_summary stringlengths 0 26.3k | docstring_tokens list | function stringlengths 18 4.83M | function_tokens list | url stringlengths 83 304 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
skylander86/lambda-text-extractor | 6da52d077a2fc571e38bfe29c33ae68f6443cd5a | lib-linux_x64/pptx/shapes/shapetree.py | python | NotesSlideShapes.ph_basename | (self, ph_type) | return {
PP_PLACEHOLDER.BODY: 'Notes Placeholder',
PP_PLACEHOLDER.DATE: 'Date Placeholder',
PP_PLACEHOLDER.FOOTER: 'Footer Placeholder',
PP_PLACEHOLDER.HEADER: 'Header Placeholder',
PP_PLACEHOLDER.SLIDE_IMAGE: 'Slide Image Placehol... | Return the base name for a placeholder of *ph_type* in this shape
collection. A notes slide uses a different name for the body
placeholder and has some unique placeholder types, so this
method overrides the default in the base class. | Return the base name for a placeholder of *ph_type* in this shape
collection. A notes slide uses a different name for the body
placeholder and has some unique placeholder types, so this
method overrides the default in the base class. | [
"Return",
"the",
"base",
"name",
"for",
"a",
"placeholder",
"of",
"*",
"ph_type",
"*",
"in",
"this",
"shape",
"collection",
".",
"A",
"notes",
"slide",
"uses",
"a",
"different",
"name",
"for",
"the",
"body",
"placeholder",
"and",
"has",
"some",
"unique",
... | def ph_basename(self, ph_type):
"""
Return the base name for a placeholder of *ph_type* in this shape
collection. A notes slide uses a different name for the body
placeholder and has some unique placeholder types, so this
method overrides the default in the base class.
""... | [
"def",
"ph_basename",
"(",
"self",
",",
"ph_type",
")",
":",
"return",
"{",
"PP_PLACEHOLDER",
".",
"BODY",
":",
"'Notes Placeholder'",
",",
"PP_PLACEHOLDER",
".",
"DATE",
":",
"'Date Placeholder'",
",",
"PP_PLACEHOLDER",
".",
"FOOTER",
":",
"'Footer Placeholder'",... | https://github.com/skylander86/lambda-text-extractor/blob/6da52d077a2fc571e38bfe29c33ae68f6443cd5a/lib-linux_x64/pptx/shapes/shapetree.py#L335-L349 | |
NifTK/NiftyNet | 935bf4334cd00fa9f9d50f6a95ddcbfdde4031e0 | niftynet/engine/application_initializer.py | python | HeUniform.get_instance | (args) | return VarianceScaling.get_instance(args) | create an instance of the initializer | create an instance of the initializer | [
"create",
"an",
"instance",
"of",
"the",
"initializer"
] | def get_instance(args):
# pylint: disable=unused-argument
"""
create an instance of the initializer
"""
if not args:
args = {"scale": "2.", "mode": "fan_in", "distribution": "uniform"}
return VarianceScaling.get_instance(args) | [
"def",
"get_instance",
"(",
"args",
")",
":",
"# pylint: disable=unused-argument",
"if",
"not",
"args",
":",
"args",
"=",
"{",
"\"scale\"",
":",
"\"2.\"",
",",
"\"mode\"",
":",
"\"fan_in\"",
",",
"\"distribution\"",
":",
"\"uniform\"",
"}",
"return",
"VarianceSc... | https://github.com/NifTK/NiftyNet/blob/935bf4334cd00fa9f9d50f6a95ddcbfdde4031e0/niftynet/engine/application_initializer.py#L155-L162 | |
tvaddonsco/script.module.urlresolver | ddeca574c133d51879624bf3059c6e73445d90bc | lib/urlresolver/plugins/streamable.py | python | StreamableResolver.base36encode | (self, number, alphabet='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ') | return base36 | Converts a positive integer to a base36 string. | Converts a positive integer to a base36 string. | [
"Converts",
"a",
"positive",
"integer",
"to",
"a",
"base36",
"string",
"."
] | def base36encode(self, number, alphabet='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'):
"""Converts a positive integer to a base36 string."""
base36 = ''
if 0 <= number < len(alphabet):
return alphabet[number]
while number != 0:
number, i = divmod(number, len(alphabet)... | [
"def",
"base36encode",
"(",
"self",
",",
"number",
",",
"alphabet",
"=",
"'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'",
")",
":",
"base36",
"=",
"''",
"if",
"0",
"<=",
"number",
"<",
"len",
"(",
"alphabet",
")",
":",
"return",
"alphabet",
"[",
"number",
"]",
"w... | https://github.com/tvaddonsco/script.module.urlresolver/blob/ddeca574c133d51879624bf3059c6e73445d90bc/lib/urlresolver/plugins/streamable.py#L54-L65 | |
XX-net/XX-Net | a9898cfcf0084195fb7e69b6bc834e59aecdf14f | python3.8.2/Lib/difflib.py | python | context_diff | (a, b, fromfile='', tofile='',
fromfiledate='', tofiledate='', n=3, lineterm='\n') | r"""
Compare two sequences of lines; generate the delta as a context diff.
Context diffs are a compact way of showing line changes and a few
lines of context. The number of context lines is set by 'n' which
defaults to three.
By default, the diff control lines (those with *** or ---) are
crea... | r"""
Compare two sequences of lines; generate the delta as a context diff. | [
"r",
"Compare",
"two",
"sequences",
"of",
"lines",
";",
"generate",
"the",
"delta",
"as",
"a",
"context",
"diff",
"."
] | def context_diff(a, b, fromfile='', tofile='',
fromfiledate='', tofiledate='', n=3, lineterm='\n'):
r"""
Compare two sequences of lines; generate the delta as a context diff.
Context diffs are a compact way of showing line changes and a few
lines of context. The number of context line... | [
"def",
"context_diff",
"(",
"a",
",",
"b",
",",
"fromfile",
"=",
"''",
",",
"tofile",
"=",
"''",
",",
"fromfiledate",
"=",
"''",
",",
"tofiledate",
"=",
"''",
",",
"n",
"=",
"3",
",",
"lineterm",
"=",
"'\\n'",
")",
":",
"_check_types",
"(",
"a",
... | https://github.com/XX-net/XX-Net/blob/a9898cfcf0084195fb7e69b6bc834e59aecdf14f/python3.8.2/Lib/difflib.py#L1210-L1284 | ||
evilhero/mylar | dbee01d7e48e8c717afa01b2de1946c5d0b956cb | lib/mako/runtime.py | python | capture | (context, callable_, *args, **kwargs) | return buf.getvalue() | Execute the given template def, capturing the output into
a buffer.
See the example in :ref:`namespaces_python_modules`. | Execute the given template def, capturing the output into
a buffer. | [
"Execute",
"the",
"given",
"template",
"def",
"capturing",
"the",
"output",
"into",
"a",
"buffer",
"."
] | def capture(context, callable_, *args, **kwargs):
"""Execute the given template def, capturing the output into
a buffer.
See the example in :ref:`namespaces_python_modules`.
"""
if not compat.callable(callable_):
raise exceptions.RuntimeException(
"capture() function expects a... | [
"def",
"capture",
"(",
"context",
",",
"callable_",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"compat",
".",
"callable",
"(",
"callable_",
")",
":",
"raise",
"exceptions",
".",
"RuntimeException",
"(",
"\"capture() function expects a ... | https://github.com/evilhero/mylar/blob/dbee01d7e48e8c717afa01b2de1946c5d0b956cb/lib/mako/runtime.py#L698-L716 | |
NanYoMy/DHT-woodworm | e28bbff214bc3c41ea462854256dd499fb8a6eb0 | btdht/node.py | python | Node.pong | (self, socket=None, trans_id=None, sender_id=None, lock=None) | Construct reply message for ping | Construct reply message for ping | [
"Construct",
"reply",
"message",
"for",
"ping"
] | def pong(self, socket=None, trans_id=None, sender_id=None, lock=None):
""" Construct reply message for ping """
message = {
"y": "r",
"r": {
"id": sender_id
}
}
logger.debug("pong msg to %s:%d, y:%s, t: %r" % (
self.host,
... | [
"def",
"pong",
"(",
"self",
",",
"socket",
"=",
"None",
",",
"trans_id",
"=",
"None",
",",
"sender_id",
"=",
"None",
",",
"lock",
"=",
"None",
")",
":",
"message",
"=",
"{",
"\"y\"",
":",
"\"r\"",
",",
"\"r\"",
":",
"{",
"\"id\"",
":",
"sender_id",... | https://github.com/NanYoMy/DHT-woodworm/blob/e28bbff214bc3c41ea462854256dd499fb8a6eb0/btdht/node.py#L111-L125 | ||
Chia-Network/chia-blockchain | 34d44c1324ae634a0896f7b02eaa2802af9526cd | chia/wallet/wallet_state_manager.py | python | WalletStateManager.remove_from_queue | (
self,
spendbundle_id: bytes32,
name: str,
send_status: MempoolInclusionStatus,
error: Optional[Err],
) | Full node received our transaction, no need to keep it in queue anymore | Full node received our transaction, no need to keep it in queue anymore | [
"Full",
"node",
"received",
"our",
"transaction",
"no",
"need",
"to",
"keep",
"it",
"in",
"queue",
"anymore"
] | async def remove_from_queue(
self,
spendbundle_id: bytes32,
name: str,
send_status: MempoolInclusionStatus,
error: Optional[Err],
):
"""
Full node received our transaction, no need to keep it in queue anymore
"""
updated = await self.tx_store.i... | [
"async",
"def",
"remove_from_queue",
"(",
"self",
",",
"spendbundle_id",
":",
"bytes32",
",",
"name",
":",
"str",
",",
"send_status",
":",
"MempoolInclusionStatus",
",",
"error",
":",
"Optional",
"[",
"Err",
"]",
",",
")",
":",
"updated",
"=",
"await",
"se... | https://github.com/Chia-Network/chia-blockchain/blob/34d44c1324ae634a0896f7b02eaa2802af9526cd/chia/wallet/wallet_state_manager.py#L897-L911 | ||
home-assistant/core | 265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1 | homeassistant/components/water_heater/__init__.py | python | WaterHeaterEntity.min_temp | (self) | return convert_temperature(
DEFAULT_MIN_TEMP, TEMP_FAHRENHEIT, self.temperature_unit
) | Return the minimum temperature. | Return the minimum temperature. | [
"Return",
"the",
"minimum",
"temperature",
"."
] | def min_temp(self):
"""Return the minimum temperature."""
if hasattr(self, "_attr_min_temp"):
return self._attr_min_temp
return convert_temperature(
DEFAULT_MIN_TEMP, TEMP_FAHRENHEIT, self.temperature_unit
) | [
"def",
"min_temp",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"\"_attr_min_temp\"",
")",
":",
"return",
"self",
".",
"_attr_min_temp",
"return",
"convert_temperature",
"(",
"DEFAULT_MIN_TEMP",
",",
"TEMP_FAHRENHEIT",
",",
"self",
".",
"temperature... | https://github.com/home-assistant/core/blob/265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1/homeassistant/components/water_heater/__init__.py#L314-L320 | |
brython-dev/brython | 9cba5fb7f43a9b52fff13e89b403e02a1dfaa5f3 | www/src/Lib/bdb.py | python | stop_here | (self, frame) | return False | Return True if frame is below the starting frame in the stack. | Return True if frame is below the starting frame in the stack. | [
"Return",
"True",
"if",
"frame",
"is",
"below",
"the",
"starting",
"frame",
"in",
"the",
"stack",
"."
] | def stop_here(self, frame):
"Return True if frame is below the starting frame in the stack."
# (CT) stopframe may now also be None, see dispatch_call.
# (CT) the former test for None is therefore removed from here.
if self.skip and \
self.is_skipped_module(frame.f_globals.... | [
"def",
"stop_here",
"(",
"self",
",",
"frame",
")",
":",
"# (CT) stopframe may now also be None, see dispatch_call.",
"# (CT) the former test for None is therefore removed from here.",
"if",
"self",
".",
"skip",
"and",
"self",
".",
"is_skipped_module",
"(",
"frame",
".",
"f... | https://github.com/brython-dev/brython/blob/9cba5fb7f43a9b52fff13e89b403e02a1dfaa5f3/www/src/Lib/bdb.py#L202-L215 | |
robinhood/deux | 5b1e774beba7d63b73b5a3f3c1e16afa54706363 | deux/abstract_models.py | python | AbstractMultiFactorAuth.enabled | (self) | return self.challenge_type in CHALLENGE_TYPES | Returns if MFA is enabled. | Returns if MFA is enabled. | [
"Returns",
"if",
"MFA",
"is",
"enabled",
"."
] | def enabled(self):
"""Returns if MFA is enabled."""
return self.challenge_type in CHALLENGE_TYPES | [
"def",
"enabled",
"(",
"self",
")",
":",
"return",
"self",
".",
"challenge_type",
"in",
"CHALLENGE_TYPES"
] | https://github.com/robinhood/deux/blob/5b1e774beba7d63b73b5a3f3c1e16afa54706363/deux/abstract_models.py#L64-L66 | |
matplotlib/matplotlib | 8d7a2b9d2a38f01ee0d6802dd4f9e98aec812322 | lib/matplotlib/textpath.py | python | TextPath._revalidate_path | (self) | Update the path if necessary.
The path for the text is initially create with the font size of
`.FONT_SCALE`, and this path is rescaled to other size when necessary. | Update the path if necessary. | [
"Update",
"the",
"path",
"if",
"necessary",
"."
] | def _revalidate_path(self):
"""
Update the path if necessary.
The path for the text is initially create with the font size of
`.FONT_SCALE`, and this path is rescaled to other size when necessary.
"""
if self._invalid or self._cached_vertices is None:
tr = (A... | [
"def",
"_revalidate_path",
"(",
"self",
")",
":",
"if",
"self",
".",
"_invalid",
"or",
"self",
".",
"_cached_vertices",
"is",
"None",
":",
"tr",
"=",
"(",
"Affine2D",
"(",
")",
".",
"scale",
"(",
"self",
".",
"_size",
"/",
"text_to_path",
".",
"FONT_SC... | https://github.com/matplotlib/matplotlib/blob/8d7a2b9d2a38f01ee0d6802dd4f9e98aec812322/lib/matplotlib/textpath.py#L418-L431 | ||
lvsh/keywordfinder | 2655a3bd6b05e09b8e1a7f463a322aaf25963ae8 | example.py | python | main | () | [] | def main():
if len(sys.argv)==1:
raise ValueError('Must specify input text file.')
else:
f = open(sys.argv[1],'r')
text = f.read()
f.close()
# load keyword classifier
preload = 1
classifier_type = 'logistic'
keyword_classifier = get_keywordclassifier(preload,classifier_type)['model']
# extrac... | [
"def",
"main",
"(",
")",
":",
"if",
"len",
"(",
"sys",
".",
"argv",
")",
"==",
"1",
":",
"raise",
"ValueError",
"(",
"'Must specify input text file.'",
")",
"else",
":",
"f",
"=",
"open",
"(",
"sys",
".",
"argv",
"[",
"1",
"]",
",",
"'r'",
")",
"... | https://github.com/lvsh/keywordfinder/blob/2655a3bd6b05e09b8e1a7f463a322aaf25963ae8/example.py#L13-L41 | ||||
dipu-bd/lightnovel-crawler | eca7a71f217ce7a6b0a54d2e2afb349571871880 | sources/en/s/scribblehub.py | python | ScribbleHubCrawler.download_chapter_list | (self, page) | return soup.select('a.toc_a') | Download list of chapters and volumes. | Download list of chapters and volumes. | [
"Download",
"list",
"of",
"chapters",
"and",
"volumes",
"."
] | def download_chapter_list(self, page):
'''Download list of chapters and volumes.'''
url = self.novel_url.split('?')[0].strip('/')
url += '?toc=%s#content1' % page
soup = self.get_soup(url)
logger.debug('Crawling chapters url in page %s' % page)
return soup.select('a.toc_a... | [
"def",
"download_chapter_list",
"(",
"self",
",",
"page",
")",
":",
"url",
"=",
"self",
".",
"novel_url",
".",
"split",
"(",
"'?'",
")",
"[",
"0",
"]",
".",
"strip",
"(",
"'/'",
")",
"url",
"+=",
"'?toc=%s#content1'",
"%",
"page",
"soup",
"=",
"self"... | https://github.com/dipu-bd/lightnovel-crawler/blob/eca7a71f217ce7a6b0a54d2e2afb349571871880/sources/en/s/scribblehub.py#L78-L84 | |
sethmlarson/virtualbox-python | 984a6e2cb0e8996f4df40f4444c1528849f1c70d | virtualbox/library.py | python | IVirtualBox.package_type | (self) | return ret | Get str value for 'packageType'
A string representing the package type of this product. The
format is OS_ARCH_DIST where OS is either WINDOWS, LINUX,
SOLARIS, DARWIN. ARCH is either 32BITS or 64BITS. DIST
is either GENERIC, UBUNTU_606, UBUNTU_710, or something like
this. | Get str value for 'packageType'
A string representing the package type of this product. The
format is OS_ARCH_DIST where OS is either WINDOWS, LINUX,
SOLARIS, DARWIN. ARCH is either 32BITS or 64BITS. DIST
is either GENERIC, UBUNTU_606, UBUNTU_710, or something like
this. | [
"Get",
"str",
"value",
"for",
"packageType",
"A",
"string",
"representing",
"the",
"package",
"type",
"of",
"this",
"product",
".",
"The",
"format",
"is",
"OS_ARCH_DIST",
"where",
"OS",
"is",
"either",
"WINDOWS",
"LINUX",
"SOLARIS",
"DARWIN",
".",
"ARCH",
"i... | def package_type(self):
"""Get str value for 'packageType'
A string representing the package type of this product. The
format is OS_ARCH_DIST where OS is either WINDOWS, LINUX,
SOLARIS, DARWIN. ARCH is either 32BITS or 64BITS. DIST
is either GENERIC, UBUNTU_606, UBUNTU_710, or so... | [
"def",
"package_type",
"(",
"self",
")",
":",
"ret",
"=",
"self",
".",
"_get_attr",
"(",
"\"packageType\"",
")",
"return",
"ret"
] | https://github.com/sethmlarson/virtualbox-python/blob/984a6e2cb0e8996f4df40f4444c1528849f1c70d/virtualbox/library.py#L10047-L10056 | |
huawei-noah/Pretrained-Language-Model | d4694a134bdfacbaef8ff1d99735106bd3b3372b | AutoTinyBERT/superbert_run_en_classifier.py | python | QqpProcessor.get_dev_examples | (self, data_dir) | return self._create_examples(
self._read_tsv(os.path.join(data_dir, "dev.tsv")), "dev") | See base class. | See base class. | [
"See",
"base",
"class",
"."
] | def get_dev_examples(self, data_dir):
"""See base class."""
return self._create_examples(
self._read_tsv(os.path.join(data_dir, "dev.tsv")), "dev") | [
"def",
"get_dev_examples",
"(",
"self",
",",
"data_dir",
")",
":",
"return",
"self",
".",
"_create_examples",
"(",
"self",
".",
"_read_tsv",
"(",
"os",
".",
"path",
".",
"join",
"(",
"data_dir",
",",
"\"dev.tsv\"",
")",
")",
",",
"\"dev\"",
")"
] | https://github.com/huawei-noah/Pretrained-Language-Model/blob/d4694a134bdfacbaef8ff1d99735106bd3b3372b/AutoTinyBERT/superbert_run_en_classifier.py#L387-L390 | |
Source-Python-Dev-Team/Source.Python | d0ffd8ccbd1e9923c9bc44936f20613c1c76b7fb | addons/source-python/Python3/distutils/cmd.py | python | Command.set_undefined_options | (self, src_cmd, *option_pairs) | Set the values of any "undefined" options from corresponding
option values in some other command object. "Undefined" here means
"is None", which is the convention used to indicate that an option
has not been changed between 'initialize_options()' and
'finalize_options()'. Usually calle... | Set the values of any "undefined" options from corresponding
option values in some other command object. "Undefined" here means
"is None", which is the convention used to indicate that an option
has not been changed between 'initialize_options()' and
'finalize_options()'. Usually calle... | [
"Set",
"the",
"values",
"of",
"any",
"undefined",
"options",
"from",
"corresponding",
"option",
"values",
"in",
"some",
"other",
"command",
"object",
".",
"Undefined",
"here",
"means",
"is",
"None",
"which",
"is",
"the",
"convention",
"used",
"to",
"indicate",... | def set_undefined_options(self, src_cmd, *option_pairs):
"""Set the values of any "undefined" options from corresponding
option values in some other command object. "Undefined" here means
"is None", which is the convention used to indicate that an option
has not been changed between 'in... | [
"def",
"set_undefined_options",
"(",
"self",
",",
"src_cmd",
",",
"*",
"option_pairs",
")",
":",
"# Option_pairs: list of (src_option, dst_option) tuples",
"src_cmd_obj",
"=",
"self",
".",
"distribution",
".",
"get_command_obj",
"(",
"src_cmd",
")",
"src_cmd_obj",
".",
... | https://github.com/Source-Python-Dev-Team/Source.Python/blob/d0ffd8ccbd1e9923c9bc44936f20613c1c76b7fb/addons/source-python/Python3/distutils/cmd.py#L271-L290 | ||
oracle/graalpython | 577e02da9755d916056184ec441c26e00b70145c | graalpython/lib-python/3/tkinter/tix.py | python | ScrolledHList.__init__ | (self, master, cnf={}, **kw) | [] | def __init__(self, master, cnf={}, **kw):
TixWidget.__init__(self, master, 'tixScrolledHList', ['options'],
cnf, kw)
self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
self.subwidget_list['hsb'] =... | [
"def",
"__init__",
"(",
"self",
",",
"master",
",",
"cnf",
"=",
"{",
"}",
",",
"*",
"*",
"kw",
")",
":",
"TixWidget",
".",
"__init__",
"(",
"self",
",",
"master",
",",
"'tixScrolledHList'",
",",
"[",
"'options'",
"]",
",",
"cnf",
",",
"kw",
")",
... | https://github.com/oracle/graalpython/blob/577e02da9755d916056184ec441c26e00b70145c/graalpython/lib-python/3/tkinter/tix.py#L1301-L1306 | ||||
owid/covid-19-data | 936aeae6cfbdc0163939ed7bd8ecdbb2582c0a92 | scripts/src/cowidev/vax/batch/sweden.py | python | Sweden.pipe_columns | (self, df: pd.DataFrame) | return df.assign(location=self.location, source_url=self.source_url_daily) | [] | def pipe_columns(self, df: pd.DataFrame) -> pd.DataFrame:
return df.assign(location=self.location, source_url=self.source_url_daily) | [
"def",
"pipe_columns",
"(",
"self",
",",
"df",
":",
"pd",
".",
"DataFrame",
")",
"->",
"pd",
".",
"DataFrame",
":",
"return",
"df",
".",
"assign",
"(",
"location",
"=",
"self",
".",
"location",
",",
"source_url",
"=",
"self",
".",
"source_url_daily",
"... | https://github.com/owid/covid-19-data/blob/936aeae6cfbdc0163939ed7bd8ecdbb2582c0a92/scripts/src/cowidev/vax/batch/sweden.py#L144-L145 | |||
IBM/pytorchpipe | 9cb17271666061cb19fe24197ecd5e4c8d32c5da | ptp/configuration/config_registry.py | python | ConfigRegistry.__init__ | (self) | Constructor:
- Call base constructor (:py:class:`Mapping`),
- Initializes empty parameters dicts for:
- `Default` parameters,
- `Config` parameters,
- Resulting tree. | Constructor: | [
"Constructor",
":"
] | def __init__(self):
"""
Constructor:
- Call base constructor (:py:class:`Mapping`),
- Initializes empty parameters dicts for:
- `Default` parameters,
- `Config` parameters,
- Resulting tree.
"""
super(ConfigRegis... | [
"def",
"__init__",
"(",
"self",
")",
":",
"super",
"(",
"ConfigRegistry",
",",
"self",
")",
".",
"__init__",
"(",
")",
"# Default parameters set in the code.",
"self",
".",
"_clear_registry",
"(",
")"
] | https://github.com/IBM/pytorchpipe/blob/9cb17271666061cb19fe24197ecd5e4c8d32c5da/ptp/configuration/config_registry.py#L55-L71 | ||
aidiary/PRML | db2dfc10bd39dc5649528d3778aa5fffb283186b | ch9/kmeans.py | python | J | (X, mean, r) | return summation | K-meansの目的関数(最小化を目指す) | K-meansの目的関数(最小化を目指す) | [
"K",
"-",
"meansの目的関数(最小化を目指す)"
] | def J(X, mean, r):
"""K-meansの目的関数(最小化を目指す)"""
summation = 0.0
for n in range(len(X)):
temp = 0.0
for k in range(K):
temp += r[n, k] * np.linalg.norm(X[n] - mean[k]) ** 2
summation += temp
return summation | [
"def",
"J",
"(",
"X",
",",
"mean",
",",
"r",
")",
":",
"summation",
"=",
"0.0",
"for",
"n",
"in",
"range",
"(",
"len",
"(",
"X",
")",
")",
":",
"temp",
"=",
"0.0",
"for",
"k",
"in",
"range",
"(",
"K",
")",
":",
"temp",
"+=",
"r",
"[",
"n"... | https://github.com/aidiary/PRML/blob/db2dfc10bd39dc5649528d3778aa5fffb283186b/ch9/kmeans.py#L26-L34 | |
mihaip/readerisdead | 0e35cf26e88f27e0a07432182757c1ce230f6936 | feed_archive/feed_archive.py | python | get_stream_id | (feed_url) | return 'feed/%s' % feed_url | [] | def get_stream_id(feed_url):
try:
parsed = urlparse.urlparse(feed_url)
# If the feed is generated by Reader itself, turn it into the underlying
# stream ID.
if parsed.hostname.startswith('www.google.') and \
parsed.path.startswith(_READER_SHARED_TAG_FEED_URL_PATH_PREFIX):
reader_url_pref... | [
"def",
"get_stream_id",
"(",
"feed_url",
")",
":",
"try",
":",
"parsed",
"=",
"urlparse",
".",
"urlparse",
"(",
"feed_url",
")",
"# If the feed is generated by Reader itself, turn it into the underlying",
"# stream ID.",
"if",
"parsed",
".",
"hostname",
".",
"startswith... | https://github.com/mihaip/readerisdead/blob/0e35cf26e88f27e0a07432182757c1ce230f6936/feed_archive/feed_archive.py#L241-L254 | |||
saltstack/salt-contrib | 062355938ad1cced273056e9c23dc344c6a2c858 | modules/smx.py | python | bundle_start | (bundle) | start the bundle
CLI Examples::
salt '*' smx.bundle_start 'some.bundle.name' | start the bundle | [
"start",
"the",
"bundle"
] | def bundle_start(bundle):
'''
start the bundle
CLI Examples::
salt '*' smx.bundle_start 'some.bundle.name'
'''
if not bundle_exists(bundle):
return 'missing'
run('osgi:start {0}'.format(bundle))
if bundle_active(bundle):
return 'active'
else:
return '... | [
"def",
"bundle_start",
"(",
"bundle",
")",
":",
"if",
"not",
"bundle_exists",
"(",
"bundle",
")",
":",
"return",
"'missing'",
"run",
"(",
"'osgi:start {0}'",
".",
"format",
"(",
"bundle",
")",
")",
"if",
"bundle_active",
"(",
"bundle",
")",
":",
"return",
... | https://github.com/saltstack/salt-contrib/blob/062355938ad1cced273056e9c23dc344c6a2c858/modules/smx.py#L228-L245 | ||
PyTorchLightning/lightning-bolts | 22e494e546e7fe322d6b4cf36258819c7ba58e02 | pl_bolts/datamodules/cifar10_datamodule.py | python | TinyCIFAR10DataModule.__init__ | (
self,
data_dir: Optional[str] = None,
val_split: int = 50,
num_workers: int = 0,
num_samples: int = 100,
labels: Optional[Sequence] = (1, 5, 8),
*args: Any,
**kwargs: Any,
) | Args:
data_dir: where to save/load the data
val_split: how many of the training images to use for the validation split
num_workers: how many workers to use for loading data
num_samples: number of examples per selected class/label
labels: list selected CIFAR10 ... | Args:
data_dir: where to save/load the data
val_split: how many of the training images to use for the validation split
num_workers: how many workers to use for loading data
num_samples: number of examples per selected class/label
labels: list selected CIFAR10 ... | [
"Args",
":",
"data_dir",
":",
"where",
"to",
"save",
"/",
"load",
"the",
"data",
"val_split",
":",
"how",
"many",
"of",
"the",
"training",
"images",
"to",
"use",
"for",
"the",
"validation",
"split",
"num_workers",
":",
"how",
"many",
"workers",
"to",
"us... | def __init__(
self,
data_dir: Optional[str] = None,
val_split: int = 50,
num_workers: int = 0,
num_samples: int = 100,
labels: Optional[Sequence] = (1, 5, 8),
*args: Any,
**kwargs: Any,
) -> None:
"""
Args:
data_dir: where t... | [
"def",
"__init__",
"(",
"self",
",",
"data_dir",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"val_split",
":",
"int",
"=",
"50",
",",
"num_workers",
":",
"int",
"=",
"0",
",",
"num_samples",
":",
"int",
"=",
"100",
",",
"labels",
":",
"Opti... | https://github.com/PyTorchLightning/lightning-bolts/blob/22e494e546e7fe322d6b4cf36258819c7ba58e02/pl_bolts/datamodules/cifar10_datamodule.py#L147-L169 | ||
mathics/Mathics | 318e06dea8f1c70758a50cb2f95c9900150e3a68 | mathics/builtin/numbers/numbertheory.py | python | PrimePi.apply | (self, n, evaluation) | return from_python(result) | PrimePi[n_?NumericQ] | PrimePi[n_?NumericQ] | [
"PrimePi",
"[",
"n_?NumericQ",
"]"
] | def apply(self, n, evaluation):
"PrimePi[n_?NumericQ]"
result = sympy.ntheory.primepi(n.to_python(n_evaluation=evaluation))
return from_python(result) | [
"def",
"apply",
"(",
"self",
",",
"n",
",",
"evaluation",
")",
":",
"result",
"=",
"sympy",
".",
"ntheory",
".",
"primepi",
"(",
"n",
".",
"to_python",
"(",
"n_evaluation",
"=",
"evaluation",
")",
")",
"return",
"from_python",
"(",
"result",
")"
] | https://github.com/mathics/Mathics/blob/318e06dea8f1c70758a50cb2f95c9900150e3a68/mathics/builtin/numbers/numbertheory.py#L600-L603 | |
ZhaoJ9014/face.evoLVe | 63520924167efb9ef53dcceed0a15cf739cad1c9 | paddle/backbone/model_resnet.py | python | ResNet_101 | (input_size, **kwargs) | return model | Constructs a ResNet-101 model. | Constructs a ResNet-101 model. | [
"Constructs",
"a",
"ResNet",
"-",
"101",
"model",
"."
] | def ResNet_101(input_size, **kwargs):
"""Constructs a ResNet-101 model.
"""
model = ResNet(input_size, Bottleneck, [3, 4, 23, 3], **kwargs)
return model | [
"def",
"ResNet_101",
"(",
"input_size",
",",
"*",
"*",
"kwargs",
")",
":",
"model",
"=",
"ResNet",
"(",
"input_size",
",",
"Bottleneck",
",",
"[",
"3",
",",
"4",
",",
"23",
",",
"3",
"]",
",",
"*",
"*",
"kwargs",
")",
"return",
"model"
] | https://github.com/ZhaoJ9014/face.evoLVe/blob/63520924167efb9ef53dcceed0a15cf739cad1c9/paddle/backbone/model_resnet.py#L176-L181 | |
art-programmer/PlaneNet | ccc4423d278388d01cb3300be992b951b90acc7a | code/polls/models/obj2egg.py | python | floats | (float_list) | return [ float(number) for number in float_list ] | coerce a list of strings that represent floats into a list of floats | coerce a list of strings that represent floats into a list of floats | [
"coerce",
"a",
"list",
"of",
"strings",
"that",
"represent",
"floats",
"into",
"a",
"list",
"of",
"floats"
] | def floats(float_list):
"""coerce a list of strings that represent floats into a list of floats"""
return [ float(number) for number in float_list ] | [
"def",
"floats",
"(",
"float_list",
")",
":",
"return",
"[",
"float",
"(",
"number",
")",
"for",
"number",
"in",
"float_list",
"]"
] | https://github.com/art-programmer/PlaneNet/blob/ccc4423d278388d01cb3300be992b951b90acc7a/code/polls/models/obj2egg.py#L27-L29 | |
microsoft/NimbusML | f6be39ce9359786976429bab0ccd837e849b4ba5 | src/python/nimbusml/ensemble/sub_model_selector/classifierbestdiverseselector.py | python | ClassifierBestDiverseSelector.get_params | (self, deep=False) | return core.get_params(self) | Get the parameters for this operator. | Get the parameters for this operator. | [
"Get",
"the",
"parameters",
"for",
"this",
"operator",
"."
] | def get_params(self, deep=False):
"""
Get the parameters for this operator.
"""
return core.get_params(self) | [
"def",
"get_params",
"(",
"self",
",",
"deep",
"=",
"False",
")",
":",
"return",
"core",
".",
"get_params",
"(",
"self",
")"
] | https://github.com/microsoft/NimbusML/blob/f6be39ce9359786976429bab0ccd837e849b4ba5/src/python/nimbusml/ensemble/sub_model_selector/classifierbestdiverseselector.py#L52-L56 | |
multani/sonata | 48f745662b848308e12a15cbecd2ca44cf618417 | sonata/audioscrobbler.py | python | AudioScrobblerError.__init__ | (self, message) | Create a new AudioScrobblerError.
:Parameters:
- `message`: The message that will be displayed to the user | Create a new AudioScrobblerError. | [
"Create",
"a",
"new",
"AudioScrobblerError",
"."
] | def __init__(self, message):
""" Create a new AudioScrobblerError.
:Parameters:
- `message`: The message that will be displayed to the user
"""
self.message = message | [
"def",
"__init__",
"(",
"self",
",",
"message",
")",
":",
"self",
".",
"message",
"=",
"message"
] | https://github.com/multani/sonata/blob/48f745662b848308e12a15cbecd2ca44cf618417/sonata/audioscrobbler.py#L341-L347 | ||
google/transitfeed | d727e97cb66ac2ca2d699a382ea1d449ee26c2a1 | gtfsscheduleviewer/marey_graph.py | python | MareyGraph.AddStationDecoration | (self, index, color="#f00") | Flushes existing decorations and highlights the given station-line.
Args:
# Integer, index of stop to be highlighted.
index: 4
# An optional string with a html color code
color: "#fff" | Flushes existing decorations and highlights the given station-line. | [
"Flushes",
"existing",
"decorations",
"and",
"highlights",
"the",
"given",
"station",
"-",
"line",
"."
] | def AddStationDecoration(self, index, color="#f00"):
"""Flushes existing decorations and highlights the given station-line.
Args:
# Integer, index of stop to be highlighted.
index: 4
# An optional string with a html color code
color: "#fff"
"""
tmpstr = str()
num_stations = ... | [
"def",
"AddStationDecoration",
"(",
"self",
",",
"index",
",",
"color",
"=",
"\"#f00\"",
")",
":",
"tmpstr",
"=",
"str",
"(",
")",
"num_stations",
"=",
"len",
"(",
"self",
".",
"_stations",
")",
"ind",
"=",
"int",
"(",
"index",
")",
"if",
"self",
"."... | https://github.com/google/transitfeed/blob/d727e97cb66ac2ca2d699a382ea1d449ee26c2a1/gtfsscheduleviewer/marey_graph.py#L400-L417 | ||
trezor/trezor-core | 18c3a6a5bd45923380312b064be96155f5a7377d | src/apps/monero/signing/step_09_sign_input.py | python | sign_input | (
state: State,
src_entr: MoneroTransactionSourceEntry,
vini_bin: bytes,
vini_hmac: bytes,
pseudo_out: bytes,
pseudo_out_hmac: bytes,
pseudo_out_alpha_enc: bytes,
spend_enc: bytes,
) | return MoneroTransactionSignInputAck(
signature=mg_buffer, pseudo_out=crypto.encodepoint(pseudo_out_c)
) | :param state: transaction state
:param src_entr: Source entry
:param vini_bin: tx.vin[i] for the transaction. Contains key image, offsets, amount (usually zero)
:param vini_hmac: HMAC for the tx.vin[i] as returned from Trezor
:param pseudo_out: Pedersen commitment for the current input, uses pseudo_out_... | :param state: transaction state
:param src_entr: Source entry
:param vini_bin: tx.vin[i] for the transaction. Contains key image, offsets, amount (usually zero)
:param vini_hmac: HMAC for the tx.vin[i] as returned from Trezor
:param pseudo_out: Pedersen commitment for the current input, uses pseudo_out_... | [
":",
"param",
"state",
":",
"transaction",
"state",
":",
"param",
"src_entr",
":",
"Source",
"entry",
":",
"param",
"vini_bin",
":",
"tx",
".",
"vin",
"[",
"i",
"]",
"for",
"the",
"transaction",
".",
"Contains",
"key",
"image",
"offsets",
"amount",
"(",
... | async def sign_input(
state: State,
src_entr: MoneroTransactionSourceEntry,
vini_bin: bytes,
vini_hmac: bytes,
pseudo_out: bytes,
pseudo_out_hmac: bytes,
pseudo_out_alpha_enc: bytes,
spend_enc: bytes,
):
"""
:param state: transaction state
:param src_entr: Source entry
:p... | [
"async",
"def",
"sign_input",
"(",
"state",
":",
"State",
",",
"src_entr",
":",
"MoneroTransactionSourceEntry",
",",
"vini_bin",
":",
"bytes",
",",
"vini_hmac",
":",
"bytes",
",",
"pseudo_out",
":",
"bytes",
",",
"pseudo_out_hmac",
":",
"bytes",
",",
"pseudo_o... | https://github.com/trezor/trezor-core/blob/18c3a6a5bd45923380312b064be96155f5a7377d/src/apps/monero/signing/step_09_sign_input.py#L28-L183 | |
RaRe-Technologies/sqlitedict | 7f87568bf0542523fa3c89dd37c9b8f29ffba0be | sqlitedict.py | python | open | (*args, **kwargs) | return SqliteDict(*args, **kwargs) | See documentation of the SqliteDict class. | See documentation of the SqliteDict class. | [
"See",
"documentation",
"of",
"the",
"SqliteDict",
"class",
"."
] | def open(*args, **kwargs):
"""See documentation of the SqliteDict class."""
return SqliteDict(*args, **kwargs) | [
"def",
"open",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"SqliteDict",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | https://github.com/RaRe-Technologies/sqlitedict/blob/7f87568bf0542523fa3c89dd37c9b8f29ffba0be/sqlitedict.py#L93-L95 | |
dcsync/pycobalt | d3a630bfadaeeb6c99aad28f226abe48f6b4acca | pycobalt/console.py | python | black | (text) | return codes['black'] + text + codes['reset'] | Style text black for the Script Console and Beacon Console.
:param text: Text to style
:return: Styled text | Style text black for the Script Console and Beacon Console. | [
"Style",
"text",
"black",
"for",
"the",
"Script",
"Console",
"and",
"Beacon",
"Console",
"."
] | def black(text):
"""
Style text black for the Script Console and Beacon Console.
:param text: Text to style
:return: Styled text
"""
return codes['black'] + text + codes['reset'] | [
"def",
"black",
"(",
"text",
")",
":",
"return",
"codes",
"[",
"'black'",
"]",
"+",
"text",
"+",
"codes",
"[",
"'reset'",
"]"
] | https://github.com/dcsync/pycobalt/blob/d3a630bfadaeeb6c99aad28f226abe48f6b4acca/pycobalt/console.py#L440-L448 | |
mrJean1/PyGeodesy | 7da5ca71aa3edb7bc49e219e0b8190686e1a7965 | pygeodesy/fmath.py | python | Fsum.__iset__ | (self, other) | return self | Override this instance with an other.
@arg other: L{Fsum} instance or C{scalar}.
@return: This instance, overridden (L{Fsum}).
@raise TypeError: Invalid B{C{other}} type. | Override this instance with an other. | [
"Override",
"this",
"instance",
"with",
"an",
"other",
"."
] | def __iset__(self, other): # PYCHOK not special
'''Override this instance with an other.
@arg other: L{Fsum} instance or C{scalar}.
@return: This instance, overridden (L{Fsum}).
@raise TypeError: Invalid B{C{other}} type.
'''
if isscalar(other):
s... | [
"def",
"__iset__",
"(",
"self",
",",
"other",
")",
":",
"# PYCHOK not special",
"if",
"isscalar",
"(",
"other",
")",
":",
"self",
".",
"_n",
"=",
"1",
"self",
".",
"_ps",
"=",
"[",
"float",
"(",
"other",
")",
"]",
"self",
".",
"_fsum2_",
"=",
"floa... | https://github.com/mrJean1/PyGeodesy/blob/7da5ca71aa3edb7bc49e219e0b8190686e1a7965/pygeodesy/fmath.py#L276-L296 | |
zvtvz/zvt | 054bf8a3e7a049df7087c324fa87e8effbaf5bdc | src/zvt/__init__.py | python | init_plugins | () | [] | def init_plugins():
for finder, name, ispkg in pkgutil.iter_modules():
if name.startswith("zvt_"):
try:
_plugins[name] = importlib.import_module(name)
except Exception as e:
logger.warning(f"failed to load plugin {name}", e)
logger.info(f"loaded pl... | [
"def",
"init_plugins",
"(",
")",
":",
"for",
"finder",
",",
"name",
",",
"ispkg",
"in",
"pkgutil",
".",
"iter_modules",
"(",
")",
":",
"if",
"name",
".",
"startswith",
"(",
"\"zvt_\"",
")",
":",
"try",
":",
"_plugins",
"[",
"name",
"]",
"=",
"importl... | https://github.com/zvtvz/zvt/blob/054bf8a3e7a049df7087c324fa87e8effbaf5bdc/src/zvt/__init__.py#L158-L165 | ||||
huggingface/transformers | 623b4f7c63f60cce917677ee704d6c93ee960b4b | src/transformers/models/lxmert/modeling_lxmert.py | python | LxmertOutput.__init__ | (self, config) | [] | def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.intermediate_size, config.hidden_size)
self.LayerNorm = nn.LayerNorm(config.hidden_size, eps=1e-12)
self.dropout = nn.Dropout(config.hidden_dropout_prob) | [
"def",
"__init__",
"(",
"self",
",",
"config",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"dense",
"=",
"nn",
".",
"Linear",
"(",
"config",
".",
"intermediate_size",
",",
"config",
".",
"hidden_size",
")",
"self",
".",
"Laye... | https://github.com/huggingface/transformers/blob/623b4f7c63f60cce917677ee704d6c93ee960b4b/src/transformers/models/lxmert/modeling_lxmert.py#L437-L441 | ||||
goace/personal-file-sharing-center | 4a5b903b003f2db1306e77c5e51b6660fc5dbc6a | web/wsgiserver/__init__.py | python | KnownLengthRFile.readline | (self, size=None) | return data | [] | def readline(self, size=None):
if self.remaining == 0:
return ''
if size is None:
size = self.remaining
else:
size = min(size, self.remaining)
data = self.rfile.readline(size)
self.remaining -= len(data)
return data | [
"def",
"readline",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"if",
"self",
".",
"remaining",
"==",
"0",
":",
"return",
"''",
"if",
"size",
"is",
"None",
":",
"size",
"=",
"self",
".",
"remaining",
"else",
":",
"size",
"=",
"min",
"(",
"siz... | https://github.com/goace/personal-file-sharing-center/blob/4a5b903b003f2db1306e77c5e51b6660fc5dbc6a/web/wsgiserver/__init__.py#L284-L294 | |||
openshift/openshift-tools | 1188778e728a6e4781acf728123e5b356380fe6f | ansible/roles/lib_oa_openshift/library/oc_pvc.py | python | OCPVC.needs_update | (self) | return not Utils.check_def_equal(self.config.data, self.pvc.yaml_dict, skip_keys=skip, debug=True) | verify an update is needed | verify an update is needed | [
"verify",
"an",
"update",
"is",
"needed"
] | def needs_update(self):
''' verify an update is needed '''
if self.pvc.get_volume_name() or self.pvc.is_bound():
return False
skip = []
return not Utils.check_def_equal(self.config.data, self.pvc.yaml_dict, skip_keys=skip, debug=True) | [
"def",
"needs_update",
"(",
"self",
")",
":",
"if",
"self",
".",
"pvc",
".",
"get_volume_name",
"(",
")",
"or",
"self",
".",
"pvc",
".",
"is_bound",
"(",
")",
":",
"return",
"False",
"skip",
"=",
"[",
"]",
"return",
"not",
"Utils",
".",
"check_def_eq... | https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/ansible/roles/lib_oa_openshift/library/oc_pvc.py#L1770-L1776 | |
omz/PythonistaAppTemplate | f560f93f8876d82a21d108977f90583df08d55af | PythonistaAppTemplate/PythonistaKit.framework/pylib_ext/matplotlib/lines.py | python | Line2D.set_marker | (self, marker) | Set the line marker
Parameters
-----------
marker: marker style
See `~matplotlib.markers` for full description of possible
argument | Set the line marker | [
"Set",
"the",
"line",
"marker"
] | def set_marker(self, marker):
"""
Set the line marker
Parameters
-----------
marker: marker style
See `~matplotlib.markers` for full description of possible
argument
"""
self._marker.set_marker(marker) | [
"def",
"set_marker",
"(",
"self",
",",
"marker",
")",
":",
"self",
".",
"_marker",
".",
"set_marker",
"(",
"marker",
")"
] | https://github.com/omz/PythonistaAppTemplate/blob/f560f93f8876d82a21d108977f90583df08d55af/PythonistaAppTemplate/PythonistaKit.framework/pylib_ext/matplotlib/lines.py#L842-L854 | ||
nipy/nipy | d16d268938dcd5c15748ca051532c21f57cf8a22 | nipy/algorithms/clustering/imm.py | python | IMM.reduce | (self, z) | return z | Reduce the assignments by removing empty clusters and update self.k
Parameters
----------
z: array of shape(n),
a vector of membership variables changed in place
Returns
-------
z: the remapped values | Reduce the assignments by removing empty clusters and update self.k | [
"Reduce",
"the",
"assignments",
"by",
"removing",
"empty",
"clusters",
"and",
"update",
"self",
".",
"k"
] | def reduce(self, z):
"""Reduce the assignments by removing empty clusters and update self.k
Parameters
----------
z: array of shape(n),
a vector of membership variables changed in place
Returns
-------
z: the remapped values
"""
uz = n... | [
"def",
"reduce",
"(",
"self",
",",
"z",
")",
":",
"uz",
"=",
"np",
".",
"unique",
"(",
"z",
"[",
"z",
">",
"-",
"1",
"]",
")",
"for",
"i",
",",
"k",
"in",
"enumerate",
"(",
"uz",
")",
":",
"z",
"[",
"z",
"==",
"k",
"]",
"=",
"i",
"self"... | https://github.com/nipy/nipy/blob/d16d268938dcd5c15748ca051532c21f57cf8a22/nipy/algorithms/clustering/imm.py#L275-L291 | |
Map-A-Droid/MAD | 81375b5c9ccc5ca3161eb487aa81469d40ded221 | mapadroid/worker/WorkerBase.py | python | WorkerBase._internal_grab_next_location | (self) | return self._mapping_manager.routemanager_get_settings(self._routemanager_name) | [] | def _internal_grab_next_location(self):
# TODO: consider adding runWarningThreadEvent.set()
self._last_known_state["last_location"] = self.last_location
self.logger.debug("Requesting next location from routemanager")
# requesting a location is blocking (iv_mitm will wait for a prioQ ite... | [
"def",
"_internal_grab_next_location",
"(",
"self",
")",
":",
"# TODO: consider adding runWarningThreadEvent.set()",
"self",
".",
"_last_known_state",
"[",
"\"last_location\"",
"]",
"=",
"self",
".",
"last_location",
"self",
".",
"logger",
".",
"debug",
"(",
"\"Requesti... | https://github.com/Map-A-Droid/MAD/blob/81375b5c9ccc5ca3161eb487aa81469d40ded221/mapadroid/worker/WorkerBase.py#L578-L595 | |||
tendenci/tendenci | 0f2c348cc0e7d41bc56f50b00ce05544b083bf1d | tendenci/apps/help_files/templatetags/help_file_tags.py | python | help_file_current_app | (context, user, help_file=None) | return context | [] | def help_file_current_app(context, user, help_file=None):
context.update({
"app_object": help_file,
"user": user
})
return context | [
"def",
"help_file_current_app",
"(",
"context",
",",
"user",
",",
"help_file",
"=",
"None",
")",
":",
"context",
".",
"update",
"(",
"{",
"\"app_object\"",
":",
"help_file",
",",
"\"user\"",
":",
"user",
"}",
")",
"return",
"context"
] | https://github.com/tendenci/tendenci/blob/0f2c348cc0e7d41bc56f50b00ce05544b083bf1d/tendenci/apps/help_files/templatetags/help_file_tags.py#L30-L35 | |||
PaddlePaddle/PaddleX | 2bab73f81ab54e328204e7871e6ae4a82e719f5d | static/paddlex/cv/nets/detection/loss/iou_loss.py | python | IouLoss._create_tensor_from_numpy | (self, numpy_array) | return paddle_array | [] | def _create_tensor_from_numpy(self, numpy_array):
paddle_array = fluid.layers.create_parameter(
attr=ParamAttr(),
shape=numpy_array.shape,
dtype=numpy_array.dtype,
default_initializer=NumpyArrayInitializer(numpy_array))
paddle_array.stop_gradient = True
... | [
"def",
"_create_tensor_from_numpy",
"(",
"self",
",",
"numpy_array",
")",
":",
"paddle_array",
"=",
"fluid",
".",
"layers",
".",
"create_parameter",
"(",
"attr",
"=",
"ParamAttr",
"(",
")",
",",
"shape",
"=",
"numpy_array",
".",
"shape",
",",
"dtype",
"=",
... | https://github.com/PaddlePaddle/PaddleX/blob/2bab73f81ab54e328204e7871e6ae4a82e719f5d/static/paddlex/cv/nets/detection/loss/iou_loss.py#L228-L235 | |||
atbaker/spin-docker | 33b985fffb82effe18b65587821fd9d7eecc2b61 | spindocker/tasks.py | python | remove_container | (self, container_id) | Deletes a container asynchronously. | Deletes a container asynchronously. | [
"Deletes",
"a",
"container",
"asynchronously",
"."
] | def remove_container(self, container_id):
"""Deletes a container asynchronously."""
delete_container_ip(container_id)
try:
client.stop(container_id)
client.remove_container(container_id)
except APIError as exception:
raise self.retry(exc=exception)
r.delete('containers:%s' ... | [
"def",
"remove_container",
"(",
"self",
",",
"container_id",
")",
":",
"delete_container_ip",
"(",
"container_id",
")",
"try",
":",
"client",
".",
"stop",
"(",
"container_id",
")",
"client",
".",
"remove_container",
"(",
"container_id",
")",
"except",
"APIError"... | https://github.com/atbaker/spin-docker/blob/33b985fffb82effe18b65587821fd9d7eecc2b61/spindocker/tasks.py#L103-L113 | ||
orakaro/rainbowstream | 96141fac10675e0775d703f65a59c4477a48c57e | rainbowstream/util.py | python | format_prefix | (listname='', keyword='') | return formattedPrefix | Format the custom prefix | Format the custom prefix | [
"Format",
"the",
"custom",
"prefix"
] | def format_prefix(listname='', keyword=''):
"""
Format the custom prefix
"""
formattedPrefix = c['PREFIX']
owner = '@' + c['original_name']
place = ''
# Public stream
if keyword:
formattedPrefix = ''.join(formattedPrefix.split('#owner'))
formattedPrefix = ''.join(formatte... | [
"def",
"format_prefix",
"(",
"listname",
"=",
"''",
",",
"keyword",
"=",
"''",
")",
":",
"formattedPrefix",
"=",
"c",
"[",
"'PREFIX'",
"]",
"owner",
"=",
"'@'",
"+",
"c",
"[",
"'original_name'",
"]",
"place",
"=",
"''",
"# Public stream",
"if",
"keyword"... | https://github.com/orakaro/rainbowstream/blob/96141fac10675e0775d703f65a59c4477a48c57e/rainbowstream/util.py#L20-L49 | |
BigBrotherBot/big-brother-bot | 848823c71413c86e7f1ff9584f43e08d40a7f2c0 | b3/plugins/poweradminhf/__init__.py | python | PoweradminhfPlugin.cmd_panextmap | (self, data, client=None, cmd=None) | - force server to the Next Map in rotation | - force server to the Next Map in rotation | [
"-",
"force",
"server",
"to",
"the",
"Next",
"Map",
"in",
"rotation"
] | def cmd_panextmap(self, data, client=None, cmd=None):
"""
- force server to the Next Map in rotation
"""
self.console.write('admin NextMap') | [
"def",
"cmd_panextmap",
"(",
"self",
",",
"data",
",",
"client",
"=",
"None",
",",
"cmd",
"=",
"None",
")",
":",
"self",
".",
"console",
".",
"write",
"(",
"'admin NextMap'",
")"
] | https://github.com/BigBrotherBot/big-brother-bot/blob/848823c71413c86e7f1ff9584f43e08d40a7f2c0/b3/plugins/poweradminhf/__init__.py#L319-L323 | ||
noyoshi/smart-sketch | 8a3c0c3af4df75bc198168829d59ef367b21ebfb | backend/models/pix2pix_model.py | python | Pix2PixModel.forward | (self, data, mode, verbose=True) | Foward pass, overrides something | Foward pass, overrides something | [
"Foward",
"pass",
"overrides",
"something"
] | def forward(self, data, mode, verbose=True):
"""Foward pass, overrides something"""
input_semantics = self.preprocess_input(data, verbose)
with torch.no_grad():
return self.generate_fake(input_semantics) | [
"def",
"forward",
"(",
"self",
",",
"data",
",",
"mode",
",",
"verbose",
"=",
"True",
")",
":",
"input_semantics",
"=",
"self",
".",
"preprocess_input",
"(",
"data",
",",
"verbose",
")",
"with",
"torch",
".",
"no_grad",
"(",
")",
":",
"return",
"self",... | https://github.com/noyoshi/smart-sketch/blob/8a3c0c3af4df75bc198168829d59ef367b21ebfb/backend/models/pix2pix_model.py#L35-L39 | ||
ajinabraham/OWASP-Xenotix-XSS-Exploit-Framework | cb692f527e4e819b6c228187c5702d990a180043 | bin/x86/Debug/scripting_engine/Lib/lib2to3/pytree.py | python | generate_matches | (patterns, nodes) | Generator yielding matches for a sequence of patterns and nodes.
Args:
patterns: a sequence of patterns
nodes: a sequence of nodes
Yields:
(count, results) tuples where:
count: the entire sequence of patterns matches nodes[:count];
results: dict containing named submatc... | Generator yielding matches for a sequence of patterns and nodes. | [
"Generator",
"yielding",
"matches",
"for",
"a",
"sequence",
"of",
"patterns",
"and",
"nodes",
"."
] | def generate_matches(patterns, nodes):
"""
Generator yielding matches for a sequence of patterns and nodes.
Args:
patterns: a sequence of patterns
nodes: a sequence of nodes
Yields:
(count, results) tuples where:
count: the entire sequence of patterns matches nodes[:cou... | [
"def",
"generate_matches",
"(",
"patterns",
",",
"nodes",
")",
":",
"if",
"not",
"patterns",
":",
"yield",
"0",
",",
"{",
"}",
"else",
":",
"p",
",",
"rest",
"=",
"patterns",
"[",
"0",
"]",
",",
"patterns",
"[",
"1",
":",
"]",
"for",
"c0",
",",
... | https://github.com/ajinabraham/OWASP-Xenotix-XSS-Exploit-Framework/blob/cb692f527e4e819b6c228187c5702d990a180043/bin/x86/Debug/scripting_engine/Lib/lib2to3/pytree.py#L862-L887 | ||
bugy/script-server | 9a57ce15903c81bcb537b872f1330ee55ba31563 | src/config/script/list_values.py | python | FilesProvider.__init__ | (self,
file_dir,
file_type=None,
file_extensions=None,
excluded_files_matcher: FileMatcher = None) | [] | def __init__(self,
file_dir,
file_type=None,
file_extensions=None,
excluded_files_matcher: FileMatcher = None) -> None:
self._file_dir = file_dir
try:
self._values = list_files(file_dir,
... | [
"def",
"__init__",
"(",
"self",
",",
"file_dir",
",",
"file_type",
"=",
"None",
",",
"file_extensions",
"=",
"None",
",",
"excluded_files_matcher",
":",
"FileMatcher",
"=",
"None",
")",
"->",
"None",
":",
"self",
".",
"_file_dir",
"=",
"file_dir",
"try",
"... | https://github.com/bugy/script-server/blob/9a57ce15903c81bcb537b872f1330ee55ba31563/src/config/script/list_values.py#L109-L123 | ||||
IronLanguages/ironpython3 | 7a7bb2a872eeab0d1009fc8a6e24dca43f65b693 | Src/StdLib/Lib/multiprocessing/heap.py | python | Heap.__init__ | (self, size=mmap.PAGESIZE) | [] | def __init__(self, size=mmap.PAGESIZE):
self._lastpid = os.getpid()
self._lock = threading.Lock()
self._size = size
self._lengths = []
self._len_to_seq = {}
self._start_to_block = {}
self._stop_to_block = {}
self._allocated_blocks = set()
self._are... | [
"def",
"__init__",
"(",
"self",
",",
"size",
"=",
"mmap",
".",
"PAGESIZE",
")",
":",
"self",
".",
"_lastpid",
"=",
"os",
".",
"getpid",
"(",
")",
"self",
".",
"_lock",
"=",
"threading",
".",
"Lock",
"(",
")",
"self",
".",
"_size",
"=",
"size",
"s... | https://github.com/IronLanguages/ironpython3/blob/7a7bb2a872eeab0d1009fc8a6e24dca43f65b693/Src/StdLib/Lib/multiprocessing/heap.py#L94-L105 | ||||
great-expectations/great_expectations | 45224cb890aeae725af25905923d0dbbab2d969d | great_expectations/dataset/sparkdf_dataset.py | python | MetaSparkDFDataset.column_map_expectation | (cls, func) | return inner_wrapper | Constructs an expectation using column-map semantics.
The MetaSparkDFDataset implementation replaces the "column" parameter supplied by the user with a Spark Dataframe
with the actual column data. The current approach for functions implementing expectation logic is to append
a column named "__... | Constructs an expectation using column-map semantics. | [
"Constructs",
"an",
"expectation",
"using",
"column",
"-",
"map",
"semantics",
"."
] | def column_map_expectation(cls, func):
"""Constructs an expectation using column-map semantics.
The MetaSparkDFDataset implementation replaces the "column" parameter supplied by the user with a Spark Dataframe
with the actual column data. The current approach for functions implementing expecta... | [
"def",
"column_map_expectation",
"(",
"cls",
",",
"func",
")",
":",
"argspec",
"=",
"inspect",
".",
"getfullargspec",
"(",
"func",
")",
"[",
"0",
"]",
"[",
"1",
":",
"]",
"@",
"cls",
".",
"expectation",
"(",
"argspec",
")",
"@",
"wraps",
"(",
"func",... | https://github.com/great-expectations/great_expectations/blob/45224cb890aeae725af25905923d0dbbab2d969d/great_expectations/dataset/sparkdf_dataset.py#L68-L211 | |
Komodo/KomodoEdit | 61edab75dce2bdb03943b387b0608ea36f548e8e | contrib/mk/mklib/path.py | python | path.listdir | (self, pattern=None) | return [self / child for child in names] | D.listdir() -> List of items in this directory.
Use D.files() or D.dirs() instead if you want a listing
of just files or just subdirectories.
The elements of the list are path objects.
With the optional 'pattern' argument, this only lists
items whose names match the given patt... | D.listdir() -> List of items in this directory. | [
"D",
".",
"listdir",
"()",
"-",
">",
"List",
"of",
"items",
"in",
"this",
"directory",
"."
] | def listdir(self, pattern=None):
""" D.listdir() -> List of items in this directory.
Use D.files() or D.dirs() instead if you want a listing
of just files or just subdirectories.
The elements of the list are path objects.
With the optional 'pattern' argument, this only lists
... | [
"def",
"listdir",
"(",
"self",
",",
"pattern",
"=",
"None",
")",
":",
"names",
"=",
"os",
".",
"listdir",
"(",
"self",
")",
"if",
"pattern",
"is",
"not",
"None",
":",
"names",
"=",
"fnmatch",
".",
"filter",
"(",
"names",
",",
"pattern",
")",
"retur... | https://github.com/Komodo/KomodoEdit/blob/61edab75dce2bdb03943b387b0608ea36f548e8e/contrib/mk/mklib/path.py#L286-L300 | |
chribsen/simple-machine-learning-examples | dc94e52a4cebdc8bb959ff88b81ff8cfeca25022 | venv/lib/python2.7/site-packages/scipy/io/arff/arffread.py | python | maxnomlen | (atrv) | return max(len(i) for i in nomtp) | Given a string containing a nominal type definition, returns the
string len of the biggest component.
A nominal type is defined as seomthing framed between brace ({}).
Parameters
----------
atrv : str
Nominal type definition
Returns
-------
slen : int
length of longest c... | Given a string containing a nominal type definition, returns the
string len of the biggest component. | [
"Given",
"a",
"string",
"containing",
"a",
"nominal",
"type",
"definition",
"returns",
"the",
"string",
"len",
"of",
"the",
"biggest",
"component",
"."
] | def maxnomlen(atrv):
"""Given a string containing a nominal type definition, returns the
string len of the biggest component.
A nominal type is defined as seomthing framed between brace ({}).
Parameters
----------
atrv : str
Nominal type definition
Returns
-------
slen : in... | [
"def",
"maxnomlen",
"(",
"atrv",
")",
":",
"nomtp",
"=",
"get_nom_val",
"(",
"atrv",
")",
"return",
"max",
"(",
"len",
"(",
"i",
")",
"for",
"i",
"in",
"nomtp",
")"
] | https://github.com/chribsen/simple-machine-learning-examples/blob/dc94e52a4cebdc8bb959ff88b81ff8cfeca25022/venv/lib/python2.7/site-packages/scipy/io/arff/arffread.py#L117-L142 | |
python-rope/rope | bcdfe6b70b1437d976e21c56b6ec1281b22823aa | rope/base/oi/type_hinting/providers/numpydocstrings.py | python | NumPyDocstringParamParser.__call__ | (self, docstring, param_name) | return [] | Search `docstring` (in numpydoc format) for type(-s) of `param_name`. | Search `docstring` (in numpydoc format) for type(-s) of `param_name`. | [
"Search",
"docstring",
"(",
"in",
"numpydoc",
"format",
")",
"for",
"type",
"(",
"-",
"s",
")",
"of",
"param_name",
"."
] | def __call__(self, docstring, param_name):
"""Search `docstring` (in numpydoc format) for type(-s) of `param_name`."""
if not docstring:
return []
params = NumpyDocString(docstring)._parsed_data["Parameters"]
for p_name, p_type, p_descr in params:
if p_name == par... | [
"def",
"__call__",
"(",
"self",
",",
"docstring",
",",
"param_name",
")",
":",
"if",
"not",
"docstring",
":",
"return",
"[",
"]",
"params",
"=",
"NumpyDocString",
"(",
"docstring",
")",
".",
"_parsed_data",
"[",
"\"Parameters\"",
"]",
"for",
"p_name",
",",... | https://github.com/python-rope/rope/blob/bcdfe6b70b1437d976e21c56b6ec1281b22823aa/rope/base/oi/type_hinting/providers/numpydocstrings.py#L17-L33 | |
Dash-Industry-Forum/dash-live-source-simulator | 23cb15c35656a731d9f6d78a30f2713eff2ec20d | dashlivesim/dashlib/mp4.py | python | stts_box.sample_time_and_duration | (self, sample_number) | return time, duration | [] | def sample_time_and_duration(self, sample_number):
# lookup entry, essentially the same as
# entry_index = bisect.bisect_right(self.lookup, sample_number) - 1
entry_index = 0
upper_bound = self.entry_count
while entry_index < upper_bound:
index = (entry_index + upper_... | [
"def",
"sample_time_and_duration",
"(",
"self",
",",
"sample_number",
")",
":",
"# lookup entry, essentially the same as",
"# entry_index = bisect.bisect_right(self.lookup, sample_number) - 1",
"entry_index",
"=",
"0",
"upper_bound",
"=",
"self",
".",
"entry_count",
"while",
"e... | https://github.com/Dash-Industry-Forum/dash-live-source-simulator/blob/23cb15c35656a731d9f6d78a30f2713eff2ec20d/dashlivesim/dashlib/mp4.py#L1575-L1597 | |||
mehulj94/BrainDamage | 49a29c2606d5f7c0d9705ae5f4201a6bb25cfe73 | eclipse.py | python | pollDevice | () | [] | def pollDevice():
while True:
if check_external_drive.FLAG == True:
print "[*] Drive Found: ", check_external_drive.DRIVE+":\\"
copyFiles(check_external_drive.DRIVE+":\\",os.path.realpath(sys.argv[0]))
check_external_drive.FLAG = False | [
"def",
"pollDevice",
"(",
")",
":",
"while",
"True",
":",
"if",
"check_external_drive",
".",
"FLAG",
"==",
"True",
":",
"print",
"\"[*] Drive Found: \"",
",",
"check_external_drive",
".",
"DRIVE",
"+",
"\":\\\\\"",
"copyFiles",
"(",
"check_external_drive",
".",
... | https://github.com/mehulj94/BrainDamage/blob/49a29c2606d5f7c0d9705ae5f4201a6bb25cfe73/eclipse.py#L361-L366 | ||||
Chaffelson/nipyapi | d3b186fd701ce308c2812746d98af9120955e810 | nipyapi/registry/models/restriction.py | python | Restriction.__init__ | (self, required_permission=None, explanation=None) | Restriction - a model defined in Swagger | Restriction - a model defined in Swagger | [
"Restriction",
"-",
"a",
"model",
"defined",
"in",
"Swagger"
] | def __init__(self, required_permission=None, explanation=None):
"""
Restriction - a model defined in Swagger
"""
self._required_permission = None
self._explanation = None
if required_permission is not None:
self.required_permission = required_permission
... | [
"def",
"__init__",
"(",
"self",
",",
"required_permission",
"=",
"None",
",",
"explanation",
"=",
"None",
")",
":",
"self",
".",
"_required_permission",
"=",
"None",
"self",
".",
"_explanation",
"=",
"None",
"if",
"required_permission",
"is",
"not",
"None",
... | https://github.com/Chaffelson/nipyapi/blob/d3b186fd701ce308c2812746d98af9120955e810/nipyapi/registry/models/restriction.py#L43-L54 | ||
nose-devs/nose | 7c26ad1e6b7d308cafa328ad34736d34028c122a | nose/tools/trivial.py | python | ok_ | (expr, msg=None) | Shorthand for assert. Saves 3 whole characters! | Shorthand for assert. Saves 3 whole characters! | [
"Shorthand",
"for",
"assert",
".",
"Saves",
"3",
"whole",
"characters!"
] | def ok_(expr, msg=None):
"""Shorthand for assert. Saves 3 whole characters!
"""
if not expr:
raise AssertionError(msg) | [
"def",
"ok_",
"(",
"expr",
",",
"msg",
"=",
"None",
")",
":",
"if",
"not",
"expr",
":",
"raise",
"AssertionError",
"(",
"msg",
")"
] | https://github.com/nose-devs/nose/blob/7c26ad1e6b7d308cafa328ad34736d34028c122a/nose/tools/trivial.py#L18-L22 | ||
parallax/svg-animation-tools | 3cbad1696760c049ed66b7e0c8631357000dbdb6 | example/parallax_svg_tools/bs4/element.py | python | NavigableString.__getattr__ | (self, attr) | text.string gives you text. This is for backwards
compatibility for Navigable*String, but for CData* it lets you
get the string without the CData wrapper. | text.string gives you text. This is for backwards
compatibility for Navigable*String, but for CData* it lets you
get the string without the CData wrapper. | [
"text",
".",
"string",
"gives",
"you",
"text",
".",
"This",
"is",
"for",
"backwards",
"compatibility",
"for",
"Navigable",
"*",
"String",
"but",
"for",
"CData",
"*",
"it",
"lets",
"you",
"get",
"the",
"string",
"without",
"the",
"CData",
"wrapper",
"."
] | def __getattr__(self, attr):
"""text.string gives you text. This is for backwards
compatibility for Navigable*String, but for CData* it lets you
get the string without the CData wrapper."""
if attr == 'string':
return self
else:
raise AttributeError(
... | [
"def",
"__getattr__",
"(",
"self",
",",
"attr",
")",
":",
"if",
"attr",
"==",
"'string'",
":",
"return",
"self",
"else",
":",
"raise",
"AttributeError",
"(",
"\"'%s' object has no attribute '%s'\"",
"%",
"(",
"self",
".",
"__class__",
".",
"__name__",
",",
"... | https://github.com/parallax/svg-animation-tools/blob/3cbad1696760c049ed66b7e0c8631357000dbdb6/example/parallax_svg_tools/bs4/element.py#L721-L730 | ||
CoinAlpha/hummingbot | 36f6149c1644c07cd36795b915f38b8f49b798e7 | hummingbot/strategy/spot_perpetual_arbitrage/arb_proposal.py | python | ArbProposal.__init__ | (self,
spot_side: ArbProposalSide,
perp_side: ArbProposalSide,
order_amount: Decimal) | Creates ArbProposal
:param spot_side: An ArbProposalSide on spot market
:param perp_side: An ArbProposalSide on perpetual market
:param order_amount: An order amount for both spot and perpetual market | Creates ArbProposal
:param spot_side: An ArbProposalSide on spot market
:param perp_side: An ArbProposalSide on perpetual market
:param order_amount: An order amount for both spot and perpetual market | [
"Creates",
"ArbProposal",
":",
"param",
"spot_side",
":",
"An",
"ArbProposalSide",
"on",
"spot",
"market",
":",
"param",
"perp_side",
":",
"An",
"ArbProposalSide",
"on",
"perpetual",
"market",
":",
"param",
"order_amount",
":",
"An",
"order",
"amount",
"for",
... | def __init__(self,
spot_side: ArbProposalSide,
perp_side: ArbProposalSide,
order_amount: Decimal):
"""
Creates ArbProposal
:param spot_side: An ArbProposalSide on spot market
:param perp_side: An ArbProposalSide on perpetual market
... | [
"def",
"__init__",
"(",
"self",
",",
"spot_side",
":",
"ArbProposalSide",
",",
"perp_side",
":",
"ArbProposalSide",
",",
"order_amount",
":",
"Decimal",
")",
":",
"if",
"spot_side",
".",
"is_buy",
"==",
"perp_side",
".",
"is_buy",
":",
"raise",
"Exception",
... | https://github.com/CoinAlpha/hummingbot/blob/36f6149c1644c07cd36795b915f38b8f49b798e7/hummingbot/strategy/spot_perpetual_arbitrage/arb_proposal.py#L37-L51 | ||
linkchecker/linkchecker | d1078ed8480e5cfc4264d0dbf026b45b45aede4d | linkcheck/checker/mailtourl.py | python | is_quoted | (addr) | return addr.startswith('"') and addr.endswith('"') | Return True iff mail address string is quoted. | Return True iff mail address string is quoted. | [
"Return",
"True",
"iff",
"mail",
"address",
"string",
"is",
"quoted",
"."
] | def is_quoted(addr):
"""Return True iff mail address string is quoted."""
return addr.startswith('"') and addr.endswith('"') | [
"def",
"is_quoted",
"(",
"addr",
")",
":",
"return",
"addr",
".",
"startswith",
"(",
"'\"'",
")",
"and",
"addr",
".",
"endswith",
"(",
"'\"'",
")"
] | https://github.com/linkchecker/linkchecker/blob/d1078ed8480e5cfc4264d0dbf026b45b45aede4d/linkcheck/checker/mailtourl.py#L44-L46 | |
scrapy/scrapy | b04cfa48328d5d5749dca6f50fa34e0cfc664c89 | scrapy/core/downloader/handlers/__init__.py | python | DownloadHandlers._load_handler | (self, scheme, skip_lazy=False) | [] | def _load_handler(self, scheme, skip_lazy=False):
path = self._schemes[scheme]
try:
dhcls = load_object(path)
if skip_lazy and getattr(dhcls, 'lazy', True):
return None
dh = create_instance(
objcls=dhcls,
settings=self._... | [
"def",
"_load_handler",
"(",
"self",
",",
"scheme",
",",
"skip_lazy",
"=",
"False",
")",
":",
"path",
"=",
"self",
".",
"_schemes",
"[",
"scheme",
"]",
"try",
":",
"dhcls",
"=",
"load_object",
"(",
"path",
")",
"if",
"skip_lazy",
"and",
"getattr",
"(",... | https://github.com/scrapy/scrapy/blob/b04cfa48328d5d5749dca6f50fa34e0cfc664c89/scrapy/core/downloader/handlers/__init__.py#L46-L68 | ||||
wmayner/pyphi | 299fccd4a8152dcfa4bb989d7d739e245343b0a5 | pyphi/models/fmt.py | python | make_repr | (self, attrs) | Construct a repr string.
If `config.REPR_VERBOSITY` is ``1`` or ``2``, this function calls the
object's __str__ method. Although this breaks the convention that __repr__
should return a string which can reconstruct the object, readable reprs are
invaluable since the Python interpreter calls `repr` to r... | Construct a repr string. | [
"Construct",
"a",
"repr",
"string",
"."
] | def make_repr(self, attrs):
"""Construct a repr string.
If `config.REPR_VERBOSITY` is ``1`` or ``2``, this function calls the
object's __str__ method. Although this breaks the convention that __repr__
should return a string which can reconstruct the object, readable reprs are
invaluable since the P... | [
"def",
"make_repr",
"(",
"self",
",",
"attrs",
")",
":",
"# TODO: change this to a closure so we can do",
"# __repr__ = make_repr(attrs) ???",
"if",
"config",
".",
"REPR_VERBOSITY",
"in",
"[",
"MEDIUM",
",",
"HIGH",
"]",
":",
"return",
"self",
".",
"__str__",
"(",
... | https://github.com/wmayner/pyphi/blob/299fccd4a8152dcfa4bb989d7d739e245343b0a5/pyphi/models/fmt.py#L47-L76 | ||
CedricGuillemet/Imogen | ee417b42747ed5b46cb11b02ef0c3630000085b3 | bin/Lib/multiprocessing/context.py | python | BaseContext.Queue | (self, maxsize=0) | return Queue(maxsize, ctx=self.get_context()) | Returns a queue object | Returns a queue object | [
"Returns",
"a",
"queue",
"object"
] | def Queue(self, maxsize=0):
'''Returns a queue object'''
from .queues import Queue
return Queue(maxsize, ctx=self.get_context()) | [
"def",
"Queue",
"(",
"self",
",",
"maxsize",
"=",
"0",
")",
":",
"from",
".",
"queues",
"import",
"Queue",
"return",
"Queue",
"(",
"maxsize",
",",
"ctx",
"=",
"self",
".",
"get_context",
"(",
")",
")"
] | https://github.com/CedricGuillemet/Imogen/blob/ee417b42747ed5b46cb11b02ef0c3630000085b3/bin/Lib/multiprocessing/context.py#L99-L102 | |
snipsco/snips-nlu | 74b2893c91fc0bafc919a7e088ecb0b2bd611acf | snips_nlu/intent_classifier/intent_classifier.py | python | IntentClassifier.get_intent | (self, text, intents_filter) | Performs intent classification on the provided *text*
Args:
text (str): Input
intents_filter (str or list of str): When defined, it will find
the most likely intent among the list, otherwise it will use
the whole list of intents defined in the dataset
... | Performs intent classification on the provided *text* | [
"Performs",
"intent",
"classification",
"on",
"the",
"provided",
"*",
"text",
"*"
] | def get_intent(self, text, intents_filter):
"""Performs intent classification on the provided *text*
Args:
text (str): Input
intents_filter (str or list of str): When defined, it will find
the most likely intent among the list, otherwise it will use
... | [
"def",
"get_intent",
"(",
"self",
",",
"text",
",",
"intents_filter",
")",
":",
"pass"
] | https://github.com/snipsco/snips-nlu/blob/74b2893c91fc0bafc919a7e088ecb0b2bd611acf/snips_nlu/intent_classifier/intent_classifier.py#L26-L40 | ||
cupy/cupy | a47ad3105f0fe817a4957de87d98ddccb8c7491f | cupy/cusparse.py | python | dense2csr | (x) | return csr | Converts a dense matrix in CSR format.
Args:
x (cupy.ndarray): A matrix to be converted.
Returns:
cupyx.scipy.sparse.csr_matrix: A converted matrix. | Converts a dense matrix in CSR format. | [
"Converts",
"a",
"dense",
"matrix",
"in",
"CSR",
"format",
"."
] | def dense2csr(x):
"""Converts a dense matrix in CSR format.
Args:
x (cupy.ndarray): A matrix to be converted.
Returns:
cupyx.scipy.sparse.csr_matrix: A converted matrix.
"""
if not check_availability('dense2csr'):
raise RuntimeError('dense2csr is not available.')
asse... | [
"def",
"dense2csr",
"(",
"x",
")",
":",
"if",
"not",
"check_availability",
"(",
"'dense2csr'",
")",
":",
"raise",
"RuntimeError",
"(",
"'dense2csr is not available.'",
")",
"assert",
"x",
".",
"ndim",
"==",
"2",
"x",
"=",
"_cupy",
".",
"asfortranarray",
"(",... | https://github.com/cupy/cupy/blob/a47ad3105f0fe817a4957de87d98ddccb8c7491f/cupy/cusparse.py#L1155-L1198 | |
omz/PythonistaAppTemplate | f560f93f8876d82a21d108977f90583df08d55af | PythonistaAppTemplate/PythonistaKit.framework/pylib_ext/numpy/lib/financial.py | python | npv | (rate, values) | return (values / (1+rate)**np.arange(0, len(values))).sum(axis=0) | Returns the NPV (Net Present Value) of a cash flow series.
Parameters
----------
rate : scalar
The discount rate.
values : array_like, shape(M, )
The values of the time series of cash flows. The (fixed) time
interval between cash flow "events" must be the same as that
f... | Returns the NPV (Net Present Value) of a cash flow series. | [
"Returns",
"the",
"NPV",
"(",
"Net",
"Present",
"Value",
")",
"of",
"a",
"cash",
"flow",
"series",
"."
] | def npv(rate, values):
"""
Returns the NPV (Net Present Value) of a cash flow series.
Parameters
----------
rate : scalar
The discount rate.
values : array_like, shape(M, )
The values of the time series of cash flows. The (fixed) time
interval between cash flow "events"... | [
"def",
"npv",
"(",
"rate",
",",
"values",
")",
":",
"values",
"=",
"np",
".",
"asarray",
"(",
"values",
")",
"return",
"(",
"values",
"/",
"(",
"1",
"+",
"rate",
")",
"**",
"np",
".",
"arange",
"(",
"0",
",",
"len",
"(",
"values",
")",
")",
"... | https://github.com/omz/PythonistaAppTemplate/blob/f560f93f8876d82a21d108977f90583df08d55af/PythonistaAppTemplate/PythonistaKit.framework/pylib_ext/numpy/lib/financial.py#L649-L692 | |
Cog-Creators/Red-DiscordBot | b05933274a11fb097873ab0d1b246d37b06aa306 | redbot/core/commands/help.py | python | RedHelpFormatter.send_help | (
self, ctx: Context, help_for: HelpTarget = None, *, from_help_command: bool = False
) | This delegates to other functions.
For most cases, you should use this and only this directly. | This delegates to other functions. | [
"This",
"delegates",
"to",
"other",
"functions",
"."
] | async def send_help(
self, ctx: Context, help_for: HelpTarget = None, *, from_help_command: bool = False
):
"""
This delegates to other functions.
For most cases, you should use this and only this directly.
"""
help_settings = await HelpSettings.from_context(ctx)
... | [
"async",
"def",
"send_help",
"(",
"self",
",",
"ctx",
":",
"Context",
",",
"help_for",
":",
"HelpTarget",
"=",
"None",
",",
"*",
",",
"from_help_command",
":",
"bool",
"=",
"False",
")",
":",
"help_settings",
"=",
"await",
"HelpSettings",
".",
"from_contex... | https://github.com/Cog-Creators/Red-DiscordBot/blob/b05933274a11fb097873ab0d1b246d37b06aa306/redbot/core/commands/help.py#L213-L245 | ||
GiulioRossetti/cdlib | b2c6311b99725bb2b029556f531d244a2af14a2a | cdlib/algorithms/internal/CONGA.py | python | CrispOverlap.__str__ | (self) | return "{0} vertices in {1} possible covers.".format(
len(self._graph.vs), len(self._covers)
) | Returns a string representation of the list of covers. | Returns a string representation of the list of covers. | [
"Returns",
"a",
"string",
"representation",
"of",
"the",
"list",
"of",
"covers",
"."
] | def __str__(self):
"""
Returns a string representation of the list of covers.
"""
return "{0} vertices in {1} possible covers.".format(
len(self._graph.vs), len(self._covers)
) | [
"def",
"__str__",
"(",
"self",
")",
":",
"return",
"\"{0} vertices in {1} possible covers.\"",
".",
"format",
"(",
"len",
"(",
"self",
".",
"_graph",
".",
"vs",
")",
",",
"len",
"(",
"self",
".",
"_covers",
")",
")"
] | https://github.com/GiulioRossetti/cdlib/blob/b2c6311b99725bb2b029556f531d244a2af14a2a/cdlib/algorithms/internal/CONGA.py#L185-L191 | |
jgagneastro/coffeegrindsize | 22661ebd21831dba4cf32bfc6ba59fe3d49f879c | App/dist/coffeegrindsize.app/Contents/Resources/lib/python3.7/scipy/ndimage/interpolation.py | python | shift | (input, shift, output=None, order=3, mode='constant', cval=0.0,
prefilter=True) | return output | Shift an array.
The array is shifted using spline interpolation of the requested order.
Points outside the boundaries of the input are filled according to the
given mode.
Parameters
----------
%(input)s
shift : float or sequence
The shift along the axes. If a float, `shift` is the ... | Shift an array. | [
"Shift",
"an",
"array",
"."
] | def shift(input, shift, output=None, order=3, mode='constant', cval=0.0,
prefilter=True):
"""
Shift an array.
The array is shifted using spline interpolation of the requested order.
Points outside the boundaries of the input are filled according to the
given mode.
Parameters
----... | [
"def",
"shift",
"(",
"input",
",",
"shift",
",",
"output",
"=",
"None",
",",
"order",
"=",
"3",
",",
"mode",
"=",
"'constant'",
",",
"cval",
"=",
"0.0",
",",
"prefilter",
"=",
"True",
")",
":",
"if",
"order",
"<",
"0",
"or",
"order",
">",
"5",
... | https://github.com/jgagneastro/coffeegrindsize/blob/22661ebd21831dba4cf32bfc6ba59fe3d49f879c/App/dist/coffeegrindsize.app/Contents/Resources/lib/python3.7/scipy/ndimage/interpolation.py#L491-L539 | |
globaleaks/GlobaLeaks | 4624ca937728adb8e21c4733a8aecec6a41cb3db | backend/globaleaks/utils/crypto.py | python | _convert_to_bytes | (arg: Union[bytes, str]) | return arg | Convert the argument to bytes if of string type
:param arg: a string or a byte object
:return: the converted byte object | Convert the argument to bytes if of string type
:param arg: a string or a byte object
:return: the converted byte object | [
"Convert",
"the",
"argument",
"to",
"bytes",
"if",
"of",
"string",
"type",
":",
"param",
"arg",
":",
"a",
"string",
"or",
"a",
"byte",
"object",
":",
"return",
":",
"the",
"converted",
"byte",
"object"
] | def _convert_to_bytes(arg: Union[bytes, str]) -> bytes:
"""
Convert the argument to bytes if of string type
:param arg: a string or a byte object
:return: the converted byte object
"""
if isinstance(arg, str):
arg = arg.encode()
return arg | [
"def",
"_convert_to_bytes",
"(",
"arg",
":",
"Union",
"[",
"bytes",
",",
"str",
"]",
")",
"->",
"bytes",
":",
"if",
"isinstance",
"(",
"arg",
",",
"str",
")",
":",
"arg",
"=",
"arg",
".",
"encode",
"(",
")",
"return",
"arg"
] | https://github.com/globaleaks/GlobaLeaks/blob/4624ca937728adb8e21c4733a8aecec6a41cb3db/backend/globaleaks/utils/crypto.py#L29-L38 | |
oilshell/oil | 94388e7d44a9ad879b12615f6203b38596b5a2d3 | Python-2.7.13/Lib/lib-tk/Tkinter.py | python | Menu.add_command | (self, cnf={}, **kw) | Add command menu item. | Add command menu item. | [
"Add",
"command",
"menu",
"item",
"."
] | def add_command(self, cnf={}, **kw):
"""Add command menu item."""
self.add('command', cnf or kw) | [
"def",
"add_command",
"(",
"self",
",",
"cnf",
"=",
"{",
"}",
",",
"*",
"*",
"kw",
")",
":",
"self",
".",
"add",
"(",
"'command'",
",",
"cnf",
"or",
"kw",
")"
] | https://github.com/oilshell/oil/blob/94388e7d44a9ad879b12615f6203b38596b5a2d3/Python-2.7.13/Lib/lib-tk/Tkinter.py#L2742-L2744 | ||
smart-mobile-software/gitstack | d9fee8f414f202143eb6e620529e8e5539a2af56 | python/Lib/site-packages/django/db/models/query.py | python | QuerySet.reverse | (self) | return clone | Reverses the ordering of the QuerySet. | Reverses the ordering of the QuerySet. | [
"Reverses",
"the",
"ordering",
"of",
"the",
"QuerySet",
"."
] | def reverse(self):
"""
Reverses the ordering of the QuerySet.
"""
clone = self._clone()
clone.query.standard_ordering = not clone.query.standard_ordering
return clone | [
"def",
"reverse",
"(",
"self",
")",
":",
"clone",
"=",
"self",
".",
"_clone",
"(",
")",
"clone",
".",
"query",
".",
"standard_ordering",
"=",
"not",
"clone",
".",
"query",
".",
"standard_ordering",
"return",
"clone"
] | https://github.com/smart-mobile-software/gitstack/blob/d9fee8f414f202143eb6e620529e8e5539a2af56/python/Lib/site-packages/django/db/models/query.py#L780-L786 | |
SkullTech/drymail | 56fac5bdfff4410bb52ed98d5f0d483bb5e1e144 | drymail.py | python | stringify_addresses | (addresses) | Converts a list of addresses into a string in the
`"John Doe" <john@example.com>, "Jane" <jane@example.com>"` format,
which can be directly used in the headers of an email.
Parameters
----------
addresses : (str or (str, str)) or list of (str or (str, str))
A single address or a list of add... | Converts a list of addresses into a string in the
`"John Doe" <john@example.com>, "Jane" <jane@example.com>"` format,
which can be directly used in the headers of an email. | [
"Converts",
"a",
"list",
"of",
"addresses",
"into",
"a",
"string",
"in",
"the",
"John",
"Doe",
"<john@example",
".",
"com",
">",
"Jane",
"<jane@example",
".",
"com",
">",
"format",
"which",
"can",
"be",
"directly",
"used",
"in",
"the",
"headers",
"of",
"... | def stringify_addresses(addresses):
"""
Converts a list of addresses into a string in the
`"John Doe" <john@example.com>, "Jane" <jane@example.com>"` format,
which can be directly used in the headers of an email.
Parameters
----------
addresses : (str or (str, str)) or list of (str or (str,... | [
"def",
"stringify_addresses",
"(",
"addresses",
")",
":",
"if",
"isinstance",
"(",
"addresses",
",",
"list",
")",
":",
"addresses",
"=",
"[",
"stringify_address",
"(",
"address",
")",
"for",
"address",
"in",
"addresses",
"]",
"return",
"', '",
".",
"join",
... | https://github.com/SkullTech/drymail/blob/56fac5bdfff4410bb52ed98d5f0d483bb5e1e144/drymail.py#L154-L175 | ||
exodrifter/unity-python | bef6e4e9ddfbbf1eaf7acbbb973e9aa3dd64a20d | Lib/SimpleXMLRPCServer.py | python | SimpleXMLRPCDispatcher.register_instance | (self, instance, allow_dotted_names=False) | Registers an instance to respond to XML-RPC requests.
Only one instance can be installed at a time.
If the registered instance has a _dispatch method then that
method will be called with the name of the XML-RPC method and
its parameters as a tuple
e.g. instance._dispatch('add',... | Registers an instance to respond to XML-RPC requests. | [
"Registers",
"an",
"instance",
"to",
"respond",
"to",
"XML",
"-",
"RPC",
"requests",
"."
] | def register_instance(self, instance, allow_dotted_names=False):
"""Registers an instance to respond to XML-RPC requests.
Only one instance can be installed at a time.
If the registered instance has a _dispatch method then that
method will be called with the name of the XML-RPC method ... | [
"def",
"register_instance",
"(",
"self",
",",
"instance",
",",
"allow_dotted_names",
"=",
"False",
")",
":",
"self",
".",
"instance",
"=",
"instance",
"self",
".",
"allow_dotted_names",
"=",
"allow_dotted_names"
] | https://github.com/exodrifter/unity-python/blob/bef6e4e9ddfbbf1eaf7acbbb973e9aa3dd64a20d/Lib/SimpleXMLRPCServer.py#L175-L209 | ||
Source-Python-Dev-Team/Source.Python | d0ffd8ccbd1e9923c9bc44936f20613c1c76b7fb | addons/source-python/Python3/importlib/_bootstrap_external.py | python | _path_is_mode_type | (path, mode) | return (stat_info.st_mode & 0o170000) == mode | Test whether the path is the specified mode type. | Test whether the path is the specified mode type. | [
"Test",
"whether",
"the",
"path",
"is",
"the",
"specified",
"mode",
"type",
"."
] | def _path_is_mode_type(path, mode):
"""Test whether the path is the specified mode type."""
try:
stat_info = _path_stat(path)
except OSError:
return False
return (stat_info.st_mode & 0o170000) == mode | [
"def",
"_path_is_mode_type",
"(",
"path",
",",
"mode",
")",
":",
"try",
":",
"stat_info",
"=",
"_path_stat",
"(",
"path",
")",
"except",
"OSError",
":",
"return",
"False",
"return",
"(",
"stat_info",
".",
"st_mode",
"&",
"0o170000",
")",
"==",
"mode"
] | https://github.com/Source-Python-Dev-Team/Source.Python/blob/d0ffd8ccbd1e9923c9bc44936f20613c1c76b7fb/addons/source-python/Python3/importlib/_bootstrap_external.py#L85-L91 | |
hequan2017/chain | 169f810551a8355579d3cef670ecf88942478a05 | tasks/views.py | python | taillog | (request, hostname, port, username, password, private, tail) | 执行 tail log 接口 | 执行 tail log 接口 | [
"执行",
"tail",
"log",
"接口"
] | def taillog(request, hostname, port, username, password, private, tail):
"""
执行 tail log 接口
"""
channel_layer = get_channel_layer()
user = request.user.username
os.environ["".format(user)] = "true"
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
i... | [
"def",
"taillog",
"(",
"request",
",",
"hostname",
",",
"port",
",",
"username",
",",
"password",
",",
"private",
",",
"tail",
")",
":",
"channel_layer",
"=",
"get_channel_layer",
"(",
")",
"user",
"=",
"request",
".",
"user",
".",
"username",
"os",
".",... | https://github.com/hequan2017/chain/blob/169f810551a8355579d3cef670ecf88942478a05/tasks/views.py#L163-L184 | ||
simons-public/protonfixes | 24ecb378bc4e99bfe698090661d255dcbb5b677f | protonfixes/corefonts.py | python | get_corefonts | () | Downloads the ms-corefonts from the pushcx/corefonts mirror | Downloads the ms-corefonts from the pushcx/corefonts mirror | [
"Downloads",
"the",
"ms",
"-",
"corefonts",
"from",
"the",
"pushcx",
"/",
"corefonts",
"mirror"
] | def get_corefonts():
""" Downloads the ms-corefonts from the pushcx/corefonts mirror
"""
if check_corefonts():
return
urlbase = 'https://github.com/pushcx/corefonts/raw/master/'
urlsuffix = '32.exe'
fonts = ['andale', 'arial', 'arialb', 'comic', 'courie', 'georgi',
'impact... | [
"def",
"get_corefonts",
"(",
")",
":",
"if",
"check_corefonts",
"(",
")",
":",
"return",
"urlbase",
"=",
"'https://github.com/pushcx/corefonts/raw/master/'",
"urlsuffix",
"=",
"'32.exe'",
"fonts",
"=",
"[",
"'andale'",
",",
"'arial'",
",",
"'arialb'",
",",
"'comic... | https://github.com/simons-public/protonfixes/blob/24ecb378bc4e99bfe698090661d255dcbb5b677f/protonfixes/corefonts.py#L89-L128 | ||
tendenci/tendenci | 0f2c348cc0e7d41bc56f50b00ce05544b083bf1d | tendenci/apps/helpdesk/views/staff.py | python | calc_basic_ticket_stats | (Tickets) | return basic_ticket_stats | [] | def calc_basic_ticket_stats(Tickets):
# all not closed tickets (open, reopened, resolved,) - independent of user
all_open_tickets = Tickets.exclude(status = Ticket.CLOSED_STATUS)
today = datetime.today()
date_30 = date_rel_to_today(today, 30)
date_60 = date_rel_to_today(today, 60)
date_30_str =... | [
"def",
"calc_basic_ticket_stats",
"(",
"Tickets",
")",
":",
"# all not closed tickets (open, reopened, resolved,) - independent of user",
"all_open_tickets",
"=",
"Tickets",
".",
"exclude",
"(",
"status",
"=",
"Ticket",
".",
"CLOSED_STATUS",
")",
"today",
"=",
"datetime",
... | https://github.com/tendenci/tendenci/blob/0f2c348cc0e7d41bc56f50b00ce05544b083bf1d/tendenci/apps/helpdesk/views/staff.py#L1396-L1437 | |||
pyscf/pyscf | 0adfb464333f5ceee07b664f291d4084801bae64 | pyscf/pbc/scf/kuhf.py | python | make_rdm1 | (mo_coeff_kpts, mo_occ_kpts, **kwargs) | return lib.asarray(dm_kpts).reshape(2,nkpts,nao,nao) | Alpha and beta spin one particle density matrices for all k-points.
Returns:
dm_kpts : (2, nkpts, nao, nao) ndarray | Alpha and beta spin one particle density matrices for all k-points. | [
"Alpha",
"and",
"beta",
"spin",
"one",
"particle",
"density",
"matrices",
"for",
"all",
"k",
"-",
"points",
"."
] | def make_rdm1(mo_coeff_kpts, mo_occ_kpts, **kwargs):
'''Alpha and beta spin one particle density matrices for all k-points.
Returns:
dm_kpts : (2, nkpts, nao, nao) ndarray
'''
nkpts = len(mo_occ_kpts[0])
nao, nmo = mo_coeff_kpts[0][0].shape
def make_dm(mos, occs):
return [np.dot... | [
"def",
"make_rdm1",
"(",
"mo_coeff_kpts",
",",
"mo_occ_kpts",
",",
"*",
"*",
"kwargs",
")",
":",
"nkpts",
"=",
"len",
"(",
"mo_occ_kpts",
"[",
"0",
"]",
")",
"nao",
",",
"nmo",
"=",
"mo_coeff_kpts",
"[",
"0",
"]",
"[",
"0",
"]",
".",
"shape",
"def"... | https://github.com/pyscf/pyscf/blob/0adfb464333f5ceee07b664f291d4084801bae64/pyscf/pbc/scf/kuhf.py#L47-L59 | |
mozillazg/pypy | 2ff5cd960c075c991389f842c6d59e71cf0cb7d0 | lib-python/2.7/sysconfig.py | python | _parse_makefile | (filename, vars=None) | return vars | Parse a Makefile-style file.
A dictionary containing name/value pairs is returned. If an
optional dictionary is passed in as the second argument, it is
used instead of a new dictionary. | Parse a Makefile-style file. | [
"Parse",
"a",
"Makefile",
"-",
"style",
"file",
"."
] | def _parse_makefile(filename, vars=None):
"""Parse a Makefile-style file.
A dictionary containing name/value pairs is returned. If an
optional dictionary is passed in as the second argument, it is
used instead of a new dictionary.
"""
import re
# Regexes needed for parsing Makefile (and si... | [
"def",
"_parse_makefile",
"(",
"filename",
",",
"vars",
"=",
"None",
")",
":",
"import",
"re",
"# Regexes needed for parsing Makefile (and similar syntaxes,",
"# like old-style Setup files).",
"_variable_rx",
"=",
"re",
".",
"compile",
"(",
"\"([a-zA-Z][a-zA-Z0-9_]+)\\s*=\\s*... | https://github.com/mozillazg/pypy/blob/2ff5cd960c075c991389f842c6d59e71cf0cb7d0/lib-python/2.7/sysconfig.py#L225-L308 | |
microsoft/bistring | e23443e495f762967b09670b27bb1ff46ff4fef1 | python/bistring/_builder.py | python | BistrBuilder.is_complete | (self) | return self.remaining == 0 | Whether we've completely processed the string. In other words, whether the modified string aligns with the end
of the current string. | Whether we've completely processed the string. In other words, whether the modified string aligns with the end
of the current string. | [
"Whether",
"we",
"ve",
"completely",
"processed",
"the",
"string",
".",
"In",
"other",
"words",
"whether",
"the",
"modified",
"string",
"aligns",
"with",
"the",
"end",
"of",
"the",
"current",
"string",
"."
] | def is_complete(self) -> bool:
"""
Whether we've completely processed the string. In other words, whether the modified string aligns with the end
of the current string.
"""
return self.remaining == 0 | [
"def",
"is_complete",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"remaining",
"==",
"0"
] | https://github.com/microsoft/bistring/blob/e23443e495f762967b09670b27bb1ff46ff4fef1/python/bistring/_builder.py#L119-L124 | |
rhinstaller/anaconda | 63edc8680f1b05cbfe11bef28703acba808c5174 | pyanaconda/modules/storage/bootloader/grub2.py | python | GRUB2.write_device_map | (self) | Write out a device map containing all supported devices. | Write out a device map containing all supported devices. | [
"Write",
"out",
"a",
"device",
"map",
"containing",
"all",
"supported",
"devices",
"."
] | def write_device_map(self):
"""Write out a device map containing all supported devices."""
map_path = os.path.normpath(conf.target.system_root + self.device_map_file)
if os.access(map_path, os.R_OK):
os.rename(map_path, map_path + ".anacbak")
devices = self.disks
if ... | [
"def",
"write_device_map",
"(",
"self",
")",
":",
"map_path",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"conf",
".",
"target",
".",
"system_root",
"+",
"self",
".",
"device_map_file",
")",
"if",
"os",
".",
"access",
"(",
"map_path",
",",
"os",
".",... | https://github.com/rhinstaller/anaconda/blob/63edc8680f1b05cbfe11bef28703acba808c5174/pyanaconda/modules/storage/bootloader/grub2.py#L227-L251 | ||
pantsbuild/pex | 473c6ac732ed4bc338b4b20a9ec930d1d722c9b4 | pex/vendor/_vendored/setuptools/pkg_resources/__init__.py | python | ResourceManager.resource_isdir | (self, package_or_requirement, resource_name) | return get_provider(package_or_requirement).resource_isdir(
resource_name
) | Is the named resource an existing directory? | Is the named resource an existing directory? | [
"Is",
"the",
"named",
"resource",
"an",
"existing",
"directory?"
] | def resource_isdir(self, package_or_requirement, resource_name):
"""Is the named resource an existing directory?"""
return get_provider(package_or_requirement).resource_isdir(
resource_name
) | [
"def",
"resource_isdir",
"(",
"self",
",",
"package_or_requirement",
",",
"resource_name",
")",
":",
"return",
"get_provider",
"(",
"package_or_requirement",
")",
".",
"resource_isdir",
"(",
"resource_name",
")"
] | https://github.com/pantsbuild/pex/blob/473c6ac732ed4bc338b4b20a9ec930d1d722c9b4/pex/vendor/_vendored/setuptools/pkg_resources/__init__.py#L1168-L1172 | |
pdpipe/pdpipe | 69502436d2a4ce70c6123d7a9db02cbf10f56cf2 | versioneer.py | python | render_pep440_post | (pieces) | return rendered | TAG[.postDISTANCE[.dev0]+gHEX] .
The ".dev0" means dirty. Note that .dev0 sorts backwards
(a dirty tree will appear "older" than the corresponding clean one),
but you shouldn't be releasing software with -dirty anyways.
Exceptions:
1: no tags. 0.postDISTANCE[.dev0] | TAG[.postDISTANCE[.dev0]+gHEX] . | [
"TAG",
"[",
".",
"postDISTANCE",
"[",
".",
"dev0",
"]",
"+",
"gHEX",
"]",
"."
] | def render_pep440_post(pieces):
"""TAG[.postDISTANCE[.dev0]+gHEX] .
The ".dev0" means dirty. Note that .dev0 sorts backwards
(a dirty tree will appear "older" than the corresponding clean one),
but you shouldn't be releasing software with -dirty anyways.
Exceptions:
1: no tags. 0.postDISTANCE[... | [
"def",
"render_pep440_post",
"(",
"pieces",
")",
":",
"if",
"pieces",
"[",
"\"closest-tag\"",
"]",
":",
"rendered",
"=",
"pieces",
"[",
"\"closest-tag\"",
"]",
"if",
"pieces",
"[",
"\"distance\"",
"]",
"or",
"pieces",
"[",
"\"dirty\"",
"]",
":",
"rendered",
... | https://github.com/pdpipe/pdpipe/blob/69502436d2a4ce70c6123d7a9db02cbf10f56cf2/versioneer.py#L1277-L1301 | |
saltstack/salt-contrib | 062355938ad1cced273056e9c23dc344c6a2c858 | modules/dockerio.py | python | _valid | (m, id_=NOTSET, comment=VALID_RESPONSE, out=None) | return _set_status(m, status=True, id_=id_, comment=comment, out=out) | Return valid status | Return valid status | [
"Return",
"valid",
"status"
] | def _valid(m, id_=NOTSET, comment=VALID_RESPONSE, out=None):
'''
Return valid status
'''
return _set_status(m, status=True, id_=id_, comment=comment, out=out) | [
"def",
"_valid",
"(",
"m",
",",
"id_",
"=",
"NOTSET",
",",
"comment",
"=",
"VALID_RESPONSE",
",",
"out",
"=",
"None",
")",
":",
"return",
"_set_status",
"(",
"m",
",",
"status",
"=",
"True",
",",
"id_",
"=",
"id_",
",",
"comment",
"=",
"comment",
"... | https://github.com/saltstack/salt-contrib/blob/062355938ad1cced273056e9c23dc344c6a2c858/modules/dockerio.py#L249-L253 | |
LiyuanLucasLiu/LD-Net | f9489b6e7d436b7e3ed6447b797fb6ce9a886483 | model_word_ada/utils.py | python | repackage_hidden | (h) | Wraps hidden states in new Variables, to detach them from their history
Parameters
----------
h : ``Tuple`` or ``Tensors``, required.
Tuple or Tensors, hidden states.
Returns
-------
hidden: ``Tuple`` or ``Tensors``.
detached hidden states | Wraps hidden states in new Variables, to detach them from their history | [
"Wraps",
"hidden",
"states",
"in",
"new",
"Variables",
"to",
"detach",
"them",
"from",
"their",
"history"
] | def repackage_hidden(h):
"""
Wraps hidden states in new Variables, to detach them from their history
Parameters
----------
h : ``Tuple`` or ``Tensors``, required.
Tuple or Tensors, hidden states.
Returns
-------
hidden: ``Tuple`` or ``Tensors``.
detached hidden states
... | [
"def",
"repackage_hidden",
"(",
"h",
")",
":",
"if",
"type",
"(",
"h",
")",
"==",
"torch",
".",
"Tensor",
":",
"return",
"h",
".",
"detach",
"(",
")",
"else",
":",
"return",
"tuple",
"(",
"repackage_hidden",
"(",
"v",
")",
"for",
"v",
"in",
"h",
... | https://github.com/LiyuanLucasLiu/LD-Net/blob/f9489b6e7d436b7e3ed6447b797fb6ce9a886483/model_word_ada/utils.py#L17-L34 | ||
jina-ai/jina | c77a492fcd5adba0fc3de5347bea83dd4e7d8087 | docarray/array/mixins/parallel.py | python | ParallelMixin.map_batch | (
self: 'T_DA',
func: Callable[['DocumentArray'], 'T'],
batch_size: int,
backend: str = 'process',
num_worker: Optional[int] = None,
shuffle: bool = False,
) | Return an iterator that applies function to every **minibatch** of iterable in parallel, yielding the results.
Each element in the returned iterator is :class:`DocumentArray`.
.. seealso::
- To process single element, please use :meth:`.map`;
- To return :class:`DocumentArray` o... | Return an iterator that applies function to every **minibatch** of iterable in parallel, yielding the results.
Each element in the returned iterator is :class:`DocumentArray`. | [
"Return",
"an",
"iterator",
"that",
"applies",
"function",
"to",
"every",
"**",
"minibatch",
"**",
"of",
"iterable",
"in",
"parallel",
"yielding",
"the",
"results",
".",
"Each",
"element",
"in",
"the",
"returned",
"iterator",
"is",
":",
"class",
":",
"Docume... | def map_batch(
self: 'T_DA',
func: Callable[['DocumentArray'], 'T'],
batch_size: int,
backend: str = 'process',
num_worker: Optional[int] = None,
shuffle: bool = False,
) -> Generator['T', None, None]:
"""Return an iterator that applies function to every **min... | [
"def",
"map_batch",
"(",
"self",
":",
"'T_DA'",
",",
"func",
":",
"Callable",
"[",
"[",
"'DocumentArray'",
"]",
",",
"'T'",
"]",
",",
"batch_size",
":",
"int",
",",
"backend",
":",
"str",
"=",
"'process'",
",",
"num_worker",
":",
"Optional",
"[",
"int"... | https://github.com/jina-ai/jina/blob/c77a492fcd5adba0fc3de5347bea83dd4e7d8087/docarray/array/mixins/parallel.py#L128-L165 | ||
jjjake/internetarchive | 7b0472464b065477101a847a8332d8b4dc1bf74e | internetarchive/cli/ia_upload.py | python | main | (argv, session) | [] | def main(argv, session):
if six.PY2:
args = docopt(__doc__.encode('utf-8'), argv=argv)
else:
args = docopt(__doc__, argv=argv)
ERRORS = False
# Validate args.
s = Schema({
str: Use(bool),
'<identifier>': Or(None, And(str, validate_s3_identifier,
error=('<... | [
"def",
"main",
"(",
"argv",
",",
"session",
")",
":",
"if",
"six",
".",
"PY2",
":",
"args",
"=",
"docopt",
"(",
"__doc__",
".",
"encode",
"(",
"'utf-8'",
")",
",",
"argv",
"=",
"argv",
")",
"else",
":",
"args",
"=",
"docopt",
"(",
"__doc__",
",",... | https://github.com/jjjake/internetarchive/blob/7b0472464b065477101a847a8332d8b4dc1bf74e/internetarchive/cli/ia_upload.py#L132-L310 | ||||
ialbert/plac | 00f9dbb5721ea855132fdc5994961cefb504aa56 | plac_core.py | python | ArgumentParser.populate_from | (self, func) | Extract the arguments from the attributes of the passed function
and return a populated ArgumentParser instance. | Extract the arguments from the attributes of the passed function
and return a populated ArgumentParser instance. | [
"Extract",
"the",
"arguments",
"from",
"the",
"attributes",
"of",
"the",
"passed",
"function",
"and",
"return",
"a",
"populated",
"ArgumentParser",
"instance",
"."
] | def populate_from(self, func):
"""
Extract the arguments from the attributes of the passed function
and return a populated ArgumentParser instance.
"""
self._set_func_argspec(func)
f = self.argspec
defaults = f.defaults or ()
n_args = len(f.args)
n... | [
"def",
"populate_from",
"(",
"self",
",",
"func",
")",
":",
"self",
".",
"_set_func_argspec",
"(",
"func",
")",
"f",
"=",
"self",
".",
"argspec",
"defaults",
"=",
"f",
".",
"defaults",
"or",
"(",
")",
"n_args",
"=",
"len",
"(",
"f",
".",
"args",
")... | https://github.com/ialbert/plac/blob/00f9dbb5721ea855132fdc5994961cefb504aa56/plac_core.py#L331-L402 | ||
fonttools/fonttools | 892322aaff6a89bea5927379ec06bc0da3dfb7df | Lib/fontTools/cffLib/specializer.py | python | _GeneralizerDecombinerCommandsMap.vvcurveto | (args) | [] | def vvcurveto(args):
if len(args) < 4 or len(args) % 4 > 1: raise ValueError(args)
if len(args) % 2 == 1:
yield ('rrcurveto', [args[0], args[1], args[2], args[3], 0, args[4]])
args = args[5:]
for args in _everyN(args, 4):
yield ('rrcurveto', [0, args[0], args[1], args[2], 0, args[3]]) | [
"def",
"vvcurveto",
"(",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"<",
"4",
"or",
"len",
"(",
"args",
")",
"%",
"4",
">",
"1",
":",
"raise",
"ValueError",
"(",
"args",
")",
"if",
"len",
"(",
"args",
")",
"%",
"2",
"==",
"1",
":",
"y... | https://github.com/fonttools/fonttools/blob/892322aaff6a89bea5927379ec06bc0da3dfb7df/Lib/fontTools/cffLib/specializer.py#L208-L214 | ||||
JasperSnoek/spearmint | b37a541be1ea035f82c7c82bbd93f5b4320e7d91 | spearmint-lite/ExperimentGrid.py | python | ExperimentGrid.__del__ | (self) | [] | def __del__(self):
self._save_jobs()
if self.locker.unlock(self.jobs_pkl):
sys.stderr.write("Released lock on job grid.\n")
else:
raise Exception("Could not release lock on job grid.\n") | [
"def",
"__del__",
"(",
"self",
")",
":",
"self",
".",
"_save_jobs",
"(",
")",
"if",
"self",
".",
"locker",
".",
"unlock",
"(",
"self",
".",
"jobs_pkl",
")",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"\"Released lock on job grid.\\n\"",
")",
"else",
... | https://github.com/JasperSnoek/spearmint/blob/b37a541be1ea035f82c7c82bbd93f5b4320e7d91/spearmint-lite/ExperimentGrid.py#L85-L90 | ||||
AppScale/gts | 46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9 | AppServer/lib/setuptools-0.6c11/pkg_resources.py | python | find_on_path | (importer, path_item, only=False) | Yield distributions accessible on a sys.path directory | Yield distributions accessible on a sys.path directory | [
"Yield",
"distributions",
"accessible",
"on",
"a",
"sys",
".",
"path",
"directory"
] | def find_on_path(importer, path_item, only=False):
"""Yield distributions accessible on a sys.path directory"""
path_item = _normalize_cached(path_item)
if os.path.isdir(path_item) and os.access(path_item, os.R_OK):
if path_item.lower().endswith('.egg'):
# unpacked egg
yield... | [
"def",
"find_on_path",
"(",
"importer",
",",
"path_item",
",",
"only",
"=",
"False",
")",
":",
"path_item",
"=",
"_normalize_cached",
"(",
"path_item",
")",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"path_item",
")",
"and",
"os",
".",
"access",
"(",
... | https://github.com/AppScale/gts/blob/46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9/AppServer/lib/setuptools-0.6c11/pkg_resources.py#L1686-L1720 | ||
NeuralEnsemble/python-neo | 34d4db8fb0dc950dbbc6defd7fb75e99ea877286 | neo/rawio/baserawio.py | python | BaseRawIO.__init__ | (self, use_cache=False, cache_path='same_as_resource', **kargs) | :TODO: Why multi-file would have a single filename is confusing here - shouldn't
the name of this argument be filenames_list or filenames_base or similar?
When rawmode=='one-file' kargs MUST contains 'filename' the filename
When rawmode=='multi-file' kargs MUST contains 'filename' one of the fi... | :TODO: Why multi-file would have a single filename is confusing here - shouldn't
the name of this argument be filenames_list or filenames_base or similar? | [
":",
"TODO",
":",
"Why",
"multi",
"-",
"file",
"would",
"have",
"a",
"single",
"filename",
"is",
"confusing",
"here",
"-",
"shouldn",
"t",
"the",
"name",
"of",
"this",
"argument",
"be",
"filenames_list",
"or",
"filenames_base",
"or",
"similar?"
] | def __init__(self, use_cache=False, cache_path='same_as_resource', **kargs):
"""
:TODO: Why multi-file would have a single filename is confusing here - shouldn't
the name of this argument be filenames_list or filenames_base or similar?
When rawmode=='one-file' kargs MUST contains 'filen... | [
"def",
"__init__",
"(",
"self",
",",
"use_cache",
"=",
"False",
",",
"cache_path",
"=",
"'same_as_resource'",
",",
"*",
"*",
"kargs",
")",
":",
"# create a logger for the IO class",
"fullname",
"=",
"self",
".",
"__class__",
".",
"__module__",
"+",
"'.'",
"+",... | https://github.com/NeuralEnsemble/python-neo/blob/34d4db8fb0dc950dbbc6defd7fb75e99ea877286/neo/rawio/baserawio.py#L142-L170 | ||
AndroBugs/AndroBugs_Framework | 7fd3a2cb1cf65a9af10b7ed2129701d4451493fe | tools/modified/androguard/core/analysis/analysis.py | python | RegisterAnalyzerVM_ImmediateValue.get_register_value_by_param_in_last_ins | (self, param) | Example code:
invoke-virtual v2, v3, v6, v4, v5, Landroid/content/Context;->openOrCreateDatabase(Ljava/lang/String; I Landroid/database/sqlite/SQLiteDatabase$CursorFactory; Landroid/database/DatabaseErrorHandler;)Landroid/database/sqlite/SQLiteDatabase;
[(0, 2), (0, 3), (0, 6), (0, 4), (0, 5), (... | Example code:
invoke-virtual v2, v3, v6, v4, v5, Landroid/content/Context;->openOrCreateDatabase(Ljava/lang/String; I Landroid/database/sqlite/SQLiteDatabase$CursorFactory; Landroid/database/DatabaseErrorHandler;)Landroid/database/sqlite/SQLiteDatabase;
[(0, 2), (0, 3), (0, 6), (0, 4), (0, 5), (... | [
"Example",
"code",
":",
"invoke",
"-",
"virtual",
"v2",
"v3",
"v6",
"v4",
"v5",
"Landroid",
"/",
"content",
"/",
"Context",
";",
"-",
">",
"openOrCreateDatabase",
"(",
"Ljava",
"/",
"lang",
"/",
"String",
";",
"I",
"Landroid",
"/",
"database",
"/",
"sq... | def get_register_value_by_param_in_last_ins(self, param):
if (self._register is None) or (self.__ins_stack is None):
return None
"""
Example code:
invoke-virtual v2, v3, v6, v4, v5, Landroid/content/Context;->openOrCreateDatabase(Ljava/lang/String; I Landroid/databa... | [
"def",
"get_register_value_by_param_in_last_ins",
"(",
"self",
",",
"param",
")",
":",
"if",
"(",
"self",
".",
"_register",
"is",
"None",
")",
"or",
"(",
"self",
".",
"__ins_stack",
"is",
"None",
")",
":",
"return",
"None",
"try",
":",
"last_ins",
"=",
"... | https://github.com/AndroBugs/AndroBugs_Framework/blob/7fd3a2cb1cf65a9af10b7ed2129701d4451493fe/tools/modified/androguard/core/analysis/analysis.py#L343-L361 | ||
buke/GreenOdoo | 3d8c55d426fb41fdb3f2f5a1533cfe05983ba1df | source/openerp/netsvc.py | python | LocalService | (name) | The openerp.netsvc.LocalService() function is deprecated. It still works
in two cases: workflows and reports. For workflows, instead of using
LocalService('workflow'), openerp.workflow should be used (better yet,
methods on openerp.osv.orm.Model should be used). For reports,
openerp.report.render_report... | The openerp.netsvc.LocalService() function is deprecated. It still works
in two cases: workflows and reports. For workflows, instead of using
LocalService('workflow'), openerp.workflow should be used (better yet,
methods on openerp.osv.orm.Model should be used). For reports,
openerp.report.render_report... | [
"The",
"openerp",
".",
"netsvc",
".",
"LocalService",
"()",
"function",
"is",
"deprecated",
".",
"It",
"still",
"works",
"in",
"two",
"cases",
":",
"workflows",
"and",
"reports",
".",
"For",
"workflows",
"instead",
"of",
"using",
"LocalService",
"(",
"workfl... | def LocalService(name):
"""
The openerp.netsvc.LocalService() function is deprecated. It still works
in two cases: workflows and reports. For workflows, instead of using
LocalService('workflow'), openerp.workflow should be used (better yet,
methods on openerp.osv.orm.Model should be used). For repor... | [
"def",
"LocalService",
"(",
"name",
")",
":",
"assert",
"openerp",
".",
"conf",
".",
"deprecation",
".",
"allow_local_service",
"_logger",
".",
"warning",
"(",
"\"LocalService() is deprecated since march 2013 (it was called with '%s').\"",
"%",
"name",
")",
"if",
"name"... | https://github.com/buke/GreenOdoo/blob/3d8c55d426fb41fdb3f2f5a1533cfe05983ba1df/source/openerp/netsvc.py#L46-L70 | ||
volatilityfoundation/volatility | a438e768194a9e05eb4d9ee9338b881c0fa25937 | volatility/plugins/overlays/windows/pe_vtypes.py | python | _LDR_DATA_TABLE_ENTRY.import_dir | (self) | return self._directory(1) | Return the IMAGE_DATA_DIRECTORY for imports | Return the IMAGE_DATA_DIRECTORY for imports | [
"Return",
"the",
"IMAGE_DATA_DIRECTORY",
"for",
"imports"
] | def import_dir(self):
"""Return the IMAGE_DATA_DIRECTORY for imports"""
return self._directory(1) | [
"def",
"import_dir",
"(",
"self",
")",
":",
"return",
"self",
".",
"_directory",
"(",
"1",
")"
] | https://github.com/volatilityfoundation/volatility/blob/a438e768194a9e05eb4d9ee9338b881c0fa25937/volatility/plugins/overlays/windows/pe_vtypes.py#L505-L507 | |
securityclippy/elasticintel | aa08d3e9f5ab1c000128e95161139ce97ff0e334 | ingest_feed_lambda/pandas/core/indexes/category.py | python | CategoricalIndex._delegate_method | (self, name, *args, **kwargs) | return CategoricalIndex(res, name=self.name) | method delegation to the ._values | method delegation to the ._values | [
"method",
"delegation",
"to",
"the",
".",
"_values"
] | def _delegate_method(self, name, *args, **kwargs):
""" method delegation to the ._values """
method = getattr(self._values, name)
if 'inplace' in kwargs:
raise ValueError("cannot use inplace with CategoricalIndex")
res = method(*args, **kwargs)
if is_scalar(res):
... | [
"def",
"_delegate_method",
"(",
"self",
",",
"name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"method",
"=",
"getattr",
"(",
"self",
".",
"_values",
",",
"name",
")",
"if",
"'inplace'",
"in",
"kwargs",
":",
"raise",
"ValueError",
"(",
"\"... | https://github.com/securityclippy/elasticintel/blob/aa08d3e9f5ab1c000128e95161139ce97ff0e334/ingest_feed_lambda/pandas/core/indexes/category.py#L738-L746 | |
inducer/pyopencl | 71b29745dc023a4d3aa9ddf22ff65c0cb3e6d703 | pyopencl/array.py | python | Array.get | (self, queue=None, ary=None, async_=None, **kwargs) | return ary | Transfer the contents of *self* into *ary* or a newly allocated
:class:`numpy.ndarray`. If *ary* is given, it must have the same
shape and dtype.
.. versionchanged:: 2019.1.2
Calling with `async_=True` was deprecated and replaced by
:meth:`get_async`.
The ev... | Transfer the contents of *self* into *ary* or a newly allocated
:class:`numpy.ndarray`. If *ary* is given, it must have the same
shape and dtype. | [
"Transfer",
"the",
"contents",
"of",
"*",
"self",
"*",
"into",
"*",
"ary",
"*",
"or",
"a",
"newly",
"allocated",
":",
"class",
":",
"numpy",
".",
"ndarray",
".",
"If",
"*",
"ary",
"*",
"is",
"given",
"it",
"must",
"have",
"the",
"same",
"shape",
"a... | def get(self, queue=None, ary=None, async_=None, **kwargs):
"""Transfer the contents of *self* into *ary* or a newly allocated
:class:`numpy.ndarray`. If *ary* is given, it must have the same
shape and dtype.
.. versionchanged:: 2019.1.2
Calling with `async_=True` was depre... | [
"def",
"get",
"(",
"self",
",",
"queue",
"=",
"None",
",",
"ary",
"=",
"None",
",",
"async_",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"async_",
":",
"from",
"warnings",
"import",
"warn",
"warn",
"(",
"\"calling pyopencl.Array.get with `asyn... | https://github.com/inducer/pyopencl/blob/71b29745dc023a4d3aa9ddf22ff65c0cb3e6d703/pyopencl/array.py#L780-L814 | |
allenai/allennlp | a3d71254fcc0f3615910e9c3d48874515edf53e0 | allennlp/training/learning_rate_schedulers/learning_rate_scheduler.py | python | _PyTorchLearningRateSchedulerWrapper.state_dict | (self) | return self.lr_scheduler.state_dict() | [] | def state_dict(self) -> Dict[str, Any]:
return self.lr_scheduler.state_dict() | [
"def",
"state_dict",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"self",
".",
"lr_scheduler",
".",
"state_dict",
"(",
")"
] | https://github.com/allenai/allennlp/blob/a3d71254fcc0f3615910e9c3d48874515edf53e0/allennlp/training/learning_rate_schedulers/learning_rate_scheduler.py#L36-L37 | |||
mlcommons/inference | 078e21f2bc0a37c7fd0e435d64f5a49760dca823 | translation/gnmt/tensorflow/nmt/model_helper.py | python | _get_embed_device | (vocab_size) | Decide on which device to place an embed matrix given its vocab size. | Decide on which device to place an embed matrix given its vocab size. | [
"Decide",
"on",
"which",
"device",
"to",
"place",
"an",
"embed",
"matrix",
"given",
"its",
"vocab",
"size",
"."
] | def _get_embed_device(vocab_size):
"""Decide on which device to place an embed matrix given its vocab size."""
if vocab_size > VOCAB_SIZE_THRESHOLD_CPU:
return "/cpu:0"
else:
return "/gpu:0" | [
"def",
"_get_embed_device",
"(",
"vocab_size",
")",
":",
"if",
"vocab_size",
">",
"VOCAB_SIZE_THRESHOLD_CPU",
":",
"return",
"\"/cpu:0\"",
"else",
":",
"return",
"\"/gpu:0\""
] | https://github.com/mlcommons/inference/blob/078e21f2bc0a37c7fd0e435d64f5a49760dca823/translation/gnmt/tensorflow/nmt/model_helper.py#L237-L242 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.