Unnamed: 0 int64 0 389k | code stringlengths 26 79.6k | docstring stringlengths 1 46.9k |
|---|---|---|
5,600 | def _build_robots_txt_checker(cls, session: AppSession):
if session.args.robots:
robots_txt_pool = session.factory.new()
robots_txt_checker = session.factory.new(
,
web_client=session.factory[],
robots_txt_pool=robots_txt_pool
... | Build robots.txt checker. |
5,601 | def get_schedule_by_regid_and_term(regid, term,
non_time_schedule_instructors=True,
per_section_prefetch_callback=None,
transcriptable_course="", **kwargs):
if "include_instructor_not_on_time_schedule" in ... | Returns a uw_sws.models.ClassSchedule object
for the regid and term passed in. |
5,602 | def near_sphere(self, x, y, max_distance=None):
expr = {
self : { : [x, y]}
}
if max_distance is not None:
expr[self][] = max_distance
return QueryExpression(expr) | Return documents near the given point using sphere distances |
5,603 | def get_factors(self, node=None):
if node:
if node not in self.nodes():
raise ValueError()
node_factors = []
for factor in self.factors:
if node in factor.scope():
node_factors.append(factor)
return node... | Returns all the factors containing the node. If node is not specified
returns all the factors that have been added till now to the graph.
Parameter
---------
node: any hashable python object (optional)
The node whose factor we want. If node is not specified
Examples... |
5,604 | def _TerminateProcessByPid(self, pid):
self._RaiseIfNotRegistered(pid)
process = self._processes_per_pid[pid]
self._TerminateProcess(process)
self._StopMonitoringProcess(process) | Terminate a process that's monitored by the engine.
Args:
pid (int): process identifier (PID).
Raises:
KeyError: if the process is not registered with and monitored by the
engine. |
5,605 | def chain_input_files(self):
ret_list = []
for key, val in self.file_dict.items():
if val & FileFlags.in_ch_mask == FileFlags.input_mask:
ret_list.append(key)
return ret_list | Return a list of the input files needed by this chain.
For `Link` sub-classes this will return only those files
that were not created by any internal `Link` |
5,606 | def load_sound(self, loc, title, group):
self.sounds.setdefault(group, {})
self.sounds[group][title] = Sound(loc, self) | Used internally when loading sounds. You should probably use
load_objects(). |
5,607 | def issues(self, from_date=DEFAULT_DATETIME,
offset=None, max_issues=MAX_ISSUES):
resource = self.RISSUES + self.CJSON
ts = datetime_to_utc(from_date)
ts = ts.strftime("%Y-%m-%dT%H:%M:%SZ")
params = {
self.PSTATUS_ID: ,
... | Get the information of a list of issues.
:param from_date: retrieve issues that where updated from that date;
dates are converted to UTC
:param offset: starting position for the search
:param max_issues: maximum number of issues to reteurn per query |
5,608 | def can_update_repositories(self):
url_path = construct_url(,
bank_id=self._catalog_idstr)
return self._get_request(url_path)[][] | Tests if this user can update ``Repositories``.
A return of true does not guarantee successful authorization. A
return of false indicates that it is known updating a
``Repository`` will result in a ``PermissionDenied``. This is
intended as a hint to an application that may not wish to o... |
5,609 | def identity(ctx, variant_id):
if not variant_id:
LOG.warning("Please provide a variant id")
ctx.abort()
adapter = ctx.obj[]
version = ctx.obj[]
LOG.info("Search variants {0}".format(adapter))
result = adapter.get_clusters(variant_id)
if result.count() == 0:
... | Check how well SVs are working in the database |
5,610 | def match_var(self, tokens, item):
setvar, = tokens
if setvar != wildcard:
if setvar in self.names:
self.add_check(self.names[setvar] + " == " + item)
else:
self.add_def(setvar + " = " + item)
self.names[setvar] = item | Matches a variable. |
5,611 | def _context_source_file_url(path_or_url):
if path_or_url.startswith():
return path_or_url
if path_or_url.startswith():
return "file://" + path_or_url
return "file://" + os.path.join(os.path.realpath(os.getcwd()), path_or_url) | Returns a URL for a remote or local context CSV file |
5,612 | def is_free_chunk(self, chk):
cs = self.get_chunk_status(chk)
if cs & 0x1 != 0:
return True
return False | Check the chunk is free or not |
5,613 | def until_some(*args, **kwargs):
done_at_least = kwargs.pop(, None)
timeout = kwargs.pop(, None)
if done_at_least is None:
done_at_least = len(args) + len(kwargs)
wait_iterator = tornado.gen.WaitIterator(*args, **kwargs)
maybe_timeout = future_timeout_manager(timeout)
results =... | Return a future that resolves when some of the passed futures resolve.
The futures can be passed as either a sequence of *args* or a dict of
*kwargs* (but not both). Some additional keyword arguments are supported,
as described below. Once a specified number of underlying futures have
resolved, the ret... |
5,614 | def description_of(file, name=):
u = UniversalDetector()
for line in file:
u.feed(line)
u.close()
result = u.result
if result[]:
return % (name,
result[],
result[])
else:
ret... | Return a string describing the probable encoding of a file. |
5,615 | def restore(s, t):
t = (c for c in t)
return .join(next(t) if not is_blacksquare(c) else c for c in s) | s is the source string, it can contain '.'
t is the target, it's smaller than s by the number of '.'s in s
Each char in s is replaced by the corresponding
char in t, jumping over '.'s in s.
>>> restore('ABC.DEF', 'XYZABC')
'XYZ.ABC' |
5,616 | def event(self, event):
if event.type() in (QEvent.Shortcut, QEvent.ShortcutOverride):
return True
else:
return super(ShortcutEditor, self).event(event) | Qt method override. |
5,617 | def selector(C, style):
clas = C.classname(style.name)
if style.type == :
outlineLvl = int((style.properties.get() or {}).get() or 8) + 1
if outlineLvl < 9:
tag = % outlineLvl
else:
tag =
elif style.type ... | return the selector for the given stylemap style |
5,618 | def get_queryset(self, **kwargs):
queryset = self.derive_queryset(**kwargs)
return self.order_queryset(queryset) | Gets our queryset. This takes care of filtering if there are any
fields to filter by. |
5,619 | def in_order(self) -> Iterator["BSP"]:
if self.children:
yield from self.children[0].in_order()
yield self
yield from self.children[1].in_order()
else:
yield self | Iterate over this BSP's hierarchy in order.
.. versionadded:: 8.3 |
5,620 | def make_assignment(instr, queue, stack):
value = make_expr(stack)
targets = []
while isinstance(instr, instrs.DUP_TOP):
targets.append(make_assign_target(queue.popleft(), queue, stack))
instr = queue.popleft()
targets.append(make_assign_target(instr, queu... | Make an ast.Assign node. |
5,621 | def recursive_update(d, u):
for k, v in u.iteritems():
if isinstance(v, collections.Mapping):
r = recursive_update(d.get(k, {}), v)
d[k] = r
else:
d[k] = u[k]
return d | Dict recursive update.
Based on Alex Martelli code on stackoverflow
http://stackoverflow.com/questions/3232943/update-value-of-a-nested-dictionary-of-varying-depth?answertab=votes#tab-top
:param d: dict to update
:param u: dict with new data
:return: |
5,622 | def get_fault(self, reply):
reply = self.replyfilter(reply)
sax = Parser()
faultroot = sax.parse(string=reply)
soapenv = faultroot.getChild()
soapbody = soapenv.getChild()
fault = soapbody.getChild()
unmarshaller = self.unmarshaller(False)
p = unm... | Extract the fault from the specified soap reply. If I{faults} is True,
an exception is raised. Otherwise, the I{unmarshalled} fault L{Object}
is returned. This method is called when the server raises a
I{web fault}.
@param reply: A soap reply message.
@type reply: str
... |
5,623 | def batch_message_from_parts(cls, messages):
middle = b.join(messages)
if not middle:
raise ProtocolError.empty_batch()
return b.join([b, middle, b]) | Convert messages, one per batch item, into a batch message. At
least one message must be passed. |
5,624 | def _choices(self):
pairs = []
for key, value in self.choices.items():
pairs.append(str(value) + "=" + str(key))
return GPTaskSpec.manifest_escape(";".join(pairs)) | Generate a string of choices as key/value pairs
:return: string |
5,625 | def nl_msg_dump(msg, ofd=_LOGGER.debug):
hdr = nlmsg_hdr(msg)
ofd()
ofd(, hdr.SIZEOF)
print_hdr(ofd, msg)
if hdr.nlmsg_type == libnl.linux_private.netlink.NLMSG_ERROR:
dump_error_msg(msg, ofd)
elif nlmsg_len(hdr) > 0:
print_msg(msg, ofd, hdr)
ofd() | Dump message in human readable format to callable.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L970
Positional arguments:
msg -- message to print (nl_msg class instance).
Keyword arguments:
ofd -- function to call with arguments similar to `logging.debug`. |
5,626 | def from_cone(cls, center,
radius=3*u.arcmin,
magnitudelimit=None,
**kw):
center = parse_center(center)
criteria = {}
if magnitudelimit is not None:
criteria[cls.defaultfilter + ] = .format(magnitudelimit)
... | Create a Constellation from a cone search of the sky,
characterized by a positional center and a radius from it.
Parameters
----------
center : SkyCoord object
The center around which the query will be made.
radius : float, with units of angle
The angular... |
5,627 | def __solve(self, lvl, x, b, cycle):
A = self.levels[lvl].A
self.levels[lvl].presmoother(A, x, b)
residual = b - A * x
coarse_b = self.levels[lvl].R * residual
coarse_x = np.zeros_like(coarse_b)
if lvl == len(self.levels) - 2:
coarse_x[:] = self.c... | Multigrid cycling.
Parameters
----------
lvl : int
Solve problem on level `lvl`
x : numpy array
Initial guess `x` and return correction
b : numpy array
Right-hand side for Ax=b
cycle : {'V','W','F','AMLI'}
Recursively calle... |
5,628 | def in_period(period, dt=None):
if dt is None:
dt = datetime.now()
for sp in sub_periods:
if _is_in_sub_period(sp, dt):
return True
return False | Determines if a datetime is within a certain time period. If the time
is omitted the current time will be used.
in_period return True is the datetime is within the time period, False if not.
If the expression is malformed a TimePeriod.InvalidFormat exception
will be raised. (Note that this differs from... |
5,629 | def column_width(tokens):
get_len = tools.display_len if PY3 else len
lens = sorted(map(get_len, tokens or [])) or [0]
width = lens[-1]
if width >= 18:
most = lens[int(len(lens) * 0.9)]
if most < width + 6:
return most
return width | Return a suitable column width to display one or more strings. |
5,630 | def duplicate(
self,
insert_sheet_index=None,
new_sheet_id=None,
new_sheet_name=None
):
return self.spreadsheet.duplicate_sheet(
self.id,
insert_sheet_index,
new_sheet_id,
new_sheet_name
) | Duplicate the sheet.
:param int insert_sheet_index: (optional) The zero-based index
where the new sheet should be inserted.
The index of all sheets after this are
incremented.
:param int... |
5,631 | def create_float(self, value: float) -> Float:
self.append((4, value))
return self.get(self.raw_count - 1) | Creates a new :class:`ConstantFloat`, adding it to the pool and
returning it.
:param value: The value of the new float. |
5,632 | def create_url(self):
headers = self.headers
headers[] = str(self.file_size)
headers[] = .join(self.encode_metadata())
resp = requests.post(self.client.url, headers=headers)
url = resp.headers.get("location")
if url is None:
msg = .format(resp.status_... | Return upload url.
Makes request to tus server to create a new upload url for the required file upload. |
5,633 | async def on_raw_cap_ls(self, params):
to_request = set()
for capab in params[0].split():
capab, value = self._capability_normalize(capab)
if capab in self._capabilities:
continue
attr = + pydle.protocol.identifie... | Update capability mapping. Request capabilities. |
5,634 | def find_connection(self):
if self.connection is not None:
return self.connection
for m in self.mpstate.mav_master:
if in m.messages:
if m.messages[].type == mavutil.mavlink.MAV_TYPE_ANTENNA_TRACKER:
return m
return None | find an antenna tracker connection if possible |
5,635 | def _explicit_close(napalm_device):
if salt.utils.napalm.not_always_alive(__opts__):
try:
napalm_device[].close()
except Exception as err:
log.error()
log.error(err)
log.error() | Will explicily close the config session with the network device,
when running in a now-always-alive proxy minion or regular minion.
This helper must be used in configuration-related functions,
as the session is preserved and not closed before making any changes. |
5,636 | def map_wrap(f):
@functools.wraps(f)
def wrapper(*args, **kwargs):
return f(*args, **kwargs)
return wrapper | Wrap standard function to easily pass into 'map' processing. |
5,637 | def fold(data, prefix=, delimeter=):
if not isinstance(delimeter, (tuple, list)):
delimeter = (delimeter, )
def deep(data):
if len(data) == 1 and len(data[0][0]) < 2:
if data[0][0]:
return {data[0][0][0]: data[0][1]}
return data[0][1]
collec... | >>> _dd(fold({'a__a': 4}))
"{'a': {'a': 4}}"
>>> _dd(fold({'a__a': 4, 'a__b': 5}))
"{'a': {'a': 4, 'b': 5}}"
>>> _dd(fold({'a__1': 2, 'a__0': 1, 'a__2': 3}))
"{'a': [1, 2, 3]}"
>>> _dd(fold({'form__a__b': 5, 'form__a__a': 4}, 'form'))
"{'a': {'a': 4, 'b': 5}}"
>>> _dd(fold({'form__a__b':... |
5,638 | def derive_fields(self):
fields = []
if self.fields:
fields.append(self.fields)
return fields | Default implementation |
5,639 | def foreign(self, value, context=None):
if self.separator is None:
separator =
else:
separator = self.separator.strip() if self.strip and hasattr(self.separator, ) else self.separator
value = self._clean(value)
try:
value = separator.join(value)
except Exception as e:
raise Concern("{... | Construct a string-like representation for an iterable of string-like objects. |
5,640 | def Pitzer(T, Tc, omega):
rs critical
temperature and acentric factor.
The enthalpy of vaporization is given by:
.. math::
\frac{\Delta_{vap} H}{RT_c}=7.08(1-T_r)^{0.354}+10.95\omega(1-T_r)^{0.456}
Parameters
----------
T : float
Temperature of fluid [K]
Tc : float
... | r'''Calculates enthalpy of vaporization at arbitrary temperatures using a
fit by [2]_ to the work of Pitzer [1]_; requires a chemical's critical
temperature and acentric factor.
The enthalpy of vaporization is given by:
.. math::
\frac{\Delta_{vap} H}{RT_c}=7.08(1-T_r)^{0.354}+10.95\omega(1-T_... |
5,641 | def download_listing(self, file: Optional[IO],
duration_timeout: Optional[float]=None) -> \
ListingResponse:
if self._session_state != SessionState.directory_request_sent:
raise RuntimeError()
self._session_state = SessionState.file_request_sent... | Read file listings.
Args:
file: A file object or asyncio stream.
duration_timeout: Maximum time in seconds of which the
entire file must be read.
Returns:
A Response populated the file listings
Be sure to call :meth:`start_file_listing` firs... |
5,642 | def meta(self):
if not self.__meta_received:
raise RuntimeError(
)
if isinstance(self.raw.value, dict):
return self.raw.value
return {} | Get metadata from the query itself. This is guaranteed to only
return a Python dictionary.
Note that if the query failed, the metadata might not be in JSON
format, in which case there may be additional, non-JSON data
which can be retrieved using the following
::
ra... |
5,643 | def unmasked(self, depth=0.01):
return 1 - (np.hstack(self._O2) +
np.hstack(self._O3) / depth) / np.hstack(self._O1) | Return the unmasked overfitting metric for a given transit depth. |
5,644 | async def async_init(self) -> None:
if not self._client_established:
await self.request(
,
.format(self.client_uuid),
data={
: DEFAULT_APP_ID,
: DEFAULT_APP_VERSION,
: self._locale
... | Create a Tile session. |
5,645 | def _check_data_port_id(self, data_port):
valid, message = super(ContainerState, self)._check_data_port_id(data_port)
if not valid:
return False, message
for scoped_variable_id, scoped_variable in self.scoped_variables.items():
if data_port.data... | Checks the validity of a data port id
Checks whether the id of the given data port is already used by anther data port (input, output, scoped vars)
within the state.
:param rafcon.core.data_port.DataPort data_port: The data port to be checked
:return bool validity, str message: validit... |
5,646 | def doc(self, export=):
rows = []
title = .format(self.__class__.__name__)
table = Tab(export=export, title=title)
for opt in sorted(self.config_descr):
if hasattr(self, opt):
c1 = opt
c2 = self.config_descr[opt]
c3 = ... | Dump help document for setting classes |
5,647 | def _get_default_value_to_cache(self, xblock):
try:
return self.from_json(xblock._field_data.default(xblock, self.name))
except KeyError:
if self._default is UNIQUE_ID:
return self._check_or_enforce_type(self._calculate_unique_id(xblock))
... | Perform special logic to provide a field's default value for caching. |
5,648 | def housekeeping(self, **kwargs):
path = % self.get_id()
self.manager.gitlab.http_post(path, **kwargs) | Start the housekeeping task.
Args:
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabHousekeepingError: If the server failed to perform the
request |
5,649 | def setEmergencyDecel(self, typeID, decel):
self._connection._sendDoubleCmd(
tc.CMD_SET_VEHICLETYPE_VARIABLE, tc.VAR_EMERGENCY_DECEL, typeID, decel) | setDecel(string, double) -> None
Sets the maximal physically possible deceleration in m/s^2 of vehicles of this type. |
5,650 | def order_quote(self, quote_id, extra):
container = self.generate_order_template(quote_id, extra)
return self.client.call(, , container, id=quote_id) | Places an order using a quote
::
extras = {
'hardware': {'hostname': 'test', 'domain': 'testing.com'},
'quantity': 2
}
manager = ordering.OrderingManager(env.client)
result = manager.order_quote(12345, extras)
:param int ... |
5,651 | def _serialize_value(self, value):
if isinstance(value, (list, tuple, set)):
return [self._serialize_value(v) for v in value]
elif isinstance(value, dict):
return dict([(k, self._serialize_value(v)) for k, v in value.items()])
elif isinstance(value, ModelBase):
... | Called by :py:meth:`._serialize` to serialise an individual value. |
5,652 | def generate_config_file():
shutil.copy(os.path.join(os.path.dirname(__file__), ),
os.path.join(os.getcwd(), )) | Generate a config file for a ProTECT run on hg19.
:return: None |
5,653 | def update(data, id, medium, credentials):
_op(data, id, medium, tokens.Operations.UPDATE, credentials) | Updates the [medium] with the given id and data on the user's [medium]List.
:param data The data for the [medium] to update.
:param id The id of the data to update.
:param medium Anime or manga (tokens.Medium.ANIME or tokens.Medium.MANGA).
:raise ValueError For bad arguments. |
5,654 | def head(self, url, **kwargs):
r
kwargs.setdefault(, False)
return self.request(, url, **kwargs) | r"""Sends a HEAD request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response |
5,655 | def append_panel(panels, size_x, size_y, max_col=12):
bottom_lines = bottoms(panels)
shape = find_shape(bottom_lines, max_col)
lines = longest_lines(shape)
line = find_place(lines, size_x)
if not line:
return
panel = {
: line[],
: line[],
: size_x,
: ... | Appends a panel to the list of panels. Finds the highest palce at the left for the new panel.
:param panels:
:param size_x:
:param size_y:
:param max_col:
:return: a new panel or None if it is not possible to place a panel with such size_x |
5,656 | def apply_to_field_if_exists(effect, field_name, fn, default):
value = getattr(effect, field_name, None)
if value is None:
return default
else:
return fn(value) | Apply function to specified field of effect if it is not None,
otherwise return default. |
5,657 | def list_drafts(self):
target_url = self.client.get_url(, , )
return base.Query(self, target_url) | A filterable list views of layers, returning the draft version of each layer.
If the most recent version of a layer or table has been published already,
it won’t be returned here. |
5,658 | def dlogpdf_link_dr(self, inv_link_f, y, Y_metadata=None):
c = np.zeros_like(y)
if Y_metadata is not None and in Y_metadata.keys():
c = Y_metadata[]
link_f = inv_link_f
y_link_f = y/link_f
log_y_link_f = np.log(y) - np.log(link_f)
... | Gradient of the log-likelihood function at y given f, w.r.t shape parameter
.. math::
:param inv_link_f: latent variables link(f)
:type inv_link_f: Nx1 array
:param y: data
:type y: Nx1 array
:param Y_metadata: includes censoring information in dictionary key 'censored'... |
5,659 | def workspace_from_url(self, mets_url, dst_dir=None, clobber_mets=False, mets_basename=None, download=False, baseurl=None):
if dst_dir and not dst_dir.startswith():
dst_dir = abspath(dst_dir)
if mets_url is None:
if baseurl is None:
raise Exception("Must... | Create a workspace from a METS by URL.
Sets the mets.xml file
Arguments:
mets_url (string): Source mets URL
dst_dir (string, None): Target directory for the workspace
clobber_mets (boolean, False): Whether to overwrite existing mets.xml. By default existing mets.xml... |
5,660 | def add_backends(self, *backends):
for backend in backends:
full = self._expand_host(backend)
self.backends[full] = 0
self.task_counter[full] = 0 | See the documentation for __init__() to see an explanation of the
*backends argument. |
5,661 | def FindUnspentCoins(self, from_addr=None, use_standard=False, watch_only_val=0):
ret = []
for coin in self.GetCoins():
if coin.State & CoinState.Confirmed > 0 and \
coin.State & CoinState.Spent == 0 and \
coin.State & CoinState.Locked == 0 an... | Finds unspent coin objects in the wallet.
Args:
from_addr (UInt160): a bytearray (len 20) representing an address.
use_standard (bool): whether or not to only include standard contracts ( i.e not a smart contract addr ).
watch_only_val (int): a flag ( 0 or 64 ) indicating wh... |
5,662 | def write_packed(self, outfile, rows):
self.write_preamble(outfile)
if self.compression is not None:
compressor = zlib.compressobj(self.compression)
else:
compressor = zlib.compressobj()
... | Write PNG file to `outfile`.
`rows` should be an iterator that yields each packed row;
a packed row being a sequence of packed bytes.
The rows have a filter byte prefixed and
are then compressed into one or more IDAT chunks.
They are not processed any further,
so if bitd... |
5,663 | def get_dummy_thread(nsamples, **kwargs):
seed = kwargs.pop(, False)
ndim = kwargs.pop(, 2)
logl_start = kwargs.pop(, -np.inf)
logl_range = kwargs.pop(, 1)
if kwargs:
raise TypeError(.format(kwargs))
if seed is not False:
np.random.seed(seed)
thread = {: np.sort(np.rando... | Generate dummy data for a single nested sampling thread.
Log-likelihood values of points are generated from a uniform distribution
in (0, 1), sorted, scaled by logl_range and shifted by logl_start (if it is
not -np.inf). Theta values of each point are each generated from a uniform
distribution in (0, 1... |
5,664 | def CopyFileInZip(from_zip, from_name, to_zip, to_name=None):
data = from_zip.read(from_name)
if to_name is None:
to_name = from_name
to_zip.writestr(to_name, data) | Read a file from a ZipFile and write it to a new ZipFile. |
5,665 | def get_accessibility_packs(self):
packs = []
for node in list(self.nodes.values()):
node[] =
for node_id, node in self.nodes.items():
if node[] == :
packs.append(self.dfs_get_all_childs(node_id))
for node... | Get accessibility packs of the graph:
in one pack element are related in a way. Between packs, there is no relation at all.
TODO: Make it work for directional graph too
Because for now, edge must be father->son AND son->father
:return: packs of nodes
:rtype: list |
5,666 | def validate(cnpj_number):
_cnpj = compat.clear_punctuation(cnpj_number)
if (len(_cnpj) != 14 or
len(set(_cnpj)) == 1):
return False
first_part = _cnpj[:12]
second_part = _cnpj[:13]
first_digit = _cnpj[12]
second_digit = _cnpj[13]
if (first_digit == calc.calculate_fir... | This function validates a CNPJ number.
This function uses calculation package to calculate both digits
and then validates the number.
:param cnpj_number: a CNPJ number to be validated. Only numbers.
:type cnpj_number: string
:return: Bool -- True for a valid number, False otherwise. |
5,667 | def _expand_target(self):
target = self.opts[]
if isinstance(target, list):
return
hostname = self.opts[].split()[-1]
needs_expansion = not in hostname and \
salt.utils.network.is_reachable_host(hostname) and \
... | Figures out if the target is a reachable host without wildcards, expands if any.
:return: |
5,668 | def get_scaled_cutout_wdht_view(shp, x1, y1, x2, y2, new_wd, new_ht):
x1, y1, x2, y2 = int(x1), int(y1), int(x2), int(y2)
new_wd, new_ht = int(new_wd), int(new_ht)
old_wd = x2 - x1 + 1
old_ht = y2 - y1 + 1
max_x, max_y = shp[1] - 1, shp[0] - 1
if (new_wd != old_wd) or (new_ht != old_... | Like get_scaled_cutout_wdht, but returns the view/slice to extract
from an image instead of the extraction itself. |
5,669 | def insertData(self, offset: int, string: str) -> None:
self._insert_data(offset, string) | Insert ``string`` at offset on this node. |
5,670 | def __parse_domain_to_employer_line(self, raw_domain, raw_org):
d = re.match(self.DOMAIN_REGEX, raw_domain, re.UNICODE)
if not d:
cause = "invalid domain format: " % raw_domain
raise InvalidFormatError(cause=cause)
dom = d.group().strip()
o = re.match(... | Parse domain to employer lines |
5,671 | def _ensure_started(self):
if not self.started:
async_handlers = [startup_handler for startup_handler in self.startup_handlers if
introspect.is_coroutine(startup_handler)]
if async_handlers:
loop = asyncio.get_event_loop()
... | Marks the API as started and runs all startup handlers |
5,672 | def _seconds_as_string(seconds):
TIME_UNITS = [(, 60), (, 60), (, 24), (, None)]
unit_strings = []
cur = max(int(seconds), 1)
for suffix, size in TIME_UNITS:
if size is not None:
cur, rest = divmod(cur, size)
else:
rest = cur
if rest > 0:
... | Returns seconds as a human-friendly string, e.g. '1d 4h 47m 41s' |
5,673 | def detect_client_auth_request(server_handshake_bytes):
for record_type, _, record_data in parse_tls_records(server_handshake_bytes):
if record_type != b:
continue
for message_type, message_data in parse_handshake_messages(record_data):
if message_type == b:
... | Determines if a CertificateRequest message is sent from the server asking
the client for a certificate
:param server_handshake_bytes:
A byte string of the handshake data received from the server
:return:
A boolean - if a client certificate request was found |
5,674 | def fitTo_t(what: Union[RtlSignal, Value], where_t: HdlType,
extend: bool=True, shrink: bool=True):
whatWidth = what._dtype.bit_length()
toWidth = where_t.bit_length()
if toWidth == whatWidth:
return what
elif toWidth < whatWidth:
if not shrink:
rai... | Slice signal "what" to fit in "where"
or
arithmetically (for signed by MSB / unsigned, vector with 0) extend
"what" to same width as "where"
little-endian impl. |
5,675 | def guess_filename(obj):
name = getattr(obj, , None)
if name and name[0] != and name[-1] != :
return os.path.basename(name) | Tries to guess the filename of the given object. |
5,676 | def output(self):
output_params = dict(
self._raw["output"],
grid=self.output_pyramid.grid,
pixelbuffer=self.output_pyramid.pixelbuffer,
metatiling=self.output_pyramid.metatiling
)
if "path" in output_params:
output_params.upda... | Output object of driver. |
5,677 | def classes_(self):
if self.__classes is None:
try:
return self.estimator.classes_
except AttributeError:
return None
return self.__classes | Proxy property to smartly access the classes from the estimator or
stored locally on the score visualizer for visualization. |
5,678 | def parseCmdline(rh):
rh.printSysLog("Enter cmdVM.parseCmdline")
if rh.totalParms >= 2:
rh.userid = rh.request[1].upper()
else:
msg = msgs.msg[][1] % modId
rh.printLn("ES", msg)
rh.updateResults(msgs.msg[][0])
rh.printSysLog("Exit cmdVM.parseCmdLine, r... | Parse the request command input.
Input:
Request Handle
Output:
Request Handle updated with parsed input.
Return code - 0: ok, non-zero: error |
5,679 | def Extract_Checkpoints(self):
if self.page is None:
raise Exception("The HTML data was not fetched due to some reasons")
if in self.page:
raise ValueError()
soup = BeautifulSoup(self.page,)
current_status = soup.find(,id=).text.strip()
if current_status == :
self.status = ... | Extract the checkpoints and store in self.tracking_data |
5,680 | def predict_sequence(self, X, A, pi, inference=):
obsll = self.predict_proba(X)
T, S = obsll.shape
alpha = np.zeros((T, S))
alpha[0, :] = pi
for t in range(1, T):
alpha[t, :] = np.dot(alpha[t-1, :], A)
for s in range(S):
alpha[t, ... | Calculate class probabilities for a sequence of data.
Parameters
----------
X : array
Test data, of dimension N times d (rows are time frames, columns
are data dimensions)
A : class transition matrix, where A[i,j] contains p(y_t=j|y_{t-1}=i)
pi : vector o... |
5,681 | def to_period(self, freq=None):
from pandas.core.arrays import PeriodArray
if self.tz is not None:
warnings.warn("Converting to PeriodArray/Index representation "
"will drop timezone information.", UserWarning)
if freq is None:
freq = ... | Cast to PeriodArray/Index at a particular frequency.
Converts DatetimeArray/Index to PeriodArray/Index.
Parameters
----------
freq : str or Offset, optional
One of pandas' :ref:`offset strings <timeseries.offset_aliases>`
or an Offset object. Will be inferred by... |
5,682 | def _get_methods_that_calculate_outputs(inputs, outputs, methods):
t calculate something we already have,
and only contains equations that might help calculate the outputs from
the inputs.
re not already returning it
if args not in output_dict.keys():
... | Given iterables of input variable names, output variable names,
and a methods dictionary, returns the subset of the methods dictionary
that can be calculated, doesn't calculate something we already have,
and only contains equations that might help calculate the outputs from
the inputs. |
5,683 | def in_virtual_env():
import sys
has_venv = False
if hasattr(sys, ):
has_venv = True
elif hasattr(sys, ):
has_venv = sys.base_prefix != sys.prefix
return has_venv | returns True if you are running inside a python virtual environment.
(DOES NOT WORK IF IN IPYTHON AND USING A VIRTUALENV)
sys.prefix gives the location of the virtualenv
Notes:
It seems IPython does not respect virtual environments properly.
TODO: find a solution
http://stackoverfl... |
5,684 | def definition(self, suffix = "", local=False, ctype=None, optionals=True,
customdim=None, modifiers=None):
kind = "({})".format(self.kind) if self.kind is not None else ""
cleanmods = [m for m in self.modifiers if m != "" and m != " "
and not (local a... | Returns the fortran code string that would define this value element.
:arg suffix: an optional suffix to append to the name of the variable.
Useful for re-using definitions with new names.
:arg local: when True, the parameter definition is re-cast as a local
variable definition that... |
5,685 | def update_filenames(self):
self.sky_file = os.path.abspath(os.path.join(os.path.join(self.input_path, ),
+ self.sky_state + + str(
self.sky_zenith) + + str(
... | Does nothing currently. May not need this method |
5,686 | def headercontent(self, method):
content = []
wsse = self.options().wsse
if wsse is not None:
content.append(wsse.xml())
headers = self.options().soapheaders
if not isinstance(headers, (tuple, list, dict)):
headers = (headers,)
elif not he... | Get the content for the SOAP I{Header} node.
@param method: A service method.
@type method: I{service.Method}
@return: The XML content for the <body/>.
@rtype: [L{Element},...] |
5,687 | def get_data_filename(filename):
global _data_map
if _data_map is None:
_data_map = {}
for root, dirs, files in os.walk(specdir):
for fname in files:
_data_map[fname] = os.path.join(root, fname)
if filename not in _data_map:
raise KeyError(filename ... | Map filename to its actual path.
Parameters
----------
filename : str
Filename to search.
Returns
-------
path : str
Full path to the file in data directory. |
5,688 | def get_user(uid, channel=14, **kwargs):
name = get_user_name(uid, **kwargs)
access = get_user_access(uid, channel, **kwargs)
data = {: name, : uid, : channel, : access[]}
return data | Get user from uid and access on channel
:param uid: user number [1:16]
:param channel: number [1:7]
:param kwargs:
- api_host=127.0.0.1
- api_user=admin
- api_pass=example
- api_port=623
- api_kg=None
Return Data
.. code-block:: none
name: (str)
... |
5,689 | def from_dict(cls, ctx):
ctx = Context(ctx)
s = cls()
ContextFlags = ctx[]
s.ContextFlags = ContextFlags
for key in cls._others:
if key != :
setattr(s, key, ctx[key])
else:
w = ctx[key]
v = (M128A * ... | Instance a new structure from a Python native type. |
5,690 | def _page(q, chunk=1000):
offset = 0
while True:
r = False
for elem in q.limit(chunk).offset(offset):
r = True
yield elem
offset += chunk
if not r:
break | Quick utility to page a query, 1000 items at a time.
We need this so we don't OOM (out of memory) ourselves loading the world. |
5,691 | def _process_marked_candidate_indexes(candidate, markers):
match = RE_SIGNATURE_CANDIDATE.match(markers[::-1])
return candidate[-match.end():] if match else [] | Run regexes against candidate's marked indexes to strip
signature candidate.
>>> _process_marked_candidate_indexes([9, 12, 14, 15, 17], 'clddc')
[15, 17] |
5,692 | def extract_connected_components(graph, connectivity_type, node_to_id):
nx_graph = nx.from_scipy_sparse_matrix(graph, create_using=nx.DiGraph())
if connectivity_type == "weak":
largest_connected_component_list = nxalgcom.weakly_connected_component_subgraphs(nx_graph)
elif connectivit... | Extract the largest connected component from a graph.
Inputs: - graph: An adjacency matrix in scipy sparse matrix format.
- connectivity_type: A string that can be either: "strong" or "weak".
- node_to_id: A map from graph node id to Twitter id, in python dictionary format.
Outputs:... |
5,693 | def __chopStringDict(self, data):
r = {}
d = data.split()
for item in d:
item_parts = item.split()
if len(item_parts) == 2:
(name, value) = item_parts
else:
name = item_parts[0]
value = item_parts[1]
... | Returns a dictionary of the provided raw service/host check string. |
5,694 | def load_name(self, name):
if name in self.globals_:
return self.globals_[name]
b = self.globals_[]
if isinstance(b, dict):
return b[name]
else:
return getattr(b, name) | Implementation of the LOAD_NAME operation |
5,695 | def view_pool(arg, opts, shell_opts):
res = Pool.list({ : arg })
if len(res) == 0:
print("No pool with name found." % arg)
return
p = res[0]
vrf_rt = None
vrf_name = None
if p.vrf:
vrf_rt = p.vrf.rt
vrf_name = p.vrf.name
print("-- Pool ")
print(... | View a single pool |
5,696 | def _cull(self):
right_now = time.time()
cull_from = -1
for index in range(len(self._call_times)):
if right_now - self._call_times[index].time >= 1.0:
cull_from = index
self._outstanding_calls -= self._call_times[index].num_calls
... | Remove calls more than 1 second old from the queue. |
5,697 | def _nest_variable(v, check_records=False):
if (check_records and is_cwl_record(v) and len(v["id"].split("/")) > 1 and
v.get("type", {}).get("type") == "array"):
return v
else:
v = copy.deepcopy(v)
v["type"] = {"type": "array", "items": v["type"]}
return v | Nest a variable when moving from scattered back to consolidated.
check_records -- avoid re-nesting a record input if it comes from a previous
step and is already nested, don't need to re-array. |
5,698 | def xvJacobianFreqs(self,jr,jphi,jz,angler,anglephi,anglez,**kwargs):
out= actionAngleTorus_c.actionAngleTorus_jacobian_c(\
self._pot,
jr,jphi,jz,
angler,anglephi,anglez,
tol=kwargs.get(,self._tol),
dJ=kwargs.get(,self._dJ))
if out[11]... | NAME:
xvJacobianFreqs
PURPOSE:
return [R,vR,vT,z,vz,phi], the Jacobian d [R,vR,vT,z,vz,phi] / d (J,angle), the Hessian dO/dJ, and frequencies Omega corresponding to a torus at multiple sets of angles
INPUT:
jr - radial action (scalar)
jphi - azimuthal ac... |
5,699 | def default_metric_definitions(cls, toolkit):
if toolkit is RLToolkit.COACH:
return [
{: ,
: },
{: ,
: }
]
elif toolkit is RLToolkit.RAY:
float_regex = "[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?" ... | Provides default metric definitions based on provided toolkit.
Args:
toolkit(sagemaker.rl.RLToolkit): RL Toolkit to be used for training.
Returns:
list: metric definitions |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.