Unnamed: 0 int64 0 389k | code stringlengths 26 79.6k | docstring stringlengths 1 46.9k |
|---|---|---|
372,700 | def printBlastRecord(record):
for key in sorted(record.__dict__.keys()):
if key not in [, , ]:
print( % (key, record.__dict__[key]))
print( % len(record.alignments))
for i, alignment in enumerate(record.alignments):
print( % (i + 1))
for attr in [, , , , ]:
... | Print a BLAST record.
@param record: A BioPython C{Bio.Blast.Record.Blast} instance. |
372,701 | def postpro_fisher(data, report=None):
if not report:
report = {}
data[data < -0.99999999999999] = -1
data[data > 0.99999999999999] = 1
fisher_data = 0.5 * np.log((1 + data) / (1 - data))
report[] = {}
report[][] =
return fisher_data, report | Performs fisher transform on everything in data.
If report variable is passed, this is added to the report. |
372,702 | def scale_aphi(self, scale_parameter):
lg.info( + str(scale_parameter))
try:
self.a_phi = self.a_phi * scale_parameter
except:
lg.exception("Can't scale a_phi, check that it has been defined ") | Scale the spectra by multiplying by linear scaling factor
:param scale_parameter: Linear scaling factor |
372,703 | def get_leaf_certificates(certs):
issuers = [cert.issuer.get_attributes_for_oid(x509.NameOID.COMMON_NAME)
for cert in certs]
leafs = [cert for cert in certs
if (cert.subject.get_attributes_for_oid(x509.NameOID.COMMON_NAME)
not in issuers)]
return leafs | Extracts the leaf certificates from a list of certificates. Leaf
certificates are ones whose subject does not appear as issuer among the
others. |
372,704 | def missing(self, field, last=True):
priceprice
if last:
self.append({field: {: }})
else:
self.append({field: {: }})
return self | Numeric fields support specific handling for missing fields in a doc.
The missing value can be _last, _first, or a custom value
(that will be used for missing docs as the sort value).
missing('price')
> {"price" : {"missing": "_last" } }
missing('price',False)
> {"price"... |
372,705 | def n1ql_query(self, query, *args, **kwargs):
if not isinstance(query, N1QLQuery):
query = N1QLQuery(query)
itercls = kwargs.pop(, N1QLRequest)
return itercls(query, self, *args, **kwargs) | Execute a N1QL query.
This method is mainly a wrapper around the :class:`~.N1QLQuery`
and :class:`~.N1QLRequest` objects, which contain the inputs
and outputs of the query.
Using an explicit :class:`~.N1QLQuery`::
query = N1QLQuery(
'SELECT airportname FROM... |
372,706 | def set_assessments(self, assessment_ids=None):
if assessment_ids is None:
raise NullArgument()
metadata = Metadata(**settings.METADATA[])
if metadata.is_read_only():
raise NoAccess()
if self._is_valid_input(assessment_ids, metadata, array=True):
... | Sets the assessments.
arg: assessmentIds (osid.id.Id): the assessment Ids
raise: INVALID_ARGUMENT - assessmentIds is invalid
raise: NullArgument - assessmentIds is null
raise: NoAccess - metadata.is_read_only() is true
compliance: mandatory - This method must be implemente... |
372,707 | def make_class(name, attrs, bases=(object,), **attributes_arguments):
if isinstance(attrs, dict):
cls_dict = attrs
elif isinstance(attrs, (list, tuple)):
cls_dict = dict((a, attrib()) for a in attrs)
else:
raise TypeError("attrs argument must be a dict or a list.")
post_ini... | A quick way to create a new class called *name* with *attrs*.
:param name: The name for the new class.
:type name: str
:param attrs: A list of names or a dictionary of mappings of names to
attributes.
If *attrs* is a list or an ordered dict (:class:`dict` on Python 3.6+,
:class:`c... |
372,708 | def del_edges(self, edges, *args, **kwargs):
for edge in edges:
self.del_edge(edge, *args, **kwargs) | Removes edges from the graph. Takes optional arguments for
``DictGraph.del_edge``.
Arguments:
- edges(iterable) Sequence of edges to be removed from the
``DictGraph``. |
372,709 | def preview(src_path):
previews = []
if sketch.is_sketchfile(src_path):
previews = sketch.preview(src_path)
if not previews:
previews = quicklook.preview(src_path)
previews = [safely_decode(preview) for preview in previews]
return previews | Generates a preview of src_path in the requested format.
:returns: A list of preview paths, one for each page. |
372,710 | def write_info_file(tensorboard_info):
payload = "%s\n" % _info_to_string(tensorboard_info)
with open(_get_info_file_path(), "w") as outfile:
outfile.write(payload) | Write TensorBoardInfo to the current process's info file.
This should be called by `main` once the server is ready. When the
server shuts down, `remove_info_file` should be called.
Args:
tensorboard_info: A valid `TensorBoardInfo` object.
Raises:
ValueError: If any field on `info` is not of the corre... |
372,711 | def fraction(self, value: float) -> :
raise_not_number(value)
self.maximum = .format(value)
return self | Set the fraction of free space to use. |
372,712 | def get_app_prefs(app=None):
if app is None:
with Frame(stepback=1) as frame:
app = frame.f_globals[].split()[0]
prefs = get_prefs()
if app not in prefs:
return {}
return prefs[app] | Returns a dictionary with preferences for a certain app/module.
:param str|unicode app:
:rtype: dict |
372,713 | def _narrow_states(node, old_state, new_state, previously_widened_state):
l.debug(, previously_widened_state.ip)
s = previously_widened_state.copy()
narrowing_occurred = False
return s, narrowing_occurred | Try to narrow the state!
:param old_state:
:param new_state:
:param previously_widened_state:
:returns: The narrowed state, and whether a narrowing has occurred |
372,714 | def get_pastml_marginal_prob_file(method, model, column):
if not is_marginal(method):
return None
column, method = get_column_method(column, method)
return PASTML_MARGINAL_PROBS_TAB.format(state=column, model=model) | Get the filename where the PastML marginal probabilities of node states are saved (will be None for non-marginal methods).
This file is inside the work_dir that can be specified for the pastml_pipeline method.
:param method: str, the ancestral state prediction method used by PASTML.
:param model: str, the ... |
372,715 | def pad_positive_wrapper(fmtfct):
def check_and_append(*args, **kwargs):
result = fmtfct(*args, **kwargs)
if fmtfct.parens and not result.endswith():
result +=
return result
return check_and_append | Ensure that numbers are aligned in table by appending a blank space to postive values if 'parenthesis' are
used to denote negative numbers |
372,716 | def poly_energies(samples_like, poly):
msg = ("poly_energies is deprecated and will be removed in dimod 0.9.0."
"In the future, use BinaryPolynomial.energies")
warnings.warn(msg, DeprecationWarning)
return BinaryPolynomial(poly, ).energies(samples_like) | Calculates energy of samples from a higher order polynomial.
Args:
sample (samples_like):
A collection of raw samples. `samples_like` is an extension of
NumPy's array_like structure. See :func:`.as_samples`.
poly (dict):
Polynomial as a dict of form {term: bias,... |
372,717 | def register(email):
data = __utils__[](
.format(_base_url()),
method=,
data=salt.utils.json.dumps({
: email,
: ,
}),
status=True,
decode=True,
decode_type=,
header_dict={
: ,
},
)
status = data[... | Register a new user account
CLI Example:
.. code-block:: bash
salt-run venafi.register email@example.com |
372,718 | def _check_location_part(cls, val, regexp):
cls._deprecation_warning()
return CourseLocator._check_location_part(val, regexp) | Deprecated. See CourseLocator._check_location_part |
372,719 | def choose_form(self, number=None, xpath=None, name=None, **kwargs):
id_ = kwargs.pop(, None)
if id_ is not None:
try:
self._lxml_form = self.select( % id_).node()
except IndexError:
raise DataNotFound("There is no form with id: %s" % id_... | Set the default form.
:param number: number of form (starting from zero)
:param id: value of "id" attribute
:param name: value of "name" attribute
:param xpath: XPath query
:raises: :class:`DataNotFound` if form not found
:raises: :class:`GrabMisuseError`
if ... |
372,720 | def authorize(*args, **kwargs):
if request.method == :
client = Client.query.filter_by(
client_id=kwargs.get()
).first()
if not client:
abort(404)
scopes = current_oauth2server.scopes
ctx = dict(
client=client,
oauth_requ... | View for rendering authorization request. |
372,721 | def validate_tzinfo(dummy, value):
if value is not None and not isinstance(value, datetime.tzinfo):
raise TypeError("%s must be an instance of datetime.tzinfo" % value)
return value | Validate the tzinfo option |
372,722 | def cli():
ch = logging.StreamHandler()
ch.setFormatter(logging.Formatter(
,
datefmt="%Y-%m-%d %H:%M:%S"
))
logger.addHandler(ch)
import argparse
parser = argparse.ArgumentParser(description="Search for hosts with a \
response to that matches ")
parser.add_argumen... | Command line interface |
372,723 | def _refresh_authentication_token(self):
if self.retry == self._MAX_RETRIES:
raise GeocoderAuthenticationFailure(
% self.retry
)
token_request_arguments = {
: self.username,
: self.password,
: self.referer,
... | POST to ArcGIS requesting a new token. |
372,724 | def Reload(self):
logger.info()
self._reload_called = True
with self._accumulators_mutex:
items = list(self._accumulators.items())
names_to_delete = set()
for name, accumulator in items:
try:
accumulator.Reload()
except (OSError, IOError) as e:
logger.err... | Call `Reload` on every `EventAccumulator`. |
372,725 | def update(self, params):
dev_info = self.json_state.get()
dev_info.update({k: params[k] for k in params if dev_info.get(k)}) | Update the dev_info data from a dictionary.
Only updates if it already exists in the device. |
372,726 | def query_by_grader(self, grader_id, end_time=None, start_time=None):
path = {}
data = {}
params = {}
path["grader_id"] = grader_id
if start_time is not None:
params["start_time"] = start_time
... | Query by grader.
List grade change events for a given grader. |
372,727 | def visit_module(self, node):
if not node.file_stream:
return
isFirstLineOfComment = True
isDocString = False
lines = node.stream().readlines()
for linenum, line in enumerate(lines):
if line.strip().startswith(b):
... | A interface will be called when visiting a module.
@param node: node of current module |
372,728 | def reporter(metadata, analysistype, reportpath):
header =
data = str()
for sample in metadata:
try:
if sample[analysistype].blastresults != :
if sample.general.closestrefseqgenus == :
clos... | Create the core genome report
:param metadata: type LIST: List of metadata objects
:param analysistype: type STR: Current analysis type
:param reportpath: type STR: Absolute path to folder in which the reports are to be created
:return: |
372,729 | def create(gandi):
contact = {}
for field, label, checks in FIELDS:
ask_field(gandi, contact, field, label, checks)
default_pwd = randomstring(16)
contact[] = click.prompt(,
hide_input=True,
confirmation_prompt=... | Create a new contact. |
372,730 | def create_sparse_mapping(id_array, unique_ids=None):
if unique_ids is None:
unique_ids = get_original_order_unique_ids(id_array)
assert isinstance(unique_ids, np.ndarray)
assert isinstance(id_array, np.ndarray)
assert unique_ids.ndim == 1
assert id_array.ndim == 1
... | Will create a scipy.sparse compressed-sparse-row matrix that maps
each row represented by an element in id_array to the corresponding
value of the unique ids in id_array.
Parameters
----------
id_array : 1D ndarray of ints.
Each element should represent some id related to the corresponding ... |
372,731 | def main(argv=None):
@contextmanager
def tmpdir():
path = mkdtemp()
try:
yield path
finally:
rmtree(path)
return
def test():
install = "{:s} install -r requirements-test.txt"
check_call(install.format(pip).split(... | Script execution.
The project repo will be cloned to a temporary directory, and the desired
branch, tag, or commit will be checked out. Then, the application will be
installed into a self-contained virtualenv environment. |
372,732 | def list_projects(self, dataset_name):
url = self.url() + "/nd/resource/dataset/{}".format(dataset_name)\
+ "/project/"
req = self.remote_utils.get_url(url)
if req.status_code is not 200:
raise RemoteDataNotFoundError(.format(req.text))
else:
... | Lists a set of projects related to a dataset.
Arguments:
dataset_name (str): Dataset name to search projects for
Returns:
dict: Projects found based on dataset query |
372,733 | def chunk(iterable, size):
iterator = iter(iterable)
while size:
result = []
try:
for i in range(size):
elem = next(iterator)
result.append(elem)
yield tuple(result)
except StopIteration:
if result:
... | chunk('ABCDEFG', 3) --> ABC DEF G |
372,734 | def _validate_relations(relations, services, add_error):
if not relations:
return
for relation in relations:
if not islist(relation):
add_error(.format(relation))
continue
relation_str = .join(.format(i) for i in relation)
for endpoint in relation:
... | Validate relations, ensuring that the endpoints exist.
Receive the relations and services bundle sections.
Use the given add_error callable to register validation error. |
372,735 | def sina_xml_to_url_list(xml_data):
rawurl = []
dom = parseString(xml_data)
for node in dom.getElementsByTagName():
url = node.getElementsByTagName()[0]
rawurl.append(url.childNodes[0].data)
return rawurl | str->list
Convert XML to URL List.
From Biligrab. |
372,736 | def find_carbon_sources(model):
try:
model.slim_optimize(error_value=None)
except OptimizationError:
return []
reactions = model.reactions.get_by_any(list(model.medium))
reactions_fluxes = [
(rxn, total_components_flux(rxn.flux, reaction_elements(rxn),
... | Find all active carbon source reactions.
Parameters
----------
model : Model
A genome-scale metabolic model.
Returns
-------
list
The medium reactions with carbon input flux. |
372,737 | def set_property(self, key, value):
self.properties[key] = value
self.sync_properties() | Update only one property in the dict |
372,738 | def canonical_url(app, pagename, templatename, context, doctree):
base = context.get("canonical_url")
if not base:
return
target = app.builder.get_target_uri(pagename)
context["page_canonical_url"] = base + target | Build the canonical URL for a page. Appends the path for the
page to the base URL specified by the
``html_context["canonical_url"]`` config and stores it in
``html_context["page_canonical_url"]``. |
372,739 | def download(self, path, retry=5, timeout=10,
chunk_size=PartSize.DOWNLOAD_MINIMUM_PART_SIZE, wait=True,
overwrite=False):
if not overwrite and os.path.exists(path):
raise LocalFileAlreadyExists(message=path)
extra = {: self.__class__.__name__, : ... | Downloads the file and returns a download handle.
Download will not start until .start() method is invoked.
:param path: Full path to the new file.
:param retry: Number of retries if error occurs during download.
:param timeout: Timeout for http requests.
:param chunk_size: Ch... |
372,740 | def bsp_resize(node: tcod.bsp.BSP, x: int, y: int, w: int, h: int) -> None:
node.x = x
node.y = y
node.width = w
node.height = h | .. deprecated:: 2.0
Assign directly to :any:`BSP` attributes instead. |
372,741 | def send_error(self, code, message=None):
try:
short, long = self.responses[code]
except KeyError:
short, long = ,
if message is None:
message = short
explain = long
self.log_error("code %d, message %s", code, message)
... | Send and log an error reply.
Arguments are the error code, and a detailed message.
The detailed message defaults to the short entry matching the
response code.
This sends an error response (so it must be called before any
output has been generated), logs the error, and finally ... |
372,742 | def get_insertion(cls) -> str:
indent = 1
blanks = * (indent+4)
subs = []
for name in cls.get_modelnames():
subs.extend([
f,
f,
f,
f,
f,
f,
f,
... | Return the complete string to be inserted into the string of the
template file.
>>> from hydpy.auxs.xmltools import XSDWriter
>>> print(XSDWriter.get_insertion()) # doctest: +ELLIPSIS
<element name="arma_v1"
substitutionGroup="hpcb:sequenceGroup"
... |
372,743 | def set_run_on_node_mask(nodemask):
mask = set_to_numa_nodemask(nodemask)
tmp = bitmask_t()
tmp.maskp = cast(byref(mask), POINTER(c_ulong))
tmp.size = sizeof(nodemask_t) * 8
if libnuma.numa_run_on_node_mask(byref(tmp)) < 0:
raise RuntimeError() | Runs the current thread and its children only on nodes specified in nodemask.
They will not migrate to CPUs of other nodes until the node affinity is
reset with a new call to L{set_run_on_node_mask}.
@param nodemask: node mask
@type nodemask: C{set} |
372,744 | def get(self, resource_id=None):
if request.path.endswith():
return self._meta()
if resource_id is None:
error_message = is_valid_method(self.__model__)
if error_message:
raise BadRequestException(error_message)
if in request.ar... | Return an HTTP response object resulting from an HTTP GET call.
If *resource_id* is provided, return just the single resource.
Otherwise, return the full collection.
:param resource_id: The value of the resource's primary key |
372,745 | def mangleIR(data, ignore_errors=False):
try:
except:
if not ignore_errors:
raise | Mangle a raw Kira data packet into shorthand |
372,746 | def initialize_path(self, path_num=None):
self.state = copy(self.initial_state)
return self.state | initialize consumer for next path |
372,747 | def create(obj: PersistedObject, obj_type: Type[Any], arg_name: str):
return MissingMandatoryAttributeFiles( + str(obj) +
+ get_pretty_type_str(obj_type) +
\
) | Helper method provided because we actually can't put that in the constructor, it creates a bug in Nose tests
https://github.com/nose-devs/nose/issues/725
:param obj:
:param obj_type:
:param arg_name:
:return: |
372,748 | def write(
contents: str,
path: Union[str, pathlib.Path],
verbose: bool = False,
logger_func=None,
) -> bool:
print_func = logger_func or print
path = pathlib.Path(path)
if path.exists():
with path.open("r") as file_pointer:
old_contents = file_pointer.read()
... | Writes ``contents`` to ``path``.
Checks if ``path`` already exists and only write out new contents if the
old contents do not match.
Creates any intermediate missing directories.
:param contents: the file contents to write
:param path: the path to write to
:param verbose: whether to print out... |
372,749 | def init_gl(self):
background = [.99, .99, .99, 1.0]
if in self.kwargs:
try:
background = to_rgba(self.kwargs[])
background = background.astype(np.float64) / 255.0
except BaseException:... | Perform the magic incantations to create an
OpenGL scene using pyglet. |
372,750 | def doubleprox_dc(x, y, f, phi, g, K, niter, gamma, mu, callback=None):
r
primal_space = f.domain
dual_space = g.domain
if phi.domain != primal_space:
raise ValueError(
.format(primal_space, phi.domain))
if K.domain != primal_space:
raise ValueError(
... | r"""Double-proxmial gradient d.c. algorithm of Banert and Bot.
This algorithm solves a problem of the form ::
min_x f(x) + phi(x) - g(Kx).
Parameters
----------
x : `LinearSpaceElement`
Initial primal guess, updated in-place.
y : `LinearSpaceElement`
Initial dual guess, up... |
372,751 | def write_to(self, group, append=False):
data = self.data
if append is True:
try:
original = read_properties(group)
data = original + data
except EOFError:
pass
data = pickle.dumps(data)... | Writes the properties to a `group`, or append it |
372,752 | def horizontal_headers(self, value):
if value is not None:
assert type(value) is OrderedDict, " attribute: type is not !".format(
"horizontal_headers", value)
self.__horizontal_headers = value | Setter for **self.__horizontal_headers** attribute.
:param value: Attribute value.
:type value: OrderedDict |
372,753 | def getLocalTime(date, time, *args, **kwargs):
if time is not None:
return getLocalDateAndTime(date, time, *args, **kwargs)[1] | Get the time in the local timezone from date and time |
372,754 | def activate(self):
payload = {
: ,
: ,
: self.scene_service
}
result = self.vera_request(**payload)
logger.debug("activate: "
"result of vera_request with payload %s: %s",
payload, result.text)
sel... | Activate a Vera scene.
This will call the Vera api to activate a scene. |
372,755 | def start(self, name):
d = self.boatd.post({: name}, endpoint=)
current = d.get()
if current is not None:
return .format(current)
else:
return | End the current behaviour and run a named behaviour.
:param name: the name of the behaviour to run
:type name: str |
372,756 | def getCSVReader(data, reader_type=csv.DictReader):
f = StringIO(data[:-4])
return reader_type(f) | Take a Rave CSV output ending with a line with just EOF on it and return a DictReader |
372,757 | def frames(self, most_recent=False):
if most_recent:
for i in xrange(4):
self._cap.grab()
for i in range(1):
if self._adjust_exposure:
try:
command = .format(self._device_id)
FNULL = open(os.devnull,... | Retrieve a new frame from the PhoXi and convert it to a ColorImage,
a DepthImage, and an IrImage.
Parameters
----------
most_recent: bool
If true, the OpenCV buffer is emptied for the webcam before reading the most recent frame.
Returns
-------
:obj:... |
372,758 | def add(self, si):
if self.o_chunk is None:
if os.path.exists(self.t_path):
os.remove(self.t_path)
self.o_chunk = streamcorpus.Chunk(self.t_path, mode=)
self.o_chunk.add(si)
logger.debug(, len(self.o_chunk))
if len(self.o_chunk) == self.ch... | puts `si` into the currently open chunk, which it creates if
necessary. If this item causes the chunk to cross chunk_max,
then the chunk closed after adding. |
372,759 | def incr(self, key, value):
returns = []
for server in self.servers:
returns.append(server.incr(key, value))
return returns[0] | Increment a key, if it exists, returns it's actual value, if it don't, return 0.
:param key: Key's name
:type key: six.string_types
:param value: Number to be incremented
:type value: int
:return: Actual value of the key on server
:rtype: int |
372,760 | def all_time(self):
if self._all_time is None:
self._all_time = AllTimeList(self._version, account_sid=self._solution[], )
return self._all_time | Access the all_time
:returns: twilio.rest.api.v2010.account.usage.record.all_time.AllTimeList
:rtype: twilio.rest.api.v2010.account.usage.record.all_time.AllTimeList |
372,761 | def add_to_pythonpath(self, path):
pathlist = self.get_pythonpath()
if path in pathlist:
return False
else:
pathlist.insert(0, path)
self.set_pythonpath(pathlist)
return True | Add path to project's PYTHONPATH
Return True if path was added, False if it was already there |
372,762 | def extract_ast_species(ast):
species_id = "None"
species_label = "None"
species = [
(species_id, species_label) for (species_id, species_label) in ast.species if species_id
]
if len(species) == 1:
(species_id, species_label) = species[0]
if not species_id:
specie... | Extract species from ast.species set of tuples (id, label) |
372,763 | def swapColors(self):
rgba = self.color.get_0_255()
self.color = self.secondColor
self.secondColor = Color(rgba, ) | Swaps the current :py:class:`Color` with the secondary :py:class:`Color`.
:rtype: Nothing. |
372,764 | def all_dataset_ids(self, reader_name=None, composites=False):
try:
if reader_name:
readers = [self.readers[reader_name]]
else:
readers = self.readers.values()
except (AttributeError, KeyError):
raise KeyError("No reader found... | Get names of all datasets from loaded readers or `reader_name` if
specified..
:return: list of all dataset names |
372,765 | def init(deb1, deb2=False):
global DEBUG
global DEBUGALL
DEBUG = deb1
DEBUGALL = deb2 | Initialize DEBUG and DEBUGALL.
Allows other modules to set DEBUG and DEBUGALL, so their
call to dprint or dprintx generate output.
Args:
deb1 (bool): value of DEBUG to set
deb2 (bool): optional - value of DEBUGALL to set,
defaults to False. |
372,766 | def is_result_edition_allowed(self, analysis_brain):
if not self.is_analysis_edition_allowed(analysis_brain):
return False
obj = api.get_object(analysis_brain)
if not obj.getDetectionLimitOperand():
return True
... | Checks if the edition of the result field is allowed
:param analysis_brain: Brain that represents an analysis
:return: True if the user can edit the result field, otherwise False |
372,767 | def update_option_set_by_id(cls, option_set_id, option_set, **kwargs):
kwargs[] = True
if kwargs.get():
return cls._update_option_set_by_id_with_http_info(option_set_id, option_set, **kwargs)
else:
(data) = cls._update_option_set_by_id_with_http_info(option_set_i... | Update OptionSet
Update attributes of OptionSet
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.update_option_set_by_id(option_set_id, option_set, async=True)
>>> result = thread.get()
... |
372,768 | def My_TreeTable(self, table, heads, heads2=None):
self.Define_TreeTable(heads, heads2)
self.Display_TreeTable(table) | Define and display a table
in which the values in first column form one or more trees. |
372,769 | def _set_rules(self, rules: dict, overwrite=True):
if not isinstance(rules, dict):
raise TypeError(
% type(rules))
if overwrite:
self.rules = Rules(rules, self.default_rule)
else:
self.rules.update(rules) | Created a new Rules object based on the provided dict of rules. |
372,770 | def start(self, timeout=None):
if self._running.isSet():
raise RuntimeError("Device client already started.")
self.ioloop = self._ioloop_manager.get_ioloop()
if timeout:
t0 = self.ioloop.time()
self._ioloop_manager.start(timeout)
self.iol... | Start the client in a new thread.
Parameters
----------
timeout : float in seconds
Seconds to wait for client thread to start. Do not specify a
timeout if start() is being called from the same ioloop that this
client will be installed on, since it will block ... |
372,771 | def p_expression_land(self, p):
p[0] = Land(p[1], p[3], lineno=p.lineno(1))
p.set_lineno(0, p.lineno(1)) | expression : expression LAND expression |
372,772 | def recognized_release(self):
_, _, rest = self.get_release_parts()
if rest == or re.match(r, rest):
return True
return False | Check if this Release value is something we can parse.
:rtype: bool |
372,773 | def __set_authoring_nodes(self, source, target):
editor = self.__script_editor.get_editor(source)
editor.set_file(target)
self.__script_editor.model.update_authoring_nodes(editor) | Sets given editor authoring nodes.
:param source: Source file.
:type source: unicode
:param target: Target file.
:type target: unicode |
372,774 | def getWindowByPID(self, pid, order=0):
if pid <= 0:
return None
EnumWindowsProc = ctypes.WINFUNCTYPE(
ctypes.c_bool,
ctypes.POINTER(ctypes.c_int),
ctypes.py_object)
def callback(hwnd, context):
if ctypes.windll.user32.IsWindow... | Returns a handle for the first window that matches the provided PID |
372,775 | def get(self, url, headers=None, kwargs=None):
return self._request(
method=,
url=url,
headers=headers,
kwargs=kwargs
) | Make a GET request.
To make a GET request pass, ``url``
:param url: ``str``
:param headers: ``dict``
:param kwargs: ``dict`` |
372,776 | def acl_remove_draft(self, id_vlan, type_acl):
parameters = dict(id_vlan=id_vlan, type_acl=type_acl)
uri = % parameters
return super(ApiVlan, self).get(uri) | Remove Acl draft by type
:param id_vlan: Identity of Vlan
:param type_acl: Acl type v4 or v6
:return: None
:raise VlanDoesNotExistException: Vlan Does Not Exist.
:raise InvalidIdVlanException: Invalid id for Vlan.
:raise NetworkAPIException: Fai... |
372,777 | def parse_port_pin(name_str):
if len(name_str) < 3:
raise ValueError("Expecting pin name to be at least 3 characters")
if name_str[:2] != :
raise ValueError("Expecting pin name to start with GP")
if not name_str[2:].isdigit():
raise ValueError("Expecting numeric GPIO number")
... | Parses a string and returns a (port, gpio_bit) tuple. |
372,778 | def get_member_class(resource):
reg = get_current_registry()
if IInterface in provided_by(resource):
member_class = reg.getUtility(resource, name=)
else:
member_class = reg.getAdapter(resource, IMemberResource,
name=)
return member_class | Returns the registered member class for the given resource.
:param resource: registered resource
:type resource: class implementing or instance providing or subclass of
a registered resource interface. |
372,779 | def position(self):
self._position, value = self.get_attr_int(self._position, )
return value | Returns the current position of the motor in pulses of the rotary
encoder. When the motor rotates clockwise, the position will increase.
Likewise, rotating counter-clockwise causes the position to decrease.
Writing will set the position to that value. |
372,780 | def merge_request(self, request_id):
request_url = "{}pull-request/{}/merge".format(self.create_basic_url(),
request_id)
return_value = self._call_api(request_url, method=)
LOG.debug(return_value) | Merge a pull request.
:param request_id: the id of the request
:return: |
372,781 | def info(environment, opts):
damaged = False
sites = environment.sites
if not environment.sites:
sites = []
damaged = True
if opts[]:
if damaged:
raise DatacatsError()
for site in sites:
environment.site_name = site
print .format(... | Display information about environment and running containers
Usage:
datacats info [-qr] [ENVIRONMENT]
Options:
-q --quiet Echo only the web URL or nothing if not running
ENVIRONMENT may be an environment name or a path to an environment directory.
Default: '.' |
372,782 | def get_steps_branch_len(self, length):
return log(length/self.length, min(self.branches[0][0])) | Get, how much steps will needed for a given branch length.
Returns:
float: The age the tree must achieve to reach the given branch length. |
372,783 | def list_archive(archive, verbosity=1, program=None, interactive=True):
util.check_existing_filename(archive)
if verbosity >= 0:
util.log_info("Listing %s ..." % archive)
return _handle_archive(archive, , verbosity=verbosity,
interactive=interactive, program=program) | List given archive. |
372,784 | def chebyshev_neg(h1, h2):
r
h1, h2 = __prepare_histogram(h1, h2)
return min(scipy.absolute(h1 - h2)) | r"""
Chebyshev negative distance.
Also Tchebychev distance, Minimum or :math:`L_{-\infty}` metric; equal to Minowski
distance with :math:`p=-\infty`. For the case of :math:`p=+\infty`, use `chebyshev`.
The Chebyshev distance between two histograms :math:`H` and :math:`H'` of size :math:`m` is
... |
372,785 | def get_node(self, name):
r
if self._validate_node_name(name):
raise RuntimeError("Argument `name` is not valid")
self._node_in_tree(name)
return self._db[name] | r"""
Get a tree node structure.
The structure is a dictionary with the following keys:
* **parent** (*NodeName*) Parent node name, :code:`''` if the
node is the root node
* **children** (*list of NodeName*) Children node names, an
empty list if node is a leaf
... |
372,786 | def generate_transit_lightcurve(
times,
mags=None,
errs=None,
paramdists={:sps.uniform(loc=0.1,scale=49.9),
:sps.uniform(loc=1.0e-4,scale=2.0e-2),
:sps.uniform(loc=0.01,scale=0.29)},
magsarefluxes=False,
):
transitperiodtransitdepthtran... | This generates fake planet transit light curves.
Parameters
----------
times : np.array
This is an array of time values that will be used as the time base.
mags,errs : np.array
These arrays will have the model added to them. If either is
None, `np.full_like(times, 0.0)` will u... |
372,787 | def _force(self,z,t=0.):
return self._Pot.zforce(self._R,z,phi=self._phi,t=t,use_physical=False)\
-self._Pot.zforce(self._R,0.,phi=self._phi,t=t,use_physical=False) | NAME:
_force
PURPOSE:
evaluate the force
INPUT:
z
t
OUTPUT:
F_z(z,t;R)
HISTORY:
2010-07-13 - Written - Bovy (NYU) |
372,788 | def _generate_docstring(self, doc_type, quote):
docstring = None
self.quote3 = quote * 3
if quote == :
self.quote3_other = """"NumpydocGoogledoc':
docstring = self._generate_google_doc(func_info)
return docstring | Generate docstring. |
372,789 | def substitute_vars(template, replacements):
result = template
for (key, value) in replacements:
result = result.replace( + key + , value)
if in result:
logging.warning("A variable was not replaced in .", result)
return result | Replace certain keys with respective values in a string.
@param template: the string in which replacements should be made
@param replacements: a dict or a list of pairs of keys and values |
372,790 | def fetch_live(self, formatter=TableFormat):
fmt = formatter(self)
for results in self.execute():
if in results and results[].get():
yield fmt.formatted(results[][]) | Fetch a live stream query. This is the equivalent of selecting
the "Play" option for monitoring fields within the SMC UI. Data will
be streamed back in real time.
:param formatter: Formatter type for data representation. Any type
in :py:mod:`smc_monitoring.models.formatters`... |
372,791 | def search_datasets(self, search_phrase, limit=None):
return self.backend.dataset_index.search(search_phrase, limit=limit) | Search for datasets. |
372,792 | def generate(env):
if not exists(env):
return
env[] = []
env[] = []
env[] =
env[].append( )
env[] = "$WIXLIGHT $WIXLIGHTFLAGS -out ${TARGET} ${SOURCES}"
env[] =
env[] =
object_builder = SCons.Builder.Builder(
action = ,
suffix = ,
s... | Add Builders and construction variables for WiX to an Environment. |
372,793 | def agg_iter(self, lower_limit=None, upper_limit=None):
lower_limit = lower_limit or self.get_bookmark().isoformat()
upper_limit = upper_limit or (
datetime.datetime.utcnow().replace(microsecond=0).isoformat())
aggregation_data = {}
self.agg_query = Search(using=sel... | Aggregate and return dictionary to be indexed in ES. |
372,794 | def next_block(self):
assert self.pos <= self.input_len
if self.pos == self.input_len:
return None
i = self.START_OVERSHOOT
while True:
try_size = int(self.bs * i)
size = self.check_request_size(try_size)
c, d = self.co... | This could probably be improved; at the moment it starts by trying to overshoot the
desired compressed block size, then it reduces the input bytes one by one until it
has met the required block size |
372,795 | def F_to_K(self, F, method=):
Q2 = self.beta * self.theta
R2 = - self.R - dot(F.T, dot(self.Q, F))
A2 = self.A - dot(self.B, F)
B2 = self.C
lq = LQ(Q2, R2, A2, B2, beta=self.beta)
neg_P, neg_K, d = lq.stationary_values(method=method)
return -neg_K, -neg_... | Compute agent 2's best cost-minimizing response K, given F.
Parameters
----------
F : array_like(float, ndim=2)
A k x n array
method : str, optional(default='doubling')
Solution method used in solving the associated Riccati
equation, str in {'doubling... |
372,796 | def copy(self):
t clone the serializers or deserializers and it won
try:
tmp = self.__class__()
except Exception:
tmp = self.__class__(self._pdict)
tmp._serializers = self._serializers
tmp.__deserializers = self.__deserializers
return... | makes a clone copy of the mapper. It won't clone the serializers or deserializers and it won't copy the events |
372,797 | def Setup(self):
self.Peers = []
self.DEAD_ADDRS = []
self.MissionsGlobal = []
self.NodeId = random.randint(1294967200, 4294967200) | Initialize the local node.
Returns: |
372,798 | def _truthtable(inputs, pcdata):
if len(inputs) == 0 and pcdata[0] in {PC_ZERO, PC_ONE}:
return {
PC_ZERO : TTZERO,
PC_ONE : TTONE
}[pcdata[0]]
elif len(inputs) == 1 and pcdata[0] == PC_ZERO and pcdata[1] == PC_ONE:
return inputs[0]
else:
return ... | Return a truth table. |
372,799 | def stats(self, key=None):
returns = {}
for server in self.servers:
returns[server.server] = server.stats(key)
return returns | Return server stats.
:param key: Optional if you want status from a key.
:type key: six.string_types
:return: A dict with server stats
:rtype: dict |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.