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 |
|---|---|---|---|---|---|---|---|---|
spry-group/python-vultr | vultr/v1_snapshot.py | https://github.com/spry-group/python-vultr/blob/bad1448f1df7b5dba70fd3d11434f32580f0b850/vultr/v1_snapshot.py#L10-L19 | def create(self, subid, params=None):
''' /v1/snapshot/create
POST - account
Create a snapshot from an existing virtual machine.
The virtual machine does not need to be stopped.
Link: https://www.vultr.com/api/#snapshot_create
'''
params = update_params(params, {... | [
"def",
"create",
"(",
"self",
",",
"subid",
",",
"params",
"=",
"None",
")",
":",
"params",
"=",
"update_params",
"(",
"params",
",",
"{",
"'SUBID'",
":",
"subid",
"}",
")",
"return",
"self",
".",
"request",
"(",
"'/v1/snapshot/create'",
",",
"params",
... | /v1/snapshot/create
POST - account
Create a snapshot from an existing virtual machine.
The virtual machine does not need to be stopped.
Link: https://www.vultr.com/api/#snapshot_create | [
"/",
"v1",
"/",
"snapshot",
"/",
"create",
"POST",
"-",
"account",
"Create",
"a",
"snapshot",
"from",
"an",
"existing",
"virtual",
"machine",
".",
"The",
"virtual",
"machine",
"does",
"not",
"need",
"to",
"be",
"stopped",
"."
] | python | train |
gbowerman/azurerm | examples/list_vmss_vms.py | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/list_vmss_vms.py#L13-L44 | def main():
'''main routine'''
# process arguments
if len(sys.argv) < 3:
usage()
rgname = sys.argv[1]
vmss_name = sys.argv[2]
# Load Azure app defaults
try:
with open('azurermconfig.json') as config_file:
config_data = json.load(config_file)
except FileNotF... | [
"def",
"main",
"(",
")",
":",
"# process arguments",
"if",
"len",
"(",
"sys",
".",
"argv",
")",
"<",
"3",
":",
"usage",
"(",
")",
"rgname",
"=",
"sys",
".",
"argv",
"[",
"1",
"]",
"vmss_name",
"=",
"sys",
".",
"argv",
"[",
"2",
"]",
"# Load Azure... | main routine | [
"main",
"routine"
] | python | train |
annoviko/pyclustering | pyclustering/core/som_wrapper.py | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/core/som_wrapper.py#L174-L188 | def som_get_capture_objects(som_pointer):
"""!
@brief Returns list of indexes of captured objects by each neuron.
@param[in] som_pointer (c_pointer): pointer to object of self-organized map.
"""
ccore = ccore_library.get()
ccore.som_get_capture_objects.restype = POI... | [
"def",
"som_get_capture_objects",
"(",
"som_pointer",
")",
":",
"ccore",
"=",
"ccore_library",
".",
"get",
"(",
")",
"ccore",
".",
"som_get_capture_objects",
".",
"restype",
"=",
"POINTER",
"(",
"pyclustering_package",
")",
"package",
"=",
"ccore",
".",
"som_get... | !
@brief Returns list of indexes of captured objects by each neuron.
@param[in] som_pointer (c_pointer): pointer to object of self-organized map. | [
"!"
] | python | valid |
CxAalto/gtfspy | gtfspy/routing/node_profile_multiobjective.py | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/routing/node_profile_multiobjective.py#L58-L79 | def _check_dep_time_is_valid(self, dep_time):
"""
A simple checker, that connections are coming in descending order of departure time
and that no departure time has been "skipped".
Parameters
----------
dep_time
Returns
-------
None
"""
... | [
"def",
"_check_dep_time_is_valid",
"(",
"self",
",",
"dep_time",
")",
":",
"assert",
"dep_time",
"<=",
"self",
".",
"_min_dep_time",
",",
"\"Labels should be entered in decreasing order of departure time.\"",
"dep_time_index",
"=",
"self",
".",
"dep_times_to_index",
"[",
... | A simple checker, that connections are coming in descending order of departure time
and that no departure time has been "skipped".
Parameters
----------
dep_time
Returns
-------
None | [
"A",
"simple",
"checker",
"that",
"connections",
"are",
"coming",
"in",
"descending",
"order",
"of",
"departure",
"time",
"and",
"that",
"no",
"departure",
"time",
"has",
"been",
"skipped",
"."
] | python | valid |
gwastro/pycbc-glue | pycbc_glue/segments.py | https://github.com/gwastro/pycbc-glue/blob/a3e906bae59fbfd707c3ff82e5d008d939ec5e24/pycbc_glue/segments.py#L1154-L1164 | def extend(self, other):
"""
Appends the segmentlists from other to the corresponding
segmentlists in self, adding new segmentslists to self as
needed.
"""
for key, value in other.iteritems():
if key not in self:
self[key] = _shallowcopy(value)
else:
self[key].extend(value) | [
"def",
"extend",
"(",
"self",
",",
"other",
")",
":",
"for",
"key",
",",
"value",
"in",
"other",
".",
"iteritems",
"(",
")",
":",
"if",
"key",
"not",
"in",
"self",
":",
"self",
"[",
"key",
"]",
"=",
"_shallowcopy",
"(",
"value",
")",
"else",
":",... | Appends the segmentlists from other to the corresponding
segmentlists in self, adding new segmentslists to self as
needed. | [
"Appends",
"the",
"segmentlists",
"from",
"other",
"to",
"the",
"corresponding",
"segmentlists",
"in",
"self",
"adding",
"new",
"segmentslists",
"to",
"self",
"as",
"needed",
"."
] | python | train |
inspirehep/harvesting-kit | harvestingkit/oup_package.py | https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/oup_package.py#L197-L225 | def _extract_packages(self):
"""
Extract a package in a new directory.
"""
if not hasattr(self, "retrieved_packages_unpacked"):
self.retrieved_packages_unpacked = [self.package_name]
for path in self.retrieved_packages_unpacked:
package_name = basename(pat... | [
"def",
"_extract_packages",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"retrieved_packages_unpacked\"",
")",
":",
"self",
".",
"retrieved_packages_unpacked",
"=",
"[",
"self",
".",
"package_name",
"]",
"for",
"path",
"in",
"self",
".",
... | Extract a package in a new directory. | [
"Extract",
"a",
"package",
"in",
"a",
"new",
"directory",
"."
] | python | valid |
kyan001/PyKyanToolKit | KyanToolKit.py | https://github.com/kyan001/PyKyanToolKit/blob/a3974fcd45ce41f743b4a3d42af961fedea8fda8/KyanToolKit.py#L190-L211 | def ajax(cls, url, param={}, method='get'):
"""Get info by ajax
Args:
url: string
Returns:
dict: json decoded into a dict
"""
param = urllib.parse.urlencode(param)
if method.lower() == 'get':
req = urllib.request.Request(url + '?' + pa... | [
"def",
"ajax",
"(",
"cls",
",",
"url",
",",
"param",
"=",
"{",
"}",
",",
"method",
"=",
"'get'",
")",
":",
"param",
"=",
"urllib",
".",
"parse",
".",
"urlencode",
"(",
"param",
")",
"if",
"method",
".",
"lower",
"(",
")",
"==",
"'get'",
":",
"r... | Get info by ajax
Args:
url: string
Returns:
dict: json decoded into a dict | [
"Get",
"info",
"by",
"ajax"
] | python | train |
C-Pro/pgdocgen | pgdocgen/ddlobject/schema.py | https://github.com/C-Pro/pgdocgen/blob/b5d95c1bc1b38e3c7977aeddc20793a7b0f5d0fe/pgdocgen/ddlobject/schema.py#L12-L40 | def read_contents(self, name, conn):
'''Read schema tables'''
sql = '''select c.relname,
d.description,
case c.relkind
when 'r' then 'table'
when 'v' then 'view'
when 'm' then 'm... | [
"def",
"read_contents",
"(",
"self",
",",
"name",
",",
"conn",
")",
":",
"sql",
"=",
"'''select c.relname,\n d.description,\n case c.relkind\n when 'r' then 'table'\n when 'v' then 'view'\n ... | Read schema tables | [
"Read",
"schema",
"tables"
] | python | train |
mozilla-releng/mozapkpublisher | mozapkpublisher/common/store_l10n.py | https://github.com/mozilla-releng/mozapkpublisher/blob/df61034220153cbb98da74c8ef6de637f9185e12/mozapkpublisher/common/store_l10n.py#L107-L112 | def _get_list_of_completed_locales(product, channel):
""" Get all the translated locales supported by Google play
So, locale unsupported by Google play won't be downloaded
Idem for not translated locale
"""
return utils.load_json_url(_ALL_LOCALES_URL.format(product=product, channel=channel)) | [
"def",
"_get_list_of_completed_locales",
"(",
"product",
",",
"channel",
")",
":",
"return",
"utils",
".",
"load_json_url",
"(",
"_ALL_LOCALES_URL",
".",
"format",
"(",
"product",
"=",
"product",
",",
"channel",
"=",
"channel",
")",
")"
] | Get all the translated locales supported by Google play
So, locale unsupported by Google play won't be downloaded
Idem for not translated locale | [
"Get",
"all",
"the",
"translated",
"locales",
"supported",
"by",
"Google",
"play",
"So",
"locale",
"unsupported",
"by",
"Google",
"play",
"won",
"t",
"be",
"downloaded",
"Idem",
"for",
"not",
"translated",
"locale"
] | python | train |
bukun/TorCMS | ext_script/autocrud/func_gen_html.py | https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/ext_script/autocrud/func_gen_html.py#L118-L132 | def gen_radio_list(sig_dic):
'''
For generating List view HTML file for RADIO.
for each item.
'''
view_zuoxiang = '''<span class="iga_pd_val">'''
dic_tmp = sig_dic['dic']
for key in dic_tmp.keys():
tmp_str = '''{{% if postinfo.extinfo['{0}'][0] == "{1}" %}} {2} {{% end %}}
'... | [
"def",
"gen_radio_list",
"(",
"sig_dic",
")",
":",
"view_zuoxiang",
"=",
"'''<span class=\"iga_pd_val\">'''",
"dic_tmp",
"=",
"sig_dic",
"[",
"'dic'",
"]",
"for",
"key",
"in",
"dic_tmp",
".",
"keys",
"(",
")",
":",
"tmp_str",
"=",
"'''{{% if postinfo.extinfo['{0}'... | For generating List view HTML file for RADIO.
for each item. | [
"For",
"generating",
"List",
"view",
"HTML",
"file",
"for",
"RADIO",
".",
"for",
"each",
"item",
"."
] | python | train |
mozilla-releng/scriptworker | scriptworker/cot/verify.py | https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L1890-L1907 | async def verify_docker_worker_task(chain, link):
"""Docker-worker specific checks.
Args:
chain (ChainOfTrust): the chain we're operating on
link (ChainOfTrust or LinkOfTrust): the trust object for the signing task.
Raises:
CoTError: on failure.
"""
if chain != link:
... | [
"async",
"def",
"verify_docker_worker_task",
"(",
"chain",
",",
"link",
")",
":",
"if",
"chain",
"!=",
"link",
":",
"# These two checks will die on `link.cot` if `link` is a ChainOfTrust",
"# object (e.g., the task we're running `verify_cot` against is a",
"# docker-worker task). So ... | Docker-worker specific checks.
Args:
chain (ChainOfTrust): the chain we're operating on
link (ChainOfTrust or LinkOfTrust): the trust object for the signing task.
Raises:
CoTError: on failure. | [
"Docker",
"-",
"worker",
"specific",
"checks",
"."
] | python | train |
nficano/python-lambda | aws_lambda/aws_lambda.py | https://github.com/nficano/python-lambda/blob/b0bd25404df70212d7fa057758760366406d64f2/aws_lambda/aws_lambda.py#L400-L421 | def _install_packages(path, packages):
"""Install all packages listed to the target directory.
Ignores any package that includes Python itself and python-lambda as well
since its only needed for deploying and not running the code
:param str path:
Path to copy installed pip packages to.
:pa... | [
"def",
"_install_packages",
"(",
"path",
",",
"packages",
")",
":",
"def",
"_filter_blacklist",
"(",
"package",
")",
":",
"blacklist",
"=",
"[",
"'-i'",
",",
"'#'",
",",
"'Python=='",
",",
"'python-lambda=='",
"]",
"return",
"all",
"(",
"package",
".",
"st... | Install all packages listed to the target directory.
Ignores any package that includes Python itself and python-lambda as well
since its only needed for deploying and not running the code
:param str path:
Path to copy installed pip packages to.
:param list packages:
A list of packages ... | [
"Install",
"all",
"packages",
"listed",
"to",
"the",
"target",
"directory",
"."
] | python | valid |
wummel/linkchecker | third_party/dnspython/dns/opcode.py | https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/third_party/dnspython/dns/opcode.py#L45-L61 | def from_text(text):
"""Convert text into an opcode.
@param text: the textual opcode
@type text: string
@raises UnknownOpcode: the opcode is unknown
@rtype: int
"""
if text.isdigit():
value = int(text)
if value >= 0 and value <= 15:
return value
value = _by_... | [
"def",
"from_text",
"(",
"text",
")",
":",
"if",
"text",
".",
"isdigit",
"(",
")",
":",
"value",
"=",
"int",
"(",
"text",
")",
"if",
"value",
">=",
"0",
"and",
"value",
"<=",
"15",
":",
"return",
"value",
"value",
"=",
"_by_text",
".",
"get",
"("... | Convert text into an opcode.
@param text: the textual opcode
@type text: string
@raises UnknownOpcode: the opcode is unknown
@rtype: int | [
"Convert",
"text",
"into",
"an",
"opcode",
"."
] | python | train |
awslabs/sockeye | sockeye/model.py | https://github.com/awslabs/sockeye/blob/5d64a1ee1ef3cbba17c6d1d94bc061020c43f6ab/sockeye/model.py#L209-L249 | def _get_embed_weights(self, prefix: str) -> Tuple[mx.sym.Symbol, mx.sym.Symbol, mx.sym.Symbol]:
"""
Returns embedding parameters for source and target.
When source and target embeddings are shared, they are created here and passed in to each side,
instead of being created in the Embeddi... | [
"def",
"_get_embed_weights",
"(",
"self",
",",
"prefix",
":",
"str",
")",
"->",
"Tuple",
"[",
"mx",
".",
"sym",
".",
"Symbol",
",",
"mx",
".",
"sym",
".",
"Symbol",
",",
"mx",
".",
"sym",
".",
"Symbol",
"]",
":",
"w_embed_source",
"=",
"mx",
".",
... | Returns embedding parameters for source and target.
When source and target embeddings are shared, they are created here and passed in to each side,
instead of being created in the Embedding constructors.
:param prefix: Prefix.
:return: Tuple of source and target parameter symbols. | [
"Returns",
"embedding",
"parameters",
"for",
"source",
"and",
"target",
".",
"When",
"source",
"and",
"target",
"embeddings",
"are",
"shared",
"they",
"are",
"created",
"here",
"and",
"passed",
"in",
"to",
"each",
"side",
"instead",
"of",
"being",
"created",
... | python | train |
sanoma/django-arctic | arctic/mixins.py | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/mixins.py#L393-L401 | def _split_str(self, field):
"""
Split title|7 into (title, 7)
"""
field_items = field.split("|")
if len(field_items) == 2:
return field_items[0], field_items[1]
elif len(field_items) == 1:
return field_items[0], None | [
"def",
"_split_str",
"(",
"self",
",",
"field",
")",
":",
"field_items",
"=",
"field",
".",
"split",
"(",
"\"|\"",
")",
"if",
"len",
"(",
"field_items",
")",
"==",
"2",
":",
"return",
"field_items",
"[",
"0",
"]",
",",
"field_items",
"[",
"1",
"]",
... | Split title|7 into (title, 7) | [
"Split",
"title|7",
"into",
"(",
"title",
"7",
")"
] | python | train |
zhmcclient/python-zhmcclient | zhmcclient_mock/_urihandler.py | https://github.com/zhmcclient/python-zhmcclient/blob/9657563e5d9184c51d3c903442a58b9725fdf335/zhmcclient_mock/_urihandler.py#L2335-L2374 | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion):
"""Operation: Activate Logical Partition (requires classic mode)."""
assert wait_for_completion is True # async not supported yet
lpar_oid = uri_parms[0]
lpar_uri = '/api/logical-partitions/' ... | [
"def",
"post",
"(",
"method",
",",
"hmc",
",",
"uri",
",",
"uri_parms",
",",
"body",
",",
"logon_required",
",",
"wait_for_completion",
")",
":",
"assert",
"wait_for_completion",
"is",
"True",
"# async not supported yet",
"lpar_oid",
"=",
"uri_parms",
"[",
"0",
... | Operation: Activate Logical Partition (requires classic mode). | [
"Operation",
":",
"Activate",
"Logical",
"Partition",
"(",
"requires",
"classic",
"mode",
")",
"."
] | python | train |
SiLab-Bonn/basil | basil/TL/Visa.py | https://github.com/SiLab-Bonn/basil/blob/99052482d9334dd1f5598eb2d2fb4d5399a32291/basil/TL/Visa.py#L26-L38 | def init(self):
'''
Initialize the device.
Parameters of visa.ResourceManager().open_resource()
'''
super(Visa, self).init()
backend = self._init.get('backend', '') # Empty string means std. backend (NI VISA)
rm = visa.ResourceManager(backend)
try:
... | [
"def",
"init",
"(",
"self",
")",
":",
"super",
"(",
"Visa",
",",
"self",
")",
".",
"init",
"(",
")",
"backend",
"=",
"self",
".",
"_init",
".",
"get",
"(",
"'backend'",
",",
"''",
")",
"# Empty string means std. backend (NI VISA)",
"rm",
"=",
"visa",
"... | Initialize the device.
Parameters of visa.ResourceManager().open_resource() | [
"Initialize",
"the",
"device",
".",
"Parameters",
"of",
"visa",
".",
"ResourceManager",
"()",
".",
"open_resource",
"()"
] | python | train |
common-workflow-language/cwltool | cwltool/main.py | https://github.com/common-workflow-language/cwltool/blob/cb81b22abc52838823da9945f04d06739ab32fda/cwltool/main.py#L453-L462 | def print_pack(document_loader, # type: Loader
processobj, # type: CommentedMap
uri, # type: Text
metadata # type: Dict[Text, Any]
): # type (...) -> Text
"""Return a CWL serialization of the CWL document in JSON."""
packed... | [
"def",
"print_pack",
"(",
"document_loader",
",",
"# type: Loader",
"processobj",
",",
"# type: CommentedMap",
"uri",
",",
"# type: Text",
"metadata",
"# type: Dict[Text, Any]",
")",
":",
"# type (...) -> Text",
"packed",
"=",
"pack",
"(",
"document_loader",
",",
"proce... | Return a CWL serialization of the CWL document in JSON. | [
"Return",
"a",
"CWL",
"serialization",
"of",
"the",
"CWL",
"document",
"in",
"JSON",
"."
] | python | train |
SKA-ScienceDataProcessor/integration-prototype | sip/tango_control/flask_master/app/app.py | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/tango_control/flask_master/app/app.py#L94-L146 | def root():
"""Home page."""
return {
"message": "Welcome to the SIP Master Controller (flask variant)",
"_links": {
"items": [
{
"Link": "Health",
"href": "{}health".format(request.url)
},
{
... | [
"def",
"root",
"(",
")",
":",
"return",
"{",
"\"message\"",
":",
"\"Welcome to the SIP Master Controller (flask variant)\"",
",",
"\"_links\"",
":",
"{",
"\"items\"",
":",
"[",
"{",
"\"Link\"",
":",
"\"Health\"",
",",
"\"href\"",
":",
"\"{}health\"",
".",
"format"... | Home page. | [
"Home",
"page",
"."
] | python | train |
nameko/nameko | nameko/runners.py | https://github.com/nameko/nameko/blob/88d7e5211de4fcc1c34cd7f84d7c77f0619c5f5d/nameko/runners.py#L54-L68 | def start(self):
""" Start all the registered services.
A new container is created for each service using the container
class provided in the __init__ method.
All containers are started concurrently and the method will block
until all have completed their startup routine.
... | [
"def",
"start",
"(",
"self",
")",
":",
"service_names",
"=",
"', '",
".",
"join",
"(",
"self",
".",
"service_names",
")",
"_log",
".",
"info",
"(",
"'starting services: %s'",
",",
"service_names",
")",
"SpawningProxy",
"(",
"self",
".",
"containers",
")",
... | Start all the registered services.
A new container is created for each service using the container
class provided in the __init__ method.
All containers are started concurrently and the method will block
until all have completed their startup routine. | [
"Start",
"all",
"the",
"registered",
"services",
"."
] | python | train |
gem/oq-engine | openquake/hmtk/parsers/catalogue/csv_catalogue_parser.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/catalogue/csv_catalogue_parser.py#L130-L143 | def _int_check(self, attribute_array, value, irow, key):
'''Checks if value is valid integer, appends to array if valid, appends
nan if not'''
value = value.strip(' ')
try:
if value:
attribute_array = np.hstack([attribute_array, int(value)])
else:
... | [
"def",
"_int_check",
"(",
"self",
",",
"attribute_array",
",",
"value",
",",
"irow",
",",
"key",
")",
":",
"value",
"=",
"value",
".",
"strip",
"(",
"' '",
")",
"try",
":",
"if",
"value",
":",
"attribute_array",
"=",
"np",
".",
"hstack",
"(",
"[",
... | Checks if value is valid integer, appends to array if valid, appends
nan if not | [
"Checks",
"if",
"value",
"is",
"valid",
"integer",
"appends",
"to",
"array",
"if",
"valid",
"appends",
"nan",
"if",
"not"
] | python | train |
rigetti/pyquil | pyquil/api/_wavefunction_simulator.py | https://github.com/rigetti/pyquil/blob/ec98e453084b0037d69d8c3245f6822a5422593d/pyquil/api/_wavefunction_simulator.py#L85-L130 | def expectation(self, prep_prog: Program,
pauli_terms: Union[PauliSum, List[PauliTerm]],
memory_map: Any = None) -> Union[float, np.ndarray]:
"""
Calculate the expectation value of Pauli operators given a state prepared by prep_program.
If ``pauli_terms``... | [
"def",
"expectation",
"(",
"self",
",",
"prep_prog",
":",
"Program",
",",
"pauli_terms",
":",
"Union",
"[",
"PauliSum",
",",
"List",
"[",
"PauliTerm",
"]",
"]",
",",
"memory_map",
":",
"Any",
"=",
"None",
")",
"->",
"Union",
"[",
"float",
",",
"np",
... | Calculate the expectation value of Pauli operators given a state prepared by prep_program.
If ``pauli_terms`` is a ``PauliSum`` then the returned value is a single ``float``,
otherwise the returned value is an array of values, one for each ``PauliTerm`` in the
list.
.. note:: If your p... | [
"Calculate",
"the",
"expectation",
"value",
"of",
"Pauli",
"operators",
"given",
"a",
"state",
"prepared",
"by",
"prep_program",
"."
] | python | train |
ch3pjw/junction | jcn/display_elements.py | https://github.com/ch3pjw/junction/blob/7d0c4d279589bee8ae7b3ac4dee2ab425c0b1b0e/jcn/display_elements.py#L43-L53 | def _do_crop(self, lines, width, height, x_crop, y_crop):
'''Crops a list of strings to the specified width/height
'''
lines = crop_or_expand(
lines, height, default=[self.fillchar * width],
scheme=self._schemes[y_crop])
for i, line in enumerate(lines):
... | [
"def",
"_do_crop",
"(",
"self",
",",
"lines",
",",
"width",
",",
"height",
",",
"x_crop",
",",
"y_crop",
")",
":",
"lines",
"=",
"crop_or_expand",
"(",
"lines",
",",
"height",
",",
"default",
"=",
"[",
"self",
".",
"fillchar",
"*",
"width",
"]",
",",... | Crops a list of strings to the specified width/height | [
"Crops",
"a",
"list",
"of",
"strings",
"to",
"the",
"specified",
"width",
"/",
"height"
] | python | train |
konstantint/pyliftover | pyliftover/intervaltree.py | https://github.com/konstantint/pyliftover/blob/5164eed9ae678ad0ddc164df8c2c5767e6a4b39f/pyliftover/intervaltree.py#L111-L135 | def _query(self, x, result):
'''
Same as self.query, but uses a provided list to accumulate results into.
'''
if self.single_interval is None: # Empty
return
elif self.single_interval != 0: # Single interval, just check whether x is in it
if self.single_i... | [
"def",
"_query",
"(",
"self",
",",
"x",
",",
"result",
")",
":",
"if",
"self",
".",
"single_interval",
"is",
"None",
":",
"# Empty",
"return",
"elif",
"self",
".",
"single_interval",
"!=",
"0",
":",
"# Single interval, just check whether x is in it",
"if",
"se... | Same as self.query, but uses a provided list to accumulate results into. | [
"Same",
"as",
"self",
".",
"query",
"but",
"uses",
"a",
"provided",
"list",
"to",
"accumulate",
"results",
"into",
"."
] | python | train |
materialsproject/pymatgen | pymatgen/io/pwscf.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/pwscf.py#L173-L186 | def as_dict(self):
"""
Create a dictionary representation of a PWInput object
Returns:
dict
"""
pwinput_dict = {'structure': self.structure.as_dict(),
'pseudo': self.pseudo,
'sections': self.sections,
... | [
"def",
"as_dict",
"(",
"self",
")",
":",
"pwinput_dict",
"=",
"{",
"'structure'",
":",
"self",
".",
"structure",
".",
"as_dict",
"(",
")",
",",
"'pseudo'",
":",
"self",
".",
"pseudo",
",",
"'sections'",
":",
"self",
".",
"sections",
",",
"'kpoints_mode'"... | Create a dictionary representation of a PWInput object
Returns:
dict | [
"Create",
"a",
"dictionary",
"representation",
"of",
"a",
"PWInput",
"object",
"Returns",
":",
"dict"
] | python | train |
spacetelescope/drizzlepac | drizzlepac/tweakback.py | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/tweakback.py#L351-L364 | def extract_input_filenames(drzfile):
"""
Generate a list of filenames from a drizzled image's header
"""
data_kws = fits.getval(drzfile, 'd*data', ext=0, memmap=False)
if len(data_kws) == 0:
return None
fnames = []
for kw in data_kws.cards:
f = kw.value.split('[')[0]
... | [
"def",
"extract_input_filenames",
"(",
"drzfile",
")",
":",
"data_kws",
"=",
"fits",
".",
"getval",
"(",
"drzfile",
",",
"'d*data'",
",",
"ext",
"=",
"0",
",",
"memmap",
"=",
"False",
")",
"if",
"len",
"(",
"data_kws",
")",
"==",
"0",
":",
"return",
... | Generate a list of filenames from a drizzled image's header | [
"Generate",
"a",
"list",
"of",
"filenames",
"from",
"a",
"drizzled",
"image",
"s",
"header"
] | python | train |
saltstack/salt | salt/utils/stringutils.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/stringutils.py#L182-L192 | def to_bool(text):
'''
Convert the string name of a boolean to that boolean value.
'''
downcased_text = six.text_type(text).strip().lower()
if downcased_text == 'false':
return False
elif downcased_text == 'true':
return True
return text | [
"def",
"to_bool",
"(",
"text",
")",
":",
"downcased_text",
"=",
"six",
".",
"text_type",
"(",
"text",
")",
".",
"strip",
"(",
")",
".",
"lower",
"(",
")",
"if",
"downcased_text",
"==",
"'false'",
":",
"return",
"False",
"elif",
"downcased_text",
"==",
... | Convert the string name of a boolean to that boolean value. | [
"Convert",
"the",
"string",
"name",
"of",
"a",
"boolean",
"to",
"that",
"boolean",
"value",
"."
] | python | train |
dstanek/snake-guice | snakeguice/modules.py | https://github.com/dstanek/snake-guice/blob/d20b62de3ee31e84119c801756398c35ed803fb3/snakeguice/modules.py#L23-L25 | def install(self, binder, module):
"""Add another module's bindings to a binder."""
ModuleAdapter(module, self._injector).configure(binder) | [
"def",
"install",
"(",
"self",
",",
"binder",
",",
"module",
")",
":",
"ModuleAdapter",
"(",
"module",
",",
"self",
".",
"_injector",
")",
".",
"configure",
"(",
"binder",
")"
] | Add another module's bindings to a binder. | [
"Add",
"another",
"module",
"s",
"bindings",
"to",
"a",
"binder",
"."
] | python | train |
cds-astro/mocpy | mocpy/moc/moc.py | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/moc/moc.py#L88-L119 | def contains(self, ra, dec, keep_inside=True):
"""
Returns a boolean mask array of the positions lying inside (or outside) the MOC instance.
Parameters
----------
ra : `astropy.units.Quantity`
Right ascension array
dec : `astropy.units.Quantity`
D... | [
"def",
"contains",
"(",
"self",
",",
"ra",
",",
"dec",
",",
"keep_inside",
"=",
"True",
")",
":",
"depth",
"=",
"self",
".",
"max_order",
"m",
"=",
"np",
".",
"zeros",
"(",
"nside2npix",
"(",
"1",
"<<",
"depth",
")",
",",
"dtype",
"=",
"bool",
")... | Returns a boolean mask array of the positions lying inside (or outside) the MOC instance.
Parameters
----------
ra : `astropy.units.Quantity`
Right ascension array
dec : `astropy.units.Quantity`
Declination array
keep_inside : bool, optional
T... | [
"Returns",
"a",
"boolean",
"mask",
"array",
"of",
"the",
"positions",
"lying",
"inside",
"(",
"or",
"outside",
")",
"the",
"MOC",
"instance",
"."
] | python | train |
xtrementl/focus | focus/plugin/modules/notify.py | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/notify.py#L12-L26 | def _terminal_notifier(title, message):
""" Shows user notification message via `terminal-notifier` command.
`title`
Notification title.
`message`
Notification message.
"""
try:
paths = common.extract_app_paths(['terminal-notifier'])
except ValueErro... | [
"def",
"_terminal_notifier",
"(",
"title",
",",
"message",
")",
":",
"try",
":",
"paths",
"=",
"common",
".",
"extract_app_paths",
"(",
"[",
"'terminal-notifier'",
"]",
")",
"except",
"ValueError",
":",
"pass",
"common",
".",
"shell_process",
"(",
"[",
"path... | Shows user notification message via `terminal-notifier` command.
`title`
Notification title.
`message`
Notification message. | [
"Shows",
"user",
"notification",
"message",
"via",
"terminal",
"-",
"notifier",
"command",
"."
] | python | train |
gabstopper/smc-python | smc/base/collection.py | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/base/collection.py#L541-L570 | def first(self):
"""
Returns the first object matched or None if there is no
matching object.
::
>>> iterator = Host.objects.iterator()
>>> c = iterator.filter('kali')
>>> if c.exists():
>>> print(c.count())
... | [
"def",
"first",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
")",
":",
"self",
".",
"_params",
".",
"update",
"(",
"limit",
"=",
"1",
")",
"if",
"'filter'",
"not",
"in",
"self",
".",
"_params",
":",
"return",
"list",
"(",
"self",
")",
"[",
... | Returns the first object matched or None if there is no
matching object.
::
>>> iterator = Host.objects.iterator()
>>> c = iterator.filter('kali')
>>> if c.exists():
>>> print(c.count())
>>> print(c.first())
7... | [
"Returns",
"the",
"first",
"object",
"matched",
"or",
"None",
"if",
"there",
"is",
"no",
"matching",
"object",
".",
"::",
">>>",
"iterator",
"=",
"Host",
".",
"objects",
".",
"iterator",
"()",
">>>",
"c",
"=",
"iterator",
".",
"filter",
"(",
"kali",
")... | python | train |
ask/carrot | carrot/messaging.py | https://github.com/ask/carrot/blob/5889a25cd2e274642071c9bba39772f4b3e3d9da/carrot/messaging.py#L1008-L1015 | def cancel(self):
"""Cancel a running :meth:`iterconsume` session."""
for consumer_tag in self._open_consumers.values():
try:
self.backend.cancel(consumer_tag)
except KeyError:
pass
self._open_consumers.clear() | [
"def",
"cancel",
"(",
"self",
")",
":",
"for",
"consumer_tag",
"in",
"self",
".",
"_open_consumers",
".",
"values",
"(",
")",
":",
"try",
":",
"self",
".",
"backend",
".",
"cancel",
"(",
"consumer_tag",
")",
"except",
"KeyError",
":",
"pass",
"self",
"... | Cancel a running :meth:`iterconsume` session. | [
"Cancel",
"a",
"running",
":",
"meth",
":",
"iterconsume",
"session",
"."
] | python | train |
simpleai-team/simpleai | simpleai/machine_learning/models.py | https://github.com/simpleai-team/simpleai/blob/2836befa7e970013f62e0ee75562652aacac6f65/simpleai/machine_learning/models.py#L76-L86 | def load(cls, filepath):
"""
Loads a pickled version of the classifier saved in `filepath`
"""
with open(filepath, "rb") as filehandler:
classifier = pickle.load(filehandler)
if not isinstance(classifier, Classifier):
raise ValueError("Pickled object is n... | [
"def",
"load",
"(",
"cls",
",",
"filepath",
")",
":",
"with",
"open",
"(",
"filepath",
",",
"\"rb\"",
")",
"as",
"filehandler",
":",
"classifier",
"=",
"pickle",
".",
"load",
"(",
"filehandler",
")",
"if",
"not",
"isinstance",
"(",
"classifier",
",",
"... | Loads a pickled version of the classifier saved in `filepath` | [
"Loads",
"a",
"pickled",
"version",
"of",
"the",
"classifier",
"saved",
"in",
"filepath"
] | python | train |
petrjasek/eve-elastic | eve_elastic/elastic.py | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L118-L122 | def default(self, value):
"""Convert mongo.ObjectId."""
if isinstance(value, ObjectId):
return str(value)
return super(ElasticJSONSerializer, self).default(value) | [
"def",
"default",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"ObjectId",
")",
":",
"return",
"str",
"(",
"value",
")",
"return",
"super",
"(",
"ElasticJSONSerializer",
",",
"self",
")",
".",
"default",
"(",
"value",
")"... | Convert mongo.ObjectId. | [
"Convert",
"mongo",
".",
"ObjectId",
"."
] | python | train |
HazyResearch/fonduer | src/fonduer/parser/parser.py | https://github.com/HazyResearch/fonduer/blob/4520f86a716f03dcca458a9f4bddac75b4e7068f/src/fonduer/parser/parser.py#L655-L688 | def _parse_section(self, node, state):
"""Parse a Section of the node.
Note that this implementation currently creates a Section at the
beginning of the document and creates Section based on tag of node.
:param node: The lxml node to parse
:param state: The global state necessa... | [
"def",
"_parse_section",
"(",
"self",
",",
"node",
",",
"state",
")",
":",
"if",
"node",
".",
"tag",
"not",
"in",
"[",
"\"html\"",
",",
"\"section\"",
"]",
":",
"return",
"state",
"# Add a Section",
"stable_id",
"=",
"(",
"f\"{state['document'].name}\"",
"f\... | Parse a Section of the node.
Note that this implementation currently creates a Section at the
beginning of the document and creates Section based on tag of node.
:param node: The lxml node to parse
:param state: The global state necessary to place the node in context
of the... | [
"Parse",
"a",
"Section",
"of",
"the",
"node",
"."
] | python | train |
alfred82santa/aio-service-client | service_client/__init__.py | https://github.com/alfred82santa/aio-service-client/blob/dd9ad49e23067b22178534915aa23ba24f6ff39b/service_client/__init__.py#L222-L229 | def close(self):
"""
Close service client and its plugins.
"""
self._execute_plugin_hooks_sync(hook='close')
if not self.session.closed:
ensure_future(self.session.close(), loop=self.loop) | [
"def",
"close",
"(",
"self",
")",
":",
"self",
".",
"_execute_plugin_hooks_sync",
"(",
"hook",
"=",
"'close'",
")",
"if",
"not",
"self",
".",
"session",
".",
"closed",
":",
"ensure_future",
"(",
"self",
".",
"session",
".",
"close",
"(",
")",
",",
"loo... | Close service client and its plugins. | [
"Close",
"service",
"client",
"and",
"its",
"plugins",
"."
] | python | train |
dropbox/pyannotate | pyannotate_tools/annotations/parse.py | https://github.com/dropbox/pyannotate/blob/d128c76b8a86f208e5c78716f2a917003650cebc/pyannotate_tools/annotations/parse.py#L173-L210 | def tokenize(s):
# type: (str) -> List[Token]
"""Translate a type comment into a list of tokens."""
original = s
tokens = [] # type: List[Token]
while True:
if not s:
tokens.append(End())
return tokens
elif s[0] == ' ':
s = s[1:]
elif s[0]... | [
"def",
"tokenize",
"(",
"s",
")",
":",
"# type: (str) -> List[Token]",
"original",
"=",
"s",
"tokens",
"=",
"[",
"]",
"# type: List[Token]",
"while",
"True",
":",
"if",
"not",
"s",
":",
"tokens",
".",
"append",
"(",
"End",
"(",
")",
")",
"return",
"token... | Translate a type comment into a list of tokens. | [
"Translate",
"a",
"type",
"comment",
"into",
"a",
"list",
"of",
"tokens",
"."
] | python | train |
phoebe-project/phoebe2 | phoebe/parameters/parameters.py | https://github.com/phoebe-project/phoebe2/blob/e64b8be683977064e2d55dd1b3ac400f64c3e379/phoebe/parameters/parameters.py#L3600-L3627 | def get_value(self, *args, **kwargs):
"""
This method should be overriden by any subclass of Parameter, and should
be decorated with the @update_if_client decorator.
Please see the individual classes documentation:
* :meth:`FloatParameter.get_value`
* :meth:`Arra... | [
"def",
"get_value",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"qualifier",
"in",
"kwargs",
".",
"keys",
"(",
")",
":",
"# then we have an \"override\" value that was passed, and we should",
"# just return that.",
"# Examp... | This method should be overriden by any subclass of Parameter, and should
be decorated with the @update_if_client decorator.
Please see the individual classes documentation:
* :meth:`FloatParameter.get_value`
* :meth:`ArrayParameter.get_value`
* :meth:`HierarchyParame... | [
"This",
"method",
"should",
"be",
"overriden",
"by",
"any",
"subclass",
"of",
"Parameter",
"and",
"should",
"be",
"decorated",
"with",
"the",
"@update_if_client",
"decorator",
".",
"Please",
"see",
"the",
"individual",
"classes",
"documentation",
":"
] | python | train |
mozilla/amo-validator | validator/errorbundler.py | https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/errorbundler.py#L257-L261 | def failed(self, fail_on_warnings=True):
"""Returns a boolean value describing whether the validation
succeeded or not."""
return bool(self.errors) or (fail_on_warnings and bool(self.warnings)) | [
"def",
"failed",
"(",
"self",
",",
"fail_on_warnings",
"=",
"True",
")",
":",
"return",
"bool",
"(",
"self",
".",
"errors",
")",
"or",
"(",
"fail_on_warnings",
"and",
"bool",
"(",
"self",
".",
"warnings",
")",
")"
] | Returns a boolean value describing whether the validation
succeeded or not. | [
"Returns",
"a",
"boolean",
"value",
"describing",
"whether",
"the",
"validation",
"succeeded",
"or",
"not",
"."
] | python | train |
oscarlazoarjona/fast | fast/misc.py | https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/misc.py#L322-L335 | def detuning_combinations(lists):
r"""This function recieves a list of length Nl with the number of
transitions each laser induces. It returns the cartesian product of all
these posibilities as a list of all possible combinations.
"""
Nl = len(lists)
comb = [[i] for i in range(lists[0])]
for... | [
"def",
"detuning_combinations",
"(",
"lists",
")",
":",
"Nl",
"=",
"len",
"(",
"lists",
")",
"comb",
"=",
"[",
"[",
"i",
"]",
"for",
"i",
"in",
"range",
"(",
"lists",
"[",
"0",
"]",
")",
"]",
"for",
"l",
"in",
"range",
"(",
"1",
",",
"Nl",
")... | r"""This function recieves a list of length Nl with the number of
transitions each laser induces. It returns the cartesian product of all
these posibilities as a list of all possible combinations. | [
"r",
"This",
"function",
"recieves",
"a",
"list",
"of",
"length",
"Nl",
"with",
"the",
"number",
"of",
"transitions",
"each",
"laser",
"induces",
".",
"It",
"returns",
"the",
"cartesian",
"product",
"of",
"all",
"these",
"posibilities",
"as",
"a",
"list",
... | python | train |
mitsei/dlkit | dlkit/json_/assessment_authoring/objects.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment_authoring/objects.py#L860-L870 | def get_maximum_score_metadata(self):
"""Gets the metadata for the maximum score.
return: (osid.Metadata) - metadata for the maximum score
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for osid.resource.ResourceForm.get_group_metada... | [
"def",
"get_maximum_score_metadata",
"(",
"self",
")",
":",
"# Implemented from template for osid.resource.ResourceForm.get_group_metadata_template",
"metadata",
"=",
"dict",
"(",
"self",
".",
"_mdata",
"[",
"'maximum_score'",
"]",
")",
"metadata",
".",
"update",
"(",
"{"... | Gets the metadata for the maximum score.
return: (osid.Metadata) - metadata for the maximum score
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"the",
"metadata",
"for",
"the",
"maximum",
"score",
"."
] | python | train |
JNPRAutomate/pyJunosManager | pyJunosManager/pyJunosManager.py | https://github.com/JNPRAutomate/pyJunosManager/blob/cfbe87bb55488f44bad0b383771a88be7b2ccf2a/pyJunosManager/pyJunosManager.py#L95-L131 | def open_config(self,type="shared"):
"""
Opens the configuration of the currently connected device
Args:
:type: The type of configuration you want to open. Any string can be provided, however the standard supported options are: **exclusive**, **private**, and **shared**. The default... | [
"def",
"open_config",
"(",
"self",
",",
"type",
"=",
"\"shared\"",
")",
":",
"try",
":",
"#attempt to open a configuration",
"output",
"=",
"self",
".",
"dev",
".",
"rpc",
"(",
"\"<open-configuration><{0}/></open-configuration>\"",
".",
"format",
"(",
"type",
")",... | Opens the configuration of the currently connected device
Args:
:type: The type of configuration you want to open. Any string can be provided, however the standard supported options are: **exclusive**, **private**, and **shared**. The default mode is **shared**.
Examples:
.. code-... | [
"Opens",
"the",
"configuration",
"of",
"the",
"currently",
"connected",
"device"
] | python | train |
facelessuser/backrefs | backrefs/uniprops/__init__.py | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L341-L352 | def get_script_property(value, is_bytes=False):
"""Get `SC` property."""
obj = unidata.ascii_scripts if is_bytes else unidata.unicode_scripts
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['script'].get(negated, negated)
else:
value = unidata.... | [
"def",
"get_script_property",
"(",
"value",
",",
"is_bytes",
"=",
"False",
")",
":",
"obj",
"=",
"unidata",
".",
"ascii_scripts",
"if",
"is_bytes",
"else",
"unidata",
".",
"unicode_scripts",
"if",
"value",
".",
"startswith",
"(",
"'^'",
")",
":",
"negated",
... | Get `SC` property. | [
"Get",
"SC",
"property",
"."
] | python | train |
pycontribs/pyrax | pyrax/cloudmonitoring.py | https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L55-L65 | def assure_entity(fnc):
"""
Converts an entityID passed as the entity to a CloudMonitorEntity object.
"""
@wraps(fnc)
def _wrapped(self, entity, *args, **kwargs):
if not isinstance(entity, CloudMonitorEntity):
# Must be the ID
entity = self._entity_manager.get(entity)... | [
"def",
"assure_entity",
"(",
"fnc",
")",
":",
"@",
"wraps",
"(",
"fnc",
")",
"def",
"_wrapped",
"(",
"self",
",",
"entity",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"entity",
",",
"CloudMonitorEntity",
")",... | Converts an entityID passed as the entity to a CloudMonitorEntity object. | [
"Converts",
"an",
"entityID",
"passed",
"as",
"the",
"entity",
"to",
"a",
"CloudMonitorEntity",
"object",
"."
] | python | train |
swimlane/swimlane-python | swimlane/core/adapters/helper.py | https://github.com/swimlane/swimlane-python/blob/588fc503a76799bcdb5aecdf2f64a6ee05e3922d/swimlane/core/adapters/helper.py#L33-L57 | def add_comment(self, app_id, record_id, field_id, message):
"""Directly add a comment to a record without retrieving the app or record first
Warnings:
Does not perform any app, record, or field ID validation
Args:
app_id (str): Full App ID string
record_id ... | [
"def",
"add_comment",
"(",
"self",
",",
"app_id",
",",
"record_id",
",",
"field_id",
",",
"message",
")",
":",
"self",
".",
"_swimlane",
".",
"request",
"(",
"'post'",
",",
"'app/{0}/record/{1}/{2}/comment'",
".",
"format",
"(",
"app_id",
",",
"record_id",
"... | Directly add a comment to a record without retrieving the app or record first
Warnings:
Does not perform any app, record, or field ID validation
Args:
app_id (str): Full App ID string
record_id (str): Full parent Record ID string
field_id (str): Full fie... | [
"Directly",
"add",
"a",
"comment",
"to",
"a",
"record",
"without",
"retrieving",
"the",
"app",
"or",
"record",
"first"
] | python | train |
h2non/paco | paco/every.py | https://github.com/h2non/paco/blob/1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d/paco/every.py#L11-L84 | def every(coro, iterable, limit=1, loop=None):
"""
Returns `True` if every element in a given iterable satisfies the coroutine
asynchronous test.
If any iteratee coroutine call returns `False`, the process is inmediately
stopped, and `False` will be returned.
You can increase the concurrency l... | [
"def",
"every",
"(",
"coro",
",",
"iterable",
",",
"limit",
"=",
"1",
",",
"loop",
"=",
"None",
")",
":",
"assert_corofunction",
"(",
"coro",
"=",
"coro",
")",
"assert_iter",
"(",
"iterable",
"=",
"iterable",
")",
"# Reduced accumulator value",
"passes",
"... | Returns `True` if every element in a given iterable satisfies the coroutine
asynchronous test.
If any iteratee coroutine call returns `False`, the process is inmediately
stopped, and `False` will be returned.
You can increase the concurrency limit for a fast race condition scenario.
This function... | [
"Returns",
"True",
"if",
"every",
"element",
"in",
"a",
"given",
"iterable",
"satisfies",
"the",
"coroutine",
"asynchronous",
"test",
"."
] | python | train |
iotile/coretools | iotilecore/iotile/core/hw/virtual/base_runnable.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/virtual/base_runnable.py#L47-L56 | def start_workers(self):
"""Start running this virtual device including any necessary worker threads."""
if self._started:
raise InternalError("The method start() was called twice on a BaseRunnable object.")
self._started = True
for worker in self._workers:
wor... | [
"def",
"start_workers",
"(",
"self",
")",
":",
"if",
"self",
".",
"_started",
":",
"raise",
"InternalError",
"(",
"\"The method start() was called twice on a BaseRunnable object.\"",
")",
"self",
".",
"_started",
"=",
"True",
"for",
"worker",
"in",
"self",
".",
"_... | Start running this virtual device including any necessary worker threads. | [
"Start",
"running",
"this",
"virtual",
"device",
"including",
"any",
"necessary",
"worker",
"threads",
"."
] | python | train |
ornlneutronimaging/ImagingReso | ImagingReso/resonance.py | https://github.com/ornlneutronimaging/ImagingReso/blob/2da5cd1f565b3128f59d86bcedfd9adc2b02218b/ImagingReso/resonance.py#L785-L978 | def export(self, output_type='df', filename=None, x_axis='energy', y_axis='attenuation', mixed=True,
all_layers=False, all_elements=False, all_isotopes=False, items_to_export=None,
offset_us=0., source_to_detector_m=16.,
t_start_us=1, time_resolution_us=0.16, time_unit='us')... | [
"def",
"export",
"(",
"self",
",",
"output_type",
"=",
"'df'",
",",
"filename",
"=",
"None",
",",
"x_axis",
"=",
"'energy'",
",",
"y_axis",
"=",
"'attenuation'",
",",
"mixed",
"=",
"True",
",",
"all_layers",
"=",
"False",
",",
"all_elements",
"=",
"False... | output x and y values to clipboard or .csv file
output the transmission or attenuation or sigma of compound, element and/or isotopes specified
'sigma_b' exported for each isotope is the product resulted from (sigma * isotopic ratio)
'atoms_per_cm3' of each element is also exported in 'sigma' mod... | [
"output",
"x",
"and",
"y",
"values",
"to",
"clipboard",
"or",
".",
"csv",
"file",
"output",
"the",
"transmission",
"or",
"attenuation",
"or",
"sigma",
"of",
"compound",
"element",
"and",
"/",
"or",
"isotopes",
"specified",
"sigma_b",
"exported",
"for",
"each... | python | train |
ui/django-post_office | post_office/mail.py | https://github.com/ui/django-post_office/blob/03e1ffb69829b475402f0f3ecd9f8a90af7da4bd/post_office/mail.py#L23-L84 | def create(sender, recipients=None, cc=None, bcc=None, subject='', message='',
html_message='', context=None, scheduled_time=None, headers=None,
template=None, priority=None, render_on_delivery=False, commit=True,
backend=''):
"""
Creates an email from supplied keyword arguments... | [
"def",
"create",
"(",
"sender",
",",
"recipients",
"=",
"None",
",",
"cc",
"=",
"None",
",",
"bcc",
"=",
"None",
",",
"subject",
"=",
"''",
",",
"message",
"=",
"''",
",",
"html_message",
"=",
"''",
",",
"context",
"=",
"None",
",",
"scheduled_time",... | Creates an email from supplied keyword arguments. If template is
specified, email subject and content will be rendered during delivery. | [
"Creates",
"an",
"email",
"from",
"supplied",
"keyword",
"arguments",
".",
"If",
"template",
"is",
"specified",
"email",
"subject",
"and",
"content",
"will",
"be",
"rendered",
"during",
"delivery",
"."
] | python | train |
dwavesystems/dimod | dimod/higherorder/polynomial.py | https://github.com/dwavesystems/dimod/blob/beff1b7f86b559d923ac653c1de6d593876d6d38/dimod/higherorder/polynomial.py#L391-L421 | def to_hising(self):
"""Construct a higher-order Ising problem from a binary polynomial.
Returns:
tuple: A 3-tuple of the form (`h`, `J`, `offset`) where `h` includes
the linear biases, `J` has the higher-order biases and `offset` is
the linear offset.
Examp... | [
"def",
"to_hising",
"(",
"self",
")",
":",
"if",
"self",
".",
"vartype",
"is",
"Vartype",
".",
"BINARY",
":",
"return",
"self",
".",
"to_spin",
"(",
")",
".",
"to_hising",
"(",
")",
"h",
"=",
"{",
"}",
"J",
"=",
"{",
"}",
"offset",
"=",
"0",
"f... | Construct a higher-order Ising problem from a binary polynomial.
Returns:
tuple: A 3-tuple of the form (`h`, `J`, `offset`) where `h` includes
the linear biases, `J` has the higher-order biases and `offset` is
the linear offset.
Examples:
>>> poly = dimo... | [
"Construct",
"a",
"higher",
"-",
"order",
"Ising",
"problem",
"from",
"a",
"binary",
"polynomial",
"."
] | python | train |
GNS3/gns3-server | gns3server/controller/notification.py | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/notification.py#L122-L132 | def _send_event_to_all(self, action, event):
"""
Send an event to all the client listening for notifications on all
projects
:param action: Action name
:param event: Event to send
"""
for project_listeners in self._listeners.values():
for listener in ... | [
"def",
"_send_event_to_all",
"(",
"self",
",",
"action",
",",
"event",
")",
":",
"for",
"project_listeners",
"in",
"self",
".",
"_listeners",
".",
"values",
"(",
")",
":",
"for",
"listener",
"in",
"project_listeners",
":",
"listener",
".",
"put_nowait",
"(",... | Send an event to all the client listening for notifications on all
projects
:param action: Action name
:param event: Event to send | [
"Send",
"an",
"event",
"to",
"all",
"the",
"client",
"listening",
"for",
"notifications",
"on",
"all",
"projects"
] | python | train |
delph-in/pydelphin | delphin/mrs/path.py | https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/path.py#L321-L335 | def merge(base, obj, location=None):
"""
merge is like XmrsPathNode.update() except it raises errors on
unequal non-None values.
"""
# pump object to it's location with dummy nodes
while location:
axis = location.pop()
obj = XmrsPathNode(None, None, links={axis: obj})
if base... | [
"def",
"merge",
"(",
"base",
",",
"obj",
",",
"location",
"=",
"None",
")",
":",
"# pump object to it's location with dummy nodes",
"while",
"location",
":",
"axis",
"=",
"location",
".",
"pop",
"(",
")",
"obj",
"=",
"XmrsPathNode",
"(",
"None",
",",
"None",... | merge is like XmrsPathNode.update() except it raises errors on
unequal non-None values. | [
"merge",
"is",
"like",
"XmrsPathNode",
".",
"update",
"()",
"except",
"it",
"raises",
"errors",
"on",
"unequal",
"non",
"-",
"None",
"values",
"."
] | python | train |
fastai/fastai | fastai/collab.py | https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/collab.py#L55-L68 | def from_df(cls, ratings:DataFrame, valid_pct:float=0.2, user_name:Optional[str]=None, item_name:Optional[str]=None,
rating_name:Optional[str]=None, test:DataFrame=None, seed:int=None, path:PathOrStr='.', bs:int=64,
val_bs:int=None, num_workers:int=defaults.cpus, dl_tfms:Optional[Collec... | [
"def",
"from_df",
"(",
"cls",
",",
"ratings",
":",
"DataFrame",
",",
"valid_pct",
":",
"float",
"=",
"0.2",
",",
"user_name",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"item_name",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"rating... | Create a `DataBunch` suitable for collaborative filtering from `ratings`. | [
"Create",
"a",
"DataBunch",
"suitable",
"for",
"collaborative",
"filtering",
"from",
"ratings",
"."
] | python | train |
gbiggs/rtctree | rtctree/config_set.py | https://github.com/gbiggs/rtctree/blob/bd725a47ac87c259c8bce06156ccc9ab71111c26/rtctree/config_set.py#L71-L75 | def _reload(self, object, description, data):
'''Reload the configuration set data.'''
self._object = object
self._description = description
self._data = data | [
"def",
"_reload",
"(",
"self",
",",
"object",
",",
"description",
",",
"data",
")",
":",
"self",
".",
"_object",
"=",
"object",
"self",
".",
"_description",
"=",
"description",
"self",
".",
"_data",
"=",
"data"
] | Reload the configuration set data. | [
"Reload",
"the",
"configuration",
"set",
"data",
"."
] | python | train |
dnanexus/dx-toolkit | src/python/dxpy/executable_builder.py | https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/executable_builder.py#L166-L200 | def assert_consistent_reg_options(exec_type, json_spec, executable_builder_exeception):
"""
Validates the "regionalOptions" field and verifies all the regions used
in "regionalOptions" have the same options.
"""
reg_options_spec = json_spec.get('regionalOptions')
json_fn = 'dxapp.json' if exec_t... | [
"def",
"assert_consistent_reg_options",
"(",
"exec_type",
",",
"json_spec",
",",
"executable_builder_exeception",
")",
":",
"reg_options_spec",
"=",
"json_spec",
".",
"get",
"(",
"'regionalOptions'",
")",
"json_fn",
"=",
"'dxapp.json'",
"if",
"exec_type",
"==",
"'app'... | Validates the "regionalOptions" field and verifies all the regions used
in "regionalOptions" have the same options. | [
"Validates",
"the",
"regionalOptions",
"field",
"and",
"verifies",
"all",
"the",
"regions",
"used",
"in",
"regionalOptions",
"have",
"the",
"same",
"options",
"."
] | python | train |
dade-ai/snipy | snipy/plt/ploting.py | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/plt/ploting.py#L279-L287 | def matshow(*args, **kwargs):
"""
imshow without interpolation like as matshow
:param args:
:param kwargs:
:return:
"""
kwargs['interpolation'] = kwargs.pop('interpolation', 'none')
return plt.imshow(*args, **kwargs) | [
"def",
"matshow",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'interpolation'",
"]",
"=",
"kwargs",
".",
"pop",
"(",
"'interpolation'",
",",
"'none'",
")",
"return",
"plt",
".",
"imshow",
"(",
"*",
"args",
",",
"*",
"*",
"k... | imshow without interpolation like as matshow
:param args:
:param kwargs:
:return: | [
"imshow",
"without",
"interpolation",
"like",
"as",
"matshow",
":",
"param",
"args",
":",
":",
"param",
"kwargs",
":",
":",
"return",
":"
] | python | valid |
aio-libs/yarl | yarl/__init__.py | https://github.com/aio-libs/yarl/blob/e47da02c00ad764e030ca7647a9565548c97d362/yarl/__init__.py#L435-L453 | def host(self):
"""Decoded host part of URL.
None for relative URLs.
"""
raw = self.raw_host
if raw is None:
return None
if "%" in raw:
# Hack for scoped IPv6 addresses like
# fe80::2%Проверка
# presence of '%' sign means ... | [
"def",
"host",
"(",
"self",
")",
":",
"raw",
"=",
"self",
".",
"raw_host",
"if",
"raw",
"is",
"None",
":",
"return",
"None",
"if",
"\"%\"",
"in",
"raw",
":",
"# Hack for scoped IPv6 addresses like",
"# fe80::2%Проверка",
"# presence of '%' sign means only IPv6 addre... | Decoded host part of URL.
None for relative URLs. | [
"Decoded",
"host",
"part",
"of",
"URL",
"."
] | python | train |
andychase/reparse | reparse/expression.py | https://github.com/andychase/reparse/blob/5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508/reparse/expression.py#L108-L121 | def AlternatesGroup(expressions, final_function, name=""):
""" Group expressions using the OR character ``|``
>>> from collections import namedtuple
>>> expr = namedtuple('expr', 'regex group_lengths run')('(1)', [1], None)
>>> grouping = AlternatesGroup([expr, expr], lambda f: None, 'yeah')
>>> gro... | [
"def",
"AlternatesGroup",
"(",
"expressions",
",",
"final_function",
",",
"name",
"=",
"\"\"",
")",
":",
"inbetweens",
"=",
"[",
"\"|\"",
"]",
"*",
"(",
"len",
"(",
"expressions",
")",
"+",
"1",
")",
"inbetweens",
"[",
"0",
"]",
"=",
"\"\"",
"inbetween... | Group expressions using the OR character ``|``
>>> from collections import namedtuple
>>> expr = namedtuple('expr', 'regex group_lengths run')('(1)', [1], None)
>>> grouping = AlternatesGroup([expr, expr], lambda f: None, 'yeah')
>>> grouping.regex # doctest: +IGNORE_UNICODE
'(?:(1))|(?:(1))'
>... | [
"Group",
"expressions",
"using",
"the",
"OR",
"character",
"|",
">>>",
"from",
"collections",
"import",
"namedtuple",
">>>",
"expr",
"=",
"namedtuple",
"(",
"expr",
"regex",
"group_lengths",
"run",
")",
"(",
"(",
"1",
")",
"[",
"1",
"]",
"None",
")",
">>... | python | train |
sixty-north/cosmic-ray | src/cosmic_ray/operators/zero_iteration_for_loop.py | https://github.com/sixty-north/cosmic-ray/blob/c654e074afbb7b7fcbc23359083c1287c0d3e991/src/cosmic_ray/operators/zero_iteration_for_loop.py#L17-L24 | def mutate(self, node, index):
"""Modify the For loop to evaluate to None"""
assert index == 0
assert isinstance(node, ForStmt)
empty_list = parso.parse(' []')
node.children[3] = empty_list
return node | [
"def",
"mutate",
"(",
"self",
",",
"node",
",",
"index",
")",
":",
"assert",
"index",
"==",
"0",
"assert",
"isinstance",
"(",
"node",
",",
"ForStmt",
")",
"empty_list",
"=",
"parso",
".",
"parse",
"(",
"' []'",
")",
"node",
".",
"children",
"[",
"3",... | Modify the For loop to evaluate to None | [
"Modify",
"the",
"For",
"loop",
"to",
"evaluate",
"to",
"None"
] | python | train |
marcomusy/vtkplotter | vtkplotter/colors.py | https://github.com/marcomusy/vtkplotter/blob/692c3396782722ec525bc1346a26999868c650c6/vtkplotter/colors.py#L758-L874 | def printHistogram(data, bins=10, height=10, logscale=False, minbin=0,
horizontal=False, char=u"\U00002589",
c=None, bold=True, title='Histogram'):
"""
Ascii histogram printing.
:param int bins: number of histogram bins
:param int height: height of the histogram in... | [
"def",
"printHistogram",
"(",
"data",
",",
"bins",
"=",
"10",
",",
"height",
"=",
"10",
",",
"logscale",
"=",
"False",
",",
"minbin",
"=",
"0",
",",
"horizontal",
"=",
"False",
",",
"char",
"=",
"u\"\\U00002589\"",
",",
"c",
"=",
"None",
",",
"bold",... | Ascii histogram printing.
:param int bins: number of histogram bins
:param int height: height of the histogram in character units
:param bool logscale: use logscale for frequencies
:param int minbin: ignore bins before minbin
:param bool horizontal: show histogram horizontally
:param str char: ... | [
"Ascii",
"histogram",
"printing",
"."
] | python | train |
apache/incubator-superset | superset/connectors/base/models.py | https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/connectors/base/models.py#L166-L215 | def data(self):
"""Data representation of the datasource sent to the frontend"""
order_by_choices = []
# self.column_names return sorted column_names
for s in self.column_names:
s = str(s or '')
order_by_choices.append((json.dumps([s, True]), s + ' [asc]'))
... | [
"def",
"data",
"(",
"self",
")",
":",
"order_by_choices",
"=",
"[",
"]",
"# self.column_names return sorted column_names",
"for",
"s",
"in",
"self",
".",
"column_names",
":",
"s",
"=",
"str",
"(",
"s",
"or",
"''",
")",
"order_by_choices",
".",
"append",
"(",... | Data representation of the datasource sent to the frontend | [
"Data",
"representation",
"of",
"the",
"datasource",
"sent",
"to",
"the",
"frontend"
] | python | train |
dmwm/DBS | Server/Python/src/dbs/business/DBSBlockInsert.py | https://github.com/dmwm/DBS/blob/9619bafce3783b3e77f0415f8f9a258e33dd1e6f/Server/Python/src/dbs/business/DBSBlockInsert.py#L430-L562 | def insertOutputModuleConfig(self, remoteConfig, migration=False):
"""
Insert Release version, application, parameter set hashes and the map(output module config).
"""
otptIdList = []
missingList = []
conn = self.dbi.connection()
try:
for c in remoteC... | [
"def",
"insertOutputModuleConfig",
"(",
"self",
",",
"remoteConfig",
",",
"migration",
"=",
"False",
")",
":",
"otptIdList",
"=",
"[",
"]",
"missingList",
"=",
"[",
"]",
"conn",
"=",
"self",
".",
"dbi",
".",
"connection",
"(",
")",
"try",
":",
"for",
"... | Insert Release version, application, parameter set hashes and the map(output module config). | [
"Insert",
"Release",
"version",
"application",
"parameter",
"set",
"hashes",
"and",
"the",
"map",
"(",
"output",
"module",
"config",
")",
"."
] | python | train |
gmr/rejected | rejected/mcp.py | https://github.com/gmr/rejected/blob/610a3e1401122ecb98d891b6795cca0255e5b044/rejected/mcp.py#L535-L561 | def remove_consumer_process(self, consumer, name):
"""Remove all details for the specified consumer and process name.
:param str consumer: The consumer name
:param str name: The process name
"""
my_pid = os.getpid()
if name in self.consumers[consumer].processes.keys():
... | [
"def",
"remove_consumer_process",
"(",
"self",
",",
"consumer",
",",
"name",
")",
":",
"my_pid",
"=",
"os",
".",
"getpid",
"(",
")",
"if",
"name",
"in",
"self",
".",
"consumers",
"[",
"consumer",
"]",
".",
"processes",
".",
"keys",
"(",
")",
":",
"ch... | Remove all details for the specified consumer and process name.
:param str consumer: The consumer name
:param str name: The process name | [
"Remove",
"all",
"details",
"for",
"the",
"specified",
"consumer",
"and",
"process",
"name",
"."
] | python | train |
pandas-dev/pandas | pandas/core/dtypes/concat.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/concat.py#L18-L56 | def get_dtype_kinds(l):
"""
Parameters
----------
l : list of arrays
Returns
-------
a set of kinds that exist in this list of arrays
"""
typs = set()
for arr in l:
dtype = arr.dtype
if is_categorical_dtype(dtype):
typ = 'category'
elif is_s... | [
"def",
"get_dtype_kinds",
"(",
"l",
")",
":",
"typs",
"=",
"set",
"(",
")",
"for",
"arr",
"in",
"l",
":",
"dtype",
"=",
"arr",
".",
"dtype",
"if",
"is_categorical_dtype",
"(",
"dtype",
")",
":",
"typ",
"=",
"'category'",
"elif",
"is_sparse",
"(",
"ar... | Parameters
----------
l : list of arrays
Returns
-------
a set of kinds that exist in this list of arrays | [
"Parameters",
"----------",
"l",
":",
"list",
"of",
"arrays"
] | python | train |
PredixDev/predixpy | predix/data/asset.py | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/data/asset.py#L132-L140 | def put_collection(self, collection, body):
"""
Updates an existing collection.
The collection being updated *is* expected to include the id.
"""
uri = self.uri + '/v1' + collection
return self.service._put(uri, body) | [
"def",
"put_collection",
"(",
"self",
",",
"collection",
",",
"body",
")",
":",
"uri",
"=",
"self",
".",
"uri",
"+",
"'/v1'",
"+",
"collection",
"return",
"self",
".",
"service",
".",
"_put",
"(",
"uri",
",",
"body",
")"
] | Updates an existing collection.
The collection being updated *is* expected to include the id. | [
"Updates",
"an",
"existing",
"collection",
"."
] | python | train |
urinieto/msaf | msaf/algorithms/fmc2d/xmeans.py | https://github.com/urinieto/msaf/blob/9dbb57d77a1310465a65cc40f1641d083ca74385/msaf/algorithms/fmc2d/xmeans.py#L18-L82 | def estimate_K_xmeans(self, th=0.2, maxK = 10):
"""Estimates K running X-means algorithm (Pelleg & Moore, 2000)."""
# Run initial K-means
means, labels = self.run_kmeans(self.X, self.init_K)
# Run X-means algorithm
stop = False
curr_K = self.init_K
while not sto... | [
"def",
"estimate_K_xmeans",
"(",
"self",
",",
"th",
"=",
"0.2",
",",
"maxK",
"=",
"10",
")",
":",
"# Run initial K-means",
"means",
",",
"labels",
"=",
"self",
".",
"run_kmeans",
"(",
"self",
".",
"X",
",",
"self",
".",
"init_K",
")",
"# Run X-means algo... | Estimates K running X-means algorithm (Pelleg & Moore, 2000). | [
"Estimates",
"K",
"running",
"X",
"-",
"means",
"algorithm",
"(",
"Pelleg",
"&",
"Moore",
"2000",
")",
"."
] | python | test |
AndrewAnnex/SpiceyPy | spiceypy/spiceypy.py | https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L2028-L2052 | def dafrda(handle, begin, end):
"""
Read the double precision data bounded by two addresses within a DAF.
Deprecated: This routine has been superseded by :func:`dafgda` and
:func:`dafgsr`. This routine is supported for purposes of backward
compatibility only.
http://naif.jpl.nasa.gov/pub/naif... | [
"def",
"dafrda",
"(",
"handle",
",",
"begin",
",",
"end",
")",
":",
"handle",
"=",
"ctypes",
".",
"c_int",
"(",
"handle",
")",
"begin",
"=",
"ctypes",
".",
"c_int",
"(",
"begin",
")",
"end",
"=",
"ctypes",
".",
"c_int",
"(",
"end",
")",
"data",
"... | Read the double precision data bounded by two addresses within a DAF.
Deprecated: This routine has been superseded by :func:`dafgda` and
:func:`dafgsr`. This routine is supported for purposes of backward
compatibility only.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dafrda_c.html
:p... | [
"Read",
"the",
"double",
"precision",
"data",
"bounded",
"by",
"two",
"addresses",
"within",
"a",
"DAF",
"."
] | python | train |
lingthio/Flask-User | flask_user/db_adapters/dynamo_db_adapter.py | https://github.com/lingthio/Flask-User/blob/a379fa0a281789618c484b459cb41236779b95b1/flask_user/db_adapters/dynamo_db_adapter.py#L39-L50 | def get_object(self, ObjectClass, id):
""" Retrieve object of type ``ObjectClass`` by ``id``.
| Returns object on success.
| Returns None otherwise.
"""
print('dynamo.get(%s, %s)' % (ObjectClass, str(id)))
resp = self.db.engine.get(ObjectClass, [id])
if resp:
... | [
"def",
"get_object",
"(",
"self",
",",
"ObjectClass",
",",
"id",
")",
":",
"print",
"(",
"'dynamo.get(%s, %s)'",
"%",
"(",
"ObjectClass",
",",
"str",
"(",
"id",
")",
")",
")",
"resp",
"=",
"self",
".",
"db",
".",
"engine",
".",
"get",
"(",
"ObjectCla... | Retrieve object of type ``ObjectClass`` by ``id``.
| Returns object on success.
| Returns None otherwise. | [
"Retrieve",
"object",
"of",
"type",
"ObjectClass",
"by",
"id",
"."
] | python | train |
RedFantom/ttkwidgets | ttkwidgets/color/functions.py | https://github.com/RedFantom/ttkwidgets/blob/02150322060f867b6e59a175522ef84b09168019/ttkwidgets/color/functions.py#L57-L60 | def rgb_to_hsv(r, g, b):
"""Convert RGB color to HSV."""
h, s, v = colorsys.rgb_to_hsv(r / 255., g / 255., b / 255.)
return round2(h * 360), round2(s * 100), round2(v * 100) | [
"def",
"rgb_to_hsv",
"(",
"r",
",",
"g",
",",
"b",
")",
":",
"h",
",",
"s",
",",
"v",
"=",
"colorsys",
".",
"rgb_to_hsv",
"(",
"r",
"/",
"255.",
",",
"g",
"/",
"255.",
",",
"b",
"/",
"255.",
")",
"return",
"round2",
"(",
"h",
"*",
"360",
")... | Convert RGB color to HSV. | [
"Convert",
"RGB",
"color",
"to",
"HSV",
"."
] | python | train |
globality-corp/microcosm-flask | microcosm_flask/conventions/relation.py | https://github.com/globality-corp/microcosm-flask/blob/c2eaf57f03e7d041eea343751a4a90fcc80df418/microcosm_flask/conventions/relation.py#L252-L258 | def configure_relation(graph, ns, mappings):
"""
Register relation endpoint(s) between two resources.
"""
convention = RelationConvention(graph)
convention.configure(ns, mappings) | [
"def",
"configure_relation",
"(",
"graph",
",",
"ns",
",",
"mappings",
")",
":",
"convention",
"=",
"RelationConvention",
"(",
"graph",
")",
"convention",
".",
"configure",
"(",
"ns",
",",
"mappings",
")"
] | Register relation endpoint(s) between two resources. | [
"Register",
"relation",
"endpoint",
"(",
"s",
")",
"between",
"two",
"resources",
"."
] | python | train |
pudo/jsongraph | jsongraph/query.py | https://github.com/pudo/jsongraph/blob/35e4f397dbe69cd5553cf9cb9ab98859c3620f03/jsongraph/query.py#L132-L152 | def query(self, parents=None):
""" Compose the query and generate SPARQL. """
# TODO: benchmark single-query strategy
q = Select([])
q = self.project(q, parent=True)
q = self.filter(q, parents=parents)
if self.parent is None:
subq = Select([self.var])
... | [
"def",
"query",
"(",
"self",
",",
"parents",
"=",
"None",
")",
":",
"# TODO: benchmark single-query strategy",
"q",
"=",
"Select",
"(",
"[",
"]",
")",
"q",
"=",
"self",
".",
"project",
"(",
"q",
",",
"parent",
"=",
"True",
")",
"q",
"=",
"self",
".",... | Compose the query and generate SPARQL. | [
"Compose",
"the",
"query",
"and",
"generate",
"SPARQL",
"."
] | python | train |
TankerHQ/python-cli-ui | cli_ui/__init__.py | https://github.com/TankerHQ/python-cli-ui/blob/4c9928827cea06cf80e6a1f5bd86478d8566863f/cli_ui/__init__.py#L538-L554 | def ask_yes_no(*question: Token, default: bool = False) -> bool:
"""Ask the user to answer by yes or no"""
while True:
tokens = [green, "::", reset] + list(question) + [reset]
if default:
tokens.append("(Y/n)")
else:
tokens.append("(y/N)")
info(*tokens)
... | [
"def",
"ask_yes_no",
"(",
"*",
"question",
":",
"Token",
",",
"default",
":",
"bool",
"=",
"False",
")",
"->",
"bool",
":",
"while",
"True",
":",
"tokens",
"=",
"[",
"green",
",",
"\"::\"",
",",
"reset",
"]",
"+",
"list",
"(",
"question",
")",
"+",... | Ask the user to answer by yes or no | [
"Ask",
"the",
"user",
"to",
"answer",
"by",
"yes",
"or",
"no"
] | python | train |
chrippa/ds4drv | ds4drv/actions/binding.py | https://github.com/chrippa/ds4drv/blob/be7327fc3f5abb8717815f2a1a2ad3d335535d8a/ds4drv/actions/binding.py#L120-L130 | def exec_background(controller, cmd, *args):
"""Executes a subprocess in the background."""
controller.logger.info("Executing in the background: {0} {1}",
cmd, " ".join(args))
try:
subprocess.Popen([cmd] + list(args),
stdout=open(os.devnull, "wb")... | [
"def",
"exec_background",
"(",
"controller",
",",
"cmd",
",",
"*",
"args",
")",
":",
"controller",
".",
"logger",
".",
"info",
"(",
"\"Executing in the background: {0} {1}\"",
",",
"cmd",
",",
"\" \"",
".",
"join",
"(",
"args",
")",
")",
"try",
":",
"subpr... | Executes a subprocess in the background. | [
"Executes",
"a",
"subprocess",
"in",
"the",
"background",
"."
] | python | train |
jonbretman/jinja-to-js | jinja_to_js/__init__.py | https://github.com/jonbretman/jinja-to-js/blob/0a784b10a83d37a3171c5797547e9fc460c51289/jinja_to_js/__init__.py#L251-L268 | def get_output(self):
"""
Returns the generated JavaScript code.
Returns:
str
"""
# generate the JS function string
template_function = TEMPLATE_WRAPPER.format(
function_name=self.js_function_name,
template_code=self.output.getvalue()
... | [
"def",
"get_output",
"(",
"self",
")",
":",
"# generate the JS function string",
"template_function",
"=",
"TEMPLATE_WRAPPER",
".",
"format",
"(",
"function_name",
"=",
"self",
".",
"js_function_name",
",",
"template_code",
"=",
"self",
".",
"output",
".",
"getvalue... | Returns the generated JavaScript code.
Returns:
str | [
"Returns",
"the",
"generated",
"JavaScript",
"code",
"."
] | python | train |
mozilla-services/amo2kinto | amo2kinto/exporter.py | https://github.com/mozilla-services/amo2kinto/blob/1ec40647e77cf89badbea4a58d328243daed49a9/amo2kinto/exporter.py#L326-L352 | def write_cert_items(xml_tree, records, api_ver=3, app_id=None, app_ver=None):
"""Generate the certificate blocklists.
<certItem issuerName="MIGQMQswCQYD...IENB">
<serialNumber>UoRGnb96CUDTxIqVry6LBg==</serialNumber>
</certItem>
or
<certItem subject='MCIxIDAeBgNVBAMMF0Fub3RoZXIgVGVzdCBFbmQt... | [
"def",
"write_cert_items",
"(",
"xml_tree",
",",
"records",
",",
"api_ver",
"=",
"3",
",",
"app_id",
"=",
"None",
",",
"app_ver",
"=",
"None",
")",
":",
"if",
"not",
"records",
"or",
"not",
"should_include_certs",
"(",
"app_id",
",",
"app_ver",
")",
":",... | Generate the certificate blocklists.
<certItem issuerName="MIGQMQswCQYD...IENB">
<serialNumber>UoRGnb96CUDTxIqVry6LBg==</serialNumber>
</certItem>
or
<certItem subject='MCIxIDAeBgNVBAMMF0Fub3RoZXIgVGVzdCBFbmQtZW50aXR5'
pubKeyHash='VCIlmPM9NkgFQtrs4Oa5TeFcDu6MWRTKSNdePEhOgD8='>
... | [
"Generate",
"the",
"certificate",
"blocklists",
"."
] | python | train |
RRZE-HPC/kerncraft | kerncraft/models/ecm.py | https://github.com/RRZE-HPC/kerncraft/blob/c60baf8043e4da8d8d66da7575021c2f4c6c78af/kerncraft/models/ecm.py#L339-L357 | def conv_cy(self, cy_cl):
"""Convert cycles (cy/CL) to other units, such as FLOP/s or It/s."""
if not isinstance(cy_cl, PrefixedUnit):
cy_cl = PrefixedUnit(cy_cl, '', 'cy/CL')
clock = self.machine['clock']
element_size = self.kernel.datatypes_size[self.kernel.datatype]
... | [
"def",
"conv_cy",
"(",
"self",
",",
"cy_cl",
")",
":",
"if",
"not",
"isinstance",
"(",
"cy_cl",
",",
"PrefixedUnit",
")",
":",
"cy_cl",
"=",
"PrefixedUnit",
"(",
"cy_cl",
",",
"''",
",",
"'cy/CL'",
")",
"clock",
"=",
"self",
".",
"machine",
"[",
"'cl... | Convert cycles (cy/CL) to other units, such as FLOP/s or It/s. | [
"Convert",
"cycles",
"(",
"cy",
"/",
"CL",
")",
"to",
"other",
"units",
"such",
"as",
"FLOP",
"/",
"s",
"or",
"It",
"/",
"s",
"."
] | python | test |
IdentityPython/SATOSA | src/satosa/proxy_server.py | https://github.com/IdentityPython/SATOSA/blob/49da5d4c0ac1a5ebf1a71b4f7aaf04f0e52d8fdb/src/satosa/proxy_server.py#L31-L45 | def unpack_post(environ, content_length):
"""
Unpacks a post request query string.
:param environ: whiskey application environment.
:return: A dictionary with parameters.
"""
post_body = environ['wsgi.input'].read(content_length).decode("utf-8")
data = None
if "application/x-www-form-url... | [
"def",
"unpack_post",
"(",
"environ",
",",
"content_length",
")",
":",
"post_body",
"=",
"environ",
"[",
"'wsgi.input'",
"]",
".",
"read",
"(",
"content_length",
")",
".",
"decode",
"(",
"\"utf-8\"",
")",
"data",
"=",
"None",
"if",
"\"application/x-www-form-ur... | Unpacks a post request query string.
:param environ: whiskey application environment.
:return: A dictionary with parameters. | [
"Unpacks",
"a",
"post",
"request",
"query",
"string",
".",
":",
"param",
"environ",
":",
"whiskey",
"application",
"environment",
".",
":",
"return",
":",
"A",
"dictionary",
"with",
"parameters",
"."
] | python | train |
jpscaletti/solution | solution/fields/file/image.py | https://github.com/jpscaletti/solution/blob/eabafd8e695bbb0209242e002dbcc05ffb327f43/solution/fields/file/image.py#L22-L30 | def clean(self, value):
"""Passes the value to FileField and resizes the image at the path the parent
returns if needed.
"""
path = super(Image, self).clean(value)
if path and self.size:
self.resize_image(join(self.base_path, path))
return path | [
"def",
"clean",
"(",
"self",
",",
"value",
")",
":",
"path",
"=",
"super",
"(",
"Image",
",",
"self",
")",
".",
"clean",
"(",
"value",
")",
"if",
"path",
"and",
"self",
".",
"size",
":",
"self",
".",
"resize_image",
"(",
"join",
"(",
"self",
".",... | Passes the value to FileField and resizes the image at the path the parent
returns if needed. | [
"Passes",
"the",
"value",
"to",
"FileField",
"and",
"resizes",
"the",
"image",
"at",
"the",
"path",
"the",
"parent",
"returns",
"if",
"needed",
"."
] | python | train |
jorgenschaefer/elpy | elpy/rpc.py | https://github.com/jorgenschaefer/elpy/blob/ffd982f829b11e53f2be187c7b770423341f29bc/elpy/rpc.py#L59-L68 | def read_json(self):
"""Read a single line and decode it as JSON.
Can raise an EOFError() when the input source was closed.
"""
line = self.stdin.readline()
if line == '':
raise EOFError()
return json.loads(line) | [
"def",
"read_json",
"(",
"self",
")",
":",
"line",
"=",
"self",
".",
"stdin",
".",
"readline",
"(",
")",
"if",
"line",
"==",
"''",
":",
"raise",
"EOFError",
"(",
")",
"return",
"json",
".",
"loads",
"(",
"line",
")"
] | Read a single line and decode it as JSON.
Can raise an EOFError() when the input source was closed. | [
"Read",
"a",
"single",
"line",
"and",
"decode",
"it",
"as",
"JSON",
"."
] | python | train |
ihgazni2/elist | elist/elist.py | https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L570-L602 | def findfivo(ol,*args,**kwargs):
'''
#findfivo f,i,v,o四元决定 fivo-4-tuple-engine
#cond_func diff_func(index,value,*diff_args)
'''
args = list(args)
lngth = args.__len__()
if(lngth==0):
diff_funcs_arr = kwargs['cond_funcs']
diff_args_... | [
"def",
"findfivo",
"(",
"ol",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"args",
"=",
"list",
"(",
"args",
")",
"lngth",
"=",
"args",
".",
"__len__",
"(",
")",
"if",
"(",
"lngth",
"==",
"0",
")",
":",
"diff_funcs_arr",
"=",
"kwargs",
... | #findfivo f,i,v,o四元决定 fivo-4-tuple-engine
#cond_func diff_func(index,value,*diff_args) | [
"#findfivo",
"f",
"i",
"v",
"o四元决定",
"fivo",
"-",
"4",
"-",
"tuple",
"-",
"engine",
"#cond_func",
"diff_func",
"(",
"index",
"value",
"*",
"diff_args",
")"
] | python | valid |
datastax/python-driver | cassandra/cqlengine/query.py | https://github.com/datastax/python-driver/blob/30a80d0b798b1f45f8cb77163b1fa791f3e3ca29/cassandra/cqlengine/query.py#L1507-L1518 | def delete(self):
""" Deletes one instance """
if self.instance is None:
raise CQLEngineException("DML Query instance attribute is None")
ds = DeleteStatement(self.column_family_name, timestamp=self._timestamp, conditionals=self._conditional, if_exists=self._if_exists)
for n... | [
"def",
"delete",
"(",
"self",
")",
":",
"if",
"self",
".",
"instance",
"is",
"None",
":",
"raise",
"CQLEngineException",
"(",
"\"DML Query instance attribute is None\"",
")",
"ds",
"=",
"DeleteStatement",
"(",
"self",
".",
"column_family_name",
",",
"timestamp",
... | Deletes one instance | [
"Deletes",
"one",
"instance"
] | python | train |
alkivi-sas/python-alkivi-logger | alkivi/logger/logger.py | https://github.com/alkivi-sas/python-alkivi-logger/blob/e96d5a987a5c8789c51d4fa7541709e05b1f51e1/alkivi/logger/logger.py#L227-L234 | def _get_handler(self, handler_class):
"""Return an existing class of handler."""
element = None
for handler in self.handlers:
if isinstance(handler, handler_class):
element = handler
break
return element | [
"def",
"_get_handler",
"(",
"self",
",",
"handler_class",
")",
":",
"element",
"=",
"None",
"for",
"handler",
"in",
"self",
".",
"handlers",
":",
"if",
"isinstance",
"(",
"handler",
",",
"handler_class",
")",
":",
"element",
"=",
"handler",
"break",
"retur... | Return an existing class of handler. | [
"Return",
"an",
"existing",
"class",
"of",
"handler",
"."
] | python | train |
sassoo/goldman | goldman/queryparams/page.py | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/queryparams/page.py#L78-L87 | def last(self):
""" Generate query parameters for the last page """
if self.limit > self.total:
return None
elif self.offset >= self.total:
return None
else:
offset = (self.total / self.limit) * self.limit
return {'page[offset]': offset, '... | [
"def",
"last",
"(",
"self",
")",
":",
"if",
"self",
".",
"limit",
">",
"self",
".",
"total",
":",
"return",
"None",
"elif",
"self",
".",
"offset",
">=",
"self",
".",
"total",
":",
"return",
"None",
"else",
":",
"offset",
"=",
"(",
"self",
".",
"t... | Generate query parameters for the last page | [
"Generate",
"query",
"parameters",
"for",
"the",
"last",
"page"
] | python | train |
mabuchilab/QNET | src/qnet/algebra/core/abstract_algebra.py | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/abstract_algebra.py#L629-L639 | def free_symbols(self):
"""Set of free SymPy symbols contained within the expression."""
if self._free_symbols is None:
res = set.union(
set([]), # dummy arg (union fails without arguments)
*[_free_symbols(val) for val in self.kwargs.values()])
res... | [
"def",
"free_symbols",
"(",
"self",
")",
":",
"if",
"self",
".",
"_free_symbols",
"is",
"None",
":",
"res",
"=",
"set",
".",
"union",
"(",
"set",
"(",
"[",
"]",
")",
",",
"# dummy arg (union fails without arguments)",
"*",
"[",
"_free_symbols",
"(",
"val",... | Set of free SymPy symbols contained within the expression. | [
"Set",
"of",
"free",
"SymPy",
"symbols",
"contained",
"within",
"the",
"expression",
"."
] | python | train |
tylerbutler/engineer | engineer/devtools/theme_tools.py | https://github.com/tylerbutler/engineer/blob/8884f587297f37646c40e5553174852b444a4024/engineer/devtools/theme_tools.py#L47-L65 | def list_theme():
"""List all available Engineer themes."""
from engineer.themes import ThemeManager
themes = ThemeManager.themes()
col1, col2 = map(max, zip(*[(len(t.id) + 2, len(t.root_path) + 2) for t in themes.itervalues()]))
themes = ThemeManager.themes_by_finder()
for finder in sorted(th... | [
"def",
"list_theme",
"(",
")",
":",
"from",
"engineer",
".",
"themes",
"import",
"ThemeManager",
"themes",
"=",
"ThemeManager",
".",
"themes",
"(",
")",
"col1",
",",
"col2",
"=",
"map",
"(",
"max",
",",
"zip",
"(",
"*",
"[",
"(",
"len",
"(",
"t",
"... | List all available Engineer themes. | [
"List",
"all",
"available",
"Engineer",
"themes",
"."
] | python | train |
erigones/zabbix-api | zabbix_api.py | https://github.com/erigones/zabbix-api/blob/2474ab1d1ddb46c26eea70671b3a599b836d42da/zabbix_api.py#L333-L341 | def relogin(self):
"""Perform a re-login"""
try:
self.__auth = None # reset auth before relogin
self.login()
except ZabbixAPIException as e:
self.log(ERROR, 'Zabbix API relogin error (%s)', e)
self.__auth = None # logged_in() will always return F... | [
"def",
"relogin",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"__auth",
"=",
"None",
"# reset auth before relogin",
"self",
".",
"login",
"(",
")",
"except",
"ZabbixAPIException",
"as",
"e",
":",
"self",
".",
"log",
"(",
"ERROR",
",",
"'Zabbix API relo... | Perform a re-login | [
"Perform",
"a",
"re",
"-",
"login"
] | python | train |
partofthething/ace | ace/supersmoother.py | https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/supersmoother.py#L93-L111 | def _enhance_bass(self):
"""Update best span choices with bass enhancement as requested by user (Eq. 11)."""
if not self._bass_enhancement:
# like in supsmu, skip if alpha=0
return
bass_span = DEFAULT_SPANS[BASS_INDEX]
enhanced_spans = []
for i, best_span_... | [
"def",
"_enhance_bass",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_bass_enhancement",
":",
"# like in supsmu, skip if alpha=0",
"return",
"bass_span",
"=",
"DEFAULT_SPANS",
"[",
"BASS_INDEX",
"]",
"enhanced_spans",
"=",
"[",
"]",
"for",
"i",
",",
"best_s... | Update best span choices with bass enhancement as requested by user (Eq. 11). | [
"Update",
"best",
"span",
"choices",
"with",
"bass",
"enhancement",
"as",
"requested",
"by",
"user",
"(",
"Eq",
".",
"11",
")",
"."
] | python | train |
oisinmulvihill/stomper | lib/stomper/stomp_10.py | https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/stomp_10.py#L493-L514 | def receipt(self, msg):
"""Called to handle a receipt message received from the server.
This method just logs the receipt message
returned:
NO_RESPONSE_NEEDED
"""
body = msg['body'].replace(NULL, '')
brief_msg = ""
if 'receipt-id' in msg['headers']... | [
"def",
"receipt",
"(",
"self",
",",
"msg",
")",
":",
"body",
"=",
"msg",
"[",
"'body'",
"]",
".",
"replace",
"(",
"NULL",
",",
"''",
")",
"brief_msg",
"=",
"\"\"",
"if",
"'receipt-id'",
"in",
"msg",
"[",
"'headers'",
"]",
":",
"brief_msg",
"=",
"ms... | Called to handle a receipt message received from the server.
This method just logs the receipt message
returned:
NO_RESPONSE_NEEDED | [
"Called",
"to",
"handle",
"a",
"receipt",
"message",
"received",
"from",
"the",
"server",
"."
] | python | train |
rainwoodman/sharedmem | sharedmem/sharedmem.py | https://github.com/rainwoodman/sharedmem/blob/b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a/sharedmem/sharedmem.py#L812-L823 | def copy(a):
""" Copy an array to the shared memory.
Notes
-----
copy is not always necessary because the private memory is always copy-on-write.
Use :code:`a = copy(a)` to immediately dereference the old 'a' on private memory
"""
shared = anonymousmemmap(a.shape, dtype=a.... | [
"def",
"copy",
"(",
"a",
")",
":",
"shared",
"=",
"anonymousmemmap",
"(",
"a",
".",
"shape",
",",
"dtype",
"=",
"a",
".",
"dtype",
")",
"shared",
"[",
":",
"]",
"=",
"a",
"[",
":",
"]",
"return",
"shared"
] | Copy an array to the shared memory.
Notes
-----
copy is not always necessary because the private memory is always copy-on-write.
Use :code:`a = copy(a)` to immediately dereference the old 'a' on private memory | [
"Copy",
"an",
"array",
"to",
"the",
"shared",
"memory",
"."
] | python | valid |
luckydonald/pytgbot | pytgbot/api_types/sendable/input_media.py | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/sendable/input_media.py#L363-L392 | def to_array(self):
"""
Serializes this InputMediaVideo to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
from .files import InputFile
array = super(InputMediaVideo, self).to_array()
# 'type' given by superclass
... | [
"def",
"to_array",
"(",
"self",
")",
":",
"from",
".",
"files",
"import",
"InputFile",
"array",
"=",
"super",
"(",
"InputMediaVideo",
",",
"self",
")",
".",
"to_array",
"(",
")",
"# 'type' given by superclass",
"# 'media' given by superclass",
"if",
"self",
".",... | Serializes this InputMediaVideo to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"InputMediaVideo",
"to",
"a",
"dictionary",
"."
] | python | train |
waqasbhatti/astrobase | astrobase/checkplot/pkl.py | https://github.com/waqasbhatti/astrobase/blob/2922a14619d183fb28005fa7d02027ac436f2265/astrobase/checkplot/pkl.py#L1527-L1689 | def checkplot_pickle_update(
currentcp,
updatedcp,
outfile=None,
outgzip=False,
pickleprotocol=None,
verbose=True
):
'''This updates the current checkplotdict with updated values provided.
Parameters
----------
currentcp : dict or str
This is ei... | [
"def",
"checkplot_pickle_update",
"(",
"currentcp",
",",
"updatedcp",
",",
"outfile",
"=",
"None",
",",
"outgzip",
"=",
"False",
",",
"pickleprotocol",
"=",
"None",
",",
"verbose",
"=",
"True",
")",
":",
"# break out python 2.7 and > 3 nonsense",
"if",
"sys",
".... | This updates the current checkplotdict with updated values provided.
Parameters
----------
currentcp : dict or str
This is either a checkplotdict produced by `checkplot_pickle` above or a
checkplot pickle file produced by the same function. This checkplot will
be updated from the ... | [
"This",
"updates",
"the",
"current",
"checkplotdict",
"with",
"updated",
"values",
"provided",
"."
] | python | valid |
Zsailer/kubeconf | kubeconf/kubeconf.py | https://github.com/Zsailer/kubeconf/blob/b4e81001b5d2fb8d461056f25eb8b03307d57a6b/kubeconf/kubeconf.py#L259-L265 | def remove_from_user(self, name, *args):
"""Remove attributes from a user.
"""
user = self.get_user(name=name)
attrs_ = user['user']
for a in args:
del attrs_[a] | [
"def",
"remove_from_user",
"(",
"self",
",",
"name",
",",
"*",
"args",
")",
":",
"user",
"=",
"self",
".",
"get_user",
"(",
"name",
"=",
"name",
")",
"attrs_",
"=",
"user",
"[",
"'user'",
"]",
"for",
"a",
"in",
"args",
":",
"del",
"attrs_",
"[",
... | Remove attributes from a user. | [
"Remove",
"attributes",
"from",
"a",
"user",
"."
] | python | train |
hobson/pug-invest | pug/invest/models.py | https://github.com/hobson/pug-invest/blob/836911258a0e920083a88c91beae88eefdebb20c/pug/invest/models.py#L37-L76 | def get_dataframes(symbols=("sne", "goog", "tsla"), source='yahoo', refresh=False):
"""Retreive table of market data ("Close", "Volume", "Adj Close") for each symbol requested
>>> dfdict = get_dataframes('GOOG', 'SNE')
"""
symbols = util.make_symbols(list(symbols))
if refresh:
symbols_to_re... | [
"def",
"get_dataframes",
"(",
"symbols",
"=",
"(",
"\"sne\"",
",",
"\"goog\"",
",",
"\"tsla\"",
")",
",",
"source",
"=",
"'yahoo'",
",",
"refresh",
"=",
"False",
")",
":",
"symbols",
"=",
"util",
".",
"make_symbols",
"(",
"list",
"(",
"symbols",
")",
"... | Retreive table of market data ("Close", "Volume", "Adj Close") for each symbol requested
>>> dfdict = get_dataframes('GOOG', 'SNE') | [
"Retreive",
"table",
"of",
"market",
"data",
"(",
"Close",
"Volume",
"Adj",
"Close",
")",
"for",
"each",
"symbol",
"requested"
] | python | train |
CalebBell/thermo | thermo/mixture.py | https://github.com/CalebBell/thermo/blob/3857ed023a3e64fd3039a32d53576c24990ef1c3/thermo/mixture.py#L2230-L2244 | def sigma(self):
r'''Surface tension of the mixture at its current temperature and
composition, in units of [N/m].
For calculation of this property at other temperatures,
or specifying manually the method used to calculate it, and more - see
the object oriented interface :obj:`t... | [
"def",
"sigma",
"(",
"self",
")",
":",
"return",
"self",
".",
"SurfaceTensionMixture",
"(",
"self",
".",
"T",
",",
"self",
".",
"P",
",",
"self",
".",
"zs",
",",
"self",
".",
"ws",
")"
] | r'''Surface tension of the mixture at its current temperature and
composition, in units of [N/m].
For calculation of this property at other temperatures,
or specifying manually the method used to calculate it, and more - see
the object oriented interface :obj:`thermo.interface.SurfaceTe... | [
"r",
"Surface",
"tension",
"of",
"the",
"mixture",
"at",
"its",
"current",
"temperature",
"and",
"composition",
"in",
"units",
"of",
"[",
"N",
"/",
"m",
"]",
"."
] | python | valid |
DataBiosphere/toil | src/toil/jobStores/aws/jobStore.py | https://github.com/DataBiosphere/toil/blob/a8252277ff814e7bee0971139c2344f88e44b644/src/toil/jobStores/aws/jobStore.py#L746-L779 | def _bindDomain(self, domain_name, create=False, block=True):
"""
Return the Boto Domain object representing the SDB domain of the given name. If the
domain does not exist and `create` is True, it will be created.
:param str domain_name: the name of the domain to bind to
:param... | [
"def",
"_bindDomain",
"(",
"self",
",",
"domain_name",
",",
"create",
"=",
"False",
",",
"block",
"=",
"True",
")",
":",
"log",
".",
"debug",
"(",
"\"Binding to job store domain '%s'.\"",
",",
"domain_name",
")",
"retryargs",
"=",
"dict",
"(",
"predicate",
"... | Return the Boto Domain object representing the SDB domain of the given name. If the
domain does not exist and `create` is True, it will be created.
:param str domain_name: the name of the domain to bind to
:param bool create: True if domain should be created if it doesn't exist
:param... | [
"Return",
"the",
"Boto",
"Domain",
"object",
"representing",
"the",
"SDB",
"domain",
"of",
"the",
"given",
"name",
".",
"If",
"the",
"domain",
"does",
"not",
"exist",
"and",
"create",
"is",
"True",
"it",
"will",
"be",
"created",
"."
] | python | train |
mitsei/dlkit | dlkit/handcar/osid/queries.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/osid/queries.py#L71-L75 | def _add_match(self, match_key, match_value):
"""Adds a match key/value"""
if match_key is None:
raise errors.NullArgument()
self._query_terms[match_key] = str(match_key) + '=' + str(match_value) | [
"def",
"_add_match",
"(",
"self",
",",
"match_key",
",",
"match_value",
")",
":",
"if",
"match_key",
"is",
"None",
":",
"raise",
"errors",
".",
"NullArgument",
"(",
")",
"self",
".",
"_query_terms",
"[",
"match_key",
"]",
"=",
"str",
"(",
"match_key",
")... | Adds a match key/value | [
"Adds",
"a",
"match",
"key",
"/",
"value"
] | python | train |
kronenthaler/mod-pbxproj | pbxproj/pbxextensions/ProjectFlags.py | https://github.com/kronenthaler/mod-pbxproj/blob/8de3cbdd3210480ddbb1fa0f50a4f4ea87de6e71/pbxproj/pbxextensions/ProjectFlags.py#L79-L87 | def remove_other_ldflags(self, flags, target_name=None, configuration_name=None):
"""
Removes the given flags from the OTHER_LDFLAGS section of the target on the configurations
:param flags: A string or array of strings. If none, removes all values from the flag.
:param target_name: Targ... | [
"def",
"remove_other_ldflags",
"(",
"self",
",",
"flags",
",",
"target_name",
"=",
"None",
",",
"configuration_name",
"=",
"None",
")",
":",
"self",
".",
"remove_flags",
"(",
"XCBuildConfigurationFlags",
".",
"OTHER_LDFLAGS",
",",
"flags",
",",
"target_name",
",... | Removes the given flags from the OTHER_LDFLAGS section of the target on the configurations
:param flags: A string or array of strings. If none, removes all values from the flag.
:param target_name: Target name or list of target names to remove the flag from or None for every target
:param config... | [
"Removes",
"the",
"given",
"flags",
"from",
"the",
"OTHER_LDFLAGS",
"section",
"of",
"the",
"target",
"on",
"the",
"configurations",
":",
"param",
"flags",
":",
"A",
"string",
"or",
"array",
"of",
"strings",
".",
"If",
"none",
"removes",
"all",
"values",
"... | python | train |
adamrehn/ue4cli | ue4cli/CachedDataManager.py | https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/CachedDataManager.py#L27-L32 | def setCachedDataKey(engineVersionHash, key, value):
"""
Sets the cached data value for the specified engine version hash and dictionary key
"""
cacheFile = CachedDataManager._cacheFileForHash(engineVersionHash)
return JsonDataManager(cacheFile).setKey(key, value) | [
"def",
"setCachedDataKey",
"(",
"engineVersionHash",
",",
"key",
",",
"value",
")",
":",
"cacheFile",
"=",
"CachedDataManager",
".",
"_cacheFileForHash",
"(",
"engineVersionHash",
")",
"return",
"JsonDataManager",
"(",
"cacheFile",
")",
".",
"setKey",
"(",
"key",
... | Sets the cached data value for the specified engine version hash and dictionary key | [
"Sets",
"the",
"cached",
"data",
"value",
"for",
"the",
"specified",
"engine",
"version",
"hash",
"and",
"dictionary",
"key"
] | python | train |
apache/incubator-heron | heron/tools/tracker/src/python/handlers/basehandler.py | https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/heron/tools/tracker/src/python/handlers/basehandler.py#L107-L116 | def make_error_response(self, message):
"""
Makes the python dict corresponding to the
JSON that needs to be sent for a failed
response. Message is the message that is
sent as the reason for failure.
"""
response = self.make_response(constants.RESPONSE_STATUS_FAILURE)
response[constants.... | [
"def",
"make_error_response",
"(",
"self",
",",
"message",
")",
":",
"response",
"=",
"self",
".",
"make_response",
"(",
"constants",
".",
"RESPONSE_STATUS_FAILURE",
")",
"response",
"[",
"constants",
".",
"RESPONSE_KEY_MESSAGE",
"]",
"=",
"message",
"return",
"... | Makes the python dict corresponding to the
JSON that needs to be sent for a failed
response. Message is the message that is
sent as the reason for failure. | [
"Makes",
"the",
"python",
"dict",
"corresponding",
"to",
"the",
"JSON",
"that",
"needs",
"to",
"be",
"sent",
"for",
"a",
"failed",
"response",
".",
"Message",
"is",
"the",
"message",
"that",
"is",
"sent",
"as",
"the",
"reason",
"for",
"failure",
"."
] | python | valid |
apache/spark | python/pyspark/sql/functions.py | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L580-L595 | def rand(seed=None):
"""Generates a random column with independent and identically distributed (i.i.d.) samples
from U[0.0, 1.0].
.. note:: The function is non-deterministic in general case.
>>> df.withColumn('rand', rand(seed=42) * 3).collect()
[Row(age=2, name=u'Alice', rand=2.4052597283576684),... | [
"def",
"rand",
"(",
"seed",
"=",
"None",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"if",
"seed",
"is",
"not",
"None",
":",
"jc",
"=",
"sc",
".",
"_jvm",
".",
"functions",
".",
"rand",
"(",
"seed",
")",
"else",
":",
"jc",
"=... | Generates a random column with independent and identically distributed (i.i.d.) samples
from U[0.0, 1.0].
.. note:: The function is non-deterministic in general case.
>>> df.withColumn('rand', rand(seed=42) * 3).collect()
[Row(age=2, name=u'Alice', rand=2.4052597283576684),
Row(age=5, name=u'Bob'... | [
"Generates",
"a",
"random",
"column",
"with",
"independent",
"and",
"identically",
"distributed",
"(",
"i",
".",
"i",
".",
"d",
".",
")",
"samples",
"from",
"U",
"[",
"0",
".",
"0",
"1",
".",
"0",
"]",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.