Unnamed: 0 int64 0 389k | code stringlengths 26 79.6k | docstring stringlengths 1 46.9k |
|---|---|---|
14,200 | def get_traffic(self, subreddit):
url = self.config[].format(
subreddit=six.text_type(subreddit))
return self.request_json(url) | Return the json dictionary containing traffic stats for a subreddit.
:param subreddit: The subreddit whose /about/traffic page we will
collect. |
14,201 | def ResolveForRead(self, partition_key):
intersecting_ranges = self._GetIntersectingRanges(partition_key)
collection_links = list()
for keyrange in intersecting_ranges:
collection_links.append(self.partition_map.get(keyrange))
return collection_links | Resolves the collection for reading/querying the documents based on the partition key.
:param dict document:
The document to be read/queried.
:return:
Collection Self link(s) or Name based link(s) which should handle the Read operation.
:rtype:
list |
14,202 | def _render(roster_file, **kwargs):
renderers = salt.loader.render(__opts__, {})
domain = __opts__.get(, )
try:
result = salt.template.compile_template(roster_file,
renderers,
__opts__[],
... | Render the roster file |
14,203 | def package_releases(self, project_name):
try:
return self._connection.package_releases(project_name)
except Exception as err:
raise PyPIClientError(err) | Retrieve the versions from PyPI by ``project_name``.
Args:
project_name (str): The name of the project we wish to retrieve
the versions of.
Returns:
list: Of string versions. |
14,204 | def _get_embed(self, embed, vocab_size, embed_size, initializer, dropout, prefix):
if embed is None:
assert embed_size is not None, \
with self.name_scope():
embed = nn.HybridSequential(prefix=prefix)
w... | Construct an embedding block. |
14,205 | def _send(self, message):
message[] =
payload = json.dumps(message).encode()
if len(payload) > LAMBDA_ASYNC_PAYLOAD_LIMIT:
raise AsyncException("Payload too large for async Lambda call")
self.response = self.client.invoke(
Functi... | Given a message, directly invoke the lamdba function for this task. |
14,206 | def get_hotp(
secret,
intervals_no,
as_string=False,
casefold=True,
digest_method=hashlib.sha1,
token_length=6,
):
if isinstance(secret, six.string_types):
secret = secret.encode()
secret = secret.replace(b, b)
try:
key = bas... | Get HMAC-based one-time password on the basis of given secret and
interval number.
:param secret: the base32-encoded string acting as secret key
:type secret: str or unicode
:param intervals_no: interval number used for getting different tokens, it
is incremented with each use
:type interva... |
14,207 | def threshold_monitor_hidden_threshold_monitor_Memory_actions(self, **kwargs):
config = ET.Element("config")
threshold_monitor_hidden = ET.SubElement(config, "threshold-monitor-hidden", xmlns="urn:brocade.com:mgmt:brocade-threshold-monitor")
threshold_monitor = ET.SubElement(threshold_m... | Auto Generated Code |
14,208 | def setLinkState(self, tlsID, tlsLinkIndex, state):
fullState = list(self.getRedYellowGreenState(tlsID))
if tlsLinkIndex >= len(fullState):
raise TraCIException(None, None, "Invalid tlsLinkIndex %s for tls with maximum index %s." % (
tlsLinkIndex, tlsID, len(fullSta... | setLinkState(string, string, int, string) -> None
Sets the state for the given tls and link index. The state must be one
of rRgGyYoOu for red, red-yellow, green, yellow, off, where lower case letters mean that the stream has to decelerate.
The link index is shown the gui when setting the appropr... |
14,209 | def getClientIP(request):
forwardedfor = request.META.get()
if forwardedfor:
ip = forwardedfor.split()[0]
else:
ip = request.META.get()
return ip | Returns the best IP address found from the request |
14,210 | def list(self, path, timeout=None):
transport = DentFilesyncTransport(self.stream)
transport.write_data(, path, timeout)
return (DeviceFileStat(dent_msg.name, dent_msg.mode,
dent_msg.size, dent_msg.time) for dent_msg in
transport.read_until_done(, timeout)) | List directory contents on the device.
Args:
path: List the contents of this directory.
timeout: Timeout to use for this operation.
Returns:
Generator yielding DeviceFileStat tuples representing the contents of
the requested path. |
14,211 | def register_remove_user_command(self, remove_user_func):
description = "Removes user permission to access a remote project."
remove_user_parser = self.subparsers.add_parser(, description=description)
add_project_name_or_id_arg(remove_user_parser, help_text_suffix="remove a user from")
... | Add the remove-user command to the parser and call remove_user_func(project_name, user_full_name) when chosen.
:param remove_user_func: func Called when this option is chosen: remove_user_func(project_name, user_full_name). |
14,212 | def _translate(self, from_str, to_str):
return ops.Translate(self, from_str, to_str).to_expr() | Returns string with set of 'from' characters replaced
by set of 'to' characters.
from_str[x] is replaced by to_str[x].
To avoid unexpected behavior, from_str should be
shorter than to_string.
Parameters
----------
from_str : string
to_str : string
Examples
--------
>>> impo... |
14,213 | def files_view(request):
hosts = Host.objects.visible_to_user(request.user)
context = {"hosts": hosts}
return render(request, "files/home.html", context) | The main filecenter view. |
14,214 | def ball_count(cls, ball_tally, strike_tally, pitch_res):
b, s = ball_tally, strike_tally
if pitch_res == "B":
if ball_tally < 4:
b += 1
elif pitch_res == "S" or pitch_res == "C" or pitch_res == "X":
if strike_tally < 3:
s += 1
... | Ball/Strike counter
:param ball_tally: Ball telly
:param strike_tally: Strike telly
:param pitch_res: pitching result(Retrosheet format)
:return: ball count, strike count |
14,215 | def delete_user_from_group(self, GroupID, UserID):
log.info( % (UserID, GroupID))
self.put( % (GroupID, UserID)) | Delete a user from a group. |
14,216 | def scaled_dot_product_attention_simple(q, k, v, bias, name=None):
with tf.variable_scope(
name, default_name="scaled_dot_product_attention_simple"):
scalar = tf.rsqrt(tf.to_float(common_layers.shape_list(q)[2]))
logits = tf.matmul(q * scalar, k, transpose_b=True)
if bias is not None:
logit... | Scaled dot-product attention. One head. One spatial dimension.
Args:
q: a Tensor with shape [batch, length_q, depth_k]
k: a Tensor with shape [batch, length_kv, depth_k]
v: a Tensor with shape [batch, length_kv, depth_v]
bias: optional Tensor broadcastable to [batch, length_q, length_kv]
name: an... |
14,217 | def configured_logger(self, name=None):
log_handlers = self.log_handlers
if not name:
basename =
name = self.name
if name and name != basename:
name = % (basename, name)
else:
na... | Configured logger. |
14,218 | def check( state_engine, nameop, block_id, checked_ops ):
from ..nameset import BlockstackDB
name = str(nameop[])
sender = str(nameop[])
sender_pubkey = None
recipient = str(nameop[])
recipient_address = str(nameop[])
preorder_hash = hash_name( nameop[], sender, recipient_address )
... | Given a NAME_IMPORT nameop, see if we can import it.
* the name must be well-formed
* the namespace must be revealed, but not ready
* the name cannot have been imported yet
* the sender must be the same as the namespace's sender
Set the __preorder__ and __prior_history__ fields, since this
is a... |
14,219 | def clear(self):
self.database.delete(self.key)
self.database.delete(self.event) | Clear the lock, allowing it to be acquired. Do not use this
method except to recover from a deadlock. Otherwise you should
use :py:meth:`Lock.release`. |
14,220 | def create_routertype(self, context, routertype):
LOG.debug("create_routertype() called. Contents %s", routertype)
rt = routertype[]
with context.session.begin(subtransactions=True):
routertype_db = l3_models.RouterType(
id=self._get_id(rt),
t... | Creates a router type.
Also binds it to the specified hosting device template. |
14,221 | def list_addresses(self, tag_values=None):
title = % self.__class__.__name__
input_fields = {
: tag_values
}
for key, value in input_fields.items():
if value:
object_title = % (title, key, str(value))
... | a method to list elastic ip addresses associated with account on AWS
:param tag_values: [optional] list of tag values
:return: list of strings with ip addresses |
14,222 | def horizon_main_nav(context):
if not in context:
return {}
current_dashboard = context[].horizon.get(, None)
dashboards = []
for dash in Horizon.get_dashboards():
if dash.can_access(context):
if callable(dash.nav) and dash.nav(context):
dashboards.appen... | Generates top-level dashboard navigation entries. |
14,223 | def parse_pr_numbers(git_log_lines):
prs = []
for line in git_log_lines:
pr_number = parse_pr_number(line)
if pr_number:
prs.append(pr_number)
return prs | Parse PR numbers from commit messages. At GitHub those have the format:
`here is the message (#1234)`
being `1234` the PR number. |
14,224 | def plot_lognormal_cdf(self,**kwargs):
if not hasattr(self,):
return
x=np.sort(self.data)
n=len(x)
xcdf = np.arange(n,0,-1,dtype=)/float(n)
lcdf = self.lognormal_dist.sf(x)
D_location = argmax(xcdf-lcdf)
pylab.vlines(x[D_location],xcdf[D_loc... | Plot the fitted lognormal distribution |
14,225 | def fit(self, sequences, y=None):
super(PCCA, self).fit(sequences, y=y)
self._do_lumping()
return self | Fit a PCCA lumping model using a sequence of cluster assignments.
Parameters
----------
sequences : list(np.ndarray(dtype='int'))
List of arrays of cluster assignments
y : None
Unused, present for sklearn compatibility only.
Returns
-------
... |
14,226 | def info(device):
*
out = __salt__[]("btrfs filesystem show {0}".format(device))
salt.utils.fsutils._verify_run(out)
return _parse_btrfs_info(out[]) | Get BTRFS filesystem information.
CLI Example:
.. code-block:: bash
salt '*' btrfs.info /dev/sda1 |
14,227 | def _harvest_validate(self, userkwargs):
parser = {}
userkwargs.update(self.network_kwargs)
original_kwargs = set(map(lambda k: k.split()[1] if k.find()>-1 else k, userkwargs.keys()))
requires = []
for key ... | Validate and Plant user provided arguments
- Go through and plants the seedlings
for any user arguments provided.
- Validate the arguments, cleaning and adapting (valideer wise)
- Extract negatives "!" arguments |
14,228 | def lru_cache(fn):
@wraps(fn)
def memoized_fn(*args):
pargs = pickle.dumps(args)
if pargs not in memoized_fn.cache:
memoized_fn.cache[pargs] = fn(*args)
return memoized_fn.cache[pargs]
for attr, value in iter(fn.__dict__.items()):
setattr(memoized_f... | Memoization wrapper that can handle function attributes, mutable arguments,
and can be applied either as a decorator or at runtime.
:param fn: Function
:type fn: function
:returns: Memoized function
:rtype: function |
14,229 | def stop_reactor_on_state_machine_finish(state_machine):
wait_for_state_machine_finished(state_machine)
from twisted.internet import reactor
if reactor.running:
plugins.run_hook("pre_destruction")
reactor.callFromThread(reactor.stop) | Wait for a state machine to be finished and stops the reactor
:param state_machine: the state machine to synchronize with |
14,230 | def format_help_text(self, ctx, formatter):
if self.help:
formatter.write_paragraph()
with formatter.indentation():
formatter.write_text(self.help) | Writes the help text to the formatter if it exists. |
14,231 | def worker(self):
if self._worker is None:
self._worker = XOrbLookupWorker(self.isThreadEnabled())
self.loadRequested.connect(self._worker.loadRecords)
self.loadBatchRequested.connect(self._worker.loadBatch)
self.loadColum... | Returns the worker associated with this tree widget.
:return <projexui.xorblookupworker.XOrbLookupWorker> |
14,232 | def build(self, get_grad_fn, get_opt_fn):
with override_to_local_variable():
get_global_step_var()
get_opt_fn = memoized(get_opt_fn)
get_opt_fn()
grad_list = DataParallelBuilder.build_on_towers(
self.towers, get_grad_fn,
... | Args:
get_grad_fn (-> [(grad, var)]):
get_opt_fn (-> tf.train.Optimizer): callable which returns an optimizer
Returns:
(tf.Operation, tf.Operation, tf.Operation):
1. the training op.
2. the op which sync all the local variables from PS.
... |
14,233 | def _evaluate(self,R,z,phi=0.,t=0.):
r2= R**2.+z**2.
rb= nu.sqrt(r2+self.b2)
return -1./(self.b+rb) | NAME:
_evaluate
PURPOSE:
evaluate the potential at R,z
INPUT:
R - Galactocentric cylindrical radius
z - vertical height
phi - azimuth
t - time
OUTPUT:
Phi(R,z)
HISTORY:
2013-09-08 - Written - Bovy (IA... |
14,234 | def sample(model, n, method="optgp", thinning=100, processes=1, seed=None):
if method == "optgp":
sampler = OptGPSampler(model, processes, thinning=thinning, seed=seed)
elif method == "achr":
sampler = ACHRSampler(model, thinning=thinning, seed=seed)
else:
raise ValueError("met... | Sample valid flux distributions from a cobra model.
The function samples valid flux distributions from a cobra model.
Currently we support two methods:
1. 'optgp' (default) which uses the OptGPSampler that supports parallel
sampling [1]_. Requires large numbers of samples to be performant
... |
14,235 | def to_ascii_bytes(self, filter_func=None):
try:
string = self.to_str(filter_func)
string = string.encode()
except (UnicodeEncodeError, UnicodeDecodeError):
self.percent_encode_non_ascii_headers()
string = self.to_str(filter_func)
stri... | Attempt to encode the headers block as ascii
If encoding fails, call percent_encode_non_ascii_headers()
to encode any headers per RFCs |
14,236 | def _parse_response_types(argspec, attrs):
return_type = argspec.annotations.get("return") or None
type_description = attrs.parameter_descriptions.get("return", "")
response_types = attrs.response_types.copy()
if return_type or len(response_types) == 0:
response_type... | from the given parameters, return back the response type dictionaries. |
14,237 | def _SetYaraRules(self, yara_rules_string):
if not yara_rules_string:
return
analyzer_object = analyzers_manager.AnalyzersManager.GetAnalyzerInstance(
)
analyzer_object.SetRules(yara_rules_string)
self._analyzers.append(analyzer_object) | Sets the Yara rules.
Args:
yara_rules_string (str): unparsed Yara rule definitions. |
14,238 | def do_reference(self, parent=None, ident=0):
(handle,) = self._readStruct(">L")
log_debug("
ref = self.references[handle - self.BASE_REFERENCE_IDX]
log_debug("
return ref | Handles a TC_REFERENCE opcode
:param parent:
:param ident: Log indentation level
:return: The referenced object |
14,239 | def summarize(self):
if not self._achievements_summarized:
for _ in self.operations():
pass
self._summarize()
return self._summary | Summarize game. |
14,240 | def _parse_complement(self, tokens):
tokens.pop(0)
tokens.pop(0)
res = self._parse_nested_interval(tokens)
tokens.pop(0)
res.switch_strand()
return res | Parses a complement
Complement ::= 'complement' '(' SuperRange ')' |
14,241 | def show_hbonds(self):
grp = self.getPseudoBondGroup("Hydrogen Bonds-%i" % self.tid, associateWith=[self.model])
grp.lineWidth = 3
for i in self.plcomplex.hbonds.ldon_id:
b = grp.newPseudoBond(self.atoms[i[0]], self.atoms[i[1]])
b.color = self.colorbyname()
... | Visualizes hydrogen bonds. |
14,242 | def resolve_indirect (data, key, splithosts=False):
value = data[key]
env_value = os.environ.get(value)
if env_value:
if splithosts:
data[key] = split_hosts(env_value)
else:
data[key] = env_value
else:
del data[key] | Replace name of environment variable with its value. |
14,243 | def build_spec(user, repo, sha=None, prov=None, extraMetadata=[]):
loader = grlc.utils.getLoader(user, repo, sha=sha, prov=prov)
files = loader.fetchFiles()
raw_repo_uri = loader.getRawRepoUri()
items = []
allowed_ext = ["rq", "sparql", "json", "tpf"]
for c in files:
glogger... | Build grlc specification for the given github user / repo. |
14,244 | def process(
self, request, application,
expected_state, label, extra_roles=None):
roles = self._get_roles_for_request(request, application)
if extra_roles is not None:
roles.update(extra_roles)
if not in roles:
return... | Process the view request at the current state. |
14,245 | def nextGen(self):
self.current_gen += 1
self.change_gen[self.current_gen % 3] = copy.copy(self.grid)
grid_cp = copy.copy(self.grid)
for cell in self.grid:
y, x = cell
y1 = (y - 1) % self.y_grid
y2 = (y + 1) % self.y_grid
x1 = (x ... | Decide the fate of the cells |
14,246 | def compute_Pi_JinsDJ_given_D(self, CDR3_seq, Pi_J_given_D, max_J_align):
max_insertions = len(self.PinsDJ) - 1
Pi_JinsDJ_given_D = [np.zeros((4, len(CDR3_seq)*3)) for i in range(len(Pi_J_given_D))]
for D_in in range(len(Pi_J_given_D)):
... | Compute Pi_JinsDJ conditioned on D.
This function returns the Pi array from the model factors of the J genomic
contributions, P(D,J)*P(delJ|J), and the DJ (N2) insertions,
first_nt_bias_insDJ(n_1)PinsDJ(\ell_{DJ})\prod_{i=2}^{\ell_{DJ}}Rdj(n_i|n_{i-1})
conditioned on D identity. T... |
14,247 | def roundrobin(*iterables):
raise NotImplementedError()
pending = len(iterables)
if six.PY2:
nexts = cycle(iter(it).next for it in iterables)
else:
nexts = cycle(iter(it).__next__ for it in iterables)
while pending:
try:
for next in nexts:
... | roundrobin('ABC', 'D', 'EF') --> A D E B F C |
14,248 | def isLoggedIn(self):
r = self._cleanGet(self.req_url.LOGIN, allow_redirects=False)
return "Location" in r.headers and "home" in r.headers["Location"] | Sends a request to Facebook to check the login status
:return: True if the client is still logged in
:rtype: bool |
14,249 | def bytes(num, check_result=False):
if num <= 0:
raise ValueError(" should be > 0")
buf = create_string_buffer(num)
result = libcrypto.RAND_bytes(buf, num)
if check_result and result == 0:
raise RandError("Random Number Generator not seeded sufficiently")
return buf.raw[:num] | Returns num bytes of cryptographically strong pseudo-random
bytes. If checkc_result is True, raises error if PRNG is not
seeded enough |
14,250 | def dispatch(self, request, **kwargs):
if request.method == :
self.__authtoken = (bool(getattr(self.request, "authtoken", False)))
self.json_worker = self.__authtoken or (self.json is True)
return super(GenDelete, self).dispatch(re... | Entry point for this class, here we decide basic stuff |
14,251 | def get_urls(self):
from django.conf.urls import patterns, url
urls = super(RecurrenceRuleAdmin, self).get_urls()
my_urls = patterns(
,
url(
r,
self.admin_site.admin_view(self.preview),
name=
),
... | Add a preview URL. |
14,252 | def merge_chromosome_dfs(df_tuple):
plus_df, minus_df = df_tuple
index_cols = "Chromosome Bin".split()
count_column = plus_df.columns[0]
if plus_df.empty:
return return_other(minus_df, count_column, index_cols)
if minus_df.empty:
return return_other(plus_df, count_column,... | Merges data from the two strands into strand-agnostic counts. |
14,253 | def read_params(filename, asheader=False, verbosity=0) -> Dict[str, Union[int, float, bool, str, None]]:
filename = str(filename)
from collections import OrderedDict
params = OrderedDict([])
for line in open(filename):
if in line:
if not asheader or line.startswith():
... | Read parameter dictionary from text file.
Assumes that parameters are specified in the format:
par1 = value1
par2 = value2
Comments that start with '#' are allowed.
Parameters
----------
filename : str, Path
Filename of data file.
asheader : bool, optional
Read... |
14,254 | def expand_variables(template_str, value_map, transformer=None):
if template_str is None:
return None
else:
if transformer is None:
transformer = lambda v: v
try:
| Expand a template string like "blah blah $FOO blah" using given value mapping. |
14,255 | def switch_on(self, *args):
if self.on_check(*args):
return self._switch.switch(True)
else:
return False | Sets the state of the switch to True if on_check() returns True,
given the arguments provided in kwargs.
:param kwargs: variable length dictionary of key-pair arguments
:return: Boolean. Returns True if the operation is successful |
14,256 | def prior_to_xarray(self):
prior = self.prior
prior_model = self.prior_model
prior_predictive = self.prior_predictive
if prior_predictive is None:
prior_predictive = []
elif isinstance(prior_predictive, str):
prior_predictive = [p... | Convert prior samples to xarray. |
14,257 | def generate_em_constraint_data(mNS_min, mNS_max, delta_mNS, sBH_min, sBH_max, delta_sBH, eos_name, threshold, eta_default):
mNS_nsamples = complex(0,int(np.ceil((mNS_max-mNS_min)/delta_mNS)+1))
sBH_nsamples = complex(0,int(np.ceil((sBH_max-sBH_min)/delta_sBH)+1))
mNS_vec, sBH_vec = np.mgrid[... | Wrapper that calls find_em_constraint_data_point over a grid
of points to generate the bh_spin_z x ns_g_mass x eta surface
above which NS-BH binaries yield a remnant disk mass that
exceeds the threshold required by the user. The user must also
specify the default symmetric mass ratio value to be assign... |
14,258 | def memory_used(self):
if self._end_memory:
memory_used = self._end_memory - self._start_memory
return memory_used
else:
return None | To know the allocated memory at function termination.
..versionadded:: 4.1
This property might return None if the function is still running.
This function should help to show memory leaks or ram greedy code. |
14,259 | def casperjs_capture(stream, url, method=None, width=None, height=None,
selector=None, data=None, waitfor=None, size=None,
crop=None, render=, wait=None):
if isinstance(stream, six.string_types):
output = stream
else:
with NamedTemporaryFile(, suffi... | Captures web pages using ``casperjs`` |
14,260 | def _crossmatch_transients_against_catalogues(
self,
transientsMetadataListIndex,
colMaps):
global theseBatches
self.log.debug(
)
transientsMetadataList = theseBatches[transientsMetadataListIndex]
dbConn = database(
... | run the transients through the crossmatch algorithm in the settings file
**Key Arguments:**
- ``transientsMetadataListIndex`` -- the list of transient metadata lifted from the database.
- ``colMaps`` -- dictionary of dictionaries with the name of the database-view (e.g. `tcs_view_agn_m... |
14,261 | def request(
self,
url,
params=None,
data=None,
headers=None,
timeout=None,
auth=None,
cookiejar=None,
):
if headers is None:
headers = {}
if timeou... | Make a request to a url and retrieve the results.
If the headers parameter does not provide an 'User-Agent' key, one will
be added automatically following the convention:
py3status/<version> <per session random uuid>
:param url: url to request eg `http://example.com`
:para... |
14,262 | def _hex_to_dec(ip, check=True):
if check and not is_hex(ip):
raise ValueError( % ip)
if isinstance(ip, int):
ip = hex(ip)
return int(str(ip), 16) | Hexadecimal to decimal conversion. |
14,263 | def get_content(self, default=None):
tree = parse_string(self.book.get_template(self._template_name))
tree_root = tree.getroot()
tree_root.set(, self.lang or self.book.language)
tree_root.attrib[ % NAMESPACES[]] = self.lang or self.book.language
try... | Returns content for this document as HTML string. Content will be of type 'str' (Python 2)
or 'bytes' (Python 3).
:Args:
- default: Default value for the content if it is not defined.
:Returns:
Returns content of this document. |
14,264 | def _bcrypt_generate_pair(algorithm, bit_size=None, curve=None):
if algorithm == :
alg_constant = BcryptConst.BCRYPT_RSA_ALGORITHM
struct_type =
private_blob_type = BcryptConst.BCRYPT_RSAFULLPRIVATE_BLOB
public_blob_type = BcryptConst.BCRYPT_RSAPUBLIC_BLOB
elif algorithm ... | Generates a public/private key pair using CNG
:param algorithm:
The key algorithm - "rsa", "dsa" or "ec"
:param bit_size:
An integer - used for "rsa" and "dsa". For "rsa" the value maye be 1024,
2048, 3072 or 4096. For "dsa" the value may be 1024, plus 2048 or 3072
if on Window... |
14,265 | def __read_response(self, nblines=-1):
resp, code, data = (b"", None, None)
cpt = 0
while True:
try:
line = self.__read_line()
except Response as inst:
code = inst.code
data = inst.data
break
... | Read a response from the server.
In the usual case, we read lines until we find one that looks
like a response (OK|NO|BYE\s*(.+)?).
If *nblines* > 0, we read excactly nblines before returning.
:param nblines: number of lines to read (default : -1)
:rtype: tuple
:return... |
14,266 | def format_national_number_with_preferred_carrier_code(numobj, fallback_carrier_code):
if (numobj.preferred_domestic_carrier_code is not None and
len(numobj.preferred_domestic_carrier_code) > 0):
carrier_code = numobj.preferred_domestic_carrier_code
else:
carrier_code = fa... | Formats a phone number in national format for dialing using the carrier
as specified in the preferred_domestic_carrier_code field of the
PhoneNumber object passed in. If that is missing, use the
fallback_carrier_code passed in instead. If there is no
preferred_domestic_carrier_code, and the fallback_car... |
14,267 | def iri(uri_string):
uri_string = str(uri_string)
if uri_string[:1] == "?":
return uri_string
if uri_string[:1] == "[":
return uri_string
if uri_string[:1] != "<":
uri_string = "<{}".format(uri_string.strip())
if uri_string[len(uri_str... | converts a string to an IRI or returns an IRI if already formated
Args:
uri_string: uri in string format
Returns:
formated uri with <> |
14,268 | def _deserialize_value(cls, types, value):
if types.main == list and value is not None:
return cls._deserialize_list(types.sub, value)
else:
return cls.deserialize(types.main, value) | :type types: ValueTypes
:type value: int|str|bool|float|bytes|unicode|list|dict
:rtype: int|str|bool|float|bytes|unicode|list|dict|object |
14,269 | def set_matrix_dimensions(self, bounds, xdensity, ydensity):
self.bounds = bounds
self.xdensity = xdensity
self.ydensity = ydensity
scs = SheetCoordinateSystem(bounds, xdensity, ydensity)
for of in self.output_fns:
if isinstance(of, TransferFn):
... | Change the dimensions of the matrix into which the pattern
will be drawn. Users of this class should call this method
rather than changing the bounds, xdensity, and ydensity
parameters directly. Subclasses can override this method to
update any internal data structures that may depend ... |
14,270 | def transform(self, blocks, y=None):
feature_vecs = (
tuple(re.search(token, block.css[attrib]) is not None
for block in blocks)
for attrib, tokens in self.attribute_tokens
for token in tokens
)
return np.column_stack(tuple(featu... | Transform an ordered sequence of blocks into a 2D features matrix with
shape (num blocks, num features).
Args:
blocks (List[Block]): as output by :class:`Blockifier.blockify`
y (None): This isn't used, it's only here for API consistency.
Returns:
`np.ndarray... |
14,271 | def get_access_token(self, code):
payload = {: ,
: code,
: self._client_id,
: self._client_secret,
: self._redirect_uri,}
req = requests.post(settings.API_ACCESS_TOKEN_URL, data=payload)
data = req.json()
... | Returns Access Token retrieved from the Health Graph API Token
Endpoint following the login to RunKeeper.
to RunKeeper.
@param code: Code returned by Health Graph API at the Authorization or
RunKeeper Login phase.
@return: Access Token for querying the... |
14,272 | def walk(self, parent=None):
if parent is None:
yield self.root
parent = self.root
for cpage_name in parent.subpages:
cpage = self.__all_pages[cpage_name]
yield cpage
for page in self.walk(parent=cpage):
yield page | Generator that yields pages in infix order
Args:
parent: hotdoc.core.tree.Page, optional, the page to start
traversal from. If None, defaults to the root of the tree.
Yields:
hotdoc.core.tree.Page: the next page |
14,273 | def get_executions(self, **kwargs):
return self._client.service_executions(service=self.id, scope=self.scope_id, **kwargs) | Retrieve the executions related to the current service.
.. versionadded:: 1.13
:param kwargs: (optional) additional search keyword arguments to limit the search even further.
:type kwargs: dict
:return: list of ServiceExecutions associated to the current service. |
14,274 | def classify(self, dataset, missing_value_action=):
return super(BoostedTreesClassifier, self).classify(dataset,
missing_value_action=missing_value_action) | Return a classification, for each example in the ``dataset``, using the
trained boosted trees model. The output SFrame contains predictions
as class labels (0 or 1) and probabilities associated with the the example.
Parameters
----------
dataset : SFrame
Dataset of n... |
14,275 | def run(self):
with self.lock:
if self in self.device_manager._threads:
self.stream.close()
self.device_manager.thread_finished(self) | Plays the audio. This method plays the audio, and shouldn't be called
explicitly, let the constructor do so. |
14,276 | async def auth_crammd5(
self, username: str, password: str, timeout: DefaultNumType = _default
) -> SMTPResponse:
async with self._command_lock:
initial_response = await self.execute_command(
b"AUTH", b"CRAM-MD5", timeout=timeout
)
if ini... | CRAM-MD5 auth uses the password as a shared secret to MD5 the server's
response.
Example::
250 AUTH CRAM-MD5
auth cram-md5
334 PDI0NjA5LjEwNDc5MTQwNDZAcG9wbWFpbC5TcGFjZS5OZXQ+
dGltIGI5MTNhNjAyYzdlZGE3YTQ5NWI0ZTZlNzMzNGQzODkw |
14,277 | def get_tier(self, name_num):
return self.tiers[name_num - 1] if isinstance(name_num, int) else\
[i for i in self.tiers if i.name == name_num][0] | Gives a tier, when multiple tiers exist with that name only the
first is returned.
:param name_num: Name or number of the tier to return.
:type name_num: int or str
:returns: The tier.
:raises IndexError: If the tier doesn't exist. |
14,278 | def train(self, x=None, y=None, training_frame=None, offset_column=None, fold_column=None,
weights_column=None, validation_frame=None, max_runtime_secs=None, ignored_columns=None,
model_id=None, verbose=False):
self._train(x=x, y=y, training_frame=training_frame, offset_colu... | Train the H2O model.
:param x: A list of column names or indices indicating the predictor columns.
:param y: An index or a column name indicating the response column.
:param H2OFrame training_frame: The H2OFrame having the columns indicated by x and y (as well as any
additional colu... |
14,279 | def get_logger(name):
if name in loggers:
return loggers[name]
logger = logging.getLogger(name)
logger.propagate = False
pre1, suf1 = hash_coloured_escapes(name) if supports_color() else (, )
pre2, suf2 = hash_coloured_escapes(name + ) \
if supports_color() else (, )
... | Helper function to get a logger |
14,280 | def add_country_location(self, country, exact=True, locations=None, use_live=True):
iso3, match = Country.get_iso3_country_code_fuzzy(country, use_live=use_live)
if iso3 is None:
raise HDXError( % country)
return self.add_other_location(iso3, exact=exact,
... | Add a country. If an iso 3 code is not provided, value is parsed and if it is a valid country name,
converted to an iso 3 code. If the country is already added, it is ignored.
Args:
country (str): Country to add
exact (bool): True for exact matching or False to allow fuzzy match... |
14,281 | def remove_label(self, label, relabel=False):
self.remove_labels(label, relabel=relabel) | Remove the label number.
The removed label is assigned a value of zero (i.e.,
background).
Parameters
----------
label : int
The label number to remove.
relabel : bool, optional
If `True`, then the segmentation image will be relabeled
... |
14,282 | def reload(self, metadata, ignore_unsupported_plugins=True):
supported_plugins = self._supported_plugins
for plugin in metadata:
if not ignore_unsupported_plugins \
or plugin[] in supported_plugins:
self._plugins[plugin[]] = Lv2Plugin(plugin) | Loads the metadata. They will be used so that it is possible to generate lv2 audio plugins.
:param list metadata: lv2 audio plugins metadata
:param bool ignore_unsupported_plugins: Not allows instantiation of uninstalled or unrecognized audio plugins? |
14,283 | def append_query_parameter(url, parameters, ignore_if_exists=True):
if ignore_if_exists:
for key in parameters.keys():
if key + "=" in url:
del parameters[key]
parameters_str = "&".join(k + "=" + v for k, v in parameters.items())
append_token = "&" if "?" in url else... | quick and dirty appending of query parameters to a url |
14,284 | def remove_this_tlink(self,tlink_id):
for tlink in self.get_tlinks():
if tlink.get_id() == tlink_id:
self.node.remove(tlink.get_node())
break | Removes the tlink for the given tlink identifier
@type tlink_id: string
@param tlink_id: the tlink identifier to be removed |
14,285 | def _time_threaded_normxcorr(templates, stream, *args, **kwargs):
no_chans = np.zeros(len(templates))
chans = [[] for _ in range(len(templates))]
array_dict_tuple = _get_array_dicts(templates, stream)
stream_dict, template_dict, pad_dict, seed_ids = array_dict_tuple
cccsums = np.zeros([len(temp... | Use the threaded time-domain routine for concurrency
:type templates: list
:param templates:
A list of templates, where each one should be an obspy.Stream object
containing multiple traces of seismic data and the relevant header
information.
:type stream: obspy.core.stream.Stream
... |
14,286 | def more_statements(self, more_url):
if isinstance(more_url, StatementsResult):
more_url = more_url.more
more_url = self.get_endpoint_server_root() + more_url
request = HTTPRequest(
method="GET",
resource=more_url
)
lrs_response = s... | Query the LRS for more statements
:param more_url: URL from a StatementsResult object used to retrieve more statements
:type more_url: str | unicode
:return: LRS Response object with the returned StatementsResult object as content
:rtype: :class:`tincan.lrs_response.LRSResponse` |
14,287 | def indexTupleFromItem(self, treeItem):
if not treeItem:
return (QtCore.QModelIndex(), QtCore.QModelIndex())
if not treeItem.parentItem:
return (QtCore.QModelIndex(), QtCore.QModelIndex())
row = treeItem.childNumber()
return (self.... | Return (first column model index, last column model index) tuple for a configTreeItem |
14,288 | def get_imported_repo(self, import_path):
try:
session = requests.session()
session.mount("http://",
requests.adapters.HTTPAdapter(max_retries=self.get_options().retries))
page_data = session.get(.format(import_path=import_path))
except requests.Connectio... | Looks for a go-import meta tag for the provided import_path.
Returns an ImportedRepo instance with the information in the meta tag,
or None if no go-import meta tag is found. |
14,289 | def _save_documentation(version, base_url="https://spark.apache.org/docs"):
target_dir = join(dirname(__file__), , )
with open(join(target_dir, "spark_properties_{}.json".format(version)), ) as fp:
all_props = _fetch_documentation(version=version, base_url=base_url)
all_props = sorted(all_p... | Write the spark property documentation to a file |
14,290 | def set_main_wire(self, wire=None):
if not wire:
for k in dir(self):
if isinstance(getattr(self, k), Wire):
wire = getattr(self, k)
break
elif not isinstance(wire, Wire):
raise ValueError("wire needs to be a Wire ... | Sets the specified wire as the link's main wire
This is done automatically during the first wire() call
Keyword Arguments:
- wire (Wire): if None, use the first wire instance found
Returns:
- Wire: the new main wire instance |
14,291 | def dicom_read(directory, pixeltype=):
slices = []
imgidx = 0
for imgpath in os.listdir(directory):
if imgpath.endswith():
if imgidx == 0:
tmp = image_read(os.path.join(directory,imgpath), dimension=3, pixeltype=pixeltype)
origin = tmp.origin
... | Read a set of dicom files in a directory into a single ANTsImage.
The origin of the resulting 3D image will be the origin of the
first dicom image read.
Arguments
---------
directory : string
folder in which all the dicom images exist
Returns
-------
ANTsImage
Example
... |
14,292 | def consultar_status_operacional(self):
resp = self._http_post()
conteudo = resp.json()
return RespostaConsultarStatusOperacional.analisar(
conteudo.get()) | Sobrepõe :meth:`~satcfe.base.FuncoesSAT.consultar_status_operacional`.
:return: Uma resposta SAT especializada em ``ConsultarStatusOperacional``.
:rtype: satcfe.resposta.consultarstatusoperacional.RespostaConsultarStatusOperacional |
14,293 | def imfill(immsk):
immsk
for iz in range(immsk.shape[0]):
for iy in range(immsk.shape[1]):
ix0 = np.argmax(immsk[iz,iy,:]>0)
ix1 = immsk.shape[2] - np.argmax(immsk[iz,iy,::-1]>0)
if (ix1-ix0) > immsk.shape[2]-10: continue
immsk[iz,iy,ix0:ix1] = 1
retu... | fill the empty patches of image mask 'immsk' |
14,294 | def ImportFile(store, filename, start):
with io.open(filename, "r") as fp:
reader = csv.Reader(fp.read())
i = 0
current_row = None
product_code_list = []
op_system_code_list = []
for row in reader:
i += 1
if i and i % 5000 == 0:
data_store.DB.Flush()
print... | Import hashes from 'filename' into 'store'. |
14,295 | def _printer(self, *out, **kws):
flush = kws.pop(, True)
fileh = kws.pop(, self.writer)
sep = kws.pop(, )
end = kws.pop(, )
print(*out, file=fileh, sep=sep, end=end)
if flush:
fileh.flush() | Generic print function. |
14,296 | def addLOADDEV(rh):
rh.printSysLog("Enter changeVM.addLOADDEV")
if ( in rh.parms and not in rh.parms):
msg = msgs.msg[][1] % (modId, "scpData", "scpDataType")
rh.printLn("ES", msg)
rh.updateResults(msgs.msg[][0])
return
if ( in rh.parms and not in rh.parms):
... | Sets the LOADDEV statement in the virtual machine's directory entry.
Input:
Request Handle with the following properties:
function - 'CHANGEVM'
subfunction - 'ADDLOADDEV'
userid - userid of the virtual machine
parms['boot'] - Boot program number
... |
14,297 | def _reset(self, command, *args, **kwargs):
if self.indexable:
self.deindex()
result = self._traverse_command(command, *args, **kwargs)
if self.indexable:
self.index()
return result | Shortcut for commands that reset values of the field.
All will be deindexed and reindexed. |
14,298 | def draw_key(self, surface, key):
if isinstance(key, VSpaceKey):
self.draw_space_key(surface, key)
elif isinstance(key, VBackKey):
self.draw_back_key(surface, key)
elif isinstance(key, VUppercaseKey):
self.draw_uppercase_key(surface, key)
elif... | Default drawing method for key.
Draw the key accordingly to it type.
:param surface: Surface background should be drawn in.
:param key: Target key to be drawn. |
14,299 | def parse_wait_time(text: str) -> int:
val = RATELIMIT.findall(text)
if len(val) > 0:
try:
res = val[0]
if res[1] == :
return int(res[0]) * 60
if res[1] == :
return int(res[0])
except Exception as e:
util_logge... | Parse the waiting time from the exception |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.