_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 31 13.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q246900 | parse_sections | train | def parse_sections(data):
"""
yields one section at a time in the form
[ (key, [val, ...]), ... ]
where key is a string and val is a string representing a single
line of any value associated with the key. Multiple vals may be
present if the value is long enough to require line continuations
... | python | {
"resource": ""
} |
q246901 | digest_chunks | train | def digest_chunks(chunks, algorithms=(hashlib.md5, hashlib.sha1)):
"""
returns a base64 rep of the given digest algorithms from the
chunks of data | python | {
"resource": ""
} |
q246902 | file_chunk | train | def file_chunk(filename, size=_BUFFERING):
"""
returns a generator function which when called will emit x-sized
chunks of filename's contents
"""
def chunks():
with open(filename, "rb", _BUFFERING) as fd:
| python | {
"resource": ""
} |
q246903 | zipentry_chunk | train | def zipentry_chunk(zipfile, name, size=_BUFFERING):
"""
returns a generator function which when called will emit x-sized
chunks of the named entry in the zipfile object
"""
def chunks():
with zipfile.open(name) as fd:
| python | {
"resource": ""
} |
q246904 | single_path_generator | train | def single_path_generator(pathname):
"""
emits name,chunkgen pairs for the given file at pathname. If
pathname is a directory, will act recursively and will emit for
each file in the directory tree chunkgen is a generator that can
be iterated over to obtain the contents of the file in multiple
p... | python | {
"resource": ""
} |
q246905 | cli_create | train | def cli_create(argument_list):
"""
command-line call to create a manifest from a JAR file or a
directory
"""
parser = argparse.ArgumentParser()
parser.add_argument("content", help="file or directory")
# TODO: shouldn't we always process directories recursively?
parser.add_argument("-r",... | python | {
"resource": ""
} |
q246906 | main | train | def main(args=sys.argv):
"""
main entry point for the manifest CLI
"""
if len(args) < 2:
return usage("Command expected")
command = args[1]
rest = args[2:]
| python | {
"resource": ""
} |
q246907 | ManifestSection.load | train | def load(self, items):
"""
Populate this section from an iteration of the parse_items call
"""
| python | {
"resource": ""
} |
q246908 | ManifestSection.store | train | def store(self, stream, linesep=os.linesep):
"""
Serialize this section and write it to a binary stream
"""
for k, v in self.items():
| python | {
"resource": ""
} |
q246909 | Manifest.create_section | train | def create_section(self, name, overwrite=True):
"""
create and return a new sub-section of this manifest, with the
given Name attribute. If a sub-section already exists with
that name, it will be lost unless overwrite is False in which
case the existing sub-section will be return... | python | {
"resource": ""
} |
q246910 | Manifest.store | train | def store(self, stream, linesep=None):
"""
Serialize the Manifest to a binary stream
"""
# either specified here, specified on the instance, or the OS
# default
linesep = linesep or self.linesep or os.linesep
| python | {
"resource": ""
} |
q246911 | Manifest.clear | train | def clear(self):
"""
removes all items from this manifest, and clears and removes all
sub-sections
| python | {
"resource": ""
} |
q246912 | SignatureManifest.digest_manifest | train | def digest_manifest(self, manifest, java_algorithm="SHA-256"):
"""
Create a main section checksum and sub-section checksums based off
of the data from an existing manifest using an algorithm given
by Java-style name.
"""
# pick a line separator for creating checksums of ... | python | {
"resource": ""
} |
q246913 | SignatureManifest.verify_manifest_main_checksum | train | def verify_manifest_main_checksum(self, manifest):
"""
Verify the checksum over the manifest main section.
:return: True if the signature over main section verifies
"""
# NOTE: JAR spec does not state whether there can be >1 digest used,
# and should the validator requi... | python | {
"resource": ""
} |
q246914 | SignatureManifest.verify_manifest_entry_checksums | train | def verify_manifest_entry_checksums(self, manifest, strict=True):
"""
Verifies the checksums over the given manifest. If strict is True
then entries which had no digests will fail verification. If
strict is False then entries with no digests will not be
considered failing.
... | python | {
"resource": ""
} |
q246915 | fnmatches | train | def fnmatches(entry, *pattern_list):
"""
returns true if entry matches any of the glob patterns, false
otherwise
"""
for pattern | python | {
"resource": ""
} |
q246916 | copydir | train | def copydir(orig, dest):
"""
copies directory orig to dest. Returns a list of tuples of
relative filenames which were copied from orig to dest
"""
copied = list()
makedirsp(dest)
for root, dirs, files in walk(orig):
| python | {
"resource": ""
} |
q246917 | _gen_from_dircmp | train | def _gen_from_dircmp(dc, lpath, rpath):
"""
do the work of comparing the dircmp
"""
left_only = dc.left_only
left_only.sort()
for f in left_only:
fp = join(dc.left, f)
if isdir(fp):
for r, _ds, fs in walk(fp):
r = relpath(r, lpath)
fo... | python | {
"resource": ""
} |
q246918 | verify | train | def verify(certificate, jar_file, sf_name=None):
"""
Verifies signature of a JAR file.
Limitations:
- diagnostic is less verbose than of jarsigner
:return None if verification succeeds.
:exception SignatureBlockFileVerificationError, ManifestChecksumError,
JarChecksumError, JarSignature... | python | {
"resource": ""
} |
q246919 | cli_create_jar | train | def cli_create_jar(argument_list):
"""
A subset of "jar" command. Creating new JARs only.
"""
usage_message = "usage: jarutil c [OPTIONS] file.jar files..."
parser = argparse.ArgumentParser(usage=usage_message)
parser.add_argument("jar_file", type=str,
help="The file to... | python | {
"resource": ""
} |
q246920 | create_signature_block | train | def create_signature_block(openssl_digest, certificate, private_key,
extra_certs, data):
"""
Produces a signature block for the data.
Reference
---------
http://docs.oracle.com/javase/7/docs/technotes/guides/jar/jar.html#Digital_Signatures
Note: Oracle does not spec... | python | {
"resource": ""
} |
q246921 | verify_signature_block | train | def verify_signature_block(certificate_file, content, signature):
"""
Verifies the 'signature' over the 'content', trusting the
'certificate'.
:param certificate_file: the trusted certificate (PEM format)
:type certificate_file: str
:param content: The signature should match this content
:t... | python | {
"resource": ""
} |
q246922 | Emails.send | train | def send(self, obj_id):
"""
Send email to the assigned lists
:param obj_id: int
:return: dict|str
"""
response = self._client.session.post(
'{url}/{id}/send'.format(
| python | {
"resource": ""
} |
q246923 | Emails.send_to_contact | train | def send_to_contact(self, obj_id, contact_id):
"""
Send email to a specific contact
:param obj_id: int
:param contact_id: int
:return: dict|str
"""
response = self._client.session.post(
'{url}/{id}/send/contact/{contact_id}'.format(
| python | {
"resource": ""
} |
q246924 | Contacts.get_owners | train | def get_owners(self):
"""
Get a list of users available as contact owners
:return: dict|str
| python | {
"resource": ""
} |
q246925 | Contacts.get_events | train | def get_events(
self,
obj_id,
search='',
include_events=None,
exclude_events=None,
order_by='',
order_by_dir='ASC',
page=1
):
"""
Get a list of a contact's engagement events
:param obj_id: int Contact ID
:param search: ... | python | {
"resource": ""
} |
q246926 | Contacts.get_contact_notes | train | def get_contact_notes(
self,
obj_id,
search='',
start=0,
limit=0,
order_by='',
order_by_dir='ASC'
):
"""
Get a list of a contact's notes
:param obj_id: int Contact ID
:param search: str
:param start: int
:param ... | python | {
"resource": ""
} |
q246927 | Contacts.add_points | train | def add_points(self, obj_id, points, **kwargs):
"""
Add the points to a contact
:param obj_id: int
:param points: int
:param kwargs: dict 'eventname' and 'actionname'
:return: dict|str
"""
response = self._client.session.post(
| python | {
"resource": ""
} |
q246928 | Contacts.add_dnc | train | def add_dnc(
self,
obj_id,
channel='email',
reason=MANUAL,
channel_id=None,
comments='via API'
):
"""
Adds Do Not Contact
:param obj_id: int
:param channel: str
:param reason: str
:param channel_id: int
:param c... | python | {
"resource": ""
} |
q246929 | Contacts.remove_dnc | train | def remove_dnc(self, obj_id, channel):
"""
Removes Do Not Contact
:param obj_id: int
:param channel: str
:return: dict|str
"""
response = self._client.session.post(
'{url}/{id}/dnc/remove/{channel}'.format(
| python | {
"resource": ""
} |
q246930 | API.get | train | def get(self, obj_id):
"""
Get a single item
:param obj_id: int
:return: dict|str
"""
response = self._client.session.get(
'{url}/{id}'.format(
| python | {
"resource": ""
} |
q246931 | API.get_list | train | def get_list(
self,
search='',
start=0,
limit=0,
order_by='',
order_by_dir='ASC',
published_only=False,
minimal=False
):
"""
Get a list of items
:param search: str
:param start: int
:param limit: int
:pa... | python | {
"resource": ""
} |
q246932 | API.edit | train | def edit(self, obj_id, parameters, create_if_not_exists=False):
"""
Edit an item with option to create if it doesn't exist
:param obj_id: int
:param create_if_not_exists: bool
:param parameters: dict
:return: dict|str
"""
if create_if_not_exists:
... | python | {
"resource": ""
} |
q246933 | Stats.get | train | def get(self, table='', start=0, limit=0, order=None, where=None):
"""
Get a list of stat items
:param table: str database table name
:param start: int
:param limit: int
:param order: list|tuple
:param where: list|tuple
:return:
"""
parame... | python | {
"resource": ""
} |
q246934 | Segments.add_contact | train | def add_contact(self, segment_id, contact_id):
"""
Add a contact to the segment
:param segment_id: int Segment ID
:param contact_id: int Contact ID
:return: dict|str
"""
response = self._client.session.post(
'{url}/{segment_id}/contact/add/{contact_i... | python | {
"resource": ""
} |
q246935 | Users.check_permission | train | def check_permission(self, obj_id, permissions):
"""
Get list of permissions for a user
:param obj_id: int
:param permissions: str|list|tuple
:return: dict|str
"""
response = self._client.session.post(
'{url}/{id}/permissioncheck'.format(
| python | {
"resource": ""
} |
q246936 | PointTriggers.delete_trigger_events | train | def delete_trigger_events(self, trigger_id, event_ids):
"""
Remove events from a point trigger
:param trigger_id: int
:param event_ids: list|tuple
:return: dict|str
"""
response = self._client.session.delete(
'{url}/{trigger_id}/events/delete'.format... | python | {
"resource": ""
} |
q246937 | Forms.delete_fields | train | def delete_fields(self, form_id, field_ids):
"""
Remove fields from a form
:param form_id: int
:param field_ids: list|tuple
:return: dict|str
"""
response = self._client.session.delete(
'{url}/{form_id}/fields/delete'.format(
| python | {
"resource": ""
} |
q246938 | Forms.delete_actions | train | def delete_actions(self, form_id, action_ids):
"""
Remove actions from a form
:param form_id: int
:param action_ids: list|tuple
:return: dict|str
"""
response = self._client.session.delete(
'{url}/{form_id}/actions/delete'.format(
| python | {
"resource": ""
} |
q246939 | update_token_tempfile | train | def update_token_tempfile(token):
"""
Example of function for token update
"""
| python | {
"resource": ""
} |
q246940 | Files.set_folder | train | def set_folder(self, folder='assets'):
"""
Changes the file folder to look at
:param folder: str [images, | python | {
"resource": ""
} |
q246941 | _check_cooling_parameters | train | def _check_cooling_parameters(radiuscooling, scalecooling):
"""Helper function to verify the cooling parameters of the training.
"""
if radiuscooling != "linear" and radiuscooling != "exponential":
raise Exception("Invalid parameter for radiuscooling: " +
| python | {
"resource": ""
} |
q246942 | _hexplot | train | def _hexplot(matrix, fig, colormap):
"""Internal function to plot a hexagonal map.
"""
umatrix_min = matrix.min()
umatrix_max = matrix.max()
n_rows, n_columns = matrix.shape
cmap = plt.get_cmap(colormap)
offsets = np.zeros((n_columns * n_rows, 2))
facecolors = []
for row in range(n_r... | python | {
"resource": ""
} |
q246943 | Somoclu.load_bmus | train | def load_bmus(self, filename):
"""Load the best matching units from a file to the Somoclu object.
:param filename: The name of the file.
:type filename: str.
"""
self.bmus = np.loadtxt(filename, comments='%', usecols=(1, 2))
if self.n_vectors != 0 and len(self.bmus) != s... | python | {
"resource": ""
} |
q246944 | Somoclu.load_umatrix | train | def load_umatrix(self, filename):
"""Load the umatrix from a file to the Somoclu object.
:param filename: The name of the file.
:type filename: str.
| python | {
"resource": ""
} |
q246945 | Somoclu.load_codebook | train | def load_codebook(self, filename):
"""Load the codebook from a file to the Somoclu object.
:param filename: The name of the file.
:type filename: str.
"""
self.codebook = np.loadtxt(filename, comments='%')
if self.n_dim == 0:
self.n_dim = self.codebook.shape[... | python | {
"resource": ""
} |
q246946 | Somoclu.update_data | train | def update_data(self, data):
"""Change the data set in the Somoclu object. It is useful when the
data is updated and the training should continue on the new data.
:param data: The training data.
:type data: 2D numpy.array of float32.
"""
oldn_dim = self.n_dim
if ... | python | {
"resource": ""
} |
q246947 | Somoclu.view_component_planes | train | def view_component_planes(self, dimensions=None, figsize=None,
colormap=cm.Spectral_r, colorbar=False,
bestmatches=False, bestmatchcolors=None,
labels=None, zoom=None, filename=None):
"""Observe the component planes in the... | python | {
"resource": ""
} |
q246948 | Somoclu.view_umatrix | train | def view_umatrix(self, figsize=None, colormap=cm.Spectral_r,
colorbar=False, bestmatches=False, bestmatchcolors=None,
labels=None, zoom=None, filename=None):
"""Plot the U-matrix of the trained map.
:param figsize: Optional parameter to specify the size of the ... | python | {
"resource": ""
} |
q246949 | Somoclu.view_activation_map | train | def view_activation_map(self, data_vector=None, data_index=None,
activation_map=None, figsize=None,
colormap=cm.Spectral_r, colorbar=False,
bestmatches=False, bestmatchcolors=None,
labels=None, zoom=None, fil... | python | {
"resource": ""
} |
q246950 | Somoclu._check_parameters | train | def _check_parameters(self):
"""Internal function to verify the basic parameters of the SOM.
"""
if self._map_type != "planar" and self._map_type != "toroid":
raise Exception("Invalid parameter for _map_type: " +
self._map_type)
if self._grid_type ... | python | {
"resource": ""
} |
q246951 | Somoclu._init_codebook | train | def _init_codebook(self):
"""Internal function to set the codebook or to indicate it to the C++
code that it should be randomly initialized.
"""
codebook_size = self._n_columns * self._n_rows * self.n_dim
if self.codebook is None:
if self._initialization == "random":
... | python | {
"resource": ""
} |
q246952 | Somoclu.cluster | train | def cluster(self, algorithm=None):
"""Cluster the codebook. The clusters of the data instances can be
assigned based on the BMUs. The method populates the class variable
Somoclu.clusters. If viewing methods are called after clustering, but
without colors for best matching units, colors w... | python | {
"resource": ""
} |
q246953 | Somoclu.get_surface_state | train | def get_surface_state(self, data=None):
"""Return the Euclidean distance between codebook and data.
:param data: Optional parameter to specify data, otherwise the
data used previously to train the SOM is used.
:type data: 2D numpy.array of float32.
:returns: The th... | python | {
"resource": ""
} |
q246954 | Somoclu.get_bmus | train | def get_bmus(self, activation_map):
"""Returns Best Matching Units indexes of the activation map.
:param activation_map: Activation map computed with self.get_surface_state()
:type activation_map: 2D numpy.array
:returns: The bmus indexes corresponding to this activation map
... | python | {
"resource": ""
} |
q246955 | Somoclu.view_similarity_matrix | train | def view_similarity_matrix(self, data=None, labels=None, figsize=None,
filename=None):
"""Plot the similarity map according to the activation map
:param data: Optional parameter for data points to calculate the
similarity with
:type data: nump... | python | {
"resource": ""
} |
q246956 | find_child_element | train | def find_child_element(elm, child_local_name):
"""
Find an XML child element by local tag name.
"""
for n in range(len(elm)):
child_elm = elm[n]
| python | {
"resource": ""
} |
q246957 | CASLoginHandler.make_service_url | train | def make_service_url(self):
"""
Make the service URL CAS will use to redirect the browser back to this service.
"""
cas_service_url = self.authenticator.cas_service_url
if cas_service_url is None:
| python | {
"resource": ""
} |
q246958 | CASLoginHandler.validate_service_ticket | train | def validate_service_ticket(self, ticket):
"""
Validate a CAS service ticket.
Returns (is_valid, user, attribs).
`is_valid` - boolean
`attribs` - set of attribute-value tuples.
"""
app_log = logging.getLogger("tornado.application")
http_client = AsyncHTTP... | python | {
"resource": ""
} |
q246959 | clean_exit | train | def clean_exit(signum, frame=None):
"""Exit all processes attempting to finish uncommitted active work before exit.
Can be called on an os signal or no zookeeper losing connection.
"""
global exiting
if exiting:
# Since this is set up as a handler for SIGCHLD when this kills one
... | python | {
"resource": ""
} |
q246960 | main | train | def main():
"""Start persister."""
config.parse_args()
# Add processors for metrics topic
if cfg.CONF.kafka_metrics.enabled:
prepare_processes(cfg.CONF.kafka_metrics,
cfg.CONF.repositories.metrics_driver)
# Add processors for alarm history topic
if cfg.CONF.ka... | python | {
"resource": ""
} |
q246961 | _get_config_files | train | def _get_config_files():
"""Get the possible configuration files accepted by oslo.config
This also includes the deprecated ones
"""
# default files
conf_files = cfg.find_config_files(project='monasca',
prog='monasca-persister')
# deprecated config files (o... | python | {
"resource": ""
} |
q246962 | load_conf_modules | train | def load_conf_modules():
"""Load all modules that contain configuration.
Method iterates over modules of :py:module:`monasca_persister.conf`
and imports only those that contain following methods:
- list_opts (required by oslo_config.genconfig)
| python | {
"resource": ""
} |
q246963 | list_opts | train | def list_opts():
"""List all conf modules opts.
Goes through all conf modules and yields their opts.
"""
for mod in load_conf_modules():
mod_opts = mod.list_opts()
if type(mod_opts) is list:
for | python | {
"resource": ""
} |
q246964 | message | train | def message(title="", text="", width=DEFAULT_WIDTH,
height=DEFAULT_HEIGHT, timeout=None):
"""
Display a simple message
:param text: text inside the window
:type text: str
:param title: title of the window
:type title: str
:param width: window width
:type width: int
:para... | python | {
"resource": ""
} |
q246965 | error | train | def error(title="", text="", width=DEFAULT_WIDTH,
height=DEFAULT_HEIGHT, timeout=None):
"""
Display a simple error
:param text: text inside the window
:type text: str
:param title: title of the window
:type title: str
:param width: window width
:type width: int
:param heig... | python | {
"resource": ""
} |
q246966 | warning | train | def warning(title="", text="", width=DEFAULT_WIDTH,
height=DEFAULT_HEIGHT, timeout=None):
"""
Display a simple warning
:param text: text inside the window
:type text: str
:param title: title of the window
:type title: str
:param width: window width
:type width: int
:para... | python | {
"resource": ""
} |
q246967 | entry | train | def entry(text="", placeholder="", title="",
width=DEFAULT_WIDTH, height=DEFAULT_HEIGHT, timeout=None):
"""
Display a text input
:param text: text inside the window
:type text: str
:param placeholder: placeholder for the input
:type placeholder: str
:param title: title of the wind... | python | {
"resource": ""
} |
q246968 | password | train | def password(text="", placeholder="", title="",
width=DEFAULT_WIDTH, height=DEFAULT_HEIGHT, timeout=None):
"""
Display a text input with hidden characters
:param text: text inside the window
:type text: str
:param placeholder: placeholder for the input
:type placeholder: str
| python | {
"resource": ""
} |
q246969 | zlist | train | def zlist(columns, items, print_columns=None,
text="", title="", width=DEFAULT_WIDTH,
height=ZLIST_HEIGHT, timeout=None):
"""
Display a list of values
:param columns: a list of columns name
:type columns: list of strings
:param items: a list of values
:type items: list of st... | python | {
"resource": ""
} |
q246970 | file_selection | train | def file_selection(multiple=False, directory=False, save=False,
confirm_overwrite=False, filename=None,
title="", width=DEFAULT_WIDTH,
height=DEFAULT_HEIGHT, timeout=None):
"""
Open a file selection window
:param multiple: allow multiple file selecti... | python | {
"resource": ""
} |
q246971 | calendar | train | def calendar(text="", day=None, month=None, title="",
width=DEFAULT_WIDTH, height=DEFAULT_HEIGHT, timeout=None):
"""
Display a calendar
:param text: text inside the window
:type text: str
:param day: default day
:type day: int
:param month: default month
:type month: int
... | python | {
"resource": ""
} |
q246972 | color_selection | train | def color_selection(show_palette=False, opacity_control=False, title="",
width=DEFAULT_WIDTH, height=DEFAULT_HEIGHT, timeout=None):
"""
Display a color selection dialog
:param show_palette: hide/show the palette with preselected colors
:type show_palette: bool
:param opacity_con... | python | {
"resource": ""
} |
q246973 | scale | train | def scale(text="", value=0, min=0 ,max=100, step=1, draw_value=True, title="",
width=DEFAULT_WIDTH, height=DEFAULT_HEIGHT, timeout=None):
"""
Select a number with a range widget
:param text: text inside window
:type text: str
:param value: current value
:type value: int
:param min... | python | {
"resource": ""
} |
q246974 | raw_on | train | def raw_on(serial):
"""
Puts the device into raw mode.
"""
def flush_to_msg(serial, msg):
"""Read the rx serial data until we reach an expected message."""
data = serial.read_until(msg)
if not data.endswith(msg):
if COMMAND_LINE_FLAG:
print(data)
... | python | {
"resource": ""
} |
q246975 | clean_error | train | def clean_error(err):
"""
Take stderr bytes returned from MicroPython and attempt to create a
non-verbose error message.
"""
if err:
decoded = err.decode('utf-8')
try:
| python | {
"resource": ""
} |
q246976 | version | train | def version(serial=None):
"""
Returns version information for MicroPython running on the connected
device.
If such information is not available or the device is not running
MicroPython, raise a ValueError.
If any other exception is thrown, the device was running MicroPython but
there was a... | python | {
"resource": ""
} |
q246977 | main | train | def main(argv=None):
"""
Entry point for the command line tool 'ufs'.
Takes the args and processes them as per the documentation. :-)
Exceptions are caught and printed for the user.
"""
if not argv:
argv = sys.argv[1:]
try:
global COMMAND_LINE_FLAG
COMMAND_LINE_FLAG... | python | {
"resource": ""
} |
q246978 | SentryReporter.http_context | train | def http_context(self, worker_ctx):
""" Attempt to extract HTTP context if an HTTP entrypoint was used.
"""
http = {}
if isinstance(worker_ctx.entrypoint, HttpRequestHandler):
try:
request = worker_ctx.args[0]
try:
if reques... | python | {
"resource": ""
} |
q246979 | SentryReporter.user_context | train | def user_context(self, worker_ctx, exc_info):
""" Merge any user context to include in the sentry payload.
Extracts user identifiers from the worker context data by matching
context keys with
| python | {
"resource": ""
} |
q246980 | SentryReporter.tags_context | train | def tags_context(self, worker_ctx, exc_info):
""" Merge any tags to include in the sentry payload.
"""
tags = {
'call_id': worker_ctx.call_id,
'parent_call_id': worker_ctx.immediate_parent_call_id,
'service_name': worker_ctx.container.service_name,
... | python | {
"resource": ""
} |
q246981 | SentryReporter.extra_context | train | def extra_context(self, worker_ctx, exc_info):
""" Merge any extra context to include in the sentry payload.
Includes all available worker context data.
"""
extra = {}
| python | {
"resource": ""
} |
q246982 | Endpoint.wait_until_serving | train | async def wait_until_serving(self) -> None:
"""
Await until the ``Endpoint`` is ready to receive events.
| python | {
"resource": ""
} |
q246983 | Endpoint.connect_to_endpoints | train | async def connect_to_endpoints(self, *endpoints: ConnectionConfig) -> None:
"""
Connect to the given endpoints and await until all connections are established.
"""
self._throw_if_already_connected(*endpoints)
await asyncio.gather(
| python | {
"resource": ""
} |
q246984 | Endpoint.connect_to_endpoints_nowait | train | def connect_to_endpoints_nowait(self, *endpoints: ConnectionConfig) -> None:
"""
Connect to the given endpoints as soon as they become available but do not block.
"""
| python | {
"resource": ""
} |
q246985 | Endpoint.wait_for | train | async def wait_for(self, event_type: Type[TWaitForEvent]) -> TWaitForEvent: # type: ignore
"""
Wait for a single instance of an event that matches | python | {
"resource": ""
} |
q246986 | HeapGenerator.add_to_heap | train | def add_to_heap(self, heap, descriptors='stale', data='stale'):
"""Update a heap to contains all the new items and item descriptors
since the last call.
Parameters
----------
heap : :py:class:`Heap`
The heap to update.
descriptors : {'stale', 'all', 'none'}
... | python | {
"resource": ""
} |
q246987 | Stream.get | train | def get(self, loop=None):
"""Coroutine that waits for a heap to become available and returns it."""
self._clear_done_waiters()
if not self._waiters:
# If something is available directly, we can avoid going back to
# the scheduler
try:
heap = se... | python | {
"resource": ""
} |
q246988 | parse_range_list | train | def parse_range_list(ranges):
"""Split a string like 2,3-5,8,9-11 into a list of integers. This is
intended to ease adding command-line options for dealing with affinity.
"""
if not ranges:
return []
parts = ranges.split(',')
out = []
for part in parts:
fields = part.split('-... | python | {
"resource": ""
} |
q246989 | Descriptor._parse_format | train | def _parse_format(cls, fmt):
"""Attempt to convert a SPEAD format specification to a numpy dtype.
Where necessary, `O` is used.
Raises
------
ValueError
If the format is illegal
"""
fields = []
if not fmt:
raise ValueError('empty f... | python | {
"resource": ""
} |
q246990 | Descriptor.itemsize_bits | train | def itemsize_bits(self):
"""Number of bits per element"""
if self.dtype is not None:
return self.dtype.itemsize * | python | {
"resource": ""
} |
q246991 | Descriptor.dynamic_shape | train | def dynamic_shape(self, max_elements):
"""Determine the dynamic shape, given incoming data that is big enough
to hold `max_elements` elements.
"""
known = 1
unknown_pos = -1
for i, x in enumerate(self.shape):
if x is not None:
known *= x
... | python | {
"resource": ""
} |
q246992 | ItemGroup.update | train | def update(self, heap):
"""Update the item descriptors and items from an incoming heap.
Parameters
----------
heap : :class:`spead2.recv.Heap`
Incoming heap
Returns
-------
dict
Items that have been updated from this heap, indexed by name... | python | {
"resource": ""
} |
q246993 | LandmarkGraph.build_landmark_op | train | def build_landmark_op(self):
"""Build the landmark operator
Calculates spectral clusters on the kernel, and calculates transition
probabilities between cluster centers by using transition probabilities
between samples assigned to each cluster.
"""
tasklogger.log_start("l... | python | {
"resource": ""
} |
q246994 | MNNGraph.build_kernel | train | def build_kernel(self):
"""Build the MNN kernel.
Build a mutual nearest neighbors kernel.
Returns
-------
K : kernel matrix, shape=[n_samples, n_samples]
symmetric matrix with ones down the diagonal
with no non-negative entries.
"""
taskl... | python | {
"resource": ""
} |
q246995 | from_igraph | train | def from_igraph(G, attribute="weight", **kwargs):
"""Convert an igraph.Graph to a graphtools.Graph
Creates a graphtools.graphs.TraditionalGraph with a
precomputed adjacency matrix
Parameters
----------
G : igraph.Graph
Graph to be converted
attribute : str, optional (default: "weig... | python | {
"resource": ""
} |
q246996 | Data._reduce_data | train | def _reduce_data(self):
"""Private method to reduce data dimension.
If data is dense, uses randomized PCA. If data is sparse, uses
randomized SVD.
TODO: should we subtract and store the mean?
Returns
-------
Reduced data matrix
"""
if self.n_pca ... | python | {
"resource": ""
} |
q246997 | Data.transform | train | def transform(self, Y):
"""Transform input data `Y` to reduced data space defined by `self.data`
Takes data in the same ambient space as `self.data` and transforms it
to be in the same reduced space as `self.data_nu`.
Parameters
----------
Y : array-like, shape=[n_sampl... | python | {
"resource": ""
} |
q246998 | Data.inverse_transform | train | def inverse_transform(self, Y, columns=None):
"""Transform input data `Y` to ambient data space defined by `self.data`
Takes data in the same reduced space as `self.data_nu` and transforms
it to be in the same ambient space as `self.data`.
Parameters
----------
Y : arra... | python | {
"resource": ""
} |
q246999 | BaseGraph._build_kernel | train | def _build_kernel(self):
"""Private method to build kernel matrix
Runs public method to build kernel matrix and runs
additional checks to ensure that the result is okay
Returns
-------
Kernel matrix, shape=[n_samples, n_samples]
Raises
------
| python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.