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 |
|---|---|---|---|---|---|---|---|---|---|
saltstack/salt | salt/modules/dracr.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dracr.py#L1535-L1577 | def update_firmware_nfs_or_cifs(filename, share,
host=None,
admin_username=None,
admin_password=None):
'''
Executes the following for CIFS
(using username and password stored in the pillar data)
.. code-bloc... | [
"def",
"update_firmware_nfs_or_cifs",
"(",
"filename",
",",
"share",
",",
"host",
"=",
"None",
",",
"admin_username",
"=",
"None",
",",
"admin_password",
"=",
"None",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
":",
"return",
... | Executes the following for CIFS
(using username and password stored in the pillar data)
.. code-block:: bash
racadm update -f <updatefile> -u user –p pass -l //IP-Address/share
Or for NFS
(using username and password stored in the pillar data)
.. code-block:: bash
racadm upda... | [
"Executes",
"the",
"following",
"for",
"CIFS",
"(",
"using",
"username",
"and",
"password",
"stored",
"in",
"the",
"pillar",
"data",
")"
] | python | train | 29.116279 |
scanny/python-pptx | pptx/text/text.py | https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/text/text.py#L236-L244 | def _extents(self):
"""
A (cx, cy) 2-tuple representing the effective rendering area for text
within this text frame when margins are taken into account.
"""
return (
self._parent.width - self.margin_left - self.margin_right,
self._parent.height - self.mar... | [
"def",
"_extents",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"_parent",
".",
"width",
"-",
"self",
".",
"margin_left",
"-",
"self",
".",
"margin_right",
",",
"self",
".",
"_parent",
".",
"height",
"-",
"self",
".",
"margin_top",
"-",
"self",
... | A (cx, cy) 2-tuple representing the effective rendering area for text
within this text frame when margins are taken into account. | [
"A",
"(",
"cx",
"cy",
")",
"2",
"-",
"tuple",
"representing",
"the",
"effective",
"rendering",
"area",
"for",
"text",
"within",
"this",
"text",
"frame",
"when",
"margins",
"are",
"taken",
"into",
"account",
"."
] | python | train | 38.888889 |
jut-io/jut-python-tools | jut/api/integrations.py | https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/api/integrations.py#L11-L33 | def get_webhook_url(deployment_name,
space='default',
data_source='webhook',
token_manager=None,
app_url=defaults.APP_URL,
**fields):
"""
return the webhook URL for posting webhook data to
"""
import_ur... | [
"def",
"get_webhook_url",
"(",
"deployment_name",
",",
"space",
"=",
"'default'",
",",
"data_source",
"=",
"'webhook'",
",",
"token_manager",
"=",
"None",
",",
"app_url",
"=",
"defaults",
".",
"APP_URL",
",",
"*",
"*",
"fields",
")",
":",
"import_url",
"=",
... | return the webhook URL for posting webhook data to | [
"return",
"the",
"webhook",
"URL",
"for",
"posting",
"webhook",
"data",
"to"
] | python | train | 40.826087 |
UCL-INGI/INGInious | inginious/frontend/pages/course_admin/aggregation_edit.py | https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/pages/course_admin/aggregation_edit.py#L166-L241 | def POST_AUTH(self, courseid, aggregationid=''): # pylint: disable=arguments-differ
""" Edit a aggregation """
course, __ = self.get_course_and_check_rights(courseid, allow_all_staff=True)
if course.is_lti():
raise web.notfound()
msg=''
error = False
errore... | [
"def",
"POST_AUTH",
"(",
"self",
",",
"courseid",
",",
"aggregationid",
"=",
"''",
")",
":",
"# pylint: disable=arguments-differ",
"course",
",",
"__",
"=",
"self",
".",
"get_course_and_check_rights",
"(",
"courseid",
",",
"allow_all_staff",
"=",
"True",
")",
"i... | Edit a aggregation | [
"Edit",
"a",
"aggregation"
] | python | train | 49.842105 |
googledatalab/pydatalab | datalab/utils/commands/_utils.py | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/utils/commands/_utils.py#L393-L405 | def validate_config_value(value, possible_values):
""" Validate a config value to make sure it is one of the possible values.
Args:
value: the config value to validate.
possible_values: the possible values the value can be
Raises:
Exception if the value is not one of possible values.
"""
if valu... | [
"def",
"validate_config_value",
"(",
"value",
",",
"possible_values",
")",
":",
"if",
"value",
"not",
"in",
"possible_values",
":",
"raise",
"Exception",
"(",
"'Invalid config value \"%s\". Possible values are '",
"'%s'",
"%",
"(",
"value",
",",
"', '",
".",
"join",... | Validate a config value to make sure it is one of the possible values.
Args:
value: the config value to validate.
possible_values: the possible values the value can be
Raises:
Exception if the value is not one of possible values. | [
"Validate",
"a",
"config",
"value",
"to",
"make",
"sure",
"it",
"is",
"one",
"of",
"the",
"possible",
"values",
"."
] | python | train | 36.769231 |
roaet/eh | eh/mdv/tabulate.py | https://github.com/roaet/eh/blob/9370864a9f1d65bb0f822d0aea83f1169c98f3bd/eh/mdv/tabulate.py#L1056-L1124 | def _main():
"""\
Usage: tabulate [options] [FILE ...]
Pretty-print tabular data.
See also https://bitbucket.org/astanin/python-tabulate
FILE a filename of the file with tabular data;
if "-" or missing, read data from stdin.
Options:
-h,... | [
"def",
"_main",
"(",
")",
":",
"import",
"getopt",
"import",
"sys",
"import",
"textwrap",
"usage",
"=",
"textwrap",
".",
"dedent",
"(",
"_main",
".",
"__doc__",
")",
"try",
":",
"opts",
",",
"args",
"=",
"getopt",
".",
"getopt",
"(",
"sys",
".",
"arg... | \
Usage: tabulate [options] [FILE ...]
Pretty-print tabular data.
See also https://bitbucket.org/astanin/python-tabulate
FILE a filename of the file with tabular data;
if "-" or missing, read data from stdin.
Options:
-h, --help ... | [
"\\",
"Usage",
":",
"tabulate",
"[",
"options",
"]",
"[",
"FILE",
"...",
"]"
] | python | train | 36.478261 |
Microsoft/azure-devops-python-api | azure-devops/azure/devops/v5_0/feed/feed_client.py | https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/feed/feed_client.py#L210-L246 | def get_package(self, feed_id, package_id, include_all_versions=None, include_urls=None, is_listed=None, is_release=None, include_deleted=None, include_description=None):
"""GetPackage.
[Preview API] Get details about a specific package.
:param str feed_id: Name or Id of the feed.
:param... | [
"def",
"get_package",
"(",
"self",
",",
"feed_id",
",",
"package_id",
",",
"include_all_versions",
"=",
"None",
",",
"include_urls",
"=",
"None",
",",
"is_listed",
"=",
"None",
",",
"is_release",
"=",
"None",
",",
"include_deleted",
"=",
"None",
",",
"includ... | GetPackage.
[Preview API] Get details about a specific package.
:param str feed_id: Name or Id of the feed.
:param str package_id: The package Id (GUID Id, not the package name).
:param bool include_all_versions: True to return all versions of the package in the response. Default is fal... | [
"GetPackage",
".",
"[",
"Preview",
"API",
"]",
"Get",
"details",
"about",
"a",
"specific",
"package",
".",
":",
"param",
"str",
"feed_id",
":",
"Name",
"or",
"Id",
"of",
"the",
"feed",
".",
":",
"param",
"str",
"package_id",
":",
"The",
"package",
"Id"... | python | train | 81.567568 |
senaite/senaite.core | bika/lims/browser/analysisrequest/analysisrequests.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/browser/analysisrequest/analysisrequests.py#L728-L752 | def get_progress_percentage(self, ar_brain):
"""Returns the percentage of completeness of the Analysis Request
"""
review_state = ar_brain.review_state
if review_state == "published":
return 100
numbers = ar_brain.getAnalysesNum
num_analyses = numbers[1] or ... | [
"def",
"get_progress_percentage",
"(",
"self",
",",
"ar_brain",
")",
":",
"review_state",
"=",
"ar_brain",
".",
"review_state",
"if",
"review_state",
"==",
"\"published\"",
":",
"return",
"100",
"numbers",
"=",
"ar_brain",
".",
"getAnalysesNum",
"num_analyses",
"=... | Returns the percentage of completeness of the Analysis Request | [
"Returns",
"the",
"percentage",
"of",
"completeness",
"of",
"the",
"Analysis",
"Request"
] | python | train | 33.2 |
mbr/tinyrpc | tinyrpc/dispatch/__init__.py | https://github.com/mbr/tinyrpc/blob/59ccf62452b3f37e8411ff0309a3a99857d05e19/tinyrpc/dispatch/__init__.py#L244-L257 | def validate_parameters(self, method, args, kwargs):
"""Verify that `*args` and `**kwargs` are appropriate parameters for `method`.
:param method: A callable.
:param args: List of positional arguments for `method`
:param kwargs: Keyword arguments for `method`
:raises ~tinyrpc.ex... | [
"def",
"validate_parameters",
"(",
"self",
",",
"method",
",",
"args",
",",
"kwargs",
")",
":",
"if",
"hasattr",
"(",
"method",
",",
"'__code__'",
")",
":",
"try",
":",
"inspect",
".",
"getcallargs",
"(",
"method",
",",
"*",
"args",
",",
"*",
"*",
"k... | Verify that `*args` and `**kwargs` are appropriate parameters for `method`.
:param method: A callable.
:param args: List of positional arguments for `method`
:param kwargs: Keyword arguments for `method`
:raises ~tinyrpc.exc.InvalidParamsError:
Raised when the provided argum... | [
"Verify",
"that",
"*",
"args",
"and",
"**",
"kwargs",
"are",
"appropriate",
"parameters",
"for",
"method",
"."
] | python | train | 43.928571 |
waqasbhatti/astrobase | astrobase/varclass/starfeatures.py | https://github.com/waqasbhatti/astrobase/blob/2922a14619d183fb28005fa7d02027ac436f2265/astrobase/varclass/starfeatures.py#L102-L174 | def coord_features(objectinfo):
'''Calculates object coordinates features, including:
- galactic coordinates
- total proper motion from pmra, pmdecl
- reduced J proper motion from propermotion and Jmag
Parameters
----------
objectinfo : dict
This is an objectinfo dict from a ligh... | [
"def",
"coord_features",
"(",
"objectinfo",
")",
":",
"retdict",
"=",
"{",
"'propermotion'",
":",
"np",
".",
"nan",
",",
"'gl'",
":",
"np",
".",
"nan",
",",
"'gb'",
":",
"np",
".",
"nan",
",",
"'rpmj'",
":",
"np",
".",
"nan",
"}",
"if",
"(",
"'ra... | Calculates object coordinates features, including:
- galactic coordinates
- total proper motion from pmra, pmdecl
- reduced J proper motion from propermotion and Jmag
Parameters
----------
objectinfo : dict
This is an objectinfo dict from a light curve file read into an
`lcdic... | [
"Calculates",
"object",
"coordinates",
"features",
"including",
":"
] | python | valid | 29.273973 |
Spinmob/spinmob | _functions.py | https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L1294-L1314 | def round_sigfigs(x, n=2):
"""
Rounds the number to the specified significant figures. x can also be
a list or array of numbers (in these cases, a numpy array is returned).
"""
iterable = is_iterable(x)
if not iterable: x = [x]
# make a copy to be safe
x = _n.array(x)
# loop o... | [
"def",
"round_sigfigs",
"(",
"x",
",",
"n",
"=",
"2",
")",
":",
"iterable",
"=",
"is_iterable",
"(",
"x",
")",
"if",
"not",
"iterable",
":",
"x",
"=",
"[",
"x",
"]",
"# make a copy to be safe",
"x",
"=",
"_n",
".",
"array",
"(",
"x",
")",
"# loop o... | Rounds the number to the specified significant figures. x can also be
a list or array of numbers (in these cases, a numpy array is returned). | [
"Rounds",
"the",
"number",
"to",
"the",
"specified",
"significant",
"figures",
".",
"x",
"can",
"also",
"be",
"a",
"list",
"or",
"array",
"of",
"numbers",
"(",
"in",
"these",
"cases",
"a",
"numpy",
"array",
"is",
"returned",
")",
"."
] | python | train | 28.761905 |
IdentityPython/pysaml2 | src/saml2/entity.py | https://github.com/IdentityPython/pysaml2/blob/d3aa78eeb7d37c12688f783cb4db1c7263a14ad6/src/saml2/entity.py#L759-L792 | def _status_response(self, response_class, issuer, status, sign=False,
sign_alg=None, digest_alg=None,
**kwargs):
""" Create a StatusResponse.
:param response_class: Which subclass of StatusResponse that should be
used
:param issuer:... | [
"def",
"_status_response",
"(",
"self",
",",
"response_class",
",",
"issuer",
",",
"status",
",",
"sign",
"=",
"False",
",",
"sign_alg",
"=",
"None",
",",
"digest_alg",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"mid",
"=",
"sid",
"(",
")",
"for... | Create a StatusResponse.
:param response_class: Which subclass of StatusResponse that should be
used
:param issuer: The issuer of the response message
:param status: The return status of the response operation
:param sign: Whether the response should be signed or not
... | [
"Create",
"a",
"StatusResponse",
"."
] | python | train | 35.058824 |
mixmastamyk/console | console/utils.py | https://github.com/mixmastamyk/console/blob/afe6c95d5a7b83d85376f450454e3769e4a5c3d0/console/utils.py#L122-L144 | def strip_ansi(text, c1=False, osc=False):
''' Strip ANSI escape sequences from a portion of text.
https://stackoverflow.com/a/38662876/450917
Arguments:
line: str
osc: bool - include OSC commands in the strippage.
c1: bool - include C1 commands in the strippa... | [
"def",
"strip_ansi",
"(",
"text",
",",
"c1",
"=",
"False",
",",
"osc",
"=",
"False",
")",
":",
"text",
"=",
"ansi_csi0_finder",
".",
"sub",
"(",
"''",
",",
"text",
")",
"if",
"osc",
":",
"text",
"=",
"ansi_osc0_finder",
".",
"sub",
"(",
"''",
",",
... | Strip ANSI escape sequences from a portion of text.
https://stackoverflow.com/a/38662876/450917
Arguments:
line: str
osc: bool - include OSC commands in the strippage.
c1: bool - include C1 commands in the strippage.
Notes:
Enabling c1 and osc... | [
"Strip",
"ANSI",
"escape",
"sequences",
"from",
"a",
"portion",
"of",
"text",
".",
"https",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"a",
"/",
"38662876",
"/",
"450917"
] | python | train | 36.608696 |
confluentinc/confluent-kafka-python | examples/avro-cli.py | https://github.com/confluentinc/confluent-kafka-python/blob/5a8aeb741609e61eaccafff2a67fa494dd549e8b/examples/avro-cli.py#L116-L151 | def consume(topic, conf):
"""
Consume User records
"""
from confluent_kafka.avro import AvroConsumer
from confluent_kafka.avro.serializer import SerializerError
print("Consuming user records from topic {} with group {}. ^c to exit.".format(topic, conf["group.id"]))
c = AvroConsumer(con... | [
"def",
"consume",
"(",
"topic",
",",
"conf",
")",
":",
"from",
"confluent_kafka",
".",
"avro",
"import",
"AvroConsumer",
"from",
"confluent_kafka",
".",
"avro",
".",
"serializer",
"import",
"SerializerError",
"print",
"(",
"\"Consuming user records from topic {} with ... | Consume User records | [
"Consume",
"User",
"records"
] | python | train | 31.861111 |
RobotStudio/bors | bors/api/adapter/socketcluster.py | https://github.com/RobotStudio/bors/blob/38bf338fc6905d90819faa56bd832140116720f0/bors/api/adapter/socketcluster.py#L17-L42 | def run(self):
"""
Called by internal API subsystem to initialize websockets connections
in the API interface
"""
self.api = self.context.get("cls")(self.context)
self.context["inst"].append(self) # Adapters used by strategies
def on_ws_connect(*args, **kwargs):... | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"api",
"=",
"self",
".",
"context",
".",
"get",
"(",
"\"cls\"",
")",
"(",
"self",
".",
"context",
")",
"self",
".",
"context",
"[",
"\"inst\"",
"]",
".",
"append",
"(",
"self",
")",
"# Adapters used... | Called by internal API subsystem to initialize websockets connections
in the API interface | [
"Called",
"by",
"internal",
"API",
"subsystem",
"to",
"initialize",
"websockets",
"connections",
"in",
"the",
"API",
"interface"
] | python | train | 38.038462 |
rdireen/spherepy | spherepy/spherepy.py | https://github.com/rdireen/spherepy/blob/241521401d4d76851d4a1a564a365cfab8e98496/spherepy/spherepy.py#L330-L339 | def _reshape_n_vecs(self):
"""return list of arrays, each array represents a different m mode"""
lst = []
sl = slice(None, None, None)
lst.append(self.__getitem__((sl, 0)))
for m in xrange(1, self.mmax + 1):
lst.append(self.__getitem__((sl, -m)))
... | [
"def",
"_reshape_n_vecs",
"(",
"self",
")",
":",
"lst",
"=",
"[",
"]",
"sl",
"=",
"slice",
"(",
"None",
",",
"None",
",",
"None",
")",
"lst",
".",
"append",
"(",
"self",
".",
"__getitem__",
"(",
"(",
"sl",
",",
"0",
")",
")",
")",
"for",
"m",
... | return list of arrays, each array represents a different m mode | [
"return",
"list",
"of",
"arrays",
"each",
"array",
"represents",
"a",
"different",
"m",
"mode"
] | python | train | 36.8 |
theonion/django-bulbs | bulbs/contributions/email.py | https://github.com/theonion/django-bulbs/blob/0c0e6e3127a7dc487b96677fab95cacd2b3806da/bulbs/contributions/email.py#L167-L174 | def get_contributors(self):
"""Return a list of contributors with contributions between the start/end dates."""
return User.objects.filter(
freelanceprofile__is_freelance=True
).filter(
contributions__content__published__gte=self.start,
contributions__content_... | [
"def",
"get_contributors",
"(",
"self",
")",
":",
"return",
"User",
".",
"objects",
".",
"filter",
"(",
"freelanceprofile__is_freelance",
"=",
"True",
")",
".",
"filter",
"(",
"contributions__content__published__gte",
"=",
"self",
".",
"start",
",",
"contributions... | Return a list of contributors with contributions between the start/end dates. | [
"Return",
"a",
"list",
"of",
"contributors",
"with",
"contributions",
"between",
"the",
"start",
"/",
"end",
"dates",
"."
] | python | train | 44.625 |
facetoe/zenpy | zenpy/lib/api.py | https://github.com/facetoe/zenpy/blob/34c54c7e408b9ed01604ddf8b3422204c8bf31ea/zenpy/lib/api.py#L1018-L1026 | def apply(self, macro):
"""
Show what a macro would do
Zendesk API `Reference <https://developer.zendesk.com/rest_api/docs/core/macros#show-changes-to-ticket>`__.
:param macro: Macro object or id.
"""
return self._query_zendesk(self.endpoint.apply, 'result', id=macro) | [
"def",
"apply",
"(",
"self",
",",
"macro",
")",
":",
"return",
"self",
".",
"_query_zendesk",
"(",
"self",
".",
"endpoint",
".",
"apply",
",",
"'result'",
",",
"id",
"=",
"macro",
")"
] | Show what a macro would do
Zendesk API `Reference <https://developer.zendesk.com/rest_api/docs/core/macros#show-changes-to-ticket>`__.
:param macro: Macro object or id. | [
"Show",
"what",
"a",
"macro",
"would",
"do",
"Zendesk",
"API",
"Reference",
"<https",
":",
"//",
"developer",
".",
"zendesk",
".",
"com",
"/",
"rest_api",
"/",
"docs",
"/",
"core",
"/",
"macros#show",
"-",
"changes",
"-",
"to",
"-",
"ticket",
">",
"__"... | python | train | 34.444444 |
wavefrontHQ/python-client | wavefront_api_client/api/derived_metric_api.py | https://github.com/wavefrontHQ/python-client/blob/b0f1046a8f68c2c7d69e395f7167241f224c738a/wavefront_api_client/api/derived_metric_api.py#L36-L57 | def add_tag_to_derived_metric(self, id, tag_value, **kwargs): # noqa: E501
"""Add a tag to a specific Derived Metric # noqa: E501
# noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread... | [
"def",
"add_tag_to_derived_metric",
"(",
"self",
",",
"id",
",",
"tag_value",
",",
"*",
"*",
"kwargs",
")",
":",
"# noqa: E501",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'async_req'",
")",
":",
"return",
... | Add a tag to a specific Derived Metric # noqa: E501
# noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.add_tag_to_derived_metric(id, tag_value, async_req=True)
>>> result = th... | [
"Add",
"a",
"tag",
"to",
"a",
"specific",
"Derived",
"Metric",
"#",
"noqa",
":",
"E501"
] | python | train | 44.681818 |
gwastro/pycbc-glue | pycbc_glue/ligolw/lsctables.py | https://github.com/gwastro/pycbc-glue/blob/a3e906bae59fbfd707c3ff82e5d008d939ec5e24/pycbc_glue/ligolw/lsctables.py#L90-L124 | def New(Type, columns = None, **kwargs):
"""
Construct a pre-defined LSC table. The optional columns argument
is a sequence of the names of the columns the table should be
constructed with. If columns = None, then the table is constructed
with all valid columns (use columns = [] to create a table with no
column... | [
"def",
"New",
"(",
"Type",
",",
"columns",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"new",
"=",
"Type",
"(",
"sax",
".",
"xmlreader",
".",
"AttributesImpl",
"(",
"{",
"u\"Name\"",
":",
"Type",
".",
"tableName",
"}",
")",
",",
"*",
"*",
"kw... | Construct a pre-defined LSC table. The optional columns argument
is a sequence of the names of the columns the table should be
constructed with. If columns = None, then the table is constructed
with all valid columns (use columns = [] to create a table with no
columns).
Example:
>>> import sys
>>> tbl = New(... | [
"Construct",
"a",
"pre",
"-",
"defined",
"LSC",
"table",
".",
"The",
"optional",
"columns",
"argument",
"is",
"a",
"sequence",
"of",
"the",
"names",
"of",
"the",
"columns",
"the",
"table",
"should",
"be",
"constructed",
"with",
".",
"If",
"columns",
"=",
... | python | train | 45.942857 |
ic-labs/django-icekit | icekit_events/migrations/0002_recurrence_rules.py | https://github.com/ic-labs/django-icekit/blob/c507ea5b1864303732c53ad7c5800571fca5fa94/icekit_events/migrations/0002_recurrence_rules.py#L30-L36 | def backwards(apps, schema_editor):
"""
Delete initial recurrence rules.
"""
RecurrenceRule = apps.get_model('icekit_events', 'RecurrenceRule')
descriptions = [d for d, rr in RULES]
RecurrenceRule.objects.filter(description__in=descriptions).delete() | [
"def",
"backwards",
"(",
"apps",
",",
"schema_editor",
")",
":",
"RecurrenceRule",
"=",
"apps",
".",
"get_model",
"(",
"'icekit_events'",
",",
"'RecurrenceRule'",
")",
"descriptions",
"=",
"[",
"d",
"for",
"d",
",",
"rr",
"in",
"RULES",
"]",
"RecurrenceRule"... | Delete initial recurrence rules. | [
"Delete",
"initial",
"recurrence",
"rules",
"."
] | python | train | 38.285714 |
glyph/secretly | secretly/_impl.py | https://github.com/glyph/secretly/blob/2f172750f37f91939008fa169e8e81ea41e06902/secretly/_impl.py#L59-L67 | def issueCommand(self, command, *args):
"""
Issue the given Assuan command and return a Deferred that will fire
with the response.
"""
result = Deferred()
self._dq.append(result)
self.sendLine(b" ".join([command] + list(args)))
return result | [
"def",
"issueCommand",
"(",
"self",
",",
"command",
",",
"*",
"args",
")",
":",
"result",
"=",
"Deferred",
"(",
")",
"self",
".",
"_dq",
".",
"append",
"(",
"result",
")",
"self",
".",
"sendLine",
"(",
"b\" \"",
".",
"join",
"(",
"[",
"command",
"]... | Issue the given Assuan command and return a Deferred that will fire
with the response. | [
"Issue",
"the",
"given",
"Assuan",
"command",
"and",
"return",
"a",
"Deferred",
"that",
"will",
"fire",
"with",
"the",
"response",
"."
] | python | train | 33 |
juju/charm-helpers | charmhelpers/core/hookenv.py | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/hookenv.py#L161-L172 | def execution_environment():
"""A convenient bundling of the current execution context"""
context = {}
context['conf'] = config()
if relation_id():
context['reltype'] = relation_type()
context['relid'] = relation_id()
context['rel'] = relation_get()
context['unit'] = local_un... | [
"def",
"execution_environment",
"(",
")",
":",
"context",
"=",
"{",
"}",
"context",
"[",
"'conf'",
"]",
"=",
"config",
"(",
")",
"if",
"relation_id",
"(",
")",
":",
"context",
"[",
"'reltype'",
"]",
"=",
"relation_type",
"(",
")",
"context",
"[",
"'rel... | A convenient bundling of the current execution context | [
"A",
"convenient",
"bundling",
"of",
"the",
"current",
"execution",
"context"
] | python | train | 33.166667 |
christophertbrown/bioscripts | ctbBio/genome_variation.py | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/genome_variation.py#L273-L309 | def count_mutations(codon, AA, alleles, counts, nucs, trans_table):
"""
count types of mutations in codon
counts = {'obs syn':#, 'pos syn':#, 'obs non-syn':#, 'pos non-syn':#}
"""
# find alternative codons based on SNPs
obs_codons = [] # codons observed from SNPs
for pos, pos_mutations in en... | [
"def",
"count_mutations",
"(",
"codon",
",",
"AA",
",",
"alleles",
",",
"counts",
",",
"nucs",
",",
"trans_table",
")",
":",
"# find alternative codons based on SNPs",
"obs_codons",
"=",
"[",
"]",
"# codons observed from SNPs",
"for",
"pos",
",",
"pos_mutations",
... | count types of mutations in codon
counts = {'obs syn':#, 'pos syn':#, 'obs non-syn':#, 'pos non-syn':#} | [
"count",
"types",
"of",
"mutations",
"in",
"codon",
"counts",
"=",
"{",
"obs",
"syn",
":",
"#",
"pos",
"syn",
":",
"#",
"obs",
"non",
"-",
"syn",
":",
"#",
"pos",
"non",
"-",
"syn",
":",
"#",
"}"
] | python | train | 41.324324 |
zomux/deepy | deepy/networks/auto_encoder.py | https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/networks/auto_encoder.py#L48-L53 | def stack_decoders(self, *layers):
"""
Stack decoding layers.
"""
self.stack(*layers)
self.decoding_layers.extend(layers) | [
"def",
"stack_decoders",
"(",
"self",
",",
"*",
"layers",
")",
":",
"self",
".",
"stack",
"(",
"*",
"layers",
")",
"self",
".",
"decoding_layers",
".",
"extend",
"(",
"layers",
")"
] | Stack decoding layers. | [
"Stack",
"decoding",
"layers",
"."
] | python | test | 26 |
dmlc/gluon-nlp | src/gluonnlp/model/elmo.py | https://github.com/dmlc/gluon-nlp/blob/4b83eb6bcc8881e5f1081a3675adaa19fac5c0ba/src/gluonnlp/model/elmo.py#L243-L284 | def hybrid_forward(self, F, inputs, states=None, mask=None):
# pylint: disable=arguments-differ
"""
Parameters
----------
inputs : NDArray
Shape (batch_size, sequence_length, max_character_per_token)
of character ids representing the current batch.
... | [
"def",
"hybrid_forward",
"(",
"self",
",",
"F",
",",
"inputs",
",",
"states",
"=",
"None",
",",
"mask",
"=",
"None",
")",
":",
"# pylint: disable=arguments-differ",
"type_representation",
"=",
"self",
".",
"_elmo_char_encoder",
"(",
"inputs",
")",
"type_represen... | Parameters
----------
inputs : NDArray
Shape (batch_size, sequence_length, max_character_per_token)
of character ids representing the current batch.
states : (list of list of NDArray, list of list of NDArray)
The states. First tuple element is the forward laye... | [
"Parameters",
"----------",
"inputs",
":",
"NDArray",
"Shape",
"(",
"batch_size",
"sequence_length",
"max_character_per_token",
")",
"of",
"character",
"ids",
"representing",
"the",
"current",
"batch",
".",
"states",
":",
"(",
"list",
"of",
"list",
"of",
"NDArray"... | python | train | 51.52381 |
thombashi/pytablereader | pytablereader/json/formatter.py | https://github.com/thombashi/pytablereader/blob/bc3c057a2cc775bcce690e0e9019c2907b638101/pytablereader/json/formatter.py#L38-L46 | def _validate_source_data(self):
"""
:raises ValidationError:
"""
try:
jsonschema.validate(self._buffer, self._schema)
except jsonschema.ValidationError as e:
raise ValidationError(e) | [
"def",
"_validate_source_data",
"(",
"self",
")",
":",
"try",
":",
"jsonschema",
".",
"validate",
"(",
"self",
".",
"_buffer",
",",
"self",
".",
"_schema",
")",
"except",
"jsonschema",
".",
"ValidationError",
"as",
"e",
":",
"raise",
"ValidationError",
"(",
... | :raises ValidationError: | [
":",
"raises",
"ValidationError",
":"
] | python | train | 26.666667 |
cloudera/cm_api | python/src/cm_api/endpoints/services.py | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/services.py#L675-L686 | def update_role_config_group(self, name, apigroup):
"""
Update a role config group.
@param name: Role config group name.
@param apigroup: The updated role config group.
@return: The updated ApiRoleConfigGroup object.
@since: API v3
"""
return role_config_groups.update_role_config_group(... | [
"def",
"update_role_config_group",
"(",
"self",
",",
"name",
",",
"apigroup",
")",
":",
"return",
"role_config_groups",
".",
"update_role_config_group",
"(",
"self",
".",
"_get_resource_root",
"(",
")",
",",
"self",
".",
"name",
",",
"name",
",",
"apigroup",
"... | Update a role config group.
@param name: Role config group name.
@param apigroup: The updated role config group.
@return: The updated ApiRoleConfigGroup object.
@since: API v3 | [
"Update",
"a",
"role",
"config",
"group",
"."
] | python | train | 33.75 |
openstack/horizon | openstack_dashboard/dashboards/project/instances/console.py | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/dashboards/project/instances/console.py#L34-L72 | def get_console(request, console_type, instance):
"""Get a tuple of console url and console type."""
if console_type == 'AUTO':
check_consoles = CONSOLES
else:
try:
check_consoles = {console_type: CONSOLES[console_type]}
except KeyError:
msg = _('Console type ... | [
"def",
"get_console",
"(",
"request",
",",
"console_type",
",",
"instance",
")",
":",
"if",
"console_type",
"==",
"'AUTO'",
":",
"check_consoles",
"=",
"CONSOLES",
"else",
":",
"try",
":",
"check_consoles",
"=",
"{",
"console_type",
":",
"CONSOLES",
"[",
"co... | Get a tuple of console url and console type. | [
"Get",
"a",
"tuple",
"of",
"console",
"url",
"and",
"console",
"type",
"."
] | python | train | 35.025641 |
fastai/fastai | fastai/data_block.py | https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/data_block.py#L154-L163 | def filter_by_folder(self, include=None, exclude=None):
"Only keep filenames in `include` folder or reject the ones in `exclude`."
include,exclude = listify(include),listify(exclude)
def _inner(o):
if isinstance(o, Path): n = o.relative_to(self.path).parts[0]
else: n = o.... | [
"def",
"filter_by_folder",
"(",
"self",
",",
"include",
"=",
"None",
",",
"exclude",
"=",
"None",
")",
":",
"include",
",",
"exclude",
"=",
"listify",
"(",
"include",
")",
",",
"listify",
"(",
"exclude",
")",
"def",
"_inner",
"(",
"o",
")",
":",
"if"... | Only keep filenames in `include` folder or reject the ones in `exclude`. | [
"Only",
"keep",
"filenames",
"in",
"include",
"folder",
"or",
"reject",
"the",
"ones",
"in",
"exclude",
"."
] | python | train | 55.2 |
jim-easterbrook/pywws | src/pywws/device_cython_hidapi.py | https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/device_cython_hidapi.py#L99-L114 | def write_data(self, buf):
"""Send data to the device.
:param buf: the data to send.
:type buf: list(int)
:return: success status.
:rtype: bool
"""
if self.hid.write(buf) != len(buf):
raise IOError(
'pywws.device_cython_hidapi.USBD... | [
"def",
"write_data",
"(",
"self",
",",
"buf",
")",
":",
"if",
"self",
".",
"hid",
".",
"write",
"(",
"buf",
")",
"!=",
"len",
"(",
"buf",
")",
":",
"raise",
"IOError",
"(",
"'pywws.device_cython_hidapi.USBDevice.write_data failed'",
")",
"return",
"True"
] | Send data to the device.
:param buf: the data to send.
:type buf: list(int)
:return: success status.
:rtype: bool | [
"Send",
"data",
"to",
"the",
"device",
"."
] | python | train | 21.875 |
six8/corona-cipr | fabfile.py | https://github.com/six8/corona-cipr/blob/a2f45761080c874afa39bf95fd5c4467c8eae272/fabfile.py#L5-L22 | def release():
"""
Release current version to pypi
"""
with settings(warn_only=True):
r = local(clom.git['diff-files']('--quiet', '--ignore-submodules', '--'))
if r.return_code != 0:
abort('There are uncommitted changes, commit or stash them before releasing')
version = open('... | [
"def",
"release",
"(",
")",
":",
"with",
"settings",
"(",
"warn_only",
"=",
"True",
")",
":",
"r",
"=",
"local",
"(",
"clom",
".",
"git",
"[",
"'diff-files'",
"]",
"(",
"'--quiet'",
",",
"'--ignore-submodules'",
",",
"'--'",
")",
")",
"if",
"r",
".",... | Release current version to pypi | [
"Release",
"current",
"version",
"to",
"pypi"
] | python | train | 34.166667 |
mozilla/treeherder | treeherder/model/models.py | https://github.com/mozilla/treeherder/blob/cc47bdec872e5c668d0f01df89517390a164cda3/treeherder/model/models.py#L1170-L1183 | def replace_with(self, other):
"""
Replace this instance with the given other.
Deletes stale Match objects and updates related TextLogErrorMetadatas'
best_classifications to point to the given other.
"""
match_ids_to_delete = list(self.update_matches(other))
Text... | [
"def",
"replace_with",
"(",
"self",
",",
"other",
")",
":",
"match_ids_to_delete",
"=",
"list",
"(",
"self",
".",
"update_matches",
"(",
"other",
")",
")",
"TextLogErrorMatch",
".",
"objects",
".",
"filter",
"(",
"id__in",
"=",
"match_ids_to_delete",
")",
".... | Replace this instance with the given other.
Deletes stale Match objects and updates related TextLogErrorMetadatas'
best_classifications to point to the given other. | [
"Replace",
"this",
"instance",
"with",
"the",
"given",
"other",
"."
] | python | train | 35.5 |
materialsvirtuallab/monty | monty/fnmatch.py | https://github.com/materialsvirtuallab/monty/blob/d99d6f3c68372d83489d28ff515566c93cd569e2/monty/fnmatch.py#L41-L53 | def filter(self, names):
"""
Returns a list with the names matching the pattern.
"""
names = list_strings(names)
fnames = []
for f in names:
for pat in self.pats:
if fnmatch.fnmatch(f, pat):
fnames.append(f)
return... | [
"def",
"filter",
"(",
"self",
",",
"names",
")",
":",
"names",
"=",
"list_strings",
"(",
"names",
")",
"fnames",
"=",
"[",
"]",
"for",
"f",
"in",
"names",
":",
"for",
"pat",
"in",
"self",
".",
"pats",
":",
"if",
"fnmatch",
".",
"fnmatch",
"(",
"f... | Returns a list with the names matching the pattern. | [
"Returns",
"a",
"list",
"with",
"the",
"names",
"matching",
"the",
"pattern",
"."
] | python | train | 24.230769 |
gbowerman/azurerm | azurerm/networkrp.py | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/networkrp.py#L421-L439 | def get_public_ip(access_token, subscription_id, resource_group, ip_name):
'''Get details about the named public ip address.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group name.
... | [
"def",
"get_public_ip",
"(",
"access_token",
",",
"subscription_id",
",",
"resource_group",
",",
"ip_name",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscription_id",
",",
"'/resourceGro... | Get details about the named public ip address.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group name.
public_ip_name (str): Name of the public ip address resource.
Returns:
... | [
"Get",
"details",
"about",
"the",
"named",
"public",
"ip",
"address",
"."
] | python | train | 42.736842 |
igorcoding/asynctnt-queue | asynctnt_queue/queue.py | https://github.com/igorcoding/asynctnt-queue/blob/75719b2dd27e8314ae924aea6a7a85be8f48ecc5/asynctnt_queue/queue.py#L74-L89 | async def statistics(self, tube_name=None):
"""
Returns queue statistics (coroutine)
:param tube_name:
If specified, statistics by a specific tube is returned,
else statistics about all tubes is returned
"""
args = None
if tube_nam... | [
"async",
"def",
"statistics",
"(",
"self",
",",
"tube_name",
"=",
"None",
")",
":",
"args",
"=",
"None",
"if",
"tube_name",
"is",
"not",
"None",
":",
"args",
"=",
"(",
"tube_name",
",",
")",
"res",
"=",
"await",
"self",
".",
"_conn",
".",
"call",
"... | Returns queue statistics (coroutine)
:param tube_name:
If specified, statistics by a specific tube is returned,
else statistics about all tubes is returned | [
"Returns",
"queue",
"statistics",
"(",
"coroutine",
")"
] | python | train | 34.6875 |
ceph/ceph-deploy | ceph_deploy/util/net.py | https://github.com/ceph/ceph-deploy/blob/86943fcc454cd4c99a86e3493e9e93a59c661fef/ceph_deploy/util/net.py#L52-L58 | def ip_in_subnet(ip, subnet):
"""Does IP exists in a given subnet utility. Returns a boolean"""
ipaddr = int(''.join(['%02x' % int(x) for x in ip.split('.')]), 16)
netstr, bits = subnet.split('/')
netaddr = int(''.join(['%02x' % int(x) for x in netstr.split('.')]), 16)
mask = (0xffffffff << (32 - in... | [
"def",
"ip_in_subnet",
"(",
"ip",
",",
"subnet",
")",
":",
"ipaddr",
"=",
"int",
"(",
"''",
".",
"join",
"(",
"[",
"'%02x'",
"%",
"int",
"(",
"x",
")",
"for",
"x",
"in",
"ip",
".",
"split",
"(",
"'.'",
")",
"]",
")",
",",
"16",
")",
"netstr",... | Does IP exists in a given subnet utility. Returns a boolean | [
"Does",
"IP",
"exists",
"in",
"a",
"given",
"subnet",
"utility",
".",
"Returns",
"a",
"boolean"
] | python | train | 54.714286 |
RPi-Distro/python-gpiozero | gpiozero/output_devices.py | https://github.com/RPi-Distro/python-gpiozero/blob/7b67374fd0c8c4fde5586d9bad9531f076db9c0c/gpiozero/output_devices.py#L1399-L1413 | def forward(self, speed=1):
"""
Drive the motor forwards.
:param float speed:
The speed at which the motor should turn. Can be any value between
0 (stopped) and the default 1 (maximum speed).
"""
if isinstance(self.enable_device, DigitalOutputDevice):
... | [
"def",
"forward",
"(",
"self",
",",
"speed",
"=",
"1",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"enable_device",
",",
"DigitalOutputDevice",
")",
":",
"if",
"speed",
"not",
"in",
"(",
"0",
",",
"1",
")",
":",
"raise",
"ValueError",
"(",
"'forw... | Drive the motor forwards.
:param float speed:
The speed at which the motor should turn. Can be any value between
0 (stopped) and the default 1 (maximum speed). | [
"Drive",
"the",
"motor",
"forwards",
"."
] | python | train | 36.666667 |
phodge/homely | homely/_vcs/__init__.py | https://github.com/phodge/homely/blob/98ddcf3e4f29b0749645817b4866baaea8376085/homely/_vcs/__init__.py#L77-L85 | def clonetopath(self, dest):
"""
Clone the repo at <self.pushablepath> into <dest>
Note that if self.pushablepath is None, then self.path will be used
instead.
"""
raise Exception(
"%s.%s needs to implement @classmethod .clonetopath(dest)" % (
... | [
"def",
"clonetopath",
"(",
"self",
",",
"dest",
")",
":",
"raise",
"Exception",
"(",
"\"%s.%s needs to implement @classmethod .clonetopath(dest)\"",
"%",
"(",
"self",
".",
"__class__",
".",
"__module__",
",",
"self",
".",
"__class__",
".",
"__name__",
")",
")"
] | Clone the repo at <self.pushablepath> into <dest>
Note that if self.pushablepath is None, then self.path will be used
instead. | [
"Clone",
"the",
"repo",
"at",
"<self",
".",
"pushablepath",
">",
"into",
"<dest",
">",
"Note",
"that",
"if",
"self",
".",
"pushablepath",
"is",
"None",
"then",
"self",
".",
"path",
"will",
"be",
"used",
"instead",
"."
] | python | train | 40.444444 |
tcalmant/ipopo | pelix/internals/registry.py | https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/internals/registry.py#L838-L902 | def fire_service_event(self, event):
"""
Notifies service events listeners of a new event in the calling thread.
:param event: The service event
"""
# Get the service properties
properties = event.get_service_reference().get_properties()
svc_specs = properties[OB... | [
"def",
"fire_service_event",
"(",
"self",
",",
"event",
")",
":",
"# Get the service properties",
"properties",
"=",
"event",
".",
"get_service_reference",
"(",
")",
".",
"get_properties",
"(",
")",
"svc_specs",
"=",
"properties",
"[",
"OBJECTCLASS",
"]",
"previou... | Notifies service events listeners of a new event in the calling thread.
:param event: The service event | [
"Notifies",
"service",
"events",
"listeners",
"of",
"a",
"new",
"event",
"in",
"the",
"calling",
"thread",
"."
] | python | train | 35.507692 |
gmr/rejected | rejected/connection.py | https://github.com/gmr/rejected/blob/610a3e1401122ecb98d891b6795cca0255e5b044/rejected/connection.py#L182-L199 | def on_channel_open(self, channel):
"""This method is invoked by pika when the channel has been opened. It
will change the state to CONNECTED, add the callbacks and setup the
channel to start consuming.
:param pika.channel.Channel channel: The channel object
"""
self.lo... | [
"def",
"on_channel_open",
"(",
"self",
",",
"channel",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'Channel opened'",
")",
"self",
".",
"set_state",
"(",
"self",
".",
"STATE_CONNECTED",
")",
"self",
".",
"channel",
"=",
"channel",
"self",
".",
"... | This method is invoked by pika when the channel has been opened. It
will change the state to CONNECTED, add the callbacks and setup the
channel to start consuming.
:param pika.channel.Channel channel: The channel object | [
"This",
"method",
"is",
"invoked",
"by",
"pika",
"when",
"the",
"channel",
"has",
"been",
"opened",
".",
"It",
"will",
"change",
"the",
"state",
"to",
"CONNECTED",
"add",
"the",
"callbacks",
"and",
"setup",
"the",
"channel",
"to",
"start",
"consuming",
"."... | python | train | 44 |
has2k1/plotnine | plotnine/guides/guide_colorbar.py | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/guides/guide_colorbar.py#L242-L292 | def add_interpolated_colorbar(da, colors, direction):
"""
Add 'rastered' colorbar to DrawingArea
"""
# Special case that arises due to not so useful
# aesthetic mapping.
if len(colors) == 1:
colors = [colors[0], colors[0]]
# Number of horizontal egdes(breaks) in the grid
# No ne... | [
"def",
"add_interpolated_colorbar",
"(",
"da",
",",
"colors",
",",
"direction",
")",
":",
"# Special case that arises due to not so useful",
"# aesthetic mapping.",
"if",
"len",
"(",
"colors",
")",
"==",
"1",
":",
"colors",
"=",
"[",
"colors",
"[",
"0",
"]",
","... | Add 'rastered' colorbar to DrawingArea | [
"Add",
"rastered",
"colorbar",
"to",
"DrawingArea"
] | python | train | 32.352941 |
gem/oq-engine | openquake/hazardlib/gsim/munson_thurber_1997.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/munson_thurber_1997.py#L67-L99 | def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
"""
See :meth:`superclass method
<.base.GroundShakingIntensityModel.get_mean_and_stddevs>`
for spec of input and result values.
"""
# Distance term
R = np.sqrt(dists.rjb ** 2 + 11.29 ** 2)
... | [
"def",
"get_mean_and_stddevs",
"(",
"self",
",",
"sites",
",",
"rup",
",",
"dists",
",",
"imt",
",",
"stddev_types",
")",
":",
"# Distance term",
"R",
"=",
"np",
".",
"sqrt",
"(",
"dists",
".",
"rjb",
"**",
"2",
"+",
"11.29",
"**",
"2",
")",
"# Magni... | See :meth:`superclass method
<.base.GroundShakingIntensityModel.get_mean_and_stddevs>`
for spec of input and result values. | [
"See",
":",
"meth",
":",
"superclass",
"method",
"<",
".",
"base",
".",
"GroundShakingIntensityModel",
".",
"get_mean_and_stddevs",
">",
"for",
"spec",
"of",
"input",
"and",
"result",
"values",
"."
] | python | train | 32.030303 |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/manager.py | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/manager.py#L457-L465 | def get_oauth_token_secret_name(self, provider):
"""
Returns the token_secret name for the oauth provider
if none is configured defaults to oauth_secret
this is configured using OAUTH_PROVIDERS and token_secret
"""
for _provider in self.oauth_providers:
... | [
"def",
"get_oauth_token_secret_name",
"(",
"self",
",",
"provider",
")",
":",
"for",
"_provider",
"in",
"self",
".",
"oauth_providers",
":",
"if",
"_provider",
"[",
"\"name\"",
"]",
"==",
"provider",
":",
"return",
"_provider",
".",
"get",
"(",
"\"token_secret... | Returns the token_secret name for the oauth provider
if none is configured defaults to oauth_secret
this is configured using OAUTH_PROVIDERS and token_secret | [
"Returns",
"the",
"token_secret",
"name",
"for",
"the",
"oauth",
"provider",
"if",
"none",
"is",
"configured",
"defaults",
"to",
"oauth_secret",
"this",
"is",
"configured",
"using",
"OAUTH_PROVIDERS",
"and",
"token_secret"
] | python | train | 47.333333 |
cltk/cltk | cltk/phonology/old_norse/transcription.py | https://github.com/cltk/cltk/blob/ed9c025b7ec43c949481173251b70e05e4dffd27/cltk/phonology/old_norse/transcription.py#L66-L89 | def phonetic_u_umlaut(sound: Vowel) -> Vowel:
"""
>>> umlaut_a = OldNorsePhonology.phonetic_u_umlaut(a)
>>> umlaut_a.ipar
'ø'
>>> umlaut_o = OldNorsePhonology.phonetic_u_umlaut(o)
>>> umlaut_o.ipar
'u'
>>> umlaut_e = OldNorsePhonology.phonetic_u_umlaut(e... | [
"def",
"phonetic_u_umlaut",
"(",
"sound",
":",
"Vowel",
")",
"->",
"Vowel",
":",
"if",
"sound",
".",
"is_equal",
"(",
"a",
")",
":",
"return",
"oee",
"# or oe",
"elif",
"sound",
".",
"is_equal",
"(",
"o",
")",
":",
"return",
"u",
"else",
":",
"return... | >>> umlaut_a = OldNorsePhonology.phonetic_u_umlaut(a)
>>> umlaut_a.ipar
'ø'
>>> umlaut_o = OldNorsePhonology.phonetic_u_umlaut(o)
>>> umlaut_o.ipar
'u'
>>> umlaut_e = OldNorsePhonology.phonetic_u_umlaut(e)
>>> umlaut_e.ipar
'e'
:param sound: in... | [
">>>",
"umlaut_a",
"=",
"OldNorsePhonology",
".",
"phonetic_u_umlaut",
"(",
"a",
")",
">>>",
"umlaut_a",
".",
"ipar",
"ø"
] | python | train | 23.375 |
linkedin/pyexchange | pyexchange/exchange2010/__init__.py | https://github.com/linkedin/pyexchange/blob/d568f4edd326adb451b915ddf66cf1a37820e3ca/pyexchange/exchange2010/__init__.py#L129-L145 | def _parse_response_for_all_events(self, response):
"""
This function will retrieve *most* of the event data, excluding Organizer & Attendee details
"""
items = response.xpath(u'//m:FindItemResponseMessage/m:RootFolder/t:Items/t:CalendarItem', namespaces=soap_request.NAMESPACES)
if not items:
... | [
"def",
"_parse_response_for_all_events",
"(",
"self",
",",
"response",
")",
":",
"items",
"=",
"response",
".",
"xpath",
"(",
"u'//m:FindItemResponseMessage/m:RootFolder/t:Items/t:CalendarItem'",
",",
"namespaces",
"=",
"soap_request",
".",
"NAMESPACES",
")",
"if",
"not... | This function will retrieve *most* of the event data, excluding Organizer & Attendee details | [
"This",
"function",
"will",
"retrieve",
"*",
"most",
"*",
"of",
"the",
"event",
"data",
"excluding",
"Organizer",
"&",
"Attendee",
"details"
] | python | train | 40.882353 |
sdispater/backpack | backpack/collections/base_collection.py | https://github.com/sdispater/backpack/blob/764e7f79fd2b1c1ac4883d8e5c9da5c65dfc875e/backpack/collections/base_collection.py#L519-L535 | def pull(self, key, default=None):
"""
Pulls an item from the collection.
:param key: The key
:type key: mixed
:param default: The default value
:type default: mixed
:rtype: mixed
"""
val = self.get(key, default)
self.forget(key)
... | [
"def",
"pull",
"(",
"self",
",",
"key",
",",
"default",
"=",
"None",
")",
":",
"val",
"=",
"self",
".",
"get",
"(",
"key",
",",
"default",
")",
"self",
".",
"forget",
"(",
"key",
")",
"return",
"val"
] | Pulls an item from the collection.
:param key: The key
:type key: mixed
:param default: The default value
:type default: mixed
:rtype: mixed | [
"Pulls",
"an",
"item",
"from",
"the",
"collection",
"."
] | python | train | 18.647059 |
inveniosoftware/invenio-logging | invenio_logging/sentry.py | https://github.com/inveniosoftware/invenio-logging/blob/59ee171ad4f9809f62a822964b5c68e5be672dd8/invenio_logging/sentry.py#L109-L116 | def process(self, data, **kwargs):
"""Process event data."""
data = super(RequestIdProcessor, self).process(data, **kwargs)
if g and hasattr(g, 'request_id'):
tags = data.get('tags', {})
tags['request_id'] = g.request_id
data['tags'] = tags
return data | [
"def",
"process",
"(",
"self",
",",
"data",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"super",
"(",
"RequestIdProcessor",
",",
"self",
")",
".",
"process",
"(",
"data",
",",
"*",
"*",
"kwargs",
")",
"if",
"g",
"and",
"hasattr",
"(",
"g",
",... | Process event data. | [
"Process",
"event",
"data",
"."
] | python | train | 39.125 |
thombashi/pytablewriter | pytablewriter/_factory.py | https://github.com/thombashi/pytablewriter/blob/52ea85ed8e89097afa64f137c6a1b3acdfefdbda/pytablewriter/_factory.py#L91-L147 | def create_from_format_name(cls, format_name):
"""
Create a table writer class instance from a format name.
Supported file format names are as follows:
============================================= ===================================
Format name ... | [
"def",
"create_from_format_name",
"(",
"cls",
",",
"format_name",
")",
":",
"format_name",
"=",
"format_name",
".",
"lower",
"(",
")",
"for",
"table_format",
"in",
"TableFormat",
":",
"if",
"format_name",
"in",
"table_format",
".",
"names",
"and",
"not",
"(",
... | Create a table writer class instance from a format name.
Supported file format names are as follows:
============================================= ===================================
Format name Writer Class
===============================... | [
"Create",
"a",
"table",
"writer",
"class",
"instance",
"from",
"a",
"format",
"name",
".",
"Supported",
"file",
"format",
"names",
"are",
"as",
"follows",
":"
] | python | train | 61.701754 |
StackStorm/pybind | pybind/nos/v6_0_2f/rbridge_id/hardware_profile/route_table/predefined/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/rbridge_id/hardware_profile/route_table/predefined/__init__.py#L93-L114 | def _set_routing_profiletype(self, v, load=False):
"""
Setter method for routing_profiletype, mapped from YANG variable /rbridge_id/hardware_profile/route_table/predefined/routing_profiletype (routing-profile-subtype)
If this variable is read-only (config: false) in the
source YANG file, then _set_routi... | [
"def",
"_set_routing_profiletype",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",... | Setter method for routing_profiletype, mapped from YANG variable /rbridge_id/hardware_profile/route_table/predefined/routing_profiletype (routing-profile-subtype)
If this variable is read-only (config: false) in the
source YANG file, then _set_routing_profiletype is considered as a private
method. Backends ... | [
"Setter",
"method",
"for",
"routing_profiletype",
"mapped",
"from",
"YANG",
"variable",
"/",
"rbridge_id",
"/",
"hardware_profile",
"/",
"route_table",
"/",
"predefined",
"/",
"routing_profiletype",
"(",
"routing",
"-",
"profile",
"-",
"subtype",
")",
"If",
"this"... | python | train | 111.136364 |
apache/incubator-mxnet | python/mxnet/random.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/random.py#L30-L100 | def seed(seed_state, ctx="all"):
"""Seeds the random number generators in MXNet.
This affects the behavior of modules in MXNet that uses random number generators,
like the dropout operator and `NDArray`'s random sampling operators.
Parameters
----------
seed_state : int
The random numb... | [
"def",
"seed",
"(",
"seed_state",
",",
"ctx",
"=",
"\"all\"",
")",
":",
"if",
"not",
"isinstance",
"(",
"seed_state",
",",
"integer_types",
")",
":",
"raise",
"ValueError",
"(",
"'seed_state must be int'",
")",
"seed_state",
"=",
"ctypes",
".",
"c_int",
"(",... | Seeds the random number generators in MXNet.
This affects the behavior of modules in MXNet that uses random number generators,
like the dropout operator and `NDArray`'s random sampling operators.
Parameters
----------
seed_state : int
The random number seed.
ctx : Context
The ... | [
"Seeds",
"the",
"random",
"number",
"generators",
"in",
"MXNet",
"."
] | python | train | 40.338028 |
toumorokoshi/transmute-core | example.py | https://github.com/toumorokoshi/transmute-core/blob/a2c26625d5d8bab37e00038f9d615a26167fc7f4/example.py#L95-L103 | def _convert_paths_to_flask(transmute_paths):
"""
convert transmute-core's path syntax (which uses {var} as the
variable wildcard) into flask's <var>.
"""
paths = []
for p in transmute_paths:
paths.append(p.replace("{", "<").replace("}", ">"))
return paths | [
"def",
"_convert_paths_to_flask",
"(",
"transmute_paths",
")",
":",
"paths",
"=",
"[",
"]",
"for",
"p",
"in",
"transmute_paths",
":",
"paths",
".",
"append",
"(",
"p",
".",
"replace",
"(",
"\"{\"",
",",
"\"<\"",
")",
".",
"replace",
"(",
"\"}\"",
",",
... | convert transmute-core's path syntax (which uses {var} as the
variable wildcard) into flask's <var>. | [
"convert",
"transmute",
"-",
"core",
"s",
"path",
"syntax",
"(",
"which",
"uses",
"{",
"var",
"}",
"as",
"the",
"variable",
"wildcard",
")",
"into",
"flask",
"s",
"<var",
">",
"."
] | python | train | 31.555556 |
rfosterslo/wagtailplus | wagtailplus/wagtailrelations/templatetags/wagtailrelations_tags.py | https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/wagtailrelations/templatetags/wagtailrelations_tags.py#L53-L67 | def get_related_with_scores(page):
"""
Returns list of related tuples (Entry instance, score) for
specified page.
:param page: the page instance.
:rtype: list.
"""
related = []
entry = Entry.get_for_model(page)
if entry:
related = entry.related_with_scores
return rel... | [
"def",
"get_related_with_scores",
"(",
"page",
")",
":",
"related",
"=",
"[",
"]",
"entry",
"=",
"Entry",
".",
"get_for_model",
"(",
"page",
")",
"if",
"entry",
":",
"related",
"=",
"entry",
".",
"related_with_scores",
"return",
"related"
] | Returns list of related tuples (Entry instance, score) for
specified page.
:param page: the page instance.
:rtype: list. | [
"Returns",
"list",
"of",
"related",
"tuples",
"(",
"Entry",
"instance",
"score",
")",
"for",
"specified",
"page",
"."
] | python | train | 20.666667 |
apache/incubator-superset | superset/views/tags.py | https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/tags.py#L91-L119 | def post(self, object_type, object_id):
"""Add new tags to an object."""
if object_id == 0:
return Response(status=404)
tagged_objects = []
for name in request.get_json(force=True):
if ':' in name:
type_name = name.split(':', 1)[0]
... | [
"def",
"post",
"(",
"self",
",",
"object_type",
",",
"object_id",
")",
":",
"if",
"object_id",
"==",
"0",
":",
"return",
"Response",
"(",
"status",
"=",
"404",
")",
"tagged_objects",
"=",
"[",
"]",
"for",
"name",
"in",
"request",
".",
"get_json",
"(",
... | Add new tags to an object. | [
"Add",
"new",
"tags",
"to",
"an",
"object",
"."
] | python | train | 29.517241 |
halcy/Mastodon.py | mastodon/Mastodon.py | https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L2182-L2187 | def domain_unblock(self, domain=None):
"""
Remove a domain block for the logged-in user.
"""
params = self.__generate_params(locals())
self.__api_request('DELETE', '/api/v1/domain_blocks', params) | [
"def",
"domain_unblock",
"(",
"self",
",",
"domain",
"=",
"None",
")",
":",
"params",
"=",
"self",
".",
"__generate_params",
"(",
"locals",
"(",
")",
")",
"self",
".",
"__api_request",
"(",
"'DELETE'",
",",
"'/api/v1/domain_blocks'",
",",
"params",
")"
] | Remove a domain block for the logged-in user. | [
"Remove",
"a",
"domain",
"block",
"for",
"the",
"logged",
"-",
"in",
"user",
"."
] | python | train | 38.5 |
peri-source/peri | peri/comp/comp.py | https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/comp.py#L532-L535 | def set_shape(self, shape, inner):
""" Set the shape for all components """
for c in self.comps:
c.set_shape(shape, inner) | [
"def",
"set_shape",
"(",
"self",
",",
"shape",
",",
"inner",
")",
":",
"for",
"c",
"in",
"self",
".",
"comps",
":",
"c",
".",
"set_shape",
"(",
"shape",
",",
"inner",
")"
] | Set the shape for all components | [
"Set",
"the",
"shape",
"for",
"all",
"components"
] | python | valid | 36.75 |
SheffieldML/GPyOpt | GPyOpt/core/evaluators/batch_local_penalization.py | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/evaluators/batch_local_penalization.py#L52-L70 | def estimate_L(model,bounds,storehistory=True):
"""
Estimate the Lipschitz constant of f by taking maximizing the norm of the expectation of the gradient of *f*.
"""
def df(x,model,x0):
x = np.atleast_2d(x)
dmdx,_ = model.predictive_gradients(x)
res = np.sqrt((dmdx*dmdx).sum(1)) ... | [
"def",
"estimate_L",
"(",
"model",
",",
"bounds",
",",
"storehistory",
"=",
"True",
")",
":",
"def",
"df",
"(",
"x",
",",
"model",
",",
"x0",
")",
":",
"x",
"=",
"np",
".",
"atleast_2d",
"(",
"x",
")",
"dmdx",
",",
"_",
"=",
"model",
".",
"pred... | Estimate the Lipschitz constant of f by taking maximizing the norm of the expectation of the gradient of *f*. | [
"Estimate",
"the",
"Lipschitz",
"constant",
"of",
"f",
"by",
"taking",
"maximizing",
"the",
"norm",
"of",
"the",
"expectation",
"of",
"the",
"gradient",
"of",
"*",
"f",
"*",
"."
] | python | train | 43.105263 |
wummel/linkchecker | third_party/dnspython/dns/name.py | https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/third_party/dnspython/dns/name.py#L534-L594 | def from_unicode(text, origin = root):
"""Convert unicode text into a Name object.
Lables are encoded in IDN ACE form.
@rtype: dns.name.Name object
"""
if not isinstance(text, unicode):
raise ValueError("input to from_unicode() must be a unicode string")
if not (origin is None or isin... | [
"def",
"from_unicode",
"(",
"text",
",",
"origin",
"=",
"root",
")",
":",
"if",
"not",
"isinstance",
"(",
"text",
",",
"unicode",
")",
":",
"raise",
"ValueError",
"(",
"\"input to from_unicode() must be a unicode string\"",
")",
"if",
"not",
"(",
"origin",
"is... | Convert unicode text into a Name object.
Lables are encoded in IDN ACE form.
@rtype: dns.name.Name object | [
"Convert",
"unicode",
"text",
"into",
"a",
"Name",
"object",
"."
] | python | train | 31.639344 |
flatangle/flatlib | flatlib/angle.py | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/angle.py#L82-L86 | def slistFloat(slist):
""" Converts signed list to float. """
values = [v / 60**(i) for (i,v) in enumerate(slist[1:])]
value = sum(values)
return -value if slist[0] == '-' else value | [
"def",
"slistFloat",
"(",
"slist",
")",
":",
"values",
"=",
"[",
"v",
"/",
"60",
"**",
"(",
"i",
")",
"for",
"(",
"i",
",",
"v",
")",
"in",
"enumerate",
"(",
"slist",
"[",
"1",
":",
"]",
")",
"]",
"value",
"=",
"sum",
"(",
"values",
")",
"r... | Converts signed list to float. | [
"Converts",
"signed",
"list",
"to",
"float",
"."
] | python | train | 38.8 |
openpermissions/koi | koi/utils.py | https://github.com/openpermissions/koi/blob/d721f8e1dfa8f07ad265d9dec32e8aaf80a9f281/koi/utils.py#L127-L140 | def sanitise_capabilities(capabilities):
"""
Makes sure dictionary of capabilities includes required options, and does not include protected ones.
:param capabilities:
:return: dict
"""
for c in REQUIRED_CAPABILITIES:
capabilities[c] = options[c]
for c in PROTECTED_CAPABILITIES:
... | [
"def",
"sanitise_capabilities",
"(",
"capabilities",
")",
":",
"for",
"c",
"in",
"REQUIRED_CAPABILITIES",
":",
"capabilities",
"[",
"c",
"]",
"=",
"options",
"[",
"c",
"]",
"for",
"c",
"in",
"PROTECTED_CAPABILITIES",
":",
"if",
"c",
"in",
"capabilities",
":"... | Makes sure dictionary of capabilities includes required options, and does not include protected ones.
:param capabilities:
:return: dict | [
"Makes",
"sure",
"dictionary",
"of",
"capabilities",
"includes",
"required",
"options",
"and",
"does",
"not",
"include",
"protected",
"ones",
".",
":",
"param",
"capabilities",
":",
":",
"return",
":",
"dict"
] | python | train | 28.857143 |
ArduPilot/MAVProxy | MAVProxy/modules/lib/MacOS/backend_wx.py | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L579-L588 | def set_joinstyle(self, js):
"""
Set the join style to be one of ('miter', 'round', 'bevel')
"""
DEBUG_MSG("set_joinstyle()", 1, self)
self.select()
GraphicsContextBase.set_joinstyle(self, js)
self._pen.SetJoin(GraphicsContextWx._joind[self._joinstyle])
se... | [
"def",
"set_joinstyle",
"(",
"self",
",",
"js",
")",
":",
"DEBUG_MSG",
"(",
"\"set_joinstyle()\"",
",",
"1",
",",
"self",
")",
"self",
".",
"select",
"(",
")",
"GraphicsContextBase",
".",
"set_joinstyle",
"(",
"self",
",",
"js",
")",
"self",
".",
"_pen",... | Set the join style to be one of ('miter', 'round', 'bevel') | [
"Set",
"the",
"join",
"style",
"to",
"be",
"one",
"of",
"(",
"miter",
"round",
"bevel",
")"
] | python | train | 36.3 |
Julian/Minion | minion/renderers.py | https://github.com/Julian/Minion/blob/518d06f9ffd38dcacc0de4d94e72d1f8452157a8/minion/renderers.py#L61-L85 | def bind(renderer, to):
"""
Bind a renderer to the given callable by constructing a new rendering view.
"""
@wraps(to)
def view(request, **kwargs):
try:
returned = to(request, **kwargs)
except Exception as error:
view_error = getattr(renderer, "view_error", ... | [
"def",
"bind",
"(",
"renderer",
",",
"to",
")",
":",
"@",
"wraps",
"(",
"to",
")",
"def",
"view",
"(",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"returned",
"=",
"to",
"(",
"request",
",",
"*",
"*",
"kwargs",
")",
"except",
"Exc... | Bind a renderer to the given callable by constructing a new rendering view. | [
"Bind",
"a",
"renderer",
"to",
"the",
"given",
"callable",
"by",
"constructing",
"a",
"new",
"rendering",
"view",
"."
] | python | train | 28.32 |
Alignak-monitoring/alignak | alignak/objects/service.py | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/service.py#L661-L680 | def raise_check_result(self):
"""Raise ACTIVE CHECK RESULT entry
Example : "ACTIVE SERVICE CHECK: server;DOWN;HARD;1;I don't know what to say..."
:return: None
"""
if not self.__class__.log_active_checks:
return
log_level = 'info'
if self.state in [u... | [
"def",
"raise_check_result",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"__class__",
".",
"log_active_checks",
":",
"return",
"log_level",
"=",
"'info'",
"if",
"self",
".",
"state",
"in",
"[",
"u'WARNING'",
",",
"u'UNREACHABLE'",
"]",
":",
"log_level",... | Raise ACTIVE CHECK RESULT entry
Example : "ACTIVE SERVICE CHECK: server;DOWN;HARD;1;I don't know what to say..."
:return: None | [
"Raise",
"ACTIVE",
"CHECK",
"RESULT",
"entry",
"Example",
":",
"ACTIVE",
"SERVICE",
"CHECK",
":",
"server",
";",
"DOWN",
";",
"HARD",
";",
"1",
";",
"I",
"don",
"t",
"know",
"what",
"to",
"say",
"..."
] | python | train | 38.95 |
globality-corp/microcosm-flask | microcosm_flask/paging.py | https://github.com/globality-corp/microcosm-flask/blob/c2eaf57f03e7d041eea343751a4a90fcc80df418/microcosm_flask/paging.py#L179-L195 | def to_paginated_list(self, result, _ns, _operation, **kwargs):
"""
Convert a controller result to a paginated list.
The result format is assumed to meet the contract of this page class's `parse_result` function.
"""
items, context = self.parse_result(result)
headers = ... | [
"def",
"to_paginated_list",
"(",
"self",
",",
"result",
",",
"_ns",
",",
"_operation",
",",
"*",
"*",
"kwargs",
")",
":",
"items",
",",
"context",
"=",
"self",
".",
"parse_result",
"(",
"result",
")",
"headers",
"=",
"dict",
"(",
")",
"paginated_list",
... | Convert a controller result to a paginated list.
The result format is assumed to meet the contract of this page class's `parse_result` function. | [
"Convert",
"a",
"controller",
"result",
"to",
"a",
"paginated",
"list",
"."
] | python | train | 31.411765 |
icgood/pymap | pymap/backend/mailbox.py | https://github.com/icgood/pymap/blob/e77d9a54d760e3cbe044a548883bb4299ed61dc2/pymap/backend/mailbox.py#L204-L215 | async def find_deleted(self, seq_set: SequenceSet,
selected: SelectedMailbox) -> Sequence[int]:
"""Return all the active message UIDs that have the ``\\Deleted`` flag.
Args:
seq_set: The sequence set of the possible messages.
selected: The selected mai... | [
"async",
"def",
"find_deleted",
"(",
"self",
",",
"seq_set",
":",
"SequenceSet",
",",
"selected",
":",
"SelectedMailbox",
")",
"->",
"Sequence",
"[",
"int",
"]",
":",
"session_flags",
"=",
"selected",
".",
"session_flags",
"return",
"[",
"msg",
".",
"uid",
... | Return all the active message UIDs that have the ``\\Deleted`` flag.
Args:
seq_set: The sequence set of the possible messages.
selected: The selected mailbox session. | [
"Return",
"all",
"the",
"active",
"message",
"UIDs",
"that",
"have",
"the",
"\\\\",
"Deleted",
"flag",
"."
] | python | train | 42.916667 |
praekeltfoundation/molo.yourtips | molo/yourtips/templatetags/tip_tags.py | https://github.com/praekeltfoundation/molo.yourtips/blob/8b3e3b1ff52cd4a78ccca5d153b3909a1f21625f/molo/yourtips/templatetags/tip_tags.py#L55-L80 | def your_tips_on_tip_submission_form(context):
"""
A template tag to display the most recent and popular tip
on the tip submission form.
:param context: takes context
"""
context = copy(context)
site_main = context['request'].site.root_page
most_recent_tip = (YourTipsArticlePage.objects... | [
"def",
"your_tips_on_tip_submission_form",
"(",
"context",
")",
":",
"context",
"=",
"copy",
"(",
"context",
")",
"site_main",
"=",
"context",
"[",
"'request'",
"]",
".",
"site",
".",
"root_page",
"most_recent_tip",
"=",
"(",
"YourTipsArticlePage",
".",
"objects... | A template tag to display the most recent and popular tip
on the tip submission form.
:param context: takes context | [
"A",
"template",
"tag",
"to",
"display",
"the",
"most",
"recent",
"and",
"popular",
"tip",
"on",
"the",
"tip",
"submission",
"form",
".",
":",
"param",
"context",
":",
"takes",
"context"
] | python | train | 33.5 |
gccxml/pygccxml | pygccxml/declarations/free_calldef.py | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/free_calldef.py#L95-L114 | def class_types(self):
"""list of class/class declaration types, extracted from the
operator arguments"""
if None is self.__class_types:
self.__class_types = []
for type_ in self.argument_types:
decl = None
type_ = type_traits.remove_refer... | [
"def",
"class_types",
"(",
"self",
")",
":",
"if",
"None",
"is",
"self",
".",
"__class_types",
":",
"self",
".",
"__class_types",
"=",
"[",
"]",
"for",
"type_",
"in",
"self",
".",
"argument_types",
":",
"decl",
"=",
"None",
"type_",
"=",
"type_traits",
... | list of class/class declaration types, extracted from the
operator arguments | [
"list",
"of",
"class",
"/",
"class",
"declaration",
"types",
"extracted",
"from",
"the",
"operator",
"arguments"
] | python | train | 41.35 |
tcalmant/ipopo | pelix/framework.py | https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/framework.py#L944-L1000 | def install_package(self, path, recursive=False, prefix=None):
# type: (str, bool, str) -> tuple
"""
Installs all the modules found in the given package
:param path: Path of the package (folder)
:param recursive: If True, install the sub-packages too
:param prefix: (**in... | [
"def",
"install_package",
"(",
"self",
",",
"path",
",",
"recursive",
"=",
"False",
",",
"prefix",
"=",
"None",
")",
":",
"# type: (str, bool, str) -> tuple",
"if",
"not",
"path",
":",
"raise",
"ValueError",
"(",
"\"Empty path\"",
")",
"elif",
"not",
"is_strin... | Installs all the modules found in the given package
:param path: Path of the package (folder)
:param recursive: If True, install the sub-packages too
:param prefix: (**internal**) Prefix for all found modules
:return: A 2-tuple, with the list of installed bundles and the list
... | [
"Installs",
"all",
"the",
"modules",
"found",
"in",
"the",
"given",
"package"
] | python | train | 35.333333 |
mattja/nsim | nsim/analysesN/plots.py | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analysesN/plots.py#L39-L81 | def phase_histogram(dts, times=None, nbins=30, colormap=mpl.cm.Blues):
"""Plot a polar histogram of a phase variable's probability distribution
Args:
dts: DistTimeseries with axis 2 ranging over separate instances of an
oscillator (time series values are assumed to represent an angle)
times ... | [
"def",
"phase_histogram",
"(",
"dts",
",",
"times",
"=",
"None",
",",
"nbins",
"=",
"30",
",",
"colormap",
"=",
"mpl",
".",
"cm",
".",
"Blues",
")",
":",
"if",
"times",
"is",
"None",
":",
"times",
"=",
"np",
".",
"linspace",
"(",
"dts",
".",
"tsp... | Plot a polar histogram of a phase variable's probability distribution
Args:
dts: DistTimeseries with axis 2 ranging over separate instances of an
oscillator (time series values are assumed to represent an angle)
times (float or sequence of floats): The target times at which
to plot the ... | [
"Plot",
"a",
"polar",
"histogram",
"of",
"a",
"phase",
"variable",
"s",
"probability",
"distribution",
"Args",
":",
"dts",
":",
"DistTimeseries",
"with",
"axis",
"2",
"ranging",
"over",
"separate",
"instances",
"of",
"an",
"oscillator",
"(",
"time",
"series",
... | python | train | 45.790698 |
ray-project/ray | python/ray/function_manager.py | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/function_manager.py#L164-L172 | def is_for_driver_task(self):
"""See whether this function descriptor is for a driver or not.
Returns:
True if this function descriptor is for driver tasks.
"""
return all(
len(x) == 0
for x in [self.module_name, self.class_name, self.function_name]) | [
"def",
"is_for_driver_task",
"(",
"self",
")",
":",
"return",
"all",
"(",
"len",
"(",
"x",
")",
"==",
"0",
"for",
"x",
"in",
"[",
"self",
".",
"module_name",
",",
"self",
".",
"class_name",
",",
"self",
".",
"function_name",
"]",
")"
] | See whether this function descriptor is for a driver or not.
Returns:
True if this function descriptor is for driver tasks. | [
"See",
"whether",
"this",
"function",
"descriptor",
"is",
"for",
"a",
"driver",
"or",
"not",
"."
] | python | train | 34.555556 |
databricks/spark-sklearn | python/spark_sklearn/group_apply.py | https://github.com/databricks/spark-sklearn/blob/cbde36f6311b73d967e2ec8a97040dfd71eca579/python/spark_sklearn/group_apply.py#L15-L166 | def gapply(grouped_data, func, schema, *cols):
"""Applies the function ``func`` to data grouped by key. In particular, given a dataframe
grouped by some set of key columns key1, key2, ..., keyn, this method groups all the values
for each row with the same key columns into a single Pandas dataframe and by de... | [
"def",
"gapply",
"(",
"grouped_data",
",",
"func",
",",
"schema",
",",
"*",
"cols",
")",
":",
"import",
"pandas",
"as",
"pd",
"minPandasVersion",
"=",
"'0.7.1'",
"if",
"LooseVersion",
"(",
"pd",
".",
"__version__",
")",
"<",
"LooseVersion",
"(",
"minPandas... | Applies the function ``func`` to data grouped by key. In particular, given a dataframe
grouped by some set of key columns key1, key2, ..., keyn, this method groups all the values
for each row with the same key columns into a single Pandas dataframe and by default invokes
``func((key1, key2, ..., keyn), valu... | [
"Applies",
"the",
"function",
"func",
"to",
"data",
"grouped",
"by",
"key",
".",
"In",
"particular",
"given",
"a",
"dataframe",
"grouped",
"by",
"some",
"set",
"of",
"key",
"columns",
"key1",
"key2",
"...",
"keyn",
"this",
"method",
"groups",
"all",
"the",... | python | train | 50.585526 |
UDST/urbansim | urbansim/developer/developer.py | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/developer/developer.py#L234-L269 | def merge(old_df, new_df, return_index=False):
"""
Merge two dataframes of buildings. The old dataframe is
usually the buildings dataset and the new dataframe is a modified
(by the user) version of what is returned by the pick method.
Parameters
----------
old_d... | [
"def",
"merge",
"(",
"old_df",
",",
"new_df",
",",
"return_index",
"=",
"False",
")",
":",
"maxind",
"=",
"np",
".",
"max",
"(",
"old_df",
".",
"index",
".",
"values",
")",
"new_df",
"=",
"new_df",
".",
"reset_index",
"(",
"drop",
"=",
"True",
")",
... | Merge two dataframes of buildings. The old dataframe is
usually the buildings dataset and the new dataframe is a modified
(by the user) version of what is returned by the pick method.
Parameters
----------
old_df : dataframe
Current set of buildings
new_df :... | [
"Merge",
"two",
"dataframes",
"of",
"buildings",
".",
"The",
"old",
"dataframe",
"is",
"usually",
"the",
"buildings",
"dataset",
"and",
"the",
"new",
"dataframe",
"is",
"a",
"modified",
"(",
"by",
"the",
"user",
")",
"version",
"of",
"what",
"is",
"returne... | python | train | 37.166667 |
jic-dtool/dtoolcore | dtoolcore/storagebroker.py | https://github.com/jic-dtool/dtoolcore/blob/eeb9a924dc8fcf543340653748a7877be1f98e0f/dtoolcore/storagebroker.py#L537-L549 | def iter_item_handles(self):
"""Return iterator over item handles."""
path = self._data_abspath
path_length = len(path) + 1
for dirpath, dirnames, filenames in os.walk(path):
for fn in filenames:
path = os.path.join(dirpath, fn)
relative_path... | [
"def",
"iter_item_handles",
"(",
"self",
")",
":",
"path",
"=",
"self",
".",
"_data_abspath",
"path_length",
"=",
"len",
"(",
"path",
")",
"+",
"1",
"for",
"dirpath",
",",
"dirnames",
",",
"filenames",
"in",
"os",
".",
"walk",
"(",
"path",
")",
":",
... | Return iterator over item handles. | [
"Return",
"iterator",
"over",
"item",
"handles",
"."
] | python | train | 36 |
ralphje/imagemounter | imagemounter/volume.py | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/volume.py#L504-L531 | def _find_loopback(self, use_loopback=True, var_name='loopback'):
"""Finds a free loopback device that can be used. The loopback is stored in :attr:`loopback`. If *use_loopback*
is True, the loopback will also be used directly.
:returns: the loopback address
:raises NoLoopbackAvailableE... | [
"def",
"_find_loopback",
"(",
"self",
",",
"use_loopback",
"=",
"True",
",",
"var_name",
"=",
"'loopback'",
")",
":",
"# noinspection PyBroadException",
"try",
":",
"loopback",
"=",
"_util",
".",
"check_output_",
"(",
"[",
"'losetup'",
",",
"'-f'",
"]",
")",
... | Finds a free loopback device that can be used. The loopback is stored in :attr:`loopback`. If *use_loopback*
is True, the loopback will also be used directly.
:returns: the loopback address
:raises NoLoopbackAvailableError: if no loopback could be found | [
"Finds",
"a",
"free",
"loopback",
"device",
"that",
"can",
"be",
"used",
".",
"The",
"loopback",
"is",
"stored",
"in",
":",
"attr",
":",
"loopback",
".",
"If",
"*",
"use_loopback",
"*",
"is",
"True",
"the",
"loopback",
"will",
"also",
"be",
"used",
"di... | python | train | 43.142857 |
hydpy-dev/hydpy | hydpy/core/sequencetools.py | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/sequencetools.py#L1985-L1997 | def open_files(self, idx):
"""Open all files with an activated disk flag."""
for name in self:
if getattr(self, '_%s_diskflag' % name):
path = getattr(self, '_%s_path' % name)
file_ = open(path, 'rb+')
ndim = getattr(self, '_%s_ndim' % name)
... | [
"def",
"open_files",
"(",
"self",
",",
"idx",
")",
":",
"for",
"name",
"in",
"self",
":",
"if",
"getattr",
"(",
"self",
",",
"'_%s_diskflag'",
"%",
"name",
")",
":",
"path",
"=",
"getattr",
"(",
"self",
",",
"'_%s_path'",
"%",
"name",
")",
"file_",
... | Open all files with an activated disk flag. | [
"Open",
"all",
"files",
"with",
"an",
"activated",
"disk",
"flag",
"."
] | python | train | 45.076923 |
sanoma/django-arctic | arctic/mixins.py | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/mixins.py#L56-L90 | def get_modal_link(self, url, obj={}):
"""
Returns the metadata for a link that needs to be confirmed, if it
exists, it also parses the message and title of the url to include
row field data if needed.
"""
if not (url in self.modal_links.keys()):
return None
... | [
"def",
"get_modal_link",
"(",
"self",
",",
"url",
",",
"obj",
"=",
"{",
"}",
")",
":",
"if",
"not",
"(",
"url",
"in",
"self",
".",
"modal_links",
".",
"keys",
"(",
")",
")",
":",
"return",
"None",
"try",
":",
"if",
"type",
"(",
"obj",
")",
"!="... | Returns the metadata for a link that needs to be confirmed, if it
exists, it also parses the message and title of the url to include
row field data if needed. | [
"Returns",
"the",
"metadata",
"for",
"a",
"link",
"that",
"needs",
"to",
"be",
"confirmed",
"if",
"it",
"exists",
"it",
"also",
"parses",
"the",
"message",
"and",
"title",
"of",
"the",
"url",
"to",
"include",
"row",
"field",
"data",
"if",
"needed",
"."
] | python | train | 36.514286 |
sprockets/sprockets.mixins.amqp | sprockets/mixins/amqp/__init__.py | https://github.com/sprockets/sprockets.mixins.amqp/blob/de22b85aec1315bc01e47774637098c34525692b/sprockets/mixins/amqp/__init__.py#L371-L388 | def connect(self):
"""This method connects to RabbitMQ, returning the connection handle.
When the connection is established, the on_connection_open method
will be invoked by pika.
:rtype: pika.TornadoConnection
"""
if not self.idle and not self.closed:
raise... | [
"def",
"connect",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"idle",
"and",
"not",
"self",
".",
"closed",
":",
"raise",
"ConnectionStateError",
"(",
"self",
".",
"state_description",
")",
"LOGGER",
".",
"debug",
"(",
"'Connecting to %s'",
",",
"self"... | This method connects to RabbitMQ, returning the connection handle.
When the connection is established, the on_connection_open method
will be invoked by pika.
:rtype: pika.TornadoConnection | [
"This",
"method",
"connects",
"to",
"RabbitMQ",
"returning",
"the",
"connection",
"handle",
".",
"When",
"the",
"connection",
"is",
"established",
"the",
"on_connection_open",
"method",
"will",
"be",
"invoked",
"by",
"pika",
"."
] | python | train | 41.611111 |
nameko/nameko | nameko/extensions.py | https://github.com/nameko/nameko/blob/88d7e5211de4fcc1c34cd7f84d7c77f0619c5f5d/nameko/extensions.py#L123-L136 | def bind(self, container):
""" Bind implementation that supports sharing.
"""
# if there's already a matching bound instance, return that
shared = container.shared_extensions.get(self.sharing_key)
if shared:
return shared
instance = super(SharedExtension, sel... | [
"def",
"bind",
"(",
"self",
",",
"container",
")",
":",
"# if there's already a matching bound instance, return that",
"shared",
"=",
"container",
".",
"shared_extensions",
".",
"get",
"(",
"self",
".",
"sharing_key",
")",
"if",
"shared",
":",
"return",
"shared",
... | Bind implementation that supports sharing. | [
"Bind",
"implementation",
"that",
"supports",
"sharing",
"."
] | python | train | 32 |
tensorflow/probability | tensorflow_probability/python/internal/distribution_util.py | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L875-L886 | def _largest_integer_by_dtype(dt):
"""Helper returning the largest integer exactly representable by dtype."""
if not _is_known_dtype(dt):
raise TypeError("Unrecognized dtype: {}".format(dt.name))
if dt.is_floating:
return int(2**(np.finfo(dt.as_numpy_dtype).nmant + 1))
if dt.is_integer:
return np.ii... | [
"def",
"_largest_integer_by_dtype",
"(",
"dt",
")",
":",
"if",
"not",
"_is_known_dtype",
"(",
"dt",
")",
":",
"raise",
"TypeError",
"(",
"\"Unrecognized dtype: {}\"",
".",
"format",
"(",
"dt",
".",
"name",
")",
")",
"if",
"dt",
".",
"is_floating",
":",
"re... | Helper returning the largest integer exactly representable by dtype. | [
"Helper",
"returning",
"the",
"largest",
"integer",
"exactly",
"representable",
"by",
"dtype",
"."
] | python | test | 42.666667 |
Datary/scrapbag | scrapbag/csvs.py | https://github.com/Datary/scrapbag/blob/3a4f9824ab6fe21121214ba9963690618da2c9de/scrapbag/csvs.py#L307-L328 | def csv_column_cleaner(rows):
"""
clean csv columns parsed omitting empty/dirty rows.
"""
# check columns if there was empty columns
result = [[] for x in range(0, len(rows))]
for i_index in range(0, len(rows[0])):
partial_values = []
for x_row in rows:
partial_val... | [
"def",
"csv_column_cleaner",
"(",
"rows",
")",
":",
"# check columns if there was empty columns",
"result",
"=",
"[",
"[",
"]",
"for",
"x",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"rows",
")",
")",
"]",
"for",
"i_index",
"in",
"range",
"(",
"0",
",",
... | clean csv columns parsed omitting empty/dirty rows. | [
"clean",
"csv",
"columns",
"parsed",
"omitting",
"empty",
"/",
"dirty",
"rows",
"."
] | python | train | 30.954545 |
quodlibet/mutagen | mutagen/mp4/_as_entry.py | https://github.com/quodlibet/mutagen/blob/e393df5971ba41ba5a50de9c2c9e7e5484d82c4e/mutagen/mp4/_as_entry.py#L396-L418 | def channels(self):
"""channel count or 0 for unknown"""
# from ProgramConfigElement()
if hasattr(self, "pce_channels"):
return self.pce_channels
conf = getattr(
self, "extensionChannelConfiguration", self.channelConfiguration)
if conf == 1:
... | [
"def",
"channels",
"(",
"self",
")",
":",
"# from ProgramConfigElement()",
"if",
"hasattr",
"(",
"self",
",",
"\"pce_channels\"",
")",
":",
"return",
"self",
".",
"pce_channels",
"conf",
"=",
"getattr",
"(",
"self",
",",
"\"extensionChannelConfiguration\"",
",",
... | channel count or 0 for unknown | [
"channel",
"count",
"or",
"0",
"for",
"unknown"
] | python | train | 25.608696 |
SFDO-Tooling/CumulusCI | cumulusci/core/keychain/BaseProjectKeychain.py | https://github.com/SFDO-Tooling/CumulusCI/blob/e19047921ca771a297e045f22f0bb201651bb6f7/cumulusci/core/keychain/BaseProjectKeychain.py#L240-L244 | def list_services(self):
""" list the services configured in the keychain """
services = list(self.services.keys())
services.sort()
return services | [
"def",
"list_services",
"(",
"self",
")",
":",
"services",
"=",
"list",
"(",
"self",
".",
"services",
".",
"keys",
"(",
")",
")",
"services",
".",
"sort",
"(",
")",
"return",
"services"
] | list the services configured in the keychain | [
"list",
"the",
"services",
"configured",
"in",
"the",
"keychain"
] | python | train | 35 |
trailofbits/manticore | manticore/native/cpu/x86.py | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/native/cpu/x86.py#L5560-L5565 | def VORPD(cpu, dest, src, src2):
"""
Performs a bitwise logical OR operation on the source operand (second operand) and second source operand (third operand)
and stores the result in the destination operand (first operand).
"""
res = dest.write(src.read() | src2.read()) | [
"def",
"VORPD",
"(",
"cpu",
",",
"dest",
",",
"src",
",",
"src2",
")",
":",
"res",
"=",
"dest",
".",
"write",
"(",
"src",
".",
"read",
"(",
")",
"|",
"src2",
".",
"read",
"(",
")",
")"
] | Performs a bitwise logical OR operation on the source operand (second operand) and second source operand (third operand)
and stores the result in the destination operand (first operand). | [
"Performs",
"a",
"bitwise",
"logical",
"OR",
"operation",
"on",
"the",
"source",
"operand",
"(",
"second",
"operand",
")",
"and",
"second",
"source",
"operand",
"(",
"third",
"operand",
")",
"and",
"stores",
"the",
"result",
"in",
"the",
"destination",
"oper... | python | valid | 51 |
sorgerlab/indra | indra/mechlinker/__init__.py | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/mechlinker/__init__.py#L277-L328 | def infer_activations(stmts):
"""Return inferred RegulateActivity from Modification + ActiveForm.
This function looks for combinations of Modification and ActiveForm
Statements and infers Activation/Inhibition Statements from them.
For example, if we know that A phosphorylates B, and th... | [
"def",
"infer_activations",
"(",
"stmts",
")",
":",
"linked_stmts",
"=",
"[",
"]",
"af_stmts",
"=",
"_get_statements_by_type",
"(",
"stmts",
",",
"ActiveForm",
")",
"mod_stmts",
"=",
"_get_statements_by_type",
"(",
"stmts",
",",
"Modification",
")",
"for",
"af_s... | Return inferred RegulateActivity from Modification + ActiveForm.
This function looks for combinations of Modification and ActiveForm
Statements and infers Activation/Inhibition Statements from them.
For example, if we know that A phosphorylates B, and the
phosphorylated form of B is act... | [
"Return",
"inferred",
"RegulateActivity",
"from",
"Modification",
"+",
"ActiveForm",
"."
] | python | train | 45.519231 |
awslabs/mxboard | python/mxboard/summary.py | https://github.com/awslabs/mxboard/blob/36057ff0f05325c9dc2fe046521325bf9d563a88/python/mxboard/summary.py#L272-L320 | def pr_curve_summary(tag, labels, predictions, num_thresholds, weights=None):
"""Outputs a precision-recall curve `Summary` protocol buffer.
Parameters
----------
tag : str
A tag attached to the summary. Used by TensorBoard for organization.
labels : MXNet `NDArray` or `numpy.nd... | [
"def",
"pr_curve_summary",
"(",
"tag",
",",
"labels",
",",
"predictions",
",",
"num_thresholds",
",",
"weights",
"=",
"None",
")",
":",
"# num_thresholds > 127 results in failure of creating protobuf,",
"# probably a bug of protobuf",
"if",
"num_thresholds",
">",
"127",
"... | Outputs a precision-recall curve `Summary` protocol buffer.
Parameters
----------
tag : str
A tag attached to the summary. Used by TensorBoard for organization.
labels : MXNet `NDArray` or `numpy.ndarray`.
The ground truth values. A tensor of 0/1 values with arbitrary sh... | [
"Outputs",
"a",
"precision",
"-",
"recall",
"curve",
"Summary",
"protocol",
"buffer",
"."
] | python | train | 53.55102 |
HPENetworking/PYHPEIMC | pyhpeimc/objects.py | https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/pyhpeimc/objects.py#L129-L137 | def delvlan(self, vlanid):
"""
Function operates on the IMCDev object. Takes input of vlanid (1-4094),
auth and url to execute the delete_dev_vlans method on the IMCDev object. Device must be
supported in the HPE IMC Platform VLAN Manager module.
:param vlanid: str of VLANId ( va... | [
"def",
"delvlan",
"(",
"self",
",",
"vlanid",
")",
":",
"delete_dev_vlans",
"(",
"vlanid",
",",
"self",
".",
"auth",
",",
"self",
".",
"url",
",",
"devid",
"=",
"self",
".",
"devid",
")"
] | Function operates on the IMCDev object. Takes input of vlanid (1-4094),
auth and url to execute the delete_dev_vlans method on the IMCDev object. Device must be
supported in the HPE IMC Platform VLAN Manager module.
:param vlanid: str of VLANId ( valid 1-4094 )
:return: | [
"Function",
"operates",
"on",
"the",
"IMCDev",
"object",
".",
"Takes",
"input",
"of",
"vlanid",
"(",
"1",
"-",
"4094",
")",
"auth",
"and",
"url",
"to",
"execute",
"the",
"delete_dev_vlans",
"method",
"on",
"the",
"IMCDev",
"object",
".",
"Device",
"must",
... | python | train | 47.555556 |
GoogleCloudPlatform/appengine-mapreduce | python/src/mapreduce/api/map_job/map_job_control.py | https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/api/map_job/map_job_control.py#L98-L111 | def get_counter(self, counter_name, default=0):
"""Get the value of the named counter from this job.
When a job is running, counter values won't be very accurate.
Args:
counter_name: name of the counter in string.
default: default value if the counter doesn't exist.
Returns:
Value i... | [
"def",
"get_counter",
"(",
"self",
",",
"counter_name",
",",
"default",
"=",
"0",
")",
":",
"self",
".",
"__update_state",
"(",
")",
"return",
"self",
".",
"_state",
".",
"counters_map",
".",
"get",
"(",
"counter_name",
",",
"default",
")"
] | Get the value of the named counter from this job.
When a job is running, counter values won't be very accurate.
Args:
counter_name: name of the counter in string.
default: default value if the counter doesn't exist.
Returns:
Value in int of the named counter. | [
"Get",
"the",
"value",
"of",
"the",
"named",
"counter",
"from",
"this",
"job",
"."
] | python | train | 30.785714 |
mwickert/scikit-dsp-comm | sk_dsp_comm/fir_design_helper.py | https://github.com/mwickert/scikit-dsp-comm/blob/5c1353412a4d81a8d7da169057564ecf940f8b5b/sk_dsp_comm/fir_design_helper.py#L122-L161 | def firwin_kaiser_bpf(f_stop1, f_pass1, f_pass2, f_stop2, d_stop,
fs = 1.0, N_bump=0):
"""
Design an FIR bandpass filter using the sinc() kernel and
a Kaiser window. The filter order is determined based on
f_stop1 Hz, f_pass1 Hz, f_pass2 Hz, f_stop2 Hz, and the
desired... | [
"def",
"firwin_kaiser_bpf",
"(",
"f_stop1",
",",
"f_pass1",
",",
"f_pass2",
",",
"f_stop2",
",",
"d_stop",
",",
"fs",
"=",
"1.0",
",",
"N_bump",
"=",
"0",
")",
":",
"# Design BPF starting from simple LPF equivalent\r",
"# The upper and lower stopbands are assumed to hav... | Design an FIR bandpass filter using the sinc() kernel and
a Kaiser window. The filter order is determined based on
f_stop1 Hz, f_pass1 Hz, f_pass2 Hz, f_stop2 Hz, and the
desired stopband attenuation d_stop in dB for both stopbands,
all relative to a sampling rate of fs Hz.
Note: the passband... | [
"Design",
"an",
"FIR",
"bandpass",
"filter",
"using",
"the",
"sinc",
"()",
"kernel",
"and",
"a",
"Kaiser",
"window",
".",
"The",
"filter",
"order",
"is",
"determined",
"based",
"on",
"f_stop1",
"Hz",
"f_pass1",
"Hz",
"f_pass2",
"Hz",
"f_stop2",
"Hz",
"and"... | python | valid | 37.7 |
Shapeways/coyote_framework | coyote_framework/webdriver/webdriverwrapper/WebElementWrapper.py | https://github.com/Shapeways/coyote_framework/blob/cb29899b984a21d56bf65d0b1d907073948fe16c/coyote_framework/webdriver/webdriverwrapper/WebElementWrapper.py#L230-L251 | def is_on_screen(self):
"""Tests if the element is within the viewport of the screen (partially hidden by overflow will return true)
@return: True if on screen, False otherwise
"""
width = self.get_width()
height = self.get_height()
loc = self.location()
el_x_lef... | [
"def",
"is_on_screen",
"(",
"self",
")",
":",
"width",
"=",
"self",
".",
"get_width",
"(",
")",
"height",
"=",
"self",
".",
"get_height",
"(",
")",
"loc",
"=",
"self",
".",
"location",
"(",
")",
"el_x_left",
"=",
"loc",
"[",
"'x'",
"]",
"el_x_right",... | Tests if the element is within the viewport of the screen (partially hidden by overflow will return true)
@return: True if on screen, False otherwise | [
"Tests",
"if",
"the",
"element",
"is",
"within",
"the",
"viewport",
"of",
"the",
"screen",
"(",
"partially",
"hidden",
"by",
"overflow",
"will",
"return",
"true",
")"
] | python | train | 37.409091 |
KieranWynn/pyquaternion | pyquaternion/quaternion.py | https://github.com/KieranWynn/pyquaternion/blob/d2aad7f3fb0d4b9cc23aa72b390e9b2e1273eae9/pyquaternion/quaternion.py#L1026-L1052 | def get_axis(self, undefined=np.zeros(3)):
"""Get the axis or vector about which the quaternion rotation occurs
For a null rotation (a purely real quaternion), the rotation angle will
always be `0`, but the rotation axis is undefined.
It is by default assumed to be `[0, 0, 0]`.
... | [
"def",
"get_axis",
"(",
"self",
",",
"undefined",
"=",
"np",
".",
"zeros",
"(",
"3",
")",
")",
":",
"tolerance",
"=",
"1e-17",
"self",
".",
"_normalise",
"(",
")",
"norm",
"=",
"np",
".",
"linalg",
".",
"norm",
"(",
"self",
".",
"vector",
")",
"i... | Get the axis or vector about which the quaternion rotation occurs
For a null rotation (a purely real quaternion), the rotation angle will
always be `0`, but the rotation axis is undefined.
It is by default assumed to be `[0, 0, 0]`.
Params:
undefined: [optional] specify the... | [
"Get",
"the",
"axis",
"or",
"vector",
"about",
"which",
"the",
"quaternion",
"rotation",
"occurs"
] | python | train | 46.111111 |
oscarlazoarjona/fast | fast/angular_momentum.py | https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/angular_momentum.py#L365-L416 | def spherical_tensor(Ji, Jj, K, Q):
ur"""Return a matrix representation of the spherical tensor with quantum
numbers $J_i, J_j, K, Q$.
>>> from sympy import pprint
>>> pprint(spherical_tensor(1, 1, 1, 0))
⎡-√2 ⎤
⎢──── 0 0 ⎥
⎢ 2 ⎥
⎢ ⎥
⎢ 0 0 0 ⎥
⎢ ... | [
"def",
"spherical_tensor",
"(",
"Ji",
",",
"Jj",
",",
"K",
",",
"Q",
")",
":",
"keti",
"=",
"{",
"(",
"Ji",
",",
"Mi",
")",
":",
"Matrix",
"(",
"[",
"KroneckerDelta",
"(",
"i",
",",
"j",
")",
"for",
"j",
"in",
"range",
"(",
"2",
"*",
"Ji",
... | ur"""Return a matrix representation of the spherical tensor with quantum
numbers $J_i, J_j, K, Q$.
>>> from sympy import pprint
>>> pprint(spherical_tensor(1, 1, 1, 0))
⎡-√2 ⎤
⎢──── 0 0 ⎥
⎢ 2 ⎥
⎢ ⎥
⎢ 0 0 0 ⎥
⎢ ⎥
⎢ √2⎥
⎢ 0 0... | [
"ur",
"Return",
"a",
"matrix",
"representation",
"of",
"the",
"spherical",
"tensor",
"with",
"quantum",
"numbers",
"$J_i",
"J_j",
"K",
"Q$",
"."
] | python | train | 26.788462 |
rootpy/rootpy | rootpy/io/file.py | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/io/file.py#L410-L419 | def rm(self, path, cycle=';*'):
"""
Delete an object at `path` relative to this directory
"""
rdir = self
with preserve_current_directory():
dirname, objname = os.path.split(os.path.normpath(path))
if dirname:
rdir = rdir.Get(dirname)
... | [
"def",
"rm",
"(",
"self",
",",
"path",
",",
"cycle",
"=",
"';*'",
")",
":",
"rdir",
"=",
"self",
"with",
"preserve_current_directory",
"(",
")",
":",
"dirname",
",",
"objname",
"=",
"os",
".",
"path",
".",
"split",
"(",
"os",
".",
"path",
".",
"nor... | Delete an object at `path` relative to this directory | [
"Delete",
"an",
"object",
"at",
"path",
"relative",
"to",
"this",
"directory"
] | python | train | 34.6 |
Godley/MuseParse | MuseParse/classes/ObjectHierarchy/TreeClasses/MeasureNode.py | https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/ObjectHierarchy/TreeClasses/MeasureNode.py#L165-L178 | def GetLastKey(self, voice=1):
"""key as in musical key, not index"""
voice_obj = self.GetChild(voice)
if voice_obj is not None:
key = BackwardSearch(KeyNode, voice_obj, 1)
if key is not None:
return key
else:
if hasattr(self, ... | [
"def",
"GetLastKey",
"(",
"self",
",",
"voice",
"=",
"1",
")",
":",
"voice_obj",
"=",
"self",
".",
"GetChild",
"(",
"voice",
")",
"if",
"voice_obj",
"is",
"not",
"None",
":",
"key",
"=",
"BackwardSearch",
"(",
"KeyNode",
",",
"voice_obj",
",",
"1",
"... | key as in musical key, not index | [
"key",
"as",
"in",
"musical",
"key",
"not",
"index"
] | python | train | 30.928571 |
sashahart/vex | vex/main.py | https://github.com/sashahart/vex/blob/b7680c40897b8cbe6aae55ec9812b4fb11738192/vex/main.py#L53-L88 | def get_virtualenv_path(ve_base, ve_name):
"""Check a virtualenv path, raising exceptions to explain problems.
"""
if not ve_base:
raise exceptions.NoVirtualenvsDirectory(
"could not figure out a virtualenvs directory. "
"make sure $HOME is set, or $WORKON_HOME,"
... | [
"def",
"get_virtualenv_path",
"(",
"ve_base",
",",
"ve_name",
")",
":",
"if",
"not",
"ve_base",
":",
"raise",
"exceptions",
".",
"NoVirtualenvsDirectory",
"(",
"\"could not figure out a virtualenvs directory. \"",
"\"make sure $HOME is set, or $WORKON_HOME,\"",
"\" or set virtu... | Check a virtualenv path, raising exceptions to explain problems. | [
"Check",
"a",
"virtualenv",
"path",
"raising",
"exceptions",
"to",
"explain",
"problems",
"."
] | python | train | 42.333333 |
spacetelescope/pysynphot | pysynphot/obsbandpass.py | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/obsbandpass.py#L419-L595 | def wave_range(bins, cenwave, npix, round='round'):
"""Get the wavelength range covered by the given number of pixels
centered on the given wavelength.
Parameters
----------
bins : ndarray
Wavelengths of pixel centers. Must be in the same units as
``cenwave``.
cenwave : float
... | [
"def",
"wave_range",
"(",
"bins",
",",
"cenwave",
",",
"npix",
",",
"round",
"=",
"'round'",
")",
":",
"# make sure that the round keyword is valid",
"if",
"round",
"not",
"in",
"(",
"None",
",",
"'round'",
",",
"'min'",
",",
"'max'",
")",
":",
"raise",
"V... | Get the wavelength range covered by the given number of pixels
centered on the given wavelength.
Parameters
----------
bins : ndarray
Wavelengths of pixel centers. Must be in the same units as
``cenwave``.
cenwave : float
Central wavelength of range. Must be in the same uni... | [
"Get",
"the",
"wavelength",
"range",
"covered",
"by",
"the",
"given",
"number",
"of",
"pixels",
"centered",
"on",
"the",
"given",
"wavelength",
"."
] | python | train | 37.276836 |
user-cont/conu | conu/backend/docker/image.py | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/image.py#L681-L711 | def build(cls, path, tag=None, dockerfile=None):
"""
Build the image from the provided dockerfile in path
:param path : str, path to the directory containing the Dockerfile
:param tag: str, A tag to add to the final image
:param dockerfile: str, path within the build context to ... | [
"def",
"build",
"(",
"cls",
",",
"path",
",",
"tag",
"=",
"None",
",",
"dockerfile",
"=",
"None",
")",
":",
"if",
"not",
"path",
":",
"raise",
"ConuException",
"(",
"'Please specify path to the directory containing the Dockerfile'",
")",
"client",
"=",
"get_clie... | Build the image from the provided dockerfile in path
:param path : str, path to the directory containing the Dockerfile
:param tag: str, A tag to add to the final image
:param dockerfile: str, path within the build context to the Dockerfile
:return: instance of DockerImage | [
"Build",
"the",
"image",
"from",
"the",
"provided",
"dockerfile",
"in",
"path"
] | python | train | 46.451613 |
tmr232/Sark | sark/code/instruction.py | https://github.com/tmr232/Sark/blob/bee62879c2aea553a3924d887e2b30f2a6008581/sark/code/instruction.py#L138-L140 | def name(self):
"""Name of the xref type."""
return self.TYPES.get(self._type, self.TYPES[idaapi.o_idpspec0]) | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"TYPES",
".",
"get",
"(",
"self",
".",
"_type",
",",
"self",
".",
"TYPES",
"[",
"idaapi",
".",
"o_idpspec0",
"]",
")"
] | Name of the xref type. | [
"Name",
"of",
"the",
"xref",
"type",
"."
] | python | train | 41 |
inveniosoftware/invenio-oauth2server | invenio_oauth2server/cli.py | https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/cli.py#L63-L68 | def tokens_create(name, user, scopes, internal):
"""Create a personal OAuth token."""
token = Token.create_personal(
name, user.id, scopes=scopes, is_internal=internal)
db.session.commit()
click.secho(token.access_token, fg='blue') | [
"def",
"tokens_create",
"(",
"name",
",",
"user",
",",
"scopes",
",",
"internal",
")",
":",
"token",
"=",
"Token",
".",
"create_personal",
"(",
"name",
",",
"user",
".",
"id",
",",
"scopes",
"=",
"scopes",
",",
"is_internal",
"=",
"internal",
")",
"db"... | Create a personal OAuth token. | [
"Create",
"a",
"personal",
"OAuth",
"token",
"."
] | python | train | 41.666667 |
wndhydrnt/python-oauth2 | oauth2/store/memcache.py | https://github.com/wndhydrnt/python-oauth2/blob/abe3bf5f27bda2ff737cab387b040e2e6e85c2e2/oauth2/store/memcache.py#L78-L96 | def save_token(self, access_token):
"""
Stores the access token and additional data in memcache.
See :class:`oauth2.store.AccessTokenStore`.
"""
key = self._generate_cache_key(access_token.token)
self.mc.set(key, access_token.__dict__)
unique_token_key = self._... | [
"def",
"save_token",
"(",
"self",
",",
"access_token",
")",
":",
"key",
"=",
"self",
".",
"_generate_cache_key",
"(",
"access_token",
".",
"token",
")",
"self",
".",
"mc",
".",
"set",
"(",
"key",
",",
"access_token",
".",
"__dict__",
")",
"unique_token_key... | Stores the access token and additional data in memcache.
See :class:`oauth2.store.AccessTokenStore`. | [
"Stores",
"the",
"access",
"token",
"and",
"additional",
"data",
"in",
"memcache",
"."
] | python | train | 41 |
wmayner/pyphi | pyphi/convert.py | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/convert.py#L270-L345 | def state_by_node2state_by_state(tpm):
"""Convert a state-by-node TPM to a state-by-state TPM.
.. important::
A nondeterministic state-by-node TPM can have more than one
representation as a state-by-state TPM. However, the mapping can be
made to be one-to-one if we assume the TPMs to be... | [
"def",
"state_by_node2state_by_state",
"(",
"tpm",
")",
":",
"# Cast to np.array.",
"tpm",
"=",
"np",
".",
"array",
"(",
"tpm",
")",
"# Convert to multidimensional form.",
"tpm",
"=",
"to_multidimensional",
"(",
"tpm",
")",
"# Get the number of nodes from the last dimensi... | Convert a state-by-node TPM to a state-by-state TPM.
.. important::
A nondeterministic state-by-node TPM can have more than one
representation as a state-by-state TPM. However, the mapping can be
made to be one-to-one if we assume the TPMs to be conditionally
independent. Therefore,... | [
"Convert",
"a",
"state",
"-",
"by",
"-",
"node",
"TPM",
"to",
"a",
"state",
"-",
"by",
"-",
"state",
"TPM",
"."
] | python | train | 43.092105 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.