repo stringlengths 7 55 | path stringlengths 4 223 | url stringlengths 87 315 | code stringlengths 75 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values | avg_line_len float64 7.91 980 |
|---|---|---|---|---|---|---|---|---|---|
numenta/nupic | src/nupic/frameworks/opf/prediction_metrics_manager.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/prediction_metrics_manager.py#L177-L194 | def getMetricDetails(self, metricLabel):
"""
Gets detailed info about a given metric, in addition to its value. This
may including any statistics or auxilary data that are computed for a given
metric.
:param metricLabel: (string) label of the given metric (see
:class:`~nupic.frameworks... | [
"def",
"getMetricDetails",
"(",
"self",
",",
"metricLabel",
")",
":",
"try",
":",
"metricIndex",
"=",
"self",
".",
"__metricLabels",
".",
"index",
"(",
"metricLabel",
")",
"except",
"IndexError",
":",
"return",
"None",
"return",
"self",
".",
"__metrics",
"["... | Gets detailed info about a given metric, in addition to its value. This
may including any statistics or auxilary data that are computed for a given
metric.
:param metricLabel: (string) label of the given metric (see
:class:`~nupic.frameworks.opf.metrics.MetricSpec`)
:returns: (dict) of met... | [
"Gets",
"detailed",
"info",
"about",
"a",
"given",
"metric",
"in",
"addition",
"to",
"its",
"value",
".",
"This",
"may",
"including",
"any",
"statistics",
"or",
"auxilary",
"data",
"that",
"are",
"computed",
"for",
"a",
"given",
"metric",
"."
] | python | valid | 35.111111 |
pyapi-gitlab/pyapi-gitlab | gitlab/__init__.py | https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/__init__.py#L1433-L1443 | def delete_repository_tag(self, project_id, tag_name):
"""
Deletes a tag of a repository with given name.
:param project_id: The ID of a project
:param tag_name: The name of a tag
:return: Dictionary containing delete tag
:raise: HttpError: If invalid response returned
... | [
"def",
"delete_repository_tag",
"(",
"self",
",",
"project_id",
",",
"tag_name",
")",
":",
"return",
"self",
".",
"delete",
"(",
"'/projects/{project_id}/repository/tags/{tag_name}'",
".",
"format",
"(",
"project_id",
"=",
"project_id",
",",
"tag_name",
"=",
"tag_na... | Deletes a tag of a repository with given name.
:param project_id: The ID of a project
:param tag_name: The name of a tag
:return: Dictionary containing delete tag
:raise: HttpError: If invalid response returned | [
"Deletes",
"a",
"tag",
"of",
"a",
"repository",
"with",
"given",
"name",
"."
] | python | train | 42 |
aiogram/aiogram | aiogram/bot/bot.py | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/bot/bot.py#L2083-L2115 | async def get_game_high_scores(self, user_id: base.Integer,
chat_id: typing.Union[base.Integer, None] = None,
message_id: typing.Union[base.Integer, None] = None,
inline_message_id: typing.Union[base.String,
... | [
"async",
"def",
"get_game_high_scores",
"(",
"self",
",",
"user_id",
":",
"base",
".",
"Integer",
",",
"chat_id",
":",
"typing",
".",
"Union",
"[",
"base",
".",
"Integer",
",",
"None",
"]",
"=",
"None",
",",
"message_id",
":",
"typing",
".",
"Union",
"... | Use this method to get data for high score tables.
This method will currently return scores for the target user, plus two of his closest neighbors on each side.
Will also return the top three users if the user and his neighbors are not among them.
Please note that this behavior is subject to ch... | [
"Use",
"this",
"method",
"to",
"get",
"data",
"for",
"high",
"score",
"tables",
"."
] | python | train | 64 |
econ-ark/HARK | HARK/ConsumptionSaving/ConsMedModel.py | https://github.com/econ-ark/HARK/blob/3d184153a189e618a87c9540df1cd12044039cc5/HARK/ConsumptionSaving/ConsMedModel.py#L857-L875 | def defUtilityFuncs(self):
'''
Defines CRRA utility function for this period (and its derivatives,
and their inverses), saving them as attributes of self for other methods
to use. Extends version from ConsIndShock models by also defining inverse
marginal utility function over me... | [
"def",
"defUtilityFuncs",
"(",
"self",
")",
":",
"ConsGenIncProcessSolver",
".",
"defUtilityFuncs",
"(",
"self",
")",
"# Do basic version",
"self",
".",
"uMedPinv",
"=",
"lambda",
"Med",
":",
"utilityP_inv",
"(",
"Med",
",",
"gam",
"=",
"self",
".",
"CRRAmed",... | Defines CRRA utility function for this period (and its derivatives,
and their inverses), saving them as attributes of self for other methods
to use. Extends version from ConsIndShock models by also defining inverse
marginal utility function over medical care.
Parameters
-------... | [
"Defines",
"CRRA",
"utility",
"function",
"for",
"this",
"period",
"(",
"and",
"its",
"derivatives",
"and",
"their",
"inverses",
")",
"saving",
"them",
"as",
"attributes",
"of",
"self",
"for",
"other",
"methods",
"to",
"use",
".",
"Extends",
"version",
"from... | python | train | 37.052632 |
aras7/deployr-python-client | deployr_connection.py | https://github.com/aras7/deployr-python-client/blob/3ca517ff38e9a7dd1e21fcc88d54537546b9e7e5/deployr_connection.py#L28-L55 | def login(self, username, password, disableautosave=True, print_response=True):
"""
:param username:
:param password:
:param disableautosave: boolean
:param print_response: print log if required
:return: status code, response data
"""
if type(username) != ... | [
"def",
"login",
"(",
"self",
",",
"username",
",",
"password",
",",
"disableautosave",
"=",
"True",
",",
"print_response",
"=",
"True",
")",
":",
"if",
"type",
"(",
"username",
")",
"!=",
"str",
":",
"return",
"False",
",",
"\"Username must be string\"",
"... | :param username:
:param password:
:param disableautosave: boolean
:param print_response: print log if required
:return: status code, response data | [
":",
"param",
"username",
":",
":",
"param",
"password",
":",
":",
"param",
"disableautosave",
":",
"boolean",
":",
"param",
"print_response",
":",
"print",
"log",
"if",
"required",
":",
"return",
":",
"status",
"code",
"response",
"data"
] | python | train | 38.535714 |
pinterest/pymemcache | pymemcache/client/base.py | https://github.com/pinterest/pymemcache/blob/f3a348f4ce2248cce8b398e93e08d984fb9100e5/pymemcache/client/base.py#L471-L485 | def gets(self, key, default=None, cas_default=None):
"""
The memcached "gets" command for one key, as a convenience.
Args:
key: str, see class docs for details.
default: value that will be returned if the key was not found.
cas_default: same behaviour as default ar... | [
"def",
"gets",
"(",
"self",
",",
"key",
",",
"default",
"=",
"None",
",",
"cas_default",
"=",
"None",
")",
":",
"defaults",
"=",
"(",
"default",
",",
"cas_default",
")",
"return",
"self",
".",
"_fetch_cmd",
"(",
"b'gets'",
",",
"[",
"key",
"]",
",",
... | The memcached "gets" command for one key, as a convenience.
Args:
key: str, see class docs for details.
default: value that will be returned if the key was not found.
cas_default: same behaviour as default argument.
Returns:
A tuple of (value, cas)
or ... | [
"The",
"memcached",
"gets",
"command",
"for",
"one",
"key",
"as",
"a",
"convenience",
"."
] | python | train | 36.933333 |
cloud-custodian/cloud-custodian | tools/sandbox/c7n_autodoc/c7n-autodoc.py | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_autodoc/c7n-autodoc.py#L68-L73 | def get_file_url(path, config):
""" Update this function to help build the link to your file
"""
file_url_regex = re.compile(config['file_url_regex'])
new_path = re.sub(file_url_regex, config['file_url_base'], path)
return new_path | [
"def",
"get_file_url",
"(",
"path",
",",
"config",
")",
":",
"file_url_regex",
"=",
"re",
".",
"compile",
"(",
"config",
"[",
"'file_url_regex'",
"]",
")",
"new_path",
"=",
"re",
".",
"sub",
"(",
"file_url_regex",
",",
"config",
"[",
"'file_url_base'",
"]"... | Update this function to help build the link to your file | [
"Update",
"this",
"function",
"to",
"help",
"build",
"the",
"link",
"to",
"your",
"file"
] | python | train | 41 |
ff0000/scarlet | scarlet/assets/models.py | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/assets/models.py#L174-L182 | def delete(self, *args, **kwargs):
"""
Deletes the actual file from storage after the object is deleted.
Calls super to actually delete the object.
"""
file_obj = self.file
super(AssetBase, self).delete(*args, **kwargs)
self.delete_real_file(file_obj) | [
"def",
"delete",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"file_obj",
"=",
"self",
".",
"file",
"super",
"(",
"AssetBase",
",",
"self",
")",
".",
"delete",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"d... | Deletes the actual file from storage after the object is deleted.
Calls super to actually delete the object. | [
"Deletes",
"the",
"actual",
"file",
"from",
"storage",
"after",
"the",
"object",
"is",
"deleted",
"."
] | python | train | 33.333333 |
CiscoDevNet/webexteamssdk | webexteamssdk/api/rooms.py | https://github.com/CiscoDevNet/webexteamssdk/blob/6fc2cc3557e080ba4b2a380664cb2a0532ae45cd/webexteamssdk/api/rooms.py#L224-L238 | def delete(self, roomId):
"""Delete a room.
Args:
roomId(basestring): The ID of the room to be deleted.
Raises:
TypeError: If the parameter types are incorrect.
ApiError: If the Webex Teams cloud returns an error.
"""
check_type(roomId, base... | [
"def",
"delete",
"(",
"self",
",",
"roomId",
")",
":",
"check_type",
"(",
"roomId",
",",
"basestring",
",",
"may_be_none",
"=",
"False",
")",
"# API request",
"self",
".",
"_session",
".",
"delete",
"(",
"API_ENDPOINT",
"+",
"'/'",
"+",
"roomId",
")"
] | Delete a room.
Args:
roomId(basestring): The ID of the room to be deleted.
Raises:
TypeError: If the parameter types are incorrect.
ApiError: If the Webex Teams cloud returns an error. | [
"Delete",
"a",
"room",
"."
] | python | test | 27.533333 |
SpectoLabs/hoverpy | hoverpy/hp.py | https://github.com/SpectoLabs/hoverpy/blob/e153ec57f80634019d827d378f184c01fedc5a0e/hoverpy/hp.py#L212-L220 | def delays(self, delays=[]):
"""
Gets / Sets the delays.
"""
if delays:
return self._session.put(
self.__v1() + "/delays", data=json.dumps(delays)).json()
else:
return self._session.get(self.__v1() + "/delays").json() | [
"def",
"delays",
"(",
"self",
",",
"delays",
"=",
"[",
"]",
")",
":",
"if",
"delays",
":",
"return",
"self",
".",
"_session",
".",
"put",
"(",
"self",
".",
"__v1",
"(",
")",
"+",
"\"/delays\"",
",",
"data",
"=",
"json",
".",
"dumps",
"(",
"delays... | Gets / Sets the delays. | [
"Gets",
"/",
"Sets",
"the",
"delays",
"."
] | python | train | 32.222222 |
edx/i18n-tools | i18n/execute.py | https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/execute.py#L13-L21 | def execute(command, working_directory=config.BASE_DIR, stderr=sp.STDOUT):
"""
Executes shell command in a given working_directory.
Command is a string to pass to the shell.
Output is ignored.
"""
LOG.info("Executing in %s ...", working_directory)
LOG.info(command)
sp.check_call(command,... | [
"def",
"execute",
"(",
"command",
",",
"working_directory",
"=",
"config",
".",
"BASE_DIR",
",",
"stderr",
"=",
"sp",
".",
"STDOUT",
")",
":",
"LOG",
".",
"info",
"(",
"\"Executing in %s ...\"",
",",
"working_directory",
")",
"LOG",
".",
"info",
"(",
"comm... | Executes shell command in a given working_directory.
Command is a string to pass to the shell.
Output is ignored. | [
"Executes",
"shell",
"command",
"in",
"a",
"given",
"working_directory",
".",
"Command",
"is",
"a",
"string",
"to",
"pass",
"to",
"the",
"shell",
".",
"Output",
"is",
"ignored",
"."
] | python | train | 40.222222 |
google/brotli | research/brotlidump.py | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L1458-L1575 | def readComplexCode(self, hskip, alphabet):
"""Read complex code"""
stream = self.stream
#read the lengths for the length code
lengths = [1,2,3,4,0,5,17,6,16,7,8,9,10,11,12,13,14,15][hskip:]
codeLengths = {}
total = 0
lol = LengthOfLengthAlphabet('##'+alphabet.nam... | [
"def",
"readComplexCode",
"(",
"self",
",",
"hskip",
",",
"alphabet",
")",
":",
"stream",
"=",
"self",
".",
"stream",
"#read the lengths for the length code",
"lengths",
"=",
"[",
"1",
",",
"2",
",",
"3",
",",
"4",
",",
"0",
",",
"5",
",",
"17",
",",
... | Read complex code | [
"Read",
"complex",
"code"
] | python | test | 46.338983 |
DLR-RM/RAFCON | source/rafcon/gui/controllers/preferences_window.py | https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/controllers/preferences_window.py#L195-L199 | def update_path_labels(self):
"""Update labels showing config paths
"""
self.view['core_label'].set_text("Core Config Path: " + str(self.core_config_model.config.config_file_path))
self.view['gui_label'].set_text("GUI Config Path: " + str(self.gui_config_model.config.config_file_path)) | [
"def",
"update_path_labels",
"(",
"self",
")",
":",
"self",
".",
"view",
"[",
"'core_label'",
"]",
".",
"set_text",
"(",
"\"Core Config Path: \"",
"+",
"str",
"(",
"self",
".",
"core_config_model",
".",
"config",
".",
"config_file_path",
")",
")",
"self",
".... | Update labels showing config paths | [
"Update",
"labels",
"showing",
"config",
"paths"
] | python | train | 62.8 |
divio/aldryn-apphooks-config | aldryn_apphooks_config/utils.py | https://github.com/divio/aldryn-apphooks-config/blob/5b8dfc7516982a8746fc08cf919c6ab116335d62/aldryn_apphooks_config/utils.py#L88-L96 | def get_apphook_configs(obj):
"""
Get apphook configs for an object obj
:param obj: any model instance
:return: list of apphook configs for given obj
"""
keys = get_apphook_field_names(obj)
return [getattr(obj, key) for key in keys] if keys else [] | [
"def",
"get_apphook_configs",
"(",
"obj",
")",
":",
"keys",
"=",
"get_apphook_field_names",
"(",
"obj",
")",
"return",
"[",
"getattr",
"(",
"obj",
",",
"key",
")",
"for",
"key",
"in",
"keys",
"]",
"if",
"keys",
"else",
"[",
"]"
] | Get apphook configs for an object obj
:param obj: any model instance
:return: list of apphook configs for given obj | [
"Get",
"apphook",
"configs",
"for",
"an",
"object",
"obj"
] | python | train | 29.888889 |
jelmer/python-fastimport | fastimport/helpers.py | https://github.com/jelmer/python-fastimport/blob/5cef9e037b7d7b37f58f522ac9ea4e343e6a1dff/fastimport/helpers.py#L40-L66 | def common_directory(paths):
"""Find the deepest common directory of a list of paths.
:return: if no paths are provided, None is returned;
if there is no common directory, '' is returned;
otherwise the common directory with a trailing / is returned.
"""
import posixpath
def get_dir_with... | [
"def",
"common_directory",
"(",
"paths",
")",
":",
"import",
"posixpath",
"def",
"get_dir_with_slash",
"(",
"path",
")",
":",
"if",
"path",
"==",
"b''",
"or",
"path",
".",
"endswith",
"(",
"b'/'",
")",
":",
"return",
"path",
"else",
":",
"dirname",
",",
... | Find the deepest common directory of a list of paths.
:return: if no paths are provided, None is returned;
if there is no common directory, '' is returned;
otherwise the common directory with a trailing / is returned. | [
"Find",
"the",
"deepest",
"common",
"directory",
"of",
"a",
"list",
"of",
"paths",
"."
] | python | train | 31.555556 |
acorg/dark-matter | dark/summarize.py | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/summarize.py#L7-L38 | def summarizeReads(file_handle, file_type):
"""
open a fasta or fastq file, prints number of of reads,
average length of read, total number of bases, longest,
shortest and median read, total number and average of
individual base (A, T, G, C, N).
"""
base_counts = defaultdict(int)
read_nu... | [
"def",
"summarizeReads",
"(",
"file_handle",
",",
"file_type",
")",
":",
"base_counts",
"=",
"defaultdict",
"(",
"int",
")",
"read_number",
"=",
"0",
"total_length",
"=",
"0",
"length_list",
"=",
"[",
"]",
"records",
"=",
"SeqIO",
".",
"parse",
"(",
"file_... | open a fasta or fastq file, prints number of of reads,
average length of read, total number of bases, longest,
shortest and median read, total number and average of
individual base (A, T, G, C, N). | [
"open",
"a",
"fasta",
"or",
"fastq",
"file",
"prints",
"number",
"of",
"of",
"reads",
"average",
"length",
"of",
"read",
"total",
"number",
"of",
"bases",
"longest",
"shortest",
"and",
"median",
"read",
"total",
"number",
"and",
"average",
"of",
"individual"... | python | train | 31.375 |
bitesofcode/projex | projex/enum.py | https://github.com/bitesofcode/projex/blob/d31743ec456a41428709968ab11a2cf6c6c76247/projex/enum.py#L162-L187 | def extend(self, base, key, value=None):
"""
Adds a new definition to this enumerated type, extending the given
base type. This will create a new key for the type and register
it as a new viable option from the system, however, it will also
register its base information so you c... | [
"def",
"extend",
"(",
"self",
",",
"base",
",",
"key",
",",
"value",
"=",
"None",
")",
":",
"new_val",
"=",
"self",
".",
"add",
"(",
"key",
",",
"value",
")",
"self",
".",
"_bases",
"[",
"new_val",
"]",
"=",
"base"
] | Adds a new definition to this enumerated type, extending the given
base type. This will create a new key for the type and register
it as a new viable option from the system, however, it will also
register its base information so you can use enum.base to retrieve
the root type.
... | [
"Adds",
"a",
"new",
"definition",
"to",
"this",
"enumerated",
"type",
"extending",
"the",
"given",
"base",
"type",
".",
"This",
"will",
"create",
"a",
"new",
"key",
"for",
"the",
"type",
"and",
"register",
"it",
"as",
"a",
"new",
"viable",
"option",
"fro... | python | train | 42.807692 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/core/rest.py | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/core/rest.py#L21-L92 | def create_requests_session(
retries=None,
backoff_factor=None,
status_forcelist=None,
pools_size=4,
maxsize=4,
ssl_verify=None,
ssl_cert=None,
proxy=None,
session=None,
):
"""Create a requests session that retries some errors."""
# pylint: disable=too-many-branches
confi... | [
"def",
"create_requests_session",
"(",
"retries",
"=",
"None",
",",
"backoff_factor",
"=",
"None",
",",
"status_forcelist",
"=",
"None",
",",
"pools_size",
"=",
"4",
",",
"maxsize",
"=",
"4",
",",
"ssl_verify",
"=",
"None",
",",
"ssl_cert",
"=",
"None",
",... | Create a requests session that retries some errors. | [
"Create",
"a",
"requests",
"session",
"that",
"retries",
"some",
"errors",
"."
] | python | train | 24.75 |
aiidateam/aiida-codtools | aiida_codtools/parsers/cif_base.py | https://github.com/aiidateam/aiida-codtools/blob/da5e4259b7a2e86cf0cc3f997e11dd36d445fa94/aiida_codtools/parsers/cif_base.py#L28-L57 | def parse(self, **kwargs):
"""Parse the contents of the output files retrieved in the `FolderData`."""
try:
output_folder = self.retrieved
except exceptions.NotExistent:
return self.exit_codes.ERROR_NO_RETRIEVED_FOLDER
filename_stdout = self.node.get_attribute('o... | [
"def",
"parse",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"output_folder",
"=",
"self",
".",
"retrieved",
"except",
"exceptions",
".",
"NotExistent",
":",
"return",
"self",
".",
"exit_codes",
".",
"ERROR_NO_RETRIEVED_FOLDER",
"filename_stdout... | Parse the contents of the output files retrieved in the `FolderData`. | [
"Parse",
"the",
"contents",
"of",
"the",
"output",
"files",
"retrieved",
"in",
"the",
"FolderData",
"."
] | python | train | 38.9 |
farshidce/touchworks-python | touchworks/api/http.py | https://github.com/farshidce/touchworks-python/blob/ea8f93a0f4273de1317a318e945a571f5038ba62/touchworks/api/http.py#L650-L707 | def save_message_from_pat_portal(self, patient_id,
p_vendor_name,
p_message_id,
p_practice_id,
message,
sent_date,
... | [
"def",
"save_message_from_pat_portal",
"(",
"self",
",",
"patient_id",
",",
"p_vendor_name",
",",
"p_message_id",
",",
"p_practice_id",
",",
"message",
",",
"sent_date",
",",
"transaction_type",
")",
":",
"portal_info_xml",
"=",
"'<msg>'",
"+",
"'<ppvendor value=\"@@V... | invokes TouchWorksMagicConstants.ACTION_GET_ENCOUNTER_LIST_FOR_PATIENT action
:param
:param message
:param sent_date
:param transaction_type - type To register a patient with the portal,
this should be 'Register Patient Request.'
Valid types are stored in iH... | [
"invokes",
"TouchWorksMagicConstants",
".",
"ACTION_GET_ENCOUNTER_LIST_FOR_PATIENT",
"action",
":",
"param",
":",
"param",
"message",
":",
"param",
"sent_date",
":",
"param",
"transaction_type",
"-",
"type",
"To",
"register",
"a",
"patient",
"with",
"the",
"portal",
... | python | train | 40.982759 |
nerdvegas/rez | src/rez/build_system.py | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/build_system.py#L14-L62 | def get_valid_build_systems(working_dir, package=None):
"""Returns the build system classes that could build the source in given dir.
Args:
working_dir (str): Dir containing the package definition and potentially
build files.
package (`Package`): Package to be built. This may or may... | [
"def",
"get_valid_build_systems",
"(",
"working_dir",
",",
"package",
"=",
"None",
")",
":",
"from",
"rez",
".",
"plugin_managers",
"import",
"plugin_manager",
"from",
"rez",
".",
"exceptions",
"import",
"PackageMetadataError",
"try",
":",
"package",
"=",
"package... | Returns the build system classes that could build the source in given dir.
Args:
working_dir (str): Dir containing the package definition and potentially
build files.
package (`Package`): Package to be built. This may or may not be needed
to determine the build system. For e... | [
"Returns",
"the",
"build",
"system",
"classes",
"that",
"could",
"build",
"the",
"source",
"in",
"given",
"dir",
"."
] | python | train | 37.469388 |
MJL85/natlas | natlas/network.py | https://github.com/MJL85/natlas/blob/5e7ae3cc7b5dd7ad884fa2b8b93bbdd9275474c4/natlas/network.py#L329-L430 | def __discover_node(self, node, depth):
'''
Given a node, recursively enumerate its adjacencies
until we reach the specified depth (>0).
Args:
node: natlas_node object to enumerate.
depth: The depth left that we can go further away from the root.
'''
... | [
"def",
"__discover_node",
"(",
"self",
",",
"node",
",",
"depth",
")",
":",
"if",
"(",
"node",
"==",
"None",
")",
":",
"return",
"if",
"(",
"depth",
">=",
"self",
".",
"max_depth",
")",
":",
"return",
"if",
"(",
"node",
".",
"discovered",
">",
"0",... | Given a node, recursively enumerate its adjacencies
until we reach the specified depth (>0).
Args:
node: natlas_node object to enumerate.
depth: The depth left that we can go further away from the root. | [
"Given",
"a",
"node",
"recursively",
"enumerate",
"its",
"adjacencies",
"until",
"we",
"reach",
"the",
"specified",
"depth",
"(",
">",
"0",
")",
"."
] | python | train | 36.27451 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/cli/commands/resync.py | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/commands/resync.py#L27-L69 | def resync(
ctx,
opts,
owner_repo_package,
skip_errors,
wait_interval,
no_wait_for_sync,
sync_attempts,
):
"""
Resynchronise a package in a repository.
This requires appropriate permissions for package.
- OWNER/REPO/PACKAGE: Specify the OWNER namespace (i.e. user or org), t... | [
"def",
"resync",
"(",
"ctx",
",",
"opts",
",",
"owner_repo_package",
",",
"skip_errors",
",",
"wait_interval",
",",
"no_wait_for_sync",
",",
"sync_attempts",
",",
")",
":",
"owner",
",",
"source",
",",
"slug",
"=",
"owner_repo_package",
"resync_package",
"(",
... | Resynchronise a package in a repository.
This requires appropriate permissions for package.
- OWNER/REPO/PACKAGE: Specify the OWNER namespace (i.e. user or org), the
REPO name where the package is stored, and the PACKAGE name (slug) of the
package itself. All separated by a slash.
Example: 'you... | [
"Resynchronise",
"a",
"package",
"in",
"a",
"repository",
"."
] | python | train | 22.837209 |
hyperledger/sawtooth-core | cli/sawtooth_cli/batch.py | https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/batch.py#L30-L50 | def add_batch_parser(subparsers, parent_parser):
"""Adds arguments parsers for the batch list, batch show and batch status
commands
Args:
subparsers: Add parsers to this subparser object
parent_parser: The parent argparse.ArgumentParser object
"""
parser = subparsers.add... | [
"def",
"add_batch_parser",
"(",
"subparsers",
",",
"parent_parser",
")",
":",
"parser",
"=",
"subparsers",
".",
"add_parser",
"(",
"'batch'",
",",
"help",
"=",
"'Displays information about batches and submit new batches'",
",",
"description",
"=",
"'Provides subcommands t... | Adds arguments parsers for the batch list, batch show and batch status
commands
Args:
subparsers: Add parsers to this subparser object
parent_parser: The parent argparse.ArgumentParser object | [
"Adds",
"arguments",
"parsers",
"for",
"the",
"batch",
"list",
"batch",
"show",
"and",
"batch",
"status",
"commands"
] | python | train | 44 |
aws/aws-encryption-sdk-python | src/aws_encryption_sdk/__init__.py | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/__init__.py#L29-L80 | def encrypt(**kwargs):
"""Encrypts and serializes provided plaintext.
.. note::
When using this function, the entire ciphertext message is encrypted into memory before returning
any data. If streaming is desired, see :class:`aws_encryption_sdk.stream`.
.. code:: python
>>> import... | [
"def",
"encrypt",
"(",
"*",
"*",
"kwargs",
")",
":",
"with",
"StreamEncryptor",
"(",
"*",
"*",
"kwargs",
")",
"as",
"encryptor",
":",
"ciphertext",
"=",
"encryptor",
".",
"read",
"(",
")",
"return",
"ciphertext",
",",
"encryptor",
".",
"header"
] | Encrypts and serializes provided plaintext.
.. note::
When using this function, the entire ciphertext message is encrypted into memory before returning
any data. If streaming is desired, see :class:`aws_encryption_sdk.stream`.
.. code:: python
>>> import aws_encryption_sdk
>>... | [
"Encrypts",
"and",
"serializes",
"provided",
"plaintext",
"."
] | python | train | 51.365385 |
mozilla-iot/webthing-python | webthing/thing.py | https://github.com/mozilla-iot/webthing-python/blob/65d467c89ed79d0bbc42b8b3c8f9e5a320edd237/webthing/thing.py#L171-L189 | def get_action_descriptions(self, action_name=None):
"""
Get the thing's actions as an array.
action_name -- Optional action name to get descriptions for
Returns the action descriptions.
"""
descriptions = []
if action_name is None:
for name in self... | [
"def",
"get_action_descriptions",
"(",
"self",
",",
"action_name",
"=",
"None",
")",
":",
"descriptions",
"=",
"[",
"]",
"if",
"action_name",
"is",
"None",
":",
"for",
"name",
"in",
"self",
".",
"actions",
":",
"for",
"action",
"in",
"self",
".",
"action... | Get the thing's actions as an array.
action_name -- Optional action name to get descriptions for
Returns the action descriptions. | [
"Get",
"the",
"thing",
"s",
"actions",
"as",
"an",
"array",
"."
] | python | test | 32.894737 |
paylogic/pip-accel | pip_accel/config.py | https://github.com/paylogic/pip-accel/blob/ccad1b784927a322d996db593403b1d2d2e22666/pip_accel/config.py#L427-L448 | def s3_cache_readonly(self):
"""
Whether the Amazon S3 bucket is considered read only.
If this is :data:`True` then the Amazon S3 bucket will only be used for
:class:`~pip_accel.caches.s3.S3CacheBackend.get()` operations (all
:class:`~pip_accel.caches.s3.S3CacheBackend.put()` op... | [
"def",
"s3_cache_readonly",
"(",
"self",
")",
":",
"return",
"coerce_boolean",
"(",
"self",
".",
"get",
"(",
"property_name",
"=",
"'s3_cache_readonly'",
",",
"environment_variable",
"=",
"'PIP_ACCEL_S3_READONLY'",
",",
"configuration_option",
"=",
"'s3-readonly'",
",... | Whether the Amazon S3 bucket is considered read only.
If this is :data:`True` then the Amazon S3 bucket will only be used for
:class:`~pip_accel.caches.s3.S3CacheBackend.get()` operations (all
:class:`~pip_accel.caches.s3.S3CacheBackend.put()` operations will
be disabled).
- En... | [
"Whether",
"the",
"Amazon",
"S3",
"bucket",
"is",
"considered",
"read",
"only",
"."
] | python | train | 48.409091 |
PythonCharmers/python-future | src/future/backports/urllib/request.py | https://github.com/PythonCharmers/python-future/blob/c423752879acc05eebc29b0bb9909327bd5c7308/src/future/backports/urllib/request.py#L1705-L1708 | def open_unknown(self, fullurl, data=None):
"""Overridable interface to open unknown URL type."""
type, url = splittype(fullurl)
raise IOError('url error', 'unknown url type', type) | [
"def",
"open_unknown",
"(",
"self",
",",
"fullurl",
",",
"data",
"=",
"None",
")",
":",
"type",
",",
"url",
"=",
"splittype",
"(",
"fullurl",
")",
"raise",
"IOError",
"(",
"'url error'",
",",
"'unknown url type'",
",",
"type",
")"
] | Overridable interface to open unknown URL type. | [
"Overridable",
"interface",
"to",
"open",
"unknown",
"URL",
"type",
"."
] | python | train | 50.5 |
edx/edx-enterprise | enterprise/api/v1/mixins.py | https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api/v1/mixins.py#L70-L104 | def update_course_runs(self, course_runs, enterprise_customer, enterprise_context):
"""
Update Marketing urls in course metadata and return updated course.
Arguments:
course_runs (list): List of course runs.
enterprise_customer (EnterpriseCustomer): enterprise customer i... | [
"def",
"update_course_runs",
"(",
"self",
",",
"course_runs",
",",
"enterprise_customer",
",",
"enterprise_context",
")",
":",
"updated_course_runs",
"=",
"[",
"]",
"for",
"course_run",
"in",
"course_runs",
":",
"track_selection_url",
"=",
"utils",
".",
"get_course_... | Update Marketing urls in course metadata and return updated course.
Arguments:
course_runs (list): List of course runs.
enterprise_customer (EnterpriseCustomer): enterprise customer instance.
enterprise_context (dict): The context to inject into URLs.
Returns:
... | [
"Update",
"Marketing",
"urls",
"in",
"course",
"metadata",
"and",
"return",
"updated",
"course",
"."
] | python | valid | 45.428571 |
openfisca/openfisca-core | openfisca_core/simulations.py | https://github.com/openfisca/openfisca-core/blob/92ce9396e29ae5d9bac5ea604cfce88517c6b35c/openfisca_core/simulations.py#L436-L457 | def set_input(self, variable_name, period, value):
"""
Set a variable's value for a given period
:param variable: the variable to be set
:param value: the input value for the variable
:param period: the period for which the value is setted
Example:
... | [
"def",
"set_input",
"(",
"self",
",",
"variable_name",
",",
"period",
",",
"value",
")",
":",
"variable",
"=",
"self",
".",
"tax_benefit_system",
".",
"get_variable",
"(",
"variable_name",
",",
"check_existence",
"=",
"True",
")",
"period",
"=",
"periods",
"... | Set a variable's value for a given period
:param variable: the variable to be set
:param value: the input value for the variable
:param period: the period for which the value is setted
Example:
>>> from openfisca_country_template import CountryTaxBenefitSyst... | [
"Set",
"a",
"variable",
"s",
"value",
"for",
"a",
"given",
"period"
] | python | train | 58.909091 |
pantsbuild/pants | src/python/pants/util/dirutil.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/util/dirutil.py#L496-L510 | def recursive_dirname(f):
"""Given a relative path like 'a/b/c/d', yield all ascending path components like:
'a/b/c/d'
'a/b/c'
'a/b'
'a'
''
"""
prev = None
while f != prev:
yield f
prev = f
f = os.path.dirname(f)
yield '' | [
"def",
"recursive_dirname",
"(",
"f",
")",
":",
"prev",
"=",
"None",
"while",
"f",
"!=",
"prev",
":",
"yield",
"f",
"prev",
"=",
"f",
"f",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"f",
")",
"yield",
"''"
] | Given a relative path like 'a/b/c/d', yield all ascending path components like:
'a/b/c/d'
'a/b/c'
'a/b'
'a'
'' | [
"Given",
"a",
"relative",
"path",
"like",
"a",
"/",
"b",
"/",
"c",
"/",
"d",
"yield",
"all",
"ascending",
"path",
"components",
"like",
":"
] | python | train | 18 |
sprockets/sprockets.http | sprockets/http/__init__.py | https://github.com/sprockets/sprockets.http/blob/8baa4cdc1fa35a162ee226fd6cc4170a0ca0ecd3/sprockets/http/__init__.py#L10-L71 | def run(create_application, settings=None, log_config=None):
"""
Run a Tornado create_application.
:param create_application: function to call to create a new
application instance
:param dict|None settings: optional configuration dictionary
that will be passed through to ``create_applic... | [
"def",
"run",
"(",
"create_application",
",",
"settings",
"=",
"None",
",",
"log_config",
"=",
"None",
")",
":",
"from",
".",
"import",
"runner",
"app_settings",
"=",
"{",
"}",
"if",
"settings",
"is",
"None",
"else",
"settings",
".",
"copy",
"(",
")",
... | Run a Tornado create_application.
:param create_application: function to call to create a new
application instance
:param dict|None settings: optional configuration dictionary
that will be passed through to ``create_application``
as kwargs.
:param dict|None log_config: optional logg... | [
"Run",
"a",
"Tornado",
"create_application",
"."
] | python | train | 42.548387 |
samuelcolvin/pydantic | pydantic/utils.py | https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/utils.py#L49-L75 | def validate_email(value: str) -> Tuple[str, str]:
"""
Brutally simple email address validation. Note unlike most email address validation
* raw ip address (literal) domain parts are not allowed.
* "John Doe <local_part@domain.com>" style "pretty" email addresses are processed
* the local part check... | [
"def",
"validate_email",
"(",
"value",
":",
"str",
")",
"->",
"Tuple",
"[",
"str",
",",
"str",
"]",
":",
"if",
"email_validator",
"is",
"None",
":",
"raise",
"ImportError",
"(",
"'email-validator is not installed, run `pip install pydantic[email]`'",
")",
"m",
"="... | Brutally simple email address validation. Note unlike most email address validation
* raw ip address (literal) domain parts are not allowed.
* "John Doe <local_part@domain.com>" style "pretty" email addresses are processed
* the local part check is extremely basic. This raises the possibility of unicode spo... | [
"Brutally",
"simple",
"email",
"address",
"validation",
".",
"Note",
"unlike",
"most",
"email",
"address",
"validation",
"*",
"raw",
"ip",
"address",
"(",
"literal",
")",
"domain",
"parts",
"are",
"not",
"allowed",
".",
"*",
"John",
"Doe",
"<local_part@domain"... | python | train | 42.111111 |
JustinLovinger/optimal | optimal/algorithms/gaoperators.py | https://github.com/JustinLovinger/optimal/blob/ab48a4961697338cc32d50e3a6b06ac989e39c3f/optimal/algorithms/gaoperators.py#L212-L223 | def one_point_crossover(parents):
"""Perform one point crossover on two parent chromosomes.
Select a random position in the chromosome.
Take genes to the left from one parent and the rest from the other parent.
Ex. p1 = xxxxx, p2 = yyyyy, position = 2 (starting at 0), child = xxyyy
"""
# The po... | [
"def",
"one_point_crossover",
"(",
"parents",
")",
":",
"# The point that the chromosomes will be crossed at (see Ex. above)",
"crossover_point",
"=",
"random",
".",
"randint",
"(",
"1",
",",
"len",
"(",
"parents",
"[",
"0",
"]",
")",
"-",
"1",
")",
"return",
"(",... | Perform one point crossover on two parent chromosomes.
Select a random position in the chromosome.
Take genes to the left from one parent and the rest from the other parent.
Ex. p1 = xxxxx, p2 = yyyyy, position = 2 (starting at 0), child = xxyyy | [
"Perform",
"one",
"point",
"crossover",
"on",
"two",
"parent",
"chromosomes",
"."
] | python | train | 48.5 |
openstack/proliantutils | proliantutils/redfish/resources/system/system.py | https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/redfish/resources/system/system.py#L287-L296 | def check_smart_storage_config_ids(self):
"""Check SmartStorageConfig controllers is there in hardware.
:raises: IloError, on an error from iLO.
"""
if self.smart_storage_config_identities is None:
msg = ('The Redfish controller failed to get the '
'SmartS... | [
"def",
"check_smart_storage_config_ids",
"(",
"self",
")",
":",
"if",
"self",
".",
"smart_storage_config_identities",
"is",
"None",
":",
"msg",
"=",
"(",
"'The Redfish controller failed to get the '",
"'SmartStorageConfig controller configurations.'",
")",
"LOG",
".",
"debu... | Check SmartStorageConfig controllers is there in hardware.
:raises: IloError, on an error from iLO. | [
"Check",
"SmartStorageConfig",
"controllers",
"is",
"there",
"in",
"hardware",
"."
] | python | train | 42.1 |
tcalmant/ipopo | samples/run_remote.py | https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/samples/run_remote.py#L101-L113 | def discovery_mdns(self):
"""
Installs the mDNS discovery bundles and instantiates components
"""
# Remove Zeroconf debug output
logging.getLogger("zeroconf").setLevel(logging.WARNING)
# Install the bundle
self.context.install_bundle("pelix.remote.discovery.mdns"... | [
"def",
"discovery_mdns",
"(",
"self",
")",
":",
"# Remove Zeroconf debug output",
"logging",
".",
"getLogger",
"(",
"\"zeroconf\"",
")",
".",
"setLevel",
"(",
"logging",
".",
"WARNING",
")",
"# Install the bundle",
"self",
".",
"context",
".",
"install_bundle",
"(... | Installs the mDNS discovery bundles and instantiates components | [
"Installs",
"the",
"mDNS",
"discovery",
"bundles",
"and",
"instantiates",
"components"
] | python | train | 37.923077 |
NASA-AMMOS/AIT-Core | ait/core/json.py | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/json.py#L26-L56 | def slotsToJSON(obj, slots=None):
"""Converts the given Python object to one suitable for Javascript
Object Notation (JSON) serialization via :func:`json.dump` or
:func:`json.dumps`. This function delegates to :func:`toJSON`.
Specifically only attributes in the list of *slots* are converted.
If *s... | [
"def",
"slotsToJSON",
"(",
"obj",
",",
"slots",
"=",
"None",
")",
":",
"if",
"slots",
"is",
"None",
":",
"slots",
"=",
"list",
"(",
"obj",
".",
"__slots__",
")",
"if",
"hasattr",
"(",
"obj",
",",
"'__slots__'",
")",
"else",
"[",
"]",
"for",
"base",... | Converts the given Python object to one suitable for Javascript
Object Notation (JSON) serialization via :func:`json.dump` or
:func:`json.dumps`. This function delegates to :func:`toJSON`.
Specifically only attributes in the list of *slots* are converted.
If *slots* is not provided, it defaults to the... | [
"Converts",
"the",
"given",
"Python",
"object",
"to",
"one",
"suitable",
"for",
"Javascript",
"Object",
"Notation",
"(",
"JSON",
")",
"serialization",
"via",
":",
"func",
":",
"json",
".",
"dump",
"or",
":",
"func",
":",
"json",
".",
"dumps",
".",
"This"... | python | train | 39.16129 |
lsst-epo/vela | astropixie-widgets/astropixie_widgets/visual.py | https://github.com/lsst-epo/vela/blob/8e17ebec509be5c3cc2063f4645dfe9e26b49c18/astropixie-widgets/astropixie_widgets/visual.py#L224-L234 | def calculate_diagram_ranges(data):
"""
Given a numpy array calculate what the ranges of the H-R
diagram should be.
"""
data = round_arr_teff_luminosity(data)
temps = data['temp']
x_range = [1.05 * np.amax(temps), .95 * np.amin(temps)]
lums = data['lum']
y_range = [.50 * np.amin(lums... | [
"def",
"calculate_diagram_ranges",
"(",
"data",
")",
":",
"data",
"=",
"round_arr_teff_luminosity",
"(",
"data",
")",
"temps",
"=",
"data",
"[",
"'temp'",
"]",
"x_range",
"=",
"[",
"1.05",
"*",
"np",
".",
"amax",
"(",
"temps",
")",
",",
".95",
"*",
"np... | Given a numpy array calculate what the ranges of the H-R
diagram should be. | [
"Given",
"a",
"numpy",
"array",
"calculate",
"what",
"the",
"ranges",
"of",
"the",
"H",
"-",
"R",
"diagram",
"should",
"be",
"."
] | python | valid | 32.818182 |
FlaskGuys/Flask-Imagine | flask_imagine/filters/thumbnail.py | https://github.com/FlaskGuys/Flask-Imagine/blob/f79c6517ecb5480b63a2b3b8554edb6e2ac8be8c/flask_imagine/filters/thumbnail.py#L62-L93 | def inset_sizes(cls, original_width, original_height, target_width, target_height):
"""
Calculate new image sizes for inset mode
:param original_width: int
:param original_height: int
:param target_width: int
:param target_height: int
:return: tuple(int, int)
... | [
"def",
"inset_sizes",
"(",
"cls",
",",
"original_width",
",",
"original_height",
",",
"target_width",
",",
"target_height",
")",
":",
"if",
"target_width",
">=",
"original_width",
"and",
"target_height",
">=",
"original_height",
":",
"target_width",
"=",
"float",
... | Calculate new image sizes for inset mode
:param original_width: int
:param original_height: int
:param target_width: int
:param target_height: int
:return: tuple(int, int) | [
"Calculate",
"new",
"image",
"sizes",
"for",
"inset",
"mode",
":",
"param",
"original_width",
":",
"int",
":",
"param",
"original_height",
":",
"int",
":",
"param",
"target_width",
":",
"int",
":",
"param",
"target_height",
":",
"int",
":",
"return",
":",
... | python | train | 40.4375 |
has2k1/plydata | plydata/utils.py | https://github.com/has2k1/plydata/blob/d8ca85ff70eee621e96f7c74034e90fec16e8b61/plydata/utils.py#L40-L60 | def temporary_attr(obj, name, value):
"""
Context manager that removes key from dictionary on closing
The dictionary will hold the key for the duration of
the context.
Parameters
----------
obj : object
Object onto which to add a temporary attribute.
name : str
Name of ... | [
"def",
"temporary_attr",
"(",
"obj",
",",
"name",
",",
"value",
")",
":",
"setattr",
"(",
"obj",
",",
"name",
",",
"value",
")",
"try",
":",
"yield",
"obj",
"finally",
":",
"delattr",
"(",
"obj",
",",
"name",
")"
] | Context manager that removes key from dictionary on closing
The dictionary will hold the key for the duration of
the context.
Parameters
----------
obj : object
Object onto which to add a temporary attribute.
name : str
Name of attribute to add to ``obj``.
value : object
... | [
"Context",
"manager",
"that",
"removes",
"key",
"from",
"dictionary",
"on",
"closing"
] | python | train | 22.809524 |
philgyford/django-spectator | spectator/core/templatetags/spectator_core.py | https://github.com/philgyford/django-spectator/blob/f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada/spectator/core/templatetags/spectator_core.py#L49-L64 | def change_object_link_card(obj, perms):
"""
If the user has permission to change `obj`, show a link to its Admin page.
obj -- An object like Movie, Play, ClassicalWork, Publication, etc.
perms -- The `perms` object that it's the template.
"""
# eg: 'movie' or 'classicalwork':
name = obj.__c... | [
"def",
"change_object_link_card",
"(",
"obj",
",",
"perms",
")",
":",
"# eg: 'movie' or 'classicalwork':",
"name",
"=",
"obj",
".",
"__class__",
".",
"__name__",
".",
"lower",
"(",
")",
"permission",
"=",
"'spectator.can_edit_{}'",
".",
"format",
"(",
"name",
")... | If the user has permission to change `obj`, show a link to its Admin page.
obj -- An object like Movie, Play, ClassicalWork, Publication, etc.
perms -- The `perms` object that it's the template. | [
"If",
"the",
"user",
"has",
"permission",
"to",
"change",
"obj",
"show",
"a",
"link",
"to",
"its",
"Admin",
"page",
".",
"obj",
"--",
"An",
"object",
"like",
"Movie",
"Play",
"ClassicalWork",
"Publication",
"etc",
".",
"perms",
"--",
"The",
"perms",
"obj... | python | train | 39.6875 |
tswicegood/Dolt | dolt/__init__.py | https://github.com/tswicegood/Dolt/blob/e0da1918b7db18f885734a89f824b9e173cc30a5/dolt/__init__.py#L222-L244 | def get_url(self, *paths, **params):
"""
Returns the URL for this request.
:param paths: Additional URL path parts to add to the request
:param params: Additional query parameters to add to the request
"""
path_stack = self._attribute_stack[:]
if paths:
... | [
"def",
"get_url",
"(",
"self",
",",
"*",
"paths",
",",
"*",
"*",
"params",
")",
":",
"path_stack",
"=",
"self",
".",
"_attribute_stack",
"[",
":",
"]",
"if",
"paths",
":",
"path_stack",
".",
"extend",
"(",
"paths",
")",
"u",
"=",
"self",
".",
"_sta... | Returns the URL for this request.
:param paths: Additional URL path parts to add to the request
:param params: Additional query parameters to add to the request | [
"Returns",
"the",
"URL",
"for",
"this",
"request",
"."
] | python | train | 30.26087 |
pymupdf/PyMuPDF | fitz/fitz.py | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/fitz.py#L2745-L2756 | def addFreetextAnnot(self, rect, text, fontsize=12, fontname=None, color=None, rotate=0):
"""Add a 'FreeText' annotation in rectangle 'rect'."""
CheckParent(self)
val = _fitz.Page_addFreetextAnnot(self, rect, text, fontsize, fontname, color, rotate)
if not val: return
val.thiso... | [
"def",
"addFreetextAnnot",
"(",
"self",
",",
"rect",
",",
"text",
",",
"fontsize",
"=",
"12",
",",
"fontname",
"=",
"None",
",",
"color",
"=",
"None",
",",
"rotate",
"=",
"0",
")",
":",
"CheckParent",
"(",
"self",
")",
"val",
"=",
"_fitz",
".",
"Pa... | Add a 'FreeText' annotation in rectangle 'rect'. | [
"Add",
"a",
"FreeText",
"annotation",
"in",
"rectangle",
"rect",
"."
] | python | train | 34.916667 |
project-rig/rig | rig/machine_control/machine_controller.py | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L173-L178 | def root_chip(self):
"""The coordinates (x, y) of the chip used to boot the machine."""
# If not known, query the machine
if self._root_chip is None:
self._root_chip = self.get_software_version(255, 255, 0).position
return self._root_chip | [
"def",
"root_chip",
"(",
"self",
")",
":",
"# If not known, query the machine",
"if",
"self",
".",
"_root_chip",
"is",
"None",
":",
"self",
".",
"_root_chip",
"=",
"self",
".",
"get_software_version",
"(",
"255",
",",
"255",
",",
"0",
")",
".",
"position",
... | The coordinates (x, y) of the chip used to boot the machine. | [
"The",
"coordinates",
"(",
"x",
"y",
")",
"of",
"the",
"chip",
"used",
"to",
"boot",
"the",
"machine",
"."
] | python | train | 46.166667 |
tensorflow/tensorboard | tensorboard/summary/writer/event_file_writer.py | https://github.com/tensorflow/tensorboard/blob/8e5f497b48e40f2a774f85416b8a35ac0693c35e/tensorboard/summary/writer/event_file_writer.py#L88-L97 | def add_event(self, event):
"""Adds an event to the event file.
Args:
event: An `Event` protocol buffer.
"""
if not isinstance(event, event_pb2.Event):
raise TypeError("Expected an event_pb2.Event proto, "
" but got %s" % type(event))
... | [
"def",
"add_event",
"(",
"self",
",",
"event",
")",
":",
"if",
"not",
"isinstance",
"(",
"event",
",",
"event_pb2",
".",
"Event",
")",
":",
"raise",
"TypeError",
"(",
"\"Expected an event_pb2.Event proto, \"",
"\" but got %s\"",
"%",
"type",
"(",
"event",
")",... | Adds an event to the event file.
Args:
event: An `Event` protocol buffer. | [
"Adds",
"an",
"event",
"to",
"the",
"event",
"file",
"."
] | python | train | 36.8 |
phoebe-project/phoebe2 | phoebe/atmospheres/passbands.py | https://github.com/phoebe-project/phoebe2/blob/e64b8be683977064e2d55dd1b3ac400f64c3e379/phoebe/atmospheres/passbands.py#L1125-L1159 | def init_passbands(refresh=False):
"""
This function should be called only once, at import time. It
traverses the passbands directory and builds a lookup table of
passband names qualified as 'pbset:pbname' and corresponding files
and atmosphere content within.
"""
global _initialized
if... | [
"def",
"init_passbands",
"(",
"refresh",
"=",
"False",
")",
":",
"global",
"_initialized",
"if",
"not",
"_initialized",
"or",
"refresh",
":",
"# load information from online passbands first so that any that are",
"# available locally will override",
"online_passbands",
"=",
"... | This function should be called only once, at import time. It
traverses the passbands directory and builds a lookup table of
passband names qualified as 'pbset:pbname' and corresponding files
and atmosphere content within. | [
"This",
"function",
"should",
"be",
"called",
"only",
"once",
"at",
"import",
"time",
".",
"It",
"traverses",
"the",
"passbands",
"directory",
"and",
"builds",
"a",
"lookup",
"table",
"of",
"passband",
"names",
"qualified",
"as",
"pbset",
":",
"pbname",
"and... | python | train | 39.142857 |
gwpy/gwpy | gwpy/types/index.py | https://github.com/gwpy/gwpy/blob/7a92b917e7dd2d99b15895293a1fa1d66cdb210a/gwpy/types/index.py#L31-L65 | def define(cls, start, step, num, dtype=None):
"""Define a new `Index`.
The output is basically::
start + numpy.arange(num) * step
Parameters
----------
start : `Number`
The starting value of the index.
step : `Number`
The step size... | [
"def",
"define",
"(",
"cls",
",",
"start",
",",
"step",
",",
"num",
",",
"dtype",
"=",
"None",
")",
":",
"if",
"dtype",
"is",
"None",
":",
"dtype",
"=",
"max",
"(",
"numpy",
".",
"array",
"(",
"start",
",",
"subok",
"=",
"True",
",",
"copy",
"=... | Define a new `Index`.
The output is basically::
start + numpy.arange(num) * step
Parameters
----------
start : `Number`
The starting value of the index.
step : `Number`
The step size of the index.
num : `int`
The size o... | [
"Define",
"a",
"new",
"Index",
"."
] | python | train | 30.314286 |
googleapis/dialogflow-python-client-v2 | dialogflow_v2/gapic/contexts_client.py | https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2/gapic/contexts_client.py#L104-L111 | def context_path(cls, project, session, context):
"""Return a fully-qualified context string."""
return google.api_core.path_template.expand(
'projects/{project}/agent/sessions/{session}/contexts/{context}',
project=project,
session=session,
context=contex... | [
"def",
"context_path",
"(",
"cls",
",",
"project",
",",
"session",
",",
"context",
")",
":",
"return",
"google",
".",
"api_core",
".",
"path_template",
".",
"expand",
"(",
"'projects/{project}/agent/sessions/{session}/contexts/{context}'",
",",
"project",
"=",
"proj... | Return a fully-qualified context string. | [
"Return",
"a",
"fully",
"-",
"qualified",
"context",
"string",
"."
] | python | train | 40.625 |
williballenthin/python-pyqt5-hexview | hexview/hexview.py | https://github.com/williballenthin/python-pyqt5-hexview/blob/461feb286dfde60bdbc12b3fb772d650f4b8ba71/hexview/hexview.py#L129-L136 | def qindex2index(index):
""" from a QIndex (row/column coordinate system), get the buffer index of the byte """
r = index.row()
c = index.column()
if c > 0x10:
return (0x10 * r) + c - 0x11
else:
return (0x10 * r) + c | [
"def",
"qindex2index",
"(",
"index",
")",
":",
"r",
"=",
"index",
".",
"row",
"(",
")",
"c",
"=",
"index",
".",
"column",
"(",
")",
"if",
"c",
">",
"0x10",
":",
"return",
"(",
"0x10",
"*",
"r",
")",
"+",
"c",
"-",
"0x11",
"else",
":",
"return... | from a QIndex (row/column coordinate system), get the buffer index of the byte | [
"from",
"a",
"QIndex",
"(",
"row",
"/",
"column",
"coordinate",
"system",
")",
"get",
"the",
"buffer",
"index",
"of",
"the",
"byte"
] | python | train | 34.125 |
cloud-custodian/cloud-custodian | c7n/mu.py | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/mu.py#L520-L546 | def publish_alias(self, func_data, alias):
"""Create or update an alias for the given function.
"""
if not alias:
return func_data['FunctionArn']
func_name = func_data['FunctionName']
func_version = func_data['Version']
exists = resource_exists(
s... | [
"def",
"publish_alias",
"(",
"self",
",",
"func_data",
",",
"alias",
")",
":",
"if",
"not",
"alias",
":",
"return",
"func_data",
"[",
"'FunctionArn'",
"]",
"func_name",
"=",
"func_data",
"[",
"'FunctionName'",
"]",
"func_version",
"=",
"func_data",
"[",
"'Ve... | Create or update an alias for the given function. | [
"Create",
"or",
"update",
"an",
"alias",
"for",
"the",
"given",
"function",
"."
] | python | train | 38.851852 |
globocom/GloboNetworkAPI-client-python | networkapiclient/Equipamento.py | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Equipamento.py#L40-L68 | def get_real_related(self, id_equip):
"""
Find reals related with equipment
:param id_equip: Identifier of equipment
:return: Following dictionary:
::
{'vips': [{'port_real': < port_real >,
'server_pool_member_id': < server_pool_member_id >,
... | [
"def",
"get_real_related",
"(",
"self",
",",
"id_equip",
")",
":",
"url",
"=",
"'equipamento/get_real_related/'",
"+",
"str",
"(",
"id_equip",
")",
"+",
"'/'",
"code",
",",
"xml",
"=",
"self",
".",
"submit",
"(",
"None",
",",
"'GET'",
",",
"url",
")",
... | Find reals related with equipment
:param id_equip: Identifier of equipment
:return: Following dictionary:
::
{'vips': [{'port_real': < port_real >,
'server_pool_member_id': < server_pool_member_id >,
'ip': < ip >,
'port_vip': < port_vip >,
... | [
"Find",
"reals",
"related",
"with",
"equipment"
] | python | train | 32.448276 |
greenbone/ospd | ospd/ospd.py | https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/ospd.py#L448-L487 | def process_credentials_elements(cred_tree):
""" Receive an XML object with the credentials to run
a scan against a given target.
@param:
<credentials>
<credential type="up" service="ssh" port="22">
<username>scanuser</username>
<password>mypass</passwo... | [
"def",
"process_credentials_elements",
"(",
"cred_tree",
")",
":",
"credentials",
"=",
"{",
"}",
"for",
"credential",
"in",
"cred_tree",
":",
"service",
"=",
"credential",
".",
"attrib",
".",
"get",
"(",
"'service'",
")",
"credentials",
"[",
"service",
"]",
... | Receive an XML object with the credentials to run
a scan against a given target.
@param:
<credentials>
<credential type="up" service="ssh" port="22">
<username>scanuser</username>
<password>mypass</password>
</credential>
<credential type="u... | [
"Receive",
"an",
"XML",
"object",
"with",
"the",
"credentials",
"to",
"run",
"a",
"scan",
"against",
"a",
"given",
"target",
"."
] | python | train | 36.15 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/generator/mavgen_cs.py | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/generator/mavgen_cs.py#L254-L343 | def generate(basename, xml):
'''generate complete MAVLink CSharp implemenation'''
structsfilename = basename + '.generated.cs'
msgs = []
enums = []
filelist = []
for x in xml:
msgs.extend(x.message)
enums.extend(x.enum)
filelist.append(os.path.basename(x.filename))
... | [
"def",
"generate",
"(",
"basename",
",",
"xml",
")",
":",
"structsfilename",
"=",
"basename",
"+",
"'.generated.cs'",
"msgs",
"=",
"[",
"]",
"enums",
"=",
"[",
"]",
"filelist",
"=",
"[",
"]",
"for",
"x",
"in",
"xml",
":",
"msgs",
".",
"extend",
"(",
... | generate complete MAVLink CSharp implemenation | [
"generate",
"complete",
"MAVLink",
"CSharp",
"implemenation"
] | python | train | 33.144444 |
pypa/pipenv | pipenv/vendor/pexpect/utils.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/utils.py#L130-L156 | def select_ignore_interrupts(iwtd, owtd, ewtd, timeout=None):
'''This is a wrapper around select.select() that ignores signals. If
select.select raises a select.error exception and errno is an EINTR
error then it is ignored. Mainly this is used to ignore sigwinch
(terminal resize). '''
# if select... | [
"def",
"select_ignore_interrupts",
"(",
"iwtd",
",",
"owtd",
",",
"ewtd",
",",
"timeout",
"=",
"None",
")",
":",
"# if select() is interrupted by a signal (errno==EINTR) then",
"# we loop back and enter the select() again.",
"if",
"timeout",
"is",
"not",
"None",
":",
"end... | This is a wrapper around select.select() that ignores signals. If
select.select raises a select.error exception and errno is an EINTR
error then it is ignored. Mainly this is used to ignore sigwinch
(terminal resize). | [
"This",
"is",
"a",
"wrapper",
"around",
"select",
".",
"select",
"()",
"that",
"ignores",
"signals",
".",
"If",
"select",
".",
"select",
"raises",
"a",
"select",
".",
"error",
"exception",
"and",
"errno",
"is",
"an",
"EINTR",
"error",
"then",
"it",
"is",... | python | train | 40.518519 |
woolfson-group/isambard | isambard/ampal/base_ampal.py | https://github.com/woolfson-group/isambard/blob/ebc33b48a28ad217e18f93b910dfba46e6e71e07/isambard/ampal/base_ampal.py#L491-L512 | def get_atoms(self, ligands=True, inc_alt_states=False):
"""Flat list of all the Atoms in the Polymer.
Parameters
----------
inc_alt_states : bool
If true atoms from alternate conformations are included rather
than only the "active" states.
Returns
... | [
"def",
"get_atoms",
"(",
"self",
",",
"ligands",
"=",
"True",
",",
"inc_alt_states",
"=",
"False",
")",
":",
"if",
"ligands",
"and",
"self",
".",
"ligands",
":",
"monomers",
"=",
"self",
".",
"_monomers",
"+",
"self",
".",
"ligands",
".",
"_monomers",
... | Flat list of all the Atoms in the Polymer.
Parameters
----------
inc_alt_states : bool
If true atoms from alternate conformations are included rather
than only the "active" states.
Returns
-------
atoms : itertools.chain
Returns an it... | [
"Flat",
"list",
"of",
"all",
"the",
"Atoms",
"in",
"the",
"Polymer",
"."
] | python | train | 33.863636 |
striglia/pyramid_swagger | pyramid_swagger/tween.py | https://github.com/striglia/pyramid_swagger/blob/1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45/pyramid_swagger/tween.py#L592-L601 | def swaggerize_response(response, op):
"""
Delegate handling the Swagger concerns of the response to bravado-core.
:type response: :class:`pyramid.response.Response`
:type op: :class:`bravado_core.operation.Operation`
"""
response_spec = get_response_spec(response.status_int, op)
bravado_co... | [
"def",
"swaggerize_response",
"(",
"response",
",",
"op",
")",
":",
"response_spec",
"=",
"get_response_spec",
"(",
"response",
".",
"status_int",
",",
"op",
")",
"bravado_core",
".",
"response",
".",
"validate_response",
"(",
"response_spec",
",",
"op",
",",
... | Delegate handling the Swagger concerns of the response to bravado-core.
:type response: :class:`pyramid.response.Response`
:type op: :class:`bravado_core.operation.Operation` | [
"Delegate",
"handling",
"the",
"Swagger",
"concerns",
"of",
"the",
"response",
"to",
"bravado",
"-",
"core",
"."
] | python | train | 40.2 |
lesscpy/lesscpy | lesscpy/plib/block.py | https://github.com/lesscpy/lesscpy/blob/51e392fb4a3cd4ccfb6175e0e42ce7d2f6b78126/lesscpy/plib/block.py#L151-L186 | def fmt(self, fills):
"""Format block (CSS)
args:
fills (dict): Fill elements
returns:
str (CSS)
"""
f = "%(identifier)s%(ws)s{%(nl)s%(proplist)s}%(eb)s"
out = []
name = self.name.fmt(fills)
if self.parsed and any(
p... | [
"def",
"fmt",
"(",
"self",
",",
"fills",
")",
":",
"f",
"=",
"\"%(identifier)s%(ws)s{%(nl)s%(proplist)s}%(eb)s\"",
"out",
"=",
"[",
"]",
"name",
"=",
"self",
".",
"name",
".",
"fmt",
"(",
"fills",
")",
"if",
"self",
".",
"parsed",
"and",
"any",
"(",
"p... | Format block (CSS)
args:
fills (dict): Fill elements
returns:
str (CSS) | [
"Format",
"block",
"(",
"CSS",
")",
"args",
":",
"fills",
"(",
"dict",
")",
":",
"Fill",
"elements",
"returns",
":",
"str",
"(",
"CSS",
")"
] | python | valid | 37.194444 |
minio/minio-py | minio/parsers.py | https://github.com/minio/minio-py/blob/7107c84183cf5fb4deff68c0a16ab9f1c0b4c37e/minio/parsers.py#L171-L184 | def parse_copy_object(bucket_name, object_name, data):
"""
Parser for copy object response.
:param data: Response data for copy object.
:return: :class:`CopyObjectResult <CopyObjectResult>`
"""
root = S3Element.fromstring('CopyObjectResult', data)
return CopyObjectResult(
bucket_na... | [
"def",
"parse_copy_object",
"(",
"bucket_name",
",",
"object_name",
",",
"data",
")",
":",
"root",
"=",
"S3Element",
".",
"fromstring",
"(",
"'CopyObjectResult'",
",",
"data",
")",
"return",
"CopyObjectResult",
"(",
"bucket_name",
",",
"object_name",
",",
"root"... | Parser for copy object response.
:param data: Response data for copy object.
:return: :class:`CopyObjectResult <CopyObjectResult>` | [
"Parser",
"for",
"copy",
"object",
"response",
"."
] | python | train | 29.428571 |
apriha/lineage | src/lineage/resources.py | https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/resources.py#L312-L346 | def _load_assembly_mapping_data(filename):
""" Load assembly mapping data.
Parameters
----------
filename : str
path to compressed archive with assembly mapping data
Returns
-------
assembly_mapping_data : dict
dict of assembly maps if lo... | [
"def",
"_load_assembly_mapping_data",
"(",
"filename",
")",
":",
"try",
":",
"assembly_mapping_data",
"=",
"{",
"}",
"with",
"tarfile",
".",
"open",
"(",
"filename",
",",
"\"r\"",
")",
"as",
"tar",
":",
"# http://stackoverflow.com/a/2018576",
"for",
"member",
"i... | Load assembly mapping data.
Parameters
----------
filename : str
path to compressed archive with assembly mapping data
Returns
-------
assembly_mapping_data : dict
dict of assembly maps if loading was successful, else None
Notes
... | [
"Load",
"assembly",
"mapping",
"data",
"."
] | python | train | 33.914286 |
EnigmaBridge/jbossply | jbossply/jbossparser.py | https://github.com/EnigmaBridge/jbossply/blob/44b30b15982cae781f0c356fab7263751b20b4d0/jbossply/jbossparser.py#L375-L381 | def p_chars(self, p):
"""chars :
| chars char"""
if len(p) == 1:
p[0] = unicode()
else:
p[0] = p[1] + p[2] | [
"def",
"p_chars",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"1",
":",
"p",
"[",
"0",
"]",
"=",
"unicode",
"(",
")",
"else",
":",
"p",
"[",
"0",
"]",
"=",
"p",
"[",
"1",
"]",
"+",
"p",
"[",
"2",
"]"
] | chars :
| chars char | [
"chars",
":",
"|",
"chars",
"char"
] | python | train | 23.571429 |
craffel/mir_eval | mir_eval/segment.py | https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/segment.py#L1079-L1150 | def vmeasure(reference_intervals, reference_labels, estimated_intervals,
estimated_labels, frame_size=0.1, beta=1.0):
"""Frame-clustering segmentation: v-measure
Computes cross-entropy of cluster assignment, normalized by the
marginal-entropy.
This is equivalent to `nce(..., marginal=True... | [
"def",
"vmeasure",
"(",
"reference_intervals",
",",
"reference_labels",
",",
"estimated_intervals",
",",
"estimated_labels",
",",
"frame_size",
"=",
"0.1",
",",
"beta",
"=",
"1.0",
")",
":",
"return",
"nce",
"(",
"reference_intervals",
",",
"reference_labels",
","... | Frame-clustering segmentation: v-measure
Computes cross-entropy of cluster assignment, normalized by the
marginal-entropy.
This is equivalent to `nce(..., marginal=True)`.
Examples
--------
>>> (ref_intervals,
... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab')
>>> (est_i... | [
"Frame",
"-",
"clustering",
"segmentation",
":",
"v",
"-",
"measure"
] | python | train | 36.638889 |
MAVENSDC/PyTplot | pytplot/zlim.py | https://github.com/MAVENSDC/PyTplot/blob/d76cdb95363a4bd4fea6bca7960f8523efa7fa83/pytplot/zlim.py#L8-L42 | def zlim(name, min, max):
"""
This function will set the z axis range displayed for a specific tplot variable.
This is only used for spec plots, where the z axis represents the magnitude of the values
in each bin.
Parameters:
name : str
The name of the tplot variable that ... | [
"def",
"zlim",
"(",
"name",
",",
"min",
",",
"max",
")",
":",
"if",
"name",
"not",
"in",
"data_quants",
".",
"keys",
"(",
")",
":",
"print",
"(",
"\"That name is currently not in pytplot.\"",
")",
"return",
"temp_data_quant",
"=",
"data_quants",
"[",
"name",... | This function will set the z axis range displayed for a specific tplot variable.
This is only used for spec plots, where the z axis represents the magnitude of the values
in each bin.
Parameters:
name : str
The name of the tplot variable that you wish to set z limits for.
... | [
"This",
"function",
"will",
"set",
"the",
"z",
"axis",
"range",
"displayed",
"for",
"a",
"specific",
"tplot",
"variable",
".",
"This",
"is",
"only",
"used",
"for",
"spec",
"plots",
"where",
"the",
"z",
"axis",
"represents",
"the",
"magnitude",
"of",
"the",... | python | train | 29.571429 |
woolfson-group/isambard | isambard/ampal/protein.py | https://github.com/woolfson-group/isambard/blob/ebc33b48a28ad217e18f93b910dfba46e6e71e07/isambard/ampal/protein.py#L366-L397 | def pack_new_sequence(self, sequence):
"""Packs a new sequence onto the polymer using Scwrl4.
Parameters
----------
sequence : str
String containing the amino acid sequence. This must
be the same length as the Polymer
Raises
------
ValueE... | [
"def",
"pack_new_sequence",
"(",
"self",
",",
"sequence",
")",
":",
"# This import is here to prevent a circular import.",
"from",
"ampal",
".",
"pdb_parser",
"import",
"convert_pdb_to_ampal",
"polymer_bb",
"=",
"self",
".",
"backbone",
"if",
"len",
"(",
"sequence",
"... | Packs a new sequence onto the polymer using Scwrl4.
Parameters
----------
sequence : str
String containing the amino acid sequence. This must
be the same length as the Polymer
Raises
------
ValueError
Raised if the sequence length doe... | [
"Packs",
"a",
"new",
"sequence",
"onto",
"the",
"polymer",
"using",
"Scwrl4",
"."
] | python | train | 38.15625 |
MaxHalford/starboost | starboost/boosting.py | https://github.com/MaxHalford/starboost/blob/59d96dcc983404cbc326878facd8171fd2655ce1/starboost/boosting.py#L385-L395 | def predict_proba(self, X):
"""Returns the predicted probabilities for ``X``.
Arguments:
X (array-like or sparse matrix of shape (n_samples, n_features)): The input samples.
Sparse matrices are accepted only if they are supported by the weak model.
Returns:
... | [
"def",
"predict_proba",
"(",
"self",
",",
"X",
")",
":",
"return",
"collections",
".",
"deque",
"(",
"self",
".",
"iter_predict_proba",
"(",
"X",
")",
",",
"maxlen",
"=",
"1",
")",
".",
"pop",
"(",
")"
] | Returns the predicted probabilities for ``X``.
Arguments:
X (array-like or sparse matrix of shape (n_samples, n_features)): The input samples.
Sparse matrices are accepted only if they are supported by the weak model.
Returns:
array of shape (n_samples, n_classe... | [
"Returns",
"the",
"predicted",
"probabilities",
"for",
"X",
"."
] | python | train | 43.636364 |
SuperCowPowers/workbench | workbench_apps/workbench_cli/workbench_shell.py | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench_apps/workbench_cli/workbench_shell.py#L135-L167 | def pivot(self, md5, tag=''):
"""Pivot on an md5 (md5 can be a single sample or a sample_set)
Args:
md5: The md5 can be a single sample or a sample_set
tags (optional): a tag for the sample (for the prompt)
Returns:
Nothing but it's sets th... | [
"def",
"pivot",
"(",
"self",
",",
"md5",
",",
"tag",
"=",
"''",
")",
":",
"# Is the md5 a tag?",
"ss",
"=",
"self",
".",
"workbench",
".",
"generate_sample_set",
"(",
"md5",
")",
"if",
"ss",
":",
"tag",
"=",
"md5",
"if",
"not",
"tag",
"else",
"tag",
... | Pivot on an md5 (md5 can be a single sample or a sample_set)
Args:
md5: The md5 can be a single sample or a sample_set
tags (optional): a tag for the sample (for the prompt)
Returns:
Nothing but it's sets the active sample/sample_set | [
"Pivot",
"on",
"an",
"md5",
"(",
"md5",
"can",
"be",
"a",
"single",
"sample",
"or",
"a",
"sample_set",
")",
"Args",
":",
"md5",
":",
"The",
"md5",
"can",
"be",
"a",
"single",
"sample",
"or",
"a",
"sample_set",
"tags",
"(",
"optional",
")",
":",
"a"... | python | train | 34.515152 |
bitesofcode/projexui | projexui/widgets/xnodewidget/xnode.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xnodewidget/xnode.py#L534-L550 | def disabledBrush( self ):
"""
Return the main brush for this node.
:return <QBrush>
"""
# create the background brush
grad = QLinearGradient()
rect = self.rect()
grad.setStart(QPointF(0, rect.y()))
grad.setFinalStop(QPointF(0... | [
"def",
"disabledBrush",
"(",
"self",
")",
":",
"# create the background brush",
"grad",
"=",
"QLinearGradient",
"(",
")",
"rect",
"=",
"self",
".",
"rect",
"(",
")",
"grad",
".",
"setStart",
"(",
"QPointF",
"(",
"0",
",",
"rect",
".",
"y",
"(",
")",
")... | Return the main brush for this node.
:return <QBrush> | [
"Return",
"the",
"main",
"brush",
"for",
"this",
"node",
".",
":",
"return",
"<QBrush",
">"
] | python | train | 28.117647 |
saltstack/salt | salt/cloud/libcloudfuncs.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/libcloudfuncs.py#L441-L465 | def list_nodes(conn=None, call=None):
'''
Return a list of the VMs that are on the provider
'''
if call == 'action':
raise SaltCloudSystemExit(
'The list_nodes function must be called with -f or --function.'
)
if not conn:
conn = get_conn() # pylint: disable=E0... | [
"def",
"list_nodes",
"(",
"conn",
"=",
"None",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The list_nodes function must be called with -f or --function.'",
")",
"if",
"not",
"conn",
":",
"conn",
... | Return a list of the VMs that are on the provider | [
"Return",
"a",
"list",
"of",
"the",
"VMs",
"that",
"are",
"on",
"the",
"provider"
] | python | train | 26.88 |
rossant/ipymd | ipymd/lib/markdown.py | https://github.com/rossant/ipymd/blob/d87c9ebc59d67fe78b0139ee00e0e5307682e303/ipymd/lib/markdown.py#L647-L653 | def _filter_markdown(source, filters):
"""Only keep some Markdown headers from a Markdown string."""
lines = source.splitlines()
# Filters is a list of 'hN' strings where 1 <= N <= 6.
headers = [_replace_header_filter(filter) for filter in filters]
lines = [line for line in lines if line.startswith(... | [
"def",
"_filter_markdown",
"(",
"source",
",",
"filters",
")",
":",
"lines",
"=",
"source",
".",
"splitlines",
"(",
")",
"# Filters is a list of 'hN' strings where 1 <= N <= 6.",
"headers",
"=",
"[",
"_replace_header_filter",
"(",
"filter",
")",
"for",
"filter",
"in... | Only keep some Markdown headers from a Markdown string. | [
"Only",
"keep",
"some",
"Markdown",
"headers",
"from",
"a",
"Markdown",
"string",
"."
] | python | train | 51.142857 |
michael-lazar/rtv | rtv/content.py | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/content.py#L1121-L1135 | def evict(self, urls):
"""Remove items from cache matching URLs.
Return the number of items removed.
"""
if isinstance(urls, six.text_type):
urls = [urls]
urls = set(normalize_url(url) for url in urls)
retval = 0
for key in list(self.cache):
... | [
"def",
"evict",
"(",
"self",
",",
"urls",
")",
":",
"if",
"isinstance",
"(",
"urls",
",",
"six",
".",
"text_type",
")",
":",
"urls",
"=",
"[",
"urls",
"]",
"urls",
"=",
"set",
"(",
"normalize_url",
"(",
"url",
")",
"for",
"url",
"in",
"urls",
")"... | Remove items from cache matching URLs.
Return the number of items removed. | [
"Remove",
"items",
"from",
"cache",
"matching",
"URLs",
"."
] | python | train | 30.133333 |
biosignalsnotebooks/biosignalsnotebooks | biosignalsnotebooks/build/lib/biosignalsnotebooks/aux_functions.py | https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/build/lib/biosignalsnotebooks/aux_functions.py#L318-L355 | def _inv_key(list_keys, valid_keys):
"""
-----
Brief
-----
A sub-function of _filter_keywords function.
-----------
Description
-----------
Function used for identification when a list of keywords contains invalid keywords not present
in the valid list.
----------
Param... | [
"def",
"_inv_key",
"(",
"list_keys",
",",
"valid_keys",
")",
":",
"inv_keys",
"=",
"[",
"]",
"bool_out",
"=",
"True",
"for",
"i",
"in",
"list_keys",
":",
"if",
"i",
"not",
"in",
"valid_keys",
":",
"bool_out",
"=",
"False",
"inv_keys",
".",
"append",
"(... | -----
Brief
-----
A sub-function of _filter_keywords function.
-----------
Description
-----------
Function used for identification when a list of keywords contains invalid keywords not present
in the valid list.
----------
Parameters
----------
list_keys : list
... | [
"-----",
"Brief",
"-----",
"A",
"sub",
"-",
"function",
"of",
"_filter_keywords",
"function",
"."
] | python | train | 23.657895 |
zimeon/iiif | iiif/auth.py | https://github.com/zimeon/iiif/blob/9d10018d01202fa2a76dfa61598dc6eca07b471f/iiif/auth.py#L178-L187 | def scheme_host_port_prefix(self, scheme='http', host='host',
port=None, prefix=None):
"""Return URI composed of scheme, server, port, and prefix."""
uri = scheme + '://' + host
if (port and not ((scheme == 'http' and port == 80) or
(sche... | [
"def",
"scheme_host_port_prefix",
"(",
"self",
",",
"scheme",
"=",
"'http'",
",",
"host",
"=",
"'host'",
",",
"port",
"=",
"None",
",",
"prefix",
"=",
"None",
")",
":",
"uri",
"=",
"scheme",
"+",
"'://'",
"+",
"host",
"if",
"(",
"port",
"and",
"not",... | Return URI composed of scheme, server, port, and prefix. | [
"Return",
"URI",
"composed",
"of",
"scheme",
"server",
"port",
"and",
"prefix",
"."
] | python | train | 45.1 |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/ietf_netconf_acm.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/ietf_netconf_acm.py#L140-L153 | def nacm_rule_list_rule_name(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
nacm = ET.SubElement(config, "nacm", xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-acm")
rule_list = ET.SubElement(nacm, "rule-list")
name_key = ET.SubElement(rule_lis... | [
"def",
"nacm_rule_list_rule_name",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"nacm",
"=",
"ET",
".",
"SubElement",
"(",
"config",
",",
"\"nacm\"",
",",
"xmlns",
"=",
"\"urn:ietf:params:xml:... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 41.5 |
flo-compbio/gopca-server | gpserver/config.py | https://github.com/flo-compbio/gopca-server/blob/4fe396b12c39c0f156ce3bc4538cade54c9d7ffe/gpserver/config.py#L176-L179 | def reset_params(self):
"""Reset all parameters to their default values."""
self.__params = dict([p, None] for p in self.param_names)
self.set_params(self.param_defaults) | [
"def",
"reset_params",
"(",
"self",
")",
":",
"self",
".",
"__params",
"=",
"dict",
"(",
"[",
"p",
",",
"None",
"]",
"for",
"p",
"in",
"self",
".",
"param_names",
")",
"self",
".",
"set_params",
"(",
"self",
".",
"param_defaults",
")"
] | Reset all parameters to their default values. | [
"Reset",
"all",
"parameters",
"to",
"their",
"default",
"values",
"."
] | python | train | 47.75 |
spyder-ide/spyder | spyder/plugins/plots/widgets/figurebrowser.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/plots/widgets/figurebrowser.py#L293-L297 | def set_shellwidget(self, shellwidget):
"""Bind the shellwidget instance to the figure browser"""
self.shellwidget = shellwidget
shellwidget.set_figurebrowser(self)
shellwidget.sig_new_inline_figure.connect(self._handle_new_figure) | [
"def",
"set_shellwidget",
"(",
"self",
",",
"shellwidget",
")",
":",
"self",
".",
"shellwidget",
"=",
"shellwidget",
"shellwidget",
".",
"set_figurebrowser",
"(",
"self",
")",
"shellwidget",
".",
"sig_new_inline_figure",
".",
"connect",
"(",
"self",
".",
"_handl... | Bind the shellwidget instance to the figure browser | [
"Bind",
"the",
"shellwidget",
"instance",
"to",
"the",
"figure",
"browser"
] | python | train | 51.8 |
Contraz/demosys-py | demosys/scene/scene.py | https://github.com/Contraz/demosys-py/blob/6466128a3029c4d09631420ccce73024025bd5b6/demosys/scene/scene.py#L97-L113 | def apply_mesh_programs(self, mesh_programs=None):
"""Applies mesh programs to meshes"""
if not mesh_programs:
mesh_programs = [ColorProgram(), TextureProgram(), FallbackProgram()]
for mesh in self.meshes:
for mp in mesh_programs:
instance = mp.apply(mesh... | [
"def",
"apply_mesh_programs",
"(",
"self",
",",
"mesh_programs",
"=",
"None",
")",
":",
"if",
"not",
"mesh_programs",
":",
"mesh_programs",
"=",
"[",
"ColorProgram",
"(",
")",
",",
"TextureProgram",
"(",
")",
",",
"FallbackProgram",
"(",
")",
"]",
"for",
"... | Applies mesh programs to meshes | [
"Applies",
"mesh",
"programs",
"to",
"meshes"
] | python | valid | 43.941176 |
DLR-RM/RAFCON | source/rafcon/gui/helpers/state.py | https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/helpers/state.py#L147-L230 | def create_new_state_from_state_with_type(source_state, target_state_class):
"""The function duplicates/transforms a state to a new state type. If the source state type and the new state
type both are ContainerStates the new state will have not transitions to force the user to explicitly re-order
the logica... | [
"def",
"create_new_state_from_state_with_type",
"(",
"source_state",
",",
"target_state_class",
")",
":",
"current_state_is_container",
"=",
"isinstance",
"(",
"source_state",
",",
"ContainerState",
")",
"new_state_is_container",
"=",
"issubclass",
"(",
"target_state_class",
... | The function duplicates/transforms a state to a new state type. If the source state type and the new state
type both are ContainerStates the new state will have not transitions to force the user to explicitly re-order
the logical flow according the paradigm of the new state type.
:param source_state: previ... | [
"The",
"function",
"duplicates",
"/",
"transforms",
"a",
"state",
"to",
"a",
"new",
"state",
"type",
".",
"If",
"the",
"source",
"state",
"type",
"and",
"the",
"new",
"state",
"type",
"both",
"are",
"ContainerStates",
"the",
"new",
"state",
"will",
"have",... | python | train | 54.297619 |
luckydonald/pytgbot | pytgbot/api_types/receivable/passport.py | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/receivable/passport.py#L77-L94 | def from_array(array):
"""
Deserialize a new PassportData from a given dictionary.
:return: new PassportData instance.
:rtype: PassportData
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_nam... | [
"def",
"from_array",
"(",
"array",
")",
":",
"if",
"array",
"is",
"None",
"or",
"not",
"array",
":",
"return",
"None",
"# end if",
"assert_type_or_raise",
"(",
"array",
",",
"dict",
",",
"parameter_name",
"=",
"\"array\"",
")",
"data",
"=",
"{",
"}",
"da... | Deserialize a new PassportData from a given dictionary.
:return: new PassportData instance.
:rtype: PassportData | [
"Deserialize",
"a",
"new",
"PassportData",
"from",
"a",
"given",
"dictionary",
"."
] | python | train | 32.388889 |
aliyun/aliyun-odps-python-sdk | odps/ml/algolib/objects.py | https://github.com/aliyun/aliyun-odps-python-sdk/blob/4b0de18f5864386df6068f26f026e62f932c41e4/odps/ml/algolib/objects.py#L370-L384 | def add_meta(self, name, value):
"""
Add a pair of meta data to the definition
:param name: name of the meta
:type name: str
:param value: value of the meta
:type value: str
"""
for mt in self.metas:
if mt.name == name:
mt.valu... | [
"def",
"add_meta",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"for",
"mt",
"in",
"self",
".",
"metas",
":",
"if",
"mt",
".",
"name",
"==",
"name",
":",
"mt",
".",
"value",
"=",
"value",
"return",
"self",
"self",
".",
"metas",
".",
"append"... | Add a pair of meta data to the definition
:param name: name of the meta
:type name: str
:param value: value of the meta
:type value: str | [
"Add",
"a",
"pair",
"of",
"meta",
"data",
"to",
"the",
"definition"
] | python | train | 27.4 |
HydraChain/hydrachain | hydrachain/consensus/base.py | https://github.com/HydraChain/hydrachain/blob/6c0919b0575dc8aa481f3a8c703e1a7f0575ecc3/hydrachain/consensus/base.py#L332-L342 | def genesis_signing_lockset(genesis, privkey):
"""
in order to avoid a complicated bootstrapping, we define
the genesis_signing_lockset as a lockset with one vote by any validator.
"""
v = VoteBlock(0, 0, genesis.hash)
v.sign(privkey)
ls = LockSet(num_eligible_votes=1)
ls.add(v)
asse... | [
"def",
"genesis_signing_lockset",
"(",
"genesis",
",",
"privkey",
")",
":",
"v",
"=",
"VoteBlock",
"(",
"0",
",",
"0",
",",
"genesis",
".",
"hash",
")",
"v",
".",
"sign",
"(",
"privkey",
")",
"ls",
"=",
"LockSet",
"(",
"num_eligible_votes",
"=",
"1",
... | in order to avoid a complicated bootstrapping, we define
the genesis_signing_lockset as a lockset with one vote by any validator. | [
"in",
"order",
"to",
"avoid",
"a",
"complicated",
"bootstrapping",
"we",
"define",
"the",
"genesis_signing_lockset",
"as",
"a",
"lockset",
"with",
"one",
"vote",
"by",
"any",
"validator",
"."
] | python | test | 30.909091 |
BlueBrain/hpcbench | hpcbench/driver/slurm.py | https://github.com/BlueBrain/hpcbench/blob/192d0ec142b897157ec25f131d1ef28f84752592/hpcbench/driver/slurm.py#L225-L260 | def _execute_sbatch(self):
"""Schedule the sbatch file using the sbatch command
:returns the slurm job id
"""
commands = self.campaign.process.get('commands', {})
sbatch = find_executable(commands.get('sbatch', 'sbatch'))
sbatch_command = [sbatch, '--parsable', self.sbatc... | [
"def",
"_execute_sbatch",
"(",
"self",
")",
":",
"commands",
"=",
"self",
".",
"campaign",
".",
"process",
".",
"get",
"(",
"'commands'",
",",
"{",
"}",
")",
"sbatch",
"=",
"find_executable",
"(",
"commands",
".",
"get",
"(",
"'sbatch'",
",",
"'sbatch'",... | Schedule the sbatch file using the sbatch command
:returns the slurm job id | [
"Schedule",
"the",
"sbatch",
"file",
"using",
"the",
"sbatch",
"command",
":",
"returns",
"the",
"slurm",
"job",
"id"
] | python | train | 39.166667 |
jtwhite79/pyemu | pyemu/utils/geostats.py | https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/utils/geostats.py#L1045-L1061 | def to_struct_file(self, f):
""" write the Vario2d to a PEST-style structure file
Parameters
----------
f : (str or file handle)
item to write to
"""
if isinstance(f, str):
f = open(f,'w')
f.write("VARIOGRAM {0}\n".format(self.name))
... | [
"def",
"to_struct_file",
"(",
"self",
",",
"f",
")",
":",
"if",
"isinstance",
"(",
"f",
",",
"str",
")",
":",
"f",
"=",
"open",
"(",
"f",
",",
"'w'",
")",
"f",
".",
"write",
"(",
"\"VARIOGRAM {0}\\n\"",
".",
"format",
"(",
"self",
".",
"name",
")... | write the Vario2d to a PEST-style structure file
Parameters
----------
f : (str or file handle)
item to write to | [
"write",
"the",
"Vario2d",
"to",
"a",
"PEST",
"-",
"style",
"structure",
"file"
] | python | train | 32.588235 |
coghost/izen | izen/helper.py | https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/helper.py#L99-L222 | def num_choice(choices, default='1', valid_keys='', depth=1, icons='', sn_info=None,
indent=4, fg_color='green', separator='',
with_img=6, img_list=None, img_cache_dir='/tmp', use_cache=False,
extra_hints='', clear_previous=False, quit_app=True,
):
"""
... | [
"def",
"num_choice",
"(",
"choices",
",",
"default",
"=",
"'1'",
",",
"valid_keys",
"=",
"''",
",",
"depth",
"=",
"1",
",",
"icons",
"=",
"''",
",",
"sn_info",
"=",
"None",
",",
"indent",
"=",
"4",
",",
"fg_color",
"=",
"'green'",
",",
"separator",
... | 传入数组, 生成待选择列表, 如果启用图片支持, 需要额外传入与数组排序一致的图片列表,
- 图片在 iterms 中显示速度较慢, 不推荐使用
.. note: 图片在 iterms 中显示速度较慢, 如果数组长度大于10, 不推荐使用
.. code:: python
sn_info = {
'align': '-', # 左右对齐
'length': 2, # 显示长度
}
:param use_cache:
:type use_cache:
... | [
"传入数组",
"生成待选择列表",
"如果启用图片支持",
"需要额外传入与数组排序一致的图片列表",
"-",
"图片在",
"iterms",
"中显示速度较慢",
"不推荐使用"
] | python | train | 32.830645 |
libnano/primer3-py | primer3/bindings.py | https://github.com/libnano/primer3-py/blob/0901c0ef3ac17afd69329d23db71136c00bcb635/primer3/bindings.py#L246-L272 | def designPrimers(seq_args, global_args=None, misprime_lib=None,
mishyb_lib=None, debug=False):
''' Run the Primer3 design process.
If the global args have been previously set (either by a pervious
`designPrimers` call or by a `setGlobals` call), `designPrimers` may be
called with seq... | [
"def",
"designPrimers",
"(",
"seq_args",
",",
"global_args",
"=",
"None",
",",
"misprime_lib",
"=",
"None",
",",
"mishyb_lib",
"=",
"None",
",",
"debug",
"=",
"False",
")",
":",
"if",
"global_args",
":",
"primerdesign",
".",
"setGlobals",
"(",
"global_args",... | Run the Primer3 design process.
If the global args have been previously set (either by a pervious
`designPrimers` call or by a `setGlobals` call), `designPrimers` may be
called with seqArgs alone (as a means of optimization).
Args:
seq_args (dict) : Primer3 sequence/design args a... | [
"Run",
"the",
"Primer3",
"design",
"process",
"."
] | python | train | 42.777778 |
cryptojuice/flask-scrypt | flask_scrypt.py | https://github.com/cryptojuice/flask-scrypt/blob/d7f01d0d97fa36b21caa30b49c22945177799886/flask_scrypt.py#L38-L52 | def enbase64(byte_str):
"""
Encode bytes/strings to base64.
Args:
- ``byte_str``: The string or bytes to base64 encode.
Returns:
- byte_str encoded as base64.
"""
# Python 3: base64.b64encode() expects type byte
if isinstance(byte_str, str) and not PYTHON2:
byte_s... | [
"def",
"enbase64",
"(",
"byte_str",
")",
":",
"# Python 3: base64.b64encode() expects type byte",
"if",
"isinstance",
"(",
"byte_str",
",",
"str",
")",
"and",
"not",
"PYTHON2",
":",
"byte_str",
"=",
"bytes",
"(",
"byte_str",
",",
"'utf-8'",
")",
"return",
"base6... | Encode bytes/strings to base64.
Args:
- ``byte_str``: The string or bytes to base64 encode.
Returns:
- byte_str encoded as base64. | [
"Encode",
"bytes",
"/",
"strings",
"to",
"base64",
"."
] | python | train | 24.866667 |
SeattleTestbed/seash | pyreadline/modes/basemode.py | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/modes/basemode.py#L339-L343 | def backward_word(self, e): # (M-b)
u"""Move back to the start of the current or previous word. Words are
composed of letters and digits."""
self.l_buffer.backward_word(self.argument_reset)
self.finalize() | [
"def",
"backward_word",
"(",
"self",
",",
"e",
")",
":",
"# (M-b)\r",
"self",
".",
"l_buffer",
".",
"backward_word",
"(",
"self",
".",
"argument_reset",
")",
"self",
".",
"finalize",
"(",
")"
] | u"""Move back to the start of the current or previous word. Words are
composed of letters and digits. | [
"u",
"Move",
"back",
"to",
"the",
"start",
"of",
"the",
"current",
"or",
"previous",
"word",
".",
"Words",
"are",
"composed",
"of",
"letters",
"and",
"digits",
"."
] | python | train | 47.4 |
singingwolfboy/flask-sse | flask_sse.py | https://github.com/singingwolfboy/flask-sse/blob/a5c6afe12cd3c29c90588ad8a2c698c829af6572/flask_sse.py#L132-L141 | def messages(self, channel='sse'):
"""
A generator of :class:`~flask_sse.Message` objects from the given channel.
"""
pubsub = self.redis.pubsub()
pubsub.subscribe(channel)
for pubsub_message in pubsub.listen():
if pubsub_message['type'] == 'message':
... | [
"def",
"messages",
"(",
"self",
",",
"channel",
"=",
"'sse'",
")",
":",
"pubsub",
"=",
"self",
".",
"redis",
".",
"pubsub",
"(",
")",
"pubsub",
".",
"subscribe",
"(",
"channel",
")",
"for",
"pubsub_message",
"in",
"pubsub",
".",
"listen",
"(",
")",
"... | A generator of :class:`~flask_sse.Message` objects from the given channel. | [
"A",
"generator",
"of",
":",
"class",
":",
"~flask_sse",
".",
"Message",
"objects",
"from",
"the",
"given",
"channel",
"."
] | python | train | 40.6 |
LonamiWebs/Telethon | telethon/extensions/html.py | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/extensions/html.py#L117-L131 | def parse(html):
"""
Parses the given HTML message and returns its stripped representation
plus a list of the MessageEntity's that were found.
:param message: the message with HTML to be parsed.
:return: a tuple consisting of (clean message, [message entities]).
"""
if not html:
ret... | [
"def",
"parse",
"(",
"html",
")",
":",
"if",
"not",
"html",
":",
"return",
"html",
",",
"[",
"]",
"parser",
"=",
"HTMLToTelegramParser",
"(",
")",
"parser",
".",
"feed",
"(",
"_add_surrogate",
"(",
"html",
")",
")",
"text",
"=",
"helpers",
".",
"stri... | Parses the given HTML message and returns its stripped representation
plus a list of the MessageEntity's that were found.
:param message: the message with HTML to be parsed.
:return: a tuple consisting of (clean message, [message entities]). | [
"Parses",
"the",
"given",
"HTML",
"message",
"and",
"returns",
"its",
"stripped",
"representation",
"plus",
"a",
"list",
"of",
"the",
"MessageEntity",
"s",
"that",
"were",
"found",
"."
] | python | train | 33.466667 |
neurosynth/neurosynth | neurosynth/base/mask.py | https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/base/mask.py#L138-L167 | def mask(self, image, nan_to_num=True, layers=None, in_global_mask=False):
""" Vectorize an image and mask out all invalid voxels.
Args:
images: The image to vectorize and mask. Input can be any object
handled by get_image().
layers: Which mask layers to use (spe... | [
"def",
"mask",
"(",
"self",
",",
"image",
",",
"nan_to_num",
"=",
"True",
",",
"layers",
"=",
"None",
",",
"in_global_mask",
"=",
"False",
")",
":",
"self",
".",
"set_mask",
"(",
"layers",
")",
"image",
"=",
"self",
".",
"get_image",
"(",
"image",
",... | Vectorize an image and mask out all invalid voxels.
Args:
images: The image to vectorize and mask. Input can be any object
handled by get_image().
layers: Which mask layers to use (specified as int, string, or
list of ints and strings). When None, applies... | [
"Vectorize",
"an",
"image",
"and",
"mask",
"out",
"all",
"invalid",
"voxels",
"."
] | python | test | 41.766667 |
ga4gh/ga4gh-server | ga4gh/server/datamodel/continuous.py | https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/ga4gh/server/datamodel/continuous.py#L154-L161 | def wiggleFileHandleToProtocol(self, fileHandle):
"""
Return a continuous protocol object satsifiying the given query
parameters from the given wiggle file handle.
"""
for line in fileHandle:
self.readWiggleLine(line)
return self._data | [
"def",
"wiggleFileHandleToProtocol",
"(",
"self",
",",
"fileHandle",
")",
":",
"for",
"line",
"in",
"fileHandle",
":",
"self",
".",
"readWiggleLine",
"(",
"line",
")",
"return",
"self",
".",
"_data"
] | Return a continuous protocol object satsifiying the given query
parameters from the given wiggle file handle. | [
"Return",
"a",
"continuous",
"protocol",
"object",
"satsifiying",
"the",
"given",
"query",
"parameters",
"from",
"the",
"given",
"wiggle",
"file",
"handle",
"."
] | python | train | 36 |
bitesofcode/projexui | projexui/widgets/ximageslider/ximageslider.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/ximageslider/ximageslider.py#L124-L134 | def removePixmap(self, pixmap):
"""
Removes the pixmap from this widgets list of pixmaps.
:param pixmap | <QPixmap>
"""
scene = self.scene()
for item in self.items():
if item.basePixmap() == pixmap:
scene.removeItem(item)... | [
"def",
"removePixmap",
"(",
"self",
",",
"pixmap",
")",
":",
"scene",
"=",
"self",
".",
"scene",
"(",
")",
"for",
"item",
"in",
"self",
".",
"items",
"(",
")",
":",
"if",
"item",
".",
"basePixmap",
"(",
")",
"==",
"pixmap",
":",
"scene",
".",
"re... | Removes the pixmap from this widgets list of pixmaps.
:param pixmap | <QPixmap> | [
"Removes",
"the",
"pixmap",
"from",
"this",
"widgets",
"list",
"of",
"pixmaps",
".",
":",
"param",
"pixmap",
"|",
"<QPixmap",
">"
] | python | train | 30.272727 |
deepmipt/DeepPavlov | deeppavlov/core/commands/infer.py | https://github.com/deepmipt/DeepPavlov/blob/f3e4a69a3764d25d2f5bad4f1f1aebc872b00f9c/deeppavlov/core/commands/infer.py#L92-L122 | def predict_on_stream(config: Union[str, Path, dict], batch_size: int = 1, file_path: Optional[str] = None) -> None:
"""Make a prediction with the component described in corresponding configuration file."""
if file_path is None or file_path == '-':
if sys.stdin.isatty():
raise RuntimeError('... | [
"def",
"predict_on_stream",
"(",
"config",
":",
"Union",
"[",
"str",
",",
"Path",
",",
"dict",
"]",
",",
"batch_size",
":",
"int",
"=",
"1",
",",
"file_path",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"None",
":",
"if",
"file_path",
... | Make a prediction with the component described in corresponding configuration file. | [
"Make",
"a",
"prediction",
"with",
"the",
"component",
"described",
"in",
"corresponding",
"configuration",
"file",
"."
] | python | test | 31.967742 |
jaraco/path.py | path/__init__.py | https://github.com/jaraco/path.py/blob/bbe7d99e7a64a004f866ace9ec12bd9b296908f5/path/__init__.py#L783-L800 | def lines(self, encoding=None, errors='strict', retain=True):
r""" Open this file, read all lines, return them in a list.
Optional arguments:
`encoding` - The Unicode encoding (or character set) of
the file. The default is ``None``, meaning the content
of th... | [
"def",
"lines",
"(",
"self",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"'strict'",
",",
"retain",
"=",
"True",
")",
":",
"return",
"self",
".",
"text",
"(",
"encoding",
",",
"errors",
")",
".",
"splitlines",
"(",
"retain",
")"
] | r""" Open this file, read all lines, return them in a list.
Optional arguments:
`encoding` - The Unicode encoding (or character set) of
the file. The default is ``None``, meaning the content
of the file is read as 8-bit characters and returned
as a l... | [
"r",
"Open",
"this",
"file",
"read",
"all",
"lines",
"return",
"them",
"in",
"a",
"list",
"."
] | python | train | 51.833333 |
mushkevych/scheduler | synergy/conf/__init__.py | https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/conf/__init__.py#L133-L147 | def _setup(self):
"""
Load the settings module pointed to by the environment variable. This
is used the first time we need any settings at all, if the user has not
previously configured the settings manually.
"""
settings_module = os.environ.get(ENVIRONMENT_SETTINGS_VARIA... | [
"def",
"_setup",
"(",
"self",
")",
":",
"settings_module",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"ENVIRONMENT_SETTINGS_VARIABLE",
",",
"'settings'",
")",
"if",
"not",
"settings_module",
":",
"raise",
"ImproperlyConfigured",
"(",
"'Requested settings module poi... | Load the settings module pointed to by the environment variable. This
is used the first time we need any settings at all, if the user has not
previously configured the settings manually. | [
"Load",
"the",
"settings",
"module",
"pointed",
"to",
"by",
"the",
"environment",
"variable",
".",
"This",
"is",
"used",
"the",
"first",
"time",
"we",
"need",
"any",
"settings",
"at",
"all",
"if",
"the",
"user",
"has",
"not",
"previously",
"configured",
"t... | python | train | 50.533333 |
openvax/varcode | varcode/variant_collection.py | https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/variant_collection.py#L237-L255 | def _merge_metadata_dictionaries(cls, dictionaries):
"""
Helper function for combining variant collections: given multiple
dictionaries mapping:
source name -> (variant -> (attribute -> value))
Returns dictionary with union of all variants and sources.
"""
#... | [
"def",
"_merge_metadata_dictionaries",
"(",
"cls",
",",
"dictionaries",
")",
":",
"# three levels of nested dictionaries!",
"# {source name: {variant: {attribute: value}}}",
"combined_dictionary",
"=",
"{",
"}",
"for",
"source_to_metadata_dict",
"in",
"dictionaries",
":",
"fo... | Helper function for combining variant collections: given multiple
dictionaries mapping:
source name -> (variant -> (attribute -> value))
Returns dictionary with union of all variants and sources. | [
"Helper",
"function",
"for",
"combining",
"variant",
"collections",
":",
"given",
"multiple",
"dictionaries",
"mapping",
":",
"source",
"name",
"-",
">",
"(",
"variant",
"-",
">",
"(",
"attribute",
"-",
">",
"value",
"))"
] | python | train | 50.526316 |
cloudtools/troposphere | scripts/gen.py | https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/scripts/gen.py#L227-L240 | def _output_validators(self):
"""Output common validator types based on usage."""
if self._walk_for_type('Boolean'):
print("from .validators import boolean")
if self._walk_for_type('Integer'):
print("from .validators import integer")
vlist = self.override.get_vali... | [
"def",
"_output_validators",
"(",
"self",
")",
":",
"if",
"self",
".",
"_walk_for_type",
"(",
"'Boolean'",
")",
":",
"print",
"(",
"\"from .validators import boolean\"",
")",
"if",
"self",
".",
"_walk_for_type",
"(",
"'Integer'",
")",
":",
"print",
"(",
"\"fro... | Output common validator types based on usage. | [
"Output",
"common",
"validator",
"types",
"based",
"on",
"usage",
"."
] | python | train | 45.071429 |
PixelwarStudio/PyTree | Tree/core.py | https://github.com/PixelwarStudio/PyTree/blob/f14b25ea145da6b00d836e34251d2a4c823766dc/Tree/core.py#L217-L223 | def _get_node_parent(self, age, pos):
"""Get the parent node of node, whch is located in tree's node list.
Returns:
object: The parent node.
"""
return self.nodes[age][int(pos / self.comp)] | [
"def",
"_get_node_parent",
"(",
"self",
",",
"age",
",",
"pos",
")",
":",
"return",
"self",
".",
"nodes",
"[",
"age",
"]",
"[",
"int",
"(",
"pos",
"/",
"self",
".",
"comp",
")",
"]"
] | Get the parent node of node, whch is located in tree's node list.
Returns:
object: The parent node. | [
"Get",
"the",
"parent",
"node",
"of",
"node",
"whch",
"is",
"located",
"in",
"tree",
"s",
"node",
"list",
"."
] | python | train | 32.571429 |
mrcagney/gtfstk | gtfstk/stops.py | https://github.com/mrcagney/gtfstk/blob/c91494e6fefc02523889655a0dc92d1c0eee8d03/gtfstk/stops.py#L581-L607 | def build_null_stop_time_series(
feed: "Feed",
date_label: str = "20010101",
freq: str = "5Min",
*,
split_directions: bool = False,
) -> DataFrame:
"""
Return a stop time series with the same index and hierarchical columns
as output by :func:`compute_stop_time_series_base`,
but fill ... | [
"def",
"build_null_stop_time_series",
"(",
"feed",
":",
"\"Feed\"",
",",
"date_label",
":",
"str",
"=",
"\"20010101\"",
",",
"freq",
":",
"str",
"=",
"\"5Min\"",
",",
"*",
",",
"split_directions",
":",
"bool",
"=",
"False",
",",
")",
"->",
"DataFrame",
":"... | Return a stop time series with the same index and hierarchical columns
as output by :func:`compute_stop_time_series_base`,
but fill it full of null values. | [
"Return",
"a",
"stop",
"time",
"series",
"with",
"the",
"same",
"index",
"and",
"hierarchical",
"columns",
"as",
"output",
"by",
":",
"func",
":",
"compute_stop_time_series_base",
"but",
"fill",
"it",
"full",
"of",
"null",
"values",
"."
] | python | train | 32.259259 |
MisterY/gnucash-portfolio | gnucash_portfolio/lib/datetimeutils.py | https://github.com/MisterY/gnucash-portfolio/blob/bfaad8345a5479d1cd111acee1939e25c2a638c2/gnucash_portfolio/lib/datetimeutils.py#L34-L52 | def parse_period(period: str):
""" parses period from date range picker. The received values are full ISO date """
period = period.split(" - ")
date_from = Datum()
if len(period[0]) == 10:
date_from.from_iso_date_string(period[0])
else:
date_from.from_iso_long_date(period[0])
da... | [
"def",
"parse_period",
"(",
"period",
":",
"str",
")",
":",
"period",
"=",
"period",
".",
"split",
"(",
"\" - \"",
")",
"date_from",
"=",
"Datum",
"(",
")",
"if",
"len",
"(",
"period",
"[",
"0",
"]",
")",
"==",
"10",
":",
"date_from",
".",
"from_is... | parses period from date range picker. The received values are full ISO date | [
"parses",
"period",
"from",
"date",
"range",
"picker",
".",
"The",
"received",
"values",
"are",
"full",
"ISO",
"date"
] | python | train | 28.842105 |
Cognexa/cxflow | cxflow/cli/train.py | https://github.com/Cognexa/cxflow/blob/dd609e6b0bd854424a8f86781dd77801a13038f9/cxflow/cli/train.py#L11-L29 | def train(config_path: str, cl_arguments: Iterable[str], output_root: str) -> None:
"""
Load config and start the training.
:param config_path: path to configuration file
:param cl_arguments: additional command line arguments which will update the configuration
:param output_root: output root in wh... | [
"def",
"train",
"(",
"config_path",
":",
"str",
",",
"cl_arguments",
":",
"Iterable",
"[",
"str",
"]",
",",
"output_root",
":",
"str",
")",
"->",
"None",
":",
"config",
"=",
"None",
"try",
":",
"config_path",
"=",
"find_config",
"(",
"config_path",
")",
... | Load config and start the training.
:param config_path: path to configuration file
:param cl_arguments: additional command line arguments which will update the configuration
:param output_root: output root in which the training directory will be created | [
"Load",
"config",
"and",
"start",
"the",
"training",
"."
] | python | train | 39.526316 |
SmartTeleMax/iktomi | iktomi/cli/sqla.py | https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/cli/sqla.py#L86-L113 | def command_create_tables(self, meta_name=None, verbose=False):
'''
Create tables according sqlalchemy data model.
Is not a complex migration tool like alembic, just creates tables that
does not exist::
./manage.py sqla:create_tables [--verbose] [meta_name]
'''
... | [
"def",
"command_create_tables",
"(",
"self",
",",
"meta_name",
"=",
"None",
",",
"verbose",
"=",
"False",
")",
":",
"def",
"_create_metadata_tables",
"(",
"metadata",
")",
":",
"for",
"table",
"in",
"metadata",
".",
"sorted_tables",
":",
"if",
"verbose",
":"... | Create tables according sqlalchemy data model.
Is not a complex migration tool like alembic, just creates tables that
does not exist::
./manage.py sqla:create_tables [--verbose] [meta_name] | [
"Create",
"tables",
"according",
"sqlalchemy",
"data",
"model",
"."
] | python | train | 39.071429 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.