repo stringlengths 7 54 | path stringlengths 4 192 | url stringlengths 87 284 | code stringlengths 78 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|
bolt-project/bolt | bolt/spark/array.py | https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/array.py#L49-L60 | def repartition(self, npartitions):
"""
Repartitions the underlying RDD
Parameters
----------
npartitions : int
Number of partitions to repartion the underlying RDD to
"""
rdd = self._rdd.repartition(npartitions)
return self._constructor(rdd,... | [
"def",
"repartition",
"(",
"self",
",",
"npartitions",
")",
":",
"rdd",
"=",
"self",
".",
"_rdd",
".",
"repartition",
"(",
"npartitions",
")",
"return",
"self",
".",
"_constructor",
"(",
"rdd",
",",
"ordered",
"=",
"False",
")",
".",
"__finalize__",
"(",... | Repartitions the underlying RDD
Parameters
----------
npartitions : int
Number of partitions to repartion the underlying RDD to | [
"Repartitions",
"the",
"underlying",
"RDD"
] | python | test |
twilio/twilio-python | twilio/rest/api/v2010/account/signing_key.py | https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/api/v2010/account/signing_key.py#L117-L126 | def get(self, sid):
"""
Constructs a SigningKeyContext
:param sid: The sid
:returns: twilio.rest.api.v2010.account.signing_key.SigningKeyContext
:rtype: twilio.rest.api.v2010.account.signing_key.SigningKeyContext
"""
return SigningKeyContext(self._version, accou... | [
"def",
"get",
"(",
"self",
",",
"sid",
")",
":",
"return",
"SigningKeyContext",
"(",
"self",
".",
"_version",
",",
"account_sid",
"=",
"self",
".",
"_solution",
"[",
"'account_sid'",
"]",
",",
"sid",
"=",
"sid",
",",
")"
] | Constructs a SigningKeyContext
:param sid: The sid
:returns: twilio.rest.api.v2010.account.signing_key.SigningKeyContext
:rtype: twilio.rest.api.v2010.account.signing_key.SigningKeyContext | [
"Constructs",
"a",
"SigningKeyContext"
] | python | train |
welbornprod/colr | colr/progress_frames.py | https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/progress_frames.py#L808-L832 | def _build_color_variants(cls):
""" Build colorized variants of all frames and return a list of
all frame object names.
"""
# Get the basic frame types first.
frametypes = cls.sets(registered=False)
_colornames = [
# 'black', disabled for now, it won't show on my terminal.
'... | [
"def",
"_build_color_variants",
"(",
"cls",
")",
":",
"# Get the basic frame types first.",
"frametypes",
"=",
"cls",
".",
"sets",
"(",
"registered",
"=",
"False",
")",
"_colornames",
"=",
"[",
"# 'black', disabled for now, it won't show on my terminal.",
"'red'",
",",
... | Build colorized variants of all frames and return a list of
all frame object names. | [
"Build",
"colorized",
"variants",
"of",
"all",
"frames",
"and",
"return",
"a",
"list",
"of",
"all",
"frame",
"object",
"names",
"."
] | python | train |
ga4gh/ga4gh-server | ga4gh/server/datarepo.py | https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/ga4gh/server/datarepo.py#L978-L1000 | def insertReadGroupSet(self, readGroupSet):
"""
Inserts a the specified readGroupSet into this repository.
"""
programsJson = json.dumps(
[protocol.toJsonDict(program) for program in
readGroupSet.getPrograms()])
statsJson = json.dumps(protocol.toJsonDict(... | [
"def",
"insertReadGroupSet",
"(",
"self",
",",
"readGroupSet",
")",
":",
"programsJson",
"=",
"json",
".",
"dumps",
"(",
"[",
"protocol",
".",
"toJsonDict",
"(",
"program",
")",
"for",
"program",
"in",
"readGroupSet",
".",
"getPrograms",
"(",
")",
"]",
")"... | Inserts a the specified readGroupSet into this repository. | [
"Inserts",
"a",
"the",
"specified",
"readGroupSet",
"into",
"this",
"repository",
"."
] | python | train |
tensorflow/mesh | mesh_tensorflow/ops.py | https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/ops.py#L4330-L4348 | def processor_groups(mesh_shape, group_dims):
"""Groups of processors which differ only in the given dimensions.
Args:
mesh_shape: a Shape
group_dims: a list of integers
Returns:
a list of lists of integers (processor numbers)
"""
group_numbers = [
pnum_to_group(mesh_shape, group_dims, pnu... | [
"def",
"processor_groups",
"(",
"mesh_shape",
",",
"group_dims",
")",
":",
"group_numbers",
"=",
"[",
"pnum_to_group",
"(",
"mesh_shape",
",",
"group_dims",
",",
"pnum",
")",
"for",
"pnum",
"in",
"xrange",
"(",
"mesh_shape",
".",
"size",
")",
"]",
"ret",
"... | Groups of processors which differ only in the given dimensions.
Args:
mesh_shape: a Shape
group_dims: a list of integers
Returns:
a list of lists of integers (processor numbers) | [
"Groups",
"of",
"processors",
"which",
"differ",
"only",
"in",
"the",
"given",
"dimensions",
"."
] | python | train |
FutunnOpen/futuquant | futuquant/examples/learn/max_sub.py | https://github.com/FutunnOpen/futuquant/blob/1512b321845f92ec9c578ce2689aa4e8482669e4/futuquant/examples/learn/max_sub.py#L55-L98 | def aStockQoutation(self,code):
'''
订阅一只股票的实时行情数据,接收推送
:param code: 股票代码
:return:
'''
#设置监听-->订阅-->调用接口
# 分时
self.quote_ctx.set_handler(RTDataTest())
self.quote_ctx.subscribe(code, SubType.RT_DATA)
ret_code_rt_data, ret_data_rt_data = sel... | [
"def",
"aStockQoutation",
"(",
"self",
",",
"code",
")",
":",
"#设置监听-->订阅-->调用接口",
"# 分时",
"self",
".",
"quote_ctx",
".",
"set_handler",
"(",
"RTDataTest",
"(",
")",
")",
"self",
".",
"quote_ctx",
".",
"subscribe",
"(",
"code",
",",
"SubType",
".",
"RT_DAT... | 订阅一只股票的实时行情数据,接收推送
:param code: 股票代码
:return: | [
"订阅一只股票的实时行情数据,接收推送",
":",
"param",
"code",
":",
"股票代码",
":",
"return",
":"
] | python | train |
hollenstein/maspy | maspy/inference.py | https://github.com/hollenstein/maspy/blob/f15fcfd24df306d8420540460d902aa3073ec133/maspy/inference.py#L850-L864 | def _findUniqueMappingValues(mapping):
"""Find mapping entries that are unique for one key (value length of 1).
.. Note:
This function can be used to find unique proteins by providing a
peptide to protein mapping.
:param mapping: dict, for each key contains a set of entries
:returns: a... | [
"def",
"_findUniqueMappingValues",
"(",
"mapping",
")",
":",
"uniqueMappingValues",
"=",
"set",
"(",
")",
"for",
"entries",
"in",
"viewvalues",
"(",
"mapping",
")",
":",
"if",
"len",
"(",
"entries",
")",
"==",
"1",
":",
"uniqueMappingValues",
".",
"update",
... | Find mapping entries that are unique for one key (value length of 1).
.. Note:
This function can be used to find unique proteins by providing a
peptide to protein mapping.
:param mapping: dict, for each key contains a set of entries
:returns: a set of unique mapping values | [
"Find",
"mapping",
"entries",
"that",
"are",
"unique",
"for",
"one",
"key",
"(",
"value",
"length",
"of",
"1",
")",
"."
] | python | train |
Fizzadar/pyinfra | pyinfra/api/state.py | https://github.com/Fizzadar/pyinfra/blob/006f751f7db2e07d32522c0285160783de2feb79/pyinfra/api/state.py#L365-L398 | def fail_hosts(self, hosts_to_fail, activated_count=None):
'''
Flag a ``set`` of hosts as failed, error for ``config.FAIL_PERCENT``.
'''
if not hosts_to_fail:
return
activated_count = activated_count or len(self.activated_hosts)
logger.debug('Failing hosts:... | [
"def",
"fail_hosts",
"(",
"self",
",",
"hosts_to_fail",
",",
"activated_count",
"=",
"None",
")",
":",
"if",
"not",
"hosts_to_fail",
":",
"return",
"activated_count",
"=",
"activated_count",
"or",
"len",
"(",
"self",
".",
"activated_hosts",
")",
"logger",
".",... | Flag a ``set`` of hosts as failed, error for ``config.FAIL_PERCENT``. | [
"Flag",
"a",
"set",
"of",
"hosts",
"as",
"failed",
"error",
"for",
"config",
".",
"FAIL_PERCENT",
"."
] | python | train |
gholt/swiftly | swiftly/cli/context.py | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/cli/context.py#L54-L68 | def write_headers(self, fp, headers, mute=None):
"""
Convenience function to output headers in a formatted fashion
to a file-like fp, optionally muting any headers in the mute
list.
"""
if headers:
if not mute:
mute = []
fmt = '%%-%... | [
"def",
"write_headers",
"(",
"self",
",",
"fp",
",",
"headers",
",",
"mute",
"=",
"None",
")",
":",
"if",
"headers",
":",
"if",
"not",
"mute",
":",
"mute",
"=",
"[",
"]",
"fmt",
"=",
"'%%-%ds %%s\\n'",
"%",
"(",
"max",
"(",
"len",
"(",
"k",
")",
... | Convenience function to output headers in a formatted fashion
to a file-like fp, optionally muting any headers in the mute
list. | [
"Convenience",
"function",
"to",
"output",
"headers",
"in",
"a",
"formatted",
"fashion",
"to",
"a",
"file",
"-",
"like",
"fp",
"optionally",
"muting",
"any",
"headers",
"in",
"the",
"mute",
"list",
"."
] | python | test |
cmbruns/pyopenvr | src/openvr/__init__.py | https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L3614-L3628 | def performApplicationPrelaunchCheck(self, pchAppKey):
"""
Returns errors that would prevent the specified application from launching immediately. Calling this function will
cause the current scene application to quit, so only call it when you are actually about to launch something else.
... | [
"def",
"performApplicationPrelaunchCheck",
"(",
"self",
",",
"pchAppKey",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"performApplicationPrelaunchCheck",
"result",
"=",
"fn",
"(",
"pchAppKey",
")",
"return",
"result"
] | Returns errors that would prevent the specified application from launching immediately. Calling this function will
cause the current scene application to quit, so only call it when you are actually about to launch something else.
What the caller should do about these failures depends on the failure:
... | [
"Returns",
"errors",
"that",
"would",
"prevent",
"the",
"specified",
"application",
"from",
"launching",
"immediately",
".",
"Calling",
"this",
"function",
"will",
"cause",
"the",
"current",
"scene",
"application",
"to",
"quit",
"so",
"only",
"call",
"it",
"when... | python | train |
drj11/pypng | code/png.py | https://github.com/drj11/pypng/blob/b8220ca9f58e4c5bc1d507e713744fcb8c049225/code/png.py#L997-L1014 | def make_palette_chunks(palette):
"""
Create the byte sequences for a ``PLTE`` and
if necessary a ``tRNS`` chunk.
Returned as a pair (*p*, *t*).
*t* will be ``None`` if no ``tRNS`` chunk is necessary.
"""
p = bytearray()
t = bytearray()
for x in palette:
p.extend(x[0:3])
... | [
"def",
"make_palette_chunks",
"(",
"palette",
")",
":",
"p",
"=",
"bytearray",
"(",
")",
"t",
"=",
"bytearray",
"(",
")",
"for",
"x",
"in",
"palette",
":",
"p",
".",
"extend",
"(",
"x",
"[",
"0",
":",
"3",
"]",
")",
"if",
"len",
"(",
"x",
")",
... | Create the byte sequences for a ``PLTE`` and
if necessary a ``tRNS`` chunk.
Returned as a pair (*p*, *t*).
*t* will be ``None`` if no ``tRNS`` chunk is necessary. | [
"Create",
"the",
"byte",
"sequences",
"for",
"a",
"PLTE",
"and",
"if",
"necessary",
"a",
"tRNS",
"chunk",
".",
"Returned",
"as",
"a",
"pair",
"(",
"*",
"p",
"*",
"*",
"t",
"*",
")",
".",
"*",
"t",
"*",
"will",
"be",
"None",
"if",
"no",
"tRNS",
... | python | train |
casacore/python-casacore | casacore/tables/msutil.py | https://github.com/casacore/python-casacore/blob/975510861ea005f7919dd9e438b5f98a1682eebe/casacore/tables/msutil.py#L362-L429 | def msregularize(msname, newname):
""" Regularize an MS
The output MS will be such that it has the same number of baselines
for each time stamp. Where needed fully flagged rows are added.
Possibly missing rows are written into a separate MS <newname>-add.
It is concatenated with the original MS an... | [
"def",
"msregularize",
"(",
"msname",
",",
"newname",
")",
":",
"# Find out all baselines.",
"t",
"=",
"table",
"(",
"msname",
")",
"t1",
"=",
"t",
".",
"sort",
"(",
"'unique ANTENNA1,ANTENNA2'",
")",
"nadded",
"=",
"0",
"# Now iterate in time,band over the MS.",
... | Regularize an MS
The output MS will be such that it has the same number of baselines
for each time stamp. Where needed fully flagged rows are added.
Possibly missing rows are written into a separate MS <newname>-add.
It is concatenated with the original MS and sorted in order of TIME,
DATADESC_ID,... | [
"Regularize",
"an",
"MS"
] | python | train |
maas/python-libmaas | maas/client/viscera/maas.py | https://github.com/maas/python-libmaas/blob/4092c68ef7fb1753efc843569848e2bcc3415002/maas/client/viscera/maas.py#L167-L176 | async def get_upstream_dns(cls) -> list:
"""Upstream DNS server addresses.
Upstream DNS servers used to resolve domains not managed by this MAAS
(space-separated IP addresses). Only used when MAAS is running its own
DNS server. This value is used as the value of 'forwarders' in the DNS
... | [
"async",
"def",
"get_upstream_dns",
"(",
"cls",
")",
"->",
"list",
":",
"data",
"=",
"await",
"cls",
".",
"get_config",
"(",
"\"upstream_dns\"",
")",
"return",
"[",
"]",
"if",
"data",
"is",
"None",
"else",
"re",
".",
"split",
"(",
"r'[,\\s]+'",
",",
"d... | Upstream DNS server addresses.
Upstream DNS servers used to resolve domains not managed by this MAAS
(space-separated IP addresses). Only used when MAAS is running its own
DNS server. This value is used as the value of 'forwarders' in the DNS
server config. | [
"Upstream",
"DNS",
"server",
"addresses",
"."
] | python | train |
pantsbuild/pex | pex/finders.py | https://github.com/pantsbuild/pex/blob/87b2129d860250d3b9edce75b9cb62f9789ee521/pex/finders.py#L228-L234 | def get_script_from_egg(name, dist):
"""Returns location, content of script in distribution or (None, None) if not there."""
if dist.metadata_isdir('scripts') and name in dist.metadata_listdir('scripts'):
return (
os.path.join(dist.egg_info, 'scripts', name),
dist.get_metadata('scripts/%s' % nam... | [
"def",
"get_script_from_egg",
"(",
"name",
",",
"dist",
")",
":",
"if",
"dist",
".",
"metadata_isdir",
"(",
"'scripts'",
")",
"and",
"name",
"in",
"dist",
".",
"metadata_listdir",
"(",
"'scripts'",
")",
":",
"return",
"(",
"os",
".",
"path",
".",
"join",... | Returns location, content of script in distribution or (None, None) if not there. | [
"Returns",
"location",
"content",
"of",
"script",
"in",
"distribution",
"or",
"(",
"None",
"None",
")",
"if",
"not",
"there",
"."
] | python | train |
ElevenPaths/AtomShields | atomshields/scanner.py | https://github.com/ElevenPaths/AtomShields/blob/e75f25393b4a7a315ec96bf9b8e654cb2200866a/atomshields/scanner.py#L419-L448 | def _getClassInstance(path, args=None):
"""
Returns a class instance from a .py file.
Args:
path (str): Absolute path to .py file
args (dict): Arguments passed via class constructor
Returns:
object: Class instance or None
"""
if not path.endswith(".py"):
return None
if args is None:
args... | [
"def",
"_getClassInstance",
"(",
"path",
",",
"args",
"=",
"None",
")",
":",
"if",
"not",
"path",
".",
"endswith",
"(",
"\".py\"",
")",
":",
"return",
"None",
"if",
"args",
"is",
"None",
":",
"args",
"=",
"{",
"}",
"classname",
"=",
"AtomShieldsScanner... | Returns a class instance from a .py file.
Args:
path (str): Absolute path to .py file
args (dict): Arguments passed via class constructor
Returns:
object: Class instance or None | [
"Returns",
"a",
"class",
"instance",
"from",
"a",
".",
"py",
"file",
"."
] | python | valid |
shoeffner/cvloop | tools/create_functions_ipynb.py | https://github.com/shoeffner/cvloop/blob/3ddd311e9b679d16c8fd36779931380374de343c/tools/create_functions_ipynb.py#L27-L34 | def is_mod_class(mod, cls):
"""Checks if a class in a module was declared in that module.
Args:
mod: the module
cls: the class
"""
return inspect.isclass(cls) and inspect.getmodule(cls) == mod | [
"def",
"is_mod_class",
"(",
"mod",
",",
"cls",
")",
":",
"return",
"inspect",
".",
"isclass",
"(",
"cls",
")",
"and",
"inspect",
".",
"getmodule",
"(",
"cls",
")",
"==",
"mod"
] | Checks if a class in a module was declared in that module.
Args:
mod: the module
cls: the class | [
"Checks",
"if",
"a",
"class",
"in",
"a",
"module",
"was",
"declared",
"in",
"that",
"module",
"."
] | python | train |
dossier/dossier.label | dossier/label/relation_label.py | https://github.com/dossier/dossier.label/blob/d445e56b02ffd91ad46b0872cfbff62b9afef7ec/dossier/label/relation_label.py#L280-L289 | def get_related_ids(self, content_id, min_strength=None):
'''Get identifiers for related identifiers.
'''
related_labels = self.get_related(content_id,
min_strength=min_strength)
related_idents = set()
for label in related_labels:
... | [
"def",
"get_related_ids",
"(",
"self",
",",
"content_id",
",",
"min_strength",
"=",
"None",
")",
":",
"related_labels",
"=",
"self",
".",
"get_related",
"(",
"content_id",
",",
"min_strength",
"=",
"min_strength",
")",
"related_idents",
"=",
"set",
"(",
")",
... | Get identifiers for related identifiers. | [
"Get",
"identifiers",
"for",
"related",
"identifiers",
"."
] | python | train |
intake/intake | intake/gui/catalog/select.py | https://github.com/intake/intake/blob/277b96bfdee39d8a3048ea5408c6d6716d568336/intake/gui/catalog/select.py#L139-L143 | def remove_selected(self, *args):
"""Remove the selected catalog - allow the passing of arbitrary
args so that buttons work. Also remove any nested catalogs."""
self.collapse_nested(self.selected)
self.remove(self.selected) | [
"def",
"remove_selected",
"(",
"self",
",",
"*",
"args",
")",
":",
"self",
".",
"collapse_nested",
"(",
"self",
".",
"selected",
")",
"self",
".",
"remove",
"(",
"self",
".",
"selected",
")"
] | Remove the selected catalog - allow the passing of arbitrary
args so that buttons work. Also remove any nested catalogs. | [
"Remove",
"the",
"selected",
"catalog",
"-",
"allow",
"the",
"passing",
"of",
"arbitrary",
"args",
"so",
"that",
"buttons",
"work",
".",
"Also",
"remove",
"any",
"nested",
"catalogs",
"."
] | python | train |
numenta/nupic | src/nupic/database/client_jobs_dao.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/database/client_jobs_dao.py#L2551-L2584 | def modelsGetFieldsForCheckpointed(self, jobID, fields):
"""
Gets fields from all models in a job that have been checkpointed. This is
used to figure out whether or not a new model should be checkpointed.
Parameters:
-----------------------------------------------------------------------
jobID:... | [
"def",
"modelsGetFieldsForCheckpointed",
"(",
"self",
",",
"jobID",
",",
"fields",
")",
":",
"assert",
"len",
"(",
"fields",
")",
">=",
"1",
",",
"\"fields is empty\"",
"# Get a database connection and cursor",
"with",
"ConnectionFactory",
".",
"get",
"(",
")",
"a... | Gets fields from all models in a job that have been checkpointed. This is
used to figure out whether or not a new model should be checkpointed.
Parameters:
-----------------------------------------------------------------------
jobID: The jobID for the models to be searched
field... | [
"Gets",
"fields",
"from",
"all",
"models",
"in",
"a",
"job",
"that",
"have",
"been",
"checkpointed",
".",
"This",
"is",
"used",
"to",
"figure",
"out",
"whether",
"or",
"not",
"a",
"new",
"model",
"should",
"be",
"checkpointed",
"."
] | python | valid |
mikejarrett/pipcheck | pipcheck/checker.py | https://github.com/mikejarrett/pipcheck/blob/2ff47b9fd8914e1764c6e659ef39b77c1b1a12ad/pipcheck/checker.py#L122-L170 | def _get_environment_updates(self, display_all_distributions=False):
"""
Check all pacakges installed in the environment to see if there are
any updates availalble.
Args:
display_all_distributions (bool): Return distribution even if it is
up-to-date. Defaults... | [
"def",
"_get_environment_updates",
"(",
"self",
",",
"display_all_distributions",
"=",
"False",
")",
":",
"updates",
"=",
"[",
"]",
"for",
"distribution",
"in",
"self",
".",
"pip",
".",
"get_installed_distributions",
"(",
")",
":",
"versions",
"=",
"self",
"."... | Check all pacakges installed in the environment to see if there are
any updates availalble.
Args:
display_all_distributions (bool): Return distribution even if it is
up-to-date. Defaults to ``False``.
Returns:
list: A list of Update objects ordered based... | [
"Check",
"all",
"pacakges",
"installed",
"in",
"the",
"environment",
"to",
"see",
"if",
"there",
"are",
"any",
"updates",
"availalble",
"."
] | python | train |
PMBio/limix-backup | limix/mtSet/mtset.py | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/mtSet/mtset.py#L275-L285 | def getVariances(self):
"""
get variances
"""
var = []
var.append(self.Cr.K().diagonal())
if self.bgRE:
var.append(self.Cg.K().diagonal())
var.append(self.Cn.K().diagonal())
var = sp.array(var)
return var | [
"def",
"getVariances",
"(",
"self",
")",
":",
"var",
"=",
"[",
"]",
"var",
".",
"append",
"(",
"self",
".",
"Cr",
".",
"K",
"(",
")",
".",
"diagonal",
"(",
")",
")",
"if",
"self",
".",
"bgRE",
":",
"var",
".",
"append",
"(",
"self",
".",
"Cg"... | get variances | [
"get",
"variances"
] | python | train |
dcos/shakedown | shakedown/dcos/__init__.py | https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/__init__.py#L94-L104 | def dcos_version():
"""Return the version of the running cluster.
:return: DC/OS cluster version as a string
"""
url = _gen_url('dcos-metadata/dcos-version.json')
response = dcos.http.request('get', url)
if response.status_code == 200:
return response.json()['version']
else:
... | [
"def",
"dcos_version",
"(",
")",
":",
"url",
"=",
"_gen_url",
"(",
"'dcos-metadata/dcos-version.json'",
")",
"response",
"=",
"dcos",
".",
"http",
".",
"request",
"(",
"'get'",
",",
"url",
")",
"if",
"response",
".",
"status_code",
"==",
"200",
":",
"retur... | Return the version of the running cluster.
:return: DC/OS cluster version as a string | [
"Return",
"the",
"version",
"of",
"the",
"running",
"cluster",
".",
":",
"return",
":",
"DC",
"/",
"OS",
"cluster",
"version",
"as",
"a",
"string"
] | python | train |
pandas-dev/pandas | pandas/core/indexing.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L270-L295 | def _has_valid_positional_setitem_indexer(self, indexer):
""" validate that an positional indexer cannot enlarge its target
will raise if needed, does not modify the indexer externally
"""
if isinstance(indexer, dict):
raise IndexError("{0} cannot enlarge its target object"
... | [
"def",
"_has_valid_positional_setitem_indexer",
"(",
"self",
",",
"indexer",
")",
":",
"if",
"isinstance",
"(",
"indexer",
",",
"dict",
")",
":",
"raise",
"IndexError",
"(",
"\"{0} cannot enlarge its target object\"",
".",
"format",
"(",
"self",
".",
"name",
")",
... | validate that an positional indexer cannot enlarge its target
will raise if needed, does not modify the indexer externally | [
"validate",
"that",
"an",
"positional",
"indexer",
"cannot",
"enlarge",
"its",
"target",
"will",
"raise",
"if",
"needed",
"does",
"not",
"modify",
"the",
"indexer",
"externally"
] | python | train |
pycontribs/pyrax | pyrax/autoscale.py | https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/autoscale.py#L731-L767 | def _resolve_lbs(load_balancers):
"""
Takes either a single LB reference or a list of references and returns
the dictionary required for creating a Scaling Group.
References can be either a dict that matches the structure required by
the autoscale API, a CloudLoadBalancer instan... | [
"def",
"_resolve_lbs",
"(",
"load_balancers",
")",
":",
"lb_args",
"=",
"[",
"]",
"if",
"not",
"isinstance",
"(",
"load_balancers",
",",
"list",
")",
":",
"lbs",
"=",
"[",
"load_balancers",
"]",
"else",
":",
"lbs",
"=",
"load_balancers",
"for",
"lb",
"in... | Takes either a single LB reference or a list of references and returns
the dictionary required for creating a Scaling Group.
References can be either a dict that matches the structure required by
the autoscale API, a CloudLoadBalancer instance, or the ID of the load
balancer. | [
"Takes",
"either",
"a",
"single",
"LB",
"reference",
"or",
"a",
"list",
"of",
"references",
"and",
"returns",
"the",
"dictionary",
"required",
"for",
"creating",
"a",
"Scaling",
"Group",
"."
] | python | train |
datacamp/protowhat | protowhat/checks/check_funcs.py | https://github.com/datacamp/protowhat/blob/a392b4e51e07a2e50e7b7f6ad918b3f5cbb63edc/protowhat/checks/check_funcs.py#L247-L319 | def has_equal_ast(
state,
incorrect_msg="Check the {ast_path}. {extra}",
sql=None,
start=["expression", "subquery", "sql_script"][0],
exact=None,
):
"""Test whether the student and solution code have identical AST representations
Args:
state: State instance describing student and so... | [
"def",
"has_equal_ast",
"(",
"state",
",",
"incorrect_msg",
"=",
"\"Check the {ast_path}. {extra}\"",
",",
"sql",
"=",
"None",
",",
"start",
"=",
"[",
"\"expression\"",
",",
"\"subquery\"",
",",
"\"sql_script\"",
"]",
"[",
"0",
"]",
",",
"exact",
"=",
"None",
... | Test whether the student and solution code have identical AST representations
Args:
state: State instance describing student and solution code. Can be omitted if used with Ex().
incorrect_msg: feedback message if student and solution ASTs don't match
sql : optional code to use instead of t... | [
"Test",
"whether",
"the",
"student",
"and",
"solution",
"code",
"have",
"identical",
"AST",
"representations"
] | python | train |
ValvePython/steam | steam/guard.py | https://github.com/ValvePython/steam/blob/2de1364c47598410b572114e6129eab8fff71d5b/steam/guard.py#L87-L100 | def get_time(self):
"""
:return: Steam aligned timestamp
:rtype: int
"""
if (self.steam_time_offset is None
or (self.align_time_every and (time() - self._offset_last_check) > self.align_time_every)
):
self.steam_time_offset = get_time_offset()
... | [
"def",
"get_time",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"steam_time_offset",
"is",
"None",
"or",
"(",
"self",
".",
"align_time_every",
"and",
"(",
"time",
"(",
")",
"-",
"self",
".",
"_offset_last_check",
")",
">",
"self",
".",
"align_time_ever... | :return: Steam aligned timestamp
:rtype: int | [
":",
"return",
":",
"Steam",
"aligned",
"timestamp",
":",
"rtype",
":",
"int"
] | python | train |
openstack/networking-hyperv | networking_hyperv/neutron/agent/hnv_neutron_agent.py | https://github.com/openstack/networking-hyperv/blob/7a89306ab0586c95b99debb44d898f70834508b9/networking_hyperv/neutron/agent/hnv_neutron_agent.py#L57-L68 | def _provision_network(self, port_id, net_uuid, network_type,
physical_network, segmentation_id):
"""Provision the network with the received information."""
LOG.info("Provisioning network %s", net_uuid)
vswitch_name = self._get_vswitch_name(network_type, physical_netw... | [
"def",
"_provision_network",
"(",
"self",
",",
"port_id",
",",
"net_uuid",
",",
"network_type",
",",
"physical_network",
",",
"segmentation_id",
")",
":",
"LOG",
".",
"info",
"(",
"\"Provisioning network %s\"",
",",
"net_uuid",
")",
"vswitch_name",
"=",
"self",
... | Provision the network with the received information. | [
"Provision",
"the",
"network",
"with",
"the",
"received",
"information",
"."
] | python | train |
edx/edx-enterprise | integrated_channels/sap_success_factors/migrations/0014_drop_historical_table.py | https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/integrated_channels/sap_success_factors/migrations/0014_drop_historical_table.py#L7-L15 | def dropHistoricalTable(apps, schema_editor):
"""
Drops the historical sap_success_factors table named herein.
"""
table_name = 'sap_success_factors_historicalsapsuccessfactorsenterprisecus80ad'
if table_name in connection.introspection.table_names():
migrations.DeleteModel(
name... | [
"def",
"dropHistoricalTable",
"(",
"apps",
",",
"schema_editor",
")",
":",
"table_name",
"=",
"'sap_success_factors_historicalsapsuccessfactorsenterprisecus80ad'",
"if",
"table_name",
"in",
"connection",
".",
"introspection",
".",
"table_names",
"(",
")",
":",
"migrations... | Drops the historical sap_success_factors table named herein. | [
"Drops",
"the",
"historical",
"sap_success_factors",
"table",
"named",
"herein",
"."
] | python | valid |
sdispater/eloquent | eloquent/query/grammars/mysql_grammar.py | https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/query/grammars/mysql_grammar.py#L23-L38 | def compile_select(self, query):
"""
Compile a select query into SQL
:param query: A QueryBuilder instance
:type query: QueryBuilder
:return: The compiled sql
:rtype: str
"""
sql = super(MySqlQueryGrammar, self).compile_select(query)
if query.un... | [
"def",
"compile_select",
"(",
"self",
",",
"query",
")",
":",
"sql",
"=",
"super",
"(",
"MySqlQueryGrammar",
",",
"self",
")",
".",
"compile_select",
"(",
"query",
")",
"if",
"query",
".",
"unions",
":",
"sql",
"=",
"'(%s) %s'",
"%",
"(",
"sql",
",",
... | Compile a select query into SQL
:param query: A QueryBuilder instance
:type query: QueryBuilder
:return: The compiled sql
:rtype: str | [
"Compile",
"a",
"select",
"query",
"into",
"SQL"
] | python | train |
mongodb/mongo-python-driver | pymongo/message.py | https://github.com/mongodb/mongo-python-driver/blob/c29c21449e3aae74154207058cf85fd94018d4cd/pymongo/message.py#L1469-L1482 | def unpack_response(self, cursor_id=None,
codec_options=_UNICODE_REPLACE_CODEC_OPTIONS,
user_fields=None, legacy_response=False):
"""Unpack a OP_MSG command response.
:Parameters:
- `cursor_id` (optional): Ignored, for compatibility with _OpRepl... | [
"def",
"unpack_response",
"(",
"self",
",",
"cursor_id",
"=",
"None",
",",
"codec_options",
"=",
"_UNICODE_REPLACE_CODEC_OPTIONS",
",",
"user_fields",
"=",
"None",
",",
"legacy_response",
"=",
"False",
")",
":",
"# If _OpMsg is in-use, this cannot be a legacy response.",
... | Unpack a OP_MSG command response.
:Parameters:
- `cursor_id` (optional): Ignored, for compatibility with _OpReply.
- `codec_options` (optional): an instance of
:class:`~bson.codec_options.CodecOptions` | [
"Unpack",
"a",
"OP_MSG",
"command",
"response",
"."
] | python | train |
COALAIP/pycoalaip | coalaip/model_validators.py | https://github.com/COALAIP/pycoalaip/blob/cecc8f6ff4733f0525fafcee63647753e832f0be/coalaip/model_validators.py#L45-L56 | def is_creation_model(instance, attribute, value):
"""Must include at least a ``name`` key."""
creation_name = value.get('name')
if not isinstance(creation_name, str):
instance_name = instance.__class__.__name__
err_str = ("'name' must be given as a string in the '{attr}' "
... | [
"def",
"is_creation_model",
"(",
"instance",
",",
"attribute",
",",
"value",
")",
":",
"creation_name",
"=",
"value",
".",
"get",
"(",
"'name'",
")",
"if",
"not",
"isinstance",
"(",
"creation_name",
",",
"str",
")",
":",
"instance_name",
"=",
"instance",
"... | Must include at least a ``name`` key. | [
"Must",
"include",
"at",
"least",
"a",
"name",
"key",
"."
] | python | train |
LPgenerator/django-db-mailer | dbmail/providers/boxcar/push.py | https://github.com/LPgenerator/django-db-mailer/blob/217a73c21ba5c6b68738f74b2c55a6dd2c1afe35/dbmail/providers/boxcar/push.py#L19-L48 | def send(token, title, **kwargs):
"""
Site: https://boxcar.io/
API: http://help.boxcar.io/knowledgebase/topics/48115-boxcar-api
Desc: Best app for system administrators
"""
headers = {
"Content-type": "application/x-www-form-urlencoded",
"User-Agent": "DBMail/%s" % get_version(),... | [
"def",
"send",
"(",
"token",
",",
"title",
",",
"*",
"*",
"kwargs",
")",
":",
"headers",
"=",
"{",
"\"Content-type\"",
":",
"\"application/x-www-form-urlencoded\"",
",",
"\"User-Agent\"",
":",
"\"DBMail/%s\"",
"%",
"get_version",
"(",
")",
",",
"}",
"data",
... | Site: https://boxcar.io/
API: http://help.boxcar.io/knowledgebase/topics/48115-boxcar-api
Desc: Best app for system administrators | [
"Site",
":",
"https",
":",
"//",
"boxcar",
".",
"io",
"/",
"API",
":",
"http",
":",
"//",
"help",
".",
"boxcar",
".",
"io",
"/",
"knowledgebase",
"/",
"topics",
"/",
"48115",
"-",
"boxcar",
"-",
"api",
"Desc",
":",
"Best",
"app",
"for",
"system",
... | python | train |
spyder-ide/spyder | spyder/plugins/help/plugin.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/plugin.py#L448-L452 | def show_plain_text(self, text):
"""Show text in plain mode"""
self.switch_to_plugin()
self.switch_to_plain_text()
self.set_plain_text(text, is_code=False) | [
"def",
"show_plain_text",
"(",
"self",
",",
"text",
")",
":",
"self",
".",
"switch_to_plugin",
"(",
")",
"self",
".",
"switch_to_plain_text",
"(",
")",
"self",
".",
"set_plain_text",
"(",
"text",
",",
"is_code",
"=",
"False",
")"
] | Show text in plain mode | [
"Show",
"text",
"in",
"plain",
"mode"
] | python | train |
gem/oq-engine | openquake/hmtk/faults/fault_models.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/faults/fault_models.py#L327-L363 | def _generate_branching_index(self):
'''
Generates a branching index (i.e. a list indicating the number of
branches in each branching level. Current branching levels are:
1) Slip
2) MSR
3) Shear Modulus
4) DLR
5) MSR_Sigma
6) Config
:retur... | [
"def",
"_generate_branching_index",
"(",
"self",
")",
":",
"branch_count",
"=",
"np",
".",
"array",
"(",
"[",
"len",
"(",
"self",
".",
"slip",
")",
",",
"len",
"(",
"self",
".",
"msr",
")",
",",
"len",
"(",
"self",
".",
"shear_modulus",
")",
",",
"... | Generates a branching index (i.e. a list indicating the number of
branches in each branching level. Current branching levels are:
1) Slip
2) MSR
3) Shear Modulus
4) DLR
5) MSR_Sigma
6) Config
:returns:
* branch_index - A 2-D numpy.ndarray wher... | [
"Generates",
"a",
"branching",
"index",
"(",
"i",
".",
"e",
".",
"a",
"list",
"indicating",
"the",
"number",
"of",
"branches",
"in",
"each",
"branching",
"level",
".",
"Current",
"branching",
"levels",
"are",
":",
"1",
")",
"Slip",
"2",
")",
"MSR",
"3"... | python | train |
jazzband/django-ddp | dddp/accounts/ddp.py | https://github.com/jazzband/django-ddp/blob/1e1954b06fe140346acea43582515991685e4e01/dddp/accounts/ddp.py#L513-L533 | def change_password(self, old_password, new_password):
"""Change password."""
try:
user = this.user
except self.user_model.DoesNotExist:
self.auth_failed()
user = auth.authenticate(
username=user.get_username(),
password=self.get_password(o... | [
"def",
"change_password",
"(",
"self",
",",
"old_password",
",",
"new_password",
")",
":",
"try",
":",
"user",
"=",
"this",
".",
"user",
"except",
"self",
".",
"user_model",
".",
"DoesNotExist",
":",
"self",
".",
"auth_failed",
"(",
")",
"user",
"=",
"au... | Change password. | [
"Change",
"password",
"."
] | python | test |
terrycain/aioboto3 | aioboto3/s3/inject.py | https://github.com/terrycain/aioboto3/blob/0fd192175461f7bb192f3ed9a872591caf8474ac/aioboto3/s3/inject.py#L17-L30 | async def download_file(self, Bucket, Key, Filename, ExtraArgs=None, Callback=None, Config=None):
"""Download an S3 object to a file.
Usage::
import boto3
s3 = boto3.resource('s3')
s3.meta.client.download_file('mybucket', 'hello.txt', '/tmp/hello.txt')
Similar behavior as S3Transf... | [
"async",
"def",
"download_file",
"(",
"self",
",",
"Bucket",
",",
"Key",
",",
"Filename",
",",
"ExtraArgs",
"=",
"None",
",",
"Callback",
"=",
"None",
",",
"Config",
"=",
"None",
")",
":",
"with",
"open",
"(",
"Filename",
",",
"'wb'",
")",
"as",
"ope... | Download an S3 object to a file.
Usage::
import boto3
s3 = boto3.resource('s3')
s3.meta.client.download_file('mybucket', 'hello.txt', '/tmp/hello.txt')
Similar behavior as S3Transfer's download_file() method,
except that parameters are capitalized. | [
"Download",
"an",
"S3",
"object",
"to",
"a",
"file",
"."
] | python | train |
mschwager/cohesion | lib/cohesion/filesystem.py | https://github.com/mschwager/cohesion/blob/b242ad59770940f3a0904931f27755ede009f491/lib/cohesion/filesystem.py#L21-L29 | def recursively_get_files_from_directory(directory):
"""
Return all filenames under recursively found in a directory
"""
return [
os.path.join(root, filename)
for root, directories, filenames in os.walk(directory)
for filename in filenames
] | [
"def",
"recursively_get_files_from_directory",
"(",
"directory",
")",
":",
"return",
"[",
"os",
".",
"path",
".",
"join",
"(",
"root",
",",
"filename",
")",
"for",
"root",
",",
"directories",
",",
"filenames",
"in",
"os",
".",
"walk",
"(",
"directory",
")"... | Return all filenames under recursively found in a directory | [
"Return",
"all",
"filenames",
"under",
"recursively",
"found",
"in",
"a",
"directory"
] | python | train |
ShawnClake/Apitax | apitax/ah/api/controllers/migrations/developers_controller.py | https://github.com/ShawnClake/Apitax/blob/2eb9c6990d4088b2503c7f13c2a76f8e59606e6d/apitax/ah/api/controllers/migrations/developers_controller.py#L54-L66 | def rename_script(rename=None): # noqa: E501
"""Rename a script
Rename a script # noqa: E501
:param rename: The data needed to save this script
:type rename: dict | bytes
:rtype: Response
"""
if connexion.request.is_json:
rename = Rename.from_dict(connexion.request.get_json()) #... | [
"def",
"rename_script",
"(",
"rename",
"=",
"None",
")",
":",
"# noqa: E501",
"if",
"connexion",
".",
"request",
".",
"is_json",
":",
"rename",
"=",
"Rename",
".",
"from_dict",
"(",
"connexion",
".",
"request",
".",
"get_json",
"(",
")",
")",
"# noqa: E501... | Rename a script
Rename a script # noqa: E501
:param rename: The data needed to save this script
:type rename: dict | bytes
:rtype: Response | [
"Rename",
"a",
"script"
] | python | train |
onicagroup/runway | runway/commands/modules_command.py | https://github.com/onicagroup/runway/blob/3f3549ec3bf6e39b9f27d9738a1847f3a4369e7f/runway/commands/modules_command.py#L177-L193 | def validate_account_id(sts_client, account_id):
"""Exit if get_caller_identity doesn't match account_id."""
resp = sts_client.get_caller_identity()
if 'Account' in resp:
if resp['Account'] == account_id:
LOGGER.info('Verified current AWS account matches required '
... | [
"def",
"validate_account_id",
"(",
"sts_client",
",",
"account_id",
")",
":",
"resp",
"=",
"sts_client",
".",
"get_caller_identity",
"(",
")",
"if",
"'Account'",
"in",
"resp",
":",
"if",
"resp",
"[",
"'Account'",
"]",
"==",
"account_id",
":",
"LOGGER",
".",
... | Exit if get_caller_identity doesn't match account_id. | [
"Exit",
"if",
"get_caller_identity",
"doesn",
"t",
"match",
"account_id",
"."
] | python | train |
Dallinger/Dallinger | dallinger/heroku/tools.py | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/heroku/tools.py#L61-L66 | def all_apps(self):
"""Capture a backup of the app."""
cmd = ["heroku", "apps", "--json"]
if self.team:
cmd.extend(["--team", self.team])
return json.loads(self._result(cmd)) | [
"def",
"all_apps",
"(",
"self",
")",
":",
"cmd",
"=",
"[",
"\"heroku\"",
",",
"\"apps\"",
",",
"\"--json\"",
"]",
"if",
"self",
".",
"team",
":",
"cmd",
".",
"extend",
"(",
"[",
"\"--team\"",
",",
"self",
".",
"team",
"]",
")",
"return",
"json",
".... | Capture a backup of the app. | [
"Capture",
"a",
"backup",
"of",
"the",
"app",
"."
] | python | train |
refenv/cijoe | deprecated/modules/cij/liblight.py | https://github.com/refenv/cijoe/blob/21d7b2ed4ff68e0a1457e7df2db27f6334f1a379/deprecated/modules/cij/liblight.py#L75-L80 | def get_chunk_meta_item(self, chunk_meta, grp, pug, chk):
"""Get item of chunk meta table"""
num_chk = self.envs["NUM_CHK"]
num_pu = self.envs["NUM_PU"]
index = grp * num_pu * num_chk + pug * num_chk + chk
return chunk_meta[index] | [
"def",
"get_chunk_meta_item",
"(",
"self",
",",
"chunk_meta",
",",
"grp",
",",
"pug",
",",
"chk",
")",
":",
"num_chk",
"=",
"self",
".",
"envs",
"[",
"\"NUM_CHK\"",
"]",
"num_pu",
"=",
"self",
".",
"envs",
"[",
"\"NUM_PU\"",
"]",
"index",
"=",
"grp",
... | Get item of chunk meta table | [
"Get",
"item",
"of",
"chunk",
"meta",
"table"
] | python | valid |
acorg/dark-matter | bin/fasta-identity-table.py | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/bin/fasta-identity-table.py#L111-L179 | def explanation(matchAmbiguous, concise, showLengths, showGaps, showNs):
"""
Make an explanation of the output HTML table.
@param matchAmbiguous: If C{True}, count ambiguous nucleotides that are
possibly correct as actually being correct. Otherwise, we are strict
and insist that only non-am... | [
"def",
"explanation",
"(",
"matchAmbiguous",
",",
"concise",
",",
"showLengths",
",",
"showGaps",
",",
"showNs",
")",
":",
"result",
"=",
"[",
"\"\"\"\n<h1>Sequence versus sequence identity table</h1>\n\n<p>\n\nThe table cells below show the nucleotide identity fraction for the seq... | Make an explanation of the output HTML table.
@param matchAmbiguous: If C{True}, count ambiguous nucleotides that are
possibly correct as actually being correct. Otherwise, we are strict
and insist that only non-ambiguous nucleotides can contribute to the
matching nucleotide count.
@par... | [
"Make",
"an",
"explanation",
"of",
"the",
"output",
"HTML",
"table",
"."
] | python | train |
bbiskup/purkinje-messages | purkinje_messages/message.py | https://github.com/bbiskup/purkinje-messages/blob/ba4217d993a86fd882bcf73d206d2910e65316dd/purkinje_messages/message.py#L141-L152 | def register_eventclass(event_id):
"""Decorator for registering event classes for parsing
"""
def register(cls):
if not issubclass(cls, Event):
raise MessageException(('Cannot register a class that'
' is not a subclass of Event'))
EVENT_REGISTR... | [
"def",
"register_eventclass",
"(",
"event_id",
")",
":",
"def",
"register",
"(",
"cls",
")",
":",
"if",
"not",
"issubclass",
"(",
"cls",
",",
"Event",
")",
":",
"raise",
"MessageException",
"(",
"(",
"'Cannot register a class that'",
"' is not a subclass of Event'... | Decorator for registering event classes for parsing | [
"Decorator",
"for",
"registering",
"event",
"classes",
"for",
"parsing"
] | python | train |
rikrd/inspire | inspirespeech/__init__.py | https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/__init__.py#L373-L417 | def full_task(self, token_id, presented_pronunciation, pronunciation, pronunciation_probability,
warn=True, default=True):
"""Provide the prediction of the full task.
This function is used to predict the probability of a given pronunciation being reported for a given token.
:... | [
"def",
"full_task",
"(",
"self",
",",
"token_id",
",",
"presented_pronunciation",
",",
"pronunciation",
",",
"pronunciation_probability",
",",
"warn",
"=",
"True",
",",
"default",
"=",
"True",
")",
":",
"if",
"pronunciation_probability",
"is",
"not",
"None",
"an... | Provide the prediction of the full task.
This function is used to predict the probability of a given pronunciation being reported for a given token.
:param token_id: The token for which the prediction is provided
:param pronunciation: The pronunciation for which the prediction is being made (a... | [
"Provide",
"the",
"prediction",
"of",
"the",
"full",
"task",
"."
] | python | train |
spatialaudio/python-pa-ringbuffer | src/pa_ringbuffer.py | https://github.com/spatialaudio/python-pa-ringbuffer/blob/b4a5eaa9b53a437c05d196ed59e1791db159e4b0/src/pa_ringbuffer.py#L156-L175 | def read(self, size=-1):
"""Read data from the ring buffer into a new buffer.
This advances the read index after reading;
calling :meth:`advance_read_index` is *not* necessary.
:param size: The number of elements to be read.
If not specified, all available elements are read... | [
"def",
"read",
"(",
"self",
",",
"size",
"=",
"-",
"1",
")",
":",
"if",
"size",
"<",
"0",
":",
"size",
"=",
"self",
".",
"read_available",
"data",
"=",
"self",
".",
"_ffi",
".",
"new",
"(",
"'unsigned char[]'",
",",
"size",
"*",
"self",
".",
"ele... | Read data from the ring buffer into a new buffer.
This advances the read index after reading;
calling :meth:`advance_read_index` is *not* necessary.
:param size: The number of elements to be read.
If not specified, all available elements are read.
:type size: int, optional
... | [
"Read",
"data",
"from",
"the",
"ring",
"buffer",
"into",
"a",
"new",
"buffer",
"."
] | python | train |
funilrys/PyFunceble | PyFunceble/config.py | https://github.com/funilrys/PyFunceble/blob/cdf69cbde120199171f7158e1c33635753e6e2f5/PyFunceble/config.py#L195-L225 | def _set_path_to_configs(cls, path_to_config):
"""
Set the paths to the configuration files.
:param path_to_config: The possible path to the config to load.
:type path_to_config: str
:return:
The path to the config to read (0), the path to the default
co... | [
"def",
"_set_path_to_configs",
"(",
"cls",
",",
"path_to_config",
")",
":",
"if",
"not",
"path_to_config",
".",
"endswith",
"(",
"PyFunceble",
".",
"directory_separator",
")",
":",
"# The path to the config does not ends with the directory separator.",
"# We initiate the defa... | Set the paths to the configuration files.
:param path_to_config: The possible path to the config to load.
:type path_to_config: str
:return:
The path to the config to read (0), the path to the default
configuration to read as fallback.(1)
:rtype: tuple | [
"Set",
"the",
"paths",
"to",
"the",
"configuration",
"files",
"."
] | python | test |
myint/language-check | setup.py | https://github.com/myint/language-check/blob/58e419833ef28a9193fcaa21193616a8a14504a9/setup.py#L363-L388 | def run_3to2(args=None):
"""Convert Python files using lib3to2."""
args = BASE_ARGS_3TO2 if args is None else BASE_ARGS_3TO2 + args
try:
proc = subprocess.Popen(['3to2'] + args, stderr=subprocess.PIPE)
except OSError:
for path in glob.glob('*.egg'):
if os.path.isdir(path) and... | [
"def",
"run_3to2",
"(",
"args",
"=",
"None",
")",
":",
"args",
"=",
"BASE_ARGS_3TO2",
"if",
"args",
"is",
"None",
"else",
"BASE_ARGS_3TO2",
"+",
"args",
"try",
":",
"proc",
"=",
"subprocess",
".",
"Popen",
"(",
"[",
"'3to2'",
"]",
"+",
"args",
",",
"... | Convert Python files using lib3to2. | [
"Convert",
"Python",
"files",
"using",
"lib3to2",
"."
] | python | valid |
theislab/scvelo | scvelo/tools/velocity_confidence.py | https://github.com/theislab/scvelo/blob/c7a96d70edfe705e86bf364434a9527d4fd8df11/scvelo/tools/velocity_confidence.py#L10-L56 | def velocity_confidence(data, vkey='velocity', copy=False):
"""Computes confidences of velocities.
Arguments
---------
data: :class:`~anndata.AnnData`
Annotated data matrix.
vkey: `str` (default: `'velocity'`)
Name of velocity estimates to be used.
copy: `bool` (default: `False`... | [
"def",
"velocity_confidence",
"(",
"data",
",",
"vkey",
"=",
"'velocity'",
",",
"copy",
"=",
"False",
")",
":",
"adata",
"=",
"data",
".",
"copy",
"(",
")",
"if",
"copy",
"else",
"data",
"if",
"vkey",
"not",
"in",
"adata",
".",
"layers",
".",
"keys",... | Computes confidences of velocities.
Arguments
---------
data: :class:`~anndata.AnnData`
Annotated data matrix.
vkey: `str` (default: `'velocity'`)
Name of velocity estimates to be used.
copy: `bool` (default: `False`)
Return a copy instead of writing to adata.
Returns
... | [
"Computes",
"confidences",
"of",
"velocities",
"."
] | python | train |
heikomuller/sco-datastore | scodata/image.py | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/image.py#L806-L828 | def create_object(self, name, image_sets):
"""Create a prediction image set list.
Parameters
----------
name : string
User-provided name for the image group.
image_sets : list(PredictionImageSet)
List of prediction image sets
Returns
----... | [
"def",
"create_object",
"(",
"self",
",",
"name",
",",
"image_sets",
")",
":",
"# Create a new object identifier",
"identifier",
"=",
"str",
"(",
"uuid",
".",
"uuid4",
"(",
")",
")",
".",
"replace",
"(",
"'-'",
",",
"''",
")",
"properties",
"=",
"{",
"da... | Create a prediction image set list.
Parameters
----------
name : string
User-provided name for the image group.
image_sets : list(PredictionImageSet)
List of prediction image sets
Returns
-------
PredictionImageSetHandle
Objec... | [
"Create",
"a",
"prediction",
"image",
"set",
"list",
"."
] | python | train |
markuskiller/textblob-de | textblob_de/ext/_pattern/text/__init__.py | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1699-L1707 | def TENSES(self):
""" Yields a list of tenses for this language, excluding negations.
Each tense is a (tense, person, number, mood, aspect)-tuple.
"""
a = set(TENSES[id] for id in self._format)
a = a.union(set(TENSES[id] for id in self._default.keys()))
a = a.union(se... | [
"def",
"TENSES",
"(",
"self",
")",
":",
"a",
"=",
"set",
"(",
"TENSES",
"[",
"id",
"]",
"for",
"id",
"in",
"self",
".",
"_format",
")",
"a",
"=",
"a",
".",
"union",
"(",
"set",
"(",
"TENSES",
"[",
"id",
"]",
"for",
"id",
"in",
"self",
".",
... | Yields a list of tenses for this language, excluding negations.
Each tense is a (tense, person, number, mood, aspect)-tuple. | [
"Yields",
"a",
"list",
"of",
"tenses",
"for",
"this",
"language",
"excluding",
"negations",
".",
"Each",
"tense",
"is",
"a",
"(",
"tense",
"person",
"number",
"mood",
"aspect",
")",
"-",
"tuple",
"."
] | python | train |
CiscoTestAutomation/yang | ncdiff/src/yang/ncdiff/model.py | https://github.com/CiscoTestAutomation/yang/blob/c70ec5ac5a91f276c4060009203770ece92e76b4/ncdiff/src/yang/ncdiff/model.py#L813-L836 | def get_diff_str(self, element, length):
'''get_diff_str
High-level api: Produce a string that indicates the difference between
two models.
Parameters
----------
element : `Element`
A node in model tree.
length : `int`
String length tha... | [
"def",
"get_diff_str",
"(",
"self",
",",
"element",
",",
"length",
")",
":",
"spaces",
"=",
"' '",
"*",
"(",
"self",
".",
"get_width",
"(",
"element",
")",
"-",
"length",
")",
"return",
"spaces",
"+",
"element",
".",
"get",
"(",
"'diff'",
")"
] | get_diff_str
High-level api: Produce a string that indicates the difference between
two models.
Parameters
----------
element : `Element`
A node in model tree.
length : `int`
String length that has been consumed.
Returns
------... | [
"get_diff_str"
] | python | train |
mattja/nsim | nsim/analysesN/phase.py | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analysesN/phase.py#L42-L44 | def circmean(dts, axis=2):
"""Circular mean phase"""
return np.exp(1.0j * dts).mean(axis=axis).angle() | [
"def",
"circmean",
"(",
"dts",
",",
"axis",
"=",
"2",
")",
":",
"return",
"np",
".",
"exp",
"(",
"1.0j",
"*",
"dts",
")",
".",
"mean",
"(",
"axis",
"=",
"axis",
")",
".",
"angle",
"(",
")"
] | Circular mean phase | [
"Circular",
"mean",
"phase"
] | python | train |
alex-kostirin/pyatomac | atomac/ldtpd/table.py | https://github.com/alex-kostirin/pyatomac/blob/3f46f6feb4504315eec07abb18bb41be4d257aeb/atomac/ldtpd/table.py#L80-L131 | def multiselect(self, window_name, object_name, row_text_list, partial_match=False):
"""
Select multiple row
@param window_name: Window name to type in, either full name,
LDTP's name convention, or a Unix glob.
@type window_name: string
@param object_name: Object name to... | [
"def",
"multiselect",
"(",
"self",
",",
"window_name",
",",
"object_name",
",",
"row_text_list",
",",
"partial_match",
"=",
"False",
")",
":",
"object_handle",
"=",
"self",
".",
"_get_object_handle",
"(",
"window_name",
",",
"object_name",
")",
"if",
"not",
"o... | Select multiple row
@param window_name: Window name to type in, either full name,
LDTP's name convention, or a Unix glob.
@type window_name: string
@param object_name: Object name to type in, either full name,
LDTP's name convention, or a Unix glob.
@type object_name: s... | [
"Select",
"multiple",
"row"
] | python | valid |
Azure/azure-cli-extensions | src/interactive/azext_interactive/azclishell/az_completer.py | https://github.com/Azure/azure-cli-extensions/blob/3d4854205b0f0d882f688cfa12383d14506c2e35/src/interactive/azext_interactive/azclishell/az_completer.py#L191-L199 | def get_arg_name(self, param):
""" gets the argument name used in the command table for a parameter """
if self.current_command in self.cmdtab:
for arg in self.cmdtab[self.current_command].arguments:
for name in self.cmdtab[self.current_command].arguments[arg].options_list:
... | [
"def",
"get_arg_name",
"(",
"self",
",",
"param",
")",
":",
"if",
"self",
".",
"current_command",
"in",
"self",
".",
"cmdtab",
":",
"for",
"arg",
"in",
"self",
".",
"cmdtab",
"[",
"self",
".",
"current_command",
"]",
".",
"arguments",
":",
"for",
"name... | gets the argument name used in the command table for a parameter | [
"gets",
"the",
"argument",
"name",
"used",
"in",
"the",
"command",
"table",
"for",
"a",
"parameter"
] | python | train |
googledatalab/pydatalab | datalab/utils/commands/_commands.py | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/utils/commands/_commands.py#L49-L64 | def create_args(line, namespace):
""" Expand any meta-variable references in the argument list. """
args = []
# Using shlex.split handles quotes args and escape characters.
for arg in shlex.split(line):
if not arg:
continue
if arg[0] == '$':
var_name = arg[1:]
if var... | [
"def",
"create_args",
"(",
"line",
",",
"namespace",
")",
":",
"args",
"=",
"[",
"]",
"# Using shlex.split handles quotes args and escape characters.",
"for",
"arg",
"in",
"shlex",
".",
"split",
"(",
"line",
")",
":",
"if",
"not",
"arg",
":",
"continue",
"if",... | Expand any meta-variable references in the argument list. | [
"Expand",
"any",
"meta",
"-",
"variable",
"references",
"in",
"the",
"argument",
"list",
"."
] | python | train |
inveniosoftware/invenio-formatter | invenio_formatter/views.py | https://github.com/inveniosoftware/invenio-formatter/blob/aa25f36742e809f05e116b52e8255cdb362e5642/invenio_formatter/views.py#L20-L67 | def create_badge_blueprint(allowed_types):
"""Create the badge blueprint.
:param allowed_types: A list of allowed types.
:returns: A Flask blueprint.
"""
from invenio_formatter.context_processors.badges import \
generate_badge_png, generate_badge_svg
blueprint = Blueprint(
'inv... | [
"def",
"create_badge_blueprint",
"(",
"allowed_types",
")",
":",
"from",
"invenio_formatter",
".",
"context_processors",
".",
"badges",
"import",
"generate_badge_png",
",",
"generate_badge_svg",
"blueprint",
"=",
"Blueprint",
"(",
"'invenio_formatter_badges'",
",",
"__nam... | Create the badge blueprint.
:param allowed_types: A list of allowed types.
:returns: A Flask blueprint. | [
"Create",
"the",
"badge",
"blueprint",
"."
] | python | train |
peshay/tpm | tpm.py | https://github.com/peshay/tpm/blob/8e64a4d8b89d54bdd2c92d965463a7508aa3d0bc/tpm.py#L430-L436 | def create_mypassword(self, data):
"""Create my password."""
# http://teampasswordmanager.com/docs/api-my-passwords/#create_password
log.info('Create MyPassword with %s' % data)
NewID = self.post('my_passwords.json', data).get('id')
log.info('MyPassword has been created with %s' ... | [
"def",
"create_mypassword",
"(",
"self",
",",
"data",
")",
":",
"# http://teampasswordmanager.com/docs/api-my-passwords/#create_password",
"log",
".",
"info",
"(",
"'Create MyPassword with %s'",
"%",
"data",
")",
"NewID",
"=",
"self",
".",
"post",
"(",
"'my_passwords.js... | Create my password. | [
"Create",
"my",
"password",
"."
] | python | train |
UDST/urbansim | urbansim/models/regression.py | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/regression.py#L460-L469 | def columns_used(self):
"""
Returns all the columns used in this model for filtering
and in the model expression.
"""
return list(tz.unique(tz.concatv(
util.columns_in_filters(self.fit_filters),
util.columns_in_filters(self.predict_filters),
u... | [
"def",
"columns_used",
"(",
"self",
")",
":",
"return",
"list",
"(",
"tz",
".",
"unique",
"(",
"tz",
".",
"concatv",
"(",
"util",
".",
"columns_in_filters",
"(",
"self",
".",
"fit_filters",
")",
",",
"util",
".",
"columns_in_filters",
"(",
"self",
".",
... | Returns all the columns used in this model for filtering
and in the model expression. | [
"Returns",
"all",
"the",
"columns",
"used",
"in",
"this",
"model",
"for",
"filtering",
"and",
"in",
"the",
"model",
"expression",
"."
] | python | train |
NuGrid/NuGridPy | nugridpy/nugridse.py | https://github.com/NuGrid/NuGridPy/blob/eee8047446e398be77362d82c1d8b3310054fab0/nugridpy/nugridse.py#L1586-L2024 | def _kip_cont2(self, sparse, cycle_start=0, cycle_end=0,
plot=['dcoeff'], thresholds=[1.0E+12],
xax='log_time_left', alphas=[1.0], yllim=0., yulim=0.,
y_res=2000, xllim=0., xulim=0., age='seconds',
sparse_intrinsic=20, engen=False,
... | [
"def",
"_kip_cont2",
"(",
"self",
",",
"sparse",
",",
"cycle_start",
"=",
"0",
",",
"cycle_end",
"=",
"0",
",",
"plot",
"=",
"[",
"'dcoeff'",
"]",
",",
"thresholds",
"=",
"[",
"1.0E+12",
"]",
",",
"xax",
"=",
"'log_time_left'",
",",
"alphas",
"=",
"[... | !! EXPERIMENTAL FEATURE (flagged as private) !!
This function creates a Kippenhahn diagram as a contour plot of
the .se.h5 or .out.h5 files using any continuous variable
(columns in the hdf5 cycle data). Multiple columns may be
plotted, their name indicated in the list "plot", and their... | [
"!!",
"EXPERIMENTAL",
"FEATURE",
"(",
"flagged",
"as",
"private",
")",
"!!"
] | python | train |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/brocade_qos.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_qos.py#L873-L884 | def nas_auto_qos_set_cos(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
nas = ET.SubElement(config, "nas", xmlns="urn:brocade.com:mgmt:brocade-qos")
auto_qos = ET.SubElement(nas, "auto-qos")
set = ET.SubElement(auto_qos, "set")
cos = ET.... | [
"def",
"nas_auto_qos_set_cos",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"nas",
"=",
"ET",
".",
"SubElement",
"(",
"config",
",",
"\"nas\"",
",",
"xmlns",
"=",
"\"urn:brocade.com:mgmt:broca... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train |
jadolg/rocketchat_API | rocketchat_API/rocketchat.py | https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L243-L245 | def chat_update(self, room_id, msg_id, text, **kwargs):
"""Updates the text of the chat message."""
return self.__call_api_post('chat.update', roomId=room_id, msgId=msg_id, text=text, kwargs=kwargs) | [
"def",
"chat_update",
"(",
"self",
",",
"room_id",
",",
"msg_id",
",",
"text",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"__call_api_post",
"(",
"'chat.update'",
",",
"roomId",
"=",
"room_id",
",",
"msgId",
"=",
"msg_id",
",",
"text",
"... | Updates the text of the chat message. | [
"Updates",
"the",
"text",
"of",
"the",
"chat",
"message",
"."
] | python | train |
psss/did | did/utils.py | https://github.com/psss/did/blob/04e4ee6f1aa14c0cae3ba9f9803871f3f98279cb/did/utils.py#L345-L376 | def set(self, mode=None):
"""
Set the coloring mode
If enabled, some objects (like case run Status) are printed in color
to easily spot failures, errors and so on. By default the feature is
enabled when script is attached to a terminal. Possible values are::
COLOR=0... | [
"def",
"set",
"(",
"self",
",",
"mode",
"=",
"None",
")",
":",
"# Detect from the environment if no mode given (only once)",
"if",
"mode",
"is",
"None",
":",
"# Nothing to do if already detected",
"if",
"self",
".",
"_mode",
"is",
"not",
"None",
":",
"return",
"# ... | Set the coloring mode
If enabled, some objects (like case run Status) are printed in color
to easily spot failures, errors and so on. By default the feature is
enabled when script is attached to a terminal. Possible values are::
COLOR=0 ... COLOR_OFF .... coloring disabled
... | [
"Set",
"the",
"coloring",
"mode"
] | python | train |
draperjames/qtpandas | qtpandas/views/CustomDelegates.py | https://github.com/draperjames/qtpandas/blob/64294fb69f1839e53dee5ea453337266bfaf24f4/qtpandas/views/CustomDelegates.py#L183-L193 | def setModelData(self, spinBox, model, index):
"""Gets data from the editor widget and stores it in the specified model at the item index.
Args:
spinBox (QDoubleSpinBox): editor widget.
model (QAbstractItemModel): parent model.
index (QModelIndex): model data index.
... | [
"def",
"setModelData",
"(",
"self",
",",
"spinBox",
",",
"model",
",",
"index",
")",
":",
"spinBox",
".",
"interpretText",
"(",
")",
"value",
"=",
"spinBox",
".",
"value",
"(",
")",
"model",
".",
"setData",
"(",
"index",
",",
"value",
",",
"QtCore",
... | Gets data from the editor widget and stores it in the specified model at the item index.
Args:
spinBox (QDoubleSpinBox): editor widget.
model (QAbstractItemModel): parent model.
index (QModelIndex): model data index. | [
"Gets",
"data",
"from",
"the",
"editor",
"widget",
"and",
"stores",
"it",
"in",
"the",
"specified",
"model",
"at",
"the",
"item",
"index",
"."
] | python | train |
okfn/ofs | ofs/local/zipfile.py | https://github.com/okfn/ofs/blob/c110cbecd7d0ae7e877963914a1a5af030cd6d45/ofs/local/zipfile.py#L724-L785 | def _RealGetContents(self):
"""Read in the table of contents for the ZIP file."""
fp = self.fp
endrec = _EndRecData(fp)
if not endrec:
raise BadZipfile("File is not a zip file")
if self.debug > 1:
print(endrec)
size_cd = endrec[_ECD_SIZE] ... | [
"def",
"_RealGetContents",
"(",
"self",
")",
":",
"fp",
"=",
"self",
".",
"fp",
"endrec",
"=",
"_EndRecData",
"(",
"fp",
")",
"if",
"not",
"endrec",
":",
"raise",
"BadZipfile",
"(",
"\"File is not a zip file\"",
")",
"if",
"self",
".",
"debug",
">",
"1",... | Read in the table of contents for the ZIP file. | [
"Read",
"in",
"the",
"table",
"of",
"contents",
"for",
"the",
"ZIP",
"file",
"."
] | python | train |
andrea-cuttone/geoplotlib | geoplotlib/utils.py | https://github.com/andrea-cuttone/geoplotlib/blob/a1c355bccec91cabd157569fad6daf53cf7687a1/geoplotlib/utils.py#L207-L217 | def from_points(lons, lats):
"""
Compute the BoundingBox from a set of latitudes and longitudes
:param lons: longitudes
:param lats: latitudes
:return: BoundingBox
"""
north, west = max(lats), min(lons)
south, east = min(lats), max(lons)
return Bo... | [
"def",
"from_points",
"(",
"lons",
",",
"lats",
")",
":",
"north",
",",
"west",
"=",
"max",
"(",
"lats",
")",
",",
"min",
"(",
"lons",
")",
"south",
",",
"east",
"=",
"min",
"(",
"lats",
")",
",",
"max",
"(",
"lons",
")",
"return",
"BoundingBox",... | Compute the BoundingBox from a set of latitudes and longitudes
:param lons: longitudes
:param lats: latitudes
:return: BoundingBox | [
"Compute",
"the",
"BoundingBox",
"from",
"a",
"set",
"of",
"latitudes",
"and",
"longitudes"
] | python | train |
apache/airflow | airflow/www/api/experimental/endpoints.py | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/www/api/experimental/endpoints.py#L114-L131 | def dag_runs(dag_id):
"""
Returns a list of Dag Runs for a specific DAG ID.
:query param state: a query string parameter '?state=queued|running|success...'
:param dag_id: String identifier of a DAG
:return: List of DAG runs of a DAG with requested state,
or all runs if the state is not specified... | [
"def",
"dag_runs",
"(",
"dag_id",
")",
":",
"try",
":",
"state",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'state'",
")",
"dagruns",
"=",
"get_dag_runs",
"(",
"dag_id",
",",
"state",
")",
"except",
"AirflowException",
"as",
"err",
":",
"_log",
"."... | Returns a list of Dag Runs for a specific DAG ID.
:query param state: a query string parameter '?state=queued|running|success...'
:param dag_id: String identifier of a DAG
:return: List of DAG runs of a DAG with requested state,
or all runs if the state is not specified | [
"Returns",
"a",
"list",
"of",
"Dag",
"Runs",
"for",
"a",
"specific",
"DAG",
"ID",
".",
":",
"query",
"param",
"state",
":",
"a",
"query",
"string",
"parameter",
"?state",
"=",
"queued|running|success",
"...",
":",
"param",
"dag_id",
":",
"String",
"identif... | python | test |
apache/incubator-heron | heronpy/api/metrics.py | https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/heronpy/api/metrics.py#L140-L143 | def add_key(self, key):
"""Adds a new key to this metric"""
if key not in self.value:
self.value[key] = ReducedMetric(self.reducer) | [
"def",
"add_key",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"not",
"in",
"self",
".",
"value",
":",
"self",
".",
"value",
"[",
"key",
"]",
"=",
"ReducedMetric",
"(",
"self",
".",
"reducer",
")"
] | Adds a new key to this metric | [
"Adds",
"a",
"new",
"key",
"to",
"this",
"metric"
] | python | valid |
vcs-python/vcspull | vcspull/config.py | https://github.com/vcs-python/vcspull/blob/c1827bf78d2cdebc61d82111c9aa35afd6ea6a25/vcspull/config.py#L182-L212 | def load_configs(files, cwd=os.getcwd()):
"""Return repos from a list of files.
:todo: Validate scheme, check for duplciate destinations, VCS urls
:param files: paths to config file
:type files: list
:param cwd: current path (pass down for :func:`extract_repos`
:type cwd: str
:returns: exp... | [
"def",
"load_configs",
"(",
"files",
",",
"cwd",
"=",
"os",
".",
"getcwd",
"(",
")",
")",
":",
"repos",
"=",
"[",
"]",
"for",
"f",
"in",
"files",
":",
"_",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"f",
")",
"conf",
"=",
"kapt... | Return repos from a list of files.
:todo: Validate scheme, check for duplciate destinations, VCS urls
:param files: paths to config file
:type files: list
:param cwd: current path (pass down for :func:`extract_repos`
:type cwd: str
:returns: expanded config dict item
:rtype: list of dict | [
"Return",
"repos",
"from",
"a",
"list",
"of",
"files",
"."
] | python | train |
timothyb0912/pylogit | pylogit/base_multinomial_cm_v2.py | https://github.com/timothyb0912/pylogit/blob/f83b0fd6debaa7358d87c3828428f6d4ead71357/pylogit/base_multinomial_cm_v2.py#L183-L207 | def check_type_of_nest_spec_keys_and_values(nest_spec):
"""
Ensures that the keys and values of `nest_spec` are strings and lists.
Raises a helpful ValueError if they are.
Parameters
----------
nest_spec : OrderedDict, or None, optional.
Keys are strings that define the name of the nest... | [
"def",
"check_type_of_nest_spec_keys_and_values",
"(",
"nest_spec",
")",
":",
"try",
":",
"assert",
"all",
"(",
"[",
"isinstance",
"(",
"k",
",",
"str",
")",
"for",
"k",
"in",
"nest_spec",
"]",
")",
"assert",
"all",
"(",
"[",
"isinstance",
"(",
"nest_spec"... | Ensures that the keys and values of `nest_spec` are strings and lists.
Raises a helpful ValueError if they are.
Parameters
----------
nest_spec : OrderedDict, or None, optional.
Keys are strings that define the name of the nests. Values are lists of
alternative ids, denoting which alter... | [
"Ensures",
"that",
"the",
"keys",
"and",
"values",
"of",
"nest_spec",
"are",
"strings",
"and",
"lists",
".",
"Raises",
"a",
"helpful",
"ValueError",
"if",
"they",
"are",
"."
] | python | train |
exxeleron/qPython | qpython/qreader.py | https://github.com/exxeleron/qPython/blob/7e64a28b1e8814a8d6b9217ce79bb8de546e62f3/qpython/qreader.py#L119-L141 | def read(self, source = None, **options):
'''
Reads and optionally parses a single message.
:Parameters:
- `source` - optional data buffer to be read, if not specified data is
read from the wrapped stream
:Options:
- `raw` (`boolean`) - indicates wh... | [
"def",
"read",
"(",
"self",
",",
"source",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"message",
"=",
"self",
".",
"read_header",
"(",
"source",
")",
"message",
".",
"data",
"=",
"self",
".",
"read_data",
"(",
"message",
".",
"size",
",",
"me... | Reads and optionally parses a single message.
:Parameters:
- `source` - optional data buffer to be read, if not specified data is
read from the wrapped stream
:Options:
- `raw` (`boolean`) - indicates whether read data should parsed or
returned in raw b... | [
"Reads",
"and",
"optionally",
"parses",
"a",
"single",
"message",
".",
":",
"Parameters",
":",
"-",
"source",
"-",
"optional",
"data",
"buffer",
"to",
"be",
"read",
"if",
"not",
"specified",
"data",
"is",
"read",
"from",
"the",
"wrapped",
"stream",
":",
... | python | train |
yougov/elastic-doc-manager | mongo_connector/doc_managers/elastic_doc_manager.py | https://github.com/yougov/elastic-doc-manager/blob/17c35f4dd3d081b171c45ba0eb9616da9dc89e82/mongo_connector/doc_managers/elastic_doc_manager.py#L454-L470 | def send_buffered_operations(self):
"""Send buffered operations to Elasticsearch.
This method is periodically called by the AutoCommitThread.
"""
with self.lock:
try:
action_buffer = self.BulkBuffer.get_buffer()
if action_buffer:
... | [
"def",
"send_buffered_operations",
"(",
"self",
")",
":",
"with",
"self",
".",
"lock",
":",
"try",
":",
"action_buffer",
"=",
"self",
".",
"BulkBuffer",
".",
"get_buffer",
"(",
")",
"if",
"action_buffer",
":",
"successes",
",",
"errors",
"=",
"bulk",
"(",
... | Send buffered operations to Elasticsearch.
This method is periodically called by the AutoCommitThread. | [
"Send",
"buffered",
"operations",
"to",
"Elasticsearch",
"."
] | python | train |
foremast/foremast | src/foremast/utils/tasks.py | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/utils/tasks.py#L97-L122 | def check_task(taskid, timeout=DEFAULT_TASK_TIMEOUT, wait=2):
"""Wrap check_task.
Args:
taskid (str): Existing Spinnaker Task ID.
timeout (int, optional): Consider Task failed after given seconds.
wait (int, optional): Seconds to pause between polling attempts.
Returns:
str... | [
"def",
"check_task",
"(",
"taskid",
",",
"timeout",
"=",
"DEFAULT_TASK_TIMEOUT",
",",
"wait",
"=",
"2",
")",
":",
"max_attempts",
"=",
"int",
"(",
"timeout",
"/",
"wait",
")",
"try",
":",
"return",
"retry_call",
"(",
"partial",
"(",
"_check_task",
",",
"... | Wrap check_task.
Args:
taskid (str): Existing Spinnaker Task ID.
timeout (int, optional): Consider Task failed after given seconds.
wait (int, optional): Seconds to pause between polling attempts.
Returns:
str: Task status.
Raises:
AssertionError: API did not respo... | [
"Wrap",
"check_task",
"."
] | python | train |
bcbio/bcbio-nextgen | bcbio/variation/validateplot.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/validateplot.py#L178-L187 | def plot_prep_methods(df, prep, prepi, out_file_base, outtype, title=None,
size=None):
"""Plot comparison between BAM preparation methods.
"""
samples = df[(df["bamprep"] == prep)]["sample"].unique()
assert len(samples) >= 1, samples
out_file = "%s-%s.%s" % (out_file_base, samp... | [
"def",
"plot_prep_methods",
"(",
"df",
",",
"prep",
",",
"prepi",
",",
"out_file_base",
",",
"outtype",
",",
"title",
"=",
"None",
",",
"size",
"=",
"None",
")",
":",
"samples",
"=",
"df",
"[",
"(",
"df",
"[",
"\"bamprep\"",
"]",
"==",
"prep",
")",
... | Plot comparison between BAM preparation methods. | [
"Plot",
"comparison",
"between",
"BAM",
"preparation",
"methods",
"."
] | python | train |
loli/medpy | medpy/core/logger.py | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/core/logger.py#L121-L143 | def setLevel(self, level):
r"""Overrides the parent method to adapt the formatting string to the level.
Parameters
----------
level : int
The new log level to set. See the logging levels in the logging module for details.
Examples
-------... | [
"def",
"setLevel",
"(",
"self",
",",
"level",
")",
":",
"if",
"logging",
".",
"DEBUG",
">=",
"level",
":",
"formatter",
"=",
"logging",
".",
"Formatter",
"(",
"\"%(asctime)s [%(levelname)-8s] %(message)s (in %(module)s.%(funcName)s:%(lineno)s)\"",
",",
"\"%d.%m.%Y %H:%M... | r"""Overrides the parent method to adapt the formatting string to the level.
Parameters
----------
level : int
The new log level to set. See the logging levels in the logging module for details.
Examples
--------
>>> import logging
... | [
"r",
"Overrides",
"the",
"parent",
"method",
"to",
"adapt",
"the",
"formatting",
"string",
"to",
"the",
"level",
".",
"Parameters",
"----------",
"level",
":",
"int",
"The",
"new",
"log",
"level",
"to",
"set",
".",
"See",
"the",
"logging",
"levels",
"in",
... | python | train |
readbeyond/aeneas | aeneas/container.py | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/container.py#L186-L200 | def is_safe(self):
"""
Return ``True`` if the container can be safely extracted,
that is, if all its entries are safe, ``False`` otherwise.
:rtype: bool
:raises: same as :func:`~aeneas.container.Container.entries`
"""
self.log(u"Checking if this container is safe... | [
"def",
"is_safe",
"(",
"self",
")",
":",
"self",
".",
"log",
"(",
"u\"Checking if this container is safe\"",
")",
"for",
"entry",
"in",
"self",
".",
"entries",
":",
"if",
"not",
"self",
".",
"is_entry_safe",
"(",
"entry",
")",
":",
"self",
".",
"log",
"(... | Return ``True`` if the container can be safely extracted,
that is, if all its entries are safe, ``False`` otherwise.
:rtype: bool
:raises: same as :func:`~aeneas.container.Container.entries` | [
"Return",
"True",
"if",
"the",
"container",
"can",
"be",
"safely",
"extracted",
"that",
"is",
"if",
"all",
"its",
"entries",
"are",
"safe",
"False",
"otherwise",
"."
] | python | train |
StanfordVL/robosuite | robosuite/environments/baxter.py | https://github.com/StanfordVL/robosuite/blob/65cd16810e2ed647e3ec88746af3412065b7f278/robosuite/environments/baxter.py#L107-L179 | def _get_reference(self):
"""Sets up references for robots, grippers, and objects."""
super()._get_reference()
# indices for joints in qpos, qvel
self.robot_joints = list(self.mujoco_robot.joints)
self._ref_joint_pos_indexes = [
self.sim.model.get_joint_qpos_addr(x) ... | [
"def",
"_get_reference",
"(",
"self",
")",
":",
"super",
"(",
")",
".",
"_get_reference",
"(",
")",
"# indices for joints in qpos, qvel",
"self",
".",
"robot_joints",
"=",
"list",
"(",
"self",
".",
"mujoco_robot",
".",
"joints",
")",
"self",
".",
"_ref_joint_p... | Sets up references for robots, grippers, and objects. | [
"Sets",
"up",
"references",
"for",
"robots",
"grippers",
"and",
"objects",
"."
] | python | train |
MrYsLab/PyMata | PyMata/pymata.py | https://github.com/MrYsLab/PyMata/blob/7e0ec34670b5a0d3d6b74bcbe4f3808c845cc429/PyMata/pymata.py#L594-L616 | def i2c_read(self, address, register, number_of_bytes, read_type, cb=None):
"""
This method requests the read of an i2c device. Results are retrieved by a call to
i2c_get_read_data().
If a callback method is provided, when data is received from the device it will be sent to the callback ... | [
"def",
"i2c_read",
"(",
"self",
",",
"address",
",",
"register",
",",
"number_of_bytes",
",",
"read_type",
",",
"cb",
"=",
"None",
")",
":",
"data",
"=",
"[",
"address",
",",
"read_type",
",",
"register",
"&",
"0x7f",
",",
"(",
"register",
">>",
"7",
... | This method requests the read of an i2c device. Results are retrieved by a call to
i2c_get_read_data().
If a callback method is provided, when data is received from the device it will be sent to the callback method
:param address: i2c device address
:param register: register number (ca... | [
"This",
"method",
"requests",
"the",
"read",
"of",
"an",
"i2c",
"device",
".",
"Results",
"are",
"retrieved",
"by",
"a",
"call",
"to",
"i2c_get_read_data",
"()",
".",
"If",
"a",
"callback",
"method",
"is",
"provided",
"when",
"data",
"is",
"received",
"fro... | python | valid |
thunder-project/thunder | thunder/blocks/local.py | https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/blocks/local.py#L54-L75 | def unchunk(self):
"""
Reconstitute the chunked array back into a full ndarray.
Returns
-------
ndarray
"""
if self.padding != len(self.shape)*(0,):
shape = self.values.shape
arr = empty(shape, dtype=object)
for inds in product... | [
"def",
"unchunk",
"(",
"self",
")",
":",
"if",
"self",
".",
"padding",
"!=",
"len",
"(",
"self",
".",
"shape",
")",
"*",
"(",
"0",
",",
")",
":",
"shape",
"=",
"self",
".",
"values",
".",
"shape",
"arr",
"=",
"empty",
"(",
"shape",
",",
"dtype"... | Reconstitute the chunked array back into a full ndarray.
Returns
-------
ndarray | [
"Reconstitute",
"the",
"chunked",
"array",
"back",
"into",
"a",
"full",
"ndarray",
"."
] | python | train |
inspirehep/isbnid | isbn/isbn.py | https://github.com/inspirehep/isbnid/blob/e8136a8bd2212b8ebd77c081fa30bb4dad0e4a75/isbn/isbn.py#L108-L121 | def isbn10(self):
'''
Encode ISBN number in ISBN10 format
Raises exception if Bookland number different from 978
@rtype: string
@return: ISBN formated as ISBN10
'''
if self._id[0:3] != '978':
raise ISBNError("Invalid Bookland code: {}".format(self._id... | [
"def",
"isbn10",
"(",
"self",
")",
":",
"if",
"self",
".",
"_id",
"[",
"0",
":",
"3",
"]",
"!=",
"'978'",
":",
"raise",
"ISBNError",
"(",
"\"Invalid Bookland code: {}\"",
".",
"format",
"(",
"self",
".",
"_id",
"[",
"0",
":",
"3",
"]",
")",
")",
... | Encode ISBN number in ISBN10 format
Raises exception if Bookland number different from 978
@rtype: string
@return: ISBN formated as ISBN10 | [
"Encode",
"ISBN",
"number",
"in",
"ISBN10",
"format",
"Raises",
"exception",
"if",
"Bookland",
"number",
"different",
"from",
"978"
] | python | train |
Microsoft/azure-devops-python-api | azure-devops/azure/devops/v5_0/service_hooks/service_hooks_client.py | https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/service_hooks/service_hooks_client.py#L28-L49 | def get_consumer_action(self, consumer_id, consumer_action_id, publisher_id=None):
"""GetConsumerAction.
Get details about a specific consumer action.
:param str consumer_id: ID for a consumer.
:param str consumer_action_id: ID for a consumerActionId.
:param str publisher_id:
... | [
"def",
"get_consumer_action",
"(",
"self",
",",
"consumer_id",
",",
"consumer_action_id",
",",
"publisher_id",
"=",
"None",
")",
":",
"route_values",
"=",
"{",
"}",
"if",
"consumer_id",
"is",
"not",
"None",
":",
"route_values",
"[",
"'consumerId'",
"]",
"=",
... | GetConsumerAction.
Get details about a specific consumer action.
:param str consumer_id: ID for a consumer.
:param str consumer_action_id: ID for a consumerActionId.
:param str publisher_id:
:rtype: :class:`<ConsumerAction> <azure.devops.v5_0.service_hooks.models.ConsumerAction>` | [
"GetConsumerAction",
".",
"Get",
"details",
"about",
"a",
"specific",
"consumer",
"action",
".",
":",
"param",
"str",
"consumer_id",
":",
"ID",
"for",
"a",
"consumer",
".",
":",
"param",
"str",
"consumer_action_id",
":",
"ID",
"for",
"a",
"consumerActionId",
... | python | train |
senaite/senaite.core | bika/lims/browser/worksheet/views/add_analyses.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/browser/worksheet/views/add_analyses.py#L153-L168 | def handle_submit(self):
"""Handle form submission
"""
wst_uid = self.request.form.get("getWorksheetTemplate")
if not wst_uid:
return False
layout = self.context.getLayout()
wst = api.get_object_by_uid(wst_uid)
self.request["context_uid"] = api.get_u... | [
"def",
"handle_submit",
"(",
"self",
")",
":",
"wst_uid",
"=",
"self",
".",
"request",
".",
"form",
".",
"get",
"(",
"\"getWorksheetTemplate\"",
")",
"if",
"not",
"wst_uid",
":",
"return",
"False",
"layout",
"=",
"self",
".",
"context",
".",
"getLayout",
... | Handle form submission | [
"Handle",
"form",
"submission"
] | python | train |
dls-controls/pymalcolm | malcolm/modules/pmac/infos.py | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/pmac/infos.py#L83-L101 | def _make_padded_ramp(self, v1, v2, pad_velocity, total_time):
"""Makes a ramp that looks like this:
v1 \______ pad_velocity
| |\
| | \v2
t1 tp t2
Such that whole section takes total_time
"""
# The time taken to ramp from v1 to pad_ve... | [
"def",
"_make_padded_ramp",
"(",
"self",
",",
"v1",
",",
"v2",
",",
"pad_velocity",
",",
"total_time",
")",
":",
"# The time taken to ramp from v1 to pad_velocity",
"t1",
"=",
"self",
".",
"acceleration_time",
"(",
"v1",
",",
"pad_velocity",
")",
"# Then on to v2",
... | Makes a ramp that looks like this:
v1 \______ pad_velocity
| |\
| | \v2
t1 tp t2
Such that whole section takes total_time | [
"Makes",
"a",
"ramp",
"that",
"looks",
"like",
"this",
":"
] | python | train |
Julian/jsonschema | docs/jsonschema_role.py | https://github.com/Julian/jsonschema/blob/a72332004cdc3ba456de7918bc32059822b2f69a/docs/jsonschema_role.py#L43-L75 | def fetch_or_load(spec_path):
"""
Fetch a new specification or use the cache if it's current.
Arguments:
cache_path:
the path to a cached specification
"""
headers = {}
try:
modified = datetime.utcfromtimestamp(os.path.getmtime(spec_path))
date = modifie... | [
"def",
"fetch_or_load",
"(",
"spec_path",
")",
":",
"headers",
"=",
"{",
"}",
"try",
":",
"modified",
"=",
"datetime",
".",
"utcfromtimestamp",
"(",
"os",
".",
"path",
".",
"getmtime",
"(",
"spec_path",
")",
")",
"date",
"=",
"modified",
".",
"strftime",... | Fetch a new specification or use the cache if it's current.
Arguments:
cache_path:
the path to a cached specification | [
"Fetch",
"a",
"new",
"specification",
"or",
"use",
"the",
"cache",
"if",
"it",
"s",
"current",
"."
] | python | train |
MisterWil/abodepy | abodepy/devices/switch.py | https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/devices/switch.py#L10-L17 | def switch_on(self):
"""Turn the switch on."""
success = self.set_status(CONST.STATUS_ON_INT)
if success:
self._json_state['status'] = CONST.STATUS_ON
return success | [
"def",
"switch_on",
"(",
"self",
")",
":",
"success",
"=",
"self",
".",
"set_status",
"(",
"CONST",
".",
"STATUS_ON_INT",
")",
"if",
"success",
":",
"self",
".",
"_json_state",
"[",
"'status'",
"]",
"=",
"CONST",
".",
"STATUS_ON",
"return",
"success"
] | Turn the switch on. | [
"Turn",
"the",
"switch",
"on",
"."
] | python | train |
quantopian/zipline | zipline/pipeline/expression.py | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/expression.py#L213-L236 | def _validate(self):
"""
Ensure that our expression string has variables of the form x_0, x_1,
... x_(N - 1), where N is the length of our inputs.
"""
variable_names, _unused = getExprNames(self._expr, {})
expr_indices = []
for name in variable_names:
... | [
"def",
"_validate",
"(",
"self",
")",
":",
"variable_names",
",",
"_unused",
"=",
"getExprNames",
"(",
"self",
".",
"_expr",
",",
"{",
"}",
")",
"expr_indices",
"=",
"[",
"]",
"for",
"name",
"in",
"variable_names",
":",
"if",
"name",
"==",
"'inf'",
":"... | Ensure that our expression string has variables of the form x_0, x_1,
... x_(N - 1), where N is the length of our inputs. | [
"Ensure",
"that",
"our",
"expression",
"string",
"has",
"variables",
"of",
"the",
"form",
"x_0",
"x_1",
"...",
"x_",
"(",
"N",
"-",
"1",
")",
"where",
"N",
"is",
"the",
"length",
"of",
"our",
"inputs",
"."
] | python | train |
danilobellini/audiolazy | audiolazy/lazy_stream.py | https://github.com/danilobellini/audiolazy/blob/dba0a278937909980ed40b976d866b8e97c35dee/audiolazy/lazy_stream.py#L290-L297 | def copy(self):
"""
Returns a "T" (tee) copy of the given stream, allowing the calling
stream to continue being used.
"""
a, b = it.tee(self._data) # 2 generators, not thread-safe
self._data = a
return Stream(b) | [
"def",
"copy",
"(",
"self",
")",
":",
"a",
",",
"b",
"=",
"it",
".",
"tee",
"(",
"self",
".",
"_data",
")",
"# 2 generators, not thread-safe",
"self",
".",
"_data",
"=",
"a",
"return",
"Stream",
"(",
"b",
")"
] | Returns a "T" (tee) copy of the given stream, allowing the calling
stream to continue being used. | [
"Returns",
"a",
"T",
"(",
"tee",
")",
"copy",
"of",
"the",
"given",
"stream",
"allowing",
"the",
"calling",
"stream",
"to",
"continue",
"being",
"used",
"."
] | python | train |
DomainTools/python_api | domaintools/api.py | https://github.com/DomainTools/python_api/blob/17be85fd4913fbe14d7660a4f4829242f1663e60/domaintools/api.py#L10-L12 | def delimited(items, character='|'):
"""Returns a character delimited version of the provided list as a Python string"""
return '|'.join(items) if type(items) in (list, tuple, set) else items | [
"def",
"delimited",
"(",
"items",
",",
"character",
"=",
"'|'",
")",
":",
"return",
"'|'",
".",
"join",
"(",
"items",
")",
"if",
"type",
"(",
"items",
")",
"in",
"(",
"list",
",",
"tuple",
",",
"set",
")",
"else",
"items"
] | Returns a character delimited version of the provided list as a Python string | [
"Returns",
"a",
"character",
"delimited",
"version",
"of",
"the",
"provided",
"list",
"as",
"a",
"Python",
"string"
] | python | train |
yougov/openpack | openpack/basepack.py | https://github.com/yougov/openpack/blob/1412ec34c1bab6ba6c8ae5490c2205d696f13717/openpack/basepack.py#L46-L52 | def related(self, reltype):
"""Return a list of parts related to this one via reltype."""
parts = []
package = getattr(self, 'package', None) or self
for rel in self.relationships.types.get(reltype, []):
parts.append(package[posixpath.join(self.base, rel.target)])
return parts | [
"def",
"related",
"(",
"self",
",",
"reltype",
")",
":",
"parts",
"=",
"[",
"]",
"package",
"=",
"getattr",
"(",
"self",
",",
"'package'",
",",
"None",
")",
"or",
"self",
"for",
"rel",
"in",
"self",
".",
"relationships",
".",
"types",
".",
"get",
"... | Return a list of parts related to this one via reltype. | [
"Return",
"a",
"list",
"of",
"parts",
"related",
"to",
"this",
"one",
"via",
"reltype",
"."
] | python | test |
Microsoft/nni | src/sdk/pynni/nni/networkmorphism_tuner/bayesian.py | https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/bayesian.py#L243-L266 | def edit_distance_matrix(train_x, train_y=None):
"""Calculate the edit distance.
Args:
train_x: A list of neural architectures.
train_y: A list of neural architectures.
Returns:
An edit-distance matrix.
"""
if train_y is None:
ret = np.zeros((train_x.shape[0], train_x... | [
"def",
"edit_distance_matrix",
"(",
"train_x",
",",
"train_y",
"=",
"None",
")",
":",
"if",
"train_y",
"is",
"None",
":",
"ret",
"=",
"np",
".",
"zeros",
"(",
"(",
"train_x",
".",
"shape",
"[",
"0",
"]",
",",
"train_x",
".",
"shape",
"[",
"0",
"]",... | Calculate the edit distance.
Args:
train_x: A list of neural architectures.
train_y: A list of neural architectures.
Returns:
An edit-distance matrix. | [
"Calculate",
"the",
"edit",
"distance",
".",
"Args",
":",
"train_x",
":",
"A",
"list",
"of",
"neural",
"architectures",
".",
"train_y",
":",
"A",
"list",
"of",
"neural",
"architectures",
".",
"Returns",
":",
"An",
"edit",
"-",
"distance",
"matrix",
"."
] | python | train |
mitsei/dlkit | dlkit/json_/osid/searches.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/osid/searches.py#L65-L91 | def limit_result_set(self, start, end):
"""By default, searches return all matching results.
This method restricts the number of results by setting the start
and end of the result set, starting from 1. The starting and
ending results can be used for paging results when a certain
... | [
"def",
"limit_result_set",
"(",
"self",
",",
"start",
",",
"end",
")",
":",
"if",
"not",
"isinstance",
"(",
"start",
",",
"int",
")",
"or",
"not",
"isinstance",
"(",
"end",
",",
"int",
")",
":",
"raise",
"errors",
".",
"InvalidArgument",
"(",
"'start a... | By default, searches return all matching results.
This method restricts the number of results by setting the start
and end of the result set, starting from 1. The starting and
ending results can be used for paging results when a certain
ordering is requested. The ending position must be... | [
"By",
"default",
"searches",
"return",
"all",
"matching",
"results",
"."
] | python | train |
watson-developer-cloud/python-sdk | ibm_watson/visual_recognition_v3.py | https://github.com/watson-developer-cloud/python-sdk/blob/4c2c9df4466fcde88975da9ecd834e6ba95eb353/ibm_watson/visual_recognition_v3.py#L1596-L1607 | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'width') and self.width is not None:
_dict['width'] = self.width
if hasattr(self, 'height') and self.height is not None:
_dict['height'] = self.height
i... | [
"def",
"_to_dict",
"(",
"self",
")",
":",
"_dict",
"=",
"{",
"}",
"if",
"hasattr",
"(",
"self",
",",
"'width'",
")",
"and",
"self",
".",
"width",
"is",
"not",
"None",
":",
"_dict",
"[",
"'width'",
"]",
"=",
"self",
".",
"width",
"if",
"hasattr",
... | Return a json dictionary representing this model. | [
"Return",
"a",
"json",
"dictionary",
"representing",
"this",
"model",
"."
] | python | train |
pbacterio/dj-paas-env | dj_paas_env/database.py | https://github.com/pbacterio/dj-paas-env/blob/1f86bf0a0253cac9eae2442b1e3a8643426077b4/dj_paas_env/database.py#L70-L81 | def data_dir(default='data'):
"""
Return persistent data directory or ``default`` if not found
Warning: Do not use this directory to store sqlite databases in producction
"""
if 'OPENSHIFT_DATA_DIR' in os.environ:
return os.environ['OPENSHIFT_DATA_DIR']
if 'GONDOR_DATA_DIR' in os.environ... | [
"def",
"data_dir",
"(",
"default",
"=",
"'data'",
")",
":",
"if",
"'OPENSHIFT_DATA_DIR'",
"in",
"os",
".",
"environ",
":",
"return",
"os",
".",
"environ",
"[",
"'OPENSHIFT_DATA_DIR'",
"]",
"if",
"'GONDOR_DATA_DIR'",
"in",
"os",
".",
"environ",
":",
"return",... | Return persistent data directory or ``default`` if not found
Warning: Do not use this directory to store sqlite databases in producction | [
"Return",
"persistent",
"data",
"directory",
"or",
"default",
"if",
"not",
"found",
"Warning",
":",
"Do",
"not",
"use",
"this",
"directory",
"to",
"store",
"sqlite",
"databases",
"in",
"producction"
] | python | train |
awslabs/serverless-application-model | samtranslator/intrinsics/actions.py | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/intrinsics/actions.py#L41-L52 | def can_handle(self, input_dict):
"""
Validates that the input dictionary contains only one key and is of the given intrinsic_name
:param input_dict: Input dictionary representing the intrinsic function
:return: True if it matches expected structure, False otherwise
"""
... | [
"def",
"can_handle",
"(",
"self",
",",
"input_dict",
")",
":",
"return",
"input_dict",
"is",
"not",
"None",
"and",
"isinstance",
"(",
"input_dict",
",",
"dict",
")",
"and",
"len",
"(",
"input_dict",
")",
"==",
"1",
"and",
"self",
".",
"intrinsic_name",
"... | Validates that the input dictionary contains only one key and is of the given intrinsic_name
:param input_dict: Input dictionary representing the intrinsic function
:return: True if it matches expected structure, False otherwise | [
"Validates",
"that",
"the",
"input",
"dictionary",
"contains",
"only",
"one",
"key",
"and",
"is",
"of",
"the",
"given",
"intrinsic_name"
] | python | train |
bxlab/bx-python | lib/bx/align/epo.py | https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/align/epo.py#L249-L278 | def intervals(self, reverse, thr=0):
"""return a list of (0-based half-open) intervals representing the match regions of the cigar
for example 4MD4M2DM with reverse=False will produce [(0,4), (5,9), (11,12)]
4MD4M2DM with reverse=True will produce [(0,1), (3,7), (8,12)] (= 12 - previous interva... | [
"def",
"intervals",
"(",
"self",
",",
"reverse",
",",
"thr",
"=",
"0",
")",
":",
"d",
"=",
"[",
"(",
"thr",
",",
"thr",
")",
"]",
"dl",
"=",
"0",
"for",
"tup",
"in",
"self",
".",
"cigar_iter",
"(",
"reverse",
")",
":",
"if",
"tup",
"[",
"1",
... | return a list of (0-based half-open) intervals representing the match regions of the cigar
for example 4MD4M2DM with reverse=False will produce [(0,4), (5,9), (11,12)]
4MD4M2DM with reverse=True will produce [(0,1), (3,7), (8,12)] (= 12 - previous interval)
:param reverse: whether to iterate i... | [
"return",
"a",
"list",
"of",
"(",
"0",
"-",
"based",
"half",
"-",
"open",
")",
"intervals",
"representing",
"the",
"match",
"regions",
"of",
"the",
"cigar"
] | python | train |
django-treebeard/django-treebeard | treebeard/mp_tree.py | https://github.com/django-treebeard/django-treebeard/blob/8042ee939cb45394909237da447f8925e3cc6aa3/treebeard/mp_tree.py#L965-L973 | def get_prev_sibling(self):
"""
:returns: The previous node's sibling, or None if it was the leftmost
sibling.
"""
try:
return self.get_siblings().filter(path__lt=self.path).reverse()[0]
except IndexError:
return None | [
"def",
"get_prev_sibling",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"get_siblings",
"(",
")",
".",
"filter",
"(",
"path__lt",
"=",
"self",
".",
"path",
")",
".",
"reverse",
"(",
")",
"[",
"0",
"]",
"except",
"IndexError",
":",
"retur... | :returns: The previous node's sibling, or None if it was the leftmost
sibling. | [
":",
"returns",
":",
"The",
"previous",
"node",
"s",
"sibling",
"or",
"None",
"if",
"it",
"was",
"the",
"leftmost",
"sibling",
"."
] | python | train |
yfpeng/bioc | bioc/biocjson/decoder.py | https://github.com/yfpeng/bioc/blob/47ddaa010960d9ba673aefe068e7bbaf39f0fff4/bioc/biocjson/decoder.py#L90-L103 | def load(fp, **kwargs) -> BioCCollection:
"""
Deserialize fp (a .read()-supporting text file or binary file containing a JSON document) to
a BioCCollection object
Args:
fp: a file containing a JSON document
**kwargs:
Returns:
BioCCollection: a collection
"""
... | [
"def",
"load",
"(",
"fp",
",",
"*",
"*",
"kwargs",
")",
"->",
"BioCCollection",
":",
"obj",
"=",
"json",
".",
"load",
"(",
"fp",
",",
"*",
"*",
"kwargs",
")",
"return",
"parse_collection",
"(",
"obj",
")"
] | Deserialize fp (a .read()-supporting text file or binary file containing a JSON document) to
a BioCCollection object
Args:
fp: a file containing a JSON document
**kwargs:
Returns:
BioCCollection: a collection | [
"Deserialize",
"fp",
"(",
"a",
".",
"read",
"()",
"-",
"supporting",
"text",
"file",
"or",
"binary",
"file",
"containing",
"a",
"JSON",
"document",
")",
"to",
"a",
"BioCCollection",
"object",
"Args",
":",
"fp",
":",
"a",
"file",
"containing",
"a",
"JSON"... | python | train |
yunpian/yunpian-python-sdk | yunpian_python_sdk/ypclient.py | https://github.com/yunpian/yunpian-python-sdk/blob/405a1196ec83fdf29ff454f74ef036974be11970/yunpian_python_sdk/ypclient.py#L85-L105 | def api(self, name):
'''return special API by package's name'''
assert name, 'name is none'
if flow.__name__ == name:
api = flow.FlowApi()
elif sign.__name__ == name:
api = sign.SignApi()
elif sms.__name__ == name:
api = sms.SmsApi()
e... | [
"def",
"api",
"(",
"self",
",",
"name",
")",
":",
"assert",
"name",
",",
"'name is none'",
"if",
"flow",
".",
"__name__",
"==",
"name",
":",
"api",
"=",
"flow",
".",
"FlowApi",
"(",
")",
"elif",
"sign",
".",
"__name__",
"==",
"name",
":",
"api",
"=... | return special API by package's name | [
"return",
"special",
"API",
"by",
"package",
"s",
"name"
] | python | train |
ggaughan/pipe2py | pipe2py/modules/pipeitembuilder.py | https://github.com/ggaughan/pipe2py/blob/4767d6d1fd354d2a35e6528594b8deb8a033eed4/pipe2py/modules/pipeitembuilder.py#L23-L49 | def asyncPipeItembuilder(context=None, _INPUT=None, conf=None, **kwargs):
"""A source that asynchronously builds an item. Loopable.
Parameters
----------
context : pipe2py.Context object
_INPUT : asyncPipe like object (twisted Deferred iterable of items)
conf : {
'attrs': [
... | [
"def",
"asyncPipeItembuilder",
"(",
"context",
"=",
"None",
",",
"_INPUT",
"=",
"None",
",",
"conf",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"pkwargs",
"=",
"cdicts",
"(",
"opts",
",",
"kwargs",
")",
"asyncFuncs",
"=",
"yield",
"asyncGetSplits",
... | A source that asynchronously builds an item. Loopable.
Parameters
----------
context : pipe2py.Context object
_INPUT : asyncPipe like object (twisted Deferred iterable of items)
conf : {
'attrs': [
{'key': {'value': 'title'}, 'value': {'value': 'new title'}},
{'key':... | [
"A",
"source",
"that",
"asynchronously",
"builds",
"an",
"item",
".",
"Loopable",
"."
] | python | train |
MacHu-GWU/angora-project | angora/bot/macro.py | https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/bot/macro.py#L187-L191 | def Left(self, n = 1, dl = 0):
"""左方向键n次
"""
self.Delay(dl)
self.keyboard.tap_key(self.keyboard.left_key, n) | [
"def",
"Left",
"(",
"self",
",",
"n",
"=",
"1",
",",
"dl",
"=",
"0",
")",
":",
"self",
".",
"Delay",
"(",
"dl",
")",
"self",
".",
"keyboard",
".",
"tap_key",
"(",
"self",
".",
"keyboard",
".",
"left_key",
",",
"n",
")"
] | 左方向键n次 | [
"左方向键n次"
] | python | train |
pybel/pybel-artifactory | src/pybel_artifactory/deploy.py | https://github.com/pybel/pybel-artifactory/blob/720107780a59be2ef08885290dfa519b1da62871/src/pybel_artifactory/deploy.py#L93-L111 | def deploy_annotation(filename, module_name, hash_check=True, auth=None):
"""Deploy a file to the Artifactory BEL annotation cache.
:param str filename: The physical file path
:param str module_name: The name of the module to deploy to
:param bool hash_check: Ensure the hash is unique before deploying
... | [
"def",
"deploy_annotation",
"(",
"filename",
",",
"module_name",
",",
"hash_check",
"=",
"True",
",",
"auth",
"=",
"None",
")",
":",
"return",
"_deploy_helper",
"(",
"filename",
",",
"module_name",
",",
"get_annotation_module_url",
",",
"get_annotation_today",
","... | Deploy a file to the Artifactory BEL annotation cache.
:param str filename: The physical file path
:param str module_name: The name of the module to deploy to
:param bool hash_check: Ensure the hash is unique before deploying
:param tuple[str] auth: A pair of (str username, str password) to give to the... | [
"Deploy",
"a",
"file",
"to",
"the",
"Artifactory",
"BEL",
"annotation",
"cache",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.