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 |
|---|---|---|---|---|---|---|---|---|---|
django-dbbackup/django-dbbackup | dbbackup/management/commands/dbrestore.py | https://github.com/django-dbbackup/django-dbbackup/blob/77de209e2d5317e51510d0f888e085ee0c400d66/dbbackup/management/commands/dbrestore.py#L70-L94 | def _restore_backup(self):
"""Restore the specified database."""
input_filename, input_file = self._get_backup_file(database=self.database_name,
servername=self.servername)
self.logger.info("Restoring backup for database '%s' and server ... | [
"def",
"_restore_backup",
"(",
"self",
")",
":",
"input_filename",
",",
"input_file",
"=",
"self",
".",
"_get_backup_file",
"(",
"database",
"=",
"self",
".",
"database_name",
",",
"servername",
"=",
"self",
".",
"servername",
")",
"self",
".",
"logger",
"."... | Restore the specified database. | [
"Restore",
"the",
"specified",
"database",
"."
] | python | train | 47.72 |
blockadeio/analyst_toolbench | blockade/api.py | https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/api.py#L63-L68 | def set_debug(self, status):
"""Control the logging state."""
if status:
self.logger.setLevel('DEBUG')
else:
self.logger.setLevel('INFO') | [
"def",
"set_debug",
"(",
"self",
",",
"status",
")",
":",
"if",
"status",
":",
"self",
".",
"logger",
".",
"setLevel",
"(",
"'DEBUG'",
")",
"else",
":",
"self",
".",
"logger",
".",
"setLevel",
"(",
"'INFO'",
")"
] | Control the logging state. | [
"Control",
"the",
"logging",
"state",
"."
] | python | train | 30 |
sods/ods | pods/datasets.py | https://github.com/sods/ods/blob/3995c659f25a0a640f6009ed7fcc2559ce659b1d/pods/datasets.py#L1009-L1021 | def osu_run1(data_set='osu_run1', sample_every=4):
"""Ohio State University's Run1 motion capture data set."""
path = os.path.join(data_path, data_set)
if not data_available(data_set):
import zipfile
download_data(data_set)
zip = zipfile.ZipFile(os.path.join(data_path, data_set, 'run... | [
"def",
"osu_run1",
"(",
"data_set",
"=",
"'osu_run1'",
",",
"sample_every",
"=",
"4",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"data_path",
",",
"data_set",
")",
"if",
"not",
"data_available",
"(",
"data_set",
")",
":",
"import",
"zi... | Ohio State University's Run1 motion capture data set. | [
"Ohio",
"State",
"University",
"s",
"Run1",
"motion",
"capture",
"data",
"set",
"."
] | python | train | 44.692308 |
mottosso/be | be/vendor/requests/packages/urllib3/connectionpool.py | https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/connectionpool.py#L772-L796 | def connection_from_url(url, **kw):
"""
Given a url, return an :class:`.ConnectionPool` instance of its host.
This is a shortcut for not having to parse out the scheme, host, and port
of the url before creating an :class:`.ConnectionPool` instance.
:param url:
Absolute URL string that must... | [
"def",
"connection_from_url",
"(",
"url",
",",
"*",
"*",
"kw",
")",
":",
"scheme",
",",
"host",
",",
"port",
"=",
"get_host",
"(",
"url",
")",
"if",
"scheme",
"==",
"'https'",
":",
"return",
"HTTPSConnectionPool",
"(",
"host",
",",
"port",
"=",
"port",... | Given a url, return an :class:`.ConnectionPool` instance of its host.
This is a shortcut for not having to parse out the scheme, host, and port
of the url before creating an :class:`.ConnectionPool` instance.
:param url:
Absolute URL string that must include the scheme. Port is optional.
:par... | [
"Given",
"a",
"url",
"return",
"an",
":",
"class",
":",
".",
"ConnectionPool",
"instance",
"of",
"its",
"host",
"."
] | python | train | 34.08 |
bcb/jsonrpcclient | jsonrpcclient/__main__.py | https://github.com/bcb/jsonrpcclient/blob/5b5abc28d1466d694c80b80c427a5dcb275382bb/jsonrpcclient/__main__.py#L40-L68 | def main(
context: click.core.Context, method: str, request_type: str, id: Any, send: str
) -> None:
"""
Create a JSON-RPC request.
"""
exit_status = 0
# Extract the jsonrpc arguments
positional = [a for a in context.args if "=" not in a]
named = {a.split("=")[0]: a.split("=")[1] for a i... | [
"def",
"main",
"(",
"context",
":",
"click",
".",
"core",
".",
"Context",
",",
"method",
":",
"str",
",",
"request_type",
":",
"str",
",",
"id",
":",
"Any",
",",
"send",
":",
"str",
")",
"->",
"None",
":",
"exit_status",
"=",
"0",
"# Extract the json... | Create a JSON-RPC request. | [
"Create",
"a",
"JSON",
"-",
"RPC",
"request",
"."
] | python | train | 31.758621 |
ska-sa/katcp-python | katcp/kattypes.py | https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/kattypes.py#L586-L605 | def unpack(self, value):
"""Unpack the parameter using its kattype.
Parameters
----------
packed_value : str
The unescaped KATCP string to unpack.
Returns
-------
value : object
The unpacked value.
"""
# Wrap errors in Fa... | [
"def",
"unpack",
"(",
"self",
",",
"value",
")",
":",
"# Wrap errors in FailReplies with information identifying the parameter",
"try",
":",
"return",
"self",
".",
"_kattype",
".",
"unpack",
"(",
"value",
",",
"self",
".",
"major",
")",
"except",
"ValueError",
","... | Unpack the parameter using its kattype.
Parameters
----------
packed_value : str
The unescaped KATCP string to unpack.
Returns
-------
value : object
The unpacked value. | [
"Unpack",
"the",
"parameter",
"using",
"its",
"kattype",
"."
] | python | train | 29.45 |
objectrocket/python-client | scripts/check_docs.py | https://github.com/objectrocket/python-client/blob/a65868c7511ff49a5fbe304e53bf592b7fc6d5ef/scripts/check_docs.py#L185-L217 | def parse_py_tree(self, pytree):
"""Parse the given Python package tree.
:param str pytree: The absolute path to the Python tree which is to be parsed.
:rtype: dict
:returns: A two-tuple. The first element is a dict where each key is the path of a parsed
Python module (relat... | [
"def",
"parse_py_tree",
"(",
"self",
",",
"pytree",
")",
":",
"parsed_pytree",
"=",
"{",
"}",
"pypackages",
"=",
"set",
"(",
")",
"for",
"base",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"pytree",
")",
":",
"if",
"self",
".",
"_ignor... | Parse the given Python package tree.
:param str pytree: The absolute path to the Python tree which is to be parsed.
:rtype: dict
:returns: A two-tuple. The first element is a dict where each key is the path of a parsed
Python module (relative to the Python tree) and its value is the... | [
"Parse",
"the",
"given",
"Python",
"package",
"tree",
"."
] | python | train | 41.272727 |
oscarbranson/latools | latools/latools.py | https://github.com/oscarbranson/latools/blob/cd25a650cfee318152f234d992708511f7047fbe/latools/latools.py#L3075-L3112 | def histograms(self, analytes=None, bins=25, logy=False,
filt=False, colourful=True):
"""
Plot histograms of analytes.
Parameters
----------
analytes : optional, array_like or str
The analyte(s) to plot. Defaults to all analytes.
bins : int... | [
"def",
"histograms",
"(",
"self",
",",
"analytes",
"=",
"None",
",",
"bins",
"=",
"25",
",",
"logy",
"=",
"False",
",",
"filt",
"=",
"False",
",",
"colourful",
"=",
"True",
")",
":",
"if",
"analytes",
"is",
"None",
":",
"analytes",
"=",
"self",
"."... | Plot histograms of analytes.
Parameters
----------
analytes : optional, array_like or str
The analyte(s) to plot. Defaults to all analytes.
bins : int
The number of bins in each histogram (default = 25)
logy : bool
If true, y axis is a log sca... | [
"Plot",
"histograms",
"of",
"analytes",
"."
] | python | test | 33.394737 |
vaexio/vaex | packages/vaex-core/vaex/functions.py | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/functions.py#L19-L71 | def register_function(scope=None, as_property=False, name=None):
"""Decorator to register a new function with vaex.
Example:
>>> import vaex
>>> df = vaex.example()
>>> @vaex.register_function()
>>> def invert(x):
>>> return 1/x
>>> df.x.invert()
>>> import numpy as np
>>... | [
"def",
"register_function",
"(",
"scope",
"=",
"None",
",",
"as_property",
"=",
"False",
",",
"name",
"=",
"None",
")",
":",
"prefix",
"=",
"''",
"if",
"scope",
":",
"prefix",
"=",
"scope",
"+",
"\"_\"",
"if",
"scope",
"not",
"in",
"scopes",
":",
"ra... | Decorator to register a new function with vaex.
Example:
>>> import vaex
>>> df = vaex.example()
>>> @vaex.register_function()
>>> def invert(x):
>>> return 1/x
>>> df.x.invert()
>>> import numpy as np
>>> df = vaex.from_arrays(departure=np.arange('2015-01-01', '2015-12-05', ... | [
"Decorator",
"to",
"register",
"a",
"new",
"function",
"with",
"vaex",
"."
] | python | test | 37.811321 |
skorch-dev/skorch | skorch/dataset.py | https://github.com/skorch-dev/skorch/blob/5b9b8b7b7712cb6e5aaa759d9608ea6269d5bcd3/skorch/dataset.py#L293-L306 | def check_cv(self, y):
"""Resolve which cross validation strategy is used."""
y_arr = None
if self.stratified:
# Try to convert y to numpy for sklearn's check_cv; if conversion
# doesn't work, still try.
try:
y_arr = to_numpy(y)
exc... | [
"def",
"check_cv",
"(",
"self",
",",
"y",
")",
":",
"y_arr",
"=",
"None",
"if",
"self",
".",
"stratified",
":",
"# Try to convert y to numpy for sklearn's check_cv; if conversion",
"# doesn't work, still try.",
"try",
":",
"y_arr",
"=",
"to_numpy",
"(",
"y",
")",
... | Resolve which cross validation strategy is used. | [
"Resolve",
"which",
"cross",
"validation",
"strategy",
"is",
"used",
"."
] | python | train | 35.071429 |
pypa/pipenv | pipenv/patched/notpip/_vendor/distro.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/distro.py#L727-L759 | def version(self, pretty=False, best=False):
"""
Return the version of the OS distribution, as a string.
For details, see :func:`distro.version`.
"""
versions = [
self.os_release_attr('version_id'),
self.lsb_release_attr('release'),
self.distr... | [
"def",
"version",
"(",
"self",
",",
"pretty",
"=",
"False",
",",
"best",
"=",
"False",
")",
":",
"versions",
"=",
"[",
"self",
".",
"os_release_attr",
"(",
"'version_id'",
")",
",",
"self",
".",
"lsb_release_attr",
"(",
"'release'",
")",
",",
"self",
"... | Return the version of the OS distribution, as a string.
For details, see :func:`distro.version`. | [
"Return",
"the",
"version",
"of",
"the",
"OS",
"distribution",
"as",
"a",
"string",
"."
] | python | train | 40.787879 |
tjvr/kurt | kurt/__init__.py | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L2416-L2423 | def _wave(self):
"""Return a wave.Wave_read instance from the ``wave`` module."""
try:
return wave.open(StringIO(self.contents))
except wave.Error, err:
err.message += "\nInvalid wave file: %s" % self
err.args = (err.message,)
raise | [
"def",
"_wave",
"(",
"self",
")",
":",
"try",
":",
"return",
"wave",
".",
"open",
"(",
"StringIO",
"(",
"self",
".",
"contents",
")",
")",
"except",
"wave",
".",
"Error",
",",
"err",
":",
"err",
".",
"message",
"+=",
"\"\\nInvalid wave file: %s\"",
"%"... | Return a wave.Wave_read instance from the ``wave`` module. | [
"Return",
"a",
"wave",
".",
"Wave_read",
"instance",
"from",
"the",
"wave",
"module",
"."
] | python | train | 37.125 |
timkpaine/lantern | lantern/plotting/plotutils.py | https://github.com/timkpaine/lantern/blob/40a3aad630ab40735a5221a1d96118697317a414/lantern/plotting/plotutils.py#L93-L145 | def align_yaxis_np(axes):
"""Align zeros of the two axes, zooming them out by same ratio"""
axes = np.array(axes)
extrema = np.array([ax.get_ylim() for ax in axes])
# reset for divide by zero issues
for i in range(len(extrema)):
if np.isclose(extrema[i, 0], 0.0):
extrema[i, 0] =... | [
"def",
"align_yaxis_np",
"(",
"axes",
")",
":",
"axes",
"=",
"np",
".",
"array",
"(",
"axes",
")",
"extrema",
"=",
"np",
".",
"array",
"(",
"[",
"ax",
".",
"get_ylim",
"(",
")",
"for",
"ax",
"in",
"axes",
"]",
")",
"# reset for divide by zero issues",
... | Align zeros of the two axes, zooming them out by same ratio | [
"Align",
"zeros",
"of",
"the",
"two",
"axes",
"zooming",
"them",
"out",
"by",
"same",
"ratio"
] | python | train | 29.056604 |
mcs07/PubChemPy | pubchempy.py | https://github.com/mcs07/PubChemPy/blob/e3c4f4a9b6120433e5cc3383464c7a79e9b2b86e/pubchempy.py#L1160-L1166 | def from_aid(cls, aid):
"""Retrieve the Assay record for the specified AID.
:param int aid: The PubChem Assay Identifier (AID).
"""
record = json.loads(request(aid, 'aid', 'assay', 'description').read().decode())['PC_AssayContainer'][0]
return cls(record) | [
"def",
"from_aid",
"(",
"cls",
",",
"aid",
")",
":",
"record",
"=",
"json",
".",
"loads",
"(",
"request",
"(",
"aid",
",",
"'aid'",
",",
"'assay'",
",",
"'description'",
")",
".",
"read",
"(",
")",
".",
"decode",
"(",
")",
")",
"[",
"'PC_AssayConta... | Retrieve the Assay record for the specified AID.
:param int aid: The PubChem Assay Identifier (AID). | [
"Retrieve",
"the",
"Assay",
"record",
"for",
"the",
"specified",
"AID",
"."
] | python | train | 41.428571 |
casacore/python-casacore | casacore/measures/__init__.py | https://github.com/casacore/python-casacore/blob/975510861ea005f7919dd9e438b5f98a1682eebe/casacore/measures/__init__.py#L807-L850 | def riseset(self, crd, ev="5deg"):
"""This will give the rise/set times of a source. It needs the
position in the frame, and a time. If the latter is not set, the
current time will be used.
:param crd: a direction measure
:param ev: the elevation limit as a quantity or string
... | [
"def",
"riseset",
"(",
"self",
",",
"crd",
",",
"ev",
"=",
"\"5deg\"",
")",
":",
"a",
"=",
"self",
".",
"rise",
"(",
"crd",
",",
"ev",
")",
"if",
"isinstance",
"(",
"a",
"[",
"'rise'",
"]",
",",
"str",
")",
":",
"return",
"{",
"\"rise\"",
":",
... | This will give the rise/set times of a source. It needs the
position in the frame, and a time. If the latter is not set, the
current time will be used.
:param crd: a direction measure
:param ev: the elevation limit as a quantity or string
:returns: The returned value is a `dict`... | [
"This",
"will",
"give",
"the",
"rise",
"/",
"set",
"times",
"of",
"a",
"source",
".",
"It",
"needs",
"the",
"position",
"in",
"the",
"frame",
"and",
"a",
"time",
".",
"If",
"the",
"latter",
"is",
"not",
"set",
"the",
"current",
"time",
"will",
"be",
... | python | train | 42.25 |
adewes/blitzdb | blitzdb/backends/file/index.py | https://github.com/adewes/blitzdb/blob/4b459e0bcde9e1f6224dd4e3bea74194586864b0/blitzdb/backends/file/index.py#L212-L232 | def load_from_data(self, data, with_undefined=False):
"""Load index structure.
:param with_undefined: Load undefined keys as well
:type with_undefined: bool
"""
if with_undefined:
defined_values, undefined_values = data
else:
defined_values = dat... | [
"def",
"load_from_data",
"(",
"self",
",",
"data",
",",
"with_undefined",
"=",
"False",
")",
":",
"if",
"with_undefined",
":",
"defined_values",
",",
"undefined_values",
"=",
"data",
"else",
":",
"defined_values",
"=",
"data",
"undefined_values",
"=",
"None",
... | Load index structure.
:param with_undefined: Load undefined keys as well
:type with_undefined: bool | [
"Load",
"index",
"structure",
"."
] | python | train | 34.904762 |
wuher/devil | devil/resource.py | https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/resource.py#L316-L334 | def _create_object(self, data, request):
""" Create a python object from the given data.
This will use ``self.factory`` object's ``create()`` function to
create the data.
If no factory is defined, this will simply return the same data
that was given.
"""
if req... | [
"def",
"_create_object",
"(",
"self",
",",
"data",
",",
"request",
")",
":",
"if",
"request",
".",
"method",
".",
"upper",
"(",
")",
"==",
"'POST'",
"and",
"self",
".",
"post_factory",
":",
"fac_func",
"=",
"self",
".",
"post_factory",
".",
"create",
"... | Create a python object from the given data.
This will use ``self.factory`` object's ``create()`` function to
create the data.
If no factory is defined, this will simply return the same data
that was given. | [
"Create",
"a",
"python",
"object",
"from",
"the",
"given",
"data",
"."
] | python | train | 31.105263 |
Hackerfleet/hfos | modules/robot/hfos/robot/machineroom.py | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/robot/hfos/robot/machineroom.py#L172-L188 | def opened(self, *args):
"""Initiates communication with the remote controlled device.
:param args:
"""
self._serial_open = True
self.log("Opened: ", args, lvl=debug)
self._send_command(b'l,1') # Saying hello, shortly
self.log("Turning off engine, pump and neut... | [
"def",
"opened",
"(",
"self",
",",
"*",
"args",
")",
":",
"self",
".",
"_serial_open",
"=",
"True",
"self",
".",
"log",
"(",
"\"Opened: \"",
",",
"args",
",",
"lvl",
"=",
"debug",
")",
"self",
".",
"_send_command",
"(",
"b'l,1'",
")",
"# Saying hello, ... | Initiates communication with the remote controlled device.
:param args: | [
"Initiates",
"communication",
"with",
"the",
"remote",
"controlled",
"device",
"."
] | python | train | 37.058824 |
HewlettPackard/python-hpOneView | hpOneView/resources/resource.py | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/resource.py#L422-L444 | def delete(self, uri, force=False, timeout=-1, custom_headers=None):
"""Deletes current resource.
Args:
force: Flag to delete the resource forcefully, default is False.
timeout: Timeout in seconds.
custom_headers: Allows to set custom http headers.
"""
... | [
"def",
"delete",
"(",
"self",
",",
"uri",
",",
"force",
"=",
"False",
",",
"timeout",
"=",
"-",
"1",
",",
"custom_headers",
"=",
"None",
")",
":",
"if",
"force",
":",
"uri",
"+=",
"'?force=True'",
"logger",
".",
"debug",
"(",
"\"Delete resource (uri = %s... | Deletes current resource.
Args:
force: Flag to delete the resource forcefully, default is False.
timeout: Timeout in seconds.
custom_headers: Allows to set custom http headers. | [
"Deletes",
"current",
"resource",
"."
] | python | train | 31.565217 |
MrYsLab/pymata-aio | pymata_aio/pymata_core.py | https://github.com/MrYsLab/pymata-aio/blob/015081a4628b9d47dfe3f8d6c698ff903f107810/pymata_aio/pymata_core.py#L1281-L1296 | async def stepper_config(self, steps_per_revolution, stepper_pins):
"""
Configure stepper motor prior to operation.
This is a FirmataPlus feature.
:param steps_per_revolution: number of steps per motor revolution
:param stepper_pins: a list of control pin numbers - either 4 or ... | [
"async",
"def",
"stepper_config",
"(",
"self",
",",
"steps_per_revolution",
",",
"stepper_pins",
")",
":",
"data",
"=",
"[",
"PrivateConstants",
".",
"STEPPER_CONFIGURE",
",",
"steps_per_revolution",
"&",
"0x7f",
",",
"(",
"steps_per_revolution",
">>",
"7",
")",
... | Configure stepper motor prior to operation.
This is a FirmataPlus feature.
:param steps_per_revolution: number of steps per motor revolution
:param stepper_pins: a list of control pin numbers - either 4 or 2
:returns: No return value. | [
"Configure",
"stepper",
"motor",
"prior",
"to",
"operation",
".",
"This",
"is",
"a",
"FirmataPlus",
"feature",
"."
] | python | train | 40.1875 |
bitesofcode/projexui | projexui/widgets/xviewwidget/xviewpanel.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xviewwidget/xviewpanel.py#L576-L590 | def setCurrentIndex(self, index):
"""
Sets the current item to the item at the inputed index.
:param index | <int>
"""
if self._currentIndex == index:
return
self._currentIndex = index
self.currentIndexChanged.emit(index)
for i, item in... | [
"def",
"setCurrentIndex",
"(",
"self",
",",
"index",
")",
":",
"if",
"self",
".",
"_currentIndex",
"==",
"index",
":",
"return",
"self",
".",
"_currentIndex",
"=",
"index",
"self",
".",
"currentIndexChanged",
".",
"emit",
"(",
"index",
")",
"for",
"i",
"... | Sets the current item to the item at the inputed index.
:param index | <int> | [
"Sets",
"the",
"current",
"item",
"to",
"the",
"item",
"at",
"the",
"inputed",
"index",
"."
] | python | train | 26.533333 |
tensorforce/tensorforce | tensorforce/core/optimizers/solvers/solver.py | https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/optimizers/solvers/solver.py#L48-L56 | def from_config(config, kwargs=None):
"""
Creates a solver from a specification dict.
"""
return util.get_object(
obj=config,
predefined=tensorforce.core.optimizers.solvers.solvers,
kwargs=kwargs
) | [
"def",
"from_config",
"(",
"config",
",",
"kwargs",
"=",
"None",
")",
":",
"return",
"util",
".",
"get_object",
"(",
"obj",
"=",
"config",
",",
"predefined",
"=",
"tensorforce",
".",
"core",
".",
"optimizers",
".",
"solvers",
".",
"solvers",
",",
"kwargs... | Creates a solver from a specification dict. | [
"Creates",
"a",
"solver",
"from",
"a",
"specification",
"dict",
"."
] | python | valid | 29.444444 |
bcbio/bcbio-nextgen | bcbio/install.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/install.py#L128-L134 | def _set_pip_ssl(anaconda_dir):
"""Set PIP SSL certificate to installed conda certificate to avoid SSL errors
"""
if anaconda_dir:
cert_file = os.path.join(anaconda_dir, "ssl", "cert.pem")
if os.path.exists(cert_file):
os.environ["PIP_CERT"] = cert_file | [
"def",
"_set_pip_ssl",
"(",
"anaconda_dir",
")",
":",
"if",
"anaconda_dir",
":",
"cert_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"anaconda_dir",
",",
"\"ssl\"",
",",
"\"cert.pem\"",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"cert_file",
")... | Set PIP SSL certificate to installed conda certificate to avoid SSL errors | [
"Set",
"PIP",
"SSL",
"certificate",
"to",
"installed",
"conda",
"certificate",
"to",
"avoid",
"SSL",
"errors"
] | python | train | 41 |
openstates/billy | billy/importers/bills.py | https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/importers/bills.py#L175-L385 | def import_bill(data, standalone_votes, categorizer):
"""
insert or update a bill
data - raw bill JSON
standalone_votes - votes scraped separately
categorizer - SubjectCategorizer (None - no categorization)
"""
abbr = data[settings.LEVEL_FIELD]
# clean up bill_ids
d... | [
"def",
"import_bill",
"(",
"data",
",",
"standalone_votes",
",",
"categorizer",
")",
":",
"abbr",
"=",
"data",
"[",
"settings",
".",
"LEVEL_FIELD",
"]",
"# clean up bill_ids",
"data",
"[",
"'bill_id'",
"]",
"=",
"fix_bill_id",
"(",
"data",
"[",
"'bill_id'",
... | insert or update a bill
data - raw bill JSON
standalone_votes - votes scraped separately
categorizer - SubjectCategorizer (None - no categorization) | [
"insert",
"or",
"update",
"a",
"bill"
] | python | train | 35.298578 |
LionelAuroux/pyrser | pyrser/passes/topython.py | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/passes/topython.py#L35-L47 | def _clause(self, pt: parsing.ParserTree) -> [ast.stmt]:
"""Normalize a test expression into a statements list.
Statements list are returned as-is.
Expression is packaged as:
if not expr:
return False
"""
if isinstance(pt, list):
return pt
... | [
"def",
"_clause",
"(",
"self",
",",
"pt",
":",
"parsing",
".",
"ParserTree",
")",
"->",
"[",
"ast",
".",
"stmt",
"]",
":",
"if",
"isinstance",
"(",
"pt",
",",
"list",
")",
":",
"return",
"pt",
"return",
"[",
"ast",
".",
"If",
"(",
"ast",
".",
"... | Normalize a test expression into a statements list.
Statements list are returned as-is.
Expression is packaged as:
if not expr:
return False | [
"Normalize",
"a",
"test",
"expression",
"into",
"a",
"statements",
"list",
"."
] | python | test | 32.692308 |
pyroscope/pyrocore | src/pyrocore/torrent/engine.py | https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/torrent/engine.py#L614-L627 | def _check_hash_view(self):
""" Return infohash if view name refers to a single item, else None.
"""
infohash = None
if self.viewname.startswith('#'):
infohash = self.viewname[1:]
elif len(self.viewname) == 40:
try:
int(self.viewname, 16)
... | [
"def",
"_check_hash_view",
"(",
"self",
")",
":",
"infohash",
"=",
"None",
"if",
"self",
".",
"viewname",
".",
"startswith",
"(",
"'#'",
")",
":",
"infohash",
"=",
"self",
".",
"viewname",
"[",
"1",
":",
"]",
"elif",
"len",
"(",
"self",
".",
"viewnam... | Return infohash if view name refers to a single item, else None. | [
"Return",
"infohash",
"if",
"view",
"name",
"refers",
"to",
"a",
"single",
"item",
"else",
"None",
"."
] | python | train | 32.357143 |
PyMySQL/Tornado-MySQL | tornado_mysql/cursors.py | https://github.com/PyMySQL/Tornado-MySQL/blob/75d3466e4332e43b2bf853799f1122dec5da60bc/tornado_mysql/cursors.py#L137-L161 | def executemany(self, query, args):
"""Run several data against one query
PyMySQL can execute bulkinsert for query like 'INSERT ... VALUES (%s)'.
In other form of queries, just run :meth:`execute` many times.
"""
if not args:
return
m = RE_INSERT_VALUES.matc... | [
"def",
"executemany",
"(",
"self",
",",
"query",
",",
"args",
")",
":",
"if",
"not",
"args",
":",
"return",
"m",
"=",
"RE_INSERT_VALUES",
".",
"match",
"(",
"query",
")",
"if",
"m",
":",
"q_prefix",
"=",
"m",
".",
"group",
"(",
"1",
")",
"q_values"... | Run several data against one query
PyMySQL can execute bulkinsert for query like 'INSERT ... VALUES (%s)'.
In other form of queries, just run :meth:`execute` many times. | [
"Run",
"several",
"data",
"against",
"one",
"query"
] | python | train | 36.96 |
CSchoel/nolds | nolds/measures.py | https://github.com/CSchoel/nolds/blob/8a5ecc472d67ac08b571bd68967287668ca9058e/nolds/measures.py#L1070-L1260 | def hurst_rs(data, nvals=None, fit="RANSAC", debug_plot=False,
debug_data=False, plot_file=None, corrected=True, unbiased=True):
"""
Calculates the Hurst exponent by a standard rescaled range (R/S) approach.
Explanation of Hurst exponent:
The Hurst exponent is a measure for the "long-term memory... | [
"def",
"hurst_rs",
"(",
"data",
",",
"nvals",
"=",
"None",
",",
"fit",
"=",
"\"RANSAC\"",
",",
"debug_plot",
"=",
"False",
",",
"debug_data",
"=",
"False",
",",
"plot_file",
"=",
"None",
",",
"corrected",
"=",
"True",
",",
"unbiased",
"=",
"True",
")",... | Calculates the Hurst exponent by a standard rescaled range (R/S) approach.
Explanation of Hurst exponent:
The Hurst exponent is a measure for the "long-term memory" of a
time series, meaning the long statistical dependencies in the data that do
not originate from cycles.
It originates from H.E. Hurs... | [
"Calculates",
"the",
"Hurst",
"exponent",
"by",
"a",
"standard",
"rescaled",
"range",
"(",
"R",
"/",
"S",
")",
"approach",
"."
] | python | train | 49.47644 |
inveniosoftware/invenio-files-rest | invenio_files_rest/serializer.py | https://github.com/inveniosoftware/invenio-files-rest/blob/59a950da61cc8d5882a03c6fde6db2e2ed10befd/invenio_files_rest/serializer.py#L100-L109 | def wrap(self, data, many):
"""Wrap response in envelope."""
if not many:
return data
else:
data = {'contents': data}
bucket = self.context.get('bucket')
if bucket:
data.update(BucketSchema().dump(bucket).data)
return da... | [
"def",
"wrap",
"(",
"self",
",",
"data",
",",
"many",
")",
":",
"if",
"not",
"many",
":",
"return",
"data",
"else",
":",
"data",
"=",
"{",
"'contents'",
":",
"data",
"}",
"bucket",
"=",
"self",
".",
"context",
".",
"get",
"(",
"'bucket'",
")",
"i... | Wrap response in envelope. | [
"Wrap",
"response",
"in",
"envelope",
"."
] | python | train | 31.3 |
saltstack/salt | salt/states/alternatives.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/alternatives.py#L106-L159 | def remove(name, path):
'''
Removes installed alternative for defined <name> and <path>
or fallback to default alternative, if some defined before.
name
is the master name for this link group
(e.g. pager)
path
is the location of one of the alternative target files.
... | [
"def",
"remove",
"(",
"name",
",",
"path",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'path'",
":",
"path",
",",
"'result'",
":",
"True",
",",
"'changes'",
":",
"{",
"}",
",",
"'comment'",
":",
"''",
"}",
"isinstalled",
"=",
"__salt__"... | Removes installed alternative for defined <name> and <path>
or fallback to default alternative, if some defined before.
name
is the master name for this link group
(e.g. pager)
path
is the location of one of the alternative target files.
(e.g. /usr/bin/less) | [
"Removes",
"installed",
"alternative",
"for",
"defined",
"<name",
">",
"and",
"<path",
">",
"or",
"fallback",
"to",
"default",
"alternative",
"if",
"some",
"defined",
"before",
"."
] | python | train | 29.296296 |
SectorLabs/django-postgres-extra | psqlextra/backend/hstore_unique.py | https://github.com/SectorLabs/django-postgres-extra/blob/eef2ed5504d225858d4e4f5d77a838082ca6053e/psqlextra/backend/hstore_unique.py#L66-L74 | def remove_field(self, model, field):
"""Ran when a field is removed from a model."""
for keys in self._iterate_uniqueness_keys(field):
self._drop_hstore_unique(
model,
field,
keys
) | [
"def",
"remove_field",
"(",
"self",
",",
"model",
",",
"field",
")",
":",
"for",
"keys",
"in",
"self",
".",
"_iterate_uniqueness_keys",
"(",
"field",
")",
":",
"self",
".",
"_drop_hstore_unique",
"(",
"model",
",",
"field",
",",
"keys",
")"
] | Ran when a field is removed from a model. | [
"Ran",
"when",
"a",
"field",
"is",
"removed",
"from",
"a",
"model",
"."
] | python | test | 29.222222 |
brandon-rhodes/logging_tree | logging_tree/nodes.py | https://github.com/brandon-rhodes/logging_tree/blob/8513cf85b3bf8ff1b58e54c73718a41ef6524a4c/logging_tree/nodes.py#L5-L25 | def tree():
"""Return a tree of tuples representing the logger layout.
Each tuple looks like ``('logger-name', <Logger>, [...])`` where the
third element is a list of zero or more child tuples that share the
same layout.
"""
root = ('', logging.root, [])
nodes = {}
items = list(logging... | [
"def",
"tree",
"(",
")",
":",
"root",
"=",
"(",
"''",
",",
"logging",
".",
"root",
",",
"[",
"]",
")",
"nodes",
"=",
"{",
"}",
"items",
"=",
"list",
"(",
"logging",
".",
"root",
".",
"manager",
".",
"loggerDict",
".",
"items",
"(",
")",
")",
... | Return a tree of tuples representing the logger layout.
Each tuple looks like ``('logger-name', <Logger>, [...])`` where the
third element is a list of zero or more child tuples that share the
same layout. | [
"Return",
"a",
"tree",
"of",
"tuples",
"representing",
"the",
"logger",
"layout",
"."
] | python | train | 32.142857 |
gitpython-developers/GitPython | git/compat.py | https://github.com/gitpython-developers/GitPython/blob/1f66e25c25cde2423917ee18c4704fff83b837d1/git/compat.py#L67-L74 | def safe_decode(s):
"""Safely decodes a binary string to unicode"""
if isinstance(s, unicode):
return s
elif isinstance(s, bytes):
return s.decode(defenc, 'surrogateescape')
elif s is not None:
raise TypeError('Expected bytes or text, but got %r' % (s,)) | [
"def",
"safe_decode",
"(",
"s",
")",
":",
"if",
"isinstance",
"(",
"s",
",",
"unicode",
")",
":",
"return",
"s",
"elif",
"isinstance",
"(",
"s",
",",
"bytes",
")",
":",
"return",
"s",
".",
"decode",
"(",
"defenc",
",",
"'surrogateescape'",
")",
"elif... | Safely decodes a binary string to unicode | [
"Safely",
"decodes",
"a",
"binary",
"string",
"to",
"unicode"
] | python | train | 35.875 |
knagra/farnsworth | managers/views.py | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/managers/views.py#L138-L150 | def add_manager_view(request):
''' View to add a new manager position. Restricted to superadmins and presidents. '''
form = ManagerForm(request.POST or None)
if form.is_valid():
manager = form.save()
messages.add_message(request, messages.SUCCESS,
MESSAGES['MANAG... | [
"def",
"add_manager_view",
"(",
"request",
")",
":",
"form",
"=",
"ManagerForm",
"(",
"request",
".",
"POST",
"or",
"None",
")",
"if",
"form",
".",
"is_valid",
"(",
")",
":",
"manager",
"=",
"form",
".",
"save",
"(",
")",
"messages",
".",
"add_message"... | View to add a new manager position. Restricted to superadmins and presidents. | [
"View",
"to",
"add",
"a",
"new",
"manager",
"position",
".",
"Restricted",
"to",
"superadmins",
"and",
"presidents",
"."
] | python | train | 49.230769 |
GetmeUK/MongoFrames | mongoframes/queries.py | https://github.com/GetmeUK/MongoFrames/blob/7d2bd792235dfa77a9deecab5366f5f73480823d/mongoframes/queries.py#L135-L144 | def ElemMatch(q, *conditions):
"""
The ElemMatch operator matches documents that contain an array field with at
least one element that matches all the specified query criteria.
"""
new_condition = {}
for condition in conditions:
deep_merge(condition.to_dict(), new_condition)
return ... | [
"def",
"ElemMatch",
"(",
"q",
",",
"*",
"conditions",
")",
":",
"new_condition",
"=",
"{",
"}",
"for",
"condition",
"in",
"conditions",
":",
"deep_merge",
"(",
"condition",
".",
"to_dict",
"(",
")",
",",
"new_condition",
")",
"return",
"Condition",
"(",
... | The ElemMatch operator matches documents that contain an array field with at
least one element that matches all the specified query criteria. | [
"The",
"ElemMatch",
"operator",
"matches",
"documents",
"that",
"contain",
"an",
"array",
"field",
"with",
"at",
"least",
"one",
"element",
"that",
"matches",
"all",
"the",
"specified",
"query",
"criteria",
"."
] | python | train | 35.8 |
mikedh/trimesh | trimesh/intersections.py | https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/intersections.py#L192-L281 | def mesh_multiplane(mesh,
plane_origin,
plane_normal,
heights):
"""
A utility function for slicing a mesh by multiple
parallel planes, which caches the dot product operation.
Parameters
-------------
mesh : trimesh.Trimesh
Geom... | [
"def",
"mesh_multiplane",
"(",
"mesh",
",",
"plane_origin",
",",
"plane_normal",
",",
"heights",
")",
":",
"# check input plane",
"plane_normal",
"=",
"util",
".",
"unitize",
"(",
"plane_normal",
")",
"plane_origin",
"=",
"np",
".",
"asanyarray",
"(",
"plane_ori... | A utility function for slicing a mesh by multiple
parallel planes, which caches the dot product operation.
Parameters
-------------
mesh : trimesh.Trimesh
Geometry to be sliced by planes
plane_normal : (3,) float
Normal vector of plane
plane_origin : (3,) float
Point on ... | [
"A",
"utility",
"function",
"for",
"slicing",
"a",
"mesh",
"by",
"multiple",
"parallel",
"planes",
"which",
"caches",
"the",
"dot",
"product",
"operation",
"."
] | python | train | 33.422222 |
jxtech/wechatpy | wechatpy/enterprise/client/api/agent.py | https://github.com/jxtech/wechatpy/blob/4df0da795618c0895a10f1c2cde9e9d5c0a93aaa/wechatpy/enterprise/client/api/agent.py#L39-L74 | def set(self,
agent_id,
name=None,
description=None,
redirect_domain=None,
logo_media_id=None,
report_location_flag=0,
is_report_user=True,
is_report_enter=True):
"""
设置应用
https://work.weixin.qq.com/a... | [
"def",
"set",
"(",
"self",
",",
"agent_id",
",",
"name",
"=",
"None",
",",
"description",
"=",
"None",
",",
"redirect_domain",
"=",
"None",
",",
"logo_media_id",
"=",
"None",
",",
"report_location_flag",
"=",
"0",
",",
"is_report_user",
"=",
"True",
",",
... | 设置应用
https://work.weixin.qq.com/api/doc#90000/90135/90228
:param agent_id: 企业应用的id
:param name: 企业应用名称,长度不超过32个utf8字符
:param description: 企业应用详情,长度为4至120个utf8字符
:param redirect_domain: 企业应用可信域名。注意:域名需通过所有权校验,否则jssdk功能将受限,此时返回错误码85005
:param logo_media_id: 企业应用头像的mediaid,... | [
"设置应用",
"https",
":",
"//",
"work",
".",
"weixin",
".",
"qq",
".",
"com",
"/",
"api",
"/",
"doc#90000",
"/",
"90135",
"/",
"90228"
] | python | train | 38.25 |
alex-kostirin/pyatomac | atomac/AXClasses.py | https://github.com/alex-kostirin/pyatomac/blob/3f46f6feb4504315eec07abb18bb41be4d257aeb/atomac/AXClasses.py#L845-L853 | def _activate(self):
"""Activate the application (bringing menus and windows forward)."""
ra = AppKit.NSRunningApplication
app = ra.runningApplicationWithProcessIdentifier_(
self._getPid())
# NSApplicationActivateAllWindows | NSApplicationActivateIgnoringOtherApps
# =... | [
"def",
"_activate",
"(",
"self",
")",
":",
"ra",
"=",
"AppKit",
".",
"NSRunningApplication",
"app",
"=",
"ra",
".",
"runningApplicationWithProcessIdentifier_",
"(",
"self",
".",
"_getPid",
"(",
")",
")",
"# NSApplicationActivateAllWindows | NSApplicationActivateIgnoring... | Activate the application (bringing menus and windows forward). | [
"Activate",
"the",
"application",
"(",
"bringing",
"menus",
"and",
"windows",
"forward",
")",
"."
] | python | valid | 52.444444 |
evolbioinfo/pastml | pastml/ml.py | https://github.com/evolbioinfo/pastml/blob/df8a375841525738383e59548eed3441b07dbd3e/pastml/ml.py#L251-L306 | def calculate_top_down_likelihood(tree, character, frequencies, sf, kappa=None, model=F81):
"""
Calculates the top-down likelihood for the given tree.
The likelihood for each node is stored in the corresponding feature,
given by get_personalised_feature_name(feature, TD_LH).
To calculate the top-do... | [
"def",
"calculate_top_down_likelihood",
"(",
"tree",
",",
"character",
",",
"frequencies",
",",
"sf",
",",
"kappa",
"=",
"None",
",",
"model",
"=",
"F81",
")",
":",
"lh_feature",
"=",
"get_personalized_feature_name",
"(",
"character",
",",
"TD_LH",
")",
"lh_sf... | Calculates the top-down likelihood for the given tree.
The likelihood for each node is stored in the corresponding feature,
given by get_personalised_feature_name(feature, TD_LH).
To calculate the top-down likelihood of a node, we assume that the tree is rooted in this node
and combine the likelihoods ... | [
"Calculates",
"the",
"top",
"-",
"down",
"likelihood",
"for",
"the",
"given",
"tree",
".",
"The",
"likelihood",
"for",
"each",
"node",
"is",
"stored",
"in",
"the",
"corresponding",
"feature",
"given",
"by",
"get_personalised_feature_name",
"(",
"feature",
"TD_LH... | python | train | 50.035714 |
clalancette/pycdlib | pycdlib/eltorito.py | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/eltorito.py#L306-L339 | def parse(self, valstr):
# type: (bytes) -> None
'''
A method to parse an El Torito Entry out of a string.
Parameters:
valstr - The string to parse the El Torito Entry out of.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlib... | [
"def",
"parse",
"(",
"self",
",",
"valstr",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'El Torito Entry already initialized'",
")",
"(",
"self",
".",
"boot_indicator",
... | A method to parse an El Torito Entry out of a string.
Parameters:
valstr - The string to parse the El Torito Entry out of.
Returns:
Nothing. | [
"A",
"method",
"to",
"parse",
"an",
"El",
"Torito",
"Entry",
"out",
"of",
"a",
"string",
"."
] | python | train | 40.617647 |
jmgilman/Neolib | neolib/pyamf/codec.py | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/codec.py#L411-L421 | def writeGenerator(self, gen):
"""
Iterates over a generator object and encodes all that is returned.
"""
n = getattr(gen, 'next')
while True:
try:
self.writeElement(n())
except StopIteration:
break | [
"def",
"writeGenerator",
"(",
"self",
",",
"gen",
")",
":",
"n",
"=",
"getattr",
"(",
"gen",
",",
"'next'",
")",
"while",
"True",
":",
"try",
":",
"self",
".",
"writeElement",
"(",
"n",
"(",
")",
")",
"except",
"StopIteration",
":",
"break"
] | Iterates over a generator object and encodes all that is returned. | [
"Iterates",
"over",
"a",
"generator",
"object",
"and",
"encodes",
"all",
"that",
"is",
"returned",
"."
] | python | train | 25.909091 |
aiogram/aiogram | aiogram/dispatcher/dispatcher.py | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/dispatcher.py#L844-L858 | def errors_handler(self, *custom_filters, exception=None, run_task=None, **kwargs):
"""
Decorator for errors handler
:param exception: you can make handler for specific errors type
:param run_task: run callback in task (no wait results)
:return:
"""
def decorato... | [
"def",
"errors_handler",
"(",
"self",
",",
"*",
"custom_filters",
",",
"exception",
"=",
"None",
",",
"run_task",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"decorator",
"(",
"callback",
")",
":",
"self",
".",
"register_errors_handler",
"(",
... | Decorator for errors handler
:param exception: you can make handler for specific errors type
:param run_task: run callback in task (no wait results)
:return: | [
"Decorator",
"for",
"errors",
"handler"
] | python | train | 36.333333 |
cloud-custodian/cloud-custodian | c7n/sqsexec.py | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/sqsexec.py#L56-L78 | def submit(self, func, *args, **kwargs):
"""Submit a function for serialized execution on sqs
"""
self.op_sequence += 1
self.sqs.send_message(
QueueUrl=self.map_queue,
MessageBody=utils.dumps({'args': args, 'kwargs': kwargs}),
MessageAttributes={
... | [
"def",
"submit",
"(",
"self",
",",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"op_sequence",
"+=",
"1",
"self",
".",
"sqs",
".",
"send_message",
"(",
"QueueUrl",
"=",
"self",
".",
"map_queue",
",",
"MessageBody",
"=",
... | Submit a function for serialized execution on sqs | [
"Submit",
"a",
"function",
"for",
"serialized",
"execution",
"on",
"sqs"
] | python | train | 34.086957 |
pyvisa/pyvisa | pyvisa/resources/resource.py | https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/resources/resource.py#L303-L310 | def disable_event(self, event_type, mechanism):
"""Disables notification of the specified event type(s) via the specified mechanism(s).
:param event_type: Logical event identifier.
:param mechanism: Specifies event handling mechanisms to be disabled.
(Constants.VI_QUEU... | [
"def",
"disable_event",
"(",
"self",
",",
"event_type",
",",
"mechanism",
")",
":",
"self",
".",
"visalib",
".",
"disable_event",
"(",
"self",
".",
"session",
",",
"event_type",
",",
"mechanism",
")"
] | Disables notification of the specified event type(s) via the specified mechanism(s).
:param event_type: Logical event identifier.
:param mechanism: Specifies event handling mechanisms to be disabled.
(Constants.VI_QUEUE, .VI_HNDLR, .VI_SUSPEND_HNDLR, .VI_ALL_MECH) | [
"Disables",
"notification",
"of",
"the",
"specified",
"event",
"type",
"(",
"s",
")",
"via",
"the",
"specified",
"mechanism",
"(",
"s",
")",
"."
] | python | train | 55.375 |
LCAV/pylocus | pylocus/mds.py | https://github.com/LCAV/pylocus/blob/c56a38c251d8a435caf4641a8ae6027ecba2c8c6/pylocus/mds.py#L112-L142 | def relaxedEMDS(X0, N, d, C, b, KE, print_out=False, lamda=10):
""" Find the set of points from an edge kernel with geometric constraints, using convex rank relaxation.
"""
E = C.shape[1]
X = Variable((E, E), PSD=True)
constraints = [C[i, :] * X == b[i] for i in range(C.shape[0])]
obj = Minimi... | [
"def",
"relaxedEMDS",
"(",
"X0",
",",
"N",
",",
"d",
",",
"C",
",",
"b",
",",
"KE",
",",
"print_out",
"=",
"False",
",",
"lamda",
"=",
"10",
")",
":",
"E",
"=",
"C",
".",
"shape",
"[",
"1",
"]",
"X",
"=",
"Variable",
"(",
"(",
"E",
",",
"... | Find the set of points from an edge kernel with geometric constraints, using convex rank relaxation. | [
"Find",
"the",
"set",
"of",
"points",
"from",
"an",
"edge",
"kernel",
"with",
"geometric",
"constraints",
"using",
"convex",
"rank",
"relaxation",
"."
] | python | train | 41.774194 |
mitsei/dlkit | dlkit/records/assessment/basic/drag_and_drop_records.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/records/assessment/basic/drag_and_drop_records.py#L1202-L1218 | def set_zone_order(self, zone_ids):
""" reorder zones per the passed in list
:param zone_ids:
:return:
"""
reordered_zones = []
current_zone_ids = [z['id'] for z in self.my_osid_object_form._my_map['zones']]
if set(zone_ids) != set(current_zone_ids):
r... | [
"def",
"set_zone_order",
"(",
"self",
",",
"zone_ids",
")",
":",
"reordered_zones",
"=",
"[",
"]",
"current_zone_ids",
"=",
"[",
"z",
"[",
"'id'",
"]",
"for",
"z",
"in",
"self",
".",
"my_osid_object_form",
".",
"_my_map",
"[",
"'zones'",
"]",
"]",
"if",
... | reorder zones per the passed in list
:param zone_ids:
:return: | [
"reorder",
"zones",
"per",
"the",
"passed",
"in",
"list",
":",
"param",
"zone_ids",
":",
":",
"return",
":"
] | python | train | 39.529412 |
getsentry/raven-python | raven/utils/stacks.py | https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/utils/stacks.py#L111-L125 | def iter_traceback_frames(tb):
"""
Given a traceback object, it will iterate over all
frames that do not contain the ``__traceback_hide__``
local variable.
"""
# Some versions of celery have hacked traceback objects that might
# miss tb_frame.
while tb and hasattr(tb, 'tb_frame'):
... | [
"def",
"iter_traceback_frames",
"(",
"tb",
")",
":",
"# Some versions of celery have hacked traceback objects that might",
"# miss tb_frame.",
"while",
"tb",
"and",
"hasattr",
"(",
"tb",
",",
"'tb_frame'",
")",
":",
"# support for __traceback_hide__ which is used by a few librari... | Given a traceback object, it will iterate over all
frames that do not contain the ``__traceback_hide__``
local variable. | [
"Given",
"a",
"traceback",
"object",
"it",
"will",
"iterate",
"over",
"all",
"frames",
"that",
"do",
"not",
"contain",
"the",
"__traceback_hide__",
"local",
"variable",
"."
] | python | train | 41.2 |
toumorokoshi/transmute-core | transmute_core/function/transmute_function.py | https://github.com/toumorokoshi/transmute-core/blob/a2c26625d5d8bab37e00038f9d615a26167fc7f4/transmute_core/function/transmute_function.py#L89-L128 | def get_swagger_operation(self, context=default_context):
"""
get the swagger_schema operation representation.
"""
consumes = produces = context.contenttype_serializers.keys()
parameters = get_swagger_parameters(self.parameters, context)
responses = {
"400": R... | [
"def",
"get_swagger_operation",
"(",
"self",
",",
"context",
"=",
"default_context",
")",
":",
"consumes",
"=",
"produces",
"=",
"context",
".",
"contenttype_serializers",
".",
"keys",
"(",
")",
"parameters",
"=",
"get_swagger_parameters",
"(",
"self",
".",
"par... | get the swagger_schema operation representation. | [
"get",
"the",
"swagger_schema",
"operation",
"representation",
"."
] | python | train | 35.5 |
cloudant/python-cloudant | src/cloudant/design_document.py | https://github.com/cloudant/python-cloudant/blob/e0ba190f6ba07fe3522a668747128214ad573c7e/src/cloudant/design_document.py#L399-L410 | def update_list_function(self, list_name, list_func):
"""
Modifies/overwrites an existing list function in the
locally cached DesignDocument indexes dictionary.
:param str list_name: Name used to identify the list function.
:param str list_func: Javascript list function.
... | [
"def",
"update_list_function",
"(",
"self",
",",
"list_name",
",",
"list_func",
")",
":",
"if",
"self",
".",
"get_list_function",
"(",
"list_name",
")",
"is",
"None",
":",
"raise",
"CloudantArgumentError",
"(",
"113",
",",
"list_name",
")",
"self",
".",
"lis... | Modifies/overwrites an existing list function in the
locally cached DesignDocument indexes dictionary.
:param str list_name: Name used to identify the list function.
:param str list_func: Javascript list function. | [
"Modifies",
"/",
"overwrites",
"an",
"existing",
"list",
"function",
"in",
"the",
"locally",
"cached",
"DesignDocument",
"indexes",
"dictionary",
"."
] | python | train | 40.416667 |
kentwait/nxsim | nxsim/simulation.py | https://github.com/kentwait/nxsim/blob/88090d8099e574bc6fd1d24734cfa205ecce4c1d/nxsim/simulation.py#L49-L55 | def run_simulation(self):
"""Runs the complete simulation"""
print('Starting simulations...')
for i in range(self.num_trials):
print('---Trial {}---'.format(i))
self.run_trial(i)
print('Simulation completed.') | [
"def",
"run_simulation",
"(",
"self",
")",
":",
"print",
"(",
"'Starting simulations...'",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"num_trials",
")",
":",
"print",
"(",
"'---Trial {}---'",
".",
"format",
"(",
"i",
")",
")",
"self",
".",
"run_tr... | Runs the complete simulation | [
"Runs",
"the",
"complete",
"simulation"
] | python | train | 37 |
mrstephenneal/pdfconduit | pdf/gui/config/images.py | https://github.com/mrstephenneal/pdfconduit/blob/993421cc087eefefe01ff09afabd893bcc2718ec/pdf/gui/config/images.py#L25-L29 | def remove(image):
"""Remove an image to the GUI img library."""
path = os.path.join(IMG_DIR, image)
if os.path.isfile(path):
os.remove(path) | [
"def",
"remove",
"(",
"image",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"IMG_DIR",
",",
"image",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"path",
")",
":",
"os",
".",
"remove",
"(",
"path",
")"
] | Remove an image to the GUI img library. | [
"Remove",
"an",
"image",
"to",
"the",
"GUI",
"img",
"library",
"."
] | python | train | 31.4 |
shawnsilva/steamwebapi | steamwebapi/api.py | https://github.com/shawnsilva/steamwebapi/blob/dc16538ebe985cc7ea170f660169ebc2366efbf2/steamwebapi/api.py#L56-L72 | def create_request_url(self, interface, method, version, parameters):
"""Create the URL to submit to the Steam Web API
interface: Steam Web API interface containing methods.
method: The method to call.
version: The version of the method.
paramters: Parameters to supply to the me... | [
"def",
"create_request_url",
"(",
"self",
",",
"interface",
",",
"method",
",",
"version",
",",
"parameters",
")",
":",
"if",
"'format'",
"in",
"parameters",
":",
"parameters",
"[",
"'key'",
"]",
"=",
"self",
".",
"apikey",
"else",
":",
"parameters",
".",
... | Create the URL to submit to the Steam Web API
interface: Steam Web API interface containing methods.
method: The method to call.
version: The version of the method.
paramters: Parameters to supply to the method. | [
"Create",
"the",
"URL",
"to",
"submit",
"to",
"the",
"Steam",
"Web",
"API"
] | python | train | 39.529412 |
brunato/lograptor | lograptor/filemap.py | https://github.com/brunato/lograptor/blob/b1f09fe1b429ed15110610092704ef12d253f3c9/lograptor/filemap.py#L212-L224 | def add(self, files, items):
"""
Add a list of files with a reference to a list of objects.
"""
if isinstance(files, (str, bytes)):
files = iter([files])
for pathname in files:
try:
values = self._filemap[pathname]
except KeyErr... | [
"def",
"add",
"(",
"self",
",",
"files",
",",
"items",
")",
":",
"if",
"isinstance",
"(",
"files",
",",
"(",
"str",
",",
"bytes",
")",
")",
":",
"files",
"=",
"iter",
"(",
"[",
"files",
"]",
")",
"for",
"pathname",
"in",
"files",
":",
"try",
":... | Add a list of files with a reference to a list of objects. | [
"Add",
"a",
"list",
"of",
"files",
"with",
"a",
"reference",
"to",
"a",
"list",
"of",
"objects",
"."
] | python | train | 31.846154 |
SwissDataScienceCenter/renku-python | renku/cli/_group.py | https://github.com/SwissDataScienceCenter/renku-python/blob/691644d695b055a01e0ca22b2620e55bbd928c0d/renku/cli/_group.py#L26-L30 | def parse_args(self, ctx, args):
"""Check if the first argument is an existing command."""
if args and args[0] in self.commands:
args.insert(0, '')
super(OptionalGroup, self).parse_args(ctx, args) | [
"def",
"parse_args",
"(",
"self",
",",
"ctx",
",",
"args",
")",
":",
"if",
"args",
"and",
"args",
"[",
"0",
"]",
"in",
"self",
".",
"commands",
":",
"args",
".",
"insert",
"(",
"0",
",",
"''",
")",
"super",
"(",
"OptionalGroup",
",",
"self",
")",... | Check if the first argument is an existing command. | [
"Check",
"if",
"the",
"first",
"argument",
"is",
"an",
"existing",
"command",
"."
] | python | train | 45.6 |
guaix-ucm/numina | numina/util/objimport.py | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/util/objimport.py#L17-L36 | def import_object(path):
"""Import an object given its fully qualified name."""
spl = path.split('.')
if len(spl) == 1:
return importlib.import_module(path)
# avoid last part for the moment
cls = spl[-1]
mods = '.'.join(spl[:-1])
mm = importlib.import_module(mods)
# try to get t... | [
"def",
"import_object",
"(",
"path",
")",
":",
"spl",
"=",
"path",
".",
"split",
"(",
"'.'",
")",
"if",
"len",
"(",
"spl",
")",
"==",
"1",
":",
"return",
"importlib",
".",
"import_module",
"(",
"path",
")",
"# avoid last part for the moment",
"cls",
"=",... | Import an object given its fully qualified name. | [
"Import",
"an",
"object",
"given",
"its",
"fully",
"qualified",
"name",
"."
] | python | train | 25.8 |
bitesofcode/projexui | projexui/widgets/xorbtreewidget/xorbrecorditem.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbtreewidget/xorbrecorditem.py#L213-L227 | def setDragTable(self, table):
"""
Sets the table that will be linked with the drag query for this
record. This information will be added to the drag & drop information
when this record is dragged from the tree and will be set into
the application/x-table format for mime da... | [
"def",
"setDragTable",
"(",
"self",
",",
"table",
")",
":",
"if",
"table",
"and",
"table",
".",
"schema",
"(",
")",
":",
"self",
".",
"setDragData",
"(",
"'application/x-orb-table'",
",",
"table",
".",
"schema",
"(",
")",
".",
"name",
"(",
")",
")",
... | Sets the table that will be linked with the drag query for this
record. This information will be added to the drag & drop information
when this record is dragged from the tree and will be set into
the application/x-table format for mime data.
:sa setDragQuery, XTreeWid... | [
"Sets",
"the",
"table",
"that",
"will",
"be",
"linked",
"with",
"the",
"drag",
"query",
"for",
"this",
"record",
".",
"This",
"information",
"will",
"be",
"added",
"to",
"the",
"drag",
"&",
"drop",
"information",
"when",
"this",
"record",
"is",
"dragged",
... | python | train | 43.333333 |
rackerlabs/rackspace-python-neutronclient | neutronclient/v2_0/client.py | https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/v2_0/client.py#L1735-L1738 | def remove_peer_from_bgp_speaker(self, speaker_id, body=None):
"""Removes a peer from BGP speaker."""
return self.put((self.bgp_speaker_path % speaker_id) +
"/remove_bgp_peer", body=body) | [
"def",
"remove_peer_from_bgp_speaker",
"(",
"self",
",",
"speaker_id",
",",
"body",
"=",
"None",
")",
":",
"return",
"self",
".",
"put",
"(",
"(",
"self",
".",
"bgp_speaker_path",
"%",
"speaker_id",
")",
"+",
"\"/remove_bgp_peer\"",
",",
"body",
"=",
"body",... | Removes a peer from BGP speaker. | [
"Removes",
"a",
"peer",
"from",
"BGP",
"speaker",
"."
] | python | train | 56 |
StackStorm/pybind | pybind/nos/v6_0_2f/interface/fc_port/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/interface/fc_port/__init__.py#L281-L302 | def _set_desire_distance(self, v, load=False):
"""
Setter method for desire_distance, mapped from YANG variable /interface/fc_port/desire_distance (desire-distance-type)
If this variable is read-only (config: false) in the
source YANG file, then _set_desire_distance is considered as a private
method... | [
"def",
"_set_desire_distance",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
... | Setter method for desire_distance, mapped from YANG variable /interface/fc_port/desire_distance (desire-distance-type)
If this variable is read-only (config: false) in the
source YANG file, then _set_desire_distance is considered as a private
method. Backends looking to populate this variable should
do ... | [
"Setter",
"method",
"for",
"desire_distance",
"mapped",
"from",
"YANG",
"variable",
"/",
"interface",
"/",
"fc_port",
"/",
"desire_distance",
"(",
"desire",
"-",
"distance",
"-",
"type",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"(",
"config"... | python | train | 89.454545 |
hyperledger/indy-plenum | ledger/compact_merkle_tree.py | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/ledger/compact_merkle_tree.py#L82-L88 | def root_hash(self):
"""Returns the root hash of this tree. (Only re-computed on change.)"""
if self.__root_hash is None:
self.__root_hash = (
self.__hasher._hash_fold(self.__hashes)
if self.__hashes else self.__hasher.hash_empty())
return self.__root_... | [
"def",
"root_hash",
"(",
"self",
")",
":",
"if",
"self",
".",
"__root_hash",
"is",
"None",
":",
"self",
".",
"__root_hash",
"=",
"(",
"self",
".",
"__hasher",
".",
"_hash_fold",
"(",
"self",
".",
"__hashes",
")",
"if",
"self",
".",
"__hashes",
"else",
... | Returns the root hash of this tree. (Only re-computed on change.) | [
"Returns",
"the",
"root",
"hash",
"of",
"this",
"tree",
".",
"(",
"Only",
"re",
"-",
"computed",
"on",
"change",
".",
")"
] | python | train | 45.428571 |
raiden-network/raiden | raiden/tasks.py | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/tasks.py#L59-L73 | def check_version(current_version: str):
""" Check periodically for a new release """
app_version = parse_version(current_version)
while True:
try:
_do_check_version(app_version)
except requests.exceptions.HTTPError as herr:
click.secho('Error while checking for versi... | [
"def",
"check_version",
"(",
"current_version",
":",
"str",
")",
":",
"app_version",
"=",
"parse_version",
"(",
"current_version",
")",
"while",
"True",
":",
"try",
":",
"_do_check_version",
"(",
"app_version",
")",
"except",
"requests",
".",
"exceptions",
".",
... | Check periodically for a new release | [
"Check",
"periodically",
"for",
"a",
"new",
"release"
] | python | train | 39.066667 |
great-expectations/great_expectations | great_expectations/data_asset/base.py | https://github.com/great-expectations/great_expectations/blob/08385c40529d4f14a1c46916788aecc47f33ee9d/great_expectations/data_asset/base.py#L355-L395 | def _copy_and_clean_up_expectations_from_indexes(
self,
match_indexes,
discard_result_format_kwargs=True,
discard_include_configs_kwargs=True,
discard_catch_exceptions_kwargs=True,
):
"""Copies and cleans all expectations provided by their index in DataAsset._expectat... | [
"def",
"_copy_and_clean_up_expectations_from_indexes",
"(",
"self",
",",
"match_indexes",
",",
"discard_result_format_kwargs",
"=",
"True",
",",
"discard_include_configs_kwargs",
"=",
"True",
",",
"discard_catch_exceptions_kwargs",
"=",
"True",
",",
")",
":",
"rval",
"=",... | Copies and cleans all expectations provided by their index in DataAsset._expectations_config.expectations.
Applies the _copy_and_clean_up_expectation method to multiple expectations, provided by their index in \
`DataAsset,_expectations_config.expectations`. Returns a list of the copied and clean... | [
"Copies",
"and",
"cleans",
"all",
"expectations",
"provided",
"by",
"their",
"index",
"in",
"DataAsset",
".",
"_expectations_config",
".",
"expectations",
"."
] | python | train | 45.170732 |
lambdalisue/django-permission | src/permission/utils/permissions.py | https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/utils/permissions.py#L12-L34 | def get_perm_codename(perm, fail_silently=True):
"""
Get permission codename from permission-string.
Examples
--------
>>> get_perm_codename('app_label.codename_model')
'codename_model'
>>> get_perm_codename('app_label.codename')
'codename'
>>> get_perm_codename('codename_model')
... | [
"def",
"get_perm_codename",
"(",
"perm",
",",
"fail_silently",
"=",
"True",
")",
":",
"try",
":",
"perm",
"=",
"perm",
".",
"split",
"(",
"'.'",
",",
"1",
")",
"[",
"1",
"]",
"except",
"IndexError",
"as",
"e",
":",
"if",
"not",
"fail_silently",
":",
... | Get permission codename from permission-string.
Examples
--------
>>> get_perm_codename('app_label.codename_model')
'codename_model'
>>> get_perm_codename('app_label.codename')
'codename'
>>> get_perm_codename('codename_model')
'codename_model'
>>> get_perm_codename('codename')
... | [
"Get",
"permission",
"codename",
"from",
"permission",
"-",
"string",
"."
] | python | train | 26.608696 |
SuperCowPowers/bat | setup.py | https://github.com/SuperCowPowers/bat/blob/069e6bc52843dc07760969c531cc442ca7da8e0c/setup.py#L19-L21 | def get_files(dir_name):
"""Simple directory walker"""
return [(os.path.join('.', d), [os.path.join(d, f) for f in files]) for d, _, files in os.walk(dir_name)] | [
"def",
"get_files",
"(",
"dir_name",
")",
":",
"return",
"[",
"(",
"os",
".",
"path",
".",
"join",
"(",
"'.'",
",",
"d",
")",
",",
"[",
"os",
".",
"path",
".",
"join",
"(",
"d",
",",
"f",
")",
"for",
"f",
"in",
"files",
"]",
")",
"for",
"d"... | Simple directory walker | [
"Simple",
"directory",
"walker"
] | python | train | 56 |
hhatto/autopep8 | autopep8.py | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L1079-L1115 | def fix_e712(self, result):
"""Fix (trivial case of) comparison with boolean."""
(line_index, offset, target) = get_index_offset_contents(result,
self.source)
# Handle very easy "not" special cases.
if re.match(r'^\s*if [\... | [
"def",
"fix_e712",
"(",
"self",
",",
"result",
")",
":",
"(",
"line_index",
",",
"offset",
",",
"target",
")",
"=",
"get_index_offset_contents",
"(",
"result",
",",
"self",
".",
"source",
")",
"# Handle very easy \"not\" special cases.",
"if",
"re",
".",
"matc... | Fix (trivial case of) comparison with boolean. | [
"Fix",
"(",
"trivial",
"case",
"of",
")",
"comparison",
"with",
"boolean",
"."
] | python | train | 42.108108 |
rfarley3/Kibana | kibana/mapping.py | https://github.com/rfarley3/Kibana/blob/3df1e13be18edfb39ec173d8d2bbe9e90be61022/kibana/mapping.py#L152-L161 | def field_cache_to_index_pattern(self, field_cache):
"""Return a .kibana index-pattern doc_type"""
mapping_dict = {}
mapping_dict['customFormats'] = "{}"
mapping_dict['title'] = self.index_pattern
# now post the data into .kibana
mapping_dict['fields'] = json.dumps(field_... | [
"def",
"field_cache_to_index_pattern",
"(",
"self",
",",
"field_cache",
")",
":",
"mapping_dict",
"=",
"{",
"}",
"mapping_dict",
"[",
"'customFormats'",
"]",
"=",
"\"{}\"",
"mapping_dict",
"[",
"'title'",
"]",
"=",
"self",
".",
"index_pattern",
"# now post the dat... | Return a .kibana index-pattern doc_type | [
"Return",
"a",
".",
"kibana",
"index",
"-",
"pattern",
"doc_type"
] | python | train | 49.9 |
meejah/txtorcon | txtorcon/onion.py | https://github.com/meejah/txtorcon/blob/14053b95adf0b4bd9dd9c317bece912a26578a93/txtorcon/onion.py#L1320-L1393 | def _validate_ports(reactor, ports):
"""
Internal helper for Onion services. Validates an incoming list of
port mappings and returns a list of strings suitable for passing
to other onion-services functions.
Accepts 3 different ways of specifying ports:
- list of ints: each int is the public ... | [
"def",
"_validate_ports",
"(",
"reactor",
",",
"ports",
")",
":",
"if",
"not",
"isinstance",
"(",
"ports",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"raise",
"ValueError",
"(",
"\"'ports' must be a list of strings, ints or 2-tuples\"",
")",
"processed_ports",... | Internal helper for Onion services. Validates an incoming list of
port mappings and returns a list of strings suitable for passing
to other onion-services functions.
Accepts 3 different ways of specifying ports:
- list of ints: each int is the public port, local port random
- list of 2-tuples ... | [
"Internal",
"helper",
"for",
"Onion",
"services",
".",
"Validates",
"an",
"incoming",
"list",
"of",
"port",
"mappings",
"and",
"returns",
"a",
"list",
"of",
"strings",
"suitable",
"for",
"passing",
"to",
"other",
"onion",
"-",
"services",
"functions",
"."
] | python | train | 36.283784 |
sailthru/sailthru-python-client | sailthru/sailthru_client.py | https://github.com/sailthru/sailthru-python-client/blob/22aa39ba0c5bddd7b8743e24ada331128c0f4f54/sailthru/sailthru_client.py#L356-L365 | def save_list(self, list_name, emails):
"""
Upload a list. The list import job is queued and will happen shortly after the API request.
http://docs.sailthru.com/api/list
@param list: list name
@param emails: List of email values or comma separated string
"""
data ... | [
"def",
"save_list",
"(",
"self",
",",
"list_name",
",",
"emails",
")",
":",
"data",
"=",
"{",
"'list'",
":",
"list_name",
",",
"'emails'",
":",
"','",
".",
"join",
"(",
"emails",
")",
"if",
"isinstance",
"(",
"emails",
",",
"list",
")",
"else",
"emai... | Upload a list. The list import job is queued and will happen shortly after the API request.
http://docs.sailthru.com/api/list
@param list: list name
@param emails: List of email values or comma separated string | [
"Upload",
"a",
"list",
".",
"The",
"list",
"import",
"job",
"is",
"queued",
"and",
"will",
"happen",
"shortly",
"after",
"the",
"API",
"request",
".",
"http",
":",
"//",
"docs",
".",
"sailthru",
".",
"com",
"/",
"api",
"/",
"list"
] | python | train | 45.9 |
MonashBI/arcana | arcana/pipeline/base.py | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/pipeline/base.py#L873-L935 | def expected_record(self, node):
"""
Constructs the provenance record that would be saved in the given node
if the pipeline was run on the current state of the repository
Parameters
----------
node : arcana.repository.tree.TreeNode
A node of the Tree represen... | [
"def",
"expected_record",
"(",
"self",
",",
"node",
")",
":",
"exp_inputs",
"=",
"{",
"}",
"# Get checksums/values of all inputs that would have been used in",
"# previous runs of an equivalent pipeline to compare with that saved",
"# in provenance to see if any have been updated.",
"f... | Constructs the provenance record that would be saved in the given node
if the pipeline was run on the current state of the repository
Parameters
----------
node : arcana.repository.tree.TreeNode
A node of the Tree representation of the study data stored in the
re... | [
"Constructs",
"the",
"provenance",
"record",
"that",
"would",
"be",
"saved",
"in",
"the",
"given",
"node",
"if",
"the",
"pipeline",
"was",
"run",
"on",
"the",
"current",
"state",
"of",
"the",
"repository"
] | python | train | 48.603175 |
CitrineInformatics/python-citrination-client | citrination_client/search/client.py | https://github.com/CitrineInformatics/python-citrination-client/blob/409984fc65ce101a620f069263f155303492465c/citrination_client/search/client.py#L154-L246 | def generate_simple_chemical_query(self, name=None, chemical_formula=None, property_name=None, property_value=None,
property_min=None, property_max=None, property_units=None, reference_doi=None,
include_datasets=[], exclude_datasets=[], from_... | [
"def",
"generate_simple_chemical_query",
"(",
"self",
",",
"name",
"=",
"None",
",",
"chemical_formula",
"=",
"None",
",",
"property_name",
"=",
"None",
",",
"property_value",
"=",
"None",
",",
"property_min",
"=",
"None",
",",
"property_max",
"=",
"None",
","... | This method generates a :class:`PifSystemReturningQuery` object using the
supplied arguments. All arguments that accept lists have logical OR's on the queries that they generate.
This means that, for example, simple_chemical_search(name=['A', 'B']) will match records that have name
equal to 'A' ... | [
"This",
"method",
"generates",
"a",
":",
"class",
":",
"PifSystemReturningQuery",
"object",
"using",
"the",
"supplied",
"arguments",
".",
"All",
"arguments",
"that",
"accept",
"lists",
"have",
"logical",
"OR",
"s",
"on",
"the",
"queries",
"that",
"they",
"gene... | python | valid | 54.677419 |
nsqio/pynsq | nsq/reader.py | https://github.com/nsqio/pynsq/blob/48bf62d65ea63cddaa401efb23187b95511dbc84/nsq/reader.py#L706-L715 | def giving_up(self, message):
"""
Called when a message has been received where ``msg.attempts > max_tries``
This is useful to subclass and override to perform a task (such as writing to disk, etc.)
:param message: the :class:`nsq.Message` received
"""
logger.warning('[... | [
"def",
"giving_up",
"(",
"self",
",",
"message",
")",
":",
"logger",
".",
"warning",
"(",
"'[%s] giving up on message %s after %d tries (max:%d) %r'",
",",
"self",
".",
"name",
",",
"message",
".",
"id",
",",
"message",
".",
"attempts",
",",
"self",
".",
"max_... | Called when a message has been received where ``msg.attempts > max_tries``
This is useful to subclass and override to perform a task (such as writing to disk, etc.)
:param message: the :class:`nsq.Message` received | [
"Called",
"when",
"a",
"message",
"has",
"been",
"received",
"where",
"msg",
".",
"attempts",
">",
"max_tries"
] | python | test | 46.1 |
Valuehorizon/valuehorizon-companies | companies/models.py | https://github.com/Valuehorizon/valuehorizon-companies/blob/5366e230da69ee30fcdc1bf4beddc99310f6b767/companies/models.py#L291-L324 | def save(self, *args, **kwargs):
"""
This method autogenerates the auto_generated_description field
"""
# Cache basic data
self.cache_data()
# Ensure slug doesn't change
if self.id is not None:
db_company = Company.objects.get(id=self.id)
... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Cache basic data",
"self",
".",
"cache_data",
"(",
")",
"# Ensure slug doesn't change",
"if",
"self",
".",
"id",
"is",
"not",
"None",
":",
"db_company",
"=",
"Company",
"... | This method autogenerates the auto_generated_description field | [
"This",
"method",
"autogenerates",
"the",
"auto_generated_description",
"field"
] | python | train | 36.941176 |
python-rope/rope | rope/base/arguments.py | https://github.com/python-rope/rope/blob/1c9f9cd5964b099a99a9111e998f0dc728860688/rope/base/arguments.py#L44-L53 | def create_arguments(primary, pyfunction, call_node, scope):
"""A factory for creating `Arguments`"""
args = list(call_node.args)
args.extend(call_node.keywords)
called = call_node.func
# XXX: Handle constructors
if _is_method_call(primary, pyfunction) and \
isinstance(called, ast.Attribu... | [
"def",
"create_arguments",
"(",
"primary",
",",
"pyfunction",
",",
"call_node",
",",
"scope",
")",
":",
"args",
"=",
"list",
"(",
"call_node",
".",
"args",
")",
"args",
".",
"extend",
"(",
"call_node",
".",
"keywords",
")",
"called",
"=",
"call_node",
".... | A factory for creating `Arguments` | [
"A",
"factory",
"for",
"creating",
"Arguments"
] | python | train | 38.6 |
StackStorm/pybind | pybind/nos/v6_0_2f/nas/server_ip/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/nas/server_ip/__init__.py#L133-L154 | def _set_vrf(self, v, load=False):
"""
Setter method for vrf, mapped from YANG variable /nas/server_ip/vrf (list)
If this variable is read-only (config: false) in the
source YANG file, then _set_vrf is considered as a private
method. Backends looking to populate this variable should
do so via ca... | [
"def",
"_set_vrf",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
"base",
"... | Setter method for vrf, mapped from YANG variable /nas/server_ip/vrf (list)
If this variable is read-only (config: false) in the
source YANG file, then _set_vrf is considered as a private
method. Backends looking to populate this variable should
do so via calling thisObj._set_vrf() directly. | [
"Setter",
"method",
"for",
"vrf",
"mapped",
"from",
"YANG",
"variable",
"/",
"nas",
"/",
"server_ip",
"/",
"vrf",
"(",
"list",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"(",
"config",
":",
"false",
")",
"in",
"the",
"source",
"YANG",
... | python | train | 98.909091 |
django-xxx/django-mobi2 | mobi2/decorators.py | https://github.com/django-xxx/django-mobi2/blob/7ac323faa1a9599f3cd39acd3c49626819ce0538/mobi2/decorators.py#L8-L18 | def detect_mobile(view):
"""View Decorator that adds a "mobile" attribute to the request which is
True or False depending on whether the request should be considered
to come from a small-screen device such as a phone or a PDA"""
@wraps(view)
def detected(request, *args, **kwargs):
Mob... | [
"def",
"detect_mobile",
"(",
"view",
")",
":",
"@",
"wraps",
"(",
"view",
")",
"def",
"detected",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"MobileDetectionMiddleware",
".",
"process_request",
"(",
"request",
")",
"return",
"vi... | View Decorator that adds a "mobile" attribute to the request which is
True or False depending on whether the request should be considered
to come from a small-screen device such as a phone or a PDA | [
"View",
"Decorator",
"that",
"adds",
"a",
"mobile",
"attribute",
"to",
"the",
"request",
"which",
"is",
"True",
"or",
"False",
"depending",
"on",
"whether",
"the",
"request",
"should",
"be",
"considered",
"to",
"come",
"from",
"a",
"small",
"-",
"screen",
... | python | train | 49 |
kivy/python-for-android | pythonforandroid/bootstrap.py | https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstrap.py#L115-L132 | def prepare_build_dir(self):
'''Ensure that a build dir exists for the recipe. This same single
dir will be used for building all different archs.'''
self.build_dir = self.get_build_dir()
self.common_dir = self.get_common_dir()
copy_files(join(self.bootstrap_dir, 'build'), self.b... | [
"def",
"prepare_build_dir",
"(",
"self",
")",
":",
"self",
".",
"build_dir",
"=",
"self",
".",
"get_build_dir",
"(",
")",
"self",
".",
"common_dir",
"=",
"self",
".",
"get_common_dir",
"(",
")",
"copy_files",
"(",
"join",
"(",
"self",
".",
"bootstrap_dir",... | Ensure that a build dir exists for the recipe. This same single
dir will be used for building all different archs. | [
"Ensure",
"that",
"a",
"build",
"dir",
"exists",
"for",
"the",
"recipe",
".",
"This",
"same",
"single",
"dir",
"will",
"be",
"used",
"for",
"building",
"all",
"different",
"archs",
"."
] | python | train | 57.222222 |
open-homeautomation/pknx | knxip/helper.py | https://github.com/open-homeautomation/pknx/blob/a8aed8271563923c447aa330ba7c1c2927286f7a/knxip/helper.py#L18-L24 | def int_to_array(i, length=2):
"""Convert an length byte integer to an array of bytes."""
res = []
for dummy in range(0, length):
res.append(i & 0xff)
i = i >> 8
return reversed(res) | [
"def",
"int_to_array",
"(",
"i",
",",
"length",
"=",
"2",
")",
":",
"res",
"=",
"[",
"]",
"for",
"dummy",
"in",
"range",
"(",
"0",
",",
"length",
")",
":",
"res",
".",
"append",
"(",
"i",
"&",
"0xff",
")",
"i",
"=",
"i",
">>",
"8",
"return",
... | Convert an length byte integer to an array of bytes. | [
"Convert",
"an",
"length",
"byte",
"integer",
"to",
"an",
"array",
"of",
"bytes",
"."
] | python | train | 29.714286 |
Duke-GCB/DukeDSClient | ddsc/core/fileuploader.py | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/fileuploader.py#L140-L155 | def create_upload_and_chunk_url(self, project_id, path_data, hash_data, remote_filename=None,
storage_provider_id=None):
"""
Create an non-chunked upload that returns upload id and upload url. This type of upload doesn't allow
additional upload urls. For singl... | [
"def",
"create_upload_and_chunk_url",
"(",
"self",
",",
"project_id",
",",
"path_data",
",",
"hash_data",
",",
"remote_filename",
"=",
"None",
",",
"storage_provider_id",
"=",
"None",
")",
":",
"upload_response",
"=",
"self",
".",
"_create_upload",
"(",
"project_i... | Create an non-chunked upload that returns upload id and upload url. This type of upload doesn't allow
additional upload urls. For single chunk files this method is more efficient than
create_upload/create_file_chunk_url.
:param project_id: str: uuid of the project
:param path_data: PathD... | [
"Create",
"an",
"non",
"-",
"chunked",
"upload",
"that",
"returns",
"upload",
"id",
"and",
"upload",
"url",
".",
"This",
"type",
"of",
"upload",
"doesn",
"t",
"allow",
"additional",
"upload",
"urls",
".",
"For",
"single",
"chunk",
"files",
"this",
"method"... | python | train | 73.875 |
gwastro/pycbc | pycbc/inject/inject.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/inject/inject.py#L121-L206 | def apply(self, strain, detector_name, f_lower=None, distance_scale=1,
simulation_ids=None, inj_filter_rejector=None):
"""Add injections (as seen by a particular detector) to a time series.
Parameters
----------
strain : TimeSeries
Time series to inject signals... | [
"def",
"apply",
"(",
"self",
",",
"strain",
",",
"detector_name",
",",
"f_lower",
"=",
"None",
",",
"distance_scale",
"=",
"1",
",",
"simulation_ids",
"=",
"None",
",",
"inj_filter_rejector",
"=",
"None",
")",
":",
"if",
"strain",
".",
"dtype",
"not",
"i... | Add injections (as seen by a particular detector) to a time series.
Parameters
----------
strain : TimeSeries
Time series to inject signals into, of type float32 or float64.
detector_name : string
Name of the detector used for projecting injections.
f_low... | [
"Add",
"injections",
"(",
"as",
"seen",
"by",
"a",
"particular",
"detector",
")",
"to",
"a",
"time",
"series",
"."
] | python | train | 41.186047 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/Utility.py | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/Utility.py#L515-L528 | def getElementText(self, node, preserve_ws=None):
"""Return the text value of an xml element node. Leading and trailing
whitespace is stripped from the value unless the preserve_ws flag
is passed with a true value."""
result = []
for child in node.childNodes:
no... | [
"def",
"getElementText",
"(",
"self",
",",
"node",
",",
"preserve_ws",
"=",
"None",
")",
":",
"result",
"=",
"[",
"]",
"for",
"child",
"in",
"node",
".",
"childNodes",
":",
"nodetype",
"=",
"child",
".",
"nodeType",
"if",
"nodetype",
"==",
"child",
"."... | Return the text value of an xml element node. Leading and trailing
whitespace is stripped from the value unless the preserve_ws flag
is passed with a true value. | [
"Return",
"the",
"text",
"value",
"of",
"an",
"xml",
"element",
"node",
".",
"Leading",
"and",
"trailing",
"whitespace",
"is",
"stripped",
"from",
"the",
"value",
"unless",
"the",
"preserve_ws",
"flag",
"is",
"passed",
"with",
"a",
"true",
"value",
"."
] | python | train | 42.642857 |
Kozea/cairocffi | cairocffi/surfaces.py | https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/surfaces.py#L305-L329 | def set_device_offset(self, x_offset, y_offset):
""" Sets an offset that is added to the device coordinates
determined by the CTM when drawing to surface.
One use case for this method is
when we want to create a :class:`Surface` that redirects drawing
for a portion of an onscreen... | [
"def",
"set_device_offset",
"(",
"self",
",",
"x_offset",
",",
"y_offset",
")",
":",
"cairo",
".",
"cairo_surface_set_device_offset",
"(",
"self",
".",
"_pointer",
",",
"x_offset",
",",
"y_offset",
")",
"self",
".",
"_check_status",
"(",
")"
] | Sets an offset that is added to the device coordinates
determined by the CTM when drawing to surface.
One use case for this method is
when we want to create a :class:`Surface` that redirects drawing
for a portion of an onscreen surface
to an offscreen surface in a way that is
... | [
"Sets",
"an",
"offset",
"that",
"is",
"added",
"to",
"the",
"device",
"coordinates",
"determined",
"by",
"the",
"CTM",
"when",
"drawing",
"to",
"surface",
".",
"One",
"use",
"case",
"for",
"this",
"method",
"is",
"when",
"we",
"want",
"to",
"create",
"a"... | python | train | 41.32 |
iotile/coretools | iotilebuild/iotile/build/config/site_scons/arm.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/site_scons/arm.py#L316-L328 | def tb_h_file_creation(target, source, env):
"""Compile tilebus file into only .h files corresponding to config variables for inclusion in a library"""
files = [str(x) for x in source]
try:
desc = TBDescriptor(files)
except pyparsing.ParseException as e:
raise BuildError("Could not par... | [
"def",
"tb_h_file_creation",
"(",
"target",
",",
"source",
",",
"env",
")",
":",
"files",
"=",
"[",
"str",
"(",
"x",
")",
"for",
"x",
"in",
"source",
"]",
"try",
":",
"desc",
"=",
"TBDescriptor",
"(",
"files",
")",
"except",
"pyparsing",
".",
"ParseE... | Compile tilebus file into only .h files corresponding to config variables for inclusion in a library | [
"Compile",
"tilebus",
"file",
"into",
"only",
".",
"h",
"files",
"corresponding",
"to",
"config",
"variables",
"for",
"inclusion",
"in",
"a",
"library"
] | python | train | 42.384615 |
mastro35/flows | flows/FlowsManager.py | https://github.com/mastro35/flows/blob/05e488385673a69597b5b39c7728795aa4d5eb18/flows/FlowsManager.py#L102-L109 | def start(self):
"""
Start all the processes
"""
Global.LOGGER.info("starting the flow manager")
self._start_actions()
self._start_message_fetcher()
Global.LOGGER.debug("flow manager started") | [
"def",
"start",
"(",
"self",
")",
":",
"Global",
".",
"LOGGER",
".",
"info",
"(",
"\"starting the flow manager\"",
")",
"self",
".",
"_start_actions",
"(",
")",
"self",
".",
"_start_message_fetcher",
"(",
")",
"Global",
".",
"LOGGER",
".",
"debug",
"(",
"\... | Start all the processes | [
"Start",
"all",
"the",
"processes"
] | python | train | 30.125 |
3DLIRIOUS/MeshLabXML | meshlabxml/transfer.py | https://github.com/3DLIRIOUS/MeshLabXML/blob/177cce21e92baca500f56a932d66bd9a33257af8/meshlabxml/transfer.py#L96-L113 | def mesh2fc(script, all_visible_layers=False):
"""Transfer mesh colors to face colors
Args:
script: the FilterScript object or script filename to write
the filter to.
all_visible_layers (bool): If true the color mapping is applied to all the meshes
"""
filter_xml = ''.join([... | [
"def",
"mesh2fc",
"(",
"script",
",",
"all_visible_layers",
"=",
"False",
")",
":",
"filter_xml",
"=",
"''",
".",
"join",
"(",
"[",
"' <filter name=\"Transfer Color: Mesh to Face\">\\n'",
",",
"' <Param name=\"allVisibleMesh\" '",
",",
"'value=\"%s\" '",
"%",
"str",... | Transfer mesh colors to face colors
Args:
script: the FilterScript object or script filename to write
the filter to.
all_visible_layers (bool): If true the color mapping is applied to all the meshes | [
"Transfer",
"mesh",
"colors",
"to",
"face",
"colors"
] | python | test | 35.5 |
toomore/goristock | ck4buy.py | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/ck4buy.py#L28-L37 | def allck():
''' 檢查所有股票買賣點,剔除$10以下、成交量小於1000張的股票。 '''
for i in twseno().allstockno:
a = goristock.goristock(i)
try:
if a.stock_vol[-1] > 1000*1000 and a.raw_data[-1] > 10:
#a.goback(3) ## 倒退天數
ck4m(a)
except:
pass | [
"def",
"allck",
"(",
")",
":",
"for",
"i",
"in",
"twseno",
"(",
")",
".",
"allstockno",
":",
"a",
"=",
"goristock",
".",
"goristock",
"(",
"i",
")",
"try",
":",
"if",
"a",
".",
"stock_vol",
"[",
"-",
"1",
"]",
">",
"1000",
"*",
"1000",
"and",
... | 檢查所有股票買賣點,剔除$10以下、成交量小於1000張的股票。 | [
"檢查所有股票買賣點,剔除$10以下、成交量小於1000張的股票。"
] | python | train | 24.8 |
gwastro/pycbc-glue | pycbc_glue/pipeline.py | https://github.com/gwastro/pycbc-glue/blob/a3e906bae59fbfd707c3ff82e5d008d939ec5e24/pycbc_glue/pipeline.py#L3006-L3012 | def set_start(self,t):
"""
Override the GPS start time (and set the duration) of this ScienceSegment.
@param t: new GPS start time.
"""
self.__dur += self.__start - t
self.__start = t | [
"def",
"set_start",
"(",
"self",
",",
"t",
")",
":",
"self",
".",
"__dur",
"+=",
"self",
".",
"__start",
"-",
"t",
"self",
".",
"__start",
"=",
"t"
] | Override the GPS start time (and set the duration) of this ScienceSegment.
@param t: new GPS start time. | [
"Override",
"the",
"GPS",
"start",
"time",
"(",
"and",
"set",
"the",
"duration",
")",
"of",
"this",
"ScienceSegment",
"."
] | python | train | 28.714286 |
ph4r05/monero-serialize | monero_serialize/xmrrpc.py | https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrrpc.py#L1246-L1280 | async def load_variant(self, elem_type, params=None, elem=None, wrapped=None, obj=None):
"""
Loads variant type from the reader.
Supports both wrapped and raw variant.
:param elem_type:
:param params:
:param elem:
:param wrapped:
:param obj:
:retu... | [
"async",
"def",
"load_variant",
"(",
"self",
",",
"elem_type",
",",
"params",
"=",
"None",
",",
"elem",
"=",
"None",
",",
"wrapped",
"=",
"None",
",",
"obj",
"=",
"None",
")",
":",
"is_wrapped",
"=",
"elem_type",
".",
"WRAPS_VALUE",
"if",
"wrapped",
"i... | Loads variant type from the reader.
Supports both wrapped and raw variant.
:param elem_type:
:param params:
:param elem:
:param wrapped:
:param obj:
:return: | [
"Loads",
"variant",
"type",
"from",
"the",
"reader",
".",
"Supports",
"both",
"wrapped",
"and",
"raw",
"variant",
"."
] | python | train | 31.885714 |
seung-lab/cloud-volume | cloudvolume/txrx.py | https://github.com/seung-lab/cloud-volume/blob/d2fd4500333f1bc3cd3e3919a8b649cec5d8e214/cloudvolume/txrx.py#L109-L137 | def cutout(vol, requested_bbox, steps, channel_slice=slice(None), parallel=1,
shared_memory_location=None, output_to_shared_memory=False):
"""Cutout a requested bounding box from storage and return it as a numpy array."""
global fs_lock
cloudpath_bbox = requested_bbox.expand_to_chunk_size(vol.underlying, offs... | [
"def",
"cutout",
"(",
"vol",
",",
"requested_bbox",
",",
"steps",
",",
"channel_slice",
"=",
"slice",
"(",
"None",
")",
",",
"parallel",
"=",
"1",
",",
"shared_memory_location",
"=",
"None",
",",
"output_to_shared_memory",
"=",
"False",
")",
":",
"global",
... | Cutout a requested bounding box from storage and return it as a numpy array. | [
"Cutout",
"a",
"requested",
"bounding",
"box",
"from",
"storage",
"and",
"return",
"it",
"as",
"a",
"numpy",
"array",
"."
] | python | train | 44.310345 |
trec-kba/streamcorpus-pipeline | streamcorpus_pipeline/_clean_visible.py | https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_clean_visible.py#L252-L278 | def make_clean_visible_from_raw(_html, tag_replacement_char=' '):
'''Takes an HTML-like Unicode (or UTF-8 encoded) string as input and
returns a Unicode string with all tags replaced by whitespace. In
particular, all Unicode characters inside HTML are replaced with a
single whitespace character.
Th... | [
"def",
"make_clean_visible_from_raw",
"(",
"_html",
",",
"tag_replacement_char",
"=",
"' '",
")",
":",
"if",
"not",
"isinstance",
"(",
"_html",
",",
"unicode",
")",
":",
"_html",
"=",
"unicode",
"(",
"_html",
",",
"'utf-8'",
")",
"#Strip tags with logic above",
... | Takes an HTML-like Unicode (or UTF-8 encoded) string as input and
returns a Unicode string with all tags replaced by whitespace. In
particular, all Unicode characters inside HTML are replaced with a
single whitespace character.
This *does* detect comments, style, script, link tags and replaces
them... | [
"Takes",
"an",
"HTML",
"-",
"like",
"Unicode",
"(",
"or",
"UTF",
"-",
"8",
"encoded",
")",
"string",
"as",
"input",
"and",
"returns",
"a",
"Unicode",
"string",
"with",
"all",
"tags",
"replaced",
"by",
"whitespace",
".",
"In",
"particular",
"all",
"Unicod... | python | test | 37.37037 |
HewlettPackard/python-hpOneView | hpOneView/oneview_client.py | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L681-L690 | def sas_interconnect_types(self):
"""
Gets the SasInterconnectTypes API client.
Returns:
SasInterconnectTypes:
"""
if not self.__sas_interconnect_types:
self.__sas_interconnect_types = SasInterconnectTypes(self.__connection)
return self.__sas_inte... | [
"def",
"sas_interconnect_types",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"__sas_interconnect_types",
":",
"self",
".",
"__sas_interconnect_types",
"=",
"SasInterconnectTypes",
"(",
"self",
".",
"__connection",
")",
"return",
"self",
".",
"__sas_interconnect... | Gets the SasInterconnectTypes API client.
Returns:
SasInterconnectTypes: | [
"Gets",
"the",
"SasInterconnectTypes",
"API",
"client",
"."
] | python | train | 32.5 |
johnnoone/aioconsul | aioconsul/client/kv_endpoint.py | https://github.com/johnnoone/aioconsul/blob/02f7a529d7dc2e49bed942111067aa5faf320e90/aioconsul/client/kv_endpoint.py#L252-L272 | async def _write(self, path, data, *,
flags=None, cas=None, acquire=None, release=None):
"""Sets the key to the given value.
Returns:
bool: ``True`` on success
"""
if not isinstance(data, bytes):
raise ValueError("value must be bytes")
... | [
"async",
"def",
"_write",
"(",
"self",
",",
"path",
",",
"data",
",",
"*",
",",
"flags",
"=",
"None",
",",
"cas",
"=",
"None",
",",
"acquire",
"=",
"None",
",",
"release",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"data",
",",
"bytes... | Sets the key to the given value.
Returns:
bool: ``True`` on success | [
"Sets",
"the",
"key",
"to",
"the",
"given",
"value",
"."
] | python | train | 31.666667 |
apache/incubator-heron | heron/shell/src/python/utils.py | https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/heron/shell/src/python/utils.py#L100-L109 | def get_listing(path):
"""
Returns the list of files and directories in a path.
Prepents a ".." (parent directory link) if path is not current dir.
"""
if path != ".":
listing = sorted(['..'] + os.listdir(path))
else:
listing = sorted(os.listdir(path))
return listing | [
"def",
"get_listing",
"(",
"path",
")",
":",
"if",
"path",
"!=",
"\".\"",
":",
"listing",
"=",
"sorted",
"(",
"[",
"'..'",
"]",
"+",
"os",
".",
"listdir",
"(",
"path",
")",
")",
"else",
":",
"listing",
"=",
"sorted",
"(",
"os",
".",
"listdir",
"(... | Returns the list of files and directories in a path.
Prepents a ".." (parent directory link) if path is not current dir. | [
"Returns",
"the",
"list",
"of",
"files",
"and",
"directories",
"in",
"a",
"path",
".",
"Prepents",
"a",
"..",
"(",
"parent",
"directory",
"link",
")",
"if",
"path",
"is",
"not",
"current",
"dir",
"."
] | python | valid | 28 |
ly0/baidupcsapi | baidupcsapi/api.py | https://github.com/ly0/baidupcsapi/blob/6f6feeef0767a75b3b968924727460eb09242d76/baidupcsapi/api.py#L1947-L2016 | def meta(self, file_list, **kwargs):
"""获得文件(s)的metainfo
:param file_list: 文件路径列表,如 ['/aaa.txt']
:type file_list: list
:return: requests.Response
.. note ::
示例
* 文件不存在
{"errno":12,"info":[{"errno":-9}],"request_id":3294861771}
... | [
"def",
"meta",
"(",
"self",
",",
"file_list",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"file_list",
",",
"list",
")",
":",
"file_list",
"=",
"[",
"file_list",
"]",
"data",
"=",
"{",
"'target'",
":",
"json",
".",
"dumps",
"... | 获得文件(s)的metainfo
:param file_list: 文件路径列表,如 ['/aaa.txt']
:type file_list: list
:return: requests.Response
.. note ::
示例
* 文件不存在
{"errno":12,"info":[{"errno":-9}],"request_id":3294861771}
* 文件存在
{
"errno"... | [
"获得文件",
"(",
"s",
")",
"的metainfo"
] | python | train | 23.114286 |
elastic/elasticsearch-dsl-py | elasticsearch_dsl/index.py | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/index.py#L481-L489 | def segments(self, using=None, **kwargs):
"""
Provide low level segments information that a Lucene index (shard
level) is built with.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.segments`` unchanged.
"""
return self._get_connection(... | [
"def",
"segments",
"(",
"self",
",",
"using",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_get_connection",
"(",
"using",
")",
".",
"indices",
".",
"segments",
"(",
"index",
"=",
"self",
".",
"_name",
",",
"*",
"*",
"kwa... | Provide low level segments information that a Lucene index (shard
level) is built with.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.segments`` unchanged. | [
"Provide",
"low",
"level",
"segments",
"information",
"that",
"a",
"Lucene",
"index",
"(",
"shard",
"level",
")",
"is",
"built",
"with",
"."
] | python | train | 40.333333 |
Miserlou/SoundScrape | soundscrape/soundscrape.py | https://github.com/Miserlou/SoundScrape/blob/efc63b99ce7e78b352e2ba22d5e51f83445546d7/soundscrape/soundscrape.py#L919-L936 | def process_hive(vargs):
"""
Main Hive.co path.
"""
artist_url = vargs['artist_url']
if 'hive.co' in artist_url:
mc_url = artist_url
else:
mc_url = 'https://www.hive.co/downloads/download/' + artist_url
filenames = scrape_hive_url(mc_url, num_tracks=vargs['num_tracks'], fo... | [
"def",
"process_hive",
"(",
"vargs",
")",
":",
"artist_url",
"=",
"vargs",
"[",
"'artist_url'",
"]",
"if",
"'hive.co'",
"in",
"artist_url",
":",
"mc_url",
"=",
"artist_url",
"else",
":",
"mc_url",
"=",
"'https://www.hive.co/downloads/download/'",
"+",
"artist_url"... | Main Hive.co path. | [
"Main",
"Hive",
".",
"co",
"path",
"."
] | python | train | 23.222222 |
luismasuelli/django-trackmodels-ritual | grimoire/django/tracked/admin.py | https://github.com/luismasuelli/django-trackmodels-ritual/blob/ee0a6e07a5851ed477c9c1e3b9f8aafd9da35657/grimoire/django/tracked/admin.py#L96-L104 | def get_list_filter(self, request):
"""
Adds the period filter to the filters list.
:param request: Current request.
:return: Iterable of filters.
"""
original = super(TrackedLiveAdmin, self).get_list_filter(request)
return original + type(original)([PeriodFilter... | [
"def",
"get_list_filter",
"(",
"self",
",",
"request",
")",
":",
"original",
"=",
"super",
"(",
"TrackedLiveAdmin",
",",
"self",
")",
".",
"get_list_filter",
"(",
"request",
")",
"return",
"original",
"+",
"type",
"(",
"original",
")",
"(",
"[",
"PeriodFil... | Adds the period filter to the filters list.
:param request: Current request.
:return: Iterable of filters. | [
"Adds",
"the",
"period",
"filter",
"to",
"the",
"filters",
"list",
".",
":",
"param",
"request",
":",
"Current",
"request",
".",
":",
"return",
":",
"Iterable",
"of",
"filters",
"."
] | python | train | 34.888889 |
berkeley-cocosci/Wallace | wallace/custom.py | https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/custom.py#L365-L378 | def assign_properties(thing):
"""Assign properties to an object.
When creating something via a post request (e.g. a node), you can pass the
properties of the object in the request. This function gets those values
from the request and fills in the relevant columns of the table.
"""
for p in rang... | [
"def",
"assign_properties",
"(",
"thing",
")",
":",
"for",
"p",
"in",
"range",
"(",
"5",
")",
":",
"property_name",
"=",
"\"property\"",
"+",
"str",
"(",
"p",
"+",
"1",
")",
"property",
"=",
"request_parameter",
"(",
"parameter",
"=",
"property_name",
",... | Assign properties to an object.
When creating something via a post request (e.g. a node), you can pass the
properties of the object in the request. This function gets those values
from the request and fills in the relevant columns of the table. | [
"Assign",
"properties",
"to",
"an",
"object",
"."
] | python | train | 38 |
mabuchilab/QNET | docs/_extensions/inheritance_diagram.py | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/docs/_extensions/inheritance_diagram.py#L112-L141 | def import_classes(name, currmodule):
# type: (unicode, unicode) -> Any
"""Import a class using its fully-qualified *name*."""
target = None
# import class or module using currmodule
if currmodule:
target = try_import(currmodule + '.' + name)
# import class or module without currmodule... | [
"def",
"import_classes",
"(",
"name",
",",
"currmodule",
")",
":",
"# type: (unicode, unicode) -> Any",
"target",
"=",
"None",
"# import class or module using currmodule",
"if",
"currmodule",
":",
"target",
"=",
"try_import",
"(",
"currmodule",
"+",
"'.'",
"+",
"name"... | Import a class using its fully-qualified *name*. | [
"Import",
"a",
"class",
"using",
"its",
"fully",
"-",
"qualified",
"*",
"name",
"*",
"."
] | python | train | 35.7 |
mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/_cartesian_class_core.py | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L885-L895 | def restrict_bond_dict(self, bond_dict):
"""Restrict a bond dictionary to self.
Args:
bond_dict (dict): Look into :meth:`~chemcoord.Cartesian.get_bonds`,
to see examples for a bond_dict.
Returns:
bond dictionary
"""
return {j: bond_dict[j... | [
"def",
"restrict_bond_dict",
"(",
"self",
",",
"bond_dict",
")",
":",
"return",
"{",
"j",
":",
"bond_dict",
"[",
"j",
"]",
"&",
"set",
"(",
"self",
".",
"index",
")",
"for",
"j",
"in",
"self",
".",
"index",
"}"
] | Restrict a bond dictionary to self.
Args:
bond_dict (dict): Look into :meth:`~chemcoord.Cartesian.get_bonds`,
to see examples for a bond_dict.
Returns:
bond dictionary | [
"Restrict",
"a",
"bond",
"dictionary",
"to",
"self",
"."
] | python | train | 31.818182 |
zetaops/zengine | zengine/views/permissions.py | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/permissions.py#L220-L229 | def _traverse_tree(tree, path):
"""Traverses the permission tree, returning the permission at given permission path."""
path_steps = (step for step in path.split('.') if step != '')
# Special handling for first step, because the first step isn't under 'objects'
first_step = path_steps.ne... | [
"def",
"_traverse_tree",
"(",
"tree",
",",
"path",
")",
":",
"path_steps",
"=",
"(",
"step",
"for",
"step",
"in",
"path",
".",
"split",
"(",
"'.'",
")",
"if",
"step",
"!=",
"''",
")",
"# Special handling for first step, because the first step isn't under 'objects'... | Traverses the permission tree, returning the permission at given permission path. | [
"Traverses",
"the",
"permission",
"tree",
"returning",
"the",
"permission",
"at",
"given",
"permission",
"path",
"."
] | python | train | 45.4 |
universalcore/unicore.hub.client | unicore/hub/client/userclient.py | https://github.com/universalcore/unicore.hub.client/blob/c706f4d31e493bd4e7ea8236780a9b271b850b8b/unicore/hub/client/userclient.py#L79-L90 | def get(self, field):
"""
Returns the value of a user field.
:param str field:
The name of the user field.
:returns: str -- the value
"""
if field in ('username', 'uuid', 'app_data'):
return self.data[field]
else:
return self.d... | [
"def",
"get",
"(",
"self",
",",
"field",
")",
":",
"if",
"field",
"in",
"(",
"'username'",
",",
"'uuid'",
",",
"'app_data'",
")",
":",
"return",
"self",
".",
"data",
"[",
"field",
"]",
"else",
":",
"return",
"self",
".",
"data",
".",
"get",
"(",
... | Returns the value of a user field.
:param str field:
The name of the user field.
:returns: str -- the value | [
"Returns",
"the",
"value",
"of",
"a",
"user",
"field",
"."
] | python | train | 28.25 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.