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 |
|---|---|---|---|---|---|---|---|---|
LISE-B26/pylabcontrol | build/lib/pylabcontrol/src/tools/export_default.py | https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/tools/export_default.py#L170-L212 | def export(target_folder, source_folders = None, class_type ='all', raise_errors = False):
"""
exports the existing scripts/instruments (future: probes) into folder as .b26 files
Args:
target_folder: target location of created .b26 script files
source_folder: singel path or list of paths tha... | [
"def",
"export",
"(",
"target_folder",
",",
"source_folders",
"=",
"None",
",",
"class_type",
"=",
"'all'",
",",
"raise_errors",
"=",
"False",
")",
":",
"if",
"class_type",
"not",
"in",
"(",
"'all'",
",",
"'scripts'",
",",
"'instruments'",
",",
"'probes'",
... | exports the existing scripts/instruments (future: probes) into folder as .b26 files
Args:
target_folder: target location of created .b26 script files
source_folder: singel path or list of paths that contains the location of python script files can also be just the name of a module
class_type... | [
"exports",
"the",
"existing",
"scripts",
"/",
"instruments",
"(",
"future",
":",
"probes",
")",
"into",
"folder",
"as",
".",
"b26",
"files",
"Args",
":",
"target_folder",
":",
"target",
"location",
"of",
"created",
".",
"b26",
"script",
"files",
"source_fold... | python | train |
ChristianTremblay/BAC0 | BAC0/core/devices/Device.py | https://github.com/ChristianTremblay/BAC0/blob/8d95b065ea068524a08f5b0c34322ebeeba95d06/BAC0/core/devices/Device.py#L584-L594 | def analog_units(self):
"""
Shortcut to retrieve all analog points units [Used by Bokeh trending feature]
"""
au = []
us = []
for each in self.points:
if isinstance(each, NumericPoint):
au.append(each.properties.name)
u... | [
"def",
"analog_units",
"(",
"self",
")",
":",
"au",
"=",
"[",
"]",
"us",
"=",
"[",
"]",
"for",
"each",
"in",
"self",
".",
"points",
":",
"if",
"isinstance",
"(",
"each",
",",
"NumericPoint",
")",
":",
"au",
".",
"append",
"(",
"each",
".",
"prope... | Shortcut to retrieve all analog points units [Used by Bokeh trending feature] | [
"Shortcut",
"to",
"retrieve",
"all",
"analog",
"points",
"units",
"[",
"Used",
"by",
"Bokeh",
"trending",
"feature",
"]"
] | python | train |
stevearc/dql | dql/engine.py | https://github.com/stevearc/dql/blob/e9d3aa22873076dae5ebd02e35318aa996b1e56a/dql/engine.py#L162-L167 | def cloudwatch_connection(self):
""" Lazy create a connection to cloudwatch """
if self._cloudwatch_connection is None:
conn = self._session.create_client("cloudwatch", self.connection.region)
self._cloudwatch_connection = conn
return self._cloudwatch_connection | [
"def",
"cloudwatch_connection",
"(",
"self",
")",
":",
"if",
"self",
".",
"_cloudwatch_connection",
"is",
"None",
":",
"conn",
"=",
"self",
".",
"_session",
".",
"create_client",
"(",
"\"cloudwatch\"",
",",
"self",
".",
"connection",
".",
"region",
")",
"sel... | Lazy create a connection to cloudwatch | [
"Lazy",
"create",
"a",
"connection",
"to",
"cloudwatch"
] | python | train |
napalm-automation/napalm-ios | napalm_ios/ios.py | https://github.com/napalm-automation/napalm-ios/blob/7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81/napalm_ios/ios.py#L201-L208 | def _create_tmp_file(config):
"""Write temp file and for use with inline config and SCP."""
tmp_dir = tempfile.gettempdir()
rand_fname = py23_compat.text_type(uuid.uuid4())
filename = os.path.join(tmp_dir, rand_fname)
with open(filename, 'wt') as fobj:
fobj.write(conf... | [
"def",
"_create_tmp_file",
"(",
"config",
")",
":",
"tmp_dir",
"=",
"tempfile",
".",
"gettempdir",
"(",
")",
"rand_fname",
"=",
"py23_compat",
".",
"text_type",
"(",
"uuid",
".",
"uuid4",
"(",
")",
")",
"filename",
"=",
"os",
".",
"path",
".",
"join",
... | Write temp file and for use with inline config and SCP. | [
"Write",
"temp",
"file",
"and",
"for",
"use",
"with",
"inline",
"config",
"and",
"SCP",
"."
] | 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#L2974-L3007 | def stk_metadata(self):
"""Return STK metadata from UIC tags as dict."""
if not self.is_stk:
return None
page = self.pages[0]
tags = page.tags
result = {}
result['NumberPlanes'] = tags['UIC2tag'].count
if page.description:
result['PlaneDesc... | [
"def",
"stk_metadata",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_stk",
":",
"return",
"None",
"page",
"=",
"self",
".",
"pages",
"[",
"0",
"]",
"tags",
"=",
"page",
".",
"tags",
"result",
"=",
"{",
"}",
"result",
"[",
"'NumberPlanes'",
"... | Return STK metadata from UIC tags as dict. | [
"Return",
"STK",
"metadata",
"from",
"UIC",
"tags",
"as",
"dict",
"."
] | python | train |
DarkEnergySurvey/ugali | ugali/analysis/results.py | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/analysis/results.py#L317-L332 | def surfaceBrightness(abs_mag, r_physical, distance):
"""
Compute the average surface brightness [mag arcsec^-2] within the half-light radius
abs_mag = absolute magnitude [mag]
r_physical = half-light radius [kpc]
distance = [kpc]
The factor 2 in the c_v equation below account for half the lu... | [
"def",
"surfaceBrightness",
"(",
"abs_mag",
",",
"r_physical",
",",
"distance",
")",
":",
"r_angle",
"=",
"np",
".",
"degrees",
"(",
"np",
".",
"arctan",
"(",
"r_physical",
"/",
"distance",
")",
")",
"c_v",
"=",
"19.78",
"# mag/arcsec^2",
"return",
"abs_ma... | Compute the average surface brightness [mag arcsec^-2] within the half-light radius
abs_mag = absolute magnitude [mag]
r_physical = half-light radius [kpc]
distance = [kpc]
The factor 2 in the c_v equation below account for half the luminosity
within the half-light radius. The 3600.**2 is conver... | [
"Compute",
"the",
"average",
"surface",
"brightness",
"[",
"mag",
"arcsec^",
"-",
"2",
"]",
"within",
"the",
"half",
"-",
"light",
"radius"
] | python | train |
vsergeev/python-periphery | periphery/mmio.py | https://github.com/vsergeev/python-periphery/blob/ff4d535691a1747a76962a3d077d96d224308611/periphery/mmio.py#L245-L268 | def write(self, offset, data):
"""Write a string of bytes to the specified `offset` in bytes, relative
to the base physical address of the MMIO region.
Args:
offset (int, long): offset from base physical address, in bytes.
data (bytes, bytearray, list): a byte array or l... | [
"def",
"write",
"(",
"self",
",",
"offset",
",",
"data",
")",
":",
"if",
"not",
"isinstance",
"(",
"offset",
",",
"(",
"int",
",",
"long",
")",
")",
":",
"raise",
"TypeError",
"(",
"\"Invalid offset type, should be integer.\"",
")",
"if",
"not",
"isinstanc... | Write a string of bytes to the specified `offset` in bytes, relative
to the base physical address of the MMIO region.
Args:
offset (int, long): offset from base physical address, in bytes.
data (bytes, bytearray, list): a byte array or list of 8-bit
... | [
"Write",
"a",
"string",
"of",
"bytes",
"to",
"the",
"specified",
"offset",
"in",
"bytes",
"relative",
"to",
"the",
"base",
"physical",
"address",
"of",
"the",
"MMIO",
"region",
"."
] | python | train |
wrboyce/telegrambot | telegrambot/api/__init__.py | https://github.com/wrboyce/telegrambot/blob/c35ce19886df4c306a2a19851cc1f63e3066d70d/telegrambot/api/__init__.py#L178-L185 | def send_chat_action(self, action, to):
"""
Use this method when you need to tell the user that something is happening on the bot's side.
The status is set for 5 seconds or less (when a message arrives from your bot,
Telegram clients clear its typing status).
"""
... | [
"def",
"send_chat_action",
"(",
"self",
",",
"action",
",",
"to",
")",
":",
"payload",
"=",
"dict",
"(",
"chat_id",
"=",
"to",
",",
"action",
"=",
"action",
")",
"return",
"self",
".",
"_get",
"(",
"'sendChatAction'",
",",
"payload",
")"
] | Use this method when you need to tell the user that something is happening on the bot's side.
The status is set for 5 seconds or less (when a message arrives from your bot,
Telegram clients clear its typing status). | [
"Use",
"this",
"method",
"when",
"you",
"need",
"to",
"tell",
"the",
"user",
"that",
"something",
"is",
"happening",
"on",
"the",
"bot",
"s",
"side",
".",
"The",
"status",
"is",
"set",
"for",
"5",
"seconds",
"or",
"less",
"(",
"when",
"a",
"message",
... | python | train |
wolfhong/formic | formic/formic.py | https://github.com/wolfhong/formic/blob/0d81eb88dcbb6fa705194fc6ccf2993f4abbaa76/formic/formic.py#L237-L272 | def _match_iter_generic(self, path_elements, start_at):
"""Implementation of match_iter for >1 self.elements"""
length = len(path_elements)
# If bound to start, we stop searching at the first element
if self.bound_start:
end = 1
else:
end = length - self.... | [
"def",
"_match_iter_generic",
"(",
"self",
",",
"path_elements",
",",
"start_at",
")",
":",
"length",
"=",
"len",
"(",
"path_elements",
")",
"# If bound to start, we stop searching at the first element",
"if",
"self",
".",
"bound_start",
":",
"end",
"=",
"1",
"else"... | Implementation of match_iter for >1 self.elements | [
"Implementation",
"of",
"match_iter",
"for",
">",
"1",
"self",
".",
"elements"
] | python | train |
aiven/pghoard | pghoard/pghoard.py | https://github.com/aiven/pghoard/blob/2994165d4ef3ff7a5669a2527346bcbfb5b3bd8a/pghoard/pghoard.py#L346-L392 | def startup_walk_for_missed_files(self):
"""Check xlog and xlog_incoming directories for files that receivexlog has received but not yet
compressed as well as the files we have compressed but not yet uploaded and process them."""
for site in self.config["backup_sites"]:
compressed_xl... | [
"def",
"startup_walk_for_missed_files",
"(",
"self",
")",
":",
"for",
"site",
"in",
"self",
".",
"config",
"[",
"\"backup_sites\"",
"]",
":",
"compressed_xlog_path",
",",
"_",
"=",
"self",
".",
"create_backup_site_paths",
"(",
"site",
")",
"uncompressed_xlog_path"... | Check xlog and xlog_incoming directories for files that receivexlog has received but not yet
compressed as well as the files we have compressed but not yet uploaded and process them. | [
"Check",
"xlog",
"and",
"xlog_incoming",
"directories",
"for",
"files",
"that",
"receivexlog",
"has",
"received",
"but",
"not",
"yet",
"compressed",
"as",
"well",
"as",
"the",
"files",
"we",
"have",
"compressed",
"but",
"not",
"yet",
"uploaded",
"and",
"proces... | python | train |
ARMmbed/icetea | icetea_lib/tools/asserts.py | https://github.com/ARMmbed/icetea/blob/b2b97ac607429830cf7d62dae2e3903692c7c778/icetea_lib/tools/asserts.py#L191-L215 | def assertJsonContains(jsonStr=None, key=None, message=None):
"""
Assert that jsonStr contains key.
:param jsonStr: Json as string
:param key: Key to look for
:param message: Failure message
:raises: TestStepFail if key is not in jsonStr or
if loading jsonStr to a dictionary fails or if jso... | [
"def",
"assertJsonContains",
"(",
"jsonStr",
"=",
"None",
",",
"key",
"=",
"None",
",",
"message",
"=",
"None",
")",
":",
"if",
"jsonStr",
"is",
"not",
"None",
":",
"try",
":",
"data",
"=",
"json",
".",
"loads",
"(",
"jsonStr",
")",
"if",
"key",
"n... | Assert that jsonStr contains key.
:param jsonStr: Json as string
:param key: Key to look for
:param message: Failure message
:raises: TestStepFail if key is not in jsonStr or
if loading jsonStr to a dictionary fails or if jsonStr is None. | [
"Assert",
"that",
"jsonStr",
"contains",
"key",
"."
] | python | train |
MolSSI-BSE/basis_set_exchange | basis_set_exchange/curate/compare.py | https://github.com/MolSSI-BSE/basis_set_exchange/blob/e79110aaeb65f392ed5032420322dee3336948f7/basis_set_exchange/curate/compare.py#L188-L218 | def compare_ecp_pots(potential1, potential2, compare_meta=False, rel_tol=0.0):
'''
Compare two ecp potentials for approximate equality
(exponents/coefficients are within a tolerance)
If compare_meta is True, the metadata is also compared for exact equality.
'''
if potential1['angular_momentum... | [
"def",
"compare_ecp_pots",
"(",
"potential1",
",",
"potential2",
",",
"compare_meta",
"=",
"False",
",",
"rel_tol",
"=",
"0.0",
")",
":",
"if",
"potential1",
"[",
"'angular_momentum'",
"]",
"!=",
"potential2",
"[",
"'angular_momentum'",
"]",
":",
"return",
"Fa... | Compare two ecp potentials for approximate equality
(exponents/coefficients are within a tolerance)
If compare_meta is True, the metadata is also compared for exact equality. | [
"Compare",
"two",
"ecp",
"potentials",
"for",
"approximate",
"equality",
"(",
"exponents",
"/",
"coefficients",
"are",
"within",
"a",
"tolerance",
")"
] | python | train |
saltstack/salt | salt/minion.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/minion.py#L2928-L2945 | def destroy(self):
'''
Tear down the minion
'''
if self._running is False:
return
self._running = False
if hasattr(self, 'schedule'):
del self.schedule
if hasattr(self, 'pub_channel') and self.pub_channel is not None:
self.pub_... | [
"def",
"destroy",
"(",
"self",
")",
":",
"if",
"self",
".",
"_running",
"is",
"False",
":",
"return",
"self",
".",
"_running",
"=",
"False",
"if",
"hasattr",
"(",
"self",
",",
"'schedule'",
")",
":",
"del",
"self",
".",
"schedule",
"if",
"hasattr",
"... | Tear down the minion | [
"Tear",
"down",
"the",
"minion"
] | python | train |
quantopian/pgcontents | pgcontents/query.py | https://github.com/quantopian/pgcontents/blob/ed36268b7917332d16868208e1e565742a8753e1/pgcontents/query.py#L256-L286 | def get_directory(db, user_id, api_dirname, content):
"""
Return the names of all files/directories that are direct children of
api_dirname.
If content is False, return a bare model containing just a database-style
name.
"""
db_dirname = from_api_dirname(api_dirname)
if not _dir_exists(... | [
"def",
"get_directory",
"(",
"db",
",",
"user_id",
",",
"api_dirname",
",",
"content",
")",
":",
"db_dirname",
"=",
"from_api_dirname",
"(",
"api_dirname",
")",
"if",
"not",
"_dir_exists",
"(",
"db",
",",
"user_id",
",",
"db_dirname",
")",
":",
"raise",
"N... | Return the names of all files/directories that are direct children of
api_dirname.
If content is False, return a bare model containing just a database-style
name. | [
"Return",
"the",
"names",
"of",
"all",
"files",
"/",
"directories",
"that",
"are",
"direct",
"children",
"of",
"api_dirname",
"."
] | python | test |
tbobm/devscripts | devscripts/logs.py | https://github.com/tbobm/devscripts/blob/beb23371ba80739afb5474766e8049ead3837925/devscripts/logs.py#L12-L49 | def simple_logger(**kwargs):
"""
Creates a simple logger
:param str name: The logger's name ('api', 'back'...)
:param int base_level: Lowest level allowed to log (Default: DEBUG)
:param str log_format: Logging format used for STDOUT
(Default: logs.FORMAT)
:param bool... | [
"def",
"simple_logger",
"(",
"*",
"*",
"kwargs",
")",
":",
"# Args",
"logger_name",
"=",
"kwargs",
".",
"get",
"(",
"'name'",
")",
"base_level",
"=",
"kwargs",
".",
"get",
"(",
"'base_level'",
",",
"logging",
".",
"DEBUG",
")",
"should_stdout",
"=",
"kwa... | Creates a simple logger
:param str name: The logger's name ('api', 'back'...)
:param int base_level: Lowest level allowed to log (Default: DEBUG)
:param str log_format: Logging format used for STDOUT
(Default: logs.FORMAT)
:param bool should_stdout: Allows to log to stdout (... | [
"Creates",
"a",
"simple",
"logger"
] | python | train |
telefonicaid/fiware-sdc | python-sdcclient/sdcclient/client.py | https://github.com/telefonicaid/fiware-sdc/blob/d2d5f87fc574caf6bcc49594bbcb31f620ba8c51/python-sdcclient/sdcclient/client.py#L165-L173 | def set_headers(self, headers):
"""
Set header.
:param headers: Headers to be used by next request (dict)
:return: None
"""
logger.debug("Setting headers: " + str(headers))
self.headers = headers | [
"def",
"set_headers",
"(",
"self",
",",
"headers",
")",
":",
"logger",
".",
"debug",
"(",
"\"Setting headers: \"",
"+",
"str",
"(",
"headers",
")",
")",
"self",
".",
"headers",
"=",
"headers"
] | Set header.
:param headers: Headers to be used by next request (dict)
:return: None | [
"Set",
"header",
".",
":",
"param",
"headers",
":",
"Headers",
"to",
"be",
"used",
"by",
"next",
"request",
"(",
"dict",
")",
":",
"return",
":",
"None"
] | python | train |
bjoernricks/python-quilt | quilt/db.py | https://github.com/bjoernricks/python-quilt/blob/fae88237f601848cc34d073584d9dcb409f01777/quilt/db.py#L296-L300 | def create(self):
""" Creates the dirname and inserts a .version file """
if not os.path.exists(self.dirname):
os.makedirs(self.dirname)
self._create_version(self.version_file) | [
"def",
"create",
"(",
"self",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"dirname",
")",
":",
"os",
".",
"makedirs",
"(",
"self",
".",
"dirname",
")",
"self",
".",
"_create_version",
"(",
"self",
".",
"version_file",
... | Creates the dirname and inserts a .version file | [
"Creates",
"the",
"dirname",
"and",
"inserts",
"a",
".",
"version",
"file"
] | python | test |
toidi/hadoop-yarn-api-python-client | yarn_api_client/resource_manager.py | https://github.com/toidi/hadoop-yarn-api-python-client/blob/d245bd41808879be6637acfd7460633c0c7dfdd6/yarn_api_client/resource_manager.py#L161-L172 | def cluster_application(self, application_id):
"""
An application resource contains information about a particular
application that was submitted to a cluster.
:param str application_id: The application id
:returns: API response object with JSON data
:rtype: :py:class:`y... | [
"def",
"cluster_application",
"(",
"self",
",",
"application_id",
")",
":",
"path",
"=",
"'/ws/v1/cluster/apps/{appid}'",
".",
"format",
"(",
"appid",
"=",
"application_id",
")",
"return",
"self",
".",
"request",
"(",
"path",
")"
] | An application resource contains information about a particular
application that was submitted to a cluster.
:param str application_id: The application id
:returns: API response object with JSON data
:rtype: :py:class:`yarn_api_client.base.Response` | [
"An",
"application",
"resource",
"contains",
"information",
"about",
"a",
"particular",
"application",
"that",
"was",
"submitted",
"to",
"a",
"cluster",
"."
] | python | train |
arista-eosplus/pyeapi | pyeapi/eapilib.py | https://github.com/arista-eosplus/pyeapi/blob/96a74faef1fe3bd79c4e900aed29c9956a0587d6/pyeapi/eapilib.py#L308-L436 | def send(self, data):
"""Sends the eAPI request to the destination node
This method is responsible for sending an eAPI request to the
destination node and returning a response based on the eAPI response
object. eAPI responds to request messages with either a success
message or ... | [
"def",
"send",
"(",
"self",
",",
"data",
")",
":",
"try",
":",
"_LOGGER",
".",
"debug",
"(",
"'Request content: {}'",
".",
"format",
"(",
"data",
")",
")",
"# debug('eapi_request: %s' % data)",
"self",
".",
"transport",
".",
"putrequest",
"(",
"'POST'",
",",... | Sends the eAPI request to the destination node
This method is responsible for sending an eAPI request to the
destination node and returning a response based on the eAPI response
object. eAPI responds to request messages with either a success
message or failure message.
eAPI Re... | [
"Sends",
"the",
"eAPI",
"request",
"to",
"the",
"destination",
"node"
] | python | train |
ARMmbed/icetea | icetea_lib/Result.py | https://github.com/ARMmbed/icetea/blob/b2b97ac607429830cf7d62dae2e3903692c7c778/icetea_lib/Result.py#L159-L168 | def build_date(self):
"""
get build date.
:return: build date. None if not found
"""
# pylint: disable=len-as-condition
if len(self.dutinformation) > 0 and (self.dutinformation.get(0).build is not None):
return self.dutinformation.get(0).build.date
re... | [
"def",
"build_date",
"(",
"self",
")",
":",
"# pylint: disable=len-as-condition",
"if",
"len",
"(",
"self",
".",
"dutinformation",
")",
">",
"0",
"and",
"(",
"self",
".",
"dutinformation",
".",
"get",
"(",
"0",
")",
".",
"build",
"is",
"not",
"None",
")"... | get build date.
:return: build date. None if not found | [
"get",
"build",
"date",
"."
] | python | train |
andreikop/qutepart | qutepart/bookmarks.py | https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/bookmarks.py#L25-L36 | def _createAction(self, widget, iconFileName, text, shortcut, slot):
"""Create QAction with given parameters and add to the widget
"""
icon = qutepart.getIcon(iconFileName)
action = QAction(icon, text, widget)
action.setShortcut(QKeySequence(shortcut))
action.setShortcutC... | [
"def",
"_createAction",
"(",
"self",
",",
"widget",
",",
"iconFileName",
",",
"text",
",",
"shortcut",
",",
"slot",
")",
":",
"icon",
"=",
"qutepart",
".",
"getIcon",
"(",
"iconFileName",
")",
"action",
"=",
"QAction",
"(",
"icon",
",",
"text",
",",
"w... | Create QAction with given parameters and add to the widget | [
"Create",
"QAction",
"with",
"given",
"parameters",
"and",
"add",
"to",
"the",
"widget"
] | python | train |
google/textfsm | textfsm/parser.py | https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/parser.py#L622-L626 | def _GetValue(self, name):
"""Returns the TextFSMValue object natching the requested name."""
for value in self.values:
if value.name == name:
return value | [
"def",
"_GetValue",
"(",
"self",
",",
"name",
")",
":",
"for",
"value",
"in",
"self",
".",
"values",
":",
"if",
"value",
".",
"name",
"==",
"name",
":",
"return",
"value"
] | Returns the TextFSMValue object natching the requested name. | [
"Returns",
"the",
"TextFSMValue",
"object",
"natching",
"the",
"requested",
"name",
"."
] | python | train |
aarongarrett/inspyred | inspyred/ec/variators/crossovers.py | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/variators/crossovers.py#L444-L493 | def laplace_crossover(random, mom, dad, args):
"""Return the offspring of Laplace crossover on the candidates.
This function performs Laplace crosssover (LX), following the
implementation specified in (Deep and Thakur, "A new crossover
operator for real coded genetic algorithms," Applied Mathemat... | [
"def",
"laplace_crossover",
"(",
"random",
",",
"mom",
",",
"dad",
",",
"args",
")",
":",
"crossover_rate",
"=",
"args",
".",
"setdefault",
"(",
"'crossover_rate'",
",",
"1.0",
")",
"if",
"random",
".",
"random",
"(",
")",
"<",
"crossover_rate",
":",
"bo... | Return the offspring of Laplace crossover on the candidates.
This function performs Laplace crosssover (LX), following the
implementation specified in (Deep and Thakur, "A new crossover
operator for real coded genetic algorithms," Applied Mathematics
and Computation, Volume 188, Issue 1, May 200... | [
"Return",
"the",
"offspring",
"of",
"Laplace",
"crossover",
"on",
"the",
"candidates",
".",
"This",
"function",
"performs",
"Laplace",
"crosssover",
"(",
"LX",
")",
"following",
"the",
"implementation",
"specified",
"in",
"(",
"Deep",
"and",
"Thakur",
"A",
"ne... | python | train |
Opentrons/opentrons | api/src/opentrons/system/smoothie_update.py | https://github.com/Opentrons/opentrons/blob/a7c15cc2636ecb64ab56c7edc1d8a57163aaeadf/api/src/opentrons/system/smoothie_update.py#L6-L16 | def _ensure_programmer_executable():
""" Find the lpc21isp executable and ensure it is executable
"""
# Find the lpc21isp executable, explicitly allowing the case where it
# is not executable (since that’s exactly what we’re trying to fix)
updater_executable = shutil.which('lpc21isp',
... | [
"def",
"_ensure_programmer_executable",
"(",
")",
":",
"# Find the lpc21isp executable, explicitly allowing the case where it",
"# is not executable (since that’s exactly what we’re trying to fix)",
"updater_executable",
"=",
"shutil",
".",
"which",
"(",
"'lpc21isp'",
",",
"mode",
"=... | Find the lpc21isp executable and ensure it is executable | [
"Find",
"the",
"lpc21isp",
"executable",
"and",
"ensure",
"it",
"is",
"executable"
] | python | train |
doconix/django-mako-plus | django_mako_plus/template/util.py | https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/template/util.py#L40-L170 | def get_template_debug(template_name, error):
'''
This structure is what Django wants when errors occur in templates.
It gives the user a nice stack trace in the error page during debug.
'''
# This is taken from mako.exceptions.html_error_template(), which has an issue
# in Py3 where files get l... | [
"def",
"get_template_debug",
"(",
"template_name",
",",
"error",
")",
":",
"# This is taken from mako.exceptions.html_error_template(), which has an issue",
"# in Py3 where files get loaded as bytes but `lines = src.split('\\n')` below",
"# splits with a string. Not sure if this is a bug or if I... | This structure is what Django wants when errors occur in templates.
It gives the user a nice stack trace in the error page during debug. | [
"This",
"structure",
"is",
"what",
"Django",
"wants",
"when",
"errors",
"occur",
"in",
"templates",
".",
"It",
"gives",
"the",
"user",
"a",
"nice",
"stack",
"trace",
"in",
"the",
"error",
"page",
"during",
"debug",
"."
] | python | train |
sorgerlab/indra | indra/sources/isi/api.py | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/isi/api.py#L240-L264 | def process_json_file(file_path, pmid=None, extra_annotations=None,
add_grounding=True):
"""Extracts statements from the given ISI output file.
Parameters
----------
file_path : str
The ISI output file from which to extract statements
pmid : int
The PMID of the... | [
"def",
"process_json_file",
"(",
"file_path",
",",
"pmid",
"=",
"None",
",",
"extra_annotations",
"=",
"None",
",",
"add_grounding",
"=",
"True",
")",
":",
"logger",
".",
"info",
"(",
"'Extracting from %s'",
"%",
"file_path",
")",
"with",
"open",
"(",
"file_... | Extracts statements from the given ISI output file.
Parameters
----------
file_path : str
The ISI output file from which to extract statements
pmid : int
The PMID of the document being preprocessed, or None if not
specified
extra_annotations : dict
Extra annotations ... | [
"Extracts",
"statements",
"from",
"the",
"given",
"ISI",
"output",
"file",
"."
] | python | train |
multiformats/py-multibase | multibase/converters.py | https://github.com/multiformats/py-multibase/blob/8f435762b50a17f921c13b59eb0c7b9c52afc879/multibase/converters.py#L47-L51 | def _chunk_with_padding(self, iterable, n, fillvalue=None):
"Collect data into fixed-length chunks or blocks"
# _chunk_with_padding('ABCDEFG', 3, 'x') --> ABC DEF Gxx"
args = [iter(iterable)] * n
return zip_longest(*args, fillvalue=fillvalue) | [
"def",
"_chunk_with_padding",
"(",
"self",
",",
"iterable",
",",
"n",
",",
"fillvalue",
"=",
"None",
")",
":",
"# _chunk_with_padding('ABCDEFG', 3, 'x') --> ABC DEF Gxx\"",
"args",
"=",
"[",
"iter",
"(",
"iterable",
")",
"]",
"*",
"n",
"return",
"zip_longest",
"... | Collect data into fixed-length chunks or blocks | [
"Collect",
"data",
"into",
"fixed",
"-",
"length",
"chunks",
"or",
"blocks"
] | python | train |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py#L306-L313 | def get_network_by_full_name(self, si, default_network_full_name):
"""
Find network by a Full Name
:param default_network_full_name: <str> Full Network Name - likes 'Root/Folder/Network'
:return:
"""
path, name = get_path_and_name(default_network_full_name)
return... | [
"def",
"get_network_by_full_name",
"(",
"self",
",",
"si",
",",
"default_network_full_name",
")",
":",
"path",
",",
"name",
"=",
"get_path_and_name",
"(",
"default_network_full_name",
")",
"return",
"self",
".",
"find_network_by_name",
"(",
"si",
",",
"path",
",",... | Find network by a Full Name
:param default_network_full_name: <str> Full Network Name - likes 'Root/Folder/Network'
:return: | [
"Find",
"network",
"by",
"a",
"Full",
"Name",
":",
"param",
"default_network_full_name",
":",
"<str",
">",
"Full",
"Network",
"Name",
"-",
"likes",
"Root",
"/",
"Folder",
"/",
"Network",
":",
"return",
":"
] | python | train |
Rapptz/discord.py | discord/guild.py | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/guild.py#L1375-L1399 | async def unban(self, user, *, reason=None):
"""|coro|
Unbans a user from the guild.
The user must meet the :class:`abc.Snowflake` abc.
You must have the :attr:`~Permissions.ban_members` permission to
do this.
Parameters
-----------
user: :class:`abc.S... | [
"async",
"def",
"unban",
"(",
"self",
",",
"user",
",",
"*",
",",
"reason",
"=",
"None",
")",
":",
"await",
"self",
".",
"_state",
".",
"http",
".",
"unban",
"(",
"user",
".",
"id",
",",
"self",
".",
"id",
",",
"reason",
"=",
"reason",
")"
] | |coro|
Unbans a user from the guild.
The user must meet the :class:`abc.Snowflake` abc.
You must have the :attr:`~Permissions.ban_members` permission to
do this.
Parameters
-----------
user: :class:`abc.Snowflake`
The user to unban.
reason:... | [
"|coro|"
] | python | train |
echinopsii/net.echinopsii.ariane.community.cli.python3 | ariane_clip3/injector.py | https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/injector.py#L1103-L1112 | def remove(self):
"""
remove the gear from the cache and stop this actor
:return:
"""
LOGGER.debug("InjectorGearSkeleton.remove")
ret = self.cached_gear_actor.remove().get()
if self.actor_ref:
self.stop()
return ret | [
"def",
"remove",
"(",
"self",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"InjectorGearSkeleton.remove\"",
")",
"ret",
"=",
"self",
".",
"cached_gear_actor",
".",
"remove",
"(",
")",
".",
"get",
"(",
")",
"if",
"self",
".",
"actor_ref",
":",
"self",
".",
... | remove the gear from the cache and stop this actor
:return: | [
"remove",
"the",
"gear",
"from",
"the",
"cache",
"and",
"stop",
"this",
"actor",
":",
"return",
":"
] | python | train |
salu133445/pypianoroll | pypianoroll/multitrack.py | https://github.com/salu133445/pypianoroll/blob/6224dc1e29222de2124d249acb80f3d072166917/pypianoroll/multitrack.py#L210-L253 | def check_validity(self):
"""
Raise an error if any invalid attribute found.
Raises
------
TypeError
If an attribute has an invalid type.
ValueError
If an attribute has an invalid value (of the correct type).
"""
# tracks
... | [
"def",
"check_validity",
"(",
"self",
")",
":",
"# tracks",
"for",
"track",
"in",
"self",
".",
"tracks",
":",
"if",
"not",
"isinstance",
"(",
"track",
",",
"Track",
")",
":",
"raise",
"TypeError",
"(",
"\"`tracks` must be a list of \"",
"\"`pypianoroll.Track` in... | Raise an error if any invalid attribute found.
Raises
------
TypeError
If an attribute has an invalid type.
ValueError
If an attribute has an invalid value (of the correct type). | [
"Raise",
"an",
"error",
"if",
"any",
"invalid",
"attribute",
"found",
"."
] | python | train |
noxdafox/clipspy | clips/classes.py | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L336-L338 | def superclass(self, klass):
"""True if the Class is a superclass of the given one."""
return bool(lib.EnvSuperclassP(self._env, self._cls, klass._cls)) | [
"def",
"superclass",
"(",
"self",
",",
"klass",
")",
":",
"return",
"bool",
"(",
"lib",
".",
"EnvSuperclassP",
"(",
"self",
".",
"_env",
",",
"self",
".",
"_cls",
",",
"klass",
".",
"_cls",
")",
")"
] | True if the Class is a superclass of the given one. | [
"True",
"if",
"the",
"Class",
"is",
"a",
"superclass",
"of",
"the",
"given",
"one",
"."
] | python | train |
fossasia/knittingpattern | knittingpattern/convert/image_to_knittingpattern.py | https://github.com/fossasia/knittingpattern/blob/8e608896b0ab82fea1ca9fbfa2b4ee023d8c8027/knittingpattern/convert/image_to_knittingpattern.py#L12-L64 | def convert_image_to_knitting_pattern(path, colors=("white", "black")):
"""Load a image file such as a png bitmap of jpeg file and convert it
to a :ref:`knitting pattern file <FileFormatSpecification>`.
:param list colors: a list of strings that should be used as
:ref:`colors <png-color>`.
:param... | [
"def",
"convert_image_to_knitting_pattern",
"(",
"path",
",",
"colors",
"=",
"(",
"\"white\"",
",",
"\"black\"",
")",
")",
":",
"image",
"=",
"PIL",
".",
"Image",
".",
"open",
"(",
"path",
")",
"pattern_id",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
... | Load a image file such as a png bitmap of jpeg file and convert it
to a :ref:`knitting pattern file <FileFormatSpecification>`.
:param list colors: a list of strings that should be used as
:ref:`colors <png-color>`.
:param str path: ignore this. It is fulfilled by the loeder.
Example:
.. co... | [
"Load",
"a",
"image",
"file",
"such",
"as",
"a",
"png",
"bitmap",
"of",
"jpeg",
"file",
"and",
"convert",
"it",
"to",
"a",
":",
"ref",
":",
"knitting",
"pattern",
"file",
"<FileFormatSpecification",
">",
"."
] | python | valid |
nugget/python-anthemav | anthemav/protocol.py | https://github.com/nugget/python-anthemav/blob/c3cee38f2d452c1ab1335d9885e0769ec24d5f90/anthemav/protocol.py#L157-L167 | def connection_made(self, transport):
"""Called when asyncio.Protocol establishes the network connection."""
self.log.info('Connection established to AVR')
self.transport = transport
#self.transport.set_write_buffer_limits(0)
limit_low, limit_high = self.transport.get_write_buff... | [
"def",
"connection_made",
"(",
"self",
",",
"transport",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'Connection established to AVR'",
")",
"self",
".",
"transport",
"=",
"transport",
"#self.transport.set_write_buffer_limits(0)",
"limit_low",
",",
"limit_high",
... | Called when asyncio.Protocol establishes the network connection. | [
"Called",
"when",
"asyncio",
".",
"Protocol",
"establishes",
"the",
"network",
"connection",
"."
] | python | train |
blockstack/blockstack-core | blockstack/blockstackd.py | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L623-L650 | def get_name_record(self, name, include_expired=False, include_history=False):
"""
Get the whois-related info for a name (not a subdomain).
Optionally include the history.
Return {'status': True, 'record': rec} on success
Return {'error': ...} on error
"""
if not ... | [
"def",
"get_name_record",
"(",
"self",
",",
"name",
",",
"include_expired",
"=",
"False",
",",
"include_history",
"=",
"False",
")",
":",
"if",
"not",
"check_name",
"(",
"name",
")",
":",
"return",
"{",
"'error'",
":",
"'invalid name'",
",",
"'http_status'",... | Get the whois-related info for a name (not a subdomain).
Optionally include the history.
Return {'status': True, 'record': rec} on success
Return {'error': ...} on error | [
"Get",
"the",
"whois",
"-",
"related",
"info",
"for",
"a",
"name",
"(",
"not",
"a",
"subdomain",
")",
".",
"Optionally",
"include",
"the",
"history",
".",
"Return",
"{",
"status",
":",
"True",
"record",
":",
"rec",
"}",
"on",
"success",
"Return",
"{",
... | python | train |
PyThaiNLP/pythainlp | pythainlp/tokenize/tcc.py | https://github.com/PyThaiNLP/pythainlp/blob/e9a300b8a99dfd1a67a955e7c06f62e4afe0fbca/pythainlp/tokenize/tcc.py#L52-L69 | def tcc(text: str) -> str:
"""
TCC generator, generates Thai Character Clusters
:param str text: text to be tokenized to character clusters
:return: subword (character cluster)
"""
if not text or not isinstance(text, str):
return ""
p = 0
while p < len(text):
m = PAT_TCC... | [
"def",
"tcc",
"(",
"text",
":",
"str",
")",
"->",
"str",
":",
"if",
"not",
"text",
"or",
"not",
"isinstance",
"(",
"text",
",",
"str",
")",
":",
"return",
"\"\"",
"p",
"=",
"0",
"while",
"p",
"<",
"len",
"(",
"text",
")",
":",
"m",
"=",
"PAT_... | TCC generator, generates Thai Character Clusters
:param str text: text to be tokenized to character clusters
:return: subword (character cluster) | [
"TCC",
"generator",
"generates",
"Thai",
"Character",
"Clusters",
":",
"param",
"str",
"text",
":",
"text",
"to",
"be",
"tokenized",
"to",
"character",
"clusters",
":",
"return",
":",
"subword",
"(",
"character",
"cluster",
")"
] | python | train |
inveniosoftware/invenio-collections | invenio_collections/receivers.py | https://github.com/inveniosoftware/invenio-collections/blob/f3adca45c6d00a4dbf1f48fd501e8a68fe347f2f/invenio_collections/receivers.py#L74-L91 | def get_record_collections(record, matcher):
"""Return list of collections to which record belongs to.
:param record: Record instance.
:param matcher: Function used to check if a record belongs to a collection.
:return: list of collection names.
"""
collections = current_collections.collections... | [
"def",
"get_record_collections",
"(",
"record",
",",
"matcher",
")",
":",
"collections",
"=",
"current_collections",
".",
"collections",
"if",
"collections",
"is",
"None",
":",
"# build collections cache",
"collections",
"=",
"current_collections",
".",
"collections",
... | Return list of collections to which record belongs to.
:param record: Record instance.
:param matcher: Function used to check if a record belongs to a collection.
:return: list of collection names. | [
"Return",
"list",
"of",
"collections",
"to",
"which",
"record",
"belongs",
"to",
"."
] | python | train |
erikdejonge/arguments | examples/classbased.py | https://github.com/erikdejonge/arguments/blob/fc222d3989d459343a81944cabb56854014335ed/examples/classbased.py#L98-L111 | def main():
"""
main
"""
args = MainArguments()
if args.tool.lower() == "tool1":
args = Tool1Arguments()
elif args.tool.lower() == "tool2":
args = Tool2Arguments()
else:
print("Unknown tool", args.tool)
print(args) | [
"def",
"main",
"(",
")",
":",
"args",
"=",
"MainArguments",
"(",
")",
"if",
"args",
".",
"tool",
".",
"lower",
"(",
")",
"==",
"\"tool1\"",
":",
"args",
"=",
"Tool1Arguments",
"(",
")",
"elif",
"args",
".",
"tool",
".",
"lower",
"(",
")",
"==",
"... | main | [
"main"
] | python | train |
refenv/cijoe | modules/cij/reporter.py | https://github.com/refenv/cijoe/blob/21d7b2ed4ff68e0a1457e7df2db27f6334f1a379/modules/cij/reporter.py#L165-L174 | def process_tcase(tcase):
"""Goes through the trun and processes "run.log" """
tcase["src_content"] = src_to_html(tcase["fpath"])
tcase["log_content"] = runlogs_to_html(tcase["res_root"])
tcase["aux_list"] = aux_listing(tcase["aux_root"])
tcase["descr_short"], tcase["descr_long"] = tcase_parse_desc... | [
"def",
"process_tcase",
"(",
"tcase",
")",
":",
"tcase",
"[",
"\"src_content\"",
"]",
"=",
"src_to_html",
"(",
"tcase",
"[",
"\"fpath\"",
"]",
")",
"tcase",
"[",
"\"log_content\"",
"]",
"=",
"runlogs_to_html",
"(",
"tcase",
"[",
"\"res_root\"",
"]",
")",
"... | Goes through the trun and processes "run.log" | [
"Goes",
"through",
"the",
"trun",
"and",
"processes",
"run",
".",
"log"
] | python | valid |
Richienb/quilt | src/quilt_lang/__init__.py | https://github.com/Richienb/quilt/blob/4a659cac66f5286ad046d54a12fd850be5606643/src/quilt_lang/__init__.py#L1135-L1197 | def circleconvert(amount, currentformat, newformat):
"""
Convert a circle measurement.
:type amount: number
:param amount: The number to convert.
:type currentformat: string
:param currentformat: The format of the provided value.
:type newformat: string
:param newformat: The intended ... | [
"def",
"circleconvert",
"(",
"amount",
",",
"currentformat",
",",
"newformat",
")",
":",
"# If the same format was provided",
"if",
"currentformat",
".",
"lower",
"(",
")",
"==",
"newformat",
".",
"lower",
"(",
")",
":",
"# Return the provided value",
"return",
"a... | Convert a circle measurement.
:type amount: number
:param amount: The number to convert.
:type currentformat: string
:param currentformat: The format of the provided value.
:type newformat: string
:param newformat: The intended format of the value.
>>> circleconvert(45, "radius", "diamet... | [
"Convert",
"a",
"circle",
"measurement",
"."
] | python | train |
etal/biofrills | biofrills/pairutils.py | https://github.com/etal/biofrills/blob/36684bb6c7632f96215e8b2b4ebc86640f331bcd/biofrills/pairutils.py#L83-L116 | def score_pairwise(aseq, bseq):
"""Compute pairwise distances between two sequences (raw strings)."""
assert len(aseq) == len(bseq)
# Affine gap penalties -- default values from EMBOSS needle/water
GAP_OPEN = -10.0
GAP_EXTEND = -0.5
GAP_CHARS = frozenset('-.')
score = 0.0
in_gap = True... | [
"def",
"score_pairwise",
"(",
"aseq",
",",
"bseq",
")",
":",
"assert",
"len",
"(",
"aseq",
")",
"==",
"len",
"(",
"bseq",
")",
"# Affine gap penalties -- default values from EMBOSS needle/water",
"GAP_OPEN",
"=",
"-",
"10.0",
"GAP_EXTEND",
"=",
"-",
"0.5",
"GAP_... | Compute pairwise distances between two sequences (raw strings). | [
"Compute",
"pairwise",
"distances",
"between",
"two",
"sequences",
"(",
"raw",
"strings",
")",
"."
] | python | train |
hydpy-dev/hydpy | hydpy/exe/commandtools.py | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/exe/commandtools.py#L223-L284 | def execute_scriptfunction() -> None:
"""Execute a HydPy script function.
Function |execute_scriptfunction| is indirectly applied and
explained in the documentation on module |hyd|.
"""
try:
args_given = []
kwargs_given = {}
for arg in sys.argv[1:]:
if len(arg) <... | [
"def",
"execute_scriptfunction",
"(",
")",
"->",
"None",
":",
"try",
":",
"args_given",
"=",
"[",
"]",
"kwargs_given",
"=",
"{",
"}",
"for",
"arg",
"in",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
":",
"if",
"len",
"(",
"arg",
")",
"<",
"3",
":",
... | Execute a HydPy script function.
Function |execute_scriptfunction| is indirectly applied and
explained in the documentation on module |hyd|. | [
"Execute",
"a",
"HydPy",
"script",
"function",
"."
] | python | train |
tariqdaouda/pyGeno | pyGeno/tools/SegmentTree.py | https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/SegmentTree.py#L224-L229 | def removeGaps(self) :
"""Remove all gaps between regions"""
for i in range(1, len(self.children)) :
if self.children[i].x1 > self.children[i-1].x2:
aux_moveTree(self.children[i-1].x2-self.children[i].x1, self.children[i]) | [
"def",
"removeGaps",
"(",
"self",
")",
":",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"len",
"(",
"self",
".",
"children",
")",
")",
":",
"if",
"self",
".",
"children",
"[",
"i",
"]",
".",
"x1",
">",
"self",
".",
"children",
"[",
"i",
"-",
"1... | Remove all gaps between regions | [
"Remove",
"all",
"gaps",
"between",
"regions"
] | python | train |
ericpruitt/cronex | cronex/__init__.py | https://github.com/ericpruitt/cronex/blob/ff48a3a71bbcdf01cff46c0bf9376e69492c9224/cronex/__init__.py#L156-L261 | def check_trigger(self, date_tuple, utc_offset=0):
"""
Returns boolean indicating if the trigger is active at the given time.
The date tuple should be in the local time. Unless periodicities are
used, utc_offset does not need to be specified. If periodicities are
used, specifical... | [
"def",
"check_trigger",
"(",
"self",
",",
"date_tuple",
",",
"utc_offset",
"=",
"0",
")",
":",
"year",
",",
"month",
",",
"day",
",",
"hour",
",",
"mins",
"=",
"date_tuple",
"given_date",
"=",
"datetime",
".",
"date",
"(",
"year",
",",
"month",
",",
... | Returns boolean indicating if the trigger is active at the given time.
The date tuple should be in the local time. Unless periodicities are
used, utc_offset does not need to be specified. If periodicities are
used, specifically in the hour and minutes fields, it is crucial that
the utc_o... | [
"Returns",
"boolean",
"indicating",
"if",
"the",
"trigger",
"is",
"active",
"at",
"the",
"given",
"time",
".",
"The",
"date",
"tuple",
"should",
"be",
"in",
"the",
"local",
"time",
".",
"Unless",
"periodicities",
"are",
"used",
"utc_offset",
"does",
"not",
... | python | train |
StorjOld/pyp2p | pyp2p/rendezvous_server.py | https://github.com/StorjOld/pyp2p/blob/7024208c3af20511496a652ff212f54c420e0464/pyp2p/rendezvous_server.py#L108-L122 | def cleanup_candidates(self, node_ip):
"""
Removes old TCP hole punching candidates for a
designated node if a certain amount of time has passed
since they last connected.
"""
if node_ip in self.factory.candidates:
old_candidates = []
for c... | [
"def",
"cleanup_candidates",
"(",
"self",
",",
"node_ip",
")",
":",
"if",
"node_ip",
"in",
"self",
".",
"factory",
".",
"candidates",
":",
"old_candidates",
"=",
"[",
"]",
"for",
"candidate",
"in",
"self",
".",
"factory",
".",
"candidates",
"[",
"node_ip",... | Removes old TCP hole punching candidates for a
designated node if a certain amount of time has passed
since they last connected. | [
"Removes",
"old",
"TCP",
"hole",
"punching",
"candidates",
"for",
"a",
"designated",
"node",
"if",
"a",
"certain",
"amount",
"of",
"time",
"has",
"passed",
"since",
"they",
"last",
"connected",
"."
] | python | train |
numenta/htmresearch | htmresearch/algorithms/apical_tiebreak_temporal_memory.py | https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/htmresearch/algorithms/apical_tiebreak_temporal_memory.py#L410-L475 | def _calculateApicalLearning(self,
learningCells,
activeColumns,
activeApicalSegments,
matchingApicalSegments,
apicalPotentialOverlaps):
"""
Calculate apical... | [
"def",
"_calculateApicalLearning",
"(",
"self",
",",
"learningCells",
",",
"activeColumns",
",",
"activeApicalSegments",
",",
"matchingApicalSegments",
",",
"apicalPotentialOverlaps",
")",
":",
"# Cells with active apical segments",
"learningActiveApicalSegments",
"=",
"self",
... | Calculate apical learning for each learning cell.
The set of learning cells was determined completely from basal segments.
Do all apical learning on the same cells.
Learn on any active segments on learning cells. For cells without active
segments, learn on the best matching segment. For cells without ... | [
"Calculate",
"apical",
"learning",
"for",
"each",
"learning",
"cell",
"."
] | python | train |
dwavesystems/dwave-system | dwave/system/composites/embedding.py | https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/composites/embedding.py#L432-L434 | def _embed_state(embedding, state):
"""Embed a single state/sample by spreading it's values over the chains in the embedding"""
return {u: state[v] for v, chain in embedding.items() for u in chain} | [
"def",
"_embed_state",
"(",
"embedding",
",",
"state",
")",
":",
"return",
"{",
"u",
":",
"state",
"[",
"v",
"]",
"for",
"v",
",",
"chain",
"in",
"embedding",
".",
"items",
"(",
")",
"for",
"u",
"in",
"chain",
"}"
] | Embed a single state/sample by spreading it's values over the chains in the embedding | [
"Embed",
"a",
"single",
"state",
"/",
"sample",
"by",
"spreading",
"it",
"s",
"values",
"over",
"the",
"chains",
"in",
"the",
"embedding"
] | python | train |
launchdarkly/relayCommander | relay_commander/generators.py | https://github.com/launchdarkly/relayCommander/blob/eee7fa22f04edc3854dd53c3ec2db8c599ad1e89/relay_commander/generators.py#L20-L38 | def generate_relay_config(self, environments: list) -> None:
"""Generate ld-relay.conf file.
Given a list of environments of a project, this will generate a
``ld-relay.conf`` file in the current working directory. The conf file
follows the specification that is documented in the main `l... | [
"def",
"generate_relay_config",
"(",
"self",
",",
"environments",
":",
"list",
")",
"->",
"None",
":",
"template",
"=",
"self",
".",
"env",
".",
"get_template",
"(",
"'ld-relay.conf.jinja'",
")",
"with",
"open",
"(",
"'ld-relay.conf'",
",",
"'w'",
")",
"as",... | Generate ld-relay.conf file.
Given a list of environments of a project, this will generate a
``ld-relay.conf`` file in the current working directory. The conf file
follows the specification that is documented in the main `ld-relay`_
documentation.
.. _ld-relay: https://github.c... | [
"Generate",
"ld",
"-",
"relay",
".",
"conf",
"file",
"."
] | python | train |
Microsoft/azure-devops-python-api | azure-devops/azure/devops/v5_1/work_item_tracking/work_item_tracking_client.py | https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_1/work_item_tracking/work_item_tracking_client.py#L1180-L1204 | def get_updates(self, id, project=None, top=None, skip=None):
"""GetUpdates.
[Preview API] Returns a the deltas between work item revisions
:param int id:
:param str project: Project ID or project name
:param int top:
:param int skip:
:rtype: [WorkItemUpdate]
... | [
"def",
"get_updates",
"(",
"self",
",",
"id",
",",
"project",
"=",
"None",
",",
"top",
"=",
"None",
",",
"skip",
"=",
"None",
")",
":",
"route_values",
"=",
"{",
"}",
"if",
"project",
"is",
"not",
"None",
":",
"route_values",
"[",
"'project'",
"]",
... | GetUpdates.
[Preview API] Returns a the deltas between work item revisions
:param int id:
:param str project: Project ID or project name
:param int top:
:param int skip:
:rtype: [WorkItemUpdate] | [
"GetUpdates",
".",
"[",
"Preview",
"API",
"]",
"Returns",
"a",
"the",
"deltas",
"between",
"work",
"item",
"revisions",
":",
"param",
"int",
"id",
":",
":",
"param",
"str",
"project",
":",
"Project",
"ID",
"or",
"project",
"name",
":",
"param",
"int",
... | python | train |
wavefrontHQ/python-client | wavefront_api_client/api/webhook_api.py | https://github.com/wavefrontHQ/python-client/blob/b0f1046a8f68c2c7d69e395f7167241f224c738a/wavefront_api_client/api/webhook_api.py#L36-L56 | def create_webhook(self, **kwargs): # noqa: E501
"""Create a specific webhook # noqa: E501
# noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.create_webhook(async_req=True)
... | [
"def",
"create_webhook",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# noqa: E501",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'async_req'",
")",
":",
"return",
"self",
".",
"create_webhook_with_http_inf... | Create a specific webhook # noqa: E501
# noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.create_webhook(async_req=True)
>>> result = thread.get()
:param async_req bo... | [
"Create",
"a",
"specific",
"webhook",
"#",
"noqa",
":",
"E501"
] | python | train |
phac-nml/sistr_cmd | sistr/src/writers.py | https://github.com/phac-nml/sistr_cmd/blob/4630fae72439723b354a94b94fbe76ad2f9f6295/sistr/src/writers.py#L5-L22 | def listattrs(x):
"""Get all instance and class attributes for an object
Get all instance and class attributes for an object except those that start
with "__" (double underscore).
__dict__ of an object only reports the instance attributes while dir()
reports all of the attributes of an ob... | [
"def",
"listattrs",
"(",
"x",
")",
":",
"return",
"[",
"attr",
"for",
"attr",
"in",
"dir",
"(",
"x",
")",
"if",
"not",
"attr",
".",
"startswith",
"(",
"\"__\"",
")",
"and",
"not",
"callable",
"(",
"getattr",
"(",
"x",
",",
"attr",
")",
")",
"]"
] | Get all instance and class attributes for an object
Get all instance and class attributes for an object except those that start
with "__" (double underscore).
__dict__ of an object only reports the instance attributes while dir()
reports all of the attributes of an object including private on... | [
"Get",
"all",
"instance",
"and",
"class",
"attributes",
"for",
"an",
"object",
"Get",
"all",
"instance",
"and",
"class",
"attributes",
"for",
"an",
"object",
"except",
"those",
"that",
"start",
"with",
"__",
"(",
"double",
"underscore",
")",
".",
"__dict__",... | python | train |
xtuml/pyxtuml | bridgepoint/oal.py | https://github.com/xtuml/pyxtuml/blob/7dd9343b9a0191d1db1887ab9288d0a026608d9a/bridgepoint/oal.py#L975-L978 | def t_END_WHILE(self, t):
r"(?i)end[\s]+while"
t.endlexpos = t.lexpos + len(t.value)
return t | [
"def",
"t_END_WHILE",
"(",
"self",
",",
"t",
")",
":",
"t",
".",
"endlexpos",
"=",
"t",
".",
"lexpos",
"+",
"len",
"(",
"t",
".",
"value",
")",
"return",
"t"
] | r"(?i)end[\s]+while | [
"r",
"(",
"?i",
")",
"end",
"[",
"\\",
"s",
"]",
"+",
"while"
] | python | test |
diging/tethne | tethne/utilities.py | https://github.com/diging/tethne/blob/ba10eeb264b7a3f2dbcce71cfd5cb2d6bbf7055f/tethne/utilities.py#L184-L194 | def subdict(super_dict, keys):
"""
Returns a subset of the super_dict with the specified keys.
"""
sub_dict = {}
valid_keys = super_dict.keys()
for key in keys:
if key in valid_keys:
sub_dict[key] = super_dict[key]
return sub_dict | [
"def",
"subdict",
"(",
"super_dict",
",",
"keys",
")",
":",
"sub_dict",
"=",
"{",
"}",
"valid_keys",
"=",
"super_dict",
".",
"keys",
"(",
")",
"for",
"key",
"in",
"keys",
":",
"if",
"key",
"in",
"valid_keys",
":",
"sub_dict",
"[",
"key",
"]",
"=",
... | Returns a subset of the super_dict with the specified keys. | [
"Returns",
"a",
"subset",
"of",
"the",
"super_dict",
"with",
"the",
"specified",
"keys",
"."
] | python | train |
seequent/properties | properties/base/instance.py | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/base/instance.py#L161-L172 | def to_json(value, **kwargs):
"""Convert instance to JSON"""
if isinstance(value, HasProperties):
return value.serialize(**kwargs)
try:
return json.loads(json.dumps(value))
except TypeError:
raise TypeError(
"Cannot convert type {} to J... | [
"def",
"to_json",
"(",
"value",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"HasProperties",
")",
":",
"return",
"value",
".",
"serialize",
"(",
"*",
"*",
"kwargs",
")",
"try",
":",
"return",
"json",
".",
"loads",
"(",
... | Convert instance to JSON | [
"Convert",
"instance",
"to",
"JSON"
] | python | train |
RedFantom/ttkthemes | ttkthemes/_utils.py | https://github.com/RedFantom/ttkthemes/blob/e7fc354c02faf0e3eb4842d7f44131a1c43dd299/ttkthemes/_utils.py#L18-L49 | def temporary_chdir(new_dir):
"""
Like os.chdir(), but always restores the old working directory
For example, code like this...
old_curdir = os.getcwd()
os.chdir('stuff')
do_some_stuff()
os.chdir(old_curdir)
...leaves the current working directory unchanged if do_some_... | [
"def",
"temporary_chdir",
"(",
"new_dir",
")",
":",
"old_dir",
"=",
"os",
".",
"getcwd",
"(",
")",
"os",
".",
"chdir",
"(",
"new_dir",
")",
"try",
":",
"yield",
"finally",
":",
"os",
".",
"chdir",
"(",
"old_dir",
")"
] | Like os.chdir(), but always restores the old working directory
For example, code like this...
old_curdir = os.getcwd()
os.chdir('stuff')
do_some_stuff()
os.chdir(old_curdir)
...leaves the current working directory unchanged if do_some_stuff()
raises an error, so it should ... | [
"Like",
"os",
".",
"chdir",
"()",
"but",
"always",
"restores",
"the",
"old",
"working",
"directory"
] | python | train |
nion-software/nionswift-instrumentation-kit | nionswift_plugin/nion_instrumentation_ui/ScanControlPanel.py | https://github.com/nion-software/nionswift-instrumentation-kit/blob/b20c4fff17e840e8cb3d544705faf5bd05f1cbf7/nionswift_plugin/nion_instrumentation_ui/ScanControlPanel.py#L581-L590 | def size_to_content(self, horizontal_padding=None, vertical_padding=None):
""" Size the canvas item to the text content. """
if horizontal_padding is None:
horizontal_padding = 0
if vertical_padding is None:
vertical_padding = 0
self.sizing.set_fixed_size(Geome... | [
"def",
"size_to_content",
"(",
"self",
",",
"horizontal_padding",
"=",
"None",
",",
"vertical_padding",
"=",
"None",
")",
":",
"if",
"horizontal_padding",
"is",
"None",
":",
"horizontal_padding",
"=",
"0",
"if",
"vertical_padding",
"is",
"None",
":",
"vertical_p... | Size the canvas item to the text content. | [
"Size",
"the",
"canvas",
"item",
"to",
"the",
"text",
"content",
"."
] | python | train |
offu/WeRoBot | werobot/session/mysqlstorage.py | https://github.com/offu/WeRoBot/blob/fd42109105b03f9acf45ebd9dcabb9d5cff98f3c/werobot/session/mysqlstorage.py#L72-L88 | def set(self, id, value):
"""
根据 id 写入数据。
:param id: 要写入的 id
:param value: 要写入的数据,可以是一个 ``dict`` 对象
"""
value = json_dumps(value)
self.conn.cursor().execute(
"INSERT INTO WeRoBot (id, value) VALUES (%s,%s) \
ON DUPLICATE KEY UPDATE val... | [
"def",
"set",
"(",
"self",
",",
"id",
",",
"value",
")",
":",
"value",
"=",
"json_dumps",
"(",
"value",
")",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
".",
"execute",
"(",
"\"INSERT INTO WeRoBot (id, value) VALUES (%s,%s) \\\n ON DUPLICATE KEY U... | 根据 id 写入数据。
:param id: 要写入的 id
:param value: 要写入的数据,可以是一个 ``dict`` 对象 | [
"根据",
"id",
"写入数据。"
] | python | train |
boriel/zxbasic | arch/zx48k/backend/__16bit.py | https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__16bit.py#L620-L634 | def _ne16(ins):
''' Compares & pops top 2 operands out of the stack, and checks
if the 1st operand != 2nd operand (top of the stack).
Pushes 0 if False, 1 if True.
16 bit un/signed version
'''
output = _16bit_oper(ins.quad[2], ins.quad[3])
output.append('or a') # Resets carry f... | [
"def",
"_ne16",
"(",
"ins",
")",
":",
"output",
"=",
"_16bit_oper",
"(",
"ins",
".",
"quad",
"[",
"2",
"]",
",",
"ins",
".",
"quad",
"[",
"3",
"]",
")",
"output",
".",
"append",
"(",
"'or a'",
")",
"# Resets carry flag",
"output",
".",
"append",
"(... | Compares & pops top 2 operands out of the stack, and checks
if the 1st operand != 2nd operand (top of the stack).
Pushes 0 if False, 1 if True.
16 bit un/signed version | [
"Compares",
"&",
"pops",
"top",
"2",
"operands",
"out",
"of",
"the",
"stack",
"and",
"checks",
"if",
"the",
"1st",
"operand",
"!",
"=",
"2nd",
"operand",
"(",
"top",
"of",
"the",
"stack",
")",
".",
"Pushes",
"0",
"if",
"False",
"1",
"if",
"True",
"... | python | train |
3DLIRIOUS/MeshLabXML | examples/shield.py | https://github.com/3DLIRIOUS/MeshLabXML/blob/177cce21e92baca500f56a932d66bd9a33257af8/examples/shield.py#L38-L130 | def main():
"""Run main script"""
# segments = number of segments to use for circles
segments = 50
# star_points = number of points (or sides) of the star
star_points = 5
# star_radius = radius of circle circumscribing the star
star_radius = 2
# ring_thickness = thickness of the colored ... | [
"def",
"main",
"(",
")",
":",
"# segments = number of segments to use for circles",
"segments",
"=",
"50",
"# star_points = number of points (or sides) of the star",
"star_points",
"=",
"5",
"# star_radius = radius of circle circumscribing the star",
"star_radius",
"=",
"2",
"# rin... | Run main script | [
"Run",
"main",
"script"
] | python | test |
zkbt/the-friendly-stars | thefriendlystars/constellations/lspm.py | https://github.com/zkbt/the-friendly-stars/blob/50d3f979e79e63c66629065c75595696dc79802e/thefriendlystars/constellations/lspm.py#L73-L105 | def from_sky(cls, magnitudelimit=None):
'''
Create a Constellation from a criteria search of the whole sky.
Parameters
----------
magnitudelimit : float
Maximum magnitude (for Ve = "estimated V").
'''
# define a query for cone search surrounding thi... | [
"def",
"from_sky",
"(",
"cls",
",",
"magnitudelimit",
"=",
"None",
")",
":",
"# define a query for cone search surrounding this center",
"criteria",
"=",
"{",
"}",
"if",
"magnitudelimit",
"is",
"not",
"None",
":",
"criteria",
"[",
"cls",
".",
"defaultfilter",
"+",... | Create a Constellation from a criteria search of the whole sky.
Parameters
----------
magnitudelimit : float
Maximum magnitude (for Ve = "estimated V"). | [
"Create",
"a",
"Constellation",
"from",
"a",
"criteria",
"search",
"of",
"the",
"whole",
"sky",
"."
] | python | train |
apache/spark | python/pyspark/rdd.py | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L329-L342 | def flatMap(self, f, preservesPartitioning=False):
"""
Return a new RDD by first applying a function to all elements of this
RDD, and then flattening the results.
>>> rdd = sc.parallelize([2, 3, 4])
>>> sorted(rdd.flatMap(lambda x: range(1, x)).collect())
[1, 1, 1, 2, 2,... | [
"def",
"flatMap",
"(",
"self",
",",
"f",
",",
"preservesPartitioning",
"=",
"False",
")",
":",
"def",
"func",
"(",
"s",
",",
"iterator",
")",
":",
"return",
"chain",
".",
"from_iterable",
"(",
"map",
"(",
"fail_on_stopiteration",
"(",
"f",
")",
",",
"i... | Return a new RDD by first applying a function to all elements of this
RDD, and then flattening the results.
>>> rdd = sc.parallelize([2, 3, 4])
>>> sorted(rdd.flatMap(lambda x: range(1, x)).collect())
[1, 1, 1, 2, 2, 3]
>>> sorted(rdd.flatMap(lambda x: [(x, x), (x, x)]).collect(... | [
"Return",
"a",
"new",
"RDD",
"by",
"first",
"applying",
"a",
"function",
"to",
"all",
"elements",
"of",
"this",
"RDD",
"and",
"then",
"flattening",
"the",
"results",
"."
] | python | train |
openstack/networking-cisco | networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py | https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L799-L809 | def update_dcnm_net_info(self, tenant_id, direc, vlan_id,
segmentation_id):
"""Update the DCNM net info with allocated values of seg/vlan. """
net_dict = self.retrieve_dcnm_net_info(tenant_id, direc)
if not net_dict:
return None
net_dict['vlan_id'... | [
"def",
"update_dcnm_net_info",
"(",
"self",
",",
"tenant_id",
",",
"direc",
",",
"vlan_id",
",",
"segmentation_id",
")",
":",
"net_dict",
"=",
"self",
".",
"retrieve_dcnm_net_info",
"(",
"tenant_id",
",",
"direc",
")",
"if",
"not",
"net_dict",
":",
"return",
... | Update the DCNM net info with allocated values of seg/vlan. | [
"Update",
"the",
"DCNM",
"net",
"info",
"with",
"allocated",
"values",
"of",
"seg",
"/",
"vlan",
"."
] | python | train |
saltstack/salt | salt/modules/pcs.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pcs.py#L306-L323 | def prop_show(prop, extra_args=None, cibfile=None):
'''
Show the value of a cluster property
prop
name of the property
extra_args
additional options for the pcs property command
cibfile
use cibfile instead of the live CIB
CLI Example:
.. code-block:: bash
... | [
"def",
"prop_show",
"(",
"prop",
",",
"extra_args",
"=",
"None",
",",
"cibfile",
"=",
"None",
")",
":",
"return",
"item_show",
"(",
"item",
"=",
"'property'",
",",
"item_id",
"=",
"prop",
",",
"extra_args",
"=",
"extra_args",
",",
"cibfile",
"=",
"cibfil... | Show the value of a cluster property
prop
name of the property
extra_args
additional options for the pcs property command
cibfile
use cibfile instead of the live CIB
CLI Example:
.. code-block:: bash
salt '*' pcs.prop_show cibfile='/tmp/2_node_cluster.cib' prop='n... | [
"Show",
"the",
"value",
"of",
"a",
"cluster",
"property"
] | python | train |
mottosso/be | be/cli.py | https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/cli.py#L77-L274 | def in_(ctx, topics, yes, as_, enter):
"""Set the current topics to `topics`
Environment:
BE_PROJECT: First topic
BE_CWD: Current `be` working directory
BE_TOPICS: Arguments to `in`
BE_DEVELOPMENTDIR: Absolute path to current development directory
BE_PROJECTROOT: Absolut... | [
"def",
"in_",
"(",
"ctx",
",",
"topics",
",",
"yes",
",",
"as_",
",",
"enter",
")",
":",
"topics",
"=",
"map",
"(",
"str",
",",
"topics",
")",
"# They enter as unicode",
"if",
"self",
".",
"isactive",
"(",
")",
":",
"lib",
".",
"echo",
"(",
"\"ERRO... | Set the current topics to `topics`
Environment:
BE_PROJECT: First topic
BE_CWD: Current `be` working directory
BE_TOPICS: Arguments to `in`
BE_DEVELOPMENTDIR: Absolute path to current development directory
BE_PROJECTROOT: Absolute path to current project
BE_PROJECTSR... | [
"Set",
"the",
"current",
"topics",
"to",
"topics"
] | python | train |
marcocamma/datastorage | datastorage/datastorage.py | https://github.com/marcocamma/datastorage/blob/d88cdc08414c1c99d34d62e65fcbf807c3088a37/datastorage/datastorage.py#L158-L163 | def h5ToDict(h5, readH5pyDataset=True):
""" Read a hdf5 file into a dictionary """
h = h5py.File(h5, "r")
ret = unwrapArray(h, recursive=True, readH5pyDataset=readH5pyDataset)
if readH5pyDataset: h.close()
return ret | [
"def",
"h5ToDict",
"(",
"h5",
",",
"readH5pyDataset",
"=",
"True",
")",
":",
"h",
"=",
"h5py",
".",
"File",
"(",
"h5",
",",
"\"r\"",
")",
"ret",
"=",
"unwrapArray",
"(",
"h",
",",
"recursive",
"=",
"True",
",",
"readH5pyDataset",
"=",
"readH5pyDataset"... | Read a hdf5 file into a dictionary | [
"Read",
"a",
"hdf5",
"file",
"into",
"a",
"dictionary"
] | python | train |
ManiacalLabs/BiblioPixel | bibliopixel/project/recurse.py | https://github.com/ManiacalLabs/BiblioPixel/blob/fd97e6c651a4bbcade64733847f4eec8f7704b7c/bibliopixel/project/recurse.py#L20-L74 | def recurse(desc, pre='pre_recursion', post=None, python_path=None):
"""
Depth first recursion through a dictionary containing type constructors
The arguments pre, post and children are independently either:
* None, which means to do nothing
* a string, which means to use the static class method o... | [
"def",
"recurse",
"(",
"desc",
",",
"pre",
"=",
"'pre_recursion'",
",",
"post",
"=",
"None",
",",
"python_path",
"=",
"None",
")",
":",
"def",
"call",
"(",
"f",
",",
"desc",
")",
":",
"if",
"isinstance",
"(",
"f",
",",
"str",
")",
":",
"# f is the ... | Depth first recursion through a dictionary containing type constructors
The arguments pre, post and children are independently either:
* None, which means to do nothing
* a string, which means to use the static class method of that name on the
class being constructed, or
* a callable, to be call... | [
"Depth",
"first",
"recursion",
"through",
"a",
"dictionary",
"containing",
"type",
"constructors"
] | python | valid |
klavinslab/coral | coral/database/_rebase.py | https://github.com/klavinslab/coral/blob/17f59591211562a59a051f474cd6cecba4829df9/coral/database/_rebase.py#L15-L51 | def update(self):
'''Update definitions.'''
# Download http://rebase.neb.com/rebase/link_withref to tmp
self._tmpdir = tempfile.mkdtemp()
try:
self._rebase_file = self._tmpdir + '/rebase_file'
print 'Downloading latest enzyme definitions'
url = 'http:/... | [
"def",
"update",
"(",
"self",
")",
":",
"# Download http://rebase.neb.com/rebase/link_withref to tmp",
"self",
".",
"_tmpdir",
"=",
"tempfile",
".",
"mkdtemp",
"(",
")",
"try",
":",
"self",
".",
"_rebase_file",
"=",
"self",
".",
"_tmpdir",
"+",
"'/rebase_file'",
... | Update definitions. | [
"Update",
"definitions",
"."
] | python | train |
algolia/algoliasearch-django | algoliasearch_django/models.py | https://github.com/algolia/algoliasearch-django/blob/ca219db41eb56bdd1c0389cdc1508a41698958d7/algoliasearch_django/models.py#L330-L361 | def update_records(self, qs, batch_size=1000, **kwargs):
"""
Updates multiple records.
This method is optimized for speed. It takes a QuerySet and the same
arguments as QuerySet.update(). Optionnaly, you can specify the size
of the batch send to Algolia with batch_size (default ... | [
"def",
"update_records",
"(",
"self",
",",
"qs",
",",
"batch_size",
"=",
"1000",
",",
"*",
"*",
"kwargs",
")",
":",
"tmp",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"name",
"=",
"self",
".",
"__transl... | Updates multiple records.
This method is optimized for speed. It takes a QuerySet and the same
arguments as QuerySet.update(). Optionnaly, you can specify the size
of the batch send to Algolia with batch_size (default to 1000).
>>> from algoliasearch_django import update_records
... | [
"Updates",
"multiple",
"records",
"."
] | python | valid |
CxAalto/gtfspy | gtfspy/exports.py | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/exports.py#L30-L44 | def write_nodes(gtfs, output, fields=None):
"""
Parameters
----------
gtfs: gtfspy.GTFS
output: str
Path to the output file
fields: list, optional
which pieces of information to provide
"""
nodes = gtfs.get_table("stops")
if fields is not None:
nodes = nodes[f... | [
"def",
"write_nodes",
"(",
"gtfs",
",",
"output",
",",
"fields",
"=",
"None",
")",
":",
"nodes",
"=",
"gtfs",
".",
"get_table",
"(",
"\"stops\"",
")",
"if",
"fields",
"is",
"not",
"None",
":",
"nodes",
"=",
"nodes",
"[",
"fields",
"]",
"with",
"util"... | Parameters
----------
gtfs: gtfspy.GTFS
output: str
Path to the output file
fields: list, optional
which pieces of information to provide | [
"Parameters",
"----------",
"gtfs",
":",
"gtfspy",
".",
"GTFS",
"output",
":",
"str",
"Path",
"to",
"the",
"output",
"file",
"fields",
":",
"list",
"optional",
"which",
"pieces",
"of",
"information",
"to",
"provide"
] | python | valid |
hydpy-dev/hydpy | hydpy/auxs/anntools.py | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/auxs/anntools.py#L788-L803 | def verify(self) -> None:
"""Raise a |RuntimeError| if the network's shape is not defined
completely.
>>> from hydpy import ANN
>>> ANN(None).verify()
Traceback (most recent call last):
...
RuntimeError: The shape of the the artificial neural network \
parameter ... | [
"def",
"verify",
"(",
"self",
")",
"->",
"None",
":",
"if",
"not",
"self",
".",
"__protectedproperties",
".",
"allready",
"(",
"self",
")",
":",
"raise",
"RuntimeError",
"(",
"'The shape of the the artificial neural network '",
"'parameter %s has not been defined so far... | Raise a |RuntimeError| if the network's shape is not defined
completely.
>>> from hydpy import ANN
>>> ANN(None).verify()
Traceback (most recent call last):
...
RuntimeError: The shape of the the artificial neural network \
parameter `ann` of element `?` has not been def... | [
"Raise",
"a",
"|RuntimeError|",
"if",
"the",
"network",
"s",
"shape",
"is",
"not",
"defined",
"completely",
"."
] | python | train |
hsolbrig/sparql_slurper | sparql_slurper/_slurpygraph.py | https://github.com/hsolbrig/sparql_slurper/blob/9e338549337a6268d6f9c52e7fbf5b493b80cf59/sparql_slurper/_slurpygraph.py#L81-L122 | def triples(self, pattern: QueryTriple):
""" Return the triples that match pattern
:param pattern: `(s, p, o)` tuple, with `None` as wild cards
:return: Generator for resulting triples
"""
self.total_calls += 1
if self.graph_name is not None:
gn = "?g" if not... | [
"def",
"triples",
"(",
"self",
",",
"pattern",
":",
"QueryTriple",
")",
":",
"self",
".",
"total_calls",
"+=",
"1",
"if",
"self",
".",
"graph_name",
"is",
"not",
"None",
":",
"gn",
"=",
"\"?g\"",
"if",
"not",
"self",
".",
"graph_name",
"else",
"self",
... | Return the triples that match pattern
:param pattern: `(s, p, o)` tuple, with `None` as wild cards
:return: Generator for resulting triples | [
"Return",
"the",
"triples",
"that",
"match",
"pattern"
] | python | train |
widdowquinn/pyADHoRe | pyadhore/iadhore.py | https://github.com/widdowquinn/pyADHoRe/blob/b2ebbf6ae9c6afe9262eb0e3d9cf395970e38533/pyadhore/iadhore.py#L244-L259 | def is_redundant_multiplicon(self, value):
""" Returns True if the passed multiplicon ID is redundant, False
otherwise.
- value, (int) multiplicon ID
"""
if not hasattr(self, '_redundant_multiplicon_cache'):
sql = '''SELECT id FROM multiplicons WHERE is_redun... | [
"def",
"is_redundant_multiplicon",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_redundant_multiplicon_cache'",
")",
":",
"sql",
"=",
"'''SELECT id FROM multiplicons WHERE is_redundant=\"-1\"'''",
"cur",
"=",
"self",
".",
"_dbconn",... | Returns True if the passed multiplicon ID is redundant, False
otherwise.
- value, (int) multiplicon ID | [
"Returns",
"True",
"if",
"the",
"passed",
"multiplicon",
"ID",
"is",
"redundant",
"False",
"otherwise",
"."
] | python | train |
LISE-B26/pylabcontrol | build/lib/pylabcontrol/src/gui/qt_b26_widgets.py | https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/gui/qt_b26_widgets.py#L183-L230 | def setData(self, column, role, value):
"""
if value is valid sets the data to value
Args:
column: column of item
role: role of item (see Qt doc)
value: value to be set
"""
assert isinstance(column, int)
assert isinstance(role, int)
... | [
"def",
"setData",
"(",
"self",
",",
"column",
",",
"role",
",",
"value",
")",
":",
"assert",
"isinstance",
"(",
"column",
",",
"int",
")",
"assert",
"isinstance",
"(",
"role",
",",
"int",
")",
"# make sure that the right row is selected, this is not always the cas... | if value is valid sets the data to value
Args:
column: column of item
role: role of item (see Qt doc)
value: value to be set | [
"if",
"value",
"is",
"valid",
"sets",
"the",
"data",
"to",
"value",
"Args",
":",
"column",
":",
"column",
"of",
"item",
"role",
":",
"role",
"of",
"item",
"(",
"see",
"Qt",
"doc",
")",
"value",
":",
"value",
"to",
"be",
"set"
] | python | train |
phenomecentre/isaExplorer | isaExplorer/isaExplorer.py | https://github.com/phenomecentre/isaExplorer/blob/2fc817d53b6acba46918a0db8dd2f72e5e1d785e/isaExplorer/isaExplorer.py#L158-L183 | def dropStudyFromISA(studyNum, pathToISATABFile):
"""
This function removes a study from an ISA file
Typically, you should use the exploreISA function to check the contents
of the ISA file and retrieve the study number you are interested in!
Warning: this function deletes the given study and all its... | [
"def",
"dropStudyFromISA",
"(",
"studyNum",
",",
"pathToISATABFile",
")",
":",
"from",
"isatools",
"import",
"isatab",
"import",
"os",
"try",
":",
"isa",
"=",
"isatab",
".",
"load",
"(",
"pathToISATABFile",
",",
"skip_load_tables",
"=",
"True",
")",
"studies",... | This function removes a study from an ISA file
Typically, you should use the exploreISA function to check the contents
of the ISA file and retrieve the study number you are interested in!
Warning: this function deletes the given study and all its associated assays
:param studyNum: The Study number (noti... | [
"This",
"function",
"removes",
"a",
"study",
"from",
"an",
"ISA",
"file",
"Typically",
"you",
"should",
"use",
"the",
"exploreISA",
"function",
"to",
"check",
"the",
"contents",
"of",
"the",
"ISA",
"file",
"and",
"retrieve",
"the",
"study",
"number",
"you",
... | python | train |
acutesoftware/AIKIF | aikif/comms.py | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/comms.py#L43-L54 | def delete_channel(self, channel, pwd_hash):
"""
adds a channel, but must have authenication
"""
if channel.pwd_hash == pwd_hash:
self.channels.remove(channel)
lg.record_process('comms.py', 'Removed channel ' + channel.name)
return True
else:
... | [
"def",
"delete_channel",
"(",
"self",
",",
"channel",
",",
"pwd_hash",
")",
":",
"if",
"channel",
".",
"pwd_hash",
"==",
"pwd_hash",
":",
"self",
".",
"channels",
".",
"remove",
"(",
"channel",
")",
"lg",
".",
"record_process",
"(",
"'comms.py'",
",",
"'... | adds a channel, but must have authenication | [
"adds",
"a",
"channel",
"but",
"must",
"have",
"authenication"
] | python | train |
Pajinek/vhm | server/apps/xmlrpc/utils/vhlib_server.py | https://github.com/Pajinek/vhm/blob/e323e99855fd5c40fd61fba87c2646a1165505ed/server/apps/xmlrpc/utils/vhlib_server.py#L45-L53 | def check_size_all(self):
"""
Get size of homedir and update data on the server
"""
result = self.rpc_srv.get_all_account(self.token)
print "debug: %s" % result
for it in result:
size = getFolderSize(it["path"])
result = self.rpc_srv.set_account_si... | [
"def",
"check_size_all",
"(",
"self",
")",
":",
"result",
"=",
"self",
".",
"rpc_srv",
".",
"get_all_account",
"(",
"self",
".",
"token",
")",
"print",
"\"debug: %s\"",
"%",
"result",
"for",
"it",
"in",
"result",
":",
"size",
"=",
"getFolderSize",
"(",
"... | Get size of homedir and update data on the server | [
"Get",
"size",
"of",
"homedir",
"and",
"update",
"data",
"on",
"the",
"server"
] | python | train |
ScottDuckworth/python-anyvcs | anyvcs/hg.py | https://github.com/ScottDuckworth/python-anyvcs/blob/9eb09defbc6b7c99d373fad53cbf8fc81b637923/anyvcs/hg.py#L79-L83 | def create(cls, path):
"""Create a new repository"""
cmd = [HG, 'init', path]
subprocess.check_call(cmd)
return cls(path) | [
"def",
"create",
"(",
"cls",
",",
"path",
")",
":",
"cmd",
"=",
"[",
"HG",
",",
"'init'",
",",
"path",
"]",
"subprocess",
".",
"check_call",
"(",
"cmd",
")",
"return",
"cls",
"(",
"path",
")"
] | Create a new repository | [
"Create",
"a",
"new",
"repository"
] | python | train |
skorch-dev/skorch | skorch/net.py | https://github.com/skorch-dev/skorch/blob/5b9b8b7b7712cb6e5aaa759d9608ea6269d5bcd3/skorch/net.py#L387-L431 | def initialize_callbacks(self):
"""Initializes all callbacks and save the result in the
``callbacks_`` attribute.
Both ``default_callbacks`` and ``callbacks`` are used (in that
order). Callbacks may either be initialized or not, and if
they don't have a name, the name is inferre... | [
"def",
"initialize_callbacks",
"(",
"self",
")",
":",
"callbacks_",
"=",
"[",
"]",
"class",
"Dummy",
":",
"# We cannot use None as dummy value since None is a",
"# legitimate value to be set.",
"pass",
"for",
"name",
",",
"cb",
"in",
"self",
".",
"_uniquely_named_callba... | Initializes all callbacks and save the result in the
``callbacks_`` attribute.
Both ``default_callbacks`` and ``callbacks`` are used (in that
order). Callbacks may either be initialized or not, and if
they don't have a name, the name is inferred from the class
name. The ``initia... | [
"Initializes",
"all",
"callbacks",
"and",
"save",
"the",
"result",
"in",
"the",
"callbacks_",
"attribute",
"."
] | python | train |
apple/turicreate | src/unity/python/turicreate/toolkits/topic_model/topic_model.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/topic_model/topic_model.py#L396-L428 | def _training_stats(self):
"""
Return a dictionary of statistics collected during creation of the
model. These statistics are also available with the ``get`` method and
are described in more detail in that method's documentation.
Returns
-------
out : dict
... | [
"def",
"_training_stats",
"(",
"self",
")",
":",
"fields",
"=",
"self",
".",
"_list_fields",
"(",
")",
"stat_fields",
"=",
"[",
"'training_time'",
",",
"'training_iterations'",
"]",
"if",
"'validation_perplexity'",
"in",
"fields",
":",
"stat_fields",
".",
"appen... | Return a dictionary of statistics collected during creation of the
model. These statistics are also available with the ``get`` method and
are described in more detail in that method's documentation.
Returns
-------
out : dict
Dictionary of statistics compiled during ... | [
"Return",
"a",
"dictionary",
"of",
"statistics",
"collected",
"during",
"creation",
"of",
"the",
"model",
".",
"These",
"statistics",
"are",
"also",
"available",
"with",
"the",
"get",
"method",
"and",
"are",
"described",
"in",
"more",
"detail",
"in",
"that",
... | python | train |
google/grr | grr/client/grr_response_client/comms.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/comms.py#L1358-L1363 | def SavePrivateKey(self, private_key):
"""Store the new private key on disk."""
self.private_key = private_key
config.CONFIG.Set("Client.private_key",
self.private_key.SerializeToString())
config.CONFIG.Write() | [
"def",
"SavePrivateKey",
"(",
"self",
",",
"private_key",
")",
":",
"self",
".",
"private_key",
"=",
"private_key",
"config",
".",
"CONFIG",
".",
"Set",
"(",
"\"Client.private_key\"",
",",
"self",
".",
"private_key",
".",
"SerializeToString",
"(",
")",
")",
... | Store the new private key on disk. | [
"Store",
"the",
"new",
"private",
"key",
"on",
"disk",
"."
] | python | train |
mjirik/io3d | io3d/dcmreaddata.py | https://github.com/mjirik/io3d/blob/ccaf3e378dcc967f2565d477fc27583fd0f61fcc/io3d/dcmreaddata.py#L645-L656 | def print_series_info(self, series_info, minimal_series_number=1):
"""
Print series_info from dcmdirstats
"""
strinfo = ''
if len(series_info) > minimal_series_number:
for serie_number in series_info.keys():
strl = get_one_serie_info(series_info, serie... | [
"def",
"print_series_info",
"(",
"self",
",",
"series_info",
",",
"minimal_series_number",
"=",
"1",
")",
":",
"strinfo",
"=",
"''",
"if",
"len",
"(",
"series_info",
")",
">",
"minimal_series_number",
":",
"for",
"serie_number",
"in",
"series_info",
".",
"keys... | Print series_info from dcmdirstats | [
"Print",
"series_info",
"from",
"dcmdirstats"
] | python | train |
PRIArobotics/HedgehogUtils | hedgehog/utils/__init__.py | https://github.com/PRIArobotics/HedgehogUtils/blob/cc368df270288c870cc66d707696ccb62823ca9c/hedgehog/utils/__init__.py#L21-L103 | def coroutine(func):
"""
A decorator to wrap a generator function into a callable interface.
>>> @coroutine
... def sum(count):
... sum = 0
... for _ in range(0, count):
... # note that generator arguments are passed as a tuple, hence `num, = ...` instead... | [
"def",
"coroutine",
"(",
"func",
")",
":",
"def",
"decorator",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"generator",
"=",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"next",
"(",
"generator",
")",
"return",
"lambda",
"*",
... | A decorator to wrap a generator function into a callable interface.
>>> @coroutine
... def sum(count):
... sum = 0
... for _ in range(0, count):
... # note that generator arguments are passed as a tuple, hence `num, = ...` instead of `num = ...`
... ... | [
"A",
"decorator",
"to",
"wrap",
"a",
"generator",
"function",
"into",
"a",
"callable",
"interface",
"."
] | python | train |
bcbio/bcbio-nextgen | bcbio/ngsalign/minimap2.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/minimap2.py#L10-L42 | def align(fastq_file, pair_file, index_dir, names, align_dir, data):
"""Perform piped alignment of fastq input files, generating sorted, deduplicated BAM.
"""
umi_ext = "-cumi" if "umi_bam" in data else ""
out_file = os.path.join(align_dir, "{0}-sort{1}.bam".format(dd.get_sample_name(data), umi_ext))
... | [
"def",
"align",
"(",
"fastq_file",
",",
"pair_file",
",",
"index_dir",
",",
"names",
",",
"align_dir",
",",
"data",
")",
":",
"umi_ext",
"=",
"\"-cumi\"",
"if",
"\"umi_bam\"",
"in",
"data",
"else",
"\"\"",
"out_file",
"=",
"os",
".",
"path",
".",
"join",... | Perform piped alignment of fastq input files, generating sorted, deduplicated BAM. | [
"Perform",
"piped",
"alignment",
"of",
"fastq",
"input",
"files",
"generating",
"sorted",
"deduplicated",
"BAM",
"."
] | python | train |
KeplerGO/K2fov | K2fov/K2findCampaigns.py | https://github.com/KeplerGO/K2fov/blob/fb122b35687340e0357cba9e0dd47b3be0760693/K2fov/K2findCampaigns.py#L49-L86 | def findCampaignsByName(target):
"""Returns a list of the campaigns that cover a given target.
Parameters
----------
target : str
Name of the celestial object.
Returns
-------
campaigns : list of int
A list of the campaigns that cover the given target name.
ra, dec : f... | [
"def",
"findCampaignsByName",
"(",
"target",
")",
":",
"# Is AstroPy (optional dependency) installed?",
"try",
":",
"from",
"astropy",
".",
"coordinates",
"import",
"SkyCoord",
"from",
"astropy",
".",
"coordinates",
".",
"name_resolve",
"import",
"NameResolveError",
"fr... | Returns a list of the campaigns that cover a given target.
Parameters
----------
target : str
Name of the celestial object.
Returns
-------
campaigns : list of int
A list of the campaigns that cover the given target name.
ra, dec : float, float
Resolved coordinates... | [
"Returns",
"a",
"list",
"of",
"the",
"campaigns",
"that",
"cover",
"a",
"given",
"target",
"."
] | python | train |
JNRowe/upoints | upoints/utils.py | https://github.com/JNRowe/upoints/blob/1e4b7a53ed2a06cd854523d54c36aabdccea3830/upoints/utils.py#L206-L228 | def prepare_xml_read(data, objectify=False):
"""Prepare various input types for XML parsing.
Args:
data (iter): Data to read
objectify (bool): Parse using lxml's objectify data binding
Returns:
etree.ElementTree: Tree suitable for parsing
Raises:
TypeError: Invalid val... | [
"def",
"prepare_xml_read",
"(",
"data",
",",
"objectify",
"=",
"False",
")",
":",
"mod",
"=",
"_objectify",
"if",
"objectify",
"else",
"etree",
"if",
"hasattr",
"(",
"data",
",",
"'readlines'",
")",
":",
"data",
"=",
"mod",
".",
"parse",
"(",
"data",
"... | Prepare various input types for XML parsing.
Args:
data (iter): Data to read
objectify (bool): Parse using lxml's objectify data binding
Returns:
etree.ElementTree: Tree suitable for parsing
Raises:
TypeError: Invalid value for data | [
"Prepare",
"various",
"input",
"types",
"for",
"XML",
"parsing",
"."
] | python | train |
BlueBrain/NeuroM | neurom/check/neuron_checks.py | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/check/neuron_checks.py#L128-L147 | def has_all_nonzero_segment_lengths(neuron, threshold=0.0):
'''Check presence of neuron segments with length not above threshold
Arguments:
neuron(Neuron): The neuron object to test
threshold(float): value above which a segment length is considered to
be non-zero
Returns:
C... | [
"def",
"has_all_nonzero_segment_lengths",
"(",
"neuron",
",",
"threshold",
"=",
"0.0",
")",
":",
"bad_ids",
"=",
"[",
"]",
"for",
"sec",
"in",
"_nf",
".",
"iter_sections",
"(",
"neuron",
")",
":",
"p",
"=",
"sec",
".",
"points",
"for",
"i",
",",
"s",
... | Check presence of neuron segments with length not above threshold
Arguments:
neuron(Neuron): The neuron object to test
threshold(float): value above which a segment length is considered to
be non-zero
Returns:
CheckResult with result including list of (section_id, segment_id)
... | [
"Check",
"presence",
"of",
"neuron",
"segments",
"with",
"length",
"not",
"above",
"threshold"
] | python | train |
crossbario/txaio | txaio/aio.py | https://github.com/crossbario/txaio/blob/29c77ff1210cabd4cc03f16f34672612e7eef704/txaio/aio.py#L452-L474 | def make_batched_timer(self, bucket_seconds, chunk_size=100):
"""
Creates and returns an object implementing
:class:`txaio.IBatchedTimer`.
:param bucket_seconds: the number of seconds in each bucket. That
is, a value of 5 means that any timeout within a 5 second
... | [
"def",
"make_batched_timer",
"(",
"self",
",",
"bucket_seconds",
",",
"chunk_size",
"=",
"100",
")",
":",
"def",
"get_seconds",
"(",
")",
":",
"return",
"self",
".",
"_config",
".",
"loop",
".",
"time",
"(",
")",
"return",
"_BatchedTimer",
"(",
"bucket_sec... | Creates and returns an object implementing
:class:`txaio.IBatchedTimer`.
:param bucket_seconds: the number of seconds in each bucket. That
is, a value of 5 means that any timeout within a 5 second
window will be in the same bucket, and get notified at the
same time. ... | [
"Creates",
"and",
"returns",
"an",
"object",
"implementing",
":",
"class",
":",
"txaio",
".",
"IBatchedTimer",
"."
] | python | train |
manns/pyspread | pyspread/src/gui/_gui_interfaces.py | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_gui_interfaces.py#L132-L165 | def get_filepath_findex_from_user(self, wildcard, message, style,
filterindex=0):
"""Opens a file dialog and returns filepath and filterindex
Parameters
----------
wildcard: String
\tWildcard string for file dialog
message: String
... | [
"def",
"get_filepath_findex_from_user",
"(",
"self",
",",
"wildcard",
",",
"message",
",",
"style",
",",
"filterindex",
"=",
"0",
")",
":",
"dlg",
"=",
"wx",
".",
"FileDialog",
"(",
"self",
".",
"main_window",
",",
"wildcard",
"=",
"wildcard",
",",
"messag... | Opens a file dialog and returns filepath and filterindex
Parameters
----------
wildcard: String
\tWildcard string for file dialog
message: String
\tMessage in the file dialog
style: Integer
\tDialog style, e. g. wx.OPEN | wx.CHANGE_DIR
filterindex... | [
"Opens",
"a",
"file",
"dialog",
"and",
"returns",
"filepath",
"and",
"filterindex"
] | python | train |
NLeSC/noodles | noodles/lib/utility.py | https://github.com/NLeSC/noodles/blob/3759e24e6e54a3a1a364431309dbb1061f617c04/noodles/lib/utility.py#L111-L128 | def inverse_deep_map(f, root):
"""Sibling to |deep_map|. Recursively maps objects in a nested structure of
``list`` and ``dict`` objects. Where |deep_map| starts at the top,
|inverse_deep_map| starts at the bottom. First, if `root` is a ``list`` or
``dict``, its contents are |inverse_deep_map|ed. Then a... | [
"def",
"inverse_deep_map",
"(",
"f",
",",
"root",
")",
":",
"if",
"isinstance",
"(",
"root",
",",
"dict",
")",
":",
"r",
"=",
"{",
"k",
":",
"inverse_deep_map",
"(",
"f",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"root",
".",
"items",
"(",
")"... | Sibling to |deep_map|. Recursively maps objects in a nested structure of
``list`` and ``dict`` objects. Where |deep_map| starts at the top,
|inverse_deep_map| starts at the bottom. First, if `root` is a ``list`` or
``dict``, its contents are |inverse_deep_map|ed. Then at the end, the
entire object is pa... | [
"Sibling",
"to",
"|deep_map|",
".",
"Recursively",
"maps",
"objects",
"in",
"a",
"nested",
"structure",
"of",
"list",
"and",
"dict",
"objects",
".",
"Where",
"|deep_map|",
"starts",
"at",
"the",
"top",
"|inverse_deep_map|",
"starts",
"at",
"the",
"bottom",
"."... | python | train |
mitsei/dlkit | dlkit/handcar/type/managers.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/type/managers.py#L72-L93 | def get_type_admin_session(self):
"""Gets the OsidSession associated with the type admin service.
return: (osid.type.TypeAdminSession) - a TypeAdminSession
raise: OperationFailed - unable to complete request
raise: Unimplemented - supports_type_admin() is false
compliance: opt... | [
"def",
"get_type_admin_session",
"(",
"self",
")",
":",
"pass",
"if",
"not",
"self",
".",
"supports_type_admin",
"(",
")",
":",
"raise",
"Unimplemented",
"(",
")",
"try",
":",
"from",
".",
"import",
"sessions",
"except",
"ImportError",
":",
"raise",
"# Opera... | Gets the OsidSession associated with the type admin service.
return: (osid.type.TypeAdminSession) - a TypeAdminSession
raise: OperationFailed - unable to complete request
raise: Unimplemented - supports_type_admin() is false
compliance: optional - This method must be implemented if
... | [
"Gets",
"the",
"OsidSession",
"associated",
"with",
"the",
"type",
"admin",
"service",
"."
] | python | train |
6809/MC6809 | MC6809/components/memory.py | https://github.com/6809/MC6809/blob/6ba2f5106df46689017b5d0b6d84d43b7ee6a240/MC6809/components/memory.py#L311-L315 | def get(self, start, end):
"""
used in unittests
"""
return [self.read_byte(addr) for addr in range(start, end)] | [
"def",
"get",
"(",
"self",
",",
"start",
",",
"end",
")",
":",
"return",
"[",
"self",
".",
"read_byte",
"(",
"addr",
")",
"for",
"addr",
"in",
"range",
"(",
"start",
",",
"end",
")",
"]"
] | used in unittests | [
"used",
"in",
"unittests"
] | python | train |
saltstack/salt | salt/utils/openstack/neutron.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/neutron.py#L411-L420 | def create_subnet(self, network, cidr, name=None, ip_version=4):
'''
Creates a new subnet
'''
net_id = self._find_network_id(network)
body = {'cidr': cidr,
'ip_version': ip_version,
'network_id': net_id,
'name': name}
return... | [
"def",
"create_subnet",
"(",
"self",
",",
"network",
",",
"cidr",
",",
"name",
"=",
"None",
",",
"ip_version",
"=",
"4",
")",
":",
"net_id",
"=",
"self",
".",
"_find_network_id",
"(",
"network",
")",
"body",
"=",
"{",
"'cidr'",
":",
"cidr",
",",
"'ip... | Creates a new subnet | [
"Creates",
"a",
"new",
"subnet"
] | python | train |
tensorflow/tensorboard | tensorboard/program.py | https://github.com/tensorflow/tensorboard/blob/8e5f497b48e40f2a774f85416b8a35ac0693c35e/tensorboard/program.py#L149-L199 | def configure(self, argv=('',), **kwargs):
"""Configures TensorBoard behavior via flags.
This method will populate the "flags" property with an argparse.Namespace
representing flag values parsed from the provided argv list, overridden by
explicit flags from remaining keyword arguments.
Args:
... | [
"def",
"configure",
"(",
"self",
",",
"argv",
"=",
"(",
"''",
",",
")",
",",
"*",
"*",
"kwargs",
")",
":",
"parser",
"=",
"argparse_flags",
".",
"ArgumentParser",
"(",
"prog",
"=",
"'tensorboard'",
",",
"description",
"=",
"(",
"'TensorBoard is a suite of ... | Configures TensorBoard behavior via flags.
This method will populate the "flags" property with an argparse.Namespace
representing flag values parsed from the provided argv list, overridden by
explicit flags from remaining keyword arguments.
Args:
argv: Can be set to CLI args equivalent to sys.ar... | [
"Configures",
"TensorBoard",
"behavior",
"via",
"flags",
"."
] | python | train |
yougov/mongo-connector | mongo_connector/doc_managers/mongo_doc_manager.py | https://github.com/yougov/mongo-connector/blob/557cafd4b54c848cd54ef28a258391a154650cb4/mongo_connector/doc_managers/mongo_doc_manager.py#L115-L124 | def _meta_collections(self):
"""Provides the meta collections currently being used
"""
if self.use_single_meta_collection:
yield self.meta_collection_name
else:
for name in self.meta_database.collection_names(
include_system_collections=False
... | [
"def",
"_meta_collections",
"(",
"self",
")",
":",
"if",
"self",
".",
"use_single_meta_collection",
":",
"yield",
"self",
".",
"meta_collection_name",
"else",
":",
"for",
"name",
"in",
"self",
".",
"meta_database",
".",
"collection_names",
"(",
"include_system_col... | Provides the meta collections currently being used | [
"Provides",
"the",
"meta",
"collections",
"currently",
"being",
"used"
] | python | train |
pyGrowler/Growler | growler/http/parser.py | https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/http/parser.py#L280-L303 | def determine_newline(data):
"""
Looks for a newline character in bytestring parameter 'data'.
Currently only looks for strings '\r\n', '\n'. If '\n' is
found at the first position of the string, this raises an
exception.
Parameters:
data (bytes): The data to... | [
"def",
"determine_newline",
"(",
"data",
")",
":",
"line_end_pos",
"=",
"data",
".",
"find",
"(",
"b'\\n'",
")",
"if",
"line_end_pos",
"==",
"-",
"1",
":",
"return",
"None",
"elif",
"line_end_pos",
"==",
"0",
":",
"return",
"b'\\n'",
"prev_char",
"=",
"d... | Looks for a newline character in bytestring parameter 'data'.
Currently only looks for strings '\r\n', '\n'. If '\n' is
found at the first position of the string, this raises an
exception.
Parameters:
data (bytes): The data to be searched
Returns:
None: ... | [
"Looks",
"for",
"a",
"newline",
"character",
"in",
"bytestring",
"parameter",
"data",
".",
"Currently",
"only",
"looks",
"for",
"strings",
"\\",
"r",
"\\",
"n",
"\\",
"n",
".",
"If",
"\\",
"n",
"is",
"found",
"at",
"the",
"first",
"position",
"of",
"th... | python | train |
Kane610/axis | axis/rtsp.py | https://github.com/Kane610/axis/blob/b2b44ce595c7b722b5e13eabcab7b91f048e1808/axis/rtsp.py#L63-L68 | def stop(self):
"""Stop session."""
if self.transport:
self.transport.write(self.method.TEARDOWN().encode())
self.transport.close()
self.rtp.stop() | [
"def",
"stop",
"(",
"self",
")",
":",
"if",
"self",
".",
"transport",
":",
"self",
".",
"transport",
".",
"write",
"(",
"self",
".",
"method",
".",
"TEARDOWN",
"(",
")",
".",
"encode",
"(",
")",
")",
"self",
".",
"transport",
".",
"close",
"(",
"... | Stop session. | [
"Stop",
"session",
"."
] | python | train |
tomekwojcik/flask-htauth | flask_htauth/extension.py | https://github.com/tomekwojcik/flask-htauth/blob/bb89bee3fa7d88de3147ae338048624e01de710b/flask_htauth/extension.py#L81-L109 | def authenticated(viewfunc):
"""Decorate **viewfunc** with this decorator to require HTTP auth on the
view."""
@wraps(viewfunc)
def wrapper(*args, **kwargs):
ctx = stack.top
if ctx and hasattr(ctx, 'htauth'):
auth_header = request.headers.get('Authorization', None)
... | [
"def",
"authenticated",
"(",
"viewfunc",
")",
":",
"@",
"wraps",
"(",
"viewfunc",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"stack",
".",
"top",
"if",
"ctx",
"and",
"hasattr",
"(",
"ctx",
",",
"'htauth'... | Decorate **viewfunc** with this decorator to require HTTP auth on the
view. | [
"Decorate",
"**",
"viewfunc",
"**",
"with",
"this",
"decorator",
"to",
"require",
"HTTP",
"auth",
"on",
"the",
"view",
"."
] | python | train |
twilio/twilio-python | twilio/rest/voice/v1/dialing_permissions/country/__init__.py | https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/voice/v1/dialing_permissions/country/__init__.py#L115-L156 | def page(self, iso_code=values.unset, continent=values.unset,
country_code=values.unset, low_risk_numbers_enabled=values.unset,
high_risk_special_numbers_enabled=values.unset,
high_risk_tollfraud_numbers_enabled=values.unset,
page_token=values.unset, page_number=value... | [
"def",
"page",
"(",
"self",
",",
"iso_code",
"=",
"values",
".",
"unset",
",",
"continent",
"=",
"values",
".",
"unset",
",",
"country_code",
"=",
"values",
".",
"unset",
",",
"low_risk_numbers_enabled",
"=",
"values",
".",
"unset",
",",
"high_risk_special_n... | Retrieve a single page of CountryInstance records from the API.
Request is executed immediately
:param unicode iso_code: Filter to retrieve the country permissions by specifying the ISO country code
:param unicode continent: Filter to retrieve the country permissions by specifying the continent... | [
"Retrieve",
"a",
"single",
"page",
"of",
"CountryInstance",
"records",
"from",
"the",
"API",
".",
"Request",
"is",
"executed",
"immediately"
] | python | train |
pywbem/pywbem | pywbem/cim_obj.py | https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/pywbem/cim_obj.py#L705-L760 | def mofval(value, indent=MOF_INDENT, maxline=MAX_MOF_LINE, line_pos=0,
end_space=0):
"""
Low level function that returns the MOF representation of a non-string
value (i.e. a value that cannot not be split into multiple parts, for
example a numeric or boolean value).
If the MOF representa... | [
"def",
"mofval",
"(",
"value",
",",
"indent",
"=",
"MOF_INDENT",
",",
"maxline",
"=",
"MAX_MOF_LINE",
",",
"line_pos",
"=",
"0",
",",
"end_space",
"=",
"0",
")",
":",
"assert",
"isinstance",
"(",
"value",
",",
"six",
".",
"text_type",
")",
"# Check for o... | Low level function that returns the MOF representation of a non-string
value (i.e. a value that cannot not be split into multiple parts, for
example a numeric or boolean value).
If the MOF representation of the value does not fit into the remaining
space of the current line, it is put into a new line, ... | [
"Low",
"level",
"function",
"that",
"returns",
"the",
"MOF",
"representation",
"of",
"a",
"non",
"-",
"string",
"value",
"(",
"i",
".",
"e",
".",
"a",
"value",
"that",
"cannot",
"not",
"be",
"split",
"into",
"multiple",
"parts",
"for",
"example",
"a",
... | python | train |
NuGrid/NuGridPy | nugridpy/nugridse.py | https://github.com/NuGrid/NuGridPy/blob/eee8047446e398be77362d82c1d8b3310054fab0/nugridpy/nugridse.py#L779-L855 | def ernst_table_exporter(self, cycle, outfname='table_out',
sheetname='Sheet 1'):
"""
This routine takes NuGrid data (model output) for a given
cycle and writes it into an Excel sheet.
This is one format as requested by Ernst Zinner in June 2013
(thr... | [
"def",
"ernst_table_exporter",
"(",
"self",
",",
"cycle",
",",
"outfname",
"=",
"'table_out'",
",",
"sheetname",
"=",
"'Sheet 1'",
")",
":",
"from",
"xlsxwriter",
".",
"workbook",
"import",
"Workbook",
"# https://xlsxwriter.readthedocs.org/ Note: We neex xlswriter. Please... | This routine takes NuGrid data (model output) for a given
cycle and writes it into an Excel sheet.
This is one format as requested by Ernst Zinner in June 2013
(through Marco). If you want all radioactive isotopes, start
from the restart file. Empty columns are not written out and
... | [
"This",
"routine",
"takes",
"NuGrid",
"data",
"(",
"model",
"output",
")",
"for",
"a",
"given",
"cycle",
"and",
"writes",
"it",
"into",
"an",
"Excel",
"sheet",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.