repo stringlengths 7 54 | path stringlengths 4 192 | url stringlengths 87 284 | code stringlengths 78 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|
rgs1/zk_shell | zk_shell/xclient.py | https://github.com/rgs1/zk_shell/blob/bbf34fdfcf1f81100e2a5816fad8af6afc782a54/zk_shell/xclient.py#L309-L348 | def diff(self, path_a, path_b):
""" Performs a deep comparison of path_a/ and path_b/
For each child, it yields (rv, child) where rv:
-1 if doesn't exist in path_b (destination)
0 if they are different
1 if it doesn't exist in path_a (source)
"""
... | [
"def",
"diff",
"(",
"self",
",",
"path_a",
",",
"path_b",
")",
":",
"path_a",
"=",
"path_a",
".",
"rstrip",
"(",
"\"/\"",
")",
"path_b",
"=",
"path_b",
".",
"rstrip",
"(",
"\"/\"",
")",
"if",
"not",
"self",
".",
"exists",
"(",
"path_a",
")",
"or",
... | Performs a deep comparison of path_a/ and path_b/
For each child, it yields (rv, child) where rv:
-1 if doesn't exist in path_b (destination)
0 if they are different
1 if it doesn't exist in path_a (source) | [
"Performs",
"a",
"deep",
"comparison",
"of",
"path_a",
"/",
"and",
"path_b",
"/"
] | python | train |
apache/airflow | airflow/contrib/kubernetes/worker_configuration.py | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/kubernetes/worker_configuration.py#L45-L131 | def _get_init_containers(self):
"""When using git to retrieve the DAGs, use the GitSync Init Container"""
# If we're using volume claims to mount the dags, no init container is needed
if self.kube_config.dags_volume_claim or \
self.kube_config.dags_volume_host or self.kube_config.dags... | [
"def",
"_get_init_containers",
"(",
"self",
")",
":",
"# If we're using volume claims to mount the dags, no init container is needed",
"if",
"self",
".",
"kube_config",
".",
"dags_volume_claim",
"or",
"self",
".",
"kube_config",
".",
"dags_volume_host",
"or",
"self",
".",
... | When using git to retrieve the DAGs, use the GitSync Init Container | [
"When",
"using",
"git",
"to",
"retrieve",
"the",
"DAGs",
"use",
"the",
"GitSync",
"Init",
"Container"
] | python | test |
lk-geimfari/mimesis | mimesis/providers/internet.py | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/internet.py#L226-L234 | def top_level_domain(self, tld_type: Optional[TLDType] = None) -> str:
"""Return random top level domain.
:param tld_type: Enum object DomainType
:return: Top level domain.
:raises NonEnumerableError: if tld_type not in DomainType.
"""
key = self._validate_enum(item=tld_... | [
"def",
"top_level_domain",
"(",
"self",
",",
"tld_type",
":",
"Optional",
"[",
"TLDType",
"]",
"=",
"None",
")",
"->",
"str",
":",
"key",
"=",
"self",
".",
"_validate_enum",
"(",
"item",
"=",
"tld_type",
",",
"enum",
"=",
"TLDType",
")",
"return",
"sel... | Return random top level domain.
:param tld_type: Enum object DomainType
:return: Top level domain.
:raises NonEnumerableError: if tld_type not in DomainType. | [
"Return",
"random",
"top",
"level",
"domain",
"."
] | python | train |
google/grumpy | third_party/pypy/datetime.py | https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pypy/datetime.py#L1316-L1327 | def tzname(self):
"""Return the timezone name.
Note that the name is 100% informational -- there's no requirement that
it mean anything in particular. For example, "GMT", "UTC", "-500",
"-5:00", "EDT", "US/Eastern", "America/New York" are all valid replies.
"""
if self._... | [
"def",
"tzname",
"(",
"self",
")",
":",
"if",
"self",
".",
"_tzinfo",
"is",
"None",
":",
"return",
"None",
"name",
"=",
"self",
".",
"_tzinfo",
".",
"tzname",
"(",
"None",
")",
"_check_tzname",
"(",
"name",
")",
"return",
"name"
] | Return the timezone name.
Note that the name is 100% informational -- there's no requirement that
it mean anything in particular. For example, "GMT", "UTC", "-500",
"-5:00", "EDT", "US/Eastern", "America/New York" are all valid replies. | [
"Return",
"the",
"timezone",
"name",
"."
] | python | valid |
ipfs/py-ipfs-api | ipfsapi/multipart.py | https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/multipart.py#L658-L692 | def stream_text(text, chunk_size=default_chunk_size):
"""Gets a buffered generator for streaming text.
Returns a buffered generator which encodes a string as
:mimetype:`multipart/form-data` with the corresponding headers.
Parameters
----------
text : str
The data bytes to stream
ch... | [
"def",
"stream_text",
"(",
"text",
",",
"chunk_size",
"=",
"default_chunk_size",
")",
":",
"if",
"isgenerator",
"(",
"text",
")",
":",
"def",
"binary_stream",
"(",
")",
":",
"for",
"item",
"in",
"text",
":",
"if",
"six",
".",
"PY2",
"and",
"isinstance",
... | Gets a buffered generator for streaming text.
Returns a buffered generator which encodes a string as
:mimetype:`multipart/form-data` with the corresponding headers.
Parameters
----------
text : str
The data bytes to stream
chunk_size : int
The maximum size of each stream chunk
... | [
"Gets",
"a",
"buffered",
"generator",
"for",
"streaming",
"text",
"."
] | python | train |
jessamynsmith/paragres | paragres/command.py | https://github.com/jessamynsmith/paragres/blob/4e068cbfcafbe8f1b010741d38fb65d40de2c6aa/paragres/command.py#L115-L125 | def download_file(self, url, filename):
""" Download file from url to filename. """
self.print_message("Downloading to file '%s' from URL '%s'" % (filename, url))
try:
db_file = urllib2.urlopen(url)
with open(filename, 'wb') as output:
output.write(db_file... | [
"def",
"download_file",
"(",
"self",
",",
"url",
",",
"filename",
")",
":",
"self",
".",
"print_message",
"(",
"\"Downloading to file '%s' from URL '%s'\"",
"%",
"(",
"filename",
",",
"url",
")",
")",
"try",
":",
"db_file",
"=",
"urllib2",
".",
"urlopen",
"(... | Download file from url to filename. | [
"Download",
"file",
"from",
"url",
"to",
"filename",
"."
] | python | train |
globocom/GloboNetworkAPI-client-python | networkapiclient/TipoRoteiro.py | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/TipoRoteiro.py#L58-L82 | def inserir(self, type, description):
"""Inserts a new Script Type and returns its identifier.
:param type: Script Type type. String with a minimum 3 and maximum of 40 characters
:param description: Script Type description. String with a minimum 3 and maximum of 100 characters
:return:... | [
"def",
"inserir",
"(",
"self",
",",
"type",
",",
"description",
")",
":",
"script_type_map",
"=",
"dict",
"(",
")",
"script_type_map",
"[",
"'type'",
"]",
"=",
"type",
"script_type_map",
"[",
"'description'",
"]",
"=",
"description",
"code",
",",
"xml",
"=... | Inserts a new Script Type and returns its identifier.
:param type: Script Type type. String with a minimum 3 and maximum of 40 characters
:param description: Script Type description. String with a minimum 3 and maximum of 100 characters
:return: Dictionary with the following structure:
... | [
"Inserts",
"a",
"new",
"Script",
"Type",
"and",
"returns",
"its",
"identifier",
"."
] | python | train |
getnikola/coil | coil/__main__.py | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/__main__.py#L74-L78 | def write_users(arguments):
"""Write users to the DB."""
import coil.init
u = coil.utils.ask("Redis URL", "redis://localhost:6379/0")
return coil.init.write_users(u) | [
"def",
"write_users",
"(",
"arguments",
")",
":",
"import",
"coil",
".",
"init",
"u",
"=",
"coil",
".",
"utils",
".",
"ask",
"(",
"\"Redis URL\"",
",",
"\"redis://localhost:6379/0\"",
")",
"return",
"coil",
".",
"init",
".",
"write_users",
"(",
"u",
")"
] | Write users to the DB. | [
"Write",
"users",
"to",
"the",
"DB",
"."
] | python | train |
HydraChain/hydrachain | hydrachain/consensus/base.py | https://github.com/HydraChain/hydrachain/blob/6c0919b0575dc8aa481f3a8c703e1a7f0575ecc3/hydrachain/consensus/base.py#L133-L142 | def hash(self):
"signatures are non deterministic"
if self.sender is None:
raise MissingSignatureError()
class HashSerializable(rlp.Serializable):
fields = [(field, sedes) for field, sedes in self.fields
if field not in ('v', 'r', 's')] + [('_sender... | [
"def",
"hash",
"(",
"self",
")",
":",
"if",
"self",
".",
"sender",
"is",
"None",
":",
"raise",
"MissingSignatureError",
"(",
")",
"class",
"HashSerializable",
"(",
"rlp",
".",
"Serializable",
")",
":",
"fields",
"=",
"[",
"(",
"field",
",",
"sedes",
")... | signatures are non deterministic | [
"signatures",
"are",
"non",
"deterministic"
] | python | test |
log2timeline/dftimewolf | dftimewolf/lib/containers/interface.py | https://github.com/log2timeline/dftimewolf/blob/45f898476a288d73c4256ae8e3836a2a4848c0d7/dftimewolf/lib/containers/interface.py#L99-L119 | def get_attribute_values_string(self):
"""Retrieves a comparable string of the attribute values.
Returns:
str: comparable string of the attribute values.
"""
attributes = []
for attribute_name, attribute_value in sorted(self.__dict__.items()):
# Not using startswith to improve performanc... | [
"def",
"get_attribute_values_string",
"(",
"self",
")",
":",
"attributes",
"=",
"[",
"]",
"for",
"attribute_name",
",",
"attribute_value",
"in",
"sorted",
"(",
"self",
".",
"__dict__",
".",
"items",
"(",
")",
")",
":",
"# Not using startswith to improve performanc... | Retrieves a comparable string of the attribute values.
Returns:
str: comparable string of the attribute values. | [
"Retrieves",
"a",
"comparable",
"string",
"of",
"the",
"attribute",
"values",
".",
"Returns",
":",
"str",
":",
"comparable",
"string",
"of",
"the",
"attribute",
"values",
"."
] | python | train |
ibis-project/ibis | ibis/expr/datatypes.py | https://github.com/ibis-project/ibis/blob/1e39a5fd9ef088b45c155e8a5f541767ee8ef2e7/ibis/expr/datatypes.py#L1319-L1326 | def infer_map(value: Mapping[GenericAny, GenericAny]) -> Map:
"""Infer the :class:`~ibis.expr.datatypes.Map` type of `value`."""
if not value:
return Map(null, null)
return Map(
highest_precedence(map(infer, value.keys())),
highest_precedence(map(infer, value.values())),
) | [
"def",
"infer_map",
"(",
"value",
":",
"Mapping",
"[",
"GenericAny",
",",
"GenericAny",
"]",
")",
"->",
"Map",
":",
"if",
"not",
"value",
":",
"return",
"Map",
"(",
"null",
",",
"null",
")",
"return",
"Map",
"(",
"highest_precedence",
"(",
"map",
"(",
... | Infer the :class:`~ibis.expr.datatypes.Map` type of `value`. | [
"Infer",
"the",
":",
"class",
":",
"~ibis",
".",
"expr",
".",
"datatypes",
".",
"Map",
"type",
"of",
"value",
"."
] | python | train |
olsoneric/pedemath | pedemath/vec3.py | https://github.com/olsoneric/pedemath/blob/4bffcfe7089e421d603eb0a9708b84789c2d16be/pedemath/vec3.py#L55-L58 | def translate_v3(vec, amount):
"""Return a new Vec3 that is translated version of vec."""
return Vec3(vec.x+amount, vec.y+amount, vec.z+amount) | [
"def",
"translate_v3",
"(",
"vec",
",",
"amount",
")",
":",
"return",
"Vec3",
"(",
"vec",
".",
"x",
"+",
"amount",
",",
"vec",
".",
"y",
"+",
"amount",
",",
"vec",
".",
"z",
"+",
"amount",
")"
] | Return a new Vec3 that is translated version of vec. | [
"Return",
"a",
"new",
"Vec3",
"that",
"is",
"translated",
"version",
"of",
"vec",
"."
] | python | train |
bitesofcode/projex | projex/xmlutil.py | https://github.com/bitesofcode/projex/blob/d31743ec456a41428709968ab11a2cf6c6c76247/projex/xmlutil.py#L374-L386 | def load(self, elem):
"""
Converts the inputted list tag to Python.
:param elem | <xml.etree.ElementTree>
:return <list>
"""
self.testTag(elem, 'list')
out = []
for xitem in elem:
out.append(XmlDataIO.fromXml(xitem))
... | [
"def",
"load",
"(",
"self",
",",
"elem",
")",
":",
"self",
".",
"testTag",
"(",
"elem",
",",
"'list'",
")",
"out",
"=",
"[",
"]",
"for",
"xitem",
"in",
"elem",
":",
"out",
".",
"append",
"(",
"XmlDataIO",
".",
"fromXml",
"(",
"xitem",
")",
")",
... | Converts the inputted list tag to Python.
:param elem | <xml.etree.ElementTree>
:return <list> | [
"Converts",
"the",
"inputted",
"list",
"tag",
"to",
"Python",
".",
":",
"param",
"elem",
"|",
"<xml",
".",
"etree",
".",
"ElementTree",
">",
":",
"return",
"<list",
">"
] | python | train |
DataDog/integrations-core | spark/datadog_checks/spark/spark.py | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/spark/datadog_checks/spark/spark.py#L403-L422 | def _get_standalone_app_url(self, app_id, spark_master_address, requests_config, tags):
"""
Return the application URL from the app info page on the Spark master.
Due to a bug, we need to parse the HTML manually because we cannot
fetch JSON data from HTTP interface.
"""
a... | [
"def",
"_get_standalone_app_url",
"(",
"self",
",",
"app_id",
",",
"spark_master_address",
",",
"requests_config",
",",
"tags",
")",
":",
"app_page",
"=",
"self",
".",
"_rest_request",
"(",
"spark_master_address",
",",
"SPARK_MASTER_APP_PATH",
",",
"SPARK_STANDALONE_S... | Return the application URL from the app info page on the Spark master.
Due to a bug, we need to parse the HTML manually because we cannot
fetch JSON data from HTTP interface. | [
"Return",
"the",
"application",
"URL",
"from",
"the",
"app",
"info",
"page",
"on",
"the",
"Spark",
"master",
".",
"Due",
"to",
"a",
"bug",
"we",
"need",
"to",
"parse",
"the",
"HTML",
"manually",
"because",
"we",
"cannot",
"fetch",
"JSON",
"data",
"from",... | python | train |
yatiml/yatiml | yatiml/introspection.py | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/introspection.py#L5-L28 | def class_subobjects(
class_: Type) -> Generator[Tuple[str, Type, bool], None, None]:
"""Find the aggregated subobjects of an object.
These are the public attributes.
Args:
class_: The class whose subobjects to return.
Yields:
Tuples (name, type, required) describing subobject... | [
"def",
"class_subobjects",
"(",
"class_",
":",
"Type",
")",
"->",
"Generator",
"[",
"Tuple",
"[",
"str",
",",
"Type",
",",
"bool",
"]",
",",
"None",
",",
"None",
"]",
":",
"argspec",
"=",
"inspect",
".",
"getfullargspec",
"(",
"class_",
".",
"__init__"... | Find the aggregated subobjects of an object.
These are the public attributes.
Args:
class_: The class whose subobjects to return.
Yields:
Tuples (name, type, required) describing subobjects. | [
"Find",
"the",
"aggregated",
"subobjects",
"of",
"an",
"object",
"."
] | python | train |
Microsoft/botbuilder-python | libraries/botbuilder-ai/botbuilder/ai/luis/luis_recognizer.py | https://github.com/Microsoft/botbuilder-python/blob/274663dd91c811bae6ac4488915ba5880771b0a7/libraries/botbuilder-ai/botbuilder/ai/luis/luis_recognizer.py#L122-L150 | def top_intent(
results: RecognizerResult, default_intent: str = "None", min_score: float = 0.0
) -> str:
"""Returns the name of the top scoring intent from a set of LUIS results.
:param results: Result set to be searched.
:type results: RecognizerResult
:param defau... | [
"def",
"top_intent",
"(",
"results",
":",
"RecognizerResult",
",",
"default_intent",
":",
"str",
"=",
"\"None\"",
",",
"min_score",
":",
"float",
"=",
"0.0",
")",
"->",
"str",
":",
"if",
"results",
"is",
"None",
":",
"raise",
"TypeError",
"(",
"\"LuisRecog... | Returns the name of the top scoring intent from a set of LUIS results.
:param results: Result set to be searched.
:type results: RecognizerResult
:param default_intent: Intent name to return should a top intent be found, defaults to "None"
:param default_intent: str, optional
... | [
"Returns",
"the",
"name",
"of",
"the",
"top",
"scoring",
"intent",
"from",
"a",
"set",
"of",
"LUIS",
"results",
".",
":",
"param",
"results",
":",
"Result",
"set",
"to",
"be",
"searched",
".",
":",
"type",
"results",
":",
"RecognizerResult",
":",
"param"... | python | test |
carlosp420/dataset-creator | dataset_creator/dataset.py | https://github.com/carlosp420/dataset-creator/blob/ea27340b145cb566a36c1836ff42263f1b2003a0/dataset_creator/dataset.py#L174-L183 | def _extract_total_number_of_chars(self):
"""
sets `self.number_chars` to the number of characters as string.
"""
self._get_gene_codes_and_seq_lengths()
sum = 0
for seq_length in self._gene_codes_and_lengths.values():
sum += sorted(seq_length, reverse=True)[0... | [
"def",
"_extract_total_number_of_chars",
"(",
"self",
")",
":",
"self",
".",
"_get_gene_codes_and_seq_lengths",
"(",
")",
"sum",
"=",
"0",
"for",
"seq_length",
"in",
"self",
".",
"_gene_codes_and_lengths",
".",
"values",
"(",
")",
":",
"sum",
"+=",
"sorted",
"... | sets `self.number_chars` to the number of characters as string. | [
"sets",
"self",
".",
"number_chars",
"to",
"the",
"number",
"of",
"characters",
"as",
"string",
"."
] | python | train |
SKA-ScienceDataProcessor/integration-prototype | sip/execution_control/configuration_db/sip_config_db/_config_db_redis.py | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/execution_control/configuration_db/sip_config_db/_config_db_redis.py#L124-L149 | def _load_values(self, db_key: str) -> dict:
"""Load values from the db at the specified key, db_key.
FIXME(BMo): Could also be extended to load scalar types (instead of
just list and hash)
"""
if self._db.type(db_key) == 'list':
db_values = self._db.lra... | [
"def",
"_load_values",
"(",
"self",
",",
"db_key",
":",
"str",
")",
"->",
"dict",
":",
"if",
"self",
".",
"_db",
".",
"type",
"(",
"db_key",
")",
"==",
"'list'",
":",
"db_values",
"=",
"self",
".",
"_db",
".",
"lrange",
"(",
"db_key",
",",
"0",
"... | Load values from the db at the specified key, db_key.
FIXME(BMo): Could also be extended to load scalar types (instead of
just list and hash) | [
"Load",
"values",
"from",
"the",
"db",
"at",
"the",
"specified",
"key",
"db_key",
"."
] | python | train |
cga-harvard/Hypermap-Registry | hypermap/aggregator/tasks.py | https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/tasks.py#L195-L205 | def remove_service_checks(self, service_id):
"""
Remove all checks from a service.
"""
from hypermap.aggregator.models import Service
service = Service.objects.get(id=service_id)
service.check_set.all().delete()
layer_to_process = service.layer_set.all()
for layer in layer_to_process:
... | [
"def",
"remove_service_checks",
"(",
"self",
",",
"service_id",
")",
":",
"from",
"hypermap",
".",
"aggregator",
".",
"models",
"import",
"Service",
"service",
"=",
"Service",
".",
"objects",
".",
"get",
"(",
"id",
"=",
"service_id",
")",
"service",
".",
"... | Remove all checks from a service. | [
"Remove",
"all",
"checks",
"from",
"a",
"service",
"."
] | python | train |
bspaans/python-mingus | mingus/midi/midi_track.py | https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/midi/midi_track.py#L235-L240 | def time_signature_event(self, meter=(4, 4)):
"""Return a time signature event for meter."""
numer = a2b_hex('%02x' % meter[0])
denom = a2b_hex('%02x' % int(log(meter[1], 2)))
return self.delta_time + META_EVENT + TIME_SIGNATURE + '\x04' + numer\
+ denom + '\x18\x08' | [
"def",
"time_signature_event",
"(",
"self",
",",
"meter",
"=",
"(",
"4",
",",
"4",
")",
")",
":",
"numer",
"=",
"a2b_hex",
"(",
"'%02x'",
"%",
"meter",
"[",
"0",
"]",
")",
"denom",
"=",
"a2b_hex",
"(",
"'%02x'",
"%",
"int",
"(",
"log",
"(",
"mete... | Return a time signature event for meter. | [
"Return",
"a",
"time",
"signature",
"event",
"for",
"meter",
"."
] | python | train |
pycampers/zproc | zproc/server/tools.py | https://github.com/pycampers/zproc/blob/352a3c7166e2ccc3597c28385a8354b5a22afdc2/zproc/server/tools.py#L52-L107 | def ping(
server_address: str, *, timeout: float = None, payload: Union[bytes] = None
) -> int:
"""
Ping the zproc server.
This can be used to easily detect if a server is alive and running, with the aid of a suitable ``timeout``.
:param server_address:
.. include:: /api/snippets/serve... | [
"def",
"ping",
"(",
"server_address",
":",
"str",
",",
"*",
",",
"timeout",
":",
"float",
"=",
"None",
",",
"payload",
":",
"Union",
"[",
"bytes",
"]",
"=",
"None",
")",
"->",
"int",
":",
"if",
"payload",
"is",
"None",
":",
"payload",
"=",
"os",
... | Ping the zproc server.
This can be used to easily detect if a server is alive and running, with the aid of a suitable ``timeout``.
:param server_address:
.. include:: /api/snippets/server_address.rst
:param timeout:
The timeout in seconds.
If this is set to ``None``, then it will ... | [
"Ping",
"the",
"zproc",
"server",
"."
] | python | train |
elastic/elasticsearch-py | elasticsearch/client/xpack/security.py | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/security.py#L325-L340 | def put_privileges(self, body, params=None):
"""
`<TODO>`_
:arg body: The privilege(s) to add
:arg refresh: If `true` (the default) then refresh the affected shards
to make this operation visible to search, if `wait_for` then wait
for a refresh to make this opera... | [
"def",
"put_privileges",
"(",
"self",
",",
"body",
",",
"params",
"=",
"None",
")",
":",
"if",
"body",
"in",
"SKIP_IN_PATH",
":",
"raise",
"ValueError",
"(",
"\"Empty value passed for a required argument 'body'.\"",
")",
"return",
"self",
".",
"transport",
".",
... | `<TODO>`_
:arg body: The privilege(s) to add
:arg refresh: If `true` (the default) then refresh the affected shards
to make this operation visible to search, if `wait_for` then wait
for a refresh to make this operation visible to search, if `false`
then do nothing wi... | [
"<TODO",
">",
"_"
] | python | train |
SiLab-Bonn/basil | basil/HL/FEI4AdapterCard.py | https://github.com/SiLab-Bonn/basil/blob/99052482d9334dd1f5598eb2d2fb4d5399a32291/basil/HL/FEI4AdapterCard.py#L165-L180 | def get_voltage(self, channel, unit='V'):
'''Reading voltage
'''
kwargs = self._ch_map[channel]['ADCV']
voltage_raw = self._get_adc_value(**kwargs)
voltage = (voltage_raw - self._ch_cal[channel]['ADCV']['offset']) / self._ch_cal[channel]['ADCV']['gain']
if unit == 'raw'... | [
"def",
"get_voltage",
"(",
"self",
",",
"channel",
",",
"unit",
"=",
"'V'",
")",
":",
"kwargs",
"=",
"self",
".",
"_ch_map",
"[",
"channel",
"]",
"[",
"'ADCV'",
"]",
"voltage_raw",
"=",
"self",
".",
"_get_adc_value",
"(",
"*",
"*",
"kwargs",
")",
"vo... | Reading voltage | [
"Reading",
"voltage"
] | python | train |
sentinel-hub/eo-learn | core/eolearn/core/eoexecution.py | https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/core/eolearn/core/eoexecution.py#L74-L100 | def run(self, workers=1):
""" Runs the executor with n workers.
:param workers: Number of parallel processes used in the execution. Default is a single process. If set to
`None` the number of workers will be the number of processors of the system.
:type workers: int or None
... | [
"def",
"run",
"(",
"self",
",",
"workers",
"=",
"1",
")",
":",
"self",
".",
"report_folder",
"=",
"self",
".",
"_get_report_folder",
"(",
")",
"if",
"self",
".",
"save_logs",
"and",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"self",
".",
"report_fo... | Runs the executor with n workers.
:param workers: Number of parallel processes used in the execution. Default is a single process. If set to
`None` the number of workers will be the number of processors of the system.
:type workers: int or None | [
"Runs",
"the",
"executor",
"with",
"n",
"workers",
"."
] | python | train |
jrxFive/python-nomad | nomad/api/deployment.py | https://github.com/jrxFive/python-nomad/blob/37df37e4de21e6f8ac41c6154e7f1f44f1800020/nomad/api/deployment.py#L90-L106 | def pause_deployment(self, id, pause):
""" This endpoint is used to pause or unpause a deployment.
This is done to pause a rolling upgrade or resume it.
https://www.nomadproject.io/docs/http/deployments.html
arguments:
- id
- pause, Specifies whet... | [
"def",
"pause_deployment",
"(",
"self",
",",
"id",
",",
"pause",
")",
":",
"pause_json",
"=",
"{",
"\"Pause\"",
":",
"pause",
",",
"\"DeploymentID\"",
":",
"id",
"}",
"return",
"self",
".",
"request",
"(",
"\"pause\"",
",",
"id",
",",
"json",
"=",
"pau... | This endpoint is used to pause or unpause a deployment.
This is done to pause a rolling upgrade or resume it.
https://www.nomadproject.io/docs/http/deployments.html
arguments:
- id
- pause, Specifies whether to pause or resume the deployment.
... | [
"This",
"endpoint",
"is",
"used",
"to",
"pause",
"or",
"unpause",
"a",
"deployment",
".",
"This",
"is",
"done",
"to",
"pause",
"a",
"rolling",
"upgrade",
"or",
"resume",
"it",
"."
] | python | test |
insilichem/ommprotocol | ommprotocol/io.py | https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/io.py#L916-L951 | def prepare_handler(cfg):
"""
Load all files into single object.
"""
positions, velocities, box = None, None, None
_path = cfg.get('_path', './')
forcefield = cfg.pop('forcefield', None)
topology_args = sanitize_args_for_file(cfg.pop('topology'), _path)
if 'checkpoint' in cfg:
r... | [
"def",
"prepare_handler",
"(",
"cfg",
")",
":",
"positions",
",",
"velocities",
",",
"box",
"=",
"None",
",",
"None",
",",
"None",
"_path",
"=",
"cfg",
".",
"get",
"(",
"'_path'",
",",
"'./'",
")",
"forcefield",
"=",
"cfg",
".",
"pop",
"(",
"'forcefi... | Load all files into single object. | [
"Load",
"all",
"files",
"into",
"single",
"object",
"."
] | python | train |
pkgw/pwkit | pwkit/io.py | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/io.py#L402-L437 | def ensure_dir (self, mode=0o777, parents=False):
"""Ensure that this path exists as a directory.
This function calls :meth:`mkdir` on this path, but does not raise an
exception if it already exists. It does raise an exception if this
path exists but is not a directory. If the directory... | [
"def",
"ensure_dir",
"(",
"self",
",",
"mode",
"=",
"0o777",
",",
"parents",
"=",
"False",
")",
":",
"if",
"parents",
":",
"p",
"=",
"self",
".",
"parent",
"if",
"p",
"==",
"self",
":",
"return",
"False",
"# can never create root; avoids loop when parents=Tr... | Ensure that this path exists as a directory.
This function calls :meth:`mkdir` on this path, but does not raise an
exception if it already exists. It does raise an exception if this
path exists but is not a directory. If the directory is created,
*mode* is used to set the permissions of... | [
"Ensure",
"that",
"this",
"path",
"exists",
"as",
"a",
"directory",
"."
] | python | train |
clalancette/pycdlib | pycdlib/pycdlib.py | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/pycdlib.py#L4246-L4265 | def write_fp(self, outfp, blocksize=32768, progress_cb=None, progress_opaque=None):
# type: (BinaryIO, int, Optional[Callable[[int, int, Any], None]], Optional[Any]) -> None
'''
Write a properly formatted ISO out to the file object passed in. This
also goes by the name of 'mastering'.
... | [
"def",
"write_fp",
"(",
"self",
",",
"outfp",
",",
"blocksize",
"=",
"32768",
",",
"progress_cb",
"=",
"None",
",",
"progress_opaque",
"=",
"None",
")",
":",
"# type: (BinaryIO, int, Optional[Callable[[int, int, Any], None]], Optional[Any]) -> None",
"if",
"not",
"self"... | Write a properly formatted ISO out to the file object passed in. This
also goes by the name of 'mastering'.
Parameters:
outfp - The file object to write the data to.
blocksize - The blocksize to use when copying data; set to 32768 by default.
progress_cb - If not None, a fun... | [
"Write",
"a",
"properly",
"formatted",
"ISO",
"out",
"to",
"the",
"file",
"object",
"passed",
"in",
".",
"This",
"also",
"goes",
"by",
"the",
"name",
"of",
"mastering",
"."
] | python | train |
sci-bots/pygtkhelpers | pygtkhelpers/ui/dialogs.py | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/ui/dialogs.py#L363-L427 | def animation_dialog(images, delay_s=1., loop=True, **kwargs):
'''
.. versionadded:: v0.19
Parameters
----------
images : list
Filepaths to images or :class:`gtk.Pixbuf` instances.
delay_s : float, optional
Number of seconds to display each frame.
Default: ``1.0``.
... | [
"def",
"animation_dialog",
"(",
"images",
",",
"delay_s",
"=",
"1.",
",",
"loop",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"_as_pixbuf",
"(",
"image",
")",
":",
"if",
"isinstance",
"(",
"image",
",",
"types",
".",
"StringTypes",
")",
":... | .. versionadded:: v0.19
Parameters
----------
images : list
Filepaths to images or :class:`gtk.Pixbuf` instances.
delay_s : float, optional
Number of seconds to display each frame.
Default: ``1.0``.
loop : bool, optional
If ``True``, restart animation after last ima... | [
"..",
"versionadded",
"::",
"v0",
".",
"19"
] | python | train |
saltstack/salt | salt/utils/json.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/json.py#L81-L99 | def loads(s, **kwargs):
'''
.. versionadded:: 2018.3.0
Wraps json.loads and prevents a traceback in the event that a bytestring is
passed to the function. (Python < 3.6 cannot load bytestrings)
You can pass an alternate json module (loaded via import_json() above)
using the _json_module argume... | [
"def",
"loads",
"(",
"s",
",",
"*",
"*",
"kwargs",
")",
":",
"json_module",
"=",
"kwargs",
".",
"pop",
"(",
"'_json_module'",
",",
"json",
")",
"try",
":",
"return",
"json_module",
".",
"loads",
"(",
"s",
",",
"*",
"*",
"kwargs",
")",
"except",
"Ty... | .. versionadded:: 2018.3.0
Wraps json.loads and prevents a traceback in the event that a bytestring is
passed to the function. (Python < 3.6 cannot load bytestrings)
You can pass an alternate json module (loaded via import_json() above)
using the _json_module argument) | [
"..",
"versionadded",
"::",
"2018",
".",
"3",
".",
"0"
] | python | train |
ethereum/pyethereum | ethereum/abi.py | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/abi.py#L49-L76 | def _canonical_type(name): # pylint: disable=too-many-return-statements
""" Replace aliases to the corresponding type to compute the ids. """
if name == 'int':
return 'int256'
if name == 'uint':
return 'uint256'
if name == 'fixed':
return 'fixed128x128'
if name == 'ufixe... | [
"def",
"_canonical_type",
"(",
"name",
")",
":",
"# pylint: disable=too-many-return-statements",
"if",
"name",
"==",
"'int'",
":",
"return",
"'int256'",
"if",
"name",
"==",
"'uint'",
":",
"return",
"'uint256'",
"if",
"name",
"==",
"'fixed'",
":",
"return",
"'fix... | Replace aliases to the corresponding type to compute the ids. | [
"Replace",
"aliases",
"to",
"the",
"corresponding",
"type",
"to",
"compute",
"the",
"ids",
"."
] | python | train |
StackStorm/pybind | pybind/nos/v6_0_2f/rmon/alarm_entry/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/rmon/alarm_entry/__init__.py#L368-L389 | def _set_alarm_owner(self, v, load=False):
"""
Setter method for alarm_owner, mapped from YANG variable /rmon/alarm_entry/alarm_owner (owner-string)
If this variable is read-only (config: false) in the
source YANG file, then _set_alarm_owner is considered as a private
method. Backends looking to pop... | [
"def",
"_set_alarm_owner",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
"ba... | Setter method for alarm_owner, mapped from YANG variable /rmon/alarm_entry/alarm_owner (owner-string)
If this variable is read-only (config: false) in the
source YANG file, then _set_alarm_owner is considered as a private
method. Backends looking to populate this variable should
do so via calling thisOb... | [
"Setter",
"method",
"for",
"alarm_owner",
"mapped",
"from",
"YANG",
"variable",
"/",
"rmon",
"/",
"alarm_entry",
"/",
"alarm_owner",
"(",
"owner",
"-",
"string",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"(",
"config",
":",
"false",
")",
... | python | train |
bslatkin/dpxdt | dpxdt/server/auth.py | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L239-L268 | def build_access_required(function_or_param_name):
"""Decorator ensures user has access to the build ID in the request.
May be used in two ways:
@build_access_required
def my_func(build):
...
@build_access_required('custom_build_id_param')
def my_func(build):
... | [
"def",
"build_access_required",
"(",
"function_or_param_name",
")",
":",
"def",
"get_wrapper",
"(",
"param_name",
",",
"f",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"wrapped",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
... | Decorator ensures user has access to the build ID in the request.
May be used in two ways:
@build_access_required
def my_func(build):
...
@build_access_required('custom_build_id_param')
def my_func(build):
...
Always calls the given function with the m... | [
"Decorator",
"ensures",
"user",
"has",
"access",
"to",
"the",
"build",
"ID",
"in",
"the",
"request",
"."
] | python | train |
angr/angr | angr/simos/linux.py | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/simos/linux.py#L326-L346 | def prepare_function_symbol(self, symbol_name, basic_addr=None):
"""
Prepare the address space with the data necessary to perform relocations pointing to the given symbol.
Returns a 2-tuple. The first item is the address of the function code, the second is the address of the
relocation ... | [
"def",
"prepare_function_symbol",
"(",
"self",
",",
"symbol_name",
",",
"basic_addr",
"=",
"None",
")",
":",
"if",
"self",
".",
"project",
".",
"loader",
".",
"main_object",
".",
"is_ppc64_abiv1",
":",
"if",
"basic_addr",
"is",
"not",
"None",
":",
"pointer",... | Prepare the address space with the data necessary to perform relocations pointing to the given symbol.
Returns a 2-tuple. The first item is the address of the function code, the second is the address of the
relocation target. | [
"Prepare",
"the",
"address",
"space",
"with",
"the",
"data",
"necessary",
"to",
"perform",
"relocations",
"pointing",
"to",
"the",
"given",
"symbol",
"."
] | python | train |
gem/oq-engine | openquake/hmtk/plotting/mapping.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/mapping.py#L399-L424 | def add_size_scaled_points(
self, longitude, latitude, data, shape='o',
logplot=False, alpha=1.0, colour='b', smin=2.0, sscale=2.0,
overlay=False):
"""
Plots a set of points with size scaled according to the data
:param bool logplot:
Choose to sca... | [
"def",
"add_size_scaled_points",
"(",
"self",
",",
"longitude",
",",
"latitude",
",",
"data",
",",
"shape",
"=",
"'o'",
",",
"logplot",
"=",
"False",
",",
"alpha",
"=",
"1.0",
",",
"colour",
"=",
"'b'",
",",
"smin",
"=",
"2.0",
",",
"sscale",
"=",
"2... | Plots a set of points with size scaled according to the data
:param bool logplot:
Choose to scale according to the logarithm (base 10) of the data
:param float smin:
Minimum scale size
:param float sscale:
Scaling factor | [
"Plots",
"a",
"set",
"of",
"points",
"with",
"size",
"scaled",
"according",
"to",
"the",
"data"
] | python | train |
nameko/nameko | nameko/messaging.py | https://github.com/nameko/nameko/blob/88d7e5211de4fcc1c34cd7f84d7c77f0619c5f5d/nameko/messaging.py#L390-L396 | def on_iteration(self):
""" Kombu callback for each `drain_events` loop iteration."""
self._cancel_consumers_if_requested()
if len(self._consumers) == 0:
_log.debug('requesting stop after iteration')
self.should_stop = True | [
"def",
"on_iteration",
"(",
"self",
")",
":",
"self",
".",
"_cancel_consumers_if_requested",
"(",
")",
"if",
"len",
"(",
"self",
".",
"_consumers",
")",
"==",
"0",
":",
"_log",
".",
"debug",
"(",
"'requesting stop after iteration'",
")",
"self",
".",
"should... | Kombu callback for each `drain_events` loop iteration. | [
"Kombu",
"callback",
"for",
"each",
"drain_events",
"loop",
"iteration",
"."
] | python | train |
bbangert/lettuce_webdriver | lettuce_webdriver/util.py | https://github.com/bbangert/lettuce_webdriver/blob/d11f8531c43bb7150c316e0dc4ccd083617becf7/lettuce_webdriver/util.py#L278-L298 | def wait_for(func):
"""
A decorator to invoke a function periodically until it returns a truthy
value.
"""
def wrapped(*args, **kwargs):
timeout = kwargs.pop('timeout', 15)
start = time()
result = None
while time() - start < timeout:
result = func(*args... | [
"def",
"wait_for",
"(",
"func",
")",
":",
"def",
"wrapped",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"timeout",
"=",
"kwargs",
".",
"pop",
"(",
"'timeout'",
",",
"15",
")",
"start",
"=",
"time",
"(",
")",
"result",
"=",
"None",
"while... | A decorator to invoke a function periodically until it returns a truthy
value. | [
"A",
"decorator",
"to",
"invoke",
"a",
"function",
"periodically",
"until",
"it",
"returns",
"a",
"truthy",
"value",
"."
] | python | train |
bioasp/caspo | caspo/design.py | https://github.com/bioasp/caspo/blob/a68d1eace75b9b08f23633d1fb5ce6134403959e/caspo/design.py#L92-L167 | def design(self, max_stimuli=-1, max_inhibitors=-1, max_experiments=10, relax=False, configure=None):
"""
Finds all optimal experimental designs using up to :attr:`max_experiments` experiments, such that each experiment has
up to :attr:`max_stimuli` stimuli and :attr:`max_inhibitors` inhibitors.... | [
"def",
"design",
"(",
"self",
",",
"max_stimuli",
"=",
"-",
"1",
",",
"max_inhibitors",
"=",
"-",
"1",
",",
"max_experiments",
"=",
"10",
",",
"relax",
"=",
"False",
",",
"configure",
"=",
"None",
")",
":",
"self",
".",
"designs",
"=",
"[",
"]",
"a... | Finds all optimal experimental designs using up to :attr:`max_experiments` experiments, such that each experiment has
up to :attr:`max_stimuli` stimuli and :attr:`max_inhibitors` inhibitors. Each optimal experimental design is appended in the
attribute :attr:`designs` as an instance of :class:`caspo.cor... | [
"Finds",
"all",
"optimal",
"experimental",
"designs",
"using",
"up",
"to",
":",
"attr",
":",
"max_experiments",
"experiments",
"such",
"that",
"each",
"experiment",
"has",
"up",
"to",
":",
"attr",
":",
"max_stimuli",
"stimuli",
"and",
":",
"attr",
":",
"max_... | python | train |
tisimst/mcerp | mcerp/umath.py | https://github.com/tisimst/mcerp/blob/2bb8260c9ad2d58a806847f1b627b6451e407de1/mcerp/umath.py#L247-L255 | def sin(x):
"""
Sine
"""
if isinstance(x, UncertainFunction):
mcpts = np.sin(x._mcpts)
return UncertainFunction(mcpts)
else:
return np.sin(x) | [
"def",
"sin",
"(",
"x",
")",
":",
"if",
"isinstance",
"(",
"x",
",",
"UncertainFunction",
")",
":",
"mcpts",
"=",
"np",
".",
"sin",
"(",
"x",
".",
"_mcpts",
")",
"return",
"UncertainFunction",
"(",
"mcpts",
")",
"else",
":",
"return",
"np",
".",
"s... | Sine | [
"Sine"
] | python | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Variables/BoolVariable.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Variables/BoolVariable.py#L47-L61 | def _text2bool(val):
"""
Converts strings to True/False depending on the 'truth' expressed by
the string. If the string can't be converted, the original value
will be returned.
See '__true_strings' and '__false_strings' for values considered
'true' or 'false respectively.
This is usable as... | [
"def",
"_text2bool",
"(",
"val",
")",
":",
"lval",
"=",
"val",
".",
"lower",
"(",
")",
"if",
"lval",
"in",
"__true_strings",
":",
"return",
"True",
"if",
"lval",
"in",
"__false_strings",
":",
"return",
"False",
"raise",
"ValueError",
"(",
"\"Invalid value ... | Converts strings to True/False depending on the 'truth' expressed by
the string. If the string can't be converted, the original value
will be returned.
See '__true_strings' and '__false_strings' for values considered
'true' or 'false respectively.
This is usable as 'converter' for SCons' Variables... | [
"Converts",
"strings",
"to",
"True",
"/",
"False",
"depending",
"on",
"the",
"truth",
"expressed",
"by",
"the",
"string",
".",
"If",
"the",
"string",
"can",
"t",
"be",
"converted",
"the",
"original",
"value",
"will",
"be",
"returned",
"."
] | python | train |
great-expectations/great_expectations | great_expectations/data_asset/base.py | https://github.com/great-expectations/great_expectations/blob/08385c40529d4f14a1c46916788aecc47f33ee9d/great_expectations/data_asset/base.py#L581-L673 | def get_expectations_config(self,
discard_failed_expectations=True,
discard_result_format_kwargs=True,
discard_include_configs_kwargs=True,
discard_catch_exceptions_kwargs=True,
... | [
"def",
"get_expectations_config",
"(",
"self",
",",
"discard_failed_expectations",
"=",
"True",
",",
"discard_result_format_kwargs",
"=",
"True",
",",
"discard_include_configs_kwargs",
"=",
"True",
",",
"discard_catch_exceptions_kwargs",
"=",
"True",
",",
"suppress_warnings... | Returns _expectation_config as a JSON object, and perform some cleaning along the way.
Args:
discard_failed_expectations (boolean): \
Only include expectations with success_on_last_run=True in the exported config. Defaults to `True`.
discard_result_format_kwargs (boolea... | [
"Returns",
"_expectation_config",
"as",
"a",
"JSON",
"object",
"and",
"perform",
"some",
"cleaning",
"along",
"the",
"way",
"."
] | python | train |
zaturox/glin | glin/zmq/messages.py | https://github.com/zaturox/glin/blob/55214a579c4e4b4d74765f3f6aa2eb815bac1c3b/glin/zmq/messages.py#L241-L249 | def uint8_3(self, name):
"""parse a tuple of 3 uint8 values"""
self._assert_is_string(name)
frame = self._next_frame()
if len(frame) != 3:
raise MessageParserError("Expected exacty 3 byte for 3 unit8 values")
vals = unpack("BBB", frame)
self.results.__dict__[n... | [
"def",
"uint8_3",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"_assert_is_string",
"(",
"name",
")",
"frame",
"=",
"self",
".",
"_next_frame",
"(",
")",
"if",
"len",
"(",
"frame",
")",
"!=",
"3",
":",
"raise",
"MessageParserError",
"(",
"\"Expecte... | parse a tuple of 3 uint8 values | [
"parse",
"a",
"tuple",
"of",
"3",
"uint8",
"values"
] | python | train |
RockFeng0/rtsf-web | webuidriver/actions.py | https://github.com/RockFeng0/rtsf-web/blob/ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71/webuidriver/actions.py#L626-L634 | def Enter(cls):
''' 在指定输入框发送回回车键
@note: key event -> enter
'''
element = cls._element()
action = ActionChains(Web.driver)
action.send_keys_to_element(element, Keys.ENTER)
action.perform() | [
"def",
"Enter",
"(",
"cls",
")",
":",
"element",
"=",
"cls",
".",
"_element",
"(",
")",
"action",
"=",
"ActionChains",
"(",
"Web",
".",
"driver",
")",
"action",
".",
"send_keys_to_element",
"(",
"element",
",",
"Keys",
".",
"ENTER",
")",
"action",
".",... | 在指定输入框发送回回车键
@note: key event -> enter | [
"在指定输入框发送回回车键"
] | python | train |
edx/edx-enterprise | enterprise/utils.py | https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/utils.py#L633-L643 | def get_configuration_value(val_name, default=None, **kwargs):
"""
Get a configuration value, or fall back to ``default`` if it doesn't exist.
Also takes a `type` argument to guide which particular upstream method to use when trying to retrieve a value.
Current types include:
- `url` to specifi... | [
"def",
"get_configuration_value",
"(",
"val_name",
",",
"default",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
".",
"get",
"(",
"'type'",
")",
"==",
"'url'",
":",
"return",
"get_url",
"(",
"val_name",
")",
"or",
"default",
"if",
"ca... | Get a configuration value, or fall back to ``default`` if it doesn't exist.
Also takes a `type` argument to guide which particular upstream method to use when trying to retrieve a value.
Current types include:
- `url` to specifically get a URL. | [
"Get",
"a",
"configuration",
"value",
"or",
"fall",
"back",
"to",
"default",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | python | valid |
JarryShaw/PyPCAPKit | src/protocols/transport/tcp.py | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/transport/tcp.py#L496-L530 | def _read_mode_pocsp(self, size, kind):
"""Read Partial Order Connection Service Profile option.
Positional arguments:
* size - int, length of option
* kind - int, 10 (POC-Serv Profile)
Returns:
* dict -- extracted Partial Order Connection Service Profile (P... | [
"def",
"_read_mode_pocsp",
"(",
"self",
",",
"size",
",",
"kind",
")",
":",
"temp",
"=",
"self",
".",
"_read_binary",
"(",
"size",
")",
"data",
"=",
"dict",
"(",
"kind",
"=",
"kind",
",",
"length",
"=",
"size",
",",
"start",
"=",
"True",
"if",
"int... | Read Partial Order Connection Service Profile option.
Positional arguments:
* size - int, length of option
* kind - int, 10 (POC-Serv Profile)
Returns:
* dict -- extracted Partial Order Connection Service Profile (POC-SP) option
Structure of TCP POC-SP Opti... | [
"Read",
"Partial",
"Order",
"Connection",
"Service",
"Profile",
"option",
"."
] | python | train |
nint8835/jigsaw | jigsaw/PluginLoader.py | https://github.com/nint8835/jigsaw/blob/109e62801a0334652e88ea972a95a341ccc96621/jigsaw/PluginLoader.py#L57-L74 | def load_manifest(self, path):
"""
Loads a plugin manifest from a given path
:param path: The folder to load the plugin manifest from
"""
manifest_path = os.path.join(path, "plugin.json")
self._logger.debug("Attempting to load plugin manifest from {}.".format(manifest_pa... | [
"def",
"load_manifest",
"(",
"self",
",",
"path",
")",
":",
"manifest_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"\"plugin.json\"",
")",
"self",
".",
"_logger",
".",
"debug",
"(",
"\"Attempting to load plugin manifest from {}.\"",
".",
"form... | Loads a plugin manifest from a given path
:param path: The folder to load the plugin manifest from | [
"Loads",
"a",
"plugin",
"manifest",
"from",
"a",
"given",
"path"
] | python | train |
open-mmlab/mmcv | mmcv/image/transforms/geometry.py | https://github.com/open-mmlab/mmcv/blob/0d77f61450aab4dde8b8585a577cc496acb95d7f/mmcv/image/transforms/geometry.py#L166-L187 | def impad(img, shape, pad_val=0):
"""Pad an image to a certain shape.
Args:
img (ndarray): Image to be padded.
shape (tuple): Expected padding shape.
pad_val (number or sequence): Values to be filled in padding areas.
Returns:
ndarray: The padded image.
"""
if not i... | [
"def",
"impad",
"(",
"img",
",",
"shape",
",",
"pad_val",
"=",
"0",
")",
":",
"if",
"not",
"isinstance",
"(",
"pad_val",
",",
"(",
"int",
",",
"float",
")",
")",
":",
"assert",
"len",
"(",
"pad_val",
")",
"==",
"img",
".",
"shape",
"[",
"-",
"1... | Pad an image to a certain shape.
Args:
img (ndarray): Image to be padded.
shape (tuple): Expected padding shape.
pad_val (number or sequence): Values to be filled in padding areas.
Returns:
ndarray: The padded image. | [
"Pad",
"an",
"image",
"to",
"a",
"certain",
"shape",
"."
] | python | test |
backbohne/docx-xslt | docxxslt/engines.py | https://github.com/backbohne/docx-xslt/blob/d4cc76776a75b8213660c3c1717d42afe5189e15/docxxslt/engines.py#L93-L97 | def render_xsl(self, node, context):
"""Render all XSL elements"""
for e in self.xsl_elements:
e.render(e.run) | [
"def",
"render_xsl",
"(",
"self",
",",
"node",
",",
"context",
")",
":",
"for",
"e",
"in",
"self",
".",
"xsl_elements",
":",
"e",
".",
"render",
"(",
"e",
".",
"run",
")"
] | Render all XSL elements | [
"Render",
"all",
"XSL",
"elements"
] | python | train |
pandas-dev/pandas | pandas/core/series.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/series.py#L598-L665 | def view(self, dtype=None):
"""
Create a new view of the Series.
This function will return a new Series with a view of the same
underlying values in memory, optionally reinterpreted with a new data
type. The new data type must preserve the same size in bytes as to not
ca... | [
"def",
"view",
"(",
"self",
",",
"dtype",
"=",
"None",
")",
":",
"return",
"self",
".",
"_constructor",
"(",
"self",
".",
"_values",
".",
"view",
"(",
"dtype",
")",
",",
"index",
"=",
"self",
".",
"index",
")",
".",
"__finalize__",
"(",
"self",
")"... | Create a new view of the Series.
This function will return a new Series with a view of the same
underlying values in memory, optionally reinterpreted with a new data
type. The new data type must preserve the same size in bytes as to not
cause index misalignment.
Parameters
... | [
"Create",
"a",
"new",
"view",
"of",
"the",
"Series",
"."
] | python | train |
onecodex/onecodex | onecodex/lib/upload.py | https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/lib/upload.py#L199-L207 | def seek(self, loc):
"""Called if upload fails and must be retried."""
assert loc == 0
# rewind progress bar
if self.progressbar:
self.progressbar.update(-self._fp.tell())
self._fp.seek(loc) | [
"def",
"seek",
"(",
"self",
",",
"loc",
")",
":",
"assert",
"loc",
"==",
"0",
"# rewind progress bar",
"if",
"self",
".",
"progressbar",
":",
"self",
".",
"progressbar",
".",
"update",
"(",
"-",
"self",
".",
"_fp",
".",
"tell",
"(",
")",
")",
"self",... | Called if upload fails and must be retried. | [
"Called",
"if",
"upload",
"fails",
"and",
"must",
"be",
"retried",
"."
] | python | train |
sloria/konch | konch.py | https://github.com/sloria/konch/blob/15160bd0a0cac967eeeab84794bd6cdd0b5b637d/konch.py#L245-L259 | def format_context(
context: Context, formatter: typing.Union[str, Formatter] = "full"
) -> str:
"""Output the a context dictionary as a string."""
if not context:
return ""
if callable(formatter):
formatter_func = formatter
else:
if formatter in CONTEXT_FORMATTERS:
... | [
"def",
"format_context",
"(",
"context",
":",
"Context",
",",
"formatter",
":",
"typing",
".",
"Union",
"[",
"str",
",",
"Formatter",
"]",
"=",
"\"full\"",
")",
"->",
"str",
":",
"if",
"not",
"context",
":",
"return",
"\"\"",
"if",
"callable",
"(",
"fo... | Output the a context dictionary as a string. | [
"Output",
"the",
"a",
"context",
"dictionary",
"as",
"a",
"string",
"."
] | python | train |
fastai/fastai | fastai/vision/image.py | https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/vision/image.py#L594-L600 | def _get_resize_target(img, crop_target, do_crop=False)->TensorImageSize:
"Calc size of `img` to fit in `crop_target` - adjust based on `do_crop`."
if crop_target is None: return None
ch,r,c = img.shape
target_r,target_c = crop_target
ratio = (min if do_crop else max)(r/target_r, c/target_c)
ret... | [
"def",
"_get_resize_target",
"(",
"img",
",",
"crop_target",
",",
"do_crop",
"=",
"False",
")",
"->",
"TensorImageSize",
":",
"if",
"crop_target",
"is",
"None",
":",
"return",
"None",
"ch",
",",
"r",
",",
"c",
"=",
"img",
".",
"shape",
"target_r",
",",
... | Calc size of `img` to fit in `crop_target` - adjust based on `do_crop`. | [
"Calc",
"size",
"of",
"img",
"to",
"fit",
"in",
"crop_target",
"-",
"adjust",
"based",
"on",
"do_crop",
"."
] | python | train |
klahnakoski/pyLibrary | pyLibrary/sql/sqlite.py | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/sql/sqlite.py#L191-L203 | def close(self):
"""
OPTIONAL COMMIT-AND-CLOSE
IF THIS IS NOT DONE, THEN THE THREAD THAT SPAWNED THIS INSTANCE
:return:
"""
self.closed = True
signal = _allocate_lock()
signal.acquire()
self.queue.add(CommandItem(COMMIT, None, signal, None, None))
... | [
"def",
"close",
"(",
"self",
")",
":",
"self",
".",
"closed",
"=",
"True",
"signal",
"=",
"_allocate_lock",
"(",
")",
"signal",
".",
"acquire",
"(",
")",
"self",
".",
"queue",
".",
"add",
"(",
"CommandItem",
"(",
"COMMIT",
",",
"None",
",",
"signal",... | OPTIONAL COMMIT-AND-CLOSE
IF THIS IS NOT DONE, THEN THE THREAD THAT SPAWNED THIS INSTANCE
:return: | [
"OPTIONAL",
"COMMIT",
"-",
"AND",
"-",
"CLOSE",
"IF",
"THIS",
"IS",
"NOT",
"DONE",
"THEN",
"THE",
"THREAD",
"THAT",
"SPAWNED",
"THIS",
"INSTANCE",
":",
"return",
":"
] | python | train |
Tygs/ww | src/ww/tools/iterables.py | https://github.com/Tygs/ww/blob/6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4/src/ww/tools/iterables.py#L333-L343 | def lasts(iterable, items=1, default=None):
# type: (Iterable[T], int, T) -> Iterable[T]
""" Lazily return the last x items from this iterable or default. """
last_items = deque(iterable, maxlen=items)
for _ in range(items - len(last_items)):
yield default
for y in last_items:
yie... | [
"def",
"lasts",
"(",
"iterable",
",",
"items",
"=",
"1",
",",
"default",
"=",
"None",
")",
":",
"# type: (Iterable[T], int, T) -> Iterable[T]",
"last_items",
"=",
"deque",
"(",
"iterable",
",",
"maxlen",
"=",
"items",
")",
"for",
"_",
"in",
"range",
"(",
"... | Lazily return the last x items from this iterable or default. | [
"Lazily",
"return",
"the",
"last",
"x",
"items",
"from",
"this",
"iterable",
"or",
"default",
"."
] | python | train |
GibbsConsulting/django-plotly-dash | demo/demo/views.py | https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/demo/demo/views.py#L9-L19 | def dash_example_1_view(request, template_name="demo_six.html", **kwargs):
'Example view that inserts content into the dash context passed to the dash application'
context = {}
# create some context to send over to Dash:
dash_context = request.session.get("django_plotly_dash", dict())
dash_context... | [
"def",
"dash_example_1_view",
"(",
"request",
",",
"template_name",
"=",
"\"demo_six.html\"",
",",
"*",
"*",
"kwargs",
")",
":",
"context",
"=",
"{",
"}",
"# create some context to send over to Dash:",
"dash_context",
"=",
"request",
".",
"session",
".",
"get",
"(... | Example view that inserts content into the dash context passed to the dash application | [
"Example",
"view",
"that",
"inserts",
"content",
"into",
"the",
"dash",
"context",
"passed",
"to",
"the",
"dash",
"application"
] | python | train |
svenkreiss/databench | databench/app.py | https://github.com/svenkreiss/databench/blob/99d4adad494b60a42af6b8bfba94dd0c41ba0786/databench/app.py#L386-L393 | def get(self):
"""Render the List-of-Analyses overview page."""
return self.render(
'index.html',
databench_version=DATABENCH_VERSION,
meta_infos=self.meta_infos(),
**self.info
) | [
"def",
"get",
"(",
"self",
")",
":",
"return",
"self",
".",
"render",
"(",
"'index.html'",
",",
"databench_version",
"=",
"DATABENCH_VERSION",
",",
"meta_infos",
"=",
"self",
".",
"meta_infos",
"(",
")",
",",
"*",
"*",
"self",
".",
"info",
")"
] | Render the List-of-Analyses overview page. | [
"Render",
"the",
"List",
"-",
"of",
"-",
"Analyses",
"overview",
"page",
"."
] | python | train |
django-salesforce/django-salesforce | salesforce/dbapi/subselect.py | https://github.com/django-salesforce/django-salesforce/blob/6fd5643dba69d49c5881de50875cf90204a8f808/salesforce/dbapi/subselect.py#L128-L149 | def _make_flat(self, row_dict, path, subroots):
"""Replace the nested dict objects by a flat dict with keys "object.object.name"."""
# can get a cursor parameter, if introspection should be possible on the fly
out = {}
for k, v in row_dict.items():
klc = k.lower() # "key low... | [
"def",
"_make_flat",
"(",
"self",
",",
"row_dict",
",",
"path",
",",
"subroots",
")",
":",
"# can get a cursor parameter, if introspection should be possible on the fly",
"out",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"row_dict",
".",
"items",
"(",
")",
":",
... | Replace the nested dict objects by a flat dict with keys "object.object.name". | [
"Replace",
"the",
"nested",
"dict",
"objects",
"by",
"a",
"flat",
"dict",
"with",
"keys",
"object",
".",
"object",
".",
"name",
"."
] | python | train |
portfors-lab/sparkle | sparkle/tools/audiotools.py | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/tools/audiotools.py#L159-L221 | def spectrogram(source, nfft=512, overlap=90, window='hanning', caldb=93, calv=2.83):
"""
Produce a matrix of spectral intensity, uses matplotlib's specgram
function. Output is in dB scale.
:param source: filename of audiofile, or samplerate and vector of audio signal
:type source: str or (int, num... | [
"def",
"spectrogram",
"(",
"source",
",",
"nfft",
"=",
"512",
",",
"overlap",
"=",
"90",
",",
"window",
"=",
"'hanning'",
",",
"caldb",
"=",
"93",
",",
"calv",
"=",
"2.83",
")",
":",
"if",
"isinstance",
"(",
"source",
",",
"basestring",
")",
":",
"... | Produce a matrix of spectral intensity, uses matplotlib's specgram
function. Output is in dB scale.
:param source: filename of audiofile, or samplerate and vector of audio signal
:type source: str or (int, numpy.ndarray)
:param nfft: size of nfft window to use
:type nfft: int
:param overlap: pe... | [
"Produce",
"a",
"matrix",
"of",
"spectral",
"intensity",
"uses",
"matplotlib",
"s",
"specgram",
"function",
".",
"Output",
"is",
"in",
"dB",
"scale",
"."
] | python | train |
google/grumpy | third_party/pythonparser/parser.py | https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L1152-L1156 | def nonlocal_stmt(self, nonlocal_loc, names):
"""(3.0-) nonlocal_stmt: 'nonlocal' NAME (',' NAME)*"""
return ast.Nonlocal(names=list(map(lambda x: x.value, names)),
name_locs=list(map(lambda x: x.loc, names)),
keyword_loc=nonlocal_loc, loc=nonlocal... | [
"def",
"nonlocal_stmt",
"(",
"self",
",",
"nonlocal_loc",
",",
"names",
")",
":",
"return",
"ast",
".",
"Nonlocal",
"(",
"names",
"=",
"list",
"(",
"map",
"(",
"lambda",
"x",
":",
"x",
".",
"value",
",",
"names",
")",
")",
",",
"name_locs",
"=",
"l... | (3.0-) nonlocal_stmt: 'nonlocal' NAME (',' NAME)* | [
"(",
"3",
".",
"0",
"-",
")",
"nonlocal_stmt",
":",
"nonlocal",
"NAME",
"(",
"NAME",
")",
"*"
] | python | valid |
nickpandolfi/Cyther | cyther/pathway.py | https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/pathway.py#L181-L196 | def get_name(path_name, *, ext=True, override=None, identity=None):
"""
Gets the name par of the path name given. By 'name' I mean the basename of
a filename's path, such as 'test.o' in the path: 'C:/test/test.o'
"""
if identity is None:
identity = identify(path_name, override=override)
... | [
"def",
"get_name",
"(",
"path_name",
",",
"*",
",",
"ext",
"=",
"True",
",",
"override",
"=",
"None",
",",
"identity",
"=",
"None",
")",
":",
"if",
"identity",
"is",
"None",
":",
"identity",
"=",
"identify",
"(",
"path_name",
",",
"override",
"=",
"o... | Gets the name par of the path name given. By 'name' I mean the basename of
a filename's path, such as 'test.o' in the path: 'C:/test/test.o' | [
"Gets",
"the",
"name",
"par",
"of",
"the",
"path",
"name",
"given",
".",
"By",
"name",
"I",
"mean",
"the",
"basename",
"of",
"a",
"filename",
"s",
"path",
"such",
"as",
"test",
".",
"o",
"in",
"the",
"path",
":",
"C",
":",
"/",
"test",
"/",
"test... | python | train |
razor-x/scipy-data_fitting | scipy_data_fitting/core.py | https://github.com/razor-x/scipy-data_fitting/blob/c756a645da8629699b3f22244bfb7d5d4d88b179/scipy_data_fitting/core.py#L3-L15 | def get_constant(value):
"""
When `value` is a string, get the corresponding constant from [`scipy.constants`][1].
[1]: http://docs.scipy.org/doc/scipy/reference/constants.html
"""
if type(value) is str:
if hasattr(scipy.constants, value):
return getattr(scipy.constants, value)
... | [
"def",
"get_constant",
"(",
"value",
")",
":",
"if",
"type",
"(",
"value",
")",
"is",
"str",
":",
"if",
"hasattr",
"(",
"scipy",
".",
"constants",
",",
"value",
")",
":",
"return",
"getattr",
"(",
"scipy",
".",
"constants",
",",
"value",
")",
"else",... | When `value` is a string, get the corresponding constant from [`scipy.constants`][1].
[1]: http://docs.scipy.org/doc/scipy/reference/constants.html | [
"When",
"value",
"is",
"a",
"string",
"get",
"the",
"corresponding",
"constant",
"from",
"[",
"scipy",
".",
"constants",
"]",
"[",
"1",
"]",
"."
] | python | train |
twisted/mantissa | xmantissa/people.py | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/people.py#L920-L941 | def getContactCreationParameters(self):
"""
Yield a L{Parameter} for each L{IContactType} known.
Each yielded object can be used with a L{LiveForm} to create a new
instance of a particular L{IContactType}.
"""
for contactType in self.getContactTypes():
if con... | [
"def",
"getContactCreationParameters",
"(",
"self",
")",
":",
"for",
"contactType",
"in",
"self",
".",
"getContactTypes",
"(",
")",
":",
"if",
"contactType",
".",
"allowMultipleContactItems",
":",
"descriptiveIdentifier",
"=",
"_descriptiveIdentifier",
"(",
"contactTy... | Yield a L{Parameter} for each L{IContactType} known.
Each yielded object can be used with a L{LiveForm} to create a new
instance of a particular L{IContactType}. | [
"Yield",
"a",
"L",
"{",
"Parameter",
"}",
"for",
"each",
"L",
"{",
"IContactType",
"}",
"known",
"."
] | python | train |
ubernostrum/django-registration | src/django_registration/backends/activation/views.py | https://github.com/ubernostrum/django-registration/blob/cf10b13423669346a1f4cfaa31aae0b42856b416/src/django_registration/backends/activation/views.py#L162-L184 | def get_user(self, username):
"""
Given the verified username, look up and return the
corresponding user account if it exists, or raising
``ActivationError`` if it doesn't.
"""
User = get_user_model()
try:
user = User.objects.get(**{
U... | [
"def",
"get_user",
"(",
"self",
",",
"username",
")",
":",
"User",
"=",
"get_user_model",
"(",
")",
"try",
":",
"user",
"=",
"User",
".",
"objects",
".",
"get",
"(",
"*",
"*",
"{",
"User",
".",
"USERNAME_FIELD",
":",
"username",
",",
"}",
")",
"if"... | Given the verified username, look up and return the
corresponding user account if it exists, or raising
``ActivationError`` if it doesn't. | [
"Given",
"the",
"verified",
"username",
"look",
"up",
"and",
"return",
"the",
"corresponding",
"user",
"account",
"if",
"it",
"exists",
"or",
"raising",
"ActivationError",
"if",
"it",
"doesn",
"t",
"."
] | python | train |
soasme/dogeon | dson/__init__.py | https://github.com/soasme/dogeon/blob/496b9a5b099946d14434ed0cd7a94a270f607207/dson/__init__.py#L125-L193 | def dump(obj, fp, skipkeys=False, ensure_ascii=True, check_circular=True,
allow_nan=True, cls=None, indent=None, separators=None,
encoding='utf-8', default=None, sort_keys=False, **kw):
"""Serialize ``obj`` as a DSON formatted stream to ``fp`` (a
``.write()``-supporting file-like object).
I... | [
"def",
"dump",
"(",
"obj",
",",
"fp",
",",
"skipkeys",
"=",
"False",
",",
"ensure_ascii",
"=",
"True",
",",
"check_circular",
"=",
"True",
",",
"allow_nan",
"=",
"True",
",",
"cls",
"=",
"None",
",",
"indent",
"=",
"None",
",",
"separators",
"=",
"No... | Serialize ``obj`` as a DSON formatted stream to ``fp`` (a
``.write()``-supporting file-like object).
If ``skipkeys`` is true then ``dict`` keys that are not basic types
(``str``, ``unicode``, ``int``, ``long``, ``float``, ``bool``, ``None``)
will be skipped instead of raising a ``TypeError``.
If `... | [
"Serialize",
"obj",
"as",
"a",
"DSON",
"formatted",
"stream",
"to",
"fp",
"(",
"a",
".",
"write",
"()",
"-",
"supporting",
"file",
"-",
"like",
"object",
")",
"."
] | python | train |
astooke/gtimer | gtimer/public/report.py | https://github.com/astooke/gtimer/blob/2146dab459e5d959feb291821733d3d3ba7c523c/gtimer/public/report.py#L89-L155 | def compare(times_list=None,
name=None,
include_list=True,
include_stats=True,
delim_mode=False,
format_options=None):
"""
Produce a formatted comparison of timing datas.
Notes:
If no times_list is provided, produces comparison reports on ... | [
"def",
"compare",
"(",
"times_list",
"=",
"None",
",",
"name",
"=",
"None",
",",
"include_list",
"=",
"True",
",",
"include_stats",
"=",
"True",
",",
"delim_mode",
"=",
"False",
",",
"format_options",
"=",
"None",
")",
":",
"if",
"times_list",
"is",
"Non... | Produce a formatted comparison of timing datas.
Notes:
If no times_list is provided, produces comparison reports on all parallel
subdivisions present at the root level of the current timer. To compare
parallel subdivisions at a lower level, get the times data, navigate
within it to... | [
"Produce",
"a",
"formatted",
"comparison",
"of",
"timing",
"datas",
"."
] | python | train |
learningequality/ricecooker | ricecooker/config.py | https://github.com/learningequality/ricecooker/blob/2f0385282500cb77ef2894646c6f9ce11bd7a853/ricecooker/config.py#L264-L270 | def open_channel_url(channel, staging=False):
""" open_channel_url: returns url to uploaded channel
Args:
channel (str): channel id of uploaded channel
Returns: string url to open channel
"""
return OPEN_CHANNEL_URL.format(domain=DOMAIN, channel_id=channel, access='staging' if st... | [
"def",
"open_channel_url",
"(",
"channel",
",",
"staging",
"=",
"False",
")",
":",
"return",
"OPEN_CHANNEL_URL",
".",
"format",
"(",
"domain",
"=",
"DOMAIN",
",",
"channel_id",
"=",
"channel",
",",
"access",
"=",
"'staging'",
"if",
"staging",
"or",
"STAGE",
... | open_channel_url: returns url to uploaded channel
Args:
channel (str): channel id of uploaded channel
Returns: string url to open channel | [
"open_channel_url",
":",
"returns",
"url",
"to",
"uploaded",
"channel",
"Args",
":",
"channel",
"(",
"str",
")",
":",
"channel",
"id",
"of",
"uploaded",
"channel",
"Returns",
":",
"string",
"url",
"to",
"open",
"channel"
] | python | train |
SetBased/py-etlt | etlt/helper/Type2Helper.py | https://github.com/SetBased/py-etlt/blob/1c5b8ea60293c14f54d7845a9fe5c595021f66f2/etlt/helper/Type2Helper.py#L325-L336 | def get_rows(self, sort=False):
"""
Returns the rows of this Type2Helper.
:param bool sort: If True the rows are sorted by the pseudo key.
"""
ret = []
for _, rows in sorted(self._rows.items()) if sort else self._rows.items():
self._rows_int2date(rows)
... | [
"def",
"get_rows",
"(",
"self",
",",
"sort",
"=",
"False",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"_",
",",
"rows",
"in",
"sorted",
"(",
"self",
".",
"_rows",
".",
"items",
"(",
")",
")",
"if",
"sort",
"else",
"self",
".",
"_rows",
".",
"items"... | Returns the rows of this Type2Helper.
:param bool sort: If True the rows are sorted by the pseudo key. | [
"Returns",
"the",
"rows",
"of",
"this",
"Type2Helper",
"."
] | python | train |
IBM/pyxcli | pyxcli/pool.py | https://github.com/IBM/pyxcli/blob/7d8ece1dcc16f50246740a447aa81b94a0dbced4/pyxcli/pool.py#L70-L79 | def flush(self):
"""remove all stale clients from pool"""
now = time.time()
to_remove = []
for k, entry in self.pool.items():
if entry.timestamp < now:
entry.client.close()
to_remove.append(k)
for k in to_remove:
del self.po... | [
"def",
"flush",
"(",
"self",
")",
":",
"now",
"=",
"time",
".",
"time",
"(",
")",
"to_remove",
"=",
"[",
"]",
"for",
"k",
",",
"entry",
"in",
"self",
".",
"pool",
".",
"items",
"(",
")",
":",
"if",
"entry",
".",
"timestamp",
"<",
"now",
":",
... | remove all stale clients from pool | [
"remove",
"all",
"stale",
"clients",
"from",
"pool"
] | python | train |
automl/HpBandSter | hpbandster/examples/commons.py | https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/examples/commons.py#L22-L46 | def compute(self, config, budget, **kwargs):
"""
Simple example for a compute function
The loss is just a the config + some noise (that decreases with the budget)
For dramatization, the function can sleep for a given interval to emphasizes
the speed ups achievable with parallel ... | [
"def",
"compute",
"(",
"self",
",",
"config",
",",
"budget",
",",
"*",
"*",
"kwargs",
")",
":",
"res",
"=",
"numpy",
".",
"clip",
"(",
"config",
"[",
"'x'",
"]",
"+",
"numpy",
".",
"random",
".",
"randn",
"(",
")",
"/",
"budget",
",",
"config",
... | Simple example for a compute function
The loss is just a the config + some noise (that decreases with the budget)
For dramatization, the function can sleep for a given interval to emphasizes
the speed ups achievable with parallel workers.
Args:
config: dictionary containing... | [
"Simple",
"example",
"for",
"a",
"compute",
"function",
"The",
"loss",
"is",
"just",
"a",
"the",
"config",
"+",
"some",
"noise",
"(",
"that",
"decreases",
"with",
"the",
"budget",
")"
] | python | train |
numenta/nupic | src/nupic/swarming/permutations_runner.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/permutations_runner.py#L1743-L1757 | def queryModelIDs(self):
"""Queuries DB for model IDs of all currently instantiated models
associated with this HyperSearch job.
See also: _iterModels()
Parameters:
----------------------------------------------------------------------
retval: A sequence of Nupic modelIDs
"""
j... | [
"def",
"queryModelIDs",
"(",
"self",
")",
":",
"jobID",
"=",
"self",
".",
"getJobID",
"(",
")",
"modelCounterPairs",
"=",
"_clientJobsDB",
"(",
")",
".",
"modelsGetUpdateCounters",
"(",
"jobID",
")",
"modelIDs",
"=",
"tuple",
"(",
"x",
"[",
"0",
"]",
"fo... | Queuries DB for model IDs of all currently instantiated models
associated with this HyperSearch job.
See also: _iterModels()
Parameters:
----------------------------------------------------------------------
retval: A sequence of Nupic modelIDs | [
"Queuries",
"DB",
"for",
"model",
"IDs",
"of",
"all",
"currently",
"instantiated",
"models",
"associated",
"with",
"this",
"HyperSearch",
"job",
"."
] | python | valid |
DataDog/integrations-core | tokumx/datadog_checks/tokumx/vendor/gridfs/grid_file.py | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/gridfs/grid_file.py#L470-L512 | def read(self, size=-1):
"""Read at most `size` bytes from the file (less if there
isn't enough data).
The bytes are returned as an instance of :class:`str` (:class:`bytes`
in python 3). If `size` is negative or omitted all data is read.
:Parameters:
- `size` (optiona... | [
"def",
"read",
"(",
"self",
",",
"size",
"=",
"-",
"1",
")",
":",
"self",
".",
"_ensure_file",
"(",
")",
"if",
"size",
"==",
"0",
":",
"return",
"EMPTY",
"remainder",
"=",
"int",
"(",
"self",
".",
"length",
")",
"-",
"self",
".",
"__position",
"i... | Read at most `size` bytes from the file (less if there
isn't enough data).
The bytes are returned as an instance of :class:`str` (:class:`bytes`
in python 3). If `size` is negative or omitted all data is read.
:Parameters:
- `size` (optional): the number of bytes to read | [
"Read",
"at",
"most",
"size",
"bytes",
"from",
"the",
"file",
"(",
"less",
"if",
"there",
"isn",
"t",
"enough",
"data",
")",
"."
] | python | train |
mikekatz04/BOWIE | bowie/plotutils/readdata.py | https://github.com/mikekatz04/BOWIE/blob/a941342a3536cb57c817a1643896d99a3f354a86/bowie/plotutils/readdata.py#L87-L107 | def txt_read_in(self):
"""Read in txt files.
Method for reading in text or csv files. This uses ascii class from astropy.io
for flexible input. It is slower than numpy, but has greater flexibility with less input.
"""
# read in
data = ascii.read(self.WORKING_DIRECTORY ... | [
"def",
"txt_read_in",
"(",
"self",
")",
":",
"# read in",
"data",
"=",
"ascii",
".",
"read",
"(",
"self",
".",
"WORKING_DIRECTORY",
"+",
"'/'",
"+",
"self",
".",
"file_name",
")",
"# find number of distinct x and y points.",
"num_x_pts",
"=",
"len",
"(",
"np",... | Read in txt files.
Method for reading in text or csv files. This uses ascii class from astropy.io
for flexible input. It is slower than numpy, but has greater flexibility with less input. | [
"Read",
"in",
"txt",
"files",
"."
] | python | train |
nats-io/python-nats | nats/io/client.py | https://github.com/nats-io/python-nats/blob/4a409319c409e7e55ce8377b64b406375c5f455b/nats/io/client.py#L206-L348 | def connect(self,
servers=["nats://127.0.0.1:4222"],
loop=None,
# 'io_loop' and 'loop' are the same, but we have
# both params to be consistent with asyncio client.
io_loop=None,
# Event Callbacks
error_cb=N... | [
"def",
"connect",
"(",
"self",
",",
"servers",
"=",
"[",
"\"nats://127.0.0.1:4222\"",
"]",
",",
"loop",
"=",
"None",
",",
"# 'io_loop' and 'loop' are the same, but we have",
"# both params to be consistent with asyncio client.",
"io_loop",
"=",
"None",
",",
"# Event Callbac... | Establishes a connection to a NATS server.
Examples:
# Configure pool of NATS servers.
nc = nats.io.client.Client()
yield nc.connect({ 'servers': ['nats://192.168.1.10:4222', 'nats://192.168.2.10:4222'] })
# User and pass are to be passed on the uri to authenticate.
... | [
"Establishes",
"a",
"connection",
"to",
"a",
"NATS",
"server",
"."
] | python | train |
jasonbot/arcrest | arcrest/server.py | https://github.com/jasonbot/arcrest/blob/b1ba71fd59bb6349415e7879d753d307dbc0da26/arcrest/server.py#L476-L481 | def services(self):
"Returns a list of Service objects available in this folder"
return [self._get_subfolder("%s/%s/" %
(s['name'].rstrip('/').split('/')[-1], s['type']),
self._service_type_mapping.get(s['type'], Service)) for s
in self._json_struct.get(... | [
"def",
"services",
"(",
"self",
")",
":",
"return",
"[",
"self",
".",
"_get_subfolder",
"(",
"\"%s/%s/\"",
"%",
"(",
"s",
"[",
"'name'",
"]",
".",
"rstrip",
"(",
"'/'",
")",
".",
"split",
"(",
"'/'",
")",
"[",
"-",
"1",
"]",
",",
"s",
"[",
"'ty... | Returns a list of Service objects available in this folder | [
"Returns",
"a",
"list",
"of",
"Service",
"objects",
"available",
"in",
"this",
"folder"
] | python | train |
cjdrake/pyeda | pyeda/boolalg/boolfunc.py | https://github.com/cjdrake/pyeda/blob/554ee53aa678f4b61bcd7e07ba2c74ddc749d665/pyeda/boolalg/boolfunc.py#L665-L677 | def smoothing(self, vs=None):
r"""Return the smoothing of a function over a sequence of N variables.
The *vs* argument is a sequence of :math:`N` Boolean variables.
The *smoothing* of :math:`f(x_1, x_2, \dots, x_i, \dots, x_n)` with
respect to variable :math:`x_i` is:
:math:`S_... | [
"def",
"smoothing",
"(",
"self",
",",
"vs",
"=",
"None",
")",
":",
"return",
"functools",
".",
"reduce",
"(",
"operator",
".",
"or_",
",",
"self",
".",
"iter_cofactors",
"(",
"vs",
")",
")"
] | r"""Return the smoothing of a function over a sequence of N variables.
The *vs* argument is a sequence of :math:`N` Boolean variables.
The *smoothing* of :math:`f(x_1, x_2, \dots, x_i, \dots, x_n)` with
respect to variable :math:`x_i` is:
:math:`S_{x_i}(f) = f_{x_i} + f_{x_i'}`
... | [
"r",
"Return",
"the",
"smoothing",
"of",
"a",
"function",
"over",
"a",
"sequence",
"of",
"N",
"variables",
"."
] | python | train |
Robpol86/libnl | libnl/nl80211/iw_scan.py | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/nl80211/iw_scan.py#L156-L171 | def get_cipher(data):
"""http://git.kernel.org/cgit/linux/kernel/git/jberg/iw.git/tree/scan.c?id=v3.17#n336.
Positional arguments:
data -- bytearray data to read.
Returns:
WiFi stream cipher used by the access point (string).
"""
legend = {0: 'Use group cipher suite', 1: 'WEP-40', 2: 'TKIP... | [
"def",
"get_cipher",
"(",
"data",
")",
":",
"legend",
"=",
"{",
"0",
":",
"'Use group cipher suite'",
",",
"1",
":",
"'WEP-40'",
",",
"2",
":",
"'TKIP'",
",",
"4",
":",
"'CCMP'",
",",
"5",
":",
"'WEP-104'",
",",
"}",
"key",
"=",
"data",
"[",
"3",
... | http://git.kernel.org/cgit/linux/kernel/git/jberg/iw.git/tree/scan.c?id=v3.17#n336.
Positional arguments:
data -- bytearray data to read.
Returns:
WiFi stream cipher used by the access point (string). | [
"http",
":",
"//",
"git",
".",
"kernel",
".",
"org",
"/",
"cgit",
"/",
"linux",
"/",
"kernel",
"/",
"git",
"/",
"jberg",
"/",
"iw",
".",
"git",
"/",
"tree",
"/",
"scan",
".",
"c?id",
"=",
"v3",
".",
"17#n336",
"."
] | python | train |
bernardopires/django-tenant-schemas | tenant_schemas/storage.py | https://github.com/bernardopires/django-tenant-schemas/blob/75faf00834e1fb7ed017949bfb54531f6329a8dd/tenant_schemas/storage.py#L27-L43 | def path(self, name):
"""
Look for files in subdirectory of MEDIA_ROOT using the tenant's
domain_url value as the specifier.
"""
if name is None:
name = ''
try:
location = safe_join(self.location, connection.tenant.domain_url)
except Attrib... | [
"def",
"path",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"''",
"try",
":",
"location",
"=",
"safe_join",
"(",
"self",
".",
"location",
",",
"connection",
".",
"tenant",
".",
"domain_url",
")",
"except",
"Attrib... | Look for files in subdirectory of MEDIA_ROOT using the tenant's
domain_url value as the specifier. | [
"Look",
"for",
"files",
"in",
"subdirectory",
"of",
"MEDIA_ROOT",
"using",
"the",
"tenant",
"s",
"domain_url",
"value",
"as",
"the",
"specifier",
"."
] | python | train |
RudolfCardinal/pythonlib | cardinal_pythonlib/rnc_text.py | https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_text.py#L39-L56 | def produce_csv_output(filehandle: TextIO,
fields: Sequence[str],
values: Iterable[str]) -> None:
"""
Produce CSV output, without using ``csv.writer``, so the log can be used
for lots of things.
- ... eh? What was I talking about?
- POOR; DEPRECATED.
... | [
"def",
"produce_csv_output",
"(",
"filehandle",
":",
"TextIO",
",",
"fields",
":",
"Sequence",
"[",
"str",
"]",
",",
"values",
":",
"Iterable",
"[",
"str",
"]",
")",
"->",
"None",
":",
"output_csv",
"(",
"filehandle",
",",
"fields",
")",
"for",
"row",
... | Produce CSV output, without using ``csv.writer``, so the log can be used
for lots of things.
- ... eh? What was I talking about?
- POOR; DEPRECATED.
Args:
filehandle: file to write to
fields: field names
values: values | [
"Produce",
"CSV",
"output",
"without",
"using",
"csv",
".",
"writer",
"so",
"the",
"log",
"can",
"be",
"used",
"for",
"lots",
"of",
"things",
"."
] | python | train |
NASA-AMMOS/AIT-Core | ait/core/bsc.py | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/bsc.py#L379-L393 | def _decode_time_rotation_index(self, time_rot_index):
''' Return the time struct index to use for log rotation checks '''
time_index_decode_table = {
'year': 0, 'years': 0, 'tm_year': 0,
'month': 1, 'months': 1, 'tm_mon': 1,
'day': 2, 'days': 2, 'tm... | [
"def",
"_decode_time_rotation_index",
"(",
"self",
",",
"time_rot_index",
")",
":",
"time_index_decode_table",
"=",
"{",
"'year'",
":",
"0",
",",
"'years'",
":",
"0",
",",
"'tm_year'",
":",
"0",
",",
"'month'",
":",
"1",
",",
"'months'",
":",
"1",
",",
"... | Return the time struct index to use for log rotation checks | [
"Return",
"the",
"time",
"struct",
"index",
"to",
"use",
"for",
"log",
"rotation",
"checks"
] | python | train |
HydrelioxGitHub/pyiss | pyiss/__init__.py | https://github.com/HydrelioxGitHub/pyiss/blob/9e30affa831629be47d6693fad3af6102a3c056d/pyiss/__init__.py#L33-L45 | def current_location(self):
"""Current location of the ISS.
:return: A dict with latitude and longitude of ISS
:rtype: dict
"""
data = requests.get('{}{}'.format(
self.API_URL, self.API_CURRENT_LOCATION), timeout=5)
if data.status_code is 200:
re... | [
"def",
"current_location",
"(",
"self",
")",
":",
"data",
"=",
"requests",
".",
"get",
"(",
"'{}{}'",
".",
"format",
"(",
"self",
".",
"API_URL",
",",
"self",
".",
"API_CURRENT_LOCATION",
")",
",",
"timeout",
"=",
"5",
")",
"if",
"data",
".",
"status_c... | Current location of the ISS.
:return: A dict with latitude and longitude of ISS
:rtype: dict | [
"Current",
"location",
"of",
"the",
"ISS",
"."
] | python | train |
StackStorm/pybind | pybind/slxos/v17s_1_02/mpls_config/router/mpls/mpls_cmds_holder/mpls_interface/rsvp/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17s_1_02/mpls_config/router/mpls/mpls_cmds_holder/mpls_interface/rsvp/__init__.py#L138-L159 | def _set_rsvp_authentication(self, v, load=False):
"""
Setter method for rsvp_authentication, mapped from YANG variable /mpls_config/router/mpls/mpls_cmds_holder/mpls_interface/rsvp/rsvp_authentication (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_rsvp_auth... | [
"def",
"_set_rsvp_authentication",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",... | Setter method for rsvp_authentication, mapped from YANG variable /mpls_config/router/mpls/mpls_cmds_holder/mpls_interface/rsvp/rsvp_authentication (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_rsvp_authentication is considered as a private
method. Backends look... | [
"Setter",
"method",
"for",
"rsvp_authentication",
"mapped",
"from",
"YANG",
"variable",
"/",
"mpls_config",
"/",
"router",
"/",
"mpls",
"/",
"mpls_cmds_holder",
"/",
"mpls_interface",
"/",
"rsvp",
"/",
"rsvp_authentication",
"(",
"container",
")",
"If",
"this",
... | python | train |
plivo/plivohelper-python | plivohelper.py | https://github.com/plivo/plivohelper-python/blob/a2f706d69e2138fbb973f792041341f662072d26/plivohelper.py#L174-L179 | def transfer_call(self, call_params):
"""REST Transfer Live Call Helper
"""
path = '/' + self.api_version + '/TransferCall/'
method = 'POST'
return self.request(path, method, call_params) | [
"def",
"transfer_call",
"(",
"self",
",",
"call_params",
")",
":",
"path",
"=",
"'/'",
"+",
"self",
".",
"api_version",
"+",
"'/TransferCall/'",
"method",
"=",
"'POST'",
"return",
"self",
".",
"request",
"(",
"path",
",",
"method",
",",
"call_params",
")"
... | REST Transfer Live Call Helper | [
"REST",
"Transfer",
"Live",
"Call",
"Helper"
] | python | valid |
frnsys/broca | broca/tokenize/util.py | https://github.com/frnsys/broca/blob/7236dcf54edc0a4a54a55eb93be30800910667e7/broca/tokenize/util.py#L4-L40 | def prune(tdocs):
"""
Prune terms which are totally subsumed by a phrase
This could be better if it just removes the individual keywords
that occur in a phrase for each time that phrase occurs.
"""
all_terms = set([t for toks in tdocs for t in toks])
terms = set()
phrases = set()
fo... | [
"def",
"prune",
"(",
"tdocs",
")",
":",
"all_terms",
"=",
"set",
"(",
"[",
"t",
"for",
"toks",
"in",
"tdocs",
"for",
"t",
"in",
"toks",
"]",
")",
"terms",
"=",
"set",
"(",
")",
"phrases",
"=",
"set",
"(",
")",
"for",
"t",
"in",
"all_terms",
":"... | Prune terms which are totally subsumed by a phrase
This could be better if it just removes the individual keywords
that occur in a phrase for each time that phrase occurs. | [
"Prune",
"terms",
"which",
"are",
"totally",
"subsumed",
"by",
"a",
"phrase"
] | python | train |
caktus/django-timepiece | setup.py | https://github.com/caktus/django-timepiece/blob/52515dec027664890efbc535429e1ba1ee152f40/setup.py#L4-L7 | def _is_requirement(line):
"""Returns whether the line is a valid package requirement."""
line = line.strip()
return line and not (line.startswith("-r") or line.startswith("#")) | [
"def",
"_is_requirement",
"(",
"line",
")",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
"return",
"line",
"and",
"not",
"(",
"line",
".",
"startswith",
"(",
"\"-r\"",
")",
"or",
"line",
".",
"startswith",
"(",
"\"#\"",
")",
")"
] | Returns whether the line is a valid package requirement. | [
"Returns",
"whether",
"the",
"line",
"is",
"a",
"valid",
"package",
"requirement",
"."
] | python | train |
coldfix/udiskie | udiskie/dbus.py | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/dbus.py#L26-L50 | async def call(proxy, method_name, signature, args, flags=0, timeout_msec=-1):
"""
Asynchronously call the specified method on a DBus proxy object.
:param Gio.DBusProxy proxy:
:param str method_name:
:param str signature:
:param tuple args:
:param int flags:
:param int timeout_msec:
... | [
"async",
"def",
"call",
"(",
"proxy",
",",
"method_name",
",",
"signature",
",",
"args",
",",
"flags",
"=",
"0",
",",
"timeout_msec",
"=",
"-",
"1",
")",
":",
"future",
"=",
"Future",
"(",
")",
"cancellable",
"=",
"None",
"proxy",
".",
"call",
"(",
... | Asynchronously call the specified method on a DBus proxy object.
:param Gio.DBusProxy proxy:
:param str method_name:
:param str signature:
:param tuple args:
:param int flags:
:param int timeout_msec: | [
"Asynchronously",
"call",
"the",
"specified",
"method",
"on",
"a",
"DBus",
"proxy",
"object",
"."
] | python | train |
ambitioninc/python-logentries-api | logentries_api/resources.py | https://github.com/ambitioninc/python-logentries-api/blob/77ff1a7a2995d7ea2725b74e34c0f880f4ee23bc/logentries_api/resources.py#L254-L273 | def list(self):
"""
Get all current tags
:return: All tags
:rtype: list of dict
:raises: This will raise a
:class:`ServerException<logentries_api.exceptions.ServerException>`
if there is an error from Logentries
"""
return list(
... | [
"def",
"list",
"(",
"self",
")",
":",
"return",
"list",
"(",
"filter",
"(",
"lambda",
"x",
":",
"x",
".",
"get",
"(",
"'type'",
")",
"==",
"'tagit'",
",",
"# pragma: no cover",
"self",
".",
"_post",
"(",
"request",
"=",
"ApiActions",
".",
"LIST",
"."... | Get all current tags
:return: All tags
:rtype: list of dict
:raises: This will raise a
:class:`ServerException<logentries_api.exceptions.ServerException>`
if there is an error from Logentries | [
"Get",
"all",
"current",
"tags"
] | python | test |
curious-containers/cc-core | cc_core/commons/cwl.py | https://github.com/curious-containers/cc-core/blob/eaeb03a4366016aff54fcc6953d052ae12ed599b/cc_core/commons/cwl.py#L223-L244 | def parse_cwl_type(cwl_type_string):
"""
Parses cwl type information from a cwl type string.
Examples:
- "File[]" -> {'type': 'File', 'isArray': True, 'isOptional': False}
- "int?" -> {'type': 'int', 'isArray': False, 'isOptional': True}
:param cwl_type_string: The cwl type string to extract ... | [
"def",
"parse_cwl_type",
"(",
"cwl_type_string",
")",
":",
"is_optional",
"=",
"cwl_type_string",
".",
"endswith",
"(",
"'?'",
")",
"if",
"is_optional",
":",
"cwl_type_string",
"=",
"cwl_type_string",
"[",
":",
"-",
"1",
"]",
"is_array",
"=",
"cwl_type_string",
... | Parses cwl type information from a cwl type string.
Examples:
- "File[]" -> {'type': 'File', 'isArray': True, 'isOptional': False}
- "int?" -> {'type': 'int', 'isArray': False, 'isOptional': True}
:param cwl_type_string: The cwl type string to extract information from
:return: A dictionary contai... | [
"Parses",
"cwl",
"type",
"information",
"from",
"a",
"cwl",
"type",
"string",
"."
] | python | train |
mitsei/dlkit | dlkit/handcar/repository/objects.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/repository/objects.py#L1098-L1118 | def set_published_date(self, published_date=None):
"""Sets the published date.
:param published_date: the new published date
:type published_date: ``osid.calendaring.DateTime``
:raise: ``InvalidArgument`` -- ``published_date`` is invalid
:raise: ``NoAccess`` -- ``Metadata.isRead... | [
"def",
"set_published_date",
"(",
"self",
",",
"published_date",
"=",
"None",
")",
":",
"if",
"published_date",
"is",
"None",
":",
"raise",
"NullArgument",
"(",
")",
"metadata",
"=",
"Metadata",
"(",
"*",
"*",
"settings",
".",
"METADATA",
"[",
"'published_da... | Sets the published date.
:param published_date: the new published date
:type published_date: ``osid.calendaring.DateTime``
:raise: ``InvalidArgument`` -- ``published_date`` is invalid
:raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` is ``true``
:raise: ``NullArgument`` -- ``pub... | [
"Sets",
"the",
"published",
"date",
"."
] | python | train |
juju/python-libjuju | juju/client/connector.py | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/connector.py#L52-L68 | async def connect(self, **kwargs):
"""Connect to an arbitrary Juju model.
kwargs are passed through to Connection.connect()
"""
kwargs.setdefault('loop', self.loop)
kwargs.setdefault('max_frame_size', self.max_frame_size)
kwargs.setdefault('bakery_client', self.bakery_cl... | [
"async",
"def",
"connect",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'loop'",
",",
"self",
".",
"loop",
")",
"kwargs",
".",
"setdefault",
"(",
"'max_frame_size'",
",",
"self",
".",
"max_frame_size",
")",
"kwargs",... | Connect to an arbitrary Juju model.
kwargs are passed through to Connection.connect() | [
"Connect",
"to",
"an",
"arbitrary",
"Juju",
"model",
"."
] | python | train |
Chilipp/psyplot | psyplot/data.py | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L3599-L3612 | def _get_dsnames(cls, data, ignore_keys=['attrs', 'plotter', 'ds'],
concat_dim=False):
"""Recursive method to get all the file names out of a dictionary
`data` created with the :meth`array_info` method"""
def filter_ignores(item):
return item[0] not in ignore_key... | [
"def",
"_get_dsnames",
"(",
"cls",
",",
"data",
",",
"ignore_keys",
"=",
"[",
"'attrs'",
",",
"'plotter'",
",",
"'ds'",
"]",
",",
"concat_dim",
"=",
"False",
")",
":",
"def",
"filter_ignores",
"(",
"item",
")",
":",
"return",
"item",
"[",
"0",
"]",
"... | Recursive method to get all the file names out of a dictionary
`data` created with the :meth`array_info` method | [
"Recursive",
"method",
"to",
"get",
"all",
"the",
"file",
"names",
"out",
"of",
"a",
"dictionary",
"data",
"created",
"with",
"the",
":",
"meth",
"array_info",
"method"
] | python | train |
inveniosoftware/invenio-communities | invenio_communities/models.py | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/models.py#L286-L304 | def add_record(self, record):
"""Add a record to the community.
:param record: Record object.
:type record: `invenio_records.api.Record`
"""
key = current_app.config['COMMUNITIES_RECORD_KEY']
record.setdefault(key, [])
if self.has_record(record):
cur... | [
"def",
"add_record",
"(",
"self",
",",
"record",
")",
":",
"key",
"=",
"current_app",
".",
"config",
"[",
"'COMMUNITIES_RECORD_KEY'",
"]",
"record",
".",
"setdefault",
"(",
"key",
",",
"[",
"]",
")",
"if",
"self",
".",
"has_record",
"(",
"record",
")",
... | Add a record to the community.
:param record: Record object.
:type record: `invenio_records.api.Record` | [
"Add",
"a",
"record",
"to",
"the",
"community",
"."
] | python | train |
softlayer/softlayer-python | SoftLayer/transports.py | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/transports.py#L544-L558 | def _format_object_mask(objectmask):
"""Format the new style object mask.
This wraps the user mask with mask[USER_MASK] if it does not already
have one. This makes it slightly easier for users.
:param objectmask: a string-based object mask
"""
objectmask = objectmask.strip()
if (not obje... | [
"def",
"_format_object_mask",
"(",
"objectmask",
")",
":",
"objectmask",
"=",
"objectmask",
".",
"strip",
"(",
")",
"if",
"(",
"not",
"objectmask",
".",
"startswith",
"(",
"'mask'",
")",
"and",
"not",
"objectmask",
".",
"startswith",
"(",
"'['",
")",
")",
... | Format the new style object mask.
This wraps the user mask with mask[USER_MASK] if it does not already
have one. This makes it slightly easier for users.
:param objectmask: a string-based object mask | [
"Format",
"the",
"new",
"style",
"object",
"mask",
"."
] | python | train |
timothydmorton/VESPA | vespa/populations.py | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/populations.py#L2516-L2531 | def apply_vcc(self,vcc):
"""
Applies velocity contrast curve constraint to each population
See :func:`vespa.stars.StarPopulation.apply_vcc`;
all arguments passed to that function for each population.
"""
if 'secondary spectrum' not in self.constraints:
self.... | [
"def",
"apply_vcc",
"(",
"self",
",",
"vcc",
")",
":",
"if",
"'secondary spectrum'",
"not",
"in",
"self",
".",
"constraints",
":",
"self",
".",
"constraints",
".",
"append",
"(",
"'secondary spectrum'",
")",
"for",
"pop",
"in",
"self",
".",
"poplist",
":",... | Applies velocity contrast curve constraint to each population
See :func:`vespa.stars.StarPopulation.apply_vcc`;
all arguments passed to that function for each population. | [
"Applies",
"velocity",
"contrast",
"curve",
"constraint",
"to",
"each",
"population"
] | python | train |
Azure/azure-event-hubs-python | azure/eventhub/async_ops/sender_async.py | https://github.com/Azure/azure-event-hubs-python/blob/737c5f966557ada2cf10fa0d8f3c19671ae96348/azure/eventhub/async_ops/sender_async.py#L185-L208 | async def close_async(self, exception=None):
"""
Close down the handler. If the handler has already closed,
this will be a no op. An optional exception can be passed in to
indicate that the handler was shutdown due to error.
:param exception: An optional exception if the handler... | [
"async",
"def",
"close_async",
"(",
"self",
",",
"exception",
"=",
"None",
")",
":",
"self",
".",
"running",
"=",
"False",
"if",
"self",
".",
"error",
":",
"return",
"if",
"isinstance",
"(",
"exception",
",",
"errors",
".",
"LinkRedirect",
")",
":",
"s... | Close down the handler. If the handler has already closed,
this will be a no op. An optional exception can be passed in to
indicate that the handler was shutdown due to error.
:param exception: An optional exception if the handler is closing
due to an error.
:type exception: Ex... | [
"Close",
"down",
"the",
"handler",
".",
"If",
"the",
"handler",
"has",
"already",
"closed",
"this",
"will",
"be",
"a",
"no",
"op",
".",
"An",
"optional",
"exception",
"can",
"be",
"passed",
"in",
"to",
"indicate",
"that",
"the",
"handler",
"was",
"shutdo... | python | train |
ANTsX/ANTsPy | ants/utils/smooth_image.py | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/utils/smooth_image.py#L34-L75 | def smooth_image(image, sigma, sigma_in_physical_coordinates=True, FWHM=False, max_kernel_width=32):
"""
Smooth an image
ANTsR function: `smoothImage`
Arguments
---------
image
Image to smooth
sigma
Smoothing factor. Can be scalar, in which case the same sigma is... | [
"def",
"smooth_image",
"(",
"image",
",",
"sigma",
",",
"sigma_in_physical_coordinates",
"=",
"True",
",",
"FWHM",
"=",
"False",
",",
"max_kernel_width",
"=",
"32",
")",
":",
"if",
"image",
".",
"components",
"==",
"1",
":",
"return",
"_smooth_image_helper",
... | Smooth an image
ANTsR function: `smoothImage`
Arguments
---------
image
Image to smooth
sigma
Smoothing factor. Can be scalar, in which case the same sigma is applied to each dimension, or a vector of length dim(inimage) to specify a unique smoothness for each dimension.... | [
"Smooth",
"an",
"image"
] | python | train |
neptune-ml/steppy-toolkit | toolkit/preprocessing/misc.py | https://github.com/neptune-ml/steppy-toolkit/blob/bf3f48cfcc65dffc46e65ddd5d6cfec6bb9f9132/toolkit/preprocessing/misc.py#L163-L173 | def transform(self, X):
"""
Args:
X: DataFrame with NaN's
Returns:
Dictionary with one key - 'X' corresponding to given DataFrame but without nan's
"""
if self.fill_missing:
X = self.filler.complete(X)
return {'X': X} | [
"def",
"transform",
"(",
"self",
",",
"X",
")",
":",
"if",
"self",
".",
"fill_missing",
":",
"X",
"=",
"self",
".",
"filler",
".",
"complete",
"(",
"X",
")",
"return",
"{",
"'X'",
":",
"X",
"}"
] | Args:
X: DataFrame with NaN's
Returns:
Dictionary with one key - 'X' corresponding to given DataFrame but without nan's | [
"Args",
":",
"X",
":",
"DataFrame",
"with",
"NaN",
"s",
"Returns",
":",
"Dictionary",
"with",
"one",
"key",
"-",
"X",
"corresponding",
"to",
"given",
"DataFrame",
"but",
"without",
"nan",
"s"
] | python | train |
JoelBender/bacpypes | py25/bacpypes/object.py | https://github.com/JoelBender/bacpypes/blob/4111b8604a16fa2b7f80d8104a43b9f3e28dfc78/py25/bacpypes/object.py#L610-L645 | def _dict_contents(self, use_dict=None, as_class=dict):
"""Return the contents of an object as a dict."""
if _debug: Object._debug("dict_contents use_dict=%r as_class=%r", use_dict, as_class)
# make/extend the dictionary of content
if use_dict is None:
use_dict = as_class()
... | [
"def",
"_dict_contents",
"(",
"self",
",",
"use_dict",
"=",
"None",
",",
"as_class",
"=",
"dict",
")",
":",
"if",
"_debug",
":",
"Object",
".",
"_debug",
"(",
"\"dict_contents use_dict=%r as_class=%r\"",
",",
"use_dict",
",",
"as_class",
")",
"# make/extend the ... | Return the contents of an object as a dict. | [
"Return",
"the",
"contents",
"of",
"an",
"object",
"as",
"a",
"dict",
"."
] | python | train |
dlintott/gns3-converter | gns3converter/main.py | https://github.com/dlintott/gns3-converter/blob/acbc55da51de86388dc5b5f6da55809b3c86b7ca/gns3converter/main.py#L219-L292 | def save(output_dir, converter, json_topology, snapshot, quiet):
"""
Save the converted topology
:param str output_dir: Output Directory
:param Converter converter: Converter instance
:param JSONTopology json_topology: JSON topology layout
:param bool snapshot: Is this a snapshot?
:param bo... | [
"def",
"save",
"(",
"output_dir",
",",
"converter",
",",
"json_topology",
",",
"snapshot",
",",
"quiet",
")",
":",
"try",
":",
"old_topology_dir",
"=",
"topology_dirname",
"(",
"converter",
".",
"topology",
")",
"if",
"output_dir",
":",
"output_dir",
"=",
"o... | Save the converted topology
:param str output_dir: Output Directory
:param Converter converter: Converter instance
:param JSONTopology json_topology: JSON topology layout
:param bool snapshot: Is this a snapshot?
:param bool quiet: No console printing | [
"Save",
"the",
"converted",
"topology"
] | python | train |
ArchiveTeam/wpull | wpull/cookie.py | https://github.com/ArchiveTeam/wpull/blob/ddf051aa3322479325ba20aa778cb2cb97606bf5/wpull/cookie.py#L58-L67 | def count_cookies(self, domain):
'''Return the number of cookies for the given domain.'''
cookies = self.cookie_jar._cookies
if domain in cookies:
return sum(
[len(cookie) for cookie in cookies[domain].values()]
)
else:
return 0 | [
"def",
"count_cookies",
"(",
"self",
",",
"domain",
")",
":",
"cookies",
"=",
"self",
".",
"cookie_jar",
".",
"_cookies",
"if",
"domain",
"in",
"cookies",
":",
"return",
"sum",
"(",
"[",
"len",
"(",
"cookie",
")",
"for",
"cookie",
"in",
"cookies",
"[",... | Return the number of cookies for the given domain. | [
"Return",
"the",
"number",
"of",
"cookies",
"for",
"the",
"given",
"domain",
"."
] | python | train |
SuLab/WikidataIntegrator | wikidataintegrator/wdi_helpers/__init__.py | https://github.com/SuLab/WikidataIntegrator/blob/8ceb2ed1c08fec070ec9edfcf7db7b8691481b62/wikidataintegrator/wdi_helpers/__init__.py#L149-L239 | def id_mapper(prop, filters=None, raise_on_duplicate=False, return_as_set=False, prefer_exact_match=False,
endpoint='https://query.wikidata.org/sparql'):
"""
Get all wikidata ID <-> prop <-> value mappings
Example: id_mapper("P352") -> { 'A0KH68': 'Q23429083',
... | [
"def",
"id_mapper",
"(",
"prop",
",",
"filters",
"=",
"None",
",",
"raise_on_duplicate",
"=",
"False",
",",
"return_as_set",
"=",
"False",
",",
"prefer_exact_match",
"=",
"False",
",",
"endpoint",
"=",
"'https://query.wikidata.org/sparql'",
")",
":",
"query",
"=... | Get all wikidata ID <-> prop <-> value mappings
Example: id_mapper("P352") -> { 'A0KH68': 'Q23429083',
'Q5ZWJ4': 'Q22334494',
'Q53WF2': 'Q21766762', .... }
Optional filters can filter query results.
Example (get all uniprot to wdid, w... | [
"Get",
"all",
"wikidata",
"ID",
"<",
"-",
">",
"prop",
"<",
"-",
">",
"value",
"mappings",
"Example",
":",
"id_mapper",
"(",
"P352",
")",
"-",
">",
"{",
"A0KH68",
":",
"Q23429083",
"Q5ZWJ4",
":",
"Q22334494",
"Q53WF2",
":",
"Q21766762",
"....",
"}",
... | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.