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 |
|---|---|---|---|---|---|---|---|---|---|
msmbuilder/msmbuilder | msmbuilder/tpt/hub.py | https://github.com/msmbuilder/msmbuilder/blob/556a93a170782f47be53f4a1e9d740fb1c8272b3/msmbuilder/tpt/hub.py#L86-L136 | def hub_scores(msm, waypoints=None):
"""
Calculate the hub score for one or more waypoints
The "hub score" is a measure of how well traveled a certain state or
set of states is in a network. Specifically, it is the fraction of
times that a walker visits a state en route from some state A to another... | [
"def",
"hub_scores",
"(",
"msm",
",",
"waypoints",
"=",
"None",
")",
":",
"n_states",
"=",
"msm",
".",
"n_states_",
"if",
"isinstance",
"(",
"waypoints",
",",
"int",
")",
":",
"waypoints",
"=",
"[",
"waypoints",
"]",
"elif",
"waypoints",
"is",
"None",
... | Calculate the hub score for one or more waypoints
The "hub score" is a measure of how well traveled a certain state or
set of states is in a network. Specifically, it is the fraction of
times that a walker visits a state en route from some state A to another
state B, averaged over all combinations of A... | [
"Calculate",
"the",
"hub",
"score",
"for",
"one",
"or",
"more",
"waypoints"
] | python | train | 31.764706 |
fermiPy/fermipy | fermipy/stats_utils.py | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/stats_utils.py#L431-L455 | def init_return(self, ret_type):
"""Specify the return type.
Note that this will also construct the
'~fermipy.castro.Interpolator' object
for the requested return type.
"""
if self._ret_type == ret_type:
return
if ret_type == "straight":
... | [
"def",
"init_return",
"(",
"self",
",",
"ret_type",
")",
":",
"if",
"self",
".",
"_ret_type",
"==",
"ret_type",
":",
"return",
"if",
"ret_type",
"==",
"\"straight\"",
":",
"self",
".",
"_interp",
"=",
"self",
".",
"_lnlfn",
".",
"interp",
"if",
"ret_type... | Specify the return type.
Note that this will also construct the
'~fermipy.castro.Interpolator' object
for the requested return type. | [
"Specify",
"the",
"return",
"type",
"."
] | python | train | 37 |
ericmjl/nxviz | nxviz/plots.py | https://github.com/ericmjl/nxviz/blob/6ea5823a8030a686f165fbe37d7a04d0f037ecc9/nxviz/plots.py#L1035-L1050 | def compute_node_positions(self):
"""
Computes nodes positions.
Arranges nodes in a line starting at (x,y) = (0,0). Node radius is
assumed to be equal to 0.5 units. Nodes are placed at integer
locations.
"""
xs = [0] * len(self.nodes)
ys = [0] * len(self.... | [
"def",
"compute_node_positions",
"(",
"self",
")",
":",
"xs",
"=",
"[",
"0",
"]",
"*",
"len",
"(",
"self",
".",
"nodes",
")",
"ys",
"=",
"[",
"0",
"]",
"*",
"len",
"(",
"self",
".",
"nodes",
")",
"for",
"i",
",",
"_",
"in",
"enumerate",
"(",
... | Computes nodes positions.
Arranges nodes in a line starting at (x,y) = (0,0). Node radius is
assumed to be equal to 0.5 units. Nodes are placed at integer
locations. | [
"Computes",
"nodes",
"positions",
"."
] | python | train | 34.625 |
ClericPy/torequests | torequests/utils.py | https://github.com/ClericPy/torequests/blob/1793261688d7a47e1c3a0830d83f8552f5e3e5d9/torequests/utils.py#L1304-L1353 | def countdown(
seconds=None,
block=True,
interval=1,
daemon=True,
tick_callback=None,
finish_callback=None,
):
"""Run a countdown function to wait something, similar to threading.Timer,
but will show the detail tick by tick_callback.
::
from torequests.utils import countdo... | [
"def",
"countdown",
"(",
"seconds",
"=",
"None",
",",
"block",
"=",
"True",
",",
"interval",
"=",
"1",
",",
"daemon",
"=",
"True",
",",
"tick_callback",
"=",
"None",
",",
"finish_callback",
"=",
"None",
",",
")",
":",
"def",
"default_tick_callback",
"(",... | Run a countdown function to wait something, similar to threading.Timer,
but will show the detail tick by tick_callback.
::
from torequests.utils import countdown
countdown(3)
# 3 2 1
# countdown finished [3 seconds]: 2018-06-13 00:12:55 => 2018-06-13 00:12:58.
countd... | [
"Run",
"a",
"countdown",
"function",
"to",
"wait",
"something",
"similar",
"to",
"threading",
".",
"Timer",
"but",
"will",
"show",
"the",
"detail",
"tick",
"by",
"tick_callback",
".",
"::"
] | python | train | 29.2 |
bw2/ConfigArgParse | configargparse.py | https://github.com/bw2/ConfigArgParse/blob/8bbc7de67f884184068d62af7f78e723d01c0081/configargparse.py#L146-L179 | def parse(self, stream):
"""Parses the keys + values from a config file."""
items = OrderedDict()
for i, line in enumerate(stream):
line = line.strip()
if not line or line[0] in ["#", ";", "["] or line.startswith("---"):
continue
white_space =... | [
"def",
"parse",
"(",
"self",
",",
"stream",
")",
":",
"items",
"=",
"OrderedDict",
"(",
")",
"for",
"i",
",",
"line",
"in",
"enumerate",
"(",
"stream",
")",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
"if",
"not",
"line",
"or",
"line",
"[",... | Parses the keys + values from a config file. | [
"Parses",
"the",
"keys",
"+",
"values",
"from",
"a",
"config",
"file",
"."
] | python | train | 38.470588 |
nicolargo/glances | glances/plugins/glances_raid.py | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_raid.py#L51-L78 | def update(self):
"""Update RAID stats using the input method."""
# Init new stats
stats = self.get_init_value()
if import_error_tag:
return self.stats
if self.input_method == 'local':
# Update stats using the PyMDstat lib (https://github.com/nicolargo/p... | [
"def",
"update",
"(",
"self",
")",
":",
"# Init new stats",
"stats",
"=",
"self",
".",
"get_init_value",
"(",
")",
"if",
"import_error_tag",
":",
"return",
"self",
".",
"stats",
"if",
"self",
".",
"input_method",
"==",
"'local'",
":",
"# Update stats using the... | Update RAID stats using the input method. | [
"Update",
"RAID",
"stats",
"using",
"the",
"input",
"method",
"."
] | python | train | 31.321429 |
snare/scruffy | scruffy/file.py | https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/file.py#L394-L425 | def add(self, *args, **kwargs):
"""
Add objects to the directory.
"""
for key in kwargs:
if isinstance(kwargs[key], str):
self._children[key] = File(kwargs[key])
else:
self._children[key] = kwargs[key]
self._children[key... | [
"def",
"add",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"key",
"in",
"kwargs",
":",
"if",
"isinstance",
"(",
"kwargs",
"[",
"key",
"]",
",",
"str",
")",
":",
"self",
".",
"_children",
"[",
"key",
"]",
"=",
"File",... | Add objects to the directory. | [
"Add",
"objects",
"to",
"the",
"directory",
"."
] | python | test | 34.5625 |
saltstack/salt | salt/utils/vmware.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/vmware.py#L475-L495 | def disconnect(service_instance):
'''
Function that disconnects from the vCenter server or ESXi host
service_instance
The Service Instance from which to obtain managed object references.
'''
log.trace('Disconnecting')
try:
Disconnect(service_instance)
except vim.fault.NoPerm... | [
"def",
"disconnect",
"(",
"service_instance",
")",
":",
"log",
".",
"trace",
"(",
"'Disconnecting'",
")",
"try",
":",
"Disconnect",
"(",
"service_instance",
")",
"except",
"vim",
".",
"fault",
".",
"NoPermission",
"as",
"exc",
":",
"log",
".",
"exception",
... | Function that disconnects from the vCenter server or ESXi host
service_instance
The Service Instance from which to obtain managed object references. | [
"Function",
"that",
"disconnects",
"from",
"the",
"vCenter",
"server",
"or",
"ESXi",
"host"
] | python | train | 34.761905 |
quokkaproject/flask-htmlbuilder | flask_htmlbuilder/htmlbuilder.py | https://github.com/quokkaproject/flask-htmlbuilder/blob/ee8b1b5d495ba9335428bf5bc8e3bce6799cf9a2/flask_htmlbuilder/htmlbuilder.py#L581-L594 | def _unmangle_attribute_name(name):
"""Unmangles attribute names so that correct Python variable names are
used for mapping attribute names."""
# Python keywords cannot be used as variable names, an underscore should
# be appended at the end of each of them when defining attribute names.
name = _PY... | [
"def",
"_unmangle_attribute_name",
"(",
"name",
")",
":",
"# Python keywords cannot be used as variable names, an underscore should",
"# be appended at the end of each of them when defining attribute names.",
"name",
"=",
"_PYTHON_KEYWORD_MAP",
".",
"get",
"(",
"name",
",",
"name",
... | Unmangles attribute names so that correct Python variable names are
used for mapping attribute names. | [
"Unmangles",
"attribute",
"names",
"so",
"that",
"correct",
"Python",
"variable",
"names",
"are",
"used",
"for",
"mapping",
"attribute",
"names",
"."
] | python | train | 42.5 |
saltstack/salt | salt/modules/pkg_resource.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pkg_resource.py#L217-L230 | def add_pkg(pkgs, name, pkgver):
'''
Add a package to a dict of installed packages.
CLI Example:
.. code-block:: bash
salt '*' pkg_resource.add_pkg '{}' bind 9
'''
try:
pkgs.setdefault(name, []).append(pkgver)
except AttributeError as exc:
log.exception(exc) | [
"def",
"add_pkg",
"(",
"pkgs",
",",
"name",
",",
"pkgver",
")",
":",
"try",
":",
"pkgs",
".",
"setdefault",
"(",
"name",
",",
"[",
"]",
")",
".",
"append",
"(",
"pkgver",
")",
"except",
"AttributeError",
"as",
"exc",
":",
"log",
".",
"exception",
"... | Add a package to a dict of installed packages.
CLI Example:
.. code-block:: bash
salt '*' pkg_resource.add_pkg '{}' bind 9 | [
"Add",
"a",
"package",
"to",
"a",
"dict",
"of",
"installed",
"packages",
"."
] | python | train | 21.428571 |
PonteIneptique/collatinus-python | pycollatinus/modele.py | https://github.com/PonteIneptique/collatinus-python/blob/fca37b0b77bc60f47d3c24ab42f6d0bdca6ba0f5/pycollatinus/modele.py#L160-L168 | def clone(self, d):
""" Crée une Désinence copiée sur la désinence d.
:param d: Desinence à copier
:type d: Desinence
:return: Désinence copiée sur la désinence d.
:rtype: Desinence
"""
return Desinence(d.grq(), d.morphoNum(), d.numRad(), self) | [
"def",
"clone",
"(",
"self",
",",
"d",
")",
":",
"return",
"Desinence",
"(",
"d",
".",
"grq",
"(",
")",
",",
"d",
".",
"morphoNum",
"(",
")",
",",
"d",
".",
"numRad",
"(",
")",
",",
"self",
")"
] | Crée une Désinence copiée sur la désinence d.
:param d: Desinence à copier
:type d: Desinence
:return: Désinence copiée sur la désinence d.
:rtype: Desinence | [
"Crée",
"une",
"Désinence",
"copiée",
"sur",
"la",
"désinence",
"d",
"."
] | python | train | 32.666667 |
apache/incubator-mxnet | python/mxnet/contrib/autograd.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/autograd.py#L163-L193 | def grad_and_loss(func, argnum=None):
"""Return function that computes both gradient of arguments and loss value.
Parameters
----------
func: a python function
The forward (loss) function.
argnum: an int or a list of int
The index of argument to calculate gradient for.
Returns
... | [
"def",
"grad_and_loss",
"(",
"func",
",",
"argnum",
"=",
"None",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapped",
"(",
"*",
"args",
")",
":",
"\"\"\"Wrapped function.\"\"\"",
"variables",
"=",
"args",
"if",
"argnum",
"is",
"n... | Return function that computes both gradient of arguments and loss value.
Parameters
----------
func: a python function
The forward (loss) function.
argnum: an int or a list of int
The index of argument to calculate gradient for.
Returns
-------
grad_and_loss_func: a python ... | [
"Return",
"function",
"that",
"computes",
"both",
"gradient",
"of",
"arguments",
"and",
"loss",
"value",
"."
] | python | train | 35.322581 |
pytroll/python-geotiepoints | geotiepoints/basic_interpolator.py | https://github.com/pytroll/python-geotiepoints/blob/7c5cc8a887f8534cc2839c716c2c560aeaf77659/geotiepoints/basic_interpolator.py#L65-L79 | def _pandas_interp(self, data, indices):
"""The actual transformation based on the following stackoverflow
entry: http://stackoverflow.com/a/10465162
"""
new_index = np.arange(indices[-1] + 1)
data_frame = DataFrame(data, index=indices)
data_frame_reindexed = data_frame... | [
"def",
"_pandas_interp",
"(",
"self",
",",
"data",
",",
"indices",
")",
":",
"new_index",
"=",
"np",
".",
"arange",
"(",
"indices",
"[",
"-",
"1",
"]",
"+",
"1",
")",
"data_frame",
"=",
"DataFrame",
"(",
"data",
",",
"index",
"=",
"indices",
")",
"... | The actual transformation based on the following stackoverflow
entry: http://stackoverflow.com/a/10465162 | [
"The",
"actual",
"transformation",
"based",
"on",
"the",
"following",
"stackoverflow",
"entry",
":",
"http",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"a",
"/",
"10465162"
] | python | train | 33.666667 |
CI-WATER/gsshapy | gsshapy/lib/cif_chunk.py | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/lib/cif_chunk.py#L45-L64 | def linkChunk(key, chunk):
"""
Parse LINK Chunk Method
"""
# Extract link type card
linkType = chunk[1].strip().split()[0]
# Cases
if linkType == 'DX':
# Cross section link type handler
result = xSectionLink(chunk)
elif linkType == 'STRUCTURE':
# Structure link ... | [
"def",
"linkChunk",
"(",
"key",
",",
"chunk",
")",
":",
"# Extract link type card",
"linkType",
"=",
"chunk",
"[",
"1",
"]",
".",
"strip",
"(",
")",
".",
"split",
"(",
")",
"[",
"0",
"]",
"# Cases",
"if",
"linkType",
"==",
"'DX'",
":",
"# Cross section... | Parse LINK Chunk Method | [
"Parse",
"LINK",
"Chunk",
"Method"
] | python | train | 24.5 |
JustinLovinger/optimal | optimal/algorithms/baseline.py | https://github.com/JustinLovinger/optimal/blob/ab48a4961697338cc32d50e3a6b06ac989e39c3f/optimal/algorithms/baseline.py#L147-L156 | def next_population(self, population, fitnesses):
"""Make a new population after each optimization iteration.
Args:
population: The population current population of solutions.
fitnesses: The fitness associated with each solution in the population
Returns:
lis... | [
"def",
"next_population",
"(",
"self",
",",
"population",
",",
"fitnesses",
")",
":",
"return",
"[",
"self",
".",
"_next_solution",
"(",
")",
"for",
"_",
"in",
"range",
"(",
"self",
".",
"_population_size",
")",
"]"
] | Make a new population after each optimization iteration.
Args:
population: The population current population of solutions.
fitnesses: The fitness associated with each solution in the population
Returns:
list; a list of solutions. | [
"Make",
"a",
"new",
"population",
"after",
"each",
"optimization",
"iteration",
"."
] | python | train | 42.3 |
johnnoone/aioconsul | aioconsul/client/kv_endpoint.py | https://github.com/johnnoone/aioconsul/blob/02f7a529d7dc2e49bed942111067aa5faf320e90/aioconsul/client/kv_endpoint.py#L141-L168 | async def get_tree(self, prefix, *,
dc=None, separator=None, watch=None, consistency=None):
"""Gets all keys with a prefix of Key during the transaction.
Parameters:
prefix (str): Prefix to fetch
separator (str): List only up to a given separator
... | [
"async",
"def",
"get_tree",
"(",
"self",
",",
"prefix",
",",
"*",
",",
"dc",
"=",
"None",
",",
"separator",
"=",
"None",
",",
"watch",
"=",
"None",
",",
"consistency",
"=",
"None",
")",
":",
"response",
"=",
"await",
"self",
".",
"_read",
"(",
"pre... | Gets all keys with a prefix of Key during the transaction.
Parameters:
prefix (str): Prefix to fetch
separator (str): List only up to a given separator
dc (str): Specify datacenter that will be used.
Defaults to the agent's local datacenter.
... | [
"Gets",
"all",
"keys",
"with",
"a",
"prefix",
"of",
"Key",
"during",
"the",
"transaction",
"."
] | python | train | 45.428571 |
woolfson-group/isambard | isambard/ampal/ligands.py | https://github.com/woolfson-group/isambard/blob/ebc33b48a28ad217e18f93b910dfba46e6e71e07/isambard/ampal/ligands.py#L34-L42 | def categories(self):
"""Returns the categories of `Ligands` in `LigandGroup`."""
category_dict = {}
for ligand in self:
if ligand.category in category_dict:
category_dict[ligand.category].append(ligand)
else:
category_dict[ligand.category]... | [
"def",
"categories",
"(",
"self",
")",
":",
"category_dict",
"=",
"{",
"}",
"for",
"ligand",
"in",
"self",
":",
"if",
"ligand",
".",
"category",
"in",
"category_dict",
":",
"category_dict",
"[",
"ligand",
".",
"category",
"]",
".",
"append",
"(",
"ligand... | Returns the categories of `Ligands` in `LigandGroup`. | [
"Returns",
"the",
"categories",
"of",
"Ligands",
"in",
"LigandGroup",
"."
] | python | train | 39.111111 |
aleju/imgaug | imgaug/external/poly_point_isect.py | https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/external/poly_point_isect.py#L514-L529 | def offer(self, p, e: Event):
"""
Offer a new event ``s`` at point ``p`` in this queue.
"""
existing = self.events_scan.setdefault(
p, ([], [], [], []) if USE_VERTICAL else
([], [], []))
# Can use double linked-list for easy insertion at beginni... | [
"def",
"offer",
"(",
"self",
",",
"p",
",",
"e",
":",
"Event",
")",
":",
"existing",
"=",
"self",
".",
"events_scan",
".",
"setdefault",
"(",
"p",
",",
"(",
"[",
"]",
",",
"[",
"]",
",",
"[",
"]",
",",
"[",
"]",
")",
"if",
"USE_VERTICAL",
"el... | Offer a new event ``s`` at point ``p`` in this queue. | [
"Offer",
"a",
"new",
"event",
"s",
"at",
"point",
"p",
"in",
"this",
"queue",
"."
] | python | valid | 30.4375 |
T-002/pycast | pycast/methods/basemethod.py | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/methods/basemethod.py#L285-L298 | def forecast_until(self, timestamp, tsformat=None):
"""Sets the forecasting goal (timestamp wise).
This function enables the automatic determination of valuesToForecast.
:param timestamp: timestamp containing the end date of the forecast.
:param string tsformat: Format of the tim... | [
"def",
"forecast_until",
"(",
"self",
",",
"timestamp",
",",
"tsformat",
"=",
"None",
")",
":",
"if",
"tsformat",
"is",
"not",
"None",
":",
"timestamp",
"=",
"TimeSeries",
".",
"convert_timestamp_to_epoch",
"(",
"timestamp",
",",
"tsformat",
")",
"self",
"."... | Sets the forecasting goal (timestamp wise).
This function enables the automatic determination of valuesToForecast.
:param timestamp: timestamp containing the end date of the forecast.
:param string tsformat: Format of the timestamp. This is used to convert the
timestamp from ... | [
"Sets",
"the",
"forecasting",
"goal",
"(",
"timestamp",
"wise",
")",
"."
] | python | train | 46.928571 |
rdussurget/py-altimetry | altimetry/data/alti_data.py | https://github.com/rdussurget/py-altimetry/blob/57ce7f2d63c6bbc4993821af0bbe46929e3a2d98/altimetry/data/alti_data.py#L652-L675 | def read_nc(self,filename,**kwargs):
'''
data reader based on :class:`altimetry.tools.nctools.nc` object.
.. note:: THIS can be VERY powerful!
'''
#Set filename
self._filename = filename
remove_existing = kwargs.get('remove_exi... | [
"def",
"read_nc",
"(",
"self",
",",
"filename",
",",
"*",
"*",
"kwargs",
")",
":",
"#Set filename\r",
"self",
".",
"_filename",
"=",
"filename",
"remove_existing",
"=",
"kwargs",
".",
"get",
"(",
"'remove_existing'",
",",
"True",
")",
"#Read data from NetCDF\r... | data reader based on :class:`altimetry.tools.nctools.nc` object.
.. note:: THIS can be VERY powerful! | [
"data",
"reader",
"based",
"on",
":",
"class",
":",
"altimetry",
".",
"tools",
".",
"nctools",
".",
"nc",
"object",
".",
"..",
"note",
"::",
"THIS",
"can",
"be",
"VERY",
"powerful!"
] | python | train | 37 |
axltxl/m2bk | m2bk/log.py | https://github.com/axltxl/m2bk/blob/980083dfd17e6e783753a946e9aa809714551141/m2bk/log.py#L50-L81 | def init(*, threshold_lvl=1, quiet_stdout=False, log_file):
"""
Initiate the log module
:param threshold_lvl: messages under this level won't be issued/logged
:param to_stdout: activate stdout log stream
"""
global _logger, _log_lvl
# translate lvl to those used by 'logging' module
_lo... | [
"def",
"init",
"(",
"*",
",",
"threshold_lvl",
"=",
"1",
",",
"quiet_stdout",
"=",
"False",
",",
"log_file",
")",
":",
"global",
"_logger",
",",
"_log_lvl",
"# translate lvl to those used by 'logging' module",
"_log_lvl",
"=",
"_set_lvl",
"(",
"threshold_lvl",
")"... | Initiate the log module
:param threshold_lvl: messages under this level won't be issued/logged
:param to_stdout: activate stdout log stream | [
"Initiate",
"the",
"log",
"module"
] | python | train | 26.5625 |
gwastro/pycbc | pycbc/types/timeseries.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/types/timeseries.py#L586-L613 | def notch_fir(self, f1, f2, order, beta=5.0, remove_corrupted=True):
""" notch filter the time series using an FIR filtered generated from
the ideal response passed through a time-domain kaiser
window (beta = 5.0)
The suppression of the notch filter is related to the bandwidth and
... | [
"def",
"notch_fir",
"(",
"self",
",",
"f1",
",",
"f2",
",",
"order",
",",
"beta",
"=",
"5.0",
",",
"remove_corrupted",
"=",
"True",
")",
":",
"from",
"pycbc",
".",
"filter",
"import",
"notch_fir",
"ts",
"=",
"notch_fir",
"(",
"self",
",",
"f1",
",",
... | notch filter the time series using an FIR filtered generated from
the ideal response passed through a time-domain kaiser
window (beta = 5.0)
The suppression of the notch filter is related to the bandwidth and
the number of samples in the filter length. For a few Hz bandwidth,
a ... | [
"notch",
"filter",
"the",
"time",
"series",
"using",
"an",
"FIR",
"filtered",
"generated",
"from",
"the",
"ideal",
"response",
"passed",
"through",
"a",
"time",
"-",
"domain",
"kaiser",
"window",
"(",
"beta",
"=",
"5",
".",
"0",
")"
] | python | train | 40.785714 |
twilio/twilio-python | twilio/rest/sync/v1/service/sync_map/sync_map_permission.py | https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/sync/v1/service/sync_map/sync_map_permission.py#L181-L195 | def get_instance(self, payload):
"""
Build an instance of SyncMapPermissionInstance
:param dict payload: Payload response from the API
:returns: twilio.rest.sync.v1.service.sync_map.sync_map_permission.SyncMapPermissionInstance
:rtype: twilio.rest.sync.v1.service.sync_map.sync_... | [
"def",
"get_instance",
"(",
"self",
",",
"payload",
")",
":",
"return",
"SyncMapPermissionInstance",
"(",
"self",
".",
"_version",
",",
"payload",
",",
"service_sid",
"=",
"self",
".",
"_solution",
"[",
"'service_sid'",
"]",
",",
"map_sid",
"=",
"self",
".",... | Build an instance of SyncMapPermissionInstance
:param dict payload: Payload response from the API
:returns: twilio.rest.sync.v1.service.sync_map.sync_map_permission.SyncMapPermissionInstance
:rtype: twilio.rest.sync.v1.service.sync_map.sync_map_permission.SyncMapPermissionInstance | [
"Build",
"an",
"instance",
"of",
"SyncMapPermissionInstance"
] | python | train | 37.333333 |
jobovy/galpy | galpy/df/streamgapdf.py | https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/df/streamgapdf.py#L1004-L1062 | def impulse_deltav_plummer(v,y,b,w,GM,rs):
"""
NAME:
impulse_deltav_plummer
PURPOSE:
calculate the delta velocity to due an encounter with a Plummer sphere in the impulse approximation; allows for arbitrary velocity vectors, but y is input as the position along the stream
INPUT:
... | [
"def",
"impulse_deltav_plummer",
"(",
"v",
",",
"y",
",",
"b",
",",
"w",
",",
"GM",
",",
"rs",
")",
":",
"if",
"len",
"(",
"v",
".",
"shape",
")",
"==",
"1",
":",
"v",
"=",
"numpy",
".",
"reshape",
"(",
"v",
",",
"(",
"1",
",",
"3",
")",
... | NAME:
impulse_deltav_plummer
PURPOSE:
calculate the delta velocity to due an encounter with a Plummer sphere in the impulse approximation; allows for arbitrary velocity vectors, but y is input as the position along the stream
INPUT:
v - velocity of the stream (nstar,3)
y - posi... | [
"NAME",
":"
] | python | train | 32.169492 |
tensorflow/cleverhans | cleverhans/model_zoo/deep_k_nearest_neighbors/dknn.py | https://github.com/tensorflow/cleverhans/blob/97488e215760547b81afc53f5e5de8ba7da5bd98/cleverhans/model_zoo/deep_k_nearest_neighbors/dknn.py#L229-L235 | def fprop(self, x):
"""
Performs a forward pass through the DkNN on a TF tensor by wrapping
the fprop_np method.
"""
logits = tf.py_func(self.fprop_np, [x], tf.float32)
return {self.O_LOGITS: logits} | [
"def",
"fprop",
"(",
"self",
",",
"x",
")",
":",
"logits",
"=",
"tf",
".",
"py_func",
"(",
"self",
".",
"fprop_np",
",",
"[",
"x",
"]",
",",
"tf",
".",
"float32",
")",
"return",
"{",
"self",
".",
"O_LOGITS",
":",
"logits",
"}"
] | Performs a forward pass through the DkNN on a TF tensor by wrapping
the fprop_np method. | [
"Performs",
"a",
"forward",
"pass",
"through",
"the",
"DkNN",
"on",
"a",
"TF",
"tensor",
"by",
"wrapping",
"the",
"fprop_np",
"method",
"."
] | python | train | 31 |
santoshphilip/eppy | eppy/EPlusInterfaceFunctions/parse_idd.py | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/EPlusInterfaceFunctions/parse_idd.py#L74-L78 | def removeblanklines(astr):
"""remove the blank lines in astr"""
lines = astr.splitlines()
lines = [line for line in lines if line.strip() != ""]
return "\n".join(lines) | [
"def",
"removeblanklines",
"(",
"astr",
")",
":",
"lines",
"=",
"astr",
".",
"splitlines",
"(",
")",
"lines",
"=",
"[",
"line",
"for",
"line",
"in",
"lines",
"if",
"line",
".",
"strip",
"(",
")",
"!=",
"\"\"",
"]",
"return",
"\"\\n\"",
".",
"join",
... | remove the blank lines in astr | [
"remove",
"the",
"blank",
"lines",
"in",
"astr"
] | python | train | 36.2 |
apple/turicreate | src/unity/python/turicreate/toolkits/_feature_engineering/_autovectorizer.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/_feature_engineering/_autovectorizer.py#L621-L643 | def fit(self, data):
"""
Fits a transformer using the SFrame `data`.
Parameters
----------
data : SFrame
The data used to fit the transformer.
Returns
-------
self (A fitted object)
See Also
--------
transform, fit_tr... | [
"def",
"fit",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"_setup_from_data",
"(",
"data",
")",
"self",
".",
"transform_chain",
".",
"fit",
"(",
"data",
")",
"self",
".",
"__proxy__",
".",
"update",
"(",
"{",
"\"fitted\"",
":",
"True",
"}",
")",... | Fits a transformer using the SFrame `data`.
Parameters
----------
data : SFrame
The data used to fit the transformer.
Returns
-------
self (A fitted object)
See Also
--------
transform, fit_transform | [
"Fits",
"a",
"transformer",
"using",
"the",
"SFrame",
"data",
"."
] | python | train | 20.130435 |
letuananh/chirptext | chirptext/texttaglib.py | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/texttaglib.py#L430-L438 | def find(self, tagtype, **kwargs):
'''Get the first tag with a type in this token '''
for t in self.__tags:
if t.tagtype == tagtype:
return t
if 'default' in kwargs:
return kwargs['default']
else:
raise LookupError("Token {} is not tagg... | [
"def",
"find",
"(",
"self",
",",
"tagtype",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"t",
"in",
"self",
".",
"__tags",
":",
"if",
"t",
".",
"tagtype",
"==",
"tagtype",
":",
"return",
"t",
"if",
"'default'",
"in",
"kwargs",
":",
"return",
"kwargs",... | Get the first tag with a type in this token | [
"Get",
"the",
"first",
"tag",
"with",
"a",
"type",
"in",
"this",
"token"
] | python | train | 41.111111 |
ajdavis/mongo-mockup-db | mockupdb/__init__.py | https://github.com/ajdavis/mongo-mockup-db/blob/ff8a3f793def59e9037397ef60607fbda6949dac/mockupdb/__init__.py#L286-L289 | def _get_c_string(data, position):
"""Decode a BSON 'C' string to python unicode string."""
end = data.index(b"\x00", position)
return _utf_8_decode(data[position:end], None, True)[0], end + 1 | [
"def",
"_get_c_string",
"(",
"data",
",",
"position",
")",
":",
"end",
"=",
"data",
".",
"index",
"(",
"b\"\\x00\"",
",",
"position",
")",
"return",
"_utf_8_decode",
"(",
"data",
"[",
"position",
":",
"end",
"]",
",",
"None",
",",
"True",
")",
"[",
"... | Decode a BSON 'C' string to python unicode string. | [
"Decode",
"a",
"BSON",
"C",
"string",
"to",
"python",
"unicode",
"string",
"."
] | python | train | 50.25 |
phoebe-project/phoebe2 | phoebe/frontend/bundle.py | https://github.com/phoebe-project/phoebe2/blob/e64b8be683977064e2d55dd1b3ac400f64c3e379/phoebe/frontend/bundle.py#L2556-L2581 | def disable_dataset(self, dataset=None, **kwargs):
"""
Disable a 'dataset'. Datasets that are enabled will be computed
during :meth:`run_compute` and included in the cost function
during :meth:`run_fitting`.
If compute is not provided, the dataset will be disabled across all
... | [
"def",
"disable_dataset",
"(",
"self",
",",
"dataset",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'context'",
"]",
"=",
"'compute'",
"kwargs",
"[",
"'dataset'",
"]",
"=",
"dataset",
"kwargs",
"[",
"'qualifier'",
"]",
"=",
"'enabled'"... | Disable a 'dataset'. Datasets that are enabled will be computed
during :meth:`run_compute` and included in the cost function
during :meth:`run_fitting`.
If compute is not provided, the dataset will be disabled across all
compute options.
:parameter str dataset: name of the dat... | [
"Disable",
"a",
"dataset",
".",
"Datasets",
"that",
"are",
"enabled",
"will",
"be",
"computed",
"during",
":",
"meth",
":",
"run_compute",
"and",
"included",
"in",
"the",
"cost",
"function",
"during",
":",
"meth",
":",
"run_fitting",
"."
] | python | train | 39.653846 |
aliyun/aliyun-odps-python-sdk | odps/tunnel/pb/input_stream.py | https://github.com/aliyun/aliyun-odps-python-sdk/blob/4b0de18f5864386df6068f26f026e62f932c41e4/odps/tunnel/pb/input_stream.py#L58-L68 | def read_little_endian32(self):
"""Interprets the next 4 bytes of the stream as a little-endian
encoded, unsiged 32-bit integer, and returns that integer.
"""
try:
i = struct.unpack(wire_format.FORMAT_UINT32_LITTLE_ENDIAN,
self._input.read(4))
... | [
"def",
"read_little_endian32",
"(",
"self",
")",
":",
"try",
":",
"i",
"=",
"struct",
".",
"unpack",
"(",
"wire_format",
".",
"FORMAT_UINT32_LITTLE_ENDIAN",
",",
"self",
".",
"_input",
".",
"read",
"(",
"4",
")",
")",
"self",
".",
"_pos",
"+=",
"4",
"r... | Interprets the next 4 bytes of the stream as a little-endian
encoded, unsiged 32-bit integer, and returns that integer. | [
"Interprets",
"the",
"next",
"4",
"bytes",
"of",
"the",
"stream",
"as",
"a",
"little",
"-",
"endian",
"encoded",
"unsiged",
"32",
"-",
"bit",
"integer",
"and",
"returns",
"that",
"integer",
"."
] | python | train | 43 |
heuer/cablemap | cablemap.core/cablemap/core/c14n.py | https://github.com/heuer/cablemap/blob/42066c8fc2972d237a2c35578e14525aaf705f38/cablemap.core/cablemap/core/c14n.py#L174-L181 | def canonicalize_origin(origin):
"""\
"""
origin = origin.replace(u'USMISSION', u'') \
.replace(u'AMEMBASSY', u'') \
.replace(u'EMBASSY', u'').strip()
return _STATION_C14N.get(origin, origin) | [
"def",
"canonicalize_origin",
"(",
"origin",
")",
":",
"origin",
"=",
"origin",
".",
"replace",
"(",
"u'USMISSION'",
",",
"u''",
")",
".",
"replace",
"(",
"u'AMEMBASSY'",
",",
"u''",
")",
".",
"replace",
"(",
"u'EMBASSY'",
",",
"u''",
")",
".",
"strip",
... | \ | [
"\\"
] | python | train | 30.375 |
apache/incubator-superset | superset/views/core.py | https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/core.py#L2465-L2501 | def results(self, key):
"""Serves a key off of the results backend"""
if not results_backend:
return json_error_response("Results backend isn't configured")
read_from_results_backend_start = now_as_float()
blob = results_backend.get(key)
stats_logger.timing(
... | [
"def",
"results",
"(",
"self",
",",
"key",
")",
":",
"if",
"not",
"results_backend",
":",
"return",
"json_error_response",
"(",
"\"Results backend isn't configured\"",
")",
"read_from_results_backend_start",
"=",
"now_as_float",
"(",
")",
"blob",
"=",
"results_backend... | Serves a key off of the results backend | [
"Serves",
"a",
"key",
"off",
"of",
"the",
"results",
"backend"
] | python | train | 38.486486 |
pgmpy/pgmpy | pgmpy/factors/discrete/JointProbabilityDistribution.py | https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/discrete/JointProbabilityDistribution.py#L206-L236 | def get_independencies(self, condition=None):
"""
Returns the independent variables in the joint probability distribution.
Returns marginally independent variables if condition=None.
Returns conditionally independent variables if condition!=None
Parameter
---------
... | [
"def",
"get_independencies",
"(",
"self",
",",
"condition",
"=",
"None",
")",
":",
"JPD",
"=",
"self",
".",
"copy",
"(",
")",
"if",
"condition",
":",
"JPD",
".",
"conditional_distribution",
"(",
"condition",
")",
"independencies",
"=",
"Independencies",
"(",... | Returns the independent variables in the joint probability distribution.
Returns marginally independent variables if condition=None.
Returns conditionally independent variables if condition!=None
Parameter
---------
condition: array_like
Random Variable on which ... | [
"Returns",
"the",
"independent",
"variables",
"in",
"the",
"joint",
"probability",
"distribution",
".",
"Returns",
"marginally",
"independent",
"variables",
"if",
"condition",
"=",
"None",
".",
"Returns",
"conditionally",
"independent",
"variables",
"if",
"condition!"... | python | train | 41.870968 |
google/apitools | apitools/base/py/encoding_helper.py | https://github.com/google/apitools/blob/f3745a7ea535aa0e88b0650c16479b696d6fd446/apitools/base/py/encoding_helper.py#L93-L98 | def RegisterCustomFieldCodec(encoder, decoder):
"""Register a custom encoder/decoder for this field."""
def Register(field):
_CUSTOM_FIELD_CODECS[field] = _Codec(encoder=encoder, decoder=decoder)
return field
return Register | [
"def",
"RegisterCustomFieldCodec",
"(",
"encoder",
",",
"decoder",
")",
":",
"def",
"Register",
"(",
"field",
")",
":",
"_CUSTOM_FIELD_CODECS",
"[",
"field",
"]",
"=",
"_Codec",
"(",
"encoder",
"=",
"encoder",
",",
"decoder",
"=",
"decoder",
")",
"return",
... | Register a custom encoder/decoder for this field. | [
"Register",
"a",
"custom",
"encoder",
"/",
"decoder",
"for",
"this",
"field",
"."
] | python | train | 41.166667 |
danielhrisca/asammdf | asammdf/mdf.py | https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/mdf.py#L590-L912 | def cut(
self,
start=None,
stop=None,
whence=0,
version=None,
include_ends=True,
time_from_zero=False,
):
"""cut *MDF* file. *start* and *stop* limits are absolute values
or values relative to the first timestamp depending on the *whence*
... | [
"def",
"cut",
"(",
"self",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
",",
"whence",
"=",
"0",
",",
"version",
"=",
"None",
",",
"include_ends",
"=",
"True",
",",
"time_from_zero",
"=",
"False",
",",
")",
":",
"if",
"version",
"is",
"None... | cut *MDF* file. *start* and *stop* limits are absolute values
or values relative to the first timestamp depending on the *whence*
argument.
Parameters
----------
start : float
start time, default *None*. If *None* then the start of measurement
is used
... | [
"cut",
"*",
"MDF",
"*",
"file",
".",
"*",
"start",
"*",
"and",
"*",
"stop",
"*",
"limits",
"are",
"absolute",
"values",
"or",
"values",
"relative",
"to",
"the",
"first",
"timestamp",
"depending",
"on",
"the",
"*",
"whence",
"*",
"argument",
"."
] | python | train | 36.585139 |
infothrill/python-launchd | launchd/launchctl.py | https://github.com/infothrill/python-launchd/blob/2cd50579e808851b116f5a26f9b871a32b65ce0e/launchd/launchctl.py#L55-L70 | def properties(self):
'''
This is a lazily loaded dictionary containing the launchd runtime
information of the job in question. Internally, this is retrieved
using ServiceManagement.SMJobCopyDictionary(). Keep in mind that
some dictionary keys are not always present (for example ... | [
"def",
"properties",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'_nsproperties'",
")",
":",
"self",
".",
"_properties",
"=",
"convert_NSDictionary_to_dict",
"(",
"self",
".",
"_nsproperties",
")",
"del",
"self",
".",
"_nsproperties",
"#self._ns... | This is a lazily loaded dictionary containing the launchd runtime
information of the job in question. Internally, this is retrieved
using ServiceManagement.SMJobCopyDictionary(). Keep in mind that
some dictionary keys are not always present (for example 'PID').
If the job specified by th... | [
"This",
"is",
"a",
"lazily",
"loaded",
"dictionary",
"containing",
"the",
"launchd",
"runtime",
"information",
"of",
"the",
"job",
"in",
"question",
".",
"Internally",
"this",
"is",
"retrieved",
"using",
"ServiceManagement",
".",
"SMJobCopyDictionary",
"()",
".",
... | python | train | 46.4375 |
UCSBarchlab/PyRTL | pyrtl/rtllib/barrel.py | https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/rtllib/barrel.py#L6-L44 | def barrel_shifter(bits_to_shift, bit_in, direction, shift_dist, wrap_around=0):
""" Create a barrel shifter that operates on data based on the wire width.
:param bits_to_shift: the input wire
:param bit_in: the 1-bit wire giving the value to shift in
:param direction: a one bit WireVector representing... | [
"def",
"barrel_shifter",
"(",
"bits_to_shift",
",",
"bit_in",
",",
"direction",
",",
"shift_dist",
",",
"wrap_around",
"=",
"0",
")",
":",
"from",
"pyrtl",
"import",
"concat",
",",
"select",
"# just for readability",
"if",
"wrap_around",
"!=",
"0",
":",
"raise... | Create a barrel shifter that operates on data based on the wire width.
:param bits_to_shift: the input wire
:param bit_in: the 1-bit wire giving the value to shift in
:param direction: a one bit WireVector representing shift direction
(0 = shift down, 1 = shift up)
:param shift_dist: WireVector... | [
"Create",
"a",
"barrel",
"shifter",
"that",
"operates",
"on",
"data",
"based",
"on",
"the",
"wire",
"width",
"."
] | python | train | 44.333333 |
tensorflow/tensor2tensor | tensor2tensor/utils/beam_search.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/beam_search.py#L396-L813 | def beam_search(symbols_to_logits_fn,
initial_ids,
beam_size,
decode_length,
vocab_size,
alpha,
states=None,
eos_id=EOS_ID,
stop_early=True,
use_tpu=False,
use_... | [
"def",
"beam_search",
"(",
"symbols_to_logits_fn",
",",
"initial_ids",
",",
"beam_size",
",",
"decode_length",
",",
"vocab_size",
",",
"alpha",
",",
"states",
"=",
"None",
",",
"eos_id",
"=",
"EOS_ID",
",",
"stop_early",
"=",
"True",
",",
"use_tpu",
"=",
"Fa... | Beam search with length penalties.
Requires a function that can take the currently decoded symbols and return
the logits for the next symbol. The implementation is inspired by
https://arxiv.org/abs/1609.08144.
When running, the beam search steps can be visualized by using tfdbg to watch
the operations gener... | [
"Beam",
"search",
"with",
"length",
"penalties",
"."
] | python | train | 42.851675 |
python-diamond/Diamond | src/collectors/rabbitmq/rabbitmq.py | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/rabbitmq/rabbitmq.py#L284-L300 | def _publish_metrics(self, name, prev_keys, key, data):
"""Recursively publish keys"""
value = data[key]
keys = prev_keys + [key]
if isinstance(value, dict):
for new_key in value:
self._publish_metrics(name, keys, new_key, value)
elif isinstance(value,... | [
"def",
"_publish_metrics",
"(",
"self",
",",
"name",
",",
"prev_keys",
",",
"key",
",",
"data",
")",
":",
"value",
"=",
"data",
"[",
"key",
"]",
"keys",
"=",
"prev_keys",
"+",
"[",
"key",
"]",
"if",
"isinstance",
"(",
"value",
",",
"dict",
")",
":"... | Recursively publish keys | [
"Recursively",
"publish",
"keys"
] | python | train | 37.176471 |
gunthercox/ChatterBot | chatterbot/storage/mongodb.py | https://github.com/gunthercox/ChatterBot/blob/1a03dcb45cba7bdc24d3db5e750582e0cb1518e2/chatterbot/storage/mongodb.py#L44-L54 | def get_statement_model(self):
"""
Return the class for the statement model.
"""
from chatterbot.conversation import Statement
# Create a storage-aware statement
statement = Statement
statement.storage = self
return statement | [
"def",
"get_statement_model",
"(",
"self",
")",
":",
"from",
"chatterbot",
".",
"conversation",
"import",
"Statement",
"# Create a storage-aware statement",
"statement",
"=",
"Statement",
"statement",
".",
"storage",
"=",
"self",
"return",
"statement"
] | Return the class for the statement model. | [
"Return",
"the",
"class",
"for",
"the",
"statement",
"model",
"."
] | python | train | 25.545455 |
biocommons/bioutils | src/bioutils/seqfetcher.py | https://github.com/biocommons/bioutils/blob/88bcbdfa707268fed1110800e91b6d4f8e9475a0/src/bioutils/seqfetcher.py#L24-L123 | def fetch_seq(ac, start_i=None, end_i=None):
"""Fetches sequences and subsequences from NCBI eutils and Ensembl
REST interfaces.
:param string ac: accession of sequence to fetch
:param int start_i: start position of *interbase* interval
:param int end_i: end position of *interbase* interval
*... | [
"def",
"fetch_seq",
"(",
"ac",
",",
"start_i",
"=",
"None",
",",
"end_i",
"=",
"None",
")",
":",
"ac_dispatch",
"=",
"[",
"{",
"\"re\"",
":",
"re",
".",
"compile",
"(",
"r\"^(?:AC|N[CGMPRTW])_|^[A-L]\\w\\d|^U\\d\"",
")",
",",
"\"fetcher\"",
":",
"_fetch_seq_... | Fetches sequences and subsequences from NCBI eutils and Ensembl
REST interfaces.
:param string ac: accession of sequence to fetch
:param int start_i: start position of *interbase* interval
:param int end_i: end position of *interbase* interval
**IMPORTANT** start_i and end_i specify 0-based inter... | [
"Fetches",
"sequences",
"and",
"subsequences",
"from",
"NCBI",
"eutils",
"and",
"Ensembl",
"REST",
"interfaces",
"."
] | python | train | 32.29 |
kytos/kytos-utils | kytos/utils/napps.py | https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/napps.py#L120-L127 | def get_disabled(self):
"""Sorted list of (username, napp_name) of disabled napps.
The difference of installed and enabled.
"""
installed = set(self.get_installed())
enabled = set(self.get_enabled())
return sorted(installed - enabled) | [
"def",
"get_disabled",
"(",
"self",
")",
":",
"installed",
"=",
"set",
"(",
"self",
".",
"get_installed",
"(",
")",
")",
"enabled",
"=",
"set",
"(",
"self",
".",
"get_enabled",
"(",
")",
")",
"return",
"sorted",
"(",
"installed",
"-",
"enabled",
")"
] | Sorted list of (username, napp_name) of disabled napps.
The difference of installed and enabled. | [
"Sorted",
"list",
"of",
"(",
"username",
"napp_name",
")",
"of",
"disabled",
"napps",
"."
] | python | train | 34.5 |
Azure/azure-sdk-for-python | azure-servicemanagement-legacy/azure/servicemanagement/servicemanagementservice.py | https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/servicemanagementservice.py#L985-L999 | def get_management_certificate(self, thumbprint):
'''
The Get Management Certificate operation retrieves information about
the management certificate with the specified thumbprint. Management
certificates, which are also known as subscription certificates,
authenticate clients at... | [
"def",
"get_management_certificate",
"(",
"self",
",",
"thumbprint",
")",
":",
"_validate_not_none",
"(",
"'thumbprint'",
",",
"thumbprint",
")",
"return",
"self",
".",
"_perform_get",
"(",
"'/'",
"+",
"self",
".",
"subscription_id",
"+",
"'/certificates/'",
"+",
... | The Get Management Certificate operation retrieves information about
the management certificate with the specified thumbprint. Management
certificates, which are also known as subscription certificates,
authenticate clients attempting to connect to resources associated
with your Windows ... | [
"The",
"Get",
"Management",
"Certificate",
"operation",
"retrieves",
"information",
"about",
"the",
"management",
"certificate",
"with",
"the",
"specified",
"thumbprint",
".",
"Management",
"certificates",
"which",
"are",
"also",
"known",
"as",
"subscription",
"certif... | python | test | 45.533333 |
Kaggle/kaggle-api | kaggle/api/kaggle_api_extended.py | https://github.com/Kaggle/kaggle-api/blob/65f14b1386470c5784d4753e491478e7537660d9/kaggle/api/kaggle_api_extended.py#L290-L307 | def unset_config_value(self, name, quiet=False):
"""unset a configuration value
Parameters
==========
name: the name of the value to unset (remove key in dictionary)
quiet: disable verbose output if True (default is False)
"""
config_data = self._rea... | [
"def",
"unset_config_value",
"(",
"self",
",",
"name",
",",
"quiet",
"=",
"False",
")",
":",
"config_data",
"=",
"self",
".",
"_read_config_file",
"(",
")",
"if",
"name",
"in",
"config_data",
":",
"del",
"config_data",
"[",
"name",
"]",
"self",
".",
"_wr... | unset a configuration value
Parameters
==========
name: the name of the value to unset (remove key in dictionary)
quiet: disable verbose output if True (default is False) | [
"unset",
"a",
"configuration",
"value",
"Parameters",
"==========",
"name",
":",
"the",
"name",
"of",
"the",
"value",
"to",
"unset",
"(",
"remove",
"key",
"in",
"dictionary",
")",
"quiet",
":",
"disable",
"verbose",
"output",
"if",
"True",
"(",
"default",
... | python | train | 29.944444 |
nicolargo/glances | glances/outputs/glances_curses.py | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L478-L511 | def __get_stat_display(self, stats, layer):
"""Return a dict of dict with all the stats display.
stats: Global stats dict
layer: ~ cs_status
"None": standalone or server mode
"Connected": Client is connected to a Glances server
"SNMP": Client is connected to a... | [
"def",
"__get_stat_display",
"(",
"self",
",",
"stats",
",",
"layer",
")",
":",
"ret",
"=",
"{",
"}",
"for",
"p",
"in",
"stats",
".",
"getPluginsList",
"(",
"enable",
"=",
"False",
")",
":",
"if",
"p",
"==",
"'quicklook'",
"or",
"p",
"==",
"'processl... | Return a dict of dict with all the stats display.
stats: Global stats dict
layer: ~ cs_status
"None": standalone or server mode
"Connected": Client is connected to a Glances server
"SNMP": Client is connected to a SNMP server
"Disconnected": Client is disc... | [
"Return",
"a",
"dict",
"of",
"dict",
"with",
"all",
"the",
"stats",
"display",
".",
"stats",
":",
"Global",
"stats",
"dict",
"layer",
":",
"~",
"cs_status",
"None",
":",
"standalone",
"or",
"server",
"mode",
"Connected",
":",
"Client",
"is",
"connected",
... | python | train | 40.764706 |
bfrog/whizzer | whizzer/rpc/msgpackrpc.py | https://github.com/bfrog/whizzer/blob/a1e43084b3ac8c1f3fb4ada081777cdbf791fd77/whizzer/rpc/msgpackrpc.py#L174-L182 | def proxy(self):
"""Return a Deferred that will result in a proxy object in the future."""
d = Deferred(self.loop)
self._proxy_deferreds.append(d)
if self._proxy:
d.callback(self._proxy)
return d | [
"def",
"proxy",
"(",
"self",
")",
":",
"d",
"=",
"Deferred",
"(",
"self",
".",
"loop",
")",
"self",
".",
"_proxy_deferreds",
".",
"append",
"(",
"d",
")",
"if",
"self",
".",
"_proxy",
":",
"d",
".",
"callback",
"(",
"self",
".",
"_proxy",
")",
"r... | Return a Deferred that will result in a proxy object in the future. | [
"Return",
"a",
"Deferred",
"that",
"will",
"result",
"in",
"a",
"proxy",
"object",
"in",
"the",
"future",
"."
] | python | train | 26.777778 |
apache/airflow | airflow/www/security.py | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/www/security.py#L236-L244 | def get_all_permissions_views(self):
"""
Returns a set of tuples with the perm name and view menu name
"""
perms_views = set()
for role in self.get_user_roles():
perms_views.update({(perm_view.permission.name, perm_view.view_menu.name)
... | [
"def",
"get_all_permissions_views",
"(",
"self",
")",
":",
"perms_views",
"=",
"set",
"(",
")",
"for",
"role",
"in",
"self",
".",
"get_user_roles",
"(",
")",
":",
"perms_views",
".",
"update",
"(",
"{",
"(",
"perm_view",
".",
"permission",
".",
"name",
"... | Returns a set of tuples with the perm name and view menu name | [
"Returns",
"a",
"set",
"of",
"tuples",
"with",
"the",
"perm",
"name",
"and",
"view",
"menu",
"name"
] | python | test | 41.555556 |
davgeo/clear | clear/database.py | https://github.com/davgeo/clear/blob/5ec85d27efd28afddfcd4c3f44df17f0115a77aa/clear/database.py#L422-L435 | def UpdateShowDirInTVLibrary(self, showID, showDir):
"""
Update show directory entry for given show id in TVLibrary table.
Parameters
----------
showID : int
Show id value.
showDir : string
Show directory name.
"""
goodlogging.Log.Info("DB", "Updating TV library for... | [
"def",
"UpdateShowDirInTVLibrary",
"(",
"self",
",",
"showID",
",",
"showDir",
")",
":",
"goodlogging",
".",
"Log",
".",
"Info",
"(",
"\"DB\"",
",",
"\"Updating TV library for ShowID={0}: ShowDir={1}\"",
".",
"format",
"(",
"showID",
",",
"showDir",
")",
")",
"s... | Update show directory entry for given show id in TVLibrary table.
Parameters
----------
showID : int
Show id value.
showDir : string
Show directory name. | [
"Update",
"show",
"directory",
"entry",
"for",
"given",
"show",
"id",
"in",
"TVLibrary",
"table",
"."
] | python | train | 32.142857 |
sdispater/orator | orator/orm/relations/has_many_through.py | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/has_many_through.py#L129-L149 | def _build_dictionary(self, results):
"""
Build model dictionary keyed by the relation's foreign key.
:param results: The results
:type results: Collection
:rtype: dict
"""
foreign = self._first_key
dictionary = {}
for result in results:
... | [
"def",
"_build_dictionary",
"(",
"self",
",",
"results",
")",
":",
"foreign",
"=",
"self",
".",
"_first_key",
"dictionary",
"=",
"{",
"}",
"for",
"result",
"in",
"results",
":",
"key",
"=",
"getattr",
"(",
"result",
",",
"foreign",
")",
"if",
"key",
"n... | Build model dictionary keyed by the relation's foreign key.
:param results: The results
:type results: Collection
:rtype: dict | [
"Build",
"model",
"dictionary",
"keyed",
"by",
"the",
"relation",
"s",
"foreign",
"key",
"."
] | python | train | 22.952381 |
edeposit/marcxml_parser | src/marcxml_parser/query.py | https://github.com/edeposit/marcxml_parser/blob/6d1c77c61fc2827b71f1b3d5aa3332d7f5807820/src/marcxml_parser/query.py#L430-L452 | def get_ISBNs(self):
"""
Get list of VALID ISBN.
Returns:
list: List with *valid* ISBN strings.
"""
invalid_isbns = set(self.get_invalid_ISBNs())
valid_isbns = [
self._clean_isbn(isbn)
for isbn in self["020a"]
if self._cle... | [
"def",
"get_ISBNs",
"(",
"self",
")",
":",
"invalid_isbns",
"=",
"set",
"(",
"self",
".",
"get_invalid_ISBNs",
"(",
")",
")",
"valid_isbns",
"=",
"[",
"self",
".",
"_clean_isbn",
"(",
"isbn",
")",
"for",
"isbn",
"in",
"self",
"[",
"\"020a\"",
"]",
"if"... | Get list of VALID ISBN.
Returns:
list: List with *valid* ISBN strings. | [
"Get",
"list",
"of",
"VALID",
"ISBN",
"."
] | python | valid | 24.217391 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L8995-L9013 | def scaled_imu_encode(self, time_boot_ms, xacc, yacc, zacc, xgyro, ygyro, zgyro, xmag, ymag, zmag):
'''
The RAW IMU readings for the usual 9DOF sensor setup. This message
should contain the scaled values to the described
units
time_boot_ms... | [
"def",
"scaled_imu_encode",
"(",
"self",
",",
"time_boot_ms",
",",
"xacc",
",",
"yacc",
",",
"zacc",
",",
"xgyro",
",",
"ygyro",
",",
"zgyro",
",",
"xmag",
",",
"ymag",
",",
"zmag",
")",
":",
"return",
"MAVLink_scaled_imu_message",
"(",
"time_boot_ms",
","... | The RAW IMU readings for the usual 9DOF sensor setup. This message
should contain the scaled values to the described
units
time_boot_ms : Timestamp (milliseconds since system boot) (uint32_t)
xacc : X acceleration (mg) (i... | [
"The",
"RAW",
"IMU",
"readings",
"for",
"the",
"usual",
"9DOF",
"sensor",
"setup",
".",
"This",
"message",
"should",
"contain",
"the",
"scaled",
"values",
"to",
"the",
"described",
"units"
] | python | train | 67.578947 |
materialsproject/pymatgen | pymatgen/core/bonds.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/core/bonds.py#L63-L83 | def get_bond_order(self, tol=0.2, default_bl=None):
"""
The bond order according the distance between the two sites
Args:
tol (float): Relative tolerance to test.
(1 + tol) * the longest bond distance is considered
to be the threshold length for a bond... | [
"def",
"get_bond_order",
"(",
"self",
",",
"tol",
"=",
"0.2",
",",
"default_bl",
"=",
"None",
")",
":",
"sp1",
"=",
"list",
"(",
"self",
".",
"site1",
".",
"species",
".",
"keys",
"(",
")",
")",
"[",
"0",
"]",
"sp2",
"=",
"list",
"(",
"self",
"... | The bond order according the distance between the two sites
Args:
tol (float): Relative tolerance to test.
(1 + tol) * the longest bond distance is considered
to be the threshold length for a bond to exist.
(1 - tol) * the shortest bond distance is con... | [
"The",
"bond",
"order",
"according",
"the",
"distance",
"between",
"the",
"two",
"sites",
"Args",
":",
"tol",
"(",
"float",
")",
":",
"Relative",
"tolerance",
"to",
"test",
".",
"(",
"1",
"+",
"tol",
")",
"*",
"the",
"longest",
"bond",
"distance",
"is"... | python | train | 47.761905 |
bcbio/bcbio-nextgen | bcbio/variation/validate.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/validate.py#L443-L450 | def _get_location_list(interval_bed):
"""Retrieve list of locations to analyze from input BED file.
"""
import pybedtools
regions = collections.OrderedDict()
for region in pybedtools.BedTool(interval_bed):
regions[str(region.chrom)] = None
return regions.keys() | [
"def",
"_get_location_list",
"(",
"interval_bed",
")",
":",
"import",
"pybedtools",
"regions",
"=",
"collections",
".",
"OrderedDict",
"(",
")",
"for",
"region",
"in",
"pybedtools",
".",
"BedTool",
"(",
"interval_bed",
")",
":",
"regions",
"[",
"str",
"(",
"... | Retrieve list of locations to analyze from input BED file. | [
"Retrieve",
"list",
"of",
"locations",
"to",
"analyze",
"from",
"input",
"BED",
"file",
"."
] | python | train | 35.75 |
fm4d/PyMarkovTextGenerator | markov.py | https://github.com/fm4d/PyMarkovTextGenerator/blob/4a7e8e2cfe14c9745aba6b9df7d7b402a9029a37/markov.py#L170-L192 | def build_chain(self, source, chain):
"""
Build markov chain from source on top of existin chain
Args:
source: iterable which will be used to build chain
chain: MarkovChain in currently loaded shelve file that
will be extended by source
"""
... | [
"def",
"build_chain",
"(",
"self",
",",
"source",
",",
"chain",
")",
":",
"for",
"group",
"in",
"WalkByGroup",
"(",
"source",
",",
"chain",
".",
"order",
"+",
"1",
")",
":",
"pre",
"=",
"group",
"[",
":",
"-",
"1",
"]",
"res",
"=",
"group",
"[",
... | Build markov chain from source on top of existin chain
Args:
source: iterable which will be used to build chain
chain: MarkovChain in currently loaded shelve file that
will be extended by source | [
"Build",
"markov",
"chain",
"from",
"source",
"on",
"top",
"of",
"existin",
"chain"
] | python | test | 30.826087 |
apple/turicreate | src/unity/python/turicreate/data_structures/sframe.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/data_structures/sframe.py#L4354-L4449 | def filter_by(self, values, column_name, exclude=False):
"""
Filter an SFrame by values inside an iterable object. Result is an
SFrame that only includes (or excludes) the rows that have a column
with the given ``column_name`` which holds one of the values in the
given ``values``... | [
"def",
"filter_by",
"(",
"self",
",",
"values",
",",
"column_name",
",",
"exclude",
"=",
"False",
")",
":",
"if",
"type",
"(",
"column_name",
")",
"is",
"not",
"str",
":",
"raise",
"TypeError",
"(",
"\"Must pass a str as column_name\"",
")",
"existing_columns"... | Filter an SFrame by values inside an iterable object. Result is an
SFrame that only includes (or excludes) the rows that have a column
with the given ``column_name`` which holds one of the values in the
given ``values`` :class:`~turicreate.SArray`. If ``values`` is not an
SArray, we atte... | [
"Filter",
"an",
"SFrame",
"by",
"values",
"inside",
"an",
"iterable",
"object",
".",
"Result",
"is",
"an",
"SFrame",
"that",
"only",
"includes",
"(",
"or",
"excludes",
")",
"the",
"rows",
"that",
"have",
"a",
"column",
"with",
"the",
"given",
"column_name"... | python | train | 40.96875 |
nirum/descent | descent/utils.py | https://github.com/nirum/descent/blob/074c8452f15a0da638668a4fe139fde06ccfae7f/descent/utils.py#L17-L36 | def wrap(f_df, xref, size=1):
"""
Memoizes an objective + gradient function, and splits it into
two functions that return just the objective and gradient, respectively.
Parameters
----------
f_df : function
Must be unary (takes a single argument)
xref : list, dict, or array_like
... | [
"def",
"wrap",
"(",
"f_df",
",",
"xref",
",",
"size",
"=",
"1",
")",
":",
"memoized_f_df",
"=",
"lrucache",
"(",
"lambda",
"x",
":",
"f_df",
"(",
"restruct",
"(",
"x",
",",
"xref",
")",
")",
",",
"size",
")",
"objective",
"=",
"compose",
"(",
"fi... | Memoizes an objective + gradient function, and splits it into
two functions that return just the objective and gradient, respectively.
Parameters
----------
f_df : function
Must be unary (takes a single argument)
xref : list, dict, or array_like
The form of the parameters
size... | [
"Memoizes",
"an",
"objective",
"+",
"gradient",
"function",
"and",
"splits",
"it",
"into",
"two",
"functions",
"that",
"return",
"just",
"the",
"objective",
"and",
"gradient",
"respectively",
"."
] | python | valid | 30.4 |
stefanbraun-private/visitoolkit_eventsystem | visitoolkit_eventsystem/eventsystem.py | https://github.com/stefanbraun-private/visitoolkit_eventsystem/blob/d606a167ac3b8edc5bfbd8de7fb7063a9a1922f1/visitoolkit_eventsystem/eventsystem.py#L136-L143 | def unhandle(self, handler):
""" unregister handler (removing callback function) """
with self._hlock:
try:
self._handler_list.remove(handler)
except ValueError:
raise ValueError("Handler is not handling this event, so cannot unhandle it.")
... | [
"def",
"unhandle",
"(",
"self",
",",
"handler",
")",
":",
"with",
"self",
".",
"_hlock",
":",
"try",
":",
"self",
".",
"_handler_list",
".",
"remove",
"(",
"handler",
")",
"except",
"ValueError",
":",
"raise",
"ValueError",
"(",
"\"Handler is not handling th... | unregister handler (removing callback function) | [
"unregister",
"handler",
"(",
"removing",
"callback",
"function",
")"
] | python | train | 40.625 |
googledatalab/pydatalab | google/datalab/utils/commands/_html.py | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/utils/commands/_html.py#L96-L149 | def _render_objects(self, items, attributes=None, datatype='object'):
"""Renders an HTML table with the specified list of objects.
Args:
items: the iterable collection of objects to render.
attributes: the optional list of properties or keys to render.
datatype: the type of data; one of 'obje... | [
"def",
"_render_objects",
"(",
"self",
",",
"items",
",",
"attributes",
"=",
"None",
",",
"datatype",
"=",
"'object'",
")",
":",
"if",
"not",
"items",
":",
"return",
"if",
"datatype",
"==",
"'chartdata'",
":",
"if",
"not",
"attributes",
":",
"attributes",
... | Renders an HTML table with the specified list of objects.
Args:
items: the iterable collection of objects to render.
attributes: the optional list of properties or keys to render.
datatype: the type of data; one of 'object' for Python objects, 'dict' for a list
of dictionaries, or 'char... | [
"Renders",
"an",
"HTML",
"table",
"with",
"the",
"specified",
"list",
"of",
"objects",
"."
] | python | train | 37.611111 |
johnbywater/eventsourcing | eventsourcing/infrastructure/eventstore.py | https://github.com/johnbywater/eventsourcing/blob/de2c22c653fdccf2f5ee96faea74453ff1847e42/eventsourcing/infrastructure/eventstore.py#L177-L183 | def all_domain_events(self):
"""
Yields all domain events in the event store.
"""
for originator_id in self.record_manager.all_sequence_ids():
for domain_event in self.get_domain_events(originator_id=originator_id, page_size=100):
yield domain_event | [
"def",
"all_domain_events",
"(",
"self",
")",
":",
"for",
"originator_id",
"in",
"self",
".",
"record_manager",
".",
"all_sequence_ids",
"(",
")",
":",
"for",
"domain_event",
"in",
"self",
".",
"get_domain_events",
"(",
"originator_id",
"=",
"originator_id",
","... | Yields all domain events in the event store. | [
"Yields",
"all",
"domain",
"events",
"in",
"the",
"event",
"store",
"."
] | python | train | 43.285714 |
barrust/mediawiki | mediawiki/mediawikipage.py | https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawikipage.py#L360-L384 | def summarize(self, sentences=0, chars=0):
""" Summarize page either by number of sentences, chars, or first
section (**default**)
Args:
sentences (int): Number of sentences to use in summary \
(first `x` sentences)
chars ... | [
"def",
"summarize",
"(",
"self",
",",
"sentences",
"=",
"0",
",",
"chars",
"=",
"0",
")",
":",
"query_params",
"=",
"{",
"\"prop\"",
":",
"\"extracts\"",
",",
"\"explaintext\"",
":",
"\"\"",
",",
"\"titles\"",
":",
"self",
".",
"title",
"}",
"if",
"sen... | Summarize page either by number of sentences, chars, or first
section (**default**)
Args:
sentences (int): Number of sentences to use in summary \
(first `x` sentences)
chars (int): Number of characters to use in summary \
... | [
"Summarize",
"page",
"either",
"by",
"number",
"of",
"sentences",
"chars",
"or",
"first",
"section",
"(",
"**",
"default",
"**",
")"
] | python | train | 44.32 |
ratcashdev/mitemp | mitemp_bt/mitemp_bt_poller.py | https://github.com/ratcashdev/mitemp/blob/bd6ffed5bfd9a3a52dd8a4b96e896fa79b5c5f10/mitemp_bt/mitemp_bt_poller.py#L136-L154 | def _check_data(self):
"""Ensure that the data in the cache is valid.
If it's invalid, the cache is wiped.
"""
if not self.cache_available():
return
parsed = self._parse_data()
_LOGGER.debug('Received new data from sensor: Temp=%.1f, Humidity=%.1f',
... | [
"def",
"_check_data",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"cache_available",
"(",
")",
":",
"return",
"parsed",
"=",
"self",
".",
"_parse_data",
"(",
")",
"_LOGGER",
".",
"debug",
"(",
"'Received new data from sensor: Temp=%.1f, Humidity=%.1f'",
","... | Ensure that the data in the cache is valid.
If it's invalid, the cache is wiped. | [
"Ensure",
"that",
"the",
"data",
"in",
"the",
"cache",
"is",
"valid",
"."
] | python | train | 31.473684 |
pyGrowler/Growler | growler/http/parser.py | https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/http/parser.py#L280-L303 | def determine_newline(data):
"""
Looks for a newline character in bytestring parameter 'data'.
Currently only looks for strings '\r\n', '\n'. If '\n' is
found at the first position of the string, this raises an
exception.
Parameters:
data (bytes): The data to... | [
"def",
"determine_newline",
"(",
"data",
")",
":",
"line_end_pos",
"=",
"data",
".",
"find",
"(",
"b'\\n'",
")",
"if",
"line_end_pos",
"==",
"-",
"1",
":",
"return",
"None",
"elif",
"line_end_pos",
"==",
"0",
":",
"return",
"b'\\n'",
"prev_char",
"=",
"d... | Looks for a newline character in bytestring parameter 'data'.
Currently only looks for strings '\r\n', '\n'. If '\n' is
found at the first position of the string, this raises an
exception.
Parameters:
data (bytes): The data to be searched
Returns:
None: ... | [
"Looks",
"for",
"a",
"newline",
"character",
"in",
"bytestring",
"parameter",
"data",
".",
"Currently",
"only",
"looks",
"for",
"strings",
"\\",
"r",
"\\",
"n",
"\\",
"n",
".",
"If",
"\\",
"n",
"is",
"found",
"at",
"the",
"first",
"position",
"of",
"th... | python | train | 29.041667 |
ejeschke/ginga | ginga/util/heaptimer.py | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/heaptimer.py#L219-L228 | def remove_all_timers(self):
"""Remove all waiting timers and terminate any blocking threads."""
with self.lock:
if self.rtimer is not None:
self.rtimer.cancel()
self.timers = {}
self.heap = []
self.rtimer = None
self.expiring ... | [
"def",
"remove_all_timers",
"(",
"self",
")",
":",
"with",
"self",
".",
"lock",
":",
"if",
"self",
".",
"rtimer",
"is",
"not",
"None",
":",
"self",
".",
"rtimer",
".",
"cancel",
"(",
")",
"self",
".",
"timers",
"=",
"{",
"}",
"self",
".",
"heap",
... | Remove all waiting timers and terminate any blocking threads. | [
"Remove",
"all",
"waiting",
"timers",
"and",
"terminate",
"any",
"blocking",
"threads",
"."
] | python | train | 31.8 |
hsolbrig/pyjsg | pyjsg/jsglib/loader.py | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/jsglib/loader.py#L93-L99 | def is_valid(obj: JSGValidateable, log: Optional[Union[TextIO, Logger]] = None) -> bool:
""" Determine whether obj is valid
:param obj: Object to validate
:param log: Logger to record validation failures. If absent, no information is recorded
"""
return obj._is_valid(log) | [
"def",
"is_valid",
"(",
"obj",
":",
"JSGValidateable",
",",
"log",
":",
"Optional",
"[",
"Union",
"[",
"TextIO",
",",
"Logger",
"]",
"]",
"=",
"None",
")",
"->",
"bool",
":",
"return",
"obj",
".",
"_is_valid",
"(",
"log",
")"
] | Determine whether obj is valid
:param obj: Object to validate
:param log: Logger to record validation failures. If absent, no information is recorded | [
"Determine",
"whether",
"obj",
"is",
"valid"
] | python | train | 41.142857 |
pyQode/pyqode.core | pyqode/core/api/syntax_highlighter.py | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/api/syntax_highlighter.py#L144-L176 | def _get_format_from_style(self, token, style):
""" Returns a QTextCharFormat for token by reading a Pygments style.
"""
result = QtGui.QTextCharFormat()
items = list(style.style_for_token(token).items())
for key, value in items:
if value is None and key == 'color':
... | [
"def",
"_get_format_from_style",
"(",
"self",
",",
"token",
",",
"style",
")",
":",
"result",
"=",
"QtGui",
".",
"QTextCharFormat",
"(",
")",
"items",
"=",
"list",
"(",
"style",
".",
"style_for_token",
"(",
"token",
")",
".",
"items",
"(",
")",
")",
"f... | Returns a QTextCharFormat for token by reading a Pygments style. | [
"Returns",
"a",
"QTextCharFormat",
"for",
"token",
"by",
"reading",
"a",
"Pygments",
"style",
"."
] | python | train | 47.818182 |
pypa/pipenv | pipenv/patched/notpip/_internal/operations/freeze.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/operations/freeze.py#L164-L223 | def get_requirement_info(dist):
# type: (Distribution) -> RequirementInfo
"""
Compute and return values (req, editable, comments) for use in
FrozenRequirement.from_dist().
"""
if not dist_is_editable(dist):
return (None, False, [])
location = os.path.normcase(os.path.abspath(dist.lo... | [
"def",
"get_requirement_info",
"(",
"dist",
")",
":",
"# type: (Distribution) -> RequirementInfo",
"if",
"not",
"dist_is_editable",
"(",
"dist",
")",
":",
"return",
"(",
"None",
",",
"False",
",",
"[",
"]",
")",
"location",
"=",
"os",
".",
"path",
".",
"norm... | Compute and return values (req, editable, comments) for use in
FrozenRequirement.from_dist(). | [
"Compute",
"and",
"return",
"values",
"(",
"req",
"editable",
"comments",
")",
"for",
"use",
"in",
"FrozenRequirement",
".",
"from_dist",
"()",
"."
] | python | train | 29.55 |
ethpm/py-ethpm | ethpm/utils/deployments.py | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/deployments.py#L69-L118 | def validate_deployments_tx_receipt(
deployments: Dict[str, Any], w3: Web3, allow_missing_data: bool = False
) -> None:
"""
Validate that address and block hash found in deployment data match what is found on-chain.
:allow_missing_data: by default, enforces validation of address and blockHash.
"""
... | [
"def",
"validate_deployments_tx_receipt",
"(",
"deployments",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"w3",
":",
"Web3",
",",
"allow_missing_data",
":",
"bool",
"=",
"False",
")",
"->",
"None",
":",
"# todo: provide hook to lazily look up tx receipt via binar... | Validate that address and block hash found in deployment data match what is found on-chain.
:allow_missing_data: by default, enforces validation of address and blockHash. | [
"Validate",
"that",
"address",
"and",
"block",
"hash",
"found",
"in",
"deployment",
"data",
"match",
"what",
"is",
"found",
"on",
"-",
"chain",
".",
":",
"allow_missing_data",
":",
"by",
"default",
"enforces",
"validation",
"of",
"address",
"and",
"blockHash",... | python | train | 51.58 |
martinpitt/python-dbusmock | dbusmock/templates/bluez4.py | https://github.com/martinpitt/python-dbusmock/blob/26f65f78bc0ed347233f699a8d6ee0e6880e7eb0/dbusmock/templates/bluez4.py#L376-L396 | def Connect(self):
'''Connect a device '''
device_path = self.path
if device_path not in mockobject.objects:
raise dbus.exceptions.DBusException('No such device.',
name='org.bluez.Error.NoSuchDevice')
device = mockobject.objects[device_path]
dev... | [
"def",
"Connect",
"(",
"self",
")",
":",
"device_path",
"=",
"self",
".",
"path",
"if",
"device_path",
"not",
"in",
"mockobject",
".",
"objects",
":",
"raise",
"dbus",
".",
"exceptions",
".",
"DBusException",
"(",
"'No such device.'",
",",
"name",
"=",
"'o... | Connect a device | [
"Connect",
"a",
"device"
] | python | train | 39.380952 |
DLR-RM/RAFCON | source/rafcon/gui/models/abstract_state.py | https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/models/abstract_state.py#L466-L522 | def load_meta_data(self, path=None):
"""Load meta data of state model from the file system
The meta data of the state model is loaded from the file system and stored in the meta property of the model.
Existing meta data is removed. Also the meta data of all state elements (data ports, outcomes,... | [
"def",
"load_meta_data",
"(",
"self",
",",
"path",
"=",
"None",
")",
":",
"# TODO: for an Execution state this method is called for each hierarchy level again and again, still?? check it!",
"# print(\"1AbstractState_load_meta_data: \", path, not path)",
"if",
"not",
"path",
":",
"pat... | Load meta data of state model from the file system
The meta data of the state model is loaded from the file system and stored in the meta property of the model.
Existing meta data is removed. Also the meta data of all state elements (data ports, outcomes,
etc) are loaded, as those stored in the... | [
"Load",
"meta",
"data",
"of",
"state",
"model",
"from",
"the",
"file",
"system"
] | python | train | 53.54386 |
stevearc/dql | dql/output.py | https://github.com/stevearc/dql/blob/e9d3aa22873076dae5ebd02e35318aa996b1e56a/dql/output.py#L55-L59 | def format_json(json_object, indent):
""" Pretty-format json data """
indent_str = "\n" + " " * indent
json_str = json.dumps(json_object, indent=2, default=serialize_json_var)
return indent_str.join(json_str.split("\n")) | [
"def",
"format_json",
"(",
"json_object",
",",
"indent",
")",
":",
"indent_str",
"=",
"\"\\n\"",
"+",
"\" \"",
"*",
"indent",
"json_str",
"=",
"json",
".",
"dumps",
"(",
"json_object",
",",
"indent",
"=",
"2",
",",
"default",
"=",
"serialize_json_var",
")"... | Pretty-format json data | [
"Pretty",
"-",
"format",
"json",
"data"
] | python | train | 46.4 |
fm4d/PyMarkovTextGenerator | markov.py | https://github.com/fm4d/PyMarkovTextGenerator/blob/4a7e8e2cfe14c9745aba6b9df7d7b402a9029a37/markov.py#L194-L223 | def generate_sentence(self, chain):
"""
!DEMO!
Demo function that shows how to generate a simple sentence starting with
uppercase letter without lenght limit.
Args:
chain: MarkovChain that will be used to generate sentence
"""
def weighted_choice(cho... | [
"def",
"generate_sentence",
"(",
"self",
",",
"chain",
")",
":",
"def",
"weighted_choice",
"(",
"choices",
")",
":",
"total_weight",
"=",
"sum",
"(",
"weight",
"for",
"val",
",",
"weight",
"in",
"choices",
")",
"rand",
"=",
"random",
".",
"uniform",
"(",... | !DEMO!
Demo function that shows how to generate a simple sentence starting with
uppercase letter without lenght limit.
Args:
chain: MarkovChain that will be used to generate sentence | [
"!DEMO!",
"Demo",
"function",
"that",
"shows",
"how",
"to",
"generate",
"a",
"simple",
"sentence",
"starting",
"with",
"uppercase",
"letter",
"without",
"lenght",
"limit",
"."
] | python | test | 29.566667 |
dnanexus/dx-toolkit | src/python/dxpy/api.py | https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/api.py#L595-L601 | def file_set_details(object_id, input_params={}, always_retry=True, **kwargs):
"""
Invokes the /file-xxxx/setDetails API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Details-and-Links#API-method%3A-%2Fclass-xxxx%2FsetDetails
"""
return DXHTTPRequest('/%s/setDetails... | [
"def",
"file_set_details",
"(",
"object_id",
",",
"input_params",
"=",
"{",
"}",
",",
"always_retry",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"DXHTTPRequest",
"(",
"'/%s/setDetails'",
"%",
"object_id",
",",
"input_params",
",",
"always_retry"... | Invokes the /file-xxxx/setDetails API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Details-and-Links#API-method%3A-%2Fclass-xxxx%2FsetDetails | [
"Invokes",
"the",
"/",
"file",
"-",
"xxxx",
"/",
"setDetails",
"API",
"method",
"."
] | python | train | 54.142857 |
MartinThoma/mpu | mpu/_cli.py | https://github.com/MartinThoma/mpu/blob/61bc36d0192ca90c0bcf9b8a5d7d0d8520e20ff6/mpu/_cli.py#L13-L20 | def main():
"""Command line interface of mpu."""
parser = get_parser()
args = parser.parse_args()
if hasattr(args, 'func') and args.func:
args.func(args)
else:
parser.print_help() | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"get_parser",
"(",
")",
"args",
"=",
"parser",
".",
"parse_args",
"(",
")",
"if",
"hasattr",
"(",
"args",
",",
"'func'",
")",
"and",
"args",
".",
"func",
":",
"args",
".",
"func",
"(",
"args",
")",
"el... | Command line interface of mpu. | [
"Command",
"line",
"interface",
"of",
"mpu",
"."
] | python | train | 26 |
emory-libraries/eulfedora | eulfedora/api.py | https://github.com/emory-libraries/eulfedora/blob/161826f3fdcdab4007f6fa7dfd9f1ecabc4bcbe4/eulfedora/api.py#L312-L389 | def addDatastream(self, pid, dsID, dsLabel=None, mimeType=None, logMessage=None,
controlGroup=None, dsLocation=None, altIDs=None, versionable=None,
dsState=None, formatURI=None, checksumType=None, checksum=None, content=None):
'''Add a new datastream to an existing object. On success,
t... | [
"def",
"addDatastream",
"(",
"self",
",",
"pid",
",",
"dsID",
",",
"dsLabel",
"=",
"None",
",",
"mimeType",
"=",
"None",
",",
"logMessage",
"=",
"None",
",",
"controlGroup",
"=",
"None",
",",
"dsLocation",
"=",
"None",
",",
"altIDs",
"=",
"None",
",",
... | Add a new datastream to an existing object. On success,
the return response should have a status of 201 Created;
if there is an error, the response body includes the error message.
:param pid: object pid
:param dsID: id for the new datastream
:param dslabel: label for the new d... | [
"Add",
"a",
"new",
"datastream",
"to",
"an",
"existing",
"object",
".",
"On",
"success",
"the",
"return",
"response",
"should",
"have",
"a",
"status",
"of",
"201",
"Created",
";",
"if",
"there",
"is",
"an",
"error",
"the",
"response",
"body",
"includes",
... | python | train | 46.448718 |
SKA-ScienceDataProcessor/integration-prototype | sip/science_pipeline_workflows/ingest_visibilities/send/async_send.py | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/science_pipeline_workflows/ingest_visibilities/send/async_send.py#L82-L98 | def fill_buffer(heap_data, i_chan):
"""Blocking function to populate data in the heap.
This is run in an executor.
"""
# Calculate the time count and fraction.
now = datetime.datetime.utcnow()
time_full = now.timestamp()
time_count = int(time_full)
time_fr... | [
"def",
"fill_buffer",
"(",
"heap_data",
",",
"i_chan",
")",
":",
"# Calculate the time count and fraction.",
"now",
"=",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
"time_full",
"=",
"now",
".",
"timestamp",
"(",
")",
"time_count",
"=",
"int",
"(",
... | Blocking function to populate data in the heap.
This is run in an executor. | [
"Blocking",
"function",
"to",
"populate",
"data",
"in",
"the",
"heap",
".",
"This",
"is",
"run",
"in",
"an",
"executor",
"."
] | python | train | 44.823529 |
bfontaine/p7magma | magma/session.py | https://github.com/bfontaine/p7magma/blob/713647aa9e3187c93c2577ef812f33ec42ae5494/magma/session.py#L95-L114 | def login(self, year, firstname, lastname, passwd, with_year=True):
"""
Authenticate an user
"""
firstname = firstname.upper()
lastname = lastname.upper()
if with_year and not self.set_year(year):
return False
url = URLS['login']
params = {
... | [
"def",
"login",
"(",
"self",
",",
"year",
",",
"firstname",
",",
"lastname",
",",
"passwd",
",",
"with_year",
"=",
"True",
")",
":",
"firstname",
"=",
"firstname",
".",
"upper",
"(",
")",
"lastname",
"=",
"lastname",
".",
"upper",
"(",
")",
"if",
"wi... | Authenticate an user | [
"Authenticate",
"an",
"user"
] | python | train | 24.9 |
cameronbwhite/Flask-CAS | flask_cas/cas_urls.py | https://github.com/cameronbwhite/Flask-CAS/blob/f85173938654cb9b9316a5c869000b74b008422e/flask_cas/cas_urls.py#L50-L74 | def create_cas_login_url(cas_url, cas_route, service, renew=None, gateway=None):
""" Create a CAS login URL .
Keyword arguments:
cas_url -- The url to the CAS (ex. http://sso.pdx.edu)
cas_route -- The route where the CAS lives on server (ex. /cas)
service -- (ex. http://localhost:5000/login)
r... | [
"def",
"create_cas_login_url",
"(",
"cas_url",
",",
"cas_route",
",",
"service",
",",
"renew",
"=",
"None",
",",
"gateway",
"=",
"None",
")",
":",
"return",
"create_url",
"(",
"cas_url",
",",
"cas_route",
",",
"(",
"'service'",
",",
"service",
")",
",",
... | Create a CAS login URL .
Keyword arguments:
cas_url -- The url to the CAS (ex. http://sso.pdx.edu)
cas_route -- The route where the CAS lives on server (ex. /cas)
service -- (ex. http://localhost:5000/login)
renew -- "true" or "false"
gateway -- "true" or "false"
Example usage:
>>> cr... | [
"Create",
"a",
"CAS",
"login",
"URL",
"."
] | python | train | 29.24 |
kajala/django-jutil | jutil/admin.py | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/admin.py#L75-L120 | def history_view(self, request, object_id, extra_context=None):
from django.template.response import TemplateResponse
from django.contrib.admin.options import get_content_type_for_model
from django.contrib.admin.utils import unquote
from django.core.exceptions import PermissionDenied
... | [
"def",
"history_view",
"(",
"self",
",",
"request",
",",
"object_id",
",",
"extra_context",
"=",
"None",
")",
":",
"from",
"django",
".",
"template",
".",
"response",
"import",
"TemplateResponse",
"from",
"django",
".",
"contrib",
".",
"admin",
".",
"options... | The 'history' admin view for this model. | [
"The",
"history",
"admin",
"view",
"for",
"this",
"model",
"."
] | python | train | 42.630435 |
CivicSpleen/ambry | ambry/valuetype/types.py | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/valuetype/types.py#L45-L54 | def nullify(v):
"""Convert empty strings and strings with only spaces to None values. """
if isinstance(v, six.string_types):
v = v.strip()
if v is None or v == '':
return None
else:
return v | [
"def",
"nullify",
"(",
"v",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"six",
".",
"string_types",
")",
":",
"v",
"=",
"v",
".",
"strip",
"(",
")",
"if",
"v",
"is",
"None",
"or",
"v",
"==",
"''",
":",
"return",
"None",
"else",
":",
"return",
... | Convert empty strings and strings with only spaces to None values. | [
"Convert",
"empty",
"strings",
"and",
"strings",
"with",
"only",
"spaces",
"to",
"None",
"values",
"."
] | python | train | 22.4 |
Alignak-monitoring-contrib/alignak-backend-client | alignak_backend_client/backend_client.py | https://github.com/Alignak-monitoring-contrib/alignak-backend-client/blob/1e21f6ce703e66984d1f9b20fe7866460ab50b39/alignak_backend_client/backend_client.py#L675-L749 | def delete_resource(self, resource_name, name):
"""Delete a specific resource by name"""
try:
logger.info("Trying to get %s: '%s'", resource_name, name)
if name is None:
# No name is defined, delete all the resources...
if not self.dry_run:
... | [
"def",
"delete_resource",
"(",
"self",
",",
"resource_name",
",",
"name",
")",
":",
"try",
":",
"logger",
".",
"info",
"(",
"\"Trying to get %s: '%s'\"",
",",
"resource_name",
",",
"name",
")",
"if",
"name",
"is",
"None",
":",
"# No name is defined, delete all t... | Delete a specific resource by name | [
"Delete",
"a",
"specific",
"resource",
"by",
"name"
] | python | test | 52.24 |
googleapis/google-cloud-python | logging/google/cloud/logging/_gapic.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/logging/google/cloud/logging/_gapic.py#L227-L244 | def sink_get(self, project, sink_name):
"""API call: retrieve a sink resource.
:type project: str
:param project: ID of the project containing the sink.
:type sink_name: str
:param sink_name: the name of the sink
:rtype: dict
:returns: The sink object returned... | [
"def",
"sink_get",
"(",
"self",
",",
"project",
",",
"sink_name",
")",
":",
"path",
"=",
"\"projects/%s/sinks/%s\"",
"%",
"(",
"project",
",",
"sink_name",
")",
"sink_pb",
"=",
"self",
".",
"_gapic_api",
".",
"get_sink",
"(",
"path",
")",
"# NOTE: LogSink me... | API call: retrieve a sink resource.
:type project: str
:param project: ID of the project containing the sink.
:type sink_name: str
:param sink_name: the name of the sink
:rtype: dict
:returns: The sink object returned from the API (converted from a
p... | [
"API",
"call",
":",
"retrieve",
"a",
"sink",
"resource",
"."
] | python | train | 36.833333 |
Chilipp/psyplot | psyplot/project.py | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/project.py#L232-L239 | def axes(self):
"""A mapping from axes to data objects with the plotter in this axes
"""
ret = utils.DefaultOrderedDict(lambda: self[1:0])
for arr in self:
if arr.psy.plotter is not None:
ret[arr.psy.plotter.ax].append(arr)
return OrderedDict(ret) | [
"def",
"axes",
"(",
"self",
")",
":",
"ret",
"=",
"utils",
".",
"DefaultOrderedDict",
"(",
"lambda",
":",
"self",
"[",
"1",
":",
"0",
"]",
")",
"for",
"arr",
"in",
"self",
":",
"if",
"arr",
".",
"psy",
".",
"plotter",
"is",
"not",
"None",
":",
... | A mapping from axes to data objects with the plotter in this axes | [
"A",
"mapping",
"from",
"axes",
"to",
"data",
"objects",
"with",
"the",
"plotter",
"in",
"this",
"axes"
] | python | train | 38.5 |
limix/limix-core | limix_core/optimize/optimize_bfgs.py | https://github.com/limix/limix-core/blob/5c590b4d351409f83ca320844b4897ce92203814/limix_core/optimize/optimize_bfgs.py#L15-L29 | def param_list_to_dict(list,param_struct,skeys):
"""convert from param dictionary to list
param_struct: structure of parameter array
"""
RV = []
i0= 0
for key in skeys:
val = param_struct[key]
shape = SP.array(val)
np = shape.prod()
i1 = i0+np
params = lis... | [
"def",
"param_list_to_dict",
"(",
"list",
",",
"param_struct",
",",
"skeys",
")",
":",
"RV",
"=",
"[",
"]",
"i0",
"=",
"0",
"for",
"key",
"in",
"skeys",
":",
"val",
"=",
"param_struct",
"[",
"key",
"]",
"shape",
"=",
"SP",
".",
"array",
"(",
"val",... | convert from param dictionary to list
param_struct: structure of parameter array | [
"convert",
"from",
"param",
"dictionary",
"to",
"list",
"param_struct",
":",
"structure",
"of",
"parameter",
"array"
] | python | train | 26.466667 |
iopipe/iopipe-python | iopipe/send_report.py | https://github.com/iopipe/iopipe-python/blob/4eb653977341bc67f8b1b87aedb3aaaefc25af61/iopipe/send_report.py#L12-L30 | def send_report(report, config):
"""
Sends the report to IOpipe's collector.
:param report: The report to be sent.
:param config: The IOpipe agent configuration.
"""
headers = {"Authorization": "Bearer {}".format(config["token"])}
url = "https://{host}{path}".format(**config)
try:
... | [
"def",
"send_report",
"(",
"report",
",",
"config",
")",
":",
"headers",
"=",
"{",
"\"Authorization\"",
":",
"\"Bearer {}\"",
".",
"format",
"(",
"config",
"[",
"\"token\"",
"]",
")",
"}",
"url",
"=",
"\"https://{host}{path}\"",
".",
"format",
"(",
"*",
"*... | Sends the report to IOpipe's collector.
:param report: The report to be sent.
:param config: The IOpipe agent configuration. | [
"Sends",
"the",
"report",
"to",
"IOpipe",
"s",
"collector",
"."
] | python | train | 32.421053 |
fabioz/PyDev.Debugger | _pydev_bundle/_pydev_completer.py | https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydev_bundle/_pydev_completer.py#L117-L151 | def attr_matches(self, text):
"""Compute matches when text contains a dot.
Assuming the text is of the form NAME.NAME....[NAME], and is
evaluatable in self.namespace or self.global_namespace, it will be
evaluated and its attributes (as revealed by dir()) are used as
possible com... | [
"def",
"attr_matches",
"(",
"self",
",",
"text",
")",
":",
"import",
"re",
"# Another option, seems to work great. Catches things like ''.<tab>",
"m",
"=",
"re",
".",
"match",
"(",
"r\"(\\S+(\\.\\w+)*)\\.(\\w*)$\"",
",",
"text",
")",
"# @UndefinedVariable",
"if",
"not",... | Compute matches when text contains a dot.
Assuming the text is of the form NAME.NAME....[NAME], and is
evaluatable in self.namespace or self.global_namespace, it will be
evaluated and its attributes (as revealed by dir()) are used as
possible completions. (For class instances, class me... | [
"Compute",
"matches",
"when",
"text",
"contains",
"a",
"dot",
"."
] | python | train | 29.771429 |
StorjOld/pyp2p | pyp2p/lib.py | https://github.com/StorjOld/pyp2p/blob/7024208c3af20511496a652ff212f54c420e0464/pyp2p/lib.py#L378-L414 | def get_wan_ip(n=0):
"""
That IP module sucks. Occasionally it returns an IP address behind
cloudflare which probably happens when cloudflare tries to proxy your web
request because it thinks you're trying to DoS. It's better if we just run
our own infrastructure.
"""
if n == 2:
try... | [
"def",
"get_wan_ip",
"(",
"n",
"=",
"0",
")",
":",
"if",
"n",
"==",
"2",
":",
"try",
":",
"ip",
"=",
"myip",
"(",
")",
"ip",
"=",
"extract_ip",
"(",
"ip",
")",
"if",
"is_ip_valid",
"(",
"ip",
")",
":",
"return",
"ip",
"except",
"Exception",
"as... | That IP module sucks. Occasionally it returns an IP address behind
cloudflare which probably happens when cloudflare tries to proxy your web
request because it thinks you're trying to DoS. It's better if we just run
our own infrastructure. | [
"That",
"IP",
"module",
"sucks",
".",
"Occasionally",
"it",
"returns",
"an",
"IP",
"address",
"behind",
"cloudflare",
"which",
"probably",
"happens",
"when",
"cloudflare",
"tries",
"to",
"proxy",
"your",
"web",
"request",
"because",
"it",
"thinks",
"you",
"re"... | python | train | 31.108108 |
ashmastaflash/kal-wrapper | kalibrate/fn.py | https://github.com/ashmastaflash/kal-wrapper/blob/80ee03ab7bd3172ac26b769d6b442960f3424b0e/kalibrate/fn.py#L206-L213 | def get_measurements_from_kal_scan(kal_out):
"""Return a list of all measurements from kalibrate channel scan."""
result = []
for line in kal_out.splitlines():
if "offset " in line:
p_line = line.split(' ')
result.append(p_line[-1])
return result | [
"def",
"get_measurements_from_kal_scan",
"(",
"kal_out",
")",
":",
"result",
"=",
"[",
"]",
"for",
"line",
"in",
"kal_out",
".",
"splitlines",
"(",
")",
":",
"if",
"\"offset \"",
"in",
"line",
":",
"p_line",
"=",
"line",
".",
"split",
"(",
"' '",
")",
... | Return a list of all measurements from kalibrate channel scan. | [
"Return",
"a",
"list",
"of",
"all",
"measurements",
"from",
"kalibrate",
"channel",
"scan",
"."
] | python | train | 35.875 |
AutomatedTester/Bugsy | bugsy/search.py | https://github.com/AutomatedTester/Bugsy/blob/ac14df84e744a148e81aeaae20a144bc5f3cebf1/bugsy/search.py#L136-L148 | def timeframe(self, start, end):
r"""
When you want to search bugs for a certain time frame.
:param start:
:param end:
:returns: :class:`Search`
"""
if start:
self._time_frame['chfieldfrom'] = start
if end:
self._ti... | [
"def",
"timeframe",
"(",
"self",
",",
"start",
",",
"end",
")",
":",
"if",
"start",
":",
"self",
".",
"_time_frame",
"[",
"'chfieldfrom'",
"]",
"=",
"start",
"if",
"end",
":",
"self",
".",
"_time_frame",
"[",
"'chfieldto'",
"]",
"=",
"end",
"return",
... | r"""
When you want to search bugs for a certain time frame.
:param start:
:param end:
:returns: :class:`Search` | [
"r",
"When",
"you",
"want",
"to",
"search",
"bugs",
"for",
"a",
"certain",
"time",
"frame",
"."
] | python | train | 27.307692 |
Dentosal/python-sc2 | sc2/bot_ai.py | https://github.com/Dentosal/python-sc2/blob/608bd25f04e89d39cef68b40101d8e9a8a7f1634/sc2/bot_ai.py#L488-L493 | def is_visible(self, pos: Union[Point2, Point3, Unit]) -> bool:
""" Returns True if you have vision on a grid point. """
# more info: https://github.com/Blizzard/s2client-proto/blob/9906df71d6909511907d8419b33acc1a3bd51ec0/s2clientprotocol/spatial.proto#L19
assert isinstance(pos, (Point2, Point3... | [
"def",
"is_visible",
"(",
"self",
",",
"pos",
":",
"Union",
"[",
"Point2",
",",
"Point3",
",",
"Unit",
"]",
")",
"->",
"bool",
":",
"# more info: https://github.com/Blizzard/s2client-proto/blob/9906df71d6909511907d8419b33acc1a3bd51ec0/s2clientprotocol/spatial.proto#L19",
"ass... | Returns True if you have vision on a grid point. | [
"Returns",
"True",
"if",
"you",
"have",
"vision",
"on",
"a",
"grid",
"point",
"."
] | python | train | 68.166667 |
SamLau95/nbinteract | nbinteract/plotting.py | https://github.com/SamLau95/nbinteract/blob/9f346452283831aad3f4416c04879f1d187ec3b7/nbinteract/plotting.py#L636-L654 | def _merge_with_defaults(params):
"""
Performs a 2-level deep merge of params with _default_params with corrent
merging of params for each mark.
This is a bit complicated since params['marks'] is a list and we need to
make sure each mark gets the default params.
"""
marks_params = [
... | [
"def",
"_merge_with_defaults",
"(",
"params",
")",
":",
"marks_params",
"=",
"[",
"tz",
".",
"merge",
"(",
"default",
",",
"param",
")",
"for",
"default",
",",
"param",
"in",
"zip",
"(",
"itertools",
".",
"repeat",
"(",
"_default_params",
"[",
"'marks'",
... | Performs a 2-level deep merge of params with _default_params with corrent
merging of params for each mark.
This is a bit complicated since params['marks'] is a list and we need to
make sure each mark gets the default params. | [
"Performs",
"a",
"2",
"-",
"level",
"deep",
"merge",
"of",
"params",
"with",
"_default_params",
"with",
"corrent",
"merging",
"of",
"params",
"for",
"each",
"mark",
"."
] | python | train | 36.210526 |
jashort/SmartFileSorter | smartfilesorter/actionplugins/renameto.py | https://github.com/jashort/SmartFileSorter/blob/77faf09e5a737da93e16e71a64707366b8307910/smartfilesorter/actionplugins/renameto.py#L28-L57 | def do_action(self, target, dry_run=False):
"""
:param target: Full path and filename
:param dry_run: True - don't actually perform action. False: perform action. No effect for this rule.
:return: filename: Full path and filename after action completes
"""
original_path =... | [
"def",
"do_action",
"(",
"self",
",",
"target",
",",
"dry_run",
"=",
"False",
")",
":",
"original_path",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"target",
")",
"original_filename",
",",
"original_extension",
"=",
"os",
".",
"path",
".",
"splitext",
... | :param target: Full path and filename
:param dry_run: True - don't actually perform action. False: perform action. No effect for this rule.
:return: filename: Full path and filename after action completes | [
":",
"param",
"target",
":",
"Full",
"path",
"and",
"filename",
":",
"param",
"dry_run",
":",
"True",
"-",
"don",
"t",
"actually",
"perform",
"action",
".",
"False",
":",
"perform",
"action",
".",
"No",
"effect",
"for",
"this",
"rule",
".",
":",
"retur... | python | train | 46.466667 |
shawnsilva/steamwebapi | steamwebapi/api.py | https://github.com/shawnsilva/steamwebapi/blob/dc16538ebe985cc7ea170f660169ebc2366efbf2/steamwebapi/api.py#L273-L291 | def get_schema_for_game(self, appID, language=None, format=None):
"""Request the available achievements and stats for a game.
appID: The app id
language: The language to return the results in. None uses default.
format: Return format. None defaults to json. (json, xml, vdf)
"""... | [
"def",
"get_schema_for_game",
"(",
"self",
",",
"appID",
",",
"language",
"=",
"None",
",",
"format",
"=",
"None",
")",
":",
"parameters",
"=",
"{",
"'appid'",
":",
"appID",
"}",
"if",
"format",
"is",
"not",
"None",
":",
"parameters",
"[",
"'format'",
... | Request the available achievements and stats for a game.
appID: The app id
language: The language to return the results in. None uses default.
format: Return format. None defaults to json. (json, xml, vdf) | [
"Request",
"the",
"available",
"achievements",
"and",
"stats",
"for",
"a",
"game",
"."
] | python | train | 38.947368 |
twilio/twilio-python | twilio/rest/video/v1/room/__init__.py | https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/video/v1/room/__init__.py#L38-L77 | def create(self, enable_turn=values.unset, type=values.unset,
unique_name=values.unset, status_callback=values.unset,
status_callback_method=values.unset, max_participants=values.unset,
record_participants_on_connect=values.unset,
video_codecs=values.unset, me... | [
"def",
"create",
"(",
"self",
",",
"enable_turn",
"=",
"values",
".",
"unset",
",",
"type",
"=",
"values",
".",
"unset",
",",
"unique_name",
"=",
"values",
".",
"unset",
",",
"status_callback",
"=",
"values",
".",
"unset",
",",
"status_callback_method",
"=... | Create a new RoomInstance
:param bool enable_turn: Use Twilio Network Traversal for TURN service.
:param RoomInstance.RoomType type: Type of room, either peer-to-peer, group-small or group.
:param unicode unique_name: Name of the Room.
:param unicode status_callback: A URL that Twilio s... | [
"Create",
"a",
"new",
"RoomInstance"
] | python | train | 49.2 |
cggh/scikit-allel | allel/stats/selection.py | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/selection.py#L661-L736 | def xpnsl(h1, h2, use_threads=True):
"""Cross-population version of the NSL statistic.
Parameters
----------
h1 : array_like, int, shape (n_variants, n_haplotypes)
Haplotype array for the first population.
h2 : array_like, int, shape (n_variants, n_haplotypes)
Haplotype array for th... | [
"def",
"xpnsl",
"(",
"h1",
",",
"h2",
",",
"use_threads",
"=",
"True",
")",
":",
"# check inputs",
"h1",
"=",
"asarray_ndim",
"(",
"h1",
",",
"2",
")",
"check_integer_dtype",
"(",
"h1",
")",
"h2",
"=",
"asarray_ndim",
"(",
"h2",
",",
"2",
")",
"check... | Cross-population version of the NSL statistic.
Parameters
----------
h1 : array_like, int, shape (n_variants, n_haplotypes)
Haplotype array for the first population.
h2 : array_like, int, shape (n_variants, n_haplotypes)
Haplotype array for the second population.
use_threads : bool,... | [
"Cross",
"-",
"population",
"version",
"of",
"the",
"NSL",
"statistic",
"."
] | python | train | 25.171053 |
prompt-toolkit/pyvim | pyvim/reporting.py | https://github.com/prompt-toolkit/pyvim/blob/5928b53b9d700863c1a06d2181a034a955f94594/pyvim/reporting.py#L33-L45 | def report(location, document):
"""
Run reporter on document and return list of ReporterError instances.
(Depending on the location it will or won't run anything.)
Returns a list of `ReporterError`.
"""
assert isinstance(location, six.string_types)
if location.endswith('.py'):
retu... | [
"def",
"report",
"(",
"location",
",",
"document",
")",
":",
"assert",
"isinstance",
"(",
"location",
",",
"six",
".",
"string_types",
")",
"if",
"location",
".",
"endswith",
"(",
"'.py'",
")",
":",
"return",
"report_pyflakes",
"(",
"document",
")",
"else"... | Run reporter on document and return list of ReporterError instances.
(Depending on the location it will or won't run anything.)
Returns a list of `ReporterError`. | [
"Run",
"reporter",
"on",
"document",
"and",
"return",
"list",
"of",
"ReporterError",
"instances",
".",
"(",
"Depending",
"on",
"the",
"location",
"it",
"will",
"or",
"won",
"t",
"run",
"anything",
".",
")"
] | python | train | 28 |
phaethon/kamene | kamene/contrib/gsm_um.py | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L1025-L1033 | def systemInformationType2ter():
"""SYSTEM INFORMATION TYPE 2ter Section 9.1.34"""
a = L2PseudoLength(l2pLength=0x12)
b = TpPd(pd=0x6)
c = MessageType(mesType=0x3) # 00000011
d = NeighbourCellsDescription2()
e = Si2terRestOctets()
packet = a / b / c / d / e
return packet | [
"def",
"systemInformationType2ter",
"(",
")",
":",
"a",
"=",
"L2PseudoLength",
"(",
"l2pLength",
"=",
"0x12",
")",
"b",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"c",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x3",
")",
"# 00000011",
"d",
"=",
"Neighbou... | SYSTEM INFORMATION TYPE 2ter Section 9.1.34 | [
"SYSTEM",
"INFORMATION",
"TYPE",
"2ter",
"Section",
"9",
".",
"1",
".",
"34"
] | python | train | 32.888889 |
pybel/pybel | src/pybel/io/lines.py | https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/io/lines.py#L35-L49 | def from_path(path: str, encoding: str = 'utf-8', **kwargs) -> BELGraph:
"""Load a BEL graph from a file resource. This function is a thin wrapper around :func:`from_lines`.
:param path: A file path
:param encoding: the encoding to use when reading this file. Is passed to :code:`codecs.open`. See the pytho... | [
"def",
"from_path",
"(",
"path",
":",
"str",
",",
"encoding",
":",
"str",
"=",
"'utf-8'",
",",
"*",
"*",
"kwargs",
")",
"->",
"BELGraph",
":",
"log",
".",
"info",
"(",
"'Loading from path: %s'",
",",
"path",
")",
"graph",
"=",
"BELGraph",
"(",
"path",
... | Load a BEL graph from a file resource. This function is a thin wrapper around :func:`from_lines`.
:param path: A file path
:param encoding: the encoding to use when reading this file. Is passed to :code:`codecs.open`. See the python
`docs <https://docs.python.org/3/library/codecs.html#standard-encodings>`... | [
"Load",
"a",
"BEL",
"graph",
"from",
"a",
"file",
"resource",
".",
"This",
"function",
"is",
"a",
"thin",
"wrapper",
"around",
":",
"func",
":",
"from_lines",
"."
] | python | train | 55.066667 |
googleapis/google-cloud-python | spanner/google/cloud/spanner_v1/instance.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/spanner/google/cloud/spanner_v1/instance.py#L334-L365 | def list_databases(self, page_size=None, page_token=None):
"""List databases for the instance.
See
https://cloud.google.com/spanner/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases
:type page_size: int
:param page_size:... | [
"def",
"list_databases",
"(",
"self",
",",
"page_size",
"=",
"None",
",",
"page_token",
"=",
"None",
")",
":",
"metadata",
"=",
"_metadata_with_prefix",
"(",
"self",
".",
"name",
")",
"page_iter",
"=",
"self",
".",
"_client",
".",
"database_admin_api",
".",
... | List databases for the instance.
See
https://cloud.google.com/spanner/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases
:type page_size: int
:param page_size:
Optional. The maximum number of databases in each page of... | [
"List",
"databases",
"for",
"the",
"instance",
"."
] | python | train | 44.28125 |
tamasgal/km3pipe | km3pipe/utils/streamds.py | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/utils/streamds.py#L165-L203 | def convert_runsummary_to_json(
df, comment='Uploaded via km3pipe.StreamDS', prefix='TEST_'
):
"""Convert a Pandas DataFrame with runsummary to JSON for DB upload"""
data_field = []
comment += ", by {}".format(getpass.getuser())
for det_id, det_data in df.groupby('det_id'):
runs_field = ... | [
"def",
"convert_runsummary_to_json",
"(",
"df",
",",
"comment",
"=",
"'Uploaded via km3pipe.StreamDS'",
",",
"prefix",
"=",
"'TEST_'",
")",
":",
"data_field",
"=",
"[",
"]",
"comment",
"+=",
"\", by {}\"",
".",
"format",
"(",
"getpass",
".",
"getuser",
"(",
")... | Convert a Pandas DataFrame with runsummary to JSON for DB upload | [
"Convert",
"a",
"Pandas",
"DataFrame",
"with",
"runsummary",
"to",
"JSON",
"for",
"DB",
"upload"
] | python | train | 43.948718 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.