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 |
|---|---|---|---|---|---|---|---|---|
wummel/linkchecker | linkcheck/fileutil.py | https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/fileutil.py#L31-L57 | def write_file (filename, content, backup=False, callback=None):
"""Overwrite a possibly existing file with new content. Do this
in a manner that does not leave truncated or broken files behind.
@param filename: name of file to write
@type filename: string
@param content: file content to write
@... | [
"def",
"write_file",
"(",
"filename",
",",
"content",
",",
"backup",
"=",
"False",
",",
"callback",
"=",
"None",
")",
":",
"# first write in a temp file",
"f",
"=",
"file",
"(",
"filename",
"+",
"\".tmp\"",
",",
"'wb'",
")",
"if",
"callback",
"is",
"None",... | Overwrite a possibly existing file with new content. Do this
in a manner that does not leave truncated or broken files behind.
@param filename: name of file to write
@type filename: string
@param content: file content to write
@type content: string
@param backup: if backup file should be left
... | [
"Overwrite",
"a",
"possibly",
"existing",
"file",
"with",
"new",
"content",
".",
"Do",
"this",
"in",
"a",
"manner",
"that",
"does",
"not",
"leave",
"truncated",
"or",
"broken",
"files",
"behind",
"."
] | python | train |
vpelletier/python-libusb1 | usb1/__init__.py | https://github.com/vpelletier/python-libusb1/blob/740c9778e28523e4ec3543415d95f5400ae0fa24/usb1/__init__.py#L692-L710 | def getISOBufferList(self):
"""
Get individual ISO transfer's buffer.
Returns a list with one item per ISO transfer, with their
individually-configured sizes.
Returned list is consistent with getISOSetupList return value.
Should not be called on a submitted transfer.
... | [
"def",
"getISOBufferList",
"(",
"self",
")",
":",
"transfer_p",
"=",
"self",
".",
"__transfer",
"transfer",
"=",
"transfer_p",
".",
"contents",
"# pylint: disable=undefined-variable",
"if",
"transfer",
".",
"type",
"!=",
"TRANSFER_TYPE_ISOCHRONOUS",
":",
"# pylint: en... | Get individual ISO transfer's buffer.
Returns a list with one item per ISO transfer, with their
individually-configured sizes.
Returned list is consistent with getISOSetupList return value.
Should not be called on a submitted transfer.
See also iterISO. | [
"Get",
"individual",
"ISO",
"transfer",
"s",
"buffer",
".",
"Returns",
"a",
"list",
"with",
"one",
"item",
"per",
"ISO",
"transfer",
"with",
"their",
"individually",
"-",
"configured",
"sizes",
".",
"Returned",
"list",
"is",
"consistent",
"with",
"getISOSetupL... | python | train |
pytorch/ignite | ignite/contrib/handlers/param_scheduler.py | https://github.com/pytorch/ignite/blob/a96bd07cb58822cfb39fd81765135712f1db41ca/ignite/contrib/handlers/param_scheduler.py#L460-L481 | def simulate_values(cls, num_events, lr_scheduler, **kwargs):
"""Method to simulate scheduled values during num_events events.
Args:
num_events (int): number of events during the simulation.
lr_scheduler (subclass of `torch.optim.lr_scheduler._LRScheduler`): lr_scheduler object ... | [
"def",
"simulate_values",
"(",
"cls",
",",
"num_events",
",",
"lr_scheduler",
",",
"*",
"*",
"kwargs",
")",
":",
"# This scheduler uses `torch.optim.lr_scheduler._LRScheduler` which",
"# should be replicated in order to simulate LR values and",
"# not perturb original scheduler.",
... | Method to simulate scheduled values during num_events events.
Args:
num_events (int): number of events during the simulation.
lr_scheduler (subclass of `torch.optim.lr_scheduler._LRScheduler`): lr_scheduler object to wrap.
Returns:
list of pairs: [event_index, value... | [
"Method",
"to",
"simulate",
"scheduled",
"values",
"during",
"num_events",
"events",
"."
] | python | train |
MacHu-GWU/docfly-project | docfly/api_reference_doc.py | https://github.com/MacHu-GWU/docfly-project/blob/46da8a9793211301c3ebc12d195228dbf79fdfec/docfly/api_reference_doc.py#L144-L170 | def generate_package_content(self, package):
"""Generate package.rst text content.
::
{{ package_name }}
==================
.. automodule:: {{ package_name }}
:members:
sub packages and modules
------------------------
... | [
"def",
"generate_package_content",
"(",
"self",
",",
"package",
")",
":",
"if",
"isinstance",
"(",
"package",
",",
"Package",
")",
":",
"return",
"package",
".",
"render",
"(",
"ignored_package",
"=",
"self",
".",
"ignored_package",
")",
"else",
":",
"# prag... | Generate package.rst text content.
::
{{ package_name }}
==================
.. automodule:: {{ package_name }}
:members:
sub packages and modules
------------------------
.. toctree::
:maxdepth: 1
... | [
"Generate",
"package",
".",
"rst",
"text",
"content",
"."
] | python | train |
gabstopper/smc-python | smc/core/node.py | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/core/node.py#L532-L546 | def change_ssh_pwd(self, pwd=None, comment=None):
"""
Executes a change SSH password operation on the specified node
:param str pwd: changed password value
:param str comment: optional comment for audit log
:raises NodeCommandFailed: cannot change ssh password
:return: N... | [
"def",
"change_ssh_pwd",
"(",
"self",
",",
"pwd",
"=",
"None",
",",
"comment",
"=",
"None",
")",
":",
"self",
".",
"make_request",
"(",
"NodeCommandFailed",
",",
"method",
"=",
"'update'",
",",
"resource",
"=",
"'change_ssh_pwd'",
",",
"params",
"=",
"{",
... | Executes a change SSH password operation on the specified node
:param str pwd: changed password value
:param str comment: optional comment for audit log
:raises NodeCommandFailed: cannot change ssh password
:return: None | [
"Executes",
"a",
"change",
"SSH",
"password",
"operation",
"on",
"the",
"specified",
"node"
] | python | train |
pandas-dev/pandas | pandas/plotting/_misc.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_misc.py#L14-L133 | def scatter_matrix(frame, alpha=0.5, figsize=None, ax=None, grid=False,
diagonal='hist', marker='.', density_kwds=None,
hist_kwds=None, range_padding=0.05, **kwds):
"""
Draw a matrix of scatter plots.
Parameters
----------
frame : DataFrame
alpha : float, o... | [
"def",
"scatter_matrix",
"(",
"frame",
",",
"alpha",
"=",
"0.5",
",",
"figsize",
"=",
"None",
",",
"ax",
"=",
"None",
",",
"grid",
"=",
"False",
",",
"diagonal",
"=",
"'hist'",
",",
"marker",
"=",
"'.'",
",",
"density_kwds",
"=",
"None",
",",
"hist_k... | Draw a matrix of scatter plots.
Parameters
----------
frame : DataFrame
alpha : float, optional
amount of transparency applied
figsize : (float,float), optional
a tuple (width, height) in inches
ax : Matplotlib axis object, optional
grid : bool, optional
setting this... | [
"Draw",
"a",
"matrix",
"of",
"scatter",
"plots",
"."
] | python | train |
mbanton/nose-mongoengine | nose_mongoengine/__init__.py | https://github.com/mbanton/nose-mongoengine/blob/3a06f52cd32f217b512af4a76d8ed4174185df59/nose_mongoengine/__init__.py#L125-L227 | def configure(self, options, conf):
"""Parse the command line options and start an instance of mongodb
"""
# This option has to be specified on the command line, to enable the
# plugin.
if not options.mongoengine or options.mongodb_bin:
return
if not options.... | [
"def",
"configure",
"(",
"self",
",",
"options",
",",
"conf",
")",
":",
"# This option has to be specified on the command line, to enable the",
"# plugin.",
"if",
"not",
"options",
".",
"mongoengine",
"or",
"options",
".",
"mongodb_bin",
":",
"return",
"if",
"not",
... | Parse the command line options and start an instance of mongodb | [
"Parse",
"the",
"command",
"line",
"options",
"and",
"start",
"an",
"instance",
"of",
"mongodb"
] | python | train |
tgbugs/ontquery | ontquery/plugins/interlex_client.py | https://github.com/tgbugs/ontquery/blob/bcf4863cb2bf221afe2b093c5dc7da1377300041/ontquery/plugins/interlex_client.py#L403-L517 | def update_entity(
self,
ilx_id: str,
label: str = None,
type: str = None,
definition: str = None,
comment: str = None,
superclass: str = None,
synonyms: list = None) -> dict:
""" Updates pre-existing entity as long as the api_key is from the accou... | [
"def",
"update_entity",
"(",
"self",
",",
"ilx_id",
":",
"str",
",",
"label",
":",
"str",
"=",
"None",
",",
"type",
":",
"str",
"=",
"None",
",",
"definition",
":",
"str",
"=",
"None",
",",
"comment",
":",
"str",
"=",
"None",
",",
"superclass",
":"... | Updates pre-existing entity as long as the api_key is from the account that created it
Args:
label: name of entity
type: entities type
Can be any of the following: term, cde, fde, pde, annotation, relationship
definition: entities definiti... | [
"Updates",
"pre",
"-",
"existing",
"entity",
"as",
"long",
"as",
"the",
"api_key",
"is",
"from",
"the",
"account",
"that",
"created",
"it"
] | python | train |
SpriteLink/NIPAP | pynipap/pynipap.py | https://github.com/SpriteLink/NIPAP/blob/f96069f11ab952d80b13cab06e0528f2d24b3de9/pynipap/pynipap.py#L1077-L1111 | def smart_search(cls, query_string, search_options=None, extra_query = None):
""" Perform a smart prefix search.
Maps to the function
:py:func:`nipap.backend.Nipap.smart_search_prefix` in the backend.
Please see the documentation for the backend function for
info... | [
"def",
"smart_search",
"(",
"cls",
",",
"query_string",
",",
"search_options",
"=",
"None",
",",
"extra_query",
"=",
"None",
")",
":",
"if",
"search_options",
"is",
"None",
":",
"search_options",
"=",
"{",
"}",
"xmlrpc",
"=",
"XMLRPCConnection",
"(",
")",
... | Perform a smart prefix search.
Maps to the function
:py:func:`nipap.backend.Nipap.smart_search_prefix` in the backend.
Please see the documentation for the backend function for
information regarding input arguments and return values. | [
"Perform",
"a",
"smart",
"prefix",
"search",
"."
] | python | train |
openego/eDisGo | edisgo/data/import_data.py | https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/data/import_data.py#L118-L250 | def _build_lv_grid(ding0_grid, network):
"""
Build eDisGo LV grid from Ding0 data
Parameters
----------
ding0_grid: ding0.MVGridDing0
Ding0 MV grid object
Returns
-------
list of LVGrid
LV grids
dict
Dictionary containing a mapping of LV stations in Ding0 to... | [
"def",
"_build_lv_grid",
"(",
"ding0_grid",
",",
"network",
")",
":",
"lv_station_mapping",
"=",
"{",
"}",
"lv_grids",
"=",
"[",
"]",
"lv_grid_mapping",
"=",
"{",
"}",
"for",
"la",
"in",
"ding0_grid",
".",
"grid_district",
".",
"_lv_load_areas",
":",
"for",
... | Build eDisGo LV grid from Ding0 data
Parameters
----------
ding0_grid: ding0.MVGridDing0
Ding0 MV grid object
Returns
-------
list of LVGrid
LV grids
dict
Dictionary containing a mapping of LV stations in Ding0 to newly
created eDisGo LV stations. This mappi... | [
"Build",
"eDisGo",
"LV",
"grid",
"from",
"Ding0",
"data"
] | python | train |
yinkaisheng/Python-UIAutomation-for-Windows | uiautomation/uiautomation.py | https://github.com/yinkaisheng/Python-UIAutomation-for-Windows/blob/2cc91060982cc8b777152e698d677cc2989bf263/uiautomation/uiautomation.py#L2187-L2199 | def SetWindowPos(handle: int, hWndInsertAfter: int, x: int, y: int, width: int, height: int, flags: int) -> bool:
"""
SetWindowPos from Win32.
handle: int, the handle of a native window.
hWndInsertAfter: int, a value whose name starts with 'HWND' in class SWP.
x: int.
y: int.
width: int.
... | [
"def",
"SetWindowPos",
"(",
"handle",
":",
"int",
",",
"hWndInsertAfter",
":",
"int",
",",
"x",
":",
"int",
",",
"y",
":",
"int",
",",
"width",
":",
"int",
",",
"height",
":",
"int",
",",
"flags",
":",
"int",
")",
"->",
"bool",
":",
"return",
"ct... | SetWindowPos from Win32.
handle: int, the handle of a native window.
hWndInsertAfter: int, a value whose name starts with 'HWND' in class SWP.
x: int.
y: int.
width: int.
height: int.
flags: int, values whose name starts with 'SWP' in class `SWP`.
Return bool, True if succeed otherwise F... | [
"SetWindowPos",
"from",
"Win32",
".",
"handle",
":",
"int",
"the",
"handle",
"of",
"a",
"native",
"window",
".",
"hWndInsertAfter",
":",
"int",
"a",
"value",
"whose",
"name",
"starts",
"with",
"HWND",
"in",
"class",
"SWP",
".",
"x",
":",
"int",
".",
"y... | python | valid |
tensorpack/tensorpack | tensorpack/tfutils/varreplace.py | https://github.com/tensorpack/tensorpack/blob/d7a13cb74c9066bc791d7aafc3b744b60ee79a9f/tensorpack/tfutils/varreplace.py#L59-L97 | def freeze_variables(stop_gradient=True, skip_collection=False):
"""
Return a context to freeze variables,
by wrapping ``tf.get_variable`` with a custom getter.
It works by either applying ``tf.stop_gradient`` on the variables,
or by keeping them out of the ``TRAINABLE_VARIABLES`` collection, or
... | [
"def",
"freeze_variables",
"(",
"stop_gradient",
"=",
"True",
",",
"skip_collection",
"=",
"False",
")",
":",
"def",
"custom_getter",
"(",
"getter",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"trainable",
"=",
"kwargs",
".",
"get",
"(",
"'train... | Return a context to freeze variables,
by wrapping ``tf.get_variable`` with a custom getter.
It works by either applying ``tf.stop_gradient`` on the variables,
or by keeping them out of the ``TRAINABLE_VARIABLES`` collection, or
both.
Example:
.. code-block:: python
with varrepl... | [
"Return",
"a",
"context",
"to",
"freeze",
"variables",
"by",
"wrapping",
"tf",
".",
"get_variable",
"with",
"a",
"custom",
"getter",
".",
"It",
"works",
"by",
"either",
"applying",
"tf",
".",
"stop_gradient",
"on",
"the",
"variables",
"or",
"by",
"keeping",
... | python | train |
openstax/cnx-publishing | cnxpublishing/subscribers.py | https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/subscribers.py#L32-L64 | def post_publication_processing(event, cursor):
"""Process post-publication events coming out of the database."""
module_ident, ident_hash = event.module_ident, event.ident_hash
celery_app = get_current_registry().celery_app
# Check baking is not already queued.
cursor.execute('SELECT result_id::t... | [
"def",
"post_publication_processing",
"(",
"event",
",",
"cursor",
")",
":",
"module_ident",
",",
"ident_hash",
"=",
"event",
".",
"module_ident",
",",
"event",
".",
"ident_hash",
"celery_app",
"=",
"get_current_registry",
"(",
")",
".",
"celery_app",
"# Check bak... | Process post-publication events coming out of the database. | [
"Process",
"post",
"-",
"publication",
"events",
"coming",
"out",
"of",
"the",
"database",
"."
] | python | valid |
SBRG/ssbio | ssbio/protein/structure/homology/itasser/itasserprop.py | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/structure/homology/itasser/itasserprop.py#L240-L286 | def get_dict(self, only_attributes=None, exclude_attributes=None, df_format=False):
"""Summarize the I-TASSER run in a dictionary containing modeling results and top predictions from COACH
Args:
only_attributes (str, list): Attributes that should be returned. If not provided, all are return... | [
"def",
"get_dict",
"(",
"self",
",",
"only_attributes",
"=",
"None",
",",
"exclude_attributes",
"=",
"None",
",",
"df_format",
"=",
"False",
")",
":",
"to_exclude",
"=",
"[",
"'coach_bsites'",
",",
"'coach_ec'",
",",
"'coach_go_mf'",
",",
"'coach_go_bp'",
",",... | Summarize the I-TASSER run in a dictionary containing modeling results and top predictions from COACH
Args:
only_attributes (str, list): Attributes that should be returned. If not provided, all are returned.
exclude_attributes (str, list): Attributes that should be excluded.
... | [
"Summarize",
"the",
"I",
"-",
"TASSER",
"run",
"in",
"a",
"dictionary",
"containing",
"modeling",
"results",
"and",
"top",
"predictions",
"from",
"COACH"
] | python | train |
dossier/dossier.models | dossier/models/pairwise.py | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/pairwise.py#L309-L339 | def classify(self, feature_names, classifier, transformer, candidates,
query_fc=None):
'''Returns ``[probability]`` in correspondence with
``candidates``.
Where each ``probability`` corresponds to the probability that
the corresponding candidate is classified with a pos... | [
"def",
"classify",
"(",
"self",
",",
"feature_names",
",",
"classifier",
",",
"transformer",
",",
"candidates",
",",
"query_fc",
"=",
"None",
")",
":",
"if",
"query_fc",
"is",
"None",
":",
"query_fc",
"=",
"self",
".",
"query_fc",
"dis",
"=",
"{",
"}",
... | Returns ``[probability]`` in correspondence with
``candidates``.
Where each ``probability`` corresponds to the probability that
the corresponding candidate is classified with a positive label
given the training data.
The list returned is in correspondence with the list of
... | [
"Returns",
"[",
"probability",
"]",
"in",
"correspondence",
"with",
"candidates",
"."
] | python | train |
INM-6/hybridLFPy | examples/Hagen_et_al_2016_cercor/analysis_params.py | https://github.com/INM-6/hybridLFPy/blob/c38bdf38982c4624c2f70caeb50c40f1d5980abd/examples/Hagen_et_al_2016_cercor/analysis_params.py#L92-L96 | def set_default_fig_style(self):
'''default figure size'''
plt.rcParams.update({
'figure.figsize' : [self.frontierswidth/self.inchpercm, self.frontierswidth/self.inchpercm],
}) | [
"def",
"set_default_fig_style",
"(",
"self",
")",
":",
"plt",
".",
"rcParams",
".",
"update",
"(",
"{",
"'figure.figsize'",
":",
"[",
"self",
".",
"frontierswidth",
"/",
"self",
".",
"inchpercm",
",",
"self",
".",
"frontierswidth",
"/",
"self",
".",
"inchp... | default figure size | [
"default",
"figure",
"size"
] | python | train |
yaml/pyyaml | lib/yaml/__init__.py | https://github.com/yaml/pyyaml/blob/e471e86bf6dabdad45a1438c20a4a5c033eb9034/lib/yaml/__init__.py#L69-L78 | def parse(stream, Loader=Loader):
"""
Parse a YAML stream and produce parsing events.
"""
loader = Loader(stream)
try:
while loader.check_event():
yield loader.get_event()
finally:
loader.dispose() | [
"def",
"parse",
"(",
"stream",
",",
"Loader",
"=",
"Loader",
")",
":",
"loader",
"=",
"Loader",
"(",
"stream",
")",
"try",
":",
"while",
"loader",
".",
"check_event",
"(",
")",
":",
"yield",
"loader",
".",
"get_event",
"(",
")",
"finally",
":",
"load... | Parse a YAML stream and produce parsing events. | [
"Parse",
"a",
"YAML",
"stream",
"and",
"produce",
"parsing",
"events",
"."
] | python | train |
tensorflow/tensorboard | tensorboard/plugins/hparams/get_experiment.py | https://github.com/tensorflow/tensorboard/blob/8e5f497b48e40f2a774f85416b8a35ac0693c35e/tensorboard/plugins/hparams/get_experiment.py#L36-L52 | def run(self):
"""Handles the request specified on construction.
Returns:
An Experiment object.
"""
experiment = self._context.experiment()
if experiment is None:
raise error.HParamsError(
"Can't find an HParams-plugin experiment data in"
" the log directory. Note t... | [
"def",
"run",
"(",
"self",
")",
":",
"experiment",
"=",
"self",
".",
"_context",
".",
"experiment",
"(",
")",
"if",
"experiment",
"is",
"None",
":",
"raise",
"error",
".",
"HParamsError",
"(",
"\"Can't find an HParams-plugin experiment data in\"",
"\" the log dire... | Handles the request specified on construction.
Returns:
An Experiment object. | [
"Handles",
"the",
"request",
"specified",
"on",
"construction",
"."
] | python | train |
sepandhaghighi/pycm | pycm/pycm_obj.py | https://github.com/sepandhaghighi/pycm/blob/cb03258afd6a821d10acba73c965aaac174bedcd/pycm/pycm_obj.py#L269-L315 | def save_csv(
self,
name,
address=True,
class_param=None,
class_name=None,
matrix_save=True,
normalize=False):
"""
Save ConfusionMatrix in CSV file.
:param name: filename
:type name : str
:param ... | [
"def",
"save_csv",
"(",
"self",
",",
"name",
",",
"address",
"=",
"True",
",",
"class_param",
"=",
"None",
",",
"class_name",
"=",
"None",
",",
"matrix_save",
"=",
"True",
",",
"normalize",
"=",
"False",
")",
":",
"try",
":",
"message",
"=",
"None",
... | Save ConfusionMatrix in CSV file.
:param name: filename
:type name : str
:param address: flag for address return
:type address : bool
:param class_param : class parameters list for save, Example : ["TPR","TNR","AUC"]
:type class_param : list
:param class_name : c... | [
"Save",
"ConfusionMatrix",
"in",
"CSV",
"file",
"."
] | python | train |
meejah/txtorcon | txtorcon/onion.py | https://github.com/meejah/txtorcon/blob/14053b95adf0b4bd9dd9c317bece912a26578a93/txtorcon/onion.py#L1053-L1071 | def _compute_permanent_id(private_key):
"""
Internal helper. Return an authenticated service's permanent ID
given an RSA private key object.
The permanent ID is the base32 encoding of the SHA1 hash of the
first 10 bytes (80 bits) of the public key.
"""
pub = private_key.public_key()
p =... | [
"def",
"_compute_permanent_id",
"(",
"private_key",
")",
":",
"pub",
"=",
"private_key",
".",
"public_key",
"(",
")",
"p",
"=",
"pub",
".",
"public_bytes",
"(",
"encoding",
"=",
"serialization",
".",
"Encoding",
".",
"PEM",
",",
"format",
"=",
"serialization... | Internal helper. Return an authenticated service's permanent ID
given an RSA private key object.
The permanent ID is the base32 encoding of the SHA1 hash of the
first 10 bytes (80 bits) of the public key. | [
"Internal",
"helper",
".",
"Return",
"an",
"authenticated",
"service",
"s",
"permanent",
"ID",
"given",
"an",
"RSA",
"private",
"key",
"object",
"."
] | python | train |
jbm950/pygame_toolbox | pygame_toolbox/tilegame_tools/__init__.py | https://github.com/jbm950/pygame_toolbox/blob/3fe32145fc149e4dd0963c30a2b6a4dddd4fac0e/pygame_toolbox/tilegame_tools/__init__.py#L234-L260 | def set_offset(self, offset, mid=None):
"""This method will allow the menu to be placed anywhere in the open
window instead of just the upper left corner.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Inputs:
offset - This is the x,y tuple of the... | [
"def",
"set_offset",
"(",
"self",
",",
"offset",
",",
"mid",
"=",
"None",
")",
":",
"ptg",
".",
"BaseScreen",
".",
"set_offset",
"(",
"self",
",",
"offset",
",",
"mid",
")",
"for",
"i",
"in",
"self",
".",
"tilelist",
":",
"for",
"j",
"in",
"i",
"... | This method will allow the menu to be placed anywhere in the open
window instead of just the upper left corner.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Inputs:
offset - This is the x,y tuple of the position that you want to
move the... | [
"This",
"method",
"will",
"allow",
"the",
"menu",
"to",
"be",
"placed",
"anywhere",
"in",
"the",
"open",
"window",
"instead",
"of",
"just",
"the",
"upper",
"left",
"corner",
".",
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",
"Inputs",
":"... | python | train |
secdev/scapy | scapy/layers/tls/crypto/cipher_block.py | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/crypto/cipher_block.py#L77-L87 | def encrypt(self, data):
"""
Encrypt the data. Also, update the cipher iv. This is needed for SSLv3
and TLS 1.0. For TLS 1.1/1.2, it is overwritten in TLS.post_build().
"""
if False in six.itervalues(self.ready):
raise CipherError(data)
encryptor = self._ciphe... | [
"def",
"encrypt",
"(",
"self",
",",
"data",
")",
":",
"if",
"False",
"in",
"six",
".",
"itervalues",
"(",
"self",
".",
"ready",
")",
":",
"raise",
"CipherError",
"(",
"data",
")",
"encryptor",
"=",
"self",
".",
"_cipher",
".",
"encryptor",
"(",
")",
... | Encrypt the data. Also, update the cipher iv. This is needed for SSLv3
and TLS 1.0. For TLS 1.1/1.2, it is overwritten in TLS.post_build(). | [
"Encrypt",
"the",
"data",
".",
"Also",
"update",
"the",
"cipher",
"iv",
".",
"This",
"is",
"needed",
"for",
"SSLv3",
"and",
"TLS",
"1",
".",
"0",
".",
"For",
"TLS",
"1",
".",
"1",
"/",
"1",
".",
"2",
"it",
"is",
"overwritten",
"in",
"TLS",
".",
... | python | train |
pvlib/pvlib-python | pvlib/pvsystem.py | https://github.com/pvlib/pvlib-python/blob/2e844a595b820b43d1170269781fa66bd0ccc8a3/pvlib/pvsystem.py#L1539-L1645 | def retrieve_sam(name=None, path=None):
'''
Retrieve latest module and inverter info from a local file or the
SAM website.
This function will retrieve either:
* CEC module database
* Sandia Module database
* CEC Inverter database
* Anton Driesse Inverter database
a... | [
"def",
"retrieve_sam",
"(",
"name",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"if",
"name",
"is",
"not",
"None",
":",
"name",
"=",
"name",
".",
"lower",
"(",
")",
"data_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
... | Retrieve latest module and inverter info from a local file or the
SAM website.
This function will retrieve either:
* CEC module database
* Sandia Module database
* CEC Inverter database
* Anton Driesse Inverter database
and return it as a pandas DataFrame.
Parameters
... | [
"Retrieve",
"latest",
"module",
"and",
"inverter",
"info",
"from",
"a",
"local",
"file",
"or",
"the",
"SAM",
"website",
"."
] | python | train |
titusjan/argos | argos/repo/rtiplugins/hdf5.py | https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/repo/rtiplugins/hdf5.py#L306-L318 | def unit(self):
""" Returns the unit of the RTI by calling dataSetUnit on the underlying dataset
"""
unit = dataSetUnit(self._h5Dataset)
fieldNames = self._h5Dataset.dtype.names
# If the missing value attribute is a list with the same length as the number of fields,
# re... | [
"def",
"unit",
"(",
"self",
")",
":",
"unit",
"=",
"dataSetUnit",
"(",
"self",
".",
"_h5Dataset",
")",
"fieldNames",
"=",
"self",
".",
"_h5Dataset",
".",
"dtype",
".",
"names",
"# If the missing value attribute is a list with the same length as the number of fields,",
... | Returns the unit of the RTI by calling dataSetUnit on the underlying dataset | [
"Returns",
"the",
"unit",
"of",
"the",
"RTI",
"by",
"calling",
"dataSetUnit",
"on",
"the",
"underlying",
"dataset"
] | python | train |
elastic/elasticsearch-dsl-py | elasticsearch_dsl/search.py | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/search.py#L474-L517 | def source(self, fields=None, **kwargs):
"""
Selectively control how the _source field is returned.
:arg fields: wildcard string, array of wildcards, or dictionary of includes and excludes
If ``fields`` is None, the entire document will be returned for
each hit. If fields is a... | [
"def",
"source",
"(",
"self",
",",
"fields",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"s",
"=",
"self",
".",
"_clone",
"(",
")",
"if",
"fields",
"and",
"kwargs",
":",
"raise",
"ValueError",
"(",
"\"You cannot specify fields and kwargs at the same time... | Selectively control how the _source field is returned.
:arg fields: wildcard string, array of wildcards, or dictionary of includes and excludes
If ``fields`` is None, the entire document will be returned for
each hit. If fields is a dictionary with keys of 'include' and/or
'exclude' t... | [
"Selectively",
"control",
"how",
"the",
"_source",
"field",
"is",
"returned",
"."
] | python | train |
cathalgarvey/deadlock | deadlock/core.py | https://github.com/cathalgarvey/deadlock/blob/30099b476ff767611ce617150a0c574fc03fdf79/deadlock/core.py#L136-L166 | def main_encrypt(A):
"Encrypt to recipient list using primary key OR prompted key. Recipients may be IDs or petnames."
profile = get_profile(A)
localKeys = profile.get('local keys', [])
if not localKeys:
localKeys = [make_lock_securely(warn_only = A.ignore_entropy)]
else:
localKeys =... | [
"def",
"main_encrypt",
"(",
"A",
")",
":",
"profile",
"=",
"get_profile",
"(",
"A",
")",
"localKeys",
"=",
"profile",
".",
"get",
"(",
"'local keys'",
",",
"[",
"]",
")",
"if",
"not",
"localKeys",
":",
"localKeys",
"=",
"[",
"make_lock_securely",
"(",
... | Encrypt to recipient list using primary key OR prompted key. Recipients may be IDs or petnames. | [
"Encrypt",
"to",
"recipient",
"list",
"using",
"primary",
"key",
"OR",
"prompted",
"key",
".",
"Recipients",
"may",
"be",
"IDs",
"or",
"petnames",
"."
] | python | train |
yinkaisheng/Python-UIAutomation-for-Windows | uiautomation/uiautomation.py | https://github.com/yinkaisheng/Python-UIAutomation-for-Windows/blob/2cc91060982cc8b777152e698d677cc2989bf263/uiautomation/uiautomation.py#L6416-L6464 | def Select(self, itemName: str = '', condition: Callable = None, waitTime: float = OPERATION_WAIT_TIME) -> bool:
"""
Show combobox's popup menu and select a item by name.
itemName: str.
condition: Callable function(comboBoxItemName: str)->bool, if condition is valid, ignore itemName.
... | [
"def",
"Select",
"(",
"self",
",",
"itemName",
":",
"str",
"=",
"''",
",",
"condition",
":",
"Callable",
"=",
"None",
",",
"waitTime",
":",
"float",
"=",
"OPERATION_WAIT_TIME",
")",
"->",
"bool",
":",
"expandCollapsePattern",
"=",
"self",
".",
"GetExpandCo... | Show combobox's popup menu and select a item by name.
itemName: str.
condition: Callable function(comboBoxItemName: str)->bool, if condition is valid, ignore itemName.
waitTime: float.
Some comboboxs doesn't support SelectionPattern, here is a workaround.
This method tries to and... | [
"Show",
"combobox",
"s",
"popup",
"menu",
"and",
"select",
"a",
"item",
"by",
"name",
".",
"itemName",
":",
"str",
".",
"condition",
":",
"Callable",
"function",
"(",
"comboBoxItemName",
":",
"str",
")",
"-",
">",
"bool",
"if",
"condition",
"is",
"valid"... | python | valid |
openstack/horizon | horizon/tables/actions.py | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tables/actions.py#L388-L413 | def get_link_url(self, datum=None):
"""Returns the final URL based on the value of ``url``.
If ``url`` is callable it will call the function.
If not, it will then try to call ``reverse`` on ``url``.
Failing that, it will simply return the value of ``url`` as-is.
When called for... | [
"def",
"get_link_url",
"(",
"self",
",",
"datum",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"url",
":",
"raise",
"NotImplementedError",
"(",
"'A LinkAction class must have a '",
"'url attribute or define its own '",
"'get_link_url method.'",
")",
"if",
"callabl... | Returns the final URL based on the value of ``url``.
If ``url`` is callable it will call the function.
If not, it will then try to call ``reverse`` on ``url``.
Failing that, it will simply return the value of ``url`` as-is.
When called for a row action, the current row data object will... | [
"Returns",
"the",
"final",
"URL",
"based",
"on",
"the",
"value",
"of",
"url",
"."
] | python | train |
stephenmcd/gunicorn-console | gunicorn_console.py | https://github.com/stephenmcd/gunicorn-console/blob/f5c9b9a69ea1f2ca00aac3565cb99491684d868a/gunicorn_console.py#L265-L295 | def main():
"""
Main entry point for gunicorn_console.
"""
# Set up curses.
stdscr = curses.initscr()
curses.start_color()
curses.init_pair(1, foreground_colour, background_colour)
curses.noecho()
stdscr.keypad(True)
stdscr.nodelay(True)
try:
curses.curs_set(False)
... | [
"def",
"main",
"(",
")",
":",
"# Set up curses.",
"stdscr",
"=",
"curses",
".",
"initscr",
"(",
")",
"curses",
".",
"start_color",
"(",
")",
"curses",
".",
"init_pair",
"(",
"1",
",",
"foreground_colour",
",",
"background_colour",
")",
"curses",
".",
"noec... | Main entry point for gunicorn_console. | [
"Main",
"entry",
"point",
"for",
"gunicorn_console",
"."
] | python | train |
DataBiosphere/toil | src/toil/cwl/cwltoil.py | https://github.com/DataBiosphere/toil/blob/a8252277ff814e7bee0971139c2344f88e44b644/src/toil/cwl/cwltoil.py#L1031-L1037 | def cleanTempDirs(job):
"""Remove temporarly created directories."""
if job is CWLJob and job._succeeded: # Only CWLJobs have this attribute.
for tempDir in job.openTempDirs:
if os.path.exists(tempDir):
shutil.rmtree(tempDir)
job.openTempDirs = [] | [
"def",
"cleanTempDirs",
"(",
"job",
")",
":",
"if",
"job",
"is",
"CWLJob",
"and",
"job",
".",
"_succeeded",
":",
"# Only CWLJobs have this attribute.",
"for",
"tempDir",
"in",
"job",
".",
"openTempDirs",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"t... | Remove temporarly created directories. | [
"Remove",
"temporarly",
"created",
"directories",
"."
] | python | train |
halcy/Mastodon.py | mastodon/Mastodon.py | https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L635-L642 | def timeline_local(self, max_id=None, min_id=None, since_id=None, limit=None):
"""
Fetches the local / instance-wide timeline, not including replies.
Returns a list of `toot dicts`_.
"""
return self.timeline('local', max_id=max_id, min_id=min_id,
sin... | [
"def",
"timeline_local",
"(",
"self",
",",
"max_id",
"=",
"None",
",",
"min_id",
"=",
"None",
",",
"since_id",
"=",
"None",
",",
"limit",
"=",
"None",
")",
":",
"return",
"self",
".",
"timeline",
"(",
"'local'",
",",
"max_id",
"=",
"max_id",
",",
"mi... | Fetches the local / instance-wide timeline, not including replies.
Returns a list of `toot dicts`_. | [
"Fetches",
"the",
"local",
"/",
"instance",
"-",
"wide",
"timeline",
"not",
"including",
"replies",
"."
] | python | train |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/common/vcenter/deployment_details_factory.py | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/vcenter/deployment_details_factory.py#L6-L25 | def create_deployment_details(vcenter_resource_model, vm_cluster, vm_storage, vm_resource_pool, vm_location):
"""
:type vcenter_resource_model: VMwarevCenterResourceModel
:type vm_cluster: str
:type vm_storage: str
:type vm_resource_pool: str
:type vm_location: str
... | [
"def",
"create_deployment_details",
"(",
"vcenter_resource_model",
",",
"vm_cluster",
",",
"vm_storage",
",",
"vm_resource_pool",
",",
"vm_location",
")",
":",
"vm_cluster",
"=",
"vm_cluster",
"or",
"vcenter_resource_model",
".",
"vm_cluster",
"vm_storage",
"=",
"vm_sto... | :type vcenter_resource_model: VMwarevCenterResourceModel
:type vm_cluster: str
:type vm_storage: str
:type vm_resource_pool: str
:type vm_location: str
:rtype: DeploymentDetails | [
":",
"type",
"vcenter_resource_model",
":",
"VMwarevCenterResourceModel",
":",
"type",
"vm_cluster",
":",
"str",
":",
"type",
"vm_storage",
":",
"str",
":",
"type",
"vm_resource_pool",
":",
"str",
":",
"type",
"vm_location",
":",
"str",
":",
"rtype",
":",
"Dep... | python | train |
tensorflow/tensor2tensor | tensor2tensor/models/research/vqa_self_attention.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/vqa_self_attention.py#L654-L678 | def iterative_encoder_decoder(encoder_input,
encoder_self_attention_bias,
encoder_decoder_attention_bias,
query,
hparams):
"""Iterative encoder decoder."""
for _ in range(hparams.num_rec_steps):
... | [
"def",
"iterative_encoder_decoder",
"(",
"encoder_input",
",",
"encoder_self_attention_bias",
",",
"encoder_decoder_attention_bias",
",",
"query",
",",
"hparams",
")",
":",
"for",
"_",
"in",
"range",
"(",
"hparams",
".",
"num_rec_steps",
")",
":",
"with",
"tf",
".... | Iterative encoder decoder. | [
"Iterative",
"encoder",
"decoder",
"."
] | python | train |
buzzfeed/caliendo | caliendo/expected_value.py | https://github.com/buzzfeed/caliendo/blob/1628a10f7782ad67c0422b5cbc9bf4979ac40abc/caliendo/expected_value.py#L131-L142 | def save( self ):
"""
Save method for the ExpectedValue of a call.
"""
packets = self.__enumerate_packets()
delete_expected_value(self.call_hash)
for packet in packets:
packet['call_hash'] = self.call_hash
insert_expected_value(packet)
re... | [
"def",
"save",
"(",
"self",
")",
":",
"packets",
"=",
"self",
".",
"__enumerate_packets",
"(",
")",
"delete_expected_value",
"(",
"self",
".",
"call_hash",
")",
"for",
"packet",
"in",
"packets",
":",
"packet",
"[",
"'call_hash'",
"]",
"=",
"self",
".",
"... | Save method for the ExpectedValue of a call. | [
"Save",
"method",
"for",
"the",
"ExpectedValue",
"of",
"a",
"call",
"."
] | python | train |
matthewdeanmartin/jiggle_version | sample_projects/ver_in_weird_file/setup_helpers.py | https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/sample_projects/ver_in_weird_file/setup_helpers.py#L125-L134 | def long_description(*filenames):
"""Provide a long description."""
res = ['']
for filename in filenames:
with open(filename) as fp:
for line in fp:
res.append(' ' + line)
res.append('')
res.append('\n')
return EMPTYSTRING.join(res) | [
"def",
"long_description",
"(",
"*",
"filenames",
")",
":",
"res",
"=",
"[",
"''",
"]",
"for",
"filename",
"in",
"filenames",
":",
"with",
"open",
"(",
"filename",
")",
"as",
"fp",
":",
"for",
"line",
"in",
"fp",
":",
"res",
".",
"append",
"(",
"' ... | Provide a long description. | [
"Provide",
"a",
"long",
"description",
"."
] | python | train |
openid/python-openid | openid/consumer/consumer.py | https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/consumer/consumer.py#L989-L1035 | def _verifyDiscoverySingle(self, endpoint, to_match):
"""Verify that the given endpoint matches the information
extracted from the OpenID assertion, and raise an exception if
there is a mismatch.
@type endpoint: openid.consumer.discover.OpenIDServiceEndpoint
@type to_match: open... | [
"def",
"_verifyDiscoverySingle",
"(",
"self",
",",
"endpoint",
",",
"to_match",
")",
":",
"# Every type URI that's in the to_match endpoint has to be",
"# present in the discovered endpoint.",
"for",
"type_uri",
"in",
"to_match",
".",
"type_uris",
":",
"if",
"not",
"endpoin... | Verify that the given endpoint matches the information
extracted from the OpenID assertion, and raise an exception if
there is a mismatch.
@type endpoint: openid.consumer.discover.OpenIDServiceEndpoint
@type to_match: openid.consumer.discover.OpenIDServiceEndpoint
@rtype: NoneT... | [
"Verify",
"that",
"the",
"given",
"endpoint",
"matches",
"the",
"information",
"extracted",
"from",
"the",
"OpenID",
"assertion",
"and",
"raise",
"an",
"exception",
"if",
"there",
"is",
"a",
"mismatch",
"."
] | python | train |
google/grr | grr/core/grr_response_core/lib/util/random.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/util/random.py#L29-L38 | def UInt32():
"""Returns a pseudo-random 32-bit unsigned integer."""
with _mutex:
try:
return _random_buffer.pop()
except IndexError:
data = os.urandom(struct.calcsize("=L") * _random_buffer_size)
_random_buffer.extend(
struct.unpack("=" + "L" * _random_buffer_size, data))
... | [
"def",
"UInt32",
"(",
")",
":",
"with",
"_mutex",
":",
"try",
":",
"return",
"_random_buffer",
".",
"pop",
"(",
")",
"except",
"IndexError",
":",
"data",
"=",
"os",
".",
"urandom",
"(",
"struct",
".",
"calcsize",
"(",
"\"=L\"",
")",
"*",
"_random_buffe... | Returns a pseudo-random 32-bit unsigned integer. | [
"Returns",
"a",
"pseudo",
"-",
"random",
"32",
"-",
"bit",
"unsigned",
"integer",
"."
] | python | train |
lpantano/seqcluster | seqcluster/seqbuster/snps.py | https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/seqbuster/snps.py#L80-L92 | def print_vcf(data):
"""Print vcf line following rules."""
id_name = "."
qual = "."
chrom = data['chrom']
pos = data['pre_pos']
nt_ref = data['nt'][1]
nt_snp = data['nt'][0]
flt = "PASS"
info = "ID=%s" % data['mature']
frmt = "GT:NR:NS"
gntp = "%s:%s:%s" % (_genotype(data), d... | [
"def",
"print_vcf",
"(",
"data",
")",
":",
"id_name",
"=",
"\".\"",
"qual",
"=",
"\".\"",
"chrom",
"=",
"data",
"[",
"'chrom'",
"]",
"pos",
"=",
"data",
"[",
"'pre_pos'",
"]",
"nt_ref",
"=",
"data",
"[",
"'nt'",
"]",
"[",
"1",
"]",
"nt_snp",
"=",
... | Print vcf line following rules. | [
"Print",
"vcf",
"line",
"following",
"rules",
"."
] | python | train |
imbolc/aiohttp-login | aiohttp_login/sql.py | https://github.com/imbolc/aiohttp-login/blob/43b30d8630ca5c14d4b75c398eb5f6a27ddf0a52/aiohttp_login/sql.py#L60-L71 | def update_sql(table, filter, updates):
'''
>>> update_sql('tbl', {'foo': 'a', 'bar': 1}, {'bar': 2, 'baz': 'b'})
('UPDATE tbl SET bar=$1, baz=$2 WHERE bar=$3 AND foo=$4', [2, 'b', 1, 'a'])
'''
where_keys, where_vals = _split_dict(filter)
up_keys, up_vals = _split_dict(updates)
changes = _pa... | [
"def",
"update_sql",
"(",
"table",
",",
"filter",
",",
"updates",
")",
":",
"where_keys",
",",
"where_vals",
"=",
"_split_dict",
"(",
"filter",
")",
"up_keys",
",",
"up_vals",
"=",
"_split_dict",
"(",
"updates",
")",
"changes",
"=",
"_pairs",
"(",
"up_keys... | >>> update_sql('tbl', {'foo': 'a', 'bar': 1}, {'bar': 2, 'baz': 'b'})
('UPDATE tbl SET bar=$1, baz=$2 WHERE bar=$3 AND foo=$4', [2, 'b', 1, 'a']) | [
">>>",
"update_sql",
"(",
"tbl",
"{",
"foo",
":",
"a",
"bar",
":",
"1",
"}",
"{",
"bar",
":",
"2",
"baz",
":",
"b",
"}",
")",
"(",
"UPDATE",
"tbl",
"SET",
"bar",
"=",
"$1",
"baz",
"=",
"$2",
"WHERE",
"bar",
"=",
"$3",
"AND",
"foo",
"=",
"$4... | python | train |
yyuu/botornado | boto/ec2/keypair.py | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/ec2/keypair.py#L60-L89 | def save(self, directory_path):
"""
Save the material (the unencrypted PEM encoded RSA private key)
of a newly created KeyPair to a local file.
:type directory_path: string
:param directory_path: The fully qualified path to the directory
in... | [
"def",
"save",
"(",
"self",
",",
"directory_path",
")",
":",
"if",
"self",
".",
"material",
":",
"directory_path",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"directory_path",
")",
"file_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"directory_pa... | Save the material (the unencrypted PEM encoded RSA private key)
of a newly created KeyPair to a local file.
:type directory_path: string
:param directory_path: The fully qualified path to the directory
in which the keypair will be saved. The
... | [
"Save",
"the",
"material",
"(",
"the",
"unencrypted",
"PEM",
"encoded",
"RSA",
"private",
"key",
")",
"of",
"a",
"newly",
"created",
"KeyPair",
"to",
"a",
"local",
"file",
".",
":",
"type",
"directory_path",
":",
"string",
":",
"param",
"directory_path",
"... | python | train |
rueckstiess/mtools | mtools/util/logevent.py | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/logevent.py#L844-L940 | def _parse_document(self):
"""Parse system.profile doc, copy all values to member variables."""
self._reset()
doc = self._profile_doc
self._split_tokens_calculated = True
self._split_tokens = None
self._duration_calculated = True
self._duration = doc[u'millis']... | [
"def",
"_parse_document",
"(",
"self",
")",
":",
"self",
".",
"_reset",
"(",
")",
"doc",
"=",
"self",
".",
"_profile_doc",
"self",
".",
"_split_tokens_calculated",
"=",
"True",
"self",
".",
"_split_tokens",
"=",
"None",
"self",
".",
"_duration_calculated",
"... | Parse system.profile doc, copy all values to member variables. | [
"Parse",
"system",
".",
"profile",
"doc",
"copy",
"all",
"values",
"to",
"member",
"variables",
"."
] | python | train |
rocky/python3-trepan | trepan/lib/sighandler.py | https://github.com/rocky/python3-trepan/blob/14e91bc0acce090d67be145b1ac040cab92ac5f3/trepan/lib/sighandler.py#L428-L435 | def handle_print(self, signame, set_print):
"""Set whether we print or not when this signal is caught."""
if set_print:
self.sigs[signame].print_method = self.dbgr.intf[-1].msg
else:
self.sigs[signame].print_method = None
pass
return set_print | [
"def",
"handle_print",
"(",
"self",
",",
"signame",
",",
"set_print",
")",
":",
"if",
"set_print",
":",
"self",
".",
"sigs",
"[",
"signame",
"]",
".",
"print_method",
"=",
"self",
".",
"dbgr",
".",
"intf",
"[",
"-",
"1",
"]",
".",
"msg",
"else",
":... | Set whether we print or not when this signal is caught. | [
"Set",
"whether",
"we",
"print",
"or",
"not",
"when",
"this",
"signal",
"is",
"caught",
"."
] | python | test |
gem/oq-engine | openquake/hazardlib/gsim/megawati_2003.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/megawati_2003.py#L94-L98 | def _get_distance_scaling(self, coe, rhypo):
"""
Returns the distance scaling term
"""
return coe["a3"] * np.log(rhypo) + coe["a4"] * rhypo | [
"def",
"_get_distance_scaling",
"(",
"self",
",",
"coe",
",",
"rhypo",
")",
":",
"return",
"coe",
"[",
"\"a3\"",
"]",
"*",
"np",
".",
"log",
"(",
"rhypo",
")",
"+",
"coe",
"[",
"\"a4\"",
"]",
"*",
"rhypo"
] | Returns the distance scaling term | [
"Returns",
"the",
"distance",
"scaling",
"term"
] | python | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/build/virtual_target.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/build/virtual_target.py#L437-L444 | def root (self, set = None):
""" Sets/gets the 'root' flag. Target is root is it directly correspods to some
variant of a main target.
"""
assert isinstance(set, (int, bool, type(None)))
if set:
self.root_ = True
return self.root_ | [
"def",
"root",
"(",
"self",
",",
"set",
"=",
"None",
")",
":",
"assert",
"isinstance",
"(",
"set",
",",
"(",
"int",
",",
"bool",
",",
"type",
"(",
"None",
")",
")",
")",
"if",
"set",
":",
"self",
".",
"root_",
"=",
"True",
"return",
"self",
"."... | Sets/gets the 'root' flag. Target is root is it directly correspods to some
variant of a main target. | [
"Sets",
"/",
"gets",
"the",
"root",
"flag",
".",
"Target",
"is",
"root",
"is",
"it",
"directly",
"correspods",
"to",
"some",
"variant",
"of",
"a",
"main",
"target",
"."
] | python | train |
ibm-watson-iot/iot-python | tmp/src/things/things.py | https://github.com/ibm-watson-iot/iot-python/blob/195f05adce3fba4ec997017e41e02ebd85c0c4cc/tmp/src/things/things.py#L751-L768 | def createEvent(self, physicalInterfaceId, eventTypeId, eventId):
"""
Create an event mapping for a physical interface.
Parameters:
physicalInterfaceId (string) - value returned by the platform when creating the physical interface
eventTypeId (string) - value returned by the ... | [
"def",
"createEvent",
"(",
"self",
",",
"physicalInterfaceId",
",",
"eventTypeId",
",",
"eventId",
")",
":",
"req",
"=",
"ApiClient",
".",
"allEventsUrl",
"%",
"(",
"self",
".",
"host",
",",
"\"/draft\"",
",",
"physicalInterfaceId",
")",
"body",
"=",
"{",
... | Create an event mapping for a physical interface.
Parameters:
physicalInterfaceId (string) - value returned by the platform when creating the physical interface
eventTypeId (string) - value returned by the platform when creating the event type
eventId (string) - matches the event i... | [
"Create",
"an",
"event",
"mapping",
"for",
"a",
"physical",
"interface",
".",
"Parameters",
":",
"physicalInterfaceId",
"(",
"string",
")",
"-",
"value",
"returned",
"by",
"the",
"platform",
"when",
"creating",
"the",
"physical",
"interface",
"eventTypeId",
"(",... | python | test |
ClimateImpactLab/DataFS | datafs/datafs.py | https://github.com/ClimateImpactLab/DataFS/blob/0d32c2b4e18d300a11b748a552f6adbc3dd8f59d/datafs/datafs.py#L130-L167 | def configure(ctx, helper, edit):
'''
Update configuration
'''
ctx.obj.config = ConfigFile(ctx.obj.config_file)
if edit:
ctx.obj.config.edit_config_file()
return
if os.path.isfile(ctx.obj.config.config_file):
ctx.obj.config.read_config()
if ctx.obj.profile is None... | [
"def",
"configure",
"(",
"ctx",
",",
"helper",
",",
"edit",
")",
":",
"ctx",
".",
"obj",
".",
"config",
"=",
"ConfigFile",
"(",
"ctx",
".",
"obj",
".",
"config_file",
")",
"if",
"edit",
":",
"ctx",
".",
"obj",
".",
"config",
".",
"edit_config_file",
... | Update configuration | [
"Update",
"configuration"
] | python | train |
saltstack/salt | salt/states/file.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L1131-L1189 | def _get_template_texts(source_list=None,
template='jinja',
defaults=None,
context=None,
**kwargs):
'''
Iterate a list of sources and process them as templates.
Returns a list of 'chunks' containing the rendered ... | [
"def",
"_get_template_texts",
"(",
"source_list",
"=",
"None",
",",
"template",
"=",
"'jinja'",
",",
"defaults",
"=",
"None",
",",
"context",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"'_get_template_texts'",
",",
"'... | Iterate a list of sources and process them as templates.
Returns a list of 'chunks' containing the rendered templates. | [
"Iterate",
"a",
"list",
"of",
"sources",
"and",
"process",
"them",
"as",
"templates",
".",
"Returns",
"a",
"list",
"of",
"chunks",
"containing",
"the",
"rendered",
"templates",
"."
] | python | train |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/hooks/hookutils.py | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/hooks/hookutils.py#L115-L124 | def qt4_plugins_binaries(plugin_type):
"""Return list of dynamic libraries formated for mod.binaries."""
binaries = []
pdir = qt4_plugins_dir()
files = misc.dlls_in_dir(os.path.join(pdir, plugin_type))
for f in files:
binaries.append((
os.path.join('qt4_plugins', plugin_type, os.... | [
"def",
"qt4_plugins_binaries",
"(",
"plugin_type",
")",
":",
"binaries",
"=",
"[",
"]",
"pdir",
"=",
"qt4_plugins_dir",
"(",
")",
"files",
"=",
"misc",
".",
"dlls_in_dir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"pdir",
",",
"plugin_type",
")",
")",
... | Return list of dynamic libraries formated for mod.binaries. | [
"Return",
"list",
"of",
"dynamic",
"libraries",
"formated",
"for",
"mod",
".",
"binaries",
"."
] | python | train |
datadotworld/data.world-py | datadotworld/client/api.py | https://github.com/datadotworld/data.world-py/blob/ffaeb115f358731ab0b805b0c43b7ff2e3cf0a77/datadotworld/client/api.py#L282-L321 | def add_files_via_url(self, dataset_key, files={}):
"""Add or update dataset files linked to source URLs
:param dataset_key: Dataset identifier, in the form of owner/id
:type dataset_key: str
:param files: Dict containing the name of files and metadata
Uses file name as a di... | [
"def",
"add_files_via_url",
"(",
"self",
",",
"dataset_key",
",",
"files",
"=",
"{",
"}",
")",
":",
"file_requests",
"=",
"[",
"_swagger",
".",
"FileCreateOrUpdateRequest",
"(",
"name",
"=",
"file_name",
",",
"source",
"=",
"_swagger",
".",
"FileSourceCreateOr... | Add or update dataset files linked to source URLs
:param dataset_key: Dataset identifier, in the form of owner/id
:type dataset_key: str
:param files: Dict containing the name of files and metadata
Uses file name as a dict containing File description, labels and
source U... | [
"Add",
"or",
"update",
"dataset",
"files",
"linked",
"to",
"source",
"URLs"
] | python | train |
quantopian/pgcontents | pgcontents/pgmanager.py | https://github.com/quantopian/pgcontents/blob/ed36268b7917332d16868208e1e565742a8753e1/pgcontents/pgmanager.py#L264-L280 | def _file_model_from_db(self, record, content, format):
"""
Build a file model from database record.
"""
# TODO: Most of this is shared with _notebook_model_from_db.
path = to_api_path(record['parent_name'] + record['name'])
model = base_model(path)
model['type'] ... | [
"def",
"_file_model_from_db",
"(",
"self",
",",
"record",
",",
"content",
",",
"format",
")",
":",
"# TODO: Most of this is shared with _notebook_model_from_db.",
"path",
"=",
"to_api_path",
"(",
"record",
"[",
"'parent_name'",
"]",
"+",
"record",
"[",
"'name'",
"]"... | Build a file model from database record. | [
"Build",
"a",
"file",
"model",
"from",
"database",
"record",
"."
] | python | test |
square/pylink | pylink/threads.py | https://github.com/square/pylink/blob/81dda0a191d923a8b2627c52cb778aba24d279d7/pylink/threads.py#L41-L56 | def run(self):
"""Runs the thread.
Args:
self (ThreadReturn): the ``ThreadReturn`` instance
Returns:
``None``
"""
target = getattr(self, '_Thread__target', getattr(self, '_target', None))
args = getattr(self, '_Thread__args', getattr(self, '_args', N... | [
"def",
"run",
"(",
"self",
")",
":",
"target",
"=",
"getattr",
"(",
"self",
",",
"'_Thread__target'",
",",
"getattr",
"(",
"self",
",",
"'_target'",
",",
"None",
")",
")",
"args",
"=",
"getattr",
"(",
"self",
",",
"'_Thread__args'",
",",
"getattr",
"("... | Runs the thread.
Args:
self (ThreadReturn): the ``ThreadReturn`` instance
Returns:
``None`` | [
"Runs",
"the",
"thread",
"."
] | python | train |
pymacaron/pymacaron | pymacaron/utils.py | https://github.com/pymacaron/pymacaron/blob/af244f203f8216108b39d374d46bf8e1813f13d5/pymacaron/utils.py#L17-L41 | def is_ec2_instance():
"""Try fetching instance metadata at 'curl http://169.254.169.254/latest/meta-data/'
to see if host is on an ec2 instance"""
# Note: this code assumes that docker containers running on ec2 instances
# inherit instances metadata, which they do as of 2016-08-25
global IS_EC2_I... | [
"def",
"is_ec2_instance",
"(",
")",
":",
"# Note: this code assumes that docker containers running on ec2 instances",
"# inherit instances metadata, which they do as of 2016-08-25",
"global",
"IS_EC2_INSTANCE",
"if",
"IS_EC2_INSTANCE",
"!=",
"-",
"1",
":",
"# Returned the cached value"... | Try fetching instance metadata at 'curl http://169.254.169.254/latest/meta-data/'
to see if host is on an ec2 instance | [
"Try",
"fetching",
"instance",
"metadata",
"at",
"curl",
"http",
":",
"//",
"169",
".",
"254",
".",
"169",
".",
"254",
"/",
"latest",
"/",
"meta",
"-",
"data",
"/",
"to",
"see",
"if",
"host",
"is",
"on",
"an",
"ec2",
"instance"
] | python | train |
maxzheng/bumper-lib | bumper/cars.py | https://github.com/maxzheng/bumper-lib/blob/32a9dec5448673825bb2d7d92fa68882b597f794/bumper/cars.py#L252-L257 | def as_requirement(self):
""" Convert back to a :class:`pkg_resources.Requirement` instance """
if self.new_version:
return pkg_resources.Requirement.parse(self.name + ''.join(self.new_version))
else:
return pkg_resources.Requirement.parse(self.name) | [
"def",
"as_requirement",
"(",
"self",
")",
":",
"if",
"self",
".",
"new_version",
":",
"return",
"pkg_resources",
".",
"Requirement",
".",
"parse",
"(",
"self",
".",
"name",
"+",
"''",
".",
"join",
"(",
"self",
".",
"new_version",
")",
")",
"else",
":"... | Convert back to a :class:`pkg_resources.Requirement` instance | [
"Convert",
"back",
"to",
"a",
":",
"class",
":",
"pkg_resources",
".",
"Requirement",
"instance"
] | python | valid |
jobovy/galpy | galpy/potential/KuzminKutuzovStaeckelPotential.py | https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/potential/KuzminKutuzovStaeckelPotential.py#L258-L274 | def _l2deriv(self,l,n):
"""
NAME:
_l2deriv
PURPOSE:
evaluate the second derivative w.r.t. lambda for this potential
INPUT:
l - prolate spheroidal coordinate lambda
n - prolate spheroidal coordinate nu
OUTPUT:
second deri... | [
"def",
"_l2deriv",
"(",
"self",
",",
"l",
",",
"n",
")",
":",
"numer",
"=",
"-",
"3.",
"*",
"nu",
".",
"sqrt",
"(",
"l",
")",
"-",
"nu",
".",
"sqrt",
"(",
"n",
")",
"denom",
"=",
"4.",
"*",
"l",
"**",
"1.5",
"*",
"(",
"nu",
".",
"sqrt",
... | NAME:
_l2deriv
PURPOSE:
evaluate the second derivative w.r.t. lambda for this potential
INPUT:
l - prolate spheroidal coordinate lambda
n - prolate spheroidal coordinate nu
OUTPUT:
second derivative w.r.t. lambda
HISTORY:
... | [
"NAME",
":",
"_l2deriv",
"PURPOSE",
":",
"evaluate",
"the",
"second",
"derivative",
"w",
".",
"r",
".",
"t",
".",
"lambda",
"for",
"this",
"potential",
"INPUT",
":",
"l",
"-",
"prolate",
"spheroidal",
"coordinate",
"lambda",
"n",
"-",
"prolate",
"spheroida... | python | train |
datacratic/pymldb | pymldb/__init__.py | https://github.com/datacratic/pymldb/blob/e41f3c37138e9fd4a82ef3db685899cdafa4125e/pymldb/__init__.py#L131-L165 | def post_and_track(self, url, payload, refresh_rate_sec=1):
"""
Post and track progress, displaying progress bars.
May display the wrong progress if 2 things post/put on the same
procedure name at the same time.
"""
if not url.startswith('/v1/procedures'):
ra... | [
"def",
"post_and_track",
"(",
"self",
",",
"url",
",",
"payload",
",",
"refresh_rate_sec",
"=",
"1",
")",
":",
"if",
"not",
"url",
".",
"startswith",
"(",
"'/v1/procedures'",
")",
":",
"raise",
"Exception",
"(",
"\"The only supported route is /v1/procedures\"",
... | Post and track progress, displaying progress bars.
May display the wrong progress if 2 things post/put on the same
procedure name at the same time. | [
"Post",
"and",
"track",
"progress",
"displaying",
"progress",
"bars",
"."
] | python | train |
rochacbruno/dynaconf | dynaconf/loaders/toml_loader.py | https://github.com/rochacbruno/dynaconf/blob/5a7cc8f8252251cbdf4f4112965801f9dfe2831d/dynaconf/loaders/toml_loader.py#L15-L38 | def load(obj, env=None, silent=True, key=None, filename=None):
"""
Reads and loads in to "obj" a single key or all keys from source file.
:param obj: the settings instance
:param env: settings current env default='development'
:param silent: if errors should raise
:param key: if defined load a ... | [
"def",
"load",
"(",
"obj",
",",
"env",
"=",
"None",
",",
"silent",
"=",
"True",
",",
"key",
"=",
"None",
",",
"filename",
"=",
"None",
")",
":",
"if",
"toml",
"is",
"None",
":",
"# pragma: no cover",
"BaseLoader",
".",
"warn_not_installed",
"(",
"obj",... | Reads and loads in to "obj" a single key or all keys from source file.
:param obj: the settings instance
:param env: settings current env default='development'
:param silent: if errors should raise
:param key: if defined load a single key, else load all in env
:param filename: Optional custom filen... | [
"Reads",
"and",
"loads",
"in",
"to",
"obj",
"a",
"single",
"key",
"or",
"all",
"keys",
"from",
"source",
"file",
"."
] | python | train |
maxzheng/bumper-lib | bumper/utils.py | https://github.com/maxzheng/bumper-lib/blob/32a9dec5448673825bb2d7d92fa68882b597f794/bumper/utils.py#L60-L63 | def all_package_versions(package):
""" All versions for package """
info = PyPI.package_info(package)
return info and sorted(info['releases'].keys(), key=lambda x: x.split(), reverse=True) or [] | [
"def",
"all_package_versions",
"(",
"package",
")",
":",
"info",
"=",
"PyPI",
".",
"package_info",
"(",
"package",
")",
"return",
"info",
"and",
"sorted",
"(",
"info",
"[",
"'releases'",
"]",
".",
"keys",
"(",
")",
",",
"key",
"=",
"lambda",
"x",
":",
... | All versions for package | [
"All",
"versions",
"for",
"package"
] | python | valid |
openstack/networking-cisco | networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py | https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L890-L901 | def _create_service_nwk(self, tenant_id, tenant_name, direc):
"""Function to create the service in network in DCNM. """
net_dict = self.retrieve_dcnm_net_info(tenant_id, direc)
net = utils.Dict2Obj(net_dict)
subnet_dict = self.retrieve_dcnm_subnet_info(tenant_id, direc)
subnet = ... | [
"def",
"_create_service_nwk",
"(",
"self",
",",
"tenant_id",
",",
"tenant_name",
",",
"direc",
")",
":",
"net_dict",
"=",
"self",
".",
"retrieve_dcnm_net_info",
"(",
"tenant_id",
",",
"direc",
")",
"net",
"=",
"utils",
".",
"Dict2Obj",
"(",
"net_dict",
")",
... | Function to create the service in network in DCNM. | [
"Function",
"to",
"create",
"the",
"service",
"in",
"network",
"in",
"DCNM",
"."
] | python | train |
vmlaker/mpipe | src/UnorderedWorker.py | https://github.com/vmlaker/mpipe/blob/5a1804cf64271931f0cd3e4fff3e2b38291212dd/src/UnorderedWorker.py#L17-L34 | def init2(
self,
input_tube, # Read task from the input tube.
output_tubes, # Send result on all the output tubes.
num_workers, # Total number of workers in the stage.
disable_result, # Whether to override any result with None.
do_stop_task, # Whether to ... | [
"def",
"init2",
"(",
"self",
",",
"input_tube",
",",
"# Read task from the input tube.",
"output_tubes",
",",
"# Send result on all the output tubes.",
"num_workers",
",",
"# Total number of workers in the stage.",
"disable_result",
",",
"# Whether to override any result with None.",... | Create *num_workers* worker objects with *input_tube* and
an iterable of *output_tubes*. The worker reads a task from *input_tube*
and writes the result to *output_tubes*. | [
"Create",
"*",
"num_workers",
"*",
"worker",
"objects",
"with",
"*",
"input_tube",
"*",
"and",
"an",
"iterable",
"of",
"*",
"output_tubes",
"*",
".",
"The",
"worker",
"reads",
"a",
"task",
"from",
"*",
"input_tube",
"*",
"and",
"writes",
"the",
"result",
... | python | train |
chrislit/abydos | abydos/phonetic/_beider_morse.py | https://github.com/chrislit/abydos/blob/165466b3ff6afd8024a4c8660421b0c4e7773db9/abydos/phonetic/_beider_morse.py#L590-L611 | def _phonetic_numbers(self, phonetic):
"""Prepare & join phonetic numbers.
Split phonetic value on '-', run through _pnums_with_leading_space,
and join with ' '
Parameters
----------
phonetic : str
A Beider-Morse phonetic encoding
Returns
--... | [
"def",
"_phonetic_numbers",
"(",
"self",
",",
"phonetic",
")",
":",
"phonetic_array",
"=",
"phonetic",
".",
"split",
"(",
"'-'",
")",
"# for names with spaces in them",
"result",
"=",
"' '",
".",
"join",
"(",
"[",
"self",
".",
"_pnums_with_leading_space",
"(",
... | Prepare & join phonetic numbers.
Split phonetic value on '-', run through _pnums_with_leading_space,
and join with ' '
Parameters
----------
phonetic : str
A Beider-Morse phonetic encoding
Returns
-------
str
A Beider-Morse phone... | [
"Prepare",
"&",
"join",
"phonetic",
"numbers",
"."
] | python | valid |
pyviz/holoviews | holoviews/plotting/plotly/plot.py | https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/plotting/plotly/plot.py#L33-L39 | def _trigger_refresh(self, key):
"Triggers update to a plot on a refresh event"
if self.top_level:
self.update(key)
else:
self.current_key = None
self.current_frame = None | [
"def",
"_trigger_refresh",
"(",
"self",
",",
"key",
")",
":",
"if",
"self",
".",
"top_level",
":",
"self",
".",
"update",
"(",
"key",
")",
"else",
":",
"self",
".",
"current_key",
"=",
"None",
"self",
".",
"current_frame",
"=",
"None"
] | Triggers update to a plot on a refresh event | [
"Triggers",
"update",
"to",
"a",
"plot",
"on",
"a",
"refresh",
"event"
] | python | train |
great-expectations/great_expectations | great_expectations/data_asset/file_data_asset.py | https://github.com/great-expectations/great_expectations/blob/08385c40529d4f14a1c46916788aecc47f33ee9d/great_expectations/data_asset/file_data_asset.py#L587-L643 | def expect_file_to_be_valid_json(self, schema=None, result_format=None,
include_config=False, catch_exceptions=None,
meta=None):
"""
schema : string
optional JSON schema file on which JSON data file is validated again... | [
"def",
"expect_file_to_be_valid_json",
"(",
"self",
",",
"schema",
"=",
"None",
",",
"result_format",
"=",
"None",
",",
"include_config",
"=",
"False",
",",
"catch_exceptions",
"=",
"None",
",",
"meta",
"=",
"None",
")",
":",
"success",
"=",
"False",
"if",
... | schema : string
optional JSON schema file on which JSON data file is validated against
result_format (str or None):
Which output mode to use: `BOOLEAN_ONLY`, `BASIC`, `COMPLETE`, or `SUMMARY`.
For more detail, see :ref:`result_format <result_format>`.
include_config... | [
"schema",
":",
"string",
"optional",
"JSON",
"schema",
"file",
"on",
"which",
"JSON",
"data",
"file",
"is",
"validated",
"against"
] | python | train |
mokelly/wabbit_wappa | wabbit_wappa/__init__.py | https://github.com/mokelly/wabbit_wappa/blob/dfe5bf6d6036079e473c4148335cd6f339d0299b/wabbit_wappa/__init__.py#L263-L274 | def _get_response(self, parse_result=True):
"""If 'parse_result' is False, ignore the received output and return None."""
# expect_exact is faster than just exact, and fine for our purpose
# (http://pexpect.readthedocs.org/en/latest/api/pexpect.html#pexpect.spawn.expect_exact)
# searchwi... | [
"def",
"_get_response",
"(",
"self",
",",
"parse_result",
"=",
"True",
")",
":",
"# expect_exact is faster than just exact, and fine for our purpose",
"# (http://pexpect.readthedocs.org/en/latest/api/pexpect.html#pexpect.spawn.expect_exact)",
"# searchwindowsize and other attributes may also... | If 'parse_result' is False, ignore the received output and return None. | [
"If",
"parse_result",
"is",
"False",
"ignore",
"the",
"received",
"output",
"and",
"return",
"None",
"."
] | python | train |
LonamiWebs/Telethon | telethon/client/chats.py | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/client/chats.py#L277-L331 | def iter_participants(
self, entity, limit=None, *, search='',
filter=None, aggressive=False
):
"""
Iterator over the participants belonging to the specified chat.
Args:
entity (`entity`):
The entity from which to retrieve the participants... | [
"def",
"iter_participants",
"(",
"self",
",",
"entity",
",",
"limit",
"=",
"None",
",",
"*",
",",
"search",
"=",
"''",
",",
"filter",
"=",
"None",
",",
"aggressive",
"=",
"False",
")",
":",
"return",
"_ParticipantsIter",
"(",
"self",
",",
"limit",
",",... | Iterator over the participants belonging to the specified chat.
Args:
entity (`entity`):
The entity from which to retrieve the participants list.
limit (`int`):
Limits amount of participants fetched.
search (`str`, optional):
... | [
"Iterator",
"over",
"the",
"participants",
"belonging",
"to",
"the",
"specified",
"chat",
"."
] | python | train |
Rackspace-DOT/flask_keystone | flask_keystone/__init__.py | https://github.com/Rackspace-DOT/flask_keystone/blob/6f6d630e9e66a3beca6607b0b786510ec2a79747/flask_keystone/__init__.py#L205-L239 | def _make_user_model(self):
"""
Dynamically generate a User class for use with FlaskKeystone.
:returns: a generated User class, inherited from
:class:`flask_keystone.UserBase`.
:rtype: class
This User model is intended to work somewhat similarly to the User
... | [
"def",
"_make_user_model",
"(",
"self",
")",
":",
"class",
"User",
"(",
"UserBase",
")",
":",
"\"\"\"\n A User as defined by the response from Keystone.\n\n Note: This class is dynamically generated by :class:`FlaskKeystone`\n from the :class:`flask_keystone.... | Dynamically generate a User class for use with FlaskKeystone.
:returns: a generated User class, inherited from
:class:`flask_keystone.UserBase`.
:rtype: class
This User model is intended to work somewhat similarly to the User
class that is created for Flask-Login, how... | [
"Dynamically",
"generate",
"a",
"User",
"class",
"for",
"use",
"with",
"FlaskKeystone",
"."
] | python | train |
rvswift/EB | EB/builder/utilities/ensemble_storage.py | https://github.com/rvswift/EB/blob/341880b79faf8147dc9fa6e90438531cd09fabcc/EB/builder/utilities/ensemble_storage.py#L17-L35 | def set_prop(self, prop, value, ef=None):
"""
set attributes values
:param prop:
:param value:
:param ef:
:return:
"""
if ef:
# prop should be restricted to n_decoys, an int, the no. of decoys corresponding to a given FPF.
# value i... | [
"def",
"set_prop",
"(",
"self",
",",
"prop",
",",
"value",
",",
"ef",
"=",
"None",
")",
":",
"if",
"ef",
":",
"# prop should be restricted to n_decoys, an int, the no. of decoys corresponding to a given FPF.",
"# value is restricted to the corresponding enrichment factor and shou... | set attributes values
:param prop:
:param value:
:param ef:
:return: | [
"set",
"attributes",
"values",
":",
"param",
"prop",
":",
":",
"param",
"value",
":",
":",
"param",
"ef",
":",
":",
"return",
":"
] | python | train |
SwissDataScienceCenter/renku-python | renku/cli/doctor.py | https://github.com/SwissDataScienceCenter/renku-python/blob/691644d695b055a01e0ca22b2620e55bbd928c0d/renku/cli/doctor.py#L36-L49 | def doctor(ctx, client):
"""Check your system and repository for potential problems."""
click.secho('\n'.join(textwrap.wrap(DOCTOR_INFO)) + '\n', bold=True)
from . import _checks
is_ok = True
for attr in _checks.__all__:
is_ok &= getattr(_checks, attr)(client)
if is_ok:
click.... | [
"def",
"doctor",
"(",
"ctx",
",",
"client",
")",
":",
"click",
".",
"secho",
"(",
"'\\n'",
".",
"join",
"(",
"textwrap",
".",
"wrap",
"(",
"DOCTOR_INFO",
")",
")",
"+",
"'\\n'",
",",
"bold",
"=",
"True",
")",
"from",
".",
"import",
"_checks",
"is_o... | Check your system and repository for potential problems. | [
"Check",
"your",
"system",
"and",
"repository",
"for",
"potential",
"problems",
"."
] | python | train |
firstprayer/monsql | monsql/query.py | https://github.com/firstprayer/monsql/blob/6285c15b574c8664046eae2edfeb548c7b173efd/monsql/query.py#L85-L193 | def to_sql(self):
"""
This function build a sql condition string (those used in the 'WHERE' clause) based on given condition
Supported match pattern:
{a: 1} -> a == 1
{a: {$gt: 1}} -> a > 1
{a: {$gte: 1}} ... | [
"def",
"to_sql",
"(",
"self",
")",
":",
"condition",
"=",
"self",
".",
"condition",
"if",
"condition",
":",
"# If the condition is not None nor empty",
"if",
"len",
"(",
"condition",
".",
"keys",
"(",
")",
")",
">",
"1",
":",
"# If in the form of {'a': 1, 'b': 2... | This function build a sql condition string (those used in the 'WHERE' clause) based on given condition
Supported match pattern:
{a: 1} -> a == 1
{a: {$gt: 1}} -> a > 1
{a: {$gte: 1}} -> a >= 1
{a: {$lt: 1}} ... | [
"This",
"function",
"build",
"a",
"sql",
"condition",
"string",
"(",
"those",
"used",
"in",
"the",
"WHERE",
"clause",
")",
"based",
"on",
"given",
"condition",
"Supported",
"match",
"pattern",
":"
] | python | train |
pandas-dev/pandas | pandas/core/algorithms.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/algorithms.py#L966-L1043 | def quantile(x, q, interpolation_method='fraction'):
"""
Compute sample quantile or quantiles of the input array. For example, q=0.5
computes the median.
The `interpolation_method` parameter supports three values, namely
`fraction` (default), `lower` and `higher`. Interpolation is done only,
if... | [
"def",
"quantile",
"(",
"x",
",",
"q",
",",
"interpolation_method",
"=",
"'fraction'",
")",
":",
"x",
"=",
"np",
".",
"asarray",
"(",
"x",
")",
"mask",
"=",
"isna",
"(",
"x",
")",
"x",
"=",
"x",
"[",
"~",
"mask",
"]",
"values",
"=",
"np",
".",
... | Compute sample quantile or quantiles of the input array. For example, q=0.5
computes the median.
The `interpolation_method` parameter supports three values, namely
`fraction` (default), `lower` and `higher`. Interpolation is done only,
if the desired quantile lies between two data points `i` and `j`. F... | [
"Compute",
"sample",
"quantile",
"or",
"quantiles",
"of",
"the",
"input",
"array",
".",
"For",
"example",
"q",
"=",
"0",
".",
"5",
"computes",
"the",
"median",
"."
] | python | train |
UpCloudLtd/upcloud-python-api | upcloud_api/cloud_manager/firewall_mixin.py | https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/cloud_manager/firewall_mixin.py#L42-L55 | def create_firewall_rule(self, server, firewall_rule_body):
"""
Create a new firewall rule for a given server uuid.
The rule can begiven as a dict or with FirewallRule.prepare_post_body().
Returns a FirewallRule object.
"""
server_uuid, server_instance = uuid_and_instanc... | [
"def",
"create_firewall_rule",
"(",
"self",
",",
"server",
",",
"firewall_rule_body",
")",
":",
"server_uuid",
",",
"server_instance",
"=",
"uuid_and_instance",
"(",
"server",
")",
"url",
"=",
"'/server/{0}/firewall_rule'",
".",
"format",
"(",
"server_uuid",
")",
... | Create a new firewall rule for a given server uuid.
The rule can begiven as a dict or with FirewallRule.prepare_post_body().
Returns a FirewallRule object. | [
"Create",
"a",
"new",
"firewall",
"rule",
"for",
"a",
"given",
"server",
"uuid",
"."
] | python | train |
pycontribs/pyrax | pyrax/queueing.py | https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/queueing.py#L504-L516 | def set_metadata(self, queue, metadata, clear=False):
"""
Accepts a dictionary and adds that to the specified queue's metadata.
If the 'clear' argument is passed as True, any existing metadata is
replaced with the new metadata.
"""
uri = "/%s/%s/metadata" % (self.uri_base... | [
"def",
"set_metadata",
"(",
"self",
",",
"queue",
",",
"metadata",
",",
"clear",
"=",
"False",
")",
":",
"uri",
"=",
"\"/%s/%s/metadata\"",
"%",
"(",
"self",
".",
"uri_base",
",",
"utils",
".",
"get_id",
"(",
"queue",
")",
")",
"if",
"clear",
":",
"c... | Accepts a dictionary and adds that to the specified queue's metadata.
If the 'clear' argument is passed as True, any existing metadata is
replaced with the new metadata. | [
"Accepts",
"a",
"dictionary",
"and",
"adds",
"that",
"to",
"the",
"specified",
"queue",
"s",
"metadata",
".",
"If",
"the",
"clear",
"argument",
"is",
"passed",
"as",
"True",
"any",
"existing",
"metadata",
"is",
"replaced",
"with",
"the",
"new",
"metadata",
... | python | train |
fastai/fastai | fastai/layers.py | https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/layers.py#L281-L283 | def MSELossFlat(*args, axis:int=-1, floatify:bool=True, **kwargs):
"Same as `nn.MSELoss`, but flattens input and target."
return FlattenedLoss(nn.MSELoss, *args, axis=axis, floatify=floatify, is_2d=False, **kwargs) | [
"def",
"MSELossFlat",
"(",
"*",
"args",
",",
"axis",
":",
"int",
"=",
"-",
"1",
",",
"floatify",
":",
"bool",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"FlattenedLoss",
"(",
"nn",
".",
"MSELoss",
",",
"*",
"args",
",",
"axis",
"="... | Same as `nn.MSELoss`, but flattens input and target. | [
"Same",
"as",
"nn",
".",
"MSELoss",
"but",
"flattens",
"input",
"and",
"target",
"."
] | python | train |
google/grumpy | third_party/stdlib/_abcoll.py | https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/_abcoll.py#L312-L320 | def pop(self):
"""Return the popped value. Raise KeyError if empty."""
it = iter(self)
try:
value = next(it)
except StopIteration:
raise KeyError
self.discard(value)
return value | [
"def",
"pop",
"(",
"self",
")",
":",
"it",
"=",
"iter",
"(",
"self",
")",
"try",
":",
"value",
"=",
"next",
"(",
"it",
")",
"except",
"StopIteration",
":",
"raise",
"KeyError",
"self",
".",
"discard",
"(",
"value",
")",
"return",
"value"
] | Return the popped value. Raise KeyError if empty. | [
"Return",
"the",
"popped",
"value",
".",
"Raise",
"KeyError",
"if",
"empty",
"."
] | python | valid |
pycontribs/pyrax | pyrax/resource.py | https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/resource.py#L66-L76 | def _add_details(self, info):
"""
Takes the dict returned by the API call and sets the
corresponding attributes on the object.
"""
for (key, val) in six.iteritems(info):
if isinstance(key, six.text_type) and six.PY2:
key = key.encode(pyrax.get_encoding... | [
"def",
"_add_details",
"(",
"self",
",",
"info",
")",
":",
"for",
"(",
"key",
",",
"val",
")",
"in",
"six",
".",
"iteritems",
"(",
"info",
")",
":",
"if",
"isinstance",
"(",
"key",
",",
"six",
".",
"text_type",
")",
"and",
"six",
".",
"PY2",
":",... | Takes the dict returned by the API call and sets the
corresponding attributes on the object. | [
"Takes",
"the",
"dict",
"returned",
"by",
"the",
"API",
"call",
"and",
"sets",
"the",
"corresponding",
"attributes",
"on",
"the",
"object",
"."
] | python | train |
ekzhu/datasketch | datasketch/minhash.py | https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/minhash.py#L137-L154 | def jaccard(self, other):
'''Estimate the `Jaccard similarity`_ (resemblance) between the sets
represented by this MinHash and the other.
Args:
other (datasketch.MinHash): The other MinHash.
Returns:
float: The Jaccard similarity, which is between 0.0 and 1.0.
... | [
"def",
"jaccard",
"(",
"self",
",",
"other",
")",
":",
"if",
"other",
".",
"seed",
"!=",
"self",
".",
"seed",
":",
"raise",
"ValueError",
"(",
"\"Cannot compute Jaccard given MinHash with\\\n different seeds\"",
")",
"if",
"len",
"(",
"self",
")... | Estimate the `Jaccard similarity`_ (resemblance) between the sets
represented by this MinHash and the other.
Args:
other (datasketch.MinHash): The other MinHash.
Returns:
float: The Jaccard similarity, which is between 0.0 and 1.0. | [
"Estimate",
"the",
"Jaccard",
"similarity",
"_",
"(",
"resemblance",
")",
"between",
"the",
"sets",
"represented",
"by",
"this",
"MinHash",
"and",
"the",
"other",
"."
] | python | test |
GoogleCloudPlatform/appengine-mapreduce | python/demo/main.py | https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/demo/main.py#L181-L185 | def split_into_sentences(s):
"""Split text into list of sentences."""
s = re.sub(r"\s+", " ", s)
s = re.sub(r"[\\.\\?\\!]", "\n", s)
return s.split("\n") | [
"def",
"split_into_sentences",
"(",
"s",
")",
":",
"s",
"=",
"re",
".",
"sub",
"(",
"r\"\\s+\"",
",",
"\" \"",
",",
"s",
")",
"s",
"=",
"re",
".",
"sub",
"(",
"r\"[\\\\.\\\\?\\\\!]\"",
",",
"\"\\n\"",
",",
"s",
")",
"return",
"s",
".",
"split",
"("... | Split text into list of sentences. | [
"Split",
"text",
"into",
"list",
"of",
"sentences",
"."
] | python | train |
saltstack/salt | salt/utils/dns.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L546-L654 | def lookup(
name,
rdtype,
method=None,
servers=None,
timeout=None,
walk=False,
walk_tld=False,
secure=None
):
'''
Lookup DNS records and return their data
:param name: name to lookup
:param rdtype: DNS record type
:param method: gai (getaddrinfo()), dnspython, dig, d... | [
"def",
"lookup",
"(",
"name",
",",
"rdtype",
",",
"method",
"=",
"None",
",",
"servers",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"walk",
"=",
"False",
",",
"walk_tld",
"=",
"False",
",",
"secure",
"=",
"None",
")",
":",
"# opts = __opts__.get('d... | Lookup DNS records and return their data
:param name: name to lookup
:param rdtype: DNS record type
:param method: gai (getaddrinfo()), dnspython, dig, drill, host, nslookup or auto (default)
:param servers: (list of) server(s) to try in-order
:param timeout: query timeout or a valiant approximatio... | [
"Lookup",
"DNS",
"records",
"and",
"return",
"their",
"data"
] | python | train |
wandb/client | wandb/vendor/prompt_toolkit/buffer.py | https://github.com/wandb/client/blob/7d08954ed5674fee223cd85ed0d8518fe47266b2/wandb/vendor/prompt_toolkit/buffer.py#L655-L666 | def join_next_line(self, separator=' '):
"""
Join the next line to the current one by deleting the line ending after
the current line.
"""
if not self.document.on_last_line:
self.cursor_position += self.document.get_end_of_line_position()
self.delete()
... | [
"def",
"join_next_line",
"(",
"self",
",",
"separator",
"=",
"' '",
")",
":",
"if",
"not",
"self",
".",
"document",
".",
"on_last_line",
":",
"self",
".",
"cursor_position",
"+=",
"self",
".",
"document",
".",
"get_end_of_line_position",
"(",
")",
"self",
... | Join the next line to the current one by deleting the line ending after
the current line. | [
"Join",
"the",
"next",
"line",
"to",
"the",
"current",
"one",
"by",
"deleting",
"the",
"line",
"ending",
"after",
"the",
"current",
"line",
"."
] | python | train |
klahnakoski/pyLibrary | jx_python/jx.py | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_python/jx.py#L914-L941 | def wrap_function(func):
"""
RETURN A THREE-PARAMETER WINDOW FUNCTION TO MATCH
"""
if is_text(func):
return compile_expression(func)
numarg = func.__code__.co_argcount
if numarg == 0:
def temp(row, rownum, rows):
return func()
return temp
elif numarg ==... | [
"def",
"wrap_function",
"(",
"func",
")",
":",
"if",
"is_text",
"(",
"func",
")",
":",
"return",
"compile_expression",
"(",
"func",
")",
"numarg",
"=",
"func",
".",
"__code__",
".",
"co_argcount",
"if",
"numarg",
"==",
"0",
":",
"def",
"temp",
"(",
"ro... | RETURN A THREE-PARAMETER WINDOW FUNCTION TO MATCH | [
"RETURN",
"A",
"THREE",
"-",
"PARAMETER",
"WINDOW",
"FUNCTION",
"TO",
"MATCH"
] | python | train |
bcbio/bcbio-nextgen | bcbio/pipeline/config_utils.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/config_utils.py#L221-L233 | def _get_program_cmd(name, pconfig, config, default):
"""Retrieve commandline of a program.
"""
if pconfig is None:
return name
elif isinstance(pconfig, six.string_types):
return pconfig
elif "cmd" in pconfig:
return pconfig["cmd"]
elif default is not None:
return... | [
"def",
"_get_program_cmd",
"(",
"name",
",",
"pconfig",
",",
"config",
",",
"default",
")",
":",
"if",
"pconfig",
"is",
"None",
":",
"return",
"name",
"elif",
"isinstance",
"(",
"pconfig",
",",
"six",
".",
"string_types",
")",
":",
"return",
"pconfig",
"... | Retrieve commandline of a program. | [
"Retrieve",
"commandline",
"of",
"a",
"program",
"."
] | python | train |
EasyPost/pystalk | pystalk/client.py | https://github.com/EasyPost/pystalk/blob/96759ad1fda264b9897ee5346eef7926892a3a4c/pystalk/client.py#L572-L587 | def pause_tube(self, tube, delay=3600):
"""Pause a tube for some number of seconds, preventing it from issuing jobs.
:param delay: Time to pause for, in seconds
:type delay: int
There is no way to permanently pause a tube; passing 0 for delay actually un-pauses the tube.
.. se... | [
"def",
"pause_tube",
"(",
"self",
",",
"tube",
",",
"delay",
"=",
"3600",
")",
":",
"with",
"self",
".",
"_sock_ctx",
"(",
")",
"as",
"socket",
":",
"delay",
"=",
"int",
"(",
"delay",
")",
"self",
".",
"_send_message",
"(",
"'pause-tube {0} {1}'",
".",... | Pause a tube for some number of seconds, preventing it from issuing jobs.
:param delay: Time to pause for, in seconds
:type delay: int
There is no way to permanently pause a tube; passing 0 for delay actually un-pauses the tube.
.. seealso::
:func:`unpause_tube()` | [
"Pause",
"a",
"tube",
"for",
"some",
"number",
"of",
"seconds",
"preventing",
"it",
"from",
"issuing",
"jobs",
"."
] | python | train |
ktbyers/netmiko | netmiko/base_connection.py | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/base_connection.py#L1147-L1158 | def strip_prompt(self, a_string):
"""Strip the trailing router prompt from the output.
:param a_string: Returned string from device
:type a_string: str
"""
response_list = a_string.split(self.RESPONSE_RETURN)
last_line = response_list[-1]
if self.base_prompt in l... | [
"def",
"strip_prompt",
"(",
"self",
",",
"a_string",
")",
":",
"response_list",
"=",
"a_string",
".",
"split",
"(",
"self",
".",
"RESPONSE_RETURN",
")",
"last_line",
"=",
"response_list",
"[",
"-",
"1",
"]",
"if",
"self",
".",
"base_prompt",
"in",
"last_li... | Strip the trailing router prompt from the output.
:param a_string: Returned string from device
:type a_string: str | [
"Strip",
"the",
"trailing",
"router",
"prompt",
"from",
"the",
"output",
"."
] | python | train |
SiLab-Bonn/basil | basil/HL/FEI4AdapterCard.py | https://github.com/SiLab-Bonn/basil/blob/99052482d9334dd1f5598eb2d2fb4d5399a32291/basil/HL/FEI4AdapterCard.py#L336-L366 | def read_eeprom_calibration(self, temperature=False): # use default values for temperature, EEPROM values are usually not calibrated and random
'''Reading EEPROM calibration for power regulators and temperature
'''
header = self.get_format()
if header == self.HEADER_V1:
data... | [
"def",
"read_eeprom_calibration",
"(",
"self",
",",
"temperature",
"=",
"False",
")",
":",
"# use default values for temperature, EEPROM values are usually not calibrated and random",
"header",
"=",
"self",
".",
"get_format",
"(",
")",
"if",
"header",
"==",
"self",
".",
... | Reading EEPROM calibration for power regulators and temperature | [
"Reading",
"EEPROM",
"calibration",
"for",
"power",
"regulators",
"and",
"temperature"
] | python | train |
danpaquin/coinbasepro-python | cbpro/authenticated_client.py | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/authenticated_client.py#L91-L129 | def get_account_history(self, account_id, **kwargs):
""" List account activity. Account activity either increases or
decreases your account balance.
Entry type indicates the reason for the account change.
* transfer: Funds moved to/from Coinbase to cbpro
* match: Funds moved as ... | [
"def",
"get_account_history",
"(",
"self",
",",
"account_id",
",",
"*",
"*",
"kwargs",
")",
":",
"endpoint",
"=",
"'/accounts/{}/ledger'",
".",
"format",
"(",
"account_id",
")",
"return",
"self",
".",
"_send_paginated_message",
"(",
"endpoint",
",",
"params",
... | List account activity. Account activity either increases or
decreases your account balance.
Entry type indicates the reason for the account change.
* transfer: Funds moved to/from Coinbase to cbpro
* match: Funds moved as a result of a trade
* fee: Fee as a result of a trade... | [
"List",
"account",
"activity",
".",
"Account",
"activity",
"either",
"increases",
"or",
"decreases",
"your",
"account",
"balance",
"."
] | python | train |
AndrewAnnex/SpiceyPy | spiceypy/spiceypy.py | https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L5089-L5118 | def eul2m(angle3, angle2, angle1, axis3, axis2, axis1):
"""
Construct a rotation matrix from a set of Euler angles.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/eul2m_c.html
:param angle3: Rotation angle about third rotation axis (radians).
:type angle3: float
:param angle2: Rotatio... | [
"def",
"eul2m",
"(",
"angle3",
",",
"angle2",
",",
"angle1",
",",
"axis3",
",",
"axis2",
",",
"axis1",
")",
":",
"angle3",
"=",
"ctypes",
".",
"c_double",
"(",
"angle3",
")",
"angle2",
"=",
"ctypes",
".",
"c_double",
"(",
"angle2",
")",
"angle1",
"="... | Construct a rotation matrix from a set of Euler angles.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/eul2m_c.html
:param angle3: Rotation angle about third rotation axis (radians).
:type angle3: float
:param angle2: Rotation angle about second rotation axis (radians).
:type angle2: floa... | [
"Construct",
"a",
"rotation",
"matrix",
"from",
"a",
"set",
"of",
"Euler",
"angles",
"."
] | python | train |
LPgenerator/django-mmc | mmc/mixins.py | https://github.com/LPgenerator/django-mmc/blob/3b6d3c9d1721c4428177277c1bb1ca24512127de/mmc/mixins.py#L111-L123 | def run_at_subprocess(self, use_subprocess, foo, *args, **kwrags):
"""
This method for run some function at subprocess.
Very useful when you have a problem with memory leaks.
"""
if use_subprocess is False:
return foo(*args, **kwrags)
child_pid = os.fork()
... | [
"def",
"run_at_subprocess",
"(",
"self",
",",
"use_subprocess",
",",
"foo",
",",
"*",
"args",
",",
"*",
"*",
"kwrags",
")",
":",
"if",
"use_subprocess",
"is",
"False",
":",
"return",
"foo",
"(",
"*",
"args",
",",
"*",
"*",
"kwrags",
")",
"child_pid",
... | This method for run some function at subprocess.
Very useful when you have a problem with memory leaks. | [
"This",
"method",
"for",
"run",
"some",
"function",
"at",
"subprocess",
".",
"Very",
"useful",
"when",
"you",
"have",
"a",
"problem",
"with",
"memory",
"leaks",
"."
] | python | train |
Unity-Technologies/ml-agents | ml-agents-envs/mlagents/envs/rpc_communicator.py | https://github.com/Unity-Technologies/ml-agents/blob/37d139af636e4a2351751fbf0f2fca5a9ed7457f/ml-agents-envs/mlagents/envs/rpc_communicator.py#L65-L75 | def check_port(self, port):
"""
Attempts to bind to the requested communicator port, checking if it is already in use.
"""
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.bind(("localhost", port))
except socket.error:
raise UnityWorker... | [
"def",
"check_port",
"(",
"self",
",",
"port",
")",
":",
"s",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_INET",
",",
"socket",
".",
"SOCK_STREAM",
")",
"try",
":",
"s",
".",
"bind",
"(",
"(",
"\"localhost\"",
",",
"port",
")",
")",
"exce... | Attempts to bind to the requested communicator port, checking if it is already in use. | [
"Attempts",
"to",
"bind",
"to",
"the",
"requested",
"communicator",
"port",
"checking",
"if",
"it",
"is",
"already",
"in",
"use",
"."
] | python | train |
pycontribs/pyrax | pyrax/queueing.py | https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/queueing.py#L528-L534 | def _configure_manager(self):
"""
Create the manager to handle queues.
"""
self._manager = QueueManager(self,
resource_class=Queue, response_key="queue",
uri_base="queues") | [
"def",
"_configure_manager",
"(",
"self",
")",
":",
"self",
".",
"_manager",
"=",
"QueueManager",
"(",
"self",
",",
"resource_class",
"=",
"Queue",
",",
"response_key",
"=",
"\"queue\"",
",",
"uri_base",
"=",
"\"queues\"",
")"
] | Create the manager to handle queues. | [
"Create",
"the",
"manager",
"to",
"handle",
"queues",
"."
] | python | train |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/bakery/_macaroon.py | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_macaroon.py#L250-L293 | def _new_caveat_id(self, base):
'''Return a third party caveat id
This does not duplicate any third party caveat ids already inside
macaroon. If base is non-empty, it is used as the id prefix.
@param base bytes
@return bytes
'''
id = bytearray()
if len(b... | [
"def",
"_new_caveat_id",
"(",
"self",
",",
"base",
")",
":",
"id",
"=",
"bytearray",
"(",
")",
"if",
"len",
"(",
"base",
")",
">",
"0",
":",
"id",
".",
"extend",
"(",
"base",
")",
"else",
":",
"# Add a version byte to the caveat id. Technically",
"# this i... | Return a third party caveat id
This does not duplicate any third party caveat ids already inside
macaroon. If base is non-empty, it is used as the id prefix.
@param base bytes
@return bytes | [
"Return",
"a",
"third",
"party",
"caveat",
"id"
] | python | train |
ipfs/py-ipfs-api | ipfsapi/client.py | https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L2282-L2330 | def pubsub_peers(self, topic=None, **kwargs):
"""List the peers we are pubsubbing with.
Lists the id's of other IPFS users who we
are connected to via some topic. Without specifying
a topic, IPFS peers from all subscribed topics
will be returned in the data. If a topic is specif... | [
"def",
"pubsub_peers",
"(",
"self",
",",
"topic",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"args",
"=",
"(",
"topic",
",",
")",
"if",
"topic",
"is",
"not",
"None",
"else",
"(",
")",
"return",
"self",
".",
"_client",
".",
"request",
"(",
"'... | List the peers we are pubsubbing with.
Lists the id's of other IPFS users who we
are connected to via some topic. Without specifying
a topic, IPFS peers from all subscribed topics
will be returned in the data. If a topic is specified
only the IPFS id's of the peers from the spec... | [
"List",
"the",
"peers",
"we",
"are",
"pubsubbing",
"with",
"."
] | python | train |
Diviyan-Kalainathan/CausalDiscoveryToolbox | cdt/causality/graph/CGNN.py | https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/graph/CGNN.py#L315-L344 | def orient_undirected_graph(self, data, umg, alg='HC'):
"""Orient the undirected graph using GNN and apply CGNN to improve the graph.
Args:
data (pandas.DataFrame): Observational data on which causal
discovery has to be performed.
umg (nx.Graph): Graph that provid... | [
"def",
"orient_undirected_graph",
"(",
"self",
",",
"data",
",",
"umg",
",",
"alg",
"=",
"'HC'",
")",
":",
"warnings",
".",
"warn",
"(",
"\"The pairwise GNN model is computed on each edge of the UMG \"",
"\"to initialize the model and start CGNN with a DAG\"",
")",
"gnn",
... | Orient the undirected graph using GNN and apply CGNN to improve the graph.
Args:
data (pandas.DataFrame): Observational data on which causal
discovery has to be performed.
umg (nx.Graph): Graph that provides the skeleton, on which the GNN
then the CGNN algo... | [
"Orient",
"the",
"undirected",
"graph",
"using",
"GNN",
"and",
"apply",
"CGNN",
"to",
"improve",
"the",
"graph",
"."
] | python | valid |
Vital-Fernandez/dazer | bin/lib/Astro_Libraries/f2n.py | https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L954-L972 | def fromfits(infile, hdu = 0, verbose = True):
"""
Factory function that reads a FITS file and returns a f2nimage object.
Use hdu to specify which HDU you want (primary = 0)
"""
pixelarray, hdr = ft.getdata(infile, hdu, header=True)
pixelarray = np.asarray(pixelarray).transpose()
#print... | [
"def",
"fromfits",
"(",
"infile",
",",
"hdu",
"=",
"0",
",",
"verbose",
"=",
"True",
")",
":",
"pixelarray",
",",
"hdr",
"=",
"ft",
".",
"getdata",
"(",
"infile",
",",
"hdu",
",",
"header",
"=",
"True",
")",
"pixelarray",
"=",
"np",
".",
"asarray",... | Factory function that reads a FITS file and returns a f2nimage object.
Use hdu to specify which HDU you want (primary = 0) | [
"Factory",
"function",
"that",
"reads",
"a",
"FITS",
"file",
"and",
"returns",
"a",
"f2nimage",
"object",
".",
"Use",
"hdu",
"to",
"specify",
"which",
"HDU",
"you",
"want",
"(",
"primary",
"=",
"0",
")"
] | python | train |
pyqt/python-qt5 | setup.py | https://github.com/pyqt/python-qt5/blob/c9ed180c56f6fd3521ffe5fb70904bc5d3f50e5f/setup.py#L35-L58 | def get_package_data():
"""Include all files from all sub-directories"""
package_data = dict()
package_data['PyQt5'] = list()
for subdir in ("doc/", "examples/", "include/",
"mkspecs/", "plugins/", "qml/",
"qsci/", "sip/", "translations/", "uic/"):
abspath ... | [
"def",
"get_package_data",
"(",
")",
":",
"package_data",
"=",
"dict",
"(",
")",
"package_data",
"[",
"'PyQt5'",
"]",
"=",
"list",
"(",
")",
"for",
"subdir",
"in",
"(",
"\"doc/\"",
",",
"\"examples/\"",
",",
"\"include/\"",
",",
"\"mkspecs/\"",
",",
"\"plu... | Include all files from all sub-directories | [
"Include",
"all",
"files",
"from",
"all",
"sub",
"-",
"directories"
] | python | train |
tonioo/sievelib | sievelib/managesieve.py | https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/managesieve.py#L485-L511 | def connect(
self, login, password, authz_id=b"", starttls=False,
authmech=None):
"""Establish a connection with the server.
This function must be used. It read the server capabilities
and wraps calls to STARTTLS and AUTHENTICATE commands.
:param login: username... | [
"def",
"connect",
"(",
"self",
",",
"login",
",",
"password",
",",
"authz_id",
"=",
"b\"\"",
",",
"starttls",
"=",
"False",
",",
"authmech",
"=",
"None",
")",
":",
"try",
":",
"self",
".",
"sock",
"=",
"socket",
".",
"create_connection",
"(",
"(",
"s... | Establish a connection with the server.
This function must be used. It read the server capabilities
and wraps calls to STARTTLS and AUTHENTICATE commands.
:param login: username
:param password: clear password
:param starttls: use a TLS connection or not
:param authmech... | [
"Establish",
"a",
"connection",
"with",
"the",
"server",
"."
] | python | train |
google/grr | grr/server/grr_response_server/databases/mysql_flows.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_flows.py#L867-L897 | def _UpdateRequestsAndScheduleFPRs(self, responses, cursor=None):
"""Updates requests and writes FlowProcessingRequests if needed."""
request_keys = set(
(r.client_id, r.flow_id, r.request_id) for r in responses)
flow_keys = set((r.client_id, r.flow_id) for r in responses)
response_counts = se... | [
"def",
"_UpdateRequestsAndScheduleFPRs",
"(",
"self",
",",
"responses",
",",
"cursor",
"=",
"None",
")",
":",
"request_keys",
"=",
"set",
"(",
"(",
"r",
".",
"client_id",
",",
"r",
".",
"flow_id",
",",
"r",
".",
"request_id",
")",
"for",
"r",
"in",
"re... | Updates requests and writes FlowProcessingRequests if needed. | [
"Updates",
"requests",
"and",
"writes",
"FlowProcessingRequests",
"if",
"needed",
"."
] | python | train |
singnet/snet-cli | snet_cli/mpe_service_metadata.py | https://github.com/singnet/snet-cli/blob/1b5ac98cb9a64211c861ead9fcfe6208f2749032/snet_cli/mpe_service_metadata.py#L103-L109 | def is_group_name_exists(self, group_name):
""" check if group with given name is already exists """
groups = self.m["groups"]
for g in groups:
if (g["group_name"] == group_name):
return True
return False | [
"def",
"is_group_name_exists",
"(",
"self",
",",
"group_name",
")",
":",
"groups",
"=",
"self",
".",
"m",
"[",
"\"groups\"",
"]",
"for",
"g",
"in",
"groups",
":",
"if",
"(",
"g",
"[",
"\"group_name\"",
"]",
"==",
"group_name",
")",
":",
"return",
"True... | check if group with given name is already exists | [
"check",
"if",
"group",
"with",
"given",
"name",
"is",
"already",
"exists"
] | python | train |
kragniz/python-etcd3 | etcd3/client.py | https://github.com/kragniz/python-etcd3/blob/0adb14840d4a6011a2023a13f07e247e4c336a80/etcd3/client.py#L453-L476 | def replace(self, key, initial_value, new_value):
"""
Atomically replace the value of a key with a new value.
This compares the current value of a key, then replaces it with a new
value if it is equal to a specified value. This operation takes place
in a transaction.
:p... | [
"def",
"replace",
"(",
"self",
",",
"key",
",",
"initial_value",
",",
"new_value",
")",
":",
"status",
",",
"_",
"=",
"self",
".",
"transaction",
"(",
"compare",
"=",
"[",
"self",
".",
"transactions",
".",
"value",
"(",
"key",
")",
"==",
"initial_value... | Atomically replace the value of a key with a new value.
This compares the current value of a key, then replaces it with a new
value if it is equal to a specified value. This operation takes place
in a transaction.
:param key: key in etcd to replace
:param initial_value: old val... | [
"Atomically",
"replace",
"the",
"value",
"of",
"a",
"key",
"with",
"a",
"new",
"value",
"."
] | python | train |
SiLab-Bonn/pyBAR | pybar/run_manager.py | https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/run_manager.py#L268-L278 | def stop(self, msg=None):
'''Stopping a run. Control for loops. Gentle stop/abort.
This event should provide a more gentle abort. The run should stop ASAP but the run is still considered complete.
'''
if not self.stop_run.is_set():
if msg:
logging.info('%s%s ... | [
"def",
"stop",
"(",
"self",
",",
"msg",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"stop_run",
".",
"is_set",
"(",
")",
":",
"if",
"msg",
":",
"logging",
".",
"info",
"(",
"'%s%s Stopping run...'",
",",
"msg",
",",
"(",
"''",
"if",
"msg",
"... | Stopping a run. Control for loops. Gentle stop/abort.
This event should provide a more gentle abort. The run should stop ASAP but the run is still considered complete. | [
"Stopping",
"a",
"run",
".",
"Control",
"for",
"loops",
".",
"Gentle",
"stop",
"/",
"abort",
"."
] | python | train |
blockstack/virtualchain | virtualchain/lib/ecdsalib.py | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/ecdsalib.py#L412-L429 | def sign_digest(hash_hex, privkey_hex, hashfunc=hashlib.sha256):
"""
Given a digest and a private key, sign it.
Return the base64-encoded signature
"""
if not isinstance(hash_hex, (str, unicode)):
raise ValueError("hash hex is not a string")
hash_hex = str(hash_hex)
pk_i = decode_p... | [
"def",
"sign_digest",
"(",
"hash_hex",
",",
"privkey_hex",
",",
"hashfunc",
"=",
"hashlib",
".",
"sha256",
")",
":",
"if",
"not",
"isinstance",
"(",
"hash_hex",
",",
"(",
"str",
",",
"unicode",
")",
")",
":",
"raise",
"ValueError",
"(",
"\"hash hex is not ... | Given a digest and a private key, sign it.
Return the base64-encoded signature | [
"Given",
"a",
"digest",
"and",
"a",
"private",
"key",
"sign",
"it",
".",
"Return",
"the",
"base64",
"-",
"encoded",
"signature"
] | python | train |
dnanexus/dx-toolkit | src/python/dxpy/utils/resolver.py | https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/utils/resolver.py#L721-L747 | def _resolve_folder(project, parent_folder, folder_name):
"""
:param project: The project that the folder belongs to
:type project: string
:param parent_folder: Full path to the parent folder that contains
folder_name
:type parent_folder: string
:param folder_name: Name ... | [
"def",
"_resolve_folder",
"(",
"project",
",",
"parent_folder",
",",
"folder_name",
")",
":",
"if",
"'/'",
"in",
"folder_name",
":",
"# Then there's no way it's supposed to be a folder",
"raise",
"ResolutionError",
"(",
"'Object of name '",
"+",
"str",
"(",
"folder_name... | :param project: The project that the folder belongs to
:type project: string
:param parent_folder: Full path to the parent folder that contains
folder_name
:type parent_folder: string
:param folder_name: Name of the folder
:type folder_name: string
:returns: The path to ... | [
":",
"param",
"project",
":",
"The",
"project",
"that",
"the",
"folder",
"belongs",
"to",
":",
"type",
"project",
":",
"string",
":",
"param",
"parent_folder",
":",
"Full",
"path",
"to",
"the",
"parent",
"folder",
"that",
"contains",
"folder_name",
":",
"t... | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.