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 |
|---|---|---|---|---|---|---|---|---|
chrisspen/dtree | dtree.py | https://github.com/chrisspen/dtree/blob/9e9c9992b22ad9a7e296af7e6837666b05db43ef/dtree.py#L530-L541 | def choose_attribute(data, attributes, class_attr, fitness, method):
"""
Cycles through all the attributes and returns the attribute with the
highest information gain (or lowest entropy).
"""
best = (-1e999999, None)
for attr in attributes:
if attr == class_attr:
continue
... | [
"def",
"choose_attribute",
"(",
"data",
",",
"attributes",
",",
"class_attr",
",",
"fitness",
",",
"method",
")",
":",
"best",
"=",
"(",
"-",
"1e999999",
",",
"None",
")",
"for",
"attr",
"in",
"attributes",
":",
"if",
"attr",
"==",
"class_attr",
":",
"... | Cycles through all the attributes and returns the attribute with the
highest information gain (or lowest entropy). | [
"Cycles",
"through",
"all",
"the",
"attributes",
"and",
"returns",
"the",
"attribute",
"with",
"the",
"highest",
"information",
"gain",
"(",
"or",
"lowest",
"entropy",
")",
"."
] | python | train |
Nic30/hwt | hwt/hdl/types/bitValFunctions.py | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/types/bitValFunctions.py#L91-L144 | def bitsCmp(self, other, op, evalFn=None):
"""
:attention: If other is Bool signal convert this to bool (not ideal,
due VHDL event operator)
"""
other = toHVal(other)
t = self._dtype
ot = other._dtype
iamVal = isinstance(self, Value)
otherIsVal = isinstance(other, Value)
if... | [
"def",
"bitsCmp",
"(",
"self",
",",
"other",
",",
"op",
",",
"evalFn",
"=",
"None",
")",
":",
"other",
"=",
"toHVal",
"(",
"other",
")",
"t",
"=",
"self",
".",
"_dtype",
"ot",
"=",
"other",
".",
"_dtype",
"iamVal",
"=",
"isinstance",
"(",
"self",
... | :attention: If other is Bool signal convert this to bool (not ideal,
due VHDL event operator) | [
":",
"attention",
":",
"If",
"other",
"is",
"Bool",
"signal",
"convert",
"this",
"to",
"bool",
"(",
"not",
"ideal",
"due",
"VHDL",
"event",
"operator",
")"
] | python | test |
tmoerman/arboreto | arboreto/core.py | https://github.com/tmoerman/arboreto/blob/3ff7b6f987b32e5774771751dea646fa6feaaa52/arboreto/core.py#L85-L102 | def to_tf_matrix(expression_matrix,
gene_names,
tf_names):
"""
:param expression_matrix: numpy matrix. Rows are observations and columns are genes.
:param gene_names: a list of gene names. Each entry corresponds to the expression_matrix column with same index.
:param tf... | [
"def",
"to_tf_matrix",
"(",
"expression_matrix",
",",
"gene_names",
",",
"tf_names",
")",
":",
"tuples",
"=",
"[",
"(",
"index",
",",
"gene",
")",
"for",
"index",
",",
"gene",
"in",
"enumerate",
"(",
"gene_names",
")",
"if",
"gene",
"in",
"tf_names",
"]"... | :param expression_matrix: numpy matrix. Rows are observations and columns are genes.
:param gene_names: a list of gene names. Each entry corresponds to the expression_matrix column with same index.
:param tf_names: a list of transcription factor names. Should be a subset of gene_names.
:return: tuple of:
... | [
":",
"param",
"expression_matrix",
":",
"numpy",
"matrix",
".",
"Rows",
"are",
"observations",
"and",
"columns",
"are",
"genes",
".",
":",
"param",
"gene_names",
":",
"a",
"list",
"of",
"gene",
"names",
".",
"Each",
"entry",
"corresponds",
"to",
"the",
"ex... | python | train |
ceph/ceph-deploy | ceph_deploy/mon.py | https://github.com/ceph/ceph-deploy/blob/86943fcc454cd4c99a86e3493e9e93a59c661fef/ceph_deploy/mon.py#L290-L304 | def hostname_is_compatible(conn, logger, provided_hostname):
"""
Make sure that the host that we are connecting to has the same value as the
`hostname` in the remote host, otherwise mons can fail not reaching quorum.
"""
logger.debug('determining if provided host has same hostname in remote')
re... | [
"def",
"hostname_is_compatible",
"(",
"conn",
",",
"logger",
",",
"provided_hostname",
")",
":",
"logger",
".",
"debug",
"(",
"'determining if provided host has same hostname in remote'",
")",
"remote_hostname",
"=",
"conn",
".",
"remote_module",
".",
"shortname",
"(",
... | Make sure that the host that we are connecting to has the same value as the
`hostname` in the remote host, otherwise mons can fail not reaching quorum. | [
"Make",
"sure",
"that",
"the",
"host",
"that",
"we",
"are",
"connecting",
"to",
"has",
"the",
"same",
"value",
"as",
"the",
"hostname",
"in",
"the",
"remote",
"host",
"otherwise",
"mons",
"can",
"fail",
"not",
"reaching",
"quorum",
"."
] | python | train |
calmjs/calmjs | src/calmjs/dist.py | https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/dist.py#L398-L484 | def build_helpers_module_registry_dependencies(registry_name='calmjs.module'):
"""
Return a tuple of funtions that will provide the functions that
return the relevant sets of module registry records based on the
dependencies defined for the provided packages.
"""
def get_module_registry_depende... | [
"def",
"build_helpers_module_registry_dependencies",
"(",
"registry_name",
"=",
"'calmjs.module'",
")",
":",
"def",
"get_module_registry_dependencies",
"(",
"pkg_names",
",",
"registry_name",
"=",
"registry_name",
",",
"working_set",
"=",
"None",
")",
":",
"\"\"\"\n ... | Return a tuple of funtions that will provide the functions that
return the relevant sets of module registry records based on the
dependencies defined for the provided packages. | [
"Return",
"a",
"tuple",
"of",
"funtions",
"that",
"will",
"provide",
"the",
"functions",
"that",
"return",
"the",
"relevant",
"sets",
"of",
"module",
"registry",
"records",
"based",
"on",
"the",
"dependencies",
"defined",
"for",
"the",
"provided",
"packages",
... | python | train |
stephanepechard/projy | projy/cmdline.py | https://github.com/stephanepechard/projy/blob/3146b0e3c207b977e1b51fcb33138746dae83c23/projy/cmdline.py#L11-L29 | def docopt_arguments():
""" Creates beautiful command-line interfaces.
See https://github.com/docopt/docopt """
doc = """Projy: Create templated project.
Usage: projy <template> <project> [<substitution>...]
projy -i | --info <template>
projy -l | --list
projy -h | ... | [
"def",
"docopt_arguments",
"(",
")",
":",
"doc",
"=",
"\"\"\"Projy: Create templated project.\n\n Usage: projy <template> <project> [<substitution>...]\n projy -i | --info <template>\n projy -l | --list\n projy -h | --help\n projy -v | --version\n\n Option... | Creates beautiful command-line interfaces.
See https://github.com/docopt/docopt | [
"Creates",
"beautiful",
"command",
"-",
"line",
"interfaces",
".",
"See",
"https",
":",
"//",
"github",
".",
"com",
"/",
"docopt",
"/",
"docopt"
] | python | train |
DataONEorg/d1_python | lib_common/src/d1_common/ext/mimeparser.py | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/ext/mimeparser.py#L50-L66 | def parse_mime_type(mime_type):
"""Carves up a mime-type and returns a tuple of the (type, subtype, params) where
'params' is a dictionary of all the parameters for the media range. For example, the
media range 'application/xhtml;q=0.5' would get parsed into:
('application', 'xhtml', {'q', '0.5'})
... | [
"def",
"parse_mime_type",
"(",
"mime_type",
")",
":",
"parts",
"=",
"mime_type",
".",
"split",
"(",
"\";\"",
")",
"params",
"=",
"dict",
"(",
"[",
"tuple",
"(",
"[",
"s",
".",
"strip",
"(",
")",
"for",
"s",
"in",
"param",
".",
"split",
"(",
"\"=\""... | Carves up a mime-type and returns a tuple of the (type, subtype, params) where
'params' is a dictionary of all the parameters for the media range. For example, the
media range 'application/xhtml;q=0.5' would get parsed into:
('application', 'xhtml', {'q', '0.5'}) | [
"Carves",
"up",
"a",
"mime",
"-",
"type",
"and",
"returns",
"a",
"tuple",
"of",
"the",
"(",
"type",
"subtype",
"params",
")",
"where",
"params",
"is",
"a",
"dictionary",
"of",
"all",
"the",
"parameters",
"for",
"the",
"media",
"range",
".",
"For",
"exa... | python | train |
Fantomas42/django-blog-zinnia | zinnia/xmlrpc/metaweblog.py | https://github.com/Fantomas42/django-blog-zinnia/blob/b4949304b104a8e1a7a7a0773cbfd024313c3a15/zinnia/xmlrpc/metaweblog.py#L127-L155 | def post_structure(entry, site):
"""
A post structure with extensions.
"""
author = entry.authors.all()[0]
return {'title': entry.title,
'description': six.text_type(entry.html_content),
'link': '%s://%s%s' % (PROTOCOL, site.domain,
entry.ge... | [
"def",
"post_structure",
"(",
"entry",
",",
"site",
")",
":",
"author",
"=",
"entry",
".",
"authors",
".",
"all",
"(",
")",
"[",
"0",
"]",
"return",
"{",
"'title'",
":",
"entry",
".",
"title",
",",
"'description'",
":",
"six",
".",
"text_type",
"(",
... | A post structure with extensions. | [
"A",
"post",
"structure",
"with",
"extensions",
"."
] | python | train |
alphatwirl/alphatwirl | alphatwirl/concurrently/WorkingArea.py | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/concurrently/WorkingArea.py#L62-L73 | def open(self):
"""Open the working area
Returns
-------
None
"""
self.path = self._prepare_dir(self.topdir)
self._copy_executable(area_path=self.path)
self._save_logging_levels(area_path=self.path)
self._put_python_modules(modules=self.python_mo... | [
"def",
"open",
"(",
"self",
")",
":",
"self",
".",
"path",
"=",
"self",
".",
"_prepare_dir",
"(",
"self",
".",
"topdir",
")",
"self",
".",
"_copy_executable",
"(",
"area_path",
"=",
"self",
".",
"path",
")",
"self",
".",
"_save_logging_levels",
"(",
"a... | Open the working area
Returns
-------
None | [
"Open",
"the",
"working",
"area"
] | python | valid |
DMSC-Instrument-Data/lewis | src/lewis/adapters/stream.py | https://github.com/DMSC-Instrument-Data/lewis/blob/931d96b8c761550a6a58f6e61e202690db04233a/src/lewis/adapters/stream.py#L734-L760 | def _bind_device(self):
"""
This method implements ``_bind_device`` from :class:`~lewis.core.devices.InterfaceBase`.
It binds Cmd and Var definitions to implementations in Interface and Device.
"""
patterns = set()
self.bound_commands = []
for cmd in self.comman... | [
"def",
"_bind_device",
"(",
"self",
")",
":",
"patterns",
"=",
"set",
"(",
")",
"self",
".",
"bound_commands",
"=",
"[",
"]",
"for",
"cmd",
"in",
"self",
".",
"commands",
":",
"bound",
"=",
"cmd",
".",
"bind",
"(",
"self",
")",
"or",
"cmd",
".",
... | This method implements ``_bind_device`` from :class:`~lewis.core.devices.InterfaceBase`.
It binds Cmd and Var definitions to implementations in Interface and Device. | [
"This",
"method",
"implements",
"_bind_device",
"from",
":",
"class",
":",
"~lewis",
".",
"core",
".",
"devices",
".",
"InterfaceBase",
".",
"It",
"binds",
"Cmd",
"and",
"Var",
"definitions",
"to",
"implementations",
"in",
"Interface",
"and",
"Device",
"."
] | python | train |
metavee/batchproc | batchproc/util.py | https://github.com/metavee/batchproc/blob/aa084a2ac8ab7950f7a7d3adb54b0cf010c6a935/batchproc/util.py#L11-L26 | def expand_folder(files):
"""Return a clone of file list files where all directories are recursively replaced with their contents."""
expfiles = []
for file in files:
if os.path.isdir(file):
for dirpath, dirnames, filenames in os.walk(file):
for filename in filenames:
... | [
"def",
"expand_folder",
"(",
"files",
")",
":",
"expfiles",
"=",
"[",
"]",
"for",
"file",
"in",
"files",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"file",
")",
":",
"for",
"dirpath",
",",
"dirnames",
",",
"filenames",
"in",
"os",
".",
"walk"... | Return a clone of file list files where all directories are recursively replaced with their contents. | [
"Return",
"a",
"clone",
"of",
"file",
"list",
"files",
"where",
"all",
"directories",
"are",
"recursively",
"replaced",
"with",
"their",
"contents",
"."
] | python | train |
inveniosoftware/invenio-previewer | invenio_previewer/extensions/zip.py | https://github.com/inveniosoftware/invenio-previewer/blob/558fd22e0f29cc8cd7a6999abd4febcf6b248c49/invenio_previewer/extensions/zip.py#L26-L67 | def make_tree(file):
"""Create tree structure from ZIP archive."""
max_files_count = current_app.config.get('PREVIEWER_ZIP_MAX_FILES', 1000)
tree = {'type': 'folder', 'id': -1, 'children': {}}
try:
with file.open() as fp:
zf = zipfile.ZipFile(fp)
# Detect filenames encod... | [
"def",
"make_tree",
"(",
"file",
")",
":",
"max_files_count",
"=",
"current_app",
".",
"config",
".",
"get",
"(",
"'PREVIEWER_ZIP_MAX_FILES'",
",",
"1000",
")",
"tree",
"=",
"{",
"'type'",
":",
"'folder'",
",",
"'id'",
":",
"-",
"1",
",",
"'children'",
"... | Create tree structure from ZIP archive. | [
"Create",
"tree",
"structure",
"from",
"ZIP",
"archive",
"."
] | python | train |
ninuxorg/nodeshot | nodeshot/community/mailing/models/outward.py | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/mailing/models/outward.py#L67-L166 | def get_recipients(self):
"""
Determine recipients depending on selected filtering which can be either:
* group based
* layer based
* user based
Choosing "group" and "layer" filtering together has the effect of sending the message
only to users for wh... | [
"def",
"get_recipients",
"(",
"self",
")",
":",
"# user model",
"User",
"=",
"get_user_model",
"(",
")",
"# prepare email list",
"emails",
"=",
"[",
"]",
"# the following code is a bit ugly. Considering the titanic amount of work required to build all",
"# the cools functionaliti... | Determine recipients depending on selected filtering which can be either:
* group based
* layer based
* user based
Choosing "group" and "layer" filtering together has the effect of sending the message
only to users for which the following conditions are both true:
... | [
"Determine",
"recipients",
"depending",
"on",
"selected",
"filtering",
"which",
"can",
"be",
"either",
":",
"*",
"group",
"based",
"*",
"layer",
"based",
"*",
"user",
"based"
] | python | train |
gwastro/pycbc-glue | pycbc_glue/ligolw/array.py | https://github.com/gwastro/pycbc-glue/blob/a3e906bae59fbfd707c3ff82e5d008d939ec5e24/pycbc_glue/ligolw/array.py#L117-L151 | def from_array(name, array, dim_names = None):
"""
Construct a LIGO Light Weight XML Array document subtree from a
numpy array object.
Example:
>>> import numpy, sys
>>> a = numpy.arange(12, dtype = "double")
>>> a.shape = (4, 3)
>>> from_array(u"test", a).write(sys.stdout) # doctest: +NORMALIZE_WHITESPACE
<... | [
"def",
"from_array",
"(",
"name",
",",
"array",
",",
"dim_names",
"=",
"None",
")",
":",
"# Type must be set for .__init__(); easier to set Name afterwards",
"# to take advantage of encoding handled by attribute proxy",
"doc",
"=",
"Array",
"(",
"Attributes",
"(",
"{",
"u\... | Construct a LIGO Light Weight XML Array document subtree from a
numpy array object.
Example:
>>> import numpy, sys
>>> a = numpy.arange(12, dtype = "double")
>>> a.shape = (4, 3)
>>> from_array(u"test", a).write(sys.stdout) # doctest: +NORMALIZE_WHITESPACE
<Array Type="real_8" Name="test:array">
<Dim>3</Dim>... | [
"Construct",
"a",
"LIGO",
"Light",
"Weight",
"XML",
"Array",
"document",
"subtree",
"from",
"a",
"numpy",
"array",
"object",
"."
] | python | train |
pecan/pecan | pecan/decorators.py | https://github.com/pecan/pecan/blob/833d0653fa0e6bbfb52545b091c30182105f4a82/pecan/decorators.py#L25-L95 | def expose(template=None,
generic=False,
route=None,
**kw):
'''
Decorator used to flag controller methods as being "exposed" for
access via HTTP, and to configure that access.
:param template: The path to a template, relative to the base template
d... | [
"def",
"expose",
"(",
"template",
"=",
"None",
",",
"generic",
"=",
"False",
",",
"route",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"content_type",
"=",
"kw",
".",
"get",
"(",
"'content_type'",
",",
"'text/html'",
")",
"if",
"template",
"==",
"'js... | Decorator used to flag controller methods as being "exposed" for
access via HTTP, and to configure that access.
:param template: The path to a template, relative to the base template
directory. Can also be passed a string representing
a special or custom renderer, suc... | [
"Decorator",
"used",
"to",
"flag",
"controller",
"methods",
"as",
"being",
"exposed",
"for",
"access",
"via",
"HTTP",
"and",
"to",
"configure",
"that",
"access",
"."
] | python | train |
adaptive-learning/proso-apps | proso_user/views.py | https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_user/views.py#L341-L370 | def initmobile_view(request):
"""
Create lazy user with a password. Used from the Android app.
Also returns csrf token.
GET parameters:
username:
user's name
password:
user's password
"""
if 'username' in request.GET and 'password' in request.GET:
... | [
"def",
"initmobile_view",
"(",
"request",
")",
":",
"if",
"'username'",
"in",
"request",
".",
"GET",
"and",
"'password'",
"in",
"request",
".",
"GET",
":",
"username",
"=",
"request",
".",
"GET",
"[",
"'username'",
"]",
"password",
"=",
"request",
".",
"... | Create lazy user with a password. Used from the Android app.
Also returns csrf token.
GET parameters:
username:
user's name
password:
user's password | [
"Create",
"lazy",
"user",
"with",
"a",
"password",
".",
"Used",
"from",
"the",
"Android",
"app",
".",
"Also",
"returns",
"csrf",
"token",
"."
] | python | train |
softlayer/softlayer-python | SoftLayer/auth.py | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/auth.py#L50-L57 | def get_request(self, request):
"""Sets token-based auth headers."""
request.headers['authenticate'] = {
'complexType': 'PortalLoginToken',
'userId': self.user_id,
'authToken': self.auth_token,
}
return request | [
"def",
"get_request",
"(",
"self",
",",
"request",
")",
":",
"request",
".",
"headers",
"[",
"'authenticate'",
"]",
"=",
"{",
"'complexType'",
":",
"'PortalLoginToken'",
",",
"'userId'",
":",
"self",
".",
"user_id",
",",
"'authToken'",
":",
"self",
".",
"a... | Sets token-based auth headers. | [
"Sets",
"token",
"-",
"based",
"auth",
"headers",
"."
] | python | train |
loli/medpy | medpy/core/logger.py | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/core/logger.py#L103-L119 | def setHandler(self, hdlr):
r"""Replace the current handler with a new one.
Parameters
----------
hdlr : logging.Handler
A subclass of Handler that should used to handle the logging output.
Notes
-----
If none should be replaces, but... | [
"def",
"setHandler",
"(",
"self",
",",
"hdlr",
")",
":",
"if",
"None",
"!=",
"self",
".",
"_handler",
":",
"self",
".",
"removeHandler",
"(",
"self",
".",
"_handler",
")",
"self",
".",
"_handler",
"=",
"hdlr",
"self",
".",
"addHandler",
"(",
"self",
... | r"""Replace the current handler with a new one.
Parameters
----------
hdlr : logging.Handler
A subclass of Handler that should used to handle the logging output.
Notes
-----
If none should be replaces, but just one added, use the parent clas... | [
"r",
"Replace",
"the",
"current",
"handler",
"with",
"a",
"new",
"one",
".",
"Parameters",
"----------",
"hdlr",
":",
"logging",
".",
"Handler",
"A",
"subclass",
"of",
"Handler",
"that",
"should",
"used",
"to",
"handle",
"the",
"logging",
"output",
".",
"N... | python | train |
SergeySatskiy/cdm-pythonparser | legacy/src/cdmbriefparser.py | https://github.com/SergeySatskiy/cdm-pythonparser/blob/7e933aca899b1853d744082313ffc3a8b1154505/legacy/src/cdmbriefparser.py#L540-L546 | def _onDecorator( self, name, line, pos, absPosition ):
" Memorizes a function or a class decorator "
# A class or a function must be on the top of the stack
self.objectsStack[ -1 ].decorators.append(
Decorator( name, line, pos,
... | [
"def",
"_onDecorator",
"(",
"self",
",",
"name",
",",
"line",
",",
"pos",
",",
"absPosition",
")",
":",
"# A class or a function must be on the top of the stack",
"self",
".",
"objectsStack",
"[",
"-",
"1",
"]",
".",
"decorators",
".",
"append",
"(",
"Decorator"... | Memorizes a function or a class decorator | [
"Memorizes",
"a",
"function",
"or",
"a",
"class",
"decorator"
] | python | train |
Qiskit/qiskit-terra | qiskit/converters/ast_to_dag.py | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/converters/ast_to_dag.py#L214-L304 | def _process_node(self, node):
"""Carry out the action associated with a node."""
if node.type == "program":
self._process_children(node)
elif node.type == "qreg":
qreg = QuantumRegister(node.index, node.name)
self.dag.add_qreg(qreg)
elif node.type =... | [
"def",
"_process_node",
"(",
"self",
",",
"node",
")",
":",
"if",
"node",
".",
"type",
"==",
"\"program\"",
":",
"self",
".",
"_process_children",
"(",
"node",
")",
"elif",
"node",
".",
"type",
"==",
"\"qreg\"",
":",
"qreg",
"=",
"QuantumRegister",
"(",
... | Carry out the action associated with a node. | [
"Carry",
"out",
"the",
"action",
"associated",
"with",
"a",
"node",
"."
] | python | test |
saltstack/salt | salt/modules/win_iis.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_iis.py#L197-L264 | def list_sites():
'''
List all the currently deployed websites.
Returns:
dict: A dictionary of the IIS sites and their properties.
CLI Example:
.. code-block:: bash
salt '*' win_iis.list_sites
'''
ret = dict()
ps_cmd = ['Get-ChildItem',
'-Path', r"'IIS:\... | [
"def",
"list_sites",
"(",
")",
":",
"ret",
"=",
"dict",
"(",
")",
"ps_cmd",
"=",
"[",
"'Get-ChildItem'",
",",
"'-Path'",
",",
"r\"'IIS:\\Sites'\"",
",",
"'|'",
",",
"'Select-Object applicationPool, applicationDefaults, Bindings, ID, Name, PhysicalPath, State'",
"]",
"ke... | List all the currently deployed websites.
Returns:
dict: A dictionary of the IIS sites and their properties.
CLI Example:
.. code-block:: bash
salt '*' win_iis.list_sites | [
"List",
"all",
"the",
"currently",
"deployed",
"websites",
"."
] | python | train |
Bearle/django-private-chat | django_private_chat/handlers.py | https://github.com/Bearle/django-private-chat/blob/5b51e65875795c5c0ce21bb631c53bd3aac4c26b/django_private_chat/handlers.py#L14-L24 | def target_message(conn, payload):
"""
Distibuted payload (message) to one connection
:param conn: connection
:param payload: payload(json dumpable)
:return:
"""
try:
yield from conn.send(json.dumps(payload))
except Exception as e:
logger.debug('could not send',... | [
"def",
"target_message",
"(",
"conn",
",",
"payload",
")",
":",
"try",
":",
"yield",
"from",
"conn",
".",
"send",
"(",
"json",
".",
"dumps",
"(",
"payload",
")",
")",
"except",
"Exception",
"as",
"e",
":",
"logger",
".",
"debug",
"(",
"'could not send'... | Distibuted payload (message) to one connection
:param conn: connection
:param payload: payload(json dumpable)
:return: | [
"Distibuted",
"payload",
"(",
"message",
")",
"to",
"one",
"connection",
":",
"param",
"conn",
":",
"connection",
":",
"param",
"payload",
":",
"payload",
"(",
"json",
"dumpable",
")",
":",
"return",
":"
] | python | train |
projecthamster/hamster | src/hamster/lib/stuff.py | https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/lib/stuff.py#L85-L121 | def format_duration(minutes, human = True):
"""formats duration in a human readable format.
accepts either minutes or timedelta"""
if isinstance(minutes, dt.timedelta):
minutes = duration_minutes(minutes)
if not minutes:
if human:
return ""
else:
return ... | [
"def",
"format_duration",
"(",
"minutes",
",",
"human",
"=",
"True",
")",
":",
"if",
"isinstance",
"(",
"minutes",
",",
"dt",
".",
"timedelta",
")",
":",
"minutes",
"=",
"duration_minutes",
"(",
"minutes",
")",
"if",
"not",
"minutes",
":",
"if",
"human",... | formats duration in a human readable format.
accepts either minutes or timedelta | [
"formats",
"duration",
"in",
"a",
"human",
"readable",
"format",
".",
"accepts",
"either",
"minutes",
"or",
"timedelta"
] | python | train |
chrisspen/burlap | burlap/deploy.py | https://github.com/chrisspen/burlap/blob/a92b0a8e5206850bb777c74af8421ea8b33779bd/burlap/deploy.py#L21-L30 | def iter_dict_differences(a, b):
"""
Returns a generator yielding all the keys that have values that differ between each dictionary.
"""
common_keys = set(a).union(b)
for k in common_keys:
a_value = a.get(k)
b_value = b.get(k)
if a_value != b_value:
yield k, (a_va... | [
"def",
"iter_dict_differences",
"(",
"a",
",",
"b",
")",
":",
"common_keys",
"=",
"set",
"(",
"a",
")",
".",
"union",
"(",
"b",
")",
"for",
"k",
"in",
"common_keys",
":",
"a_value",
"=",
"a",
".",
"get",
"(",
"k",
")",
"b_value",
"=",
"b",
".",
... | Returns a generator yielding all the keys that have values that differ between each dictionary. | [
"Returns",
"a",
"generator",
"yielding",
"all",
"the",
"keys",
"that",
"have",
"values",
"that",
"differ",
"between",
"each",
"dictionary",
"."
] | python | valid |
tomplus/kubernetes_asyncio | kubernetes_asyncio/client/api/storage_v1_api.py | https://github.com/tomplus/kubernetes_asyncio/blob/f9ab15317ec921409714c7afef11aeb0f579985d/kubernetes_asyncio/client/api/storage_v1_api.py#L35-L58 | def create_storage_class(self, body, **kwargs): # noqa: E501
"""create_storage_class # noqa: E501
create a StorageClass # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.crea... | [
"def",
"create_storage_class",
"(",
"self",
",",
"body",
",",
"*",
"*",
"kwargs",
")",
":",
"# noqa: E501",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'async_req'",
")",
":",
"return",
"self",
".",
"creat... | create_storage_class # noqa: E501
create a StorageClass # 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_storage_class(body, async_req=True)
>>> result = thread.get()
... | [
"create_storage_class",
"#",
"noqa",
":",
"E501"
] | python | train |
AndrewAnnex/SpiceyPy | spiceypy/spiceypy.py | https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L6809-L6832 | def hx2dp(string):
"""
Convert a string representing a double precision number in a
base 16 scientific notation into its equivalent double
precision number.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/hx2dp_c.html
:param string: Hex form string to convert to double precision.
:... | [
"def",
"hx2dp",
"(",
"string",
")",
":",
"string",
"=",
"stypes",
".",
"stringToCharP",
"(",
"string",
")",
"lenout",
"=",
"ctypes",
".",
"c_int",
"(",
"80",
")",
"errmsg",
"=",
"stypes",
".",
"stringToCharP",
"(",
"lenout",
")",
"number",
"=",
"ctypes... | Convert a string representing a double precision number in a
base 16 scientific notation into its equivalent double
precision number.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/hx2dp_c.html
:param string: Hex form string to convert to double precision.
:type string: str
:return: D... | [
"Convert",
"a",
"string",
"representing",
"a",
"double",
"precision",
"number",
"in",
"a",
"base",
"16",
"scientific",
"notation",
"into",
"its",
"equivalent",
"double",
"precision",
"number",
"."
] | python | train |
mikusjelly/apkutils | apkutils/apkfile.py | https://github.com/mikusjelly/apkutils/blob/2db1ed0cdb610dfc55bfd77266e9a91e4764bba4/apkutils/apkfile.py#L1394-L1415 | def _writecheck(self, zinfo):
"""Check for errors before writing a file to the archive."""
if zinfo.filename in self.NameToInfo:
import warnings
warnings.warn('Duplicate name: %r' % zinfo.filename, stacklevel=3)
if self.mode not in ('w', 'x', 'a'):
raise Runti... | [
"def",
"_writecheck",
"(",
"self",
",",
"zinfo",
")",
":",
"if",
"zinfo",
".",
"filename",
"in",
"self",
".",
"NameToInfo",
":",
"import",
"warnings",
"warnings",
".",
"warn",
"(",
"'Duplicate name: %r'",
"%",
"zinfo",
".",
"filename",
",",
"stacklevel",
"... | Check for errors before writing a file to the archive. | [
"Check",
"for",
"errors",
"before",
"writing",
"a",
"file",
"to",
"the",
"archive",
"."
] | python | train |
androguard/androguard | generators/axplorer_to_androguard.py | https://github.com/androguard/androguard/blob/984c0d981be2950cf0451e484f7b0d4d53bc4911/generators/axplorer_to_androguard.py#L18-L53 | def name_to_androguard(n):
"""
Convert a object or primitive name into androguard syntax
For example:
byte --> B
foo.bar.bla --> Lfoo/bar/bla;
[int --> [I
There is also a special case, where some arrays are specified differently:
B[] --> [B
foo.bar.bla[] --> [Lf... | [
"def",
"name_to_androguard",
"(",
"n",
")",
":",
"if",
"n",
"==",
"\"\"",
":",
"return",
"\"\"",
"is_array",
"=",
"\"\"",
"# FIXME what about n-dimensional arrays?",
"if",
"n",
".",
"startswith",
"(",
"\"[\"",
")",
":",
"is_array",
"=",
"\"[\"",
"n",
"=",
... | Convert a object or primitive name into androguard syntax
For example:
byte --> B
foo.bar.bla --> Lfoo/bar/bla;
[int --> [I
There is also a special case, where some arrays are specified differently:
B[] --> [B
foo.bar.bla[] --> [Lfoo/bar/bla;
:param n:
:return: | [
"Convert",
"a",
"object",
"or",
"primitive",
"name",
"into",
"androguard",
"syntax"
] | python | train |
OLC-Bioinformatics/sipprverse | MLSTsippr/mlst.py | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/MLSTsippr/mlst.py#L519-L556 | def report_parse(self):
"""
If the pipeline has previously been run on these data, instead of reading through the results, parse the
report instead
"""
# Initialise lists
report_strains = list()
genus_list = list()
if self.analysistype == 'mlst':
... | [
"def",
"report_parse",
"(",
"self",
")",
":",
"# Initialise lists",
"report_strains",
"=",
"list",
"(",
")",
"genus_list",
"=",
"list",
"(",
")",
"if",
"self",
".",
"analysistype",
"==",
"'mlst'",
":",
"for",
"sample",
"in",
"self",
".",
"runmetadata",
"."... | If the pipeline has previously been run on these data, instead of reading through the results, parse the
report instead | [
"If",
"the",
"pipeline",
"has",
"previously",
"been",
"run",
"on",
"these",
"data",
"instead",
"of",
"reading",
"through",
"the",
"results",
"parse",
"the",
"report",
"instead"
] | python | train |
joytunes/JTLocalize | localization_flow/jtlocalize/prepare_for_translation.py | https://github.com/joytunes/JTLocalize/blob/87864dc60114e0e61c768d057c6eddfadff3f40a/localization_flow/jtlocalize/prepare_for_translation.py#L31-L60 | def prepare_for_translation(localization_bundle_path):
""" Prepares the localization bundle for translation.
This means, after creating the strings files using genstrings.sh, this will produce '.pending' files, that contain
the files that are yet to be translated.
Args:
localization_bundle_pat... | [
"def",
"prepare_for_translation",
"(",
"localization_bundle_path",
")",
":",
"logging",
".",
"info",
"(",
"\"Preparing for translation..\"",
")",
"for",
"strings_file",
"in",
"os",
".",
"listdir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"localization_bundle_path",... | Prepares the localization bundle for translation.
This means, after creating the strings files using genstrings.sh, this will produce '.pending' files, that contain
the files that are yet to be translated.
Args:
localization_bundle_path (str): The path to the localization bundle. | [
"Prepares",
"the",
"localization",
"bundle",
"for",
"translation",
"."
] | python | train |
RI-imaging/nrefocus | examples/example_helper.py | https://github.com/RI-imaging/nrefocus/blob/ad09aeecace609ab8f9effcb662d2b7d50826080/examples/example_helper.py#L7-L21 | def load_cell(fname="HL60_field.zip"):
"Load zip file and return complex field"
here = op.dirname(op.abspath(__file__))
data = op.join(here, "data")
arc = zipfile.ZipFile(op.join(data, fname))
for f in arc.filelist:
with arc.open(f) as fd:
if f.filename.count("imag"):
... | [
"def",
"load_cell",
"(",
"fname",
"=",
"\"HL60_field.zip\"",
")",
":",
"here",
"=",
"op",
".",
"dirname",
"(",
"op",
".",
"abspath",
"(",
"__file__",
")",
")",
"data",
"=",
"op",
".",
"join",
"(",
"here",
",",
"\"data\"",
")",
"arc",
"=",
"zipfile",
... | Load zip file and return complex field | [
"Load",
"zip",
"file",
"and",
"return",
"complex",
"field"
] | python | train |
saltstack/salt | salt/modules/network.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/network.py#L286-L360 | def _netstat_bsd():
'''
Return netstat information for BSD flavors
'''
ret = []
if __grains__['kernel'] == 'NetBSD':
for addr_family in ('inet', 'inet6'):
cmd = 'netstat -f {0} -an | tail -n+3'.format(addr_family)
out = __salt__['cmd.run'](cmd, python_shell=True)
... | [
"def",
"_netstat_bsd",
"(",
")",
":",
"ret",
"=",
"[",
"]",
"if",
"__grains__",
"[",
"'kernel'",
"]",
"==",
"'NetBSD'",
":",
"for",
"addr_family",
"in",
"(",
"'inet'",
",",
"'inet6'",
")",
":",
"cmd",
"=",
"'netstat -f {0} -an | tail -n+3'",
".",
"format",... | Return netstat information for BSD flavors | [
"Return",
"netstat",
"information",
"for",
"BSD",
"flavors"
] | python | train |
dhhagan/py-opc | opc/__init__.py | https://github.com/dhhagan/py-opc/blob/2c8f19530fb64bf5fd4ee0d694a47850161ed8a7/opc/__init__.py#L235-L258 | def read_info_string(self):
"""Reads the information string for the OPC
:rtype: string
:Example:
>>> alpha.read_info_string()
'OPC-N2 FirmwareVer=OPC-018.2....................BD'
"""
infostring = []
# Send the command byte and sleep for 9 ms
se... | [
"def",
"read_info_string",
"(",
"self",
")",
":",
"infostring",
"=",
"[",
"]",
"# Send the command byte and sleep for 9 ms",
"self",
".",
"cnxn",
".",
"xfer",
"(",
"[",
"0x3F",
"]",
")",
"sleep",
"(",
"9e-3",
")",
"# Read the info string by sending 60 empty bytes",
... | Reads the information string for the OPC
:rtype: string
:Example:
>>> alpha.read_info_string()
'OPC-N2 FirmwareVer=OPC-018.2....................BD' | [
"Reads",
"the",
"information",
"string",
"for",
"the",
"OPC"
] | python | valid |
markuskiller/textblob-de | textblob_de/ext/_pattern/text/tree.py | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L222-L230 | def next(self, type=None):
""" Returns the next word in the sentence with the given type.
"""
i = self.index + 1
s = self.sentence
while i < len(s):
if type in (s[i].type, None):
return s[i]
i += 1 | [
"def",
"next",
"(",
"self",
",",
"type",
"=",
"None",
")",
":",
"i",
"=",
"self",
".",
"index",
"+",
"1",
"s",
"=",
"self",
".",
"sentence",
"while",
"i",
"<",
"len",
"(",
"s",
")",
":",
"if",
"type",
"in",
"(",
"s",
"[",
"i",
"]",
".",
"... | Returns the next word in the sentence with the given type. | [
"Returns",
"the",
"next",
"word",
"in",
"the",
"sentence",
"with",
"the",
"given",
"type",
"."
] | python | train |
lvieirajr/mongorest | mongorest/decorators.py | https://github.com/lvieirajr/mongorest/blob/00f4487ded33254434bc51ff09d48c7a936bd465/mongorest/decorators.py#L47-L67 | def serializable(wrapped):
"""
If a keyword argument 'serialize' with a True value is passed to the
Wrapped function, the return of the wrapped function will be serialized.
Nothing happens if the argument is not passed or the value is not True
"""
@wraps(wrapped)
def wrapper(*args, **kwargs... | [
"def",
"serializable",
"(",
"wrapped",
")",
":",
"@",
"wraps",
"(",
"wrapped",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"should_serialize",
"=",
"kwargs",
".",
"pop",
"(",
"'serialize'",
",",
"False",
")",
"result",
... | If a keyword argument 'serialize' with a True value is passed to the
Wrapped function, the return of the wrapped function will be serialized.
Nothing happens if the argument is not passed or the value is not True | [
"If",
"a",
"keyword",
"argument",
"serialize",
"with",
"a",
"True",
"value",
"is",
"passed",
"to",
"the",
"Wrapped",
"function",
"the",
"return",
"of",
"the",
"wrapped",
"function",
"will",
"be",
"serialized",
".",
"Nothing",
"happens",
"if",
"the",
"argumen... | python | train |
PmagPy/PmagPy | programs/deprecated/umich_magic.py | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/deprecated/umich_magic.py#L7-L244 | def main():
"""
NAME
umich_magic.py
DESCRIPTION
converts UMICH .mag format files to magic_measurements format files
SYNTAX
umich_magic.py [command line options]
OPTIONS
-h: prints the help message and quits.
-usr USER: identify user, default is ""
... | [
"def",
"main",
"(",
")",
":",
"# initialize some stuff",
"dir_path",
"=",
"'.'",
"infile_type",
"=",
"\"mag\"",
"noave",
"=",
"0",
"methcode",
",",
"inst",
"=",
"\"\"",
",",
"\"\"",
"phi",
",",
"theta",
",",
"peakfield",
",",
"labfield",
"=",
"0",
",",
... | NAME
umich_magic.py
DESCRIPTION
converts UMICH .mag format files to magic_measurements format files
SYNTAX
umich_magic.py [command line options]
OPTIONS
-h: prints the help message and quits.
-usr USER: identify user, default is ""
-f FILE: specify .mag ... | [
"NAME",
"umich_magic",
".",
"py",
"DESCRIPTION",
"converts",
"UMICH",
".",
"mag",
"format",
"files",
"to",
"magic_measurements",
"format",
"files"
] | python | train |
rigetti/quantumflow | quantumflow/paulialgebra.py | https://github.com/rigetti/quantumflow/blob/13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb/quantumflow/paulialgebra.py#L348-L372 | def pauli_commuting_sets(element: Pauli) -> Tuple[Pauli, ...]:
"""Gather the terms of a Pauli polynomial into commuting sets.
Uses the algorithm defined in (Raeisi, Wiebe, Sanders,
arXiv:1108.4318, 2011) to find commuting sets. Except uses commutation
check from arXiv:1405.5749v2
"""
if len(ele... | [
"def",
"pauli_commuting_sets",
"(",
"element",
":",
"Pauli",
")",
"->",
"Tuple",
"[",
"Pauli",
",",
"...",
"]",
":",
"if",
"len",
"(",
"element",
")",
"<",
"2",
":",
"return",
"(",
"element",
",",
")",
"groups",
":",
"List",
"[",
"Pauli",
"]",
"=",... | Gather the terms of a Pauli polynomial into commuting sets.
Uses the algorithm defined in (Raeisi, Wiebe, Sanders,
arXiv:1108.4318, 2011) to find commuting sets. Except uses commutation
check from arXiv:1405.5749v2 | [
"Gather",
"the",
"terms",
"of",
"a",
"Pauli",
"polynomial",
"into",
"commuting",
"sets",
"."
] | python | train |
pgmpy/pgmpy | pgmpy/models/DynamicBayesianNetwork.py | https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/DynamicBayesianNetwork.py#L120-L133 | def _nodes(self):
"""
Returns the list of nodes present in the network
Examples
--------
>>> from pgmpy.models import DynamicBayesianNetwork as DBN
>>> dbn = DBN()
>>> dbn.add_nodes_from(['A', 'B', 'C'])
>>> sorted(dbn._nodes())
['B', 'A', 'C']
... | [
"def",
"_nodes",
"(",
"self",
")",
":",
"return",
"list",
"(",
"set",
"(",
"[",
"node",
"for",
"node",
",",
"timeslice",
"in",
"super",
"(",
"DynamicBayesianNetwork",
",",
"self",
")",
".",
"nodes",
"(",
")",
"]",
")",
")"
] | Returns the list of nodes present in the network
Examples
--------
>>> from pgmpy.models import DynamicBayesianNetwork as DBN
>>> dbn = DBN()
>>> dbn.add_nodes_from(['A', 'B', 'C'])
>>> sorted(dbn._nodes())
['B', 'A', 'C'] | [
"Returns",
"the",
"list",
"of",
"nodes",
"present",
"in",
"the",
"network"
] | python | train |
pandas-dev/pandas | pandas/core/internals/blocks.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2597-L2643 | def convert(self, *args, **kwargs):
""" attempt to coerce any object types to better types return a copy of
the block (if copy = True) by definition we ARE an ObjectBlock!!!!!
can return multiple blocks!
"""
if args:
raise NotImplementedError
by_item = kwarg... | [
"def",
"convert",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"args",
":",
"raise",
"NotImplementedError",
"by_item",
"=",
"kwargs",
".",
"get",
"(",
"'by_item'",
",",
"True",
")",
"new_inputs",
"=",
"[",
"'coerce'",
",",
... | attempt to coerce any object types to better types return a copy of
the block (if copy = True) by definition we ARE an ObjectBlock!!!!!
can return multiple blocks! | [
"attempt",
"to",
"coerce",
"any",
"object",
"types",
"to",
"better",
"types",
"return",
"a",
"copy",
"of",
"the",
"block",
"(",
"if",
"copy",
"=",
"True",
")",
"by",
"definition",
"we",
"ARE",
"an",
"ObjectBlock!!!!!"
] | python | train |
datascopeanalytics/scrubadub | scrubadub/detectors/__init__.py | https://github.com/datascopeanalytics/scrubadub/blob/914bda49a16130b44af43df6a2f84755477c407c/scrubadub/detectors/__init__.py#L12-L22 | def iter_detector_clss():
"""Iterate over all of the detectors that are included in this sub-package.
This is a convenience method for capturing all new Detectors that are added
over time and it is used both by the unit tests and in the
``Scrubber.__init__`` method.
"""
return iter_subclasses(
... | [
"def",
"iter_detector_clss",
"(",
")",
":",
"return",
"iter_subclasses",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"__file__",
")",
")",
",",
"Detector",
",",
"_is_abstract_detector",
",",
")"
] | Iterate over all of the detectors that are included in this sub-package.
This is a convenience method for capturing all new Detectors that are added
over time and it is used both by the unit tests and in the
``Scrubber.__init__`` method. | [
"Iterate",
"over",
"all",
"of",
"the",
"detectors",
"that",
"are",
"included",
"in",
"this",
"sub",
"-",
"package",
".",
"This",
"is",
"a",
"convenience",
"method",
"for",
"capturing",
"all",
"new",
"Detectors",
"that",
"are",
"added",
"over",
"time",
"and... | python | train |
wmayner/pyphi | pyphi/validate.py | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/validate.py#L118-L128 | def network(n):
"""Validate a |Network|.
Checks the TPM and connectivity matrix.
"""
tpm(n.tpm)
connectivity_matrix(n.cm)
if n.cm.shape[0] != n.size:
raise ValueError("Connectivity matrix must be NxN, where N is the "
"number of nodes in the network.")
retur... | [
"def",
"network",
"(",
"n",
")",
":",
"tpm",
"(",
"n",
".",
"tpm",
")",
"connectivity_matrix",
"(",
"n",
".",
"cm",
")",
"if",
"n",
".",
"cm",
".",
"shape",
"[",
"0",
"]",
"!=",
"n",
".",
"size",
":",
"raise",
"ValueError",
"(",
"\"Connectivity m... | Validate a |Network|.
Checks the TPM and connectivity matrix. | [
"Validate",
"a",
"|Network|",
"."
] | python | train |
StackStorm/pybind | pybind/slxos/v17r_1_01a/mpls_state/rsvp/interfaces/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17r_1_01a/mpls_state/rsvp/interfaces/__init__.py#L871-L894 | def _set_interface_flooding_up_threshold(self, v, load=False):
"""
Setter method for interface_flooding_up_threshold, mapped from YANG variable /mpls_state/rsvp/interfaces/interface_flooding_up_threshold (feature-config-source)
If this variable is read-only (config: false) in the
source YANG file, then ... | [
"def",
"_set_interface_flooding_up_threshold",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",... | Setter method for interface_flooding_up_threshold, mapped from YANG variable /mpls_state/rsvp/interfaces/interface_flooding_up_threshold (feature-config-source)
If this variable is read-only (config: false) in the
source YANG file, then _set_interface_flooding_up_threshold is considered as a private
method.... | [
"Setter",
"method",
"for",
"interface_flooding_up_threshold",
"mapped",
"from",
"YANG",
"variable",
"/",
"mpls_state",
"/",
"rsvp",
"/",
"interfaces",
"/",
"interface_flooding_up_threshold",
"(",
"feature",
"-",
"config",
"-",
"source",
")",
"If",
"this",
"variable"... | python | train |
peeringdb/peeringdb-py | peeringdb/config.py | https://github.com/peeringdb/peeringdb-py/blob/cf2060a1d5ef879a01cf849e54b7756909ab2661/peeringdb/config.py#L115-L120 | def convert_old(data):
"Convert config data with old schema to new schema"
ret = default_config()
ret['sync'].update(data.get('peeringdb', {}))
ret['orm']['database'].update(data.get('database', {}))
return ret | [
"def",
"convert_old",
"(",
"data",
")",
":",
"ret",
"=",
"default_config",
"(",
")",
"ret",
"[",
"'sync'",
"]",
".",
"update",
"(",
"data",
".",
"get",
"(",
"'peeringdb'",
",",
"{",
"}",
")",
")",
"ret",
"[",
"'orm'",
"]",
"[",
"'database'",
"]",
... | Convert config data with old schema to new schema | [
"Convert",
"config",
"data",
"with",
"old",
"schema",
"to",
"new",
"schema"
] | python | train |
project-rig/rig | rig/machine_control/machine_controller.py | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L2838-L2869 | def unpack_routing_table_entry(packed):
"""Unpack a routing table entry read from a SpiNNaker machine.
Parameters
----------
packet : :py:class:`bytes`
Bytes containing a packed routing table.
Returns
-------
(:py:class:`~rig.routing_table.RoutingTableEntry`, app_id, core) or None
... | [
"def",
"unpack_routing_table_entry",
"(",
"packed",
")",
":",
"# Unpack the routing table entry",
"_",
",",
"free",
",",
"route",
",",
"key",
",",
"mask",
"=",
"struct",
".",
"unpack",
"(",
"consts",
".",
"RTE_PACK_STRING",
",",
"packed",
")",
"# If the top 8 bi... | Unpack a routing table entry read from a SpiNNaker machine.
Parameters
----------
packet : :py:class:`bytes`
Bytes containing a packed routing table.
Returns
-------
(:py:class:`~rig.routing_table.RoutingTableEntry`, app_id, core) or None
Tuple containing the routing entry, the... | [
"Unpack",
"a",
"routing",
"table",
"entry",
"read",
"from",
"a",
"SpiNNaker",
"machine",
"."
] | python | train |
edx/XBlock | xblock/runtime.py | https://github.com/edx/XBlock/blob/368bf46e2c0ee69bbb21817f428c4684936e18ee/xblock/runtime.py#L1264-L1268 | def lex(self, text):
"""Iterator that tokenizes `text` and yields up tokens as they are found"""
for match in self.regex.finditer(text):
name = match.lastgroup
yield (name, match.group(name)) | [
"def",
"lex",
"(",
"self",
",",
"text",
")",
":",
"for",
"match",
"in",
"self",
".",
"regex",
".",
"finditer",
"(",
"text",
")",
":",
"name",
"=",
"match",
".",
"lastgroup",
"yield",
"(",
"name",
",",
"match",
".",
"group",
"(",
"name",
")",
")"
... | Iterator that tokenizes `text` and yields up tokens as they are found | [
"Iterator",
"that",
"tokenizes",
"text",
"and",
"yields",
"up",
"tokens",
"as",
"they",
"are",
"found"
] | python | train |
libtcod/python-tcod | tcod/libtcodpy.py | https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L818-L833 | def color_scale_HSV(c: Color, scoef: float, vcoef: float) -> None:
"""Scale a color's saturation and value.
Does not return a new Color. ``c`` is modified inplace.
Args:
c (Union[Color, List[int]]): A Color instance, or an [r, g, b] list.
scoef (float): Saturation multiplier, from 0 to 1.... | [
"def",
"color_scale_HSV",
"(",
"c",
":",
"Color",
",",
"scoef",
":",
"float",
",",
"vcoef",
":",
"float",
")",
"->",
"None",
":",
"color_p",
"=",
"ffi",
".",
"new",
"(",
"\"TCOD_color_t*\"",
")",
"color_p",
".",
"r",
",",
"color_p",
".",
"g",
",",
... | Scale a color's saturation and value.
Does not return a new Color. ``c`` is modified inplace.
Args:
c (Union[Color, List[int]]): A Color instance, or an [r, g, b] list.
scoef (float): Saturation multiplier, from 0 to 1.
Use 1 to keep current saturation.
vcoef (f... | [
"Scale",
"a",
"color",
"s",
"saturation",
"and",
"value",
"."
] | python | train |
CI-WATER/mapkit | mapkit/RasterLoader.py | https://github.com/CI-WATER/mapkit/blob/ce5fbded6af7adabdf1eec85631c6811ef8ecc34/mapkit/RasterLoader.py#L181-L247 | def makeSingleBandWKBRaster(cls, session, width, height, upperLeftX, upperLeftY, cellSizeX, cellSizeY, skewX, skewY, srid, dataArray, initialValue=None, noDataValue=None):
"""
Generate Well Known Binary via SQL. Must be used on a PostGIS database as it relies on several PostGIS
database function... | [
"def",
"makeSingleBandWKBRaster",
"(",
"cls",
",",
"session",
",",
"width",
",",
"height",
",",
"upperLeftX",
",",
"upperLeftY",
",",
"cellSizeX",
",",
"cellSizeY",
",",
"skewX",
",",
"skewY",
",",
"srid",
",",
"dataArray",
",",
"initialValue",
"=",
"None",
... | Generate Well Known Binary via SQL. Must be used on a PostGIS database as it relies on several PostGIS
database functions.
:param session: SQLAlchemy session object bound to a PostGIS enabled database
:param height: Height of the raster (or number of rows)
:param width: Width of the rast... | [
"Generate",
"Well",
"Known",
"Binary",
"via",
"SQL",
".",
"Must",
"be",
"used",
"on",
"a",
"PostGIS",
"database",
"as",
"it",
"relies",
"on",
"several",
"PostGIS",
"database",
"functions",
".",
":",
"param",
"session",
":",
"SQLAlchemy",
"session",
"object",... | python | train |
secynic/ipwhois | ipwhois/rdap.py | https://github.com/secynic/ipwhois/blob/b5d634d36b0b942d538d38d77b3bdcd815f155a0/ipwhois/rdap.py#L600-L661 | def parse(self):
"""
The function for parsing the JSON response to the vars dictionary.
"""
try:
self.vars['handle'] = self.json['handle'].strip()
except (KeyError, ValueError, TypeError):
raise InvalidEntityObject('Handle is missing for RDAP entity')
... | [
"def",
"parse",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"vars",
"[",
"'handle'",
"]",
"=",
"self",
".",
"json",
"[",
"'handle'",
"]",
".",
"strip",
"(",
")",
"except",
"(",
"KeyError",
",",
"ValueError",
",",
"TypeError",
")",
":",
"raise",... | The function for parsing the JSON response to the vars dictionary. | [
"The",
"function",
"for",
"parsing",
"the",
"JSON",
"response",
"to",
"the",
"vars",
"dictionary",
"."
] | python | train |
MDAnalysis/GridDataFormats | gridData/OpenDX.py | https://github.com/MDAnalysis/GridDataFormats/blob/3eeb0432f8cf856912436e4f3e7aba99d3c916be/gridData/OpenDX.py#L462-L484 | def write(self, filename):
"""Write the complete dx object to the file.
This is the simple OpenDX format which includes the data into
the header via the 'object array ... data follows' statement.
Only simple regular arrays are supported.
The format should be compatible with VM... | [
"def",
"write",
"(",
"self",
",",
"filename",
")",
":",
"# comments (VMD chokes on lines of len > 80, so truncate)",
"maxcol",
"=",
"80",
"with",
"open",
"(",
"filename",
",",
"'w'",
")",
"as",
"outfile",
":",
"for",
"line",
"in",
"self",
".",
"comments",
":",... | Write the complete dx object to the file.
This is the simple OpenDX format which includes the data into
the header via the 'object array ... data follows' statement.
Only simple regular arrays are supported.
The format should be compatible with VMD's dx reader plugin. | [
"Write",
"the",
"complete",
"dx",
"object",
"to",
"the",
"file",
"."
] | python | valid |
ejeschke/ginga | ginga/canvas/transform.py | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/canvas/transform.py#L166-L181 | def from_(self, pct_pts):
"""Reverse of :meth:`to_`."""
pct_pts = np.asarray(pct_pts, dtype=np.float)
has_z = (pct_pts.shape[-1] > 2)
max_pt = list(self.viewer.get_window_size())
if has_z:
max_pt.append(0.0)
win_pts = np.multiply(pct_pts, max_pt)
# ... | [
"def",
"from_",
"(",
"self",
",",
"pct_pts",
")",
":",
"pct_pts",
"=",
"np",
".",
"asarray",
"(",
"pct_pts",
",",
"dtype",
"=",
"np",
".",
"float",
")",
"has_z",
"=",
"(",
"pct_pts",
".",
"shape",
"[",
"-",
"1",
"]",
">",
"2",
")",
"max_pt",
"=... | Reverse of :meth:`to_`. | [
"Reverse",
"of",
":",
"meth",
":",
"to_",
"."
] | python | train |
PedalPi/PluginsManager | pluginsmanager/observer/observable_list.py | https://github.com/PedalPi/PluginsManager/blob/2dcc9f6a79b48e9c9be82efffd855352fa15c5c7/pluginsmanager/observer/observable_list.py#L149-L164 | def move(self, item, new_position):
"""
Moves a item list to new position
Calls observer ``self.observer(UpdateType.DELETED, item, index)``
and observer ``self.observer(UpdateType.CREATED, item, index)``
if ``val != self[index]``
:param item: Item that will be moved to ... | [
"def",
"move",
"(",
"self",
",",
"item",
",",
"new_position",
")",
":",
"if",
"item",
"==",
"self",
"[",
"new_position",
"]",
":",
"return",
"self",
".",
"remove",
"(",
"item",
")",
"self",
".",
"insert",
"(",
"new_position",
",",
"item",
")"
] | Moves a item list to new position
Calls observer ``self.observer(UpdateType.DELETED, item, index)``
and observer ``self.observer(UpdateType.CREATED, item, index)``
if ``val != self[index]``
:param item: Item that will be moved to new_position
:param new_position: Item's new pos... | [
"Moves",
"a",
"item",
"list",
"to",
"new",
"position"
] | python | train |
artefactual-labs/mets-reader-writer | metsrw/fsentry.py | https://github.com/artefactual-labs/mets-reader-writer/blob/d95939cabdfdc25cb1bf67df0c84bd0d6e6a73ff/metsrw/fsentry.py#L243-L275 | def _add_metadata_element(self, md, subsection, mdtype, mode="mdwrap", **kwargs):
"""
:param md: Value to pass to the MDWrap/MDRef
:param str subsection: Metadata tag to create. See :const:`SubSection.ALLOWED_SUBSECTIONS`
:param str mdtype: Value for mdWrap/mdRef @MDTYPE
:param ... | [
"def",
"_add_metadata_element",
"(",
"self",
",",
"md",
",",
"subsection",
",",
"mdtype",
",",
"mode",
"=",
"\"mdwrap\"",
",",
"*",
"*",
"kwargs",
")",
":",
"# HELP how handle multiple amdSecs?",
"# When adding *MD which amdSec to add to?",
"if",
"mode",
".",
"lower... | :param md: Value to pass to the MDWrap/MDRef
:param str subsection: Metadata tag to create. See :const:`SubSection.ALLOWED_SUBSECTIONS`
:param str mdtype: Value for mdWrap/mdRef @MDTYPE
:param str mode: 'mdwrap' or 'mdref'
:param str loctype: Required if mode is 'mdref'. LOCTYPE of a md... | [
":",
"param",
"md",
":",
"Value",
"to",
"pass",
"to",
"the",
"MDWrap",
"/",
"MDRef",
":",
"param",
"str",
"subsection",
":",
"Metadata",
"tag",
"to",
"create",
".",
"See",
":",
"const",
":",
"SubSection",
".",
"ALLOWED_SUBSECTIONS",
":",
"param",
"str",
... | python | train |
dusty-phillips/opterator | opterator.py | https://github.com/dusty-phillips/opterator/blob/84fe31f22c73dc0a3666ed82c179461b1799c257/opterator.py#L52-L78 | def portable_argspec(func):
'''
Given a function, return a tuple of
(positional_params, keyword_params, varargs, defaults, annotations)
where
* positional_params is a list of parameters that don't have default values
* keyword_params is a list of parameters that have default values
* varargs... | [
"def",
"portable_argspec",
"(",
"func",
")",
":",
"if",
"sys",
".",
"version_info",
"<",
"(",
"3",
",",
"0",
")",
":",
"# PYTHON 2 MUST DIE",
"argnames",
",",
"varargs",
",",
"varkw",
",",
"defaults",
"=",
"inspect",
".",
"getargspec",
"(",
"func",
")",
... | Given a function, return a tuple of
(positional_params, keyword_params, varargs, defaults, annotations)
where
* positional_params is a list of parameters that don't have default values
* keyword_params is a list of parameters that have default values
* varargs is the string name for variable argumen... | [
"Given",
"a",
"function",
"return",
"a",
"tuple",
"of",
"(",
"positional_params",
"keyword_params",
"varargs",
"defaults",
"annotations",
")",
"where",
"*",
"positional_params",
"is",
"a",
"list",
"of",
"parameters",
"that",
"don",
"t",
"have",
"default",
"value... | python | train |
glenfant/openxmllib | openxmllib/document.py | https://github.com/glenfant/openxmllib/blob/c8208f8ecd9fc3ef1e73c1db68081a65361afb3f/openxmllib/document.py#L166-L175 | def allProperties(self):
"""Helper that merges core, extended and custom properties
:return: mapping of all properties
"""
rval = {}
rval.update(self.coreProperties)
rval.update(self.extendedProperties)
rval.update(self.customProperties)
return rval | [
"def",
"allProperties",
"(",
"self",
")",
":",
"rval",
"=",
"{",
"}",
"rval",
".",
"update",
"(",
"self",
".",
"coreProperties",
")",
"rval",
".",
"update",
"(",
"self",
".",
"extendedProperties",
")",
"rval",
".",
"update",
"(",
"self",
".",
"customPr... | Helper that merges core, extended and custom properties
:return: mapping of all properties | [
"Helper",
"that",
"merges",
"core",
"extended",
"and",
"custom",
"properties"
] | python | train |
DigitalGlobe/gbdxtools | gbdxtools/images/meta.py | https://github.com/DigitalGlobe/gbdxtools/blob/def62f8f2d77b168aa2bd115290aaa0f9a08a4bb/gbdxtools/images/meta.py#L260-L296 | def pxbounds(self, geom, clip=False):
""" Returns the bounds of a geometry object in pixel coordinates
Args:
geom: Shapely geometry object or GeoJSON as Python dictionary or WKT string
clip (bool): Clip the bounds to the min/max extent of the image
Returns:
... | [
"def",
"pxbounds",
"(",
"self",
",",
"geom",
",",
"clip",
"=",
"False",
")",
":",
"try",
":",
"if",
"isinstance",
"(",
"geom",
",",
"dict",
")",
":",
"if",
"'geometry'",
"in",
"geom",
":",
"geom",
"=",
"shape",
"(",
"geom",
"[",
"'geometry'",
"]",
... | Returns the bounds of a geometry object in pixel coordinates
Args:
geom: Shapely geometry object or GeoJSON as Python dictionary or WKT string
clip (bool): Clip the bounds to the min/max extent of the image
Returns:
list: bounds in pixels [min x, min y, max x, max y... | [
"Returns",
"the",
"bounds",
"of",
"a",
"geometry",
"object",
"in",
"pixel",
"coordinates"
] | python | valid |
python-diamond/Diamond | src/diamond/handler/riemann.py | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/riemann.py#L69-L81 | def get_default_config(self):
"""
Return the default config for the handler
"""
config = super(RiemannHandler, self).get_default_config()
config.update({
'host': '',
'port': 123,
'transport': 'tcp',
})
return config | [
"def",
"get_default_config",
"(",
"self",
")",
":",
"config",
"=",
"super",
"(",
"RiemannHandler",
",",
"self",
")",
".",
"get_default_config",
"(",
")",
"config",
".",
"update",
"(",
"{",
"'host'",
":",
"''",
",",
"'port'",
":",
"123",
",",
"'transport'... | Return the default config for the handler | [
"Return",
"the",
"default",
"config",
"for",
"the",
"handler"
] | python | train |
samirelanduk/quickplots | quickplots/series.py | https://github.com/samirelanduk/quickplots/blob/59f5e6ff367b2c1c24ba7cf1805d03552034c6d8/quickplots/series.py#L277-L290 | def write_to_canvas(self, canvas, name):
"""Writes the series to an OmniCanvas canvas.
:param Canvas canvas: The canvas to write to.
:param str name: The name to give the line graphic on the canvas."""
points = self.canvas_points()
args = []
for point in points:
... | [
"def",
"write_to_canvas",
"(",
"self",
",",
"canvas",
",",
"name",
")",
":",
"points",
"=",
"self",
".",
"canvas_points",
"(",
")",
"args",
"=",
"[",
"]",
"for",
"point",
"in",
"points",
":",
"args",
"+=",
"list",
"(",
"point",
")",
"canvas",
".",
... | Writes the series to an OmniCanvas canvas.
:param Canvas canvas: The canvas to write to.
:param str name: The name to give the line graphic on the canvas. | [
"Writes",
"the",
"series",
"to",
"an",
"OmniCanvas",
"canvas",
"."
] | python | train |
gwastro/pycbc | pycbc/inference/io/__init__.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/inference/io/__init__.py#L622-L648 | def injections_from_cli(opts):
"""Gets injection parameters from the inference file(s).
Parameters
----------
opts : argparser
Argparser object that has the command-line objects to parse.
Returns
-------
FieldArray
Array of the injection parameters from all of the input fil... | [
"def",
"injections_from_cli",
"(",
"opts",
")",
":",
"input_files",
"=",
"opts",
".",
"input_file",
"if",
"isinstance",
"(",
"input_files",
",",
"str",
")",
":",
"input_files",
"=",
"[",
"input_files",
"]",
"injections",
"=",
"None",
"# loop over all input files... | Gets injection parameters from the inference file(s).
Parameters
----------
opts : argparser
Argparser object that has the command-line objects to parse.
Returns
-------
FieldArray
Array of the injection parameters from all of the input files given
by ``opts.input_file`... | [
"Gets",
"injection",
"parameters",
"from",
"the",
"inference",
"file",
"(",
"s",
")",
"."
] | python | train |
sorgerlab/indra | indra/tools/assemble_corpus.py | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/assemble_corpus.py#L43-L78 | def load_statements(fname, as_dict=False):
"""Load statements from a pickle file.
Parameters
----------
fname : str
The name of the pickle file to load statements from.
as_dict : Optional[bool]
If True and the pickle file contains a dictionary of statements, it
is returned a... | [
"def",
"load_statements",
"(",
"fname",
",",
"as_dict",
"=",
"False",
")",
":",
"logger",
".",
"info",
"(",
"'Loading %s...'",
"%",
"fname",
")",
"with",
"open",
"(",
"fname",
",",
"'rb'",
")",
"as",
"fh",
":",
"# Encoding argument not available in pickle for ... | Load statements from a pickle file.
Parameters
----------
fname : str
The name of the pickle file to load statements from.
as_dict : Optional[bool]
If True and the pickle file contains a dictionary of statements, it
is returned as a dictionary. If False, the statements are alway... | [
"Load",
"statements",
"from",
"a",
"pickle",
"file",
"."
] | python | train |
googleapis/oauth2client | oauth2client/client.py | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/client.py#L829-L863 | def _do_revoke(self, http, token):
"""Revokes this credential and deletes the stored copy (if it exists).
Args:
http: an object to be used to make HTTP requests.
token: A string used as the token to be revoked. Can be either an
access_token or refresh_token.
... | [
"def",
"_do_revoke",
"(",
"self",
",",
"http",
",",
"token",
")",
":",
"logger",
".",
"info",
"(",
"'Revoking token'",
")",
"query_params",
"=",
"{",
"'token'",
":",
"token",
"}",
"token_revoke_uri",
"=",
"_helpers",
".",
"update_query_params",
"(",
"self",
... | Revokes this credential and deletes the stored copy (if it exists).
Args:
http: an object to be used to make HTTP requests.
token: A string used as the token to be revoked. Can be either an
access_token or refresh_token.
Raises:
TokenRevokeError: ... | [
"Revokes",
"this",
"credential",
"and",
"deletes",
"the",
"stored",
"copy",
"(",
"if",
"it",
"exists",
")",
"."
] | python | valid |
libfuse/python-fuse | fuseparts/subbedopts.py | https://github.com/libfuse/python-fuse/blob/2c088b657ad71faca6975b456f80b7d2c2cea2a7/fuseparts/subbedopts.py#L59-L76 | def filter(self, other):
"""
Throw away those options which are not in the other one.
Returns a new instance with the rejected options.
"""
self.canonify()
other.canonify()
rej = self.__class__()
rej.optlist = self.optlist.difference(other.optlist)
... | [
"def",
"filter",
"(",
"self",
",",
"other",
")",
":",
"self",
".",
"canonify",
"(",
")",
"other",
".",
"canonify",
"(",
")",
"rej",
"=",
"self",
".",
"__class__",
"(",
")",
"rej",
".",
"optlist",
"=",
"self",
".",
"optlist",
".",
"difference",
"(",... | Throw away those options which are not in the other one.
Returns a new instance with the rejected options. | [
"Throw",
"away",
"those",
"options",
"which",
"are",
"not",
"in",
"the",
"other",
"one",
".",
"Returns",
"a",
"new",
"instance",
"with",
"the",
"rejected",
"options",
"."
] | python | train |
wtsi-hgi/gitlab-build-variables | gitlabbuildvariables/executables/gitlab_set_variables.py | https://github.com/wtsi-hgi/gitlab-build-variables/blob/ed1afe50bc41fa20ffb29cacba5ff6dbc2446808/gitlabbuildvariables/executables/gitlab_set_variables.py#L21-L35 | def _parse_args(args: List[str]) -> _SetArgumentsRunConfig:
"""
Parses the given CLI arguments to get a run configuration.
:param args: CLI arguments
:return: run configuration derived from the given CLI arguments
"""
parser = argparse.ArgumentParser(
prog="gitlab-set-variables", descrip... | [
"def",
"_parse_args",
"(",
"args",
":",
"List",
"[",
"str",
"]",
")",
"->",
"_SetArgumentsRunConfig",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"prog",
"=",
"\"gitlab-set-variables\"",
",",
"description",
"=",
"\"Tool for setting a GitLab project's... | Parses the given CLI arguments to get a run configuration.
:param args: CLI arguments
:return: run configuration derived from the given CLI arguments | [
"Parses",
"the",
"given",
"CLI",
"arguments",
"to",
"get",
"a",
"run",
"configuration",
".",
":",
"param",
"args",
":",
"CLI",
"arguments",
":",
"return",
":",
"run",
"configuration",
"derived",
"from",
"the",
"given",
"CLI",
"arguments"
] | python | train |
googleapis/google-cloud-python | pubsub/google/cloud/pubsub_v1/subscriber/_protocol/leaser.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/pubsub/google/cloud/pubsub_v1/subscriber/_protocol/leaser.py#L92-L159 | def maintain_leases(self):
"""Maintain all of the leases being managed.
This method modifies the ack deadline for all of the managed
ack IDs, then waits for most of that time (but with jitter), and
repeats.
"""
while self._manager.is_active and not self._stop_event.is_se... | [
"def",
"maintain_leases",
"(",
"self",
")",
":",
"while",
"self",
".",
"_manager",
".",
"is_active",
"and",
"not",
"self",
".",
"_stop_event",
".",
"is_set",
"(",
")",
":",
"# Determine the appropriate duration for the lease. This is",
"# based off of how long previous ... | Maintain all of the leases being managed.
This method modifies the ack deadline for all of the managed
ack IDs, then waits for most of that time (but with jitter), and
repeats. | [
"Maintain",
"all",
"of",
"the",
"leases",
"being",
"managed",
"."
] | python | train |
zarr-developers/zarr | zarr/hierarchy.py | https://github.com/zarr-developers/zarr/blob/fb8e6d5ea6bc26e451e5cf0eaaee36977556d5b5/zarr/hierarchy.py#L388-L411 | def groups(self):
"""Return an iterator over (name, value) pairs for groups only.
Examples
--------
>>> import zarr
>>> g1 = zarr.group()
>>> g2 = g1.create_group('foo')
>>> g3 = g1.create_group('bar')
>>> d1 = g1.create_dataset('baz', shape=100, chunks=1... | [
"def",
"groups",
"(",
"self",
")",
":",
"for",
"key",
"in",
"sorted",
"(",
"listdir",
"(",
"self",
".",
"_store",
",",
"self",
".",
"_path",
")",
")",
":",
"path",
"=",
"self",
".",
"_key_prefix",
"+",
"key",
"if",
"contains_group",
"(",
"self",
".... | Return an iterator over (name, value) pairs for groups only.
Examples
--------
>>> import zarr
>>> g1 = zarr.group()
>>> g2 = g1.create_group('foo')
>>> g3 = g1.create_group('bar')
>>> d1 = g1.create_dataset('baz', shape=100, chunks=10)
>>> d2 = g1.create... | [
"Return",
"an",
"iterator",
"over",
"(",
"name",
"value",
")",
"pairs",
"for",
"groups",
"only",
"."
] | python | train |
daviddrysdale/python-phonenumbers | python/phonenumbers/phonenumberutil.py | https://github.com/daviddrysdale/python-phonenumbers/blob/9cc5bb4ab5e661e70789b4c64bf7a9383c7bdc20/python/phonenumbers/phonenumberutil.py#L2964-L3001 | def _is_number_match_OO(numobj1_in, numobj2_in):
"""Takes two phone number objects and compares them for equality."""
# We only care about the fields that uniquely define a number, so we copy these across explicitly.
numobj1 = _copy_core_fields_only(numobj1_in)
numobj2 = _copy_core_fields_only(numobj2_i... | [
"def",
"_is_number_match_OO",
"(",
"numobj1_in",
",",
"numobj2_in",
")",
":",
"# We only care about the fields that uniquely define a number, so we copy these across explicitly.",
"numobj1",
"=",
"_copy_core_fields_only",
"(",
"numobj1_in",
")",
"numobj2",
"=",
"_copy_core_fields_o... | Takes two phone number objects and compares them for equality. | [
"Takes",
"two",
"phone",
"number",
"objects",
"and",
"compares",
"them",
"for",
"equality",
"."
] | python | train |
sethmlarson/virtualbox-python | virtualbox/library.py | https://github.com/sethmlarson/virtualbox-python/blob/706c8e3f6e3aee17eb06458e73cbb4bc2d37878b/virtualbox/library.py#L28501-L28511 | def on_dn_d_mode_change(self, dnd_mode):
"""Notification when the drag'n drop mode changes.
in dnd_mode of type :class:`DnDMode`
The new mode for drag'n drop.
"""
if not isinstance(dnd_mode, DnDMode):
raise TypeError("dnd_mode can only be an instance of type DnD... | [
"def",
"on_dn_d_mode_change",
"(",
"self",
",",
"dnd_mode",
")",
":",
"if",
"not",
"isinstance",
"(",
"dnd_mode",
",",
"DnDMode",
")",
":",
"raise",
"TypeError",
"(",
"\"dnd_mode can only be an instance of type DnDMode\"",
")",
"self",
".",
"_call",
"(",
"\"onDnDM... | Notification when the drag'n drop mode changes.
in dnd_mode of type :class:`DnDMode`
The new mode for drag'n drop. | [
"Notification",
"when",
"the",
"drag",
"n",
"drop",
"mode",
"changes",
"."
] | python | train |
odlgroup/odl | odl/operator/pspace_ops.py | https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/operator/pspace_ops.py#L315-L386 | def derivative(self, x):
"""Derivative of the product space operator.
Parameters
----------
x : `domain` element
The point to take the derivative in
Returns
-------
adjoint : linear`ProductSpaceOperator`
The derivative
Examples
... | [
"def",
"derivative",
"(",
"self",
",",
"x",
")",
":",
"# Lazy import to improve `import odl` time",
"import",
"scipy",
".",
"sparse",
"# Short circuit optimization",
"if",
"self",
".",
"is_linear",
":",
"return",
"self",
"deriv_ops",
"=",
"[",
"op",
".",
"derivati... | Derivative of the product space operator.
Parameters
----------
x : `domain` element
The point to take the derivative in
Returns
-------
adjoint : linear`ProductSpaceOperator`
The derivative
Examples
--------
>>> r3 = odl... | [
"Derivative",
"of",
"the",
"product",
"space",
"operator",
"."
] | python | train |
kinegratii/borax | borax/calendars/lunardate.py | https://github.com/kinegratii/borax/blob/921649f9277e3f657b6dea5a80e67de9ee5567f6/borax/calendars/lunardate.py#L288-L309 | def get_term_info(year, month, day):
"""Parse solar term and stem-branch year/month/day from a solar date.
(sy, sm, sd) => (term, next_gz_month)
term for year 2101,:2101.1.5(初六) 小寒 2101.1.20(廿一) 大寒
"""
if year == 2101:
days = [5, 20]
else:
days = T... | [
"def",
"get_term_info",
"(",
"year",
",",
"month",
",",
"day",
")",
":",
"if",
"year",
"==",
"2101",
":",
"days",
"=",
"[",
"5",
",",
"20",
"]",
"else",
":",
"days",
"=",
"TermUtils",
".",
"parse_term_days",
"(",
"year",
")",
"term_index1",
"=",
"2... | Parse solar term and stem-branch year/month/day from a solar date.
(sy, sm, sd) => (term, next_gz_month)
term for year 2101,:2101.1.5(初六) 小寒 2101.1.20(廿一) 大寒 | [
"Parse",
"solar",
"term",
"and",
"stem",
"-",
"branch",
"year",
"/",
"month",
"/",
"day",
"from",
"a",
"solar",
"date",
".",
"(",
"sy",
"sm",
"sd",
")",
"=",
">",
"(",
"term",
"next_gz_month",
")",
"term",
"for",
"year",
"2101",
":",
"2101",
".",
... | python | train |
gem/oq-engine | openquake/hazardlib/gsim/edwards_fah_2013a.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/edwards_fah_2013a.py#L201-L208 | def _compute_term_4(self, C, mag, R):
"""
(a16 + a17.*M + a18.*M.*M + a19.*M.*M.*M).*(d(r).^3)
"""
return (
(C['a16'] + C['a17'] * mag + C['a18'] * np.power(mag, 2) +
C['a19'] * np.power(mag, 3)) * np.power(R, 3)
) | [
"def",
"_compute_term_4",
"(",
"self",
",",
"C",
",",
"mag",
",",
"R",
")",
":",
"return",
"(",
"(",
"C",
"[",
"'a16'",
"]",
"+",
"C",
"[",
"'a17'",
"]",
"*",
"mag",
"+",
"C",
"[",
"'a18'",
"]",
"*",
"np",
".",
"power",
"(",
"mag",
",",
"2"... | (a16 + a17.*M + a18.*M.*M + a19.*M.*M.*M).*(d(r).^3) | [
"(",
"a16",
"+",
"a17",
".",
"*",
"M",
"+",
"a18",
".",
"*",
"M",
".",
"*",
"M",
"+",
"a19",
".",
"*",
"M",
".",
"*",
"M",
".",
"*",
"M",
")",
".",
"*",
"(",
"d",
"(",
"r",
")",
".",
"^3",
")"
] | python | train |
codeinn/vcs | vcs/backends/git/repository.py | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/git/repository.py#L526-L574 | def get_diff(self, rev1, rev2, path=None, ignore_whitespace=False,
context=3):
"""
Returns (git like) *diff*, as plain text. Shows changes introduced by
``rev2`` since ``rev1``.
:param rev1: Entry point from which diff is shown. Can be
``self.EMPTY_CHANGESET``... | [
"def",
"get_diff",
"(",
"self",
",",
"rev1",
",",
"rev2",
",",
"path",
"=",
"None",
",",
"ignore_whitespace",
"=",
"False",
",",
"context",
"=",
"3",
")",
":",
"flags",
"=",
"[",
"'-U%s'",
"%",
"context",
",",
"'--full-index'",
",",
"'--binary'",
",",
... | Returns (git like) *diff*, as plain text. Shows changes introduced by
``rev2`` since ``rev1``.
:param rev1: Entry point from which diff is shown. Can be
``self.EMPTY_CHANGESET`` - in this case, patch showing all
the changes since empty state of the repository until ``rev2``
... | [
"Returns",
"(",
"git",
"like",
")",
"*",
"diff",
"*",
"as",
"plain",
"text",
".",
"Shows",
"changes",
"introduced",
"by",
"rev2",
"since",
"rev1",
"."
] | python | train |
doconix/django-mako-plus | django_mako_plus/filters.py | https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/filters.py#L64-L124 | def alternate_syntax(local, using, **kwargs):
'''
A Mako filter that renders a block of text using a different template engine
than Mako. The named template engine must be listed in settings.TEMPLATES.
The template context variables are available in the embedded template.
Specify kwargs to add add... | [
"def",
"alternate_syntax",
"(",
"local",
",",
"using",
",",
"*",
"*",
"kwargs",
")",
":",
"# get the request (the MakoTemplateAdapter above places this in the context)",
"request",
"=",
"local",
".",
"context",
"[",
"'request'",
"]",
"if",
"isinstance",
"(",
"local",
... | A Mako filter that renders a block of text using a different template engine
than Mako. The named template engine must be listed in settings.TEMPLATES.
The template context variables are available in the embedded template.
Specify kwargs to add additional variables created within the template.
This i... | [
"A",
"Mako",
"filter",
"that",
"renders",
"a",
"block",
"of",
"text",
"using",
"a",
"different",
"template",
"engine",
"than",
"Mako",
".",
"The",
"named",
"template",
"engine",
"must",
"be",
"listed",
"in",
"settings",
".",
"TEMPLATES",
"."
] | python | train |
mobinrg/rpi_spark_drives | JMRPiSpark/Drives/Audio/RPiAudio.py | https://github.com/mobinrg/rpi_spark_drives/blob/e1602d8268a5ef48e9e0a8b37de89e0233f946ea/JMRPiSpark/Drives/Audio/RPiAudio.py#L91-L115 | def off(self):
"""!
\~english
Close Audio output. set pin mode to output
@return a boolean value. if True means close audio output is OK otherwise failed to close.
\~chinese
关闭音频输出。 将引脚模式设置为输出
@return 布尔值。 如果为 True 关闭音频输出成功,否则关闭不成功。
"""
isOK = Tru... | [
"def",
"off",
"(",
"self",
")",
":",
"isOK",
"=",
"True",
"try",
":",
"if",
"self",
".",
"channelR",
"!=",
"None",
":",
"sub",
".",
"call",
"(",
"[",
"\"gpio\"",
",",
"\"-g\"",
",",
"\"mode\"",
",",
"\"{}\"",
".",
"format",
"(",
"self",
".",
"cha... | !
\~english
Close Audio output. set pin mode to output
@return a boolean value. if True means close audio output is OK otherwise failed to close.
\~chinese
关闭音频输出。 将引脚模式设置为输出
@return 布尔值。 如果为 True 关闭音频输出成功,否则关闭不成功。 | [
"!",
"\\",
"~english",
"Close",
"Audio",
"output",
".",
"set",
"pin",
"mode",
"to",
"output",
"@return",
"a",
"boolean",
"value",
".",
"if",
"True",
"means",
"close",
"audio",
"output",
"is",
"OK",
"otherwise",
"failed",
"to",
"close",
"."
] | python | train |
quintusdias/glymur | glymur/lib/openjpeg.py | https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/lib/openjpeg.py#L497-L516 | def encode(cinfo, cio, image):
"""Wrapper for openjpeg library function opj_encode.
Encodes an image into a JPEG-2000 codestream.
Parameters
----------
cinfo : compression handle
cio : output buffer stream
image : image to encode
"""
argtypes = [ctypes.POINTER(CompressionInfoType... | [
"def",
"encode",
"(",
"cinfo",
",",
"cio",
",",
"image",
")",
":",
"argtypes",
"=",
"[",
"ctypes",
".",
"POINTER",
"(",
"CompressionInfoType",
")",
",",
"ctypes",
".",
"POINTER",
"(",
"CioType",
")",
",",
"ctypes",
".",
"POINTER",
"(",
"ImageType",
")"... | Wrapper for openjpeg library function opj_encode.
Encodes an image into a JPEG-2000 codestream.
Parameters
----------
cinfo : compression handle
cio : output buffer stream
image : image to encode | [
"Wrapper",
"for",
"openjpeg",
"library",
"function",
"opj_encode",
"."
] | python | train |
matousc89/padasip | padasip/filters/rls.py | https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/filters/rls.py#L208-L224 | def adapt(self, d, x):
"""
Adapt weights according one desired value and its input.
**Args:**
* `d` : desired value (float)
* `x` : input array (1-dimensional array)
"""
y = np.dot(self.w, x)
e = d - y
R1 = np.dot(np.dot(np.dot(self.R,x),x.T),se... | [
"def",
"adapt",
"(",
"self",
",",
"d",
",",
"x",
")",
":",
"y",
"=",
"np",
".",
"dot",
"(",
"self",
".",
"w",
",",
"x",
")",
"e",
"=",
"d",
"-",
"y",
"R1",
"=",
"np",
".",
"dot",
"(",
"np",
".",
"dot",
"(",
"np",
".",
"dot",
"(",
"sel... | Adapt weights according one desired value and its input.
**Args:**
* `d` : desired value (float)
* `x` : input array (1-dimensional array) | [
"Adapt",
"weights",
"according",
"one",
"desired",
"value",
"and",
"its",
"input",
"."
] | python | train |
vallis/libstempo | libstempo/toasim.py | https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/toasim.py#L350-L360 | def add_line(psr,f,A,offset=0.5):
"""
Add a line of frequency `f` [Hz] and amplitude `A` [s],
with origin at a fraction `offset` through the dataset.
"""
t = psr.toas()
t0 = offset * (N.max(t) - N.min(t))
sine = A * N.cos(2 * math.pi * f * day * (t - t0))
psr.stoas[:] += sine / day | [
"def",
"add_line",
"(",
"psr",
",",
"f",
",",
"A",
",",
"offset",
"=",
"0.5",
")",
":",
"t",
"=",
"psr",
".",
"toas",
"(",
")",
"t0",
"=",
"offset",
"*",
"(",
"N",
".",
"max",
"(",
"t",
")",
"-",
"N",
".",
"min",
"(",
"t",
")",
")",
"si... | Add a line of frequency `f` [Hz] and amplitude `A` [s],
with origin at a fraction `offset` through the dataset. | [
"Add",
"a",
"line",
"of",
"frequency",
"f",
"[",
"Hz",
"]",
"and",
"amplitude",
"A",
"[",
"s",
"]",
"with",
"origin",
"at",
"a",
"fraction",
"offset",
"through",
"the",
"dataset",
"."
] | python | train |
apple/turicreate | deps/src/libxml2-2.9.1/python/libxml2.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/libxml2-2.9.1/python/libxml2.py#L820-L826 | def htmlParseFile(filename, encoding):
"""parse an HTML file and build a tree. Automatic support for
ZLIB/Compress compressed document is provided by default if
found at compile-time. """
ret = libxml2mod.htmlParseFile(filename, encoding)
if ret is None:raise parserError('htmlParseFile() failed... | [
"def",
"htmlParseFile",
"(",
"filename",
",",
"encoding",
")",
":",
"ret",
"=",
"libxml2mod",
".",
"htmlParseFile",
"(",
"filename",
",",
"encoding",
")",
"if",
"ret",
"is",
"None",
":",
"raise",
"parserError",
"(",
"'htmlParseFile() failed'",
")",
"return",
... | parse an HTML file and build a tree. Automatic support for
ZLIB/Compress compressed document is provided by default if
found at compile-time. | [
"parse",
"an",
"HTML",
"file",
"and",
"build",
"a",
"tree",
".",
"Automatic",
"support",
"for",
"ZLIB",
"/",
"Compress",
"compressed",
"document",
"is",
"provided",
"by",
"default",
"if",
"found",
"at",
"compile",
"-",
"time",
"."
] | python | train |
fbcotter/py3nvml | py3nvml/py3nvml.py | https://github.com/fbcotter/py3nvml/blob/47f0f2c0eee56dec4e4beebec26b734e01d357b7/py3nvml/py3nvml.py#L5333-L5369 | def nvmlDeviceGetTopologyNearestGpus(device, level):
r"""
/**
* Retrieve the set of GPUs that are nearest to a given device at a specific interconnectivity level
* For all products.
* Supported on Linux only.
*
* @param device The identifier of the first de... | [
"def",
"nvmlDeviceGetTopologyNearestGpus",
"(",
"device",
",",
"level",
")",
":",
"c_count",
"=",
"c_uint",
"(",
"0",
")",
"fn",
"=",
"_nvmlGetFunctionPointer",
"(",
"\"nvmlDeviceGetTopologyNearestGpus\"",
")",
"# First call will get the size",
"ret",
"=",
"fn",
"(",
... | r"""
/**
* Retrieve the set of GPUs that are nearest to a given device at a specific interconnectivity level
* For all products.
* Supported on Linux only.
*
* @param device The identifier of the first device
* @param level T... | [
"r",
"/",
"**",
"*",
"Retrieve",
"the",
"set",
"of",
"GPUs",
"that",
"are",
"nearest",
"to",
"a",
"given",
"device",
"at",
"a",
"specific",
"interconnectivity",
"level",
"*",
"For",
"all",
"products",
".",
"*",
"Supported",
"on",
"Linux",
"only",
".",
... | python | train |
emory-libraries/eulxml | eulxml/xmlmap/fields.py | https://github.com/emory-libraries/eulxml/blob/17d71c7d98c0cebda9932b7f13e72093805e1fe2/eulxml/xmlmap/fields.py#L1187-L1221 | def get_field(self, schema):
"""Get the requested type definition from the schema and return the
appropriate :class:`~eulxml.xmlmap.fields.Field`.
:param schema: instance of :class:`eulxml.xmlmap.core.XsdSchema`
:rtype: :class:`eulxml.xmlmap.fields.Field`
"""
type = sche... | [
"def",
"get_field",
"(",
"self",
",",
"schema",
")",
":",
"type",
"=",
"schema",
".",
"get_type",
"(",
"self",
".",
"schema_type",
")",
"logger",
".",
"debug",
"(",
"'Found schema type %s; base type %s, restricted values %s'",
"%",
"(",
"self",
".",
"schema_type... | Get the requested type definition from the schema and return the
appropriate :class:`~eulxml.xmlmap.fields.Field`.
:param schema: instance of :class:`eulxml.xmlmap.core.XsdSchema`
:rtype: :class:`eulxml.xmlmap.fields.Field` | [
"Get",
"the",
"requested",
"type",
"definition",
"from",
"the",
"schema",
"and",
"return",
"the",
"appropriate",
":",
"class",
":",
"~eulxml",
".",
"xmlmap",
".",
"fields",
".",
"Field",
"."
] | python | train |
radical-cybertools/radical.entk | src/radical/entk/execman/rp/task_processor.py | https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/execman/rp/task_processor.py#L423-L472 | def create_task_from_cu(cu, prof=None):
"""
Purpose: Create a Task based on the Compute Unit.
Details: Currently, only the uid, parent_stage and parent_pipeline are retrieved. The exact initial Task (that was
converted to a CUD) cannot be recovered as the RP API does not provide the same attributes for... | [
"def",
"create_task_from_cu",
"(",
"cu",
",",
"prof",
"=",
"None",
")",
":",
"try",
":",
"logger",
".",
"debug",
"(",
"'Create Task from CU %s'",
"%",
"cu",
".",
"name",
")",
"if",
"prof",
":",
"prof",
".",
"prof",
"(",
"'task from cu - create'",
",",
"u... | Purpose: Create a Task based on the Compute Unit.
Details: Currently, only the uid, parent_stage and parent_pipeline are retrieved. The exact initial Task (that was
converted to a CUD) cannot be recovered as the RP API does not provide the same attributes for a CU as for a CUD.
Also, this is not required f... | [
"Purpose",
":",
"Create",
"a",
"Task",
"based",
"on",
"the",
"Compute",
"Unit",
"."
] | python | train |
numenta/nupic | src/nupic/swarming/hypersearch/permutation_helpers.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/hypersearch/permutation_helpers.py#L212-L236 | def newPosition(self, globalBestPosition, rng):
"""See comments in base class."""
# First, update the velocity. The new velocity is given as:
# v = (inertia * v) + (cogRate * r1 * (localBest-pos))
# + (socRate * r2 * (globalBest-pos))
#
# where r1 and r2 are random numbers be... | [
"def",
"newPosition",
"(",
"self",
",",
"globalBestPosition",
",",
"rng",
")",
":",
"# First, update the velocity. The new velocity is given as:",
"# v = (inertia * v) + (cogRate * r1 * (localBest-pos))",
"# + (socRate * r2 * (globalBest-pos))",
"#",
"# where r1 and r... | See comments in base class. | [
"See",
"comments",
"in",
"base",
"class",
"."
] | python | valid |
Dallinger/Dallinger | dallinger/data.py | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/data.py#L139-L145 | def register(id, url=None):
"""Register a UUID key in the global S3 bucket."""
bucket = registration_s3_bucket()
key = registration_key(id)
obj = bucket.Object(key)
obj.put(Body=url or "missing")
return _generate_s3_url(bucket, key) | [
"def",
"register",
"(",
"id",
",",
"url",
"=",
"None",
")",
":",
"bucket",
"=",
"registration_s3_bucket",
"(",
")",
"key",
"=",
"registration_key",
"(",
"id",
")",
"obj",
"=",
"bucket",
".",
"Object",
"(",
"key",
")",
"obj",
".",
"put",
"(",
"Body",
... | Register a UUID key in the global S3 bucket. | [
"Register",
"a",
"UUID",
"key",
"in",
"the",
"global",
"S3",
"bucket",
"."
] | python | train |
peterldowns/lggr | lggr/__init__.py | https://github.com/peterldowns/lggr/blob/622968f17133e02d9a46a4900dd20fb3b19fe961/lggr/__init__.py#L263-L268 | def error(self, msg, *args, **kwargs):
""" Log a message with ERROR level. Automatically includes stack and
process info unless they are specifically not included. """
kwargs.setdefault('inc_stackinfo', True)
kwargs.setdefault('inc_multiproc', True)
self.log(ERROR, msg, args, **k... | [
"def",
"error",
"(",
"self",
",",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'inc_stackinfo'",
",",
"True",
")",
"kwargs",
".",
"setdefault",
"(",
"'inc_multiproc'",
",",
"True",
")",
"self",
".",
"... | Log a message with ERROR level. Automatically includes stack and
process info unless they are specifically not included. | [
"Log",
"a",
"message",
"with",
"ERROR",
"level",
".",
"Automatically",
"includes",
"stack",
"and",
"process",
"info",
"unless",
"they",
"are",
"specifically",
"not",
"included",
"."
] | python | train |
wbond/certbuilder | certbuilder/__init__.py | https://github.com/wbond/certbuilder/blob/969dae884fa7f73988bbf1dcbec4fb51e234a3c5/certbuilder/__init__.py#L688-L699 | def ocsp_no_check(self, value):
"""
A bool - if the certificate should have the OCSP no check extension.
Only applicable to certificates created for signing OCSP responses.
Such certificates should normally be issued for a very short period of
time since they are effectively whit... | [
"def",
"ocsp_no_check",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"self",
".",
"_ocsp_no_check",
"=",
"None",
"else",
":",
"self",
".",
"_ocsp_no_check",
"=",
"bool",
"(",
"value",
")"
] | A bool - if the certificate should have the OCSP no check extension.
Only applicable to certificates created for signing OCSP responses.
Such certificates should normally be issued for a very short period of
time since they are effectively whitelisted by clients. | [
"A",
"bool",
"-",
"if",
"the",
"certificate",
"should",
"have",
"the",
"OCSP",
"no",
"check",
"extension",
".",
"Only",
"applicable",
"to",
"certificates",
"created",
"for",
"signing",
"OCSP",
"responses",
".",
"Such",
"certificates",
"should",
"normally",
"be... | python | train |
yamcs/yamcs-python | yamcs-client/yamcs/tmtc/client.py | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/yamcs/tmtc/client.py#L554-L589 | def set_default_calibrator(self, parameter, type, data): # pylint: disable=W0622
"""
Apply a calibrator while processing raw values of the specified
parameter. If there is already a default calibrator associated
to this parameter, that calibrator gets replaced.
.. note::
... | [
"def",
"set_default_calibrator",
"(",
"self",
",",
"parameter",
",",
"type",
",",
"data",
")",
":",
"# pylint: disable=W0622",
"req",
"=",
"mdb_pb2",
".",
"ChangeParameterRequest",
"(",
")",
"req",
".",
"action",
"=",
"mdb_pb2",
".",
"ChangeParameterRequest",
".... | Apply a calibrator while processing raw values of the specified
parameter. If there is already a default calibrator associated
to this parameter, that calibrator gets replaced.
.. note::
Contextual calibrators take precedence over the default calibrator
See :meth:`set_c... | [
"Apply",
"a",
"calibrator",
"while",
"processing",
"raw",
"values",
"of",
"the",
"specified",
"parameter",
".",
"If",
"there",
"is",
"already",
"a",
"default",
"calibrator",
"associated",
"to",
"this",
"parameter",
"that",
"calibrator",
"gets",
"replaced",
"."
] | python | train |
rmed/pyemtmad | pyemtmad/api/parking.py | https://github.com/rmed/pyemtmad/blob/c21c42d0c7b50035dfed29540d7e64ab67833728/pyemtmad/api/parking.py#L308-L329 | def list_types_poi(self, **kwargs):
"""Obtain a list of families, types and categories of POI.
Args:
lang (str): Language code (*es* or *en*).
Returns:
Status boolean and parsed response (list[ParkingPoiType]), or message
string in case of error.
"""... | [
"def",
"list_types_poi",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Endpoint parameters",
"url_args",
"=",
"{",
"'language'",
":",
"util",
".",
"language_code",
"(",
"kwargs",
".",
"get",
"(",
"'lang'",
")",
")",
"}",
"# Request",
"result",
"=",
... | Obtain a list of families, types and categories of POI.
Args:
lang (str): Language code (*es* or *en*).
Returns:
Status boolean and parsed response (list[ParkingPoiType]), or message
string in case of error. | [
"Obtain",
"a",
"list",
"of",
"families",
"types",
"and",
"categories",
"of",
"POI",
"."
] | python | train |
Asana/python-asana | asana/resources/gen/tasks.py | https://github.com/Asana/python-asana/blob/6deb7a34495db23f44858e53b6bb2c9eccff7872/asana/resources/gen/tasks.py#L241-L252 | def remove_followers(self, task, params={}, **options):
"""Removes each of the specified followers from the task if they are
following. Returns the complete, updated record for the affected task.
Parameters
----------
task : {Id} The task to remove followers from.
[data... | [
"def",
"remove_followers",
"(",
"self",
",",
"task",
",",
"params",
"=",
"{",
"}",
",",
"*",
"*",
"options",
")",
":",
"path",
"=",
"\"/tasks/%s/removeFollowers\"",
"%",
"(",
"task",
")",
"return",
"self",
".",
"client",
".",
"post",
"(",
"path",
",",
... | Removes each of the specified followers from the task if they are
following. Returns the complete, updated record for the affected task.
Parameters
----------
task : {Id} The task to remove followers from.
[data] : {Object} Data for the request
- followers : {Array} An... | [
"Removes",
"each",
"of",
"the",
"specified",
"followers",
"from",
"the",
"task",
"if",
"they",
"are",
"following",
".",
"Returns",
"the",
"complete",
"updated",
"record",
"for",
"the",
"affected",
"task",
"."
] | python | train |
af/turrentine | turrentine/views.py | https://github.com/af/turrentine/blob/bbbd5139744ccc6264595cc8960784e5c308c009/turrentine/views.py#L78-L89 | def _try_url_with_appended_slash(self):
"""
Try our URL with an appended slash. If a CMS page is found at that URL, redirect to it.
If no page is found at that URL, raise Http404.
"""
new_url_to_try = self.kwargs.get('path', '') + '/'
if not new_url_to_try.startswith('/')... | [
"def",
"_try_url_with_appended_slash",
"(",
"self",
")",
":",
"new_url_to_try",
"=",
"self",
".",
"kwargs",
".",
"get",
"(",
"'path'",
",",
"''",
")",
"+",
"'/'",
"if",
"not",
"new_url_to_try",
".",
"startswith",
"(",
"'/'",
")",
":",
"new_url_to_try",
"="... | Try our URL with an appended slash. If a CMS page is found at that URL, redirect to it.
If no page is found at that URL, raise Http404. | [
"Try",
"our",
"URL",
"with",
"an",
"appended",
"slash",
".",
"If",
"a",
"CMS",
"page",
"is",
"found",
"at",
"that",
"URL",
"redirect",
"to",
"it",
".",
"If",
"no",
"page",
"is",
"found",
"at",
"that",
"URL",
"raise",
"Http404",
"."
] | python | train |
ariebovenberg/gentools | gentools/core.py | https://github.com/ariebovenberg/gentools/blob/4a1f9f928c7f8b4752b69168858e83b4b23d6bcb/gentools/core.py#L351-L372 | def imap_send(func, gen):
"""Apply a function to all ``send`` values of a generator
Parameters
----------
func: ~typing.Callable[[T_send], T_mapped]
the function to apply
gen: Generable[T_yield, T_mapped, T_return]
the generator iterable.
Returns
-------
~typing.Generat... | [
"def",
"imap_send",
"(",
"func",
",",
"gen",
")",
":",
"gen",
"=",
"iter",
"(",
"gen",
")",
"assert",
"_is_just_started",
"(",
"gen",
")",
"yielder",
"=",
"yield_from",
"(",
"gen",
")",
"for",
"item",
"in",
"yielder",
":",
"with",
"yielder",
":",
"yi... | Apply a function to all ``send`` values of a generator
Parameters
----------
func: ~typing.Callable[[T_send], T_mapped]
the function to apply
gen: Generable[T_yield, T_mapped, T_return]
the generator iterable.
Returns
-------
~typing.Generator[T_yield, T_send, T_return]
... | [
"Apply",
"a",
"function",
"to",
"all",
"send",
"values",
"of",
"a",
"generator"
] | python | valid |
pypa/pipenv | pipenv/vendor/jinja2/nodes.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/nodes.py#L219-L226 | def set_environment(self, environment):
"""Set the environment for all nodes."""
todo = deque([self])
while todo:
node = todo.popleft()
node.environment = environment
todo.extend(node.iter_child_nodes())
return self | [
"def",
"set_environment",
"(",
"self",
",",
"environment",
")",
":",
"todo",
"=",
"deque",
"(",
"[",
"self",
"]",
")",
"while",
"todo",
":",
"node",
"=",
"todo",
".",
"popleft",
"(",
")",
"node",
".",
"environment",
"=",
"environment",
"todo",
".",
"... | Set the environment for all nodes. | [
"Set",
"the",
"environment",
"for",
"all",
"nodes",
"."
] | python | train |
mikedh/trimesh | trimesh/primitives.py | https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/primitives.py#L639-L651 | def direction(self):
"""
Based on the extrudes transform, what is the vector along
which the polygon will be extruded
Returns
---------
direction: (3,) float vector. If self.primitive.transform is an
identity matrix this will be [0.0, 0.0, 1.0]
... | [
"def",
"direction",
"(",
"self",
")",
":",
"direction",
"=",
"np",
".",
"dot",
"(",
"self",
".",
"primitive",
".",
"transform",
"[",
":",
"3",
",",
":",
"3",
"]",
",",
"[",
"0.0",
",",
"0.0",
",",
"np",
".",
"sign",
"(",
"self",
".",
"primitive... | Based on the extrudes transform, what is the vector along
which the polygon will be extruded
Returns
---------
direction: (3,) float vector. If self.primitive.transform is an
identity matrix this will be [0.0, 0.0, 1.0] | [
"Based",
"on",
"the",
"extrudes",
"transform",
"what",
"is",
"the",
"vector",
"along",
"which",
"the",
"polygon",
"will",
"be",
"extruded"
] | python | train |
markovmodel/PyEMMA | pyemma/plots/plots2d.py | https://github.com/markovmodel/PyEMMA/blob/5c3124398217de05ba5ce9c8fb01519222481ab8/pyemma/plots/plots2d.py#L253-L377 | def plot_map(
x, y, z, ax=None, cmap=None,
ncontours=100, vmin=None, vmax=None, levels=None,
cbar=True, cax=None, cbar_label=None,
cbar_orientation='vertical', norm=None,
**kwargs):
"""Plot a two-dimensional map from data on a grid.
Parameters
----------
x : ndar... | [
"def",
"plot_map",
"(",
"x",
",",
"y",
",",
"z",
",",
"ax",
"=",
"None",
",",
"cmap",
"=",
"None",
",",
"ncontours",
"=",
"100",
",",
"vmin",
"=",
"None",
",",
"vmax",
"=",
"None",
",",
"levels",
"=",
"None",
",",
"cbar",
"=",
"True",
",",
"c... | Plot a two-dimensional map from data on a grid.
Parameters
----------
x : ndarray(T)
Binned x-coordinates.
y : ndarray(T)
Binned y-coordinates.
z : ndarray(T)
Binned z-coordinates.
ax : matplotlib.Axes object, optional, default=None
The ax to plot to; if ax=None,... | [
"Plot",
"a",
"two",
"-",
"dimensional",
"map",
"from",
"data",
"on",
"a",
"grid",
"."
] | python | train |
trailofbits/manticore | manticore/core/smtlib/visitors.py | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/core/smtlib/visitors.py#L529-L539 | def visit_BitVecShiftLeft(self, expression, *operands):
""" a << 0 => a remove zero
a << ct => 0 if ct > sizeof(a) remove big constant shift
"""
left = expression.operands[0]
right = expression.operands[1]
if isinstance(right, BitVecConstant):... | [
"def",
"visit_BitVecShiftLeft",
"(",
"self",
",",
"expression",
",",
"*",
"operands",
")",
":",
"left",
"=",
"expression",
".",
"operands",
"[",
"0",
"]",
"right",
"=",
"expression",
".",
"operands",
"[",
"1",
"]",
"if",
"isinstance",
"(",
"right",
",",
... | a << 0 => a remove zero
a << ct => 0 if ct > sizeof(a) remove big constant shift | [
"a",
"<<",
"0",
"=",
">",
"a",
"remove",
"zero",
"a",
"<<",
"ct",
"=",
">",
"0",
"if",
"ct",
">",
"sizeof",
"(",
"a",
")",
"remove",
"big",
"constant",
"shift"
] | python | valid |
waqasbhatti/astrobase | astrobase/services/dust.py | https://github.com/waqasbhatti/astrobase/blob/2922a14619d183fb28005fa7d02027ac436f2265/astrobase/services/dust.py#L88-L257 | def extinction_query(lon, lat,
coordtype='equatorial',
sizedeg=5.0,
forcefetch=False,
cachedir='~/.astrobase/dust-cache',
verbose=True,
timeout=10.0,
jitter=5.0):
'''Thi... | [
"def",
"extinction_query",
"(",
"lon",
",",
"lat",
",",
"coordtype",
"=",
"'equatorial'",
",",
"sizedeg",
"=",
"5.0",
",",
"forcefetch",
"=",
"False",
",",
"cachedir",
"=",
"'~/.astrobase/dust-cache'",
",",
"verbose",
"=",
"True",
",",
"timeout",
"=",
"10.0"... | This queries the 2MASS DUST service to find the extinction parameters
for the given `lon`, `lat`.
Parameters
----------
lon,lat: float
These are decimal right ascension and declination if `coordtype =
'equatorial'`. These are are decimal Galactic longitude and latitude if
`coor... | [
"This",
"queries",
"the",
"2MASS",
"DUST",
"service",
"to",
"find",
"the",
"extinction",
"parameters",
"for",
"the",
"given",
"lon",
"lat",
"."
] | python | valid |
saltstack/salt | salt/modules/twilio_notify.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/twilio_notify.py#L57-L67 | def _get_twilio(profile):
'''
Return the twilio connection
'''
creds = __salt__['config.option'](profile)
client = TwilioRestClient(
creds.get('twilio.account_sid'),
creds.get('twilio.auth_token'),
)
return client | [
"def",
"_get_twilio",
"(",
"profile",
")",
":",
"creds",
"=",
"__salt__",
"[",
"'config.option'",
"]",
"(",
"profile",
")",
"client",
"=",
"TwilioRestClient",
"(",
"creds",
".",
"get",
"(",
"'twilio.account_sid'",
")",
",",
"creds",
".",
"get",
"(",
"'twil... | Return the twilio connection | [
"Return",
"the",
"twilio",
"connection"
] | python | train |
gawel/aiocron | aiocron/__init__.py | https://github.com/gawel/aiocron/blob/949870b2f7fe1e10e4220f3243c9d4237255d203/aiocron/__init__.py#L71-L73 | def get_next(self):
"""Return next iteration time related to loop time"""
return self.loop_time + (self.croniter.get_next(float) - self.time) | [
"def",
"get_next",
"(",
"self",
")",
":",
"return",
"self",
".",
"loop_time",
"+",
"(",
"self",
".",
"croniter",
".",
"get_next",
"(",
"float",
")",
"-",
"self",
".",
"time",
")"
] | Return next iteration time related to loop time | [
"Return",
"next",
"iteration",
"time",
"related",
"to",
"loop",
"time"
] | python | train |
dw/mitogen | mitogen/parent.py | https://github.com/dw/mitogen/blob/a7fdb55e1300a7e0a5e404b09eb730cf9a525da7/mitogen/parent.py#L807-L819 | def wstatus_to_str(status):
"""
Parse and format a :func:`os.waitpid` exit status.
"""
if os.WIFEXITED(status):
return 'exited with return code %d' % (os.WEXITSTATUS(status),)
if os.WIFSIGNALED(status):
n = os.WTERMSIG(status)
return 'exited due to signal %d (%s)' % (n, SIGNA... | [
"def",
"wstatus_to_str",
"(",
"status",
")",
":",
"if",
"os",
".",
"WIFEXITED",
"(",
"status",
")",
":",
"return",
"'exited with return code %d'",
"%",
"(",
"os",
".",
"WEXITSTATUS",
"(",
"status",
")",
",",
")",
"if",
"os",
".",
"WIFSIGNALED",
"(",
"sta... | Parse and format a :func:`os.waitpid` exit status. | [
"Parse",
"and",
"format",
"a",
":",
"func",
":",
"os",
".",
"waitpid",
"exit",
"status",
"."
] | python | train |
brutasse/graphite-api | graphite_api/render/glyph.py | https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/render/glyph.py#L401-L446 | def applySettings(self, axisMin=None, axisMax=None, axisLimit=None):
"""Apply the specified settings to this axis.
Set self.minValue, self.minValueSource, self.maxValue,
self.maxValueSource, and self.axisLimit reasonably based on the
parameters provided.
Arguments:
axi... | [
"def",
"applySettings",
"(",
"self",
",",
"axisMin",
"=",
"None",
",",
"axisMax",
"=",
"None",
",",
"axisLimit",
"=",
"None",
")",
":",
"if",
"axisMin",
"is",
"not",
"None",
"and",
"not",
"math",
".",
"isnan",
"(",
"axisMin",
")",
":",
"self",
".",
... | Apply the specified settings to this axis.
Set self.minValue, self.minValueSource, self.maxValue,
self.maxValueSource, and self.axisLimit reasonably based on the
parameters provided.
Arguments:
axisMin -- a finite number, or None to choose a round minimum
limit tha... | [
"Apply",
"the",
"specified",
"settings",
"to",
"this",
"axis",
"."
] | python | train |
ereOn/azmq | azmq/common.py | https://github.com/ereOn/azmq/blob/9f40d6d721eea7f7659ec6cc668811976db59854/azmq/common.py#L428-L441 | def write_nowait(self, item):
"""
Write in the box in a non-blocking manner.
If the box is full, an exception is thrown. You should always check
for fullness with `full` or `wait_not_full` before calling this method.
:param item: An item.
"""
self._queue.put_now... | [
"def",
"write_nowait",
"(",
"self",
",",
"item",
")",
":",
"self",
".",
"_queue",
".",
"put_nowait",
"(",
"item",
")",
"self",
".",
"_can_read",
".",
"set",
"(",
")",
"if",
"self",
".",
"_queue",
".",
"full",
"(",
")",
":",
"self",
".",
"_can_write... | Write in the box in a non-blocking manner.
If the box is full, an exception is thrown. You should always check
for fullness with `full` or `wait_not_full` before calling this method.
:param item: An item. | [
"Write",
"in",
"the",
"box",
"in",
"a",
"non",
"-",
"blocking",
"manner",
"."
] | python | train |
cuihantao/andes | andes/models/base.py | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1462-L1483 | def _check_Vn(self):
"""Check data consistency of Vn and Vdcn if connected to Bus or Node
:return None
"""
if hasattr(self, 'bus') and hasattr(self, 'Vn'):
bus_Vn = self.read_data_ext('Bus', field='Vn', idx=self.bus)
for name, bus, Vn, Vn0 in zip(self.name, self.... | [
"def",
"_check_Vn",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'bus'",
")",
"and",
"hasattr",
"(",
"self",
",",
"'Vn'",
")",
":",
"bus_Vn",
"=",
"self",
".",
"read_data_ext",
"(",
"'Bus'",
",",
"field",
"=",
"'Vn'",
",",
"idx",
"=",... | Check data consistency of Vn and Vdcn if connected to Bus or Node
:return None | [
"Check",
"data",
"consistency",
"of",
"Vn",
"and",
"Vdcn",
"if",
"connected",
"to",
"Bus",
"or",
"Node"
] | python | train |
inspirehep/harvesting-kit | harvestingkit/bibrecord.py | https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/bibrecord.py#L1579-L1597 | def _compare_fields(field1, field2, strict=True):
"""
Compare 2 fields.
If strict is True, then the order of the subfield will be taken care of, if
not then the order of the subfields doesn't matter.
:return: True if the field are equivalent, False otherwise.
"""
if strict:
# Retur... | [
"def",
"_compare_fields",
"(",
"field1",
",",
"field2",
",",
"strict",
"=",
"True",
")",
":",
"if",
"strict",
":",
"# Return a simple equal test on the field minus the position.",
"return",
"field1",
"[",
":",
"4",
"]",
"==",
"field2",
"[",
":",
"4",
"]",
"els... | Compare 2 fields.
If strict is True, then the order of the subfield will be taken care of, if
not then the order of the subfields doesn't matter.
:return: True if the field are equivalent, False otherwise. | [
"Compare",
"2",
"fields",
"."
] | python | valid |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.