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 |
|---|---|---|---|---|---|---|---|---|
flowersteam/explauto | explauto/sensorimotor_model/inverse/sciopt.py | https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/sciopt.py#L17-L40 | def infer_x(self, y):
"""Infer probable x from input y
@param y the desired output for infered x.
@return a list of probable x
"""
OptimizedInverseModel.infer_x(self, y)
if self.fmodel.size() == 0:
return self._random_x()
x_guesses = [self._guess_x... | [
"def",
"infer_x",
"(",
"self",
",",
"y",
")",
":",
"OptimizedInverseModel",
".",
"infer_x",
"(",
"self",
",",
"y",
")",
"if",
"self",
".",
"fmodel",
".",
"size",
"(",
")",
"==",
"0",
":",
"return",
"self",
".",
"_random_x",
"(",
")",
"x_guesses",
"... | Infer probable x from input y
@param y the desired output for infered x.
@return a list of probable x | [
"Infer",
"probable",
"x",
"from",
"input",
"y"
] | python | train |
Trebek/pydealer | pydealer/stack.py | https://github.com/Trebek/pydealer/blob/2ac583dd8c55715658c740b614387775f4dda333/pydealer/stack.py#L344-L386 | def find(self, term, limit=0, sort=False, ranks=None):
"""
Searches the stack for cards with a value, suit, name, or
abbreviation matching the given argument, 'term'.
:arg str term:
The search term. Can be a card full name, value, suit,
or abbreviation.
:... | [
"def",
"find",
"(",
"self",
",",
"term",
",",
"limit",
"=",
"0",
",",
"sort",
"=",
"False",
",",
"ranks",
"=",
"None",
")",
":",
"ranks",
"=",
"ranks",
"or",
"self",
".",
"ranks",
"found_indices",
"=",
"[",
"]",
"count",
"=",
"0",
"if",
"not",
... | Searches the stack for cards with a value, suit, name, or
abbreviation matching the given argument, 'term'.
:arg str term:
The search term. Can be a card full name, value, suit,
or abbreviation.
:arg int limit:
The number of items to retrieve for each term. `... | [
"Searches",
"the",
"stack",
"for",
"cards",
"with",
"a",
"value",
"suit",
"name",
"or",
"abbreviation",
"matching",
"the",
"given",
"argument",
"term",
"."
] | python | train |
Erotemic/utool | utool/util_import.py | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_import.py#L272-L317 | def check_module_installed(modname):
"""
Check if a python module is installed without attempting to import it.
Note, that if ``modname`` indicates a child module, the parent module is
always loaded.
Args:
modname (str): module name
Returns:
bool: found
References:
... | [
"def",
"check_module_installed",
"(",
"modname",
")",
":",
"import",
"pkgutil",
"if",
"'.'",
"in",
"modname",
":",
"# Prevent explicit import if possible",
"parts",
"=",
"modname",
".",
"split",
"(",
"'.'",
")",
"base",
"=",
"parts",
"[",
"0",
"]",
"submods",
... | Check if a python module is installed without attempting to import it.
Note, that if ``modname`` indicates a child module, the parent module is
always loaded.
Args:
modname (str): module name
Returns:
bool: found
References:
http://stackoverflow.com/questions/14050281/mod... | [
"Check",
"if",
"a",
"python",
"module",
"is",
"installed",
"without",
"attempting",
"to",
"import",
"it",
".",
"Note",
"that",
"if",
"modname",
"indicates",
"a",
"child",
"module",
"the",
"parent",
"module",
"is",
"always",
"loaded",
"."
] | python | train |
clld/cdstarcat | src/cdstarcat/catalog.py | https://github.com/clld/cdstarcat/blob/41f33f59cdde5e30835d2f3accf2d1fbe5332cab/src/cdstarcat/catalog.py#L175-L188 | def add(self, obj, metadata=None, update=False):
"""
Add an existing CDSTAR object to the catalog.
:param obj: A pycdstar.resource.Object instance
"""
if (obj not in self) or update:
self[obj.id] = Object.fromdict(
obj.id,
dict(
... | [
"def",
"add",
"(",
"self",
",",
"obj",
",",
"metadata",
"=",
"None",
",",
"update",
"=",
"False",
")",
":",
"if",
"(",
"obj",
"not",
"in",
"self",
")",
"or",
"update",
":",
"self",
"[",
"obj",
".",
"id",
"]",
"=",
"Object",
".",
"fromdict",
"("... | Add an existing CDSTAR object to the catalog.
:param obj: A pycdstar.resource.Object instance | [
"Add",
"an",
"existing",
"CDSTAR",
"object",
"to",
"the",
"catalog",
"."
] | python | train |
quantopian/pgcontents | pgcontents/hybridmanager.py | https://github.com/quantopian/pgcontents/blob/ed36268b7917332d16868208e1e565742a8753e1/pgcontents/hybridmanager.py#L118-L130 | def path_dispatch_kwarg(mname, path_default, returns_model):
"""
Parameterized decorator for methods that accept path as a second
argument.
"""
def _wrapper(self, path=path_default, **kwargs):
prefix, mgr, mgr_path = _resolve_path(path, self.managers)
result = getattr(mgr, mname)(pat... | [
"def",
"path_dispatch_kwarg",
"(",
"mname",
",",
"path_default",
",",
"returns_model",
")",
":",
"def",
"_wrapper",
"(",
"self",
",",
"path",
"=",
"path_default",
",",
"*",
"*",
"kwargs",
")",
":",
"prefix",
",",
"mgr",
",",
"mgr_path",
"=",
"_resolve_path... | Parameterized decorator for methods that accept path as a second
argument. | [
"Parameterized",
"decorator",
"for",
"methods",
"that",
"accept",
"path",
"as",
"a",
"second",
"argument",
"."
] | python | test |
caffeinehit/django-oauth2-provider | provider/views.py | https://github.com/caffeinehit/django-oauth2-provider/blob/6b5bc0d3ad706d2aaa47fa476f38406cddd01236/provider/views.py#L222-L246 | def error_response(self, request, error, **kwargs):
"""
Return an error to be displayed to the resource owner if anything goes
awry. Errors can include invalid clients, authorization denials and
other edge cases such as a wrong ``redirect_uri`` in the authorization
request.
... | [
"def",
"error_response",
"(",
"self",
",",
"request",
",",
"error",
",",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"{",
"}",
"ctx",
".",
"update",
"(",
"error",
")",
"# If we got a malicious redirect_uri or client_id, remove all the",
"# cached data and tell the res... | Return an error to be displayed to the resource owner if anything goes
awry. Errors can include invalid clients, authorization denials and
other edge cases such as a wrong ``redirect_uri`` in the authorization
request.
:param request: :attr:`django.http.HttpRequest`
:param error... | [
"Return",
"an",
"error",
"to",
"be",
"displayed",
"to",
"the",
"resource",
"owner",
"if",
"anything",
"goes",
"awry",
".",
"Errors",
"can",
"include",
"invalid",
"clients",
"authorization",
"denials",
"and",
"other",
"edge",
"cases",
"such",
"as",
"a",
"wron... | python | train |
bspaans/python-mingus | mingus/containers/note.py | https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/containers/note.py#L111-L115 | def change_octave(self, diff):
"""Change the octave of the note to the current octave + diff."""
self.octave += diff
if self.octave < 0:
self.octave = 0 | [
"def",
"change_octave",
"(",
"self",
",",
"diff",
")",
":",
"self",
".",
"octave",
"+=",
"diff",
"if",
"self",
".",
"octave",
"<",
"0",
":",
"self",
".",
"octave",
"=",
"0"
] | Change the octave of the note to the current octave + diff. | [
"Change",
"the",
"octave",
"of",
"the",
"note",
"to",
"the",
"current",
"octave",
"+",
"diff",
"."
] | python | train |
inspirehep/harvesting-kit | harvestingkit/inspire_cds_package/from_cds.py | https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_cds.py#L173-L189 | def add_cms_link(self):
"""Special handling if record is a CMS NOTE."""
intnote = record_get_field_values(self.record, '690',
filter_subfield_code="a",
filter_subfield_value='INTNOTE')
if intnote:
val... | [
"def",
"add_cms_link",
"(",
"self",
")",
":",
"intnote",
"=",
"record_get_field_values",
"(",
"self",
".",
"record",
",",
"'690'",
",",
"filter_subfield_code",
"=",
"\"a\"",
",",
"filter_subfield_value",
"=",
"'INTNOTE'",
")",
"if",
"intnote",
":",
"val_088",
... | Special handling if record is a CMS NOTE. | [
"Special",
"handling",
"if",
"record",
"is",
"a",
"CMS",
"NOTE",
"."
] | python | valid |
aarongarrett/inspyred | inspyred/benchmarks.py | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/benchmarks.py#L1016-L1033 | def evaluator(self, candidates, args):
"""Return the fitness values for the given candidates."""
fitness = []
if self._use_ants:
for candidate in candidates:
total = 0
for c in candidate:
total += self.weights[c.element[0]][c.elemen... | [
"def",
"evaluator",
"(",
"self",
",",
"candidates",
",",
"args",
")",
":",
"fitness",
"=",
"[",
"]",
"if",
"self",
".",
"_use_ants",
":",
"for",
"candidate",
"in",
"candidates",
":",
"total",
"=",
"0",
"for",
"c",
"in",
"candidate",
":",
"total",
"+=... | Return the fitness values for the given candidates. | [
"Return",
"the",
"fitness",
"values",
"for",
"the",
"given",
"candidates",
"."
] | python | train |
blockstack/blockstack-core | blockstack/lib/nameset/namedb.py | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/namedb.py#L1306-L1316 | def get_namespace_reveal( self, namespace_id, include_history=True ):
"""
Given the name of a namespace, get it if it is currently
being revealed.
Return the reveal record on success.
Return None if it is not being revealed, or is expired.
"""
cur = self.db.curso... | [
"def",
"get_namespace_reveal",
"(",
"self",
",",
"namespace_id",
",",
"include_history",
"=",
"True",
")",
":",
"cur",
"=",
"self",
".",
"db",
".",
"cursor",
"(",
")",
"namespace_reveal",
"=",
"namedb_get_namespace_reveal",
"(",
"cur",
",",
"namespace_id",
","... | Given the name of a namespace, get it if it is currently
being revealed.
Return the reveal record on success.
Return None if it is not being revealed, or is expired. | [
"Given",
"the",
"name",
"of",
"a",
"namespace",
"get",
"it",
"if",
"it",
"is",
"currently",
"being",
"revealed",
"."
] | python | train |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/nose/suite.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/nose/suite.py#L196-L232 | def run(self, result):
"""Run tests in suite inside of suite fixtures.
"""
# proxy the result for myself
log.debug("suite %s (%s) run called, tests: %s", id(self), self, self._tests)
#import pdb
#pdb.set_trace()
if self.resultProxy:
result, orig = self... | [
"def",
"run",
"(",
"self",
",",
"result",
")",
":",
"# proxy the result for myself",
"log",
".",
"debug",
"(",
"\"suite %s (%s) run called, tests: %s\"",
",",
"id",
"(",
"self",
")",
",",
"self",
",",
"self",
".",
"_tests",
")",
"#import pdb",
"#pdb.set_trace()"... | Run tests in suite inside of suite fixtures. | [
"Run",
"tests",
"in",
"suite",
"inside",
"of",
"suite",
"fixtures",
"."
] | python | test |
vburenin/xjpath | xjpath/xjpath.py | https://github.com/vburenin/xjpath/blob/98a19fd6e6d0bcdc5ecbd3651ffa8915f06d7d44/xjpath/xjpath.py#L118-L155 | def split(inp_str, sep_char, maxsplit=-1, escape_char='\\'):
"""Separates a string on a character, taking into account escapes.
:param str inp_str: string to split.
:param str sep_char: separator character.
:param int maxsplit: maximum number of times to split from left.
:param str escape_char: esc... | [
"def",
"split",
"(",
"inp_str",
",",
"sep_char",
",",
"maxsplit",
"=",
"-",
"1",
",",
"escape_char",
"=",
"'\\\\'",
")",
":",
"word_chars",
"=",
"[",
"]",
"word_chars_append",
"=",
"word_chars",
".",
"append",
"inp_str_iter",
"=",
"iter",
"(",
"inp_str",
... | Separates a string on a character, taking into account escapes.
:param str inp_str: string to split.
:param str sep_char: separator character.
:param int maxsplit: maximum number of times to split from left.
:param str escape_char: escape character.
:rtype: __generator[str]
:return: sub-strings... | [
"Separates",
"a",
"string",
"on",
"a",
"character",
"taking",
"into",
"account",
"escapes",
"."
] | python | train |
hydraplatform/hydra-base | hydra_base/lib/scenario.py | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/scenario.py#L1062-L1074 | def delete_resourcegroupitems(scenario_id, item_ids, **kwargs):
"""
Delete specified items in a group, in a scenario.
"""
user_id = int(kwargs.get('user_id'))
#check the scenario exists
_get_scenario(scenario_id, user_id)
for item_id in item_ids:
rgi = db.DBSession.query(Resource... | [
"def",
"delete_resourcegroupitems",
"(",
"scenario_id",
",",
"item_ids",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"int",
"(",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
")",
"#check the scenario exists",
"_get_scenario",
"(",
"scenario_id",
",",
"u... | Delete specified items in a group, in a scenario. | [
"Delete",
"specified",
"items",
"in",
"a",
"group",
"in",
"a",
"scenario",
"."
] | python | train |
NetEaseGame/aircv | aircv/__init__.py | https://github.com/NetEaseGame/aircv/blob/d479e49ef98347bbbe6ac2e4aa9119cecc15c8ca/aircv/__init__.py#L174-L181 | def find_sift(im_source, im_search, min_match_count=4):
'''
SIFT特征点匹配
'''
res = find_all_sift(im_source, im_search, min_match_count, maxcnt=1)
if not res:
return None
return res[0] | [
"def",
"find_sift",
"(",
"im_source",
",",
"im_search",
",",
"min_match_count",
"=",
"4",
")",
":",
"res",
"=",
"find_all_sift",
"(",
"im_source",
",",
"im_search",
",",
"min_match_count",
",",
"maxcnt",
"=",
"1",
")",
"if",
"not",
"res",
":",
"return",
... | SIFT特征点匹配 | [
"SIFT特征点匹配"
] | python | train |
shichao-an/homura | homura.py | https://github.com/shichao-an/homura/blob/87d1b698e1196963a23fc1c615c12020daf77dcc/homura.py#L304-L311 | def download(url, path=None, headers=None, session=None, show_progress=True,
resume=True, auto_retry=True, max_rst_retries=5,
pass_through_opts=None, cainfo=None, user_agent=None, auth=None):
"""Main download function"""
hm = Homura(url, path, headers, session, show_progress, resume,
... | [
"def",
"download",
"(",
"url",
",",
"path",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"session",
"=",
"None",
",",
"show_progress",
"=",
"True",
",",
"resume",
"=",
"True",
",",
"auto_retry",
"=",
"True",
",",
"max_rst_retries",
"=",
"5",
",",
"... | Main download function | [
"Main",
"download",
"function"
] | python | train |
openstack/proliantutils | proliantutils/redfish/resources/system/ethernet_interface.py | https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/redfish/resources/system/ethernet_interface.py#L36-L56 | def summary(self):
"""property to return the summary MAC addresses and state
This filters the MACs whose health is OK,
and in 'Enabled' State would be returned.
The returned format will be {<port_id>: <mac_address>}.
This is because RIBCL returns the data in format
{'Por... | [
"def",
"summary",
"(",
"self",
")",
":",
"mac_dict",
"=",
"{",
"}",
"for",
"eth",
"in",
"self",
".",
"get_members",
"(",
")",
":",
"if",
"eth",
".",
"mac_address",
"is",
"not",
"None",
":",
"if",
"(",
"eth",
".",
"status",
"is",
"not",
"None",
"a... | property to return the summary MAC addresses and state
This filters the MACs whose health is OK,
and in 'Enabled' State would be returned.
The returned format will be {<port_id>: <mac_address>}.
This is because RIBCL returns the data in format
{'Port 1': 'aa:bb:cc:dd:ee:ff'} and... | [
"property",
"to",
"return",
"the",
"summary",
"MAC",
"addresses",
"and",
"state"
] | python | train |
fracpete/python-weka-wrapper3 | python/weka/core/classes.py | https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L949-L961 | def next_int(self, n=None):
"""
Next random integer. if n is provided, then between 0 and n-1.
:param n: the upper limit (minus 1) for the random integer
:type n: int
:return: the next random integer
:rtype: int
"""
if n is None:
return javabr... | [
"def",
"next_int",
"(",
"self",
",",
"n",
"=",
"None",
")",
":",
"if",
"n",
"is",
"None",
":",
"return",
"javabridge",
".",
"call",
"(",
"self",
".",
"jobject",
",",
"\"nextInt\"",
",",
"\"()I\"",
")",
"else",
":",
"return",
"javabridge",
".",
"call"... | Next random integer. if n is provided, then between 0 and n-1.
:param n: the upper limit (minus 1) for the random integer
:type n: int
:return: the next random integer
:rtype: int | [
"Next",
"random",
"integer",
".",
"if",
"n",
"is",
"provided",
"then",
"between",
"0",
"and",
"n",
"-",
"1",
"."
] | python | train |
xmunoz/sodapy | sodapy/__init__.py | https://github.com/xmunoz/sodapy/blob/dad2ca9560cde0acb03bdb4423260e891ca40d7b/sodapy/__init__.py#L258-L267 | def update_metadata(self, dataset_identifier, update_fields, content_type="json"):
'''
Update the metadata for a particular dataset.
update_fields is a dictionary containing [metadata key:new value] pairs.
This method performs a full replace for the key:value pairs listed in `update... | [
"def",
"update_metadata",
"(",
"self",
",",
"dataset_identifier",
",",
"update_fields",
",",
"content_type",
"=",
"\"json\"",
")",
":",
"resource",
"=",
"_format_old_api_request",
"(",
"dataid",
"=",
"dataset_identifier",
",",
"content_type",
"=",
"content_type",
")... | Update the metadata for a particular dataset.
update_fields is a dictionary containing [metadata key:new value] pairs.
This method performs a full replace for the key:value pairs listed in `update_fields`, and
returns all of the metadata with the updates applied. | [
"Update",
"the",
"metadata",
"for",
"a",
"particular",
"dataset",
".",
"update_fields",
"is",
"a",
"dictionary",
"containing",
"[",
"metadata",
"key",
":",
"new",
"value",
"]",
"pairs",
"."
] | python | train |
SoCo/SoCo | soco/music_services/music_service.py | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/music_services/music_service.py#L783-L799 | def get_extended_metadata(self, item_id):
"""Get extended metadata for a media item, such as related items.
Args:
item_id (str): The item for which metadata is required.
Returns:
~collections.OrderedDict: The item's extended metadata or None.
See also:
... | [
"def",
"get_extended_metadata",
"(",
"self",
",",
"item_id",
")",
":",
"response",
"=",
"self",
".",
"soap_client",
".",
"call",
"(",
"'getExtendedMetadata'",
",",
"[",
"(",
"'id'",
",",
"item_id",
")",
"]",
")",
"return",
"response",
".",
"get",
"(",
"'... | Get extended metadata for a media item, such as related items.
Args:
item_id (str): The item for which metadata is required.
Returns:
~collections.OrderedDict: The item's extended metadata or None.
See also:
The Sonos `getExtendedMetadata API
<h... | [
"Get",
"extended",
"metadata",
"for",
"a",
"media",
"item",
"such",
"as",
"related",
"items",
"."
] | python | train |
d0c-s4vage/pfp | pfp/interp.py | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L730-L738 | def get_curr_lines(self):
"""Return the current line number in the template,
as well as the surrounding source lines
"""
start = max(0, self._coord.line - 5)
end = min(len(self._template_lines), self._coord.line + 4)
lines = [(x, self._template_lines[x]) for x in six.mov... | [
"def",
"get_curr_lines",
"(",
"self",
")",
":",
"start",
"=",
"max",
"(",
"0",
",",
"self",
".",
"_coord",
".",
"line",
"-",
"5",
")",
"end",
"=",
"min",
"(",
"len",
"(",
"self",
".",
"_template_lines",
")",
",",
"self",
".",
"_coord",
".",
"line... | Return the current line number in the template,
as well as the surrounding source lines | [
"Return",
"the",
"current",
"line",
"number",
"in",
"the",
"template",
"as",
"well",
"as",
"the",
"surrounding",
"source",
"lines"
] | python | train |
prometheus/client_python | prometheus_client/decorator.py | https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/decorator.py#L229-L239 | def decorate(func, caller):
"""
decorate(func, caller) decorates a function using a caller.
"""
evaldict = dict(_call_=caller, _func_=func)
fun = FunctionMaker.create(
func, "return _call_(_func_, %(shortsignature)s)",
evaldict, __wrapped__=func)
if hasattr(func, '__qualname__'):... | [
"def",
"decorate",
"(",
"func",
",",
"caller",
")",
":",
"evaldict",
"=",
"dict",
"(",
"_call_",
"=",
"caller",
",",
"_func_",
"=",
"func",
")",
"fun",
"=",
"FunctionMaker",
".",
"create",
"(",
"func",
",",
"\"return _call_(_func_, %(shortsignature)s)\"",
",... | decorate(func, caller) decorates a function using a caller. | [
"decorate",
"(",
"func",
"caller",
")",
"decorates",
"a",
"function",
"using",
"a",
"caller",
"."
] | python | train |
JukeboxPipeline/jukebox-core | src/jukeboxcore/addons/guerilla/guerillamgmt.py | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/addons/guerilla/guerillamgmt.py#L2372-L2386 | def user_remove_prj(self, *args, **kwargs):
"""Remove the selected project from the user
:returns: None
:rtype: None
:raises: None
"""
if not self.cur_user:
return
i = self.user_prj_tablev.currentIndex()
item = i.internalPointer()
if i... | [
"def",
"user_remove_prj",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"cur_user",
":",
"return",
"i",
"=",
"self",
".",
"user_prj_tablev",
".",
"currentIndex",
"(",
")",
"item",
"=",
"i",
".",
"internal... | Remove the selected project from the user
:returns: None
:rtype: None
:raises: None | [
"Remove",
"the",
"selected",
"project",
"from",
"the",
"user"
] | python | train |
spyder-ide/spyder | spyder/plugins/variableexplorer/widgets/arrayeditor.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/arrayeditor.py#L585-L598 | def change_format(self):
"""Change display format"""
format, valid = QInputDialog.getText(self, _( 'Format'),
_( "Float formatting"),
QLineEdit.Normal, self.model.get_format())
if valid:
format = str(format)
... | [
"def",
"change_format",
"(",
"self",
")",
":",
"format",
",",
"valid",
"=",
"QInputDialog",
".",
"getText",
"(",
"self",
",",
"_",
"(",
"'Format'",
")",
",",
"_",
"(",
"\"Float formatting\"",
")",
",",
"QLineEdit",
".",
"Normal",
",",
"self",
".",
"mod... | Change display format | [
"Change",
"display",
"format"
] | python | train |
andrewda/frc-livescore | livescore/simpleocr_utils/processor.py | https://github.com/andrewda/frc-livescore/blob/71594cd6d2c8b6c5feb3889bb05552d09b8128b1/livescore/simpleocr_utils/processor.py#L13-L22 | def _broadcast(src_processor, src_atr_name, dest_processors, dest_atr_name, transform_function):
"""
To be used exclusively by create_broadcast.
A broadcast function gets an attribute on the src_processor and
sets it (possibly under a different name) on dest_processors
"""
value = getattr(src_pr... | [
"def",
"_broadcast",
"(",
"src_processor",
",",
"src_atr_name",
",",
"dest_processors",
",",
"dest_atr_name",
",",
"transform_function",
")",
":",
"value",
"=",
"getattr",
"(",
"src_processor",
",",
"src_atr_name",
")",
"value",
"=",
"transform_function",
"(",
"va... | To be used exclusively by create_broadcast.
A broadcast function gets an attribute on the src_processor and
sets it (possibly under a different name) on dest_processors | [
"To",
"be",
"used",
"exclusively",
"by",
"create_broadcast",
".",
"A",
"broadcast",
"function",
"gets",
"an",
"attribute",
"on",
"the",
"src_processor",
"and",
"sets",
"it",
"(",
"possibly",
"under",
"a",
"different",
"name",
")",
"on",
"dest_processors"
] | python | train |
libtcod/python-tcod | scripts/tag_release.py | https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/scripts/tag_release.py#L29-L45 | def parse_changelog(args: Any) -> Tuple[str, str]:
"""Return an updated changelog and and the list of changes."""
with open("CHANGELOG.rst", "r") as file:
match = re.match(
pattern=r"(.*?Unreleased\n---+\n)(.+?)(\n*[^\n]+\n---+\n.*)",
string=file.read(),
flags=re.DOTA... | [
"def",
"parse_changelog",
"(",
"args",
":",
"Any",
")",
"->",
"Tuple",
"[",
"str",
",",
"str",
"]",
":",
"with",
"open",
"(",
"\"CHANGELOG.rst\"",
",",
"\"r\"",
")",
"as",
"file",
":",
"match",
"=",
"re",
".",
"match",
"(",
"pattern",
"=",
"r\"(.*?Un... | Return an updated changelog and and the list of changes. | [
"Return",
"an",
"updated",
"changelog",
"and",
"and",
"the",
"list",
"of",
"changes",
"."
] | python | train |
apache/spark | python/pyspark/rdd.py | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L1876-L1891 | def aggregateByKey(self, zeroValue, seqFunc, combFunc, numPartitions=None,
partitionFunc=portable_hash):
"""
Aggregate the values of each key, using given combine functions and a neutral
"zero value". This function can return a different result type, U, than the type
... | [
"def",
"aggregateByKey",
"(",
"self",
",",
"zeroValue",
",",
"seqFunc",
",",
"combFunc",
",",
"numPartitions",
"=",
"None",
",",
"partitionFunc",
"=",
"portable_hash",
")",
":",
"def",
"createZero",
"(",
")",
":",
"return",
"copy",
".",
"deepcopy",
"(",
"z... | Aggregate the values of each key, using given combine functions and a neutral
"zero value". This function can return a different result type, U, than the type
of the values in this RDD, V. Thus, we need one operation for merging a V into
a U and one operation for merging two U's, The former oper... | [
"Aggregate",
"the",
"values",
"of",
"each",
"key",
"using",
"given",
"combine",
"functions",
"and",
"a",
"neutral",
"zero",
"value",
".",
"This",
"function",
"can",
"return",
"a",
"different",
"result",
"type",
"U",
"than",
"the",
"type",
"of",
"the",
"val... | python | train |
push-things/wallabag_api | wallabag_api/wallabag.py | https://github.com/push-things/wallabag_api/blob/8d1e10a6ebc03d1ac9af2b38b57eb69f29b4216e/wallabag_api/wallabag.py#L236-L276 | async def patch_entries(self, entry, **kwargs):
"""
PATCH /api/entries/{entry}.{_format}
Change several properties of an entry
:param entry: the entry to 'patch' / update
:param kwargs: can contain one of the following
title: string
tags: a list of tags ... | [
"async",
"def",
"patch_entries",
"(",
"self",
",",
"entry",
",",
"*",
"*",
"kwargs",
")",
":",
"# default values",
"params",
"=",
"{",
"'access_token'",
":",
"self",
".",
"token",
",",
"'title'",
":",
"''",
",",
"'tags'",
":",
"[",
"]",
"}",
"if",
"'... | PATCH /api/entries/{entry}.{_format}
Change several properties of an entry
:param entry: the entry to 'patch' / update
:param kwargs: can contain one of the following
title: string
tags: a list of tags tag1,tag2,tag3
archive: '0' or '1', default '0' archive... | [
"PATCH",
"/",
"api",
"/",
"entries",
"/",
"{",
"entry",
"}",
".",
"{",
"_format",
"}"
] | python | train |
pandas-dev/pandas | pandas/core/sparse/series.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/series.py#L268-L284 | def _ixs(self, i, axis=0):
"""
Return the i-th value or values in the SparseSeries by location
Parameters
----------
i : int, slice, or sequence of integers
Returns
-------
value : scalar (int) or Series (slice, sequence)
"""
label = self... | [
"def",
"_ixs",
"(",
"self",
",",
"i",
",",
"axis",
"=",
"0",
")",
":",
"label",
"=",
"self",
".",
"index",
"[",
"i",
"]",
"if",
"isinstance",
"(",
"label",
",",
"Index",
")",
":",
"return",
"self",
".",
"take",
"(",
"i",
",",
"axis",
"=",
"ax... | Return the i-th value or values in the SparseSeries by location
Parameters
----------
i : int, slice, or sequence of integers
Returns
-------
value : scalar (int) or Series (slice, sequence) | [
"Return",
"the",
"i",
"-",
"th",
"value",
"or",
"values",
"in",
"the",
"SparseSeries",
"by",
"location"
] | python | train |
ryanjdillon/pyotelem | pyotelem/plots/plotutils.py | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/plots/plotutils.py#L42-L63 | def hourminsec(n_seconds):
'''Generate a string of hours and minutes from total number of seconds
Args
----
n_seconds: int
Total number of seconds to calculate hours, minutes, and seconds from
Returns
-------
hours: int
Number of hours in `n_seconds`
minutes: int
... | [
"def",
"hourminsec",
"(",
"n_seconds",
")",
":",
"hours",
",",
"remainder",
"=",
"divmod",
"(",
"n_seconds",
",",
"3600",
")",
"minutes",
",",
"seconds",
"=",
"divmod",
"(",
"remainder",
",",
"60",
")",
"return",
"abs",
"(",
"hours",
")",
",",
"abs",
... | Generate a string of hours and minutes from total number of seconds
Args
----
n_seconds: int
Total number of seconds to calculate hours, minutes, and seconds from
Returns
-------
hours: int
Number of hours in `n_seconds`
minutes: int
Remaining minutes in `n_seconds`... | [
"Generate",
"a",
"string",
"of",
"hours",
"and",
"minutes",
"from",
"total",
"number",
"of",
"seconds"
] | python | train |
xapple/plumbing | plumbing/slurm/job.py | https://github.com/xapple/plumbing/blob/4a7706c7722f5996d0ca366f191aff9ac145880a/plumbing/slurm/job.py#L263-L267 | def wait_locally(self):
"""If you have run the query in a non-blocking way, call this method to pause
until the query is finished."""
try: self.thread.join(sys.maxint) # maxint timeout so that we can Ctrl-C them
except KeyboardInterrupt: print "Stopped waiting on job '%s'" % self.kwargs[... | [
"def",
"wait_locally",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"thread",
".",
"join",
"(",
"sys",
".",
"maxint",
")",
"# maxint timeout so that we can Ctrl-C them",
"except",
"KeyboardInterrupt",
":",
"print",
"\"Stopped waiting on job '%s'\"",
"%",
"self",
... | If you have run the query in a non-blocking way, call this method to pause
until the query is finished. | [
"If",
"you",
"have",
"run",
"the",
"query",
"in",
"a",
"non",
"-",
"blocking",
"way",
"call",
"this",
"method",
"to",
"pause",
"until",
"the",
"query",
"is",
"finished",
"."
] | python | train |
google/openhtf | openhtf/util/console_output.py | https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/util/console_output.py#L136-L160 | def cli_print(msg, color='', end=None, file=sys.stdout, logger=_LOG):
"""Print the message to file and also log it.
This function is intended as a 'tee' mechanism to enable the CLI interface as
a first-class citizen, while ensuring that everything the operator sees also
has an analogous logging entry in the te... | [
"def",
"cli_print",
"(",
"msg",
",",
"color",
"=",
"''",
",",
"end",
"=",
"None",
",",
"file",
"=",
"sys",
".",
"stdout",
",",
"logger",
"=",
"_LOG",
")",
":",
"if",
"logger",
":",
"logger",
".",
"debug",
"(",
"'-> {}'",
".",
"format",
"(",
"msg"... | Print the message to file and also log it.
This function is intended as a 'tee' mechanism to enable the CLI interface as
a first-class citizen, while ensuring that everything the operator sees also
has an analogous logging entry in the test record for later inspection.
Args:
msg: The message to print/log.... | [
"Print",
"the",
"message",
"to",
"file",
"and",
"also",
"log",
"it",
"."
] | python | train |
tensorflow/tensorboard | tensorboard/compat/tensorflow_stub/io/gfile.py | https://github.com/tensorflow/tensorboard/blob/8e5f497b48e40f2a774f85416b8a35ac0693c35e/tensorboard/compat/tensorflow_stub/io/gfile.py#L161-L169 | def bucket_and_path(self, url):
"""Split an S3-prefixed URL into bucket and path."""
url = compat.as_str_any(url)
if url.startswith("s3://"):
url = url[len("s3://"):]
idx = url.index("/")
bucket = url[:idx]
path = url[(idx + 1):]
return bucket, path | [
"def",
"bucket_and_path",
"(",
"self",
",",
"url",
")",
":",
"url",
"=",
"compat",
".",
"as_str_any",
"(",
"url",
")",
"if",
"url",
".",
"startswith",
"(",
"\"s3://\"",
")",
":",
"url",
"=",
"url",
"[",
"len",
"(",
"\"s3://\"",
")",
":",
"]",
"idx"... | Split an S3-prefixed URL into bucket and path. | [
"Split",
"an",
"S3",
"-",
"prefixed",
"URL",
"into",
"bucket",
"and",
"path",
"."
] | python | train |
michal-stuglik/django-blastplus | blastplus/forms.py | https://github.com/michal-stuglik/django-blastplus/blob/4f5e15fb9f8069c3bed5f8fd941c4b9891daad4b/blastplus/forms.py#L138-L174 | def validate_sequence(sequence: str, sequence_is_as_nucleotide=True):
"""Validate sequence in blast/tblastn form. """
tmp_seq = tempfile.NamedTemporaryFile(mode="wb+", delete=False)
if len(str(sequence).strip()) == 0:
raise forms.ValidationError(blast_settings.BLAST_CORRECT_SEQ_ERROR_MSG)
if... | [
"def",
"validate_sequence",
"(",
"sequence",
":",
"str",
",",
"sequence_is_as_nucleotide",
"=",
"True",
")",
":",
"tmp_seq",
"=",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"mode",
"=",
"\"wb+\"",
",",
"delete",
"=",
"False",
")",
"if",
"len",
"(",
"str",
... | Validate sequence in blast/tblastn form. | [
"Validate",
"sequence",
"in",
"blast",
"/",
"tblastn",
"form",
"."
] | python | train |
jbrudvik/yahooscraper | yahooscraper/fantasy/team.py | https://github.com/jbrudvik/yahooscraper/blob/e880323fea0dd25f03410eea9d088760ba7c3528/yahooscraper/fantasy/team.py#L83-L91 | def start_active_players_path(page):
"""
Return the path in the "Start Active Players" button
"""
soup = BeautifulSoup(page)
try:
return soup.find('a', href=True, text='Start Active Players')['href']
except:
return None | [
"def",
"start_active_players_path",
"(",
"page",
")",
":",
"soup",
"=",
"BeautifulSoup",
"(",
"page",
")",
"try",
":",
"return",
"soup",
".",
"find",
"(",
"'a'",
",",
"href",
"=",
"True",
",",
"text",
"=",
"'Start Active Players'",
")",
"[",
"'href'",
"]... | Return the path in the "Start Active Players" button | [
"Return",
"the",
"path",
"in",
"the",
"Start",
"Active",
"Players",
"button"
] | python | train |
quantopian/zipline | zipline/pipeline/loaders/synthetic.py | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/synthetic.py#L319-L329 | def expected_bar_value(asset_id, date, colname):
"""
Check that the raw value for an asset/date/column triple is as
expected.
Used by tests to verify data written by a writer.
"""
from_asset = asset_id * 100000
from_colname = OHLCV.index(colname) * 1000
from_date = (date - PSEUDO_EPOCH)... | [
"def",
"expected_bar_value",
"(",
"asset_id",
",",
"date",
",",
"colname",
")",
":",
"from_asset",
"=",
"asset_id",
"*",
"100000",
"from_colname",
"=",
"OHLCV",
".",
"index",
"(",
"colname",
")",
"*",
"1000",
"from_date",
"=",
"(",
"date",
"-",
"PSEUDO_EPO... | Check that the raw value for an asset/date/column triple is as
expected.
Used by tests to verify data written by a writer. | [
"Check",
"that",
"the",
"raw",
"value",
"for",
"an",
"asset",
"/",
"date",
"/",
"column",
"triple",
"is",
"as",
"expected",
"."
] | python | train |
pyviz/geoviews | geoviews/data/iris.py | https://github.com/pyviz/geoviews/blob/cc70ac2d5a96307769bc6192eaef8576c3d24b30/geoviews/data/iris.py#L328-L335 | def add_dimension(cls, columns, dimension, dim_pos, values, vdim):
"""
Adding value dimensions not currently supported by iris interface.
Adding key dimensions not possible on dense interfaces.
"""
if not vdim:
raise Exception("Cannot add key dimension to a dense repr... | [
"def",
"add_dimension",
"(",
"cls",
",",
"columns",
",",
"dimension",
",",
"dim_pos",
",",
"values",
",",
"vdim",
")",
":",
"if",
"not",
"vdim",
":",
"raise",
"Exception",
"(",
"\"Cannot add key dimension to a dense representation.\"",
")",
"raise",
"NotImplemente... | Adding value dimensions not currently supported by iris interface.
Adding key dimensions not possible on dense interfaces. | [
"Adding",
"value",
"dimensions",
"not",
"currently",
"supported",
"by",
"iris",
"interface",
".",
"Adding",
"key",
"dimensions",
"not",
"possible",
"on",
"dense",
"interfaces",
"."
] | python | train |
spyder-ide/spyder | spyder/plugins/onlinehelp/onlinehelp.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/onlinehelp/onlinehelp.py#L83-L88 | def closing_plugin(self, cancelable=False):
"""Perform actions before parent main window is closed"""
self.save_history()
self.set_option('zoom_factor',
self.pydocbrowser.webview.get_zoom_factor())
return True | [
"def",
"closing_plugin",
"(",
"self",
",",
"cancelable",
"=",
"False",
")",
":",
"self",
".",
"save_history",
"(",
")",
"self",
".",
"set_option",
"(",
"'zoom_factor'",
",",
"self",
".",
"pydocbrowser",
".",
"webview",
".",
"get_zoom_factor",
"(",
")",
")"... | Perform actions before parent main window is closed | [
"Perform",
"actions",
"before",
"parent",
"main",
"window",
"is",
"closed"
] | python | train |
kensho-technologies/graphql-compiler | graphql_compiler/schema_generation/schema_graph.py | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L371-L381 | def validate_properties_exist(self, classname, property_names):
"""Validate that the specified property names are indeed defined on the given class."""
schema_element = self.get_element_by_class_name(classname)
requested_properties = set(property_names)
available_properties = set(schema... | [
"def",
"validate_properties_exist",
"(",
"self",
",",
"classname",
",",
"property_names",
")",
":",
"schema_element",
"=",
"self",
".",
"get_element_by_class_name",
"(",
"classname",
")",
"requested_properties",
"=",
"set",
"(",
"property_names",
")",
"available_prope... | Validate that the specified property names are indeed defined on the given class. | [
"Validate",
"that",
"the",
"specified",
"property",
"names",
"are",
"indeed",
"defined",
"on",
"the",
"given",
"class",
"."
] | python | train |
saltstack/salt | salt/cloud/clouds/azurearm.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/azurearm.py#L1744-L1769 | def list_blobs(call=None, kwargs=None): # pylint: disable=unused-argument
'''
List blobs.
'''
if kwargs is None:
kwargs = {}
if 'container' not in kwargs:
raise SaltCloudSystemExit(
'A container must be specified'
)
storageservice = _get_block_blob_service(... | [
"def",
"list_blobs",
"(",
"call",
"=",
"None",
",",
"kwargs",
"=",
"None",
")",
":",
"# pylint: disable=unused-argument",
"if",
"kwargs",
"is",
"None",
":",
"kwargs",
"=",
"{",
"}",
"if",
"'container'",
"not",
"in",
"kwargs",
":",
"raise",
"SaltCloudSystemEx... | List blobs. | [
"List",
"blobs",
"."
] | python | train |
evhub/coconut | coconut/compiler/compiler.py | https://github.com/evhub/coconut/blob/ff97177344e7604e89a0a98a977a87ed2a56fc6d/coconut/compiler/compiler.py#L451-L455 | def set_skips(self, skips):
"""Set the line skips."""
skips.sort()
internal_assert(lambda: len(set(skips)) == len(skips), "duplicate line skip(s) in skips", skips)
self.skips = skips | [
"def",
"set_skips",
"(",
"self",
",",
"skips",
")",
":",
"skips",
".",
"sort",
"(",
")",
"internal_assert",
"(",
"lambda",
":",
"len",
"(",
"set",
"(",
"skips",
")",
")",
"==",
"len",
"(",
"skips",
")",
",",
"\"duplicate line skip(s) in skips\"",
",",
... | Set the line skips. | [
"Set",
"the",
"line",
"skips",
"."
] | python | train |
poldracklab/niworkflows | niworkflows/interfaces/masks.py | https://github.com/poldracklab/niworkflows/blob/254f4b4fcc5e6ecb29d2f4602a30786b913ecce5/niworkflows/interfaces/masks.py#L46-L58 | def _post_run_hook(self, runtime):
''' generates a report showing slices from each axis of an arbitrary
volume of in_file, with the resulting binary brain mask overlaid '''
self._anat_file = self.inputs.in_file
self._mask_file = self.aggregate_outputs(runtime=runtime).mask_file
... | [
"def",
"_post_run_hook",
"(",
"self",
",",
"runtime",
")",
":",
"self",
".",
"_anat_file",
"=",
"self",
".",
"inputs",
".",
"in_file",
"self",
".",
"_mask_file",
"=",
"self",
".",
"aggregate_outputs",
"(",
"runtime",
"=",
"runtime",
")",
".",
"mask_file",
... | generates a report showing slices from each axis of an arbitrary
volume of in_file, with the resulting binary brain mask overlaid | [
"generates",
"a",
"report",
"showing",
"slices",
"from",
"each",
"axis",
"of",
"an",
"arbitrary",
"volume",
"of",
"in_file",
"with",
"the",
"resulting",
"binary",
"brain",
"mask",
"overlaid"
] | python | train |
dnanexus/dx-toolkit | src/python/dxpy/bindings/dxapplet.py | https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/bindings/dxapplet.py#L384-L394 | def run(self, applet_input, *args, **kwargs):
"""
Creates a new job that executes the function "main" of this applet with
the given input *applet_input*.
See :meth:`dxpy.bindings.dxapplet.DXExecutable.run` for the available
args.
"""
# Rename applet_input arg to ... | [
"def",
"run",
"(",
"self",
",",
"applet_input",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Rename applet_input arg to preserve API compatibility when calling",
"# DXApplet.run(applet_input=...)",
"return",
"super",
"(",
"DXApplet",
",",
"self",
")",
".",
... | Creates a new job that executes the function "main" of this applet with
the given input *applet_input*.
See :meth:`dxpy.bindings.dxapplet.DXExecutable.run` for the available
args. | [
"Creates",
"a",
"new",
"job",
"that",
"executes",
"the",
"function",
"main",
"of",
"this",
"applet",
"with",
"the",
"given",
"input",
"*",
"applet_input",
"*",
"."
] | python | train |
pyamg/pyamg | pyamg/krylov/_gmres_mgs.py | https://github.com/pyamg/pyamg/blob/89dc54aa27e278f65d2f54bdaf16ab97d7768fa6/pyamg/krylov/_gmres_mgs.py#L41-L365 | def gmres_mgs(A, b, x0=None, tol=1e-5, restrt=None, maxiter=None, xtype=None,
M=None, callback=None, residuals=None, reorth=False):
"""Generalized Minimum Residual Method (GMRES) based on MGS.
GMRES iteratively refines the initial solution guess to the system
Ax = b
Modified Gram-Schmidt ... | [
"def",
"gmres_mgs",
"(",
"A",
",",
"b",
",",
"x0",
"=",
"None",
",",
"tol",
"=",
"1e-5",
",",
"restrt",
"=",
"None",
",",
"maxiter",
"=",
"None",
",",
"xtype",
"=",
"None",
",",
"M",
"=",
"None",
",",
"callback",
"=",
"None",
",",
"residuals",
... | Generalized Minimum Residual Method (GMRES) based on MGS.
GMRES iteratively refines the initial solution guess to the system
Ax = b
Modified Gram-Schmidt version
Parameters
----------
A : array, matrix, sparse matrix, LinearOperator
n x n, linear system to solve
b : array, matrix
... | [
"Generalized",
"Minimum",
"Residual",
"Method",
"(",
"GMRES",
")",
"based",
"on",
"MGS",
"."
] | python | train |
benedictpaten/sonLib | bioio.py | https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/bioio.py#L762-L789 | def fastqRead(fileHandleOrFile):
"""Reads a fastq file iteratively
"""
fileHandle = _getFileHandle(fileHandleOrFile)
line = fileHandle.readline()
while line != '':
if line[0] == '@':
name = line[1:-1]
seq = fileHandle.readline()[:-1]
plus = fileHandle.read... | [
"def",
"fastqRead",
"(",
"fileHandleOrFile",
")",
":",
"fileHandle",
"=",
"_getFileHandle",
"(",
"fileHandleOrFile",
")",
"line",
"=",
"fileHandle",
".",
"readline",
"(",
")",
"while",
"line",
"!=",
"''",
":",
"if",
"line",
"[",
"0",
"]",
"==",
"'@'",
":... | Reads a fastq file iteratively | [
"Reads",
"a",
"fastq",
"file",
"iteratively"
] | python | train |
LogicalDash/LiSE | allegedb/allegedb/query.py | https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/query.py#L481-L497 | def edge_val_dump(self):
"""Yield the entire contents of the edge_val table."""
self._flush_edge_val()
for (
graph, orig, dest, idx, key, branch, turn, tick, value
) in self.sql('edge_val_dump'):
yield (
self.unpack(graph),
self... | [
"def",
"edge_val_dump",
"(",
"self",
")",
":",
"self",
".",
"_flush_edge_val",
"(",
")",
"for",
"(",
"graph",
",",
"orig",
",",
"dest",
",",
"idx",
",",
"key",
",",
"branch",
",",
"turn",
",",
"tick",
",",
"value",
")",
"in",
"self",
".",
"sql",
... | Yield the entire contents of the edge_val table. | [
"Yield",
"the",
"entire",
"contents",
"of",
"the",
"edge_val",
"table",
"."
] | python | train |
fuzeman/PyUPnP | pyupnp/lict.py | https://github.com/fuzeman/PyUPnP/blob/6dea64be299952346a14300ab6cc7dac42736433/pyupnp/lict.py#L337-L341 | def setdefault(self, k, d=None):
""" D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D """
if k not in self._col_dict:
self._set_key(k, d)
return self._col_dict.get(k) | [
"def",
"setdefault",
"(",
"self",
",",
"k",
",",
"d",
"=",
"None",
")",
":",
"if",
"k",
"not",
"in",
"self",
".",
"_col_dict",
":",
"self",
".",
"_set_key",
"(",
"k",
",",
"d",
")",
"return",
"self",
".",
"_col_dict",
".",
"get",
"(",
"k",
")"
... | D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D | [
"D",
".",
"setdefault",
"(",
"k",
"[",
"d",
"]",
")",
"-",
">",
"D",
".",
"get",
"(",
"k",
"d",
")",
"also",
"set",
"D",
"[",
"k",
"]",
"=",
"d",
"if",
"k",
"not",
"in",
"D"
] | python | train |
ericmjl/hiveplot | hiveplot/hiveplot.py | https://github.com/ericmjl/hiveplot/blob/f465a7118b7f005c83ab054d400deb02bd9f7410/hiveplot/hiveplot.py#L338-L353 | def correct_angles(self, start_angle, end_angle):
"""
This function corrects for the following problems in the edges:
"""
# Edges going the anti-clockwise direction involves angle = 0.
if start_angle == 0 and (end_angle - start_angle > np.pi):
start_angle = np.pi * 2
... | [
"def",
"correct_angles",
"(",
"self",
",",
"start_angle",
",",
"end_angle",
")",
":",
"# Edges going the anti-clockwise direction involves angle = 0.",
"if",
"start_angle",
"==",
"0",
"and",
"(",
"end_angle",
"-",
"start_angle",
">",
"np",
".",
"pi",
")",
":",
"st... | This function corrects for the following problems in the edges: | [
"This",
"function",
"corrects",
"for",
"the",
"following",
"problems",
"in",
"the",
"edges",
":"
] | python | valid |
metachris/RPIO | source/RPIO/_RPIO.py | https://github.com/metachris/RPIO/blob/be1942a69b2592ddacd9dc833d2668a19aafd8d2/source/RPIO/_RPIO.py#L114-L217 | def add_interrupt_callback(self, gpio_id, callback, edge='both',
pull_up_down=_GPIO.PUD_OFF, threaded_callback=False,
debounce_timeout_ms=None):
"""
Add a callback to be executed when the value on 'gpio_id' changes to
the edge specified via the 'edge' parameter (default='... | [
"def",
"add_interrupt_callback",
"(",
"self",
",",
"gpio_id",
",",
"callback",
",",
"edge",
"=",
"'both'",
",",
"pull_up_down",
"=",
"_GPIO",
".",
"PUD_OFF",
",",
"threaded_callback",
"=",
"False",
",",
"debounce_timeout_ms",
"=",
"None",
")",
":",
"gpio_id",
... | Add a callback to be executed when the value on 'gpio_id' changes to
the edge specified via the 'edge' parameter (default='both').
`pull_up_down` can be set to `RPIO.PUD_UP`, `RPIO.PUD_DOWN`, and
`RPIO.PUD_OFF`.
If `threaded_callback` is True, the callback will be started
insid... | [
"Add",
"a",
"callback",
"to",
"be",
"executed",
"when",
"the",
"value",
"on",
"gpio_id",
"changes",
"to",
"the",
"edge",
"specified",
"via",
"the",
"edge",
"parameter",
"(",
"default",
"=",
"both",
")",
"."
] | python | train |
KarchinLab/probabilistic2020 | prob2020/python/gene_sequence.py | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/gene_sequence.py#L153-L195 | def _fetch_3ss_fasta(fasta, gene_name, exon_num,
chrom, strand, start, end):
"""Retreives the 3' SS sequence flanking the specified exon.
Returns a string in fasta format with the first line containing
a ">" and the second line contains the two base pairs of 3' SS.
Parameters
... | [
"def",
"_fetch_3ss_fasta",
"(",
"fasta",
",",
"gene_name",
",",
"exon_num",
",",
"chrom",
",",
"strand",
",",
"start",
",",
"end",
")",
":",
"if",
"strand",
"==",
"'-'",
":",
"ss_seq",
"=",
"fasta",
".",
"fetch",
"(",
"reference",
"=",
"chrom",
",",
... | Retreives the 3' SS sequence flanking the specified exon.
Returns a string in fasta format with the first line containing
a ">" and the second line contains the two base pairs of 3' SS.
Parameters
----------
fasta : pysam.Fastafile
fasta object from pysam
gene_name : str
gene n... | [
"Retreives",
"the",
"3",
"SS",
"sequence",
"flanking",
"the",
"specified",
"exon",
"."
] | python | train |
google/prettytensor | prettytensor/local_trainer.py | https://github.com/google/prettytensor/blob/75daa0b11252590f548da5647addc0ea610c4c45/prettytensor/local_trainer.py#L327-L357 | def train_model(self,
train_op,
cost_to_log,
num_steps,
feed_vars=(),
feed_data=None,
print_every=100):
"""Trains the given model.
Args:
train_op: The training operation.
cost_to_log: A cost ... | [
"def",
"train_model",
"(",
"self",
",",
"train_op",
",",
"cost_to_log",
",",
"num_steps",
",",
"feed_vars",
"=",
"(",
")",
",",
"feed_data",
"=",
"None",
",",
"print_every",
"=",
"100",
")",
":",
"costs",
"=",
"[",
"train_op",
"]",
"if",
"(",
"isinstan... | Trains the given model.
Args:
train_op: The training operation.
cost_to_log: A cost to log.
num_steps: Number of batches to run.
feed_vars: A list or tuple of the variables that will be fed.
feed_data: A generator that produces tuples of the same length as
feed_vars.
pri... | [
"Trains",
"the",
"given",
"model",
"."
] | python | train |
DataDog/integrations-core | tokumx/datadog_checks/tokumx/vendor/pymongo/bulk.py | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/bulk.py#L241-L252 | def add_replace(self, selector, replacement, upsert=False,
collation=None):
"""Create a replace document and add it to the list of ops.
"""
validate_ok_for_replace(replacement)
cmd = SON([('q', selector), ('u', replacement),
('multi', False), ('upse... | [
"def",
"add_replace",
"(",
"self",
",",
"selector",
",",
"replacement",
",",
"upsert",
"=",
"False",
",",
"collation",
"=",
"None",
")",
":",
"validate_ok_for_replace",
"(",
"replacement",
")",
"cmd",
"=",
"SON",
"(",
"[",
"(",
"'q'",
",",
"selector",
")... | Create a replace document and add it to the list of ops. | [
"Create",
"a",
"replace",
"document",
"and",
"add",
"it",
"to",
"the",
"list",
"of",
"ops",
"."
] | python | train |
NatLibFi/Skosify | skosify/skosify.py | https://github.com/NatLibFi/Skosify/blob/1d269987f10df08e706272dcf6a86aef4abebcde/skosify/skosify.py#L691-L705 | def cleanup_unreachable(rdf):
"""Remove triples which cannot be reached from the concepts by graph
traversal."""
all_subjects = set(rdf.subjects())
logging.debug("total subject resources: %d", len(all_subjects))
reachable = find_reachable(rdf, SKOS.Concept)
nonreachable = all_subjects - reach... | [
"def",
"cleanup_unreachable",
"(",
"rdf",
")",
":",
"all_subjects",
"=",
"set",
"(",
"rdf",
".",
"subjects",
"(",
")",
")",
"logging",
".",
"debug",
"(",
"\"total subject resources: %d\"",
",",
"len",
"(",
"all_subjects",
")",
")",
"reachable",
"=",
"find_re... | Remove triples which cannot be reached from the concepts by graph
traversal. | [
"Remove",
"triples",
"which",
"cannot",
"be",
"reached",
"from",
"the",
"concepts",
"by",
"graph",
"traversal",
"."
] | python | train |
linkedin/Zopkio | zopkio/deployer.py | https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/deployer.py#L236-L246 | def fetch_logs(self, unique_id, logs, directory, pattern=constants.FILTER_NAME_ALLOW_NONE):
""" Copies logs from the remote host that the process is running on to the provided directory
:Parameter unique_id the unique_id of the process in question
:Parameter logs a list of logs given by absolute path from ... | [
"def",
"fetch_logs",
"(",
"self",
",",
"unique_id",
",",
"logs",
",",
"directory",
",",
"pattern",
"=",
"constants",
".",
"FILTER_NAME_ALLOW_NONE",
")",
":",
"hostname",
"=",
"self",
".",
"processes",
"[",
"unique_id",
"]",
".",
"hostname",
"install_path",
"... | Copies logs from the remote host that the process is running on to the provided directory
:Parameter unique_id the unique_id of the process in question
:Parameter logs a list of logs given by absolute path from the remote host
:Parameter directory the local directory to store the copied logs
:Parameter... | [
"Copies",
"logs",
"from",
"the",
"remote",
"host",
"that",
"the",
"process",
"is",
"running",
"on",
"to",
"the",
"provided",
"directory"
] | python | train |
Kane610/axis | axis/port_cgi.py | https://github.com/Kane610/axis/blob/b2b44ce595c7b722b5e13eabcab7b91f048e1808/axis/port_cgi.py#L92-L96 | def name(self) -> str:
"""Return name relevant to direction."""
if self.direction == DIRECTION_IN:
return self.raw.get('Input.Name', '')
return self.raw.get('Output.Name', '') | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"if",
"self",
".",
"direction",
"==",
"DIRECTION_IN",
":",
"return",
"self",
".",
"raw",
".",
"get",
"(",
"'Input.Name'",
",",
"''",
")",
"return",
"self",
".",
"raw",
".",
"get",
"(",
"'Output.Name'... | Return name relevant to direction. | [
"Return",
"name",
"relevant",
"to",
"direction",
"."
] | python | train |
pln-fing-udelar/fast-krippendorff | krippendorff/krippendorff.py | https://github.com/pln-fing-udelar/fast-krippendorff/blob/fbc983f206d41f76a6e8da8cabd7114941634420/krippendorff/krippendorff.py#L88-L110 | def _distances(value_domain, distance_metric, n_v):
"""Distances of the different possible values.
Parameters
----------
value_domain : array_like, with shape (V,)
Possible values V the units can take.
If the level of measurement is not nominal, it must be ordered.
distance_metric ... | [
"def",
"_distances",
"(",
"value_domain",
",",
"distance_metric",
",",
"n_v",
")",
":",
"return",
"np",
".",
"array",
"(",
"[",
"[",
"distance_metric",
"(",
"v1",
",",
"v2",
",",
"i1",
"=",
"i1",
",",
"i2",
"=",
"i2",
",",
"n_v",
"=",
"n_v",
")",
... | Distances of the different possible values.
Parameters
----------
value_domain : array_like, with shape (V,)
Possible values V the units can take.
If the level of measurement is not nominal, it must be ordered.
distance_metric : callable
Callable that return the distance of two... | [
"Distances",
"of",
"the",
"different",
"possible",
"values",
"."
] | python | valid |
genialis/resolwe | resolwe/flow/signals.py | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/signals.py#L48-L61 | def delete_relation(sender, instance, **kwargs):
"""Delete the Relation object when the last Entity is removed."""
def process_signal(relation_id):
"""Get the relation and delete it if it has no entities left."""
try:
relation = Relation.objects.get(pk=relation_id)
except Rel... | [
"def",
"delete_relation",
"(",
"sender",
",",
"instance",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"process_signal",
"(",
"relation_id",
")",
":",
"\"\"\"Get the relation and delete it if it has no entities left.\"\"\"",
"try",
":",
"relation",
"=",
"Relation",
".",
... | Delete the Relation object when the last Entity is removed. | [
"Delete",
"the",
"Relation",
"object",
"when",
"the",
"last",
"Entity",
"is",
"removed",
"."
] | python | train |
tomplus/kubernetes_asyncio | kubernetes_asyncio/client/api/core_v1_api.py | https://github.com/tomplus/kubernetes_asyncio/blob/f9ab15317ec921409714c7afef11aeb0f579985d/kubernetes_asyncio/client/api/core_v1_api.py#L483-L504 | def connect_delete_node_proxy(self, name, **kwargs): # noqa: E501
"""connect_delete_node_proxy # noqa: E501
connect DELETE requests to proxy of Node # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
... | [
"def",
"connect_delete_node_proxy",
"(",
"self",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"# noqa: E501",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'async_req'",
")",
":",
"return",
"self",
".",
"... | connect_delete_node_proxy # noqa: E501
connect DELETE requests to proxy of Node # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.connect_delete_node_proxy(name, async_req=True)
... | [
"connect_delete_node_proxy",
"#",
"noqa",
":",
"E501"
] | python | train |
ehansis/ozelot | ozelot/etl/util.py | https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/ozelot/etl/util.py#L130-L161 | def sanitize(s,
normalize_whitespace=True,
normalize_unicode=True,
form='NFKC',
enforce_encoding=True,
encoding='utf-8'):
"""Normalize a string
Args:
s (unicode string): input unicode string
normalize_whitespace (bool): if True, n... | [
"def",
"sanitize",
"(",
"s",
",",
"normalize_whitespace",
"=",
"True",
",",
"normalize_unicode",
"=",
"True",
",",
"form",
"=",
"'NFKC'",
",",
"enforce_encoding",
"=",
"True",
",",
"encoding",
"=",
"'utf-8'",
")",
":",
"if",
"enforce_encoding",
":",
"s",
"... | Normalize a string
Args:
s (unicode string): input unicode string
normalize_whitespace (bool): if True, normalize all whitespace to single spaces (including newlines),
strip whitespace at start/end
normalize_unicode (bool): if True, normalize unicode for... | [
"Normalize",
"a",
"string"
] | python | train |
Jammy2211/PyAutoLens | autolens/data/array/grids.py | https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/data/array/grids.py#L907-L919 | def array_2d_from_array_1d(self, padded_array_1d):
""" Map a padded 1D array of values to its original 2D array, trimming all edge values.
Parameters
-----------
padded_array_1d : ndarray
A 1D array of values which were computed using the *PaddedRegularGrid*.
"""
... | [
"def",
"array_2d_from_array_1d",
"(",
"self",
",",
"padded_array_1d",
")",
":",
"padded_array_2d",
"=",
"self",
".",
"map_to_2d_keep_padded",
"(",
"padded_array_1d",
")",
"pad_size_0",
"=",
"self",
".",
"mask",
".",
"shape",
"[",
"0",
"]",
"-",
"self",
".",
... | Map a padded 1D array of values to its original 2D array, trimming all edge values.
Parameters
-----------
padded_array_1d : ndarray
A 1D array of values which were computed using the *PaddedRegularGrid*. | [
"Map",
"a",
"padded",
"1D",
"array",
"of",
"values",
"to",
"its",
"original",
"2D",
"array",
"trimming",
"all",
"edge",
"values",
"."
] | python | valid |
senseobservationsystems/commonsense-python-lib | senseapi.py | https://github.com/senseobservationsystems/commonsense-python-lib/blob/aac59a1751ef79eb830b3ca1fab6ef2c83931f87/senseapi.py#L1063-L1076 | def UsersChangePassword (self, current_password, new_password):
"""
Change the password for the current user
@param current_password (string) - md5 hash of the current password of the user
@param new_password (string) - md5 hash of the new password of the us... | [
"def",
"UsersChangePassword",
"(",
"self",
",",
"current_password",
",",
"new_password",
")",
":",
"if",
"self",
".",
"__SenseApiCall__",
"(",
"'/change_password'",
",",
"\"POST\"",
",",
"{",
"\"current_password\"",
":",
"current_password",
",",
"\"new_password\"",
... | Change the password for the current user
@param current_password (string) - md5 hash of the current password of the user
@param new_password (string) - md5 hash of the new password of the user (make sure to doublecheck!)
@return (bool) - Boolean indicat... | [
"Change",
"the",
"password",
"for",
"the",
"current",
"user"
] | python | train |
SHDShim/pytheos | pytheos/eqn_bm3.py | https://github.com/SHDShim/pytheos/blob/be079624405e92fbec60c5ead253eb5917e55237/pytheos/eqn_bm3.py#L184-L202 | def cal_g_bm3(p, g, k):
"""
calculate shear modulus at given pressure
:param p: pressure
:param g: [g0, g0p]
:param k: [v0, k0, k0p]
:return: shear modulus at high pressure
"""
v = cal_v_bm3(p, k)
v0 = k[0]
k0 = k[1]
kp = k[2]
g0 = g[0]
gp = g[1]
f = 0.5 * ((v / ... | [
"def",
"cal_g_bm3",
"(",
"p",
",",
"g",
",",
"k",
")",
":",
"v",
"=",
"cal_v_bm3",
"(",
"p",
",",
"k",
")",
"v0",
"=",
"k",
"[",
"0",
"]",
"k0",
"=",
"k",
"[",
"1",
"]",
"kp",
"=",
"k",
"[",
"2",
"]",
"g0",
"=",
"g",
"[",
"0",
"]",
... | calculate shear modulus at given pressure
:param p: pressure
:param g: [g0, g0p]
:param k: [v0, k0, k0p]
:return: shear modulus at high pressure | [
"calculate",
"shear",
"modulus",
"at",
"given",
"pressure"
] | python | train |
totalgood/nlpia | src/nlpia/transcoders.py | https://github.com/totalgood/nlpia/blob/efa01126275e9cd3c3a5151a644f1c798a9ec53f/src/nlpia/transcoders.py#L295-L327 | def fix_hunspell_json(badjson_path='en_us.json', goodjson_path='en_us_fixed.json'):
"""Fix the invalid hunspellToJSON.py json format by inserting double-quotes in list of affix strings
Args:
badjson_path (str): path to input json file that doesn't properly quote
goodjson_path (str): path to output ... | [
"def",
"fix_hunspell_json",
"(",
"badjson_path",
"=",
"'en_us.json'",
",",
"goodjson_path",
"=",
"'en_us_fixed.json'",
")",
":",
"with",
"open",
"(",
"badjson_path",
",",
"'r'",
")",
"as",
"fin",
":",
"with",
"open",
"(",
"goodjson_path",
",",
"'w'",
")",
"a... | Fix the invalid hunspellToJSON.py json format by inserting double-quotes in list of affix strings
Args:
badjson_path (str): path to input json file that doesn't properly quote
goodjson_path (str): path to output json file with properly quoted strings in list of affixes
Returns:
list of all w... | [
"Fix",
"the",
"invalid",
"hunspellToJSON",
".",
"py",
"json",
"format",
"by",
"inserting",
"double",
"-",
"quotes",
"in",
"list",
"of",
"affix",
"strings"
] | python | train |
jhermann/rudiments | src/rudiments/reamed/click.py | https://github.com/jhermann/rudiments/blob/028ec7237946115c7b18e50557cbc5f6b824653e/src/rudiments/reamed/click.py#L137-L161 | def locations(self, exists=True):
""" Return the location of the config file(s).
A given directory will be scanned for ``*.conf`` files, in alphabetical order.
Any duplicates will be eliminated.
If ``exists`` is True, only existing configuration locations are returned.
... | [
"def",
"locations",
"(",
"self",
",",
"exists",
"=",
"True",
")",
":",
"result",
"=",
"[",
"]",
"for",
"config_files",
"in",
"self",
".",
"config_paths",
":",
"if",
"not",
"config_files",
":",
"continue",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"... | Return the location of the config file(s).
A given directory will be scanned for ``*.conf`` files, in alphabetical order.
Any duplicates will be eliminated.
If ``exists`` is True, only existing configuration locations are returned. | [
"Return",
"the",
"location",
"of",
"the",
"config",
"file",
"(",
"s",
")",
"."
] | python | train |
pyparsing/pyparsing | examples/pymicko.py | https://github.com/pyparsing/pyparsing/blob/f0264bd8d1a548a50b3e5f7d99cfefd577942d14/examples/pymicko.py#L766-L770 | def function_begin(self):
"""Inserts function name label and function frame initialization"""
self.newline_label(self.shared.function_name, False, True)
self.push("%14")
self.move("%15", "%14") | [
"def",
"function_begin",
"(",
"self",
")",
":",
"self",
".",
"newline_label",
"(",
"self",
".",
"shared",
".",
"function_name",
",",
"False",
",",
"True",
")",
"self",
".",
"push",
"(",
"\"%14\"",
")",
"self",
".",
"move",
"(",
"\"%15\"",
",",
"\"%14\"... | Inserts function name label and function frame initialization | [
"Inserts",
"function",
"name",
"label",
"and",
"function",
"frame",
"initialization"
] | python | train |
inveniosoftware-contrib/invenio-workflows | invenio_workflows/tasks.py | https://github.com/inveniosoftware-contrib/invenio-workflows/blob/9c09fd29509a3db975ac2aba337e6760d8cfd3c2/invenio_workflows/tasks.py#L81-L103 | def resume(oid, restart_point="continue_next", **kwargs):
"""Continue workflow for given WorkflowObject id (oid).
Depending on `start_point` it may start from previous, current or
next task.
Special custom keyword arguments can be given to the workflow engine
in order to pass certain variables to ... | [
"def",
"resume",
"(",
"oid",
",",
"restart_point",
"=",
"\"continue_next\"",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
"worker_engine",
"import",
"continue_worker",
"return",
"text_type",
"(",
"continue_worker",
"(",
"oid",
",",
"restart_point",
",",
"*"... | Continue workflow for given WorkflowObject id (oid).
Depending on `start_point` it may start from previous, current or
next task.
Special custom keyword arguments can be given to the workflow engine
in order to pass certain variables to the tasks in the workflow execution,
such as a task-id from B... | [
"Continue",
"workflow",
"for",
"given",
"WorkflowObject",
"id",
"(",
"oid",
")",
"."
] | python | train |
xiaocong/uiautomator | uiautomator/__init__.py | https://github.com/xiaocong/uiautomator/blob/9a0c892ffd056713f91aa2153d1533c5b0553a1c/uiautomator/__init__.py#L670-L683 | def open(self):
'''
Open notification or quick settings.
Usage:
d.open.notification()
d.open.quick_settings()
'''
@param_to_property(action=["notification", "quick_settings"])
def _open(action):
if action == "notification":
retu... | [
"def",
"open",
"(",
"self",
")",
":",
"@",
"param_to_property",
"(",
"action",
"=",
"[",
"\"notification\"",
",",
"\"quick_settings\"",
"]",
")",
"def",
"_open",
"(",
"action",
")",
":",
"if",
"action",
"==",
"\"notification\"",
":",
"return",
"self",
".",... | Open notification or quick settings.
Usage:
d.open.notification()
d.open.quick_settings() | [
"Open",
"notification",
"or",
"quick",
"settings",
".",
"Usage",
":",
"d",
".",
"open",
".",
"notification",
"()",
"d",
".",
"open",
".",
"quick_settings",
"()"
] | python | train |
gboeing/osmnx | osmnx/core.py | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L1885-L1919 | def graph_from_file(filename, bidirectional=False, simplify=True,
retain_all=False, name='unnamed'):
"""
Create a networkx graph from OSM data in an XML file.
Parameters
----------
filename : string
the name of a file containing OSM XML data
bidirectional : bool
... | [
"def",
"graph_from_file",
"(",
"filename",
",",
"bidirectional",
"=",
"False",
",",
"simplify",
"=",
"True",
",",
"retain_all",
"=",
"False",
",",
"name",
"=",
"'unnamed'",
")",
":",
"# transmogrify file of OSM XML data into JSON",
"response_jsons",
"=",
"[",
"ove... | Create a networkx graph from OSM data in an XML file.
Parameters
----------
filename : string
the name of a file containing OSM XML data
bidirectional : bool
if True, create bidirectional edges for one-way streets
simplify : bool
if True, simplify the graph topology
reta... | [
"Create",
"a",
"networkx",
"graph",
"from",
"OSM",
"data",
"in",
"an",
"XML",
"file",
"."
] | python | train |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L12903-L12911 | def message_interval_send(self, message_id, interval_us, force_mavlink1=False):
'''
This interface replaces DATA_STREAM
message_id : The ID of the requested MAVLink message. v1.0 is limited to 254 messages. (uint16_t)
interval_us ... | [
"def",
"message_interval_send",
"(",
"self",
",",
"message_id",
",",
"interval_us",
",",
"force_mavlink1",
"=",
"False",
")",
":",
"return",
"self",
".",
"send",
"(",
"self",
".",
"message_interval_encode",
"(",
"message_id",
",",
"interval_us",
")",
",",
"for... | This interface replaces DATA_STREAM
message_id : The ID of the requested MAVLink message. v1.0 is limited to 254 messages. (uint16_t)
interval_us : The interval between two messages, in microseconds. A value of -1 indicates this stream is disabled, 0 indicat... | [
"This",
"interface",
"replaces",
"DATA_STREAM"
] | python | train |
googleapis/gax-python | google/gax/api_callable.py | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/api_callable.py#L216-L360 | def construct_settings(
service_name, client_config, config_override,
retry_names, bundle_descriptors=None, page_descriptors=None,
metrics_headers=(), kwargs=None):
"""Constructs a dictionary mapping method names to _CallSettings.
The ``client_config`` parameter is parsed from a client ... | [
"def",
"construct_settings",
"(",
"service_name",
",",
"client_config",
",",
"config_override",
",",
"retry_names",
",",
"bundle_descriptors",
"=",
"None",
",",
"page_descriptors",
"=",
"None",
",",
"metrics_headers",
"=",
"(",
")",
",",
"kwargs",
"=",
"None",
"... | Constructs a dictionary mapping method names to _CallSettings.
The ``client_config`` parameter is parsed from a client configuration JSON
file of the form:
.. code-block:: json
{
"interfaces": {
"google.fake.v1.ServiceName": {
"retry_codes": {
"idemp... | [
"Constructs",
"a",
"dictionary",
"mapping",
"method",
"names",
"to",
"_CallSettings",
"."
] | python | train |
rainwoodman/sharedmem | contrib/array.py | https://github.com/rainwoodman/sharedmem/blob/b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a/contrib/array.py#L201-L205 | def adapt(cls, source, template):
""" adapt source to a packarray according to the layout of template """
if not isinstance(template, packarray):
raise TypeError('template must be a packarray')
return cls(source, template.start, template.end) | [
"def",
"adapt",
"(",
"cls",
",",
"source",
",",
"template",
")",
":",
"if",
"not",
"isinstance",
"(",
"template",
",",
"packarray",
")",
":",
"raise",
"TypeError",
"(",
"'template must be a packarray'",
")",
"return",
"cls",
"(",
"source",
",",
"template",
... | adapt source to a packarray according to the layout of template | [
"adapt",
"source",
"to",
"a",
"packarray",
"according",
"to",
"the",
"layout",
"of",
"template"
] | python | valid |
horazont/aioxmpp | aioxmpp/pubsub/service.py | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/pubsub/service.py#L985-L1020 | def change_node_subscriptions(self, jid, node, subscriptions_to_set):
"""
Update the subscriptions at a node.
:param jid: Address of the PubSub service.
:type jid: :class:`aioxmpp.JID`
:param node: Name of the node to modify
:type node: :class:`str`
:param subscr... | [
"def",
"change_node_subscriptions",
"(",
"self",
",",
"jid",
",",
"node",
",",
"subscriptions_to_set",
")",
":",
"iq",
"=",
"aioxmpp",
".",
"stanza",
".",
"IQ",
"(",
"type_",
"=",
"aioxmpp",
".",
"structs",
".",
"IQType",
".",
"SET",
",",
"to",
"=",
"j... | Update the subscriptions at a node.
:param jid: Address of the PubSub service.
:type jid: :class:`aioxmpp.JID`
:param node: Name of the node to modify
:type node: :class:`str`
:param subscriptions_to_set: The subscriptions to set at the node.
:type subscriptions_to_set: ... | [
"Update",
"the",
"subscriptions",
"at",
"a",
"node",
"."
] | python | train |
igorcoding/asynctnt-queue | asynctnt_queue/tube.py | https://github.com/igorcoding/asynctnt-queue/blob/75719b2dd27e8314ae924aea6a7a85be8f48ecc5/asynctnt_queue/tube.py#L141-L154 | async def release(self, task_id, *, delay=None):
"""
Release task (return to queue) with delay if specified
:param task_id: Task id
:param delay: Time in seconds before task will become ready again
:return: Task instance
"""
opts = {}
if d... | [
"async",
"def",
"release",
"(",
"self",
",",
"task_id",
",",
"*",
",",
"delay",
"=",
"None",
")",
":",
"opts",
"=",
"{",
"}",
"if",
"delay",
"is",
"not",
"None",
":",
"opts",
"[",
"'delay'",
"]",
"=",
"delay",
"args",
"=",
"(",
"task_id",
",",
... | Release task (return to queue) with delay if specified
:param task_id: Task id
:param delay: Time in seconds before task will become ready again
:return: Task instance | [
"Release",
"task",
"(",
"return",
"to",
"queue",
")",
"with",
"delay",
"if",
"specified"
] | python | train |
zarr-developers/zarr | zarr/hierarchy.py | https://github.com/zarr-developers/zarr/blob/fb8e6d5ea6bc26e451e5cf0eaaee36977556d5b5/zarr/hierarchy.py#L368-L386 | def group_keys(self):
"""Return an iterator over member names for groups only.
Examples
--------
>>> import zarr
>>> g1 = zarr.group()
>>> g2 = g1.create_group('foo')
>>> g3 = g1.create_group('bar')
>>> d1 = g1.create_dataset('baz', shape=100, chunks=10)
... | [
"def",
"group_keys",
"(",
"self",
")",
":",
"for",
"key",
"in",
"sorted",
"(",
"listdir",
"(",
"self",
".",
"_store",
",",
"self",
".",
"_path",
")",
")",
":",
"path",
"=",
"self",
".",
"_key_prefix",
"+",
"key",
"if",
"contains_group",
"(",
"self",
... | Return an iterator over member names for groups only.
Examples
--------
>>> import zarr
>>> g1 = zarr.group()
>>> g2 = g1.create_group('foo')
>>> g3 = g1.create_group('bar')
>>> d1 = g1.create_dataset('baz', shape=100, chunks=10)
>>> d2 = g1.create_datase... | [
"Return",
"an",
"iterator",
"over",
"member",
"names",
"for",
"groups",
"only",
"."
] | python | train |
bcbio/bcbio-nextgen | bcbio/variation/prioritize.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/prioritize.py#L148-L161 | def _calc_priority_filter(row, pops):
"""Calculate the priority filter based on external associated data.
- Pass high/medium impact variants not found in population databases
- Pass variants found in COSMIC or Clinvar provided they don't have two
additional reasons to filter (found in multiple extern... | [
"def",
"_calc_priority_filter",
"(",
"row",
",",
"pops",
")",
":",
"filters",
"=",
"[",
"]",
"passes",
"=",
"[",
"]",
"passes",
".",
"extend",
"(",
"_find_known",
"(",
"row",
")",
")",
"filters",
".",
"extend",
"(",
"_known_populations",
"(",
"row",
",... | Calculate the priority filter based on external associated data.
- Pass high/medium impact variants not found in population databases
- Pass variants found in COSMIC or Clinvar provided they don't have two
additional reasons to filter (found in multiple external populations) | [
"Calculate",
"the",
"priority",
"filter",
"based",
"on",
"external",
"associated",
"data",
"."
] | python | train |
JelteF/PyLaTeX | pylatex/table.py | https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/table.py#L112-L129 | def dumps(self):
r"""Turn the Latex Object into a string in Latex format."""
string = ""
if self.row_height is not None:
row_height = Command('renewcommand', arguments=[
NoEscape(r'\arraystretch'),
self.row_height])
string += row_height.d... | [
"def",
"dumps",
"(",
"self",
")",
":",
"string",
"=",
"\"\"",
"if",
"self",
".",
"row_height",
"is",
"not",
"None",
":",
"row_height",
"=",
"Command",
"(",
"'renewcommand'",
",",
"arguments",
"=",
"[",
"NoEscape",
"(",
"r'\\arraystretch'",
")",
",",
"sel... | r"""Turn the Latex Object into a string in Latex format. | [
"r",
"Turn",
"the",
"Latex",
"Object",
"into",
"a",
"string",
"in",
"Latex",
"format",
"."
] | python | train |
PMEAL/OpenPNM | openpnm/utils/Project.py | https://github.com/PMEAL/OpenPNM/blob/0547b5724ffedc0a593aae48639d36fe10e0baed/openpnm/utils/Project.py#L463-L478 | def save_object(self, obj):
r"""
Saves the given object to a file
Parameters
----------
obj : OpenPNM object
The file to be saved. Depending on the object type, the file
extension will be one of 'net', 'geo', 'phase', 'phys' or 'alg'.
"""
... | [
"def",
"save_object",
"(",
"self",
",",
"obj",
")",
":",
"if",
"not",
"isinstance",
"(",
"obj",
",",
"list",
")",
":",
"obj",
"=",
"[",
"obj",
"]",
"for",
"item",
"in",
"obj",
":",
"filename",
"=",
"item",
".",
"name",
"+",
"'.'",
"+",
"item",
... | r"""
Saves the given object to a file
Parameters
----------
obj : OpenPNM object
The file to be saved. Depending on the object type, the file
extension will be one of 'net', 'geo', 'phase', 'phys' or 'alg'. | [
"r",
"Saves",
"the",
"given",
"object",
"to",
"a",
"file"
] | python | train |
addisonlynch/iexfinance | iexfinance/stocks/base.py | https://github.com/addisonlynch/iexfinance/blob/40f0bdcc51b329031d06178020fd774494250456/iexfinance/stocks/base.py#L418-L441 | def get_fund_ownership(self, **kwargs):
"""Fund Ownership
Returns the top 10 fund holders, meaning any firm not defined as
buy-side or sell-side such as mutual funds, pension funds, endowments,
investment firms, and other large entities that manage funds on behalf
of other... | [
"def",
"get_fund_ownership",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"fmt_p",
"(",
"out",
")",
":",
"out",
"=",
"{",
"(",
"symbol",
",",
"owner",
"[",
"\"entityProperName\"",
"]",
")",
":",
"owner",
"for",
"symbol",
"in",
"out",
"for",... | Fund Ownership
Returns the top 10 fund holders, meaning any firm not defined as
buy-side or sell-side such as mutual funds, pension funds, endowments,
investment firms, and other large entities that manage funds on behalf
of others.
Reference: https://iexcloud.io/docs/ap... | [
"Fund",
"Ownership",
"Returns",
"the",
"top",
"10",
"fund",
"holders",
"meaning",
"any",
"firm",
"not",
"defined",
"as",
"buy",
"-",
"side",
"or",
"sell",
"-",
"side",
"such",
"as",
"mutual",
"funds",
"pension",
"funds",
"endowments",
"investment",
"firms",
... | python | train |
LCAV/pylocus | pylocus/opt_space.py | https://github.com/LCAV/pylocus/blob/c56a38c251d8a435caf4641a8ae6027ecba2c8c6/pylocus/opt_space.py#L222-L239 | def getoptS(X, Y, M_E, E):
''' Find Sopt given X, Y
'''
n, r = X.shape
C = np.dot(np.dot(X.T, M_E), Y)
C = C.flatten()
A = np.zeros((r * r, r * r))
for i in range(r):
for j in range(r):
ind = j * r + i
temp = np.dot(
np.dot(X.T, np... | [
"def",
"getoptS",
"(",
"X",
",",
"Y",
",",
"M_E",
",",
"E",
")",
":",
"n",
",",
"r",
"=",
"X",
".",
"shape",
"C",
"=",
"np",
".",
"dot",
"(",
"np",
".",
"dot",
"(",
"X",
".",
"T",
",",
"M_E",
")",
",",
"Y",
")",
"C",
"=",
"C",
".",
... | Find Sopt given X, Y | [
"Find",
"Sopt",
"given",
"X",
"Y"
] | python | train |
saltstack/salt | salt/modules/panos.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/panos.py#L724-L750 | def get_jobs(state='all'):
'''
List all jobs on the device.
state
The state of the jobs to display. Valid options are all, pending, or processed. Pending jobs are jobs
that are currently in a running or waiting state. Processed jobs are jobs that have completed
execution.
CLI E... | [
"def",
"get_jobs",
"(",
"state",
"=",
"'all'",
")",
":",
"if",
"state",
".",
"lower",
"(",
")",
"==",
"'all'",
":",
"query",
"=",
"{",
"'type'",
":",
"'op'",
",",
"'cmd'",
":",
"'<show><jobs><all></all></jobs></show>'",
"}",
"elif",
"state",
".",
"lower"... | List all jobs on the device.
state
The state of the jobs to display. Valid options are all, pending, or processed. Pending jobs are jobs
that are currently in a running or waiting state. Processed jobs are jobs that have completed
execution.
CLI Example:
.. code-block:: bash
... | [
"List",
"all",
"jobs",
"on",
"the",
"device",
"."
] | python | train |
saltstack/salt | salt/states/glusterfs.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/glusterfs.py#L111-L222 | def volume_present(name, bricks, stripe=False, replica=False, device_vg=False,
transport='tcp', start=False, force=False, arbiter=False):
'''
Ensure that the volume exists
name
name of the volume
bricks
list of brick paths
replica
replica count for volum... | [
"def",
"volume_present",
"(",
"name",
",",
"bricks",
",",
"stripe",
"=",
"False",
",",
"replica",
"=",
"False",
",",
"device_vg",
"=",
"False",
",",
"transport",
"=",
"'tcp'",
",",
"start",
"=",
"False",
",",
"force",
"=",
"False",
",",
"arbiter",
"=",... | Ensure that the volume exists
name
name of the volume
bricks
list of brick paths
replica
replica count for volume
arbiter
use every third brick as arbiter (metadata only)
.. versionadded:: 2019.2.0
start
ensure that the volume is also started
... | [
"Ensure",
"that",
"the",
"volume",
"exists"
] | python | train |
mitsei/dlkit | dlkit/json_/cataloging/managers.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/cataloging/managers.py#L384-L401 | def get_catalog_hierarchy_design_session(self, proxy):
"""Gets the catalog hierarchy design session.
arg: proxy (osid.proxy.Proxy): proxy
return: (osid.cataloging.CatalogHierarchyDesignSession) - a
``CatalogHierarchyDesignSession``
raise: NullArgument - ``proxy`` is ... | [
"def",
"get_catalog_hierarchy_design_session",
"(",
"self",
",",
"proxy",
")",
":",
"if",
"not",
"self",
".",
"supports_catalog_hierarchy_design",
"(",
")",
":",
"raise",
"errors",
".",
"Unimplemented",
"(",
")",
"# pylint: disable=no-member",
"return",
"sessions",
... | Gets the catalog hierarchy design session.
arg: proxy (osid.proxy.Proxy): proxy
return: (osid.cataloging.CatalogHierarchyDesignSession) - a
``CatalogHierarchyDesignSession``
raise: NullArgument - ``proxy`` is null
raise: OperationFailed - unable to complete request
... | [
"Gets",
"the",
"catalog",
"hierarchy",
"design",
"session",
"."
] | python | train |
fake-name/ChromeController | ChromeController/Generator/Generated.py | https://github.com/fake-name/ChromeController/blob/914dd136184e8f1165c7aa6ef30418aaf10c61f0/ChromeController/Generator/Generated.py#L3015-L3033 | def DOMStorage_removeDOMStorageItem(self, storageId, key):
"""
Function path: DOMStorage.removeDOMStorageItem
Domain: DOMStorage
Method name: removeDOMStorageItem
Parameters:
Required arguments:
'storageId' (type: StorageId) -> No description
'key' (type: string) -> No description
No re... | [
"def",
"DOMStorage_removeDOMStorageItem",
"(",
"self",
",",
"storageId",
",",
"key",
")",
":",
"assert",
"isinstance",
"(",
"key",
",",
"(",
"str",
",",
")",
")",
",",
"\"Argument 'key' must be of type '['str']'. Received type: '%s'\"",
"%",
"type",
"(",
"key",
")... | Function path: DOMStorage.removeDOMStorageItem
Domain: DOMStorage
Method name: removeDOMStorageItem
Parameters:
Required arguments:
'storageId' (type: StorageId) -> No description
'key' (type: string) -> No description
No return value. | [
"Function",
"path",
":",
"DOMStorage",
".",
"removeDOMStorageItem",
"Domain",
":",
"DOMStorage",
"Method",
"name",
":",
"removeDOMStorageItem",
"Parameters",
":",
"Required",
"arguments",
":",
"storageId",
"(",
"type",
":",
"StorageId",
")",
"-",
">",
"No",
"des... | python | train |
erikrose/more-itertools | more_itertools/more.py | https://github.com/erikrose/more-itertools/blob/6a91b4e25c8e12fcf9fc2b53cf8ee0fba293e6f9/more_itertools/more.py#L1731-L1844 | def islice_extended(iterable, *args):
"""An extension of :func:`itertools.islice` that supports negative values
for *stop*, *start*, and *step*.
>>> iterable = iter('abcdefgh')
>>> list(islice_extended(iterable, -4, -1))
['e', 'f', 'g']
Slices with negative values require some cach... | [
"def",
"islice_extended",
"(",
"iterable",
",",
"*",
"args",
")",
":",
"s",
"=",
"slice",
"(",
"*",
"args",
")",
"start",
"=",
"s",
".",
"start",
"stop",
"=",
"s",
".",
"stop",
"if",
"s",
".",
"step",
"==",
"0",
":",
"raise",
"ValueError",
"(",
... | An extension of :func:`itertools.islice` that supports negative values
for *stop*, *start*, and *step*.
>>> iterable = iter('abcdefgh')
>>> list(islice_extended(iterable, -4, -1))
['e', 'f', 'g']
Slices with negative values require some caching of *iterable*, but this
function take... | [
"An",
"extension",
"of",
":",
"func",
":",
"itertools",
".",
"islice",
"that",
"supports",
"negative",
"values",
"for",
"*",
"stop",
"*",
"*",
"start",
"*",
"and",
"*",
"step",
"*",
"."
] | python | train |
GoogleCloudPlatform/appengine-gcs-client | python/src/cloudstorage/cloudstorage_api.py | https://github.com/GoogleCloudPlatform/appengine-gcs-client/blob/d11078331ecd915d753c886e96a80133599f3f98/python/src/cloudstorage/cloudstorage_api.py#L47-L107 | def open(filename,
mode='r',
content_type=None,
options=None,
read_buffer_size=storage_api.ReadBuffer.DEFAULT_BUFFER_SIZE,
retry_params=None,
_account_id=None,
offset=0):
"""Opens a Google Cloud Storage file and returns it as a File-like object.
Args:
... | [
"def",
"open",
"(",
"filename",
",",
"mode",
"=",
"'r'",
",",
"content_type",
"=",
"None",
",",
"options",
"=",
"None",
",",
"read_buffer_size",
"=",
"storage_api",
".",
"ReadBuffer",
".",
"DEFAULT_BUFFER_SIZE",
",",
"retry_params",
"=",
"None",
",",
"_accou... | Opens a Google Cloud Storage file and returns it as a File-like object.
Args:
filename: A Google Cloud Storage filename of form '/bucket/filename'.
mode: 'r' for reading mode. 'w' for writing mode.
In reading mode, the file must exist. In writing mode, a file will
be created or be overrode.
c... | [
"Opens",
"a",
"Google",
"Cloud",
"Storage",
"file",
"and",
"returns",
"it",
"as",
"a",
"File",
"-",
"like",
"object",
"."
] | python | train |
nickmilon/Hellas | Hellas/Sparta.py | https://github.com/nickmilon/Hellas/blob/542e4778692fbec90753942946f20100412ec9ee/Hellas/Sparta.py#L333-L340 | def class_name_str(obj, skip_parent=False):
"""
return's object's class name as string
"""
rt = str(type(obj)).split(" ")[1][1:-2]
if skip_parent:
rt = rt.split(".")[-1]
return rt | [
"def",
"class_name_str",
"(",
"obj",
",",
"skip_parent",
"=",
"False",
")",
":",
"rt",
"=",
"str",
"(",
"type",
"(",
"obj",
")",
")",
".",
"split",
"(",
"\" \"",
")",
"[",
"1",
"]",
"[",
"1",
":",
"-",
"2",
"]",
"if",
"skip_parent",
":",
"rt",
... | return's object's class name as string | [
"return",
"s",
"object",
"s",
"class",
"name",
"as",
"string"
] | python | train |
martinpitt/python-dbusmock | dbusmock/mockobject.py | https://github.com/martinpitt/python-dbusmock/blob/26f65f78bc0ed347233f699a8d6ee0e6880e7eb0/dbusmock/mockobject.py#L197-L241 | def AddObject(self, path, interface, properties, methods):
'''Add a new D-Bus object to the mock
path: D-Bus object path
interface: Primary D-Bus interface name of this object (where
properties and methods will be put on)
properties: A property_name (string) → value m... | [
"def",
"AddObject",
"(",
"self",
",",
"path",
",",
"interface",
",",
"properties",
",",
"methods",
")",
":",
"if",
"path",
"in",
"objects",
":",
"raise",
"dbus",
".",
"exceptions",
".",
"DBusException",
"(",
"'object %s already exists'",
"%",
"path",
",",
... | Add a new D-Bus object to the mock
path: D-Bus object path
interface: Primary D-Bus interface name of this object (where
properties and methods will be put on)
properties: A property_name (string) → value map with initial
properties on "interface"
... | [
"Add",
"a",
"new",
"D",
"-",
"Bus",
"object",
"to",
"the",
"mock"
] | python | train |
RiotGames/cloud-inquisitor | plugins/public/cinq-collector-dns/cinq_collector_dns/__init__.py | https://github.com/RiotGames/cloud-inquisitor/blob/181dc2566ca59fc855f695b7fcc2c3b934e6ee9f/plugins/public/cinq-collector-dns/cinq_collector_dns/__init__.py#L195-L230 | def get_cloudflare_records(self, *, account):
"""Return a `list` of `dict`s containing the zones and their records, obtained from the CloudFlare API
Returns:
account (:obj:`CloudFlareAccount`): A CloudFlare Account object
:obj:`list` of `dict`
"""
zones = []
... | [
"def",
"get_cloudflare_records",
"(",
"self",
",",
"*",
",",
"account",
")",
":",
"zones",
"=",
"[",
"]",
"for",
"zobj",
"in",
"self",
".",
"__cloudflare_list_zones",
"(",
"account",
"=",
"account",
")",
":",
"try",
":",
"self",
".",
"log",
".",
"debug... | Return a `list` of `dict`s containing the zones and their records, obtained from the CloudFlare API
Returns:
account (:obj:`CloudFlareAccount`): A CloudFlare Account object
:obj:`list` of `dict` | [
"Return",
"a",
"list",
"of",
"dict",
"s",
"containing",
"the",
"zones",
"and",
"their",
"records",
"obtained",
"from",
"the",
"CloudFlare",
"API"
] | python | train |
nyaruka/python-librato-bg | librato_bg/consumer.py | https://github.com/nyaruka/python-librato-bg/blob/e541092838694de31d256becea8391a9cfe086c7/librato_bg/consumer.py#L75-L82 | def next_item(self):
"""Get a single item from the queue."""
queue = self.queue
try:
item = queue.get(block=True, timeout=5)
return item
except Exception:
return None | [
"def",
"next_item",
"(",
"self",
")",
":",
"queue",
"=",
"self",
".",
"queue",
"try",
":",
"item",
"=",
"queue",
".",
"get",
"(",
"block",
"=",
"True",
",",
"timeout",
"=",
"5",
")",
"return",
"item",
"except",
"Exception",
":",
"return",
"None"
] | Get a single item from the queue. | [
"Get",
"a",
"single",
"item",
"from",
"the",
"queue",
"."
] | python | valid |
gwastro/pycbc | pycbc/inference/models/__init__.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/inference/models/__init__.py#L153-L174 | def read_from_config(cp, **kwargs):
"""Initializes a model from the given config file.
The section must have a ``name`` argument. The name argument corresponds to
the name of the class to initialize.
Parameters
----------
cp : WorkflowConfigParser
Config file parser to read.
\**kwa... | [
"def",
"read_from_config",
"(",
"cp",
",",
"*",
"*",
"kwargs",
")",
":",
"# use the name to get the distribution",
"name",
"=",
"cp",
".",
"get",
"(",
"\"model\"",
",",
"\"name\"",
")",
"return",
"models",
"[",
"name",
"]",
".",
"from_config",
"(",
"cp",
"... | Initializes a model from the given config file.
The section must have a ``name`` argument. The name argument corresponds to
the name of the class to initialize.
Parameters
----------
cp : WorkflowConfigParser
Config file parser to read.
\**kwargs :
All other keyword arguments a... | [
"Initializes",
"a",
"model",
"from",
"the",
"given",
"config",
"file",
"."
] | python | train |
archman/beamline | beamline/mathutils.py | https://github.com/archman/beamline/blob/417bc5dc13e754bc89d246427984590fced64d07/beamline/mathutils.py#L350-L366 | def setParams(self, bend_length, bend_field, drift_length, gamma):
""" set chicane parameters
:param bend_length: bend length, [m]
:param bend_field: bend field, [T]
:param drift_length: drift length, [m], list
:param gamma: electron energy, gamma
:return: None
"... | [
"def",
"setParams",
"(",
"self",
",",
"bend_length",
",",
"bend_field",
",",
"drift_length",
",",
"gamma",
")",
":",
"if",
"None",
"in",
"(",
"bend_length",
",",
"bend_field",
",",
"drift_length",
",",
"gamma",
")",
":",
"print",
"(",
"\"warning: 'bend_lengt... | set chicane parameters
:param bend_length: bend length, [m]
:param bend_field: bend field, [T]
:param drift_length: drift length, [m], list
:param gamma: electron energy, gamma
:return: None | [
"set",
"chicane",
"parameters"
] | python | train |
oceanprotocol/squid-py | squid_py/ocean/ocean_conditions.py | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ocean/ocean_conditions.py#L42-L63 | def release_reward(self, agreement_id, amount, account):
"""
Release reward condition.
:param agreement_id: id of the agreement, hex str
:param amount: Amount of tokens, int
:param account: Account
:return:
"""
agreement_values = self._keeper.agreement_ma... | [
"def",
"release_reward",
"(",
"self",
",",
"agreement_id",
",",
"amount",
",",
"account",
")",
":",
"agreement_values",
"=",
"self",
".",
"_keeper",
".",
"agreement_manager",
".",
"get_agreement",
"(",
"agreement_id",
")",
"consumer",
",",
"provider",
"=",
"se... | Release reward condition.
:param agreement_id: id of the agreement, hex str
:param amount: Amount of tokens, int
:param account: Account
:return: | [
"Release",
"reward",
"condition",
"."
] | python | train |
ANTsX/ANTsPy | ants/core/ants_image.py | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_image.py#L302-L316 | def astype(self, dtype):
"""
Cast & clone an ANTsImage to a given numpy datatype.
Map:
uint8 : unsigned char
uint32 : unsigned int
float32 : float
float64 : double
"""
if dtype not in _supported_dtypes:
raise ValueEr... | [
"def",
"astype",
"(",
"self",
",",
"dtype",
")",
":",
"if",
"dtype",
"not",
"in",
"_supported_dtypes",
":",
"raise",
"ValueError",
"(",
"'Datatype %s not supported. Supported types are %s'",
"%",
"(",
"dtype",
",",
"_supported_dtypes",
")",
")",
"pixeltype",
"=",
... | Cast & clone an ANTsImage to a given numpy datatype.
Map:
uint8 : unsigned char
uint32 : unsigned int
float32 : float
float64 : double | [
"Cast",
"&",
"clone",
"an",
"ANTsImage",
"to",
"a",
"given",
"numpy",
"datatype",
"."
] | python | train |
happyleavesaoc/python-firetv | firetv/__main__.py | https://github.com/happyleavesaoc/python-firetv/blob/3dd953376c0d5af502e775ae14ed0afe03224781/firetv/__main__.py#L50-L63 | def is_valid_device_id(device_id):
""" Check if device identifier is valid.
A valid device identifier contains only ascii word characters or dashes.
:param device_id: Device identifier
:returns: Valid or not.
"""
valid = valid_device_id.match(device_id)
if not valid:
logging.error(... | [
"def",
"is_valid_device_id",
"(",
"device_id",
")",
":",
"valid",
"=",
"valid_device_id",
".",
"match",
"(",
"device_id",
")",
"if",
"not",
"valid",
":",
"logging",
".",
"error",
"(",
"\"A valid device identifier contains \"",
"\"only ascii word characters or dashes. \"... | Check if device identifier is valid.
A valid device identifier contains only ascii word characters or dashes.
:param device_id: Device identifier
:returns: Valid or not. | [
"Check",
"if",
"device",
"identifier",
"is",
"valid",
"."
] | python | train |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/core/api/packages.py | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/core/api/packages.py#L205-L211 | def get_package_format_names(predicate=None):
"""Get names for available package formats."""
return [
k
for k, v in six.iteritems(get_package_formats())
if not predicate or predicate(k, v)
] | [
"def",
"get_package_format_names",
"(",
"predicate",
"=",
"None",
")",
":",
"return",
"[",
"k",
"for",
"k",
",",
"v",
"in",
"six",
".",
"iteritems",
"(",
"get_package_formats",
"(",
")",
")",
"if",
"not",
"predicate",
"or",
"predicate",
"(",
"k",
",",
... | Get names for available package formats. | [
"Get",
"names",
"for",
"available",
"package",
"formats",
"."
] | python | train |
googlefonts/ufo2ft | Lib/ufo2ft/featureWriters/__init__.py | https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/featureWriters/__init__.py#L62-L104 | def loadFeatureWriters(ufo, ignoreErrors=True):
"""Check UFO lib for key "com.github.googlei18n.ufo2ft.featureWriters",
containing a list of dicts, each having the following key/value pairs:
For example:
{
"module": "myTools.featureWriters", # default: ufo2ft.featureWriters
"class": ... | [
"def",
"loadFeatureWriters",
"(",
"ufo",
",",
"ignoreErrors",
"=",
"True",
")",
":",
"if",
"FEATURE_WRITERS_KEY",
"not",
"in",
"ufo",
".",
"lib",
":",
"return",
"None",
"writers",
"=",
"[",
"]",
"for",
"wdict",
"in",
"ufo",
".",
"lib",
"[",
"FEATURE_WRIT... | Check UFO lib for key "com.github.googlei18n.ufo2ft.featureWriters",
containing a list of dicts, each having the following key/value pairs:
For example:
{
"module": "myTools.featureWriters", # default: ufo2ft.featureWriters
"class": "MyKernFeatureWriter", # required
"options": {... | [
"Check",
"UFO",
"lib",
"for",
"key",
"com",
".",
"github",
".",
"googlei18n",
".",
"ufo2ft",
".",
"featureWriters",
"containing",
"a",
"list",
"of",
"dicts",
"each",
"having",
"the",
"following",
"key",
"/",
"value",
"pairs",
":",
"For",
"example",
":"
] | python | train |
Antidote1911/cryptoshop | cryptoshop/_cascade_engine.py | https://github.com/Antidote1911/cryptoshop/blob/0b7ff4a6848f2733f4737606957e8042a4d6ca0b/cryptoshop/_cascade_engine.py#L39-L104 | def encry_decry_cascade(data, masterkey, bool_encry, assoc_data):
"""
When bool_encry is True, encrypt the data with master key. When it is False, the function extract the three nonce
from the encrypted data (first 3*21 bytes), and decrypt the data.
:param data: the data to encrypt or decrypt.
:para... | [
"def",
"encry_decry_cascade",
"(",
"data",
",",
"masterkey",
",",
"bool_encry",
",",
"assoc_data",
")",
":",
"engine1",
"=",
"botan",
".",
"cipher",
"(",
"algo",
"=",
"\"Serpent/GCM\"",
",",
"encrypt",
"=",
"bool_encry",
")",
"engine2",
"=",
"botan",
".",
... | When bool_encry is True, encrypt the data with master key. When it is False, the function extract the three nonce
from the encrypted data (first 3*21 bytes), and decrypt the data.
:param data: the data to encrypt or decrypt.
:param masterkey: a 32 bytes key in bytes.
:param bool_encry: if bool_encry is ... | [
"When",
"bool_encry",
"is",
"True",
"encrypt",
"the",
"data",
"with",
"master",
"key",
".",
"When",
"it",
"is",
"False",
"the",
"function",
"extract",
"the",
"three",
"nonce",
"from",
"the",
"encrypted",
"data",
"(",
"first",
"3",
"*",
"21",
"bytes",
")"... | python | train |
bitesofcode/projexui | projexui/xapplication.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/xapplication.py#L448-L473 | def systemSettings(self):
"""
Returns the settings associated with this application for all users.
:return <projexui.xsettings.XSettings>
"""
if not self._systemSettings:
if self.isCompiled():
settings = QtCore.QSettings(XSettings.... | [
"def",
"systemSettings",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_systemSettings",
":",
"if",
"self",
".",
"isCompiled",
"(",
")",
":",
"settings",
"=",
"QtCore",
".",
"QSettings",
"(",
"XSettings",
".",
"IniFormat",
",",
"XSettings",
".",
"Sys... | Returns the settings associated with this application for all users.
:return <projexui.xsettings.XSettings> | [
"Returns",
"the",
"settings",
"associated",
"with",
"this",
"application",
"for",
"all",
"users",
".",
":",
"return",
"<projexui",
".",
"xsettings",
".",
"XSettings",
">"
] | python | train |
feliphebueno/Rinzler | rinzler/__init__.py | https://github.com/feliphebueno/Rinzler/blob/7f6d5445b5662cba2e8938bb82c7f3ef94e5ded8/rinzler/__init__.py#L88-L99 | def set_auth_service(self, auth_service: BaseAuthService):
"""
Sets the authentication service
:param auth_service: BaseAuthService Authentication service
:raises: TypeError If the auth_service object is not a subclass of rinzler.auth.BaseAuthService
:rtype: Rinzler
"""
... | [
"def",
"set_auth_service",
"(",
"self",
",",
"auth_service",
":",
"BaseAuthService",
")",
":",
"if",
"issubclass",
"(",
"auth_service",
".",
"__class__",
",",
"BaseAuthService",
")",
":",
"self",
".",
"auth_service",
"=",
"auth_service",
"return",
"self",
"else"... | Sets the authentication service
:param auth_service: BaseAuthService Authentication service
:raises: TypeError If the auth_service object is not a subclass of rinzler.auth.BaseAuthService
:rtype: Rinzler | [
"Sets",
"the",
"authentication",
"service",
":",
"param",
"auth_service",
":",
"BaseAuthService",
"Authentication",
"service",
":",
"raises",
":",
"TypeError",
"If",
"the",
"auth_service",
"object",
"is",
"not",
"a",
"subclass",
"of",
"rinzler",
".",
"auth",
"."... | python | train |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L10671-L10696 | def set_position_target_global_int_encode(self, time_boot_ms, target_system, target_component, coordinate_frame, type_mask, lat_int, lon_int, alt, vx, vy, vz, afx, afy, afz, yaw, yaw_rate):
'''
Sets a desired vehicle position, velocity, and/or acceleration in a
global coo... | [
"def",
"set_position_target_global_int_encode",
"(",
"self",
",",
"time_boot_ms",
",",
"target_system",
",",
"target_component",
",",
"coordinate_frame",
",",
"type_mask",
",",
"lat_int",
",",
"lon_int",
",",
"alt",
",",
"vx",
",",
"vy",
",",
"vz",
",",
"afx",
... | Sets a desired vehicle position, velocity, and/or acceleration in a
global coordinate system (WGS84). Used by an external
controller to command the vehicle (manual controller
or other system).
time_boot_ms : Timestamp in milliseconds since sy... | [
"Sets",
"a",
"desired",
"vehicle",
"position",
"velocity",
"and",
"/",
"or",
"acceleration",
"in",
"a",
"global",
"coordinate",
"system",
"(",
"WGS84",
")",
".",
"Used",
"by",
"an",
"external",
"controller",
"to",
"command",
"the",
"vehicle",
"(",
"manual",
... | python | train |
matrix-org/matrix-python-sdk | matrix_client/room.py | https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L414-L427 | def send_state_event(self, event_type, content, state_key=""):
"""Send a state event to the room.
Args:
event_type (str): The type of event that you are sending.
content (): An object with the content of the message.
state_key (str, optional): A unique key to identif... | [
"def",
"send_state_event",
"(",
"self",
",",
"event_type",
",",
"content",
",",
"state_key",
"=",
"\"\"",
")",
":",
"return",
"self",
".",
"client",
".",
"api",
".",
"send_state_event",
"(",
"self",
".",
"room_id",
",",
"event_type",
",",
"content",
",",
... | Send a state event to the room.
Args:
event_type (str): The type of event that you are sending.
content (): An object with the content of the message.
state_key (str, optional): A unique key to identify the state. | [
"Send",
"a",
"state",
"event",
"to",
"the",
"room",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.