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 |
|---|---|---|---|---|---|---|---|---|
robotools/fontParts | Lib/fontParts/base/normalizers.py | https://github.com/robotools/fontParts/blob/d2ff106fe95f9d566161d936a645157626568712/Lib/fontParts/base/normalizers.py#L319-L337 | def normalizeGlyphUnicode(value):
"""
Normalizes glyph unicode.
* **value** must be an int or hex (represented as a string).
* **value** must be in a unicode range.
* Returned value will be an ``int``.
"""
if not isinstance(value, (int, basestring)) or isinstance(value, bool):
raise... | [
"def",
"normalizeGlyphUnicode",
"(",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"(",
"int",
",",
"basestring",
")",
")",
"or",
"isinstance",
"(",
"value",
",",
"bool",
")",
":",
"raise",
"TypeError",
"(",
"\"Glyph unicode must be a int ... | Normalizes glyph unicode.
* **value** must be an int or hex (represented as a string).
* **value** must be in a unicode range.
* Returned value will be an ``int``. | [
"Normalizes",
"glyph",
"unicode",
"."
] | python | train |
iotile/coretools | iotilecore/iotile/core/utilities/schema_verify/bool_verify.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/schema_verify/bool_verify.py#L17-L36 | def verify(self, obj):
"""Verify that the object conforms to this verifier's schema
Args:
obj (object): A python object to verify
Raises:
ValidationError: If there is a problem verifying the dictionary, a
ValidationError is thrown with at least the reaso... | [
"def",
"verify",
"(",
"self",
",",
"obj",
")",
":",
"if",
"not",
"isinstance",
"(",
"obj",
",",
"bool",
")",
":",
"raise",
"ValidationError",
"(",
"\"Object is not a bool\"",
",",
"reason",
"=",
"'object is not a bool'",
",",
"object",
"=",
"obj",
")",
"if... | Verify that the object conforms to this verifier's schema
Args:
obj (object): A python object to verify
Raises:
ValidationError: If there is a problem verifying the dictionary, a
ValidationError is thrown with at least the reason key set indicating
... | [
"Verify",
"that",
"the",
"object",
"conforms",
"to",
"this",
"verifier",
"s",
"schema"
] | python | train |
vintasoftware/django-role-permissions | rolepermissions/roles.py | https://github.com/vintasoftware/django-role-permissions/blob/28924361e689e994e0c3575e18104a1a5abd8de6/rolepermissions/roles.py#L183-L192 | def get_or_create_permission(codename, name=camel_or_snake_to_title):
"""
Get a Permission object from a permission name.
@:param codename: permission code name
@:param name: human-readable permissions name (str) or callable that takes codename as
argument and returns str
"""
u... | [
"def",
"get_or_create_permission",
"(",
"codename",
",",
"name",
"=",
"camel_or_snake_to_title",
")",
":",
"user_ct",
"=",
"ContentType",
".",
"objects",
".",
"get_for_model",
"(",
"get_user_model",
"(",
")",
")",
"return",
"Permission",
".",
"objects",
".",
"ge... | Get a Permission object from a permission name.
@:param codename: permission code name
@:param name: human-readable permissions name (str) or callable that takes codename as
argument and returns str | [
"Get",
"a",
"Permission",
"object",
"from",
"a",
"permission",
"name",
"."
] | python | train |
twisted/mantissa | xmantissa/signup.py | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/signup.py#L170-L182 | def handleRequestForUser(self, username, url):
"""
User C{username} wants to reset their password. Create an attempt
item, and send them an email if the username is valid
"""
attempt = self.newAttemptForUser(username)
account = self.accountByAddress(username)
if ... | [
"def",
"handleRequestForUser",
"(",
"self",
",",
"username",
",",
"url",
")",
":",
"attempt",
"=",
"self",
".",
"newAttemptForUser",
"(",
"username",
")",
"account",
"=",
"self",
".",
"accountByAddress",
"(",
"username",
")",
"if",
"account",
"is",
"None",
... | User C{username} wants to reset their password. Create an attempt
item, and send them an email if the username is valid | [
"User",
"C",
"{",
"username",
"}",
"wants",
"to",
"reset",
"their",
"password",
".",
"Create",
"an",
"attempt",
"item",
"and",
"send",
"them",
"an",
"email",
"if",
"the",
"username",
"is",
"valid"
] | python | train |
marcinmiklitz/pywindow | pywindow/molecular.py | https://github.com/marcinmiklitz/pywindow/blob/e5264812157224f22a691741ca2e0aefdc9bd2eb/pywindow/molecular.py#L806-L828 | def load_file(cls, filepath):
"""
Create a :class:`MolecularSystem` from an input file.
Recognized input file formats: XYZ, PDB and MOL (V3000).
Parameters
----------
filepath : :class:`str`
The input's filepath.
Returns
-------
:clas... | [
"def",
"load_file",
"(",
"cls",
",",
"filepath",
")",
":",
"obj",
"=",
"cls",
"(",
")",
"obj",
".",
"system",
"=",
"obj",
".",
"_Input",
".",
"load_file",
"(",
"filepath",
")",
"obj",
".",
"filename",
"=",
"os",
".",
"path",
".",
"basename",
"(",
... | Create a :class:`MolecularSystem` from an input file.
Recognized input file formats: XYZ, PDB and MOL (V3000).
Parameters
----------
filepath : :class:`str`
The input's filepath.
Returns
-------
:class:`pywindow.molecular.MolecularSystem`
... | [
"Create",
"a",
":",
"class",
":",
"MolecularSystem",
"from",
"an",
"input",
"file",
"."
] | python | train |
tensorflow/cleverhans | examples/RL-attack/model.py | https://github.com/tensorflow/cleverhans/blob/97488e215760547b81afc53f5e5de8ba7da5bd98/examples/RL-attack/model.py#L38-L95 | def dueling_model(img_in, num_actions, scope, noisy=False, reuse=False,
concat_softmax=False):
"""As described in https://arxiv.org/abs/1511.06581"""
with tf.variable_scope(scope, reuse=reuse):
out = img_in
with tf.variable_scope("convnet"):
# original architecture
out = layers... | [
"def",
"dueling_model",
"(",
"img_in",
",",
"num_actions",
",",
"scope",
",",
"noisy",
"=",
"False",
",",
"reuse",
"=",
"False",
",",
"concat_softmax",
"=",
"False",
")",
":",
"with",
"tf",
".",
"variable_scope",
"(",
"scope",
",",
"reuse",
"=",
"reuse",... | As described in https://arxiv.org/abs/1511.06581 | [
"As",
"described",
"in",
"https",
":",
"//",
"arxiv",
".",
"org",
"/",
"abs",
"/",
"1511",
".",
"06581"
] | python | train |
benmack/eo-box | eobox/raster/utils.py | https://github.com/benmack/eo-box/blob/a291450c766bf50ea06adcdeb5729a4aad790ed5/eobox/raster/utils.py#L13-L40 | def dtype_checker_df(df, dtype, return_=None):
"""Check if there are NaN values of values outside of a given datatype range.
Arguments:
df {dataframe} -- A dataframe.
dtype {str} -- The datatype to check for.
Keyword Arguments:
return_ {str} -- Returns a boolean dataframe with the v... | [
"def",
"dtype_checker_df",
"(",
"df",
",",
"dtype",
",",
"return_",
"=",
"None",
")",
":",
"dtype_range",
"=",
"dtype_ranges",
"[",
"dtype",
"]",
"df_out_of_range",
"=",
"(",
"df",
"<",
"dtype_range",
"[",
"0",
"]",
")",
"|",
"(",
"df",
">",
"dtype_ran... | Check if there are NaN values of values outside of a given datatype range.
Arguments:
df {dataframe} -- A dataframe.
dtype {str} -- The datatype to check for.
Keyword Arguments:
return_ {str} -- Returns a boolean dataframe with the values not in the range of the dtype ('all'),
... | [
"Check",
"if",
"there",
"are",
"NaN",
"values",
"of",
"values",
"outside",
"of",
"a",
"given",
"datatype",
"range",
"."
] | python | train |
Kami/python-yubico-client | yubico_client/yubico.py | https://github.com/Kami/python-yubico-client/blob/3334b2ee1b5b996af3ef6be57a4ea52b8e45e764/yubico_client/yubico.py#L347-L365 | def _init_request_urls(self, api_urls):
"""
Returns a list of the API URLs.
"""
if not isinstance(api_urls, (str, list, tuple)):
raise TypeError('api_urls needs to be string or iterable!')
if isinstance(api_urls, str):
api_urls = (api_urls,)
api_... | [
"def",
"_init_request_urls",
"(",
"self",
",",
"api_urls",
")",
":",
"if",
"not",
"isinstance",
"(",
"api_urls",
",",
"(",
"str",
",",
"list",
",",
"tuple",
")",
")",
":",
"raise",
"TypeError",
"(",
"'api_urls needs to be string or iterable!'",
")",
"if",
"i... | Returns a list of the API URLs. | [
"Returns",
"a",
"list",
"of",
"the",
"API",
"URLs",
"."
] | python | train |
django-fluent/django-fluent-contents | fluent_contents/management/commands/find_contentitem_urls.py | https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/management/commands/find_contentitem_urls.py#L119-L146 | def extract_html_urls(self, html):
"""
Take all ``<img src="..">`` from the HTML
"""
p = HTMLParser(tree=treebuilders.getTreeBuilder("dom"))
dom = p.parse(html)
urls = []
for img in dom.getElementsByTagName('img'):
src = img.getAttribute('src')
... | [
"def",
"extract_html_urls",
"(",
"self",
",",
"html",
")",
":",
"p",
"=",
"HTMLParser",
"(",
"tree",
"=",
"treebuilders",
".",
"getTreeBuilder",
"(",
"\"dom\"",
")",
")",
"dom",
"=",
"p",
".",
"parse",
"(",
"html",
")",
"urls",
"=",
"[",
"]",
"for",
... | Take all ``<img src="..">`` from the HTML | [
"Take",
"all",
"<img",
"src",
"=",
"..",
">",
"from",
"the",
"HTML"
] | python | train |
tensorflow/cleverhans | cleverhans/utils_tf.py | https://github.com/tensorflow/cleverhans/blob/97488e215760547b81afc53f5e5de8ba7da5bd98/cleverhans/utils_tf.py#L647-L665 | def jacobian_graph(predictions, x, nb_classes):
"""
Create the Jacobian graph to be ran later in a TF session
:param predictions: the model's symbolic output (linear output,
pre-softmax)
:param x: the input placeholder
:param nb_classes: the number of classes the model has
:return:
"""
# This fun... | [
"def",
"jacobian_graph",
"(",
"predictions",
",",
"x",
",",
"nb_classes",
")",
":",
"# This function will return a list of TF gradients",
"list_derivatives",
"=",
"[",
"]",
"# Define the TF graph elements to compute our derivatives for each class",
"for",
"class_ind",
"in",
"xr... | Create the Jacobian graph to be ran later in a TF session
:param predictions: the model's symbolic output (linear output,
pre-softmax)
:param x: the input placeholder
:param nb_classes: the number of classes the model has
:return: | [
"Create",
"the",
"Jacobian",
"graph",
"to",
"be",
"ran",
"later",
"in",
"a",
"TF",
"session",
":",
"param",
"predictions",
":",
"the",
"model",
"s",
"symbolic",
"output",
"(",
"linear",
"output",
"pre",
"-",
"softmax",
")",
":",
"param",
"x",
":",
"the... | python | train |
iotile/coretools | iotilegateway/iotilegateway/supervisor/client.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilegateway/iotilegateway/supervisor/client.py#L615-L625 | def get_headline(self, name):
"""Get stored messages for a service.
Args:
name (string): The name of the service to get messages from.
Returns:
ServiceMessage: the headline or None if no headline has been set
"""
return self._loop.run_coroutine(self._cl... | [
"def",
"get_headline",
"(",
"self",
",",
"name",
")",
":",
"return",
"self",
".",
"_loop",
".",
"run_coroutine",
"(",
"self",
".",
"_client",
".",
"get_headline",
"(",
"name",
")",
")"
] | Get stored messages for a service.
Args:
name (string): The name of the service to get messages from.
Returns:
ServiceMessage: the headline or None if no headline has been set | [
"Get",
"stored",
"messages",
"for",
"a",
"service",
"."
] | python | train |
Alignak-monitoring/alignak | alignak/objects/host.py | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/host.py#L1438-L1464 | def explode(self, hostgroups, contactgroups):
"""Explode hosts with hostgroups, contactgroups::
* Add contact from contactgroups to host contacts
* Add host into their hostgroups as hostgroup members
:param hostgroups: Hostgroups to explode
:type hostgroups: alignak.objects.hos... | [
"def",
"explode",
"(",
"self",
",",
"hostgroups",
",",
"contactgroups",
")",
":",
"for",
"template",
"in",
"list",
"(",
"self",
".",
"templates",
".",
"values",
"(",
")",
")",
":",
"# items::explode_contact_groups_into_contacts",
"# take all contacts from our contac... | Explode hosts with hostgroups, contactgroups::
* Add contact from contactgroups to host contacts
* Add host into their hostgroups as hostgroup members
:param hostgroups: Hostgroups to explode
:type hostgroups: alignak.objects.hostgroup.Hostgroups
:param contactgroups: Contactgo... | [
"Explode",
"hosts",
"with",
"hostgroups",
"contactgroups",
"::"
] | python | train |
fermiPy/fermipy | fermipy/diffuse/job_library.py | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/job_library.py#L418-L437 | def build_job_configs(self, args):
"""Hook to build job configurations
"""
job_configs = {}
gmm = make_ring_dicts(library=args['library'], basedir='.')
for galkey in gmm.galkeys():
ring_dict = gmm.ring_dict(galkey)
for ring_key, ring_info in ring_dict.it... | [
"def",
"build_job_configs",
"(",
"self",
",",
"args",
")",
":",
"job_configs",
"=",
"{",
"}",
"gmm",
"=",
"make_ring_dicts",
"(",
"library",
"=",
"args",
"[",
"'library'",
"]",
",",
"basedir",
"=",
"'.'",
")",
"for",
"galkey",
"in",
"gmm",
".",
"galkey... | Hook to build job configurations | [
"Hook",
"to",
"build",
"job",
"configurations"
] | python | train |
mjirik/imcut | imcut/pycut.py | https://github.com/mjirik/imcut/blob/1b38e7cd18a7a38fe683c1cabe1222fe5fa03aa3/imcut/pycut.py#L1539-L1555 | def get_node_msindex(msinds, node_seed):
"""
Convert seeds-like selection of voxel to multiscale index.
:param msinds: ndarray with indexes
:param node_seed: ndarray with 1 where selected pixel is, or list of indexes in this array
:return: multiscale index of first found seed
"""
if type(nod... | [
"def",
"get_node_msindex",
"(",
"msinds",
",",
"node_seed",
")",
":",
"if",
"type",
"(",
"node_seed",
")",
"==",
"np",
".",
"ndarray",
":",
"seed_indexes",
"=",
"np",
".",
"nonzero",
"(",
"node_seed",
")",
"elif",
"type",
"(",
"node_seed",
")",
"==",
"... | Convert seeds-like selection of voxel to multiscale index.
:param msinds: ndarray with indexes
:param node_seed: ndarray with 1 where selected pixel is, or list of indexes in this array
:return: multiscale index of first found seed | [
"Convert",
"seeds",
"-",
"like",
"selection",
"of",
"voxel",
"to",
"multiscale",
"index",
".",
":",
"param",
"msinds",
":",
"ndarray",
"with",
"indexes",
":",
"param",
"node_seed",
":",
"ndarray",
"with",
"1",
"where",
"selected",
"pixel",
"is",
"or",
"lis... | python | train |
cyrus-/cypy | cypy/cg.py | https://github.com/cyrus-/cypy/blob/04bb59e91fa314e8cf987743189c77a9b6bc371d/cypy/cg.py#L149-L161 | def lines_once(cls, code, **kwargs):
"""One-off code generation using :meth:`lines`.
If keyword args are provided, initialized using
:meth:`with_id_processor`.
"""
if kwargs:
g = cls.with_id_processor()
g._append_context(kwargs)
else:
... | [
"def",
"lines_once",
"(",
"cls",
",",
"code",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
":",
"g",
"=",
"cls",
".",
"with_id_processor",
"(",
")",
"g",
".",
"_append_context",
"(",
"kwargs",
")",
"else",
":",
"g",
"=",
"cls",
"(",
")",
"g... | One-off code generation using :meth:`lines`.
If keyword args are provided, initialized using
:meth:`with_id_processor`. | [
"One",
"-",
"off",
"code",
"generation",
"using",
":",
"meth",
":",
"lines",
".",
"If",
"keyword",
"args",
"are",
"provided",
"initialized",
"using",
":",
"meth",
":",
"with_id_processor",
"."
] | python | train |
materialsproject/pymatgen | pymatgen/analysis/graphs.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L1696-L1748 | def add_edge(self, from_index, to_index,
weight=None, warn_duplicates=True,
edge_properties=None):
"""
Add edge to graph.
Since physically a 'bond' (or other connection
between sites) doesn't have a direction, from_index,
from_jimage can be swap... | [
"def",
"add_edge",
"(",
"self",
",",
"from_index",
",",
"to_index",
",",
"weight",
"=",
"None",
",",
"warn_duplicates",
"=",
"True",
",",
"edge_properties",
"=",
"None",
")",
":",
"# this is not necessary for the class to work, but",
"# just makes it neater",
"if",
... | Add edge to graph.
Since physically a 'bond' (or other connection
between sites) doesn't have a direction, from_index,
from_jimage can be swapped with to_index, to_jimage.
However, images will always always be shifted so that
from_index < to_index and from_jimage becomes (0, 0,... | [
"Add",
"edge",
"to",
"graph",
"."
] | python | train |
pjuren/pyokit | src/pyokit/statistics/beta.py | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/statistics/beta.py#L110-L115 | def beta_pdf(x, a, b):
"""Beta distirbution probability density function."""
bc = 1 / beta(a, b)
fc = x ** (a - 1)
sc = (1 - x) ** (b - 1)
return bc * fc * sc | [
"def",
"beta_pdf",
"(",
"x",
",",
"a",
",",
"b",
")",
":",
"bc",
"=",
"1",
"/",
"beta",
"(",
"a",
",",
"b",
")",
"fc",
"=",
"x",
"**",
"(",
"a",
"-",
"1",
")",
"sc",
"=",
"(",
"1",
"-",
"x",
")",
"**",
"(",
"b",
"-",
"1",
")",
"retu... | Beta distirbution probability density function. | [
"Beta",
"distirbution",
"probability",
"density",
"function",
"."
] | python | train |
PGower/PyCanvas | pycanvas/apis/group_categories.py | https://github.com/PGower/PyCanvas/blob/68520005382b440a1e462f9df369f54d364e21e8/pycanvas/apis/group_categories.py#L290-L317 | def list_users_in_group_category(self, group_category_id, search_term=None, unassigned=None):
"""
List users in group category.
Returns a list of users in the group category.
"""
path = {}
data = {}
params = {}
# REQUIRED - PATH - group_categor... | [
"def",
"list_users_in_group_category",
"(",
"self",
",",
"group_category_id",
",",
"search_term",
"=",
"None",
",",
"unassigned",
"=",
"None",
")",
":",
"path",
"=",
"{",
"}",
"data",
"=",
"{",
"}",
"params",
"=",
"{",
"}",
"# REQUIRED - PATH - group_category_... | List users in group category.
Returns a list of users in the group category. | [
"List",
"users",
"in",
"group",
"category",
".",
"Returns",
"a",
"list",
"of",
"users",
"in",
"the",
"group",
"category",
"."
] | python | train |
ninuxorg/nodeshot | nodeshot/community/participation/views.py | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/participation/views.py#L15-L23 | def initial(self, request, *args, **kwargs):
"""
Custom initial method:
* ensure node exists and store it in an instance attribute
* change queryset to return only comments of current node
"""
super(NodeRelationViewMixin, self).initial(request, *args, **kwargs)
... | [
"def",
"initial",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"NodeRelationViewMixin",
",",
"self",
")",
".",
"initial",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"self",
"."... | Custom initial method:
* ensure node exists and store it in an instance attribute
* change queryset to return only comments of current node | [
"Custom",
"initial",
"method",
":",
"*",
"ensure",
"node",
"exists",
"and",
"store",
"it",
"in",
"an",
"instance",
"attribute",
"*",
"change",
"queryset",
"to",
"return",
"only",
"comments",
"of",
"current",
"node"
] | python | train |
boriel/zxbasic | arch/zx48k/backend/__init__.py | https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L946-L995 | def _cast(ins):
""" Convert data from typeA to typeB (only numeric data types)
"""
# Signed and unsigned types are the same in the Z80
tA = ins.quad[2] # From TypeA
tB = ins.quad[3] # To TypeB
YY_TYPES[tA] # Type sizes
xsB = sB = YY_TYPES[tB] # Type sizes
output = []
if tA in (... | [
"def",
"_cast",
"(",
"ins",
")",
":",
"# Signed and unsigned types are the same in the Z80",
"tA",
"=",
"ins",
".",
"quad",
"[",
"2",
"]",
"# From TypeA",
"tB",
"=",
"ins",
".",
"quad",
"[",
"3",
"]",
"# To TypeB",
"YY_TYPES",
"[",
"tA",
"]",
"# Type sizes",... | Convert data from typeA to typeB (only numeric data types) | [
"Convert",
"data",
"from",
"typeA",
"to",
"typeB",
"(",
"only",
"numeric",
"data",
"types",
")"
] | python | train |
librosa/librosa | librosa/filters.py | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/filters.py#L229-L359 | def chroma(sr, n_fft, n_chroma=12, A440=440.0, ctroct=5.0,
octwidth=2, norm=2, base_c=True, dtype=np.float32):
"""Create a Filterbank matrix to convert STFT to chroma
Parameters
----------
sr : number > 0 [scalar]
audio sampling rate
n_fft : int > 0 [scalar]
... | [
"def",
"chroma",
"(",
"sr",
",",
"n_fft",
",",
"n_chroma",
"=",
"12",
",",
"A440",
"=",
"440.0",
",",
"ctroct",
"=",
"5.0",
",",
"octwidth",
"=",
"2",
",",
"norm",
"=",
"2",
",",
"base_c",
"=",
"True",
",",
"dtype",
"=",
"np",
".",
"float32",
"... | Create a Filterbank matrix to convert STFT to chroma
Parameters
----------
sr : number > 0 [scalar]
audio sampling rate
n_fft : int > 0 [scalar]
number of FFT bins
n_chroma : int > 0 [scalar]
number of chroma bins
A440 : float > 0 [scalar]
Re... | [
"Create",
"a",
"Filterbank",
"matrix",
"to",
"convert",
"STFT",
"to",
"chroma"
] | python | test |
helixyte/everest | everest/traversalpath.py | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/traversalpath.py#L51-L56 | def pop(self):
"""
Removes the last traversal path node from this traversal path.
"""
node = self.nodes.pop()
self.__keys.remove(node.key) | [
"def",
"pop",
"(",
"self",
")",
":",
"node",
"=",
"self",
".",
"nodes",
".",
"pop",
"(",
")",
"self",
".",
"__keys",
".",
"remove",
"(",
"node",
".",
"key",
")"
] | Removes the last traversal path node from this traversal path. | [
"Removes",
"the",
"last",
"traversal",
"path",
"node",
"from",
"this",
"traversal",
"path",
"."
] | python | train |
Azure/azure-sdk-for-python | azure-batch/azure/batch/custom/patch.py | https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-batch/azure/batch/custom/patch.py#L172-L186 | def _handle_output(results_queue):
"""Scan output for exceptions
If there is an output from an add task collection call add it to the results.
:param results_queue: Queue containing results of attempted add_collection's
:type results_queue: collections.deque
:return: list of TaskAddResults
:rt... | [
"def",
"_handle_output",
"(",
"results_queue",
")",
":",
"results",
"=",
"[",
"]",
"while",
"results_queue",
":",
"queue_item",
"=",
"results_queue",
".",
"pop",
"(",
")",
"results",
".",
"append",
"(",
"queue_item",
")",
"return",
"results"
] | Scan output for exceptions
If there is an output from an add task collection call add it to the results.
:param results_queue: Queue containing results of attempted add_collection's
:type results_queue: collections.deque
:return: list of TaskAddResults
:rtype: list[~TaskAddResult] | [
"Scan",
"output",
"for",
"exceptions"
] | python | test |
Cognexa/cxflow | cxflow/cli/common.py | https://github.com/Cognexa/cxflow/blob/dd609e6b0bd854424a8f86781dd77801a13038f9/cxflow/cli/common.py#L66-L90 | def create_dataset(config: dict, output_dir: Optional[str]=None) -> AbstractDataset:
"""
Create a dataset object according to the given config.
Dataset config section and the `output_dir` are passed to the constructor in a single YAML-encoded string.
:param config: config dict with dataset config
... | [
"def",
"create_dataset",
"(",
"config",
":",
"dict",
",",
"output_dir",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"AbstractDataset",
":",
"logging",
".",
"info",
"(",
"'Creating dataset'",
")",
"dataset_config",
"=",
"make_simple",
"(",
"conf... | Create a dataset object according to the given config.
Dataset config section and the `output_dir` are passed to the constructor in a single YAML-encoded string.
:param config: config dict with dataset config
:param output_dir: path to the training output dir or None
:return: dataset object | [
"Create",
"a",
"dataset",
"object",
"according",
"to",
"the",
"given",
"config",
"."
] | python | train |
mgbarrero/xbob.db.atvskeystroke | xbob/db/atvskeystroke/query.py | https://github.com/mgbarrero/xbob.db.atvskeystroke/blob/b7358a73e21757b43334df7c89ba057b377ca704/xbob/db/atvskeystroke/query.py#L249-L253 | def protocol(self, name):
"""Returns the protocol object in the database given a certain name. Raises
an error if that does not exist."""
return self.query(Protocol).filter(Protocol.name==name).one() | [
"def",
"protocol",
"(",
"self",
",",
"name",
")",
":",
"return",
"self",
".",
"query",
"(",
"Protocol",
")",
".",
"filter",
"(",
"Protocol",
".",
"name",
"==",
"name",
")",
".",
"one",
"(",
")"
] | Returns the protocol object in the database given a certain name. Raises
an error if that does not exist. | [
"Returns",
"the",
"protocol",
"object",
"in",
"the",
"database",
"given",
"a",
"certain",
"name",
".",
"Raises",
"an",
"error",
"if",
"that",
"does",
"not",
"exist",
"."
] | python | train |
okpy/ok-client | client/protocols/backup.py | https://github.com/okpy/ok-client/blob/517f57dd76284af40ba9766e42d9222b644afd9c/client/protocols/backup.py#L223-L250 | def send_messages(self, access_token, messages, timeout, current):
"""Send messages to server, along with user authentication."""
is_submit = current and self.args.submit and not self.args.revise
is_revision = current and self.args.revise
data = {
'assignment': self.assignme... | [
"def",
"send_messages",
"(",
"self",
",",
"access_token",
",",
"messages",
",",
"timeout",
",",
"current",
")",
":",
"is_submit",
"=",
"current",
"and",
"self",
".",
"args",
".",
"submit",
"and",
"not",
"self",
".",
"args",
".",
"revise",
"is_revision",
... | Send messages to server, along with user authentication. | [
"Send",
"messages",
"to",
"server",
"along",
"with",
"user",
"authentication",
"."
] | python | train |
kakwa/ldapcherry | ldapcherry/roles.py | https://github.com/kakwa/ldapcherry/blob/b5e7cb6a44065abc30d164e72981b3713a172dda/ldapcherry/roles.py#L302-L327 | def get_roles(self, groups):
"""get list of roles and list of standalone groups"""
roles = set([])
parentroles = set([])
notroles = set([])
tmp = set([])
usedgroups = {}
unusedgroups = {}
ret = {}
# determine roles membership
for role in se... | [
"def",
"get_roles",
"(",
"self",
",",
"groups",
")",
":",
"roles",
"=",
"set",
"(",
"[",
"]",
")",
"parentroles",
"=",
"set",
"(",
"[",
"]",
")",
"notroles",
"=",
"set",
"(",
"[",
"]",
")",
"tmp",
"=",
"set",
"(",
"[",
"]",
")",
"usedgroups",
... | get list of roles and list of standalone groups | [
"get",
"list",
"of",
"roles",
"and",
"list",
"of",
"standalone",
"groups"
] | python | train |
RedHatInsights/insights-core | insights/parsers/ps.py | https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/parsers/ps.py#L104-L123 | def users(self, proc):
"""
Searches for all users running a given command.
Returns:
dict: each username as a key to a list of PIDs (as strings) that
are running the given process.
``{}`` if neither ``USER`` nor ``UID`` is found or ``proc`` is not found.
... | [
"def",
"users",
"(",
"self",
",",
"proc",
")",
":",
"ret",
"=",
"{",
"}",
"if",
"self",
".",
"first_column",
"in",
"[",
"'USER'",
",",
"'UID'",
"]",
":",
"for",
"row",
"in",
"self",
".",
"data",
":",
"if",
"proc",
"==",
"row",
"[",
"self",
".",... | Searches for all users running a given command.
Returns:
dict: each username as a key to a list of PIDs (as strings) that
are running the given process.
``{}`` if neither ``USER`` nor ``UID`` is found or ``proc`` is not found.
.. note::
'proc' must match... | [
"Searches",
"for",
"all",
"users",
"running",
"a",
"given",
"command",
"."
] | python | train |
merll/docker-map | dockermap/map/state/base.py | https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/map/state/base.py#L107-L125 | def inspect(self):
"""
Fetches information about the container from the client.
"""
policy = self.policy
config_id = self.config_id
if self.config_id.config_type == ItemType.VOLUME:
if self.container_map.use_attached_parent_name:
container_name... | [
"def",
"inspect",
"(",
"self",
")",
":",
"policy",
"=",
"self",
".",
"policy",
"config_id",
"=",
"self",
".",
"config_id",
"if",
"self",
".",
"config_id",
".",
"config_type",
"==",
"ItemType",
".",
"VOLUME",
":",
"if",
"self",
".",
"container_map",
".",
... | Fetches information about the container from the client. | [
"Fetches",
"information",
"about",
"the",
"container",
"from",
"the",
"client",
"."
] | python | train |
jobovy/galpy | galpy/df/streamdf.py | https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/df/streamdf.py#L1256-L1359 | def _determine_stream_spreadLB(self,simple=_USESIMPLE,
ro=None,vo=None,
R0=None,Zsun=None,vsun=None):
"""Determine the spread in the stream in observable coordinates"""
if not hasattr(self,'_allErrCovs'):
self._determine_s... | [
"def",
"_determine_stream_spreadLB",
"(",
"self",
",",
"simple",
"=",
"_USESIMPLE",
",",
"ro",
"=",
"None",
",",
"vo",
"=",
"None",
",",
"R0",
"=",
"None",
",",
"Zsun",
"=",
"None",
",",
"vsun",
"=",
"None",
")",
":",
"if",
"not",
"hasattr",
"(",
"... | Determine the spread in the stream in observable coordinates | [
"Determine",
"the",
"spread",
"in",
"the",
"stream",
"in",
"observable",
"coordinates"
] | python | train |
gwastro/pycbc | pycbc/events/ranking.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/events/ranking.py#L90-L109 | def get_newsnr_sgveto(trigs):
"""
Calculate newsnr re-weigthed by the sine-gaussian veto
Parameters
----------
trigs: dict of numpy.ndarrays, h5py group (or similar dict-like object)
Dictionary-like object holding single detector trigger information.
'chisq_dof', 'snr', 'sg_chisq' a... | [
"def",
"get_newsnr_sgveto",
"(",
"trigs",
")",
":",
"dof",
"=",
"2.",
"*",
"trigs",
"[",
"'chisq_dof'",
"]",
"[",
":",
"]",
"-",
"2.",
"nsnr_sg",
"=",
"newsnr_sgveto",
"(",
"trigs",
"[",
"'snr'",
"]",
"[",
":",
"]",
",",
"trigs",
"[",
"'chisq'",
"]... | Calculate newsnr re-weigthed by the sine-gaussian veto
Parameters
----------
trigs: dict of numpy.ndarrays, h5py group (or similar dict-like object)
Dictionary-like object holding single detector trigger information.
'chisq_dof', 'snr', 'sg_chisq' and 'chisq' are required keys
Returns
... | [
"Calculate",
"newsnr",
"re",
"-",
"weigthed",
"by",
"the",
"sine",
"-",
"gaussian",
"veto"
] | python | train |
OSSOS/MOP | src/ossos/core/ossos/storage.py | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/core/ossos/storage.py#L1020-L1066 | def get_hdu(uri, cutout=None):
"""Get a at the given uri from VOSpace, possibly doing a cutout.
If the cutout is flips the image then we also must flip the datasec keywords. Also, we must offset the
datasec to reflect the cutout area being used.
@param uri: The URI in VOSpace of the image to HDU to r... | [
"def",
"get_hdu",
"(",
"uri",
",",
"cutout",
"=",
"None",
")",
":",
"try",
":",
"# the filename is based on the Simple FITS images file.",
"filename",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"uri",
")",
"if",
"os",
".",
"access",
"(",
"filename",
",",
... | Get a at the given uri from VOSpace, possibly doing a cutout.
If the cutout is flips the image then we also must flip the datasec keywords. Also, we must offset the
datasec to reflect the cutout area being used.
@param uri: The URI in VOSpace of the image to HDU to retrieve.
@param cutout: A CADC dat... | [
"Get",
"a",
"at",
"the",
"given",
"uri",
"from",
"VOSpace",
"possibly",
"doing",
"a",
"cutout",
"."
] | python | train |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/brocade_threshold_monitor.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_threshold_monitor.py#L422-L433 | def threshold_monitor_hidden_threshold_monitor_Cpu_poll(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
threshold_monitor_hidden = ET.SubElement(config, "threshold-monitor-hidden", xmlns="urn:brocade.com:mgmt:brocade-threshold-monitor")
threshold_monitor... | [
"def",
"threshold_monitor_hidden_threshold_monitor_Cpu_poll",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"threshold_monitor_hidden",
"=",
"ET",
".",
"SubElement",
"(",
"config",
",",
"\"threshold-mo... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train |
bastikr/boolean.py | boolean/boolean.py | https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L1061-L1073 | def cancel(self):
"""
Cancel itself and following NOTs as far as possible.
Returns the simplified expression.
"""
expr = self
while True:
arg = expr.args[0]
if not isinstance(arg, self.__class__):
return expr
expr = arg.... | [
"def",
"cancel",
"(",
"self",
")",
":",
"expr",
"=",
"self",
"while",
"True",
":",
"arg",
"=",
"expr",
".",
"args",
"[",
"0",
"]",
"if",
"not",
"isinstance",
"(",
"arg",
",",
"self",
".",
"__class__",
")",
":",
"return",
"expr",
"expr",
"=",
"arg... | Cancel itself and following NOTs as far as possible.
Returns the simplified expression. | [
"Cancel",
"itself",
"and",
"following",
"NOTs",
"as",
"far",
"as",
"possible",
".",
"Returns",
"the",
"simplified",
"expression",
"."
] | python | train |
oasis-open/cti-taxii-client | taxii2client/__init__.py | https://github.com/oasis-open/cti-taxii-client/blob/b4c037fb61d8b8892af34423e2c67c81218d6f8e/taxii2client/__init__.py#L235-L239 | def refresh(self, accept=MEDIA_TYPE_TAXII_V20):
"""Updates Status information"""
response = self.__raw = self._conn.get(self.url,
headers={"Accept": accept})
self._populate_fields(**response) | [
"def",
"refresh",
"(",
"self",
",",
"accept",
"=",
"MEDIA_TYPE_TAXII_V20",
")",
":",
"response",
"=",
"self",
".",
"__raw",
"=",
"self",
".",
"_conn",
".",
"get",
"(",
"self",
".",
"url",
",",
"headers",
"=",
"{",
"\"Accept\"",
":",
"accept",
"}",
")... | Updates Status information | [
"Updates",
"Status",
"information"
] | python | valid |
airspeed-velocity/asv | asv/extern/asizeof.py | https://github.com/airspeed-velocity/asv/blob/d23bb8b74e8adacbfa3cf5724bda55fb39d56ba6/asv/extern/asizeof.py#L511-L527 | def _refs(obj, named, *ats, **kwds):
'''Return specific attribute objects of an object.
'''
if named:
for a in ats: # cf. inspect.getmembers()
if hasattr(obj, a):
yield _NamedRef(a, getattr(obj, a))
if kwds: # kwds are _dir2() args
for a, o in _dir2(... | [
"def",
"_refs",
"(",
"obj",
",",
"named",
",",
"*",
"ats",
",",
"*",
"*",
"kwds",
")",
":",
"if",
"named",
":",
"for",
"a",
"in",
"ats",
":",
"# cf. inspect.getmembers()",
"if",
"hasattr",
"(",
"obj",
",",
"a",
")",
":",
"yield",
"_NamedRef",
"(",
... | Return specific attribute objects of an object. | [
"Return",
"specific",
"attribute",
"objects",
"of",
"an",
"object",
"."
] | python | train |
bcbio/bcbio-nextgen | bcbio/structural/titancna.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/titancna.py#L86-L95 | def _run_select_solution(ploidy_outdirs, work_dir, data):
"""Select optimal
"""
out_file = os.path.join(work_dir, "optimalClusters.txt")
if not utils.file_exists(out_file):
with file_transaction(data, out_file) as tx_out_file:
ploidy_inputs = " ".join(["--ploidyRun%s=%s" % (p, d) for... | [
"def",
"_run_select_solution",
"(",
"ploidy_outdirs",
",",
"work_dir",
",",
"data",
")",
":",
"out_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"work_dir",
",",
"\"optimalClusters.txt\"",
")",
"if",
"not",
"utils",
".",
"file_exists",
"(",
"out_file",
")... | Select optimal | [
"Select",
"optimal"
] | python | train |
datahq/dataflows | setup.py | https://github.com/datahq/dataflows/blob/2c5e5e01e09c8b44e0ff36d85b3f2f4dcf4e8465/setup.py#L12-L17 | def read(*paths):
"""Read a text file."""
basedir = os.path.dirname(__file__)
fullpath = os.path.join(basedir, *paths)
contents = io.open(fullpath, encoding='utf-8').read().strip()
return contents | [
"def",
"read",
"(",
"*",
"paths",
")",
":",
"basedir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
"fullpath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"basedir",
",",
"*",
"paths",
")",
"contents",
"=",
"io",
".",
"open",
"(",... | Read a text file. | [
"Read",
"a",
"text",
"file",
"."
] | python | train |
letuananh/chirptext | chirptext/dekomecab.py | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/dekomecab.py#L57-L70 | def run_mecab_process(content, *args, **kwargs):
''' Use subprocess to run mecab '''
encoding = 'utf-8' if 'encoding' not in kwargs else kwargs['encoding']
mecab_loc = kwargs['mecab_loc'] if 'mecab_loc' in kwargs else None
if mecab_loc is None:
mecab_loc = MECAB_LOC
proc_args = [mecab_... | [
"def",
"run_mecab_process",
"(",
"content",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"encoding",
"=",
"'utf-8'",
"if",
"'encoding'",
"not",
"in",
"kwargs",
"else",
"kwargs",
"[",
"'encoding'",
"]",
"mecab_loc",
"=",
"kwargs",
"[",
"'mecab_loc'"... | Use subprocess to run mecab | [
"Use",
"subprocess",
"to",
"run",
"mecab"
] | python | train |
Dentosal/python-sc2 | sc2/unit.py | https://github.com/Dentosal/python-sc2/blob/608bd25f04e89d39cef68b40101d8e9a8a7f1634/sc2/unit.py#L204-L208 | def health_percentage(self) -> Union[int, float]:
""" Does not include shields """
if self._proto.health_max == 0:
return 0
return self._proto.health / self._proto.health_max | [
"def",
"health_percentage",
"(",
"self",
")",
"->",
"Union",
"[",
"int",
",",
"float",
"]",
":",
"if",
"self",
".",
"_proto",
".",
"health_max",
"==",
"0",
":",
"return",
"0",
"return",
"self",
".",
"_proto",
".",
"health",
"/",
"self",
".",
"_proto"... | Does not include shields | [
"Does",
"not",
"include",
"shields"
] | python | train |
saltstack/salt | salt/modules/nagios.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nagios.py#L131-L189 | def retcode_pillar(pillar_name):
'''
Run one or more nagios plugins from pillar data and get the result of cmd.retcode
The pillar have to be in this format::
------
webserver:
Ping_google:
- check_icmp: 8.8.8.8
- check_icmp: google.com
... | [
"def",
"retcode_pillar",
"(",
"pillar_name",
")",
":",
"groups",
"=",
"__salt__",
"[",
"'pillar.get'",
"]",
"(",
"pillar_name",
")",
"check",
"=",
"{",
"}",
"data",
"=",
"{",
"}",
"for",
"group",
"in",
"groups",
":",
"commands",
"=",
"groups",
"[",
"gr... | Run one or more nagios plugins from pillar data and get the result of cmd.retcode
The pillar have to be in this format::
------
webserver:
Ping_google:
- check_icmp: 8.8.8.8
- check_icmp: google.com
Load:
- check_load: -w 0.8 -... | [
"Run",
"one",
"or",
"more",
"nagios",
"plugins",
"from",
"pillar",
"data",
"and",
"get",
"the",
"result",
"of",
"cmd",
".",
"retcode",
"The",
"pillar",
"have",
"to",
"be",
"in",
"this",
"format",
"::"
] | python | train |
miyakogi/wdom | wdom/web_node.py | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/web_node.py#L168-L184 | def removeClass(self, *classes: str) -> None:
"""[Not Standard] Remove classes from this node."""
_remove_cl = []
for class_ in classes:
if class_ not in self.classList:
if class_ in self.get_class_list():
logger.warning(
't... | [
"def",
"removeClass",
"(",
"self",
",",
"*",
"classes",
":",
"str",
")",
"->",
"None",
":",
"_remove_cl",
"=",
"[",
"]",
"for",
"class_",
"in",
"classes",
":",
"if",
"class_",
"not",
"in",
"self",
".",
"classList",
":",
"if",
"class_",
"in",
"self",
... | [Not Standard] Remove classes from this node. | [
"[",
"Not",
"Standard",
"]",
"Remove",
"classes",
"from",
"this",
"node",
"."
] | python | train |
messagebird/python-rest-api | messagebird/client.py | https://github.com/messagebird/python-rest-api/blob/fb7864f178135f92d09af803bee93270e99f3963/messagebird/client.py#L126-L129 | def lookup(self, phonenumber, params=None):
"""Do a new lookup."""
if params is None: params = {}
return Lookup().load(self.request('lookup/' + str(phonenumber), 'GET', params)) | [
"def",
"lookup",
"(",
"self",
",",
"phonenumber",
",",
"params",
"=",
"None",
")",
":",
"if",
"params",
"is",
"None",
":",
"params",
"=",
"{",
"}",
"return",
"Lookup",
"(",
")",
".",
"load",
"(",
"self",
".",
"request",
"(",
"'lookup/'",
"+",
"str"... | Do a new lookup. | [
"Do",
"a",
"new",
"lookup",
"."
] | python | train |
prajwalkr/track-it | trackit/trackers.py | https://github.com/prajwalkr/track-it/blob/01a91dba8e7bc169976e0b13faacf7dd7330237b/trackit/trackers.py#L221-L234 | def wait_till_page_load(self,driver,max_wait_time):
'''
This method pauses execution until the page is loaded fully, including
data delayed by JavaScript
'''
sleepCount = max_wait_time # wait for a fixed max_wait_time only
# A page that's fully loaded has the word 'Current Status'
while self.trackin... | [
"def",
"wait_till_page_load",
"(",
"self",
",",
"driver",
",",
"max_wait_time",
")",
":",
"sleepCount",
"=",
"max_wait_time",
"# wait for a fixed max_wait_time only ",
"# A page that's fully loaded has the word 'Current Status'",
"while",
"self",
".",
"tracking_no",
"not",
"i... | This method pauses execution until the page is loaded fully, including
data delayed by JavaScript | [
"This",
"method",
"pauses",
"execution",
"until",
"the",
"page",
"is",
"loaded",
"fully",
"including",
"data",
"delayed",
"by",
"JavaScript"
] | python | train |
jay-johnson/spylunking | spylunking/wait_for_exit.py | https://github.com/jay-johnson/spylunking/blob/95cc86776f04ec5935cf04e291cf18798345d6cb/spylunking/wait_for_exit.py#L6-L70 | def wait_for_exit(
log,
debug=False):
"""wait_for_exit
Sleep to allow the thread to pick up final messages
before exiting and stopping the Splunk HTTP publisher.
You can decrease this delay (in seconds) by reducing
the splunk_sleep_interval or by exporting the env var:
export S... | [
"def",
"wait_for_exit",
"(",
"log",
",",
"debug",
"=",
"False",
")",
":",
"debug",
"=",
"SPLUNK_DEBUG",
"for",
"i",
"in",
"log",
".",
"root",
".",
"handlers",
":",
"handler_class_name",
"=",
"i",
".",
"__class__",
".",
"__name__",
".",
"lower",
"(",
")... | wait_for_exit
Sleep to allow the thread to pick up final messages
before exiting and stopping the Splunk HTTP publisher.
You can decrease this delay (in seconds) by reducing
the splunk_sleep_interval or by exporting the env var:
export SPLUNK_SLEEP_INTERVAL=0.5
If you set the timer to 0 then ... | [
"wait_for_exit"
] | python | train |
carpyncho/feets | feets/datasets/ogle3.py | https://github.com/carpyncho/feets/blob/53bdfb73b53845561914fc1f756e0c2377b9b76b/feets/datasets/ogle3.py#L155-L246 | def fetch_OGLE3(ogle3_id, data_home=None,
metadata=None, download_if_missing=True):
"""Retrieve a lighte curve from OGLE-3 database
Parameters
----------
ogle3_id : str
The id of the source (see: ``load_OGLE3_catalog()`` for
available sources.
data_home : optional, d... | [
"def",
"fetch_OGLE3",
"(",
"ogle3_id",
",",
"data_home",
"=",
"None",
",",
"metadata",
"=",
"None",
",",
"download_if_missing",
"=",
"True",
")",
":",
"# retrieve the data dir for ogle",
"store_path",
"=",
"_get_OGLE3_data_home",
"(",
"data_home",
")",
"# the data d... | Retrieve a lighte curve from OGLE-3 database
Parameters
----------
ogle3_id : str
The id of the source (see: ``load_OGLE3_catalog()`` for
available sources.
data_home : optional, default: None
Specify another download and cache folder for the datasets. By default
all fee... | [
"Retrieve",
"a",
"lighte",
"curve",
"from",
"OGLE",
"-",
"3",
"database"
] | python | train |
yyuu/botornado | boto/s3/bucket.py | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/s3/bucket.py#L208-L245 | def list(self, prefix='', delimiter='', marker='', headers=None):
"""
List key objects within a bucket. This returns an instance of an
BucketListResultSet that automatically handles all of the result
paging, etc. from S3. You just need to keep iterating until
there are no more ... | [
"def",
"list",
"(",
"self",
",",
"prefix",
"=",
"''",
",",
"delimiter",
"=",
"''",
",",
"marker",
"=",
"''",
",",
"headers",
"=",
"None",
")",
":",
"return",
"BucketListResultSet",
"(",
"self",
",",
"prefix",
",",
"delimiter",
",",
"marker",
",",
"he... | List key objects within a bucket. This returns an instance of an
BucketListResultSet that automatically handles all of the result
paging, etc. from S3. You just need to keep iterating until
there are no more results.
Called with no arguments, this will return an iterator objec... | [
"List",
"key",
"objects",
"within",
"a",
"bucket",
".",
"This",
"returns",
"an",
"instance",
"of",
"an",
"BucketListResultSet",
"that",
"automatically",
"handles",
"all",
"of",
"the",
"result",
"paging",
"etc",
".",
"from",
"S3",
".",
"You",
"just",
"need",
... | python | train |
dls-controls/pymalcolm | malcolm/core/notifier.py | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/notifier.py#L136-L170 | def notify_changes(self, changes):
# type: (List[List]) -> CallbackResponses
"""Set our data and notify anyone listening
Args:
changes (list): [[path, optional data]] where path is the path to
what has changed, and data is the unserialized object that has
... | [
"def",
"notify_changes",
"(",
"self",
",",
"changes",
")",
":",
"# type: (List[List]) -> CallbackResponses",
"ret",
"=",
"[",
"]",
"child_changes",
"=",
"{",
"}",
"for",
"change",
"in",
"changes",
":",
"# Add any changes that our children need to know about",
"self",
... | Set our data and notify anyone listening
Args:
changes (list): [[path, optional data]] where path is the path to
what has changed, and data is the unserialized object that has
changed
Returns:
list: [(callback, Response)] that need to be called | [
"Set",
"our",
"data",
"and",
"notify",
"anyone",
"listening"
] | python | train |
JukeboxPipeline/jukebox-core | src/jukeboxcore/gui/widgets/reftrackwidget.py | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/gui/widgets/reftrackwidget.py#L324-L333 | def get_taskfileinfo_selection(self, ):
"""Return a taskfileinfo that the user chose from the available options
:returns: the chosen taskfileinfo
:rtype: :class:`jukeboxcore.filesys.TaskFileInfo`
:raises: None
"""
sel = OptionSelector(self.reftrack)
sel.exec_()
... | [
"def",
"get_taskfileinfo_selection",
"(",
"self",
",",
")",
":",
"sel",
"=",
"OptionSelector",
"(",
"self",
".",
"reftrack",
")",
"sel",
".",
"exec_",
"(",
")",
"return",
"sel",
".",
"selected"
] | Return a taskfileinfo that the user chose from the available options
:returns: the chosen taskfileinfo
:rtype: :class:`jukeboxcore.filesys.TaskFileInfo`
:raises: None | [
"Return",
"a",
"taskfileinfo",
"that",
"the",
"user",
"chose",
"from",
"the",
"available",
"options"
] | python | train |
alphatwirl/alphatwirl | alphatwirl/concurrently/CommunicationChannel.py | https://github.com/alphatwirl/alphatwirl/blob/5138eeba6cd8a334ba52d6c2c022b33c61e3ba38/alphatwirl/concurrently/CommunicationChannel.py#L114-L120 | def begin(self):
"""begin
"""
if self.isopen: return
self.dropbox.open()
self.isopen = True | [
"def",
"begin",
"(",
"self",
")",
":",
"if",
"self",
".",
"isopen",
":",
"return",
"self",
".",
"dropbox",
".",
"open",
"(",
")",
"self",
".",
"isopen",
"=",
"True"
] | begin | [
"begin"
] | python | valid |
limodou/uliweb | uliweb/lib/werkzeug/serving.py | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/serving.py#L334-L341 | def generate_adhoc_ssl_context():
"""Generates an adhoc SSL context for the development server."""
from OpenSSL import SSL
cert, pkey = generate_adhoc_ssl_pair()
ctx = SSL.Context(SSL.SSLv23_METHOD)
ctx.use_privatekey(pkey)
ctx.use_certificate(cert)
return ctx | [
"def",
"generate_adhoc_ssl_context",
"(",
")",
":",
"from",
"OpenSSL",
"import",
"SSL",
"cert",
",",
"pkey",
"=",
"generate_adhoc_ssl_pair",
"(",
")",
"ctx",
"=",
"SSL",
".",
"Context",
"(",
"SSL",
".",
"SSLv23_METHOD",
")",
"ctx",
".",
"use_privatekey",
"("... | Generates an adhoc SSL context for the development server. | [
"Generates",
"an",
"adhoc",
"SSL",
"context",
"for",
"the",
"development",
"server",
"."
] | python | train |
gamechanger/mongothon | mongothon/model.py | https://github.com/gamechanger/mongothon/blob/5305bdae8e38d09bfe7881f1edc99ac0a2e6b96b/mongothon/model.py#L273-L276 | def class_method(cls, f):
"""Decorator which dynamically binds class methods to the model for later use."""
setattr(cls, f.__name__, classmethod(f))
return f | [
"def",
"class_method",
"(",
"cls",
",",
"f",
")",
":",
"setattr",
"(",
"cls",
",",
"f",
".",
"__name__",
",",
"classmethod",
"(",
"f",
")",
")",
"return",
"f"
] | Decorator which dynamically binds class methods to the model for later use. | [
"Decorator",
"which",
"dynamically",
"binds",
"class",
"methods",
"to",
"the",
"model",
"for",
"later",
"use",
"."
] | python | train |
mushkevych/scheduler | synergy/scheduler/state_machine_freerun.py | https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/scheduler/state_machine_freerun.py#L142-L147 | def _process_terminal_state(self, freerun_entry, uow, flow_request=None):
""" method that takes care of processing unit_of_work records in
STATE_PROCESSED, STATE_NOOP, STATE_INVALID, STATE_CANCELED states"""
msg = 'UOW for {0} found in state {1}.'.format(freerun_entry.schedulable_name, uow.s... | [
"def",
"_process_terminal_state",
"(",
"self",
",",
"freerun_entry",
",",
"uow",
",",
"flow_request",
"=",
"None",
")",
":",
"msg",
"=",
"'UOW for {0} found in state {1}.'",
".",
"format",
"(",
"freerun_entry",
".",
"schedulable_name",
",",
"uow",
".",
"state",
... | method that takes care of processing unit_of_work records in
STATE_PROCESSED, STATE_NOOP, STATE_INVALID, STATE_CANCELED states | [
"method",
"that",
"takes",
"care",
"of",
"processing",
"unit_of_work",
"records",
"in",
"STATE_PROCESSED",
"STATE_NOOP",
"STATE_INVALID",
"STATE_CANCELED",
"states"
] | python | train |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/brocade_xstp_ext.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_xstp_ext.py#L4027-L4039 | def get_stp_mst_detail_output_cist_migrate_time(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
get_stp_mst_detail = ET.Element("get_stp_mst_detail")
config = get_stp_mst_detail
output = ET.SubElement(get_stp_mst_detail, "output")
cist = ... | [
"def",
"get_stp_mst_detail_output_cist_migrate_time",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"get_stp_mst_detail",
"=",
"ET",
".",
"Element",
"(",
"\"get_stp_mst_detail\"",
")",
"config",
"=",... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train |
fp12/achallonge | challonge/participant.py | https://github.com/fp12/achallonge/blob/25780b3c48b66400a50ff9f884e4287afd4c89e4/challonge/participant.py#L135-L148 | async def undo_check_in(self):
""" Undo the check in for this participant
|methcoro|
Warning:
|unstable|
Raises:
APIException
"""
res = await self.connection('POST', 'tournaments/{}/participants/{}/undo_check_in'.format(self._tournament_id, sel... | [
"async",
"def",
"undo_check_in",
"(",
"self",
")",
":",
"res",
"=",
"await",
"self",
".",
"connection",
"(",
"'POST'",
",",
"'tournaments/{}/participants/{}/undo_check_in'",
".",
"format",
"(",
"self",
".",
"_tournament_id",
",",
"self",
".",
"_id",
")",
")",
... | Undo the check in for this participant
|methcoro|
Warning:
|unstable|
Raises:
APIException | [
"Undo",
"the",
"check",
"in",
"for",
"this",
"participant"
] | python | train |
jpscaletti/pyceo | pyceo/parser.py | https://github.com/jpscaletti/pyceo/blob/7f37eaf8e557d25f8e54634176139e0aad84b8df/pyceo/parser.py#L62-L69 | def is_key(sarg):
"""Check if `sarg` is a key (eg. -foo, --foo) or a negative number (eg. -33).
"""
if not sarg.startswith("-"):
return False
if sarg.startswith("--"):
return True
return not sarg.lstrip("-").isnumeric() | [
"def",
"is_key",
"(",
"sarg",
")",
":",
"if",
"not",
"sarg",
".",
"startswith",
"(",
"\"-\"",
")",
":",
"return",
"False",
"if",
"sarg",
".",
"startswith",
"(",
"\"--\"",
")",
":",
"return",
"True",
"return",
"not",
"sarg",
".",
"lstrip",
"(",
"\"-\"... | Check if `sarg` is a key (eg. -foo, --foo) or a negative number (eg. -33). | [
"Check",
"if",
"sarg",
"is",
"a",
"key",
"(",
"eg",
".",
"-",
"foo",
"--",
"foo",
")",
"or",
"a",
"negative",
"number",
"(",
"eg",
".",
"-",
"33",
")",
"."
] | python | train |
bububa/pyTOP | pyTOP/fenxiao.py | https://github.com/bububa/pyTOP/blob/1e48009bcfe886be392628244b370e6374e1f2b2/pyTOP/fenxiao.py#L52-L60 | def get(self, session, discount_id=None, ext_fields=None):
'''taobao.fenxiao.discounts.get 获取折扣信息
查询折扣信息'''
request = TOPRequest('taobao.fenxiao.discounts.get')
if discount_id!=None: request['discount_id'] = discount_id
if ext_fields!=None: request['ext_fields'] = ext_fi... | [
"def",
"get",
"(",
"self",
",",
"session",
",",
"discount_id",
"=",
"None",
",",
"ext_fields",
"=",
"None",
")",
":",
"request",
"=",
"TOPRequest",
"(",
"'taobao.fenxiao.discounts.get'",
")",
"if",
"discount_id",
"!=",
"None",
":",
"request",
"[",
"'discount... | taobao.fenxiao.discounts.get 获取折扣信息
查询折扣信息 | [
"taobao",
".",
"fenxiao",
".",
"discounts",
".",
"get",
"获取折扣信息",
"查询折扣信息"
] | python | train |
OnroerendErfgoed/oe_utils | oe_utils/range_parser.py | https://github.com/OnroerendErfgoed/oe_utils/blob/7b2014bda8ac6bb71b7138eaa06ac17ef3ff4a6d/oe_utils/range_parser.py#L101-L143 | def set_link_headers(self, request, total_count):
"""
Sets Link headers on the response.
When the Range header is present in the request no Link headers will
be added.
4 links will be added: first, prev, next, last.
If the current page is already the first page, the prev... | [
"def",
"set_link_headers",
"(",
"self",
",",
"request",
",",
"total_count",
")",
":",
"response",
"=",
"request",
".",
"response",
"if",
"request",
".",
"headers",
".",
"get",
"(",
"'Range'",
")",
":",
"# Don't set the Link headers when custom ranges were used.",
... | Sets Link headers on the response.
When the Range header is present in the request no Link headers will
be added.
4 links will be added: first, prev, next, last.
If the current page is already the first page, the prev link will
not be present.
If the current page is alre... | [
"Sets",
"Link",
"headers",
"on",
"the",
"response",
"."
] | python | train |
crate/crash | src/crate/crash/tabulate.py | https://github.com/crate/crash/blob/32d3ddc78fd2f7848ed2b99d9cd8889e322528d9/src/crate/crash/tabulate.py#L770-L1055 | def tabulate(tabular_data, headers=(), tablefmt="simple",
floatfmt="g", numalign="decimal", stralign="left",
missingval=""):
"""Format a fixed width table for pretty printing.
>>> print(tabulate([[1, 2.34], [-56, "8.999"], ["2", "10001"]]))
--- ---------
1 2.34
-56... | [
"def",
"tabulate",
"(",
"tabular_data",
",",
"headers",
"=",
"(",
")",
",",
"tablefmt",
"=",
"\"simple\"",
",",
"floatfmt",
"=",
"\"g\"",
",",
"numalign",
"=",
"\"decimal\"",
",",
"stralign",
"=",
"\"left\"",
",",
"missingval",
"=",
"\"\"",
")",
":",
"if... | Format a fixed width table for pretty printing.
>>> print(tabulate([[1, 2.34], [-56, "8.999"], ["2", "10001"]]))
--- ---------
1 2.34
-56 8.999
2 10001
--- ---------
The first required argument (`tabular_data`) can be a
list-of-lists (or another iterable of iterables),... | [
"Format",
"a",
"fixed",
"width",
"table",
"for",
"pretty",
"printing",
"."
] | python | train |
bblfsh/client-python | bblfsh/compat.py | https://github.com/bblfsh/client-python/blob/815835d191d5e385973f3c685849cc3b46aa20a5/bblfsh/compat.py#L270-L275 | def filter_nodes(n: Node, query: str) -> CompatNodeIterator:
"""
Utility function. Same as filter() but will only filter for nodes (i. e.
it will exclude scalars and positions).
"""
return CompatNodeIterator(filter(n, query)._nodeit, only_nodes=True) | [
"def",
"filter_nodes",
"(",
"n",
":",
"Node",
",",
"query",
":",
"str",
")",
"->",
"CompatNodeIterator",
":",
"return",
"CompatNodeIterator",
"(",
"filter",
"(",
"n",
",",
"query",
")",
".",
"_nodeit",
",",
"only_nodes",
"=",
"True",
")"
] | Utility function. Same as filter() but will only filter for nodes (i. e.
it will exclude scalars and positions). | [
"Utility",
"function",
".",
"Same",
"as",
"filter",
"()",
"but",
"will",
"only",
"filter",
"for",
"nodes",
"(",
"i",
".",
"e",
".",
"it",
"will",
"exclude",
"scalars",
"and",
"positions",
")",
"."
] | python | train |
data61/clkhash | clkhash/randomnames.py | https://github.com/data61/clkhash/blob/ec6398d6708a063de83f7c3d6286587bff8e7121/clkhash/randomnames.py#L106-L129 | def generate_random_person(self, n):
# type: (int) -> Iterable[Tuple[str, str, str, str]]
"""
Generator that yields details on a person with plausible name, sex and age.
:yields: Generated data for one person
tuple - (id: int, name: str('First Last'), birthdate: str('DD/MM/Y... | [
"def",
"generate_random_person",
"(",
"self",
",",
"n",
")",
":",
"# type: (int) -> Iterable[Tuple[str, str, str, str]]",
"assert",
"self",
".",
"all_male_first_names",
"is",
"not",
"None",
"assert",
"self",
".",
"all_female_first_names",
"is",
"not",
"None",
"assert",
... | Generator that yields details on a person with plausible name, sex and age.
:yields: Generated data for one person
tuple - (id: int, name: str('First Last'), birthdate: str('DD/MM/YYYY'), sex: str('M' | 'F') ) | [
"Generator",
"that",
"yields",
"details",
"on",
"a",
"person",
"with",
"plausible",
"name",
"sex",
"and",
"age",
"."
] | python | train |
HDI-Project/mit-d3m | mit_d3m/config.py | https://github.com/HDI-Project/mit-d3m/blob/3ab44eb5db8de8e28a29ca4b695a7a4becf45275/mit_d3m/config.py#L10-L60 | def build_config(dataset, datasets_dir, phase, problem=None, output_dir='data/output'):
"""
root@d3m-example-pod:/# cat /input/185_baseball/test_config.json
{
"problem_schema": "/input/TEST/problem_TEST/problemDoc.json",
"problem_root": "/input/TEST/problem_TEST",
"dataset_schema": "/input... | [
"def",
"build_config",
"(",
"dataset",
",",
"datasets_dir",
",",
"phase",
",",
"problem",
"=",
"None",
",",
"output_dir",
"=",
"'data/output'",
")",
":",
"if",
"problem",
":",
"full_phase",
"=",
"phase",
"+",
"'_'",
"+",
"problem",
"else",
":",
"full_phase... | root@d3m-example-pod:/# cat /input/185_baseball/test_config.json
{
"problem_schema": "/input/TEST/problem_TEST/problemDoc.json",
"problem_root": "/input/TEST/problem_TEST",
"dataset_schema": "/input/TEST/dataset_TEST/datasetDoc.json",
"test_data_root": "/input/TEST/dataset_TEST",
"resu... | [
"root@d3m",
"-",
"example",
"-",
"pod",
":",
"/",
"#",
"cat",
"/",
"input",
"/",
"185_baseball",
"/",
"test_config",
".",
"json",
"{",
"problem_schema",
":",
"/",
"input",
"/",
"TEST",
"/",
"problem_TEST",
"/",
"problemDoc",
".",
"json",
"problem_root",
... | python | train |
dnanexus/dx-toolkit | src/python/dxpy/api.py | https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/api.py#L1321-L1327 | def system_global_search(input_params={}, always_retry=True, **kwargs):
"""
Invokes the /system/globalSearch API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Search#API-method:-/system/globalSearch
"""
return DXHTTPRequest('/system/globalSearch', input_params, alwa... | [
"def",
"system_global_search",
"(",
"input_params",
"=",
"{",
"}",
",",
"always_retry",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"DXHTTPRequest",
"(",
"'/system/globalSearch'",
",",
"input_params",
",",
"always_retry",
"=",
"always_retry",
",",
... | Invokes the /system/globalSearch API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Search#API-method:-/system/globalSearch | [
"Invokes",
"the",
"/",
"system",
"/",
"globalSearch",
"API",
"method",
"."
] | python | train |
mjirik/imtools | imtools/sample_data.py | https://github.com/mjirik/imtools/blob/eb29fa59df0e0684d8334eb3bc5ef36ea46d1d3a/imtools/sample_data.py#L227-L253 | def get_conda_path():
"""
Return anaconda or miniconda directory
:return: anaconda directory
"""
dstdir = ''
# try:
import subprocess
import re
# cond info --root work only for root environment
# p = subprocess.Popen(['conda', 'info', '--root'], stdout=subprocess.PIPE, stderr=s... | [
"def",
"get_conda_path",
"(",
")",
":",
"dstdir",
"=",
"''",
"# try:",
"import",
"subprocess",
"import",
"re",
"# cond info --root work only for root environment",
"# p = subprocess.Popen(['conda', 'info', '--root'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)",
"p",
"=",
"sub... | Return anaconda or miniconda directory
:return: anaconda directory | [
"Return",
"anaconda",
"or",
"miniconda",
"directory",
":",
"return",
":",
"anaconda",
"directory"
] | python | train |
tbielawa/bitmath | bitmath/integrations.py | https://github.com/tbielawa/bitmath/blob/58ad3ac5f076cc6e53f36a91af055c6028c850a5/bitmath/integrations.py#L92-L104 | def update(self, pbar):
"""Updates the widget with the current NIST/SI speed.
Basically, this calculates the average rate of update and figures out
how to make a "pretty" prefix unit"""
if pbar.seconds_elapsed < 2e-6 or pbar.currval < 2e-6:
scaled = bitmath.Byte()
else:
... | [
"def",
"update",
"(",
"self",
",",
"pbar",
")",
":",
"if",
"pbar",
".",
"seconds_elapsed",
"<",
"2e-6",
"or",
"pbar",
".",
"currval",
"<",
"2e-6",
":",
"scaled",
"=",
"bitmath",
".",
"Byte",
"(",
")",
"else",
":",
"speed",
"=",
"pbar",
".",
"currva... | Updates the widget with the current NIST/SI speed.
Basically, this calculates the average rate of update and figures out
how to make a "pretty" prefix unit | [
"Updates",
"the",
"widget",
"with",
"the",
"current",
"NIST",
"/",
"SI",
"speed",
"."
] | python | train |
sentinel-hub/eo-learn | docs/source/conf.py | https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/docs/source/conf.py#L221-L249 | def process_readme():
""" Function which will process README.md file and divide it into INTRO.md and INSTALL.md, which will be used in
documentation
"""
with open('../../README.md', 'r') as file:
readme = file.read()
readme = readme.replace('# eo-learn', '# Introduction').replace('docs/sour... | [
"def",
"process_readme",
"(",
")",
":",
"with",
"open",
"(",
"'../../README.md'",
",",
"'r'",
")",
"as",
"file",
":",
"readme",
"=",
"file",
".",
"read",
"(",
")",
"readme",
"=",
"readme",
".",
"replace",
"(",
"'# eo-learn'",
",",
"'# Introduction'",
")"... | Function which will process README.md file and divide it into INTRO.md and INSTALL.md, which will be used in
documentation | [
"Function",
"which",
"will",
"process",
"README",
".",
"md",
"file",
"and",
"divide",
"it",
"into",
"INTRO",
".",
"md",
"and",
"INSTALL",
".",
"md",
"which",
"will",
"be",
"used",
"in",
"documentation"
] | python | train |
gwastro/pycbc | pycbc/inference/models/gaussian_noise.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/inference/models/gaussian_noise.py#L423-L443 | def det_optimal_snrsq(self, det):
"""Returns the opitmal SNR squared in the given detector.
Parameters
----------
det : str
The name of the detector.
Returns
-------
float :
The opimtal SNR squared.
"""
# try to get it fro... | [
"def",
"det_optimal_snrsq",
"(",
"self",
",",
"det",
")",
":",
"# try to get it from current stats",
"try",
":",
"return",
"getattr",
"(",
"self",
".",
"_current_stats",
",",
"'{}_optimal_snrsq'",
".",
"format",
"(",
"det",
")",
")",
"except",
"AttributeError",
... | Returns the opitmal SNR squared in the given detector.
Parameters
----------
det : str
The name of the detector.
Returns
-------
float :
The opimtal SNR squared. | [
"Returns",
"the",
"opitmal",
"SNR",
"squared",
"in",
"the",
"given",
"detector",
"."
] | python | train |
projectshift/shift-boiler | boiler/cli/user.py | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/cli/user.py#L19-L29 | def find_user(search_params):
"""
Find user
Attempts to find a user by a set of search params. You must be in
application context.
"""
user = None
params = {prop: value for prop, value in search_params.items() if value}
if 'id' in params or 'email' in params:
user = user_service.... | [
"def",
"find_user",
"(",
"search_params",
")",
":",
"user",
"=",
"None",
"params",
"=",
"{",
"prop",
":",
"value",
"for",
"prop",
",",
"value",
"in",
"search_params",
".",
"items",
"(",
")",
"if",
"value",
"}",
"if",
"'id'",
"in",
"params",
"or",
"'e... | Find user
Attempts to find a user by a set of search params. You must be in
application context. | [
"Find",
"user",
"Attempts",
"to",
"find",
"a",
"user",
"by",
"a",
"set",
"of",
"search",
"params",
".",
"You",
"must",
"be",
"in",
"application",
"context",
"."
] | python | train |
twisted/mantissa | xmantissa/smtp.py | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/smtp.py#L190-L207 | def parseAddress(address):
"""
Parse the given RFC 2821 email address into a structured object.
@type address: C{str}
@param address: The address to parse.
@rtype: L{Address}
@raise xmantissa.error.ArgumentError: The given string was not a valid RFC
2821 address.
"""
parts = []
... | [
"def",
"parseAddress",
"(",
"address",
")",
":",
"parts",
"=",
"[",
"]",
"parser",
"=",
"_AddressParser",
"(",
")",
"end",
"=",
"parser",
"(",
"parts",
",",
"address",
")",
"if",
"end",
"!=",
"len",
"(",
"address",
")",
":",
"raise",
"InvalidTrailingBy... | Parse the given RFC 2821 email address into a structured object.
@type address: C{str}
@param address: The address to parse.
@rtype: L{Address}
@raise xmantissa.error.ArgumentError: The given string was not a valid RFC
2821 address. | [
"Parse",
"the",
"given",
"RFC",
"2821",
"email",
"address",
"into",
"a",
"structured",
"object",
"."
] | python | train |
mdickinson/bigfloat | bigfloat/core.py | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L1560-L1570 | def log10(x, context=None):
"""
Return the base-ten logarithm of x.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_log10,
(BigFloat._implicit_convert(x),),
context,
) | [
"def",
"log10",
"(",
"x",
",",
"context",
"=",
"None",
")",
":",
"return",
"_apply_function_in_current_context",
"(",
"BigFloat",
",",
"mpfr",
".",
"mpfr_log10",
",",
"(",
"BigFloat",
".",
"_implicit_convert",
"(",
"x",
")",
",",
")",
",",
"context",
",",
... | Return the base-ten logarithm of x. | [
"Return",
"the",
"base",
"-",
"ten",
"logarithm",
"of",
"x",
"."
] | python | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L3271-L3289 | def store_zonefile_data( self, fetched_zfhash, zonefile_data, min_block_height, peer_hostport, con, path ):
"""
Store the fetched zonefile (as a serialized string) to storage and cache it locally.
Update internal state to mark it present
Return True on success
Return False on err... | [
"def",
"store_zonefile_data",
"(",
"self",
",",
"fetched_zfhash",
",",
"zonefile_data",
",",
"min_block_height",
",",
"peer_hostport",
",",
"con",
",",
"path",
")",
":",
"rc",
"=",
"add_atlas_zonefile_data",
"(",
"zonefile_data",
",",
"self",
".",
"zonefile_dir",
... | Store the fetched zonefile (as a serialized string) to storage and cache it locally.
Update internal state to mark it present
Return True on success
Return False on error | [
"Store",
"the",
"fetched",
"zonefile",
"(",
"as",
"a",
"serialized",
"string",
")",
"to",
"storage",
"and",
"cache",
"it",
"locally",
".",
"Update",
"internal",
"state",
"to",
"mark",
"it",
"present",
"Return",
"True",
"on",
"success",
"Return",
"False",
"... | python | train |
vallis/libstempo | libstempo/spharmORFbasis.py | https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/spharmORFbasis.py#L281-L297 | def real_rotated_Gammas(m,l,phi1,phi2,theta1,theta2,gamma_ml):
"""
This function returns the real-valued form of the Overlap Reduction Functions,
see Eqs 47 in Mingarelli et al, 2013.
"""
if m>0:
ans=(1./sqrt(2))*(rotated_Gamma_ml(m,l,phi1,phi2,theta1,theta2,gamma_ml) + \
... | [
"def",
"real_rotated_Gammas",
"(",
"m",
",",
"l",
",",
"phi1",
",",
"phi2",
",",
"theta1",
",",
"theta2",
",",
"gamma_ml",
")",
":",
"if",
"m",
">",
"0",
":",
"ans",
"=",
"(",
"1.",
"/",
"sqrt",
"(",
"2",
")",
")",
"*",
"(",
"rotated_Gamma_ml",
... | This function returns the real-valued form of the Overlap Reduction Functions,
see Eqs 47 in Mingarelli et al, 2013. | [
"This",
"function",
"returns",
"the",
"real",
"-",
"valued",
"form",
"of",
"the",
"Overlap",
"Reduction",
"Functions",
"see",
"Eqs",
"47",
"in",
"Mingarelli",
"et",
"al",
"2013",
"."
] | python | train |
CxAalto/gtfspy | gtfspy/filter.py | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/filter.py#L234-L267 | def _filter_by_calendar(self):
"""
update calendar table's services
:param copy_db_conn:
:param start_date:
:param end_date:
:return:
"""
if (self.start_date is not None) and (self.end_date is not None):
logging.info("Making date extract")
... | [
"def",
"_filter_by_calendar",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"start_date",
"is",
"not",
"None",
")",
"and",
"(",
"self",
".",
"end_date",
"is",
"not",
"None",
")",
":",
"logging",
".",
"info",
"(",
"\"Making date extract\"",
")",
"start_d... | update calendar table's services
:param copy_db_conn:
:param start_date:
:param end_date:
:return: | [
"update",
"calendar",
"table",
"s",
"services",
":",
"param",
"copy_db_conn",
":",
":",
"param",
"start_date",
":",
":",
"param",
"end_date",
":",
":",
"return",
":"
] | python | valid |
Loudr/asana-hub | asana_hub/json_data.py | https://github.com/Loudr/asana-hub/blob/af996ce890ed23d8ede5bf68dcd318e3438829cb/asana_hub/json_data.py#L68-L112 | def apply(self, key, value, prompt=None,
on_load=lambda a: a, on_save=lambda a: a):
"""Applies a setting value to a key, if the value is not `None`.
Returns without prompting if either of the following:
* `value` is not `None`
* already present in the dictionary
... | [
"def",
"apply",
"(",
"self",
",",
"key",
",",
"value",
",",
"prompt",
"=",
"None",
",",
"on_load",
"=",
"lambda",
"a",
":",
"a",
",",
"on_save",
"=",
"lambda",
"a",
":",
"a",
")",
":",
"# Reset value if flag exists without value",
"if",
"value",
"==",
... | Applies a setting value to a key, if the value is not `None`.
Returns without prompting if either of the following:
* `value` is not `None`
* already present in the dictionary
Args:
prompt:
May either be a string to prompt via `raw_input` or a
... | [
"Applies",
"a",
"setting",
"value",
"to",
"a",
"key",
"if",
"the",
"value",
"is",
"not",
"None",
"."
] | python | test |
RIPE-NCC/ripe-atlas-cousteau | ripe/atlas/cousteau/measurement.py | https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/measurement.py#L100-L132 | def v2_translator(self, option):
"""
This is a temporary function that helps move from v1 API to v2 without
breaking already running script and keep backwards compatibility.
Translates option name from API v1 to renamed one of v2 API.
"""
new_option = option
new_v... | [
"def",
"v2_translator",
"(",
"self",
",",
"option",
")",
":",
"new_option",
"=",
"option",
"new_value",
"=",
"getattr",
"(",
"self",
",",
"option",
")",
"renaming_pairs",
"=",
"{",
"\"dontfrag\"",
":",
"\"dont_fragment\"",
",",
"\"maxhops\"",
":",
"\"max_hops\... | This is a temporary function that helps move from v1 API to v2 without
breaking already running script and keep backwards compatibility.
Translates option name from API v1 to renamed one of v2 API. | [
"This",
"is",
"a",
"temporary",
"function",
"that",
"helps",
"move",
"from",
"v1",
"API",
"to",
"v2",
"without",
"breaking",
"already",
"running",
"script",
"and",
"keep",
"backwards",
"compatibility",
".",
"Translates",
"option",
"name",
"from",
"API",
"v1",
... | python | train |
fabioz/PyDev.Debugger | pydevd_attach_to_process/winappdbg/textio.py | https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/textio.py#L516-L532 | def printable(data):
"""
Replace unprintable characters with dots.
@type data: str
@param data: Binary data.
@rtype: str
@return: Printable text.
"""
result = ''
for c in data:
if 32 < ord(c) < 128:
result += c
... | [
"def",
"printable",
"(",
"data",
")",
":",
"result",
"=",
"''",
"for",
"c",
"in",
"data",
":",
"if",
"32",
"<",
"ord",
"(",
"c",
")",
"<",
"128",
":",
"result",
"+=",
"c",
"else",
":",
"result",
"+=",
"'.'",
"return",
"result"
] | Replace unprintable characters with dots.
@type data: str
@param data: Binary data.
@rtype: str
@return: Printable text. | [
"Replace",
"unprintable",
"characters",
"with",
"dots",
"."
] | python | train |
Jarn/jarn.viewdoc | jarn/viewdoc/viewdoc.py | https://github.com/Jarn/jarn.viewdoc/blob/59ae82fd1658889c41096c1d8c08dcb1047dc349/jarn/viewdoc/viewdoc.py#L314-L324 | def convert_string(self, rest):
"""Convert a reST string to an HTML string.
"""
try:
html = publish_string(rest, writer_name='html')
except SystemExit as e:
err_exit('HTML conversion failed with error: %s' % e.code)
else:
if sys.version_info[0]... | [
"def",
"convert_string",
"(",
"self",
",",
"rest",
")",
":",
"try",
":",
"html",
"=",
"publish_string",
"(",
"rest",
",",
"writer_name",
"=",
"'html'",
")",
"except",
"SystemExit",
"as",
"e",
":",
"err_exit",
"(",
"'HTML conversion failed with error: %s'",
"%"... | Convert a reST string to an HTML string. | [
"Convert",
"a",
"reST",
"string",
"to",
"an",
"HTML",
"string",
"."
] | python | train |
cdgriffith/Reusables | reusables/cli.py | https://github.com/cdgriffith/Reusables/blob/bc32f72e4baee7d76a6d58b88fcb23dd635155cd/reusables/cli.py#L29-L44 | def cmd(command, ignore_stderr=False, raise_on_return=False, timeout=None,
encoding="utf-8"):
""" Run a shell command and have it automatically decoded and printed
:param command: Command to run as str
:param ignore_stderr: To not print stderr
:param raise_on_return: Run CompletedProcess.check_... | [
"def",
"cmd",
"(",
"command",
",",
"ignore_stderr",
"=",
"False",
",",
"raise_on_return",
"=",
"False",
",",
"timeout",
"=",
"None",
",",
"encoding",
"=",
"\"utf-8\"",
")",
":",
"result",
"=",
"run",
"(",
"command",
",",
"timeout",
"=",
"timeout",
",",
... | Run a shell command and have it automatically decoded and printed
:param command: Command to run as str
:param ignore_stderr: To not print stderr
:param raise_on_return: Run CompletedProcess.check_returncode()
:param timeout: timeout to pass to communicate if python 3
:param encoding: How the outpu... | [
"Run",
"a",
"shell",
"command",
"and",
"have",
"it",
"automatically",
"decoded",
"and",
"printed"
] | python | train |
nugget/python-insteonplm | insteonplm/tools.py | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/tools.py#L792-L832 | async def do_del_aldb(self, args):
"""Delete device All-Link record.
WARNING THIS METHOD CAN DAMAGE YOUR DEVICE IF USED INCORRECTLY.
Please ensure the memory id is appropriate for the device.
You must load the ALDB of the device before using this method.
The memory id must be an... | [
"async",
"def",
"do_del_aldb",
"(",
"self",
",",
"args",
")",
":",
"params",
"=",
"args",
".",
"split",
"(",
")",
"addr",
"=",
"None",
"mem_bytes",
"=",
"None",
"memory",
"=",
"None",
"try",
":",
"addr",
"=",
"Address",
"(",
"params",
"[",
"0",
"]"... | Delete device All-Link record.
WARNING THIS METHOD CAN DAMAGE YOUR DEVICE IF USED INCORRECTLY.
Please ensure the memory id is appropriate for the device.
You must load the ALDB of the device before using this method.
The memory id must be an existing memory id in the ALDB or this
... | [
"Delete",
"device",
"All",
"-",
"Link",
"record",
"."
] | python | train |
toumorokoshi/sprinter | sprinter/environment.py | https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/environment.py#L433-L467 | def _finalize(self):
""" command to run at the end of sprinter's run """
self.logger.info("Finalizing...")
self.write_manifest()
if self.directory.rewrite_config:
# always ensure .rc is written (sourcing .env)
self.directory.add_to_rc('')
# prepend br... | [
"def",
"_finalize",
"(",
"self",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"\"Finalizing...\"",
")",
"self",
".",
"write_manifest",
"(",
")",
"if",
"self",
".",
"directory",
".",
"rewrite_config",
":",
"# always ensure .rc is written (sourcing .env)",
"... | command to run at the end of sprinter's run | [
"command",
"to",
"run",
"at",
"the",
"end",
"of",
"sprinter",
"s",
"run"
] | python | train |
summernote/django-summernote | django_summernote/utils.py | https://github.com/summernote/django-summernote/blob/bc7fbbf065d88a909fe3e1533c84110e0dd132bc/django_summernote/utils.py#L180-L199 | def get_attachment_model():
"""
Returns the Attachment model that is active in this project.
"""
try:
from .models import AbstractAttachment
klass = apps.get_model(config["attachment_model"])
if not issubclass(klass, AbstractAttachment):
raise ImproperlyConfigured(
... | [
"def",
"get_attachment_model",
"(",
")",
":",
"try",
":",
"from",
".",
"models",
"import",
"AbstractAttachment",
"klass",
"=",
"apps",
".",
"get_model",
"(",
"config",
"[",
"\"attachment_model\"",
"]",
")",
"if",
"not",
"issubclass",
"(",
"klass",
",",
"Abst... | Returns the Attachment model that is active in this project. | [
"Returns",
"the",
"Attachment",
"model",
"that",
"is",
"active",
"in",
"this",
"project",
"."
] | python | train |
CalebBell/fluids | fluids/nrlmsise00/nrlmsise_00.py | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/nrlmsise00/nrlmsise_00.py#L278-L303 | def splint(xa, ya, y2a, n, x, y):
'''
/* CALCULATE CUBIC SPLINE INTERP VALUE
* ADAPTED FROM NUMERICAL RECIPES BY PRESS ET AL.
* XA,YA: ARRAYS OF TABULATED FUNCTION IN ASCENDING ORDER BY X
* Y2A: ARRAY OF SECOND DERIVATIVES
* N: SIZE OF ARRAYS XA,YA,Y2A
* X: ABSCISSA FOR INTER... | [
"def",
"splint",
"(",
"xa",
",",
"ya",
",",
"y2a",
",",
"n",
",",
"x",
",",
"y",
")",
":",
"klo",
"=",
"0",
"khi",
"=",
"n",
"-",
"1",
"while",
"(",
"(",
"khi",
"-",
"klo",
")",
">",
"1",
")",
":",
"k",
"=",
"int",
"(",
"(",
"khi",
"+... | /* CALCULATE CUBIC SPLINE INTERP VALUE
* ADAPTED FROM NUMERICAL RECIPES BY PRESS ET AL.
* XA,YA: ARRAYS OF TABULATED FUNCTION IN ASCENDING ORDER BY X
* Y2A: ARRAY OF SECOND DERIVATIVES
* N: SIZE OF ARRAYS XA,YA,Y2A
* X: ABSCISSA FOR INTERPOLATION
* Y: OUTPUT VALUE
*/ | [
"/",
"*",
"CALCULATE",
"CUBIC",
"SPLINE",
"INTERP",
"VALUE",
"*",
"ADAPTED",
"FROM",
"NUMERICAL",
"RECIPES",
"BY",
"PRESS",
"ET",
"AL",
".",
"*",
"XA",
"YA",
":",
"ARRAYS",
"OF",
"TABULATED",
"FUNCTION",
"IN",
"ASCENDING",
"ORDER",
"BY",
"X",
"*",
"Y2A",... | python | train |
google/prettytensor | prettytensor/tutorial/data_utils.py | https://github.com/google/prettytensor/blob/75daa0b11252590f548da5647addc0ea610c4c45/prettytensor/tutorial/data_utils.py#L37-L46 | def maybe_download(url, filename):
"""Download the data from Yann's website, unless it's already here."""
if not os.path.exists(WORK_DIRECTORY):
os.mkdir(WORK_DIRECTORY)
filepath = os.path.join(WORK_DIRECTORY, filename)
if not os.path.exists(filepath):
filepath, _ = request.urlretrieve(url + filename, f... | [
"def",
"maybe_download",
"(",
"url",
",",
"filename",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"WORK_DIRECTORY",
")",
":",
"os",
".",
"mkdir",
"(",
"WORK_DIRECTORY",
")",
"filepath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"WOR... | Download the data from Yann's website, unless it's already here. | [
"Download",
"the",
"data",
"from",
"Yann",
"s",
"website",
"unless",
"it",
"s",
"already",
"here",
"."
] | python | train |
SeleniumHQ/selenium | py/selenium/webdriver/remote/webelement.py | https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/webelement.py#L674-L700 | def find_element(self, by=By.ID, value=None):
"""
Find an element given a By strategy and locator. Prefer the find_element_by_* methods when
possible.
:Usage:
::
element = element.find_element(By.ID, 'foo')
:rtype: WebElement
"""
if ... | [
"def",
"find_element",
"(",
"self",
",",
"by",
"=",
"By",
".",
"ID",
",",
"value",
"=",
"None",
")",
":",
"if",
"self",
".",
"_w3c",
":",
"if",
"by",
"==",
"By",
".",
"ID",
":",
"by",
"=",
"By",
".",
"CSS_SELECTOR",
"value",
"=",
"'[id=\"%s\"]'",... | Find an element given a By strategy and locator. Prefer the find_element_by_* methods when
possible.
:Usage:
::
element = element.find_element(By.ID, 'foo')
:rtype: WebElement | [
"Find",
"an",
"element",
"given",
"a",
"By",
"strategy",
"and",
"locator",
".",
"Prefer",
"the",
"find_element_by_",
"*",
"methods",
"when",
"possible",
"."
] | python | train |
openwisp/netjsonconfig | netjsonconfig/backends/openwrt/openwrt.py | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/openwrt/openwrt.py#L30-L49 | def _generate_contents(self, tar):
"""
Adds configuration files to tarfile instance.
:param tar: tarfile instance
:returns: None
"""
uci = self.render(files=False)
# create a list with all the packages (and remove empty entries)
packages = packages_patter... | [
"def",
"_generate_contents",
"(",
"self",
",",
"tar",
")",
":",
"uci",
"=",
"self",
".",
"render",
"(",
"files",
"=",
"False",
")",
"# create a list with all the packages (and remove empty entries)",
"packages",
"=",
"packages_pattern",
".",
"split",
"(",
"uci",
"... | Adds configuration files to tarfile instance.
:param tar: tarfile instance
:returns: None | [
"Adds",
"configuration",
"files",
"to",
"tarfile",
"instance",
"."
] | python | valid |
dmwm/DBS | Server/Python/src/dbs/business/DBSAcquisitionEra.py | https://github.com/dmwm/DBS/blob/9619bafce3783b3e77f0415f8f9a258e33dd1e6f/Server/Python/src/dbs/business/DBSAcquisitionEra.py#L57-L83 | def insertAcquisitionEra(self, businput):
"""
Input dictionary has to have the following keys:
acquisition_era_name, creation_date, create_by, start_date, end_date.
it builds the correct dictionary for dao input and executes the dao
"""
conn = self.dbi.connection()
... | [
"def",
"insertAcquisitionEra",
"(",
"self",
",",
"businput",
")",
":",
"conn",
"=",
"self",
".",
"dbi",
".",
"connection",
"(",
")",
"tran",
"=",
"conn",
".",
"begin",
"(",
")",
"try",
":",
"businput",
"[",
"\"acquisition_era_id\"",
"]",
"=",
"self",
"... | Input dictionary has to have the following keys:
acquisition_era_name, creation_date, create_by, start_date, end_date.
it builds the correct dictionary for dao input and executes the dao | [
"Input",
"dictionary",
"has",
"to",
"have",
"the",
"following",
"keys",
":",
"acquisition_era_name",
"creation_date",
"create_by",
"start_date",
"end_date",
".",
"it",
"builds",
"the",
"correct",
"dictionary",
"for",
"dao",
"input",
"and",
"executes",
"the",
"dao"... | python | train |
fastai/fastai | fastai/datasets.py | https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/datasets.py#L140-L142 | def get_key(cls, key):
"Get the path to `key` in the config file."
return cls.get().get(key, cls.DEFAULT_CONFIG.get(key,None)) | [
"def",
"get_key",
"(",
"cls",
",",
"key",
")",
":",
"return",
"cls",
".",
"get",
"(",
")",
".",
"get",
"(",
"key",
",",
"cls",
".",
"DEFAULT_CONFIG",
".",
"get",
"(",
"key",
",",
"None",
")",
")"
] | Get the path to `key` in the config file. | [
"Get",
"the",
"path",
"to",
"key",
"in",
"the",
"config",
"file",
"."
] | python | train |
nicolargo/glances | glances/outputs/glances_curses_browser.py | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses_browser.py#L134-L144 | def cursor_down(self, stats):
"""Set the cursor to position N-1 in the list."""
if self.cursor_position + 1 < self.get_pagelines(stats):
self.cursor_position += 1
else:
if self._current_page + 1 < self._page_max:
self._current_page += 1
... | [
"def",
"cursor_down",
"(",
"self",
",",
"stats",
")",
":",
"if",
"self",
".",
"cursor_position",
"+",
"1",
"<",
"self",
".",
"get_pagelines",
"(",
"stats",
")",
":",
"self",
".",
"cursor_position",
"+=",
"1",
"else",
":",
"if",
"self",
".",
"_current_p... | Set the cursor to position N-1 in the list. | [
"Set",
"the",
"cursor",
"to",
"position",
"N",
"-",
"1",
"in",
"the",
"list",
"."
] | python | train |
Azure/msrest-for-python | msrest/service_client.py | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/service_client.py#L302-L316 | def send_formdata(self, request, headers=None, content=None, **config):
"""Send data as a multipart form-data request.
We only deal with file-like objects or strings at this point.
The requests is not yet streamed.
This method is deprecated, and shouldn't be used anymore.
:para... | [
"def",
"send_formdata",
"(",
"self",
",",
"request",
",",
"headers",
"=",
"None",
",",
"content",
"=",
"None",
",",
"*",
"*",
"config",
")",
":",
"request",
".",
"headers",
"=",
"headers",
"request",
".",
"add_formdata",
"(",
"content",
")",
"return",
... | Send data as a multipart form-data request.
We only deal with file-like objects or strings at this point.
The requests is not yet streamed.
This method is deprecated, and shouldn't be used anymore.
:param ClientRequest request: The request object to be sent.
:param dict headers... | [
"Send",
"data",
"as",
"a",
"multipart",
"form",
"-",
"data",
"request",
".",
"We",
"only",
"deal",
"with",
"file",
"-",
"like",
"objects",
"or",
"strings",
"at",
"this",
"point",
".",
"The",
"requests",
"is",
"not",
"yet",
"streamed",
"."
] | python | train |
jamieleshaw/lurklib | lurklib/channel.py | https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/channel.py#L139-L174 | def cmode(self, channel, modes=''):
"""
Sets or gets the channel mode.
Required arguments:
* channel - Channel to set/get modes of.
Optional arguments:
* modes='' - Modes to set.
If not specified return the modes of the channel.
"""
with self.l... | [
"def",
"cmode",
"(",
"self",
",",
"channel",
",",
"modes",
"=",
"''",
")",
":",
"with",
"self",
".",
"lock",
":",
"self",
".",
"is_in_channel",
"(",
"channel",
")",
"if",
"not",
"modes",
":",
"self",
".",
"send",
"(",
"'MODE %s'",
"%",
"channel",
"... | Sets or gets the channel mode.
Required arguments:
* channel - Channel to set/get modes of.
Optional arguments:
* modes='' - Modes to set.
If not specified return the modes of the channel. | [
"Sets",
"or",
"gets",
"the",
"channel",
"mode",
".",
"Required",
"arguments",
":",
"*",
"channel",
"-",
"Channel",
"to",
"set",
"/",
"get",
"modes",
"of",
".",
"Optional",
"arguments",
":",
"*",
"modes",
"=",
"-",
"Modes",
"to",
"set",
".",
"If",
"no... | python | train |
rags/pynt-contrib | pyntcontrib/__init__.py | https://github.com/rags/pynt-contrib/blob/912315f2df9ea9b4b61abc923cad8807eed54cba/pyntcontrib/__init__.py#L11-L25 | def safe_cd(path):
"""
Changes to a directory, yields, and changes back.
Additionally any error will also change the directory back.
Usage:
>>> with safe_cd('some/repo'):
... call('git status')
"""
starting_directory = os.getcwd()
try:
os.chdir(path)
yield
fi... | [
"def",
"safe_cd",
"(",
"path",
")",
":",
"starting_directory",
"=",
"os",
".",
"getcwd",
"(",
")",
"try",
":",
"os",
".",
"chdir",
"(",
"path",
")",
"yield",
"finally",
":",
"os",
".",
"chdir",
"(",
"starting_directory",
")"
] | Changes to a directory, yields, and changes back.
Additionally any error will also change the directory back.
Usage:
>>> with safe_cd('some/repo'):
... call('git status') | [
"Changes",
"to",
"a",
"directory",
"yields",
"and",
"changes",
"back",
".",
"Additionally",
"any",
"error",
"will",
"also",
"change",
"the",
"directory",
"back",
"."
] | python | train |
facetoe/zenpy | zenpy/lib/api.py | https://github.com/facetoe/zenpy/blob/34c54c7e408b9ed01604ddf8b3422204c8bf31ea/zenpy/lib/api.py#L1459-L1467 | def count(self, view, include=None):
"""
Return a ViewCount for a view.
:param include: list of objects to sideload. `Side-loading API Docs
<https://developer.zendesk.com/rest_api/docs/core/side_loading>`__.
:param view: View or view id
"""
return self._get(... | [
"def",
"count",
"(",
"self",
",",
"view",
",",
"include",
"=",
"None",
")",
":",
"return",
"self",
".",
"_get",
"(",
"self",
".",
"_build_url",
"(",
"self",
".",
"endpoint",
".",
"count",
"(",
"id",
"=",
"view",
",",
"include",
"=",
"include",
")",... | Return a ViewCount for a view.
:param include: list of objects to sideload. `Side-loading API Docs
<https://developer.zendesk.com/rest_api/docs/core/side_loading>`__.
:param view: View or view id | [
"Return",
"a",
"ViewCount",
"for",
"a",
"view",
"."
] | python | train |
RI-imaging/qpsphere | qpsphere/imagefit/__init__.py | https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/imagefit/__init__.py#L4-L53 | def analyze(qpi, model, n0, r0, c0=None, imagekw={},
ret_center=False, ret_pha_offset=False, ret_qpi=False):
"""Fit refractive index and radius to a phase image of a sphere
Parameters
----------
qpi: QPImage
Quantitative phase image information
model: str
Name of the lig... | [
"def",
"analyze",
"(",
"qpi",
",",
"model",
",",
"n0",
",",
"r0",
",",
"c0",
"=",
"None",
",",
"imagekw",
"=",
"{",
"}",
",",
"ret_center",
"=",
"False",
",",
"ret_pha_offset",
"=",
"False",
",",
"ret_qpi",
"=",
"False",
")",
":",
"res",
"=",
"ma... | Fit refractive index and radius to a phase image of a sphere
Parameters
----------
qpi: QPImage
Quantitative phase image information
model: str
Name of the light-scattering model
(see :const:`qpsphere.models.available`)
n0: float
Approximate refractive index of the s... | [
"Fit",
"refractive",
"index",
"and",
"radius",
"to",
"a",
"phase",
"image",
"of",
"a",
"sphere"
] | python | train |
iotile/coretools | iotilesensorgraph/iotile/sg/node.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/node.py#L59-L73 | def format_trigger(self, stream):
"""Create a user understandable string like count(stream) >= X.
Args:
stream (DataStream): The stream to use to format ourselves.
Returns:
str: The formatted string
"""
src = u'value'
if self.use_count:
... | [
"def",
"format_trigger",
"(",
"self",
",",
"stream",
")",
":",
"src",
"=",
"u'value'",
"if",
"self",
".",
"use_count",
":",
"src",
"=",
"u'count'",
"return",
"u\"{}({}) {} {}\"",
".",
"format",
"(",
"src",
",",
"stream",
",",
"self",
".",
"comp_string",
... | Create a user understandable string like count(stream) >= X.
Args:
stream (DataStream): The stream to use to format ourselves.
Returns:
str: The formatted string | [
"Create",
"a",
"user",
"understandable",
"string",
"like",
"count",
"(",
"stream",
")",
">",
"=",
"X",
"."
] | python | train |
nickoala/telepot | telepot/__init__.py | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L945-L950 | def uploadStickerFile(self, user_id, png_sticker):
"""
See: https://core.telegram.org/bots/api#uploadstickerfile
"""
p = _strip(locals(), more=['png_sticker'])
return self._api_request_with_file('uploadStickerFile', _rectify(p), 'png_sticker', png_sticker) | [
"def",
"uploadStickerFile",
"(",
"self",
",",
"user_id",
",",
"png_sticker",
")",
":",
"p",
"=",
"_strip",
"(",
"locals",
"(",
")",
",",
"more",
"=",
"[",
"'png_sticker'",
"]",
")",
"return",
"self",
".",
"_api_request_with_file",
"(",
"'uploadStickerFile'",... | See: https://core.telegram.org/bots/api#uploadstickerfile | [
"See",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api#uploadstickerfile"
] | python | train |
JonathanRaiman/pytreebank | pytreebank/labeled_trees.py | https://github.com/JonathanRaiman/pytreebank/blob/7b4c671d3dff661cc3677e54db817e50c5a1c666/pytreebank/labeled_trees.py#L92-L101 | def lowercase(self):
"""
Lowercase all strings in this tree.
Works recursively and in-place.
"""
if len(self.children) > 0:
for child in self.children:
child.lowercase()
else:
self.text = self.text.lower() | [
"def",
"lowercase",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"children",
")",
">",
"0",
":",
"for",
"child",
"in",
"self",
".",
"children",
":",
"child",
".",
"lowercase",
"(",
")",
"else",
":",
"self",
".",
"text",
"=",
"self",
".",... | Lowercase all strings in this tree.
Works recursively and in-place. | [
"Lowercase",
"all",
"strings",
"in",
"this",
"tree",
".",
"Works",
"recursively",
"and",
"in",
"-",
"place",
"."
] | python | train |
weld-project/weld | python/numpy/weldnumpy/weldnumpy.py | https://github.com/weld-project/weld/blob/8ddd6db6b28878bef0892da44b1d2002b564389c/python/numpy/weldnumpy/weldnumpy.py#L55-L63 | def get_supported_unary_ops():
'''
Returns a dictionary of the Weld supported unary ops, with values being their Weld symbol.
'''
unary_ops = {}
unary_ops[np.exp.__name__] = 'exp'
unary_ops[np.log.__name__] = 'log'
unary_ops[np.sqrt.__name__] = 'sqrt'
return unary_ops | [
"def",
"get_supported_unary_ops",
"(",
")",
":",
"unary_ops",
"=",
"{",
"}",
"unary_ops",
"[",
"np",
".",
"exp",
".",
"__name__",
"]",
"=",
"'exp'",
"unary_ops",
"[",
"np",
".",
"log",
".",
"__name__",
"]",
"=",
"'log'",
"unary_ops",
"[",
"np",
".",
... | Returns a dictionary of the Weld supported unary ops, with values being their Weld symbol. | [
"Returns",
"a",
"dictionary",
"of",
"the",
"Weld",
"supported",
"unary",
"ops",
"with",
"values",
"being",
"their",
"Weld",
"symbol",
"."
] | python | train |
optimizely/python-sdk | optimizely/lib/pymmh3.py | https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/lib/pymmh3.py#L97-L403 | def hash128( key, seed = 0x0, x64arch = True ):
''' Implements 128bit murmur3 hash. '''
def hash128_x64( key, seed ):
''' Implements 128bit murmur3 hash for x64. '''
def fmix( k ):
k ^= k >> 33
k = ( k * 0xff51afd7ed558ccd ) & 0xFFFFFFFFFFFFFFFF
k ^= k >> 33... | [
"def",
"hash128",
"(",
"key",
",",
"seed",
"=",
"0x0",
",",
"x64arch",
"=",
"True",
")",
":",
"def",
"hash128_x64",
"(",
"key",
",",
"seed",
")",
":",
"''' Implements 128bit murmur3 hash for x64. '''",
"def",
"fmix",
"(",
"k",
")",
":",
"k",
"^=",
"k",
... | Implements 128bit murmur3 hash. | [
"Implements",
"128bit",
"murmur3",
"hash",
"."
] | python | train |
andrewsnowden/dota2py | dota2py/summary.py | https://github.com/andrewsnowden/dota2py/blob/67637f4b9c160ea90c11b7e81545baf350affa7a/dota2py/summary.py#L268-L273 | def parse_say_text(self, event):
"""
All chat
"""
if event.chat and event.format == "DOTA_Chat_All":
self.chatlog.append((event.prefix, event.text)) | [
"def",
"parse_say_text",
"(",
"self",
",",
"event",
")",
":",
"if",
"event",
".",
"chat",
"and",
"event",
".",
"format",
"==",
"\"DOTA_Chat_All\"",
":",
"self",
".",
"chatlog",
".",
"append",
"(",
"(",
"event",
".",
"prefix",
",",
"event",
".",
"text",... | All chat | [
"All",
"chat"
] | python | train |
nerdvegas/rez | src/rez/resolver.py | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/resolver.py#L158-L302 | def _get_cached_solve(self):
"""Find a memcached resolve.
If there is NOT a resolve timestamp:
- fetch a non-timestamped memcache entry;
- if no entry, then fail;
- if packages have changed, then:
- delete the entry;
- fail;
-... | [
"def",
"_get_cached_solve",
"(",
"self",
")",
":",
"if",
"not",
"(",
"self",
".",
"caching",
"and",
"self",
".",
"memcached_servers",
")",
":",
"return",
"None",
"# these caches avoids some potentially repeated file stats",
"variant_states",
"=",
"{",
"}",
"last_rel... | Find a memcached resolve.
If there is NOT a resolve timestamp:
- fetch a non-timestamped memcache entry;
- if no entry, then fail;
- if packages have changed, then:
- delete the entry;
- fail;
- if no packages in the entry have been r... | [
"Find",
"a",
"memcached",
"resolve",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.