repo stringlengths 7 54 | path stringlengths 4 192 | url stringlengths 87 284 | code stringlengths 78 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|
watson-developer-cloud/python-sdk | ibm_watson/discovery_v1.py | https://github.com/watson-developer-cloud/python-sdk/blob/4c2c9df4466fcde88975da9ecd834e6ba95eb353/ibm_watson/discovery_v1.py#L5163-L5170 | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'step') and self.step is not None:
_dict['step'] = self.step
if hasattr(self, 'snapshot') and self.snapshot is not None:
_dict['snapshot'] = self.snapshot
... | [
"def",
"_to_dict",
"(",
"self",
")",
":",
"_dict",
"=",
"{",
"}",
"if",
"hasattr",
"(",
"self",
",",
"'step'",
")",
"and",
"self",
".",
"step",
"is",
"not",
"None",
":",
"_dict",
"[",
"'step'",
"]",
"=",
"self",
".",
"step",
"if",
"hasattr",
"(",... | Return a json dictionary representing this model. | [
"Return",
"a",
"json",
"dictionary",
"representing",
"this",
"model",
"."
] | python | train |
LonamiWebs/Telethon | telethon/client/uploads.py | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/client/uploads.py#L295-L360 | async def _send_album(self, entity, files, caption='',
progress_callback=None, reply_to=None,
parse_mode=(), silent=None):
"""Specialized version of .send_file for albums"""
# We don't care if the user wants to avoid cache, we will use it
# any... | [
"async",
"def",
"_send_album",
"(",
"self",
",",
"entity",
",",
"files",
",",
"caption",
"=",
"''",
",",
"progress_callback",
"=",
"None",
",",
"reply_to",
"=",
"None",
",",
"parse_mode",
"=",
"(",
")",
",",
"silent",
"=",
"None",
")",
":",
"# We don't... | Specialized version of .send_file for albums | [
"Specialized",
"version",
"of",
".",
"send_file",
"for",
"albums"
] | python | train |
CenturyLinkCloud/clc-python-sdk | src/clc/APIv2/__init__.py | https://github.com/CenturyLinkCloud/clc-python-sdk/blob/f4dba40c627cb08dd4b7d0d277e8d67578010b05/src/clc/APIv2/__init__.py#L46-L53 | def SetCredentials(api_username,api_passwd):
"""Establish API username and password associated with APIv2 commands."""
global V2_API_USERNAME
global V2_API_PASSWD
global _V2_ENABLED
_V2_ENABLED = True
V2_API_USERNAME = api_username
V2_API_PASSWD = api_passwd | [
"def",
"SetCredentials",
"(",
"api_username",
",",
"api_passwd",
")",
":",
"global",
"V2_API_USERNAME",
"global",
"V2_API_PASSWD",
"global",
"_V2_ENABLED",
"_V2_ENABLED",
"=",
"True",
"V2_API_USERNAME",
"=",
"api_username",
"V2_API_PASSWD",
"=",
"api_passwd"
] | Establish API username and password associated with APIv2 commands. | [
"Establish",
"API",
"username",
"and",
"password",
"associated",
"with",
"APIv2",
"commands",
"."
] | python | train |
blackecho/Deep-Learning-TensorFlow | yadlt/core/model.py | https://github.com/blackecho/Deep-Learning-TensorFlow/blob/ddeb1f2848da7b7bee166ad2152b4afc46bb2086/yadlt/core/model.py#L107-L125 | def get_parameters(self, params, graph=None):
"""Get the parameters of the model.
:param params: dictionary of keys (str names) and values (tensors).
:return: evaluated tensors in params
"""
g = graph if graph is not None else self.tf_graph
with g.as_default():
... | [
"def",
"get_parameters",
"(",
"self",
",",
"params",
",",
"graph",
"=",
"None",
")",
":",
"g",
"=",
"graph",
"if",
"graph",
"is",
"not",
"None",
"else",
"self",
".",
"tf_graph",
"with",
"g",
".",
"as_default",
"(",
")",
":",
"with",
"tf",
".",
"Ses... | Get the parameters of the model.
:param params: dictionary of keys (str names) and values (tensors).
:return: evaluated tensors in params | [
"Get",
"the",
"parameters",
"of",
"the",
"model",
"."
] | python | train |
binux/pyspider | pyspider/scheduler/scheduler.py | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/scheduler/scheduler.py#L348-L370 | def _check_task_done(self):
'''Check status queue'''
cnt = 0
try:
while True:
task = self.status_queue.get_nowait()
# check _on_get_info result here
if task.get('taskid') == '_on_get_info' and 'project' in task and 'track' in task:
... | [
"def",
"_check_task_done",
"(",
"self",
")",
":",
"cnt",
"=",
"0",
"try",
":",
"while",
"True",
":",
"task",
"=",
"self",
".",
"status_queue",
".",
"get_nowait",
"(",
")",
"# check _on_get_info result here",
"if",
"task",
".",
"get",
"(",
"'taskid'",
")",
... | Check status queue | [
"Check",
"status",
"queue"
] | python | train |
ejeschke/ginga | ginga/web/pgw/ImageViewPg.py | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/web/pgw/ImageViewPg.py#L63-L68 | def set_widget(self, canvas_w):
"""Call this method with the widget that will be used
for the display.
"""
self.logger.debug("set widget canvas_w=%s" % canvas_w)
self.pgcanvas = canvas_w | [
"def",
"set_widget",
"(",
"self",
",",
"canvas_w",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"set widget canvas_w=%s\"",
"%",
"canvas_w",
")",
"self",
".",
"pgcanvas",
"=",
"canvas_w"
] | Call this method with the widget that will be used
for the display. | [
"Call",
"this",
"method",
"with",
"the",
"widget",
"that",
"will",
"be",
"used",
"for",
"the",
"display",
"."
] | python | train |
yunojuno-archive/django-package-monitor | package_monitor/models.py | https://github.com/yunojuno-archive/django-package-monitor/blob/534aa35ccfe187d2c55aeca0cb52b8278254e437/package_monitor/models.py#L130-L143 | def update_from_pypi(self):
"""Call get_latest_version and then save the object."""
package = pypi.Package(self.package_name)
self.licence = package.licence()
if self.is_parseable:
self.latest_version = package.latest_version()
self.next_version = package.next_ver... | [
"def",
"update_from_pypi",
"(",
"self",
")",
":",
"package",
"=",
"pypi",
".",
"Package",
"(",
"self",
".",
"package_name",
")",
"self",
".",
"licence",
"=",
"package",
".",
"licence",
"(",
")",
"if",
"self",
".",
"is_parseable",
":",
"self",
".",
"lat... | Call get_latest_version and then save the object. | [
"Call",
"get_latest_version",
"and",
"then",
"save",
"the",
"object",
"."
] | python | train |
ibelie/typy | typy/google/protobuf/text_format.py | https://github.com/ibelie/typy/blob/3616845fb91459aacd8df6bf82c5d91f4542bee7/typy/google/protobuf/text_format.py#L372-L390 | def ParseLines(lines, message, allow_unknown_extension=False,
allow_field_number=False):
"""Parses an text representation of a protocol message into a message.
Args:
lines: An iterable of lines of a message's text representation.
message: A protocol buffer message to merge into.
allow_un... | [
"def",
"ParseLines",
"(",
"lines",
",",
"message",
",",
"allow_unknown_extension",
"=",
"False",
",",
"allow_field_number",
"=",
"False",
")",
":",
"parser",
"=",
"_Parser",
"(",
"allow_unknown_extension",
",",
"allow_field_number",
")",
"return",
"parser",
".",
... | Parses an text representation of a protocol message into a message.
Args:
lines: An iterable of lines of a message's text representation.
message: A protocol buffer message to merge into.
allow_unknown_extension: if True, skip over missing extensions and keep
parsing
allow_field_number: if True... | [
"Parses",
"an",
"text",
"representation",
"of",
"a",
"protocol",
"message",
"into",
"a",
"message",
"."
] | python | valid |
python-wink/python-wink | src/pywink/devices/fan.py | https://github.com/python-wink/python-wink/blob/cf8bdce8c6518f30b91b23aa7aa32e89c2ce48da/src/pywink/devices/fan.py#L72-L83 | def set_fan_direction(self, direction):
"""
:param direction: a string one of ["forward", "reverse"]
:return: nothing
"""
desired_state = {"direction": direction}
response = self.api_interface.set_device_state(self, {
"desired_state": desired_state
})... | [
"def",
"set_fan_direction",
"(",
"self",
",",
"direction",
")",
":",
"desired_state",
"=",
"{",
"\"direction\"",
":",
"direction",
"}",
"response",
"=",
"self",
".",
"api_interface",
".",
"set_device_state",
"(",
"self",
",",
"{",
"\"desired_state\"",
":",
"de... | :param direction: a string one of ["forward", "reverse"]
:return: nothing | [
":",
"param",
"direction",
":",
"a",
"string",
"one",
"of",
"[",
"forward",
"reverse",
"]",
":",
"return",
":",
"nothing"
] | python | train |
bwohlberg/sporco | sporco/linalg.py | https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/linalg.py#L826-L862 | def lu_factor(A, rho, check_finite=True):
r"""
Compute LU factorisation of either :math:`A^T A + \rho I` or
:math:`A A^T + \rho I`, depending on which matrix is smaller.
Parameters
----------
A : array_like
Array :math:`A`
rho : float
Scalar :math:`\rho`
check_finite : bool,... | [
"def",
"lu_factor",
"(",
"A",
",",
"rho",
",",
"check_finite",
"=",
"True",
")",
":",
"N",
",",
"M",
"=",
"A",
".",
"shape",
"# If N < M it is cheaper to factorise A*A^T + rho*I and then use the",
"# matrix inversion lemma to compute the inverse of A^T*A + rho*I",
"if",
"... | r"""
Compute LU factorisation of either :math:`A^T A + \rho I` or
:math:`A A^T + \rho I`, depending on which matrix is smaller.
Parameters
----------
A : array_like
Array :math:`A`
rho : float
Scalar :math:`\rho`
check_finite : bool, optional (default False)
Flag indicatin... | [
"r",
"Compute",
"LU",
"factorisation",
"of",
"either",
":",
"math",
":",
"A^T",
"A",
"+",
"\\",
"rho",
"I",
"or",
":",
"math",
":",
"A",
"A^T",
"+",
"\\",
"rho",
"I",
"depending",
"on",
"which",
"matrix",
"is",
"smaller",
"."
] | python | train |
tBuLi/symfit | symfit/core/fit.py | https://github.com/tBuLi/symfit/blob/759dd3d1d4270510d651f40b23dd26b1b10eee83/symfit/core/fit.py#L1590-L1660 | def eval_components(self, *args, **kwargs):
"""
Numerically integrate the system of ODEs.
:param args: Ordered arguments for the parameters and independent
variables
:param kwargs: Keyword arguments for the parameters and independent
variables
:return:
... | [
"def",
"eval_components",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"bound_arguments",
"=",
"self",
".",
"__signature__",
".",
"bind",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"t_like",
"=",
"bound_arguments",
".",
"argum... | Numerically integrate the system of ODEs.
:param args: Ordered arguments for the parameters and independent
variables
:param kwargs: Keyword arguments for the parameters and independent
variables
:return: | [
"Numerically",
"integrate",
"the",
"system",
"of",
"ODEs",
"."
] | python | train |
saltstack/salt | salt/cloud/clouds/qingcloud.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/qingcloud.py#L448-L473 | def _show_normalized_node(full_node):
'''
Normalize the QingCloud instance data. Used by list_nodes()-related
functions.
'''
public_ips = full_node.get('eip', [])
if public_ips:
public_ip = public_ips['eip_addr']
public_ips = [public_ip, ]
private_ips = []
for vxnet in f... | [
"def",
"_show_normalized_node",
"(",
"full_node",
")",
":",
"public_ips",
"=",
"full_node",
".",
"get",
"(",
"'eip'",
",",
"[",
"]",
")",
"if",
"public_ips",
":",
"public_ip",
"=",
"public_ips",
"[",
"'eip_addr'",
"]",
"public_ips",
"=",
"[",
"public_ip",
... | Normalize the QingCloud instance data. Used by list_nodes()-related
functions. | [
"Normalize",
"the",
"QingCloud",
"instance",
"data",
".",
"Used",
"by",
"list_nodes",
"()",
"-",
"related",
"functions",
"."
] | python | train |
blue-yonder/tsfresh | tsfresh/feature_extraction/feature_calculators.py | https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/feature_extraction/feature_calculators.py#L277-L288 | def has_duplicate_min(x):
"""
Checks if the minimal value of x is observed more than once
:param x: the time series to calculate the feature of
:type x: numpy.ndarray
:return: the value of this feature
:return type: bool
"""
if not isinstance(x, (np.ndarray, pd.Series)):
x = np.... | [
"def",
"has_duplicate_min",
"(",
"x",
")",
":",
"if",
"not",
"isinstance",
"(",
"x",
",",
"(",
"np",
".",
"ndarray",
",",
"pd",
".",
"Series",
")",
")",
":",
"x",
"=",
"np",
".",
"asarray",
"(",
"x",
")",
"return",
"np",
".",
"sum",
"(",
"x",
... | Checks if the minimal value of x is observed more than once
:param x: the time series to calculate the feature of
:type x: numpy.ndarray
:return: the value of this feature
:return type: bool | [
"Checks",
"if",
"the",
"minimal",
"value",
"of",
"x",
"is",
"observed",
"more",
"than",
"once"
] | python | train |
nitely/django-hooks | hooks/signalhook.py | https://github.com/nitely/django-hooks/blob/26ea2150c9be110e90b9ee60fbfd1065ac30ab1d/hooks/signalhook.py#L25-L35 | def register(self, name):
"""
Register a new hook. Not required (see :py:func:`.connect` method)
:param str name: The hook name
:return: Django signal
:rtype: :py:class:`django.dispatch.Signal`
"""
signal = Signal(providing_args=['args', 'kwargs'])
self._... | [
"def",
"register",
"(",
"self",
",",
"name",
")",
":",
"signal",
"=",
"Signal",
"(",
"providing_args",
"=",
"[",
"'args'",
",",
"'kwargs'",
"]",
")",
"self",
".",
"_registry",
"[",
"name",
"]",
"=",
"signal",
"return",
"signal"
] | Register a new hook. Not required (see :py:func:`.connect` method)
:param str name: The hook name
:return: Django signal
:rtype: :py:class:`django.dispatch.Signal` | [
"Register",
"a",
"new",
"hook",
".",
"Not",
"required",
"(",
"see",
":",
"py",
":",
"func",
":",
".",
"connect",
"method",
")"
] | python | train |
twisted/mantissa | xmantissa/product.py | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/product.py#L29-L40 | def installProductOn(self, userstore):
"""
Creates an Installation in this user store for our collection
of powerups, and then install those powerups on the user's
store.
"""
def install():
i = Installation(store=userstore)
i.types = self.types
... | [
"def",
"installProductOn",
"(",
"self",
",",
"userstore",
")",
":",
"def",
"install",
"(",
")",
":",
"i",
"=",
"Installation",
"(",
"store",
"=",
"userstore",
")",
"i",
".",
"types",
"=",
"self",
".",
"types",
"i",
".",
"install",
"(",
")",
"userstor... | Creates an Installation in this user store for our collection
of powerups, and then install those powerups on the user's
store. | [
"Creates",
"an",
"Installation",
"in",
"this",
"user",
"store",
"for",
"our",
"collection",
"of",
"powerups",
"and",
"then",
"install",
"those",
"powerups",
"on",
"the",
"user",
"s",
"store",
"."
] | python | train |
osfclient/osfclient | osfclient/models/file.py | https://github.com/osfclient/osfclient/blob/44b9a87e8c1ae6b63cdecd27a924af3fc2bf94cf/osfclient/models/file.py#L7-L18 | def copyfileobj(fsrc, fdst, total, length=16*1024):
"""Copy data from file-like object fsrc to file-like object fdst
This is like shutil.copyfileobj but with a progressbar.
"""
with tqdm(unit='bytes', total=total, unit_scale=True) as pbar:
while 1:
buf = fsrc.read(length)
... | [
"def",
"copyfileobj",
"(",
"fsrc",
",",
"fdst",
",",
"total",
",",
"length",
"=",
"16",
"*",
"1024",
")",
":",
"with",
"tqdm",
"(",
"unit",
"=",
"'bytes'",
",",
"total",
"=",
"total",
",",
"unit_scale",
"=",
"True",
")",
"as",
"pbar",
":",
"while",... | Copy data from file-like object fsrc to file-like object fdst
This is like shutil.copyfileobj but with a progressbar. | [
"Copy",
"data",
"from",
"file",
"-",
"like",
"object",
"fsrc",
"to",
"file",
"-",
"like",
"object",
"fdst"
] | python | valid |
RPi-Distro/python-gpiozero | gpiozero/tools.py | https://github.com/RPi-Distro/python-gpiozero/blob/7b67374fd0c8c4fde5586d9bad9531f076db9c0c/gpiozero/tools.py#L574-L601 | def post_periodic_filtered(values, repeat_after, block):
"""
After every *repeat_after* items, blocks the next *block* items from
*values*. Note that unlike :func:`pre_periodic_filtered`, *repeat_after*
can't be 0. For example, to block every tenth item read from an ADC::
from gpiozero import M... | [
"def",
"post_periodic_filtered",
"(",
"values",
",",
"repeat_after",
",",
"block",
")",
":",
"values",
"=",
"_normalize",
"(",
"values",
")",
"if",
"repeat_after",
"<",
"1",
":",
"raise",
"ValueError",
"(",
"\"repeat_after must be 1 or larger\"",
")",
"if",
"blo... | After every *repeat_after* items, blocks the next *block* items from
*values*. Note that unlike :func:`pre_periodic_filtered`, *repeat_after*
can't be 0. For example, to block every tenth item read from an ADC::
from gpiozero import MCP3008
from gpiozero.tools import post_periodic_filtered
... | [
"After",
"every",
"*",
"repeat_after",
"*",
"items",
"blocks",
"the",
"next",
"*",
"block",
"*",
"items",
"from",
"*",
"values",
"*",
".",
"Note",
"that",
"unlike",
":",
"func",
":",
"pre_periodic_filtered",
"*",
"repeat_after",
"*",
"can",
"t",
"be",
"0... | python | train |
demianbrecht/flask-canvas | flask_canvas.py | https://github.com/demianbrecht/flask-canvas/blob/07aa310c43f9386598cdfd5b163f94efa7808c85/flask_canvas.py#L56-L102 | def _canvas_route(self, *args, **kwargs):
""" Decorator for canvas route
"""
def outer(view_fn):
@self.route(*args, **kwargs)
def inner(*args, **kwargs):
fn_args = getargspec(view_fn)
try:
idx = fn_args.args.index(_ARG_KEY)
except ValueErr... | [
"def",
"_canvas_route",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"outer",
"(",
"view_fn",
")",
":",
"@",
"self",
".",
"route",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"def",
"inner",
"(",
"*",
"args",
","... | Decorator for canvas route | [
"Decorator",
"for",
"canvas",
"route"
] | python | train |
benedictpaten/sonLib | bioio.py | https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/bioio.py#L875-L887 | def fastaAlignmentWrite(columnAlignment, names, seqNo, fastaFile,
filter=lambda x : True):
"""
Writes out column alignment to given file multi-fasta format
"""
fastaFile = open(fastaFile, 'w')
columnAlignment = [ i for i in columnAlignment if filter(i) ]
for seq in xrange... | [
"def",
"fastaAlignmentWrite",
"(",
"columnAlignment",
",",
"names",
",",
"seqNo",
",",
"fastaFile",
",",
"filter",
"=",
"lambda",
"x",
":",
"True",
")",
":",
"fastaFile",
"=",
"open",
"(",
"fastaFile",
",",
"'w'",
")",
"columnAlignment",
"=",
"[",
"i",
"... | Writes out column alignment to given file multi-fasta format | [
"Writes",
"out",
"column",
"alignment",
"to",
"given",
"file",
"multi",
"-",
"fasta",
"format"
] | python | train |
tensorpack/tensorpack | tensorpack/utils/nvml.py | https://github.com/tensorpack/tensorpack/blob/d7a13cb74c9066bc791d7aafc3b744b60ee79a9f/tensorpack/utils/nvml.py#L92-L113 | def memory(self):
"""Memory information in bytes
Example:
>>> print(ctx.device(0).memory())
{'total': 4238016512L, 'used': 434831360L, 'free': 3803185152L}
Returns:
total/used/free memory in bytes
"""
class GpuMemoryInfo(Structure):
... | [
"def",
"memory",
"(",
"self",
")",
":",
"class",
"GpuMemoryInfo",
"(",
"Structure",
")",
":",
"_fields_",
"=",
"[",
"(",
"'total'",
",",
"c_ulonglong",
")",
",",
"(",
"'free'",
",",
"c_ulonglong",
")",
",",
"(",
"'used'",
",",
"c_ulonglong",
")",
",",
... | Memory information in bytes
Example:
>>> print(ctx.device(0).memory())
{'total': 4238016512L, 'used': 434831360L, 'free': 3803185152L}
Returns:
total/used/free memory in bytes | [
"Memory",
"information",
"in",
"bytes"
] | python | train |
wind-python/windpowerlib | windpowerlib/wind_turbine.py | https://github.com/wind-python/windpowerlib/blob/421b316139743311b7cb68a69f6b53d2665f7e23/windpowerlib/wind_turbine.py#L126-L190 | def fetch_turbine_data(self, fetch_curve, data_source):
r"""
Fetches data of the requested wind turbine.
Method fetches nominal power as well as power coefficient curve or
power curve from a data set provided in the OpenEnergy Database
(oedb). You can also import your own power ... | [
"def",
"fetch_turbine_data",
"(",
"self",
",",
"fetch_curve",
",",
"data_source",
")",
":",
"if",
"data_source",
"==",
"'oedb'",
":",
"curve_df",
",",
"nominal_power",
"=",
"get_turbine_data_from_oedb",
"(",
"turbine_type",
"=",
"self",
".",
"name",
",",
"fetch_... | r"""
Fetches data of the requested wind turbine.
Method fetches nominal power as well as power coefficient curve or
power curve from a data set provided in the OpenEnergy Database
(oedb). You can also import your own power (coefficient) curves from a
file. For that the wind spee... | [
"r",
"Fetches",
"data",
"of",
"the",
"requested",
"wind",
"turbine",
"."
] | python | train |
PMBio/limix-backup | limix/deprecated/utils/preprocess.py | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/utils/preprocess.py#L62-L86 | def rankStandardizeNormal(X):
"""
Gaussianize X: [samples x phenotypes]
- each phentoype is converted to ranks and transformed back to normal using the inverse CDF
"""
Is = X.argsort(axis=0)
RV = SP.zeros_like(X)
rank = SP.zeros_like(X)
for i in range(X.shape[1]):
x = X[:,i]
i_nan = SP.isnan(x)
if 0:
... | [
"def",
"rankStandardizeNormal",
"(",
"X",
")",
":",
"Is",
"=",
"X",
".",
"argsort",
"(",
"axis",
"=",
"0",
")",
"RV",
"=",
"SP",
".",
"zeros_like",
"(",
"X",
")",
"rank",
"=",
"SP",
".",
"zeros_like",
"(",
"X",
")",
"for",
"i",
"in",
"range",
"... | Gaussianize X: [samples x phenotypes]
- each phentoype is converted to ranks and transformed back to normal using the inverse CDF | [
"Gaussianize",
"X",
":",
"[",
"samples",
"x",
"phenotypes",
"]",
"-",
"each",
"phentoype",
"is",
"converted",
"to",
"ranks",
"and",
"transformed",
"back",
"to",
"normal",
"using",
"the",
"inverse",
"CDF"
] | python | train |
peopledoc/workalendar | workalendar/core.py | https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/workalendar/core.py#L246-L256 | def find_following_working_day(self, day):
"""Looks for the following working day, if not already a working day.
**WARNING**: this function doesn't take into account the calendar
holidays, only the days of the week and the weekend days parameters.
"""
day = cleaned_date(day)
... | [
"def",
"find_following_working_day",
"(",
"self",
",",
"day",
")",
":",
"day",
"=",
"cleaned_date",
"(",
"day",
")",
"while",
"day",
".",
"weekday",
"(",
")",
"in",
"self",
".",
"get_weekend_days",
"(",
")",
":",
"day",
"=",
"day",
"+",
"timedelta",
"(... | Looks for the following working day, if not already a working day.
**WARNING**: this function doesn't take into account the calendar
holidays, only the days of the week and the weekend days parameters. | [
"Looks",
"for",
"the",
"following",
"working",
"day",
"if",
"not",
"already",
"a",
"working",
"day",
"."
] | python | train |
celery/cell | cell/actors.py | https://github.com/celery/cell/blob/c7f9b3a0c11ae3429eacb4114279cf2614e94a48/cell/actors.py#L422-L428 | def call(self, method, args={}, retry=False, retry_policy=None,
ticket=None, **props):
"""Send message to the same actor and return :class:`AsyncResult`."""
ticket = ticket or uuid()
reply_q = self.get_reply_queue(ticket)
self.cast(method, args, declare=[reply_q], reply_to=t... | [
"def",
"call",
"(",
"self",
",",
"method",
",",
"args",
"=",
"{",
"}",
",",
"retry",
"=",
"False",
",",
"retry_policy",
"=",
"None",
",",
"ticket",
"=",
"None",
",",
"*",
"*",
"props",
")",
":",
"ticket",
"=",
"ticket",
"or",
"uuid",
"(",
")",
... | Send message to the same actor and return :class:`AsyncResult`. | [
"Send",
"message",
"to",
"the",
"same",
"actor",
"and",
"return",
":",
"class",
":",
"AsyncResult",
"."
] | python | train |
minhhoit/yacms | yacms/core/managers.py | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/managers.py#L390-L408 | def url_map(self, for_user=None, **kwargs):
"""
Returns a dictionary of urls mapped to Displayable subclass
instances, including a fake homepage instance if none exists.
Used in ``yacms.core.sitemaps``.
"""
class Home:
title = _("Home")
home = Home()
... | [
"def",
"url_map",
"(",
"self",
",",
"for_user",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"class",
"Home",
":",
"title",
"=",
"_",
"(",
"\"Home\"",
")",
"home",
"=",
"Home",
"(",
")",
"setattr",
"(",
"home",
",",
"\"get_absolute_url\"",
",",
... | Returns a dictionary of urls mapped to Displayable subclass
instances, including a fake homepage instance if none exists.
Used in ``yacms.core.sitemaps``. | [
"Returns",
"a",
"dictionary",
"of",
"urls",
"mapped",
"to",
"Displayable",
"subclass",
"instances",
"including",
"a",
"fake",
"homepage",
"instance",
"if",
"none",
"exists",
".",
"Used",
"in",
"yacms",
".",
"core",
".",
"sitemaps",
"."
] | python | train |
Spinmob/spinmob | egg/_gui.py | https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/egg/_gui.py#L439-L445 | def set_column_stretch(self, column=0, stretch=10):
"""
Sets the column stretch. Larger numbers mean it will expand more to
fill space.
"""
self._layout.setColumnStretch(column, stretch)
return self | [
"def",
"set_column_stretch",
"(",
"self",
",",
"column",
"=",
"0",
",",
"stretch",
"=",
"10",
")",
":",
"self",
".",
"_layout",
".",
"setColumnStretch",
"(",
"column",
",",
"stretch",
")",
"return",
"self"
] | Sets the column stretch. Larger numbers mean it will expand more to
fill space. | [
"Sets",
"the",
"column",
"stretch",
".",
"Larger",
"numbers",
"mean",
"it",
"will",
"expand",
"more",
"to",
"fill",
"space",
"."
] | python | train |
pandas-dev/pandas | pandas/core/strings.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L1085-L1176 | def str_findall(arr, pat, flags=0):
"""
Find all occurrences of pattern or regular expression in the Series/Index.
Equivalent to applying :func:`re.findall` to all the elements in the
Series/Index.
Parameters
----------
pat : str
Pattern or regular expression.
flags : int, defa... | [
"def",
"str_findall",
"(",
"arr",
",",
"pat",
",",
"flags",
"=",
"0",
")",
":",
"regex",
"=",
"re",
".",
"compile",
"(",
"pat",
",",
"flags",
"=",
"flags",
")",
"return",
"_na_map",
"(",
"regex",
".",
"findall",
",",
"arr",
")"
] | Find all occurrences of pattern or regular expression in the Series/Index.
Equivalent to applying :func:`re.findall` to all the elements in the
Series/Index.
Parameters
----------
pat : str
Pattern or regular expression.
flags : int, default 0
Flags from ``re`` module, e.g. `re... | [
"Find",
"all",
"occurrences",
"of",
"pattern",
"or",
"regular",
"expression",
"in",
"the",
"Series",
"/",
"Index",
"."
] | python | train |
Qiskit/qiskit-terra | qiskit/circuit/instructionset.py | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/circuit/instructionset.py#L45-L49 | def inverse(self):
"""Invert all instructions."""
for index, instruction in enumerate(self.instructions):
self.instructions[index] = instruction.inverse()
return self | [
"def",
"inverse",
"(",
"self",
")",
":",
"for",
"index",
",",
"instruction",
"in",
"enumerate",
"(",
"self",
".",
"instructions",
")",
":",
"self",
".",
"instructions",
"[",
"index",
"]",
"=",
"instruction",
".",
"inverse",
"(",
")",
"return",
"self"
] | Invert all instructions. | [
"Invert",
"all",
"instructions",
"."
] | python | test |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/dipole.py | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/dipole.py#L85-L91 | def com(self, center1_x, center1_y, center2_x, center2_y, Fm):
"""
:return: center of mass
"""
com_x = (Fm * center1_x + center2_x)/(Fm + 1.)
com_y = (Fm * center1_y + center2_y)/(Fm + 1.)
return com_x, com_y | [
"def",
"com",
"(",
"self",
",",
"center1_x",
",",
"center1_y",
",",
"center2_x",
",",
"center2_y",
",",
"Fm",
")",
":",
"com_x",
"=",
"(",
"Fm",
"*",
"center1_x",
"+",
"center2_x",
")",
"/",
"(",
"Fm",
"+",
"1.",
")",
"com_y",
"=",
"(",
"Fm",
"*"... | :return: center of mass | [
":",
"return",
":",
"center",
"of",
"mass"
] | python | train |
OCHA-DAP/hdx-python-utilities | src/hdx/utilities/dictandlist.py | https://github.com/OCHA-DAP/hdx-python-utilities/blob/9c89e0aa5afac2c002b02a2d8f0e5b91eeb3d2a3/src/hdx/utilities/dictandlist.py#L106-L121 | def dict_of_lists_add(dictionary, key, value):
# type: (DictUpperBound, Any, Any) -> None
"""Add value to a list in a dictionary by key
Args:
dictionary (DictUpperBound): Dictionary to which to add values
key (Any): Key within dictionary
value (Any): Value to add to list in dictiona... | [
"def",
"dict_of_lists_add",
"(",
"dictionary",
",",
"key",
",",
"value",
")",
":",
"# type: (DictUpperBound, Any, Any) -> None",
"list_objs",
"=",
"dictionary",
".",
"get",
"(",
"key",
",",
"list",
"(",
")",
")",
"list_objs",
".",
"append",
"(",
"value",
")",
... | Add value to a list in a dictionary by key
Args:
dictionary (DictUpperBound): Dictionary to which to add values
key (Any): Key within dictionary
value (Any): Value to add to list in dictionary
Returns:
None | [
"Add",
"value",
"to",
"a",
"list",
"in",
"a",
"dictionary",
"by",
"key"
] | python | train |
epfl-lts2/pygsp | pygsp/graphs/graph.py | https://github.com/epfl-lts2/pygsp/blob/8ce5bde39206129287375af24fdbcd7edddca8c5/pygsp/graphs/graph.py#L687-L738 | def d(self):
r"""The degree (number of neighbors) of vertices.
For undirected graphs, the degree of a vertex is the number of vertices
it is connected to.
For directed graphs, the degree is the average of the in and out
degrees, where the in degree is the number of incoming edge... | [
"def",
"d",
"(",
"self",
")",
":",
"if",
"self",
".",
"_d",
"is",
"None",
":",
"if",
"not",
"self",
".",
"is_directed",
"(",
")",
":",
"# Shortcut for undirected graphs.",
"self",
".",
"_d",
"=",
"self",
".",
"W",
".",
"getnnz",
"(",
"axis",
"=",
"... | r"""The degree (number of neighbors) of vertices.
For undirected graphs, the degree of a vertex is the number of vertices
it is connected to.
For directed graphs, the degree is the average of the in and out
degrees, where the in degree is the number of incoming edges, and the
ou... | [
"r",
"The",
"degree",
"(",
"number",
"of",
"neighbors",
")",
"of",
"vertices",
"."
] | python | train |
google/grr | grr/client/grr_response_client/vfs_handlers/sleuthkit.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/vfs_handlers/sleuthkit.py#L331-L357 | def ListFiles(self, ext_attrs=None):
"""List all the files in the directory."""
del ext_attrs # Unused.
if not self.IsDirectory():
raise IOError("%s is not a directory" % self.pathspec.CollapsePath())
for f in self.fd.as_directory():
try:
name = _DecodeUTF8WithWarning(f.info.name.... | [
"def",
"ListFiles",
"(",
"self",
",",
"ext_attrs",
"=",
"None",
")",
":",
"del",
"ext_attrs",
"# Unused.",
"if",
"not",
"self",
".",
"IsDirectory",
"(",
")",
":",
"raise",
"IOError",
"(",
"\"%s is not a directory\"",
"%",
"self",
".",
"pathspec",
".",
"Col... | List all the files in the directory. | [
"List",
"all",
"the",
"files",
"in",
"the",
"directory",
"."
] | python | train |
zsimic/runez | src/runez/config.py | https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/config.py#L471-L482 | def unitized(value, unit, base=DEFAULT_BASE):
"""
Args:
value (int | float): Value to expand
unit (str | unicode): Given unit (see UNITS)
base (int): Base to use (usually 1024)
Returns:
Deduced value (example: "1k" becomes 1000)
"""
exponent = 0 if not unit else UNIT... | [
"def",
"unitized",
"(",
"value",
",",
"unit",
",",
"base",
"=",
"DEFAULT_BASE",
")",
":",
"exponent",
"=",
"0",
"if",
"not",
"unit",
"else",
"UNITS",
".",
"index",
"(",
"unit",
")",
"+",
"1",
"return",
"int",
"(",
"value",
"*",
"(",
"base",
"**",
... | Args:
value (int | float): Value to expand
unit (str | unicode): Given unit (see UNITS)
base (int): Base to use (usually 1024)
Returns:
Deduced value (example: "1k" becomes 1000) | [
"Args",
":",
"value",
"(",
"int",
"|",
"float",
")",
":",
"Value",
"to",
"expand",
"unit",
"(",
"str",
"|",
"unicode",
")",
":",
"Given",
"unit",
"(",
"see",
"UNITS",
")",
"base",
"(",
"int",
")",
":",
"Base",
"to",
"use",
"(",
"usually",
"1024",... | python | train |
kubernetes-client/python | kubernetes/client/apis/core_v1_api.py | https://github.com/kubernetes-client/python/blob/5e512ff564c244c50cab780d821542ed56aa965a/kubernetes/client/apis/core_v1_api.py#L14942-L14967 | def patch_namespaced_event(self, name, namespace, body, **kwargs):
"""
partially update the specified Event
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.patch_namespaced_event(name, name... | [
"def",
"patch_namespaced_event",
"(",
"self",
",",
"name",
",",
"namespace",
",",
"body",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'async_req'",
")",
":",
"return",
... | partially update the specified Event
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.patch_namespaced_event(name, namespace, body, async_req=True)
>>> result = thread.get()
:param async_re... | [
"partially",
"update",
"the",
"specified",
"Event",
"This",
"method",
"makes",
"a",
"synchronous",
"HTTP",
"request",
"by",
"default",
".",
"To",
"make",
"an",
"asynchronous",
"HTTP",
"request",
"please",
"pass",
"async_req",
"=",
"True",
">>>",
"thread",
"=",... | python | train |
MartinThoma/hwrt | hwrt/language_model/language_model.py | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/language_model/language_model.py#L157-L177 | def load_model():
"""
Load a n-gram language model for mathematics in ARPA format which gets
shipped with hwrt.
Returns
-------
A NgramLanguageModel object
"""
logging.info("Load language model...")
ngram_arpa_t = pkg_resources.resource_filename('hwrt',
... | [
"def",
"load_model",
"(",
")",
":",
"logging",
".",
"info",
"(",
"\"Load language model...\"",
")",
"ngram_arpa_t",
"=",
"pkg_resources",
".",
"resource_filename",
"(",
"'hwrt'",
",",
"'misc/ngram.arpa.tar.bz2'",
")",
"with",
"tarfile",
".",
"open",
"(",
"ngram_ar... | Load a n-gram language model for mathematics in ARPA format which gets
shipped with hwrt.
Returns
-------
A NgramLanguageModel object | [
"Load",
"a",
"n",
"-",
"gram",
"language",
"model",
"for",
"mathematics",
"in",
"ARPA",
"format",
"which",
"gets",
"shipped",
"with",
"hwrt",
"."
] | python | train |
marcomusy/vtkplotter | vtkplotter/utils.py | https://github.com/marcomusy/vtkplotter/blob/692c3396782722ec525bc1346a26999868c650c6/vtkplotter/utils.py#L181-L198 | def pointIsInTriangle(p, p1, p2, p3):
"""
Return True if a point is inside (or above/below) a triangle defined by 3 points in space.
"""
p = np.array(p)
u = np.array(p2) - p1
v = np.array(p3) - p1
n = np.cross(u, v)
w = p - p1
ln = np.dot(n, n)
if not ln:
return True # d... | [
"def",
"pointIsInTriangle",
"(",
"p",
",",
"p1",
",",
"p2",
",",
"p3",
")",
":",
"p",
"=",
"np",
".",
"array",
"(",
"p",
")",
"u",
"=",
"np",
".",
"array",
"(",
"p2",
")",
"-",
"p1",
"v",
"=",
"np",
".",
"array",
"(",
"p3",
")",
"-",
"p1"... | Return True if a point is inside (or above/below) a triangle defined by 3 points in space. | [
"Return",
"True",
"if",
"a",
"point",
"is",
"inside",
"(",
"or",
"above",
"/",
"below",
")",
"a",
"triangle",
"defined",
"by",
"3",
"points",
"in",
"space",
"."
] | python | train |
BD2KGenomics/protect | attic/ProTECT.py | https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/attic/ProTECT.py#L1099-L1109 | def run_fusion_caller(job, star_bam, univ_options, fusion_options):
"""
This module will run a fusion caller on DNA bams. This module will be
implemented in the future.
This module corresponds to node 10 on the tree
"""
job.fileStore.logToMaster('Running FUSION on %s' % univ_options['patient']... | [
"def",
"run_fusion_caller",
"(",
"job",
",",
"star_bam",
",",
"univ_options",
",",
"fusion_options",
")",
":",
"job",
".",
"fileStore",
".",
"logToMaster",
"(",
"'Running FUSION on %s'",
"%",
"univ_options",
"[",
"'patient'",
"]",
")",
"fusion_file",
"=",
"job",... | This module will run a fusion caller on DNA bams. This module will be
implemented in the future.
This module corresponds to node 10 on the tree | [
"This",
"module",
"will",
"run",
"a",
"fusion",
"caller",
"on",
"DNA",
"bams",
".",
"This",
"module",
"will",
"be",
"implemented",
"in",
"the",
"future",
"."
] | python | train |
PGower/PyCanvas | pycanvas/apis/calendar_events.py | https://github.com/PGower/PyCanvas/blob/68520005382b440a1e462f9df369f54d364e21e8/pycanvas/apis/calendar_events.py#L254-L286 | def reserve_time_slot(self, id, cancel_existing=None, comments=None, participant_id=None):
"""
Reserve a time slot.
Reserves a particular time slot and return the new reservation
"""
path = {}
data = {}
params = {}
# REQUIRED - PATH - id
... | [
"def",
"reserve_time_slot",
"(",
"self",
",",
"id",
",",
"cancel_existing",
"=",
"None",
",",
"comments",
"=",
"None",
",",
"participant_id",
"=",
"None",
")",
":",
"path",
"=",
"{",
"}",
"data",
"=",
"{",
"}",
"params",
"=",
"{",
"}",
"# REQUIRED - PA... | Reserve a time slot.
Reserves a particular time slot and return the new reservation | [
"Reserve",
"a",
"time",
"slot",
".",
"Reserves",
"a",
"particular",
"time",
"slot",
"and",
"return",
"the",
"new",
"reservation"
] | python | train |
fabioz/PyDev.Debugger | pydevd_attach_to_process/winappdbg/thread.py | https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/thread.py#L1598-L1617 | def disassemble_string(self, lpAddress, code):
"""
Disassemble instructions from a block of binary code.
@type lpAddress: int
@param lpAddress: Memory address where the code was read from.
@type code: str
@param code: Binary code to disassemble.
@rtype: list... | [
"def",
"disassemble_string",
"(",
"self",
",",
"lpAddress",
",",
"code",
")",
":",
"aProcess",
"=",
"self",
".",
"get_process",
"(",
")",
"return",
"aProcess",
".",
"disassemble_string",
"(",
"lpAddress",
",",
"code",
")"
] | Disassemble instructions from a block of binary code.
@type lpAddress: int
@param lpAddress: Memory address where the code was read from.
@type code: str
@param code: Binary code to disassemble.
@rtype: list of tuple( long, int, str, str )
@return: List of tuples. E... | [
"Disassemble",
"instructions",
"from",
"a",
"block",
"of",
"binary",
"code",
"."
] | python | train |
jonathf/chaospy | chaospy/distributions/operators/sinh.py | https://github.com/jonathf/chaospy/blob/25ecfa7bf5608dc10c0b31d142ded0e3755f5d74/chaospy/distributions/operators/sinh.py#L38-L41 | def _pdf(self, x, dist, cache):
"""Probability density function."""
return evaluation.evaluate_density(
dist, numpy.arcsinh(x), cache=cache)/numpy.sqrt(1+x*x) | [
"def",
"_pdf",
"(",
"self",
",",
"x",
",",
"dist",
",",
"cache",
")",
":",
"return",
"evaluation",
".",
"evaluate_density",
"(",
"dist",
",",
"numpy",
".",
"arcsinh",
"(",
"x",
")",
",",
"cache",
"=",
"cache",
")",
"/",
"numpy",
".",
"sqrt",
"(",
... | Probability density function. | [
"Probability",
"density",
"function",
"."
] | python | train |
squidsoup/muddle.py | muddle/api.py | https://github.com/squidsoup/muddle.py/blob/f58c62e7d92b9ac24a16de007c0fbd6607b15687/muddle/api.py#L249-L266 | def details(self):
"""
Returns details for given category
:returns: category response object
Example Usage::
>>> import muddle
>>> muddle.category(10).details()
"""
params = {'wsfunction': 'core_course_get_categories',
'criteria[0][key... | [
"def",
"details",
"(",
"self",
")",
":",
"params",
"=",
"{",
"'wsfunction'",
":",
"'core_course_get_categories'",
",",
"'criteria[0][key]'",
":",
"'id'",
",",
"'criteria[0][value]'",
":",
"self",
".",
"category_id",
"}",
"params",
".",
"update",
"(",
"self",
"... | Returns details for given category
:returns: category response object
Example Usage::
>>> import muddle
>>> muddle.category(10).details() | [
"Returns",
"details",
"for",
"given",
"category"
] | python | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/pdftex.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/pdftex.py#L71-L99 | def generate(env):
"""Add Builders and construction variables for pdftex to an Environment."""
global PDFTeXAction
if PDFTeXAction is None:
PDFTeXAction = SCons.Action.Action('$PDFTEXCOM', '$PDFTEXCOMSTR')
global PDFLaTeXAction
if PDFLaTeXAction is None:
PDFLaTeXAction = SCons.Actio... | [
"def",
"generate",
"(",
"env",
")",
":",
"global",
"PDFTeXAction",
"if",
"PDFTeXAction",
"is",
"None",
":",
"PDFTeXAction",
"=",
"SCons",
".",
"Action",
".",
"Action",
"(",
"'$PDFTEXCOM'",
",",
"'$PDFTEXCOMSTR'",
")",
"global",
"PDFLaTeXAction",
"if",
"PDFLaTe... | Add Builders and construction variables for pdftex to an Environment. | [
"Add",
"Builders",
"and",
"construction",
"variables",
"for",
"pdftex",
"to",
"an",
"Environment",
"."
] | python | train |
edx/bok-choy | bok_choy/browser.py | https://github.com/edx/bok-choy/blob/cdd0d423419fc0c49d56a9226533aa1490b60afc/bok_choy/browser.py#L477-L503 | def _proxy_kwargs(browser_name, proxy, browser_kwargs={}): # pylint: disable=dangerous-default-value
"""
Determines the kwargs needed to set up a proxy based on the
browser type.
Returns: a dictionary of arguments needed to pass when
instantiating the WebDriver instance.
"""
proxy_dic... | [
"def",
"_proxy_kwargs",
"(",
"browser_name",
",",
"proxy",
",",
"browser_kwargs",
"=",
"{",
"}",
")",
":",
"# pylint: disable=dangerous-default-value",
"proxy_dict",
"=",
"{",
"\"httpProxy\"",
":",
"proxy",
".",
"proxy",
",",
"\"proxyType\"",
":",
"'manual'",
",",... | Determines the kwargs needed to set up a proxy based on the
browser type.
Returns: a dictionary of arguments needed to pass when
instantiating the WebDriver instance. | [
"Determines",
"the",
"kwargs",
"needed",
"to",
"set",
"up",
"a",
"proxy",
"based",
"on",
"the",
"browser",
"type",
"."
] | python | train |
DancingQuanta/pyusbiss | usbiss/usbiss.py | https://github.com/DancingQuanta/pyusbiss/blob/fc64e123f1c97f53ad153c474d230ad38044c3cb/usbiss/usbiss.py#L95-L112 | def get_iss_info(self):
"""
Get information about the USB-ISS
Querying will return three bytes;
- the module ID (7),
- firmware version (currently 2),
- the current operating mode.
"""
self.write_data([self.ISS_CMD, self.ISS_VERSION])
response = s... | [
"def",
"get_iss_info",
"(",
"self",
")",
":",
"self",
".",
"write_data",
"(",
"[",
"self",
".",
"ISS_CMD",
",",
"self",
".",
"ISS_VERSION",
"]",
")",
"response",
"=",
"self",
".",
"read_data",
"(",
"3",
")",
"if",
"len",
"(",
"response",
")",
"==",
... | Get information about the USB-ISS
Querying will return three bytes;
- the module ID (7),
- firmware version (currently 2),
- the current operating mode. | [
"Get",
"information",
"about",
"the",
"USB",
"-",
"ISS"
] | python | train |
apache/incubator-superset | superset/connectors/druid/models.py | https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/connectors/druid/models.py#L1010-L1025 | def _dimensions_to_values(dimensions):
"""
Replace dimensions specs with their `dimension`
values, and ignore those without
"""
values = []
for dimension in dimensions:
if isinstance(dimension, dict):
if 'extractionFn' in dimension:
... | [
"def",
"_dimensions_to_values",
"(",
"dimensions",
")",
":",
"values",
"=",
"[",
"]",
"for",
"dimension",
"in",
"dimensions",
":",
"if",
"isinstance",
"(",
"dimension",
",",
"dict",
")",
":",
"if",
"'extractionFn'",
"in",
"dimension",
":",
"values",
".",
"... | Replace dimensions specs with their `dimension`
values, and ignore those without | [
"Replace",
"dimensions",
"specs",
"with",
"their",
"dimension",
"values",
"and",
"ignore",
"those",
"without"
] | python | train |
eternnoir/pyTelegramBotAPI | telebot/apihelper.py | https://github.com/eternnoir/pyTelegramBotAPI/blob/47b53b88123097f1b9562a6cd5d4e080b86185d1/telebot/apihelper.py#L34-L56 | def _make_request(token, method_name, method='get', params=None, files=None, base_url=API_URL):
"""
Makes a request to the Telegram API.
:param token: The bot's API token. (Created with @BotFather)
:param method_name: Name of the API method to be called. (E.g. 'getUpdates')
:param method: HTTP metho... | [
"def",
"_make_request",
"(",
"token",
",",
"method_name",
",",
"method",
"=",
"'get'",
",",
"params",
"=",
"None",
",",
"files",
"=",
"None",
",",
"base_url",
"=",
"API_URL",
")",
":",
"request_url",
"=",
"base_url",
".",
"format",
"(",
"token",
",",
"... | Makes a request to the Telegram API.
:param token: The bot's API token. (Created with @BotFather)
:param method_name: Name of the API method to be called. (E.g. 'getUpdates')
:param method: HTTP method to be used. Defaults to 'get'.
:param params: Optional parameters. Should be a dictionary with key-val... | [
"Makes",
"a",
"request",
"to",
"the",
"Telegram",
"API",
".",
":",
"param",
"token",
":",
"The",
"bot",
"s",
"API",
"token",
".",
"(",
"Created",
"with"
] | python | train |
ewels/MultiQC | multiqc/modules/vcftools/tstv_summary.py | https://github.com/ewels/MultiQC/blob/2037d6322b2554146a74efbf869156ad20d4c4ec/multiqc/modules/vcftools/tstv_summary.py#L14-L49 | def parse_tstv_summary(self):
""" Create the HTML for the TsTv summary plot. """
self.vcftools_tstv_summary = dict()
for f in self.find_log_files('vcftools/tstv_summary', filehandles=True):
d = {}
for line in f['f'].readlines()[1:]: # don't add the header line (first row... | [
"def",
"parse_tstv_summary",
"(",
"self",
")",
":",
"self",
".",
"vcftools_tstv_summary",
"=",
"dict",
"(",
")",
"for",
"f",
"in",
"self",
".",
"find_log_files",
"(",
"'vcftools/tstv_summary'",
",",
"filehandles",
"=",
"True",
")",
":",
"d",
"=",
"{",
"}",... | Create the HTML for the TsTv summary plot. | [
"Create",
"the",
"HTML",
"for",
"the",
"TsTv",
"summary",
"plot",
"."
] | python | train |
pytroll/pyspectral | rsr_convert_scripts/metimage_rsr.py | https://github.com/pytroll/pyspectral/blob/fd296c0e0bdf5364fa180134a1292665d6bc50a3/rsr_convert_scripts/metimage_rsr.py#L71-L88 | def _load(self, scale=1.0):
"""Load the MetImage RSR data for the band requested"""
data = np.genfromtxt(self.requested_band_filename,
unpack=True,
names=['wavenumber',
'response'],
... | [
"def",
"_load",
"(",
"self",
",",
"scale",
"=",
"1.0",
")",
":",
"data",
"=",
"np",
".",
"genfromtxt",
"(",
"self",
".",
"requested_band_filename",
",",
"unpack",
"=",
"True",
",",
"names",
"=",
"[",
"'wavenumber'",
",",
"'response'",
"]",
",",
"skip_h... | Load the MetImage RSR data for the band requested | [
"Load",
"the",
"MetImage",
"RSR",
"data",
"for",
"the",
"band",
"requested"
] | python | train |
PyGithub/PyGithub | github/AuthenticatedUser.py | https://github.com/PyGithub/PyGithub/blob/f716df86bbe7dc276c6596699fa9712b61ef974c/github/AuthenticatedUser.py#L529-L601 | def create_repo(self, name, description=github.GithubObject.NotSet, homepage=github.GithubObject.NotSet,
private=github.GithubObject.NotSet, has_issues=github.GithubObject.NotSet,
has_wiki=github.GithubObject.NotSet, has_downloads=github.GithubObject.NotSet,
h... | [
"def",
"create_repo",
"(",
"self",
",",
"name",
",",
"description",
"=",
"github",
".",
"GithubObject",
".",
"NotSet",
",",
"homepage",
"=",
"github",
".",
"GithubObject",
".",
"NotSet",
",",
"private",
"=",
"github",
".",
"GithubObject",
".",
"NotSet",
",... | :calls: `POST /user/repos <http://developer.github.com/v3/repos>`_
:param name: string
:param description: string
:param homepage: string
:param private: bool
:param has_issues: bool
:param has_wiki: bool
:param has_downloads: bool
:param has_projects: boo... | [
":",
"calls",
":",
"POST",
"/",
"user",
"/",
"repos",
"<http",
":",
"//",
"developer",
".",
"github",
".",
"com",
"/",
"v3",
"/",
"repos",
">",
"_",
":",
"param",
"name",
":",
"string",
":",
"param",
"description",
":",
"string",
":",
"param",
"hom... | python | train |
flaviogrossi/sockjs-cyclone | sockjs/cyclone/router.py | https://github.com/flaviogrossi/sockjs-cyclone/blob/d3ca053ec1aa1e85f652347bff562c2319be37a2/sockjs/cyclone/router.py#L131-L158 | def create_session(self, session_id, register=True, session_factory=None):
""" Creates new session object and returns it.
@param session_id: Session id. If not provided, will generate a
new session id.
@param register: Should be the session registered in a storage.
... | [
"def",
"create_session",
"(",
"self",
",",
"session_id",
",",
"register",
"=",
"True",
",",
"session_factory",
"=",
"None",
")",
":",
"if",
"session_factory",
"is",
"not",
"None",
":",
"# use custom class to create session",
"sess_factory",
",",
"sess_args",
",",
... | Creates new session object and returns it.
@param session_id: Session id. If not provided, will generate a
new session id.
@param register: Should be the session registered in a storage.
Websockets don't need it.
@param session_factory: Use ... | [
"Creates",
"new",
"session",
"object",
"and",
"returns",
"it",
"."
] | python | train |
materialsproject/pymatgen | pymatgen/analysis/chemenv/coordination_environments/coordination_geometry_finder.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/chemenv/coordination_environments/coordination_geometry_finder.py#L419-L429 | def set_structure(self, lattice, species, coords, coords_are_cartesian):
"""
Sets up the pymatgen structure for which the coordination geometries have to be identified starting from the
lattice, the species and the coordinates
:param lattice: The lattice of the structure
:param s... | [
"def",
"set_structure",
"(",
"self",
",",
"lattice",
",",
"species",
",",
"coords",
",",
"coords_are_cartesian",
")",
":",
"self",
".",
"setup_structure",
"(",
"Structure",
"(",
"lattice",
",",
"species",
",",
"coords",
",",
"coords_are_cartesian",
")",
")"
] | Sets up the pymatgen structure for which the coordination geometries have to be identified starting from the
lattice, the species and the coordinates
:param lattice: The lattice of the structure
:param species: The species on the sites
:param coords: The coordinates of the sites
... | [
"Sets",
"up",
"the",
"pymatgen",
"structure",
"for",
"which",
"the",
"coordination",
"geometries",
"have",
"to",
"be",
"identified",
"starting",
"from",
"the",
"lattice",
"the",
"species",
"and",
"the",
"coordinates",
":",
"param",
"lattice",
":",
"The",
"latt... | python | train |
AkihikoITOH/capybara | capybara/virtualenv/lib/python2.7/site-packages/setuptools/depends.py | https://github.com/AkihikoITOH/capybara/blob/e86c2173ea386654f4ae061148e8fbe3f25e715c/capybara/virtualenv/lib/python2.7/site-packages/setuptools/depends.py#L166-L198 | def extract_constant(code, symbol, default=-1):
"""Extract the constant value of 'symbol' from 'code'
If the name 'symbol' is bound to a constant value by the Python code
object 'code', return that value. If 'symbol' is bound to an expression,
return 'default'. Otherwise, return 'None'.
Return v... | [
"def",
"extract_constant",
"(",
"code",
",",
"symbol",
",",
"default",
"=",
"-",
"1",
")",
":",
"if",
"symbol",
"not",
"in",
"code",
".",
"co_names",
":",
"# name's not there, can't possibly be an assigment",
"return",
"None",
"name_idx",
"=",
"list",
"(",
"co... | Extract the constant value of 'symbol' from 'code'
If the name 'symbol' is bound to a constant value by the Python code
object 'code', return that value. If 'symbol' is bound to an expression,
return 'default'. Otherwise, return 'None'.
Return value is based on the first assignment to 'symbol'. 'sy... | [
"Extract",
"the",
"constant",
"value",
"of",
"symbol",
"from",
"code"
] | python | test |
KnowledgeLinks/rdfframework | rdfframework/rdfclass/rdfclass.py | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdfclass.py#L660-L689 | def _initilize_props(self):
""" Adds an intialized property to the class dictionary """
# if self.subject == "pyuri_aHR0cDovL3R1dHQuZWR1Lw==_":
# pdb.set_trace()
try:
# pdb.set_trace()
for prop in self.es_props:
self[prop] = self.properties[pro... | [
"def",
"_initilize_props",
"(",
"self",
")",
":",
"# if self.subject == \"pyuri_aHR0cDovL3R1dHQuZWR1Lw==_\":",
"# pdb.set_trace()",
"try",
":",
"# pdb.set_trace()",
"for",
"prop",
"in",
"self",
".",
"es_props",
":",
"self",
"[",
"prop",
"]",
"=",
"self",
".",
"p... | Adds an intialized property to the class dictionary | [
"Adds",
"an",
"intialized",
"property",
"to",
"the",
"class",
"dictionary"
] | python | train |
juju/python-libjuju | juju/model.py | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/model.py#L343-L355 | def previous(self):
"""Return a copy of this object as was at its previous state in
history.
Returns None if this object is new (and therefore has no history).
The returned object is always "disconnected", i.e. does not receive
live updates.
"""
return self.mod... | [
"def",
"previous",
"(",
"self",
")",
":",
"return",
"self",
".",
"model",
".",
"state",
".",
"get_entity",
"(",
"self",
".",
"entity_type",
",",
"self",
".",
"entity_id",
",",
"self",
".",
"_history_index",
"-",
"1",
",",
"connected",
"=",
"False",
")"... | Return a copy of this object as was at its previous state in
history.
Returns None if this object is new (and therefore has no history).
The returned object is always "disconnected", i.e. does not receive
live updates. | [
"Return",
"a",
"copy",
"of",
"this",
"object",
"as",
"was",
"at",
"its",
"previous",
"state",
"in",
"history",
"."
] | python | train |
Jaymon/prom | prom/decorators.py | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/decorators.py#L13-L81 | def reconnecting(count=None, backoff=None):
"""this is a very specific decorator meant to be used on Interface classes.
It will attempt to reconnect if the connection is closed and run the same
method again.
TODO -- I think this will have issues with transactions using passed in
connections, ie, y... | [
"def",
"reconnecting",
"(",
"count",
"=",
"None",
",",
"backoff",
"=",
"None",
")",
":",
"# we get trixxy here so we can manipulate these values in the wrapped function,",
"# this is one of the first times I wish we were on Python 3",
"# http://stackoverflow.com/a/9264845/5006",
"recon... | this is a very specific decorator meant to be used on Interface classes.
It will attempt to reconnect if the connection is closed and run the same
method again.
TODO -- I think this will have issues with transactions using passed in
connections, ie, you pass in a transacting connection to the insert()... | [
"this",
"is",
"a",
"very",
"specific",
"decorator",
"meant",
"to",
"be",
"used",
"on",
"Interface",
"classes",
".",
"It",
"will",
"attempt",
"to",
"reconnect",
"if",
"the",
"connection",
"is",
"closed",
"and",
"run",
"the",
"same",
"method",
"again",
"."
] | python | train |
danpaquin/coinbasepro-python | cbpro/authenticated_client.py | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/authenticated_client.py#L131-L174 | def get_account_holds(self, account_id, **kwargs):
""" Get holds on an account.
This method returns a generator which may make multiple HTTP requests
while iterating through it.
Holds are placed on an account for active orders or
pending withdraw requests.
As an order ... | [
"def",
"get_account_holds",
"(",
"self",
",",
"account_id",
",",
"*",
"*",
"kwargs",
")",
":",
"endpoint",
"=",
"'/accounts/{}/holds'",
".",
"format",
"(",
"account_id",
")",
"return",
"self",
".",
"_send_paginated_message",
"(",
"endpoint",
",",
"params",
"="... | Get holds on an account.
This method returns a generator which may make multiple HTTP requests
while iterating through it.
Holds are placed on an account for active orders or
pending withdraw requests.
As an order is filled, the hold amount is updated. If an order
is c... | [
"Get",
"holds",
"on",
"an",
"account",
"."
] | python | train |
asweigart/pytweening | pytweening/__init__.py | https://github.com/asweigart/pytweening/blob/20d74368e53dc7d0f77c810b624b2c90994f099d/pytweening/__init__.py#L511-L522 | def easeOutBack(n, s=1.70158):
"""A tween function that overshoots the destination a little and then backs into the destination.
Args:
n (float): The time progress, starting at 0.0 and ending at 1.0.
Returns:
(float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to... | [
"def",
"easeOutBack",
"(",
"n",
",",
"s",
"=",
"1.70158",
")",
":",
"_checkRange",
"(",
"n",
")",
"n",
"=",
"n",
"-",
"1",
"return",
"n",
"*",
"n",
"*",
"(",
"(",
"s",
"+",
"1",
")",
"*",
"n",
"+",
"s",
")",
"+",
"1"
] | A tween function that overshoots the destination a little and then backs into the destination.
Args:
n (float): The time progress, starting at 0.0 and ending at 1.0.
Returns:
(float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnLine(). | [
"A",
"tween",
"function",
"that",
"overshoots",
"the",
"destination",
"a",
"little",
"and",
"then",
"backs",
"into",
"the",
"destination",
"."
] | python | train |
jorgeecardona/dynect | dynect/__init__.py | https://github.com/jorgeecardona/dynect/blob/d2cd85bc510f00108a3a5bfe515f45daae15a482/dynect/__init__.py#L348-L352 | def delete(self):
" Delete the record."
response = self.dyn.delete(self.url)
return response.content['job_id'] | [
"def",
"delete",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"dyn",
".",
"delete",
"(",
"self",
".",
"url",
")",
"return",
"response",
".",
"content",
"[",
"'job_id'",
"]"
] | Delete the record. | [
"Delete",
"the",
"record",
"."
] | python | train |
zhanglab/psamm | psamm/gapfilling.py | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/gapfilling.py#L98-L156 | def add_all_transport_reactions(model, boundaries, allow_duplicates=False):
"""Add all transport reactions to database and to model.
Add transport reactions for all boundaries. Boundaries are defined
by pairs (2-tuples) of compartment IDs. Transport reactions are
added for all compounds in the model, n... | [
"def",
"add_all_transport_reactions",
"(",
"model",
",",
"boundaries",
",",
"allow_duplicates",
"=",
"False",
")",
":",
"all_reactions",
"=",
"{",
"}",
"if",
"not",
"allow_duplicates",
":",
"# TODO: Avoid adding reactions that already exist in the database.",
"# This should... | Add all transport reactions to database and to model.
Add transport reactions for all boundaries. Boundaries are defined
by pairs (2-tuples) of compartment IDs. Transport reactions are
added for all compounds in the model, not just for compounds in the
two boundary compartments.
Args:
mode... | [
"Add",
"all",
"transport",
"reactions",
"to",
"database",
"and",
"to",
"model",
"."
] | python | train |
gem/oq-engine | openquake/baselib/parallel.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/parallel.py#L707-L724 | def submit(self, *args, func=None, monitor=None):
"""
Submit the given arguments to the underlying task
"""
monitor = monitor or self.monitor
func = func or self.task_func
if not hasattr(self, 'socket'): # first time
self.__class__.running_tasks = self.tasks
... | [
"def",
"submit",
"(",
"self",
",",
"*",
"args",
",",
"func",
"=",
"None",
",",
"monitor",
"=",
"None",
")",
":",
"monitor",
"=",
"monitor",
"or",
"self",
".",
"monitor",
"func",
"=",
"func",
"or",
"self",
".",
"task_func",
"if",
"not",
"hasattr",
"... | Submit the given arguments to the underlying task | [
"Submit",
"the",
"given",
"arguments",
"to",
"the",
"underlying",
"task"
] | python | train |
dereneaton/ipyrad | ipyrad/assemble/write_outfiles.py | https://github.com/dereneaton/ipyrad/blob/5eeb8a178160f45faf71bf47cec4abe998a575d1/ipyrad/assemble/write_outfiles.py#L1748-L1796 | def write_nex(data, sidx, pnames):
"""
write the nexus output file from the tmparr[seqarray] and tmparr[maparr]
"""
## grab seq data from tmparr
start = time.time()
tmparrs = os.path.join(data.dirs.outfiles, "tmp-{}.h5".format(data.name))
with h5py.File(tmparrs, 'r') as io5:
s... | [
"def",
"write_nex",
"(",
"data",
",",
"sidx",
",",
"pnames",
")",
":",
"## grab seq data from tmparr",
"start",
"=",
"time",
".",
"time",
"(",
")",
"tmparrs",
"=",
"os",
".",
"path",
".",
"join",
"(",
"data",
".",
"dirs",
".",
"outfiles",
",",
"\"tmp-{... | write the nexus output file from the tmparr[seqarray] and tmparr[maparr] | [
"write",
"the",
"nexus",
"output",
"file",
"from",
"the",
"tmparr",
"[",
"seqarray",
"]",
"and",
"tmparr",
"[",
"maparr",
"]"
] | python | valid |
timstaley/voeventdb | voeventdb/server/database/models.py | https://github.com/timstaley/voeventdb/blob/e37b176d65fced4ca4f059109a95d6974bb8a091/voeventdb/server/database/models.py#L28-L56 | def _has_bad_coords(root, stream):
"""
Predicate function encapsulating 'data clean up' filter code.
Currently minimal, but these sort of functions tend to grow over time.
Problem 1:
Some of the GCN packets have an RA /Dec equal to (0,0) in the WhereWhen,
and a flag in the What signify... | [
"def",
"_has_bad_coords",
"(",
"root",
",",
"stream",
")",
":",
"if",
"stream",
"==",
"\"com.dc3/dc3.broker\"",
":",
"return",
"True",
"if",
"not",
"stream",
".",
"split",
"(",
"'/'",
")",
"[",
"0",
"]",
"==",
"'nasa.gsfc.gcn'",
":",
"return",
"False",
"... | Predicate function encapsulating 'data clean up' filter code.
Currently minimal, but these sort of functions tend to grow over time.
Problem 1:
Some of the GCN packets have an RA /Dec equal to (0,0) in the WhereWhen,
and a flag in the What signifying that those are actually dummy co-ords.
... | [
"Predicate",
"function",
"encapsulating",
"data",
"clean",
"up",
"filter",
"code",
"."
] | python | train |
dropbox/stone | stone/backends/python_type_stubs.py | https://github.com/dropbox/stone/blob/2e95cbcd1c48e05cca68c919fd8d24adec6b0f58/stone/backends/python_type_stubs.py#L109-L141 | def _generate_base_namespace_module(self, namespace):
# type: (ApiNamespace) -> None
"""Creates a module for the namespace. All data types and routes are
represented as Python classes."""
self.cur_namespace = namespace
self.import_tracker.clear()
generate_module_header(s... | [
"def",
"_generate_base_namespace_module",
"(",
"self",
",",
"namespace",
")",
":",
"# type: (ApiNamespace) -> None",
"self",
".",
"cur_namespace",
"=",
"namespace",
"self",
".",
"import_tracker",
".",
"clear",
"(",
")",
"generate_module_header",
"(",
"self",
")",
"s... | Creates a module for the namespace. All data types and routes are
represented as Python classes. | [
"Creates",
"a",
"module",
"for",
"the",
"namespace",
".",
"All",
"data",
"types",
"and",
"routes",
"are",
"represented",
"as",
"Python",
"classes",
"."
] | python | train |
wreckage/django-happenings | happenings/utils/common.py | https://github.com/wreckage/django-happenings/blob/7bca5576efa6cd4c4e87356bf9e5b8cd538ae91d/happenings/utils/common.py#L169-L180 | def check_weekday(year, month, day, reverse=False):
"""
Make sure any event day we send back for weekday repeating
events is not a weekend.
"""
d = date(year, month, day)
while d.weekday() in (5, 6):
if reverse:
d -= timedelta(days=1)
else:
d += timedelta(... | [
"def",
"check_weekday",
"(",
"year",
",",
"month",
",",
"day",
",",
"reverse",
"=",
"False",
")",
":",
"d",
"=",
"date",
"(",
"year",
",",
"month",
",",
"day",
")",
"while",
"d",
".",
"weekday",
"(",
")",
"in",
"(",
"5",
",",
"6",
")",
":",
"... | Make sure any event day we send back for weekday repeating
events is not a weekend. | [
"Make",
"sure",
"any",
"event",
"day",
"we",
"send",
"back",
"for",
"weekday",
"repeating",
"events",
"is",
"not",
"a",
"weekend",
"."
] | python | test |
slackapi/python-slack-events-api | slackeventsapi/__init__.py | https://github.com/slackapi/python-slack-events-api/blob/1254d83181eb939f124a0e4746dafea7e14047c1/slackeventsapi/__init__.py#L13-L23 | def start(self, host='127.0.0.1', port=None, debug=False, **kwargs):
"""
Start the built in webserver, bound to the host and port you'd like.
Default host is `127.0.0.1` and port 8080.
:param host: The host you want to bind the build in webserver to
:param port: The port number ... | [
"def",
"start",
"(",
"self",
",",
"host",
"=",
"'127.0.0.1'",
",",
"port",
"=",
"None",
",",
"debug",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"server",
".",
"run",
"(",
"host",
"=",
"host",
",",
"port",
"=",
"port",
",",
"... | Start the built in webserver, bound to the host and port you'd like.
Default host is `127.0.0.1` and port 8080.
:param host: The host you want to bind the build in webserver to
:param port: The port number you want the webserver to run on
:param debug: Set to `True` to enable debug leve... | [
"Start",
"the",
"built",
"in",
"webserver",
"bound",
"to",
"the",
"host",
"and",
"port",
"you",
"d",
"like",
".",
"Default",
"host",
"is",
"127",
".",
"0",
".",
"0",
".",
"1",
"and",
"port",
"8080",
"."
] | python | train |
hearsaycorp/normalize | normalize/visitor.py | https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/visitor.py#L482-L506 | def reflect(cls, X, **kwargs):
"""Reflect is for visitors where you are exposing some information
about the types reachable from a starting type to an external system.
For example, a front-end, a REST URL router and documentation
framework, an avro schema definition, etc.
X can ... | [
"def",
"reflect",
"(",
"cls",
",",
"X",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"X",
",",
"type",
")",
":",
"value",
"=",
"None",
"value_type",
"=",
"X",
"else",
":",
"value",
"=",
"X",
"value_type",
"=",
"type",
"(",
"X",
"... | Reflect is for visitors where you are exposing some information
about the types reachable from a starting type to an external system.
For example, a front-end, a REST URL router and documentation
framework, an avro schema definition, etc.
X can be a type or an instance.
This AP... | [
"Reflect",
"is",
"for",
"visitors",
"where",
"you",
"are",
"exposing",
"some",
"information",
"about",
"the",
"types",
"reachable",
"from",
"a",
"starting",
"type",
"to",
"an",
"external",
"system",
".",
"For",
"example",
"a",
"front",
"-",
"end",
"a",
"RE... | python | train |
cons3rt/pycons3rt | pycons3rt/nexus.py | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/nexus.py#L302-L553 | def get_artifact_nexus3(suppress_status=False, nexus_base_url=sample_nexus_base_url, repository=None,
timeout_sec=600, overwrite=True, username=None, password=None, **kwargs):
"""Retrieves an artifact from the Nexus 3 ReST API
:param suppress_status: (bool) Set to True to suppress print... | [
"def",
"get_artifact_nexus3",
"(",
"suppress_status",
"=",
"False",
",",
"nexus_base_url",
"=",
"sample_nexus_base_url",
",",
"repository",
"=",
"None",
",",
"timeout_sec",
"=",
"600",
",",
"overwrite",
"=",
"True",
",",
"username",
"=",
"None",
",",
"password",... | Retrieves an artifact from the Nexus 3 ReST API
:param suppress_status: (bool) Set to True to suppress printing download status
:param nexus_base_url: (str) Base URL of the Nexus Server (domain name portion only, see sample)
:param repository: (str) Repository to query (e.g. snapshots) if not provided, wil... | [
"Retrieves",
"an",
"artifact",
"from",
"the",
"Nexus",
"3",
"ReST",
"API"
] | python | train |
justquick/django-activity-stream | actstream/templatetags/activity_tags.py | https://github.com/justquick/django-activity-stream/blob/a1e06f2e6429cc5fc321e7801440dd7c5b9d5a35/actstream/templatetags/activity_tags.py#L60-L79 | def handle_token(cls, parser, token):
"""
Class method to parse and return a Node.
"""
tag_error = "Accepted formats {%% %(tagname)s %(args)s %%} or " \
"{%% %(tagname)s %(args)s as [var] %%}"
bits = token.split_contents()
args_count = len(bits) - 1
... | [
"def",
"handle_token",
"(",
"cls",
",",
"parser",
",",
"token",
")",
":",
"tag_error",
"=",
"\"Accepted formats {%% %(tagname)s %(args)s %%} or \"",
"\"{%% %(tagname)s %(args)s as [var] %%}\"",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"args_count",
"=",
"l... | Class method to parse and return a Node. | [
"Class",
"method",
"to",
"parse",
"and",
"return",
"a",
"Node",
"."
] | python | train |
google/mobly | mobly/controllers/monsoon.py | https://github.com/google/mobly/blob/38ba2cf7d29a20e6a2fca1718eecb337df38db26/mobly/controllers/monsoon.py#L481-L488 | def average_current(self):
"""Average current in the unit of mA.
"""
len_data_pt = len(self.data_points)
if len_data_pt == 0:
return 0
cur = sum(self.data_points) * 1000 / len_data_pt
return round(cur, self.sr) | [
"def",
"average_current",
"(",
"self",
")",
":",
"len_data_pt",
"=",
"len",
"(",
"self",
".",
"data_points",
")",
"if",
"len_data_pt",
"==",
"0",
":",
"return",
"0",
"cur",
"=",
"sum",
"(",
"self",
".",
"data_points",
")",
"*",
"1000",
"/",
"len_data_p... | Average current in the unit of mA. | [
"Average",
"current",
"in",
"the",
"unit",
"of",
"mA",
"."
] | python | train |
pantsbuild/pants | src/python/pants/base/hash_utils.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/base/hash_utils.py#L19-L28 | def hash_all(strs, digest=None):
"""Returns a hash of the concatenation of all the strings in strs.
If a hashlib message digest is not supplied a new sha1 message digest is used.
"""
digest = digest or hashlib.sha1()
for s in strs:
s = ensure_binary(s)
digest.update(s)
return digest.hexdigest() if ... | [
"def",
"hash_all",
"(",
"strs",
",",
"digest",
"=",
"None",
")",
":",
"digest",
"=",
"digest",
"or",
"hashlib",
".",
"sha1",
"(",
")",
"for",
"s",
"in",
"strs",
":",
"s",
"=",
"ensure_binary",
"(",
"s",
")",
"digest",
".",
"update",
"(",
"s",
")"... | Returns a hash of the concatenation of all the strings in strs.
If a hashlib message digest is not supplied a new sha1 message digest is used. | [
"Returns",
"a",
"hash",
"of",
"the",
"concatenation",
"of",
"all",
"the",
"strings",
"in",
"strs",
"."
] | python | train |
intuition-io/intuition | intuition/api/portfolio.py | https://github.com/intuition-io/intuition/blob/cd517e6b3b315a743eb4d0d0dc294e264ab913ce/intuition/api/portfolio.py#L77-L84 | def update(self, portfolio, date, perfs=None):
'''
Actualizes the portfolio universe with the alog state
'''
# Make the manager aware of current simulation
self.portfolio = portfolio
self.perfs = perfs
self.date = date | [
"def",
"update",
"(",
"self",
",",
"portfolio",
",",
"date",
",",
"perfs",
"=",
"None",
")",
":",
"# Make the manager aware of current simulation",
"self",
".",
"portfolio",
"=",
"portfolio",
"self",
".",
"perfs",
"=",
"perfs",
"self",
".",
"date",
"=",
"dat... | Actualizes the portfolio universe with the alog state | [
"Actualizes",
"the",
"portfolio",
"universe",
"with",
"the",
"alog",
"state"
] | python | train |
neo4j/neo4j-python-driver | neo4j/types/temporal.py | https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/types/temporal.py#L80-L97 | def dehydrate_time(value):
""" Dehydrator for `time` values.
:param value:
:type value: Time
:return:
"""
if isinstance(value, Time):
nanoseconds = int(value.ticks * 1000000000)
elif isinstance(value, time):
nanoseconds = (3600000000000 * value.hour + 60000000000 * value.min... | [
"def",
"dehydrate_time",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"Time",
")",
":",
"nanoseconds",
"=",
"int",
"(",
"value",
".",
"ticks",
"*",
"1000000000",
")",
"elif",
"isinstance",
"(",
"value",
",",
"time",
")",
":",
"nanosec... | Dehydrator for `time` values.
:param value:
:type value: Time
:return: | [
"Dehydrator",
"for",
"time",
"values",
"."
] | python | train |
Nachtfeuer/pipeline | spline/tools/loader.py | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/loader.py#L32-L39 | def include(self, node):
"""Include the defined yaml file."""
result = None
if isinstance(node, ScalarNode):
result = Loader.include_file(self.construct_scalar(node))
else:
raise RuntimeError("Not supported !include on type %s" % type(node))
return result | [
"def",
"include",
"(",
"self",
",",
"node",
")",
":",
"result",
"=",
"None",
"if",
"isinstance",
"(",
"node",
",",
"ScalarNode",
")",
":",
"result",
"=",
"Loader",
".",
"include_file",
"(",
"self",
".",
"construct_scalar",
"(",
"node",
")",
")",
"else"... | Include the defined yaml file. | [
"Include",
"the",
"defined",
"yaml",
"file",
"."
] | python | train |
pyca/pyopenssl | src/OpenSSL/crypto.py | https://github.com/pyca/pyopenssl/blob/1fbe064c50fd030948141d7d630673761525b0d0/src/OpenSSL/crypto.py#L1071-L1081 | def to_cryptography(self):
"""
Export as a ``cryptography`` certificate.
:rtype: ``cryptography.x509.Certificate``
.. versionadded:: 17.1.0
"""
from cryptography.hazmat.backends.openssl.x509 import _Certificate
backend = _get_backend()
return _Certificat... | [
"def",
"to_cryptography",
"(",
"self",
")",
":",
"from",
"cryptography",
".",
"hazmat",
".",
"backends",
".",
"openssl",
".",
"x509",
"import",
"_Certificate",
"backend",
"=",
"_get_backend",
"(",
")",
"return",
"_Certificate",
"(",
"backend",
",",
"self",
"... | Export as a ``cryptography`` certificate.
:rtype: ``cryptography.x509.Certificate``
.. versionadded:: 17.1.0 | [
"Export",
"as",
"a",
"cryptography",
"certificate",
"."
] | python | test |
cds-astro/mocpy | mocpy/abstract_moc.py | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/abstract_moc.py#L410-L487 | def _to_str(uniq):
"""
Serializes a MOC to the STRING format.
HEALPix cells are separated by a comma. The HEALPix cell at order 0 and number 10 is encoded
by the string: "0/10", the first digit representing the depth and the second the HEALPix cell number
for this depth. HEALPix... | [
"def",
"_to_str",
"(",
"uniq",
")",
":",
"def",
"write_cells",
"(",
"serial",
",",
"a",
",",
"b",
",",
"sep",
"=",
"''",
")",
":",
"if",
"a",
"==",
"b",
":",
"serial",
"+=",
"'{0}{1}'",
".",
"format",
"(",
"a",
",",
"sep",
")",
"else",
":",
"... | Serializes a MOC to the STRING format.
HEALPix cells are separated by a comma. The HEALPix cell at order 0 and number 10 is encoded
by the string: "0/10", the first digit representing the depth and the second the HEALPix cell number
for this depth. HEALPix cells next to each other within a spec... | [
"Serializes",
"a",
"MOC",
"to",
"the",
"STRING",
"format",
"."
] | python | train |
hayd/pep8radius | pep8radius/vcs.py | https://github.com/hayd/pep8radius/blob/0c1d14835d390f7feeb602f35a768e52ce306a0a/pep8radius/vcs.py#L246-L256 | def parse_diff_filenames(diff_files):
"""Parse the output of filenames_diff_cmd."""
# ? .gitignore
# M 0.txt
files = []
for line in diff_files.splitlines():
line = line.strip()
fn = re.findall('[^ ]+\s+(.*.py)', line)
if fn and not line.star... | [
"def",
"parse_diff_filenames",
"(",
"diff_files",
")",
":",
"# ? .gitignore",
"# M 0.txt",
"files",
"=",
"[",
"]",
"for",
"line",
"in",
"diff_files",
".",
"splitlines",
"(",
")",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
"fn",
"=",
"re",
".",
... | Parse the output of filenames_diff_cmd. | [
"Parse",
"the",
"output",
"of",
"filenames_diff_cmd",
"."
] | python | train |
biocommons/bioutils | src/bioutils/cytobands.py | https://github.com/biocommons/bioutils/blob/88bcbdfa707268fed1110800e91b6d4f8e9475a0/src/bioutils/cytobands.py#L13-L23 | def get_cytoband_names():
"""Returns the names of available cytoband data files
>> get_cytoband_names()
['ucsc-hg38', 'ucsc-hg19']
"""
return [
n.replace(".json.gz", "")
for n in pkg_resources.resource_listdir(__name__, _data_dir)
if n.endswith(".json.gz")
] | [
"def",
"get_cytoband_names",
"(",
")",
":",
"return",
"[",
"n",
".",
"replace",
"(",
"\".json.gz\"",
",",
"\"\"",
")",
"for",
"n",
"in",
"pkg_resources",
".",
"resource_listdir",
"(",
"__name__",
",",
"_data_dir",
")",
"if",
"n",
".",
"endswith",
"(",
"\... | Returns the names of available cytoband data files
>> get_cytoband_names()
['ucsc-hg38', 'ucsc-hg19'] | [
"Returns",
"the",
"names",
"of",
"available",
"cytoband",
"data",
"files"
] | python | train |
Contraz/demosys-py | demosys/context/__init__.py | https://github.com/Contraz/demosys-py/blob/6466128a3029c4d09631420ccce73024025bd5b6/demosys/context/__init__.py#L23-L29 | def ctx() -> moderngl.Context:
"""ModernGL context"""
win = window()
if not win.ctx:
raise RuntimeError("Attempting to get context before creation")
return win.ctx | [
"def",
"ctx",
"(",
")",
"->",
"moderngl",
".",
"Context",
":",
"win",
"=",
"window",
"(",
")",
"if",
"not",
"win",
".",
"ctx",
":",
"raise",
"RuntimeError",
"(",
"\"Attempting to get context before creation\"",
")",
"return",
"win",
".",
"ctx"
] | ModernGL context | [
"ModernGL",
"context"
] | python | valid |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/IPython/core/completer.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/core/completer.py#L521-L602 | def file_matches(self, text):
"""Match filenames, expanding ~USER type strings.
Most of the seemingly convoluted logic in this completer is an
attempt to handle filenames with spaces in them. And yet it's not
quite perfect, because Python's readline doesn't expose all of the
GN... | [
"def",
"file_matches",
"(",
"self",
",",
"text",
")",
":",
"#io.rprint('Completer->file_matches: <%r>' % text) # dbg",
"# chars that require escaping with backslash - i.e. chars",
"# that readline treats incorrectly as delimiters, but we",
"# don't want to treat as delimiters in filename match... | Match filenames, expanding ~USER type strings.
Most of the seemingly convoluted logic in this completer is an
attempt to handle filenames with spaces in them. And yet it's not
quite perfect, because Python's readline doesn't expose all of the
GNU readline details needed for this to be ... | [
"Match",
"filenames",
"expanding",
"~USER",
"type",
"strings",
"."
] | python | test |
cirruscluster/cirruscluster | cirruscluster/core.py | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L500-L519 | def PrivateToPublicOpenSSH(key, host):
""" Computes the OpenSSH public key format given a private key. """
# Create public key from private key.
ssh_rsa = '00000007' + base64.b16encode('ssh-rsa')
# Exponent.
exponent = '%x' % (key.e,)
if len(exponent) % 2:
exponent = '0' + exponent
ssh_rsa += '%08x'... | [
"def",
"PrivateToPublicOpenSSH",
"(",
"key",
",",
"host",
")",
":",
"# Create public key from private key.",
"ssh_rsa",
"=",
"'00000007'",
"+",
"base64",
".",
"b16encode",
"(",
"'ssh-rsa'",
")",
"# Exponent.",
"exponent",
"=",
"'%x'",
"%",
"(",
"key",
".",
"e",
... | Computes the OpenSSH public key format given a private key. | [
"Computes",
"the",
"OpenSSH",
"public",
"key",
"format",
"given",
"a",
"private",
"key",
"."
] | python | train |
gamechanger/schemer | schemer/validators.py | https://github.com/gamechanger/schemer/blob/1d1dd7da433d3b84ce5a80ded5a84ab4a65825ee/schemer/validators.py#L8-L21 | def one_of(*args):
"""
Validates that a field value matches one of the values
given to this validator.
"""
if len(args) == 1 and isinstance(args[0], list):
items = args[0]
else:
items = list(args)
def validate(value):
if not value in items:
return e("{} i... | [
"def",
"one_of",
"(",
"*",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"1",
"and",
"isinstance",
"(",
"args",
"[",
"0",
"]",
",",
"list",
")",
":",
"items",
"=",
"args",
"[",
"0",
"]",
"else",
":",
"items",
"=",
"list",
"(",
"args"... | Validates that a field value matches one of the values
given to this validator. | [
"Validates",
"that",
"a",
"field",
"value",
"matches",
"one",
"of",
"the",
"values",
"given",
"to",
"this",
"validator",
"."
] | python | train |
ibm-watson-data-lab/ibmseti | ibmseti/features.py | https://github.com/ibm-watson-data-lab/ibmseti/blob/3361bc0adb4770dc7a554ed7cda292503892acee/ibmseti/features.py#L29-L60 | def difference(arr, n=1, axis=0, **kwargs):
'''
Assuming that `arr` is a 2D spectrogram returned by
ibmseti.dsp.raw_to_spectrogram(data), this function
uses the Numpy.diff function to calculate the nth
difference along either time or frequency.
If axis = 0 and n=1, then the first difference is taken
betw... | [
"def",
"difference",
"(",
"arr",
",",
"n",
"=",
"1",
",",
"axis",
"=",
"0",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"np",
".",
"diff",
"(",
"arr",
",",
"n",
"=",
"n",
",",
"axis",
"=",
"axis",
",",
"*",
"*",
"kwargs",
")"
] | Assuming that `arr` is a 2D spectrogram returned by
ibmseti.dsp.raw_to_spectrogram(data), this function
uses the Numpy.diff function to calculate the nth
difference along either time or frequency.
If axis = 0 and n=1, then the first difference is taken
between subsequent time samples
If axis = 1 and n=1, ... | [
"Assuming",
"that",
"arr",
"is",
"a",
"2D",
"spectrogram",
"returned",
"by",
"ibmseti",
".",
"dsp",
".",
"raw_to_spectrogram",
"(",
"data",
")",
"this",
"function",
"uses",
"the",
"Numpy",
".",
"diff",
"function",
"to",
"calculate",
"the",
"nth",
"difference... | python | train |
shazow/unstdlib.py | unstdlib/standard/string_.py | https://github.com/shazow/unstdlib.py/blob/e0632fe165cfbfdb5a7e4bc7b412c9d6f2ebad83/unstdlib/standard/string_.py#L420-L425 | def slugify(s, delimiter='-'):
"""
Normalize `s` into ASCII and replace non-word characters with `delimiter`.
"""
s = unicodedata.normalize('NFKD', to_unicode(s)).encode('ascii', 'ignore').decode('ascii')
return RE_SLUG.sub(delimiter, s).strip(delimiter).lower() | [
"def",
"slugify",
"(",
"s",
",",
"delimiter",
"=",
"'-'",
")",
":",
"s",
"=",
"unicodedata",
".",
"normalize",
"(",
"'NFKD'",
",",
"to_unicode",
"(",
"s",
")",
")",
".",
"encode",
"(",
"'ascii'",
",",
"'ignore'",
")",
".",
"decode",
"(",
"'ascii'",
... | Normalize `s` into ASCII and replace non-word characters with `delimiter`. | [
"Normalize",
"s",
"into",
"ASCII",
"and",
"replace",
"non",
"-",
"word",
"characters",
"with",
"delimiter",
"."
] | python | train |
AtmaHou/atma | Metrics.py | https://github.com/AtmaHou/atma/blob/41cd8ea9443a9c3b2dd71432f46f44a0f83093c7/Metrics.py#L102-L130 | def top_x_bleu(query_dic, mark, x=1):
"""
Calculate the top x average bleu value predictions ranking by item, x default is set above
:param query_dic: dict, key is qid, value is (item, bleu) tuple list, which will be ranked by 'item' as key
:param mark:string, which indicates which method is evaluat... | [
"def",
"top_x_bleu",
"(",
"query_dic",
",",
"mark",
",",
"x",
"=",
"1",
")",
":",
"all_total",
"=",
"0.0",
"with",
"open",
"(",
"top_bleu_path",
"+",
"mark",
",",
"'w'",
")",
"as",
"writer",
":",
"for",
"k",
"in",
"query_dic",
":",
"candidate_lst",
"... | Calculate the top x average bleu value predictions ranking by item, x default is set above
:param query_dic: dict, key is qid, value is (item, bleu) tuple list, which will be ranked by 'item' as key
:param mark:string, which indicates which method is evaluated, also used as output file name here.
:param ... | [
"Calculate",
"the",
"top",
"x",
"average",
"bleu",
"value",
"predictions",
"ranking",
"by",
"item",
"x",
"default",
"is",
"set",
"above",
":",
"param",
"query_dic",
":",
"dict",
"key",
"is",
"qid",
"value",
"is",
"(",
"item",
"bleu",
")",
"tuple",
"list"... | python | train |
monarch-initiative/dipper | dipper/models/Genotype.py | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/models/Genotype.py#L316-L332 | def addTaxon(self, taxon_id, genopart_id):
"""
The supplied geno part will have the specified taxon added with
RO:in_taxon relation.
Generally the taxon is associated with a genomic_background,
but could be added to any genotype part (including a gene,
regulatory element,... | [
"def",
"addTaxon",
"(",
"self",
",",
"taxon_id",
",",
"genopart_id",
")",
":",
"self",
".",
"graph",
".",
"addTriple",
"(",
"genopart_id",
",",
"self",
".",
"globaltt",
"[",
"'in taxon'",
"]",
",",
"taxon_id",
")",
"return"
] | The supplied geno part will have the specified taxon added with
RO:in_taxon relation.
Generally the taxon is associated with a genomic_background,
but could be added to any genotype part (including a gene,
regulatory element, or sequence alteration).
:param taxon_id:
:par... | [
"The",
"supplied",
"geno",
"part",
"will",
"have",
"the",
"specified",
"taxon",
"added",
"with",
"RO",
":",
"in_taxon",
"relation",
".",
"Generally",
"the",
"taxon",
"is",
"associated",
"with",
"a",
"genomic_background",
"but",
"could",
"be",
"added",
"to",
... | python | train |
docker/docker-py | docker/api/daemon.py | https://github.com/docker/docker-py/blob/613d6aad83acc9931ff2ecfd6a6c7bd8061dc125/docker/api/daemon.py#L168-L181 | def version(self, api_version=True):
"""
Returns version information from the server. Similar to the ``docker
version`` command.
Returns:
(dict): The server version information
Raises:
:py:class:`docker.errors.APIError`
If the server retu... | [
"def",
"version",
"(",
"self",
",",
"api_version",
"=",
"True",
")",
":",
"url",
"=",
"self",
".",
"_url",
"(",
"\"/version\"",
",",
"versioned_api",
"=",
"api_version",
")",
"return",
"self",
".",
"_result",
"(",
"self",
".",
"_get",
"(",
"url",
")",
... | Returns version information from the server. Similar to the ``docker
version`` command.
Returns:
(dict): The server version information
Raises:
:py:class:`docker.errors.APIError`
If the server returns an error. | [
"Returns",
"version",
"information",
"from",
"the",
"server",
".",
"Similar",
"to",
"the",
"docker",
"version",
"command",
"."
] | python | train |
appointlet/span | span/__init__.py | https://github.com/appointlet/span/blob/6d4f2920e45df827890ebe55b1c41b1f3414c0c9/span/__init__.py#L55-L62 | def rtouches(self, span):
"""
Returns true if the start of this span touches the right (ending) side of the given span.
"""
if isinstance(span, list):
return [sp for sp in span if self._rtouches(sp)]
return self._rtouches(span) | [
"def",
"rtouches",
"(",
"self",
",",
"span",
")",
":",
"if",
"isinstance",
"(",
"span",
",",
"list",
")",
":",
"return",
"[",
"sp",
"for",
"sp",
"in",
"span",
"if",
"self",
".",
"_rtouches",
"(",
"sp",
")",
"]",
"return",
"self",
".",
"_rtouches",
... | Returns true if the start of this span touches the right (ending) side of the given span. | [
"Returns",
"true",
"if",
"the",
"start",
"of",
"this",
"span",
"touches",
"the",
"right",
"(",
"ending",
")",
"side",
"of",
"the",
"given",
"span",
"."
] | python | train |
PSPC-SPAC-buyandsell/von_anchor | von_anchor/anchor/verifier.py | https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/verifier.py#L194-L317 | async def build_proof_req_json(self, cd_id2spec: dict) -> str:
"""
Build and return indy-sdk proof request for input attributes and non-revocation intervals by cred def id.
:param cd_id2spec: dict mapping cred def ids to:
- (optionally) 'attrs': lists of names of attributes of inte... | [
"async",
"def",
"build_proof_req_json",
"(",
"self",
",",
"cd_id2spec",
":",
"dict",
")",
"->",
"str",
":",
"LOGGER",
".",
"debug",
"(",
"'Verifier.build_proof_req_json >>> cd_id2spec: %s'",
",",
"cd_id2spec",
")",
"cd_id2schema",
"=",
"{",
"}",
"now",
"=",
"int... | Build and return indy-sdk proof request for input attributes and non-revocation intervals by cred def id.
:param cd_id2spec: dict mapping cred def ids to:
- (optionally) 'attrs': lists of names of attributes of interest (omit for all, empty list or None for none)
- (optionally) '>=': (... | [
"Build",
"and",
"return",
"indy",
"-",
"sdk",
"proof",
"request",
"for",
"input",
"attributes",
"and",
"non",
"-",
"revocation",
"intervals",
"by",
"cred",
"def",
"id",
"."
] | python | train |
jay-johnson/antinex-client | antinex_client/ai_client.py | https://github.com/jay-johnson/antinex-client/blob/850ba2a2fe21c836e071def618dcecc9caf5d59c/antinex_client/ai_client.py#L121-L186 | def login(
self):
"""login"""
auth_url = self.api_urls["login"]
if self.verbose:
log.info(("log in user={} url={} ca_dir={} cert={}")
.format(
self.user,
auth_url,
self.ca_dir,
... | [
"def",
"login",
"(",
"self",
")",
":",
"auth_url",
"=",
"self",
".",
"api_urls",
"[",
"\"login\"",
"]",
"if",
"self",
".",
"verbose",
":",
"log",
".",
"info",
"(",
"(",
"\"log in user={} url={} ca_dir={} cert={}\"",
")",
".",
"format",
"(",
"self",
".",
... | login | [
"login"
] | python | train |
mrsarm/mongotail | mongotail/conn.py | https://github.com/mrsarm/mongotail/blob/82ba74e32eff92faa320833a8d19c58555f9cd49/mongotail/conn.py#L31-L78 | def connect(address, args):
"""
Connect with `address`, and return a tuple with a :class:`~pymongo.MongoClient`,
and a :class:`~pymongo.database.Database` object.
:param address: a string representation with the db address
:param args: connection arguments:
- username: username for authenticatio... | [
"def",
"connect",
"(",
"address",
",",
"args",
")",
":",
"try",
":",
"host",
",",
"port",
",",
"dbname",
"=",
"get_res_address",
"(",
"address",
")",
"except",
"AddressError",
"as",
"e",
":",
"error_parsing",
"(",
"str",
"(",
"e",
")",
".",
"replace",
... | Connect with `address`, and return a tuple with a :class:`~pymongo.MongoClient`,
and a :class:`~pymongo.database.Database` object.
:param address: a string representation with the db address
:param args: connection arguments:
- username: username for authentication (optional)
- password: password fo... | [
"Connect",
"with",
"address",
"and",
"return",
"a",
"tuple",
"with",
"a",
":",
"class",
":",
"~pymongo",
".",
"MongoClient",
"and",
"a",
":",
"class",
":",
"~pymongo",
".",
"database",
".",
"Database",
"object",
".",
":",
"param",
"address",
":",
"a",
... | python | test |
robmarkcole/HASS-data-detective | detective/auth.py | https://github.com/robmarkcole/HASS-data-detective/blob/f67dfde9dd63a3af411944d1857b0835632617c5/detective/auth.py#L35-L42 | def user_name(self, user_id):
"""Return name for user."""
user = self.users.get(user_id)
if user is None:
return "Unknown user ({})".format(user_id)
return user["name"] | [
"def",
"user_name",
"(",
"self",
",",
"user_id",
")",
":",
"user",
"=",
"self",
".",
"users",
".",
"get",
"(",
"user_id",
")",
"if",
"user",
"is",
"None",
":",
"return",
"\"Unknown user ({})\"",
".",
"format",
"(",
"user_id",
")",
"return",
"user",
"["... | Return name for user. | [
"Return",
"name",
"for",
"user",
"."
] | python | train |
tensorflow/probability | tensorflow_probability/python/layers/distribution_layer.py | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/layers/distribution_layer.py#L732-L751 | def get_config(self):
"""Returns the config of this layer.
NOTE: At the moment, this configuration can only be serialized if the
Layer's `convert_to_tensor_fn` is a serializable Keras object (i.e.,
implements `get_config`) or one of the standard values:
- `Distribution.sample` (or `"sample"`)
... | [
"def",
"get_config",
"(",
"self",
")",
":",
"config",
"=",
"{",
"'event_shape'",
":",
"self",
".",
"_event_shape",
",",
"'convert_to_tensor_fn'",
":",
"_serialize",
"(",
"self",
".",
"_convert_to_tensor_fn",
")",
",",
"'sample_dtype'",
":",
"self",
".",
"_samp... | Returns the config of this layer.
NOTE: At the moment, this configuration can only be serialized if the
Layer's `convert_to_tensor_fn` is a serializable Keras object (i.e.,
implements `get_config`) or one of the standard values:
- `Distribution.sample` (or `"sample"`)
- `Distribution.mean` (or `"... | [
"Returns",
"the",
"config",
"of",
"this",
"layer",
"."
] | python | test |
dopefishh/pympi | pympi/Elan.py | https://github.com/dopefishh/pympi/blob/79c747cde45b5ba203ed93154d8c123ac9c3ef56/pympi/Elan.py#L514-L524 | def generate_annotation_id(self):
"""Generate the next annotation id, this function is mainly used
internally.
"""
if not self.maxaid:
valid_anns = [int(''.join(filter(str.isdigit, a)))
for a in self.timeslots]
self.maxaid = max(valid_ann... | [
"def",
"generate_annotation_id",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"maxaid",
":",
"valid_anns",
"=",
"[",
"int",
"(",
"''",
".",
"join",
"(",
"filter",
"(",
"str",
".",
"isdigit",
",",
"a",
")",
")",
")",
"for",
"a",
"in",
"self",
... | Generate the next annotation id, this function is mainly used
internally. | [
"Generate",
"the",
"next",
"annotation",
"id",
"this",
"function",
"is",
"mainly",
"used",
"internally",
"."
] | python | test |
EntilZha/PyFunctional | functional/transformations.py | https://github.com/EntilZha/PyFunctional/blob/ac04e4a8552b0c464a7f492f7c9862424867b63e/functional/transformations.py#L320-L331 | def cartesian_t(iterables, repeat):
"""
Transformation for Sequence.cartesian
:param iterables: elements for cartesian product
:param repeat: how many times to repeat iterables
:return: transformation
"""
return Transformation(
'cartesian',
lambda sequence: product(sequence, ... | [
"def",
"cartesian_t",
"(",
"iterables",
",",
"repeat",
")",
":",
"return",
"Transformation",
"(",
"'cartesian'",
",",
"lambda",
"sequence",
":",
"product",
"(",
"sequence",
",",
"*",
"iterables",
",",
"repeat",
"=",
"repeat",
")",
",",
"None",
")"
] | Transformation for Sequence.cartesian
:param iterables: elements for cartesian product
:param repeat: how many times to repeat iterables
:return: transformation | [
"Transformation",
"for",
"Sequence",
".",
"cartesian",
":",
"param",
"iterables",
":",
"elements",
"for",
"cartesian",
"product",
":",
"param",
"repeat",
":",
"how",
"many",
"times",
"to",
"repeat",
"iterables",
":",
"return",
":",
"transformation"
] | python | train |
coldfix/udiskie | udiskie/udisks2.py | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/udisks2.py#L532-L540 | def set_autoclear(self, value, auth_no_user_interaction=None):
"""Set autoclear flag for loop partition."""
return self._M.Loop.SetAutoclear(
'(ba{sv})',
value,
filter_opt({
'auth.no_user_interaction': ('b', auth_no_user_interaction),
})
... | [
"def",
"set_autoclear",
"(",
"self",
",",
"value",
",",
"auth_no_user_interaction",
"=",
"None",
")",
":",
"return",
"self",
".",
"_M",
".",
"Loop",
".",
"SetAutoclear",
"(",
"'(ba{sv})'",
",",
"value",
",",
"filter_opt",
"(",
"{",
"'auth.no_user_interaction'"... | Set autoclear flag for loop partition. | [
"Set",
"autoclear",
"flag",
"for",
"loop",
"partition",
"."
] | python | train |
datosgobar/pydatajson | pydatajson/readers.py | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/readers.py#L286-L318 | def _get_dataset_index(catalog, dataset_identifier, dataset_title,
logger=None):
"""Devuelve el índice de un dataset en el catálogo en función de su
identificador"""
logger = logger or pydj_logger
matching_datasets = []
for idx, dataset in enumerate(catalog["catalog_dataset"]... | [
"def",
"_get_dataset_index",
"(",
"catalog",
",",
"dataset_identifier",
",",
"dataset_title",
",",
"logger",
"=",
"None",
")",
":",
"logger",
"=",
"logger",
"or",
"pydj_logger",
"matching_datasets",
"=",
"[",
"]",
"for",
"idx",
",",
"dataset",
"in",
"enumerate... | Devuelve el índice de un dataset en el catálogo en función de su
identificador | [
"Devuelve",
"el",
"índice",
"de",
"un",
"dataset",
"en",
"el",
"catálogo",
"en",
"función",
"de",
"su",
"identificador"
] | python | train |
tensorflow/tensor2tensor | tensor2tensor/visualization/visualization.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/visualization/visualization.py#L159-L205 | def get_att_mats(translate_model):
"""Get's the tensors representing the attentions from a build model.
The attentions are stored in a dict on the Transformer object while building
the graph.
Args:
translate_model: Transformer object to fetch the attention weights from.
Returns:
Tuple of attention ma... | [
"def",
"get_att_mats",
"(",
"translate_model",
")",
":",
"enc_atts",
"=",
"[",
"]",
"dec_atts",
"=",
"[",
"]",
"encdec_atts",
"=",
"[",
"]",
"prefix",
"=",
"\"transformer/body/\"",
"postfix_self_attention",
"=",
"\"/multihead_attention/dot_product_attention\"",
"if",
... | Get's the tensors representing the attentions from a build model.
The attentions are stored in a dict on the Transformer object while building
the graph.
Args:
translate_model: Transformer object to fetch the attention weights from.
Returns:
Tuple of attention matrices; (
enc_atts: Encoder self a... | [
"Get",
"s",
"the",
"tensors",
"representing",
"the",
"attentions",
"from",
"a",
"build",
"model",
"."
] | python | train |
linkedin/Zopkio | zopkio/adhoc_deployer.py | https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/adhoc_deployer.py#L264-L306 | def stop(self, unique_id, configs=None):
"""Stop the service. If the deployer has not started a service with`unique_id` the deployer will raise an Exception
There are two configs that will be considered:
'terminate_only': if this config is passed in then this method is the same as terminate(unique_id) (thi... | [
"def",
"stop",
"(",
"self",
",",
"unique_id",
",",
"configs",
"=",
"None",
")",
":",
"# the following is necessay to set the configs for this function as the combination of the",
"# default configurations and the parameter with the parameter superceding the defaults but",
"# not modifyin... | Stop the service. If the deployer has not started a service with`unique_id` the deployer will raise an Exception
There are two configs that will be considered:
'terminate_only': if this config is passed in then this method is the same as terminate(unique_id) (this is also the
behavior if stop_command is No... | [
"Stop",
"the",
"service",
".",
"If",
"the",
"deployer",
"has",
"not",
"started",
"a",
"service",
"with",
"unique_id",
"the",
"deployer",
"will",
"raise",
"an",
"Exception",
"There",
"are",
"two",
"configs",
"that",
"will",
"be",
"considered",
":",
"terminate... | python | train |
stitchfix/pyxley | examples/metricsgraphics/project/buildui.py | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/examples/metricsgraphics/project/buildui.py#L23-L35 | def create_histogram(df):
""" create a mg line plot
Args:
df (pandas.DataFrame): data to plot
"""
fig = Figure("/mg/histogram/", "mg_histogram")
fig.layout.set_size(width=450, height=200)
fig.layout.set_margin(left=40, right=40)
fig.graphics.animate_on_load()
# Make a h... | [
"def",
"create_histogram",
"(",
"df",
")",
":",
"fig",
"=",
"Figure",
"(",
"\"/mg/histogram/\"",
",",
"\"mg_histogram\"",
")",
"fig",
".",
"layout",
".",
"set_size",
"(",
"width",
"=",
"450",
",",
"height",
"=",
"200",
")",
"fig",
".",
"layout",
".",
"... | create a mg line plot
Args:
df (pandas.DataFrame): data to plot | [
"create",
"a",
"mg",
"line",
"plot"
] | python | train |
ziwenxie/netease-dl | netease/logger.py | https://github.com/ziwenxie/netease-dl/blob/84b226fc07b10f7f66580f0fc69f10356f66b5c3/netease/logger.py#L24-L38 | def get_logger(name):
"""Return a logger with a file handler."""
logger = logging.getLogger(name)
logger.setLevel(logging.INFO)
# File output handler
file_handler = logging.FileHandler(log_path)
file_handler.setLevel(logging.INFO)
formatter = logging.Formatter(
'%(asctime)s %(name)1... | [
"def",
"get_logger",
"(",
"name",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"name",
")",
"logger",
".",
"setLevel",
"(",
"logging",
".",
"INFO",
")",
"# File output handler",
"file_handler",
"=",
"logging",
".",
"FileHandler",
"(",
"log_path... | Return a logger with a file handler. | [
"Return",
"a",
"logger",
"with",
"a",
"file",
"handler",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.