Unnamed: 0 int64 0 389k | code stringlengths 26 79.6k | docstring stringlengths 1 46.9k |
|---|---|---|
388,500 | def adjust_prior(self, index, prior):
self.latent_variables.adjust_prior(index=index, prior=prior) | Adjusts priors for the latent variables
Parameters
----------
index : int or list[int]
Which latent variable index/indices to be altered
prior : Prior object
Which prior distribution? E.g. Normal(0,1)
Returns
----------
None (changes pri... |
388,501 | def resize_volume(self, volumeObj, sizeInGb, bsize=1000):
current_vol = self.get_volume_by_id(volumeObj.id)
if current_vol.size_kb > (sizeInGb * bsize * bsize):
raise RuntimeError(
"resize_volume() - New size needs to be bigger than: %d KBs" % current_vol.size_kb)
... | Resize a volume to new GB size, must be larger than original.
:param volumeObj: ScaleIO Volume Object
:param sizeInGb: New size in GB (have to be larger than original)
:param bsize: 1000
:return: POST request response
:rtype: Requests POST response object |
388,502 | def run_on(*, event: str):
def decorator(callback):
@functools.wraps(callback)
def decorator_wrapper():
RTMClient.on(event=event, callback=callback)
return decorator_wrapper()
return decorator | A decorator to store and link a callback to an event. |
388,503 | def _get_parser(extra_args):
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
dirs = appdirs.AppDirs(, )
default_token_path = os.path.join(dirs.user_cache_dir, )
parser.add_argument(
, default=default_token_path,
help=
)
... | Return ArgumentParser with any extra arguments. |
388,504 | def get_codemirror_parameters(self, name):
config = self.get_config(name)
return {k: config[k] for k in config if k not in self._internal_only} | Return CodeMirror parameters for given configuration name.
This is a reduced configuration from internal parameters.
Arguments:
name (string): Config name from available ones in
``settings.CODEMIRROR_SETTINGS``.
Returns:
dict: Parameters. |
388,505 | def show_driver(devname):
*
try:
module = ethtool.get_module(devname)
except IOError:
log.error(, devname)
return
try:
businfo = ethtool.get_businfo(devname)
except IOError:
log.error(, devname)
return
ret = {
: module,
: busin... | Queries the specified network device for associated driver information
CLI Example:
.. code-block:: bash
salt '*' ethtool.show_driver <devname> |
388,506 | def unorm(data, ord=None, axis=None, keepdims=False):
norm = np.linalg.norm(data, ord=ord, axis=axis, keepdims=keepdims)
if norm.shape == ():
return unyt_quantity(norm, data.units)
return unyt_array(norm, data.units) | Matrix or vector norm that preserves units
This is a wrapper around np.linalg.norm that preserves units. See
the documentation for that function for descriptions of the keyword
arguments.
Examples
--------
>>> from unyt import km
>>> data = [1, 2, 3]*km
>>> print(unorm(data))
3.741... |
388,507 | def prepare_adiabatic_limit(slh, k=None):
if k is None:
k = symbols(, positive=True)
Ld = slh.L.dag()
LdL = (Ld * slh.L)[0, 0]
K = (-LdL / 2 + I * slh.H).expand().simplify_scalar()
N = slh.S.dag()
B, A, Y = K.series_expand(k, 0, 2)
G, F = Ld.series_expand(k, 0, 1)
return Y,... | Prepare the adiabatic elimination on an SLH object
Args:
slh: The SLH object to take the limit for
k: The scaling parameter $k \rightarrow \infty$. The default is a
positive symbol 'k'
Returns:
tuple: The objects ``Y, A, B, F, G, N``
necessary to compute the limitin... |
388,508 | def request(self, url, method = u"get", data = None, headers = None, **kwargs):
url, method, data, headers, kwargs = self._pre_request(url,
method=method,
data=data,
... | public method for doing the live request |
388,509 | def _parse_typed_parameter_typed_value(values):
type_, value = _expand_one_key_dictionary(values)
_current_parameter_value.type = type_
if _is_simple_type(value):
arg = Argument(value)
_current_parameter_value.add_argument(arg)
elif isinstance(value, list):
for idx in value... | Creates Arguments in a TypedParametervalue. |
388,510 | def msg(cls, error=None, debug=True, trace=True):
if debug and error is not None:
print(error)
if trace:
print(traceback.format_exc()) | prints the error message
:param error: the error message
:param debug: only prints it if debug is set to true
:param trace: if true prints the trace
:return: |
388,511 | def src2ast(src: str) -> Expression:
try:
return ast.parse(src, mode=)
except SyntaxError:
raise ValueError("Not a valid expression.") from None | Return ast.Expression created from source code given in `src`. |
388,512 | def take_snapshot(obj, store=True, **kw):
logger.debug("📷 Take new snapshot for {}".format(repr(obj)))
snapshot = get_object_data(obj)
metadata = get_object_metadata(obj, **kw)
snapshot["__metadata__"] = metadata
data = json.dumps(snapshot)
if not store:
... | Takes a snapshot of the passed in object
:param obj: Content object
:returns: New snapshot |
388,513 | async def _set_rev_reg(self, rr_id: str, rr_size: int) -> None:
LOGGER.debug(, rr_id, rr_size)
assert self.rrbx
dir_hopper_rr_id = join(self.rrb.dir_tails_hopper, rr_id)
while Tails.linked(dir_hopper_rr_id, rr_id) is None:
await asyncio.sleep(1)
await self... | Move precomputed revocation registry data from hopper into place within tails directory.
:param rr_id: revocation registry identifier
:param rr_size: revocation registry size, in case creation required |
388,514 | def do_state_tomography(preparation_program, nsamples, cxn, qubits=None, use_run=False):
return tomography._do_tomography(preparation_program, nsamples, cxn, qubits,
tomography.MAX_QUBITS_STATE_TOMO,
StateTomography, state_tomography_pro... | Method to perform both a QPU and QVM state tomography, and use the latter as
as reference to calculate the fidelity of the former.
:param Program preparation_program: Program to execute.
:param int nsamples: Number of samples to take for the program.
:param QVMConnection|QPUConnection cxn: Connection o... |
388,515 | def fix_chrome_mac_platform(platform):
ver = platform.split()[1]
build_range = range(*MACOSX_CHROME_BUILD_RANGE[ver])
build = choice(build_range)
mac_ver = ver.replace(, ) + + str(build)
return % mac_ver | Chrome on Mac OS adds minor version number and uses underscores instead
of dots. E.g. platform for Firefox will be: 'Intel Mac OS X 10.11'
but for Chrome it will be 'Intel Mac OS X 10_11_6'.
:param platform: - string like "Macintosh; Intel Mac OS X 10.8"
:return: platform with version number including ... |
388,516 | def sub_template(template,template_tag,substitution):
template = template.replace(template_tag,substitution)
return template | make a substitution for a template_tag in a template |
388,517 | def BuildCampaignOperations(batch_job_helper,
budget_operations, number_of_campaigns=1):
budget_id = budget_operations[0][][]
campaign_operations = [
{
: ,
: {
: % uuid.uuid4(),
... | Builds the operations needed to create a new Campaign.
Note: When the Campaigns are created, they will have a different Id than those
generated here as a temporary Id. This is just used to identify them in the
BatchJobService.
Args:
batch_job_helper: a BatchJobHelper instance.
budget_operations: a lis... |
388,518 | def get_interface_detail_output_interface_if_state(self, **kwargs):
config = ET.Element("config")
get_interface_detail = ET.Element("get_interface_detail")
config = get_interface_detail
output = ET.SubElement(get_interface_detail, "output")
interface = ET.SubElement(outp... | Auto Generated Code |
388,519 | def expand_path(path):
paths = []
path = os.path.expanduser(path)
path = os.path.expandvars(path)
if os.path.isdir(path):
for (dir, dirs, files) in os.walk(path):
for file in files:
paths.append(os.path.join(dir, file))
else:
paths.extend(glob(path... | Expands directories and globs in given path. |
388,520 | def render(self, *args, **kwargs):
r = []
if self.doctype:
r.append(self.doctype)
r.append()
r.append(super(document, self).render(*args, **kwargs))
return u.join(r) | Creates a <title> tag if not present and renders the DOCTYPE and tag tree. |
388,521 | def callback(self, provider):
provider = self.get_provider(provider)
try:
return provider.authorized_handler(self.login)(provider=provider)
except OAuthException as ex:
logging.error("Data: %s", ex.data)
raise | Handles 3rd party callback and processes it's data |
388,522 | def get(self, sid):
return SigningKeyContext(self._version, account_sid=self._solution[], sid=sid, ) | Constructs a SigningKeyContext
:param sid: The sid
:returns: twilio.rest.api.v2010.account.signing_key.SigningKeyContext
:rtype: twilio.rest.api.v2010.account.signing_key.SigningKeyContext |
388,523 | def extract_concepts(self, sentences=None, ids=None,
composite_phrase=4, filename=None,
file_format=, allow_acronym_variants=False,
word_sense_disambiguation=False, allow_large_n=False,
strict_model=False, relaxed_model=... | extract_concepts takes a list of sentences and ids(optional)
then returns a list of Concept objects extracted via
MetaMap.
Supported Options:
Composite Phrase -Q
Word Sense Disambiguation -y
use strict model -A
use rela... |
388,524 | def update_data(self):
time_elapsed = datetime.datetime.now() - self.start_time
crntTemp = self.roaster.current_temp
targetTemp = self.roaster.target_temp
heaterLevel = self.roaster.heater_level
self.file.write(
"%4.6f,%d,%d,%d\n" %... | This is a method that will be called every time a packet is opened
from the roaster. |
388,525 | def _as_published_topic(self):
oop = self.get_operator_output_port()
if not hasattr(oop, ):
return
export = oop.export
if export[] != :
return
seen_export_type = False
topic = None
for p in export[]:
if p[] != :
... | This stream as a PublishedTopic if it is published otherwise None |
388,526 | def _vmomentsurfaceIntegrand(vz,vR,vT,R,z,df,sigmaR1,gamma,sigmaz1,n,m,o):
return vR**n*vT**m*vz**o*df(R,vR*sigmaR1,vT*sigmaR1*gamma,z,vz*sigmaz1,
use_physical=False) | Internal function that is the integrand for the vmomentsurface mass integration |
388,527 | def main():
r = Random(42)
startSerializationTime = time.time()
for i in xrange(_SERIALIZATION_LOOPS):
builderProto = RandomProto.new_message()
r.write(builderProto)
elapsedSerializationTime = time.time() - startSerializationTime
builderBytes = builderProto.to_bytes()
... | Measure capnp serialization performance of Random |
388,528 | def delete(queue, items):
with _conn(commit=True) as cur:
if isinstance(items, dict):
cmd = str().format(
queue,
salt.utils.json.dumps(items))
log.debug(, cmd)
cur.execute(cmd)
return True
if isinstance(items, lis... | Delete an item or items from a queue |
388,529 | def load_config():
configfile = get_configfile()
if not os.path.exists(configfile):
data = {
:
}
save_config(data)
with open(configfile, ) as f:
return json.load(f) | Load configuration file containing API KEY and other settings.
:rtype: str |
388,530 | def insertFromMimeData(self, source):
lines = projex.text.nativestring(source.text()).splitlines()
for i in range(1, len(lines)):
if not lines[i].startswith():
lines[i] = + lines[i]
if len(lines) > 1:
lines.append()
... | Inserts the information from the inputed source.
:param source | <QMimeData> |
388,531 | def _get_mapping_for_table(self, table):
for mapping in self.mappings.values():
if mapping["table"] == table:
return mapping | Returns the first mapping for a table name |
388,532 | def __focus(self, item):
cols = self.__get_display_columns()
for col in cols:
self.__event_info =(col,item)
self.event_generate()
if col in self._inplace_widgets:
w = self._inplace_widgets[col]
w.bind(,
lamb... | Called when focus item has changed |
388,533 | def print_(*objects, **kwargs):
sep = kwargs.get("sep")
sep = sep if sep is not None else " "
end = kwargs.get("end")
end = end if end is not None else "\n"
file = kwargs.get("file")
file = file if file is not None else sys.stdout
flush = bool(kwargs.get("flush", False))
if is_win... | print_(*objects, sep=None, end=None, file=None, flush=False)
Args:
objects (object): zero or more objects to print
sep (str): Object separator to use, defaults to ``" "``
end (str): Trailing string to use, defaults to ``"\\n"``.
If end is ``"\\n"`` then `os.linesep` is used.
... |
388,534 | def _merge_outfile_fname(out_file, bam_files, work_dir, batch):
if out_file is None:
out_file = os.path.join(work_dir, os.path.basename(sorted(bam_files)[0]))
if batch is not None:
base, ext = os.path.splitext(out_file)
out_file = "%s-b%s%s" % (base, batch, ext)
return out_file | Derive correct name of BAM file based on batching. |
388,535 | def extractValue(self, model, item):
certPath = super(CertificateColumn, self).extractValue(model, item)
return certPath.path.decode(, ) | Get the path referenced by this column's attribute.
@param model: Either a TabularDataModel or a ScrollableView, depending
on what this column is part of.
@param item: A port item instance (as defined by L{xmantissa.port}).
@rtype: C{unicode} |
388,536 | def Refresh():
try:
GdbCache.DICT = gdb.lookup_type().pointer()
GdbCache.TYPE = gdb.lookup_type().pointer()
except gdb.error as err:
pass
interp_head_name = GdbCache.FuzzySymbolLookup()
if interp_head_name:
GdbCache.INTERP_HEAD = gdb.parse_and_eval(interp_head_name)
... | looks up symbols within the inferior and caches their names / values.
If debugging information is only partial, this method does its best to
find as much information as it can, validation can be done using
IsSymbolFileSane. |
388,537 | def __mark(self, element, mark_set):
try:
original = self.__elements.pop(element)
mark_set.add(original)
except KeyError:
return False
else:
if not self.__elements:
self.__call()
... | Marks an element
:param element: The element to mark
:param mark_set: The set corresponding to the mark
:return: True if the element was known |
388,538 | def data_transforms_mnist(args, mnist_mean=None, mnist_std=None):
if mnist_mean is None:
mnist_mean = [0.5]
if mnist_std is None:
mnist_std = [0.5]
train_transform = transforms.Compose(
[
transforms.RandomCrop(28, padding=4),
transforms.RandomHorizontal... | data_transforms for mnist dataset |
388,539 | def sign_statement(self, statement, node_name, key_file, node_id, id_attr):
if isinstance(statement, SamlBase):
statement = str(statement)
_, fil = make_temp(
statement,
suffix=,
decode=False,
delete=self._xmlsec_delete_tmpfiles,
... | Sign an XML statement.
:param statement: The statement to be signed
:param node_name: string like 'urn:oasis:names:...:Assertion'
:param key_file: The file where the key can be found
:param node_id:
:param id_attr: The attribute name for the identifier, normally one of
... |
388,540 | def get_core_name_without_suffix(file_path):
if in file_path:
file_path = file_path.replace(, )
file_name = os.path.basename(file_path)
core_names = file_name.split()
if len(core_names) > 1:
core_names = core_names[:-1]
if isinstance(cor... | Return core file name without suffix.
Examples:
>>> FileClass.get_core_name_without_suffix(r'/home/zhulj/1990.01.30/test.01.tif')
'test.01'
>>> FileClass.get_core_name_without_suffix(r'C:\zhulj\igsnrr\lreis.txt')
'lreis'
>>> FileClass.get_core_name_wi... |
388,541 | def concatenate(ctx, *text):
result =
for arg in text:
result += conversions.to_string(arg, ctx)
return result | Joins text strings into one text string |
388,542 | def encode_string(data, encoding=):
hex
if six.PY2:
return data.encode(encoding)
else:
if isinstance(data, str):
data = bytes(data, )
return codecs.encode(data, encoding).decode() | Encode string
:param data: string to encode
:param encoding: encoding to use (default: 'hex')
:return: encoded string |
388,543 | def find(self, nameFilter=None, typeFilter=None, bindingModeFilter=None, boundFilter=None):
queryParms = {}
if nameFilter:
queryParms["name"] = nameFilter
if typeFilter:
queryParms["type"] = typeFilter
if bindingModeFilter:
queryParms["bindin... | Gets the list of services that the Watson IoT Platform can connect to.
The list can include a mixture of services that are either bound or unbound.
Parameters:
- nameFilter(string) - Filter the results by the specified name
- typeFilter(string) - Filter the res... |
388,544 | def create(cls, cash_register_id, tab_uuid, description,
monetary_account_id=None, ean_code=None,
avatar_attachment_uuid=None, tab_attachment=None, quantity=None,
amount=None, custom_headers=None):
if custom_headers is None:
custom_headers = {}
... | Create a new TabItem for a given Tab.
:type user_id: int
:type monetary_account_id: int
:type cash_register_id: int
:type tab_uuid: str
:param description: The TabItem's brief description. Can't be empty and
must be no longer than 100 characters
:type description... |
388,545 | def hazeDriver():
try:
(command, args) = findSubCommand(sys.argv)
if os.path.basename(command) == "haze":
print "Could not find a subcommand for %s" % " ".join(sys.argv)
sys.exit(1)
except StandardError:
print "Could not find a subcommand for %s" % " ".join(sys.argv)
sys.ex... | Process the command line arguments and run the appropriate haze subcommand.
We want to be able to do git-style handoffs to subcommands where if we
do `haze aws foo bar` and the executable haze-aws-foo exists, we'll call
it with the argument bar.
We deliberately don't do anything with the arguments other than ... |
388,546 | def bump_version(version, bump=):
try:
parts = map(int, version.split())
except ValueError:
fail()
if bump == :
parts[2] += 1
elif bump == :
parts[1] += 1
parts[2] = 0
elif bump == :
parts[0] +=1
parts[1] = 0
parts[2] = 0
ret... | patch: patch, minor, major |
388,547 | def get_glibc_version():
try:
out = subprocess.Popen([, ],
stdout=subprocess.PIPE).communicate()[0]
except OSError:
return
match = re.search(, out)
try:
return map(int, match.groups())
except AttributeError:
return | Returns:
Version as a pair of ints (major, minor) or None |
388,548 | def refresh(self, module=None):
module = module._mdl if module is not None else ffi.NULL
lib.EnvRefreshAgenda(self._env, module) | Recompute the salience values of the Activations on the Agenda
and then reorder the agenda.
The Python equivalent of the CLIPS refresh-agenda command.
If no Module is specified, the current one is used. |
388,549 | def commit_manually(using=None):
def entering(using):
enter_transaction_management(using=using)
def exiting(exc_value, using):
leave_transaction_management(using=using)
return _transaction_func(entering, exiting, using) | Decorator that activates manual transaction control. It just disables
automatic transaction control and doesn't do any commit/rollback of its
own -- it's up to the user to call the commit and rollback functions
themselves. |
388,550 | def UpdateStatus(self, is_complete):
status = if is_complete else
transferred = os.path.getsize(self.props[TRANSFER_IFACE][])
self.props[TRANSFER_IFACE][] = status
self.props[TRANSFER_IFACE][] = dbus.UInt64(transferred, variant_level=1)
self.EmitSignal(dbus.PROPERTIES_IFACE, , , [
T... | Mock method to update the transfer status.
If is_complete is False, this marks the transfer is active; otherwise it
marks the transfer as complete. It is an error to call this method after
calling it with is_complete as True.
In both cases, it updates the number of bytes transferred to be the current
... |
388,551 | def alter_object(self, obj):
for attname, field, replacer in self.replacers:
currentval = getattr(obj, attname)
replacement = replacer(self, obj, field, currentval)
setattr(obj, attname, replacement) | Alters all the attributes in an individual object.
If it returns False, the object will not be saved |
388,552 | def check(self):
if not self.is_valid:
raise PolyaxonDeploymentConfigError(
.format(self.deployment_type))
check = False
if self.is_kubernetes:
check = self.check_for_kubernetes()
elif self.is_docker_compose:
check = self.check... | Add platform specific checks |
388,553 | def invalidate(self, name):
with self.__instances_lock:
try:
stored_instance = self.__instances[name]
except KeyError:
raise ValueError(
"Unknown component instance ".format(name)
)
else:
... | Invalidates the given component
:param name: Name of the component to invalidate
:raise ValueError: Invalid component name |
388,554 | def gather(self, cmd):
if not isinstance(cmd, list):
cmd_list = shlex.split(cmd)
else:
cmd_list = cmd
cwd = pushd.Dir.getcwd()
cmd_info = .format(cwd, cmd_list)
self.logger.debug("Executing:gather {}".format(cmd_info))
proc = subprocess... | Runs a command and returns rc,stdout,stderr as a tuple.
If called while the `Dir` context manager is in effect, guarantees that the
process is executed in that directory, even if it is no longer the current
directory of the process (i.e. it is thread-safe).
:param cmd: The command and ... |
388,555 | def identifyApplication(self, unProcessId, pchAppKey):
fn = self.function_table.identifyApplication
result = fn(unProcessId, pchAppKey)
return result | Identifies a running application. OpenVR can't always tell which process started in response
to a URL. This function allows a URL handler (or the process itself) to identify the app key
for the now running application. Passing a process ID of 0 identifies the calling process.
The application m... |
388,556 | def _create_filter(self):
self._product_filter = {}
for chip in itertools.chain(iter(self._family.targets(self._tile.short_name)),
iter([self._family.platform_independent_target()])):
for key, prods in chip.property(, {}).items():
... | Create a filter of all of the dependency products that we have selected. |
388,557 | def Serialize(self, writer):
writer.WriteVarBytes(self.Script)
writer.WriteVarBytes(self.ParameterList)
writer.WriteByte(self.ReturnType) | Serialize full object.
Args:
writer (neo.IO.BinaryWriter): |
388,558 | def _generate_typevars(self):
self.emit("T = TypeVar(, bound=bb.AnnotationType)")
self.emit("U = TypeVar()")
self.import_tracker._register_typing_import()
self.emit() | Creates type variables that are used by the type signatures for
_process_custom_annotations. |
388,559 | def run_samtools(align_bams, items, ref_file, assoc_files, region=None,
out_file=None):
return shared_variantcall(_call_variants_samtools, "samtools", align_bams, ref_file,
items, assoc_files, region, out_file) | Detect SNPs and indels with samtools mpileup and bcftools. |
388,560 | def project_decrease_permissions(object_id, input_params={}, always_retry=True, **kwargs):
return DXHTTPRequest( % object_id, input_params, always_retry=always_retry, **kwargs) | Invokes the /project-xxxx/decreasePermissions API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Project-Permissions-and-Sharing#API-method%3A-%2Fproject-xxxx%2FdecreasePermissions |
388,561 | def _add_reference(self, obj, ident=0):
log_debug(
"
len(self.references) + self.BASE_REFERENCE_IDX,
type(obj).__name__,
repr(obj),
),
ident,
)
self.references.append(obj) | Adds a read reference to the marshaler storage
:param obj: Reference to add
:param ident: Log indentation level |
388,562 | def _process_message(self, message: amqp.Message) -> None:
if self.shutdown_pending.is_set():
return
try:
if isinstance(message.body, bytes):
message.body = message.body.decode()
description = json.loads(message.body)
except Exception... | Processes the message received from the queue. |
388,563 | def change_wavelength(self, wavelength):
for name, slab in self.slabs.items():
const_args = slab._const_args
mat_args = slab._mat_params
const_args[8] = wavelength
s = Slab(*const_args)
for mat_arg in mat_args:
s.add_material... | Changes the wavelength of the structure.
This will affect the mode solver and potentially
the refractive indices used (provided functions
were provided as refractive indices).
Args:
wavelength (float): The new wavelength. |
388,564 | def set_perms(path,
grant_perms=None,
deny_perms=None,
inheritance=True,
reset=False):
userpermsbasic_permissionuserpermsfull_controlapplies_tothis_folderuserpermsread_attributesread_eaapplies_tothis_folderUsersread & execute*Userspermsread_executeUserspermsre... | Set permissions for the given path
Args:
path (str):
The full path to the directory.
grant_perms (dict):
A dictionary containing the user/group and the basic permissions to
grant, ie: ``{'user': {'perms': 'basic_permission'}}``. You can also
set the... |
388,565 | def group_by_month(self):
data_by_month = OrderedDict()
for d in xrange(1, 13):
data_by_month[d] = []
for v, dt in zip(self._values, self.datetimes):
data_by_month[dt.month].append(v)
return data_by_month | Return a dictionary of this collection's values grouped by each month.
Key values are between 1-12. |
388,566 | def require_iterable_of(objs, types, name=None, type_name=None, truncate_at=80):
try:
if all(isinstance(obj, types) for obj in objs):
return
except TypeError:
require_instance(objs, list, name, "iterable", truncate_at)
| Raise an exception if objs is not an iterable with each element an instance
of one of the specified types.
See `require_instance` for descriptions of the other parameters. |
388,567 | def delete_attachment(self, attachment):
parent = None
if attachment.getLinkedRequests():
parent = attachment.getRequest()
elif attachment.getLinkedAnalyses():
parent = attachment.getAnalysis()
if parent is None:
... | Delete attachment from the AR or Analysis
The attachment will be only deleted if it is not further referenced by
another AR/Analysis. |
388,568 | def change_port_speed(self, instance_id, public, speed):
if public:
return self.client.call(, ,
speed, id=instance_id)
else:
return self.client.call(, ,
speed, id=instance_id) | Allows you to change the port speed of a virtual server's NICs.
Example::
#change the Public interface to 10Mbps on instance 12345
result = mgr.change_port_speed(instance_id=12345,
public=True, speed=10)
# result will be True or an Ex... |
388,569 | def _add_fold_decoration(self, block, region):
deco = TextDecoration(block)
deco.signals.clicked.connect(self._on_fold_deco_clicked)
deco.tooltip = region.text(max_lines=25)
deco.draw_order = 1
deco.block = block
deco.select_line()
deco.set_outline(drift_... | Add fold decorations (boxes arround a folded block in the editor
widget). |
388,570 | def zoom_to(self, zoomlevel, no_reset=False):
scale_x, scale_y = self.zoom.calc_scale(zoomlevel)
self._scale_to(scale_x, scale_y, no_reset=no_reset) | Set zoom level in a channel.
This only changes the relevant settings; The image is not modified.
Also see :meth:`scale_to`.
.. note::
In addition to the given zoom level, other zoom settings are
defined for the channel in preferences.
Parameters
-------... |
388,571 | def import_device(self, directory):
with open(os.path.join(directory, "device.json"), "r") as f:
ddata = json.load(f)
d = self[ddata["name"]]
dname = ddata["name"]
del ddata["name"]
if dname == "meta":
return
elif dname == "us... | Imports a device from the given directory. You export the device
by using device.export()
There are two special cases: user and meta devices.
If the device name is meta, import_device will not do anything.
If the device name is "user", import_device will overwrite the user device
... |
388,572 | def deployed_devices(self):
if self._deployed_devices is None:
self._deployed_devices = DeployedDevices(self)
return self._deployed_devices | :returns: Version deployed_devices of preview
:rtype: twilio.rest.preview.deployed_devices.DeployedDevices |
388,573 | def get_distribution(self, name):
result = None
name = name.lower()
if not self._cache_enabled:
for dist in self._yield_distributions():
if dist.key == name:
result = dist
break
else:
self._generate_... | Looks for a named distribution on the path.
This function only returns the first result found, as no more than one
value is expected. If nothing is found, ``None`` is returned.
:rtype: :class:`InstalledDistribution`, :class:`EggInfoDistribution`
or ``None`` |
388,574 | def get_root_modules():
ip = get_ipython()
if in ip.db:
return ip.db[]
t = time()
store = False
modules = list(sys.builtin_module_names)
for path in sys.path:
modules += module_list(path)
if time() - t >= TIMEOUT_STORAGE and not store:
store = True
... | Returns a list containing the names of all the modules available in the
folders of the pythonpath. |
388,575 | def match_criterion(self, tag):
return tag.name == self.reference_tag_name and \
tag.attrs.get(, ) == self.reference_tag_kind | Override. Determine if a tag has the desired name and kind attribute
value.
Args:
tag: A BeautifulSoup Tag.
Returns:
True if tag has the desired name and kind, otherwise False. |
388,576 | def dbRestore(self, db_value, context=None):
if db_value is not None:
return yaml.load(projex.text.nativestring(db_value))
else:
return db_value | Converts a stored database value to Python.
:param py_value: <variant>
:param context: <orb.Context>
:return: <variant> |
388,577 | def _append_value(self, v_values, next_value, v_idx=None, n_vals=1):
for _ in range(n_vals):
if v_idx:
try:
v_i = next(v_idx)
except StopIteration:
if next_value is not None:
... | Update a list of parsed values with a new value. |
388,578 | def _get_queue(self):
if self._queue is None:
self._links = []
queue, depth = self._resolve_queue(self.queue, links=self._links)
if queue is None and depth > 0:
raise QueueLinkBroken
self._queue = queue
return self._queue | Gets the actual location of the queue, or None. |
388,579 | def _expectation(p, rbf_kern, feat1, lin_kern, feat2, nghp=None):
if rbf_kern.on_separate_dims(lin_kern) and isinstance(p, DiagonalGaussian):
eKxz1 = expectation(p, (rbf_kern, feat1))
eKxz2 = expectation(p, (lin_kern, feat2))
return eKxz1[:, :, None] * eKxz2[:, None, :]
if feat1 ... | Compute the expectation:
expectation[n] = <Ka_{Z1, x_n} Kb_{x_n, Z2}>_p(x_n)
- K_lin_{.,.} :: RBF kernel
- K_rbf_{.,.} :: Linear kernel
Different Z1 and Z2 are handled if p is diagonal and K_lin and K_rbf have disjoint
active_dims, in which case the joint expectations simplify into a product... |
388,580 | def getNameFromPath(filePath):
if len(filePath) == 0:
raise ValueError("Cannot have empty path for name")
fileName = os.path.split(os.path.normpath(filePath))[1]
ret = fileName.split(".")[0]
assert ret != ""
return ret | Returns the filename of the specified path without its extensions.
This is usually how we derive the default name for a given object. |
388,581 | def _execute(self, *args):
command = (
[
,
% self.config_filename,
]
+ self.get_configuration_override_args()
+ [six.text_type(arg) for arg in args]
)
for i in range(len(command)):
... | Execute a given taskwarrior command with arguments
Returns a 2-tuple of stdout and stderr (respectively). |
388,582 | def set_ylabel(self, s, delay_draw=False):
"set plot ylabel"
self.conf.relabel(ylabel=s, delay_draw=delay_draw) | set plot ylabel |
388,583 | def autoconfig_url_from_preferences():
if not ON_DARWIN:
raise NotDarwinError()
try:
config = SystemConfiguration.SCDynamicStoreCopyProxies(None)
except AttributeError:
return
if all(( in config,
in config,
not config.get(, 0))):
... | Get the PAC ``AutoConfigURL`` value from the macOS System Preferences.
This setting is visible as the "URL" field in
System Preferences > Network > Advanced... > Proxies > Automatic Proxy Configuration.
:return: The value from the registry, or None if the value isn't configured or available.
N... |
388,584 | def getPositionFromState(pState):
result = dict()
for (varName, value) in pState[].iteritems():
result[varName] = value[]
return result | Return the position of a particle given its state dict.
Parameters:
--------------------------------------------------------------
retval: dict() of particle position, keys are the variable names,
values are their positions |
388,585 | def _normalised_numpy(self):
dx = (self.screen.width / float(len(self.points)))
oy = (self.screen.height)
points = np.array(self.points) - self.minimum
points = points * 4.0 / self.extents * self.size.y
for x, y in enumerate(points):
yield Point((
... | Normalised data points using numpy. |
388,586 | def instantiateSong(fileName):
ext = detectFormat(fileName)
if(ext == "mp3"):
return pd.AudioSegment.from_mp3(fileName)
elif(ext == "wav"):
return pd.AudioSegment.from_wav(fileName)
elif(ext == "ogg"):
return pd.AudioSegment.from_ogg(fileName)
elif(ext == "flv"):
... | Create an AudioSegment with the data from the given file |
388,587 | def CheckFile(self, path):
print(.format(path))
definitions_registry = registry.DataTypeDefinitionsRegistry()
definitions_reader = reader.YAMLDataTypeDefinitionsFileReader()
result = False
try:
definitions_reader.ReadFile(definitions_registry, path)
result = True
except KeyEr... | Validates the definition in a file.
Args:
path (str): path of the definition file.
Returns:
bool: True if the file contains valid definitions. |
388,588 | def county_state_alerts(self, county, state):
samecode = self.geo.lookup_samecode(county, state)
return self.samecode_alerts(samecode) | Given a county and state, return alerts |
388,589 | def return_letters_from_string(text):
out = ""
for letter in text:
if letter.isalpha():
out += letter
return out | Get letters from string only. |
388,590 | def cubic_lattice( a, b, c, spacing ):
grid = np.array( list( range( 1, a * b * c + 1 ) ) ).reshape( a, b, c, order= )
it = np.nditer( grid, flags=[ ] )
sites = []
while not it.finished:
x, y, z = it.multi_index
r = np.array( [ x, y, z ] ) * spacing
neighbours = [ np.roll( ... | Generate a cubic lattice.
Args:
a (Int): Number of lattice repeat units along x.
b (Int): Number of lattice repeat units along y.
c (Int): Number of lattice repeat units along z.
spacing (Float): Distance between lattice sites.
Returns:
(Lattice)... |
388,591 | async def stream(
self, version="1.1", keep_alive=False, keep_alive_timeout=None
):
headers = self.get_headers(
version,
keep_alive=keep_alive,
keep_alive_timeout=keep_alive_timeout,
)
self.protocol.push_data(headers)
await self.pr... | Streams headers, runs the `streaming_fn` callback that writes
content to the response body, then finalizes the response body. |
388,592 | def _viewport_default(self):
viewport = Viewport(component=self.canvas, enable_zoom=True)
viewport.tools.append(ViewportPanTool(viewport))
return viewport | Trait initialiser |
388,593 | def command(name):
for args, kwargs in argparse_args_list:
command.add_argument_tuple((args, kwargs))
return command
return wrapper | Create a command, using the wrapped function as the handler.
Args
----
name : str
Name given to the created Command instance.
Returns
-------
Command
A new instance of Command, with handler set to the wrapped function. |
388,594 | def _port_action_vlan(self, port, segment, func, vni):
if not self._is_valid_segment(segment):
return
device_id = self._get_port_uuid(port)
if nexus_help.is_baremetal(port):
host_id = port.get()
else:
host_id = port.get(bc.portbind... | Verify configuration and then process event. |
388,595 | def channel_is_settled(
self,
participant1: Address,
participant2: Address,
block_identifier: BlockSpecification,
channel_identifier: ChannelID,
) -> bool:
try:
channel_state = self._get_channel_state(
participa... | Returns true if the channel is in a settled state, false otherwise. |
388,596 | def info(self, **kwargs):
path = self._get_path()
kwargs.update({: self.session_id})
response = self._GET(path, kwargs)
self.id = response[]
self._set_attrs_to_values(response)
return response | Get the basic information for an account.
Call this method first, before calling other Account methods.
Returns:
A dict respresentation of the JSON returned from the API. |
388,597 | def command(cls, command, stdin=None, shell=False):
if not shell and isinstance(command, str):
command = cls.shlex.split(command)
collate_original = None
try:
collate_original = cls.os.environ[]
except KeyError:
pass
cls.os.environ[] =... | Runs specified command.
The command can be fed with data on stdin with parameter ``stdin``.
The command can also be treated as a shell command with parameter ``shell``.
Please refer to subprocess.Popen on how does this stuff work
:returns: Run() instance with resulting data |
388,598 | def set_memcached_backend(self, config):
config[] =
if is_importable(config[]):
return
if config.get() and is_importable():
config[] =
return
| Select the most suitable Memcached backend based on the config and
on what's installed |
388,599 | def view_umatrix(self, figsize=None, colormap=cm.Spectral_r,
colorbar=False, bestmatches=False, bestmatchcolors=None,
labels=None, zoom=None, filename=None):
if self.umatrix is None:
raise Exception("The U-matrix is not available. Either train a map... | Plot the U-matrix of the trained map.
:param figsize: Optional parameter to specify the size of the figure.
:type figsize: (int, int)
:param colormap: Optional parameter to specify the color map to be
used.
:type colormap: matplotlib.colors.Colormap
:par... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.