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 |
|---|---|---|---|---|---|---|---|---|
Azure/azure-cli-extensions | src/storage-preview/azext_storage_preview/vendored_sdks/azure_storage/v2018_03_28/queue/queueservice.py | https://github.com/Azure/azure-cli-extensions/blob/3d4854205b0f0d882f688cfa12383d14506c2e35/src/storage-preview/azext_storage_preview/vendored_sdks/azure_storage/v2018_03_28/queue/queueservice.py#L636-L652 | def exists(self, queue_name, timeout=None):
'''
Returns a boolean indicating whether the queue exists.
:param str queue_name:
The name of queue to check for existence.
:param int timeout:
The server timeout, expressed in seconds.
:return: A boolean indica... | [
"def",
"exists",
"(",
"self",
",",
"queue_name",
",",
"timeout",
"=",
"None",
")",
":",
"try",
":",
"self",
".",
"get_queue_metadata",
"(",
"queue_name",
",",
"timeout",
"=",
"timeout",
")",
"return",
"True",
"except",
"AzureHttpError",
"as",
"ex",
":",
... | Returns a boolean indicating whether the queue exists.
:param str queue_name:
The name of queue to check for existence.
:param int timeout:
The server timeout, expressed in seconds.
:return: A boolean indicating whether the queue exists.
:rtype: bool | [
"Returns",
"a",
"boolean",
"indicating",
"whether",
"the",
"queue",
"exists",
"."
] | python | train |
cs50/check50 | check50/internal.py | https://github.com/cs50/check50/blob/42c1f0c36baa6a24f69742d74551a9ea7a5ceb33/check50/internal.py#L63-L105 | def load_config(check_dir):
"""
Load configuration file from ``check_dir / ".cs50.yaml"``, applying
defaults to unspecified values.
:param check_dir: directory from which to load config file
:type check_dir: str / Path
:rtype: dict
"""
# Defaults for top-level keys
options = {
... | [
"def",
"load_config",
"(",
"check_dir",
")",
":",
"# Defaults for top-level keys",
"options",
"=",
"{",
"\"checks\"",
":",
"\"__init__.py\"",
",",
"\"dependencies\"",
":",
"None",
",",
"\"translations\"",
":",
"None",
"}",
"# Defaults for translation keys",
"translation... | Load configuration file from ``check_dir / ".cs50.yaml"``, applying
defaults to unspecified values.
:param check_dir: directory from which to load config file
:type check_dir: str / Path
:rtype: dict | [
"Load",
"configuration",
"file",
"from",
"check_dir",
"/",
".",
"cs50",
".",
"yaml",
"applying",
"defaults",
"to",
"unspecified",
"values",
"."
] | python | train |
deepmind/sonnet | sonnet/python/modules/util.py | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/util.py#L491-L506 | def _get_vars_to_collections(variables):
"""Returns a dict mapping variables to the collections they appear in."""
var_to_collections = collections.defaultdict(lambda: [])
if isinstance(variables, dict):
variables = list(v for _, v in variable_map_items(variables))
for graph in set(v.graph for v in variable... | [
"def",
"_get_vars_to_collections",
"(",
"variables",
")",
":",
"var_to_collections",
"=",
"collections",
".",
"defaultdict",
"(",
"lambda",
":",
"[",
"]",
")",
"if",
"isinstance",
"(",
"variables",
",",
"dict",
")",
":",
"variables",
"=",
"list",
"(",
"v",
... | Returns a dict mapping variables to the collections they appear in. | [
"Returns",
"a",
"dict",
"mapping",
"variables",
"to",
"the",
"collections",
"they",
"appear",
"in",
"."
] | python | train |
ralphbean/bugwarrior | bugwarrior/db.py | https://github.com/ralphbean/bugwarrior/blob/b2a5108f7b40cb0c437509b64eaa28f941f7ac8b/bugwarrior/db.py#L91-L97 | def hamdist(str1, str2):
"""Count the # of differences between equal length strings str1 and str2"""
diffs = 0
for ch1, ch2 in zip(str1, str2):
if ch1 != ch2:
diffs += 1
return diffs | [
"def",
"hamdist",
"(",
"str1",
",",
"str2",
")",
":",
"diffs",
"=",
"0",
"for",
"ch1",
",",
"ch2",
"in",
"zip",
"(",
"str1",
",",
"str2",
")",
":",
"if",
"ch1",
"!=",
"ch2",
":",
"diffs",
"+=",
"1",
"return",
"diffs"
] | Count the # of differences between equal length strings str1 and str2 | [
"Count",
"the",
"#",
"of",
"differences",
"between",
"equal",
"length",
"strings",
"str1",
"and",
"str2"
] | python | test |
cni/MRS | MRS/analysis.py | https://github.com/cni/MRS/blob/16098b3cf4830780efd787fee9efa46513850283/MRS/analysis.py#L809-L845 | def simple_auc(spectrum, f_ppm, center=3.00, bandwidth=0.30):
"""
Calculates area under the curve (no fitting)
Parameters
----------
spectrum : array of shape (n_transients, n_points)
Typically the difference of the on/off spectra in each transient.
center, bandwidth : float
Determine th... | [
"def",
"simple_auc",
"(",
"spectrum",
",",
"f_ppm",
",",
"center",
"=",
"3.00",
",",
"bandwidth",
"=",
"0.30",
")",
":",
"range",
"=",
"np",
".",
"max",
"(",
"f_ppm",
")",
"-",
"np",
".",
"min",
"(",
"f_ppm",
")",
"dx",
"=",
"float",
"(",
"range"... | Calculates area under the curve (no fitting)
Parameters
----------
spectrum : array of shape (n_transients, n_points)
Typically the difference of the on/off spectra in each transient.
center, bandwidth : float
Determine the limits for the part of the spectrum for which we want
to calcula... | [
"Calculates",
"area",
"under",
"the",
"curve",
"(",
"no",
"fitting",
")"
] | python | train |
eventbrite/eventbrite-sdk-python | eventbrite/access_methods.py | https://github.com/eventbrite/eventbrite-sdk-python/blob/f2e5dc5aa1aa3e45766de13f16fd65722163d91a/eventbrite/access_methods.py#L356-L363 | def post_event_access_code(self, id, access_code_id, **data):
"""
POST /events/:id/access_codes/:access_code_id/
Updates an access code; returns the result as a :format:`access_code` as the
key ``access_code``.
"""
return self.post("/events/{0}/access_codes/{0}/"... | [
"def",
"post_event_access_code",
"(",
"self",
",",
"id",
",",
"access_code_id",
",",
"*",
"*",
"data",
")",
":",
"return",
"self",
".",
"post",
"(",
"\"/events/{0}/access_codes/{0}/\"",
".",
"format",
"(",
"id",
",",
"access_code_id",
")",
",",
"data",
"=",
... | POST /events/:id/access_codes/:access_code_id/
Updates an access code; returns the result as a :format:`access_code` as the
key ``access_code``. | [
"POST",
"/",
"events",
"/",
":",
"id",
"/",
"access_codes",
"/",
":",
"access_code_id",
"/",
"Updates",
"an",
"access",
"code",
";",
"returns",
"the",
"result",
"as",
"a",
":",
"format",
":",
"access_code",
"as",
"the",
"key",
"access_code",
"."
] | python | train |
Telefonica/toolium | toolium/driver_wrappers_pool.py | https://github.com/Telefonica/toolium/blob/56847c243b3a98876df74c184b75e43f8810e475/toolium/driver_wrappers_pool.py#L95-L111 | def capture_screenshots(cls, name):
"""Capture a screenshot in each driver
:param name: screenshot name suffix
"""
screenshot_name = '{}_driver{}' if len(cls.driver_wrappers) > 1 else '{}'
driver_index = 1
for driver_wrapper in cls.driver_wrappers:
if not dri... | [
"def",
"capture_screenshots",
"(",
"cls",
",",
"name",
")",
":",
"screenshot_name",
"=",
"'{}_driver{}'",
"if",
"len",
"(",
"cls",
".",
"driver_wrappers",
")",
">",
"1",
"else",
"'{}'",
"driver_index",
"=",
"1",
"for",
"driver_wrapper",
"in",
"cls",
".",
"... | Capture a screenshot in each driver
:param name: screenshot name suffix | [
"Capture",
"a",
"screenshot",
"in",
"each",
"driver"
] | python | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/slim/scopes.py | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/scopes.py#L138-L157 | def add_arg_scope(func):
"""Decorates a function with args so it can be used within an arg_scope.
Args:
func: function to decorate.
Returns:
A tuple with the decorated function func_with_args().
"""
@functools.wraps(func)
def func_with_args(*args, **kwargs):
current_scope = _current_arg_scope(... | [
"def",
"add_arg_scope",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"func_with_args",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"current_scope",
"=",
"_current_arg_scope",
"(",
")",
"current_args",
"=",
"kwa... | Decorates a function with args so it can be used within an arg_scope.
Args:
func: function to decorate.
Returns:
A tuple with the decorated function func_with_args(). | [
"Decorates",
"a",
"function",
"with",
"args",
"so",
"it",
"can",
"be",
"used",
"within",
"an",
"arg_scope",
"."
] | python | train |
PMEAL/porespy | porespy/visualization/__views__.py | https://github.com/PMEAL/porespy/blob/1e13875b56787d8f5b7ffdabce8c4342c33ba9f8/porespy/visualization/__views__.py#L49-L80 | def sem(im, direction='X'):
r"""
Simulates an SEM photograph looking into the porous material in the
specified direction. Features are colored according to their depth into
the image, so darker features are further away.
Parameters
----------
im : array_like
ND-image of the porous ... | [
"def",
"sem",
"(",
"im",
",",
"direction",
"=",
"'X'",
")",
":",
"im",
"=",
"sp",
".",
"array",
"(",
"~",
"im",
",",
"dtype",
"=",
"int",
")",
"if",
"direction",
"in",
"[",
"'Y'",
",",
"'y'",
"]",
":",
"im",
"=",
"sp",
".",
"transpose",
"(",
... | r"""
Simulates an SEM photograph looking into the porous material in the
specified direction. Features are colored according to their depth into
the image, so darker features are further away.
Parameters
----------
im : array_like
ND-image of the porous material with the solid phase ma... | [
"r",
"Simulates",
"an",
"SEM",
"photograph",
"looking",
"into",
"the",
"porous",
"material",
"in",
"the",
"specified",
"direction",
".",
"Features",
"are",
"colored",
"according",
"to",
"their",
"depth",
"into",
"the",
"image",
"so",
"darker",
"features",
"are... | python | train |
uogbuji/versa | tools/py/driver/postgres.py | https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/driver/postgres.py#L113-L139 | def _process_db_rows_iter(self, cursor):
'''
Turn the low-level rows from the result of a standard query join
into higher-level statements, yielded iteratively. Note this might lead to
idle transaction errors?
'''
#Be aware of: http://packages.python.org/psycopg2/faq.htm... | [
"def",
"_process_db_rows_iter",
"(",
"self",
",",
"cursor",
")",
":",
"#Be aware of: http://packages.python.org/psycopg2/faq.html#problems-with-transactions-handling",
"#The results will come back grouped by the raw relationship IDs, in order",
"for",
"relid",
",",
"relgroup",
"in",
"g... | Turn the low-level rows from the result of a standard query join
into higher-level statements, yielded iteratively. Note this might lead to
idle transaction errors? | [
"Turn",
"the",
"low",
"-",
"level",
"rows",
"from",
"the",
"result",
"of",
"a",
"standard",
"query",
"join",
"into",
"higher",
"-",
"level",
"statements",
"yielded",
"iteratively",
".",
"Note",
"this",
"might",
"lead",
"to",
"idle",
"transaction",
"errors?"
... | python | train |
pantsbuild/pex | pex/vendor/_vendored/setuptools/setuptools/sandbox.py | https://github.com/pantsbuild/pex/blob/87b2129d860250d3b9edce75b9cb62f9789ee521/pex/vendor/_vendored/setuptools/setuptools/sandbox.py#L117-L131 | def dump(type, exc):
"""
Always return a dumped (pickled) type and exc. If exc can't be pickled,
wrap it in UnpickleableException first.
"""
try:
return pickle.dumps(type), pickle.dumps(exc)
except Exception:
# get UnpickleableException inside the ... | [
"def",
"dump",
"(",
"type",
",",
"exc",
")",
":",
"try",
":",
"return",
"pickle",
".",
"dumps",
"(",
"type",
")",
",",
"pickle",
".",
"dumps",
"(",
"exc",
")",
"except",
"Exception",
":",
"# get UnpickleableException inside the sandbox",
"if",
"\"__PEX_UNVEN... | Always return a dumped (pickled) type and exc. If exc can't be pickled,
wrap it in UnpickleableException first. | [
"Always",
"return",
"a",
"dumped",
"(",
"pickled",
")",
"type",
"and",
"exc",
".",
"If",
"exc",
"can",
"t",
"be",
"pickled",
"wrap",
"it",
"in",
"UnpickleableException",
"first",
"."
] | python | train |
ubernostrum/django-registration | src/django_registration/validators.py | https://github.com/ubernostrum/django-registration/blob/cf10b13423669346a1f4cfaa31aae0b42856b416/src/django_registration/validators.py#L237-L250 | def validate_confusables(value):
"""
Validator which disallows 'dangerous' usernames likely to
represent homograph attacks.
A username is 'dangerous' if it is mixed-script (as defined by
Unicode 'Script' property) and contains one or more characters
appearing in the Unicode Visually Confusable ... | [
"def",
"validate_confusables",
"(",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"six",
".",
"text_type",
")",
":",
"return",
"if",
"confusables",
".",
"is_dangerous",
"(",
"value",
")",
":",
"raise",
"ValidationError",
"(",
"CONFUSABLE",... | Validator which disallows 'dangerous' usernames likely to
represent homograph attacks.
A username is 'dangerous' if it is mixed-script (as defined by
Unicode 'Script' property) and contains one or more characters
appearing in the Unicode Visually Confusable Characters file. | [
"Validator",
"which",
"disallows",
"dangerous",
"usernames",
"likely",
"to",
"represent",
"homograph",
"attacks",
"."
] | python | train |
apache/spark | python/pyspark/serializers.py | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/serializers.py#L345-L352 | def load_stream(self, stream):
"""
Deserialize ArrowRecordBatches to an Arrow table and return as a list of pandas.Series.
"""
batches = super(ArrowStreamPandasSerializer, self).load_stream(stream)
import pyarrow as pa
for batch in batches:
yield [self.arrow_t... | [
"def",
"load_stream",
"(",
"self",
",",
"stream",
")",
":",
"batches",
"=",
"super",
"(",
"ArrowStreamPandasSerializer",
",",
"self",
")",
".",
"load_stream",
"(",
"stream",
")",
"import",
"pyarrow",
"as",
"pa",
"for",
"batch",
"in",
"batches",
":",
"yield... | Deserialize ArrowRecordBatches to an Arrow table and return as a list of pandas.Series. | [
"Deserialize",
"ArrowRecordBatches",
"to",
"an",
"Arrow",
"table",
"and",
"return",
"as",
"a",
"list",
"of",
"pandas",
".",
"Series",
"."
] | python | train |
tornadoweb/tornado | tornado/ioloop.py | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/ioloop.py#L548-L587 | def add_timeout(
self,
deadline: Union[float, datetime.timedelta],
callback: Callable[..., None],
*args: Any,
**kwargs: Any
) -> object:
"""Runs the ``callback`` at the time ``deadline`` from the I/O loop.
Returns an opaque handle that may be passed to
... | [
"def",
"add_timeout",
"(",
"self",
",",
"deadline",
":",
"Union",
"[",
"float",
",",
"datetime",
".",
"timedelta",
"]",
",",
"callback",
":",
"Callable",
"[",
"...",
",",
"None",
"]",
",",
"*",
"args",
":",
"Any",
",",
"*",
"*",
"kwargs",
":",
"Any... | Runs the ``callback`` at the time ``deadline`` from the I/O loop.
Returns an opaque handle that may be passed to
`remove_timeout` to cancel.
``deadline`` may be a number denoting a time (on the same
scale as `IOLoop.time`, normally `time.time`), or a
`datetime.timedelta` object... | [
"Runs",
"the",
"callback",
"at",
"the",
"time",
"deadline",
"from",
"the",
"I",
"/",
"O",
"loop",
"."
] | python | train |
elifesciences/elife-tools | elifetools/parseJATS.py | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L493-L508 | def collection_year(soup):
"""
Pub date of type collection will hold a year element for VOR articles
"""
pub_date = first(raw_parser.pub_date(soup, pub_type="collection"))
if not pub_date:
pub_date = first(raw_parser.pub_date(soup, date_type="collection"))
if not pub_date:
return... | [
"def",
"collection_year",
"(",
"soup",
")",
":",
"pub_date",
"=",
"first",
"(",
"raw_parser",
".",
"pub_date",
"(",
"soup",
",",
"pub_type",
"=",
"\"collection\"",
")",
")",
"if",
"not",
"pub_date",
":",
"pub_date",
"=",
"first",
"(",
"raw_parser",
".",
... | Pub date of type collection will hold a year element for VOR articles | [
"Pub",
"date",
"of",
"type",
"collection",
"will",
"hold",
"a",
"year",
"element",
"for",
"VOR",
"articles"
] | python | train |
zhmcclient/python-zhmcclient | zhmcclient/_metrics.py | https://github.com/zhmcclient/python-zhmcclient/blob/9657563e5d9184c51d3c903442a58b9725fdf335/zhmcclient/_metrics.py#L846-L915 | def resource(self):
"""
:class:`~zhmcclient.BaseResource`: The Python resource object of the
resource these metric values apply to.
Raises:
:exc:`~zhmcclient.NotFound`: No resource found for this URI in the
management scope of the HMC.
"""
if sel... | [
"def",
"resource",
"(",
"self",
")",
":",
"if",
"self",
".",
"_resource",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_resource",
"resource_class",
"=",
"self",
".",
"metric_group_definition",
".",
"resource_class",
"resource_uri",
"=",
"self",
".",
"r... | :class:`~zhmcclient.BaseResource`: The Python resource object of the
resource these metric values apply to.
Raises:
:exc:`~zhmcclient.NotFound`: No resource found for this URI in the
management scope of the HMC. | [
":",
"class",
":",
"~zhmcclient",
".",
"BaseResource",
":",
"The",
"Python",
"resource",
"object",
"of",
"the",
"resource",
"these",
"metric",
"values",
"apply",
"to",
"."
] | python | train |
inveniosoftware/invenio-collections | invenio_collections/cli.py | https://github.com/inveniosoftware/invenio-collections/blob/f3adca45c6d00a4dbf1f48fd501e8a68fe347f2f/invenio_collections/cli.py#L41-L51 | def dry_run(func):
"""Dry run: simulate sql execution."""
@wraps(func)
def inner(dry_run, *args, **kwargs):
ret = func(dry_run=dry_run, *args, **kwargs)
if not dry_run:
db.session.commit()
else:
db.session.rollback()
return ret
return inner | [
"def",
"dry_run",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"inner",
"(",
"dry_run",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"func",
"(",
"dry_run",
"=",
"dry_run",
",",
"*",
"args",
",",
"*",
"*",
... | Dry run: simulate sql execution. | [
"Dry",
"run",
":",
"simulate",
"sql",
"execution",
"."
] | python | train |
trailofbits/manticore | examples/script/concolic.py | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/examples/script/concolic.py#L157-L184 | def symbolic_run_get_cons(trace):
'''
Execute a symbolic run that follows a concrete run; return constraints generated
and the stdin data produced
'''
m2 = Manticore.linux(prog, workspace_url='mem:')
f = Follower(trace)
m2.verbosity(VERBOSITY)
m2.register_plugin(f)
def on_term_test... | [
"def",
"symbolic_run_get_cons",
"(",
"trace",
")",
":",
"m2",
"=",
"Manticore",
".",
"linux",
"(",
"prog",
",",
"workspace_url",
"=",
"'mem:'",
")",
"f",
"=",
"Follower",
"(",
"trace",
")",
"m2",
".",
"verbosity",
"(",
"VERBOSITY",
")",
"m2",
".",
"reg... | Execute a symbolic run that follows a concrete run; return constraints generated
and the stdin data produced | [
"Execute",
"a",
"symbolic",
"run",
"that",
"follows",
"a",
"concrete",
"run",
";",
"return",
"constraints",
"generated",
"and",
"the",
"stdin",
"data",
"produced"
] | python | valid |
stefanfoulis/django-sendsms | sendsms/api.py | https://github.com/stefanfoulis/django-sendsms/blob/375f469789866853253eceba936ebcff98e83c07/sendsms/api.py#L14-L28 | def send_sms(body, from_phone, to, flash=False, fail_silently=False,
auth_user=None, auth_password=None, connection=None):
"""
Easy wrapper for send a single SMS to a recipient list.
:returns: the number of SMSs sent.
"""
from sendsms.message import SmsMessage
connection = connecti... | [
"def",
"send_sms",
"(",
"body",
",",
"from_phone",
",",
"to",
",",
"flash",
"=",
"False",
",",
"fail_silently",
"=",
"False",
",",
"auth_user",
"=",
"None",
",",
"auth_password",
"=",
"None",
",",
"connection",
"=",
"None",
")",
":",
"from",
"sendsms",
... | Easy wrapper for send a single SMS to a recipient list.
:returns: the number of SMSs sent. | [
"Easy",
"wrapper",
"for",
"send",
"a",
"single",
"SMS",
"to",
"a",
"recipient",
"list",
"."
] | python | train |
openstack/proliantutils | proliantutils/utils.py | https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/utils.py#L138-L156 | def validate_href(image_href):
"""Validate HTTP image reference.
:param image_href: Image reference.
:raises: exception.ImageRefValidationFailed if HEAD request failed or
returned response code not equal to 200.
:returns: Response to HEAD request.
"""
try:
... | [
"def",
"validate_href",
"(",
"image_href",
")",
":",
"try",
":",
"response",
"=",
"requests",
".",
"head",
"(",
"image_href",
")",
"if",
"response",
".",
"status_code",
"!=",
"http_client",
".",
"OK",
":",
"raise",
"exception",
".",
"ImageRefValidationFailed",... | Validate HTTP image reference.
:param image_href: Image reference.
:raises: exception.ImageRefValidationFailed if HEAD request failed or
returned response code not equal to 200.
:returns: Response to HEAD request. | [
"Validate",
"HTTP",
"image",
"reference",
"."
] | python | train |
tilezen/tilequeue | tilequeue/query/rawr.py | https://github.com/tilezen/tilequeue/blob/d7b9484ab92e246eb2773949c784ebb37c731e28/tilequeue/query/rawr.py#L229-L239 | def _snapping_round(num, eps, resolution):
"""
Return num snapped to within eps of an integer, or int(resolution(num)).
"""
rounded = round(num)
delta = abs(num - rounded)
if delta < eps:
return int(rounded)
else:
return int(resolution(num)) | [
"def",
"_snapping_round",
"(",
"num",
",",
"eps",
",",
"resolution",
")",
":",
"rounded",
"=",
"round",
"(",
"num",
")",
"delta",
"=",
"abs",
"(",
"num",
"-",
"rounded",
")",
"if",
"delta",
"<",
"eps",
":",
"return",
"int",
"(",
"rounded",
")",
"el... | Return num snapped to within eps of an integer, or int(resolution(num)). | [
"Return",
"num",
"snapped",
"to",
"within",
"eps",
"of",
"an",
"integer",
"or",
"int",
"(",
"resolution",
"(",
"num",
"))",
"."
] | python | train |
graphql-python/graphql-core-next | graphql/execution/execute.py | https://github.com/graphql-python/graphql-core-next/blob/073dce3f002f897d40f9348ffd8f107815160540/graphql/execution/execute.py#L537-L553 | def does_fragment_condition_match(
self,
fragment: Union[FragmentDefinitionNode, InlineFragmentNode],
type_: GraphQLObjectType,
) -> bool:
"""Determine if a fragment is applicable to the given type."""
type_condition_node = fragment.type_condition
if not type_conditio... | [
"def",
"does_fragment_condition_match",
"(",
"self",
",",
"fragment",
":",
"Union",
"[",
"FragmentDefinitionNode",
",",
"InlineFragmentNode",
"]",
",",
"type_",
":",
"GraphQLObjectType",
",",
")",
"->",
"bool",
":",
"type_condition_node",
"=",
"fragment",
".",
"ty... | Determine if a fragment is applicable to the given type. | [
"Determine",
"if",
"a",
"fragment",
"is",
"applicable",
"to",
"the",
"given",
"type",
"."
] | python | train |
mitsei/dlkit | dlkit/json_/resource/objects.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/resource/objects.py#L185-L190 | def _init_map(self, record_types=None, **kwargs):
"""Initialize form map"""
osid_objects.OsidObjectForm._init_map(self, record_types=record_types)
self._my_map['assignedBinIds'] = [str(kwargs['bin_id'])]
self._my_map['group'] = self._group_default
self._my_map['avatarId'] = self.... | [
"def",
"_init_map",
"(",
"self",
",",
"record_types",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"osid_objects",
".",
"OsidObjectForm",
".",
"_init_map",
"(",
"self",
",",
"record_types",
"=",
"record_types",
")",
"self",
".",
"_my_map",
"[",
"'assign... | Initialize form map | [
"Initialize",
"form",
"map"
] | python | train |
yyuu/botornado | boto/route53/record.py | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/route53/record.py#L65-L73 | def to_xml(self):
"""Convert this ResourceRecordSet into XML
to be saved via the ChangeResourceRecordSetsRequest"""
changesXML = ""
for change in self.changes:
changeParams = {"action": change[0], "record": change[1].to_xml()}
changesXML += self.ChangeXML % change... | [
"def",
"to_xml",
"(",
"self",
")",
":",
"changesXML",
"=",
"\"\"",
"for",
"change",
"in",
"self",
".",
"changes",
":",
"changeParams",
"=",
"{",
"\"action\"",
":",
"change",
"[",
"0",
"]",
",",
"\"record\"",
":",
"change",
"[",
"1",
"]",
".",
"to_xml... | Convert this ResourceRecordSet into XML
to be saved via the ChangeResourceRecordSetsRequest | [
"Convert",
"this",
"ResourceRecordSet",
"into",
"XML",
"to",
"be",
"saved",
"via",
"the",
"ChangeResourceRecordSetsRequest"
] | python | train |
panzarino/mlbgame | mlbgame/__init__.py | https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/__init__.py#L211-L215 | def player_stats(game_id):
"""Return dictionary of player stats for game matching the game id."""
# get information for that game
data = mlbgame.stats.player_stats(game_id)
return mlbgame.stats.Stats(data, game_id, True) | [
"def",
"player_stats",
"(",
"game_id",
")",
":",
"# get information for that game",
"data",
"=",
"mlbgame",
".",
"stats",
".",
"player_stats",
"(",
"game_id",
")",
"return",
"mlbgame",
".",
"stats",
".",
"Stats",
"(",
"data",
",",
"game_id",
",",
"True",
")"... | Return dictionary of player stats for game matching the game id. | [
"Return",
"dictionary",
"of",
"player",
"stats",
"for",
"game",
"matching",
"the",
"game",
"id",
"."
] | python | train |
saltstack/salt | salt/modules/bcache.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/bcache.py#L451-L561 | def device(dev, stats=False, config=False, internals=False, superblock=False):
'''
Check the state of a single bcache device
CLI example:
.. code-block:: bash
salt '*' bcache.device bcache0
salt '*' bcache.device /dev/sdc stats=True
:param stats: include statistics
:param set... | [
"def",
"device",
"(",
"dev",
",",
"stats",
"=",
"False",
",",
"config",
"=",
"False",
",",
"internals",
"=",
"False",
",",
"superblock",
"=",
"False",
")",
":",
"result",
"=",
"{",
"}",
"if",
"not",
"_sysfs_attr",
"(",
"_bcpath",
"(",
"dev",
")",
"... | Check the state of a single bcache device
CLI example:
.. code-block:: bash
salt '*' bcache.device bcache0
salt '*' bcache.device /dev/sdc stats=True
:param stats: include statistics
:param settings: include all settings
:param internals: include all internals
:param superblo... | [
"Check",
"the",
"state",
"of",
"a",
"single",
"bcache",
"device"
] | python | train |
arviz-devs/arviz | arviz/data/io_cmdstan.py | https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_cmdstan.py#L400-L568 | def _read_output(path):
"""Read CmdStan output.csv.
Parameters
----------
path : str
Returns
-------
List[DataFrame, DataFrame, List[str], List[str], List[str]]
pandas.DataFrame
Sample data
pandas.DataFrame
Sample stats
List[str]
... | [
"def",
"_read_output",
"(",
"path",
")",
":",
"chains",
"=",
"[",
"]",
"configuration_info",
"=",
"[",
"]",
"adaptation_info",
"=",
"[",
"]",
"timing_info",
"=",
"[",
"]",
"i",
"=",
"0",
"# Read (first) configuration and adaption",
"with",
"open",
"(",
"path... | Read CmdStan output.csv.
Parameters
----------
path : str
Returns
-------
List[DataFrame, DataFrame, List[str], List[str], List[str]]
pandas.DataFrame
Sample data
pandas.DataFrame
Sample stats
List[str]
Configuration information
... | [
"Read",
"CmdStan",
"output",
".",
"csv",
"."
] | python | train |
thomasdelaet/python-velbus | velbus/messages/set_date.py | https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/set_date.py#L35-L46 | def populate(self, priority, address, rtr, data):
"""
:return: None
"""
assert isinstance(data, bytes)
self.needs_low_priority(priority)
self.needs_no_rtr(rtr)
self.needs_data(data, 4)
self.set_attributes(priority, address, rtr)
self._day = data[0]... | [
"def",
"populate",
"(",
"self",
",",
"priority",
",",
"address",
",",
"rtr",
",",
"data",
")",
":",
"assert",
"isinstance",
"(",
"data",
",",
"bytes",
")",
"self",
".",
"needs_low_priority",
"(",
"priority",
")",
"self",
".",
"needs_no_rtr",
"(",
"rtr",
... | :return: None | [
":",
"return",
":",
"None"
] | python | train |
bird-house/twitcher | twitcher/utils.py | https://github.com/bird-house/twitcher/blob/e6a36b3aeeacf44eec537434b0fb87c09ab54b5f/twitcher/utils.py#L51-L62 | def localize_datetime(dt, tz_name='UTC'):
"""Provide a timzeone-aware object for a given datetime and timezone name
"""
tz_aware_dt = dt
if dt.tzinfo is None:
utc = pytz.timezone('UTC')
aware = utc.localize(dt)
timezone = pytz.timezone(tz_name)
tz_aware_dt = aware.astimez... | [
"def",
"localize_datetime",
"(",
"dt",
",",
"tz_name",
"=",
"'UTC'",
")",
":",
"tz_aware_dt",
"=",
"dt",
"if",
"dt",
".",
"tzinfo",
"is",
"None",
":",
"utc",
"=",
"pytz",
".",
"timezone",
"(",
"'UTC'",
")",
"aware",
"=",
"utc",
".",
"localize",
"(",
... | Provide a timzeone-aware object for a given datetime and timezone name | [
"Provide",
"a",
"timzeone",
"-",
"aware",
"object",
"for",
"a",
"given",
"datetime",
"and",
"timezone",
"name"
] | python | valid |
chemlab/chemlab | chemlab/mviewer/api/appeareance.py | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/mviewer/api/appeareance.py#L19-L39 | def change_background(color):
"""Setup the background color to *color*.
Example::
change_background('black')
change_background('white')
change_background('#ffffff')
You can call this function interactively by using::
change_color.interactive()
A new dialog wil... | [
"def",
"change_background",
"(",
"color",
")",
":",
"viewer",
".",
"widget",
".",
"background_color",
"=",
"colors",
".",
"any_to_rgb",
"(",
"color",
")",
"viewer",
".",
"update",
"(",
")"
] | Setup the background color to *color*.
Example::
change_background('black')
change_background('white')
change_background('#ffffff')
You can call this function interactively by using::
change_color.interactive()
A new dialog will popup with a color chooser.
.... | [
"Setup",
"the",
"background",
"color",
"to",
"*",
"color",
"*",
".",
"Example",
"::"
] | python | train |
arne-cl/discoursegraphs | src/discoursegraphs/readwrite/rst/heilman_sagae_2015.py | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/rst/heilman_sagae_2015.py#L210-L223 | def get_tree_type(tree):
"""Return the (sub)tree type: 'root', 'nucleus', 'satellite', 'text' or 'leaf'
Parameters
----------
tree : nltk.tree.ParentedTree
a tree representing a rhetorical structure (or a part of it)
"""
if is_leaf_node(tree):
return SubtreeType.leaf
tree_t... | [
"def",
"get_tree_type",
"(",
"tree",
")",
":",
"if",
"is_leaf_node",
"(",
"tree",
")",
":",
"return",
"SubtreeType",
".",
"leaf",
"tree_type",
"=",
"tree",
".",
"label",
"(",
")",
".",
"lower",
"(",
")",
".",
"split",
"(",
"':'",
")",
"[",
"0",
"]"... | Return the (sub)tree type: 'root', 'nucleus', 'satellite', 'text' or 'leaf'
Parameters
----------
tree : nltk.tree.ParentedTree
a tree representing a rhetorical structure (or a part of it) | [
"Return",
"the",
"(",
"sub",
")",
"tree",
"type",
":",
"root",
"nucleus",
"satellite",
"text",
"or",
"leaf"
] | python | train |
sassoo/goldman | goldman/stores/postgres/store.py | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/stores/postgres/store.py#L381-L407 | def query(self, query, param=None):
""" Perform a SQL based query
This will abort on a failure to communicate with
the database.
:query: string query
:params: parameters for the query
:return: RecordList from psycopg2
"""
with self.conn.cursor() as curs... | [
"def",
"query",
"(",
"self",
",",
"query",
",",
"param",
"=",
"None",
")",
":",
"with",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"as",
"curs",
":",
"print",
"'XXX QUERY'",
",",
"curs",
".",
"mogrify",
"(",
"query",
",",
"param",
")",
"try",
... | Perform a SQL based query
This will abort on a failure to communicate with
the database.
:query: string query
:params: parameters for the query
:return: RecordList from psycopg2 | [
"Perform",
"a",
"SQL",
"based",
"query"
] | python | train |
portfors-lab/sparkle | sparkle/stim/auto_parameter_model.py | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/stim/auto_parameter_model.py#L301-L335 | def ranges(self):
"""The expanded lists of values generated from the parameter fields
:returns: list<list>, outer list is for each parameter, inner loops are that
parameter's values to loop through
"""
steps = []
for p in self._parameters:
# inclusive range
... | [
"def",
"ranges",
"(",
"self",
")",
":",
"steps",
"=",
"[",
"]",
"for",
"p",
"in",
"self",
".",
"_parameters",
":",
"# inclusive range",
"if",
"p",
"[",
"'parameter'",
"]",
"==",
"'filename'",
":",
"steps",
".",
"append",
"(",
"p",
"[",
"'names'",
"]"... | The expanded lists of values generated from the parameter fields
:returns: list<list>, outer list is for each parameter, inner loops are that
parameter's values to loop through | [
"The",
"expanded",
"lists",
"of",
"values",
"generated",
"from",
"the",
"parameter",
"fields"
] | python | train |
jobovy/galpy | galpy/util/bovy_plot.py | https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/util/bovy_plot.py#L1083-L1114 | def _add_ticks(xticks=True,yticks=True):
"""
NAME:
_add_ticks
PURPOSE:
add minor axis ticks to a plot
INPUT:
(none; works on the current axes)
OUTPUT:
(none; works on the current axes)
HISTORY:
2009-12-23 - Written - Bovy (NYU)
"""
ax=pyplot.g... | [
"def",
"_add_ticks",
"(",
"xticks",
"=",
"True",
",",
"yticks",
"=",
"True",
")",
":",
"ax",
"=",
"pyplot",
".",
"gca",
"(",
")",
"if",
"xticks",
":",
"xstep",
"=",
"ax",
".",
"xaxis",
".",
"get_majorticklocs",
"(",
")",
"xstep",
"=",
"xstep",
"[",... | NAME:
_add_ticks
PURPOSE:
add minor axis ticks to a plot
INPUT:
(none; works on the current axes)
OUTPUT:
(none; works on the current axes)
HISTORY:
2009-12-23 - Written - Bovy (NYU) | [
"NAME",
":"
] | python | train |
SectorLabs/django-postgres-extra | psqlextra/backend/hstore_required.py | https://github.com/SectorLabs/django-postgres-extra/blob/eef2ed5504d225858d4e4f5d77a838082ca6053e/psqlextra/backend/hstore_required.py#L134-L149 | def _rename_hstore_required(self, old_table_name, new_table_name,
old_field, new_field, key):
"""Renames an existing REQUIRED CONSTRAINT for the specified
hstore key."""
old_name = self._required_constraint_name(
old_table_name, old_field, key)
... | [
"def",
"_rename_hstore_required",
"(",
"self",
",",
"old_table_name",
",",
"new_table_name",
",",
"old_field",
",",
"new_field",
",",
"key",
")",
":",
"old_name",
"=",
"self",
".",
"_required_constraint_name",
"(",
"old_table_name",
",",
"old_field",
",",
"key",
... | Renames an existing REQUIRED CONSTRAINT for the specified
hstore key. | [
"Renames",
"an",
"existing",
"REQUIRED",
"CONSTRAINT",
"for",
"the",
"specified",
"hstore",
"key",
"."
] | python | test |
Alignak-monitoring/alignak | alignak/scheduler.py | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/scheduler.py#L2203-L2227 | def find_item_by_id(self, object_id):
"""Get item based on its id or uuid
:param object_id:
:type object_id: int | str
:return:
:rtype: alignak.objects.item.Item | None
"""
# Item id may be an item
if isinstance(object_id, Item):
return object... | [
"def",
"find_item_by_id",
"(",
"self",
",",
"object_id",
")",
":",
"# Item id may be an item",
"if",
"isinstance",
"(",
"object_id",
",",
"Item",
")",
":",
"return",
"object_id",
"# Item id should be a uuid string",
"if",
"not",
"isinstance",
"(",
"object_id",
",",
... | Get item based on its id or uuid
:param object_id:
:type object_id: int | str
:return:
:rtype: alignak.objects.item.Item | None | [
"Get",
"item",
"based",
"on",
"its",
"id",
"or",
"uuid"
] | python | train |
spacetelescope/stsci.tools | lib/stsci/tools/configobj.py | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/configobj.py#L680-L693 | def pop(self, key, default=MISSING):
"""
'D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
If key is not found, d is returned if given, otherwise KeyError is raised'
"""
try:
val = self[key]
except KeyError:
if default is... | [
"def",
"pop",
"(",
"self",
",",
"key",
",",
"default",
"=",
"MISSING",
")",
":",
"try",
":",
"val",
"=",
"self",
"[",
"key",
"]",
"except",
"KeyError",
":",
"if",
"default",
"is",
"MISSING",
":",
"raise",
"val",
"=",
"default",
"else",
":",
"del",
... | 'D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
If key is not found, d is returned if given, otherwise KeyError is raised' | [
"D",
".",
"pop",
"(",
"k",
"[",
"d",
"]",
")",
"-",
">",
"v",
"remove",
"specified",
"key",
"and",
"return",
"the",
"corresponding",
"value",
".",
"If",
"key",
"is",
"not",
"found",
"d",
"is",
"returned",
"if",
"given",
"otherwise",
"KeyError",
"is",... | python | train |
jealous/stockstats | stockstats.py | https://github.com/jealous/stockstats/blob/a479a504ea1906955feeb8519c34ef40eb48ec9b/stockstats.py#L233-L250 | def _get_rsv(df, n_days):
""" Calculate the RSV (Raw Stochastic Value) within N days
This value is essential for calculating KDJs
Current day is included in N
:param df: data
:param n_days: N days
:return: None
"""
n_days = int(n_days)
c... | [
"def",
"_get_rsv",
"(",
"df",
",",
"n_days",
")",
":",
"n_days",
"=",
"int",
"(",
"n_days",
")",
"column_name",
"=",
"'rsv_{}'",
".",
"format",
"(",
"n_days",
")",
"low_min",
"=",
"df",
"[",
"'low'",
"]",
".",
"rolling",
"(",
"min_periods",
"=",
"1",... | Calculate the RSV (Raw Stochastic Value) within N days
This value is essential for calculating KDJs
Current day is included in N
:param df: data
:param n_days: N days
:return: None | [
"Calculate",
"the",
"RSV",
"(",
"Raw",
"Stochastic",
"Value",
")",
"within",
"N",
"days",
"This",
"value",
"is",
"essential",
"for",
"calculating",
"KDJs",
"Current",
"day",
"is",
"included",
"in",
"N",
":",
"param",
"df",
":",
"data",
":",
"param",
"n_d... | python | train |
aio-libs/aioftp | aioftp/client.py | https://github.com/aio-libs/aioftp/blob/b45395b1aba41301b898040acade7010e6878a08/aioftp/client.py#L198-L215 | def check_codes(self, expected_codes, received_code, info):
"""
Checks if any of expected matches received.
:param expected_codes: tuple of expected codes
:type expected_codes: :py:class:`tuple`
:param received_code: received code for matching
:type received_code: :py:c... | [
"def",
"check_codes",
"(",
"self",
",",
"expected_codes",
",",
"received_code",
",",
"info",
")",
":",
"if",
"not",
"any",
"(",
"map",
"(",
"received_code",
".",
"matches",
",",
"expected_codes",
")",
")",
":",
"raise",
"errors",
".",
"StatusCodeError",
"(... | Checks if any of expected matches received.
:param expected_codes: tuple of expected codes
:type expected_codes: :py:class:`tuple`
:param received_code: received code for matching
:type received_code: :py:class:`aioftp.Code`
:param info: list of response lines from server
... | [
"Checks",
"if",
"any",
"of",
"expected",
"matches",
"received",
"."
] | python | valid |
aws/sagemaker-python-sdk | src/sagemaker/utils.py | https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/utils.py#L46-L62 | def name_from_base(base, max_length=63, short=False):
"""Append a timestamp to the provided string.
This function assures that the total length of the resulting string is not
longer than the specified max length, trimming the input parameter if necessary.
Args:
base (str): String used as prefi... | [
"def",
"name_from_base",
"(",
"base",
",",
"max_length",
"=",
"63",
",",
"short",
"=",
"False",
")",
":",
"timestamp",
"=",
"sagemaker_short_timestamp",
"(",
")",
"if",
"short",
"else",
"sagemaker_timestamp",
"(",
")",
"trimmed_base",
"=",
"base",
"[",
":",
... | Append a timestamp to the provided string.
This function assures that the total length of the resulting string is not
longer than the specified max length, trimming the input parameter if necessary.
Args:
base (str): String used as prefix to generate the unique name.
max_length (int): Maxi... | [
"Append",
"a",
"timestamp",
"to",
"the",
"provided",
"string",
"."
] | python | train |
dbcli/cli_helpers | cli_helpers/tabular_output/preprocessors.py | https://github.com/dbcli/cli_helpers/blob/3ebd891ac0c02bad061182dbcb54a47fb21980ae/cli_helpers/tabular_output/preprocessors.py#L27-L40 | def convert_to_string(data, headers, **_):
"""Convert all *data* and *headers* to strings.
Binary data that cannot be decoded is converted to a hexadecimal
representation via :func:`binascii.hexlify`.
:param iterable data: An :term:`iterable` (e.g. list) of rows.
:param iterable headers: The colum... | [
"def",
"convert_to_string",
"(",
"data",
",",
"headers",
",",
"*",
"*",
"_",
")",
":",
"return",
"(",
"(",
"[",
"utils",
".",
"to_string",
"(",
"v",
")",
"for",
"v",
"in",
"row",
"]",
"for",
"row",
"in",
"data",
")",
",",
"[",
"utils",
".",
"to... | Convert all *data* and *headers* to strings.
Binary data that cannot be decoded is converted to a hexadecimal
representation via :func:`binascii.hexlify`.
:param iterable data: An :term:`iterable` (e.g. list) of rows.
:param iterable headers: The column headers.
:return: The processed data and hea... | [
"Convert",
"all",
"*",
"data",
"*",
"and",
"*",
"headers",
"*",
"to",
"strings",
"."
] | python | test |
inveniosoftware/invenio-oauthclient | invenio_oauthclient/views/client.py | https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/views/client.py#L97-L128 | def authorized(remote_app=None):
"""Authorized handler callback."""
if remote_app not in current_oauthclient.handlers:
return abort(404)
state_token = request.args.get('state')
# Verify state parameter
try:
assert state_token
# Checks authenticity and integrity of state and... | [
"def",
"authorized",
"(",
"remote_app",
"=",
"None",
")",
":",
"if",
"remote_app",
"not",
"in",
"current_oauthclient",
".",
"handlers",
":",
"return",
"abort",
"(",
"404",
")",
"state_token",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'state'",
")",
... | Authorized handler callback. | [
"Authorized",
"handler",
"callback",
"."
] | python | train |
GoogleCloudPlatform/datastore-ndb-python | ndb/model.py | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/model.py#L3005-L3014 | def _check_initialized(self):
"""Internal helper to check for uninitialized properties.
Raises:
BadValueError if it finds any.
"""
baddies = self._find_uninitialized()
if baddies:
raise datastore_errors.BadValueError(
'Entity has uninitialized properties: %s' % ', '.join(baddi... | [
"def",
"_check_initialized",
"(",
"self",
")",
":",
"baddies",
"=",
"self",
".",
"_find_uninitialized",
"(",
")",
"if",
"baddies",
":",
"raise",
"datastore_errors",
".",
"BadValueError",
"(",
"'Entity has uninitialized properties: %s'",
"%",
"', '",
".",
"join",
"... | Internal helper to check for uninitialized properties.
Raises:
BadValueError if it finds any. | [
"Internal",
"helper",
"to",
"check",
"for",
"uninitialized",
"properties",
"."
] | python | train |
Kautenja/nes-py | nes_py/nes_env.py | https://github.com/Kautenja/nes-py/blob/a113885198d418f38fcf24b8f79ac508975788c2/nes_py/nes_env.py#L271-L307 | def step(self, action):
"""
Run one frame of the NES and return the relevant observation data.
Args:
action (byte): the bitmap determining which buttons to press
Returns:
a tuple of:
- state (np.ndarray): next frame as a result of the given action
... | [
"def",
"step",
"(",
"self",
",",
"action",
")",
":",
"# if the environment is done, raise an error",
"if",
"self",
".",
"done",
":",
"raise",
"ValueError",
"(",
"'cannot step in a done environment! call `reset`'",
")",
"# set the action on the controller",
"self",
".",
"c... | Run one frame of the NES and return the relevant observation data.
Args:
action (byte): the bitmap determining which buttons to press
Returns:
a tuple of:
- state (np.ndarray): next frame as a result of the given action
- reward (float) : amount of rewar... | [
"Run",
"one",
"frame",
"of",
"the",
"NES",
"and",
"return",
"the",
"relevant",
"observation",
"data",
"."
] | python | train |
tensorflow/tensor2tensor | tensor2tensor/models/research/lm_experiments.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/lm_experiments.py#L141-L149 | def lmx_moe_h1k_f8k_x16():
"""Transformer with mixture of experts. 890M Params."""
hparams = lmx_h1k_f4k()
hparams.filter_size = 8192
hparams.ffn_layer = "local_moe_tpu"
hparams.moe_num_experts = 16
hparams.weight_dtype = "bfloat16"
hparams.batch_size = 8192
return hparams | [
"def",
"lmx_moe_h1k_f8k_x16",
"(",
")",
":",
"hparams",
"=",
"lmx_h1k_f4k",
"(",
")",
"hparams",
".",
"filter_size",
"=",
"8192",
"hparams",
".",
"ffn_layer",
"=",
"\"local_moe_tpu\"",
"hparams",
".",
"moe_num_experts",
"=",
"16",
"hparams",
".",
"weight_dtype",... | Transformer with mixture of experts. 890M Params. | [
"Transformer",
"with",
"mixture",
"of",
"experts",
".",
"890M",
"Params",
"."
] | python | train |
senaite/senaite.core | bika/lims/content/worksheet.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/content/worksheet.py#L532-L583 | def get_suitable_slot_for_duplicate(self, src_slot):
"""Returns the suitable position for a duplicate analysis, taking into
account if there is a WorksheetTemplate assigned to this worksheet.
By default, returns a new slot at the end of the worksheet unless there
is a slot defined for a... | [
"def",
"get_suitable_slot_for_duplicate",
"(",
"self",
",",
"src_slot",
")",
":",
"slot_from",
"=",
"to_int",
"(",
"src_slot",
",",
"0",
")",
"if",
"slot_from",
"<",
"1",
":",
"return",
"-",
"1",
"# Are the analyses from src_slot suitable for duplicates creation?",
... | Returns the suitable position for a duplicate analysis, taking into
account if there is a WorksheetTemplate assigned to this worksheet.
By default, returns a new slot at the end of the worksheet unless there
is a slot defined for a duplicate of the src_slot in the worksheet
template lay... | [
"Returns",
"the",
"suitable",
"position",
"for",
"a",
"duplicate",
"analysis",
"taking",
"into",
"account",
"if",
"there",
"is",
"a",
"WorksheetTemplate",
"assigned",
"to",
"this",
"worksheet",
"."
] | python | train |
xeroc/python-graphenelib | graphenecommon/amount.py | https://github.com/xeroc/python-graphenelib/blob/8bb5396bc79998ee424cf3813af478304173f3a6/graphenecommon/amount.py#L134-L141 | def copy(self):
""" Copy the instance and make sure not to use a reference
"""
return self.__class__(
amount=self["amount"],
asset=self["asset"].copy(),
blockchain_instance=self.blockchain,
) | [
"def",
"copy",
"(",
"self",
")",
":",
"return",
"self",
".",
"__class__",
"(",
"amount",
"=",
"self",
"[",
"\"amount\"",
"]",
",",
"asset",
"=",
"self",
"[",
"\"asset\"",
"]",
".",
"copy",
"(",
")",
",",
"blockchain_instance",
"=",
"self",
".",
"bloc... | Copy the instance and make sure not to use a reference | [
"Copy",
"the",
"instance",
"and",
"make",
"sure",
"not",
"to",
"use",
"a",
"reference"
] | python | valid |
SoCo/SoCo | soco/music_services/music_service.py | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/music_services/music_service.py#L76-L125 | def get_soap_header(self):
"""Generate the SOAP authentication header for the related service.
This header contains all the necessary authentication details.
Returns:
str: A string representation of the XML content of the SOAP
header.
"""
# Accordin... | [
"def",
"get_soap_header",
"(",
"self",
")",
":",
"# According to the SONOS SMAPI, this header must be sent with all",
"# SOAP requests. Building this is an expensive operation (though",
"# occasionally necessary), so f we have a cached value, return it",
"if",
"self",
".",
"_cached_soap_head... | Generate the SOAP authentication header for the related service.
This header contains all the necessary authentication details.
Returns:
str: A string representation of the XML content of the SOAP
header. | [
"Generate",
"the",
"SOAP",
"authentication",
"header",
"for",
"the",
"related",
"service",
"."
] | python | train |
Nukesor/pueue | pueue/daemon/daemon.py | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L128-L150 | def read_config(self):
"""Read a previous configuration file or create a new with default values."""
config_file = os.path.join(self.config_dir, 'pueue.ini')
self.config = configparser.ConfigParser()
# Try to get configuration file and return it
# If this doesn't work, a new defa... | [
"def",
"read_config",
"(",
"self",
")",
":",
"config_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"config_dir",
",",
"'pueue.ini'",
")",
"self",
".",
"config",
"=",
"configparser",
".",
"ConfigParser",
"(",
")",
"# Try to get configuration f... | Read a previous configuration file or create a new with default values. | [
"Read",
"a",
"previous",
"configuration",
"file",
"or",
"create",
"a",
"new",
"with",
"default",
"values",
"."
] | python | train |
assemblerflow/flowcraft | flowcraft/generator/process.py | https://github.com/assemblerflow/flowcraft/blob/fc3f4bddded1efc76006600016dc71a06dd908c0/flowcraft/generator/process.py#L518-L567 | def set_secondary_channel(self, source, channel_list):
""" General purpose method for setting a secondary channel
This method allows a given source channel to be forked into one or
more channels and sets those forks in the :py:attr:`Process.forks`
attribute. Both the source and the chan... | [
"def",
"set_secondary_channel",
"(",
"self",
",",
"source",
",",
"channel_list",
")",
":",
"logger",
".",
"debug",
"(",
"\"Setting secondary channel for source '{}': {}\"",
".",
"format",
"(",
"source",
",",
"channel_list",
")",
")",
"source",
"=",
"\"{}_{}\"",
".... | General purpose method for setting a secondary channel
This method allows a given source channel to be forked into one or
more channels and sets those forks in the :py:attr:`Process.forks`
attribute. Both the source and the channels in the ``channel_list``
argument must be the final cha... | [
"General",
"purpose",
"method",
"for",
"setting",
"a",
"secondary",
"channel"
] | python | test |
rehandalal/buchner | buchner/helpers.py | https://github.com/rehandalal/buchner/blob/dc22a61c493b9d4a74d76e8b42a319aa13e385f3/buchner/helpers.py#L13-L19 | def json_requested():
"""Check if json is the preferred output format for the request."""
best = request.accept_mimetypes.best_match(
['application/json', 'text/html'])
return (best == 'application/json' and
request.accept_mimetypes[best] >
request.accept_mimetypes['text/html... | [
"def",
"json_requested",
"(",
")",
":",
"best",
"=",
"request",
".",
"accept_mimetypes",
".",
"best_match",
"(",
"[",
"'application/json'",
",",
"'text/html'",
"]",
")",
"return",
"(",
"best",
"==",
"'application/json'",
"and",
"request",
".",
"accept_mimetypes"... | Check if json is the preferred output format for the request. | [
"Check",
"if",
"json",
"is",
"the",
"preferred",
"output",
"format",
"for",
"the",
"request",
"."
] | python | train |
ToFuProject/tofu | tofu/geom/_comp.py | https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/geom/_comp.py#L45-L104 | def _Struct_set_Poly(Poly, pos=None, extent=None, arrayorder='C',
Type='Tor', Clock=False):
""" Compute geometrical attributes of a Struct object """
# Make Poly closed, counter-clockwise, with '(cc,N)' layout and arrayorder
Poly = _GG.Poly_Order(Poly, order='C', Clock=False,
... | [
"def",
"_Struct_set_Poly",
"(",
"Poly",
",",
"pos",
"=",
"None",
",",
"extent",
"=",
"None",
",",
"arrayorder",
"=",
"'C'",
",",
"Type",
"=",
"'Tor'",
",",
"Clock",
"=",
"False",
")",
":",
"# Make Poly closed, counter-clockwise, with '(cc,N)' layout and arrayorder... | Compute geometrical attributes of a Struct object | [
"Compute",
"geometrical",
"attributes",
"of",
"a",
"Struct",
"object"
] | python | train |
python-cmd2/cmd2 | cmd2/cmd2.py | https://github.com/python-cmd2/cmd2/blob/b22c0bd891ed08c8b09df56df9d91f48166a5e2a/cmd2/cmd2.py#L3763-L3784 | def enable_command(self, command: str) -> None:
"""
Enable a command by restoring its functions
:param command: the command being enabled
"""
# If the commands is already enabled, then return
if command not in self.disabled_commands:
return
help_func_... | [
"def",
"enable_command",
"(",
"self",
",",
"command",
":",
"str",
")",
"->",
"None",
":",
"# If the commands is already enabled, then return",
"if",
"command",
"not",
"in",
"self",
".",
"disabled_commands",
":",
"return",
"help_func_name",
"=",
"HELP_FUNC_PREFIX",
"... | Enable a command by restoring its functions
:param command: the command being enabled | [
"Enable",
"a",
"command",
"by",
"restoring",
"its",
"functions",
":",
"param",
"command",
":",
"the",
"command",
"being",
"enabled"
] | python | train |
senaite/senaite.core | bika/lims/content/client.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/content/client.py#L265-L283 | def manage_delObjects(self, ids=None, REQUEST=None):
"""Overrides parent function. If the ids passed in are from Attachment
types, the function ignores the DeleteObjects permission. For the rest
of types, it works as usual (checks the permission)
"""
if ids is None:
i... | [
"def",
"manage_delObjects",
"(",
"self",
",",
"ids",
"=",
"None",
",",
"REQUEST",
"=",
"None",
")",
":",
"if",
"ids",
"is",
"None",
":",
"ids",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"ids",
",",
"basestring",
")",
":",
"ids",
"=",
"[",
"ids",
"]... | Overrides parent function. If the ids passed in are from Attachment
types, the function ignores the DeleteObjects permission. For the rest
of types, it works as usual (checks the permission) | [
"Overrides",
"parent",
"function",
".",
"If",
"the",
"ids",
"passed",
"in",
"are",
"from",
"Attachment",
"types",
"the",
"function",
"ignores",
"the",
"DeleteObjects",
"permission",
".",
"For",
"the",
"rest",
"of",
"types",
"it",
"works",
"as",
"usual",
"(",... | python | train |
GNS3/gns3-server | gns3server/compute/dynamips/nodes/router.py | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/router.py#L638-L651 | def set_clock_divisor(self, clock_divisor):
"""
Sets the clock divisor value. The higher is the value, the faster is the clock in the
virtual machine. The default is 4, but it is often required to adjust it.
:param clock_divisor: clock divisor value (integer)
"""
yield ... | [
"def",
"set_clock_divisor",
"(",
"self",
",",
"clock_divisor",
")",
":",
"yield",
"from",
"self",
".",
"_hypervisor",
".",
"send",
"(",
"'vm set_clock_divisor \"{name}\" {clock}'",
".",
"format",
"(",
"name",
"=",
"self",
".",
"_name",
",",
"clock",
"=",
"cloc... | Sets the clock divisor value. The higher is the value, the faster is the clock in the
virtual machine. The default is 4, but it is often required to adjust it.
:param clock_divisor: clock divisor value (integer) | [
"Sets",
"the",
"clock",
"divisor",
"value",
".",
"The",
"higher",
"is",
"the",
"value",
"the",
"faster",
"is",
"the",
"clock",
"in",
"the",
"virtual",
"machine",
".",
"The",
"default",
"is",
"4",
"but",
"it",
"is",
"often",
"required",
"to",
"adjust",
... | python | train |
rhayes777/PyAutoFit | autofit/tools/pipeline.py | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/tools/pipeline.py#L38-L53 | def add(self, phase_name, result):
"""
Add the result of a phase.
Parameters
----------
phase_name: str
The name of the phase
result
The result of that phase
"""
if phase_name in self.__result_dict:
raise exc.PipelineEx... | [
"def",
"add",
"(",
"self",
",",
"phase_name",
",",
"result",
")",
":",
"if",
"phase_name",
"in",
"self",
".",
"__result_dict",
":",
"raise",
"exc",
".",
"PipelineException",
"(",
"\"Results from a phase called {} already exist in the pipeline\"",
".",
"format",
"(",... | Add the result of a phase.
Parameters
----------
phase_name: str
The name of the phase
result
The result of that phase | [
"Add",
"the",
"result",
"of",
"a",
"phase",
"."
] | python | train |
andy-z/ged4py | ged4py/detail/name.py | https://github.com/andy-z/ged4py/blob/d0e0cceaadf0a84cbf052705e3c27303b12e1757/ged4py/detail/name.py#L7-L35 | def split_name(name):
"""Extracts pieces of name from full name string.
Full name can have one of these formats:
<NAME_TEXT> |
/<NAME_TEXT>/ |
<NAME_TEXT> /<NAME_TEXT>/ |
/<NAME_TEXT>/ <NAME_TEXT> |
<NAME_TEXT> /<NAME_TEXT>/ <NAME_TEXT>
<NAME_TEXT> can include almos... | [
"def",
"split_name",
"(",
"name",
")",
":",
"given1",
",",
"_",
",",
"rem",
"=",
"name",
".",
"partition",
"(",
"\"/\"",
")",
"surname",
",",
"_",
",",
"given2",
"=",
"rem",
".",
"partition",
"(",
"\"/\"",
")",
"return",
"given1",
".",
"strip",
"("... | Extracts pieces of name from full name string.
Full name can have one of these formats:
<NAME_TEXT> |
/<NAME_TEXT>/ |
<NAME_TEXT> /<NAME_TEXT>/ |
/<NAME_TEXT>/ <NAME_TEXT> |
<NAME_TEXT> /<NAME_TEXT>/ <NAME_TEXT>
<NAME_TEXT> can include almost anything excluding commas, ... | [
"Extracts",
"pieces",
"of",
"name",
"from",
"full",
"name",
"string",
"."
] | python | train |
tensorflow/cleverhans | examples/multigpu_advtrain/model.py | https://github.com/tensorflow/cleverhans/blob/97488e215760547b81afc53f5e5de8ba7da5bd98/examples/multigpu_advtrain/model.py#L206-L214 | def set_device(self, device_name):
"""
Set the device before the next fprop to create a new graph on the
specified device.
"""
device_name = unify_device_name(device_name)
self.device_name = device_name
for layer in self.layers:
layer.device_name = device_name | [
"def",
"set_device",
"(",
"self",
",",
"device_name",
")",
":",
"device_name",
"=",
"unify_device_name",
"(",
"device_name",
")",
"self",
".",
"device_name",
"=",
"device_name",
"for",
"layer",
"in",
"self",
".",
"layers",
":",
"layer",
".",
"device_name",
"... | Set the device before the next fprop to create a new graph on the
specified device. | [
"Set",
"the",
"device",
"before",
"the",
"next",
"fprop",
"to",
"create",
"a",
"new",
"graph",
"on",
"the",
"specified",
"device",
"."
] | python | train |
serhatbolsu/robotframework-appiumlibrary | AppiumLibrary/keywords/_element.py | https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_element.py#L82-L88 | def input_value(self, locator, text):
"""Sets the given value into text field identified by `locator`. This is an IOS only keyword, input value makes use of set_value
See `introduction` for details about locating elements.
"""
self._info("Setting text '%s' into text field '%s'" % (... | [
"def",
"input_value",
"(",
"self",
",",
"locator",
",",
"text",
")",
":",
"self",
".",
"_info",
"(",
"\"Setting text '%s' into text field '%s'\"",
"%",
"(",
"text",
",",
"locator",
")",
")",
"self",
".",
"_element_input_value_by_locator",
"(",
"locator",
",",
... | Sets the given value into text field identified by `locator`. This is an IOS only keyword, input value makes use of set_value
See `introduction` for details about locating elements. | [
"Sets",
"the",
"given",
"value",
"into",
"text",
"field",
"identified",
"by",
"locator",
".",
"This",
"is",
"an",
"IOS",
"only",
"keyword",
"input",
"value",
"makes",
"use",
"of",
"set_value",
"See",
"introduction",
"for",
"details",
"about",
"locating",
"el... | python | train |
saltstack/salt | salt/modules/xfs.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xfs.py#L275-L297 | def _xfs_prune_output(out, uuid):
'''
Parse prune output.
'''
data = {}
cnt = []
cutpoint = False
for line in [l.strip() for l in out.split("\n") if l]:
if line.startswith("-"):
if cutpoint:
break
else:
cutpoint = True
... | [
"def",
"_xfs_prune_output",
"(",
"out",
",",
"uuid",
")",
":",
"data",
"=",
"{",
"}",
"cnt",
"=",
"[",
"]",
"cutpoint",
"=",
"False",
"for",
"line",
"in",
"[",
"l",
".",
"strip",
"(",
")",
"for",
"l",
"in",
"out",
".",
"split",
"(",
"\"\\n\"",
... | Parse prune output. | [
"Parse",
"prune",
"output",
"."
] | python | train |
idlesign/django-admirarchy | admirarchy/utils.py | https://github.com/idlesign/django-admirarchy/blob/723e4fd212fdebcc156492cb16b9d65356f5ca73/admirarchy/utils.py#L307-L349 | def hook_get_results(self, changelist):
"""Triggered by `ChangeList.get_results()`."""
# Poor NestedSet guys they've punished themselves once chosen that approach,
# and now we punish them again with all those DB hits.
result_list = list(changelist.result_list)
# Get children ... | [
"def",
"hook_get_results",
"(",
"self",
",",
"changelist",
")",
":",
"# Poor NestedSet guys they've punished themselves once chosen that approach,",
"# and now we punish them again with all those DB hits.",
"result_list",
"=",
"list",
"(",
"changelist",
".",
"result_list",
")",
"... | Triggered by `ChangeList.get_results()`. | [
"Triggered",
"by",
"ChangeList",
".",
"get_results",
"()",
"."
] | python | train |
boundary/pulse-api-cli | boundary/plugin_get.py | https://github.com/boundary/pulse-api-cli/blob/b01ca65b442eed19faac309c9d62bbc3cb2c098f/boundary/plugin_get.py#L32-L40 | def get_arguments(self):
"""
Extracts the specific arguments of this CLI
"""
ApiCli.get_arguments(self)
if self.args.plugin_name is not None:
self.plugin_name = self.args.plugin_name
self.path = "v1/plugins/{0}".format(self.plugin_name) | [
"def",
"get_arguments",
"(",
"self",
")",
":",
"ApiCli",
".",
"get_arguments",
"(",
"self",
")",
"if",
"self",
".",
"args",
".",
"plugin_name",
"is",
"not",
"None",
":",
"self",
".",
"plugin_name",
"=",
"self",
".",
"args",
".",
"plugin_name",
"self",
... | Extracts the specific arguments of this CLI | [
"Extracts",
"the",
"specific",
"arguments",
"of",
"this",
"CLI"
] | python | test |
pandas-dev/pandas | pandas/core/nanops.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/nanops.py#L1203-L1232 | def _nanpercentile_1d(values, mask, q, na_value, interpolation):
"""
Wraper for np.percentile that skips missing values, specialized to
1-dimensional case.
Parameters
----------
values : array over which to find quantiles
mask : ndarray[bool]
locations in values that should be consi... | [
"def",
"_nanpercentile_1d",
"(",
"values",
",",
"mask",
",",
"q",
",",
"na_value",
",",
"interpolation",
")",
":",
"# mask is Union[ExtensionArray, ndarray]",
"values",
"=",
"values",
"[",
"~",
"mask",
"]",
"if",
"len",
"(",
"values",
")",
"==",
"0",
":",
... | Wraper for np.percentile that skips missing values, specialized to
1-dimensional case.
Parameters
----------
values : array over which to find quantiles
mask : ndarray[bool]
locations in values that should be considered missing
q : scalar or array of quantile indices to find
na_valu... | [
"Wraper",
"for",
"np",
".",
"percentile",
"that",
"skips",
"missing",
"values",
"specialized",
"to",
"1",
"-",
"dimensional",
"case",
"."
] | python | train |
senaite/senaite.jsonapi | src/senaite/jsonapi/fieldmanagers.py | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/fieldmanagers.py#L201-L213 | def json_data(self, instance, default=None):
"""Get a JSON compatible value
"""
value = self.get(instance)
out = []
for rel in value:
if rel.isBroken():
logger.warn("Skipping broken relation {}".format(repr(rel)))
continue
... | [
"def",
"json_data",
"(",
"self",
",",
"instance",
",",
"default",
"=",
"None",
")",
":",
"value",
"=",
"self",
".",
"get",
"(",
"instance",
")",
"out",
"=",
"[",
"]",
"for",
"rel",
"in",
"value",
":",
"if",
"rel",
".",
"isBroken",
"(",
")",
":",
... | Get a JSON compatible value | [
"Get",
"a",
"JSON",
"compatible",
"value"
] | python | train |
JoeVirtual/KonFoo | konfoo/core.py | https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L2000-L2006 | def name(self):
""" Returns the type name of the `Stream` field (read-only)."""
size = len(self)
if size > 0:
return self.item_type.name.capitalize() + str(size)
else:
return self.item_type.name.capitalize() | [
"def",
"name",
"(",
"self",
")",
":",
"size",
"=",
"len",
"(",
"self",
")",
"if",
"size",
">",
"0",
":",
"return",
"self",
".",
"item_type",
".",
"name",
".",
"capitalize",
"(",
")",
"+",
"str",
"(",
"size",
")",
"else",
":",
"return",
"self",
... | Returns the type name of the `Stream` field (read-only). | [
"Returns",
"the",
"type",
"name",
"of",
"the",
"Stream",
"field",
"(",
"read",
"-",
"only",
")",
"."
] | python | train |
Microsoft/knack | knack/log.py | https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/log.py#L143-L152 | def _determine_verbose_level(self, args):
""" Get verbose level by reading the arguments. """
verbose_level = 0
for arg in args:
if arg == CLILogging.VERBOSE_FLAG:
verbose_level += 1
elif arg == CLILogging.DEBUG_FLAG:
verbose_level += 2
... | [
"def",
"_determine_verbose_level",
"(",
"self",
",",
"args",
")",
":",
"verbose_level",
"=",
"0",
"for",
"arg",
"in",
"args",
":",
"if",
"arg",
"==",
"CLILogging",
".",
"VERBOSE_FLAG",
":",
"verbose_level",
"+=",
"1",
"elif",
"arg",
"==",
"CLILogging",
"."... | Get verbose level by reading the arguments. | [
"Get",
"verbose",
"level",
"by",
"reading",
"the",
"arguments",
"."
] | python | train |
ayust/kitnirc | kitnirc/contrib/commands.py | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/contrib/commands.py#L84-L97 | def check_for_interest(self, client, recipient, message):
"""Determine whether this line is addressing us."""
for prefix in self.prefixes:
if message.startswith(prefix):
return True, message[len(prefix):]
# Don't require a prefix if addressed in PM.
# This co... | [
"def",
"check_for_interest",
"(",
"self",
",",
"client",
",",
"recipient",
",",
"message",
")",
":",
"for",
"prefix",
"in",
"self",
".",
"prefixes",
":",
"if",
"message",
".",
"startswith",
"(",
"prefix",
")",
":",
"return",
"True",
",",
"message",
"[",
... | Determine whether this line is addressing us. | [
"Determine",
"whether",
"this",
"line",
"is",
"addressing",
"us",
"."
] | python | train |
PiotrDabkowski/Js2Py | js2py/internals/operations.py | https://github.com/PiotrDabkowski/Js2Py/blob/c0fa43f5679cf91ca8986c5747fcb07a433dc584/js2py/internals/operations.py#L227-L253 | def abstract_equality_op(self, other):
''' returns the result of JS == compare.
result is PyJs type: bool'''
tx, ty = Type(self), Type(other)
if tx == ty:
if tx == 'Undefined' or tx == 'Null':
return True
if tx == 'Number' or tx == 'String' or tx == 'Boolean':
... | [
"def",
"abstract_equality_op",
"(",
"self",
",",
"other",
")",
":",
"tx",
",",
"ty",
"=",
"Type",
"(",
"self",
")",
",",
"Type",
"(",
"other",
")",
"if",
"tx",
"==",
"ty",
":",
"if",
"tx",
"==",
"'Undefined'",
"or",
"tx",
"==",
"'Null'",
":",
"re... | returns the result of JS == compare.
result is PyJs type: bool | [
"returns",
"the",
"result",
"of",
"JS",
"==",
"compare",
".",
"result",
"is",
"PyJs",
"type",
":",
"bool"
] | python | valid |
Microsoft/azure-devops-python-api | azure-devops/azure/devops/v5_1/work_item_tracking/work_item_tracking_client.py | https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_1/work_item_tracking/work_item_tracking_client.py#L1552-L1573 | def read_reporting_discussions(self, project=None, continuation_token=None, max_page_size=None):
"""ReadReportingDiscussions.
[Preview API]
:param str project: Project ID or project name
:param str continuation_token:
:param int max_page_size:
:rtype: :class:`<ReportingWo... | [
"def",
"read_reporting_discussions",
"(",
"self",
",",
"project",
"=",
"None",
",",
"continuation_token",
"=",
"None",
",",
"max_page_size",
"=",
"None",
")",
":",
"route_values",
"=",
"{",
"}",
"if",
"project",
"is",
"not",
"None",
":",
"route_values",
"[",... | ReadReportingDiscussions.
[Preview API]
:param str project: Project ID or project name
:param str continuation_token:
:param int max_page_size:
:rtype: :class:`<ReportingWorkItemRevisionsBatch> <azure.devops.v5_1.work-item-tracking.models.ReportingWorkItemRevisionsBatch>` | [
"ReadReportingDiscussions",
".",
"[",
"Preview",
"API",
"]",
":",
"param",
"str",
"project",
":",
"Project",
"ID",
"or",
"project",
"name",
":",
"param",
"str",
"continuation_token",
":",
":",
"param",
"int",
"max_page_size",
":",
":",
"rtype",
":",
":",
"... | python | train |
wtsi-hgi/python-common | hgicommon/collections.py | https://github.com/wtsi-hgi/python-common/blob/0376a6b574ff46e82e509e90b6cb3693a3dbb577/hgicommon/collections.py#L66-L89 | def rename(self, key: Any, new_key: Any):
"""
Renames an item in this collection as a transaction.
Will override if new key name already exists.
:param key: the current name of the item
:param new_key: the new name that the item should have
"""
if new_key == key:... | [
"def",
"rename",
"(",
"self",
",",
"key",
":",
"Any",
",",
"new_key",
":",
"Any",
")",
":",
"if",
"new_key",
"==",
"key",
":",
"return",
"required_locks",
"=",
"[",
"self",
".",
"_key_locks",
"[",
"key",
"]",
",",
"self",
".",
"_key_locks",
"[",
"n... | Renames an item in this collection as a transaction.
Will override if new key name already exists.
:param key: the current name of the item
:param new_key: the new name that the item should have | [
"Renames",
"an",
"item",
"in",
"this",
"collection",
"as",
"a",
"transaction",
"."
] | python | valid |
UncleRus/regnupg | regnupg.py | https://github.com/UncleRus/regnupg/blob/c1acb5d459107c70e45967ec554831a5f2cd1aaf/regnupg.py#L909-L921 | def sign(self, message, *args, **kwargs):
'''
Make a signature.
:param message: Message to sign
:param key_id: Key for signing, default will be used if null
:param passphrase: Key password
:param clearsign: Make a clear text signature
:param detach: Make a detach... | [
"def",
"sign",
"(",
"self",
",",
"message",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"sign_file",
"(",
"self",
".",
"create_stream",
"(",
"message",
")",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Make a signature.
:param message: Message to sign
:param key_id: Key for signing, default will be used if null
:param passphrase: Key password
:param clearsign: Make a clear text signature
:param detach: Make a detached signature
:param binary: If false, create ASCII arm... | [
"Make",
"a",
"signature",
"."
] | python | train |
PGower/PyCanvas | pycanvas/apis/assignments.py | https://github.com/PGower/PyCanvas/blob/68520005382b440a1e462f9df369f54d364e21e8/pycanvas/apis/assignments.py#L865-L890 | def batch_retrieve_overrides_in_course(self, course_id, assignment_overrides_id, assignment_overrides_assignment_id):
"""
Batch retrieve overrides in a course.
Returns a list of specified overrides in this course, providing
they target sections/groups/students visible to the curren... | [
"def",
"batch_retrieve_overrides_in_course",
"(",
"self",
",",
"course_id",
",",
"assignment_overrides_id",
",",
"assignment_overrides_assignment_id",
")",
":",
"path",
"=",
"{",
"}",
"data",
"=",
"{",
"}",
"params",
"=",
"{",
"}",
"# REQUIRED - PATH - course_id\r",
... | Batch retrieve overrides in a course.
Returns a list of specified overrides in this course, providing
they target sections/groups/students visible to the current user.
Returns null elements in the list for requests that were not found. | [
"Batch",
"retrieve",
"overrides",
"in",
"a",
"course",
".",
"Returns",
"a",
"list",
"of",
"specified",
"overrides",
"in",
"this",
"course",
"providing",
"they",
"target",
"sections",
"/",
"groups",
"/",
"students",
"visible",
"to",
"the",
"current",
"user",
... | python | train |
danilobellini/audiolazy | audiolazy/lazy_analysis.py | https://github.com/danilobellini/audiolazy/blob/dba0a278937909980ed40b976d866b8e97c35dee/audiolazy/lazy_analysis.py#L615-L643 | def clip(sig, low=-1., high=1.):
"""
Clips the signal up to both a lower and a higher limit.
Parameters
----------
sig :
The signal to be clipped, be it a Stream instance, a list or any iterable.
low, high :
Lower and higher clipping limit, "saturating" the input to them. Defaults
to -1.0 and 1... | [
"def",
"clip",
"(",
"sig",
",",
"low",
"=",
"-",
"1.",
",",
"high",
"=",
"1.",
")",
":",
"if",
"low",
"is",
"None",
":",
"if",
"high",
"is",
"None",
":",
"return",
"Stream",
"(",
"sig",
")",
"return",
"Stream",
"(",
"el",
"if",
"el",
"<",
"hi... | Clips the signal up to both a lower and a higher limit.
Parameters
----------
sig :
The signal to be clipped, be it a Stream instance, a list or any iterable.
low, high :
Lower and higher clipping limit, "saturating" the input to them. Defaults
to -1.0 and 1.0, respectively. These can be None when ... | [
"Clips",
"the",
"signal",
"up",
"to",
"both",
"a",
"lower",
"and",
"a",
"higher",
"limit",
"."
] | python | train |
svenevs/exhale | exhale/graph.py | https://github.com/svenevs/exhale/blob/fe7644829057af622e467bb529db6c03a830da99/exhale/graph.py#L1523-L1544 | def reparentAll(self):
'''
Fixes some of the parental relationships lost in parsing the Breathe graph.
File relationships are recovered in
:func:`~exhale.graph.ExhaleRoot.fileRefDiscovery`. This method simply calls in
this order:
1. :func:`~exhale.graph.ExhaleRoot.repar... | [
"def",
"reparentAll",
"(",
"self",
")",
":",
"self",
".",
"reparentUnions",
"(",
")",
"self",
".",
"reparentClassLike",
"(",
")",
"self",
".",
"reparentDirectories",
"(",
")",
"self",
".",
"renameToNamespaceScopes",
"(",
")",
"self",
".",
"reparentNamespaces",... | Fixes some of the parental relationships lost in parsing the Breathe graph.
File relationships are recovered in
:func:`~exhale.graph.ExhaleRoot.fileRefDiscovery`. This method simply calls in
this order:
1. :func:`~exhale.graph.ExhaleRoot.reparentUnions`
2. :func:`~exhale.graph.... | [
"Fixes",
"some",
"of",
"the",
"parental",
"relationships",
"lost",
"in",
"parsing",
"the",
"Breathe",
"graph",
".",
"File",
"relationships",
"are",
"recovered",
"in",
":",
"func",
":",
"~exhale",
".",
"graph",
".",
"ExhaleRoot",
".",
"fileRefDiscovery",
".",
... | python | train |
frictionlessdata/tableschema-py | tableschema/cli.py | https://github.com/frictionlessdata/tableschema-py/blob/9c5fa930319e7c5b10351f794091c5f9de5e8684/tableschema/cli.py#L58-L67 | def validate(schema):
"""Validate that a supposed schema is in fact a Table Schema."""
try:
tableschema.validate(schema)
click.echo("Schema is valid")
sys.exit(0)
except tableschema.exceptions.ValidationError as exception:
click.echo("Schema is not valid")
click.echo(... | [
"def",
"validate",
"(",
"schema",
")",
":",
"try",
":",
"tableschema",
".",
"validate",
"(",
"schema",
")",
"click",
".",
"echo",
"(",
"\"Schema is valid\"",
")",
"sys",
".",
"exit",
"(",
"0",
")",
"except",
"tableschema",
".",
"exceptions",
".",
"Valida... | Validate that a supposed schema is in fact a Table Schema. | [
"Validate",
"that",
"a",
"supposed",
"schema",
"is",
"in",
"fact",
"a",
"Table",
"Schema",
"."
] | python | train |
gem/oq-engine | openquake/calculators/getters.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/getters.py#L306-L326 | def init(self):
"""
Initialize the computers. Should be called on the workers
"""
if hasattr(self, 'computers'): # init already called
return
with hdf5.File(self.rupgetter.filename, 'r') as parent:
self.weights = parent['weights'].value
self.compu... | [
"def",
"init",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'computers'",
")",
":",
"# init already called",
"return",
"with",
"hdf5",
".",
"File",
"(",
"self",
".",
"rupgetter",
".",
"filename",
",",
"'r'",
")",
"as",
"parent",
":",
"sel... | Initialize the computers. Should be called on the workers | [
"Initialize",
"the",
"computers",
".",
"Should",
"be",
"called",
"on",
"the",
"workers"
] | python | train |
lalinsky/python-phoenixdb | phoenixdb/__init__.py | https://github.com/lalinsky/python-phoenixdb/blob/1bb34488dd530ca65f91b29ef16aa7b71f26b806/phoenixdb/__init__.py#L44-L67 | def connect(url, max_retries=None, **kwargs):
"""Connects to a Phoenix query server.
:param url:
URL to the Phoenix query server, e.g. ``http://localhost:8765/``
:param autocommit:
Switch the connection to autocommit mode.
:param readonly:
Switch the connection to readonly mod... | [
"def",
"connect",
"(",
"url",
",",
"max_retries",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"client",
"=",
"AvaticaClient",
"(",
"url",
",",
"max_retries",
"=",
"max_retries",
")",
"client",
".",
"connect",
"(",
")",
"return",
"Connection",
"(",
... | Connects to a Phoenix query server.
:param url:
URL to the Phoenix query server, e.g. ``http://localhost:8765/``
:param autocommit:
Switch the connection to autocommit mode.
:param readonly:
Switch the connection to readonly mode.
:param max_retries:
The maximum numbe... | [
"Connects",
"to",
"a",
"Phoenix",
"query",
"server",
"."
] | python | train |
hvac/hvac | hvac/api/secrets_engines/aws.py | https://github.com/hvac/hvac/blob/cce5b86889193f622c2a72a4a1b7e1c9c8aff1ce/hvac/api/secrets_engines/aws.py#L70-L91 | def rotate_root_iam_credentials(self, mount_point=DEFAULT_MOUNT_POINT):
"""Rotate static root IAM credentials.
When you have configured Vault with static credentials, you can use this endpoint to have Vault rotate the
access key it used. Note that, due to AWS eventual consistency, after calling... | [
"def",
"rotate_root_iam_credentials",
"(",
"self",
",",
"mount_point",
"=",
"DEFAULT_MOUNT_POINT",
")",
":",
"api_path",
"=",
"'/v1/{mount_point}/config/rotate-root'",
".",
"format",
"(",
"mount_point",
"=",
"mount_point",
")",
"response",
"=",
"self",
".",
"_adapter"... | Rotate static root IAM credentials.
When you have configured Vault with static credentials, you can use this endpoint to have Vault rotate the
access key it used. Note that, due to AWS eventual consistency, after calling this endpoint, subsequent calls
from Vault to AWS may fail for a few secon... | [
"Rotate",
"static",
"root",
"IAM",
"credentials",
"."
] | python | train |
chriso/gauged | gauged/drivers/__init__.py | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/drivers/__init__.py#L14-L57 | def parse_dsn(dsn_string):
"""Parse a connection string and return the associated driver"""
dsn = urlparse(dsn_string)
scheme = dsn.scheme.split('+')[0]
username = password = host = port = None
host = dsn.netloc
if '@' in host:
username, host = host.split('@')
if ':' in username:... | [
"def",
"parse_dsn",
"(",
"dsn_string",
")",
":",
"dsn",
"=",
"urlparse",
"(",
"dsn_string",
")",
"scheme",
"=",
"dsn",
".",
"scheme",
".",
"split",
"(",
"'+'",
")",
"[",
"0",
"]",
"username",
"=",
"password",
"=",
"host",
"=",
"port",
"=",
"None",
... | Parse a connection string and return the associated driver | [
"Parse",
"a",
"connection",
"string",
"and",
"return",
"the",
"associated",
"driver"
] | python | train |
obspy/vcr | vcr/core.py | https://github.com/obspy/vcr/blob/f961d3bffc57d1761b6de2fb1e67d5f464ebc6b6/vcr/core.py#L112-L122 | def reset(cls):
"""
Reset to default settings
"""
cls.debug = False
cls.disabled = False
cls.overwrite = False
cls.playback_only = False
cls.recv_timeout = 5
cls.recv_endmarkers = []
cls.recv_size = None | [
"def",
"reset",
"(",
"cls",
")",
":",
"cls",
".",
"debug",
"=",
"False",
"cls",
".",
"disabled",
"=",
"False",
"cls",
".",
"overwrite",
"=",
"False",
"cls",
".",
"playback_only",
"=",
"False",
"cls",
".",
"recv_timeout",
"=",
"5",
"cls",
".",
"recv_e... | Reset to default settings | [
"Reset",
"to",
"default",
"settings"
] | python | train |
eventable/vobject | docs/build/lib/vobject/icalendar.py | https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/icalendar.py#L1208-L1219 | def generateImplicitParameters(obj):
"""
Create default ACTION and TRIGGER if they're not set.
"""
try:
obj.action
except AttributeError:
obj.add('action').value = 'AUDIO'
try:
obj.trigger
except AttributeError:
obj.... | [
"def",
"generateImplicitParameters",
"(",
"obj",
")",
":",
"try",
":",
"obj",
".",
"action",
"except",
"AttributeError",
":",
"obj",
".",
"add",
"(",
"'action'",
")",
".",
"value",
"=",
"'AUDIO'",
"try",
":",
"obj",
".",
"trigger",
"except",
"AttributeErro... | Create default ACTION and TRIGGER if they're not set. | [
"Create",
"default",
"ACTION",
"and",
"TRIGGER",
"if",
"they",
"re",
"not",
"set",
"."
] | python | train |
praekeltfoundation/marathon-acme | marathon_acme/clients/marathon_lb.py | https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/clients/marathon_lb.py#L29-L36 | def _request(self, endpoint, *args, **kwargs):
"""
Perform a request to a specific endpoint. Raise an error if the status
code indicates a client or server error.
"""
kwargs['url'] = endpoint
return (super(MarathonLbClient, self).request(*args, **kwargs)
.... | [
"def",
"_request",
"(",
"self",
",",
"endpoint",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'url'",
"]",
"=",
"endpoint",
"return",
"(",
"super",
"(",
"MarathonLbClient",
",",
"self",
")",
".",
"request",
"(",
"*",
"args",
... | Perform a request to a specific endpoint. Raise an error if the status
code indicates a client or server error. | [
"Perform",
"a",
"request",
"to",
"a",
"specific",
"endpoint",
".",
"Raise",
"an",
"error",
"if",
"the",
"status",
"code",
"indicates",
"a",
"client",
"or",
"server",
"error",
"."
] | python | valid |
eqcorrscan/EQcorrscan | eqcorrscan/core/subspace.py | https://github.com/eqcorrscan/EQcorrscan/blob/3121b4aca801ee5d38f56ca297ce1c0f9515d9ff/eqcorrscan/core/subspace.py#L234-L251 | def energy_capture(self, stachans='all', size=(10, 7), show=False):
"""
Calculate the average percentage energy capture for this subspace.
:return: Percentage energy capture
:rtype: float
"""
if show:
return subspace_fc_plot(detector=self, stachans=stachans,
... | [
"def",
"energy_capture",
"(",
"self",
",",
"stachans",
"=",
"'all'",
",",
"size",
"=",
"(",
"10",
",",
"7",
")",
",",
"show",
"=",
"False",
")",
":",
"if",
"show",
":",
"return",
"subspace_fc_plot",
"(",
"detector",
"=",
"self",
",",
"stachans",
"=",... | Calculate the average percentage energy capture for this subspace.
:return: Percentage energy capture
:rtype: float | [
"Calculate",
"the",
"average",
"percentage",
"energy",
"capture",
"for",
"this",
"subspace",
"."
] | python | train |
recurly/recurly-client-python | recurly/resource.py | https://github.com/recurly/recurly-client-python/blob/682217c4e85ec5c8d4e41519ee0620d2dc4d84d7/recurly/resource.py#L347-L360 | def get(cls, uuid):
"""Return a `Resource` instance of this class identified by
the given code or UUID.
Only `Resource` classes with specified `member_path` attributes
can be directly requested with this method.
"""
if not uuid:
raise ValueError("get must ha... | [
"def",
"get",
"(",
"cls",
",",
"uuid",
")",
":",
"if",
"not",
"uuid",
":",
"raise",
"ValueError",
"(",
"\"get must have a value passed as an argument\"",
")",
"uuid",
"=",
"quote",
"(",
"str",
"(",
"uuid",
")",
")",
"url",
"=",
"recurly",
".",
"base_uri",
... | Return a `Resource` instance of this class identified by
the given code or UUID.
Only `Resource` classes with specified `member_path` attributes
can be directly requested with this method. | [
"Return",
"a",
"Resource",
"instance",
"of",
"this",
"class",
"identified",
"by",
"the",
"given",
"code",
"or",
"UUID",
"."
] | python | train |
thebigmunch/google-music | src/google_music/clients/mobileclient.py | https://github.com/thebigmunch/google-music/blob/d8a94dab462a1f063fbc1152187a73dc2f0e2a85/src/google_music/clients/mobileclient.py#L978-L996 | def podcast(self, podcast_series_id, *, max_episodes=50):
"""Get information about a podcast series.
Parameters:
podcast_series_id (str): A podcast series ID.
max_episodes (int, Optional): Include up to given number of episodes in returned dict.
Default: ``50``
Returns:
dict: Podcast series informa... | [
"def",
"podcast",
"(",
"self",
",",
"podcast_series_id",
",",
"*",
",",
"max_episodes",
"=",
"50",
")",
":",
"podcast_info",
"=",
"self",
".",
"_call",
"(",
"mc_calls",
".",
"PodcastFetchSeries",
",",
"podcast_series_id",
",",
"max_episodes",
"=",
"max_episode... | Get information about a podcast series.
Parameters:
podcast_series_id (str): A podcast series ID.
max_episodes (int, Optional): Include up to given number of episodes in returned dict.
Default: ``50``
Returns:
dict: Podcast series information. | [
"Get",
"information",
"about",
"a",
"podcast",
"series",
"."
] | python | train |
bcbio/bcbio-nextgen | bcbio/rnaseq/bcbiornaseq.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/rnaseq/bcbiornaseq.py#L82-L107 | def create_load_string(upload_dir, groups=None, organism=None):
"""
create the code necessary to load the bcbioRNAseq object
"""
libraryline = 'library(bcbioRNASeq)'
load_template = Template(
('bcb <- bcbioRNASeq(uploadDir="$upload_dir",'
'interestingGroups=$groups,'
'organ... | [
"def",
"create_load_string",
"(",
"upload_dir",
",",
"groups",
"=",
"None",
",",
"organism",
"=",
"None",
")",
":",
"libraryline",
"=",
"'library(bcbioRNASeq)'",
"load_template",
"=",
"Template",
"(",
"(",
"'bcb <- bcbioRNASeq(uploadDir=\"$upload_dir\",'",
"'interesting... | create the code necessary to load the bcbioRNAseq object | [
"create",
"the",
"code",
"necessary",
"to",
"load",
"the",
"bcbioRNAseq",
"object"
] | python | train |
Microsoft/azure-devops-python-api | azure-devops/azure/devops/v5_1/gallery/gallery_client.py | https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_1/gallery/gallery_client.py#L759-L775 | def create_extension(self, upload_stream, **kwargs):
"""CreateExtension.
[Preview API]
:param object upload_stream: Stream to upload
:rtype: :class:`<PublishedExtension> <azure.devops.v5_1.gallery.models.PublishedExtension>`
"""
if "callback" in kwargs:
callba... | [
"def",
"create_extension",
"(",
"self",
",",
"upload_stream",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"\"callback\"",
"in",
"kwargs",
":",
"callback",
"=",
"kwargs",
"[",
"\"callback\"",
"]",
"else",
":",
"callback",
"=",
"None",
"content",
"=",
"self",
... | CreateExtension.
[Preview API]
:param object upload_stream: Stream to upload
:rtype: :class:`<PublishedExtension> <azure.devops.v5_1.gallery.models.PublishedExtension>` | [
"CreateExtension",
".",
"[",
"Preview",
"API",
"]",
":",
"param",
"object",
"upload_stream",
":",
"Stream",
"to",
"upload",
":",
"rtype",
":",
":",
"class",
":",
"<PublishedExtension",
">",
"<azure",
".",
"devops",
".",
"v5_1",
".",
"gallery",
".",
"models... | python | train |
toumorokoshi/transmute-core | transmute_core/frameworks/aiohttp/route.py | https://github.com/toumorokoshi/transmute-core/blob/a2c26625d5d8bab37e00038f9d615a26167fc7f4/transmute_core/frameworks/aiohttp/route.py#L6-L21 | def add_route(app, fn, context=default_context):
"""
a decorator that adds a transmute route to the application.
"""
transmute_func = TransmuteFunction(
fn,
args_not_from_request=["request"]
)
handler = create_handler(transmute_func, context=context)
get_swagger_spec(app).add... | [
"def",
"add_route",
"(",
"app",
",",
"fn",
",",
"context",
"=",
"default_context",
")",
":",
"transmute_func",
"=",
"TransmuteFunction",
"(",
"fn",
",",
"args_not_from_request",
"=",
"[",
"\"request\"",
"]",
")",
"handler",
"=",
"create_handler",
"(",
"transmu... | a decorator that adds a transmute route to the application. | [
"a",
"decorator",
"that",
"adds",
"a",
"transmute",
"route",
"to",
"the",
"application",
"."
] | python | train |
ebroecker/canmatrix | src/canmatrix/formats/arxml.py | https://github.com/ebroecker/canmatrix/blob/d6150b7a648350f051a11c431e9628308c8d5593/src/canmatrix/formats/arxml.py#L771-L780 | def fill_tree_from_xml(tag, ar_tree, namespace):
# type: (_Element, ArTree, str) -> None
"""Parse the xml tree into ArTree objects."""
for child in tag: # type: _Element
name_elem = child.find('./' + namespace + 'SHORT-NAME')
# long_name = child.find('./' + namespace + 'LONG-NAME')
... | [
"def",
"fill_tree_from_xml",
"(",
"tag",
",",
"ar_tree",
",",
"namespace",
")",
":",
"# type: (_Element, ArTree, str) -> None",
"for",
"child",
"in",
"tag",
":",
"# type: _Element",
"name_elem",
"=",
"child",
".",
"find",
"(",
"'./'",
"+",
"namespace",
"+",
"'SH... | Parse the xml tree into ArTree objects. | [
"Parse",
"the",
"xml",
"tree",
"into",
"ArTree",
"objects",
"."
] | python | train |
Lagg/steamodd | steam/sim.py | https://github.com/Lagg/steamodd/blob/2e9ced4e7a6dbe3e09d5a648450bafc12b937b95/steam/sim.py#L35-L48 | def get(self, key):
""" Returns context data for a given app, can be an ID or a case insensitive name """
keystr = str(key)
res = None
try:
res = self.ctx[keystr]
except KeyError:
for k, v in self.ctx.items():
if "name" in v and v["name"].... | [
"def",
"get",
"(",
"self",
",",
"key",
")",
":",
"keystr",
"=",
"str",
"(",
"key",
")",
"res",
"=",
"None",
"try",
":",
"res",
"=",
"self",
".",
"ctx",
"[",
"keystr",
"]",
"except",
"KeyError",
":",
"for",
"k",
",",
"v",
"in",
"self",
".",
"c... | Returns context data for a given app, can be an ID or a case insensitive name | [
"Returns",
"context",
"data",
"for",
"a",
"given",
"app",
"can",
"be",
"an",
"ID",
"or",
"a",
"case",
"insensitive",
"name"
] | python | train |
ansibleplaybookbundle/ansible-playbook-bundle | src/apb/cli.py | https://github.com/ansibleplaybookbundle/ansible-playbook-bundle/blob/585694be9b417f1a88354cbfe286bfd68c2c9494/src/apb/cli.py#L108-L165 | def subcmd_init_parser(subcmd):
""" init subcommand """
subcmd.add_argument(
'tag',
action='store',
help=u'Tag (org/name) or name of APB to initialize'
)
subcmd.add_argument(
'--force',
action='store_true',
dest='force',
help=u'Force re-init on cu... | [
"def",
"subcmd_init_parser",
"(",
"subcmd",
")",
":",
"subcmd",
".",
"add_argument",
"(",
"'tag'",
",",
"action",
"=",
"'store'",
",",
"help",
"=",
"u'Tag (org/name) or name of APB to initialize'",
")",
"subcmd",
".",
"add_argument",
"(",
"'--force'",
",",
"action... | init subcommand | [
"init",
"subcommand"
] | python | train |
Metatab/tableintuit | tableintuit/rows.py | https://github.com/Metatab/tableintuit/blob/9a3d500d5d90e44e6637dd17ca4c8dae474d6d4c/tableintuit/rows.py#L189-L288 | def run(self, head_rows, tail_rows=None, n_rows=None):
"""
Run the intuition process
:param head_rows: A list of rows from the start of the file. Should have at least 30 rows
:param tail_rows: A list of rows from the end of the file. Optional, but should have at least 30 rows
:pa... | [
"def",
"run",
"(",
"self",
",",
"head_rows",
",",
"tail_rows",
"=",
"None",
",",
"n_rows",
"=",
"None",
")",
":",
"from",
".",
"exceptions",
"import",
"RowIntuitError",
"header_rows",
"=",
"[",
"]",
"found_header",
"=",
"False",
"MIN_SKIP_ROWS",
"=",
"30",... | Run the intuition process
:param head_rows: A list of rows from the start of the file. Should have at least 30 rows
:param tail_rows: A list of rows from the end of the file. Optional, but should have at least 30 rows
:param n_rows: Total number of rows, if a subset was provided in head_rows
... | [
"Run",
"the",
"intuition",
"process",
":",
"param",
"head_rows",
":",
"A",
"list",
"of",
"rows",
"from",
"the",
"start",
"of",
"the",
"file",
".",
"Should",
"have",
"at",
"least",
"30",
"rows",
":",
"param",
"tail_rows",
":",
"A",
"list",
"of",
"rows",... | python | train |
isislovecruft/python-gnupg | examples/make-8192-bit-key.py | https://github.com/isislovecruft/python-gnupg/blob/784571449032e811587249743e183fc5e908a673/examples/make-8192-bit-key.py#L158-L176 | def displayNewKey(key):
"""Use ``gnupg.GPG.list_keys()`` to display details of the new key."""
if key.keyring:
gpg.keyring = key.keyring
if key.secring:
gpg.secring = key.secring
# Using '--fingerprint' twice will display subkey fingerprints too:
gpg.options = ['--fingerprint', '--... | [
"def",
"displayNewKey",
"(",
"key",
")",
":",
"if",
"key",
".",
"keyring",
":",
"gpg",
".",
"keyring",
"=",
"key",
".",
"keyring",
"if",
"key",
".",
"secring",
":",
"gpg",
".",
"secring",
"=",
"key",
".",
"secring",
"# Using '--fingerprint' twice will disp... | Use ``gnupg.GPG.list_keys()`` to display details of the new key. | [
"Use",
"gnupg",
".",
"GPG",
".",
"list_keys",
"()",
"to",
"display",
"details",
"of",
"the",
"new",
"key",
"."
] | python | train |
ajenhl/tacl | tacl/sequence.py | https://github.com/ajenhl/tacl/blob/b8a343248e77f1c07a5a4ac133a9ad6e0b4781c2/tacl/sequence.py#L24-L42 | def _format_alignment(self, a1, a2):
"""Returns `a1` marked up with HTML spans around characters that are
also at the same index in `a2`.
:param a1: text sequence from one witness
:type a1: `str`
:param a2: text sequence from another witness
:type a2: `str`
:rtyp... | [
"def",
"_format_alignment",
"(",
"self",
",",
"a1",
",",
"a2",
")",
":",
"html",
"=",
"[",
"]",
"for",
"index",
",",
"char",
"in",
"enumerate",
"(",
"a1",
")",
":",
"output",
"=",
"self",
".",
"_substitutes",
".",
"get",
"(",
"char",
",",
"char",
... | Returns `a1` marked up with HTML spans around characters that are
also at the same index in `a2`.
:param a1: text sequence from one witness
:type a1: `str`
:param a2: text sequence from another witness
:type a2: `str`
:rtype: `str` | [
"Returns",
"a1",
"marked",
"up",
"with",
"HTML",
"spans",
"around",
"characters",
"that",
"are",
"also",
"at",
"the",
"same",
"index",
"in",
"a2",
"."
] | python | train |
fermiPy/fermipy | fermipy/srcmap_utils.py | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/srcmap_utils.py#L84-L112 | def shift_to_coords(self, pix, fill_value=np.nan):
"""Create a new map that is shifted to the pixel coordinates
``pix``."""
pix_offset = self.get_offsets(pix)
dpix = np.zeros(len(self.shape) - 1)
for i in range(len(self.shape) - 1):
x = self.rebin * (pix[i] - pix_off... | [
"def",
"shift_to_coords",
"(",
"self",
",",
"pix",
",",
"fill_value",
"=",
"np",
".",
"nan",
")",
":",
"pix_offset",
"=",
"self",
".",
"get_offsets",
"(",
"pix",
")",
"dpix",
"=",
"np",
".",
"zeros",
"(",
"len",
"(",
"self",
".",
"shape",
")",
"-",... | Create a new map that is shifted to the pixel coordinates
``pix``. | [
"Create",
"a",
"new",
"map",
"that",
"is",
"shifted",
"to",
"the",
"pixel",
"coordinates",
"pix",
"."
] | python | train |
armstrong/armstrong.core.arm_sections | armstrong/core/arm_sections/utils.py | https://github.com/armstrong/armstrong.core.arm_sections/blob/39c999c93771da909359e53b35afefe4846f77cb/armstrong/core/arm_sections/utils.py#L30-L34 | def get_section_relations(Section):
"""Find every relationship between section and the item model."""
all_rels = (Section._meta.get_all_related_objects() +
Section._meta.get_all_related_many_to_many_objects())
return filter_item_rels(all_rels) | [
"def",
"get_section_relations",
"(",
"Section",
")",
":",
"all_rels",
"=",
"(",
"Section",
".",
"_meta",
".",
"get_all_related_objects",
"(",
")",
"+",
"Section",
".",
"_meta",
".",
"get_all_related_many_to_many_objects",
"(",
")",
")",
"return",
"filter_item_rels... | Find every relationship between section and the item model. | [
"Find",
"every",
"relationship",
"between",
"section",
"and",
"the",
"item",
"model",
"."
] | python | train |
FutunnOpen/futuquant | futuquant/examples/learn/get_realtime_data.py | https://github.com/FutunnOpen/futuquant/blob/1512b321845f92ec9c578ce2689aa4e8482669e4/futuquant/examples/learn/get_realtime_data.py#L36-L65 | def _example_cur_kline(quote_ctx):
"""
获取当前K线,输出 股票代码,时间,开盘价,收盘价,最高价,最低价,成交量,成交额
"""
# subscribe Kline
stock_code_list = ["US.AAPL", "HK.00700"]
sub_type_list = [ft.SubType.K_1M, ft.SubType.K_5M, ft.SubType.K_15M, ft.SubType.K_30M, ft.SubType.K_60M,
ft.SubType.K_DAY, ft.SubT... | [
"def",
"_example_cur_kline",
"(",
"quote_ctx",
")",
":",
"# subscribe Kline",
"stock_code_list",
"=",
"[",
"\"US.AAPL\"",
",",
"\"HK.00700\"",
"]",
"sub_type_list",
"=",
"[",
"ft",
".",
"SubType",
".",
"K_1M",
",",
"ft",
".",
"SubType",
".",
"K_5M",
",",
"ft... | 获取当前K线,输出 股票代码,时间,开盘价,收盘价,最高价,最低价,成交量,成交额 | [
"获取当前K线,输出",
"股票代码,时间,开盘价,收盘价,最高价,最低价,成交量,成交额"
] | python | train |
christophercrouzet/gorilla | gorilla.py | https://github.com/christophercrouzet/gorilla/blob/10c68d04be28524f2cd7be22eddca77678e12860/gorilla.py#L668-L697 | def get_decorator_data(obj, set_default=False):
"""Retrieve any decorator data from an object.
Parameters
----------
obj : object
Object.
set_default : bool
If no data is found, a default one is set on the object and returned,
otherwise ``None`` is returned.
Returns
... | [
"def",
"get_decorator_data",
"(",
"obj",
",",
"set_default",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"_CLASS_TYPES",
")",
":",
"datas",
"=",
"getattr",
"(",
"obj",
",",
"_DECORATOR_DATA",
",",
"{",
"}",
")",
"data",
"=",
"datas",
"... | Retrieve any decorator data from an object.
Parameters
----------
obj : object
Object.
set_default : bool
If no data is found, a default one is set on the object and returned,
otherwise ``None`` is returned.
Returns
-------
gorilla.DecoratorData
The decorato... | [
"Retrieve",
"any",
"decorator",
"data",
"from",
"an",
"object",
"."
] | python | train |
Gorialis/jishaku | jishaku/cog.py | https://github.com/Gorialis/jishaku/blob/fc7c479b9d510ede189a929c8aa6f7c8ef7f9a6e/jishaku/cog.py#L199-L214 | async def jsk_tasks(self, ctx: commands.Context):
"""
Shows the currently running jishaku tasks.
"""
if not self.tasks:
return await ctx.send("No currently running tasks.")
paginator = commands.Paginator(max_size=1985)
for task in self.tasks:
pa... | [
"async",
"def",
"jsk_tasks",
"(",
"self",
",",
"ctx",
":",
"commands",
".",
"Context",
")",
":",
"if",
"not",
"self",
".",
"tasks",
":",
"return",
"await",
"ctx",
".",
"send",
"(",
"\"No currently running tasks.\"",
")",
"paginator",
"=",
"commands",
".",
... | Shows the currently running jishaku tasks. | [
"Shows",
"the",
"currently",
"running",
"jishaku",
"tasks",
"."
] | python | train |
rocky/python3-trepan | trepan/bwprocessor/main.py | https://github.com/rocky/python3-trepan/blob/14e91bc0acce090d67be145b1ac040cab92ac5f3/trepan/bwprocessor/main.py#L370-L403 | def setup(self):
"""Initialization done before entering the debugger-command
loop. In particular we set up the call stack used for local
variable lookup and frame/up/down commands.
We return True if we should NOT enter the debugger-command
loop."""
self.forget()
... | [
"def",
"setup",
"(",
"self",
")",
":",
"self",
".",
"forget",
"(",
")",
"if",
"self",
".",
"settings",
"(",
"'dbg_trepan'",
")",
":",
"self",
".",
"frame",
"=",
"inspect",
".",
"currentframe",
"(",
")",
"pass",
"if",
"self",
".",
"event",
"in",
"["... | Initialization done before entering the debugger-command
loop. In particular we set up the call stack used for local
variable lookup and frame/up/down commands.
We return True if we should NOT enter the debugger-command
loop. | [
"Initialization",
"done",
"before",
"entering",
"the",
"debugger",
"-",
"command",
"loop",
".",
"In",
"particular",
"we",
"set",
"up",
"the",
"call",
"stack",
"used",
"for",
"local",
"variable",
"lookup",
"and",
"frame",
"/",
"up",
"/",
"down",
"commands",
... | python | test |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.