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 |
|---|---|---|---|---|---|---|---|---|---|
google/openhtf | openhtf/util/logs.py | https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/util/logs.py#L188-L193 | def log_once(log_func, msg, *args, **kwargs):
""""Logs a message only once."""
if msg not in _LOG_ONCE_SEEN:
log_func(msg, *args, **kwargs)
# Key on the message, ignoring args. This should fit most use cases.
_LOG_ONCE_SEEN.add(msg) | [
"def",
"log_once",
"(",
"log_func",
",",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"msg",
"not",
"in",
"_LOG_ONCE_SEEN",
":",
"log_func",
"(",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"# Key on the message, ignorin... | Logs a message only once. | [
"Logs",
"a",
"message",
"only",
"once",
"."
] | python | train | 40.5 |
log2timeline/dfvfs | examples/source_analyzer.py | https://github.com/log2timeline/dfvfs/blob/2b3ccd115f9901d89f383397d4a1376a873c83c4/examples/source_analyzer.py#L283-L337 | def Main():
"""The main program function.
Returns:
bool: True if successful or False if not.
"""
argument_parser = argparse.ArgumentParser(description=(
'Calculates a message digest hash for every file in a directory or '
'storage media image.'))
argument_parser.add_argument(
'source',... | [
"def",
"Main",
"(",
")",
":",
"argument_parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"(",
"'Calculates a message digest hash for every file in a directory or '",
"'storage media image.'",
")",
")",
"argument_parser",
".",
"add_argument",
"(",
... | The main program function.
Returns:
bool: True if successful or False if not. | [
"The",
"main",
"program",
"function",
"."
] | python | train | 25.490909 |
zimeon/iiif | iiif/static.py | https://github.com/zimeon/iiif/blob/9d10018d01202fa2a76dfa61598dc6eca07b471f/iiif/static.py#L331-L368 | def setup_destination(self):
"""Setup output directory based on self.dst and self.identifier.
Returns the output directory name on success, raises and exception on
failure.
"""
# Do we have a separate identifier?
if (not self.identifier):
# No separate identi... | [
"def",
"setup_destination",
"(",
"self",
")",
":",
"# Do we have a separate identifier?",
"if",
"(",
"not",
"self",
".",
"identifier",
")",
":",
"# No separate identifier specified, split off the last path segment",
"# of the source name, strip the extension to get the identifier",
... | Setup output directory based on self.dst and self.identifier.
Returns the output directory name on success, raises and exception on
failure. | [
"Setup",
"output",
"directory",
"based",
"on",
"self",
".",
"dst",
"and",
"self",
".",
"identifier",
"."
] | python | train | 41.105263 |
hendrix/hendrix | hendrix/options.py | https://github.com/hendrix/hendrix/blob/175af011a7e5822b772bfec0e11a46466bb8688d/hendrix/options.py#L7-L26 | def cleanOptions(options):
"""
Takes an options dict and returns a tuple containing the daemonize boolean,
the reload boolean, and the parsed list of cleaned options as would be
expected to be passed to hx
"""
_reload = options.pop('reload')
dev = options.pop('dev')
opts = []
store_t... | [
"def",
"cleanOptions",
"(",
"options",
")",
":",
"_reload",
"=",
"options",
".",
"pop",
"(",
"'reload'",
")",
"dev",
"=",
"options",
".",
"pop",
"(",
"'dev'",
")",
"opts",
"=",
"[",
"]",
"store_true",
"=",
"[",
"'--nocache'",
",",
"'--global_cache'",
"... | Takes an options dict and returns a tuple containing the daemonize boolean,
the reload boolean, and the parsed list of cleaned options as would be
expected to be passed to hx | [
"Takes",
"an",
"options",
"dict",
"and",
"returns",
"a",
"tuple",
"containing",
"the",
"daemonize",
"boolean",
"the",
"reload",
"boolean",
"and",
"the",
"parsed",
"list",
"of",
"cleaned",
"options",
"as",
"would",
"be",
"expected",
"to",
"be",
"passed",
"to"... | python | train | 32.45 |
log2timeline/plaso | plaso/parsers/esedb_plugins/interface.py | https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/parsers/esedb_plugins/interface.py#L99-L123 | def _ConvertValueBinaryDataToUBInt64(self, value):
"""Converts a binary data value into an integer.
Args:
value (bytes): binary data value containing an unsigned 64-bit big-endian
integer.
Returns:
int: integer representation of binary data value or None if value is
not set... | [
"def",
"_ConvertValueBinaryDataToUBInt64",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"value",
":",
"return",
"None",
"integer_map",
"=",
"self",
".",
"_GetDataTypeMap",
"(",
"'uint64be'",
")",
"try",
":",
"return",
"self",
".",
"_ReadStructureFromByteStr... | Converts a binary data value into an integer.
Args:
value (bytes): binary data value containing an unsigned 64-bit big-endian
integer.
Returns:
int: integer representation of binary data value or None if value is
not set.
Raises:
ParseError: if the integer value cann... | [
"Converts",
"a",
"binary",
"data",
"value",
"into",
"an",
"integer",
"."
] | python | train | 29 |
pyblish/pyblish-maya | pyblish_maya/lib.py | https://github.com/pyblish/pyblish-maya/blob/75db8b5d8de9d53ae95e74195a788b5f6db2cb5f/pyblish_maya/lib.py#L26-L50 | def setup(menu=True):
"""Setup integration
Registers Pyblish for Maya plug-ins and appends an item to the File-menu
Attributes:
console (bool): Display console with GUI
port (int, optional): Port from which to start looking for an
available port to connect with Pyblish QML, def... | [
"def",
"setup",
"(",
"menu",
"=",
"True",
")",
":",
"if",
"self",
".",
"_has_been_setup",
":",
"teardown",
"(",
")",
"register_plugins",
"(",
")",
"register_host",
"(",
")",
"if",
"menu",
":",
"add_to_filemenu",
"(",
")",
"self",
".",
"_has_menu",
"=",
... | Setup integration
Registers Pyblish for Maya plug-ins and appends an item to the File-menu
Attributes:
console (bool): Display console with GUI
port (int, optional): Port from which to start looking for an
available port to connect with Pyblish QML, default
provided by ... | [
"Setup",
"integration"
] | python | test | 23.68 |
apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L148-L159 | def create_basic_op_node(op_name, node, kwargs):
"""Helper function to create a basic operator
node that doesn't contain op specific attrs"""
name, input_nodes, _ = get_inputs(node, kwargs)
node = onnx.helper.make_node(
op_name,
input_nodes,
[name],
name=name
)
r... | [
"def",
"create_basic_op_node",
"(",
"op_name",
",",
"node",
",",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"_",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"node",
"=",
"onnx",
".",
"helper",
".",
"make_node",
"(",
"op_name",
",",
"i... | Helper function to create a basic operator
node that doesn't contain op specific attrs | [
"Helper",
"function",
"to",
"create",
"a",
"basic",
"operator",
"node",
"that",
"doesn",
"t",
"contain",
"op",
"specific",
"attrs"
] | python | train | 26.75 |
tensorlayer/tensorlayer | examples/text_classification/tutorial_imdb_fasttext.py | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/examples/text_classification/tutorial_imdb_fasttext.py#L112-L120 | def load_and_preprocess_imdb_data(n_gram=None):
"""Load IMDb data and augment with hashed n-gram features."""
X_train, y_train, X_test, y_test = tl.files.load_imdb_dataset(nb_words=VOCAB_SIZE)
if n_gram is not None:
X_train = np.array([augment_with_ngrams(x, VOCAB_SIZE, N_BUCKETS, n=n_gram) for x i... | [
"def",
"load_and_preprocess_imdb_data",
"(",
"n_gram",
"=",
"None",
")",
":",
"X_train",
",",
"y_train",
",",
"X_test",
",",
"y_test",
"=",
"tl",
".",
"files",
".",
"load_imdb_dataset",
"(",
"nb_words",
"=",
"VOCAB_SIZE",
")",
"if",
"n_gram",
"is",
"not",
... | Load IMDb data and augment with hashed n-gram features. | [
"Load",
"IMDb",
"data",
"and",
"augment",
"with",
"hashed",
"n",
"-",
"gram",
"features",
"."
] | python | valid | 52.111111 |
Azure/blobxfer | blobxfer/models/crypto.py | https://github.com/Azure/blobxfer/blob/3eccbe7530cc6a20ab2d30f9e034b6f021817f34/blobxfer/models/crypto.py#L169-L188 | def create_new_metadata(self, rsa_public_key):
# type: (EncryptionMetadata,
# cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey)
# -> None
"""Create new metadata entries for encryption (upload)
:param EncryptionMetadata self: this
:param cryptograph... | [
"def",
"create_new_metadata",
"(",
"self",
",",
"rsa_public_key",
")",
":",
"# type: (EncryptionMetadata,",
"# cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey)",
"# -> None",
"self",
".",
"_rsa_public_key",
"=",
"rsa_public_key",
"self",
".",
"_symkey",
... | Create new metadata entries for encryption (upload)
:param EncryptionMetadata self: this
:param cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey:
rsa public key | [
"Create",
"new",
"metadata",
"entries",
"for",
"encryption",
"(",
"upload",
")",
":",
"param",
"EncryptionMetadata",
"self",
":",
"this",
":",
"param",
"cryptography",
".",
"hazmat",
".",
"primitives",
".",
"asymmetric",
".",
"rsa",
".",
"RSAPublicKey",
":",
... | python | train | 48.8 |
ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_gasheli.py | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_gasheli.py#L83-L96 | def idle_task(self):
'''run periodic tasks'''
if self.starting_motor:
if self.gasheli_settings.ignition_disable_time > 0:
elapsed = time.time() - self.motor_t1
if elapsed >= self.gasheli_settings.ignition_disable_time:
self.module('rc').set... | [
"def",
"idle_task",
"(",
"self",
")",
":",
"if",
"self",
".",
"starting_motor",
":",
"if",
"self",
".",
"gasheli_settings",
".",
"ignition_disable_time",
">",
"0",
":",
"elapsed",
"=",
"time",
".",
"time",
"(",
")",
"-",
"self",
".",
"motor_t1",
"if",
... | run periodic tasks | [
"run",
"periodic",
"tasks"
] | python | train | 55.214286 |
Esri/ArcREST | src/arcrest/manageorg/_community.py | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/_community.py#L987-L1004 | def applications(self):
"""returns all the group applications to join"""
url = self._url + "/applications"
params = {"f" : "json"}
res = self._get(url=url,
param_dict=params,
proxy_url=self._proxy_url,
proxy... | [
"def",
"applications",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/applications\"",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
"}",
"res",
"=",
"self",
".",
"_get",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
","... | returns all the group applications to join | [
"returns",
"all",
"the",
"group",
"applications",
"to",
"join"
] | python | train | 43.777778 |
tox-dev/tox-venv | src/tox_venv/hooks.py | https://github.com/tox-dev/tox-venv/blob/e740a96c81e076d850065e6a8444ae1cd833468b/src/tox_venv/hooks.py#L8-L69 | def real_python3(python, version_dict):
"""
Determine the path of the real python executable, which is then used for
venv creation. This is necessary, because an active virtualenv environment
will cause venv creation to malfunction. By getting the path of the real
executable, this issue is bypassed.... | [
"def",
"real_python3",
"(",
"python",
",",
"version_dict",
")",
":",
"args",
"=",
"[",
"python",
",",
"'-c'",
",",
"'import sys; print(sys.real_prefix)'",
"]",
"# get python prefix",
"try",
":",
"output",
"=",
"subprocess",
".",
"check_output",
"(",
"args",
",",... | Determine the path of the real python executable, which is then used for
venv creation. This is necessary, because an active virtualenv environment
will cause venv creation to malfunction. By getting the path of the real
executable, this issue is bypassed.
The provided `python` path may be either:
... | [
"Determine",
"the",
"path",
"of",
"the",
"real",
"python",
"executable",
"which",
"is",
"then",
"used",
"for",
"venv",
"creation",
".",
"This",
"is",
"necessary",
"because",
"an",
"active",
"virtualenv",
"environment",
"will",
"cause",
"venv",
"creation",
"to"... | python | train | 40.935484 |
pyapi-gitlab/pyapi-gitlab | gitlab/__init__.py | https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/__init__.py#L188-L205 | def delete_project(self, id):
"""
Delete a project from the Gitlab server
Gitlab currently returns a Boolean True if the deleted and as such we return an
empty Dictionary
:param id: The ID of the project or NAMESPACE/PROJECT_NAME
:return: Dictionary
:raise: Http... | [
"def",
"delete_project",
"(",
"self",
",",
"id",
")",
":",
"url",
"=",
"'/projects/{id}'",
".",
"format",
"(",
"id",
"=",
"id",
")",
"response",
"=",
"self",
".",
"delete",
"(",
"url",
")",
"if",
"response",
"is",
"True",
":",
"return",
"{",
"}",
"... | Delete a project from the Gitlab server
Gitlab currently returns a Boolean True if the deleted and as such we return an
empty Dictionary
:param id: The ID of the project or NAMESPACE/PROJECT_NAME
:return: Dictionary
:raise: HttpError: If invalid response returned | [
"Delete",
"a",
"project",
"from",
"the",
"Gitlab",
"server"
] | python | train | 29.166667 |
dade-ai/snipy | snipy/iterflow.py | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/iterflow.py#L359-L381 | def shuffle(qsize=1024, iterable=None):
"""
add example
:param qsize:
:param iterable:
:return:
"""
@iterflow
def shuffleit(it):
from random import randrange
q = []
for i, d in enumerate(it):
q.insert(randrange(0, len(q) + 1), d)
if i < q... | [
"def",
"shuffle",
"(",
"qsize",
"=",
"1024",
",",
"iterable",
"=",
"None",
")",
":",
"@",
"iterflow",
"def",
"shuffleit",
"(",
"it",
")",
":",
"from",
"random",
"import",
"randrange",
"q",
"=",
"[",
"]",
"for",
"i",
",",
"d",
"in",
"enumerate",
"("... | add example
:param qsize:
:param iterable:
:return: | [
"add",
"example",
":",
"param",
"qsize",
":",
":",
"param",
"iterable",
":",
":",
"return",
":"
] | python | valid | 21.956522 |
SheffieldML/GPyOpt | GPyOpt/models/gpmodel.py | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/models/gpmodel.py#L48-L74 | def _create_model(self, X, Y):
"""
Creates the model given some input data X and Y.
"""
# --- define kernel
self.input_dim = X.shape[1]
if self.kernel is None:
kern = GPy.kern.Matern52(self.input_dim, variance=1., ARD=self.ARD) #+ GPy.kern.Bias(self.input_dim... | [
"def",
"_create_model",
"(",
"self",
",",
"X",
",",
"Y",
")",
":",
"# --- define kernel",
"self",
".",
"input_dim",
"=",
"X",
".",
"shape",
"[",
"1",
"]",
"if",
"self",
".",
"kernel",
"is",
"None",
":",
"kern",
"=",
"GPy",
".",
"kern",
".",
"Matern... | Creates the model given some input data X and Y. | [
"Creates",
"the",
"model",
"given",
"some",
"input",
"data",
"X",
"and",
"Y",
"."
] | python | train | 39.814815 |
pantsbuild/pants | src/python/pants/backend/native/config/environment.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/backend/native/config/environment.py#L89-L122 | def sequence(self, other, exclude_list_fields=None):
"""Return a copy of this object which combines all the fields common to both `self` and `other`.
List fields will be concatenated.
The return type of this method is the type of `self` (or whatever `.copy()` returns), but the
`other` argument can be ... | [
"def",
"sequence",
"(",
"self",
",",
"other",
",",
"exclude_list_fields",
"=",
"None",
")",
":",
"exclude_list_fields",
"=",
"frozenset",
"(",
"exclude_list_fields",
"or",
"[",
"]",
")",
"overwrite_kwargs",
"=",
"{",
"}",
"nonexistent_excluded_fields",
"=",
"exc... | Return a copy of this object which combines all the fields common to both `self` and `other`.
List fields will be concatenated.
The return type of this method is the type of `self` (or whatever `.copy()` returns), but the
`other` argument can be any `_ExtensibleAlgebraic` instance. | [
"Return",
"a",
"copy",
"of",
"this",
"object",
"which",
"combines",
"all",
"the",
"fields",
"common",
"to",
"both",
"self",
"and",
"other",
"."
] | python | train | 45.029412 |
annoviko/pyclustering | pyclustering/utils/__init__.py | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/utils/__init__.py#L201-L230 | def average_neighbor_distance(points, num_neigh):
"""!
@brief Returns average distance for establish links between specified number of nearest neighbors.
@param[in] points (list): Input data, list of points where each point represented by list.
@param[in] num_neigh (uint): Number of neighbors ... | [
"def",
"average_neighbor_distance",
"(",
"points",
",",
"num_neigh",
")",
":",
"if",
"num_neigh",
">",
"len",
"(",
"points",
")",
"-",
"1",
":",
"raise",
"NameError",
"(",
"'Impossible to calculate average distance to neighbors when number of object is less than number of n... | !
@brief Returns average distance for establish links between specified number of nearest neighbors.
@param[in] points (list): Input data, list of points where each point represented by list.
@param[in] num_neigh (uint): Number of neighbors that should be used for distance calculation.
@... | [
"!"
] | python | valid | 44.6 |
cloudtools/stacker | stacker/context.py | https://github.com/cloudtools/stacker/blob/ad6013a03a560c46ba3c63c4d153336273e6da5d/stacker/context.py#L186-L204 | def set_hook_data(self, key, data):
"""Set hook data for the given key.
Args:
key(str): The key to store the hook data in.
data(:class:`collections.Mapping`): A dictionary of data to store,
as returned from a hook.
"""
if not isinstance(data, col... | [
"def",
"set_hook_data",
"(",
"self",
",",
"key",
",",
"data",
")",
":",
"if",
"not",
"isinstance",
"(",
"data",
",",
"collections",
".",
"Mapping",
")",
":",
"raise",
"ValueError",
"(",
"\"Hook (key: %s) data must be an instance of \"",
"\"collections.Mapping (a dic... | Set hook data for the given key.
Args:
key(str): The key to store the hook data in.
data(:class:`collections.Mapping`): A dictionary of data to store,
as returned from a hook. | [
"Set",
"hook",
"data",
"for",
"the",
"given",
"key",
"."
] | python | train | 38.157895 |
artefactual-labs/agentarchives | agentarchives/atom/client.py | https://github.com/artefactual-labs/agentarchives/blob/af19ade56a90c64069cf46b50972fe72b6f10a45/agentarchives/atom/client.py#L749-L757 | def delete_record(self, record_id):
"""
Delete a record with record_id.
"""
self._delete(
urljoin(self.base_url, "informationobjects/{}".format(record_id)),
expected_response=204,
)
return {"status": "Deleted"} | [
"def",
"delete_record",
"(",
"self",
",",
"record_id",
")",
":",
"self",
".",
"_delete",
"(",
"urljoin",
"(",
"self",
".",
"base_url",
",",
"\"informationobjects/{}\"",
".",
"format",
"(",
"record_id",
")",
")",
",",
"expected_response",
"=",
"204",
",",
"... | Delete a record with record_id. | [
"Delete",
"a",
"record",
"with",
"record_id",
"."
] | python | train | 30.444444 |
bukun/TorCMS | torcms/handlers/reply_handler.py | https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/reply_handler.py#L66-L80 | def get_by_id(self, reply_id):
'''
Get the reply by id.
'''
reply = MReply.get_by_uid(reply_id)
logger.info('get_reply: {0}'.format(reply_id))
self.render('misc/reply/show_reply.html',
reply=reply,
username=reply.user_name,
... | [
"def",
"get_by_id",
"(",
"self",
",",
"reply_id",
")",
":",
"reply",
"=",
"MReply",
".",
"get_by_uid",
"(",
"reply_id",
")",
"logger",
".",
"info",
"(",
"'get_reply: {0}'",
".",
"format",
"(",
"reply_id",
")",
")",
"self",
".",
"render",
"(",
"'misc/repl... | Get the reply by id. | [
"Get",
"the",
"reply",
"by",
"id",
"."
] | python | train | 31.933333 |
pantsbuild/pants | src/python/pants/build_graph/target.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/build_graph/target.py#L685-L736 | def strict_dependencies(self, dep_context):
"""
:param dep_context: A DependencyContext with configuration for the request.
:return: targets that this target "strictly" depends on. This set of dependencies contains
only directly declared dependencies, with two exceptions:
1) aliases are expand... | [
"def",
"strict_dependencies",
"(",
"self",
",",
"dep_context",
")",
":",
"strict_deps",
"=",
"self",
".",
"_cached_strict_dependencies_map",
".",
"get",
"(",
"dep_context",
",",
"None",
")",
"if",
"strict_deps",
"is",
"None",
":",
"default_predicate",
"=",
"self... | :param dep_context: A DependencyContext with configuration for the request.
:return: targets that this target "strictly" depends on. This set of dependencies contains
only directly declared dependencies, with two exceptions:
1) aliases are expanded transitively
2) the strict_dependencies of ta... | [
":",
"param",
"dep_context",
":",
"A",
"DependencyContext",
"with",
"configuration",
"for",
"the",
"request",
".",
":",
"return",
":",
"targets",
"that",
"this",
"target",
"strictly",
"depends",
"on",
".",
"This",
"set",
"of",
"dependencies",
"contains",
"only... | python | train | 37.461538 |
unt-libraries/edtf-validate | edtf_validate/valid_edtf.py | https://github.com/unt-libraries/edtf-validate/blob/d6d63141919a66aea4ff1c31fa0cb8ff744ef9d9/edtf_validate/valid_edtf.py#L254-L261 | def replace_u_start_month(month):
"""Find the earliest legitimate month."""
month = month.lstrip('-')
if month == 'uu' or month == '0u':
return '01'
if month == 'u0':
return '10'
return month.replace('u', '0') | [
"def",
"replace_u_start_month",
"(",
"month",
")",
":",
"month",
"=",
"month",
".",
"lstrip",
"(",
"'-'",
")",
"if",
"month",
"==",
"'uu'",
"or",
"month",
"==",
"'0u'",
":",
"return",
"'01'",
"if",
"month",
"==",
"'u0'",
":",
"return",
"'10'",
"return"... | Find the earliest legitimate month. | [
"Find",
"the",
"earliest",
"legitimate",
"month",
"."
] | python | train | 29.75 |
mapillary/mapillary_tools | mapillary_tools/exif_read.py | https://github.com/mapillary/mapillary_tools/blob/816785e90c589cae6e8e34a5530ce8417d29591c/mapillary_tools/exif_read.py#L136-L148 | def extract_altitude(self):
'''
Extract altitude
'''
altitude_ref = {
0: 1,
1: -1}
fields = ['GPS GPSAltitude', 'EXIF GPS GPSAltitude']
refs = ['GPS GPSAltitudeRef', 'EXIF GPS GPSAltitudeRef']
altitude, _ = self._extract_alternative_fields(... | [
"def",
"extract_altitude",
"(",
"self",
")",
":",
"altitude_ref",
"=",
"{",
"0",
":",
"1",
",",
"1",
":",
"-",
"1",
"}",
"fields",
"=",
"[",
"'GPS GPSAltitude'",
",",
"'EXIF GPS GPSAltitude'",
"]",
"refs",
"=",
"[",
"'GPS GPSAltitudeRef'",
",",
"'EXIF GPS ... | Extract altitude | [
"Extract",
"altitude"
] | python | train | 39.538462 |
StackStorm/pybind | pybind/nos/v7_2_0/firmware/peripheral_update/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v7_2_0/firmware/peripheral_update/__init__.py#L92-L113 | def _set_microcode(self, v, load=False):
"""
Setter method for microcode, mapped from YANG variable /firmware/peripheral_update/microcode (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_microcode is considered as a private
method. Backends looking to popu... | [
"def",
"_set_microcode",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
"base... | Setter method for microcode, mapped from YANG variable /firmware/peripheral_update/microcode (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_microcode is considered as a private
method. Backends looking to populate this variable should
do so via calling thisO... | [
"Setter",
"method",
"for",
"microcode",
"mapped",
"from",
"YANG",
"variable",
"/",
"firmware",
"/",
"peripheral_update",
"/",
"microcode",
"(",
"container",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"(",
"config",
":",
"false",
")",
"in",
"... | python | train | 72 |
frejanordsiek/hdf5storage | hdf5storage/utilities.py | https://github.com/frejanordsiek/hdf5storage/blob/539275141dd3a4efbbbfd9bdb978f3ed59e3f05d/hdf5storage/utilities.py#L1036-L1174 | def convert_to_numpy_bytes(data, length=None):
""" Decodes data to Numpy UTF-8 econded string (bytes\_).
Decodes `data` to a Numpy UTF-8 encoded string, which is
``numpy.bytes_``, or an array of them in which case it will be ASCII
encoded instead. If it can't be decoded, it is returned as
is. Unsig... | [
"def",
"convert_to_numpy_bytes",
"(",
"data",
",",
"length",
"=",
"None",
")",
":",
"# The method of conversion depends on its type.",
"if",
"isinstance",
"(",
"data",
",",
"np",
".",
"bytes_",
")",
"or",
"(",
"isinstance",
"(",
"data",
",",
"np",
".",
"ndarra... | Decodes data to Numpy UTF-8 econded string (bytes\_).
Decodes `data` to a Numpy UTF-8 encoded string, which is
``numpy.bytes_``, or an array of them in which case it will be ASCII
encoded instead. If it can't be decoded, it is returned as
is. Unsigned integers, Python string types (``str``, ``bytes``),... | [
"Decodes",
"data",
"to",
"Numpy",
"UTF",
"-",
"8",
"econded",
"string",
"(",
"bytes",
"\\",
"_",
")",
"."
] | python | train | 44.517986 |
klmitch/framer | framer/framers.py | https://github.com/klmitch/framer/blob/bd34cee9737793dab61d1d8973930b64bd08acb4/framer/framers.py#L745-L762 | def to_bytes(self, frame, state):
"""
Convert a single frame into bytes that can be transmitted on
the stream.
:param frame: The frame to convert. Should be the same type
of object returned by ``to_frame()``.
:param state: An instance of ``FramerState``. ... | [
"def",
"to_bytes",
"(",
"self",
",",
"frame",
",",
"state",
")",
":",
"# Generate and return the frame",
"return",
"(",
"self",
".",
"begin",
"+",
"self",
".",
"nop",
".",
"join",
"(",
"six",
".",
"binary_type",
"(",
"frame",
")",
".",
"split",
"(",
"s... | Convert a single frame into bytes that can be transmitted on
the stream.
:param frame: The frame to convert. Should be the same type
of object returned by ``to_frame()``.
:param state: An instance of ``FramerState``. This object may
be used to track... | [
"Convert",
"a",
"single",
"frame",
"into",
"bytes",
"that",
"can",
"be",
"transmitted",
"on",
"the",
"stream",
"."
] | python | train | 37 |
ryanpetrello/python-zombie | zombie/proxy/client.py | https://github.com/ryanpetrello/python-zombie/blob/638916572d8ee5ebbdb2dcfc5000a952e99f280f/zombie/proxy/client.py#L25-L36 | def encode_args(args, extra=False):
"""
Encode a list of arguments
"""
if not args:
return ''
methodargs = ', '.join([encode(a) for a in args])
if extra:
methodargs += ', '
return methodargs | [
"def",
"encode_args",
"(",
"args",
",",
"extra",
"=",
"False",
")",
":",
"if",
"not",
"args",
":",
"return",
"''",
"methodargs",
"=",
"', '",
".",
"join",
"(",
"[",
"encode",
"(",
"a",
")",
"for",
"a",
"in",
"args",
"]",
")",
"if",
"extra",
":",
... | Encode a list of arguments | [
"Encode",
"a",
"list",
"of",
"arguments"
] | python | train | 18.75 |
pgmpy/pgmpy | pgmpy/factors/continuous/ContinuousFactor.py | https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/continuous/ContinuousFactor.py#L151-L180 | def discretize(self, method, *args, **kwargs):
"""
Discretizes the continuous distribution into discrete
probability masses using various methods.
Parameters
----------
method : A Discretizer Class from pgmpy.discretize
*args, **kwargs:
The parameter... | [
"def",
"discretize",
"(",
"self",
",",
"method",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"method",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
".",
"get_discrete_values",
"(",
")"
] | Discretizes the continuous distribution into discrete
probability masses using various methods.
Parameters
----------
method : A Discretizer Class from pgmpy.discretize
*args, **kwargs:
The parameters to be given to the Discretizer Class.
Returns
--... | [
"Discretizes",
"the",
"continuous",
"distribution",
"into",
"discrete",
"probability",
"masses",
"using",
"various",
"methods",
"."
] | python | train | 36.233333 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/WSDLTools.py | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/WSDLTools.py#L1391-L1404 | def GetWSAActionInput(operation):
"""Find wsa:Action attribute, and return value or the default."""
attr = operation.input.action
if attr is not None:
return attr
portType = operation.getPortType()
targetNamespace = portType.getTargetNamespace()
ptName = portType.name
msgName = opera... | [
"def",
"GetWSAActionInput",
"(",
"operation",
")",
":",
"attr",
"=",
"operation",
".",
"input",
".",
"action",
"if",
"attr",
"is",
"not",
"None",
":",
"return",
"attr",
"portType",
"=",
"operation",
".",
"getPortType",
"(",
")",
"targetNamespace",
"=",
"po... | Find wsa:Action attribute, and return value or the default. | [
"Find",
"wsa",
":",
"Action",
"attribute",
"and",
"return",
"value",
"or",
"the",
"default",
"."
] | python | train | 38.857143 |
mar10/wsgidav | wsgidav/util.py | https://github.com/mar10/wsgidav/blob/cec0d84222fc24bea01be1cea91729001963f172/wsgidav/util.py#L956-L996 | def get_etag(file_path):
"""Return a strong Entity Tag for a (file)path.
http://www.webdav.org/specs/rfc4918.html#etag
Returns the following as entity tags::
Non-file - md5(pathname)
Win32 - md5(pathname)-lastmodifiedtime-filesize
Others - inode-lastmodifiedtime-filesize
"""
... | [
"def",
"get_etag",
"(",
"file_path",
")",
":",
"# (At least on Vista) os.path.exists returns False, if a file name contains",
"# special characters, even if it is correctly UTF-8 encoded.",
"# So we convert to unicode. On the other hand, md5() needs a byte string.",
"if",
"compat",
".",
"is_... | Return a strong Entity Tag for a (file)path.
http://www.webdav.org/specs/rfc4918.html#etag
Returns the following as entity tags::
Non-file - md5(pathname)
Win32 - md5(pathname)-lastmodifiedtime-filesize
Others - inode-lastmodifiedtime-filesize | [
"Return",
"a",
"strong",
"Entity",
"Tag",
"for",
"a",
"(",
"file",
")",
"path",
"."
] | python | valid | 31.536585 |
Clinical-Genomics/scout | scout/parse/hpo.py | https://github.com/Clinical-Genomics/scout/blob/90a551e2e1653a319e654c2405c2866f93d0ebb9/scout/parse/hpo.py#L23-L40 | def parse_hpo_gene(hpo_line):
"""Parse hpo gene information
Args:
hpo_line(str): A iterable with hpo phenotype lines
Yields:
hpo_info(dict)
"""
if not len(hpo_line) > 3:
return {}
hpo_line = hpo_line.rstrip().split('\t')
hpo_info = {}
hpo... | [
"def",
"parse_hpo_gene",
"(",
"hpo_line",
")",
":",
"if",
"not",
"len",
"(",
"hpo_line",
")",
">",
"3",
":",
"return",
"{",
"}",
"hpo_line",
"=",
"hpo_line",
".",
"rstrip",
"(",
")",
".",
"split",
"(",
"'\\t'",
")",
"hpo_info",
"=",
"{",
"}",
"hpo_... | Parse hpo gene information
Args:
hpo_line(str): A iterable with hpo phenotype lines
Yields:
hpo_info(dict) | [
"Parse",
"hpo",
"gene",
"information",
"Args",
":",
"hpo_line",
"(",
"str",
")",
":",
"A",
"iterable",
"with",
"hpo",
"phenotype",
"lines",
"Yields",
":",
"hpo_info",
"(",
"dict",
")"
] | python | test | 24.5 |
jeongyoonlee/Kaggler | kaggler/data_io.py | https://github.com/jeongyoonlee/Kaggler/blob/20661105b61958dc9a3c529c1d3b2313ab23ae32/kaggler/data_io.py#L68-L77 | def save_libsvm(X, y, path):
"""Save data as a LibSVM file.
Args:
X (numpy or scipy sparse matrix): Data matrix
y (numpy array): Target vector.
path (str): Path to the CSV file to save data.
"""
dump_svmlight_file(X, y, path, zero_based=False) | [
"def",
"save_libsvm",
"(",
"X",
",",
"y",
",",
"path",
")",
":",
"dump_svmlight_file",
"(",
"X",
",",
"y",
",",
"path",
",",
"zero_based",
"=",
"False",
")"
] | Save data as a LibSVM file.
Args:
X (numpy or scipy sparse matrix): Data matrix
y (numpy array): Target vector.
path (str): Path to the CSV file to save data. | [
"Save",
"data",
"as",
"a",
"LibSVM",
"file",
"."
] | python | train | 27.6 |
dls-controls/pymalcolm | malcolm/core/process.py | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/process.py#L152-L172 | def spawn(self, function, *args, **kwargs):
# type: (Callable[..., Any], *Any, **Any) -> Spawned
"""Runs the function in a worker thread, returning a Result object
Args:
function: Function to run
args: Positional arguments to run the function with
kwargs: Key... | [
"def",
"spawn",
"(",
"self",
",",
"function",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (Callable[..., Any], *Any, **Any) -> Spawned",
"assert",
"self",
".",
"state",
"!=",
"STOPPED",
",",
"\"Can't spawn when process stopped\"",
"spawned",
"=",
... | Runs the function in a worker thread, returning a Result object
Args:
function: Function to run
args: Positional arguments to run the function with
kwargs: Keyword arguments to run the function with
Returns:
Spawned: Something you can call wait(timeout) ... | [
"Runs",
"the",
"function",
"in",
"a",
"worker",
"thread",
"returning",
"a",
"Result",
"object"
] | python | train | 40.428571 |
edx/XBlock | xblock/runtime.py | https://github.com/edx/XBlock/blob/368bf46e2c0ee69bbb21817f428c4684936e18ee/xblock/runtime.py#L638-L651 | def get_block(self, usage_id, for_parent=None):
"""
Create an XBlock instance in this runtime.
The `usage_id` is used to find the XBlock class and data.
"""
def_id = self.id_reader.get_definition_id(usage_id)
try:
block_type = self.id_reader.get_block_type(de... | [
"def",
"get_block",
"(",
"self",
",",
"usage_id",
",",
"for_parent",
"=",
"None",
")",
":",
"def_id",
"=",
"self",
".",
"id_reader",
".",
"get_definition_id",
"(",
"usage_id",
")",
"try",
":",
"block_type",
"=",
"self",
".",
"id_reader",
".",
"get_block_ty... | Create an XBlock instance in this runtime.
The `usage_id` is used to find the XBlock class and data. | [
"Create",
"an",
"XBlock",
"instance",
"in",
"this",
"runtime",
"."
] | python | train | 39.928571 |
jd/tenacity | tenacity/before.py | https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/before.py#L24-L32 | def before_log(logger, log_level):
"""Before call strategy that logs to some logger the attempt."""
def log_it(retry_state):
logger.log(log_level,
"Starting call to '%s', this is the %s time calling it.",
_utils.get_callback_name(retry_state.fn),
... | [
"def",
"before_log",
"(",
"logger",
",",
"log_level",
")",
":",
"def",
"log_it",
"(",
"retry_state",
")",
":",
"logger",
".",
"log",
"(",
"log_level",
",",
"\"Starting call to '%s', this is the %s time calling it.\"",
",",
"_utils",
".",
"get_callback_name",
"(",
... | Before call strategy that logs to some logger the attempt. | [
"Before",
"call",
"strategy",
"that",
"logs",
"to",
"some",
"logger",
"the",
"attempt",
"."
] | python | train | 41.888889 |
evhub/coconut | coconut/compiler/compiler.py | https://github.com/evhub/coconut/blob/ff97177344e7604e89a0a98a977a87ed2a56fc6d/coconut/compiler/compiler.py#L1944-L1946 | def async_comp_check(self, original, loc, tokens):
"""Check for Python 3.6 async comprehension."""
return self.check_py("36", "async comprehension", original, loc, tokens) | [
"def",
"async_comp_check",
"(",
"self",
",",
"original",
",",
"loc",
",",
"tokens",
")",
":",
"return",
"self",
".",
"check_py",
"(",
"\"36\"",
",",
"\"async comprehension\"",
",",
"original",
",",
"loc",
",",
"tokens",
")"
] | Check for Python 3.6 async comprehension. | [
"Check",
"for",
"Python",
"3",
".",
"6",
"async",
"comprehension",
"."
] | python | train | 61.666667 |
qualisys/qualisys_python_sdk | examples/basic_example.py | https://github.com/qualisys/qualisys_python_sdk/blob/127d7eeebc2b38b5cafdfa5d1d0198437fedd274/examples/basic_example.py#L11-L17 | def on_packet(packet):
""" Callback function that is called everytime a data packet arrives from QTM """
print("Framenumber: {}".format(packet.framenumber))
header, markers = packet.get_3d_markers()
print("Component info: {}".format(header))
for marker in markers:
print("\t", marker) | [
"def",
"on_packet",
"(",
"packet",
")",
":",
"print",
"(",
"\"Framenumber: {}\"",
".",
"format",
"(",
"packet",
".",
"framenumber",
")",
")",
"header",
",",
"markers",
"=",
"packet",
".",
"get_3d_markers",
"(",
")",
"print",
"(",
"\"Component info: {}\"",
".... | Callback function that is called everytime a data packet arrives from QTM | [
"Callback",
"function",
"that",
"is",
"called",
"everytime",
"a",
"data",
"packet",
"arrives",
"from",
"QTM"
] | python | valid | 43.714286 |
dw/mitogen | mitogen/parent.py | https://github.com/dw/mitogen/blob/a7fdb55e1300a7e0a5e404b09eb730cf9a525da7/mitogen/parent.py#L1880-L1895 | def _propagate_up(self, handle, target_id, name=None):
"""
In a non-master context, propagate an update towards the master.
:param int handle:
:data:`mitogen.core.ADD_ROUTE` or :data:`mitogen.core.DEL_ROUTE`
:param int target_id:
ID of the connecting or disconnec... | [
"def",
"_propagate_up",
"(",
"self",
",",
"handle",
",",
"target_id",
",",
"name",
"=",
"None",
")",
":",
"if",
"self",
".",
"parent",
":",
"stream",
"=",
"self",
".",
"router",
".",
"stream_by_id",
"(",
"self",
".",
"parent",
".",
"context_id",
")",
... | In a non-master context, propagate an update towards the master.
:param int handle:
:data:`mitogen.core.ADD_ROUTE` or :data:`mitogen.core.DEL_ROUTE`
:param int target_id:
ID of the connecting or disconnecting context.
:param str name:
For :data:`mitogen.core.... | [
"In",
"a",
"non",
"-",
"master",
"context",
"propagate",
"an",
"update",
"towards",
"the",
"master",
"."
] | python | train | 44.75 |
saltstack/salt | salt/utils/cache.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cache.py#L172-L195 | def _read(self):
'''
Read in from disk
'''
if msgpack is None:
log.error('Cache cannot be read from the disk: msgpack is missing')
elif not os.path.exists(self._path):
log.debug('Cache path does not exist for reading: %s', self._path)
else:
... | [
"def",
"_read",
"(",
"self",
")",
":",
"if",
"msgpack",
"is",
"None",
":",
"log",
".",
"error",
"(",
"'Cache cannot be read from the disk: msgpack is missing'",
")",
"elif",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"_path",
")",
":",
"log... | Read in from disk | [
"Read",
"in",
"from",
"disk"
] | python | train | 48.666667 |
vmalyi/adb_android | adb_android/adb_android.py | https://github.com/vmalyi/adb_android/blob/de53dc54f27b14dc8c2ae64b136a60a59e1a1cb1/adb_android/adb_android.py#L28-L47 | def bugreport(dest_file="default.log"):
"""
Prints dumpsys, dumpstate, and logcat data to the screen, for the purposes of bug reporting
:return: result of _exec_command() execution
"""
adb_full_cmd = [v.ADB_COMMAND_PREFIX, v.ADB_COMMAND_BUGREPORT]
try:
dest_file_handler = open(dest_file,... | [
"def",
"bugreport",
"(",
"dest_file",
"=",
"\"default.log\"",
")",
":",
"adb_full_cmd",
"=",
"[",
"v",
".",
"ADB_COMMAND_PREFIX",
",",
"v",
".",
"ADB_COMMAND_BUGREPORT",
"]",
"try",
":",
"dest_file_handler",
"=",
"open",
"(",
"dest_file",
",",
"\"w\"",
")",
... | Prints dumpsys, dumpstate, and logcat data to the screen, for the purposes of bug reporting
:return: result of _exec_command() execution | [
"Prints",
"dumpsys",
"dumpstate",
"and",
"logcat",
"data",
"to",
"the",
"screen",
"for",
"the",
"purposes",
"of",
"bug",
"reporting",
":",
"return",
":",
"result",
"of",
"_exec_command",
"()",
"execution"
] | python | train | 41.35 |
bcbio/bcbio-nextgen | bcbio/variation/validate.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/validate.py#L305-L342 | def _pick_best_quality_score(vrn_file):
"""Flexible quality score selection, picking the best available.
Implementation based on discussion:
https://github.com/bcbio/bcbio-nextgen/commit/a538cecd86c0000d17d3f9d4f8ac9d2da04f9884#commitcomment-14539249
(RTG=AVR/GATK=VQSLOD/MuTect=t_lod_fstar, otherwise... | [
"def",
"_pick_best_quality_score",
"(",
"vrn_file",
")",
":",
"# pysam fails on checking reference contigs if input is empty",
"if",
"not",
"vcfutils",
".",
"vcf_has_variants",
"(",
"vrn_file",
")",
":",
"return",
"\"DP\"",
"to_check",
"=",
"25",
"scores",
"=",
"collect... | Flexible quality score selection, picking the best available.
Implementation based on discussion:
https://github.com/bcbio/bcbio-nextgen/commit/a538cecd86c0000d17d3f9d4f8ac9d2da04f9884#commitcomment-14539249
(RTG=AVR/GATK=VQSLOD/MuTect=t_lod_fstar, otherwise GQ, otherwise QUAL, otherwise DP.)
For Mu... | [
"Flexible",
"quality",
"score",
"selection",
"picking",
"the",
"best",
"available",
"."
] | python | train | 43.184211 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/color/color_array.py | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/color/color_array.py#L313-L317 | def value(self, val):
"""Set the color using length-N array of (from HSV)"""
hsv = self._hsv
hsv[:, 2] = _array_clip_val(val)
self.rgba = _hsv_to_rgb(hsv) | [
"def",
"value",
"(",
"self",
",",
"val",
")",
":",
"hsv",
"=",
"self",
".",
"_hsv",
"hsv",
"[",
":",
",",
"2",
"]",
"=",
"_array_clip_val",
"(",
"val",
")",
"self",
".",
"rgba",
"=",
"_hsv_to_rgb",
"(",
"hsv",
")"
] | Set the color using length-N array of (from HSV) | [
"Set",
"the",
"color",
"using",
"length",
"-",
"N",
"array",
"of",
"(",
"from",
"HSV",
")"
] | python | train | 36.4 |
HewlettPackard/python-hpOneView | hpOneView/resources/resource.py | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/resource.py#L1427-L1455 | def patch_request(self, id_or_uri, body, timeout=-1, custom_headers=None):
"""
Uses the PATCH to update a resource.
Only one operation can be performed in each PATCH call.
Args:
id_or_uri: Can be either the resource ID or the resource URI.
body: Patch request bo... | [
"def",
"patch_request",
"(",
"self",
",",
"id_or_uri",
",",
"body",
",",
"timeout",
"=",
"-",
"1",
",",
"custom_headers",
"=",
"None",
")",
":",
"uri",
"=",
"self",
".",
"build_uri",
"(",
"id_or_uri",
")",
"logger",
".",
"debug",
"(",
"'Patch resource (u... | Uses the PATCH to update a resource.
Only one operation can be performed in each PATCH call.
Args:
id_or_uri: Can be either the resource ID or the resource URI.
body: Patch request body
timeout: Timeout in seconds. Wait for task completion by default. The timeout do... | [
"Uses",
"the",
"PATCH",
"to",
"update",
"a",
"resource",
"."
] | python | train | 38.551724 |
Microsoft/azure-devops-python-api | azure-devops/azure/devops/v5_0/work/work_client.py | https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/work/work_client.py#L1186-L1219 | def update_team_days_off(self, days_off_patch, team_context, iteration_id):
"""UpdateTeamDaysOff.
Set a team's days off for an iteration
:param :class:`<TeamSettingsDaysOffPatch> <azure.devops.v5_0.work.models.TeamSettingsDaysOffPatch>` days_off_patch: Team's days off patch containting a list of... | [
"def",
"update_team_days_off",
"(",
"self",
",",
"days_off_patch",
",",
"team_context",
",",
"iteration_id",
")",
":",
"project",
"=",
"None",
"team",
"=",
"None",
"if",
"team_context",
"is",
"not",
"None",
":",
"if",
"team_context",
".",
"project_id",
":",
... | UpdateTeamDaysOff.
Set a team's days off for an iteration
:param :class:`<TeamSettingsDaysOffPatch> <azure.devops.v5_0.work.models.TeamSettingsDaysOffPatch>` days_off_patch: Team's days off patch containting a list of start and end dates
:param :class:`<TeamContext> <azure.devops.v5_0.work.model... | [
"UpdateTeamDaysOff",
".",
"Set",
"a",
"team",
"s",
"days",
"off",
"for",
"an",
"iteration",
":",
"param",
":",
"class",
":",
"<TeamSettingsDaysOffPatch",
">",
"<azure",
".",
"devops",
".",
"v5_0",
".",
"work",
".",
"models",
".",
"TeamSettingsDaysOffPatch",
... | python | train | 52.911765 |
jrspruitt/ubi_reader | ubireader/ubi_io.py | https://github.com/jrspruitt/ubi_reader/blob/7079dd380c1c9896bced30d6d34e8780b9181597/ubireader/ubi_io.py#L159-L167 | def read_block_data(self, block):
"""Read LEB data from file
Argument:
Obj:block -- Block data is desired for.
"""
self.seek(block.file_offset + block.ec_hdr.data_offset)
buf = self._fhandle.read(block.size - block.ec_hdr.data_offset - block.vid_hdr.data_pad)
... | [
"def",
"read_block_data",
"(",
"self",
",",
"block",
")",
":",
"self",
".",
"seek",
"(",
"block",
".",
"file_offset",
"+",
"block",
".",
"ec_hdr",
".",
"data_offset",
")",
"buf",
"=",
"self",
".",
"_fhandle",
".",
"read",
"(",
"block",
".",
"size",
"... | Read LEB data from file
Argument:
Obj:block -- Block data is desired for. | [
"Read",
"LEB",
"data",
"from",
"file",
"Argument",
":",
"Obj",
":",
"block",
"--",
"Block",
"data",
"is",
"desired",
"for",
"."
] | python | train | 36.333333 |
solocompt/plugs-mail | plugs_mail/utils.py | https://github.com/solocompt/plugs-mail/blob/6139fa79ddb437562db1769d03bd3098c25a06fa/plugs_mail/utils.py#L27-L35 | def to_staff(email_class, **data):
"""
Email staff users
"""
for user in get_user_model().objects.filter(is_staff=True):
try:
email_class().send([user.email], user.language, **data)
except AttributeError:
email_class().send([user.email], translation.get_language()... | [
"def",
"to_staff",
"(",
"email_class",
",",
"*",
"*",
"data",
")",
":",
"for",
"user",
"in",
"get_user_model",
"(",
")",
".",
"objects",
".",
"filter",
"(",
"is_staff",
"=",
"True",
")",
":",
"try",
":",
"email_class",
"(",
")",
".",
"send",
"(",
"... | Email staff users | [
"Email",
"staff",
"users"
] | python | train | 35.666667 |
google/grr | grr/client/grr_response_client/client_actions/osx/osx.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/osx/osx.py#L393-L419 | def OSXEnumerateRunningServicesFromClient(args):
"""Get running launchd jobs.
Args:
args: Unused.
Yields:
`rdf_client.OSXServiceInformation` instances.
Raises:
UnsupportedOSVersionError: for OS X earlier than 10.6.
"""
del args # Unused.
osx_version = client_utils_osx.OSXVersion()
vers... | [
"def",
"OSXEnumerateRunningServicesFromClient",
"(",
"args",
")",
":",
"del",
"args",
"# Unused.",
"osx_version",
"=",
"client_utils_osx",
".",
"OSXVersion",
"(",
")",
"version_array",
"=",
"osx_version",
".",
"VersionAsMajorMinor",
"(",
")",
"if",
"version_array",
... | Get running launchd jobs.
Args:
args: Unused.
Yields:
`rdf_client.OSXServiceInformation` instances.
Raises:
UnsupportedOSVersionError: for OS X earlier than 10.6. | [
"Get",
"running",
"launchd",
"jobs",
"."
] | python | train | 26.296296 |
tensorflow/tensor2tensor | tensor2tensor/data_generators/text_encoder.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/data_generators/text_encoder.py#L559-L574 | def _token_to_subtoken_ids(self, token):
"""Converts token to a list of subtoken ids.
Args:
token: a string.
Returns:
a list of integers in the range [0, vocab_size)
"""
cache_location = hash(token) % self._cache_size
cache_key, cache_value = self._cache[cache_location]
if cache... | [
"def",
"_token_to_subtoken_ids",
"(",
"self",
",",
"token",
")",
":",
"cache_location",
"=",
"hash",
"(",
"token",
")",
"%",
"self",
".",
"_cache_size",
"cache_key",
",",
"cache_value",
"=",
"self",
".",
"_cache",
"[",
"cache_location",
"]",
"if",
"cache_key... | Converts token to a list of subtoken ids.
Args:
token: a string.
Returns:
a list of integers in the range [0, vocab_size) | [
"Converts",
"token",
"to",
"a",
"list",
"of",
"subtoken",
"ids",
"."
] | python | train | 31.1875 |
cloudmesh/cloudmesh-common | cloudmesh/common/logger.py | https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/logger.py#L12-L61 | def LOGGER(filename):
"""creates a logger with the given name.
You can use it as follows::
log = cloudmesh.common.LOGGER(__file__)
log.error("this is an error")
log.info("this is an info")
log.warning("this is a warning")
"""
pwd = os.getcwd()
name = filename.replace(p... | [
"def",
"LOGGER",
"(",
"filename",
")",
":",
"pwd",
"=",
"os",
".",
"getcwd",
"(",
")",
"name",
"=",
"filename",
".",
"replace",
"(",
"pwd",
",",
"\"$PWD\"",
")",
"try",
":",
"(",
"first",
",",
"name",
")",
"=",
"name",
".",
"split",
"(",
"\"site-... | creates a logger with the given name.
You can use it as follows::
log = cloudmesh.common.LOGGER(__file__)
log.error("this is an error")
log.info("this is an info")
log.warning("this is a warning") | [
"creates",
"a",
"logger",
"with",
"the",
"given",
"name",
"."
] | python | train | 28.56 |
Shoobx/xmldiff | xmldiff/_diff_match_patch_py3.py | https://github.com/Shoobx/xmldiff/blob/ec7835bce9ba69ff4ce03ab6c11397183b6f8411/xmldiff/_diff_match_patch_py3.py#L138-L195 | def diff_compute(self, text1, text2, checklines, deadline):
"""Find the differences between two texts. Assumes that the texts do not
have any common prefix or suffix.
Args:
text1: Old string to be diffed.
text2: New string to be diffed.
checklines: Speedup flag. If false, then don't r... | [
"def",
"diff_compute",
"(",
"self",
",",
"text1",
",",
"text2",
",",
"checklines",
",",
"deadline",
")",
":",
"if",
"not",
"text1",
":",
"# Just add some text (speedup).",
"return",
"[",
"(",
"self",
".",
"DIFF_INSERT",
",",
"text2",
")",
"]",
"if",
"not",... | Find the differences between two texts. Assumes that the texts do not
have any common prefix or suffix.
Args:
text1: Old string to be diffed.
text2: New string to be diffed.
checklines: Speedup flag. If false, then don't run a line-level diff
first to identify the changed areas.
... | [
"Find",
"the",
"differences",
"between",
"two",
"texts",
".",
"Assumes",
"that",
"the",
"texts",
"do",
"not",
"have",
"any",
"common",
"prefix",
"or",
"suffix",
"."
] | python | train | 37.603448 |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/IPython/config/configurable.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/config/configurable.py#L152-L166 | def class_get_help(cls, inst=None):
"""Get the help string for this class in ReST format.
If `inst` is given, it's current trait values will be used in place of
class defaults.
"""
assert inst is None or isinstance(inst, cls)
cls_traits = cls.class_traits(config=... | [
"def",
"class_get_help",
"(",
"cls",
",",
"inst",
"=",
"None",
")",
":",
"assert",
"inst",
"is",
"None",
"or",
"isinstance",
"(",
"inst",
",",
"cls",
")",
"cls_traits",
"=",
"cls",
".",
"class_traits",
"(",
"config",
"=",
"True",
")",
"final_help",
"="... | Get the help string for this class in ReST format.
If `inst` is given, it's current trait values will be used in place of
class defaults. | [
"Get",
"the",
"help",
"string",
"for",
"this",
"class",
"in",
"ReST",
"format",
".",
"If",
"inst",
"is",
"given",
"it",
"s",
"current",
"trait",
"values",
"will",
"be",
"used",
"in",
"place",
"of",
"class",
"defaults",
"."
] | python | test | 42.533333 |
tanghaibao/goatools | goatools/anno/annoreader_base.py | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/annoreader_base.py#L131-L136 | def _get_goid2dbids(associations):
"""Return gene2go data for user-specified taxids."""
go2ids = cx.defaultdict(set)
for ntd in associations:
go2ids[ntd.GO_ID].add(ntd.DB_ID)
return dict(go2ids) | [
"def",
"_get_goid2dbids",
"(",
"associations",
")",
":",
"go2ids",
"=",
"cx",
".",
"defaultdict",
"(",
"set",
")",
"for",
"ntd",
"in",
"associations",
":",
"go2ids",
"[",
"ntd",
".",
"GO_ID",
"]",
".",
"add",
"(",
"ntd",
".",
"DB_ID",
")",
"return",
... | Return gene2go data for user-specified taxids. | [
"Return",
"gene2go",
"data",
"for",
"user",
"-",
"specified",
"taxids",
"."
] | python | train | 38.833333 |
happyleavesaoc/aoc-mgz | mgz/enums.py | https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/enums.py#L8-L81 | def ObjectEnum(ctx):
"""Object Enumeration.
Should export the whole list from the game for the best accuracy.
"""
return Enum(
ctx,
villager_male=83,
villager_female=293,
scout_cavalry=448,
eagle_warrior=751,
king=434,
flare=332,
relic=285... | [
"def",
"ObjectEnum",
"(",
"ctx",
")",
":",
"return",
"Enum",
"(",
"ctx",
",",
"villager_male",
"=",
"83",
",",
"villager_female",
"=",
"293",
",",
"scout_cavalry",
"=",
"448",
",",
"eagle_warrior",
"=",
"751",
",",
"king",
"=",
"434",
",",
"flare",
"="... | Object Enumeration.
Should export the whole list from the game for the best accuracy. | [
"Object",
"Enumeration",
"."
] | python | train | 21.202703 |
elastic/elasticsearch-dsl-py | elasticsearch_dsl/mapping.py | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/mapping.py#L40-L51 | def _collect_fields(self):
""" Iterate over all Field objects within, including multi fields. """
for f in itervalues(self.properties.to_dict()):
yield f
# multi fields
if hasattr(f, 'fields'):
for inner_f in itervalues(f.fields.to_dict()):
... | [
"def",
"_collect_fields",
"(",
"self",
")",
":",
"for",
"f",
"in",
"itervalues",
"(",
"self",
".",
"properties",
".",
"to_dict",
"(",
")",
")",
":",
"yield",
"f",
"# multi fields",
"if",
"hasattr",
"(",
"f",
",",
"'fields'",
")",
":",
"for",
"inner_f",... | Iterate over all Field objects within, including multi fields. | [
"Iterate",
"over",
"all",
"Field",
"objects",
"within",
"including",
"multi",
"fields",
"."
] | python | train | 41.833333 |
tensorflow/mesh | mesh_tensorflow/transformer/dataset.py | https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/transformer/dataset.py#L213-L250 | def packed_parallel_tsv_dataset(filenames=gin.REQUIRED,
dataset_split=gin.REQUIRED,
batch_size=gin.REQUIRED,
sequence_length=gin.REQUIRED,
vocabulary=gin.REQUIRED,
... | [
"def",
"packed_parallel_tsv_dataset",
"(",
"filenames",
"=",
"gin",
".",
"REQUIRED",
",",
"dataset_split",
"=",
"gin",
".",
"REQUIRED",
",",
"batch_size",
"=",
"gin",
".",
"REQUIRED",
",",
"sequence_length",
"=",
"gin",
".",
"REQUIRED",
",",
"vocabulary",
"=",... | Reads parallel tab-separated text file. One example per line. | [
"Reads",
"parallel",
"tab",
"-",
"separated",
"text",
"file",
".",
"One",
"example",
"per",
"line",
"."
] | python | train | 45.236842 |
pysathq/pysat | pysat/solvers.py | https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/pysat/solvers.py#L1660-L1667 | def get_core(self):
"""
Get an unsatisfiable core if the formula was previously
unsatisfied.
"""
if self.lingeling and self.status == False:
return pysolvers.lingeling_core(self.lingeling, self.prev_assumps) | [
"def",
"get_core",
"(",
"self",
")",
":",
"if",
"self",
".",
"lingeling",
"and",
"self",
".",
"status",
"==",
"False",
":",
"return",
"pysolvers",
".",
"lingeling_core",
"(",
"self",
".",
"lingeling",
",",
"self",
".",
"prev_assumps",
")"
] | Get an unsatisfiable core if the formula was previously
unsatisfied. | [
"Get",
"an",
"unsatisfiable",
"core",
"if",
"the",
"formula",
"was",
"previously",
"unsatisfied",
"."
] | python | train | 32.625 |
konomae/lastpass-python | lastpass/parser.py | https://github.com/konomae/lastpass-python/blob/5063911b789868a1fd9db9922db82cdf156b938a/lastpass/parser.py#L216-L226 | def decode_aes256_base64_auto(data, encryption_key):
"""Guesses AES cipher (EBC or CBD) from the length of the base64 encoded data."""
assert isinstance(data, bytes)
length = len(data)
if length == 0:
return b''
elif data[0] == b'!'[0]:
return decode_aes256_cbc_base64(data, encrypti... | [
"def",
"decode_aes256_base64_auto",
"(",
"data",
",",
"encryption_key",
")",
":",
"assert",
"isinstance",
"(",
"data",
",",
"bytes",
")",
"length",
"=",
"len",
"(",
"data",
")",
"if",
"length",
"==",
"0",
":",
"return",
"b''",
"elif",
"data",
"[",
"0",
... | Guesses AES cipher (EBC or CBD) from the length of the base64 encoded data. | [
"Guesses",
"AES",
"cipher",
"(",
"EBC",
"or",
"CBD",
")",
"from",
"the",
"length",
"of",
"the",
"base64",
"encoded",
"data",
"."
] | python | train | 35.363636 |
raymondEhlers/pachyderm | pachyderm/generic_config.py | https://github.com/raymondEhlers/pachyderm/blob/aaa1d8374fd871246290ce76f1796f2f7582b01d/pachyderm/generic_config.py#L193-L234 | def determine_selection_of_iterable_values_from_config(config: DictLike, possible_iterables: Mapping[str, Type[enum.Enum]]) -> Dict[str, List[Any]]:
""" Determine iterable values to use to create objects for a given configuration.
All values of an iterable can be included be setting the value to ``True`` (Not ... | [
"def",
"determine_selection_of_iterable_values_from_config",
"(",
"config",
":",
"DictLike",
",",
"possible_iterables",
":",
"Mapping",
"[",
"str",
",",
"Type",
"[",
"enum",
".",
"Enum",
"]",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"List",
"[",
"Any",
"]",
... | Determine iterable values to use to create objects for a given configuration.
All values of an iterable can be included be setting the value to ``True`` (Not as a single value list,
but as the only value.). Alternatively, an iterator can be disabled by setting the value to ``False``.
Args:
config:... | [
"Determine",
"iterable",
"values",
"to",
"use",
"to",
"create",
"objects",
"for",
"a",
"given",
"configuration",
"."
] | python | train | 47.880952 |
dslackw/slpkg | slpkg/slack/patches.py | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/slack/patches.py#L135-L157 | def store(self):
"""
Store and return packages for upgrading
"""
data = repo_data(self.PACKAGES_TXT, "slack", self.flag)
black = BlackList().packages(pkgs=data[0], repo="slack")
for name, loc, comp, uncomp in zip(data[0], data[1], data[2], data[3]):
status(0.0... | [
"def",
"store",
"(",
"self",
")",
":",
"data",
"=",
"repo_data",
"(",
"self",
".",
"PACKAGES_TXT",
",",
"\"slack\"",
",",
"self",
".",
"flag",
")",
"black",
"=",
"BlackList",
"(",
")",
".",
"packages",
"(",
"pkgs",
"=",
"data",
"[",
"0",
"]",
",",
... | Store and return packages for upgrading | [
"Store",
"and",
"return",
"packages",
"for",
"upgrading"
] | python | train | 46.956522 |
dls-controls/annotypes | annotypes/_fake_typing.py | https://github.com/dls-controls/annotypes/blob/31ab68a0367bb70ebd9898e8b9fa9405423465bd/annotypes/_fake_typing.py#L135-L140 | def _gorg(a):
"""Return the farthest origin of a generic class (internal helper)."""
assert isinstance(a, GenericMeta)
while a.__origin__ is not None:
a = a.__origin__
return a | [
"def",
"_gorg",
"(",
"a",
")",
":",
"assert",
"isinstance",
"(",
"a",
",",
"GenericMeta",
")",
"while",
"a",
".",
"__origin__",
"is",
"not",
"None",
":",
"a",
"=",
"a",
".",
"__origin__",
"return",
"a"
] | Return the farthest origin of a generic class (internal helper). | [
"Return",
"the",
"farthest",
"origin",
"of",
"a",
"generic",
"class",
"(",
"internal",
"helper",
")",
"."
] | python | train | 32.5 |
jut-io/jut-python-tools | jut/api/data_engine.py | https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/api/data_engine.py#L92-L102 | def get_import_data_url(deployment_name,
token_manager=None,
app_url=defaults.APP_URL):
"""
return the import data url
"""
return get_data_url(deployment_name,
endpoint_type='http-import',
app_url=app_url,
... | [
"def",
"get_import_data_url",
"(",
"deployment_name",
",",
"token_manager",
"=",
"None",
",",
"app_url",
"=",
"defaults",
".",
"APP_URL",
")",
":",
"return",
"get_data_url",
"(",
"deployment_name",
",",
"endpoint_type",
"=",
"'http-import'",
",",
"app_url",
"=",
... | return the import data url | [
"return",
"the",
"import",
"data",
"url"
] | python | train | 32.818182 |
Riminder/python-riminder-api | riminder/riminder.py | https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/riminder.py#L61-L64 | def patch(self, resource_endpoint, data={}):
"""Don't use it."""
url = self._create_request_url(resource_endpoint)
return req.patch(url, headers=self.auth_header, json=data) | [
"def",
"patch",
"(",
"self",
",",
"resource_endpoint",
",",
"data",
"=",
"{",
"}",
")",
":",
"url",
"=",
"self",
".",
"_create_request_url",
"(",
"resource_endpoint",
")",
"return",
"req",
".",
"patch",
"(",
"url",
",",
"headers",
"=",
"self",
".",
"au... | Don't use it. | [
"Don",
"t",
"use",
"it",
"."
] | python | train | 48.5 |
jxtech/wechatpy | wechatpy/client/api/customservice.py | https://github.com/jxtech/wechatpy/blob/4df0da795618c0895a10f1c2cde9e9d5c0a93aaa/wechatpy/client/api/customservice.py#L182-L196 | def get_session_list(self, account):
"""
获取客服的会话列表
详情请参考
http://mp.weixin.qq.com/wiki/2/6c20f3e323bdf5986cfcb33cbd3b829a.html
:param account: 完整客服账号
:return: 客服的会话列表
"""
res = self._get(
'https://api.weixin.qq.com/customservice/kfsession/getse... | [
"def",
"get_session_list",
"(",
"self",
",",
"account",
")",
":",
"res",
"=",
"self",
".",
"_get",
"(",
"'https://api.weixin.qq.com/customservice/kfsession/getsessionlist'",
",",
"params",
"=",
"{",
"'kf_account'",
":",
"account",
"}",
",",
"result_processor",
"=",
... | 获取客服的会话列表
详情请参考
http://mp.weixin.qq.com/wiki/2/6c20f3e323bdf5986cfcb33cbd3b829a.html
:param account: 完整客服账号
:return: 客服的会话列表 | [
"获取客服的会话列表",
"详情请参考",
"http",
":",
"//",
"mp",
".",
"weixin",
".",
"qq",
".",
"com",
"/",
"wiki",
"/",
"2",
"/",
"6c20f3e323bdf5986cfcb33cbd3b829a",
".",
"html"
] | python | train | 29.733333 |
Opentrons/opentrons | api/src/opentrons/legacy_api/instruments/pipette.py | https://github.com/Opentrons/opentrons/blob/a7c15cc2636ecb64ab56c7edc1d8a57163aaeadf/api/src/opentrons/legacy_api/instruments/pipette.py#L1256-L1371 | def transfer(self, volume, source, dest, **kwargs):
"""
Transfer will move a volume of liquid from a source location(s)
to a dest location(s). It is a higher-level command, incorporating
other :any:`Pipette` commands, like :any:`aspirate` and
:any:`dispense`, designed to make pro... | [
"def",
"transfer",
"(",
"self",
",",
"volume",
",",
"source",
",",
"dest",
",",
"*",
"*",
"kwargs",
")",
":",
"# Note: currently it varies whether the pipette should have a tip on",
"# or not depending on the parameters for this call, so we cannot",
"# create a very reliable asse... | Transfer will move a volume of liquid from a source location(s)
to a dest location(s). It is a higher-level command, incorporating
other :any:`Pipette` commands, like :any:`aspirate` and
:any:`dispense`, designed to make protocol writing easier at the
cost of specificity.
Parame... | [
"Transfer",
"will",
"move",
"a",
"volume",
"of",
"liquid",
"from",
"a",
"source",
"location",
"(",
"s",
")",
"to",
"a",
"dest",
"location",
"(",
"s",
")",
".",
"It",
"is",
"a",
"higher",
"-",
"level",
"command",
"incorporating",
"other",
":",
"any",
... | python | train | 42.405172 |
NuGrid/NuGridPy | nugridpy/astronomy.py | https://github.com/NuGrid/NuGridPy/blob/eee8047446e398be77362d82c1d8b3310054fab0/nugridpy/astronomy.py#L384-L399 | def Nasv(macs,T):
'''
Returns
-------
Na*<sigma v>
for MACS [mb] at T [K].
'''
Na = avogadro_constant
k = boltzmann_constant
vtherm=(2.*k*T/mass_H_atom)**0.5
s = macs*1.e-27
Nasv = s*vtherm*Na
return Nasv | [
"def",
"Nasv",
"(",
"macs",
",",
"T",
")",
":",
"Na",
"=",
"avogadro_constant",
"k",
"=",
"boltzmann_constant",
"vtherm",
"=",
"(",
"2.",
"*",
"k",
"*",
"T",
"/",
"mass_H_atom",
")",
"**",
"0.5",
"s",
"=",
"macs",
"*",
"1.e-27",
"Nasv",
"=",
"s",
... | Returns
-------
Na*<sigma v>
for MACS [mb] at T [K]. | [
"Returns",
"-------",
"Na",
"*",
"<sigma",
"v",
">",
"for",
"MACS",
"[",
"mb",
"]",
"at",
"T",
"[",
"K",
"]",
"."
] | python | train | 15.9375 |
mitsei/dlkit | dlkit/json_/osid/objects.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/osid/objects.py#L859-L912 | def _is_valid_input(self, inpt, metadata, array):
"""The _is_valid_input method takes three arguments:
the user input to be checked, the associated osid.Metadata object
containing validation requirements and a boolean value indicating
whether this is an array value.
"""
... | [
"def",
"_is_valid_input",
"(",
"self",
",",
"inpt",
",",
"metadata",
",",
"array",
")",
":",
"# pylint: disable=too-many-branches,no-self-use",
"# Please redesign, and move to utility module",
"syntax",
"=",
"metadata",
".",
"get_syntax",
"(",
")",
"# First check if this is... | The _is_valid_input method takes three arguments:
the user input to be checked, the associated osid.Metadata object
containing validation requirements and a boolean value indicating
whether this is an array value. | [
"The",
"_is_valid_input",
"method",
"takes",
"three",
"arguments",
":"
] | python | train | 39.981481 |
fermiPy/fermipy | fermipy/gtanalysis.py | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L1786-L1798 | def set_parameter_scale(self, name, par, scale):
"""Update the scale of a parameter while keeping its value constant."""
name = self.roi.get_source_by_name(name).name
idx = self.like.par_index(name, par)
current_bounds = list(self.like.model[idx].getBounds())
current_scale = self... | [
"def",
"set_parameter_scale",
"(",
"self",
",",
"name",
",",
"par",
",",
"scale",
")",
":",
"name",
"=",
"self",
".",
"roi",
".",
"get_source_by_name",
"(",
"name",
")",
".",
"name",
"idx",
"=",
"self",
".",
"like",
".",
"par_index",
"(",
"name",
","... | Update the scale of a parameter while keeping its value constant. | [
"Update",
"the",
"scale",
"of",
"a",
"parameter",
"while",
"keeping",
"its",
"value",
"constant",
"."
] | python | train | 52.307692 |
CalebBell/thermo | thermo/utils.py | https://github.com/CalebBell/thermo/blob/3857ed023a3e64fd3039a32d53576c24990ef1c3/thermo/utils.py#L1263-L1309 | def allclose_variable(a, b, limits, rtols=None, atols=None):
'''Returns True if two arrays are element-wise equal within several
different tolerances. Tolerance values are always positive, usually
very small. Based on numpy's allclose function.
Only atols or rtols needs to be specified; both are u... | [
"def",
"allclose_variable",
"(",
"a",
",",
"b",
",",
"limits",
",",
"rtols",
"=",
"None",
",",
"atols",
"=",
"None",
")",
":",
"l",
"=",
"float",
"(",
"len",
"(",
"a",
")",
")",
"if",
"rtols",
"is",
"None",
"and",
"atols",
"is",
"None",
":",
"r... | Returns True if two arrays are element-wise equal within several
different tolerances. Tolerance values are always positive, usually
very small. Based on numpy's allclose function.
Only atols or rtols needs to be specified; both are used if given.
Parameters
----------
a, b : array_li... | [
"Returns",
"True",
"if",
"two",
"arrays",
"are",
"element",
"-",
"wise",
"equal",
"within",
"several",
"different",
"tolerances",
".",
"Tolerance",
"values",
"are",
"always",
"positive",
"usually",
"very",
"small",
".",
"Based",
"on",
"numpy",
"s",
"allclose",... | python | valid | 42.042553 |
assamite/creamas | creamas/core/environment.py | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/core/environment.py#L198-L215 | def create_connections(self, connection_map):
'''Create agent connections from a given connection map.
:param dict connection_map:
A map of connections to be created. Dictionary where keys are
agent addresses and values are lists of (addr, attitude)-tuples
suitable f... | [
"def",
"create_connections",
"(",
"self",
",",
"connection_map",
")",
":",
"agents",
"=",
"self",
".",
"get_agents",
"(",
"addr",
"=",
"False",
")",
"rets",
"=",
"[",
"]",
"for",
"a",
"in",
"agents",
":",
"if",
"a",
".",
"addr",
"in",
"connection_map",... | Create agent connections from a given connection map.
:param dict connection_map:
A map of connections to be created. Dictionary where keys are
agent addresses and values are lists of (addr, attitude)-tuples
suitable for
:meth:`~creamas.core.agent.CreativeAgent.a... | [
"Create",
"agent",
"connections",
"from",
"a",
"given",
"connection",
"map",
"."
] | python | train | 38.722222 |
CartoDB/cartoframes | cartoframes/context.py | https://github.com/CartoDB/cartoframes/blob/c94238a545f3dec45963dac3892540942b6f0df8/cartoframes/context.py#L368-L383 | def delete(self, table_name):
"""Delete a table in user's CARTO account.
Args:
table_name (str): Name of table to delete
Returns:
bool: `True` if table is removed
"""
dataset = Dataset(self, table_name)
deleted = dataset.delete()
if dele... | [
"def",
"delete",
"(",
"self",
",",
"table_name",
")",
":",
"dataset",
"=",
"Dataset",
"(",
"self",
",",
"table_name",
")",
"deleted",
"=",
"dataset",
".",
"delete",
"(",
")",
"if",
"deleted",
":",
"return",
"deleted",
"raise",
"CartoException",
"(",
"'''... | Delete a table in user's CARTO account.
Args:
table_name (str): Name of table to delete
Returns:
bool: `True` if table is removed | [
"Delete",
"a",
"table",
"in",
"user",
"s",
"CARTO",
"account",
"."
] | python | train | 26.3125 |
MaT1g3R/option | option/result.py | https://github.com/MaT1g3R/option/blob/37c954e6e74273d48649b3236bc881a1286107d6/option/result.py#L278-L296 | def unwrap_or_else(self, op: Callable[[E], U]) -> Union[T, U]:
"""
Returns the sucess value in the :class:`Result` or computes a default
from the error value.
Args:
op: The function to computes default with.
Returns:
The success value in the :class:`Resu... | [
"def",
"unwrap_or_else",
"(",
"self",
",",
"op",
":",
"Callable",
"[",
"[",
"E",
"]",
",",
"U",
"]",
")",
"->",
"Union",
"[",
"T",
",",
"U",
"]",
":",
"return",
"cast",
"(",
"T",
",",
"self",
".",
"_val",
")",
"if",
"self",
".",
"_is_ok",
"el... | Returns the sucess value in the :class:`Result` or computes a default
from the error value.
Args:
op: The function to computes default with.
Returns:
The success value in the :class:`Result` if it is
a :meth:`Result.Ok` value, otherwise ``op(E)``.
... | [
"Returns",
"the",
"sucess",
"value",
"in",
"the",
":",
"class",
":",
"Result",
"or",
"computes",
"a",
"default",
"from",
"the",
"error",
"value",
"."
] | python | train | 32.789474 |
bcbio/bcbio-nextgen | bcbio/variation/vcfutils.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vcfutils.py#L680-L690 | def cyvcf_add_filter(rec, name):
"""Add a FILTER value to a cyvcf2 record
"""
if rec.FILTER:
filters = rec.FILTER.split(";")
else:
filters = []
if name not in filters:
filters.append(name)
rec.FILTER = filters
return rec | [
"def",
"cyvcf_add_filter",
"(",
"rec",
",",
"name",
")",
":",
"if",
"rec",
".",
"FILTER",
":",
"filters",
"=",
"rec",
".",
"FILTER",
".",
"split",
"(",
"\";\"",
")",
"else",
":",
"filters",
"=",
"[",
"]",
"if",
"name",
"not",
"in",
"filters",
":",
... | Add a FILTER value to a cyvcf2 record | [
"Add",
"a",
"FILTER",
"value",
"to",
"a",
"cyvcf2",
"record"
] | python | train | 24.181818 |
schlamar/cov-core | cov_core.py | https://github.com/schlamar/cov-core/blob/791b1f6890456ee9e3beec33c89a7c573a382b7b/cov_core.py#L167-L172 | def configure_node(self, node):
"""Slaves need to know if they are collocated and what files have moved."""
node.slaveinput['cov_master_host'] = socket.gethostname()
node.slaveinput['cov_master_topdir'] = self.topdir
node.slaveinput['cov_master_rsync_roots'] = [str(root) for root in nod... | [
"def",
"configure_node",
"(",
"self",
",",
"node",
")",
":",
"node",
".",
"slaveinput",
"[",
"'cov_master_host'",
"]",
"=",
"socket",
".",
"gethostname",
"(",
")",
"node",
".",
"slaveinput",
"[",
"'cov_master_topdir'",
"]",
"=",
"self",
".",
"topdir",
"nod... | Slaves need to know if they are collocated and what files have moved. | [
"Slaves",
"need",
"to",
"know",
"if",
"they",
"are",
"collocated",
"and",
"what",
"files",
"have",
"moved",
"."
] | python | train | 55.833333 |
librosa/librosa | librosa/core/time_frequency.py | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/core/time_frequency.py#L1014-L1067 | def times_like(X, sr=22050, hop_length=512, n_fft=None, axis=-1):
"""Return an array of time values to match the time axis from a feature matrix.
Parameters
----------
X : np.ndarray or scalar
- If ndarray, X is a feature matrix, e.g. STFT, chromagram, or mel spectrogram.
- If scalar, X... | [
"def",
"times_like",
"(",
"X",
",",
"sr",
"=",
"22050",
",",
"hop_length",
"=",
"512",
",",
"n_fft",
"=",
"None",
",",
"axis",
"=",
"-",
"1",
")",
":",
"samples",
"=",
"samples_like",
"(",
"X",
",",
"hop_length",
"=",
"hop_length",
",",
"n_fft",
"=... | Return an array of time values to match the time axis from a feature matrix.
Parameters
----------
X : np.ndarray or scalar
- If ndarray, X is a feature matrix, e.g. STFT, chromagram, or mel spectrogram.
- If scalar, X represents the number of frames.
sr : number > 0 [scalar]
a... | [
"Return",
"an",
"array",
"of",
"time",
"values",
"to",
"match",
"the",
"time",
"axis",
"from",
"a",
"feature",
"matrix",
"."
] | python | test | 32.87037 |
Julian/Ivoire | ivoire/run.py | https://github.com/Julian/Ivoire/blob/5b8218cffa409ed733cf850a6fde16fafb8fc2af/ivoire/run.py#L45-L59 | def parse(argv=None):
"""
Parse some arguments using the parser.
"""
if argv is None:
argv = sys.argv[1:]
# Evade http://bugs.python.org/issue9253
if not argv or argv[0] not in {"run", "transform"}:
argv = ["run"] + argv
arguments = _clean(_parser.parse_args(argv))
re... | [
"def",
"parse",
"(",
"argv",
"=",
"None",
")",
":",
"if",
"argv",
"is",
"None",
":",
"argv",
"=",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
"# Evade http://bugs.python.org/issue9253",
"if",
"not",
"argv",
"or",
"argv",
"[",
"0",
"]",
"not",
"in",
"{",
... | Parse some arguments using the parser. | [
"Parse",
"some",
"arguments",
"using",
"the",
"parser",
"."
] | python | test | 21.333333 |
mgedmin/check-manifest | check_manifest.py | https://github.com/mgedmin/check-manifest/blob/7f787e8272f56c5750670bfb3223509e0df72708/check_manifest.py#L701-L771 | def _get_ignore_from_manifest_lines(lines):
"""Gather the various ignore patterns from a MANIFEST.in.
'lines' should be a list of strings with comments removed
and continuation lines joined.
Returns a list of standard ignore patterns and a list of regular
expressions to ignore.
"""
ignore ... | [
"def",
"_get_ignore_from_manifest_lines",
"(",
"lines",
")",
":",
"ignore",
"=",
"[",
"]",
"ignore_regexps",
"=",
"[",
"]",
"for",
"line",
"in",
"lines",
":",
"try",
":",
"cmd",
",",
"rest",
"=",
"line",
".",
"split",
"(",
"None",
",",
"1",
")",
"exc... | Gather the various ignore patterns from a MANIFEST.in.
'lines' should be a list of strings with comments removed
and continuation lines joined.
Returns a list of standard ignore patterns and a list of regular
expressions to ignore. | [
"Gather",
"the",
"various",
"ignore",
"patterns",
"from",
"a",
"MANIFEST",
".",
"in",
"."
] | python | train | 46.169014 |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/ietf_netconf_monitoring.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/ietf_netconf_monitoring.py#L509-L520 | def get_schema_input_version(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
get_schema = ET.Element("get_schema")
config = get_schema
input = ET.SubElement(get_schema, "input")
version = ET.SubElement(input, "version")
version.te... | [
"def",
"get_schema_input_version",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"get_schema",
"=",
"ET",
".",
"Element",
"(",
"\"get_schema\"",
")",
"config",
"=",
"get_schema",
"input",
"=",
... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 35.5 |
luckydonald/pytgbot | code_generation/output/pytgbot/api_types/receivable/peer.py | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/receivable/peer.py#L373-L403 | def from_array(array):
"""
Deserialize a new Chat from a given dictionary.
:return: new Chat instance.
:rtype: Chat
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
from ... | [
"def",
"from_array",
"(",
"array",
")",
":",
"if",
"array",
"is",
"None",
"or",
"not",
"array",
":",
"return",
"None",
"# end if",
"assert_type_or_raise",
"(",
"array",
",",
"dict",
",",
"parameter_name",
"=",
"\"array\"",
")",
"from",
"pytgbot",
".",
"api... | Deserialize a new Chat from a given dictionary.
:return: new Chat instance.
:rtype: Chat | [
"Deserialize",
"a",
"new",
"Chat",
"from",
"a",
"given",
"dictionary",
"."
] | python | train | 59.935484 |
asphalt-framework/asphalt | asphalt/core/context.py | https://github.com/asphalt-framework/asphalt/blob/4114b3ac9743cbd9facb374a3f53e19d3afef22d/asphalt/core/context.py#L487-L502 | def call_async(self, func: Callable, *args, **kwargs):
"""
Call the given callable in the event loop thread.
This method lets you call asynchronous code from a worker thread.
Do not use it from within the event loop thread.
If the callable returns an awaitable, it is resolved b... | [
"def",
"call_async",
"(",
"self",
",",
"func",
":",
"Callable",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"asyncio_extras",
".",
"call_async",
"(",
"self",
".",
"loop",
",",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")... | Call the given callable in the event loop thread.
This method lets you call asynchronous code from a worker thread.
Do not use it from within the event loop thread.
If the callable returns an awaitable, it is resolved before returning to the caller.
:param func: a regular function or ... | [
"Call",
"the",
"given",
"callable",
"in",
"the",
"event",
"loop",
"thread",
"."
] | python | train | 41.8125 |
adamcharnock/swiftwind | swiftwind/costs/models.py | https://github.com/adamcharnock/swiftwind/blob/72c715800841c3b2feabded3f3b65b76388b4cea/swiftwind/costs/models.py#L236-L248 | def _is_ready(self, as_of):
"""Is the RecurringCost ready to be enacted as of the date `as_of`
This determines if `as_of` precedes the start of `initial_billing_cycle`. If so,
we should not be enacting this RecurringCost yet.
Args:
as_of (Date):
"""
if self.... | [
"def",
"_is_ready",
"(",
"self",
",",
"as_of",
")",
":",
"if",
"self",
".",
"is_one_off",
"(",
")",
":",
"return",
"self",
".",
"initial_billing_cycle",
".",
"date_range",
".",
"lower",
"<=",
"as_of",
"else",
":",
"return",
"True"
] | Is the RecurringCost ready to be enacted as of the date `as_of`
This determines if `as_of` precedes the start of `initial_billing_cycle`. If so,
we should not be enacting this RecurringCost yet.
Args:
as_of (Date): | [
"Is",
"the",
"RecurringCost",
"ready",
"to",
"be",
"enacted",
"as",
"of",
"the",
"date",
"as_of"
] | python | train | 33.153846 |
mstuttgart/pycep-correios | pycep_correios/cliente.py | https://github.com/mstuttgart/pycep-correios/blob/99f98b08f9a78a11373804bffe618f26f893518d/pycep_correios/cliente.py#L34-L74 | def consultar_cep(cep, ambiente=PRODUCAO):
"""Retorna o endereço correspondente ao número de CEP informado.
Arguments:
cep {str} -- CEP a ser consultado.
Keyword Arguments:
ambiente {int} -- Indica qual será o webservice utilizado na consulta de CEP. Valor default é PRODUCAO (default: {PRO... | [
"def",
"consultar_cep",
"(",
"cep",
",",
"ambiente",
"=",
"PRODUCAO",
")",
":",
"if",
"ambiente",
"not",
"in",
"URL",
":",
"raise",
"KeyError",
"(",
"'Ambiente inválido! Valor deve ser 1 para produção e 2 '",
"'para homologação')",
"",
"try",
":",
"with",
"warnings"... | Retorna o endereço correspondente ao número de CEP informado.
Arguments:
cep {str} -- CEP a ser consultado.
Keyword Arguments:
ambiente {int} -- Indica qual será o webservice utilizado na consulta de CEP. Valor default é PRODUCAO (default: {PRODUCAO})
Raises:
KeyError -- Quando am... | [
"Retorna",
"o",
"endereço",
"correspondente",
"ao",
"número",
"de",
"CEP",
"informado",
"."
] | python | train | 36.243902 |
secdev/scapy | scapy/arch/common.py | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/common.py#L128-L150 | def get_bpf_pointer(tcpdump_lines):
"""Create a BPF Pointer for TCPDump filter"""
if conf.use_pypy:
return _legacy_bpf_pointer(tcpdump_lines)
# Allocate BPF instructions
size = int(tcpdump_lines[0])
bpf_insn_a = bpf_insn * size
bip = bpf_insn_a()
# Fill the BPF instruction structur... | [
"def",
"get_bpf_pointer",
"(",
"tcpdump_lines",
")",
":",
"if",
"conf",
".",
"use_pypy",
":",
"return",
"_legacy_bpf_pointer",
"(",
"tcpdump_lines",
")",
"# Allocate BPF instructions",
"size",
"=",
"int",
"(",
"tcpdump_lines",
"[",
"0",
"]",
")",
"bpf_insn_a",
"... | Create a BPF Pointer for TCPDump filter | [
"Create",
"a",
"BPF",
"Pointer",
"for",
"TCPDump",
"filter"
] | python | train | 29.652174 |
apriha/lineage | src/lineage/snps.py | https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/snps.py#L272-L306 | def _read_ftdna_famfinder(file):
""" Read and parse Family Tree DNA (FTDNA) "famfinder" file.
https://www.familytreedna.com
Parameters
----------
file : str
path to file
Returns
-------
pandas.DataFrame
individual's genetic data ... | [
"def",
"_read_ftdna_famfinder",
"(",
"file",
")",
":",
"df",
"=",
"pd",
".",
"read_csv",
"(",
"file",
",",
"comment",
"=",
"\"#\"",
",",
"na_values",
"=",
"\"-\"",
",",
"names",
"=",
"[",
"\"rsid\"",
",",
"\"chrom\"",
",",
"\"pos\"",
",",
"\"allele1\"",
... | Read and parse Family Tree DNA (FTDNA) "famfinder" file.
https://www.familytreedna.com
Parameters
----------
file : str
path to file
Returns
-------
pandas.DataFrame
individual's genetic data normalized for use with `lineage`
str... | [
"Read",
"and",
"parse",
"Family",
"Tree",
"DNA",
"(",
"FTDNA",
")",
"famfinder",
"file",
"."
] | python | train | 25.371429 |
python-visualization/folium | folium/features.py | https://github.com/python-visualization/folium/blob/8595240517135d1637ca4cf7cc624045f1d911b3/folium/features.py#L469-L494 | def process_data(self, data):
"""Convert an unknown data input into a geojson dictionary."""
if isinstance(data, dict):
self.embed = True
return data
elif isinstance(data, str):
if data.lower().startswith(('http:', 'ftp:', 'https:')):
if not se... | [
"def",
"process_data",
"(",
"self",
",",
"data",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"dict",
")",
":",
"self",
".",
"embed",
"=",
"True",
"return",
"data",
"elif",
"isinstance",
"(",
"data",
",",
"str",
")",
":",
"if",
"data",
".",
"low... | Convert an unknown data input into a geojson dictionary. | [
"Convert",
"an",
"unknown",
"data",
"input",
"into",
"a",
"geojson",
"dictionary",
"."
] | python | train | 43.538462 |
lightning-viz/lightning-python | lightning/types/base.py | https://github.com/lightning-viz/lightning-python/blob/68563e1da82d162d204069d7586f7c695b8bd4a6/lightning/types/base.py#L141-L179 | def _baseplot(cls, session, type, *args, **kwargs):
"""
Base method for plotting data and images.
Applies a plot-type specific cleaning operation to generate
a dictionary with the data, then creates a visualization with the data.
Expects a session and a type, followed by all pl... | [
"def",
"_baseplot",
"(",
"cls",
",",
"session",
",",
"type",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"type",
":",
"raise",
"Exception",
"(",
"\"Must provide a plot type\"",
")",
"options",
",",
"description",
"=",
"cls",
".",
... | Base method for plotting data and images.
Applies a plot-type specific cleaning operation to generate
a dictionary with the data, then creates a visualization with the data.
Expects a session and a type, followed by all plot-type specific
positional and keyword arguments, which will be... | [
"Base",
"method",
"for",
"plotting",
"data",
"and",
"images",
"."
] | python | train | 40.205128 |
opentok/Opentok-Python-SDK | opentok/opentok.py | https://github.com/opentok/Opentok-Python-SDK/blob/ffc6714e76be0d29e6b56aff8cbf7509b71a8b2c/opentok/opentok.py#L415-L434 | def delete_archive(self, archive_id):
"""
Deletes an OpenTok archive.
You can only delete an archive which has a status of "available" or "uploaded". Deleting an
archive removes its record from the list of archives. For an "available" archive, it also
removes the archive file, m... | [
"def",
"delete_archive",
"(",
"self",
",",
"archive_id",
")",
":",
"response",
"=",
"requests",
".",
"delete",
"(",
"self",
".",
"endpoints",
".",
"archive_url",
"(",
"archive_id",
")",
",",
"headers",
"=",
"self",
".",
"json_headers",
"(",
")",
",",
"pr... | Deletes an OpenTok archive.
You can only delete an archive which has a status of "available" or "uploaded". Deleting an
archive removes its record from the list of archives. For an "available" archive, it also
removes the archive file, making it unavailable for download.
:param String ... | [
"Deletes",
"an",
"OpenTok",
"archive",
"."
] | python | train | 44.9 |
codelv/enaml-native | examples/playground/main.py | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/examples/playground/main.py#L25-L41 | def main():
""" Called by PyBridge.start()
"""
#: If we set the TMP env variable the dev reloader will save file
#: and load changes in this directory instead of overwriting the
#: ones installed with the app.
os.environ['TMP'] = os.path.join(sys.path[0], '../tmp')
from enamlnative.android... | [
"def",
"main",
"(",
")",
":",
"#: If we set the TMP env variable the dev reloader will save file",
"#: and load changes in this directory instead of overwriting the",
"#: ones installed with the app.",
"os",
".",
"environ",
"[",
"'TMP'",
"]",
"=",
"os",
".",
"path",
".",
"join"... | Called by PyBridge.start() | [
"Called",
"by",
"PyBridge",
".",
"start",
"()"
] | python | train | 28.352941 |
mdgoldberg/sportsref | sportsref/nfl/teams.py | https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/teams.py#L265-L280 | def sos(self, year):
"""Returns the SOS (Strength of Schedule) for a team in a year, based
on SRS.
:year: The year for the season in question.
:returns: A float of SOS.
"""
try:
sos_text = self._year_info_pq(year, 'SOS').text()
except ValueError:
... | [
"def",
"sos",
"(",
"self",
",",
"year",
")",
":",
"try",
":",
"sos_text",
"=",
"self",
".",
"_year_info_pq",
"(",
"year",
",",
"'SOS'",
")",
".",
"text",
"(",
")",
"except",
"ValueError",
":",
"return",
"None",
"m",
"=",
"re",
".",
"search",
"(",
... | Returns the SOS (Strength of Schedule) for a team in a year, based
on SRS.
:year: The year for the season in question.
:returns: A float of SOS. | [
"Returns",
"the",
"SOS",
"(",
"Strength",
"of",
"Schedule",
")",
"for",
"a",
"team",
"in",
"a",
"year",
"based",
"on",
"SRS",
"."
] | python | test | 29.0625 |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/brocade_trilloam.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_trilloam.py#L238-L252 | def l2traceroute_result_output_l2_hop_results_l2_hop_egress_interface_type(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
l2traceroute_result = ET.Element("l2traceroute_result")
config = l2traceroute_result
output = ET.SubElement(l2traceroute_re... | [
"def",
"l2traceroute_result_output_l2_hop_results_l2_hop_egress_interface_type",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"l2traceroute_result",
"=",
"ET",
".",
"Element",
"(",
"\"l2traceroute_result\... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 47.133333 |
LuqueDaniel/pybooru | pybooru/moebooru.py | https://github.com/LuqueDaniel/pybooru/blob/60cd5254684d293b308f0b11b8f4ac2dce101479/pybooru/moebooru.py#L90-L102 | def _build_url(self, api_call):
"""Build request url.
Parameters:
api_call (str): Base API Call.
Returns:
Complete url (str).
"""
if self.api_version in ('1.13.0', '1.13.0+update.1', '1.13.0+update.2'):
if '/' not in api_call:
... | [
"def",
"_build_url",
"(",
"self",
",",
"api_call",
")",
":",
"if",
"self",
".",
"api_version",
"in",
"(",
"'1.13.0'",
",",
"'1.13.0+update.1'",
",",
"'1.13.0+update.2'",
")",
":",
"if",
"'/'",
"not",
"in",
"api_call",
":",
"return",
"\"{0}/{1}/index.json\"",
... | Build request url.
Parameters:
api_call (str): Base API Call.
Returns:
Complete url (str). | [
"Build",
"request",
"url",
"."
] | python | train | 33.076923 |
e7dal/bubble3 | behave4cmd0/textutil.py | https://github.com/e7dal/bubble3/blob/59c735281a95b44f6263a25f4d6ce24fca520082/behave4cmd0/textutil.py#L164-L172 | def text_remove_empty_lines(text):
"""
Whitespace normalization:
- Strip empty lines
- Strip trailing whitespace
"""
lines = [ line.rstrip() for line in text.splitlines() if line.strip() ]
return "\n".join(lines) | [
"def",
"text_remove_empty_lines",
"(",
"text",
")",
":",
"lines",
"=",
"[",
"line",
".",
"rstrip",
"(",
")",
"for",
"line",
"in",
"text",
".",
"splitlines",
"(",
")",
"if",
"line",
".",
"strip",
"(",
")",
"]",
"return",
"\"\\n\"",
".",
"join",
"(",
... | Whitespace normalization:
- Strip empty lines
- Strip trailing whitespace | [
"Whitespace",
"normalization",
":"
] | python | train | 26.555556 |
materialsproject/pymatgen | pymatgen/io/xr.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/xr.py#L142-L162 | def from_file(filename, use_cores=True, thresh=1.e-4):
"""
Reads an xr-formatted file to create an Xr object.
Args:
filename (str): name of file to read from.
use_cores (bool): use core positions and discard shell
positions if set to True (default). ... | [
"def",
"from_file",
"(",
"filename",
",",
"use_cores",
"=",
"True",
",",
"thresh",
"=",
"1.e-4",
")",
":",
"with",
"zopen",
"(",
"filename",
",",
"\"rt\"",
")",
"as",
"f",
":",
"return",
"Xr",
".",
"from_string",
"(",
"f",
".",
"read",
"(",
")",
",... | Reads an xr-formatted file to create an Xr object.
Args:
filename (str): name of file to read from.
use_cores (bool): use core positions and discard shell
positions if set to True (default). Otherwise,
use shell positions and discard core positio... | [
"Reads",
"an",
"xr",
"-",
"formatted",
"file",
"to",
"create",
"an",
"Xr",
"object",
"."
] | python | train | 41.142857 |
aholkner/bacon | native/Vendor/FreeType/src/tools/glnames.py | https://github.com/aholkner/bacon/blob/edf3810dcb211942d392a8637945871399b0650d/native/Vendor/FreeType/src/tools/glnames.py#L5238-L5479 | def main():
"""main program body"""
if len( sys.argv ) != 2:
print __doc__ % sys.argv[0]
sys.exit( 1 )
file = open( sys.argv[1], "w\n" )
write = file.write
count_sid = len( sid_standard_names )
# `mac_extras' contains the list of glyph names in the Macintosh standard
# encoding which are not ... | [
"def",
"main",
"(",
")",
":",
"if",
"len",
"(",
"sys",
".",
"argv",
")",
"!=",
"2",
":",
"print",
"__doc__",
"%",
"sys",
".",
"argv",
"[",
"0",
"]",
"sys",
".",
"exit",
"(",
"1",
")",
"file",
"=",
"open",
"(",
"sys",
".",
"argv",
"[",
"1",
... | main program body | [
"main",
"program",
"body"
] | python | test | 26.239669 |
ungarj/mapchete | mapchete/formats/default/geojson.py | https://github.com/ungarj/mapchete/blob/d482918d0e66a5b414dff6aa7cc854e01fc60ee4/mapchete/formats/default/geojson.py#L145-L165 | def is_valid_with_config(self, config):
"""
Check if output format is valid with other process parameters.
Parameters
----------
config : dictionary
output configuration parameters
Returns
-------
is_valid : bool
"""
validate_... | [
"def",
"is_valid_with_config",
"(",
"self",
",",
"config",
")",
":",
"validate_values",
"(",
"config",
",",
"[",
"(",
"\"schema\"",
",",
"dict",
")",
",",
"(",
"\"path\"",
",",
"str",
")",
"]",
")",
"validate_values",
"(",
"config",
"[",
"\"schema\"",
"]... | Check if output format is valid with other process parameters.
Parameters
----------
config : dictionary
output configuration parameters
Returns
-------
is_valid : bool | [
"Check",
"if",
"output",
"format",
"is",
"valid",
"with",
"other",
"process",
"parameters",
"."
] | python | valid | 32.047619 |
limodou/uliweb | uliweb/core/SimpleFrame.py | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/core/SimpleFrame.py#L222-L261 | def CORS(func=None):
"""
CORS support
"""
def w(r=None):
from uliweb import request, response
if request.method == 'OPTIONS':
response = Response(status=204)
response.headers['Access-Control-Allow-Credentials'] = 'true'
response.headers['Access-Contr... | [
"def",
"CORS",
"(",
"func",
"=",
"None",
")",
":",
"def",
"w",
"(",
"r",
"=",
"None",
")",
":",
"from",
"uliweb",
"import",
"request",
",",
"response",
"if",
"request",
".",
"method",
"==",
"'OPTIONS'",
":",
"response",
"=",
"Response",
"(",
"status"... | CORS support | [
"CORS",
"support"
] | python | train | 43.125 |
i3visio/osrframework | osrframework/thirdparties/pipl_com/lib/fields.py | https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/thirdparties/pipl_com/lib/fields.py#L383-L391 | def is_valid_email(self):
"""A bool value that indicates whether the address is a valid
email address.
Note that the check is done be matching to the regular expression
at Email.re_email which is very basic and far from covering end-cases...
"""
... | [
"def",
"is_valid_email",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"self",
".",
"address",
"and",
"Email",
".",
"re_email",
".",
"match",
"(",
"self",
".",
"address",
")",
")"
] | A bool value that indicates whether the address is a valid
email address.
Note that the check is done be matching to the regular expression
at Email.re_email which is very basic and far from covering end-cases... | [
"A",
"bool",
"value",
"that",
"indicates",
"whether",
"the",
"address",
"is",
"a",
"valid",
"email",
"address",
".",
"Note",
"that",
"the",
"check",
"is",
"done",
"be",
"matching",
"to",
"the",
"regular",
"expression",
"at",
"Email",
".",
"re_email",
"whic... | python | train | 42 |
vtkiorg/vtki | vtki/examples/downloads.py | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/examples/downloads.py#L324-L358 | def download_kitchen(split=False):
"""Download structured grid of kitchen with velocity field. Use the
``split`` argument to extract all of the furniture in the kitchen.
"""
mesh = _download_and_read('kitchen.vtk')
if not split:
return mesh
extents = {
'door' : (27, 27, 14, 18, ... | [
"def",
"download_kitchen",
"(",
"split",
"=",
"False",
")",
":",
"mesh",
"=",
"_download_and_read",
"(",
"'kitchen.vtk'",
")",
"if",
"not",
"split",
":",
"return",
"mesh",
"extents",
"=",
"{",
"'door'",
":",
"(",
"27",
",",
"27",
",",
"14",
",",
"18",
... | Download structured grid of kitchen with velocity field. Use the
``split`` argument to extract all of the furniture in the kitchen. | [
"Download",
"structured",
"grid",
"of",
"kitchen",
"with",
"velocity",
"field",
".",
"Use",
"the",
"split",
"argument",
"to",
"extract",
"all",
"of",
"the",
"furniture",
"in",
"the",
"kitchen",
"."
] | python | train | 37.171429 |
numenta/nupic | src/nupic/swarming/hypersearch/support.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/hypersearch/support.py#L117-L136 | def makeDirectoryFromAbsolutePath(absDirPath):
""" Makes directory for the given directory path with default permissions.
If the directory already exists, it is treated as success.
absDirPath: absolute path of the directory to create.
Returns: absDirPath arg
Exceptions: OSError if directory ... | [
"def",
"makeDirectoryFromAbsolutePath",
"(",
"absDirPath",
")",
":",
"assert",
"os",
".",
"path",
".",
"isabs",
"(",
"absDirPath",
")",
"try",
":",
"os",
".",
"makedirs",
"(",
"absDirPath",
")",
"except",
"OSError",
",",
"e",
":",
"if",
"e",
".",
"errno"... | Makes directory for the given directory path with default permissions.
If the directory already exists, it is treated as success.
absDirPath: absolute path of the directory to create.
Returns: absDirPath arg
Exceptions: OSError if directory creation fails | [
"Makes",
"directory",
"for",
"the",
"given",
"directory",
"path",
"with",
"default",
"permissions",
".",
"If",
"the",
"directory",
"already",
"exists",
"it",
"is",
"treated",
"as",
"success",
"."
] | python | valid | 24.1 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/app/canvas.py | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/canvas.py#L302-L330 | def connect(self, fun):
""" Connect a function to an event
The name of the function
should be on_X, with X the name of the event (e.g. 'on_draw').
This method is typically used as a decorator on a function
definition for an event handler.
Parameters
----------
... | [
"def",
"connect",
"(",
"self",
",",
"fun",
")",
":",
"# Get and check name",
"name",
"=",
"fun",
".",
"__name__",
"if",
"not",
"name",
".",
"startswith",
"(",
"'on_'",
")",
":",
"raise",
"ValueError",
"(",
"'When connecting a function based on its name, '",
"'th... | Connect a function to an event
The name of the function
should be on_X, with X the name of the event (e.g. 'on_draw').
This method is typically used as a decorator on a function
definition for an event handler.
Parameters
----------
fun : callable
T... | [
"Connect",
"a",
"function",
"to",
"an",
"event"
] | python | train | 30.689655 |
openai/baselines | baselines/common/plot_util.py | https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/common/plot_util.py#L39-L109 | def one_sided_ema(xolds, yolds, low=None, high=None, n=512, decay_steps=1., low_counts_threshold=1e-8):
'''
perform one-sided (causal) EMA (exponential moving average)
smoothing and resampling to an even grid with n points.
Does not do extrapolation, so we assume
xolds[0] <= low && high <= xolds[-1]... | [
"def",
"one_sided_ema",
"(",
"xolds",
",",
"yolds",
",",
"low",
"=",
"None",
",",
"high",
"=",
"None",
",",
"n",
"=",
"512",
",",
"decay_steps",
"=",
"1.",
",",
"low_counts_threshold",
"=",
"1e-8",
")",
":",
"low",
"=",
"xolds",
"[",
"0",
"]",
"if"... | perform one-sided (causal) EMA (exponential moving average)
smoothing and resampling to an even grid with n points.
Does not do extrapolation, so we assume
xolds[0] <= low && high <= xolds[-1]
Arguments:
xolds: array or list - x values of data. Needs to be sorted in ascending order
yolds: arr... | [
"perform",
"one",
"-",
"sided",
"(",
"causal",
")",
"EMA",
"(",
"exponential",
"moving",
"average",
")",
"smoothing",
"and",
"resampling",
"to",
"an",
"even",
"grid",
"with",
"n",
"points",
".",
"Does",
"not",
"do",
"extrapolation",
"so",
"we",
"assume",
... | python | valid | 35.971831 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.