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 |
|---|---|---|---|---|---|---|---|---|---|
apmoore1/tweebo_parser_python_api | tweebo_parser/api.py | https://github.com/apmoore1/tweebo_parser_python_api/blob/224be2570b8b2508d29771f5e5abe06e1889fd89/tweebo_parser/api.py#L47-L55 | def log_error(self, text: str) -> None:
'''
Given some error text it will log the text if self.log_errors is True
:param text: Error text to log
'''
if self.log_errors:
with self._log_fp.open('a+') as log_file:
log_file.write(f'{text}\n') | [
"def",
"log_error",
"(",
"self",
",",
"text",
":",
"str",
")",
"->",
"None",
":",
"if",
"self",
".",
"log_errors",
":",
"with",
"self",
".",
"_log_fp",
".",
"open",
"(",
"'a+'",
")",
"as",
"log_file",
":",
"log_file",
".",
"write",
"(",
"f'{text}\\n'... | Given some error text it will log the text if self.log_errors is True
:param text: Error text to log | [
"Given",
"some",
"error",
"text",
"it",
"will",
"log",
"the",
"text",
"if",
"self",
".",
"log_errors",
"is",
"True"
] | python | valid | 33.222222 |
alevinval/scheduling | scheduling/graph.py | https://github.com/alevinval/scheduling/blob/127239712c0b73b929ca19b4b5c2855eebb7fcf0/scheduling/graph.py#L113-L121 | def explore(node):
""" Given a node, explores on relatives, siblings and children
:param node: GraphNode from which to explore
:return: set of explored GraphNodes
"""
explored = set()
explored.add(node)
dfs(node, callback=lambda n: explored.add(n))
return explored | [
"def",
"explore",
"(",
"node",
")",
":",
"explored",
"=",
"set",
"(",
")",
"explored",
".",
"add",
"(",
"node",
")",
"dfs",
"(",
"node",
",",
"callback",
"=",
"lambda",
"n",
":",
"explored",
".",
"add",
"(",
"n",
")",
")",
"return",
"explored"
] | Given a node, explores on relatives, siblings and children
:param node: GraphNode from which to explore
:return: set of explored GraphNodes | [
"Given",
"a",
"node",
"explores",
"on",
"relatives",
"siblings",
"and",
"children",
":",
"param",
"node",
":",
"GraphNode",
"from",
"which",
"to",
"explore",
":",
"return",
":",
"set",
"of",
"explored",
"GraphNodes"
] | python | train | 32 |
saltstack/salt | salt/states/elasticsearch.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/elasticsearch.py#L437-L492 | def search_template_present(name, definition):
'''
Ensure that the named search template is present.
name
Name of the search template to add
definition
Required dict for creation parameters as per http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html
*... | [
"def",
"search_template_present",
"(",
"name",
",",
"definition",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}",
",",
"'result'",
":",
"True",
",",
"'comment'",
":",
"''",
"}",
"try",
":",
"template",
"=",
"__salt__"... | Ensure that the named search template is present.
name
Name of the search template to add
definition
Required dict for creation parameters as per http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html
**Example:**
.. code-block:: yaml
test_pipelin... | [
"Ensure",
"that",
"the",
"named",
"search",
"template",
"is",
"present",
"."
] | python | train | 35.392857 |
saltstack/salt | salt/modules/npm.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/npm.py#L68-L182 | def install(pkg=None,
pkgs=None,
dir=None,
runas=None,
registry=None,
env=None,
dry_run=False,
silent=True):
'''
Install an NPM package.
If no directory is specified, the package will be installed globally. If
no packag... | [
"def",
"install",
"(",
"pkg",
"=",
"None",
",",
"pkgs",
"=",
"None",
",",
"dir",
"=",
"None",
",",
"runas",
"=",
"None",
",",
"registry",
"=",
"None",
",",
"env",
"=",
"None",
",",
"dry_run",
"=",
"False",
",",
"silent",
"=",
"True",
")",
":",
... | Install an NPM package.
If no directory is specified, the package will be installed globally. If
no package is specified, the dependencies (from package.json) of the
package in the given directory will be installed.
pkg
A package name in any format accepted by NPM, including a version
... | [
"Install",
"an",
"NPM",
"package",
"."
] | python | train | 23.904348 |
lingthio/Flask-User | flask_user/db_adapters/dynamo_db_adapter.py | https://github.com/lingthio/Flask-User/blob/a379fa0a281789618c484b459cb41236779b95b1/flask_user/db_adapters/dynamo_db_adapter.py#L114-L118 | def delete_object(self, object):
""" Delete object specified by ``object``. """
#pdb.set_trace()
self.db.engine.delete_key(object)#, userid='abc123', id='1')
print('dynamo.delete_object(%s)' % object) | [
"def",
"delete_object",
"(",
"self",
",",
"object",
")",
":",
"#pdb.set_trace()",
"self",
".",
"db",
".",
"engine",
".",
"delete_key",
"(",
"object",
")",
"#, userid='abc123', id='1')",
"print",
"(",
"'dynamo.delete_object(%s)'",
"%",
"object",
")"
] | Delete object specified by ``object``. | [
"Delete",
"object",
"specified",
"by",
"object",
"."
] | python | train | 45.6 |
BerkeleyAutomation/perception | perception/primesense_sensor.py | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/primesense_sensor.py#L241-L260 | def min_depth_img(self, num_img=1):
"""Collect a series of depth images and return the min of the set.
Parameters
----------
num_img : int
The number of consecutive frames to process.
Returns
-------
:obj:`DepthImage`
The min DepthImage c... | [
"def",
"min_depth_img",
"(",
"self",
",",
"num_img",
"=",
"1",
")",
":",
"depths",
"=",
"[",
"]",
"for",
"_",
"in",
"range",
"(",
"num_img",
")",
":",
"_",
",",
"depth",
",",
"_",
"=",
"self",
".",
"frames",
"(",
")",
"depths",
".",
"append",
"... | Collect a series of depth images and return the min of the set.
Parameters
----------
num_img : int
The number of consecutive frames to process.
Returns
-------
:obj:`DepthImage`
The min DepthImage collected from the frames. | [
"Collect",
"a",
"series",
"of",
"depth",
"images",
"and",
"return",
"the",
"min",
"of",
"the",
"set",
"."
] | python | train | 25.3 |
tensorflow/datasets | tensorflow_datasets/core/api_utils.py | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/api_utils.py#L67-L75 | def _required_args(fn):
"""Returns arguments of fn with default=REQUIRED_ARG."""
spec = getargspec(fn)
if not spec.defaults:
return []
arg_names = spec.args[-len(spec.defaults):]
return [name for name, val in zip(arg_names, spec.defaults)
if val is REQUIRED_ARG] | [
"def",
"_required_args",
"(",
"fn",
")",
":",
"spec",
"=",
"getargspec",
"(",
"fn",
")",
"if",
"not",
"spec",
".",
"defaults",
":",
"return",
"[",
"]",
"arg_names",
"=",
"spec",
".",
"args",
"[",
"-",
"len",
"(",
"spec",
".",
"defaults",
")",
":",
... | Returns arguments of fn with default=REQUIRED_ARG. | [
"Returns",
"arguments",
"of",
"fn",
"with",
"default",
"=",
"REQUIRED_ARG",
"."
] | python | train | 31 |
whiteclover/dbpy | samples/orm.py | https://github.com/whiteclover/dbpy/blob/3d9ce85f55cfb39cced22081e525f79581b26b3a/samples/orm.py#L46-L54 | def find(self, uid):
"""Find and load the user from database by uid(user id)"""
data = (db.select(self.table).select('username', 'email', 'real_name',
'password', 'bio', 'status', 'role', 'uid').
condition('uid', uid).execute()
... | [
"def",
"find",
"(",
"self",
",",
"uid",
")",
":",
"data",
"=",
"(",
"db",
".",
"select",
"(",
"self",
".",
"table",
")",
".",
"select",
"(",
"'username'",
",",
"'email'",
",",
"'real_name'",
",",
"'password'",
",",
"'bio'",
",",
"'status'",
",",
"'... | Find and load the user from database by uid(user id) | [
"Find",
"and",
"load",
"the",
"user",
"from",
"database",
"by",
"uid",
"(",
"user",
"id",
")"
] | python | train | 46.888889 |
zapier/django-rest-hooks | rest_hooks/models.py | https://github.com/zapier/django-rest-hooks/blob/cf4f9588cd9f2d4696f2f0654a205722ee19b80e/rest_hooks/models.py#L158-L167 | def custom_action(sender, action,
instance,
user=None,
**kwargs):
"""
Manually trigger a custom action (or even a standard action).
"""
opts = get_opts(instance)
model = '.'.join([opts.app_label, opts.object_name])
dis... | [
"def",
"custom_action",
"(",
"sender",
",",
"action",
",",
"instance",
",",
"user",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"opts",
"=",
"get_opts",
"(",
"instance",
")",
"model",
"=",
"'.'",
".",
"join",
"(",
"[",
"opts",
".",
"app_label",
... | Manually trigger a custom action (or even a standard action). | [
"Manually",
"trigger",
"a",
"custom",
"action",
"(",
"or",
"even",
"a",
"standard",
"action",
")",
"."
] | python | train | 37.2 |
lk-geimfari/mimesis | mimesis/builtins/ru.py | https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/builtins/ru.py#L125-L149 | def inn(self) -> str:
"""Generate random, but valid ``INN``.
:return: INN.
"""
def control_sum(nums: list, t: str) -> int:
digits = {
'n2': [7, 2, 4, 10, 3, 5, 9, 4, 6, 8],
'n1': [3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8],
}
nu... | [
"def",
"inn",
"(",
"self",
")",
"->",
"str",
":",
"def",
"control_sum",
"(",
"nums",
":",
"list",
",",
"t",
":",
"str",
")",
"->",
"int",
":",
"digits",
"=",
"{",
"'n2'",
":",
"[",
"7",
",",
"2",
",",
"4",
",",
"10",
",",
"3",
",",
"5",
"... | Generate random, but valid ``INN``.
:return: INN. | [
"Generate",
"random",
"but",
"valid",
"INN",
"."
] | python | train | 30.8 |
OpenKMIP/PyKMIP | kmip/core/objects.py | https://github.com/OpenKMIP/PyKMIP/blob/b51c5b044bd05f8c85a1d65d13a583a4d8fc1b0e/kmip/core/objects.py#L5262-L5383 | def write(self, output_buffer, kmip_version=enums.KMIPVersion.KMIP_1_3):
"""
Write the ValidationInformation structure encoding to the data stream.
Args:
output_buffer (stream): A data stream in which to encode
ValidationInformation structure data, supporting a write... | [
"def",
"write",
"(",
"self",
",",
"output_buffer",
",",
"kmip_version",
"=",
"enums",
".",
"KMIPVersion",
".",
"KMIP_1_3",
")",
":",
"if",
"kmip_version",
"<",
"enums",
".",
"KMIPVersion",
".",
"KMIP_1_3",
":",
"raise",
"exceptions",
".",
"VersionNotSupported"... | Write the ValidationInformation structure encoding to the data stream.
Args:
output_buffer (stream): A data stream in which to encode
ValidationInformation structure data, supporting a write
method.
kmip_version (enum): A KMIPVersion enumeration defining ... | [
"Write",
"the",
"ValidationInformation",
"structure",
"encoding",
"to",
"the",
"data",
"stream",
"."
] | python | test | 33.614754 |
xhtml2pdf/xhtml2pdf | xhtml2pdf/w3c/cssParser.py | https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/w3c/cssParser.py#L900-L935 | def _parseSimpleSelector(self, src):
"""simple_selector
: [ namespace_selector ]? element_name? [ HASH | class | attrib | pseudo ]* S*
;
"""
ctxsrc = src.lstrip()
nsPrefix, src = self._getMatchResult(self.re_namespace_selector, src)
name, src = self._getMatchResul... | [
"def",
"_parseSimpleSelector",
"(",
"self",
",",
"src",
")",
":",
"ctxsrc",
"=",
"src",
".",
"lstrip",
"(",
")",
"nsPrefix",
",",
"src",
"=",
"self",
".",
"_getMatchResult",
"(",
"self",
".",
"re_namespace_selector",
",",
"src",
")",
"name",
",",
"src",
... | simple_selector
: [ namespace_selector ]? element_name? [ HASH | class | attrib | pseudo ]* S*
; | [
"simple_selector",
":",
"[",
"namespace_selector",
"]",
"?",
"element_name?",
"[",
"HASH",
"|",
"class",
"|",
"attrib",
"|",
"pseudo",
"]",
"*",
"S",
"*",
";"
] | python | train | 38.083333 |
ansible/molecule | molecule/command/init/scenario.py | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/init/scenario.py#L53-L89 | def execute(self):
"""
Execute the actions necessary to perform a `molecule init scenario` and
returns None.
:return: None
"""
scenario_name = self._command_args['scenario_name']
role_name = os.getcwd().split(os.sep)[-1]
role_directory = util.abs_path(os.... | [
"def",
"execute",
"(",
"self",
")",
":",
"scenario_name",
"=",
"self",
".",
"_command_args",
"[",
"'scenario_name'",
"]",
"role_name",
"=",
"os",
".",
"getcwd",
"(",
")",
".",
"split",
"(",
"os",
".",
"sep",
")",
"[",
"-",
"1",
"]",
"role_directory",
... | Execute the actions necessary to perform a `molecule init scenario` and
returns None.
:return: None | [
"Execute",
"the",
"actions",
"necessary",
"to",
"perform",
"a",
"molecule",
"init",
"scenario",
"and",
"returns",
"None",
"."
] | python | train | 42.540541 |
BD2KGenomics/protect | src/protect/common.py | https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/src/protect/common.py#L401-L448 | def export_results(job, fsid, file_name, univ_options, subfolder=None):
"""
Write out a file to a given location. The location can be either a directory on the local
machine, or a folder with a bucket on AWS.
:param str fsid: The file store id for the file to be exported
:param str file_name: The n... | [
"def",
"export_results",
"(",
"job",
",",
"fsid",
",",
"file_name",
",",
"univ_options",
",",
"subfolder",
"=",
"None",
")",
":",
"job",
".",
"fileStore",
".",
"logToMaster",
"(",
"'Exporting %s to output location'",
"%",
"fsid",
")",
"file_name",
"=",
"os",
... | Write out a file to a given location. The location can be either a directory on the local
machine, or a folder with a bucket on AWS.
:param str fsid: The file store id for the file to be exported
:param str file_name: The name of the file that neeeds to be exported (path to file is also
acceptab... | [
"Write",
"out",
"a",
"file",
"to",
"a",
"given",
"location",
".",
"The",
"location",
"can",
"be",
"either",
"a",
"directory",
"on",
"the",
"local",
"machine",
"or",
"a",
"folder",
"with",
"a",
"bucket",
"on",
"AWS",
"."
] | python | train | 47.333333 |
DheerendraRathor/django-auth-ldap-ng | django_auth_ldap/backend.py | https://github.com/DheerendraRathor/django-auth-ldap-ng/blob/4d2458bd90c4539353c5bfd5ea793c1e59780ee8/django_auth_ldap/backend.py#L539-L582 | def _get_or_create_user(self, force_populate=False):
"""
Loads the User model object from the database or creates it if it
doesn't exist. Also populates the fields, subject to
AUTH_LDAP_ALWAYS_UPDATE_USER.
"""
save_user = False
username = self.backend.ldap_to_dja... | [
"def",
"_get_or_create_user",
"(",
"self",
",",
"force_populate",
"=",
"False",
")",
":",
"save_user",
"=",
"False",
"username",
"=",
"self",
".",
"backend",
".",
"ldap_to_django_username",
"(",
"self",
".",
"_username",
")",
"self",
".",
"_user",
",",
"crea... | Loads the User model object from the database or creates it if it
doesn't exist. Also populates the fields, subject to
AUTH_LDAP_ALWAYS_UPDATE_USER. | [
"Loads",
"the",
"User",
"model",
"object",
"from",
"the",
"database",
"or",
"creates",
"it",
"if",
"it",
"doesn",
"t",
"exist",
".",
"Also",
"populates",
"the",
"fields",
"subject",
"to",
"AUTH_LDAP_ALWAYS_UPDATE_USER",
"."
] | python | train | 37.113636 |
twilio/twilio-python | twilio/rest/api/v2010/account/notification.py | https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/api/v2010/account/notification.py#L208-L217 | def get_instance(self, payload):
"""
Build an instance of NotificationInstance
:param dict payload: Payload response from the API
:returns: twilio.rest.api.v2010.account.notification.NotificationInstance
:rtype: twilio.rest.api.v2010.account.notification.NotificationInstance
... | [
"def",
"get_instance",
"(",
"self",
",",
"payload",
")",
":",
"return",
"NotificationInstance",
"(",
"self",
".",
"_version",
",",
"payload",
",",
"account_sid",
"=",
"self",
".",
"_solution",
"[",
"'account_sid'",
"]",
",",
")"
] | Build an instance of NotificationInstance
:param dict payload: Payload response from the API
:returns: twilio.rest.api.v2010.account.notification.NotificationInstance
:rtype: twilio.rest.api.v2010.account.notification.NotificationInstance | [
"Build",
"an",
"instance",
"of",
"NotificationInstance"
] | python | train | 42.5 |
tBaxter/python-card-me | card_me/icalendar.py | https://github.com/tBaxter/python-card-me/blob/ffebc7fed44f83983b7438e57263dcda67207664/card_me/icalendar.py#L361-L471 | def getrruleset(self, addRDate=False):
"""
Get an rruleset created from self.
If addRDate is True, add an RDATE for dtstart if it's not included in
an RRULE, and count is decremented if it exists.
Note that for rules which don't match DTSTART, DTSTART may not appear
in ... | [
"def",
"getrruleset",
"(",
"self",
",",
"addRDate",
"=",
"False",
")",
":",
"rruleset",
"=",
"None",
"for",
"name",
"in",
"DATESANDRULES",
":",
"addfunc",
"=",
"None",
"for",
"line",
"in",
"self",
".",
"contents",
".",
"get",
"(",
"name",
",",
"(",
"... | Get an rruleset created from self.
If addRDate is True, add an RDATE for dtstart if it's not included in
an RRULE, and count is decremented if it exists.
Note that for rules which don't match DTSTART, DTSTART may not appear
in list(rruleset), although it should. By default, an RDATE i... | [
"Get",
"an",
"rruleset",
"created",
"from",
"self",
"."
] | python | train | 52.63964 |
Kane610/deconz | pydeconz/websocket.py | https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/websocket.py#L146-L150 | def stop(self):
"""Close websocket connection."""
self.state = STATE_STOPPED
if self.transport:
self.transport.close() | [
"def",
"stop",
"(",
"self",
")",
":",
"self",
".",
"state",
"=",
"STATE_STOPPED",
"if",
"self",
".",
"transport",
":",
"self",
".",
"transport",
".",
"close",
"(",
")"
] | Close websocket connection. | [
"Close",
"websocket",
"connection",
"."
] | python | train | 30 |
deepmind/sonnet | sonnet/python/modules/util.py | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/util.py#L300-L368 | def custom_getter_router(custom_getter_map, name_fn):
"""Creates a custom getter than matches requests to dict of custom getters.
Custom getters are callables which implement the
[custom getter API]
(https://www.tensorflow.org/versions/r1.0/api_docs/python/tf/get_variable).
The returned custom getter dispat... | [
"def",
"custom_getter_router",
"(",
"custom_getter_map",
",",
"name_fn",
")",
":",
"for",
"custom_getter",
"in",
"custom_getter_map",
".",
"values",
"(",
")",
":",
"if",
"not",
"callable",
"(",
"custom_getter",
")",
":",
"raise",
"TypeError",
"(",
"\"Given custo... | Creates a custom getter than matches requests to dict of custom getters.
Custom getters are callables which implement the
[custom getter API]
(https://www.tensorflow.org/versions/r1.0/api_docs/python/tf/get_variable).
The returned custom getter dispatches calls based on pattern matching the
name of the requ... | [
"Creates",
"a",
"custom",
"getter",
"than",
"matches",
"requests",
"to",
"dict",
"of",
"custom",
"getters",
"."
] | python | train | 34.275362 |
Opentrons/opentrons | api/src/opentrons/legacy_api/containers/placeable.py | https://github.com/Opentrons/opentrons/blob/a7c15cc2636ecb64ab56c7edc1d8a57163aaeadf/api/src/opentrons/legacy_api/containers/placeable.py#L240-L245 | def coordinates(self, reference=None):
"""
Returns the coordinates of a :Placeable: relative to :reference:
"""
coordinates = [i._coordinates for i in self.get_trace(reference)]
return functools.reduce(lambda a, b: a + b, coordinates) | [
"def",
"coordinates",
"(",
"self",
",",
"reference",
"=",
"None",
")",
":",
"coordinates",
"=",
"[",
"i",
".",
"_coordinates",
"for",
"i",
"in",
"self",
".",
"get_trace",
"(",
"reference",
")",
"]",
"return",
"functools",
".",
"reduce",
"(",
"lambda",
... | Returns the coordinates of a :Placeable: relative to :reference: | [
"Returns",
"the",
"coordinates",
"of",
"a",
":",
"Placeable",
":",
"relative",
"to",
":",
"reference",
":"
] | python | train | 44.833333 |
cole/aiosmtplib | src/aiosmtplib/smtp.py | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/smtp.py#L168-L193 | async def _send_recipients(
self,
recipients: List[str],
options: List[str] = None,
timeout: DefaultNumType = _default,
) -> RecipientErrorsType:
"""
Send the recipients given to the server. Used as part of
:meth:`.sendmail`.
"""
recipient_erro... | [
"async",
"def",
"_send_recipients",
"(",
"self",
",",
"recipients",
":",
"List",
"[",
"str",
"]",
",",
"options",
":",
"List",
"[",
"str",
"]",
"=",
"None",
",",
"timeout",
":",
"DefaultNumType",
"=",
"_default",
",",
")",
"->",
"RecipientErrorsType",
":... | Send the recipients given to the server. Used as part of
:meth:`.sendmail`. | [
"Send",
"the",
"recipients",
"given",
"to",
"the",
"server",
".",
"Used",
"as",
"part",
"of",
":",
"meth",
":",
".",
"sendmail",
"."
] | python | train | 30.5 |
LordGaav/python-chaos | chaos/threading/scheduler.py | https://github.com/LordGaav/python-chaos/blob/52cd29a6fd15693ee1e53786b93bcb23fbf84ddd/chaos/threading/scheduler.py#L90-L105 | def setStopAction(self, action, *args, **kwargs):
"""
Set a function to call when run() is stopping, after 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",
"setStopAction",
"(",
"self",
",",
"action",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"stop_action",
"=",
"action",
"self",
".",
"stop_args",
"=",
"args",
"self",
".",
"stop_kwargs",
"=",
"kwargs"
] | Set a function to call when run() is stopping, after 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",
"stopping",
"after",
"the",
"main",
"action",
"is",
"called",
"."
] | python | train | 24.375 |
OnroerendErfgoed/crabpy | crabpy/client.py | https://github.com/OnroerendErfgoed/crabpy/blob/3a6fd8bc5aca37c2a173e3ea94e4e468b8aa79c1/crabpy/client.py#L41-L52 | def crab_request(client, action, *args):
'''
Utility function that helps making requests to the CRAB service.
:param client: A :class:`suds.client.Client` for the CRAB service.
:param string action: Which method to call, eg. `ListGewesten`
:returns: Result of the SOAP call.
.. versionadded:: 0... | [
"def",
"crab_request",
"(",
"client",
",",
"action",
",",
"*",
"args",
")",
":",
"log",
".",
"debug",
"(",
"'Calling %s on CRAB service.'",
",",
"action",
")",
"return",
"getattr",
"(",
"client",
".",
"service",
",",
"action",
")",
"(",
"*",
"args",
")"
... | Utility function that helps making requests to the CRAB service.
:param client: A :class:`suds.client.Client` for the CRAB service.
:param string action: Which method to call, eg. `ListGewesten`
:returns: Result of the SOAP call.
.. versionadded:: 0.3.0 | [
"Utility",
"function",
"that",
"helps",
"making",
"requests",
"to",
"the",
"CRAB",
"service",
"."
] | python | train | 35.333333 |
pandas-dev/pandas | pandas/core/reshape/melt.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/reshape/melt.py#L178-L458 | def wide_to_long(df, stubnames, i, j, sep="", suffix=r'\d+'):
r"""
Wide panel to long format. Less flexible but more user-friendly than melt.
With stubnames ['A', 'B'], this function expects to find one or more
group of columns with format
A-suffix1, A-suffix2,..., B-suffix1, B-suffix2,...
You ... | [
"def",
"wide_to_long",
"(",
"df",
",",
"stubnames",
",",
"i",
",",
"j",
",",
"sep",
"=",
"\"\"",
",",
"suffix",
"=",
"r'\\d+'",
")",
":",
"def",
"get_var_names",
"(",
"df",
",",
"stub",
",",
"sep",
",",
"suffix",
")",
":",
"regex",
"=",
"r'^{stub}{... | r"""
Wide panel to long format. Less flexible but more user-friendly than melt.
With stubnames ['A', 'B'], this function expects to find one or more
group of columns with format
A-suffix1, A-suffix2,..., B-suffix1, B-suffix2,...
You specify what you want to call this suffix in the resulting long fo... | [
"r",
"Wide",
"panel",
"to",
"long",
"format",
".",
"Less",
"flexible",
"but",
"more",
"user",
"-",
"friendly",
"than",
"melt",
"."
] | python | train | 33.701068 |
python-astrodynamics/spacetrack | spacetrack/base.py | https://github.com/python-astrodynamics/spacetrack/blob/18f63b7de989a31b983d140a11418e01bd6fd398/spacetrack/base.py#L492-L507 | def _download_predicate_data(self, class_, controller):
"""Get raw predicate information for given request class, and cache for
subsequent calls.
"""
self.authenticate()
url = ('{0}{1}/modeldef/class/{2}'
.format(self.base_url, controller, class_))
logger... | [
"def",
"_download_predicate_data",
"(",
"self",
",",
"class_",
",",
"controller",
")",
":",
"self",
".",
"authenticate",
"(",
")",
"url",
"=",
"(",
"'{0}{1}/modeldef/class/{2}'",
".",
"format",
"(",
"self",
".",
"base_url",
",",
"controller",
",",
"class_",
... | Get raw predicate information for given request class, and cache for
subsequent calls. | [
"Get",
"raw",
"predicate",
"information",
"for",
"given",
"request",
"class",
"and",
"cache",
"for",
"subsequent",
"calls",
"."
] | python | train | 28.5 |
Ex-Mente/auxi.0 | auxi/tools/chemistry/thermochemistry.py | https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/tools/chemistry/thermochemistry.py#L656-L671 | def _split_compound_string_(compound_string):
"""
Split a compound's combined formula and phase into separate strings for
the formula and phase.
:param compound_string: Formula and phase of a chemical compound, e.g.
'SiO2[S1]'.
:returns: Formula of chemical compound.
:returns: Phase of c... | [
"def",
"_split_compound_string_",
"(",
"compound_string",
")",
":",
"formula",
"=",
"compound_string",
".",
"replace",
"(",
"']'",
",",
"''",
")",
".",
"split",
"(",
"'['",
")",
"[",
"0",
"]",
"phase",
"=",
"compound_string",
".",
"replace",
"(",
"']'",
... | Split a compound's combined formula and phase into separate strings for
the formula and phase.
:param compound_string: Formula and phase of a chemical compound, e.g.
'SiO2[S1]'.
:returns: Formula of chemical compound.
:returns: Phase of chemical compound. | [
"Split",
"a",
"compound",
"s",
"combined",
"formula",
"and",
"phase",
"into",
"separate",
"strings",
"for",
"the",
"formula",
"and",
"phase",
"."
] | python | valid | 29.875 |
SeattleTestbed/seash | pyreadline/console/ansi.py | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/console/ansi.py#L118-L151 | def write_color_old( text, attr=None):
u'''write text at current cursor position and interpret color escapes.
return the number of characters written.
'''
res = []
chunks = terminal_escape.split(text)
n = 0 # count the characters we actually write, omitting the escapes
if attr is No... | [
"def",
"write_color_old",
"(",
"text",
",",
"attr",
"=",
"None",
")",
":",
"res",
"=",
"[",
"]",
"chunks",
"=",
"terminal_escape",
".",
"split",
"(",
"text",
")",
"n",
"=",
"0",
"# count the characters we actually write, omitting the escapes\r",
"if",
"attr",
... | u'''write text at current cursor position and interpret color escapes.
return the number of characters written. | [
"u",
"write",
"text",
"at",
"current",
"cursor",
"position",
"and",
"interpret",
"color",
"escapes",
".",
"return",
"the",
"number",
"of",
"characters",
"written",
"."
] | python | train | 45.176471 |
sethmlarson/virtualbox-python | virtualbox/library.py | https://github.com/sethmlarson/virtualbox-python/blob/706c8e3f6e3aee17eb06458e73cbb4bc2d37878b/virtualbox/library.py#L13862-L13878 | def get_usb_controller_by_name(self, name):
"""Returns a USB controller with the given type.
in name of type str
return controller of type :class:`IUSBController`
raises :class:`VBoxErrorObjectNotFound`
A USB controller with given name doesn't exist.
"""
... | [
"def",
"get_usb_controller_by_name",
"(",
"self",
",",
"name",
")",
":",
"if",
"not",
"isinstance",
"(",
"name",
",",
"basestring",
")",
":",
"raise",
"TypeError",
"(",
"\"name can only be an instance of type basestring\"",
")",
"controller",
"=",
"self",
".",
"_c... | Returns a USB controller with the given type.
in name of type str
return controller of type :class:`IUSBController`
raises :class:`VBoxErrorObjectNotFound`
A USB controller with given name doesn't exist. | [
"Returns",
"a",
"USB",
"controller",
"with",
"the",
"given",
"type",
"."
] | python | train | 34.823529 |
sharibarboza/py_zap | py_zap/py_zap.py | https://github.com/sharibarboza/py_zap/blob/ce90853efcad66d3e28b8f1ac910f275349d016c/py_zap/py_zap.py#L165-L176 | def get_json(self):
"""Serialize ratings object as JSON-formatted string"""
ratings_dict = {
'category': self.category,
'date': self.date,
'day': self.weekday,
'next week': self.next_week,
'last week': self.last_week,
'entries': sel... | [
"def",
"get_json",
"(",
"self",
")",
":",
"ratings_dict",
"=",
"{",
"'category'",
":",
"self",
".",
"category",
",",
"'date'",
":",
"self",
".",
"date",
",",
"'day'",
":",
"self",
".",
"weekday",
",",
"'next week'",
":",
"self",
".",
"next_week",
",",
... | Serialize ratings object as JSON-formatted string | [
"Serialize",
"ratings",
"object",
"as",
"JSON",
"-",
"formatted",
"string"
] | python | train | 32.833333 |
hvac/hvac | hvac/api/auth_methods/github.py | https://github.com/hvac/hvac/blob/cce5b86889193f622c2a72a4a1b7e1c9c8aff1ce/hvac/api/auth_methods/github.py#L16-L52 | def configure(self, organization, base_url='', ttl='', max_ttl='', mount_point=DEFAULT_MOUNT_POINT):
"""Configure the connection parameters for GitHub.
This path honors the distinction between the create and update capabilities inside ACL policies.
Supported methods:
POST: /auth/{m... | [
"def",
"configure",
"(",
"self",
",",
"organization",
",",
"base_url",
"=",
"''",
",",
"ttl",
"=",
"''",
",",
"max_ttl",
"=",
"''",
",",
"mount_point",
"=",
"DEFAULT_MOUNT_POINT",
")",
":",
"params",
"=",
"{",
"'organization'",
":",
"organization",
",",
... | Configure the connection parameters for GitHub.
This path honors the distinction between the create and update capabilities inside ACL policies.
Supported methods:
POST: /auth/{mount_point}/config. Produces: 204 (empty body)
:param organization: The organization users must be par... | [
"Configure",
"the",
"connection",
"parameters",
"for",
"GitHub",
"."
] | python | train | 39.378378 |
spyder-ide/spyder | spyder/plugins/explorer/widgets.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L541-L547 | def startDrag(self, dropActions):
"""Reimplement Qt Method - handle drag event"""
data = QMimeData()
data.setUrls([QUrl(fname) for fname in self.get_selected_filenames()])
drag = QDrag(self)
drag.setMimeData(data)
drag.exec_() | [
"def",
"startDrag",
"(",
"self",
",",
"dropActions",
")",
":",
"data",
"=",
"QMimeData",
"(",
")",
"data",
".",
"setUrls",
"(",
"[",
"QUrl",
"(",
"fname",
")",
"for",
"fname",
"in",
"self",
".",
"get_selected_filenames",
"(",
")",
"]",
")",
"drag",
"... | Reimplement Qt Method - handle drag event | [
"Reimplement",
"Qt",
"Method",
"-",
"handle",
"drag",
"event"
] | python | train | 39.142857 |
dariusbakunas/rawdisk | rawdisk/plugins/filesystems/ntfs/bootsector.py | https://github.com/dariusbakunas/rawdisk/blob/1dc9d0b377fe5da3c406ccec4abc238c54167403/rawdisk/plugins/filesystems/ntfs/bootsector.py#L51-L60 | def mft_record_size(self):
"""
Returns:
int: MFT record size in bytes
"""
if self.extended_bpb.clusters_per_mft < 0:
return 2 ** abs(self.extended_bpb.clusters_per_mft)
else:
return self.clusters_per_mft * self.sectors_per_cluster * \
... | [
"def",
"mft_record_size",
"(",
"self",
")",
":",
"if",
"self",
".",
"extended_bpb",
".",
"clusters_per_mft",
"<",
"0",
":",
"return",
"2",
"**",
"abs",
"(",
"self",
".",
"extended_bpb",
".",
"clusters_per_mft",
")",
"else",
":",
"return",
"self",
".",
"c... | Returns:
int: MFT record size in bytes | [
"Returns",
":",
"int",
":",
"MFT",
"record",
"size",
"in",
"bytes"
] | python | train | 33.9 |
seleniumbase/SeleniumBase | seleniumbase/core/tour_helper.py | https://github.com/seleniumbase/SeleniumBase/blob/62e5b43ee1f90a9ed923841bdd53b1b38358f43a/seleniumbase/core/tour_helper.py#L68-L99 | def activate_hopscotch(driver):
""" Allows you to use Hopscotch Tours with SeleniumBase
http://linkedin.github.io/hopscotch/
"""
hopscotch_css = constants.Hopscotch.MIN_CSS
hopscotch_js = constants.Hopscotch.MIN_JS
backdrop_style = style_sheet.hops_backdrop_style
verify_script = ("""// ... | [
"def",
"activate_hopscotch",
"(",
"driver",
")",
":",
"hopscotch_css",
"=",
"constants",
".",
"Hopscotch",
".",
"MIN_CSS",
"hopscotch_js",
"=",
"constants",
".",
"Hopscotch",
".",
"MIN_JS",
"backdrop_style",
"=",
"style_sheet",
".",
"hops_backdrop_style",
"verify_sc... | Allows you to use Hopscotch Tours with SeleniumBase
http://linkedin.github.io/hopscotch/ | [
"Allows",
"you",
"to",
"use",
"Hopscotch",
"Tours",
"with",
"SeleniumBase",
"http",
":",
"//",
"linkedin",
".",
"github",
".",
"io",
"/",
"hopscotch",
"/"
] | python | train | 38.875 |
PGower/PyCanvas | pycanvas/apis/modules.py | https://github.com/PGower/PyCanvas/blob/68520005382b440a1e462f9df369f54d364e21e8/pycanvas/apis/modules.py#L496-L534 | def select_mastery_path(self, id, course_id, module_id, assignment_set_id=None, student_id=None):
"""
Select a mastery path.
Select a mastery path when module item includes several possible paths.
Requires Mastery Paths feature to be enabled. Returns a compound document
w... | [
"def",
"select_mastery_path",
"(",
"self",
",",
"id",
",",
"course_id",
",",
"module_id",
",",
"assignment_set_id",
"=",
"None",
",",
"student_id",
"=",
"None",
")",
":",
"path",
"=",
"{",
"}",
"data",
"=",
"{",
"}",
"params",
"=",
"{",
"}",
"# REQUIRE... | Select a mastery path.
Select a mastery path when module item includes several possible paths.
Requires Mastery Paths feature to be enabled. Returns a compound document
with the assignments included in the given path and any module items
related to those assignments | [
"Select",
"a",
"mastery",
"path",
".",
"Select",
"a",
"mastery",
"path",
"when",
"module",
"item",
"includes",
"several",
"possible",
"paths",
".",
"Requires",
"Mastery",
"Paths",
"feature",
"to",
"be",
"enabled",
".",
"Returns",
"a",
"compound",
"document",
... | python | train | 41.384615 |
AnalogJ/lexicon | lexicon/providers/route53.py | https://github.com/AnalogJ/lexicon/blob/9330b871988753cad44fe2876a217b4c67b1fa0e/lexicon/providers/route53.py#L182-L206 | def _list_records(self, rtype=None, name=None, content=None):
"""List all records for the hosted zone."""
records = []
paginator = RecordSetPaginator(self.r53_client, self.domain_id)
for record in paginator.all_record_sets():
if rtype is not None and record['Type'] != rtype:
... | [
"def",
"_list_records",
"(",
"self",
",",
"rtype",
"=",
"None",
",",
"name",
"=",
"None",
",",
"content",
"=",
"None",
")",
":",
"records",
"=",
"[",
"]",
"paginator",
"=",
"RecordSetPaginator",
"(",
"self",
".",
"r53_client",
",",
"self",
".",
"domain... | List all records for the hosted zone. | [
"List",
"all",
"records",
"for",
"the",
"hosted",
"zone",
"."
] | python | train | 51.32 |
flowersteam/explauto | explauto/sensorimotor_model/inverse/cma.py | https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L7250-L7276 | def plot(self, plot_cmd=None, tf=lambda y: y):
"""plot the data we have, return ``self``"""
if not plot_cmd:
plot_cmd = self.plot_cmd
colors = 'bgrcmyk'
pyplot.hold(False)
res = self.res
flatx, flatf = self.flattened()
minf = np.inf
for i in f... | [
"def",
"plot",
"(",
"self",
",",
"plot_cmd",
"=",
"None",
",",
"tf",
"=",
"lambda",
"y",
":",
"y",
")",
":",
"if",
"not",
"plot_cmd",
":",
"plot_cmd",
"=",
"self",
".",
"plot_cmd",
"colors",
"=",
"'bgrcmyk'",
"pyplot",
".",
"hold",
"(",
"False",
")... | plot the data we have, return ``self`` | [
"plot",
"the",
"data",
"we",
"have",
"return",
"self"
] | python | train | 38.111111 |
saltstack/salt | salt/modules/schedule.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/schedule.py#L286-L393 | def build_schedule_item(name, **kwargs):
'''
Build a schedule job
CLI Example:
.. code-block:: bash
salt '*' schedule.build_schedule_item job1 function='test.ping' seconds=3600
'''
ret = {'comment': [],
'result': True}
if not name:
ret['comment'] = 'Job name i... | [
"def",
"build_schedule_item",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"{",
"'comment'",
":",
"[",
"]",
",",
"'result'",
":",
"True",
"}",
"if",
"not",
"name",
":",
"ret",
"[",
"'comment'",
"]",
"=",
"'Job name is required.'",
"ret",... | Build a schedule job
CLI Example:
.. code-block:: bash
salt '*' schedule.build_schedule_item job1 function='test.ping' seconds=3600 | [
"Build",
"a",
"schedule",
"job"
] | python | train | 31.212963 |
maas/python-libmaas | maas/client/flesh/machines.py | https://github.com/maas/python-libmaas/blob/4092c68ef7fb1753efc843569848e2bcc3415002/maas/client/flesh/machines.py#L343-L351 | def perform_action(
self, action, machines, params, progress_title, success_title):
"""Perform the action on the set of machines."""
if len(machines) == 0:
return 0
with utils.Spinner() as context:
return self._async_perform_action(
context, ac... | [
"def",
"perform_action",
"(",
"self",
",",
"action",
",",
"machines",
",",
"params",
",",
"progress_title",
",",
"success_title",
")",
":",
"if",
"len",
"(",
"machines",
")",
"==",
"0",
":",
"return",
"0",
"with",
"utils",
".",
"Spinner",
"(",
")",
"as... | Perform the action on the set of machines. | [
"Perform",
"the",
"action",
"on",
"the",
"set",
"of",
"machines",
"."
] | python | train | 43.111111 |
noahmorrison/chevron | chevron/renderer.py | https://github.com/noahmorrison/chevron/blob/78f1a384eddef16906732d8db66deea6d37049b7/chevron/renderer.py#L124-L367 | def render(template='', data={}, partials_path='.', partials_ext='mustache',
partials_dict={}, padding='', def_ldel='{{', def_rdel='}}',
scopes=None):
"""Render a mustache template.
Renders a mustache template with a data scope and partial capability.
Given the file structure...
╷... | [
"def",
"render",
"(",
"template",
"=",
"''",
",",
"data",
"=",
"{",
"}",
",",
"partials_path",
"=",
"'.'",
",",
"partials_ext",
"=",
"'mustache'",
",",
"partials_dict",
"=",
"{",
"}",
",",
"padding",
"=",
"''",
",",
"def_ldel",
"=",
"'{{'",
",",
"def... | Render a mustache template.
Renders a mustache template with a data scope and partial capability.
Given the file structure...
╷
├─╼ main.py
├─╼ main.ms
└─┮ partials
└── part.ms
then main.py would make the following call:
render(open('main.ms', 'r'), {...}, 'partials', 'ms')
... | [
"Render",
"a",
"mustache",
"template",
"."
] | python | train | 36.504098 |
yandex/yandex-tank | yandextank/stepper/load_plan.py | https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/stepper/load_plan.py#L109-L119 | def get_rps_list(self):
"""
get list of each second's rps
:returns: list of tuples (rps, duration of corresponding rps in seconds)
:rtype: list
"""
seconds = range(0, int(self.duration) + 1)
rps_groups = groupby([proper_round(self.rps_at(t)) for t in seconds],
... | [
"def",
"get_rps_list",
"(",
"self",
")",
":",
"seconds",
"=",
"range",
"(",
"0",
",",
"int",
"(",
"self",
".",
"duration",
")",
"+",
"1",
")",
"rps_groups",
"=",
"groupby",
"(",
"[",
"proper_round",
"(",
"self",
".",
"rps_at",
"(",
"t",
")",
")",
... | get list of each second's rps
:returns: list of tuples (rps, duration of corresponding rps in seconds)
:rtype: list | [
"get",
"list",
"of",
"each",
"second",
"s",
"rps",
":",
"returns",
":",
"list",
"of",
"tuples",
"(",
"rps",
"duration",
"of",
"corresponding",
"rps",
"in",
"seconds",
")",
":",
"rtype",
":",
"list"
] | python | test | 40.181818 |
Neurosim-lab/netpyne | netpyne/support/morphology.py | https://github.com/Neurosim-lab/netpyne/blob/edb67b5098b2e7923d55010ded59ad1bf75c0f18/netpyne/support/morphology.py#L408-L418 | def root_sections(h):
"""
Returns a list of all sections that have no parent.
"""
roots = []
for section in h.allsec():
sref = h.SectionRef(sec=section)
# has_parent returns a float... cast to bool
if sref.has_parent() < 0.9:
roots.append(section)
return roots | [
"def",
"root_sections",
"(",
"h",
")",
":",
"roots",
"=",
"[",
"]",
"for",
"section",
"in",
"h",
".",
"allsec",
"(",
")",
":",
"sref",
"=",
"h",
".",
"SectionRef",
"(",
"sec",
"=",
"section",
")",
"# has_parent returns a float... cast to bool",
"if",
"sr... | Returns a list of all sections that have no parent. | [
"Returns",
"a",
"list",
"of",
"all",
"sections",
"that",
"have",
"no",
"parent",
"."
] | python | train | 28.181818 |
kyb3r/dhooks | dhooks/embed.py | https://github.com/kyb3r/dhooks/blob/2cde52b26cc94dcbf538ebcc4e17dfc3714d2827/dhooks/embed.py#L189-L205 | def set_footer(self, text: str, icon_url: str = None) -> None:
"""
Sets the footer of the embed.
Parameters
----------
text: str
The footer text.
icon_url: str, optional
URL for the icon in the footer.
"""
self.footer = {
... | [
"def",
"set_footer",
"(",
"self",
",",
"text",
":",
"str",
",",
"icon_url",
":",
"str",
"=",
"None",
")",
"->",
"None",
":",
"self",
".",
"footer",
"=",
"{",
"'text'",
":",
"text",
",",
"'icon_url'",
":",
"icon_url",
"}"
] | Sets the footer of the embed.
Parameters
----------
text: str
The footer text.
icon_url: str, optional
URL for the icon in the footer. | [
"Sets",
"the",
"footer",
"of",
"the",
"embed",
"."
] | python | train | 21.470588 |
PyCQA/astroid | astroid/node_classes.py | https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/node_classes.py#L423-L436 | def get_children(self):
"""Get the child nodes below this node.
:returns: The children.
:rtype: iterable(NodeNG)
"""
for field in self._astroid_fields:
attr = getattr(self, field)
if attr is None:
continue
if isinstance(attr, (... | [
"def",
"get_children",
"(",
"self",
")",
":",
"for",
"field",
"in",
"self",
".",
"_astroid_fields",
":",
"attr",
"=",
"getattr",
"(",
"self",
",",
"field",
")",
"if",
"attr",
"is",
"None",
":",
"continue",
"if",
"isinstance",
"(",
"attr",
",",
"(",
"... | Get the child nodes below this node.
:returns: The children.
:rtype: iterable(NodeNG) | [
"Get",
"the",
"child",
"nodes",
"below",
"this",
"node",
"."
] | python | train | 28.428571 |
DistrictDataLabs/yellowbrick | yellowbrick/datasets/base.py | https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/datasets/base.py#L110-L122 | def citation(self):
"""
Returns the contents of the citation.bib file that describes the source
and provenance of the dataset or to cite for academic work.
"""
path = find_dataset_path(
self.name, data_home=self.data_home, fname="meta.json", raises=False
)
... | [
"def",
"citation",
"(",
"self",
")",
":",
"path",
"=",
"find_dataset_path",
"(",
"self",
".",
"name",
",",
"data_home",
"=",
"self",
".",
"data_home",
",",
"fname",
"=",
"\"meta.json\"",
",",
"raises",
"=",
"False",
")",
"if",
"path",
"is",
"None",
":"... | Returns the contents of the citation.bib file that describes the source
and provenance of the dataset or to cite for academic work. | [
"Returns",
"the",
"contents",
"of",
"the",
"citation",
".",
"bib",
"file",
"that",
"describes",
"the",
"source",
"and",
"provenance",
"of",
"the",
"dataset",
"or",
"to",
"cite",
"for",
"academic",
"work",
"."
] | python | train | 32.076923 |
inodb/sufam | sufam/mpileup_parser.py | https://github.com/inodb/sufam/blob/d4e41c5478ca9ba58be44d95106885c096c90a74/sufam/mpileup_parser.py#L97-L136 | def run(bam, chrom, pos1, pos2, reffa, chr_reffa, parameters):
"""Run mpileup on given chrom and pos"""
# check for chr ref
is_chr_query = chrom.startswith('chr')
if is_chr_query and chr_reffa is None:
chr_reffa = reffa
# check bam ref type
bam_header = subprocess.check_output("samtool... | [
"def",
"run",
"(",
"bam",
",",
"chrom",
",",
"pos1",
",",
"pos2",
",",
"reffa",
",",
"chr_reffa",
",",
"parameters",
")",
":",
"# check for chr ref",
"is_chr_query",
"=",
"chrom",
".",
"startswith",
"(",
"'chr'",
")",
"if",
"is_chr_query",
"and",
"chr_reff... | Run mpileup on given chrom and pos | [
"Run",
"mpileup",
"on",
"given",
"chrom",
"and",
"pos"
] | python | train | 43.55 |
opereto/pyopereto | pyopereto/client.py | https://github.com/opereto/pyopereto/blob/16ca987738a7e1b82b52b0b099794a74ed557223/pyopereto/client.py#L1074-L1094 | def modify_process_summary(self, pid=None, text='', append=False):
'''
modify_process_summary(self, pid=None, text='')
Modifies the summary text of the process execution
:Parameters:
* *key* (`pid`) -- Identifier of an existing process
* *key* (`text`) -- summary text
... | [
"def",
"modify_process_summary",
"(",
"self",
",",
"pid",
"=",
"None",
",",
"text",
"=",
"''",
",",
"append",
"=",
"False",
")",
":",
"pid",
"=",
"self",
".",
"_get_pid",
"(",
"pid",
")",
"if",
"append",
":",
"current_summary",
"=",
"self",
".",
"get... | modify_process_summary(self, pid=None, text='')
Modifies the summary text of the process execution
:Parameters:
* *key* (`pid`) -- Identifier of an existing process
* *key* (`text`) -- summary text
* *append* (`boolean`) -- True to append to summary. False to override it. | [
"modify_process_summary",
"(",
"self",
"pid",
"=",
"None",
"text",
"=",
")"
] | python | train | 38.380952 |
tsnaomi/finnsyll | finnsyll/prev/v02.py | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v02.py#L231-L250 | def apply_T7(word):
'''If a VVV-sequence does not contain a potential /i/-final diphthong,
there is a syllable boundary between the second and third vowels, e.g.
[kau.an], [leu.an], [kiu.as].'''
T7 = ''
WORD = word.split('.')
for i, v in enumerate(WORD):
if contains_VVV(v):
... | [
"def",
"apply_T7",
"(",
"word",
")",
":",
"T7",
"=",
"''",
"WORD",
"=",
"word",
".",
"split",
"(",
"'.'",
")",
"for",
"i",
",",
"v",
"in",
"enumerate",
"(",
"WORD",
")",
":",
"if",
"contains_VVV",
"(",
"v",
")",
":",
"for",
"I",
",",
"V",
"in... | If a VVV-sequence does not contain a potential /i/-final diphthong,
there is a syllable boundary between the second and third vowels, e.g.
[kau.an], [leu.an], [kiu.as]. | [
"If",
"a",
"VVV",
"-",
"sequence",
"does",
"not",
"contain",
"a",
"potential",
"/",
"i",
"/",
"-",
"final",
"diphthong",
"there",
"is",
"a",
"syllable",
"boundary",
"between",
"the",
"second",
"and",
"third",
"vowels",
"e",
".",
"g",
".",
"[",
"kau",
... | python | train | 24.8 |
pklaus/brother_ql | brother_ql/raster.py | https://github.com/pklaus/brother_ql/blob/b551b1fc944873f3a2ead7032d144dfd81011e79/brother_ql/raster.py#L194-L208 | def add_compression(self, compression=True):
"""
Add an instruction enabling or disabling compression for the transmitted raster image lines.
Not all models support compression. If the specific model doesn't support it but this method
is called trying to enable it, either a warning is se... | [
"def",
"add_compression",
"(",
"self",
",",
"compression",
"=",
"True",
")",
":",
"if",
"self",
".",
"model",
"not",
"in",
"compressionsupport",
":",
"self",
".",
"_unsupported",
"(",
"\"Trying to set compression on a printer that doesn't support it\"",
")",
"return",... | Add an instruction enabling or disabling compression for the transmitted raster image lines.
Not all models support compression. If the specific model doesn't support it but this method
is called trying to enable it, either a warning is set or an exception is raised depending on
the value of :py... | [
"Add",
"an",
"instruction",
"enabling",
"or",
"disabling",
"compression",
"for",
"the",
"transmitted",
"raster",
"image",
"lines",
".",
"Not",
"all",
"models",
"support",
"compression",
".",
"If",
"the",
"specific",
"model",
"doesn",
"t",
"support",
"it",
"but... | python | train | 51.266667 |
coin-or/GiMPy | src/gimpy/graph.py | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L3001-L3076 | def min_cost_flow(self, display = None, **args):
'''
API:
min_cost_flow(self, display='off', **args)
Description:
Solves minimum cost flow problem using node/edge attributes with
the algorithm specified.
Pre:
(1) Assumes a directed graph in... | [
"def",
"min_cost_flow",
"(",
"self",
",",
"display",
"=",
"None",
",",
"*",
"*",
"args",
")",
":",
"if",
"display",
"is",
"None",
":",
"display",
"=",
"self",
".",
"attr",
"[",
"'display'",
"]",
"if",
"'algo'",
"in",
"args",
":",
"algorithm",
"=",
... | API:
min_cost_flow(self, display='off', **args)
Description:
Solves minimum cost flow problem using node/edge attributes with
the algorithm specified.
Pre:
(1) Assumes a directed graph in which each arc has 'capacity' and
'cost' attributes.
... | [
"API",
":",
"min_cost_flow",
"(",
"self",
"display",
"=",
"off",
"**",
"args",
")",
"Description",
":",
"Solves",
"minimum",
"cost",
"flow",
"problem",
"using",
"node",
"/",
"edge",
"attributes",
"with",
"the",
"algorithm",
"specified",
".",
"Pre",
":",
"(... | python | train | 47 |
materialsproject/pymatgen | pymatgen/core/structure.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/core/structure.py#L216-L224 | def composition(self):
"""
(Composition) Returns the composition
"""
elmap = collections.defaultdict(float)
for site in self:
for species, occu in site.species.items():
elmap[species] += occu
return Composition(elmap) | [
"def",
"composition",
"(",
"self",
")",
":",
"elmap",
"=",
"collections",
".",
"defaultdict",
"(",
"float",
")",
"for",
"site",
"in",
"self",
":",
"for",
"species",
",",
"occu",
"in",
"site",
".",
"species",
".",
"items",
"(",
")",
":",
"elmap",
"[",... | (Composition) Returns the composition | [
"(",
"Composition",
")",
"Returns",
"the",
"composition"
] | python | train | 31.666667 |
openfisca/openfisca-core | openfisca_core/taxscales.py | https://github.com/openfisca/openfisca-core/blob/92ce9396e29ae5d9bac5ea604cfce88517c6b35c/openfisca_core/taxscales.py#L248-L273 | def inverse(self):
"""Returns a new instance of MarginalRateTaxScale
Invert a taxscale:
Assume tax_scale composed of bracket which thresholds are expressed in term of brut revenue.
The inverse is another MarginalTaxSclae which thresholds are expressed in terms of net revenue.
... | [
"def",
"inverse",
"(",
"self",
")",
":",
"# threshold : threshold of brut revenue",
"# net_threshold: threshold of net revenue",
"# theta : ordonnée à l'origine des segments des différents seuils dans une",
"# représentation du revenu imposable comme fonction linéaire par",
"# mo... | Returns a new instance of MarginalRateTaxScale
Invert a taxscale:
Assume tax_scale composed of bracket which thresholds are expressed in term of brut revenue.
The inverse is another MarginalTaxSclae which thresholds are expressed in terms of net revenue.
If net = revbrut - ... | [
"Returns",
"a",
"new",
"instance",
"of",
"MarginalRateTaxScale"
] | python | train | 52.115385 |
arne-cl/discoursegraphs | src/discoursegraphs/readwrite/tiger.py | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/tiger.py#L319-L341 | def get_unconnected_nodes(sentence_graph):
"""
Takes a TigerSentenceGraph and returns a list of node IDs of
unconnected nodes.
A node is unconnected, if it doesn't have any in- or outgoing edges.
A node is NOT considered unconnected, if the graph only consists of
that particular node.
Para... | [
"def",
"get_unconnected_nodes",
"(",
"sentence_graph",
")",
":",
"return",
"[",
"node",
"for",
"node",
"in",
"sentence_graph",
".",
"nodes_iter",
"(",
")",
"if",
"sentence_graph",
".",
"degree",
"(",
"node",
")",
"==",
"0",
"and",
"sentence_graph",
".",
"num... | Takes a TigerSentenceGraph and returns a list of node IDs of
unconnected nodes.
A node is unconnected, if it doesn't have any in- or outgoing edges.
A node is NOT considered unconnected, if the graph only consists of
that particular node.
Parameters
----------
sentence_graph : TigerSentenc... | [
"Takes",
"a",
"TigerSentenceGraph",
"and",
"returns",
"a",
"list",
"of",
"node",
"IDs",
"of",
"unconnected",
"nodes",
"."
] | python | train | 31.956522 |
pymupdf/PyMuPDF | fitz/utils.py | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/utils.py#L2072-L2089 | def drawBezier(self, p1, p2, p3, p4):
"""Draw a standard cubic Bezier curve.
"""
p1 = Point(p1)
p2 = Point(p2)
p3 = Point(p3)
p4 = Point(p4)
if not (self.lastPoint == p1):
self.draw_cont += "%g %g m\n" % JM_TUPLE(p1 * self.ipctm)
self.draw_cont... | [
"def",
"drawBezier",
"(",
"self",
",",
"p1",
",",
"p2",
",",
"p3",
",",
"p4",
")",
":",
"p1",
"=",
"Point",
"(",
"p1",
")",
"p2",
"=",
"Point",
"(",
"p2",
")",
"p3",
"=",
"Point",
"(",
"p3",
")",
"p4",
"=",
"Point",
"(",
"p4",
")",
"if",
... | Draw a standard cubic Bezier curve. | [
"Draw",
"a",
"standard",
"cubic",
"Bezier",
"curve",
"."
] | python | train | 39 |
bdastur/rex | rex.py | https://github.com/bdastur/rex/blob/e45173aa93f05a1d2ee65746e6f6cc6d829daf60/rex.py#L275-L307 | def parse_lrvalue_string(search_string,
delimiter=":"):
'''
The function takes a multi-line output/string with the format
"name/descr : value", and converts it to a dictionary object
with key value pairs, where key is built from the name/desc
part and value as the value.
... | [
"def",
"parse_lrvalue_string",
"(",
"search_string",
",",
"delimiter",
"=",
"\":\"",
")",
":",
"mac_search_pattern",
"=",
"r\"(.*) *%s ([\\w|\\d]+.*)\"",
"%",
"delimiter",
"search_pattern",
"=",
"r\"(.*) *%s *(.*)\"",
"%",
"delimiter",
"rexdict",
"=",
"{",
"}",
"for",... | The function takes a multi-line output/string with the format
"name/descr : value", and converts it to a dictionary object
with key value pairs, where key is built from the name/desc
part and value as the value.
eg: "Serial Number: FCH1724V1GT" will be translated to
dict['serial_number'] = "FCH1... | [
"The",
"function",
"takes",
"a",
"multi",
"-",
"line",
"output",
"/",
"string",
"with",
"the",
"format",
"name",
"/",
"descr",
":",
"value",
"and",
"converts",
"it",
"to",
"a",
"dictionary",
"object",
"with",
"key",
"value",
"pairs",
"where",
"key",
"is"... | python | train | 32.848485 |
rvswift/EB | EB/builder/utilities/classification.py | https://github.com/rvswift/EB/blob/341880b79faf8147dc9fa6e90438531cd09fabcc/EB/builder/utilities/classification.py#L153-L171 | def calculate_ef_var(tpf, fpf):
"""
determine variance due to actives (efvar_a) decoys (efvar_d) and s2, the slope of the ROC curve tangent to the
fpf @ which the enrichment factor was calculated
:param tpf: float tpf @ which the enrichment factor was calculated
:param fpf: float fpf @ which the enr... | [
"def",
"calculate_ef_var",
"(",
"tpf",
",",
"fpf",
")",
":",
"efvara",
"=",
"(",
"tpf",
"*",
"(",
"1",
"-",
"tpf",
")",
")",
"efvard",
"=",
"(",
"fpf",
"*",
"(",
"1",
"-",
"fpf",
")",
")",
"ef",
"=",
"tpf",
"/",
"fpf",
"if",
"fpf",
"==",
"1... | determine variance due to actives (efvar_a) decoys (efvar_d) and s2, the slope of the ROC curve tangent to the
fpf @ which the enrichment factor was calculated
:param tpf: float tpf @ which the enrichment factor was calculated
:param fpf: float fpf @ which the enrichment factor was calculated
:return ef... | [
"determine",
"variance",
"due",
"to",
"actives",
"(",
"efvar_a",
")",
"decoys",
"(",
"efvar_d",
")",
"and",
"s2",
"the",
"slope",
"of",
"the",
"ROC",
"curve",
"tangent",
"to",
"the",
"fpf"
] | python | train | 32.368421 |
mrname/haralyzer | haralyzer/multihar.py | https://github.com/mrname/haralyzer/blob/5ef38b8cfc044d2dfeacf2dd4d1efb810228309d/haralyzer/multihar.py#L164-L169 | def video_load_time(self):
"""
Returns aggregate video load time for all pages.
"""
load_times = self.get_load_times('video')
return round(mean(load_times), self.decimal_precision) | [
"def",
"video_load_time",
"(",
"self",
")",
":",
"load_times",
"=",
"self",
".",
"get_load_times",
"(",
"'video'",
")",
"return",
"round",
"(",
"mean",
"(",
"load_times",
")",
",",
"self",
".",
"decimal_precision",
")"
] | Returns aggregate video load time for all pages. | [
"Returns",
"aggregate",
"video",
"load",
"time",
"for",
"all",
"pages",
"."
] | python | train | 35.833333 |
iotile/coretools | iotileemulate/iotile/emulate/internal/emulation_loop.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/internal/emulation_loop.py#L70-L103 | def create_event(self, register=False):
"""Create an asyncio.Event inside the emulation loop.
This method exists as a convenience to create an Event object that is
associated with the correct EventLoop(). If you pass register=True,
then the event will be registered as an event that mus... | [
"def",
"create_event",
"(",
"self",
",",
"register",
"=",
"False",
")",
":",
"event",
"=",
"asyncio",
".",
"Event",
"(",
"loop",
"=",
"self",
".",
"_loop",
")",
"if",
"register",
":",
"self",
".",
"_events",
".",
"add",
"(",
"event",
")",
"return",
... | Create an asyncio.Event inside the emulation loop.
This method exists as a convenience to create an Event object that is
associated with the correct EventLoop(). If you pass register=True,
then the event will be registered as an event that must be set for the
EmulationLoop to be consid... | [
"Create",
"an",
"asyncio",
".",
"Event",
"inside",
"the",
"emulation",
"loop",
"."
] | python | train | 42.5 |
todddeluca/fabvenv | fabvenv.py | https://github.com/todddeluca/fabvenv/blob/ba0121412a7f47b3732d45b6cee42ac2b8737159/fabvenv.py#L111-L124 | def venv_pth(self, dirs):
'''
Add the directories in `dirs` to the `sys.path`. A venv.pth file
will be written in the site-packages dir of this virtualenv to add
dirs to sys.path.
dirs: a list of directories.
'''
# Create venv.pth to add dirs to sys.path when us... | [
"def",
"venv_pth",
"(",
"self",
",",
"dirs",
")",
":",
"# Create venv.pth to add dirs to sys.path when using the virtualenv.",
"text",
"=",
"StringIO",
".",
"StringIO",
"(",
")",
"text",
".",
"write",
"(",
"\"# Autogenerated file. Do not modify.\\n\"",
")",
"for",
"pat... | Add the directories in `dirs` to the `sys.path`. A venv.pth file
will be written in the site-packages dir of this virtualenv to add
dirs to sys.path.
dirs: a list of directories. | [
"Add",
"the",
"directories",
"in",
"dirs",
"to",
"the",
"sys",
".",
"path",
".",
"A",
"venv",
".",
"pth",
"file",
"will",
"be",
"written",
"in",
"the",
"site",
"-",
"packages",
"dir",
"of",
"this",
"virtualenv",
"to",
"add",
"dirs",
"to",
"sys",
".",... | python | train | 41 |
neithere/django-navigation | navigation/templatetags/navigation_tags.py | https://github.com/neithere/django-navigation/blob/aff8d671a8431c84dde65cba6236ea8c16a08b4d/navigation/templatetags/navigation_tags.py#L219-L229 | def named_crumb(context, name, *args, **kwargs):
""" Resolves given named URL and returns the relevant breadcrumb label (if
available). Usage::
<a href="{% url project-detail project.slug %}">
{% named_crumb project-detail project.slug %}
</a>
"""
url = reverse(name, args=a... | [
"def",
"named_crumb",
"(",
"context",
",",
"name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"reverse",
"(",
"name",
",",
"args",
"=",
"args",
",",
"kwargs",
"=",
"kwargs",
")",
"return",
"find_crumb",
"(",
"context",
"[",
"'... | Resolves given named URL and returns the relevant breadcrumb label (if
available). Usage::
<a href="{% url project-detail project.slug %}">
{% named_crumb project-detail project.slug %}
</a> | [
"Resolves",
"given",
"named",
"URL",
"and",
"returns",
"the",
"relevant",
"breadcrumb",
"label",
"(",
"if",
"available",
")",
".",
"Usage",
"::"
] | python | train | 34.181818 |
pbrisk/businessdate | businessdate/businessdate.py | https://github.com/pbrisk/businessdate/blob/79a0c5a4e557cbacca82a430403b18413404a9bc/businessdate/businessdate.py#L761-L777 | def is_businessperiod(cls, in_period):
"""
:param in_period: object to be checked
:type in_period: object, str, timedelta
:return: True if cast works
:rtype: Boolean
checks is argument con becasted to BusinessPeriod
"""
try: # to be removed
i... | [
"def",
"is_businessperiod",
"(",
"cls",
",",
"in_period",
")",
":",
"try",
":",
"# to be removed",
"if",
"str",
"(",
"in_period",
")",
".",
"upper",
"(",
")",
"==",
"'0D'",
":",
"return",
"True",
"else",
":",
"p",
"=",
"BusinessPeriod",
"(",
"str",
"("... | :param in_period: object to be checked
:type in_period: object, str, timedelta
:return: True if cast works
:rtype: Boolean
checks is argument con becasted to BusinessPeriod | [
":",
"param",
"in_period",
":",
"object",
"to",
"be",
"checked",
":",
"type",
"in_period",
":",
"object",
"str",
"timedelta",
":",
"return",
":",
"True",
"if",
"cast",
"works",
":",
"rtype",
":",
"Boolean"
] | python | valid | 33.823529 |
Azure/azure-cosmos-python | azure/cosmos/cosmos_client.py | https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/cosmos_client.py#L452-L475 | def UpsertUser(self, database_link, user, options=None):
"""Upserts a user.
:param str database_link:
The link to the database.
:param dict user:
The Azure Cosmos user to upsert.
:param dict options:
The request options for the request.
:retu... | [
"def",
"UpsertUser",
"(",
"self",
",",
"database_link",
",",
"user",
",",
"options",
"=",
"None",
")",
":",
"if",
"options",
"is",
"None",
":",
"options",
"=",
"{",
"}",
"database_id",
",",
"path",
"=",
"self",
".",
"_GetDatabaseIdWithPathForUser",
"(",
... | Upserts a user.
:param str database_link:
The link to the database.
:param dict user:
The Azure Cosmos user to upsert.
:param dict options:
The request options for the request.
:return:
The upserted User.
:rtype: dict | [
"Upserts",
"a",
"user",
"."
] | python | train | 29.708333 |
axltxl/m2bk | m2bk/config.py | https://github.com/axltxl/m2bk/blob/980083dfd17e6e783753a946e9aa809714551141/m2bk/config.py#L113-L128 | def set_from_file(file_name):
"""
Merge configuration from a file with JSON data
:param file_name: name of the file to be read
:raises TypeError: if file_name is not str
"""
if type(file_name) != str:
raise TypeError('file_name must be str')
global _config_file_name
_config_file... | [
"def",
"set_from_file",
"(",
"file_name",
")",
":",
"if",
"type",
"(",
"file_name",
")",
"!=",
"str",
":",
"raise",
"TypeError",
"(",
"'file_name must be str'",
")",
"global",
"_config_file_name",
"_config_file_name",
"=",
"file_name",
"# Try to open the file and get ... | Merge configuration from a file with JSON data
:param file_name: name of the file to be read
:raises TypeError: if file_name is not str | [
"Merge",
"configuration",
"from",
"a",
"file",
"with",
"JSON",
"data"
] | python | train | 34.8125 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L11202-L11221 | def optical_flow_rad_send(self, time_usec, sensor_id, integration_time_us, integrated_x, integrated_y, integrated_xgyro, integrated_ygyro, integrated_zgyro, temperature, quality, time_delta_distance_us, distance, force_mavlink1=False):
'''
Optical flow from an angular rate flow sensor (e... | [
"def",
"optical_flow_rad_send",
"(",
"self",
",",
"time_usec",
",",
"sensor_id",
",",
"integration_time_us",
",",
"integrated_x",
",",
"integrated_y",
",",
"integrated_xgyro",
",",
"integrated_ygyro",
",",
"integrated_zgyro",
",",
"temperature",
",",
"quality",
",",
... | Optical flow from an angular rate flow sensor (e.g. PX4FLOW or mouse
sensor)
time_usec : Timestamp (microseconds, synced to UNIX time or since system boot) (uint64_t)
sensor_id : Sensor ID (uint8_t)
integration_time_us ... | [
"Optical",
"flow",
"from",
"an",
"angular",
"rate",
"flow",
"sensor",
"(",
"e",
".",
"g",
".",
"PX4FLOW",
"or",
"mouse",
"sensor",
")"
] | python | train | 112.7 |
SKA-ScienceDataProcessor/integration-prototype | sip/science_pipeline_workflows/ingest_visibilities/recv/async_recv.py | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/science_pipeline_workflows/ingest_visibilities/recv/async_recv.py#L161-L167 | def run(self):
"""Starts the receiver."""
executor = concurrent.futures.ThreadPoolExecutor(max_workers=1)
loop = asyncio.get_event_loop()
loop.run_until_complete(self._run_loop(executor))
self._log.info('Shutting down...')
executor.shutdown() | [
"def",
"run",
"(",
"self",
")",
":",
"executor",
"=",
"concurrent",
".",
"futures",
".",
"ThreadPoolExecutor",
"(",
"max_workers",
"=",
"1",
")",
"loop",
"=",
"asyncio",
".",
"get_event_loop",
"(",
")",
"loop",
".",
"run_until_complete",
"(",
"self",
".",
... | Starts the receiver. | [
"Starts",
"the",
"receiver",
"."
] | python | train | 40.571429 |
quaddra/provision | provision/config.py | https://github.com/quaddra/provision/blob/d84dca80abb34ed93381aae4d5b8005bd08a5681/provision/config.py#L219-L232 | def import_by_path(path):
"""Append the path to sys.path, then attempt to import module with
path's basename, finally making certain to remove appended path.
http://stackoverflow.com/questions/1096216/override-namespace-in-python"""
sys.path.append(os.path.dirname(path))
try:
return __imp... | [
"def",
"import_by_path",
"(",
"path",
")",
":",
"sys",
".",
"path",
".",
"append",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"path",
")",
")",
"try",
":",
"return",
"__import__",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"path",
")",
")",
... | Append the path to sys.path, then attempt to import module with
path's basename, finally making certain to remove appended path.
http://stackoverflow.com/questions/1096216/override-namespace-in-python | [
"Append",
"the",
"path",
"to",
"sys",
".",
"path",
"then",
"attempt",
"to",
"import",
"module",
"with",
"path",
"s",
"basename",
"finally",
"making",
"certain",
"to",
"remove",
"appended",
"path",
"."
] | python | train | 32.5 |
andreasjansson/head-in-the-clouds | headintheclouds/docker.py | https://github.com/andreasjansson/head-in-the-clouds/blob/32c1d00d01036834dc94368e7f38b0afd3f7a82f/headintheclouds/docker.py#L191-L230 | def tunnel(container, local_port, remote_port=None, gateway_port=None):
'''
Set up an SSH tunnel into the container, using the host as a gateway host.
Args:
* container: Container name or ID
* local_port: Local port
* remote_port=None: Port on the Docker container (defaults to local... | [
"def",
"tunnel",
"(",
"container",
",",
"local_port",
",",
"remote_port",
"=",
"None",
",",
"gateway_port",
"=",
"None",
")",
":",
"if",
"remote_port",
"is",
"None",
":",
"remote_port",
"=",
"local_port",
"if",
"gateway_port",
"is",
"None",
":",
"gateway_por... | Set up an SSH tunnel into the container, using the host as a gateway host.
Args:
* container: Container name or ID
* local_port: Local port
* remote_port=None: Port on the Docker container (defaults to local_port)
* gateway_port=None: Port on the gateway host (defaults to remote_por... | [
"Set",
"up",
"an",
"SSH",
"tunnel",
"into",
"the",
"container",
"using",
"the",
"host",
"as",
"a",
"gateway",
"host",
"."
] | python | train | 32.1 |
jazzband/django-pipeline | pipeline/compressors/__init__.py | https://github.com/jazzband/django-pipeline/blob/3cd2f93bb47bf8d34447e13ff691f7027e7b07a2/pipeline/compressors/__init__.py#L192-L195 | def mime_type(self, path):
"""Get mime-type from filename"""
name, ext = os.path.splitext(path)
return MIME_TYPES[ext] | [
"def",
"mime_type",
"(",
"self",
",",
"path",
")",
":",
"name",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"path",
")",
"return",
"MIME_TYPES",
"[",
"ext",
"]"
] | Get mime-type from filename | [
"Get",
"mime",
"-",
"type",
"from",
"filename"
] | python | train | 34.75 |
oasis-open/cti-stix-validator | stix2validator/v21/shoulds.py | https://github.com/oasis-open/cti-stix-validator/blob/a607014e3fa500a7678f8b61b278456ca581f9d0/stix2validator/v21/shoulds.py#L926-L1016 | def hash_length(instance):
"""Ensure keys in 'hashes'-type properties are no more than 30 characters long.
"""
for key, obj in instance['objects'].items():
if 'type' not in obj:
continue
if obj['type'] == 'file':
try:
hashes = obj['hashes']
... | [
"def",
"hash_length",
"(",
"instance",
")",
":",
"for",
"key",
",",
"obj",
"in",
"instance",
"[",
"'objects'",
"]",
".",
"items",
"(",
")",
":",
"if",
"'type'",
"not",
"in",
"obj",
":",
"continue",
"if",
"obj",
"[",
"'type'",
"]",
"==",
"'file'",
"... | Ensure keys in 'hashes'-type properties are no more than 30 characters long. | [
"Ensure",
"keys",
"in",
"hashes",
"-",
"type",
"properties",
"are",
"no",
"more",
"than",
"30",
"characters",
"long",
"."
] | python | train | 45.428571 |
Microsoft/nni | tools/nni_cmd/tensorboard_utils.py | https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/tensorboard_utils.py#L38-L53 | def parse_log_path(args, trial_content):
'''parse log path'''
path_list = []
host_list = []
for trial in trial_content:
if args.trial_id and args.trial_id != 'all' and trial.get('id') != args.trial_id:
continue
pattern = r'(?P<head>.+)://(?P<host>.+):(?P<path>.*)'
mat... | [
"def",
"parse_log_path",
"(",
"args",
",",
"trial_content",
")",
":",
"path_list",
"=",
"[",
"]",
"host_list",
"=",
"[",
"]",
"for",
"trial",
"in",
"trial_content",
":",
"if",
"args",
".",
"trial_id",
"and",
"args",
".",
"trial_id",
"!=",
"'all'",
"and",... | parse log path | [
"parse",
"log",
"path"
] | python | train | 36.9375 |
DataDog/integrations-core | etcd/datadog_checks/etcd/etcd.py | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/etcd/datadog_checks/etcd/etcd.py#L270-L280 | def _get_health_status(self, url, ssl_params, timeout):
"""
Don't send the "can connect" service check if we have troubles getting
the health status
"""
try:
r = self._perform_request(url, "/health", ssl_params, timeout)
# we don't use get() here so we can... | [
"def",
"_get_health_status",
"(",
"self",
",",
"url",
",",
"ssl_params",
",",
"timeout",
")",
":",
"try",
":",
"r",
"=",
"self",
".",
"_perform_request",
"(",
"url",
",",
"\"/health\"",
",",
"ssl_params",
",",
"timeout",
")",
"# we don't use get() here so we c... | Don't send the "can connect" service check if we have troubles getting
the health status | [
"Don",
"t",
"send",
"the",
"can",
"connect",
"service",
"check",
"if",
"we",
"have",
"troubles",
"getting",
"the",
"health",
"status"
] | python | train | 43.454545 |
ncolony/ncolony | ncolony/ctllib.py | https://github.com/ncolony/ncolony/blob/6ac71bda1de6706fb34244ae4972e36db5f062d3/ncolony/ctllib.py#L56-L91 | def add(places, name, cmd, args, env=None, uid=None, gid=None, extras=None,
env_inherit=None):
"""Add a process.
:param places: a Places instance
:param name: string, the logical name of the process
:param cmd: string, executable
:param args: list of strings, command-line arguments
:par... | [
"def",
"add",
"(",
"places",
",",
"name",
",",
"cmd",
",",
"args",
",",
"env",
"=",
"None",
",",
"uid",
"=",
"None",
",",
"gid",
"=",
"None",
",",
"extras",
"=",
"None",
",",
"env_inherit",
"=",
"None",
")",
":",
"args",
"=",
"[",
"cmd",
"]",
... | Add a process.
:param places: a Places instance
:param name: string, the logical name of the process
:param cmd: string, executable
:param args: list of strings, command-line arguments
:param env: dictionary mapping strings to strings
(will be environment in subprocess)
:param uid: int... | [
"Add",
"a",
"process",
"."
] | python | test | 34.583333 |
LuqueDaniel/pybooru | pybooru/api_danbooru.py | https://github.com/LuqueDaniel/pybooru/blob/60cd5254684d293b308f0b11b8f4ac2dce101479/pybooru/api_danbooru.py#L965-L973 | def pool_revert(self, pool_id, version_id):
"""Function to revert a specific pool (Requires login) (UNTESTED).
Parameters:
pool_id (int): Where pool_id is the pool id.
version_id (int):
"""
return self._get('pools/{0}/revert.json'.format(pool_id),
... | [
"def",
"pool_revert",
"(",
"self",
",",
"pool_id",
",",
"version_id",
")",
":",
"return",
"self",
".",
"_get",
"(",
"'pools/{0}/revert.json'",
".",
"format",
"(",
"pool_id",
")",
",",
"{",
"'version_id'",
":",
"version_id",
"}",
",",
"method",
"=",
"'PUT'"... | Function to revert a specific pool (Requires login) (UNTESTED).
Parameters:
pool_id (int): Where pool_id is the pool id.
version_id (int): | [
"Function",
"to",
"revert",
"a",
"specific",
"pool",
"(",
"Requires",
"login",
")",
"(",
"UNTESTED",
")",
"."
] | python | train | 41.555556 |
joke2k/faker | faker/providers/date_time/__init__.py | https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/date_time/__init__.py#L1695-L1723 | def date_time_this_century(
self,
before_now=True,
after_now=False,
tzinfo=None):
"""
Gets a DateTime object for the current century.
:param before_now: include days in current century before today
:param after_now: include days in current... | [
"def",
"date_time_this_century",
"(",
"self",
",",
"before_now",
"=",
"True",
",",
"after_now",
"=",
"False",
",",
"tzinfo",
"=",
"None",
")",
":",
"now",
"=",
"datetime",
".",
"now",
"(",
"tzinfo",
")",
"this_century_start",
"=",
"datetime",
"(",
"now",
... | Gets a DateTime object for the current century.
:param before_now: include days in current century before today
:param after_now: include days in current century after today
:param tzinfo: timezone, instance of datetime.tzinfo subclass
:example DateTime('2012-04-04 11:02:02')
:r... | [
"Gets",
"a",
"DateTime",
"object",
"for",
"the",
"current",
"century",
"."
] | python | train | 39.896552 |
bykof/billomapy | billomapy/billomapy.py | https://github.com/bykof/billomapy/blob/a28ba69fd37654fa145d0411d52c200e7f8984ab/billomapy/billomapy.py#L2386-L2400 | def get_tags_of_offer_per_page(self, offer_id, per_page=1000, page=1):
"""
Get tags of offer per page
:param per_page: How many objects per page. Default: 1000
:param page: Which page. Default: 1
:param offer_id: the offer id
:return: list
"""
return self... | [
"def",
"get_tags_of_offer_per_page",
"(",
"self",
",",
"offer_id",
",",
"per_page",
"=",
"1000",
",",
"page",
"=",
"1",
")",
":",
"return",
"self",
".",
"_get_resource_per_page",
"(",
"resource",
"=",
"OFFER_TAGS",
",",
"per_page",
"=",
"per_page",
",",
"pag... | Get tags of offer per page
:param per_page: How many objects per page. Default: 1000
:param page: Which page. Default: 1
:param offer_id: the offer id
:return: list | [
"Get",
"tags",
"of",
"offer",
"per",
"page"
] | python | train | 31.333333 |
yero13/na3x | na3x/integration/request.py | https://github.com/yero13/na3x/blob/b31ef801ea574081125020a7d0f9c4242f8f8b02/na3x/integration/request.py#L142-L160 | def factory(cfg, login, pswd, request_type):
"""
Instantiate ExportRequest
:param cfg: request configuration, should consist of request description (url and optional parameters)
:param login:
:param pswd:
:param request_type: TYPE_SET_FIELD_VALUE || TYPE_CREATE_ENTITY || ... | [
"def",
"factory",
"(",
"cfg",
",",
"login",
",",
"pswd",
",",
"request_type",
")",
":",
"if",
"request_type",
"==",
"ExportRequest",
".",
"TYPE_SET_FIELD_VALUE",
":",
"return",
"SetFieldValueRequest",
"(",
"cfg",
",",
"login",
",",
"pswd",
")",
"elif",
"requ... | Instantiate ExportRequest
:param cfg: request configuration, should consist of request description (url and optional parameters)
:param login:
:param pswd:
:param request_type: TYPE_SET_FIELD_VALUE || TYPE_CREATE_ENTITY || TYPE_DELETE_ENTITY || TYPE_CREATE_RELATION
:return: Expor... | [
"Instantiate",
"ExportRequest",
":",
"param",
"cfg",
":",
"request",
"configuration",
"should",
"consist",
"of",
"request",
"description",
"(",
"url",
"and",
"optional",
"parameters",
")",
":",
"param",
"login",
":",
":",
"param",
"pswd",
":",
":",
"param",
... | python | train | 52.052632 |
hosford42/xcs | build_readme.py | https://github.com/hosford42/xcs/blob/183bdd0dd339e19ded3be202f86e1b38bdb9f1e5/build_readme.py#L17-L68 | def convert_md_to_rst(source, destination=None, backup_dir=None):
"""Try to convert the source, an .md (markdown) file, to an .rst
(reStructuredText) file at the destination. If the destination isn't
provided, it defaults to be the same as the source path except for the
filename extension. If the destin... | [
"def",
"convert_md_to_rst",
"(",
"source",
",",
"destination",
"=",
"None",
",",
"backup_dir",
"=",
"None",
")",
":",
"# Doing this in the function instead of the module level ensures the",
"# error occurs when the function is called, rather than when the module",
"# is evaluated.",
... | Try to convert the source, an .md (markdown) file, to an .rst
(reStructuredText) file at the destination. If the destination isn't
provided, it defaults to be the same as the source path except for the
filename extension. If the destination file already exists, it will be
overwritten. In the event of an... | [
"Try",
"to",
"convert",
"the",
"source",
"an",
".",
"md",
"(",
"markdown",
")",
"file",
"to",
"an",
".",
"rst",
"(",
"reStructuredText",
")",
"file",
"at",
"the",
"destination",
".",
"If",
"the",
"destination",
"isn",
"t",
"provided",
"it",
"defaults",
... | python | train | 37.980769 |
ibm-watson-data-lab/ibmseti | ibmseti/features.py | https://github.com/ibm-watson-data-lab/ibmseti/blob/3361bc0adb4770dc7a554ed7cda292503892acee/ibmseti/features.py#L149-L163 | def total_variation(arr):
'''
If arr is a 2D array (N X M), assumes that arr is a spectrogram with time along axis=0.
Calculates the 1D total variation in time for each frequency and returns an array
of size M.
If arr is a 1D array, calculates total variation and returns a scalar.
Sum ( Abs(arr_i+1,j - ... | [
"def",
"total_variation",
"(",
"arr",
")",
":",
"return",
"np",
".",
"sum",
"(",
"np",
".",
"abs",
"(",
"np",
".",
"diff",
"(",
"arr",
",",
"axis",
"=",
"0",
")",
")",
",",
"axis",
"=",
"0",
")"
] | If arr is a 2D array (N X M), assumes that arr is a spectrogram with time along axis=0.
Calculates the 1D total variation in time for each frequency and returns an array
of size M.
If arr is a 1D array, calculates total variation and returns a scalar.
Sum ( Abs(arr_i+1,j - arr_ij) )
If arr is a 2D array,... | [
"If",
"arr",
"is",
"a",
"2D",
"array",
"(",
"N",
"X",
"M",
")",
"assumes",
"that",
"arr",
"is",
"a",
"spectrogram",
"with",
"time",
"along",
"axis",
"=",
"0",
"."
] | python | train | 32.866667 |
Qiskit/qiskit-terra | qiskit/transpiler/passmanager.py | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passmanager.py#L185-L194 | def passes(self):
"""
Returns a list structure of the appended passes and its options.
Returns (list): The appended passes.
"""
ret = []
for pass_ in self.working_list:
ret.append(pass_.dump_passes())
return ret | [
"def",
"passes",
"(",
"self",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"pass_",
"in",
"self",
".",
"working_list",
":",
"ret",
".",
"append",
"(",
"pass_",
".",
"dump_passes",
"(",
")",
")",
"return",
"ret"
] | Returns a list structure of the appended passes and its options.
Returns (list): The appended passes. | [
"Returns",
"a",
"list",
"structure",
"of",
"the",
"appended",
"passes",
"and",
"its",
"options",
"."
] | python | test | 27.1 |
waqasbhatti/astrobase | astrobase/timeutils.py | https://github.com/waqasbhatti/astrobase/blob/2922a14619d183fb28005fa7d02027ac436f2265/astrobase/timeutils.py#L442-L469 | def jd_to_datetime(jd, returniso=False):
'''This converts a UTC JD to a Python `datetime` object or ISO date string.
Parameters
----------
jd : float
The Julian date measured at UTC.
returniso : bool
If False, returns a naive Python `datetime` object corresponding to
`jd`.... | [
"def",
"jd_to_datetime",
"(",
"jd",
",",
"returniso",
"=",
"False",
")",
":",
"tt",
"=",
"astime",
".",
"Time",
"(",
"jd",
",",
"format",
"=",
"'jd'",
",",
"scale",
"=",
"'utc'",
")",
"if",
"returniso",
":",
"return",
"tt",
".",
"iso",
"else",
":",... | This converts a UTC JD to a Python `datetime` object or ISO date string.
Parameters
----------
jd : float
The Julian date measured at UTC.
returniso : bool
If False, returns a naive Python `datetime` object corresponding to
`jd`. If True, returns the ISO format string correspo... | [
"This",
"converts",
"a",
"UTC",
"JD",
"to",
"a",
"Python",
"datetime",
"object",
"or",
"ISO",
"date",
"string",
"."
] | python | valid | 22.321429 |
apache/incubator-heron | heronpy/api/topology.py | https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/heronpy/api/topology.py#L72-L85 | def class_dict_to_specs(mcs, class_dict):
"""Takes a class `__dict__` and returns `HeronComponentSpec` entries"""
specs = {}
for name, spec in class_dict.items():
if isinstance(spec, HeronComponentSpec):
# Use the variable name as the specification name.
if spec.name is None:
... | [
"def",
"class_dict_to_specs",
"(",
"mcs",
",",
"class_dict",
")",
":",
"specs",
"=",
"{",
"}",
"for",
"name",
",",
"spec",
"in",
"class_dict",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"spec",
",",
"HeronComponentSpec",
")",
":",
"# Use the v... | Takes a class `__dict__` and returns `HeronComponentSpec` entries | [
"Takes",
"a",
"class",
"__dict__",
"and",
"returns",
"HeronComponentSpec",
"entries"
] | python | valid | 35.142857 |
wonambi-python/wonambi | setup_wonambi.py | https://github.com/wonambi-python/wonambi/blob/1d8e3d7e53df8017c199f703bcab582914676e76/setup_wonambi.py#L166-L196 | def _release(level):
"""TODO: we should make sure that we are on master release"""
version, comment = _new_version(level)
if version is not None:
run(['git',
'commit',
str(VER_PATH.relative_to(BASE_PATH)),
str(CHANGES_PATH.relative_to(BASE_PATH)),
... | [
"def",
"_release",
"(",
"level",
")",
":",
"version",
",",
"comment",
"=",
"_new_version",
"(",
"level",
")",
"if",
"version",
"is",
"not",
"None",
":",
"run",
"(",
"[",
"'git'",
",",
"'commit'",
",",
"str",
"(",
"VER_PATH",
".",
"relative_to",
"(",
... | TODO: we should make sure that we are on master release | [
"TODO",
":",
"we",
"should",
"make",
"sure",
"that",
"we",
"are",
"on",
"master",
"release"
] | python | train | 23.387097 |
uchicago-cs/deepdish | deepdish/util/padding.py | https://github.com/uchicago-cs/deepdish/blob/01af93621fe082a3972fe53ba7375388c02b0085/deepdish/util/padding.py#L5-L50 | def pad(data, padwidth, value=0.0):
"""
Pad an array with a specific value.
Parameters
----------
data : ndarray
Numpy array of any dimension and type.
padwidth : int or tuple
If int, it will pad using this amount at the beginning and end of all
dimensions. If it is a tu... | [
"def",
"pad",
"(",
"data",
",",
"padwidth",
",",
"value",
"=",
"0.0",
")",
":",
"data",
"=",
"np",
".",
"asarray",
"(",
"data",
")",
"shape",
"=",
"data",
".",
"shape",
"if",
"isinstance",
"(",
"padwidth",
",",
"int",
")",
":",
"padwidth",
"=",
"... | Pad an array with a specific value.
Parameters
----------
data : ndarray
Numpy array of any dimension and type.
padwidth : int or tuple
If int, it will pad using this amount at the beginning and end of all
dimensions. If it is a tuple (of same length as `ndim`), then the
... | [
"Pad",
"an",
"array",
"with",
"a",
"specific",
"value",
"."
] | python | train | 30.326087 |
wavycloud/pyboto3 | pyboto3/databasemigrationservice.py | https://github.com/wavycloud/pyboto3/blob/924957ccf994303713a4eed90b775ff2ab95b2e5/pyboto3/databasemigrationservice.py#L1412-L1501 | def describe_events(SourceIdentifier=None, SourceType=None, StartTime=None, EndTime=None, Duration=None, EventCategories=None, Filters=None, MaxRecords=None, Marker=None):
"""
Lists events for a given source identifier and source type. You can also specify a start and end time. For more information on AWS DMS e... | [
"def",
"describe_events",
"(",
"SourceIdentifier",
"=",
"None",
",",
"SourceType",
"=",
"None",
",",
"StartTime",
"=",
"None",
",",
"EndTime",
"=",
"None",
",",
"Duration",
"=",
"None",
",",
"EventCategories",
"=",
"None",
",",
"Filters",
"=",
"None",
",",... | Lists events for a given source identifier and source type. You can also specify a start and end time. For more information on AWS DMS events, see Working with Events and Notifications .
See also: AWS API Documentation
:example: response = client.describe_events(
SourceIdentifier='string',
... | [
"Lists",
"events",
"for",
"a",
"given",
"source",
"identifier",
"and",
"source",
"type",
".",
"You",
"can",
"also",
"specify",
"a",
"start",
"and",
"end",
"time",
".",
"For",
"more",
"information",
"on",
"AWS",
"DMS",
"events",
"see",
"Working",
"with",
... | python | train | 34.111111 |
riptano/ccm | ccmlib/remote.py | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/remote.py#L142-L169 | def __connect(host, port, username, password, private_key):
"""
Establish remote connection
:param host: Hostname or IP address to connect to
:param port: Port number to use for SSH
:param username: Username credentials for SSH access
:param password: Password credential... | [
"def",
"__connect",
"(",
"host",
",",
"port",
",",
"username",
",",
"password",
",",
"private_key",
")",
":",
"# Initialize the SSH connection",
"ssh",
"=",
"paramiko",
".",
"SSHClient",
"(",
")",
"ssh",
".",
"set_missing_host_key_policy",
"(",
"paramiko",
".",
... | Establish remote connection
:param host: Hostname or IP address to connect to
:param port: Port number to use for SSH
:param username: Username credentials for SSH access
:param password: Password credentials for SSH access (or private key passphrase)
:param private_key: Private... | [
"Establish",
"remote",
"connection"
] | python | train | 43.107143 |
winkidney/cmdtree | src/cmdtree/tree.py | https://github.com/winkidney/cmdtree/blob/8558be856f4c3044cf13d2d07a86b69877bb6491/src/cmdtree/tree.py#L80-L108 | def add_parent_commands(self, cmd_path, help=None):
"""
Create parent command object in cmd tree then return
the last parent command object.
:rtype: dict
"""
existed_cmd_end_index = self.index_in_tree(cmd_path)
new_path, existed_path = self._get_paths(
... | [
"def",
"add_parent_commands",
"(",
"self",
",",
"cmd_path",
",",
"help",
"=",
"None",
")",
":",
"existed_cmd_end_index",
"=",
"self",
".",
"index_in_tree",
"(",
"cmd_path",
")",
"new_path",
",",
"existed_path",
"=",
"self",
".",
"_get_paths",
"(",
"cmd_path",
... | Create parent command object in cmd tree then return
the last parent command object.
:rtype: dict | [
"Create",
"parent",
"command",
"object",
"in",
"cmd",
"tree",
"then",
"return",
"the",
"last",
"parent",
"command",
"object",
".",
":",
"rtype",
":",
"dict"
] | python | train | 33.275862 |
portfors-lab/sparkle | sparkle/run/calibration_runner.py | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/run/calibration_runner.py#L20-L25 | def stash_calibration(self, attenuations, freqs, frange, calname):
"""Save it for later"""
self.calibration_vector = attenuations
self.calibration_freqs = freqs
self.calibration_frange = frange
self.calname = calname | [
"def",
"stash_calibration",
"(",
"self",
",",
"attenuations",
",",
"freqs",
",",
"frange",
",",
"calname",
")",
":",
"self",
".",
"calibration_vector",
"=",
"attenuations",
"self",
".",
"calibration_freqs",
"=",
"freqs",
"self",
".",
"calibration_frange",
"=",
... | Save it for later | [
"Save",
"it",
"for",
"later"
] | python | train | 41.833333 |
jaysonsantos/python-binary-memcached | bmemcached/client/mixin.py | https://github.com/jaysonsantos/python-binary-memcached/blob/6a792829349c69204d9c5045e5c34b4231216dd6/bmemcached/client/mixin.py#L87-L102 | def stats(self, key=None):
"""
Return server stats.
:param key: Optional if you want status from a key.
:type key: six.string_types
:return: A dict with server stats
:rtype: dict
"""
# TODO: Stats with key is not working.
returns = {}
for... | [
"def",
"stats",
"(",
"self",
",",
"key",
"=",
"None",
")",
":",
"# TODO: Stats with key is not working.",
"returns",
"=",
"{",
"}",
"for",
"server",
"in",
"self",
".",
"servers",
":",
"returns",
"[",
"server",
".",
"server",
"]",
"=",
"server",
".",
"sta... | Return server stats.
:param key: Optional if you want status from a key.
:type key: six.string_types
:return: A dict with server stats
:rtype: dict | [
"Return",
"server",
"stats",
"."
] | python | train | 25.5 |
mwickert/scikit-dsp-comm | sk_dsp_comm/fec_conv.py | https://github.com/mwickert/scikit-dsp-comm/blob/5c1353412a4d81a8d7da169057564ecf940f8b5b/sk_dsp_comm/fec_conv.py#L248-L469 | def viterbi_decoder(self,x,metric_type='soft',quant_level=3):
"""
A method which performs Viterbi decoding of noisy bit stream,
taking as input soft bit values centered on +/-1 and returning
hard decision 0/1 bits.
Parameters
----------
x: Received noisy... | [
"def",
"viterbi_decoder",
"(",
"self",
",",
"x",
",",
"metric_type",
"=",
"'soft'",
",",
"quant_level",
"=",
"3",
")",
":",
"if",
"metric_type",
"==",
"'hard'",
":",
"# If hard decision must have 0/1 integers for input else float\r",
"if",
"np",
".",
"issubdtype",
... | A method which performs Viterbi decoding of noisy bit stream,
taking as input soft bit values centered on +/-1 and returning
hard decision 0/1 bits.
Parameters
----------
x: Received noisy bit values centered on +/-1 at one sample per bit
metric_type:
... | [
"A",
"method",
"which",
"performs",
"Viterbi",
"decoding",
"of",
"noisy",
"bit",
"stream",
"taking",
"as",
"input",
"soft",
"bit",
"values",
"centered",
"on",
"+",
"/",
"-",
"1",
"and",
"returning",
"hard",
"decision",
"0",
"/",
"1",
"bits",
".",
"Parame... | python | valid | 50.653153 |
ARMmbed/icetea | icetea_lib/tools/asserts.py | https://github.com/ARMmbed/icetea/blob/b2b97ac607429830cf7d62dae2e3903692c7c778/icetea_lib/tools/asserts.py#L77-L90 | def assertDutTraceDoesNotContain(dut, message, bench):
"""
Raise TestStepFail if bench.verify_trace does not find message from dut traces.
:param dut: Dut object.
:param message: Message to look for.
:param: Bench, must contain verify_trace method.
:raises: AttributeError if bench does not cont... | [
"def",
"assertDutTraceDoesNotContain",
"(",
"dut",
",",
"message",
",",
"bench",
")",
":",
"if",
"not",
"hasattr",
"(",
"bench",
",",
"\"verify_trace\"",
")",
":",
"raise",
"AttributeError",
"(",
"\"Bench object does not contain verify_trace method!\"",
")",
"if",
"... | Raise TestStepFail if bench.verify_trace does not find message from dut traces.
:param dut: Dut object.
:param message: Message to look for.
:param: Bench, must contain verify_trace method.
:raises: AttributeError if bench does not contain verify_trace method.
TestStepFail if verify_trace returns T... | [
"Raise",
"TestStepFail",
"if",
"bench",
".",
"verify_trace",
"does",
"not",
"find",
"message",
"from",
"dut",
"traces",
"."
] | python | train | 45.428571 |
jciskey/pygraph | pygraph/helpers/functions.py | https://github.com/jciskey/pygraph/blob/037bb2f32503fecb60d62921f9766d54109f15e2/pygraph/helpers/functions.py#L108-L129 | def merge_graphs(main_graph, addition_graph):
"""Merges an ''addition_graph'' into the ''main_graph''.
Returns a tuple of dictionaries, mapping old node ids and edge ids to new ids.
"""
node_mapping = {}
edge_mapping = {}
for node in addition_graph.get_all_node_objects():
node_id = nod... | [
"def",
"merge_graphs",
"(",
"main_graph",
",",
"addition_graph",
")",
":",
"node_mapping",
"=",
"{",
"}",
"edge_mapping",
"=",
"{",
"}",
"for",
"node",
"in",
"addition_graph",
".",
"get_all_node_objects",
"(",
")",
":",
"node_id",
"=",
"node",
"[",
"'id'",
... | Merges an ''addition_graph'' into the ''main_graph''.
Returns a tuple of dictionaries, mapping old node ids and edge ids to new ids. | [
"Merges",
"an",
"addition_graph",
"into",
"the",
"main_graph",
".",
"Returns",
"a",
"tuple",
"of",
"dictionaries",
"mapping",
"old",
"node",
"ids",
"and",
"edge",
"ids",
"to",
"new",
"ids",
"."
] | python | train | 36.363636 |
f3at/feat | src/feat/agencies/agency.py | https://github.com/f3at/feat/blob/15da93fc9d6ec8154f52a9172824e25821195ef8/src/feat/agencies/agency.py#L873-L884 | def _terminate(self):
'''Shutdown agent gently removing the descriptor and
notifying partners.'''
def generate_body():
d = defer.succeed(None)
d.addBoth(defer.drop_param, self.agent.shutdown_agent)
# Delete the descriptor
d.addBoth(lambda _: self.... | [
"def",
"_terminate",
"(",
"self",
")",
":",
"def",
"generate_body",
"(",
")",
":",
"d",
"=",
"defer",
".",
"succeed",
"(",
"None",
")",
"d",
".",
"addBoth",
"(",
"defer",
".",
"drop_param",
",",
"self",
".",
"agent",
".",
"shutdown_agent",
")",
"# De... | Shutdown agent gently removing the descriptor and
notifying partners. | [
"Shutdown",
"agent",
"gently",
"removing",
"the",
"descriptor",
"and",
"notifying",
"partners",
"."
] | python | train | 35.083333 |
SKA-ScienceDataProcessor/integration-prototype | sip/execution_control/configuration_db/sip_config_db/scheduling/workflow_definitions.py | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/execution_control/configuration_db/sip_config_db/scheduling/workflow_definitions.py#L126-L140 | def _load_templates(workflow: dict, templates_root: str):
"""Load templates keys."""
workflow_template_path = join(templates_root, workflow['id'],
workflow['version'])
for i, stage_config in enumerate(workflow['stages']):
stage_template_path = join(workflow_template... | [
"def",
"_load_templates",
"(",
"workflow",
":",
"dict",
",",
"templates_root",
":",
"str",
")",
":",
"workflow_template_path",
"=",
"join",
"(",
"templates_root",
",",
"workflow",
"[",
"'id'",
"]",
",",
"workflow",
"[",
"'version'",
"]",
")",
"for",
"i",
"... | Load templates keys. | [
"Load",
"templates",
"keys",
"."
] | python | train | 56.266667 |
blockstack/pybitcoin | pybitcoin/transactions/network.py | https://github.com/blockstack/pybitcoin/blob/92c8da63c40f7418594b1ce395990c3f5a4787cc/pybitcoin/transactions/network.py#L113-L136 | def make_op_return_tx(data, private_key,
blockchain_client=BlockchainInfoClient(), fee=OP_RETURN_FEE,
change_address=None, format='bin'):
""" Builds and signs an OP_RETURN transaction.
"""
# get out the private key object, sending address, and inputs
private_key_obj, from_address, inputs... | [
"def",
"make_op_return_tx",
"(",
"data",
",",
"private_key",
",",
"blockchain_client",
"=",
"BlockchainInfoClient",
"(",
")",
",",
"fee",
"=",
"OP_RETURN_FEE",
",",
"change_address",
"=",
"None",
",",
"format",
"=",
"'bin'",
")",
":",
"# get out the private key ob... | Builds and signs an OP_RETURN transaction. | [
"Builds",
"and",
"signs",
"an",
"OP_RETURN",
"transaction",
"."
] | python | train | 37.75 |
BerkeleyAutomation/visualization | visualization/visualizer3d.py | https://github.com/BerkeleyAutomation/visualization/blob/f8d038cc65c78f841ef27f99fb2a638f44fa72b6/visualization/visualizer3d.py#L401-L421 | def table(T_table_world=RigidTransform(from_frame='table', to_frame='world'), dim=0.16, color=(0,0,0)):
"""Plot a table mesh in 3D.
Parameters
----------
T_table_world : autolab_core.RigidTransform
Pose of table relative to world.
dim : float
The side-len... | [
"def",
"table",
"(",
"T_table_world",
"=",
"RigidTransform",
"(",
"from_frame",
"=",
"'table'",
",",
"to_frame",
"=",
"'world'",
")",
",",
"dim",
"=",
"0.16",
",",
"color",
"=",
"(",
"0",
",",
"0",
",",
"0",
")",
")",
":",
"table_vertices",
"=",
"np"... | Plot a table mesh in 3D.
Parameters
----------
T_table_world : autolab_core.RigidTransform
Pose of table relative to world.
dim : float
The side-length for the table.
color : 3-tuple
Color tuple. | [
"Plot",
"a",
"table",
"mesh",
"in",
"3D",
"."
] | python | train | 41.047619 |
mseclab/PyJFuzz | pyjfuzz/core/pjf_mutators.py | https://github.com/mseclab/PyJFuzz/blob/f777067076f62c9ab74ffea6e90fd54402b7a1b4/pyjfuzz/core/pjf_mutators.py#L142-L146 | def get_string_polyglot_attack(self, obj):
"""
Return a polyglot attack containing the original object
"""
return self.polyglot_attacks[random.choice(self.config.techniques)] % obj | [
"def",
"get_string_polyglot_attack",
"(",
"self",
",",
"obj",
")",
":",
"return",
"self",
".",
"polyglot_attacks",
"[",
"random",
".",
"choice",
"(",
"self",
".",
"config",
".",
"techniques",
")",
"]",
"%",
"obj"
] | Return a polyglot attack containing the original object | [
"Return",
"a",
"polyglot",
"attack",
"containing",
"the",
"original",
"object"
] | python | test | 41.6 |
gem/oq-engine | openquake/hazardlib/gsim/zhao_2016.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/zhao_2016.py#L793-L804 | def get_depth_term(self, C, rup):
"""
Returns depth term (dependent on top of rupture depth) as given
in equations 1
Note that there is a ztor cap of 100 km that is introduced in the
Fortran code but not mentioned in the original paper!
"""
if rup.ztor > 100.0:
... | [
"def",
"get_depth_term",
"(",
"self",
",",
"C",
",",
"rup",
")",
":",
"if",
"rup",
".",
"ztor",
">",
"100.0",
":",
"return",
"C",
"[",
"\"bSLH\"",
"]",
"*",
"100.0",
"else",
":",
"return",
"C",
"[",
"\"bSLH\"",
"]",
"*",
"rup",
".",
"ztor"
] | Returns depth term (dependent on top of rupture depth) as given
in equations 1
Note that there is a ztor cap of 100 km that is introduced in the
Fortran code but not mentioned in the original paper! | [
"Returns",
"depth",
"term",
"(",
"dependent",
"on",
"top",
"of",
"rupture",
"depth",
")",
"as",
"given",
"in",
"equations",
"1"
] | python | train | 33.166667 |
yamcs/yamcs-python | yamcs-client/yamcs/core/futures.py | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/yamcs/core/futures.py#L166-L176 | def reply(self, timeout=None):
"""
Returns the initial reply. This is emitted before any subscription
data is emitted. This function raises an exception if the subscription
attempt failed.
"""
self._wait_on_signal(self._response_received)
if self._response_excepti... | [
"def",
"reply",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"self",
".",
"_wait_on_signal",
"(",
"self",
".",
"_response_received",
")",
"if",
"self",
".",
"_response_exception",
"is",
"not",
"None",
":",
"msg",
"=",
"self",
".",
"_response_excepti... | Returns the initial reply. This is emitted before any subscription
data is emitted. This function raises an exception if the subscription
attempt failed. | [
"Returns",
"the",
"initial",
"reply",
".",
"This",
"is",
"emitted",
"before",
"any",
"subscription",
"data",
"is",
"emitted",
".",
"This",
"function",
"raises",
"an",
"exception",
"if",
"the",
"subscription",
"attempt",
"failed",
"."
] | python | train | 40.545455 |
quantopian/alphalens | alphalens/tears.py | https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/tears.py#L450-L490 | def create_full_tear_sheet(factor_data,
long_short=True,
group_neutral=False,
by_group=False):
"""
Creates a full tear sheet for analysis and evaluating single
return predicting (alpha) factor.
Parameters
----------
... | [
"def",
"create_full_tear_sheet",
"(",
"factor_data",
",",
"long_short",
"=",
"True",
",",
"group_neutral",
"=",
"False",
",",
"by_group",
"=",
"False",
")",
":",
"plotting",
".",
"plot_quantile_statistics_table",
"(",
"factor_data",
")",
"create_returns_tear_sheet",
... | Creates a full tear sheet for analysis and evaluating single
return predicting (alpha) factor.
Parameters
----------
factor_data : pd.DataFrame - MultiIndex
A MultiIndex DataFrame indexed by date (level 0) and asset (level 1),
containing the values for a single alpha factor, forward ret... | [
"Creates",
"a",
"full",
"tear",
"sheet",
"for",
"analysis",
"and",
"evaluating",
"single",
"return",
"predicting",
"(",
"alpha",
")",
"factor",
"."
] | python | train | 44.365854 |
dmwm/DBS | Server/Python/src/dbs/dao/Oracle/OutputModuleConfig/GetIDForBlockInsert.py | https://github.com/dmwm/DBS/blob/9619bafce3783b3e77f0415f8f9a258e33dd1e6f/Server/Python/src/dbs/dao/Oracle/OutputModuleConfig/GetIDForBlockInsert.py#L32-L51 | def execute(self, conn, app, release_version, pset_hash, output_label, global_tag, transaction = False):
"""
returns id for a given application
This always requires all four variables to be set, because
you better have them in blockInsert
"""
binds = {}
binds["ap... | [
"def",
"execute",
"(",
"self",
",",
"conn",
",",
"app",
",",
"release_version",
",",
"pset_hash",
",",
"output_label",
",",
"global_tag",
",",
"transaction",
"=",
"False",
")",
":",
"binds",
"=",
"{",
"}",
"binds",
"[",
"\"app_name\"",
"]",
"=",
"app",
... | returns id for a given application
This always requires all four variables to be set, because
you better have them in blockInsert | [
"returns",
"id",
"for",
"a",
"given",
"application"
] | python | train | 34.15 |
dbarsam/python-vsgen | vsgen/solution.py | https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/solution.py#L49-L60 | def write(self):
"""
Writes the ``.sln`` file to disk.
"""
filters = {
'MSGUID': lambda x: ('{%s}' % x).upper(),
'relslnfile': lambda x: os.path.relpath(x, os.path.dirname(self.FileName))
}
context = {
'sln': self
}
retu... | [
"def",
"write",
"(",
"self",
")",
":",
"filters",
"=",
"{",
"'MSGUID'",
":",
"lambda",
"x",
":",
"(",
"'{%s}'",
"%",
"x",
")",
".",
"upper",
"(",
")",
",",
"'relslnfile'",
":",
"lambda",
"x",
":",
"os",
".",
"path",
".",
"relpath",
"(",
"x",
",... | Writes the ``.sln`` file to disk. | [
"Writes",
"the",
".",
"sln",
"file",
"to",
"disk",
"."
] | python | train | 31.75 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.