Unnamed: 0 int64 0 389k | code stringlengths 26 79.6k | docstring stringlengths 1 46.9k |
|---|---|---|
379,300 | def to_input_req(self):
return {
WARM_START_TYPE: self.type.value,
PARENT_HYPERPARAMETER_TUNING_JOBS: [{HYPERPARAMETER_TUNING_JOB_NAME: parent} for parent in self.parents]
} | Converts the ``self`` instance to the desired input request format.
Returns:
dict: Containing the "WarmStartType" and "ParentHyperParameterTuningJobs" as the first class fields.
Examples:
>>> warm_start_config = WarmStartConfig(warm_start_type=WarmStartTypes.TransferLearning,pa... |
379,301 | def remove_leading_zeros(num: str) -> str:
if not num:
return num
if num.startswith():
ret = + num[1:].lstrip()
elif num.startswith():
ret = + num[1:].lstrip()
else:
ret = num.lstrip()
return if ret in (, , ) else ret | Strips zeros while handling -, M, and empty strings |
379,302 | def dSbr_dV(self, Yf, Yt, V, buses=None, branches=None):
buses = self.buses if buses is None else buses
branches = self.branches if branches is None else branches
nl = len(branches)
nb = len(V)
il = range(nl)
ib = range(nb)
f = [l.from_bus._i for l in b... | Based on dSbr_dV.m from MATPOWER by Ray Zimmerman, developed at
PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more
information.
@return: The branch power flow vectors and the partial derivatives of
branch power flow w.r.t voltage magnitude and voltage angle.
... |
379,303 | def get(self):
return ExecutionContextContext(
self._version,
flow_sid=self._solution[],
execution_sid=self._solution[],
) | Constructs a ExecutionContextContext
:returns: twilio.rest.studio.v1.flow.execution.execution_context.ExecutionContextContext
:rtype: twilio.rest.studio.v1.flow.execution.execution_context.ExecutionContextContext |
379,304 | def JoinPath(self, path_segments):
first_path_segment = None
if path_segments and platform.system() == :
first_path_segment = path_segments[0]
first_path_segment_length = len(first_path_segment)
first_path_segment_prefix = None
if (first_path_segment_length... | Joins the path segments into a path.
Args:
path_segments (list[str]): path segments.
Returns:
str: joined path segments prefixed with the path separator. |
379,305 | def within_line(self, viewer, points, p_start, p_stop, canvas_radius):
scale_x, scale_y = viewer.get_scale_xy()
new_radius = canvas_radius * 1.0 / min(scale_x, scale_y)
return self.point_within_line(points, p_start, p_stop, new_radius) | Points `points` and line endpoints `p_start`, `p_stop` are in
data coordinates.
Return True for points within the line defined by a line from
p_start to p_end and within `canvas_radius`.
The distance between points is scaled by the viewer's canvas scale. |
379,306 | def variant_stats_from_variant(variant,
metadata,
merge_fn=(lambda all_stats: \
max(all_stats, key=(lambda stats: stats.tumor_stats.depth)))):
all_stats = []
for (variant_file, variant_metadata) in metadata.items(... | Parse the variant calling stats from a variant called from multiple variant files. The stats are merged
based on `merge_fn`
Parameters
----------
variant : varcode.Variant
metadata : dict
Dictionary of variant file to variant calling metadata from that file
merge_fn : function
F... |
379,307 | def parse_name(self):
name = []
while True:
part = self.match_string_pattern(spat.alphau, spat.alphal)
if part == :
break
self.eat_string(part)
name.append(part)
if self.get_... | This function uses string patterns to match a title cased name.
This is done in a loop until there are no more names to match so as
to be able to include surnames etc. in the output. |
379,308 | def write_uint16(self, value, little_endian=True):
if little_endian:
endian = "<"
else:
endian = ">"
return self.pack( % endian, value) | Pack the value as an unsigned integer and write 2 bytes to the stream.
Args:
value:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: the number of bytes written. |
379,309 | def hard_wrap(self):
self.linebreak = re.compile(r)
self.text = re.compile(
r
) | Grammar for hard wrap linebreak. You don't need to add two
spaces at the end of a line. |
379,310 | def create_tx(self, txins=None, txouts=None, lock_time=0):
txins = [] if txins is None else txins
txouts = [] if txouts is None else txouts
lock_time = deserialize.positive_integer(lock_time)
txins = deserialize.txins(txins)
txouts = deserialize.txouts(self.testnet, txou... | Create unsigned rawtx with given txins/txouts as json data.
<txins>: '[{"txid" : hexdata, "index" : integer}, ...]'
<txouts>: '[{"address" : hexdata, "value" : satoshis}, ...]' |
379,311 | def do_handle_log(self, workunit, level, *msg_elements):
if not self.is_under_main_root(workunit):
return
if self.use_color_for_workunit(workunit, self.settings.color):
msg = self._COLOR_BY_LEVEL.get(level, lambda x: x)(msg)
self.emit(self._prefix(workunit, msg))
self.flush() | Implementation of Reporter callback. |
379,312 | def _fetch(self, request):
client = self.client
call = Call(__id__=client.newCall(request.request))
call.enqueue(request.handler)
request.call = call | Fetch using the OkHttpClient |
379,313 | def _make_path(self, items):
s url pattern and replaces instances of <var_name>
with the appropriate value from the items dict.
Value "%s" for key "%s" must be an instance of basestring{%s}' % key, val)
return path | Returns a relative path for the given dictionary of items.
Uses this url rule's url pattern and replaces instances of <var_name>
with the appropriate value from the items dict. |
379,314 | def evaluate_policy(self, sigma):
if self.beta == 1:
raise NotImplementedError(self._error_msg_no_discounting)
R_sigma, Q_sigma = self.RQ_sigma(sigma)
b = R_sigma
A = self._I - self.beta * Q_sigma
v_sigma = self._lineq_solve(A, b)
return ... | Compute the value of a policy.
Parameters
----------
sigma : array_like(int, ndim=1)
Policy vector, of length n.
Returns
-------
v_sigma : ndarray(float, ndim=1)
Value vector of `sigma`, of length n. |
379,315 | def _maybe_club(self, list_of_dicts):
column_headers = JsonConverter._list_of_dicts_to_column_headers(list_of_dicts)
if column_headers is None:
html_output = self._markup(list_of_dicts)
else:
html_output = self._table_opening_tag
html_out... | If all keys in a list of dicts are identical, values from each ``dict``
are clubbed, i.e. inserted under a common column heading. If the keys
are not identical ``None`` is returned, and the list should be converted
to HTML per the normal ``convert`` function.
Parameters
-------... |
379,316 | def __remove_index(self, ids):
if not ids:
return
ids = ",".join((str(id) for id in ids))
self.execute("DELETE FROM fact_index where id in (%s)" % ids) | remove affected ids from the index |
379,317 | def _collective_with_groups(self, x, mesh_axes, collective):
if not mesh_axes:
return x
x = x.to_laid_out_tensor()
if len(mesh_axes) == self.ndims:
return self.LaidOutTensor(collective(x.tensor_list, self._devices))
else:
groups = mtf.processor_groups(self.shape, mesh_axes)
... | Grouped collective, (across the given dimensions).
Args:
x: a LaidOutTensor
mesh_axes: a list of integers - the mesh dimensions to be reduced
collective: fn from list(tf.Tensor), list(device) -> list(tf.Tensor)
Returns:
a LaidOutTensor |
379,318 | def book(symbol=None, token=, version=):
_raiseIfNotStr(symbol)
if symbol:
return _getJson( + symbol, token, version)
return _getJson(, token, version) | Book shows IEX’s bids and asks for given symbols.
https://iexcloud.io/docs/api/#deep-book
Args:
symbol (string); Ticker to request
token (string); Access token
version (string); API version
Returns:
dict: result |
379,319 | def html_entity_decode_codepoint(self, m,
defs=htmlentities.codepoint2name):
try:
char = defs[m.group(1)]
return "&{char};".format(char=char)
except ValueError:
return m.group(0)
except KeyError:
return... | decode html entity into one of the codepoint2name |
379,320 | def besj(self, x, n):
if n < 0:
return 0.0
d = 1e-6
b = 0
if math.fabs(x) <= d:
if n != 0:
return 0
return 1
b1 = 0
m1 = int(math.fabs(x)) + 6
if math.fabs(x) > 5:
m1 = int(math.... | Function BESJ calculates Bessel function of first kind of order n
Arguments:
n - an integer (>=0), the order
x - value at which the Bessel function is required
--------------------
C++ Mathematical Library
Converted from equivalent FORTRAN library
Converte... |
379,321 | def d3logpdf_dlink3(self, inv_link_f, y, Y_metadata=None):
e = y - inv_link_f
d3lik_dlink3 = ( -(2*(self.v + 1)*(-e)*(e**2 - 3*self.v*self.sigma2)) /
((e**2 + self.sigma2*self.v)**3)
)
return d3lik_dlink3 | Third order derivative log-likelihood function at y given link(f) w.r.t link(f)
.. math::
\\frac{d^{3} \\ln p(y_{i}|\lambda(f_{i}))}{d^{3}\\lambda(f)} = \\frac{-2(v+1)((y_{i} - \lambda(f_{i}))^3 - 3(y_{i} - \lambda(f_{i})) \\sigma^{2} v))}{((y_{i} - \lambda(f_{i})) + \\sigma^{2} v)^3}
:par... |
379,322 | def parse_environment_data(block):
warnings.warn(
"Process.parse_environment_data() is deprecated" \
" since WinAppDbg 1.5.",
DeprecationWarning)
environment = dict()
if not block:
return environment
... | Parse the environment block into a Python dictionary.
@warn: Deprecated since WinAppDbg 1.5.
@note: Values of duplicated keys are joined using null characters.
@type block: list of str
@param block: List of strings as returned by L{get_environment_data}.
@rtype: dict(str S{... |
379,323 | def update_batch(self, **kwargs):
items = kwargs.pop("items")
def transform(item):
item[self.identifier_key] = item.pop("id")
return item
return dict(
items=[
self.replace(**transform(item))
for item in i... | Simplistic batch update operation implemented in terms of `replace()`.
Assumes that:
- Request and response schemas contains lists of items.
- Request items define a primary key identifier
- The entire batch succeeds or fails together. |
379,324 | def getAllClasses(self, hide_base_schemas=True, hide_implicit_types=True):
query =
BIT_BASE_SCHEMAS =
BIT_IMPLICIT_TYPES =
if hide_base_schemas == False:
BIT_BASE_SCHEMAS = ""
if hide_implicit_types == True:
BIT_IMPLICIT_TYPES = ""
... | * hide_base_schemas: by default, obscure all RDF/RDFS/OWL/XML stuff
* hide_implicit_types: don't make any inference based on rdf:type declarations |
379,325 | def resetPassword(self, attempt, newPassword):
self.accountByAddress(attempt.username).password = newPassword
self.store.query(
PersistentSession,
PersistentSession.authenticatedAs == str(attempt.username)
).deleteFromStore()
attempt.deleteFromStor... | @param attempt: L{_PasswordResetAttempt}
reset the password of the user who initiated C{attempt} to C{newPassword},
and afterward, delete the attempt and any persistent sessions that belong
to the user |
379,326 | def fit_naa(self, reject_outliers=3.0, fit_lb=1.8, fit_ub=2.4,
phase_correct=True):
model, signal, params = ana.fit_lorentzian(self.diff_spectra,
self.f_ppm,
lb=fit_lb,
... | Fit a Lorentzian function to the NAA peak at ~ 2 ppm. Example of
fitting inverted peak: Foerster et al. 2013, An imbalance between
excitatory and inhibitory neurotransmitters in amyothrophic lateral
sclerosis revealed by use of 3T proton MRS |
379,327 | def midi_outputs(self):
return self.client.get_ports(is_midi=True, is_physical=True, is_output=True) | :return: A list of MIDI output :class:`Ports`. |
379,328 | def get_diff_amounts(self):
diffs = []
last_commit = None
for commit in self.repo.iter_commits():
if last_commit is not None:
diff = self.get_diff(commit.hexsha, last_commit.hexsha)
total_changed = diff[Diff.ADD] + diff[Diff.DEL]
... | Gets list of total diff
:return: List of total diff between 2 consecutive commits since start |
379,329 | def delete(self, force=False):
if not force and self._state not in (
Bundle.INSTALLED,
Bundle.RESOLVED,
Bundle.STOPPING,
):
_logger.warning("Trying to delete an active framework")
return False
return FrameworkFactory.delete_fr... | Deletes the current framework
:param force: If True, stops the framework before deleting it
:return: True if the framework has been delete, False if is couldn't |
379,330 | def get_instance(self, payload):
return EngagementContextInstance(
self._version,
payload,
flow_sid=self._solution[],
engagement_sid=self._solution[],
) | Build an instance of EngagementContextInstance
:param dict payload: Payload response from the API
:returns: twilio.rest.studio.v1.flow.engagement.engagement_context.EngagementContextInstance
:rtype: twilio.rest.studio.v1.flow.engagement.engagement_context.EngagementContextInstance |
379,331 | def parse_mapping(mapping_file: Optional[str]) -> configparser.ConfigParser:
LOGGER.debug(, mapping_file)
def parse(mapping_file):
config = configparser.ConfigParser()
config.read_file(mapping_file)
return config
if mapping_file is not None:
LOGGER.debug()
... | Parse the file containing the mappings from hosts to pass entries.
Args:
mapping_file:
Name of the file to parse. If ``None``, the default file from the
XDG location is used. |
379,332 | def import_from_netcdf(network, path, skip_time=False):
assert has_xarray, "xarray must be installed for netCDF support."
basename = os.path.basename(path) if isinstance(path, string_types) else None
with ImporterNetCDF(path=path) as importer:
_import_from_importer(network, importer, basename... | Import network data from netCDF file or xarray Dataset at `path`.
Parameters
----------
path : string|xr.Dataset
Path to netCDF dataset or instance of xarray Dataset
skip_time : bool, default False
Skip reading in time dependent attributes |
379,333 | def get_node_affiliations(self, jid, node):
iq = aioxmpp.stanza.IQ(
type_=aioxmpp.structs.IQType.GET,
to=jid,
payload=pubsub_xso.OwnerRequest(
pubsub_xso.OwnerAffiliations(node),
)
)
return (yield from self.client.send(iq)... | Return the affiliations of other jids at a node.
:param jid: Address of the PubSub service.
:type jid: :class:`aioxmpp.JID`
:param node: Name of the node to query
:type node: :class:`str`
:raises aioxmpp.errors.XMPPError: as returned by the service
:return: The response ... |
379,334 | async def _get_descriptions(self):
self.fields = []
self.converters = []
use_unicode = self.connection.use_unicode
conn_encoding = self.connection.encoding
description = []
for i in range(self.field_count):
field = await self.connection._read_packet(
... | Read a column descriptor packet for each column in the result. |
379,335 | def resolve_for(self, node, exact=None):
from capybara.driver.node import Node
from capybara.node.element import Element
from capybara.node.simple import Simple
@node.synchronize
def resolve():
if self.selector.format == "css":
children = no... | Resolves this query relative to the given node.
Args:
node (node.Base): The node relative to which this query should be resolved.
exact (bool, optional): Whether to exactly match text.
Returns:
list[Element]: A list of elements matched by this query. |
379,336 | def get_connection(self, name):
return self._api_get(.format(
urllib.parse.quote_plus(name)
)) | An individual connection.
:param name: The connection name
:type name: str |
379,337 | def _maybe_start_instance(instance):
if not instance:
return
if instance.state[] == :
instance.start()
while True:
print(f"Waiting for {instance} to start.")
instance.reload()
if instance.state[] == :
break
time.sleep(10) | Starts instance if it's stopped, no-op otherwise. |
379,338 | def to_native(key):
item = find(whatever=key)
if not item:
raise NonExistentLanguageError()
return item[u] | Find the native name for the language specified by key.
>>> to_native('br')
u'brezhoneg'
>>> to_native('sw')
u'Kiswahili' |
379,339 | def save_raw_data_from_data_queue(data_queue, filename, mode=, title=, scan_parameters=None):
if not scan_parameters:
scan_parameters = {}
with open_raw_data_file(filename, mode=, title=, scan_parameters=list(dict.iterkeys(scan_parameters))) as raw_data_file:
raw_data_file.append(data_que... | Writing raw data file from data queue
If you need to write raw data once in a while this function may make it easy for you. |
379,340 | def filter_macro(func, *args, **kwargs):
filter_partial = partial(func, *args, **kwargs)
class FilterMacroMeta(FilterMeta):
@staticmethod
def __new__(mcs, name, bases, attrs):
for attr in WRAPPER_ASSIGNMENTS:
if hasattr(func, attr):
... | Promotes a function that returns a filter into its own filter type.
Example::
@filter_macro
def String():
return Unicode | Strip | NotEmpty
# You can now use `String` anywhere you would use a regular Filter:
(String | Split(':')).apply('...')
You can also use ``fi... |
379,341 | def activate(self, resource=None, timeout=3, wait_for_finish=False):
return Task.execute(self, , json={: resource},
timeout=timeout, wait_for_finish=wait_for_finish) | Activate this package on the SMC
:param list resource: node href's to activate on. Resource is only
required for software upgrades
:param int timeout: timeout between queries
:raises TaskRunFailed: failure during activation (downloading, etc)
:rtype: TaskOperationPoller |
379,342 | def path_to_songname(path: str)->str:
return os.path.splitext(os.path.basename(path))[0] | Extracts song name from a filepath. Used to identify which songs
have already been fingerprinted on disk. |
379,343 | def bschoc(value, ndim, lenvals, array, order):
value = stypes.stringToCharP(value)
ndim = ctypes.c_int(ndim)
lenvals = ctypes.c_int(lenvals)
array = stypes.listToCharArrayPtr(array, xLen=lenvals, yLen=ndim)
order = stypes.toIntVector(order)
return libspice.bschoc_c(value, ndim, lenvals, ar... | Do a binary search for a given value within a character string array,
accompanied by an order vector. Return the index of the matching array
entry, or -1 if the key value is not found.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bschoc_c.html
:param value: Key value to be found in array.
... |
379,344 | def update_points(self):
x, y, w, h = self.x, self.y, self.w, self.h
self.points = (x, y, x + w, y, x + w, y + h, x, y + h) | 统一变为多个点组成的多边形,用于处理碰撞 |
379,345 | def ystep(self):
r
self.Y = np.asarray(sp.prox_l2(
self.AX + self.U, (self.lmbda/self.rho)*self.Wtvna,
axis=self.saxes), dtype=self.dtype) | r"""Minimise Augmented Lagrangian with respect to
:math:`\mathbf{y}`. |
379,346 | def export_txt(obj, file_name, two_dimensional=False, **kwargs):
if obj.ctrlpts is None or len(obj.ctrlpts) == 0:
raise exch.GeomdlException("There are no control points to save!")
if obj.pdimension == 1 and two_dimensional:
two_dimensional = False
col_sep = kw... | Exports control points as a text file.
For curves the output is always a list of control points. For surfaces, it is possible to generate a 2-dimensional
control point output file using ``two_dimensional``.
Please see :py:func:`.exchange.import_txt()` for detailed description of the keyword arguments.
... |
379,347 | def load_registered_fixtures(context):
runner = context._runner
step_registry = getattr(runner, , None)
if not step_registry:
step_registry = module_step_registry.registry
for step in context.scenario.all_steps:
match = step_registry.find_match(step... | Apply fixtures that are registered with the @fixtures decorator. |
379,348 | def remove_users_from_account_group(self, account_id, group_id, **kwargs):
kwargs[] = True
if kwargs.get():
return self.remove_users_from_account_group_with_http_info(account_id, group_id, **kwargs)
else:
(data) = self.remove_users_from_account_group_with_htt... | Remove users from a group. # noqa: E501
An endpoint for removing users from groups. **Example usage:** `curl -X DELETE https://api.us-east-1.mbedcloud.com/v3/accounts/{accountID}/policy-groups/{groupID}/users -d '[0162056a9a1586f30242590700000000,0117056a9a1586f30242590700000000]' -H 'content-type: applicat... |
379,349 | def sub_tag(self, path, follow=True):
tags = path.split()
rec = self
for tag in tags:
recs = [x for x in (rec.sub_records or []) if x.tag == tag]
if not recs:
return None
rec = recs[0]
if follow and isinstance(rec, Pointer)... | Returns direct sub-record with given tag name or None.
Path can be a simple tag name, in which case the first direct
sub-record of this record with the matching tag is returned. Path
can also consist of several tags separated by slashes, in that case
sub-records are searched recursively... |
379,350 | def canonical_peer( self, peer ):
their_host, their_port = url_to_host_port( peer )
if their_host in [, ]:
their_host =
return "%s:%s" % (their_host, their_port) | Get the canonical peer name |
379,351 | def delete_snmp_template(auth, url, template_name= None, template_id= None):
try:
if template_id is None:
snmp_templates = get_snmp_templates(auth, url)
if template_name is None:
template_name = snmp_template[]
template_id = None
for templ... | Takes template_name as input to issue RESTUL call to HP IMC which will delete the specific
snmp template from the IMC system
:param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class
:param url: base url of IMC RS interface #usually auth.url from pyhpeimc.auth.authclass
:par... |
379,352 | def postprocess(self, calc, with_module=None, dry_run=None):
for appname, appclass in self.Apps.items():
if with_module and with_module != appname: continue
run_permitted = False
if appclass[]:
for key in appclass[]:
... | Invokes module(s) API
NB: this is the PUBLIC method
@returns apps_dict |
379,353 | def create_sconstruct(self, project_dir=, sayyes=False):
project_dir = util.check_dir(project_dir)
sconstruct_name =
sconstruct_path = util.safe_join(project_dir, sconstruct_name)
local_sconstruct_path = util.safe_join(
util.get_folder(), sconstruct_name)
... | Creates a default SConstruct file |
379,354 | def expect(self, pattern, timeout=-1):
if self.blocking:
raise RuntimeError("expect can only be used on non-blocking commands.")
try:
self.subprocess.expect(pattern=pattern, timeout=timeout)
except pexpect.EOF:
pass | Waits on the given pattern to appear in std_out |
379,355 | def diff(cls, a, b, ignore_formatting=False):
def underline(x): return u % (x,)
def blink(x): return u % (x,)
a_rows = []
b_rows = []
max_width = max([len(row) for row in a] + [len(row) for row in b])
a_lengths = []
b_lengths = []
for a_row, b_row... | Returns two FSArrays with differences underlined |
379,356 | def _set_cos_traffic_class(self, v, load=False):
if hasattr(v, "_utype"):
v = v._utype(v)
try:
t = YANGDynClass(v,base=YANGListType("name",cos_traffic_class.cos_traffic_class, yang_name="cos-traffic-class", rest_name="cos-traffic-class", parent=self, is_container=, user_ordered=False, path_help... | Setter method for cos_traffic_class, mapped from YANG variable /qos/map/cos_traffic_class (list)
If this variable is read-only (config: false) in the
source YANG file, then _set_cos_traffic_class is considered as a private
method. Backends looking to populate this variable should
do so via calling thisO... |
379,357 | def transform(self, X):
if self.timeseries_container is None:
raise RuntimeError("You have to provide a time series using the set_timeseries_container function before.")
timeseries_container_X = restrict_input_to_index(self.timeseries_container, self.column_id, X.index)
... | Add the features calculated using the timeseries_container and add them to the corresponding rows in the input
pandas.DataFrame X.
To save some computing time, you should only include those time serieses in the container, that you
need. You can set the timeseries container with the method :func... |
379,358 | def _sd_handler(self, desc_type, unit, desc, show_on_keypad):
if desc_type not in self._descriptions_in_progress:
LOG.debug("Text description response ignored for " + str(desc_type))
return
(max_units, results, callback) = self._descriptions_in_progress[desc_type]
... | Text description |
379,359 | def request_openbus(self, service, endpoint, **kwargs):
if service == :
endpoints = ENDPOINTS_BUS
elif service == :
endpoints = ENDPOINTS_GEO
else:
return None
if endpoint not in endpoints:
return None
... | Make a request to the given endpoint of the ``openbus`` server.
This returns the plain JSON (dict) response which can then be parsed
using one of the implemented types.
Args:
service (str): Service to fetch ('bus' or 'geo').
endpoint (str): Endpoint to send the request ... |
379,360 | def enbase64(byte_str):
if isinstance(byte_str, str) and not PYTHON2:
byte_str = bytes(byte_str, )
return base64.b64encode(byte_str) | Encode bytes/strings to base64.
Args:
- ``byte_str``: The string or bytes to base64 encode.
Returns:
- byte_str encoded as base64. |
379,361 | def load_profiles_definitions(filename):
with open(filename, ) as fp:
profile_definitions = yaml.load(fp)
profiles_dict = NocaseDict()
for profile in profile_definitions:
value = ProfileDef(profile["central_class"],
profile["scoping_class"],
... | Load the registered profiles defined in the file filename. This is a
yml file that defines the basic characteristics of each profile with the
following variables:
It produces a dictionary that can be accessed with the a string that
defines the profile organization and name in the form <org>:<profile n... |
379,362 | def run(argv=argv):
config_file = kwconfig.manage(
file_path=resource_filename(Requirement.parse(), ),
defaults={
: ,
: ,
: 3,
: ,
: ,
: 10})
if len(argv) > 1:
if argv[1] == :
open_new_tab(_doc_link)
exit()
elif argv[1] == :
open_new_... | Runs the search_google command line tool.
This function runs the search_google command line tool
in a terminal. It was intended for use inside a py file
(.py) to be executed using python.
Notes:
* ``[q]`` reflects key ``q`` in the ``cseargs`` parameter for :class:`api.results`
* Optional argumen... |
379,363 | def wait_for_import_to_complete(self, import_id, region=):
task_running = True
while task_running:
import_status_cmd = "aws ec2 --profile {} --region --output describe-import-image-tasks --import-task-ids {}".format(self.aws_project, region, import_id)
res = subproces... | Monitors the status of aws import, waiting for it to complete, or error out
:param import_id: id of import task to monitor |
379,364 | def extendManager(mixinClass):
-published
class MixinManager(models.Manager, mixinClass):
class MixinQuerySet(models.query.QuerySet, mixinClass):
pass
def get_queryset(self):
return self.MixinQuerySet(self.model, using = self._db)
return MixinManager() | Use as a class decorator to add extra methods to your model manager.
Example usage:
class Article(django.db.models.Model):
published = models.DateTimeField()
...
@extendManager
class objects(object):
def getPublished(self):
return self.filter(published__lte = django.utils.timezone.now()).order... |
379,365 | def pltnp(point, v1, v2, v3):
point = stypes.toDoubleVector(point)
v1 = stypes.toDoubleVector(v1)
v2 = stypes.toDoubleVector(v2)
v3 = stypes.toDoubleVector(v3)
pnear = stypes.emptyDoubleVector(3)
dist = ctypes.c_double()
libspice.pltnp_c(point, v1, v2, v3, pnear, ctypes.byref(dist))
... | Find the nearest point on a triangular plate to a given point.
https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/pltnp_c.html
:param point: A point in 3-dimensional space.
:type point: 3-Element Array of floats
:param v1: Vertices of a triangular plate.
:type v1: 3-Element Array o... |
379,366 | def require_exp_directory(f):
error = "The current directory is not a valid Dallinger experiment."
@wraps(f)
def wrapper(**kwargs):
if not verify_directory(kwargs.get("verbose")):
raise click.UsageError(error)
return f(**kwargs)
return wrapper | Decorator to verify that a command is run inside a valid Dallinger
experiment directory. |
379,367 | def get_python_symbol_icons(oedata):
class_icon = ima.icon()
method_icon = ima.icon()
function_icon = ima.icon()
private_icon = ima.icon()
super_private_icon = ima.icon()
symbols = process_python_symbol_data(oedata)
fold_levels = sorted(list(set([s[2] for s in symbols])))
par... | Return a list of icons for oedata of a python file. |
379,368 | def delete(self, filename, storage_type=None, bucket_name=None):
if not (storage_type and bucket_name):
self._delete_local(filename)
else:
if storage_type != :
raise ValueError( % storage_type)
self._delete_s3(filename, bucket_name) | Deletes the specified file, either locally or from S3, depending on the file's storage type. |
379,369 | def mapper_from_partial_prior_arguments(self, arguments):
original_prior_dict = {prior: prior for prior in self.priors}
return self.mapper_from_prior_arguments({**original_prior_dict, **arguments}) | Creates a new model mapper from a dictionary mapping_matrix existing priors to new priors, keeping existing
priors where no mapping is provided.
Parameters
----------
arguments: {Prior: Prior}
A dictionary mapping_matrix priors to priors
Returns
-------
... |
379,370 | def analyze(self, scratch, **kwargs):
scripts_set = set()
for script in self.iter_scripts(scratch):
if script[0].type.text == :
continue
blocks_list = []
for name, _, _ in self.iter_blocks(script.blocks):
blocks_list.append(n... | Run and return the results from the DuplicateScripts plugin.
Only takes into account scripts with more than 3 blocks. |
379,371 | def from_connections(cls, caption, connections):
root = ET.Element(, caption=caption, version=, inline=)
outer_connection = ET.SubElement(root, )
outer_connection.set(, )
named_conns = ET.SubElement(outer_connection, )
for conn in connections:
nc = ET.SubEle... | Create a new Data Source give a list of Connections. |
379,372 | def start(self):
def _heartbeat():
if not self._client.lifecycle.is_live:
return
self._heartbeat()
self._heartbeat_timer = self._client.reactor.add_timer(self._heartbeat_interval, _heartbeat)
self._heartbeat_timer = self._client.reactor.add_t... | Starts sending periodic HeartBeat operations. |
379,373 | def init_app(self, app):
self.init_extension(app)
if not hasattr(app, ):
app.extensions = {}
classname = self.__class__.__name__
extname = classname.replace(, ).lower()
app.extensions[extname] = self | Initialize extension to the given application.
Extension will be registered to `app.extensions` with lower classname
as key and instance as value.
:param app: Flask application. |
379,374 | def log_start(task, logger="TaskLogger"):
tasklogger = get_tasklogger(logger)
tasklogger.start_task(task)
return tasklogger | Begin logging of a task
Convenience function to log a task in the default
TaskLogger
Parameters
----------
task : str
Name of the task to be started
logger : str, optional (default: "TaskLogger")
Unique name of the logger to retrieve
Returns
-------
logger : TaskLo... |
379,375 | def iterate(iterator, n=None):
ensure_iterable(iterator)
if n is None:
deque(iterator, maxlen=0)
else:
next(islice(iterator, n, n), None) | Efficiently advances the iterator N times; by default goes to its end.
The actual loop is done "in C" and hence it is faster than equivalent 'for'.
:param n: How much the iterator should be advanced.
If None, it will be advanced until the end. |
379,376 | def remote_archive(class_obj: type) -> type:
assert isinstance(class_obj, type), "class_obj is not a Class"
global _remote_archive_resource_type
_remote_archive_resource_type = class_obj
return class_obj | Decorator to annotate the RemoteArchive class. Registers the decorated class
as the RemoteArchive known type. |
379,377 | def build(outdir):
print("Building your Blended files into a website!")
reload(sys)
sys.setdefaultencoding()
build_files(outdir)
print("The files are built! You can find them in the " + outdir +
"/ directory. Run the view command to see what you have created in a web browser.") | Blends the generated files and outputs a HTML website |
379,378 | def gamma(ranks_list1,ranks_list2):
s gamma correlation coefficient
:param ranks_list1: a list of ranks (integers)
:param ranks_list2: a second list of ranks (integers) of equal length with corresponding entries
:return: Gamma correlation coefficient (rank correlation ignoring ties)
n/a'
return ... | Goodman and Kruskal's gamma correlation coefficient
:param ranks_list1: a list of ranks (integers)
:param ranks_list2: a second list of ranks (integers) of equal length with corresponding entries
:return: Gamma correlation coefficient (rank correlation ignoring ties) |
379,379 | def slice_rates_to_data(self, strain):
output_variables = list(strain.data)
cond = (isinstance(strain.target_magnitudes, np.ndarray) or
isinstance(strain.target_magnitudes, list))
if cond:
magnitude_list = [ % mag for mag in strain.target_magnitudes]
... | For the strain data, checks to see if seismicity rates have been
calculated. If so, each column in the array is sliced and stored as a
single vector in the strain.data dictionary with the corresponding
magnitude as a key.
:param strain:
Instance of :class: openquake.hmtk.str... |
379,380 | def check_event_coverage(patterns, event_list):
proportions = []
for pattern_list in patterns:
proportion = 0
for pattern in pattern_list:
for node in pattern.nodes():
if node in event_list:
proportion += 1.0 / len(pattern_list)
... | Calculate the ratio of patterns that were extracted. |
379,381 | def solver(A, config):
A = make_csr(A)
try:
return \
smoothed_aggregation_solver(A,
B=config[],
BH=config[],
smooth=config[],
... | Generate an SA solver given matrix A and a configuration.
Parameters
----------
A : array, matrix, csr_matrix, bsr_matrix
Matrix to invert, CSR or BSR format preferred for efficiency
config : dict
A dictionary of solver configuration parameters that is used to
generate a smoothe... |
379,382 | def generate_not(self):
not_definition = self._definition[]
if not_definition is True:
self.l()
elif not_definition is False:
return
elif not not_definition:
with self.l(, self._variable):
self.l()
else:
wit... | Means that value have not to be valid by this definition.
.. code-block:: python
{'not': {'type': 'null'}}
Valid values for this definition are 'hello', 42, {} ... but not None.
Since draft 06 definition can be boolean. False means nothing, True
means everything is invali... |
379,383 | def transform(self, X, mean=None, lenscale=None):
mean = self._check_dim(X.shape[1], mean, paramind=0)
lenscale = self._check_dim(X.shape[1], lenscale, paramind=1)
VX = self._makeVX(X / lenscale)
mX = X.dot(mean)[:, np.newaxis]
Phi = np.hstack((np.cos(VX + mX), np.sin(V... | Apply the spectral mixture component basis to X.
Parameters
----------
X: ndarray
(N, d) array of observations where N is the number of samples, and
d is the dimensionality of X.
mean: ndarray, optional
array of shape (d,) frequency means (one for eac... |
379,384 | def add_directory(self, iso_path=None, rr_name=None, joliet_path=None,
file_mode=None, udf_path=None):
if not self._initialized:
raise pycdlibexception.PyCdlibInvalidInput()
if iso_path is None and joliet_path is None and udf_path is None:
... | Add a directory to the ISO. At least one of an iso_path, joliet_path,
or udf_path must be provided. Providing joliet_path on a non-Joliet
ISO, or udf_path on a non-UDF ISO, is an error. If the ISO contains
Rock Ridge, then a Rock Ridge name must be provided.
Parameters:
iso_... |
379,385 | def get_last_week_range(weekday_start="Sunday"):
today = date.today()
start_of_week = snap_to_beginning_of_week(today, weekday_start) - timedelta(weeks=1)
end_of_week = start_of_week + timedelta(days=6)
return (start_of_week, end_of_week) | Gets the date for the first and the last day of the previous complete week.
:param weekday_start: Either "Monday" or "Sunday", indicating the first day of the week.
:returns: A tuple containing two date objects, for the first and the last day of the week
respectively. |
379,386 | def add(self, factory, component, properties=None):
with self.__lock:
if component in self.__names:
raise ValueError(
"Component name already queued: {0}".format(component)
)
if properties is None:
... | Enqueues the instantiation of the given component
:param factory: Factory name
:param component: Component name
:param properties: Component properties
:raise ValueError: Component name already reserved in the queue
:raise Exception: Error instantiating the component |
379,387 | def addVariantSet(self):
self._openRepo()
dataset = self._repo.getDatasetByName(self._args.datasetName)
dataUrls = self._args.dataFiles
name = self._args.name
if len(dataUrls) == 1:
if self._args.name is None:
name = getNameFromPath(dataUrls[0... | Adds a new VariantSet into this repo. |
379,388 | def to_json(self):
json_dict = self.to_json_basic()
json_dict[] = self.relay_channels
return json.dumps(json_dict) | :return: str |
379,389 | def winner(self):
for c in :
for comb in [(0,3,6), (1,4,7), (2,5,8), (0,1,2), (3,4,5), (6,7,8), (0,4,8), (2,4,6)]:
if all(self.spots[p] == c for p in comb):
return c
return None | Returns either x or o if one of them won, otherwise None |
379,390 | def zoom_out(self):
zoom = self.grid.grid_renderer.zoom
target_zoom = zoom * (1 - config["zoom_factor"])
if target_zoom > config["minimum_zoom"]:
self.zoom(target_zoom) | Zooms out by zoom factor |
379,391 | def airspeeds_encode(self, time_boot_ms, airspeed_imu, airspeed_pitot, airspeed_hot_wire, airspeed_ultrasonic, aoa, aoy):
return MAVLink_airspeeds_message(time_boot_ms, airspeed_imu, airspeed_pitot, airspeed_hot_wire, airspeed_ultrasonic, aoa, aoy) | The airspeed measured by sensors and IMU
time_boot_ms : Timestamp (milliseconds since system boot) (uint32_t)
airspeed_imu : Airspeed estimate from IMU, cm/s (int16_t)
airspeed_pitot : Pitot measured forward airpseed, cm/s (int16_t)
... |
379,392 | async def save(self):
if in self._changed_data and self._changed_data[]:
self._changed_data[] = self._changed_data[][]
if (self._orig_data[] and
in self._orig_data[] and
self._changed_data[] == (
self... | Save this subnet. |
379,393 | def _clean_streams(repo, mapped_streams):
for stream_name in (, ):
stream = mapped_streams.get(stream_name)
if not stream:
continue
path = os.path.relpath(stream, start=repo.working_dir)
if (path, 0) not in repo.index.entries:
os.remove(stream)
e... | Clean mapped standard streams. |
379,394 | def DSP_callback_toc(self):
if self.Tcapture > 0:
self.DSP_toc.append(time.time()-self.start_time) | Add new toc time to the DSP_toc list. Will not be called if
Tcapture = 0. |
379,395 | def headers_for_url(cls, url):
response = cls.http_request(url, method=)
if response.status != 200:
cls.raise_http_error(response)
return Resource.headers_as_dict(response) | Return the headers only for the given URL as a dict |
379,396 | def entropy(self, base = 2):
entropy = 0
if not base and self.base: base = self.base
for type in self._dist:
if not base:
entropy += self._dist[type] * -math.log(self._dist[type])
else:
entropy += self._dist[type] * -math.log(self.... | Compute the entropy of the distribution |
379,397 | def _get_price_id_for_upgrade(self, package_items, option, value, public=True):
warnings.warn("use _get_price_id_for_upgrade_option() instead",
DeprecationWarning)
option_category = {
: ,
: ,
:
}
category_code = option_c... | Find the price id for the option and value to upgrade.
Deprecated in favor of _get_price_id_for_upgrade_option()
:param list package_items: Contains all the items related to an VS
:param string option: Describes type of parameter to be upgraded
:param int value: The value of the parame... |
379,398 | def walk_files(args, root, directory, action):
for entry in os.listdir(directory):
if is_hidden(args, entry):
continue
if is_excluded_directory(args, entry):
continue
if is_in_default_excludes(entry):
continue
if not is_included(args, entry):
... | Recusively go do the subdirectories of the directory,
calling the action on each file |
379,399 | def list(context, job_id, sort, limit, where, verbose):
result = job.list_files(context, id=job_id, sort=sort, limit=limit,
verbose=verbose, where=where)
utils.format_output(result, context.format, verbose=verbose) | list(context, sort, limit, where, verbose)
List all files.
>>> dcictl file-list job-id [OPTIONS]
:param string sort: Field to apply sort
:param integer limit: Max number of rows to return
:param string where: An optional filter criteria
:param boolean verbose: Display verbose output |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.