Unnamed: 0 int64 0 389k | code stringlengths 26 79.6k | docstring stringlengths 1 46.9k |
|---|---|---|
384,300 | def create(self, ip_access_control_list_sid):
data = values.of({: ip_access_control_list_sid, })
payload = self._version.create(
,
self._uri,
data=data,
)
return IpAccessControlListMappingInstance(
self._version,
payl... | Create a new IpAccessControlListMappingInstance
:param unicode ip_access_control_list_sid: The unique id of the IP access control list to map to the SIP domain
:returns: Newly created IpAccessControlListMappingInstance
:rtype: twilio.rest.api.v2010.account.sip.domain.ip_access_control_list_map... |
384,301 | def search(self, entity_type, property_name, search_string, start_index=0, max_results=99999):
params = {
"entity-type": entity_type,
"expand": entity_type,
"property-search-restriction": {
"property": {"name": property_name, "type": "STRING"},
... | Performs a user search using the Crowd search API.
https://developer.atlassian.com/display/CROWDDEV/Crowd+REST+Resources#CrowdRESTResources-SearchResource
Args:
entity_type: 'user' or 'group'
property_name: eg. 'email', 'name'
search_string: the string to search for... |
384,302 | def get_redirect_target():
for target in request.values.get(), request.referrer:
if target and is_local_url(target):
return target | Get URL to redirect to and ensure that it is local. |
384,303 | def filename(self):
self._filename = getattr(self, , None)
self._root_path = getattr(self, , None)
if self._filename is None and self._root_path is None:
return self._filename_global()
else:
return self._filename_projects() | Defines the name of the configuration file to use. |
384,304 | def _find_zone_by_id(self, zone_id):
if not self.zones:
return None
zone = list(filter(
lambda zone: zone.id == zone_id, self.zones))
return zone[0] if zone else None | Return zone by id. |
384,305 | def find_two_letter_edits(word_string):
if word_string is None:
return {}
elif isinstance(word_string, str):
return (e2 for e1 in find_one_letter_edits(word_string) for e2 in find_one_letter_edits(e1))
else:
raise InputError("string or none type variable not passed as argument t... | Finds all possible two letter edits of word_string:
- Splitting word_string into two words at all character locations
- Deleting one letter at all character locations
- Switching neighbouring characters
- Replacing a character with every alphabetical letter
- Inserting all possible alphabetical char... |
384,306 | def copy(self, *args, **kwargs):
for slot in self.__slots__:
attr = getattr(self, slot)
if slot[0] == :
slot = slot[1:]
if slot not in kwargs:
kwargs[slot] = attr
result = type(self)(*args, **kwargs)
return result | Copy this model element and contained elements if they exist. |
384,307 | def __on_message(self, ws, msg):
msg = json.loads(msg)
logging.debug("ConnectorDB:WS: Msg ", msg["stream"])
stream_key = msg["stream"] + ":"
if "transform" in msg:
stream_key += msg["transform"]
self.subscription_lock.acquire()
if stream_ke... | This function is called whenever there is a message received from the server |
384,308 | def _attach_params(self, params, **kwargs):
lst = params.to_list() if isinstance(params, ParameterSet) else params
for param in lst:
param._bundle = self
for k, v in kwargs.items():
self._params.append(param)
self._check_copy_for()
... | Attach a list of parameters (or ParameterSet) to this ParameterSet.
:parameter list params: list of parameters, or ParameterSet
:parameter **kwargs: attributes to set for each parameter (ie tags) |
384,309 | def _get_position_from_instance(self, instance, ordering):
qs_order = getattr(instance, )
result = super(SequenceCursorPagination, self)._get_position_from_instance(instance, ordering[1:])
return (qs_order, result) | The position will be a tuple of values:
The QuerySet number inside of the QuerySetSequence.
Whatever the normal value taken from the ordering property gives. |
384,310 | def _sort_locations(locations, expand_dir=False):
files = []
urls = []
def sort_path(path):
url = path_to_url(path)
if mimetypes.guess_type(url, strict=False)[0] == :
urls.append(url)
else:
files.append(url)
... | Sort locations into "files" (archives) and "urls", and return
a pair of lists (files,urls) |
384,311 | def GetCpuReservationMHz(self):
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetCpuReservationMHz(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | Retrieves the minimum processing power in MHz reserved for the virtual
machine. For information about setting a CPU reservation, see "Limits and
Reservations" on page 14. |
384,312 | def copy(self):
health = self.health, self.health_max
r = self.r, self.r_max
g = self.g, self.g_max
b = self.b, self.b_max
y = self.y, self.y_max
x = self.x, self.x_max
m = self.m, self.m_max
h = self.h, self.h_max
c = self.c, self.c_max
... | Return a copy of this actor with the same attribute values. |
384,313 | def _to_http_hosts(hosts: Union[Iterable[str], str]) -> List[str]:
if isinstance(hosts, str):
hosts = hosts.replace(, ).split()
return [_to_http_uri(i) for i in hosts] | Convert a string of whitespace or comma separated hosts into a list of hosts.
Hosts may also already be a list or other iterable.
Each host will be prefixed with 'http://' if it is not already there.
>>> _to_http_hosts('n1:4200,n2:4200')
['http://n1:4200', 'http://n2:4200']
>>> _to_http_hosts('n1... |
384,314 | def upload(self, array, fields=None, table="MyDB", configfile=None):
wsid=
password=
if configfile is None:
configfile = "CasJobs.config"
logger.info("Reading config file: %s"%configfile)
lines = open(configfile,).readlines()
for line in lines:
... | Upload an array to a personal database using SOAP POST protocol.
http://skyserver.sdss3.org/casjobs/services/jobs.asmx?op=UploadData |
384,315 | def local_batch_predict(training_dir, prediction_input_file, output_dir, mode, batch_size,
shard_files, output_format):
from .prediction import predict as predict_module
if mode == :
model_dir = os.path.join(training_dir, )
elif mode == :
model_dir = os.path.join(training_di... | See batch_predict |
384,316 | def _handle_final_metric_data(self, data):
id_ = data[]
value = data[]
if id_ in _customized_parameter_ids:
self.tuner.receive_customized_trial_result(id_, _trial_params[id_], value)
else:
self.tuner.receive_trial_result(id_, _trial_params[id_], value) | Call tuner to process final results |
384,317 | def append(self, header, f, _left=False):
self.items_length += len(header)
if _left:
self.deque.appendleft((header, f))
else:
self.deque.append((header, f)) | Add a column to the table.
Args:
header (str):
Column header
f (function(datum)->str):
Makes the row string from the datum. Str returned by f should
have the same width as header. |
384,318 | def SpiceUDREPU(f):
@functools.wraps(f)
def wrapping_udrepu(beg, end, et):
f(beg, end, et)
return UDREPU(wrapping_udrepu) | Decorator for wrapping python functions in spice udrepu callback type
:param f: function to be wrapped
:type f: builtins.function
:return: wrapped udrepu function
:rtype: builtins.function |
384,319 | def plot_slippage_sensitivity(returns, positions, transactions,
ax=None, **kwargs):
if ax is None:
ax = plt.gca()
avg_returns_given_slippage = pd.Series()
for bps in range(1, 100):
adj_returns = txn.adjust_returns_for_slippage(returns, positions,
... | Plots curve relating per-dollar slippage to average annual returns.
Parameters
----------
returns : pd.Series
Timeseries of portfolio returns to be adjusted for various
degrees of slippage.
positions : pd.DataFrame
Daily net position values.
- See full explanation in te... |
384,320 | def validate(self):
assert self.path, "{} must have a path".format(self.__class__.__name__)
ext = extract_path_ext(self.path, default_ext=self.subtitlesformat)
if ext not in self.allowed_formats and ext not in CONVERTIBLE_FORMATS[self.get_preset()]:
raise ValueError(.format(... | Ensure `self.path` has one of the extensions in `self.allowed_formats`. |
384,321 | def dictionary(self) -> dict:
self.config.read(self.filepath)
return self.config._sections | Get a python dictionary of contents. |
384,322 | def download_song_by_id(self, song_id, song_name, folder=):
try:
url = self.crawler.get_song_url(song_id)
if self.lyric:
lyric_info = self.crawler.get_song_lyric(song_id)
else:
lyric_info = None
song_name ... | Download a song by id and save it to disk.
:params song_id: song id.
:params song_name: song name.
:params folder: storage path. |
384,323 | def licenses_configured(name, licenses=None):
t, it creates it
Check if license is assigned to the cluster:
- if its no space
- if it
ret = {: name,
: {},
: None,
: }
if not licenses:
raise salt.exceptions.ArgumentValueError()
cluster_name, da... | Configures licenses on the cluster entity
Checks if each license exists on the server:
- if it doesn't, it creates it
Check if license is assigned to the cluster:
- if it's not assigned to the cluster:
- assign it to the cluster if there is space
- error if there's no sp... |
384,324 | def _execute_wk(*args, input=None):
wk_args = (WK_PATH,) + args
return subprocess.run(wk_args, input=input, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | Generate path for the wkhtmltopdf binary and execute command.
:param args: args to pass straight to subprocess.Popen
:return: stdout, stderr |
384,325 | def path(self):
p = os.path.normpath(self._path)
if p.endswith():
p = p + os.path.sep
return p | Return path
:returns: path
:rtype: str
:raises: None |
384,326 | def ssh_reachable(self, tries=None, propagate_fail=True):
if not self.running():
return False
try:
ssh.get_ssh_client(
ip_addr=self.ip(),
host_name=self.name(),
ssh_tries=tries,
propagate_fail=propagate_fai... | Check if the VM is reachable with ssh
Args:
tries(int): Number of tries to try connecting to the host
propagate_fail(bool): If set to true, this event will appear
in the log and fail the outter stage. Otherwise, it will be
discarded.
Returns:
b... |
384,327 | def clear(self):
self.__cancel_timer()
self.__timer = None
self.__timer_args = None
self.__still_valid = False
self._value = None
super(TemporalDependency, self).clear() | Cleans up the manager. The manager can't be used after this method has
been called |
384,328 | def next_k_array(a):
k = len(a)
if k == 1 or a[0] + 1 < a[1]:
a[0] += 1
return a
a[0] = 0
i = 1
x = a[i] + 1
while i < k-1 and x == a[i+1]:
i += 1
a[i-1] = i - 1
x = a[i] + 1
a[i] = x
return a | Given an array `a` of k distinct nonnegative integers, sorted in
ascending order, return the next k-array in the lexicographic
ordering of the descending sequences of the elements [1]_. `a` is
modified in place.
Parameters
----------
a : ndarray(int, ndim=1)
Array of length k.
Retu... |
384,329 | def autocorrelate(data, unbias=2, normalize=2):
coefficients = correlate(data, data, )
size = np.int(coefficients.size/2)
coefficients = coefficients[size:]
N = coefficients.size
if unbias:
if unbias == 1:
coefficients /= (N - np.arange(N))
elif unbias ==... | Compute the autocorrelation coefficients for time series data.
Here we use scipy.signal.correlate, but the results are the same as in
Yang, et al., 2012 for unbias=1:
"The autocorrelation coefficient refers to the correlation of a time
series with its own past or future values. iGAIT u... |
384,330 | def chord(ref, est, **kwargs):
rreference.jamsestimated.jamschordchord
namespace =
ref = coerce_annotation(ref, namespace)
est = coerce_annotation(est, namespace)
ref_interval, ref_value = ref.to_interval_values()
est_interval, est_value = est.to_interval_values()
return mir_eval.chord.ev... | r'''Chord evaluation
Parameters
----------
ref : jams.Annotation
Reference annotation object
est : jams.Annotation
Estimated annotation object
kwargs
Additional keyword arguments
Returns
-------
scores : dict
Dictionary of scores, where the key is the me... |
384,331 | def _attach_to_model(self, model):
if not issubclass(model, ModelWithDynamicFieldMixin):
raise ImplementationError(
% (
model.__name__, self.name))
super(DynamicFieldMixin, self)._attach_to_model(model)
if self.dynamic_vers... | Check that the model can handle dynamic fields |
384,332 | def _revert_caffe2_pad(attr):
if len(attr) == 4:
attr = attr[:2]
elif len(attr) == 2:
pass
else:
raise ValueError("Invalid caffe2 type padding: {}".format(attr))
return attr | Removing extra padding from Caffe2. |
384,333 | def paint( self, painter, option, widget ):
if ( self._rebuildRequired ):
self.rebuild()
painter.setPen(self.borderColor())
if ( self.isSelected() ):
painter.setBrush(self.highlightColor())
else:
painter.se... | Paints this item on the painter.
:param painter | <QPainter>
option | <QStyleOptionGraphicsItem>
widget | <QWidget> |
384,334 | def list_experiments(project_path,
sort=None,
output=None,
filter_op=None,
info_keys=None):
_check_tabulate()
base, experiment_folders, _ = next(os.walk(project_path))
experiment_data_collection = []
for experimen... | Lists experiments in the directory subtree.
Args:
project_path (str): Directory where experiments are located.
Corresponds to Experiment.local_dir.
sort (str): Key to sort by.
output (str): Name of file where output is saved.
filter_op (str): Filter operation in the form... |
384,335 | def skip_if_empty(func):
@partial_safe_wraps(func)
def inner(value, *args, **kwargs):
if value is EMPTY:
return
else:
return func(value, *args, **kwargs)
return inner | Decorator for validation functions which makes them pass if the value
passed in is the EMPTY sentinal value. |
384,336 | def _get_containers(self):
infos = self.native_conn.list_containers_info()
return [self.cont_cls(self, i[], i[], i[])
for i in infos] | Return available containers. |
384,337 | def _sort(self, short_list, sorts):
sort_values = self._index_columns(sorts)
output = []
def _sort_more(short_list, i, sorts):
if len(sorts) == 0:
output.extend(short_list)
sort = sorts[0]
index = self._index[sort_values[i... | TAKE SHORTLIST, RETURN IT SORTED
:param short_list:
:param sorts: LIST OF SORTS TO PERFORM
:return: |
384,338 | def bls_snr(blsdict,
times,
mags,
errs,
assumeserialbls=False,
magsarefluxes=False,
sigclip=10.0,
npeaks=None,
perioddeltapercent=10,
ingressdurationfraction=0.1,
verbose=True):
bestperiodbestlspv... | Calculates the signal to noise ratio for each best peak in the BLS
periodogram, along with transit depth, duration, and refit period and epoch.
The following equation is used for SNR::
SNR = (transit model depth / RMS of LC with transit model subtracted)
* sqrt(number of points in transi... |
384,339 | def setup_exchanges(app):
with app.producer_or_acquire() as P:
for q in app.amqp.queues.values():
P.maybe_declare(q) | Setup result exchange to route all tasks to platform queue. |
384,340 | def get_base_wrappers(method=, template_name=, predicates=(), wrappers=()):
wrappers += (preserve_view(MethodPredicate(method), *predicates),)
if template_name:
wrappers += (render_template(template_name),)
return wrappers | basic View Wrappers used by view_config. |
384,341 | def connect(self):
try:
settings = configparser.ConfigParser()
settings._interpolation = configparser.ExtendedInterpolation()
except Exception as err:
self.logger.error("Failed to instantiate config parser exception: %s" % err)
raise
... | instantiate objects / parse config file |
384,342 | def validate(self, model, checks=[]):
records = self.data.to_dict("records")
self.evaluate_report(
validate(records, headers=list(records[0]),
preset=, schema=self.schema,
order_fields=True, custom_checks=checks)) | Use a defined schema to validate the given table. |
384,343 | def auprc(y_true, y_pred):
y_true, y_pred = _mask_value_nan(y_true, y_pred)
return skm.average_precision_score(y_true, y_pred) | Area under the precision-recall curve |
384,344 | def close(self):
if self.error_log and not self.quiet:
print("\nErrors occured:", file=sys.stderr)
for err in self.error_log:
print(err, file=sys.stderr)
self._session.close() | Print error log and close session |
384,345 | def has_listener(self, evt_name, fn):
listeners = self.__get_listeners(evt_name)
return fn in listeners | 指定listener是否存在
:params evt_name: 事件名称
:params fn: 要注册的触发函数函数 |
384,346 | def execute(opts, data, func, args, kwargs):
cat /etc/sudoerscat /etc/sudoers
cmd = [,
, opts.get(),
,
, ,
,
, opts.get(),
,
data.get()]
if data[] in (, , ):
kwargs[] = True
for arg in args:
cmd.append(_cmd_quot... | Allow for the calling of execution modules via sudo.
This module is invoked by the minion if the ``sudo_user`` minion config is
present.
Example minion config:
.. code-block:: yaml
sudo_user: saltdev
Once this setting is made, any execution module call done by the minion will be
run... |
384,347 | def _default_hashfunc(content, hashbits):
if content == "":
return 0
x = ord(content[0]) << 7
m = 1000003
mask = 2 ** hashbits - 1
for c in content:
x = ((x * m) ^ ord(c)) & mask
x ^= len(content)
if x == -1:
x = -2
return x | Default hash function is variable-length version of Python's builtin hash.
:param content: data that needs to hash.
:return: return a decimal number. |
384,348 | def resolve_outputs(self):
input_shape = None
for i, shape in enumerate(self._input_shapes.values()):
if i == 0:
input_shape = shape
if len(input_shape) != len(shape) or any(
a is not None and b is not None and a != b
... | Resolve the names of outputs for this layer into shape tuples. |
384,349 | def _to_dict(self):
_dict = {}
if hasattr(self, ) and self.document is not None:
_dict[] = self.document._to_dict()
if hasattr(self, ) and self.model_id is not None:
_dict[] = self.model_id
if hasattr(self, ) and self.model_version is not None:
... | Return a json dictionary representing this model. |
384,350 | def get_script(self):
uri = "{}/script".format(self.data["uri"])
return self._helper.do_get(uri) | Gets the configuration script of the logical enclosure by ID or URI.
Return:
str: Configuration script. |
384,351 | def renew_voms_proxy(passwd="", vo=None, lifetime="196:00"):
with tmp_file() as (_, tmp):
with open(tmp, "w") as f:
f.write(passwd)
cmd = "cat | voms-proxy-init --valid ".format(tmp, lifetime)
if vo:
cmd += " -voms ".format(vo)
code, out, _ = interrupta... | Renews the voms proxy using a password *passwd*, an optional virtual organization name *vo*, and
a default *lifetime* of 8 days. The password is written to a temporary file first and piped into
the renewal commad to ensure it is not visible in the process list. |
384,352 | def __parse_organizations(self, stream):
for aliases in self.__parse_stream(stream):
identity = self.__parse_alias(aliases[1])
uuid = identity.email
uid = self._identities.get(uuid, None)
if not uid:
uid = UniqueIdentity(uu... | Parse organizations stream |
384,353 | def get_nameid_data(self):
nameid = None
nameid_data = {}
encrypted_id_data_nodes = self.__query_assertion()
if encrypted_id_data_nodes:
encrypted_data = encrypted_id_data_nodes[0]
key = self.__settings.get_sp_key()
nameid = OneLogin_Saml2_Ut... | Gets the NameID Data provided by the SAML Response from the IdP
:returns: Name ID Data (Value, Format, NameQualifier, SPNameQualifier)
:rtype: dict |
384,354 | def get_section(value):
section = Section()
if not value or value[0] != :
raise errors.HeaderParseError("Expected section but found {}".format(
value))
section.append(ValueTerminal(, ))
value = value[1:]
if not value or not value[0].isdigit():
... | '*' digits
The formal BNF is more complicated because leading 0s are not allowed. We
check for that and add a defect. We also assume no CFWS is allowed between
the '*' and the digits, though the RFC is not crystal clear on that.
The caller should already have dealt with leading CFWS. |
384,355 | def create_index(self, index, index_type=GEO2D):
self.logger.info("Adding %s index to stores on attribute: %s" % (index_type, index))
yield self.collection.create_index([(index, index_type)]) | Create an index on a given attribute
:param str index: Attribute to set index on
:param str index_type: See PyMongo index types for further information, defaults to GEO2D index. |
384,356 | def update_message(self, message_id, category_id, title, body,
extended_body, use_textile=False, private=False, notify=None):
path = % message_id
req = ET.Element()
req.append(self._create_message_post_elem(category_id, title, body,
extended_body, use_textile=False,... | Updates an existing message, optionally sending notifications to a
selected list of people. Note that you can also upload files using
this function, but you have to format the request as
multipart/form-data. (See the ruby Basecamp API wrapper for an example
of how to do this.) |
384,357 | def close(self, proto):
try:
proto.sendClose()
except Exception as ex:
logger.exception("Failed to send close")
proto.reraise(ex) | Closes a connection |
384,358 | def handler(*names, **kwargs):
def wrapper(f):
if names and isinstance(names[0], bool) and not names[0]:
f.handler = False
return f
if len(names) > 0 and inspect.isclass(names[0]) and \
issubclass(names[0], hfosEvent):
f.names = (str(names[0... | Creates an Event Handler
This decorator can be applied to methods of classes derived from
:class:`circuits.core.components.BaseComponent`. It marks the method as a
handler for the events passed as arguments to the ``@handler`` decorator.
The events are specified by their name.
The decorated method... |
384,359 | def sample_discrete(self, state=None, n_steps=100, random_state=None):
r
random = check_random_state(random_state)
r = random.rand(1 + n_steps)
if state is None:
initial = np.sum(np.cumsum(self.populations_) < r[0])
elif hasattr(state, ) and len(state) == self.n_stat... | r"""Generate a random sequence of states by propagating the model
using discrete time steps given by the model lagtime.
Parameters
----------
state : {None, ndarray, label}
Specify the starting state for the chain.
``None``
Choose the initial sta... |
384,360 | def sort(self, column_or_label, descending=False, distinct=False):
column = self._get_column(column_or_label)
if distinct:
_, row_numbers = np.unique(column, return_index=True)
else:
row_numbers = np.argsort(column, axis=0, kind=)
assert (row_numbers < se... | Return a Table of rows sorted according to the values in a column.
Args:
``column_or_label``: the column whose values are used for sorting.
``descending``: if True, sorting will be in descending, rather than
ascending order.
``distinct``: if True, repeated ... |
384,361 | def init_state(self):
self.in_warc_response = False
self.in_http_response = False
self.in_payload = False | Sets the initial state of the state machine. |
384,362 | def require_single_root_target(self):
target_roots = self.context.target_roots
if len(target_roots) == 0:
raise TaskError()
elif len(target_roots) > 1:
raise TaskError(
.format(.join([repr(t) for t in target_roots])))
return target_roots[0] | If a single target was specified on the cmd line, returns that target.
Otherwise throws TaskError.
:API: public |
384,363 | def setConfigurable(self, state):
self._configurable = state
self._configButton.setVisible(state) | Sets whether or not this logger widget is configurable.
:param state | <bool> |
384,364 | def invoked(self, ctx):
print("{} + {} = {}".format(
ctx.args.x,
ctx.args.y,
ctx.args.x + ctx.args.y)) | Guacamole method used by the command ingredient.
:param ctx:
The guacamole context object. Context provides access to all
features of guacamole. The argparse ingredient adds the ``args``
attribute to it. That attribute contains the result of parsing
command line ... |
384,365 | def import_name(mod_name):
try:
mod_obj_old = sys.modules[mod_name]
except KeyError:
mod_obj_old = None
if mod_obj_old is not None:
return mod_obj_old
__import__(mod_name)
mod_obj = sys.modules[mod_name]
return mod_obj | Import a module by module name.
@param mod_name: module name. |
384,366 | def _on_hid_pnp(self, w_param, l_param):
"Process WM_DEVICECHANGE system messages"
new_status = "unknown"
if w_param == DBT_DEVICEARRIVAL:
notify_obj = None
if int(l_param):
notify_obj =... | Process WM_DEVICECHANGE system messages |
384,367 | def _is_image_sequenced(image):
try:
image.seek(1)
image.seek(0)
result = True
except EOFError:
result = False
return result | Determine if the image is a sequenced image. |
384,368 | def get_valid_error(x1, x2=-1):
if type(x2) == int and x2 == -1:
try:
e = np.array(x1)
except:
raise ValueError()
else:
try:
x1 = np.array(x1)
x2 = np.array(x2)
except:
raise ValueError()
... | Function that validates:
* x1 is possible to convert to numpy array
* x2 is possible to convert to numpy array (if exists)
* x1 and x2 have the same length (if both exist) |
384,369 | def handle_setting_changed(sender, setting, value, enter, **kwargs):
if setting == :
AxesProxyHandler.get_implementation(force=True) | Reinitialize handler implementation if a relevant setting changes
in e.g. application reconfiguration or during testing. |
384,370 | def rgb2termhex(r: int, g: int, b: int) -> str:
incs = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff]
res = []
parts = r, g, b
for part in parts:
if (part < 0) or (part > 255):
raise ValueError(
.format(parts)
)
i = 0
while i < len(incs) - 1:
... | Convert an rgb value to the nearest hex value that matches a term code.
The hex value will be one in `hex2term_map`. |
384,371 | def _g(self, z):
return np.exp(np.multiply(-self.theta, z)) - 1 | Helper function to solve Frank copula.
This functions encapsulates :math:`g_z = e^{-\\theta z} - 1` used on Frank copulas.
Argument:
z: np.ndarray
Returns:
np.ndarray |
384,372 | def certclone(chain, copy_extensions=False):
for i in range(len(chain)):
chain[i] = chain[i].to_cryptography()
newchain = []
first = True
for original in chain[::-1]:
key = rsa.generate_private_key(
public_exponent=65537,
key_size=2048,
... | key = rsa.generate_private_key(
public_exponent=65537,
key_size=2048,
backend=default_backend()
)
pubkey = key.public_key() |
384,373 | def __period_remaining(self):
elapsed = self.clock() - self.last_reset
return self.period - elapsed | Return the period remaining for the current rate limit window.
:return: The remaing period.
:rtype: float |
384,374 | def parse_band_log(self, message):
if "payload" in message and hasattr(message["payload"], "name"):
record = message["payload"]
for k in dir(record):
if k.startswith("workflows_exc_"):
setattr(record, k[14:], getattr(record, k))
... | Process incoming logging messages from the service. |
384,375 | def base_dict_to_string(base_dict):
outstr =
base_list = sorted(base_dict.items(), key=lambda kv: kv[1], reverse=True)
for base in base_list:
outstr += .format(base[0], base[1])
return outstr[:-1] | Converts a dictionary to a string. {'C': 12, 'A':4} gets converted to C:12;A:4
:param base_dict: Dictionary of bases and counts created by find_if_multibase
:return: String representing that dictionary. |
384,376 | def close(self, **kw):
if self._closing_deferred:
d = defer.Deferred()
def closed(arg):
d.callback(arg)
return arg
self._closing_deferred.addBoth(closed)
return d
self._closing_deferred = defer.... | This asks Tor to close the underlying circuit object. See
:meth:`txtorcon.torstate.TorState.close_circuit`
for details.
You may pass keyword arguments to take care of any Flags Tor
accepts for the CLOSECIRCUIT command. Currently, this is only
"IfUnused". So for example: circ.clo... |
384,377 | def get_renderers(self):
try:
source = self.get_object()
except (ImproperlyConfigured, APIException):
self.renderer_classes = [RENDERER_MAPPING[i] for i in self.__class__.renderers]
return [RENDERER_MAPPING[i]() for i in self.__class__.renderers]
else... | Instantiates and returns the list of renderers that this view can use. |
384,378 | def wash_urlargd(form, content):
result = {}
for k, (dst_type, default) in content.items():
try:
value = form[k]
except KeyError:
result[k] = default
continue
src_type = type(value)
if src_type in (list, tuple... | Wash the complete form based on the specification in content.
Content is a dictionary containing the field names as a
key, and a tuple (type, default) as value.
'type' can be list, unicode, legacy.wsgi.utils.StringField, int,
tuple, or legacy.wsgi.utils.Field (for file uploads).
The specification... |
384,379 | def _input_as_lines(self, data):
if data:
self.Parameters[]\
.on(super(CD_HIT,self)._input_as_lines(data))
return | Writes data to tempfile and sets -i parameter
data -- list of lines, ready to be written to file |
384,380 | def start_at(self, document_fields):
query = query_mod.Query(self)
return query.start_at(document_fields) | Start query at a cursor with this collection as parent.
See
:meth:`~.firestore_v1beta1.query.Query.start_at` for
more information on this method.
Args:
document_fields (Union[~.firestore_v1beta1.\
document.DocumentSnapshot, dict, list, tuple]): a document
... |
384,381 | def fix_bam_header(job, bamfile, sample_type, univ_options, samtools_options, retained_chroms=None):
if retained_chroms is None:
retained_chroms = []
work_dir = os.getcwd()
input_files = {
sample_type + : bamfile}
input_files = get_files_from_filestore(job, input_files, work_dir, d... | Fix the bam header to remove the command line call. Failing to do this causes Picard to reject
the bam.
:param dict bamfile: The input bam file
:param str sample_type: Description of the sample to inject into the filename
:param dict univ_options: Dict of universal options used by almost all tools
... |
384,382 | def generate_move(self, position):
while True:
print(position)
raw = input(str(self.color) + "\'s move \n")
move = converter.short_alg(raw, self.color, position)
if move is None:
continue
return move | Returns valid and legal move given position
:type: position: Board
:rtype: Move |
384,383 | def get_assessments_offered(self):
if self.retrieved:
raise errors.IllegalState()
self.retrieved = True
return objects.AssessmentOfferedList(self._results, runtime=self._runtime) | Gets the assessment offered list resulting from the search.
return: (osid.assessment.AssessmentOfferedList) - the assessment
offered list
raise: IllegalState - the assessment offered list has already
been retrieved
*compliance: mandatory -- This method must be i... |
384,384 | def set_sim_data(inj, field, data):
try:
sim_field = sim_inspiral_map[field]
except KeyError:
sim_field = field
if sim_field == :
inj.geocent_end_time = int(data)
inj.geocent_end_time_ns = int(1e9*(data % 1))
else:
setattr(inj, sim_field, data) | Sets data of a SimInspiral instance. |
384,385 | def files(self, *args, **kwargs):
return [p for p in self.listdir(*args, **kwargs) if p.isfile()] | D.files() -> List of the files in this directory.
The elements of the list are Path objects.
This does not walk into subdirectories (see :meth:`walkfiles`).
Accepts parameters to :meth:`listdir`. |
384,386 | def select(self, ids, do_emit=True, **kwargs):
self.eval_js(.format(dumps(ids)))
if do_emit:
self.emit(, ids, **kwargs) | Select some rows in the table.
By default, the `select` event is raised, unless `do_emit=False`. |
384,387 | def configure_model(self, attrs, field_name):
self.relationship = field_name
self._set_method_names(relationship=field_name)
if self.res_name is None:
self.res_name = grammar.singularize(attrs.get(, ).strip()) | Hook for ResourceMeta class to call when initializing model class.
Saves fields obtained from resource class backlinks |
384,388 | def Cp_material(ID, T=298.15):
rMineral fiber
if ID not in materials_dict:
ID = nearest_material(ID)
if ID in refractories:
Cp = refractory_VDI_Cp(ID, T)
elif ID in building_materials:
Cp = float(building_materials[ID][2])
else:
Cp = ASHRAE[ID][1]
if Cp is No... | r'''Returns heat capacity of a building, insulating, or refractory
material from tables in [1]_, [2]_, and [3]_. Heat capacity may or
may not be dependent on temperature depending on the source used. Function
must be provided with either a key to one of the dictionaries
`refractories`, `ASHRAE`, or `bu... |
384,389 | def h(tagName, *children, **kwargs):
attrs = {}
if in kwargs:
attrs = kwargs.pop()
attrs = attrs.copy()
attrs.update(kwargs)
el = createComponent(tagName)
return el(children, **attrs) | Takes an HTML Tag, children (string, array, or another element), and
attributes
Examples:
>>> h('div', [h('p', 'hey')])
<div><p>hey</p></div> |
384,390 | async def start(self):
_LOGGER.debug(, __version__)
await self.fetch_token()
if self._token is not None:
await self.fetch_device_list()
await self.assign_users()
return True
else:
return False | Start api initialization. |
384,391 | def adjoint(self):
if self.variant == :
variant =
elif self.variant == :
variant =
else:
raise RuntimeError(.format(self.variant))
return WeightedSumSamplingOperator(self.domain, self.sampling_points,
... | Adjoint of the sampling operator, a `WeightedSumSamplingOperator`.
If each sampling point occurs only once, the adjoint consists
in inserting the given values into the output at the sampling
points. Duplicate sampling points are weighted with their
multiplicity.
Examples
... |
384,392 | def SetTimelineOwner(self, username):
self._timeline_owner = username
logger.info(.format(self._timeline_owner)) | Sets the username of the user that should own the timeline.
Args:
username (str): username. |
384,393 | def tube_hires(script, height=1.0, radius=None, radius1=None, radius2=None,
diameter=None, diameter1=None, diameter2=None, cir_segments=32,
rad_segments=1, height_segments=1, center=False,
simple_bottom=False, color=None):
if radius is not None and d... | Create a cylinder with user defined number of segments |
384,394 | def addcol(msname, colname=None, shape=None,
data_desc_type=, valuetype=None, init_with=0, **kw):
import numpy
import pyrap.tables
tab = pyrap.tables.table(msname,readonly=False)
try:
tab.getcol(colname)
print()
except RuntimeError:
print(%(colname,msname))... | add column to MS
msanme : MS to add colmn to
colname : column name
shape : shape
valuetype : data type
data_desc_type : 'scalar' for scalar elements and array for 'array' elements
init_with : value to initialise the column with |
384,395 | def determine_deaths(self, event: Event):
effective_rate = self.mortality_rate(event.index)
effective_probability = 1 - np.exp(-effective_rate)
draw = self.randomness.get_draw(event.index)
affected_simulants = draw < effective_probability
self.population_view.update(pd.S... | Determines who dies each time step.
Parameters
----------
event :
An event object emitted by the simulation containing an index
representing the simulants affected by the event and timing
information. |
384,396 | def load(self, ):
assert self.status() == self.UNLOADED,\
"Cannot load if there is no unloaded reference. Use reference instead."
self.get_refobjinter().load(self._refobj)
self.set_status(self.LOADED)
self.fetch_new_children()
self.update_restrictions()
... | If the reference is in the scene but unloaded, load it.
.. Note:: Do not confuse this with reference or import. Load means that it is already referenced.
But the data from the reference was not read until now. Load loads the data from the reference.
This will call :meth:`RefobjInterf... |
384,397 | def serialize(self, private=False):
if self.priv_key:
self._serialize(self.priv_key)
else:
self._serialize(self.pub_key)
res = self.common()
res.update({
"crv": self.crv,
"x": self.x,
"y": self.y
})
i... | Go from a
cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey
or EllipticCurvePublicKey instance to a JWK representation.
:param private: Whether we should include the private attributes or not.
:return: A JWK as a dictionary |
384,398 | def _get_mime_type(self, buff):
if self._magic is not None:
return self._magic.id_buffer(buff)
else:
try:
return mimetypes.guess_type("f." + imghdr.what(0, buff))[0]
except (IOError, TypeError):
logging.warning("CouldncontentTy... | Get the MIME type for a given stream of bytes
:param buff: Stream of bytes
:type buff: bytes
:rtype: str |
384,399 | def gaussian_distribution(mean, stdev, num_pts=50):
warnings.warn("pyemu.helpers.gaussian_distribution() has moved to plot_utils",PyemuWarning)
from pyemu import plot_utils
return plot_utils.gaussian_distribution(mean=mean,stdev=stdev,num_pts=num_pts) | get an x and y numpy.ndarray that spans the +/- 4
standard deviation range of a gaussian distribution with
a given mean and standard deviation. useful for plotting
Parameters
----------
mean : float
the mean of the distribution
stdev : float
the standard deviation of the distrib... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.