Unnamed: 0 int64 0 389k | code stringlengths 26 79.6k | docstring stringlengths 1 46.9k |
|---|---|---|
385,700 | def is_cached(self):
try:
for item in self.rule.output_files:
log.info(item)
self.cachemgr.in_cache(item, self._metahash())
except cache.CacheMiss:
log.info(, self.address)
return False
else:
log.in... | Returns true if this rule is already cached. |
385,701 | def write_header(self):
for properties in self.header.values():
value = properties[]
offset_bytes = int(properties[])
self.file.seek(offset_bytes)
value.tofile(self.file) | Write `header` to `file`.
See Also
--------
write_data |
385,702 | def cancelAllPendingResults( self ):
jobs = self.pendingResults()
if len(jobs) > 0:
self._abortJobs(jobs)
self.notebook().cancelAllPendingResults() | Cancel all pending results. |
385,703 | def from_meta(cls, meta, meta_all=None):
if len(meta.args) == 2:
name = meta.args[1]
meta_type = None
for x in meta_all:
if x.args[1] == name and x.args[0] == :
meta_type = x.description
break
retur... | Copy DocstringMeta from another instance. |
385,704 | def issue_comments(self, issue_id_or_key, extra_query_params={}):
return self.do("GET", "issues/{issue_id_or_key}/comments",
url_params={"issue_id_or_key": issue_id_or_key},
query_params=extra_query_params
) | client = BacklogClient("your_space_name", "your_api_key")
client.issue_comments("YOUR_PROJECT-999") |
385,705 | def to_sigproc_keyword(keyword, value=None):
keyword = bytes(keyword)
if value is None:
return np.int32(len(keyword)).tostring() + keyword
else:
dtype = header_keyword_types[keyword]
dtype_to_type = {b : np.int32,
b : str,
b ... | Generate a serialized string for a sigproc keyword:value pair
If value=None, just the keyword will be written with no payload.
Data type is inferred by keyword name (via a lookup table)
Args:
keyword (str): Keyword to write
value (None, float, str, double or angle): value to write to file
... |
385,706 | def print_report(label, user, system, real):
print("{:<12s} {:12f} {:12f} ( {:12f} )".format(label,
user,
system,
real)) | Prints the report of one step of a benchmark. |
385,707 | def encode(self, b64=False, always_bytes=True):
if self.binary and not b64:
encoded_packet = six.int2byte(self.packet_type)
else:
encoded_packet = six.text_type(self.packet_type)
if self.binary and b64:
encoded_packet = + encoded_packet
... | Encode the packet for transmission. |
385,708 | def start(self, daemon=True):
if self._run_lock.acquire(False):
try:
if self._run_thread is None:
self._run_thread = threading.Thread(target=self._run_in_thread)
self._run_thread.daemon = daemon
... | Start driving the chain asynchronously, return immediately
:param daemon: ungracefully kill the driver when the program terminates
:type daemon: bool |
385,709 | def softmax_to_unary(sm, GT_PROB=1):
warning("pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.")
scale = None if GT_PROB == 1 else GT_PROB
return unary_from_softmax(sm, scale, clip=None) | Deprecated, use `unary_from_softmax` instead. |
385,710 | def teardown(self):
if self.controller:
self.controller.teardown()
for monitor in self.monitors:
monitor.teardown() | Clean up the target once all tests are completed |
385,711 | def notify_slaves(self):
if self.disable_slave_notify is not None:
LOGGER.debug()
return False
if self.zone_data()[] == :
response_code = self._put( + self.domain + ).status_code
if response_code == 200:
LOGGER.debug()
... | Checks to see if slaves should be notified, and notifies them if needed |
385,712 | def to_api_data(self):
data = {}
if self.__interval and isinstance(self.__interval, int):
recurrence_pattern = data[self._cc()] = {}
recurrence_pattern[self._cc()] =
recurrence_pattern[self._cc()] = self.__interval
if self.__days_of_week... | Returns a dict to communicate with the server
:rtype: dict |
385,713 | def get_gradebook_hierarchy_session(self, proxy):
if not self.supports_gradebook_hierarchy():
raise errors.Unimplemented()
return sessions.GradebookHierarchySession(proxy=proxy, runtime=self._runtime) | Gets the session traversing gradebook hierarchies.
arg: proxy (osid.proxy.Proxy): a proxy
return: (osid.grading.GradebookHierarchySession) - a
``GradebookHierarchySession``
raise: NullArgument - ``proxy`` is ``null``
raise: OperationFailed - unable to complete reque... |
385,714 | def create(self, num):
self.log.record_process(, + str(num) + + self.name) | Creates the environment
in your subclassed create function include the line below
super().build(arg1, arg2, arg2, ...) |
385,715 | def get_moments(metricParams, vary_fmax=False, vary_density=None):
psd_amp = metricParams.psd.data
psd_f = numpy.arange(len(psd_amp), dtype=float) * metricParams.deltaF
new_f, new_amp = interpolate_psd(psd_f, psd_amp, metricParams.deltaF)
funct = lambda x,f0: 1
I7 = calcul... | This function will calculate the various integrals (moments) that are
needed to compute the metric used in template bank placement and
coincidence.
Parameters
-----------
metricParams : metricParameters instance
Structure holding all the options for construction of the metric.
vary_fmax... |
385,716 | def find_first_version(self):
for version in self.versions_to_try:
remote_url = self.get_download_url(version=version)
if http_url_exists(remote_url):
return version, remote_url
return None, None | Finds the first version of igraph that exists in the nightly build
repo from the version numbers provided in ``self.versions_to_try``. |
385,717 | def file_is_present(self, file_path):
p = self.p(file_path)
if not os.path.exists(p):
return False
if not os.path.isfile(p):
raise IOError("%s is not a file" % file_path)
return True | check if file 'file_path' is present, raises IOError if file_path
is not a file
:param file_path: str, path to the file
:return: True if file exists, False if file does not exist |
385,718 | def update_members(self, list_id, data):
self.list_id = list_id
if not in data:
raise KeyError()
else:
if not len(data[]) <= 500:
raise ValueError()
for member in data[]:
if not in member:
raise KeyError()
... | Batch subscribe or unsubscribe list members.
Only the members array is required in the request body parameters.
Within the members array, each member requires an email_address
and either a status or status_if_new. The update_existing parameter
will also be considered required to help pr... |
385,719 | def show(self):
print("APKs in Session: {}".format(len(self.analyzed_apk)))
for d, a in self.analyzed_apk.items():
print("\t{}: {}".format(d, a))
print("DEXs in Session: {}".format(len(self.analyzed_dex)))
for d, dex in self.analyzed_dex.items():
print("... | Print information to stdout about the current session.
Gets all APKs, all DEX files and all Analysis objects. |
385,720 | def predict_fixation_duration(
durations, angles, length_diffs, dataset=None, params=None):
if dataset is None:
dataset = np.ones(durations.shape)
corrected_durations = np.nan * np.ones(durations.shape)
for i, ds in enumerate(np.unique(dataset)):
e = lambda v, x, y, z: (leastsq_... | Fits a non-linear piecewise regression to fixtaion durations for a fixmat.
Returns corrected fixation durations. |
385,721 | def diff_tree(candidate_config=None,
candidate_path=None,
running_config=None,
running_path=None,
saltenv=):
*
candidate_tree = tree(config=candidate_config,
path=candidate_path,
saltenv=saltenv)
runn... | Return the diff, as Python dictionary, between the candidate and the running
configuration.
candidate_config
The candidate configuration sent as text. This argument is ignored when
``candidate_path`` is set.
candidate_path
Absolute or remote path from where to load the candidate co... |
385,722 | def ensure_unique(qs, field_name, value, exclude_id=None):
orig = value
if not value:
value = "None"
for x in itertools.count(1):
if not qs.exclude(id=exclude_id).filter(**{field_name: value}).exists():
break
if orig:
value = % (orig, x)
else:
... | Makes sure that `value` is unique on model.fieldname. And nonempty. |
385,723 | def check(self, obj, condition) -> "WriteTransaction":
self._extend([TxItem.new("check", obj, condition)])
return self | Add a condition which must be met for the transaction to commit.
While the condition is checked against the provided object, that object will not be modified. It is only
used to provide the hash and range key to apply the condition to.
At most 10 items can be checked, saved, or deleted in the... |
385,724 | def access_zipped_assets(cls, static_module_name, static_path, dir_location=None):
path = os.path.join(static_path, asset_target)
file_data = resource_string(static_module_name, path)
fp.write(file_data)
if dir_location is None:
temp_dir = safe_mkdtemp()
els... | Create a copy of static resource files as we can't serve them from within the pex file.
:param static_module_name: Module name containing module to cache in a tempdir
:type static_module_name: string, for example 'twitter.common.zookeeper' or similar
:param static_path: Module name, for example 'serverset'... |
385,725 | def create_object(self, filename, img_properties=None):
prop_name = os.path.basename(os.path.normpath(filename))
prop_mime = None
pos = prop_name.rfind()
if pos >= 0:
suffix = prop_name[pos:].lower()
if suffix in VALID_... | Create an image object on local disk from the given file. The file
is copied to a new local directory that is created for the image object.
The optional list of image properties will be associated with the new
object together with the set of default properties for images.
Parameters
... |
385,726 | def column(self):
from .column import Column
if in self.soup:
url = Column_Url + + self.soup[][]
name = self.soup[][]
return Column(url, name, session=self._session)
else:
return None | 获取文章所在专栏.
:return: 文章所在专栏
:rtype: Column |
385,727 | def pretokenized_tfrecord_dataset(filenames,
text2self,
eos_included,
repeat,
batch_size,
sequence_length):
dataset = tf.data.TFRecordDataset(fil... | Reads tensor2tensor-style data files.
The dataset is defined by sets of TFRecord files of TFExample protos.
There should be a "targets" feature (a 1d tensor of integers)
If not text2self, there should also be an "inputs" feature.
Other features get ignored.
eos_included specifies whether the inputs and targ... |
385,728 | def flatten(inputs, scope=None):
if len(inputs.get_shape()) < 2:
raise ValueError()
dims = inputs.get_shape()[1:]
k = dims.num_elements()
with tf.name_scope(scope, , [inputs]):
return tf.reshape(inputs, [-1, k]) | Flattens the input while maintaining the batch_size.
Assumes that the first dimension represents the batch.
Args:
inputs: a tensor of size [batch_size, ...].
scope: Optional scope for name_scope.
Returns:
a flattened tensor with shape [batch_size, k].
Raises:
ValueError: if inputs.shape is ... |
385,729 | def _set_police_priority_map(self, v, load=False):
if hasattr(v, "_utype"):
v = v._utype(v)
try:
t = YANGDynClass(v,base=YANGListType("name",police_priority_map.police_priority_map, yang_name="police-priority-map", rest_name="police-priority-map", parent=self, is_container=, user_ordered=False,... | Setter method for police_priority_map, mapped from YANG variable /police_priority_map (list)
If this variable is read-only (config: false) in the
source YANG file, then _set_police_priority_map is considered as a private
method. Backends looking to populate this variable should
do so via calling thisObj... |
385,730 | def set(self, time_sec, callback_fn, *args, **kwdargs):
timer = self.timer()
timer.set_callback(, callback_fn, *args, **kwdargs)
timer.set(time_sec)
return timer | Convenience function to create and set a timer.
Equivalent to:
timer = timer_factory.timer()
timer.set_callback('expired', callback_fn, *args, **kwdargs)
timer.set(time_sec) |
385,731 | def default_from_address(self):
if self._coinbase_cache_til is not None:
if time.time - self._coinbase_cache_til > 30:
self._coinbase_cache_til = None
self._coinbase_cache = None
if self._coinbase_cache is None:
self._coinbase_cache = sel... | Cache the coinbase address so that we don't make two requests for every
single transaction. |
385,732 | def reset( self ):
self.setValue(, XPaletteColorSet())
self.setValue(, QApplication.font())
self.setValue(, QApplication.font().pointSize()) | Resets the values to the current application information. |
385,733 | def setText(self, sequence):
self.setToolTip(sequence)
super(ShortcutLineEdit, self).setText(sequence) | Qt method extension. |
385,734 | def set_starting_ratio(self, ratio):
from samplerate.lowlevel import src_set_ratio
if self._state is None:
self._create()
src_set_ratio(self._state, ratio)
self.ratio = ratio | Set the starting conversion ratio for the next `read` call. |
385,735 | def connect(self):
sock = socket.create_connection((self.host, self.port),
self.timeout, self.source_address)
if getattr(self, , None):
self.sock = sock
self._tunnel()
self.sock = ssl.wrap_so... | Overrides HTTPSConnection.connect to specify TLS version |
385,736 | def get_by_ip(cls, ip):
ret = cls.hosts_by_ip.get(ip)
if ret is None:
ret = cls.hosts_by_ip[ip] = [Host(ip)]
return ret | Returns Host instance for the given ip address. |
385,737 | def multiply(self, a, b):
if a is None or b is None: return None
m, n = len(a), len(b[0])
if len(b) != n:
raise Exception("As row number.")
l = len(b[0])
table_a, table_b = {}, {}
for i, row in enumerate(a):
for j, ele in enumerate(row):
if ele:
i... | :type A: List[List[int]]
:type B: List[List[int]]
:rtype: List[List[int]] |
385,738 | def download(self, url, path):
qurl = QUrl(url)
url = to_text_string(qurl.toEncoded(), encoding=)
logger.debug(str((url, path)))
if url in self._workers:
while not self._workers[url].finished:
return self._workers[url]
worker = Dow... | Download url and save data to path. |
385,739 | def is_unit(q):
if isinstance(q, six.string_types):
try: return hasattr(units, q)
except: return False
else:
cls = type(q)
return cls.__module__.startswith() and cls.__name__ == | is_unit(q) yields True if q is a pint unit or a string that names a pint unit and False
otherwise. |
385,740 | def _expand_host(self, host):
if isinstance(host, basestring):
return (host, self.default_port)
return tuple(host) | Used internally to add the default port to hosts not including
portnames. |
385,741 | def write(filename, mesh, write_binary=True):
if mesh.points.shape[1] == 2:
logging.warning(
"msh2 requires 3D points, but 2D points given. "
"Appending 0 third component."
)
mesh.points = numpy.column_stack(
[mesh.points[:, 0], mesh.points[:, 1], num... | Writes msh files, cf.
<http://gmsh.info//doc/texinfo/gmsh.html#MSH-ASCII-file-format>. |
385,742 | def _set_pw_profile(self, v, load=False):
if hasattr(v, "_utype"):
v = v._utype(v)
try:
t = YANGDynClass(v,base=YANGListType("pw_profile_name",pw_profile.pw_profile, yang_name="pw-profile", rest_name="pw-profile", parent=self, is_container=, user_ordered=False, path_helper=self._path_helper, ya... | Setter method for pw_profile, mapped from YANG variable /pw_profile (list)
If this variable is read-only (config: false) in the
source YANG file, then _set_pw_profile is considered as a private
method. Backends looking to populate this variable should
do so via calling thisObj._set_pw_profile() directly... |
385,743 | def when_connected(self):
if self._client and not self._client.is_closed:
return defer.succeed(self._client)
else:
return self._client_deferred | Retrieve the currently-connected Protocol, or the next one to connect.
Returns:
defer.Deferred: A Deferred that fires with a connected
:class:`FedoraMessagingProtocolV2` instance. This is similar to
the whenConnected method from the Twisted endpoints APIs, which
... |
385,744 | def view(self, buffer_time = 10.0, sample_size = 10000, name=None, description=None, start=False):
if name is None:
name = .join(random.choice() for x in range(16))
if self.oport.schema == streamsx.topology.schema.CommonSchema.Python:
if self._json_stream:
... | Defines a view on a stream.
A view is a continually updated sampled buffer of a streams's tuples.
Views allow visibility into a stream from external clients such
as Jupyter Notebooks, the Streams console,
`Microsoft Excel <https://www.ibm.com/support/knowledgecenter/SSCRJU_4.2.0/com.ibm... |
385,745 | def chempot_vs_gamma_plot_one(self, plt, entry, ref_delu, chempot_range,
delu_dict={}, delu_default=0, label=, JPERM2=False):
chempot_range = sorted(chempot_range)
ucell_comp = self.ucell_entry.composition.reduced_composition
if entr... | Helper function to help plot the surface energy of a
single SlabEntry as a function of chemical potential.
Args:
plt (Plot): A plot.
entry (SlabEntry): Entry of the slab whose surface energy we want
to plot
ref_delu (sympy Symbol): The range stabilit... |
385,746 | def add_device_notification(self, data_name, attr, callback, user_handle=None):
if self._port is not None:
notification_handle, user_handle = adsSyncAddDeviceNotificationReqEx(
self._port, self._adr, data_name, attr, callback, user_handle
)
... | Add a device notification.
:param str data_name: PLC storage address
:param pyads.structs.NotificationAttrib attr: object that contains
all the attributes for the definition of a notification
:param callback: callback function that gets executed on in the event
of ... |
385,747 | def all(self, fields=None, include_fields=True, page=None, per_page=None, extra_params=None):
params = extra_params or {}
params[] = fields and .join(fields) or None
params[] = str(include_fields).lower()
params[] = page
params[] = per_page
return self.client.ge... | Retrieves a list of all the applications.
Important: The client_secret and encryption_key attributes can only be
retrieved with the read:client_keys scope.
Args:
fields (list of str, optional): A list of fields to include or
exclude from the result (depending on includ... |
385,748 | def connect(host=None,
port=rethinkdb.DEFAULT_PORT,
timeout=20,
verify=True,
**kwargs):
if not host:
host = DEFAULT_HOSTS.get(check_stage_env())
connection = None
tries = 0
time_quit = time() + timeout
while not connection and time() <= ti... | RethinkDB semantic connection wrapper
raises <brain.connection.BrainNotReady> if connection verification fails
:param verify: <bool> (default True) whether to run POST
:param timeout: <int> max time (s) to wait for connection
:param kwargs: <dict> passthrough rethinkdb arguments
:return: |
385,749 | def p_function_declaration(self, p):
if len(p) == 8:
p[0] = ast.FuncDecl(
identifier=p[2], parameters=None, elements=p[6])
else:
p[0] = ast.FuncDecl(
identifier=p[2], parameters=p[4], elements=p[7]) | function_declaration \
: FUNCTION identifier LPAREN RPAREN LBRACE function_body RBRACE
| FUNCTION identifier LPAREN formal_parameter_list RPAREN LBRACE \
function_body RBRACE |
385,750 | def filter_cat(self, axis, cat_index, cat_name):
run_filter.filter_cat(self, axis, cat_index, cat_name) | Filter the matrix based on their category. cat_index is the index of the category, the first category has index=1. |
385,751 | def shewhart(self, data: [, str] = None,
boxchart: str = None,
cchart: str = None,
irchart: str = None,
mchart: str = None,
mrchart: str = None,
npchart: str = None,
pchart: str = None,
... | Python method to call the SHEWHART procedure
Documentation link:
https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=qcug&docsetTarget=qcug_shewhart_toc.htm&locale=en
:param data: SASdata object or string. This parameter is required.
:parm boxchart: The boxcha... |
385,752 | def save_config(self, cmd="save config", confirm=False, confirm_response=""):
return super(ExtremeVspSSH, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | Save Config |
385,753 | def generate_n_vectors(N_max, dx=1, dy=1, dz=1, half_lattice=True):
r
vecs = np.meshgrid(np.arange(-N_max, N_max+1, dx),
np.arange(-N_max, N_max+1, dy),
np.arange(-N_max, N_max+1, dz))
vecs = np.vstack(map(np.ravel, vecs)).T
vecs = vecs[np.linalg.norm(vecs, ... | r"""
Generate integer vectors, :math:`\boldsymbol{n}`, with
:math:`|\boldsymbol{n}| < N_{\rm max}`.
If ``half_lattice=True``, only return half of the three-dimensional
lattice. If the set N = {(i,j,k)} defines the lattice, we restrict to
the cases such that ``(k > 0)``, ``(k = 0, j > 0)``, and
... |
385,754 | def set_voltage(self, value, channel=1):
cmd = "V%d %f" % (channel, value)
self.write(cmd) | channel: 1=OP1, 2=OP2, AUX is not supported |
385,755 | def ToRequest(self):
param = {}
if self.email:
param[] = self.email
if self.user_id:
param[] = self.user_id
if self.name:
param[] = self.name
if self.photo_url:
param[] = self.photo_url
if self.email_verified is not None:
param[] = self.email_verified
if se... | Converts to gitkit api request parameter dict.
Returns:
Dict, containing non-empty user attributes. |
385,756 | def partial_derivative(self, X, y=0):
self.check_fit()
U, V = self.split_matrix(X)
if self.theta == 1:
return V
else:
t1 = np.power(-np.log(U), self.theta)
t2 = np.power(-np.log(V), self.theta)
p1 = self.cumulative_distribution(... | Compute partial derivative :math:`C(u|v)` of cumulative density.
Args:
X: `np.ndarray`
y: `float`
Returns: |
385,757 | def wmean_and_var_str_array(W, x):
m = np.empty(shape=x.shape[1:], dtype=x.dtype)
v = np.empty_like(m)
for p in x.dtype.names:
m[p], v[p] = wmean_and_var(W, x[p]).values()
return {: m, : v} | Weighted mean and variance of each component of a structured array.
Parameters
----------
W: (N,) ndarray
normalised weights (must be >=0 and sum to one).
x: (N,) structured array
data
Returns
-------
dictionary
{'mean':weighted_means, 'var':weighted_variances} |
385,758 | def is_quota_exceeded(self) -> bool:
if self.quota and self._url_table is not None:
return self.size >= self.quota and \
self._url_table.get_root_url_todo_count() == 0 | Return whether the quota is exceeded. |
385,759 | def wanmen_download_by_course_topic_part(json_api_content, tIndex, pIndex, output_dir=, merge=True, info_only=False, **kwargs):
html = json_api_content
title = _wanmen_get_title_by_json_topic_part(html,
tIndex,
... | int, int, int->None
Download ONE PART of the course. |
385,760 | def filler(self):
if not self.filled:
raise SlotNotFilledError(
% (self.name, self.key))
return self._filler_pipeline_key.name() | Returns the pipeline ID that filled this slot's value.
Returns:
A string that is the pipeline ID.
Raises:
SlotNotFilledError if the value hasn't been filled yet. |
385,761 | def _get_span(self, m):
return (m.sentence.id, m.char_start, m.char_end) | Gets a tuple that identifies a span for the specific mention class
that m belongs to. |
385,762 | async def stepper_config(self, steps_per_revolution, stepper_pins):
data = [PrivateConstants.STEPPER_CONFIGURE, steps_per_revolution & 0x7f,
(steps_per_revolution >> 7) & 0x7f]
for pin in range(len(stepper_pins)):
data.append(stepper_pins[pin])
await self._se... | Configure stepper motor prior to operation.
This is a FirmataPlus feature.
:param steps_per_revolution: number of steps per motor revolution
:param stepper_pins: a list of control pin numbers - either 4 or 2
:returns: No return value. |
385,763 | def _mod_spec(self):
mod_spec={}
for mod, sizes in self.int_len_mod.items():
for conv in self.int_sign[]:
mod_spec[mod + conv] = sizes[0]
for conv in self.int_sign[]:
mod_spec[mod + conv] = sizes[1]
return mod_spec | Modified length specifiers: mapping between length modifiers and conversion specifiers. This generates all the
possibilities, i.e. hhd, etc. |
385,764 | def _check_max_running(self, func, data, opts, now):
if not data[]:
return data
if not in data or data[]:
jobcount = 0
if self.opts[] == :
current_jobs = salt.utils.master.get_running_jobs(self.opts)
els... | Return the schedule data structure |
385,765 | def make_app(global_conf, full_stack=True, **app_conf):
app = make_base_app(global_conf, full_stack=True, **app_conf)
from depot.manager import DepotManager
app = DepotManager.make_middleware(app)
return app | Set depotexample up with the settings found in the PasteDeploy configuration
file used.
:param global_conf: The global settings for depotexample (those
defined under the ``[DEFAULT]`` section).
:type global_conf: dict
:param full_stack: Should the whole TG2 stack be set up?
:type full_s... |
385,766 | def get_trans(self, out_vec=None):
if out_vec:
return out_vec.set(*self.data[3][:3])
return Vec3(*self.data[3][:3]) | Return the translation portion of the matrix as a vector.
If out_vec is provided, store in out_vec instead of creating a new Vec3. |
385,767 | def set_hot_pluggable_for_device(self, name, controller_port, device, hot_pluggable):
if not isinstance(name, basestring):
raise TypeError("name can only be an instance of type basestring")
if not isinstance(controller_port, baseinteger):
raise TypeError("controller_port... | Sets a flag in the device information which indicates that the attached
device is hot pluggable or not. This may or may not be supported by a
particular controller and/or drive, and is silently ignored in the
latter case. Changing the setting while the VM is running is forbidden.
The dev... |
385,768 | def format_args(self, args):
def format_arg(a):
if isinstance(a, dbus.Boolean):
return str(bool(a))
if isinstance(a, dbus.Byte):
return str(int(a))
if isinstance(a, int) or isinstance(a, long):
return str(a)
... | Format a D-Bus argument tuple into an appropriate logging string. |
385,769 | def create_empty_dataset(self, dataset_id="", project_id="",
dataset_reference=None):
if dataset_reference:
_validate_value(, dataset_reference, dict)
else:
dataset_reference = {}
if "datasetReference" not in dataset_reference:
... | Create a new empty dataset:
https://cloud.google.com/bigquery/docs/reference/rest/v2/datasets/insert
:param project_id: The name of the project where we want to create
an empty a dataset. Don't need to provide, if projectId in dataset_reference.
:type project_id: str
:param ... |
385,770 | def add_time_step(self, **create_time_step_kwargs):
ts = time_step.TimeStep.create_time_step(**create_time_step_kwargs)
assert isinstance(ts, time_step.TimeStep)
self._time_steps.append(ts) | Creates a time-step and appends it to the list.
Args:
**create_time_step_kwargs: Forwarded to
time_step.TimeStep.create_time_step. |
385,771 | def absent(name,
**kwargs):
ret = {: name,
: True,
: {},
: []}
if __salt__[](name):
try:
__salt__[](name)
except CommandExecutionError as exc:
return _fail(ret, exc.strerror)
else:
ret[] = {0}\.format(n... | Ensure the job is absent from the Jenkins configured jobs
name
The name of the Jenkins job to remove |
385,772 | def status(name, init_system, verbose):
try:
status = Serv(init_system, verbose=verbose).status(name)
except ServError as ex:
sys.exit(ex)
click.echo(json.dumps(status, indent=4, sort_keys=True)) | WIP! Try at your own expense |
385,773 | def from_schema(cls, schema, handlers={}, **kwargs):
return cls(
schema.get(, schema.get(, )) if isinstance(schema, dict) else ,
schema,
handlers=handlers,
**kwargs
) | Construct a resolver from a JSON schema object. |
385,774 | def get_argument_parser():
file_mv = cli.file_mv
desc =
parser = cli.get_argument_parser(desc)
parser.add_argument(
, , type=str, required=True, metavar=file_mv,
help=
)
parser.add_argument(
, , type=str, required=True, metavar=file_mv,
help=
)
p... | Function to obtain the argument parser.
Returns
-------
A fully configured `argparse.ArgumentParser` object.
Notes
-----
This function is used by the `sphinx-argparse` extension for sphinx. |
385,775 | def _compress(self, data, operation):
original_output_size = int(
math.ceil(len(data) + (len(data) >> 2) + 10240)
)
available_out = ffi.new("size_t *")
available_out[0] = original_output_size
output_buffer = ffi.new("uint8_t []", available_o... | This private method compresses some data in a given mode. This is used
because almost all of the code uses the exact same setup. It wouldn't
have to, but it doesn't hurt at all. |
385,776 | def plot_surface(x, y, z, color=default_color, wrapx=False, wrapy=False):
return plot_mesh(x, y, z, color=color, wrapx=wrapx, wrapy=wrapy, wireframe=False) | Draws a 2d surface in 3d, defined by the 2d ordered arrays x,y,z.
:param x: {x2d}
:param y: {y2d}
:param z: {z2d}
:param color: {color2d}
:param bool wrapx: when True, the x direction is assumed to wrap, and polygons are drawn between the end end begin points
:param bool wrapy: simular for the ... |
385,777 | def from_url(cls, reactor, url, key, alg=RS256, jws_client=None):
action = LOG_ACME_CONSUME_DIRECTORY(
url=url, key_type=key.typ, alg=alg.name)
with action.context():
check_directory_url_type(url)
jws_client = _default_client(jws_client, reactor, key, alg)
... | Construct a client from an ACME directory at a given URL.
:param url: The ``twisted.python.url.URL`` to fetch the directory from.
See `txacme.urls` for constants for various well-known public
directories.
:param reactor: The Twisted reactor to use.
:param ~josepy.jwk.JWK... |
385,778 | def open(self, inf, psw):
if inf.file_redir:
if inf.file_redir[0] in (RAR5_XREDIR_FILE_COPY, RAR5_XREDIR_HARD_LINK):
inf = self.getinfo(inf.file_redir[2])
if not inf:
raise BadRarFile()
if inf.flags & RAR_FILE_SPLIT_... | Return stream object for file data. |
385,779 | def get_node_attribute(self, node, attribute_name):
if not self.has_node(node):
raise ValueError("No such node exists.")
elif attribute_name not in self._node_attributes[node]:
raise ValueError("No such attribute exists.")
else:
return copy.\
... | Given a node and the name of an attribute, get a copy
of that node's attribute.
:param node: reference to the node to retrieve the attribute of.
:param attribute_name: name of the attribute to retrieve.
:returns: attribute value of the attribute_name key for the
specifie... |
385,780 | def list_projects(self):
data = self._run(
url_path="projects/list"
)
projects = data[].get(, [])
return [self._project_formatter(item) for item in projects] | Returns the list of projects owned by user. |
385,781 | def reportResourceUsage(imageObjectList, outwcs, num_cores,
interactive=False):
from . import imageObject
if outwcs is None:
output_mem = 0
else:
if isinstance(outwcs,imageObject.WCSObject):
owcs = outwcs.final_wcs
else:
owcs = ou... | Provide some information to the user on the estimated resource
usage (primarily memory) for this run. |
385,782 | def _gen_vol_xml(vmname,
diskname,
disktype,
size,
pool):
size = int(size) * 1024
context = {
: vmname,
: .format(diskname, disktype),
: diskname,
: disktype,
: six.text_type(size),
: pool,... | Generate the XML string to define a libvirt storage volume |
385,783 | def deleteByteArray(self, context, page, returnError):
returnError.contents.value = self.IllegalStateError
raise NotImplementedError("You must override this method.") | please override |
385,784 | def unwrap(s, node_indent):
def get_indent():
if line_str.startswith():
return node_indent
return len(re.match(r"^( *)", line_str).group(1))
def finish_block():
if block_list:
unwrap_list.append(
(block_indent, (" ".join([v.strip() for v in ... | Group lines of a docstring to blocks.
For now, only groups markdown list sections.
A block designates a list of consequtive lines that all start at the same
indentation level.
The lines of the docstring are iterated top to bottom. Each line is added to
`block_list` until a line is encountered tha... |
385,785 | def writeto(fpath, to_write, aslines=False, verbose=None):
r
if verbose:
print( % (fpath,))
with open(fpath, ) as file:
if aslines:
to_write = map(_ensure_bytes , to_write)
file.writelines(to_write)
else:
bytes = _ensure_bytes(to_writ... | r"""
Writes (utf8) text to a file.
Args:
fpath (PathLike): file path
to_write (str): text to write (must be unicode text)
aslines (bool): if True to_write is assumed to be a list of lines
verbose (bool): verbosity flag
CommandLine:
python -m ubelt.util_io writeto --... |
385,786 | def compute_hkdf(ikm, salt):
prk = hmac.new(salt, ikm, hashlib.sha256).digest()
info_bits_update = info_bits + bytearray(chr(1), )
hmac_hash = hmac.new(prk, info_bits_update, hashlib.sha256).digest()
return hmac_hash[:16] | Standard hkdf algorithm
:param {Buffer} ikm Input key material.
:param {Buffer} salt Salt value.
:return {Buffer} Strong key material.
@private |
385,787 | def fromJavascript(cls, javascript_datetime):
title =
jsDTpattern = re.compile()
jsGMTpattern = re.compile()
if not jsGMTpattern.findall(javascript_datetime):
raise Exception( % title)
adj_input = jsDTpattern.sub(, javascript_datetime)... | a method to construct labDT from a javascript datetime string
:param javascript_datetime: string with datetime info in javascript formatting
:return: labDT object |
385,788 | def find_win32_generator():
ver = int(m.group(1))
return ver >= 14
generators = list(filter(drop_old_vs, generators))
generators.append( + ( if is_64bit else ))
for generator in generators:
build_dir = tempfile.mkdtemp()
print("Trying generator %r" % (generator,))
... | Find a suitable cmake "generator" under Windows. |
385,789 | def walker(self, path=None, base_folder=None):
path = path or self.path or
base_folder = base_folder or self.base_folder
path = os.path.normpath(upath(path))
if base_folder:
base_folder = os.path.normpath(upath(base_folder))
print("The directory... | This method walk a directory structure and create the
Folders and Files as they appear. |
385,790 | def list_sinks(self, project, page_size=0, page_token=None):
path = "projects/%s" % (project,)
page_iter = self._gapic_api.list_sinks(path, page_size=page_size)
page_iter.client = self._client
page_iter.next_page_token = page_token
page_iter.item_to_value = _item_to_sink... | List sinks for the project associated with this client.
:type project: str
:param project: ID of the project whose sinks are to be listed.
:type page_size: int
:param page_size: maximum number of sinks to return, If not passed,
defaults to a value set by the A... |
385,791 | def plot(self, data):
import IPython
if not isinstance(data, dict) or not all(isinstance(v, pd.DataFrame) for v in data.values()):
raise ValueError()
gfsg = GenericFeatureStatisticsGenerator()
data = [{: k, : self._remove_nonascii(v)} for k, v in six.iteritems(data)]
data_proto = gfsg.... | Plots an overview in a list of dataframes
Args:
data: a dictionary with key the name, and value the dataframe. |
385,792 | def branches(self):
if self._branches is None:
cmd = .format(self.sha1)
out = shell.run(
cmd,
capture=True,
never_pretend=True
).stdout.strip()
self._branches = [x.strip() for x in out.splitlines()]... | List of all branches this commit is a part of. |
385,793 | def _spawn_background_rendering(self, rate=5.0):
self.render_trigger.connect(self.ren_win.Render)
twait = rate**-1
def render():
while self.active:
time.sleep(twait)
self._render()
self.render_thread = Thread(target=render)
s... | Spawns a thread that updates the render window.
Sometimes directly modifiying object data doesn't trigger
Modified() and upstream objects won't be updated. This
ensures the render window stays updated without consuming too
many resources. |
385,794 | def delete(self, user, commit=True):
events.user_delete_event.send(user)
return super().delete(user, commit) | Delete a user |
385,795 | def sde(self):
variance = float(self.variance.values)
lengthscale = float(self.lengthscale.values)
foo = np.sqrt(3.)/lengthscale
F = np.array([[0, 1], [-foo**2, -2*foo]])
L = np.array([[0], [1]])
Qc = np.array([[12.*np.sqrt(3) / lengthscale**3 * variance... | Return the state space representation of the covariance. |
385,796 | def train(cls, rdd, k, maxIterations=100, initMode="random"):
r
model = callMLlibFunc("trainPowerIterationClusteringModel",
rdd.map(_convert_to_vector), int(k), int(maxIterations), initMode)
return PowerIterationClusteringModel(model) | r"""
:param rdd:
An RDD of (i, j, s\ :sub:`ij`\) tuples representing the
affinity matrix, which is the matrix A in the PIC paper. The
similarity s\ :sub:`ij`\ must be nonnegative. This is a symmetric
matrix and hence s\ :sub:`ij`\ = s\ :sub:`ji`\ For any (i, j) with
... |
385,797 | def set_pool_quota(service, pool_name, max_bytes=None, max_objects=None):
cmd = [, , service, , , , pool_name]
if max_bytes:
cmd = cmd + [, str(max_bytes)]
if max_objects:
cmd = cmd + [, str(max_objects)]
check_call(cmd) | :param service: The Ceph user name to run the command under
:type service: str
:param pool_name: Name of pool
:type pool_name: str
:param max_bytes: Maximum bytes quota to apply
:type max_bytes: int
:param max_objects: Maximum objects quota to apply
:type max_objects: int
:raises: subpro... |
385,798 | def idle_task(self):
if self.threat_timeout_timer.trigger():
self.check_threat_timeout()
if self.threat_detection_timer.trigger():
self.perform_threat_detection() | called on idle |
385,799 | def props_to_image(regionprops, shape, prop):
r
im = sp.zeros(shape=shape)
for r in regionprops:
if prop == :
mask = r.convex_image
else:
mask = r.image
temp = mask * r[prop]
s = bbox_to_slices(r.bbox)
im[s] += temp
return im | r"""
Creates an image with each region colored according the specified ``prop``,
as obtained by ``regionprops_3d``.
Parameters
----------
regionprops : list
This is a list of properties for each region that is computed
by PoreSpy's ``regionprops_3D`` or Skimage's ``regionsprops``.
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.