repo stringlengths 7 54 | path stringlengths 4 192 | url stringlengths 87 284 | code stringlengths 78 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|
hearsaycorp/normalize | normalize/diff.py | https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/diff.py#L290-L302 | def normalize_object_slot(self, value=_nothing, prop=None, obj=None):
"""This hook wraps ``normalize_slot``, and performs clean-ups which
require access to the object the slot is in as well as the value.
"""
if value is not _nothing and hasattr(prop, "compare_as"):
method, na... | [
"def",
"normalize_object_slot",
"(",
"self",
",",
"value",
"=",
"_nothing",
",",
"prop",
"=",
"None",
",",
"obj",
"=",
"None",
")",
":",
"if",
"value",
"is",
"not",
"_nothing",
"and",
"hasattr",
"(",
"prop",
",",
"\"compare_as\"",
")",
":",
"method",
"... | This hook wraps ``normalize_slot``, and performs clean-ups which
require access to the object the slot is in as well as the value. | [
"This",
"hook",
"wraps",
"normalize_slot",
"and",
"performs",
"clean",
"-",
"ups",
"which",
"require",
"access",
"to",
"the",
"object",
"the",
"slot",
"is",
"in",
"as",
"well",
"as",
"the",
"value",
"."
] | python | train |
Microsoft/azure-devops-python-api | azure-devops/azure/devops/v5_0/service_endpoint/service_endpoint_client.py | https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/service_endpoint/service_endpoint_client.py#L176-L200 | def update_service_endpoint(self, endpoint, project, endpoint_id, operation=None):
"""UpdateServiceEndpoint.
[Preview API] Update a service endpoint.
:param :class:`<ServiceEndpoint> <azure.devops.v5_0.service_endpoint.models.ServiceEndpoint>` endpoint: Service endpoint to update.
:param... | [
"def",
"update_service_endpoint",
"(",
"self",
",",
"endpoint",
",",
"project",
",",
"endpoint_id",
",",
"operation",
"=",
"None",
")",
":",
"route_values",
"=",
"{",
"}",
"if",
"project",
"is",
"not",
"None",
":",
"route_values",
"[",
"'project'",
"]",
"=... | UpdateServiceEndpoint.
[Preview API] Update a service endpoint.
:param :class:`<ServiceEndpoint> <azure.devops.v5_0.service_endpoint.models.ServiceEndpoint>` endpoint: Service endpoint to update.
:param str project: Project ID or project name
:param str endpoint_id: Id of the service end... | [
"UpdateServiceEndpoint",
".",
"[",
"Preview",
"API",
"]",
"Update",
"a",
"service",
"endpoint",
".",
":",
"param",
":",
"class",
":",
"<ServiceEndpoint",
">",
"<azure",
".",
"devops",
".",
"v5_0",
".",
"service_endpoint",
".",
"models",
".",
"ServiceEndpoint",... | python | train |
bspaans/python-mingus | mingus/extra/tablature.py | https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/tablature.py#L28-L41 | def begin_track(tuning, padding=2):
"""Helper function that builds the first few characters of every bar."""
# find longest shorthand tuning base
names = [x.to_shorthand() for x in tuning.tuning]
basesize = len(max(names)) + 3
# Build result
res = []
for x in names:
r = ' %s' % x
... | [
"def",
"begin_track",
"(",
"tuning",
",",
"padding",
"=",
"2",
")",
":",
"# find longest shorthand tuning base",
"names",
"=",
"[",
"x",
".",
"to_shorthand",
"(",
")",
"for",
"x",
"in",
"tuning",
".",
"tuning",
"]",
"basesize",
"=",
"len",
"(",
"max",
"(... | Helper function that builds the first few characters of every bar. | [
"Helper",
"function",
"that",
"builds",
"the",
"first",
"few",
"characters",
"of",
"every",
"bar",
"."
] | python | train |
globality-corp/flake8-logging-format | logging_format/visitor.py | https://github.com/globality-corp/flake8-logging-format/blob/3c6ce53d0ff1ec369799cff0ed6d048343252e40/logging_format/visitor.py#L228-L239 | def get_except_handler_name(self, node):
"""
Helper to get the exception name from an ExceptHandler node in both py2 and py3.
"""
name = node.name
if not name:
return None
if version_info < (3,):
return name.id
return name | [
"def",
"get_except_handler_name",
"(",
"self",
",",
"node",
")",
":",
"name",
"=",
"node",
".",
"name",
"if",
"not",
"name",
":",
"return",
"None",
"if",
"version_info",
"<",
"(",
"3",
",",
")",
":",
"return",
"name",
".",
"id",
"return",
"name"
] | Helper to get the exception name from an ExceptHandler node in both py2 and py3. | [
"Helper",
"to",
"get",
"the",
"exception",
"name",
"from",
"an",
"ExceptHandler",
"node",
"in",
"both",
"py2",
"and",
"py3",
"."
] | python | test |
mozilla/FoxPuppet | foxpuppet/windows/browser/notifications/base.py | https://github.com/mozilla/FoxPuppet/blob/6575eb4c72fd024c986b254e198c8b4e6f68cddd/foxpuppet/windows/browser/notifications/base.py#L95-L99 | def close(self):
"""Close the notification."""
with self.selenium.context(self.selenium.CONTEXT_CHROME):
self.find_close_button().click()
self.window.wait_for_notification(None) | [
"def",
"close",
"(",
"self",
")",
":",
"with",
"self",
".",
"selenium",
".",
"context",
"(",
"self",
".",
"selenium",
".",
"CONTEXT_CHROME",
")",
":",
"self",
".",
"find_close_button",
"(",
")",
".",
"click",
"(",
")",
"self",
".",
"window",
".",
"wa... | Close the notification. | [
"Close",
"the",
"notification",
"."
] | python | train |
chaoss/grimoirelab-toolkit | grimoirelab_toolkit/datetime.py | https://github.com/chaoss/grimoirelab-toolkit/blob/30f36e89f3070f1a7b9973ea3c8a31f4b792ee2b/grimoirelab_toolkit/datetime.py#L65-L94 | def datetime_to_utc(ts):
"""Convert a timestamp to UTC+0 timezone.
Returns the given datetime object converted to a date with
UTC+0 timezone. For naive datetimes, it will be assumed that
they are in UTC+0. When the timezone is wrong, UTC+0 will
be set as default (using `dateutil.tz.tzutc` object).
... | [
"def",
"datetime_to_utc",
"(",
"ts",
")",
":",
"if",
"not",
"isinstance",
"(",
"ts",
",",
"datetime",
".",
"datetime",
")",
":",
"msg",
"=",
"'<%s> object'",
"%",
"type",
"(",
"ts",
")",
"raise",
"InvalidDateError",
"(",
"date",
"=",
"msg",
")",
"if",
... | Convert a timestamp to UTC+0 timezone.
Returns the given datetime object converted to a date with
UTC+0 timezone. For naive datetimes, it will be assumed that
they are in UTC+0. When the timezone is wrong, UTC+0 will
be set as default (using `dateutil.tz.tzutc` object).
:param dt: timestamp to con... | [
"Convert",
"a",
"timestamp",
"to",
"UTC",
"+",
"0",
"timezone",
"."
] | python | train |
alberanid/python-iplib | iplib.py | https://github.com/alberanid/python-iplib/blob/488b56fe57ad836b27feec9e76f51883db28faa6/iplib.py#L495-L518 | def convert(ip, notation=IP_DOT, inotation=IP_UNKNOWN, check=True):
"""Convert among IP address notations.
Given an IP address, this function returns the address
in another notation.
@param ip: the IP address.
@type ip: integers, strings or object with an appropriate __str()__ method.
@param ... | [
"def",
"convert",
"(",
"ip",
",",
"notation",
"=",
"IP_DOT",
",",
"inotation",
"=",
"IP_UNKNOWN",
",",
"check",
"=",
"True",
")",
":",
"return",
"_convert",
"(",
"ip",
",",
"notation",
",",
"inotation",
",",
"_check",
"=",
"check",
",",
"_isnm",
"=",
... | Convert among IP address notations.
Given an IP address, this function returns the address
in another notation.
@param ip: the IP address.
@type ip: integers, strings or object with an appropriate __str()__ method.
@param notation: the notation of the output (default: IP_DOT).
@type notation:... | [
"Convert",
"among",
"IP",
"address",
"notations",
"."
] | python | valid |
ten10solutions/Geist | geist/vision.py | https://github.com/ten10solutions/Geist/blob/a1ef16d8b4c3777735008b671a50acfde3ce7bf1/geist/vision.py#L138-L201 | def overlapped_convolution(bin_template, bin_image,
tollerance=0.5, splits=(4, 2)):
"""
As each of these images are hold only binary values, and RFFT2 works on
float64 greyscale values, we can make the convolution more efficient by
breaking the image up into :splits: sect... | [
"def",
"overlapped_convolution",
"(",
"bin_template",
",",
"bin_image",
",",
"tollerance",
"=",
"0.5",
",",
"splits",
"=",
"(",
"4",
",",
"2",
")",
")",
":",
"th",
",",
"tw",
"=",
"bin_template",
".",
"shape",
"ih",
",",
"iw",
"=",
"bin_image",
".",
... | As each of these images are hold only binary values, and RFFT2 works on
float64 greyscale values, we can make the convolution more efficient by
breaking the image up into :splits: sectons. Each one of these sections
then has its greyscale value adjusted and then stacked.
We then apply the convolut... | [
"As",
"each",
"of",
"these",
"images",
"are",
"hold",
"only",
"binary",
"values",
"and",
"RFFT2",
"works",
"on",
"float64",
"greyscale",
"values",
"we",
"can",
"make",
"the",
"convolution",
"more",
"efficient",
"by",
"breaking",
"the",
"image",
"up",
"into",... | python | train |
saltstack/salt | salt/runners/manage.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/manage.py#L471-L494 | def not_alived(subset=None, show_ip=False, show_ipv4=None):
'''
.. versionadded:: 2015.8.0
.. versionchanged:: 2019.2.0
The 'show_ipv4' argument has been renamed to 'show_ip' as it now
includes IPv6 addresses for IPv6-connected minions.
Print a list of all minions that are NOT up accord... | [
"def",
"not_alived",
"(",
"subset",
"=",
"None",
",",
"show_ip",
"=",
"False",
",",
"show_ipv4",
"=",
"None",
")",
":",
"show_ip",
"=",
"_show_ip_migration",
"(",
"show_ip",
",",
"show_ipv4",
")",
"return",
"list_not_state",
"(",
"subset",
"=",
"subset",
"... | .. versionadded:: 2015.8.0
.. versionchanged:: 2019.2.0
The 'show_ipv4' argument has been renamed to 'show_ip' as it now
includes IPv6 addresses for IPv6-connected minions.
Print a list of all minions that are NOT up according to Salt's presence
detection (no commands will be sent)
sub... | [
"..",
"versionadded",
"::",
"2015",
".",
"8",
".",
"0",
"..",
"versionchanged",
"::",
"2019",
".",
"2",
".",
"0",
"The",
"show_ipv4",
"argument",
"has",
"been",
"renamed",
"to",
"show_ip",
"as",
"it",
"now",
"includes",
"IPv6",
"addresses",
"for",
"IPv6"... | python | train |
ray-project/ray | python/ray/tune/registry.py | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/registry.py#L24-L50 | def register_trainable(name, trainable):
"""Register a trainable function or class.
Args:
name (str): Name to register.
trainable (obj): Function or tune.Trainable class. Functions must
take (config, status_reporter) as arguments and will be
automatically converted into ... | [
"def",
"register_trainable",
"(",
"name",
",",
"trainable",
")",
":",
"from",
"ray",
".",
"tune",
".",
"trainable",
"import",
"Trainable",
"from",
"ray",
".",
"tune",
".",
"function_runner",
"import",
"wrap_function",
"if",
"isinstance",
"(",
"trainable",
",",... | Register a trainable function or class.
Args:
name (str): Name to register.
trainable (obj): Function or tune.Trainable class. Functions must
take (config, status_reporter) as arguments and will be
automatically converted into a class during registration. | [
"Register",
"a",
"trainable",
"function",
"or",
"class",
"."
] | python | train |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L10175-L10190 | def format_size(size, threshold=1536):
"""Return file size as string from byte size.
>>> format_size(1234)
'1234 B'
>>> format_size(12345678901)
'11.50 GiB'
"""
if size < threshold:
return "%i B" % size
for unit in ('KiB', 'MiB', 'GiB', 'TiB', 'PiB'):
size /= 1024.0
... | [
"def",
"format_size",
"(",
"size",
",",
"threshold",
"=",
"1536",
")",
":",
"if",
"size",
"<",
"threshold",
":",
"return",
"\"%i B\"",
"%",
"size",
"for",
"unit",
"in",
"(",
"'KiB'",
",",
"'MiB'",
",",
"'GiB'",
",",
"'TiB'",
",",
"'PiB'",
")",
":",
... | Return file size as string from byte size.
>>> format_size(1234)
'1234 B'
>>> format_size(12345678901)
'11.50 GiB' | [
"Return",
"file",
"size",
"as",
"string",
"from",
"byte",
"size",
"."
] | python | train |
StellarCN/py-stellar-base | stellar_base/base58.py | https://github.com/StellarCN/py-stellar-base/blob/cce2e782064fb3955c85e1696e630d67b1010848/stellar_base/base58.py#L73-L77 | def b58encode_check(v):
"""Encode a string using Base58 with a 4 character checksum"""
digest = sha256(sha256(v).digest()).digest()
return b58encode(v + digest[:4]) | [
"def",
"b58encode_check",
"(",
"v",
")",
":",
"digest",
"=",
"sha256",
"(",
"sha256",
"(",
"v",
")",
".",
"digest",
"(",
")",
")",
".",
"digest",
"(",
")",
"return",
"b58encode",
"(",
"v",
"+",
"digest",
"[",
":",
"4",
"]",
")"
] | Encode a string using Base58 with a 4 character checksum | [
"Encode",
"a",
"string",
"using",
"Base58",
"with",
"a",
"4",
"character",
"checksum"
] | python | train |
scanny/python-pptx | pptx/oxml/chart/shared.py | https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/oxml/chart/shared.py#L121-L126 | def horz_offset(self, offset):
"""
Set the value of ./c:x@val to *offset* and ./c:xMode@val to "factor".
"""
self.get_or_add_xMode().val = ST_LayoutMode.FACTOR
self.get_or_add_x().val = offset | [
"def",
"horz_offset",
"(",
"self",
",",
"offset",
")",
":",
"self",
".",
"get_or_add_xMode",
"(",
")",
".",
"val",
"=",
"ST_LayoutMode",
".",
"FACTOR",
"self",
".",
"get_or_add_x",
"(",
")",
".",
"val",
"=",
"offset"
] | Set the value of ./c:x@val to *offset* and ./c:xMode@val to "factor". | [
"Set",
"the",
"value",
"of",
".",
"/",
"c",
":",
"x"
] | python | train |
CEA-COSMIC/ModOpt | modopt/opt/algorithms.py | https://github.com/CEA-COSMIC/ModOpt/blob/019b189cb897cbb4d210c44a100daaa08468830c/modopt/opt/algorithms.py#L409-L429 | def update_beta(self, beta):
r"""Update beta
This method updates beta only in the case of safeguarding (should only
be done in the greedy restarting strategy).
Parameters
----------
beta: float
The beta parameter
Returns
-------
floa... | [
"def",
"update_beta",
"(",
"self",
",",
"beta",
")",
":",
"if",
"self",
".",
"_safeguard",
":",
"beta",
"*=",
"self",
".",
"xi_restart",
"beta",
"=",
"max",
"(",
"beta",
",",
"self",
".",
"min_beta",
")",
"return",
"beta"
] | r"""Update beta
This method updates beta only in the case of safeguarding (should only
be done in the greedy restarting strategy).
Parameters
----------
beta: float
The beta parameter
Returns
-------
float: the new value for the beta paramet... | [
"r",
"Update",
"beta"
] | python | train |
skulumani/kinematics | kinematics/attitude.py | https://github.com/skulumani/kinematics/blob/e8cb45efb40539982025ed0f85d6561f9f10fef0/kinematics/attitude.py#L273-L295 | def dcmtoquat(dcm):
"""Convert DCM to quaternion
This function will convert a rotation matrix, also called a direction
cosine matrix into the equivalent quaternion.
Parameters:
----------
dcm - (3,3) numpy array
Numpy rotation matrix which defines a rotation from the b to a frame
... | [
"def",
"dcmtoquat",
"(",
"dcm",
")",
":",
"quat",
"=",
"np",
".",
"zeros",
"(",
"4",
")",
"quat",
"[",
"-",
"1",
"]",
"=",
"1",
"/",
"2",
"*",
"np",
".",
"sqrt",
"(",
"np",
".",
"trace",
"(",
"dcm",
")",
"+",
"1",
")",
"quat",
"[",
"0",
... | Convert DCM to quaternion
This function will convert a rotation matrix, also called a direction
cosine matrix into the equivalent quaternion.
Parameters:
----------
dcm - (3,3) numpy array
Numpy rotation matrix which defines a rotation from the b to a frame
Returns:
--------
... | [
"Convert",
"DCM",
"to",
"quaternion",
"This",
"function",
"will",
"convert",
"a",
"rotation",
"matrix",
"also",
"called",
"a",
"direction",
"cosine",
"matrix",
"into",
"the",
"equivalent",
"quaternion",
"."
] | python | train |
ehansis/ozelot | ozelot/cache.py | https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/ozelot/cache.py#L204-L222 | def clear(self, url=None, xpath=None):
"""Clear cache
Args:
url (str): If given, clear specific item only. Otherwise remove the DB file.
xpath (str): xpath to search (may be ``None``)
"""
if url is not None:
query = self._query(url, xpath)
... | [
"def",
"clear",
"(",
"self",
",",
"url",
"=",
"None",
",",
"xpath",
"=",
"None",
")",
":",
"if",
"url",
"is",
"not",
"None",
":",
"query",
"=",
"self",
".",
"_query",
"(",
"url",
",",
"xpath",
")",
"if",
"query",
".",
"count",
"(",
")",
">",
... | Clear cache
Args:
url (str): If given, clear specific item only. Otherwise remove the DB file.
xpath (str): xpath to search (may be ``None``) | [
"Clear",
"cache"
] | python | train |
bslatkin/dpxdt | dpxdt/server/work_queue.py | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/work_queue.py#L345-L377 | def _query(queue_name=None, build_id=None, release_id=None, run_id=None,
count=None):
"""Queries for work items based on their criteria.
Args:
queue_name: Optional queue name to restrict to.
build_id: Optional build ID to restrict to.
release_id: Optional release ID to restri... | [
"def",
"_query",
"(",
"queue_name",
"=",
"None",
",",
"build_id",
"=",
"None",
",",
"release_id",
"=",
"None",
",",
"run_id",
"=",
"None",
",",
"count",
"=",
"None",
")",
":",
"assert",
"queue_name",
"or",
"build_id",
"or",
"release_id",
"or",
"run_id",
... | Queries for work items based on their criteria.
Args:
queue_name: Optional queue name to restrict to.
build_id: Optional build ID to restrict to.
release_id: Optional release ID to restrict to.
run_id: Optional run ID to restrict to.
count: How many tasks to fetch. Defaults ... | [
"Queries",
"for",
"work",
"items",
"based",
"on",
"their",
"criteria",
"."
] | python | train |
elliterate/capybara.py | capybara/session_matchers.py | https://github.com/elliterate/capybara.py/blob/0c6ae449cc37e4445ec3cd6af95674533beedc6c/capybara/session_matchers.py#L58-L73 | def has_current_path(self, path, **kwargs):
"""
Checks if the page has the given path.
Args:
path (str | RegexObject): The string or regex that the current "path" should match.
**kwargs: Arbitrary keyword arguments for :class:`CurrentPathQuery`.
Returns:
... | [
"def",
"has_current_path",
"(",
"self",
",",
"path",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"self",
".",
"assert_current_path",
"(",
"path",
",",
"*",
"*",
"kwargs",
")",
"except",
"ExpectationNotMet",
":",
"return",
"False"
] | Checks if the page has the given path.
Args:
path (str | RegexObject): The string or regex that the current "path" should match.
**kwargs: Arbitrary keyword arguments for :class:`CurrentPathQuery`.
Returns:
bool: Whether it matches. | [
"Checks",
"if",
"the",
"page",
"has",
"the",
"given",
"path",
"."
] | python | test |
jesford/cluster-lensing | clusterlensing/clusters.py | https://github.com/jesford/cluster-lensing/blob/2815c1bb07d904ca91a80dae3f52090016768072/clusterlensing/clusters.py#L32-L47 | def calc_delta_c(c200):
"""Calculate characteristic overdensity from concentration.
Parameters
----------
c200 : ndarray or float
Cluster concentration parameter.
Returns
----------
ndarray or float
Cluster characteristic overdensity, of same type as c200.
"""
top =... | [
"def",
"calc_delta_c",
"(",
"c200",
")",
":",
"top",
"=",
"(",
"200.",
"/",
"3.",
")",
"*",
"c200",
"**",
"3.",
"bottom",
"=",
"np",
".",
"log",
"(",
"1.",
"+",
"c200",
")",
"-",
"(",
"c200",
"/",
"(",
"1.",
"+",
"c200",
")",
")",
"return",
... | Calculate characteristic overdensity from concentration.
Parameters
----------
c200 : ndarray or float
Cluster concentration parameter.
Returns
----------
ndarray or float
Cluster characteristic overdensity, of same type as c200. | [
"Calculate",
"characteristic",
"overdensity",
"from",
"concentration",
"."
] | python | train |
hellosign/hellosign-python-sdk | hellosign_sdk/hsclient.py | https://github.com/hellosign/hellosign-python-sdk/blob/4325a29ad5766380a214eac3914511f62f7ecba4/hellosign_sdk/hsclient.py#L705-L717 | def get_template(self, template_id):
''' Gets a Template which includes a list of Accounts that can access it
Args:
template_id (str): The id of the template to retrieve
Returns:
A Template object
'''
request = self._get_request()
return reques... | [
"def",
"get_template",
"(",
"self",
",",
"template_id",
")",
":",
"request",
"=",
"self",
".",
"_get_request",
"(",
")",
"return",
"request",
".",
"get",
"(",
"self",
".",
"TEMPLATE_GET_URL",
"+",
"template_id",
")"
] | Gets a Template which includes a list of Accounts that can access it
Args:
template_id (str): The id of the template to retrieve
Returns:
A Template object | [
"Gets",
"a",
"Template",
"which",
"includes",
"a",
"list",
"of",
"Accounts",
"that",
"can",
"access",
"it"
] | python | train |
genialis/django-rest-framework-reactive | src/rest_framework_reactive/views.py | https://github.com/genialis/django-rest-framework-reactive/blob/ddf3d899685a54b6bd0ae4b3789649a89340c59f/src/rest_framework_reactive/views.py#L7-L16 | def post(self, request):
"""Handle a query observer unsubscription request."""
try:
observer_id = request.query_params['observer']
session_id = request.query_params['subscriber']
except KeyError:
return response.Response(status=400)
observer.remove_su... | [
"def",
"post",
"(",
"self",
",",
"request",
")",
":",
"try",
":",
"observer_id",
"=",
"request",
".",
"query_params",
"[",
"'observer'",
"]",
"session_id",
"=",
"request",
".",
"query_params",
"[",
"'subscriber'",
"]",
"except",
"KeyError",
":",
"return",
... | Handle a query observer unsubscription request. | [
"Handle",
"a",
"query",
"observer",
"unsubscription",
"request",
"."
] | python | train |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L4878-L4893 | def keyframe(self, keyframe):
"""Set keyframe."""
if self._keyframe == keyframe:
return
if self._keyframe is not None:
raise RuntimeError('cannot reset keyframe')
if len(self._offsetscounts[0]) != len(keyframe.dataoffsets):
raise RuntimeError('incompat... | [
"def",
"keyframe",
"(",
"self",
",",
"keyframe",
")",
":",
"if",
"self",
".",
"_keyframe",
"==",
"keyframe",
":",
"return",
"if",
"self",
".",
"_keyframe",
"is",
"not",
"None",
":",
"raise",
"RuntimeError",
"(",
"'cannot reset keyframe'",
")",
"if",
"len",... | Set keyframe. | [
"Set",
"keyframe",
"."
] | python | train |
zestyping/star-destroyer | star_destroyer.py | https://github.com/zestyping/star-destroyer/blob/e23584c85d1e8b8f098e5c75977c6a98a41f3f68/star_destroyer.py#L70-L80 | def find_module(modpath):
"""Determines whether a module exists with the given modpath."""
module_path = modpath.replace('.', '/') + '.py'
init_path = modpath.replace('.', '/') + '/__init__.py'
for root_path in sys.path:
path = os.path.join(root_path, module_path)
if os.path.isfile(path)... | [
"def",
"find_module",
"(",
"modpath",
")",
":",
"module_path",
"=",
"modpath",
".",
"replace",
"(",
"'.'",
",",
"'/'",
")",
"+",
"'.py'",
"init_path",
"=",
"modpath",
".",
"replace",
"(",
"'.'",
",",
"'/'",
")",
"+",
"'/__init__.py'",
"for",
"root_path",... | Determines whether a module exists with the given modpath. | [
"Determines",
"whether",
"a",
"module",
"exists",
"with",
"the",
"given",
"modpath",
"."
] | python | train |
quantmind/pulsar | pulsar/apps/data/channels.py | https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/apps/data/channels.py#L135-L150 | async def register(self, channel, event, callback):
"""Register a callback to ``channel_name`` and ``event``.
A prefix will be added to the channel name if not already available or
the prefix is an empty string
:param channel: channel name
:param event: event name
:para... | [
"async",
"def",
"register",
"(",
"self",
",",
"channel",
",",
"event",
",",
"callback",
")",
":",
"channel",
"=",
"self",
".",
"channel",
"(",
"channel",
")",
"event",
"=",
"channel",
".",
"register",
"(",
"event",
",",
"callback",
")",
"await",
"chann... | Register a callback to ``channel_name`` and ``event``.
A prefix will be added to the channel name if not already available or
the prefix is an empty string
:param channel: channel name
:param event: event name
:param callback: callback to execute when event on channel occurs
... | [
"Register",
"a",
"callback",
"to",
"channel_name",
"and",
"event",
"."
] | python | train |
amorison/loam | loam/manager.py | https://github.com/amorison/loam/blob/a566c943a75e068a4510099331a1ddfe5bbbdd94/loam/manager.py#L187-L200 | def from_dict_(cls, conf_dict):
"""Use a dictionary to create a :class:`ConfigurationManager`.
Args:
conf_dict (dict of dict of :class:`ConfOpt`): the first level of
keys should be the section names. The second level should be
the option names. The values are... | [
"def",
"from_dict_",
"(",
"cls",
",",
"conf_dict",
")",
":",
"return",
"cls",
"(",
"*",
"*",
"{",
"name",
":",
"Section",
"(",
"*",
"*",
"opts",
")",
"for",
"name",
",",
"opts",
"in",
"conf_dict",
".",
"items",
"(",
")",
"}",
")"
] | Use a dictionary to create a :class:`ConfigurationManager`.
Args:
conf_dict (dict of dict of :class:`ConfOpt`): the first level of
keys should be the section names. The second level should be
the option names. The values are the options metadata.
Returns:
... | [
"Use",
"a",
"dictionary",
"to",
"create",
"a",
":",
"class",
":",
"ConfigurationManager",
"."
] | python | test |
Jajcus/pyxmpp2 | pyxmpp2/ext/legacyauth.py | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/ext/legacyauth.py#L399-L417 | def registration_form_received(self, stanza):
"""Handle registration form received.
[client only]
Call self.registration_callback with the registration form received
as the argument. Use the value returned by the callback will be a
filled-in form.
:Parameters:
... | [
"def",
"registration_form_received",
"(",
"self",
",",
"stanza",
")",
":",
"self",
".",
"lock",
".",
"acquire",
"(",
")",
"try",
":",
"self",
".",
"__register",
"=",
"Register",
"(",
"stanza",
".",
"get_query",
"(",
")",
")",
"self",
".",
"registration_c... | Handle registration form received.
[client only]
Call self.registration_callback with the registration form received
as the argument. Use the value returned by the callback will be a
filled-in form.
:Parameters:
- `stanza`: the stanza received.
:Types:
... | [
"Handle",
"registration",
"form",
"received",
"."
] | python | valid |
horazont/aioxmpp | aioxmpp/service.py | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/service.py#L1546-L1556 | def is_attrsignal_handler(descriptor, signal_name, cb, *, defer=False):
"""
Return true if `cb` has been decorated with :func:`attrsignal` for the
given signal, descriptor and connection mode.
"""
try:
handlers = get_magic_attr(cb)
except AttributeError:
return False
return ... | [
"def",
"is_attrsignal_handler",
"(",
"descriptor",
",",
"signal_name",
",",
"cb",
",",
"*",
",",
"defer",
"=",
"False",
")",
":",
"try",
":",
"handlers",
"=",
"get_magic_attr",
"(",
"cb",
")",
"except",
"AttributeError",
":",
"return",
"False",
"return",
"... | Return true if `cb` has been decorated with :func:`attrsignal` for the
given signal, descriptor and connection mode. | [
"Return",
"true",
"if",
"cb",
"has",
"been",
"decorated",
"with",
":",
"func",
":",
"attrsignal",
"for",
"the",
"given",
"signal",
"descriptor",
"and",
"connection",
"mode",
"."
] | python | train |
saltstack/salt | salt/modules/napalm_netacl.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/napalm_netacl.py#L858-L883 | def get_filter_pillar(filter_name,
pillar_key='acl',
pillarenv=None,
saltenv=None):
'''
Helper that can be used inside a state SLS,
in order to get the filter configuration given its name.
filter_name
The name of the filter.
... | [
"def",
"get_filter_pillar",
"(",
"filter_name",
",",
"pillar_key",
"=",
"'acl'",
",",
"pillarenv",
"=",
"None",
",",
"saltenv",
"=",
"None",
")",
":",
"return",
"__salt__",
"[",
"'capirca.get_filter_pillar'",
"]",
"(",
"filter_name",
",",
"pillar_key",
"=",
"p... | Helper that can be used inside a state SLS,
in order to get the filter configuration given its name.
filter_name
The name of the filter.
pillar_key
The root key of the whole policy config.
pillarenv
Query the master to generate fresh pillar data on the fly,
specificall... | [
"Helper",
"that",
"can",
"be",
"used",
"inside",
"a",
"state",
"SLS",
"in",
"order",
"to",
"get",
"the",
"filter",
"configuration",
"given",
"its",
"name",
"."
] | python | train |
ssalentin/plip | plip/modules/preparation.py | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/preparation.py#L208-L213 | def get_linkage(self, line):
"""Get the linkage information from a LINK entry PDB line."""
conf1, id1, chain1, pos1 = line[16].strip(), line[17:20].strip(), line[21].strip(), int(line[22:26])
conf2, id2, chain2, pos2 = line[46].strip(), line[47:50].strip(), line[51].strip(), int(line[52:56])
... | [
"def",
"get_linkage",
"(",
"self",
",",
"line",
")",
":",
"conf1",
",",
"id1",
",",
"chain1",
",",
"pos1",
"=",
"line",
"[",
"16",
"]",
".",
"strip",
"(",
")",
",",
"line",
"[",
"17",
":",
"20",
"]",
".",
"strip",
"(",
")",
",",
"line",
"[",
... | Get the linkage information from a LINK entry PDB line. | [
"Get",
"the",
"linkage",
"information",
"from",
"a",
"LINK",
"entry",
"PDB",
"line",
"."
] | python | train |
DataDog/integrations-core | tokumx/datadog_checks/tokumx/vendor/pymongo/helpers.py | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/helpers.py#L52-L65 | def _index_list(key_or_list, direction=None):
"""Helper to generate a list of (key, direction) pairs.
Takes such a list, or a single key, or a single key and direction.
"""
if direction is not None:
return [(key_or_list, direction)]
else:
if isinstance(key_or_list, string_type):
... | [
"def",
"_index_list",
"(",
"key_or_list",
",",
"direction",
"=",
"None",
")",
":",
"if",
"direction",
"is",
"not",
"None",
":",
"return",
"[",
"(",
"key_or_list",
",",
"direction",
")",
"]",
"else",
":",
"if",
"isinstance",
"(",
"key_or_list",
",",
"stri... | Helper to generate a list of (key, direction) pairs.
Takes such a list, or a single key, or a single key and direction. | [
"Helper",
"to",
"generate",
"a",
"list",
"of",
"(",
"key",
"direction",
")",
"pairs",
"."
] | python | train |
refindlyllc/rets | rets/session.py | https://github.com/refindlyllc/rets/blob/c615dfc272cff0825fd3b50863c46afc3e33916f/rets/session.py#L188-L195 | def get_lookup_values(self, resource, lookup_name):
"""
Get possible lookup values for a given field
:param resource: The name of the resource
:param lookup_name: The name of the the field to get lookup values for
:return: list
"""
return self._make_metadata_reque... | [
"def",
"get_lookup_values",
"(",
"self",
",",
"resource",
",",
"lookup_name",
")",
":",
"return",
"self",
".",
"_make_metadata_request",
"(",
"meta_id",
"=",
"resource",
"+",
"':'",
"+",
"lookup_name",
",",
"metadata_type",
"=",
"'METADATA-LOOKUP_TYPE'",
")"
] | Get possible lookup values for a given field
:param resource: The name of the resource
:param lookup_name: The name of the the field to get lookup values for
:return: list | [
"Get",
"possible",
"lookup",
"values",
"for",
"a",
"given",
"field",
":",
"param",
"resource",
":",
"The",
"name",
"of",
"the",
"resource",
":",
"param",
"lookup_name",
":",
"The",
"name",
"of",
"the",
"the",
"field",
"to",
"get",
"lookup",
"values",
"fo... | python | train |
srittau/python-json-get | jsonget/__init__.py | https://github.com/srittau/python-json-get/blob/eb21fa7a4ed7fbd324de1cb3ad73876297e49bf8/jsonget/__init__.py#L282-L304 | def json_get_default(json: JsonValue, path: str,
default: Any, expected_type: Any = ANY) -> Any:
"""Get a JSON value by path, optionally checking its type.
This works exactly like json_get(), but instead of raising
ValueError or IndexError when a path part is not found, return
the ... | [
"def",
"json_get_default",
"(",
"json",
":",
"JsonValue",
",",
"path",
":",
"str",
",",
"default",
":",
"Any",
",",
"expected_type",
":",
"Any",
"=",
"ANY",
")",
"->",
"Any",
":",
"try",
":",
"return",
"json_get",
"(",
"json",
",",
"path",
",",
"expe... | Get a JSON value by path, optionally checking its type.
This works exactly like json_get(), but instead of raising
ValueError or IndexError when a path part is not found, return
the provided default value:
>>> json_get_default({}, "/foo", "I am a default value")
'I am a default value'
TypeErr... | [
"Get",
"a",
"JSON",
"value",
"by",
"path",
"optionally",
"checking",
"its",
"type",
"."
] | python | valid |
yyuu/botornado | boto/mturk/connection.py | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/mturk/connection.py#L712-L717 | def get_qualification_score(self, qualification_type_id, worker_id):
"""TODO: Document."""
params = {'QualificationTypeId' : qualification_type_id,
'SubjectId' : worker_id}
return self._process_request('GetQualificationScore', params,
[('Qualification', Qual... | [
"def",
"get_qualification_score",
"(",
"self",
",",
"qualification_type_id",
",",
"worker_id",
")",
":",
"params",
"=",
"{",
"'QualificationTypeId'",
":",
"qualification_type_id",
",",
"'SubjectId'",
":",
"worker_id",
"}",
"return",
"self",
".",
"_process_request",
... | TODO: Document. | [
"TODO",
":",
"Document",
"."
] | python | train |
saltstack/salt | salt/modules/azurearm_network.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/azurearm_network.py#L702-L736 | def subnet_get(name, virtual_network, resource_group, **kwargs):
'''
.. versionadded:: 2019.2.0
Get details about a specific subnet.
:param name: The name of the subnet to query.
:param virtual_network: The virtual network name containing the
subnet.
:param resource_group: The resour... | [
"def",
"subnet_get",
"(",
"name",
",",
"virtual_network",
",",
"resource_group",
",",
"*",
"*",
"kwargs",
")",
":",
"netconn",
"=",
"__utils__",
"[",
"'azurearm.get_client'",
"]",
"(",
"'network'",
",",
"*",
"*",
"kwargs",
")",
"try",
":",
"subnet",
"=",
... | .. versionadded:: 2019.2.0
Get details about a specific subnet.
:param name: The name of the subnet to query.
:param virtual_network: The virtual network name containing the
subnet.
:param resource_group: The resource group name assigned to the
virtual network.
CLI Example:
... | [
"..",
"versionadded",
"::",
"2019",
".",
"2",
".",
"0"
] | python | train |
ponty/psidialogs | psidialogs/__init__.py | https://github.com/ponty/psidialogs/blob/e385ab6b48cb43af52b810a1bf76a8135f4585b8/psidialogs/__init__.py#L48-L60 | def text(text, message='', title=''):
"""
This function is suitable for displaying general text, which can be longer
than in :func:`message`
:ref:`screenshots<text>`
:param text: (long) text to be displayed
:param message: (short) message to be displayed.
:param title: window title
:rt... | [
"def",
"text",
"(",
"text",
",",
"message",
"=",
"''",
",",
"title",
"=",
"''",
")",
":",
"return",
"backend_api",
".",
"opendialog",
"(",
"\"text\"",
",",
"dict",
"(",
"text",
"=",
"text",
",",
"message",
"=",
"message",
",",
"title",
"=",
"title",
... | This function is suitable for displaying general text, which can be longer
than in :func:`message`
:ref:`screenshots<text>`
:param text: (long) text to be displayed
:param message: (short) message to be displayed.
:param title: window title
:rtype: None | [
"This",
"function",
"is",
"suitable",
"for",
"displaying",
"general",
"text",
"which",
"can",
"be",
"longer",
"than",
"in",
":",
"func",
":",
"message"
] | python | train |
tensorlayer/tensorlayer | tensorlayer/files/utils.py | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/files/utils.py#L937-L974 | def download_file_from_google_drive(ID, destination):
"""Download file from Google Drive.
See ``tl.files.load_celebA_dataset`` for example.
Parameters
--------------
ID : str
The driver ID.
destination : str
The destination for save file.
"""
def save_response_content... | [
"def",
"download_file_from_google_drive",
"(",
"ID",
",",
"destination",
")",
":",
"def",
"save_response_content",
"(",
"response",
",",
"destination",
",",
"chunk_size",
"=",
"32",
"*",
"1024",
")",
":",
"total_size",
"=",
"int",
"(",
"response",
".",
"header... | Download file from Google Drive.
See ``tl.files.load_celebA_dataset`` for example.
Parameters
--------------
ID : str
The driver ID.
destination : str
The destination for save file. | [
"Download",
"file",
"from",
"Google",
"Drive",
"."
] | python | valid |
agschwender/pilbox | pilbox/image.py | https://github.com/agschwender/pilbox/blob/8b1d154436fd1b9f9740925549793561c58d4400/pilbox/image.py#L182-L206 | def resize(self, width, height, **kwargs):
"""Resizes the image to the supplied width/height. Returns the
instance. Supports the following optional keyword arguments:
mode - The resizing mode to use, see Image.MODES
filter - The filter to use: see Image.FILTERS
background - The ... | [
"def",
"resize",
"(",
"self",
",",
"width",
",",
"height",
",",
"*",
"*",
"kwargs",
")",
":",
"opts",
"=",
"Image",
".",
"_normalize_options",
"(",
"kwargs",
")",
"size",
"=",
"self",
".",
"_get_size",
"(",
"width",
",",
"height",
")",
"if",
"opts",
... | Resizes the image to the supplied width/height. Returns the
instance. Supports the following optional keyword arguments:
mode - The resizing mode to use, see Image.MODES
filter - The filter to use: see Image.FILTERS
background - The hexadecimal background fill color, RGB or ARGB
... | [
"Resizes",
"the",
"image",
"to",
"the",
"supplied",
"width",
"/",
"height",
".",
"Returns",
"the",
"instance",
".",
"Supports",
"the",
"following",
"optional",
"keyword",
"arguments",
":"
] | python | train |
softlayer/softlayer-python | SoftLayer/managers/ordering.py | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ordering.py#L40-L65 | def get_packages_of_type(self, package_types, mask=None):
"""Get packages that match a certain type.
Each ordering package has a type, so return all packages that match
the types we are looking for
:param list package_types: List of strings representing the package
... | [
"def",
"get_packages_of_type",
"(",
"self",
",",
"package_types",
",",
"mask",
"=",
"None",
")",
":",
"_filter",
"=",
"{",
"'type'",
":",
"{",
"'keyName'",
":",
"{",
"'operation'",
":",
"'in'",
",",
"'options'",
":",
"[",
"{",
"'name'",
":",
"'data'",
... | Get packages that match a certain type.
Each ordering package has a type, so return all packages that match
the types we are looking for
:param list package_types: List of strings representing the package
type keynames we are interested in.
:param str... | [
"Get",
"packages",
"that",
"match",
"a",
"certain",
"type",
"."
] | python | train |
googlefonts/fontbakery | Lib/fontbakery/checkrunner.py | https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/checkrunner.py#L1626-L1659 | def get_module_profile(module, name=None):
"""
Get or create a profile from a module and return it.
If the name `module.profile` is present the value of that is returned.
Otherwise, if the name `module.profile_factory` is present, a new profile
is created using `module.profile_factory` and then `profile.auto... | [
"def",
"get_module_profile",
"(",
"module",
",",
"name",
"=",
"None",
")",
":",
"try",
":",
"# if profile is defined we just use it",
"return",
"module",
".",
"profile",
"except",
"AttributeError",
":",
"# > 'module' object has no attribute 'profile'",
"# try to create one ... | Get or create a profile from a module and return it.
If the name `module.profile` is present the value of that is returned.
Otherwise, if the name `module.profile_factory` is present, a new profile
is created using `module.profile_factory` and then `profile.auto_register`
is called with the module namespace.
... | [
"Get",
"or",
"create",
"a",
"profile",
"from",
"a",
"module",
"and",
"return",
"it",
"."
] | python | train |
crdoconnor/strictyaml | hitch/key.py | https://github.com/crdoconnor/strictyaml/blob/efdac7f89e81679fc95686288cd32b9563fde609/hitch/key.py#L85-L97 | def regressfile(filename):
"""
Run all stories in filename 'filename' in python 2 and 3.
"""
_storybook({"rewrite": False}).in_filename(filename).with_params(
**{"python version": "2.7.14"}
).filter(
lambda story: not story.info.get("fails_on_python_2")
).ordered_by_name().play()... | [
"def",
"regressfile",
"(",
"filename",
")",
":",
"_storybook",
"(",
"{",
"\"rewrite\"",
":",
"False",
"}",
")",
".",
"in_filename",
"(",
"filename",
")",
".",
"with_params",
"(",
"*",
"*",
"{",
"\"python version\"",
":",
"\"2.7.14\"",
"}",
")",
".",
"fil... | Run all stories in filename 'filename' in python 2 and 3. | [
"Run",
"all",
"stories",
"in",
"filename",
"filename",
"in",
"python",
"2",
"and",
"3",
"."
] | python | train |
opennode/waldur-core | waldur_core/quotas/handlers.py | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/quotas/handlers.py#L35-L43 | def init_quotas(sender, instance, created=False, **kwargs):
""" Initialize new instances quotas """
if not created:
return
for field in sender.get_quotas_fields():
try:
field.get_or_create_quota(scope=instance)
except CreationConditionFailedQuotaError:
pass | [
"def",
"init_quotas",
"(",
"sender",
",",
"instance",
",",
"created",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"created",
":",
"return",
"for",
"field",
"in",
"sender",
".",
"get_quotas_fields",
"(",
")",
":",
"try",
":",
"field",
... | Initialize new instances quotas | [
"Initialize",
"new",
"instances",
"quotas"
] | python | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/utils/epub.py | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/epub.py#L129-L160 | def make_epub_base(location):
"""
Creates the base structure for an EPUB file in a specified location.
This function creates constant components for the structure of the EPUB in
a specified directory location.
Parameters
----------
location : str
A path string to a local directory ... | [
"def",
"make_epub_base",
"(",
"location",
")",
":",
"log",
".",
"info",
"(",
"'Making EPUB base files in {0}'",
".",
"format",
"(",
"location",
")",
")",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"location",
",",
"'mimetype'",
")",
",",
"... | Creates the base structure for an EPUB file in a specified location.
This function creates constant components for the structure of the EPUB in
a specified directory location.
Parameters
----------
location : str
A path string to a local directory in which the EPUB is to be built | [
"Creates",
"the",
"base",
"structure",
"for",
"an",
"EPUB",
"file",
"in",
"a",
"specified",
"location",
"."
] | python | train |
mitsei/dlkit | dlkit/json_/assessment/sessions.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/sessions.py#L7447-L7506 | def get_assessment_taken_form_for_create(self, assessment_offered_id, assessment_taken_record_types):
"""Gets the assessment taken form for creating new assessments taken.
A new form should be requested for each create transaction.
arg: assessment_offered_id (osid.id.Id): the ``Id`` of the
... | [
"def",
"get_assessment_taken_form_for_create",
"(",
"self",
",",
"assessment_offered_id",
",",
"assessment_taken_record_types",
")",
":",
"if",
"not",
"isinstance",
"(",
"assessment_offered_id",
",",
"ABCId",
")",
":",
"raise",
"errors",
".",
"InvalidArgument",
"(",
"... | Gets the assessment taken form for creating new assessments taken.
A new form should be requested for each create transaction.
arg: assessment_offered_id (osid.id.Id): the ``Id`` of the
related ``AssessmentOffered``
arg: assessment_taken_record_types (osid.type.Type[]): a... | [
"Gets",
"the",
"assessment",
"taken",
"form",
"for",
"creating",
"new",
"assessments",
"taken",
"."
] | python | train |
DistrictDataLabs/yellowbrick | yellowbrick/text/umap_vis.py | https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/text/umap_vis.py#L224-L247 | def make_transformer(self, umap_kwargs={}):
"""
Creates an internal transformer pipeline to project the data set into
2D space using UMAP. This method will reset the transformer on the
class.
Parameters
----------
Returns
-------
transformer : Pi... | [
"def",
"make_transformer",
"(",
"self",
",",
"umap_kwargs",
"=",
"{",
"}",
")",
":",
"# Create the pipeline steps",
"steps",
"=",
"[",
"]",
"# Add the UMAP manifold",
"steps",
".",
"append",
"(",
"(",
"'umap'",
",",
"UMAP",
"(",
"n_components",
"=",
"2",
","... | Creates an internal transformer pipeline to project the data set into
2D space using UMAP. This method will reset the transformer on the
class.
Parameters
----------
Returns
-------
transformer : Pipeline
Pipelined transformer for UMAP projections | [
"Creates",
"an",
"internal",
"transformer",
"pipeline",
"to",
"project",
"the",
"data",
"set",
"into",
"2D",
"space",
"using",
"UMAP",
".",
"This",
"method",
"will",
"reset",
"the",
"transformer",
"on",
"the",
"class",
"."
] | python | train |
uber/tchannel-python | tchannel/event.py | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/event.py#L133-L151 | def register_hook(self, hook, event_type=None):
"""
If ``event_type`` is provided, then ``hook`` will be called whenever
that event is fired.
If no ``event_type`` is specifid, but ``hook`` implements any methods
with names matching an event hook, then those will be registered wi... | [
"def",
"register_hook",
"(",
"self",
",",
"hook",
",",
"event_type",
"=",
"None",
")",
":",
"if",
"event_type",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"event_type",
")",
"is",
"int",
",",
"\"register hooks with int values\"",
"return",
"self",
".",... | If ``event_type`` is provided, then ``hook`` will be called whenever
that event is fired.
If no ``event_type`` is specifid, but ``hook`` implements any methods
with names matching an event hook, then those will be registered with
their corresponding events. This allows for more stateful... | [
"If",
"event_type",
"is",
"provided",
"then",
"hook",
"will",
"be",
"called",
"whenever",
"that",
"event",
"is",
"fired",
"."
] | python | train |
sdispater/pytzdata | pytzdata/__init__.py | https://github.com/sdispater/pytzdata/blob/5707a44e425c0ab57cf9d1f6be83528accc31412/pytzdata/__init__.py#L88-L114 | def get_timezones():
"""
Get the supported timezones.
The list will be cached unless you set the "fresh" attribute to True.
:param fresh: Whether to get a fresh list or not
:type fresh: bool
:rtype: tuple
"""
base_dir = _DIRECTORY
zones = ()
for root, dirs, files in os.walk(b... | [
"def",
"get_timezones",
"(",
")",
":",
"base_dir",
"=",
"_DIRECTORY",
"zones",
"=",
"(",
")",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"base_dir",
")",
":",
"for",
"basename",
"in",
"files",
":",
"zone",
"=",
"os",
".... | Get the supported timezones.
The list will be cached unless you set the "fresh" attribute to True.
:param fresh: Whether to get a fresh list or not
:type fresh: bool
:rtype: tuple | [
"Get",
"the",
"supported",
"timezones",
"."
] | python | train |
kristianfoerster/melodist | melodist/util/util.py | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/util/util.py#L145-L221 | def get_sun_times(dates, lon, lat, time_zone):
"""Computes the times of sunrise, solar noon, and sunset for each day.
Parameters
----
dates: datetime
lat : latitude in DecDeg
lon : longitude in DecDeg
time_zone : timezone
Returns
----
DataFrame: [sunrise,... | [
"def",
"get_sun_times",
"(",
"dates",
",",
"lon",
",",
"lat",
",",
"time_zone",
")",
":",
"df",
"=",
"pd",
".",
"DataFrame",
"(",
"index",
"=",
"dates",
",",
"columns",
"=",
"[",
"'sunrise'",
",",
"'sunnoon'",
",",
"'sunset'",
",",
"'daylength'",
"]",
... | Computes the times of sunrise, solar noon, and sunset for each day.
Parameters
----
dates: datetime
lat : latitude in DecDeg
lon : longitude in DecDeg
time_zone : timezone
Returns
----
DataFrame: [sunrise, sunnoon, sunset, day length] in dec hours | [
"Computes",
"the",
"times",
"of",
"sunrise",
"solar",
"noon",
"and",
"sunset",
"for",
"each",
"day",
"."
] | python | train |
hazelcast/hazelcast-python-client | hazelcast/proxy/queue.py | https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/queue.py#L126-L146 | def drain_to(self, list, max_size=-1):
"""
Transfers all available items to the given `list`_ and removes these items from this queue. If a max_size is
specified, it transfers at most the given number of items. In case of a failure, an item can exist in both
collections or none of them.
... | [
"def",
"drain_to",
"(",
"self",
",",
"list",
",",
"max_size",
"=",
"-",
"1",
")",
":",
"def",
"drain_result",
"(",
"f",
")",
":",
"resp",
"=",
"f",
".",
"result",
"(",
")",
"list",
".",
"extend",
"(",
"resp",
")",
"return",
"len",
"(",
"resp",
... | Transfers all available items to the given `list`_ and removes these items from this queue. If a max_size is
specified, it transfers at most the given number of items. In case of a failure, an item can exist in both
collections or none of them.
This operation may be more efficient than polling ... | [
"Transfers",
"all",
"available",
"items",
"to",
"the",
"given",
"list",
"_",
"and",
"removes",
"these",
"items",
"from",
"this",
"queue",
".",
"If",
"a",
"max_size",
"is",
"specified",
"it",
"transfers",
"at",
"most",
"the",
"given",
"number",
"of",
"items... | python | train |
dschien/PyExcelModelingHelper | excel_helper/__init__.py | https://github.com/dschien/PyExcelModelingHelper/blob/d00d98ae2f28ad71cfcd2a365c3045e439517df2/excel_helper/__init__.py#L241-L301 | def generate_values(self, *args, **kwargs):
"""
Instantiate a random variable and apply annual growth factors.
:return:
"""
assert 'ref value' in self.kwargs
# 1. Generate $\mu$
start_date = self.times[0].to_pydatetime()
end_date = self.times[-1].to_pyda... | [
"def",
"generate_values",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"assert",
"'ref value'",
"in",
"self",
".",
"kwargs",
"# 1. Generate $\\mu$",
"start_date",
"=",
"self",
".",
"times",
"[",
"0",
"]",
".",
"to_pydatetime",
"(",
"... | Instantiate a random variable and apply annual growth factors.
:return: | [
"Instantiate",
"a",
"random",
"variable",
"and",
"apply",
"annual",
"growth",
"factors",
"."
] | python | train |
PaulHancock/Aegean | AegeanTools/msq2.py | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/msq2.py#L45-L92 | def step(self, x, y):
"""
Move from the current location to the next
Parameters
----------
x, y : int
The current location
"""
up_left = self.solid(x - 1, y - 1)
up_right = self.solid(x, y - 1)
down_left = self.solid(x - 1, y)
... | [
"def",
"step",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"up_left",
"=",
"self",
".",
"solid",
"(",
"x",
"-",
"1",
",",
"y",
"-",
"1",
")",
"up_right",
"=",
"self",
".",
"solid",
"(",
"x",
",",
"y",
"-",
"1",
")",
"down_left",
"=",
"self",... | Move from the current location to the next
Parameters
----------
x, y : int
The current location | [
"Move",
"from",
"the",
"current",
"location",
"to",
"the",
"next"
] | python | train |
turicas/rows | rows/plugins/xls.py | https://github.com/turicas/rows/blob/c74da41ae9ed091356b803a64f8a30c641c5fc45/rows/plugins/xls.py#L83-L143 | def cell_value(sheet, row, col):
"""Return the cell value of the table passed by argument, based in row and column."""
cell = sheet.cell(row, col)
field_type = CELL_TYPES[cell.ctype]
# TODO: this approach will not work if using locale
value = cell.value
if field_type is None:
return No... | [
"def",
"cell_value",
"(",
"sheet",
",",
"row",
",",
"col",
")",
":",
"cell",
"=",
"sheet",
".",
"cell",
"(",
"row",
",",
"col",
")",
"field_type",
"=",
"CELL_TYPES",
"[",
"cell",
".",
"ctype",
"]",
"# TODO: this approach will not work if using locale",
"valu... | Return the cell value of the table passed by argument, based in row and column. | [
"Return",
"the",
"cell",
"value",
"of",
"the",
"table",
"passed",
"by",
"argument",
"based",
"in",
"row",
"and",
"column",
"."
] | python | train |
pricingassistant/mrq | mrq/queue.py | https://github.com/pricingassistant/mrq/blob/d0a5a34de9cba38afa94fb7c9e17f9b570b79a50/mrq/queue.py#L164-L208 | def all_known(cls, sources=None, prefixes=None):
""" List all currently known queues """
sources = sources or ("config", "jobs", "raw_subqueues")
queues = set()
if "config" in sources and not prefixes:
# Some queues are explicitly declared in the config (including all root... | [
"def",
"all_known",
"(",
"cls",
",",
"sources",
"=",
"None",
",",
"prefixes",
"=",
"None",
")",
":",
"sources",
"=",
"sources",
"or",
"(",
"\"config\"",
",",
"\"jobs\"",
",",
"\"raw_subqueues\"",
")",
"queues",
"=",
"set",
"(",
")",
"if",
"\"config\"",
... | List all currently known queues | [
"List",
"all",
"currently",
"known",
"queues"
] | python | train |
apache/airflow | airflow/api/common/experimental/mark_tasks.py | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/api/common/experimental/mark_tasks.py#L57-L184 | def set_state(task, execution_date, upstream=False, downstream=False,
future=False, past=False, state=State.SUCCESS, commit=False, session=None):
"""
Set the state of a task instance and if needed its relatives. Can set state
for future tasks (calculated from execution_date) and retroactively
... | [
"def",
"set_state",
"(",
"task",
",",
"execution_date",
",",
"upstream",
"=",
"False",
",",
"downstream",
"=",
"False",
",",
"future",
"=",
"False",
",",
"past",
"=",
"False",
",",
"state",
"=",
"State",
".",
"SUCCESS",
",",
"commit",
"=",
"False",
","... | Set the state of a task instance and if needed its relatives. Can set state
for future tasks (calculated from execution_date) and retroactively
for past tasks. Will verify integrity of past dag runs in order to create
tasks that did not exist. It will not create dag runs that are missing
on the schedule... | [
"Set",
"the",
"state",
"of",
"a",
"task",
"instance",
"and",
"if",
"needed",
"its",
"relatives",
".",
"Can",
"set",
"state",
"for",
"future",
"tasks",
"(",
"calculated",
"from",
"execution_date",
")",
"and",
"retroactively",
"for",
"past",
"tasks",
".",
"W... | python | test |
openstack/horizon | openstack_dashboard/dashboards/project/security_groups/tables.py | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/dashboards/project/security_groups/tables.py#L105-L109 | def filter(self, table, security_groups, filter_string):
"""Naive case-insensitive search."""
query = filter_string.lower()
return [security_group for security_group in security_groups
if query in security_group.name.lower()] | [
"def",
"filter",
"(",
"self",
",",
"table",
",",
"security_groups",
",",
"filter_string",
")",
":",
"query",
"=",
"filter_string",
".",
"lower",
"(",
")",
"return",
"[",
"security_group",
"for",
"security_group",
"in",
"security_groups",
"if",
"query",
"in",
... | Naive case-insensitive search. | [
"Naive",
"case",
"-",
"insensitive",
"search",
"."
] | python | train |
fabioz/PyDev.Debugger | third_party/pep8/lib2to3/lib2to3/pytree.py | https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/third_party/pep8/lib2to3/lib2to3/pytree.py#L332-L339 | def insert_child(self, i, child):
"""
Equivalent to 'node.children.insert(i, child)'. This method also sets
the child's parent attribute appropriately.
"""
child.parent = self
self.children.insert(i, child)
self.changed() | [
"def",
"insert_child",
"(",
"self",
",",
"i",
",",
"child",
")",
":",
"child",
".",
"parent",
"=",
"self",
"self",
".",
"children",
".",
"insert",
"(",
"i",
",",
"child",
")",
"self",
".",
"changed",
"(",
")"
] | Equivalent to 'node.children.insert(i, child)'. This method also sets
the child's parent attribute appropriately. | [
"Equivalent",
"to",
"node",
".",
"children",
".",
"insert",
"(",
"i",
"child",
")",
".",
"This",
"method",
"also",
"sets",
"the",
"child",
"s",
"parent",
"attribute",
"appropriately",
"."
] | python | train |
cloudmesh-cmd3/cmd3 | cmd3/shell.py | https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/cmd3/shell.py#L312-L320 | def create_file(filename):
"""
Creates a new file if the file name does not exists
:param filename: the name of the file
"""
expanded_filename = os.path.expanduser(os.path.expandvars(filename))
if not os.path.exists(expanded_filename):
open(expanded_filename, "a").close() | [
"def",
"create_file",
"(",
"filename",
")",
":",
"expanded_filename",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"os",
".",
"path",
".",
"expandvars",
"(",
"filename",
")",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"expanded_filename"... | Creates a new file if the file name does not exists
:param filename: the name of the file | [
"Creates",
"a",
"new",
"file",
"if",
"the",
"file",
"name",
"does",
"not",
"exists",
":",
"param",
"filename",
":",
"the",
"name",
"of",
"the",
"file"
] | python | train |
abseil/abseil-py | absl/app.py | https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/app.py#L182-L226 | def _register_and_parse_flags_with_usage(
argv=None,
flags_parser=parse_flags_with_usage,
):
"""Registers help flags, parses arguments and shows usage if appropriate.
This also calls sys.exit(0) if flag --only_check_args is True.
Args:
argv: [str], a non-empty list of the command line arguments incl... | [
"def",
"_register_and_parse_flags_with_usage",
"(",
"argv",
"=",
"None",
",",
"flags_parser",
"=",
"parse_flags_with_usage",
",",
")",
":",
"if",
"_register_and_parse_flags_with_usage",
".",
"done",
":",
"raise",
"SystemError",
"(",
"'Flag registration can be done only once... | Registers help flags, parses arguments and shows usage if appropriate.
This also calls sys.exit(0) if flag --only_check_args is True.
Args:
argv: [str], a non-empty list of the command line arguments including
program name, sys.argv is used if None.
flags_parser: Callable[[List[Text]], Any], the f... | [
"Registers",
"help",
"flags",
"parses",
"arguments",
"and",
"shows",
"usage",
"if",
"appropriate",
"."
] | python | train |
DataDog/integrations-core | tokumx/datadog_checks/tokumx/vendor/gridfs/grid_file.py | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/gridfs/grid_file.py#L553-L578 | def seek(self, pos, whence=_SEEK_SET):
"""Set the current position of this file.
:Parameters:
- `pos`: the position (or offset if using relative
positioning) to seek to
- `whence` (optional): where to seek
from. :attr:`os.SEEK_SET` (``0``) for absolute file
... | [
"def",
"seek",
"(",
"self",
",",
"pos",
",",
"whence",
"=",
"_SEEK_SET",
")",
":",
"if",
"whence",
"==",
"_SEEK_SET",
":",
"new_pos",
"=",
"pos",
"elif",
"whence",
"==",
"_SEEK_CUR",
":",
"new_pos",
"=",
"self",
".",
"__position",
"+",
"pos",
"elif",
... | Set the current position of this file.
:Parameters:
- `pos`: the position (or offset if using relative
positioning) to seek to
- `whence` (optional): where to seek
from. :attr:`os.SEEK_SET` (``0``) for absolute file
positioning, :attr:`os.SEEK_CUR` (``1``) to ... | [
"Set",
"the",
"current",
"position",
"of",
"this",
"file",
"."
] | python | train |
gholt/swiftly | swiftly/client/client.py | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/client/client.py#L114-L148 | def head_account(self, headers=None, query=None, cdn=False):
"""
HEADs the account and returns the results. Useful headers
returned are:
=========================== =================================
x-account-bytes-used Object storage used for the
... | [
"def",
"head_account",
"(",
"self",
",",
"headers",
"=",
"None",
",",
"query",
"=",
"None",
",",
"cdn",
"=",
"False",
")",
":",
"return",
"self",
".",
"request",
"(",
"'HEAD'",
",",
"''",
",",
"''",
",",
"headers",
",",
"query",
"=",
"query",
",",
... | HEADs the account and returns the results. Useful headers
returned are:
=========================== =================================
x-account-bytes-used Object storage used for the
account, in bytes.
x-account-container-count The number of ... | [
"HEADs",
"the",
"account",
"and",
"returns",
"the",
"results",
".",
"Useful",
"headers",
"returned",
"are",
":"
] | python | test |
cimm-kzn/CGRtools | CGRtools/algorithms/isomorphism.py | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/algorithms/isomorphism.py#L56-L62 | def get_mapping(self, other):
"""
get self to other mapping
"""
m = next(self._matcher(other).isomorphisms_iter(), None)
if m:
return {v: k for k, v in m.items()} | [
"def",
"get_mapping",
"(",
"self",
",",
"other",
")",
":",
"m",
"=",
"next",
"(",
"self",
".",
"_matcher",
"(",
"other",
")",
".",
"isomorphisms_iter",
"(",
")",
",",
"None",
")",
"if",
"m",
":",
"return",
"{",
"v",
":",
"k",
"for",
"k",
",",
"... | get self to other mapping | [
"get",
"self",
"to",
"other",
"mapping"
] | python | train |
ewels/MultiQC | multiqc/modules/theta2/theta2.py | https://github.com/ewels/MultiQC/blob/2037d6322b2554146a74efbf869156ad20d4c4ec/multiqc/modules/theta2/theta2.py#L75-L99 | def theta2_purities_chart (self):
""" Make the plot showing alignment rates """
# Specify the order of the different possible categories
keys = OrderedDict()
keys['proportion_germline'] = { 'name': 'Germline' }
keys['proportion_tumour_1'] = { 'name': 'Tumour Subclone 1' }
... | [
"def",
"theta2_purities_chart",
"(",
"self",
")",
":",
"# Specify the order of the different possible categories",
"keys",
"=",
"OrderedDict",
"(",
")",
"keys",
"[",
"'proportion_germline'",
"]",
"=",
"{",
"'name'",
":",
"'Germline'",
"}",
"keys",
"[",
"'proportion_tu... | Make the plot showing alignment rates | [
"Make",
"the",
"plot",
"showing",
"alignment",
"rates"
] | python | train |
openstack/horizon | horizon/utils/functions.py | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/utils/functions.py#L96-L100 | def save_config_value(request, response, key, value):
"""Sets value of key `key` to `value` in both session and cookies."""
request.session[key] = value
response.set_cookie(key, value, expires=one_year_from_now())
return response | [
"def",
"save_config_value",
"(",
"request",
",",
"response",
",",
"key",
",",
"value",
")",
":",
"request",
".",
"session",
"[",
"key",
"]",
"=",
"value",
"response",
".",
"set_cookie",
"(",
"key",
",",
"value",
",",
"expires",
"=",
"one_year_from_now",
... | Sets value of key `key` to `value` in both session and cookies. | [
"Sets",
"value",
"of",
"key",
"key",
"to",
"value",
"in",
"both",
"session",
"and",
"cookies",
"."
] | python | train |
chrisjrn/registrasion | registrasion/reporting/views.py | https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/reporting/views.py#L414-L432 | def credit_notes(request, form):
''' Shows all of the credit notes in the system. '''
notes = commerce.CreditNote.objects.all().select_related(
"creditnoterefund",
"creditnoteapplication",
"invoice",
"invoice__user__attendee__attendeeprofilebase",
)
return QuerysetRepor... | [
"def",
"credit_notes",
"(",
"request",
",",
"form",
")",
":",
"notes",
"=",
"commerce",
".",
"CreditNote",
".",
"objects",
".",
"all",
"(",
")",
".",
"select_related",
"(",
"\"creditnoterefund\"",
",",
"\"creditnoteapplication\"",
",",
"\"invoice\"",
",",
"\"i... | Shows all of the credit notes in the system. | [
"Shows",
"all",
"of",
"the",
"credit",
"notes",
"in",
"the",
"system",
"."
] | python | test |
splunk/splunk-sdk-python | splunklib/client.py | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L3590-L3602 | def update_field(self, name, value):
"""Changes the definition of a KV Store field.
:param name: name of field to change
:type name: ``string``
:param value: new field definition
:type value: ``string``
:return: Result of POST request
"""
kwargs = {}
... | [
"def",
"update_field",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"kwargs",
"=",
"{",
"}",
"kwargs",
"[",
"'field.'",
"+",
"name",
"]",
"=",
"value",
"return",
"self",
".",
"post",
"(",
"*",
"*",
"kwargs",
")"
] | Changes the definition of a KV Store field.
:param name: name of field to change
:type name: ``string``
:param value: new field definition
:type value: ``string``
:return: Result of POST request | [
"Changes",
"the",
"definition",
"of",
"a",
"KV",
"Store",
"field",
"."
] | python | train |
realestate-com-au/dashmat | dashmat/core_modules/splunk/splunk-sdk-1.3.0/splunklib/client.py | https://github.com/realestate-com-au/dashmat/blob/433886e52698f0ddb9956f087b76041966c3bcd1/dashmat/core_modules/splunk/splunk-sdk-1.3.0/splunklib/client.py#L1883-L1914 | def attach(self, host=None, source=None, sourcetype=None):
"""Opens a stream (a writable socket) for writing events to the index.
:param host: The host value for events written to the stream.
:type host: ``string``
:param source: The source value for events written to the stream.
... | [
"def",
"attach",
"(",
"self",
",",
"host",
"=",
"None",
",",
"source",
"=",
"None",
",",
"sourcetype",
"=",
"None",
")",
":",
"args",
"=",
"{",
"'index'",
":",
"self",
".",
"name",
"}",
"if",
"host",
"is",
"not",
"None",
":",
"args",
"[",
"'host'... | Opens a stream (a writable socket) for writing events to the index.
:param host: The host value for events written to the stream.
:type host: ``string``
:param source: The source value for events written to the stream.
:type source: ``string``
:param sourcetype: The sourcetype v... | [
"Opens",
"a",
"stream",
"(",
"a",
"writable",
"socket",
")",
"for",
"writing",
"events",
"to",
"the",
"index",
"."
] | python | train |
codelv/enaml-native | src/enamlnative/widgets/scroll_view.py | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/widgets/scroll_view.py#L65-L72 | def _update_proxy(self, change):
""" An observer which sends the state change to the proxy.
"""
if change['type'] in ['event', 'update'] and self.proxy_is_active:
handler = getattr(self.proxy, 'set_' + change['name'], None)
if handler is not None:
handler... | [
"def",
"_update_proxy",
"(",
"self",
",",
"change",
")",
":",
"if",
"change",
"[",
"'type'",
"]",
"in",
"[",
"'event'",
",",
"'update'",
"]",
"and",
"self",
".",
"proxy_is_active",
":",
"handler",
"=",
"getattr",
"(",
"self",
".",
"proxy",
",",
"'set_'... | An observer which sends the state change to the proxy. | [
"An",
"observer",
"which",
"sends",
"the",
"state",
"change",
"to",
"the",
"proxy",
"."
] | python | train |
gbiggs/rtctree | rtctree/manager.py | https://github.com/gbiggs/rtctree/blob/bd725a47ac87c259c8bce06156ccc9ab71111c26/rtctree/manager.py#L236-L248 | def unload_module(self, path):
'''Unload a loaded shared library.
Call this function to remove a shared library (e.g. a component) that
was previously loaded.
@param path The path to the shared library.
@raises FailedToUnloadModuleError
'''
with self._mutex:
... | [
"def",
"unload_module",
"(",
"self",
",",
"path",
")",
":",
"with",
"self",
".",
"_mutex",
":",
"if",
"self",
".",
"_obj",
".",
"unload_module",
"(",
"path",
")",
"!=",
"RTC",
".",
"RTC_OK",
":",
"raise",
"FailedToUnloadModuleError",
"(",
"path",
")"
] | Unload a loaded shared library.
Call this function to remove a shared library (e.g. a component) that
was previously loaded.
@param path The path to the shared library.
@raises FailedToUnloadModuleError | [
"Unload",
"a",
"loaded",
"shared",
"library",
"."
] | python | train |
nickoala/telepot | telepot/__init__.py | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L789-L792 | def deleteChatPhoto(self, chat_id):
""" See: https://core.telegram.org/bots/api#deletechatphoto """
p = _strip(locals())
return self._api_request('deleteChatPhoto', _rectify(p)) | [
"def",
"deleteChatPhoto",
"(",
"self",
",",
"chat_id",
")",
":",
"p",
"=",
"_strip",
"(",
"locals",
"(",
")",
")",
"return",
"self",
".",
"_api_request",
"(",
"'deleteChatPhoto'",
",",
"_rectify",
"(",
"p",
")",
")"
] | See: https://core.telegram.org/bots/api#deletechatphoto | [
"See",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api#deletechatphoto"
] | python | train |
useblocks/groundwork | groundwork/patterns/gw_base_pattern.py | https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_base_pattern.py#L148-L154 | def _post_activate_injection(self):
"""
Injects functions after the activation routine of child classes got called
:return: None
"""
self.active = True
self.app.signals.send("plugin_activate_post", self) | [
"def",
"_post_activate_injection",
"(",
"self",
")",
":",
"self",
".",
"active",
"=",
"True",
"self",
".",
"app",
".",
"signals",
".",
"send",
"(",
"\"plugin_activate_post\"",
",",
"self",
")"
] | Injects functions after the activation routine of child classes got called
:return: None | [
"Injects",
"functions",
"after",
"the",
"activation",
"routine",
"of",
"child",
"classes",
"got",
"called",
":",
"return",
":",
"None"
] | python | train |
flatangle/flatlib | flatlib/predictives/primarydirections.py | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/predictives/primarydirections.py#L322-L328 | def bySignificator(self, ID):
""" Returns all directions to a significator. """
res = []
for direction in self.table:
if ID in direction[2]:
res.append(direction)
return res | [
"def",
"bySignificator",
"(",
"self",
",",
"ID",
")",
":",
"res",
"=",
"[",
"]",
"for",
"direction",
"in",
"self",
".",
"table",
":",
"if",
"ID",
"in",
"direction",
"[",
"2",
"]",
":",
"res",
".",
"append",
"(",
"direction",
")",
"return",
"res"
] | Returns all directions to a significator. | [
"Returns",
"all",
"directions",
"to",
"a",
"significator",
"."
] | python | train |
pybel/pybel-tools | src/pybel_tools/summary/node_properties.py | https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/node_properties.py#L80-L89 | def get_causal_central_nodes(graph: BELGraph, func: str) -> Set[BaseEntity]:
"""Return a set of all nodes that have both an in-degree > 0 and out-degree > 0.
This means that they are an integral part of a pathway, since they are both produced and consumed.
"""
return {
node
for node in ... | [
"def",
"get_causal_central_nodes",
"(",
"graph",
":",
"BELGraph",
",",
"func",
":",
"str",
")",
"->",
"Set",
"[",
"BaseEntity",
"]",
":",
"return",
"{",
"node",
"for",
"node",
"in",
"graph",
"if",
"node",
".",
"function",
"==",
"func",
"and",
"is_causal_... | Return a set of all nodes that have both an in-degree > 0 and out-degree > 0.
This means that they are an integral part of a pathway, since they are both produced and consumed. | [
"Return",
"a",
"set",
"of",
"all",
"nodes",
"that",
"have",
"both",
"an",
"in",
"-",
"degree",
">",
"0",
"and",
"out",
"-",
"degree",
">",
"0",
"."
] | python | valid |
saltstack/salt | salt/config/__init__.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/config/__init__.py#L2560-L2581 | def apply_sdb(opts, sdb_opts=None):
'''
Recurse for sdb:// links for opts
'''
# Late load of SDB to keep CLI light
import salt.utils.sdb
if sdb_opts is None:
sdb_opts = opts
if isinstance(sdb_opts, six.string_types) and sdb_opts.startswith('sdb://'):
return salt.utils.sdb.sdb... | [
"def",
"apply_sdb",
"(",
"opts",
",",
"sdb_opts",
"=",
"None",
")",
":",
"# Late load of SDB to keep CLI light",
"import",
"salt",
".",
"utils",
".",
"sdb",
"if",
"sdb_opts",
"is",
"None",
":",
"sdb_opts",
"=",
"opts",
"if",
"isinstance",
"(",
"sdb_opts",
",... | Recurse for sdb:// links for opts | [
"Recurse",
"for",
"sdb",
":",
"//",
"links",
"for",
"opts"
] | python | train |
innogames/polysh | polysh/remote_dispatcher.py | https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/remote_dispatcher.py#L367-L376 | def rename(self, name):
"""Send to the remote shell, its new name to be shell expanded"""
if name:
# defug callback add?
rename1, rename2 = callbacks.add(
b'rename', self.change_name, False)
self.dispatch_command(b'/bin/echo "' + rename1 + b'""' + rena... | [
"def",
"rename",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
":",
"# defug callback add?",
"rename1",
",",
"rename2",
"=",
"callbacks",
".",
"add",
"(",
"b'rename'",
",",
"self",
".",
"change_name",
",",
"False",
")",
"self",
".",
"dispatch_command",... | Send to the remote shell, its new name to be shell expanded | [
"Send",
"to",
"the",
"remote",
"shell",
"its",
"new",
"name",
"to",
"be",
"shell",
"expanded"
] | python | train |
peterdemin/pip-compile-multi | pipcompilemulti/environment.py | https://github.com/peterdemin/pip-compile-multi/blob/7bd1968c424dd7ce3236885b4b3e4e28523e6915/pipcompilemulti/environment.py#L103-L115 | def fix_lockfile(self):
"""Run each line of outfile through fix_pin"""
with open(self.outfile, 'rt') as fp:
lines = [
self.fix_pin(line)
for line in self.concatenated(fp)
]
with open(self.outfile, 'wt') as fp:
fp.writelines([
... | [
"def",
"fix_lockfile",
"(",
"self",
")",
":",
"with",
"open",
"(",
"self",
".",
"outfile",
",",
"'rt'",
")",
"as",
"fp",
":",
"lines",
"=",
"[",
"self",
".",
"fix_pin",
"(",
"line",
")",
"for",
"line",
"in",
"self",
".",
"concatenated",
"(",
"fp",
... | Run each line of outfile through fix_pin | [
"Run",
"each",
"line",
"of",
"outfile",
"through",
"fix_pin"
] | python | train |
gmr/tredis | tredis/sets.py | https://github.com/gmr/tredis/blob/2e91c6a58a35460be0525c51ac6a98fde3b506ad/tredis/sets.py#L253-L285 | def srandmember(self, key, count=None):
"""When called with just the key argument, return a random element from
the set value stored at key.
Starting from Redis version 2.6, when called with the additional count
argument, return an array of count distinct elements if count is
po... | [
"def",
"srandmember",
"(",
"self",
",",
"key",
",",
"count",
"=",
"None",
")",
":",
"command",
"=",
"[",
"b'SRANDMEMBER'",
",",
"key",
"]",
"if",
"count",
":",
"command",
".",
"append",
"(",
"ascii",
"(",
"count",
")",
".",
"encode",
"(",
"'ascii'",
... | When called with just the key argument, return a random element from
the set value stored at key.
Starting from Redis version 2.6, when called with the additional count
argument, return an array of count distinct elements if count is
positive. If called with a negative count the behavio... | [
"When",
"called",
"with",
"just",
"the",
"key",
"argument",
"return",
"a",
"random",
"element",
"from",
"the",
"set",
"value",
"stored",
"at",
"key",
"."
] | python | train |
chrisspen/burlap | burlap/rpi.py | https://github.com/chrisspen/burlap/blob/a92b0a8e5206850bb777c74af8421ea8b33779bd/burlap/rpi.py#L170-L218 | def init_ubuntu_disk(self, yes=0):
"""
Downloads the latest Ubuntu image and writes it to a microSD card.
Based on the instructions from:
https://wiki.ubuntu.com/ARM/RaspberryPi
For recommended SD card brands, see:
http://elinux.org/RPi_SD_cards
Note,... | [
"def",
"init_ubuntu_disk",
"(",
"self",
",",
"yes",
"=",
"0",
")",
":",
"self",
".",
"assume_localhost",
"(",
")",
"yes",
"=",
"int",
"(",
"yes",
")",
"if",
"not",
"self",
".",
"dryrun",
":",
"device_question",
"=",
"'SD card present at %s? '",
"%",
"sel... | Downloads the latest Ubuntu image and writes it to a microSD card.
Based on the instructions from:
https://wiki.ubuntu.com/ARM/RaspberryPi
For recommended SD card brands, see:
http://elinux.org/RPi_SD_cards
Note, if you get an error like:
Kernel panic-no... | [
"Downloads",
"the",
"latest",
"Ubuntu",
"image",
"and",
"writes",
"it",
"to",
"a",
"microSD",
"card",
"."
] | python | valid |
wonambi-python/wonambi | wonambi/widgets/detect_dialogs.py | https://github.com/wonambi-python/wonambi/blob/1d8e3d7e53df8017c199f703bcab582914676e76/wonambi/widgets/detect_dialogs.py#L465-L476 | def count_channels(self):
"""If more than one channel selected, activate merge checkbox."""
merge = self.index['merge']
if len(self.idx_chan.selectedItems()) > 1:
if merge.isEnabled():
return
else:
merge.setEnabled(True)
else:
... | [
"def",
"count_channels",
"(",
"self",
")",
":",
"merge",
"=",
"self",
".",
"index",
"[",
"'merge'",
"]",
"if",
"len",
"(",
"self",
".",
"idx_chan",
".",
"selectedItems",
"(",
")",
")",
">",
"1",
":",
"if",
"merge",
".",
"isEnabled",
"(",
")",
":",
... | If more than one channel selected, activate merge checkbox. | [
"If",
"more",
"than",
"one",
"channel",
"selected",
"activate",
"merge",
"checkbox",
"."
] | python | train |
nephila/python-taiga | taiga/models/models.py | https://github.com/nephila/python-taiga/blob/5b471d6b8b59e5d410162a6f1c2f0d4188445a56/taiga/models/models.py#L91-L104 | def create(self, project, name, **attrs):
"""
Create a new :class:`CustomAttribute`.
:param project: :class:`Project` id
:param name: name of the custom attribute
:param attrs: optional attributes of the custom attributes
"""
attrs.update(
{
... | [
"def",
"create",
"(",
"self",
",",
"project",
",",
"name",
",",
"*",
"*",
"attrs",
")",
":",
"attrs",
".",
"update",
"(",
"{",
"'project'",
":",
"project",
",",
"'name'",
":",
"name",
"}",
")",
"return",
"self",
".",
"_new_resource",
"(",
"payload",
... | Create a new :class:`CustomAttribute`.
:param project: :class:`Project` id
:param name: name of the custom attribute
:param attrs: optional attributes of the custom attributes | [
"Create",
"a",
"new",
":",
"class",
":",
"CustomAttribute",
"."
] | python | train |
estnltk/estnltk | estnltk/mw_verbs/basic_verbchain_detection.py | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/mw_verbs/basic_verbchain_detection.py#L133-L161 | def _canFormAraPhrase( araVerb, otherVerb ):
''' Teeb kindlaks, kas etteantud 'ära' verb (araVerb) yhildub teise verbiga;
Arvestab järgimisi ühilduvusi:
ains 2. pööre: ära_neg.o + V_o
ains 3. pööre: ära_neg.gu + V_gu
mitm 1. pööre: ära_neg.me + V_me... | [
"def",
"_canFormAraPhrase",
"(",
"araVerb",
",",
"otherVerb",
")",
":",
"global",
"_verbAraAgreements",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"_verbAraAgreements",
")",
",",
"2",
")",
":",
"araVerbTemplate",
"=",
"_verbAraAgreements",
"[",
"i... | Teeb kindlaks, kas etteantud 'ära' verb (araVerb) yhildub teise verbiga;
Arvestab järgimisi ühilduvusi:
ains 2. pööre: ära_neg.o + V_o
ains 3. pööre: ära_neg.gu + V_gu
mitm 1. pööre: ära_neg.me + V_me
ära_neg.me + V_o
... | [
"Teeb",
"kindlaks",
"kas",
"etteantud",
"ära",
"verb",
"(",
"araVerb",
")",
"yhildub",
"teise",
"verbiga",
";",
"Arvestab",
"järgimisi",
"ühilduvusi",
":",
"ains",
"2",
".",
"pööre",
":",
"ära_neg",
".",
"o",
"+",
"V_o",
"ains",
"3",
".",
"pööre",
":",
... | python | train |
NASA-AMMOS/AIT-Core | ait/core/server/server.py | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/server/server.py#L240-L292 | def _create_plugin(self, config):
"""
Creates a plugin from its config.
Params:
config: plugin configuration as read by ait.config
Returns:
plugin: a Plugin
Raises:
ValueError: if any of the required config values are missing
... | [
"def",
"_create_plugin",
"(",
"self",
",",
"config",
")",
":",
"if",
"config",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'No plugin config to create plugin from.'",
")",
"name",
"=",
"config",
".",
"pop",
"(",
"'name'",
",",
"None",
")",
"if",
"name",
... | Creates a plugin from its config.
Params:
config: plugin configuration as read by ait.config
Returns:
plugin: a Plugin
Raises:
ValueError: if any of the required config values are missing | [
"Creates",
"a",
"plugin",
"from",
"its",
"config",
"."
] | python | train |
ska-sa/katversion | katversion/version.py | https://github.com/ska-sa/katversion/blob/f507e46e6c5610aec89a08dd480c9b3721da0f8a/katversion/version.py#L248-L321 | def get_version(path=None, module=None):
"""Return the version string.
This function ensures that the version string complies with PEP 440.
The format of our version string is:
- for RELEASE builds:
<major>.<minor>
e.g.
0.1
2.4
- for DEVELOPME... | [
"def",
"get_version",
"(",
"path",
"=",
"None",
",",
"module",
"=",
"None",
")",
":",
"# Check the module option first.",
"version",
"=",
"get_version_from_module",
"(",
"module",
")",
"if",
"version",
":",
"return",
"normalised",
"(",
"version",
")",
"# Turn pa... | Return the version string.
This function ensures that the version string complies with PEP 440.
The format of our version string is:
- for RELEASE builds:
<major>.<minor>
e.g.
0.1
2.4
- for DEVELOPMENT builds:
<major>.<minor>.dev<num_b... | [
"Return",
"the",
"version",
"string",
"."
] | python | train |
audreyr/jinja2_pluralize | jinja2_pluralize/__init__.py | https://github.com/audreyr/jinja2_pluralize/blob/e94770417ff65c71461980ec26c5a1b4e4212ca5/jinja2_pluralize/__init__.py#L18-L62 | def pluralize_dj(value, arg='s'):
"""
Adapted from django.template.defaultfilters:
https://github.com/django/django/blob/master/django/template/defaultfilters.py
Returns a plural suffix if the value is not 1. By default, 's' is used as
the suffix:
* If value is 0, vote{{ value|pluralize }} dis... | [
"def",
"pluralize_dj",
"(",
"value",
",",
"arg",
"=",
"'s'",
")",
":",
"if",
"','",
"not",
"in",
"arg",
":",
"arg",
"=",
"','",
"+",
"arg",
"bits",
"=",
"arg",
".",
"split",
"(",
"','",
")",
"if",
"len",
"(",
"bits",
")",
">",
"2",
":",
"retu... | Adapted from django.template.defaultfilters:
https://github.com/django/django/blob/master/django/template/defaultfilters.py
Returns a plural suffix if the value is not 1. By default, 's' is used as
the suffix:
* If value is 0, vote{{ value|pluralize }} displays "0 votes".
* If value is 1, vote{{ v... | [
"Adapted",
"from",
"django",
".",
"template",
".",
"defaultfilters",
":",
"https",
":",
"//",
"github",
".",
"com",
"/",
"django",
"/",
"django",
"/",
"blob",
"/",
"master",
"/",
"django",
"/",
"template",
"/",
"defaultfilters",
".",
"py"
] | python | train |
PeerAssets/pypeerassets | pypeerassets/protocol.py | https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/protocol.py#L147-L152 | def to_json(self) -> dict:
'''export the Deck object to json-ready format'''
d = self.__dict__
d['p2th_wif'] = self.p2th_wif
return d | [
"def",
"to_json",
"(",
"self",
")",
"->",
"dict",
":",
"d",
"=",
"self",
".",
"__dict__",
"d",
"[",
"'p2th_wif'",
"]",
"=",
"self",
".",
"p2th_wif",
"return",
"d"
] | export the Deck object to json-ready format | [
"export",
"the",
"Deck",
"object",
"to",
"json",
"-",
"ready",
"format"
] | python | train |
inasafe/inasafe | safe/definitions/utilities.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/utilities.py#L239-L259 | def get_non_compulsory_fields(layer_purpose, layer_subcategory=None):
"""Get non compulsory field based on layer_purpose and layer_subcategory.
Used for get field in InaSAFE Fields step in wizard.
:param layer_purpose: The layer purpose.
:type layer_purpose: str
:param layer_subcategory: Exposure... | [
"def",
"get_non_compulsory_fields",
"(",
"layer_purpose",
",",
"layer_subcategory",
"=",
"None",
")",
":",
"all_fields",
"=",
"get_fields",
"(",
"layer_purpose",
",",
"layer_subcategory",
",",
"replace_null",
"=",
"False",
")",
"compulsory_field",
"=",
"get_compulsory... | Get non compulsory field based on layer_purpose and layer_subcategory.
Used for get field in InaSAFE Fields step in wizard.
:param layer_purpose: The layer purpose.
:type layer_purpose: str
:param layer_subcategory: Exposure or hazard value.
:type layer_subcategory: str
:returns: Compulsory ... | [
"Get",
"non",
"compulsory",
"field",
"based",
"on",
"layer_purpose",
"and",
"layer_subcategory",
"."
] | python | train |
gwastro/pycbc | pycbc/psd/estimate.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/psd/estimate.py#L57-L185 | def welch(timeseries, seg_len=4096, seg_stride=2048, window='hann',
avg_method='median', num_segments=None, require_exact_data_fit=False):
"""PSD estimator based on Welch's method.
Parameters
----------
timeseries : TimeSeries
Time series for which the PSD is to be estimated.
seg_... | [
"def",
"welch",
"(",
"timeseries",
",",
"seg_len",
"=",
"4096",
",",
"seg_stride",
"=",
"2048",
",",
"window",
"=",
"'hann'",
",",
"avg_method",
"=",
"'median'",
",",
"num_segments",
"=",
"None",
",",
"require_exact_data_fit",
"=",
"False",
")",
":",
"wind... | PSD estimator based on Welch's method.
Parameters
----------
timeseries : TimeSeries
Time series for which the PSD is to be estimated.
seg_len : int
Segment length in samples.
seg_stride : int
Separation between consecutive segments, in samples.
window : {'hann', numpy.n... | [
"PSD",
"estimator",
"based",
"on",
"Welch",
"s",
"method",
"."
] | python | train |
wheeler-microfluidics/dmf-control-board-firmware | dmf_control_board_firmware/__init__.py | https://github.com/wheeler-microfluidics/dmf-control-board-firmware/blob/1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c/dmf_control_board_firmware/__init__.py#L1504-L1520 | def persistent_write(self, address, byte, refresh_config=False):
'''
Write a single byte to an address in persistent memory.
Parameters
----------
address : int
Address in persistent memory (e.g., EEPROM).
byte : int
Value to write to address.
... | [
"def",
"persistent_write",
"(",
"self",
",",
"address",
",",
"byte",
",",
"refresh_config",
"=",
"False",
")",
":",
"self",
".",
"_persistent_write",
"(",
"address",
",",
"byte",
")",
"if",
"refresh_config",
":",
"self",
".",
"load_config",
"(",
"False",
"... | Write a single byte to an address in persistent memory.
Parameters
----------
address : int
Address in persistent memory (e.g., EEPROM).
byte : int
Value to write to address.
refresh_config : bool, optional
Is ``True``, :meth:`load_config()` i... | [
"Write",
"a",
"single",
"byte",
"to",
"an",
"address",
"in",
"persistent",
"memory",
"."
] | python | train |
JosuaKrause/quick_server | quick_server/quick_server.py | https://github.com/JosuaKrause/quick_server/blob/55dc7c5fe726a341f8476f749fe0f9da156fc1cb/quick_server/quick_server.py#L2787-L2794 | def handle_error(self, request, client_address):
"""Handle an error gracefully.
"""
if self.can_ignore_error():
return
thread = threading.current_thread()
msg("Error in request ({0}): {1} in {2}\n{3}",
client_address, repr(request), thread.name, traceback.... | [
"def",
"handle_error",
"(",
"self",
",",
"request",
",",
"client_address",
")",
":",
"if",
"self",
".",
"can_ignore_error",
"(",
")",
":",
"return",
"thread",
"=",
"threading",
".",
"current_thread",
"(",
")",
"msg",
"(",
"\"Error in request ({0}): {1} in {2}\\n... | Handle an error gracefully. | [
"Handle",
"an",
"error",
"gracefully",
"."
] | python | train |
Scifabric/pbs | helpers.py | https://github.com/Scifabric/pbs/blob/3e5d5f3f0f5d20f740eaacc4d6e872a0c9fb8b38/helpers.py#L103-L138 | def _update_project(config, task_presenter, results,
long_description, tutorial):
"""Update a project."""
try:
# Get project
project = find_project_by_short_name(config.project['short_name'],
config.pbclient,
... | [
"def",
"_update_project",
"(",
"config",
",",
"task_presenter",
",",
"results",
",",
"long_description",
",",
"tutorial",
")",
":",
"try",
":",
"# Get project",
"project",
"=",
"find_project_by_short_name",
"(",
"config",
".",
"project",
"[",
"'short_name'",
"]",
... | Update a project. | [
"Update",
"a",
"project",
"."
] | python | train |
upsight/doctor | doctor/flask.py | https://github.com/upsight/doctor/blob/2cf1d433f6f1aa1355644b449a757c0660793cdd/doctor/flask.py#L97-L246 | def handle_http(handler: Resource, args: Tuple, kwargs: Dict, logic: Callable):
"""Handle a Flask HTTP request
:param handler: flask_restful.Resource: An instance of a Flask Restful
resource class.
:param tuple args: Any positional arguments passed to the wrapper method.
:param dict kwargs: Any... | [
"def",
"handle_http",
"(",
"handler",
":",
"Resource",
",",
"args",
":",
"Tuple",
",",
"kwargs",
":",
"Dict",
",",
"logic",
":",
"Callable",
")",
":",
"try",
":",
"# We are checking mimetype here instead of content_type because",
"# mimetype is just the content-type, wh... | Handle a Flask HTTP request
:param handler: flask_restful.Resource: An instance of a Flask Restful
resource class.
:param tuple args: Any positional arguments passed to the wrapper method.
:param dict kwargs: Any keyword arguments passed to the wrapper method.
:param callable logic: The callabl... | [
"Handle",
"a",
"Flask",
"HTTP",
"request"
] | python | train |
gccxml/pygccxml | pygccxml/declarations/scopedef.py | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/scopedef.py#L582-L603 | def variable(
self,
name=None,
function=None,
decl_type=None,
header_dir=None,
header_file=None,
recursive=None):
"""returns reference to variable declaration, that is matched defined
criteria"""
return (
... | [
"def",
"variable",
"(",
"self",
",",
"name",
"=",
"None",
",",
"function",
"=",
"None",
",",
"decl_type",
"=",
"None",
",",
"header_dir",
"=",
"None",
",",
"header_file",
"=",
"None",
",",
"recursive",
"=",
"None",
")",
":",
"return",
"(",
"self",
".... | returns reference to variable declaration, that is matched defined
criteria | [
"returns",
"reference",
"to",
"variable",
"declaration",
"that",
"is",
"matched",
"defined",
"criteria"
] | python | train |
StanfordVL/robosuite | robosuite/environments/sawyer.py | https://github.com/StanfordVL/robosuite/blob/65cd16810e2ed647e3ec88746af3412065b7f278/robosuite/environments/sawyer.py#L106-L116 | def _reset_internal(self):
"""
Sets initial pose of arm and grippers.
"""
super()._reset_internal()
self.sim.data.qpos[self._ref_joint_pos_indexes] = self.mujoco_robot.init_qpos
if self.has_gripper:
self.sim.data.qpos[
self._ref_joint_gripper_... | [
"def",
"_reset_internal",
"(",
"self",
")",
":",
"super",
"(",
")",
".",
"_reset_internal",
"(",
")",
"self",
".",
"sim",
".",
"data",
".",
"qpos",
"[",
"self",
".",
"_ref_joint_pos_indexes",
"]",
"=",
"self",
".",
"mujoco_robot",
".",
"init_qpos",
"if",... | Sets initial pose of arm and grippers. | [
"Sets",
"initial",
"pose",
"of",
"arm",
"and",
"grippers",
"."
] | python | train |
nickmckay/LiPD-utilities | Python/lipd/lpd_noaa.py | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/lpd_noaa.py#L1263-L1276 | def __write_funding(self):
"""
Write funding section. There are likely multiple entries.
:param dict d:
:return none:
"""
self.__reorganize_funding()
# if funding is empty, insert a blank entry so that it'll still write the empty section on the template.
i... | [
"def",
"__write_funding",
"(",
"self",
")",
":",
"self",
".",
"__reorganize_funding",
"(",
")",
"# if funding is empty, insert a blank entry so that it'll still write the empty section on the template.",
"if",
"not",
"self",
".",
"noaa_data_sorted",
"[",
"\"Funding_Agency\"",
"... | Write funding section. There are likely multiple entries.
:param dict d:
:return none: | [
"Write",
"funding",
"section",
".",
"There",
"are",
"likely",
"multiple",
"entries",
".",
":",
"param",
"dict",
"d",
":",
":",
"return",
"none",
":"
] | python | train |
spacetelescope/pysynphot | pysynphot/spectrum.py | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/spectrum.py#L1818-L1856 | def pivot(self, binned=False):
"""Calculate :ref:`pysynphot-formula-pivwv`.
Parameters
----------
binned : bool
This is reserved for use by `~pysynphot.observation.Observation`.
If `True`, binned wavelength set is used. Default is `False`.
Returns
... | [
"def",
"pivot",
"(",
"self",
",",
"binned",
"=",
"False",
")",
":",
"if",
"binned",
":",
"try",
":",
"wave",
"=",
"self",
".",
"binwave",
"except",
"AttributeError",
":",
"raise",
"AttributeError",
"(",
"'Class '",
"+",
"str",
"(",
"type",
"(",
"self",... | Calculate :ref:`pysynphot-formula-pivwv`.
Parameters
----------
binned : bool
This is reserved for use by `~pysynphot.observation.Observation`.
If `True`, binned wavelength set is used. Default is `False`.
Returns
-------
ans : float
... | [
"Calculate",
":",
"ref",
":",
"pysynphot",
"-",
"formula",
"-",
"pivwv",
"."
] | python | train |
bastibe/PySoundCard | pysoundcard.py | https://github.com/bastibe/PySoundCard/blob/fb16460b75a1bb416089ebecdf700fa954faa5b7/pysoundcard.py#L416-L425 | def start(self):
"""Commence audio processing.
If successful, the stream is considered active.
"""
err = _pa.Pa_StartStream(self._stream)
if err == _pa.paStreamIsNotStopped:
return
self._handle_error(err) | [
"def",
"start",
"(",
"self",
")",
":",
"err",
"=",
"_pa",
".",
"Pa_StartStream",
"(",
"self",
".",
"_stream",
")",
"if",
"err",
"==",
"_pa",
".",
"paStreamIsNotStopped",
":",
"return",
"self",
".",
"_handle_error",
"(",
"err",
")"
] | Commence audio processing.
If successful, the stream is considered active. | [
"Commence",
"audio",
"processing",
"."
] | python | train |
ga4gh/ga4gh-server | ga4gh/server/datarepo.py | https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/ga4gh/server/datarepo.py#L68-L74 | def addOntology(self, ontology):
"""
Add an ontology map to this data repository.
"""
self._ontologyNameMap[ontology.getName()] = ontology
self._ontologyIdMap[ontology.getId()] = ontology
self._ontologyIds.append(ontology.getId()) | [
"def",
"addOntology",
"(",
"self",
",",
"ontology",
")",
":",
"self",
".",
"_ontologyNameMap",
"[",
"ontology",
".",
"getName",
"(",
")",
"]",
"=",
"ontology",
"self",
".",
"_ontologyIdMap",
"[",
"ontology",
".",
"getId",
"(",
")",
"]",
"=",
"ontology",
... | Add an ontology map to this data repository. | [
"Add",
"an",
"ontology",
"map",
"to",
"this",
"data",
"repository",
"."
] | python | train |
peterwittek/somoclu | src/Python/somoclu/train.py | https://github.com/peterwittek/somoclu/blob/b31dfbeba6765e64aedddcf8259626d6684f5349/src/Python/somoclu/train.py#L136-L154 | def load_bmus(self, filename):
"""Load the best matching units from a file to the Somoclu object.
:param filename: The name of the file.
:type filename: str.
"""
self.bmus = np.loadtxt(filename, comments='%', usecols=(1, 2))
if self.n_vectors != 0 and len(self.bmus) != s... | [
"def",
"load_bmus",
"(",
"self",
",",
"filename",
")",
":",
"self",
".",
"bmus",
"=",
"np",
".",
"loadtxt",
"(",
"filename",
",",
"comments",
"=",
"'%'",
",",
"usecols",
"=",
"(",
"1",
",",
"2",
")",
")",
"if",
"self",
".",
"n_vectors",
"!=",
"0"... | Load the best matching units from a file to the Somoclu object.
:param filename: The name of the file.
:type filename: str. | [
"Load",
"the",
"best",
"matching",
"units",
"from",
"a",
"file",
"to",
"the",
"Somoclu",
"object",
"."
] | python | train |
gwpy/gwpy | gwpy/utils/sphinx/zenodo.py | https://github.com/gwpy/gwpy/blob/7a92b917e7dd2d99b15895293a1fa1d66cdb210a/gwpy/utils/sphinx/zenodo.py#L46-L90 | def format_citations(zid, url='https://zenodo.org/', hits=10, tag_prefix='v'):
"""Query and format a citations page from Zenodo entries
Parameters
----------
zid : `int`, `str`
the Zenodo ID of the target record
url : `str`, optional
the base URL of the Zenodo host, defaults to ``h... | [
"def",
"format_citations",
"(",
"zid",
",",
"url",
"=",
"'https://zenodo.org/'",
",",
"hits",
"=",
"10",
",",
"tag_prefix",
"=",
"'v'",
")",
":",
"# query for metadata",
"url",
"=",
"(",
"'{url}/api/records/?'",
"'page=1&'",
"'size={hits}&'",
"'q=conceptrecid:\"{id}... | Query and format a citations page from Zenodo entries
Parameters
----------
zid : `int`, `str`
the Zenodo ID of the target record
url : `str`, optional
the base URL of the Zenodo host, defaults to ``https://zenodo.org``
hist : `int`, optional
the maximum number of hits to ... | [
"Query",
"and",
"format",
"a",
"citations",
"page",
"from",
"Zenodo",
"entries"
] | python | train |
Microsoft/botbuilder-python | libraries/botbuilder-core/botbuilder/core/bot_adapter.py | https://github.com/Microsoft/botbuilder-python/blob/274663dd91c811bae6ac4488915ba5880771b0a7/libraries/botbuilder-core/botbuilder/core/bot_adapter.py#L51-L59 | async def run_middleware(self, context: TurnContext, callback: Callable=None):
"""
Called by the parent class to run the adapters middleware set and calls the passed in `callback()` handler at
the end of the chain.
:param context:
:param callback:
:return:
"""
... | [
"async",
"def",
"run_middleware",
"(",
"self",
",",
"context",
":",
"TurnContext",
",",
"callback",
":",
"Callable",
"=",
"None",
")",
":",
"return",
"await",
"self",
".",
"_middleware",
".",
"receive_activity_with_status",
"(",
"context",
",",
"callback",
")"... | Called by the parent class to run the adapters middleware set and calls the passed in `callback()` handler at
the end of the chain.
:param context:
:param callback:
:return: | [
"Called",
"by",
"the",
"parent",
"class",
"to",
"run",
"the",
"adapters",
"middleware",
"set",
"and",
"calls",
"the",
"passed",
"in",
"callback",
"()",
"handler",
"at",
"the",
"end",
"of",
"the",
"chain",
".",
":",
"param",
"context",
":",
":",
"param",
... | python | test |
PyCQA/pylint | pylint/checkers/utils.py | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/utils.py#L398-L411 | def is_ancestor_name(
frame: astroid.node_classes.NodeNG, node: astroid.node_classes.NodeNG
) -> bool:
"""return True if `frame` is an astroid.Class node with `node` in the
subtree of its bases attribute
"""
try:
bases = frame.bases
except AttributeError:
return False
for bas... | [
"def",
"is_ancestor_name",
"(",
"frame",
":",
"astroid",
".",
"node_classes",
".",
"NodeNG",
",",
"node",
":",
"astroid",
".",
"node_classes",
".",
"NodeNG",
")",
"->",
"bool",
":",
"try",
":",
"bases",
"=",
"frame",
".",
"bases",
"except",
"AttributeError... | return True if `frame` is an astroid.Class node with `node` in the
subtree of its bases attribute | [
"return",
"True",
"if",
"frame",
"is",
"an",
"astroid",
".",
"Class",
"node",
"with",
"node",
"in",
"the",
"subtree",
"of",
"its",
"bases",
"attribute"
] | python | test |
square/pylink | pylink/jlink.py | https://github.com/square/pylink/blob/81dda0a191d923a8b2627c52cb778aba24d279d7/pylink/jlink.py#L4467-L4483 | def swo_stop(self):
"""Stops collecting SWO data.
Args:
self (JLink): the ``JLink`` instance
Returns:
``None``
Raises:
JLinkException: on error
"""
res = self._dll.JLINKARM_SWO_Control(enums.JLinkSWOCommands.STOP, 0)
if res < 0:
... | [
"def",
"swo_stop",
"(",
"self",
")",
":",
"res",
"=",
"self",
".",
"_dll",
".",
"JLINKARM_SWO_Control",
"(",
"enums",
".",
"JLinkSWOCommands",
".",
"STOP",
",",
"0",
")",
"if",
"res",
"<",
"0",
":",
"raise",
"errors",
".",
"JLinkException",
"(",
"res",... | Stops collecting SWO data.
Args:
self (JLink): the ``JLink`` instance
Returns:
``None``
Raises:
JLinkException: on error | [
"Stops",
"collecting",
"SWO",
"data",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.