repo stringlengths 7 55 | path stringlengths 4 223 | url stringlengths 87 315 | code stringlengths 75 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values | avg_line_len float64 7.91 980 |
|---|---|---|---|---|---|---|---|---|---|
log2timeline/plaso | plaso/cli/helpers/viper_analysis.py | https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/cli/helpers/viper_analysis.py#L70-L104 | def ParseOptions(cls, options, analysis_plugin):
"""Parses and validates options.
Args:
options (argparse.Namespace): parser options.
analysis_plugin (ViperAnalysisPlugin): analysis plugin to configure.
Raises:
BadConfigObject: when the output module object is of the wrong type.
Ba... | [
"def",
"ParseOptions",
"(",
"cls",
",",
"options",
",",
"analysis_plugin",
")",
":",
"if",
"not",
"isinstance",
"(",
"analysis_plugin",
",",
"viper",
".",
"ViperAnalysisPlugin",
")",
":",
"raise",
"errors",
".",
"BadConfigObject",
"(",
"'Analysis plugin is not an ... | Parses and validates options.
Args:
options (argparse.Namespace): parser options.
analysis_plugin (ViperAnalysisPlugin): analysis plugin to configure.
Raises:
BadConfigObject: when the output module object is of the wrong type.
BadConfigOption: when unable to connect to Viper instance. | [
"Parses",
"and",
"validates",
"options",
"."
] | python | train | 36.971429 |
liftoff/pyminifier | pyminifier/__main__.py | https://github.com/liftoff/pyminifier/blob/087ea7b0c8c964f1f907c3f350f5ce281798db86/pyminifier/__main__.py#L17-L171 | def main():
"""
Sets up our command line options, prints the usage/help (if warranted), and
runs :py:func:`pyminifier.pyminify` with the given command line options.
"""
usage = '%prog [options] "<input file>"'
if '__main__.py' in sys.argv[0]: # python -m pyminifier
usage = 'pyminifier [o... | [
"def",
"main",
"(",
")",
":",
"usage",
"=",
"'%prog [options] \"<input file>\"'",
"if",
"'__main__.py'",
"in",
"sys",
".",
"argv",
"[",
"0",
"]",
":",
"# python -m pyminifier",
"usage",
"=",
"'pyminifier [options] \"<input file>\"'",
"parser",
"=",
"OptionParser",
"... | Sets up our command line options, prints the usage/help (if warranted), and
runs :py:func:`pyminifier.pyminify` with the given command line options. | [
"Sets",
"up",
"our",
"command",
"line",
"options",
"prints",
"the",
"usage",
"/",
"help",
"(",
"if",
"warranted",
")",
"and",
"runs",
":",
"py",
":",
"func",
":",
"pyminifier",
".",
"pyminify",
"with",
"the",
"given",
"command",
"line",
"options",
"."
] | python | train | 30.877419 |
payu-org/payu | payu/laboratory.py | https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/laboratory.py#L51-L69 | def get_default_lab_path(self, config):
"""Generate a default laboratory path based on user environment."""
# Default path settings
# Append project name if present (NCI-specific)
default_project = os.environ.get('PROJECT', '')
default_short_path = os.path.join('/short', default... | [
"def",
"get_default_lab_path",
"(",
"self",
",",
"config",
")",
":",
"# Default path settings",
"# Append project name if present (NCI-specific)",
"default_project",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'PROJECT'",
",",
"''",
")",
"default_short_path",
"=",
"o... | Generate a default laboratory path based on user environment. | [
"Generate",
"a",
"default",
"laboratory",
"path",
"based",
"on",
"user",
"environment",
"."
] | python | train | 38.368421 |
majerteam/sqla_inspect | sqla_inspect/base.py | https://github.com/majerteam/sqla_inspect/blob/67edb5541e6a56b0a657d3774d1e19c1110cd402/sqla_inspect/base.py#L102-L108 | def add_formatter(self, sqla_col_type, formatter, key_specific=None):
"""
Add a formatter to the registry
if key_specific is provided, this formatter will only be used for some
specific exports
"""
self.add_item(sqla_col_type, formatter, key_specific) | [
"def",
"add_formatter",
"(",
"self",
",",
"sqla_col_type",
",",
"formatter",
",",
"key_specific",
"=",
"None",
")",
":",
"self",
".",
"add_item",
"(",
"sqla_col_type",
",",
"formatter",
",",
"key_specific",
")"
] | Add a formatter to the registry
if key_specific is provided, this formatter will only be used for some
specific exports | [
"Add",
"a",
"formatter",
"to",
"the",
"registry",
"if",
"key_specific",
"is",
"provided",
"this",
"formatter",
"will",
"only",
"be",
"used",
"for",
"some",
"specific",
"exports"
] | python | train | 41.857143 |
dtmilano/AndroidViewClient | src/com/dtmilano/android/viewclient.py | https://github.com/dtmilano/AndroidViewClient/blob/7e6e83fde63af99e5e4ab959712ecf94f9881aa2/src/com/dtmilano/android/viewclient.py#L4245-L4323 | def __levenshteinDistance(s, t):
'''
Find the Levenshtein distance between two Strings.
Python version of Levenshtein distance method implemented in Java at
U{http://www.java2s.com/Code/Java/Data-Type/FindtheLevenshteindistancebetweentwoStrings.htm}.
This is the number of chang... | [
"def",
"__levenshteinDistance",
"(",
"s",
",",
"t",
")",
":",
"if",
"s",
"is",
"None",
"or",
"t",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Strings must not be null\"",
")",
"n",
"=",
"len",
"(",
"s",
")",
"m",
"=",
"len",
"(",
"t",
")",
"i... | Find the Levenshtein distance between two Strings.
Python version of Levenshtein distance method implemented in Java at
U{http://www.java2s.com/Code/Java/Data-Type/FindtheLevenshteindistancebetweentwoStrings.htm}.
This is the number of changes needed to change one String into
another, ... | [
"Find",
"the",
"Levenshtein",
"distance",
"between",
"two",
"Strings",
"."
] | python | train | 36.974684 |
python-openxml/python-docx | docx/opc/pkgwriter.py | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/pkgwriter.py#L87-L98 | def from_parts(cls, parts):
"""
Return content types XML mapping each part in *parts* to the
appropriate content type and suitable for storage as
``[Content_Types].xml`` in an OPC package.
"""
cti = cls()
cti._defaults['rels'] = CT.OPC_RELATIONSHIPS
cti._d... | [
"def",
"from_parts",
"(",
"cls",
",",
"parts",
")",
":",
"cti",
"=",
"cls",
"(",
")",
"cti",
".",
"_defaults",
"[",
"'rels'",
"]",
"=",
"CT",
".",
"OPC_RELATIONSHIPS",
"cti",
".",
"_defaults",
"[",
"'xml'",
"]",
"=",
"CT",
".",
"XML",
"for",
"part"... | Return content types XML mapping each part in *parts* to the
appropriate content type and suitable for storage as
``[Content_Types].xml`` in an OPC package. | [
"Return",
"content",
"types",
"XML",
"mapping",
"each",
"part",
"in",
"*",
"parts",
"*",
"to",
"the",
"appropriate",
"content",
"type",
"and",
"suitable",
"for",
"storage",
"as",
"[",
"Content_Types",
"]",
".",
"xml",
"in",
"an",
"OPC",
"package",
"."
] | python | train | 37.166667 |
michael-lazar/rtv | rtv/theme.py | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/theme.py#L293-L322 | def list_themes(cls, path=THEMES):
"""
Compile all of the themes configuration files in the search path.
"""
themes, errors = [], OrderedDict()
def load_themes(path, source):
"""
Load all themes in the given path.
"""
if os.path.is... | [
"def",
"list_themes",
"(",
"cls",
",",
"path",
"=",
"THEMES",
")",
":",
"themes",
",",
"errors",
"=",
"[",
"]",
",",
"OrderedDict",
"(",
")",
"def",
"load_themes",
"(",
"path",
",",
"source",
")",
":",
"\"\"\"\n Load all themes in the given path.\n ... | Compile all of the themes configuration files in the search path. | [
"Compile",
"all",
"of",
"the",
"themes",
"configuration",
"files",
"in",
"the",
"search",
"path",
"."
] | python | train | 34.833333 |
un33k/django-toolware | toolware/utils/query.py | https://github.com/un33k/django-toolware/blob/973f3e003dc38b812897dab88455bee37dcaf931/toolware/utils/query.py#L208-L217 | def get_date_less_query(days, date_field):
"""
Query for if date_field is within number of "days" from now.
"""
query = None
days = get_integer(days)
if days:
future = get_days_from_now(days)
query = Q(**{"%s__lte" % date_field: future.isoformat()})
return query | [
"def",
"get_date_less_query",
"(",
"days",
",",
"date_field",
")",
":",
"query",
"=",
"None",
"days",
"=",
"get_integer",
"(",
"days",
")",
"if",
"days",
":",
"future",
"=",
"get_days_from_now",
"(",
"days",
")",
"query",
"=",
"Q",
"(",
"*",
"*",
"{",
... | Query for if date_field is within number of "days" from now. | [
"Query",
"for",
"if",
"date_field",
"is",
"within",
"number",
"of",
"days",
"from",
"now",
"."
] | python | test | 29.7 |
pallets/werkzeug | src/werkzeug/wrappers/base_request.py | https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/wrappers/base_request.py#L294-L327 | def _load_form_data(self):
"""Method used internally to retrieve submitted data. After calling
this sets `form` and `files` on the request object to multi dicts
filled with the incoming form data. As a matter of fact the input
stream will be empty afterwards. You can also call this me... | [
"def",
"_load_form_data",
"(",
"self",
")",
":",
"# abort early if we have already consumed the stream",
"if",
"\"form\"",
"in",
"self",
".",
"__dict__",
":",
"return",
"_assert_not_shallow",
"(",
"self",
")",
"if",
"self",
".",
"want_form_data_parsed",
":",
"content_... | Method used internally to retrieve submitted data. After calling
this sets `form` and `files` on the request object to multi dicts
filled with the incoming form data. As a matter of fact the input
stream will be empty afterwards. You can also call this method to
force the parsing of t... | [
"Method",
"used",
"internally",
"to",
"retrieve",
"submitted",
"data",
".",
"After",
"calling",
"this",
"sets",
"form",
"and",
"files",
"on",
"the",
"request",
"object",
"to",
"multi",
"dicts",
"filled",
"with",
"the",
"incoming",
"form",
"data",
".",
"As",
... | python | train | 38.676471 |
PmagPy/PmagPy | dialogs/pmag_gui_menu2.py | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/dialogs/pmag_gui_menu2.py#L168-L172 | def on_import1(self, event):
"""
initialize window to import an arbitrary file into the working directory
"""
pmag_menu_dialogs.MoveFileIntoWD(self.parent, self.parent.WD) | [
"def",
"on_import1",
"(",
"self",
",",
"event",
")",
":",
"pmag_menu_dialogs",
".",
"MoveFileIntoWD",
"(",
"self",
".",
"parent",
",",
"self",
".",
"parent",
".",
"WD",
")"
] | initialize window to import an arbitrary file into the working directory | [
"initialize",
"window",
"to",
"import",
"an",
"arbitrary",
"file",
"into",
"the",
"working",
"directory"
] | python | train | 39.8 |
mdickinson/bigfloat | bigfloat/core.py | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L1690-L1713 | def acos(x, context=None):
"""
Return the inverse cosine of ``x``.
The mathematically exact result lies in the range [0, π]. However, note
that as a result of rounding to the current context, it's possible for the
actual value returned to be fractionally larger than π::
>>> from bigfloat ... | [
"def",
"acos",
"(",
"x",
",",
"context",
"=",
"None",
")",
":",
"return",
"_apply_function_in_current_context",
"(",
"BigFloat",
",",
"mpfr",
".",
"mpfr_acos",
",",
"(",
"BigFloat",
".",
"_implicit_convert",
"(",
"x",
")",
",",
")",
",",
"context",
",",
... | Return the inverse cosine of ``x``.
The mathematically exact result lies in the range [0, π]. However, note
that as a result of rounding to the current context, it's possible for the
actual value returned to be fractionally larger than π::
>>> from bigfloat import precision
>>> with preci... | [
"Return",
"the",
"inverse",
"cosine",
"of",
"x",
"."
] | python | train | 26.041667 |
RedHatInsights/insights-core | insights/client/mount.py | https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/client/mount.py#L274-L286 | def mount(self, identifier):
"""
Mounts a container or image referred to by identifier to
the host filesystem.
"""
driver = self.client.info()['Driver']
driver_mount_fn = getattr(self, "_mount_" + driver,
self._unsupported_backend)
... | [
"def",
"mount",
"(",
"self",
",",
"identifier",
")",
":",
"driver",
"=",
"self",
".",
"client",
".",
"info",
"(",
")",
"[",
"'Driver'",
"]",
"driver_mount_fn",
"=",
"getattr",
"(",
"self",
",",
"\"_mount_\"",
"+",
"driver",
",",
"self",
".",
"_unsuppor... | Mounts a container or image referred to by identifier to
the host filesystem. | [
"Mounts",
"a",
"container",
"or",
"image",
"referred",
"to",
"by",
"identifier",
"to",
"the",
"host",
"filesystem",
"."
] | python | train | 34.307692 |
inveniosoftware/invenio-search | invenio_search/cli.py | https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/cli.py#L184-L194 | def put(index_name, doc_type, identifier, body, force, verbose):
"""Index input data."""
result = current_search_client.index(
index=index_name,
doc_type=doc_type or index_name,
id=identifier,
body=json.load(body),
op_type='index' if force or identifier is None else 'crea... | [
"def",
"put",
"(",
"index_name",
",",
"doc_type",
",",
"identifier",
",",
"body",
",",
"force",
",",
"verbose",
")",
":",
"result",
"=",
"current_search_client",
".",
"index",
"(",
"index",
"=",
"index_name",
",",
"doc_type",
"=",
"doc_type",
"or",
"index_... | Index input data. | [
"Index",
"input",
"data",
"."
] | python | train | 34.090909 |
dj-stripe/dj-stripe | djstripe/utils.py | https://github.com/dj-stripe/dj-stripe/blob/a5308a3808cd6e2baba49482f7a699f3a8992518/djstripe/utils.py#L106-L119 | def convert_tstamp(response):
"""
Convert a Stripe API timestamp response (unix epoch) to a native datetime.
:rtype: datetime
"""
if response is None:
# Allow passing None to convert_tstamp()
return response
# Overrides the set timezone to UTC - I think...
tz = timezone.utc if settings.USE_TZ else None
r... | [
"def",
"convert_tstamp",
"(",
"response",
")",
":",
"if",
"response",
"is",
"None",
":",
"# Allow passing None to convert_tstamp()",
"return",
"response",
"# Overrides the set timezone to UTC - I think...",
"tz",
"=",
"timezone",
".",
"utc",
"if",
"settings",
".",
"USE_... | Convert a Stripe API timestamp response (unix epoch) to a native datetime.
:rtype: datetime | [
"Convert",
"a",
"Stripe",
"API",
"timestamp",
"response",
"(",
"unix",
"epoch",
")",
"to",
"a",
"native",
"datetime",
"."
] | python | train | 25.571429 |
openego/eTraGo | etrago/tools/io.py | https://github.com/openego/eTraGo/blob/2a8fc6d4368d0e9abe6fe0d0c39baf66ea0126b9/etrago/tools/io.py#L831-L853 | def distance(x0, x1, y0, y1):
"""
Function that calculates the square of the distance between two points.
Parameters
-----
x0: x - coordinate of point 0
x1: x - coordinate of point 1
y0: y - coordinate of point 0
y1: y - coordinate of point 1
Returns
-----... | [
"def",
"distance",
"(",
"x0",
",",
"x1",
",",
"y0",
",",
"y1",
")",
":",
"# Calculate square of the distance between two points (Pythagoras)",
"distance",
"=",
"(",
"x1",
".",
"values",
"-",
"x0",
".",
"values",
")",
"*",
"(",
"x1",
".",
"values",
"-",
"x0... | Function that calculates the square of the distance between two points.
Parameters
-----
x0: x - coordinate of point 0
x1: x - coordinate of point 1
y0: y - coordinate of point 0
y1: y - coordinate of point 1
Returns
------
distance : float
square ... | [
"Function",
"that",
"calculates",
"the",
"square",
"of",
"the",
"distance",
"between",
"two",
"points",
"."
] | python | train | 25.347826 |
mlperf/training | translation/tensorflow/transformer/data_download.py | https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/data_download.py#L86-L96 | def find_file(path, filename, max_depth=5):
"""Returns full filepath if the file is in path or a subdirectory."""
for root, dirs, files in os.walk(path):
if filename in files:
return os.path.join(root, filename)
# Don't search past max_depth
depth = root[len(path) + 1:].count(os.sep)
if depth... | [
"def",
"find_file",
"(",
"path",
",",
"filename",
",",
"max_depth",
"=",
"5",
")",
":",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"path",
")",
":",
"if",
"filename",
"in",
"files",
":",
"return",
"os",
".",
"path",
"... | Returns full filepath if the file is in path or a subdirectory. | [
"Returns",
"full",
"filepath",
"if",
"the",
"file",
"is",
"in",
"path",
"or",
"a",
"subdirectory",
"."
] | python | train | 33.545455 |
pyokagan/pyglreg | glreg.py | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L380-L394 | def get_removes(self, profile=None):
"""Get filtered list of Remove objects in this Feature
:param str profile: Return Remove objects with this profile or None
to return all Remove objects.
:return: list of Remove objects
"""
out = []
for rem ... | [
"def",
"get_removes",
"(",
"self",
",",
"profile",
"=",
"None",
")",
":",
"out",
"=",
"[",
"]",
"for",
"rem",
"in",
"self",
".",
"removes",
":",
"# Filter Remove by profile",
"if",
"(",
"(",
"rem",
".",
"profile",
"and",
"not",
"profile",
")",
"or",
... | Get filtered list of Remove objects in this Feature
:param str profile: Return Remove objects with this profile or None
to return all Remove objects.
:return: list of Remove objects | [
"Get",
"filtered",
"list",
"of",
"Remove",
"objects",
"in",
"this",
"Feature"
] | python | train | 36.8 |
LEMS/pylems | lems/sim/sim.py | https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/sim/sim.py#L37-L49 | def add_runnable(self, runnable):
"""
Adds a runnable component to the list of runnable components in
this simulation.
@param runnable: A runnable component
@type runnable: lems.sim.runnable.Runnable
"""
if runnable.id in self.runnables:
raise SimErr... | [
"def",
"add_runnable",
"(",
"self",
",",
"runnable",
")",
":",
"if",
"runnable",
".",
"id",
"in",
"self",
".",
"runnables",
":",
"raise",
"SimError",
"(",
"'Duplicate runnable component {0}'",
".",
"format",
"(",
"runnable",
".",
"id",
")",
")",
"self",
".... | Adds a runnable component to the list of runnable components in
this simulation.
@param runnable: A runnable component
@type runnable: lems.sim.runnable.Runnable | [
"Adds",
"a",
"runnable",
"component",
"to",
"the",
"list",
"of",
"runnable",
"components",
"in",
"this",
"simulation",
"."
] | python | train | 31.846154 |
theislab/scanpy | scanpy/readwrite.py | https://github.com/theislab/scanpy/blob/9e4e5ee02e04cf618872d9b098e24f0542e8b227/scanpy/readwrite.py#L402-L417 | def get_params_from_list(params_list):
"""Transform params list to dictionary.
"""
params = {}
for i in range(0, len(params_list)):
if '=' not in params_list[i]:
try:
if not isinstance(params[key], list): params[key] = [params[key]]
params[key] += [par... | [
"def",
"get_params_from_list",
"(",
"params_list",
")",
":",
"params",
"=",
"{",
"}",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"params_list",
")",
")",
":",
"if",
"'='",
"not",
"in",
"params_list",
"[",
"i",
"]",
":",
"try",
":",
"if",... | Transform params list to dictionary. | [
"Transform",
"params",
"list",
"to",
"dictionary",
"."
] | python | train | 36.875 |
saltstack/salt | salt/cache/redis_cache.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cache/redis_cache.py#L313-L330 | def _get_banks_to_remove(redis_server, bank, path=''):
'''
A simple tree tarversal algorithm that builds the list of banks to remove,
starting from an arbitrary node in the tree.
'''
current_path = bank if not path else '{path}/{bank}'.format(path=path, bank=bank)
bank_paths_to_remove = [current... | [
"def",
"_get_banks_to_remove",
"(",
"redis_server",
",",
"bank",
",",
"path",
"=",
"''",
")",
":",
"current_path",
"=",
"bank",
"if",
"not",
"path",
"else",
"'{path}/{bank}'",
".",
"format",
"(",
"path",
"=",
"path",
",",
"bank",
"=",
"bank",
")",
"bank_... | A simple tree tarversal algorithm that builds the list of banks to remove,
starting from an arbitrary node in the tree. | [
"A",
"simple",
"tree",
"tarversal",
"algorithm",
"that",
"builds",
"the",
"list",
"of",
"banks",
"to",
"remove",
"starting",
"from",
"an",
"arbitrary",
"node",
"in",
"the",
"tree",
"."
] | python | train | 46.722222 |
ask/carrot | carrot/backends/librabbitmq.py | https://github.com/ask/carrot/blob/5889a25cd2e274642071c9bba39772f4b3e3d9da/carrot/backends/librabbitmq.py#L187-L191 | def cancel(self, consumer_tag):
"""Cancel a channel by consumer tag."""
if not self.channel.conn:
return
self.channel.basic_cancel(consumer_tag) | [
"def",
"cancel",
"(",
"self",
",",
"consumer_tag",
")",
":",
"if",
"not",
"self",
".",
"channel",
".",
"conn",
":",
"return",
"self",
".",
"channel",
".",
"basic_cancel",
"(",
"consumer_tag",
")"
] | Cancel a channel by consumer tag. | [
"Cancel",
"a",
"channel",
"by",
"consumer",
"tag",
"."
] | python | train | 35.2 |
sci-bots/mpm | mpm/api.py | https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/api.py#L464-L539 | def update(*args, **kwargs):
'''
Update installed plugin package(s).
Each plugin package must have a directory (**NOT** a link) containing a
``properties.yml`` file with a ``package_name`` value in the following
directory:
<conda prefix>/share/microdrop/plugins/available/
Parameters
... | [
"def",
"update",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"package_name",
"=",
"kwargs",
".",
"pop",
"(",
"'package_name'",
",",
"None",
")",
"# Only consider **installed** plugins (see `installed_plugins()` docstring).",
"installed_plugins_",
"=",
"instal... | Update installed plugin package(s).
Each plugin package must have a directory (**NOT** a link) containing a
``properties.yml`` file with a ``package_name`` value in the following
directory:
<conda prefix>/share/microdrop/plugins/available/
Parameters
----------
*args
Extra arg... | [
"Update",
"installed",
"plugin",
"package",
"(",
"s",
")",
"."
] | python | train | 32.381579 |
saltstack/salt | salt/modules/vsphere.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/vsphere.py#L280-L297 | def supports_proxies(*proxy_types):
'''
Decorator to specify which proxy types are supported by a function
proxy_types:
Arbitrary list of strings with the supported types of proxies
'''
def _supports_proxies(fn):
@wraps(fn)
def __supports_proxies(*args, **kwargs):
... | [
"def",
"supports_proxies",
"(",
"*",
"proxy_types",
")",
":",
"def",
"_supports_proxies",
"(",
"fn",
")",
":",
"@",
"wraps",
"(",
"fn",
")",
"def",
"__supports_proxies",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"proxy_type",
"=",
"get_proxy_t... | Decorator to specify which proxy types are supported by a function
proxy_types:
Arbitrary list of strings with the supported types of proxies | [
"Decorator",
"to",
"specify",
"which",
"proxy",
"types",
"are",
"supported",
"by",
"a",
"function"
] | python | train | 38 |
gusutabopb/aioinflux | aioinflux/serialization/__init__.py | https://github.com/gusutabopb/aioinflux/blob/2e4b7b3e13604e7618c686d89a0673f0bc70b24e/aioinflux/serialization/__init__.py#L9-L24 | def serialize(data, measurement=None, tag_columns=None, **extra_tags):
"""Converts input data into line protocol format"""
if isinstance(data, bytes):
return data
elif isinstance(data, str):
return data.encode('utf-8')
elif hasattr(data, 'to_lineprotocol'):
return data.to_linepro... | [
"def",
"serialize",
"(",
"data",
",",
"measurement",
"=",
"None",
",",
"tag_columns",
"=",
"None",
",",
"*",
"*",
"extra_tags",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"bytes",
")",
":",
"return",
"data",
"elif",
"isinstance",
"(",
"data",
",",... | Converts input data into line protocol format | [
"Converts",
"input",
"data",
"into",
"line",
"protocol",
"format"
] | python | train | 46.375 |
pyQode/pyqode.core | pyqode/core/widgets/interactive.py | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/interactive.py#L440-L465 | def apply_color_scheme(self, color_scheme):
"""
Apply a pygments color scheme to the console.
As there is not a 1 to 1 mapping between color scheme formats and
console formats, we decided to make the following mapping (it usually
looks good for most of the available pygments sty... | [
"def",
"apply_color_scheme",
"(",
"self",
",",
"color_scheme",
")",
":",
"self",
".",
"stdout_color",
"=",
"color_scheme",
".",
"formats",
"[",
"'normal'",
"]",
".",
"foreground",
"(",
")",
".",
"color",
"(",
")",
"self",
".",
"stdin_color",
"=",
"color_sc... | Apply a pygments color scheme to the console.
As there is not a 1 to 1 mapping between color scheme formats and
console formats, we decided to make the following mapping (it usually
looks good for most of the available pygments styles):
- stdout_color = normal color
- s... | [
"Apply",
"a",
"pygments",
"color",
"scheme",
"to",
"the",
"console",
"."
] | python | train | 41.807692 |
hugapi/hug | hug/decorators.py | https://github.com/hugapi/hug/blob/080901c81576657f82e2432fd4a82f1d0d2f370c/hug/decorators.py#L41-L57 | def default_output_format(content_type='application/json', apply_globally=False, api=None, cli=False, http=True):
"""A decorator that allows you to override the default output format for an API"""
def decorator(formatter):
formatter = hug.output_format.content_type(content_type)(formatter)
if ap... | [
"def",
"default_output_format",
"(",
"content_type",
"=",
"'application/json'",
",",
"apply_globally",
"=",
"False",
",",
"api",
"=",
"None",
",",
"cli",
"=",
"False",
",",
"http",
"=",
"True",
")",
":",
"def",
"decorator",
"(",
"formatter",
")",
":",
"for... | A decorator that allows you to override the default output format for an API | [
"A",
"decorator",
"that",
"allows",
"you",
"to",
"override",
"the",
"default",
"output",
"format",
"for",
"an",
"API"
] | python | train | 45.588235 |
caioariede/docker-run-build | docker_rb/utils.py | https://github.com/caioariede/docker-run-build/blob/76ca4802018a63d6778374ebdba082d6750816b2/docker_rb/utils.py#L31-L47 | def restore_image_options(cli, image, options):
""" Restores CMD and ENTRYPOINT values of the image
This is needed because we force the overwrite of ENTRYPOINT and CMD in the
`run_code_in_container` function, to be able to run the code in the
container, through /bin/bash.
"""
dockerfile = io.St... | [
"def",
"restore_image_options",
"(",
"cli",
",",
"image",
",",
"options",
")",
":",
"dockerfile",
"=",
"io",
".",
"StringIO",
"(",
")",
"dockerfile",
".",
"write",
"(",
"u'FROM {image}\\nCMD {cmd}'",
".",
"format",
"(",
"image",
"=",
"image",
",",
"cmd",
"... | Restores CMD and ENTRYPOINT values of the image
This is needed because we force the overwrite of ENTRYPOINT and CMD in the
`run_code_in_container` function, to be able to run the code in the
container, through /bin/bash. | [
"Restores",
"CMD",
"and",
"ENTRYPOINT",
"values",
"of",
"the",
"image"
] | python | train | 35.235294 |
peterbrittain/asciimatics | asciimatics/widgets.py | https://github.com/peterbrittain/asciimatics/blob/f471427d7786ce2d5f1eeb2dae0e67d19e46e085/asciimatics/widgets.py#L134-L158 | def _enforce_width(text, width, unicode_aware=True):
"""
Enforce a displayed piece of text to be a certain number of cells wide. This takes into
account double-width characters used in CJK languages.
:param text: The text to be truncated
:param width: The screen cell width to enforce
:return: ... | [
"def",
"_enforce_width",
"(",
"text",
",",
"width",
",",
"unicode_aware",
"=",
"True",
")",
":",
"# Double-width strings cannot be more than twice the string length, so no need to try",
"# expensive truncation if this upper bound isn't an issue.",
"if",
"2",
"*",
"len",
"(",
"t... | Enforce a displayed piece of text to be a certain number of cells wide. This takes into
account double-width characters used in CJK languages.
:param text: The text to be truncated
:param width: The screen cell width to enforce
:return: The resulting truncated text | [
"Enforce",
"a",
"displayed",
"piece",
"of",
"text",
"to",
"be",
"a",
"certain",
"number",
"of",
"cells",
"wide",
".",
"This",
"takes",
"into",
"account",
"double",
"-",
"width",
"characters",
"used",
"in",
"CJK",
"languages",
"."
] | python | train | 36.32 |
the01/python-paps | examples/measure/server.py | https://github.com/the01/python-paps/blob/2dde5a71913e4c7b22901cf05c6ecedd890919c4/examples/measure/server.py#L136-L155 | def create(host, port):
"""
Prepare server to execute
:return: Modules to execute, cmd line function
:rtype: list[WrapperServer], callable | None
"""
wrapper = WrapperServer({
'server': None
})
d = {
'listen_port': port,
'changer': wrapper
}
if host:
... | [
"def",
"create",
"(",
"host",
",",
"port",
")",
":",
"wrapper",
"=",
"WrapperServer",
"(",
"{",
"'server'",
":",
"None",
"}",
")",
"d",
"=",
"{",
"'listen_port'",
":",
"port",
",",
"'changer'",
":",
"wrapper",
"}",
"if",
"host",
":",
"d",
"[",
"'li... | Prepare server to execute
:return: Modules to execute, cmd line function
:rtype: list[WrapperServer], callable | None | [
"Prepare",
"server",
"to",
"execute"
] | python | train | 20.75 |
CellProfiler/centrosome | centrosome/bg_compensate.py | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/bg_compensate.py#L134-L141 | def gauss(x,m_y,sigma):
'''returns the gaussian with mean m_y and std. dev. sigma,
calculated at the points of x.'''
e_y = [np.exp((1.0/(2*float(sigma)**2)*-(n-m_y)**2)) for n in np.array(x)]
y = [1.0/(float(sigma) * np.sqrt(2 * np.pi)) * e for e in e_y]
return np.array(y) | [
"def",
"gauss",
"(",
"x",
",",
"m_y",
",",
"sigma",
")",
":",
"e_y",
"=",
"[",
"np",
".",
"exp",
"(",
"(",
"1.0",
"/",
"(",
"2",
"*",
"float",
"(",
"sigma",
")",
"**",
"2",
")",
"*",
"-",
"(",
"n",
"-",
"m_y",
")",
"**",
"2",
")",
")",
... | returns the gaussian with mean m_y and std. dev. sigma,
calculated at the points of x. | [
"returns",
"the",
"gaussian",
"with",
"mean",
"m_y",
"and",
"std",
".",
"dev",
".",
"sigma",
"calculated",
"at",
"the",
"points",
"of",
"x",
"."
] | python | train | 36 |
fred49/linshare-api | linshareapi/user/threadentries.py | https://github.com/fred49/linshare-api/blob/be646c25aa8ba3718abb6869c620b157d53d6e41/linshareapi/user/threadentries.py#L321-L333 | def update(self, data):
""" Update meta of one document."""
self.debug(data)
self._check(data)
wg_uuid = data.get('workGroup')
self.log.debug("wg_uuid : %s ", wg_uuid)
uuid = data.get('uuid')
url = "%(base)s/%(wg_uuid)s/nodes/%(uuid)s" % {
'base': self... | [
"def",
"update",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"debug",
"(",
"data",
")",
"self",
".",
"_check",
"(",
"data",
")",
"wg_uuid",
"=",
"data",
".",
"get",
"(",
"'workGroup'",
")",
"self",
".",
"log",
".",
"debug",
"(",
"\"wg_uuid : %... | Update meta of one document. | [
"Update",
"meta",
"of",
"one",
"document",
"."
] | python | train | 33.384615 |
aarongarrett/inspyred | inspyred/ec/evaluators.py | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/evaluators.py#L45-L77 | def evaluator(evaluate):
"""Return an inspyred evaluator function based on the given function.
This function generator takes a function that evaluates only one
candidate. The generator handles the iteration over each candidate
to be evaluated.
The given function ``evaluate`` must have the fol... | [
"def",
"evaluator",
"(",
"evaluate",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"evaluate",
")",
"def",
"inspyred_evaluator",
"(",
"candidates",
",",
"args",
")",
":",
"fitness",
"=",
"[",
"]",
"for",
"candidate",
"in",
"candidates",
":",
"fitness",
... | Return an inspyred evaluator function based on the given function.
This function generator takes a function that evaluates only one
candidate. The generator handles the iteration over each candidate
to be evaluated.
The given function ``evaluate`` must have the following signature::
... | [
"Return",
"an",
"inspyred",
"evaluator",
"function",
"based",
"on",
"the",
"given",
"function",
".",
"This",
"function",
"generator",
"takes",
"a",
"function",
"that",
"evaluates",
"only",
"one",
"candidate",
".",
"The",
"generator",
"handles",
"the",
"iteration... | python | train | 34.090909 |
NerdWalletOSS/savage | src/savage/utils.py | https://github.com/NerdWalletOSS/savage/blob/54f64ac1c912528710365107952967d31d56e60d/src/savage/utils.py#L93-L99 | def get_column_keys_and_names(table):
"""
Return a generator of tuples k, c such that k is the name of the python attribute for
the column and c is the name of the column in the sql table.
"""
ins = inspect(table)
return ((k, c.name) for k, c in ins.mapper.c.items()) | [
"def",
"get_column_keys_and_names",
"(",
"table",
")",
":",
"ins",
"=",
"inspect",
"(",
"table",
")",
"return",
"(",
"(",
"k",
",",
"c",
".",
"name",
")",
"for",
"k",
",",
"c",
"in",
"ins",
".",
"mapper",
".",
"c",
".",
"items",
"(",
")",
")"
] | Return a generator of tuples k, c such that k is the name of the python attribute for
the column and c is the name of the column in the sql table. | [
"Return",
"a",
"generator",
"of",
"tuples",
"k",
"c",
"such",
"that",
"k",
"is",
"the",
"name",
"of",
"the",
"python",
"attribute",
"for",
"the",
"column",
"and",
"c",
"is",
"the",
"name",
"of",
"the",
"column",
"in",
"the",
"sql",
"table",
"."
] | python | train | 40.714286 |
panosl/django-currencies | currencies/management/commands/_openexchangerates.py | https://github.com/panosl/django-currencies/blob/8d4c6c202ad7c4cc06263ab2c1b1f969bbe99acd/currencies/management/commands/_openexchangerates.py#L80-L86 | def get_ratetimestamp(self, base, code):
"""Return rate timestamp as a datetime/date or None"""
self.get_latestcurrencyrates(base)
try:
return datetime.fromtimestamp(self.rates["timestamp"])
except KeyError:
return None | [
"def",
"get_ratetimestamp",
"(",
"self",
",",
"base",
",",
"code",
")",
":",
"self",
".",
"get_latestcurrencyrates",
"(",
"base",
")",
"try",
":",
"return",
"datetime",
".",
"fromtimestamp",
"(",
"self",
".",
"rates",
"[",
"\"timestamp\"",
"]",
")",
"excep... | Return rate timestamp as a datetime/date or None | [
"Return",
"rate",
"timestamp",
"as",
"a",
"datetime",
"/",
"date",
"or",
"None"
] | python | train | 38.428571 |
batiste/django-page-cms | pages/admin/views.py | https://github.com/batiste/django-page-cms/blob/3c72111eb7c3997a63c462c1776ffd8ce8c50a5d/pages/admin/views.py#L36-L48 | def list_pages_ajax(request, invalid_move=False):
"""Render pages table for ajax function."""
language = get_language_from_request(request)
pages = Page.objects.root()
context = {
'can_publish': request.user.has_perm('pages.can_publish'),
'invalid_move': invalid_move,
'language':... | [
"def",
"list_pages_ajax",
"(",
"request",
",",
"invalid_move",
"=",
"False",
")",
":",
"language",
"=",
"get_language_from_request",
"(",
"request",
")",
"pages",
"=",
"Page",
".",
"objects",
".",
"root",
"(",
")",
"context",
"=",
"{",
"'can_publish'",
":",
... | Render pages table for ajax function. | [
"Render",
"pages",
"table",
"for",
"ajax",
"function",
"."
] | python | train | 34.153846 |
Erotemic/utool | utool/util_time.py | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_time.py#L42-L58 | def toc(tt, return_msg=False, write_msg=True, verbose=None):
"""
similar to matlab toc
SeeAlso:
ut.tic
"""
if verbose is not None:
write_msg = verbose
(msg, start_time) = tt
ellapsed = (default_timer() - start_time)
if (not return_msg) and write_msg and msg is not None:
... | [
"def",
"toc",
"(",
"tt",
",",
"return_msg",
"=",
"False",
",",
"write_msg",
"=",
"True",
",",
"verbose",
"=",
"None",
")",
":",
"if",
"verbose",
"is",
"not",
"None",
":",
"write_msg",
"=",
"verbose",
"(",
"msg",
",",
"start_time",
")",
"=",
"tt",
"... | similar to matlab toc
SeeAlso:
ut.tic | [
"similar",
"to",
"matlab",
"toc"
] | python | train | 27.058824 |
INM-6/hybridLFPy | examples/Hagen_et_al_2016_cercor/plotting_helpers.py | https://github.com/INM-6/hybridLFPy/blob/c38bdf38982c4624c2f70caeb50c40f1d5980abd/examples/Hagen_et_al_2016_cercor/plotting_helpers.py#L49-L55 | def add_to_bar_plot(ax, x, number, name = '', color = '0.'):
''' This function takes an axes and adds one bar to it '''
plt.sca(ax)
plt.setp(ax,xticks=np.append(ax.get_xticks(),np.array([x]))\
,xticklabels=[item.get_text() for item in ax.get_xticklabels()] +[name])
plt.bar([x],number , colo... | [
"def",
"add_to_bar_plot",
"(",
"ax",
",",
"x",
",",
"number",
",",
"name",
"=",
"''",
",",
"color",
"=",
"'0.'",
")",
":",
"plt",
".",
"sca",
"(",
"ax",
")",
"plt",
".",
"setp",
"(",
"ax",
",",
"xticks",
"=",
"np",
".",
"append",
"(",
"ax",
"... | This function takes an axes and adds one bar to it | [
"This",
"function",
"takes",
"an",
"axes",
"and",
"adds",
"one",
"bar",
"to",
"it"
] | python | train | 50 |
mitodl/PyLmod | pylmod/gradebook.py | https://github.com/mitodl/PyLmod/blob/b798b86c33d1eb615e7cd4f3457b5c15da1d86e0/pylmod/gradebook.py#L611-L681 | def get_sections(self, gradebook_id='', simple=False):
"""Get the sections for a gradebook.
Return a dictionary of types of sections containing a list of that
type for a given gradebook. Specified by a gradebookid.
If simple=True, a list of dictionaries is provided for each
se... | [
"def",
"get_sections",
"(",
"self",
",",
"gradebook_id",
"=",
"''",
",",
"simple",
"=",
"False",
")",
":",
"params",
"=",
"dict",
"(",
"includeMembers",
"=",
"'false'",
")",
"section_data",
"=",
"self",
".",
"get",
"(",
"'sections/{gradebookId}'",
".",
"fo... | Get the sections for a gradebook.
Return a dictionary of types of sections containing a list of that
type for a given gradebook. Specified by a gradebookid.
If simple=True, a list of dictionaries is provided for each
section regardless of type. The dictionary only contains one
... | [
"Get",
"the",
"sections",
"for",
"a",
"gradebook",
"."
] | python | train | 36.084507 |
Bachmann1234/diff-cover | diff_cover/report_generator.py | https://github.com/Bachmann1234/diff-cover/blob/901cb3fc986982961785e841658085ead453c6c9/diff_cover/report_generator.py#L86-L105 | def percent_covered(self, src_path):
"""
Return a float percent of lines covered for the source
in `src_path`.
If we have no coverage information for `src_path`, returns None
"""
diff_violations = self._diff_violations().get(src_path)
if diff_violations is None:... | [
"def",
"percent_covered",
"(",
"self",
",",
"src_path",
")",
":",
"diff_violations",
"=",
"self",
".",
"_diff_violations",
"(",
")",
".",
"get",
"(",
"src_path",
")",
"if",
"diff_violations",
"is",
"None",
":",
"return",
"None",
"# Protect against a divide by ze... | Return a float percent of lines covered for the source
in `src_path`.
If we have no coverage information for `src_path`, returns None | [
"Return",
"a",
"float",
"percent",
"of",
"lines",
"covered",
"for",
"the",
"source",
"in",
"src_path",
"."
] | python | train | 30.9 |
project-generator/project_generator | project_generator/tools/iar.py | https://github.com/project-generator/project_generator/blob/a361be16eeb5a8829ff5cd26850ddd4b264296fe/project_generator/tools/iar.py#L361-L507 | def _export_single_project(self):
""" A single project export """
expanded_dic = self.workspace.copy()
self._fix_paths(expanded_dic)
# generic tool template specified or project
if expanded_dic['template']:
template_ewp = False
template_ewd = False
... | [
"def",
"_export_single_project",
"(",
"self",
")",
":",
"expanded_dic",
"=",
"self",
".",
"workspace",
".",
"copy",
"(",
")",
"self",
".",
"_fix_paths",
"(",
"expanded_dic",
")",
"# generic tool template specified or project",
"if",
"expanded_dic",
"[",
"'template'"... | A single project export | [
"A",
"single",
"project",
"export"
] | python | train | 52.768707 |
bslatkin/dpxdt | dpxdt/client/workers.py | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/client/workers.py#L274-L295 | def outstanding(self):
"""Returns whether or not this barrier has pending work."""
# Allow the same WorkItem to be yielded multiple times but not
# count towards blocking the barrier.
done_count = 0
for item in self:
if not self.wait_any and item.fire_and_forget:
... | [
"def",
"outstanding",
"(",
"self",
")",
":",
"# Allow the same WorkItem to be yielded multiple times but not",
"# count towards blocking the barrier.",
"done_count",
"=",
"0",
"for",
"item",
"in",
"self",
":",
"if",
"not",
"self",
".",
"wait_any",
"and",
"item",
".",
... | Returns whether or not this barrier has pending work. | [
"Returns",
"whether",
"or",
"not",
"this",
"barrier",
"has",
"pending",
"work",
"."
] | python | train | 35.863636 |
bwohlberg/sporco | sporco/cnvrep.py | https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/cnvrep.py#L705-L838 | def bcrop(v, dsz, dimN=2):
"""Crop specified number of initial spatial dimensions of dictionary
array to specified size. Parameter `dsz` must be a tuple having one
of the following forms (the examples assume two spatial/temporal
dimensions). If all filters are of the same size, then
::
(flt_... | [
"def",
"bcrop",
"(",
"v",
",",
"dsz",
",",
"dimN",
"=",
"2",
")",
":",
"if",
"isinstance",
"(",
"dsz",
"[",
"0",
"]",
",",
"tuple",
")",
":",
"# Multi-scale dictionary specification",
"maxsz",
"=",
"np",
".",
"zeros",
"(",
"(",
"dimN",
",",
")",
",... | Crop specified number of initial spatial dimensions of dictionary
array to specified size. Parameter `dsz` must be a tuple having one
of the following forms (the examples assume two spatial/temporal
dimensions). If all filters are of the same size, then
::
(flt_rows, filt_cols, num_filt)
ma... | [
"Crop",
"specified",
"number",
"of",
"initial",
"spatial",
"dimensions",
"of",
"dictionary",
"array",
"to",
"specified",
"size",
".",
"Parameter",
"dsz",
"must",
"be",
"a",
"tuple",
"having",
"one",
"of",
"the",
"following",
"forms",
"(",
"the",
"examples",
... | python | train | 31.671642 |
Unidata/MetPy | metpy/plots/cartopy_utils.py | https://github.com/Unidata/MetPy/blob/16f68a94919b9a82dcf9cada2169cf039129e67b/metpy/plots/cartopy_utils.py#L19-L26 | def geometries(self):
"""Return an iterator of (shapely) geometries for this feature."""
# Ensure that the associated files are in the cache
fname = '{}_{}'.format(self.name, self.scale)
for extension in ['.dbf', '.shx']:
get_test_data(fname + extension)
path = get_te... | [
"def",
"geometries",
"(",
"self",
")",
":",
"# Ensure that the associated files are in the cache",
"fname",
"=",
"'{}_{}'",
".",
"format",
"(",
"self",
".",
"name",
",",
"self",
".",
"scale",
")",
"for",
"extension",
"in",
"[",
"'.dbf'",
",",
"'.shx'",
"]",
... | Return an iterator of (shapely) geometries for this feature. | [
"Return",
"an",
"iterator",
"of",
"(",
"shapely",
")",
"geometries",
"for",
"this",
"feature",
"."
] | python | train | 52.375 |
CalebBell/fluids | fluids/nrlmsise00/nrlmsise_00.py | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/nrlmsise00/nrlmsise_00.py#L1056-L1068 | def gtd7d(Input, flags, output): # pragma: no cover
'''A separate subroutine (GTD7D) computes the ‘‘effec-
tive’’ mass density by summing the thermospheric mass
density and the mass density of the anomalous oxygen
component. Below 500 km, the effective mass density is
equivalent to the thermospheric... | [
"def",
"gtd7d",
"(",
"Input",
",",
"flags",
",",
"output",
")",
":",
"# pragma: no cover",
"gtd7",
"(",
"Input",
",",
"flags",
",",
"output",
")",
"output",
".",
"d",
"[",
"5",
"]",
"=",
"1.66E-24",
"*",
"(",
"4.0",
"*",
"output",
".",
"d",
"[",
... | A separate subroutine (GTD7D) computes the ‘‘effec-
tive’’ mass density by summing the thermospheric mass
density and the mass density of the anomalous oxygen
component. Below 500 km, the effective mass density is
equivalent to the thermospheric mass density, and we drop
the distinction. | [
"A",
"separate",
"subroutine",
"(",
"GTD7D",
")",
"computes",
"the",
"‘‘effec",
"-",
"tive’’",
"mass",
"density",
"by",
"summing",
"the",
"thermospheric",
"mass",
"density",
"and",
"the",
"mass",
"density",
"of",
"the",
"anomalous",
"oxygen",
"component",
".",... | python | train | 50.384615 |
vmware/pyvmomi | pyVmomi/Differ.py | https://github.com/vmware/pyvmomi/blob/3ffcb23bf77d757175c0d5216ba9a25345d824cd/pyVmomi/Differ.py#L148-L166 | def DiffArrayObjects(self, oldObj, newObj, isElementLinks=False):
"""Method which deligates the diffing of arrays based on the type"""
if oldObj == newObj:
return True
if not oldObj or not newObj:
return False
if len(oldObj) != len(newObj):
__Log__.debug('DiffArrayObje... | [
"def",
"DiffArrayObjects",
"(",
"self",
",",
"oldObj",
",",
"newObj",
",",
"isElementLinks",
"=",
"False",
")",
":",
"if",
"oldObj",
"==",
"newObj",
":",
"return",
"True",
"if",
"not",
"oldObj",
"or",
"not",
"newObj",
":",
"return",
"False",
"if",
"len",... | Method which deligates the diffing of arrays based on the type | [
"Method",
"which",
"deligates",
"the",
"diffing",
"of",
"arrays",
"based",
"on",
"the",
"type"
] | python | train | 44.263158 |
aio-libs/aiodocker | aiodocker/utils.py | https://github.com/aio-libs/aiodocker/blob/88d0285ddba8e606ff684278e0a831347209189c/aiodocker/utils.py#L176-L181 | def clean_map(obj: Mapping[Any, Any]) -> Mapping[Any, Any]:
"""
Return a new copied dictionary without the keys with ``None`` values from
the given Mapping object.
"""
return {k: v for k, v in obj.items() if v is not None} | [
"def",
"clean_map",
"(",
"obj",
":",
"Mapping",
"[",
"Any",
",",
"Any",
"]",
")",
"->",
"Mapping",
"[",
"Any",
",",
"Any",
"]",
":",
"return",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",
"obj",
".",
"items",
"(",
")",
"if",
"v",
"is",
"... | Return a new copied dictionary without the keys with ``None`` values from
the given Mapping object. | [
"Return",
"a",
"new",
"copied",
"dictionary",
"without",
"the",
"keys",
"with",
"None",
"values",
"from",
"the",
"given",
"Mapping",
"object",
"."
] | python | train | 39.5 |
trailofbits/manticore | manticore/core/smtlib/solver.py | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/core/smtlib/solver.py#L104-L111 | def minmax(self, constraints, x, iters=10000):
"""Returns the min and max possible values for x within given constraints"""
if issymbolic(x):
m = self.min(constraints, x, iters)
M = self.max(constraints, x, iters)
return m, M
else:
return x, x | [
"def",
"minmax",
"(",
"self",
",",
"constraints",
",",
"x",
",",
"iters",
"=",
"10000",
")",
":",
"if",
"issymbolic",
"(",
"x",
")",
":",
"m",
"=",
"self",
".",
"min",
"(",
"constraints",
",",
"x",
",",
"iters",
")",
"M",
"=",
"self",
".",
"max... | Returns the min and max possible values for x within given constraints | [
"Returns",
"the",
"min",
"and",
"max",
"possible",
"values",
"for",
"x",
"within",
"given",
"constraints"
] | python | valid | 38.5 |
arviz-devs/arviz | arviz/data/base.py | https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/base.py#L30-L82 | def generate_dims_coords(shape, var_name, dims=None, coords=None, default_dims=None):
"""Generate default dimensions and coordinates for a variable.
Parameters
----------
shape : tuple[int]
Shape of the variable
var_name : str
Name of the variable. Used in the default name, if neces... | [
"def",
"generate_dims_coords",
"(",
"shape",
",",
"var_name",
",",
"dims",
"=",
"None",
",",
"coords",
"=",
"None",
",",
"default_dims",
"=",
"None",
")",
":",
"if",
"default_dims",
"is",
"None",
":",
"default_dims",
"=",
"[",
"]",
"if",
"dims",
"is",
... | Generate default dimensions and coordinates for a variable.
Parameters
----------
shape : tuple[int]
Shape of the variable
var_name : str
Name of the variable. Used in the default name, if necessary
dims : list
List of dimensions for the variable
coords : dict[str] -> li... | [
"Generate",
"default",
"dimensions",
"and",
"coordinates",
"for",
"a",
"variable",
"."
] | python | train | 32.226415 |
numenta/nupic | src/nupic/algorithms/fdrutilities.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/fdrutilities.py#L1311-L1399 | def predictionExtent(inputs, resets, outputs, minOverlapPct=100.0):
"""
Computes the predictive ability of a temporal memory (TM). This routine returns
a value which is the average number of time steps of prediction provided
by the TM. It accepts as input the inputs, outputs, and resets provided to
the TM as ... | [
"def",
"predictionExtent",
"(",
"inputs",
",",
"resets",
",",
"outputs",
",",
"minOverlapPct",
"=",
"100.0",
")",
":",
"# List of how many times we encountered each prediction amount. Element 0",
"# is how many times we successfully predicted 0 steps in advance, element 1",
"# is h... | Computes the predictive ability of a temporal memory (TM). This routine returns
a value which is the average number of time steps of prediction provided
by the TM. It accepts as input the inputs, outputs, and resets provided to
the TM as well as a 'minOverlapPct' used to evalulate whether or not a
prediction is... | [
"Computes",
"the",
"predictive",
"ability",
"of",
"a",
"temporal",
"memory",
"(",
"TM",
")",
".",
"This",
"routine",
"returns",
"a",
"value",
"which",
"is",
"the",
"average",
"number",
"of",
"time",
"steps",
"of",
"prediction",
"provided",
"by",
"the",
"TM... | python | valid | 41.359551 |
apache/airflow | airflow/contrib/hooks/gcp_transfer_hook.py | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_transfer_hook.py#L312-L320 | def resume_transfer_operation(self, operation_name):
"""
Resumes an transfer operation in Google Storage Transfer Service.
:param operation_name: (Required) Name of the transfer operation.
:type operation_name: str
:rtype: None
"""
self.get_conn().transferOperati... | [
"def",
"resume_transfer_operation",
"(",
"self",
",",
"operation_name",
")",
":",
"self",
".",
"get_conn",
"(",
")",
".",
"transferOperations",
"(",
")",
".",
"resume",
"(",
"name",
"=",
"operation_name",
")",
".",
"execute",
"(",
"num_retries",
"=",
"self",... | Resumes an transfer operation in Google Storage Transfer Service.
:param operation_name: (Required) Name of the transfer operation.
:type operation_name: str
:rtype: None | [
"Resumes",
"an",
"transfer",
"operation",
"in",
"Google",
"Storage",
"Transfer",
"Service",
"."
] | python | test | 42.555556 |
mitsei/dlkit | dlkit/json_/commenting/sessions.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/commenting/sessions.py#L1002-L1044 | def create_comment(self, comment_form):
"""Creates a new ``Comment``.
arg: comment_form (osid.commenting.CommentForm): the form for
this ``Comment``
return: (osid.commenting.Comment) - the new ``Comment``
raise: IllegalState - ``comment_form`` already used in a creat... | [
"def",
"create_comment",
"(",
"self",
",",
"comment_form",
")",
":",
"# Implemented from template for",
"# osid.resource.ResourceAdminSession.create_resource_template",
"collection",
"=",
"JSONClientValidated",
"(",
"'commenting'",
",",
"collection",
"=",
"'Comment'",
",",
"r... | Creates a new ``Comment``.
arg: comment_form (osid.commenting.CommentForm): the form for
this ``Comment``
return: (osid.commenting.Comment) - the new ``Comment``
raise: IllegalState - ``comment_form`` already used in a create
transaction
raise: Inval... | [
"Creates",
"a",
"new",
"Comment",
"."
] | python | train | 49.232558 |
EntilZha/PyFunctional | functional/pipeline.py | https://github.com/EntilZha/PyFunctional/blob/ac04e4a8552b0c464a7f492f7c9862424867b63e/functional/pipeline.py#L1632-L1649 | def show(self, n=10, headers=(), tablefmt="simple", floatfmt="g", numalign="decimal",
stralign="left", missingval=""):
"""
Pretty print first n rows of sequence as a table. See
https://bitbucket.org/astanin/python-tabulate for details on tabulate parameters
:param n: Number... | [
"def",
"show",
"(",
"self",
",",
"n",
"=",
"10",
",",
"headers",
"=",
"(",
")",
",",
"tablefmt",
"=",
"\"simple\"",
",",
"floatfmt",
"=",
"\"g\"",
",",
"numalign",
"=",
"\"decimal\"",
",",
"stralign",
"=",
"\"left\"",
",",
"missingval",
"=",
"\"\"",
... | Pretty print first n rows of sequence as a table. See
https://bitbucket.org/astanin/python-tabulate for details on tabulate parameters
:param n: Number of rows to show
:param headers: Passed to tabulate
:param tablefmt: Passed to tabulate
:param floatfmt: Passed to tabulate
... | [
"Pretty",
"print",
"first",
"n",
"rows",
"of",
"sequence",
"as",
"a",
"table",
".",
"See",
"https",
":",
"//",
"bitbucket",
".",
"org",
"/",
"astanin",
"/",
"python",
"-",
"tabulate",
"for",
"details",
"on",
"tabulate",
"parameters"
] | python | train | 47.777778 |
mitsei/dlkit | dlkit/json_/commenting/objects.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/commenting/objects.py#L584-L599 | def get_parent_book_nodes(self):
"""Gets the parents of this book.
return: (osid.commenting.BookNodeList) - the parents of this
book
*compliance: mandatory -- This method must be implemented.*
"""
parent_book_nodes = []
for node in self._my_map['parentNo... | [
"def",
"get_parent_book_nodes",
"(",
"self",
")",
":",
"parent_book_nodes",
"=",
"[",
"]",
"for",
"node",
"in",
"self",
".",
"_my_map",
"[",
"'parentNodes'",
"]",
":",
"parent_book_nodes",
".",
"append",
"(",
"BookNode",
"(",
"node",
".",
"_my_map",
",",
"... | Gets the parents of this book.
return: (osid.commenting.BookNodeList) - the parents of this
book
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"the",
"parents",
"of",
"this",
"book",
"."
] | python | train | 35.1875 |
KelSolaar/Umbra | umbra/components/factory/script_editor/models.py | https://github.com/KelSolaar/Umbra/blob/66f45f08d9d723787f1191989f8b0dda84b412ce/umbra/components/factory/script_editor/models.py#L950-L968 | def register_language(self, language):
"""
Registers given language in the :obj:`LanguagesModel.languages` class property.
:param language: Language to register.
:type language: Language
:return: Method success.
:rtype: bool
"""
if self.get_language(lang... | [
"def",
"register_language",
"(",
"self",
",",
"language",
")",
":",
"if",
"self",
".",
"get_language",
"(",
"language",
")",
":",
"raise",
"foundations",
".",
"exceptions",
".",
"ProgrammingError",
"(",
"\"{0} | '{1}' language is already registered!\"",
".",
"format... | Registers given language in the :obj:`LanguagesModel.languages` class property.
:param language: Language to register.
:type language: Language
:return: Method success.
:rtype: bool | [
"Registers",
"given",
"language",
"in",
"the",
":",
"obj",
":",
"LanguagesModel",
".",
"languages",
"class",
"property",
"."
] | python | train | 34.052632 |
OCA/odoorpc | odoorpc/odoo.py | https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/odoo.py#L600-L625 | def list(cls, rc_file='~/.odoorpcrc'):
"""Return a list of all stored sessions available in the
`rc_file` file:
.. doctest::
:options: +SKIP
>>> import odoorpc
>>> odoorpc.ODOO.list()
['foo', 'bar']
Use the :func:`save <odoorpc.ODOO.save... | [
"def",
"list",
"(",
"cls",
",",
"rc_file",
"=",
"'~/.odoorpcrc'",
")",
":",
"sessions",
"=",
"session",
".",
"get_all",
"(",
"rc_file",
")",
"return",
"[",
"name",
"for",
"name",
"in",
"sessions",
"if",
"sessions",
"[",
"name",
"]",
".",
"get",
"(",
... | Return a list of all stored sessions available in the
`rc_file` file:
.. doctest::
:options: +SKIP
>>> import odoorpc
>>> odoorpc.ODOO.list()
['foo', 'bar']
Use the :func:`save <odoorpc.ODOO.save>` and
:func:`load <odoorpc.ODOO.load>` me... | [
"Return",
"a",
"list",
"of",
"all",
"stored",
"sessions",
"available",
"in",
"the",
"rc_file",
"file",
":"
] | python | train | 26 |
TrafficSenseMSD/SumoTools | traci/_vehicle.py | https://github.com/TrafficSenseMSD/SumoTools/blob/8607b4f885f1d1798e43240be643efe6dccccdaa/traci/_vehicle.py#L754-L761 | def setChargingStationStop(self, vehID, stopID, duration=2**31 - 1, until=-1, flags=tc.STOP_DEFAULT):
"""setChargingStationStop(string, string, integer, integer, integer) -> None
Adds or modifies a stop at a chargingStation with the given parameters. The duration and the until attribute are
in ... | [
"def",
"setChargingStationStop",
"(",
"self",
",",
"vehID",
",",
"stopID",
",",
"duration",
"=",
"2",
"**",
"31",
"-",
"1",
",",
"until",
"=",
"-",
"1",
",",
"flags",
"=",
"tc",
".",
"STOP_DEFAULT",
")",
":",
"self",
".",
"setStop",
"(",
"vehID",
"... | setChargingStationStop(string, string, integer, integer, integer) -> None
Adds or modifies a stop at a chargingStation with the given parameters. The duration and the until attribute are
in milliseconds. | [
"setChargingStationStop",
"(",
"string",
"string",
"integer",
"integer",
"integer",
")",
"-",
">",
"None"
] | python | train | 58.375 |
internap/fake-switches | fake_switches/command_processing/base_command_processor.py | https://github.com/internap/fake-switches/blob/ea5f77f0c73493497fb43ce59f3c75b52ce9bac8/fake_switches/command_processing/base_command_processor.py#L19-L35 | def init(self, switch_configuration, terminal_controller, logger, piping_processor, *args):
"""
:type switch_configuration: fake_switches.switch_configuration.SwitchConfiguration
:type terminal_controller: fake_switches.terminal.TerminalController
:type logger: logging.Logger
:ty... | [
"def",
"init",
"(",
"self",
",",
"switch_configuration",
",",
"terminal_controller",
",",
"logger",
",",
"piping_processor",
",",
"*",
"args",
")",
":",
"self",
".",
"switch_configuration",
"=",
"switch_configuration",
"self",
".",
"terminal_controller",
"=",
"ter... | :type switch_configuration: fake_switches.switch_configuration.SwitchConfiguration
:type terminal_controller: fake_switches.terminal.TerminalController
:type logger: logging.Logger
:type piping_processor: fake_switches.command_processing.piping_processor_base.PipingProcessorBase | [
":",
"type",
"switch_configuration",
":",
"fake_switches",
".",
"switch_configuration",
".",
"SwitchConfiguration",
":",
"type",
"terminal_controller",
":",
"fake_switches",
".",
"terminal",
".",
"TerminalController",
":",
"type",
"logger",
":",
"logging",
".",
"Logge... | python | train | 45.529412 |
vtkiorg/vtki | vtki/common.py | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L391-L401 | def rotate_y(self, angle):
"""
Rotates mesh about the y-axis.
Parameters
----------
angle : float
Angle in degrees to rotate about the y-axis.
"""
axis_rotation(self.points, angle, inplace=True, axis='y') | [
"def",
"rotate_y",
"(",
"self",
",",
"angle",
")",
":",
"axis_rotation",
"(",
"self",
".",
"points",
",",
"angle",
",",
"inplace",
"=",
"True",
",",
"axis",
"=",
"'y'",
")"
] | Rotates mesh about the y-axis.
Parameters
----------
angle : float
Angle in degrees to rotate about the y-axis. | [
"Rotates",
"mesh",
"about",
"the",
"y",
"-",
"axis",
"."
] | python | train | 24 |
jedie/PyHardLinkBackup | PyHardLinkBackup/phlb/phlb_main.py | https://github.com/jedie/PyHardLinkBackup/blob/be28666834d2d9e3d8aac1b661cb2d5bd4056c29/PyHardLinkBackup/phlb/phlb_main.py#L156-L225 | def deduplication_backup(self, process_bar):
"""
Backup the current file and compare the content.
:param process_bar: tqdm process bar
"""
self.fast_backup = False # Was a fast backup used?
src_path = self.dir_path.resolved_path
log.debug("*** deduplication bac... | [
"def",
"deduplication_backup",
"(",
"self",
",",
"process_bar",
")",
":",
"self",
".",
"fast_backup",
"=",
"False",
"# Was a fast backup used?",
"src_path",
"=",
"self",
".",
"dir_path",
".",
"resolved_path",
"log",
".",
"debug",
"(",
"\"*** deduplication backup: '%... | Backup the current file and compare the content.
:param process_bar: tqdm process bar | [
"Backup",
"the",
"current",
"file",
"and",
"compare",
"the",
"content",
"."
] | python | train | 43.5 |
benvanwerkhoven/kernel_tuner | kernel_tuner/c.py | https://github.com/benvanwerkhoven/kernel_tuner/blob/cfcb5da5e510db494f8219c22566ab65d5fcbd9f/kernel_tuner/c.py#L267-L294 | def run_kernel(self, func, c_args, threads, grid):
"""runs the kernel once, returns whatever the kernel returns
:param func: A C function compiled for this specific configuration
:type func: ctypes._FuncPtr
:param c_args: A list of arguments to the function, order should match the
... | [
"def",
"run_kernel",
"(",
"self",
",",
"func",
",",
"c_args",
",",
"threads",
",",
"grid",
")",
":",
"logging",
".",
"debug",
"(",
"\"run_kernel\"",
")",
"logging",
".",
"debug",
"(",
"\"arguments=\"",
"+",
"str",
"(",
"[",
"str",
"(",
"arg",
".",
"c... | runs the kernel once, returns whatever the kernel returns
:param func: A C function compiled for this specific configuration
:type func: ctypes._FuncPtr
:param c_args: A list of arguments to the function, order should match the
order in the code. The list should be prepared using
... | [
"runs",
"the",
"kernel",
"once",
"returns",
"whatever",
"the",
"kernel",
"returns"
] | python | train | 37.535714 |
spyder-ide/spyder | spyder/plugins/editor/panels/codefolding.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/panels/codefolding.py#L624-L628 | def _clear_block_deco(self):
"""Clear the folded block decorations."""
for deco in self._block_decos:
self.editor.decorations.remove(deco)
self._block_decos[:] = [] | [
"def",
"_clear_block_deco",
"(",
"self",
")",
":",
"for",
"deco",
"in",
"self",
".",
"_block_decos",
":",
"self",
".",
"editor",
".",
"decorations",
".",
"remove",
"(",
"deco",
")",
"self",
".",
"_block_decos",
"[",
":",
"]",
"=",
"[",
"]"
] | Clear the folded block decorations. | [
"Clear",
"the",
"folded",
"block",
"decorations",
"."
] | python | train | 39.2 |
mitsei/dlkit | dlkit/records/assessment/mecqbank/mecqbank_base_records.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/records/assessment/mecqbank/mecqbank_base_records.py#L412-L420 | def set_published(self, value=None):
"""stub"""
if value is None:
raise NullArgument()
if self.get_published_metadata().is_read_only():
raise NoAccess()
if not self.my_osid_object_form._is_valid_boolean(value):
raise InvalidArgument()
self.my_o... | [
"def",
"set_published",
"(",
"self",
",",
"value",
"=",
"None",
")",
":",
"if",
"value",
"is",
"None",
":",
"raise",
"NullArgument",
"(",
")",
"if",
"self",
".",
"get_published_metadata",
"(",
")",
".",
"is_read_only",
"(",
")",
":",
"raise",
"NoAccess",... | stub | [
"stub"
] | python | train | 39.555556 |
cmaugg/pystatemachine | pystatemachine.py | https://github.com/cmaugg/pystatemachine/blob/5a6cd9cbd88180a86569cda1e564331753299c6c/pystatemachine.py#L108-L139 | def event(from_states=None, to_state=None):
""" a decorator for transitioning from certain states to a target state. must be used on bound methods of a class
instance, only. """
from_states_tuple = (from_states, ) if isinstance(from_states, State) else tuple(from_states or [])
if not len(from_states_tup... | [
"def",
"event",
"(",
"from_states",
"=",
"None",
",",
"to_state",
"=",
"None",
")",
":",
"from_states_tuple",
"=",
"(",
"from_states",
",",
")",
"if",
"isinstance",
"(",
"from_states",
",",
"State",
")",
"else",
"tuple",
"(",
"from_states",
"or",
"[",
"]... | a decorator for transitioning from certain states to a target state. must be used on bound methods of a class
instance, only. | [
"a",
"decorator",
"for",
"transitioning",
"from",
"certain",
"states",
"to",
"a",
"target",
"state",
".",
"must",
"be",
"used",
"on",
"bound",
"methods",
"of",
"a",
"class",
"instance",
"only",
"."
] | python | train | 40.53125 |
biocore/burrito-fillings | bfillings/mothur.py | https://github.com/biocore/burrito-fillings/blob/02ab71a46119b40793bd56a4ae00ca15f6dc3329/bfillings/mothur.py#L252-L275 | def _derive_log_path(self):
"""Guess logfile path produced by Mothur
This method checks the working directory for log files
generated by Mothur. It will raise an ApplicationError if no
log file can be found.
Mothur generates log files named in a nondeterministic way,
u... | [
"def",
"_derive_log_path",
"(",
"self",
")",
":",
"filenames",
"=",
"listdir",
"(",
"self",
".",
"WorkingDir",
")",
"lognames",
"=",
"[",
"x",
"for",
"x",
"in",
"filenames",
"if",
"re",
".",
"match",
"(",
"\"^mothur\\.\\d+\\.logfile$\"",
",",
"x",
")",
"... | Guess logfile path produced by Mothur
This method checks the working directory for log files
generated by Mothur. It will raise an ApplicationError if no
log file can be found.
Mothur generates log files named in a nondeterministic way,
using the current time. We return the l... | [
"Guess",
"logfile",
"path",
"produced",
"by",
"Mothur"
] | python | train | 42.666667 |
Azure/blobxfer | blobxfer/operations/crypto.py | https://github.com/Azure/blobxfer/blob/3eccbe7530cc6a20ab2d30f9e034b6f021817f34/blobxfer/operations/crypto.py#L168-L178 | def pkcs7_unpad(buf):
# type: (bytes) -> bytes
"""Removes PKCS7 padding a decrypted object
:param bytes buf: buffer to remove padding
:rtype: bytes
:return: buffer without PKCS7_PADDING
"""
unpadder = cryptography.hazmat.primitives.padding.PKCS7(
cryptography.hazmat.primitives.cipher... | [
"def",
"pkcs7_unpad",
"(",
"buf",
")",
":",
"# type: (bytes) -> bytes",
"unpadder",
"=",
"cryptography",
".",
"hazmat",
".",
"primitives",
".",
"padding",
".",
"PKCS7",
"(",
"cryptography",
".",
"hazmat",
".",
"primitives",
".",
"ciphers",
".",
"algorithms",
"... | Removes PKCS7 padding a decrypted object
:param bytes buf: buffer to remove padding
:rtype: bytes
:return: buffer without PKCS7_PADDING | [
"Removes",
"PKCS7",
"padding",
"a",
"decrypted",
"object",
":",
"param",
"bytes",
"buf",
":",
"buffer",
"to",
"remove",
"padding",
":",
"rtype",
":",
"bytes",
":",
"return",
":",
"buffer",
"without",
"PKCS7_PADDING"
] | python | train | 37.454545 |
urbn/Caesium | caesium/handler.py | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/handler.py#L211-L242 | def group_objects_by(self, list, attr, valueLabel="value", childrenLabel="children"):
"""
Generates a group object based on the attribute value on of the given attr value that is passed in.
:param list list: A list of dictionary objects
:param str attr: The attribute that the dictionari... | [
"def",
"group_objects_by",
"(",
"self",
",",
"list",
",",
"attr",
",",
"valueLabel",
"=",
"\"value\"",
",",
"childrenLabel",
"=",
"\"children\"",
")",
":",
"groups",
"=",
"[",
"]",
"for",
"obj",
"in",
"list",
":",
"val",
"=",
"obj",
".",
"get",
"(",
... | Generates a group object based on the attribute value on of the given attr value that is passed in.
:param list list: A list of dictionary objects
:param str attr: The attribute that the dictionaries should be sorted upon
:param str valueLabel: What to call the key of the field we're sorting up... | [
"Generates",
"a",
"group",
"object",
"based",
"on",
"the",
"attribute",
"value",
"on",
"of",
"the",
"given",
"attr",
"value",
"that",
"is",
"passed",
"in",
"."
] | python | train | 35.03125 |
buzzfeed/caliendo | caliendo/hooks.py | https://github.com/buzzfeed/caliendo/blob/1628a10f7782ad67c0422b5cbc9bf4979ac40abc/caliendo/hooks.py#L111-L119 | def load(self):
"""
Loads the state of a previously saved CallStack to this instance.
"""
s = load_stack(self)
if s:
self.hooks = s.hooks
self.calls = s.calls | [
"def",
"load",
"(",
"self",
")",
":",
"s",
"=",
"load_stack",
"(",
"self",
")",
"if",
"s",
":",
"self",
".",
"hooks",
"=",
"s",
".",
"hooks",
"self",
".",
"calls",
"=",
"s",
".",
"calls"
] | Loads the state of a previously saved CallStack to this instance. | [
"Loads",
"the",
"state",
"of",
"a",
"previously",
"saved",
"CallStack",
"to",
"this",
"instance",
"."
] | python | train | 23.888889 |
deep-compute/logagg | logagg/forwarders.py | https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/forwarders.py#L167-L221 | def _tag_and_field_maker(self, event):
'''
>>> idbf = InfluxDBForwarder('no_host', '8086', 'deadpool',
... 'chimichanga', 'logs', 'collection')
>>> log = {u'data': {u'_': {u'file': u'log.py',
... u'fn': u'start',
... ... | [
"def",
"_tag_and_field_maker",
"(",
"self",
",",
"event",
")",
":",
"data",
"=",
"event",
".",
"pop",
"(",
"'data'",
")",
"data",
"=",
"flatten_dict",
"(",
"{",
"'data'",
":",
"data",
"}",
")",
"t",
"=",
"dict",
"(",
"(",
"k",
",",
"event",
"[",
... | >>> idbf = InfluxDBForwarder('no_host', '8086', 'deadpool',
... 'chimichanga', 'logs', 'collection')
>>> log = {u'data': {u'_': {u'file': u'log.py',
... u'fn': u'start',
... u'ln': 8,
... ... | [
">>>",
"idbf",
"=",
"InfluxDBForwarder",
"(",
"no_host",
"8086",
"deadpool",
"...",
"chimichanga",
"logs",
"collection",
")",
">>>",
"log",
"=",
"{",
"u",
"data",
":",
"{",
"u",
"_",
":",
"{",
"u",
"file",
":",
"u",
"log",
".",
"py",
"...",
"u",
"f... | python | train | 36.163636 |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/brocade_qos.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_qos.py#L677-L689 | def qos_queue_scheduler_strict_priority_dwrr_traffic_class4(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
qos = ET.SubElement(config, "qos", xmlns="urn:brocade.com:mgmt:brocade-qos")
queue = ET.SubElement(qos, "queue")
scheduler = ET.SubElement... | [
"def",
"qos_queue_scheduler_strict_priority_dwrr_traffic_class4",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"qos",
"=",
"ET",
".",
"SubElement",
"(",
"config",
",",
"\"qos\"",
",",
"xmlns",
"... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 49.384615 |
mitsei/dlkit | dlkit/json_/logging_/sessions.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/logging_/sessions.py#L1504-L1524 | def unassign_log_entry_from_log(self, log_entry_id, log_id):
"""Removes a ``LogEntry`` from a ``Log``.
arg: log_entry_id (osid.id.Id): the ``Id`` of the
``LogEntry``
arg: log_id (osid.id.Id): the ``Id`` of the ``Log``
raise: NotFound - ``log_entry_id`` or ``log_id... | [
"def",
"unassign_log_entry_from_log",
"(",
"self",
",",
"log_entry_id",
",",
"log_id",
")",
":",
"# Implemented from template for",
"# osid.resource.ResourceBinAssignmentSession.unassign_resource_from_bin",
"mgr",
"=",
"self",
".",
"_get_provider_manager",
"(",
"'LOGGING'",
","... | Removes a ``LogEntry`` from a ``Log``.
arg: log_entry_id (osid.id.Id): the ``Id`` of the
``LogEntry``
arg: log_id (osid.id.Id): the ``Id`` of the ``Log``
raise: NotFound - ``log_entry_id`` or ``log_id`` not found or
``log_entry_id`` not assigned to ``log_i... | [
"Removes",
"a",
"LogEntry",
"from",
"a",
"Log",
"."
] | python | train | 49.714286 |
bionikspoon/pureyaml | pureyaml/grammar/productions.py | https://github.com/bionikspoon/pureyaml/blob/784830b907ca14525c4cecdb6ae35306f6f8a877/pureyaml/grammar/productions.py#L202-L208 | def p_scalar__doublequote(self, p):
"""
scalar : DOUBLEQUOTE_START SCALAR DOUBLEQUOTE_END
"""
scalar = re.sub('\n\s+', ' ', str(p[2]))
p[0] = Str(scalar.replace('\\"', '"')) | [
"def",
"p_scalar__doublequote",
"(",
"self",
",",
"p",
")",
":",
"scalar",
"=",
"re",
".",
"sub",
"(",
"'\\n\\s+'",
",",
"' '",
",",
"str",
"(",
"p",
"[",
"2",
"]",
")",
")",
"p",
"[",
"0",
"]",
"=",
"Str",
"(",
"scalar",
".",
"replace",
"(",
... | scalar : DOUBLEQUOTE_START SCALAR DOUBLEQUOTE_END | [
"scalar",
":",
"DOUBLEQUOTE_START",
"SCALAR",
"DOUBLEQUOTE_END"
] | python | train | 29.857143 |
gmr/tornado-elasticsearch | tornado_elasticsearch.py | https://github.com/gmr/tornado-elasticsearch/blob/fafe0de680277ce6faceb7449ded0b33822438d0/tornado_elasticsearch.py#L873-L895 | def suggest(self, index=None, body=None, params=None):
"""
The suggest feature suggests similar looking terms based on a provided
text by using a suggester.
`<http://elasticsearch.org/guide/reference/api/search/suggest/>`_
:arg index: A comma-separated list of index names to res... | [
"def",
"suggest",
"(",
"self",
",",
"index",
"=",
"None",
",",
"body",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"_",
",",
"data",
"=",
"yield",
"self",
".",
"transport",
".",
"perform_request",
"(",
"'POST'",
",",
"_make_path",
"(",
"index"... | The suggest feature suggests similar looking terms based on a provided
text by using a suggester.
`<http://elasticsearch.org/guide/reference/api/search/suggest/>`_
:arg index: A comma-separated list of index names to restrict the
operation; use `_all` or empty string to perform the ... | [
"The",
"suggest",
"feature",
"suggests",
"similar",
"looking",
"terms",
"based",
"on",
"a",
"provided",
"text",
"by",
"using",
"a",
"suggester",
".",
"<http",
":",
"//",
"elasticsearch",
".",
"org",
"/",
"guide",
"/",
"reference",
"/",
"api",
"/",
"search"... | python | test | 51.217391 |
ChrisCummins/labm8 | system.py | https://github.com/ChrisCummins/labm8/blob/dd10d67a757aefb180cb508f86696f99440c94f5/system.py#L117-L156 | def run(self, timeout=-1):
"""
Run the subprocess.
Arguments:
timeout (optional) If a positive real value, then timout after
the given number of seconds.
Raises:
SubprocessError If subprocess has not completed after "timeout"
seco... | [
"def",
"run",
"(",
"self",
",",
"timeout",
"=",
"-",
"1",
")",
":",
"def",
"target",
"(",
")",
":",
"self",
".",
"process",
"=",
"subprocess",
".",
"Popen",
"(",
"self",
".",
"cmd",
",",
"stdout",
"=",
"self",
".",
"stdout_dest",
",",
"stderr",
"... | Run the subprocess.
Arguments:
timeout (optional) If a positive real value, then timout after
the given number of seconds.
Raises:
SubprocessError If subprocess has not completed after "timeout"
seconds. | [
"Run",
"the",
"subprocess",
"."
] | python | train | 34.375 |
toumorokoshi/transmute-core | transmute_core/frameworks/flask/route.py | https://github.com/toumorokoshi/transmute-core/blob/a2c26625d5d8bab37e00038f9d615a26167fc7f4/transmute_core/frameworks/flask/route.py#L9-L23 | def route(app_or_blueprint, context=default_context, **kwargs):
""" attach a transmute route. """
def decorator(fn):
fn = describe(**kwargs)(fn)
transmute_func = TransmuteFunction(fn)
routes, handler = create_routes_and_handler(transmute_func, context)
for r in routes:
... | [
"def",
"route",
"(",
"app_or_blueprint",
",",
"context",
"=",
"default_context",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"decorator",
"(",
"fn",
")",
":",
"fn",
"=",
"describe",
"(",
"*",
"*",
"kwargs",
")",
"(",
"fn",
")",
"transmute_func",
"=",
"... | attach a transmute route. | [
"attach",
"a",
"transmute",
"route",
"."
] | python | train | 48.066667 |
tijme/not-your-average-web-crawler | nyawc/Crawler.py | https://github.com/tijme/not-your-average-web-crawler/blob/d77c14e1616c541bb3980f649a7e6f8ed02761fb/nyawc/Crawler.py#L151-L179 | def __crawler_start(self):
"""Spawn the first X queued request, where X is the max threads option.
Note:
The main thread will sleep until the crawler is finished. This enables
quiting the application using sigints (see http://stackoverflow.com/a/11816038/2491049).
Note:... | [
"def",
"__crawler_start",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"__options",
".",
"callbacks",
".",
"crawler_before_start",
"(",
")",
"except",
"Exception",
"as",
"e",
":",
"print",
"(",
"e",
")",
"print",
"(",
"traceback",
".",
"format_exc",
"... | Spawn the first X queued request, where X is the max threads option.
Note:
The main thread will sleep until the crawler is finished. This enables
quiting the application using sigints (see http://stackoverflow.com/a/11816038/2491049).
Note:
`__crawler_stop()` and `_... | [
"Spawn",
"the",
"first",
"X",
"queued",
"request",
"where",
"X",
"is",
"the",
"max",
"threads",
"option",
"."
] | python | train | 30.724138 |
alephdata/memorious | memorious/helpers/__init__.py | https://github.com/alephdata/memorious/blob/b4033c5064447ed5f696f9c2bbbc6c12062d2fa4/memorious/helpers/__init__.py#L16-L30 | def soviet_checksum(code):
"""Courtesy of Sir Vlad Lavrov."""
def sum_digits(code, offset=1):
total = 0
for digit, index in zip(code[:7], count(offset)):
total += int(digit) * index
summed = (total / 11 * 11)
return total - summed
check = sum_digits(code, 1)
... | [
"def",
"soviet_checksum",
"(",
"code",
")",
":",
"def",
"sum_digits",
"(",
"code",
",",
"offset",
"=",
"1",
")",
":",
"total",
"=",
"0",
"for",
"digit",
",",
"index",
"in",
"zip",
"(",
"code",
"[",
":",
"7",
"]",
",",
"count",
"(",
"offset",
")",... | Courtesy of Sir Vlad Lavrov. | [
"Courtesy",
"of",
"Sir",
"Vlad",
"Lavrov",
"."
] | python | train | 29.333333 |
ojii/django-multilingual-ng | multilingual/translation.py | https://github.com/ojii/django-multilingual-ng/blob/0d320a0732ec59949380d4b5f21e153174d3ecf7/multilingual/translation.py#L268-L288 | def get_unique_fields(cls):
"""
Return a list of fields with "unique" attribute, which needs to
be augmented by the language.
"""
unique_fields = []
for fname, field in cls.__dict__.items():
if isinstance(field, models.fields.Field):
if getatt... | [
"def",
"get_unique_fields",
"(",
"cls",
")",
":",
"unique_fields",
"=",
"[",
"]",
"for",
"fname",
",",
"field",
"in",
"cls",
".",
"__dict__",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"field",
",",
"models",
".",
"fields",
".",
"Field",
"... | Return a list of fields with "unique" attribute, which needs to
be augmented by the language. | [
"Return",
"a",
"list",
"of",
"fields",
"with",
"unique",
"attribute",
"which",
"needs",
"to",
"be",
"augmented",
"by",
"the",
"language",
"."
] | python | train | 41.52381 |
secnot/rectpack | rectpack/maxrects.py | https://github.com/secnot/rectpack/blob/21d46be48fd453500ea49de699bc9eabc427bdf7/rectpack/maxrects.py#L96-L116 | def _split(self, rect):
"""
Split all max_rects intersecting the rectangle rect into up to
4 new max_rects.
Arguments:
rect (Rectangle): Rectangle
Returns:
split (Rectangle list): List of rectangles resulting from the split
"""
ma... | [
"def",
"_split",
"(",
"self",
",",
"rect",
")",
":",
"max_rects",
"=",
"collections",
".",
"deque",
"(",
")",
"for",
"r",
"in",
"self",
".",
"_max_rects",
":",
"if",
"r",
".",
"intersects",
"(",
"rect",
")",
":",
"max_rects",
".",
"extend",
"(",
"s... | Split all max_rects intersecting the rectangle rect into up to
4 new max_rects.
Arguments:
rect (Rectangle): Rectangle
Returns:
split (Rectangle list): List of rectangles resulting from the split | [
"Split",
"all",
"max_rects",
"intersecting",
"the",
"rectangle",
"rect",
"into",
"up",
"to",
"4",
"new",
"max_rects",
".",
"Arguments",
":",
"rect",
"(",
"Rectangle",
")",
":",
"Rectangle"
] | python | train | 28.619048 |
django-admin-tools/django-admin-tools | admin_tools/menu/items.py | https://github.com/django-admin-tools/django-admin-tools/blob/ba6f46f51ebd84fcf84f2f79ec9487f45452d79b/admin_tools/menu/items.py#L340-L352 | def init_with_context(self, context):
"""
Please refer to
:meth:`~admin_tools.menu.items.MenuItem.init_with_context`
documentation from :class:`~admin_tools.menu.items.MenuItem` class.
"""
from admin_tools.menu.models import Bookmark
for b in Bookmark.objects.fil... | [
"def",
"init_with_context",
"(",
"self",
",",
"context",
")",
":",
"from",
"admin_tools",
".",
"menu",
".",
"models",
"import",
"Bookmark",
"for",
"b",
"in",
"Bookmark",
".",
"objects",
".",
"filter",
"(",
"user",
"=",
"context",
"[",
"'request'",
"]",
"... | Please refer to
:meth:`~admin_tools.menu.items.MenuItem.init_with_context`
documentation from :class:`~admin_tools.menu.items.MenuItem` class. | [
"Please",
"refer",
"to",
":",
"meth",
":",
"~admin_tools",
".",
"menu",
".",
"items",
".",
"MenuItem",
".",
"init_with_context",
"documentation",
"from",
":",
"class",
":",
"~admin_tools",
".",
"menu",
".",
"items",
".",
"MenuItem",
"class",
"."
] | python | train | 37 |
erocarrera/pefile | pefile.py | https://github.com/erocarrera/pefile/blob/8a78a2e251a3f2336c232bf411133927b479edf2/pefile.py#L5186-L5198 | def get_word_from_data(self, data, offset):
"""Convert two bytes of data to a word (little endian)
'offset' is assumed to index into a word array. So setting it to
N will return a dword out of the data starting at offset N*2.
Returns None if the data can't be turned into a word.
... | [
"def",
"get_word_from_data",
"(",
"self",
",",
"data",
",",
"offset",
")",
":",
"if",
"(",
"offset",
"+",
"1",
")",
"*",
"2",
">",
"len",
"(",
"data",
")",
":",
"return",
"None",
"return",
"struct",
".",
"unpack",
"(",
"'<H'",
",",
"data",
"[",
"... | Convert two bytes of data to a word (little endian)
'offset' is assumed to index into a word array. So setting it to
N will return a dword out of the data starting at offset N*2.
Returns None if the data can't be turned into a word. | [
"Convert",
"two",
"bytes",
"of",
"data",
"to",
"a",
"word",
"(",
"little",
"endian",
")"
] | python | train | 34.076923 |
h2oai/h2o-3 | h2o-py/h2o/frame.py | https://github.com/h2oai/h2o-3/blob/dd62aaa1e7f680a8b16ee14bc66b0fb5195c2ad8/h2o-py/h2o/frame.py#L1750-L1827 | def split_frame(self, ratios=None, destination_frames=None, seed=None):
"""
Split a frame into distinct subsets of size determined by the given ratios.
The number of subsets is always 1 more than the number of ratios given. Note that
this does not give an exact split. H2O is designed to... | [
"def",
"split_frame",
"(",
"self",
",",
"ratios",
"=",
"None",
",",
"destination_frames",
"=",
"None",
",",
"seed",
"=",
"None",
")",
":",
"assert_is_type",
"(",
"ratios",
",",
"[",
"numeric",
"]",
",",
"None",
")",
"assert_is_type",
"(",
"destination_fram... | Split a frame into distinct subsets of size determined by the given ratios.
The number of subsets is always 1 more than the number of ratios given. Note that
this does not give an exact split. H2O is designed to be efficient on big data
using a probabilistic splitting method rather than an exac... | [
"Split",
"a",
"frame",
"into",
"distinct",
"subsets",
"of",
"size",
"determined",
"by",
"the",
"given",
"ratios",
"."
] | python | test | 39.820513 |
timothydmorton/VESPA | vespa/populations.py | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/populations.py#L2543-L2863 | def calculate_eclipses(M1s, M2s, R1s, R2s, mag1s, mag2s,
u11s=0.394, u21s=0.296, u12s=0.394, u22s=0.296,
Ps=None, period=None, logperkde=RAGHAVAN_LOGPERKDE,
incs=None, eccs=None,
mininc=None, calc_mininc=True,
... | [
"def",
"calculate_eclipses",
"(",
"M1s",
",",
"M2s",
",",
"R1s",
",",
"R2s",
",",
"mag1s",
",",
"mag2s",
",",
"u11s",
"=",
"0.394",
",",
"u21s",
"=",
"0.296",
",",
"u12s",
"=",
"0.394",
",",
"u22s",
"=",
"0.296",
",",
"Ps",
"=",
"None",
",",
"per... | Returns random eclipse parameters for provided inputs
:param M1s, M2s, R1s, R2s, mag1s, mag2s: (array-like)
Primary and secondary properties (mass, radius, magnitude)
:param u11s, u21s, u12s, u22s: (optional)
Limb darkening parameters (u11 = u1 for star 1, u21 = u2 for star 1, etc.)
:par... | [
"Returns",
"random",
"eclipse",
"parameters",
"for",
"provided",
"inputs"
] | python | train | 39.389408 |
westurner/pgs | pgs/app.py | https://github.com/westurner/pgs/blob/1cc2bf2c41479d8d3ba50480f003183f1675e518/pgs/app.py#L60-L94 | def pathjoin(*args, **kwargs):
"""
Arguments:
args (list): *args list of paths
if len(args) == 1, args[0] is not a string, and args[0] is iterable,
set args to args[0].
Basically::
joined_path = u'/'.join(
[args[0].rstrip('/')] +
[a.strip('/'... | [
"def",
"pathjoin",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"debug",
"(",
"'pathjoin: %r'",
"%",
"list",
"(",
"args",
")",
")",
"def",
"_pathjoin",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"len_",
"=",
"len",
... | Arguments:
args (list): *args list of paths
if len(args) == 1, args[0] is not a string, and args[0] is iterable,
set args to args[0].
Basically::
joined_path = u'/'.join(
[args[0].rstrip('/')] +
[a.strip('/') for a in args[1:-1]] +
[args[... | [
"Arguments",
":",
"args",
"(",
"list",
")",
":",
"*",
"args",
"list",
"of",
"paths",
"if",
"len",
"(",
"args",
")",
"==",
"1",
"args",
"[",
"0",
"]",
"is",
"not",
"a",
"string",
"and",
"args",
"[",
"0",
"]",
"is",
"iterable",
"set",
"args",
"to... | python | valid | 30 |
phac-nml/sistr_cmd | sistr/misc/add_ref_genomes.py | https://github.com/phac-nml/sistr_cmd/blob/4630fae72439723b354a94b94fbe76ad2f9f6295/sistr/misc/add_ref_genomes.py#L65-L85 | def sketch_fasta(fasta_path, outdir):
"""Create a Mash sketch from an input fasta file
Args:
fasta_path (str): input fasta file path. Genome name in fasta filename
outdir (str): output directory path to write Mash sketch file to
Returns:
str: output Mash sketch file path
"""
... | [
"def",
"sketch_fasta",
"(",
"fasta_path",
",",
"outdir",
")",
":",
"genome_name",
"=",
"genome_name_from_fasta_path",
"(",
"fasta_path",
")",
"outpath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"outdir",
",",
"genome_name",
")",
"args",
"=",
"[",
"'mash'",
... | Create a Mash sketch from an input fasta file
Args:
fasta_path (str): input fasta file path. Genome name in fasta filename
outdir (str): output directory path to write Mash sketch file to
Returns:
str: output Mash sketch file path | [
"Create",
"a",
"Mash",
"sketch",
"from",
"an",
"input",
"fasta",
"file"
] | python | train | 36.380952 |
pvlib/pvlib-python | pvlib/forecast.py | https://github.com/pvlib/pvlib-python/blob/2e844a595b820b43d1170269781fa66bd0ccc8a3/pvlib/forecast.py#L727-L749 | def process_data(self, data, cloud_cover='total_clouds', **kwargs):
"""
Defines the steps needed to convert raw forecast data
into processed forecast data.
Parameters
----------
data: DataFrame
Raw forecast data
cloud_cover: str, default 'total_clouds... | [
"def",
"process_data",
"(",
"self",
",",
"data",
",",
"cloud_cover",
"=",
"'total_clouds'",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"super",
"(",
"GFS",
",",
"self",
")",
".",
"process_data",
"(",
"data",
",",
"*",
"*",
"kwargs",
")",
"data",... | Defines the steps needed to convert raw forecast data
into processed forecast data.
Parameters
----------
data: DataFrame
Raw forecast data
cloud_cover: str, default 'total_clouds'
The type of cloud cover used to infer the irradiance.
Returns
... | [
"Defines",
"the",
"steps",
"needed",
"to",
"convert",
"raw",
"forecast",
"data",
"into",
"processed",
"forecast",
"data",
"."
] | python | train | 35.565217 |
onelogin/python-saml | src/onelogin/saml2/utils.py | https://github.com/onelogin/python-saml/blob/9fe7a72da5b4caa1529c1640b52d2649447ce49b/src/onelogin/saml2/utils.py#L734-L771 | def get_status(dom):
"""
Gets Status from a Response.
:param dom: The Response as XML
:type: Document
:returns: The Status, an array with the code and a message.
:rtype: dict
"""
status = {}
status_entry = OneLogin_Saml2_Utils.query(dom, '/samlp... | [
"def",
"get_status",
"(",
"dom",
")",
":",
"status",
"=",
"{",
"}",
"status_entry",
"=",
"OneLogin_Saml2_Utils",
".",
"query",
"(",
"dom",
",",
"'/samlp:Response/samlp:Status'",
")",
"if",
"len",
"(",
"status_entry",
")",
"!=",
"1",
":",
"raise",
"OneLogin_S... | Gets Status from a Response.
:param dom: The Response as XML
:type: Document
:returns: The Status, an array with the code and a message.
:rtype: dict | [
"Gets",
"Status",
"from",
"a",
"Response",
"."
] | python | train | 39.315789 |
Lagg/steamodd | steam/items.py | https://github.com/Lagg/steamodd/blob/2e9ced4e7a6dbe3e09d5a648450bafc12b937b95/steam/items.py#L130-L145 | def _attribute_definition(self, attrid):
""" Returns the attribute definition dict of a given attribute
ID, can be the name or the integer ID """
attrs = self._schema["attributes"]
try:
# Make a new dict to avoid side effects
return dict(attrs[attrid])
ex... | [
"def",
"_attribute_definition",
"(",
"self",
",",
"attrid",
")",
":",
"attrs",
"=",
"self",
".",
"_schema",
"[",
"\"attributes\"",
"]",
"try",
":",
"# Make a new dict to avoid side effects",
"return",
"dict",
"(",
"attrs",
"[",
"attrid",
"]",
")",
"except",
"K... | Returns the attribute definition dict of a given attribute
ID, can be the name or the integer ID | [
"Returns",
"the",
"attribute",
"definition",
"dict",
"of",
"a",
"given",
"attribute",
"ID",
"can",
"be",
"the",
"name",
"or",
"the",
"integer",
"ID"
] | python | train | 34.8125 |
limpyd/redis-limpyd-jobs | limpyd_jobs/models.py | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/models.py#L298-L372 | def add_job(cls, identifier, queue_name=None, priority=0, queue_model=None,
prepend=False, delayed_for=None, delayed_until=None,
**fields_if_new):
"""
Add a job to a queue.
If this job already exists, check it's current priority. If its higher
than the new... | [
"def",
"add_job",
"(",
"cls",
",",
"identifier",
",",
"queue_name",
"=",
"None",
",",
"priority",
"=",
"0",
",",
"queue_model",
"=",
"None",
",",
"prepend",
"=",
"False",
",",
"delayed_for",
"=",
"None",
",",
"delayed_until",
"=",
"None",
",",
"*",
"*"... | Add a job to a queue.
If this job already exists, check it's current priority. If its higher
than the new one, don't touch it, else move the job to the wanted queue.
Before setting/moving the job to the queue, check for a `delayed_for`
(int/foat/timedelta) or `delayed_until` (datetime) a... | [
"Add",
"a",
"job",
"to",
"a",
"queue",
".",
"If",
"this",
"job",
"already",
"exists",
"check",
"it",
"s",
"current",
"priority",
".",
"If",
"its",
"higher",
"than",
"the",
"new",
"one",
"don",
"t",
"touch",
"it",
"else",
"move",
"the",
"job",
"to",
... | python | train | 39.32 |
neherlab/treetime | treetime/gtr.py | https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/gtr.py#L897-L925 | def evolve(self, profile, t, return_log=False):
"""
Compute the probability of the sequence state of the child
at time t later, given the parent profile.
Parameters
----------
profile : numpy.array
Sequence profile. Shape = (L, a),
where L - seq... | [
"def",
"evolve",
"(",
"self",
",",
"profile",
",",
"t",
",",
"return_log",
"=",
"False",
")",
":",
"Qt",
"=",
"self",
".",
"expQt",
"(",
"t",
")",
".",
"T",
"res",
"=",
"profile",
".",
"dot",
"(",
"Qt",
")",
"return",
"np",
".",
"log",
"(",
"... | Compute the probability of the sequence state of the child
at time t later, given the parent profile.
Parameters
----------
profile : numpy.array
Sequence profile. Shape = (L, a),
where L - sequence length, a - alphabet size.
t : double
Ti... | [
"Compute",
"the",
"probability",
"of",
"the",
"sequence",
"state",
"of",
"the",
"child",
"at",
"time",
"t",
"later",
"given",
"the",
"parent",
"profile",
"."
] | python | test | 26.344828 |
mattbierner/blotre-py | blotre.py | https://github.com/mattbierner/blotre-py/blob/c98228d1159bc651aad546e442b0acbf97b1e043/blotre.py#L358-L365 | def _persist(self):
"""Persist client data."""
with open(self.file, 'w') as f:
json.dump({
'client': self.client,
'creds': self.creds,
'config': self.config
}, f) | [
"def",
"_persist",
"(",
"self",
")",
":",
"with",
"open",
"(",
"self",
".",
"file",
",",
"'w'",
")",
"as",
"f",
":",
"json",
".",
"dump",
"(",
"{",
"'client'",
":",
"self",
".",
"client",
",",
"'creds'",
":",
"self",
".",
"creds",
",",
"'config'"... | Persist client data. | [
"Persist",
"client",
"data",
"."
] | python | train | 30.375 |
baverman/supplement | supplement/hooks/pygtk/__init__.py | https://github.com/baverman/supplement/blob/955002fe5a5749c9f0d89002f0006ec4fcd35bc9/supplement/hooks/pygtk/__init__.py#L315-L326 | def get_function_params(self, scope_path, pyfunc):
""":type pyfunc: rope.base.pyobjectsdef.PyFunction"""
pyclass = pyfunc.parent
scope_path = get_attribute_scope_path(pyclass)
glade_file = self.get_glade_file_for_class(scope_path, pyclass)
if glade_file:
self.proces... | [
"def",
"get_function_params",
"(",
"self",
",",
"scope_path",
",",
"pyfunc",
")",
":",
"pyclass",
"=",
"pyfunc",
".",
"parent",
"scope_path",
"=",
"get_attribute_scope_path",
"(",
"pyclass",
")",
"glade_file",
"=",
"self",
".",
"get_glade_file_for_class",
"(",
"... | :type pyfunc: rope.base.pyobjectsdef.PyFunction | [
":",
"type",
"pyfunc",
":",
"rope",
".",
"base",
".",
"pyobjectsdef",
".",
"PyFunction"
] | python | train | 36.916667 |
dshean/pygeotools | pygeotools/lib/geolib.py | https://github.com/dshean/pygeotools/blob/5ac745717c0098d01eb293ff1fe32fd7358c76ab/pygeotools/lib/geolib.py#L863-L886 | def shp2geom(shp_fn):
"""Extract geometries from input shapefile
Need to handle multi-part geom: http://osgeo-org.1560.x6.nabble.com/Multipart-to-singlepart-td3746767.html
"""
ds = ogr.Open(shp_fn)
lyr = ds.GetLayer()
srs = lyr.GetSpatialRef()
lyr.ResetReading()
geom_list = []
f... | [
"def",
"shp2geom",
"(",
"shp_fn",
")",
":",
"ds",
"=",
"ogr",
".",
"Open",
"(",
"shp_fn",
")",
"lyr",
"=",
"ds",
".",
"GetLayer",
"(",
")",
"srs",
"=",
"lyr",
".",
"GetSpatialRef",
"(",
")",
"lyr",
".",
"ResetReading",
"(",
")",
"geom_list",
"=",
... | Extract geometries from input shapefile
Need to handle multi-part geom: http://osgeo-org.1560.x6.nabble.com/Multipart-to-singlepart-td3746767.html | [
"Extract",
"geometries",
"from",
"input",
"shapefile",
"Need",
"to",
"handle",
"multi",
"-",
"part",
"geom",
":",
"http",
":",
"//",
"osgeo",
"-",
"org",
".",
"1560",
".",
"x6",
".",
"nabble",
".",
"com",
"/",
"Multipart",
"-",
"to",
"-",
"singlepart",... | python | train | 34.375 |
andreikop/qutepart | qutepart/__init__.py | https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/__init__.py#L335-L348 | def terminate(self):
""" Terminate Qutepart instance.
This method MUST be called before application stop to avoid crashes and
some other interesting effects
Call it on close to free memory and stop background highlighting
"""
self.text = ''
self._completer.termina... | [
"def",
"terminate",
"(",
"self",
")",
":",
"self",
".",
"text",
"=",
"''",
"self",
".",
"_completer",
".",
"terminate",
"(",
")",
"if",
"self",
".",
"_highlighter",
"is",
"not",
"None",
":",
"self",
".",
"_highlighter",
".",
"terminate",
"(",
")",
"i... | Terminate Qutepart instance.
This method MUST be called before application stop to avoid crashes and
some other interesting effects
Call it on close to free memory and stop background highlighting | [
"Terminate",
"Qutepart",
"instance",
".",
"This",
"method",
"MUST",
"be",
"called",
"before",
"application",
"stop",
"to",
"avoid",
"crashes",
"and",
"some",
"other",
"interesting",
"effects",
"Call",
"it",
"on",
"close",
"to",
"free",
"memory",
"and",
"stop",... | python | train | 33.214286 |
Microsoft/azure-devops-python-api | azure-devops/azure/devops/v5_0/graph/graph_client.py | https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/graph/graph_client.py#L93-L116 | def list_groups(self, scope_descriptor=None, subject_types=None, continuation_token=None):
"""ListGroups.
[Preview API] Gets a list of all groups in the current scope (usually organization or account).
:param str scope_descriptor: Specify a non-default scope (collection, project) to search for g... | [
"def",
"list_groups",
"(",
"self",
",",
"scope_descriptor",
"=",
"None",
",",
"subject_types",
"=",
"None",
",",
"continuation_token",
"=",
"None",
")",
":",
"query_parameters",
"=",
"{",
"}",
"if",
"scope_descriptor",
"is",
"not",
"None",
":",
"query_paramete... | ListGroups.
[Preview API] Gets a list of all groups in the current scope (usually organization or account).
:param str scope_descriptor: Specify a non-default scope (collection, project) to search for groups.
:param [str] subject_types: A comma separated list of user subject subtypes to reduce t... | [
"ListGroups",
".",
"[",
"Preview",
"API",
"]",
"Gets",
"a",
"list",
"of",
"all",
"groups",
"in",
"the",
"current",
"scope",
"(",
"usually",
"organization",
"or",
"account",
")",
".",
":",
"param",
"str",
"scope_descriptor",
":",
"Specify",
"a",
"non",
"-... | python | train | 79.708333 |
Unity-Technologies/ml-agents | ml-agents/mlagents/trainers/models.py | https://github.com/Unity-Technologies/ml-agents/blob/37d139af636e4a2351751fbf0f2fca5a9ed7457f/ml-agents/mlagents/trainers/models.py#L112-L131 | def create_vector_observation_encoder(observation_input, h_size, activation, num_layers, scope,
reuse):
"""
Builds a set of hidden state encoders.
:param reuse: Whether to re-use the weights within the same scope.
:param scope: Graph scope for th... | [
"def",
"create_vector_observation_encoder",
"(",
"observation_input",
",",
"h_size",
",",
"activation",
",",
"num_layers",
",",
"scope",
",",
"reuse",
")",
":",
"with",
"tf",
".",
"variable_scope",
"(",
"scope",
")",
":",
"hidden",
"=",
"observation_input",
"for... | Builds a set of hidden state encoders.
:param reuse: Whether to re-use the weights within the same scope.
:param scope: Graph scope for the encoder ops.
:param observation_input: Input vector.
:param h_size: Hidden layer size.
:param activation: What type of activation function t... | [
"Builds",
"a",
"set",
"of",
"hidden",
"state",
"encoders",
".",
":",
"param",
"reuse",
":",
"Whether",
"to",
"re",
"-",
"use",
"the",
"weights",
"within",
"the",
"same",
"scope",
".",
":",
"param",
"scope",
":",
"Graph",
"scope",
"for",
"the",
"encoder... | python | train | 52.85 |
kahowell/pywebui | bridge/pywebui/bridge/__init__.py | https://github.com/kahowell/pywebui/blob/91c031e784454a83bea6808517e6de4389ca6ffa/bridge/pywebui/bridge/__init__.py#L27-L33 | def import_module(self, name):
"""Import a module into the bridge."""
if name not in self._objects:
module = _import_module(name)
self._objects[name] = module
self._object_references[id(module)] = name
return self._objects[name] | [
"def",
"import_module",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"not",
"in",
"self",
".",
"_objects",
":",
"module",
"=",
"_import_module",
"(",
"name",
")",
"self",
".",
"_objects",
"[",
"name",
"]",
"=",
"module",
"self",
".",
"_object_refe... | Import a module into the bridge. | [
"Import",
"a",
"module",
"into",
"the",
"bridge",
"."
] | python | train | 40.285714 |
nuagenetworks/monolithe | monolithe/courgette/courgette.py | https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/courgette/courgette.py#L57-L82 | def run(self, configurations):
""" Run all tests
Returns:
A dictionnary containing tests results.
"""
result = CourgetteResult()
for configuration in configurations:
runner = CourgetteTestsRunner(url=self.url,
... | [
"def",
"run",
"(",
"self",
",",
"configurations",
")",
":",
"result",
"=",
"CourgetteResult",
"(",
")",
"for",
"configuration",
"in",
"configurations",
":",
"runner",
"=",
"CourgetteTestsRunner",
"(",
"url",
"=",
"self",
".",
"url",
",",
"username",
"=",
"... | Run all tests
Returns:
A dictionnary containing tests results. | [
"Run",
"all",
"tests"
] | python | train | 44.192308 |
KE-works/pykechain | pykechain/models/part.py | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/part.py#L424-L479 | def edit(self, name=None, description=None, **kwargs):
# type: (AnyStr, AnyStr, **Any) -> None
"""
Edit the details of a part (model or instance).
For an instance you can edit the Part instance name and the part instance description. To alter the values
of properties use :func:`... | [
"def",
"edit",
"(",
"self",
",",
"name",
"=",
"None",
",",
"description",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (AnyStr, AnyStr, **Any) -> None",
"update_dict",
"=",
"{",
"'id'",
":",
"self",
".",
"id",
"}",
"if",
"name",
":",
"if",
... | Edit the details of a part (model or instance).
For an instance you can edit the Part instance name and the part instance description. To alter the values
of properties use :func:`Part.update()`.
In order to prevent the backend from updating the frontend you may add `suppress_kevents=True` as
... | [
"Edit",
"the",
"details",
"of",
"a",
"part",
"(",
"model",
"or",
"instance",
")",
"."
] | python | train | 43.267857 |
CellProfiler/centrosome | centrosome/filter.py | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L1010-L1021 | def velocity_kalman_model():
'''Return a KalmanState set up to model objects with constant velocity
The observation and measurement vectors are i,j.
The state vector is i,j,vi,vj
'''
om = np.array([[1,0,0,0], [0, 1, 0, 0]])
tm = np.array([[1,0,1,0],
[0,1,0,1],
... | [
"def",
"velocity_kalman_model",
"(",
")",
":",
"om",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"1",
",",
"0",
",",
"0",
",",
"0",
"]",
",",
"[",
"0",
",",
"1",
",",
"0",
",",
"0",
"]",
"]",
")",
"tm",
"=",
"np",
".",
"array",
"(",
"[",
"[... | Return a KalmanState set up to model objects with constant velocity
The observation and measurement vectors are i,j.
The state vector is i,j,vi,vj | [
"Return",
"a",
"KalmanState",
"set",
"up",
"to",
"model",
"objects",
"with",
"constant",
"velocity"
] | python | train | 32.083333 |
laginha/django-mobileesp | src/django_mobileesp/mdetect.py | https://github.com/laginha/django-mobileesp/blob/91d4babb2343b992970bdb076508d380680c8b7e/src/django_mobileesp/mdetect.py#L778-L785 | def detectGamingHandheld(self):
"""Return detection of a gaming handheld with a modern iPhone-class browser
Detects if the current device is a handheld gaming device with
a touchscreen and modern iPhone-class browser. Includes the Playstation Vita.
"""
return UAgentInfo.devicePl... | [
"def",
"detectGamingHandheld",
"(",
"self",
")",
":",
"return",
"UAgentInfo",
".",
"devicePlaystation",
"in",
"self",
".",
"__userAgent",
"and",
"UAgentInfo",
".",
"devicePlaystationVita",
"in",
"self",
".",
"__userAgent"
] | Return detection of a gaming handheld with a modern iPhone-class browser
Detects if the current device is a handheld gaming device with
a touchscreen and modern iPhone-class browser. Includes the Playstation Vita. | [
"Return",
"detection",
"of",
"a",
"gaming",
"handheld",
"with",
"a",
"modern",
"iPhone",
"-",
"class",
"browser"
] | python | train | 51.625 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.