text stringlengths 75 104k | code_tokens list | avg_line_len float64 7.91 980 | score float64 0 0.18 |
|---|---|---|---|
def copy_func(dest, src, symlinks=True):
"""
If symlinks (is true), then a symbolic link will be
shallow copied and recreated as a symbolic link; otherwise, copying
a symbolic link will be equivalent to copying the symbolic link's
final target regardless of symbolic link depth.
"""
dest = s... | [
"def",
"copy_func",
"(",
"dest",
",",
"src",
",",
"symlinks",
"=",
"True",
")",
":",
"dest",
"=",
"str",
"(",
"dest",
")",
"src",
"=",
"str",
"(",
"src",
")",
"SCons",
".",
"Node",
".",
"FS",
".",
"invalidate_node_memos",
"(",
"dest",
")",
"if",
... | 33.965517 | 0.000987 |
def load_qt(api_options):
"""
Attempt to import Qt, given a preference list
of permissible bindings
It is safe to call this function multiple times.
Parameters
----------
api_options: List of strings
The order of APIs to try. Valid items are 'pyside',
'pyqt', and 'pyqtv1'
... | [
"def",
"load_qt",
"(",
"api_options",
")",
":",
"loaders",
"=",
"{",
"QT_API_PYSIDE",
":",
"import_pyside",
",",
"QT_API_PYQT",
":",
"import_pyqt4",
",",
"QT_API_PYQTv1",
":",
"partial",
"(",
"import_pyqt4",
",",
"version",
"=",
"1",
")",
",",
"QT_API_PYQT_DEF... | 31.2 | 0.000956 |
def attendee_list(request):
''' Returns a list of all attendees. '''
attendees = people.Attendee.objects.select_related(
"attendeeprofilebase",
"user",
)
profiles = AttendeeProfile.objects.filter(
attendee__in=attendees
).select_related(
"attendee", "attendee__user"... | [
"def",
"attendee_list",
"(",
"request",
")",
":",
"attendees",
"=",
"people",
".",
"Attendee",
".",
"objects",
".",
"select_related",
"(",
"\"attendeeprofilebase\"",
",",
"\"user\"",
",",
")",
"profiles",
"=",
"AttendeeProfile",
".",
"objects",
".",
"filter",
... | 25.55 | 0.000943 |
def cublasDtrsm(handle, side, uplo, trans, diag, m, n, alpha, A, lda, B, ldb):
"""
Solve a real triangular system with multiple right-hand sides.
"""
status = _libcublas.cublasDtrsm_v2(handle,
_CUBLAS_SIDE_MODE[side],
... | [
"def",
"cublasDtrsm",
"(",
"handle",
",",
"side",
",",
"uplo",
",",
"trans",
",",
"diag",
",",
"m",
",",
"n",
",",
"alpha",
",",
"A",
",",
"lda",
",",
"B",
",",
"ldb",
")",
":",
"status",
"=",
"_libcublas",
".",
"cublasDtrsm_v2",
"(",
"handle",
"... | 44.928571 | 0.012461 |
def geckoboard_pie_chart(request):
"""
Shows a pie chart of the metrics in the uids[] GET variable array.
"""
params = get_gecko_params(request, cumulative=True)
from_date = datetime.now()-timedelta(days=params['days_back'])
metrics = Metric.objects.filter(uid__in=params['uids'])
results =... | [
"def",
"geckoboard_pie_chart",
"(",
"request",
")",
":",
"params",
"=",
"get_gecko_params",
"(",
"request",
",",
"cumulative",
"=",
"True",
")",
"from_date",
"=",
"datetime",
".",
"now",
"(",
")",
"-",
"timedelta",
"(",
"days",
"=",
"params",
"[",
"'days_b... | 40.153846 | 0.009363 |
def serializeG1(x, compress=True):
"""
Converts G1 element @x into an array of bytes. If @compress is True,
the point will be compressed resulting in a much shorter string of bytes.
"""
assertType(x, G1Element)
return _serialize(x, compress, librelic.g1_size_bin_abi,
librelic.g1_write_b... | [
"def",
"serializeG1",
"(",
"x",
",",
"compress",
"=",
"True",
")",
":",
"assertType",
"(",
"x",
",",
"G1Element",
")",
"return",
"_serialize",
"(",
"x",
",",
"compress",
",",
"librelic",
".",
"g1_size_bin_abi",
",",
"librelic",
".",
"g1_write_bin_abi",
")"... | 40 | 0.009174 |
def get_flagged_args():
"""get_flagged_args
Collects from the execution statement the arguments provided to this script.
The items are then interpretted and returned. The object expected are the
KvP's:
--os_type - the operating system type to be built
--os_version - the operating system version to be buil... | [
"def",
"get_flagged_args",
"(",
")",
":",
"expected",
"=",
"[",
"'os_type'",
",",
"'os_version'",
"]",
"arguments",
"=",
"{",
"}",
"try",
":",
"opts",
",",
"adds",
"=",
"getopt",
".",
"getopt",
"(",
"sys",
".",
"argv",
",",
"''",
",",
"map",
"(",
"... | 39.5 | 0.000618 |
def fit_glx(self, reject_outliers=3.0, fit_lb=3.6, fit_ub=3.9,
fit_func=None):
"""
Fit a Gaussian function to the Glu/Gln (GLX) peak at 3.75ppm, +/-
0.15ppm [Hurd2004]_. Compare this model to a model
that treats the Glx signal as two gaussian peaks. Glx signal
a... | [
"def",
"fit_glx",
"(",
"self",
",",
"reject_outliers",
"=",
"3.0",
",",
"fit_lb",
"=",
"3.6",
",",
"fit_ub",
"=",
"3.9",
",",
"fit_func",
"=",
"None",
")",
":",
"# Use everything:",
"fit_spectra",
"=",
"self",
".",
"diff_spectra",
".",
"copy",
"(",
")",
... | 39.416667 | 0.002063 |
def hash(self, id):
""" Creates a unique filename in the cache for the id.
"""
h = md5(id).hexdigest()
return os.path.join(self.path, h+self.type) | [
"def",
"hash",
"(",
"self",
",",
"id",
")",
":",
"h",
"=",
"md5",
"(",
"id",
")",
".",
"hexdigest",
"(",
")",
"return",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"path",
",",
"h",
"+",
"self",
".",
"type",
")"
] | 24.857143 | 0.011111 |
def _check_out_arg(func):
"""Check if ``func`` has an (optional) ``out`` argument.
Also verify that the signature of ``func`` has no ``*args`` since
they make argument propagation a hassle.
Parameters
----------
func : callable
Object that should be inspected.
Returns
-------
... | [
"def",
"_check_out_arg",
"(",
"func",
")",
":",
"if",
"sys",
".",
"version_info",
".",
"major",
">",
"2",
":",
"spec",
"=",
"inspect",
".",
"getfullargspec",
"(",
"func",
")",
"kw_only",
"=",
"spec",
".",
"kwonlyargs",
"else",
":",
"spec",
"=",
"inspec... | 27.183673 | 0.000725 |
def build(self, ignore=None):
'''Calls all necessary methods to build the Lambda Package'''
self._prepare_workspace()
self.install_dependencies()
self.package(ignore) | [
"def",
"build",
"(",
"self",
",",
"ignore",
"=",
"None",
")",
":",
"self",
".",
"_prepare_workspace",
"(",
")",
"self",
".",
"install_dependencies",
"(",
")",
"self",
".",
"package",
"(",
"ignore",
")"
] | 38.8 | 0.010101 |
def put_event_multi_touch(self, count, contacts, scan_time):
"""Sends a multi-touch pointer event. The coordinates are expressed in
pixels and start from [1,1] which corresponds to the top left
corner of the virtual display.
The guest may not understan... | [
"def",
"put_event_multi_touch",
"(",
"self",
",",
"count",
",",
"contacts",
",",
"scan_time",
")",
":",
"if",
"not",
"isinstance",
"(",
"count",
",",
"baseinteger",
")",
":",
"raise",
"TypeError",
"(",
"\"count can only be an instance of type baseinteger\"",
")",
... | 42.085106 | 0.008399 |
def factorize(
self,
na_sentinel: int = -1,
) -> Tuple[np.ndarray, ABCExtensionArray]:
"""
Encode the extension array as an enumerated type.
Parameters
----------
na_sentinel : int, default -1
Value to use in the `labels` array to indicate... | [
"def",
"factorize",
"(",
"self",
",",
"na_sentinel",
":",
"int",
"=",
"-",
"1",
",",
")",
"->",
"Tuple",
"[",
"np",
".",
"ndarray",
",",
"ABCExtensionArray",
"]",
":",
"# Impelmentor note: There are two ways to override the behavior of",
"# pandas.factorize",
"# 1. ... | 33.843137 | 0.001689 |
def _compute_global_interested_rts(self):
"""Computes current global interested RTs for global tables.
Computes interested RTs based on current RT filters for peers. This
filter should be used to check if for RTs on a path that is installed
in any global table (expect RT Table).
... | [
"def",
"_compute_global_interested_rts",
"(",
"self",
")",
":",
"interested_rts",
"=",
"set",
"(",
")",
"for",
"rtfilter",
"in",
"self",
".",
"_peer_to_rtfilter_map",
".",
"values",
"(",
")",
":",
"interested_rts",
".",
"update",
"(",
"rtfilter",
")",
"interes... | 47.764706 | 0.002415 |
def apply_rectwv_coeff(reduced_image,
rectwv_coeff,
args_resampling=2,
args_ignore_dtu_configuration=True,
debugplot=0):
"""Compute rectification and wavelength calibration coefficients.
Parameters
----------
re... | [
"def",
"apply_rectwv_coeff",
"(",
"reduced_image",
",",
"rectwv_coeff",
",",
"args_resampling",
"=",
"2",
",",
"args_ignore_dtu_configuration",
"=",
"True",
",",
"debugplot",
"=",
"0",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
... | 38.588496 | 0.000112 |
def compile_file(fullpath, outfile_name, compiler_args):
"""Calls HamlPy compiler."""
if Options.VERBOSE:
print '%s %s -> %s' % (strftime("%H:%M:%S"), fullpath, outfile_name)
try:
if Options.DEBUG:
print "Compiling %s -> %s" % (fullpath, outfile_name)
haml_lines = codecs.... | [
"def",
"compile_file",
"(",
"fullpath",
",",
"outfile_name",
",",
"compiler_args",
")",
":",
"if",
"Options",
".",
"VERBOSE",
":",
"print",
"'%s %s -> %s'",
"%",
"(",
"strftime",
"(",
"\"%H:%M:%S\"",
")",
",",
"fullpath",
",",
"outfile_name",
")",
"try",
":"... | 46.933333 | 0.009749 |
def write_connection_file(self):
"""write connection info to JSON file"""
if os.path.basename(self.connection_file) == self.connection_file:
cf = os.path.join(self.profile_dir.security_dir, self.connection_file)
else:
cf = self.connection_file
write_connection_fil... | [
"def",
"write_connection_file",
"(",
"self",
")",
":",
"if",
"os",
".",
"path",
".",
"basename",
"(",
"self",
".",
"connection_file",
")",
"==",
"self",
".",
"connection_file",
":",
"cf",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"profile_... | 47.272727 | 0.013208 |
def demo(context):
"""Setup a scout demo instance. This instance will be populated with a
case, a gene panel and some variants.
"""
LOG.info("Running scout setup demo")
institute_name = context.obj['institute_name']
user_name = context.obj['user_name']
user_mail = context.obj['user_mail']... | [
"def",
"demo",
"(",
"context",
")",
":",
"LOG",
".",
"info",
"(",
"\"Running scout setup demo\"",
")",
"institute_name",
"=",
"context",
".",
"obj",
"[",
"'institute_name'",
"]",
"user_name",
"=",
"context",
".",
"obj",
"[",
"'user_name'",
"]",
"user_mail",
... | 28.7 | 0.011804 |
def rlecode_hqx(s):
"""
Run length encoding for binhex4.
The CPython implementation does not do run length encoding
of \x90 characters. This implementation does.
"""
if not s:
return ''
result = []
prev = s[0]
count = 1
# Add a dummy character to get the loop to go one ex... | [
"def",
"rlecode_hqx",
"(",
"s",
")",
":",
"if",
"not",
"s",
":",
"return",
"''",
"result",
"=",
"[",
"]",
"prev",
"=",
"s",
"[",
"0",
"]",
"count",
"=",
"1",
"# Add a dummy character to get the loop to go one extra round.",
"# The dummy must be different from the ... | 29.023256 | 0.000775 |
def weight_layers(name, bilm_ops, l2_coef=None,
use_top_only=False, do_layer_norm=False, reuse=False):
"""
Weight the layers of a biLM with trainable scalar weights to
compute ELMo representations.
For each output layer, this returns two ops. The first computes
a layer specif... | [
"def",
"weight_layers",
"(",
"name",
",",
"bilm_ops",
",",
"l2_coef",
"=",
"None",
",",
"use_top_only",
"=",
"False",
",",
"do_layer_norm",
"=",
"False",
",",
"reuse",
"=",
"False",
")",
":",
"def",
"_l2_regularizer",
"(",
"weights",
")",
":",
"if",
"l2_... | 37.795455 | 0.001172 |
def generate_mediation_matrix(dsm):
"""
Generate the mediation matrix of the given matrix.
Rules for mediation matrix generation:
Set -1 for items NOT to be considered
Set 0 for items which MUST NOT be present
Set 1 for items which MUST be present
Each module h... | [
"def",
"generate_mediation_matrix",
"(",
"dsm",
")",
":",
"cat",
"=",
"dsm",
".",
"categories",
"ent",
"=",
"dsm",
".",
"entities",
"size",
"=",
"dsm",
".",
"size",
"[",
"0",
"]",
"if",
"not",
"cat",
":",
"cat",
"=",
"[",
"'appmodule'",
"]",
"*",
"... | 42.387755 | 0.00047 |
def get_request_parameters(self, request_body_type="", method="",
authn_method='', request_args=None,
http_args=None, **kwargs):
"""
Builds the request message and constructs the HTTP headers.
This is the starting point for a pipelin... | [
"def",
"get_request_parameters",
"(",
"self",
",",
"request_body_type",
"=",
"\"\"",
",",
"method",
"=",
"\"\"",
",",
"authn_method",
"=",
"''",
",",
"request_args",
"=",
"None",
",",
"http_args",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"no... | 38.628571 | 0.001442 |
def _set_static_ip(name, session, vm_):
'''
Set static IP during create() if defined
'''
ipv4_cidr = ''
ipv4_gw = ''
if 'ipv4_gw' in vm_.keys():
log.debug('ipv4_gw is found in keys')
ipv4_gw = vm_['ipv4_gw']
if 'ipv4_cidr' in vm_.keys():
log.debug('ipv4_cidr is found ... | [
"def",
"_set_static_ip",
"(",
"name",
",",
"session",
",",
"vm_",
")",
":",
"ipv4_cidr",
"=",
"''",
"ipv4_gw",
"=",
"''",
"if",
"'ipv4_gw'",
"in",
"vm_",
".",
"keys",
"(",
")",
":",
"log",
".",
"debug",
"(",
"'ipv4_gw is found in keys'",
")",
"ipv4_gw",
... | 33.285714 | 0.002088 |
def _get(self, **kwargs):
"""Get the resource from a remote Transifex server."""
path = self._construct_path_to_item()
return self._http.get(path) | [
"def",
"_get",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"path",
"=",
"self",
".",
"_construct_path_to_item",
"(",
")",
"return",
"self",
".",
"_http",
".",
"get",
"(",
"path",
")"
] | 41.75 | 0.011765 |
def merge_checkpoint(input_graph,
checkpoint,
output_node_names,
output_graph,
sess):
"""
Get the variable values from the checkpoint file, and merge them to the GraphDef file
Args:
input_graph: the GraphDef file, do... | [
"def",
"merge_checkpoint",
"(",
"input_graph",
",",
"checkpoint",
",",
"output_node_names",
",",
"output_graph",
",",
"sess",
")",
":",
"restore_op_name",
"=",
"\"save/restore_all\"",
"filename_tensor_name",
"=",
"\"save/Const:0\"",
"input_graph_def",
"=",
"graph_pb2",
... | 34.027778 | 0.001587 |
def exception(self, timeout=None):
"""Return a exception raised by the call that the future
represents.
:param timeout: The number of seconds to wait for the exception
if the future has not been completed. None, the default,
sets no limit.
:returns: The exception ... | [
"def",
"exception",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"with",
"self",
".",
"__condition",
":",
"if",
"self",
".",
"__state",
"==",
"FINISHED",
":",
"return",
"self",
".",
"__exception",
"lock",
"=",
"get_lock",
"(",
")",
"if",
"lock",... | 38.192308 | 0.001965 |
def set_direct(self, address_value_dict):
"""Called in the context manager's set method to either overwrite the
value for an address, or create a new future and immediately set a
value in the future.
Args:
address_value_dict (dict of str:bytes): The unique full addresses
... | [
"def",
"set_direct",
"(",
"self",
",",
"address_value_dict",
")",
":",
"with",
"self",
".",
"_lock",
":",
"for",
"address",
",",
"value",
"in",
"address_value_dict",
".",
"items",
"(",
")",
":",
"self",
".",
"_validate_write",
"(",
"address",
")",
"if",
... | 37.681818 | 0.002353 |
def main():
"""
The main function of the Andes command-line tool.
This function executes the following workflow:
* Parse the command line inputs
* Show the tool preamble
* Output the requested helps, edit/save configs or remove outputs. Exit
the main program if any of the above is ex... | [
"def",
"main",
"(",
")",
":",
"t0",
",",
"s",
"=",
"elapsed",
"(",
")",
"# parser command line arguments",
"args",
"=",
"vars",
"(",
"cli_new",
"(",
")",
")",
"# configure stream handler verbose level",
"config_logger",
"(",
"log_path",
"=",
"misc",
".",
"get_... | 29.027778 | 0.000925 |
def trans_coeff(eq, x, y, z):
"""This function is provided by MOKA2 Development Team (1996.xx.xx)
and used in SOSS system."""
tt = (eq - 2000.0) / 100.0
zeta = 2306.2181 * tt + 0.30188 * tt * tt + 0.017998 * tt * tt * tt
zetto = 2306.2181 * tt + 1.09468 * tt * tt + 0.018203 * tt * tt * tt
theta... | [
"def",
"trans_coeff",
"(",
"eq",
",",
"x",
",",
"y",
",",
"z",
")",
":",
"tt",
"=",
"(",
"eq",
"-",
"2000.0",
")",
"/",
"100.0",
"zeta",
"=",
"2306.2181",
"*",
"tt",
"+",
"0.30188",
"*",
"tt",
"*",
"tt",
"+",
"0.017998",
"*",
"tt",
"*",
"tt",... | 42.071429 | 0.00083 |
def get_bios_settings(irmc_info):
"""Get the current BIOS settings on the server
:param irmc_info: node info.
:returns: a list of dictionary BIOS settings
"""
bios_config = backup_bios_config(irmc_info)['bios_config']
bios_config_data = bios_config['Server']['SystemConfig']['BiosConfig']
s... | [
"def",
"get_bios_settings",
"(",
"irmc_info",
")",
":",
"bios_config",
"=",
"backup_bios_config",
"(",
"irmc_info",
")",
"[",
"'bios_config'",
"]",
"bios_config_data",
"=",
"bios_config",
"[",
"'Server'",
"]",
"[",
"'SystemConfig'",
"]",
"[",
"'BiosConfig'",
"]",
... | 40.263158 | 0.001277 |
def _load_commands(root):
"""Returns {name: Command}"""
def proto_text(t):
if t.tag == 'name':
return '{name}'
elif t.tag == 'ptype':
return '{type}'
out = []
if t.text:
out.append(_escape_tpl_str(t.text))
for x in t:
out.ap... | [
"def",
"_load_commands",
"(",
"root",
")",
":",
"def",
"proto_text",
"(",
"t",
")",
":",
"if",
"t",
".",
"tag",
"==",
"'name'",
":",
"return",
"'{name}'",
"elif",
"t",
".",
"tag",
"==",
"'ptype'",
":",
"return",
"'{type}'",
"out",
"=",
"[",
"]",
"i... | 37 | 0.001054 |
def read_feather(path, columns=None, use_threads=True):
"""
Load a feather-format object from the file path
.. versionadded 0.20.0
Parameters
----------
path : string file path, or file-like object
columns : sequence, default None
If not provided, all columns are read
.. v... | [
"def",
"read_feather",
"(",
"path",
",",
"columns",
"=",
"None",
",",
"use_threads",
"=",
"True",
")",
":",
"feather",
",",
"pyarrow",
"=",
"_try_import",
"(",
")",
"path",
"=",
"_stringify_path",
"(",
"path",
")",
"if",
"LooseVersion",
"(",
"pyarrow",
"... | 28.525 | 0.000847 |
def get_as_map_with_default(self, key, default_value):
"""
Converts map element into an AnyValueMap or returns default value if conversion is not possible.
:param key: a key of element to get.
:param default_value: the default value
:return: AnyValueMap value of the element or... | [
"def",
"get_as_map_with_default",
"(",
"self",
",",
"key",
",",
"default_value",
")",
":",
"value",
"=",
"self",
".",
"get_as_nullable_map",
"(",
"key",
")",
"return",
"MapConverter",
".",
"to_map_with_default",
"(",
"value",
",",
"default_value",
")"
] | 40.25 | 0.008097 |
def multi_bulk(self, args):
'''Multi bulk encoding for list/tuple ``args``
'''
return null_array if args is None else b''.join(self._pack(args)) | [
"def",
"multi_bulk",
"(",
"self",
",",
"args",
")",
":",
"return",
"null_array",
"if",
"args",
"is",
"None",
"else",
"b''",
".",
"join",
"(",
"self",
".",
"_pack",
"(",
"args",
")",
")"
] | 41.25 | 0.011905 |
def get_koji_module_build(session, module_spec):
"""
Get build information from Koji for a module. The module specification must
include at least name, stream and version. For legacy support, you can omit
context if there is only one build of the specified NAME:STREAM:VERSION.
:param session: KojiS... | [
"def",
"get_koji_module_build",
"(",
"session",
",",
"module_spec",
")",
":",
"if",
"module_spec",
".",
"context",
"is",
"not",
"None",
":",
"# The easy case - we can build the koji \"name-version-release\" out of the",
"# module spec.",
"koji_nvr",
"=",
"\"{}-{}-{}.{}\"",
... | 45.944444 | 0.001579 |
def throw(self, type, value=None, traceback=None): # pylint: disable=redefined-builtin
"""Raise an exception in this element"""
return self.__wrapped__.throw(type, value, traceback) | [
"def",
"throw",
"(",
"self",
",",
"type",
",",
"value",
"=",
"None",
",",
"traceback",
"=",
"None",
")",
":",
"# pylint: disable=redefined-builtin",
"return",
"self",
".",
"__wrapped__",
".",
"throw",
"(",
"type",
",",
"value",
",",
"traceback",
")"
] | 65.333333 | 0.015152 |
def get_mean_DEV(sum_ptrm_checks, sum_abs_ptrm_checks, n_pTRM, delta_x_prime):
"""
input: sum_ptrm_checks, sum_abs_ptrm_checks, n_pTRM, delta_x_prime
output: Mean deviation of a pTRM check
"""
if not n_pTRM:
return float('nan'), float('nan')
mean_DEV = ((old_div(1., n_pTRM)) * (old_div(s... | [
"def",
"get_mean_DEV",
"(",
"sum_ptrm_checks",
",",
"sum_abs_ptrm_checks",
",",
"n_pTRM",
",",
"delta_x_prime",
")",
":",
"if",
"not",
"n_pTRM",
":",
"return",
"float",
"(",
"'nan'",
")",
",",
"float",
"(",
"'nan'",
")",
"mean_DEV",
"=",
"(",
"(",
"old_div... | 48.3 | 0.00813 |
def df2chucks(din,chunksize,outd,fn,return_fmt='\t',force=False):
"""
:param return_fmt: '\t': tab-sep file, lly, '.', 'list': returns a list
"""
from os.path import exists#,splitext,dirname,splitext,basename,realpath
from os import makedirs
din.index=range(0,len(din),1)
chunkrange=list(np.... | [
"def",
"df2chucks",
"(",
"din",
",",
"chunksize",
",",
"outd",
",",
"fn",
",",
"return_fmt",
"=",
"'\\t'",
",",
"force",
"=",
"False",
")",
":",
"from",
"os",
".",
"path",
"import",
"exists",
"#,splitext,dirname,splitext,basename,realpath",
"from",
"os",
"im... | 31.529412 | 0.030769 |
def add_management_certificate(self, public_key, thumbprint, data):
'''
The Add Management Certificate operation adds a certificate to the
list of management certificates. Management certificates, which are
also known as subscription certificates, authenticate clients
attempting ... | [
"def",
"add_management_certificate",
"(",
"self",
",",
"public_key",
",",
"thumbprint",
",",
"data",
")",
":",
"_validate_not_none",
"(",
"'public_key'",
",",
"public_key",
")",
"_validate_not_none",
"(",
"'thumbprint'",
",",
"thumbprint",
")",
"_validate_not_none",
... | 44.956522 | 0.001894 |
def make_muc_userinfo(self):
"""
Create <x xmlns="...muc#user"/> element in the stanza.
:return: the element created.
:returntype: `MucUserX`
"""
self.clear_muc_child()
self.muc_child=MucUserX(parent=self.xmlnode)
return self.muc_child | [
"def",
"make_muc_userinfo",
"(",
"self",
")",
":",
"self",
".",
"clear_muc_child",
"(",
")",
"self",
".",
"muc_child",
"=",
"MucUserX",
"(",
"parent",
"=",
"self",
".",
"xmlnode",
")",
"return",
"self",
".",
"muc_child"
] | 29.1 | 0.01 |
def coastal_coords():
"""
A coastal coord is a 2-tuple: (tile id, direction).
An edge is coastal if it is on the grid's border.
:return: list( (tile_id, direction) )
"""
coast = list()
for tile_id in coastal_tile_ids():
tile_coord = tile_id_to_coord(tile_id)
for edge_coord ... | [
"def",
"coastal_coords",
"(",
")",
":",
"coast",
"=",
"list",
"(",
")",
"for",
"tile_id",
"in",
"coastal_tile_ids",
"(",
")",
":",
"tile_coord",
"=",
"tile_id_to_coord",
"(",
"tile_id",
")",
"for",
"edge_coord",
"in",
"coastal_edges",
"(",
"tile_id",
")",
... | 33.705882 | 0.001698 |
def enable() -> None:
"""Patch ``sys.stdout`` to use ``DebugPrint``."""
if not isinstance(sys.stdout, DebugPrint):
sys.stdout = DebugPrint(sys.stdout) | [
"def",
"enable",
"(",
")",
"->",
"None",
":",
"if",
"not",
"isinstance",
"(",
"sys",
".",
"stdout",
",",
"DebugPrint",
")",
":",
"sys",
".",
"stdout",
"=",
"DebugPrint",
"(",
"sys",
".",
"stdout",
")"
] | 43.75 | 0.011236 |
def legendre_lm(l, m, z, normalization='4pi', csphase=1, cnorm=0):
"""
Compute the associated Legendre function for a specific degree and order.
Usage
-----
plm = legendre_lm (l, m, z, [normalization, csphase, cnorm])
Returns
-------
plm : float
The associated Legendre function... | [
"def",
"legendre_lm",
"(",
"l",
",",
"m",
",",
"z",
",",
"normalization",
"=",
"'4pi'",
",",
"csphase",
"=",
"1",
",",
"cnorm",
"=",
"0",
")",
":",
"if",
"l",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"\"The degree l must be greater or equal to 0. Input v... | 39.661017 | 0.000417 |
def check_messages(filename, report_empty=False):
"""
Checks messages in `filename` in various ways:
* Translations must have the same slots as the English.
* Messages can't have astral characters in them.
If `report_empty` is True, will also report empty translation strings.
Returns the pro... | [
"def",
"check_messages",
"(",
"filename",
",",
"report_empty",
"=",
"False",
")",
":",
"problems",
"=",
"[",
"]",
"pomsgs",
"=",
"polib",
".",
"pofile",
"(",
"filename",
")",
"for",
"msg",
"in",
"pomsgs",
":",
"# Check for characters Javascript can't support.",
... | 36.032258 | 0.001743 |
def getnodes(self, name):
"Return the direct subnodes with name 'name'"
for node in self.nodes:
if striptag(node.tag) == name:
yield node | [
"def",
"getnodes",
"(",
"self",
",",
"name",
")",
":",
"for",
"node",
"in",
"self",
".",
"nodes",
":",
"if",
"striptag",
"(",
"node",
".",
"tag",
")",
"==",
"name",
":",
"yield",
"node"
] | 35.4 | 0.01105 |
def split(url):
"""Split URL into scheme, netloc, path, query and fragment.
>>> split('http://www.example.com/abc?x=1&y=2#foo')
SplitResult(scheme='http', netloc='www.example.com', path='/abc', query='x=1&y=2', fragment='foo')
"""
scheme = netloc = path = query = fragment = ''
ip6_start = url.f... | [
"def",
"split",
"(",
"url",
")",
":",
"scheme",
"=",
"netloc",
"=",
"path",
"=",
"query",
"=",
"fragment",
"=",
"''",
"ip6_start",
"=",
"url",
".",
"find",
"(",
"'['",
")",
"scheme_end",
"=",
"url",
".",
"find",
"(",
"':'",
")",
"if",
"ip6_start",
... | 30.5 | 0.001095 |
def realimag_files(xscript=0, yscript="d[1]+1j*d[2]", eyscript=None, exscript=None, paths=None, g=None, **kwargs):
"""
This will load a bunch of data files, generate data based on the supplied
scripts, and then plot the ydata's real and imaginary parts versus xdata.
Parameters
----------
xscrip... | [
"def",
"realimag_files",
"(",
"xscript",
"=",
"0",
",",
"yscript",
"=",
"\"d[1]+1j*d[2]\"",
",",
"eyscript",
"=",
"None",
",",
"exscript",
"=",
"None",
",",
"paths",
"=",
"None",
",",
"g",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"fi... | 35.37931 | 0.009488 |
def EndVector(self, vectorNumElems):
"""EndVector writes data necessary to finish vector construction."""
self.assertNested()
## @cond FLATBUFFERS_INTERNAL
self.nested = False
## @endcond
# we already made space for this, so write without PrependUint32
self.Place... | [
"def",
"EndVector",
"(",
"self",
",",
"vectorNumElems",
")",
":",
"self",
".",
"assertNested",
"(",
")",
"## @cond FLATBUFFERS_INTERNAL",
"self",
".",
"nested",
"=",
"False",
"## @endcond",
"# we already made space for this, so write without PrependUint32",
"self",
".",
... | 36.4 | 0.010724 |
def f_supports(self, data):
""" Simply checks if data is supported """
if isinstance(data, Quantity):
return True
elif super(Brian2Parameter, self).f_supports(data):
return True
return False | [
"def",
"f_supports",
"(",
"self",
",",
"data",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"Quantity",
")",
":",
"return",
"True",
"elif",
"super",
"(",
"Brian2Parameter",
",",
"self",
")",
".",
"f_supports",
"(",
"data",
")",
":",
"return",
"True"... | 34.285714 | 0.00813 |
def read_header(filename, return_idxs=False):
""" Read blimpy header and return a Python dictionary of key:value pairs
Args:
filename (str): name of file to open
Optional args:
return_idxs (bool): Default False. If true, returns the file offset indexes
for value... | [
"def",
"read_header",
"(",
"filename",
",",
"return_idxs",
"=",
"False",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"fh",
":",
"header_dict",
"=",
"{",
"}",
"header_idxs",
"=",
"{",
"}",
"# Check this is a blimpy file",
"keyword",
"... | 26.486486 | 0.001969 |
def f2p_list(phrase, max_word_size=15, cutoff=3):
"""Convert a phrase from Finglish to Persian.
phrase: The phrase to convert.
max_word_size: Maximum size of the words to consider. Words larger
than this will be kept unchanged.
cutoff: The cut-off point. For each word, there could be many
pos... | [
"def",
"f2p_list",
"(",
"phrase",
",",
"max_word_size",
"=",
"15",
",",
"cutoff",
"=",
"3",
")",
":",
"# split the phrase into words",
"results",
"=",
"[",
"w",
"for",
"w",
"in",
"sep_regex",
".",
"split",
"(",
"phrase",
")",
"if",
"w",
"]",
"# return an... | 29.758621 | 0.001122 |
def tokenise(cls, route):
''' Split a string into an iterator of (type, value) tokens. '''
match = None
for match in cls.syntax.finditer(route):
pre, name, rex = match.groups()
if pre: yield ('TXT', pre.replace('\\:',':'))
if rex and name: yield ('VAR', (rex, ... | [
"def",
"tokenise",
"(",
"cls",
",",
"route",
")",
":",
"match",
"=",
"None",
"for",
"match",
"in",
"cls",
".",
"syntax",
".",
"finditer",
"(",
"route",
")",
":",
"pre",
",",
"name",
",",
"rex",
"=",
"match",
".",
"groups",
"(",
")",
"if",
"pre",
... | 45.615385 | 0.014876 |
def parse_config(file_name='/usr/local/etc/pkg.conf'):
'''
Return dict of uncommented global variables.
CLI Example:
.. code-block:: bash
salt '*' pkg.parse_config
``NOTE:`` not working properly right now
'''
ret = {}
if not os.path.isfile(file_name):
return 'Unable t... | [
"def",
"parse_config",
"(",
"file_name",
"=",
"'/usr/local/etc/pkg.conf'",
")",
":",
"ret",
"=",
"{",
"}",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"file_name",
")",
":",
"return",
"'Unable to find {0} on file system'",
".",
"format",
"(",
"file_nam... | 27.269231 | 0.001362 |
def kpath_from_seekpath(cls, seekpath, point_coords):
r"""Convert seekpath-formatted kpoints path to sumo-preferred format.
If 'GAMMA' is used as a label this will be replaced by '\Gamma'.
Args:
seekpath (list): A :obj:`list` of 2-tuples containing the labels at
eac... | [
"def",
"kpath_from_seekpath",
"(",
"cls",
",",
"seekpath",
",",
"point_coords",
")",
":",
"# convert from seekpath format e.g. [(l1, l2), (l2, l3), (l4, l5)]",
"# to our preferred representation [[l1, l2, l3], [l4, l5]]",
"path",
"=",
"[",
"[",
"seekpath",
"[",
"0",
"]",
"[",... | 37.816327 | 0.001052 |
def adjustSize( self ):
"""
Adjusts the size of this node to support the length of its contents.
"""
cell = self.scene().cellWidth() * 2
minheight = cell
minwidth = 2 * cell
# fit to the grid size
metrics = QFontMetrics(QApplication.font())
... | [
"def",
"adjustSize",
"(",
"self",
")",
":",
"cell",
"=",
"self",
".",
"scene",
"(",
")",
".",
"cellWidth",
"(",
")",
"*",
"2",
"minheight",
"=",
"cell",
"minwidth",
"=",
"2",
"*",
"cell",
"# fit to the grid size",
"metrics",
"=",
"QFontMetrics",
"(",
"... | 29.361111 | 0.015568 |
def files_in_directory(db, user_id, db_dirname):
"""
Return files in a directory.
"""
fields = _file_default_fields()
rows = db.execute(
select(
fields,
).where(
_is_in_directory(files, user_id, db_dirname),
).order_by(
files.c.user_id,
... | [
"def",
"files_in_directory",
"(",
"db",
",",
"user_id",
",",
"db_dirname",
")",
":",
"fields",
"=",
"_file_default_fields",
"(",
")",
"rows",
"=",
"db",
".",
"execute",
"(",
"select",
"(",
"fields",
",",
")",
".",
"where",
"(",
"_is_in_directory",
"(",
"... | 27.45 | 0.001761 |
def get(
self,
key: str,
default: typing.Any = UNSET,
type_: typing.Type[typing.Any] = str,
subtype: typing.Type[typing.Any] = str,
mapper: typing.Optional[typing.Callable[[object], object]] = None,
) -> typing.Any:
"""
Parse a value from an environmen... | [
"def",
"get",
"(",
"self",
",",
"key",
":",
"str",
",",
"default",
":",
"typing",
".",
"Any",
"=",
"UNSET",
",",
"type_",
":",
"typing",
".",
"Type",
"[",
"typing",
".",
"Any",
"]",
"=",
"str",
",",
"subtype",
":",
"typing",
".",
"Type",
"[",
"... | 29.017544 | 0.001754 |
def get_active_entry(user, select_for_update=False):
"""Returns the user's currently-active entry, or None."""
entries = apps.get_model('entries', 'Entry').no_join
if select_for_update:
entries = entries.select_for_update()
entries = entries.filter(user=user, end_time__isnull=True)
if not e... | [
"def",
"get_active_entry",
"(",
"user",
",",
"select_for_update",
"=",
"False",
")",
":",
"entries",
"=",
"apps",
".",
"get_model",
"(",
"'entries'",
",",
"'Entry'",
")",
".",
"no_join",
"if",
"select_for_update",
":",
"entries",
"=",
"entries",
".",
"select... | 38.583333 | 0.00211 |
def remount(name, device, mkmnt=False, fstype='', opts='defaults', user=None):
'''
Attempt to remount a device, if the device is not already mounted, mount
is called
CLI Example:
.. code-block:: bash
salt '*' mount.remount /mnt/foo /dev/sdz1 True
'''
force_mount = False
if __g... | [
"def",
"remount",
"(",
"name",
",",
"device",
",",
"mkmnt",
"=",
"False",
",",
"fstype",
"=",
"''",
",",
"opts",
"=",
"'defaults'",
",",
"user",
"=",
"None",
")",
":",
"force_mount",
"=",
"False",
"if",
"__grains__",
"[",
"'os'",
"]",
"in",
"[",
"'... | 35.839286 | 0.001455 |
def fastp_filtered_reads_chart(self):
""" Function to generate the fastp filtered reads bar plot """
# Specify the order of the different possible categories
keys = OrderedDict()
keys['filtering_result_passed_filter_reads'] = { 'name': 'Passed Filter' }
keys['filtering_result_lo... | [
"def",
"fastp_filtered_reads_chart",
"(",
"self",
")",
":",
"# Specify the order of the different possible categories",
"keys",
"=",
"OrderedDict",
"(",
")",
"keys",
"[",
"'filtering_result_passed_filter_reads'",
"]",
"=",
"{",
"'name'",
":",
"'Passed Filter'",
"}",
"keys... | 47.277778 | 0.019585 |
def listDatasetChildren(self, dataset):
"""
takes required dataset parameter
returns only children dataset name
"""
if( dataset == "" ):
dbsExceptionHandler("dbsException-invalid-input", "DBSDataset/listDatasetChildren. Parent Dataset name is required.")
conn ... | [
"def",
"listDatasetChildren",
"(",
"self",
",",
"dataset",
")",
":",
"if",
"(",
"dataset",
"==",
"\"\"",
")",
":",
"dbsExceptionHandler",
"(",
"\"dbsException-invalid-input\"",
",",
"\"DBSDataset/listDatasetChildren. Parent Dataset name is required.\"",
")",
"conn",
"=",
... | 35.857143 | 0.009709 |
def update_file(self, path):
'''
Updates the file watcher and calls the appropriate method for results
@return: False if we need to keep trying the connection
'''
try:
# grab the file
result, stat = self.zoo_client.get(path, watch=self.watch_file)
... | [
"def",
"update_file",
"(",
"self",
",",
"path",
")",
":",
"try",
":",
"# grab the file",
"result",
",",
"stat",
"=",
"self",
".",
"zoo_client",
".",
"get",
"(",
"path",
",",
"watch",
"=",
"self",
".",
"watch_file",
")",
"except",
"ZookeeperError",
":",
... | 35.606061 | 0.001657 |
def _speak_normal(self, element):
"""
Speak the content of element only.
:param element: The element.
:type element: hatemile.util.html.htmldomelement.HTMLDOMElement
"""
if element.has_attribute(AccessibleCSSImplementation.DATA_SPEAK):
if (
(... | [
"def",
"_speak_normal",
"(",
"self",
",",
"element",
")",
":",
"if",
"element",
".",
"has_attribute",
"(",
"AccessibleCSSImplementation",
".",
"DATA_SPEAK",
")",
":",
"if",
"(",
"(",
"element",
".",
"get_attribute",
"(",
"AccessibleCSSImplementation",
".",
"DATA... | 35.958333 | 0.002257 |
def to_filename(data,
mask=DEFAULT_PAPERS_FILENAME_MASK,
extra_formatters=None):
"""
Convert a bibtex entry to a formatted filename according to a given mask.
.. note ::
Available formatters out of the box are:
- ``journal``
- ``title``
... | [
"def",
"to_filename",
"(",
"data",
",",
"mask",
"=",
"DEFAULT_PAPERS_FILENAME_MASK",
",",
"extra_formatters",
"=",
"None",
")",
":",
"# Handle default argument",
"if",
"extra_formatters",
"is",
"None",
":",
"extra_formatters",
"=",
"{",
"}",
"entry",
"=",
"data",
... | 32.258065 | 0.000485 |
def validate_wrap(self, value):
''' Check that ``value`` is valid for unwrapping with ``ComputedField.computed_type``'''
try:
self.computed_type.validate_wrap(value)
except BadValueException as bve:
self._fail_validation(value, 'Bad value for computed field', cause=bve) | [
"def",
"validate_wrap",
"(",
"self",
",",
"value",
")",
":",
"try",
":",
"self",
".",
"computed_type",
".",
"validate_wrap",
"(",
"value",
")",
"except",
"BadValueException",
"as",
"bve",
":",
"self",
".",
"_fail_validation",
"(",
"value",
",",
"'Bad value f... | 52.166667 | 0.012579 |
def gen_binary(table, output, ascii_props=False, append=False, prefix=""):
"""Generate binary properties."""
categories = []
binary_props = (
('DerivedCoreProperties.txt', None),
('PropList.txt', None),
('DerivedNormalizationProps.txt', ('Changes_When_NFKC_Casefolded', 'Full_Composi... | [
"def",
"gen_binary",
"(",
"table",
",",
"output",
",",
"ascii_props",
"=",
"False",
",",
"append",
"=",
"False",
",",
"prefix",
"=",
"\"\"",
")",
":",
"categories",
"=",
"[",
"]",
"binary_props",
"=",
"(",
"(",
"'DerivedCoreProperties.txt'",
",",
"None",
... | 36.551724 | 0.002143 |
def export_process_element(definitions, process_id, process_attributes_dictionary):
"""
Creates process element for exported BPMN XML file.
:param process_id: string object. ID of exported process element,
:param definitions: an XML element ('definitions'), root element of BPMN 2.0 docu... | [
"def",
"export_process_element",
"(",
"definitions",
",",
"process_id",
",",
"process_attributes_dictionary",
")",
":",
"process",
"=",
"eTree",
".",
"SubElement",
"(",
"definitions",
",",
"consts",
".",
"Consts",
".",
"process",
")",
"process",
".",
"set",
"(",... | 57.875 | 0.008502 |
def create_token(user, client, scope, id_token_dic=None):
"""
Create and populate a Token object.
Return a Token object.
"""
token = Token()
token.user = user
token.client = client
token.access_token = uuid.uuid4().hex
if id_token_dic is not None:
token.id_token = id_token_d... | [
"def",
"create_token",
"(",
"user",
",",
"client",
",",
"scope",
",",
"id_token_dic",
"=",
"None",
")",
":",
"token",
"=",
"Token",
"(",
")",
"token",
".",
"user",
"=",
"user",
"token",
".",
"client",
"=",
"client",
"token",
".",
"access_token",
"=",
... | 25.894737 | 0.001961 |
def arrows(self):
"""Iterate over all my arrows."""
for o in self.arrow.values():
for arro in o.values():
yield arro | [
"def",
"arrows",
"(",
"self",
")",
":",
"for",
"o",
"in",
"self",
".",
"arrow",
".",
"values",
"(",
")",
":",
"for",
"arro",
"in",
"o",
".",
"values",
"(",
")",
":",
"yield",
"arro"
] | 31.2 | 0.0125 |
def parseBEDString(line, scoreType=int, dropAfter=None):
"""
Parse a string in BED format and return a GenomicInterval object.
:param line: the string to be parsed
:param dropAfter: an int indicating that any fields after and including
this field should be ignored as they don't conform to
... | [
"def",
"parseBEDString",
"(",
"line",
",",
"scoreType",
"=",
"int",
",",
"dropAfter",
"=",
"None",
")",
":",
"peices",
"=",
"line",
".",
"split",
"(",
"\"\\t\"",
")",
"if",
"dropAfter",
"is",
"not",
"None",
":",
"peices",
"=",
"peices",
"[",
"0",
":"... | 33.823529 | 0.01268 |
def _get_var_decl_init_value(self, _ctype, children):
"""
Gathers initialisation values by parsing children nodes of a VAR_DECL.
"""
# FIXME TU for INIT_LIST_EXPR
# FIXME: always return [(child.kind,child.value),...]
# FIXME: simplify this redondant code.
init_va... | [
"def",
"_get_var_decl_init_value",
"(",
"self",
",",
"_ctype",
",",
"children",
")",
":",
"# FIXME TU for INIT_LIST_EXPR",
"# FIXME: always return [(child.kind,child.value),...]",
"# FIXME: simplify this redondant code.",
"init_value",
"=",
"[",
"]",
"children",
"=",
"list",
... | 39.208333 | 0.002075 |
def makepilimage(self, scale = "log", negative = False):
"""
Makes a PIL image out of the array, respecting the z1 and z2 cutoffs.
By default we use a log scaling identical to iraf's, and produce an image of mode "L", i.e. grayscale.
But some drawings or colourscales will change the mode... | [
"def",
"makepilimage",
"(",
"self",
",",
"scale",
"=",
"\"log\"",
",",
"negative",
"=",
"False",
")",
":",
"if",
"scale",
"==",
"\"log\"",
"or",
"scale",
"==",
"\"lin\"",
":",
"self",
".",
"negative",
"=",
"negative",
"numpyarrayshape",
"=",
"self",
".",... | 41.901515 | 0.014836 |
def _chunk_putter(self, uri, open_file, headers=None):
"""Make many PUT request for a single chunked object.
Objects that are processed by this method have a SHA256 hash appended
to the name as well as a count for object indexing which starts at 0.
To make a PUT request pass, ``url``
... | [
"def",
"_chunk_putter",
"(",
"self",
",",
"uri",
",",
"open_file",
",",
"headers",
"=",
"None",
")",
":",
"count",
"=",
"0",
"dynamic_hash",
"=",
"hashlib",
".",
"sha256",
"(",
"self",
".",
"job_args",
".",
"get",
"(",
"'container'",
")",
")",
"dynamic... | 34.115385 | 0.001096 |
def push_tx(self, crypto, tx_hex):
"""
This method is untested.
"""
url = "%s/pushtx" % self.base_url
return self.post_url(url, {'hex': tx_hex}).content | [
"def",
"push_tx",
"(",
"self",
",",
"crypto",
",",
"tx_hex",
")",
":",
"url",
"=",
"\"%s/pushtx\"",
"%",
"self",
".",
"base_url",
"return",
"self",
".",
"post_url",
"(",
"url",
",",
"{",
"'hex'",
":",
"tx_hex",
"}",
")",
".",
"content"
] | 31.166667 | 0.010417 |
def process(self, element):
"""Run batch prediciton on a TF graph.
Args:
element: list of strings, representing one batch input to the TF graph.
"""
import collections
import apache_beam as beam
num_in_batch = 0
try:
assert self._session is not None
feed_dict = collectio... | [
"def",
"process",
"(",
"self",
",",
"element",
")",
":",
"import",
"collections",
"import",
"apache_beam",
"as",
"beam",
"num_in_batch",
"=",
"0",
"try",
":",
"assert",
"self",
".",
"_session",
"is",
"not",
"None",
"feed_dict",
"=",
"collections",
".",
"de... | 32.592593 | 0.014892 |
def _get_content(self, params, mode_translate):
"""
This method gets the token and makes the header variable that
will be used in connection authentication. After that, calls
the _make_request() method to return the desired data.
"""
token = self._get_... | [
"def",
"_get_content",
"(",
"self",
",",
"params",
",",
"mode_translate",
")",
":",
"token",
"=",
"self",
".",
"_get_token",
"(",
")",
"headers",
"=",
"{",
"'Authorization'",
":",
"'Bearer '",
"+",
"token",
"}",
"parameters",
"=",
"params",
"translation_url"... | 46.909091 | 0.009506 |
def _send_commit_request(self, retry_delay=None, attempt=None):
"""Send a commit request with our last_processed_offset"""
# If there's a _commit_call, and it's not active, clear it, it probably
# just called us...
if self._commit_call and not self._commit_call.active():
self... | [
"def",
"_send_commit_request",
"(",
"self",
",",
"retry_delay",
"=",
"None",
",",
"attempt",
"=",
"None",
")",
":",
"# If there's a _commit_call, and it's not active, clear it, it probably",
"# just called us...",
"if",
"self",
".",
"_commit_call",
"and",
"not",
"self",
... | 43.228571 | 0.001293 |
def get_offset(name):
"""
Return DateOffset object associated with rule name
Examples
--------
get_offset('EOM') --> BMonthEnd(1)
"""
if name not in libfreqs._dont_uppercase:
name = name.upper()
name = libfreqs._lite_rule_alias.get(name, name)
name = libfreqs._lite_r... | [
"def",
"get_offset",
"(",
"name",
")",
":",
"if",
"name",
"not",
"in",
"libfreqs",
".",
"_dont_uppercase",
":",
"name",
"=",
"name",
".",
"upper",
"(",
")",
"name",
"=",
"libfreqs",
".",
"_lite_rule_alias",
".",
"get",
"(",
"name",
",",
"name",
")",
... | 31.37931 | 0.001066 |
def remove_user(name, profile='github'):
'''
Remove a Github user by name.
name
The user for which to obtain information.
profile
The name of the profile configuration to use. Defaults to ``github``.
CLI Example:
.. code-block:: bash
salt myminion github.remove_user ... | [
"def",
"remove_user",
"(",
"name",
",",
"profile",
"=",
"'github'",
")",
":",
"client",
"=",
"_get_client",
"(",
"profile",
")",
"organization",
"=",
"client",
".",
"get_organization",
"(",
"_get_config_value",
"(",
"profile",
",",
"'org_name'",
")",
")",
"t... | 23.28125 | 0.001289 |
def unix_timestamp_to_datetime(unix_timestamp):
"""
<Purpose>
Convert 'unix_timestamp' (i.e., POSIX time, in UNIX_TIMESTAMP_SCHEMA format)
to a datetime.datetime() object. 'unix_timestamp' is the number of seconds
since the epoch (January 1, 1970.)
>>> datetime_object = unix_timestamp_to_datetime(... | [
"def",
"unix_timestamp_to_datetime",
"(",
"unix_timestamp",
")",
":",
"# Is 'unix_timestamp' properly formatted?",
"# Raise 'securesystemslib.exceptions.FormatError' if there is a mismatch.",
"securesystemslib",
".",
"formats",
".",
"UNIX_TIMESTAMP_SCHEMA",
".",
"check_match",
"(",
"... | 33.853659 | 0.009804 |
def append_search_summary(xmldoc, process, shared_object = "standalone", lalwrapper_cvs_tag = "", lal_cvs_tag = "", comment = None, ifos = None, inseg = None, outseg = None, nevents = 0, nnodes = 1):
"""
Append search summary information associated with the given process
to the search summary table in xmldoc. Retur... | [
"def",
"append_search_summary",
"(",
"xmldoc",
",",
"process",
",",
"shared_object",
"=",
"\"standalone\"",
",",
"lalwrapper_cvs_tag",
"=",
"\"\"",
",",
"lal_cvs_tag",
"=",
"\"\"",
",",
"comment",
"=",
"None",
",",
"ifos",
"=",
"None",
",",
"inseg",
"=",
"No... | 37.28 | 0.044979 |
def create(sender, recipients=None, cc=None, bcc=None, subject='', message='',
html_message='', context=None, scheduled_time=None, headers=None,
template=None, priority=None, render_on_delivery=False, commit=True,
backend=''):
"""
Creates an email from supplied keyword arguments... | [
"def",
"create",
"(",
"sender",
",",
"recipients",
"=",
"None",
",",
"cc",
"=",
"None",
",",
"bcc",
"=",
"None",
",",
"subject",
"=",
"''",
",",
"message",
"=",
"''",
",",
"html_message",
"=",
"''",
",",
"context",
"=",
"None",
",",
"scheduled_time",... | 29.83871 | 0.000523 |
def var(names, **args):
"""
Create symbols and inject them into the global namespace.
INPUT:
- s -- a string, either a single variable name, or
- a space separated list of variable names, or
- a list of variable names.
This calls :func:`symbols` with the same... | [
"def",
"var",
"(",
"names",
",",
"*",
"*",
"args",
")",
":",
"def",
"traverse",
"(",
"symbols",
",",
"frame",
")",
":",
"\"\"\"Recursively inject symbols to the global namespace. \"\"\"",
"for",
"symbol",
"in",
"symbols",
":",
"if",
"isinstance",
"(",
"symbol",
... | 27.711864 | 0.000591 |
def read_namespaced_job(self, name, namespace, **kwargs): # noqa: E501
"""read_namespaced_job # noqa: E501
read the specified Job # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread ... | [
"def",
"read_namespaced_job",
"(",
"self",
",",
"name",
",",
"namespace",
",",
"*",
"*",
"kwargs",
")",
":",
"# noqa: E501",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'async_req'",
")",
":",
"return",
"s... | 53.44 | 0.001471 |
def applySettings(self, axisMin=None, axisMax=None, axisLimit=None):
"""Apply the specified settings to this axis.
Set self.minValue, self.minValueSource, self.maxValue,
self.maxValueSource, and self.axisLimit reasonably based on the
parameters provided.
Arguments:
axi... | [
"def",
"applySettings",
"(",
"self",
",",
"axisMin",
"=",
"None",
",",
"axisMax",
"=",
"None",
",",
"axisLimit",
"=",
"None",
")",
":",
"if",
"axisMin",
"is",
"not",
"None",
"and",
"not",
"math",
".",
"isnan",
"(",
"axisMin",
")",
":",
"self",
".",
... | 39.934783 | 0.001063 |
def persist_header_chain(self,
headers: Iterable[BlockHeader]
) -> Tuple[Tuple[BlockHeader, ...], Tuple[BlockHeader, ...]]:
"""
Return two iterable of headers, the first containing the new canonical headers,
the second containing the old ... | [
"def",
"persist_header_chain",
"(",
"self",
",",
"headers",
":",
"Iterable",
"[",
"BlockHeader",
"]",
")",
"->",
"Tuple",
"[",
"Tuple",
"[",
"BlockHeader",
",",
"...",
"]",
",",
"Tuple",
"[",
"BlockHeader",
",",
"...",
"]",
"]",
":",
"with",
"self",
".... | 49.222222 | 0.013304 |
def platform_detect():
"""Detect if running on the Raspberry Pi or Beaglebone Black and return the
platform type. Will return RASPBERRY_PI, BEAGLEBONE_BLACK, or UNKNOWN."""
# Handle Raspberry Pi
pi = pi_version()
if pi is not None:
return RASPBERRY_PI
# Handle Beaglebone Black
# TO... | [
"def",
"platform_detect",
"(",
")",
":",
"# Handle Raspberry Pi",
"pi",
"=",
"pi_version",
"(",
")",
"if",
"pi",
"is",
"not",
"None",
":",
"return",
"RASPBERRY_PI",
"# Handle Beaglebone Black",
"# TODO: Check the Beaglebone Black /proc/cpuinfo value instead of reading",
"# ... | 36.73913 | 0.001153 |
def ips(self):
"""return all the possible ips of this request, this will include public and private ips"""
r = []
names = ['X_FORWARDED_FOR', 'CLIENT_IP', 'X_REAL_IP', 'X_FORWARDED',
'X_CLUSTER_CLIENT_IP', 'FORWARDED_FOR', 'FORWARDED', 'VIA',
'REMOTE_ADDR']
... | [
"def",
"ips",
"(",
"self",
")",
":",
"r",
"=",
"[",
"]",
"names",
"=",
"[",
"'X_FORWARDED_FOR'",
",",
"'CLIENT_IP'",
",",
"'X_REAL_IP'",
",",
"'X_FORWARDED'",
",",
"'X_CLUSTER_CLIENT_IP'",
",",
"'FORWARDED_FOR'",
",",
"'FORWARDED'",
",",
"'VIA'",
",",
"'REMO... | 35.294118 | 0.00974 |
def image(self):
"""
Returns a json-schema document that represents a single image entity.
"""
uri = "/%s/image" % self.uri_base
resp, resp_body = self.api.method_get(uri)
return resp_body | [
"def",
"image",
"(",
"self",
")",
":",
"uri",
"=",
"\"/%s/image\"",
"%",
"self",
".",
"uri_base",
"resp",
",",
"resp_body",
"=",
"self",
".",
"api",
".",
"method_get",
"(",
"uri",
")",
"return",
"resp_body"
] | 32.857143 | 0.008475 |
def show_relations(self):
''' display every relation in the database as (src, relation, dst) '''
for src_node in self.iter_nodes():
for relation in src_node.outgoing:
for dst_node in src_node.outgoing[relation]:
print(repr(src_node.obj), '-', relation, '-'... | [
"def",
"show_relations",
"(",
"self",
")",
":",
"for",
"src_node",
"in",
"self",
".",
"iter_nodes",
"(",
")",
":",
"for",
"relation",
"in",
"src_node",
".",
"outgoing",
":",
"for",
"dst_node",
"in",
"src_node",
".",
"outgoing",
"[",
"relation",
"]",
":",... | 56 | 0.008798 |
def inject_extra_args(callback, request, kwargs):
'''Inject extra arguments from header, body, form.'''
# TODO: this is a temporary pach, should be managed via honouring the
# mimetype in the request header....
annots = dict(callback.__annotations__)
del annots['return']
for param_name, (param_t... | [
"def",
"inject_extra_args",
"(",
"callback",
",",
"request",
",",
"kwargs",
")",
":",
"# TODO: this is a temporary pach, should be managed via honouring the",
"# mimetype in the request header....",
"annots",
"=",
"dict",
"(",
"callback",
".",
"__annotations__",
")",
"del",
... | 48.368421 | 0.002134 |
def _init_metadata(self):
"""stub"""
self._files_metadata = {
'element_id': Id(self.my_osid_object_form._authority,
self.my_osid_object_form._namespace,
'files'),
'element_label': 'Files',
'instructions': 'ente... | [
"def",
"_init_metadata",
"(",
"self",
")",
":",
"self",
".",
"_files_metadata",
"=",
"{",
"'element_id'",
":",
"Id",
"(",
"self",
".",
"my_osid_object_form",
".",
"_authority",
",",
"self",
".",
"my_osid_object_form",
".",
"_namespace",
",",
"'files'",
")",
... | 36.304348 | 0.001166 |
def getRole(self, label):
"""Get the :class:`rtcclient.models.Role` object by the label name
:param label: the label name of the role
:return: the :class:`rtcclient.models.Role` object
:rtype: :class:`rtcclient.models.Role`
"""
if not isinstance(label, six.string_types)... | [
"def",
"getRole",
"(",
"self",
",",
"label",
")",
":",
"if",
"not",
"isinstance",
"(",
"label",
",",
"six",
".",
"string_types",
")",
"or",
"not",
"label",
":",
"excp_msg",
"=",
"\"Please specify a valid role label\"",
"self",
".",
"log",
".",
"error",
"("... | 38.32 | 0.002037 |
def seek(self, offset, whence=os.SEEK_SET):
"""Seeks to an offset within the file-like object.
Args:
offset (int): offset to seek to.
whence (Optional(int)): value that indicates whether offset is an absolute
or relative position within the file.
Raises:
IOError: if the seek fa... | [
"def",
"seek",
"(",
"self",
",",
"offset",
",",
"whence",
"=",
"os",
".",
"SEEK_SET",
")",
":",
"if",
"not",
"self",
".",
"_is_open",
":",
"raise",
"IOError",
"(",
"'Not opened.'",
")",
"if",
"self",
".",
"_fsntfs_data_stream",
":",
"self",
".",
"_fsnt... | 29.368421 | 0.008681 |
def plot_cumulative_gain(y_true, y_probas, title='Cumulative Gains Curve',
ax=None, figsize=None, title_fontsize="large",
text_fontsize="medium"):
"""Generates the Cumulative Gains Plot from labels and scores/probabilities
The cumulative gains chart is used to ... | [
"def",
"plot_cumulative_gain",
"(",
"y_true",
",",
"y_probas",
",",
"title",
"=",
"'Cumulative Gains Curve'",
",",
"ax",
"=",
"None",
",",
"figsize",
"=",
"None",
",",
"title_fontsize",
"=",
"\"large\"",
",",
"text_fontsize",
"=",
"\"medium\"",
")",
":",
"y_tr... | 37.988372 | 0.000298 |
def file_put_contents(path, data):
""" Put passed contents into file located at 'path' """
with open(path, 'w') as f:
f.write(data); f.flush() | [
"def",
"file_put_contents",
"(",
"path",
",",
"data",
")",
":",
"with",
"open",
"(",
"path",
",",
"'w'",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
"data",
")",
"f",
".",
"flush",
"(",
")"
] | 38.75 | 0.012658 |
def _submit(self, body, future):
"""Enqueue a problem for submission to the server.
This method is thread safe.
"""
self._submission_queue.put(self._submit.Message(body, future)) | [
"def",
"_submit",
"(",
"self",
",",
"body",
",",
"future",
")",
":",
"self",
".",
"_submission_queue",
".",
"put",
"(",
"self",
".",
"_submit",
".",
"Message",
"(",
"body",
",",
"future",
")",
")"
] | 34.333333 | 0.009479 |
def wavenumber(src, rec, depth, res, freq, wavenumber, ab=11, aniso=None,
epermH=None, epermV=None, mpermH=None, mpermV=None, verb=2):
r"""Depreciated. Use `dipole_k` instead."""
# Issue warning
mesg = ("\n The use of `model.wavenumber` is deprecated and will " +
"be removed;\... | [
"def",
"wavenumber",
"(",
"src",
",",
"rec",
",",
"depth",
",",
"res",
",",
"freq",
",",
"wavenumber",
",",
"ab",
"=",
"11",
",",
"aniso",
"=",
"None",
",",
"epermH",
"=",
"None",
",",
"epermV",
"=",
"None",
",",
"mpermH",
"=",
"None",
",",
"mper... | 47.272727 | 0.001887 |
def calc_effective_diffusivity(self, inlets=None, outlets=None,
domain_area=None, domain_length=None):
r"""
This calculates the effective diffusivity in this linear transport
algorithm.
Parameters
----------
inlets : array_like
... | [
"def",
"calc_effective_diffusivity",
"(",
"self",
",",
"inlets",
"=",
"None",
",",
"outlets",
"=",
"None",
",",
"domain_area",
"=",
"None",
",",
"domain_length",
"=",
"None",
")",
":",
"return",
"self",
".",
"_calc_eff_prop",
"(",
"inlets",
"=",
"inlets",
... | 42.135135 | 0.001881 |
def getBaseSpec(cls):
"""Return the base Spec for TemporalPoolerRegion.
Doesn't include the pooler parameters
"""
spec = dict(
description=TemporalPoolerRegion.__doc__,
singleNodeOnly=True,
inputs=dict(
activeCells=dict(
description="Active cells",
dataType... | [
"def",
"getBaseSpec",
"(",
"cls",
")",
":",
"spec",
"=",
"dict",
"(",
"description",
"=",
"TemporalPoolerRegion",
".",
"__doc__",
",",
"singleNodeOnly",
"=",
"True",
",",
"inputs",
"=",
"dict",
"(",
"activeCells",
"=",
"dict",
"(",
"description",
"=",
"\"A... | 26.737705 | 0.001183 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.