Unnamed: 0 int64 0 389k | code stringlengths 26 79.6k | docstring stringlengths 1 46.9k |
|---|---|---|
386,800 | def render_template(self, template_name, out_path=None):
return render_template(template_name, self.to_dict(), out_path=out_path) | Render a template based on this TileBus Block.
The template has access to all of the attributes of this block as a
dictionary (the result of calling self.to_dict()).
You can optionally render to a file by passing out_path.
Args:
template_name (str): The name of the templat... |
386,801 | def files(self):
if self._files is None:
self._files = SeriesZipTifPhasics._index_files(self.path)
return self._files | List of Phasics tif file names in the input zip file |
386,802 | def discover_single_case(self, module, case_attributes):
case = module
loader = self._loader
for index, component in enumerate(case_attributes):
case = getattr(case, component, None)
if case is None:
return loader.create_suite()
... | Find and load a single TestCase or TestCase method from a module.
Parameters
----------
module : module
The imported Python module containing the TestCase to be
loaded.
case_attributes : list
A list (length 1 or 2) of str. The first component must be... |
386,803 | def _get_mean_deep_soil(self, mag, rake, rrup, is_reverse, imt):
if mag <= self.NEAR_FIELD_SATURATION_MAG:
c4 = self.COEFFS_SOIL_IMT_INDEPENDENT[]
c5 = self.COEFFS_SOIL_IMT_INDEPENDENT[]
else:
c4 = self.COEFFS_SOIL_IMT_INDEPENDENT[]
c5 = self.COEF... | Calculate and return the mean intensity for deep soil sites.
Implements an equation from table 4. |
386,804 | def to_bytes(self):
self.sanitize()
bitstream = BitArray( % self.message_type)
bitstream += BitArray(
% (self.probe,
self.enlra_enabled,
self.security))
... | Create bytes from properties |
386,805 | def open(self):
self.device = usb.core.find(idVendor=self.idVendor, idProduct=self.idProduct)
if self.device is None:
raise NoDeviceError()
try:
if self.device.is_kernel_driver_active(self.interface):
self.device.detach_kernel_driver(self... | Search device on USB tree and set is as escpos device |
386,806 | def allowance (self, filename):
for line in self.rulelines:
log.debug(LOG_CHECK, "%s %s %s", filename, str(line), line.allowance)
if line.applies_to(filename):
log.debug(LOG_CHECK, " ... rule line %s", line)
return line.allowance
log.debug... | Preconditions:
- our agent applies to this entry
- filename is URL decoded
Check if given filename is allowed to acces this entry.
@return: True if allowed, else False
@rtype: bool |
386,807 | def get_plugins(modules, classobj):
for module in modules:
for plugin in get_module_plugins(module, classobj):
yield plugin | Find all class objects in all modules.
@param modules: the modules to search
@ptype modules: iterator of modules
@return: found classes
@rytpe: iterator of class objects |
386,808 | def on_return(self, channel, method, properties, body):
pending = self.pending_confirmations()
if not pending:
self.logger.warning(
,
utils.message_info(method.exchange,
... | Invoked by RabbitMQ when it returns a message that was published.
:param channel: The channel the message was delivered on
:type channel: pika.channel.Channel
:param method: The AMQP method frame
:type method: pika.frame.Frame
:param properties: The AMQP message properties
... |
386,809 | def getNextSample(self, V):
W, WProb = self.drawRankingPlakettLuce(V)
VProb = self.calcProbOfVFromW(V, W)
acceptanceRatio = self.calcAcceptanceRatio(V, W)
prob = min(1.0, acceptanceRatio * (VProb/WProb))
if random.random() <= prob:
V = W
return V | Given a ranking over the candidates, generate a new ranking by assigning each candidate at
position i a Plakett-Luce weight of phi^i and draw a new ranking.
:ivar list<int> V: Contains integer representations of each candidate in order of their
ranking in a vote, from first to last. |
386,810 | def factors(self):
if self._factors is None:
self._factors = FactorList(
self._version,
service_sid=self._solution[],
identity=self._solution[],
)
return self._factors | Access the factors
:returns: twilio.rest.authy.v1.service.entity.factor.FactorList
:rtype: twilio.rest.authy.v1.service.entity.factor.FactorList |
386,811 | def _add_deprecated_function_notice_to_docstring(doc, date, instructions):
if instructions:
deprecation_message = % (( if date is None else ( % date)), instructions)
else:
deprecation_message = % (( if date is None else ( % date)))
main_text = [deprecation_message]
return _add... | Adds a deprecation notice to a docstring for deprecated functions. |
386,812 | def openSafeReplace(filepath, mode=):
tempfileName = None
if not _isFileAccessible(filepath):
raise IOError( % (filepath, ))
with tempfile.NamedTemporaryFile(delete=False, mode=mode) as tmpf:
tempfileName = tmpf.name
yield tmpf
if not _isFileAccessible(fi... | Context manager to open a temporary file and replace the original file on
closing. |
386,813 | def _getDefaultCombinedL4Params(self, numInputBits, inputSize,
numExternalInputBits, externalInputSize,
L2CellCount):
sampleSize = numExternalInputBits + numInputBits
activationThreshold = int(max(numExternalInputBits, numInputBits) * .6)
... | Returns a good default set of parameters to use in a combined L4 region. |
386,814 | def _handle_authentication_error(self):
response = make_response()
response.headers[] = self.auth.get_authenticate_header()
response.status_code = 401
return response | Return an authentication error. |
386,815 | def page_view(url):
def decorator(func):
@wraps(func)
async def wrapper(self: BaseState, *args, **kwargs):
user_id = self.request.user.id
try:
user_lang = await self.request.user.get_locale()
except NotImplementedError:
user_... | Page view decorator.
Put that around a state handler function in order to log a page view each
time the handler gets called.
:param url: simili-URL that you want to give to the state |
386,816 | def male_breeding_location_type(self):
if int(self.Male.all()[0].Cage) == int(self.Cage):
type = "resident breeder"
else:
type = "non-resident breeder"
return type | This attribute defines whether a breeding male's current location is the same as the breeding cage.
This attribute is used to color breeding table entries such that male mice which are currently in a different cage can quickly be identified. |
386,817 | def sync_agg_metric(self, unique_identifier, metric, start_date, end_date):
self.sync_week_metric(unique_identifier, metric, start_date, end_date)
self.sync_month_metric(unique_identifier, metric, start_date, end_date) | Uses the count for each day in the date range to recalculate the counters for the associated weeks and months for
the ``metric`` for ``unique_identifier``. Useful for updating the counters for week and month after using set_metric_by_day.
The redis backend supports lists for both ``unique_identifier`` ... |
386,818 | def _data_update(subjects, queue, run_flag):
while run_flag.running:
while not queue.empty():
data = queue.get()
for subject in [s for s in subjects if not s.is_disposed]:
subject.on_next(data)
time.sleep(0.1) | Get data from backgound process and notify all subscribed observers with the new data |
386,819 | def iter_work_specs(self, limit=None, start=None):
count = 0
ws_list, start = self.list_work_specs(limit, start)
while True:
for name_spec in ws_list:
yield name_spec[1]
count += 1
if (limit is not None) and (count >= limit):
... | yield work spec dicts |
386,820 | def clear_context(pid_file):
return
raise RuntimeError("Should not happen")
fname = get_context_file_name(pid_file)
shutil.move(fname, fname.replace("context.json", "context.old.json"))
data = {}
data["terminated"] = str(datetime.datetime.now(datetime.timezone.utc))
set_context(pid_fil... | Called at exit. Delete the context file to signal there is no active notebook.
We don't delete the whole file, but leave it around for debugging purposes. Maybe later we want to pass some information back to the web site. |
386,821 | def replace_cluster_custom_object(self, group, version, plural, name, body, **kwargs):
kwargs[] = True
if kwargs.get():
return self.replace_cluster_custom_object_with_http_info(group, version, plural, name, body, **kwargs)
else:
(data) = self.replace_cluster_... | replace_cluster_custom_object # noqa: E501
replace the specified cluster scoped custom object # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.replace_cluster_custom_object(group, ve... |
386,822 | def get_case(word, correction):
if word.istitle():
return correction.title()
if word.isupper():
return correction.upper()
if correction == word and not word.islower():
return word
if len(word) > 2 and word[:2].isupper():
return correction.title()
if not known_as_... | Best guess of intended case.
manchester => manchester
chilton => Chilton
AAvTech => AAvTech
THe => The
imho => IMHO |
386,823 | def get(cls, name=__name__):
if not isinstance(name, str):
raise TypeError()
if name not in cls.__instances:
cls.__instances[name] = cls()
cls.__instances[name]._name = name
return cls.__instances[name] | Return a Mapper instance with the given name.
If the name already exist return its instance.
Does not work if a Mapper was created via its constructor.
Using `Mapper.get()`_ is the prefered way.
Args:
name (str, optional): Name for the newly created instance.
... |
386,824 | def _set_log_level(self):
log_level = "INFO"
if hasattr(self._config, "level") and self._config.level.upper() in ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]:
log_level = self._config.level.upper()
self._log_level = log_level | Inspects config and sets the log level as instance attr. If not present
in config, default is "INFO". |
386,825 | async def _dump_container_val(self, writer, elem, container_type, params=None):
elem_type = container_elem_type(container_type, params)
await self.dump_field(writer, elem, elem_type, params[1:] if params else None) | Single elem dump
:param writer:
:param elem:
:param container_type:
:param params:
:return: |
386,826 | def max_date(self, symbol):
res = self._collection.find_one({SYMBOL: symbol}, projection={ID: 0, END: 1},
sort=[(START, pymongo.DESCENDING)])
if res is None:
raise NoDataFoundException("No Data found for {}".format(symbol))
return utc_... | Return the maximum datetime stored for a particular symbol
Parameters
----------
symbol : `str`
symbol name for the item |
386,827 | def select_action(self, state):
value = 0
if self.steps < self.min_steps:
action = np.random.randint(self.actions)
else:
self.eps = max(self.eps_end, self.eps * self.eps_decay)
if random.random() < self.eps:
action = np.random.randint(self.actions)
else:
self.loc... | Select the best action for the given state using e-greedy exploration to
minimize overfitting
:return: tuple(action, value) |
386,828 | def render_er(input, output, mode=, include_tables=None, include_columns=None,
exclude_tables=None, exclude_columns=None, schema=None):
try:
tables, relationships = all_to_intermediary(input, schema=schema)
tables, relationships = filter_resources(tables, relationships,
... | Transform the metadata into a representation.
:param input: Possible inputs are instances of:
MetaData: SQLAlchemy Metadata
DeclarativeMeta: SQLAlchemy declarative Base
:param output: name of the file to output the
:param mode: str in list:
'er': writes to a file the markup to genera... |
386,829 | def pool_function(p, nick, rutaDescarga, avoidProcessing=True, avoidDownload=True, verbosity=1):
try:
res = p.getInfo(
query=nick,
mode="usufy",
process=True
)
return {"platform" : str(p), "status": "Ok", "data": res}
except Exception as... | Wrapper for being able to launch all the threads of getPageWrapper.
We receive the parameters for getPageWrapper as a tuple.
Args:
-----
pName: Platform where the information is stored. It is a string.
nick: Nick to be searched.
rutaDescarga: Local file where saving the obtained in... |
386,830 | def create(self, friendly_name=values.unset, domain_name=values.unset,
disaster_recovery_url=values.unset,
disaster_recovery_method=values.unset, recording=values.unset,
secure=values.unset, cnam_lookup_enabled=values.unset):
data = values.of({
:... | Create a new TrunkInstance
:param unicode friendly_name: A string to describe the resource
:param unicode domain_name: The unique address you reserve on Twilio to which you route your SIP traffic
:param unicode disaster_recovery_url: The HTTP URL that we should call if an error occurs while sen... |
386,831 | def pci_contents(self, use_dict=None, as_class=dict):
if _debug: PCI._debug("pci_contents use_dict=%r as_class=%r", use_dict, as_class)
if use_dict is None:
use_dict = as_class()
for k, v in ((, self.pduUserData), (, self.pduSource), (, self.pduDestinatio... | Return the contents of an object as a dict. |
386,832 | def coredump_configured(name, enabled, dump_ip, host_vnic=, dump_port=6500):
s core dump configuration.
name
Name of the state.
enabled
Sets whether or not ESXi core dump collection should be enabled.
This is a boolean value set to ``True`` or ``False`` to enable
or disable... | Ensures a host's core dump configuration.
name
Name of the state.
enabled
Sets whether or not ESXi core dump collection should be enabled.
This is a boolean value set to ``True`` or ``False`` to enable
or disable core dumps.
Note that ESXi requires that the core dump m... |
386,833 | def solve2x2(lhs, rhs):
if np.abs(lhs[1, 0]) > np.abs(lhs[0, 0]):
ratio = lhs[0, 0] / lhs[1, 0]
denominator = lhs[0, 1] - ratio * lhs[1, 1]
if denominator == 0.0:
return Tru... | Solve a square 2 x 2 system via LU factorization.
This is meant to be a stand-in for LAPACK's ``dgesv``, which just wraps
two calls to ``dgetrf`` and ``dgetrs``. We wrap for two reasons:
* We seek to avoid exceptions as part of the control flow (which is
what :func`numpy.linalg.solve` does).
* W... |
386,834 | def configure_savedsearch(self, ns, definition):
paginated_list_schema = self.page_cls.make_paginated_list_schema_class(
ns,
definition.response_schema,
)()
@self.add_route(ns.collection_path, Operation.SavedSearch, ns)
@request(definition.request_schema... | Register a saved search endpoint.
The definition's func should be a search function, which must:
- accept kwargs for the request data
- return a tuple of (items, count) where count is the total number of items
available (in the case of pagination)
The definition's request_sch... |
386,835 | def _setVirtualEnv():
try:
activate = options.virtualenv.activate_cmd
except AttributeError:
activate = None
if activate is None:
virtualenv = path(os.environ.get(, ))
if not virtualenv:
virtualenv = options.paved.cwd
else:
virtualenv = p... | Attempt to set the virtualenv activate command, if it hasn't been specified. |
386,836 | def split_iterable_as_unordered_iterable(self, values):
from collections import defaultdict
cache = defaultdict(list)
count = self.count
unique = self.unique
key = (lambda i: unique[i]) if isinstance(unique, np.ndarray) else (lambda i: tuple(c[i] for c in unique))
... | Group iterable into iterables, without regard for the ordering of self.index.unique
key-group tuples are yielded as soon as they are complete
Parameters
----------
values : iterable of length equal to keys
iterable of values to be grouped
Yields
------
... |
386,837 | def toc_html(self):
if self._toc is None:
return None
def indent():
return * (len(h_stack) - 1)
lines = []
h_stack = [0]
for level, id, name in self._toc:
if level > h_stack[-1]:
lines.append("%s<ul>" % indent())
... | Return the HTML for the current TOC.
This expects the `_toc` attribute to have been set on this instance. |
386,838 | def sendcontrol(self, char):
\ag
n, byte = self.ptyproc.sendcontrol(char)
self._log_control(byte)
return n | Helper method that wraps send() with mnemonic access for sending control
character to the child (such as Ctrl-C or Ctrl-D). For example, to send
Ctrl-G (ASCII 7, bell, '\a')::
child.sendcontrol('g')
See also, sendintr() and sendeof(). |
386,839 | def from_str(string, max_number=9, separator="."):
tokens = string.split(separator)
tokens = list(reversed(tokens))
most_important = tokens[-1]
levels = [
Level(max_number, int(token)) for token in tokens[:-1]
]
levels.append(
Level(fl... | Parses string
:param string: Version
:param max_number: Max number reachable by sub
:param separator: Version numbers are separated with this split
:return: Parses string and returns object |
386,840 | def _image_size(image_config, type_, target_size):
return min(
image_config[.format(type_)],
key=lambda size: (abs(target_size - int(size[1:]))
if size.startswith() or size.startswith()
else 999),
) | Find the closest available size for specified image type.
Arguments:
image_config (:py:class:`dict`): The image config data.
type_ (:py:class:`str`): The type of image to create a URL
for, (``'poster'`` or ``'profile'``).
target_size (:py:class:`int`): The size of imag... |
386,841 | def linop_scale(w, op):
with tf.name_scope("linop_scale"):
def scaled_identity(w):
return tf.linalg.LinearOperatorScaledIdentity(
num_rows=op.range_dimension_tensor(),
multiplier=w,
is_non_singular=op.is_non_singular,
is_self_adjoint=op.... | Creates weighted `LinOp` from existing `LinOp`. |
386,842 | def cli(ctx, verbose, fake, install, uninstall, config):
ctx.obj = SCMRepo()
ctx.obj.fake = fake
ctx.obj.verbose = fake or verbose
if install:
do_install(ctx, verbose, fake)
ctx.exit()
elif uninstall:
do_uninstall(ctx, verbose, fake)
ctx.exit()
... | legit command line interface |
386,843 | def create_new(self, body):
return self.client.post(self._url(), data=body) | Configure a new custom domain
Args:
body (str): The domain, tye and verification method in json
See: https://auth0.com/docs/api/management/v2#!/Custom_Domains/post_custom_domains |
386,844 | def create_code_cell(block):
code_cell = nbbase.new_code_cell(source=block[])
attr = block[]
if not attr.is_empty:
code_cell.metadata \
= nbbase.NotebookNode({: attr.to_dict()})
execution_count = attr.kvs.get()
if not execution_count:... | Create a notebook code cell from a block. |
386,845 | def set_cmd_env_var(value):
def func_decorator(function):
@functools.wraps(function)
def wrapper(*args, **kwargs):
previous_cmd_env_var = os.getenv(temple.constants.TEMPLE_ENV_VAR)
os.environ[temple.constants.TEMPLE_ENV_VAR] = value
try:
ret_v... | Decorator that sets the temple command env var to value |
386,846 | def getRoles(self):
self.log.info("Get all the roles in <ProjectArea %s>",
self)
roles_url = "/".join([self.rtc_obj.url,
"process/project-areas/%s/roles" % self.id])
resp = self.get(roles_url,
... | Get all :class:`rtcclient.models.Role` objects in this project
area
If no :class:`Roles` are retrieved, `None` is returned.
:return: a :class:`list` that contains all
:class:`rtcclient.models.Role` objects
:rtype: list |
386,847 | def namedb_state_transition( cur, opcode, op_data, block_id, vtxindex, txid, history_id, cur_record, record_table, constraints_ignored=[] ):
try:
assert opcode in OPCODE_NAME_STATE_TRANSITIONS + OPCODE_NAMESPACE_STATE_TRANSITIONS, "BUG: opcode is not a state-transition"
assert not i... | Given an operation (opcode, op_data), a point in time (block_id, vtxindex, txid), and a current
record (history_id, cur_record), apply the operation to the record and save the delta to the record's
history. Also, insert or update the new record into the db.
The cur_record must exist already.
Return t... |
386,848 | def delete_entity(self, partition_key, row_key,
if_match=):
request = _delete_entity(partition_key, row_key, if_match)
self._add_to_batch(partition_key, row_key, request) | Adds a delete entity operation to the batch. See
:func:`~azure.storage.table.tableservice.TableService.delete_entity` for more
information on deletes.
The operation will not be executed until the batch is committed.
:param str partition_key:
The PartitionKey of the entity... |
386,849 | def render_to_json_response(self, context, **kwargs):
return HttpResponse(
self.convert_context_to_json(context),
content_type=,
**kwargs
) | Returns a JSON response, transforming 'context' to make the payload. |
386,850 | def value(self):
if self.scores.numel() == 0:
return 0
ap = torch.zeros(self.scores.size(1))
rg = torch.arange(1, self.scores.size(0)).float()
for k in range(self.scores.size(1)):
scores = self.scores[:, k]
targets = se... | Returns the model's average precision for each class
Return:
ap (FloatTensor): 1xK tensor, with avg precision for each class k |
386,851 | def multi_index_df_to_component_dfs(multi_index_df, rid="rid", cid="cid"):
rids = list(multi_index_df.index.get_level_values(rid))
cids = list(multi_index_df.columns.get_level_values(cid))
mi_df_index = multi_index_df.index.droplevel(rid)
rhds = list(mi_df_... | Convert a multi-index df into 3 component dfs. |
386,852 | def crossvalidate(self, foldsfile):
options = "-F " + self.format + " " + self.timbloptions + " -t cross_validate"
print("Instantiating Timbl API : " + options,file=stderr)
if sys.version < :
self.api = timblapi.TimblAPI(b(options), b"")
else:
self.api =... | Train & Test using cross validation, testfile is a file that contains the filenames of all the folds! |
386,853 | def to_env_vars(self):
env = {
: self.hosts, : self.network_interface_name,
: self.hyperparameters, : self.user_entry_point,
: self.additional_framework_parameters,
: self.resource_config, : self.input_data_config,
: self.output_data_dir,
... | Environment variable representation of the training environment
Returns:
dict: an instance of dictionary |
386,854 | def upgrade():
if op.get_context().dialect.name == :
Fk =
op.execute(
.format(Fk))
else:
op.drop_constraint(, , type_=)
op.create_primary_key(
, , [])
op.create_unique_constraint(
,... | Upgrade database. |
386,855 | def data2schema(
_data=None, _force=False, _besteffort=True, _registry=None,
_factory=None, _buildkwargs=None, **kwargs
):
if _data is None:
return lambda _data: data2schema(
_data, _force=False, _besteffort=True, _registry=None,
_factory=None, _buildkwargs=None,... | Get the schema able to instanciate input data.
The default value of schema will be data.
Can be used such as a decorator:
..code-block:: python
@data2schema
def example(): pass # return a function schema
@data2schema(_registry=myregistry)
def example(): pass # return a... |
386,856 | def save_thumbnail(image_path_template, src_file, file_conf, gallery_conf):
thumbnail_number = file_conf.get(, 1)
if not isinstance(thumbnail_number, int):
raise TypeError(
% (thumbnail_number,))
thumbnail_image_path, ext = _find_image_ext(image_path_template,
... | Generate and Save the thumbnail image
Parameters
----------
image_path_template : str
holds the template where to save and how to name the image
src_file : str
path to source python file
gallery_conf : dict
Sphinx-Gallery configuration dictionary |
386,857 | def _parse_lti_data(self, courseid, taskid):
post_input = web.webapi.rawinput("POST")
self.logger.debug( + str(post_input))
try:
course = self.course_factory.get_course(courseid)
except exceptions.CourseNotFoundException as ex:
raise web.notfound(str(ex)... | Verify and parse the data for the LTI basic launch |
386,858 | def get_tables(self):
url = self.build_url(self._endpoints.get())
response = self.session.get(url)
if not response:
return []
data = response.json()
return [self.table_constructor(parent=self, **{self._cloud_data_key: table})
for table in ... | Returns a collection of this worksheet tables |
386,859 | def _parse_hello_extensions(data):
if data == b:
return
extentions_length = int_from_bytes(data[0:2])
extensions_start = 2
extensions_end = 2 + extentions_length
pointer = extensions_start
while pointer < extensions_end:
extension_type = int_from_bytes(data[pointer:pointe... | Creates a generator returning tuples of information about each extension
from a byte string of extension data contained in a ServerHello ores
ClientHello message
:param data:
A byte string of a extension data from a TLS ServerHello or ClientHello
message
:return:
A generator th... |
386,860 | def read_config_file(self, file_name):
with open(os.path.join(self.__path(), os.path.basename(file_name)),
) as file_config:
return self._parser.parseString(file_config.read()) | Reads a CWR grammar config file.
:param file_name: name of the text file
:return: the file's contents |
386,861 | def spin(self):
for x in self.spinchars:
self.string = self.msg + "...\t" + x + "\r"
self.out.write(self.string.encode())
self.out.flush()
time.sleep(self.waittime) | Perform a single spin |
386,862 | def check_chunks(n_samples, n_features, chunks=None):
if chunks is None:
chunks = (max(100, n_samples // cpu_count()), n_features)
elif isinstance(chunks, Integral):
chunks = (max(100, n_samples // chunks), n_features)
elif isinstance(chunks, Sequence):
chunks = tuple(chunks)
... | Validate and normalize the chunks argument for a dask.array
Parameters
----------
n_samples, n_features : int
Give the shape of the array
chunks : int, sequence, optional, default None
* For 'chunks=None', this picks a "good" default number of chunks based
on the number of CPU... |
386,863 | def add_spectra(self, spectra_dict, key_sort_func=None):
if key_sort_func:
keys = sorted(spectra_dict.keys(), key=key_sort_func)
else:
keys = spectra_dict.keys()
for label in keys:
self.add_spectra(label, spectra_dict[label]) | Add a dictionary of doses, with an optional sorting function for the
keys.
Args:
dos_dict: dict of {label: Dos}
key_sort_func: function used to sort the dos_dict keys. |
386,864 | def knot_removal_alpha_j(u, degree, knotvector, num, idx):
return (u - knotvector[idx - num]) / (knotvector[idx + degree + 1] - knotvector[idx - num]) | Computes :math:`\\alpha_{j}` coefficient for knot removal algorithm.
Please refer to Eq. 5.29 of The NURBS Book by Piegl & Tiller, 2nd Edition, p.184 for details.
:param u: knot
:type u: float
:param degree: degree
:type degree: int
:param knotvector: knot vector
:type knotvector: tuple
... |
386,865 | def get_end_trigger(options):
if options.endTriggerType.lower() == "epoch":
return MaxEpoch(options.endTriggerNum)
else:
return MaxIteration(options.endTriggerNum) | When to end the optimization based on input option. |
386,866 | def load_dependencies(req, history=None):
if history is None:
history = set()
dist = pkg_resources.get_distribution(req)
spec = dict(
requirement=str(req),
resolved=str(dist),
)
if req not in history:
history.add(req)
extras = parse_extras(req)
... | Load the dependency tree as a Python object tree,
suitable for JSON serialization.
>>> deps = load_dependencies('jaraco.packaging')
>>> import json
>>> doc = json.dumps(deps) |
386,867 | def coalesce_events(self, coalesce=True):
self._coalesce = coalesce
if not coalesce:
self._eventset.clear() | Coalescing events. Events are usually processed by batchs, their size
depend on various factors. Thus, before processing them, events received
from inotify are aggregated in a fifo queue. If this coalescing
option is enabled events are filtered based on their unicity, only
unique events ... |
386,868 | def Update(self):
return(clc.v2.Requests(clc.v2.API.Call(, % (self.parent.server.alias,self.parent.server.id,self.id),
json.dumps({: [o.ToDict() for o in self.ports],
: [o.ToDict() for o in self.source_restrictions] }),
session=self.session),
... | Commit current PublicIP definition to cloud.
Usually called by the class to commit changes to port and source restriction policies.
>>> clc.v2.Server("WA1BTDIX01").PublicIPs().public_ips[0].Update().WaitUntilComplete()
0 |
386,869 | def read_file(self):
with open(self.filename, mode=, encoding=) as text_file:
self.raw_file = text_file.read()
self.file_lines = [x.rstrip() for x in self.raw_file.splitlines()] | Grabs filename and enables it to be read.
:return: raw_file = unaltered text; file_lines = text split by lines. |
386,870 | def iter_by_year(self):
for yr, details in self.txn_details.iter_by_year():
yield yr, Performance(details) | Split the return objects by year and iterate |
386,871 | def writeToDelimitedString(obj, stream=None):
if stream is None:
stream = BytesIO()
_EncodeVarint(stream.write, obj.ByteSize(), True)
stream.write(obj.SerializeToString())
return stream | Stanford CoreNLP uses the Java "writeDelimitedTo" function, which
writes the size (and offset) of the buffer before writing the object.
This function handles parsing this message starting from offset 0.
@returns how many bytes of @buf were consumed. |
386,872 | def parse_sentence(obj: dict) -> BioCSentence:
sentence = BioCSentence()
sentence.offset = obj[]
sentence.infons = obj[]
sentence.text = obj[]
for annotation in obj[]:
sentence.add_annotation(parse_annotation(annotation))
for relation in obj[]:
sentence.add_relation... | Deserialize a dict obj to a BioCSentence object |
386,873 | def rdn_to_dn(changes: Changeset, name: str, base_dn: str) -> Changeset:
dn = changes.get_value_as_single()
if dn is not None:
return changes
value = changes.get_value_as_single(name)
if value is None:
raise tldap.exceptions.ValidationError(
"Cannot use %s in dn as it i... | Convert the rdn to a fully qualified DN for the specified LDAP
connection.
:param changes: The changes object to lookup.
:param name: rdn to convert.
:param base_dn: The base_dn to lookup.
:return: fully qualified DN. |
386,874 | def main():
global args, server_address
parser = ArgumentParser(description=__doc__)
parser.add_argument(
"host", nargs=,
help="address of host (default %r)" % (SERVER_HOST,),
default=SERVER_HOST,
)
parser.add_argument(
"port", nargs=, type=int,
... | Main function, called when run as an application. |
386,875 | def get_cdd_hdd_candidate_models(
data,
minimum_non_zero_cdd,
minimum_non_zero_hdd,
minimum_total_cdd,
minimum_total_hdd,
beta_cdd_maximum_p_value,
beta_hdd_maximum_p_value,
weights_col,
):
cooling_balance_points = [
int(col[4:]) for col in data.columns if col.startswit... | Return a list of candidate cdd_hdd models for a particular selection
of cooling balance point and heating balance point
Parameters
----------
data : :any:`pandas.DataFrame`
A DataFrame containing at least the column ``meter_value`` and 1 to n
columns each of the form ``hdd_<heating_bala... |
386,876 | def handle_authorized(self, event):
request_software_version(self.client, self.target_jid,
self.success, self.failure) | Send the initial presence after log-in. |
386,877 | def ffill(arr, dim=None, limit=None):
import bottleneck as bn
axis = arr.get_axis_num(dim)
_limit = limit if limit is not None else arr.shape[axis]
return apply_ufunc(bn.push, arr,
dask=,
keep_attrs=True,
output_dtypes=[ar... | forward fill missing values |
386,878 | def get_urlpatterns(self):
return [
path(
_(),
self.topic_lock_view.as_view(),
name=,
),
path(
_(),
self.topic_unlock_view.as_view(),
name=,
),
pat... | Returns the URL patterns managed by the considered factory / application. |
386,879 | def UpdateValues(self):
msg = wx.grid.GridTableMessage(self,
wx.grid.GRIDTABLE_REQUEST_VIEW_GET_VALUES)
self.grid.ProcessTableMessage(msg) | Update all displayed values |
386,880 | def _Execute(statements, context, callback, trace):
if trace:
trace.exec_depth += 1
for i, statement in enumerate(statements):
if isinstance(statement, six.string_types):
callback(statement)
else:
raise | Execute a bunch of template statements in a ScopedContext.
Args:
callback: Strings are "written" to this callback function.
trace: Trace object, or None
This is called in a mutually recursive fashion. |
386,881 | def get_page_template(self, **kwargs):
opts = self.object_list.model._meta
return .format(
opts.app_label,
opts.object_name.lower(),
self.template_name_suffix,
self.page_template_suffix,
) | Return the template name used for this request.
Only called if *page_template* is not given as a kwarg of
*self.as_view*. |
386,882 | def get_flat(self):
self._check_sess()
return np.concatenate([
v.eval(session=self.sess).flatten()
for v in self.variables.values()
]) | Gets the weights and returns them as a flat array.
Returns:
1D Array containing the flattened weights. |
386,883 | def macronize_tags(self, text):
return [self._macronize_word(word) for word in self._retrieve_tag(text)] | Return macronized form along with POS tags.
E.g. "Gallia est omnis divisa in partes tres," ->
[('gallia', 'n-s---fb-', 'galliā'), ('est', 'v3spia---', 'est'), ('omnis', 'a-s---mn-', 'omnis'),
('divisa', 't-prppnn-', 'dīvīsa'), ('in', 'r--------', 'in'), ('partes', 'n-p---fa-', 'partēs'),
... |
386,884 | def disconnect(self, mol):
log.debug()
for smarts in [self._metal_nof, self._metal_non]:
pairs = mol.GetSubstructMatches(smarts)
rwmol = Chem.RWMol(mol)
orders = []
for i, j in pairs:
orders.append(int(mol... | Break covalent bonds between metals and organic atoms under certain conditions.
The algorithm works as follows:
- Disconnect N, O, F from any metal.
- Disconnect other non-metals from transition metals + Al (but not Hg, Ga, Ge, In, Sn, As, Tl, Pb, Bi, Po).
- For every bond broken, adju... |
386,885 | def apply_time_offset(time, years=0, months=0, days=0, hours=0):
return (pd.to_datetime(time.values) +
pd.DateOffset(years=years, months=months, days=days, hours=hours)) | Apply a specified offset to the given time array.
This is useful for GFDL model output of instantaneous values. For example,
3 hourly data postprocessed to netCDF files spanning 1 year each will
actually have time values that are offset by 3 hours, such that the first
value is for 1 Jan 03:00 and the ... |
386,886 | def _filter_defs_at_call_sites(self, defs):
filtered_defs = LiveDefinitions()
for variable, locs in defs.items():
if isinstance(variable, SimRegisterVariable):
if self.project.arch.name == :
if variable.reg in (self.project.arch... | If we are not tracing into the function that are called in a real execution, we should properly filter the defs
to account for the behavior of the skipped function at this call site.
This function is a WIP. See TODOs inside.
:param defs:
:return: |
386,887 | def _serialize_input_list(input_value):
input_list = []
for item in input_value:
if isinstance(item, list):
input_list.append(Task._serialize_input_list(item))
else:
if isinstance(item, File):
item = Task._to_api_file_f... | Recursively serialize task input list |
386,888 | def get_ssm_parameter(parameter_name):
try:
response = boto3.client().get_parameters(
Names=[parameter_name],
WithDecryption=True
)
return response.get(, None)[0].get(, )
except Exception:
pass
return | Get the decrypted value of an SSM parameter
Args:
parameter_name - the name of the stored parameter of interest
Return:
Value if allowed and present else None |
386,889 | def device_status(self):
try:
return self.device_status_simple(
self.data.get().get())
except (KeyError, AttributeError):
return self.device_status_simple() | Return the status of the device as string. |
386,890 | def mutect_to_bed(df):
s = (df.contig.astype(str) + +
(df.position - 1).astype(int).astype(str) + +
df.position.astype(int).astype(str) + +
df.tumor_name)
s = .join(s.values) +
bt = pbt.BedTool(s, from_string=True)
return bt | Convert MuTect results (read into dataframe) to BedTool object
Parameters
----------
df : pandas.DataFrame
Pandas DataFrame with MuTect results.
Returns
-------
bt : pybedtools.BedTool
BedTool with variants. |
386,891 | def handle_assignattr_type(node, parent):
try:
values = set(node.infer())
current = set(parent.instance_attrs_type[node.attrname])
parent.instance_attrs_type[node.attrname] = list(current | values)
except astroid.InferenceError:
pass | handle an astroid.assignattr node
handle instance_attrs_type |
386,892 | def get_ref_dir(region, coordsys):
if region is None:
if coordsys == "GAL":
c = SkyCoord(0., 0., frame=Galactic, unit="deg")
elif coordsys == "CEL":
c = SkyCoord(0., 0., frame=ICRS, unit="deg")
return c
tokens = parse_hpxregio... | Finds and returns the reference direction for a given
HEALPix region string.
region : a string describing a HEALPix region
coordsys : coordinate system, GAL | CEL |
386,893 | def figureStimulus(abf,sweeps=[0]):
stimuli=[2.31250, 2.35270]
for sweep in sweeps:
abf.setsweep(sweep)
for stimulus in stimuli:
S1=int(abf.pointsPerSec*stimulus)
S2=int(abf.pointsPerSec*(stimulus+0.001))
abf.sweepY[S1:S2]=np.nan
I1=int(abf.poi... | Create a plot of one area of interest of a single sweep. |
386,894 | def _group_raw(self, raw_scores, cur=None, level=1):
def trim_groups(r):
if isinstance(r.name, tuple) or isinstance(r.name, list):
new_name = r.name[1:]
else:
new_name = []
return Result(r.weight, r.value, new_name, r.msgs)
... | Internal recursive method to group raw scores into a cascading score summary.
Only top level items are tallied for scores.
@param list raw_scores: list of raw scores (Result objects) |
386,895 | def _update_yaw_and_pitch(self):
front = Vector3([0.0, 0.0, 0.0])
front.x = cos(radians(self.yaw)) * cos(radians(self.pitch))
front.y = sin(radians(self.pitch))
front.z = sin(radians(self.yaw)) * cos(radians(self.pitch))
self.dir = vector.normalise(front)
self.r... | Updates the camera vectors based on the current yaw and pitch |
386,896 | def convert_type(self, type):
mapping = {
: sa.Text,
: None,
: sa.Boolean,
: sa.Date,
: sa.DateTime,
: None,
: None,
: None,
: sa.Integer,
: sa.Float,
: None,
... | Convert type to SQL |
386,897 | def optimize_branch_length(self, mode=, **kwargs):
self.logger("TreeAnc.optimize_branch_length: running branch length optimization in mode %s..."%mode,1)
if (self.tree is None) or (self.aln is None):
self.logger("TreeAnc.optimize_branch_length: ERROR, alignment or tree are missing"... | Perform optimization for the branch lengths of the entire tree.
This method only does a single path and needs to be iterated.
**Note** this method assumes that each node stores information
about its sequence as numpy.array object (node.sequence attribute).
Therefore, before calling this... |
386,898 | def x_axis_rotation(theta):
R = np.array([[1, 0, 0,],
[0, np.cos(theta), -np.sin(theta)],
[0, np.sin(theta), np.cos(theta)]])
return R | Generates a 3x3 rotation matrix for a rotation of angle
theta about the x axis.
Parameters
----------
theta : float
amount to rotate, in radians
Returns
-------
:obj:`numpy.ndarray` of float
A random 3x3 rotation matrix. |
386,899 | def promote_deployment_groups(self, id, groups=list()):
promote_groups_json = {"Groups": groups,
"DeploymentID": id}
return self.request("promote", id, json=promote_groups_json, method="post").json() | This endpoint is used to promote task groups that have canaries for a deployment. This should be done when
the placed canaries are healthy and the rolling upgrade of the remaining allocations should begin.
https://www.nomadproject.io/docs/http/deployments.html
arguments:
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.