code stringlengths 20 4.93k | docstring stringlengths 33 1.27k | source stringclasses 3
values |
|---|---|---|
def get_lagged_subsequences(self, sequence: torch.Tensor, subsequences_length: int, shift: int=0) -> torch.Tensor:
indices = [lag - shift for lag in self.config.lags_sequence]
sequence_length = sequence.shape[1]
if max(indices) + subsequences_length > sequence_length:
raise ValueError(f'lags cannot ... | Returns lagged subsequences of a given sequence. Returns a tensor of shape (batch_size, subsequences_length,
feature_size, indices_length), containing lagged subsequences. Specifically, lagged[i, j, :, k] = sequence[i,
-indices[k]-subsequences_length+j, :].
Args:
sequence (`torch.Tensor` or shape `(batch_size, context... | github-repos |
def prune_conv1d_layer(layer: Conv1D, index: torch.LongTensor, dim: int=1) -> Conv1D:
index = index.to(layer.weight.device)
W = layer.weight.index_select(dim, index).detach().clone()
if dim == 0:
b = layer.bias.detach().clone()
else:
b = layer.bias[index].detach().clone()
new_size = ... | Prune a Conv1D layer to keep only entries in index. A Conv1D work as a Linear layer (see e.g. BERT) but the weights
are transposed.
Used to remove heads.
Args:
layer ([`~pytorch_utils.Conv1D`]): The layer to prune.
index (`torch.LongTensor`): The indices to keep in the layer.
dim (`int`, *optional*, defaults to 1): T... | github-repos |
def get_setter(proto):
_, type_registrations = _REVIVED_TYPE_REGISTRY.get(proto.identifier, (None, None))
if type_registrations is not None:
for type_registration in type_registrations:
if type_registration.should_load(proto):
return type_registration.setter
return None | Gets the registered setter function for the SavedUserObject proto.
See VersionedTypeRegistration for info about the setter function.
Args:
proto: SavedUserObject proto
Returns:
setter function | github-repos |
def _get_facet_chempots(self, facet):
complist = [self.qhull_entries[i].composition for i in facet]
energylist = [self.qhull_entries[i].energy_per_atom for i in facet]
m = [[c.get_atomic_fraction(e) for e in self.elements] for c in complist]
chempots = np.linalg.solve(m, energylist)
return dict(zip(... | Calculates the chemical potentials for each element within a facet.
Args:
facet: Facet of the phase diagram.
Returns:
{ element: chempot } for all elements in the phase diagram. | codesearchnet |
def create_branch(profile, name, branch_off):
branch_off_sha = get_branch_sha(profile, branch_off)
ref = ('heads/' + name)
data = refs.create_ref(profile, ref, branch_off_sha)
return data | Create a branch.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
name
The name of the new branch.
branch_off
The name of a branch to create the new branch off of.
Returns:
A dict w... | codesearchnet |
def get_meshes_vec(step, var):
if step.geom.twod_xz:
(xmesh, ymesh) = (step.geom.x_mesh[(:, 0, :)], step.geom.z_mesh[(:, 0, :)])
vec1 = step.fields[(var + '1')][(:, 0, :, 0)]
vec2 = step.fields[(var + '3')][(:, 0, :, 0)]
elif (step.geom.cartesian and step.geom.twod_yz):
(xmesh, y... | Return vector field components along with coordinates meshes.
Only works properly in 2D geometry.
Args:
step (:class:`~stagpy.stagyydata._Step`): a step of a StagyyData
instance.
var (str): vector field name.
Returns:
tuple of :class:`numpy.array`: xmesh, ymesh, fldx, fldy
2D arrays containing respectively the x posi... | codesearchnet |
def parse_args(arglist=None):
climan = CLIManager(conf, **SUB_CMDS)
create_complete_files(climan, CONFIG_DIR, 'stagpy', 'stagpy-git',
zsh_sourceable=True)
cmd_args, all_subs = climan.parse_args(arglist)
sub_cmd = cmd_args.loam_sub_name
if sub_cmd is None:
re... | Parse cmd line arguments.
Update :attr:`stagpy.conf` accordingly.
Args:
arglist (list of str): the list of cmd line arguments. If set to
None, the arguments are taken from :attr:`sys.argv`.
Returns:
function: the function implementing the sub command to be executed. | juraj-google-style |
def query_properties_with_values(self, query, include_defaults=True):
themed_keys = set()
result = dict()
if include_defaults:
keys = self.properties()
else:
keys = set(self._property_values.keys()) | se... | Query the properties values of |HasProps| instances with a
predicate.
Args:
query (callable) :
A callable that accepts property descriptors and returns True
or False
include_defaults (bool, optional) :
Whether to include properties that have not been explicitly
set by a user (default: True)
Returns:
dict : mapping o... | juraj-google-style |
def add(self, text, checked=False, sort=None):
node = ListItem(parent_id=self.id, parent_server_id=self.server_id)
node.checked = checked
node.text = text
if (sort is not None):
node.sort = sort
self.append(node, True)
self.touch(True)
return node | Add a new item to the list.
Args:
text (str): The text.
checked (bool): Whether this item is checked.
sort (int): Item id for sorting. | codesearchnet |
def _get_full_name(self):
full_name_parts = [self._get_class(), self._get_name()]
return ' | Gets the qualified name of the test method corresponding to the
instrumentation block.
Returns:
A string containing the fully qualified name of the
instrumentation test method. If parts are missing, then degrades
steadily. | github-repos |
def parse_metadata(lines):
meta = defaultdict(list)
for line in lines:
line = line.rstrip()
if line.startswith("!"):
if "_table_begin" in line or "_table_end" in line:
continue
key, value = __parse_entry(line)
meta[key].append(value)
... | Parse list of lines with metadata information from SOFT file.
Args:
lines (:obj:`Iterable`): Iterator over the lines.
Returns:
:obj:`dict`: Metadata from SOFT file. | juraj-google-style |
def run(self, dag):
for node in dag.op_nodes(self.gate):
if (not node.op.definition):
continue
rule = node.op.definition
decomposition = DAGCircuit()
decomposition.add_qreg(rule[0][1][0][0])
if rule[0][2]:
decomposition.add_creg(rule[0][2][0][0])
... | Expand a given gate into its decomposition.
Args:
dag(DAGCircuit): input dag
Returns:
DAGCircuit: output dag where gate was expanded. | codesearchnet |
def get_tensor_num_entries(self, tensor_name, partial_layout=None,
mesh_dimension_to_size=None):
shape = self.get_tensor_shape(tensor_name)
num_entries = 1
for dim in shape.dims:
num_entries = num_entries * dim.value
if not partial_layout:
return ... | The number of entries in a tensor.
If partial_layout is specified, then mesh_dimension_to_size must also be. In
this case, the number of entries on a single device is returned.
Args:
tensor_name: a string, name of a tensor in the graph.
partial_layout: an optional {string: string}, from MTF dimension name to
mesh dim... | juraj-google-style |
def _assert_float_dtype(dtype):
if not dtype.is_floating:
raise ValueError(f'Argument `dtype` is expected to be floating point. Received: {dtype}.')
return dtype | Validate and return floating point type based on `dtype`.
`dtype` must be a floating point type.
Args:
dtype: The data type to validate.
Returns:
Validated type.
Raises:
ValueError: if `dtype` is not a floating point type. | github-repos |
def get_data_location(self, catalog_id):
try:
record = self.get(catalog_id)
except:
return None
if 'Landsat8' in record['type'] and 'LandsatAcquisition' in record['type']:
bucket = record['properties']['bucketName']
prefix = rec... | Find and return the S3 data location given a catalog_id.
Args:
catalog_id: The catalog ID
Returns:
A string containing the s3 location of the data associated with a catalog ID. Returns
None if the catalog ID is not found, or if there is no data yet associated with it. | juraj-google-style |
def group_systems(self, group_name, systems):
api_group_id = None
headers = {'Content-Type': 'application/json'}
group_path = (self.api_url + '/v1/groups')
group_get_path = (group_path + ('?display_name=%s' % quote(group_name)))
logger.debug('GET group: %s', group_get_path)
net_logger.info('GET ... | Adds an array of systems to specified group
Args:
group_name: Display name of group
systems: Array of {'machine_id': machine_id} | codesearchnet |
def _pull_response(self, namespace, req_type, **params):
self._validate_namespace(namespace)
context_id = params['EnumerationContext']
try:
context_data = self.enumeration_contexts[context_id]
except KeyError:
raise CIMError(CIM_ERR_INVALID_ENUMERATION_CONTEXT, _format('EnumerationContex... | Common method for all of the Pull methods. Since all of the pull
methods operate independent of the type of data, this single function
severs as common code
This method validates the namespace, gets data on the enumeration
sequence from the enumeration_contexts table, validates the pull
type, and returns the required ... | codesearchnet |
def find_duplicate_items(items, k=2):
r
import utool as ut
duplicate_map = ut.ddict(list)
for count, item in enumerate(items):
duplicate_map[item].append(count)
singleton_keys = []
for key in six.iterkeys(duplicate_map):
if len(duplicate_map[key]) == 1:
sing... | r"""
Args:
items (list):
Returns:
dict: duplicate_map of indexes
CommandLine:
python -m utool.util_list --test-find_duplicate_items
Example:
>>> # DISABLE_DOCTEST
>>> from utool.util_list import * # NOQA
>>> items = [0, 1, 2, 3, 3, 0, 12, 2, 9]
>>> duplicate_map = find_duplicate_items(items)
>>> result = str(duplic... | juraj-google-style |
def destroy_connection(self, connection):
log.debug('Destroying connection at <{0}>'.format(hex(id(connection))))
self._decontextualise_connection(connection)
connection.unbind() | Destroys a connection. Removes the connection from the appcontext, and
unbinds it.
Args:
connection (ldap3.Connection): The connnection to destroy | codesearchnet |
def Send(self, message):
if (not isinstance(message, common_pb2.Message)):
raise ValueError('Send requires a fleetspeak.Message')
if (message.destination.service_name == 'system'):
raise ValueError('Only predefined messages can have destination.service_name == "system"')
return self._SendImp... | Send a message through Fleetspeak.
Args:
message: A message protocol buffer.
Returns:
Size of the message in bytes.
Raises:
ValueError: If message is not a common_pb2.Message. | codesearchnet |
def print_network_spec(mlmodel_spec, interface_only=False):
inputs, outputs, layers_info = summarize_neural_network_spec(mlmodel_spec)
print('Inputs:')
for i in inputs:
name, description = i
print(' {} {}'.format(name, description))
print('Outputs:')
for o in outputs:
... | Print the network information summary.
Args:
mlmodel_spec : the mlmodel spec
interface_only : Shows only the input and output of the network | juraj-google-style |
def orient_graph(self, df_data, graph, nb_runs=6, printout=None, **kwargs):
if (type(graph) == nx.DiGraph):
edges = [a for a in list(graph.edges()) if ((a[1], a[0]) in list(graph.edges()))]
oriented_edges = [a for a in list(graph.edges()) if ((a[1], a[0]) not in list(graph.edges()))]
for a i... | Orient an undirected graph using the pairwise method defined by the subclass.
The pairwise method is ran on every undirected edge.
Args:
df_data (pandas.DataFrame): Data
umg (networkx.Graph): Graph to orient
nb_runs (int): number of times to rerun for each pair (bootstrap)
printout (str): (optional) Path to file wher... | codesearchnet |
def from_args(cls: Type[ConfigT], args: Namespace) -> ConfigT:
parsed_args = cls.parse_args(args)
return cls(args, host=args.host, port=args.port, debug=args.debug,
reject_insecure_auth=not args.insecure_login,
cert_file=args.cert, key_file=args.key,
... | Build and return a new :class:`IMAPConfig` using command-line
arguments.
Args:
args: The arguments parsed from the command-line. | juraj-google-style |
def sampling_query(sql, context, fields=None, count=5, sampling=None, udfs=None, data_sources=None):
return Query(_sampling.Sampling.sampling_query(sql, fields, count, sampling), context=context, udfs=udfs, data_sources=data_sources) | Returns a sampling Query for the SQL object.
Args:
sql: the SQL statement (string) or Query object to sample.
context: a Context object providing project_id and credentials.
fields: an optional list of field names to retrieve.
count: an optional count of rows to retrieve which is used if a specific
sampling is not spe... | codesearchnet |
def filter_by_conditional_statement(self, statement):
_filt_values, _filt_datetimes = self._filter_by_statement(statement)
if self._enumeration is None:
self._get_mutable_enumeration()
col_obj = self._enumeration['mutable'][self._collection_type]
collection = col_obj... | Filter the Data Collection based on a conditional statement.
Args:
statement: A conditional statement as a string (e.g. a > 25 and a%5 == 0).
The variable should always be named as 'a' (without quotations).
Return:
A new Data Collection containing only the filtered data | juraj-google-style |
class API:
def __init__(self, config, api):
self.config = config
self.api = api['api']
self.version = api['version']
self.auth = api['auth']
self.uri = api.get('uri')
self.key = api.get('key')
self.labels = api.get('labels')
self.function_stack = list... | A wrapper around Google API with built in helpers for StarThinker.
The wrapper mimics function calls, storing the m in a stack, until it
encounters
execute(). Then it uses the stored stack and arguments to call the actual
API.
This allows handlers on execute such as API_Retry and API_Iterator.
See module level descr... | github-repos |
def spliceext(filepath, s):
(root, ext) = os.path.splitext(safepath(filepath))
return ((root + s) + ext) | Add s into filepath before the extension
Args:
filepath (str, path): file path
s (str): string to splice
Returns:
str | codesearchnet |
def __init__(self, json_data=None, **kwargs):
if isinstance(json_data, OhPickle):
return
if isinstance(json_data, basestring):
json_data = json.loads(json_data)
if json_data is not None:
kwargs = type(self).json_to_initkwargs(json_data, kwargs)
... | Build a new JsonRecord sub-class.
Args:
``json_data=``\ *LIST|other*
JSON data (string or already ``json.loads``'d)
``**kwargs``
Other initializer attributes, for lists with extra
attributes (eg, paging information) | juraj-google-style |
def __init__(self, url_formatter, mapsources):
super().__init__(url_formatter)
self.map_folders = {
root: {
"folders": folders,
"maps": maps
} for root, folders, maps in walk_mapsources(mapsources)
}
self.add_maps(parent=se... | Create a KML master document.
Args:
mapsources (list of MapSource): | juraj-google-style |
def _from_to_as_term(self, frm, to):
from_year = ''
to_year = ''
def year_or_empty(prefix, year, suffix):
try:
return prefix + str(int(year)) + suffix
except (ValueError, TypeError):
return ''
... | Turns from and to into the query format.
Args:
frm (str): from year
to (str): to year
Returns:
FTS query str with years range. | juraj-google-style |
def _generate_splits(self, m, r):
new_rects = []
if r.left > m.left:
new_rects.append(Rectangle(m.left, m.bottom, r.left-m.left, m.height))
if r.right < m.right:
new_rects.append(Rectangle(r.right, m.bottom, m.right-r.right, m.height))
if r.top <... | When a rectangle is placed inside a maximal rectangle, it stops being one
and up to 4 new maximal rectangles may appear depending on the placement.
_generate_splits calculates them.
Arguments:
m (Rectangle): max_rect rectangle
r (Rectangle): rectangle placed
Returns:
list : list containing new maximal rectangles or a... | juraj-google-style |
def enable_preset_args(include_all_preset_kwargs: bool=False, preset_name: str='global') -> Callable[[types.FunctionType], types.FunctionType]:
def decorator(func):
sig = inspect.signature(func)
positional_arg_names = [p.name for p in sig.parameters.values() if p.kind == inspect.Parameter.POSITIONA... | Decorator for functions that maybe use preset argument values.
Usage::
@pg.typing.enable_preset_args
def foo(x, y=pg.typing.PresetArgValue(default=1)):
return x + y
with pg.typing.preset_args(y=2):
print(foo(x=1)) # 3: y=2
print(foo(x=1)) # 2: y=1
Args:
include_all_preset_kwargs: Whether to include all preset kwa... | github-repos |
def _ParseIdentifierMappingsTable(self, parser_mediator, esedb_table):
identifier_mappings = {}
for esedb_record in esedb_table.records:
if parser_mediator.abort:
break
(identifier, mapped_value) = self._ParseIdentifierMappingRecord(parser_mediator, esedb_table.name, esedb_record)
... | Extracts identifier mappings from the SruDbIdMapTable table.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
esedb_table (pyesedb.table): table.
Returns:
dict[int, str]: mapping of numeric identifiers to their string
representation. | codesearchnet |
def plot_seebeck_temp(self, doping='all', output='average'):
import matplotlib.pyplot as plt
if (output == 'average'):
sbk = self._bz.get_seebeck(output='average')
elif (output == 'eigs'):
sbk = self._bz.get_seebeck(output='eigs')
plt.figure(figsize=(22, 14))
tlist = sorted(sbk['n'].... | Plot the Seebeck coefficient in function of temperature for different
doping levels.
Args:
dopings: the default 'all' plots all the doping levels in the analyzer.
Specify a list of doping levels if you want to plot only some.
output: with 'average' you get an average of the three directions
with 'eigs' you get all the... | codesearchnet |
def feature_path(self, gff_path):
if not gff_path:
self.feature_dir = None
self.feature_file = None
else:
if not op.exists(gff_path):
raise OSError('{}: file does not exist!'.format(gff_path))
if not op.dirname(gff_path):
... | Load a GFF file with information on a single sequence and store features in the ``features`` attribute
Args:
gff_path: Path to GFF file. | juraj-google-style |
def __init__(self, resolver_context):
super(TSKPartitionFile, self).__init__(resolver_context)
self._file_system = None | Initializes a file-like object.
Args:
resolver_context (Context): resolver context. | juraj-google-style |
def run(self, input_dir, output_dir, epsilon):
print('Running attack ', self.name)
cmd = [self.docker_binary(), 'run',
'-v', '{0}:/input_images'.format(input_dir),
'-v', '{0}:/output_images'.format(output_dir),
'-v', '{0}:/code'.format(self.directory),
'-w', '/co... | Runs attack inside Docker.
Args:
input_dir: directory with input (dataset).
output_dir: directory where output (adversarial images) should be written.
epsilon: maximum allowed size of adversarial perturbation,
should be in range [0, 255]. | juraj-google-style |
def __init__(self, inputs, mesh=None, name=None):
if mesh is None:
if not inputs:
raise ValueError("mesh must be specified if no inputs")
mesh = inputs[0].mesh
self._inputs = inputs
self._outputs = []
self._mesh = mesh
self._splittable_dims, self._unsplittable_dims = (
... | Initializer.
Args:
inputs: a list of Tensor
mesh: an optional Mesh (if unspecified, will be inferred from first input)
name: a string, which will get uniquified (in TensorFlow style)
Raises:
ValueError: mesh was not provided and there were no inputs to infer from. | juraj-google-style |
def frame_counts(self,subsets=None):
mergeon = self.cdf.frame_columns+['region_label']
if subsets is None:
cnts = self.groupby(mergeon+['phenotype_label']).count()[['cell_index']].\
rename(columns={'cell_index':'count'})
mr = self.measured_regions
... | Frame counts is the core of all the counting operations. It counts on a per-frame/per-region basis.
Args:
subsets (list): a list of Subset Objects. if not specified, the phenotypes are used.
Returns:
pandas.DataFrame: A dataframe of count data | juraj-google-style |
def CheckDefaultLambdaCaptures(filename, clean_lines, linenum, error):
line = clean_lines.elided[linenum]
match = Match(r'^(.*)\[\s*(?:=|&[^\w])', line)
if match:
line, _, pos = CloseExpression(clean_lines, linenum, len(match.group(1)))
if pos >= 0 and Match(r'^\s*[{(]', line[pos:... | Check that default lambda captures are not used.
Args:
filename: The name of the current file.
clean_lines: A CleansedLines instance containing the file.
linenum: The number of the line to check.
error: The function to call with any errors found. | juraj-google-style |
def find_all(self, model_class, params={}):
url = '{host}/{namespace}/{model}{params}'.format(host=self._host, namespace=self._namespace, model=self._translate_name(model_class.__name__), params=self._build_param_string(params))
data = self._get_json(url)['data']
fresh_models = []
for item in data:
... | Return an list of models from the API and caches the result.
Args:
model_class (:class:`cinder_data.model.CinderModel`): A subclass of
:class:`cinder_data.model.CinderModel` of your chosen model.
params (dict, optional): Description
Returns:
list: A list of instances of you model_class or and empty list. | codesearchnet |
def range_index_map(batch_shape, num_segments, name='range_index_map'):
device = num_segments.device if torch.is_tensor(num_segments) else 'cpu'
batch_shape = torch.as_tensor(batch_shape, dtype=torch.long, device=device)
assert len(batch_shape.size()) == 1
num_segments = torch.as_tensor(num_segments, de... | Constructs an index map equal to range(num_segments).
Args:
batch_shape (`torch.Size`):
Batch shape
num_segments (`int`):
Number of segments
name (`str`, *optional*, defaults to 'range_index_map'):
Name for the operation. Currently not used
Returns:
(`IndexMap`): IndexMap of shape batch_shape with elements equal to r... | github-repos |
def calculate_hashes(self):
hashers = []
if (not self.mardata.signatures):
return []
for s in self.mardata.signatures.sigs:
h = make_hasher(s.algorithm_id)
hashers.append((s.algorithm_id, h))
for block in get_signature_data(self.fileobj, self.mardata.signatures.filesize):
... | Return hashes of the contents of this MAR file.
The hashes depend on the algorithms defined in the MAR file's signature block.
Returns:
A list of (algorithm_id, hash) tuples | codesearchnet |
def _create_partition_config(option: t.Tuple, config: Config) -> Config:
copy = cp.deepcopy(config.selection)
out = cp.deepcopy(config)
for idx, key in enumerate(config.partition_keys):
copy[key] = [option[idx]]
if 'hdate' in copy:
copy['hdate'] = [generate_hdate(copy['date'][0], v) for ... | Create a config for a single partition option.
Output a config dictionary, overriding the range of values for
each key with the partition instance in 'selection'.
Continuing the example from prepare_partitions, the selection section
would be:
{ 'foo': ..., 'year': ['2020'], 'month': ['01'], ... }
{ 'foo': ..., 'year':... | github-repos |
def from_nested_row_lengths(cls, flat_values, nested_row_lengths, name=None, validate=True):
if not isinstance(validate, bool):
raise TypeError(f'Argument `validate` must have type bool. Received {validate}.')
if isinstance(nested_row_lengths, tensor_lib.Tensor):
raise TypeError(f'Argument `nest... | Creates a `RaggedTensor` from a nested list of `row_lengths` tensors.
Equivalent to:
```python
result = flat_values
for row_lengths in reversed(nested_row_lengths):
result = from_row_lengths(result, row_lengths)
```
Args:
flat_values: A potentially ragged tensor.
nested_row_lengths: A list of 1-D integer tensors. T... | github-repos |
def record(self, auth, resource, entries, options={}, defer=False):
return self._call('record', auth, [resource, entries, options], defer) | Records a list of historical entries to the resource specified.
Note: This API is depricated, use recordbatch instead.
Calls a function that bulids a request that writes a list of historical entries to the
specified resource.
Args:
auth: Takes the device cik
resource: Takes the dataport alias or rid.
entries: A list... | juraj-google-style |
def logs_urlpatterns(admin_view=lambda x: x):
return [
url(r'^$',
admin_view(LogsMenu.as_view()),
name='logs'),
url(r'^status_codes$',
admin_view(LogsStatusCodes.as_view()),
name='logs_status_codes'),
url(r'^status_codes_by_date$',
... | Return the URL patterns for the logs views.
Args:
admin_view (callable): admin_view method from an AdminSite instance.
Returns:
list: the URL patterns for the logs views. | juraj-google-style |
def get_user_groups(name, sid=False):
if (name == 'SYSTEM'):
groups = [name]
else:
groups = win32net.NetUserGetLocalGroups(None, name)
if (not sid):
return groups
ret_groups = set()
for group in groups:
ret_groups.add(get_sid_from_name(group))
return ret_groups | Get the groups to which a user belongs
Args:
name (str): The user name to query
sid (bool): True will return a list of SIDs, False will return a list of
group names
Returns:
list: A list of group names or sids | codesearchnet |
def autocov(x):
acorr = autocorr(x)
varx = ((np.var(x, ddof=1) * (len(x) - 1)) / len(x))
acov = (acorr * varx)
return acov | Compute autocovariance estimates for every lag for the input array.
Args:
x (array-like): An array containing MCMC samples.
Returns:
np.ndarray: An array of the same size as the input array. | codesearchnet |
def lint(cls, document, is_saved, flags=''):
if (not is_saved):
return cls.last_diags[document.path]
path = document.path
if sys.platform.startswith('win'):
path = path.replace('\\', '/')
(out, _err) = py_run('{} -f json {}'.format(path, flags), return_std=True)
json_str = out.getval... | Plugin interface to pyls linter.
Args:
document: The document to be linted.
is_saved: Whether or not the file has been saved to disk.
flags: Additional flags to pass to pylint. Not exposed to
pyls_lint, but used for testing.
Returns:
A list of dicts with the following format:
{
'source': 'pylint',
'range': {
'start'... | codesearchnet |
def validate_source_dir(script, directory):
if directory:
if not os.path.isfile(os.path.join(directory, script)):
raise ValueError('No file named "{}" was found in directory "{}".'.format(script, directory))
return True | Validate that the source directory exists and it contains the user script
Args:
script (str): Script filename.
directory (str): Directory containing the source file.
Raises:
ValueError: If ``directory`` does not exist, is not a directory, or does not contain ``script``. | juraj-google-style |
def __convertIp6PrefixStringToIp6Address(self, strIp6Prefix):
prefix1 = strIp6Prefix.rstrip('L')
prefix2 = prefix1.lstrip("0x")
hexPrefix = str(prefix2).ljust(16,'0')
hexIter = iter(hexPrefix)
finalMac = ':'.join(a + b + c + d for a,b,c,d in zip(hexIter, hexIter,hexIter,... | convert IPv6 prefix string to IPv6 dotted-quad format
for example:
2001000000000000 -> 2001::
Args:
strIp6Prefix: IPv6 address string
Returns:
IPv6 address dotted-quad format | juraj-google-style |
def nb_fit(data, P_init=None, R_init=None, epsilon=1e-8, max_iters=100):
means = data.mean(1)
variances = data.var(1)
if (means > variances).any():
raise ValueError("For NB fit, means must be less than variances")
genes, cells = data.shape
P = 1.0 - means/variances
R = means*(1... | Fits the NB distribution to data using method of moments.
Args:
data (array): genes x cells
P_init (array, optional): NB success prob param - genes x 1
R_init (array, optional): NB stopping param - genes x 1
Returns:
P, R - fit to data | juraj-google-style |
def yield_batch(iterable, batch_size, num_tensors=1):
tensors = [[] for i in range(num_tensors)]
for item in iterable:
if item is None:
break
for i in range(num_tensors):
tmp = str(item[i]) if type(item[i]) is bytearray else item[i]
tensors[i].append(tmp)
if len(tensors[0]) >= batch... | Generator that yields batches of a DataFrame iterator.
Args:
:iterable: Spark partition iterator.
:batch_size: number of items to retrieve per invocation.
:num_tensors: number of tensors (columns) expected in each item.
Returns:
An array of ``num_tensors`` arrays, each of length `batch_size` | juraj-google-style |
def count(self, axis=0, level=None, numeric_only=False):
axis = self._get_axis_number(axis) if axis is not None else 0
return self._reduce_dimension(
self._query_compiler.count(
axis=axis, level=level, numeric_only=numeric_only
)
) | Get the count of non-null objects in the DataFrame.
Arguments:
axis: 0 or 'index' for row-wise, 1 or 'columns' for column-wise.
level: If the axis is a MultiIndex (hierarchical), count along a
particular level, collapsing into a DataFrame.
numeric_only: Include only float, int, boolean data
Returns:
The count, in a S... | juraj-google-style |
def get_metadata(self, key) -> str:
return (self.metadata[key] if (key in self.metadata) else None) | Get the value of a metadata. Returns None if metadata does not exist.
Args:
key (str): name of the metadata
Returns:
str: the value of the metadata (or None) | codesearchnet |
def normalize_log_line_timestamp(log_line_timestamp):
return sanitize_filename(log_line_timestamp) | Replace special characters in log line timestamp with normal characters.
.. deprecated:: 1.10
This method is obsolete with the more general `sanitize_filename` method
and is only kept for backwards compatibility. In a future update, this
method may be removed.
Args:
log_line_timestamp: A string in the log line times... | github-repos |
def GetHashers(cls, hasher_names):
hashers = []
for (hasher_name, hasher_class) in iter(cls._hasher_classes.items()):
if (hasher_name in hasher_names):
hashers.append(hasher_class())
return hashers | Retrieves instances for all the specified hashers.
Args:
hasher_names (list[str]): names of the hashers to retrieve.
Returns:
list[BaseHasher]: hashers. | codesearchnet |
def operator(name=None, operators=None, aliases=None, kind=None):
def delegator(assertion, subject, expected, *args, **kw):
return assertion.test(subject, expected, *args, **kw)
def decorator(fn):
operator = Operator(fn=fn, aliases=aliases, kind=kind)
_name = (name if isinstance(name, ... | Registers a new operator function in the test engine.
Arguments:
*args: variadic arguments.
**kw: variadic keyword arguments.
Returns:
function | codesearchnet |
def addAllowMAC(self, xEUI):
print '%s call addAllowMAC' % self.port
print xEUI
if isinstance(xEUI, str):
macAddr = xEUI
else:
macAddr = self.__convertLongToString(xEUI)
try:
if self._addressfilterMode != 'whitelist':
... | add a given extended address to the whitelist addressfilter
Args:
xEUI: a given extended address in hex format
Returns:
True: successful to add a given extended address to the whitelist entry
False: fail to add a given extended address to the whitelist entry | juraj-google-style |
def build_example(label, param_dict_real, zip_path_label):
np.random.seed(RANDOM_SEED)
report = {'tflite_converter': report_lib.NOTRUN, 'tf': report_lib.FAILED}
report['tf_log'] = ''
report['tflite_converter_log'] = ''
tf.compat.v1.reset_default_graph()
with tf.Graph().as_default():
with... | Build the model with parameter values set in param_dict_real.
Args:
label: Label of the model
param_dict_real: Parameter dictionary (arguments to the factories
make_graph and make_test_inputs)
zip_path_label: Filename in the zip
Returns:
(tflite_model_binary, report) where tflite_model_binary is the
serialized flatbu... | github-repos |
def tokenize(self, text: TextInput, **kwargs) -> list[str]:
split_special_tokens = kwargs.pop('split_special_tokens', self.split_special_tokens)
text, kwargs = self.prepare_for_tokenization(text, **kwargs)
if kwargs:
logger.warning(f'Keyword arguments {kwargs} not recognized.')
if hasattr(self, ... | Converts a string into a sequence of tokens, using the tokenizer.
Split in words for word-based vocabulary or sub-words for sub-word-based vocabularies
(BPE/SentencePieces/WordPieces). Takes care of added tokens.
Args:
text (`str`):
The sequence to be encoded.
**kwargs (additional keyword arguments):
Passed along to ... | github-repos |
def new_reviewer(self, name, anomalous=None):
n = self._reviewer_cls(
self, name=name, credibility=self.credibility, anomalous=anomalous)
self.graph.add_node(n)
self.reviewers.append(n)
return n | Create a new reviewer.
Args:
name: name of the new reviewer.
anomalous: initial anomalous score. (default: None)
Returns:
A new reviewer instance. | juraj-google-style |
def box_area(boxes: Tensor) -> Tensor:
boxes = _upcast(boxes)
return (boxes[:, 2] - boxes[:, 0]) * (boxes[:, 3] - boxes[:, 1]) | Computes the area of a set of bounding boxes, which are specified by its (x1, y1, x2, y2) coordinates.
Args:
boxes (`torch.FloatTensor` of shape `(number_of_boxes, 4)`):
Boxes for which the area will be computed. They are expected to be in (x1, y1, x2, y2) format with `0 <= x1
< x2` and `0 <= y1 < y2`.
Returns:
`torc... | github-repos |
def __init__(self, model, generation_config: GenerationConfig, manual_eviction: bool=False, max_queue_size=0, streaming: bool=True):
self.model = model
self.generation_config = generation_config
self.input_queue = queue.Queue(maxsize=max_queue_size)
self.output_queue = queue.Queue()
self.stop_event ... | Initialize the continuous batching manager.
Args:
model: The language model for generation
generation_config: Configuration for generation parameters
max_queue_size: Maximum size of the request queue (0 = unlimited)
streaming: Whether to stream tokens as they are generated | github-repos |
def _IsMetadataFile(self, file_entry):
if (file_entry.type_indicator == dfvfs_definitions.TYPE_INDICATOR_TSK and
file_entry.path_spec.location in self._METADATA_FILE_LOCATIONS_TSK):
return True
return False | Determines if the file entry is a metadata file.
Args:
file_entry (dfvfs.FileEntry): a file entry object.
Returns:
bool: True if the file entry is a metadata file. | juraj-google-style |
def list_storage_accounts_sub(access_token, subscription_id):
endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/providers/Microsoft.Storage/storageAccounts', '?api-version=', STORAGE_API])
return do_get(endpoint, access_token) | List the storage accounts in the specified subscription.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
Returns:
HTTP response. JSON body list of storage accounts. | codesearchnet |
def __str__(self):
return self.str_internal() | Generates a useful string for this object.
Compactly displays interesting fields. In particular, pickled
fields are not displayed. Note that we collapse the fields of the
contained Worker* object into this object, since there is a 1-1
mapping between Operation and operation_specs.Worker*.
Returns:
Compact string re... | github-repos |
def _broadcast(value, target):
return tf.broadcast_to(
tf.convert_to_tensor(value=value, dtype=target.dtype),
distribution_util.prefer_static_shape(target)[:-1]) | Broadcast a value to match the batching dimensions of a target.
If necessary the value is converted into a tensor. Both value and target
should be of the same dtype.
Args:
value: A value to broadcast.
target: A `Tensor` of shape [b1, ..., bn, d].
Returns:
A `Tensor` of shape [b1, ..., bn] and same dtype as the targe... | juraj-google-style |
def get_section_header(self, section):
self._ensure_section_headers_loaded()
if type(section) is int:
return self._section_headers_by_index[section]
else:
return self._section_headers_by_name[section] | Get a specific section header by index or name.
Args:
section(int or str): The index or name of the section header to return.
Returns:
:class:`~ELF.SectionHeader`: The section header.
Raises:
KeyError: The requested section header does not exist. | juraj-google-style |
def write(self, output_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):
local_buffer = utils.BytearrayStream()
if self._object_type:
self._object_type.write(local_buffer, kmip_version=kmip_version)
else:
raise exceptions.InvalidField('The DeriveKey request payload is missing the object type... | Write the data encoding the DeriveKey request payload to a stream.
Args:
output_buffer (stream): A data stream in which to encode object
data, supporting a write method; usually a BytearrayStream
object.
kmip_version (KMIPVersion): An enumeration defining the KMIP
version with which the object will be encoded. Optiona... | codesearchnet |
def edge(self, tail_name, head_name, label=None, _attributes=None, **attrs):
tail_name = self._quote_edge(tail_name)
head_name = self._quote_edge(head_name)
attr_list = self._attr_list(label, attrs, _attributes)
line = self._edge % (tail_name, head_name, attr_list)
self.... | Create an edge between two nodes.
Args:
tail_name: Start node identifier.
head_name: End node identifier.
label: Caption to be displayed near the edge.
attrs: Any additional edge attributes (must be strings). | juraj-google-style |
def f():
return constant_op.constant(1) | First sentence.
Second sentence.
Returns:
Something. | github-repos |
def set_precision(predictions, labels,
weights_fn=common_layers.weights_nonzero):
with tf.variable_scope("set_precision", values=[predictions, labels]):
labels = tf.squeeze(labels, [2, 3])
weights = weights_fn(labels)
labels = tf.one_hot(labels, predictions.shape[-1])
labels = tf.... | Precision of set predictions.
Args:
predictions : A Tensor of scores of shape [batch, nlabels].
labels: A Tensor of int32s giving true set elements,
of shape [batch, seq_length].
weights_fn: A function to weight the elements.
Returns:
hits: A Tensor of shape [batch, nlabels].
weights: A Tensor of shape [batch, nlabel... | juraj-google-style |
def kaiser_sinc_filter1d(cutoff, half_width, kernel_size):
is_even = kernel_size % 2 == 0
half_size = kernel_size
delta_f = 4 * half_width
attenuation = 2.285 * (half_size - 1) * math.pi * delta_f + 7.95
if attenuation > 50.0:
beta = 0.1102 * (attenuation - 8.7)
elif attenuation >= 21.0... | Generates a 1D Kaiser-windowed sinc filter.
Args:
cutoff (float): Normalized cutoff frequency (0 to 0.5).
half_width (float): Transition bandwidth.
kernel_size (int): Number of filter taps.
Returns:
torch.Tensor: A tensor of shape (1, 1, kernel_size) representing the filter. | github-repos |
def transform(self, X, y=None):
word_ids = [self._word_vocab.doc2id(doc) for doc in X]
word_ids = pad_sequences(word_ids, padding='post')
if self._use_char:
char_ids = [[self._char_vocab.doc2id(w) for w in doc] for doc in X]
char_ids = pad_nested_sequences(char_... | Transform documents to document ids.
Uses the vocabulary learned by fit.
Args:
X : iterable
an iterable which yields either str, unicode or file objects.
y : iterabl, label strings.
Returns:
features: document id matrix.
y: label id matrix. | juraj-google-style |
def __init__(self, caption, content, enabled=True):
self._caption = caption
self._content = content
self._enabled = enabled | Menu constructor.
TODO(cais): Nested menu is currently not supported. Support it.
Args:
caption: (str) caption of the menu item.
content: Content of the menu item. For a menu item that triggers
a command, for example, content is the command string.
enabled: (bool) whether this menu item is enabled. | github-repos |
def period_neighborhood_probability(self, radius, smoothing, threshold, stride, start_time, end_time):
neighbor_x = self.x[(::stride, ::stride)]
neighbor_y = self.y[(::stride, ::stride)]
neighbor_kd_tree = cKDTree(np.vstack((neighbor_x.ravel(), neighbor_y.ravel())).T)
neighbor_prob = np.zeros((self.data... | Calculate the neighborhood probability over the full period of the forecast
Args:
radius: circular radius from each point in km
smoothing: width of Gaussian smoother in km
threshold: intensity of exceedance
stride: number of grid points to skip for reduced neighborhood grid
Returns:
(neighborhood probabilities) | codesearchnet |
def generic_object_comparison(lhs, rhs, lhs_path, rhs_path, max_depth):
if id(lhs) == id(rhs):
return 0
if type(lhs) != type(rhs):
return compare(str(type(lhs)), str(type(rhs)))
if type(lhs) in [int, float, bool, str, bool, bytes, bytearray]:
return compare(lhs, rhs)
if isinstanc... | Identifies which object goes first in an (almost) total order of objects.
Args:
lhs: An arbitrary Python object or built-in type.
rhs: An arbitrary Python object or built-in type.
lhs_path: Traversal path from the root lhs object up to, but not including,
lhs. The original contents of lhs_path are restored before the ... | github-repos |
def publish(self, subject, msg, reply=None):
if msg is None:
msg = ''
if reply is None:
command = 'PUB %s %d' % (subject, len(msg))
else:
command = 'PUB %s %s %d' % (subject, reply, len(msg))
self._send(command)
self._send(msg) | Publish publishes the data argument to the given subject.
Args:
subject (string): a string with the subject
msg (string): payload string
reply (string): subject used in the reply | juraj-google-style |
def remove_alias(type_):
if isinstance(type_, cpptypes.type_t):
type_ref = type_
elif isinstance(type_, typedef.typedef_t):
type_ref = type_.decl_type
else:
return type_
if type_ref.cache.remove_alias:
return type_ref.cache.remove_alias
no_alias = __remove_alias(type_... | Returns `type_t` without typedef
Args:
type_ (type_t | declaration_t): type or declaration
Returns:
type_t: the type associated to the inputted declaration | codesearchnet |
def _check_id(entity, entity_type):
if entity is None:
raise ParseError('{} ID missing'.format(entity_type))
elif not isinstance(entity, string_types):
msg = '{} ID must be a string, id was {}.'.format(entity_type, entity)
if isinstance(entity, bool):
msg += (' You may ... | Check whether the ID is valid.
First check if the ID is missing, and then check if it is a qualified
string type, finally check if the string is empty. For all checks, it
would raise a ParseError with the corresponding message.
Args:
entity: a string type object to be checked.
entity_type: a string that shows the typ... | juraj-google-style |
def pauli_from_char(ch, n=0):
ch = ch.upper()
if (ch == 'I'):
return I
if (ch == 'X'):
return X(n)
if (ch == 'Y'):
return Y(n)
if (ch == 'Z'):
return Z(n)
raise ValueError('ch shall be X, Y, Z or I') | Make Pauli matrix from an character.
Args:
ch (str): "X" or "Y" or "Z" or "I".
n (int, optional): Make Pauli matrix as n-th qubits.
Returns:
If ch is "X" => X, "Y" => Y, "Z" => Z, "I" => I
Raises:
ValueError: When ch is not "X", "Y", "Z" nor "I". | codesearchnet |
def match_variables(self, pattern, return_type='name'):
pattern = re.compile(pattern)
vars_ = [v for v in self.variables.values() if pattern.search(v.name)]
return vars_ if return_type.startswith('var') \
else [v.name for v in vars_] | Return columns whose names match the provided regex pattern.
Args:
pattern (str): A regex pattern to match all variable names against.
return_type (str): What to return. Must be one of:
'name': Returns a list of names of matching variables.
'variable': Returns a list of Variable objects whose names
match. | juraj-google-style |
def _create_controller_info_record(self, controller_module_name):
module = self._controller_modules[controller_module_name]
controller_info = None
try:
controller_info = module.get_info(copy.copy(self._controller_objects[controller_module_name]))
except AttributeError:
logging.warning('N... | Creates controller info record for a particular controller type.
Info is retrieved from all the controller objects spawned from the
specified module, using the controller module's `get_info` function.
Args:
controller_module_name: string, the name of the controller module
to retrieve info from.
Returns:
A records.Co... | codesearchnet |
def returnListOfConfigurationValues(util):
VALUES = {}
configPath = os.path.join(getConfigPath()["appPath"], "general.cfg")
if not os.path.exists(configPath):
defaultConfigPath = os.path.join(getConfigPath()["appPathDefaults"], "general.cfg")
try:
... | Method that recovers the configuration information about each program
TODO: Grab the default file from the package data instead of storing it in
the main folder.
Args:
-----
util: Any of the utils that are contained in the framework: domainfy,
entify, mailfy, phonefy, searchfy, usufy.
Returns:
--------
A dictionary ... | juraj-google-style |
def get_message(self, metadata=False, asctime=True):
msg = self.msg if is_string(self.msg) else str(self.msg)
if self.args:
try:
msg = msg % self.args
except:
msg += str(self.args)
if asctime: msg = "[" + self.asctime + "] " + msg... | Return the message after merging any user-supplied arguments with the message.
Args:
metadata: True if function and module name should be added.
asctime: True if time string should be added. | juraj-google-style |
def segmentation_to_mask(polys, height, width):
polys = [p.flatten().tolist() for p in polys]
assert len(polys) > 0, "Polygons are empty!"
import pycocotools.mask as cocomask
rles = cocomask.frPyObjects(polys, height, width)
rle = cocomask.merge(rles)
return cocomask.decode(rle) | Convert polygons to binary masks.
Args:
polys: a list of nx2 float array. Each array contains many (x, y) coordinates.
Returns:
a binary matrix of (height, width) | juraj-google-style |
def _build_document_scrapers(cls, session: AppSession):
html_parser = session.factory['HTMLParser']
element_walker = session.factory.new('ElementWalker')
scrapers = [session.factory.new('HTMLScraper', html_parser, element_walker, followed_tags=session.args.follow_tags, ignored_tags=session.args.ignore_tags,... | Create the document scrapers.
Returns:
A list of document scrapers | codesearchnet |
def _set_state(self, shard_state, tstate, task_directive):
if (task_directive in (self._TASK_DIRECTIVE.RETRY_TASK, self._TASK_DIRECTIVE.DROP_TASK)):
return task_directive
if (task_directive == self._TASK_DIRECTIVE.ABORT_SHARD):
shard_state.set_for_abort()
return task_directive
if (ta... | Set shard_state and tstate based on task_directive.
Args:
shard_state: model.ShardState for current shard.
tstate: model.TransientShardState for current shard.
task_directive: self._TASK_DIRECTIVE for current shard.
Returns:
A _TASK_DIRECTIVE enum.
PROCEED_TASK if task should proceed normally.
RETRY_SHARD if shard sh... | codesearchnet |
def add_multiple_to_queue(self, items, container=None):
if container is not None:
container_uri = container.resources[0].uri
container_metadata = to_didl_string(container)
else:
container_uri = ''
container_metadata = ''
chunk_size = ... | Add a sequence of items to the queue.
Args:
items (list): A sequence of items to the be added to the queue
container (DidlObject, optional): A container object which
includes the items. | juraj-google-style |
def create_from(cls, backend):
backend_config = backend.configuration()
try:
backend_default = backend.defaults()
except ModelValidationError:
from collections import namedtuple
BackendDefault = namedtuple('BackendDefault', ('qubit_freq_est'... | Create device specification with values in backend configuration.
Args:
backend(Backend): backend configuration
Returns:
DeviceSpecification: created device specification
Raises:
PulseError: when an invalid backend is specified | juraj-google-style |
def ParseDom(self, dom, feed):
shape_num = 0
for node in dom.getElementsByTagName('Placemark'):
p = self.ParsePlacemark(node)
if p.IsPoint():
(lon, lat) = p.coordinates[0]
m = self.stopNameRe.search(p.name)
feed.AddStop(lat, lon, m.group(1))
elif p.IsLine():
... | Parses the given kml dom tree and updates the Google transit feed object.
Args:
dom - kml dom tree
feed - an instance of Schedule class to be updated | juraj-google-style |
def reqAccountUpdatesMulti(
self, account: str = '', modelCode: str = ''):
self._run(self.reqAccountUpdatesMultiAsync(account, modelCode)) | It is recommended to use :meth:`.accountValues` instead.
Request account values of multiple accounts and keep updated.
This method is blocking.
Args:
account: If specified, filter for this account name.
modelCode: If specified, filter for this account model. | juraj-google-style |
def to_soft(self, path_or_handle, as_gzip=False):
if isinstance(path_or_handle, str):
if as_gzip:
with gzip.open(path_or_handle, 'wt') as outfile:
outfile.write(self._get_object_as_soft())
else:
with open(path_or_handle, 'w') as outfile:
outfil... | Save the object in a SOFT format.
Args:
path_or_handle (:obj:`str` or :obj:`file`): Path or handle to
output file
as_gzip (:obj:`bool`): Save as gzip | codesearchnet |
def cut_setting(self, cut):
cut_settings = {'full' : 0b00000001,
'half' : 0b00000010,
'chain': 0b00000100,
'special': 0b00001000
}
if cut in cut_settings:
self.send(chr(27)+'iC'+... | Set cut setting for printer.
Args:
cut: The type of cut setting we want. Choices are 'full', 'half', 'chain', and 'special'.
Returns:
None
Raises:
RuntimeError: Invalid cut type. | juraj-google-style |
def recode_curesim_reads(curesim_fastq_fo, rnf_fastq_fo, fai_fo, genome_id, number_of_read_tuples=(10 ** 9), recode_random=False):
curesim_pattern = re.compile('@(.*)_([0-9]+)_([0-9]+)_([0-9]+)_([0-9]+)_([0-9]+)_([0-9]+)_([0-9]+)')
'\n\t\t\tCuReSim read name format\n\n\t\t\t@<
max_seq_len = 0
fai_index ... | Recode CuReSim output FASTQ file to the RNF-compatible output FASTQ file.
Args:
curesim_fastq_fo (file object): File object of CuReSim FASTQ file.
fastq_rnf_fo (file object): File object of RNF FASTQ.
fai_fo (file object): File object for FAI file of the reference genome.
genome_id (int): RNF genome ID to be used.
num... | codesearchnet |
def _txn_is_in_valid_batch(self, txn_id):
batch = self._batches_by_txn_id[txn_id]
return all(
self._txn_results[sig].is_valid
for sig in set(self._txn_results).intersection(
(txn.header_signature for txn in batch.transactions))) | Returns whether the transaction is in a valid batch.
Args:
txn_id (str): The transaction header signature.
Returns:
(bool): True if the txn's batch is valid, False otherwise. | juraj-google-style |
def l2_distance_sq(t1, t2, name=None):
with tf.name_scope(name, 'l2_distance_sq', [t1, t2]) as scope:
t1 = tf.convert_to_tensor(t1, name='t1')
t2 = tf.convert_to_tensor(t2, name='t2')
return length_squared(tf.subtract(t1, t2), name=scope) | Square of l2 distance between t1 and t2.
Args:
t1: A tensor.
t2: A tensor that is the same size as t1.
name: Optional name for this op.
Returns:
The l2 distance between t1 and t2. | juraj-google-style |
def _allocate_channel(self):
try:
channel = (yield self.channel())
except pika.exceptions.NoFreeChannels:
raise NoFreeChannels()
_std_log.debug('Created AMQP channel id %d', channel.channel_number)
if self._confirms:
(yield channel.confirm_delivery())
defer.returnValue(channe... | Allocate a new AMQP channel.
Raises:
NoFreeChannels: If this connection has reached its maximum number of channels. | codesearchnet |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.