repo stringlengths 7 55 | path stringlengths 4 223 | url stringlengths 87 315 | code stringlengths 75 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values | avg_line_len float64 7.91 980 |
|---|---|---|---|---|---|---|---|---|---|
exosite-labs/pyonep | pyonep/onep.py | https://github.com/exosite-labs/pyonep/blob/d27b621b00688a542e0adcc01f3e3354c05238a1/pyonep/onep.py#L501-L512 | def wait(self, auth, resource, options, defer=False):
""" This is a HTTP Long Polling API which allows a user to wait on specific resources to be
updated.
Args:
auth: <cik> for authentication
resource: <ResourceID> to specify what resource to wait on.
options... | [
"def",
"wait",
"(",
"self",
",",
"auth",
",",
"resource",
",",
"options",
",",
"defer",
"=",
"False",
")",
":",
"# let the server control the timeout",
"return",
"self",
".",
"_call",
"(",
"'wait'",
",",
"auth",
",",
"[",
"resource",
",",
"options",
"]",
... | This is a HTTP Long Polling API which allows a user to wait on specific resources to be
updated.
Args:
auth: <cik> for authentication
resource: <ResourceID> to specify what resource to wait on.
options: Options for the wait including a timeout (in ms), (max 5min) and... | [
"This",
"is",
"a",
"HTTP",
"Long",
"Polling",
"API",
"which",
"allows",
"a",
"user",
"to",
"wait",
"on",
"specific",
"resources",
"to",
"be",
"updated",
"."
] | python | train | 48.25 |
aws/aws-iot-device-sdk-python | AWSIoTPythonSDK/MQTTLib.py | https://github.com/aws/aws-iot-device-sdk-python/blob/f0aa2ce34b21dd2e44f4fb7e1d058656aaf2fc62/AWSIoTPythonSDK/MQTTLib.py#L1021-L1053 | def configureAutoReconnectBackoffTime(self, baseReconnectQuietTimeSecond, maxReconnectQuietTimeSecond, stableConnectionTimeSecond):
"""
**Description**
Used to configure the auto-reconnect backoff timing. Should be called before connect. This is a public
facing API inherited by applicat... | [
"def",
"configureAutoReconnectBackoffTime",
"(",
"self",
",",
"baseReconnectQuietTimeSecond",
",",
"maxReconnectQuietTimeSecond",
",",
"stableConnectionTimeSecond",
")",
":",
"# AWSIoTMQTTClient.configureBackoffTime",
"self",
".",
"_AWSIoTMQTTClient",
".",
"configureAutoReconnectBa... | **Description**
Used to configure the auto-reconnect backoff timing. Should be called before connect. This is a public
facing API inherited by application level public clients.
**Syntax**
.. code:: python
# Configure the auto-reconnect backoff to start with 1 second and use... | [
"**",
"Description",
"**"
] | python | train | 41.878788 |
nanoporetech/ont_fast5_api | ont_fast5_api/helpers.py | https://github.com/nanoporetech/ont_fast5_api/blob/352b3903155fcf4f19234c4f429dcefaa6d6bc4a/ont_fast5_api/helpers.py#L26-L41 | def compare_hdf_files(file1, file2):
""" Compare two hdf files.
:param file1: First file to compare.
:param file2: Second file to compare.
:returns True if they are the same.
"""
data1 = FileToDict()
data2 = FileToDict()
scanner1 = data1.scan
scanner2 = data2.scan
with h5py.File... | [
"def",
"compare_hdf_files",
"(",
"file1",
",",
"file2",
")",
":",
"data1",
"=",
"FileToDict",
"(",
")",
"data2",
"=",
"FileToDict",
"(",
")",
"scanner1",
"=",
"data1",
".",
"scan",
"scanner2",
"=",
"data2",
".",
"scan",
"with",
"h5py",
".",
"File",
"("... | Compare two hdf files.
:param file1: First file to compare.
:param file2: Second file to compare.
:returns True if they are the same. | [
"Compare",
"two",
"hdf",
"files",
".",
":",
"param",
"file1",
":",
"First",
"file",
"to",
"compare",
".",
":",
"param",
"file2",
":",
"Second",
"file",
"to",
"compare",
"."
] | python | train | 29.625 |
orbingol/NURBS-Python | geomdl/_operations.py | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/_operations.py#L41-L57 | def tangent_curve_single_list(obj, param_list, normalize):
""" Evaluates the curve tangent vectors at the given list of parameter values.
:param obj: input curve
:type obj: abstract.Curve
:param param_list: parameter list
:type param_list: list or tuple
:param normalize: if True, the returned v... | [
"def",
"tangent_curve_single_list",
"(",
"obj",
",",
"param_list",
",",
"normalize",
")",
":",
"ret_vector",
"=",
"[",
"]",
"for",
"param",
"in",
"param_list",
":",
"temp",
"=",
"tangent_curve_single",
"(",
"obj",
",",
"param",
",",
"normalize",
")",
"ret_ve... | Evaluates the curve tangent vectors at the given list of parameter values.
:param obj: input curve
:type obj: abstract.Curve
:param param_list: parameter list
:type param_list: list or tuple
:param normalize: if True, the returned vector is converted to a unit vector
:type normalize: bool
:... | [
"Evaluates",
"the",
"curve",
"tangent",
"vectors",
"at",
"the",
"given",
"list",
"of",
"parameter",
"values",
"."
] | python | train | 36.352941 |
flo-compbio/gopca-server | gpserver/cli.py | https://github.com/flo-compbio/gopca-server/blob/4fe396b12c39c0f156ce3bc4538cade54c9d7ffe/gpserver/cli.py#L67-L91 | def add_reporting_args(parser):
"""Add reporting arguments to an argument parser.
Parameters
----------
parser: `argparse.ArgumentParser`
Returns
-------
`argparse.ArgumentGroup`
The argument group created.
"""
g = parser.add_argument_group('Reporting options')
g.add_a... | [
"def",
"add_reporting_args",
"(",
"parser",
")",
":",
"g",
"=",
"parser",
".",
"add_argument_group",
"(",
"'Reporting options'",
")",
"g",
".",
"add_argument",
"(",
"'-l'",
",",
"'--log-file'",
",",
"default",
"=",
"None",
",",
"type",
"=",
"str_type",
",",
... | Add reporting arguments to an argument parser.
Parameters
----------
parser: `argparse.ArgumentParser`
Returns
-------
`argparse.ArgumentGroup`
The argument group created. | [
"Add",
"reporting",
"arguments",
"to",
"an",
"argument",
"parser",
"."
] | python | train | 30.52 |
Microsoft/botbuilder-python | libraries/botbuilder-dialogs/botbuilder/dialogs/dialog_context.py | https://github.com/Microsoft/botbuilder-python/blob/274663dd91c811bae6ac4488915ba5880771b0a7/libraries/botbuilder-dialogs/botbuilder/dialogs/dialog_context.py#L202-L214 | async def replace_dialog(self, dialog_id: str, options: object = None) -> DialogTurnResult:
"""
Ends the active dialog and starts a new dialog in its place. This is particularly useful
for creating loops or redirecting to another dialog.
:param dialog_id: ID of the dialog to search for.
... | [
"async",
"def",
"replace_dialog",
"(",
"self",
",",
"dialog_id",
":",
"str",
",",
"options",
":",
"object",
"=",
"None",
")",
"->",
"DialogTurnResult",
":",
"# End the current dialog and giving the reason.",
"await",
"self",
".",
"end_active_dialog",
"(",
"DialogRea... | Ends the active dialog and starts a new dialog in its place. This is particularly useful
for creating loops or redirecting to another dialog.
:param dialog_id: ID of the dialog to search for.
:param options: (Optional) additional argument(s) to pass to the new dialog.
:return: | [
"Ends",
"the",
"active",
"dialog",
"and",
"starts",
"a",
"new",
"dialog",
"in",
"its",
"place",
".",
"This",
"is",
"particularly",
"useful",
"for",
"creating",
"loops",
"or",
"redirecting",
"to",
"another",
"dialog",
".",
":",
"param",
"dialog_id",
":",
"I... | python | test | 49 |
PSPC-SPAC-buyandsell/von_anchor | von_anchor/wallet/wallet.py | https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/wallet/wallet.py#L546-L565 | async def get_link_secret_label(self) -> str:
"""
Get current link secret label from non-secret storage records; return None for no match.
:return: latest non-secret storage record for link secret label
"""
LOGGER.debug('Wallet.get_link_secret_label >>>')
if not self.h... | [
"async",
"def",
"get_link_secret_label",
"(",
"self",
")",
"->",
"str",
":",
"LOGGER",
".",
"debug",
"(",
"'Wallet.get_link_secret_label >>>'",
")",
"if",
"not",
"self",
".",
"handle",
":",
"LOGGER",
".",
"debug",
"(",
"'Wallet.get_link_secret <!< Wallet %s is close... | Get current link secret label from non-secret storage records; return None for no match.
:return: latest non-secret storage record for link secret label | [
"Get",
"current",
"link",
"secret",
"label",
"from",
"non",
"-",
"secret",
"storage",
"records",
";",
"return",
"None",
"for",
"no",
"match",
"."
] | python | train | 37.75 |
AndrewAnnex/SpiceyPy | spiceypy/spiceypy.py | https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L8106-L8125 | def lstled(x, n, array):
"""
Given a number x and an array of non-decreasing floats
find the index of the largest array element less than or equal to x.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/lstled_c.html
:param x: Value to search against.
:type x: float
:param n: Number ... | [
"def",
"lstled",
"(",
"x",
",",
"n",
",",
"array",
")",
":",
"array",
"=",
"stypes",
".",
"toDoubleVector",
"(",
"array",
")",
"x",
"=",
"ctypes",
".",
"c_double",
"(",
"x",
")",
"n",
"=",
"ctypes",
".",
"c_int",
"(",
"n",
")",
"return",
"libspic... | Given a number x and an array of non-decreasing floats
find the index of the largest array element less than or equal to x.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/lstled_c.html
:param x: Value to search against.
:type x: float
:param n: Number elements in array.
:type n: int
... | [
"Given",
"a",
"number",
"x",
"and",
"an",
"array",
"of",
"non",
"-",
"decreasing",
"floats",
"find",
"the",
"index",
"of",
"the",
"largest",
"array",
"element",
"less",
"than",
"or",
"equal",
"to",
"x",
"."
] | python | train | 32.3 |
saltstack/salt | salt/states/pcs.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/pcs.py#L230-L236 | def _get_cibfile_tmp(cibname):
'''
Get the full path of a temporary CIB-file with the name of the CIB
'''
cibfile_tmp = '{0}.tmp'.format(_get_cibfile(cibname))
log.trace('cibfile_tmp: %s', cibfile_tmp)
return cibfile_tmp | [
"def",
"_get_cibfile_tmp",
"(",
"cibname",
")",
":",
"cibfile_tmp",
"=",
"'{0}.tmp'",
".",
"format",
"(",
"_get_cibfile",
"(",
"cibname",
")",
")",
"log",
".",
"trace",
"(",
"'cibfile_tmp: %s'",
",",
"cibfile_tmp",
")",
"return",
"cibfile_tmp"
] | Get the full path of a temporary CIB-file with the name of the CIB | [
"Get",
"the",
"full",
"path",
"of",
"a",
"temporary",
"CIB",
"-",
"file",
"with",
"the",
"name",
"of",
"the",
"CIB"
] | python | train | 34 |
sanger-pathogens/pymummer | pymummer/alignment.py | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/alignment.py#L52-L58 | def _swap(self):
'''Swaps the alignment so that the reference becomes the query and vice-versa. Swaps their names, coordinates etc. The frame is not changed'''
self.ref_start, self.qry_start = self.qry_start, self.ref_start
self.ref_end, self.qry_end = self.qry_end, self.ref_end
self.hit... | [
"def",
"_swap",
"(",
"self",
")",
":",
"self",
".",
"ref_start",
",",
"self",
".",
"qry_start",
"=",
"self",
".",
"qry_start",
",",
"self",
".",
"ref_start",
"self",
".",
"ref_end",
",",
"self",
".",
"qry_end",
"=",
"self",
".",
"qry_end",
",",
"self... | Swaps the alignment so that the reference becomes the query and vice-versa. Swaps their names, coordinates etc. The frame is not changed | [
"Swaps",
"the",
"alignment",
"so",
"that",
"the",
"reference",
"becomes",
"the",
"query",
"and",
"vice",
"-",
"versa",
".",
"Swaps",
"their",
"names",
"coordinates",
"etc",
".",
"The",
"frame",
"is",
"not",
"changed"
] | python | train | 76.142857 |
Azure/azure-cosmos-python | samples/IndexManagement/Program.py | https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/samples/IndexManagement/Program.py#L428-L512 | def UseRangeIndexesOnStrings(client, database_id):
"""Showing how range queries can be performed even on strings.
"""
try:
DeleteContainerIfExists(client, database_id, COLLECTION_ID)
database_link = GetDatabaseLink(database_id)
# collections = Query_Entities(client, 'collection', pa... | [
"def",
"UseRangeIndexesOnStrings",
"(",
"client",
",",
"database_id",
")",
":",
"try",
":",
"DeleteContainerIfExists",
"(",
"client",
",",
"database_id",
",",
"COLLECTION_ID",
")",
"database_link",
"=",
"GetDatabaseLink",
"(",
"database_id",
")",
"# collections = Quer... | Showing how range queries can be performed even on strings. | [
"Showing",
"how",
"range",
"queries",
"can",
"be",
"performed",
"even",
"on",
"strings",
"."
] | python | train | 41.4 |
hyperledger/sawtooth-core | rest_api/sawtooth_rest_api/error_handlers.py | https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/error_handlers.py#L40-L58 | def check(cls, status):
"""Checks if a status enum matches the trigger originally set, and
if so, raises the appropriate error.
Args:
status (int, enum): A protobuf enum response status to check.
Raises:
AssertionError: If trigger or error were not set.
... | [
"def",
"check",
"(",
"cls",
",",
"status",
")",
":",
"assert",
"cls",
".",
"trigger",
"is",
"not",
"None",
",",
"'Invalid ErrorTrap, trigger not set'",
"assert",
"cls",
".",
"error",
"is",
"not",
"None",
",",
"'Invalid ErrorTrap, error not set'",
"if",
"status",... | Checks if a status enum matches the trigger originally set, and
if so, raises the appropriate error.
Args:
status (int, enum): A protobuf enum response status to check.
Raises:
AssertionError: If trigger or error were not set.
_ApiError: If the statuses don'... | [
"Checks",
"if",
"a",
"status",
"enum",
"matches",
"the",
"trigger",
"originally",
"set",
"and",
"if",
"so",
"raises",
"the",
"appropriate",
"error",
"."
] | python | train | 39.736842 |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/brocade_aaa.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_aaa.py#L794-L810 | def rule_command_cmdlist_interface_o_interface_loopback_leaf_interface_loopback_leaf(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
rule = ET.SubElement(config, "rule", xmlns="urn:brocade.com:mgmt:brocade-aaa")
index_key = ET.SubElement(rule, "index")
... | [
"def",
"rule_command_cmdlist_interface_o_interface_loopback_leaf_interface_loopback_leaf",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"rule",
"=",
"ET",
".",
"SubElement",
"(",
"config",
",",
"\"rul... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 51.882353 |
PyAr/fades | fades/envbuilder.py | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/envbuilder.py#L75-L93 | def create_with_virtualenv(self, interpreter, virtualenv_options):
"""Create a virtualenv using the virtualenv lib."""
args = ['virtualenv', '--python', interpreter, self.env_path]
args.extend(virtualenv_options)
if not self.pip_installed:
args.insert(3, '--no-pip')
t... | [
"def",
"create_with_virtualenv",
"(",
"self",
",",
"interpreter",
",",
"virtualenv_options",
")",
":",
"args",
"=",
"[",
"'virtualenv'",
",",
"'--python'",
",",
"interpreter",
",",
"self",
".",
"env_path",
"]",
"args",
".",
"extend",
"(",
"virtualenv_options",
... | Create a virtualenv using the virtualenv lib. | [
"Create",
"a",
"virtualenv",
"using",
"the",
"virtualenv",
"lib",
"."
] | python | train | 53.421053 |
pyblish/pyblish-maya | pyblish_maya/lib.py | https://github.com/pyblish/pyblish-maya/blob/75db8b5d8de9d53ae95e74195a788b5f6db2cb5f/pyblish_maya/lib.py#L75-L87 | def _discover_gui():
"""Return the most desirable of the currently registered GUIs"""
# Prefer last registered
guis = reversed(pyblish.api.registered_guis())
for gui in guis:
try:
gui = __import__(gui).show
except (ImportError, AttributeError):
continue
... | [
"def",
"_discover_gui",
"(",
")",
":",
"# Prefer last registered",
"guis",
"=",
"reversed",
"(",
"pyblish",
".",
"api",
".",
"registered_guis",
"(",
")",
")",
"for",
"gui",
"in",
"guis",
":",
"try",
":",
"gui",
"=",
"__import__",
"(",
"gui",
")",
".",
... | Return the most desirable of the currently registered GUIs | [
"Return",
"the",
"most",
"desirable",
"of",
"the",
"currently",
"registered",
"GUIs"
] | python | test | 25.846154 |
chaimleib/intervaltree | intervaltree/node.py | https://github.com/chaimleib/intervaltree/blob/ffb2b1667f8b832e89324a75a175be8440504c9d/intervaltree/node.py#L446-L486 | def verify(self, parents=set()):
"""
## DEBUG ONLY ##
Recursively ensures that the invariants of an interval subtree
hold.
"""
assert(isinstance(self.s_center, set))
bal = self.balance
assert abs(bal) < 2, \
"Error: Rotation should have happen... | [
"def",
"verify",
"(",
"self",
",",
"parents",
"=",
"set",
"(",
")",
")",
":",
"assert",
"(",
"isinstance",
"(",
"self",
".",
"s_center",
",",
"set",
")",
")",
"bal",
"=",
"self",
".",
"balance",
"assert",
"abs",
"(",
"bal",
")",
"<",
"2",
",",
... | ## DEBUG ONLY ##
Recursively ensures that the invariants of an interval subtree
hold. | [
"##",
"DEBUG",
"ONLY",
"##",
"Recursively",
"ensures",
"that",
"the",
"invariants",
"of",
"an",
"interval",
"subtree",
"hold",
"."
] | python | train | 39.170732 |
basho/riak-python-client | riak/transports/http/transport.py | https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/transports/http/transport.py#L273-L290 | def set_bucket_props(self, bucket, props):
"""
Set the properties on the bucket object given
"""
bucket_type = self._get_bucket_type(bucket.bucket_type)
url = self.bucket_properties_path(bucket.name,
bucket_type=bucket_type)
heade... | [
"def",
"set_bucket_props",
"(",
"self",
",",
"bucket",
",",
"props",
")",
":",
"bucket_type",
"=",
"self",
".",
"_get_bucket_type",
"(",
"bucket",
".",
"bucket_type",
")",
"url",
"=",
"self",
".",
"bucket_properties_path",
"(",
"bucket",
".",
"name",
",",
... | Set the properties on the bucket object given | [
"Set",
"the",
"properties",
"on",
"the",
"bucket",
"object",
"given"
] | python | train | 39.222222 |
CI-WATER/gsshapy | gsshapy/lib/pivot.py | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/lib/pivot.py#L14-L94 | def pivot(table, left, top, value):
"""
Creates a cross-tab or pivot table from a normalised input table. Use this
function to 'denormalize' a table of normalized records.
* The table argument can be a list of dictionaries or a Table object.
(http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/... | [
"def",
"pivot",
"(",
"table",
",",
"left",
",",
"top",
",",
"value",
")",
":",
"rs",
"=",
"{",
"}",
"ysort",
"=",
"[",
"]",
"xsort",
"=",
"[",
"]",
"for",
"row",
"in",
"table",
":",
"yaxis",
"=",
"tuple",
"(",
"[",
"row",
"[",
"c",
"]",
"fo... | Creates a cross-tab or pivot table from a normalised input table. Use this
function to 'denormalize' a table of normalized records.
* The table argument can be a list of dictionaries or a Table object.
(http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/334621)
* The left argument is a tuple of he... | [
"Creates",
"a",
"cross",
"-",
"tab",
"or",
"pivot",
"table",
"from",
"a",
"normalised",
"input",
"table",
".",
"Use",
"this",
"function",
"to",
"denormalize",
"a",
"table",
"of",
"normalized",
"records",
"."
] | python | train | 29.222222 |
berkeley-cocosci/Wallace | wallace/command_line.py | https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/command_line.py#L724-L799 | def export(app, local):
"""Export the data."""
print_header()
log("Preparing to export the data...")
id = str(app)
subdata_path = os.path.join("data", id, "data")
# Create the data package
os.makedirs(subdata_path)
# Copy the experiment code into a code/ subdirectory
try:
... | [
"def",
"export",
"(",
"app",
",",
"local",
")",
":",
"print_header",
"(",
")",
"log",
"(",
"\"Preparing to export the data...\"",
")",
"id",
"=",
"str",
"(",
"app",
")",
"subdata_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"\"data\"",
",",
"id",
"... | Export the data. | [
"Export",
"the",
"data",
"."
] | python | train | 23.592105 |
Erotemic/utool | utool/util_path.py | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L1907-L1946 | def greplines(lines, regexpr_list, reflags=0):
"""
grepfile - greps a specific file
TODO: move to util_str, rework to be core of grepfile
"""
found_lines = []
found_lxs = []
# Ensure a list
islist = isinstance(regexpr_list, (list, tuple))
islist2 = isinstance(reflags, (list, tuple))... | [
"def",
"greplines",
"(",
"lines",
",",
"regexpr_list",
",",
"reflags",
"=",
"0",
")",
":",
"found_lines",
"=",
"[",
"]",
"found_lxs",
"=",
"[",
"]",
"# Ensure a list",
"islist",
"=",
"isinstance",
"(",
"regexpr_list",
",",
"(",
"list",
",",
"tuple",
")",... | grepfile - greps a specific file
TODO: move to util_str, rework to be core of grepfile | [
"grepfile",
"-",
"greps",
"a",
"specific",
"file"
] | python | train | 34.925 |
materialsproject/pymatgen | pymatgen/analysis/chemenv/utils/coordination_geometry_utils.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/chemenv/utils/coordination_geometry_utils.py#L651-L660 | def is_in_list(self, plane_list):
"""
Checks whether the plane is identical to one of the Planes in the plane_list list of Planes
:param plane_list: List of Planes to be compared to
:return: True if the plane is in the list, False otherwise
"""
for plane in plane_list:
... | [
"def",
"is_in_list",
"(",
"self",
",",
"plane_list",
")",
":",
"for",
"plane",
"in",
"plane_list",
":",
"if",
"self",
".",
"is_same_plane_as",
"(",
"plane",
")",
":",
"return",
"True",
"return",
"False"
] | Checks whether the plane is identical to one of the Planes in the plane_list list of Planes
:param plane_list: List of Planes to be compared to
:return: True if the plane is in the list, False otherwise | [
"Checks",
"whether",
"the",
"plane",
"is",
"identical",
"to",
"one",
"of",
"the",
"Planes",
"in",
"the",
"plane_list",
"list",
"of",
"Planes",
":",
"param",
"plane_list",
":",
"List",
"of",
"Planes",
"to",
"be",
"compared",
"to",
":",
"return",
":",
"Tru... | python | train | 40.2 |
hickeroar/simplebayes | simplebayes/__init__.py | https://github.com/hickeroar/simplebayes/blob/b8da72c50d20b6f8c0df2c2f39620715b08ddd32/simplebayes/__init__.py#L220-L247 | def calculate_bayesian_probability(self, cat, token_score, token_tally):
"""
Calculates the bayesian probability for a given token/category
:param cat: The category we're scoring for this token
:type cat: str
:param token_score: The tally of this token for this category
... | [
"def",
"calculate_bayesian_probability",
"(",
"self",
",",
"cat",
",",
"token_score",
",",
"token_tally",
")",
":",
"# P that any given token IS in this category",
"prc",
"=",
"self",
".",
"probabilities",
"[",
"cat",
"]",
"[",
"'prc'",
"]",
"# P that any given token ... | Calculates the bayesian probability for a given token/category
:param cat: The category we're scoring for this token
:type cat: str
:param token_score: The tally of this token for this category
:type token_score: float
:param token_tally: The tally total for this token from all ... | [
"Calculates",
"the",
"bayesian",
"probability",
"for",
"a",
"given",
"token",
"/",
"category"
] | python | train | 42.392857 |
timothydmorton/isochrones | isochrones/starmodel_old.py | https://github.com/timothydmorton/isochrones/blob/d84495573044c66db2fd6b959fe69e370757ea14/isochrones/starmodel_old.py#L1442-L1470 | def triangle(self, params=None, **kwargs):
"""
Makes a nifty corner plot.
Uses :func:`triangle.corner`.
:param params: (optional)
Names of columns (from :attr:`StarModel.samples`)
to plot. If ``None``, then it will plot samples
of the parameters use... | [
"def",
"triangle",
"(",
"self",
",",
"params",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"params",
"is",
"None",
":",
"params",
"=",
"[",
"'mass_A'",
",",
"'mass_B'",
",",
"'age'",
",",
"'feh'",
",",
"'distance'",
",",
"'AV'",
"]",
"sup... | Makes a nifty corner plot.
Uses :func:`triangle.corner`.
:param params: (optional)
Names of columns (from :attr:`StarModel.samples`)
to plot. If ``None``, then it will plot samples
of the parameters used in the MCMC fit-- that is,
mass, age, [Fe/H], and... | [
"Makes",
"a",
"nifty",
"corner",
"plot",
"."
] | python | train | 32 |
alexa/alexa-skills-kit-sdk-for-python | ask-sdk-core/ask_sdk_core/utils/request_util.py | https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/097b6406aa12d5ca0b825b00c936861b530cbf39/ask-sdk-core/ask_sdk_core/utils/request_util.py#L65-L85 | def get_intent_name(handler_input):
# type: (HandlerInput) -> AnyStr
"""Return the name of the intent request.
The method retrieves the intent ``name`` from the input request, only if
the input request is an
:py:class:`ask_sdk_model.intent_request.IntentRequest`. If the input
is not an IntentRe... | [
"def",
"get_intent_name",
"(",
"handler_input",
")",
":",
"# type: (HandlerInput) -> AnyStr",
"request",
"=",
"handler_input",
".",
"request_envelope",
".",
"request",
"if",
"isinstance",
"(",
"request",
",",
"IntentRequest",
")",
":",
"return",
"request",
".",
"int... | Return the name of the intent request.
The method retrieves the intent ``name`` from the input request, only if
the input request is an
:py:class:`ask_sdk_model.intent_request.IntentRequest`. If the input
is not an IntentRequest, a :py:class:`TypeError` is raised.
:param handler_input: The handler... | [
"Return",
"the",
"name",
"of",
"the",
"intent",
"request",
"."
] | python | train | 39.333333 |
msmbuilder/msmbuilder | basesetup.py | https://github.com/msmbuilder/msmbuilder/blob/556a93a170782f47be53f4a1e9d740fb1c8272b3/basesetup.py#L210-L217 | def _detect_sse3(self):
"Does this compiler support SSE3 intrinsics?"
self._print_support_start('SSE3')
result = self.hasfunction('__m128 v; _mm_hadd_ps(v,v)',
include='<pmmintrin.h>',
extra_postargs=['-msse3'])
self._print_support_en... | [
"def",
"_detect_sse3",
"(",
"self",
")",
":",
"self",
".",
"_print_support_start",
"(",
"'SSE3'",
")",
"result",
"=",
"self",
".",
"hasfunction",
"(",
"'__m128 v; _mm_hadd_ps(v,v)'",
",",
"include",
"=",
"'<pmmintrin.h>'",
",",
"extra_postargs",
"=",
"[",
"'-mss... | Does this compiler support SSE3 intrinsics? | [
"Does",
"this",
"compiler",
"support",
"SSE3",
"intrinsics?"
] | python | train | 44 |
pallets/werkzeug | examples/simplewiki/actions.py | https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/examples/simplewiki/actions.py#L96-L139 | def on_diff(request, page_name):
"""Show the diff between two revisions."""
old = request.args.get("old", type=int)
new = request.args.get("new", type=int)
error = ""
diff = page = old_rev = new_rev = None
if not (old and new):
error = "No revisions specified."
else:
revisio... | [
"def",
"on_diff",
"(",
"request",
",",
"page_name",
")",
":",
"old",
"=",
"request",
".",
"args",
".",
"get",
"(",
"\"old\"",
",",
"type",
"=",
"int",
")",
"new",
"=",
"request",
".",
"args",
".",
"get",
"(",
"\"new\"",
",",
"type",
"=",
"int",
"... | Show the diff between two revisions. | [
"Show",
"the",
"diff",
"between",
"two",
"revisions",
"."
] | python | train | 30.431818 |
saltstack/salt | salt/spm/__init__.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/spm/__init__.py#L983-L993 | def _list_packages(self, args):
'''
List files for an installed package
'''
packages = self._pkgdb_fun('list_packages', self.db_conn)
for package in packages:
if self.opts['verbose']:
status_msg = ','.join(package)
else:
sta... | [
"def",
"_list_packages",
"(",
"self",
",",
"args",
")",
":",
"packages",
"=",
"self",
".",
"_pkgdb_fun",
"(",
"'list_packages'",
",",
"self",
".",
"db_conn",
")",
"for",
"package",
"in",
"packages",
":",
"if",
"self",
".",
"opts",
"[",
"'verbose'",
"]",
... | List files for an installed package | [
"List",
"files",
"for",
"an",
"installed",
"package"
] | python | train | 33.545455 |
ambitioninc/django-activatable-model | activatable_model/validation.py | https://github.com/ambitioninc/django-activatable-model/blob/2c142430949a923a69201f4914a6b73a642b4b48/activatable_model/validation.py#L14-L43 | def validate_activatable_models():
"""
Raises a ValidationError for any ActivatableModel that has ForeignKeys or OneToOneFields that will
cause cascading deletions to occur. This function also raises a ValidationError if the activatable
model has not defined a Boolean field with the field name defined b... | [
"def",
"validate_activatable_models",
"(",
")",
":",
"for",
"model",
"in",
"get_activatable_models",
"(",
")",
":",
"# Verify the activatable model has an activatable boolean field",
"activatable_field",
"=",
"next",
"(",
"(",
"f",
"for",
"f",
"in",
"model",
".",
"_me... | Raises a ValidationError for any ActivatableModel that has ForeignKeys or OneToOneFields that will
cause cascading deletions to occur. This function also raises a ValidationError if the activatable
model has not defined a Boolean field with the field name defined by the ACTIVATABLE_FIELD_NAME variable
on th... | [
"Raises",
"a",
"ValidationError",
"for",
"any",
"ActivatableModel",
"that",
"has",
"ForeignKeys",
"or",
"OneToOneFields",
"that",
"will",
"cause",
"cascading",
"deletions",
"to",
"occur",
".",
"This",
"function",
"also",
"raises",
"a",
"ValidationError",
"if",
"th... | python | valid | 59.933333 |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Action.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Action.py#L284-L329 | def _function_contents(func):
"""
The signature is as follows (should be byte/chars):
< _code_contents (see above) from func.__code__ >
,( comma separated _object_contents for function argument defaults)
,( comma separated _object_contents for any closure contents )
See also: https://docs.pyth... | [
"def",
"_function_contents",
"(",
"func",
")",
":",
"contents",
"=",
"[",
"_code_contents",
"(",
"func",
".",
"__code__",
",",
"func",
".",
"__doc__",
")",
"]",
"# The function contents depends on the value of defaults arguments",
"if",
"func",
".",
"__defaults__",
... | The signature is as follows (should be byte/chars):
< _code_contents (see above) from func.__code__ >
,( comma separated _object_contents for function argument defaults)
,( comma separated _object_contents for any closure contents )
See also: https://docs.python.org/3/reference/datamodel.html
- ... | [
"The",
"signature",
"is",
"as",
"follows",
"(",
"should",
"be",
"byte",
"/",
"chars",
")",
":",
"<",
"_code_contents",
"(",
"see",
"above",
")",
"from",
"func",
".",
"__code__",
">",
"(",
"comma",
"separated",
"_object_contents",
"for",
"function",
"argume... | python | train | 35.521739 |
python-constraint/python-constraint | constraint/__init__.py | https://github.com/python-constraint/python-constraint/blob/e23fe9852cddddf1c3e258e03f2175df24b4c702/constraint/__init__.py#L212-L231 | def getSolution(self):
"""
Find and return a solution to the problem
Example:
>>> problem = Problem()
>>> problem.getSolution() is None
True
>>> problem.addVariables(["a"], [42])
>>> problem.getSolution()
{'a': 42}
@return: Solution for ... | [
"def",
"getSolution",
"(",
"self",
")",
":",
"domains",
",",
"constraints",
",",
"vconstraints",
"=",
"self",
".",
"_getArgs",
"(",
")",
"if",
"not",
"domains",
":",
"return",
"None",
"return",
"self",
".",
"_solver",
".",
"getSolution",
"(",
"domains",
... | Find and return a solution to the problem
Example:
>>> problem = Problem()
>>> problem.getSolution() is None
True
>>> problem.addVariables(["a"], [42])
>>> problem.getSolution()
{'a': 42}
@return: Solution for the problem
@rtype: dictionary mapp... | [
"Find",
"and",
"return",
"a",
"solution",
"to",
"the",
"problem"
] | python | train | 28.2 |
rodricios/eatiht | eatiht/eatiht_trees.py | https://github.com/rodricios/eatiht/blob/7341c46327cfe7e0c9f226ef5e9808975c4d43da/eatiht/eatiht_trees.py#L228-L250 | def __make_tree(self):
"""Build a tree using lxml.html.builder and our subtrees"""
# create div with "container" class
div = E.DIV(E.CLASS("container"))
# append header with title
div.append(E.H2(self.__title))
# next, iterate through subtrees appending each t... | [
"def",
"__make_tree",
"(",
"self",
")",
":",
"# create div with \"container\" class\r",
"div",
"=",
"E",
".",
"DIV",
"(",
"E",
".",
"CLASS",
"(",
"\"container\"",
")",
")",
"# append header with title\r",
"div",
".",
"append",
"(",
"E",
".",
"H2",
"(",
"self... | Build a tree using lxml.html.builder and our subtrees | [
"Build",
"a",
"tree",
"using",
"lxml",
".",
"html",
".",
"builder",
"and",
"our",
"subtrees"
] | python | train | 27.608696 |
PmagPy/PmagPy | pmagpy/builder2.py | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/builder2.py#L365-L385 | def add_site(self, site_name, location_name=None, er_data=None, pmag_data=None):
"""
Create a Site object and add it to self.sites.
If a location name is provided, add the site to location.sites as well.
"""
if location_name:
location = self.find_by_name(location_name... | [
"def",
"add_site",
"(",
"self",
",",
"site_name",
",",
"location_name",
"=",
"None",
",",
"er_data",
"=",
"None",
",",
"pmag_data",
"=",
"None",
")",
":",
"if",
"location_name",
":",
"location",
"=",
"self",
".",
"find_by_name",
"(",
"location_name",
",",
... | Create a Site object and add it to self.sites.
If a location name is provided, add the site to location.sites as well. | [
"Create",
"a",
"Site",
"object",
"and",
"add",
"it",
"to",
"self",
".",
"sites",
".",
"If",
"a",
"location",
"name",
"is",
"provided",
"add",
"the",
"site",
"to",
"location",
".",
"sites",
"as",
"well",
"."
] | python | train | 39.571429 |
Qiskit/qiskit-terra | qiskit/quantum_info/operators/base_operator.py | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/base_operator.py#L195-L217 | def power(self, n):
"""Return the compose of a operator with itself n times.
Args:
n (int): the number of times to compose with self (n>0).
Returns:
BaseOperator: the n-times composed operator.
Raises:
QiskitError: if the input and output dimensions... | [
"def",
"power",
"(",
"self",
",",
"n",
")",
":",
"# NOTE: if a subclass can have negative or non-integer powers",
"# this method should be overriden in that class.",
"if",
"not",
"isinstance",
"(",
"n",
",",
"(",
"int",
",",
"np",
".",
"integer",
")",
")",
"or",
"n"... | Return the compose of a operator with itself n times.
Args:
n (int): the number of times to compose with self (n>0).
Returns:
BaseOperator: the n-times composed operator.
Raises:
QiskitError: if the input and output dimensions of the operator
ar... | [
"Return",
"the",
"compose",
"of",
"a",
"operator",
"with",
"itself",
"n",
"times",
"."
] | python | test | 38.782609 |
vaexio/vaex | packages/vaex-core/vaex/dataframe.py | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/dataframe.py#L3207-L3224 | def add_virtual_columns_aitoff(self, alpha, delta, x, y, radians=True):
"""Add aitoff (https://en.wikipedia.org/wiki/Aitoff_projection) projection
:param alpha: azimuth angle
:param delta: polar angle
:param x: output name for x coordinate
:param y: output name for y coordinate
... | [
"def",
"add_virtual_columns_aitoff",
"(",
"self",
",",
"alpha",
",",
"delta",
",",
"x",
",",
"y",
",",
"radians",
"=",
"True",
")",
":",
"transform",
"=",
"\"\"",
"if",
"radians",
"else",
"\"*pi/180.\"",
"aitoff_alpha",
"=",
"\"__aitoff_alpha_%s_%s\"",
"%",
... | Add aitoff (https://en.wikipedia.org/wiki/Aitoff_projection) projection
:param alpha: azimuth angle
:param delta: polar angle
:param x: output name for x coordinate
:param y: output name for y coordinate
:param radians: input and output in radians (True), or degrees (False)
... | [
"Add",
"aitoff",
"(",
"https",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"Aitoff_projection",
")",
"projection"
] | python | test | 54.222222 |
skoczen/inkblock | inkblock/main.py | https://github.com/skoczen/inkblock/blob/099f834c1e9fc0938abaa8824725eeac57603f6c/inkblock/main.py#L1369-L1376 | def scaffold():
"""Start a new site."""
click.echo("A whole new site? Awesome.")
title = click.prompt("What's the title?")
url = click.prompt("Great. What's url? http://")
# Make sure that title doesn't exist.
click.echo("Got it. Creating %s..." % url) | [
"def",
"scaffold",
"(",
")",
":",
"click",
".",
"echo",
"(",
"\"A whole new site? Awesome.\"",
")",
"title",
"=",
"click",
".",
"prompt",
"(",
"\"What's the title?\"",
")",
"url",
"=",
"click",
".",
"prompt",
"(",
"\"Great. What's url? http://\"",
")",
"# Make s... | Start a new site. | [
"Start",
"a",
"new",
"site",
"."
] | python | valid | 33.75 |
openstack/networking-cisco | networking_cisco/apps/saf/server/services/firewall/native/fw_mgr.py | https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fw_mgr.py#L160-L168 | def create_fw(self, proj_name, pol_id, fw_id, fw_name, fw_type, rtr_id):
"""Fills up the local attributes when FW is created. """
self.tenant_name = proj_name
self.fw_id = fw_id
self.fw_name = fw_name
self.fw_created = True
self.active_pol_id = pol_id
self.fw_type... | [
"def",
"create_fw",
"(",
"self",
",",
"proj_name",
",",
"pol_id",
",",
"fw_id",
",",
"fw_name",
",",
"fw_type",
",",
"rtr_id",
")",
":",
"self",
".",
"tenant_name",
"=",
"proj_name",
"self",
".",
"fw_id",
"=",
"fw_id",
"self",
".",
"fw_name",
"=",
"fw_... | Fills up the local attributes when FW is created. | [
"Fills",
"up",
"the",
"local",
"attributes",
"when",
"FW",
"is",
"created",
"."
] | python | train | 39.333333 |
drewsonne/pyum | pyum/rpm.py | https://github.com/drewsonne/pyum/blob/5d2955f86575c9430ab7104211b3d67bd4c0febe/pyum/rpm.py#L101-L108 | def from_url(url):
"""
Given a URL, return a package
:param url:
:return:
"""
package_data = HTTPClient().http_request(url=url, decode=None)
return Package(raw_data=package_data) | [
"def",
"from_url",
"(",
"url",
")",
":",
"package_data",
"=",
"HTTPClient",
"(",
")",
".",
"http_request",
"(",
"url",
"=",
"url",
",",
"decode",
"=",
"None",
")",
"return",
"Package",
"(",
"raw_data",
"=",
"package_data",
")"
] | Given a URL, return a package
:param url:
:return: | [
"Given",
"a",
"URL",
"return",
"a",
"package",
":",
"param",
"url",
":",
":",
"return",
":"
] | python | test | 28.375 |
tensorflow/probability | tensorflow_probability/python/layers/distribution_layer.py | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/layers/distribution_layer.py#L1084-L1103 | def new(params, event_shape=(), validate_args=False, name=None):
"""Create the distribution instance from a `params` vector."""
with tf.compat.v1.name_scope(name, 'IndependentPoisson',
[params, event_shape]):
params = tf.convert_to_tensor(value=params, name='params')
... | [
"def",
"new",
"(",
"params",
",",
"event_shape",
"=",
"(",
")",
",",
"validate_args",
"=",
"False",
",",
"name",
"=",
"None",
")",
":",
"with",
"tf",
".",
"compat",
".",
"v1",
".",
"name_scope",
"(",
"name",
",",
"'IndependentPoisson'",
",",
"[",
"pa... | Create the distribution instance from a `params` vector. | [
"Create",
"the",
"distribution",
"instance",
"from",
"a",
"params",
"vector",
"."
] | python | test | 44.35 |
xtrementl/focus | focus/version.py | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/version.py#L8-L46 | def compare_version(value):
""" Determines if the provided version value compares with program version.
`value`
Version comparison string (e.g. ==1.0, <=1.0, >1.1)
Supported operators:
<, <=, ==, >, >=
"""
# extract parts from value
import re... | [
"def",
"compare_version",
"(",
"value",
")",
":",
"# extract parts from value",
"import",
"re",
"res",
"=",
"re",
".",
"match",
"(",
"r'(<|<=|==|>|>=)(\\d{1,2}\\.\\d{1,2}(\\.\\d{1,2})?)$'",
",",
"str",
"(",
"value",
")",
".",
"strip",
"(",
")",
")",
"if",
"not",... | Determines if the provided version value compares with program version.
`value`
Version comparison string (e.g. ==1.0, <=1.0, >1.1)
Supported operators:
<, <=, ==, >, >= | [
"Determines",
"if",
"the",
"provided",
"version",
"value",
"compares",
"with",
"program",
"version",
"."
] | python | train | 23.974359 |
adamreeve/npTDMS | nptdms/tdms.py | https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L359-L423 | def read_metadata(self, f, objects, previous_segment=None):
"""Read segment metadata section and update object information"""
if not self.toc["kTocMetaData"]:
try:
self.ordered_objects = previous_segment.ordered_objects
except AttributeError:
rais... | [
"def",
"read_metadata",
"(",
"self",
",",
"f",
",",
"objects",
",",
"previous_segment",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"toc",
"[",
"\"kTocMetaData\"",
"]",
":",
"try",
":",
"self",
".",
"ordered_objects",
"=",
"previous_segment",
".",
"... | Read segment metadata section and update object information | [
"Read",
"segment",
"metadata",
"section",
"and",
"update",
"object",
"information"
] | python | train | 44.476923 |
aio-libs/aioodbc | aioodbc/cursor.py | https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/cursor.py#L124-L132 | def executemany(self, sql, *params):
"""Prepare a database query or command and then execute it against
all parameter sequences found in the sequence seq_of_params.
:param sql: the SQL statement to execute with optional ? parameters
:param params: sequence parameters for the markers in... | [
"def",
"executemany",
"(",
"self",
",",
"sql",
",",
"*",
"params",
")",
":",
"fut",
"=",
"self",
".",
"_run_operation",
"(",
"self",
".",
"_impl",
".",
"executemany",
",",
"sql",
",",
"*",
"params",
")",
"return",
"fut"
] | Prepare a database query or command and then execute it against
all parameter sequences found in the sequence seq_of_params.
:param sql: the SQL statement to execute with optional ? parameters
:param params: sequence parameters for the markers in the SQL. | [
"Prepare",
"a",
"database",
"query",
"or",
"command",
"and",
"then",
"execute",
"it",
"against",
"all",
"parameter",
"sequences",
"found",
"in",
"the",
"sequence",
"seq_of_params",
"."
] | python | train | 47.111111 |
vhf/confusable_homoglyphs | confusable_homoglyphs/cli.py | https://github.com/vhf/confusable_homoglyphs/blob/14f43ddd74099520ddcda29fac557c27a28190e6/confusable_homoglyphs/cli.py#L70-L95 | def generate_confusables():
"""Generates the confusables JSON data file from the unicode specification.
:return: True for success, raises otherwise.
:rtype: bool
"""
url = 'ftp://ftp.unicode.org/Public/security/latest/confusables.txt'
file = get(url)
confusables_matrix = defaultdict(list)
... | [
"def",
"generate_confusables",
"(",
")",
":",
"url",
"=",
"'ftp://ftp.unicode.org/Public/security/latest/confusables.txt'",
"file",
"=",
"get",
"(",
"url",
")",
"confusables_matrix",
"=",
"defaultdict",
"(",
"list",
")",
"match",
"=",
"re",
".",
"compile",
"(",
"r... | Generates the confusables JSON data file from the unicode specification.
:return: True for success, raises otherwise.
:rtype: bool | [
"Generates",
"the",
"confusables",
"JSON",
"data",
"file",
"from",
"the",
"unicode",
"specification",
"."
] | python | train | 33.538462 |
square/pylink | pylink/unlockers/unlock_kinetis.py | https://github.com/square/pylink/blob/81dda0a191d923a8b2627c52cb778aba24d279d7/pylink/unlockers/unlock_kinetis.py#L54-L65 | def unlock_kinetis_abort_clear():
"""Returns the abort register clear code.
Returns:
The abort register clear code.
"""
flags = registers.AbortRegisterFlags()
flags.STKCMPCLR = 1
flags.STKERRCLR = 1
flags.WDERRCLR = 1
flags.ORUNERRCLR = 1
return flags.value | [
"def",
"unlock_kinetis_abort_clear",
"(",
")",
":",
"flags",
"=",
"registers",
".",
"AbortRegisterFlags",
"(",
")",
"flags",
".",
"STKCMPCLR",
"=",
"1",
"flags",
".",
"STKERRCLR",
"=",
"1",
"flags",
".",
"WDERRCLR",
"=",
"1",
"flags",
".",
"ORUNERRCLR",
"=... | Returns the abort register clear code.
Returns:
The abort register clear code. | [
"Returns",
"the",
"abort",
"register",
"clear",
"code",
"."
] | python | train | 24.083333 |
robhowley/nhlscrapi | nhlscrapi/scrapr/rosterrep.py | https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/scrapr/rosterrep.py#L116-L131 | def parse_coaches(self):
"""
Parse the home and away coaches
:returns: ``self`` on success, ``None`` otherwise
"""
lx_doc = self.html_doc()
tr = lx_doc.xpath('//tr[@id="HeadCoaches"]')[0]
for i, td in enumerate(tr):
txt = td.xpath('.//text()')
... | [
"def",
"parse_coaches",
"(",
"self",
")",
":",
"lx_doc",
"=",
"self",
".",
"html_doc",
"(",
")",
"tr",
"=",
"lx_doc",
".",
"xpath",
"(",
"'//tr[@id=\"HeadCoaches\"]'",
")",
"[",
"0",
"]",
"for",
"i",
",",
"td",
"in",
"enumerate",
"(",
"tr",
")",
":",... | Parse the home and away coaches
:returns: ``self`` on success, ``None`` otherwise | [
"Parse",
"the",
"home",
"and",
"away",
"coaches"
] | python | train | 29.8125 |
log2timeline/dfvfs | dfvfs/file_io/sqlite_blob_file_io.py | https://github.com/log2timeline/dfvfs/blob/2b3ccd115f9901d89f383397d4a1376a873c83c4/dfvfs/file_io/sqlite_blob_file_io.py#L159-L176 | def GetNumberOfRows(self):
"""Retrieves the number of rows of the table.
Returns:
int: number of rows.
Raises:
IOError: if the file-like object has not been opened.
OSError: if the file-like object has not been opened.
"""
if not self._database_object:
raise IOError('Not op... | [
"def",
"GetNumberOfRows",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_database_object",
":",
"raise",
"IOError",
"(",
"'Not opened.'",
")",
"if",
"self",
".",
"_number_of_rows",
"is",
"None",
":",
"self",
".",
"_number_of_rows",
"=",
"self",
".",
"_... | Retrieves the number of rows of the table.
Returns:
int: number of rows.
Raises:
IOError: if the file-like object has not been opened.
OSError: if the file-like object has not been opened. | [
"Retrieves",
"the",
"number",
"of",
"rows",
"of",
"the",
"table",
"."
] | python | train | 26.5 |
ajdavis/mongo-mockup-db | mockupdb/__init__.py | https://github.com/ajdavis/mongo-mockup-db/blob/ff8a3f793def59e9037397ef60607fbda6949dac/mockupdb/__init__.py#L422-L430 | def assert_matches(self, *args, **kwargs):
"""Assert this matches a :ref:`message spec <message spec>`.
Returns self.
"""
matcher = make_matcher(*args, **kwargs)
if not matcher.matches(self):
raise AssertionError('%r does not match %r' % (self, matcher))
retu... | [
"def",
"assert_matches",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"matcher",
"=",
"make_matcher",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"not",
"matcher",
".",
"matches",
"(",
"self",
")",
":",
"raise",
"Asse... | Assert this matches a :ref:`message spec <message spec>`.
Returns self. | [
"Assert",
"this",
"matches",
"a",
":",
"ref",
":",
"message",
"spec",
"<message",
"spec",
">",
"."
] | python | train | 35.444444 |
dmwm/DBS | Client/src/python/dbs/apis/dbsClient.py | https://github.com/dmwm/DBS/blob/9619bafce3783b3e77f0415f8f9a258e33dd1e6f/Client/src/python/dbs/apis/dbsClient.py#L776-L802 | def listDatasetArray(self, **kwargs):
"""
API to list datasets in DBS.
:param dataset: list of datasets [dataset1,dataset2,..,dataset n] (Required if dataset_id is not presented), Max length 1000.
:type dataset: list
:param dataset_id: list of dataset_ids that are the primary ke... | [
"def",
"listDatasetArray",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"validParameters",
"=",
"[",
"'dataset'",
",",
"'dataset_access_type'",
",",
"'detail'",
",",
"'dataset_id'",
"]",
"requiredParameters",
"=",
"{",
"'multiple'",
":",
"[",
"'dataset'",
"... | API to list datasets in DBS.
:param dataset: list of datasets [dataset1,dataset2,..,dataset n] (Required if dataset_id is not presented), Max length 1000.
:type dataset: list
:param dataset_id: list of dataset_ids that are the primary keys of datasets table: [dataset_id1,dataset_id2,..,dataset_... | [
"API",
"to",
"list",
"datasets",
"in",
"DBS",
"."
] | python | train | 60.481481 |
DataBiosphere/dsub | dsub/lib/job_model.py | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/job_model.py#L105-L113 | def validate_param_name(name, param_type):
"""Validate that the name follows posix conventions for env variables."""
# http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_235
#
# 3.235 Name
# In the shell command language, a word consisting solely of underscores,
# digits, and alp... | [
"def",
"validate_param_name",
"(",
"name",
",",
"param_type",
")",
":",
"# http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_235",
"#",
"# 3.235 Name",
"# In the shell command language, a word consisting solely of underscores,",
"# digits, and alphabetics from th... | Validate that the name follows posix conventions for env variables. | [
"Validate",
"that",
"the",
"name",
"follows",
"posix",
"conventions",
"for",
"env",
"variables",
"."
] | python | valid | 51.888889 |
samfoo/vt102 | vt102/__init__.py | https://github.com/samfoo/vt102/blob/ff5be883bc9a880a422b09bb87b210d7c408cf2c/vt102/__init__.py#L765-L770 | def _cursor_down(self, count=1):
"""
Moves cursor down count lines in same column. Cursor stops at bottom
margin.
"""
self.y = min(self.size[0] - 1, self.y + count) | [
"def",
"_cursor_down",
"(",
"self",
",",
"count",
"=",
"1",
")",
":",
"self",
".",
"y",
"=",
"min",
"(",
"self",
".",
"size",
"[",
"0",
"]",
"-",
"1",
",",
"self",
".",
"y",
"+",
"count",
")"
] | Moves cursor down count lines in same column. Cursor stops at bottom
margin. | [
"Moves",
"cursor",
"down",
"count",
"lines",
"in",
"same",
"column",
".",
"Cursor",
"stops",
"at",
"bottom",
"margin",
"."
] | python | train | 33.333333 |
limodou/uliweb | uliweb/orm/__init__.py | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/orm/__init__.py#L732-L799 | def save_file(result, filename, encoding='utf8', headers=None,
convertors=None, visitor=None, writer=None, **kwargs):
"""
save query result to a csv file
visitor can used to convert values, all value should be convert to string
visitor function should be defined as:
def visitor(key... | [
"def",
"save_file",
"(",
"result",
",",
"filename",
",",
"encoding",
"=",
"'utf8'",
",",
"headers",
"=",
"None",
",",
"convertors",
"=",
"None",
",",
"visitor",
"=",
"None",
",",
"writer",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"os... | save query result to a csv file
visitor can used to convert values, all value should be convert to string
visitor function should be defined as:
def visitor(keys, values, encoding):
#return new values []
convertors is used to convert single column value, for example:
... | [
"save",
"query",
"result",
"to",
"a",
"csv",
"file",
"visitor",
"can",
"used",
"to",
"convert",
"values",
"all",
"value",
"should",
"be",
"convert",
"to",
"string",
"visitor",
"function",
"should",
"be",
"defined",
"as",
":",
"def",
"visitor",
"(",
"keys",... | python | train | 31.147059 |
bfontaine/p7magma | magma/souputils.py | https://github.com/bfontaine/p7magma/blob/713647aa9e3187c93c2577ef812f33ec42ae5494/magma/souputils.py#L8-L18 | def text(el, strip=True):
"""
Return the text of a ``BeautifulSoup`` element
"""
if not el:
return ""
text = el.text
if strip:
text = text.strip()
return text | [
"def",
"text",
"(",
"el",
",",
"strip",
"=",
"True",
")",
":",
"if",
"not",
"el",
":",
"return",
"\"\"",
"text",
"=",
"el",
".",
"text",
"if",
"strip",
":",
"text",
"=",
"text",
".",
"strip",
"(",
")",
"return",
"text"
] | Return the text of a ``BeautifulSoup`` element | [
"Return",
"the",
"text",
"of",
"a",
"BeautifulSoup",
"element"
] | python | train | 17.545455 |
monarch-initiative/dipper | dipper/sources/IMPC.py | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/IMPC.py#L552-L642 | def _add_study_provenance(
self,
phenotyping_center,
colony,
project_fullname,
pipeline_name,
pipeline_stable_id,
procedure_stable_id,
procedure_name,
parameter_stable_id,
parameter_name,
... | [
"def",
"_add_study_provenance",
"(",
"self",
",",
"phenotyping_center",
",",
"colony",
",",
"project_fullname",
",",
"pipeline_name",
",",
"pipeline_stable_id",
",",
"procedure_stable_id",
",",
"procedure_name",
",",
"parameter_stable_id",
",",
"parameter_name",
",",
"s... | :param phenotyping_center: str, from self.files['all']
:param colony: str, from self.files['all']
:param project_fullname: str, from self.files['all']
:param pipeline_name: str, from self.files['all']
:param pipeline_stable_id: str, from self.files['all']
:param procedure_stable_... | [
":",
"param",
"phenotyping_center",
":",
"str",
"from",
"self",
".",
"files",
"[",
"all",
"]",
":",
"param",
"colony",
":",
"str",
"from",
"self",
".",
"files",
"[",
"all",
"]",
":",
"param",
"project_fullname",
":",
"str",
"from",
"self",
".",
"files"... | python | train | 36.395604 |
ansible/tower-cli | tower_cli/cli/action.py | https://github.com/ansible/tower-cli/blob/a2b151fed93c47725018d3034848cb3a1814bed7/tower_cli/cli/action.py#L33-L46 | def parse_args(self, ctx, args):
"""Parse arguments sent to this command.
The code for this method is taken from MultiCommand:
https://github.com/mitsuhiko/click/blob/master/click/core.py
It is Copyright (c) 2014 by Armin Ronacher.
See the license:
https://github.com/mi... | [
"def",
"parse_args",
"(",
"self",
",",
"ctx",
",",
"args",
")",
":",
"if",
"not",
"args",
"and",
"self",
".",
"no_args_is_help",
"and",
"not",
"ctx",
".",
"resilient_parsing",
":",
"click",
".",
"echo",
"(",
"ctx",
".",
"get_help",
"(",
")",
")",
"ct... | Parse arguments sent to this command.
The code for this method is taken from MultiCommand:
https://github.com/mitsuhiko/click/blob/master/click/core.py
It is Copyright (c) 2014 by Armin Ronacher.
See the license:
https://github.com/mitsuhiko/click/blob/master/LICENSE | [
"Parse",
"arguments",
"sent",
"to",
"this",
"command",
"."
] | python | valid | 39.785714 |
saltstack/salt | salt/modules/vsphere.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/vsphere.py#L5964-L6008 | def list_disks(disk_ids=None, scsi_addresses=None, service_instance=None):
'''
Returns a list of dict representations of the disks in an ESXi host.
The list of disks can be filtered by disk canonical names or
scsi addresses.
disk_ids:
List of disk canonical names to be retrieved. Default is... | [
"def",
"list_disks",
"(",
"disk_ids",
"=",
"None",
",",
"scsi_addresses",
"=",
"None",
",",
"service_instance",
"=",
"None",
")",
":",
"host_ref",
"=",
"_get_proxy_target",
"(",
"service_instance",
")",
"hostname",
"=",
"__proxy__",
"[",
"'esxi.get_details'",
"]... | Returns a list of dict representations of the disks in an ESXi host.
The list of disks can be filtered by disk canonical names or
scsi addresses.
disk_ids:
List of disk canonical names to be retrieved. Default is None.
scsi_addresses
List of scsi addresses of disks to be retrieved. Def... | [
"Returns",
"a",
"list",
"of",
"dict",
"representations",
"of",
"the",
"disks",
"in",
"an",
"ESXi",
"host",
".",
"The",
"list",
"of",
"disks",
"can",
"be",
"filtered",
"by",
"disk",
"canonical",
"names",
"or",
"scsi",
"addresses",
"."
] | python | train | 38.155556 |
push-things/django-th | django_th/api/consumer.py | https://github.com/push-things/django-th/blob/86c999d16bcf30b6224206e5b40824309834ac8c/django_th/api/consumer.py#L5-L24 | def save_data(trigger_id, data):
"""
call the consumer and handle the data
:param trigger_id:
:param data:
:return:
"""
status = True
# consumer - the service which uses the data
default_provider.load_services()
service = TriggerService.objects.get(id=trigger_id)
... | [
"def",
"save_data",
"(",
"trigger_id",
",",
"data",
")",
":",
"status",
"=",
"True",
"# consumer - the service which uses the data",
"default_provider",
".",
"load_services",
"(",
")",
"service",
"=",
"TriggerService",
".",
"objects",
".",
"get",
"(",
"id",
"=",
... | call the consumer and handle the data
:param trigger_id:
:param data:
:return: | [
"call",
"the",
"consumer",
"and",
"handle",
"the",
"data",
":",
"param",
"trigger_id",
":",
":",
"param",
"data",
":",
":",
"return",
":"
] | python | train | 31 |
GNS3/gns3-server | gns3server/compute/iou/iou_vm.py | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/iou/iou_vm.py#L441-L445 | def _nvram_file(self):
"""
Path to the nvram file
"""
return os.path.join(self.working_dir, "nvram_{:05d}".format(self.application_id)) | [
"def",
"_nvram_file",
"(",
"self",
")",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"working_dir",
",",
"\"nvram_{:05d}\"",
".",
"format",
"(",
"self",
".",
"application_id",
")",
")"
] | Path to the nvram file | [
"Path",
"to",
"the",
"nvram",
"file"
] | python | train | 32.6 |
yyuu/botornado | boto/s3/key.py | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/s3/key.py#L904-L970 | def set_contents_from_filename(self, filename, headers=None, replace=True,
cb=None, num_cb=10, policy=None, md5=None,
reduced_redundancy=False,
encrypt_key=False):
"""
Store an object in S3 using the... | [
"def",
"set_contents_from_filename",
"(",
"self",
",",
"filename",
",",
"headers",
"=",
"None",
",",
"replace",
"=",
"True",
",",
"cb",
"=",
"None",
",",
"num_cb",
"=",
"10",
",",
"policy",
"=",
"None",
",",
"md5",
"=",
"None",
",",
"reduced_redundancy",... | Store an object in S3 using the name of the Key object as the
key in S3 and the contents of the file named by 'filename'.
See set_contents_from_file method for details about the
parameters.
:type filename: string
:param filename: The name of the file that you want to put onto S3... | [
"Store",
"an",
"object",
"in",
"S3",
"using",
"the",
"name",
"of",
"the",
"Key",
"object",
"as",
"the",
"key",
"in",
"S3",
"and",
"the",
"contents",
"of",
"the",
"file",
"named",
"by",
"filename",
".",
"See",
"set_contents_from_file",
"method",
"for",
"d... | python | train | 49.731343 |
tagcubeio/tagcube-cli | tagcube_cli/utils.py | https://github.com/tagcubeio/tagcube-cli/blob/709e4b0b11331a4d2791dc79107e5081518d75bf/tagcube_cli/utils.py#L205-L231 | def path_file_to_list(path_file):
"""
:return: A list with the paths which are stored in a text file in a line-by-
line format. Validate each path using is_valid_path
"""
paths = []
path_file_fd = file(path_file)
for line_no, line in enumerate(path_file_fd.readlines(), start=1):
... | [
"def",
"path_file_to_list",
"(",
"path_file",
")",
":",
"paths",
"=",
"[",
"]",
"path_file_fd",
"=",
"file",
"(",
"path_file",
")",
"for",
"line_no",
",",
"line",
"in",
"enumerate",
"(",
"path_file_fd",
".",
"readlines",
"(",
")",
",",
"start",
"=",
"1",... | :return: A list with the paths which are stored in a text file in a line-by-
line format. Validate each path using is_valid_path | [
":",
"return",
":",
"A",
"list",
"with",
"the",
"paths",
"which",
"are",
"stored",
"in",
"a",
"text",
"file",
"in",
"a",
"line",
"-",
"by",
"-",
"line",
"format",
".",
"Validate",
"each",
"path",
"using",
"is_valid_path"
] | python | train | 26.444444 |
4Catalyzer/flask-resty | flask_resty/spec/operation.py | https://github.com/4Catalyzer/flask-resty/blob/a8b6502a799c270ca9ce41c6d8b7297713942097/flask_resty/spec/operation.py#L12-L20 | def add_parameter(self, location='query', **kwargs):
"""Adds a new parameter to the request
:param location: the 'in' field of the parameter (e.g: 'query',
'body', 'path')
"""
kwargs.setdefault('in', location)
if kwargs['in'] != 'body':
kwargs.setdefault('... | [
"def",
"add_parameter",
"(",
"self",
",",
"location",
"=",
"'query'",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'in'",
",",
"location",
")",
"if",
"kwargs",
"[",
"'in'",
"]",
"!=",
"'body'",
":",
"kwargs",
".",
"setdefault",... | Adds a new parameter to the request
:param location: the 'in' field of the parameter (e.g: 'query',
'body', 'path') | [
"Adds",
"a",
"new",
"parameter",
"to",
"the",
"request",
":",
"param",
"location",
":",
"the",
"in",
"field",
"of",
"the",
"parameter",
"(",
"e",
".",
"g",
":",
"query",
"body",
"path",
")"
] | python | train | 41.111111 |
maxfischer2781/include | include/__init__.py | https://github.com/maxfischer2781/include/blob/d8b0404f4996b6abcd39fdebf282b31fad8bb6f5/include/__init__.py#L81-L91 | def enable(identifier, exclude_children=False):
"""
Enable a previously disabled include type
:param identifier: module or name of the include type
:param exclude_children: disable the include type only for child processes, not the current process
The ``identifier`` can be specified in multiple wa... | [
"def",
"enable",
"(",
"identifier",
",",
"exclude_children",
"=",
"False",
")",
":",
"DISABLED_TYPES",
".",
"enable",
"(",
"identifier",
"=",
"identifier",
",",
"exclude_children",
"=",
"exclude_children",
")"
] | Enable a previously disabled include type
:param identifier: module or name of the include type
:param exclude_children: disable the include type only for child processes, not the current process
The ``identifier`` can be specified in multiple ways to disable an include type.
See :py:meth:`~.DisabledI... | [
"Enable",
"a",
"previously",
"disabled",
"include",
"type"
] | python | train | 45 |
J535D165/recordlinkage | recordlinkage/classifiers.py | https://github.com/J535D165/recordlinkage/blob/87a5f4af904e0834047cd07ff1c70146b1e6d693/recordlinkage/classifiers.py#L200-L205 | def weights(self):
"""Weights as described in the FS framework."""
m = self.kernel.feature_log_prob_[self._match_class_pos()]
u = self.kernel.feature_log_prob_[self._nonmatch_class_pos()]
return self._prob_inverse_transform(numpy.exp(m - u)) | [
"def",
"weights",
"(",
"self",
")",
":",
"m",
"=",
"self",
".",
"kernel",
".",
"feature_log_prob_",
"[",
"self",
".",
"_match_class_pos",
"(",
")",
"]",
"u",
"=",
"self",
".",
"kernel",
".",
"feature_log_prob_",
"[",
"self",
".",
"_nonmatch_class_pos",
"... | Weights as described in the FS framework. | [
"Weights",
"as",
"described",
"in",
"the",
"FS",
"framework",
"."
] | python | train | 44.833333 |
readbeyond/aeneas | aeneas/globalfunctions.py | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/globalfunctions.py#L123-L133 | def print_warning(msg, color=True):
"""
Print a warning message.
:param string msg: the message
:param bool color: if ``True``, print with POSIX color
"""
if color and is_posix():
safe_print(u"%s[WARN] %s%s" % (ANSI_WARNING, msg, ANSI_END))
else:
safe_print(u"[WARN] %s" % (m... | [
"def",
"print_warning",
"(",
"msg",
",",
"color",
"=",
"True",
")",
":",
"if",
"color",
"and",
"is_posix",
"(",
")",
":",
"safe_print",
"(",
"u\"%s[WARN] %s%s\"",
"%",
"(",
"ANSI_WARNING",
",",
"msg",
",",
"ANSI_END",
")",
")",
"else",
":",
"safe_print",... | Print a warning message.
:param string msg: the message
:param bool color: if ``True``, print with POSIX color | [
"Print",
"a",
"warning",
"message",
"."
] | python | train | 28.545455 |
kajala/django-jutil | jutil/xml.py | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/xml.py#L175-L218 | def dict_to_element(doc: dict, value_key: str='@', attribute_prefix: str='@') -> Element:
"""
Generates XML Element from dict.
Generates complex elements by assuming element attributes are prefixed with '@', and value is stored to plain '@'
in case of complex element. Children are sub-dicts.
For ex... | [
"def",
"dict_to_element",
"(",
"doc",
":",
"dict",
",",
"value_key",
":",
"str",
"=",
"'@'",
",",
"attribute_prefix",
":",
"str",
"=",
"'@'",
")",
"->",
"Element",
":",
"from",
"xml",
".",
"etree",
"import",
"ElementTree",
"as",
"ET",
"if",
"len",
"(",... | Generates XML Element from dict.
Generates complex elements by assuming element attributes are prefixed with '@', and value is stored to plain '@'
in case of complex element. Children are sub-dicts.
For example:
{
'Doc': {
'@version': '1.2',
'A': [{'@clas... | [
"Generates",
"XML",
"Element",
"from",
"dict",
".",
"Generates",
"complex",
"elements",
"by",
"assuming",
"element",
"attributes",
"are",
"prefixed",
"with",
"@",
"and",
"value",
"is",
"stored",
"to",
"plain",
"@",
"in",
"case",
"of",
"complex",
"element",
"... | python | train | 33.977273 |
saltstack/salt | salt/transport/tcp.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/tcp.py#L766-L791 | def handle_stream(self, stream, address):
'''
Handle incoming streams and add messages to the incoming queue
'''
log.trace('Req client %s connected', address)
self.clients.append((stream, address))
unpacker = msgpack.Unpacker()
try:
while True:
... | [
"def",
"handle_stream",
"(",
"self",
",",
"stream",
",",
"address",
")",
":",
"log",
".",
"trace",
"(",
"'Req client %s connected'",
",",
"address",
")",
"self",
".",
"clients",
".",
"append",
"(",
"(",
"stream",
",",
"address",
")",
")",
"unpacker",
"="... | Handle incoming streams and add messages to the incoming queue | [
"Handle",
"incoming",
"streams",
"and",
"add",
"messages",
"to",
"the",
"incoming",
"queue"
] | python | train | 42.038462 |
IBMStreams/pypi.streamsx | streamsx/topology/schema.py | https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/schema.py#L659-L675 | def _fnop_style(schema, op, name):
"""Set an operator's parameter representing the style of this schema."""
if is_common(schema):
if name in op.params:
del op.params[name]
return
if _is_pending(schema):
ntp = 'pending'
elif schema.style... | [
"def",
"_fnop_style",
"(",
"schema",
",",
"op",
",",
"name",
")",
":",
"if",
"is_common",
"(",
"schema",
")",
":",
"if",
"name",
"in",
"op",
".",
"params",
":",
"del",
"op",
".",
"params",
"[",
"name",
"]",
"return",
"if",
"_is_pending",
"(",
"sche... | Set an operator's parameter representing the style of this schema. | [
"Set",
"an",
"operator",
"s",
"parameter",
"representing",
"the",
"style",
"of",
"this",
"schema",
"."
] | python | train | 36.647059 |
Clinical-Genomics/scout | scout/server/blueprints/variants/controllers.py | https://github.com/Clinical-Genomics/scout/blob/90a551e2e1653a319e654c2405c2866f93d0ebb9/scout/server/blueprints/variants/controllers.py#L1165-L1177 | def upload_panel(store, institute_id, case_name, stream):
"""Parse out HGNC symbols from a stream."""
institute_obj, case_obj = institute_and_case(store, institute_id, case_name)
raw_symbols = [line.strip().split('\t')[0] for line in stream if
line and not line.startswith('#')]
# chec... | [
"def",
"upload_panel",
"(",
"store",
",",
"institute_id",
",",
"case_name",
",",
"stream",
")",
":",
"institute_obj",
",",
"case_obj",
"=",
"institute_and_case",
"(",
"store",
",",
"institute_id",
",",
"case_name",
")",
"raw_symbols",
"=",
"[",
"line",
".",
... | Parse out HGNC symbols from a stream. | [
"Parse",
"out",
"HGNC",
"symbols",
"from",
"a",
"stream",
"."
] | python | test | 46.923077 |
inasafe/inasafe | safe/gui/widgets/message_viewer.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/message_viewer.py#L259-L303 | def show_messages(self):
"""Show all messages."""
if isinstance(self.static_message, MessageElement):
# Handle sent Message instance
string = html_header()
if self.static_message is not None:
string += self.static_message.to_html()
# Keep ... | [
"def",
"show_messages",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"static_message",
",",
"MessageElement",
")",
":",
"# Handle sent Message instance",
"string",
"=",
"html_header",
"(",
")",
"if",
"self",
".",
"static_message",
"is",
"not",
... | Show all messages. | [
"Show",
"all",
"messages",
"."
] | python | train | 36.044444 |
markovmodel/PyEMMA | pyemma/util/types.py | https://github.com/markovmodel/PyEMMA/blob/5c3124398217de05ba5ce9c8fb01519222481ab8/pyemma/util/types.py#L121-L128 | def is_bool_matrix(l):
r"""Checks if l is a 2D numpy array of bools
"""
if isinstance(l, np.ndarray):
if l.ndim == 2 and (l.dtype == bool):
return True
return False | [
"def",
"is_bool_matrix",
"(",
"l",
")",
":",
"if",
"isinstance",
"(",
"l",
",",
"np",
".",
"ndarray",
")",
":",
"if",
"l",
".",
"ndim",
"==",
"2",
"and",
"(",
"l",
".",
"dtype",
"==",
"bool",
")",
":",
"return",
"True",
"return",
"False"
] | r"""Checks if l is a 2D numpy array of bools | [
"r",
"Checks",
"if",
"l",
"is",
"a",
"2D",
"numpy",
"array",
"of",
"bools"
] | python | train | 24.25 |
alfred82santa/dirty-models | dirty_models/model_types.py | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/model_types.py#L276-L298 | def export_modifications(self):
"""
Returns list modifications.
"""
if self.__modified_data__ is not None:
return self.export_data()
result = {}
for key, value in enumerate(self.__original_data__):
try:
if not value.is_modified():... | [
"def",
"export_modifications",
"(",
"self",
")",
":",
"if",
"self",
".",
"__modified_data__",
"is",
"not",
"None",
":",
"return",
"self",
".",
"export_data",
"(",
")",
"result",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"enumerate",
"(",
"self",
... | Returns list modifications. | [
"Returns",
"list",
"modifications",
"."
] | python | train | 28.73913 |
lrq3000/pyFileFixity | pyFileFixity/lib/profilers/visual/pympler/classtracker_stats.py | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/classtracker_stats.py#L537-L550 | def relative_path(self, filepath, basepath=None):
"""
Convert the filepath path to a relative path against basepath. By
default basepath is self.basedir.
"""
if basepath is None:
basepath = self.basedir
if not basepath:
return filepath
if f... | [
"def",
"relative_path",
"(",
"self",
",",
"filepath",
",",
"basepath",
"=",
"None",
")",
":",
"if",
"basepath",
"is",
"None",
":",
"basepath",
"=",
"self",
".",
"basedir",
"if",
"not",
"basepath",
":",
"return",
"filepath",
"if",
"filepath",
".",
"starts... | Convert the filepath path to a relative path against basepath. By
default basepath is self.basedir. | [
"Convert",
"the",
"filepath",
"path",
"to",
"a",
"relative",
"path",
"against",
"basepath",
".",
"By",
"default",
"basepath",
"is",
"self",
".",
"basedir",
"."
] | python | train | 32.928571 |
craffel/mir_eval | mir_eval/transcription.py | https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/transcription.py#L757-L829 | def evaluate(ref_intervals, ref_pitches, est_intervals, est_pitches, **kwargs):
"""Compute all metrics for the given reference and estimated annotations.
Examples
--------
>>> ref_intervals, ref_pitches = mir_eval.io.load_valued_intervals(
... 'reference.txt')
>>> est_intervals, est_pitches ... | [
"def",
"evaluate",
"(",
"ref_intervals",
",",
"ref_pitches",
",",
"est_intervals",
",",
"est_pitches",
",",
"*",
"*",
"kwargs",
")",
":",
"# Compute all the metrics",
"scores",
"=",
"collections",
".",
"OrderedDict",
"(",
")",
"# Precision, recall and f-measure taking... | Compute all metrics for the given reference and estimated annotations.
Examples
--------
>>> ref_intervals, ref_pitches = mir_eval.io.load_valued_intervals(
... 'reference.txt')
>>> est_intervals, est_pitches = mir_eval.io.load_valued_intervals(
... 'estimate.txt')
>>> scores = mir_ev... | [
"Compute",
"all",
"metrics",
"for",
"the",
"given",
"reference",
"and",
"estimated",
"annotations",
"."
] | python | train | 38.205479 |
theosysbio/means | src/means/approximation/lna/lna.py | https://github.com/theosysbio/means/blob/fe164916a1d84ab2a4fa039871d38ccdf638b1db/src/means/approximation/lna/lna.py#L26-L111 | def run(self):
"""
Overrides the default _run() private method.
Performs the complete analysis
:return: A fully computed set of Ordinary Differential Equations that can be used for further simulation
:rtype: :class:`~means.core.problems.ODEProblem`
"""
S = self.m... | [
"def",
"run",
"(",
"self",
")",
":",
"S",
"=",
"self",
".",
"model",
".",
"stoichiometry_matrix",
"amat",
"=",
"self",
".",
"model",
".",
"propensities",
"ymat",
"=",
"self",
".",
"model",
".",
"species",
"n_species",
"=",
"len",
"(",
"ymat",
")",
"#... | Overrides the default _run() private method.
Performs the complete analysis
:return: A fully computed set of Ordinary Differential Equations that can be used for further simulation
:rtype: :class:`~means.core.problems.ODEProblem` | [
"Overrides",
"the",
"default",
"_run",
"()",
"private",
"method",
".",
"Performs",
"the",
"complete",
"analysis",
":",
"return",
":",
"A",
"fully",
"computed",
"set",
"of",
"Ordinary",
"Differential",
"Equations",
"that",
"can",
"be",
"used",
"for",
"further",... | python | train | 39.174419 |
openstack/quark | quark/api/extensions/scalingip.py | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/api/extensions/scalingip.py#L127-L135 | def get_resources(cls):
"""Returns Ext Resources."""
plural_mappings = resource_helper.build_plural_mappings(
{}, RESOURCE_ATTRIBUTE_MAP)
# attr.PLURALS.update(plural_mappings)
return resource_helper.build_resource_info(plural_mappings,
... | [
"def",
"get_resources",
"(",
"cls",
")",
":",
"plural_mappings",
"=",
"resource_helper",
".",
"build_plural_mappings",
"(",
"{",
"}",
",",
"RESOURCE_ATTRIBUTE_MAP",
")",
"# attr.PLURALS.update(plural_mappings)",
"return",
"resource_helper",
".",
"build_resource_info",
"("... | Returns Ext Resources. | [
"Returns",
"Ext",
"Resources",
"."
] | python | valid | 52.888889 |
locationlabs/mockredis | mockredis/client.py | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L579-L582 | def hincrby(self, hashkey, attribute, increment=1):
"""Emulate hincrby."""
return self._hincrby(hashkey, attribute, 'HINCRBY', long, increment) | [
"def",
"hincrby",
"(",
"self",
",",
"hashkey",
",",
"attribute",
",",
"increment",
"=",
"1",
")",
":",
"return",
"self",
".",
"_hincrby",
"(",
"hashkey",
",",
"attribute",
",",
"'HINCRBY'",
",",
"long",
",",
"increment",
")"
] | Emulate hincrby. | [
"Emulate",
"hincrby",
"."
] | python | train | 39.25 |
Clinical-Genomics/scout | scout/parse/panel.py | https://github.com/Clinical-Genomics/scout/blob/90a551e2e1653a319e654c2405c2866f93d0ebb9/scout/parse/panel.py#L260-L293 | def parse_gene_panel(path, institute='cust000', panel_id='test', panel_type='clinical', date=datetime.now(),
version=1.0, display_name=None, genes = None):
"""Parse the panel info and return a gene panel
Args:
path(str): Path to panel file
institute(str): Name ... | [
"def",
"parse_gene_panel",
"(",
"path",
",",
"institute",
"=",
"'cust000'",
",",
"panel_id",
"=",
"'test'",
",",
"panel_type",
"=",
"'clinical'",
",",
"date",
"=",
"datetime",
".",
"now",
"(",
")",
",",
"version",
"=",
"1.0",
",",
"display_name",
"=",
"N... | Parse the panel info and return a gene panel
Args:
path(str): Path to panel file
institute(str): Name of institute that owns the panel
panel_id(str): Panel id
date(datetime.datetime): Date of creation
version(float)
full_name(str): Option ... | [
"Parse",
"the",
"panel",
"info",
"and",
"return",
"a",
"gene",
"panel"
] | python | test | 32.970588 |
BreakingBytes/simkit | simkit/core/formulas.py | https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/formulas.py#L35-L48 | def register(self, new_formulas, *args, **kwargs):
"""
Register formula and meta data.
* ``islinear`` - ``True`` if formula is linear, ``False`` if non-linear.
* ``args`` - position of arguments
* ``units`` - units of returns and arguments as pair of tuples
* ``isconstan... | [
"def",
"register",
"(",
"self",
",",
"new_formulas",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"update",
"(",
"zip",
"(",
"self",
".",
"meta_names",
",",
"args",
")",
")",
"# call super method, meta must be passed as kwargs!",
"supe... | Register formula and meta data.
* ``islinear`` - ``True`` if formula is linear, ``False`` if non-linear.
* ``args`` - position of arguments
* ``units`` - units of returns and arguments as pair of tuples
* ``isconstant`` - constant arguments not included in covariance
:param new... | [
"Register",
"formula",
"and",
"meta",
"data",
"."
] | python | train | 43.785714 |
SheffieldML/GPyOpt | GPyOpt/optimization/optimizer.py | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/optimization/optimizer.py#L238-L253 | def choose_optimizer(optimizer_name, bounds):
"""
Selects the type of local optimizer
"""
if optimizer_name == 'lbfgs':
optimizer = OptLbfgs(bounds)
elif optimizer_name == 'DIRECT':
optimizer = OptDirect(bounds)
elif optimizer_name == 'CMA':
... | [
"def",
"choose_optimizer",
"(",
"optimizer_name",
",",
"bounds",
")",
":",
"if",
"optimizer_name",
"==",
"'lbfgs'",
":",
"optimizer",
"=",
"OptLbfgs",
"(",
"bounds",
")",
"elif",
"optimizer_name",
"==",
"'DIRECT'",
":",
"optimizer",
"=",
"OptDirect",
"(",
"bou... | Selects the type of local optimizer | [
"Selects",
"the",
"type",
"of",
"local",
"optimizer"
] | python | train | 28.3125 |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L665-L676 | def generic_loss(top_out, targets, model_hparams, vocab_size, weights_fn):
"""Compute loss numerator and denominator for one shard of output."""
del vocab_size # unused arg
logits = top_out
logits = common_attention.maybe_upcast(logits, hparams=model_hparams)
cutoff = getattr(model_hparams, "video_modality_l... | [
"def",
"generic_loss",
"(",
"top_out",
",",
"targets",
",",
"model_hparams",
",",
"vocab_size",
",",
"weights_fn",
")",
":",
"del",
"vocab_size",
"# unused arg",
"logits",
"=",
"top_out",
"logits",
"=",
"common_attention",
".",
"maybe_upcast",
"(",
"logits",
","... | Compute loss numerator and denominator for one shard of output. | [
"Compute",
"loss",
"numerator",
"and",
"denominator",
"for",
"one",
"shard",
"of",
"output",
"."
] | python | train | 40.583333 |
zhelev/python-afsapi | afsapi/__init__.py | https://github.com/zhelev/python-afsapi/blob/bb1990cf1460ae42f2dde75f2291625ddac2c0e4/afsapi/__init__.py#L150-L156 | def handle_text(self, item):
"""Helper method for fetching a text value."""
doc = yield from self.handle_get(item)
if doc is None:
return None
return doc.value.c8_array.text or None | [
"def",
"handle_text",
"(",
"self",
",",
"item",
")",
":",
"doc",
"=",
"yield",
"from",
"self",
".",
"handle_get",
"(",
"item",
")",
"if",
"doc",
"is",
"None",
":",
"return",
"None",
"return",
"doc",
".",
"value",
".",
"c8_array",
".",
"text",
"or",
... | Helper method for fetching a text value. | [
"Helper",
"method",
"for",
"fetching",
"a",
"text",
"value",
"."
] | python | valid | 31.428571 |
openego/ding0 | ding0/grid/mv_grid/solvers/local_search.py | https://github.com/openego/ding0/blob/e2d6528f96255e4bb22ba15514a4f1883564ed5d/ding0/grid/mv_grid/solvers/local_search.py#L221-L330 | def operator_relocate(self, graph, solution, op_diff_round_digits, anim):
"""applies Relocate inter-route operator to solution
Takes every node from every route and calculates savings when inserted
into all possible positions in other routes. Insertion is done at
position with m... | [
"def",
"operator_relocate",
"(",
"self",
",",
"graph",
",",
"solution",
",",
"op_diff_round_digits",
",",
"anim",
")",
":",
"# shorter var names for loop",
"dm",
"=",
"graph",
".",
"_matrix",
"dn",
"=",
"graph",
".",
"_nodes",
"# Relocate: Search better solutions by... | applies Relocate inter-route operator to solution
Takes every node from every route and calculates savings when inserted
into all possible positions in other routes. Insertion is done at
position with max. saving and procedure starts over again with newly
created graph as input.... | [
"applies",
"Relocate",
"inter",
"-",
"route",
"operator",
"to",
"solution",
"Takes",
"every",
"node",
"from",
"every",
"route",
"and",
"calculates",
"savings",
"when",
"inserted",
"into",
"all",
"possible",
"positions",
"in",
"other",
"routes",
".",
"Insertion",... | python | train | 46.118182 |
toros-astro/corral | corral/db/__init__.py | https://github.com/toros-astro/corral/blob/75474b38ff366330d33644461a902d07374a5bbc/corral/db/__init__.py#L143-L153 | def session_scope(session_cls=None):
"""Provide a transactional scope around a series of operations."""
session = session_cls() if session_cls else Session()
try:
yield session
session.commit()
except Exception:
session.rollback()
raise
finally:
session.close(... | [
"def",
"session_scope",
"(",
"session_cls",
"=",
"None",
")",
":",
"session",
"=",
"session_cls",
"(",
")",
"if",
"session_cls",
"else",
"Session",
"(",
")",
"try",
":",
"yield",
"session",
"session",
".",
"commit",
"(",
")",
"except",
"Exception",
":",
... | Provide a transactional scope around a series of operations. | [
"Provide",
"a",
"transactional",
"scope",
"around",
"a",
"series",
"of",
"operations",
"."
] | python | train | 28.272727 |
NASA-AMMOS/AIT-Core | ait/core/cmd.py | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/cmd.py#L224-L254 | def encode(self, pad=106):
"""Encodes this AIT command to binary.
If pad is specified, it indicates the maximum size of the encoded
command in bytes. If the encoded command is less than pad, the
remaining bytes are set to zero.
Commands sent to ISS payloads over 1553 are limit... | [
"def",
"encode",
"(",
"self",
",",
"pad",
"=",
"106",
")",
":",
"opcode",
"=",
"struct",
".",
"pack",
"(",
"'>H'",
",",
"self",
".",
"defn",
".",
"opcode",
")",
"offset",
"=",
"len",
"(",
"opcode",
")",
"size",
"=",
"max",
"(",
"offset",
"+",
"... | Encodes this AIT command to binary.
If pad is specified, it indicates the maximum size of the encoded
command in bytes. If the encoded command is less than pad, the
remaining bytes are set to zero.
Commands sent to ISS payloads over 1553 are limited to 64 words
(128 bytes) wit... | [
"Encodes",
"this",
"AIT",
"command",
"to",
"binary",
"."
] | python | train | 34.645161 |
cdgriffith/Reusables | reusables/cli.py | https://github.com/cdgriffith/Reusables/blob/bc32f72e4baee7d76a6d58b88fcb23dd635155cd/reusables/cli.py#L122-L147 | def head(file_path, lines=10, encoding="utf-8", printed=True,
errors='strict'):
"""
Read the first N lines of a file, defaults to 10
:param file_path: Path to file to read
:param lines: Number of lines to read in
:param encoding: defaults to utf-8 to decode as, will fail on binary
:par... | [
"def",
"head",
"(",
"file_path",
",",
"lines",
"=",
"10",
",",
"encoding",
"=",
"\"utf-8\"",
",",
"printed",
"=",
"True",
",",
"errors",
"=",
"'strict'",
")",
":",
"data",
"=",
"[",
"]",
"with",
"open",
"(",
"file_path",
",",
"\"rb\"",
")",
"as",
"... | Read the first N lines of a file, defaults to 10
:param file_path: Path to file to read
:param lines: Number of lines to read in
:param encoding: defaults to utf-8 to decode as, will fail on binary
:param printed: Automatically print the lines instead of returning it
:param errors: Decoding errors:... | [
"Read",
"the",
"first",
"N",
"lines",
"of",
"a",
"file",
"defaults",
"to",
"10"
] | python | train | 35.807692 |
cmbruns/pyopenvr | src/openvr/__init__.py | https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L4888-L4894 | def getOverlayTransformTrackedDeviceComponent(self, ulOverlayHandle, pchComponentName, unComponentNameSize):
"""Gets the transform information when the overlay is rendering on a component."""
fn = self.function_table.getOverlayTransformTrackedDeviceComponent
punDeviceIndex = TrackedDeviceIndex_... | [
"def",
"getOverlayTransformTrackedDeviceComponent",
"(",
"self",
",",
"ulOverlayHandle",
",",
"pchComponentName",
",",
"unComponentNameSize",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getOverlayTransformTrackedDeviceComponent",
"punDeviceIndex",
"=",
"Tracke... | Gets the transform information when the overlay is rendering on a component. | [
"Gets",
"the",
"transform",
"information",
"when",
"the",
"overlay",
"is",
"rendering",
"on",
"a",
"component",
"."
] | python | train | 64.857143 |
globocom/GloboNetworkAPI-client-python | networkapiclient/EnvironmentVIP.py | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/EnvironmentVIP.py#L314-L343 | def buscar_ambientep44_por_finalidade_cliente(
self,
finalidade_txt,
cliente_txt):
"""Search ambiente_p44_txt environment vip
:return: Dictionary with the following structure:
::
{‘ambiente_p44_txt’:
'id':<'id_ambientevip'>,
... | [
"def",
"buscar_ambientep44_por_finalidade_cliente",
"(",
"self",
",",
"finalidade_txt",
",",
"cliente_txt",
")",
":",
"vip_map",
"=",
"dict",
"(",
")",
"vip_map",
"[",
"'finalidade_txt'",
"]",
"=",
"finalidade_txt",
"vip_map",
"[",
"'cliente_txt'",
"]",
"=",
"clie... | Search ambiente_p44_txt environment vip
:return: Dictionary with the following structure:
::
{‘ambiente_p44_txt’:
'id':<'id_ambientevip'>,
‘finalidade’: <'finalidade_txt'>,
'cliente_txt: <'cliente_txt'>',
'ambiente_p44: <'ambiente_p44'>',}
... | [
"Search",
"ambiente_p44_txt",
"environment",
"vip"
] | python | train | 31.633333 |
jeffh/rpi_courses | rpi_courses/models.py | https://github.com/jeffh/rpi_courses/blob/c97176f73f866f112c785910ebf3ff8a790e8e9a/rpi_courses/models.py#L327-L335 | def credits(self):
"""Returns either a tuple representing the credit range or a
single integer if the range is set to one value.
Use self.cred to always get the tuple.
"""
if self.cred[0] == self.cred[1]:
return self.cred[0]
return self.cred | [
"def",
"credits",
"(",
"self",
")",
":",
"if",
"self",
".",
"cred",
"[",
"0",
"]",
"==",
"self",
".",
"cred",
"[",
"1",
"]",
":",
"return",
"self",
".",
"cred",
"[",
"0",
"]",
"return",
"self",
".",
"cred"
] | Returns either a tuple representing the credit range or a
single integer if the range is set to one value.
Use self.cred to always get the tuple. | [
"Returns",
"either",
"a",
"tuple",
"representing",
"the",
"credit",
"range",
"or",
"a",
"single",
"integer",
"if",
"the",
"range",
"is",
"set",
"to",
"one",
"value",
"."
] | python | train | 32.666667 |
theno/fabsetup | fabsetup/fabfile/setup/service/selfoss.py | https://github.com/theno/fabsetup/blob/ced728abff93551ba5677e63bc1bdc0ef5ca5777/fabsetup/fabfile/setup/service/selfoss.py#L19-L54 | def selfoss(reset_password=False):
'''Install, update and set up selfoss.
This selfoss installation uses sqlite (selfoss-default), php5-fpm and nginx.
The connection is https-only and secured by a letsencrypt certificate. This
certificate must be created separately with task setup.server_letsencrypt.... | [
"def",
"selfoss",
"(",
"reset_password",
"=",
"False",
")",
":",
"hostname",
"=",
"re",
".",
"sub",
"(",
"r'^[^@]+@'",
",",
"''",
",",
"env",
".",
"host",
")",
"# without username if any",
"sitename",
"=",
"query_input",
"(",
"question",
"=",
"'\\nEnter site... | Install, update and set up selfoss.
This selfoss installation uses sqlite (selfoss-default), php5-fpm and nginx.
The connection is https-only and secured by a letsencrypt certificate. This
certificate must be created separately with task setup.server_letsencrypt.
More infos:
https://selfoss.ad... | [
"Install",
"update",
"and",
"set",
"up",
"selfoss",
"."
] | python | train | 35.944444 |
briancappello/py-yaml-fixtures | py_yaml_fixtures/fixtures_loader.py | https://github.com/briancappello/py-yaml-fixtures/blob/60c37daf58ec3b1c4bba637889949523a69b8a73/py_yaml_fixtures/fixtures_loader.py#L217-L228 | def _preloading_env(self):
"""
A "stripped" jinja environment.
"""
ctx = self.env.globals
try:
ctx['random_model'] = lambda *a, **kw: None
ctx['random_models'] = lambda *a, **kw: None
yield self.env
finally:
ctx['random_mode... | [
"def",
"_preloading_env",
"(",
"self",
")",
":",
"ctx",
"=",
"self",
".",
"env",
".",
"globals",
"try",
":",
"ctx",
"[",
"'random_model'",
"]",
"=",
"lambda",
"*",
"a",
",",
"*",
"*",
"kw",
":",
"None",
"ctx",
"[",
"'random_models'",
"]",
"=",
"lam... | A "stripped" jinja environment. | [
"A",
"stripped",
"jinja",
"environment",
"."
] | python | train | 35.333333 |
SteveMcGrath/pySecurityCenter | examples/sc5/download_scans/downloader.py | https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/examples/sc5/download_scans/downloader.py#L15-L79 | def download_scans(sc, age=0, unzip=False, path='scans'):
'''Scan Downloader
Here we will attempt to download all of the scans that have completed between
now and AGE days ago.
sc = SecurityCenter5 object
age = how many days back do we want to pull? (default: 0)
unzip = Do we want to uncompress... | [
"def",
"download_scans",
"(",
"sc",
",",
"age",
"=",
"0",
",",
"unzip",
"=",
"False",
",",
"path",
"=",
"'scans'",
")",
":",
"# if the download path doesn't exist, we need to create it.",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
... | Scan Downloader
Here we will attempt to download all of the scans that have completed between
now and AGE days ago.
sc = SecurityCenter5 object
age = how many days back do we want to pull? (default: 0)
unzip = Do we want to uncompress the nessus files? (default: False)
path = Path where the res... | [
"Scan",
"Downloader",
"Here",
"we",
"will",
"attempt",
"to",
"download",
"all",
"of",
"the",
"scans",
"that",
"have",
"completed",
"between",
"now",
"and",
"AGE",
"days",
"ago",
"."
] | python | train | 48.538462 |
TracyWebTech/django-revproxy | revproxy/utils.py | https://github.com/TracyWebTech/django-revproxy/blob/b8d1d9e44eadbafbd16bc03f04d15560089d4472/revproxy/utils.py#L86-L101 | def get_charset(content_type):
"""Function used to retrieve the charset from a content-type.If there is no
charset in the content type then the charset defined on DEFAULT_CHARSET
will be returned
:param content_type: A string containing a Content-Type header
:returns: A string cont... | [
"def",
"get_charset",
"(",
"content_type",
")",
":",
"if",
"not",
"content_type",
":",
"return",
"DEFAULT_CHARSET",
"matched",
"=",
"_get_charset_re",
".",
"search",
"(",
"content_type",
")",
"if",
"matched",
":",
"# Extract the charset and strip its double quotes",
"... | Function used to retrieve the charset from a content-type.If there is no
charset in the content type then the charset defined on DEFAULT_CHARSET
will be returned
:param content_type: A string containing a Content-Type header
:returns: A string containing the charset | [
"Function",
"used",
"to",
"retrieve",
"the",
"charset",
"from",
"a",
"content",
"-",
"type",
".",
"If",
"there",
"is",
"no",
"charset",
"in",
"the",
"content",
"type",
"then",
"the",
"charset",
"defined",
"on",
"DEFAULT_CHARSET",
"will",
"be",
"returned"
] | python | train | 37.3125 |
rix0rrr/gcl | gcl/query.py | https://github.com/rix0rrr/gcl/blob/4e3bccc978a9c60aaaffd20f6f291c4d23775cdf/gcl/query.py#L85-L124 | def select(self, model):
"""Select nodes according to the input selector.
This can ALWAYS return multiple root elements.
"""
res = []
def doSelect(value, pre, remaining):
if not remaining:
res.append((pre, value))
else:
# For the other selectors to work, value must be a... | [
"def",
"select",
"(",
"self",
",",
"model",
")",
":",
"res",
"=",
"[",
"]",
"def",
"doSelect",
"(",
"value",
",",
"pre",
",",
"remaining",
")",
":",
"if",
"not",
"remaining",
":",
"res",
".",
"append",
"(",
"(",
"pre",
",",
"value",
")",
")",
"... | Select nodes according to the input selector.
This can ALWAYS return multiple root elements. | [
"Select",
"nodes",
"according",
"to",
"the",
"input",
"selector",
"."
] | python | train | 32.4 |
google/grumpy | third_party/stdlib/dummy_thread.py | https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/dummy_thread.py#L27-L56 | def start_new_thread(function, args, kwargs={}):
"""Dummy implementation of thread.start_new_thread().
Compatibility is maintained by making sure that ``args`` is a
tuple and ``kwargs`` is a dictionary. If an exception is raised
and it is SystemExit (which can be done by thread.exit()) it is
caugh... | [
"def",
"start_new_thread",
"(",
"function",
",",
"args",
",",
"kwargs",
"=",
"{",
"}",
")",
":",
"if",
"type",
"(",
"args",
")",
"!=",
"type",
"(",
"tuple",
"(",
")",
")",
":",
"raise",
"TypeError",
"(",
"\"2nd arg must be a tuple\"",
")",
"if",
"type"... | Dummy implementation of thread.start_new_thread().
Compatibility is maintained by making sure that ``args`` is a
tuple and ``kwargs`` is a dictionary. If an exception is raised
and it is SystemExit (which can be done by thread.exit()) it is
caught and nothing is done; all other exceptions are printed ... | [
"Dummy",
"implementation",
"of",
"thread",
".",
"start_new_thread",
"()",
"."
] | python | valid | 32.066667 |
PagerDuty/pagerduty-api-python-client | pypd/models/entity.py | https://github.com/PagerDuty/pagerduty-api-python-client/blob/f420b34ca9b29689cc2ecc9adca6dc5d56ae7161/pypd/models/entity.py#L158-L196 | def _fetch_all(cls, api_key, endpoint=None, offset=0, limit=25, **kwargs):
"""
Call `self._fetch_page` for as many pages as exist.
TODO: should be extended to do async page fetches if API allows it via
exposing total value.
Returns a list of `cls` instances.
"""
... | [
"def",
"_fetch_all",
"(",
"cls",
",",
"api_key",
",",
"endpoint",
"=",
"None",
",",
"offset",
"=",
"0",
",",
"limit",
"=",
"25",
",",
"*",
"*",
"kwargs",
")",
":",
"output",
"=",
"[",
"]",
"qp",
"=",
"kwargs",
".",
"copy",
"(",
")",
"limit",
"=... | Call `self._fetch_page` for as many pages as exist.
TODO: should be extended to do async page fetches if API allows it via
exposing total value.
Returns a list of `cls` instances. | [
"Call",
"self",
".",
"_fetch_page",
"for",
"as",
"many",
"pages",
"as",
"exist",
"."
] | python | train | 31.538462 |
astooke/gtimer | gtimer/public/timer.py | https://github.com/astooke/gtimer/blob/2146dab459e5d959feb291821733d3d3ba7c523c/gtimer/public/timer.py#L258-L278 | def resume():
"""
Resume a paused timer, re-activating it. Subsequent time accumulates in
the total.
Returns:
float: The current time.
Raises:
PausedError: If timer was not in paused state.
StoppedError: If timer was already stopped.
"""
t = timer()
if f.t.stop... | [
"def",
"resume",
"(",
")",
":",
"t",
"=",
"timer",
"(",
")",
"if",
"f",
".",
"t",
".",
"stopped",
":",
"raise",
"StoppedError",
"(",
"\"Cannot resume stopped timer.\"",
")",
"if",
"not",
"f",
".",
"t",
".",
"paused",
":",
"raise",
"PausedError",
"(",
... | Resume a paused timer, re-activating it. Subsequent time accumulates in
the total.
Returns:
float: The current time.
Raises:
PausedError: If timer was not in paused state.
StoppedError: If timer was already stopped. | [
"Resume",
"a",
"paused",
"timer",
"re",
"-",
"activating",
"it",
".",
"Subsequent",
"time",
"accumulates",
"in",
"the",
"total",
"."
] | python | train | 25.238095 |
softlayer/softlayer-python | SoftLayer/shell/completer.py | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/shell/completer.py#L28-L54 | def _click_autocomplete(root, text):
"""Completer generator for click applications."""
try:
parts = shlex.split(text)
except ValueError:
raise StopIteration
location, incomplete = _click_resolve_command(root, parts)
if not text.endswith(' ') and not incomplete and text:
rai... | [
"def",
"_click_autocomplete",
"(",
"root",
",",
"text",
")",
":",
"try",
":",
"parts",
"=",
"shlex",
".",
"split",
"(",
"text",
")",
"except",
"ValueError",
":",
"raise",
"StopIteration",
"location",
",",
"incomplete",
"=",
"_click_resolve_command",
"(",
"ro... | Completer generator for click applications. | [
"Completer",
"generator",
"for",
"click",
"applications",
"."
] | python | train | 40.37037 |
aws/sagemaker-python-sdk | src/sagemaker/session.py | https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/session.py#L1110-L1226 | def logs_for_job(self, job_name, wait=False, poll=10): # noqa: C901 - suppress complexity warning for this method
"""Display the logs for a given training job, optionally tailing them until the
job is complete. If the output is a tty or a Jupyter cell, it will be color-coded
based on which inst... | [
"def",
"logs_for_job",
"(",
"self",
",",
"job_name",
",",
"wait",
"=",
"False",
",",
"poll",
"=",
"10",
")",
":",
"# noqa: C901 - suppress complexity warning for this method",
"description",
"=",
"self",
".",
"sagemaker_client",
".",
"describe_training_job",
"(",
"T... | Display the logs for a given training job, optionally tailing them until the
job is complete. If the output is a tty or a Jupyter cell, it will be color-coded
based on which instance the log entry is from.
Args:
job_name (str): Name of the training job to display the logs for.
... | [
"Display",
"the",
"logs",
"for",
"a",
"given",
"training",
"job",
"optionally",
"tailing",
"them",
"until",
"the",
"job",
"is",
"complete",
".",
"If",
"the",
"output",
"is",
"a",
"tty",
"or",
"a",
"Jupyter",
"cell",
"it",
"will",
"be",
"color",
"-",
"c... | python | train | 53.717949 |
shoebot/shoebot | lib/beziereditor/__init__.py | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/beziereditor/__init__.py#L245-L316 | def insert_point(self, x, y):
""" Inserts a point on the path at the mouse location.
We first need to check if the mouse location is on the path.
Inserting point is time intensive and experimental.
"""
try:
bezier = _ctx.ximport("b... | [
"def",
"insert_point",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"try",
":",
"bezier",
"=",
"_ctx",
".",
"ximport",
"(",
"\"bezier\"",
")",
"except",
":",
"from",
"nodebox",
".",
"graphics",
"import",
"bezier",
"# Do a number of checks distributed along the p... | Inserts a point on the path at the mouse location.
We first need to check if the mouse location is on the path.
Inserting point is time intensive and experimental. | [
"Inserts",
"a",
"point",
"on",
"the",
"path",
"at",
"the",
"mouse",
"location",
".",
"We",
"first",
"need",
"to",
"check",
"if",
"the",
"mouse",
"location",
"is",
"on",
"the",
"path",
".",
"Inserting",
"point",
"is",
"time",
"intensive",
"and",
"experime... | python | valid | 35.638889 |
delph-in/pydelphin | delphin/mrs/components.py | https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/components.py#L182-L189 | def tokens(cls, tokens):
"""
Create a Lnk object for a token range.
Args:
tokens: a list of token identifiers
"""
return cls(Lnk.TOKENS, tuple(map(int, tokens))) | [
"def",
"tokens",
"(",
"cls",
",",
"tokens",
")",
":",
"return",
"cls",
"(",
"Lnk",
".",
"TOKENS",
",",
"tuple",
"(",
"map",
"(",
"int",
",",
"tokens",
")",
")",
")"
] | Create a Lnk object for a token range.
Args:
tokens: a list of token identifiers | [
"Create",
"a",
"Lnk",
"object",
"for",
"a",
"token",
"range",
"."
] | python | train | 25.875 |
markovmodel/msmtools | msmtools/estimation/dense/covariance.py | https://github.com/markovmodel/msmtools/blob/54dc76dd2113a0e8f3d15d5316abab41402941be/msmtools/estimation/dense/covariance.py#L176-L199 | def error_perturbation(C, S):
r"""Error perturbation for given sensitivity matrix.
Parameters
----------
C : (M, M) ndarray
Count matrix
S : (M, M) ndarray or (K, M, M) ndarray
Sensitivity matrix (for scalar observable) or sensitivity
tensor for vector observable
Return... | [
"def",
"error_perturbation",
"(",
"C",
",",
"S",
")",
":",
"if",
"len",
"(",
"S",
".",
"shape",
")",
"==",
"2",
":",
"# Scalar observable",
"return",
"error_perturbation_single",
"(",
"C",
",",
"S",
")",
"elif",
"len",
"(",
"S",
".",
"shape",
")",
"=... | r"""Error perturbation for given sensitivity matrix.
Parameters
----------
C : (M, M) ndarray
Count matrix
S : (M, M) ndarray or (K, M, M) ndarray
Sensitivity matrix (for scalar observable) or sensitivity
tensor for vector observable
Returns
-------
X : float or (K,... | [
"r",
"Error",
"perturbation",
"for",
"given",
"sensitivity",
"matrix",
"."
] | python | train | 30.666667 |
TC01/calcpkg | calcrepo/index.py | https://github.com/TC01/calcpkg/blob/5168f606264620a090b42a64354331d208b00d5f/calcrepo/index.py#L19-L49 | def count(self, searchString, category="", math=False, game=False, searchFiles=False, extension=""):
"""Counts the number of ticalc.org files containing some search term, doesn't return them"""
fileData = {}
nameData = {}
#Search the index
if searchFiles:
fileData = self.searchNamesIndex(self.fileIndex,... | [
"def",
"count",
"(",
"self",
",",
"searchString",
",",
"category",
"=",
"\"\"",
",",
"math",
"=",
"False",
",",
"game",
"=",
"False",
",",
"searchFiles",
"=",
"False",
",",
"extension",
"=",
"\"\"",
")",
":",
"fileData",
"=",
"{",
"}",
"nameData",
"=... | Counts the number of ticalc.org files containing some search term, doesn't return them | [
"Counts",
"the",
"number",
"of",
"ticalc",
".",
"org",
"files",
"containing",
"some",
"search",
"term",
"doesn",
"t",
"return",
"them"
] | python | train | 41.193548 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.