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 |
|---|---|---|---|---|---|---|---|---|---|
andrewramsay/sk8-drivers | pysk8/calibration/sk8_calibration_gui.py | https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/calibration/sk8_calibration_gui.py#L285-L288 | def imu_changed(self, val):
"""Handle clicks on the IMU index spinner."""
self.current_imuid = '{}_IMU{}'.format(self.sk8.get_device_name(), val)
self.update_data_display(self.get_current_data()) | [
"def",
"imu_changed",
"(",
"self",
",",
"val",
")",
":",
"self",
".",
"current_imuid",
"=",
"'{}_IMU{}'",
".",
"format",
"(",
"self",
".",
"sk8",
".",
"get_device_name",
"(",
")",
",",
"val",
")",
"self",
".",
"update_data_display",
"(",
"self",
".",
"... | Handle clicks on the IMU index spinner. | [
"Handle",
"clicks",
"on",
"the",
"IMU",
"index",
"spinner",
"."
] | python | train | 54 |
ecell/ecell4 | ecell4/extra/ensemble.py | https://github.com/ecell/ecell4/blob/a4a1229661c39b2059adbbacae9090e5ba664e01/ecell4/extra/ensemble.py#L503-L523 | def run_azure(target, jobs, n=1, nproc=None, path='.', delete=True, config=None, **kwargs):
"""
Evaluate the given function with each set of arguments, and return a list of results.
This function does in parallel with Microsoft Azure Batch.
This function is the work in progress.
The argument `nproc... | [
"def",
"run_azure",
"(",
"target",
",",
"jobs",
",",
"n",
"=",
"1",
",",
"nproc",
"=",
"None",
",",
"path",
"=",
"'.'",
",",
"delete",
"=",
"True",
",",
"config",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"ecell4",
".",
"extra",
... | Evaluate the given function with each set of arguments, and return a list of results.
This function does in parallel with Microsoft Azure Batch.
This function is the work in progress.
The argument `nproc` doesn't work yet.
See `ecell4.extra.azure_batch.run_azure` for details.
See Also
--------... | [
"Evaluate",
"the",
"given",
"function",
"with",
"each",
"set",
"of",
"arguments",
"and",
"return",
"a",
"list",
"of",
"results",
".",
"This",
"function",
"does",
"in",
"parallel",
"with",
"Microsoft",
"Azure",
"Batch",
"."
] | python | train | 36.380952 |
minio/minio-py | minio/api.py | https://github.com/minio/minio-py/blob/7107c84183cf5fb4deff68c0a16ab9f1c0b4c37e/minio/api.py#L1712-L1747 | def _complete_multipart_upload(self, bucket_name, object_name,
upload_id, uploaded_parts):
"""
Complete an active multipart upload request.
:param bucket_name: Bucket name of the multipart request.
:param object_name: Object name of the multipart reque... | [
"def",
"_complete_multipart_upload",
"(",
"self",
",",
"bucket_name",
",",
"object_name",
",",
"upload_id",
",",
"uploaded_parts",
")",
":",
"is_valid_bucket_name",
"(",
"bucket_name",
")",
"is_non_empty_string",
"(",
"object_name",
")",
"is_non_empty_string",
"(",
"u... | Complete an active multipart upload request.
:param bucket_name: Bucket name of the multipart request.
:param object_name: Object name of the multipart request.
:param upload_id: Upload id of the active multipart request.
:param uploaded_parts: Key, Value dictionary of uploaded parts. | [
"Complete",
"an",
"active",
"multipart",
"upload",
"request",
"."
] | python | train | 40.527778 |
hasgeek/coaster | coaster/sqlalchemy/mixins.py | https://github.com/hasgeek/coaster/blob/07f7eb5d5f516e22fa14fdf4dc70e0ae13ee398d/coaster/sqlalchemy/mixins.py#L517-L529 | def short_title(self):
"""
Generates an abbreviated title by subtracting the parent's title from this instance's title.
"""
if self.title and self.parent is not None and hasattr(self.parent, 'title') and self.parent.title:
if self.title.startswith(self.parent.title):
... | [
"def",
"short_title",
"(",
"self",
")",
":",
"if",
"self",
".",
"title",
"and",
"self",
".",
"parent",
"is",
"not",
"None",
"and",
"hasattr",
"(",
"self",
".",
"parent",
",",
"'title'",
")",
"and",
"self",
".",
"parent",
".",
"title",
":",
"if",
"s... | Generates an abbreviated title by subtracting the parent's title from this instance's title. | [
"Generates",
"an",
"abbreviated",
"title",
"by",
"subtracting",
"the",
"parent",
"s",
"title",
"from",
"this",
"instance",
"s",
"title",
"."
] | python | train | 45.153846 |
luismasuelli/django-trackmodels-ritual | grimoire/django/tracked/reports.py | https://github.com/luismasuelli/django-trackmodels-ritual/blob/ee0a6e07a5851ed477c9c1e3b9f8aafd9da35657/grimoire/django/tracked/reports.py#L300-L310 | def dump_report_content(self, request, result):
"""
Dumps the content to a string, suitable to being written on a file.
:param result: The result being processed.
:return: string
"""
output = StringIO()
writer = csv.writer(output, **self.csv_kwargs)
write... | [
"def",
"dump_report_content",
"(",
"self",
",",
"request",
",",
"result",
")",
":",
"output",
"=",
"StringIO",
"(",
")",
"writer",
"=",
"csv",
".",
"writer",
"(",
"output",
",",
"*",
"*",
"self",
".",
"csv_kwargs",
")",
"writer",
".",
"writerows",
"(",... | Dumps the content to a string, suitable to being written on a file.
:param result: The result being processed.
:return: string | [
"Dumps",
"the",
"content",
"to",
"a",
"string",
"suitable",
"to",
"being",
"written",
"on",
"a",
"file",
".",
":",
"param",
"result",
":",
"The",
"result",
"being",
"processed",
".",
":",
"return",
":",
"string"
] | python | train | 35.272727 |
InfoAgeTech/django-core | django_core/auth/views.py | https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/auth/views.py#L54-L60 | def get_authorization_user(self, **kwargs):
"""Gets the user the authorization object is for."""
if self.authorization_user is not None:
return self.authorization_user
self.authorization_user = self.request.user
return self.request.user | [
"def",
"get_authorization_user",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"authorization_user",
"is",
"not",
"None",
":",
"return",
"self",
".",
"authorization_user",
"self",
".",
"authorization_user",
"=",
"self",
".",
"request",
"... | Gets the user the authorization object is for. | [
"Gets",
"the",
"user",
"the",
"authorization",
"object",
"is",
"for",
"."
] | python | train | 39.285714 |
rackerlabs/silverberg | scripts/python-lint.py | https://github.com/rackerlabs/silverberg/blob/c6fae78923a019f1615e9516ab30fa105c72a542/scripts/python-lint.py#L24-L49 | def lint(to_lint):
"""
Run all linters against a list of files.
:param to_lint: a list of files to lint.
"""
exit_code = 0
for linter, options in (('pyflakes', []), ('pep8', [])):
try:
output = local[linter](*(options + to_lint))
except commands.ProcessExecutionErro... | [
"def",
"lint",
"(",
"to_lint",
")",
":",
"exit_code",
"=",
"0",
"for",
"linter",
",",
"options",
"in",
"(",
"(",
"'pyflakes'",
",",
"[",
"]",
")",
",",
"(",
"'pep8'",
",",
"[",
"]",
")",
")",
":",
"try",
":",
"output",
"=",
"local",
"[",
"linte... | Run all linters against a list of files.
:param to_lint: a list of files to lint. | [
"Run",
"all",
"linters",
"against",
"a",
"list",
"of",
"files",
"."
] | python | train | 24.115385 |
gtaylor/petfinder-api | petfinder/exceptions.py | https://github.com/gtaylor/petfinder-api/blob/4f1bc76c276d537208c9b11f7c87282f6d2bb50d/petfinder/exceptions.py#L93-L113 | def _get_exception_class_from_status_code(status_code):
"""
Utility function that accepts a status code, and spits out a reference
to the correct exception class to raise.
:param str status_code: The status code to return an exception class for.
:rtype: PetfinderAPIError or None
:returns: The a... | [
"def",
"_get_exception_class_from_status_code",
"(",
"status_code",
")",
":",
"if",
"status_code",
"==",
"'100'",
":",
"return",
"None",
"exc_class",
"=",
"STATUS_CODE_MAPPING",
".",
"get",
"(",
"status_code",
")",
"if",
"not",
"exc_class",
":",
"# No status code ma... | Utility function that accepts a status code, and spits out a reference
to the correct exception class to raise.
:param str status_code: The status code to return an exception class for.
:rtype: PetfinderAPIError or None
:returns: The appropriate PetfinderAPIError subclass. If the status code
is... | [
"Utility",
"function",
"that",
"accepts",
"a",
"status",
"code",
"and",
"spits",
"out",
"a",
"reference",
"to",
"the",
"correct",
"exception",
"class",
"to",
"raise",
"."
] | python | train | 35.142857 |
DancingQuanta/pyusbiss | usbiss/spi.py | https://github.com/DancingQuanta/pyusbiss/blob/fc64e123f1c97f53ad153c474d230ad38044c3cb/usbiss/spi.py#L118-L140 | def exchange(self, data):
"""
Perform SPI transaction.
The first received byte is either ACK or NACK.
:TODO: enforce rule that up to 63 bytes of data can be sent.
:TODO: enforce rule that there is no gaps in data bytes (what define a gap?)
:param data: List of bytes
... | [
"def",
"exchange",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"_usbiss",
".",
"write_data",
"(",
"[",
"self",
".",
"_usbiss",
".",
"SPI_CMD",
"]",
"+",
"data",
")",
"response",
"=",
"self",
".",
"_usbiss",
".",
"read_data",
"(",
"1",
"+",
"le... | Perform SPI transaction.
The first received byte is either ACK or NACK.
:TODO: enforce rule that up to 63 bytes of data can be sent.
:TODO: enforce rule that there is no gaps in data bytes (what define a gap?)
:param data: List of bytes
:returns: List of bytes
:rtype: ... | [
"Perform",
"SPI",
"transaction",
"."
] | python | train | 35.478261 |
ConsenSys/mythril-classic | mythril/ethereum/interface/leveldb/client.py | https://github.com/ConsenSys/mythril-classic/blob/27af71c34b2ce94f4fae5613ec457f93df1a8f56/mythril/ethereum/interface/leveldb/client.py#L286-L293 | def eth_getCode(self, address):
"""Get account code.
:param address:
:return:
"""
account = self.reader._get_account(address)
return _encode_hex(account.code) | [
"def",
"eth_getCode",
"(",
"self",
",",
"address",
")",
":",
"account",
"=",
"self",
".",
"reader",
".",
"_get_account",
"(",
"address",
")",
"return",
"_encode_hex",
"(",
"account",
".",
"code",
")"
] | Get account code.
:param address:
:return: | [
"Get",
"account",
"code",
"."
] | python | train | 25 |
androguard/androguard | androguard/core/bytecodes/dvm.py | https://github.com/androguard/androguard/blob/984c0d981be2950cf0451e484f7b0d4d53bc4911/androguard/core/bytecodes/dvm.py#L8281-L8293 | def disassemble(self, offset, size):
"""
Disassembles a given offset in the DEX file
:param offset: offset to disassemble in the file (from the beginning of the file)
:type offset: int
:param size:
:type size:
"""
for i in DCode(
self.CM, ... | [
"def",
"disassemble",
"(",
"self",
",",
"offset",
",",
"size",
")",
":",
"for",
"i",
"in",
"DCode",
"(",
"self",
".",
"CM",
",",
"offset",
",",
"size",
",",
"self",
".",
"get_buff",
"(",
")",
"[",
"offset",
":",
"offset",
"+",
"size",
"]",
")",
... | Disassembles a given offset in the DEX file
:param offset: offset to disassemble in the file (from the beginning of the file)
:type offset: int
:param size:
:type size: | [
"Disassembles",
"a",
"given",
"offset",
"in",
"the",
"DEX",
"file"
] | python | train | 32 |
xeroc/python-graphenelib | graphenestorage/__init__.py | https://github.com/xeroc/python-graphenelib/blob/8bb5396bc79998ee424cf3813af478304173f3a6/graphenestorage/__init__.py#L27-L35 | def get_default_key_store(*args, config, **kwargs):
""" This method returns the default **key** store
that uses an SQLite database internally.
:params str appname: The appname that is used internally to distinguish
different SQLite files
"""
kwargs["appname"] = kwargs.get("appna... | [
"def",
"get_default_key_store",
"(",
"*",
"args",
",",
"config",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"\"appname\"",
"]",
"=",
"kwargs",
".",
"get",
"(",
"\"appname\"",
",",
"\"graphene\"",
")",
"return",
"SqliteEncryptedKeyStore",
"(",
"config"... | This method returns the default **key** store
that uses an SQLite database internally.
:params str appname: The appname that is used internally to distinguish
different SQLite files | [
"This",
"method",
"returns",
"the",
"default",
"**",
"key",
"**",
"store",
"that",
"uses",
"an",
"SQLite",
"database",
"internally",
"."
] | python | valid | 43.111111 |
apacha/OMR-Datasets | omrdatasettools/downloaders/MuscimaPlusPlusDatasetDownloader.py | https://github.com/apacha/OMR-Datasets/blob/d0a22a03ae35caeef211729efa340e1ec0e01ea5/omrdatasettools/downloaders/MuscimaPlusPlusDatasetDownloader.py#L33-L54 | def download_and_extract_dataset(self, destination_directory: str):
"""
Downloads and extracts the MUSCIMA++ dataset along with the images from the CVC-MUSCIMA dataset
that were manually annotated (140 out of 1000 images).
"""
if not os.path.exists(self.get_dataset_filename()):
... | [
"def",
"download_and_extract_dataset",
"(",
"self",
",",
"destination_directory",
":",
"str",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"get_dataset_filename",
"(",
")",
")",
":",
"print",
"(",
"\"Downloading MUSCIMA++ Dataset...... | Downloads and extracts the MUSCIMA++ dataset along with the images from the CVC-MUSCIMA dataset
that were manually annotated (140 out of 1000 images). | [
"Downloads",
"and",
"extracts",
"the",
"MUSCIMA",
"++",
"dataset",
"along",
"with",
"the",
"images",
"from",
"the",
"CVC",
"-",
"MUSCIMA",
"dataset",
"that",
"were",
"manually",
"annotated",
"(",
"140",
"out",
"of",
"1000",
"images",
")",
"."
] | python | train | 57.681818 |
inveniosoftware/invenio-accounts | invenio_accounts/forms.py | https://github.com/inveniosoftware/invenio-accounts/blob/b0d2f0739b00dbefea22ca15d7d374a1b4a63aec/invenio_accounts/forms.py#L43-L52 | def register_form_factory(Form, app):
"""Return extended registration form."""
if app.config.get('RECAPTCHA_PUBLIC_KEY') and \
app.config.get('RECAPTCHA_PRIVATE_KEY'):
class RegisterForm(Form):
recaptcha = FormField(RegistrationFormRecaptcha, separator='.')
return Regist... | [
"def",
"register_form_factory",
"(",
"Form",
",",
"app",
")",
":",
"if",
"app",
".",
"config",
".",
"get",
"(",
"'RECAPTCHA_PUBLIC_KEY'",
")",
"and",
"app",
".",
"config",
".",
"get",
"(",
"'RECAPTCHA_PRIVATE_KEY'",
")",
":",
"class",
"RegisterForm",
"(",
... | Return extended registration form. | [
"Return",
"extended",
"registration",
"form",
"."
] | python | train | 33.4 |
timeyyy/apptools | peasoup/peasoup.py | https://github.com/timeyyy/apptools/blob/d3c0f324b0c2689c35f5601348276f4efd6cb240/peasoup/peasoup.py#L64-L71 | def save(self):
'''saves our config objet to file'''
if self.app.cfg_mode == 'json':
with open(self.app.cfg_file, 'w') as opened_file:
json.dump(self.app.cfg, opened_file)
else:
with open(self.app.cfg_file, 'w')as opened_file:
yaml.dump(sel... | [
"def",
"save",
"(",
"self",
")",
":",
"if",
"self",
".",
"app",
".",
"cfg_mode",
"==",
"'json'",
":",
"with",
"open",
"(",
"self",
".",
"app",
".",
"cfg_file",
",",
"'w'",
")",
"as",
"opened_file",
":",
"json",
".",
"dump",
"(",
"self",
".",
"app... | saves our config objet to file | [
"saves",
"our",
"config",
"objet",
"to",
"file"
] | python | train | 42 |
spulec/moto | moto/packages/httpretty/core.py | https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/packages/httpretty/core.py#L809-L837 | def get_next_entry(self, method, info, request):
"""Cycle through available responses, but only once.
Any subsequent requests will receive the last response"""
if method not in self.current_entries:
self.current_entries[method] = 0
# restrict selection to entries that match... | [
"def",
"get_next_entry",
"(",
"self",
",",
"method",
",",
"info",
",",
"request",
")",
":",
"if",
"method",
"not",
"in",
"self",
".",
"current_entries",
":",
"self",
".",
"current_entries",
"[",
"method",
"]",
"=",
"0",
"# restrict selection to entries that ma... | Cycle through available responses, but only once.
Any subsequent requests will receive the last response | [
"Cycle",
"through",
"available",
"responses",
"but",
"only",
"once",
".",
"Any",
"subsequent",
"requests",
"will",
"receive",
"the",
"last",
"response"
] | python | train | 39.896552 |
deepmind/sonnet | sonnet/python/modules/util.py | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/util.py#L881-L894 | def name_for_callable(func):
"""Returns a module name for a callable or `None` if no name can be found."""
if isinstance(func, functools.partial):
return name_for_callable(func.func)
try:
name = func.__name__
except AttributeError:
return None
if name == "<lambda>":
return None
else:
r... | [
"def",
"name_for_callable",
"(",
"func",
")",
":",
"if",
"isinstance",
"(",
"func",
",",
"functools",
".",
"partial",
")",
":",
"return",
"name_for_callable",
"(",
"func",
".",
"func",
")",
"try",
":",
"name",
"=",
"func",
".",
"__name__",
"except",
"Att... | Returns a module name for a callable or `None` if no name can be found. | [
"Returns",
"a",
"module",
"name",
"for",
"a",
"callable",
"or",
"None",
"if",
"no",
"name",
"can",
"be",
"found",
"."
] | python | train | 23.714286 |
the01/python-paps | paps/si/app/sensor.py | https://github.com/the01/python-paps/blob/2dde5a71913e4c7b22901cf05c6ecedd890919c4/paps/si/app/sensor.py#L374-L386 | def stop(self):
"""
Stop the interface
:rtype: None
"""
should_sleep = self._is_running
super(Sensor, self).stop()
if should_sleep:
# Make sure everything has enough time to exit
time.sleep(max(self._select_timeout, self._retransmit_timeou... | [
"def",
"stop",
"(",
"self",
")",
":",
"should_sleep",
"=",
"self",
".",
"_is_running",
"super",
"(",
"Sensor",
",",
"self",
")",
".",
"stop",
"(",
")",
"if",
"should_sleep",
":",
"# Make sure everything has enough time to exit",
"time",
".",
"sleep",
"(",
"m... | Stop the interface
:rtype: None | [
"Stop",
"the",
"interface"
] | python | train | 30.923077 |
suds-community/suds | suds/argparser.py | https://github.com/suds-community/suds/blob/6fb0a829337b5037a66c20aae6f89b41acd77e40/suds/argparser.py#L124-L147 | def __all_parameters_processed(self):
"""
Finish the argument processing.
Should be called after all the web service operation's parameters have
been successfully processed and, afterwards, no further parameter
processing is allowed.
Returns a 2-tuple containing the num... | [
"def",
"__all_parameters_processed",
"(",
"self",
")",
":",
"assert",
"self",
".",
"active",
"(",
")",
"sentinel_frame",
"=",
"self",
".",
"__stack",
"[",
"0",
"]",
"self",
".",
"__pop_frames_above",
"(",
"sentinel_frame",
")",
"assert",
"len",
"(",
"self",
... | Finish the argument processing.
Should be called after all the web service operation's parameters have
been successfully processed and, afterwards, no further parameter
processing is allowed.
Returns a 2-tuple containing the number of required & allowed
arguments.
See ... | [
"Finish",
"the",
"argument",
"processing",
"."
] | python | train | 36.333333 |
KelSolaar/Umbra | umbra/managers/file_system_events_manager.py | https://github.com/KelSolaar/Umbra/blob/66f45f08d9d723787f1191989f8b0dda84b412ce/umbra/managers/file_system_events_manager.py#L406-L421 | def unregister_path(self, path):
"""
Unregisters given path.
:param path: Path name.
:type path: unicode
:return: Method success.
:rtype: bool
"""
if not path in self:
raise umbra.exceptions.PathExistsError("{0} | '{1}' path isn't registered!... | [
"def",
"unregister_path",
"(",
"self",
",",
"path",
")",
":",
"if",
"not",
"path",
"in",
"self",
":",
"raise",
"umbra",
".",
"exceptions",
".",
"PathExistsError",
"(",
"\"{0} | '{1}' path isn't registered!\"",
".",
"format",
"(",
"self",
".",
"__class__",
".",... | Unregisters given path.
:param path: Path name.
:type path: unicode
:return: Method success.
:rtype: bool | [
"Unregisters",
"given",
"path",
"."
] | python | train | 26 |
simpleai-team/simpleai | simpleai/machine_learning/classifiers.py | https://github.com/simpleai-team/simpleai/blob/2836befa7e970013f62e0ee75562652aacac6f65/simpleai/machine_learning/classifiers.py#L322-L334 | def _max_gain_split(self, examples):
"""
Returns an OnlineInformationGain of the attribute with
max gain based on `examples`.
"""
gains = self._new_set_of_gain_counters()
for example in examples:
for gain in gains:
gain.add(example)
win... | [
"def",
"_max_gain_split",
"(",
"self",
",",
"examples",
")",
":",
"gains",
"=",
"self",
".",
"_new_set_of_gain_counters",
"(",
")",
"for",
"example",
"in",
"examples",
":",
"for",
"gain",
"in",
"gains",
":",
"gain",
".",
"add",
"(",
"example",
")",
"winn... | Returns an OnlineInformationGain of the attribute with
max gain based on `examples`. | [
"Returns",
"an",
"OnlineInformationGain",
"of",
"the",
"attribute",
"with",
"max",
"gain",
"based",
"on",
"examples",
"."
] | python | train | 36.769231 |
annoviko/pyclustering | pyclustering/container/kdtree.py | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/container/kdtree.py#L459-L473 | def find_node(self, point, cur_node = None):
"""!
@brief Find node with coordinates that are defined by specified point.
@details If node with specified parameters does not exist then None will be returned,
otherwise required node will be returned.
@para... | [
"def",
"find_node",
"(",
"self",
",",
"point",
",",
"cur_node",
"=",
"None",
")",
":",
"rule_search",
"=",
"lambda",
"node",
",",
"point",
"=",
"point",
":",
"self",
".",
"__point_comparator",
"(",
"node",
".",
"data",
",",
"point",
")",
"return",
"sel... | !
@brief Find node with coordinates that are defined by specified point.
@details If node with specified parameters does not exist then None will be returned,
otherwise required node will be returned.
@param[in] point (list): Coordinates of the point whose node s... | [
"!"
] | python | valid | 50.266667 |
etcher-be/emiz | emiz/miz.py | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/miz.py#L334-L364 | def zip(self, destination: typing.Union[str, Path] = None, encode: bool = True) -> str:
"""
Write mission, dictionary etc. to a MIZ file
Args:
destination: target MIZ file (if none, defaults to source MIZ + "_EMIZ"
Returns: destination file
"""
if encode:
... | [
"def",
"zip",
"(",
"self",
",",
"destination",
":",
"typing",
".",
"Union",
"[",
"str",
",",
"Path",
"]",
"=",
"None",
",",
"encode",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"if",
"encode",
":",
"self",
".",
"_encode",
"(",
")",
"if",
... | Write mission, dictionary etc. to a MIZ file
Args:
destination: target MIZ file (if none, defaults to source MIZ + "_EMIZ"
Returns: destination file | [
"Write",
"mission",
"dictionary",
"etc",
".",
"to",
"a",
"MIZ",
"file"
] | python | train | 35.548387 |
MartijnBraam/pyElectronics | electronics/devices/bmp180.py | https://github.com/MartijnBraam/pyElectronics/blob/a20878c9fa190135f1e478e9ea0b54ca43ff308e/electronics/devices/bmp180.py#L87-L104 | def temperature(self):
"""Get the temperature from the sensor.
:returns: The temperature in degree celcius as a float
:example:
>>> sensor = BMP180(gw)
>>> sensor.load_calibration()
>>> sensor.temperature()
21.4
"""
ut = self.get_raw_temp()
... | [
"def",
"temperature",
"(",
"self",
")",
":",
"ut",
"=",
"self",
".",
"get_raw_temp",
"(",
")",
"x1",
"=",
"(",
"(",
"ut",
"-",
"self",
".",
"cal",
"[",
"'AC6'",
"]",
")",
"*",
"self",
".",
"cal",
"[",
"'AC5'",
"]",
")",
">>",
"15",
"x2",
"=",... | Get the temperature from the sensor.
:returns: The temperature in degree celcius as a float
:example:
>>> sensor = BMP180(gw)
>>> sensor.load_calibration()
>>> sensor.temperature()
21.4 | [
"Get",
"the",
"temperature",
"from",
"the",
"sensor",
"."
] | python | train | 26.611111 |
recurly/recurly-client-python | recurly/__init__.py | https://github.com/recurly/recurly-client-python/blob/682217c4e85ec5c8d4e41519ee0620d2dc4d84d7/recurly/__init__.py#L362-L367 | def create_shipping_address(self, shipping_address):
"""Creates a shipping address on an existing account. If you are
creating an account, you can embed the shipping addresses with the
request"""
url = urljoin(self._url, '/shipping_addresses')
return shipping_address.post(url) | [
"def",
"create_shipping_address",
"(",
"self",
",",
"shipping_address",
")",
":",
"url",
"=",
"urljoin",
"(",
"self",
".",
"_url",
",",
"'/shipping_addresses'",
")",
"return",
"shipping_address",
".",
"post",
"(",
"url",
")"
] | Creates a shipping address on an existing account. If you are
creating an account, you can embed the shipping addresses with the
request | [
"Creates",
"a",
"shipping",
"address",
"on",
"an",
"existing",
"account",
".",
"If",
"you",
"are",
"creating",
"an",
"account",
"you",
"can",
"embed",
"the",
"shipping",
"addresses",
"with",
"the",
"request"
] | python | train | 52 |
phoebe-project/phoebe2 | phoebe/parameters/constraint.py | https://github.com/phoebe-project/phoebe2/blob/e64b8be683977064e2d55dd1b3ac400f64c3e379/phoebe/parameters/constraint.py#L189-L193 | def t0_supconj_to_perpass(t0_supconj, period, ecc, per0):
"""
TODO: add documentation
"""
return ConstraintParameter(t0_supconj._bundle, "t0_supconj_to_perpass({}, {}, {}, {})".format(_get_expr(t0_supconj), _get_expr(period), _get_expr(ecc), _get_expr(per0))) | [
"def",
"t0_supconj_to_perpass",
"(",
"t0_supconj",
",",
"period",
",",
"ecc",
",",
"per0",
")",
":",
"return",
"ConstraintParameter",
"(",
"t0_supconj",
".",
"_bundle",
",",
"\"t0_supconj_to_perpass({}, {}, {}, {})\"",
".",
"format",
"(",
"_get_expr",
"(",
"t0_supco... | TODO: add documentation | [
"TODO",
":",
"add",
"documentation"
] | python | train | 54.2 |
AtteqCom/zsl | src/zsl/resource/json_server_resource.py | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/resource/json_server_resource.py#L233-L247 | def update(self, *args, **kwargs):
"""Modifies the parameters and adds metadata for update results.
Currently it does not support `PUT` method, which works as replacing
the resource. This is somehow questionable in relation DB.
"""
if request.method == 'PUT':
logging... | [
"def",
"update",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"request",
".",
"method",
"==",
"'PUT'",
":",
"logging",
".",
"warning",
"(",
"\"Called not implemented resource method PUT\"",
")",
"resource",
"=",
"super",
"(",
"Js... | Modifies the parameters and adds metadata for update results.
Currently it does not support `PUT` method, which works as replacing
the resource. This is somehow questionable in relation DB. | [
"Modifies",
"the",
"parameters",
"and",
"adds",
"metadata",
"for",
"update",
"results",
"."
] | python | train | 35.266667 |
juju/python-libjuju | juju/model.py | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/model.py#L2097-L2164 | async def deploy(self, charm, series, application, options, constraints,
storage, endpoint_bindings, *args):
"""
:param charm string:
Charm holds the URL of the charm to be used to deploy this
application.
:param series string:
Series hol... | [
"async",
"def",
"deploy",
"(",
"self",
",",
"charm",
",",
"series",
",",
"application",
",",
"options",
",",
"constraints",
",",
"storage",
",",
"endpoint_bindings",
",",
"*",
"args",
")",
":",
"# resolve indirect references",
"charm",
"=",
"self",
".",
"res... | :param charm string:
Charm holds the URL of the charm to be used to deploy this
application.
:param series string:
Series holds the series of the application to be deployed
if the charm default is not sufficient.
:param application string:
Ap... | [
":",
"param",
"charm",
"string",
":",
"Charm",
"holds",
"the",
"URL",
"of",
"the",
"charm",
"to",
"be",
"used",
"to",
"deploy",
"this",
"application",
"."
] | python | train | 36.367647 |
tonysimpson/nanomsg-python | _nanomsg_ctypes/__init__.py | https://github.com/tonysimpson/nanomsg-python/blob/3acd9160f90f91034d4a43ce603aaa19fbaf1f2e/_nanomsg_ctypes/__init__.py#L224-L244 | def nn_poll(fds, timeout=-1):
"""
nn_pollfds
:param fds: dict (file descriptor => pollmode)
:param timeout: timeout in milliseconds
:return:
"""
polls = []
for i, entry in enumerate(fds.items()):
s = PollFds()
fd, event = entry
s.fd = fd
s.events = event
... | [
"def",
"nn_poll",
"(",
"fds",
",",
"timeout",
"=",
"-",
"1",
")",
":",
"polls",
"=",
"[",
"]",
"for",
"i",
",",
"entry",
"in",
"enumerate",
"(",
"fds",
".",
"items",
"(",
")",
")",
":",
"s",
"=",
"PollFds",
"(",
")",
"fd",
",",
"event",
"=",
... | nn_pollfds
:param fds: dict (file descriptor => pollmode)
:param timeout: timeout in milliseconds
:return: | [
"nn_pollfds",
":",
"param",
"fds",
":",
"dict",
"(",
"file",
"descriptor",
"=",
">",
"pollmode",
")",
":",
"param",
"timeout",
":",
"timeout",
"in",
"milliseconds",
":",
"return",
":"
] | python | train | 26.047619 |
pantsbuild/pants | src/python/pants/ivy/ivy.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/ivy/ivy.py#L74-L94 | def execute(self, jvm_options=None, args=None, executor=None,
workunit_factory=None, workunit_name=None, workunit_labels=None):
"""Executes the ivy commandline client with the given args.
Raises Ivy.Error if the command fails for any reason.
:param executor: Java executor to run ivy with.
... | [
"def",
"execute",
"(",
"self",
",",
"jvm_options",
"=",
"None",
",",
"args",
"=",
"None",
",",
"executor",
"=",
"None",
",",
"workunit_factory",
"=",
"None",
",",
"workunit_name",
"=",
"None",
",",
"workunit_labels",
"=",
"None",
")",
":",
"# NB(gmalmquist... | Executes the ivy commandline client with the given args.
Raises Ivy.Error if the command fails for any reason.
:param executor: Java executor to run ivy with. | [
"Executes",
"the",
"ivy",
"commandline",
"client",
"with",
"the",
"given",
"args",
"."
] | python | train | 57.714286 |
apache/airflow | airflow/utils/log/gcs_task_handler.py | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/log/gcs_task_handler.py#L132-L163 | def gcs_write(self, log, remote_log_location, append=True):
"""
Writes the log to the remote_log_location. Fails silently if no hook
was created.
:param log: the log to write to the remote_log_location
:type log: str
:param remote_log_location: the log's location in remot... | [
"def",
"gcs_write",
"(",
"self",
",",
"log",
",",
"remote_log_location",
",",
"append",
"=",
"True",
")",
":",
"if",
"append",
":",
"try",
":",
"old_log",
"=",
"self",
".",
"gcs_read",
"(",
"remote_log_location",
")",
"log",
"=",
"'\\n'",
".",
"join",
... | Writes the log to the remote_log_location. Fails silently if no hook
was created.
:param log: the log to write to the remote_log_location
:type log: str
:param remote_log_location: the log's location in remote storage
:type remote_log_location: str (path)
:param append: i... | [
"Writes",
"the",
"log",
"to",
"the",
"remote_log_location",
".",
"Fails",
"silently",
"if",
"no",
"hook",
"was",
"created",
".",
":",
"param",
"log",
":",
"the",
"log",
"to",
"write",
"to",
"the",
"remote_log_location",
":",
"type",
"log",
":",
"str",
":... | python | test | 46.1875 |
BerkeleyAutomation/autolab_core | autolab_core/data_stream_recorder.py | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/data_stream_recorder.py#L209-L217 | def _stop(self):
""" Stops recording. Returns all recorded data and their timestamps. Destroys recorder process."""
self._pause()
self._cmds_q.put(("stop",))
try:
self._recorder.terminate()
except Exception:
pass
self._recording = False | [
"def",
"_stop",
"(",
"self",
")",
":",
"self",
".",
"_pause",
"(",
")",
"self",
".",
"_cmds_q",
".",
"put",
"(",
"(",
"\"stop\"",
",",
")",
")",
"try",
":",
"self",
".",
"_recorder",
".",
"terminate",
"(",
")",
"except",
"Exception",
":",
"pass",
... | Stops recording. Returns all recorded data and their timestamps. Destroys recorder process. | [
"Stops",
"recording",
".",
"Returns",
"all",
"recorded",
"data",
"and",
"their",
"timestamps",
".",
"Destroys",
"recorder",
"process",
"."
] | python | train | 33.333333 |
walkr/nanoservice | benchmarks/bench_req_rep.py | https://github.com/walkr/nanoservice/blob/e2098986b1baa5f283167ae487d14f3c6c21961a/benchmarks/bench_req_rep.py#L8-L21 | def start_service(addr, n):
""" Start a service """
s = Service(addr)
s.register('add', lambda x, y: x + y)
started = time.time()
for _ in range(n):
s.process()
duration = time.time() - started
time.sleep(0.1)
print('Service stats:')
util.print_stats(n, duration)
return | [
"def",
"start_service",
"(",
"addr",
",",
"n",
")",
":",
"s",
"=",
"Service",
"(",
"addr",
")",
"s",
".",
"register",
"(",
"'add'",
",",
"lambda",
"x",
",",
"y",
":",
"x",
"+",
"y",
")",
"started",
"=",
"time",
".",
"time",
"(",
")",
"for",
"... | Start a service | [
"Start",
"a",
"service"
] | python | train | 21.928571 |
merll/docker-fabric | dockerfabric/apiclient.py | https://github.com/merll/docker-fabric/blob/785d84e40e17265b667d8b11a6e30d8e6b2bf8d4/dockerfabric/apiclient.py#L223-L237 | def pull(self, repository, tag=None, stream=True, **kwargs):
"""
Identical to :meth:`dockermap.client.base.DockerClientWrapper.pull` with two enhancements:
* additional logging;
* the ``insecure_registry`` flag can be passed through ``kwargs``, or set as default using
``env.do... | [
"def",
"pull",
"(",
"self",
",",
"repository",
",",
"tag",
"=",
"None",
",",
"stream",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"c_insecure",
"=",
"kwargs",
".",
"pop",
"(",
"'insecure_registry'",
",",
"env",
".",
"get",
"(",
"'docker_registry_i... | Identical to :meth:`dockermap.client.base.DockerClientWrapper.pull` with two enhancements:
* additional logging;
* the ``insecure_registry`` flag can be passed through ``kwargs``, or set as default using
``env.docker_registry_insecure``. | [
"Identical",
"to",
":",
"meth",
":",
"dockermap",
".",
"client",
".",
"base",
".",
"DockerClientWrapper",
".",
"pull",
"with",
"two",
"enhancements",
":"
] | python | train | 49.133333 |
BerkeleyAutomation/perception | perception/image.py | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L761-L771 | def nonzero_pixels(self):
""" Return an array of the nonzero pixels.
Returns
-------
:obj:`numpy.ndarray`
Nx2 array of the nonzero pixels
"""
nonzero_px = np.where(np.sum(self.raw_data, axis=2) > 0)
nonzero_px = np.c_[nonzero_px[0], nonzero_px[1]]
... | [
"def",
"nonzero_pixels",
"(",
"self",
")",
":",
"nonzero_px",
"=",
"np",
".",
"where",
"(",
"np",
".",
"sum",
"(",
"self",
".",
"raw_data",
",",
"axis",
"=",
"2",
")",
">",
"0",
")",
"nonzero_px",
"=",
"np",
".",
"c_",
"[",
"nonzero_px",
"[",
"0"... | Return an array of the nonzero pixels.
Returns
-------
:obj:`numpy.ndarray`
Nx2 array of the nonzero pixels | [
"Return",
"an",
"array",
"of",
"the",
"nonzero",
"pixels",
"."
] | python | train | 30.272727 |
joedborg/CoPing | CoPing/ping.py | https://github.com/joedborg/CoPing/blob/2239729ee4107b999c1cba696d94f7d48ab73d36/CoPing/ping.py#L194-L232 | def send_one_ping(self, current_socket):
"""
Send one ICMP ECHO_REQUEST.
"""
# Header is type (8), code (8), checksum (16), id (16), sequence (16)
checksum = 0
# Make a dummy header with a 0 checksum.
header = struct.pack(
"!BBHHH", ICMP_ECHO, 0, chec... | [
"def",
"send_one_ping",
"(",
"self",
",",
"current_socket",
")",
":",
"# Header is type (8), code (8), checksum (16), id (16), sequence (16)",
"checksum",
"=",
"0",
"# Make a dummy header with a 0 checksum.",
"header",
"=",
"struct",
".",
"pack",
"(",
"\"!BBHHH\"",
",",
"IC... | Send one ICMP ECHO_REQUEST. | [
"Send",
"one",
"ICMP",
"ECHO_REQUEST",
"."
] | python | train | 33.564103 |
observermedia/django-wordpress-rest | wordpress/loading.py | https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L807-L816 | def get_or_create_media(self, api_media):
"""
Find or create a Media object given API data.
:param api_media: the API data for the Media
:return: a tuple of an Media instance and a boolean indicating whether the Media was created or not
"""
return Media.objects.get_or_cr... | [
"def",
"get_or_create_media",
"(",
"self",
",",
"api_media",
")",
":",
"return",
"Media",
".",
"objects",
".",
"get_or_create",
"(",
"site_id",
"=",
"self",
".",
"site_id",
",",
"wp_id",
"=",
"api_media",
"[",
"\"ID\"",
"]",
",",
"defaults",
"=",
"self",
... | Find or create a Media object given API data.
:param api_media: the API data for the Media
:return: a tuple of an Media instance and a boolean indicating whether the Media was created or not | [
"Find",
"or",
"create",
"a",
"Media",
"object",
"given",
"API",
"data",
"."
] | python | train | 49.7 |
StackStorm/pybind | pybind/slxos/v17r_1_01a/brocade_mpls_rpc/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17r_1_01a/brocade_mpls_rpc/__init__.py#L1047-L1068 | def _set_show_mpls_rsvp(self, v, load=False):
"""
Setter method for show_mpls_rsvp, mapped from YANG variable /brocade_mpls_rpc/show_mpls_rsvp (rpc)
If this variable is read-only (config: false) in the
source YANG file, then _set_show_mpls_rsvp is considered as a private
method. Backends looking to ... | [
"def",
"_set_show_mpls_rsvp",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
... | Setter method for show_mpls_rsvp, mapped from YANG variable /brocade_mpls_rpc/show_mpls_rsvp (rpc)
If this variable is read-only (config: false) in the
source YANG file, then _set_show_mpls_rsvp is considered as a private
method. Backends looking to populate this variable should
do so via calling thisOb... | [
"Setter",
"method",
"for",
"show_mpls_rsvp",
"mapped",
"from",
"YANG",
"variable",
"/",
"brocade_mpls_rpc",
"/",
"show_mpls_rsvp",
"(",
"rpc",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"(",
"config",
":",
"false",
")",
"in",
"the",
"source",
... | python | train | 72.590909 |
frascoweb/frasco | frasco/commands.py | https://github.com/frascoweb/frasco/blob/ea519d69dd5ca6deaf3650175692ee4a1a02518f/frasco/commands.py#L76-L99 | def as_command(self):
"""Creates the click command wrapping the function
"""
try:
params = self.unbound_func.__click_params__
params.reverse()
del self.unbound_func.__click_params__
except AttributeError:
params = []
help = inspect.... | [
"def",
"as_command",
"(",
"self",
")",
":",
"try",
":",
"params",
"=",
"self",
".",
"unbound_func",
".",
"__click_params__",
"params",
".",
"reverse",
"(",
")",
"del",
"self",
".",
"unbound_func",
".",
"__click_params__",
"except",
"AttributeError",
":",
"pa... | Creates the click command wrapping the function | [
"Creates",
"the",
"click",
"command",
"wrapping",
"the",
"function"
] | python | train | 41.375 |
PyHDI/Pyverilog | pyverilog/vparser/parser.py | https://github.com/PyHDI/Pyverilog/blob/b852cc5ed6a7a2712e33639f9d9782d0d1587a53/pyverilog/vparser/parser.py#L927-L930 | def p_expression_ulnot(self, p):
'expression : LNOT expression %prec ULNOT'
p[0] = Ulnot(p[2], lineno=p.lineno(1))
p.set_lineno(0, p.lineno(1)) | [
"def",
"p_expression_ulnot",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"Ulnot",
"(",
"p",
"[",
"2",
"]",
",",
"lineno",
"=",
"p",
".",
"lineno",
"(",
"1",
")",
")",
"p",
".",
"set_lineno",
"(",
"0",
",",
"p",
".",
"lineno",
... | expression : LNOT expression %prec ULNOT | [
"expression",
":",
"LNOT",
"expression",
"%prec",
"ULNOT"
] | python | train | 41 |
Parsl/parsl | parsl/providers/jetstream/jetstream.py | https://github.com/Parsl/parsl/blob/d7afb3bc37f50dcf224ae78637944172edb35dac/parsl/providers/jetstream/jetstream.py#L119-L129 | def scale_in(self, blocks=0, machines=0, strategy=None):
''' Scale in resources
'''
count = 0
instances = self.client.servers.list()
for instance in instances[0:machines]:
print("Deleting : ", instance)
instance.delete()
count += 1
ret... | [
"def",
"scale_in",
"(",
"self",
",",
"blocks",
"=",
"0",
",",
"machines",
"=",
"0",
",",
"strategy",
"=",
"None",
")",
":",
"count",
"=",
"0",
"instances",
"=",
"self",
".",
"client",
".",
"servers",
".",
"list",
"(",
")",
"for",
"instance",
"in",
... | Scale in resources | [
"Scale",
"in",
"resources"
] | python | valid | 29 |
seequent/properties | properties/base/instance.py | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/base/instance.py#L125-L139 | def serialize(self, value, **kwargs):
"""Serialize instance to JSON
If the value is a HasProperties instance, it is serialized with
the include_class argument passed along. Otherwise, to_json is
called.
"""
kwargs.update({'include_class': kwargs.get('include_class', True... | [
"def",
"serialize",
"(",
"self",
",",
"value",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"update",
"(",
"{",
"'include_class'",
":",
"kwargs",
".",
"get",
"(",
"'include_class'",
",",
"True",
")",
"}",
")",
"if",
"self",
".",
"serializer",
"i... | Serialize instance to JSON
If the value is a HasProperties instance, it is serialized with
the include_class argument passed along. Otherwise, to_json is
called. | [
"Serialize",
"instance",
"to",
"JSON"
] | python | train | 39.066667 |
couchbase/couchbase-python-client | couchbase/bucket.py | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/bucket.py#L1274-L1294 | def endure_multi(self, keys, persist_to=-1, replicate_to=-1,
timeout=5.0, interval=0.010, check_removed=False):
"""Check durability requirements for multiple keys
:param keys: The keys to check
The type of keys may be one of the following:
* Sequence of keys
... | [
"def",
"endure_multi",
"(",
"self",
",",
"keys",
",",
"persist_to",
"=",
"-",
"1",
",",
"replicate_to",
"=",
"-",
"1",
",",
"timeout",
"=",
"5.0",
",",
"interval",
"=",
"0.010",
",",
"check_removed",
"=",
"False",
")",
":",
"return",
"_Base",
".",
"e... | Check durability requirements for multiple keys
:param keys: The keys to check
The type of keys may be one of the following:
* Sequence of keys
* A :class:`~couchbase.result.MultiResult` object
* A ``dict`` with CAS values as the dictionary value
* A seq... | [
"Check",
"durability",
"requirements",
"for",
"multiple",
"keys"
] | python | train | 43.095238 |
astrocatalogs/astrocats | astrocats/catalog/entry.py | https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L881-L902 | def get_source_by_alias(self, alias):
"""Given an alias, find the corresponding source in this entry.
If the given alias doesn't exist (e.g. there are no sources), then a
`ValueError` is raised.
Arguments
---------
alias : str
The str-integer (e.g. '8') of t... | [
"def",
"get_source_by_alias",
"(",
"self",
",",
"alias",
")",
":",
"for",
"source",
"in",
"self",
".",
"get",
"(",
"self",
".",
"_KEYS",
".",
"SOURCES",
",",
"[",
"]",
")",
":",
"if",
"source",
"[",
"self",
".",
"_KEYS",
".",
"ALIAS",
"]",
"==",
... | Given an alias, find the corresponding source in this entry.
If the given alias doesn't exist (e.g. there are no sources), then a
`ValueError` is raised.
Arguments
---------
alias : str
The str-integer (e.g. '8') of the target source.
Returns
------... | [
"Given",
"an",
"alias",
"find",
"the",
"corresponding",
"source",
"in",
"this",
"entry",
"."
] | python | train | 33.363636 |
mehmetg/streak_client | streak_client/streak_client.py | https://github.com/mehmetg/streak_client/blob/46575510b4e4163a4a3cc06f7283a1ae377cdce6/streak_client/streak_client.py#L685-L703 | def get_box_field(self, box_key, field_key = None):
'''Gets one/all field in a box
Args:
box_key key for pipeline
field_key key for field (default: None i.e. ALL)
returns status code, field dict or list thereof
'''
#does not work
self._raise_unimplemented_error()
uri = '/'.join([self.api... | [
"def",
"get_box_field",
"(",
"self",
",",
"box_key",
",",
"field_key",
"=",
"None",
")",
":",
"#does not work",
"self",
".",
"_raise_unimplemented_error",
"(",
")",
"uri",
"=",
"'/'",
".",
"join",
"(",
"[",
"self",
".",
"api_uri",
",",
"self",
".",
"boxe... | Gets one/all field in a box
Args:
box_key key for pipeline
field_key key for field (default: None i.e. ALL)
returns status code, field dict or list thereof | [
"Gets",
"one",
"/",
"all",
"field",
"in",
"a",
"box",
"Args",
":",
"box_key",
"key",
"for",
"pipeline",
"field_key",
"key",
"for",
"field",
"(",
"default",
":",
"None",
"i",
".",
"e",
".",
"ALL",
")",
"returns",
"status",
"code",
"field",
"dict",
"or... | python | train | 24.473684 |
etcher-be/emiz | emiz/avwx/service.py | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/service.py#L128-L134 | def _extract(self, raw: str, station: str) -> str: # type: ignore
"""
Extracts the reports message using string finding
"""
report = raw[raw.find(station.upper() + ' '):]
report = report[:report.find(' =')]
return report | [
"def",
"_extract",
"(",
"self",
",",
"raw",
":",
"str",
",",
"station",
":",
"str",
")",
"->",
"str",
":",
"# type: ignore",
"report",
"=",
"raw",
"[",
"raw",
".",
"find",
"(",
"station",
".",
"upper",
"(",
")",
"+",
"' '",
")",
":",
"]",
"report... | Extracts the reports message using string finding | [
"Extracts",
"the",
"reports",
"message",
"using",
"string",
"finding"
] | python | train | 37.571429 |
SUSE-Enceladus/ipa | ipa/ipa_gce.py | https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_gce.py#L244-L263 | def _validate_region(self):
"""Validate region was passed in and is a valid GCE zone."""
if not self.region:
raise GCECloudException(
'Zone is required for GCE cloud framework: '
'Example: us-west1-a'
)
try:
zone = self.compute... | [
"def",
"_validate_region",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"region",
":",
"raise",
"GCECloudException",
"(",
"'Zone is required for GCE cloud framework: '",
"'Example: us-west1-a'",
")",
"try",
":",
"zone",
"=",
"self",
".",
"compute_driver",
".",
... | Validate region was passed in and is a valid GCE zone. | [
"Validate",
"region",
"was",
"passed",
"in",
"and",
"is",
"a",
"valid",
"GCE",
"zone",
"."
] | python | train | 30.6 |
gbiggs/rtsprofile | rtsprofile/config_set.py | https://github.com/gbiggs/rtsprofile/blob/fded6eddcb0b25fe9808b1b12336a4413ea00905/rtsprofile/config_set.py#L216-L220 | def save_xml(self, doc, element):
'''Save this configuration data into an xml.dom.Element object.'''
element.setAttributeNS(RTS_NS, RTS_NS_S + 'name', self.name)
if self.data:
element.setAttributeNS(RTS_NS, RTS_NS_S + 'data', self.data) | [
"def",
"save_xml",
"(",
"self",
",",
"doc",
",",
"element",
")",
":",
"element",
".",
"setAttributeNS",
"(",
"RTS_NS",
",",
"RTS_NS_S",
"+",
"'name'",
",",
"self",
".",
"name",
")",
"if",
"self",
".",
"data",
":",
"element",
".",
"setAttributeNS",
"(",... | Save this configuration data into an xml.dom.Element object. | [
"Save",
"this",
"configuration",
"data",
"into",
"an",
"xml",
".",
"dom",
".",
"Element",
"object",
"."
] | python | train | 53.6 |
DLR-RM/RAFCON | source/rafcon/gui/mygaphas/utils/gap_helper.py | https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/mygaphas/utils/gap_helper.py#L200-L265 | def add_transition_to_state(from_port, to_port):
"""Interface method between Gaphas and RAFCON core for adding transitions
The method checks the types of the given ports (IncomeView or OutcomeView) and from this determines the necessary
parameters for the add_transition method of the RAFCON core. Also the ... | [
"def",
"add_transition_to_state",
"(",
"from_port",
",",
"to_port",
")",
":",
"from",
"rafcon",
".",
"gui",
".",
"mygaphas",
".",
"items",
".",
"ports",
"import",
"IncomeView",
",",
"OutcomeView",
"from_state_v",
"=",
"from_port",
".",
"parent",
"to_state_v",
... | Interface method between Gaphas and RAFCON core for adding transitions
The method checks the types of the given ports (IncomeView or OutcomeView) and from this determines the necessary
parameters for the add_transition method of the RAFCON core. Also the parent state is derived from the ports.
:param from... | [
"Interface",
"method",
"between",
"Gaphas",
"and",
"RAFCON",
"core",
"for",
"adding",
"transitions"
] | python | train | 43.454545 |
JasonKessler/scattertext | scattertext/TermDocMatrix.py | https://github.com/JasonKessler/scattertext/blob/cacf1f687d218ee8cae3fc05cc901db824bb1b81/scattertext/TermDocMatrix.py#L298-L310 | def remove_terms_by_indices(self, idx_to_delete_list):
'''
Parameters
----------
idx_to_delete_list, list
Returns
-------
TermDocMatrix
'''
new_X, new_term_idx_store = self._get_X_after_delete_terms(idx_to_delete_list)
return self._make_ne... | [
"def",
"remove_terms_by_indices",
"(",
"self",
",",
"idx_to_delete_list",
")",
":",
"new_X",
",",
"new_term_idx_store",
"=",
"self",
".",
"_get_X_after_delete_terms",
"(",
"idx_to_delete_list",
")",
"return",
"self",
".",
"_make_new_term_doc_matrix",
"(",
"new_X",
","... | Parameters
----------
idx_to_delete_list, list
Returns
-------
TermDocMatrix | [
"Parameters",
"----------",
"idx_to_delete_list",
"list"
] | python | train | 37.615385 |
Microsoft/azure-devops-python-api | azure-devops/azure/devops/v5_0/build/build_client.py | https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/build/build_client.py#L550-L574 | def get_changes_between_builds(self, project, from_build_id=None, to_build_id=None, top=None):
"""GetChangesBetweenBuilds.
[Preview API] Gets the changes made to the repository between two given builds.
:param str project: Project ID or project name
:param int from_build_id: The ID of th... | [
"def",
"get_changes_between_builds",
"(",
"self",
",",
"project",
",",
"from_build_id",
"=",
"None",
",",
"to_build_id",
"=",
"None",
",",
"top",
"=",
"None",
")",
":",
"route_values",
"=",
"{",
"}",
"if",
"project",
"is",
"not",
"None",
":",
"route_values... | GetChangesBetweenBuilds.
[Preview API] Gets the changes made to the repository between two given builds.
:param str project: Project ID or project name
:param int from_build_id: The ID of the first build.
:param int to_build_id: The ID of the last build.
:param int top: The maxim... | [
"GetChangesBetweenBuilds",
".",
"[",
"Preview",
"API",
"]",
"Gets",
"the",
"changes",
"made",
"to",
"the",
"repository",
"between",
"two",
"given",
"builds",
".",
":",
"param",
"str",
"project",
":",
"Project",
"ID",
"or",
"project",
"name",
":",
"param",
... | python | train | 56.84 |
reorx/torext | torext/script.py | https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/script.py#L241-L258 | def command(self, profile=False):
"""This is a Flask-Script like decorator, provide functionality like
@manager.command
def foo():
pass
@manager.command
def foo(first_arg, second_arg, first_option=True, second_option=3):
pass
"""
def wrape... | [
"def",
"command",
"(",
"self",
",",
"profile",
"=",
"False",
")",
":",
"def",
"wraped",
"(",
"func",
")",
":",
"assert",
"inspect",
".",
"isfunction",
"(",
"func",
")",
"self",
".",
"_commands",
"[",
"func",
".",
"__name__",
"]",
"=",
"Command",
"(",... | This is a Flask-Script like decorator, provide functionality like
@manager.command
def foo():
pass
@manager.command
def foo(first_arg, second_arg, first_option=True, second_option=3):
pass | [
"This",
"is",
"a",
"Flask",
"-",
"Script",
"like",
"decorator",
"provide",
"functionality",
"like",
"@manager",
".",
"command",
"def",
"foo",
"()",
":",
"pass"
] | python | train | 29.111111 |
kwikteam/phy | phy/plot/panzoom.py | https://github.com/kwikteam/phy/blob/7e9313dc364304b7d2bd03b92938347343703003/phy/plot/panzoom.py#L464-L483 | def attach(self, canvas):
"""Attach this interact to a canvas."""
super(PanZoom, self).attach(canvas)
canvas.panzoom = self
canvas.transforms.add_on_gpu([self._translate, self._scale])
# Add the variable declarations.
vs = ('uniform vec2 {};\n'.format(self.pan_var_name) ... | [
"def",
"attach",
"(",
"self",
",",
"canvas",
")",
":",
"super",
"(",
"PanZoom",
",",
"self",
")",
".",
"attach",
"(",
"canvas",
")",
"canvas",
".",
"panzoom",
"=",
"self",
"canvas",
".",
"transforms",
".",
"add_on_gpu",
"(",
"[",
"self",
".",
"_trans... | Attach this interact to a canvas. | [
"Attach",
"this",
"interact",
"to",
"a",
"canvas",
"."
] | python | train | 34.9 |
disqus/disqus-python | disqusapi/utils.py | https://github.com/disqus/disqus-python/blob/605f33c7b735fcb85e16041c27658fbba49d7a7b/disqusapi/utils.py#L90-L98 | def get_body_hash(params):
"""
Returns BASE64 ( HASH (text) ) as described in OAuth2 MAC spec.
http://tools.ietf.org/html/draft-ietf-oauth-v2-http-mac-00#section-3.2
"""
norm_params = get_normalized_params(params)
return binascii.b2a_base64(hashlib.sha1(norm_params).digest())[:-1] | [
"def",
"get_body_hash",
"(",
"params",
")",
":",
"norm_params",
"=",
"get_normalized_params",
"(",
"params",
")",
"return",
"binascii",
".",
"b2a_base64",
"(",
"hashlib",
".",
"sha1",
"(",
"norm_params",
")",
".",
"digest",
"(",
")",
")",
"[",
":",
"-",
... | Returns BASE64 ( HASH (text) ) as described in OAuth2 MAC spec.
http://tools.ietf.org/html/draft-ietf-oauth-v2-http-mac-00#section-3.2 | [
"Returns",
"BASE64",
"(",
"HASH",
"(",
"text",
")",
")",
"as",
"described",
"in",
"OAuth2",
"MAC",
"spec",
"."
] | python | train | 33.222222 |
EmbodiedCognition/pagoda | pagoda/parser.py | https://github.com/EmbodiedCognition/pagoda/blob/8892f847026d98aba8646ecbc4589397e6dec7bd/pagoda/parser.py#L263-L285 | def parse_asf(source, world, jointgroup=None, density=1000, color=None):
'''Load and parse a source file.
Parameters
----------
source : file
A file-like object that contains text information describing bodies and
joints to add to the world.
world : :class:`pagoda.physics.World`
... | [
"def",
"parse_asf",
"(",
"source",
",",
"world",
",",
"jointgroup",
"=",
"None",
",",
"density",
"=",
"1000",
",",
"color",
"=",
"None",
")",
":",
"visitor",
"=",
"AsfVisitor",
"(",
"world",
",",
"jointgroup",
",",
"density",
",",
"color",
")",
"visito... | Load and parse a source file.
Parameters
----------
source : file
A file-like object that contains text information describing bodies and
joints to add to the world.
world : :class:`pagoda.physics.World`
The world to add objects and joints to.
jointgroup : ode.JointGroup, op... | [
"Load",
"and",
"parse",
"a",
"source",
"file",
"."
] | python | valid | 43.434783 |
angr/claripy | claripy/vsa/strided_interval.py | https://github.com/angr/claripy/blob/4ed61924880af1ea8fb778047d896ec0156412a6/claripy/vsa/strided_interval.py#L2064-L2113 | def bitwise_or(self, t):
"""
Binary operation: logical or
:param b: The other operand
:return: self | b
"""
"""
This implementation combines the approaches used by 'WYSINWYX: what you see is not what you execute'
paper and 'Signedness-Agnostic Program Ana... | [
"def",
"bitwise_or",
"(",
"self",
",",
"t",
")",
":",
"\"\"\"\n This implementation combines the approaches used by 'WYSINWYX: what you see is not what you execute'\n paper and 'Signedness-Agnostic Program Analysis: Precise Integer Bounds for Low-Level Code'. The\n first paper p... | Binary operation: logical or
:param b: The other operand
:return: self | b | [
"Binary",
"operation",
":",
"logical",
"or"
] | python | train | 50.26 |
sdcooke/django_bundles | django_bundles/utils/__init__.py | https://github.com/sdcooke/django_bundles/blob/2810fc455ec7391283792c1f108f4e8340f5d12f/django_bundles/utils/__init__.py#L1-L21 | def get_class(class_string):
"""
Get a class from a dotted string
"""
split_string = class_string.encode('ascii').split('.')
import_path = '.'.join(split_string[:-1])
class_name = split_string[-1]
if class_name:
try:
if import_path:
mod = __import__(impor... | [
"def",
"get_class",
"(",
"class_string",
")",
":",
"split_string",
"=",
"class_string",
".",
"encode",
"(",
"'ascii'",
")",
".",
"split",
"(",
"'.'",
")",
"import_path",
"=",
"'.'",
".",
"join",
"(",
"split_string",
"[",
":",
"-",
"1",
"]",
")",
"class... | Get a class from a dotted string | [
"Get",
"a",
"class",
"from",
"a",
"dotted",
"string"
] | python | train | 28 |
fracpete/python-weka-wrapper3 | python/weka/classifiers.py | https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/classifiers.py#L573-L585 | def classifiers(self):
"""
Returns the list of base classifiers.
:return: the classifier list
:rtype: list
"""
objects = javabridge.get_env().get_object_array_elements(
javabridge.call(self.jobject, "getClassifiers", "()[Lweka/classifiers/Classifier;"))
... | [
"def",
"classifiers",
"(",
"self",
")",
":",
"objects",
"=",
"javabridge",
".",
"get_env",
"(",
")",
".",
"get_object_array_elements",
"(",
"javabridge",
".",
"call",
"(",
"self",
".",
"jobject",
",",
"\"getClassifiers\"",
",",
"\"()[Lweka/classifiers/Classifier;\... | Returns the list of base classifiers.
:return: the classifier list
:rtype: list | [
"Returns",
"the",
"list",
"of",
"base",
"classifiers",
"."
] | python | train | 32.538462 |
ninuxorg/nodeshot | nodeshot/community/mailing/models/outward.py | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/mailing/models/outward.py#L236-L245 | def save(self, *args, **kwargs):
"""
Custom save method
"""
# change status to scheduled if necessary
if self.is_scheduled and self.status is not OUTWARD_STATUS.get('scheduled'):
self.status = OUTWARD_STATUS.get('scheduled')
# call super.save()
super(... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# change status to scheduled if necessary",
"if",
"self",
".",
"is_scheduled",
"and",
"self",
".",
"status",
"is",
"not",
"OUTWARD_STATUS",
".",
"get",
"(",
"'scheduled'",
")",... | Custom save method | [
"Custom",
"save",
"method"
] | python | train | 34.7 |
mryellow/maze_explorer | mazeexp/engine/world_items.py | https://github.com/mryellow/maze_explorer/blob/ab8a25ccd05105d2fe57e0213d690cfc07e45827/mazeexp/engine/world_items.py#L116-L151 | def update_collisions(self):
"""
Test player for collisions with items
"""
if not self.mode['items'] or len(self.mode['items']) == 0: return
# update collman
# FIXME: Why update each frame?
self.collman.clear()
for z, node in self.children:
if... | [
"def",
"update_collisions",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"mode",
"[",
"'items'",
"]",
"or",
"len",
"(",
"self",
".",
"mode",
"[",
"'items'",
"]",
")",
"==",
"0",
":",
"return",
"# update collman",
"# FIXME: Why update each frame?",
"sel... | Test player for collisions with items | [
"Test",
"player",
"for",
"collisions",
"with",
"items"
] | python | train | 30.277778 |
lumpywizard/check_email_status | check_email_status/resolvers.py | https://github.com/lumpywizard/check_email_status/blob/3a4c5dc42ada61325d5d9baad9e2b1b78084ee2f/check_email_status/resolvers.py#L61-L76 | def get_mx_records(domain):
"""
Gets an array of MXRecords associated to the domain specified.
:param domain:
:return: [MXRecord]
"""
import dns.resolver
response = dns.resolver.query(domain, 'MX')
mx_records = []
for answer in response.answers:... | [
"def",
"get_mx_records",
"(",
"domain",
")",
":",
"import",
"dns",
".",
"resolver",
"response",
"=",
"dns",
".",
"resolver",
".",
"query",
"(",
"domain",
",",
"'MX'",
")",
"mx_records",
"=",
"[",
"]",
"for",
"answer",
"in",
"response",
".",
"answers",
... | Gets an array of MXRecords associated to the domain specified.
:param domain:
:return: [MXRecord] | [
"Gets",
"an",
"array",
"of",
"MXRecords",
"associated",
"to",
"the",
"domain",
"specified",
"."
] | python | train | 30.3125 |
ericmjl/nxviz | nxviz/plots.py | https://github.com/ericmjl/nxviz/blob/6ea5823a8030a686f165fbe37d7a04d0f037ecc9/nxviz/plots.py#L1018-L1027 | def draw(self):
"""
Draws the plot to screen.
Note to self: Do NOT call super(MatrixPlot, self).draw(); the
underlying logic for drawing here is completely different from other
plots, and as such necessitates a different implementation.
"""
matrix = nx.to_numpy_m... | [
"def",
"draw",
"(",
"self",
")",
":",
"matrix",
"=",
"nx",
".",
"to_numpy_matrix",
"(",
"self",
".",
"graph",
",",
"nodelist",
"=",
"self",
".",
"nodes",
")",
"self",
".",
"ax",
".",
"matshow",
"(",
"matrix",
",",
"cmap",
"=",
"self",
".",
"cmap",
... | Draws the plot to screen.
Note to self: Do NOT call super(MatrixPlot, self).draw(); the
underlying logic for drawing here is completely different from other
plots, and as such necessitates a different implementation. | [
"Draws",
"the",
"plot",
"to",
"screen",
"."
] | python | train | 39.7 |
NASA-AMMOS/AIT-Core | ait/core/dtype.py | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/dtype.py#L613-L628 | def decode(self, bytes, raw=False):
"""decode(bytearray, raw=False) -> value
Decodes the given bytearray and returns the number of
(fractional) seconds.
If the optional parameter ``raw`` is ``True``, the byte (U8)
itself will be returned.
"""
result = super(Tim... | [
"def",
"decode",
"(",
"self",
",",
"bytes",
",",
"raw",
"=",
"False",
")",
":",
"result",
"=",
"super",
"(",
"Time8Type",
",",
"self",
")",
".",
"decode",
"(",
"bytes",
")",
"if",
"not",
"raw",
":",
"result",
"/=",
"256.0",
"return",
"result"
] | decode(bytearray, raw=False) -> value
Decodes the given bytearray and returns the number of
(fractional) seconds.
If the optional parameter ``raw`` is ``True``, the byte (U8)
itself will be returned. | [
"decode",
"(",
"bytearray",
"raw",
"=",
"False",
")",
"-",
">",
"value"
] | python | train | 25.25 |
pantsbuild/pants | src/python/pants/goal/goal.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/goal/goal.py#L54-L79 | def register(cls, name, description, options_registrar_cls=None):
"""Register a goal description.
Otherwise the description must be set when registering some task on the goal,
which is clunky, and dependent on things like registration order of tasks in the goal.
A goal that isn't explicitly registered... | [
"def",
"register",
"(",
"cls",
",",
"name",
",",
"description",
",",
"options_registrar_cls",
"=",
"None",
")",
":",
"goal",
"=",
"cls",
".",
"by_name",
"(",
"name",
")",
"goal",
".",
"_description",
"=",
"description",
"goal",
".",
"_options_registrar_cls",... | Register a goal description.
Otherwise the description must be set when registering some task on the goal,
which is clunky, and dependent on things like registration order of tasks in the goal.
A goal that isn't explicitly registered with a description will fall back to the description
of the task in ... | [
"Register",
"a",
"goal",
"description",
"."
] | python | train | 51.269231 |
ns1/ns1-python | ns1/zones.py | https://github.com/ns1/ns1-python/blob/f3e1d90a3b76a1bd18f855f2c622a8a49d4b585e/ns1/zones.py#L228-L238 | def loadRecord(self, domain, rtype, callback=None, errback=None):
"""
Load a high level Record object from a domain within this Zone.
:param str domain: The name of the record to load
:param str rtype: The DNS record type
:rtype: ns1.records.Record
:return: new Record
... | [
"def",
"loadRecord",
"(",
"self",
",",
"domain",
",",
"rtype",
",",
"callback",
"=",
"None",
",",
"errback",
"=",
"None",
")",
":",
"rec",
"=",
"Record",
"(",
"self",
",",
"domain",
",",
"rtype",
")",
"return",
"rec",
".",
"load",
"(",
"callback",
... | Load a high level Record object from a domain within this Zone.
:param str domain: The name of the record to load
:param str rtype: The DNS record type
:rtype: ns1.records.Record
:return: new Record | [
"Load",
"a",
"high",
"level",
"Record",
"object",
"from",
"a",
"domain",
"within",
"this",
"Zone",
"."
] | python | train | 38.272727 |
PyHDI/Pyverilog | pyverilog/vparser/parser.py | https://github.com/PyHDI/Pyverilog/blob/b852cc5ed6a7a2712e33639f9d9782d0d1587a53/pyverilog/vparser/parser.py#L1277-L1279 | def p_always_comb(self, p):
'always_comb : ALWAYS_COMB senslist always_statement'
p[0] = AlwaysComb(p[2], p[3], lineno=p.lineno(1)) | [
"def",
"p_always_comb",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"AlwaysComb",
"(",
"p",
"[",
"2",
"]",
",",
"p",
"[",
"3",
"]",
",",
"lineno",
"=",
"p",
".",
"lineno",
"(",
"1",
")",
")"
] | always_comb : ALWAYS_COMB senslist always_statement | [
"always_comb",
":",
"ALWAYS_COMB",
"senslist",
"always_statement"
] | python | train | 48.333333 |
thisfred/val | val/_val.py | https://github.com/thisfred/val/blob/ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c/val/_val.py#L141-L153 | def _validate_type_key(key, value, types, validated):
"""Validate a key's value by type."""
for key_schema, value_schema in types.items():
if not isinstance(key, key_schema):
continue
try:
validated[key] = value_schema(value)
except NotValid:
continue
... | [
"def",
"_validate_type_key",
"(",
"key",
",",
"value",
",",
"types",
",",
"validated",
")",
":",
"for",
"key_schema",
",",
"value_schema",
"in",
"types",
".",
"items",
"(",
")",
":",
"if",
"not",
"isinstance",
"(",
"key",
",",
"key_schema",
")",
":",
"... | Validate a key's value by type. | [
"Validate",
"a",
"key",
"s",
"value",
"by",
"type",
"."
] | python | train | 30.230769 |
ParthKolekar/parthsql | parthsql/parthsql.py | https://github.com/ParthKolekar/parthsql/blob/98b69448aeaca1331c9db29bc85e731702a6b0d9/parthsql/parthsql.py#L28-L55 | def load_contents(self):
"""
Loads contents of the tables into database.
"""
with open(METADATA_FILE) as f:
lines = f.readlines()
lines = map(lambda x: x.strip(), lines)
exclude_strings = ['<begin_table>', '<end_table>']
list_of_databases_and_co... | [
"def",
"load_contents",
"(",
"self",
")",
":",
"with",
"open",
"(",
"METADATA_FILE",
")",
"as",
"f",
":",
"lines",
"=",
"f",
".",
"readlines",
"(",
")",
"lines",
"=",
"map",
"(",
"lambda",
"x",
":",
"x",
".",
"strip",
"(",
")",
",",
"lines",
")",... | Loads contents of the tables into database. | [
"Loads",
"contents",
"of",
"the",
"tables",
"into",
"database",
"."
] | python | train | 28.285714 |
jantman/pypi-download-stats | pypi_download_stats/dataquery.py | https://github.com/jantman/pypi-download-stats/blob/44a7a6bbcd61a9e7f02bd02c52584a98183f80c5/pypi_download_stats/dataquery.py#L582-L597 | def run_queries(self, backfill_num_days=7):
"""
Run the data queries for the specified projects.
:param backfill_num_days: number of days of historical data to backfill,
if missing
:type backfill_num_days: int
"""
available_tables = self._get_download_table_ids... | [
"def",
"run_queries",
"(",
"self",
",",
"backfill_num_days",
"=",
"7",
")",
":",
"available_tables",
"=",
"self",
".",
"_get_download_table_ids",
"(",
")",
"logger",
".",
"debug",
"(",
"'Found %d available download tables: %s'",
",",
"len",
"(",
"available_tables",
... | Run the data queries for the specified projects.
:param backfill_num_days: number of days of historical data to backfill,
if missing
:type backfill_num_days: int | [
"Run",
"the",
"data",
"queries",
"for",
"the",
"specified",
"projects",
"."
] | python | train | 42.3125 |
douban/brownant | brownant/app.py | https://github.com/douban/brownant/blob/3c7e6d30f67b8f0f8ca1f823ea3daed74e8725cd/brownant/app.py#L53-L81 | def validate_url(self, url):
"""Validate the :class:`~urllib.parse.ParseResult` object.
This method will make sure the :meth:`~brownant.app.BrownAnt.parse_url`
could work as expected even meet a unexpected URL string.
:param url: the parsed url.
:type url: :class:`~urllib.parse... | [
"def",
"validate_url",
"(",
"self",
",",
"url",
")",
":",
"# fix up the non-ascii path",
"url_path",
"=",
"to_bytes_safe",
"(",
"url",
".",
"path",
")",
"url_path",
"=",
"urllib",
".",
"parse",
".",
"quote",
"(",
"url_path",
",",
"safe",
"=",
"b\"/%\"",
")... | Validate the :class:`~urllib.parse.ParseResult` object.
This method will make sure the :meth:`~brownant.app.BrownAnt.parse_url`
could work as expected even meet a unexpected URL string.
:param url: the parsed url.
:type url: :class:`~urllib.parse.ParseResult` | [
"Validate",
"the",
":",
"class",
":",
"~urllib",
".",
"parse",
".",
"ParseResult",
"object",
"."
] | python | train | 39.241379 |
DocNow/twarc | twarc/client.py | https://github.com/DocNow/twarc/blob/47dd87d0c00592a4d583412c9d660ba574fc6f26/twarc/client.py#L438-L447 | def dehydrate(self, iterator):
"""
Pass in an iterator of tweets' JSON and get back an iterator of the
IDs of each tweet.
"""
for line in iterator:
try:
yield json.loads(line)['id_str']
except Exception as e:
log.error("uhoh... | [
"def",
"dehydrate",
"(",
"self",
",",
"iterator",
")",
":",
"for",
"line",
"in",
"iterator",
":",
"try",
":",
"yield",
"json",
".",
"loads",
"(",
"line",
")",
"[",
"'id_str'",
"]",
"except",
"Exception",
"as",
"e",
":",
"log",
".",
"error",
"(",
"\... | Pass in an iterator of tweets' JSON and get back an iterator of the
IDs of each tweet. | [
"Pass",
"in",
"an",
"iterator",
"of",
"tweets",
"JSON",
"and",
"get",
"back",
"an",
"iterator",
"of",
"the",
"IDs",
"of",
"each",
"tweet",
"."
] | python | train | 32.3 |
Othernet-Project/conz | conz/console.py | https://github.com/Othernet-Project/conz/blob/051214fa95a837c21595b03426a2c54c522d07a0/conz/console.py#L87-L89 | def pwa(self, val, wa='WARN'):
""" Print val: WARN in yellow on STDOUT """
self.pstd(self.color.yellow('{}: {}'.format(val, wa))) | [
"def",
"pwa",
"(",
"self",
",",
"val",
",",
"wa",
"=",
"'WARN'",
")",
":",
"self",
".",
"pstd",
"(",
"self",
".",
"color",
".",
"yellow",
"(",
"'{}: {}'",
".",
"format",
"(",
"val",
",",
"wa",
")",
")",
")"
] | Print val: WARN in yellow on STDOUT | [
"Print",
"val",
":",
"WARN",
"in",
"yellow",
"on",
"STDOUT"
] | python | train | 47.666667 |
ewels/MultiQC | multiqc/modules/fastp/fastp.py | https://github.com/ewels/MultiQC/blob/2037d6322b2554146a74efbf869156ad20d4c4ec/multiqc/modules/fastp/fastp.py#L368-L383 | def fastp_read_gc_plot(self):
""" Make the read GC plot for Fastp """
data_labels, pdata = self.filter_pconfig_pdata_subplots(self.fastp_gc_content_data, 'Base Content Percent')
pconfig = {
'id': 'fastp-seq-content-gc-plot',
'title': 'Fastp: Read GC Content',
... | [
"def",
"fastp_read_gc_plot",
"(",
"self",
")",
":",
"data_labels",
",",
"pdata",
"=",
"self",
".",
"filter_pconfig_pdata_subplots",
"(",
"self",
".",
"fastp_gc_content_data",
",",
"'Base Content Percent'",
")",
"pconfig",
"=",
"{",
"'id'",
":",
"'fastp-seq-content-g... | Make the read GC plot for Fastp | [
"Make",
"the",
"read",
"GC",
"plot",
"for",
"Fastp"
] | python | train | 41.375 |
dopefishh/pympi | pympi/Elan.py | https://github.com/dopefishh/pympi/blob/79c747cde45b5ba203ed93154d8c123ac9c3ef56/pympi/Elan.py#L1254-L1263 | def remove_tier(self, id_tier, clean=True):
"""Remove a tier.
:param str id_tier: Name of the tier.
:param bool clean: Flag to also clean the timeslots.
:raises KeyError: If tier is non existent.
"""
del(self.tiers[id_tier])
if clean:
self.clean_time_... | [
"def",
"remove_tier",
"(",
"self",
",",
"id_tier",
",",
"clean",
"=",
"True",
")",
":",
"del",
"(",
"self",
".",
"tiers",
"[",
"id_tier",
"]",
")",
"if",
"clean",
":",
"self",
".",
"clean_time_slots",
"(",
")"
] | Remove a tier.
:param str id_tier: Name of the tier.
:param bool clean: Flag to also clean the timeslots.
:raises KeyError: If tier is non existent. | [
"Remove",
"a",
"tier",
"."
] | python | test | 31.8 |
LordGaav/python-chaos | chaos/threading/scheduler.py | https://github.com/LordGaav/python-chaos/blob/52cd29a6fd15693ee1e53786b93bcb23fbf84ddd/chaos/threading/scheduler.py#L72-L88 | def setStartAction(self, action, *args, **kwargs):
"""
Set a function to call when run() is called, before the main action is called.
Parameters
----------
action: function pointer
The function to call.
*args
Positional arguments to pass to action.
**kwargs:
Keyword arguments to pass to action.
... | [
"def",
"setStartAction",
"(",
"self",
",",
"action",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"init_action",
"=",
"action",
"self",
".",
"init_args",
"=",
"args",
"self",
".",
"init_kwargs",
"=",
"kwargs"
] | Set a function to call when run() is called, before the main action is called.
Parameters
----------
action: function pointer
The function to call.
*args
Positional arguments to pass to action.
**kwargs:
Keyword arguments to pass to action. | [
"Set",
"a",
"function",
"to",
"call",
"when",
"run",
"()",
"is",
"called",
"before",
"the",
"main",
"action",
"is",
"called",
"."
] | python | train | 22.941176 |
lsst-sqre/documenteer | documenteer/sphinxext/lssttasks/topiclists.py | https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxext/lssttasks/topiclists.py#L74-L104 | def _build_toctree(self):
"""Create a hidden toctree node with the contents of a directory
prefixed by the directory name specified by the `toctree` directive
option.
"""
dirname = posixpath.dirname(self._env.docname)
tree_prefix = self.options['toctree'].strip()
... | [
"def",
"_build_toctree",
"(",
"self",
")",
":",
"dirname",
"=",
"posixpath",
".",
"dirname",
"(",
"self",
".",
"_env",
".",
"docname",
")",
"tree_prefix",
"=",
"self",
".",
"options",
"[",
"'toctree'",
"]",
".",
"strip",
"(",
")",
"root",
"=",
"posixpa... | Create a hidden toctree node with the contents of a directory
prefixed by the directory name specified by the `toctree` directive
option. | [
"Create",
"a",
"hidden",
"toctree",
"node",
"with",
"the",
"contents",
"of",
"a",
"directory",
"prefixed",
"by",
"the",
"directory",
"name",
"specified",
"by",
"the",
"toctree",
"directive",
"option",
"."
] | python | train | 44 |
bwohlberg/sporco | sporco/cnvrep.py | https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/cnvrep.py#L456-L477 | def stdformD(D, Cd, M, dimN=2):
"""Reshape dictionary array (`D` in :mod:`.admm.cbpdn` module, `X` in
:mod:`.admm.ccmod` module) to internal standard form.
Parameters
----------
D : array_like
Dictionary array
Cd : int
Size of dictionary channel index
M : int
Number of fil... | [
"def",
"stdformD",
"(",
"D",
",",
"Cd",
",",
"M",
",",
"dimN",
"=",
"2",
")",
":",
"return",
"D",
".",
"reshape",
"(",
"D",
".",
"shape",
"[",
"0",
":",
"dimN",
"]",
"+",
"(",
"Cd",
",",
")",
"+",
"(",
"1",
",",
")",
"+",
"(",
"M",
",",... | Reshape dictionary array (`D` in :mod:`.admm.cbpdn` module, `X` in
:mod:`.admm.ccmod` module) to internal standard form.
Parameters
----------
D : array_like
Dictionary array
Cd : int
Size of dictionary channel index
M : int
Number of filters in dictionary
dimN : int, opti... | [
"Reshape",
"dictionary",
"array",
"(",
"D",
"in",
":",
"mod",
":",
".",
"admm",
".",
"cbpdn",
"module",
"X",
"in",
":",
"mod",
":",
".",
"admm",
".",
"ccmod",
"module",
")",
"to",
"internal",
"standard",
"form",
"."
] | python | train | 24.409091 |
mitsei/dlkit | dlkit/primordium/locale/types/language.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/primordium/locale/types/language.py#L1234-L1261 | def get_type_data(name):
"""Return dictionary representation of type.
Can be used to initialize primordium.type.primitives.Type
"""
name = name.upper()
if name in ISO_LANGUAGE_CODES:
name = ISO_LANGUAGE_CODES[name]
if name in ISO_MAJOR_LANGUAGE_TYPES:
namespace = '639-2'
... | [
"def",
"get_type_data",
"(",
"name",
")",
":",
"name",
"=",
"name",
".",
"upper",
"(",
")",
"if",
"name",
"in",
"ISO_LANGUAGE_CODES",
":",
"name",
"=",
"ISO_LANGUAGE_CODES",
"[",
"name",
"]",
"if",
"name",
"in",
"ISO_MAJOR_LANGUAGE_TYPES",
":",
"namespace",
... | Return dictionary representation of type.
Can be used to initialize primordium.type.primitives.Type | [
"Return",
"dictionary",
"representation",
"of",
"type",
"."
] | python | train | 31.321429 |
Cornices/cornice.ext.swagger | cornice_swagger/swagger.py | https://github.com/Cornices/cornice.ext.swagger/blob/c31a5cc8d5dd112b11dc41ccb6d09b423b537abc/cornice_swagger/swagger.py#L687-L705 | def _extract_transform_colander_schema(self, args):
"""
Extract schema from view args and transform it using
the pipeline of schema transformers
:param args:
Arguments from the view decorator.
:rtype: colander.MappingSchema()
:returns: View schema cloned and... | [
"def",
"_extract_transform_colander_schema",
"(",
"self",
",",
"args",
")",
":",
"schema",
"=",
"args",
".",
"get",
"(",
"'schema'",
",",
"colander",
".",
"MappingSchema",
"(",
")",
")",
"if",
"not",
"isinstance",
"(",
"schema",
",",
"colander",
".",
"Sche... | Extract schema from view args and transform it using
the pipeline of schema transformers
:param args:
Arguments from the view decorator.
:rtype: colander.MappingSchema()
:returns: View schema cloned and transformed | [
"Extract",
"schema",
"from",
"view",
"args",
"and",
"transform",
"it",
"using",
"the",
"pipeline",
"of",
"schema",
"transformers"
] | python | valid | 32.894737 |
qubole/qds-sdk-py | qds_sdk/util.py | https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/util.py#L146-L160 | def _make_minimal(dictionary):
"""
This function removes all the keys whose value is either None or an empty
dictionary.
"""
new_dict = {}
for key, value in dictionary.items():
if value is not None:
if isinstance(value, dict):
new_value = _make_minimal(value)
... | [
"def",
"_make_minimal",
"(",
"dictionary",
")",
":",
"new_dict",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"dictionary",
".",
"items",
"(",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"if",
"isinstance",
"(",
"value",
",",
"dict",
")",
... | This function removes all the keys whose value is either None or an empty
dictionary. | [
"This",
"function",
"removes",
"all",
"the",
"keys",
"whose",
"value",
"is",
"either",
"None",
"or",
"an",
"empty",
"dictionary",
"."
] | python | train | 30.466667 |
ethpm/py-ethpm | ethpm/backends/ipfs.py | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/backends/ipfs.py#L158-L170 | def pin_assets(self, file_or_dir_path: Path) -> List[Dict[str, str]]:
"""
Return a dict containing the IPFS hash, file name, and size of a file.
"""
if file_or_dir_path.is_dir():
asset_data = [dummy_ipfs_pin(path) for path in file_or_dir_path.glob("*")]
elif file_or_d... | [
"def",
"pin_assets",
"(",
"self",
",",
"file_or_dir_path",
":",
"Path",
")",
"->",
"List",
"[",
"Dict",
"[",
"str",
",",
"str",
"]",
"]",
":",
"if",
"file_or_dir_path",
".",
"is_dir",
"(",
")",
":",
"asset_data",
"=",
"[",
"dummy_ipfs_pin",
"(",
"path"... | Return a dict containing the IPFS hash, file name, and size of a file. | [
"Return",
"a",
"dict",
"containing",
"the",
"IPFS",
"hash",
"file",
"name",
"and",
"size",
"of",
"a",
"file",
"."
] | python | train | 42.615385 |
tino/pyFirmata | pyfirmata/pyfirmata.py | https://github.com/tino/pyFirmata/blob/05881909c4d7c4e808e9ed457144670b2136706e/pyfirmata/pyfirmata.py#L247-L257 | def send_sysex(self, sysex_cmd, data):
"""
Sends a SysEx msg.
:arg sysex_cmd: A sysex command byte
: arg data: a bytearray of 7-bit bytes of arbitrary data
"""
msg = bytearray([START_SYSEX, sysex_cmd])
msg.extend(data)
msg.append(END_SYSEX)
self.s... | [
"def",
"send_sysex",
"(",
"self",
",",
"sysex_cmd",
",",
"data",
")",
":",
"msg",
"=",
"bytearray",
"(",
"[",
"START_SYSEX",
",",
"sysex_cmd",
"]",
")",
"msg",
".",
"extend",
"(",
"data",
")",
"msg",
".",
"append",
"(",
"END_SYSEX",
")",
"self",
".",... | Sends a SysEx msg.
:arg sysex_cmd: A sysex command byte
: arg data: a bytearray of 7-bit bytes of arbitrary data | [
"Sends",
"a",
"SysEx",
"msg",
"."
] | python | train | 29.272727 |
sdss/tree | python/tree/misc/docutree.py | https://github.com/sdss/tree/blob/f61fe0876c138ccb61874912d4b8590dadfa835c/python/tree/misc/docutree.py#L105-L145 | def _generate_section(self, name, config, cfg_section='default', remove_sasbase=False):
"""Generate the relevant Sphinx nodes.
Generates a section for the Tree datamodel. Formats a tree section
as a list-table directive.
Parameters:
name (str):
The name of ... | [
"def",
"_generate_section",
"(",
"self",
",",
"name",
",",
"config",
",",
"cfg_section",
"=",
"'default'",
",",
"remove_sasbase",
"=",
"False",
")",
":",
"# the source name",
"source_name",
"=",
"name",
"# Title",
"section",
"=",
"nodes",
".",
"section",
"(",
... | Generate the relevant Sphinx nodes.
Generates a section for the Tree datamodel. Formats a tree section
as a list-table directive.
Parameters:
name (str):
The name of the config to be documented, e.g. 'sdsswork'
config (dict):
The tree di... | [
"Generate",
"the",
"relevant",
"Sphinx",
"nodes",
"."
] | python | train | 32.073171 |
fabioz/PyDev.Debugger | third_party/pep8/pycodestyle.py | https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/third_party/pep8/pycodestyle.py#L1201-L1214 | def bare_except(logical_line, noqa):
r"""When catching exceptions, mention specific exceptions whenever possible.
Okay: except Exception:
Okay: except BaseException:
E722: except:
"""
if noqa:
return
regex = re.compile(r"except\s*:")
match = regex.match(logical_line)
if mat... | [
"def",
"bare_except",
"(",
"logical_line",
",",
"noqa",
")",
":",
"if",
"noqa",
":",
"return",
"regex",
"=",
"re",
".",
"compile",
"(",
"r\"except\\s*:\"",
")",
"match",
"=",
"regex",
".",
"match",
"(",
"logical_line",
")",
"if",
"match",
":",
"yield",
... | r"""When catching exceptions, mention specific exceptions whenever possible.
Okay: except Exception:
Okay: except BaseException:
E722: except: | [
"r",
"When",
"catching",
"exceptions",
"mention",
"specific",
"exceptions",
"whenever",
"possible",
"."
] | python | train | 26.428571 |
mitsei/dlkit | dlkit/json_/cataloging/sessions.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/cataloging/sessions.py#L1368-L1386 | def remove_child_catalog(self, catalog_id, child_id):
"""Removes a child from a catalog.
arg: catalog_id (osid.id.Id): the ``Id`` of a catalog
arg: child_id (osid.id.Id): the ``Id`` of the new child
raise: NotFound - ``catalog_id`` is not a parent of
``child_id``
... | [
"def",
"remove_child_catalog",
"(",
"self",
",",
"catalog_id",
",",
"child_id",
")",
":",
"# Implemented from template for",
"# osid.resource.BinHierarchyDesignSession.remove_child_bin_template",
"if",
"self",
".",
"_catalog_session",
"is",
"not",
"None",
":",
"return",
"se... | Removes a child from a catalog.
arg: catalog_id (osid.id.Id): the ``Id`` of a catalog
arg: child_id (osid.id.Id): the ``Id`` of the new child
raise: NotFound - ``catalog_id`` is not a parent of
``child_id``
raise: NullArgument - ``catalog_id`` or ``child_id`` is
... | [
"Removes",
"a",
"child",
"from",
"a",
"catalog",
"."
] | python | train | 50.105263 |
saltstack/salt | salt/modules/boto_s3_bucket.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_s3_bucket.py#L646-L671 | def put_policy(Bucket, Policy,
region=None, key=None, keyid=None, profile=None):
'''
Given a valid config, update the policy for a bucket.
Returns {updated: true} if policy was updated and returns
{updated: False} if policy was not updated.
CLI Example:
.. code-block:: bash
... | [
"def",
"put_policy",
"(",
"Bucket",
",",
"Policy",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"try",
":",
"conn",
"=",
"_get_conn",
"(",
"region",
"=",
"region",
",",
"key"... | Given a valid config, update the policy for a bucket.
Returns {updated: true} if policy was updated and returns
{updated: False} if policy was not updated.
CLI Example:
.. code-block:: bash
salt myminion boto_s3_bucket.put_policy my_bucket {...} | [
"Given",
"a",
"valid",
"config",
"update",
"the",
"policy",
"for",
"a",
"bucket",
"."
] | python | train | 31.692308 |
doconix/django-mako-plus | django_mako_plus/router/discover.py | https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/router/discover.py#L50-L99 | def find_view_function(module_name, function_name, fallback_app=None, fallback_template=None, verify_decorator=True):
'''
Finds a view function, class-based view, or template view.
Raises ViewDoesNotExist if not found.
'''
dmp = apps.get_app_config('django_mako_plus')
# I'm first calling find_s... | [
"def",
"find_view_function",
"(",
"module_name",
",",
"function_name",
",",
"fallback_app",
"=",
"None",
",",
"fallback_template",
"=",
"None",
",",
"verify_decorator",
"=",
"True",
")",
":",
"dmp",
"=",
"apps",
".",
"get_app_config",
"(",
"'django_mako_plus'",
... | Finds a view function, class-based view, or template view.
Raises ViewDoesNotExist if not found. | [
"Finds",
"a",
"view",
"function",
"class",
"-",
"based",
"view",
"or",
"template",
"view",
".",
"Raises",
"ViewDoesNotExist",
"if",
"not",
"found",
"."
] | python | train | 47.92 |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/psutil/_pslinux.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/psutil/_pslinux.py#L551-L609 | def get_memory_maps(self):
"""Return process's mapped memory regions as a list of nameduples.
Fields are explained in 'man proc'; here is an updated (Apr 2012)
version: http://goo.gl/fmebo
"""
f = None
try:
f = open("/proc/%s/smaps" % self.pid)
fir... | [
"def",
"get_memory_maps",
"(",
"self",
")",
":",
"f",
"=",
"None",
"try",
":",
"f",
"=",
"open",
"(",
"\"/proc/%s/smaps\"",
"%",
"self",
".",
"pid",
")",
"first_line",
"=",
"f",
".",
"readline",
"(",
")",
"current_block",
"=",
"[",
"first_line",
"]",
... | Return process's mapped memory regions as a list of nameduples.
Fields are explained in 'man proc'; here is an updated (Apr 2012)
version: http://goo.gl/fmebo | [
"Return",
"process",
"s",
"mapped",
"memory",
"regions",
"as",
"a",
"list",
"of",
"nameduples",
".",
"Fields",
"are",
"explained",
"in",
"man",
"proc",
";",
"here",
"is",
"an",
"updated",
"(",
"Apr",
"2012",
")",
"version",
":",
"http",
":",
"//",
"goo... | python | test | 41.084746 |
saltstack/salt | salt/cloud/clouds/oneandone.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/oneandone.py#L1020-L1039 | def load_public_key(vm_):
'''
Load the public key file if exists.
'''
public_key_filename = config.get_cloud_config_value(
'ssh_public_key', vm_, __opts__, search_global=False, default=None
)
if public_key_filename is not None:
public_key_filename = os.path.expanduser(public_key_... | [
"def",
"load_public_key",
"(",
"vm_",
")",
":",
"public_key_filename",
"=",
"config",
".",
"get_cloud_config_value",
"(",
"'ssh_public_key'",
",",
"vm_",
",",
"__opts__",
",",
"search_global",
"=",
"False",
",",
"default",
"=",
"None",
")",
"if",
"public_key_fil... | Load the public key file if exists. | [
"Load",
"the",
"public",
"key",
"file",
"if",
"exists",
"."
] | python | train | 37.05 |
openvax/varcode | varcode/reference.py | https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/reference.py#L59-L99 | def infer_reference_name(reference_name_or_path):
"""
Given a string containing a reference name (such as a path to
that reference's FASTA file), return its canonical name
as used by Ensembl.
"""
# identify all cases where reference name or path matches candidate aliases
reference_file_name ... | [
"def",
"infer_reference_name",
"(",
"reference_name_or_path",
")",
":",
"# identify all cases where reference name or path matches candidate aliases",
"reference_file_name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"reference_name_or_path",
")",
"matches",
"=",
"{",
"'fi... | Given a string containing a reference name (such as a path to
that reference's FASTA file), return its canonical name
as used by Ensembl. | [
"Given",
"a",
"string",
"containing",
"a",
"reference",
"name",
"(",
"such",
"as",
"a",
"path",
"to",
"that",
"reference",
"s",
"FASTA",
"file",
")",
"return",
"its",
"canonical",
"name",
"as",
"used",
"by",
"Ensembl",
"."
] | python | train | 51.195122 |
tradenity/python-sdk | tradenity/resources/country.py | https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/country.py#L401-L421 | def create_country(cls, country, **kwargs):
"""Create Country
Create a new Country
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.create_country(country, async=True)
>>> result = thre... | [
"def",
"create_country",
"(",
"cls",
",",
"country",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'async'",
")",
":",
"return",
"cls",
".",
"_create_country_with_http_info",... | Create Country
Create a new Country
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.create_country(country, async=True)
>>> result = thread.get()
:param async bool
:param Coun... | [
"Create",
"Country"
] | python | train | 38.809524 |
stepank/pyws | src/pyws/server.py | https://github.com/stepank/pyws/blob/ff39133aabeb56bbb08d66286ac0cc8731eda7dd/src/pyws/server.py#L117-L125 | def add_function(self, function):
"""
Registers the function to the server's default fixed function manager.
"""
#noinspection PyTypeChecker
if not len(self.settings.FUNCTION_MANAGERS):
raise ConfigurationError(
'Where have the default function manager... | [
"def",
"add_function",
"(",
"self",
",",
"function",
")",
":",
"#noinspection PyTypeChecker",
"if",
"not",
"len",
"(",
"self",
".",
"settings",
".",
"FUNCTION_MANAGERS",
")",
":",
"raise",
"ConfigurationError",
"(",
"'Where have the default function manager gone?!'",
... | Registers the function to the server's default fixed function manager. | [
"Registers",
"the",
"function",
"to",
"the",
"server",
"s",
"default",
"fixed",
"function",
"manager",
"."
] | python | train | 43 |
KeplerGO/K2fov | K2fov/K2findCampaigns.py | https://github.com/KeplerGO/K2fov/blob/fb122b35687340e0357cba9e0dd47b3be0760693/K2fov/K2findCampaigns.py#L133-L169 | def K2findCampaigns_byname_main(args=None):
"""Exposes K2findCampaigns to the command line."""
parser = argparse.ArgumentParser(
description="Check if a target is "
"(or was) observable by any past or future "
"observing campaig... | [
"def",
"K2findCampaigns_byname_main",
"(",
"args",
"=",
"None",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"Check if a target is \"",
"\"(or was) observable by any past or future \"",
"\"observing campaign of NASA's K2 mission.\"",
")... | Exposes K2findCampaigns to the command line. | [
"Exposes",
"K2findCampaigns",
"to",
"the",
"command",
"line",
"."
] | python | train | 47.297297 |
log2timeline/plaso | plaso/parsers/winreg_plugins/sam_users.py | https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/parsers/winreg_plugins/sam_users.py#L60-L85 | def _ParseFValue(self, registry_key):
"""Parses an F value.
Args:
registry_key (dfwinreg.WinRegistryKey): Windows Registry key.
Returns:
f_value: F value stored in the Windows Registry key.
Raises:
ParseError: if the Windows Registry key does not contain an F value or
F va... | [
"def",
"_ParseFValue",
"(",
"self",
",",
"registry_key",
")",
":",
"registry_value",
"=",
"registry_key",
".",
"GetValueByName",
"(",
"'F'",
")",
"if",
"not",
"registry_value",
":",
"raise",
"errors",
".",
"ParseError",
"(",
"'missing value: \"F\" in Windows Registr... | Parses an F value.
Args:
registry_key (dfwinreg.WinRegistryKey): Windows Registry key.
Returns:
f_value: F value stored in the Windows Registry key.
Raises:
ParseError: if the Windows Registry key does not contain an F value or
F value cannot be parsed. | [
"Parses",
"an",
"F",
"value",
"."
] | python | train | 30.576923 |
cloudant/python-cloudant | src/cloudant/_client_session.py | https://github.com/cloudant/python-cloudant/blob/e0ba190f6ba07fe3522a668747128214ad573c7e/src/cloudant/_client_session.py#L44-L58 | def base64_user_pass(self):
"""
Composes a basic http auth string, suitable for use with the
_replicator database, and other places that need it.
:returns: Basic http authentication string
"""
if self._username is None or self._password is None:
return None
... | [
"def",
"base64_user_pass",
"(",
"self",
")",
":",
"if",
"self",
".",
"_username",
"is",
"None",
"or",
"self",
".",
"_password",
"is",
"None",
":",
"return",
"None",
"hash_",
"=",
"base64",
".",
"urlsafe_b64encode",
"(",
"bytes_",
"(",
"\"{username}:{password... | Composes a basic http auth string, suitable for use with the
_replicator database, and other places that need it.
:returns: Basic http authentication string | [
"Composes",
"a",
"basic",
"http",
"auth",
"string",
"suitable",
"for",
"use",
"with",
"the",
"_replicator",
"database",
"and",
"other",
"places",
"that",
"need",
"it",
"."
] | python | train | 34.733333 |
hobson/aima | aima/probability.py | https://github.com/hobson/aima/blob/3572b2fb92039b4a1abe384be8545560fbd3d470/aima/probability.py#L265-L275 | def enumeration_ask(X, e, bn):
"""Return the conditional probability distribution of variable X
given evidence e, from BayesNet bn. [Fig. 14.9]
>>> enumeration_ask('Burglary', dict(JohnCalls=T, MaryCalls=T), burglary
... ).show_approx()
'False: 0.716, True: 0.284'"""
assert X not in e, "Query v... | [
"def",
"enumeration_ask",
"(",
"X",
",",
"e",
",",
"bn",
")",
":",
"assert",
"X",
"not",
"in",
"e",
",",
"\"Query variable must be distinct from evidence\"",
"Q",
"=",
"ProbDist",
"(",
"X",
")",
"for",
"xi",
"in",
"bn",
".",
"variable_values",
"(",
"X",
... | Return the conditional probability distribution of variable X
given evidence e, from BayesNet bn. [Fig. 14.9]
>>> enumeration_ask('Burglary', dict(JohnCalls=T, MaryCalls=T), burglary
... ).show_approx()
'False: 0.716, True: 0.284 | [
"Return",
"the",
"conditional",
"probability",
"distribution",
"of",
"variable",
"X",
"given",
"evidence",
"e",
"from",
"BayesNet",
"bn",
".",
"[",
"Fig",
".",
"14",
".",
"9",
"]",
">>>",
"enumeration_ask",
"(",
"Burglary",
"dict",
"(",
"JohnCalls",
"=",
"... | python | valid | 44.727273 |
CalebBell/fpi | fpi/drag.py | https://github.com/CalebBell/fpi/blob/6e6da3b9d0c17e10cc0886c97bc1bb8aeba2cca5/fpi/drag.py#L278-L340 | def Morsi_Alexander(Re):
r'''Calculates drag coefficient of a smooth sphere using the method in
[1]_ as described in [2]_.
.. math::
C_D = \left\{ \begin{array}{ll}
\frac{24}{Re} & \mbox{if $Re < 0.1$}\\
\frac{22.73}{Re}+\frac{0.0903}{Re^2} + 3.69 & \mbox{if $0.1 < Re < 1$}\\
... | [
"def",
"Morsi_Alexander",
"(",
"Re",
")",
":",
"if",
"Re",
"<",
"0.1",
":",
"Cd",
"=",
"24.",
"/",
"Re",
"elif",
"Re",
"<",
"1",
":",
"Cd",
"=",
"22.73",
"/",
"Re",
"+",
"0.0903",
"/",
"Re",
"**",
"2",
"+",
"3.69",
"elif",
"Re",
"<",
"10",
... | r'''Calculates drag coefficient of a smooth sphere using the method in
[1]_ as described in [2]_.
.. math::
C_D = \left\{ \begin{array}{ll}
\frac{24}{Re} & \mbox{if $Re < 0.1$}\\
\frac{22.73}{Re}+\frac{0.0903}{Re^2} + 3.69 & \mbox{if $0.1 < Re < 1$}\\
\frac{29.1667}{Re}-\frac{3.... | [
"r",
"Calculates",
"drag",
"coefficient",
"of",
"a",
"smooth",
"sphere",
"using",
"the",
"method",
"in",
"[",
"1",
"]",
"_",
"as",
"described",
"in",
"[",
"2",
"]",
"_",
"."
] | python | train | 35.793651 |
StagPython/StagPy | stagpy/processing.py | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/processing.py#L180-L193 | def diffs_prof(step):
"""Scaled diffusion.
This computation takes sphericity into account if necessary.
Args:
step (:class:`~stagpy.stagyydata._Step`): a step of a StagyyData
instance.
Returns:
tuple of :class:`numpy.array`: the diffusion and the radial position
at ... | [
"def",
"diffs_prof",
"(",
"step",
")",
":",
"diff",
",",
"rad",
"=",
"diff_prof",
"(",
"step",
")",
"return",
"_scale_prof",
"(",
"step",
",",
"diff",
",",
"rad",
")",
",",
"rad"
] | Scaled diffusion.
This computation takes sphericity into account if necessary.
Args:
step (:class:`~stagpy.stagyydata._Step`): a step of a StagyyData
instance.
Returns:
tuple of :class:`numpy.array`: the diffusion and the radial position
at which it is evaluated. | [
"Scaled",
"diffusion",
"."
] | python | train | 29.571429 |
SatelliteQE/nailgun | nailgun/entity_mixins.py | https://github.com/SatelliteQE/nailgun/blob/c36d8c20862e87bf6975bd48ac1ca40a9e634eaa/nailgun/entity_mixins.py#L657-L693 | def delete(self, synchronous=True):
"""Delete the current entity.
Call :meth:`delete_raw` and check for an HTTP 4XX or 5XX response.
Return either the JSON-decoded response or information about a
completed foreman task.
:param synchronous: A boolean. What should happen if the s... | [
"def",
"delete",
"(",
"self",
",",
"synchronous",
"=",
"True",
")",
":",
"response",
"=",
"self",
".",
"delete_raw",
"(",
")",
"response",
".",
"raise_for_status",
"(",
")",
"if",
"(",
"synchronous",
"is",
"True",
"and",
"response",
".",
"status_code",
"... | Delete the current entity.
Call :meth:`delete_raw` and check for an HTTP 4XX or 5XX response.
Return either the JSON-decoded response or information about a
completed foreman task.
:param synchronous: A boolean. What should happen if the server returns
an HTTP 202 (accepted... | [
"Delete",
"the",
"current",
"entity",
"."
] | python | train | 44.972973 |
theonion/django-bulbs | bulbs/special_coverage/management/commands/migrate_active_to_published.py | https://github.com/theonion/django-bulbs/blob/0c0e6e3127a7dc487b96677fab95cacd2b3806da/bulbs/special_coverage/management/commands/migrate_active_to_published.py#L10-L13 | def get_month_start_date(self):
"""Returns the first day of the current month"""
now = timezone.now()
return timezone.datetime(day=1, month=now.month, year=now.year, tzinfo=now.tzinfo) | [
"def",
"get_month_start_date",
"(",
"self",
")",
":",
"now",
"=",
"timezone",
".",
"now",
"(",
")",
"return",
"timezone",
".",
"datetime",
"(",
"day",
"=",
"1",
",",
"month",
"=",
"now",
".",
"month",
",",
"year",
"=",
"now",
".",
"year",
",",
"tzi... | Returns the first day of the current month | [
"Returns",
"the",
"first",
"day",
"of",
"the",
"current",
"month"
] | python | train | 51.25 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.