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 |
|---|---|---|---|---|---|---|---|---|
bennylope/pygeocodio | geocodio/client.py | https://github.com/bennylope/pygeocodio/blob/4c33d3d34f6b63d4b8fe85fe571ae02b9f67d6c3/geocodio/client.py#L134-L149 | def batch_geocode(self, addresses, **kwargs):
"""
Returns an Address dictionary with the components of the queried
address.
"""
fields = ",".join(kwargs.pop("fields", []))
response = self._req(
"post",
verb="geocode",
params={"fields": ... | [
"def",
"batch_geocode",
"(",
"self",
",",
"addresses",
",",
"*",
"*",
"kwargs",
")",
":",
"fields",
"=",
"\",\"",
".",
"join",
"(",
"kwargs",
".",
"pop",
"(",
"\"fields\"",
",",
"[",
"]",
")",
")",
"response",
"=",
"self",
".",
"_req",
"(",
"\"post... | Returns an Address dictionary with the components of the queried
address. | [
"Returns",
"an",
"Address",
"dictionary",
"with",
"the",
"components",
"of",
"the",
"queried",
"address",
"."
] | python | train |
jaraco/path.py | path/__init__.py | https://github.com/jaraco/path.py/blob/bbe7d99e7a64a004f866ace9ec12bd9b296908f5/path/__init__.py#L1336-L1424 | def in_place(
self, mode='r', buffering=-1, encoding=None, errors=None,
newline=None, backup_extension=None,
):
"""
A context in which a file may be re-written in-place with
new content.
Yields a tuple of :samp:`({readable}, {writable})` file
objects,... | [
"def",
"in_place",
"(",
"self",
",",
"mode",
"=",
"'r'",
",",
"buffering",
"=",
"-",
"1",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"None",
",",
"newline",
"=",
"None",
",",
"backup_extension",
"=",
"None",
",",
")",
":",
"import",
"io",
"i... | A context in which a file may be re-written in-place with
new content.
Yields a tuple of :samp:`({readable}, {writable})` file
objects, where `writable` replaces `readable`.
If an exception occurs, the old file is restored, removing the
written data.
Mode *must not* us... | [
"A",
"context",
"in",
"which",
"a",
"file",
"may",
"be",
"re",
"-",
"written",
"in",
"-",
"place",
"with",
"new",
"content",
"."
] | python | train |
tcalmant/ipopo | pelix/rsa/__init__.py | https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/rsa/__init__.py#L1513-L1527 | def get_dot_properties(prefix, props, remove_prefix):
# type: (str, Dict[str, Any], bool) -> Dict[str, Any]
"""
Gets the properties starting with the given prefix
"""
result_props = {}
if props:
dot_keys = [x for x in props.keys() if x.startswith(prefix + ".")]
for dot_key in dot... | [
"def",
"get_dot_properties",
"(",
"prefix",
",",
"props",
",",
"remove_prefix",
")",
":",
"# type: (str, Dict[str, Any], bool) -> Dict[str, Any]",
"result_props",
"=",
"{",
"}",
"if",
"props",
":",
"dot_keys",
"=",
"[",
"x",
"for",
"x",
"in",
"props",
".",
"keys... | Gets the properties starting with the given prefix | [
"Gets",
"the",
"properties",
"starting",
"with",
"the",
"given",
"prefix"
] | python | train |
ARMmbed/icetea | icetea_lib/cloud.py | https://github.com/ARMmbed/icetea/blob/b2b97ac607429830cf7d62dae2e3903692c7c778/icetea_lib/cloud.py#L224-L241 | def _resolve_host(self): # pylint: disable=no-self-use
"""
Resolve cloud provider host name. Defaults to environment variables
OPENTMI_ADDRESS_PRIVATE or OPENTMI_ADDRESS_PUBLIC if environment variable NODE_NAME
starts with 'aws'. Otherwise gets ICETEA_CLOUD_HOST environment variable OR
... | [
"def",
"_resolve_host",
"(",
"self",
")",
":",
"# pylint: disable=no-self-use",
"node_name",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'NODE_NAME'",
",",
"''",
")",
"if",
"node_name",
".",
"startswith",
"(",
"'aws'",
")",
":",
"_host",
"=",
"os",
".",
... | Resolve cloud provider host name. Defaults to environment variables
OPENTMI_ADDRESS_PRIVATE or OPENTMI_ADDRESS_PUBLIC if environment variable NODE_NAME
starts with 'aws'. Otherwise gets ICETEA_CLOUD_HOST environment variable OR
localhost:3000 if that one does not exist.
:return: Cloud ho... | [
"Resolve",
"cloud",
"provider",
"host",
"name",
".",
"Defaults",
"to",
"environment",
"variables",
"OPENTMI_ADDRESS_PRIVATE",
"or",
"OPENTMI_ADDRESS_PUBLIC",
"if",
"environment",
"variable",
"NODE_NAME",
"starts",
"with",
"aws",
".",
"Otherwise",
"gets",
"ICETEA_CLOUD_H... | python | train |
sosy-lab/benchexec | benchexec/util.py | https://github.com/sosy-lab/benchexec/blob/44428f67f41384c03aea13e7e25f884764653617/benchexec/util.py#L109-L113 | def get_list_from_xml(elem, tag="option", attributes=["name"]):
'''
This function searches for all "option"-tags and returns a list with all attributes and texts.
'''
return flatten(([option.get(attr) for attr in attributes] + [option.text] for option in elem.findall(tag)), exclude=[None]) | [
"def",
"get_list_from_xml",
"(",
"elem",
",",
"tag",
"=",
"\"option\"",
",",
"attributes",
"=",
"[",
"\"name\"",
"]",
")",
":",
"return",
"flatten",
"(",
"(",
"[",
"option",
".",
"get",
"(",
"attr",
")",
"for",
"attr",
"in",
"attributes",
"]",
"+",
"... | This function searches for all "option"-tags and returns a list with all attributes and texts. | [
"This",
"function",
"searches",
"for",
"all",
"option",
"-",
"tags",
"and",
"returns",
"a",
"list",
"with",
"all",
"attributes",
"and",
"texts",
"."
] | python | train |
pyblish/pyblish-qml | pyblish_qml/util.py | https://github.com/pyblish/pyblish-qml/blob/6095d18b2ec0afd0409a9b1a17e53b0658887283/pyblish_qml/util.py#L121-L144 | def defer(target, args=None, kwargs=None, callback=None):
"""Perform operation in thread with callback
Instances are cached until finished, at which point
they are garbage collected. If we didn't do this,
Python would step in and garbage collect the thread
before having had time to finish, resultin... | [
"def",
"defer",
"(",
"target",
",",
"args",
"=",
"None",
",",
"kwargs",
"=",
"None",
",",
"callback",
"=",
"None",
")",
":",
"obj",
"=",
"_defer",
"(",
"target",
",",
"args",
",",
"kwargs",
",",
"callback",
")",
"obj",
".",
"finished",
".",
"connec... | Perform operation in thread with callback
Instances are cached until finished, at which point
they are garbage collected. If we didn't do this,
Python would step in and garbage collect the thread
before having had time to finish, resulting in an
exception.
Arguments:
target (callable):... | [
"Perform",
"operation",
"in",
"thread",
"with",
"callback"
] | python | train |
theislab/scanpy | scanpy/readwrite.py | https://github.com/theislab/scanpy/blob/9e4e5ee02e04cf618872d9b098e24f0542e8b227/scanpy/readwrite.py#L188-L214 | def _read_v3_10x_h5(filename):
"""
Read hdf5 file from Cell Ranger v3 or later versions.
"""
with tables.open_file(str(filename), 'r') as f:
try:
dsets = {}
for node in f.walk_nodes('/matrix', 'Array'):
dsets[node.name] = node.read()
from scipy... | [
"def",
"_read_v3_10x_h5",
"(",
"filename",
")",
":",
"with",
"tables",
".",
"open_file",
"(",
"str",
"(",
"filename",
")",
",",
"'r'",
")",
"as",
"f",
":",
"try",
":",
"dsets",
"=",
"{",
"}",
"for",
"node",
"in",
"f",
".",
"walk_nodes",
"(",
"'/mat... | Read hdf5 file from Cell Ranger v3 or later versions. | [
"Read",
"hdf5",
"file",
"from",
"Cell",
"Ranger",
"v3",
"or",
"later",
"versions",
"."
] | python | train |
bcbio/bcbio-nextgen | bcbio/variation/annotation.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/annotation.py#L115-L134 | def _update_header(orig_vcf, base_file, new_lines, chrom_process_fn=None):
"""Fix header with additional lines and remapping of generic sample names.
"""
new_header = "%s-sample_header.txt" % utils.splitext_plus(base_file)[0]
with open(new_header, "w") as out_handle:
chrom_line = None
wi... | [
"def",
"_update_header",
"(",
"orig_vcf",
",",
"base_file",
",",
"new_lines",
",",
"chrom_process_fn",
"=",
"None",
")",
":",
"new_header",
"=",
"\"%s-sample_header.txt\"",
"%",
"utils",
".",
"splitext_plus",
"(",
"base_file",
")",
"[",
"0",
"]",
"with",
"open... | Fix header with additional lines and remapping of generic sample names. | [
"Fix",
"header",
"with",
"additional",
"lines",
"and",
"remapping",
"of",
"generic",
"sample",
"names",
"."
] | python | train |
ministryofjustice/money-to-prisoners-common | mtp_common/auth/middleware.py | https://github.com/ministryofjustice/money-to-prisoners-common/blob/33c43a2912cb990d9148da7c8718f480f07d90a1/mtp_common/auth/middleware.py#L11-L18 | def get_user(request):
"""
Returns a cached copy of the user if it exists or calls `auth_get_user`
otherwise.
"""
if not hasattr(request, '_cached_user'):
request._cached_user = auth_get_user(request)
return request._cached_user | [
"def",
"get_user",
"(",
"request",
")",
":",
"if",
"not",
"hasattr",
"(",
"request",
",",
"'_cached_user'",
")",
":",
"request",
".",
"_cached_user",
"=",
"auth_get_user",
"(",
"request",
")",
"return",
"request",
".",
"_cached_user"
] | Returns a cached copy of the user if it exists or calls `auth_get_user`
otherwise. | [
"Returns",
"a",
"cached",
"copy",
"of",
"the",
"user",
"if",
"it",
"exists",
"or",
"calls",
"auth_get_user",
"otherwise",
"."
] | python | train |
horazont/aioxmpp | aioxmpp/service.py | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/service.py#L1520-L1530 | def is_depsignal_handler(class_, signal_name, cb, *, defer=False):
"""
Return true if `cb` has been decorated with :func:`depsignal` for the given
signal, class and connection mode.
"""
try:
handlers = get_magic_attr(cb)
except AttributeError:
return False
return _depsignal_... | [
"def",
"is_depsignal_handler",
"(",
"class_",
",",
"signal_name",
",",
"cb",
",",
"*",
",",
"defer",
"=",
"False",
")",
":",
"try",
":",
"handlers",
"=",
"get_magic_attr",
"(",
"cb",
")",
"except",
"AttributeError",
":",
"return",
"False",
"return",
"_deps... | Return true if `cb` has been decorated with :func:`depsignal` for the given
signal, class and connection mode. | [
"Return",
"true",
"if",
"cb",
"has",
"been",
"decorated",
"with",
":",
"func",
":",
"depsignal",
"for",
"the",
"given",
"signal",
"class",
"and",
"connection",
"mode",
"."
] | python | train |
saltstack/salt | salt/utils/pkg/win.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/pkg/win.py#L382-L420 | def get_product_value(self, value_name, wanted_type=None):
'''
For the product section of the registry return the name value.
Args:
value_name (str): Registry value name.
wanted_type (str):
The type of value wanted if the type does not match
... | [
"def",
"get_product_value",
"(",
"self",
",",
"value_name",
",",
"wanted_type",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"__reg_products_handle",
":",
"return",
"None",
"subkey",
",",
"search_value_name",
"=",
"os",
".",
"path",
".",
"split",
"(",
... | For the product section of the registry return the name value.
Args:
value_name (str): Registry value name.
wanted_type (str):
The type of value wanted if the type does not match
None is return. wanted_type support values are
``str`` ``int... | [
"For",
"the",
"product",
"section",
"of",
"the",
"registry",
"return",
"the",
"name",
"value",
"."
] | python | train |
senaite/senaite.core | bika/lims/validators.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/validators.py#L1063-L1071 | def _sumLists(a, b):
"""
Algorithm to check validity of NBI and NIF.
Receives string with a umber to validate.
"""
val = 0
for i in map(lambda a, b: a * b, a, b):
val += i
return val | [
"def",
"_sumLists",
"(",
"a",
",",
"b",
")",
":",
"val",
"=",
"0",
"for",
"i",
"in",
"map",
"(",
"lambda",
"a",
",",
"b",
":",
"a",
"*",
"b",
",",
"a",
",",
"b",
")",
":",
"val",
"+=",
"i",
"return",
"val"
] | Algorithm to check validity of NBI and NIF.
Receives string with a umber to validate. | [
"Algorithm",
"to",
"check",
"validity",
"of",
"NBI",
"and",
"NIF",
".",
"Receives",
"string",
"with",
"a",
"umber",
"to",
"validate",
"."
] | python | train |
pyblish/pyblish-qml | pyblish_qml/models.py | https://github.com/pyblish/pyblish-qml/blob/6095d18b2ec0afd0409a9b1a17e53b0658887283/pyblish_qml/models.py#L830-L840 | def _remove_rule(self, group, role, value=None):
"""Implementation detail"""
if role not in group:
return
if value is None:
group.pop(role, None)
else:
group[role].remove(value)
self.invalidate() | [
"def",
"_remove_rule",
"(",
"self",
",",
"group",
",",
"role",
",",
"value",
"=",
"None",
")",
":",
"if",
"role",
"not",
"in",
"group",
":",
"return",
"if",
"value",
"is",
"None",
":",
"group",
".",
"pop",
"(",
"role",
",",
"None",
")",
"else",
"... | Implementation detail | [
"Implementation",
"detail"
] | python | train |
FujiMakoto/AgentML | agentml/parser/trigger/__init__.py | https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/parser/trigger/__init__.py#L190-L205 | def _add_response(self, response, weight=1):
"""
Add a new trigger
:param response: The Response object
:type response: Response or Condition
:param weight: The weight of the response
:type weight: int
"""
# If no response with this priority level has b... | [
"def",
"_add_response",
"(",
"self",
",",
"response",
",",
"weight",
"=",
"1",
")",
":",
"# If no response with this priority level has been defined yet, create a new list",
"if",
"response",
".",
"priority",
"not",
"in",
"self",
".",
"_responses",
":",
"self",
".",
... | Add a new trigger
:param response: The Response object
:type response: Response or Condition
:param weight: The weight of the response
:type weight: int | [
"Add",
"a",
"new",
"trigger",
":",
"param",
"response",
":",
"The",
"Response",
"object",
":",
"type",
"response",
":",
"Response",
"or",
"Condition"
] | python | train |
Asana/python-asana | asana/resources/gen/teams.py | https://github.com/Asana/python-asana/blob/6deb7a34495db23f44858e53b6bb2c9eccff7872/asana/resources/gen/teams.py#L10-L19 | def find_by_id(self, team, params={}, **options):
"""Returns the full record for a single team.
Parameters
----------
team : {Id} Globally unique identifier for the team.
[params] : {Object} Parameters for the request
"""
path = "/teams/%s" % (team)
retu... | [
"def",
"find_by_id",
"(",
"self",
",",
"team",
",",
"params",
"=",
"{",
"}",
",",
"*",
"*",
"options",
")",
":",
"path",
"=",
"\"/teams/%s\"",
"%",
"(",
"team",
")",
"return",
"self",
".",
"client",
".",
"get",
"(",
"path",
",",
"params",
",",
"*... | Returns the full record for a single team.
Parameters
----------
team : {Id} Globally unique identifier for the team.
[params] : {Object} Parameters for the request | [
"Returns",
"the",
"full",
"record",
"for",
"a",
"single",
"team",
"."
] | python | train |
ashleysommer/sanicpluginsframework | spf/plugins/contextualize.py | https://github.com/ashleysommer/sanicpluginsframework/blob/2cb1656d9334f04c30c738074784b0450c1b893e/spf/plugins/contextualize.py#L173-L194 | def middleware(self, *args, **kwargs):
"""Decorate and register middleware
:param args: captures all of the positional arguments passed in
:type args: tuple(Any)
:param kwargs: captures the keyword arguments passed in
:type kwargs: dict(Any)
:return: The middleware functi... | [
"def",
"middleware",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'priority'",
",",
"5",
")",
"kwargs",
".",
"setdefault",
"(",
"'relative'",
",",
"None",
")",
"kwargs",
".",
"setdefault",
"(",
... | Decorate and register middleware
:param args: captures all of the positional arguments passed in
:type args: tuple(Any)
:param kwargs: captures the keyword arguments passed in
:type kwargs: dict(Any)
:return: The middleware function to use as the decorator
:rtype: fn | [
"Decorate",
"and",
"register",
"middleware",
":",
"param",
"args",
":",
"captures",
"all",
"of",
"the",
"positional",
"arguments",
"passed",
"in",
":",
"type",
"args",
":",
"tuple",
"(",
"Any",
")",
":",
"param",
"kwargs",
":",
"captures",
"the",
"keyword"... | python | train |
bitesofcode/projex | projex/xmlutil.py | https://github.com/bitesofcode/projex/blob/d31743ec456a41428709968ab11a2cf6c6c76247/projex/xmlutil.py#L388-L405 | def save(self, data, xparent=None):
"""
Parses the element from XML to Python.
:param data | <variant>
xparent | <xml.etree.ElementTree.Element> || None
:return <xml.etree.ElementTree.Element>
"""
if xparent is not None:
... | [
"def",
"save",
"(",
"self",
",",
"data",
",",
"xparent",
"=",
"None",
")",
":",
"if",
"xparent",
"is",
"not",
"None",
":",
"elem",
"=",
"ElementTree",
".",
"SubElement",
"(",
"xparent",
",",
"'list'",
")",
"else",
":",
"elem",
"=",
"ElementTree",
"."... | Parses the element from XML to Python.
:param data | <variant>
xparent | <xml.etree.ElementTree.Element> || None
:return <xml.etree.ElementTree.Element> | [
"Parses",
"the",
"element",
"from",
"XML",
"to",
"Python",
".",
":",
"param",
"data",
"|",
"<variant",
">",
"xparent",
"|",
"<xml",
".",
"etree",
".",
"ElementTree",
".",
"Element",
">",
"||",
"None",
":",
"return",
"<xml",
".",
"etree",
".",
"ElementT... | python | train |
projectatomic/atomic-reactor | atomic_reactor/plugins/pre_resolve_composes.py | https://github.com/projectatomic/atomic-reactor/blob/fd31c01b964097210bf169960d051e5f04019a80/atomic_reactor/plugins/pre_resolve_composes.py#L131-L148 | def adjust_for_autorebuild(self):
"""Ignore pre-filled signing_intent and compose_ids for autorebuids
Auto rebuilds are expected to use a known configuration. The parameters
signing_intent and compose_ids are meant for one-off build calls. This
method ensure that these parameters are ig... | [
"def",
"adjust_for_autorebuild",
"(",
"self",
")",
":",
"if",
"not",
"is_rebuild",
"(",
"self",
".",
"workflow",
")",
":",
"return",
"if",
"self",
".",
"signing_intent",
":",
"self",
".",
"log",
".",
"info",
"(",
"'Autorebuild detected: Ignoring signing_intent p... | Ignore pre-filled signing_intent and compose_ids for autorebuids
Auto rebuilds are expected to use a known configuration. The parameters
signing_intent and compose_ids are meant for one-off build calls. This
method ensure that these parameters are ignored for autorebuilds. | [
"Ignore",
"pre",
"-",
"filled",
"signing_intent",
"and",
"compose_ids",
"for",
"autorebuids"
] | python | train |
sixpack/sixpack | sixpack/models.py | https://github.com/sixpack/sixpack/blob/fec044a35eea79dd7b9af73fafe1b7d15f1d9ef8/sixpack/models.py#L629-L656 | def record_participation(self, client, dt=None):
"""Record a user's participation in a test along with a given variation"""
if dt is None:
date = datetime.now()
else:
date = dt
experiment_key = self.experiment.name
pipe = self.redis.pipeline()
p... | [
"def",
"record_participation",
"(",
"self",
",",
"client",
",",
"dt",
"=",
"None",
")",
":",
"if",
"dt",
"is",
"None",
":",
"date",
"=",
"datetime",
".",
"now",
"(",
")",
"else",
":",
"date",
"=",
"dt",
"experiment_key",
"=",
"self",
".",
"experiment... | Record a user's participation in a test along with a given variation | [
"Record",
"a",
"user",
"s",
"participation",
"in",
"a",
"test",
"along",
"with",
"a",
"given",
"variation"
] | python | train |
googleapis/google-auth-library-python | google/oauth2/_client.py | https://github.com/googleapis/google-auth-library-python/blob/2c6ad78917e936f38f87c946209c8031166dc96e/google/oauth2/_client.py#L159-L201 | def id_token_jwt_grant(request, token_uri, assertion):
"""Implements the JWT Profile for OAuth 2.0 Authorization Grants, but
requests an OpenID Connect ID Token instead of an access token.
This is a variant on the standard JWT Profile that is currently unique
to Google. This was added for the benefit o... | [
"def",
"id_token_jwt_grant",
"(",
"request",
",",
"token_uri",
",",
"assertion",
")",
":",
"body",
"=",
"{",
"'assertion'",
":",
"assertion",
",",
"'grant_type'",
":",
"_JWT_GRANT_TYPE",
",",
"}",
"response_data",
"=",
"_token_endpoint_request",
"(",
"request",
... | Implements the JWT Profile for OAuth 2.0 Authorization Grants, but
requests an OpenID Connect ID Token instead of an access token.
This is a variant on the standard JWT Profile that is currently unique
to Google. This was added for the benefit of authenticating to services
that require ID Tokens instea... | [
"Implements",
"the",
"JWT",
"Profile",
"for",
"OAuth",
"2",
".",
"0",
"Authorization",
"Grants",
"but",
"requests",
"an",
"OpenID",
"Connect",
"ID",
"Token",
"instead",
"of",
"an",
"access",
"token",
"."
] | python | train |
apache/incubator-mxnet | example/multivariate_time_series/src/metrics.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/multivariate_time_series/src/metrics.py#L31-L35 | def rae(label, pred):
"""computes the relative absolute error (condensed using standard deviation formula)"""
numerator = np.mean(np.abs(label - pred), axis=None)
denominator = np.mean(np.abs(label - np.mean(label, axis=None)), axis=None)
return numerator / denominator | [
"def",
"rae",
"(",
"label",
",",
"pred",
")",
":",
"numerator",
"=",
"np",
".",
"mean",
"(",
"np",
".",
"abs",
"(",
"label",
"-",
"pred",
")",
",",
"axis",
"=",
"None",
")",
"denominator",
"=",
"np",
".",
"mean",
"(",
"np",
".",
"abs",
"(",
"... | computes the relative absolute error (condensed using standard deviation formula) | [
"computes",
"the",
"relative",
"absolute",
"error",
"(",
"condensed",
"using",
"standard",
"deviation",
"formula",
")"
] | python | train |
assamite/creamas | creamas/grid.py | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/grid.py#L203-L222 | def add_to_grid(self, agent):
'''Add agent to the next available spot in the grid.
:returns:
(x,y) of the agent in the grid. This is the agent's overall
coordinate in the grand grid (i.e. the actual coordinate of the
agent w.t.r **origin**).
:raises: `ValueE... | [
"def",
"add_to_grid",
"(",
"self",
",",
"agent",
")",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"grid",
")",
")",
":",
"for",
"j",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"grid",
"[",
"0",
"]",
")",
")",
":",
"if",
... | Add agent to the next available spot in the grid.
:returns:
(x,y) of the agent in the grid. This is the agent's overall
coordinate in the grand grid (i.e. the actual coordinate of the
agent w.t.r **origin**).
:raises: `ValueError` if the grid is full. | [
"Add",
"agent",
"to",
"the",
"next",
"available",
"spot",
"in",
"the",
"grid",
"."
] | python | train |
sendgrid/sendgrid-python | sendgrid/helpers/mail/mail.py | https://github.com/sendgrid/sendgrid-python/blob/266c2abde7a35dfcce263e06bedc6a0bbdebeac9/sendgrid/helpers/mail/mail.py#L702-L712 | def content(self, contents):
"""The content(s) of the email
:param contents: The content(s) of the email
:type contents: Content, list(Content)
"""
if isinstance(contents, list):
for c in contents:
self.add_content(c)
else:
self.ad... | [
"def",
"content",
"(",
"self",
",",
"contents",
")",
":",
"if",
"isinstance",
"(",
"contents",
",",
"list",
")",
":",
"for",
"c",
"in",
"contents",
":",
"self",
".",
"add_content",
"(",
"c",
")",
"else",
":",
"self",
".",
"add_content",
"(",
"content... | The content(s) of the email
:param contents: The content(s) of the email
:type contents: Content, list(Content) | [
"The",
"content",
"(",
"s",
")",
"of",
"the",
"email"
] | python | train |
ssato/python-anyconfig | src/anyconfig/backend/xml.py | https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/xml.py#L240-L264 | def _process_children_elems(elem, dic, subdic, container=dict,
children="@children", **options):
"""
:param elem: ET Element object or None
:param dic: <container> (dict[-like]) object converted from elem
:param subdic: Sub <container> object converted from elem
:param co... | [
"def",
"_process_children_elems",
"(",
"elem",
",",
"dic",
",",
"subdic",
",",
"container",
"=",
"dict",
",",
"children",
"=",
"\"@children\"",
",",
"*",
"*",
"options",
")",
":",
"cdics",
"=",
"[",
"elem_to_container",
"(",
"c",
",",
"container",
"=",
"... | :param elem: ET Element object or None
:param dic: <container> (dict[-like]) object converted from elem
:param subdic: Sub <container> object converted from elem
:param container: callble to make a container object
:param children: Tag for children nodes
:param options:
Keyword options, see ... | [
":",
"param",
"elem",
":",
"ET",
"Element",
"object",
"or",
"None",
":",
"param",
"dic",
":",
"<container",
">",
"(",
"dict",
"[",
"-",
"like",
"]",
")",
"object",
"converted",
"from",
"elem",
":",
"param",
"subdic",
":",
"Sub",
"<container",
">",
"o... | python | train |
Duke-GCB/DukeDSClient | ddsc/core/fileuploader.py | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/fileuploader.py#L140-L155 | def create_upload_and_chunk_url(self, project_id, path_data, hash_data, remote_filename=None,
storage_provider_id=None):
"""
Create an non-chunked upload that returns upload id and upload url. This type of upload doesn't allow
additional upload urls. For singl... | [
"def",
"create_upload_and_chunk_url",
"(",
"self",
",",
"project_id",
",",
"path_data",
",",
"hash_data",
",",
"remote_filename",
"=",
"None",
",",
"storage_provider_id",
"=",
"None",
")",
":",
"upload_response",
"=",
"self",
".",
"_create_upload",
"(",
"project_i... | Create an non-chunked upload that returns upload id and upload url. This type of upload doesn't allow
additional upload urls. For single chunk files this method is more efficient than
create_upload/create_file_chunk_url.
:param project_id: str: uuid of the project
:param path_data: PathD... | [
"Create",
"an",
"non",
"-",
"chunked",
"upload",
"that",
"returns",
"upload",
"id",
"and",
"upload",
"url",
".",
"This",
"type",
"of",
"upload",
"doesn",
"t",
"allow",
"additional",
"upload",
"urls",
".",
"For",
"single",
"chunk",
"files",
"this",
"method"... | python | train |
bwohlberg/sporco | sporco/dictlrn/onlinecdl.py | https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/dictlrn/onlinecdl.py#L546-L567 | def xstep(self, S, W, lmbda, dimK):
"""Solve CSC problem for training data `S`."""
if self.opt['CUDA_CBPDN']:
Z = cuda.cbpdnmsk(self.D.squeeze(), S[..., 0], W.squeeze(), lmbda,
self.opt['CBPDN'])
Z = Z.reshape(self.cri.Nv + (1, 1, self.cri.M,))
... | [
"def",
"xstep",
"(",
"self",
",",
"S",
",",
"W",
",",
"lmbda",
",",
"dimK",
")",
":",
"if",
"self",
".",
"opt",
"[",
"'CUDA_CBPDN'",
"]",
":",
"Z",
"=",
"cuda",
".",
"cbpdnmsk",
"(",
"self",
".",
"D",
".",
"squeeze",
"(",
")",
",",
"S",
"[",
... | Solve CSC problem for training data `S`. | [
"Solve",
"CSC",
"problem",
"for",
"training",
"data",
"S",
"."
] | python | train |
dslackw/slpkg | slpkg/auto_pkg.py | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/auto_pkg.py#L46-L72 | def select(self):
"""Select Slackware command
"""
print("\nDetected Slackware binary package for installation:\n")
for pkg in self.packages:
print(" " + pkg.split("/")[-1])
print("")
self.msg.template(78)
print("| Choose a Slackware command:")
... | [
"def",
"select",
"(",
"self",
")",
":",
"print",
"(",
"\"\\nDetected Slackware binary package for installation:\\n\"",
")",
"for",
"pkg",
"in",
"self",
".",
"packages",
":",
"print",
"(",
"\" \"",
"+",
"pkg",
".",
"split",
"(",
"\"/\"",
")",
"[",
"-",
"1",
... | Select Slackware command | [
"Select",
"Slackware",
"command"
] | python | train |
krukas/Trionyx | trionyx/models.py | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/models.py#L60-L69 | def get_fields(cls, inlcude_base=False, include_id=False):
"""Get model fields"""
for field in cls._meta.fields:
if field.name == 'deleted':
continue
if not include_id and field.name == 'id':
continue
if not inlcude_base and field.name ... | [
"def",
"get_fields",
"(",
"cls",
",",
"inlcude_base",
"=",
"False",
",",
"include_id",
"=",
"False",
")",
":",
"for",
"field",
"in",
"cls",
".",
"_meta",
".",
"fields",
":",
"if",
"field",
".",
"name",
"==",
"'deleted'",
":",
"continue",
"if",
"not",
... | Get model fields | [
"Get",
"model",
"fields"
] | python | train |
McSwindler/python-milight | milight/white.py | https://github.com/McSwindler/python-milight/blob/4891b1d7d6a720901a27a64f7b0d0c208f0c291f/milight/white.py#L87-L95 | def warmness(level=100, group=0):
""" Assumes level is out of 100 """
if level not in range(0,101):
raise Exception("Warmness must be value between 0 and 100")
b = int(floor(level / 10.0)) #lights have 10 levels of warmness
commands = list(coolest(group))
for i in range(0, b):
comman... | [
"def",
"warmness",
"(",
"level",
"=",
"100",
",",
"group",
"=",
"0",
")",
":",
"if",
"level",
"not",
"in",
"range",
"(",
"0",
",",
"101",
")",
":",
"raise",
"Exception",
"(",
"\"Warmness must be value between 0 and 100\"",
")",
"b",
"=",
"int",
"(",
"f... | Assumes level is out of 100 | [
"Assumes",
"level",
"is",
"out",
"of",
"100"
] | python | valid |
Erotemic/utool | utool/util_profile.py | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_profile.py#L141-L170 | def get_summary(profile_block_list, maxlines=20):
"""
References:
https://github.com/rkern/line_profiler
"""
time_list = [get_block_totaltime(block) for block in profile_block_list]
time_list = [time if time is not None else -1 for time in time_list]
blockid_list = [get_block_id(block) f... | [
"def",
"get_summary",
"(",
"profile_block_list",
",",
"maxlines",
"=",
"20",
")",
":",
"time_list",
"=",
"[",
"get_block_totaltime",
"(",
"block",
")",
"for",
"block",
"in",
"profile_block_list",
"]",
"time_list",
"=",
"[",
"time",
"if",
"time",
"is",
"not",... | References:
https://github.com/rkern/line_profiler | [
"References",
":",
"https",
":",
"//",
"github",
".",
"com",
"/",
"rkern",
"/",
"line_profiler"
] | python | train |
googleapis/oauth2client | oauth2client/contrib/appengine.py | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/appengine.py#L757-L810 | def callback_handler(self):
"""RequestHandler for the OAuth 2.0 redirect callback.
Usage::
app = webapp.WSGIApplication([
('/index', MyIndexHandler),
...,
(decorator.callback_path, decorator.callback_handler())
])
Returns... | [
"def",
"callback_handler",
"(",
"self",
")",
":",
"decorator",
"=",
"self",
"class",
"OAuth2Handler",
"(",
"webapp",
".",
"RequestHandler",
")",
":",
"\"\"\"Handler for the redirect_uri of the OAuth 2.0 dance.\"\"\"",
"@",
"login_required",
"def",
"get",
"(",
"self",
... | RequestHandler for the OAuth 2.0 redirect callback.
Usage::
app = webapp.WSGIApplication([
('/index', MyIndexHandler),
...,
(decorator.callback_path, decorator.callback_handler())
])
Returns:
A webapp.RequestHandler t... | [
"RequestHandler",
"for",
"the",
"OAuth",
"2",
".",
"0",
"redirect",
"callback",
"."
] | python | valid |
ambitioninc/django-query-builder | querybuilder/query.py | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L596-L614 | def init_defaults(self):
"""
Sets the default values for this instance
"""
self.sql = ''
self.tables = []
self.joins = []
self._where = Where()
self.groups = []
self.sorters = []
self._limit = None
self.table_prefix = ''
sel... | [
"def",
"init_defaults",
"(",
"self",
")",
":",
"self",
".",
"sql",
"=",
"''",
"self",
".",
"tables",
"=",
"[",
"]",
"self",
".",
"joins",
"=",
"[",
"]",
"self",
".",
"_where",
"=",
"Where",
"(",
")",
"self",
".",
"groups",
"=",
"[",
"]",
"self"... | Sets the default values for this instance | [
"Sets",
"the",
"default",
"values",
"for",
"this",
"instance"
] | python | train |
taborlab/FlowCal | FlowCal/transform.py | https://github.com/taborlab/FlowCal/blob/031a7af82acb1d46879a8e384a1a00f27f0bdc7a/FlowCal/transform.py#L22-L79 | def transform(data, channels, transform_fxn, def_channels = None):
"""
Apply some transformation function to flow cytometry data.
This function is a template transformation function, intended to be
used by other specific transformation functions. It performs basic
checks on `channels` and `data`. I... | [
"def",
"transform",
"(",
"data",
",",
"channels",
",",
"transform_fxn",
",",
"def_channels",
"=",
"None",
")",
":",
"# Copy data array",
"data_t",
"=",
"data",
".",
"copy",
"(",
")",
".",
"astype",
"(",
"np",
".",
"float64",
")",
"# Default",
"if",
"chan... | Apply some transformation function to flow cytometry data.
This function is a template transformation function, intended to be
used by other specific transformation functions. It performs basic
checks on `channels` and `data`. It then applies `transform_fxn` to the
specified channels. Finally, it resca... | [
"Apply",
"some",
"transformation",
"function",
"to",
"flow",
"cytometry",
"data",
"."
] | python | train |
openstack/quark | quark/tools/async_worker.py | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/tools/async_worker.py#L115-L125 | def start_api_and_rpc_workers(self):
"""Initializes eventlet and starts wait for workers to exit.
Spawns the workers returned from serve_rpc
"""
pool = eventlet.GreenPool()
quark_rpc = self.serve_rpc()
pool.spawn(quark_rpc.wait)
pool.waitall() | [
"def",
"start_api_and_rpc_workers",
"(",
"self",
")",
":",
"pool",
"=",
"eventlet",
".",
"GreenPool",
"(",
")",
"quark_rpc",
"=",
"self",
".",
"serve_rpc",
"(",
")",
"pool",
".",
"spawn",
"(",
"quark_rpc",
".",
"wait",
")",
"pool",
".",
"waitall",
"(",
... | Initializes eventlet and starts wait for workers to exit.
Spawns the workers returned from serve_rpc | [
"Initializes",
"eventlet",
"and",
"starts",
"wait",
"for",
"workers",
"to",
"exit",
"."
] | python | valid |
shreyaspotnis/rampage | rampage/server.py | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/server.py#L616-L626 | def get_digital_channels(channel_list):
"""Goes through channel list and returns digital channels with ids
Dev1/port0/line08, Dev1/port0/line09... Dev1/port0/line30."""
dig_ids = digital_channel_ids()
dig_channels = []
for ln in dig_ids:
for ch in channel_list:
if ch.dct['id'] ==... | [
"def",
"get_digital_channels",
"(",
"channel_list",
")",
":",
"dig_ids",
"=",
"digital_channel_ids",
"(",
")",
"dig_channels",
"=",
"[",
"]",
"for",
"ln",
"in",
"dig_ids",
":",
"for",
"ch",
"in",
"channel_list",
":",
"if",
"ch",
".",
"dct",
"[",
"'id'",
... | Goes through channel list and returns digital channels with ids
Dev1/port0/line08, Dev1/port0/line09... Dev1/port0/line30. | [
"Goes",
"through",
"channel",
"list",
"and",
"returns",
"digital",
"channels",
"with",
"ids",
"Dev1",
"/",
"port0",
"/",
"line08",
"Dev1",
"/",
"port0",
"/",
"line09",
"...",
"Dev1",
"/",
"port0",
"/",
"line30",
"."
] | python | train |
andrewsnowden/dota2py | dota2py/parser.py | https://github.com/andrewsnowden/dota2py/blob/67637f4b9c160ea90c11b7e81545baf350affa7a/dota2py/parser.py#L100-L115 | def read_vint32(self):
"""
This seems to be a variable length integer ala utf-8 style
"""
result = 0
count = 0
while True:
if count > 4:
raise ValueError("Corrupt VarInt32")
b = self.read_byte()
result = result | (b & 0... | [
"def",
"read_vint32",
"(",
"self",
")",
":",
"result",
"=",
"0",
"count",
"=",
"0",
"while",
"True",
":",
"if",
"count",
">",
"4",
":",
"raise",
"ValueError",
"(",
"\"Corrupt VarInt32\"",
")",
"b",
"=",
"self",
".",
"read_byte",
"(",
")",
"result",
"... | This seems to be a variable length integer ala utf-8 style | [
"This",
"seems",
"to",
"be",
"a",
"variable",
"length",
"integer",
"ala",
"utf",
"-",
"8",
"style"
] | python | train |
deepmind/sonnet | sonnet/python/modules/block_matrix.py | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/block_matrix.py#L182-L185 | def _content_blocks(self, r):
"""Number of content blocks in block row `r`."""
return (self._block_rows - self._left_zero_blocks(r)
- self._right_zero_blocks(r)) | [
"def",
"_content_blocks",
"(",
"self",
",",
"r",
")",
":",
"return",
"(",
"self",
".",
"_block_rows",
"-",
"self",
".",
"_left_zero_blocks",
"(",
"r",
")",
"-",
"self",
".",
"_right_zero_blocks",
"(",
"r",
")",
")"
] | Number of content blocks in block row `r`. | [
"Number",
"of",
"content",
"blocks",
"in",
"block",
"row",
"r",
"."
] | python | train |
avihad/twistes | twistes/client.py | https://github.com/avihad/twistes/blob/9ab8f5aa088b8886aefe3dec85a400e5035e034a/twistes/client.py#L348-L377 | def index(self, index, doc_type, body, id=None, **query_params):
"""
Adds or updates a typed JSON document in a specific index, making it searchable.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html>`_
:param index: The name of the index
:param d... | [
"def",
"index",
"(",
"self",
",",
"index",
",",
"doc_type",
",",
"body",
",",
"id",
"=",
"None",
",",
"*",
"*",
"query_params",
")",
":",
"self",
".",
"_es_parser",
".",
"is_not_empty_params",
"(",
"index",
",",
"doc_type",
",",
"body",
")",
"method",
... | Adds or updates a typed JSON document in a specific index, making it searchable.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html>`_
:param index: The name of the index
:param doc_type: The type of the document
:param body: The document
:param id... | [
"Adds",
"or",
"updates",
"a",
"typed",
"JSON",
"document",
"in",
"a",
"specific",
"index",
"making",
"it",
"searchable",
".",
"<http",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference",
"/",
"c... | python | train |
synw/dataswim | dataswim/data/transform/columns.py | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/transform/columns.py#L80-L97 | def drop(self, *cols):
"""
Drops columns from the main dataframe
:param cols: names of the columns
:type cols: str
:example: ``ds.drop("Col 1", "Col 2")``
"""
try:
index = self.df.columns.values
for col in cols:
if col not... | [
"def",
"drop",
"(",
"self",
",",
"*",
"cols",
")",
":",
"try",
":",
"index",
"=",
"self",
".",
"df",
".",
"columns",
".",
"values",
"for",
"col",
"in",
"cols",
":",
"if",
"col",
"not",
"in",
"index",
":",
"self",
".",
"warning",
"(",
"\"Column\""... | Drops columns from the main dataframe
:param cols: names of the columns
:type cols: str
:example: ``ds.drop("Col 1", "Col 2")`` | [
"Drops",
"columns",
"from",
"the",
"main",
"dataframe"
] | python | train |
vinu76jsr/pipsort | setup.py | https://github.com/vinu76jsr/pipsort/blob/71ead1269de85ee0255741390bf1da85d81b7d16/setup.py#L49-L56 | def version():
""" Get the local package version.
"""
path = join("lib", _CONFIG["name"], "__version__.py")
with open(path) as stream:
exec(stream.read())
return __version__ | [
"def",
"version",
"(",
")",
":",
"path",
"=",
"join",
"(",
"\"lib\"",
",",
"_CONFIG",
"[",
"\"name\"",
"]",
",",
"\"__version__.py\"",
")",
"with",
"open",
"(",
"path",
")",
"as",
"stream",
":",
"exec",
"(",
"stream",
".",
"read",
"(",
")",
")",
"r... | Get the local package version. | [
"Get",
"the",
"local",
"package",
"version",
"."
] | python | train |
rbuffat/pyepw | pyepw/epw.py | https://github.com/rbuffat/pyepw/blob/373d4d3c8386c8d35789f086ac5f6018c2711745/pyepw/epw.py#L1940-L1960 | def wb010(self, value=None):
""" Corresponds to IDD Field `wb010`
Wet-bulb temperature corresponding to 1.0% annual cumulative frequency of occurrence
Args:
value (float): value for IDD Field `wb010`
Unit: C
if `value` is None it will not be checked ... | [
"def",
"wb010",
"(",
"self",
",",
"value",
"=",
"None",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"try",
":",
"value",
"=",
"float",
"(",
"value",
")",
"except",
"ValueError",
":",
"raise",
"ValueError",
"(",
"'value {} need to be of type float '"... | Corresponds to IDD Field `wb010`
Wet-bulb temperature corresponding to 1.0% annual cumulative frequency of occurrence
Args:
value (float): value for IDD Field `wb010`
Unit: C
if `value` is None it will not be checked against the
specification ... | [
"Corresponds",
"to",
"IDD",
"Field",
"wb010",
"Wet",
"-",
"bulb",
"temperature",
"corresponding",
"to",
"1",
".",
"0%",
"annual",
"cumulative",
"frequency",
"of",
"occurrence"
] | python | train |
MacHu-GWU/constant2-project | constant2/_constant2.py | https://github.com/MacHu-GWU/constant2-project/blob/ccf7e14b0e23f9f4bfd13a3e2ce4a1142e570d4f/constant2/_constant2.py#L77-L103 | def Items(cls):
"""non-class attributes ordered by alphabetical order.
::
>>> class MyClass(Constant):
... a = 1 # non-class attributre
... b = 2 # non-class attributre
...
... class C(Constant):
... pass
... | [
"def",
"Items",
"(",
"cls",
")",
":",
"l",
"=",
"list",
"(",
")",
"for",
"attr",
",",
"value",
"in",
"get_all_attributes",
"(",
"cls",
")",
":",
"# if it's not a class(Constant)",
"if",
"not",
"inspect",
".",
"isclass",
"(",
"value",
")",
":",
"l",
"."... | non-class attributes ordered by alphabetical order.
::
>>> class MyClass(Constant):
... a = 1 # non-class attributre
... b = 2 # non-class attributre
...
... class C(Constant):
... pass
...
... ... | [
"non",
"-",
"class",
"attributes",
"ordered",
"by",
"alphabetical",
"order",
"."
] | python | train |
rootpy/rootpy | rootpy/plotting/style/lhcb/labels.py | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/style/lhcb/labels.py#L17-L61 | def LHCb_label(side="L", status="final", text="", pad=None):
"""Add an 'LHCb (Preliminary|Unofficial)' label to the current pad."""
if pad is None:
pad = ROOT.gPad
with preserve_current_canvas():
pad.cd()
if side == "L":
l = ROOT.TPaveText(pad.GetLeftMargin() + 0.05,
... | [
"def",
"LHCb_label",
"(",
"side",
"=",
"\"L\"",
",",
"status",
"=",
"\"final\"",
",",
"text",
"=",
"\"\"",
",",
"pad",
"=",
"None",
")",
":",
"if",
"pad",
"is",
"None",
":",
"pad",
"=",
"ROOT",
".",
"gPad",
"with",
"preserve_current_canvas",
"(",
")"... | Add an 'LHCb (Preliminary|Unofficial)' label to the current pad. | [
"Add",
"an",
"LHCb",
"(",
"Preliminary|Unofficial",
")",
"label",
"to",
"the",
"current",
"pad",
"."
] | python | train |
yyuu/botornado | boto/__init__.py | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/__init__.py#L264-L276 | def connect_emr(aws_access_key_id=None, aws_secret_access_key=None, **kwargs):
"""
:type aws_access_key_id: string
:param aws_access_key_id: Your AWS Access Key ID
:type aws_secret_access_key: string
:param aws_secret_access_key: Your AWS Secret Access Key
:rtype: :class:`boto.emr.EmrConnectio... | [
"def",
"connect_emr",
"(",
"aws_access_key_id",
"=",
"None",
",",
"aws_secret_access_key",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"boto",
".",
"emr",
"import",
"EmrConnection",
"return",
"EmrConnection",
"(",
"aws_access_key_id",
",",
"aws_secre... | :type aws_access_key_id: string
:param aws_access_key_id: Your AWS Access Key ID
:type aws_secret_access_key: string
:param aws_secret_access_key: Your AWS Secret Access Key
:rtype: :class:`boto.emr.EmrConnection`
:return: A connection to Elastic mapreduce | [
":",
"type",
"aws_access_key_id",
":",
"string",
":",
"param",
"aws_access_key_id",
":",
"Your",
"AWS",
"Access",
"Key",
"ID"
] | python | train |
za-creature/gulpless | gulpless/handlers.py | https://github.com/za-creature/gulpless/blob/fd73907dbe86880086719816bb042233f85121f6/gulpless/handlers.py#L128-L132 | def build(self, input_path, output_paths):
"""Should be extended by subclasses to actually do stuff. By default
this will copy `input` over every file in the `outputs` list."""
for output in output_paths:
shutil.copy(input_path, output_paths) | [
"def",
"build",
"(",
"self",
",",
"input_path",
",",
"output_paths",
")",
":",
"for",
"output",
"in",
"output_paths",
":",
"shutil",
".",
"copy",
"(",
"input_path",
",",
"output_paths",
")"
] | Should be extended by subclasses to actually do stuff. By default
this will copy `input` over every file in the `outputs` list. | [
"Should",
"be",
"extended",
"by",
"subclasses",
"to",
"actually",
"do",
"stuff",
".",
"By",
"default",
"this",
"will",
"copy",
"input",
"over",
"every",
"file",
"in",
"the",
"outputs",
"list",
"."
] | python | train |
wadda/gps3 | gps3/gps3threaded.py | https://github.com/wadda/gps3/blob/91adcd7073b891b135b2a46d039ce2125cf09a09/gps3/gps3threaded.py#L48-L58 | def run_thread(self, usnap=.2, daemon=True):
"""run thread with data
"""
# self.stream_data() # Unless other changes are made this would limit to localhost only.
try:
gps3_data_thread = Thread(target=self.unpack_data, args={usnap: usnap}, daemon=daemon)
except TypeErr... | [
"def",
"run_thread",
"(",
"self",
",",
"usnap",
"=",
".2",
",",
"daemon",
"=",
"True",
")",
":",
"# self.stream_data() # Unless other changes are made this would limit to localhost only.",
"try",
":",
"gps3_data_thread",
"=",
"Thread",
"(",
"target",
"=",
"self",
".",... | run thread with data | [
"run",
"thread",
"with",
"data"
] | python | train |
klmitch/bark | bark/format.py | https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/format.py#L82-L96 | def add_text(self, end, next=None):
"""
Adds the text from string beginning to the specified ending
index to the format.
:param end: The ending index of the string.
:param next: The next string begin index. If None, the string
index will not be updated.
... | [
"def",
"add_text",
"(",
"self",
",",
"end",
",",
"next",
"=",
"None",
")",
":",
"if",
"self",
".",
"str_begin",
"!=",
"end",
":",
"self",
".",
"fmt",
".",
"append_text",
"(",
"self",
".",
"format",
"[",
"self",
".",
"str_begin",
":",
"end",
"]",
... | Adds the text from string beginning to the specified ending
index to the format.
:param end: The ending index of the string.
:param next: The next string begin index. If None, the string
index will not be updated. | [
"Adds",
"the",
"text",
"from",
"string",
"beginning",
"to",
"the",
"specified",
"ending",
"index",
"to",
"the",
"format",
"."
] | python | train |
HDI-Project/BTB | btb/tuning/tuner.py | https://github.com/HDI-Project/BTB/blob/7f489ebc5591bd0886652ef743098c022d7f7460/btb/tuning/tuner.py#L52-L60 | def fit(self, X, y):
"""Fit
Args:
X (np.array): Array of hyperparameter values with shape (n_samples, len(tunables))
y (np.array): Array of scores with shape (n_samples, )
"""
self.X = X
self.y = y | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
")",
":",
"self",
".",
"X",
"=",
"X",
"self",
".",
"y",
"=",
"y"
] | Fit
Args:
X (np.array): Array of hyperparameter values with shape (n_samples, len(tunables))
y (np.array): Array of scores with shape (n_samples, ) | [
"Fit"
] | python | train |
fabioz/PyDev.Debugger | _pydevd_bundle/pydevconsole_code_for_ironpython.py | https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydevd_bundle/pydevconsole_code_for_ironpython.py#L343-L364 | def showtraceback(self, *args, **kwargs):
"""Display the exception that just occurred.
We remove the first stack item because it is our own code.
The output is written by self.write(), below.
"""
try:
type, value, tb = sys.exc_info()
sys.last_type = typ... | [
"def",
"showtraceback",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"type",
",",
"value",
",",
"tb",
"=",
"sys",
".",
"exc_info",
"(",
")",
"sys",
".",
"last_type",
"=",
"type",
"sys",
".",
"last_value",
"=",
"va... | Display the exception that just occurred.
We remove the first stack item because it is our own code.
The output is written by self.write(), below. | [
"Display",
"the",
"exception",
"that",
"just",
"occurred",
"."
] | python | train |
anthill/koala | koala/ast/__init__.py | https://github.com/anthill/koala/blob/393089fe081380506e73235db18a32b4e078d222/koala/ast/__init__.py#L358-L386 | def cell2code(cell, named_ranges):
"""Generate python code for the given cell"""
if cell.formula:
debug = False
# if 'OFFSET' in cell.formula or 'INDEX' in cell.formula:
# debug = True
# if debug:
# print 'FORMULA', cell.formula
ref = parse_cell_address(... | [
"def",
"cell2code",
"(",
"cell",
",",
"named_ranges",
")",
":",
"if",
"cell",
".",
"formula",
":",
"debug",
"=",
"False",
"# if 'OFFSET' in cell.formula or 'INDEX' in cell.formula:",
"# debug = True",
"# if debug:",
"# print 'FORMULA', cell.formula",
"ref",
"=",
"... | Generate python code for the given cell | [
"Generate",
"python",
"code",
"for",
"the",
"given",
"cell"
] | python | train |
heuer/cablemap | cablemap.tm/cablemap/tm/handler.py | https://github.com/heuer/cablemap/blob/42066c8fc2972d237a2c35578e14525aaf705f38/cablemap.tm/cablemap/tm/handler.py#L264-L281 | def _handle_recipient(self, typ, recipient):
"""\
"""
route, name, precedence, mcn = recipient.route, recipient.name, recipient.precedence, recipient.mcn
if not name:
return
h = self._handler
h.startAssociation(typ)
h.role(psis.CABLE_TYPE, self._cable... | [
"def",
"_handle_recipient",
"(",
"self",
",",
"typ",
",",
"recipient",
")",
":",
"route",
",",
"name",
",",
"precedence",
",",
"mcn",
"=",
"recipient",
".",
"route",
",",
"recipient",
".",
"name",
",",
"recipient",
".",
"precedence",
",",
"recipient",
".... | \ | [
"\\"
] | python | train |
tradenity/python-sdk | tradenity/resources/refund_transaction.py | https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/refund_transaction.py#L454-L474 | def get_refund_transaction_by_id(cls, refund_transaction_id, **kwargs):
"""Find RefundTransaction
Return single instance of RefundTransaction by its ID.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thre... | [
"def",
"get_refund_transaction_by_id",
"(",
"cls",
",",
"refund_transaction_id",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'async'",
")",
":",
"return",
"cls",
".",
"_get... | Find RefundTransaction
Return single instance of RefundTransaction by its ID.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.get_refund_transaction_by_id(refund_transaction_id, async=True)
>>... | [
"Find",
"RefundTransaction"
] | python | train |
ramrod-project/database-brain | schema/brain/queries/reads.py | https://github.com/ramrod-project/database-brain/blob/b024cb44f34cabb9d80af38271ddb65c25767083/schema/brain/queries/reads.py#L21-L44 | def _jobs_cursor(plugin_name, location=None, port=None, custom=None):
"""
generates a reql cursor for plugin_name
with status ready
and prepares to sort by StartTime
:param plugin_name:
:param location:
:param port:
:return:
"""
cur = RBJ.get_all(READY, index=STATUS_FIELD)
cu... | [
"def",
"_jobs_cursor",
"(",
"plugin_name",
",",
"location",
"=",
"None",
",",
"port",
"=",
"None",
",",
"custom",
"=",
"None",
")",
":",
"cur",
"=",
"RBJ",
".",
"get_all",
"(",
"READY",
",",
"index",
"=",
"STATUS_FIELD",
")",
"cur_filter",
"=",
"(",
... | generates a reql cursor for plugin_name
with status ready
and prepares to sort by StartTime
:param plugin_name:
:param location:
:param port:
:return: | [
"generates",
"a",
"reql",
"cursor",
"for",
"plugin_name",
"with",
"status",
"ready",
"and",
"prepares",
"to",
"sort",
"by",
"StartTime",
":",
"param",
"plugin_name",
":",
":",
"param",
"location",
":",
":",
"param",
"port",
":",
":",
"return",
":"
] | python | train |
vaexio/vaex | packages/vaex-core/vaex/ext/readcol.py | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/ext/readcol.py#L270-L281 | def readff(s,format):
"""
Fixed-format reader
Pass in a single line string (s) and a format list,
which needs to be a python list of string lengths
"""
F = numpy.array([0]+format).cumsum()
bothF = zip(F[:-1],F[1:])
strarr = [s[l:u] for l,u in bothF]
return strarr | [
"def",
"readff",
"(",
"s",
",",
"format",
")",
":",
"F",
"=",
"numpy",
".",
"array",
"(",
"[",
"0",
"]",
"+",
"format",
")",
".",
"cumsum",
"(",
")",
"bothF",
"=",
"zip",
"(",
"F",
"[",
":",
"-",
"1",
"]",
",",
"F",
"[",
"1",
":",
"]",
... | Fixed-format reader
Pass in a single line string (s) and a format list,
which needs to be a python list of string lengths | [
"Fixed",
"-",
"format",
"reader",
"Pass",
"in",
"a",
"single",
"line",
"string",
"(",
"s",
")",
"and",
"a",
"format",
"list",
"which",
"needs",
"to",
"be",
"a",
"python",
"list",
"of",
"string",
"lengths"
] | python | test |
stevearc/dql | dql/engine.py | https://github.com/stevearc/dql/blob/e9d3aa22873076dae5ebd02e35318aa996b1e56a/dql/engine.py#L974-L992 | def execute(self, fragment, pretty_format=True):
"""
Run or aggregate a query fragment
Concat the fragment to any stored fragments. If they form a complete
query, run it and return the result. If not, store them and return
None.
"""
self.fragments = (self.fragme... | [
"def",
"execute",
"(",
"self",
",",
"fragment",
",",
"pretty_format",
"=",
"True",
")",
":",
"self",
".",
"fragments",
"=",
"(",
"self",
".",
"fragments",
"+",
"\"\\n\"",
"+",
"fragment",
")",
".",
"lstrip",
"(",
")",
"try",
":",
"line_parser",
".",
... | Run or aggregate a query fragment
Concat the fragment to any stored fragments. If they form a complete
query, run it and return the result. If not, store them and return
None. | [
"Run",
"or",
"aggregate",
"a",
"query",
"fragment"
] | python | train |
agoragames/kairos | kairos/mongo_backend.py | https://github.com/agoragames/kairos/blob/0b062d543b0f4a46df460fa0eb6ec281232ab179/kairos/mongo_backend.py#L127-L150 | def _batch_insert(self, inserts, intervals, **kwargs):
'''
Batch insert implementation.
'''
updates = {}
# TODO support flush interval
for interval,config in self._intervals.items():
for timestamp,names in inserts.iteritems():
timestamps = self._normalize_timestamps(timestamp, inte... | [
"def",
"_batch_insert",
"(",
"self",
",",
"inserts",
",",
"intervals",
",",
"*",
"*",
"kwargs",
")",
":",
"updates",
"=",
"{",
"}",
"# TODO support flush interval",
"for",
"interval",
",",
"config",
"in",
"self",
".",
"_intervals",
".",
"items",
"(",
")",
... | Batch insert implementation. | [
"Batch",
"insert",
"implementation",
"."
] | python | train |
Nachtfeuer/pipeline | spline/components/bash.py | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/components/bash.py#L138-L145 | def render_bash_options(self):
"""Rendering Bash options."""
options = ''
if self.config.debug:
options += "set -x\n"
if self.config.strict:
options += "set -euo pipefail\n"
return options | [
"def",
"render_bash_options",
"(",
"self",
")",
":",
"options",
"=",
"''",
"if",
"self",
".",
"config",
".",
"debug",
":",
"options",
"+=",
"\"set -x\\n\"",
"if",
"self",
".",
"config",
".",
"strict",
":",
"options",
"+=",
"\"set -euo pipefail\\n\"",
"return... | Rendering Bash options. | [
"Rendering",
"Bash",
"options",
"."
] | python | train |
roclark/sportsreference | sportsreference/ncaaf/conferences.py | https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaaf/conferences.py#L73-L103 | def _find_conference_teams(self, conference_abbreviation, year):
"""
Retrieve the teams in the conference for the requested season.
Find and retrieve all teams that participated in a conference for a
given season. The name and abbreviation for each team are parsed and
recorded t... | [
"def",
"_find_conference_teams",
"(",
"self",
",",
"conference_abbreviation",
",",
"year",
")",
":",
"if",
"not",
"year",
":",
"year",
"=",
"utils",
".",
"_find_year_for_season",
"(",
"'ncaaf'",
")",
"page",
"=",
"self",
".",
"_pull_conference_page",
"(",
"con... | Retrieve the teams in the conference for the requested season.
Find and retrieve all teams that participated in a conference for a
given season. The name and abbreviation for each team are parsed and
recorded to enable easy queries of conference schools..
Parameters
----------
... | [
"Retrieve",
"the",
"teams",
"in",
"the",
"conference",
"for",
"the",
"requested",
"season",
"."
] | python | train |
fozzle/python-brotherprint | brotherprint/brotherprint.py | https://github.com/fozzle/python-brotherprint/blob/5fb92df11b599c30a7da3d6ac7ed60acff230044/brotherprint/brotherprint.py#L62-L73 | def initialize(self):
'''Calling this function initializes the printer.
Args:
None
Returns:
None
Raises:
None
'''
self.fonttype = self.font_types['bitmap']
self.send(chr(27)+chr(64)) | [
"def",
"initialize",
"(",
"self",
")",
":",
"self",
".",
"fonttype",
"=",
"self",
".",
"font_types",
"[",
"'bitmap'",
"]",
"self",
".",
"send",
"(",
"chr",
"(",
"27",
")",
"+",
"chr",
"(",
"64",
")",
")"
] | Calling this function initializes the printer.
Args:
None
Returns:
None
Raises:
None | [
"Calling",
"this",
"function",
"initializes",
"the",
"printer",
".",
"Args",
":",
"None",
"Returns",
":",
"None",
"Raises",
":",
"None"
] | python | train |
cdriehuys/django-rest-email-auth | rest_email_auth/serializers.py | https://github.com/cdriehuys/django-rest-email-auth/blob/7e752c4d77ae02d2d046f214f56e743aa12ab23f/rest_email_auth/serializers.py#L297-L313 | def validate_key(self, key):
"""
Validate the provided reset key.
Returns:
The validated key.
Raises:
serializers.ValidationError:
If the provided key does not exist.
"""
if not models.PasswordResetToken.valid_tokens.filter(key=ke... | [
"def",
"validate_key",
"(",
"self",
",",
"key",
")",
":",
"if",
"not",
"models",
".",
"PasswordResetToken",
".",
"valid_tokens",
".",
"filter",
"(",
"key",
"=",
"key",
")",
".",
"exists",
"(",
")",
":",
"raise",
"serializers",
".",
"ValidationError",
"("... | Validate the provided reset key.
Returns:
The validated key.
Raises:
serializers.ValidationError:
If the provided key does not exist. | [
"Validate",
"the",
"provided",
"reset",
"key",
"."
] | python | valid |
explosion/spaCy | spacy/pipeline/functions.py | https://github.com/explosion/spaCy/blob/8ee4100f8ffb336886208a1ea827bf4c745e2709/spacy/pipeline/functions.py#L24-L36 | def merge_entities(doc):
"""Merge entities into a single token.
doc (Doc): The Doc object.
RETURNS (Doc): The Doc object with merged entities.
DOCS: https://spacy.io/api/pipeline-functions#merge_entities
"""
with doc.retokenize() as retokenizer:
for ent in doc.ents:
attrs =... | [
"def",
"merge_entities",
"(",
"doc",
")",
":",
"with",
"doc",
".",
"retokenize",
"(",
")",
"as",
"retokenizer",
":",
"for",
"ent",
"in",
"doc",
".",
"ents",
":",
"attrs",
"=",
"{",
"\"tag\"",
":",
"ent",
".",
"root",
".",
"tag",
",",
"\"dep\"",
":"... | Merge entities into a single token.
doc (Doc): The Doc object.
RETURNS (Doc): The Doc object with merged entities.
DOCS: https://spacy.io/api/pipeline-functions#merge_entities | [
"Merge",
"entities",
"into",
"a",
"single",
"token",
"."
] | python | train |
keon/algorithms | algorithms/tree/bst/kth_smallest.py | https://github.com/keon/algorithms/blob/4d6569464a62a75c1357acc97e2dd32ee2f9f4a3/algorithms/tree/bst/kth_smallest.py#L24-L32 | def kth_smallest(self, root, k):
"""
:type root: TreeNode
:type k: int
:rtype: int
"""
count = []
self.helper(root, count)
return count[k-1] | [
"def",
"kth_smallest",
"(",
"self",
",",
"root",
",",
"k",
")",
":",
"count",
"=",
"[",
"]",
"self",
".",
"helper",
"(",
"root",
",",
"count",
")",
"return",
"count",
"[",
"k",
"-",
"1",
"]"
] | :type root: TreeNode
:type k: int
:rtype: int | [
":",
"type",
"root",
":",
"TreeNode",
":",
"type",
"k",
":",
"int",
":",
"rtype",
":",
"int"
] | python | train |
tensorflow/datasets | tensorflow_datasets/core/features/feature.py | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/features/feature.py#L468-L490 | def encode_example(self, example_dict):
"""See base class for details."""
# Flatten dict matching the tf-example features
# Use NonMutableDict to ensure there is no collision between features keys
tfexample_dict = utils.NonMutableDict()
# Iterate over example fields
for feature_key, (feature, e... | [
"def",
"encode_example",
"(",
"self",
",",
"example_dict",
")",
":",
"# Flatten dict matching the tf-example features",
"# Use NonMutableDict to ensure there is no collision between features keys",
"tfexample_dict",
"=",
"utils",
".",
"NonMutableDict",
"(",
")",
"# Iterate over exa... | See base class for details. | [
"See",
"base",
"class",
"for",
"details",
"."
] | python | train |
xiaocong/uiautomator | uiautomator/__init__.py | https://github.com/xiaocong/uiautomator/blob/9a0c892ffd056713f91aa2153d1533c5b0553a1c/uiautomator/__init__.py#L963-L976 | def drag(self):
'''
Drag the ui object to other point or ui object.
Usage:
d(text="Clock").drag.to(x=100, y=100) # drag to point (x,y)
d(text="Clock").drag.to(text="Remove") # drag to another object
'''
def to(obj, *args, **kwargs):
if len(args) >= 2 ... | [
"def",
"drag",
"(",
"self",
")",
":",
"def",
"to",
"(",
"obj",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"args",
")",
">=",
"2",
"or",
"\"x\"",
"in",
"kwargs",
"or",
"\"y\"",
"in",
"kwargs",
":",
"drag_to",
"=",
"... | Drag the ui object to other point or ui object.
Usage:
d(text="Clock").drag.to(x=100, y=100) # drag to point (x,y)
d(text="Clock").drag.to(text="Remove") # drag to another object | [
"Drag",
"the",
"ui",
"object",
"to",
"other",
"point",
"or",
"ui",
"object",
".",
"Usage",
":",
"d",
"(",
"text",
"=",
"Clock",
")",
".",
"drag",
".",
"to",
"(",
"x",
"=",
"100",
"y",
"=",
"100",
")",
"#",
"drag",
"to",
"point",
"(",
"x",
"y"... | python | train |
lepture/safe | safe/__init__.py | https://github.com/lepture/safe/blob/038a72e59557caf97c1b93f66124a8f014eb032b/safe/__init__.py#L142-L185 | def check(raw, length=8, freq=0, min_types=3, level=STRONG):
"""Check the safety level of the password.
:param raw: raw text password.
:param length: minimal length of the password.
:param freq: minimum frequency.
:param min_types: minimum character family.
:param level: minimum level to valida... | [
"def",
"check",
"(",
"raw",
",",
"length",
"=",
"8",
",",
"freq",
"=",
"0",
",",
"min_types",
"=",
"3",
",",
"level",
"=",
"STRONG",
")",
":",
"raw",
"=",
"to_unicode",
"(",
"raw",
")",
"if",
"level",
">",
"STRONG",
":",
"level",
"=",
"STRONG",
... | Check the safety level of the password.
:param raw: raw text password.
:param length: minimal length of the password.
:param freq: minimum frequency.
:param min_types: minimum character family.
:param level: minimum level to validate a password. | [
"Check",
"the",
"safety",
"level",
"of",
"the",
"password",
"."
] | python | train |
kootenpv/yagmail | yagmail/validate.py | https://github.com/kootenpv/yagmail/blob/b8873299ce682193eef43314aa214e553c2b67cb/yagmail/validate.py#L100-L113 | def validate_email_with_regex(email_address):
"""
Note that this will only filter out syntax mistakes in emailaddresses.
If a human would think it is probably a valid email, it will most likely pass.
However, it could still very well be that the actual emailaddress has simply
not be claimed by anyon... | [
"def",
"validate_email_with_regex",
"(",
"email_address",
")",
":",
"if",
"not",
"re",
".",
"match",
"(",
"VALID_ADDRESS_REGEXP",
",",
"email_address",
")",
":",
"emsg",
"=",
"'Emailaddress \"{}\" is not valid according to RFC 2822 standards'",
".",
"format",
"(",
"emai... | Note that this will only filter out syntax mistakes in emailaddresses.
If a human would think it is probably a valid email, it will most likely pass.
However, it could still very well be that the actual emailaddress has simply
not be claimed by anyone (so then this function fails to devalidate). | [
"Note",
"that",
"this",
"will",
"only",
"filter",
"out",
"syntax",
"mistakes",
"in",
"emailaddresses",
".",
"If",
"a",
"human",
"would",
"think",
"it",
"is",
"probably",
"a",
"valid",
"email",
"it",
"will",
"most",
"likely",
"pass",
".",
"However",
"it",
... | python | train |
spacetelescope/stsci.tools | lib/stsci/tools/swapgeis.py | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/swapgeis.py#L92-L515 | def byteswap(input,output=None,clobber=True):
"""Input GEIS files "input" will be read and converted to a new GEIS file
whose byte-order has been swapped from its original state.
Parameters
----------
input - str
Full filename with path of input GEIS image header file
output - str
... | [
"def",
"byteswap",
"(",
"input",
",",
"output",
"=",
"None",
",",
"clobber",
"=",
"True",
")",
":",
"global",
"dat",
"cardLen",
"=",
"fits",
".",
"Card",
".",
"length",
"# input file(s) must be of the form *.??h and *.??d",
"if",
"input",
"[",
"-",
"1",
"]",... | Input GEIS files "input" will be read and converted to a new GEIS file
whose byte-order has been swapped from its original state.
Parameters
----------
input - str
Full filename with path of input GEIS image header file
output - str
Full filename with path of output GEIS image head... | [
"Input",
"GEIS",
"files",
"input",
"will",
"be",
"read",
"and",
"converted",
"to",
"a",
"new",
"GEIS",
"file",
"whose",
"byte",
"-",
"order",
"has",
"been",
"swapped",
"from",
"its",
"original",
"state",
"."
] | python | train |
michael-lazar/rtv | rtv/packages/praw/objects.py | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/objects.py#L1232-L1245 | def comments(self): # pylint: disable=E0202
"""Return forest of comments, with top-level comments as tree roots.
May contain instances of MoreComment objects. To easily replace these
objects with Comment objects, use the replace_more_comments method then
fetch this attribute. Use comme... | [
"def",
"comments",
"(",
"self",
")",
":",
"# pylint: disable=E0202",
"if",
"self",
".",
"_comments",
"is",
"None",
":",
"self",
".",
"comments",
"=",
"Submission",
".",
"from_url",
"(",
"# pylint: disable=W0212",
"self",
".",
"reddit_session",
",",
"self",
"."... | Return forest of comments, with top-level comments as tree roots.
May contain instances of MoreComment objects. To easily replace these
objects with Comment objects, use the replace_more_comments method then
fetch this attribute. Use comment replies to walk down the tree. To get
an unne... | [
"Return",
"forest",
"of",
"comments",
"with",
"top",
"-",
"level",
"comments",
"as",
"tree",
"roots",
"."
] | python | train |
devricks/soft_drf | soft_drf/api/viewsets/__init__.py | https://github.com/devricks/soft_drf/blob/1869b13f9341bfcebd931059e93de2bc38570da3/soft_drf/api/viewsets/__init__.py#L11-L19 | def get_serializer_class(self, action=None):
"""
Return the serializer class depending on request method.
Attribute of proper serializer should be defined.
"""
if action is not None:
return getattr(self, '%s_serializer_class' % action)
else:
return... | [
"def",
"get_serializer_class",
"(",
"self",
",",
"action",
"=",
"None",
")",
":",
"if",
"action",
"is",
"not",
"None",
":",
"return",
"getattr",
"(",
"self",
",",
"'%s_serializer_class'",
"%",
"action",
")",
"else",
":",
"return",
"super",
"(",
"GenericVie... | Return the serializer class depending on request method.
Attribute of proper serializer should be defined. | [
"Return",
"the",
"serializer",
"class",
"depending",
"on",
"request",
"method",
".",
"Attribute",
"of",
"proper",
"serializer",
"should",
"be",
"defined",
"."
] | python | train |
macacajs/wd.py | macaca/util.py | https://github.com/macacajs/wd.py/blob/6d3c52060013e01a67cd52b68b5230b387427bad/macaca/util.py#L152-L180 | def value_to_key_strokes(value):
"""Convert value to a list of key strokes
>>> value_to_key_strokes(123)
['123']
>>> value_to_key_strokes('123')
['123']
>>> value_to_key_strokes([1, 2, 3])
['123']
>>> value_to_key_strokes(['1', '2', '3'])
['123']
Args:
value(int|str|list... | [
"def",
"value_to_key_strokes",
"(",
"value",
")",
":",
"result",
"=",
"''",
"if",
"isinstance",
"(",
"value",
",",
"Integral",
")",
":",
"value",
"=",
"str",
"(",
"value",
")",
"for",
"v",
"in",
"value",
":",
"if",
"isinstance",
"(",
"v",
",",
"Keys"... | Convert value to a list of key strokes
>>> value_to_key_strokes(123)
['123']
>>> value_to_key_strokes('123')
['123']
>>> value_to_key_strokes([1, 2, 3])
['123']
>>> value_to_key_strokes(['1', '2', '3'])
['123']
Args:
value(int|str|list)
Returns:
A list of string... | [
"Convert",
"value",
"to",
"a",
"list",
"of",
"key",
"strokes",
">>>",
"value_to_key_strokes",
"(",
"123",
")",
"[",
"123",
"]",
">>>",
"value_to_key_strokes",
"(",
"123",
")",
"[",
"123",
"]",
">>>",
"value_to_key_strokes",
"(",
"[",
"1",
"2",
"3",
"]",
... | python | valid |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/convert/ArrayConverter.py | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/convert/ArrayConverter.py#L23-L41 | def to_nullable_array(value):
"""
Converts value into array object.
Single values are converted into arrays with a single element.
:param value: the value to convert.
:return: array object or None when value is None.
"""
# Shortcuts
if value == None:
... | [
"def",
"to_nullable_array",
"(",
"value",
")",
":",
"# Shortcuts",
"if",
"value",
"==",
"None",
":",
"return",
"None",
"if",
"type",
"(",
"value",
")",
"==",
"list",
":",
"return",
"value",
"if",
"type",
"(",
"value",
")",
"in",
"[",
"tuple",
",",
"s... | Converts value into array object.
Single values are converted into arrays with a single element.
:param value: the value to convert.
:return: array object or None when value is None. | [
"Converts",
"value",
"into",
"array",
"object",
".",
"Single",
"values",
"are",
"converted",
"into",
"arrays",
"with",
"a",
"single",
"element",
"."
] | python | train |
pallets/werkzeug | src/werkzeug/wrappers/base_request.py | https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/wrappers/base_request.py#L543-L545 | def full_path(self):
"""Requested path as unicode, including the query string."""
return self.path + u"?" + to_unicode(self.query_string, self.url_charset) | [
"def",
"full_path",
"(",
"self",
")",
":",
"return",
"self",
".",
"path",
"+",
"u\"?\"",
"+",
"to_unicode",
"(",
"self",
".",
"query_string",
",",
"self",
".",
"url_charset",
")"
] | Requested path as unicode, including the query string. | [
"Requested",
"path",
"as",
"unicode",
"including",
"the",
"query",
"string",
"."
] | python | train |
sergiocorreia/panflute | examples/pandocfilters/gabc.py | https://github.com/sergiocorreia/panflute/blob/65c2d570c26a190deb600cab5e2ad8a828a3302e/examples/pandocfilters/gabc.py#L120-L172 | def gabc(key, value, fmt, meta): # pylint:disable=I0011,W0613
"""Handle gabc file inclusion and gabc code block."""
if key == 'Code':
[[ident, classes, kvs], contents] = value # pylint:disable=I0011,W0612
kvs = {key: value for key, value in kvs}
if "gabc" in classes:
... | [
"def",
"gabc",
"(",
"key",
",",
"value",
",",
"fmt",
",",
"meta",
")",
":",
"# pylint:disable=I0011,W0613",
"if",
"key",
"==",
"'Code'",
":",
"[",
"[",
"ident",
",",
"classes",
",",
"kvs",
"]",
",",
"contents",
"]",
"=",
"value",
"# pylint:disable=I0011,... | Handle gabc file inclusion and gabc code block. | [
"Handle",
"gabc",
"file",
"inclusion",
"and",
"gabc",
"code",
"block",
"."
] | python | train |
ska-sa/katcp-python | katcp/ioloop_manager.py | https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/ioloop_manager.py#L199-L220 | def decorate_callable(self, callable_):
"""Decorate a callable to use call_in_ioloop"""
@wraps(callable_)
def decorated(*args, **kwargs):
# Extract timeout from request itself or use default for ioloop wrapper
timeout = kwargs.get('timeout')
return self.call_i... | [
"def",
"decorate_callable",
"(",
"self",
",",
"callable_",
")",
":",
"@",
"wraps",
"(",
"callable_",
")",
"def",
"decorated",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Extract timeout from request itself or use default for ioloop wrapper",
"timeout",
... | Decorate a callable to use call_in_ioloop | [
"Decorate",
"a",
"callable",
"to",
"use",
"call_in_ioloop"
] | python | train |
geminipy/geminipy | geminipy/__init__.py | https://github.com/geminipy/geminipy/blob/0d83fe225b746ac4c8bb800aa6091e1b606231e8/geminipy/__init__.py#L243-L252 | def tradevolume(self):
"""Send a request to get your trade volume, return the response."""
request = '/v1/tradevolume'
url = self.base_url + request
params = {
'request': request,
'nonce': self.get_nonce()
}
return requests.post(url, headers=self.... | [
"def",
"tradevolume",
"(",
"self",
")",
":",
"request",
"=",
"'/v1/tradevolume'",
"url",
"=",
"self",
".",
"base_url",
"+",
"request",
"params",
"=",
"{",
"'request'",
":",
"request",
",",
"'nonce'",
":",
"self",
".",
"get_nonce",
"(",
")",
"}",
"return"... | Send a request to get your trade volume, return the response. | [
"Send",
"a",
"request",
"to",
"get",
"your",
"trade",
"volume",
"return",
"the",
"response",
"."
] | python | train |
5j9/wikitextparser | wikitextparser/_wikitext.py | https://github.com/5j9/wikitextparser/blob/1347425814361d7955342c53212edbb27f0ff4b5/wikitextparser/_wikitext.py#L297-L300 | def string(self) -> str:
"""Return str(self)."""
start, end = self._span
return self._lststr[0][start:end] | [
"def",
"string",
"(",
"self",
")",
"->",
"str",
":",
"start",
",",
"end",
"=",
"self",
".",
"_span",
"return",
"self",
".",
"_lststr",
"[",
"0",
"]",
"[",
"start",
":",
"end",
"]"
] | Return str(self). | [
"Return",
"str",
"(",
"self",
")",
"."
] | python | test |
quadrismegistus/prosodic | prosodic/Text.py | https://github.com/quadrismegistus/prosodic/blob/8af66ed9be40c922d03a0b09bc11c87d2061b618/prosodic/Text.py#L191-L256 | def stats_positions(self,meter=None,all_parses=False):
"""Produce statistics from the parser"""
"""Positions
All feats of slots
All constraint violations
"""
parses = self.allParses(meter=meter) if all_parses else [[parse] for parse in self.bestParses(meter=meter)]
dx={}
for parselist in parses:
... | [
"def",
"stats_positions",
"(",
"self",
",",
"meter",
"=",
"None",
",",
"all_parses",
"=",
"False",
")",
":",
"\"\"\"Positions\n\t\tAll feats of slots\n\t\tAll constraint violations\n\n\n\t\t\"\"\"",
"parses",
"=",
"self",
".",
"allParses",
"(",
"meter",
"=",
"meter",
... | Produce statistics from the parser | [
"Produce",
"statistics",
"from",
"the",
"parser"
] | python | train |
jxtech/wechatpy | wechatpy/client/api/wxa.py | https://github.com/jxtech/wechatpy/blob/4df0da795618c0895a10f1c2cde9e9d5c0a93aaa/wechatpy/client/api/wxa.py#L145-L164 | def commit(self, template_id, ext_json, version, description):
"""
为授权的小程序账号上传小程序代码
详情请参考
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1489140610_Uavc4
:param template_id: 代码库中的代码模板 ID
:param ext_json: 第三方自定义的配置
:param version: 代码版本号,开发者... | [
"def",
"commit",
"(",
"self",
",",
"template_id",
",",
"ext_json",
",",
"version",
",",
"description",
")",
":",
"return",
"self",
".",
"_post",
"(",
"'wxa/commit'",
",",
"data",
"=",
"{",
"'template_id'",
":",
"template_id",
",",
"'ext_json'",
":",
"ext_j... | 为授权的小程序账号上传小程序代码
详情请参考
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1489140610_Uavc4
:param template_id: 代码库中的代码模板 ID
:param ext_json: 第三方自定义的配置
:param version: 代码版本号,开发者可自定义
:param description: 代码描述,开发者可自定义 | [
"为授权的小程序账号上传小程序代码",
"详情请参考",
"https",
":",
"//",
"open",
".",
"weixin",
".",
"qq",
".",
"com",
"/",
"cgi",
"-",
"bin",
"/",
"showdocument?action",
"=",
"dir_list&id",
"=",
"open1489140610_Uavc4"
] | python | train |
autokey/autokey | lib/autokey/iomediator/_iomediator.py | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/iomediator/_iomediator.py#L211-L216 | def send_up(self, count):
"""
Sends the given number of up key presses.
"""
for i in range(count):
self.interface.send_key(Key.UP) | [
"def",
"send_up",
"(",
"self",
",",
"count",
")",
":",
"for",
"i",
"in",
"range",
"(",
"count",
")",
":",
"self",
".",
"interface",
".",
"send_key",
"(",
"Key",
".",
"UP",
")"
] | Sends the given number of up key presses. | [
"Sends",
"the",
"given",
"number",
"of",
"up",
"key",
"presses",
"."
] | python | train |
noobermin/lspreader | lspreader/lspreader.py | https://github.com/noobermin/lspreader/blob/903b9d6427513b07986ffacf76cbca54e18d8be6/lspreader/lspreader.py#L155-L162 | def flds_firstsort(d):
'''
Perform a lexsort and return the sort indices and shape as a tuple.
'''
shape = [ len( np.unique(d[l]) )
for l in ['xs', 'ys', 'zs'] ];
si = np.lexsort((d['z'],d['y'],d['x']));
return si,shape; | [
"def",
"flds_firstsort",
"(",
"d",
")",
":",
"shape",
"=",
"[",
"len",
"(",
"np",
".",
"unique",
"(",
"d",
"[",
"l",
"]",
")",
")",
"for",
"l",
"in",
"[",
"'xs'",
",",
"'ys'",
",",
"'zs'",
"]",
"]",
"si",
"=",
"np",
".",
"lexsort",
"(",
"("... | Perform a lexsort and return the sort indices and shape as a tuple. | [
"Perform",
"a",
"lexsort",
"and",
"return",
"the",
"sort",
"indices",
"and",
"shape",
"as",
"a",
"tuple",
"."
] | python | train |
nathankw/pulsarpy | pulsarpy/models.py | https://github.com/nathankw/pulsarpy/blob/359b040c0f2383b88c0b5548715fefd35f5f634c/pulsarpy/models.py#L969-L1005 | def post(cls, payload):
"""
A wrapper over Model.post() that handles the case where a Library has a PairedBarcode
and the user may have supplied the PairedBarcode in the form of index1-index2, i.e.
GATTTCCA-GGCGTCGA. This isn't the PairedBarcode's record name or a record ID, thus
... | [
"def",
"post",
"(",
"cls",
",",
"payload",
")",
":",
"slpk_attr_name",
"=",
"\"sequencing_library_prep_kit_id\"",
"paired_bc_id_attr_name",
"=",
"\"paired_barcode_id\"",
"seq_reg",
"=",
"re",
".",
"compile",
"(",
"\"^[ACGTN]+$\"",
")",
"if",
"paired_bc_id_attr_name",
... | A wrapper over Model.post() that handles the case where a Library has a PairedBarcode
and the user may have supplied the PairedBarcode in the form of index1-index2, i.e.
GATTTCCA-GGCGTCGA. This isn't the PairedBarcode's record name or a record ID, thus
Model.post() won't be able to figure out ... | [
"A",
"wrapper",
"over",
"Model",
".",
"post",
"()",
"that",
"handles",
"the",
"case",
"where",
"a",
"Library",
"has",
"a",
"PairedBarcode",
"and",
"the",
"user",
"may",
"have",
"supplied",
"the",
"PairedBarcode",
"in",
"the",
"form",
"of",
"index1",
"-",
... | python | train |
spacetelescope/drizzlepac | drizzlepac/updatenpol.py | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/updatenpol.py#L286-L295 | def run(configobj=None,editpars=False):
""" Teal interface for running this code.
"""
if configobj is None:
configobj =teal.teal(__taskname__,loadOnly=(not editpars))
update(configobj['input'],configobj['refdir'],
local=configobj['local'],interactive=configobj['interactive'],
w... | [
"def",
"run",
"(",
"configobj",
"=",
"None",
",",
"editpars",
"=",
"False",
")",
":",
"if",
"configobj",
"is",
"None",
":",
"configobj",
"=",
"teal",
".",
"teal",
"(",
"__taskname__",
",",
"loadOnly",
"=",
"(",
"not",
"editpars",
")",
")",
"update",
... | Teal interface for running this code. | [
"Teal",
"interface",
"for",
"running",
"this",
"code",
"."
] | python | train |
Jaza/flask-restplus-patched | flask_restplus_patched/namespace.py | https://github.com/Jaza/flask-restplus-patched/blob/38b4a030f28e6aec374d105173aa5e9b6bd51e5e/flask_restplus_patched/namespace.py#L96-L192 | def response(self, model=None, code=HTTPStatus.OK, description=None, **kwargs):
"""
Endpoint response OpenAPI documentation decorator.
It automatically documents HTTPError%(code)d responses with relevant
schemas.
Arguments:
model (flask_marshmallow.Schema) - it can ... | [
"def",
"response",
"(",
"self",
",",
"model",
"=",
"None",
",",
"code",
"=",
"HTTPStatus",
".",
"OK",
",",
"description",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"code",
"=",
"HTTPStatus",
"(",
"code",
")",
"if",
"code",
"is",
"HTTPStatus",
... | Endpoint response OpenAPI documentation decorator.
It automatically documents HTTPError%(code)d responses with relevant
schemas.
Arguments:
model (flask_marshmallow.Schema) - it can be a class or an instance
of the class, which will be used for OpenAPI documentation... | [
"Endpoint",
"response",
"OpenAPI",
"documentation",
"decorator",
"."
] | python | train |
dahlia/sqlalchemy-imageattach | sqlalchemy_imageattach/entity.py | https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/entity.py#L846-L853 | def original(self):
"""(:class:`Image`) The original image. It could be :const:`None`
if there are no stored images yet.
"""
images = self.query._original_images(**self.identity_map)
if images:
return images[0] | [
"def",
"original",
"(",
"self",
")",
":",
"images",
"=",
"self",
".",
"query",
".",
"_original_images",
"(",
"*",
"*",
"self",
".",
"identity_map",
")",
"if",
"images",
":",
"return",
"images",
"[",
"0",
"]"
] | (:class:`Image`) The original image. It could be :const:`None`
if there are no stored images yet. | [
"(",
":",
"class",
":",
"Image",
")",
"The",
"original",
"image",
".",
"It",
"could",
"be",
":",
"const",
":",
"None",
"if",
"there",
"are",
"no",
"stored",
"images",
"yet",
"."
] | python | train |
sammchardy/python-binance | binance/depthcache.py | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/depthcache.py#L221-L254 | def _process_depth_message(self, msg, buffer=False):
"""Process a depth event message.
:param msg: Depth event message.
:return:
"""
if buffer and msg['u'] <= self._last_update_id:
# ignore any updates before the initial update id
return
elif ms... | [
"def",
"_process_depth_message",
"(",
"self",
",",
"msg",
",",
"buffer",
"=",
"False",
")",
":",
"if",
"buffer",
"and",
"msg",
"[",
"'u'",
"]",
"<=",
"self",
".",
"_last_update_id",
":",
"# ignore any updates before the initial update id",
"return",
"elif",
"msg... | Process a depth event message.
:param msg: Depth event message.
:return: | [
"Process",
"a",
"depth",
"event",
"message",
"."
] | python | train |
wavefrontHQ/python-client | wavefront_api_client/api/search_api.py | https://github.com/wavefrontHQ/python-client/blob/b0f1046a8f68c2c7d69e395f7167241f224c738a/wavefront_api_client/api/search_api.py#L4819-L4840 | def search_user_group_for_facet(self, facet, **kwargs): # noqa: E501
"""Lists the values of a specific facet over the customer's user groups # noqa: E501
# noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req... | [
"def",
"search_user_group_for_facet",
"(",
"self",
",",
"facet",
",",
"*",
"*",
"kwargs",
")",
":",
"# noqa: E501",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'async_req'",
")",
":",
"return",
"self",
".",
... | Lists the values of a specific facet over the customer's user groups # noqa: E501
# noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.search_user_group_for_facet(facet, async_req=True)... | [
"Lists",
"the",
"values",
"of",
"a",
"specific",
"facet",
"over",
"the",
"customer",
"s",
"user",
"groups",
"#",
"noqa",
":",
"E501"
] | python | train |
toomore/goristock | grs/goristock.py | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/goristock.py#L511-L526 | def ckMAO(self,data,s=5,pm=False):
"""判斷正負乖離位置
s = 取樣判斷區間
pm = True(正)/False(負) 乖離
return [T/F, 第幾個轉折日, 乖離值]
"""
c = data[-s:]
if pm:
ckvalue = max(c)
preckvalue = max(c) > 0
else:
ckvalue = min(c)
preckvalue = max(c) < 0
return [s - c.index(ckvalue... | [
"def",
"ckMAO",
"(",
"self",
",",
"data",
",",
"s",
"=",
"5",
",",
"pm",
"=",
"False",
")",
":",
"c",
"=",
"data",
"[",
"-",
"s",
":",
"]",
"if",
"pm",
":",
"ckvalue",
"=",
"max",
"(",
"c",
")",
"preckvalue",
"=",
"max",
"(",
"c",
")",
">... | 判斷正負乖離位置
s = 取樣判斷區間
pm = True(正)/False(負) 乖離
return [T/F, 第幾個轉折日, 乖離值] | [
"判斷正負乖離位置",
"s",
"=",
"取樣判斷區間",
"pm",
"=",
"True(正)",
"/",
"False(負)",
"乖離",
"return",
"[",
"T",
"/",
"F",
"第幾個轉折日",
"乖離值",
"]"
] | python | train |
osrg/ryu | ryu/services/protocols/bgp/core_managers/table_manager.py | https://github.com/osrg/ryu/blob/6f906e72c92e10bd0264c9b91a2f7bb85b97780c/ryu/services/protocols/bgp/core_managers/table_manager.py#L162-L172 | def learn_path(self, path):
"""Inserts `path` into correct global table.
Since known paths to `Destination` has changes, we queue it for further
processing.
"""
# Get VPN/Global table
table = self.get_global_table_by_route_family(path.route_family)
gpath_dest = t... | [
"def",
"learn_path",
"(",
"self",
",",
"path",
")",
":",
"# Get VPN/Global table",
"table",
"=",
"self",
".",
"get_global_table_by_route_family",
"(",
"path",
".",
"route_family",
")",
"gpath_dest",
"=",
"table",
".",
"insert",
"(",
"path",
")",
"# Since destina... | Inserts `path` into correct global table.
Since known paths to `Destination` has changes, we queue it for further
processing. | [
"Inserts",
"path",
"into",
"correct",
"global",
"table",
"."
] | python | train |
gem/oq-engine | openquake/server/views.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/views.py#L708-L732 | def calc_datastore(request, job_id):
"""
Download a full datastore file.
:param request:
`django.http.HttpRequest` object.
:param job_id:
The id of the requested datastore
:returns:
A `django.http.HttpResponse` containing the content
of the requested artifact, if pre... | [
"def",
"calc_datastore",
"(",
"request",
",",
"job_id",
")",
":",
"job",
"=",
"logs",
".",
"dbcmd",
"(",
"'get_job'",
",",
"int",
"(",
"job_id",
")",
")",
"if",
"job",
"is",
"None",
":",
"return",
"HttpResponseNotFound",
"(",
")",
"if",
"not",
"utils",... | Download a full datastore file.
:param request:
`django.http.HttpRequest` object.
:param job_id:
The id of the requested datastore
:returns:
A `django.http.HttpResponse` containing the content
of the requested artifact, if present, else throws a 404 | [
"Download",
"a",
"full",
"datastore",
"file",
"."
] | python | train |
pyQode/pyqode.core | pyqode/core/panels/folding.py | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/panels/folding.py#L553-L570 | def leaveEvent(self, event):
"""
Removes scope decorations and background from the editor and the panel
if highlight_caret_scope, else simply update the scope decorations to
match the caret scope.
"""
super(FoldingPanel, self).leaveEvent(event)
QtWidgets.QApplica... | [
"def",
"leaveEvent",
"(",
"self",
",",
"event",
")",
":",
"super",
"(",
"FoldingPanel",
",",
"self",
")",
".",
"leaveEvent",
"(",
"event",
")",
"QtWidgets",
".",
"QApplication",
".",
"restoreOverrideCursor",
"(",
")",
"self",
".",
"_highlight_runner",
".",
... | Removes scope decorations and background from the editor and the panel
if highlight_caret_scope, else simply update the scope decorations to
match the caret scope. | [
"Removes",
"scope",
"decorations",
"and",
"background",
"from",
"the",
"editor",
"and",
"the",
"panel",
"if",
"highlight_caret_scope",
"else",
"simply",
"update",
"the",
"scope",
"decorations",
"to",
"match",
"the",
"caret",
"scope",
"."
] | python | train |
ministryofjustice/money-to-prisoners-common | mtp_common/build_tasks/tasks.py | https://github.com/ministryofjustice/money-to-prisoners-common/blob/33c43a2912cb990d9148da7c8718f480f07d90a1/mtp_common/build_tasks/tasks.py#L121-L127 | def create_build_paths(context: Context):
"""
Creates directories needed for build outputs
"""
paths = [context.app.asset_build_path, context.app.screenshots_build_path, context.app.collected_assets_path]
for path in filter(None, paths):
os.makedirs(path, exist_ok=True) | [
"def",
"create_build_paths",
"(",
"context",
":",
"Context",
")",
":",
"paths",
"=",
"[",
"context",
".",
"app",
".",
"asset_build_path",
",",
"context",
".",
"app",
".",
"screenshots_build_path",
",",
"context",
".",
"app",
".",
"collected_assets_path",
"]",
... | Creates directories needed for build outputs | [
"Creates",
"directories",
"needed",
"for",
"build",
"outputs"
] | python | train |
jaraco/keyrings.alt | keyrings/alt/file.py | https://github.com/jaraco/keyrings.alt/blob/5b71223d12bf9ac6abd05b1b395f1efccb5ea660/keyrings/alt/file.py#L47-L54 | def _create_cipher(self, password, salt, IV):
"""
Create the cipher object to encrypt or decrypt a payload.
"""
from Crypto.Protocol.KDF import PBKDF2
from Crypto.Cipher import AES
pw = PBKDF2(password, salt, dkLen=self.block_size)
return AES.new(pw[:self.block_si... | [
"def",
"_create_cipher",
"(",
"self",
",",
"password",
",",
"salt",
",",
"IV",
")",
":",
"from",
"Crypto",
".",
"Protocol",
".",
"KDF",
"import",
"PBKDF2",
"from",
"Crypto",
".",
"Cipher",
"import",
"AES",
"pw",
"=",
"PBKDF2",
"(",
"password",
",",
"sa... | Create the cipher object to encrypt or decrypt a payload. | [
"Create",
"the",
"cipher",
"object",
"to",
"encrypt",
"or",
"decrypt",
"a",
"payload",
"."
] | python | train |
google/openhtf | openhtf/util/timeouts.py | https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/util/timeouts.py#L422-L440 | def take_at_most_n_seconds(time_s, func, *args, **kwargs):
"""A function that returns whether a function call took less than time_s.
NOTE: The function call is not killed and will run indefinitely if hung.
Args:
time_s: Maximum amount of time to take.
func: Function to call.
*args: Arguments to call... | [
"def",
"take_at_most_n_seconds",
"(",
"time_s",
",",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"thread",
"=",
"threading",
".",
"Thread",
"(",
"target",
"=",
"func",
",",
"args",
"=",
"args",
",",
"kwargs",
"=",
"kwargs",
")",
"thr... | A function that returns whether a function call took less than time_s.
NOTE: The function call is not killed and will run indefinitely if hung.
Args:
time_s: Maximum amount of time to take.
func: Function to call.
*args: Arguments to call the function with.
**kwargs: Keyword arguments to call the ... | [
"A",
"function",
"that",
"returns",
"whether",
"a",
"function",
"call",
"took",
"less",
"than",
"time_s",
"."
] | python | train |
barrust/pyspellchecker | spellchecker/spellchecker.py | https://github.com/barrust/pyspellchecker/blob/fa96024c0cdeba99e10e11060d5fd7aba796b271/spellchecker/spellchecker.py#L79-L88 | def distance(self, val):
""" set the distance parameter """
tmp = 2
try:
int(val)
if val > 0 and val <= 2:
tmp = val
except (ValueError, TypeError):
pass
self._distance = tmp | [
"def",
"distance",
"(",
"self",
",",
"val",
")",
":",
"tmp",
"=",
"2",
"try",
":",
"int",
"(",
"val",
")",
"if",
"val",
">",
"0",
"and",
"val",
"<=",
"2",
":",
"tmp",
"=",
"val",
"except",
"(",
"ValueError",
",",
"TypeError",
")",
":",
"pass",
... | set the distance parameter | [
"set",
"the",
"distance",
"parameter"
] | python | train |
fprimex/zdesk | zdesk/zdesk_api.py | https://github.com/fprimex/zdesk/blob/851611c13b4d530e9df31390b3ec709baf0a0188/zdesk/zdesk_api.py#L934-L938 | def community_topic_delete(self, id, **kwargs):
"https://developer.zendesk.com/rest_api/docs/help_center/topics#delete-topic"
api_path = "/api/v2/community/topics/{id}.json"
api_path = api_path.format(id=id)
return self.call(api_path, method="DELETE", **kwargs) | [
"def",
"community_topic_delete",
"(",
"self",
",",
"id",
",",
"*",
"*",
"kwargs",
")",
":",
"api_path",
"=",
"\"/api/v2/community/topics/{id}.json\"",
"api_path",
"=",
"api_path",
".",
"format",
"(",
"id",
"=",
"id",
")",
"return",
"self",
".",
"call",
"(",
... | https://developer.zendesk.com/rest_api/docs/help_center/topics#delete-topic | [
"https",
":",
"//",
"developer",
".",
"zendesk",
".",
"com",
"/",
"rest_api",
"/",
"docs",
"/",
"help_center",
"/",
"topics#delete",
"-",
"topic"
] | python | train |
apache/incubator-heron | heron/tools/ui/src/python/handlers/topology.py | https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/heron/tools/ui/src/python/handlers/topology.py#L176-L195 | def get(self, cluster, environ, topology, container):
'''
:param cluster:
:param environ:
:param topology:
:param container:
:return:
'''
path = self.get_argument("path")
options = dict(
cluster=cluster,
environ=environ,
topology=topology,
container=c... | [
"def",
"get",
"(",
"self",
",",
"cluster",
",",
"environ",
",",
"topology",
",",
"container",
")",
":",
"path",
"=",
"self",
".",
"get_argument",
"(",
"\"path\"",
")",
"options",
"=",
"dict",
"(",
"cluster",
"=",
"cluster",
",",
"environ",
"=",
"enviro... | :param cluster:
:param environ:
:param topology:
:param container:
:return: | [
":",
"param",
"cluster",
":",
":",
"param",
"environ",
":",
":",
"param",
"topology",
":",
":",
"param",
"container",
":",
":",
"return",
":"
] | python | valid |
Workiva/furious | furious/config.py | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/furious/config.py#L98-L115 | def find_furious_yaml(config_file=__file__):
"""
Traverse directory trees to find a furious.yaml file
Begins with the location of this file then checks the
working directory if not found
Args:
config_file: location of this file, override for
testing
Returns:
the path of... | [
"def",
"find_furious_yaml",
"(",
"config_file",
"=",
"__file__",
")",
":",
"checked",
"=",
"set",
"(",
")",
"result",
"=",
"_find_furious_yaml",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"config_file",
")",
",",
"checked",
")",
"if",
"not",
"result",
... | Traverse directory trees to find a furious.yaml file
Begins with the location of this file then checks the
working directory if not found
Args:
config_file: location of this file, override for
testing
Returns:
the path of furious.yaml or None if not found | [
"Traverse",
"directory",
"trees",
"to",
"find",
"a",
"furious",
".",
"yaml",
"file"
] | python | train |
bodylabs/lace | lace/serialization/dae.py | https://github.com/bodylabs/lace/blob/b68f4a60a4cac66c0607ffbae38ef9d07d37f459/lace/serialization/dae.py#L7-L12 | def _dump(f, mesh):
'''
Writes a mesh to collada file format.
'''
dae = mesh_to_collada(mesh)
dae.write(f.name) | [
"def",
"_dump",
"(",
"f",
",",
"mesh",
")",
":",
"dae",
"=",
"mesh_to_collada",
"(",
"mesh",
")",
"dae",
".",
"write",
"(",
"f",
".",
"name",
")"
] | Writes a mesh to collada file format. | [
"Writes",
"a",
"mesh",
"to",
"collada",
"file",
"format",
"."
] | python | train |
ejhigson/nestcheck | nestcheck/diagnostics_tables.py | https://github.com/ejhigson/nestcheck/blob/29151c314deb89746fd674f27f6ce54b77603189/nestcheck/diagnostics_tables.py#L231-L244 | def run_list_error_summary(run_list, estimator_list, estimator_names,
n_simulate, **kwargs):
"""Wrapper which runs run_list_error_values then applies error_values
summary to the resulting dataframe. See the docstrings for those two
funcions for more details and for descriptions of... | [
"def",
"run_list_error_summary",
"(",
"run_list",
",",
"estimator_list",
",",
"estimator_names",
",",
"n_simulate",
",",
"*",
"*",
"kwargs",
")",
":",
"true_values",
"=",
"kwargs",
".",
"pop",
"(",
"'true_values'",
",",
"None",
")",
"include_true_values",
"=",
... | Wrapper which runs run_list_error_values then applies error_values
summary to the resulting dataframe. See the docstrings for those two
funcions for more details and for descriptions of parameters and output. | [
"Wrapper",
"which",
"runs",
"run_list_error_values",
"then",
"applies",
"error_values",
"summary",
"to",
"the",
"resulting",
"dataframe",
".",
"See",
"the",
"docstrings",
"for",
"those",
"two",
"funcions",
"for",
"more",
"details",
"and",
"for",
"descriptions",
"o... | python | train |
Neurita/boyle | boyle/dicom/convert.py | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/dicom/convert.py#L44-L102 | def add_meta_to_nii(nii_file, dicom_file, dcm_tags=''):
""" Add slice duration and acquisition times to the headers of the nifit1 files in `nii_file`.
It will add the repetition time of the DICOM file (field: {0x0018, 0x0080, DS, Repetition Time})
to the NifTI file as well as any other tag in `dcm_tags`.
... | [
"def",
"add_meta_to_nii",
"(",
"nii_file",
",",
"dicom_file",
",",
"dcm_tags",
"=",
"''",
")",
":",
"# Load a dicom image",
"dcmimage",
"=",
"dicom",
".",
"read_file",
"(",
"dicom_file",
")",
"# Load the nifti1 image",
"image",
"=",
"nibabel",
".",
"load",
"(",
... | Add slice duration and acquisition times to the headers of the nifit1 files in `nii_file`.
It will add the repetition time of the DICOM file (field: {0x0018, 0x0080, DS, Repetition Time})
to the NifTI file as well as any other tag in `dcm_tags`.
All selected DICOM tags values are set in the `descrip` nifti ... | [
"Add",
"slice",
"duration",
"and",
"acquisition",
"times",
"to",
"the",
"headers",
"of",
"the",
"nifit1",
"files",
"in",
"nii_file",
".",
"It",
"will",
"add",
"the",
"repetition",
"time",
"of",
"the",
"DICOM",
"file",
"(",
"field",
":",
"{",
"0x0018",
"0... | python | valid |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.